]> git.proxmox.com Git - mirror_edk2.git/commitdiff
More renames for Tool Packages
authorlhauch <lhauch@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 5 Oct 2006 23:16:50 +0000 (23:16 +0000)
committerlhauch <lhauch@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 5 Oct 2006 23:16:50 +0000 (23:16 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1675 6f19259b-4bc3-4df7-8a09-765794883524

553 files changed:
Tools/CodeTools/Source/Common/CommonLib.c [new file with mode: 0644]
Tools/CodeTools/Source/Common/CommonLib.h [new file with mode: 0644]
Tools/CodeTools/Source/Common/Crc32.c [new file with mode: 0644]
Tools/CodeTools/Source/Common/Crc32.h [new file with mode: 0644]
Tools/CodeTools/Source/Common/EfiCompress.c [new file with mode: 0644]
Tools/CodeTools/Source/Common/EfiCompress.h [new file with mode: 0644]
Tools/CodeTools/Source/Common/EfiCustomizedCompress.h [new file with mode: 0644]
Tools/CodeTools/Source/Common/EfiDecompress.c [new file with mode: 0644]
Tools/CodeTools/Source/Common/EfiDecompress.h [new file with mode: 0644]
Tools/CodeTools/Source/Common/EfiUtilityMsgs.c [new file with mode: 0644]
Tools/CodeTools/Source/Common/EfiUtilityMsgs.h [new file with mode: 0644]
Tools/CodeTools/Source/Common/FvLib.c [new file with mode: 0644]
Tools/CodeTools/Source/Common/FvLib.h [new file with mode: 0644]
Tools/CodeTools/Source/Common/MyAlloc.c [new file with mode: 0644]
Tools/CodeTools/Source/Common/MyAlloc.h [new file with mode: 0644]
Tools/CodeTools/Source/Common/ParseInf.c [new file with mode: 0644]
Tools/CodeTools/Source/Common/ParseInf.h [new file with mode: 0644]
Tools/CodeTools/Source/Common/SimpleFileParsing.c [new file with mode: 0644]
Tools/CodeTools/Source/Common/SimpleFileParsing.h [new file with mode: 0644]
Tools/CodeTools/Source/Common/WinNtInclude.h [new file with mode: 0644]
Tools/CodeTools/Source/Common/build.xml [new file with mode: 0644]
Tools/CodeTools/Source/CompressDll/CompressDll.c [new file with mode: 0644]
Tools/CodeTools/Source/CompressDll/CompressDll.h [new file with mode: 0644]
Tools/CodeTools/Source/CompressDll/build.xml [new file with mode: 0644]
Tools/CodeTools/Source/CreateMtFile/CreateMtFile.c [new file with mode: 0644]
Tools/CodeTools/Source/CreateMtFile/build.xml [new file with mode: 0644]
Tools/CodeTools/Source/CustomizedCompress/CustomizedCompress.c [new file with mode: 0644]
Tools/CodeTools/Source/CustomizedCompress/build.xml [new file with mode: 0644]
Tools/CodeTools/Source/EfiCompress/EfiCompressMain.c [new file with mode: 0644]
Tools/CodeTools/Source/EfiCompress/build.xml [new file with mode: 0644]
Tools/CodeTools/Source/EfiRom/EfiRom.c [new file with mode: 0644]
Tools/CodeTools/Source/EfiRom/build.xml [new file with mode: 0644]
Tools/CodeTools/Source/FlashMap/FlashDefFile.c [new file with mode: 0644]
Tools/CodeTools/Source/FlashMap/FlashDefFile.h [new file with mode: 0644]
Tools/CodeTools/Source/FlashMap/FlashMap.c [new file with mode: 0644]
Tools/CodeTools/Source/FlashMap/Microcode.c [new file with mode: 0644]
Tools/CodeTools/Source/FlashMap/Microcode.h [new file with mode: 0644]
Tools/CodeTools/Source/FlashMap/Symbols.c [new file with mode: 0644]
Tools/CodeTools/Source/FlashMap/Symbols.h [new file with mode: 0644]
Tools/CodeTools/Source/FlashMap/build.xml [new file with mode: 0644]
Tools/CodeTools/Source/FwImage/build.xml [new file with mode: 0644]
Tools/CodeTools/Source/FwImage/fwimage.c [new file with mode: 0644]
Tools/CodeTools/Source/GenAcpiTable/GenAcpiTable.c [new file with mode: 0644]
Tools/CodeTools/Source/GenAcpiTable/build.xml [new file with mode: 0644]
Tools/CodeTools/Source/GenCRC32Section/GenCRC32Section.c [new file with mode: 0644]
Tools/CodeTools/Source/GenCRC32Section/GenCRC32Section.h [new file with mode: 0644]
Tools/CodeTools/Source/GenCRC32Section/build.xml [new file with mode: 0644]
Tools/CodeTools/Source/GenCapsuleHdr/CreateGuid.c [new file with mode: 0644]
Tools/CodeTools/Source/GenCapsuleHdr/GenCapsuleHdr.c [new file with mode: 0644]
Tools/CodeTools/Source/GenCapsuleHdr/build.xml [new file with mode: 0644]
Tools/CodeTools/Source/GenDepex/DepexParser.c [new file with mode: 0644]
Tools/CodeTools/Source/GenDepex/DepexParser.h [new file with mode: 0644]
Tools/CodeTools/Source/GenDepex/GenDepex.c [new file with mode: 0644]
Tools/CodeTools/Source/GenDepex/GenDepex.h [new file with mode: 0644]
Tools/CodeTools/Source/GenDepex/build.xml [new file with mode: 0644]
Tools/CodeTools/Source/GenFfsFile/GenFfsFile.c [new file with mode: 0644]
Tools/CodeTools/Source/GenFfsFile/GenFfsFile.h [new file with mode: 0644]
Tools/CodeTools/Source/GenFfsFile/SimpleFileParsing.c [new file with mode: 0644]
Tools/CodeTools/Source/GenFfsFile/build.xml [new file with mode: 0644]
Tools/CodeTools/Source/GenFvImage/Ebc/PeCoffLoaderEx.c [new file with mode: 0644]
Tools/CodeTools/Source/GenFvImage/GenFvImageExe.c [new file with mode: 0644]
Tools/CodeTools/Source/GenFvImage/GenFvImageExe.h [new file with mode: 0644]
Tools/CodeTools/Source/GenFvImage/GenFvImageLib.c [new file with mode: 0644]
Tools/CodeTools/Source/GenFvImage/GenFvImageLib.h [new file with mode: 0644]
Tools/CodeTools/Source/GenFvImage/GenFvImageLibInternal.h [new file with mode: 0644]
Tools/CodeTools/Source/GenFvImage/build.xml [new file with mode: 0644]
Tools/CodeTools/Source/GenSection/GenSection.c [new file with mode: 0644]
Tools/CodeTools/Source/GenSection/GenSection.h [new file with mode: 0644]
Tools/CodeTools/Source/GenSection/build.xml [new file with mode: 0644]
Tools/CodeTools/Source/GenTEImage/GenTEImage.c [new file with mode: 0644]
Tools/CodeTools/Source/GenTEImage/build.xml [new file with mode: 0644]
Tools/CodeTools/Source/GuidChk/CommonUtils.h [new file with mode: 0644]
Tools/CodeTools/Source/GuidChk/FileSearch.c [new file with mode: 0644]
Tools/CodeTools/Source/GuidChk/FileSearch.h [new file with mode: 0644]
Tools/CodeTools/Source/GuidChk/GuidChk.c [new file with mode: 0644]
Tools/CodeTools/Source/GuidChk/GuidList.c [new file with mode: 0644]
Tools/CodeTools/Source/GuidChk/UtilsMsgs.c [new file with mode: 0644]
Tools/CodeTools/Source/GuidChk/UtilsMsgs.h [new file with mode: 0644]
Tools/CodeTools/Source/GuidChk/build.xml [new file with mode: 0644]
Tools/CodeTools/Source/Include/Common/BaseTypes.h [new file with mode: 0644]
Tools/CodeTools/Source/Include/Common/Capsule.h [new file with mode: 0644]
Tools/CodeTools/Source/Include/Common/Dependency.h [new file with mode: 0644]
Tools/CodeTools/Source/Include/Common/EfiImage.h [new file with mode: 0644]
Tools/CodeTools/Source/Include/Common/FirmwareFileSystem.h [new file with mode: 0644]
Tools/CodeTools/Source/Include/Common/FirmwareVolumeHeader.h [new file with mode: 0644]
Tools/CodeTools/Source/Include/Common/FirmwareVolumeImageFormat.h [new file with mode: 0644]
Tools/CodeTools/Source/Include/Common/InternalFormRepresentation.h [new file with mode: 0644]
Tools/CodeTools/Source/Include/Common/MultiPhase.h [new file with mode: 0644]
Tools/CodeTools/Source/Include/Common/UefiBaseTypes.h [new file with mode: 0644]
Tools/CodeTools/Source/Include/Common/Variable.h [new file with mode: 0644]
Tools/CodeTools/Source/Include/Common/WorkingBlockHeader.h [new file with mode: 0644]
Tools/CodeTools/Source/Include/Guid/AcpiTableStorage.h [new file with mode: 0644]
Tools/CodeTools/Source/Include/Guid/Apriori.h [new file with mode: 0644]
Tools/CodeTools/Source/Include/Guid/Capsule.h [new file with mode: 0644]
Tools/CodeTools/Source/Include/Guid/FirmwareFileSystem.h [new file with mode: 0644]
Tools/CodeTools/Source/Include/Ia32/ProcessorBind.h [new file with mode: 0644]
Tools/CodeTools/Source/Include/IndustryStandard/pci22.h [new file with mode: 0644]
Tools/CodeTools/Source/Include/Library/PeCoffLib.h [new file with mode: 0644]
Tools/CodeTools/Source/Include/Library/PrintLib.h [new file with mode: 0644]
Tools/CodeTools/Source/Include/Protocol/DevicePath.h [new file with mode: 0644]
Tools/CodeTools/Source/Include/Protocol/GuidedSectionExtraction.h [new file with mode: 0644]
Tools/CodeTools/Source/Include/Protocol/Hii.h [new file with mode: 0644]
Tools/CodeTools/Source/Include/Protocol/UgaDraw.h [new file with mode: 0644]
Tools/CodeTools/Source/Include/X64/ProcessorBind.h [new file with mode: 0644]
Tools/CodeTools/Source/MakeDeps/MakeDeps.c [new file with mode: 0755]
Tools/CodeTools/Source/MakeDeps/build.xml [new file with mode: 0755]
Tools/CodeTools/Source/ModifyInf/ModifyInf.c [new file with mode: 0755]
Tools/CodeTools/Source/ModifyInf/build.xml [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/CHANGES_FROM_131.txt [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/CHANGES_FROM_133.txt [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/CHANGES_FROM_133_BEFORE_MR13.txt [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/CHANGES_SUMMARY.txt [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/KNOWN_PROBLEMS.txt [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/MPW_Read_Me [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/NOTES.bcc [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/NOTES.msvc [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/README [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/RIGHTS [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/antlr/AntlrMS.mak [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/antlr/AntlrPPC.mak [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/antlr/README [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/antlr/antlr.1 [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/antlr/antlr.c [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/antlr/antlr.g [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/antlr/antlr.r [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/antlr/antlr1.txt [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/antlr/bits.c [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/antlr/build.c [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/antlr/build.xml [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/antlr/dumpcycles.c [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/antlr/dumpnode.c [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/antlr/egman.c [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/antlr/err.c [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/antlr/fcache.c [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/antlr/fset.c [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/antlr/fset2.c [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/antlr/gen.c [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/antlr/generic.h [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/antlr/globals.c [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/antlr/hash.c [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/antlr/hash.h [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/antlr/lex.c [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/antlr/main.c [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/antlr/makefile [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/antlr/makefile.cygwin [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/antlr/makefile1 [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/antlr/misc.c [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/antlr/mode.h [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/antlr/mrhoist.c [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/antlr/parser.dlg [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/antlr/pred.c [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/antlr/proto.h [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/antlr/scan.c [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/antlr/stdpccts.h [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/antlr/syn.h [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/antlr/tokens.h [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/build.xml [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/dlg/DlgMS.mak [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/dlg/DlgPPC.mak [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/dlg/automata.c [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/dlg/build.xml [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/dlg/dlg.1 [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/dlg/dlg.h [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/dlg/dlg.r [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/dlg/dlg1.txt [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/dlg/dlg_a.c [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/dlg/dlg_p.c [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/dlg/dlg_p.g [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/dlg/err.c [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/dlg/main.c [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/dlg/makefile [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/dlg/makefile.cygwin [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/dlg/makefile1 [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/dlg/mode.h [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/dlg/output.c [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/dlg/parser.dlg [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/dlg/relabel.c [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/dlg/stdpccts.h [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/dlg/support.c [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/dlg/tokens.h [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/h/AParser.cpp [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/h/AParser.h [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/h/ASTBase.cpp [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/h/ASTBase.h [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/h/ATokPtr.h [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/h/ATokPtrImpl.h [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/h/AToken.h [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/h/ATokenBuffer.cpp [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/h/ATokenBuffer.h [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/h/ATokenStream.h [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/h/BufFileInput.cpp [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/h/BufFileInput.h [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/h/DLG_stream_input.h [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/h/DLexer.h [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/h/DLexerBase.cpp [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/h/DLexerBase.h [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/h/PBlackBox.h [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/h/PCCTSAST.cpp [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/h/PCCTSAST.h [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/h/SList.h [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/h/antlr.h [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/h/ast.c [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/h/ast.h [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/h/charbuf.h [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/h/charptr.c [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/h/charptr.h [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/h/config.h [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/h/dlgauto.h [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/h/dlgdef.h [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/h/err.h [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/h/int.h [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/h/pccts_assert.h [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/h/pccts_iostream.h [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/h/pccts_istream.h [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/h/pccts_setjmp.h [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/h/pccts_stdarg.h [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/h/pccts_stdio.h [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/h/pccts_stdlib.h [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/h/pccts_string.h [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/h/pcctscfg.h [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/h/pcnames.bat [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/h/slist.cpp [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/history.ps [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/history.txt [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/makefile [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/support/genmk/genmk.c [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/support/genmk/genmk_old.c [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/support/genmk/makefile [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/support/rexpr/makefile [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/support/rexpr/rexpr.c [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/support/rexpr/rexpr.h [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/support/rexpr/test.c [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/support/set/set.c [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/support/set/set.h [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/support/sym/sym.c [new file with mode: 0644]
Tools/CodeTools/Source/Pccts/support/sym/template.h [new file with mode: 0644]
Tools/CodeTools/Source/PeCoffLoader/BasePeCoff.c [new file with mode: 0644]
Tools/CodeTools/Source/PeCoffLoader/Common/EfiImage.h [new file with mode: 0644]
Tools/CodeTools/Source/PeCoffLoader/Ia32/PeCoffLoaderEx.c [new file with mode: 0644]
Tools/CodeTools/Source/PeCoffLoader/Ipf/PeCoffLoaderEx.c [new file with mode: 0644]
Tools/CodeTools/Source/PeCoffLoader/X64/PeCoffLoaderEx.c [new file with mode: 0644]
Tools/CodeTools/Source/PeCoffLoader/build.xml [new file with mode: 0644]
Tools/CodeTools/Source/PeiRebase/PeiRebaseExe.c [new file with mode: 0644]
Tools/CodeTools/Source/PeiRebase/PeiRebaseExe.h [new file with mode: 0644]
Tools/CodeTools/Source/PeiRebase/build.xml [new file with mode: 0644]
Tools/CodeTools/Source/SecApResetVectorFixup/SecApResetVectorFixup.c [new file with mode: 0644]
Tools/CodeTools/Source/SecApResetVectorFixup/SecApResetVectorFixup.h [new file with mode: 0644]
Tools/CodeTools/Source/SecApResetVectorFixup/build.xml [new file with mode: 0644]
Tools/CodeTools/Source/SecFixup/SecFixup.c [new file with mode: 0644]
Tools/CodeTools/Source/SecFixup/SecFixup.h [new file with mode: 0644]
Tools/CodeTools/Source/SecFixup/build.xml [new file with mode: 0644]
Tools/CodeTools/Source/SetStamp/SetStamp.c [new file with mode: 0644]
Tools/CodeTools/Source/SetStamp/build.xml [new file with mode: 0644]
Tools/CodeTools/Source/SplitFile/SplitFile.c [new file with mode: 0644]
Tools/CodeTools/Source/SplitFile/build.xml [new file with mode: 0644]
Tools/CodeTools/Source/StrGather/StrGather.c [new file with mode: 0644]
Tools/CodeTools/Source/StrGather/StrGather.h [new file with mode: 0644]
Tools/CodeTools/Source/StrGather/StringDB.c [new file with mode: 0644]
Tools/CodeTools/Source/StrGather/StringDB.h [new file with mode: 0644]
Tools/CodeTools/Source/StrGather/build.xml [new file with mode: 0644]
Tools/CodeTools/Source/String/PrintLib.c [new file with mode: 0644]
Tools/CodeTools/Source/String/PrintLibInternal.c [new file with mode: 0644]
Tools/CodeTools/Source/String/PrintLibInternal.h [new file with mode: 0644]
Tools/CodeTools/Source/String/String.c [new file with mode: 0644]
Tools/CodeTools/Source/String/build.xml [new file with mode: 0644]
Tools/CodeTools/Source/Strip/Strip.c [new file with mode: 0644]
Tools/CodeTools/Source/Strip/build.xml [new file with mode: 0644]
Tools/CodeTools/Source/TianoTools.msa [new file with mode: 0644]
Tools/CodeTools/Source/VfrCompile/EfiVfr.h [new file with mode: 0644]
Tools/CodeTools/Source/VfrCompile/VfrCompile.g [new file with mode: 0644]
Tools/CodeTools/Source/VfrCompile/VfrServices.cpp [new file with mode: 0644]
Tools/CodeTools/Source/VfrCompile/VfrServices.h [new file with mode: 0644]
Tools/CodeTools/Source/VfrCompile/build.xml [new file with mode: 0644]
Tools/CodeTools/Source/ZeroDebugData/ZeroDebugData.c [new file with mode: 0644]
Tools/CodeTools/Source/ZeroDebugData/build.xml [new file with mode: 0644]
Tools/CodeTools/Source/build.xml [new file with mode: 0644]
Tools/CodeTools/TianoTools/Common/CommonLib.c [deleted file]
Tools/CodeTools/TianoTools/Common/CommonLib.h [deleted file]
Tools/CodeTools/TianoTools/Common/Crc32.c [deleted file]
Tools/CodeTools/TianoTools/Common/Crc32.h [deleted file]
Tools/CodeTools/TianoTools/Common/EfiCompress.c [deleted file]
Tools/CodeTools/TianoTools/Common/EfiCompress.h [deleted file]
Tools/CodeTools/TianoTools/Common/EfiCustomizedCompress.h [deleted file]
Tools/CodeTools/TianoTools/Common/EfiDecompress.c [deleted file]
Tools/CodeTools/TianoTools/Common/EfiDecompress.h [deleted file]
Tools/CodeTools/TianoTools/Common/EfiUtilityMsgs.c [deleted file]
Tools/CodeTools/TianoTools/Common/EfiUtilityMsgs.h [deleted file]
Tools/CodeTools/TianoTools/Common/FvLib.c [deleted file]
Tools/CodeTools/TianoTools/Common/FvLib.h [deleted file]
Tools/CodeTools/TianoTools/Common/MyAlloc.c [deleted file]
Tools/CodeTools/TianoTools/Common/MyAlloc.h [deleted file]
Tools/CodeTools/TianoTools/Common/ParseInf.c [deleted file]
Tools/CodeTools/TianoTools/Common/ParseInf.h [deleted file]
Tools/CodeTools/TianoTools/Common/SimpleFileParsing.c [deleted file]
Tools/CodeTools/TianoTools/Common/SimpleFileParsing.h [deleted file]
Tools/CodeTools/TianoTools/Common/WinNtInclude.h [deleted file]
Tools/CodeTools/TianoTools/Common/build.xml [deleted file]
Tools/CodeTools/TianoTools/CompressDll/CompressDll.c [deleted file]
Tools/CodeTools/TianoTools/CompressDll/CompressDll.h [deleted file]
Tools/CodeTools/TianoTools/CompressDll/build.xml [deleted file]
Tools/CodeTools/TianoTools/CreateMtFile/CreateMtFile.c [deleted file]
Tools/CodeTools/TianoTools/CreateMtFile/build.xml [deleted file]
Tools/CodeTools/TianoTools/CustomizedCompress/CustomizedCompress.c [deleted file]
Tools/CodeTools/TianoTools/CustomizedCompress/build.xml [deleted file]
Tools/CodeTools/TianoTools/EfiCompress/EfiCompressMain.c [deleted file]
Tools/CodeTools/TianoTools/EfiCompress/build.xml [deleted file]
Tools/CodeTools/TianoTools/EfiRom/EfiRom.c [deleted file]
Tools/CodeTools/TianoTools/EfiRom/build.xml [deleted file]
Tools/CodeTools/TianoTools/FlashMap/FlashDefFile.c [deleted file]
Tools/CodeTools/TianoTools/FlashMap/FlashDefFile.h [deleted file]
Tools/CodeTools/TianoTools/FlashMap/FlashMap.c [deleted file]
Tools/CodeTools/TianoTools/FlashMap/Microcode.c [deleted file]
Tools/CodeTools/TianoTools/FlashMap/Microcode.h [deleted file]
Tools/CodeTools/TianoTools/FlashMap/Symbols.c [deleted file]
Tools/CodeTools/TianoTools/FlashMap/Symbols.h [deleted file]
Tools/CodeTools/TianoTools/FlashMap/build.xml [deleted file]
Tools/CodeTools/TianoTools/FwImage/build.xml [deleted file]
Tools/CodeTools/TianoTools/FwImage/fwimage.c [deleted file]
Tools/CodeTools/TianoTools/GenAcpiTable/GenAcpiTable.c [deleted file]
Tools/CodeTools/TianoTools/GenAcpiTable/build.xml [deleted file]
Tools/CodeTools/TianoTools/GenCRC32Section/GenCRC32Section.c [deleted file]
Tools/CodeTools/TianoTools/GenCRC32Section/GenCRC32Section.h [deleted file]
Tools/CodeTools/TianoTools/GenCRC32Section/build.xml [deleted file]
Tools/CodeTools/TianoTools/GenCapsuleHdr/CreateGuid.c [deleted file]
Tools/CodeTools/TianoTools/GenCapsuleHdr/GenCapsuleHdr.c [deleted file]
Tools/CodeTools/TianoTools/GenCapsuleHdr/build.xml [deleted file]
Tools/CodeTools/TianoTools/GenDepex/DepexParser.c [deleted file]
Tools/CodeTools/TianoTools/GenDepex/DepexParser.h [deleted file]
Tools/CodeTools/TianoTools/GenDepex/GenDepex.c [deleted file]
Tools/CodeTools/TianoTools/GenDepex/GenDepex.h [deleted file]
Tools/CodeTools/TianoTools/GenDepex/build.xml [deleted file]
Tools/CodeTools/TianoTools/GenFfsFile/GenFfsFile.c [deleted file]
Tools/CodeTools/TianoTools/GenFfsFile/GenFfsFile.h [deleted file]
Tools/CodeTools/TianoTools/GenFfsFile/SimpleFileParsing.c [deleted file]
Tools/CodeTools/TianoTools/GenFfsFile/build.xml [deleted file]
Tools/CodeTools/TianoTools/GenFvImage/Ebc/PeCoffLoaderEx.c [deleted file]
Tools/CodeTools/TianoTools/GenFvImage/GenFvImageExe.c [deleted file]
Tools/CodeTools/TianoTools/GenFvImage/GenFvImageExe.h [deleted file]
Tools/CodeTools/TianoTools/GenFvImage/GenFvImageLib.c [deleted file]
Tools/CodeTools/TianoTools/GenFvImage/GenFvImageLib.h [deleted file]
Tools/CodeTools/TianoTools/GenFvImage/GenFvImageLibInternal.h [deleted file]
Tools/CodeTools/TianoTools/GenFvImage/build.xml [deleted file]
Tools/CodeTools/TianoTools/GenSection/GenSection.c [deleted file]
Tools/CodeTools/TianoTools/GenSection/GenSection.h [deleted file]
Tools/CodeTools/TianoTools/GenSection/build.xml [deleted file]
Tools/CodeTools/TianoTools/GenTEImage/GenTEImage.c [deleted file]
Tools/CodeTools/TianoTools/GenTEImage/build.xml [deleted file]
Tools/CodeTools/TianoTools/GuidChk/CommonUtils.h [deleted file]
Tools/CodeTools/TianoTools/GuidChk/FileSearch.c [deleted file]
Tools/CodeTools/TianoTools/GuidChk/FileSearch.h [deleted file]
Tools/CodeTools/TianoTools/GuidChk/GuidChk.c [deleted file]
Tools/CodeTools/TianoTools/GuidChk/GuidList.c [deleted file]
Tools/CodeTools/TianoTools/GuidChk/UtilsMsgs.c [deleted file]
Tools/CodeTools/TianoTools/GuidChk/UtilsMsgs.h [deleted file]
Tools/CodeTools/TianoTools/GuidChk/build.xml [deleted file]
Tools/CodeTools/TianoTools/Include/Common/BaseTypes.h [deleted file]
Tools/CodeTools/TianoTools/Include/Common/Capsule.h [deleted file]
Tools/CodeTools/TianoTools/Include/Common/Dependency.h [deleted file]
Tools/CodeTools/TianoTools/Include/Common/EfiImage.h [deleted file]
Tools/CodeTools/TianoTools/Include/Common/FirmwareFileSystem.h [deleted file]
Tools/CodeTools/TianoTools/Include/Common/FirmwareVolumeHeader.h [deleted file]
Tools/CodeTools/TianoTools/Include/Common/FirmwareVolumeImageFormat.h [deleted file]
Tools/CodeTools/TianoTools/Include/Common/InternalFormRepresentation.h [deleted file]
Tools/CodeTools/TianoTools/Include/Common/MultiPhase.h [deleted file]
Tools/CodeTools/TianoTools/Include/Common/UefiBaseTypes.h [deleted file]
Tools/CodeTools/TianoTools/Include/Common/Variable.h [deleted file]
Tools/CodeTools/TianoTools/Include/Common/WorkingBlockHeader.h [deleted file]
Tools/CodeTools/TianoTools/Include/Guid/AcpiTableStorage.h [deleted file]
Tools/CodeTools/TianoTools/Include/Guid/Apriori.h [deleted file]
Tools/CodeTools/TianoTools/Include/Guid/Capsule.h [deleted file]
Tools/CodeTools/TianoTools/Include/Guid/FirmwareFileSystem.h [deleted file]
Tools/CodeTools/TianoTools/Include/Ia32/ProcessorBind.h [deleted file]
Tools/CodeTools/TianoTools/Include/IndustryStandard/pci22.h [deleted file]
Tools/CodeTools/TianoTools/Include/Library/PeCoffLib.h [deleted file]
Tools/CodeTools/TianoTools/Include/Library/PrintLib.h [deleted file]
Tools/CodeTools/TianoTools/Include/Protocol/DevicePath.h [deleted file]
Tools/CodeTools/TianoTools/Include/Protocol/GuidedSectionExtraction.h [deleted file]
Tools/CodeTools/TianoTools/Include/Protocol/Hii.h [deleted file]
Tools/CodeTools/TianoTools/Include/Protocol/UgaDraw.h [deleted file]
Tools/CodeTools/TianoTools/Include/X64/ProcessorBind.h [deleted file]
Tools/CodeTools/TianoTools/MakeDeps/MakeDeps.c [deleted file]
Tools/CodeTools/TianoTools/MakeDeps/build.xml [deleted file]
Tools/CodeTools/TianoTools/ModifyInf/ModifyInf.c [deleted file]
Tools/CodeTools/TianoTools/ModifyInf/build.xml [deleted file]
Tools/CodeTools/TianoTools/Pccts/CHANGES_FROM_131.txt [deleted file]
Tools/CodeTools/TianoTools/Pccts/CHANGES_FROM_133.txt [deleted file]
Tools/CodeTools/TianoTools/Pccts/CHANGES_FROM_133_BEFORE_MR13.txt [deleted file]
Tools/CodeTools/TianoTools/Pccts/CHANGES_SUMMARY.txt [deleted file]
Tools/CodeTools/TianoTools/Pccts/KNOWN_PROBLEMS.txt [deleted file]
Tools/CodeTools/TianoTools/Pccts/MPW_Read_Me [deleted file]
Tools/CodeTools/TianoTools/Pccts/NOTES.bcc [deleted file]
Tools/CodeTools/TianoTools/Pccts/NOTES.msvc [deleted file]
Tools/CodeTools/TianoTools/Pccts/README [deleted file]
Tools/CodeTools/TianoTools/Pccts/RIGHTS [deleted file]
Tools/CodeTools/TianoTools/Pccts/antlr/AntlrMS.mak [deleted file]
Tools/CodeTools/TianoTools/Pccts/antlr/AntlrPPC.mak [deleted file]
Tools/CodeTools/TianoTools/Pccts/antlr/README [deleted file]
Tools/CodeTools/TianoTools/Pccts/antlr/antlr.1 [deleted file]
Tools/CodeTools/TianoTools/Pccts/antlr/antlr.c [deleted file]
Tools/CodeTools/TianoTools/Pccts/antlr/antlr.g [deleted file]
Tools/CodeTools/TianoTools/Pccts/antlr/antlr.r [deleted file]
Tools/CodeTools/TianoTools/Pccts/antlr/antlr1.txt [deleted file]
Tools/CodeTools/TianoTools/Pccts/antlr/bits.c [deleted file]
Tools/CodeTools/TianoTools/Pccts/antlr/build.c [deleted file]
Tools/CodeTools/TianoTools/Pccts/antlr/build.xml [deleted file]
Tools/CodeTools/TianoTools/Pccts/antlr/dumpcycles.c [deleted file]
Tools/CodeTools/TianoTools/Pccts/antlr/dumpnode.c [deleted file]
Tools/CodeTools/TianoTools/Pccts/antlr/egman.c [deleted file]
Tools/CodeTools/TianoTools/Pccts/antlr/err.c [deleted file]
Tools/CodeTools/TianoTools/Pccts/antlr/fcache.c [deleted file]
Tools/CodeTools/TianoTools/Pccts/antlr/fset.c [deleted file]
Tools/CodeTools/TianoTools/Pccts/antlr/fset2.c [deleted file]
Tools/CodeTools/TianoTools/Pccts/antlr/gen.c [deleted file]
Tools/CodeTools/TianoTools/Pccts/antlr/generic.h [deleted file]
Tools/CodeTools/TianoTools/Pccts/antlr/globals.c [deleted file]
Tools/CodeTools/TianoTools/Pccts/antlr/hash.c [deleted file]
Tools/CodeTools/TianoTools/Pccts/antlr/hash.h [deleted file]
Tools/CodeTools/TianoTools/Pccts/antlr/lex.c [deleted file]
Tools/CodeTools/TianoTools/Pccts/antlr/main.c [deleted file]
Tools/CodeTools/TianoTools/Pccts/antlr/makefile [deleted file]
Tools/CodeTools/TianoTools/Pccts/antlr/makefile.cygwin [deleted file]
Tools/CodeTools/TianoTools/Pccts/antlr/makefile1 [deleted file]
Tools/CodeTools/TianoTools/Pccts/antlr/misc.c [deleted file]
Tools/CodeTools/TianoTools/Pccts/antlr/mode.h [deleted file]
Tools/CodeTools/TianoTools/Pccts/antlr/mrhoist.c [deleted file]
Tools/CodeTools/TianoTools/Pccts/antlr/parser.dlg [deleted file]
Tools/CodeTools/TianoTools/Pccts/antlr/pred.c [deleted file]
Tools/CodeTools/TianoTools/Pccts/antlr/proto.h [deleted file]
Tools/CodeTools/TianoTools/Pccts/antlr/scan.c [deleted file]
Tools/CodeTools/TianoTools/Pccts/antlr/stdpccts.h [deleted file]
Tools/CodeTools/TianoTools/Pccts/antlr/syn.h [deleted file]
Tools/CodeTools/TianoTools/Pccts/antlr/tokens.h [deleted file]
Tools/CodeTools/TianoTools/Pccts/build.xml [deleted file]
Tools/CodeTools/TianoTools/Pccts/dlg/DlgMS.mak [deleted file]
Tools/CodeTools/TianoTools/Pccts/dlg/DlgPPC.mak [deleted file]
Tools/CodeTools/TianoTools/Pccts/dlg/automata.c [deleted file]
Tools/CodeTools/TianoTools/Pccts/dlg/build.xml [deleted file]
Tools/CodeTools/TianoTools/Pccts/dlg/dlg.1 [deleted file]
Tools/CodeTools/TianoTools/Pccts/dlg/dlg.h [deleted file]
Tools/CodeTools/TianoTools/Pccts/dlg/dlg.r [deleted file]
Tools/CodeTools/TianoTools/Pccts/dlg/dlg1.txt [deleted file]
Tools/CodeTools/TianoTools/Pccts/dlg/dlg_a.c [deleted file]
Tools/CodeTools/TianoTools/Pccts/dlg/dlg_p.c [deleted file]
Tools/CodeTools/TianoTools/Pccts/dlg/dlg_p.g [deleted file]
Tools/CodeTools/TianoTools/Pccts/dlg/err.c [deleted file]
Tools/CodeTools/TianoTools/Pccts/dlg/main.c [deleted file]
Tools/CodeTools/TianoTools/Pccts/dlg/makefile [deleted file]
Tools/CodeTools/TianoTools/Pccts/dlg/makefile.cygwin [deleted file]
Tools/CodeTools/TianoTools/Pccts/dlg/makefile1 [deleted file]
Tools/CodeTools/TianoTools/Pccts/dlg/mode.h [deleted file]
Tools/CodeTools/TianoTools/Pccts/dlg/output.c [deleted file]
Tools/CodeTools/TianoTools/Pccts/dlg/parser.dlg [deleted file]
Tools/CodeTools/TianoTools/Pccts/dlg/relabel.c [deleted file]
Tools/CodeTools/TianoTools/Pccts/dlg/stdpccts.h [deleted file]
Tools/CodeTools/TianoTools/Pccts/dlg/support.c [deleted file]
Tools/CodeTools/TianoTools/Pccts/dlg/tokens.h [deleted file]
Tools/CodeTools/TianoTools/Pccts/h/AParser.cpp [deleted file]
Tools/CodeTools/TianoTools/Pccts/h/AParser.h [deleted file]
Tools/CodeTools/TianoTools/Pccts/h/ASTBase.cpp [deleted file]
Tools/CodeTools/TianoTools/Pccts/h/ASTBase.h [deleted file]
Tools/CodeTools/TianoTools/Pccts/h/ATokPtr.h [deleted file]
Tools/CodeTools/TianoTools/Pccts/h/ATokPtrImpl.h [deleted file]
Tools/CodeTools/TianoTools/Pccts/h/AToken.h [deleted file]
Tools/CodeTools/TianoTools/Pccts/h/ATokenBuffer.cpp [deleted file]
Tools/CodeTools/TianoTools/Pccts/h/ATokenBuffer.h [deleted file]
Tools/CodeTools/TianoTools/Pccts/h/ATokenStream.h [deleted file]
Tools/CodeTools/TianoTools/Pccts/h/BufFileInput.cpp [deleted file]
Tools/CodeTools/TianoTools/Pccts/h/BufFileInput.h [deleted file]
Tools/CodeTools/TianoTools/Pccts/h/DLG_stream_input.h [deleted file]
Tools/CodeTools/TianoTools/Pccts/h/DLexer.h [deleted file]
Tools/CodeTools/TianoTools/Pccts/h/DLexerBase.cpp [deleted file]
Tools/CodeTools/TianoTools/Pccts/h/DLexerBase.h [deleted file]
Tools/CodeTools/TianoTools/Pccts/h/PBlackBox.h [deleted file]
Tools/CodeTools/TianoTools/Pccts/h/PCCTSAST.cpp [deleted file]
Tools/CodeTools/TianoTools/Pccts/h/PCCTSAST.h [deleted file]
Tools/CodeTools/TianoTools/Pccts/h/SList.h [deleted file]
Tools/CodeTools/TianoTools/Pccts/h/antlr.h [deleted file]
Tools/CodeTools/TianoTools/Pccts/h/ast.c [deleted file]
Tools/CodeTools/TianoTools/Pccts/h/ast.h [deleted file]
Tools/CodeTools/TianoTools/Pccts/h/charbuf.h [deleted file]
Tools/CodeTools/TianoTools/Pccts/h/charptr.c [deleted file]
Tools/CodeTools/TianoTools/Pccts/h/charptr.h [deleted file]
Tools/CodeTools/TianoTools/Pccts/h/config.h [deleted file]
Tools/CodeTools/TianoTools/Pccts/h/dlgauto.h [deleted file]
Tools/CodeTools/TianoTools/Pccts/h/dlgdef.h [deleted file]
Tools/CodeTools/TianoTools/Pccts/h/err.h [deleted file]
Tools/CodeTools/TianoTools/Pccts/h/int.h [deleted file]
Tools/CodeTools/TianoTools/Pccts/h/pccts_assert.h [deleted file]
Tools/CodeTools/TianoTools/Pccts/h/pccts_iostream.h [deleted file]
Tools/CodeTools/TianoTools/Pccts/h/pccts_istream.h [deleted file]
Tools/CodeTools/TianoTools/Pccts/h/pccts_setjmp.h [deleted file]
Tools/CodeTools/TianoTools/Pccts/h/pccts_stdarg.h [deleted file]
Tools/CodeTools/TianoTools/Pccts/h/pccts_stdio.h [deleted file]
Tools/CodeTools/TianoTools/Pccts/h/pccts_stdlib.h [deleted file]
Tools/CodeTools/TianoTools/Pccts/h/pccts_string.h [deleted file]
Tools/CodeTools/TianoTools/Pccts/h/pcctscfg.h [deleted file]
Tools/CodeTools/TianoTools/Pccts/h/pcnames.bat [deleted file]
Tools/CodeTools/TianoTools/Pccts/h/slist.cpp [deleted file]
Tools/CodeTools/TianoTools/Pccts/history.ps [deleted file]
Tools/CodeTools/TianoTools/Pccts/history.txt [deleted file]
Tools/CodeTools/TianoTools/Pccts/makefile [deleted file]
Tools/CodeTools/TianoTools/Pccts/support/genmk/genmk.c [deleted file]
Tools/CodeTools/TianoTools/Pccts/support/genmk/genmk_old.c [deleted file]
Tools/CodeTools/TianoTools/Pccts/support/genmk/makefile [deleted file]
Tools/CodeTools/TianoTools/Pccts/support/rexpr/makefile [deleted file]
Tools/CodeTools/TianoTools/Pccts/support/rexpr/rexpr.c [deleted file]
Tools/CodeTools/TianoTools/Pccts/support/rexpr/rexpr.h [deleted file]
Tools/CodeTools/TianoTools/Pccts/support/rexpr/test.c [deleted file]
Tools/CodeTools/TianoTools/Pccts/support/set/set.c [deleted file]
Tools/CodeTools/TianoTools/Pccts/support/set/set.h [deleted file]
Tools/CodeTools/TianoTools/Pccts/support/sym/sym.c [deleted file]
Tools/CodeTools/TianoTools/Pccts/support/sym/template.h [deleted file]
Tools/CodeTools/TianoTools/PeCoffLoader/BasePeCoff.c [deleted file]
Tools/CodeTools/TianoTools/PeCoffLoader/Common/EfiImage.h [deleted file]
Tools/CodeTools/TianoTools/PeCoffLoader/Ia32/PeCoffLoaderEx.c [deleted file]
Tools/CodeTools/TianoTools/PeCoffLoader/Ipf/PeCoffLoaderEx.c [deleted file]
Tools/CodeTools/TianoTools/PeCoffLoader/X64/PeCoffLoaderEx.c [deleted file]
Tools/CodeTools/TianoTools/PeCoffLoader/build.xml [deleted file]
Tools/CodeTools/TianoTools/PeiRebase/PeiRebaseExe.c [deleted file]
Tools/CodeTools/TianoTools/PeiRebase/PeiRebaseExe.h [deleted file]
Tools/CodeTools/TianoTools/PeiRebase/build.xml [deleted file]
Tools/CodeTools/TianoTools/SecApResetVectorFixup/SecApResetVectorFixup.c [deleted file]
Tools/CodeTools/TianoTools/SecApResetVectorFixup/SecApResetVectorFixup.h [deleted file]
Tools/CodeTools/TianoTools/SecApResetVectorFixup/build.xml [deleted file]
Tools/CodeTools/TianoTools/SecFixup/SecFixup.c [deleted file]
Tools/CodeTools/TianoTools/SecFixup/SecFixup.h [deleted file]
Tools/CodeTools/TianoTools/SecFixup/build.xml [deleted file]
Tools/CodeTools/TianoTools/SetStamp/SetStamp.c [deleted file]
Tools/CodeTools/TianoTools/SetStamp/build.xml [deleted file]
Tools/CodeTools/TianoTools/SplitFile/SplitFile.c [deleted file]
Tools/CodeTools/TianoTools/SplitFile/build.xml [deleted file]
Tools/CodeTools/TianoTools/StrGather/StrGather.c [deleted file]
Tools/CodeTools/TianoTools/StrGather/StrGather.h [deleted file]
Tools/CodeTools/TianoTools/StrGather/StringDB.c [deleted file]
Tools/CodeTools/TianoTools/StrGather/StringDB.h [deleted file]
Tools/CodeTools/TianoTools/StrGather/build.xml [deleted file]
Tools/CodeTools/TianoTools/String/PrintLib.c [deleted file]
Tools/CodeTools/TianoTools/String/PrintLibInternal.c [deleted file]
Tools/CodeTools/TianoTools/String/PrintLibInternal.h [deleted file]
Tools/CodeTools/TianoTools/String/String.c [deleted file]
Tools/CodeTools/TianoTools/String/build.xml [deleted file]
Tools/CodeTools/TianoTools/Strip/Strip.c [deleted file]
Tools/CodeTools/TianoTools/Strip/build.xml [deleted file]
Tools/CodeTools/TianoTools/TianoTools.msa [deleted file]
Tools/CodeTools/TianoTools/VfrCompile/EfiVfr.h [deleted file]
Tools/CodeTools/TianoTools/VfrCompile/VfrCompile.g [deleted file]
Tools/CodeTools/TianoTools/VfrCompile/VfrServices.cpp [deleted file]
Tools/CodeTools/TianoTools/VfrCompile/VfrServices.h [deleted file]
Tools/CodeTools/TianoTools/VfrCompile/build.xml [deleted file]
Tools/CodeTools/TianoTools/ZeroDebugData/ZeroDebugData.c [deleted file]
Tools/CodeTools/TianoTools/ZeroDebugData/build.xml [deleted file]
Tools/CodeTools/TianoTools/build.xml [deleted file]
Tools/build.xml

diff --git a/Tools/CodeTools/Source/Common/CommonLib.c b/Tools/CodeTools/Source/Common/CommonLib.c
new file mode 100644 (file)
index 0000000..4d1663a
--- /dev/null
@@ -0,0 +1,508 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  CommonLib.c\r
+\r
+Abstract:\r
+\r
+  Common Library Functions\r
\r
+--*/\r
+\r
+#include <stdio.h>\r
+#include <string.h>\r
+#include <stdlib.h>\r
+#include "CommonLib.h"\r
+\r
+VOID\r
+PeiZeroMem (\r
+  IN VOID   *Buffer,\r
+  IN UINTN  Size\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Set Buffer to zero for Size bytes.\r
+\r
+Arguments:\r
+\r
+  Buffer  - Memory to set.\r
+\r
+  Size    - Number of bytes to set\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+{\r
+  INT8  *Ptr;\r
+\r
+  Ptr = Buffer;\r
+  while (Size--) {\r
+    *(Ptr++) = 0;\r
+  }\r
+}\r
+\r
+VOID\r
+PeiCopyMem (\r
+  IN VOID   *Destination,\r
+  IN VOID   *Source,\r
+  IN UINTN  Length\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Copy Length bytes from Source to Destination.\r
+\r
+Arguments:\r
+\r
+  Destination - Target of copy\r
+\r
+  Source      - Place to copy from\r
+\r
+  Length      - Number of bytes to copy\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+{\r
+  CHAR8 *Destination8;\r
+  CHAR8 *Source8;\r
+\r
+  Destination8  = Destination;\r
+  Source8       = Source;\r
+  while (Length--) {\r
+    *(Destination8++) = *(Source8++);\r
+  }\r
+}\r
+\r
+VOID\r
+ZeroMem (\r
+  IN VOID   *Buffer,\r
+  IN UINTN  Size\r
+  )\r
+{\r
+  PeiZeroMem (Buffer, Size);\r
+}\r
+\r
+VOID\r
+CopyMem (\r
+  IN VOID   *Destination,\r
+  IN VOID   *Source,\r
+  IN UINTN  Length\r
+  )\r
+{\r
+  PeiCopyMem (Destination, Source, Length);\r
+}\r
+\r
+INTN\r
+CompareGuid (\r
+  IN EFI_GUID     *Guid1,\r
+  IN EFI_GUID     *Guid2\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Compares to GUIDs\r
+\r
+Arguments:\r
+\r
+  Guid1 - guid to compare\r
+  Guid2 - guid to compare\r
+\r
+Returns:\r
+  =  0  if Guid1 == Guid2\r
+  != 0  if Guid1 != Guid2 \r
+\r
+--*/\r
+{\r
+  INT32 *g1;\r
+  INT32 *g2;\r
+  INT32 r;\r
+\r
+  //\r
+  // Compare 32 bits at a time\r
+  //\r
+  g1  = (INT32 *) Guid1;\r
+  g2  = (INT32 *) Guid2;\r
+\r
+  r   = g1[0] - g2[0];\r
+  r |= g1[1] - g2[1];\r
+  r |= g1[2] - g2[2];\r
+  r |= g1[3] - g2[3];\r
+\r
+  return r;\r
+}\r
+\r
+EFI_STATUS\r
+GetFileImage (\r
+  IN CHAR8    *InputFileName,\r
+  OUT CHAR8   **InputFileImage,\r
+  OUT UINT32  *BytesRead\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function opens a file and reads it into a memory buffer.  The function \r
+  will allocate the memory buffer and returns the size of the buffer.\r
+\r
+Arguments:\r
+\r
+  InputFileName     The name of the file to read.\r
+  InputFileImage    A pointer to the memory buffer.\r
+  BytesRead         The size of the memory buffer.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS              The function completed successfully.\r
+  EFI_INVALID_PARAMETER    One of the input parameters was invalid.\r
+  EFI_ABORTED              An error occurred.\r
+  EFI_OUT_OF_RESOURCES     No resource to complete operations.\r
+\r
+--*/\r
+{\r
+  FILE    *InputFile;\r
+  UINT32  FileSize;\r
+\r
+  //\r
+  // Verify input parameters.\r
+  //\r
+  if (InputFileName == NULL || strlen (InputFileName) == 0 || InputFileImage == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+  //\r
+  // Open the file and copy contents into a memory buffer.\r
+  //\r
+  //\r
+  // Open the file\r
+  //\r
+  InputFile = fopen (InputFileName, "rb");\r
+  if (InputFile == NULL) {\r
+    printf ("ERROR: Could not open input file \"%s\".\n", InputFileName);\r
+    return EFI_ABORTED;\r
+  }\r
+  //\r
+  // Go to the end so that we can determine the file size\r
+  //\r
+  if (fseek (InputFile, 0, SEEK_END)) {\r
+    printf ("ERROR: System error reading input file \"%s\".\n", InputFileName);\r
+    fclose (InputFile);\r
+    return EFI_ABORTED;\r
+  }\r
+  //\r
+  // Get the file size\r
+  //\r
+  FileSize = ftell (InputFile);\r
+  if (FileSize == -1) {\r
+    printf ("ERROR: System error parsing input file \"%s\".\n", InputFileName);\r
+    fclose (InputFile);\r
+    return EFI_ABORTED;\r
+  }\r
+  //\r
+  // Allocate a buffer\r
+  //\r
+  *InputFileImage = malloc (FileSize);\r
+  if (*InputFileImage == NULL) {\r
+    fclose (InputFile);\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+  //\r
+  // Reset to the beginning of the file\r
+  //\r
+  if (fseek (InputFile, 0, SEEK_SET)) {\r
+    printf ("ERROR: System error reading input file \"%s\".\n", InputFileName);\r
+    fclose (InputFile);\r
+    free (*InputFileImage);\r
+    *InputFileImage = NULL;\r
+    return EFI_ABORTED;\r
+  }\r
+  //\r
+  // Read all of the file contents.\r
+  //\r
+  *BytesRead = fread (*InputFileImage, sizeof (UINT8), FileSize, InputFile);\r
+  if (*BytesRead != sizeof (UINT8) * FileSize) {\r
+    printf ("ERROR: Reading file \"%s\"%i.\n", InputFileName);\r
+    fclose (InputFile);\r
+    free (*InputFileImage);\r
+    *InputFileImage = NULL;\r
+    return EFI_ABORTED;\r
+  }\r
+  //\r
+  // Close the file\r
+  //\r
+  fclose (InputFile);\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+UINT8\r
+CalculateChecksum8 (\r
+  IN UINT8        *Buffer,\r
+  IN UINTN        Size\r
+  )\r
+/*++\r
+  \r
+Routine Description:\r
+\r
+  This function calculates the value needed for a valid UINT8 checksum\r
+\r
+Arguments:\r
+\r
+  Buffer      Pointer to buffer containing byte data of component.\r
+  Size        Size of the buffer\r
+\r
+Returns:\r
+\r
+  The 8 bit checksum value needed.\r
+\r
+--*/\r
+{\r
+  return (UINT8) (0x100 - CalculateSum8 (Buffer, Size));\r
+}\r
+\r
+UINT8\r
+CalculateSum8 (\r
+  IN UINT8  *Buffer,\r
+  IN UINTN  Size\r
+  )\r
+/*++\r
+  \r
+Routine Description::\r
+\r
+  This function calculates the UINT8 sum for the requested region.\r
+\r
+Arguments:\r
+\r
+  Buffer      Pointer to buffer containing byte data of component.\r
+  Size        Size of the buffer\r
+\r
+Returns:\r
+\r
+  The 8 bit checksum value needed.\r
+\r
+--*/\r
+{\r
+  UINTN Index;\r
+  UINT8 Sum;\r
+\r
+  Sum = 0;\r
+\r
+  //\r
+  // Perform the byte sum for buffer\r
+  //\r
+  for (Index = 0; Index < Size; Index++) {\r
+    Sum = (UINT8) (Sum + Buffer[Index]);\r
+  }\r
+\r
+  return Sum;\r
+}\r
+\r
+UINT16\r
+CalculateChecksum16 (\r
+  IN UINT16       *Buffer,\r
+  IN UINTN        Size\r
+  )\r
+/*++\r
+  \r
+Routine Description::\r
+\r
+  This function calculates the value needed for a valid UINT16 checksum\r
+\r
+Arguments:\r
+\r
+  Buffer      Pointer to buffer containing byte data of component.\r
+  Size        Size of the buffer\r
+\r
+Returns:\r
+\r
+  The 16 bit checksum value needed.\r
+\r
+--*/\r
+{\r
+  return (UINT16) (0x10000 - CalculateSum16 (Buffer, Size));\r
+}\r
+\r
+UINT16\r
+CalculateSum16 (\r
+  IN UINT16       *Buffer,\r
+  IN UINTN        Size\r
+  )\r
+/*++\r
+  \r
+Routine Description:\r
+\r
+  This function calculates the UINT16 sum for the requested region.\r
+\r
+Arguments:\r
+\r
+  Buffer      Pointer to buffer containing byte data of component.\r
+  Size        Size of the buffer\r
+\r
+Returns:\r
+\r
+  The 16 bit checksum\r
+\r
+--*/\r
+{\r
+  UINTN   Index;\r
+  UINT16  Sum;\r
+\r
+  Sum = 0;\r
+\r
+  //\r
+  // Perform the word sum for buffer\r
+  //\r
+  for (Index = 0; Index < Size; Index++) {\r
+    Sum = (UINT16) (Sum + Buffer[Index]);\r
+  }\r
+\r
+  return (UINT16) Sum;\r
+}\r
+\r
+EFI_STATUS\r
+PrintGuid (\r
+  IN EFI_GUID *Guid\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function prints a GUID to STDOUT.\r
+\r
+Arguments:\r
+\r
+  Guid    Pointer to a GUID to print.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS             The GUID was printed.\r
+  EFI_INVALID_PARAMETER   The input was NULL.\r
+\r
+--*/\r
+{\r
+  if (Guid == NULL) {\r
+    printf ("ERROR: PrintGuid called with a NULL value.\n");\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  printf (\r
+    "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x\n",\r
+    Guid->Data1,\r
+    Guid->Data2,\r
+    Guid->Data3,\r
+    Guid->Data4[0],\r
+    Guid->Data4[1],\r
+    Guid->Data4[2],\r
+    Guid->Data4[3],\r
+    Guid->Data4[4],\r
+    Guid->Data4[5],\r
+    Guid->Data4[6],\r
+    Guid->Data4[7]\r
+    );\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+PrintGuidToBuffer (\r
+  IN EFI_GUID     *Guid,\r
+  IN OUT UINT8    *Buffer,\r
+  IN UINT32       BufferLen,\r
+  IN BOOLEAN      Uppercase\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function prints a GUID to a buffer\r
+\r
+Arguments:\r
+\r
+  Guid      - Pointer to a GUID to print.\r
+  Buffer    - Pointer to a user-provided buffer to print to\r
+  BufferLen - Size of the Buffer\r
+  Uppercase - If use upper case.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS             The GUID was printed.\r
+  EFI_INVALID_PARAMETER   The input was NULL.\r
+  EFI_BUFFER_TOO_SMALL    The input buffer was not big enough\r
+  \r
+--*/\r
+{\r
+  if (Guid == NULL) {\r
+    printf ("ERROR: PrintGuidToBuffer() called with a NULL value\n");\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  if (BufferLen < PRINTED_GUID_BUFFER_SIZE) {\r
+    printf ("ERORR: PrintGuidToBuffer() called with invalid buffer size\n");\r
+    return EFI_BUFFER_TOO_SMALL;\r
+  }\r
+\r
+  if (Uppercase) {\r
+    sprintf (\r
+      Buffer,\r
+      "%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X",\r
+      Guid->Data1,\r
+      Guid->Data2,\r
+      Guid->Data3,\r
+      Guid->Data4[0],\r
+      Guid->Data4[1],\r
+      Guid->Data4[2],\r
+      Guid->Data4[3],\r
+      Guid->Data4[4],\r
+      Guid->Data4[5],\r
+      Guid->Data4[6],\r
+      Guid->Data4[7]\r
+      );\r
+  } else {\r
+    sprintf (\r
+      Buffer,\r
+      "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",\r
+      Guid->Data1,\r
+      Guid->Data2,\r
+      Guid->Data3,\r
+      Guid->Data4[0],\r
+      Guid->Data4[1],\r
+      Guid->Data4[2],\r
+      Guid->Data4[3],\r
+      Guid->Data4[4],\r
+      Guid->Data4[5],\r
+      Guid->Data4[6],\r
+      Guid->Data4[7]\r
+      );\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+#ifdef __GNUC__\r
+#ifndef __CYGWIN__\r
+char *strlwr(char *s)\r
+{\r
+  char *p = s;\r
+  for(;*s;s++) {\r
+    *s = tolower(*s);\r
+  }\r
+  return p;\r
+}\r
+#endif\r
+#endif\r
diff --git a/Tools/CodeTools/Source/Common/CommonLib.h b/Tools/CodeTools/Source/Common/CommonLib.h
new file mode 100644 (file)
index 0000000..46f0cba
--- /dev/null
@@ -0,0 +1,135 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  CommonLib.h\r
+\r
+Abstract:\r
+\r
+  Common library assistance routines.\r
+\r
+--*/\r
+\r
+#ifndef _EFI_COMMON_LIB_H\r
+#define _EFI_COMMON_LIB_H\r
+\r
+#include <Common/UefiBaseTypes.h>\r
+\r
+#ifndef _MAX_PATH\r
+#define _MAX_PATH 500\r
+#endif\r
+\r
+#define PRINTED_GUID_BUFFER_SIZE  37  // including null-termination\r
+//\r
+// Function declarations\r
+//\r
+VOID\r
+PeiZeroMem (\r
+  IN VOID   *Buffer,\r
+  IN UINTN  Size\r
+  )\r
+;\r
+\r
+VOID\r
+PeiCopyMem (\r
+  IN VOID   *Destination,\r
+  IN VOID   *Source,\r
+  IN UINTN  Length\r
+  )\r
+;\r
+\r
+VOID\r
+ZeroMem (\r
+  IN VOID   *Buffer,\r
+  IN UINTN  Size\r
+  )\r
+;\r
+\r
+VOID\r
+CopyMem (\r
+  IN VOID   *Destination,\r
+  IN VOID   *Source,\r
+  IN UINTN  Length\r
+  )\r
+;\r
+\r
+INTN\r
+CompareGuid (\r
+  IN EFI_GUID     *Guid1,\r
+  IN EFI_GUID     *Guid2\r
+  )\r
+;\r
+\r
+EFI_STATUS\r
+GetFileImage (\r
+  IN CHAR8    *InputFileName,\r
+  OUT CHAR8   **InputFileImage,\r
+  OUT UINT32  *BytesRead\r
+  )\r
+;\r
+\r
+UINT8\r
+CalculateChecksum8 (\r
+  IN UINT8        *Buffer,\r
+  IN UINTN        Size\r
+  )\r
+;\r
+\r
+UINT8\r
+CalculateSum8 (\r
+  IN UINT8        *Buffer,\r
+  IN UINTN        Size\r
+  )\r
+;\r
+\r
+UINT16\r
+CalculateChecksum16 (\r
+  IN UINT16       *Buffer,\r
+  IN UINTN        Size\r
+  )\r
+;\r
+\r
+UINT16\r
+CalculateSum16 (\r
+  IN UINT16       *Buffer,\r
+  IN UINTN        Size\r
+  )\r
+;\r
+\r
+EFI_STATUS\r
+PrintGuid (\r
+  IN EFI_GUID                     *Guid\r
+  )\r
+;\r
+\r
+#define PRINTED_GUID_BUFFER_SIZE  37  // including null-termination\r
+EFI_STATUS\r
+PrintGuidToBuffer (\r
+  IN EFI_GUID     *Guid,\r
+  IN OUT UINT8    *Buffer,\r
+  IN UINT32       BufferLen,\r
+  IN BOOLEAN      Uppercase\r
+  )\r
+;\r
+\r
+#define ASSERT(x) assert(x)\r
+\r
+#ifdef __GNUC__\r
+#define stricmp strcasecmp\r
+#define strnicmp strncasecmp\r
+#define strcmpi strcasecmp\r
+#ifndef __CYGWIN__\r
+char *strlwr(char *s);\r
+#endif\r
+#endif\r
+\r
+#endif\r
diff --git a/Tools/CodeTools/Source/Common/Crc32.c b/Tools/CodeTools/Source/Common/Crc32.c
new file mode 100644 (file)
index 0000000..4ae5eb4
--- /dev/null
@@ -0,0 +1,326 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  crc32.c\r
+\r
+Abstract:\r
+\r
+  CalcuateCrc32 routine.\r
+  \r
+--*/\r
+\r
+#include <stdlib.h>\r
+#include "Crc32.h"\r
+\r
+UINT32  mCrcTable[256] = {\r
+  0x00000000,\r
+  0x77073096,\r
+  0xEE0E612C,\r
+  0x990951BA,\r
+  0x076DC419,\r
+  0x706AF48F,\r
+  0xE963A535,\r
+  0x9E6495A3,\r
+  0x0EDB8832,\r
+  0x79DCB8A4,\r
+  0xE0D5E91E,\r
+  0x97D2D988,\r
+  0x09B64C2B,\r
+  0x7EB17CBD,\r
+  0xE7B82D07,\r
+  0x90BF1D91,\r
+  0x1DB71064,\r
+  0x6AB020F2,\r
+  0xF3B97148,\r
+  0x84BE41DE,\r
+  0x1ADAD47D,\r
+  0x6DDDE4EB,\r
+  0xF4D4B551,\r
+  0x83D385C7,\r
+  0x136C9856,\r
+  0x646BA8C0,\r
+  0xFD62F97A,\r
+  0x8A65C9EC,\r
+  0x14015C4F,\r
+  0x63066CD9,\r
+  0xFA0F3D63,\r
+  0x8D080DF5,\r
+  0x3B6E20C8,\r
+  0x4C69105E,\r
+  0xD56041E4,\r
+  0xA2677172,\r
+  0x3C03E4D1,\r
+  0x4B04D447,\r
+  0xD20D85FD,\r
+  0xA50AB56B,\r
+  0x35B5A8FA,\r
+  0x42B2986C,\r
+  0xDBBBC9D6,\r
+  0xACBCF940,\r
+  0x32D86CE3,\r
+  0x45DF5C75,\r
+  0xDCD60DCF,\r
+  0xABD13D59,\r
+  0x26D930AC,\r
+  0x51DE003A,\r
+  0xC8D75180,\r
+  0xBFD06116,\r
+  0x21B4F4B5,\r
+  0x56B3C423,\r
+  0xCFBA9599,\r
+  0xB8BDA50F,\r
+  0x2802B89E,\r
+  0x5F058808,\r
+  0xC60CD9B2,\r
+  0xB10BE924,\r
+  0x2F6F7C87,\r
+  0x58684C11,\r
+  0xC1611DAB,\r
+  0xB6662D3D,\r
+  0x76DC4190,\r
+  0x01DB7106,\r
+  0x98D220BC,\r
+  0xEFD5102A,\r
+  0x71B18589,\r
+  0x06B6B51F,\r
+  0x9FBFE4A5,\r
+  0xE8B8D433,\r
+  0x7807C9A2,\r
+  0x0F00F934,\r
+  0x9609A88E,\r
+  0xE10E9818,\r
+  0x7F6A0DBB,\r
+  0x086D3D2D,\r
+  0x91646C97,\r
+  0xE6635C01,\r
+  0x6B6B51F4,\r
+  0x1C6C6162,\r
+  0x856530D8,\r
+  0xF262004E,\r
+  0x6C0695ED,\r
+  0x1B01A57B,\r
+  0x8208F4C1,\r
+  0xF50FC457,\r
+  0x65B0D9C6,\r
+  0x12B7E950,\r
+  0x8BBEB8EA,\r
+  0xFCB9887C,\r
+  0x62DD1DDF,\r
+  0x15DA2D49,\r
+  0x8CD37CF3,\r
+  0xFBD44C65,\r
+  0x4DB26158,\r
+  0x3AB551CE,\r
+  0xA3BC0074,\r
+  0xD4BB30E2,\r
+  0x4ADFA541,\r
+  0x3DD895D7,\r
+  0xA4D1C46D,\r
+  0xD3D6F4FB,\r
+  0x4369E96A,\r
+  0x346ED9FC,\r
+  0xAD678846,\r
+  0xDA60B8D0,\r
+  0x44042D73,\r
+  0x33031DE5,\r
+  0xAA0A4C5F,\r
+  0xDD0D7CC9,\r
+  0x5005713C,\r
+  0x270241AA,\r
+  0xBE0B1010,\r
+  0xC90C2086,\r
+  0x5768B525,\r
+  0x206F85B3,\r
+  0xB966D409,\r
+  0xCE61E49F,\r
+  0x5EDEF90E,\r
+  0x29D9C998,\r
+  0xB0D09822,\r
+  0xC7D7A8B4,\r
+  0x59B33D17,\r
+  0x2EB40D81,\r
+  0xB7BD5C3B,\r
+  0xC0BA6CAD,\r
+  0xEDB88320,\r
+  0x9ABFB3B6,\r
+  0x03B6E20C,\r
+  0x74B1D29A,\r
+  0xEAD54739,\r
+  0x9DD277AF,\r
+  0x04DB2615,\r
+  0x73DC1683,\r
+  0xE3630B12,\r
+  0x94643B84,\r
+  0x0D6D6A3E,\r
+  0x7A6A5AA8,\r
+  0xE40ECF0B,\r
+  0x9309FF9D,\r
+  0x0A00AE27,\r
+  0x7D079EB1,\r
+  0xF00F9344,\r
+  0x8708A3D2,\r
+  0x1E01F268,\r
+  0x6906C2FE,\r
+  0xF762575D,\r
+  0x806567CB,\r
+  0x196C3671,\r
+  0x6E6B06E7,\r
+  0xFED41B76,\r
+  0x89D32BE0,\r
+  0x10DA7A5A,\r
+  0x67DD4ACC,\r
+  0xF9B9DF6F,\r
+  0x8EBEEFF9,\r
+  0x17B7BE43,\r
+  0x60B08ED5,\r
+  0xD6D6A3E8,\r
+  0xA1D1937E,\r
+  0x38D8C2C4,\r
+  0x4FDFF252,\r
+  0xD1BB67F1,\r
+  0xA6BC5767,\r
+  0x3FB506DD,\r
+  0x48B2364B,\r
+  0xD80D2BDA,\r
+  0xAF0A1B4C,\r
+  0x36034AF6,\r
+  0x41047A60,\r
+  0xDF60EFC3,\r
+  0xA867DF55,\r
+  0x316E8EEF,\r
+  0x4669BE79,\r
+  0xCB61B38C,\r
+  0xBC66831A,\r
+  0x256FD2A0,\r
+  0x5268E236,\r
+  0xCC0C7795,\r
+  0xBB0B4703,\r
+  0x220216B9,\r
+  0x5505262F,\r
+  0xC5BA3BBE,\r
+  0xB2BD0B28,\r
+  0x2BB45A92,\r
+  0x5CB36A04,\r
+  0xC2D7FFA7,\r
+  0xB5D0CF31,\r
+  0x2CD99E8B,\r
+  0x5BDEAE1D,\r
+  0x9B64C2B0,\r
+  0xEC63F226,\r
+  0x756AA39C,\r
+  0x026D930A,\r
+  0x9C0906A9,\r
+  0xEB0E363F,\r
+  0x72076785,\r
+  0x05005713,\r
+  0x95BF4A82,\r
+  0xE2B87A14,\r
+  0x7BB12BAE,\r
+  0x0CB61B38,\r
+  0x92D28E9B,\r
+  0xE5D5BE0D,\r
+  0x7CDCEFB7,\r
+  0x0BDBDF21,\r
+  0x86D3D2D4,\r
+  0xF1D4E242,\r
+  0x68DDB3F8,\r
+  0x1FDA836E,\r
+  0x81BE16CD,\r
+  0xF6B9265B,\r
+  0x6FB077E1,\r
+  0x18B74777,\r
+  0x88085AE6,\r
+  0xFF0F6A70,\r
+  0x66063BCA,\r
+  0x11010B5C,\r
+  0x8F659EFF,\r
+  0xF862AE69,\r
+  0x616BFFD3,\r
+  0x166CCF45,\r
+  0xA00AE278,\r
+  0xD70DD2EE,\r
+  0x4E048354,\r
+  0x3903B3C2,\r
+  0xA7672661,\r
+  0xD06016F7,\r
+  0x4969474D,\r
+  0x3E6E77DB,\r
+  0xAED16A4A,\r
+  0xD9D65ADC,\r
+  0x40DF0B66,\r
+  0x37D83BF0,\r
+  0xA9BCAE53,\r
+  0xDEBB9EC5,\r
+  0x47B2CF7F,\r
+  0x30B5FFE9,\r
+  0xBDBDF21C,\r
+  0xCABAC28A,\r
+  0x53B39330,\r
+  0x24B4A3A6,\r
+  0xBAD03605,\r
+  0xCDD70693,\r
+  0x54DE5729,\r
+  0x23D967BF,\r
+  0xB3667A2E,\r
+  0xC4614AB8,\r
+  0x5D681B02,\r
+  0x2A6F2B94,\r
+  0xB40BBE37,\r
+  0xC30C8EA1,\r
+  0x5A05DF1B,\r
+  0x2D02EF8D\r
+};\r
+\r
+EFI_STATUS\r
+CalculateCrc32 (\r
+  IN  UINT8                             *Data,\r
+  IN  UINTN                             DataSize,\r
+  IN OUT UINT32                         *CrcOut\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  The CalculateCrc32 routine.\r
+\r
+Arguments:\r
+\r
+  Data        - The buffer contaning the data to be processed\r
+  DataSize    - The size of data to be processed\r
+  CrcOut      - A pointer to the caller allocated UINT32 that on\r
+                contains the CRC32 checksum of Data\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS               - Calculation is successful.\r
+  EFI_INVALID_PARAMETER     - Data / CrcOut = NULL, or DataSize = 0\r
+\r
+--*/\r
+{\r
+  UINT32  Crc;\r
+  UINTN   Index;\r
+  UINT8   *Ptr;\r
+\r
+  if ((DataSize == 0) || (Data == NULL) || (CrcOut == NULL)) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  Crc = 0xffffffff;\r
+  for (Index = 0, Ptr = Data; Index < DataSize; Index++, Ptr++) {\r
+    Crc = (Crc >> 8) ^ mCrcTable[(UINT8) Crc ^ *Ptr];\r
+  }\r
+\r
+  *CrcOut = Crc ^ 0xffffffff;\r
+\r
+  return EFI_SUCCESS;\r
+}\r
diff --git a/Tools/CodeTools/Source/Common/Crc32.h b/Tools/CodeTools/Source/Common/Crc32.h
new file mode 100644 (file)
index 0000000..ec48cdd
--- /dev/null
@@ -0,0 +1,54 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Crc32.h\r
+\r
+Abstract:\r
+\r
+  Header file for CalcuateCrc32 routine\r
+  \r
+--*/\r
+\r
+#ifndef _CRC32_H\r
+#define _CRC32_H\r
+\r
+#include <Common/UefiBaseTypes.h>\r
+\r
+EFI_STATUS\r
+CalculateCrc32 (\r
+  IN  UINT8                             *Data,\r
+  IN  UINTN                             DataSize,\r
+  IN OUT UINT32                         *CrcOut\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  The CalculateCrc32 routine.\r
+\r
+Arguments:\r
+\r
+  Data        - The buffer contaning the data to be processed\r
+  DataSize    - The size of data to be processed\r
+  CrcOut      - A pointer to the caller allocated UINT32 that on\r
+                contains the CRC32 checksum of Data\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS               - Calculation is successful.\r
+  EFI_INVALID_PARAMETER     - Data / CrcOut = NULL, or DataSize = 0\r
+\r
+--*/\r
+;\r
+\r
+#endif\r
diff --git a/Tools/CodeTools/Source/Common/EfiCompress.c b/Tools/CodeTools/Source/Common/EfiCompress.c
new file mode 100644 (file)
index 0000000..5b91b1d
--- /dev/null
@@ -0,0 +1,1742 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  EfiCompress.c\r
+\r
+Abstract:\r
+\r
+  Compression routine. The compression algorithm is a mixture of\r
+  LZ77 and Huffman coding. LZ77 transforms the source data into a\r
+  sequence of Original Characters and Pointers to repeated strings.\r
+  This sequence is further divided into Blocks and Huffman codings\r
+  are applied to each Block.\r
+\r
+--*/\r
+\r
+#include "EfiCompress.h"\r
+\r
+//\r
+// Macro Definitions\r
+//\r
+typedef INT32 NODE;\r
+#define UINT8_BIT     8\r
+#define THRESHOLD     3\r
+#define INIT_CRC      0\r
+#define WNDBIT        19\r
+#define WNDSIZ        (1U << WNDBIT)\r
+#define MAXMATCH      256\r
+#define BLKSIZ        (1U << 14)  // 16 * 1024U\r
+#define PERC_FLAG     0x80000000U\r
+#define CODE_BIT      16\r
+#define NIL           0\r
+#define MAX_HASH_VAL  (3 * WNDSIZ + (WNDSIZ / 512 + 1) * UINT8_MAX)\r
+#define HASH(p, c)    ((p) + ((c) << (WNDBIT - 9)) + WNDSIZ * 2)\r
+#define CRCPOLY       0xA001\r
+#define UPDATE_CRC(c) mCrc = mCrcTable[(mCrc ^ (c)) & 0xFF] ^ (mCrc >> UINT8_BIT)\r
+\r
+//\r
+// C: the Char&Len Set; P: the Position Set; T: the exTra Set\r
+//\r
+#define NC    (UINT8_MAX + MAXMATCH + 2 - THRESHOLD)\r
+#define CBIT  9\r
+#define NP    (WNDBIT + 1)\r
+#define PBIT  5\r
+#define NT    (CODE_BIT + 3)\r
+#define TBIT  5\r
+#if NT > NP\r
+#define NPT NT\r
+#else\r
+#define NPT NP\r
+#endif\r
+//\r
+// Function Prototypes\r
+//\r
+STATIC VOID PutDword(IN UINT32 Data);\r
+\r
+STATIC\r
+EFI_STATUS\r
+AllocateMemory (\r
+  VOID\r
+  );\r
+\r
+STATIC\r
+VOID\r
+FreeMemory (\r
+  VOID\r
+  );\r
+\r
+STATIC\r
+VOID\r
+InitSlide (\r
+  VOID\r
+  );\r
+\r
+STATIC\r
+NODE\r
+Child (\r
+  IN NODE   NodeQ,\r
+  IN UINT8  CharC\r
+  );\r
+\r
+STATIC\r
+VOID\r
+MakeChild (\r
+  IN NODE  NodeQ,\r
+  IN UINT8 CharC,\r
+  IN NODE  NodeR\r
+  );\r
+\r
+STATIC\r
+VOID\r
+Split (\r
+  IN NODE Old\r
+  );\r
+\r
+STATIC\r
+VOID\r
+InsertNode (\r
+  VOID\r
+  );\r
+\r
+STATIC\r
+VOID\r
+DeleteNode (\r
+  VOID\r
+  );\r
+\r
+STATIC\r
+VOID\r
+GetNextMatch (\r
+  VOID\r
+  );\r
+\r
+STATIC\r
+EFI_STATUS\r
+Encode (\r
+  VOID\r
+  );\r
+\r
+STATIC\r
+VOID\r
+CountTFreq (\r
+  VOID\r
+  );\r
+\r
+STATIC\r
+VOID\r
+WritePTLen (\r
+  IN INT32 Number,\r
+  IN INT32 nbit,\r
+  IN INT32 Special\r
+  );\r
+\r
+STATIC\r
+VOID\r
+WriteCLen (\r
+  VOID\r
+  );\r
+\r
+STATIC\r
+VOID\r
+EncodeC (\r
+  IN INT32 Value\r
+  );\r
+\r
+STATIC\r
+VOID\r
+EncodeP (\r
+  IN UINT32 Value\r
+  );\r
+\r
+STATIC\r
+VOID\r
+SendBlock (\r
+  VOID\r
+  );\r
+\r
+STATIC\r
+VOID\r
+Output (\r
+  IN UINT32 c,\r
+  IN UINT32 p\r
+  );\r
+\r
+STATIC\r
+VOID\r
+HufEncodeStart (\r
+  VOID\r
+  );\r
+\r
+STATIC\r
+VOID\r
+HufEncodeEnd (\r
+  VOID\r
+  );\r
+\r
+STATIC\r
+VOID\r
+MakeCrcTable (\r
+  VOID\r
+  );\r
+\r
+STATIC\r
+VOID\r
+PutBits (\r
+  IN INT32  Number,\r
+  IN UINT32 Value\r
+  );\r
+\r
+STATIC\r
+INT32\r
+FreadCrc (\r
+  OUT UINT8 *Pointer,\r
+  IN  INT32 Number\r
+  );\r
+\r
+STATIC\r
+VOID\r
+InitPutBits (\r
+  VOID\r
+  );\r
+\r
+STATIC\r
+VOID\r
+CountLen (\r
+  IN INT32 Index\r
+  );\r
+\r
+STATIC\r
+VOID\r
+MakeLen (\r
+  IN INT32 Root\r
+  );\r
+\r
+STATIC\r
+VOID\r
+DownHeap (\r
+  IN INT32 Index\r
+  );\r
+\r
+STATIC\r
+VOID\r
+MakeCode (\r
+  IN  INT32       Number,\r
+  IN  UINT8 Len[  ],\r
+  OUT UINT16 Code[]\r
+  );\r
+\r
+STATIC\r
+INT32\r
+MakeTree (\r
+  IN  INT32            NParm,\r
+  IN  UINT16  FreqParm[],\r
+  OUT UINT8   LenParm[ ],\r
+  OUT UINT16  CodeParm[]\r
+  );\r
+\r
+//\r
+//  Global Variables\r
+//\r
+static UINT8  *mSrc, *mDst, *mSrcUpperLimit, *mDstUpperLimit;\r
+\r
+static UINT8  *mLevel, *mText, *mChildCount, *mBuf, mCLen[NC], mPTLen[NPT], *mLen;\r
+static INT16  mHeap[NC + 1];\r
+static INT32  mRemainder, mMatchLen, mBitCount, mHeapSize, mN;\r
+static UINT32 mBufSiz = 0, mOutputPos, mOutputMask, mSubBitBuf, mCrc;\r
+static UINT32 mCompSize, mOrigSize;\r
+\r
+static UINT16 *mFreq, *mSortPtr, mLenCnt[17], mLeft[2 * NC - 1], mRight[2 * NC - 1], mCrcTable[UINT8_MAX + 1],\r
+  mCFreq[2 * NC - 1], mCTable[4096], mCCode[NC], mPFreq[2 * NP - 1], mPTCode[NPT], mTFreq[2 * NT - 1];\r
+\r
+static NODE   mPos, mMatchPos, mAvail, *mPosition, *mParent, *mPrev, *mNext = NULL;\r
+\r
+//\r
+// functions\r
+//\r
+EFI_STATUS\r
+Compress (\r
+  IN      UINT8   *SrcBuffer,\r
+  IN      UINT32  SrcSize,\r
+  IN      UINT8   *DstBuffer,\r
+  IN OUT  UINT32  *DstSize\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  The main compression routine.\r
+\r
+Arguments:\r
+\r
+  SrcBuffer   - The buffer storing the source data\r
+  SrcSize     - The size of source data\r
+  DstBuffer   - The buffer to store the compressed data\r
+  DstSize     - On input, the size of DstBuffer; On output,\r
+                the size of the actual compressed data.\r
+\r
+Returns:\r
+\r
+  EFI_BUFFER_TOO_SMALL  - The DstBuffer is too small. In this case,\r
+                DstSize contains the size needed.\r
+  EFI_SUCCESS           - Compression is successful.\r
+  EFI_OUT_OF_RESOURCES  - No resource to complete function.\r
+\r
+--*/\r
+{\r
+  EFI_STATUS  Status;\r
+\r
+  //\r
+  // Initializations\r
+  //\r
+  mBufSiz         = 0;\r
+  mBuf            = NULL;\r
+  mText           = NULL;\r
+  mLevel          = NULL;\r
+  mChildCount     = NULL;\r
+  mPosition       = NULL;\r
+  mParent         = NULL;\r
+  mPrev           = NULL;\r
+  mNext           = NULL;\r
+\r
+  mSrc            = SrcBuffer;\r
+  mSrcUpperLimit  = mSrc + SrcSize;\r
+  mDst            = DstBuffer;\r
+  mDstUpperLimit  = mDst +*DstSize;\r
+\r
+  PutDword (0L);\r
+  PutDword (0L);\r
+\r
+  MakeCrcTable ();\r
+\r
+  mOrigSize             = mCompSize = 0;\r
+  mCrc                  = INIT_CRC;\r
+\r
+  //\r
+  // Compress it\r
+  //\r
+  Status = Encode ();\r
+  if (EFI_ERROR (Status)) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+  //\r
+  // Null terminate the compressed data\r
+  //\r
+  if (mDst < mDstUpperLimit) {\r
+    *mDst++ = 0;\r
+  }\r
+  //\r
+  // Fill in compressed size and original size\r
+  //\r
+  mDst = DstBuffer;\r
+  PutDword (mCompSize + 1);\r
+  PutDword (mOrigSize);\r
+\r
+  //\r
+  // Return\r
+  //\r
+  if (mCompSize + 1 + 8 > *DstSize) {\r
+    *DstSize = mCompSize + 1 + 8;\r
+    return EFI_BUFFER_TOO_SMALL;\r
+  } else {\r
+    *DstSize = mCompSize + 1 + 8;\r
+    return EFI_SUCCESS;\r
+  }\r
+\r
+}\r
+\r
+STATIC\r
+VOID\r
+PutDword (\r
+  IN UINT32 Data\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Put a dword to output stream\r
+  \r
+Arguments:\r
+\r
+  Data    - the dword to put\r
+  \r
+Returns: (VOID)\r
+  \r
+--*/\r
+{\r
+  if (mDst < mDstUpperLimit) {\r
+    *mDst++ = (UINT8) (((UINT8) (Data)) & 0xff);\r
+  }\r
+\r
+  if (mDst < mDstUpperLimit) {\r
+    *mDst++ = (UINT8) (((UINT8) (Data >> 0x08)) & 0xff);\r
+  }\r
+\r
+  if (mDst < mDstUpperLimit) {\r
+    *mDst++ = (UINT8) (((UINT8) (Data >> 0x10)) & 0xff);\r
+  }\r
+\r
+  if (mDst < mDstUpperLimit) {\r
+    *mDst++ = (UINT8) (((UINT8) (Data >> 0x18)) & 0xff);\r
+  }\r
+}\r
+\r
+STATIC\r
+EFI_STATUS\r
+AllocateMemory (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Allocate memory spaces for data structures used in compression process\r
+  \r
+Argements: \r
+  VOID\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS           - Memory is allocated successfully\r
+  EFI_OUT_OF_RESOURCES  - Allocation fails\r
+\r
+--*/\r
+{\r
+  UINT32  Index;\r
+\r
+  mText = malloc (WNDSIZ * 2 + MAXMATCH);\r
+  for (Index = 0; Index < WNDSIZ * 2 + MAXMATCH; Index++) {\r
+    mText[Index] = 0;\r
+  }\r
+\r
+  mLevel      = malloc ((WNDSIZ + UINT8_MAX + 1) * sizeof (*mLevel));\r
+  mChildCount = malloc ((WNDSIZ + UINT8_MAX + 1) * sizeof (*mChildCount));\r
+  mPosition   = malloc ((WNDSIZ + UINT8_MAX + 1) * sizeof (*mPosition));\r
+  mParent     = malloc (WNDSIZ * 2 * sizeof (*mParent));\r
+  mPrev       = malloc (WNDSIZ * 2 * sizeof (*mPrev));\r
+  mNext       = malloc ((MAX_HASH_VAL + 1) * sizeof (*mNext));\r
+\r
+  mBufSiz     = BLKSIZ;\r
+  mBuf        = malloc (mBufSiz);\r
+  while (mBuf == NULL) {\r
+    mBufSiz = (mBufSiz / 10U) * 9U;\r
+    if (mBufSiz < 4 * 1024U) {\r
+      return EFI_OUT_OF_RESOURCES;\r
+    }\r
+\r
+    mBuf = malloc (mBufSiz);\r
+  }\r
+\r
+  mBuf[0] = 0;\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+VOID\r
+FreeMemory (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Called when compression is completed to free memory previously allocated.\r
+  \r
+Arguments: (VOID)\r
+\r
+Returns: (VOID)\r
+\r
+--*/\r
+{\r
+  if (mText != NULL) {\r
+    free (mText);\r
+  }\r
+\r
+  if (mLevel != NULL) {\r
+    free (mLevel);\r
+  }\r
+\r
+  if (mChildCount != NULL) {\r
+    free (mChildCount);\r
+  }\r
+\r
+  if (mPosition != NULL) {\r
+    free (mPosition);\r
+  }\r
+\r
+  if (mParent != NULL) {\r
+    free (mParent);\r
+  }\r
+\r
+  if (mPrev != NULL) {\r
+    free (mPrev);\r
+  }\r
+\r
+  if (mNext != NULL) {\r
+    free (mNext);\r
+  }\r
+\r
+  if (mBuf != NULL) {\r
+    free (mBuf);\r
+  }\r
+\r
+  return ;\r
+}\r
+\r
+STATIC\r
+VOID\r
+InitSlide (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Initialize String Info Log data structures\r
+  \r
+Arguments: (VOID)\r
+\r
+Returns: (VOID)\r
+\r
+--*/\r
+{\r
+  NODE  Index;\r
+\r
+  for (Index = WNDSIZ; Index <= WNDSIZ + UINT8_MAX; Index++) {\r
+    mLevel[Index]     = 1;\r
+    mPosition[Index]  = NIL;  /* sentinel */\r
+  }\r
+\r
+  for (Index = WNDSIZ; Index < WNDSIZ * 2; Index++) {\r
+    mParent[Index] = NIL;\r
+  }\r
+\r
+  mAvail = 1;\r
+  for (Index = 1; Index < WNDSIZ - 1; Index++) {\r
+    mNext[Index] = (NODE) (Index + 1);\r
+  }\r
+\r
+  mNext[WNDSIZ - 1] = NIL;\r
+  for (Index = WNDSIZ * 2; Index <= MAX_HASH_VAL; Index++) {\r
+    mNext[Index] = NIL;\r
+  }\r
+}\r
+\r
+STATIC\r
+NODE\r
+Child (\r
+  IN NODE  NodeQ,\r
+  IN UINT8 CharC\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Find child node given the parent node and the edge character\r
+  \r
+Arguments:\r
+\r
+  NodeQ       - the parent node\r
+  CharC       - the edge character\r
+  \r
+Returns:\r
+\r
+  The child node (NIL if not found)  \r
+  \r
+--*/\r
+{\r
+  NODE  NodeR;\r
+\r
+  NodeR = mNext[HASH (NodeQ, CharC)];\r
+  //\r
+  // sentinel\r
+  //\r
+  mParent[NIL] = NodeQ;\r
+  while (mParent[NodeR] != NodeQ) {\r
+    NodeR = mNext[NodeR];\r
+  }\r
+\r
+  return NodeR;\r
+}\r
+\r
+STATIC\r
+VOID\r
+MakeChild (\r
+  IN NODE  Parent,\r
+  IN UINT8 CharC,\r
+  IN NODE  Child\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Create a new child for a given parent node.\r
+  \r
+Arguments:\r
+\r
+  Parent       - the parent node\r
+  CharC   - the edge character\r
+  Child       - the child node\r
+  \r
+Returns: (VOID)\r
+\r
+--*/\r
+{\r
+  NODE  Node1;\r
+  NODE  Node2;\r
+\r
+  Node1           = (NODE) HASH (Parent, CharC);\r
+  Node2           = mNext[Node1];\r
+  mNext[Node1]    = Child;\r
+  mNext[Child]    = Node2;\r
+  mPrev[Node2]    = Child;\r
+  mPrev[Child]    = Node1;\r
+  mParent[Child]  = Parent;\r
+  mChildCount[Parent]++;\r
+}\r
+\r
+STATIC\r
+VOID\r
+Split (\r
+  NODE Old\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Split a node.\r
+  \r
+Arguments:\r
+\r
+  Old     - the node to split\r
+  \r
+Returns: (VOID)\r
+\r
+--*/\r
+{\r
+  NODE  New;\r
+  NODE  TempNode;\r
+\r
+  New               = mAvail;\r
+  mAvail            = mNext[New];\r
+  mChildCount[New]  = 0;\r
+  TempNode          = mPrev[Old];\r
+  mPrev[New]        = TempNode;\r
+  mNext[TempNode]   = New;\r
+  TempNode          = mNext[Old];\r
+  mNext[New]        = TempNode;\r
+  mPrev[TempNode]   = New;\r
+  mParent[New]      = mParent[Old];\r
+  mLevel[New]       = (UINT8) mMatchLen;\r
+  mPosition[New]    = mPos;\r
+  MakeChild (New, mText[mMatchPos + mMatchLen], Old);\r
+  MakeChild (New, mText[mPos + mMatchLen], mPos);\r
+}\r
+\r
+STATIC\r
+VOID\r
+InsertNode (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Insert string info for current position into the String Info Log\r
+  \r
+Arguments: (VOID)\r
+\r
+Returns: (VOID)\r
+\r
+--*/\r
+{\r
+  NODE  NodeQ;\r
+  NODE  NodeR;\r
+  NODE  Index2;\r
+  NODE  NodeT;\r
+  UINT8 CharC;\r
+  UINT8 *t1;\r
+  UINT8 *t2;\r
+\r
+  if (mMatchLen >= 4) {\r
+    //\r
+    // We have just got a long match, the target tree\r
+    // can be located by MatchPos + 1. Travese the tree\r
+    // from bottom up to get to a proper starting point.\r
+    // The usage of PERC_FLAG ensures proper node deletion\r
+    // in DeleteNode() later.\r
+    //\r
+    mMatchLen--;\r
+    NodeR = (NODE) ((mMatchPos + 1) | WNDSIZ);\r
+    NodeQ = mParent[NodeR];\r
+    while (NodeQ == NIL) {\r
+      NodeR = mNext[NodeR];\r
+      NodeQ = mParent[NodeR];\r
+    }\r
+\r
+    while (mLevel[NodeQ] >= mMatchLen) {\r
+      NodeR = NodeQ;\r
+      NodeQ = mParent[NodeQ];\r
+    }\r
+\r
+    NodeT = NodeQ;\r
+    while (mPosition[NodeT] < 0) {\r
+      mPosition[NodeT]  = mPos;\r
+      NodeT             = mParent[NodeT];\r
+    }\r
+\r
+    if (NodeT < WNDSIZ) {\r
+      mPosition[NodeT] = (NODE) (mPos | (UINT32) PERC_FLAG);\r
+    }\r
+  } else {\r
+    //\r
+    // Locate the target tree\r
+    //\r
+    NodeQ = (NODE) (mText[mPos] + WNDSIZ);\r
+    CharC = mText[mPos + 1];\r
+    NodeR = Child (NodeQ, CharC);\r
+    if (NodeR == NIL) {\r
+      MakeChild (NodeQ, CharC, mPos);\r
+      mMatchLen = 1;\r
+      return ;\r
+    }\r
+\r
+    mMatchLen = 2;\r
+  }\r
+  //\r
+  // Traverse down the tree to find a match.\r
+  // Update Position value along the route.\r
+  // Node split or creation is involved.\r
+  //\r
+  for (;;) {\r
+    if (NodeR >= WNDSIZ) {\r
+      Index2    = MAXMATCH;\r
+      mMatchPos = NodeR;\r
+    } else {\r
+      Index2    = mLevel[NodeR];\r
+      mMatchPos = (NODE) (mPosition[NodeR] & (UINT32)~PERC_FLAG);\r
+    }\r
+\r
+    if (mMatchPos >= mPos) {\r
+      mMatchPos -= WNDSIZ;\r
+    }\r
+\r
+    t1  = &mText[mPos + mMatchLen];\r
+    t2  = &mText[mMatchPos + mMatchLen];\r
+    while (mMatchLen < Index2) {\r
+      if (*t1 != *t2) {\r
+        Split (NodeR);\r
+        return ;\r
+      }\r
+\r
+      mMatchLen++;\r
+      t1++;\r
+      t2++;\r
+    }\r
+\r
+    if (mMatchLen >= MAXMATCH) {\r
+      break;\r
+    }\r
+\r
+    mPosition[NodeR]  = mPos;\r
+    NodeQ             = NodeR;\r
+    NodeR             = Child (NodeQ, *t1);\r
+    if (NodeR == NIL) {\r
+      MakeChild (NodeQ, *t1, mPos);\r
+      return ;\r
+    }\r
+\r
+    mMatchLen++;\r
+  }\r
+\r
+  NodeT           = mPrev[NodeR];\r
+  mPrev[mPos]     = NodeT;\r
+  mNext[NodeT]    = mPos;\r
+  NodeT           = mNext[NodeR];\r
+  mNext[mPos]     = NodeT;\r
+  mPrev[NodeT]    = mPos;\r
+  mParent[mPos]   = NodeQ;\r
+  mParent[NodeR]  = NIL;\r
+\r
+  //\r
+  // Special usage of 'next'\r
+  //\r
+  mNext[NodeR] = mPos;\r
+\r
+}\r
+\r
+STATIC\r
+VOID\r
+DeleteNode (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Delete outdated string info. (The Usage of PERC_FLAG\r
+  ensures a clean deletion)\r
+  \r
+Arguments: (VOID)\r
+\r
+Returns: (VOID)\r
+\r
+--*/\r
+{\r
+  NODE  NodeQ;\r
+  NODE  NodeR;\r
+  NODE  NodeS;\r
+  NODE  NodeT;\r
+  NODE  NodeU;\r
+\r
+  if (mParent[mPos] == NIL) {\r
+    return ;\r
+  }\r
+\r
+  NodeR         = mPrev[mPos];\r
+  NodeS         = mNext[mPos];\r
+  mNext[NodeR]  = NodeS;\r
+  mPrev[NodeS]  = NodeR;\r
+  NodeR         = mParent[mPos];\r
+  mParent[mPos] = NIL;\r
+  if (NodeR >= WNDSIZ) {\r
+    return ;\r
+  }\r
+\r
+  mChildCount[NodeR]--;\r
+  if (mChildCount[NodeR] > 1) {\r
+    return ;\r
+  }\r
+\r
+  NodeT = (NODE) (mPosition[NodeR] & (UINT32)~PERC_FLAG);\r
+  if (NodeT >= mPos) {\r
+    NodeT -= WNDSIZ;\r
+  }\r
+\r
+  NodeS = NodeT;\r
+  NodeQ = mParent[NodeR];\r
+  NodeU = mPosition[NodeQ];\r
+  while (NodeU & (UINT32) PERC_FLAG) {\r
+    NodeU &= (UINT32)~PERC_FLAG;\r
+    if (NodeU >= mPos) {\r
+      NodeU -= WNDSIZ;\r
+    }\r
+\r
+    if (NodeU > NodeS) {\r
+      NodeS = NodeU;\r
+    }\r
+\r
+    mPosition[NodeQ]  = (NODE) (NodeS | WNDSIZ);\r
+    NodeQ             = mParent[NodeQ];\r
+    NodeU             = mPosition[NodeQ];\r
+  }\r
+\r
+  if (NodeQ < WNDSIZ) {\r
+    if (NodeU >= mPos) {\r
+      NodeU -= WNDSIZ;\r
+    }\r
+\r
+    if (NodeU > NodeS) {\r
+      NodeS = NodeU;\r
+    }\r
+\r
+    mPosition[NodeQ] = (NODE) (NodeS | WNDSIZ | (UINT32) PERC_FLAG);\r
+  }\r
+\r
+  NodeS           = Child (NodeR, mText[NodeT + mLevel[NodeR]]);\r
+  NodeT           = mPrev[NodeS];\r
+  NodeU           = mNext[NodeS];\r
+  mNext[NodeT]    = NodeU;\r
+  mPrev[NodeU]    = NodeT;\r
+  NodeT           = mPrev[NodeR];\r
+  mNext[NodeT]    = NodeS;\r
+  mPrev[NodeS]    = NodeT;\r
+  NodeT           = mNext[NodeR];\r
+  mPrev[NodeT]    = NodeS;\r
+  mNext[NodeS]    = NodeT;\r
+  mParent[NodeS]  = mParent[NodeR];\r
+  mParent[NodeR]  = NIL;\r
+  mNext[NodeR]    = mAvail;\r
+  mAvail          = NodeR;\r
+}\r
+\r
+STATIC\r
+VOID\r
+GetNextMatch (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Advance the current position (read in new data if needed).\r
+  Delete outdated string info. Find a match string for current position.\r
+\r
+Arguments: (VOID)\r
+\r
+Returns: (VOID)\r
+\r
+--*/\r
+{\r
+  INT32 Number;\r
+\r
+  mRemainder--;\r
+  mPos++;\r
+  if (mPos == WNDSIZ * 2) {\r
+    memmove (&mText[0], &mText[WNDSIZ], WNDSIZ + MAXMATCH);\r
+    Number = FreadCrc (&mText[WNDSIZ + MAXMATCH], WNDSIZ);\r
+    mRemainder += Number;\r
+    mPos = WNDSIZ;\r
+  }\r
+\r
+  DeleteNode ();\r
+  InsertNode ();\r
+}\r
+\r
+STATIC\r
+EFI_STATUS\r
+Encode (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  The main controlling routine for compression process.\r
+\r
+Arguments: (VOID)\r
+\r
+Returns:\r
+  \r
+  EFI_SUCCESS           - The compression is successful\r
+  EFI_OUT_0F_RESOURCES  - Not enough memory for compression process\r
+\r
+--*/\r
+{\r
+  EFI_STATUS  Status;\r
+  INT32       LastMatchLen;\r
+  NODE        LastMatchPos;\r
+\r
+  Status = AllocateMemory ();\r
+  if (EFI_ERROR (Status)) {\r
+    FreeMemory ();\r
+    return Status;\r
+  }\r
+\r
+  InitSlide ();\r
+\r
+  HufEncodeStart ();\r
+\r
+  mRemainder  = FreadCrc (&mText[WNDSIZ], WNDSIZ + MAXMATCH);\r
+\r
+  mMatchLen   = 0;\r
+  mPos        = WNDSIZ;\r
+  InsertNode ();\r
+  if (mMatchLen > mRemainder) {\r
+    mMatchLen = mRemainder;\r
+  }\r
+\r
+  while (mRemainder > 0) {\r
+    LastMatchLen  = mMatchLen;\r
+    LastMatchPos  = mMatchPos;\r
+    GetNextMatch ();\r
+    if (mMatchLen > mRemainder) {\r
+      mMatchLen = mRemainder;\r
+    }\r
+\r
+    if (mMatchLen > LastMatchLen || LastMatchLen < THRESHOLD) {\r
+      //\r
+      // Not enough benefits are gained by outputting a pointer,\r
+      // so just output the original character\r
+      //\r
+      Output (mText[mPos - 1], 0);\r
+\r
+    } else {\r
+\r
+      if (LastMatchLen == THRESHOLD) {\r
+        if (((mPos - LastMatchPos - 2) & (WNDSIZ - 1)) > (1U << 11)) {\r
+          Output (mText[mPos - 1], 0);\r
+          continue;\r
+        }\r
+      }\r
+      //\r
+      // Outputting a pointer is beneficial enough, do it.\r
+      //\r
+      Output (\r
+        LastMatchLen + (UINT8_MAX + 1 - THRESHOLD),\r
+        (mPos - LastMatchPos - 2) & (WNDSIZ - 1)\r
+        );\r
+      LastMatchLen--;\r
+      while (LastMatchLen > 0) {\r
+        GetNextMatch ();\r
+        LastMatchLen--;\r
+      }\r
+\r
+      if (mMatchLen > mRemainder) {\r
+        mMatchLen = mRemainder;\r
+      }\r
+    }\r
+  }\r
+\r
+  HufEncodeEnd ();\r
+  FreeMemory ();\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+STATIC\r
+VOID\r
+CountTFreq (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Count the frequencies for the Extra Set\r
+  \r
+Arguments: (VOID)\r
+\r
+Returns: (VOID)\r
+\r
+--*/\r
+{\r
+  INT32 Index;\r
+  INT32 Index3;\r
+  INT32 Number;\r
+  INT32 Count;\r
+\r
+  for (Index = 0; Index < NT; Index++) {\r
+    mTFreq[Index] = 0;\r
+  }\r
+\r
+  Number = NC;\r
+  while (Number > 0 && mCLen[Number - 1] == 0) {\r
+    Number--;\r
+  }\r
+\r
+  Index = 0;\r
+  while (Index < Number) {\r
+    Index3 = mCLen[Index++];\r
+    if (Index3 == 0) {\r
+      Count = 1;\r
+      while (Index < Number && mCLen[Index] == 0) {\r
+        Index++;\r
+        Count++;\r
+      }\r
+\r
+      if (Count <= 2) {\r
+        mTFreq[0] = (UINT16) (mTFreq[0] + Count);\r
+      } else if (Count <= 18) {\r
+        mTFreq[1]++;\r
+      } else if (Count == 19) {\r
+        mTFreq[0]++;\r
+        mTFreq[1]++;\r
+      } else {\r
+        mTFreq[2]++;\r
+      }\r
+    } else {\r
+      mTFreq[Index3 + 2]++;\r
+    }\r
+  }\r
+}\r
+\r
+STATIC\r
+VOID\r
+WritePTLen (\r
+  IN INT32 Number,\r
+  IN INT32 nbit,\r
+  IN INT32 Special\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Outputs the code length array for the Extra Set or the Position Set.\r
+  \r
+Arguments:\r
+\r
+  Number       - the number of symbols\r
+  nbit    - the number of bits needed to represent 'n'\r
+  Special - the special symbol that needs to be take care of\r
+  \r
+Returns: (VOID)\r
+\r
+--*/\r
+{\r
+  INT32 Index;\r
+  INT32 Index3;\r
+\r
+  while (Number > 0 && mPTLen[Number - 1] == 0) {\r
+    Number--;\r
+  }\r
+\r
+  PutBits (nbit, Number);\r
+  Index = 0;\r
+  while (Index < Number) {\r
+    Index3 = mPTLen[Index++];\r
+    if (Index3 <= 6) {\r
+      PutBits (3, Index3);\r
+    } else {\r
+      PutBits (Index3 - 3, (1U << (Index3 - 3)) - 2);\r
+    }\r
+\r
+    if (Index == Special) {\r
+      while (Index < 6 && mPTLen[Index] == 0) {\r
+        Index++;\r
+      }\r
+\r
+      PutBits (2, (Index - 3) & 3);\r
+    }\r
+  }\r
+}\r
+\r
+STATIC\r
+VOID\r
+WriteCLen (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Outputs the code length array for Char&Length Set\r
+  \r
+Arguments: (VOID)\r
+\r
+Returns: (VOID)\r
+\r
+--*/\r
+{\r
+  INT32 Index;\r
+  INT32 Index3;\r
+  INT32 Number;\r
+  INT32 Count;\r
+\r
+  Number = NC;\r
+  while (Number > 0 && mCLen[Number - 1] == 0) {\r
+    Number--;\r
+  }\r
+\r
+  PutBits (CBIT, Number);\r
+  Index = 0;\r
+  while (Index < Number) {\r
+    Index3 = mCLen[Index++];\r
+    if (Index3 == 0) {\r
+      Count = 1;\r
+      while (Index < Number && mCLen[Index] == 0) {\r
+        Index++;\r
+        Count++;\r
+      }\r
+\r
+      if (Count <= 2) {\r
+        for (Index3 = 0; Index3 < Count; Index3++) {\r
+          PutBits (mPTLen[0], mPTCode[0]);\r
+        }\r
+      } else if (Count <= 18) {\r
+        PutBits (mPTLen[1], mPTCode[1]);\r
+        PutBits (4, Count - 3);\r
+      } else if (Count == 19) {\r
+        PutBits (mPTLen[0], mPTCode[0]);\r
+        PutBits (mPTLen[1], mPTCode[1]);\r
+        PutBits (4, 15);\r
+      } else {\r
+        PutBits (mPTLen[2], mPTCode[2]);\r
+        PutBits (CBIT, Count - 20);\r
+      }\r
+    } else {\r
+      PutBits (mPTLen[Index3 + 2], mPTCode[Index3 + 2]);\r
+    }\r
+  }\r
+}\r
+\r
+STATIC\r
+VOID\r
+EncodeC (\r
+  IN INT32 Value\r
+  )\r
+{\r
+  PutBits (mCLen[Value], mCCode[Value]);\r
+}\r
+\r
+STATIC\r
+VOID\r
+EncodeP (\r
+  IN UINT32 Value\r
+  )\r
+{\r
+  UINT32  Index;\r
+  UINT32  NodeQ;\r
+\r
+  Index = 0;\r
+  NodeQ = Value;\r
+  while (NodeQ) {\r
+    NodeQ >>= 1;\r
+    Index++;\r
+  }\r
+\r
+  PutBits (mPTLen[Index], mPTCode[Index]);\r
+  if (Index > 1) {\r
+    PutBits (Index - 1, Value & (0xFFFFFFFFU >> (32 - Index + 1)));\r
+  }\r
+}\r
+\r
+STATIC\r
+VOID\r
+SendBlock (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Huffman code the block and output it.\r
+  \r
+Arguments: \r
+  (VOID)\r
+\r
+Returns: \r
+  (VOID)\r
+\r
+--*/\r
+{\r
+  UINT32  Index;\r
+  UINT32  Index2;\r
+  UINT32  Index3;\r
+  UINT32  Flags;\r
+  UINT32  Root;\r
+  UINT32  Pos;\r
+  UINT32  Size;\r
+  Flags = 0;\r
+\r
+  Root  = MakeTree (NC, mCFreq, mCLen, mCCode);\r
+  Size  = mCFreq[Root];\r
+  PutBits (16, Size);\r
+  if (Root >= NC) {\r
+    CountTFreq ();\r
+    Root = MakeTree (NT, mTFreq, mPTLen, mPTCode);\r
+    if (Root >= NT) {\r
+      WritePTLen (NT, TBIT, 3);\r
+    } else {\r
+      PutBits (TBIT, 0);\r
+      PutBits (TBIT, Root);\r
+    }\r
+\r
+    WriteCLen ();\r
+  } else {\r
+    PutBits (TBIT, 0);\r
+    PutBits (TBIT, 0);\r
+    PutBits (CBIT, 0);\r
+    PutBits (CBIT, Root);\r
+  }\r
+\r
+  Root = MakeTree (NP, mPFreq, mPTLen, mPTCode);\r
+  if (Root >= NP) {\r
+    WritePTLen (NP, PBIT, -1);\r
+  } else {\r
+    PutBits (PBIT, 0);\r
+    PutBits (PBIT, Root);\r
+  }\r
+\r
+  Pos = 0;\r
+  for (Index = 0; Index < Size; Index++) {\r
+    if (Index % UINT8_BIT == 0) {\r
+      Flags = mBuf[Pos++];\r
+    } else {\r
+      Flags <<= 1;\r
+    }\r
+\r
+    if (Flags & (1U << (UINT8_BIT - 1))) {\r
+      EncodeC (mBuf[Pos++] + (1U << UINT8_BIT));\r
+      Index3 = mBuf[Pos++];\r
+      for (Index2 = 0; Index2 < 3; Index2++) {\r
+        Index3 <<= UINT8_BIT;\r
+        Index3 += mBuf[Pos++];\r
+      }\r
+\r
+      EncodeP (Index3);\r
+    } else {\r
+      EncodeC (mBuf[Pos++]);\r
+    }\r
+  }\r
+\r
+  for (Index = 0; Index < NC; Index++) {\r
+    mCFreq[Index] = 0;\r
+  }\r
+\r
+  for (Index = 0; Index < NP; Index++) {\r
+    mPFreq[Index] = 0;\r
+  }\r
+}\r
+\r
+STATIC\r
+VOID\r
+Output (\r
+  IN UINT32 CharC,\r
+  IN UINT32 Pos\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Outputs an Original Character or a Pointer\r
+\r
+Arguments:\r
+\r
+  CharC     - The original character or the 'String Length' element of a Pointer\r
+  Pos     - The 'Position' field of a Pointer\r
+\r
+Returns: (VOID)\r
+\r
+--*/\r
+{\r
+  static UINT32 CPos;\r
+\r
+  if ((mOutputMask >>= 1) == 0) {\r
+    mOutputMask = 1U << (UINT8_BIT - 1);\r
+    //\r
+    // Check the buffer overflow per outputing UINT8_BIT symbols\r
+    // which is an Original Character or a Pointer. The biggest\r
+    // symbol is a Pointer which occupies 5 bytes.\r
+    //\r
+    if (mOutputPos >= mBufSiz - 5 * UINT8_BIT) {\r
+      SendBlock ();\r
+      mOutputPos = 0;\r
+    }\r
+\r
+    CPos        = mOutputPos++;\r
+    mBuf[CPos]  = 0;\r
+  }\r
+\r
+  mBuf[mOutputPos++] = (UINT8) CharC;\r
+  mCFreq[CharC]++;\r
+  if (CharC >= (1U << UINT8_BIT)) {\r
+    mBuf[CPos] |= mOutputMask;\r
+    mBuf[mOutputPos++]  = (UINT8) (Pos >> 24);\r
+    mBuf[mOutputPos++]  = (UINT8) (Pos >> 16);\r
+    mBuf[mOutputPos++]  = (UINT8) (Pos >> (UINT8_BIT));\r
+    mBuf[mOutputPos++]  = (UINT8) Pos;\r
+    CharC               = 0;\r
+    while (Pos) {\r
+      Pos >>= 1;\r
+      CharC++;\r
+    }\r
+\r
+    mPFreq[CharC]++;\r
+  }\r
+}\r
+\r
+STATIC\r
+VOID\r
+HufEncodeStart (\r
+  VOID\r
+  )\r
+{\r
+  INT32 Index;\r
+\r
+  for (Index = 0; Index < NC; Index++) {\r
+    mCFreq[Index] = 0;\r
+  }\r
+\r
+  for (Index = 0; Index < NP; Index++) {\r
+    mPFreq[Index] = 0;\r
+  }\r
+\r
+  mOutputPos = mOutputMask = 0;\r
+  InitPutBits ();\r
+  return ;\r
+}\r
+\r
+STATIC\r
+VOID\r
+HufEncodeEnd (\r
+  VOID\r
+  )\r
+{\r
+  SendBlock ();\r
+\r
+  //\r
+  // Flush remaining bits\r
+  //\r
+  PutBits (UINT8_BIT - 1, 0);\r
+\r
+  return ;\r
+}\r
+\r
+STATIC\r
+VOID\r
+MakeCrcTable (\r
+  VOID\r
+  )\r
+{\r
+  UINT32  Index;\r
+  UINT32  Index2;\r
+  UINT32  Temp;\r
+\r
+  for (Index = 0; Index <= UINT8_MAX; Index++) {\r
+    Temp = Index;\r
+    for (Index2 = 0; Index2 < UINT8_BIT; Index2++) {\r
+      if (Temp & 1) {\r
+        Temp = (Temp >> 1) ^ CRCPOLY;\r
+      } else {\r
+        Temp >>= 1;\r
+      }\r
+    }\r
+\r
+    mCrcTable[Index] = (UINT16) Temp;\r
+  }\r
+}\r
+\r
+STATIC\r
+VOID\r
+PutBits (\r
+  IN INT32  Number,\r
+  IN UINT32 Value\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Outputs rightmost n bits of x\r
+\r
+Arguments:\r
+\r
+  Number   - the rightmost n bits of the data is used\r
+  x   - the data \r
+\r
+Returns: (VOID)\r
+\r
+--*/\r
+{\r
+  UINT8 Temp;\r
+\r
+  while (Number >= mBitCount) {\r
+    //\r
+    // Number -= mBitCount should never equal to 32\r
+    //\r
+    Temp = (UINT8) (mSubBitBuf | (Value >> (Number -= mBitCount)));\r
+    if (mDst < mDstUpperLimit) {\r
+      *mDst++ = Temp;\r
+    }\r
+\r
+    mCompSize++;\r
+    mSubBitBuf  = 0;\r
+    mBitCount   = UINT8_BIT;\r
+  }\r
+\r
+  mSubBitBuf |= Value << (mBitCount -= Number);\r
+}\r
+\r
+STATIC\r
+INT32\r
+FreadCrc (\r
+  OUT UINT8 *Pointer,\r
+  IN  INT32 Number\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Read in source data\r
+  \r
+Arguments:\r
+\r
+  Pointer   - the buffer to hold the data\r
+  Number   - number of bytes to read\r
+\r
+Returns:\r
+\r
+  number of bytes actually read\r
+  \r
+--*/\r
+{\r
+  INT32 Index;\r
+\r
+  for (Index = 0; mSrc < mSrcUpperLimit && Index < Number; Index++) {\r
+    *Pointer++ = *mSrc++;\r
+  }\r
+\r
+  Number = Index;\r
+\r
+  Pointer -= Number;\r
+  mOrigSize += Number;\r
+  Index--;\r
+  while (Index >= 0) {\r
+    UPDATE_CRC (*Pointer++);\r
+    Index--;\r
+  }\r
+\r
+  return Number;\r
+}\r
+\r
+STATIC\r
+VOID\r
+InitPutBits (\r
+  VOID\r
+  )\r
+{\r
+  mBitCount   = UINT8_BIT;\r
+  mSubBitBuf  = 0;\r
+}\r
+\r
+STATIC\r
+VOID\r
+CountLen (\r
+  IN INT32 Index\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Count the number of each code length for a Huffman tree.\r
+  \r
+Arguments:\r
+\r
+  Index   - the top node\r
+  \r
+Returns: (VOID)\r
+\r
+--*/\r
+{\r
+  static INT32  Depth = 0;\r
+\r
+  if (Index < mN) {\r
+    mLenCnt[(Depth < 16) ? Depth : 16]++;\r
+  } else {\r
+    Depth++;\r
+    CountLen (mLeft[Index]);\r
+    CountLen (mRight[Index]);\r
+    Depth--;\r
+  }\r
+}\r
+\r
+STATIC\r
+VOID\r
+MakeLen (\r
+  IN INT32 Root\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Create code length array for a Huffman tree\r
+  \r
+Arguments:\r
+\r
+  Root   - the root of the tree\r
+  \r
+Returns:\r
+\r
+  VOID\r
+\r
+--*/\r
+{\r
+  INT32   Index;\r
+  INT32   Index3;\r
+  UINT32  Cum;\r
+\r
+  for (Index = 0; Index <= 16; Index++) {\r
+    mLenCnt[Index] = 0;\r
+  }\r
+\r
+  CountLen (Root);\r
+\r
+  //\r
+  // Adjust the length count array so that\r
+  // no code will be generated longer than its designated length\r
+  //\r
+  Cum = 0;\r
+  for (Index = 16; Index > 0; Index--) {\r
+    Cum += mLenCnt[Index] << (16 - Index);\r
+  }\r
+\r
+  while (Cum != (1U << 16)) {\r
+    mLenCnt[16]--;\r
+    for (Index = 15; Index > 0; Index--) {\r
+      if (mLenCnt[Index] != 0) {\r
+        mLenCnt[Index]--;\r
+        mLenCnt[Index + 1] += 2;\r
+        break;\r
+      }\r
+    }\r
+\r
+    Cum--;\r
+  }\r
+\r
+  for (Index = 16; Index > 0; Index--) {\r
+    Index3 = mLenCnt[Index];\r
+    Index3--;\r
+    while (Index3 >= 0) {\r
+      mLen[*mSortPtr++] = (UINT8) Index;\r
+      Index3--;\r
+    }\r
+  }\r
+}\r
+\r
+STATIC\r
+VOID\r
+DownHeap (\r
+  IN INT32 Index\r
+  )\r
+{\r
+  INT32 Index2;\r
+  INT32 Index3;\r
+\r
+  //\r
+  // priority queue: send Index-th entry down heap\r
+  //\r
+  Index3  = mHeap[Index];\r
+  Index2  = 2 * Index;\r
+  while (Index2 <= mHeapSize) {\r
+    if (Index2 < mHeapSize && mFreq[mHeap[Index2]] > mFreq[mHeap[Index2 + 1]]) {\r
+      Index2++;\r
+    }\r
+\r
+    if (mFreq[Index3] <= mFreq[mHeap[Index2]]) {\r
+      break;\r
+    }\r
+\r
+    mHeap[Index]  = mHeap[Index2];\r
+    Index         = Index2;\r
+    Index2        = 2 * Index;\r
+  }\r
+\r
+  mHeap[Index] = (INT16) Index3;\r
+}\r
+\r
+STATIC\r
+VOID\r
+MakeCode (\r
+  IN  INT32       Number,\r
+  IN  UINT8 Len[  ],\r
+  OUT UINT16 Code[]\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Assign code to each symbol based on the code length array\r
+  \r
+Arguments:\r
+\r
+  Number     - number of symbols\r
+  Len   - the code length array\r
+  Code  - stores codes for each symbol\r
+\r
+Returns: (VOID)\r
+\r
+--*/\r
+{\r
+  INT32   Index;\r
+  UINT16  Start[18];\r
+\r
+  Start[1] = 0;\r
+  for (Index = 1; Index <= 16; Index++) {\r
+    Start[Index + 1] = (UINT16) ((Start[Index] + mLenCnt[Index]) << 1);\r
+  }\r
+\r
+  for (Index = 0; Index < Number; Index++) {\r
+    Code[Index] = Start[Len[Index]]++;\r
+  }\r
+}\r
+\r
+STATIC\r
+INT32\r
+MakeTree (\r
+  IN  INT32            NParm,\r
+  IN  UINT16  FreqParm[],\r
+  OUT UINT8   LenParm[ ],\r
+  OUT UINT16  CodeParm[]\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Generates Huffman codes given a frequency distribution of symbols\r
+  \r
+Arguments:\r
+\r
+  NParm    - number of symbols\r
+  FreqParm - frequency of each symbol\r
+  LenParm  - code length for each symbol\r
+  CodeParm - code for each symbol\r
+  \r
+Returns:\r
+\r
+  Root of the Huffman tree.\r
+  \r
+--*/\r
+{\r
+  INT32 Index;\r
+  INT32 Index2;\r
+  INT32 Index3;\r
+  INT32 Avail;\r
+\r
+  //\r
+  // make tree, calculate len[], return root\r
+  //\r
+  mN        = NParm;\r
+  mFreq     = FreqParm;\r
+  mLen      = LenParm;\r
+  Avail     = mN;\r
+  mHeapSize = 0;\r
+  mHeap[1]  = 0;\r
+  for (Index = 0; Index < mN; Index++) {\r
+    mLen[Index] = 0;\r
+    if (mFreq[Index]) {\r
+      mHeapSize++;\r
+      mHeap[mHeapSize] = (INT16) Index;\r
+    }\r
+  }\r
+\r
+  if (mHeapSize < 2) {\r
+    CodeParm[mHeap[1]] = 0;\r
+    return mHeap[1];\r
+  }\r
+\r
+  for (Index = mHeapSize / 2; Index >= 1; Index--) {\r
+    //\r
+    // make priority queue\r
+    //\r
+    DownHeap (Index);\r
+  }\r
+\r
+  mSortPtr = CodeParm;\r
+  do {\r
+    Index = mHeap[1];\r
+    if (Index < mN) {\r
+      *mSortPtr++ = (UINT16) Index;\r
+    }\r
+\r
+    mHeap[1] = mHeap[mHeapSize--];\r
+    DownHeap (1);\r
+    Index2 = mHeap[1];\r
+    if (Index2 < mN) {\r
+      *mSortPtr++ = (UINT16) Index2;\r
+    }\r
+\r
+    Index3        = Avail++;\r
+    mFreq[Index3] = (UINT16) (mFreq[Index] + mFreq[Index2]);\r
+    mHeap[1]      = (INT16) Index3;\r
+    DownHeap (1);\r
+    mLeft[Index3]   = (UINT16) Index;\r
+    mRight[Index3]  = (UINT16) Index2;\r
+  } while (mHeapSize > 1);\r
+\r
+  mSortPtr = CodeParm;\r
+  MakeLen (Index3);\r
+  MakeCode (NParm, LenParm, CodeParm);\r
+\r
+  //\r
+  // return root\r
+  //\r
+  return Index3;\r
+}\r
diff --git a/Tools/CodeTools/Source/Common/EfiCompress.h b/Tools/CodeTools/Source/Common/EfiCompress.h
new file mode 100644 (file)
index 0000000..6ad80e4
--- /dev/null
@@ -0,0 +1,69 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  EfiCompress.h\r
+\r
+Abstract:\r
+\r
+  Header file for compression routine\r
+  \r
+--*/\r
+\r
+#ifndef _EFICOMPRESS_H\r
+#define _EFICOMPRESS_H\r
+\r
+#include <string.h>\r
+#include <stdlib.h>\r
+\r
+#include <Common/UefiBaseTypes.h>\r
+\r
+EFI_STATUS\r
+Compress (\r
+  IN      UINT8   *SrcBuffer,\r
+  IN      UINT32  SrcSize,\r
+  IN      UINT8   *DstBuffer,\r
+  IN OUT  UINT32  *DstSize\r
+  )\r
+;\r
+\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  The compression routine.\r
+\r
+Arguments:\r
+\r
+  SrcBuffer   - The buffer storing the source data\r
+  SrcSize     - The size of source data\r
+  DstBuffer   - The buffer to store the compressed data\r
+  DstSize     - On input, the size of DstBuffer; On output,\r
+                the size of the actual compressed data.\r
+\r
+Returns:\r
+\r
+  EFI_BUFFER_TOO_SMALL  - The DstBuffer is too small. In this case,\r
+                DstSize contains the size needed.\r
+  EFI_SUCCESS           - Compression is successful.\r
+\r
+--*/\r
+typedef\r
+EFI_STATUS\r
+(*COMPRESS_FUNCTION) (\r
+  IN      UINT8   *SrcBuffer,\r
+  IN      UINT32  SrcSize,\r
+  IN      UINT8   *DstBuffer,\r
+  IN OUT  UINT32  *DstSize\r
+  );\r
+\r
+#endif\r
diff --git a/Tools/CodeTools/Source/Common/EfiCustomizedCompress.h b/Tools/CodeTools/Source/Common/EfiCustomizedCompress.h
new file mode 100644 (file)
index 0000000..af26b6f
--- /dev/null
@@ -0,0 +1,141 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+  EfiCustomizedCompress.h\r
+\r
+Abstract:\r
+\r
+  Header file for Customized compression routine\r
+  \r
+--*/\r
+\r
+#ifndef _EFICUSTOMIZEDCOMPRESS_H\r
+#define _EFICUSTOMIZEDCOMPRESS_H\r
+\r
+#include <Common/UefiBaseTypes.h>\r
+\r
+EFI_STATUS\r
+SetCustomizedCompressionType (\r
+  IN  CHAR8   *Type\r
+  )\r
+;\r
+\r
+/*++\r
+\r
+Routine Description:\r
+\r
+The implementation of Customized SetCompressionType().\r
+\r
+Arguments:\r
+  Type        - The type if compression.\r
+    \r
+Returns:\r
+    \r
+  EFI_SUCCESS           - The type has been set.\r
+  EFI_UNSUPPORTED       - This type is unsupported.\r
+\r
+    \r
+--*/\r
+EFI_STATUS\r
+CustomizedGetInfo (\r
+  IN      VOID    *Source,\r
+  IN      UINT32  SrcSize,\r
+  OUT     UINT32  *DstSize,\r
+  OUT     UINT32  *ScratchSize\r
+  )\r
+;\r
+\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  The implementation of Customized GetInfo().\r
+\r
+Arguments:\r
+\r
+  Source      - The source buffer containing the compressed data.\r
+  SrcSize     - The size of source buffer\r
+  DstSize     - The size of destination buffer.\r
+  ScratchSize - The size of scratch buffer.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS           - The size of destination buffer and the size of scratch buffer are successull retrieved.\r
+  EFI_INVALID_PARAMETER - The source data is corrupted\r
+\r
+--*/\r
+EFI_STATUS\r
+CustomizedDecompress (\r
+  IN      VOID    *Source,\r
+  IN      UINT32  SrcSize,\r
+  IN OUT  VOID    *Destination,\r
+  IN      UINT32  DstSize,\r
+  IN OUT  VOID    *Scratch,\r
+  IN      UINT32  ScratchSize\r
+  )\r
+;\r
+\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  The implementation of Customized Decompress().\r
+\r
+Arguments:\r
+\r
+  This        - The protocol instance pointer\r
+  Source      - The source buffer containing the compressed data.\r
+  SrcSize     - The size of source buffer\r
+  Destination - The destination buffer to store the decompressed data\r
+  DstSize     - The size of destination buffer.\r
+  Scratch     - The buffer used internally by the decompress routine. This  buffer is needed to store intermediate data.\r
+  ScratchSize - The size of scratch buffer.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS           - Decompression is successfull\r
+  EFI_INVALID_PARAMETER - The source data is corrupted\r
+\r
+--*/\r
+EFI_STATUS\r
+CustomizedCompress (\r
+  IN      UINT8   *SrcBuffer,\r
+  IN      UINT32  SrcSize,\r
+  IN      UINT8   *DstBuffer,\r
+  IN OUT  UINT32  *DstSize\r
+  )\r
+;\r
+\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  The Customized compression routine.\r
+\r
+Arguments:\r
+\r
+  SrcBuffer   - The buffer storing the source data\r
+  SrcSize     - The size of source data\r
+  DstBuffer   - The buffer to store the compressed data\r
+  DstSize     - On input, the size of DstBuffer; On output,\r
+                the size of the actual compressed data.\r
+\r
+Returns:\r
+\r
+  EFI_BUFFER_TOO_SMALL  - The DstBuffer is too small. In this case,\r
+                          DstSize contains the size needed.\r
+  EFI_SUCCESS           - Compression is successful.\r
+\r
+--*/\r
+\r
+#endif\r
diff --git a/Tools/CodeTools/Source/Common/EfiDecompress.c b/Tools/CodeTools/Source/Common/EfiDecompress.c
new file mode 100644 (file)
index 0000000..288c425
--- /dev/null
@@ -0,0 +1,790 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+  EfiDecompress.c\r
+\r
+Abstract:\r
+\r
+  Decompressor. Algorithm Ported from OPSD code (Decomp.asm)\r
+  \r
+--*/\r
+\r
+#include "EfiDecompress.h"\r
+\r
+//\r
+// Decompression algorithm begins here\r
+//\r
+#define BITBUFSIZ 32\r
+#define MAXMATCH  256\r
+#define THRESHOLD 3\r
+#define CODE_BIT  16\r
+#define BAD_TABLE - 1\r
+\r
+//\r
+// C: Char&Len Set; P: Position Set; T: exTra Set\r
+//\r
+#define NC    (0xff + MAXMATCH + 2 - THRESHOLD)\r
+#define CBIT  9\r
+#define PBIT  5\r
+#define TBIT  5\r
+#define MAXNP ((1U << PBIT) - 1)\r
+#define NT    (CODE_BIT + 3)\r
+#if NT > MAXNP\r
+#define NPT NT\r
+#else\r
+#define NPT MAXNP\r
+#endif\r
+\r
+typedef struct {\r
+  UINT8   *mSrcBase;  // Starting address of compressed data\r
+  UINT8   *mDstBase;  // Starting address of decompressed data\r
+  UINT32  mOutBuf;\r
+  UINT32  mInBuf;\r
+\r
+  UINT16  mBitCount;\r
+  UINT32  mBitBuf;\r
+  UINT32  mSubBitBuf;\r
+  UINT16  mBlockSize;\r
+  UINT32  mCompSize;\r
+  UINT32  mOrigSize;\r
+\r
+  UINT16  mBadTableFlag;\r
+\r
+  UINT16  mLeft[2 * NC - 1];\r
+  UINT16  mRight[2 * NC - 1];\r
+  UINT8   mCLen[NC];\r
+  UINT8   mPTLen[NPT];\r
+  UINT16  mCTable[4096];\r
+  UINT16  mPTTable[256];\r
+} SCRATCH_DATA;\r
+\r
+STATIC\r
+VOID\r
+FillBuf (\r
+  IN  SCRATCH_DATA  *Sd,\r
+  IN  UINT16        NumOfBits\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Shift mBitBuf NumOfBits left. Read in NumOfBits of bits from source.\r
+\r
+Arguments:\r
+\r
+  Sd        - The global scratch data\r
+  NumOfBit  - The number of bits to shift and read.\r
+\r
+Returns: (VOID)\r
+\r
+--*/\r
+{\r
+  Sd->mBitBuf = (UINT32) (Sd->mBitBuf << NumOfBits);\r
+\r
+  while (NumOfBits > Sd->mBitCount) {\r
+\r
+    Sd->mBitBuf |= (UINT32) (Sd->mSubBitBuf << (NumOfBits = (UINT16) (NumOfBits - Sd->mBitCount)));\r
+\r
+    if (Sd->mCompSize > 0) {\r
+      //\r
+      // Get 1 byte into SubBitBuf\r
+      //\r
+      Sd->mCompSize--;\r
+      Sd->mSubBitBuf  = 0;\r
+      Sd->mSubBitBuf  = Sd->mSrcBase[Sd->mInBuf++];\r
+      Sd->mBitCount   = 8;\r
+\r
+    } else {\r
+      //\r
+      // No more bits from the source, just pad zero bit.\r
+      //\r
+      Sd->mSubBitBuf  = 0;\r
+      Sd->mBitCount   = 8;\r
+\r
+    }\r
+  }\r
+\r
+  Sd->mBitCount = (UINT16) (Sd->mBitCount - NumOfBits);\r
+  Sd->mBitBuf |= Sd->mSubBitBuf >> Sd->mBitCount;\r
+}\r
+\r
+STATIC\r
+UINT32\r
+GetBits (\r
+  IN  SCRATCH_DATA  *Sd,\r
+  IN  UINT16        NumOfBits\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Get NumOfBits of bits out from mBitBuf. Fill mBitBuf with subsequent \r
+  NumOfBits of bits from source. Returns NumOfBits of bits that are \r
+  popped out.\r
+\r
+Arguments:\r
+\r
+  Sd            - The global scratch data.\r
+  NumOfBits     - The number of bits to pop and read.\r
+\r
+Returns:\r
+\r
+  The bits that are popped out.\r
+\r
+--*/\r
+{\r
+  UINT32  OutBits;\r
+\r
+  OutBits = (UINT32) (Sd->mBitBuf >> (BITBUFSIZ - NumOfBits));\r
+\r
+  FillBuf (Sd, NumOfBits);\r
+\r
+  return OutBits;\r
+}\r
+\r
+STATIC\r
+UINT16\r
+MakeTable (\r
+  IN  SCRATCH_DATA  *Sd,\r
+  IN  UINT16        NumOfChar,\r
+  IN  UINT8         *BitLen,\r
+  IN  UINT16        TableBits,\r
+  OUT UINT16        *Table\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Creates Huffman Code mapping table according to code length array.\r
+\r
+Arguments:\r
+\r
+  Sd        - The global scratch data\r
+  NumOfChar - Number of symbols in the symbol set\r
+  BitLen    - Code length array\r
+  TableBits - The width of the mapping table\r
+  Table     - The table\r
+  \r
+Returns:\r
+  \r
+  0         - OK.\r
+  BAD_TABLE - The table is corrupted.\r
+\r
+--*/\r
+{\r
+  UINT16  Count[17];\r
+  UINT16  Weight[17];\r
+  UINT16  Start[18];\r
+  UINT16  *Pointer;\r
+  UINT16  Index3;\r
+  UINT16  Index;\r
+  UINT16  Len;\r
+  UINT16  Char;\r
+  UINT16  JuBits;\r
+  UINT16  Avail;\r
+  UINT16  NextCode;\r
+  UINT16  Mask;\r
+\r
+  for (Index = 1; Index <= 16; Index++) {\r
+    Count[Index] = 0;\r
+  }\r
+\r
+  for (Index = 0; Index < NumOfChar; Index++) {\r
+    Count[BitLen[Index]]++;\r
+  }\r
+\r
+  Start[1] = 0;\r
+\r
+  for (Index = 1; Index <= 16; Index++) {\r
+    Start[Index + 1] = (UINT16) (Start[Index] + (Count[Index] << (16 - Index)));\r
+  }\r
+\r
+  if (Start[17] != 0) {\r
+    /*(1U << 16)*/\r
+    return (UINT16) BAD_TABLE;\r
+  }\r
+\r
+  JuBits = (UINT16) (16 - TableBits);\r
+\r
+  for (Index = 1; Index <= TableBits; Index++) {\r
+    Start[Index] >>= JuBits;\r
+    Weight[Index] = (UINT16) (1U << (TableBits - Index));\r
+  }\r
+\r
+  while (Index <= 16) {\r
+    Weight[Index++] = (UINT16) (1U << (16 - Index));\r
+  }\r
+\r
+  Index = (UINT16) (Start[TableBits + 1] >> JuBits);\r
+\r
+  if (Index != 0) {\r
+    Index3 = (UINT16) (1U << TableBits);\r
+    while (Index != Index3) {\r
+      Table[Index++] = 0;\r
+    }\r
+  }\r
+\r
+  Avail = NumOfChar;\r
+  Mask  = (UINT16) (1U << (15 - TableBits));\r
+\r
+  for (Char = 0; Char < NumOfChar; Char++) {\r
+\r
+    Len = BitLen[Char];\r
+    if (Len == 0) {\r
+      continue;\r
+    }\r
+\r
+    NextCode = (UINT16) (Start[Len] + Weight[Len]);\r
+\r
+    if (Len <= TableBits) {\r
+\r
+      for (Index = Start[Len]; Index < NextCode; Index++) {\r
+        Table[Index] = Char;\r
+      }\r
+\r
+    } else {\r
+\r
+      Index3  = Start[Len];\r
+      Pointer = &Table[Index3 >> JuBits];\r
+      Index   = (UINT16) (Len - TableBits);\r
+\r
+      while (Index != 0) {\r
+        if (*Pointer == 0) {\r
+          Sd->mRight[Avail]                     = Sd->mLeft[Avail] = 0;\r
+          *Pointer = Avail++;\r
+        }\r
+\r
+        if (Index3 & Mask) {\r
+          Pointer = &Sd->mRight[*Pointer];\r
+        } else {\r
+          Pointer = &Sd->mLeft[*Pointer];\r
+        }\r
+\r
+        Index3 <<= 1;\r
+        Index--;\r
+      }\r
+\r
+      *Pointer = Char;\r
+\r
+    }\r
+\r
+    Start[Len] = NextCode;\r
+  }\r
+  //\r
+  // Succeeds\r
+  //\r
+  return 0;\r
+}\r
+\r
+STATIC\r
+UINT32\r
+DecodeP (\r
+  IN  SCRATCH_DATA  *Sd\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Decodes a position value.\r
+\r
+Arguments:\r
+\r
+  Sd      - the global scratch data\r
+\r
+Returns:\r
+\r
+  The position value decoded.\r
+\r
+--*/\r
+{\r
+  UINT16  Val;\r
+  UINT32  Mask;\r
+  UINT32  Pos;\r
+\r
+  Val = Sd->mPTTable[Sd->mBitBuf >> (BITBUFSIZ - 8)];\r
+\r
+  if (Val >= MAXNP) {\r
+    Mask = 1U << (BITBUFSIZ - 1 - 8);\r
+\r
+    do {\r
+\r
+      if (Sd->mBitBuf & Mask) {\r
+        Val = Sd->mRight[Val];\r
+      } else {\r
+        Val = Sd->mLeft[Val];\r
+      }\r
+\r
+      Mask >>= 1;\r
+    } while (Val >= MAXNP);\r
+  }\r
+  //\r
+  // Advance what we have read\r
+  //\r
+  FillBuf (Sd, Sd->mPTLen[Val]);\r
+\r
+  Pos = Val;\r
+  if (Val > 1) {\r
+    Pos = (UINT32) ((1U << (Val - 1)) + GetBits (Sd, (UINT16) (Val - 1)));\r
+  }\r
+\r
+  return Pos;\r
+}\r
+\r
+STATIC\r
+UINT16\r
+ReadPTLen (\r
+  IN  SCRATCH_DATA  *Sd,\r
+  IN  UINT16        nn,\r
+  IN  UINT16        nbit,\r
+  IN  UINT16        Special\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Reads code lengths for the Extra Set or the Position Set\r
+\r
+Arguments:\r
+\r
+  Sd        - The global scratch data\r
+  nn        - Number of symbols\r
+  nbit      - Number of bits needed to represent nn\r
+  Special   - The special symbol that needs to be taken care of \r
+\r
+Returns:\r
+\r
+  0         - OK.\r
+  BAD_TABLE - Table is corrupted.\r
+\r
+--*/\r
+{\r
+  UINT16  Number;\r
+  UINT16  CharC;\r
+  UINT16  Index;\r
+  UINT32  Mask;\r
+\r
+  Number = (UINT16) GetBits (Sd, nbit);\r
+\r
+  if (Number == 0) {\r
+    CharC = (UINT16) GetBits (Sd, nbit);\r
+\r
+    for (Index = 0; Index < 256; Index++) {\r
+      Sd->mPTTable[Index] = CharC;\r
+    }\r
+\r
+    for (Index = 0; Index < nn; Index++) {\r
+      Sd->mPTLen[Index] = 0;\r
+    }\r
+\r
+    return 0;\r
+  }\r
+\r
+  Index = 0;\r
+\r
+  while (Index < Number) {\r
+\r
+    CharC = (UINT16) (Sd->mBitBuf >> (BITBUFSIZ - 3));\r
+\r
+    if (CharC == 7) {\r
+      Mask = 1U << (BITBUFSIZ - 1 - 3);\r
+      while (Mask & Sd->mBitBuf) {\r
+        Mask >>= 1;\r
+        CharC += 1;\r
+      }\r
+    }\r
+\r
+    FillBuf (Sd, (UINT16) ((CharC < 7) ? 3 : CharC - 3));\r
+\r
+    Sd->mPTLen[Index++] = (UINT8) CharC;\r
+\r
+    if (Index == Special) {\r
+      CharC = (UINT16) GetBits (Sd, 2);\r
+      CharC--;\r
+      while ((INT16) (CharC) >= 0) {\r
+        Sd->mPTLen[Index++] = 0;\r
+        CharC--;\r
+      }\r
+    }\r
+  }\r
+\r
+  while (Index < nn) {\r
+    Sd->mPTLen[Index++] = 0;\r
+  }\r
+\r
+  return MakeTable (Sd, nn, Sd->mPTLen, 8, Sd->mPTTable);\r
+}\r
+\r
+STATIC\r
+VOID\r
+ReadCLen (\r
+  SCRATCH_DATA  *Sd\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Reads code lengths for Char&Len Set.\r
+\r
+Arguments:\r
+\r
+  Sd    - the global scratch data\r
+\r
+Returns: (VOID)\r
+\r
+--*/\r
+{\r
+  UINT16  Number;\r
+  UINT16  CharC;\r
+  UINT16  Index;\r
+  UINT32  Mask;\r
+\r
+  Number = (UINT16) GetBits (Sd, CBIT);\r
+\r
+  if (Number == 0) {\r
+    CharC = (UINT16) GetBits (Sd, CBIT);\r
+\r
+    for (Index = 0; Index < NC; Index++) {\r
+      Sd->mCLen[Index] = 0;\r
+    }\r
+\r
+    for (Index = 0; Index < 4096; Index++) {\r
+      Sd->mCTable[Index] = CharC;\r
+    }\r
+\r
+    return ;\r
+  }\r
+\r
+  Index = 0;\r
+  while (Index < Number) {\r
+\r
+    CharC = Sd->mPTTable[Sd->mBitBuf >> (BITBUFSIZ - 8)];\r
+    if (CharC >= NT) {\r
+      Mask = 1U << (BITBUFSIZ - 1 - 8);\r
+\r
+      do {\r
+\r
+        if (Mask & Sd->mBitBuf) {\r
+          CharC = Sd->mRight[CharC];\r
+        } else {\r
+          CharC = Sd->mLeft[CharC];\r
+        }\r
+\r
+        Mask >>= 1;\r
+\r
+      } while (CharC >= NT);\r
+    }\r
+    //\r
+    // Advance what we have read\r
+    //\r
+    FillBuf (Sd, Sd->mPTLen[CharC]);\r
+\r
+    if (CharC <= 2) {\r
+\r
+      if (CharC == 0) {\r
+        CharC = 1;\r
+      } else if (CharC == 1) {\r
+        CharC = (UINT16) (GetBits (Sd, 4) + 3);\r
+      } else if (CharC == 2) {\r
+        CharC = (UINT16) (GetBits (Sd, CBIT) + 20);\r
+      }\r
+\r
+      CharC--;\r
+      while ((INT16) (CharC) >= 0) {\r
+        Sd->mCLen[Index++] = 0;\r
+        CharC--;\r
+      }\r
+\r
+    } else {\r
+\r
+      Sd->mCLen[Index++] = (UINT8) (CharC - 2);\r
+\r
+    }\r
+  }\r
+\r
+  while (Index < NC) {\r
+    Sd->mCLen[Index++] = 0;\r
+  }\r
+\r
+  MakeTable (Sd, NC, Sd->mCLen, 12, Sd->mCTable);\r
+\r
+  return ;\r
+}\r
+\r
+STATIC\r
+UINT16\r
+DecodeC (\r
+  SCRATCH_DATA  *Sd\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Decode a character/length value.\r
+\r
+Arguments:\r
+\r
+  Sd    - The global scratch data.\r
+\r
+Returns:\r
+\r
+  The value decoded.\r
+\r
+--*/\r
+{\r
+  UINT16  Index2;\r
+  UINT32  Mask;\r
+\r
+  if (Sd->mBlockSize == 0) {\r
+    //\r
+    // Starting a new block\r
+    //\r
+    Sd->mBlockSize    = (UINT16) GetBits (Sd, 16);\r
+    Sd->mBadTableFlag = ReadPTLen (Sd, NT, TBIT, 3);\r
+    if (Sd->mBadTableFlag != 0) {\r
+      return 0;\r
+    }\r
+\r
+    ReadCLen (Sd);\r
+\r
+    Sd->mBadTableFlag = ReadPTLen (Sd, MAXNP, PBIT, (UINT16) (-1));\r
+    if (Sd->mBadTableFlag != 0) {\r
+      return 0;\r
+    }\r
+  }\r
+\r
+  Sd->mBlockSize--;\r
+  Index2 = Sd->mCTable[Sd->mBitBuf >> (BITBUFSIZ - 12)];\r
+\r
+  if (Index2 >= NC) {\r
+    Mask = 1U << (BITBUFSIZ - 1 - 12);\r
+\r
+    do {\r
+      if (Sd->mBitBuf & Mask) {\r
+        Index2 = Sd->mRight[Index2];\r
+      } else {\r
+        Index2 = Sd->mLeft[Index2];\r
+      }\r
+\r
+      Mask >>= 1;\r
+    } while (Index2 >= NC);\r
+  }\r
+  //\r
+  // Advance what we have read\r
+  //\r
+  FillBuf (Sd, Sd->mCLen[Index2]);\r
+\r
+  return Index2;\r
+}\r
+\r
+STATIC\r
+VOID\r
+Decode (\r
+  SCRATCH_DATA  *Sd\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Decode the source data and put the resulting data into the destination buffer.\r
+\r
+Arguments:\r
+\r
+  Sd            - The global scratch data\r
+\r
+Returns: (VOID)\r
+\r
+ --*/\r
+{\r
+  UINT16  BytesRemain;\r
+  UINT32  DataIdx;\r
+  UINT16  CharC;\r
+\r
+  BytesRemain = (UINT16) (-1);\r
+\r
+  DataIdx     = 0;\r
+\r
+  for (;;) {\r
+    CharC = DecodeC (Sd);\r
+    if (Sd->mBadTableFlag != 0) {\r
+      return ;\r
+    }\r
+\r
+    if (CharC < 256) {\r
+      //\r
+      // Process an Original character\r
+      //\r
+      Sd->mDstBase[Sd->mOutBuf++] = (UINT8) CharC;\r
+      if (Sd->mOutBuf >= Sd->mOrigSize) {\r
+        return ;\r
+      }\r
+\r
+    } else {\r
+      //\r
+      // Process a Pointer\r
+      //\r
+      CharC       = (UINT16) (CharC - (UINT8_MAX + 1 - THRESHOLD));\r
+\r
+      BytesRemain = CharC;\r
+\r
+      DataIdx     = Sd->mOutBuf - DecodeP (Sd) - 1;\r
+\r
+      BytesRemain--;\r
+      while ((INT16) (BytesRemain) >= 0) {\r
+        Sd->mDstBase[Sd->mOutBuf++] = Sd->mDstBase[DataIdx++];\r
+        if (Sd->mOutBuf >= Sd->mOrigSize) {\r
+          return ;\r
+        }\r
+\r
+        BytesRemain--;\r
+      }\r
+    }\r
+  }\r
+\r
+  return ;\r
+}\r
+\r
+EFI_STATUS\r
+GetInfo (\r
+  IN      VOID    *Source,\r
+  IN      UINT32  SrcSize,\r
+  OUT     UINT32  *DstSize,\r
+  OUT     UINT32  *ScratchSize\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  The implementation of EFI_DECOMPRESS_PROTOCOL.GetInfo().\r
+\r
+Arguments:\r
+\r
+  Source      - The source buffer containing the compressed data.\r
+  SrcSize     - The size of source buffer\r
+  DstSize     - The size of destination buffer.\r
+  ScratchSize - The size of scratch buffer.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS           - The size of destination buffer and the size of scratch buffer are successull retrieved.\r
+  EFI_INVALID_PARAMETER - The source data is corrupted\r
+\r
+--*/\r
+{\r
+  UINT8 *Src;\r
+\r
+  *ScratchSize  = sizeof (SCRATCH_DATA);\r
+\r
+  Src           = Source;\r
+  if (SrcSize < 8) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  *DstSize = Src[4] + (Src[5] << 8) + (Src[6] << 16) + (Src[7] << 24);\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+Decompress (\r
+  IN      VOID    *Source,\r
+  IN      UINT32  SrcSize,\r
+  IN OUT  VOID    *Destination,\r
+  IN      UINT32  DstSize,\r
+  IN OUT  VOID    *Scratch,\r
+  IN      UINT32  ScratchSize\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  The implementation of EFI_DECOMPRESS_PROTOCOL.Decompress().\r
+\r
+Arguments:\r
+\r
+  This        - The protocol instance pointer\r
+  Source      - The source buffer containing the compressed data.\r
+  SrcSize     - The size of source buffer\r
+  Destination - The destination buffer to store the decompressed data\r
+  DstSize     - The size of destination buffer.\r
+  Scratch     - The buffer used internally by the decompress routine. This  buffer is needed to store intermediate data.\r
+  ScratchSize - The size of scratch buffer.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS           - Decompression is successfull\r
+  EFI_INVALID_PARAMETER - The source data is corrupted\r
+\r
+--*/\r
+{\r
+  UINT32        Index;\r
+  UINT32        CompSize;\r
+  UINT32        OrigSize;\r
+  EFI_STATUS    Status;\r
+  SCRATCH_DATA  *Sd;\r
+  UINT8         *Src;\r
+  UINT8         *Dst;\r
+\r
+  Status  = EFI_SUCCESS;\r
+  Src     = Source;\r
+  Dst     = Destination;\r
+\r
+  if (ScratchSize < sizeof (SCRATCH_DATA)) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  Sd = (SCRATCH_DATA *) Scratch;\r
+\r
+  if (SrcSize < 8) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  CompSize  = Src[0] + (Src[1] << 8) + (Src[2] << 16) + (Src[3] << 24);\r
+  OrigSize  = Src[4] + (Src[5] << 8) + (Src[6] << 16) + (Src[7] << 24);\r
+\r
+  if (SrcSize < CompSize + 8) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  if (DstSize != OrigSize) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  Src = Src + 8;\r
+\r
+  for (Index = 0; Index < sizeof (SCRATCH_DATA); Index++) {\r
+    ((UINT8 *) Sd)[Index] = 0;\r
+  }\r
+\r
+  Sd->mSrcBase  = Src;\r
+  Sd->mDstBase  = Dst;\r
+  Sd->mCompSize = CompSize;\r
+  Sd->mOrigSize = OrigSize;\r
+\r
+  //\r
+  // Fill the first BITBUFSIZ bits\r
+  //\r
+  FillBuf (Sd, BITBUFSIZ);\r
+\r
+  //\r
+  // Decompress it\r
+  //\r
+  Decode (Sd);\r
+\r
+  if (Sd->mBadTableFlag != 0) {\r
+    //\r
+    // Something wrong with the source\r
+    //\r
+    Status = EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  return Status;\r
+}\r
diff --git a/Tools/CodeTools/Source/Common/EfiDecompress.h b/Tools/CodeTools/Source/Common/EfiDecompress.h
new file mode 100644 (file)
index 0000000..3f82ac6
--- /dev/null
@@ -0,0 +1,106 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+  EfiDecompress.h\r
+\r
+Abstract:\r
+\r
+  Header file for compression routine\r
+  \r
+--*/\r
+\r
+#ifndef _EFI_DECOMPRESS_H\r
+#define _EFI_DECOMPRESS_H\r
+\r
+#include <Common/UefiBaseTypes.h>\r
+\r
+EFI_STATUS\r
+GetInfo (\r
+  IN      VOID    *Source,\r
+  IN      UINT32  SrcSize,\r
+  OUT     UINT32  *DstSize,\r
+  OUT     UINT32  *ScratchSize\r
+  );\r
+\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  The implementation of EFI_DECOMPRESS_PROTOCOL.GetInfo().\r
+\r
+Arguments:\r
+\r
+  Source      - The source buffer containing the compressed data.\r
+  SrcSize     - The size of source buffer\r
+  DstSize     - The size of destination buffer.\r
+  ScratchSize - The size of scratch buffer.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS           - The size of destination buffer and the size of scratch buffer are successull retrieved.\r
+  EFI_INVALID_PARAMETER - The source data is corrupted\r
+\r
+--*/\r
+EFI_STATUS\r
+Decompress (\r
+  IN      VOID    *Source,\r
+  IN      UINT32  SrcSize,\r
+  IN OUT  VOID    *Destination,\r
+  IN      UINT32  DstSize,\r
+  IN OUT  VOID    *Scratch,\r
+  IN      UINT32  ScratchSize\r
+  )\r
+;\r
+\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  The implementation of EFI_DECOMPRESS_PROTOCOL.Decompress().\r
+\r
+Arguments:\r
+\r
+  This        - The protocol instance pointer\r
+  Source      - The source buffer containing the compressed data.\r
+  SrcSize     - The size of source buffer\r
+  Destination - The destination buffer to store the decompressed data\r
+  DstSize     - The size of destination buffer.\r
+  Scratch     - The buffer used internally by the decompress routine. This  buffer is needed to store intermediate data.\r
+  ScratchSize - The size of scratch buffer.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS           - Decompression is successfull\r
+  EFI_INVALID_PARAMETER - The source data is corrupted\r
+\r
+--*/\r
+typedef\r
+EFI_STATUS\r
+(*GETINFO_FUNCTION) (\r
+  IN      VOID    *Source,\r
+  IN      UINT32  SrcSize,\r
+  OUT     UINT32  *DstSize,\r
+  OUT     UINT32  *ScratchSize\r
+  );\r
+\r
+typedef\r
+EFI_STATUS\r
+(*DECOMPRESS_FUNCTION) (\r
+  IN      VOID    *Source,\r
+  IN      UINT32  SrcSize,\r
+  IN OUT  VOID    *Destination,\r
+  IN      UINT32  DstSize,\r
+  IN OUT  VOID    *Scratch,\r
+  IN      UINT32  ScratchSize\r
+  );\r
+#endif\r
diff --git a/Tools/CodeTools/Source/Common/EfiUtilityMsgs.c b/Tools/CodeTools/Source/Common/EfiUtilityMsgs.c
new file mode 100644 (file)
index 0000000..566d214
--- /dev/null
@@ -0,0 +1,755 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:  \r
+\r
+  EfiUtilityMsgs.c\r
+  \r
+Abstract:\r
+\r
+  EFI tools utility functions to display warning, error, and informational\r
+  messages.\r
+  \r
+--*/\r
+\r
+#include <stdio.h>\r
+#include <string.h>\r
+#include <ctype.h>\r
+#include <stdarg.h>\r
+\r
+#include "EfiUtilityMsgs.h"\r
+\r
+#define MAX_LINE_LEN  200\r
+\r
+//\r
+// Declare module globals for keeping track of the the utility's\r
+// name and other settings.\r
+//\r
+static STATUS mStatus                 = STATUS_SUCCESS;\r
+static CHAR8  mUtilityName[50]        = { 0 };\r
+static UINT32 mDebugMsgMask           = 0;\r
+static CHAR8  *mSourceFileName        = NULL;\r
+static UINT32 mSourceFileLineNum      = 0;\r
+static UINT32 mErrorCount             = 0;\r
+static UINT32 mWarningCount           = 0;\r
+static UINT32 mMaxErrors              = 0;\r
+static UINT32 mMaxWarnings            = 0;\r
+static UINT32 mMaxWarningsPlusErrors  = 0;\r
+static INT8   mPrintLimitsSet         = 0;\r
+\r
+static\r
+void\r
+PrintMessage (\r
+  CHAR8   *Type,\r
+  CHAR8   *FileName,\r
+  UINT32  LineNumber,\r
+  UINT32  MessageCode,\r
+  CHAR8   *Text,\r
+  CHAR8   *MsgFmt,\r
+  va_list List\r
+  );\r
+\r
+static\r
+void\r
+PrintLimitExceeded (\r
+  VOID\r
+  );\r
+\r
+void\r
+Error (\r
+  CHAR8   *FileName,\r
+  UINT32  LineNumber,\r
+  UINT32  MessageCode,\r
+  CHAR8   *Text,\r
+  CHAR8   *MsgFmt,\r
+  ...\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Prints an error message.\r
+  \r
+Arguments:\r
+  All arguments are optional, though the printed message may be useless if\r
+  at least something valid is not specified.\r
+  \r
+  FileName - name of the file or application. If not specified, then the\r
+             utilty name (as set by the utility calling SetUtilityName()\r
+             earlier) is used. Otherwise "Unknown utility" is used.\r
+  \r
+  LineNumber - the line number of error, typically used by parsers. If the\r
+               utility is not a parser, then 0 should be specified. Otherwise\r
+               the FileName and LineNumber info can be used to cause\r
+               MS Visual Studio to jump to the error.\r
+               \r
+  MessageCode - an application-specific error code that can be referenced in\r
+              other documentation. \r
+\r
+  Text        - the text in question, typically used by parsers.\r
+  \r
+  MsgFmt - the format string for the error message. Can contain formatting\r
+           controls for use with the varargs.\r
+           \r
+Returns:\r
+  None.\r
+  \r
+Notes:\r
+  We print the following (similar to the Warn() and Debug() \r
+  W\r
+  Typical error/warning message format:\r
+\r
+  bin\VfrCompile.cpp(330) : error C2660: 'AddVfrDataStructField' : function does not take 2 parameters\r
+\r
+  BUGBUG -- these three utility functions are almost identical, and\r
+  should be modified to share code.\r
+\r
+  Visual Studio does not find error messages with:\r
+  \r
+     " error :"\r
+     " error 1:"\r
+     " error c1:"\r
+     " error 1000:"\r
+     " error c100:"\r
+\r
+  It does find:\r
+     " error c1000:"     \r
+--*/\r
+{\r
+  va_list List;\r
+  //\r
+  // If limits have been set, then check that we have not exceeded them\r
+  //\r
+  if (mPrintLimitsSet) {\r
+    //\r
+    // See if we've exceeded our total count\r
+    //\r
+    if (mMaxWarningsPlusErrors != 0) {\r
+      if (mErrorCount + mWarningCount > mMaxWarningsPlusErrors) {\r
+        PrintLimitExceeded ();\r
+        return ;\r
+      }\r
+    }\r
+    //\r
+    // See if we've exceeded our error count\r
+    //\r
+    if (mMaxErrors != 0) {\r
+      if (mErrorCount > mMaxErrors) {\r
+        PrintLimitExceeded ();\r
+        return ;\r
+      }\r
+    }\r
+  }\r
+\r
+  mErrorCount++;\r
+  va_start (List, MsgFmt);\r
+  PrintMessage ("error", FileName, LineNumber, MessageCode, Text, MsgFmt, List);\r
+  va_end (List);\r
+  //\r
+  // Set status accordingly\r
+  //\r
+  if (mStatus < STATUS_ERROR) {\r
+    mStatus = STATUS_ERROR;\r
+  }\r
+}\r
+\r
+void\r
+ParserError (\r
+  UINT32  MessageCode,\r
+  CHAR8   *Text,\r
+  CHAR8   *MsgFmt,\r
+  ...\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Print a parser error, using the source file name and line number\r
+  set by a previous call to SetParserPosition().\r
+\r
+Arguments:\r
+  MessageCode   - application-specific error code\r
+  Text          - text to print in the error message\r
+  MsgFmt        - format string to print at the end of the error message\r
+\r
+Returns:\r
+  NA\r
+\r
+--*/\r
+{\r
+  va_list List;\r
+  //\r
+  // If limits have been set, then check them\r
+  //\r
+  if (mPrintLimitsSet) {\r
+    //\r
+    // See if we've exceeded our total count\r
+    //\r
+    if (mMaxWarningsPlusErrors != 0) {\r
+      if (mErrorCount + mWarningCount > mMaxWarningsPlusErrors) {\r
+        PrintLimitExceeded ();\r
+        return ;\r
+      }\r
+    }\r
+    //\r
+    // See if we've exceeded our error count\r
+    //\r
+    if (mMaxErrors != 0) {\r
+      if (mErrorCount > mMaxErrors) {\r
+        PrintLimitExceeded ();\r
+        return ;\r
+      }\r
+    }\r
+  }\r
+\r
+  mErrorCount++;\r
+  va_start (List, MsgFmt);\r
+  PrintMessage ("error", mSourceFileName, mSourceFileLineNum, MessageCode, Text, MsgFmt, List);\r
+  va_end (List);\r
+  //\r
+  // Set status accordingly\r
+  //\r
+  if (mStatus < STATUS_ERROR) {\r
+    mStatus = STATUS_ERROR;\r
+  }\r
+}\r
+\r
+void\r
+ParserWarning (\r
+  UINT32  ErrorCode,\r
+  CHAR8   *OffendingText,\r
+  CHAR8   *MsgFmt,\r
+  ...\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Print a parser warning, using the source file name and line number\r
+  set by a previous call to SetParserPosition().\r
+\r
+Arguments:\r
+  ErrorCode     - application-specific error code\r
+  OffendingText - text to print in the warning message\r
+  MsgFmt        - format string to print at the end of the warning message\r
+\r
+Returns:\r
+  NA\r
+\r
+--*/\r
+{\r
+  va_list List;\r
+  //\r
+  // If limits have been set, then check them\r
+  //\r
+  if (mPrintLimitsSet) {\r
+    //\r
+    // See if we've exceeded our total count\r
+    //\r
+    if (mMaxWarningsPlusErrors != 0) {\r
+      if (mErrorCount + mWarningCount > mMaxWarningsPlusErrors) {\r
+        PrintLimitExceeded ();\r
+        return ;\r
+      }\r
+    }\r
+    //\r
+    // See if we've exceeded our warning count\r
+    //\r
+    if (mMaxWarnings != 0) {\r
+      if (mWarningCount > mMaxWarnings) {\r
+        PrintLimitExceeded ();\r
+        return ;\r
+      }\r
+    }\r
+  }\r
+\r
+  mWarningCount++;\r
+  va_start (List, MsgFmt);\r
+  PrintMessage ("warning", mSourceFileName, mSourceFileLineNum, ErrorCode, OffendingText, MsgFmt, List);\r
+  va_end (List);\r
+  //\r
+  // Set status accordingly\r
+  //\r
+  if (mStatus < STATUS_WARNING) {\r
+    mStatus = STATUS_WARNING;\r
+  }\r
+}\r
+\r
+void\r
+Warning (\r
+  CHAR8   *FileName,\r
+  UINT32  LineNumber,\r
+  UINT32  MessageCode,\r
+  CHAR8   *Text,\r
+  CHAR8   *MsgFmt,\r
+  ...\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Print a warning message.\r
+\r
+Arguments:\r
+  FileName    - name of the file where the warning was detected, or the name\r
+                of the application that detected the warning\r
+  \r
+  LineNumber  - the line number where the warning was detected (parsers).\r
+                0 should be specified if the utility is not a parser.\r
+               \r
+  MessageCode - an application-specific warning code that can be referenced in\r
+                other documentation. \r
+\r
+  Text        - the text in question (parsers)\r
+  \r
+  MsgFmt      - the format string for the warning message. Can contain formatting\r
+                controls for use with varargs.\r
+           \r
+Returns:\r
+  None.\r
+\r
+--*/\r
+{\r
+  va_list List;\r
+  //\r
+  // If limits have been set, then check them\r
+  //\r
+  if (mPrintLimitsSet) {\r
+    //\r
+    // See if we've exceeded our total count\r
+    //\r
+    if (mMaxWarningsPlusErrors != 0) {\r
+      if (mErrorCount + mWarningCount > mMaxWarningsPlusErrors) {\r
+        PrintLimitExceeded ();\r
+        return ;\r
+      }\r
+    }\r
+    //\r
+    // See if we've exceeded our warning count\r
+    //\r
+    if (mMaxWarnings != 0) {\r
+      if (mWarningCount > mMaxWarnings) {\r
+        PrintLimitExceeded ();\r
+        return ;\r
+      }\r
+    }\r
+  }\r
+\r
+  mWarningCount++;\r
+  va_start (List, MsgFmt);\r
+  PrintMessage ("warning", FileName, LineNumber, MessageCode, Text, MsgFmt, List);\r
+  va_end (List);\r
+  //\r
+  // Set status accordingly\r
+  //\r
+  if (mStatus < STATUS_WARNING) {\r
+    mStatus = STATUS_WARNING;\r
+  }\r
+}\r
+\r
+void\r
+DebugMsg (\r
+  CHAR8   *FileName,\r
+  UINT32  LineNumber,\r
+  UINT32  MsgMask,\r
+  CHAR8   *Text,\r
+  CHAR8   *MsgFmt,\r
+  ...\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Print a warning message.\r
+\r
+Arguments:\r
+  FileName    - typically the name of the utility printing the debug message, but\r
+                can be the name of a file being parsed.\r
+  \r
+  LineNumber  - the line number in FileName (parsers) \r
+               \r
+  MsgMask     - an application-specific bitmask that, in combination with mDebugMsgMask,\r
+                determines if the debug message gets printed.\r
+\r
+  Text        - the text in question (parsers)\r
+  \r
+  MsgFmt      - the format string for the debug message. Can contain formatting\r
+                controls for use with varargs.\r
+           \r
+Returns:\r
+  None.\r
+\r
+--*/\r
+{\r
+  va_list List;\r
+  //\r
+  // If the debug mask is not applicable, then do nothing.\r
+  //\r
+  if ((MsgMask != 0) && ((mDebugMsgMask & MsgMask) == 0)) {\r
+    return ;\r
+  }\r
+\r
+  va_start (List, MsgFmt);\r
+  PrintMessage ("debug", FileName, LineNumber, 0, Text, MsgFmt, List);\r
+  va_end (List);\r
+}\r
+\r
+static\r
+void\r
+PrintMessage (\r
+  CHAR8   *Type,\r
+  CHAR8   *FileName,\r
+  UINT32  LineNumber,\r
+  UINT32  MessageCode,\r
+  CHAR8   *Text,\r
+  CHAR8   *MsgFmt,\r
+  va_list List\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Worker routine for all the utility printing services. Prints the message in\r
+  a format that Visual Studio will find when scanning build outputs for\r
+  errors or warnings.\r
+\r
+Arguments:\r
+  Type        - "warning" or "error" string to insert into the message to be\r
+                printed. The first character of this string (converted to uppercase)\r
+                is used to preceed the MessageCode value in the output string.\r
+\r
+  FileName    - name of the file where the warning was detected, or the name\r
+                of the application that detected the warning\r
+  \r
+  LineNumber  - the line number where the warning was detected (parsers).\r
+                0 should be specified if the utility is not a parser.\r
+               \r
+  MessageCode - an application-specific warning code that can be referenced in\r
+                other documentation. \r
+\r
+  Text        - part of the message to print\r
+  \r
+  MsgFmt      - the format string for the message. Can contain formatting\r
+                controls for use with varargs.\r
+  List        - the variable list.\r
+           \r
+Returns:\r
+  None.\r
+\r
+Notes:\r
+  If FileName == NULL then this utility will use the string passed into SetUtilityName(). \r
+  \r
+  LineNumber is only used if the caller is a parser, in which case FileName refers to the\r
+  file being parsed.\r
+\r
+  Text and MsgFmt are both optional, though it would be of little use calling this function with\r
+  them both NULL.\r
+\r
+  Output will typically be of the form:\r
+    <FileName>(<LineNumber>) : <Type> <Type[0]><MessageCode>: <Text> : <MsgFmt>\r
+\r
+    Parser (LineNumber != 0)\r
+      VfrCompile.cpp(330) : error E2660: AddVfrDataStructField : function does not take 2 parameters\r
+    Generic utility (LineNumber == 0) \r
+      UtilityName : error E1234 : Text string : MsgFmt string and args\r
+\r
+--*/\r
+{\r
+  CHAR8 Line[MAX_LINE_LEN];\r
+  CHAR8 Line2[MAX_LINE_LEN];\r
+  CHAR8 *Cptr;\r
+  //\r
+  // If given a filename, then add it (and the line number) to the string.\r
+  // If there's no filename, then use the program name if provided.\r
+  //\r
+  if (FileName != NULL) {\r
+    Cptr = FileName;\r
+  } else if (mUtilityName[0] != 0) {\r
+    Cptr = mUtilityName;\r
+  } else {\r
+    Cptr = "Unknown utility";\r
+  }\r
+\r
+  strcpy (Line, Cptr);\r
+  if (LineNumber != 0) {\r
+    sprintf (Line2, "(%d)", LineNumber);\r
+    strcat (Line, Line2);\r
+  }\r
+  //\r
+  // Have to print an error code or Visual Studio won't find the\r
+  // message for you. It has to be decimal digits too.\r
+  //\r
+  sprintf (Line2, " : %s %c%04d", Type, toupper (Type[0]), MessageCode);\r
+  strcat (Line, Line2);\r
+  fprintf (stdout, "%s", Line);\r
+  //\r
+  // If offending text was provided, then print it\r
+  //\r
+  if (Text != NULL) {\r
+    fprintf (stdout, ": %s ", Text);\r
+  }\r
+  //\r
+  // Print formatted message if provided\r
+  //\r
+  if (MsgFmt != NULL) {\r
+    vsprintf (Line2, MsgFmt, List);\r
+    fprintf (stdout, ": %s", Line2);\r
+  }\r
+\r
+  fprintf (stdout, "\n");\r
+}\r
+\r
+void\r
+ParserSetPosition (\r
+  CHAR8   *SourceFileName,\r
+  UINT32  LineNum\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Set the position in a file being parsed. This can be used to \r
+  print error messages deeper down in a parser.\r
+\r
+Arguments:\r
+  SourceFileName - name of the source file being parsed\r
+  LineNum        - line number of the source file being parsed\r
+\r
+Returns:\r
+  NA\r
+\r
+--*/\r
+{\r
+  mSourceFileName     = SourceFileName;\r
+  mSourceFileLineNum  = LineNum;\r
+}\r
+\r
+void\r
+SetUtilityName (\r
+  CHAR8   *UtilityName\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  All printed error/warning/debug messages follow the same format, and\r
+  typically will print a filename or utility name followed by the error\r
+  text. However if a filename is not passed to the print routines, then\r
+  they'll print the utility name if you call this function early in your\r
+  app to set the utility name.\r
+  \r
+Arguments:\r
+  UtilityName  -  name of the utility, which will be printed with all\r
+                  error/warning/debug messags.\r
+\r
+Returns:\r
+  NA\r
+  \r
+--*/\r
+{\r
+  //\r
+  // Save the name of the utility in our local variable. Make sure its\r
+  // length does not exceed our buffer.\r
+  //\r
+  if (UtilityName != NULL) {\r
+    if (strlen (UtilityName) >= sizeof (mUtilityName)) {\r
+      Error (UtilityName, 0, 0, "application error", "utility name length exceeds internal buffer size");\r
+      strncpy (mUtilityName, UtilityName, sizeof (mUtilityName) - 1);\r
+      mUtilityName[sizeof (mUtilityName) - 1] = 0;\r
+      return ;\r
+    } else {\r
+      strcpy (mUtilityName, UtilityName);\r
+    }\r
+  } else {\r
+    Error (NULL, 0, 0, "application error", "SetUtilityName() called with NULL utility name");\r
+  }\r
+}\r
+\r
+STATUS\r
+GetUtilityStatus (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  When you call Error() or Warning(), this module keeps track of it and\r
+  sets a local mStatus to STATUS_ERROR or STATUS_WARNING. When the utility\r
+  exits, it can call this function to get the status and use it as a return\r
+  value.\r
+  \r
+Arguments:\r
+  None.\r
+\r
+Returns:\r
+  Worst-case status reported, as defined by which print function was called.\r
+  \r
+--*/\r
+{\r
+  return mStatus;\r
+}\r
+\r
+void\r
+SetDebugMsgMask (\r
+  UINT32  DebugMask\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Set the debug printing mask. This is used by the DebugMsg() function\r
+  to determine when/if a debug message should be printed.\r
+\r
+Arguments:\r
+  DebugMask  - bitmask, specific to the calling application\r
+\r
+Returns:\r
+  NA\r
+\r
+--*/\r
+{\r
+  mDebugMsgMask = DebugMask;\r
+}\r
+\r
+void\r
+SetPrintLimits (\r
+  UINT32  MaxErrors,\r
+  UINT32  MaxWarnings,\r
+  UINT32  MaxWarningsPlusErrors\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Set the limits of how many errors, warnings, and errors+warnings\r
+  we will print.\r
+\r
+Arguments:\r
+  MaxErrors       - maximum number of error messages to print\r
+  MaxWarnings     - maximum number of warning messages to print\r
+  MaxWarningsPlusErrors \r
+                  - maximum number of errors+warnings to print\r
+\r
+Returns:\r
+  NA\r
+\r
+--*/\r
+{\r
+  mMaxErrors              = MaxErrors;\r
+  mMaxWarnings            = MaxWarnings;\r
+  mMaxWarningsPlusErrors  = MaxWarningsPlusErrors;\r
+  mPrintLimitsSet         = 1;\r
+}\r
+\r
+static\r
+void\r
+PrintLimitExceeded (\r
+  VOID\r
+  )\r
+{\r
+  static INT8 mPrintLimitExceeded = 0;\r
+  //\r
+  // If we've already printed the message, do nothing. Otherwise\r
+  // temporarily increase our print limits so we can pass one\r
+  // more message through.\r
+  //\r
+  if (mPrintLimitExceeded == 0) {\r
+    mPrintLimitExceeded++;\r
+    mMaxErrors++;\r
+    mMaxWarnings++;\r
+    mMaxWarningsPlusErrors++;\r
+    Error (NULL, 0, 0, "error/warning print limit exceeded", NULL);\r
+    mMaxErrors--;\r
+    mMaxWarnings--;\r
+    mMaxWarningsPlusErrors--;\r
+  }\r
+}\r
+\r
+#if 0\r
+void\r
+TestUtilityMessages (\r
+  VOID\r
+  )\r
+{\r
+  char *ArgStr = "ArgString";\r
+  int  ArgInt;\r
+\r
+  ArgInt  = 0x12345678;\r
+  //\r
+  // Test without setting utility name\r
+  //\r
+  fprintf (stdout, "* Testing without setting utility name\n");\r
+  fprintf (stdout, "** Test debug message not printed\n");\r
+  DebugMsg (NULL, 0, 0x00000001, NULL, NULL);\r
+  fprintf (stdout, "** Test warning with two strings and two args\n");\r
+  Warning (NULL, 0, 1234, "Text1", "Text2 %s 0x%X", ArgStr, ArgInt);\r
+  fprintf (stdout, "** Test error with two strings and two args\n");\r
+  Warning (NULL, 0, 1234, "Text1", "Text2 %s 0x%X", ArgStr, ArgInt);\r
+  fprintf (stdout, "** Test parser warning with nothing\n");\r
+  ParserWarning (0, NULL, NULL);\r
+  fprintf (stdout, "** Test parser error with nothing\n");\r
+  ParserError (0, NULL, NULL);\r
+  //\r
+  // Test with utility name set now\r
+  //\r
+  fprintf (stdout, "** Testingin with utility name set\n");\r
+  SetUtilityName ("MyUtilityName");\r
+  //\r
+  // Test debug prints\r
+  //\r
+  SetDebugMsgMask (2);\r
+  fprintf (stdout, "** Test debug message with one string\n");\r
+  DebugMsg (NULL, 0, 0x00000002, "Text1", NULL);\r
+  fprintf (stdout, "** Test debug message with one string\n");\r
+  DebugMsg (NULL, 0, 0x00000002, NULL, "Text2");\r
+  fprintf (stdout, "** Test debug message with two strings\n");\r
+  DebugMsg (NULL, 0, 0x00000002, "Text1", "Text2");\r
+  fprintf (stdout, "** Test debug message with two strings and two args\n");\r
+  DebugMsg (NULL, 0, 0x00000002, "Text1", "Text2 %s 0x%X", ArgStr, ArgInt);\r
+  //\r
+  // Test warning prints\r
+  //\r
+  fprintf (stdout, "** Test warning with no strings\n");\r
+  Warning (NULL, 0, 1234, NULL, NULL);\r
+  fprintf (stdout, "** Test warning with one string\n");\r
+  Warning (NULL, 0, 1234, "Text1", NULL);\r
+  fprintf (stdout, "** Test warning with one string\n");\r
+  Warning (NULL, 0, 1234, NULL, "Text2");\r
+  fprintf (stdout, "** Test warning with two strings and two args\n");\r
+  Warning (NULL, 0, 1234, "Text1", "Text2 %s 0x%X", ArgStr, ArgInt);\r
+  //\r
+  // Test error prints\r
+  //\r
+  fprintf (stdout, "** Test error with no strings\n");\r
+  Error (NULL, 0, 1234, NULL, NULL);\r
+  fprintf (stdout, "** Test error with one string\n");\r
+  Error (NULL, 0, 1234, "Text1", NULL);\r
+  fprintf (stdout, "** Test error with one string\n");\r
+  Error (NULL, 0, 1234, NULL, "Text2");\r
+  fprintf (stdout, "** Test error with two strings and two args\n");\r
+  Error (NULL, 0, 1234, "Text1", "Text2 %s 0x%X", ArgStr, ArgInt);\r
+  //\r
+  // Test parser prints\r
+  //\r
+  fprintf (stdout, "** Test parser errors\n");\r
+  ParserSetPosition (__FILE__, __LINE__ + 1);\r
+  ParserError (1234, NULL, NULL);\r
+  ParserSetPosition (__FILE__, __LINE__ + 1);\r
+  ParserError (1234, "Text1", NULL);\r
+  ParserSetPosition (__FILE__, __LINE__ + 1);\r
+  ParserError (1234, NULL, "Text2");\r
+  ParserSetPosition (__FILE__, __LINE__ + 1);\r
+  ParserError (1234, "Text1", "Text2");\r
+  ParserSetPosition (__FILE__, __LINE__ + 1);\r
+  ParserError (1234, "Text1", "Text2 %s 0x%X", ArgStr, ArgInt);\r
+\r
+  fprintf (stdout, "** Test parser warnings\n");\r
+  ParserSetPosition (__FILE__, __LINE__ + 1);\r
+  ParserWarning (4321, NULL, NULL);\r
+  ParserSetPosition (__FILE__, __LINE__ + 1);\r
+  ParserWarning (4321, "Text1", NULL);\r
+  ParserSetPosition (__FILE__, __LINE__ + 1);\r
+  ParserWarning (4321, NULL, "Text2");\r
+  ParserSetPosition (__FILE__, __LINE__ + 1);\r
+  ParserWarning (4321, "Text1", "Text2");\r
+  ParserSetPosition (__FILE__, __LINE__ + 1);\r
+  ParserWarning (4321, "Text1", "Text2 %s 0x%X", ArgStr, ArgInt);\r
+}\r
+#endif\r
diff --git a/Tools/CodeTools/Source/Common/EfiUtilityMsgs.h b/Tools/CodeTools/Source/Common/EfiUtilityMsgs.h
new file mode 100644 (file)
index 0000000..a76b822
--- /dev/null
@@ -0,0 +1,137 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  EfiUtilityMsgs.h\r
+\r
+Abstract:\r
+\r
+  Defines and prototypes for common EFI utility error and debug messages.\r
+  \r
+--*/\r
+\r
+#ifndef _EFI_UTILITY_MSGS_H_\r
+#define _EFI_UTILITY_MSGS_H_\r
+\r
+#include <Common/UefiBaseTypes.h>\r
+\r
+//\r
+// Status codes returned by EFI utility programs and functions\r
+//\r
+#define STATUS_SUCCESS  0\r
+#define STATUS_WARNING  1\r
+#define STATUS_ERROR    2\r
+#define VOID void \r
+\r
+typedef int STATUS;\r
+\r
+#ifdef __cplusplus\r
+extern "C" {\r
+#endif\r
+//\r
+// When we call Error() or Warning(), the module keeps track of the worst\r
+// case reported. GetUtilityStatus() will get the worst-case results, which\r
+// can be used as the return value from the app.\r
+//\r
+STATUS\r
+GetUtilityStatus (\r
+  void\r
+  );\r
+\r
+//\r
+// If someone prints an error message and didn't specify a source file name,\r
+// then we print the utility name instead. However they must tell us the\r
+// utility name early on via this function.\r
+//\r
+void\r
+SetUtilityName (\r
+  CHAR8 *ProgramName\r
+  )\r
+;\r
+\r
+void\r
+Error (\r
+  CHAR8   *FileName,\r
+  UINT32  LineNumber,\r
+  UINT32  ErrorCode,\r
+  CHAR8   *OffendingText,\r
+  CHAR8   *MsgFmt,\r
+  ...\r
+  )\r
+;\r
+\r
+void\r
+Warning (\r
+  CHAR8   *FileName,\r
+  UINT32  LineNumber,\r
+  UINT32  ErrorCode,\r
+  CHAR8   *OffendingText,\r
+  CHAR8   *MsgFmt,\r
+  ...\r
+  )\r
+;\r
+\r
+void\r
+DebugMsg (\r
+  CHAR8   *FileName,\r
+  UINT32  LineNumber,\r
+  UINT32  MsgLevel,\r
+  CHAR8   *OffendingText,\r
+  CHAR8   *MsgFmt,\r
+  ...\r
+  )\r
+;\r
+\r
+void\r
+SetDebugMsgMask (\r
+  UINT32    MsgMask\r
+  )\r
+;\r
+\r
+void\r
+ParserSetPosition (\r
+  CHAR8   *SourceFileName,\r
+  UINT32  LineNum\r
+  )\r
+;\r
+\r
+void\r
+ParserError (\r
+  UINT32  ErrorCode,\r
+  CHAR8   *OffendingText,\r
+  CHAR8   *MsgFmt,\r
+  ...\r
+  )\r
+;\r
+\r
+void\r
+ParserWarning (\r
+  UINT32  ErrorCode,\r
+  CHAR8   *OffendingText,\r
+  CHAR8   *MsgFmt,\r
+  ...\r
+  )\r
+;\r
+\r
+void\r
+SetPrintLimits (\r
+  UINT32  NumErrors,\r
+  UINT32  NumWarnings,\r
+  UINT32  NumWarningsPlusErrors\r
+  )\r
+;\r
+\r
+#ifdef __cplusplus\r
+}\r
+#endif\r
+\r
+#endif // #ifndef _EFI_UTILITY_MSGS_H_\r
diff --git a/Tools/CodeTools/Source/Common/FvLib.c b/Tools/CodeTools/Source/Common/FvLib.c
new file mode 100644 (file)
index 0000000..e8d6279
--- /dev/null
@@ -0,0 +1,780 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  FvLib.c\r
+\r
+Abstract:\r
+\r
+  These functions assist in parsing and manipulating a Firmware Volume.\r
+\r
+--*/\r
+\r
+//\r
+// Include files\r
+//\r
+#include "FvLib.h"\r
+#include "CommonLib.h"\r
+#include "EfiUtilityMsgs.h"\r
+\r
+//\r
+// Module global variables\r
+//\r
+EFI_FIRMWARE_VOLUME_HEADER  *mFvHeader  = NULL;\r
+UINT32                      mFvLength   = 0;\r
+\r
+//\r
+// External function implementations\r
+//\r
+EFI_STATUS\r
+InitializeFvLib (\r
+  IN VOID                         *Fv,\r
+  IN UINT32                       FvLength\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This initializes the FV lib with a pointer to the FV and length.  It does not\r
+  verify the FV in any way.\r
+\r
+Arguments:\r
+\r
+  Fv            Buffer containing the FV.\r
+  FvLength      Length of the FV\r
+    \r
+Returns:\r
\r
+  EFI_SUCCESS             Function Completed successfully.\r
+  EFI_INVALID_PARAMETER   A required parameter was NULL.\r
+\r
+--*/\r
+{\r
+  //\r
+  // Verify input arguments\r
+  //\r
+  if (Fv == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  mFvHeader = (EFI_FIRMWARE_VOLUME_HEADER *) Fv;\r
+  mFvLength = FvLength;\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+GetFvHeader (\r
+  OUT EFI_FIRMWARE_VOLUME_HEADER  **FvHeader,\r
+  OUT UINT32                      *FvLength\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function returns a pointer to the current FV and the size.\r
+\r
+Arguments:\r
+\r
+  FvHeader      Pointer to the FV buffer.\r
+  FvLength      Length of the FV\r
+    \r
+Returns:\r
\r
+  EFI_SUCCESS             Function Completed successfully.\r
+  EFI_INVALID_PARAMETER   A required parameter was NULL.\r
+  EFI_ABORTED             The library needs to be initialized.\r
+\r
+--*/\r
+{\r
+  //\r
+  // Verify library has been initialized.\r
+  //\r
+  if (mFvHeader == NULL || mFvLength == 0) {\r
+    return EFI_ABORTED;\r
+  }\r
+  //\r
+  // Verify input arguments\r
+  //\r
+  if (FvHeader == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  *FvHeader = mFvHeader;\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+GetNextFile (\r
+  IN EFI_FFS_FILE_HEADER          *CurrentFile,\r
+  OUT EFI_FFS_FILE_HEADER         **NextFile\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function returns the next file.  If the current file is NULL, it returns\r
+  the first file in the FV.  If the function returns EFI_SUCCESS and the file \r
+  pointer is NULL, then there are no more files in the FV.\r
+\r
+Arguments:\r
+\r
+  CurrentFile   Pointer to the current file, must be within the current FV.\r
+  NextFile      Pointer to the next file in the FV.\r
+    \r
+Returns:\r
\r
+  EFI_SUCCESS             Function completed successfully.\r
+  EFI_INVALID_PARAMETER   A required parameter was NULL or is out of range.\r
+  EFI_ABORTED             The library needs to be initialized.\r
+\r
+--*/\r
+{\r
+  EFI_STATUS  Status;\r
+\r
+  //\r
+  // Verify library has been initialized.\r
+  //\r
+  if (mFvHeader == NULL || mFvLength == 0) {\r
+    return EFI_ABORTED;\r
+  }\r
+  //\r
+  // Verify input arguments\r
+  //\r
+  if (NextFile == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+  //\r
+  // Verify FV header\r
+  //\r
+  Status = VerifyFv (mFvHeader);\r
+  if (EFI_ERROR (Status)) {\r
+    return EFI_ABORTED;\r
+  }\r
+  //\r
+  // Get first file\r
+  //\r
+  if (CurrentFile == NULL) {\r
+    CurrentFile = (EFI_FFS_FILE_HEADER *) ((UINTN) mFvHeader + mFvHeader->HeaderLength);\r
+\r
+    //\r
+    // Verify file is valid\r
+    //\r
+    Status = VerifyFfsFile (CurrentFile);\r
+    if (EFI_ERROR (Status)) {\r
+      //\r
+      // no files in this FV\r
+      //\r
+      *NextFile = NULL;\r
+      return EFI_SUCCESS;\r
+    } else {\r
+      //\r
+      // Verify file is in this FV.\r
+      //\r
+      if ((UINTN) CurrentFile >= (UINTN) mFvHeader + mFvLength - sizeof (EFI_FFS_FILE_HEADER)) {\r
+        *NextFile = NULL;\r
+        return EFI_SUCCESS;\r
+      }\r
+\r
+      *NextFile = CurrentFile;\r
+      return EFI_SUCCESS;\r
+    }\r
+  }\r
+  //\r
+  // Verify current file is in range\r
+  //\r
+  if (((UINTN) CurrentFile < (UINTN) mFvHeader + sizeof (EFI_FIRMWARE_VOLUME_HEADER)) ||\r
+      ((UINTN) CurrentFile >= (UINTN) mFvHeader + mFvLength - sizeof (EFI_FIRMWARE_VOLUME_HEADER))\r
+      ) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+  //\r
+  // Get next file, compensate for 8 byte alignment if necessary.\r
+  //\r
+  *NextFile = (EFI_FFS_FILE_HEADER *) (((UINTN) CurrentFile + GetLength (CurrentFile->Size) + 0x07) & (-1 << 3));\r
+\r
+  //\r
+  // Verify file is in this FV.\r
+  //\r
+  if ((UINTN) *NextFile >= (UINTN) mFvHeader + mFvLength - sizeof (EFI_FFS_FILE_HEADER)) {\r
+    *NextFile = NULL;\r
+    return EFI_SUCCESS;\r
+  }\r
+  //\r
+  // Verify file is valid\r
+  //\r
+  Status = VerifyFfsFile (*NextFile);\r
+  if (EFI_ERROR (Status)) {\r
+    //\r
+    // no more files in this FV\r
+    //\r
+    *NextFile = NULL;\r
+    return EFI_SUCCESS;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+GetFileByName (\r
+  IN EFI_GUID                     *FileName,\r
+  OUT EFI_FFS_FILE_HEADER         **File\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Find a file by name.  The function will return NULL if the file is not found.\r
+\r
+Arguments:\r
+\r
+  FileName    The GUID file name of the file to search for.\r
+  File        Return pointer.  In the case of an error, contents are undefined.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS             The function completed successfully.\r
+  EFI_ABORTED             An error was encountered.\r
+  EFI_INVALID_PARAMETER   One of the parameters was NULL.\r
+\r
+--*/\r
+{\r
+  EFI_FFS_FILE_HEADER *CurrentFile;\r
+  EFI_STATUS          Status;\r
+\r
+  //\r
+  // Verify library has been initialized.\r
+  //\r
+  if (mFvHeader == NULL || mFvLength == 0) {\r
+    return EFI_ABORTED;\r
+  }\r
+  //\r
+  // Verify input parameters\r
+  //\r
+  if (FileName == NULL || File == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+  //\r
+  // Verify FV header\r
+  //\r
+  Status = VerifyFv (mFvHeader);\r
+  if (EFI_ERROR (Status)) {\r
+    return EFI_ABORTED;\r
+  }\r
+  //\r
+  // Get the first file\r
+  //\r
+  Status = GetNextFile (NULL, &CurrentFile);\r
+  if (EFI_ERROR (Status)) {\r
+    Error (NULL, 0, 0, "error parsing the FV", NULL);\r
+    return EFI_ABORTED;\r
+  }\r
+  //\r
+  // Loop as long as we have a valid file\r
+  //\r
+  while (CurrentFile) {\r
+    if (!CompareGuid (&CurrentFile->Name, FileName)) {\r
+      *File = CurrentFile;\r
+      return EFI_SUCCESS;\r
+    }\r
+\r
+    Status = GetNextFile (CurrentFile, &CurrentFile);\r
+    if (EFI_ERROR (Status)) {\r
+      Error (NULL, 0, 0, "error parsing the FV", NULL);\r
+      return EFI_ABORTED;\r
+    }\r
+  }\r
+  //\r
+  // File not found in this FV.\r
+  //\r
+  *File = NULL;\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+GetFileByType (\r
+  IN EFI_FV_FILETYPE              FileType,\r
+  IN UINTN                        Instance,\r
+  OUT EFI_FFS_FILE_HEADER         **File\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Find a file by type and instance.  An instance of 1 is the first instance.\r
+  The function will return NULL if a matching file cannot be found.\r
+  File type EFI_FV_FILETYPE_ALL means any file type is valid.\r
+\r
+Arguments:\r
+\r
+  FileType    Type of file to search for.\r
+  Instance    Instace of the file type to return.\r
+  File        Return pointer.  In the case of an error, contents are undefined.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS             The function completed successfully.\r
+  EFI_ABORTED             An error was encountered.\r
+  EFI_INVALID_PARAMETER   One of the parameters was NULL.\r
+\r
+--*/\r
+{\r
+  EFI_FFS_FILE_HEADER *CurrentFile;\r
+  EFI_STATUS          Status;\r
+  UINTN               FileCount;\r
+\r
+  //\r
+  // Verify library has been initialized.\r
+  //\r
+  if (mFvHeader == NULL || mFvLength == 0) {\r
+    return EFI_ABORTED;\r
+  }\r
+  //\r
+  // Verify input parameters\r
+  //\r
+  if (File == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+  //\r
+  // Verify FV header\r
+  //\r
+  Status = VerifyFv (mFvHeader);\r
+  if (EFI_ERROR (Status)) {\r
+    return EFI_ABORTED;\r
+  }\r
+  //\r
+  // Initialize the number of matching files found.\r
+  //\r
+  FileCount = 0;\r
+\r
+  //\r
+  // Get the first file\r
+  //\r
+  Status = GetNextFile (NULL, &CurrentFile);\r
+  if (EFI_ERROR (Status)) {\r
+    Error (NULL, 0, 0, "error parsing FV", NULL);\r
+    return EFI_ABORTED;\r
+  }\r
+  //\r
+  // Loop as long as we have a valid file\r
+  //\r
+  while (CurrentFile) {\r
+    if (FileType == EFI_FV_FILETYPE_ALL || CurrentFile->Type == FileType) {\r
+      FileCount++;\r
+    }\r
+\r
+    if (FileCount == Instance) {\r
+      *File = CurrentFile;\r
+      return EFI_SUCCESS;\r
+    }\r
+\r
+    Status = GetNextFile (CurrentFile, &CurrentFile);\r
+    if (EFI_ERROR (Status)) {\r
+      Error (NULL, 0, 0, "error parsing the FV", NULL);\r
+      return EFI_ABORTED;\r
+    }\r
+  }\r
+\r
+  *File = NULL;\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+GetSectionByType (\r
+  IN EFI_FFS_FILE_HEADER          *File,\r
+  IN EFI_SECTION_TYPE             SectionType,\r
+  IN UINTN                        Instance,\r
+  OUT EFI_FILE_SECTION_POINTER    *Section\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Find a section in a file by type and instance.  An instance of 1 is the first \r
+  instance.  The function will return NULL if a matching section cannot be found.\r
+  The function will not handle encapsulating sections.\r
+\r
+Arguments:\r
+\r
+  File        The file to search.\r
+  SectionType Type of file to search for.\r
+  Instance    Instace of the section to return.\r
+  Section     Return pointer.  In the case of an error, contents are undefined.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS             The function completed successfully.\r
+  EFI_ABORTED             An error was encountered.\r
+  EFI_INVALID_PARAMETER   One of the parameters was NULL.\r
+  EFI_NOT_FOUND           No found.\r
+--*/\r
+{\r
+  EFI_FILE_SECTION_POINTER  CurrentSection;\r
+  EFI_STATUS                Status;\r
+  UINTN                     SectionCount;\r
+\r
+  //\r
+  // Verify input parameters\r
+  //\r
+  if (File == NULL || Instance == 0) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+  //\r
+  // Verify FFS header\r
+  //\r
+  Status = VerifyFfsFile (File);\r
+  if (EFI_ERROR (Status)) {\r
+    Error (NULL, 0, 0, "invalid FFS file", NULL);\r
+    return EFI_ABORTED;\r
+  }\r
+  //\r
+  // Initialize the number of matching sections found.\r
+  //\r
+  SectionCount = 0;\r
+\r
+  //\r
+  // Get the first section\r
+  //\r
+  CurrentSection.CommonHeader = (EFI_COMMON_SECTION_HEADER *) ((UINTN) File + sizeof (EFI_FFS_FILE_HEADER));\r
+\r
+  //\r
+  // Loop as long as we have a valid file\r
+  //\r
+  while ((UINTN) CurrentSection.CommonHeader < (UINTN) File + GetLength (File->Size)) {\r
+    if (CurrentSection.CommonHeader->Type == SectionType) {\r
+      SectionCount++;\r
+    }\r
+\r
+    if (SectionCount == Instance) {\r
+      *Section = CurrentSection;\r
+      return EFI_SUCCESS;\r
+    }\r
+    //\r
+    // Find next section (including compensating for alignment issues.\r
+    //\r
+    CurrentSection.CommonHeader = (EFI_COMMON_SECTION_HEADER *) ((((UINTN) CurrentSection.CommonHeader) + GetLength (CurrentSection.CommonHeader->Size) + 0x03) & (-1 << 2));\r
+  }\r
+  //\r
+  // Section not found\r
+  //\r
+  (*Section).Code16Section = NULL;\r
+  return EFI_NOT_FOUND;\r
+}\r
+//\r
+// will not parse compressed sections\r
+//\r
+EFI_STATUS\r
+VerifyFv (\r
+  IN EFI_FIRMWARE_VOLUME_HEADER   *FvHeader\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Verify the current pointer points to a valid FV header.\r
+\r
+Arguments:\r
+\r
+  FvHeader     Pointer to an alleged FV file.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS             The FV header is valid.\r
+  EFI_VOLUME_CORRUPTED    The FV header is not valid.\r
+  EFI_INVALID_PARAMETER   A required parameter was NULL.\r
+  EFI_ABORTED             Operation aborted.\r
+\r
+--*/\r
+{\r
+  UINT16  Checksum;\r
+\r
+  //\r
+  // Verify input parameters\r
+  //\r
+  if (FvHeader == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  if (FvHeader->Signature != EFI_FVH_SIGNATURE) {\r
+    Error (NULL, 0, 0, "invalid FV header signature", NULL);\r
+    return EFI_VOLUME_CORRUPTED;\r
+  }\r
+  //\r
+  // Verify header checksum\r
+  //\r
+  Checksum = CalculateSum16 ((UINT16 *) FvHeader, FvHeader->HeaderLength / sizeof (UINT16));\r
+\r
+  if (Checksum != 0) {\r
+    Error (NULL, 0, 0, "invalid FV header checksum", NULL);\r
+    return EFI_ABORTED;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+VerifyFfsFile (\r
+  IN EFI_FFS_FILE_HEADER  *FfsHeader\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Verify the current pointer points to a FFS file header.\r
+\r
+Arguments:\r
+\r
+  FfsHeader     Pointer to an alleged FFS file.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS           The Ffs header is valid.\r
+  EFI_NOT_FOUND         This "file" is the beginning of free space.\r
+  EFI_VOLUME_CORRUPTED  The Ffs header is not valid.\r
+  EFI_ABORTED           The erase polarity is not known.\r
+\r
+--*/\r
+{\r
+  BOOLEAN             ErasePolarity;\r
+  EFI_STATUS          Status;\r
+  EFI_FFS_FILE_HEADER BlankHeader;\r
+  UINT8               Checksum;\r
+  UINT32              FileLength;\r
+  UINT32              OccupiedFileLength;\r
+  EFI_FFS_FILE_TAIL   *Tail;\r
+  UINT8               SavedChecksum;\r
+  UINT8               SavedState;\r
+  UINT8               FileGuidString[80];\r
+  UINT32              TailSize;\r
+  //\r
+  // Verify library has been initialized.\r
+  //\r
+  if (mFvHeader == NULL || mFvLength == 0) {\r
+    return EFI_ABORTED;\r
+  }\r
+  //\r
+  // Verify FV header\r
+  //\r
+  Status = VerifyFv (mFvHeader);\r
+  if (EFI_ERROR (Status)) {\r
+    return EFI_ABORTED;\r
+  }\r
+  //\r
+  // Get the erase polarity.\r
+  //\r
+  Status = GetErasePolarity (&ErasePolarity);\r
+  if (EFI_ERROR (Status)) {\r
+    return EFI_ABORTED;\r
+  }\r
+  //\r
+  // Check if we have free space\r
+  //\r
+  if (ErasePolarity) {\r
+    memset (&BlankHeader, -1, sizeof (EFI_FFS_FILE_HEADER));\r
+  } else {\r
+    memset (&BlankHeader, 0, sizeof (EFI_FFS_FILE_HEADER));\r
+  }\r
+\r
+  if (memcmp (&BlankHeader, FfsHeader, sizeof (EFI_FFS_FILE_HEADER)) == 0) {\r
+    return EFI_NOT_FOUND;\r
+  }\r
+  //\r
+  // Convert the GUID to a string so we can at least report which file\r
+  // if we find an error.\r
+  //\r
+  PrintGuidToBuffer (&FfsHeader->Name, FileGuidString, sizeof (FileGuidString), TRUE);\r
+  if (FfsHeader->Attributes & FFS_ATTRIB_TAIL_PRESENT) {\r
+    TailSize = sizeof (EFI_FFS_FILE_TAIL);\r
+  } else {\r
+    TailSize = 0;\r
+  }\r
+  //\r
+  // Verify file header checksum\r
+  //\r
+  SavedState = FfsHeader->State;\r
+  FfsHeader->State = 0;\r
+  SavedChecksum = FfsHeader->IntegrityCheck.Checksum.File;\r
+  FfsHeader->IntegrityCheck.Checksum.File = 0;\r
+  Checksum = CalculateSum8 ((UINT8 *) FfsHeader, sizeof (EFI_FFS_FILE_HEADER));\r
+  FfsHeader->State = SavedState;\r
+  FfsHeader->IntegrityCheck.Checksum.File = SavedChecksum;\r
+  if (Checksum != 0) {\r
+    Error (NULL, 0, 0, FileGuidString, "invalid FFS file header checksum");\r
+    return EFI_ABORTED;\r
+  }\r
+  //\r
+  // Verify file checksum\r
+  //\r
+  if (FfsHeader->Attributes & FFS_ATTRIB_CHECKSUM) {\r
+    //\r
+    // Verify file data checksum\r
+    //\r
+    FileLength          = GetLength (FfsHeader->Size);\r
+    OccupiedFileLength  = (FileLength + 0x07) & (-1 << 3);\r
+    Checksum            = CalculateSum8 ((UINT8 *) FfsHeader, FileLength - TailSize);\r
+    Checksum            = (UINT8) (Checksum - FfsHeader->State);\r
+    if (Checksum != 0) {\r
+      Error (NULL, 0, 0, FileGuidString, "invalid FFS file checksum");\r
+      return EFI_ABORTED;\r
+    }\r
+  } else {\r
+    //\r
+    // File does not have a checksum\r
+    // Verify contents are 0x5A as spec'd\r
+    //\r
+    if (FfsHeader->IntegrityCheck.Checksum.File != FFS_FIXED_CHECKSUM) {\r
+      Error (NULL, 0, 0, FileGuidString, "invalid fixed FFS file header checksum");\r
+      return EFI_ABORTED;\r
+    }\r
+  }\r
+  //\r
+  // Check if the tail is present and verify it if it is.\r
+  //\r
+  if (FfsHeader->Attributes & FFS_ATTRIB_TAIL_PRESENT) {\r
+    //\r
+    // Verify tail is complement of integrity check field in the header.\r
+    //\r
+    Tail = (EFI_FFS_FILE_TAIL *) ((UINTN) FfsHeader + GetLength (FfsHeader->Size) - sizeof (EFI_FFS_FILE_TAIL));\r
+    if (FfsHeader->IntegrityCheck.TailReference != (EFI_FFS_FILE_TAIL)~(*Tail)) {\r
+      Error (NULL, 0, 0, FileGuidString, "invalid FFS file tail");\r
+      return EFI_ABORTED;\r
+    }\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+UINT32\r
+GetLength (\r
+  UINT8     *ThreeByteLength\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Converts a three byte length value into a UINT32.\r
+\r
+Arguments:\r
+\r
+  ThreeByteLength   Pointer to the first of the 3 byte length.\r
+\r
+Returns:\r
+\r
+  UINT32      Size of the section\r
+\r
+--*/\r
+{\r
+  UINT32  Length;\r
+\r
+  if (ThreeByteLength == NULL) {\r
+    return 0;\r
+  }\r
+\r
+  Length  = *((UINT32 *) ThreeByteLength);\r
+  Length  = Length & 0x00FFFFFF;\r
+\r
+  return Length;\r
+}\r
+\r
+EFI_STATUS\r
+GetErasePolarity (\r
+  OUT BOOLEAN   *ErasePolarity\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function returns with the FV erase polarity.  If the erase polarity\r
+  for a bit is 1, the function return TRUE.\r
+\r
+Arguments:\r
+\r
+  ErasePolarity   A pointer to the erase polarity.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS              The function completed successfully.\r
+  EFI_INVALID_PARAMETER    One of the input parameters was invalid.\r
+  EFI_ABORTED              Operation aborted.\r
+  \r
+--*/\r
+{\r
+  EFI_STATUS  Status;\r
+\r
+  //\r
+  // Verify library has been initialized.\r
+  //\r
+  if (mFvHeader == NULL || mFvLength == 0) {\r
+    return EFI_ABORTED;\r
+  }\r
+  //\r
+  // Verify FV header\r
+  //\r
+  Status = VerifyFv (mFvHeader);\r
+  if (EFI_ERROR (Status)) {\r
+    return EFI_ABORTED;\r
+  }\r
+  //\r
+  // Verify input parameters.\r
+  //\r
+  if (ErasePolarity == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  if (mFvHeader->Attributes & EFI_FVB_ERASE_POLARITY) {\r
+    *ErasePolarity = TRUE;\r
+  } else {\r
+    *ErasePolarity = FALSE;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+UINT8\r
+GetFileState (\r
+  IN BOOLEAN              ErasePolarity,\r
+  IN EFI_FFS_FILE_HEADER  *FfsHeader\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function returns a the highest state bit in the FFS that is set.\r
+  It in no way validate the FFS file.\r
+\r
+Arguments:\r
+  \r
+  ErasePolarity The erase polarity for the file state bits.\r
+  FfsHeader     Pointer to a FFS file.\r
+\r
+Returns:\r
+\r
+  UINT8   The hightest set state of the file.\r
+\r
+--*/\r
+{\r
+  UINT8 FileState;\r
+  UINT8 HighestBit;\r
+\r
+  FileState = FfsHeader->State;\r
+\r
+  if (ErasePolarity) {\r
+    FileState = (UINT8)~FileState;\r
+  }\r
+\r
+  HighestBit = 0x80;\r
+  while (HighestBit != 0 && (HighestBit & FileState) == 0) {\r
+    HighestBit >>= 1;\r
+  }\r
+\r
+  return HighestBit;\r
+}\r
diff --git a/Tools/CodeTools/Source/Common/FvLib.h b/Tools/CodeTools/Source/Common/FvLib.h
new file mode 100644 (file)
index 0000000..1ad1e81
--- /dev/null
@@ -0,0 +1,181 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  FvLib.h\r
+\r
+Abstract:\r
+\r
+  These functions assist in parsing and manipulating a Firmware Volume.\r
+\r
+--*/\r
+\r
+#ifndef _EFI_FV_LIB_H\r
+#define _EFI_FV_LIB_H\r
+\r
+//\r
+// Include files\r
+//\r
+#include <string.h>\r
+\r
+#include <Common/UefiBaseTypes.h>\r
+#include <Common/EfiImage.h>\r
+#include <Common/FirmwareVolumeImageFormat.h>\r
+#include <Common/FirmwareFileSystem.h>\r
+#include <Common/FirmwareVolumeHeader.h>\r
+#include <Common/MultiPhase.h>\r
+\r
+EFI_STATUS\r
+InitializeFvLib (\r
+  IN VOID                         *Fv,\r
+  IN UINT32                       FvLength\r
+  )\r
+;\r
+\r
+EFI_STATUS\r
+GetFvHeader (\r
+  OUT EFI_FIRMWARE_VOLUME_HEADER  **FvHeader,\r
+  OUT UINT32                      *FvLength\r
+  )\r
+;\r
+\r
+EFI_STATUS\r
+GetNextFile (\r
+  IN EFI_FFS_FILE_HEADER          *CurrentFile,\r
+  OUT EFI_FFS_FILE_HEADER         **NextFile\r
+  )\r
+;\r
+\r
+EFI_STATUS\r
+GetFileByName (\r
+  IN EFI_GUID                     *FileName,\r
+  OUT EFI_FFS_FILE_HEADER         **File\r
+  )\r
+;\r
+\r
+EFI_STATUS\r
+GetFileByType (\r
+  IN EFI_FV_FILETYPE              FileType,\r
+  IN UINTN                        Instance,\r
+  OUT EFI_FFS_FILE_HEADER         **File\r
+  )\r
+;\r
+\r
+EFI_STATUS\r
+GetSectionByType (\r
+  IN EFI_FFS_FILE_HEADER          *File,\r
+  IN EFI_SECTION_TYPE             SectionType,\r
+  IN UINTN                        Instance,\r
+  OUT EFI_FILE_SECTION_POINTER    *Section\r
+  )\r
+;\r
+//\r
+// will not parse compressed sections\r
+//\r
+EFI_STATUS\r
+VerifyFv (\r
+  IN EFI_FIRMWARE_VOLUME_HEADER   *FvHeader\r
+  )\r
+;\r
+\r
+EFI_STATUS\r
+VerifyFfsFile (\r
+  IN EFI_FFS_FILE_HEADER          *FfsHeader\r
+  )\r
+;\r
+\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Verify the current pointer points to a FFS file header.\r
+\r
+Arguments:\r
+\r
+  FfsHeader     Pointer to an alleged FFS file.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS           The Ffs header is valid.\r
+  EFI_NOT_FOUND         This "file" is the beginning of free space.\r
+  EFI_VOLUME_CORRUPTED  The Ffs header is not valid.\r
+\r
+--*/\r
+UINT32\r
+GetLength (\r
+  UINT8                           *ThreeByteLength\r
+  )\r
+;\r
+\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Converts a three byte length value into a UINT32.\r
+\r
+Arguments:\r
+\r
+  ThreeByteLength   Pointer to the first of the 3 byte length.\r
+\r
+Returns:\r
+\r
+  UINT32      Size of the section\r
+\r
+--*/\r
+EFI_STATUS\r
+GetErasePolarity (\r
+  OUT BOOLEAN   *ErasePolarity\r
+  )\r
+;\r
+\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function returns with the FV erase polarity.  If the erase polarity\r
+  for a bit is 1, the function return TRUE.\r
+\r
+Arguments:\r
+\r
+  ErasePolarity   A pointer to the erase polarity.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS              The function completed successfully.\r
+  EFI_INVALID_PARAMETER    One of the input parameters was invalid.\r
+\r
+--*/\r
+UINT8\r
+GetFileState (\r
+  IN BOOLEAN              ErasePolarity,\r
+  IN EFI_FFS_FILE_HEADER  *FfsHeader\r
+  )\r
+;\r
+\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function returns a the highest state bit in the FFS that is set.\r
+  It in no way validate the FFS file.\r
+\r
+Arguments:\r
+  \r
+  ErasePolarity The erase polarity for the file state bits.\r
+  FfsHeader     Pointer to a FFS file.\r
+\r
+Returns:\r
+\r
+  UINT8   The hightest set state of the file.\r
+\r
+--*/\r
+#endif\r
diff --git a/Tools/CodeTools/Source/Common/MyAlloc.c b/Tools/CodeTools/Source/Common/MyAlloc.c
new file mode 100644 (file)
index 0000000..39fddf7
--- /dev/null
@@ -0,0 +1,516 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  MyAlloc.c\r
+\r
+Abstract:\r
+\r
+  File for memory allocation tracking functions.\r
+\r
+--*/\r
+\r
+#include "MyAlloc.h"\r
+\r
+#if USE_MYALLOC\r
+//\r
+// Get back to original alloc/free calls.\r
+//\r
+#undef malloc\r
+#undef calloc\r
+#undef realloc\r
+#undef free\r
+//\r
+// Start of allocation list.\r
+//\r
+static MY_ALLOC_STRUCT  *MyAllocData = NULL;\r
+\r
+//\r
+//\r
+//\r
+static UINT32           MyAllocHeadMagik  = MYALLOC_HEAD_MAGIK;\r
+static UINT32           MyAllocTailMagik  = MYALLOC_TAIL_MAGIK;\r
+\r
+//\r
+// ////////////////////////////////////////////////////////////////////////////\r
+//\r
+//\r
+VOID\r
+MyCheck (\r
+  BOOLEAN      Final,\r
+  UINT8        File[],\r
+  UINTN        Line\r
+  )\r
+// *++\r
+// Description:\r
+//\r
+//  Check for corruptions in the allocated memory chain.  If a corruption\r
+//  is detection program operation stops w/ an exit(1) call.\r
+//\r
+// Parameters:\r
+//\r
+//  Final := When FALSE, MyCheck() returns if the allocated memory chain\r
+//           has not been corrupted.  When TRUE, MyCheck() returns if there\r
+//           are no un-freed allocations.  If there are un-freed allocations,\r
+//           they are displayed and exit(1) is called.\r
+//\r
+//\r
+//  File := Set to __FILE__ by macro expansion.\r
+//\r
+//  Line := Set to __LINE__ by macro expansion.\r
+//\r
+// Returns:\r
+//\r
+//  n/a\r
+//\r
+// --*/\r
+//\r
+{\r
+  MY_ALLOC_STRUCT *Tmp;\r
+\r
+  //\r
+  // Check parameters.\r
+  //\r
+  if (File == NULL || Line == 0) {\r
+    printf (\r
+      "\nMyCheck(Final=%u, File=%xh, Line=%u)"\r
+      "Invalid parameter(s).\n",\r
+      Final,\r
+      File,\r
+      Line\r
+      );\r
+\r
+    exit (1);\r
+  }\r
+\r
+  if (strlen (File) == 0) {\r
+    printf (\r
+      "\nMyCheck(Final=%u, File=%s, Line=%u)"\r
+      "Invalid parameter.\n",\r
+      Final,\r
+      File,\r
+      Line\r
+      );\r
+\r
+    exit (1);\r
+  }\r
+  //\r
+  // Check structure contents.\r
+  //\r
+  for (Tmp = MyAllocData; Tmp != NULL; Tmp = Tmp->Next) {\r
+    if (memcmp(Tmp->Buffer, &MyAllocHeadMagik, sizeof MyAllocHeadMagik) ||\r
+        memcmp(&Tmp->Buffer[Tmp->Size + sizeof(UINT32)], &MyAllocTailMagik, sizeof MyAllocTailMagik)) {\r
+      break;\r
+    }\r
+  }\r
+  //\r
+  // If Tmp is not NULL, the structure is corrupt.\r
+  //\r
+  if (Tmp != NULL) {\r
+    printf (\r
+      "\nMyCheck(Final=%u, File=%s, Line=%u)""\nStructure corrupted!"\r
+      "\nFile=%s, Line=%u, nSize=%u, Head=%xh, Tail=%xh\n",\r
+      Final,\r
+      File,\r
+      Line,\r
+      Tmp->File,\r
+      Tmp->Line,\r
+      Tmp->Size,\r
+      *(UINT32 *) (Tmp->Buffer),\r
+      *(UINT32 *) (&Tmp->Buffer[Tmp->Size + sizeof (UINT32)])\r
+      );\r
+\r
+    exit (1);\r
+  }\r
+  //\r
+  // If Final is TRUE, display the state of the structure chain.\r
+  //\r
+  if (Final) {\r
+    if (MyAllocData != NULL) {\r
+      printf (\r
+        "\nMyCheck(Final=%u, File=%s, Line=%u)"\r
+        "\nSome allocated items have not been freed.\n",\r
+        Final,\r
+        File,\r
+        Line\r
+        );\r
+\r
+      for (Tmp = MyAllocData; Tmp != NULL; Tmp = Tmp->Next) {\r
+        printf (\r
+          "File=%s, Line=%u, nSize=%u, Head=%xh, Tail=%xh\n",\r
+          Tmp->File,\r
+          Tmp->Line,\r
+          Tmp->Size,\r
+          *(UINT32 *) (Tmp->Buffer),\r
+          *(UINT32 *) (&Tmp->Buffer[Tmp->Size + sizeof (UINT32)])\r
+          );\r
+      }\r
+    }\r
+  }\r
+}\r
+//\r
+// ////////////////////////////////////////////////////////////////////////////\r
+//\r
+//\r
+VOID *\r
+MyAlloc (\r
+  UINTN      Size,\r
+  UINT8 File[],\r
+  UINTN      Line\r
+  )\r
+// *++\r
+// Description:\r
+//\r
+//  Allocate a new link in the allocation chain along with enough storage\r
+//  for the File[] string, requested Size and alignment overhead.  If\r
+//  memory cannot be allocated or the allocation chain has been corrupted,\r
+//  exit(1) will be called.\r
+//\r
+// Parameters:\r
+//\r
+//  Size := Number of bytes (UINT8) requested by the called.\r
+//          Size cannot be zero.\r
+//\r
+//  File := Set to __FILE__ by macro expansion.\r
+//\r
+//  Line := Set to __LINE__ by macro expansion.\r
+//\r
+// Returns:\r
+//\r
+//  Pointer to the caller's buffer.\r
+//\r
+// --*/\r
+//\r
+{\r
+  MY_ALLOC_STRUCT *Tmp;\r
+  UINTN           Len;\r
+\r
+  //\r
+  // Check for invalid parameters.\r
+  //\r
+  if (Size == 0 || File == NULL || Line == 0) {\r
+    printf (\r
+      "\nMyAlloc(Size=%u, File=%xh, Line=%u)"\r
+      "\nInvalid parameter(s).\n",\r
+      Size,\r
+      File,\r
+      Line\r
+      );\r
+\r
+    exit (1);\r
+  }\r
+\r
+  Len = strlen (File);\r
+  if (Len == 0) {\r
+    printf (\r
+      "\nMyAlloc(Size=%u, File=%s, Line=%u)"\r
+      "\nInvalid parameter.\n",\r
+      Size,\r
+      File,\r
+      Line\r
+      );\r
+\r
+    exit (1);\r
+  }\r
+  //\r
+  // Check the allocation list for corruption.\r
+  //\r
+  MyCheck (0, __FILE__, __LINE__);\r
+\r
+  //\r
+  // Allocate a new entry.\r
+  //\r
+  Tmp = calloc (\r
+          1,\r
+          sizeof (MY_ALLOC_STRUCT) + Len + 1 + sizeof (UINT64) + Size + (sizeof MyAllocHeadMagik) + (sizeof MyAllocTailMagik)\r
+          );\r
+\r
+  if (Tmp == NULL) {\r
+    printf (\r
+      "\nMyAlloc(Size=%u, File=%s, Line=%u)"\r
+      "\nOut of memory.\n",\r
+      Size,\r
+      File,\r
+      Line\r
+      );\r
+\r
+    exit (1);\r
+  }\r
+  //\r
+  // Fill in the new entry.\r
+  //\r
+  Tmp->File = ((UINT8 *) Tmp) + sizeof (MY_ALLOC_STRUCT);\r
+  strcpy (Tmp->File, File);\r
+  Tmp->Line   = Line;\r
+  Tmp->Size   = Size;\r
+  Tmp->Buffer = (UINT8 *) (((UINTN) Tmp + Len + 9) &~7);\r
+\r
+  memcpy (Tmp->Buffer, &MyAllocHeadMagik, sizeof MyAllocHeadMagik);\r
+\r
+  memcpy (\r
+    &Tmp->Buffer[Size + sizeof (UINT32)],\r
+    &MyAllocTailMagik,\r
+    sizeof MyAllocTailMagik\r
+    );\r
+\r
+  Tmp->Next   = MyAllocData;\r
+  Tmp->Cksum  = (UINTN) Tmp + (UINTN) (Tmp->Next) + Tmp->Line + Tmp->Size + (UINTN) (Tmp->File) + (UINTN) (Tmp->Buffer);\r
+\r
+  MyAllocData = Tmp;\r
+\r
+  return Tmp->Buffer + sizeof (UINT32);\r
+}\r
+//\r
+// ////////////////////////////////////////////////////////////////////////////\r
+//\r
+//\r
+VOID *\r
+MyRealloc (\r
+  VOID       *Ptr,\r
+  UINTN      Size,\r
+  UINT8 File[],\r
+  UINTN      Line\r
+  )\r
+// *++\r
+// Description:\r
+//\r
+//  This does a MyAlloc(), memcpy() and MyFree().  There is no optimization\r
+//  for shrinking or expanding buffers.  An invalid parameter will cause\r
+//  MyRealloc() to fail with a call to exit(1).\r
+//\r
+// Parameters:\r
+//\r
+//  Ptr := Pointer to the caller's buffer to be re-allocated.\r
+//\r
+//  Size := Size of new buffer.  Size cannot be zero.\r
+//\r
+//  File := Set to __FILE__ by macro expansion.\r
+//\r
+//  Line := Set to __LINE__ by macro expansion.\r
+//\r
+// Returns:\r
+//\r
+//  Pointer to new caller's buffer.\r
+//\r
+// --*/\r
+//\r
+{\r
+  MY_ALLOC_STRUCT *Tmp;\r
+  VOID            *Buffer;\r
+\r
+  //\r
+  // Check for invalid parameter(s).\r
+  //\r
+  if (Size == 0 || File == NULL || Line == 0) {\r
+    printf (\r
+      "\nMyRealloc(Ptr=%xh, Size=%u, File=%xh, Line=%u)"\r
+      "\nInvalid parameter(s).\n",\r
+      Ptr,\r
+      Size,\r
+      File,\r
+      Line\r
+      );\r
+\r
+    exit (1);\r
+  }\r
+\r
+  if (strlen (File) == 0) {\r
+    printf (\r
+      "\nMyRealloc(Ptr=%xh, Size=%u, File=%s, Line=%u)"\r
+      "\nInvalid parameter.\n",\r
+      Ptr,\r
+      Size,\r
+      File,\r
+      Line\r
+      );\r
+\r
+    exit (1);\r
+  }\r
+  //\r
+  // Find existing buffer in allocation list.\r
+  //\r
+  if (Ptr == NULL) {\r
+    Tmp = NULL;\r
+  } else if (&MyAllocData->Buffer[sizeof (UINT32)] == Ptr) {\r
+    Tmp = MyAllocData;\r
+  } else {\r
+    for (Tmp = MyAllocData;; Tmp = Tmp->Next) {\r
+      if (Tmp->Next == NULL) {\r
+        printf (\r
+          "\nMyRealloc(Ptr=%xh, Size=%u, File=%s, Line=%u)"\r
+          "\nCould not find buffer.\n",\r
+          Ptr,\r
+          Size,\r
+          File,\r
+          Line\r
+          );\r
+\r
+        exit (1);\r
+      }\r
+\r
+      Tmp = Tmp->Next;\r
+    }\r
+  }\r
+  //\r
+  // Allocate new buffer, copy old data, free old buffer.\r
+  //\r
+  Buffer = MyAlloc (Size, File, Line);\r
+\r
+  if (Buffer != NULL && Tmp != NULL) {\r
+    memcpy (\r
+      Buffer,\r
+      &Tmp->Buffer[sizeof (UINT32)],\r
+      ((Size <= Tmp->Size) ? Size : Tmp->Size)\r
+      );\r
+\r
+    MyFree (Ptr, __FILE__, __LINE__);\r
+  }\r
+\r
+  return Buffer;\r
+}\r
+//\r
+// ////////////////////////////////////////////////////////////////////////////\r
+//\r
+//\r
+VOID\r
+MyFree (\r
+  VOID       *Ptr,\r
+  UINT8 File[],\r
+  UINTN      Line\r
+  )\r
+// *++\r
+// Description:\r
+//\r
+//  Release a previously allocated buffer.  Invalid parameters will cause\r
+//  MyFree() to fail with an exit(1) call.\r
+//\r
+// Parameters:\r
+//\r
+//  Ptr := Pointer to the caller's buffer to be freed.\r
+//         A NULL pointer will be ignored.\r
+//\r
+//  File := Set to __FILE__ by macro expansion.\r
+//\r
+//  Line := Set to __LINE__ by macro expansion.\r
+//\r
+// Returns:\r
+//\r
+//  n/a\r
+//\r
+// --*/\r
+//\r
+{\r
+  MY_ALLOC_STRUCT *Tmp;\r
+  MY_ALLOC_STRUCT *Tmp2;\r
+\r
+  //\r
+  // Check for invalid parameter(s).\r
+  //\r
+  if (File == NULL || Line == 0) {\r
+    printf (\r
+      "\nMyFree(Ptr=%xh, File=%xh, Line=%u)"\r
+      "\nInvalid parameter(s).\n",\r
+      Ptr,\r
+      File,\r
+      Line\r
+      );\r
+\r
+    exit (1);\r
+  }\r
+\r
+  if (strlen (File) == 0) {\r
+    printf (\r
+      "\nMyFree(Ptr=%xh, File=%s, Line=%u)"\r
+      "\nInvalid parameter.\n",\r
+      Ptr,\r
+      File,\r
+      Line\r
+      );\r
+\r
+    exit (1);\r
+  }\r
+  //\r
+  // Freeing NULL is always valid.\r
+  //\r
+  if (Ptr == NULL) {\r
+    return ;\r
+  }\r
+  //\r
+  // Fail if nothing is allocated.\r
+  //\r
+  if (MyAllocData == NULL) {\r
+    printf (\r
+      "\nMyFree(Ptr=%xh, File=%s, Line=%u)"\r
+      "\nCalled before memory allocated.\n",\r
+      Ptr,\r
+      File,\r
+      Line\r
+      );\r
+\r
+    exit (1);\r
+  }\r
+  //\r
+  // Check for corrupted allocation list.\r
+  //\r
+  MyCheck (0, __FILE__, __LINE__);\r
+\r
+  //\r
+  // Need special check for first item in list.\r
+  //\r
+  if (&MyAllocData->Buffer[sizeof (UINT32)] == Ptr) {\r
+    //\r
+    // Unlink first item in list.\r
+    //\r
+    Tmp         = MyAllocData;\r
+    MyAllocData = MyAllocData->Next;\r
+  } else {\r
+    //\r
+    // Walk list looking for matching item.\r
+    //\r
+    for (Tmp = MyAllocData;; Tmp = Tmp->Next) {\r
+      //\r
+      // Fail if end of list is reached.\r
+      //\r
+      if (Tmp->Next == NULL) {\r
+        printf (\r
+          "\nMyFree(Ptr=%xh, File=%s, Line=%u)\n"\r
+          "\nNot found.\n",\r
+          Ptr,\r
+          File,\r
+          Line\r
+          );\r
+\r
+        exit (1);\r
+      }\r
+      //\r
+      // Leave loop when match is found.\r
+      //\r
+      if (&Tmp->Next->Buffer[sizeof (UINT32)] == Ptr) {\r
+        break;\r
+      }\r
+    }\r
+    //\r
+    // Unlink item from list.\r
+    //\r
+    Tmp2      = Tmp->Next;\r
+    Tmp->Next = Tmp->Next->Next;\r
+    Tmp       = Tmp2;\r
+  }\r
+  //\r
+  // Release item.\r
+  //\r
+  free (Tmp);\r
+}\r
+\r
+#endif /* USE_MYALLOC */\r
+\r
+/* eof - MyAlloc.c */\r
diff --git a/Tools/CodeTools/Source/Common/MyAlloc.h b/Tools/CodeTools/Source/Common/MyAlloc.h
new file mode 100644 (file)
index 0000000..9697012
--- /dev/null
@@ -0,0 +1,222 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  MyAlloc.h\r
+\r
+Abstract:\r
+\r
+  Header file for memory allocation tracking functions.\r
+\r
+--*/\r
+\r
+#ifndef _MYALLOC_H_\r
+#define _MYALLOC_H_\r
+\r
+#include <stdio.h>\r
+#include <stdlib.h>\r
+#include <string.h>\r
+\r
+#include <Common/BaseTypes.h>\r
+\r
+//\r
+// Default operation is to use the memory allocation tracking functions.\r
+// To over-ride add "#define USE_MYALLOC 0" to your program header and/or\r
+// source files as needed.  Or, just do not include this header file in\r
+// your project.\r
+//\r
+#ifndef USE_MYALLOC\r
+#define USE_MYALLOC 1\r
+#endif\r
+\r
+#if USE_MYALLOC\r
+//\r
+// Replace C library allocation routines with MyAlloc routines.\r
+//\r
+#define malloc(size)        MyAlloc ((size), __FILE__, __LINE__)\r
+#define calloc(count, size) MyAlloc ((count) * (size), __FILE__, __LINE__)\r
+#define realloc(ptr, size)  MyRealloc ((ptr), (size), __FILE__, __LINE__)\r
+#define free(ptr)           MyFree ((ptr), __FILE__, __LINE__)\r
+#define alloc_check(final)  MyCheck ((final), __FILE__, __LINE__)\r
+\r
+//\r
+// Structure for checking/tracking memory allocations.\r
+//\r
+typedef struct MyAllocStruct {\r
+  UINTN                 Cksum;\r
+  struct MyAllocStruct  *Next;\r
+  UINTN                 Line;\r
+  UINTN                 Size;\r
+  UINT8                 *File;\r
+  UINT8                 *Buffer;\r
+} MY_ALLOC_STRUCT;\r
+//\r
+// Cksum := (UINTN)This + (UINTN)Next + Line + Size + (UINTN)File +\r
+//          (UINTN)Buffer;\r
+//\r
+// Next := Pointer to next allocation structure in the list.\r
+//\r
+// Line := __LINE__\r
+//\r
+// Size := Size of allocation request.\r
+//\r
+// File := Pointer to __FILE__ string stored immediately following\r
+//         MY_ALLOC_STRUCT in memory.\r
+//\r
+// Buffer := Pointer to UINT32 aligned storage immediately following\r
+//           the NULL terminated __FILE__ string.  This is UINT32\r
+//           aligned because the underflow signature is 32-bits and\r
+//           this will place the first caller address on a 64-bit\r
+//           boundary.\r
+//\r
+//\r
+// Signatures used to check for buffer overflow/underflow conditions.\r
+//\r
+#define MYALLOC_HEAD_MAGIK  0xBADFACED\r
+#define MYALLOC_TAIL_MAGIK  0xDEADBEEF\r
+\r
+VOID\r
+MyCheck (\r
+  BOOLEAN      Final,\r
+  UINT8        File[],\r
+  UINTN        Line\r
+  )\r
+;\r
+//\r
+// *++\r
+// Description:\r
+//\r
+//  Check for corruptions in the allocated memory chain.  If a corruption\r
+//  is detection program operation stops w/ an exit(1) call.\r
+//\r
+// Parameters:\r
+//\r
+//  Final := When FALSE, MyCheck() returns if the allocated memory chain\r
+//           has not been corrupted.  When TRUE, MyCheck() returns if there\r
+//           are no un-freed allocations.  If there are un-freed allocations,\r
+//           they are displayed and exit(1) is called.\r
+//\r
+//\r
+//  File := Set to __FILE__ by macro expansion.\r
+//\r
+//  Line := Set to __LINE__ by macro expansion.\r
+//\r
+// Returns:\r
+//\r
+//  n/a\r
+//\r
+// --*/\r
+//\r
+VOID  *\r
+MyAlloc (\r
+  UINTN      Size,\r
+  UINT8      File[],\r
+  UINTN      Line\r
+  )\r
+;\r
+//\r
+// *++\r
+// Description:\r
+//\r
+//  Allocate a new link in the allocation chain along with enough storage\r
+//  for the File[] string, requested Size and alignment overhead.  If\r
+//  memory cannot be allocated or the allocation chain has been corrupted,\r
+//  exit(1) will be called.\r
+//\r
+// Parameters:\r
+//\r
+//  Size := Number of bytes (UINT8) requested by the called.\r
+//          Size cannot be zero.\r
+//\r
+//  File := Set to __FILE__ by macro expansion.\r
+//\r
+//  Line := Set to __LINE__ by macro expansion.\r
+//\r
+// Returns:\r
+//\r
+//  Pointer to the caller's buffer.\r
+//\r
+// --*/\r
+//\r
+VOID  *\r
+MyRealloc (\r
+  VOID       *Ptr,\r
+  UINTN      Size,\r
+  UINT8      File[],\r
+  UINTN      Line\r
+  )\r
+;\r
+//\r
+// *++\r
+// Description:\r
+//\r
+//  This does a MyAlloc(), memcpy() and MyFree().  There is no optimization\r
+//  for shrinking or expanding buffers.  An invalid parameter will cause\r
+//  MyRealloc() to fail with a call to exit(1).\r
+//\r
+// Parameters:\r
+//\r
+//  Ptr := Pointer to the caller's buffer to be re-allocated.\r
+//         Ptr cannot be NULL.\r
+//\r
+//  Size := Size of new buffer.  Size cannot be zero.\r
+//\r
+//  File := Set to __FILE__ by macro expansion.\r
+//\r
+//  Line := Set to __LINE__ by macro expansion.\r
+//\r
+// Returns:\r
+//\r
+//  Pointer to new caller's buffer.\r
+//\r
+// --*/\r
+//\r
+VOID\r
+MyFree (\r
+  VOID       *Ptr,\r
+  UINT8      File[],\r
+  UINTN      Line\r
+  )\r
+;\r
+//\r
+// *++\r
+// Description:\r
+//\r
+//  Release a previously allocated buffer.  Invalid parameters will cause\r
+//  MyFree() to fail with an exit(1) call.\r
+//\r
+// Parameters:\r
+//\r
+//  Ptr := Pointer to the caller's buffer to be freed.\r
+//         A NULL pointer will be ignored.\r
+//\r
+//  File := Set to __FILE__ by macro expansion.\r
+//\r
+//  Line := Set to __LINE__ by macro expansion.\r
+//\r
+// Returns:\r
+//\r
+//  n/a\r
+//\r
+// --*/\r
+//\r
+#else /* USE_MYALLOC */\r
+\r
+//\r
+// Nothing to do when USE_MYALLOC is zero.\r
+//\r
+#define alloc_check(final)\r
+\r
+#endif /* USE_MYALLOC */\r
+#endif /* _MYALLOC_H_ */\r
+\r
+/* eof - MyAlloc.h */\r
diff --git a/Tools/CodeTools/Source/Common/ParseInf.c b/Tools/CodeTools/Source/Common/ParseInf.c
new file mode 100644 (file)
index 0000000..de0ffd8
--- /dev/null
@@ -0,0 +1,630 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  ParseInf.c\r
+\r
+Abstract:\r
+\r
+  This contains some useful functions for parsing INF files.\r
+\r
+--*/\r
+\r
+#include <assert.h>\r
+#include <string.h>\r
+#include <ctype.h>\r
+#include <stdlib.h>\r
+#include "ParseInf.h"\r
+\r
+#ifndef _MAX_PATH\r
+#define _MAX_PATH 500\r
+#endif\r
+\r
+CHAR8 *\r
+ReadLine (\r
+  IN MEMORY_FILE    *InputFile,\r
+  IN OUT CHAR8      *InputBuffer,\r
+  IN UINTN          MaxLength\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function reads a line, stripping any comments.\r
+  The function reads a string from the input stream argument and stores it in \r
+  the input string. ReadLine reads characters from the current file position \r
+  to and including the first newline character, to the end of the stream, or \r
+  until the number of characters read is equal to MaxLength - 1, whichever \r
+  comes first.  The newline character, if read, is replaced with a \0. \r
+\r
+Arguments:\r
+\r
+  InputFile     Memory file image.\r
+  InputBuffer   Buffer to read into, must be _MAX_PATH size.\r
+  MaxLength     The maximum size of the input buffer.\r
+\r
+Returns:\r
+\r
+  NULL if error or EOF\r
+  InputBuffer otherwise\r
+\r
+--*/\r
+{\r
+  CHAR8 *CharPtr;\r
+  CHAR8 *EndOfLine;\r
+  UINTN CharsToCopy;\r
+\r
+  //\r
+  // Verify input parameters are not null\r
+  //\r
+  assert (InputBuffer);\r
+  assert (InputFile->FileImage);\r
+  assert (InputFile->Eof);\r
+  assert (InputFile->CurrentFilePointer);\r
+\r
+  //\r
+  // Check for end of file condition\r
+  //\r
+  if (InputFile->CurrentFilePointer >= InputFile->Eof) {\r
+    return NULL;\r
+  }\r
+  //\r
+  // Find the next newline char\r
+  //\r
+  EndOfLine = strchr (InputFile->CurrentFilePointer, '\n');\r
+\r
+  //\r
+  // Determine the number of characters to copy.\r
+  //\r
+  if (EndOfLine == 0) {\r
+    //\r
+    // If no newline found, copy to the end of the file.\r
+    //\r
+    CharsToCopy = InputFile->Eof - InputFile->CurrentFilePointer;\r
+  } else if (EndOfLine >= InputFile->Eof) {\r
+    //\r
+    // If the newline found was beyond the end of file, copy to the eof.\r
+    //\r
+    CharsToCopy = InputFile->Eof - InputFile->CurrentFilePointer;\r
+  } else {\r
+    //\r
+    // Newline found in the file.\r
+    //\r
+    CharsToCopy = EndOfLine - InputFile->CurrentFilePointer;\r
+  }\r
+  //\r
+  // If the end of line is too big for the current buffer, set it to the max\r
+  // size of the buffer (leaving room for the \0.\r
+  //\r
+  if (CharsToCopy > MaxLength - 1) {\r
+    CharsToCopy = MaxLength - 1;\r
+  }\r
+  //\r
+  // Copy the line.\r
+  //\r
+  memcpy (InputBuffer, InputFile->CurrentFilePointer, CharsToCopy);\r
+\r
+  //\r
+  // Add the null termination over the 0x0D\r
+  //\r
+  InputBuffer[CharsToCopy - 1] = '\0';\r
+\r
+  //\r
+  // Increment the current file pointer (include the 0x0A)\r
+  //\r
+  InputFile->CurrentFilePointer += CharsToCopy + 1;\r
+\r
+  //\r
+  // Strip any comments\r
+  //\r
+  CharPtr = strstr (InputBuffer, "//");\r
+  if (CharPtr != 0) {\r
+    CharPtr[0] = 0;\r
+  }\r
+  //\r
+  // Return the string\r
+  //\r
+  return InputBuffer;\r
+}\r
+\r
+BOOLEAN\r
+FindSection (\r
+  IN MEMORY_FILE    *InputFile,\r
+  IN CHAR8          *Section\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function parses a file from the beginning to find a section.\r
+  The section string may be anywhere within a line.\r
+\r
+Arguments:\r
+\r
+  InputFile     Memory file image.\r
+  Section       Section to search for\r
+\r
+Returns:\r
+\r
+  FALSE if error or EOF\r
+  TRUE if section found\r
+\r
+--*/\r
+{\r
+  CHAR8 InputBuffer[_MAX_PATH];\r
+  CHAR8 *CurrentToken;\r
+\r
+  //\r
+  // Verify input is not NULL\r
+  //\r
+  assert (InputFile->FileImage);\r
+  assert (InputFile->Eof);\r
+  assert (InputFile->CurrentFilePointer);\r
+  assert (Section);\r
+\r
+  //\r
+  // Rewind to beginning of file\r
+  //\r
+  InputFile->CurrentFilePointer = InputFile->FileImage;\r
+\r
+  //\r
+  // Read lines until the section is found\r
+  //\r
+  while (InputFile->CurrentFilePointer < InputFile->Eof) {\r
+    //\r
+    // Read a line\r
+    //\r
+    ReadLine (InputFile, InputBuffer, _MAX_PATH);\r
+\r
+    //\r
+    // Check if the section is found\r
+    //\r
+    CurrentToken = strstr (InputBuffer, Section);\r
+    if (CurrentToken != NULL) {\r
+      return TRUE;\r
+    }\r
+  }\r
+\r
+  return FALSE;\r
+}\r
+\r
+EFI_STATUS\r
+FindToken (\r
+  IN MEMORY_FILE    *InputFile,\r
+  IN CHAR8          *Section,\r
+  IN CHAR8          *Token,\r
+  IN UINTN          Instance,\r
+  OUT CHAR8         *Value\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Finds a token value given the section and token to search for.\r
+\r
+Arguments:\r
+\r
+  InputFile Memory file image.\r
+  Section   The section to search for, a string within [].\r
+  Token     The token to search for, e.g. EFI_PEIM_RECOVERY, followed by an = in the INF file.\r
+  Instance  The instance of the token to search for.  Zero is the first instance.\r
+  Value     The string that holds the value following the =.  Must be _MAX_PATH in size.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS             Value found.\r
+  EFI_ABORTED             Format error detected in INF file.\r
+  EFI_INVALID_PARAMETER   Input argument was null.\r
+  EFI_LOAD_ERROR          Error reading from the file.\r
+  EFI_NOT_FOUND           Section/Token/Value not found.\r
+\r
+--*/\r
+{\r
+  CHAR8   InputBuffer[_MAX_PATH];\r
+  CHAR8   *CurrentToken;\r
+  BOOLEAN ParseError;\r
+  BOOLEAN ReadError;\r
+  UINTN   Occurrance;\r
+\r
+  //\r
+  // Check input parameters\r
+  //\r
+  if (InputFile->FileImage == NULL ||\r
+      InputFile->Eof == NULL ||\r
+      InputFile->CurrentFilePointer == NULL ||\r
+      Section == NULL ||\r
+      strlen (Section) == 0 ||\r
+      Token == NULL ||\r
+      strlen (Token) == 0 ||\r
+      Value == NULL\r
+      ) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+  //\r
+  // Initialize error codes\r
+  //\r
+  ParseError  = FALSE;\r
+  ReadError   = FALSE;\r
+\r
+  //\r
+  // Initialize our instance counter for the search token\r
+  //\r
+  Occurrance = 0;\r
+\r
+  if (FindSection (InputFile, Section)) {\r
+    //\r
+    // Found the desired section, find and read the desired token\r
+    //\r
+    do {\r
+      //\r
+      // Read a line from the file\r
+      //\r
+      if (ReadLine (InputFile, InputBuffer, _MAX_PATH) == NULL) {\r
+        //\r
+        // Error reading from input file\r
+        //\r
+        ReadError = TRUE;\r
+        break;\r
+      }\r
+      //\r
+      // Get the first non-whitespace string\r
+      //\r
+      CurrentToken = strtok (InputBuffer, " \t\n");\r
+      if (CurrentToken == NULL) {\r
+        //\r
+        // Whitespace line found (or comment) so continue\r
+        //\r
+        CurrentToken = InputBuffer;\r
+        continue;\r
+      }\r
+      //\r
+      // Make sure we have not reached the end of the current section\r
+      //\r
+      if (CurrentToken[0] == '[') {\r
+        break;\r
+      }\r
+      //\r
+      // Compare the current token with the desired token\r
+      //\r
+      if (strcmp (CurrentToken, Token) == 0) {\r
+        //\r
+        // Found it\r
+        //\r
+        //\r
+        // Check if it is the correct instance\r
+        //\r
+        if (Instance == Occurrance) {\r
+          //\r
+          // Copy the contents following the =\r
+          //\r
+          CurrentToken = strtok (NULL, "= \t\n");\r
+          if (CurrentToken == NULL) {\r
+            //\r
+            // Nothing found, parsing error\r
+            //\r
+            ParseError = TRUE;\r
+          } else {\r
+            //\r
+            // Copy the current token to the output value\r
+            //\r
+            strcpy (Value, CurrentToken);\r
+            return EFI_SUCCESS;\r
+          }\r
+        } else {\r
+          //\r
+          // Increment the occurrance found\r
+          //\r
+          Occurrance++;\r
+        }\r
+      }\r
+    } while (\r
+      !ParseError &&\r
+      !ReadError &&\r
+      InputFile->CurrentFilePointer < InputFile->Eof &&\r
+      CurrentToken[0] != '[' &&\r
+      Occurrance <= Instance\r
+    );\r
+  }\r
+  //\r
+  // Distinguish between read errors and INF file format errors.\r
+  //\r
+  if (ReadError) {\r
+    return EFI_LOAD_ERROR;\r
+  }\r
+\r
+  if (ParseError) {\r
+    return EFI_ABORTED;\r
+  }\r
+\r
+  return EFI_NOT_FOUND;\r
+}\r
+\r
+EFI_STATUS\r
+StringToGuid (\r
+  IN CHAR8      *AsciiGuidBuffer,\r
+  OUT EFI_GUID  *GuidBuffer\r
+  )\r
+/*++\r
+\r
+Routine Description: \r
+\r
+  Converts a string to an EFI_GUID.  The string must be in the \r
+  xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx format.\r
+\r
+Arguments:  \r
+\r
+  AsciiGuidBuffer - pointer to ascii string\r
+  GuidBuffer      - pointer to destination Guid\r
+\r
+Returns:  \r
+\r
+  EFI_ABORTED             Could not convert the string\r
+  EFI_SUCCESS             The string was successfully converted\r
+  EFI_INVALID_PARAMETER   Input parameter is invalid.\r
+\r
+--*/\r
+{\r
+  INT32 Index;\r
+  UINTN Data1;\r
+  UINTN Data2;\r
+  UINTN Data3;\r
+  UINTN Data4[8];\r
+\r
+  if (AsciiGuidBuffer == NULL || GuidBuffer == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+  //\r
+  // Scan the guid string into the buffer\r
+  //\r
+  Index = sscanf (\r
+            AsciiGuidBuffer,\r
+            "%08x-%04x-%04x-%02x%02x-%02hx%02hx%02hx%02hx%02hx%02hx",\r
+            &Data1,\r
+            &Data2,\r
+            &Data3,\r
+            &Data4[0],\r
+            &Data4[1],\r
+            &Data4[2],\r
+            &Data4[3],\r
+            &Data4[4],\r
+            &Data4[5],\r
+            &Data4[6],\r
+            &Data4[7]\r
+            );\r
+\r
+  //\r
+  // Verify the correct number of items were scanned.\r
+  //\r
+  if (Index != 11) {\r
+    printf ("ERROR: Malformed GUID \"%s\".\n\n", AsciiGuidBuffer);\r
+    return EFI_ABORTED;\r
+  }\r
+  //\r
+  // Copy the data into our GUID.\r
+  //\r
+  GuidBuffer->Data1     = (UINT32) Data1;\r
+  GuidBuffer->Data2     = (UINT16) Data2;\r
+  GuidBuffer->Data3     = (UINT16) Data3;\r
+  GuidBuffer->Data4[0]  = (UINT8) Data4[0];\r
+  GuidBuffer->Data4[1]  = (UINT8) Data4[1];\r
+  GuidBuffer->Data4[2]  = (UINT8) Data4[2];\r
+  GuidBuffer->Data4[3]  = (UINT8) Data4[3];\r
+  GuidBuffer->Data4[4]  = (UINT8) Data4[4];\r
+  GuidBuffer->Data4[5]  = (UINT8) Data4[5];\r
+  GuidBuffer->Data4[6]  = (UINT8) Data4[6];\r
+  GuidBuffer->Data4[7]  = (UINT8) Data4[7];\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+AsciiStringToUint64 (\r
+  IN CONST CHAR8  *AsciiString,\r
+  IN BOOLEAN      IsHex,\r
+  OUT UINT64      *ReturnValue\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Converts a null terminated ascii string that represents a number into a \r
+  UINT64 value.  A hex number may be preceeded by a 0x, but may not be \r
+  succeeded by an h.  A number without 0x or 0X is considered to be base 10 \r
+  unless the IsHex input is true.\r
+\r
+Arguments:\r
+\r
+  AsciiString   The string to convert.\r
+  IsHex         Force the string to be treated as a hex number.\r
+  ReturnValue   The return value.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS   Number successfully converted.\r
+  EFI_ABORTED   Invalid character encountered.\r
+\r
+--*/\r
+{\r
+  UINT8   Index;\r
+  UINT64  HexNumber;\r
+  CHAR8   CurrentChar;\r
+\r
+  //\r
+  // Initialize the result\r
+  //\r
+  HexNumber = 0;\r
+\r
+  //\r
+  // Add each character to the result\r
+  //\r
+  if (IsHex || (AsciiString[0] == '0' && (AsciiString[1] == 'x' || AsciiString[1] == 'X'))) {\r
+    //\r
+    // Verify string is a hex number\r
+    //\r
+    for (Index = 2; Index < strlen (AsciiString); Index++) {\r
+      if (isxdigit (AsciiString[Index]) == 0) {\r
+        return EFI_ABORTED;\r
+      }\r
+    }\r
+    //\r
+    // Convert the hex string.\r
+    //\r
+    for (Index = 2; AsciiString[Index] != '\0'; Index++) {\r
+      CurrentChar = AsciiString[Index];\r
+      HexNumber *= 16;\r
+      if (CurrentChar >= '0' && CurrentChar <= '9') {\r
+        HexNumber += CurrentChar - '0';\r
+      } else if (CurrentChar >= 'a' && CurrentChar <= 'f') {\r
+        HexNumber += CurrentChar - 'a' + 10;\r
+      } else if (CurrentChar >= 'A' && CurrentChar <= 'F') {\r
+        HexNumber += CurrentChar - 'A' + 10;\r
+      } else {\r
+        //\r
+        // Unrecognized character\r
+        //\r
+        return EFI_ABORTED;\r
+      }\r
+    }\r
+\r
+    *ReturnValue = HexNumber;\r
+  } else {\r
+    //\r
+    // Verify string is a number\r
+    //\r
+    for (Index = 0; Index < strlen (AsciiString); Index++) {\r
+      if (isdigit (AsciiString[Index]) == 0) {\r
+        return EFI_ABORTED;\r
+      }\r
+    }\r
+\r
+    *ReturnValue = atol (AsciiString);\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+};\r
+\r
+CHAR8 *\r
+ReadLineInStream (\r
+  IN FILE       *InputFile,\r
+  IN OUT CHAR8  *InputBuffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function reads a line, stripping any comments.\r
+  // BUGBUG:  This is obsolete once genmake goes away...\r
+\r
+Arguments:\r
+\r
+  InputFile     Stream pointer.\r
+  InputBuffer   Buffer to read into, must be _MAX_PATH size.\r
+\r
+Returns:\r
+\r
+  NULL if error or EOF\r
+  InputBuffer otherwise\r
+\r
+--*/\r
+{\r
+  CHAR8 *CharPtr;\r
+\r
+  //\r
+  // Verify input parameters are not null\r
+  //\r
+  assert (InputFile);\r
+  assert (InputBuffer);\r
+\r
+  //\r
+  // Read a line\r
+  //\r
+  if (fgets (InputBuffer, _MAX_PATH, InputFile) == NULL) {\r
+    return NULL;\r
+  }\r
+  //\r
+  // Strip any comments\r
+  //\r
+  CharPtr = strstr (InputBuffer, "//");\r
+  if (CharPtr != 0) {\r
+    CharPtr[0] = 0;\r
+  }\r
+\r
+  CharPtr = strstr (InputBuffer, "#");\r
+  if (CharPtr != 0) {\r
+    CharPtr[0] = 0;\r
+  }\r
+  //\r
+  // Return the string\r
+  //\r
+  return InputBuffer;\r
+}\r
+\r
+BOOLEAN\r
+FindSectionInStream (\r
+  IN FILE       *InputFile,\r
+  IN CHAR8      *Section\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function parses a stream file from the beginning to find a section.\r
+  The section string may be anywhere within a line.\r
+  // BUGBUG:  This is obsolete once genmake goes away...\r
+\r
+Arguments:\r
+\r
+  InputFile     Stream pointer.\r
+  Section       Section to search for\r
+\r
+Returns:\r
+\r
+  FALSE if error or EOF\r
+  TRUE if section found\r
+\r
+--*/\r
+{\r
+  CHAR8 InputBuffer[_MAX_PATH];\r
+  CHAR8 *CurrentToken;\r
+\r
+  //\r
+  // Verify input is not NULL\r
+  //\r
+  assert (InputFile);\r
+  assert (Section);\r
+\r
+  //\r
+  // Rewind to beginning of file\r
+  //\r
+  if (fseek (InputFile, 0, SEEK_SET) != 0) {\r
+    return FALSE;\r
+  }\r
+  //\r
+  // Read lines until the section is found\r
+  //\r
+  while (feof (InputFile) == 0) {\r
+    //\r
+    // Read a line\r
+    //\r
+    ReadLineInStream (InputFile, InputBuffer);\r
+\r
+    //\r
+    // Check if the section is found\r
+    //\r
+    CurrentToken = strstr (InputBuffer, Section);\r
+    if (CurrentToken != NULL) {\r
+      return TRUE;\r
+    }\r
+  }\r
+\r
+  return FALSE;\r
+}\r
diff --git a/Tools/CodeTools/Source/Common/ParseInf.h b/Tools/CodeTools/Source/Common/ParseInf.h
new file mode 100644 (file)
index 0000000..ff98635
--- /dev/null
@@ -0,0 +1,234 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  ParseInf.h\r
+\r
+Abstract:\r
+\r
+  Header file for helper functions useful for parsing INF files.\r
+\r
+--*/\r
+\r
+#ifndef _EFI_PARSE_INF_H\r
+#define _EFI_PARSE_INF_H\r
+\r
+#include <stdio.h>\r
+#include <stdlib.h>\r
+\r
+#include <Common/UefiBaseTypes.h>\r
+\r
+//\r
+// Common data structures\r
+//\r
+typedef struct {\r
+  CHAR8 *FileImage;\r
+  CHAR8 *Eof;\r
+  CHAR8 *CurrentFilePointer;\r
+} MEMORY_FILE;\r
+\r
+//\r
+// Functions declarations\r
+//\r
+CHAR8 *\r
+ReadLine (\r
+  IN MEMORY_FILE    *InputFile,\r
+  IN OUT CHAR8      *InputBuffer,\r
+  IN UINTN          MaxLength\r
+  )\r
+;\r
+\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function reads a line, stripping any comments.\r
+  The function reads a string from the input stream argument and stores it in \r
+  the input string. ReadLine reads characters from the current file position \r
+  to and including the first newline character, to the end of the stream, or \r
+  until the number of characters read is equal to MaxLength - 1, whichever \r
+  comes first.  The newline character, if read, is replaced with a \0. \r
+\r
+Arguments:\r
+\r
+  InputFile     Memory file image.\r
+  InputBuffer   Buffer to read into, must be _MAX_PATH size.\r
+  MaxLength     The maximum size of the input buffer.\r
+\r
+Returns:\r
+\r
+  NULL if error or EOF\r
+  InputBuffer otherwise\r
+\r
+--*/\r
+BOOLEAN\r
+FindSection (\r
+  IN MEMORY_FILE    *InputFile,\r
+  IN CHAR8          *Section\r
+  )\r
+;\r
+\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function parses a file from the beginning to find a section.\r
+  The section string may be anywhere within a line.\r
+\r
+Arguments:\r
+\r
+  InputFile     Memory file image.\r
+  Section       Section to search for\r
+\r
+Returns:\r
+\r
+  FALSE if error or EOF\r
+  TRUE if section found\r
+\r
+--*/\r
+EFI_STATUS\r
+FindToken (\r
+  IN MEMORY_FILE    *InputFile,\r
+  IN CHAR8          *Section,\r
+  IN CHAR8          *Token,\r
+  IN UINTN          Instance,\r
+  OUT CHAR8         *Value\r
+  )\r
+;\r
+\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Finds a token value given the section and token to search for.\r
+\r
+Arguments:\r
+\r
+  InputFile Memory file image.\r
+  Section   The section to search for, a string within [].\r
+  Token     The token to search for, e.g. EFI_PEIM_RECOVERY, followed by an = in the INF file.\r
+  Instance  The instance of the token to search for.  Zero is the first instance.\r
+  Value     The string that holds the value following the =.  Must be _MAX_PATH in size.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS             Value found.\r
+  EFI_ABORTED             Format error detected in INF file.\r
+  EFI_INVALID_PARAMETER   Input argument was null.\r
+  EFI_LOAD_ERROR          Error reading from the file.\r
+  EFI_NOT_FOUND           Section/Token/Value not found.\r
+\r
+--*/\r
+EFI_STATUS\r
+StringToGuid (\r
+  IN CHAR8        *AsciiGuidBuffer,\r
+  OUT EFI_GUID    *GuidBuffer\r
+  )\r
+;\r
+\r
+/*++\r
+\r
+Routine Description: \r
+\r
+  Converts a string to an EFI_GUID.  The string must be in the \r
+  xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx format.\r
+\r
+Arguments:  \r
+\r
+  GuidBuffer      - pointer to destination Guid\r
+  AsciiGuidBuffer - pointer to ascii string\r
+\r
+Returns:  \r
+\r
+  EFI_ABORTED    Could not convert the string\r
+  EFI_SUCCESS    The string was successfully converted\r
+\r
+--*/\r
+EFI_STATUS\r
+AsciiStringToUint64 (\r
+  IN CONST CHAR8  *AsciiString,\r
+  IN BOOLEAN      IsHex,\r
+  OUT UINT64      *ReturnValue\r
+  )\r
+;\r
+\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Converts a null terminated ascii string that represents a number into a \r
+  UINT64 value.  A hex number may be preceeded by a 0x, but may not be \r
+  succeeded by an h.  A number without 0x or 0X is considered to be base 10 \r
+  unless the IsHex input is true.\r
+\r
+Arguments:\r
+\r
+  AsciiString   The string to convert.\r
+  IsHex         Force the string to be treated as a hex number.\r
+  ReturnValue   The return value.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS   Number successfully converted.\r
+  EFI_ABORTED   Invalid character encountered.\r
+\r
+--*/\r
+CHAR8 *\r
+ReadLineInStream (\r
+  IN FILE       *InputFile,\r
+  IN OUT CHAR8  *InputBuffer\r
+  )\r
+;\r
+\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function reads a line, stripping any comments.\r
+\r
+Arguments:\r
+\r
+  InputFile     Stream pointer.\r
+  InputBuffer   Buffer to read into, must be _MAX_PATH size.\r
+\r
+Returns:\r
+\r
+  NULL if error or EOF\r
+  InputBuffer otherwise\r
+\r
+--*/\r
+BOOLEAN\r
+FindSectionInStream (\r
+  IN FILE       *InputFile,\r
+  IN CHAR8      *Section\r
+  )\r
+;\r
+\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function parses a stream file from the beginning to find a section.\r
+  The section string may be anywhere within a line.\r
+\r
+Arguments:\r
+\r
+  InputFile     Stream pointer.\r
+  Section       Section to search for\r
+\r
+Returns:\r
+\r
+  FALSE if error or EOF\r
+  TRUE if section found\r
+\r
+--*/\r
+#endif\r
diff --git a/Tools/CodeTools/Source/Common/SimpleFileParsing.c b/Tools/CodeTools/Source/Common/SimpleFileParsing.c
new file mode 100644 (file)
index 0000000..73b74cd
--- /dev/null
@@ -0,0 +1,1457 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  SimpleFileParsing.c  \r
+\r
+Abstract:\r
+\r
+  Generic but simple file parsing routines.\r
+\r
+--*/\r
+\r
+#include <stdio.h>\r
+#include <string.h>\r
+#include <stdlib.h>\r
+#include <ctype.h>\r
+\r
+#include "EfiUtilityMsgs.h"\r
+#include "SimpleFileParsing.h"\r
+\r
+#ifndef MAX_PATH\r
+#define MAX_PATH  255\r
+#endif\r
+//\r
+// just in case we get in an endless loop.\r
+//\r
+#define MAX_NEST_DEPTH  20\r
+//\r
+// number of wchars\r
+//\r
+#define MAX_STRING_IDENTIFIER_NAME  100\r
+\r
+#define MAX_LINE_LEN                400\r
+\r
+#define T_CHAR_SPACE                ' '\r
+#define T_CHAR_NULL                 0\r
+#define T_CHAR_CR                   '\r'\r
+#define T_CHAR_TAB                  '\t'\r
+#define T_CHAR_LF                   '\n'\r
+#define T_CHAR_SLASH                '/'\r
+#define T_CHAR_BACKSLASH            '\\'\r
+#define T_CHAR_DOUBLE_QUOTE         '"'\r
+#define T_CHAR_LC_X                 'x'\r
+#define T_CHAR_0                    '0'\r
+#define T_CHAR_STAR                 '*'\r
+\r
+//\r
+// We keep a linked list of these for the source files we process\r
+//\r
+typedef struct _SOURCE_FILE {\r
+  FILE                *Fptr;\r
+  T_CHAR              *FileBuffer;\r
+  T_CHAR              *FileBufferPtr;\r
+  unsigned int        FileSize;\r
+  char                FileName[MAX_PATH];\r
+  unsigned int        LineNum;\r
+  BOOLEAN             EndOfFile;\r
+  BOOLEAN             SkipToHash;\r
+  struct _SOURCE_FILE *Previous;\r
+  struct _SOURCE_FILE *Next;\r
+  T_CHAR              ControlCharacter;\r
+} SOURCE_FILE;\r
+\r
+typedef struct {\r
+  T_CHAR  *FileBufferPtr;\r
+} FILE_POSITION;\r
+\r
+//\r
+// Keep all our module globals in this structure\r
+//\r
+static struct {\r
+  SOURCE_FILE SourceFile;\r
+  BOOLEAN     VerboseFile;\r
+  BOOLEAN     VerboseToken;\r
+} mGlobals;\r
+\r
+static\r
+unsigned int\r
+t_strcmp (\r
+  T_CHAR *Buffer,\r
+  T_CHAR *Str\r
+  );\r
+\r
+static\r
+unsigned int\r
+t_strncmp (\r
+  T_CHAR *Str1,\r
+  T_CHAR *Str2,\r
+  int    Len\r
+  );\r
+\r
+static\r
+unsigned int\r
+t_strlen (\r
+  T_CHAR *Str\r
+  );\r
+\r
+static\r
+void\r
+RewindFile (\r
+  SOURCE_FILE *SourceFile\r
+  );\r
+\r
+static\r
+BOOLEAN\r
+IsWhiteSpace (\r
+  SOURCE_FILE *SourceFile\r
+  );\r
+\r
+static\r
+unsigned int\r
+SkipWhiteSpace (\r
+  SOURCE_FILE *SourceFile\r
+  );\r
+\r
+static\r
+BOOLEAN\r
+EndOfFile (\r
+  SOURCE_FILE *SourceFile\r
+  );\r
+\r
+static\r
+void\r
+PreprocessFile (\r
+  SOURCE_FILE *SourceFile\r
+  );\r
+\r
+static\r
+T_CHAR  *\r
+t_strcpy (\r
+  T_CHAR *Dest,\r
+  T_CHAR *Src\r
+  );\r
+\r
+static\r
+STATUS\r
+ProcessIncludeFile (\r
+  SOURCE_FILE *SourceFile,\r
+  SOURCE_FILE *ParentSourceFile\r
+  );\r
+\r
+static\r
+STATUS\r
+ParseFile (\r
+  SOURCE_FILE *SourceFile\r
+  );\r
+\r
+static\r
+FILE    *\r
+FindFile (\r
+  char          *FileName,\r
+  char          *FoundFileName,\r
+  unsigned int  FoundFileNameLen\r
+  );\r
+\r
+static\r
+STATUS\r
+ProcessFile (\r
+  SOURCE_FILE *SourceFile\r
+  );\r
+\r
+static\r
+STATUS\r
+GetFilePosition (\r
+  FILE_POSITION *Fpos\r
+  );\r
+\r
+static\r
+STATUS\r
+SetFilePosition (\r
+  FILE_POSITION *Fpos\r
+  );\r
+\r
+STATUS\r
+SFPInit (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+Arguments:\r
+  None.\r
+\r
+Returns:\r
+  STATUS_SUCCESS always\r
+\r
+--*/\r
+{\r
+  memset ((void *) &mGlobals, 0, sizeof (mGlobals));\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+unsigned\r
+int\r
+SFPGetLineNumber (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Return the line number of the file we're parsing. Used\r
+  for error reporting purposes.\r
+\r
+Arguments:\r
+  None.\r
+\r
+Returns:\r
+  The line number, or 0 if no file is being processed\r
+\r
+--*/\r
+{\r
+  return mGlobals.SourceFile.LineNum;\r
+}\r
+\r
+T_CHAR *\r
+SFPGetFileName (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Return the name of the file we're parsing. Used\r
+  for error reporting purposes.\r
+\r
+Arguments:\r
+  None.\r
+\r
+Returns:\r
+  A pointer to the file name. Null if no file is being\r
+  processed.\r
+\r
+--*/\r
+{\r
+  if (mGlobals.SourceFile.FileName[0]) {\r
+    return mGlobals.SourceFile.FileName;\r
+  }\r
+\r
+  return NULL;\r
+}\r
+\r
+STATUS\r
+SFPOpenFile (\r
+  char      *FileName\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Open a file for parsing.\r
+\r
+Arguments:\r
+  FileName  - name of the file to parse\r
+\r
+Returns:\r
+  \r
+\r
+--*/\r
+{\r
+  STATUS  Status;\r
+  t_strcpy (mGlobals.SourceFile.FileName, FileName);\r
+  Status = ProcessIncludeFile (&mGlobals.SourceFile, NULL);\r
+  return Status;\r
+}\r
+\r
+BOOLEAN\r
+SFPIsToken (\r
+  T_CHAR *Str\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Check to see if the specified token is found at\r
+  the current position in the input file.\r
+\r
+Arguments:\r
+  Str - the token to look for\r
+\r
+Returns:\r
+  TRUE - the token is next\r
+  FALSE - the token is not next\r
+\r
+Notes:\r
+  We do a simple string comparison on this function. It is\r
+  the responsibility of the caller to ensure that the token\r
+  is not a subset of some other token.\r
+\r
+  The file pointer is advanced past the token in the input file.\r
+\r
+--*/\r
+{\r
+  unsigned int  Len;\r
+  SkipWhiteSpace (&mGlobals.SourceFile);\r
+  if (EndOfFile (&mGlobals.SourceFile)) {\r
+    return FALSE;\r
+  }\r
+\r
+  if ((Len = t_strcmp (mGlobals.SourceFile.FileBufferPtr, Str)) > 0) {\r
+    mGlobals.SourceFile.FileBufferPtr += Len;\r
+    if (mGlobals.VerboseToken) {\r
+      printf ("Token: '%s'\n", Str);\r
+    }\r
+\r
+    return TRUE;\r
+  }\r
+\r
+  return FALSE;\r
+}\r
+\r
+BOOLEAN\r
+SFPIsKeyword (\r
+  T_CHAR *Str\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Check to see if the specified keyword is found at\r
+  the current position in the input file.\r
+\r
+Arguments:\r
+  Str - keyword to look for\r
+\r
+Returns:\r
+  TRUE - the keyword is next\r
+  FALSE - the keyword is not next\r
+\r
+Notes:\r
+  A keyword is defined as a "special" string that has a non-alphanumeric\r
+  character following it.\r
+\r
+--*/\r
+{\r
+  unsigned int  Len;\r
+  SkipWhiteSpace (&mGlobals.SourceFile);\r
+  if (EndOfFile (&mGlobals.SourceFile)) {\r
+    return FALSE;\r
+  }\r
+\r
+  if ((Len = t_strcmp (mGlobals.SourceFile.FileBufferPtr, Str)) > 0) {\r
+    if (isalnum (mGlobals.SourceFile.FileBufferPtr[Len])) {\r
+      return FALSE;\r
+    }\r
+\r
+    mGlobals.SourceFile.FileBufferPtr += Len;\r
+    if (mGlobals.VerboseToken) {\r
+      printf ("Token: '%s'\n", Str);\r
+    }\r
+\r
+    return TRUE;\r
+  }\r
+\r
+  return FALSE;\r
+}\r
+\r
+BOOLEAN\r
+SFPGetNextToken (\r
+  T_CHAR        *Str,\r
+  unsigned int  Len\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Get the next token from the input stream. \r
+\r
+Arguments:\r
+  Str - pointer to a copy of the next token\r
+  Len - size of buffer pointed to by Str\r
+\r
+Returns:\r
+  TRUE  - next token successfully returned\r
+  FALSE - otherwise\r
+\r
+Notes:\r
+  Preceeding white space is ignored. \r
+  The parser's buffer pointer is advanced past the end of the\r
+  token.\r
+\r
+--*/\r
+{\r
+  unsigned int  Index;\r
+  T_CHAR        TempChar;\r
+\r
+  SkipWhiteSpace (&mGlobals.SourceFile);\r
+  if (EndOfFile (&mGlobals.SourceFile)) {\r
+    return FALSE;\r
+  }\r
+  //\r
+  // Have to have enough string for at least one char and a null-terminator\r
+  //\r
+  if (Len < 2) {\r
+    return FALSE;\r
+  }\r
+  //\r
+  // Look at the first character. If it's an identifier, then treat it\r
+  // as such\r
+  //\r
+  TempChar = mGlobals.SourceFile.FileBufferPtr[0];\r
+  if (((TempChar >= 'a') && (TempChar <= 'z')) || ((TempChar >= 'A') && (TempChar <= 'Z')) || (TempChar == '_')) {\r
+    Str[0] = TempChar;\r
+    mGlobals.SourceFile.FileBufferPtr++;\r
+    Index = 1;\r
+    while (!EndOfFile (&mGlobals.SourceFile) && (Index < Len)) {\r
+      TempChar = mGlobals.SourceFile.FileBufferPtr[0];\r
+      if (((TempChar >= 'a') && (TempChar <= 'z')) ||\r
+          ((TempChar >= 'A') && (TempChar <= 'Z')) ||\r
+          ((TempChar >= '0') && (TempChar <= '9')) ||\r
+          (TempChar == '_')\r
+          ) {\r
+        Str[Index] = mGlobals.SourceFile.FileBufferPtr[0];\r
+        mGlobals.SourceFile.FileBufferPtr++;\r
+        Index++;\r
+      } else {\r
+        //\r
+        // Invalid character for symbol name, so break out\r
+        //\r
+        break;\r
+      }\r
+    }\r
+    //\r
+    // Null terminate and return success\r
+    //\r
+    Str[Index] = 0;\r
+    return TRUE;\r
+  } else if ((TempChar == ')') || (TempChar == '(') || (TempChar == '*')) {\r
+    Str[0] = mGlobals.SourceFile.FileBufferPtr[0];\r
+    mGlobals.SourceFile.FileBufferPtr++;\r
+    Str[1] = 0;\r
+    return TRUE;\r
+  } else {\r
+    //\r
+    // Everything else is white-space (or EOF) separated\r
+    //\r
+    Index = 0;\r
+    while (!EndOfFile (&mGlobals.SourceFile) && (Index < Len)) {\r
+      if (IsWhiteSpace (&mGlobals.SourceFile)) {\r
+        if (Index > 0) {\r
+          Str[Index] = 0;\r
+          return TRUE;\r
+        }\r
+\r
+        return FALSE;\r
+      } else {\r
+        Str[Index] = mGlobals.SourceFile.FileBufferPtr[0];\r
+        mGlobals.SourceFile.FileBufferPtr++;\r
+        Index++;\r
+      }\r
+    }\r
+    //\r
+    // See if we just ran out of file contents, but did find a token\r
+    //\r
+    if ((Index > 0) && EndOfFile (&mGlobals.SourceFile)) {\r
+      Str[Index] = 0;\r
+      return TRUE;\r
+    }\r
+  }\r
+\r
+  return FALSE;\r
+}\r
+\r
+BOOLEAN\r
+SFPGetGuidToken (\r
+  T_CHAR *Str,\r
+  UINT32 Len\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Parse a GUID from the input stream. Stop when you discover white space.\r
+\r
+Arguments:\r
+  Str - pointer to a copy of the next token\r
+  Len - size of buffer pointed to by Str\r
+\r
+Returns:\r
+  TRUE  - GUID string returned successfully\r
+  FALSE - otherwise\r
+\r
+--*/\r
+{\r
+  UINT32  Index;\r
+  SkipWhiteSpace (&mGlobals.SourceFile);\r
+  if (EndOfFile (&mGlobals.SourceFile)) {\r
+    return FALSE;\r
+  }\r
+\r
+  Index = 0;\r
+  while (!EndOfFile (&mGlobals.SourceFile) && (Index < Len)) {\r
+    if (IsWhiteSpace (&mGlobals.SourceFile)) {\r
+      if (Index > 0) {\r
+        Str[Index] = 0;\r
+        return TRUE;\r
+      }\r
+\r
+      return FALSE;\r
+    } else {\r
+      Str[Index] = mGlobals.SourceFile.FileBufferPtr[0];\r
+      mGlobals.SourceFile.FileBufferPtr++;\r
+      Index++;\r
+    }\r
+  }\r
+\r
+  return FALSE;\r
+}\r
+\r
+BOOLEAN\r
+SFPSkipToToken (\r
+  T_CHAR *Str\r
+  )\r
+{\r
+  unsigned int  Len;\r
+  T_CHAR        *SavePos;\r
+  Len     = t_strlen (Str);\r
+  SavePos = mGlobals.SourceFile.FileBufferPtr;\r
+  SkipWhiteSpace (&mGlobals.SourceFile);\r
+  while (!EndOfFile (&mGlobals.SourceFile)) {\r
+    if (t_strncmp (Str, mGlobals.SourceFile.FileBufferPtr, Len) == 0) {\r
+      mGlobals.SourceFile.FileBufferPtr += Len;\r
+      return TRUE;\r
+    }\r
+\r
+    mGlobals.SourceFile.FileBufferPtr++;\r
+    SkipWhiteSpace (&mGlobals.SourceFile);\r
+  }\r
+\r
+  mGlobals.SourceFile.FileBufferPtr = SavePos;\r
+  return FALSE;\r
+}\r
+\r
+BOOLEAN\r
+SFPGetNumber (\r
+  unsigned int *Value\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Check the token at the current file position for a numeric value.\r
+  May be either decimal or hex.\r
+\r
+Arguments:\r
+  Value  - pointer where to store the value\r
+\r
+Returns:\r
+  FALSE    - current token is not a number\r
+  TRUE     - current token is a number\r
+\r
+--*/\r
+{\r
+  SkipWhiteSpace (&mGlobals.SourceFile);\r
+  if (EndOfFile (&mGlobals.SourceFile)) {\r
+    return FALSE;\r
+  }\r
+\r
+  if (isdigit (mGlobals.SourceFile.FileBufferPtr[0])) {\r
+    //\r
+    // Check for hex value\r
+    //\r
+    if ((mGlobals.SourceFile.FileBufferPtr[0] == T_CHAR_0) && (mGlobals.SourceFile.FileBufferPtr[1] == T_CHAR_LC_X)) {\r
+      if (!isxdigit (mGlobals.SourceFile.FileBufferPtr[2])) {\r
+        return FALSE;\r
+      }\r
+\r
+      mGlobals.SourceFile.FileBufferPtr += 2;\r
+      sscanf (mGlobals.SourceFile.FileBufferPtr, "%x", Value);\r
+      while (isxdigit (mGlobals.SourceFile.FileBufferPtr[0])) {\r
+        mGlobals.SourceFile.FileBufferPtr++;\r
+      }\r
+\r
+      return TRUE;\r
+    } else {\r
+      *Value = atoi (mGlobals.SourceFile.FileBufferPtr);\r
+      while (isdigit (mGlobals.SourceFile.FileBufferPtr[0])) {\r
+        mGlobals.SourceFile.FileBufferPtr++;\r
+      }\r
+\r
+      return TRUE;\r
+    }\r
+  } else {\r
+    return FALSE;\r
+  }\r
+}\r
+\r
+STATUS\r
+SFPCloseFile (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Close the file being parsed.\r
+\r
+Arguments:\r
+  None.\r
+\r
+Returns:\r
+  STATUS_SUCCESS - the file was closed \r
+  STATUS_ERROR   - no file is currently open\r
+\r
+--*/\r
+{\r
+  if (mGlobals.SourceFile.FileBuffer != NULL) {\r
+    free (mGlobals.SourceFile.FileBuffer);\r
+    memset (&mGlobals.SourceFile, 0, sizeof (mGlobals.SourceFile));\r
+    return STATUS_SUCCESS;\r
+  }\r
+\r
+  return STATUS_ERROR;\r
+}\r
+\r
+static\r
+STATUS\r
+ProcessIncludeFile (\r
+  SOURCE_FILE *SourceFile,\r
+  SOURCE_FILE *ParentSourceFile\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Given a source file, open the file and parse it\r
+  \r
+Arguments:\r
+\r
+  SourceFile        - name of file to parse\r
+  ParentSourceFile  - for error reporting purposes, the file that #included SourceFile.\r
+\r
+Returns:\r
+\r
+  Standard status.\r
+  \r
+--*/\r
+{\r
+  static unsigned int NestDepth = 0;\r
+  char                FoundFileName[MAX_PATH];\r
+  STATUS              Status;\r
+\r
+  Status = STATUS_SUCCESS;\r
+  NestDepth++;\r
+  //\r
+  // Print the file being processed. Indent so you can tell the include nesting\r
+  // depth.\r
+  //\r
+  if (mGlobals.VerboseFile) {\r
+    fprintf (stdout, "%*cProcessing file '%s'\n", NestDepth * 2, ' ', SourceFile->FileName);\r
+    fprintf (stdout, "Parent source file = '%s'\n", ParentSourceFile);\r
+  }\r
+\r
+  //\r
+  // Make sure we didn't exceed our maximum nesting depth\r
+  //\r
+  if (NestDepth > MAX_NEST_DEPTH) {\r
+    Error (NULL, 0, 0, SourceFile->FileName, "max nesting depth (%d) exceeded", NestDepth);\r
+    Status = STATUS_ERROR;\r
+    goto Finish;\r
+  }\r
+  //\r
+  // Try to open the file locally, and if that fails try along our include paths.\r
+  //\r
+  strcpy (FoundFileName, SourceFile->FileName);\r
+  if ((SourceFile->Fptr = fopen (FoundFileName, "rb")) == NULL) {\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Process the file found\r
+  //\r
+  ProcessFile (SourceFile);\r
+Finish:\r
+  //\r
+  // Close open files and return status\r
+  //\r
+  if (SourceFile->Fptr != NULL) {\r
+    fclose (SourceFile->Fptr);\r
+    SourceFile->Fptr = NULL;\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
+static\r
+STATUS\r
+ProcessFile (\r
+  SOURCE_FILE *SourceFile\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Given a source file that's been opened, read the contents into an internal\r
+  buffer and pre-process it to remove comments.\r
+  \r
+Arguments:\r
+\r
+  SourceFile        - structure containing info on the file to process\r
+\r
+Returns:\r
+\r
+  Standard status.\r
+  \r
+--*/\r
+{\r
+  //\r
+  // Get the file size, and then read the entire thing into memory.\r
+  // Allocate extra space for a terminator character.\r
+  //\r
+  fseek (SourceFile->Fptr, 0, SEEK_END);\r
+  SourceFile->FileSize = ftell (SourceFile->Fptr);\r
+  if (mGlobals.VerboseFile) {\r
+    printf ("FileSize = %d (0x%X)\n", SourceFile->FileSize, SourceFile->FileSize);\r
+  }\r
+\r
+  fseek (SourceFile->Fptr, 0, SEEK_SET);\r
+  SourceFile->FileBuffer = (T_CHAR *) malloc (SourceFile->FileSize + sizeof (T_CHAR));\r
+  if (SourceFile->FileBuffer == NULL) {\r
+    Error (NULL, 0, 0, "memory allocation failure", NULL);\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  fread ((void *) SourceFile->FileBuffer, SourceFile->FileSize, 1, SourceFile->Fptr);\r
+  SourceFile->FileBuffer[(SourceFile->FileSize / sizeof (T_CHAR))] = T_CHAR_NULL;\r
+  //\r
+  // Pre-process the file to replace comments with spaces\r
+  //\r
+  PreprocessFile (SourceFile);\r
+  SourceFile->LineNum = 1;\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+void\r
+PreprocessFile (\r
+  SOURCE_FILE *SourceFile\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Preprocess a file to replace all carriage returns with NULLs so\r
+  we can print lines (as part of error messages) from the file to the screen.\r
+  \r
+Arguments:\r
+  SourceFile - structure that we use to keep track of an input file.\r
+\r
+Returns:\r
+  Nothing.\r
+  \r
+--*/\r
+{\r
+  BOOLEAN InComment;\r
+  BOOLEAN SlashSlashComment;\r
+  int     LineNum;\r
+\r
+  RewindFile (SourceFile);\r
+  InComment         = FALSE;\r
+  SlashSlashComment = FALSE;\r
+  while (!EndOfFile (SourceFile)) {\r
+    //\r
+    // If a line-feed, then no longer in a comment if we're in a // comment\r
+    //\r
+    if (SourceFile->FileBufferPtr[0] == T_CHAR_LF) {\r
+      SourceFile->FileBufferPtr++;\r
+      SourceFile->LineNum++;\r
+      if (InComment && SlashSlashComment) {\r
+        InComment         = FALSE;\r
+        SlashSlashComment = FALSE;\r
+      }\r
+    } else if (SourceFile->FileBufferPtr[0] == T_CHAR_CR) {\r
+      //\r
+      // Replace all carriage returns with a NULL so we can print stuff\r
+      //\r
+      SourceFile->FileBufferPtr[0] = 0;\r
+      SourceFile->FileBufferPtr++;\r
+      //\r
+      // Check for */ comment end\r
+      //\r
+    } else if (InComment &&\r
+             !SlashSlashComment &&\r
+             (SourceFile->FileBufferPtr[0] == T_CHAR_STAR) &&\r
+             (SourceFile->FileBufferPtr[1] == T_CHAR_SLASH)\r
+            ) {\r
+      SourceFile->FileBufferPtr[0] = T_CHAR_SPACE;\r
+      SourceFile->FileBufferPtr++;\r
+      SourceFile->FileBufferPtr[0] = T_CHAR_SPACE;\r
+      SourceFile->FileBufferPtr++;\r
+      InComment = FALSE;\r
+    } else if (InComment) {\r
+      SourceFile->FileBufferPtr[0] = T_CHAR_SPACE;\r
+      SourceFile->FileBufferPtr++;\r
+      //\r
+      // Check for // comments\r
+      //\r
+    } else if ((SourceFile->FileBufferPtr[0] == T_CHAR_SLASH) && (SourceFile->FileBufferPtr[1] == T_CHAR_SLASH)) {\r
+      InComment         = TRUE;\r
+      SlashSlashComment = TRUE;\r
+      //\r
+      // Check for /* comment start\r
+      //\r
+    } else if ((SourceFile->FileBufferPtr[0] == T_CHAR_SLASH) && (SourceFile->FileBufferPtr[1] == T_CHAR_STAR)) {\r
+      SourceFile->FileBufferPtr[0] = T_CHAR_SPACE;\r
+      SourceFile->FileBufferPtr++;\r
+      SourceFile->FileBufferPtr[0] = T_CHAR_SPACE;\r
+      SourceFile->FileBufferPtr++;\r
+      SlashSlashComment = FALSE;\r
+      InComment         = TRUE;\r
+    } else {\r
+      SourceFile->FileBufferPtr++;\r
+    }\r
+  }\r
+  //\r
+  // Could check for end-of-file and still in a comment, but\r
+  // should not be necessary. So just restore the file pointers.\r
+  //\r
+  RewindFile (SourceFile);\r
+  //\r
+  // Dump the reformatted file if verbose mode\r
+  //\r
+  if (mGlobals.VerboseFile) {\r
+    LineNum = 1;\r
+    printf ("%04d: ", LineNum);\r
+    while (!EndOfFile (SourceFile)) {\r
+      if (SourceFile->FileBufferPtr[0] == T_CHAR_LF) {\r
+        printf ("'\n%04d: '", ++LineNum);\r
+      } else {\r
+        printf ("%c", SourceFile->FileBufferPtr[0]);\r
+      }\r
+\r
+      SourceFile->FileBufferPtr++;\r
+    }\r
+\r
+    printf ("'\n");\r
+    printf ("FileSize = %d (0x%X)\n", SourceFile->FileSize, SourceFile->FileSize);\r
+    RewindFile (SourceFile);\r
+  }\r
+}\r
+\r
+BOOLEAN\r
+SFPGetQuotedString (\r
+  T_CHAR      *Str,\r
+  int         Length\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Retrieve a quoted-string from the input file. \r
+  \r
+Arguments:\r
+  Str    - pointer to a copy of the quoted string parsed\r
+  Length - size of buffer pointed to by Str\r
+\r
+Returns:\r
+  TRUE    - next token in input stream was a quoted string, and\r
+            the string value was returned in Str\r
+  FALSE   - otherwise\r
+  \r
+--*/\r
+{\r
+  SkipWhiteSpace (&mGlobals.SourceFile);\r
+  if (EndOfFile (&mGlobals.SourceFile)) {\r
+    return FALSE;\r
+  }\r
+\r
+  if (mGlobals.SourceFile.FileBufferPtr[0] == T_CHAR_DOUBLE_QUOTE) {\r
+    mGlobals.SourceFile.FileBufferPtr++;\r
+    while (Length > 0) {\r
+      if (EndOfFile (&mGlobals.SourceFile)) {\r
+        return FALSE;\r
+      }\r
+      //\r
+      // Check for closing quote\r
+      //\r
+      if (mGlobals.SourceFile.FileBufferPtr[0] == T_CHAR_DOUBLE_QUOTE) {\r
+        mGlobals.SourceFile.FileBufferPtr++;\r
+        *Str = 0;\r
+        return TRUE;\r
+      }\r
+\r
+      *Str = mGlobals.SourceFile.FileBufferPtr[0];\r
+      Str++;\r
+      Length--;\r
+      mGlobals.SourceFile.FileBufferPtr++;\r
+    }\r
+  }\r
+  //\r
+  // First character was not a quote, or the input string length was\r
+  // insufficient to contain the quoted string, so return failure code.\r
+  //\r
+  return FALSE;\r
+}\r
+\r
+BOOLEAN\r
+SFPIsEOF (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Return TRUE of FALSE to indicate whether or not we've reached the end of the\r
+  file we're parsing.\r
+  \r
+Arguments:\r
+  NA\r
+\r
+Returns:\r
+  TRUE    - EOF reached\r
+  FALSE   - otherwise\r
+  \r
+--*/\r
+{\r
+  SkipWhiteSpace (&mGlobals.SourceFile);\r
+  return EndOfFile (&mGlobals.SourceFile);\r
+}\r
+\r
+#if 0\r
+static\r
+T_CHAR *\r
+GetQuotedString (\r
+  SOURCE_FILE *SourceFile,\r
+  BOOLEAN     Optional\r
+  )\r
+{\r
+  T_CHAR        *String;\r
+  T_CHAR        *Start;\r
+  T_CHAR        *Ptr;\r
+  unsigned int  Len;\r
+  BOOLEAN       PreviousBackslash;\r
+\r
+  if (SourceFile->FileBufferPtr[0] != T_CHAR_DOUBLE_QUOTE) {\r
+    if (Optional == FALSE) {\r
+      Error (SourceFile->FileName, SourceFile->LineNum, 0, "expected quoted string", "%S", SourceFile->FileBufferPtr);\r
+    }\r
+\r
+    return NULL;\r
+  }\r
+\r
+  Len = 0;\r
+  SourceFile->FileBufferPtr++;\r
+  Start             = Ptr = SourceFile->FileBufferPtr;\r
+  PreviousBackslash = FALSE;\r
+  while (!EndOfFile (SourceFile)) {\r
+    if ((SourceFile->FileBufferPtr[0] == T_CHAR_DOUBLE_QUOTE) && (PreviousBackslash == FALSE)) {\r
+      break;\r
+    } else if (SourceFile->FileBufferPtr[0] == T_CHAR_CR) {\r
+      Warning (SourceFile->FileName, SourceFile->LineNum, 0, "carriage return found in quoted string", "%S", Start);\r
+      PreviousBackslash = FALSE;\r
+    } else if (SourceFile->FileBufferPtr[0] == T_CHAR_BACKSLASH) {\r
+      PreviousBackslash = TRUE;\r
+    } else {\r
+      PreviousBackslash = FALSE;\r
+    }\r
+\r
+    SourceFile->FileBufferPtr++;\r
+    Len++;\r
+  }\r
+\r
+  if (SourceFile->FileBufferPtr[0] != T_CHAR_DOUBLE_QUOTE) {\r
+    Warning (SourceFile->FileName, SourceFile->LineNum, 0, "missing closing quote on string", "%S", Start);\r
+  } else {\r
+    SourceFile->FileBufferPtr++;\r
+  }\r
+  //\r
+  // Now allocate memory for the string and save it off\r
+  //\r
+  String = (T_CHAR *) malloc ((Len + 1) * sizeof (T_CHAR));\r
+  if (String == NULL) {\r
+    Error (NULL, 0, 0, "memory allocation failed", NULL);\r
+    return NULL;\r
+  }\r
+  //\r
+  // Copy the string from the file buffer to the local copy.\r
+  // We do no reformatting of it whatsoever at this point.\r
+  //\r
+  Ptr = String;\r
+  while (Len > 0) {\r
+    *Ptr = *Start;\r
+    Start++;\r
+    Ptr++;\r
+    Len--;\r
+  }\r
+\r
+  *Ptr = 0;\r
+  return String;\r
+}\r
+#endif\r
+static\r
+BOOLEAN\r
+EndOfFile (\r
+  SOURCE_FILE *SourceFile\r
+  )\r
+{\r
+  //\r
+  // The file buffer pointer will typically get updated before the End-of-file flag in the\r
+  // source file structure, so check it first.\r
+  //\r
+  if (SourceFile->FileBufferPtr >= SourceFile->FileBuffer + SourceFile->FileSize / sizeof (T_CHAR)) {\r
+    SourceFile->EndOfFile = TRUE;\r
+    return TRUE;\r
+  }\r
+\r
+  if (SourceFile->EndOfFile) {\r
+    return TRUE;\r
+  }\r
+\r
+  return FALSE;\r
+}\r
+\r
+#if 0\r
+static\r
+void\r
+ProcessTokenInclude (\r
+  SOURCE_FILE *SourceFile\r
+  )\r
+{\r
+  char          IncludeFileName[MAX_PATH];\r
+  char          *To;\r
+  unsigned int  Len;\r
+  BOOLEAN       ReportedError;\r
+  SOURCE_FILE   IncludedSourceFile;\r
+\r
+  ReportedError = FALSE;\r
+  if (SkipWhiteSpace (SourceFile) == 0) {\r
+    Warning (SourceFile->FileName, SourceFile->LineNum, 0, "expected whitespace following #include keyword", NULL);\r
+  }\r
+  //\r
+  // Should be quoted file name\r
+  //\r
+  if (SourceFile->FileBufferPtr[0] != T_CHAR_DOUBLE_QUOTE) {\r
+    Error (SourceFile->FileName, SourceFile->LineNum, 0, "expected quoted include file name", NULL);\r
+    goto FailDone;\r
+  }\r
+\r
+  SourceFile->FileBufferPtr++;\r
+  //\r
+  // Copy the filename as ascii to our local string\r
+  //\r
+  To  = IncludeFileName;\r
+  Len = 0;\r
+  while (!EndOfFile (SourceFile)) {\r
+    if ((SourceFile->FileBufferPtr[0] == T_CHAR_CR) || (SourceFile->FileBufferPtr[0] == T_CHAR_LF)) {\r
+      Error (SourceFile->FileName, SourceFile->LineNum, 0, "end-of-line found in quoted include file name", NULL);\r
+      goto FailDone;\r
+    }\r
+\r
+    if (SourceFile->FileBufferPtr[0] == T_CHAR_DOUBLE_QUOTE) {\r
+      SourceFile->FileBufferPtr++;\r
+      break;\r
+    }\r
+    //\r
+    // If too long, then report the error once and process until the closing quote\r
+    //\r
+    Len++;\r
+    if (!ReportedError && (Len >= sizeof (IncludeFileName))) {\r
+      Error (SourceFile->FileName, SourceFile->LineNum, 0, "length of include file name exceeds limit", NULL);\r
+      ReportedError = TRUE;\r
+    }\r
+\r
+    if (!ReportedError) {\r
+      *To = (T_CHAR) SourceFile->FileBufferPtr[0];\r
+      To++;\r
+    }\r
+\r
+    SourceFile->FileBufferPtr++;\r
+  }\r
+\r
+  if (!ReportedError) {\r
+    *To = 0;\r
+    memset ((char *) &IncludedSourceFile, 0, sizeof (SOURCE_FILE));\r
+    strcpy (IncludedSourceFile.FileName, IncludeFileName);\r
+    ProcessIncludeFile (&IncludedSourceFile, SourceFile);\r
+  }\r
+\r
+  return ;\r
+FailDone:\r
+  //\r
+  // Error recovery -- skip to next #\r
+  //\r
+  SourceFile->SkipToHash = TRUE;\r
+}\r
+#endif\r
+static\r
+BOOLEAN\r
+IsWhiteSpace (\r
+  SOURCE_FILE *SourceFile\r
+  )\r
+{\r
+  switch (*SourceFile->FileBufferPtr) {\r
+  case T_CHAR_NULL:\r
+  case T_CHAR_CR:\r
+  case T_CHAR_SPACE:\r
+  case T_CHAR_TAB:\r
+  case T_CHAR_LF:\r
+    return TRUE;\r
+\r
+  default:\r
+    return FALSE;\r
+  }\r
+}\r
+\r
+unsigned int\r
+SkipWhiteSpace (\r
+  SOURCE_FILE *SourceFile\r
+  )\r
+{\r
+  unsigned int  Count;\r
+\r
+  Count = 0;\r
+  while (!EndOfFile (SourceFile)) {\r
+    Count++;\r
+    switch (*SourceFile->FileBufferPtr) {\r
+    case T_CHAR_NULL:\r
+    case T_CHAR_CR:\r
+    case T_CHAR_SPACE:\r
+    case T_CHAR_TAB:\r
+      SourceFile->FileBufferPtr++;\r
+      break;\r
+\r
+    case T_CHAR_LF:\r
+      SourceFile->FileBufferPtr++;\r
+      SourceFile->LineNum++;\r
+      break;\r
+\r
+    default:\r
+      return Count - 1;\r
+    }\r
+  }\r
+  //\r
+  // Some tokens require trailing whitespace. If we're at the end of the\r
+  // file, then we count that as well.\r
+  //\r
+  if ((Count == 0) && (EndOfFile (SourceFile))) {\r
+    Count++;\r
+  }\r
+\r
+  return Count;\r
+}\r
+\r
+static\r
+unsigned int\r
+t_strcmp (\r
+  T_CHAR *Buffer,\r
+  T_CHAR *Str\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Compare two strings for equality. The string pointed to by 'Buffer' may or may not be null-terminated,\r
+  so only compare up to the length of Str.\r
+\r
+Arguments:\r
+  Buffer  - pointer to first (possibly not null-terminated) string\r
+  Str     - pointer to null-terminated string to compare to Buffer\r
+\r
+Returns:\r
+  Number of bytes matched if exact match\r
+  0 if Buffer does not start with Str\r
+\r
+--*/\r
+{\r
+  unsigned int  Len;\r
+\r
+  Len = 0;\r
+  while (*Str && (*Str == *Buffer)) {\r
+    Buffer++;\r
+    Str++;\r
+    Len++;\r
+  }\r
+\r
+  if (*Str) {\r
+    return 0;\r
+  }\r
+\r
+  return Len;\r
+}\r
+\r
+static\r
+unsigned int\r
+t_strlen (\r
+  T_CHAR *Str\r
+  )\r
+{\r
+  unsigned int  Len;\r
+  Len = 0;\r
+  while (*Str) {\r
+    Len++;\r
+    Str++;\r
+  }\r
+\r
+  return Len;\r
+}\r
+\r
+static\r
+unsigned int\r
+t_strncmp (\r
+  T_CHAR *Str1,\r
+  T_CHAR *Str2,\r
+  int    Len\r
+  )\r
+{\r
+  while (Len > 0) {\r
+    if (*Str1 != *Str2) {\r
+      return Len;\r
+    }\r
+\r
+    Len--;\r
+    Str1++;\r
+    Str2++;\r
+  }\r
+\r
+  return 0;\r
+}\r
+\r
+static\r
+T_CHAR *\r
+t_strcpy (\r
+  T_CHAR *Dest,\r
+  T_CHAR *Src\r
+  )\r
+{\r
+  T_CHAR  *SaveDest;\r
+  SaveDest = Dest;\r
+  while (*Src) {\r
+    *Dest = *Src;\r
+    Dest++;\r
+    Src++;\r
+  }\r
+\r
+  *Dest = 0;\r
+  return SaveDest;\r
+}\r
+\r
+static\r
+void\r
+RewindFile (\r
+  SOURCE_FILE *SourceFile\r
+  )\r
+{\r
+  SourceFile->LineNum       = 1;\r
+  SourceFile->FileBufferPtr = SourceFile->FileBuffer;\r
+  SourceFile->EndOfFile     = 0;\r
+}\r
+\r
+static\r
+UINT32\r
+GetHexChars (\r
+  T_CHAR      *Buffer,\r
+  UINT32      BufferLen\r
+  )\r
+{\r
+  UINT32  Len;\r
+  Len = 0;\r
+  while (!EndOfFile (&mGlobals.SourceFile) && (BufferLen > 0)) {\r
+    if (isxdigit (mGlobals.SourceFile.FileBufferPtr[0])) {\r
+      *Buffer = mGlobals.SourceFile.FileBufferPtr[0];\r
+      Buffer++;\r
+      Len++;\r
+      BufferLen--;\r
+      mGlobals.SourceFile.FileBufferPtr++;\r
+    } else {\r
+      break;\r
+    }\r
+  }\r
+  //\r
+  // Null terminate if we can\r
+  //\r
+  if ((Len > 0) && (BufferLen > 0)) {\r
+    *Buffer = 0;\r
+  }\r
+\r
+  return Len;\r
+}\r
+\r
+BOOLEAN\r
+SFPGetGuid (\r
+  int         GuidStyle,\r
+  EFI_GUID    *Value\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Parse a GUID from the input stream. Stop when you discover white space.\r
+\r
+Arguments:\r
+  GuidStyle - Style of the following GUID token\r
+  Value     - pointer to EFI_GUID struct for output\r
+\r
+Returns:\r
+  TRUE  - GUID string parsed successfully\r
+  FALSE - otherwise\r
+\r
+  GUID styles\r
+    Style[0] 12345678-1234-5678-AAAA-BBBBCCCCDDDD\r
+\r
+--*/\r
+{\r
+  UINT32        Value32;\r
+  UINT32        Index;\r
+  FILE_POSITION FPos;\r
+  T_CHAR        TempString[20];\r
+  T_CHAR        TempString2[3];\r
+  T_CHAR        *From;\r
+  T_CHAR        *To;\r
+  UINT32        Len;\r
+  BOOLEAN       Status;\r
+\r
+  Status = FALSE;\r
+  //\r
+  // Skip white space, then start parsing\r
+  //\r
+  SkipWhiteSpace (&mGlobals.SourceFile);\r
+  GetFilePosition (&FPos);\r
+  if (EndOfFile (&mGlobals.SourceFile)) {\r
+    return FALSE;\r
+  }\r
+\r
+  if (GuidStyle == PARSE_GUID_STYLE_5_FIELDS) {\r
+    //\r
+    // Style[0] 12345678-1234-5678-AAAA-BBBBCCCCDDDD\r
+    //\r
+    Len = GetHexChars (TempString, sizeof (TempString));\r
+    if ((Len == 0) || (Len > 8)) {\r
+      goto Done;\r
+    }\r
+\r
+    sscanf (TempString, "%x", &Value32);\r
+    Value->Data1 = Value32;\r
+    //\r
+    // Next two UINT16 fields\r
+    //\r
+    if (mGlobals.SourceFile.FileBufferPtr[0] != '-') {\r
+      goto Done;\r
+    }\r
+\r
+    mGlobals.SourceFile.FileBufferPtr++;\r
+    Len = GetHexChars (TempString, sizeof (TempString));\r
+    if ((Len == 0) || (Len > 4)) {\r
+      goto Done;\r
+    }\r
+\r
+    sscanf (TempString, "%x", &Value32);\r
+    Value->Data2 = (UINT16) Value32;\r
+\r
+    if (mGlobals.SourceFile.FileBufferPtr[0] != '-') {\r
+      goto Done;\r
+    }\r
+\r
+    mGlobals.SourceFile.FileBufferPtr++;\r
+    Len = GetHexChars (TempString, sizeof (TempString));\r
+    if ((Len == 0) || (Len > 4)) {\r
+      goto Done;\r
+    }\r
+\r
+    sscanf (TempString, "%x", &Value32);\r
+    Value->Data3 = (UINT16) Value32;\r
+    //\r
+    // Parse the "AAAA" as two bytes\r
+    //\r
+    if (mGlobals.SourceFile.FileBufferPtr[0] != '-') {\r
+      goto Done;\r
+    }\r
+\r
+    mGlobals.SourceFile.FileBufferPtr++;\r
+    Len = GetHexChars (TempString, sizeof (TempString));\r
+    if ((Len == 0) || (Len > 4)) {\r
+      goto Done;\r
+    }\r
+\r
+    sscanf (TempString, "%x", &Value32);\r
+    Value->Data4[0] = (UINT8) (Value32 >> 8);\r
+    Value->Data4[1] = (UINT8) Value32;\r
+    if (mGlobals.SourceFile.FileBufferPtr[0] != '-') {\r
+      goto Done;\r
+    }\r
+\r
+    mGlobals.SourceFile.FileBufferPtr++;\r
+    //\r
+    // Read the last 6 bytes of the GUID\r
+    //\r
+    //\r
+    Len = GetHexChars (TempString, sizeof (TempString));\r
+    if ((Len == 0) || (Len > 12)) {\r
+      goto Done;\r
+    }\r
+    //\r
+    // Insert leading 0's to make life easier\r
+    //\r
+    if (Len != 12) {\r
+      From            = TempString + Len - 1;\r
+      To              = TempString + 11;\r
+      TempString[12]  = 0;\r
+      while (From >= TempString) {\r
+        *To = *From;\r
+        To--;\r
+        From--;\r
+      }\r
+\r
+      while (To >= TempString) {\r
+        *To = '0';\r
+        To--;\r
+      }\r
+    }\r
+    //\r
+    // Now parse each byte\r
+    //\r
+    TempString2[2] = 0;\r
+    for (Index = 0; Index < 6; Index++) {\r
+      //\r
+      // Copy the two characters from the input string to something\r
+      // we can parse.\r
+      //\r
+      TempString2[0]  = TempString[Index * 2];\r
+      TempString2[1]  = TempString[Index * 2 + 1];\r
+      sscanf (TempString2, "%x", &Value32);\r
+      Value->Data4[Index + 2] = (UINT8) Value32;\r
+    }\r
+\r
+    Status = TRUE;\r
+  } else {\r
+    //\r
+    // Unsupported GUID style\r
+    //\r
+    return FALSE;\r
+  }\r
+\r
+Done:\r
+  if (Status == FALSE) {\r
+    SetFilePosition (&FPos);\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
+static\r
+STATUS\r
+GetFilePosition (\r
+  FILE_POSITION *Fpos\r
+  )\r
+{\r
+  Fpos->FileBufferPtr = mGlobals.SourceFile.FileBufferPtr;\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+STATUS\r
+SetFilePosition (\r
+  FILE_POSITION *Fpos\r
+  )\r
+{\r
+  //\r
+  // Should check range of pointer\r
+  //\r
+  mGlobals.SourceFile.FileBufferPtr = Fpos->FileBufferPtr;\r
+  return STATUS_SUCCESS;\r
+}\r
diff --git a/Tools/CodeTools/Source/Common/SimpleFileParsing.h b/Tools/CodeTools/Source/Common/SimpleFileParsing.h
new file mode 100644 (file)
index 0000000..7cf25a6
--- /dev/null
@@ -0,0 +1,120 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  SimpleFileParsing.h\r
+\r
+Abstract:\r
+\r
+  Function prototypes and defines for the simple file parsing routines.\r
+\r
+--*/\r
+\r
+#ifndef _SIMPLE_FILE_PARSING_H_\r
+#define _SIMPLE_FILE_PARSING_H_\r
+\r
+#include <Common/UefiBaseTypes.h>\r
+\r
+#define T_CHAR  char\r
+\r
+STATUS\r
+SFPInit (\r
+  VOID\r
+  )\r
+;\r
+\r
+STATUS\r
+SFPOpenFile (\r
+  char    *FileName\r
+  )\r
+;\r
+\r
+BOOLEAN\r
+SFPIsKeyword (\r
+  T_CHAR *Str\r
+  )\r
+;\r
+\r
+BOOLEAN\r
+SFPIsToken (\r
+  T_CHAR *Str\r
+  )\r
+;\r
+\r
+BOOLEAN\r
+SFPGetNextToken (\r
+  T_CHAR        *Str,\r
+  unsigned int  Len\r
+  )\r
+;\r
+\r
+BOOLEAN\r
+SFPGetGuidToken (\r
+  T_CHAR *Str,\r
+  UINT32 Len\r
+  )\r
+;\r
+\r
+#define PARSE_GUID_STYLE_5_FIELDS 0\r
+\r
+BOOLEAN\r
+SFPGetGuid (\r
+  int         GuidStyle,\r
+  EFI_GUID    *Value\r
+  )\r
+;\r
+\r
+BOOLEAN\r
+SFPSkipToToken (\r
+  T_CHAR *Str\r
+  )\r
+;\r
+\r
+BOOLEAN\r
+SFPGetNumber (\r
+  unsigned int   *Value\r
+  )\r
+;\r
+\r
+BOOLEAN\r
+SFPGetQuotedString (\r
+  T_CHAR      *Str,\r
+  int         Length\r
+  )\r
+;\r
+\r
+BOOLEAN\r
+SFPIsEOF (\r
+  VOID\r
+  )\r
+;\r
+\r
+STATUS\r
+SFPCloseFile (\r
+  VOID\r
+  )\r
+;\r
+\r
+unsigned\r
+int\r
+SFPGetLineNumber (\r
+  VOID\r
+  )\r
+;\r
+\r
+T_CHAR  *\r
+SFPGetFileName (\r
+  VOID\r
+  )\r
+;\r
+\r
+#endif // #ifndef _SIMPLE_FILE_PARSING_H_\r
diff --git a/Tools/CodeTools/Source/Common/WinNtInclude.h b/Tools/CodeTools/Source/Common/WinNtInclude.h
new file mode 100644 (file)
index 0000000..80e45b4
--- /dev/null
@@ -0,0 +1,73 @@
+/*--\r
+\r
+Copyright (c) 2006, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+Module Name:\r
+  WinNtInclude.h\r
+\r
+Abstract:\r
+  Include file for the WinNt Library\r
+\r
+--*/\r
+\r
+#ifndef __WIN_NT_INCLUDE_H__\r
+#define __WIN_NT_INCLUDE_H__\r
+\r
+//\r
+// Win32 include files do not compile clean with /W4, so we use the warning\r
+// pragma to suppress the warnings for Win32 only. This way our code can stil\r
+// compile at /W4 (highest warning level) with /WX (warnings cause build\r
+// errors).\r
+//\r
+#pragma warning(disable : 4115)\r
+#pragma warning(disable : 4201)\r
+#pragma warning(disable : 4214)\r
+#pragma warning(disable : 4028)\r
+#pragma warning(disable : 4133)\r
+\r
+#define GUID  _WINNT_DUP_GUID_____\r
+#define _LIST_ENTRY  _WINNT_DUP_LIST_ENTRY_FORWARD\r
+#define LIST_ENTRY   _WINNT_DUP_LIST_ENTRY\r
+#define InterlockedIncrement _WINNT_DUP_InterlockedIncrement\r
+#define InterlockedDecrement _WINNT_DUP_InterlockedDecrement\r
+#define InterlockedCompareExchange64 _WINNT_DUP_InterlockedCompareExchange64\r
+#undef UNALIGNED\r
+#undef CONST\r
+#undef VOID\r
+\r
+#ifndef __GNUC__\r
+#include "windows.h"\r
+#endif\r
+\r
+#undef GUID\r
+#undef _LIST_ENTRY\r
+#undef LIST_ENTRY\r
+#undef InterlockedIncrement\r
+#undef InterlockedDecrement\r
+#undef InterlockedCompareExchange64\r
+#undef InterlockedCompareExchangePointer\r
+\r
+#define VOID void\r
+\r
+//\r
+// Prevent collisions with Windows API name macros that deal with Unicode/Not issues\r
+//\r
+#undef LoadImage\r
+#undef CreateEvent\r
+\r
+//\r
+// Set the warnings back on as the EFI code must be /W4.\r
+//\r
+#pragma warning(default : 4115)\r
+#pragma warning(default : 4201)\r
+#pragma warning(default : 4214)\r
+\r
+\r
+#endif\r
diff --git a/Tools/CodeTools/Source/Common/build.xml b/Tools/CodeTools/Source/Common/build.xml
new file mode 100644 (file)
index 0000000..902f677
--- /dev/null
@@ -0,0 +1,67 @@
+<?xml version="1.0" ?>\r
+<!--\r
+Copyright (c) 2006, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+-->\r
+<project default="CommonTools.lib" basedir=".">\r
+<!--\r
+    EDK Common Tools Library\r
+  Copyright (c) 2006, Intel Corporation\r
+-->\r
+\r
+  <taskdef resource="cpptasks.tasks"/>\r
+  <typedef resource="cpptasks.types"/>\r
+  <taskdef resource="net/sf/antcontrib/antlib.xml"/>\r
+\r
+  <property name="tmp" value="tmp"/>\r
+  <property name="LibName" value="CommonTool"/>\r
+\r
+  <property name="LINK_OUTPUT_TYPE" value="static"/>\r
+  <property name="BUILD_DIR" value="${PACKAGE_DIR}/Common/tmp"/>\r
+\r
+  <target name="CommonTools.lib" depends="init, ToolsLibrary">\r
+    <echo message="The EDK Tool Library: ${LibName} build has completed."/>\r
+  </target>\r
+\r
+  <target name="init">\r
+    <echo message="Building the EDK Tool Library: ${LibName}"/>\r
+    <mkdir dir="${BUILD_DIR}"/>\r
+  </target>\r
+\r
+  <target name="ToolsLibrary" depends="init">\r
+    <cc name="${ToolChain}" objdir="${BUILD_DIR}" \r
+        outfile="${LIB_DIR}/CommonTools"\r
+        outtype="static"\r
+        debug="true"\r
+        optimize="speed">\r
+      <compilerarg value="${ExtraArgus}" if="ExtraArgus" />\r
+      <compilerarg value="-fPIC" if="x86_64_linux"/>\r
+\r
+      <includepath path="${PACKAGE_DIR}/Include"/>\r
+      <includepath path="${PACKAGE_DIR}/Include/${HostArch}"/>\r
+\r
+      <fileset dir="${basedir}/Common" \r
+        includes="*.c" />\r
+    </cc>\r
+  </target>\r
+\r
+  <target name="clean">\r
+    <echo message="Removing Intermediate Files Only from ${BUILD_DIR}"/>  \r
+    <delete dir="${BUILD_DIR}"/>\r
+  </target>\r
+\r
+  <target name="cleanall">\r
+    <echo message="Removing Object Files and the Library: ${LibName}${ext_static}"/>  \r
+    <delete failonerror="false" quiet="true" includeEmptyDirs="true">\r
+      <fileset dir="${BUILD_DIR}"/>\r
+      <fileset file="${LIB_DIR}/${LibName}${ext_static}"/>\r
+    </delete>\r
+  </target>\r
+\r
+</project>\r
diff --git a/Tools/CodeTools/Source/CompressDll/CompressDll.c b/Tools/CodeTools/Source/CompressDll/CompressDll.c
new file mode 100644 (file)
index 0000000..cc06f26
--- /dev/null
@@ -0,0 +1,105 @@
+/** @file\r
+  Compression DLL used by PCD Tools\r
+\r
+  Copyright (c) 2006, Intel Corporation   All rights reserved.\r
+  This program and the accompanying materials are licensed and made available \r
+  under the terms and conditions of the BSD License which accompanies this \r
+  distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php \r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+#if defined(__GNUC__)\r
+typedef long long __int64;/*For cygwin build*/\r
+#endif\r
+#include "CompressDll.h"\r
+#include "EfiCompress.h"\r
+\r
+extern\r
+EFI_STATUS\r
+Compress (\r
+  IN      UINT8   *SrcBuffer,\r
+  IN      UINT32  SrcSize,\r
+  IN      UINT8   *DstBuffer,\r
+  IN OUT  UINT32  *DstSize\r
+  );\r
+  \r
+JNIEXPORT jbyteArray JNICALL  Java_org_tianocore_framework_tasks_Compress_CallCompress \r
+(JNIEnv *env, jobject obj, jbyteArray SourceBuffer, jint SourceSize, jstring path)\r
+{\r
+  char*          DestBuffer;\r
+  int            DestSize;   \r
+  int            Result;\r
+  char           *InputBuffer;\r
+  jbyteArray     OutputBuffer;\r
+  jbyte          *TempByte;\r
+  \r
+  DestSize   = 0;\r
+  DestBuffer = NULL;\r
+  \r
+  TempByte = (*env)->GetByteArrayElements(env, SourceBuffer, 0);\r
+  InputBuffer = (char*) TempByte;\r
+\r
+  \r
+   //\r
+   //  First call compress function and get need buffer size\r
+   //\r
+\r
+   Result = Compress (\r
+        (char*) InputBuffer, \r
+        SourceSize,  \r
+        DestBuffer,\r
+        &DestSize\r
+        );\r
+\r
+   if (Result = EFI_BUFFER_TOO_SMALL) {\r
+     DestBuffer = malloc (DestSize);\r
+   }\r
+\r
+   //\r
+   //  Second call compress and get the DestBuffer value\r
+   //\r
+   Result = Compress(\r
+              (char*) InputBuffer, \r
+        SourceSize,  \r
+        DestBuffer,\r
+        &DestSize  \r
+     );\r
+\r
+   //\r
+   // new a MV array to store the return compressed buffer\r
+   //\r
+   OutputBuffer = (*env)->NewByteArray(env, DestSize);\r
+   (*env)->SetByteArrayRegion(env, OutputBuffer,0, DestSize, (jbyte*) DestBuffer);\r
+\r
+   //\r
+   // Free Ouputbuffer.\r
+   //\r
+   free (DestBuffer);\r
+  \r
+\r
+  if (Result != 0) {\r
+    return NULL;\r
+  } else {\r
+    return OutputBuffer;\r
+  }\r
+}\r
+\r
+#ifdef _MSC_VER\r
+BOOLEAN \r
+__stdcall \r
+DllMainCRTStartup(\r
+    unsigned int hDllHandle, \r
+    unsigned int nReason,    \r
+    void*   Reserved    \r
+)\r
+{\r
+  return TRUE;\r
+}\r
+#else\r
+#ifdef __GNUC__\r
+#endif\r
+#endif\r
+\r
diff --git a/Tools/CodeTools/Source/CompressDll/CompressDll.h b/Tools/CodeTools/Source/CompressDll/CompressDll.h
new file mode 100644 (file)
index 0000000..fa3b83c
--- /dev/null
@@ -0,0 +1,22 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */\r
+\r
+#include <jni.h>\r
+/* Header for class org_tianocore_frameworktasks_Compress */\r
+\r
+#ifndef _Included_org_tianocore_framework_tasks_Compress\r
+#define _Included_org_tianocore_framework_tasks_Compress\r
+#ifdef __cplusplus\r
+extern "C" {\r
+#endif\r
+/*\r
+ * Class:     org_tianocore_frameworktasks_Compress\r
+ * Method:    CallCompress\r
+ * Signature: ([BILjava/lang/String;)[B\r
+ */\r
+JNIEXPORT jbyteArray JNICALL Java_org_tianocore_framework_tasks_Compress_CallCompress\r
+  (JNIEnv *, jobject, jbyteArray, jint, jstring);\r
+\r
+#ifdef __cplusplus\r
+}\r
+#endif\r
+#endif\r
diff --git a/Tools/CodeTools/Source/CompressDll/build.xml b/Tools/CodeTools/Source/CompressDll/build.xml
new file mode 100644 (file)
index 0000000..5043d12
--- /dev/null
@@ -0,0 +1,80 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<!--\r
+Copyright (c) 2006, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+-->\r
+<project default="GenTool" basedir=".">\r
+<!--\r
+    EDK CompressDll Tool Library\r
+  Copyright (c) 2006, Intel Corporation\r
+-->\r
+\r
+  <property name="WORKSPACE" value="${env.WORKSPACE}"/>\r
+  <property name="LibName" value="CompressDll"/>\r
+  <property name="FileSet" value="CompressDll.c CompressDll.h"/>\r
+  <property name="LibFileSet" value="CompressDll.c DepexParser.h"/>\r
+\r
+  <taskdef resource="cpptasks.tasks"/>\r
+  <typedef resource="cpptasks.types"/>\r
+  <taskdef resource="net/sf/antcontrib/antlib.xml"/>\r
+\r
+  <property name="LINK_OUTPUT_TYPE" value="static"/>\r
+  <property name="BUILD_DIR" value="${WORKSPACE}/Tools/Source/TianoTools/${LibName}/tmp"/>\r
+\r
+  <target name="GenTool" depends="init,Lib" >\r
+    <echo message="The EDK Tool Library: ${LibName} build has completed!"/>\r
+  </target>\r
+\r
+  <target name="init">\r
+    <echo message="Building the EDK Tool Library: ${LibName}"/>\r
+    <mkdir dir="${BUILD_DIR}"/>\r
+  </target>\r
+  \r
+  <target name="Lib" depends="init">\r
+    <cc name="${ToolChain}" \r
+      objdir="${BUILD_DIR}" \r
+      outtype="shared" \r
+      debug="true"\r
+      optimize="speed" \r
+      outfile="${BIN_DIR}/${LibName}"\r
+      outputfileproperty="result"\r
+      >\r
+      <compilerarg value="${ExtraArgus}" if="ExtraArgus" />\r
+      <fileset dir="${LibName}" includes="${LibFileSet}" defaultexcludes="TRUE" excludes="*.xml *.inf"/>\r
+      <includepath path="${PACKAGE_DIR}/Include"/>\r
+      <includepath path="${PACKAGE_DIR}/Include/${HostArch}"/>\r
+      <includepath path="${PACKAGE_DIR}/Common"/>\r
+      <includepath path="${env.JAVA_HOME}/include"/>\r
+      <includepath path="${env.JAVA_HOME}/include/linux" if="gcc"/>\r
+      <includepath path="${env.JAVA_HOME}/include/win32" if="cygwin"/>\r
+      <includepath path="${env.JAVA_HOME}/include/win32" if="msft"/>\r
+      <libset dir="${LIB_DIR}" libs="CommonTools"/>\r
+      <syslibset libs="kernel32" if="msft"/>\r
+      <linkerarg value="-mno-cygwin" if="cygwin"/>\r
+      <linkerarg value="--add-stdcall-alias" if="cygwin"/>\r
+    </cc>\r
+    <copy file="${result}" tofile="${BIN_DIR}/CompressDll.dll"/>\r
+    <chmod file="${BIN_DIR}/CompressDll.dll" perm="ugo+x"/>\r
+  </target>\r
+\r
+  <target name="clean">\r
+    <echo message="Removing Intermediate Files Only"/>\r
+    <delete>\r
+      <fileset dir="${BUILD_DIR}" includes="*.obj"/>\r
+    </delete>\r
+  </target>\r
+\r
+  <target name="cleanall">\r
+    <echo message="Removing Object Files and the Executable: ${LibName}${ext_shared}"/>\r
+    <delete failonerror="false" quiet="true" includeEmptyDirs="true">\r
+      <fileset dir="${BUILD_DIR}"/>\r
+      <fileset file="${BIN_DIR}/${LibName}.*"/>\r
+    </delete>\r
+  </target>\r
+</project>\r
diff --git a/Tools/CodeTools/Source/CreateMtFile/CreateMtFile.c b/Tools/CodeTools/Source/CreateMtFile/CreateMtFile.c
new file mode 100644 (file)
index 0000000..1c17b3d
--- /dev/null
@@ -0,0 +1,247 @@
+/*++\r
+\r
+Copyright (c)  1999-2006 Intel Corporation. All rights reserved\r
+This program and the accompanying materials are licensed and made available \r
+under the terms and conditions of the BSD License which accompanies this \r
+distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+\r
+Module Name:\r
+\r
+  CreateMtFile.c\r
+\r
+Abstract:\r
+\r
+  Simple utility to create a pad file containing fixed data.\r
+  \r
+--*/\r
+\r
+#include <stdio.h>\r
+#include <string.h>\r
+#include <stdlib.h>\r
+\r
+#include <Common/UefiBaseTypes.h>\r
+\r
+#define PROGRAM_NAME  "CreateMtFile"\r
+\r
+typedef struct {\r
+  INT8    *OutFileName;\r
+  INT8    ByteValue;\r
+  UINT32  FileSize;\r
+} OPTIONS;\r
+\r
+static\r
+EFI_STATUS\r
+ProcessArgs (\r
+  IN INT32          Argc,\r
+  IN INT8           *Argv[],\r
+  IN OUT OPTIONS    *Options\r
+  );\r
+\r
+static\r
+void\r
+Usage (\r
+  VOID\r
+  );\r
+\r
+int\r
+main (\r
+  IN INT32  Argc,\r
+  IN INT8   *Argv[]\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  Main entry point for this utility.\r
+\r
+Arguments:\r
+\r
+  Standard C entry point args Argc and Argv\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS if good to go\r
+\r
+--*/\r
+// GC_TODO:    ] - add argument and description to function comment\r
+// GC_TODO:    EFI_INVALID_PARAMETER - add return value to function comment\r
+// GC_TODO:    EFI_DEVICE_ERROR - add return value to function comment\r
+// GC_TODO:    EFI_DEVICE_ERROR - add return value to function comment\r
+{\r
+  FILE    *OutFptr;\r
+  OPTIONS Options;\r
+\r
+  //\r
+  // Process the command-line arguments.\r
+  //\r
+  if (ProcessArgs (Argc, Argv, &Options) != EFI_SUCCESS) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+  //\r
+  // Open the output file\r
+  //\r
+  if ((OutFptr = fopen (Options.OutFileName, "wb")) == NULL) {\r
+    fprintf (\r
+      stdout,\r
+      PROGRAM_NAME " ERROR: Could not open output file '%s' for writing\n",\r
+      Options.OutFileName\r
+      );\r
+    return EFI_DEVICE_ERROR;\r
+  }\r
+  //\r
+  // Write the pad bytes. Do it the slow way (one at a time) for now.\r
+  //\r
+  while (Options.FileSize > 0) {\r
+    if (fwrite (&Options.ByteValue, 1, 1, OutFptr) != 1) {\r
+      fclose (OutFptr);\r
+      fprintf (stdout, PROGRAM_NAME " ERROR: Failed to write to output file\n");\r
+      return EFI_DEVICE_ERROR;\r
+    }\r
+\r
+    Options.FileSize--;\r
+  }\r
+  //\r
+  // Close the file\r
+  //\r
+  fclose (OutFptr);\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+static\r
+EFI_STATUS\r
+ProcessArgs (\r
+  IN INT32          Argc,\r
+  IN INT8           *Argv[],\r
+  IN OUT OPTIONS    *Options\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  Process the command line arguments.\r
+\r
+Arguments:\r
+\r
+  Argc    - argument count as passed in to the entry point function\r
+  Argv    - array of arguments as passed in to the entry point function\r
+  Options - stucture of where to put the values of the parsed arguments\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS if everything looks good\r
+  EFI_INVALID_PARAMETER otherwise\r
+\r
+--*/\r
+// GC_TODO:    ] - add argument and description to function comment\r
+{\r
+  UINT32  Multiplier;\r
+\r
+  //\r
+  // Clear the options\r
+  //\r
+  memset ((char *) Options, 0, sizeof (OPTIONS));\r
+\r
+  //\r
+  // Skip program name\r
+  //\r
+  Argv++;\r
+  Argc--;\r
+  if (Argc < 2) {\r
+    Usage ();\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+  //\r
+  // If first arg is dash-option, then print usage.\r
+  //\r
+  if (Argv[0][0] == '-') {\r
+    Usage ();\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+  //\r
+  // First arg is file name\r
+  //\r
+  Options->OutFileName = Argv[0];\r
+  Argc--;\r
+  Argv++;\r
+\r
+  //\r
+  // Second arg is file size. Allow 0x1000, 0x100K, 1024, 1K\r
+  //\r
+  Multiplier = 1;\r
+  if ((Argv[0][strlen (Argv[0]) - 1] == 'k') || (Argv[0][strlen (Argv[0]) - 1] == 'K')) {\r
+    Multiplier = 1024;\r
+  }\r
+  //\r
+  // Look for 0x prefix on file size\r
+  //\r
+  if ((Argv[0][0] == '0') && ((Argv[0][1] == 'x') || (Argv[0][1] == 'X'))) {\r
+    if (sscanf (Argv[0], "%x", &Options->FileSize) != 1) {\r
+      fprintf (stdout, PROGRAM_NAME " ERROR: Invalid file size '%s'\n", Argv[0]);\r
+      Usage ();\r
+      return EFI_INVALID_PARAMETER;\r
+    }\r
+    //\r
+    // Otherwise must be a decimal number\r
+    //\r
+  } else {\r
+    if (sscanf (Argv[0], "%d", &Options->FileSize) != 1) {\r
+      fprintf (stdout, PROGRAM_NAME " ERROR: Invalid file size '%s'\n", Argv[0]);\r
+      Usage ();\r
+      return EFI_INVALID_PARAMETER;\r
+    }\r
+  }\r
+\r
+  Options->FileSize *= Multiplier;\r
+  //\r
+  // Assume byte value of 0xff\r
+  //\r
+  Options->ByteValue = (INT8) (UINT8) 0xFF;\r
+  return EFI_SUCCESS;\r
+}\r
+//\r
+// Print utility usage info\r
+//\r
+static\r
+void\r
+Usage (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  None\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+{\r
+  UINT32            Index;\r
+  static const INT8 *Text[] = {\r
+    " ",\r
+    "Usage:  "PROGRAM_NAME " OutFileName FileSize",\r
+    "  where:",\r
+    "    OutFileName is the name of the output file to generate",\r
+    "    FileSize is the size of the file to create",\r
+    "  Examples:",\r
+    "    "PROGRAM_NAME " OutFile.bin 32K",\r
+    "    "PROGRAM_NAME " OutFile.bin 0x1000",\r
+    " ",\r
+    NULL\r
+  };\r
+\r
+  for (Index = 0; Text[Index] != NULL; Index++) {\r
+    fprintf (stdout, "%s\n", Text[Index]);\r
+  }\r
+}\r
diff --git a/Tools/CodeTools/Source/CreateMtFile/build.xml b/Tools/CodeTools/Source/CreateMtFile/build.xml
new file mode 100644 (file)
index 0000000..b227224
--- /dev/null
@@ -0,0 +1,70 @@
+<?xml version="1.0" ?>\r
+<!--\r
+Copyright (c) 2006, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+-->\r
+<project default="GenTool" basedir=".">\r
+<!--\r
+    EDK CreateMtFile Tool\r
+  Copyright (c) 2006, Intel Corporation\r
+-->\r
+  <property name="ToolName" value="CreateMtFile"/>\r
+  <property name="FileSet" value="*.c"/>\r
+\r
+  <taskdef resource="cpptasks.tasks"/>\r
+  <typedef resource="cpptasks.types"/>\r
+  <taskdef resource="net/sf/antcontrib/antlib.xml"/>\r
+\r
+  <property name="LINK_OUTPUT_TYPE" value="static"/>\r
+  <property name="BUILD_DIR" value="${PACKAGE_DIR}/${ToolName}/tmp"/>\r
+\r
+  <target name="GenTool" depends="init, Tool">\r
+    <echo message="The EDK Tool: ${ToolName} build has completed!"/>\r
+  </target>\r
+\r
+  <target name="init">\r
+    <echo message="Building the EDK Tool: ${ToolName}"/>\r
+    <mkdir dir="${BUILD_DIR}"/>\r
+  </target>\r
+\r
+  <target name="Tool" depends="init">\r
+    <cc name="${ToolChain}" objdir="${BUILD_DIR}" \r
+        outfile="${BIN_DIR}/${ToolName}"\r
+        outtype="executable"\r
+        optimize="speed" \r
+        debug="true">\r
+      <compilerarg value="${ExtraArgus}" if="ExtraArgus" />\r
+\r
+      <fileset dir="${basedir}/${ToolName}" \r
+        includes="${FileSet}" \r
+        defaultexcludes="TRUE" \r
+        excludes="*.xml *.inf"/>\r
+\r
+      <includepath path="${PACKAGE_DIR}/Include"/>\r
+      <includepath path="${PACKAGE_DIR}/Include/Ia32"/>\r
+      <includepath path="${PACKAGE_DIR}/Common"/>\r
+    </cc>\r
+  </target>\r
+\r
+  <target name="clean">\r
+    <echo message="Removing Intermediate Files Only"/>  \r
+    <delete>\r
+      <fileset dir="${BUILD_DIR}" includes="*.obj"/>\r
+    </delete>\r
+  </target>\r
+\r
+  <target name="cleanall">\r
+    <echo message="Removing Object Files and the Executable: ${ToolName}${ext_exe}"/>  \r
+    <delete failonerror="false" quiet="true" includeEmptyDirs="true">\r
+      <fileset dir="${BUILD_DIR}"/>\r
+      <fileset file="${BIN_DIR}/${ToolName}${ext_exe}"/>\r
+    </delete>\r
+  </target>\r
+\r
+</project>\r
diff --git a/Tools/CodeTools/Source/CustomizedCompress/CustomizedCompress.c b/Tools/CodeTools/Source/CustomizedCompress/CustomizedCompress.c
new file mode 100644 (file)
index 0000000..0dc6612
--- /dev/null
@@ -0,0 +1,146 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+  CustomizedCompress.c\r
+\r
+Abstract:\r
+\r
+  Header file for Customized compression routine\r
+  \r
+--*/\r
+\r
+#include <Common/UefiBaseTypes.h>\r
+\r
+EFI_STATUS\r
+SetCustomizedCompressionType (\r
+  IN  CHAR8   *Type\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+The implementation of Customized SetCompressionType().\r
+\r
+Arguments:\r
+  Type        - The type if compression.\r
+    \r
+Returns:\r
+    \r
+  EFI_SUCCESS           - The type has been set.\r
+  EFI_UNSUPPORTED       - This type is unsupported.\r
+\r
+    \r
+--*/\r
+{\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
+EFI_STATUS\r
+CustomizedGetInfo (\r
+  IN      VOID    *Source,\r
+  IN      UINT32  SrcSize,\r
+  OUT     UINT32  *DstSize,\r
+  OUT     UINT32  *ScratchSize\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+The implementation of Customized GetInfo().\r
+\r
+Arguments:\r
+  Source      - The source buffer containing the compressed data.\r
+  SrcSize     - The size of source buffer\r
+  DstSize     - The size of destination buffer.\r
+  ScratchSize - The size of scratch buffer.\r
+    \r
+Returns:\r
+    \r
+  EFI_SUCCESS           - The size of destination buffer and the size of scratch buffer are successull retrieved.\r
+  EFI_INVALID_PARAMETER - The source data is corrupted\r
+  EFI_UNSUPPORTED       - The operation is unsupported.\r
+\r
+    \r
+--*/\r
+{\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
+EFI_STATUS\r
+CustomizedDecompress (\r
+  IN      VOID    *Source,\r
+  IN      UINT32  SrcSize,\r
+  IN OUT  VOID    *Destination,\r
+  IN      UINT32  DstSize,\r
+  IN OUT  VOID    *Scratch,\r
+  IN      UINT32  ScratchSize\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  The implementation of Customized Decompress().\r
+\r
+Arguments:\r
+\r
+  This        - The protocol instance pointer\r
+  Source      - The source buffer containing the compressed data.\r
+  SrcSize     - The size of source buffer\r
+  Destination - The destination buffer to store the decompressed data\r
+  DstSize     - The size of destination buffer.\r
+  Scratch     - The buffer used internally by the decompress routine. This  buffer is needed to store intermediate data.\r
+  ScratchSize - The size of scratch buffer.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS           - Decompression is successfull\r
+  EFI_INVALID_PARAMETER - The source data is corrupted\r
+  EFI_UNSUPPORTED       - The operation is unsupported.\r
+\r
+--*/\r
+{\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
+EFI_STATUS\r
+CustomizedCompress (\r
+  IN      UINT8   *SrcBuffer,\r
+  IN      UINT32  SrcSize,\r
+  IN      UINT8   *DstBuffer,\r
+  IN OUT  UINT32  *DstSize\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  The Customized compression routine.\r
+\r
+Arguments:\r
+\r
+  SrcBuffer   - The buffer storing the source data\r
+  SrcSize     - The size of source data\r
+  DstBuffer   - The buffer to store the compressed data\r
+  DstSize     - On input, the size of DstBuffer; On output,\r
+                the size of the actual compressed data.\r
+\r
+Returns:\r
+\r
+  EFI_BUFFER_TOO_SMALL  - The DstBuffer is too small. In this case,\r
+                DstSize contains the size needed.\r
+  EFI_SUCCESS           - Compression is successful.\r
+\r
+  EFI_UNSUPPORTED       - The operation is unsupported.\r
+--*/\r
+{\r
+  return EFI_UNSUPPORTED;\r
+}\r
diff --git a/Tools/CodeTools/Source/CustomizedCompress/build.xml b/Tools/CodeTools/Source/CustomizedCompress/build.xml
new file mode 100644 (file)
index 0000000..4664a95
--- /dev/null
@@ -0,0 +1,75 @@
+<?xml version="1.0" ?>\r
+<!--\r
+Copyright (c) 2006, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+-->\r
+<project default="GenLib" basedir="." name="CustomizedCompressLibrary">\r
+<!--\r
+    EDK Customized Compress Library\r
+  Copyright (c) 2006, Intel Corporation\r
+-->\r
+\r
+  <taskdef resource="cpptasks.tasks"/>\r
+  <typedef resource="cpptasks.types"/>\r
+  <taskdef resource="net/sf/antcontrib/antlib.xml"/>\r
+\r
+  <property name="LibName" value="CustomizedCompress"/>\r
+  <property name="LINK_OUTPUT_TYPE" value="static"/>\r
+  <property name="BUILD_DIR" value="${PACKAGE_DIR}/CustomizedCompress/tmp"/>\r
+\r
+  <target name="GenLib" depends="init, CustomizedCompress">\r
+    <echo message="The EDK Tool Library ${LibName} build has completed!"/>\r
+  </target>\r
+\r
+  <target name="init">\r
+    <echo message="Building the EDK Tool Library: ${LibName}"/>\r
+    <mkdir dir="${BUILD_DIR}"/>\r
+  </target>\r
+\r
+  <target name="CustomizedCompress" depends="init">\r
+    <cc name="${ToolChain}" objdir="${BUILD_DIR}" \r
+        outfile="${LIB_DIR}/${LibName}"\r
+        outtype="static"\r
+        debug="true"\r
+        optimize="speed">\r
+\r
+      <fileset dir="${basedir}/CustomizedCompress" \r
+        includes="*.c" \r
+        defaultexcludes="TRUE" \r
+        excludes="*.xml *.inf"/>\r
+\r
+      <includepath path="${PACKAGE_DIR}/Include"/>\r
+      <includepath path="${PACKAGE_DIR}/Include/Ia32"/>\r
+    </cc>\r
+    <if>\r
+      <istrue value="msft"/>\r
+      <then>\r
+        <exec dir="${BUILD_DIR}" executable="lib" failonerror="false">\r
+          <arg line="/NOLOGO *.lib /OUT:${LIB_DIR}/CustomizedCompress${ext_static}"/>\r
+        </exec>\r
+      </then>\r
+    </if>\r
+  </target>\r
+\r
+  <target name="clean">\r
+    <echo message="Removing Intermediate Files Only"/>  \r
+    <delete>\r
+      <fileset dir="${BUILD_DIR}" includes="*.obj"/>\r
+    </delete>\r
+  </target>\r
+\r
+  <target name="cleanall">\r
+    <echo message="Removing Object Files and the Library: ${LibName}${ext_static}"/>  \r
+    <delete failonerror="false" quiet="true" includeEmptyDirs="true">\r
+      <fileset dir="${BUILD_DIR}"/>\r
+      <fileset file="${LIB_DIR}/${LibName}${ext_static}"/>\r
+    </delete>\r
+  </target>\r
+\r
+</project>\r
diff --git a/Tools/CodeTools/Source/EfiCompress/EfiCompressMain.c b/Tools/CodeTools/Source/EfiCompress/EfiCompressMain.c
new file mode 100644 (file)
index 0000000..492210f
--- /dev/null
@@ -0,0 +1,165 @@
+/*++\r
+\r
+Copyright (c)  1999-2006 Intel Corporation. All rights reserved\r
+This program and the accompanying materials are licensed and made available \r
+under the terms and conditions of the BSD License which accompanies this \r
+distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+\r
+Module Name:\r
+  \r
+  EfiCompressMain.c\r
+\r
+Abstract:\r
+\r
+  The main function for the compression utility.\r
+  \r
+--*/\r
+\r
+#include <stdlib.h>\r
+#include <string.h>\r
+#include <ctype.h>\r
+#include <stdarg.h>\r
+#include <stdio.h>\r
+\r
+#include <Common/UefiBaseTypes.h>\r
+\r
+#include "EfiCompress.h"\r
+\r
+int\r
+main (\r
+  INT32 argc,\r
+  CHAR8 *argv[]\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Compresses the input files\r
+\r
+Arguments:\r
+\r
+  argc   - number of arguments passed into the command line.\r
+  argv[] - files to compress and files to output compressed data to.\r
+\r
+Returns:\r
+\r
+  int: 0 for successful execution of the function.\r
+\r
+--*/\r
+{\r
+  EFI_STATUS  Status;\r
+  FILE        *infile;\r
+  FILE        *outfile;\r
+  UINT32      SrcSize;\r
+  UINT32      DstSize;\r
+  UINT8       *SrcBuffer;\r
+  UINT8       *DstBuffer;\r
+  UINT8       Buffer[8];\r
+\r
+  //\r
+  //  Added for makefile debug - KCE\r
+  //\r
+  INT32       arg_counter;\r
+  printf ("\n\n");\r
+  for (arg_counter = 0; arg_counter < argc; arg_counter++) {\r
+    printf ("%s ", argv[arg_counter]);\r
+  }\r
+\r
+  printf ("\n\n");\r
+\r
+  SrcBuffer             = DstBuffer = NULL;\r
+\r
+  infile                = outfile = NULL;\r
+\r
+  if (argc != 3) {\r
+    printf ("Usage: EFICOMPRESS <infile> <outfile>\n");\r
+    goto Done;\r
+  }\r
+\r
+  if ((outfile = fopen (argv[2], "wb")) == NULL) {\r
+    printf ("Can't open output file\n");\r
+    goto Done;\r
+  }\r
+\r
+  if ((infile = fopen (argv[1], "rb")) == NULL) {\r
+    printf ("Can't open input file\n");\r
+    goto Done;\r
+  }\r
+  //\r
+  // Get the size of source file\r
+  //\r
+  SrcSize = 0;\r
+  while (fread (Buffer, 1, 1, infile)) {\r
+    SrcSize++;\r
+\r
+  }\r
+  //\r
+  // Read in the source data\r
+  //\r
+  if ((SrcBuffer = malloc (SrcSize)) == NULL) {\r
+    printf ("Can't allocate memory\n");\r
+    goto Done;\r
+  }\r
+\r
+  rewind (infile);\r
+  if (fread (SrcBuffer, 1, SrcSize, infile) != SrcSize) {\r
+    printf ("Can't read from source\n");\r
+    goto Done;\r
+  }\r
+  //\r
+  // Get destination data size and do the compression\r
+  //\r
+  DstSize = 0;\r
+  Status  = Compress (SrcBuffer, SrcSize, DstBuffer, &DstSize);\r
+  if (Status == EFI_BUFFER_TOO_SMALL) {\r
+    if ((DstBuffer = malloc (DstSize)) == NULL) {\r
+      printf ("Can't allocate memory\n");\r
+      goto Done;\r
+    }\r
+\r
+    Status = Compress (SrcBuffer, SrcSize, DstBuffer, &DstSize);\r
+  }\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    printf ("Compress Error\n");\r
+    goto Done;\r
+  }\r
+\r
+  printf ("\nOrig Size = %ld\n", SrcSize);\r
+  printf ("Comp Size = %ld\n", DstSize);\r
+\r
+  if (DstBuffer == NULL) {\r
+    printf ("No destination to write to.\n");\r
+    goto Done;\r
+  }\r
+  //\r
+  // Write out the result\r
+  //\r
+  if (fwrite (DstBuffer, 1, DstSize, outfile) != DstSize) {\r
+    printf ("Can't write to destination file\n");\r
+  }\r
+\r
+Done:\r
+  if (SrcBuffer) {\r
+    free (SrcBuffer);\r
+  }\r
+\r
+  if (DstBuffer) {\r
+    free (DstBuffer);\r
+  }\r
+\r
+  if (infile) {\r
+    fclose (infile);\r
+  }\r
+\r
+  if (outfile) {\r
+    fclose (outfile);\r
+  }\r
+\r
+  return 0;\r
+}\r
diff --git a/Tools/CodeTools/Source/EfiCompress/build.xml b/Tools/CodeTools/Source/EfiCompress/build.xml
new file mode 100644 (file)
index 0000000..94f6055
--- /dev/null
@@ -0,0 +1,70 @@
+<?xml version="1.0" ?>\r
+<!--\r
+Copyright (c) 2006, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+-->\r
+<project default="GenTool" basedir=".">\r
+<!--\r
+    EDK EfiCompress Tool\r
+  Copyright (c) 2006, Intel Corporation\r
+-->\r
+  <property name="ToolName" value="EfiCompress"/>\r
+  <property name="FileSet" value="*.c"/>\r
+\r
+  <taskdef resource="cpptasks.tasks"/>\r
+  <typedef resource="cpptasks.types"/>\r
+  <taskdef resource="net/sf/antcontrib/antlib.xml"/>\r
+\r
+  <property name="LINK_OUTPUT_TYPE" value="static"/>\r
+  <property name="BUILD_DIR" value="${PACKAGE_DIR}/${ToolName}/tmp"/>\r
+\r
+  <target name="GenTool" depends="init, Tool">\r
+    <echo message="The EDK Tool: ${ToolName} build has completed!"/>\r
+  </target>\r
+\r
+  <target name="init">\r
+    <echo message="Building the EDK Tool: ${ToolName}"/>\r
+    <mkdir dir="${BUILD_DIR}"/>\r
+  </target>\r
+\r
+  <target name="Tool" depends="init">\r
+    <cc name="${ToolChain}" objdir="${BUILD_DIR}" \r
+        outfile="${BIN_DIR}/${ToolName}"\r
+        outtype="executable"\r
+        optimize="speed" \r
+        debug="true">\r
+\r
+      <fileset dir="${basedir}/${ToolName}" \r
+        includes="${FileSet}" \r
+        defaultexcludes="TRUE" \r
+        excludes="*.xml *.inf"/>\r
+\r
+      <includepath path="${PACKAGE_DIR}/Include"/>\r
+      <includepath path="${PACKAGE_DIR}/Include/${HostArch}"/>\r
+      <includepath path="${PACKAGE_DIR}/Common"/>\r
+      <libset dir="${LIB_DIR}" libs="CommonTools"/>\r
+    </cc>\r
+  </target>\r
+\r
+  <target name="clean">\r
+    <echo message="Removing Intermediate Files Only"/>  \r
+    <delete>\r
+      <fileset dir="${BUILD_DIR}" includes="*.obj"/>\r
+    </delete>\r
+  </target>\r
+\r
+  <target name="cleanall">\r
+    <echo message="Removing Object Files and the Executable: ${ToolName}${ext_exe}"/>  \r
+    <delete failonerror="false" quiet="true" includeEmptyDirs="true">\r
+      <fileset dir="${BUILD_DIR}"/>\r
+      <fileset file="${BIN_DIR}/${ToolName}${ext_exe}"/>\r
+    </delete>\r
+  </target>\r
+\r
+</project>\r
diff --git a/Tools/CodeTools/Source/EfiRom/EfiRom.c b/Tools/CodeTools/Source/EfiRom/EfiRom.c
new file mode 100644 (file)
index 0000000..2cc478b
--- /dev/null
@@ -0,0 +1,1536 @@
+/*++\r
+\r
+Copyright (c)  1999-2006 Intel Corporation. All rights reserved\r
+This program and the accompanying materials are licensed and made available \r
+under the terms and conditions of the BSD License which accompanies this \r
+distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+Module Name:\r
+\r
+  EfiRom.c\r
+  \r
+Abstract:\r
+\r
+  Utility program to create an EFI option ROM image from binary and \r
+  EFI PE32 files.\r
+\r
+\r
+--*/\r
+\r
+#include <stdio.h>\r
+#include <string.h>\r
+#include <stdlib.h>\r
+\r
+#include <Common/UefiBaseTypes.h>\r
+#include <Common/EfiImage.h>  // for PE32 structure definitions\r
+#include <Common/MultiPhase.h>\r
+\r
+#include <IndustryStandard/pci22.h>  // for option ROM header structures\r
+\r
+#include "EfiCompress.h"\r
+#include "CommonLib.h"\r
+\r
+//\r
+// Version of this utility\r
+//\r
+#define UTILITY_VERSION "v2.5"\r
+\r
+//\r
+// Define some status return values\r
+//\r
+#define STATUS_SUCCESS  0\r
+#define STATUS_WARNING  1\r
+#define STATUS_ERROR    2\r
+\r
+//\r
+// Define the max length of a filename\r
+//\r
+#define MAX_PATH                  200\r
+\r
+#define DEFAULT_OUTPUT_EXTENSION  ".rom"\r
+\r
+//\r
+// Max size for an option ROM image\r
+//\r
+#define MAX_OPTION_ROM_SIZE (1024 * 1024 * 16)  // 16MB\r
+//\r
+// Values for the indicator field in the PCI data structure\r
+//\r
+#define INDICATOR_LAST  0x80  // last file in series of files\r
+//\r
+// Masks for the FILE_LIST.FileFlags field\r
+//\r
+#define FILE_FLAG_BINARY    0x01\r
+#define FILE_FLAG_EFI       0x02\r
+#define FILE_FLAG_COMPRESS  0x04\r
+\r
+//\r
+// Use this linked list structure to keep track of all the filenames\r
+// specified on the command line.\r
+//\r
+typedef struct _FILE_LIST {\r
+  struct _FILE_LIST *Next;\r
+  INT8              *FileName;\r
+  UINT32            FileFlags;\r
+  UINT32            ClassCode;\r
+  UINT16            CodeRevision;\r
+} FILE_LIST;\r
+\r
+//\r
+// Use this to track our command-line options\r
+//\r
+typedef struct {\r
+  INT8      OutFileName[MAX_PATH];\r
+  INT8      NoLast;\r
+  INT8      Verbose;\r
+  INT8      DumpOption;\r
+  UINT8     DevIdValid;\r
+  UINT8     VendIdValid;\r
+  UINT16    VendId;\r
+  UINT16    DevId;\r
+  FILE_LIST *FileList;\r
+} OPTIONS;\r
+\r
+//\r
+// Make a global structure to keep track of command-line options\r
+//\r
+static OPTIONS  mOptions;\r
+\r
+//\r
+// Use these to convert from machine type value to a named type\r
+//\r
+typedef struct {\r
+  UINT16  Value;\r
+  char    *Name;\r
+} STRING_LOOKUP;\r
+\r
+static STRING_LOOKUP  mMachineTypes[] = {\r
+  EFI_IMAGE_MACHINE_IA32,\r
+  "IA32",\r
+  EFI_IMAGE_MACHINE_IA64,\r
+  "IA64",\r
+  EFI_IMAGE_MACHINE_EBC,\r
+  "EBC",\r
+  0,\r
+  NULL\r
+};\r
+\r
+static STRING_LOOKUP  mSubsystemTypes[] = {\r
+  EFI_IMAGE_SUBSYSTEM_EFI_APPLICATION,\r
+  "EFI application",\r
+  EFI_IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER,\r
+  "EFI boot service driver",\r
+  EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER,\r
+  "EFI runtime driver",\r
+  0,\r
+  NULL\r
+};\r
+//\r
+//  Function prototypes\r
+//\r
+static\r
+void\r
+Usage (\r
+  VOID\r
+  );\r
+\r
+static\r
+int\r
+ParseCommandLine (\r
+  int       Argc,\r
+  char      *Argv[],\r
+  OPTIONS   *Options\r
+  );\r
+\r
+static\r
+int\r
+CheckPE32File (\r
+  FILE      *Fptr,\r
+  UINT16    *MachineType,\r
+  UINT16    *SubSystem\r
+  );\r
+\r
+static\r
+int\r
+ProcessEfiFile (\r
+  FILE      *OutFptr,\r
+  FILE_LIST *InFile,\r
+  UINT16    VendId,\r
+  UINT16    DevId,\r
+  UINT32    *Size\r
+  );\r
+\r
+static\r
+int\r
+ProcessBinFile (\r
+  FILE      *OutFptr,\r
+  FILE_LIST *InFile,\r
+  UINT32    *Size\r
+  );\r
+\r
+static\r
+void\r
+DumpImage (\r
+  FILE_LIST *InFile\r
+  );\r
+\r
+char                  *\r
+GetMachineTypeStr (\r
+  UINT16    MachineType\r
+  );\r
+\r
+static\r
+char                  *\r
+GetSubsystemTypeStr (\r
+  UINT16  SubsystemType\r
+  );\r
+\r
+main (\r
+  int   Argc,\r
+  char  *Argv[]\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  Given an EFI image filename, create a ROM-able image by creating an option \r
+  ROM header and PCI data structure, filling them in, and then writing the\r
+  option ROM header + PCI data structure + EFI image out to the output file.\r
+\r
+Arguments:\r
+\r
+  Argc            - standard C main() argument count\r
+\r
+  Argv            - standard C main() argument list\r
+\r
+Returns:\r
+\r
+  0             success\r
+  non-zero      otherwise\r
+\r
+--*/\r
+// GC_TODO:    ] - add argument and description to function comment\r
+{\r
+  INT8      *Ext;\r
+  FILE      *FptrOut;\r
+  UINT32    Status;\r
+  FILE_LIST *FList;\r
+  UINT32    TotalSize;\r
+  UINT32    Size;\r
+\r
+  Status  = STATUS_SUCCESS;\r
+  FptrOut = NULL;\r
+\r
+  //\r
+  // Parse the command line arguments\r
+  //\r
+  if (ParseCommandLine (Argc, Argv, &mOptions)) {\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // If dumping an image, then do that and quit\r
+  //\r
+  if (mOptions.DumpOption) {\r
+    DumpImage (mOptions.FileList);\r
+    goto BailOut;\r
+  }\r
+  //\r
+  // Determine the output filename. Either what they specified on\r
+  // the command line, or the first input filename with a different extension.\r
+  //\r
+  if (!mOptions.OutFileName[0]) {\r
+    strcpy (mOptions.OutFileName, mOptions.FileList->FileName);\r
+    //\r
+    // Find the last . on the line and replace the filename extension with\r
+    // the default\r
+    //\r
+    for (Ext = mOptions.OutFileName + strlen (mOptions.OutFileName) - 1;\r
+         (Ext >= mOptions.OutFileName) && (*Ext != '.') && (*Ext != '\\');\r
+         Ext--\r
+        )\r
+      ;\r
+    //\r
+    // If dot here, then insert extension here, otherwise append\r
+    //\r
+    if (*Ext != '.') {\r
+      Ext = mOptions.OutFileName + strlen (mOptions.OutFileName);\r
+    }\r
+\r
+    strcpy (Ext, DEFAULT_OUTPUT_EXTENSION);\r
+  }\r
+  //\r
+  // Make sure we don't have the same filename for input and output files\r
+  //\r
+  for (FList = mOptions.FileList; FList != NULL; FList = FList->Next) {\r
+    if (stricmp (mOptions.OutFileName, FList->FileName) == 0) {\r
+      Status = STATUS_ERROR;\r
+      fprintf (\r
+        stdout,\r
+        "ERROR: Input and output file names must be different - %s = %s\n",\r
+        FList->FileName,\r
+        mOptions.OutFileName\r
+        );\r
+      goto BailOut;\r
+    }\r
+  }\r
+  //\r
+  // Now open our output file\r
+  //\r
+  if ((FptrOut = fopen (mOptions.OutFileName, "w+b")) == NULL) {\r
+    fprintf (stdout, "ERROR: Failed to open output file %s\n", mOptions.OutFileName);\r
+    goto BailOut;\r
+  }\r
+  //\r
+  // Process all our files\r
+  //\r
+  TotalSize = 0;\r
+  for (FList = mOptions.FileList; FList != NULL; FList = FList->Next) {\r
+    Size = 0;\r
+    if (FList->FileFlags & FILE_FLAG_EFI) {\r
+      if (mOptions.Verbose) {\r
+        fprintf (stdout, "Processing EFI file    %s\n", FList->FileName);\r
+      }\r
+\r
+      Status = ProcessEfiFile (FptrOut, FList, mOptions.VendId, mOptions.DevId, &Size);\r
+    } else if (FList->FileFlags & FILE_FLAG_BINARY) {\r
+      if (mOptions.Verbose) {\r
+        fprintf (stdout, "Processing binary file %s\n", FList->FileName);\r
+      }\r
+\r
+      Status = ProcessBinFile (FptrOut, FList, &Size);\r
+    } else {\r
+      fprintf (stdout, "ERROR: File not specified as EFI or binary: %s\n", FList->FileName);\r
+      Status = STATUS_ERROR;\r
+    }\r
+\r
+    if (mOptions.Verbose) {\r
+      fprintf (stdout, "  Output size = 0x%X\n", Size);\r
+    }\r
+\r
+    if (Status != STATUS_SUCCESS) {\r
+      break;\r
+    }\r
+\r
+    TotalSize += Size;\r
+  }\r
+  //\r
+  // Check total size\r
+  //\r
+  if (TotalSize > MAX_OPTION_ROM_SIZE) {\r
+    fprintf (\r
+      stdout,\r
+      "ERROR: Option ROM image size exceeds limit 0x%X bytes\n",\r
+      MAX_OPTION_ROM_SIZE\r
+      );\r
+    Status = STATUS_ERROR;\r
+  }\r
+\r
+BailOut:\r
+  if (FptrOut != NULL) {\r
+    fclose (FptrOut);\r
+  }\r
+  //\r
+  // Clean up our file list\r
+  //\r
+  while (mOptions.FileList != NULL) {\r
+    FList = mOptions.FileList->Next;\r
+    free (mOptions.FileList);\r
+    mOptions.FileList = FList;\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
+static\r
+int\r
+ProcessBinFile (\r
+  FILE      *OutFptr,\r
+  FILE_LIST *InFile,\r
+  UINT32    *Size\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  Process a binary input file.\r
+\r
+Arguments:\r
+\r
+  OutFptr     - file pointer to output binary ROM image file we're creating\r
+  InFile      - structure contains information on the binary file to process\r
+  Size        - pointer to where to return the size added to the output file\r
+\r
+Returns:\r
+\r
+  0 - successful\r
+\r
+--*/\r
+{\r
+  FILE                      *InFptr;\r
+  UINT32                    TotalSize;\r
+  UINT32                    FileSize;\r
+  UINT8                     *Buffer;\r
+  UINT32                    Status;\r
+  PCI_EXPANSION_ROM_HEADER  *RomHdr;\r
+  PCI_DATA_STRUCTURE        *PciDs;\r
+  UINT32                    Index;\r
+  UINT8                     ByteCheckSum;\r
+\r
+  Status = STATUS_SUCCESS;\r
+\r
+  //\r
+  // Try to open the input file\r
+  //\r
+  if ((InFptr = fopen (InFile->FileName, "rb")) == NULL) {\r
+    fprintf (stdout, "ERROR: Failed to open input file %s\n", InFile->FileName);\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Seek to the end of the input file and get the file size. Then allocate\r
+  // a buffer to read it in to.\r
+  //\r
+  fseek (InFptr, 0, SEEK_END);\r
+  FileSize = ftell (InFptr);\r
+  if (mOptions.Verbose) {\r
+    fprintf (stdout, "  File size   = 0x%X\n", FileSize);\r
+  }\r
+\r
+  fseek (InFptr, 0, SEEK_SET);\r
+  Buffer = (INT8 *) malloc (FileSize);\r
+  if (Buffer == NULL) {\r
+    fprintf (stdout, "ERROR: Memory allocation failed\n");\r
+    Status = STATUS_ERROR;\r
+    goto BailOut;\r
+  }\r
+\r
+  if (fread (Buffer, FileSize, 1, InFptr) != 1) {\r
+    fprintf (stdout, "ERROR: Failed to read all bytes from input file\n");\r
+    Status = STATUS_ERROR;\r
+    goto BailOut;\r
+  }\r
+  //\r
+  // Total size must be an even multiple of 512 bytes, and can't exceed\r
+  // the option ROM image size.\r
+  //\r
+  TotalSize = FileSize;\r
+  if (TotalSize & 0x1FF) {\r
+    TotalSize = (TotalSize + 0x200) &~0x1ff;\r
+  }\r
+\r
+  if (TotalSize > MAX_OPTION_ROM_SIZE) {\r
+    fprintf (\r
+      stdout,\r
+      "ERROR: Option ROM image %s size exceeds limit 0x%X bytes\n",\r
+      InFile->FileName,\r
+      MAX_OPTION_ROM_SIZE\r
+      );\r
+    Status = STATUS_ERROR;\r
+    goto BailOut;\r
+  }\r
+  //\r
+  // Return the size to the caller so they can keep track of the running total.\r
+  //\r
+  *Size = TotalSize;\r
+\r
+  //\r
+  // Crude check to make sure it's a legitimate ROM image\r
+  //\r
+  RomHdr = (PCI_EXPANSION_ROM_HEADER *) Buffer;\r
+  if (RomHdr->Signature != PCI_EXPANSION_ROM_HEADER_SIGNATURE) {\r
+    fprintf (stdout, "ERROR: ROM image file has invalid ROM signature\n");\r
+    Status = STATUS_ERROR;\r
+    goto BailOut;\r
+  }\r
+  //\r
+  // Make sure the pointer to the PCI data structure is within the size of the image.\r
+  // Then check it for valid signature.\r
+  //\r
+  if ((RomHdr->PcirOffset > FileSize) || (RomHdr->PcirOffset == 0)) {\r
+    fprintf (stdout, "ERROR: Invalid PCI data structure offset\n");\r
+    Status = STATUS_ERROR;\r
+    goto BailOut;\r
+  }\r
+\r
+  PciDs = (PCI_DATA_STRUCTURE *) (Buffer + RomHdr->PcirOffset);\r
+  if (PciDs->Signature != PCI_DATA_STRUCTURE_SIGNATURE) {\r
+    fprintf (stdout, "ERROR: PCI data structure has invalid signature\n");\r
+    Status = STATUS_ERROR;\r
+    goto BailOut;\r
+  }\r
+  //\r
+  // If this is the last image, then set the LAST bit unless requested not\r
+  // to via the command-line -l argument. Otherwise, make sure you clear it.\r
+  //\r
+  if ((InFile->Next == NULL) && (mOptions.NoLast == 0)) {\r
+    PciDs->Indicator = INDICATOR_LAST;\r
+  } else {\r
+    PciDs->Indicator = 0;\r
+  }\r
+\r
+  ByteCheckSum = 0;\r
+  for (Index = 0; Index < FileSize - 1; Index++) {\r
+    ByteCheckSum = (UINT8) (ByteCheckSum + Buffer[Index]);\r
+  }\r
+\r
+  Buffer[FileSize - 1] = (UINT8) ((~ByteCheckSum) + 1);\r
+  fprintf (stdout, "CheckSUm = %02x\n", (UINT32) Buffer[FileSize - 1]);\r
+\r
+  //\r
+  // Now copy the input file contents out to the output file\r
+  //\r
+  if (fwrite (Buffer, FileSize, 1, OutFptr) != 1) {\r
+    fprintf (stdout, "ERROR: Failed to write all file bytes to output file\n");\r
+    Status = STATUS_ERROR;\r
+    goto BailOut;\r
+  }\r
+\r
+  TotalSize -= FileSize;\r
+  //\r
+  // Pad the rest of the image to make it a multiple of 512 bytes\r
+  //\r
+  while (TotalSize > 0) {\r
+    putc (~0, OutFptr);\r
+    TotalSize--;\r
+  }\r
+\r
+BailOut:\r
+  if (InFptr != NULL) {\r
+    fclose (InFptr);\r
+  }\r
+\r
+  if (Buffer != NULL) {\r
+    free (Buffer);\r
+  }\r
+  //\r
+  // Print the file name if errors occurred\r
+  //\r
+  if (Status != STATUS_SUCCESS) {\r
+    fprintf (stdout, "Error processing binary file %s\n", InFile->FileName);\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
+static\r
+int\r
+ProcessEfiFile (\r
+  FILE      *OutFptr,\r
+  FILE_LIST *InFile,\r
+  UINT16    VendId,\r
+  UINT16    DevId,\r
+  UINT32    *Size\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  Process a PE32 EFI file.\r
+\r
+Arguments:\r
+\r
+  OutFptr     - file pointer to output binary ROM image file we're creating\r
+  InFile      - structure contains information on the PE32 file to process\r
+  VendId      - vendor ID as required in the option ROM header\r
+  DevId       - device ID as required in the option ROM header\r
+  Size        - pointer to where to return the size added to the output file\r
+\r
+Returns:\r
+\r
+  0 - successful\r
+\r
+--*/\r
+{\r
+  UINT32                        Status;\r
+  FILE                          *InFptr;\r
+  EFI_PCI_EXPANSION_ROM_HEADER  RomHdr;\r
+  PCI_DATA_STRUCTURE            PciDs;\r
+  UINT32                        FileSize;\r
+  UINT32                        CompressedFileSize;\r
+  UINT8                         *Buffer;\r
+  UINT8                         *CompressedBuffer;\r
+  UINT8                         *TempBufferPtr;\r
+  UINT32                        TotalSize;\r
+  UINT32                        HeaderSize;\r
+  UINT16                        MachineType;\r
+  UINT16                        SubSystem;\r
+  UINT32                        HeaderPadBytes;\r
+\r
+  //\r
+  // Try to open the input file\r
+  //\r
+  if ((InFptr = fopen (InFile->FileName, "rb")) == NULL) {\r
+    fprintf (stdout, "ERROR: Failed to open input file %s\n", InFile->FileName);\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Initialize our buffer pointers to null.\r
+  //\r
+  Buffer            = NULL;\r
+  CompressedBuffer  = NULL;\r
+\r
+  //\r
+  // Double-check the file to make sure it's what we expect it to be\r
+  //\r
+  Status = CheckPE32File (InFptr, &MachineType, &SubSystem);\r
+  if (Status != STATUS_SUCCESS) {\r
+    goto BailOut;\r
+  }\r
+  //\r
+  // Seek to the end of the input file and get the file size\r
+  //\r
+  fseek (InFptr, 0, SEEK_END);\r
+  FileSize = ftell (InFptr);\r
+\r
+  //\r
+  // Get the size of the headers we're going to put in front of the image. The\r
+  // EFI header must be aligned on a 4-byte boundary, so pad accordingly.\r
+  //\r
+  if (sizeof (RomHdr) & 0x03) {\r
+    HeaderPadBytes = 4 - (sizeof (RomHdr) & 0x03);\r
+  } else {\r
+    HeaderPadBytes = 0;\r
+  }\r
+\r
+  HeaderSize = sizeof (PCI_DATA_STRUCTURE) + HeaderPadBytes + sizeof (EFI_PCI_EXPANSION_ROM_HEADER);\r
+  if (mOptions.Verbose) {\r
+    fprintf (stdout, "  File size   = 0x%X\n", FileSize);\r
+  }\r
+  //\r
+  // Allocate memory for the entire file (in case we have to compress), then\r
+  // seek back to the beginning of the file and read it into our buffer.\r
+  //\r
+  Buffer = (INT8 *) malloc (FileSize);\r
+  if (Buffer == NULL) {\r
+    fprintf (stdout, "ERROR: Memory allocation failed\n");\r
+    Status = STATUS_ERROR;\r
+    goto BailOut;\r
+  }\r
+\r
+  fseek (InFptr, 0, SEEK_SET);\r
+  if (fread (Buffer, FileSize, 1, InFptr) != 1) {\r
+    fprintf (stdout, "ERROR: Failed to read all bytes from input file\n");\r
+    Status = STATUS_ERROR;\r
+    goto BailOut;\r
+  }\r
+  //\r
+  // Now determine the size of the final output file. It's either the header size\r
+  // plus the file's size, or the header size plus the compressed file size.\r
+  //\r
+  if (InFile->FileFlags & FILE_FLAG_COMPRESS) {\r
+    //\r
+    // Allocate a buffer into which we can compress the image, compress it,\r
+    // and use that size as the new size.\r
+    //\r
+    CompressedBuffer = (INT8 *) malloc (FileSize);\r
+    if (CompressedBuffer == NULL) {\r
+      fprintf (stdout, "ERROR: Memory allocation failed\n");\r
+      Status = STATUS_ERROR;\r
+      goto BailOut;\r
+    }\r
+\r
+    CompressedFileSize  = FileSize;\r
+    Status              = Compress (Buffer, FileSize, CompressedBuffer, &CompressedFileSize);\r
+    if (Status != STATUS_SUCCESS) {\r
+      fprintf (stdout, "ERROR: Compression failed\n");\r
+      goto BailOut;\r
+    }\r
+    //\r
+    // Now compute the size, then swap buffer pointers.\r
+    //\r
+    if (mOptions.Verbose) {\r
+      fprintf (stdout, "  Comp size   = 0x%X\n", CompressedFileSize);\r
+    }\r
+\r
+    TotalSize         = CompressedFileSize + HeaderSize;\r
+    FileSize          = CompressedFileSize;\r
+    TempBufferPtr     = Buffer;\r
+    Buffer            = CompressedBuffer;\r
+    CompressedBuffer  = TempBufferPtr;\r
+  } else {\r
+    TotalSize = FileSize + HeaderSize;\r
+  }\r
+  //\r
+  // Total size must be an even multiple of 512 bytes\r
+  //\r
+  if (TotalSize & 0x1FF) {\r
+    TotalSize = (TotalSize + 0x200) &~0x1ff;\r
+  }\r
+  //\r
+  // Check size\r
+  //\r
+  if (TotalSize > MAX_OPTION_ROM_SIZE) {\r
+    fprintf (\r
+      stdout,\r
+      "ERROR: Option ROM image %s size exceeds limit 0x%X bytes\n",\r
+      InFile->FileName,\r
+      MAX_OPTION_ROM_SIZE\r
+      );\r
+    Status = STATUS_ERROR;\r
+    goto BailOut;\r
+  }\r
+  //\r
+  // Return the size to the caller so they can keep track of the running total.\r
+  //\r
+  *Size = TotalSize;\r
+\r
+  //\r
+  // Now fill in the ROM header. These values come from chapter 18 of the\r
+  // EFI 1.02 specification.\r
+  //\r
+  memset (&RomHdr, 0, sizeof (RomHdr));\r
+  RomHdr.Signature            = PCI_EXPANSION_ROM_HEADER_SIGNATURE;\r
+  RomHdr.InitializationSize   = (UINT16) (TotalSize / 512);\r
+  RomHdr.EfiSignature         = EFI_PCI_EXPANSION_ROM_HEADER_EFISIGNATURE;\r
+  RomHdr.EfiSubsystem         = SubSystem;\r
+  RomHdr.EfiMachineType       = MachineType;\r
+  RomHdr.EfiImageHeaderOffset = (UINT16) HeaderSize;\r
+  RomHdr.PcirOffset           = (UINT16) (sizeof (RomHdr) + HeaderPadBytes);\r
+  //\r
+  // Set image as compressed or not\r
+  //\r
+  if (InFile->FileFlags & FILE_FLAG_COMPRESS) {\r
+    RomHdr.CompressionType = EFI_PCI_EXPANSION_ROM_HEADER_COMPRESSED;\r
+  }\r
+  //\r
+  // Fill in the PCI data structure\r
+  //\r
+  memset (&PciDs, 0, sizeof (PCI_DATA_STRUCTURE));\r
+\r
+  PciDs.Signature = PCI_DATA_STRUCTURE_SIGNATURE;\r
+  PciDs.VendorId  = VendId;\r
+  PciDs.DeviceId  = DevId;\r
+  PciDs.Length    = (UINT16) sizeof (PCI_DATA_STRUCTURE);\r
+  PciDs.Revision  = 0;\r
+  //\r
+  // Class code and code revision from the command line (optional)\r
+  //\r
+  PciDs.ClassCode[0]  = (UINT8) InFile->ClassCode;\r
+  PciDs.ClassCode[1]  = (UINT8) (InFile->ClassCode >> 8);\r
+  PciDs.ClassCode[2]  = (UINT8) (InFile->ClassCode >> 16);\r
+  PciDs.ImageLength   = RomHdr.InitializationSize;\r
+  PciDs.CodeRevision  = InFile->CodeRevision;\r
+  PciDs.CodeType      = PCI_CODE_TYPE_EFI_IMAGE;\r
+\r
+  //\r
+  // If this is the last image, then set the LAST bit unless requested not\r
+  // to via the command-line -l argument.\r
+  //\r
+  if ((InFile->Next == NULL) && (mOptions.NoLast == 0)) {\r
+    PciDs.Indicator = INDICATOR_LAST;\r
+  }\r
+  //\r
+  // Write the ROM header to the output file\r
+  //\r
+  if (fwrite (&RomHdr, sizeof (RomHdr), 1, OutFptr) != 1) {\r
+    fprintf (stdout, "ERROR: Failed to write ROM header to output file\n");\r
+    Status = STATUS_ERROR;\r
+    goto BailOut;\r
+  }\r
+\r
+  //\r
+  // Write pad bytes to align the PciDs\r
+  //\r
+  while (HeaderPadBytes > 0) {\r
+    if (putc (0, OutFptr) == EOF) {\r
+      fprintf (stdout, "ERROR: Failed to write ROM header pad bytes to output file\n");\r
+      Status = STATUS_ERROR;\r
+      goto BailOut;\r
+    }\r
+\r
+    HeaderPadBytes--;\r
+  }\r
+  //\r
+  // Write the PCI data structure header to the output file\r
+  //\r
+  if (fwrite (&PciDs, sizeof (PciDs), 1, OutFptr) != 1) {\r
+    fprintf (stdout, "ERROR: Failed to write PCI ROM header to output file\n");\r
+    Status = STATUS_ERROR;\r
+    goto BailOut;\r
+  }\r
+  //\r
+  // Keep track of how many bytes left to write\r
+  //\r
+  TotalSize -= HeaderSize;\r
+\r
+  //\r
+  // Now dump the input file's contents to the output file\r
+  //\r
+  if (fwrite (Buffer, FileSize, 1, OutFptr) != 1) {\r
+    fprintf (stdout, "ERROR: Failed to write all file bytes to output file\n");\r
+    Status = STATUS_ERROR;\r
+    goto BailOut;\r
+  }\r
+\r
+  TotalSize -= FileSize;\r
+  //\r
+  // Pad the rest of the image to make it a multiple of 512 bytes\r
+  //\r
+  while (TotalSize > 0) {\r
+    if (putc (~0, OutFptr) == EOF) {\r
+      fprintf (stdout, "ERROR: Failed to write trailing pad bytes output file\n");\r
+      Status = STATUS_ERROR;\r
+      goto BailOut;\r
+    }\r
+\r
+    TotalSize--;\r
+  }\r
+\r
+BailOut:\r
+  if (InFptr != NULL) {\r
+    fclose (InFptr);\r
+  }\r
+\r
+  //\r
+  // Free up our buffers\r
+  //\r
+  if (Buffer != NULL) {\r
+    free (Buffer);\r
+  }\r
+\r
+  if (CompressedBuffer != NULL) {\r
+    free (CompressedBuffer);\r
+  }\r
+  //\r
+  // Print the file name if errors occurred\r
+  //\r
+  if (Status != STATUS_SUCCESS) {\r
+    fprintf (stdout, "Error processing EFI file %s\n", InFile->FileName);\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
+static\r
+int\r
+CheckPE32File (\r
+  FILE      *Fptr,\r
+  UINT16    *MachineType,\r
+  UINT16    *SubSystem\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Fptr        - GC_TODO: add argument description\r
+  MachineType - GC_TODO: add argument description\r
+  SubSystem   - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+{\r
+  /*++\r
+\r
+Routine Description:\r
+  \r
+  Given a file pointer to a supposed PE32 image file, verify that it is indeed a\r
+  PE32 image file, and then return the machine type in the supplied pointer.\r
+\r
+Arguments:\r
+\r
+  Fptr          File pointer to the already-opened PE32 file\r
+  MachineType   Location to stuff the machine type of the PE32 file. This is needed\r
+                because the image may be Itanium-based, IA32, or EBC.\r
+\r
+Returns:\r
+\r
+  0             success\r
+  non-zero      otherwise\r
+\r
+--*/\r
+  EFI_IMAGE_DOS_HEADER      DosHeader;\r
+  EFI_IMAGE_FILE_HEADER     FileHdr;\r
+  EFI_IMAGE_OPTIONAL_HEADER OptionalHdr;\r
+  UINT32                    PESig;\r
+\r
+  //\r
+  // Position to the start of the file\r
+  //\r
+  fseek (Fptr, 0, SEEK_SET);\r
+\r
+  //\r
+  // Read the DOS header\r
+  //\r
+  if (fread (&DosHeader, sizeof (DosHeader), 1, Fptr) != 1) {\r
+    fprintf (stdout, "ERROR: Failed to read the DOS stub from the input file\n");\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Check the magic number (0x5A4D)\r
+  //\r
+  if (DosHeader.e_magic != EFI_IMAGE_DOS_SIGNATURE) {\r
+    fprintf (stdout, "ERROR: Input file does not appear to be a PE32 image (magic number)\n");\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Position into the file and check the PE signature\r
+  //\r
+  fseek (Fptr, (long) DosHeader.e_lfanew, SEEK_SET);\r
+  if (fread (&PESig, sizeof (PESig), 1, Fptr) != 1) {\r
+    fprintf (stdout, "ERROR: Failed to read PE signature bytes from input file\n");\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Check the PE signature in the header "PE\0\0"\r
+  //\r
+  if (PESig != EFI_IMAGE_NT_SIGNATURE) {\r
+    fprintf (stdout, "ERROR: Input file does not appear to be a PE32 image (signature)\n");\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Read the file header and stuff their MachineType\r
+  //\r
+  if (fread (&FileHdr, sizeof (FileHdr), 1, Fptr) != 1) {\r
+    fprintf (stdout, "ERROR: Failed to read PE file header from input file\n");\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  memcpy ((char *) MachineType, &FileHdr.Machine, 2);\r
+\r
+  //\r
+  // Read the optional header so we can get the subsystem\r
+  //\r
+  if (fread (&OptionalHdr, sizeof (OptionalHdr), 1, Fptr) != 1) {\r
+    fprintf (stdout, "ERROR: Failed to read COFF optional header from input file\n");\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  *SubSystem = OptionalHdr.Subsystem;\r
+  if (mOptions.Verbose) {\r
+    fprintf (stdout, "  Got subsystem = 0x%X from image\n", (int) *SubSystem);\r
+  }\r
+  //\r
+  // Good to go\r
+  //\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+int\r
+ParseCommandLine (\r
+  int         Argc,\r
+  char        *Argv[],\r
+  OPTIONS     *Options\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  Given the Argc/Argv program arguments, and a pointer to an options structure,\r
+  parse the command-line options and check their validity.\r
+\r
+\r
+Arguments:\r
+\r
+  Argc            - standard C main() argument count\r
+  Argv[]          - standard C main() argument list\r
+  Options         - pointer to a structure to store the options in\r
+\r
+Returns:\r
+\r
+  STATUS_SUCCESS    success\r
+  non-zero          otherwise\r
+\r
+--*/\r
+//\r
+{\r
+  FILE_LIST *FileList;\r
+\r
+  FILE_LIST *PrevFileList;\r
+  UINT32    FileFlags;\r
+  UINT32    ClassCode;\r
+  UINT32    CodeRevision;\r
+\r
+  FileFlags = 0;\r
+\r
+  //\r
+  // Clear out the options\r
+  //\r
+  memset ((char *) Options, 0, sizeof (OPTIONS));\r
+\r
+  //\r
+  // To avoid compile warnings\r
+  //\r
+  FileList                = PrevFileList = NULL;\r
+\r
+  ClassCode               = 0;\r
+  CodeRevision            = 0;\r
+  //\r
+  // Skip over the program name\r
+  //\r
+  Argc--;\r
+  Argv++;\r
+\r
+  //\r
+  // If no arguments, assume they want usage info\r
+  //\r
+  if (Argc == 0) {\r
+    Usage ();\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Process until no more arguments\r
+  //\r
+  while (Argc > 0) {\r
+    if ((Argv[0][0] == '-') || (Argv[0][0] == '/')) {\r
+      //\r
+      // To simplify string comparisons, replace slashes with dashes\r
+      //\r
+      Argv[0][0] = '-';\r
+\r
+      //\r
+      // Vendor ID specified with -v\r
+      //\r
+      if (stricmp (Argv[0], "-v") == 0) {\r
+        //\r
+        // Make sure there's another parameter\r
+        //\r
+        if (Argc > 1) {\r
+          Options->VendId       = (UINT16) strtol (Argv[1], NULL, 16);\r
+          Options->VendIdValid  = 1;\r
+        } else {\r
+          fprintf (\r
+            stdout,\r
+            "ERROR: Missing Vendor ID with %s\n\n",\r
+            Argv[0]\r
+            );\r
+          Usage ();\r
+          return STATUS_ERROR;\r
+        }\r
+\r
+        Argv++;\r
+        Argc--;\r
+      } else if (stricmp (Argv[0], "-d") == 0) {\r
+        //\r
+        // Device ID specified with -d\r
+        // Make sure there's another parameter\r
+        //\r
+        if (Argc > 1) {\r
+          Options->DevId      = (UINT16) strtol (Argv[1], NULL, 16);\r
+          Options->DevIdValid = 1;\r
+        } else {\r
+          fprintf (\r
+            stdout,\r
+            "ERROR: Missing Device ID with %s\n\n",\r
+            Argv[0]\r
+            );\r
+          Usage ();\r
+          return STATUS_ERROR;\r
+        }\r
+\r
+        Argv++;\r
+        Argc--;\r
+      } else if (stricmp (Argv[0], "-o") == 0) {\r
+        //\r
+        // Output filename specified with -o\r
+        // Make sure there's another parameter\r
+        //\r
+        if (Argc > 1) {\r
+          strcpy (Options->OutFileName, Argv[1]);\r
+        } else {\r
+          fprintf (\r
+            stdout,\r
+            "ERROR: Missing output file name with %s\n\n",\r
+            Argv[0]\r
+            );\r
+          Usage ();\r
+          return STATUS_ERROR;\r
+        }\r
+\r
+        Argv++;\r
+        Argc--;\r
+      } else if ((stricmp (Argv[0], "-h") == 0) || (strcmp (Argv[0], "-?") == 0)) {\r
+        //\r
+        // Help option\r
+        //\r
+        Usage ();\r
+        return STATUS_ERROR;\r
+      } else if (stricmp (Argv[0], "-b") == 0) {\r
+        //\r
+        // Specify binary files with -b\r
+        //\r
+        FileFlags = (FileFlags &~FILE_FLAG_EFI) | FILE_FLAG_BINARY;\r
+      } else if ((stricmp (Argv[0], "-e") == 0) || (stricmp (Argv[0], "-ec") == 0)) {\r
+        //\r
+        // Specify EFI files with -e. Specify EFI-compressed with -ec.\r
+        //\r
+        FileFlags = (FileFlags &~FILE_FLAG_BINARY) | FILE_FLAG_EFI;\r
+        if ((Argv[0][2] == 'c') || (Argv[0][2] == 'C')) {\r
+          FileFlags |= FILE_FLAG_COMPRESS;\r
+        }\r
+        //\r
+        // Specify not to set the LAST bit in the last file with -l\r
+        //\r
+      } else if (stricmp (Argv[0], "-l") == 0) {\r
+        Options->NoLast = 1;\r
+      } else if (stricmp (Argv[0], "-p") == 0) {\r
+        //\r
+        // -v for verbose would have been nicer, but it's already used. Let's use\r
+        // -p for prolix (wordy) output\r
+        //\r
+        Options->Verbose = 1;\r
+      } else if (stricmp (Argv[0], "-dump") == 0) {\r
+        //\r
+        // -dump for dumping a ROM image. In this case, say that the device id\r
+        // and vendor id are valid so we don't have to specify bogus ones on the\r
+        // command line.\r
+        //\r
+        Options->DumpOption   = 1;\r
+\r
+        Options->VendIdValid  = 1;\r
+        Options->DevIdValid   = 1;\r
+        FileFlags             = FILE_FLAG_BINARY;\r
+      } else if (stricmp (Argv[0], "-cc") == 0) {\r
+        //\r
+        // Class code value for the next file in the list.\r
+        // Make sure there's another parameter\r
+        //\r
+        if (Argc > 1) {\r
+          //\r
+          // No error checking on the return value. Could check for LONG_MAX,\r
+          // LONG_MIN, or 0 class code value if desired. Check range (3 bytes)\r
+          // at least.\r
+          //\r
+          ClassCode = (UINT32) strtol (Argv[1], NULL, 16);\r
+          if (ClassCode & 0xFF000000) {\r
+            fprintf (stdout, "ERROR: Class code %s out of range\n", Argv[1]);\r
+            return STATUS_ERROR;\r
+          }\r
+        } else {\r
+          fprintf (\r
+            stdout,\r
+            "ERROR: Missing class code value with %s\n\n",\r
+            Argv[0]\r
+            );\r
+          Usage ();\r
+          return STATUS_ERROR;\r
+        }\r
+\r
+        Argv++;\r
+        Argc--;\r
+      } else if (stricmp (Argv[0], "-rev") == 0) {\r
+        //\r
+        // Code revision in the PCI data structure. The value is for the next\r
+        // file in the list.\r
+        // Make sure there's another parameter\r
+        //\r
+        if (Argc > 1) {\r
+          //\r
+          // No error checking on the return value. Could check for LONG_MAX,\r
+          // LONG_MIN, or 0 value if desired. Check range (2 bytes)\r
+          // at least.\r
+          //\r
+          CodeRevision = (UINT32) strtol (Argv[1], NULL, 16);\r
+          if (CodeRevision & 0xFFFF0000) {\r
+            fprintf (stdout, "ERROR: Code revision %s out of range\n", Argv[1]);\r
+            return STATUS_ERROR;\r
+          }\r
+        } else {\r
+          fprintf (\r
+            stdout,\r
+            "ERROR: Missing code revision value with %s\n\n",\r
+            Argv[0]\r
+            );\r
+          Usage ();\r
+          return STATUS_ERROR;\r
+        }\r
+\r
+        Argv++;\r
+        Argc--;\r
+      } else {\r
+        fprintf (stdout, "ERROR: Invalid option specified: %s\n\n", Argv[0]);\r
+        Usage ();\r
+        return STATUS_ERROR;\r
+      }\r
+    } else {\r
+      //\r
+      // Not a slash-option argument. Must be a file name. Make sure they've specified\r
+      // -e or -b already.\r
+      //\r
+      if ((FileFlags & (FILE_FLAG_BINARY | FILE_FLAG_EFI)) == 0) {\r
+        fprintf (stdout, "ERROR: Missing -e or -b with input file %s\n", Argv[0]);\r
+        return STATUS_ERROR;\r
+      }\r
+      //\r
+      // Create a new file structure\r
+      //\r
+      FileList = (FILE_LIST *) malloc (sizeof (FILE_LIST));\r
+      if (FileList == NULL) {\r
+        fprintf (stdout, "ERROR: Memory allocation failure\n");\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      memset ((char *) FileList, 0, sizeof (FILE_LIST));\r
+      FileList->FileName  = Argv[0];\r
+      FileList->FileFlags = FileFlags;\r
+      if (Options->FileList == NULL) {\r
+        Options->FileList = FileList;\r
+      } else {\r
+        if (PrevFileList == NULL) {\r
+          PrevFileList = FileList;\r
+        } else {          \r
+          PrevFileList->Next = FileList;\r
+        }\r
+      }\r
+\r
+      PrevFileList = FileList;\r
+      //\r
+      // Set the class code and code revision for this file, then reset the values.\r
+      //\r
+      FileList->ClassCode     = ClassCode;\r
+      FileList->CodeRevision  = (UINT16) CodeRevision;\r
+      ClassCode               = 0;\r
+      CodeRevision            = 0;\r
+    }\r
+    //\r
+    // Next argument\r
+    //\r
+    Argv++;\r
+    Argc--;\r
+  }\r
+  //\r
+  // Make sure they specified a device ID and vendor ID\r
+  //\r
+  if (!Options->VendIdValid) {\r
+    fprintf (stdout, "ERROR: Missing Vendor ID on command line\n\n");\r
+    Usage ();\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  if (!Options->DevIdValid) {\r
+    fprintf (stdout, "ERROR: Missing Device ID on command line\n\n");\r
+    Usage ();\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Must have specified some files\r
+  //\r
+  if (Options->FileList == NULL) {\r
+    fprintf (stdout, "ERROR: Missing input file name\n");\r
+    Usage ();\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  return 0;\r
+}\r
+\r
+static\r
+void\r
+Usage (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  Print usage information for this utility.\r
+\r
+Arguments:\r
+\r
+  None.\r
+\r
+Returns:\r
+\r
+  Nothing.\r
+\r
+--*/\r
+{\r
+  int               Index;\r
+  static const char *Msg[] = {\r
+    "EfiRom "UTILITY_VERSION " - Intel EFI Make Option ROM utility",\r
+    "  Copyright (C), 1999-2002 Intel Coproration\n",\r
+    "  Create an option ROM image from a list of input files",\r
+    "  Usage: efirom {-p} [-v VendorId] [-d DeviceId] {-o OutFileName} ",\r
+    "                [-e|-b] [FileName(s)]",\r
+    "    where:",\r
+    "      VendorId       - required hex PCI Vendor ID for the device",\r
+    "      DeviceId       - required hex PCI Device ID for the device",\r
+    "      OutFileName    - optional output file name. Default is the first input",\r
+    "                       file name with a "DEFAULT_OUTPUT_EXTENSION " file extension",\r
+    "      FileNames      - input PE32 or binary file name(s)",\r
+    "      BinFileName    - input binary file name(s)",\r
+    "      -p             - for verbose output",\r
+    "      -l             - to not automatically set the LAST bit on the last file",\r
+    "      -b             - following FileNames are binary files",\r
+    "      -e             - following FileNames are EFI PE32 image files",\r
+    "      -ec            - following FileNames are EFI PE32 image files, and should",\r
+    "                       be compressed by this utility",\r
+    "      -cc ClassCode  - to use hex ClassCode in the PCI data structure header for",\r
+    "                       the following FileName",\r
+    "      -rev Revision  - to use hex Revision in the PCI data structure header for",\r
+    "                       the following FileName",\r
+    "      -dump          - to dump the headers of an existing option ROM image",\r
+    "",\r
+    "Example usage: EfiRom -v 0xABCD -d 0x1234 -b File1.bin File2.bin -e File1.efi File2.efi ",\r
+    "",\r
+    NULL\r
+  };\r
+\r
+  for (Index = 0; Msg[Index] != NULL; Index++) {\r
+    fprintf (stdout, "%s\n", Msg[Index]);\r
+  }\r
+}\r
+\r
+static\r
+void\r
+DumpImage (\r
+  FILE_LIST *InFile\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  InFile  - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+{\r
+  PCI_EXPANSION_ROM_HEADER      PciRomHdr;\r
+  FILE                          *InFptr;\r
+  UINT32                        ImageStart;\r
+  UINT32                        ImageCount;\r
+  EFI_PCI_EXPANSION_ROM_HEADER  EfiRomHdr;\r
+  PCI_DATA_STRUCTURE            PciDs;\r
+\r
+  //\r
+  // Open the input file\r
+  //\r
+  if ((InFptr = fopen (InFile->FileName, "rb")) == NULL) {\r
+    fprintf (\r
+      stdout,\r
+      "ERROR: Could not open input file %s\n",\r
+      InFile->FileName\r
+      );\r
+    return ;\r
+  }\r
+  //\r
+  // Go through the image and dump the header stuff for each\r
+  //\r
+  ImageCount = 0;\r
+  for (;;) {\r
+    //\r
+    // Save our postition in the file, since offsets in the headers\r
+    // are relative to the particular image.\r
+    //\r
+    ImageStart = ftell (InFptr);\r
+    ImageCount++;\r
+\r
+    //\r
+    // Read the option ROM header. Have to assume a raw binary image for now.\r
+    //\r
+    if (fread (&PciRomHdr, sizeof (PciRomHdr), 1, InFptr) != 1) {\r
+      fprintf (stdout, "ERROR: Failed to read PCI ROM header from file\n");\r
+      goto BailOut;\r
+    }\r
+\r
+    //\r
+    // Dump the contents of the header\r
+    //\r
+    fprintf (stdout, "Image %d -- Offset 0x%X\n", ImageCount, ImageStart);\r
+    fprintf (stdout, "  ROM header contents\n");\r
+    fprintf (stdout, "    Signature              0x%04X\n", (UINT32) PciRomHdr.Signature);\r
+    fprintf (stdout, "    PCIR offset            0x%04X\n", (UINT32) PciRomHdr.PcirOffset);\r
+    //\r
+    // Find PCI data structure\r
+    //\r
+    if (fseek (InFptr, ImageStart + PciRomHdr.PcirOffset, SEEK_SET)) {\r
+      fprintf (stdout, "ERROR: Failed to seek to PCI data structure\n");\r
+      goto BailOut;\r
+    }\r
+    //\r
+    // Read and dump the PCI data structure\r
+    //\r
+    if (fread (&PciDs, sizeof (PciDs), 1, InFptr) != 1) {\r
+      fprintf (stdout, "ERROR: Failed to read PCI data structure from file\n");\r
+      goto BailOut;\r
+    }\r
+\r
+    fprintf (stdout, "  PCI Data Structure\n");\r
+    fprintf (\r
+      stdout,\r
+      "    Signature              %c%c%c%c\n",\r
+      (char) PciDs.Signature,\r
+      (char) (PciDs.Signature >> 8),\r
+      (char) (PciDs.Signature >> 16),\r
+      (char) (PciDs.Signature >> 24)\r
+      );\r
+    fprintf (stdout, "    Vendor ID              0x%04X\n", PciDs.VendorId);\r
+    fprintf (stdout, "    Device ID              0x%04X\n", PciDs.DeviceId);\r
+    fprintf (\r
+      stdout,\r
+      "    Class Code             0x%06X\n",\r
+      (UINT32) (PciDs.ClassCode[0] | (PciDs.ClassCode[1] << 8) | (PciDs.ClassCode[2] << 16))\r
+      );\r
+    fprintf (stdout, "    Image size             0x%X\n", PciDs.ImageLength * 512);\r
+    fprintf (stdout, "    Code revision:         0x%04X\n", PciDs.CodeRevision);\r
+    fprintf (stdout, "    Indicator              0x%02X", (UINT32) PciDs.Indicator);\r
+    //\r
+    // Print the indicator, used to flag the last image\r
+    //\r
+    if (PciDs.Indicator == INDICATOR_LAST) {\r
+      fprintf (stdout, "   (last image)\n");\r
+    } else {\r
+      fprintf (stdout, "\n");\r
+    }\r
+    //\r
+    // Print the code type. If EFI code, then we can provide more info.\r
+    //\r
+    fprintf (stdout, "    Code type              0x%02X", (UINT32) PciDs.CodeType);\r
+    if (PciDs.CodeType == PCI_CODE_TYPE_EFI_IMAGE) {\r
+      fprintf (stdout, "   (EFI image)\n");\r
+      //\r
+      // Re-read the header as an EFI ROM header, then dump more info\r
+      //\r
+      fprintf (stdout, "  EFI ROM header contents\n");\r
+      if (fseek (InFptr, ImageStart, SEEK_SET)) {\r
+        fprintf (stdout, "ERROR: Failed to re-seek to ROM header structure\n");\r
+        goto BailOut;\r
+      }\r
+\r
+      if (fread (&EfiRomHdr, sizeof (EfiRomHdr), 1, InFptr) != 1) {\r
+        fprintf (stdout, "ERROR: Failed to read EFI PCI ROM header from file\n");\r
+        goto BailOut;\r
+      }\r
+      //\r
+      // Now dump more info\r
+      //\r
+      fprintf (stdout, "    EFI Signature          0x%04X\n", EfiRomHdr.EfiSignature);\r
+      fprintf (\r
+        stdout,\r
+        "    Compression Type       0x%04X ",\r
+        (UINT32) EfiRomHdr.CompressionType\r
+        );\r
+      if (EfiRomHdr.CompressionType == EFI_PCI_EXPANSION_ROM_HEADER_COMPRESSED) {\r
+        fprintf (stdout, "(compressed)\n");\r
+      } else {\r
+        fprintf (stdout, "(not compressed)\n");\r
+      }\r
+\r
+      fprintf (\r
+        stdout,\r
+        "    Machine type           0x%04X (%s)\n",\r
+        EfiRomHdr.EfiMachineType,\r
+        GetMachineTypeStr (EfiRomHdr.EfiMachineType)\r
+        );\r
+      fprintf (\r
+        stdout,\r
+        "    Subsystem              0x%04X (%s)\n",\r
+        EfiRomHdr.EfiSubsystem,\r
+        GetSubsystemTypeStr (EfiRomHdr.EfiSubsystem)\r
+        );\r
+      fprintf (\r
+        stdout,\r
+        "    EFI image offset       0x%04X (@0x%X)\n",\r
+        (UINT32) EfiRomHdr.EfiImageHeaderOffset,\r
+        (UINT32) (EfiRomHdr.EfiImageHeaderOffset + ImageStart)\r
+        );\r
+\r
+    } else {\r
+      //\r
+      // Not an EFI image\r
+      //\r
+      fprintf (stdout, "\n");\r
+    }\r
+    //\r
+    // If code type is EFI image, then dump it as well?\r
+    //\r
+    // if (PciDs.CodeType == PCI_CODE_TYPE_EFI_IMAGE) {\r
+    // }\r
+    //\r
+    // If last image, then we're done\r
+    //\r
+    if (PciDs.Indicator == INDICATOR_LAST) {\r
+      goto BailOut;\r
+    }\r
+    //\r
+    // Seek to the start of the next image\r
+    //\r
+    if (fseek (InFptr, ImageStart + (PciDs.ImageLength * 512), SEEK_SET)) {\r
+      fprintf (stdout, "ERROR: Failed to seek to next image\n");\r
+      goto BailOut;\r
+    }\r
+  }\r
+\r
+BailOut:\r
+  fclose (InFptr);\r
+}\r
+\r
+char *\r
+GetMachineTypeStr (\r
+  UINT16    MachineType\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  MachineType - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+{\r
+  int Index;\r
+\r
+  for (Index = 0; mMachineTypes[Index].Name != NULL; Index++) {\r
+    if (mMachineTypes[Index].Value == MachineType) {\r
+      return mMachineTypes[Index].Name;\r
+    }\r
+  }\r
+\r
+  return "unknown";\r
+}\r
+\r
+static\r
+char *\r
+GetSubsystemTypeStr (\r
+  UINT16  SubsystemType\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  SubsystemType - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+{\r
+  int Index;\r
+\r
+  for (Index = 0; mSubsystemTypes[Index].Name != NULL; Index++) {\r
+    if (mSubsystemTypes[Index].Value == SubsystemType) {\r
+      return mSubsystemTypes[Index].Name;\r
+    }\r
+  }\r
+\r
+  return "unknown";\r
+}\r
diff --git a/Tools/CodeTools/Source/EfiRom/build.xml b/Tools/CodeTools/Source/EfiRom/build.xml
new file mode 100644 (file)
index 0000000..acb94a4
--- /dev/null
@@ -0,0 +1,70 @@
+<?xml version="1.0" ?>\r
+<!--\r
+Copyright (c) 2006, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+-->\r
+<project default="GenTool" basedir=".">\r
+<!--\r
+    EDK EfiRom Tool\r
+  Copyright (c) 2006, Intel Corporation\r
+-->\r
+  <property name="ToolName" value="EfiRom"/>\r
+  <property name="FileSet" value="*.c"/>\r
+\r
+  <taskdef resource="cpptasks.tasks"/>\r
+  <typedef resource="cpptasks.types"/>\r
+  <taskdef resource="net/sf/antcontrib/antlib.xml"/>\r
+\r
+  <property name="LINK_OUTPUT_TYPE" value="static"/>\r
+  <property name="BUILD_DIR" value="${PACKAGE_DIR}/${ToolName}/tmp"/>\r
+\r
+  <target name="GenTool" depends="init, Tool">\r
+    <echo message="The EDK Tool: ${ToolName} build has completed!"/>\r
+  </target>\r
+\r
+  <target name="init">\r
+    <echo message="Building the EDK Tool: ${ToolName}"/>\r
+    <mkdir dir="${BUILD_DIR}"/>\r
+  </target>\r
+\r
+  <target name="Tool" depends="init">\r
+    <cc name="${ToolChain}" objdir="${BUILD_DIR}" \r
+        outfile="${BIN_DIR}/${ToolName}"\r
+        outtype="executable"\r
+        optimize="speed" \r
+        debug="true">\r
+      <compilerarg value="${ExtraArgus}" if="ExtraArgus" />\r
+      <fileset dir="${basedir}/${ToolName}" \r
+        includes="${FileSet}" \r
+        defaultexcludes="TRUE" \r
+        excludes="*.xml *.inf"/>\r
+\r
+      <includepath path="${PACKAGE_DIR}/Include"/>\r
+      <includepath path="${PACKAGE_DIR}/Include/${HostArch}"/>\r
+      <includepath path="${PACKAGE_DIR}/Common"/>\r
+      <libset dir="${LIB_DIR}" libs="CommonTools"/>\r
+    </cc>\r
+  </target>\r
+\r
+  <target name="clean">\r
+    <echo message="Removing Intermediate Files Only"/>  \r
+    <delete>\r
+      <fileset dir="${BUILD_DIR}" includes="*.obj"/>\r
+    </delete>\r
+  </target>\r
+\r
+  <target name="cleanall">\r
+    <echo message="Removing Object Files and the Executable: ${ToolName}${ext_exe}"/>  \r
+    <delete failonerror="false" quiet="true" includeEmptyDirs="true">\r
+      <fileset dir="${BUILD_DIR}"/>\r
+      <fileset file="${BIN_DIR}/${ToolName}${ext_exe}"/>\r
+    </delete>\r
+  </target>\r
+\r
+</project>\r
diff --git a/Tools/CodeTools/Source/FlashMap/FlashDefFile.c b/Tools/CodeTools/Source/FlashMap/FlashDefFile.c
new file mode 100644 (file)
index 0000000..cdbf788
--- /dev/null
@@ -0,0 +1,2788 @@
+/*++\r
+\r
+Copyright (c)  2004-2006 Intel Corporation. All rights reserved\r
+This program and the accompanying materials are licensed and made available \r
+under the terms and conditions of the BSD License which accompanies this \r
+distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+Module Name:\r
+\r
+  FlashDefFile.c\r
+\r
+Abstract:\r
+\r
+  Utility for flash management in the Intel Platform Innovation Framework\r
+  for EFI build environment.\r
+\r
+--*/\r
+\r
+#include <stdio.h>\r
+#include <string.h>\r
+#include <stdlib.h>\r
+\r
+#include <Common/UefiBaseTypes.h>\r
+#include <Common/FirmwareVolumeHeader.h>\r
+#include <Common/MultiPhase.h>\r
+\r
+#include "EfiUtilityMsgs.h"\r
+#include "FlashDefFile.h"\r
+#include "SimpleFileParsing.h"\r
+#include "Symbols.h"\r
+\r
+//\r
+// #include "TrackMallocFree.h"\r
+//\r
+#define WCHAR_T           char\r
+#define MAX_STRING_LEN    256\r
+#define MAX_NAME_LEN      128\r
+#define BUFFER_SIZE       1024\r
+#define MAX_ATTR_LEN      128\r
+#define MAX_AREATYPE_LEN  128\r
+#define COLUMN2_START     60\r
+#define COLUMN3_START     70\r
+//\r
+// Information for each subregions defined in the fdf file will be saved in these\r
+//\r
+typedef struct _FLASH_SUBREGION_DESCRIPTION {\r
+  struct _FLASH_SUBREGION_DESCRIPTION *Next;\r
+  int                                 CreateHob;                  // to add to the auto-created HOB array\r
+  WCHAR_T                             Name[MAX_NAME_LEN];         // each subregion within a region must have a unique name\r
+  unsigned int                        Size;                       // size, in bytes, of this subregion\r
+  unsigned int                        SizeLeft;                   // used when creating the image\r
+  WCHAR_T                             Attributes[MAX_ATTR_LEN];   // subregion attributes used in the output HOB\r
+  WCHAR_T                             AreaType[MAX_AREATYPE_LEN]; // subregion area type used in the output HOB\r
+  EFI_GUID                            NameGuid;                   // used in the output HOB\r
+  WCHAR_T                             NameGuidString[MAX_NAME_LEN];\r
+  EFI_GUID                            AreaTypeGuid;               // used in the output HOB\r
+  WCHAR_T                             AreaTypeGuidString[MAX_NAME_LEN];\r
+  EFI_GUID                            FileSystemGuid;             // used in the output HOB\r
+  WCHAR_T                             FileSystemGuidString[MAX_NAME_LEN];\r
+} FLASH_SUBREGION_DESCRIPTION;\r
+\r
+//\r
+// Information for each block in a flash device will be saved in one of these.\r
+// We'll also use it for region definitions.\r
+//\r
+typedef struct _FLASH_BLOCK_DESCRIPTION {\r
+  struct _FLASH_BLOCK_DESCRIPTION *Next;                      // next block in the linked list\r
+  WCHAR_T                         Name[MAX_NAME_LEN];         // each block must have a unique name\r
+  unsigned int                    Size;                       // size, in bytes, of this block\r
+  unsigned int                    SizeLeft;                   // for use when creating image\r
+  unsigned int                    Flags;                      // user-defined flags for the block\r
+  unsigned int                    Alignment;                  // power of 2 alignment\r
+  WCHAR_T                         Attributes[MAX_ATTR_LEN];   // only used for Region definitions\r
+  WCHAR_T                         AreaType[MAX_AREATYPE_LEN]; // only used for Region definitions\r
+  FLASH_SUBREGION_DESCRIPTION     *Subregions;\r
+  FLASH_SUBREGION_DESCRIPTION     *LastSubregion;\r
+} FLASH_BLOCK_DESCRIPTION;\r
+\r
+//\r
+// Information for each flash device will be saved in one of these\r
+//\r
+typedef struct _FLASH_DEVICE_DESCRIPTION {\r
+  struct _FLASH_DEVICE_DESCRIPTION  *Next;              // next flash device in our linked list\r
+  int                               ErasePolarity;      // erase polarity of the flash device\r
+  unsigned int                      BaseAddress;        // base address of the flash device\r
+  unsigned int                      Size;               // total size, in bytes, of the flash device\r
+  WCHAR_T                           Name[MAX_NAME_LEN]; // name of the flash device\r
+  FLASH_BLOCK_DESCRIPTION           *PBlocks;           // linked list of physical block descriptors\r
+  FLASH_BLOCK_DESCRIPTION           *LastPBlock;        // last block in the linked list\r
+  FLASH_BLOCK_DESCRIPTION           *Regions;           // linked list of flash region descriptors\r
+  FLASH_BLOCK_DESCRIPTION           *LastRegion;        // last region in the linked list\r
+} FLASH_DEVICE_DESCRIPTION;\r
+\r
+//\r
+// For image definitions, they can specify a file name or raw data bytes. Keep a linked list.\r
+//\r
+typedef struct _IMAGE_DEFINITION_ENTRY {\r
+  struct _IMAGE_DEFINITION_ENTRY  *Next;\r
+  WCHAR_T                         RegionName[MAX_NAME_LEN];\r
+  WCHAR_T                         SubregionName[MAX_NAME_LEN];\r
+  WCHAR_T                         Name[MAX_NAME_LEN]; // file or data name\r
+  int                             IsRawData;          // non-zero if raw data bytes\r
+  unsigned int                    RawDataSize;\r
+  char                            *RawData;\r
+  int                             Optional;           // optional file (don't include if it doesn't exist)\r
+} IMAGE_DEFINITION_ENTRY;\r
+\r
+//\r
+// When we parse an image definition, save all the data for each in one of these\r
+//\r
+typedef struct _IMAGE_DEFINITION {\r
+  struct _IMAGE_DEFINITION  *Next;\r
+  WCHAR_T                   Name[MAX_NAME_LEN];\r
+  IMAGE_DEFINITION_ENTRY    *Entries;\r
+  IMAGE_DEFINITION_ENTRY    *LastEntry;\r
+} IMAGE_DEFINITION;\r
+\r
+typedef struct {\r
+  char  *BufferStart;\r
+  char  *BufferEnd;\r
+  char  *BufferPos;\r
+} BUFFER_DATA;\r
+\r
+static const char               *CIncludeHeader = "/*++\n\n"\r
+"  DO NOT EDIT -- file auto-generated by FlashMap utility\n\n""--*/\n""\n""#ifndef _FLASH_MAP_H_\n"\r
+"#define _FLASH_MAP_H_\n\n";\r
+//\r
+//  "#include \"EfiFlashMap.h\"\n\n";\r
+//\r
+static const char               *CIncludeFooter = "#endif // #ifndef _FLASH_MAP_H_\n\n";\r
+\r
+static const char               *CFlashMapDataFileHeader = "/*++\n\n"\r
+"  DO NOT EDIT -- file auto-generated by FlashMap utility\n\n""--*/\n""\n";\r
+\r
+static FLASH_DEVICE_DESCRIPTION *mFlashDevices      = NULL;\r
+static IMAGE_DEFINITION         *mImageDefinitions  = NULL;\r
+\r
+//\r
+// Local function prototypes\r
+//\r
+static\r
+BUFFER_DATA                     *\r
+CreateBufferData (\r
+  VOID\r
+  );\r
+\r
+static\r
+BOOLEAN\r
+AddBufferDataByte (\r
+  BUFFER_DATA *Buffer,\r
+  char        Data\r
+  );\r
+\r
+static\r
+void\r
+FreeBufferData (\r
+  BUFFER_DATA *Buffer,\r
+  BOOLEAN     FreeData\r
+  );\r
+\r
+static\r
+char                            *\r
+GetBufferData (\r
+  BUFFER_DATA *Buffer,\r
+  int         *BufferSize\r
+  );\r
+\r
+static\r
+FLASH_SUBREGION_DESCRIPTION     *\r
+ParseSubregionDefinition (\r
+  unsigned int  SizeLeft\r
+  );\r
+\r
+void\r
+FDFConstructor (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Initialization routine for the services that operate on a flash\r
+  definition file.\r
+\r
+Arguments:\r
+  None.\r
+\r
+Returns:\r
+  NA\r
+\r
+--*/\r
+{\r
+  mFlashDevices     = NULL;\r
+  mImageDefinitions = NULL;\r
+}\r
+\r
+void\r
+FDFDestructor (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Finalization/cleanup routine for the services that operate on a flash\r
+  definition file.\r
+\r
+Arguments:\r
+  None.\r
+\r
+Returns:\r
+  NA\r
+\r
+--*/\r
+{\r
+  FLASH_BLOCK_DESCRIPTION     *FBNext;\r
+  FLASH_DEVICE_DESCRIPTION    *FDNext;\r
+  IMAGE_DEFINITION            *IDNext;\r
+  IMAGE_DEFINITION_ENTRY      *IDENext;\r
+  FLASH_SUBREGION_DESCRIPTION *SubNext;\r
+  //\r
+  // Go through all our flash devices and free the memory\r
+  //\r
+  while (mFlashDevices != NULL) {\r
+    //\r
+    // Free the physical block definitions\r
+    //\r
+    while (mFlashDevices->PBlocks != NULL) {\r
+      FBNext = mFlashDevices->PBlocks->Next;\r
+      _free (mFlashDevices->PBlocks);\r
+      mFlashDevices->PBlocks = FBNext;\r
+    }\r
+    //\r
+    // Free the region definitions\r
+    //\r
+    while (mFlashDevices->Regions != NULL) {\r
+      FBNext = mFlashDevices->Regions->Next;\r
+      //\r
+      // First free the subregion definitions\r
+      //\r
+      while (mFlashDevices->Regions->Subregions != NULL) {\r
+        SubNext = mFlashDevices->Regions->Subregions->Next;\r
+        _free (mFlashDevices->Regions->Subregions);\r
+        mFlashDevices->Regions->Subregions = SubNext;\r
+      }\r
+\r
+      _free (mFlashDevices->Regions);\r
+      mFlashDevices->Regions = FBNext;\r
+    }\r
+\r
+    FDNext = mFlashDevices->Next;\r
+    _free (mFlashDevices);\r
+    mFlashDevices = FDNext;\r
+  }\r
+  //\r
+  // Free up the image definitions, and the data\r
+  //\r
+  while (mImageDefinitions != NULL) {\r
+    //\r
+    // Free the entries\r
+    //\r
+    while (mImageDefinitions->Entries != NULL) {\r
+      IDENext = mImageDefinitions->Entries->Next;\r
+      if (mImageDefinitions->Entries->RawData != NULL) {\r
+        _free (mImageDefinitions->Entries->RawData);\r
+      }\r
+\r
+      _free (mImageDefinitions->Entries);\r
+      mImageDefinitions->Entries = IDENext;\r
+    }\r
+\r
+    IDNext = mImageDefinitions->Next;\r
+    _free (mImageDefinitions);\r
+    mImageDefinitions = IDNext;\r
+  }\r
+}\r
+\r
+STATUS\r
+FDFParseFile (\r
+  char    *FileName\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Parse the specified flash definition file, saving the definitions in\r
+  file-static variables for use by other functions.\r
+  \r
+Arguments:\r
+  FileName    - name of the input flash definition text file.\r
+\r
+Returns:\r
+  STATUS_SUCCESS    - file parsed with no errors or warnings\r
+  STATUS_WARNING    - warnings, but no errors, were encountered while parsing\r
+  STATUS_ERROR      - errors were encountered while parsing\r
+  \r
+--*/\r
+{\r
+  FILE                        *Fptr;\r
+  STATUS                      Status;\r
+  unsigned int                Num;\r
+  FLASH_DEVICE_DESCRIPTION    *FDDesc;\r
+  FLASH_BLOCK_DESCRIPTION     *FBlockDesc;\r
+  FLASH_BLOCK_DESCRIPTION     *TempBlockDesc;\r
+  FLASH_SUBREGION_DESCRIPTION *Subregion;\r
+  FLASH_SUBREGION_DESCRIPTION *TempSubregion;\r
+  unsigned int                BlockSizeLeft;\r
+  unsigned int                RegionSizeLeft;\r
+  unsigned int                SubregionSizeLeft;\r
+  int                         ErrorCount;\r
+  int                         WarningCount;\r
+  IMAGE_DEFINITION            *ImageDef;\r
+  IMAGE_DEFINITION_ENTRY      *ImageDefEntry;\r
+  IMAGE_DEFINITION_ENTRY      *TempImageDefEntry;\r
+  BUFFER_DATA                 *BufferData;\r
+  char                        Str[100];\r
+  BOOLEAN                     PreviousComma;\r
+\r
+  if ((Fptr = fopen (FileName, "r")) == NULL) {\r
+    Error (NULL, 0, 0, FileName, "failed to open input flash definition file for reading");\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  fclose (Fptr);\r
+  Status        = STATUS_SUCCESS;\r
+  ErrorCount    = 0;\r
+  WarningCount  = 0;\r
+  //\r
+  // Initialize the simple-file-parsing routines\r
+  //\r
+  SFPInit ();\r
+  //\r
+  // Open the file\r
+  //\r
+  if ((Status = SFPOpenFile (FileName)) != STATUS_SUCCESS) {\r
+    return Status;\r
+  }\r
+  //\r
+  // Parse the file. Should start with a series of these:\r
+  // FlashDevice {\r
+  //   Name = "FLASH_1234", Size = 0x2004, BaseAddress = 0xFFF0000, ErasePolarity = 1,\r
+  //   Block { Name = "BLOCK1",  Size = 0x1000, Flags = 0x0001 }\r
+  //   Block { Name = "BLOCK2",  Size = 0x1004, Flags = 0x0002 }\r
+  //   Region  { Name = "REGION_NAME", Size = 0x2004, Align= 4 }\r
+  // }\r
+  //\r
+  while (SFPIsKeyword ("FlashDevice")) {\r
+    //\r
+    // Allocate memory for new flash device description block\r
+    //\r
+    FDDesc = (FLASH_DEVICE_DESCRIPTION *) _malloc (sizeof (FLASH_DEVICE_DESCRIPTION));\r
+    if (FDDesc == NULL) {\r
+      Error (__FILE__, __LINE__, 0, "memory allocation failure", NULL);\r
+      ErrorCount++;\r
+      goto Done;\r
+    }\r
+\r
+    memset (FDDesc, 0, sizeof (FLASH_DEVICE_DESCRIPTION));\r
+    //\r
+    // Open brace -- warning if not there\r
+    //\r
+    if (!SFPIsToken ("{")) {\r
+      Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected {", NULL);\r
+      WarningCount++;\r
+    }\r
+    //\r
+    // Parse:  Name = "DeviceName",\r
+    //\r
+    if (!SFPIsKeyword ("Name")) {\r
+      Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected 'Name'", NULL);\r
+      ErrorCount++;\r
+      goto Done;\r
+    }\r
+\r
+    if (!SFPIsToken ("=")) {\r
+      Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected '='", NULL);\r
+      WarningCount++;\r
+    }\r
+\r
+    if (!SFPGetQuotedString (FDDesc->Name, sizeof (FDDesc->Name))) {\r
+      Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected quoted name of flash device", NULL);\r
+      ErrorCount++;\r
+      goto Done;\r
+    }\r
+\r
+    if (!SFPIsToken (",")) {\r
+      Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected comma following flash device name", NULL);\r
+      WarningCount++;\r
+    }\r
+    //\r
+    // Parse: Size = 0x20000,\r
+    //\r
+    if (!SFPIsKeyword ("Size")) {\r
+      Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected 'Size'", NULL);\r
+      ErrorCount++;\r
+      goto Done;\r
+    }\r
+\r
+    if (!SFPIsToken ("=")) {\r
+      Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected '='", NULL);\r
+      WarningCount++;\r
+    }\r
+\r
+    if (!SFPGetNumber (&FDDesc->Size)) {\r
+      Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected numeric Size value", NULL);\r
+      ErrorCount++;\r
+      goto Done;\r
+    }\r
+    //\r
+    // Check for 0 size\r
+    //\r
+    if (FDDesc->Size == 0) {\r
+      Error (SFPGetFileName (), SFPGetLineNumber (), 0, FDDesc->Name, "Size field cannot be 0", NULL);\r
+      ErrorCount++;\r
+      goto Done;\r
+    }\r
+\r
+    SFPIsToken (",");\r
+    //\r
+    // Parse: BaseAddress = 0xFFF0000,\r
+    //\r
+    if (!SFPIsKeyword ("BaseAddress")) {\r
+      Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected 'BaseAddress'", NULL);\r
+      ErrorCount++;\r
+      goto Done;\r
+    }\r
+\r
+    if (!SFPIsToken ("=")) {\r
+      Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected '='", NULL);\r
+      WarningCount++;\r
+    }\r
+\r
+    if (!SFPGetNumber (&FDDesc->BaseAddress)) {\r
+      Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected numeric value for BaseAddress", NULL);\r
+      ErrorCount++;\r
+      goto Done;\r
+    }\r
+\r
+    if (!SFPIsToken (",")) {\r
+      Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected comma following BaseAddress value", NULL);\r
+      WarningCount++;\r
+    }\r
+    //\r
+    // Parse: ErasePolarity = 1,\r
+    //\r
+    if (!SFPIsKeyword ("ErasePolarity")) {\r
+      Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected 'ErasePolarity'", NULL);\r
+      ErrorCount++;\r
+      goto Done;\r
+    }\r
+\r
+    if (!SFPIsToken ("=")) {\r
+      Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected '='", NULL);\r
+      WarningCount++;\r
+    }\r
+\r
+    if (!SFPGetNumber (&Num) || ((Num != 0) && (Num != 1))) {\r
+      Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected numeric erase polarity value 1 or 0", NULL);\r
+      ErrorCount++;\r
+      goto Done;\r
+    }\r
+\r
+    FDDesc->ErasePolarity = Num;\r
+    if (!SFPIsToken (",")) {\r
+      Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected comma following erase polarity value", NULL);\r
+      WarningCount++;\r
+    }\r
+    //\r
+    // Parse array of:\r
+    //   Block {  Name = "BLOCK1", Size = 0x1000, Flags = 0x0001 }\r
+    //\r
+    // Keep track of size to make sure the sum of the physical blocks and region sizes do not\r
+    // exceed the size of the flash device.\r
+    //\r
+    BlockSizeLeft   = FDDesc->Size;\r
+    RegionSizeLeft  = FDDesc->Size;\r
+    while (SFPIsKeyword ("Block")) {\r
+      //\r
+      // Allocate memory for a new physical block descriptor\r
+      //\r
+      FBlockDesc = (FLASH_BLOCK_DESCRIPTION *) _malloc (sizeof (FLASH_BLOCK_DESCRIPTION));\r
+      if (FBlockDesc == NULL) {\r
+        Error (__FILE__, __LINE__, 0, "memory allocation failure", NULL);\r
+        ErrorCount++;\r
+        goto Done;\r
+      }\r
+\r
+      memset (FBlockDesc, 0, sizeof (FLASH_BLOCK_DESCRIPTION));\r
+      //\r
+      // Open brace -- warning if not there\r
+      //\r
+      if (!SFPIsToken ("{")) {\r
+        Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected {", NULL);\r
+        WarningCount++;\r
+      }\r
+      //\r
+      // Parse:  Name = "BlockName",\r
+      //\r
+      if (!SFPIsKeyword ("Name")) {\r
+        Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected 'Name'", NULL);\r
+        ErrorCount++;\r
+        goto Done;\r
+      }\r
+\r
+      if (!SFPIsToken ("=")) {\r
+        Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected '='", NULL);\r
+        WarningCount++;\r
+      }\r
+\r
+      if (!SFPGetQuotedString (FBlockDesc->Name, sizeof (FBlockDesc->Name))) {\r
+        Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected quoted name of physical block", NULL);\r
+        ErrorCount++;\r
+        goto Done;\r
+      }\r
+      //\r
+      // Make sure there are no other physical block names with this same name\r
+      //\r
+      for (TempBlockDesc = FDDesc->PBlocks; TempBlockDesc != NULL; TempBlockDesc = TempBlockDesc->Next) {\r
+        if (strcmp (TempBlockDesc->Name, FBlockDesc->Name) == 0) {\r
+          Error (\r
+            SFPGetFileName (),\r
+            SFPGetLineNumber (),\r
+            0,\r
+            TempBlockDesc->Name,\r
+            "physical block with this name already defined"\r
+            );\r
+          ErrorCount++;\r
+        }\r
+      }\r
+\r
+      if (!SFPIsToken (",")) {\r
+        Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected comma following physical block name", NULL);\r
+        WarningCount++;\r
+      }\r
+      //\r
+      // Parse: Size = 0x2000,\r
+      //\r
+      if (!SFPIsKeyword ("Size")) {\r
+        Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected 'Size'", NULL);\r
+        ErrorCount++;\r
+        goto Done;\r
+      }\r
+\r
+      if (!SFPIsToken ("=")) {\r
+        Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected '='", NULL);\r
+        WarningCount++;\r
+      }\r
+\r
+      if (!SFPGetNumber (&FBlockDesc->Size)) {\r
+        Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected numeric Size value", NULL);\r
+        ErrorCount++;\r
+        goto Done;\r
+      }\r
+      //\r
+      // Make sure the sum of physical blocks so far does not exceed flash device size\r
+      //\r
+      if (BlockSizeLeft < FBlockDesc->Size) {\r
+        Error (\r
+          SFPGetFileName (),\r
+          SFPGetLineNumber (),\r
+          0,\r
+          "sum of physical block sizes exceeds flash device size",\r
+          NULL\r
+          );\r
+        ErrorCount++;\r
+      }\r
+\r
+      BlockSizeLeft -= FBlockDesc->Size;\r
+      SFPIsToken (",");\r
+      //\r
+      // Optional parse: Flags = 0xFFF0000,\r
+      //\r
+      if (SFPIsKeyword ("Flags")) {\r
+        if (!SFPIsToken ("=")) {\r
+          Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected '='", NULL);\r
+          WarningCount++;\r
+        }\r
+\r
+        if (!SFPGetNumber (&FBlockDesc->Flags)) {\r
+          Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected numeric value for Flags", NULL);\r
+          ErrorCount++;\r
+          goto Done;\r
+        }\r
+      }\r
+\r
+      if (!SFPIsToken ("}")) {\r
+        Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected PhysicalBlock closing brace '}'", NULL);\r
+        WarningCount++;\r
+      }\r
+      //\r
+      // Add the physical block descriptor to the end of the linked list\r
+      //\r
+      if (FDDesc->LastPBlock != NULL) {\r
+        FDDesc->LastPBlock->Next = FBlockDesc;\r
+      } else {\r
+        FDDesc->PBlocks = FBlockDesc;\r
+      }\r
+\r
+      FDDesc->LastPBlock = FBlockDesc;\r
+    }\r
+    //\r
+    // Make sure sum of sizes of physical blocks added up to size of flash device\r
+    //\r
+    if (BlockSizeLeft != 0) {\r
+      Error (\r
+        SFPGetFileName (),\r
+        SFPGetLineNumber (),\r
+        0,\r
+        NULL,\r
+        "sum of sizes of physical blocks (0x%08X) != flash device size (0x%08X) : delta = 0x%08X",\r
+        FDDesc->Size - BlockSizeLeft,\r
+        FDDesc->Size,\r
+        BlockSizeLeft\r
+        );\r
+      ErrorCount++;\r
+    }\r
+    //\r
+    // Parse array of:\r
+    //   Region { Name = "REGION_1", Size = 0x2000, Flags = 0x1234, Alignment = 4, Attributes = "str", AreaType = "str" }\r
+    //\r
+    while (SFPIsKeyword ("Region")) {\r
+      //\r
+      // Allocate memory for a new physical block descriptor\r
+      //\r
+      FBlockDesc = (FLASH_BLOCK_DESCRIPTION *) _malloc (sizeof (FLASH_BLOCK_DESCRIPTION));\r
+      if (FBlockDesc == NULL) {\r
+        Error (__FILE__, __LINE__, 0, "memory allocation failure", NULL);\r
+        ErrorCount++;\r
+        goto Done;\r
+      }\r
+\r
+      memset (FBlockDesc, 0, sizeof (FLASH_BLOCK_DESCRIPTION));\r
+      //\r
+      // Open brace -- warning if not there\r
+      //\r
+      if (!SFPIsToken ("{")) {\r
+        Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected {", NULL);\r
+        WarningCount++;\r
+      }\r
+      //\r
+      // Parse:  Name = "BlockName",\r
+      //\r
+      if (!SFPIsKeyword ("Name")) {\r
+        Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected 'Name'", NULL);\r
+        ErrorCount++;\r
+        goto Done;\r
+      }\r
+\r
+      if (!SFPIsToken ("=")) {\r
+        Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected '='", NULL);\r
+        WarningCount++;\r
+      }\r
+\r
+      if (!SFPGetQuotedString (FBlockDesc->Name, sizeof (FBlockDesc->Name))) {\r
+        Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected quoted Region name", NULL);\r
+        ErrorCount++;\r
+        goto Done;\r
+      }\r
+      //\r
+      // Make sure there are no other region names with this same name\r
+      //\r
+      for (TempBlockDesc = FDDesc->Regions; TempBlockDesc != NULL; TempBlockDesc = TempBlockDesc->Next) {\r
+        if (strcmp (TempBlockDesc->Name, FBlockDesc->Name) == 0) {\r
+          Error (\r
+            SFPGetFileName (),\r
+            SFPGetLineNumber (),\r
+            0,\r
+            TempBlockDesc->Name,\r
+            "Region with this name already defined"\r
+            );\r
+          ErrorCount++;\r
+        }\r
+      }\r
+\r
+      if (!SFPIsToken (",")) {\r
+        Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected comma following Region name", NULL);\r
+        WarningCount++;\r
+      }\r
+      //\r
+      // Parse: Size = 0x2000,\r
+      //\r
+      if (!SFPIsKeyword ("Size")) {\r
+        Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected 'Size'", NULL);\r
+        ErrorCount++;\r
+        goto Done;\r
+      }\r
+\r
+      if (!SFPIsToken ("=")) {\r
+        Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected '='", NULL);\r
+        WarningCount++;\r
+      }\r
+\r
+      if (!SFPGetNumber (&FBlockDesc->Size)) {\r
+        Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected numeric Size value", NULL);\r
+        ErrorCount++;\r
+        goto Done;\r
+      }\r
+\r
+      if (!SFPIsToken (",")) {\r
+        Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected ','", NULL);\r
+      }\r
+      //\r
+      // Make sure the sum of regions so far does not exceed flash device size\r
+      //\r
+      if (RegionSizeLeft < FBlockDesc->Size) {\r
+        Error (SFPGetFileName (), SFPGetLineNumber (), 0, "sum of Region sizes exceeds flash device size", NULL);\r
+        ErrorCount++;\r
+      }\r
+\r
+      RegionSizeLeft -= FBlockDesc->Size;\r
+      //\r
+      // Optional parse: Flags = 0xFFF0000,\r
+      //\r
+      if (SFPIsKeyword ("Flags")) {\r
+        if (!SFPIsToken ("=")) {\r
+          Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected '='", NULL);\r
+          WarningCount++;\r
+        }\r
+\r
+        if (!SFPGetNumber (&FBlockDesc->Flags)) {\r
+          Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected numeric value for Flags", NULL);\r
+          ErrorCount++;\r
+          goto Done;\r
+        }\r
+        //\r
+        // comma\r
+        //\r
+        if (!SFPIsToken (",")) {\r
+          Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected ','", NULL);\r
+        }\r
+      }\r
+      //\r
+      // Optional parse: Alignment = 4\r
+      //\r
+      if (SFPIsKeyword ("Alignment")) {\r
+        if (!SFPIsToken ("=")) {\r
+          Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected '='", NULL);\r
+          WarningCount++;\r
+        }\r
+\r
+        if (!SFPGetNumber (&FBlockDesc->Alignment)) {\r
+          Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected numeric Alignment value", NULL);\r
+          ErrorCount++;\r
+          goto Done;\r
+        }\r
+        //\r
+        // comma\r
+        //\r
+        if (!SFPIsToken (",")) {\r
+          Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected ','", NULL);\r
+        }\r
+      }\r
+      //\r
+      // Parse:  Attributes = "String",\r
+      //\r
+      if (!SFPIsKeyword ("Attributes")) {\r
+        Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected 'Attributes'", NULL);\r
+        ErrorCount++;\r
+        goto Done;\r
+      }\r
+\r
+      if (!SFPIsToken ("=")) {\r
+        Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected '='", NULL);\r
+        WarningCount++;\r
+      }\r
+\r
+      if (!SFPGetQuotedString (FBlockDesc->Attributes, sizeof (FBlockDesc->Attributes))) {\r
+        Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected quoted Attributes string", NULL);\r
+        ErrorCount++;\r
+        goto Done;\r
+      }\r
+\r
+      if (!SFPIsToken (",")) {\r
+        Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected ','", NULL);\r
+      }\r
+      //\r
+      // Parse:  AreaType = "String",\r
+      //\r
+      if (!SFPIsKeyword ("AreaType")) {\r
+        Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected 'AreaType'", NULL);\r
+        ErrorCount++;\r
+        goto Done;\r
+      }\r
+\r
+      if (!SFPIsToken ("=")) {\r
+        Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected '='", NULL);\r
+        WarningCount++;\r
+      }\r
+\r
+      if (!SFPGetQuotedString (FBlockDesc->AreaType, sizeof (FBlockDesc->AreaType))) {\r
+        Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected quoted AreaType string", NULL);\r
+        ErrorCount++;\r
+        goto Done;\r
+      }\r
+\r
+      PreviousComma = SFPIsToken (",");\r
+      //\r
+      // Parse optional Subregion definitions\r
+      //\r
+      SubregionSizeLeft = FBlockDesc->Size;\r
+      while (SFPIsToken ("Subregion")) {\r
+        if (!PreviousComma) {\r
+          Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected ',' before 'Subregion'", NULL);\r
+          WarningCount++;\r
+          PreviousComma = TRUE;\r
+        }\r
+\r
+        Subregion = ParseSubregionDefinition (SubregionSizeLeft);\r
+        if (Subregion == NULL) {\r
+          ErrorCount++;\r
+          goto Done;\r
+        }\r
+\r
+        SubregionSizeLeft -= Subregion->Size;\r
+        //\r
+        // Add it to the end of our list\r
+        //\r
+        if (FBlockDesc->Subregions == NULL) {\r
+          FBlockDesc->Subregions = Subregion;\r
+        } else {\r
+          FBlockDesc->LastSubregion->Next = Subregion;\r
+        }\r
+\r
+        FBlockDesc->LastSubregion = Subregion;\r
+        //\r
+        // Make sure all subregion names are unique. We do this each time\r
+        // through so that we catch the error immediately after it happens, in\r
+        // which case the reported line number is at least close to where the\r
+        // problem lies. We don't exit on the error because we can continue parsing\r
+        // the script to perhaps catch other errors or warnings.\r
+        //\r
+        for (Subregion = FBlockDesc->Subregions; Subregion != NULL; Subregion = Subregion->Next) {\r
+          for (TempSubregion = Subregion->Next; TempSubregion != NULL; TempSubregion = TempSubregion->Next) {\r
+            if (strcmp (Subregion->Name, TempSubregion->Name) == 0) {\r
+              Error (SFPGetFileName (), SFPGetLineNumber (), 0, Subregion->Name, "duplicate Subregion name");\r
+              ErrorCount++;\r
+            }\r
+          }\r
+        }\r
+      }\r
+\r
+      if (!SFPIsToken ("}")) {\r
+        Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected Region closing brace '}'", NULL);\r
+        WarningCount++;\r
+      }\r
+      //\r
+      // Add the region descriptor to the end of the linked list\r
+      //\r
+      if (FDDesc->LastRegion != NULL) {\r
+        FDDesc->LastRegion->Next = FBlockDesc;\r
+      } else {\r
+        FDDesc->Regions = FBlockDesc;\r
+      }\r
+\r
+      FDDesc->LastRegion = FBlockDesc;\r
+    }\r
+    //\r
+    // Make sure sum of sizes of regions adds up to size of flash device\r
+    //\r
+    if (RegionSizeLeft != 0) {\r
+      Error (\r
+        SFPGetFileName (),\r
+        SFPGetLineNumber (),\r
+        0,\r
+        NULL,\r
+        "sum of sizes of Regions (0x%08X) != flash device size (0x%08X) : delta = 0x%08X",\r
+        FDDesc->Size - RegionSizeLeft,\r
+        FDDesc->Size,\r
+        RegionSizeLeft\r
+        );\r
+      ErrorCount++;\r
+    }\r
+    //\r
+    // Look for closing brace\r
+    //\r
+    if (!SFPIsToken ("}")) {\r
+      Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected FlashDevice closing brace '}'", NULL);\r
+      WarningCount++;\r
+    }\r
+    //\r
+    // Add this flash description to the list\r
+    //\r
+    FDDesc->Next  = mFlashDevices;\r
+    mFlashDevices = FDDesc;\r
+  }\r
+\r
+  while (SFPIsKeyword ("FlashDeviceImage")) {\r
+    //\r
+    // Allocate memory for a new FD image definition\r
+    //\r
+    ImageDef = (IMAGE_DEFINITION *) _malloc (sizeof (IMAGE_DEFINITION));\r
+    if (ImageDef == NULL) {\r
+      Error (__FILE__, __LINE__, 0, "memory allocation failure", NULL);\r
+      ErrorCount++;\r
+      goto Done;\r
+    }\r
+\r
+    memset (ImageDef, 0, sizeof (IMAGE_DEFINITION));\r
+    //\r
+    // Open brace -- warning if not there\r
+    //\r
+    if (!SFPIsToken ("{")) {\r
+      Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected {", NULL);\r
+      WarningCount++;\r
+    }\r
+    //\r
+    // Parse:  Name = "ImageName",\r
+    //\r
+    if (!SFPIsKeyword ("Name")) {\r
+      Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected 'Name'", NULL);\r
+      ErrorCount++;\r
+      goto Done;\r
+    }\r
+\r
+    if (!SFPIsToken ("=")) {\r
+      Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected '='", NULL);\r
+      WarningCount++;\r
+    }\r
+\r
+    if (!SFPGetQuotedString (ImageDef->Name, sizeof (ImageDef->Name))) {\r
+      Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected quoted name of image", NULL);\r
+      ErrorCount++;\r
+      goto Done;\r
+    }\r
+\r
+    if (!SFPIsToken (",")) {\r
+      Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected comma following image name", NULL);\r
+      WarningCount++;\r
+    }\r
+\r
+    while (1) {\r
+      //\r
+      // Parse: File { Name = "FV\FvOem.fv", Region = "REGION_OEM", Optional = TRUE }\r
+      //\r
+      if (SFPIsKeyword ("File")) {\r
+        ImageDefEntry = (IMAGE_DEFINITION_ENTRY *) _malloc (sizeof (IMAGE_DEFINITION_ENTRY));\r
+        if (ImageDefEntry == NULL) {\r
+          Error (__FILE__, __LINE__, 0, "memory allocation failure", NULL);\r
+          ErrorCount++;\r
+          goto Done;\r
+        }\r
+\r
+        memset (ImageDefEntry, 0, sizeof (IMAGE_DEFINITION_ENTRY));\r
+        //\r
+        // Open brace -- warning if not there\r
+        //\r
+        if (!SFPIsToken ("{")) {\r
+          Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected {", NULL);\r
+          WarningCount++;\r
+        }\r
+        //\r
+        // Parse: Name = "FileName.txt"\r
+        //\r
+        if (!SFPIsKeyword ("Name")) {\r
+          Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected 'Name'", NULL);\r
+          ErrorCount++;\r
+          goto Done;\r
+        }\r
+\r
+        if (!SFPIsToken ("=")) {\r
+          Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected '='", NULL);\r
+          WarningCount++;\r
+        }\r
+\r
+        if (!SFPGetQuotedString (ImageDefEntry->Name, sizeof (ImageDefEntry->Name))) {\r
+          Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected quoted name of file", NULL);\r
+          ErrorCount++;\r
+          goto Done;\r
+        }\r
+\r
+        if (!SFPIsToken (",")) {\r
+          Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected comma following file name", NULL);\r
+          WarningCount++;\r
+        }\r
+        //\r
+        // Parse: Region = "REGION_NAME"\r
+        //\r
+        if (!SFPIsKeyword ("Region")) {\r
+          Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected 'Region'", NULL);\r
+          ErrorCount++;\r
+          goto Done;\r
+        }\r
+\r
+        if (!SFPIsToken ("=")) {\r
+          Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected '='", NULL);\r
+          WarningCount++;\r
+        }\r
+\r
+        if (!SFPGetQuotedString (ImageDefEntry->RegionName, sizeof (ImageDefEntry->RegionName))) {\r
+          Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected quoted Region name", NULL);\r
+          ErrorCount++;\r
+          goto Done;\r
+        }\r
+\r
+        if (!SFPIsToken (",")) {\r
+          Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected comma following Region name", NULL);\r
+          WarningCount++;\r
+        }\r
+        //\r
+        // Parse optional: Subregion = "SUBREGION_NAME"\r
+        //\r
+        if (SFPIsKeyword ("Subregion")) {\r
+          if (!SFPIsToken ("=")) {\r
+            Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected '='", NULL);\r
+            WarningCount++;\r
+          }\r
+\r
+          if (!SFPGetQuotedString (ImageDefEntry->SubregionName, sizeof (ImageDefEntry->SubregionName))) {\r
+            Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected quoted Subegion name", NULL);\r
+            ErrorCount++;\r
+            goto Done;\r
+          }\r
+\r
+          if (!SFPIsToken (",")) {\r
+            Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected comma following Subregion name", NULL);\r
+            WarningCount++;\r
+          }\r
+          //\r
+          // For a given region, you can only place data using the region name, or the subregion names.\r
+          // In other words, you can't say File1->Region1 and File2->Region1.Subregion1. Enforce that\r
+          // here by checking that any previous entries with the same Region name had a Subregion specified\r
+          // as well.\r
+          //\r
+          for (TempImageDefEntry = ImageDef->Entries;\r
+               TempImageDefEntry != NULL;\r
+               TempImageDefEntry = TempImageDefEntry->Next\r
+              ) {\r
+            if (strcmp (TempImageDefEntry->Name, ImageDefEntry->Name) == 0) {\r
+              if (TempImageDefEntry->SubregionName[0] == 0) {\r
+                Error (\r
+                  SFPGetFileName (),\r
+                  SFPGetLineNumber (),\r
+                  0,\r
+                  TempImageDefEntry->RegionName,\r
+                  "data already placed on a region-basis in the region, can't place data using subregions"\r
+                  );\r
+                ErrorCount++;\r
+              }\r
+            }\r
+          }\r
+        }\r
+        //\r
+        // Optional parse: Optional = TRUE | FALSE\r
+        //\r
+        if (SFPIsKeyword ("Optional")) {\r
+          if (!SFPIsToken ("=")) {\r
+            Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected '='", NULL);\r
+            WarningCount++;\r
+          }\r
+\r
+          if (!SFPIsKeyword ("TRUE")) {\r
+            ImageDefEntry->Optional = 1;\r
+          } else if (SFPIsKeyword ("FALSE")) {\r
+            //\r
+            // Already set to 0\r
+            //\r
+          } else {\r
+            Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected 'TRUE' or 'FALSE'", NULL);\r
+            ErrorCount++;\r
+            goto Done;\r
+          }\r
+\r
+          SFPIsToken (",");\r
+        }\r
+        //\r
+        // Closing brace\r
+        //\r
+        if (!SFPIsToken ("}")) {\r
+          Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected '}' closing brace to File entry", NULL);\r
+          ErrorCount++;\r
+          goto Done;\r
+        }\r
+        //\r
+        // Add the entry to the end of the list\r
+        //\r
+        if (ImageDef->LastEntry != NULL) {\r
+          ImageDef->LastEntry->Next = ImageDefEntry;\r
+        } else {\r
+          ImageDef->Entries = ImageDefEntry;\r
+        }\r
+\r
+        ImageDef->LastEntry = ImageDefEntry;\r
+      } else if (SFPIsKeyword ("RawData")) {\r
+        //\r
+        // Parse: RawData { Name = "PadBytes", Region = "REGION_1", Data = { 0x78, 0x56, 0x34, 0x12 }}\r
+        //\r
+        ImageDefEntry = (IMAGE_DEFINITION_ENTRY *) _malloc (sizeof (IMAGE_DEFINITION_ENTRY));\r
+        if (ImageDefEntry == NULL) {\r
+          Error (__FILE__, __LINE__, 0, "memory allocation failure", NULL);\r
+          ErrorCount++;\r
+          goto Done;\r
+        }\r
+\r
+        memset (ImageDefEntry, 0, sizeof (IMAGE_DEFINITION_ENTRY));\r
+        ImageDefEntry->IsRawData = 1;\r
+        //\r
+        // Open brace -- warning if not there\r
+        //\r
+        if (!SFPIsToken ("{")) {\r
+          Warning (\r
+            SFPGetFileName (),\r
+            SFPGetLineNumber (),\r
+            0,\r
+            "expected '{' opening brace for RawData definition",\r
+            NULL\r
+            );\r
+          WarningCount++;\r
+        }\r
+        //\r
+        // Parse: Name = "PadBytes"\r
+        //\r
+        if (!SFPIsKeyword ("Name")) {\r
+          Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected 'Name'", NULL);\r
+          ErrorCount++;\r
+          goto Done;\r
+        }\r
+\r
+        if (!SFPIsToken ("=")) {\r
+          Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected '='", NULL);\r
+          WarningCount++;\r
+        }\r
+\r
+        if (!SFPGetQuotedString (ImageDefEntry->Name, sizeof (ImageDefEntry->Name))) {\r
+          Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected quoted name of raw data", NULL);\r
+          ErrorCount++;\r
+          goto Done;\r
+        }\r
+\r
+        if (!SFPIsToken (",")) {\r
+          Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected comma following raw data name", NULL);\r
+          WarningCount++;\r
+        }\r
+        //\r
+        // Parse: Region = "REGION_NAME"\r
+        //\r
+        if (!SFPIsKeyword ("Region")) {\r
+          Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected 'Region'", NULL);\r
+          ErrorCount++;\r
+          goto Done;\r
+        }\r
+\r
+        if (!SFPIsToken ("=")) {\r
+          Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected '='", NULL);\r
+          WarningCount++;\r
+        }\r
+\r
+        if (!SFPGetQuotedString (ImageDefEntry->RegionName, sizeof (ImageDefEntry->RegionName))) {\r
+          Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected quoted Region name", NULL);\r
+          ErrorCount++;\r
+          goto Done;\r
+        }\r
+\r
+        if (!SFPIsToken (",")) {\r
+          Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected comma following Region name", NULL);\r
+          WarningCount++;\r
+        }\r
+        //\r
+        // Parse optional: Subregion = "SUBREGION_NAME"\r
+        //\r
+        if (SFPIsKeyword ("Subregion")) {\r
+          if (!SFPIsToken ("=")) {\r
+            Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected '='", NULL);\r
+            WarningCount++;\r
+          }\r
+\r
+          if (!SFPGetQuotedString (ImageDefEntry->SubregionName, sizeof (ImageDefEntry->SubregionName))) {\r
+            Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected quoted Subegion name", NULL);\r
+            ErrorCount++;\r
+            goto Done;\r
+          }\r
+\r
+          if (!SFPIsToken (",")) {\r
+            Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected comma following Subregion name", NULL);\r
+            WarningCount++;\r
+          }\r
+          //\r
+          // For a given region, you can only place data using the region name, or the subregion names.\r
+          // In other words, you can't say File1->Region1 and File2->Region1.Subregion1. Enforce that\r
+          // here by checking that any previous entries with the same Region name had a Subregion specified\r
+          // as well.\r
+          //\r
+          for (TempImageDefEntry = ImageDef->Entries;\r
+               TempImageDefEntry != NULL;\r
+               TempImageDefEntry = TempImageDefEntry->Next\r
+              ) {\r
+            if (strcmp (TempImageDefEntry->Name, ImageDefEntry->Name) == 0) {\r
+              if (TempImageDefEntry->SubregionName[0] == 0) {\r
+                Error (\r
+                  SFPGetFileName (),\r
+                  SFPGetLineNumber (),\r
+                  0,\r
+                  TempImageDefEntry->RegionName,\r
+                  "data already placed on a region-basis in the region, can't place data using subregions"\r
+                  );\r
+                ErrorCount++;\r
+              }\r
+            }\r
+          }\r
+        }\r
+        //\r
+        // Parse: Data = { 0x78, 0x56, 0x34, 0x12 }\r
+        //\r
+        if (!SFPIsKeyword ("Data")) {\r
+          Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected 'Data'", NULL);\r
+          ErrorCount++;\r
+          goto Done;\r
+        }\r
+\r
+        if (!SFPIsToken ("=")) {\r
+          Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected '='", NULL);\r
+          WarningCount++;\r
+        }\r
+\r
+        if (!SFPIsToken ("{")) {\r
+          Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected '{' preceeding data list", NULL);\r
+          WarningCount++;\r
+        }\r
+\r
+        if ((BufferData = CreateBufferData ()) == NULL) {\r
+          ErrorCount++;\r
+          goto Done;\r
+        }\r
+        //\r
+        // Read bytes from input file until closing brace\r
+        //\r
+        while (!SFPIsToken ("}")) {\r
+          if (!SFPGetNumber (&Num)) {\r
+            SFPGetNextToken (Str, sizeof (Str));\r
+            Error (SFPGetFileName (), SFPGetLineNumber (), 0, Str, "expected data value", Str);\r
+            ErrorCount++;\r
+            FreeBufferData (BufferData, TRUE);\r
+            goto Done;\r
+          } else {\r
+            //\r
+            // Only allow bytes\r
+            //\r
+            if (Num > 0xFF) {\r
+              Error (SFPGetFileName (), SFPGetLineNumber (), 0, "only values 0-255 (0x00-0xFF) allowed", NULL);\r
+              ErrorCount++;\r
+              FreeBufferData (BufferData, TRUE);\r
+              goto Done;\r
+            }\r
+\r
+            AddBufferDataByte (BufferData, (char) Num);\r
+            SFPIsToken (",");\r
+          }\r
+        }\r
+        //\r
+        // Now get the data and save it in our image entry\r
+        //\r
+        ImageDefEntry->RawData = GetBufferData (BufferData, &ImageDefEntry->RawDataSize);\r
+        FreeBufferData (BufferData, 0);\r
+        //\r
+        // Closing brace for RawData {}\r
+        //\r
+        if (!SFPIsToken ("}")) {\r
+          Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected '}' closing brace for RawData", NULL);\r
+          ErrorCount++;\r
+          goto Done;\r
+        }\r
+        //\r
+        // Add the entry to the end of the list\r
+        //\r
+        if (ImageDef->LastEntry != NULL) {\r
+          ImageDef->LastEntry->Next = ImageDefEntry;\r
+        } else {\r
+          ImageDef->Entries = ImageDefEntry;\r
+        }\r
+\r
+        ImageDef->LastEntry = ImageDefEntry;\r
+      } else if (SFPIsToken ("}")) {\r
+        //\r
+        // Closing brace for FDImage {}\r
+        //\r
+        break;\r
+      } else {\r
+        SFPGetNextToken (Str, sizeof (Str));\r
+        Error (SFPGetFileName (), SFPGetLineNumber (), 0, Str, "unrecognized token", Str);\r
+        ErrorCount++;\r
+        goto Done;\r
+      }\r
+    }\r
+    //\r
+    // Add this image definition to our global list\r
+    //\r
+    ImageDef->Next    = mImageDefinitions;\r
+    mImageDefinitions = ImageDef;\r
+  }\r
+  //\r
+  // Check for end-of-file\r
+  //\r
+  if (!SFPIsEOF ()) {\r
+    SFPGetNextToken (Str, sizeof (Str));\r
+    Error (SFPGetFileName (), SFPGetLineNumber (), 0, Str, "expected end-of-file", Str);\r
+    ErrorCount++;\r
+  }\r
+\r
+Done:\r
+  SFPCloseFile ();\r
+  if (ErrorCount != 0) {\r
+    return STATUS_ERROR;\r
+  } else if (WarningCount != 0) {\r
+    return STATUS_WARNING;\r
+  }\r
+\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+FLASH_SUBREGION_DESCRIPTION *\r
+ParseSubregionDefinition (\r
+  unsigned int  SizeLeft\r
+  )\r
+/*++\r
+  \r
+Routine Description:\r
+\r
+  Parse Subregion definitions from the input flash definition file. Format:\r
+\r
+    Subregion {\r
+      CreateHob       = TRUE,\r
+      Name            = "FOO",\r
+      Size            = 0xA000,\r
+      Attributes      = "EFI_FLASH_AREA_SUBFV | EFI_FLASH_AREA_MEMMAPPED_FV",\r
+      AreaType        = "EFI_FLASH_AREA_EFI_VARIABLES",\r
+      NameGuid        = 12345678-1234-5678-AAAA-BBBBCCCCDDDD (or "EFI_SOME_GUID"),\r
+      AreaTypeGuid    = 11111111-2222-3333-4444-1, (or "EFI_SOME_GUID") (optional)\r
+      FileSystemGuid  = 11111111-2222-3333-4444-1, (or "EFI_SOME_GUID") (optional)\r
+    }\r
+\r
+    NOTE: The caller has already parsed the "Subregion" token, so start with the opening brace.\r
+\r
+Arguments:\r
+   \r
+   SizeLeft   - in the flash definition file, a Region can be broken up into\r
+                one or more subregions. As we parse the subregion definitions,\r
+                the caller keeps track of how much space is left in the region\r
+                that we're parsing subregions for. SizeLeft is that size, and\r
+                so the size of the subregion we're now parsing better not\r
+                exceed the size left.\r
+  Returns:\r
+\r
+    NULL    - unrecoverable errors detected while parsing the subregion definition\r
+\r
+    pointer to a subregion definition created from the parsed subregion\r
+\r
+--*/\r
+{\r
+  FLASH_SUBREGION_DESCRIPTION *Subregion;\r
+  int                         ErrorCount;\r
+  int                         WarningCount;\r
+  unsigned int                Number;\r
+  BOOLEAN                     PreviousComma;\r
+  //\r
+  // Allocate memory for the new subregion descriptor\r
+  //\r
+  ErrorCount    = 0;\r
+  WarningCount  = 0;\r
+  Subregion     = (FLASH_SUBREGION_DESCRIPTION *) _malloc (sizeof (FLASH_SUBREGION_DESCRIPTION));\r
+  if (Subregion == NULL) {\r
+    Error (__FILE__, __LINE__, 0, "memory allocation failure", NULL);\r
+    ErrorCount++;\r
+    goto Done;\r
+  }\r
+\r
+  memset (Subregion, 0, sizeof (FLASH_SUBREGION_DESCRIPTION));\r
+  //\r
+  // Open brace -- warning if not there\r
+  //\r
+  if (!SFPIsToken ("{")) {\r
+    Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected {", NULL);\r
+    WarningCount++;\r
+  }\r
+  //\r
+  // Parse:  CreateHob = TRUE | FALSE,\r
+  //\r
+  if (!SFPIsKeyword ("CreateHob")) {\r
+    Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected 'CreateHob'", NULL);\r
+    ErrorCount++;\r
+    goto Done;\r
+  }\r
+\r
+  if (!SFPIsToken ("=")) {\r
+    Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected '='", NULL);\r
+    WarningCount++;\r
+  }\r
+\r
+  if (SFPIsToken ("TRUE")) {\r
+    Subregion->CreateHob = 1;\r
+  } else if (SFPIsToken ("FALSE")) {\r
+    //\r
+    // Subregion->CreateHob = 0; -- not required since we did a memset earlier\r
+    //\r
+  } else {\r
+    Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected 'TRUE' or 'FALSE'", NULL);\r
+    ErrorCount++;\r
+    goto Done;\r
+  }\r
+\r
+  if (!SFPIsToken (",")) {\r
+    Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected ',' following CreateHob value", NULL);\r
+    WarningCount++;\r
+  }\r
+  //\r
+  // Parse:  Name = "Name",\r
+  //\r
+  if (!SFPIsKeyword ("Name")) {\r
+    Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected 'Name'", NULL);\r
+    ErrorCount++;\r
+    goto Done;\r
+  }\r
+\r
+  if (!SFPIsToken ("=")) {\r
+    Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected '='", NULL);\r
+    WarningCount++;\r
+  }\r
+\r
+  if (!SFPGetQuotedString (Subregion->Name, sizeof (Subregion->Name))) {\r
+    Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected Subregion name", NULL);\r
+    ErrorCount++;\r
+    goto Done;\r
+  }\r
+\r
+  if (!SFPIsToken (",")) {\r
+    Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected comma following Region name", NULL);\r
+    WarningCount++;\r
+  }\r
+  //\r
+  // Parse: Size = 0x2000,\r
+  //\r
+  if (!SFPIsKeyword ("Size")) {\r
+    Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected 'Size'", NULL);\r
+    ErrorCount++;\r
+    goto Done;\r
+  }\r
+\r
+  if (!SFPIsToken ("=")) {\r
+    Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected '='", NULL);\r
+    WarningCount++;\r
+  }\r
+\r
+  if (!SFPGetNumber (&Subregion->Size)) {\r
+    Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected numeric Size value", NULL);\r
+    ErrorCount++;\r
+    goto Done;\r
+  }\r
+\r
+  //\r
+  // Check that the size does not exceed the size left passed in\r
+  //\r
+  if (Subregion->Size > SizeLeft) {\r
+    Error (SFPGetFileName (), SFPGetLineNumber (), 0, "sum of Subregion sizes exceeds Region size", NULL);\r
+    ErrorCount++;\r
+    goto Done;\r
+  }\r
+\r
+  if (!SFPIsToken (",")) {\r
+    Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected ',' following Size value", NULL);\r
+  }\r
+  //\r
+  // Parse:  Attributes = Number | "String",\r
+  //\r
+  if (!SFPIsKeyword ("Attributes")) {\r
+    Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected 'Attributes'", NULL);\r
+    ErrorCount++;\r
+    goto Done;\r
+  }\r
+\r
+  if (!SFPIsToken ("=")) {\r
+    Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected '='", NULL);\r
+    WarningCount++;\r
+  }\r
+\r
+  if (SFPGetNumber (&Number)) {\r
+    sprintf (Subregion->Attributes, "0x%X", Number);\r
+  } else if (!SFPGetQuotedString (Subregion->Attributes, sizeof (Subregion->Attributes))) {\r
+    Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected quoted Attributes string", NULL);\r
+    ErrorCount++;\r
+    goto Done;\r
+  }\r
+\r
+  if (!SFPIsToken (",")) {\r
+    Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected ','", NULL);\r
+  }\r
+  //\r
+  // Parse:  AreaType = Number | "String",\r
+  // AreaType is a UINT8, so error if it exceeds the size\r
+  //\r
+  if (!SFPIsKeyword ("AreaType")) {\r
+    Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected 'AreaType'", NULL);\r
+    ErrorCount++;\r
+    goto Done;\r
+  }\r
+\r
+  if (!SFPIsToken ("=")) {\r
+    Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected '='", NULL);\r
+    WarningCount++;\r
+  }\r
+\r
+  if (SFPGetNumber (&Number)) {\r
+    if (Number > 0xFF) {\r
+      Error (SFPGetFileName (), SFPGetLineNumber (), 0, "AreaType value exceeds 255", NULL);\r
+      ErrorCount++;\r
+    }\r
+\r
+    sprintf (Subregion->AreaType, "0x%X", Number & 0x00FF);\r
+  } else if (!SFPGetQuotedString (Subregion->AreaType, sizeof (Subregion->AreaType))) {\r
+    Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected quoted AreaType string", NULL);\r
+    ErrorCount++;\r
+    goto Done;\r
+  }\r
+\r
+  if (!SFPIsToken (",")) {\r
+    Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected ',' following AreaType value", NULL);\r
+  }\r
+  //\r
+  // Parse the three GUIDs (last two are optional)\r
+  //\r
+  //    NameGuid        = 12345678-1234-5678-AAAA-BBBBCCCCDDDD, (or "EFI_SOME_GUID")\r
+  //    AreaTypeGuid    = 11111111-2222-3333-4444-1, (or "EFI_SOME_GUID")\r
+  //    FileSysteGuid   = 11111111-2222-3333-4444-1, (or "EFI_SOME_GUID")\r
+  //\r
+  if (!SFPIsKeyword ("NameGuid")) {\r
+    Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected 'NameGuid'", NULL);\r
+    ErrorCount++;\r
+    goto Done;\r
+  }\r
+\r
+  if (!SFPIsToken ("=")) {\r
+    Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected '='", NULL);\r
+    WarningCount++;\r
+  }\r
+  //\r
+  // Allow a GUID or a quoted string identifier, which we'll just copy as a string\r
+  //\r
+  if (SFPGetQuotedString (Subregion->NameGuidString, sizeof (Subregion->NameGuidString))) {\r
+    //\r
+    // Nothing else to do\r
+    //\r
+  } else if (!SFPGetGuid (PARSE_GUID_STYLE_5_FIELDS, &Subregion->NameGuid)) {\r
+    Error (\r
+      SFPGetFileName (),\r
+      SFPGetLineNumber (),\r
+      0,\r
+      "expected NameGuid quoted string or GUID of form 12345678-1234-1234-1234-123456789ABC",\r
+      NULL\r
+      );\r
+    ErrorCount++;\r
+    goto Done;\r
+  }\r
+  //\r
+  // Comma following NameGuid is optional if they don't specify AreaTypeGuid or FileSystemGuid\r
+  //\r
+  PreviousComma = SFPIsToken (",");\r
+  if (SFPIsKeyword ("AreaTypeGuid")) {\r
+    //\r
+    // Check for preceeding comma now\r
+    //\r
+    if (!PreviousComma) {\r
+      Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected ',' before 'AreaTypeGuid'", NULL);\r
+      WarningCount++;\r
+    }\r
+\r
+    if (!SFPIsToken ("=")) {\r
+      Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected '='", NULL);\r
+      WarningCount++;\r
+    }\r
+\r
+    if (SFPGetQuotedString (Subregion->AreaTypeGuidString, sizeof (Subregion->AreaTypeGuidString))) {\r
+      //\r
+      // Nothing else to do\r
+      //\r
+    } else if (!SFPGetGuid (PARSE_GUID_STYLE_5_FIELDS, &Subregion->AreaTypeGuid)) {\r
+      Error (\r
+        SFPGetFileName (),\r
+        SFPGetLineNumber (),\r
+        0,\r
+        "expected AreaTypeGuid quoted string or GUID of form 12345678-1234-1234-1234-123456789ABC",\r
+        NULL\r
+        );\r
+      ErrorCount++;\r
+      goto Done;\r
+    }\r
+\r
+    PreviousComma = SFPIsToken (",");\r
+  }\r
+\r
+  if (SFPIsKeyword ("FileSystemGuid")) {\r
+    //\r
+    // Check for preceeding comma now\r
+    //\r
+    if (!PreviousComma) {\r
+      Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected ',' before 'FileSystemGuid'", NULL);\r
+      WarningCount++;\r
+    }\r
+\r
+    if (!SFPIsToken ("=")) {\r
+      Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected '='", NULL);\r
+      WarningCount++;\r
+    }\r
+    //\r
+    // Allow a GUID or a quoted string identifier, which we'll just copy as a string\r
+    //\r
+    if (SFPGetQuotedString (Subregion->FileSystemGuidString, sizeof (Subregion->FileSystemGuidString))) {\r
+      //\r
+      // Nothing else to do\r
+      //\r
+    } else if (!SFPGetGuid (PARSE_GUID_STYLE_5_FIELDS, &Subregion->FileSystemGuid)) {\r
+      Error (\r
+        SFPGetFileName (),\r
+        SFPGetLineNumber (),\r
+        0,\r
+        "expected FileSystemGuid quoted string or GUID of form 12345678-1234-1234-1234-123456789ABC",\r
+        NULL\r
+        );\r
+      ErrorCount++;\r
+      goto Done;\r
+    }\r
+\r
+    SFPIsToken (",");\r
+  }\r
+  //\r
+  // Look for subregion closing brace\r
+  //\r
+  if (!SFPIsToken ("}")) {\r
+    Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected Subregion closing brace '}'", NULL);\r
+    WarningCount++;\r
+  }\r
+\r
+Done:\r
+  //\r
+  // If any errors were encountered, then delete the subregion definition\r
+  //\r
+  if (ErrorCount != 0) {\r
+    _free (Subregion);\r
+    Subregion = NULL;\r
+  }\r
+\r
+  return Subregion;\r
+}\r
+\r
+STATUS\r
+FDFCreateCIncludeFile (\r
+  char      *FlashDeviceName,\r
+  char      *FileName\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Create a header file with #define definitions per an already-parsed\r
+  flash definition file.\r
+\r
+Arguments:\r
+  FlashDeviceName - name of flash device (from the flash definition file)\r
+                    to use\r
+  FileName        - name of output file to create\r
+\r
+Returns:\r
+  STATUS_SUCCESS    - no errors or warnings\r
+  STATUS_WARNING    - warnings, but no errors, were encountered\r
+  STATUS_ERROR      - errors were encountered\r
+\r
+--*/\r
+{\r
+  FILE                        *OutFptr;\r
+  FLASH_BLOCK_DESCRIPTION     *FBlock;\r
+  FLASH_DEVICE_DESCRIPTION    *FDev;\r
+  FLASH_SUBREGION_DESCRIPTION *Subregion;\r
+  unsigned int                Offset;\r
+  unsigned int                SubregionOffset;\r
+  int                         CreateHobs;\r
+  //\r
+  // Find the definition we're supposed to use\r
+  //\r
+  for (FDev = mFlashDevices; FDev != NULL; FDev = FDev->Next) {\r
+    if (strcmp (FDev->Name, FlashDeviceName) == 0) {\r
+      break;\r
+    }\r
+  }\r
+\r
+  if (FDev == NULL) {\r
+    Error (NULL, 0, 0, NULL, FlashDeviceName, "flash device not found in flash definitions");\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  if ((OutFptr = fopen (FileName, "w")) == NULL) {\r
+    Error (NULL, 0, 0, FileName, "failed to open output file for writing");\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Write a header\r
+  //\r
+  fprintf (OutFptr, CIncludeHeader);\r
+  //\r
+  // Write flash block base and size defines\r
+  //\r
+  fprintf (OutFptr, "#define FLASH_BASE                                          0x%08X\n", FDev->BaseAddress);\r
+  fprintf (OutFptr, "#define FLASH_SIZE                                          0x%08X\n\n", FDev->Size);\r
+  //\r
+  // Write flash regions base, size and offset defines\r
+  //\r
+  Offset      = 0;\r
+  CreateHobs  = 0;\r
+  for (FBlock = FDev->Regions; FBlock != NULL; FBlock = FBlock->Next) {\r
+    fprintf (\r
+      OutFptr,\r
+      "#define FLASH_REGION_%s_BASE              %*c0x%08X\n",\r
+      FBlock->Name,\r
+      COLUMN2_START - 40 - strlen (FBlock->Name),\r
+      ' ',\r
+      Offset + FDev->BaseAddress\r
+      );\r
+    fprintf (\r
+      OutFptr,\r
+      "#define FLASH_REGION_%s_SIZE              %*c0x%08X\n",\r
+      FBlock->Name,\r
+      COLUMN2_START - 40 - strlen (FBlock->Name),\r
+      ' ',\r
+      FBlock->Size\r
+      );\r
+    fprintf (\r
+      OutFptr,\r
+      "#define FLASH_REGION_%s_OFFSET            %*c0x%08X\n",\r
+      FBlock->Name,\r
+      COLUMN2_START - 40 - strlen (FBlock->Name),\r
+      ' ',\r
+      Offset\r
+      );\r
+    //\r
+    // Create defines for any subregions\r
+    //\r
+    SubregionOffset = 0;\r
+    for (Subregion = FBlock->Subregions; Subregion != NULL; Subregion = Subregion->Next) {\r
+      fprintf (\r
+        OutFptr,\r
+        "#define FLASH_REGION_%s_SUBREGION_%s_BASE     %*c0x%08X\n",\r
+        FBlock->Name,\r
+        Subregion->Name,\r
+        COLUMN3_START - 43 - strlen (FBlock->Name) - strlen (Subregion->Name),\r
+        ' ',\r
+        FDev->BaseAddress + Offset + SubregionOffset\r
+        );\r
+      fprintf (\r
+        OutFptr,\r
+        "#define FLASH_REGION_%s_SUBREGION_%s_SIZE     %*c0x%08X\n",\r
+        FBlock->Name,\r
+        Subregion->Name,\r
+        COLUMN3_START - 43 - strlen (FBlock->Name) - strlen (Subregion->Name),\r
+        ' ',\r
+        Subregion->Size\r
+        );\r
+      fprintf (\r
+        OutFptr,\r
+        "#define FLASH_REGION_%s_SUBREGION_%s_OFFSET   %*c0x%08X\n",\r
+        FBlock->Name,\r
+        Subregion->Name,\r
+        COLUMN3_START - 43 - strlen (FBlock->Name) - strlen (Subregion->Name),\r
+        ' ',\r
+        Offset + SubregionOffset\r
+        );\r
+      SubregionOffset += Subregion->Size;\r
+      if (Subregion->CreateHob != 0) {\r
+        CreateHobs = 1;\r
+      }\r
+    }\r
+\r
+    Offset += FBlock->Size;\r
+  }\r
+  //\r
+  // Now create a #define for the flash map data definition\r
+  //\r
+  fprintf (OutFptr, "\n\n#define EFI_FLASH_AREA_DATA_DEFINITION \\\n");\r
+  //\r
+  // Emit entry for each region\r
+  //\r
+  Offset = 0;\r
+  for (FBlock = FDev->Regions; FBlock != NULL; FBlock = FBlock->Next) {\r
+    fprintf (OutFptr, "  /* %s region */\\\n", FBlock->Name);\r
+    fprintf (OutFptr, "  {\\\n");\r
+    fprintf (OutFptr, "    FLASH_REGION_%s_BASE,\\\n", FBlock->Name);\r
+    fprintf (OutFptr, "    FLASH_REGION_%s_SIZE,\\\n", FBlock->Name);\r
+    fprintf (OutFptr, "    %s,\\\n", FBlock->Attributes);\r
+    fprintf (OutFptr, "    %s,\\\n  },\\\n", FBlock->AreaType);\r
+  }\r
+\r
+  fprintf (OutFptr, "\n\n");\r
+  //\r
+  // Now walk the list again to create the EFI_HOB_FLASH_MAP_ENTRY_TYPE definition\r
+  //\r
+  if (CreateHobs != 0) {\r
+    fprintf (OutFptr, "//\n// EFI_HOB_FLASH_MAP_ENTRY_TYPE definition\n//\n");\r
+    fprintf (OutFptr, "#define EFI_HOB_FLASH_MAP_ENTRY_TYPE_DATA_DEFINITION");\r
+    for (FBlock = FDev->Regions; FBlock != NULL; FBlock = FBlock->Next) {\r
+      //\r
+      // See if the block has subregions, and that the CreateHobs flag is set\r
+      // for any of them.\r
+      //\r
+      CreateHobs = 0;\r
+      for (Subregion = FBlock->Subregions; Subregion != NULL; Subregion = Subregion->Next) {\r
+        if (Subregion->CreateHob != 0) {\r
+          CreateHobs = 1;\r
+          break;\r
+        }\r
+      }\r
+      //\r
+      // If any of the subregions had the CreateHobs flag set, then create the entries in the\r
+      // output file\r
+      //\r
+      if (CreateHobs != 0) {\r
+        for (Subregion = FBlock->Subregions; Subregion != NULL; Subregion = Subregion->Next) {\r
+          if (Subregion->CreateHob != 0) {\r
+            fprintf (OutFptr, " \\\n");\r
+            fprintf (OutFptr, "  /* %s.%s Subregion */\\\n", FBlock->Name, Subregion->Name);\r
+            fprintf (OutFptr, "  {\\\n");\r
+            fprintf (OutFptr, "    EFI_HOB_TYPE_GUID_EXTENSION,\\\n");\r
+            fprintf (OutFptr, "    sizeof (EFI_HOB_FLASH_MAP_ENTRY_TYPE ),\\\n");\r
+            fprintf (OutFptr, "    0,\\\n");\r
+            //\r
+            // The NameGuid may have been specified in the input flash definition file as a GUID, or\r
+            // as a quoted string. Do the right one.\r
+            //\r
+            if (Subregion->NameGuidString[0] != 0) {\r
+              fprintf (OutFptr, "    %s, \\\n", Subregion->NameGuidString);\r
+            } else {\r
+              fprintf (\r
+                OutFptr,\r
+                "    { 0x%08X, 0x%04X, 0x%04X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X },\\\n",\r
+                Subregion->NameGuid.Data1,\r
+                (unsigned int) Subregion->NameGuid.Data2,\r
+                (unsigned int) Subregion->NameGuid.Data3,\r
+                (unsigned int) Subregion->NameGuid.Data4[0],\r
+                (unsigned int) Subregion->NameGuid.Data4[1],\r
+                (unsigned int) Subregion->NameGuid.Data4[2],\r
+                (unsigned int) Subregion->NameGuid.Data4[3],\r
+                (unsigned int) Subregion->NameGuid.Data4[4],\r
+                (unsigned int) Subregion->NameGuid.Data4[5],\r
+                (unsigned int) Subregion->NameGuid.Data4[6],\r
+                (unsigned int) Subregion->NameGuid.Data4[7]\r
+                );\r
+            }\r
+\r
+            fprintf (OutFptr, "    0, 0, 0,\\\n");\r
+            fprintf (OutFptr, "    %s,\\\n", Subregion->AreaType);\r
+            //\r
+            // The AreaTypeGuid may have been specified in the input flash definition file as a GUID, or\r
+            // as a quoted string. Do the right one.\r
+            //\r
+            if (Subregion->AreaTypeGuidString[0] != 0) {\r
+              fprintf (OutFptr, "    %s, \\\n", Subregion->AreaTypeGuidString);\r
+            } else {\r
+              fprintf (\r
+                OutFptr,\r
+                "    { 0x%08X, 0x%04X, 0x%04X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X },\\\n",\r
+                Subregion->AreaTypeGuid.Data1,\r
+                (unsigned int) Subregion->AreaTypeGuid.Data2,\r
+                (unsigned int) Subregion->AreaTypeGuid.Data3,\r
+                (unsigned int) Subregion->AreaTypeGuid.Data4[0],\r
+                (unsigned int) Subregion->AreaTypeGuid.Data4[1],\r
+                (unsigned int) Subregion->AreaTypeGuid.Data4[2],\r
+                (unsigned int) Subregion->AreaTypeGuid.Data4[3],\r
+                (unsigned int) Subregion->AreaTypeGuid.Data4[4],\r
+                (unsigned int) Subregion->AreaTypeGuid.Data4[5],\r
+                (unsigned int) Subregion->AreaTypeGuid.Data4[6],\r
+                (unsigned int) Subregion->AreaTypeGuid.Data4[7]\r
+                );\r
+            }\r
+\r
+            fprintf (OutFptr, "    1,\\\n");\r
+            fprintf (OutFptr, "    {\\\n");\r
+            fprintf (OutFptr, "      %s,\\\n", Subregion->Attributes);\r
+            fprintf (OutFptr, "      0,\\\n");\r
+            fprintf (OutFptr, "      FLASH_REGION_%s_SUBREGION_%s_BASE,\\\n", FBlock->Name, Subregion->Name);\r
+            fprintf (OutFptr, "      FLASH_REGION_%s_SUBREGION_%s_SIZE,\\\n", FBlock->Name, Subregion->Name);\r
+            //\r
+            // The FileSystemGuid may have been specified in the input flash definition file as a GUID, or\r
+            // as a quoted string. Do the right one.\r
+            //\r
+            if (Subregion->FileSystemGuidString[0] != 0) {\r
+              fprintf (OutFptr, "      %s, \\\n", Subregion->FileSystemGuidString);\r
+            } else {\r
+              fprintf (\r
+                OutFptr,\r
+                "      { 0x%08X, 0x%04X, 0x%04X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X },\\\n",\r
+                Subregion->FileSystemGuid.Data1,\r
+                (unsigned int) Subregion->FileSystemGuid.Data2,\r
+                (unsigned int) Subregion->FileSystemGuid.Data3,\r
+                (unsigned int) Subregion->FileSystemGuid.Data4[0],\r
+                (unsigned int) Subregion->FileSystemGuid.Data4[1],\r
+                (unsigned int) Subregion->FileSystemGuid.Data4[2],\r
+                (unsigned int) Subregion->FileSystemGuid.Data4[3],\r
+                (unsigned int) Subregion->FileSystemGuid.Data4[4],\r
+                (unsigned int) Subregion->FileSystemGuid.Data4[5],\r
+                (unsigned int) Subregion->FileSystemGuid.Data4[6],\r
+                (unsigned int) Subregion->FileSystemGuid.Data4[7]\r
+                );\r
+            }\r
+\r
+            fprintf (OutFptr, "    },\\\n");\r
+            fprintf (OutFptr, "  },");\r
+          }\r
+        }\r
+      }\r
+    }\r
+\r
+    fprintf (OutFptr, "\n\n");\r
+  }\r
+\r
+  //\r
+  // Write the file's closing #endif\r
+  //\r
+  fprintf (OutFptr, CIncludeFooter);\r
+  fclose (OutFptr);\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+STATUS\r
+FDFCreateAsmIncludeFile (\r
+  char      *FlashDeviceName,\r
+  char      *FileName\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Create an assembly header file with equate definitions per an already-parsed\r
+  flash definition file.\r
+\r
+Arguments:\r
+  FlashDeviceName - name of flash device (from the flash definition file)\r
+                    to use\r
+  FileName        - name of output file to create\r
+\r
+Returns:\r
+  STATUS_SUCCESS    - no errors or warnings\r
+  STATUS_WARNING    - warnings, but no errors, were encountered\r
+  STATUS_ERROR      - errors were encountered\r
+\r
+--*/\r
+{\r
+  FILE                        *OutFptr;\r
+  FLASH_BLOCK_DESCRIPTION     *FBlock;\r
+  FLASH_DEVICE_DESCRIPTION    *FDev;\r
+  unsigned int                Offset;\r
+  FLASH_SUBREGION_DESCRIPTION *Subregion;\r
+  unsigned int                SubregionOffset;\r
+  //\r
+  // Find the definition we're supposed to use\r
+  //\r
+  for (FDev = mFlashDevices; FDev != NULL; FDev = FDev->Next) {\r
+    if (strcmp (FDev->Name, FlashDeviceName) == 0) {\r
+      break;\r
+    }\r
+  }\r
+\r
+  if (FDev == NULL) {\r
+    Error (NULL, 0, 0, NULL, FlashDeviceName, "flash device not found in flash definitions");\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  if ((OutFptr = fopen (FileName, "w")) == NULL) {\r
+    Error (NULL, 0, 0, FileName, "failed to open output file for writing");\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Write a header\r
+  //\r
+  fprintf (OutFptr, "\n\n");\r
+  //\r
+  // Write flash block size and offset defines\r
+  //\r
+  fprintf (\r
+    OutFptr,\r
+    "FLASH_BASE                               %*cequ 0%08Xh\n",\r
+    COLUMN2_START - 40,\r
+    ' ',\r
+    FDev->BaseAddress\r
+    );\r
+  fprintf (OutFptr, "FLASH_SIZE                               %*cequ 0%08Xh\n", COLUMN2_START - 40, ' ', FDev->Size);\r
+  //\r
+  // Write flash region size and offset defines\r
+  //\r
+  fprintf (OutFptr, "\n");\r
+  Offset = 0;\r
+  for (FBlock = FDev->Regions; FBlock != NULL; FBlock = FBlock->Next) {\r
+    fprintf (\r
+      OutFptr,\r
+      "FLASH_REGION_%s_BASE   %*cequ 0%08Xh\n",\r
+      FBlock->Name,\r
+      COLUMN2_START - 20 - strlen (FBlock->Name),\r
+      ' ',\r
+      FDev->BaseAddress + Offset\r
+      );\r
+    fprintf (\r
+      OutFptr,\r
+      "FLASH_REGION_%s_SIZE   %*cequ 0%08Xh\n",\r
+      FBlock->Name,\r
+      COLUMN2_START - 20 - strlen (FBlock->Name),\r
+      ' ',\r
+      FBlock->Size\r
+      );\r
+    fprintf (\r
+      OutFptr,\r
+      "FLASH_REGION_%s_OFFSET %*cequ 0%08Xh\n",\r
+      FBlock->Name,\r
+      COLUMN2_START - 20 - strlen (FBlock->Name),\r
+      ' ',\r
+      Offset\r
+      );\r
+    //\r
+    // Create defines for any subregions\r
+    //\r
+    SubregionOffset = 0;\r
+    for (Subregion = FBlock->Subregions; Subregion != NULL; Subregion = Subregion->Next) {\r
+      fprintf (\r
+        OutFptr,\r
+        "FLASH_REGION_%s_SUBREGION_%s_BASE     %*cequ 0%08Xh\n",\r
+        FBlock->Name,\r
+        Subregion->Name,\r
+        COLUMN3_START - 39 - strlen (FBlock->Name) - strlen (Subregion->Name),\r
+        ' ',\r
+        FDev->BaseAddress + Offset + SubregionOffset\r
+        );\r
+      fprintf (\r
+        OutFptr,\r
+        "FLASH_REGION_%s_SUBREGION_%s_SIZE     %*cequ 0%08Xh\n",\r
+        FBlock->Name,\r
+        Subregion->Name,\r
+        COLUMN3_START - 39 - strlen (FBlock->Name) - strlen (Subregion->Name),\r
+        ' ',\r
+        Subregion->Size\r
+        );\r
+      fprintf (\r
+        OutFptr,\r
+        "FLASH_REGION_%s_SUBREGION_%s_OFFSET   %*cequ 0%08Xh\n",\r
+        FBlock->Name,\r
+        Subregion->Name,\r
+        COLUMN3_START - 39 - strlen (FBlock->Name) - strlen (Subregion->Name),\r
+        ' ',\r
+        Offset + SubregionOffset\r
+        );\r
+      SubregionOffset += Subregion->Size;\r
+    }\r
+\r
+    Offset += FBlock->Size;\r
+  }\r
+\r
+  //\r
+  // Write closing \n\r
+  //\r
+  fprintf (OutFptr, "\n\n");\r
+  fclose (OutFptr);\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+STATUS\r
+FDFCreateSymbols (\r
+  char      *FlashDeviceName\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Using the given flash device name, add symbols to the global symbol table. This\r
+  allows other functions to use the symbol definitions for other purposes.\r
+\r
+Arguments:\r
+  FlashDeviceName - name of flash device (from the flash definition file)\r
+                    to use\r
+\r
+Returns:\r
+  STATUS_SUCCESS    - no errors or warnings\r
+  STATUS_WARNING    - warnings, but no errors, were encountered\r
+  STATUS_ERROR      - errors were encountered\r
+\r
+--*/\r
+{\r
+  FLASH_BLOCK_DESCRIPTION     *FBlock;\r
+  FLASH_DEVICE_DESCRIPTION    *FDev;\r
+  unsigned int                Offset;\r
+  char                        SymName[120];\r
+  char                        SymValue[120];\r
+  FLASH_SUBREGION_DESCRIPTION *Subregion;\r
+  unsigned int                SubregionOffset;\r
+  //\r
+  // Find the definition we're supposed to use\r
+  //\r
+  for (FDev = mFlashDevices; FDev != NULL; FDev = FDev->Next) {\r
+    if (strcmp (FDev->Name, FlashDeviceName) == 0) {\r
+      break;\r
+    }\r
+  }\r
+\r
+  if (FDev == NULL) {\r
+    Error (NULL, 0, 0, NULL, FlashDeviceName, "flash device not found in flash definitions");\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  sprintf (SymValue, "0x%08X", FDev->BaseAddress);\r
+  SymbolAdd ("FLASH_BASE", SymValue, 0);\r
+  sprintf (SymValue, "0x%08X", FDev->Size);\r
+  SymbolAdd ("FLASH_SIZE", SymValue, 0);\r
+  //\r
+  // Add flash block size and offset defines\r
+  //\r
+  // Offset = 0;\r
+  // for (FBlock = FDev->PBlocks; FBlock != NULL; FBlock = FBlock->Next) {\r
+  //  sprintf (SymName, "FLASH_BLOCK_%s_BASE", FBlock->Name);\r
+  //  sprintf (SymValue, "0x%08X", FDev->BaseAddress + Offset);\r
+  //  SymbolAdd (SymName, SymValue, 0);\r
+  //  sprintf (SymName, "FLASH_BLOCK_%s_SIZE", FBlock->Name);\r
+  //  sprintf (SymValue, "0x%08X", FBlock->Size);\r
+  //  SymbolAdd (SymName, SymValue, 0);\r
+  //  sprintf (SymName, "FLASH_BLOCK_%s_OFFSET", FBlock->Name);\r
+  //  sprintf (SymValue, "0x%08X", Offset);\r
+  //  SymbolAdd (SymName, SymValue, 0);\r
+  //  Offset += FBlock->Size;\r
+  // }\r
+  //\r
+  // Add flash region block base, size, and offset defines\r
+  //\r
+  Offset = 0;\r
+  for (FBlock = FDev->Regions; FBlock != NULL; FBlock = FBlock->Next) {\r
+    sprintf (SymName, "FLASH_REGION_%s_BASE", FBlock->Name);\r
+    sprintf (SymValue, "0x%08X", FDev->BaseAddress + Offset);\r
+    SymbolAdd (SymName, SymValue, 0);\r
+    sprintf (SymName, "FLASH_REGION_%s_SIZE", FBlock->Name);\r
+    sprintf (SymValue, "0x%08X", FBlock->Size);\r
+    SymbolAdd (SymName, SymValue, 0);\r
+    sprintf (SymName, "FLASH_REGION_%s_OFFSET", FBlock->Name);\r
+    sprintf (SymValue, "0x%08X", Offset);\r
+    SymbolAdd (SymName, SymValue, 0);\r
+    //\r
+    // Add subregion symbols\r
+    //\r
+    if (FBlock->Subregions != NULL) {\r
+      SubregionOffset = 0;\r
+      for (Subregion = FBlock->Subregions; Subregion != NULL; Subregion = Subregion->Next) {\r
+        sprintf (SymName, "FLASH_REGION_%s_SUBREGION_%s_BASE", FBlock->Name, Subregion->Name);\r
+        sprintf (SymValue, "0x%08X", FDev->BaseAddress + Offset + SubregionOffset);\r
+        SymbolAdd (SymName, SymValue, 0);\r
+        sprintf (SymName, "FLASH_REGION_%s_SUBREGION_%s_SIZE", FBlock->Name, Subregion->Name);\r
+        sprintf (SymValue, "0x%08X", Subregion->Size);\r
+        SymbolAdd (SymName, SymValue, 0);\r
+        sprintf (SymName, "FLASH_REGION_%s_SUBREGION_%s_OFFSET", FBlock->Name, Subregion->Name);\r
+        sprintf (SymValue, "0x%08X", Offset + SubregionOffset);\r
+        SymbolAdd (SymName, SymValue, 0);\r
+        SubregionOffset += Subregion->Size;\r
+      }\r
+    }\r
+\r
+    Offset += FBlock->Size;\r
+  }\r
+\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+STATUS\r
+FDFCreateImage (\r
+  char      *FlashDeviceName,\r
+  char      *ImageName,\r
+  char      *FileName\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Create a flash image using the given device and image names.\r
+\r
+Arguments:\r
+  FlashDeviceName - name of flash device (from the flash definition file)\r
+                    to use\r
+  ImageName       - name of image (from the flash definition file) to create\r
+  FileName        - name of output file to create\r
+\r
+Returns:\r
+  STATUS_SUCCESS    - no errors or warnings\r
+  STATUS_WARNING    - warnings, but no errors, were encountered\r
+  STATUS_ERROR      - errors were encountered\r
+\r
+--*/\r
+{\r
+  STATUS                      Status;\r
+  FILE                        *OutFptr;\r
+  FLASH_BLOCK_DESCRIPTION     *RegionDef;\r
+  FLASH_DEVICE_DESCRIPTION    *FDev;\r
+  IMAGE_DEFINITION            *ImageDef;\r
+  unsigned int                Offset;\r
+  char                        *Buffer;\r
+  FILE                        *InFptr;\r
+  long                        FileSize;\r
+  IMAGE_DEFINITION_ENTRY      *IDefEntry;\r
+  FLASH_SUBREGION_DESCRIPTION *SubregionDef;\r
+  //\r
+  // Find the flash definition we're supposed to use\r
+  //\r
+  InFptr  = NULL;\r
+  Status  = STATUS_ERROR;\r
+  for (FDev = mFlashDevices; FDev != NULL; FDev = FDev->Next) {\r
+    if (strcmp (FDev->Name, FlashDeviceName) == 0) {\r
+      break;\r
+    }\r
+  }\r
+\r
+  if (FDev == NULL) {\r
+    Error (NULL, 0, 0, FlashDeviceName, "flash device not found in flash definitions");\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Find the image name we're supposed to create\r
+  //\r
+  for (ImageDef = mImageDefinitions; ImageDef != NULL; ImageDef = ImageDef->Next) {\r
+    if (strcmp (ImageDef->Name, ImageName) == 0) {\r
+      break;\r
+    }\r
+  }\r
+\r
+  if (ImageDef == NULL) {\r
+    Error (NULL, 0, 0, ImageName, "image definition not found in image definitions");\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Open the output file\r
+  //\r
+  if ((OutFptr = fopen (FileName, "wb")) == NULL) {\r
+    Error (NULL, 0, 0, FileName, "failed to open output file for writing");\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Allocate a buffer to copy the input data to\r
+  //\r
+  Buffer = (char *) _malloc (FDev->Size);\r
+  if (Buffer == NULL) {\r
+    Error (NULL, 0, 0, (INT8 *) "failed to allocate memory", NULL);\r
+    goto Done;\r
+  }\r
+  //\r
+  // Set contents of buffer to the erased value\r
+  //\r
+  if (FDev->ErasePolarity) {\r
+    memset (Buffer, 0xFF, FDev->Size);\r
+  } else {\r
+    memset (Buffer, 0, FDev->Size);\r
+  }\r
+  //\r
+  // Set all region and subregion size-left fields to the size of the region/subregion\r
+  //\r
+  for (RegionDef = FDev->Regions; RegionDef != NULL; RegionDef = RegionDef->Next) {\r
+    RegionDef->SizeLeft = RegionDef->Size;\r
+    for (SubregionDef = RegionDef->Subregions; SubregionDef != NULL; SubregionDef = SubregionDef->Next) {\r
+      SubregionDef->SizeLeft = SubregionDef->Size;\r
+    }\r
+  }\r
+  //\r
+  // Now go through the image list, read files into the buffer.\r
+  //\r
+  for (IDefEntry = ImageDef->Entries; IDefEntry != NULL; IDefEntry = IDefEntry->Next) {\r
+    //\r
+    // If it's a file name, open the file, get the size, find the corresponding\r
+    // flash region it's in, and copy the data.\r
+    //\r
+    if (IDefEntry->IsRawData == 0) {\r
+      if ((InFptr = fopen (IDefEntry->Name, "rb")) == NULL) {\r
+        Error (NULL, 0, 0, IDefEntry->Name, "failed to open input file for reading");\r
+        goto Done;\r
+      }\r
+\r
+      fseek (InFptr, 0, SEEK_END);\r
+      FileSize = ftell (InFptr);\r
+      fseek (InFptr, 0, SEEK_SET);\r
+    } else {\r
+      FileSize = IDefEntry->RawDataSize;\r
+    }\r
+    //\r
+    // Find the region/subregion it's in, see if we have space left\r
+    //\r
+    Offset = 0;\r
+    for (RegionDef = FDev->Regions; RegionDef != NULL; RegionDef = RegionDef->Next) {\r
+      if (strcmp (RegionDef->Name, IDefEntry->RegionName) == 0) {\r
+        break;\r
+      }\r
+\r
+      Offset += RegionDef->Size;\r
+    }\r
+\r
+    if (RegionDef == NULL) {\r
+      Error (NULL, 0, 0, IDefEntry->RegionName, "Region name not found in FlashDevice %s definition", FDev->Name);\r
+      goto Done;\r
+    }\r
+\r
+    //\r
+    // Check for subregion\r
+    //\r
+    if (IDefEntry->SubregionName[0] != 0) {\r
+      for (SubregionDef = RegionDef->Subregions; SubregionDef != NULL; SubregionDef = SubregionDef->Next) {\r
+        if (strcmp (SubregionDef->Name, IDefEntry->SubregionName) == 0) {\r
+          break;\r
+        }\r
+\r
+        Offset += SubregionDef->Size;\r
+      }\r
+\r
+      if (SubregionDef == NULL) {\r
+        Error (\r
+          NULL,\r
+          0,\r
+          0,\r
+          IDefEntry->SubregionName,\r
+          "Subregion name not found in FlashDevice %s.%s Region definition",\r
+          FDev->Name,\r
+          RegionDef->Name\r
+          );\r
+        goto Done;\r
+      }\r
+      //\r
+      // Enough space in the subregion?\r
+      //\r
+      if (SubregionDef->SizeLeft < (unsigned int) FileSize) {\r
+        Error (\r
+          NULL,\r
+          0,\r
+          0,\r
+          IDefEntry->Name,\r
+          "insufficient space in Subregion (at least 0x%X additional bytes required)",\r
+          FileSize - SubregionDef->SizeLeft\r
+          );\r
+        goto Done;\r
+      }\r
+\r
+      //\r
+      // Read the file into the buffer if it's a file. Otherwise copy the raw data\r
+      //\r
+      if (IDefEntry->IsRawData == 0) {\r
+        if (fread (Buffer + Offset + (SubregionDef->Size - SubregionDef->SizeLeft), FileSize, 1, InFptr) != 1) {\r
+          Error (NULL, 0, 0, IDefEntry->Name, "failed to read file contents");\r
+          goto Done;\r
+        }\r
+\r
+        fclose (InFptr);\r
+        InFptr = NULL;\r
+      } else {\r
+        memcpy (\r
+          Buffer + Offset + (SubregionDef->Size - SubregionDef->SizeLeft),\r
+          IDefEntry->RawData,\r
+          IDefEntry->RawDataSize\r
+          );\r
+      }\r
+\r
+      SubregionDef->SizeLeft -= FileSize;\r
+      //\r
+      // Align based on the Region alignment requirements.\r
+      //\r
+      if (RegionDef->Alignment != 0) {\r
+        while (((unsigned int) (SubregionDef->Size - SubregionDef->SizeLeft) &~RegionDef->Alignment) != 0) {\r
+          if (SubregionDef->SizeLeft == 0) {\r
+            break;\r
+          }\r
+\r
+          SubregionDef->SizeLeft--;\r
+        }\r
+      }\r
+    } else {\r
+      //\r
+      // Placing data in a region. Check for enough space in the region left.\r
+      //\r
+      if (RegionDef->SizeLeft < (unsigned int) FileSize) {\r
+        Error (\r
+          NULL,\r
+          0,\r
+          0,\r
+          IDefEntry->Name,\r
+          "insufficient space in Region (at least 0x%X additional bytes required)",\r
+          FileSize - RegionDef->SizeLeft\r
+          );\r
+        goto Done;\r
+      }\r
+\r
+      //\r
+      // Read the file into the buffer if it's a file. Otherwise copy the raw data\r
+      //\r
+      if (IDefEntry->IsRawData == 0) {\r
+        if (fread (Buffer + Offset + (RegionDef->Size - RegionDef->SizeLeft), FileSize, 1, InFptr) != 1) {\r
+          Error (NULL, 0, 0, IDefEntry->Name, "failed to read file contents");\r
+          goto Done;\r
+        }\r
+\r
+        fclose (InFptr);\r
+        InFptr = NULL;\r
+      } else {\r
+        memcpy (Buffer + Offset + (RegionDef->Size - RegionDef->SizeLeft), IDefEntry->RawData, IDefEntry->RawDataSize);\r
+      }\r
+\r
+      RegionDef->SizeLeft -= FileSize;\r
+      //\r
+      // Align\r
+      //\r
+      if (RegionDef->Alignment != 0) {\r
+        while (((unsigned int) (RegionDef->Size - RegionDef->SizeLeft) &~RegionDef->Alignment) != 0) {\r
+          if (RegionDef->SizeLeft == 0) {\r
+            break;\r
+          }\r
+\r
+          RegionDef->SizeLeft--;\r
+        }\r
+      }\r
+    }\r
+  }\r
+\r
+  if (fwrite (Buffer, FDev->Size, 1, OutFptr) != 1) {\r
+    Error (NULL, 0, 0, "failed to write buffer contents to output file", NULL);\r
+    goto Done;\r
+  }\r
+\r
+  Status = STATUS_SUCCESS;\r
+Done:\r
+  if (InFptr != NULL) {\r
+    fclose (InFptr);\r
+  }\r
+\r
+  if (Buffer != NULL) {\r
+    _free (Buffer);\r
+  }\r
+\r
+  if (OutFptr != NULL) {\r
+    fclose (OutFptr);\r
+    if (Status == STATUS_ERROR) {\r
+      remove (FileName);\r
+    }\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
+STATUS\r
+FDFCreateDscFile (\r
+  char      *FlashDeviceName,\r
+  char      *FileName\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Create a DSC-style output file with equates for flash management.\r
+\r
+Arguments:\r
+  FlashDeviceName - name of flash device (from the flash definition file)\r
+                    to use\r
+  FileName        - name of output file to create\r
+\r
+Returns:\r
+  STATUS_SUCCESS    - no errors or warnings\r
+  STATUS_WARNING    - warnings, but no errors, were encountered\r
+  STATUS_ERROR      - errors were encountered\r
+\r
+--*/\r
+{\r
+  FILE                        *OutFptr;\r
+  FLASH_BLOCK_DESCRIPTION     *FBlock;\r
+  FLASH_DEVICE_DESCRIPTION    *FDev;\r
+  unsigned int                Offset;\r
+  FLASH_SUBREGION_DESCRIPTION *Subregion;\r
+  unsigned int                SubregionOffset;\r
+  //\r
+  // Find the definition we're supposed to use\r
+  //\r
+  for (FDev = mFlashDevices; FDev != NULL; FDev = FDev->Next) {\r
+    if (strcmp (FDev->Name, FlashDeviceName) == 0) {\r
+      break;\r
+    }\r
+  }\r
+\r
+  if (FDev == NULL) {\r
+    Error (NULL, 0, 0, FlashDeviceName, "flash device not found in flash definitions");\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  if ((OutFptr = fopen (FileName, "w")) == NULL) {\r
+    Error (NULL, 0, 0, FileName, "failed to open output file for writing");\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Write the flash base address and size\r
+  //\r
+  fprintf (OutFptr, "\n");\r
+  fprintf (OutFptr, "FLASH_BASE                                      = 0x%08X\n", FDev->BaseAddress);\r
+  fprintf (OutFptr, "FLASH_SIZE                                      = 0x%08X\n\n", FDev->Size);\r
+  //\r
+  // Write flash block size and offset defines\r
+  //\r
+  Offset = 0;\r
+  for (FBlock = FDev->Regions; FBlock != NULL; FBlock = FBlock->Next) {\r
+    fprintf (\r
+      OutFptr,\r
+      "FLASH_REGION_%s_BASE          %*c= 0x%08X\n",\r
+      FBlock->Name,\r
+      COLUMN2_START - 40 - strlen (FBlock->Name),\r
+      ' ',\r
+      Offset + FDev->BaseAddress\r
+      );\r
+    fprintf (\r
+      OutFptr,\r
+      "FLASH_REGION_%s_SIZE          %*c= 0x%08X\n",\r
+      FBlock->Name,\r
+      COLUMN2_START - 40 - strlen (FBlock->Name),\r
+      ' ',\r
+      FBlock->Size\r
+      );\r
+    fprintf (\r
+      OutFptr,\r
+      "FLASH_REGION_%s_SIZE_BLOCKS   %*c= 0x%x\n",\r
+      FBlock->Name,\r
+      COLUMN2_START - 40 - strlen (FBlock->Name),\r
+      ' ',\r
+      (FBlock->Size)/(FDev->PBlocks->Size)\r
+      );      \r
+    //\r
+    // Create defines for any subregions\r
+    //\r
+    SubregionOffset = 0;\r
+    for (Subregion = FBlock->Subregions; Subregion != NULL; Subregion = Subregion->Next) {\r
+      fprintf (\r
+        OutFptr,\r
+        "FLASH_REGION_%s_SUBREGION_%s_BASE     %*c= 0x%08X\n",\r
+        FBlock->Name,\r
+        Subregion->Name,\r
+        COLUMN3_START - 48 - strlen (FBlock->Name) - strlen (Subregion->Name),\r
+        ' ',\r
+        FDev->BaseAddress + Offset + SubregionOffset\r
+        );\r
+      fprintf (\r
+        OutFptr,\r
+        "FLASH_REGION_%s_SUBREGION_%s_SIZE     %*c= 0x%08X\n",\r
+        FBlock->Name,\r
+        Subregion->Name,\r
+        COLUMN3_START - 48 - strlen (FBlock->Name) - strlen (Subregion->Name),\r
+        ' ',\r
+        Subregion->Size\r
+        );\r
+      fprintf (\r
+        OutFptr,\r
+        "FLASH_REGION_%s_SUBREGION_%s_OFFSET   %*c= 0x%08X\n",\r
+        FBlock->Name,\r
+        Subregion->Name,\r
+        COLUMN3_START - 48 - strlen (FBlock->Name) - strlen (Subregion->Name),\r
+        ' ',\r
+        Offset + SubregionOffset\r
+        );\r
+\r
+      SubregionOffset += Subregion->Size;\r
+    }\r
+\r
+    Offset += FBlock->Size;\r
+  }\r
+  //\r
+  // Close file\r
+  //\r
+  fprintf (OutFptr, "\n");\r
+  fclose (OutFptr);\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+\r
+/*++\r
+\r
+Routine Description:\r
+  The following buffer management routines are used to encapsulate functionality\r
+  for managing a growable data buffer.\r
+\r
+Arguments:\r
+  BUFFER_DATA     - structure that is used to maintain a data buffer\r
+\r
+Returns:\r
+  NA\r
+\r
+--*/\r
+static\r
+BUFFER_DATA *\r
+CreateBufferData (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Create a growable data buffer with default buffer length.\r
+\r
+Arguments:\r
+\r
+  None\r
+\r
+Returns:\r
+\r
+  NULL          - error occured during data buffer creation\r
+  Not NULL      - the pointer to the newly created data buffer\r
+\r
+--*/\r
+{\r
+  BUFFER_DATA *BD;\r
+  BD = (BUFFER_DATA *) _malloc (sizeof (BUFFER_DATA));\r
+  if (BD == NULL) {\r
+    Error (__FILE__, __LINE__, 0, "memory allocation failure", NULL);\r
+    return NULL;\r
+  }\r
+\r
+  memset (BD, 0, sizeof (BUFFER_DATA));\r
+  BD->BufferStart = (char *) _malloc (BUFFER_SIZE);\r
+  if (BD->BufferStart == NULL) {\r
+    _free (BD);\r
+    Error (__FILE__, __LINE__, 0, "memory allocation failure", NULL);\r
+    return NULL;\r
+  }\r
+\r
+  BD->BufferEnd = BD->BufferStart + BUFFER_SIZE;\r
+  BD->BufferPos = BD->BufferStart;\r
+  return BD;\r
+}\r
+\r
+static\r
+BOOLEAN\r
+AddBufferDataByte (\r
+  BUFFER_DATA *Buffer,\r
+  char        Data\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Add a single byte to a growable data buffer, growing the buffer if required.\r
+\r
+Arguments:\r
+\r
+  Buffer  - pointer to the growable data buffer to add a single byte to\r
+  Data    - value of the single byte data to be added\r
+\r
+Returns:\r
+\r
+  TRUE    - the single byte data was successfully added\r
+  FALSE   - error occurred, the single byte data was not added\r
+\r
+--*/\r
+{\r
+  int   Size;\r
+  char  *NewBuffer;\r
+  //\r
+  // See if we have to grow the buffer\r
+  //\r
+  if (Buffer->BufferPos >= Buffer->BufferEnd) {\r
+    Size      = (int) Buffer->BufferEnd - (int) Buffer->BufferStart;\r
+    NewBuffer = (char *) _malloc (Size + BUFFER_SIZE);\r
+    if (NewBuffer == NULL) {\r
+      Error (__FILE__, __LINE__, 0, "memory allocation failure", NULL);\r
+      return FALSE;\r
+    }\r
+\r
+    memcpy (NewBuffer, Buffer->BufferStart, Size);\r
+    _free (Buffer->BufferStart);\r
+    Buffer->BufferStart = NewBuffer;\r
+    Buffer->BufferPos   = Buffer->BufferStart + Size;\r
+    Buffer->BufferEnd   = Buffer->BufferStart + Size + BUFFER_SIZE;\r
+  }\r
+\r
+  *Buffer->BufferPos = Data;\r
+  Buffer->BufferPos++;\r
+  return TRUE;\r
+}\r
+\r
+static\r
+void\r
+FreeBufferData (\r
+  BUFFER_DATA *Buffer,\r
+  BOOLEAN     FreeData\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Free memory used to manage a growable data buffer.\r
+\r
+Arguments:\r
+\r
+  Buffer    - pointer to the growable data buffer to be destructed\r
+  FreeData  - TRUE, free memory containing the buffered data\r
+              FALSE, do not free the buffered data memory\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+{\r
+  if (Buffer != NULL) {\r
+    if (FreeData && (Buffer->BufferStart != NULL)) {\r
+      _free (Buffer->BufferStart);\r
+    }\r
+\r
+    _free (Buffer);\r
+  }\r
+}\r
+\r
+static\r
+char *\r
+GetBufferData (\r
+  BUFFER_DATA *Buffer,\r
+  int         *BufferSize\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Return a pointer and size of the data in a growable data buffer.\r
+\r
+Arguments:\r
+\r
+  Buffer      - pointer to the growable data buffer\r
+  BufferSize  - size of the data in the growable data buffer\r
+\r
+Returns:\r
+\r
+  pointer of the data in the growable data buffer\r
+\r
+--*/\r
+{\r
+  *BufferSize = (int) Buffer->BufferPos - (int) Buffer->BufferStart;\r
+  return Buffer->BufferStart;\r
+}\r
+\r
+STATUS\r
+FDDiscover (\r
+  char          *FDFileName,\r
+  unsigned int  BaseAddr\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Walk a binary image and see if you find anything that looks like a\r
+  firmware volume.\r
+\r
+Arguments:\r
+  FDFileName        - name of input FD image to parse\r
+  BaseAddr          - base address of input FD image\r
+\r
+Returns:\r
+  STATUS_SUCCESS    - no errors or warnings\r
+  STATUS_WARNING    - warnings, but no errors, were encountered\r
+  STATUS_ERROR      - errors were encountered\r
+\r
+NOTE:\r
+  This routine is used for debug purposes only.\r
+\r
+--*/\r
+{\r
+  FILE                        *InFptr;\r
+  long                        FileSize;\r
+  long                        Offset;\r
+  EFI_FIRMWARE_VOLUME_HEADER  FVHeader;\r
+  EFI_GUID\r
+    FileSystemGuid = { 0x7A9354D9, 0x0468, 0x444a, 0x81, 0xCE, 0x0B, 0xF6, 0x17, 0xD8, 0x90, 0xDF };\r
+\r
+  if ((InFptr = fopen (FDFileName, "rb")) == NULL) {\r
+    Error (NULL, 0, 0, FDFileName, "failed to open file for reading");\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  fseek (InFptr, 0, SEEK_END);\r
+  FileSize = ftell (InFptr);\r
+  fseek (InFptr, 0, SEEK_SET);\r
+  Offset = 0;\r
+  while (Offset < FileSize) {\r
+    fseek (InFptr, Offset, SEEK_SET);\r
+    //\r
+    // Read the contents of the file, see if it's an FV header\r
+    //\r
+    if (fread (&FVHeader, sizeof (EFI_FIRMWARE_VOLUME_HEADER), 1, InFptr) == 1) {\r
+      //\r
+      // Check version and GUID\r
+      //\r
+      if ((FVHeader.Revision == EFI_FVH_REVISION) && (FVHeader.Signature == EFI_FVH_SIGNATURE)) {\r
+        fprintf (stdout, "FV header at 0x%08X FVSize=0x%08X ", Offset + BaseAddr, (UINT32) FVHeader.FvLength);\r
+        if (memcmp (&FVHeader.FileSystemGuid, &FileSystemGuid, sizeof (EFI_GUID)) == 0) {\r
+          fprintf (stdout, "standard FFS file system\n");\r
+        } else {\r
+          fprintf (stdout, "non-standard FFS file system\n");\r
+        }\r
+      }\r
+    }\r
+\r
+    Offset += 16 * 1024;\r
+  }\r
+\r
+  fclose (InFptr);\r
+  return STATUS_SUCCESS;\r
+}\r
diff --git a/Tools/CodeTools/Source/FlashMap/FlashDefFile.h b/Tools/CodeTools/Source/FlashMap/FlashDefFile.h
new file mode 100644 (file)
index 0000000..0e2ea2c
--- /dev/null
@@ -0,0 +1,281 @@
+/*++\r
+\r
+Copyright (c)  2004-2006 Intel Corporation. All rights reserved\r
+This program and the accompanying materials are licensed and made available \r
+under the terms and conditions of the BSD License which accompanies this \r
+distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+\r
+Module Name:\r
+\r
+  FlashDefFile.h\r
+\r
+Abstract:\r
+\r
+  Header file for flash management utility in the Intel Platform \r
+  Innovation Framework for EFI build environment.\r
+\r
+--*/\r
+\r
+#ifndef _FLASH_DEF_FILE_H_\r
+#define _FLASH_DEF_FILE_H_\r
+\r
+#ifdef __cplusplus\r
+extern "C"\r
+{\r
+#endif\r
+\r
+void\r
+FDFConstructor (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  None\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+void\r
+FDFDestructor (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  None\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+STATUS\r
+FDFParseFile (\r
+  char    *FileName\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  FileName  - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+STATUS\r
+FDFCreateCIncludeFile (\r
+  char      *FlashDeviceName,\r
+  char      *FileName\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  FlashDeviceName - GC_TODO: add argument description\r
+  FileName        - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+STATUS\r
+FDFCreateCFlashMapDataFile (\r
+  char      *FlashDeviceName,\r
+  char      *FileName\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  FlashDeviceName - GC_TODO: add argument description\r
+  FileName        - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+STATUS\r
+FDFCreateAsmIncludeFile (\r
+  char      *FlashDeviceName,\r
+  char      *FileName\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  FlashDeviceName - GC_TODO: add argument description\r
+  FileName        - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+STATUS\r
+FDFParseFile (\r
+  char      *FileName\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  FileName  - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+STATUS\r
+FDFCreateImage (\r
+  char      *FlashDeviceName,\r
+  char      *ImageName,\r
+  char      *FileName\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  FlashDeviceName - GC_TODO: add argument description\r
+  ImageName       - GC_TODO: add argument description\r
+  FileName        - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+STATUS\r
+FDFCreateDscFile (\r
+  char      *FlashDeviceName,\r
+  char      *FileName\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  FlashDeviceName - GC_TODO: add argument description\r
+  FileName        - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+STATUS\r
+FDFCreateSymbols (\r
+  char      *FlashDeviceName\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  FlashDeviceName - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+STATUS\r
+FDDiscover (\r
+  char          *FDFileName,\r
+  unsigned int  BaseAddr\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  FDFileName  - GC_TODO: add argument description\r
+  BaseAddr    - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+#ifdef __cplusplus\r
+}\r
+#endif\r
+\r
+#endif // #ifndef _FLASH_DEF_FILE_H_\r
diff --git a/Tools/CodeTools/Source/FlashMap/FlashMap.c b/Tools/CodeTools/Source/FlashMap/FlashMap.c
new file mode 100644 (file)
index 0000000..88f5003
--- /dev/null
@@ -0,0 +1,769 @@
+/*++\r
+\r
+Copyright (c)  2004-2006 Intel Corporation. All rights reserved\r
+This program and the accompanying materials are licensed and made available \r
+under the terms and conditions of the BSD License which accompanies this \r
+distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+Module Name:\r
+\r
+  FlashMap.c\r
+\r
+Abstract:\r
+\r
+  Utility for flash management in the Intel Platform Innovation Framework\r
+  for EFI build environment.\r
+\r
+--*/\r
+\r
+#include <stdio.h>\r
+#include <string.h>\r
+#include <stdlib.h>\r
+#include <ctype.h>\r
+\r
+#include <Common/UefiBaseTypes.h>\r
+\r
+#include "EfiUtilityMsgs.h"\r
+#include "Microcode.h"\r
+#include "FlashDefFile.h"\r
+#include "Symbols.h"\r
+\r
+#define UTILITY_NAME  "FlashMap"\r
+\r
+typedef struct _STRING_LIST {\r
+  struct _STRING_LIST *Next;\r
+  char                *Str;\r
+} STRING_LIST;\r
+\r
+//\r
+// Keep our globals in one of these structures\r
+//\r
+static struct {\r
+  char          *CIncludeFileName;\r
+  char          *FlashDevice;\r
+  char          *FlashDeviceImage;\r
+  char          *MCIFileName;\r
+  char          *MCOFileName;\r
+  char          *ImageOutFileName;\r
+  char          *DscFileName;\r
+  char          *AsmIncludeFileName;\r
+  char          *FlashDefinitionFileName;\r
+  char          *StringReplaceInFileName;\r
+  char          *StringReplaceOutFileName;\r
+  char          *DiscoverFDImageName;\r
+  char          MicrocodePadByteValue;\r
+  unsigned int  MicrocodeAlignment;\r
+  STRING_LIST   *MCIFileNames;\r
+  STRING_LIST   *LastMCIFileNames;\r
+  unsigned int  BaseAddress;\r
+} mGlobals;\r
+\r
+#define DEFAULT_MC_PAD_BYTE_VALUE 0xFF\r
+#define DEFAULT_MC_ALIGNMENT      16\r
+\r
+static\r
+STATUS\r
+ProcessCommandLine (\r
+  int     argc,\r
+  char    *argv[]\r
+  );\r
+\r
+static\r
+STATUS\r
+MergeMicrocodeFiles (\r
+  char            *OutFileName,\r
+  STRING_LIST     *FileNames,\r
+  unsigned int    Alignment,\r
+  char            PadByteValue\r
+  );\r
+\r
+static\r
+void\r
+Usage (\r
+  VOID\r
+  );\r
+\r
+char* \r
+NormalizePath (\r
+  char* OldPathName\r
+  );\r
+\r
+int\r
+main (\r
+  int   argc,\r
+  char  *argv[]\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Parse the command line arguments and then call worker functions to do the work\r
+  \r
+Arguments:\r
+  argc      - number of elements in argv\r
+  argv      - array of command-line arguments\r
+\r
+Returns:\r
+  STATUS_SUCCESS    - no problems encountered while processing\r
+  STATUS_WARNING    - warnings, but no errors, were encountered while processing\r
+  STATUS_ERROR      - errors were encountered while processing\r
+  \r
+--*/\r
+{\r
+  STATUS  Status;\r
+\r
+  SetUtilityName (UTILITY_NAME);\r
+  Status = ProcessCommandLine (argc, argv);\r
+  if (Status != STATUS_SUCCESS) {\r
+    return Status;\r
+  }\r
+  //\r
+  // Check for discovery of an FD (command line option)\r
+  //\r
+  if (mGlobals.DiscoverFDImageName != NULL) {\r
+    Status = FDDiscover (mGlobals.DiscoverFDImageName, mGlobals.BaseAddress);\r
+    goto Done;\r
+  }\r
+  //\r
+  // If they're doing microcode file parsing, then do that\r
+  //\r
+  if (mGlobals.MCIFileName != NULL) {\r
+    MicrocodeConstructor ();\r
+    MicrocodeParseFile (mGlobals.MCIFileName, mGlobals.MCOFileName);\r
+    MicrocodeDestructor ();\r
+  }\r
+  //\r
+  // If they're doing microcode file merging, then do that now\r
+  //\r
+  if (mGlobals.MCIFileNames != NULL) {\r
+    MergeMicrocodeFiles (\r
+      mGlobals.MCOFileName,\r
+      mGlobals.MCIFileNames,\r
+      mGlobals.MicrocodeAlignment,\r
+      mGlobals.MicrocodePadByteValue\r
+      );\r
+  }\r
+  //\r
+  // If using a flash definition file, then process that and return\r
+  //\r
+  if (mGlobals.FlashDefinitionFileName != NULL) {\r
+    FDFConstructor ();\r
+    SymbolsConstructor ();\r
+    Status = FDFParseFile (mGlobals.FlashDefinitionFileName);\r
+    if (GetUtilityStatus () != STATUS_ERROR) {\r
+      //\r
+      // If they want us to do a string-replace on a file, then add the symbol definitions to\r
+      // the symbol table, and then do the string replace.\r
+      //\r
+      if (mGlobals.StringReplaceInFileName != NULL) {\r
+        Status  = FDFCreateSymbols (mGlobals.FlashDevice);\r
+        Status  = SymbolsFileStringsReplace (mGlobals.StringReplaceInFileName, mGlobals.StringReplaceOutFileName);\r
+      }\r
+      //\r
+      // If they want us to create a .h defines file or .c flashmap data file, then do so now\r
+      //\r
+      if (mGlobals.CIncludeFileName != NULL) {\r
+        Status = FDFCreateCIncludeFile (mGlobals.FlashDevice, mGlobals.CIncludeFileName);\r
+      }\r
+      if (mGlobals.AsmIncludeFileName != NULL) {\r
+        Status = FDFCreateAsmIncludeFile (mGlobals.FlashDevice, mGlobals.AsmIncludeFileName);\r
+      }\r
+      //\r
+      // If they want us to create an image, do that now\r
+      //\r
+      if (mGlobals.ImageOutFileName != NULL) {\r
+        Status = FDFCreateImage (mGlobals.FlashDevice, mGlobals.FlashDeviceImage, mGlobals.ImageOutFileName);\r
+      }\r
+      //\r
+      // If they want to create an output DSC file, do that now\r
+      //\r
+      if (mGlobals.DscFileName != NULL) {\r
+        Status = FDFCreateDscFile (mGlobals.FlashDevice, mGlobals.DscFileName);\r
+      }\r
+    }\r
+    SymbolsDestructor ();\r
+    FDFDestructor ();\r
+  }\r
+Done:\r
+  //\r
+  // Free up memory\r
+  //\r
+  while (mGlobals.MCIFileNames != NULL) {\r
+    mGlobals.LastMCIFileNames = mGlobals.MCIFileNames->Next;\r
+    _free (mGlobals.MCIFileNames);\r
+    mGlobals.MCIFileNames = mGlobals.LastMCIFileNames;\r
+  }\r
+  return GetUtilityStatus ();\r
+}\r
+\r
+static\r
+STATUS\r
+MergeMicrocodeFiles (\r
+  char            *OutFileName,\r
+  STRING_LIST     *FileNames,\r
+  unsigned int    Alignment,\r
+  char            PadByteValue\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Merge binary microcode files into a single file, taking into consideration\r
+  the alignment and pad value.\r
+\r
+Arguments:\r
+\r
+  OutFileName     - name of the output file to create\r
+  FileNames       - linked list of input microcode files to merge\r
+  Alignment       - alignment for each microcode file in the output image\r
+  PadByteValue    - value to use when padding to meet alignment requirements\r
+\r
+Returns:\r
+\r
+  STATUS_SUCCESS  - merge completed successfully or with acceptable warnings\r
+  STATUS_ERROR    - merge failed, output file not created\r
+\r
+--*/\r
+{\r
+  long    FileSize;\r
+  long    TotalFileSize;\r
+  FILE    *InFptr;\r
+  FILE    *OutFptr;\r
+  char    *Buffer;\r
+  STATUS  Status;\r
+\r
+  //\r
+  // Open the output file\r
+  //\r
+  if ((OutFptr = fopen (OutFileName, "wb")) == NULL) {\r
+    Error (NULL, 0, 0, OutFileName, "failed to open output file for writing");\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Walk the list of files\r
+  //\r
+  Status        = STATUS_ERROR;\r
+  Buffer        = NULL;\r
+  InFptr        = NULL;\r
+  TotalFileSize = 0;\r
+  while (FileNames != NULL) {\r
+    //\r
+    // Open the file, determine the size, then read it in and write\r
+    // it back out.\r
+    //\r
+    if ((InFptr = fopen (NormalizePath(FileNames->Str), "rb")) == NULL) {\r
+      Error (NULL, 0, 0, NormalizePath(FileNames->Str), "failed to open input file for reading");\r
+      goto Done;\r
+    }\r
+    fseek (InFptr, 0, SEEK_END);\r
+    FileSize = ftell (InFptr);\r
+    fseek (InFptr, 0, SEEK_SET);\r
+    if (FileSize != 0) {\r
+      Buffer = (char *) _malloc (FileSize);\r
+      if (Buffer == NULL) {\r
+        Error (NULL, 0, 0, "memory allocation failure", NULL);\r
+        goto Done;\r
+      }\r
+      if (fread (Buffer, FileSize, 1, InFptr) != 1) {\r
+        Error (NULL, 0, 0, FileNames->Str, "failed to read file contents");\r
+        goto Done;\r
+      }\r
+      //\r
+      // Align\r
+      //\r
+      if (Alignment != 0) {\r
+        while ((TotalFileSize % Alignment) != 0) {\r
+          if (fwrite (&PadByteValue, 1, 1, OutFptr) != 1) {\r
+            Error (NULL, 0, 0, OutFileName, "failed to write pad bytes to output file");\r
+            goto Done;\r
+          }\r
+          TotalFileSize++;\r
+        }\r
+      }\r
+      TotalFileSize += FileSize;\r
+      if (fwrite (Buffer, FileSize, 1, OutFptr) != 1) {\r
+        Error (NULL, 0, 0, OutFileName, "failed to write to output file");\r
+        goto Done;\r
+      }\r
+      _free (Buffer);\r
+      Buffer = NULL;\r
+    } else {\r
+      Warning (NULL, 0, 0, FileNames->Str, "0-size file encountered");\r
+    }\r
+    fclose (InFptr);\r
+    InFptr    = NULL;\r
+    FileNames = FileNames->Next;\r
+  }\r
+  Status = STATUS_SUCCESS;\r
+Done:\r
+  fclose (OutFptr);\r
+  if (InFptr != NULL) {\r
+    fclose (InFptr);\r
+  }\r
+  if (Buffer != NULL) {\r
+    _free (Buffer);\r
+  }\r
+  if (Status == STATUS_ERROR) {\r
+    remove (OutFileName);\r
+  }\r
+  return Status;\r
+}\r
+\r
+static\r
+STATUS\r
+ProcessCommandLine (\r
+  int   argc,\r
+  char  *argv[]\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Process the command line arguments\r
+  \r
+Arguments:\r
+  argc   - Standard C entry point arguments\r
+  argv[] - Standard C entry point arguments\r
+\r
+Returns:\r
+  STATUS_SUCCESS    - no problems encountered while processing\r
+  STATUS_WARNING    - warnings, but no errors, were encountered while processing\r
+  STATUS_ERROR      - errors were encountered while processing\r
+  \r
+--*/\r
+{\r
+  int           ThingsToDo;\r
+  unsigned int  Temp;\r
+  STRING_LIST   *Str;\r
+  //\r
+  // Skip program name arg, process others\r
+  //\r
+  argc--;\r
+  argv++;\r
+  if (argc == 0) {\r
+    Usage ();\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Clear out our globals, then start walking the arguments\r
+  //\r
+  memset ((void *) &mGlobals, 0, sizeof (mGlobals));\r
+  mGlobals.MicrocodePadByteValue  = DEFAULT_MC_PAD_BYTE_VALUE;\r
+  mGlobals.MicrocodeAlignment     = DEFAULT_MC_ALIGNMENT;\r
+  ThingsToDo                      = 0;\r
+  while (argc > 0) {\r
+    if (strcmp (argv[0], "-?") == 0) {\r
+      Usage ();\r
+      return STATUS_ERROR;\r
+    } else if (strcmp (argv[0], "-hfile") == 0) {\r
+      //\r
+      // -hfile FileName\r
+      //\r
+      // Used to specify an output C #include file to create that contains\r
+      // #define statements for all the flashmap region offsets and sizes.\r
+      // Check for additional argument.\r
+      //\r
+      if (argc < 2) {\r
+        Error (NULL, 0, 0, argv[0], "option requires an output file name");\r
+        return STATUS_ERROR;\r
+      }\r
+      argc--;\r
+      argv++;\r
+      mGlobals.CIncludeFileName = argv[0];\r
+      ThingsToDo++;\r
+    } else if (strcmp (argv[0], "-flashdevice") == 0) {\r
+      //\r
+      // -flashdevice FLASH_DEVICE_NAME\r
+      //\r
+      // Used to select which flash device definition to operate on.\r
+      // Check for additional argument\r
+      //\r
+      if (argc < 2) {\r
+        Error (NULL, 0, 0, argv[0], "option requires a flash device name to use");\r
+        return STATUS_ERROR;\r
+      }\r
+      argc--;\r
+      argv++;\r
+      mGlobals.FlashDevice = argv[0];\r
+    } else if (strcmp (argv[0], "-mco") == 0) {\r
+      //\r
+      // -mco OutFileName\r
+      //\r
+      // Used to specify a microcode output binary file to create.\r
+      // Check for additional argument.\r
+      //\r
+      if (argc < 2) {\r
+        Error (NULL, 0, 0, (INT8 *) argv[0], (INT8 *) "option requires an output microcode file name to create");\r
+        return STATUS_ERROR;\r
+      }\r
+      argc--;\r
+      argv++;\r
+      mGlobals.MCOFileName = argv[0];\r
+      ThingsToDo++;\r
+    } else if (strcmp (argv[0], "-asmincfile") == 0) {\r
+      //\r
+      // -asmincfile FileName\r
+      //\r
+      // Used to specify the name of the output assembly include file that contains\r
+      // equates for the flash region addresses and sizes.\r
+      // Check for additional argument.\r
+      //\r
+      if (argc < 2) {\r
+        Error (NULL, 0, 0, argv[0], "option requires an output ASM include file name to create");\r
+        return STATUS_ERROR;\r
+      }\r
+      argc--;\r
+      argv++;\r
+      mGlobals.AsmIncludeFileName = argv[0];\r
+      ThingsToDo++;\r
+    } else if (strcmp (argv[0], "-mci") == 0) {\r
+      //\r
+      // -mci FileName\r
+      //\r
+      // Used to specify an input microcode text file to parse.\r
+      // Check for additional argument\r
+      //\r
+      if (argc < 2) {\r
+        Error (NULL, 0, 0, (INT8 *) argv[0], (INT8 *) "option requires an input microcode text file name to parse");\r
+        return STATUS_ERROR;\r
+      }\r
+      argc--;\r
+      argv++;\r
+      mGlobals.MCIFileName = argv[0];\r
+    } else if (strcmp (argv[0], "-flashdeviceimage") == 0) {\r
+      //\r
+      // -flashdeviceimage FlashDeviceImage\r
+      //\r
+      // Used to specify which flash device image definition from the input flash definition file\r
+      // to create.\r
+      // Check for additional argument.\r
+      //\r
+      if (argc < 2) {\r
+        Error (NULL, 0, 0, argv[0], "option requires the name of a flash definition image to use");\r
+        return STATUS_ERROR;\r
+      }\r
+      argc--;\r
+      argv++;\r
+      mGlobals.FlashDeviceImage = argv[0];\r
+    } else if (strcmp (argv[0], "-imageout") == 0) {\r
+      //\r
+      // -imageout FileName\r
+      //\r
+      // Used to specify the name of the output FD image file to create.\r
+      // Check for additional argument.\r
+      //\r
+      if (argc < 2) {\r
+        Error (NULL, 0, 0, argv[0], "option requires an output image filename to create");\r
+        return STATUS_ERROR;\r
+      }\r
+      argc--;\r
+      argv++;\r
+      mGlobals.ImageOutFileName = argv[0];\r
+      ThingsToDo++;\r
+    } else if (strcmp (argv[0], "-dsc") == 0) {\r
+      //\r
+      // -dsc FileName\r
+      //\r
+      // Used to specify the name of the output DSC file to create.\r
+      // Check for additional argument.\r
+      //\r
+      if (argc < 2) {\r
+        Error (NULL, 0, 0, argv[0], "option requires an output DSC filename to create");\r
+        return STATUS_ERROR;\r
+      }\r
+      argc--;\r
+      argv++;\r
+      mGlobals.DscFileName = argv[0];\r
+      ThingsToDo++;\r
+    } else if (strcmp (argv[0], "-fdf") == 0) {\r
+      //\r
+      // -fdf FileName\r
+      //\r
+      // Used to specify the name of the input flash definition file.\r
+      // Check for additional argument.\r
+      //\r
+      if (argc < 2) {\r
+        Error (NULL, 0, 0, argv[0], "option requires an input flash definition file name");\r
+        return STATUS_ERROR;\r
+      }\r
+      argc--;\r
+      argv++;\r
+      mGlobals.FlashDefinitionFileName = argv[0];\r
+    } else if (strcmp (argv[0], "-discover") == 0) {\r
+      //\r
+      // -discover FDFileName\r
+      //\r
+      // Debug functionality used to scan an existing FD image, trying to find\r
+      // firmware volumes at 64K boundaries.\r
+      // Check for additional argument.\r
+      //\r
+      if (argc < 2) {\r
+        Error (NULL, 0, 0, argv[0], "option requires an input FD image file name");\r
+        return STATUS_ERROR;\r
+      }\r
+      argc--;\r
+      argv++;\r
+      mGlobals.DiscoverFDImageName = argv[0];\r
+      ThingsToDo++;\r
+    } else if (strcmp (argv[0], "-baseaddr") == 0) {\r
+      //\r
+      // -baseaddr Addr\r
+      //\r
+      // Used to specify a base address when doing a discover of an FD image.\r
+      // Check for additional argument.\r
+      //\r
+      if (argc < 2) {\r
+        Error (NULL, 0, 0, argv[0], "option requires a base address");\r
+        return STATUS_ERROR;\r
+      }\r
+      argc--;\r
+      argv++;\r
+      if (tolower (argv[0][1]) == 'x') {\r
+        sscanf (argv[0] + 2, "%x", &mGlobals.BaseAddress);\r
+      } else {\r
+        sscanf (argv[0], "%d", &mGlobals.BaseAddress);\r
+      }\r
+    } else if (strcmp (argv[0], "-padvalue") == 0) {\r
+      //\r
+      // -padvalue Value\r
+      //\r
+      // Used to specify the value to pad with when aligning data while\r
+      // creating an FD image. Check for additional argument.\r
+      //\r
+      if (argc < 2) {\r
+        Error (NULL, 0, 0, argv[0], "option requires a byte value");\r
+        return STATUS_ERROR;\r
+      }\r
+      argc--;\r
+      argv++;\r
+      if (tolower (argv[0][1]) == 'x') {\r
+        sscanf (argv[0] + 2, "%x", &Temp);\r
+        mGlobals.MicrocodePadByteValue = (char) Temp;\r
+      } else {\r
+        sscanf (argv[0], "%d", &Temp);\r
+        mGlobals.MicrocodePadByteValue = (char) Temp;\r
+      }\r
+    } else if (strcmp (argv[0], "-align") == 0) {\r
+      //\r
+      // -align Alignment\r
+      //\r
+      // Used to specify how each data file is aligned in the region\r
+      // when creating an FD image. Check for additional argument.\r
+      //\r
+      if (argc < 2) {\r
+        Error (NULL, 0, 0, argv[0], "option requires an alignment");\r
+        return STATUS_ERROR;\r
+      }\r
+      argc--;\r
+      argv++;\r
+      if (tolower (argv[0][1]) == 'x') {\r
+        sscanf (argv[0] + 2, "%x", &mGlobals.MicrocodeAlignment);\r
+      } else {\r
+        sscanf (argv[0], "%d", &mGlobals.MicrocodeAlignment);\r
+      }\r
+    } else if (strcmp (argv[0], "-mcmerge") == 0) {\r
+      //\r
+      // -mcmerge FileName(s)\r
+      //\r
+      // Used to concatenate multiple microde binary files. Can specify\r
+      // multiple file names with the one -mcmerge flag. Check for additional argument.\r
+      //\r
+      if ((argc < 2) || (argv[1][0] == '-')) {\r
+        Error (NULL, 0, 0, argv[0], "option requires one or more input file names");\r
+        return STATUS_ERROR;\r
+      }\r
+      //\r
+      // Take input files until another option or end of list\r
+      //\r
+      ThingsToDo++;\r
+      while ((argc > 1) && (argv[1][0] != '-')) {\r
+        Str = (STRING_LIST *) _malloc (sizeof (STRING_LIST));\r
+        if (Str == NULL) {\r
+          Error (NULL, 0, 0, "memory allocation failure", NULL);\r
+          return STATUS_ERROR;\r
+        }\r
+        memset (Str, 0, sizeof (STRING_LIST));\r
+        Str->Str = argv[1];\r
+        if (mGlobals.MCIFileNames == NULL) {\r
+          mGlobals.MCIFileNames = Str;\r
+        } else {\r
+          mGlobals.LastMCIFileNames->Next = Str;\r
+        }\r
+        mGlobals.LastMCIFileNames = Str;\r
+        argc--;\r
+        argv++;\r
+      }\r
+    } else if (strcmp (argv[0], "-strsub") == 0) {\r
+      //\r
+      // -strsub SrcFile DestFile\r
+      //\r
+      // Used to perform string substitutions on a file, writing the result to a new\r
+      // file. Check for two additional arguments.\r
+      //\r
+      if (argc < 3) {\r
+        Error (NULL, 0, 0, argv[0], "option requires input and output file names for string substitution");\r
+        return STATUS_ERROR;\r
+      }\r
+      argc--;\r
+      argv++;\r
+      mGlobals.StringReplaceInFileName = argv[0];\r
+      argc--;\r
+      argv++;\r
+      mGlobals.StringReplaceOutFileName = argv[0];\r
+      ThingsToDo++;\r
+    } else {\r
+      Error (NULL, 0, 0, argv[0], "invalid option");\r
+      return STATUS_ERROR;\r
+    }\r
+    argc--;\r
+    argv++;\r
+  }\r
+  //\r
+  // If no outputs requested, then report an error\r
+  //\r
+  if (ThingsToDo == 0) {\r
+    Error (NULL, 0, 0, "nothing to do", NULL);\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // If they want an asm file, #include file, or C file to be created, then they have to specify a\r
+  // flash device name and flash definition file name.\r
+  //\r
+  if ((mGlobals.CIncludeFileName != NULL) &&\r
+      ((mGlobals.FlashDevice == NULL) || (mGlobals.FlashDefinitionFileName == NULL))) {\r
+    Error (NULL, 0, 0, "must specify -flashdevice and -fdf with -hfile", NULL);\r
+    return STATUS_ERROR;\r
+  }\r
+  if ((mGlobals.AsmIncludeFileName != NULL) &&\r
+      ((mGlobals.FlashDevice == NULL) || (mGlobals.FlashDefinitionFileName == NULL))) {\r
+    Error (NULL, 0, 0, "must specify -flashdevice and -fdf with -asmincfile", NULL);\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // If they want a dsc file to be created, then they have to specify a\r
+  // flash device name and a flash definition file name\r
+  //\r
+  if (mGlobals.DscFileName != NULL) {\r
+    if (mGlobals.FlashDevice == NULL) {\r
+      Error (NULL, 0, 0, "must specify -flashdevice with -dsc", NULL);\r
+      return STATUS_ERROR;\r
+    }\r
+    if (mGlobals.FlashDefinitionFileName == NULL) {\r
+      Error (NULL, 0, 0, "must specify -fdf with -dsc", NULL);\r
+      return STATUS_ERROR;\r
+    }\r
+  }\r
+  //\r
+  // If they specified an output microcode file name, then they have to specify an input\r
+  // file name, and vice versa.\r
+  //\r
+  if ((mGlobals.MCIFileName != NULL) && (mGlobals.MCOFileName == NULL)) {\r
+    Error (NULL, 0, 0, "must specify output microcode file name", NULL);\r
+    return STATUS_ERROR;\r
+  }\r
+  if ((mGlobals.MCOFileName != NULL) && (mGlobals.MCIFileName == NULL) && (mGlobals.MCIFileNames == NULL)) {\r
+    Error (NULL, 0, 0, "must specify input microcode file name", NULL);\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // If doing merge, then have to specify output file name\r
+  //\r
+  if ((mGlobals.MCIFileNames != NULL) && (mGlobals.MCOFileName == NULL)) {\r
+    Error (NULL, 0, 0, "must specify output microcode file name", NULL);\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // If they want an output image to be created, then they have to specify\r
+  // the flash device and the flash device image to use.\r
+  //\r
+  if (mGlobals.ImageOutFileName != NULL) {\r
+    if (mGlobals.FlashDevice == NULL) {\r
+      Error (NULL, 0, 0, "must specify -flashdevice with -imageout", NULL);\r
+      return STATUS_ERROR;\r
+    }\r
+    if (mGlobals.FlashDeviceImage == NULL) {\r
+      Error (NULL, 0, 0, "must specify -flashdeviceimage with -imageout", NULL);\r
+      return STATUS_ERROR;\r
+    }\r
+    if (mGlobals.FlashDefinitionFileName == NULL) {\r
+      Error (NULL, 0, 0, "must specify -c or -fdf with -imageout", NULL);\r
+      return STATUS_ERROR;\r
+    }\r
+  }\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+void\r
+Usage (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Print utility command line help\r
+  \r
+Arguments:\r
+  None\r
+\r
+Returns:\r
+  NA\r
+\r
+--*/\r
+{\r
+  int   i;\r
+  char  *Msg[] = {\r
+    "Usage: FlashTool -fdf FlashDefFile -flashdevice FlashDevice",\r
+    "                 -flashdeviceimage FlashDeviceImage -mci MCIFile -mco MCOFile",\r
+    "                 -discover FDImage -dsc DscFile -asmincfile AsmIncFile",\r
+    "                 -imageOut ImageOutFile -hfile HFile -strsub InStrFile OutStrFile",\r
+    "                 -baseaddr BaseAddr -align Alignment -padvalue PadValue",\r
+    "                 -mcmerge MCIFile(s)",\r
+    "  where",\r
+    "    FlashDefFile     - input Flash Definition File",\r
+    "    FlashDevice      - flash device to use (from flash definition file)",\r
+    "    FlashDeviceImage - flash device image to use (from flash definition file)",\r
+    "    MCIFile          - input microcode file to parse",\r
+    "    MCOFile          - output binary microcode image to create from MCIFile",\r
+    "    HFile            - output #include file to create",\r
+    "    FDImage          - name of input FDImage file to scan",\r
+    "    ImageOutFile     - output image file to create",\r
+    "    DscFile          - output DSC file to create",\r
+    "    AsmIncFile       - output ASM include file to create",\r
+    "    InStrFile        - input file to replace symbol names, writing result to OutStrFile",\r
+    "    BaseAddr         - base address of FDImage (used with -discover)",\r
+    "    Alignment        - alignment to use when merging microcode binaries",\r
+    "    PadValue         - byte value to use as pad value when aligning microcode binaries",\r
+    "    MCIFile(s)       - one or more microcode binary files to merge/concatenate",\r
+    "",\r
+    NULL\r
+  };\r
+  for (i = 0; Msg[i] != NULL; i++) {\r
+    fprintf (stdout, "%s\n", Msg[i]);\r
+  }\r
+}\r
+\r
+char* \r
+NormalizePath (\r
+  char* OldPathName\r
+  )\r
+{\r
+  char* Visitor;\r
+  \r
+  if (OldPathName == NULL) {\r
+    return NULL;\r
+  }\r
+  \r
+  Visitor = OldPathName;\r
+  while (*Visitor != '\0') {\r
+    if (*Visitor == '\\') {\r
+      *Visitor = '/';\r
+    }\r
+    Visitor++;\r
+  }\r
+  \r
+  return OldPathName;\r
+}\r
+\r
diff --git a/Tools/CodeTools/Source/FlashMap/Microcode.c b/Tools/CodeTools/Source/FlashMap/Microcode.c
new file mode 100644 (file)
index 0000000..2335325
--- /dev/null
@@ -0,0 +1,304 @@
+/*++\r
+\r
+Copyright (c)  2004-2006 Intel Corporation. All rights reserved\r
+This program and the accompanying materials are licensed and made available \r
+under the terms and conditions of the BSD License which accompanies this \r
+distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+Module Name:\r
+\r
+  Microcode.c\r
+\r
+Abstract:\r
+\r
+  Utility for working with microcode patch files in the Intel \r
+  Platform Innovation Framework for EFI build environment.\r
+\r
+--*/\r
+\r
+#include <stdio.h>\r
+#include <string.h> // for memset()\r
+#include <ctype.h>\r
+#include <stdlib.h> // for malloc()\r
+\r
+#include "EfiUtilityMsgs.h"\r
+#include "Microcode.h"\r
+\r
+#define MAX_LINE_LEN  256\r
+\r
+//\r
+// Structure definition for a microcode header\r
+//\r
+typedef struct {\r
+  unsigned int  HeaderVersion;\r
+  unsigned int  PatchId;\r
+  unsigned int  Date;\r
+  unsigned int  CpuId;\r
+  unsigned int  Checksum;\r
+  unsigned int  LoaderVersion;\r
+  unsigned int  PlatformId;\r
+  unsigned int  DataSize;   // if 0, then TotalSize = 2048, and TotalSize field is invalid\r
+  unsigned int  TotalSize;  // number of bytes\r
+  unsigned int  Reserved[3];\r
+} MICROCODE_IMAGE_HEADER;\r
+\r
+static\r
+STATUS\r
+MicrocodeReadData (\r
+  FILE          *InFptr,\r
+  unsigned int  *Data\r
+  );\r
+\r
+void\r
+MicrocodeConstructor (\r
+  void\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Constructor of module Microcode\r
+\r
+Arguments:\r
+\r
+  None\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+{\r
+}\r
+\r
+void\r
+MicrocodeDestructor (\r
+  void\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Destructor of module Microcode\r
+\r
+Arguments:\r
+\r
+  None\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+{\r
+}\r
+\r
+static\r
+STATUS\r
+MicrocodeReadData (\r
+  FILE          *InFptr,\r
+  unsigned int  *Data\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Read a 32-bit microcode data value from a text file and convert to raw binary form.\r
+\r
+Arguments:\r
+  InFptr    - file pointer to input text file\r
+  Data      - pointer to where to return the data parsed\r
+\r
+Returns:\r
+  STATUS_SUCCESS    - no errors or warnings, Data contains valid information\r
+  STATUS_ERROR      - errors were encountered\r
+\r
+--*/\r
+{\r
+  char  Line[MAX_LINE_LEN];\r
+  char  *cptr;\r
+\r
+  Line[MAX_LINE_LEN - 1]  = 0;\r
+  *Data                   = 0;\r
+  if (fgets (Line, MAX_LINE_LEN, InFptr) == NULL) {\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // If it was a binary file, then it may have overwritten our null terminator\r
+  //\r
+  if (Line[MAX_LINE_LEN - 1] != 0) {\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Look for\r
+  // dd 000000001h ; comment\r
+  // dd XXXXXXXX\r
+  // DD  XXXXXXXXX\r
+  //  DD XXXXXXXXX\r
+  //\r
+  for (cptr = Line; *cptr && isspace(*cptr); cptr++) {\r
+  }\r
+  if ((tolower(cptr[0]) == 'd') && (tolower(cptr[1]) == 'd') && isspace (cptr[2])) {\r
+    //\r
+    // Skip blanks and look for a hex digit\r
+    //\r
+    cptr += 3;\r
+    for (; *cptr && isspace(*cptr); cptr++) {\r
+    }\r
+    if (isxdigit (*cptr)) {\r
+      if (sscanf (cptr, "%X", Data) != 1) {\r
+        return STATUS_ERROR;\r
+      }\r
+    }\r
+    return STATUS_SUCCESS;\r
+  }\r
+  return STATUS_ERROR;\r
+}\r
+\r
+STATUS\r
+MicrocodeParseFile (\r
+  char  *InFileName,\r
+  char  *OutFileName\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Parse a microcode text file, and write the binary results to an output file.\r
+\r
+Arguments:\r
+  InFileName  - input text file to parse\r
+  OutFileName - output file to write raw binary data from parsed input file\r
+\r
+Returns:\r
+  STATUS_SUCCESS    - no errors or warnings\r
+  STATUS_ERROR      - errors were encountered\r
+\r
+--*/\r
+{\r
+  FILE                    *InFptr;\r
+  FILE                    *OutFptr;\r
+  STATUS                  Status;\r
+  MICROCODE_IMAGE_HEADER  *Header;\r
+  unsigned int            Size;\r
+  unsigned int            Size2;\r
+  unsigned int            Data;\r
+  unsigned int            Checksum;\r
+  char                    *Buffer;\r
+  char                    *Ptr;\r
+  unsigned int            TotalSize;\r
+\r
+  Status  = STATUS_ERROR;\r
+  InFptr  = NULL;\r
+  OutFptr = NULL;\r
+  Buffer  = NULL;\r
+  //\r
+  // Open the input text file\r
+  //\r
+  if ((InFptr = fopen (InFileName, "r")) == NULL) {\r
+    Error (NULL, 0, 0, InFileName, "failed to open input microcode file for reading");\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Make two passes on the input file. The first pass is to determine how\r
+  // much data is in the file so we can allocate a working buffer. Then\r
+  // we'll allocate a buffer and re-read the file into the buffer for processing.\r
+  //\r
+  Size = 0;\r
+  do {\r
+    Status = MicrocodeReadData (InFptr, &Data);\r
+    if (Status == STATUS_SUCCESS) {\r
+      Size += sizeof (Data);\r
+    }\r
+  } while (Status == STATUS_SUCCESS);\r
+  //\r
+  // Error if no data.\r
+  //\r
+  if (Size == 0) {\r
+    Error (NULL, 0, 0, InFileName, "no parse-able data found in file");\r
+    goto Done;\r
+  }\r
+  if (Size < sizeof (MICROCODE_IMAGE_HEADER)) {\r
+    Error (NULL, 0, 0, InFileName, "amount of parse-able data is insufficient to contain a microcode header");\r
+    goto Done;\r
+  }\r
+  //\r
+  // Allocate a buffer for the data\r
+  //\r
+  Buffer = (char *) _malloc (Size);\r
+  if (Buffer == NULL) {\r
+    Error (NULL, 0, 0, "memory allocation failure", NULL);\r
+    goto Done;\r
+  }\r
+  //\r
+  // Re-read the file, storing the data into our buffer\r
+  //\r
+  fseek (InFptr, 0, SEEK_SET);\r
+  Ptr = Buffer;\r
+  do {\r
+    Status = MicrocodeReadData (InFptr, &Data);\r
+    if (Status == STATUS_SUCCESS) {\r
+      *(unsigned int *) Ptr = Data;\r
+      Ptr += sizeof (Data);\r
+    }\r
+  } while (Status == STATUS_SUCCESS);\r
+  //\r
+  // Can't do much checking on the header because, per the spec, the\r
+  // DataSize field may be 0, which means DataSize = 2000 and TotalSize = 2K,\r
+  // and the TotalSize field is invalid (actually missing). Thus we can't\r
+  // even verify the Reserved fields are 0.\r
+  //\r
+  Header = (MICROCODE_IMAGE_HEADER *) Buffer;\r
+  if (Header->DataSize == 0) {\r
+    TotalSize = 2048;\r
+  } else {\r
+    TotalSize = Header->TotalSize;\r
+  }\r
+  if (TotalSize != Size) {\r
+    Error (NULL, 0, 0, InFileName, "file contents do not contain expected TotalSize 0x%04X", TotalSize);\r
+    goto Done;\r
+  }\r
+  //\r
+  // Checksum the contents\r
+  //\r
+  Ptr       = Buffer;\r
+  Checksum  = 0;\r
+  Size2     = 0;\r
+  while (Size2 < Size) {\r
+    Checksum += *(unsigned int *) Ptr;\r
+    Ptr += 4;\r
+    Size2 += 4;\r
+  }\r
+  if (Checksum != 0) {\r
+    Error (NULL, 0, 0, InFileName, "checksum failed on file contents");\r
+    goto Done;\r
+  }\r
+  //\r
+  // Open the output file and write the buffer contents\r
+  //\r
+  if ((OutFptr = fopen (OutFileName, "wb")) == NULL) {\r
+    Error (NULL, 0, 0, OutFileName, "failed to open output microcode file for writing");\r
+    goto Done;\r
+  }\r
+  if (fwrite (Buffer, Size, 1, OutFptr) != 1) {\r
+    Error (NULL, 0, 0, OutFileName, "failed to write microcode data to output file");\r
+    goto Done;\r
+  }\r
+  Status = STATUS_SUCCESS;\r
+Done:\r
+  if (Buffer != NULL) {\r
+    free (Buffer);\r
+  }\r
+  if (InFptr != NULL) {\r
+    fclose (InFptr);\r
+  }\r
+  if (OutFptr != NULL) {\r
+    fclose (OutFptr);\r
+    if (Status == STATUS_ERROR) {\r
+      remove (OutFileName);\r
+    }\r
+  }\r
+  return Status;\r
+}\r
diff --git a/Tools/CodeTools/Source/FlashMap/Microcode.h b/Tools/CodeTools/Source/FlashMap/Microcode.h
new file mode 100644 (file)
index 0000000..f85313e
--- /dev/null
@@ -0,0 +1,87 @@
+/*++\r
+\r
+Copyright (c)  2004-2006 Intel Corporation. All rights reserved\r
+This program and the accompanying materials are licensed and made available \r
+under the terms and conditions of the BSD License which accompanies this \r
+distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+Module Name:\r
+\r
+  Microcode.h\r
+\r
+Abstract:\r
+\r
+  Header file for flash management utility in the Intel Platform \r
+  Innovation Framework for EFI build environment.\r
+\r
+--*/\r
+\r
+#ifndef _MICROCODE_H_\r
+#define _MICROCODE_H_\r
+\r
+void\r
+MicrocodeConstructor (\r
+  void\r
+  );\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Constructor of module Microcode\r
+\r
+Arguments:\r
+\r
+  None\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+\r
+void\r
+MicrocodeDestructor (\r
+  void\r
+  );\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Destructor of module Microcode\r
+\r
+Arguments:\r
+\r
+  None\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+\r
+STATUS\r
+MicrocodeParseFile (\r
+  char  *InFileName,\r
+  char  *OutFileName\r
+  );\r
+/*++\r
+\r
+Routine Description:\r
+  Parse a microcode text file, and write the binary results to an output file.\r
+\r
+Arguments:\r
+  InFileName  - input text file to parse\r
+  OutFileName - output file to write raw binary data from parsed input file\r
+\r
+Returns:\r
+  STATUS_SUCCESS    - no errors or warnings\r
+  STATUS_ERROR      - errors were encountered\r
+\r
+--*/\r
+\r
+\r
+#endif // #ifndef _MICROCODE_H_\r
diff --git a/Tools/CodeTools/Source/FlashMap/Symbols.c b/Tools/CodeTools/Source/FlashMap/Symbols.c
new file mode 100644 (file)
index 0000000..8e40814
--- /dev/null
@@ -0,0 +1,648 @@
+/*++\r
+\r
+Copyright (c)  2004-2006 Intel Corporation. All rights reserved\r
+This program and the accompanying materials are licensed and made available \r
+under the terms and conditions of the BSD License which accompanies this \r
+distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+Module Name:\r
+\r
+  Symbol.c\r
+\r
+Abstract:\r
+\r
+  Class-like implementation for a symbol table.\r
+\r
+--*/\r
+\r
+// GC_TODO: fix comment to set correct module name: Symbols.c\r
+#include <stdio.h>\r
+#include <string.h>\r
+#include <stdlib.h>\r
+//\r
+// for isspace()\r
+//\r
+#include <ctype.h>\r
+\r
+#include <Common/UefiBaseTypes.h>\r
+\r
+#include "CommonLib.h"\r
+#include "EfiUtilityMsgs.h"\r
+#include "Symbols.h"\r
+\r
+#define MAX_LINE_LEN  512\r
+\r
+//\r
+// Linked list to keep track of all symbols\r
+//\r
+typedef struct _SYMBOL {\r
+  struct _SYMBOL  *Next;\r
+  int             Type;\r
+  char            *Name;\r
+  char            *Value;\r
+} SYMBOL;\r
+\r
+static\r
+SYMBOL        *\r
+FreeSymbols (\r
+  SYMBOL *Syms\r
+  );\r
+\r
+static\r
+int\r
+ExpandMacros (\r
+  char  *SourceLine,\r
+  char  *DestLine,\r
+  int   LineLen\r
+  );\r
+\r
+static SYMBOL *mSymbolTable = NULL;\r
+\r
+void\r
+SymbolsConstructor (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  None\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+{\r
+  SymbolsDestructor ();\r
+}\r
+\r
+void\r
+SymbolsDestructor (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  None\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+{\r
+  mSymbolTable = FreeSymbols (mSymbolTable);\r
+}\r
+\r
+char *\r
+GetSymbolValue (\r
+  char *SymbolName\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  Look up a symbol in our symbol table.\r
+\r
+Arguments:\r
+\r
+  SymbolName\r
+\r
+Returns:\r
+\r
+  Pointer to the value of the symbol if found\r
+  NULL if the symbol is not found\r
+\r
+--*/\r
+// GC_TODO:    SymbolName - add argument and description to function comment\r
+{\r
+  SYMBOL  *Symbol;\r
+  //\r
+  // Walk the symbol table\r
+  //\r
+  Symbol = mSymbolTable;\r
+  while (Symbol) {\r
+    if (stricmp (SymbolName, Symbol->Name) == 0) {\r
+      return Symbol->Value;\r
+    }\r
+\r
+    Symbol = Symbol->Next;\r
+  }\r
+\r
+  return NULL;\r
+}\r
+\r
+int\r
+SymbolAdd (\r
+  char    *Name,\r
+  char    *Value,\r
+  int     Mode\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  Add a symbol name/value to the symbol table\r
+\r
+Arguments:\r
+\r
+  Name  - name of symbol to add\r
+  Value - value of symbol to add\r
+  Mode  - currrently unused\r
+\r
+Returns:\r
+\r
+  Length of symbol added.\r
+\r
+Notes:\r
+  If Value == NULL, then this routine will assume that the Name field\r
+  looks something like "MySymName = MySymValue", and will try to parse\r
+  it that way and add the symbol name/pair from the string.\r
+\r
+--*/\r
+{\r
+  SYMBOL  *Symbol;\r
+\r
+  SYMBOL  *NewSymbol;\r
+  int     Len;\r
+  char    *Start;\r
+  char    *Cptr;\r
+  char    CSave;\r
+  char    *SaveCptr;\r
+\r
+  Len       = 0;\r
+  SaveCptr  = NULL;\r
+  CSave     = 0;\r
+  //\r
+  // If value pointer is null, then they passed us a line something like:\r
+  //    varname = value, or simply var =\r
+  //\r
+  if (Value == NULL) {\r
+    Start = Name;\r
+    while (*Name && isspace (*Name)) {\r
+      Name++;\r
+    }\r
+\r
+    if (Name == NULL) {\r
+      return -1;\r
+    }\r
+    //\r
+    // Find the end of the name. Either space or a '='.\r
+    //\r
+    for (Value = Name; *Value && !isspace (*Value) && (*Value != '='); Value++)\r
+      ;\r
+    if (Value == NULL) {\r
+      return -1;\r
+    }\r
+    //\r
+    // Look for the '='\r
+    //\r
+    Cptr = Value;\r
+    while (*Value && (*Value != '=')) {\r
+      Value++;\r
+    }\r
+\r
+    if (Value == NULL) {\r
+      return -1;\r
+    }\r
+    //\r
+    // Now truncate the name\r
+    //\r
+    *Cptr = 0;\r
+    //\r
+    // Skip over the = and then any spaces\r
+    //\r
+    Value++;\r
+    while (*Value && isspace (*Value)) {\r
+      Value++;\r
+\r
+    }\r
+    //\r
+    // Find end of string, checking for quoted string\r
+    //\r
+    if (*Value == '\"') {\r
+      Value++;\r
+      for (Cptr = Value; *Cptr && *Cptr != '\"'; Cptr++)\r
+        ;\r
+    } else {\r
+      for (Cptr = Value; *Cptr && !isspace (*Cptr); Cptr++)\r
+        ;\r
+    }\r
+    //\r
+    // Null terminate the value string\r
+    //\r
+    CSave     = *Cptr;\r
+    SaveCptr  = Cptr;\r
+    *Cptr     = 0;\r
+    Len       = (int) (Cptr - Start);\r
+  }\r
+  //\r
+  // We now have a symbol name and a value. Look for an existing variable\r
+  // and overwrite it.\r
+  //\r
+  Symbol = mSymbolTable;\r
+  while (Symbol) {\r
+    //\r
+    // Check for symbol name match\r
+    //\r
+    if (stricmp (Name, Symbol->Name) == 0) {\r
+      _free (Symbol->Value);\r
+      Symbol->Value = (char *) _malloc (strlen (Value) + 1);\r
+      if (Symbol->Value == NULL) {\r
+        Error (NULL, 0, 0, NULL, "failed to allocate memory");\r
+        return -1;\r
+      }\r
+\r
+      strcpy (Symbol->Value, Value);\r
+      //\r
+      // If value == "NULL", then make it a 0-length string\r
+      //\r
+      if (stricmp (Symbol->Value, "NULL") == 0) {\r
+        Symbol->Value[0] = 0;\r
+      }\r
+\r
+      return Len;\r
+    }\r
+\r
+    Symbol = Symbol->Next;\r
+  }\r
+  //\r
+  // Does not exist, create a new one\r
+  //\r
+  NewSymbol = (SYMBOL *) _malloc (sizeof (SYMBOL));\r
+  if (NewSymbol == NULL) {\r
+    Error (NULL, 0, 0, NULL, "memory allocation failure");\r
+    return -1;\r
+  }\r
+\r
+  memset ((char *) NewSymbol, 0, sizeof (SYMBOL));\r
+  NewSymbol->Name = (char *) _malloc (strlen (Name) + 1);\r
+  if (NewSymbol->Name == NULL) {\r
+    Error (NULL, 0, 0, NULL, "memory allocation failure");\r
+    _free (NewSymbol);\r
+    return -1;\r
+  }\r
+\r
+  NewSymbol->Value = (char *) _malloc (strlen (Value) + 1);\r
+  if (NewSymbol->Value == NULL) {\r
+    Error (NULL, 0, 0, NULL, "memory allocation failure");\r
+    _free (NewSymbol->Name);\r
+    _free (NewSymbol);\r
+    return -1;\r
+  }\r
+\r
+  strcpy (NewSymbol->Name, Name);\r
+  strcpy (NewSymbol->Value, Value);\r
+  //\r
+  // Remove trailing spaces\r
+  //\r
+  Cptr = NewSymbol->Value + strlen (NewSymbol->Value) - 1;\r
+  while (Cptr > NewSymbol->Value) {\r
+    if (isspace (*Cptr)) {\r
+      *Cptr = 0;\r
+      Cptr--;\r
+    } else {\r
+      break;\r
+    }\r
+  }\r
+  //\r
+  // Add it to the head of the list.\r
+  //\r
+  NewSymbol->Next = mSymbolTable;\r
+  mSymbolTable    = NewSymbol;\r
+  //\r
+  // If value == "NULL", then make it a 0-length string\r
+  //\r
+  if (stricmp (NewSymbol->Value, "NULL") == 0) {\r
+    NewSymbol->Value[0] = 0;\r
+  }\r
+  //\r
+  // Restore the terminator we inserted if they passed in var=value\r
+  //\r
+  if (SaveCptr != NULL) {\r
+    *SaveCptr = CSave;\r
+  }\r
+  _free (NewSymbol->Value);\r
+  _free (NewSymbol->Name);\r
+  _free (NewSymbol);\r
+  return Len;\r
+}\r
+\r
+static\r
+STATUS\r
+RemoveSymbol (\r
+  char *Name,\r
+  char SymbolType\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  Remove a symbol name/value from the symbol table\r
+\r
+Arguments:\r
+\r
+  Name  - name of symbol to remove\r
+  SymbolType - type of symbol to remove\r
+\r
+Returns:\r
+\r
+  STATUS_SUCCESS - matching symbol found and removed\r
+  STATUS_ERROR   - matching symbol not found in symbol table\r
+\r
+--*/\r
+{\r
+  SYMBOL  *Symbol;\r
+\r
+  SYMBOL  *PrevSymbol;\r
+\r
+  PrevSymbol  = NULL;\r
+  Symbol      = mSymbolTable;\r
+  //\r
+  // Walk the linked list of symbols in the symbol table looking\r
+  // for a match of both symbol name and type.\r
+  //\r
+  while (Symbol) {\r
+    if ((stricmp (Name, Symbol->Name) == 0) && (Symbol->Type & SymbolType)) {\r
+      //\r
+      // If the symbol has a value associated with it, free the memory\r
+      // allocated for the value.\r
+      // Then free the memory allocated for the symbols string name.\r
+      //\r
+      if (Symbol->Value) {\r
+        _free (Symbol->Value);\r
+      }\r
+\r
+      _free (Symbol->Name);\r
+      //\r
+      // Link the previous symbol to the next symbol to effectively\r
+      // remove this symbol from the linked list.\r
+      //\r
+      if (PrevSymbol) {\r
+        PrevSymbol->Next = Symbol->Next;\r
+      } else {\r
+        mSymbolTable = Symbol->Next;\r
+      }\r
+\r
+      _free (Symbol);\r
+      return STATUS_SUCCESS;\r
+    }\r
+\r
+    PrevSymbol  = Symbol;\r
+    Symbol      = Symbol->Next;\r
+  }\r
+\r
+  return STATUS_WARNING;\r
+}\r
+\r
+static\r
+SYMBOL *\r
+FreeSymbols (\r
+  SYMBOL *Syms\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Syms  - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+{\r
+  SYMBOL  *Next;\r
+  while (Syms) {\r
+    if (Syms->Name != NULL) {\r
+      _free (Syms->Name);\r
+    }\r
+\r
+    if (Syms->Value != NULL) {\r
+      _free (Syms->Value);\r
+    }\r
+\r
+    Next = Syms->Next;\r
+    _free (Syms);\r
+    Syms = Next;\r
+  }\r
+\r
+  return Syms;\r
+}\r
+\r
+static\r
+int\r
+ExpandMacros (\r
+  char  *SourceLine,\r
+  char  *DestLine,\r
+  int   LineLen\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  Given a line of text, replace all variables of format $(NAME) with values\r
+  from our symbol table.\r
+\r
+Arguments:\r
+\r
+  SourceLine    - input line of text to do symbol replacements on\r
+  DestLine      - on output, SourceLine with symbols replaced\r
+  LineLen       - length of DestLine, so we don't exceed its allocated length\r
+\r
+Returns:\r
+\r
+  STATUS_SUCCESS - no problems encountered\r
+  STATUS_WARNING - missing closing parenthesis on a symbol reference in SourceLine\r
+  STATUS_ERROR   - memory allocation failure\r
+\r
+--*/\r
+{\r
+  static int  NestDepth = 0;\r
+  char        *FromPtr;\r
+  char        *ToPtr;\r
+  char        *SaveStart;\r
+  char        *Cptr;\r
+  char        *value;\r
+  int         Expanded;\r
+  int         ExpandedCount;\r
+  INT8        *LocalDestLine;\r
+  STATUS      Status;\r
+  int         LocalLineLen;\r
+\r
+  NestDepth++;\r
+  Status        = STATUS_SUCCESS;\r
+  LocalDestLine = (char *) _malloc (LineLen);\r
+  if (LocalDestLine == NULL) {\r
+    Error (__FILE__, __LINE__, 0, "memory allocation failed", NULL);\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  FromPtr = SourceLine;\r
+  ToPtr   = LocalDestLine;\r
+  //\r
+  // Walk the entire line, replacing $(MACRO_NAME).\r
+  //\r
+  LocalLineLen  = LineLen;\r
+  ExpandedCount = 0;\r
+  while (*FromPtr && (LocalLineLen > 0)) {\r
+    if ((*FromPtr == '$') && (*(FromPtr + 1) == '(')) {\r
+      //\r
+      // Save the start in case it's undefined, in which case we copy it as-is.\r
+      //\r
+      SaveStart = FromPtr;\r
+      Expanded  = 0;\r
+      //\r
+      // Macro expansion time. Find the end (no spaces allowed)\r
+      //\r
+      FromPtr += 2;\r
+      for (Cptr = FromPtr; *Cptr && (*Cptr != ')'); Cptr++)\r
+        ;\r
+      if (*Cptr) {\r
+        //\r
+        // Truncate the string at the closing parenthesis for ease-of-use.\r
+        // Then copy the string directly to the destination line in case we don't find\r
+        // a definition for it.\r
+        //\r
+        *Cptr = 0;\r
+        strcpy (ToPtr, SaveStart);\r
+        if ((value = GetSymbolValue (FromPtr)) != NULL) {\r
+          strcpy (ToPtr, value);\r
+          LocalLineLen -= strlen (value);\r
+          ToPtr += strlen (value);\r
+          Expanded = 1;\r
+          ExpandedCount++;\r
+        }\r
+\r
+        if (!Expanded) {\r
+          //\r
+          // Restore closing parenthesis, and advance to next character\r
+          //\r
+          *Cptr   = ')';\r
+          FromPtr = SaveStart + 1;\r
+          ToPtr++;\r
+        } else {\r
+          FromPtr = Cptr + 1;\r
+        }\r
+      } else {\r
+        Error (NULL, 0, 0, SourceLine, "missing closing parenthesis on macro");\r
+        strcpy (ToPtr, FromPtr);\r
+        Status = STATUS_WARNING;\r
+        goto Done;\r
+      }\r
+    } else {\r
+      *ToPtr = *FromPtr;\r
+      FromPtr++;\r
+      ToPtr++;\r
+      LocalLineLen--;\r
+    }\r
+  }\r
+\r
+  if (*FromPtr == 0) {\r
+    *ToPtr = 0;\r
+  }\r
+\r
+  //\r
+  // If we expanded at least one string successfully, then make a recursive call to try again.\r
+  //\r
+  if ((ExpandedCount != 0) && (Status == STATUS_SUCCESS) && (NestDepth < 10)) {\r
+    Status = ExpandMacros (LocalDestLine, DestLine, LineLen);\r
+    _free (LocalDestLine);\r
+    NestDepth = 0;\r
+    return Status;\r
+  }\r
+\r
+Done:\r
+  if (Status != STATUS_ERROR) {\r
+    strcpy (DestLine, LocalDestLine);\r
+  }\r
+\r
+  NestDepth = 0;\r
+  _free (LocalDestLine);\r
+  return Status;\r
+}\r
+\r
+STATUS\r
+SymbolsFileStringsReplace (\r
+  char    *InFileName,\r
+  char    *OutFileName\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  Given input and output file names, read in the input file, replace variable\r
+  references of format $(NAME) with appropriate values from our symbol table,\r
+  and write the result out to the output file.\r
+\r
+Arguments:\r
+\r
+  InFileName  - name of input text file to replace variable references\r
+  OutFileName - name of output text file to write results to\r
+\r
+Returns:\r
+\r
+  STATUS_SUCCESS - no problems encountered\r
+  STATUS_ERROR   - failed to open input or output file\r
+\r
+--*/\r
+{\r
+  STATUS  Status;\r
+  FILE    *InFptr;\r
+  FILE    *OutFptr;\r
+  char    Line[MAX_LINE_LEN];\r
+  char    OutLine[MAX_LINE_LEN];\r
+\r
+  Status = STATUS_ERROR;\r
+  //\r
+  // Open input and output files\r
+  //\r
+  InFptr  = NULL;\r
+  OutFptr = NULL;\r
+  if ((InFptr = fopen (InFileName, "r")) == NULL) {\r
+    Error (NULL, 0, 0, InFileName, "failed to open input file for reading");\r
+    goto Done;\r
+  }\r
+\r
+  if ((OutFptr = fopen (OutFileName, "w")) == NULL) {\r
+    Error (NULL, 0, 0, OutFileName, "failed to open output file for writing");\r
+    goto Done;\r
+  }\r
+  //\r
+  // Read lines from input file until done\r
+  //\r
+  while (fgets (Line, sizeof (Line), InFptr) != NULL) {\r
+    ExpandMacros (Line, OutLine, sizeof (OutLine));\r
+    fprintf (OutFptr, OutLine);\r
+  }\r
+\r
+  Status = STATUS_SUCCESS;\r
+Done:\r
+  if (InFptr != NULL) {\r
+    fclose (InFptr);\r
+  }\r
+\r
+  if (OutFptr != NULL) {\r
+    fclose (OutFptr);\r
+  }\r
+\r
+  return Status;\r
+}\r
diff --git a/Tools/CodeTools/Source/FlashMap/Symbols.h b/Tools/CodeTools/Source/FlashMap/Symbols.h
new file mode 100644 (file)
index 0000000..a3cadff
--- /dev/null
@@ -0,0 +1,124 @@
+/*++\r
+\r
+Copyright (c)  2004-2006 Intel Corporation. All rights reserved\r
+This program and the accompanying materials are licensed and made available \r
+under the terms and conditions of the BSD License which accompanies this \r
+distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+Module Name:\r
+\r
+  Symbols.h\r
+\r
+Abstract:\r
+\r
+  Defines and prototypes for a class-like symbol table service.\r
+\r
+--*/\r
+\r
+#ifndef _SYMBOLS_H_\r
+#define _SYMBOLS_H_\r
+\r
+#ifdef __cplusplus\r
+extern "C"\r
+{\r
+#endif\r
+\r
+int\r
+SymbolAdd (\r
+  char    *Name,\r
+  char    *Value,\r
+  int     Mode\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Name  - GC_TODO: add argument description\r
+  Value - GC_TODO: add argument description\r
+  Mode  - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+STATUS\r
+SymbolsFileStringsReplace (\r
+  char    *InFileName,\r
+  char    *OutFileName\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  InFileName  - GC_TODO: add argument description\r
+  OutFileName - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+void\r
+SymbolsConstructor (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  None\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+void\r
+SymbolsDestructor (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  None\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+#ifdef __cplusplus\r
+}\r
+#endif\r
+\r
+#endif // #ifndef _SYMBOLS_H_\r
diff --git a/Tools/CodeTools/Source/FlashMap/build.xml b/Tools/CodeTools/Source/FlashMap/build.xml
new file mode 100644 (file)
index 0000000..680c182
--- /dev/null
@@ -0,0 +1,76 @@
+<?xml version="1.0" ?>\r
+<!--\r
+Copyright (c) 2006, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+-->\r
+<project default="GenTool" basedir=".">\r
+<!--\r
+    EDK FlashMap Tool\r
+  Copyright (c) 2006, Intel Corporation\r
+-->\r
+  <property name="ToolName" value="FlashMap"/>\r
+  <property name="FileSet" value="*.c"/>\r
+\r
+  <taskdef resource="cpptasks.tasks"/>\r
+  <typedef resource="cpptasks.types"/>\r
+  <taskdef resource="net/sf/antcontrib/antlib.xml"/>\r
+\r
+  <property name="LINK_OUTPUT_TYPE" value="static"/>\r
+  <property name="BUILD_DIR" value="${PACKAGE_DIR}/${ToolName}/tmp"/>\r
+\r
+  <target name="GenTool" depends="init, Tool">\r
+    <echo message="The EDK Tool: ${ToolName} build has completed!"/>\r
+  </target>\r
+\r
+  <target name="init">\r
+    <echo message="Building the EDK Tool: ${ToolName}"/>\r
+    <mkdir dir="${BUILD_DIR}"/>\r
+  </target>\r
+\r
+  <target name="Tool" depends="init">\r
+    <cc name="${ToolChain}" objdir="${BUILD_DIR}" \r
+        outfile="${BIN_DIR}/${ToolName}"\r
+        outtype="executable"\r
+        optimize="speed" \r
+        debug="true">\r
+      <compilerarg value="${ExtraArgus}" if="ExtraArgus" />\r
+\r
+      <defineset>\r
+        <define name="_malloc" value="malloc"/>\r
+        <define name="_free" value="free"/>\r
+      </defineset>\r
+\r
+      <fileset dir="${basedir}/${ToolName}" \r
+        includes="${FileSet}" \r
+        defaultexcludes="TRUE" \r
+        excludes="*.xml *.inf"/>\r
+\r
+      <includepath path="${PACKAGE_DIR}/Include"/>\r
+      <includepath path="${PACKAGE_DIR}/Include/${HostArch}"/>\r
+      <includepath path="${PACKAGE_DIR}/Common"/>\r
+      <libset dir="${LIB_DIR}" libs="CommonTools"/>\r
+    </cc>\r
+  </target>\r
+\r
+  <target name="clean">\r
+    <echo message="Removing Intermediate Files Only"/>  \r
+    <delete>\r
+      <fileset dir="${BUILD_DIR}" includes="*.obj"/>\r
+    </delete>\r
+  </target>\r
+\r
+  <target name="cleanall">\r
+    <echo message="Removing Object Files and the Executable: ${ToolName}${ext_exe}"/>  \r
+    <delete failonerror="false" quiet="true" includeEmptyDirs="true">\r
+      <fileset dir="${BUILD_DIR}"/>\r
+      <fileset file="${BIN_DIR}/${ToolName}${ext_exe}"/>\r
+    </delete>\r
+  </target>\r
+\r
+</project>\r
diff --git a/Tools/CodeTools/Source/FwImage/build.xml b/Tools/CodeTools/Source/FwImage/build.xml
new file mode 100644 (file)
index 0000000..b52c576
--- /dev/null
@@ -0,0 +1,71 @@
+<?xml version="1.0" ?>\r
+<!--\r
+Copyright (c) 2006, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+-->\r
+<project default="GenTool" basedir=".">\r
+<!--\r
+    EDK FwImage Tool\r
+  Copyright (c) 2006, Intel Corporation\r
+-->\r
+  <property name="ToolName" value="FwImage"/>\r
+  <property name="FileSet" value="fwimage.c"/>\r
+\r
+  <taskdef resource="cpptasks.tasks"/>\r
+  <typedef resource="cpptasks.types"/>\r
+  <taskdef resource="net/sf/antcontrib/antlib.xml"/>\r
+\r
+  <property name="LINK_OUTPUT_TYPE" value="static"/>\r
+  <property name="BUILD_DIR" value="${PACKAGE_DIR}/${ToolName}/tmp"/>\r
+\r
+  <target name="GenTool" depends="init, Tool">\r
+    <echo message="The EDK Tool: ${ToolName} build has completed!"/>\r
+  </target>\r
+\r
+  <target name="init">\r
+    <echo message="Building the EDK Tool: ${ToolName}"/>\r
+    <mkdir dir="${BUILD_DIR}"/>\r
+  </target>\r
+\r
+  <target name="Tool" depends="init">\r
+    <cc name="${ToolChain}" objdir="${BUILD_DIR}" \r
+        outfile="${BIN_DIR}/${ToolName}"\r
+        outtype="executable"\r
+        debug="true"\r
+        optimize="speed">\r
+      <compilerarg value="${ExtraArgus}" if="ExtraArgus" />\r
+\r
+      <fileset dir="${basedir}/${ToolName}" \r
+        includes="${FileSet}" \r
+        defaultexcludes="TRUE" \r
+        excludes="*.xml *.inf"/>\r
+\r
+      <includepath path="${PACKAGE_DIR}/Include"/>\r
+      <includepath path="${PACKAGE_DIR}/Include/${HostArch}"/>\r
+      <includepath path="${PACKAGE_DIR}/Common"/>\r
+      <libset dir="${LIB_DIR}" libs="CommonTools"/>\r
+    </cc>\r
+  </target>\r
+\r
+  <target name="clean">\r
+    <echo message="Removing Intermediate Files Only"/>  \r
+    <delete>\r
+      <fileset dir="${BUILD_DIR}" includes="*.obj"/>\r
+    </delete>\r
+  </target>\r
+\r
+  <target name="cleanall">\r
+    <echo message="Removing Object Files and the Executable: ${ToolName}${ext_exe}"/>  \r
+    <delete failonerror="false" quiet="true" includeEmptyDirs="true">\r
+      <fileset dir="${BUILD_DIR}"/>\r
+      <fileset file="${BIN_DIR}/${ToolName}${ext_exe}"/>\r
+    </delete>\r
+  </target>\r
+\r
+</project>\r
diff --git a/Tools/CodeTools/Source/FwImage/fwimage.c b/Tools/CodeTools/Source/FwImage/fwimage.c
new file mode 100644 (file)
index 0000000..5dd1634
--- /dev/null
@@ -0,0 +1,510 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+    fwimage.c\r
+\r
+Abstract:\r
+\r
+    Converts a pe32+ image to an FW image type\r
+\r
+--*/\r
+\r
+#include "WinNtInclude.h"\r
+\r
+#ifndef __GNUC__\r
+#include <windows.h>\r
+#endif\r
+#include <stdio.h>\r
+#include <stdlib.h>\r
+#include <string.h>\r
+#include <time.h>\r
+\r
+#include <Common/UefiBaseTypes.h>\r
+#include <Common/EfiImage.h>\r
+\r
+#include "CommonLib.h"\r
+#include "EfiUtilityMsgs.c"\r
+\r
+#define UTILITY_NAME  "FwImage"\r
+\r
+#ifdef __GNUC__\r
+typedef unsigned long ULONG;\r
+typedef unsigned char UCHAR;\r
+typedef unsigned char *PUCHAR;\r
+typedef unsigned short USHORT;\r
+#endif\r
+\r
+VOID\r
+Usage (\r
+  VOID\r
+  )\r
+{\r
+  printf ("Usage: " UTILITY_NAME "  {-t time-date} [BASE|SEC|PEI_CORE|PEIM|DXE_CORE|DXE_DRIVER|DXE_RUNTIME_DRIVER|DXE_SAL_DRIVER|DXE_SMM_DRIVER|TOOL|UEFI_DRIVER|UEFI_APPLICATION|USER_DEFINED] peimage [outimage]");\r
+}\r
+\r
+static\r
+STATUS\r
+FCopyFile (\r
+  FILE    *in,\r
+  FILE    *out\r
+  )\r
+{\r
+  ULONG filesize;\r
+  ULONG offset;\r
+  ULONG length;\r
+  UCHAR Buffer[8 * 1024];\r
+\r
+  fseek (in, 0, SEEK_END);\r
+  filesize = ftell (in);\r
+\r
+  fseek (in, 0, SEEK_SET);\r
+  fseek (out, 0, SEEK_SET);\r
+\r
+  offset = 0;\r
+  while (offset < filesize) {\r
+    length = sizeof (Buffer);\r
+    if (filesize - offset < length) {\r
+      length = filesize - offset;\r
+    }\r
+\r
+    fread (Buffer, length, 1, in);\r
+    fwrite (Buffer, length, 1, out);\r
+    offset += length;\r
+  }\r
+\r
+  if ((ULONG) ftell (out) != filesize) {\r
+    Error (NULL, 0, 0, "write error", NULL);\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+STATUS\r
+FReadFile (\r
+  FILE    *in,\r
+  VOID    **Buffer,\r
+  UINTN   *Length\r
+  )\r
+{\r
+  fseek (in, 0, SEEK_END);\r
+  *Length = ftell (in);\r
+  *Buffer = malloc (*Length);\r
+  fseek (in, 0, SEEK_SET);\r
+  fread (*Buffer, *Length, 1, in);\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+STATUS\r
+FWriteFile (\r
+  FILE    *out,\r
+  VOID    *Buffer,\r
+  UINTN   Length\r
+  )\r
+{\r
+  fseek (out, 0, SEEK_SET);\r
+  fwrite (Buffer, Length, 1, out);\r
+  if ((ULONG) ftell (out) != Length) {\r
+    Error (NULL, 0, 0, "write error", NULL);\r
+    return STATUS_ERROR;\r
+  }\r
+  free (Buffer);\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+int\r
+main (\r
+  int  argc,\r
+  char *argv[]\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Main function.\r
+\r
+Arguments:\r
+\r
+  argc - Number of command line parameters.\r
+  argv - Array of pointers to command line parameter strings.\r
+\r
+Returns:\r
+  STATUS_SUCCESS - Utility exits successfully.\r
+  STATUS_ERROR   - Some error occurred during execution.\r
+\r
+--*/\r
+{\r
+  ULONG             Type;\r
+  PUCHAR            Ext;\r
+  PUCHAR            p;\r
+  PUCHAR            pe;\r
+  PUCHAR            OutImageName;\r
+  UCHAR             outname[500];\r
+  FILE              *fpIn;\r
+  FILE              *fpOut;\r
+  VOID              *ZeroBuffer;\r
+  EFI_IMAGE_DOS_HEADER  *DosHdr;\r
+  EFI_IMAGE_NT_HEADERS  *PeHdr;\r
+  EFI_IMAGE_OPTIONAL_HEADER32  *Optional32;\r
+  EFI_IMAGE_OPTIONAL_HEADER64  *Optional64;\r
+  time_t            TimeStamp;\r
+  struct tm         TimeStruct;\r
+  EFI_IMAGE_DOS_HEADER  BackupDosHdr;\r
+  ULONG             Index;\r
+  ULONG             Index1;\r
+  ULONG             Index2;\r
+  ULONG             Index3;\r
+  BOOLEAN           TimeStampPresent;\r
+  UINTN                                 AllignedRelocSize;\r
+  UINTN                                 Delta;\r
+  EFI_IMAGE_SECTION_HEADER              *SectionHeader;\r
+  UINT8      *FileBuffer;\r
+  UINTN      FileLength;\r
+  RUNTIME_FUNCTION  *RuntimeFunction;\r
+  UNWIND_INFO       *UnwindInfo;\r
+\r
+  SetUtilityName (UTILITY_NAME);\r
+  //\r
+  // Assign to fix compile warning\r
+  //\r
+  OutImageName      = NULL;\r
+  Type              = 0;\r
+  Ext               = 0;\r
+  TimeStamp         = 0;\r
+  TimeStampPresent  = FALSE;\r
+\r
+  //\r
+  // Look for -t time-date option first. If the time is "0", then\r
+  // skip it.\r
+  //\r
+  if ((argc > 2) && !strcmp (argv[1], "-t")) {\r
+    TimeStampPresent = TRUE;\r
+    if (strcmp (argv[2], "0") != 0) {\r
+      //\r
+      // Convert the string to a value\r
+      //\r
+      memset ((char *) &TimeStruct, 0, sizeof (TimeStruct));\r
+      if (sscanf(\r
+          argv[2], "%d/%d/%d,%d:%d:%d",\r
+          &TimeStruct.tm_mon,   /* months since January - [0,11] */\r
+          &TimeStruct.tm_mday,  /* day of the month - [1,31] */\r
+          &TimeStruct.tm_year,  /* years since 1900 */\r
+          &TimeStruct.tm_hour,  /* hours since midnight - [0,23] */\r
+          &TimeStruct.tm_min,   /* minutes after the hour - [0,59] */\r
+          &TimeStruct.tm_sec    /* seconds after the minute - [0,59] */\r
+            ) != 6) {\r
+        Error (NULL, 0, 0, argv[2], "failed to convert to mm/dd/yyyy,hh:mm:ss format");\r
+        return STATUS_ERROR;\r
+      }\r
+      //\r
+      // Now fixup some of the fields\r
+      //\r
+      TimeStruct.tm_mon--;\r
+      TimeStruct.tm_year -= 1900;\r
+      //\r
+      // Sanity-check values?\r
+      // Convert\r
+      //\r
+      TimeStamp = mktime (&TimeStruct);\r
+      if (TimeStamp == (time_t) - 1) {\r
+        Error (NULL, 0, 0, argv[2], "failed to convert time");\r
+        return STATUS_ERROR;\r
+      }\r
+    }\r
+    //\r
+    // Skip over the args\r
+    //\r
+    argc -= 2;\r
+    argv += 2;\r
+  }\r
+  //\r
+  // Check for enough args\r
+  //\r
+  if (argc < 3) {\r
+    Usage ();\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  if (argc == 4) {\r
+    OutImageName = argv[3];\r
+  }\r
+  //\r
+  // Get new image type\r
+  //\r
+  p = argv[1];\r
+  if (*p == '/' || *p == '\\') {\r
+    p += 1;\r
+  }\r
+\r
+  if (stricmp (p, "app") == 0 || stricmp (p, "UEFI_APPLICATION") == 0) {\r
+    Type  = EFI_IMAGE_SUBSYSTEM_EFI_APPLICATION;\r
+    Ext   = ".efi";\r
+\r
+  } else if (stricmp (p, "bsdrv") == 0 || stricmp (p, "DXE_DRIVER") == 0) {\r
+    Type  = EFI_IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER;\r
+    Ext   = ".efi";\r
+\r
+  } else if (stricmp (p, "rtdrv") == 0 || stricmp (p, "DXE_RUNTIME_DRIVER") == 0) {\r
+    Type  = EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER;\r
+    Ext   = ".efi";\r
+\r
+  } else if (stricmp (p, "rtdrv") == 0 || stricmp (p, "DXE_SAL_DRIVER") == 0) {\r
+    Type  = EFI_IMAGE_SUBSYSTEM_SAL_RUNTIME_DRIVER;\r
+    Ext   = ".efi";\r
+  } else if (stricmp (p, "SEC") == 0) {\r
+    Type  = EFI_IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER;\r
+    Ext   = ".sec";\r
+  } else if (stricmp (p, "peim") == 0 ||\r
+           stricmp (p, "BASE") == 0 ||\r
+           stricmp (p, "PEI_CORE") == 0 ||\r
+           stricmp (p, "PEIM") == 0 ||\r
+           stricmp (p, "DXE_SMM_DRIVER") == 0 ||\r
+           stricmp (p, "TOOL") == 0 ||\r
+           stricmp (p, "UEFI_APPLICATION") == 0 ||\r
+           stricmp (p, "USER_DEFINED") == 0 ||\r
+           stricmp (p, "UEFI_DRIVER") == 0 ||\r
+           stricmp (p, "DXE_CORE") == 0\r
+          ) {\r
+    Type  = EFI_IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER;\r
+    Ext   = ".pei";\r
+  } else {\r
+       printf ("%s", p);\r
+    Usage ();\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // open source file\r
+  //\r
+  fpIn = fopen (argv[2], "rb");\r
+  if (!fpIn) {\r
+    Error (NULL, 0, 0, argv[2], "failed to open input file for reading");\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  FReadFile (fpIn, (VOID **)&FileBuffer, &FileLength);\r
+\r
+  //\r
+  // Read the dos & pe hdrs of the image\r
+  //\r
+  DosHdr = (EFI_IMAGE_DOS_HEADER *)FileBuffer;\r
+  if (DosHdr->e_magic != EFI_IMAGE_DOS_SIGNATURE) {\r
+    Error (NULL, 0, 0, argv[2], "DOS header signature not found in source image");\r
+    fclose (fpIn);\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  PeHdr = (EFI_IMAGE_NT_HEADERS *)(FileBuffer + DosHdr->e_lfanew);\r
+  if (PeHdr->Signature != EFI_IMAGE_NT_SIGNATURE) {\r
+    Error (NULL, 0, 0, argv[2], "PE header signature not found in source image");\r
+    fclose (fpIn);\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  //\r
+  // open output file\r
+  //\r
+  strcpy (outname, argv[2]);\r
+  pe = NULL;\r
+  for (p = outname; *p; p++) {\r
+    if (*p == '.') {\r
+      pe = p;\r
+    }\r
+  }\r
+\r
+  if (!pe) {\r
+    pe = p;\r
+  }\r
+\r
+  strcpy (pe, Ext);\r
+\r
+  if (!OutImageName) {\r
+    OutImageName = outname;\r
+  }\r
+\r
+  fpOut = fopen (OutImageName, "w+b");\r
+  if (!fpOut) {\r
+    Error (NULL, 0, 0, OutImageName, "could not open output file for writing");\r
+    fclose (fpIn);\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  //\r
+  // Zero all unused fields of the DOS header\r
+  //\r
+  memcpy (&BackupDosHdr, DosHdr, sizeof (EFI_IMAGE_DOS_HEADER));\r
+  memset (DosHdr, 0, sizeof (EFI_IMAGE_DOS_HEADER));\r
+  DosHdr->e_magic  = BackupDosHdr.e_magic;\r
+  DosHdr->e_lfanew = BackupDosHdr.e_lfanew;\r
+\r
+  for (Index = sizeof (EFI_IMAGE_DOS_HEADER); Index < (ULONG) DosHdr->e_lfanew; Index++) {\r
+    FileBuffer[Index] = DosHdr->e_cp;\r
+  }\r
+\r
+  //\r
+  // Path the PE header\r
+  //\r
+  PeHdr->OptionalHeader.Subsystem = (USHORT) Type;\r
+  if (TimeStampPresent) {\r
+    PeHdr->FileHeader.TimeDateStamp = (UINT32) TimeStamp;\r
+  }\r
+\r
+  if (PeHdr->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {\r
+    Optional32 = (EFI_IMAGE_OPTIONAL_HEADER32 *)&PeHdr->OptionalHeader;\r
+    Optional32->MajorLinkerVersion          = 0;\r
+    Optional32->MinorLinkerVersion          = 0;\r
+    Optional32->MajorOperatingSystemVersion = 0;\r
+    Optional32->MinorOperatingSystemVersion = 0;\r
+    Optional32->MajorImageVersion           = 0;\r
+    Optional32->MinorImageVersion           = 0;\r
+    Optional32->MajorSubsystemVersion       = 0;\r
+    Optional32->MinorSubsystemVersion       = 0;\r
+    Optional32->Win32VersionValue           = 0;\r
+    Optional32->CheckSum                    = 0;\r
+    Optional32->SizeOfStackReserve = 0;\r
+    Optional32->SizeOfStackCommit  = 0;\r
+    Optional32->SizeOfHeapReserve  = 0;\r
+    Optional32->SizeOfHeapCommit   = 0;\r
+\r
+    //\r
+    // Strip zero padding at the end of the .reloc section \r
+    //\r
+    if (Optional32->NumberOfRvaAndSizes >= 6) {\r
+      if (Optional32->DataDirectory[5].Size != 0) {\r
+        SectionHeader = (EFI_IMAGE_SECTION_HEADER *)(FileBuffer + DosHdr->e_lfanew + sizeof(UINT32) + sizeof (EFI_IMAGE_FILE_HEADER) + PeHdr->FileHeader.SizeOfOptionalHeader);\r
+        for (Index = 0; Index < PeHdr->FileHeader.NumberOfSections; Index++, SectionHeader++) {\r
+          //\r
+          // Look for the Section Header that starts as the same virtual address as the Base Relocation Data Directory\r
+          //\r
+          if (SectionHeader->VirtualAddress == Optional32->DataDirectory[5].VirtualAddress) {\r
+            SectionHeader->Misc.VirtualSize = Optional32->DataDirectory[5].Size;\r
+            AllignedRelocSize = (Optional32->DataDirectory[5].Size + Optional32->FileAlignment - 1) & (~(Optional32->FileAlignment - 1));\r
+            //\r
+            // Check to see if there is zero padding at the end of the base relocations\r
+            //\r
+            if (AllignedRelocSize < SectionHeader->SizeOfRawData) {\r
+              //\r
+              // Check to see if the base relocations are at the end of the file\r
+              //\r
+              if (SectionHeader->PointerToRawData + SectionHeader->SizeOfRawData == Optional32->SizeOfImage) {\r
+                //\r
+                // All the required conditions are met to strip the zero padding of the end of the base relocations section\r
+                //\r
+                Optional32->SizeOfImage -= (SectionHeader->SizeOfRawData - AllignedRelocSize);\r
+                Optional32->SizeOfInitializedData -= (SectionHeader->SizeOfRawData - AllignedRelocSize);\r
+                SectionHeader->SizeOfRawData = AllignedRelocSize;\r
+                FileLength = Optional32->SizeOfImage;\r
+              }\r
+            }\r
+          }\r
+        }\r
+      }\r
+    }\r
+  } \r
+  if (PeHdr->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC) {\r
+    Optional64 = (EFI_IMAGE_OPTIONAL_HEADER64 *)&PeHdr->OptionalHeader;\r
+    Optional64->MajorLinkerVersion          = 0;\r
+    Optional64->MinorLinkerVersion          = 0;\r
+    Optional64->MajorOperatingSystemVersion = 0;\r
+    Optional64->MinorOperatingSystemVersion = 0;\r
+    Optional64->MajorImageVersion           = 0;\r
+    Optional64->MinorImageVersion           = 0;\r
+    Optional64->MajorSubsystemVersion       = 0;\r
+    Optional64->MinorSubsystemVersion       = 0;\r
+    Optional64->Win32VersionValue           = 0;\r
+    Optional64->CheckSum                    = 0;\r
+    Optional64->SizeOfStackReserve = 0;\r
+    Optional64->SizeOfStackCommit  = 0;\r
+    Optional64->SizeOfHeapReserve  = 0;\r
+    Optional64->SizeOfHeapCommit   = 0;\r
+\r
+    //\r
+    // Zero the .pdata section if the machine type is X64 and the Debug Directory is empty\r
+    //\r
+    if (PeHdr->FileHeader.Machine == 0x8664) { // X64\r
+      if (Optional64->NumberOfRvaAndSizes >= 4) {\r
+        if (Optional64->NumberOfRvaAndSizes < 7 || (Optional64->NumberOfRvaAndSizes >= 7 && Optional64->DataDirectory[6].Size == 0)) {\r
+          SectionHeader = (EFI_IMAGE_SECTION_HEADER *)(FileBuffer + DosHdr->e_lfanew + sizeof(UINT32) + sizeof (EFI_IMAGE_FILE_HEADER) + PeHdr->FileHeader.SizeOfOptionalHeader);\r
+          for (Index = 0; Index < PeHdr->FileHeader.NumberOfSections; Index++, SectionHeader++) {\r
+            if (SectionHeader->VirtualAddress == Optional64->DataDirectory[3].VirtualAddress) {\r
+              RuntimeFunction = (RUNTIME_FUNCTION *)(FileBuffer + SectionHeader->PointerToRawData);\r
+              for (Index1 = 0; Index1 < Optional64->DataDirectory[3].Size / sizeof (RUNTIME_FUNCTION); Index1++, RuntimeFunction++) {\r
+                SectionHeader = (EFI_IMAGE_SECTION_HEADER *)(FileBuffer + DosHdr->e_lfanew + sizeof(UINT32) + sizeof (EFI_IMAGE_FILE_HEADER) + PeHdr->FileHeader.SizeOfOptionalHeader);\r
+                for (Index2 = 0; Index2 < PeHdr->FileHeader.NumberOfSections; Index2++, SectionHeader++) {\r
+                  if (RuntimeFunction->UnwindInfoAddress > SectionHeader->VirtualAddress && RuntimeFunction->UnwindInfoAddress < (SectionHeader->VirtualAddress + SectionHeader->SizeOfRawData)) {\r
+                    UnwindInfo = (UNWIND_INFO *)(FileBuffer + SectionHeader->PointerToRawData + (RuntimeFunction->UnwindInfoAddress - SectionHeader->VirtualAddress));\r
+                    if (UnwindInfo->Version == 1) {\r
+                      memset (UnwindInfo + 1, 0, UnwindInfo->CountOfUnwindCodes * sizeof (UINT16));\r
+                      memset (UnwindInfo, 0, sizeof (UNWIND_INFO));\r
+                    }\r
+                  }\r
+                }\r
+                memset (RuntimeFunction, 0, sizeof (RUNTIME_FUNCTION));\r
+              }\r
+            }\r
+          }\r
+          Optional64->DataDirectory[3].Size = 0;\r
+          Optional64->DataDirectory[3].VirtualAddress = 0;\r
+        }\r
+      }\r
+    }\r
+\r
+    //\r
+    // Strip zero padding at the end of the .reloc section \r
+    //\r
+    if (Optional64->NumberOfRvaAndSizes >= 6) {\r
+      if (Optional64->DataDirectory[5].Size != 0) {\r
+        SectionHeader = (EFI_IMAGE_SECTION_HEADER *)(FileBuffer + DosHdr->e_lfanew + sizeof(UINT32) + sizeof (EFI_IMAGE_FILE_HEADER) + PeHdr->FileHeader.SizeOfOptionalHeader);\r
+        for (Index = 0; Index < PeHdr->FileHeader.NumberOfSections; Index++, SectionHeader++) {\r
+          //\r
+          // Look for the Section Header that starts as the same virtual address as the Base Relocation Data Directory\r
+          //\r
+          if (SectionHeader->VirtualAddress == Optional64->DataDirectory[5].VirtualAddress) {\r
+            SectionHeader->Misc.VirtualSize = Optional64->DataDirectory[5].Size;\r
+            AllignedRelocSize = (Optional64->DataDirectory[5].Size + Optional64->FileAlignment - 1) & (~(Optional64->FileAlignment - 1));\r
+            //\r
+            // Check to see if there is zero padding at the end of the base relocations\r
+            //\r
+            if (AllignedRelocSize < SectionHeader->SizeOfRawData) {\r
+              //\r
+              // Check to see if the base relocations are at the end of the file\r
+              //\r
+              if (SectionHeader->PointerToRawData + SectionHeader->SizeOfRawData == Optional64->SizeOfImage) {\r
+                //\r
+                // All the required conditions are met to strip the zero padding of the end of the base relocations section\r
+                //\r
+                Optional64->SizeOfImage -= (SectionHeader->SizeOfRawData - AllignedRelocSize);\r
+                Optional64->SizeOfInitializedData -= (SectionHeader->SizeOfRawData - AllignedRelocSize);\r
+                SectionHeader->SizeOfRawData = AllignedRelocSize;\r
+                FileLength = Optional64->SizeOfImage;\r
+              }\r
+            }\r
+          }\r
+        }\r
+      }\r
+    }\r
+  }\r
+\r
+  FWriteFile (fpOut, FileBuffer, FileLength);\r
+\r
+  //\r
+  // Done\r
+  //\r
+  fclose (fpIn);\r
+  fclose (fpOut);\r
+  //\r
+  // printf ("Created %s\n", OutImageName);\r
+  //\r
+  return STATUS_SUCCESS;\r
+}\r
diff --git a/Tools/CodeTools/Source/GenAcpiTable/GenAcpiTable.c b/Tools/CodeTools/Source/GenAcpiTable/GenAcpiTable.c
new file mode 100644 (file)
index 0000000..7a413ea
--- /dev/null
@@ -0,0 +1,544 @@
+/*++\r
+\r
+Copyright (c)  2004-2006 Intel Corporation. All rights reserved\r
+This program and the accompanying materials are licensed and made available \r
+under the terms and conditions of the BSD License which accompanies this \r
+distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+Module Name:\r
+\r
+  GenAcpiTable.c\r
+  \r
+Abstract:\r
+\r
+  A utility that extracts the .DATA section from a PE/COFF image.\r
+\r
+--*/\r
+\r
+#include <stdio.h>\r
+#include <string.h>\r
+#include <stdlib.h>\r
+\r
+#include <Common/UefiBaseTypes.h>\r
+#include <Common/EfiImage.h> // for PE32 structure definitions\r
+\r
+#include "CommonLib.h"\r
+#include "EfiUtilityMsgs.h"\r
+\r
+//\r
+// Version of this utility\r
+//\r
+#define UTILITY_NAME    "GenAcpiTable"\r
+#define UTILITY_VERSION "v0.11"\r
+\r
+//\r
+// Define the max length of a filename\r
+//\r
+#define MAX_PATH                  256\r
+#define DEFAULT_OUTPUT_EXTENSION  ".acpi"\r
+\r
+//\r
+// Use this to track our command-line options and globals\r
+//\r
+struct {\r
+  INT8  OutFileName[MAX_PATH];\r
+  INT8  InFileName[MAX_PATH];\r
+} mOptions;\r
+\r
+//\r
+// Use these to convert from machine type value to a named type\r
+//\r
+typedef struct {\r
+  UINT16  Value;\r
+  INT8    *Name;\r
+} STRING_LOOKUP;\r
+\r
+static STRING_LOOKUP  mMachineTypes[] = {\r
+  EFI_IMAGE_MACHINE_IA32,\r
+  "IA32",\r
+  EFI_IMAGE_MACHINE_IA64,\r
+  "IA64",\r
+  EFI_IMAGE_MACHINE_EBC,\r
+  "EBC",\r
+  0,\r
+  NULL\r
+};\r
+\r
+static STRING_LOOKUP  mSubsystemTypes[] = {\r
+  EFI_IMAGE_SUBSYSTEM_EFI_APPLICATION,\r
+  "EFI application",\r
+  EFI_IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER,\r
+  "EFI boot service driver",\r
+  EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER,\r
+  "EFI runtime driver",\r
+  0,\r
+  NULL\r
+};\r
+//\r
+//  Function prototypes\r
+//\r
+static\r
+void\r
+Usage (\r
+  VOID\r
+  );\r
+\r
+static\r
+STATUS\r
+ParseCommandLine (\r
+  int       Argc,\r
+  char      *Argv[]\r
+  );\r
+\r
+static\r
+STATUS\r
+CheckPE32File (\r
+  INT8      *FileName,\r
+  FILE      *Fptr,\r
+  UINT16    *MachineType,\r
+  UINT16    *SubSystem\r
+  );\r
+\r
+static\r
+STATUS\r
+ProcessFile (\r
+  INT8      *InFileName,\r
+  INT8      *OutFileName\r
+  );\r
+\r
+static\r
+void\r
+DumpImage (\r
+  INT8      *FileName\r
+  );\r
+\r
+main (\r
+  int   Argc,\r
+  char  *Argv[]\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+\r
+Arguments:\r
+\r
+  Argc            - standard C main() argument count\r
+\r
+  Argv            - standard C main() argument list\r
+\r
+Returns:\r
+\r
+  0             success\r
+  non-zero      otherwise\r
+\r
+--*/\r
+// GC_TODO:    ] - add argument and description to function comment\r
+{\r
+  UINT32  Status;\r
+\r
+  SetUtilityName (UTILITY_NAME);\r
+  //\r
+  // Parse the command line arguments\r
+  //\r
+  if (ParseCommandLine (Argc, Argv)) {\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Make sure we don't have the same filename for input and output files\r
+  //\r
+  if (stricmp (mOptions.OutFileName, mOptions.InFileName) == 0) {\r
+    Error (NULL, 0, 0, mOptions.OutFileName, "input and output file names must be different");\r
+    goto Finish;\r
+  }\r
+  //\r
+  // Process the file\r
+  //\r
+  ProcessFile (mOptions.InFileName, mOptions.OutFileName);\r
+Finish:\r
+  Status = GetUtilityStatus ();\r
+  return Status;\r
+}\r
+\r
+static\r
+STATUS\r
+ProcessFile (\r
+  INT8      *InFileName,\r
+  INT8      *OutFileName\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  Process a PE32 EFI file.\r
+\r
+Arguments:\r
+\r
+  InFileName - Name of the PE32 EFI file to process.\r
+  OutFileName - Name of the output file for the processed data.\r
+\r
+Returns:\r
+\r
+  0 - successful\r
+\r
+--*/\r
+{\r
+  STATUS                      Status;\r
+  UINTN                       Index;\r
+  FILE                        *InFptr;\r
+  FILE                        *OutFptr;\r
+  UINT16                      MachineType;\r
+  UINT16                      SubSystem;\r
+  UINT32                      PESigOffset;\r
+  EFI_IMAGE_FILE_HEADER       FileHeader;\r
+  EFI_IMAGE_OPTIONAL_HEADER32 OptionalHeader32;\r
+  EFI_IMAGE_OPTIONAL_HEADER64 OptionalHeader64;\r
+  EFI_IMAGE_SECTION_HEADER    SectionHeader;\r
+  UINT8                       *Buffer;\r
+  long                        SaveFilePosition;\r
+\r
+  InFptr  = NULL;\r
+  OutFptr = NULL;\r
+  Buffer  = NULL;\r
+  Status  = STATUS_ERROR;\r
+  //\r
+  // Try to open the input file\r
+  //\r
+  if ((InFptr = fopen (InFileName, "rb")) == NULL) {\r
+    Error (NULL, 0, 0, InFileName, "failed to open input file for reading");\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Double-check the file to make sure it's what we expect it to be\r
+  //\r
+  if (CheckPE32File (InFileName, InFptr, &MachineType, &SubSystem) != STATUS_SUCCESS) {\r
+    goto Finish;\r
+  }\r
+  //\r
+  // Per the PE/COFF specification, at offset 0x3C in the file is a 32-bit\r
+  // offset (from the start of the file) to the PE signature, which always\r
+  // follows the MSDOS stub. The PE signature is immediately followed by the\r
+  // COFF file header.\r
+  //\r
+  //\r
+  if (fseek (InFptr, 0x3C, SEEK_SET) != 0) {\r
+    Error (NULL, 0, 0, InFileName, "failed to seek to PE signature in file", NULL);\r
+    goto Finish;\r
+  }\r
+\r
+  if (fread (&PESigOffset, sizeof (PESigOffset), 1, InFptr) != 1) {\r
+    Error (NULL, 0, 0, InFileName, "failed to read PE signature offset from file");\r
+    goto Finish;\r
+  }\r
+\r
+  if (fseek (InFptr, PESigOffset + 4, SEEK_SET) != 0) {\r
+    Error (NULL, 0, 0, InFileName, "failed to seek to PE signature");\r
+    goto Finish;\r
+  }\r
+  //\r
+  // We should now be at the COFF file header. Read it in and verify it's\r
+  // of an image type we support.\r
+  //\r
+  if (fread (&FileHeader, sizeof (EFI_IMAGE_FILE_HEADER), 1, InFptr) != 1) {\r
+    Error (NULL, 0, 0, InFileName, "failed to read file header from image");\r
+    goto Finish;\r
+  }\r
+\r
+  if ((FileHeader.Machine != EFI_IMAGE_MACHINE_IA32) && (FileHeader.Machine != EFI_IMAGE_MACHINE_IA64) && (FileHeader.Machine != EFI_IMAGE_MACHINE_X64)) {\r
+    Error (NULL, 0, 0, InFileName, "image is of an unsupported machine type 0x%X", (UINT32) FileHeader.Machine);\r
+    goto Finish;\r
+  }\r
+  //\r
+  // Read in the optional header. Assume PE32, and if not, then re-read as PE32+\r
+  //\r
+  SaveFilePosition = ftell (InFptr);\r
+  if (fread (&OptionalHeader32, sizeof (EFI_IMAGE_OPTIONAL_HEADER32), 1, InFptr) != 1) {\r
+    Error (NULL, 0, 0, InFileName, "failed to read optional header from input file");\r
+    goto Finish;\r
+  }\r
+\r
+  if (OptionalHeader32.Magic == EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC) {\r
+    if (fseek (InFptr, SaveFilePosition, SEEK_SET) != 0) {\r
+      Error (NULL, 0, 0, InFileName, "failed to seek to .data section");\r
+      goto Finish;\r
+    }\r
+\r
+    if (fread (&OptionalHeader64, sizeof (EFI_IMAGE_OPTIONAL_HEADER64), 1, InFptr) != 1) {\r
+      Error (NULL, 0, 0, InFileName, "failed to read optional header from input file");\r
+      goto Finish;\r
+    }\r
+  }\r
+  //\r
+  // Search for the ".data" section\r
+  //\r
+  for (Index = 0; Index < FileHeader.NumberOfSections; Index++) {\r
+    if (fread (&SectionHeader, sizeof (EFI_IMAGE_SECTION_HEADER), 1, InFptr) != 1) {\r
+      Error (NULL, 0, 0, InFileName, "failed to read optional header from input file");\r
+      goto Finish;\r
+    }\r
+\r
+    if (strcmp (SectionHeader.Name, ".data") == 0) {\r
+      if (fseek (InFptr, SectionHeader.PointerToRawData, SEEK_SET) != 0) {\r
+        Error (NULL, 0, 0, InFileName, "failed to seek to .data section");\r
+        goto Finish;\r
+      }\r
+\r
+      Buffer = (UINT8 *) malloc (SectionHeader.Misc.VirtualSize);\r
+      if (Buffer == NULL) {\r
+        Status = EFI_OUT_OF_RESOURCES;\r
+        goto Finish;\r
+      }\r
+      if (fread (Buffer, SectionHeader.Misc.VirtualSize, 1, InFptr) != 1) {\r
+        Error (NULL, 0, 0, InFileName, "failed to .data section");\r
+        goto Finish;\r
+      }\r
+      //\r
+      // Now open our output file\r
+      //\r
+      if ((OutFptr = fopen (OutFileName, "wb")) == NULL) {\r
+        Error (NULL, 0, 0, OutFileName, "failed to open output file for writing");\r
+        goto Finish;\r
+      }\r
+\r
+      if (fwrite (Buffer, SectionHeader.Misc.VirtualSize, 1, OutFptr) != 1) {\r
+        Error (NULL, 0, 0, OutFileName, "failed to write .data section");\r
+        goto Finish;\r
+      }\r
+\r
+      Status = STATUS_SUCCESS;\r
+      goto Finish;\r
+    }\r
+  }\r
+\r
+  Status = STATUS_ERROR;\r
+\r
+Finish:\r
+  if (InFptr != NULL) {\r
+    fclose (InFptr);\r
+  }\r
+  //\r
+  // Close the output file. If there was an error, delete the output file so\r
+  // that a subsequent build will rebuild it.\r
+  //\r
+  if (OutFptr != NULL) {\r
+    fclose (OutFptr);\r
+    if (GetUtilityStatus () == STATUS_ERROR) {\r
+      remove (OutFileName);\r
+    }\r
+  }\r
+\r
+  //\r
+  // Free up our buffer\r
+  //\r
+  if (Buffer != NULL) {\r
+    free (Buffer);\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
+static\r
+STATUS\r
+CheckPE32File (\r
+  INT8      *FileName,\r
+  FILE      *Fptr,\r
+  UINT16    *MachineType,\r
+  UINT16    *SubSystem\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  FileName    - GC_TODO: add argument description\r
+  Fptr        - GC_TODO: add argument description\r
+  MachineType - GC_TODO: add argument description\r
+  SubSystem   - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+{\r
+  /*++\r
+\r
+Routine Description:\r
+  \r
+  Given a file pointer to a supposed PE32 image file, verify that it is indeed a\r
+  PE32 image file, and then return the machine type in the supplied pointer.\r
+\r
+Arguments:\r
+\r
+  Fptr          File pointer to the already-opened PE32 file\r
+  MachineType   Location to stuff the machine type of the PE32 file. This is needed\r
+                because the image may be Itanium-based, IA32, or EBC.\r
+\r
+Returns:\r
+\r
+  0             success\r
+  non-zero      otherwise\r
+\r
+--*/\r
+  EFI_IMAGE_DOS_HEADER      DosHeader;\r
+  EFI_IMAGE_FILE_HEADER     FileHdr;\r
+  EFI_IMAGE_OPTIONAL_HEADER OptionalHdr;\r
+  UINT32                    PESig;\r
+  STATUS                    Status;\r
+\r
+  Status = STATUS_ERROR;\r
+  //\r
+  // Position to the start of the file\r
+  //\r
+  fseek (Fptr, 0, SEEK_SET);\r
+  //\r
+  // Read the DOS header\r
+  //\r
+  if (fread (&DosHeader, sizeof (DosHeader), 1, Fptr) != 1) {\r
+    Error (NULL, 0, 0, FileName, "failed to read the DOS stub from the input file");\r
+    goto Finish;\r
+  }\r
+  //\r
+  // Check the magic number (0x5A4D)\r
+  //\r
+  if (DosHeader.e_magic != EFI_IMAGE_DOS_SIGNATURE) {\r
+    Error (NULL, 0, 0, FileName, "input file does not appear to be a PE32 image (magic number)");\r
+    goto Finish;\r
+  }\r
+  //\r
+  // Position into the file and check the PE signature\r
+  //\r
+  fseek (Fptr, (long) DosHeader.e_lfanew, SEEK_SET);\r
+  if (fread (&PESig, sizeof (PESig), 1, Fptr) != 1) {\r
+    Error (NULL, 0, 0, FileName, "failed to read PE signature bytes");\r
+    goto Finish;\r
+  }\r
+  //\r
+  // Check the PE signature in the header "PE\0\0"\r
+  //\r
+  if (PESig != EFI_IMAGE_NT_SIGNATURE) {\r
+    Error (NULL, 0, 0, FileName, "file does not appear to be a PE32 image (signature)");\r
+    goto Finish;\r
+  }\r
+  //\r
+  // Read the file header\r
+  //\r
+  if (fread (&FileHdr, sizeof (FileHdr), 1, Fptr) != 1) {\r
+    Error (NULL, 0, 0, FileName, "failed to read PE file header from input file");\r
+    goto Finish;\r
+  }\r
+  //\r
+  // Read the optional header so we can get the subsystem\r
+  //\r
+  if (fread (&OptionalHdr, sizeof (OptionalHdr), 1, Fptr) != 1) {\r
+    Error (NULL, 0, 0, FileName, "failed to read COFF optional header from input file");\r
+    goto Finish;\r
+  }\r
+\r
+  *SubSystem = OptionalHdr.Subsystem;\r
+  //\r
+  // Good to go\r
+  //\r
+  Status = STATUS_SUCCESS;\r
+Finish:\r
+  fseek (Fptr, 0, SEEK_SET);\r
+  return Status;\r
+}\r
+\r
+static\r
+int\r
+ParseCommandLine (\r
+  int         Argc,\r
+  char        *Argv[]\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  Given the Argc/Argv program arguments, and a pointer to an options structure,\r
+  parse the command-line options and check their validity.\r
+\r
+\r
+Arguments:\r
+\r
+  Argc            - standard C main() argument count\r
+  Argv            - standard C main() argument list\r
+\r
+Returns:\r
+\r
+  STATUS_SUCCESS    success\r
+  non-zero          otherwise\r
+\r
+--*/\r
+// GC_TODO:    ] - add argument and description to function comment\r
+{\r
+  //\r
+  // Clear out the options\r
+  //\r
+  memset ((char *) &mOptions, 0, sizeof (mOptions));\r
+  //\r
+  // Skip over the program name\r
+  //\r
+  Argc--;\r
+  Argv++;\r
+\r
+  if (Argc != 2) {\r
+    Usage ();\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  strcpy (mOptions.InFileName, Argv[0]);\r
+  //\r
+  // Next argument\r
+  //\r
+  Argv++;\r
+  Argc--;\r
+\r
+  strcpy (mOptions.OutFileName, Argv[0]);\r
+\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+void\r
+Usage (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  Print usage information for this utility.\r
+\r
+Arguments:\r
+\r
+  None.\r
+\r
+Returns:\r
+\r
+  Nothing.\r
+\r
+--*/\r
+{\r
+  int               Index;\r
+  static const char *Msg[] = {\r
+    UTILITY_NAME " version "UTILITY_VERSION " - Generate ACPI Table image utility",\r
+    "  Generate an ACPI Table image from an EFI PE32 image",\r
+    "  Usage: "UTILITY_NAME " InFileName OutFileName",\r
+    "    where:",\r
+    "      InFileName     - name of the input PE32 file",\r
+    "      OutFileName    - to write output to OutFileName rather than InFileName"DEFAULT_OUTPUT_EXTENSION,\r
+    "",\r
+    NULL\r
+  };\r
+  for (Index = 0; Msg[Index] != NULL; Index++) {\r
+    fprintf (stdout, "%s\n", Msg[Index]);\r
+  }\r
+}\r
diff --git a/Tools/CodeTools/Source/GenAcpiTable/build.xml b/Tools/CodeTools/Source/GenAcpiTable/build.xml
new file mode 100644 (file)
index 0000000..8c8c5eb
--- /dev/null
@@ -0,0 +1,71 @@
+<?xml version="1.0" ?>\r
+<!--\r
+Copyright (c) 2006, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+-->\r
+<project default="GenTool" basedir=".">\r
+<!--\r
+    EDK GenAcpiTable Tool\r
+  Copyright (c) 2006, Intel Corporation\r
+-->\r
+  <property name="ToolName" value="GenAcpiTable"/>\r
+  <property name="FileSet" value="*.c"/>\r
+\r
+  <taskdef resource="cpptasks.tasks"/>\r
+  <typedef resource="cpptasks.types"/>\r
+  <taskdef resource="net/sf/antcontrib/antlib.xml"/>\r
+\r
+  <property name="LINK_OUTPUT_TYPE" value="static"/>\r
+  <property name="BUILD_DIR" value="${PACKAGE_DIR}/${ToolName}/tmp"/>\r
+\r
+  <target name="GenTool" depends="init, Tool">\r
+    <echo message="The EDK Tool: ${ToolName} build has completed!"/>\r
+  </target>\r
+\r
+  <target name="init">\r
+    <echo message="Building the EDK Tool: ${ToolName}"/>\r
+    <mkdir dir="${BUILD_DIR}"/>\r
+  </target>\r
+\r
+  <target name="Tool" depends="init">\r
+    <cc name="${ToolChain}" objdir="${BUILD_DIR}" \r
+        outfile="${BIN_DIR}/${ToolName}"\r
+        outtype="executable"\r
+        optimize="speed" \r
+        debug="true">\r
+      <compilerarg value="${ExtraArgus}" if="ExtraArgus" />\r
+\r
+      <fileset dir="${basedir}/${ToolName}" \r
+        includes="${FileSet}" \r
+        defaultexcludes="TRUE" \r
+        excludes="*.xml *.inf"/>\r
+\r
+      <includepath path="${PACKAGE_DIR}/Include"/>\r
+      <includepath path="${PACKAGE_DIR}/Include/Ia32"/>\r
+      <includepath path="${PACKAGE_DIR}/Common"/>\r
+      <libset dir="${LIB_DIR}" libs="CommonTools"/>\r
+    </cc>\r
+  </target>\r
+\r
+  <target name="clean">\r
+    <echo message="Removing Intermediate Files Only"/>  \r
+    <delete>\r
+      <fileset dir="${BUILD_DIR}" includes="*.obj"/>\r
+    </delete>\r
+  </target>\r
+\r
+  <target name="cleanall">\r
+    <echo message="Removing Object Files and the Executable: ${ToolName}${ext_exe}"/>  \r
+    <delete failonerror="false" quiet="true" includeEmptyDirs="true">\r
+      <fileset dir="${BUILD_DIR}"/>\r
+      <fileset file="${BIN_DIR}/${ToolName}${ext_exe}"/>\r
+    </delete>\r
+  </target>\r
+\r
+</project>\r
diff --git a/Tools/CodeTools/Source/GenCRC32Section/GenCRC32Section.c b/Tools/CodeTools/Source/GenCRC32Section/GenCRC32Section.c
new file mode 100644 (file)
index 0000000..b99cf2f
--- /dev/null
@@ -0,0 +1,286 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+    GenCRC32Section.c\r
+\r
+Abstract:\r
+\r
+  This file contains functions required to generate a Firmware File System \r
+  file. The code is compliant with the Tiano C Coding standards.\r
+\r
+--*/\r
+\r
+#include "GenCRC32Section.h"\r
+\r
+#define TOOLVERSION   "0.2"\r
+\r
+#define UTILITY_NAME  "GenCrc32Section"\r
+\r
+EFI_GUID  gEfiCrc32SectionGuid = EFI_CRC32_GUIDED_SECTION_EXTRACTION_PROTOCOL_GUID;\r
+\r
+EFI_STATUS\r
+SignSectionWithCrc32 (\r
+  IN OUT UINT8  *FileBuffer,\r
+  IN OUT UINT32 *BufferSize,\r
+  IN UINT32     DataSize\r
+  )\r
+/*++\r
+        \r
+Routine Description:\r
+           \r
+  Signs the section with CRC32 and add GUIDed section header for the \r
+  signed data. data stays in same location (overwrites source data).\r
+            \r
+Arguments:\r
+               \r
+  FileBuffer  - Buffer containing data to sign\r
+                \r
+  BufferSize  - On input, the size of FileBuffer. On output, the size of \r
+                actual section data (including added section header).              \r
+\r
+  DataSize    - Length of data to Sign\r
+\r
+  Key         - Key to use when signing. Currently only CRC32 is supported.\r
+                                       \r
+Returns:\r
+                       \r
+  EFI_SUCCESS           - Successful\r
+  EFI_OUT_OF_RESOURCES  - Not enough resource to complete the operation.\r
+                        \r
+--*/\r
+{\r
+\r
+  UINT32                Crc32Checksum;\r
+  EFI_STATUS            Status;\r
+  UINT32                TotalSize;\r
+  CRC32_SECTION_HEADER  Crc32Header;\r
+  UINT8                 *SwapBuffer;\r
+\r
+  Crc32Checksum = 0;\r
+  SwapBuffer    = NULL;\r
+\r
+  if (DataSize == 0) {\r
+    *BufferSize = 0;\r
+\r
+    return EFI_SUCCESS;\r
+  }\r
+\r
+  Status = CalculateCrc32 (FileBuffer, DataSize, &Crc32Checksum);\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  TotalSize = DataSize + CRC32_SECTION_HEADER_SIZE;\r
+  Crc32Header.GuidSectionHeader.CommonHeader.Type     = EFI_SECTION_GUID_DEFINED;\r
+  Crc32Header.GuidSectionHeader.CommonHeader.Size[0]  = (UINT8) (TotalSize & 0xff);\r
+  Crc32Header.GuidSectionHeader.CommonHeader.Size[1]  = (UINT8) ((TotalSize & 0xff00) >> 8);\r
+  Crc32Header.GuidSectionHeader.CommonHeader.Size[2]  = (UINT8) ((TotalSize & 0xff0000) >> 16);\r
+  memcpy (&(Crc32Header.GuidSectionHeader.SectionDefinitionGuid), &gEfiCrc32SectionGuid, sizeof (EFI_GUID));\r
+  Crc32Header.GuidSectionHeader.Attributes  = EFI_GUIDED_SECTION_AUTH_STATUS_VALID;\r
+  Crc32Header.GuidSectionHeader.DataOffset  = CRC32_SECTION_HEADER_SIZE;\r
+  Crc32Header.CRC32Checksum                 = Crc32Checksum;\r
+\r
+  SwapBuffer = (UINT8 *) malloc (DataSize);\r
+  if (SwapBuffer == NULL) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+\r
+  memcpy (SwapBuffer, FileBuffer, DataSize);\r
+  memcpy (FileBuffer, &Crc32Header, CRC32_SECTION_HEADER_SIZE);\r
+  memcpy (FileBuffer + CRC32_SECTION_HEADER_SIZE, SwapBuffer, DataSize);\r
+\r
+  //\r
+  // Make sure section ends on a DWORD boundary\r
+  //\r
+  while ((TotalSize & 0x03) != 0) {\r
+    FileBuffer[TotalSize] = 0;\r
+    TotalSize++;\r
+  }\r
+\r
+  *BufferSize = TotalSize;\r
+\r
+  if (SwapBuffer != NULL) {\r
+    free (SwapBuffer);\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+VOID\r
+PrintUsage (\r
+  VOID\r
+  )\r
+{\r
+  printf ("Usage:\n");\r
+  printf (UTILITY_NAME " -i \"inputfile1\" \"inputfile2\" -o \"outputfile\" \n");\r
+  printf ("   -i \"inputfile\":\n ");\r
+  printf ("       specifies the input files that would be signed to CRC32 Guided section.\n");\r
+  printf ("   -o \"outputfile\":\n");\r
+  printf ("       specifies the output file that is a CRC32 Guided section.\n");\r
+}\r
+\r
+INT32\r
+ReadFilesContentsIntoBuffer (\r
+  IN      CHAR8   *argv[],\r
+  IN      INT32   Start,\r
+  IN OUT  UINT8   **FileBuffer,\r
+  IN OUT  UINT32  *BufferSize,\r
+  OUT     UINT32  *ContentSize,\r
+  IN      INT32   MaximumArguments\r
+  )\r
+{\r
+  INT32   Index;\r
+  CHAR8   *FileName;\r
+  FILE    *InputFile;\r
+  UINT8   Temp;\r
+  UINT32  Size;\r
+\r
+  FileName  = NULL;\r
+  InputFile = NULL;\r
+  Size      = 0;\r
+  Index     = 0;\r
+\r
+  //\r
+  // read all input files into one file buffer\r
+  //\r
+  while (argv[Start + Index][0] != '-') {\r
+\r
+    FileName  = argv[Start + Index];\r
+    InputFile = fopen (FileName, "rb");\r
+    if (InputFile == NULL) {\r
+      Error (NULL, 0, 0, FileName, "failed to open input binary file");\r
+      return -1;\r
+    }\r
+\r
+    fread (&Temp, sizeof (UINT8), 1, InputFile);\r
+    while (!feof (InputFile)) {\r
+      (*FileBuffer)[Size++] = Temp;\r
+      fread (&Temp, sizeof (UINT8), 1, InputFile);\r
+    }\r
+\r
+    fclose (InputFile);\r
+    InputFile = NULL;\r
+\r
+    //\r
+    // Make sure section ends on a DWORD boundary\r
+    //\r
+    while ((Size & 0x03) != 0) {\r
+      (*FileBuffer)[Size] = 0;\r
+      Size++;\r
+    }\r
+\r
+    Index++;\r
+    if (Index == MaximumArguments) {\r
+      break;\r
+    }\r
+  }\r
+\r
+  *ContentSize = Size;\r
+  return Index;\r
+}\r
+\r
+int\r
+main (\r
+  INT32 argc,\r
+  CHAR8 *argv[]\r
+  )\r
+{\r
+  FILE        *OutputFile;\r
+  UINT8       *FileBuffer;\r
+  UINT32      BufferSize;\r
+  EFI_STATUS  Status;\r
+  UINT32      ContentSize;\r
+  CHAR8       *OutputFileName;\r
+  INT32       ReturnValue;\r
+  INT32       Index;\r
+\r
+  OutputFile      = NULL;\r
+  FileBuffer      = NULL;\r
+  ContentSize     = 0;\r
+  OutputFileName  = NULL;\r
+\r
+  SetUtilityName (UTILITY_NAME);\r
+\r
+  if (argc == 1) {\r
+    PrintUsage ();\r
+    return -1;\r
+  }\r
+\r
+  BufferSize  = 1024 * 1024 * 16;\r
+  FileBuffer  = (UINT8 *) malloc (BufferSize * sizeof (UINT8));\r
+  if (FileBuffer == NULL) {\r
+    Error (NULL, 0, 0, "memory allocation failed", NULL);\r
+    return -1;\r
+  }\r
+\r
+  ZeroMem (FileBuffer, BufferSize);\r
+\r
+  for (Index = 0; Index < argc; Index++) {\r
+    if (strcmpi (argv[Index], "-i") == 0) {\r
+      ReturnValue = ReadFilesContentsIntoBuffer (\r
+                      argv,\r
+                      (Index + 1),\r
+                      &FileBuffer,\r
+                      &BufferSize,\r
+                      &ContentSize,\r
+                      (argc - (Index + 1))\r
+                      );\r
+      if (ReturnValue == -1) {\r
+        Error (NULL, 0, 0, "failed to read file contents", NULL);\r
+        return -1;\r
+      }\r
+\r
+      Index += ReturnValue;\r
+    }\r
+\r
+    if (strcmpi (argv[Index], "-o") == 0) {\r
+      OutputFileName = argv[Index + 1];\r
+    }\r
+  }\r
+\r
+  OutputFile = fopen (OutputFileName, "wb");\r
+  if (OutputFile == NULL) {\r
+    Error (NULL, 0, 0, OutputFileName, "failed to open output binary file");\r
+    free (FileBuffer);\r
+    return -1;\r
+  }\r
+\r
+  /*  \r
+  //\r
+  // make sure section ends on a DWORD boundary ??\r
+  //\r
+  while ( (Size & 0x03) != 0 ) {\r
+    FileBuffer[Size] = 0;\r
+    Size ++;\r
+  }\r
+*/\r
+  Status = SignSectionWithCrc32 (FileBuffer, &BufferSize, ContentSize);\r
+  if (EFI_ERROR (Status)) {\r
+    Error (NULL, 0, 0, "failed to sign section", NULL);\r
+    free (FileBuffer);\r
+    fclose (OutputFile);\r
+    return -1;\r
+  }\r
+\r
+  ContentSize = fwrite (FileBuffer, sizeof (UINT8), BufferSize, OutputFile);\r
+  if (ContentSize != BufferSize) {\r
+    Error (NULL, 0, 0, "failed to write output buffer", NULL);\r
+    ReturnValue = -1;\r
+  } else {\r
+    ReturnValue = 0;\r
+  }\r
+\r
+  free (FileBuffer);\r
+  fclose (OutputFile);\r
+  return ReturnValue;\r
+}\r
diff --git a/Tools/CodeTools/Source/GenCRC32Section/GenCRC32Section.h b/Tools/CodeTools/Source/GenCRC32Section/GenCRC32Section.h
new file mode 100644 (file)
index 0000000..1cf976b
--- /dev/null
@@ -0,0 +1,63 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  GenCRC32Section.h \r
+\r
+Abstract:\r
+\r
+  Header file for GenFfsFile. Mainly defines the header of section\r
+  header for CRC32 GUID defined sections. Share with GenSection.c\r
+\r
+--*/\r
+\r
+//\r
+// External Files Referenced\r
+//\r
+\r
+/* Standard Headers */\r
+#include <stdio.h>\r
+#include <stdlib.h>\r
+#include <string.h>\r
+#include <assert.h>\r
+\r
+/* MDE Headers */\r
+#include <Common/UefiBaseTypes.h>\r
+#include <Common/EfiImage.h>\r
+#include <Common/FirmwareVolumeImageFormat.h>\r
+#include <Common/FirmwareFileSystem.h>\r
+#include <Common/FirmwareVolumeHeader.h>\r
+#include <Protocol/GuidedSectionExtraction.h>\r
+\r
+/* Tool Headers */\r
+#include "CommonLib.h"\r
+#include "Crc32.h"\r
+#include "EfiCompress.h"\r
+#include "EfiUtilityMsgs.h"\r
+#include "ParseInf.h"\r
+\r
+//\r
+// Module Coded to Tiano Coding Conventions\r
+//\r
+#ifndef _EFI_GEN_CRC32_SECTION_H\r
+#define _EFI_GEN_CRC32_SECTION_H\r
+\r
+\r
+typedef struct {\r
+  EFI_GUID_DEFINED_SECTION  GuidSectionHeader;\r
+  UINT32                    CRC32Checksum;\r
+} CRC32_SECTION_HEADER;\r
+\r
+#define EFI_SECTION_CRC32_GUID_DEFINED  0\r
+#define CRC32_SECTION_HEADER_SIZE       (sizeof (CRC32_SECTION_HEADER))\r
+\r
+#endif\r
diff --git a/Tools/CodeTools/Source/GenCRC32Section/build.xml b/Tools/CodeTools/Source/GenCRC32Section/build.xml
new file mode 100644 (file)
index 0000000..bbb0f71
--- /dev/null
@@ -0,0 +1,69 @@
+<?xml version="1.0" ?>\r
+<!--\r
+Copyright (c) 2006, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+-->\r
+<project default="GenTool" basedir=".">\r
+<!--\r
+    EDK GenCRC32Section Tool\r
+  Copyright (c) 2006, Intel Corporation\r
+-->\r
+  <property name="ToolName" value="GenCRC32Section"/>\r
+  <property name="FileSet" value="GenCRC32Section.c GenCRC32Section.h"/>\r
+\r
+  <taskdef resource="cpptasks.tasks"/>\r
+  <typedef resource="cpptasks.types"/>\r
+  <taskdef resource="net/sf/antcontrib/antlib.xml"/>\r
+\r
+  <property name="LINK_OUTPUT_TYPE" value="static"/>\r
+  <property name="BUILD_DIR" value="${PACKAGE_DIR}/${ToolName}/tmp"/>\r
+\r
+  <target name="GenTool" depends="init, Tool">\r
+    <echo message="The EDK Tool: ${ToolName} build has completed!"/>\r
+  </target>\r
+\r
+  <target name="init">\r
+    <echo message="Building the EDK Tool: ${ToolName}"/>\r
+    <mkdir dir="${BUILD_DIR}"/>\r
+  </target>\r
+\r
+  <target name="Tool" depends="init">\r
+    <cc name="${ToolChain}" objdir="${BUILD_DIR}" \r
+        outfile="${BIN_DIR}/${ToolName}"\r
+        outtype="executable"\r
+        debug="true"\r
+        optimize="speed">\r
+\r
+      <fileset dir="${basedir}/${ToolName}" \r
+        includes="${FileSet}"/>\r
+\r
+      <includepath path="${PACKAGE_DIR}/Include"/>\r
+      <includepath path="${PACKAGE_DIR}/Include/${HostArch}"/>\r
+      <includepath path="${PACKAGE_DIR}/Common"/>\r
+      <libset dir="${LIB_DIR}" libs="CommonTools"/>\r
+\r
+    </cc>\r
+  </target>\r
+\r
+  <target name="clean">\r
+    <echo message="Removing Intermediate Files Only"/>  \r
+    <delete>\r
+      <fileset dir="${BUILD_DIR}" includes="*.obj"/>\r
+    </delete>\r
+  </target>\r
+\r
+  <target name="cleanall">\r
+    <echo message="Removing Object Files and the Executable: ${ToolName}${ext_exe}"/>  \r
+    <delete failonerror="false" quiet="true" includeEmptyDirs="true">\r
+      <fileset dir="${BUILD_DIR}"/>\r
+      <fileset file="${BIN_DIR}/${ToolName}${ext_exe}"/>\r
+    </delete>\r
+  </target>\r
+\r
+</project>\r
diff --git a/Tools/CodeTools/Source/GenCapsuleHdr/CreateGuid.c b/Tools/CodeTools/Source/GenCapsuleHdr/CreateGuid.c
new file mode 100644 (file)
index 0000000..2a984fa
--- /dev/null
@@ -0,0 +1,50 @@
+/*++\r
+\r
+Copyright (c)  2004-2006 Intel Corporation. All rights reserved\r
+This program and the accompanying materials are licensed and made available \r
+under the terms and conditions of the BSD License which accompanies this \r
+distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+\r
+Module Name:\r
+\r
+  CreateGuid.c  \r
+\r
+Abstract:\r
+\r
+  Library routine to create a GUID\r
+\r
+--*/\r
+\r
+#include <windows.h>\r
+#include <stdio.h>\r
+#include <string.h>\r
+#include <stdlib.h>\r
+#include <ctype.h>\r
+\r
+void\r
+CreateGuid (\r
+  GUID *Guid\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Guid  - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+{\r
+  CoCreateGuid (Guid);\r
+}\r
diff --git a/Tools/CodeTools/Source/GenCapsuleHdr/GenCapsuleHdr.c b/Tools/CodeTools/Source/GenCapsuleHdr/GenCapsuleHdr.c
new file mode 100644 (file)
index 0000000..d1f55b9
--- /dev/null
@@ -0,0 +1,2674 @@
+/*++\r
+\r
+Copyright (c)  2002-2006 Intel Corporation. All rights reserved\r
+This program and the accompanying materials are licensed and made available \r
+under the terms and conditions of the BSD License which accompanies this \r
+distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+\r
+Module Name:\r
+\r
+  GenCapsuleHdr.c  \r
+\r
+Abstract:\r
+\r
+  Generate a capsule header for a file, and optionally prepend the\r
+  header to a file or list of files.\r
+\r
+--*/\r
+\r
+#define _UNICODE\r
+\r
+#include <stdio.h>\r
+#include <string.h>\r
+#include <stdlib.h>\r
+#include <ctype.h>\r
+\r
+#include <Common/UefiBaseTypes.h>\r
+#include <Common/MultiPhase.h>\r
+#include <Common/Capsule.h>\r
+#include <Common/FirmwareVolumeImageFormat.h>\r
+#include <Common/FirmwareVolumeHeader.h>\r
+#include <Common/FirmwareFileSystem.h>  // for FV header GUID\r
+#include <Guid/Capsule.h>\r
+#include <Guid/FirmwareFileSystem.h>  // for FV header GUID\r
+\r
+#include "CommonLib.h"\r
+#include "EfiUtilityMsgs.h"\r
+\r
+#define MAX_PATH                  256\r
+#define PROGRAM_NAME              "GenCapsuleHdr"\r
+\r
+#define UNICODE_BACKSLASH         L'\\'\r
+#define UNICODE_FILE_START        0xFEFF\r
+#define UNICODE_CR                0x000D\r
+#define UNICODE_LF                0x000A\r
+#define UNICODE_NULL              0x0000\r
+#define UNICODE_SPACE             L' '\r
+#define UNICODE_SLASH             L'/'\r
+#define UNICODE_DOUBLE_QUOTE      L'"'\r
+#define UNICODE_A                 L'A'\r
+#define UNICODE_F                 L'F'\r
+#define UNICODE_Z                 L'Z'\r
+#define UNICODE_a                 L'a'\r
+#define UNICODE_f                 L'f'\r
+#define UNICODE_z                 L'z'\r
+#define UNICODE_0                 L'0'\r
+#define UNICODE_9                 L'9'\r
+#define UNICODE_TAB               L'\t'\r
+\r
+#define OEM_HEADER_STRING         L"OemHeader"\r
+#define AUTHOR_INFO_STRING        L"AuthorInfo"\r
+#define REVISION_INFO_STRING      L"RevisionInfo"\r
+#define SHORT_DESCRIPTION_STRING  L"ShortDescription"\r
+#define LONG_DESCRIPTION_STRING   L"LongDescription"\r
+#define EQUAL_STRING              L"="\r
+#define OPEN_BRACE_STRING         L"{"\r
+#define CLOSE_BRACE_STRING        L"}"\r
+#define GUID_STRING               L"GUID"\r
+#define DATA_STRING               L"DATA"\r
+\r
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
+#define UEFI_CAPSULE_HEADER_NO_FALAGS      0\r
+#define UEFI_CAPSULE_HEADER_RESET_FALAGS   CAPSULE_FLAGS_PERSIST_ACROSS_RESET\r
+#define UEFI_CAPSULE_HEADER_ALL_FALAGS     (CAPSULE_FLAGS_PERSIST_ACROSS_RESET | CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE)\r
+#endif\r
+\r
+typedef wchar_t WCHAR;\r
+\r
+typedef struct _FILE_LIST {\r
+  struct _FILE_LIST *Next;\r
+  INT8              FileName[MAX_PATH];\r
+} FILE_LIST;\r
+\r
+typedef struct _SIZE_LIST {\r
+  struct _SIZE_LIST *Next;\r
+  UINT32            Size;\r
+} SIZE_LIST;\r
+\r
+typedef struct {\r
+  INT8    FileName[MAX_PATH];\r
+  WCHAR   *FileBuffer;\r
+  WCHAR   *FileBufferPtr;\r
+  UINT32  FileSize;\r
+  FILE    *FilePtr;\r
+  BOOLEAN EndOfFile;\r
+  UINT32  LineNum;\r
+} SOURCE_FILE;\r
+\r
+//\r
+// Here's all our globals.\r
+//\r
+static struct {\r
+  BOOLEAN   Dump;\r
+  BOOLEAN   Verbose;\r
+  BOOLEAN   JoinMode;\r
+  INT8      ScriptFileName[MAX_PATH];\r
+  INT8      OutputFileName[MAX_PATH];\r
+  FILE_LIST *FileList;\r
+  FILE      *OutFptr;\r
+  SIZE_LIST *SizeList;\r
+  SIZE_LIST *LastSize;\r
+  SIZE_LIST *CurrentSize;\r
+} mOptions;\r
+\r
+static EFI_GUID mEfiCapsuleHeaderGuid = EFI_CAPSULE_GUID;\r
+\r
+void\r
+CreateGuid (\r
+  EFI_GUID *Guid\r
+  );\r
+\r
+static\r
+STATUS\r
+ProcessArgs (\r
+  int   Argc,\r
+  char  *Argv[]\r
+  );\r
+\r
+static\r
+void\r
+SkipWhiteSpace (\r
+  SOURCE_FILE *SourceFile\r
+  );\r
+\r
+static\r
+STATUS\r
+GetHexValue (\r
+  SOURCE_FILE  *SourceFile,\r
+  UINT32       *Value,\r
+  UINT32       NumDigits\r
+  );\r
+\r
+static\r
+BOOLEAN\r
+GetSplitFileName (\r
+  INT8    *BaseFileName,\r
+  INT8    *NewFileName,\r
+  UINT32  SequenceNumber\r
+  );\r
+\r
+static\r
+STATUS\r
+SplitCapsule (\r
+  INT8 *CapsuleFileName\r
+  );\r
+\r
+static\r
+void\r
+Usage (\r
+  VOID\r
+  );\r
+\r
+static\r
+void\r
+DumpCapsule (\r
+  VOID\r
+  );\r
+\r
+static\r
+STATUS\r
+JoinCapsule (\r
+  VOID\r
+  );\r
+\r
+static\r
+STATUS\r
+DumpCapsuleHeaderStrings (\r
+  UINT8   *SectionName,\r
+  WCHAR   *Buffer\r
+  );\r
+\r
+static\r
+STATUS\r
+CheckFirmwareVolumeHeader (\r
+  INT8    *FileName,\r
+  INT8    *Buffer,\r
+  UINT32  BufferSize\r
+  );\r
+\r
+static\r
+BOOLEAN\r
+IsToken (\r
+  SOURCE_FILE *File,\r
+  WCHAR       *Token\r
+  );\r
+\r
+static\r
+BOOLEAN\r
+GetNumber (\r
+  INT8    *Str,\r
+  UINT32  *Value\r
+  );\r
+\r
+static\r
+STATUS\r
+ProcessScriptFile (\r
+  INT8                *ScriptFileName,\r
+  FILE                *OutFptr,\r
+  EFI_CAPSULE_HEADER  *CapsuleHeader\r
+  );\r
+\r
+static\r
+STATUS\r
+ParseCapsuleInfo (\r
+  SOURCE_FILE       *SourceFile,\r
+  FILE              *OutFptr,\r
+  WCHAR             *SectionName\r
+  );\r
+\r
+static\r
+STATUS\r
+CreateCapsule (\r
+  VOID\r
+  );\r
+\r
+static\r
+STATUS\r
+ParseOemInfo (\r
+  SOURCE_FILE       *SourceFile,\r
+  FILE              *OutFptr\r
+  );\r
+\r
+static\r
+BOOLEAN\r
+IsWhiteSpace (\r
+  WCHAR Char\r
+  );\r
+\r
+static\r
+BOOLEAN\r
+EndOfFile (\r
+  SOURCE_FILE *File\r
+  );\r
+\r
+int\r
+main (\r
+  int   Argc,\r
+  char  *Argv[]\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Call the routine to process the command-line arguments, then\r
+  dispatch to the appropriate function.\r
+  \r
+Arguments:\r
+  Standard C main() argc and argv.\r
+\r
+Returns:\r
+  0      if successful\r
+  nonzero otherwise\r
+  \r
+--*/\r
+// GC_TODO:    Argc - add argument and description to function comment\r
+// GC_TODO:    ] - add argument and description to function comment\r
+{\r
+  STATUS    Status;\r
+  FILE_LIST *NextFile;\r
+  //\r
+  // Specify our program name to the error printing routines.\r
+  //\r
+  SetUtilityName (PROGRAM_NAME);\r
+  //\r
+  // Process the command-line arguments\r
+  //\r
+  Status = ProcessArgs (Argc, Argv);\r
+  if (Status == STATUS_SUCCESS) {\r
+    if (mOptions.Dump) {\r
+      DumpCapsule ();\r
+    } else if (mOptions.JoinMode) {\r
+      JoinCapsule ();\r
+    } else {\r
+      CreateCapsule ();\r
+    }\r
+  }\r
+  //\r
+  // Cleanup\r
+  //\r
+  while (mOptions.FileList != NULL) {\r
+    NextFile = mOptions.FileList->Next;\r
+    free (mOptions.FileList);\r
+    mOptions.FileList = NextFile;\r
+  }\r
+\r
+  while (mOptions.SizeList != NULL) {\r
+    mOptions.CurrentSize = mOptions.SizeList->Next;\r
+    free (mOptions.SizeList);\r
+    mOptions.SizeList = mOptions.CurrentSize;\r
+  }\r
+\r
+  return GetUtilityStatus ();\r
+}\r
+\r
+static\r
+STATUS\r
+CreateCapsule (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  None\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+{\r
+  FILE                        *InFptr;\r
+  FILE_LIST                   *FileList;\r
+  INT8                        *Buffer;\r
+  UINT32                      Size;\r
+  EFI_CAPSULE_HEADER          CapsuleHeader;\r
+  UINT8                       Zero;\r
+  UINT8                       FirstFile;\r
+  UINT32                      CapsuleHeaderSize;\r
+  long                        InsertedBlockMapEntryOffset;\r
+  EFI_FV_BLOCK_MAP_ENTRY      InsertedBlockMapEntry;\r
+  UINT64                      FirmwareVolumeSize;\r
+  long                        FileSize;\r
+  EFI_FIRMWARE_VOLUME_HEADER  FVHeader;\r
+\r
+  Buffer                      = NULL;\r
+  InFptr                      = NULL;\r
+  FirmwareVolumeSize          = 0;\r
+  CapsuleHeaderSize           = 0;\r
+  InsertedBlockMapEntryOffset = 0;\r
+  memset (&InsertedBlockMapEntry, 0, sizeof (EFI_FV_BLOCK_MAP_ENTRY));\r
+  memset (&FVHeader, 0, sizeof (EFI_FIRMWARE_VOLUME_HEADER));\r
+\r
+  if ((mOptions.OutFptr = fopen (mOptions.OutputFileName, "wb")) == NULL) {\r
+    Error (NULL, 0, 0, mOptions.OutputFileName, "failed to open output file for writing");\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  memset ((char *) &CapsuleHeader, 0, sizeof (CapsuleHeader));\r
+  memcpy ((void *) &CapsuleHeader.CapsuleGuid, (void *) &mEfiCapsuleHeaderGuid, sizeof (EFI_GUID));\r
+  CapsuleHeader.HeaderSize        = sizeof (EFI_CAPSULE_HEADER);\r
+  CapsuleHeader.CapsuleImageSize  = sizeof (EFI_CAPSULE_HEADER);\r
+  if (mOptions.ScriptFileName[0] != 0) {\r
+    if (ProcessScriptFile (mOptions.ScriptFileName, mOptions.OutFptr, &CapsuleHeader) != STATUS_SUCCESS) {\r
+      goto Done;\r
+    }\r
+  } else {\r
+    //\r
+    // Insert a default capsule header\r
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
+    CapsuleHeader.HeaderSize = sizeof (EFI_CAPSULE_HEADER);\r
+    CapsuleHeader.Flags   = UEFI_CAPSULE_HEADER_ALL_FALAGS;\r
+#endif\r
+    CapsuleHeader.OffsetToCapsuleBody = sizeof (EFI_CAPSULE_HEADER);\r
+\r
+   if (fwrite ((void *) &CapsuleHeader, sizeof (CapsuleHeader), 1, mOptions.OutFptr) != 1) {\r
+     Error (NULL, 0, 0, mOptions.OutputFileName, "failed to write to file");\r
+     goto Done;\r
+   }\r
+ }\r
+\r
+  CapsuleHeaderSize = CapsuleHeader.OffsetToCapsuleBody;\r
+  //\r
+  // Now copy the contents of any other files specified on the command\r
+  // line to the output file. Files must be FFS files, which are aligned\r
+  // on 8-byte boundaries. Don't align the first file, since it's the start\r
+  // of the image once the capsule header has been removed.\r
+  //\r
+  FileList  = mOptions.FileList;\r
+  FirstFile = 1;\r
+  Zero      = 0;\r
+  while (FileList != NULL) {\r
+    if ((InFptr = fopen (FileList->FileName, "rb")) == NULL) {\r
+      Error (NULL, 0, 0, FileList->FileName, "failed to open file for reading");\r
+      goto Done;\r
+    }\r
+    //\r
+    // Allocate a buffer into which we can read the file.\r
+    //\r
+    fseek (InFptr, 0, SEEK_END);\r
+    Size = ftell (InFptr);\r
+    rewind (InFptr);\r
+    Buffer = (char *) malloc (Size);\r
+    if (Buffer == NULL) {\r
+      Error (__FILE__, __LINE__, 0, FileList->FileName, "failed to allocate buffer to read file into");\r
+      goto Done;\r
+    }\r
+\r
+    if (fread ((void *) Buffer, Size, 1, InFptr) != 1) {\r
+      Error (NULL, 0, 0, FileList->FileName, "failed to read file contents");\r
+      goto Done;\r
+    }\r
+\r
+    if (Size > 0) {\r
+      //\r
+      // Align the write of the first bytes from the file if not the first file\r
+      //\r
+      if (FirstFile) {\r
+        //\r
+        // First file must be a firmware volume. Double-check, and then insert\r
+        // an additional block map entry so we can add more files from the command line\r
+        //\r
+        if (CheckFirmwareVolumeHeader (FileList->FileName, Buffer, Size) != STATUS_SUCCESS) {\r
+          goto Done;\r
+        }\r
+        //\r
+        // Save a copy of the firmware volume header for later\r
+        //\r
+        memcpy (&FVHeader, Buffer, sizeof (EFI_FIRMWARE_VOLUME_HEADER));\r
+        FirmwareVolumeSize = FVHeader.FvLength;\r
+        if (FileList->Next != NULL) {\r
+          //\r
+          // Copy the firmware volume header\r
+          //\r
+          InsertedBlockMapEntryOffset = CapsuleHeaderSize + FVHeader.HeaderLength;\r
+          if (fwrite (Buffer, FVHeader.HeaderLength, 1, mOptions.OutFptr) != 1) {\r
+            Error (NULL, 0, 0, mOptions.OutputFileName, "failed to write to file");\r
+            goto Done;\r
+          }\r
+\r
+          if (fwrite (&InsertedBlockMapEntry, sizeof (EFI_FV_BLOCK_MAP_ENTRY), 1, mOptions.OutFptr) != 1) {\r
+            Error (NULL, 0, 0, mOptions.OutputFileName, "failed to write to file");\r
+            goto Done;\r
+          }\r
+\r
+          if (fwrite (\r
+                Buffer + FVHeader.HeaderLength,\r
+                Size - FVHeader.HeaderLength,\r
+                1,\r
+                mOptions.OutFptr\r
+                ) != 1) {\r
+            Error (NULL, 0, 0, mOptions.OutputFileName, "failed to write to file");\r
+            goto Done;\r
+          }\r
+        } else {\r
+          //\r
+          // Copy the file contents as-is\r
+          //\r
+          if (fwrite ((void *) Buffer, Size, 1, mOptions.OutFptr) != 1) {\r
+            Error (NULL, 0, 0, mOptions.OutputFileName, "failed to write to file");\r
+            goto Done;\r
+          }\r
+        }\r
+      } else {\r
+        while ((ftell (mOptions.OutFptr) - CapsuleHeaderSize) & 0x07) {\r
+          if (fwrite ((void *) &Zero, 1, 1, mOptions.OutFptr) != 1) {\r
+            Error (NULL, 0, 0, mOptions.OutputFileName, "failed to write to file");\r
+            goto Done;\r
+          }\r
+        }\r
+\r
+        if (fwrite ((void *) Buffer, Size, 1, mOptions.OutFptr) != 1) {\r
+          Error (NULL, 0, 0, mOptions.OutputFileName, "failed to write to file");\r
+          goto Done;\r
+        }\r
+      }\r
+\r
+      FirstFile = 0;\r
+    }\r
+\r
+    free (Buffer);\r
+    Buffer = NULL;\r
+    fclose (InFptr);\r
+    InFptr    = NULL;\r
+    FileList  = FileList->Next;\r
+  }\r
+\r
+Done:\r
+  if (Buffer != NULL) {\r
+    free (Buffer);\r
+  }\r
+\r
+  if (InFptr != NULL) {\r
+    fclose (InFptr);\r
+  }\r
+  //\r
+  // If we inserted an additional block map entry, then fix it up. Fix up the\r
+  // FV header as well to reflect our new size.\r
+  //\r
+  if (InsertedBlockMapEntryOffset != 0) {\r
+    FileSize                        = ftell (mOptions.OutFptr);\r
+    InsertedBlockMapEntry.NumBlocks = 1;\r
+    InsertedBlockMapEntry.BlockLength = (UINT32) ((UINT64) FileSize - (UINT64) CapsuleHeaderSize - FirmwareVolumeSize - sizeof (EFI_FV_BLOCK_MAP_ENTRY));\r
+    fseek (mOptions.OutFptr, InsertedBlockMapEntryOffset, SEEK_SET);\r
+    fwrite (&InsertedBlockMapEntry, sizeof (EFI_FV_BLOCK_MAP_ENTRY), 1, mOptions.OutFptr);\r
+    //\r
+    // Fix up the firmware volume header and write it out\r
+    //\r
+    fseek (mOptions.OutFptr, CapsuleHeaderSize, SEEK_SET);\r
+    FVHeader.FvLength = FileSize - CapsuleHeaderSize;\r
+    FVHeader.HeaderLength += sizeof (EFI_FV_BLOCK_MAP_ENTRY);\r
+    fwrite (&FVHeader, sizeof (EFI_FIRMWARE_VOLUME_HEADER) - sizeof (EFI_FV_BLOCK_MAP_ENTRY), 1, mOptions.OutFptr);\r
+    //\r
+    // Reposition to the end of the file\r
+    //\r
+  }\r
+  //\r
+  // Close files and free the global string lists we allocated memory for\r
+  //\r
+  if (mOptions.OutFptr != NULL) {\r
+    //\r
+    // We should now know the full capsule image size. Update the header and write it again.\r
+    //\r
+    fseek (mOptions.OutFptr, 0, SEEK_END);\r
+    Size  = ftell (mOptions.OutFptr);\r
+    CapsuleHeader.CapsuleImageSize = Size;\r
+    fseek (mOptions.OutFptr, 0, SEEK_SET);\r
+    if (fwrite ((void *) &CapsuleHeader, sizeof (CapsuleHeader), 1, mOptions.OutFptr) != 1) {\r
+      Error (NULL, 0, 0, mOptions.OutputFileName, "failed to write to file");\r
+    }\r
+\r
+    fseek (mOptions.OutFptr, 0, SEEK_END);\r
+    fclose (mOptions.OutFptr);\r
+    mOptions.OutFptr = NULL;\r
+  }\r
+  //\r
+  // If they are doing split capsule output, then split it up now.\r
+  //\r
+  if ((mOptions.Dump == 0) && (GetUtilityStatus () == STATUS_SUCCESS) && (mOptions.SizeList != NULL)) {\r
+    SplitCapsule (mOptions.OutputFileName);\r
+  }\r
+\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+STATUS\r
+ProcessScriptFile (\r
+  INT8                *ScriptFileName,\r
+  FILE                *OutFptr,\r
+  EFI_CAPSULE_HEADER  *CapsuleHeader\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Parse a capsule header script file.\r
+\r
+Arguments:\r
+  ScriptFileName    - name of script file to parse\r
+  OutFptr           - output to dump binary data\r
+  CapsuleHeader     - capsule header to update with size info\r
+                      of parsed fields in the script file\r
+\r
+Returns:\r
+  STATUS_SUCCESS - if all went well\r
+\r
+--*/\r
+{\r
+#if 0\r
+  STATUS      Status;\r
+  SOURCE_FILE SourceFile;\r
+  WCHAR       *WScriptFileName;\r
+  BOOLEAN     InComment;\r
+\r
+  if (fwrite (CapsuleHeader, sizeof (EFI_CAPSULE_HEADER), 1, OutFptr) != 1) {\r
+    Error (NULL, 0, 0, "failed to write capsule header to output file", NULL);\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  memset (&SourceFile, 0, sizeof (SOURCE_FILE));\r
+  strcpy (SourceFile.FileName, ScriptFileName);\r
+\r
+  Status = STATUS_ERROR;\r
+  //\r
+  // Open the input unicode script file and read it into a buffer\r
+  //\r
+  WScriptFileName = (WCHAR *) malloc ((strlen (ScriptFileName) + 1) * sizeof (WCHAR));\r
+  if (WScriptFileName == NULL) {\r
+    Error (__FILE__, __LINE__, 0, "failed to allocate memory", NULL);\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  swprintf (WScriptFileName, L"%S", ScriptFileName);\r
+  if ((SourceFile.FilePtr = _wfopen (WScriptFileName, L"r")) == NULL) {\r
+    free (WScriptFileName);\r
+    Error (NULL, 0, 0, ScriptFileName, "failed to open script file for reading");\r
+    goto Done;\r
+  }\r
+\r
+  free (WScriptFileName);\r
+  fseek (SourceFile.FilePtr, 0, SEEK_END);\r
+  SourceFile.FileSize = ftell (SourceFile.FilePtr);\r
+  rewind (SourceFile.FilePtr);\r
+  SourceFile.FileBuffer = (WCHAR *) malloc (SourceFile.FileSize + sizeof (WCHAR));\r
+  if (SourceFile.FileBuffer == NULL) {\r
+    Error (__FILE__, __LINE__, 0, ScriptFileName, "failed to allocate memory to read in file contents");\r
+    goto Done;\r
+  }\r
+\r
+  if (fread (SourceFile.FileBuffer, SourceFile.FileSize, 1, SourceFile.FilePtr) != 1) {\r
+    Error (NULL, 0, 0, ScriptFileName, "failed to read file contents");\r
+    goto Done;\r
+  }\r
+\r
+  SourceFile.FileBufferPtr  = SourceFile.FileBuffer;\r
+  SourceFile.LineNum        = 1;\r
+  if (SourceFile.FileBuffer[0] != UNICODE_FILE_START) {\r
+    Error (ScriptFileName, 1, 0, "file does not appear to be a unicode file", NULL);\r
+    goto Done;\r
+  }\r
+\r
+  SourceFile.FileBufferPtr++;\r
+  SourceFile.FileBuffer[SourceFile.FileSize / sizeof (WCHAR)] = 0;\r
+  //\r
+  // Walk the source file buffer and replace all carriage returns with 0 so\r
+  // we can print from the file contents on parse errors.\r
+  //\r
+  InComment = 0;\r
+  while (!EndOfFile (&SourceFile)) {\r
+    if (SourceFile.FileBufferPtr[0] == UNICODE_CR) {\r
+      SourceFile.FileBufferPtr[0] = 0;\r
+      InComment                   = 0;\r
+    } else if (SourceFile.FileBufferPtr[0] == UNICODE_LF) {\r
+      InComment = 0;\r
+    } else if (InComment) {\r
+      SourceFile.FileBufferPtr[0] = UNICODE_SPACE;\r
+    } else if ((SourceFile.FileBufferPtr[0] == UNICODE_SLASH) && (SourceFile.FileBufferPtr[1] == UNICODE_SLASH)) {\r
+      InComment                   = 1;\r
+      SourceFile.FileBufferPtr[0] = UNICODE_SPACE;\r
+    }\r
+\r
+    SourceFile.FileBufferPtr++;\r
+  }\r
+  //\r
+  // Reposition to the start of the file, but skip over the unicode file start\r
+  //\r
+  SourceFile.FileBufferPtr = SourceFile.FileBuffer;\r
+  SourceFile.FileBufferPtr++;\r
+  SourceFile.EndOfFile                    = 0;\r
+  CapsuleHeader->OffsetToOemDefinedHeader = ftell (OutFptr);\r
+  //\r
+  // Parse the OEM bytes\r
+  //\r
+  if (ParseOemInfo (&SourceFile, OutFptr) != STATUS_SUCCESS) {\r
+    goto Done;\r
+  }\r
+  //\r
+  // Parse the author information\r
+  //\r
+  CapsuleHeader->OffsetToAuthorInformation = ftell (OutFptr);\r
+  if (ParseCapsuleInfo (&SourceFile, OutFptr, AUTHOR_INFO_STRING) != STATUS_SUCCESS) {\r
+    goto Done;\r
+  }\r
+  //\r
+  // Parse the revision information\r
+  //\r
+  CapsuleHeader->OffsetToRevisionInformation = ftell (OutFptr);\r
+  if (ParseCapsuleInfo (&SourceFile, OutFptr, REVISION_INFO_STRING) != STATUS_SUCCESS) {\r
+    goto Done;\r
+  }\r
+  //\r
+  // Parse the short description\r
+  //\r
+  CapsuleHeader->OffsetToShortDescription = ftell (OutFptr);\r
+  if (ParseCapsuleInfo (&SourceFile, OutFptr, SHORT_DESCRIPTION_STRING) != STATUS_SUCCESS) {\r
+    goto Done;\r
+  }\r
+  //\r
+  // Parse the long description\r
+  //\r
+  CapsuleHeader->OffsetToLongDescription = ftell (OutFptr);\r
+  if (ParseCapsuleInfo (&SourceFile, OutFptr, LONG_DESCRIPTION_STRING) != STATUS_SUCCESS) {\r
+    goto Done;\r
+  }\r
+  //\r
+  // Better be end of contents\r
+  //\r
+  SkipWhiteSpace (&SourceFile);\r
+  if (!EndOfFile (&SourceFile)) {\r
+    Error (ScriptFileName, SourceFile.LineNum, 0, NULL, "expected end-of-file, not %.20S", SourceFile.FileBufferPtr);\r
+    goto Done;\r
+  }\r
+\r
+  CapsuleHeader->OffsetToCapsuleBody = ftell (OutFptr);\r
+  rewind (OutFptr);\r
+  fwrite (CapsuleHeader, sizeof (EFI_CAPSULE_HEADER), 1, OutFptr);\r
+  fseek (OutFptr, 0, SEEK_END);\r
+  Status = STATUS_SUCCESS;\r
+Done:\r
+  if (SourceFile.FilePtr != NULL) {\r
+    fclose (SourceFile.FilePtr);\r
+  }\r
+\r
+  if (SourceFile.FileBuffer != NULL) {\r
+    free (SourceFile.FileBuffer);\r
+  }\r
+\r
+  return Status;\r
+\r
+#endif\r
+  return STATUS_SUCCESS;\r
+}\r
+//\r
+// Parse the OEM data of format:\r
+//      OemInfo {\r
+//            GUID = 12345676-1234-1234-123456789ABC\r
+//            DATA = 0x01, 0x02, 0x03...\r
+//      }\r
+//\r
+static\r
+STATUS\r
+ParseOemInfo (\r
+  SOURCE_FILE       *SourceFile,\r
+  FILE              *OutFptr\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  SourceFile  - GC_TODO: add argument description\r
+  OutFptr     - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+{\r
+  long                    OemHeaderOffset;\r
+  UINT32                  Data;\r
+  EFI_CAPSULE_OEM_HEADER  OemHeader;\r
+  STATUS                  Status;\r
+  UINT32                  DigitCount;\r
+  WCHAR                   *SaveFilePos;\r
+  UINT8                   ByteData;\r
+\r
+  Status = STATUS_ERROR;\r
+  memset (&OemHeader, 0, sizeof (EFI_CAPSULE_OEM_HEADER));\r
+  OemHeaderOffset       = ftell (OutFptr);\r
+  OemHeader.HeaderSize  = sizeof (EFI_CAPSULE_OEM_HEADER);\r
+  if (fwrite (&OemHeader, sizeof (EFI_CAPSULE_OEM_HEADER), 1, OutFptr) != 1) {\r
+    Error (NULL, 0, 0, "failed to write OEM header to output file", NULL);\r
+    goto Done;\r
+  }\r
+\r
+  if (!IsToken (SourceFile, OEM_HEADER_STRING)) {\r
+    Error (\r
+      SourceFile->FileName,\r
+      SourceFile->LineNum,\r
+      0,\r
+      NULL,\r
+      "expected %S, not %.20S",\r
+      OEM_HEADER_STRING,\r
+      SourceFile->FileBufferPtr\r
+      );\r
+    goto Done;\r
+  }\r
+\r
+  if (!IsToken (SourceFile, EQUAL_STRING)) {\r
+    Error (\r
+      SourceFile->FileName,\r
+      SourceFile->LineNum,\r
+      0,\r
+      NULL,\r
+      "expected %S, not %.20S",\r
+      EQUAL_STRING,\r
+      SourceFile->FileBufferPtr\r
+      );\r
+    goto Done;\r
+  }\r
+\r
+  if (!IsToken (SourceFile, OPEN_BRACE_STRING)) {\r
+    Error (\r
+      SourceFile->FileName,\r
+      SourceFile->LineNum,\r
+      0,\r
+      NULL,\r
+      "expected %S, not %.20S",\r
+      OPEN_BRACE_STRING,\r
+      SourceFile->FileBufferPtr\r
+      );\r
+    goto Done;\r
+  }\r
+  //\r
+  // Look for:  GUID = xxxxxxx-xxxx-xxxx-xxxxxxxxxxxxx\r
+  //\r
+  if (!IsToken (SourceFile, GUID_STRING)) {\r
+    Error (\r
+      SourceFile->FileName,\r
+      SourceFile->LineNum,\r
+      0,\r
+      NULL,\r
+      "expected %S, not %.20S",\r
+      GUID_STRING,\r
+      SourceFile->FileBufferPtr\r
+      );\r
+    goto Done;\r
+  }\r
+\r
+  if (!IsToken (SourceFile, EQUAL_STRING)) {\r
+    Error (\r
+      SourceFile->FileName,\r
+      SourceFile->LineNum,\r
+      0,\r
+      NULL,\r
+      "expected %S, not %.20S",\r
+      EQUAL_STRING,\r
+      SourceFile->FileBufferPtr\r
+      );\r
+    goto Done;\r
+  }\r
+  //\r
+  // Parse the xxxxxxxx-xxxx-xxxx-xxxx portion of the GUID\r
+  //\r
+  SkipWhiteSpace (SourceFile);\r
+  if (GetHexValue (SourceFile, &Data, 8) != STATUS_SUCCESS) {\r
+    Error (SourceFile->FileName, SourceFile->LineNum, 0, "invalid GUID", NULL);\r
+    goto Done;\r
+  }\r
+\r
+  OemHeader.OemGuid.Data1 = Data;\r
+  if (!IsToken (SourceFile, L"-")) {\r
+    Error (\r
+      SourceFile->FileName,\r
+      SourceFile->LineNum,\r
+      0,\r
+      NULL,\r
+      "expected dash in GUID, not %S",\r
+      SourceFile->FileBufferPtr\r
+      );\r
+    goto Done;\r
+  }\r
+  //\r
+  // Get 3 word values\r
+  //\r
+  for (DigitCount = 0; DigitCount < 3; DigitCount++) {\r
+    if (GetHexValue (SourceFile, &Data, 4) != STATUS_SUCCESS) {\r
+      Error (SourceFile->FileName, SourceFile->LineNum, 0, "invalid GUID", NULL);\r
+      goto Done;\r
+    }\r
+\r
+    switch (DigitCount) {\r
+    case 0:\r
+      OemHeader.OemGuid.Data2 = (UINT16) Data;\r
+      break;\r
+\r
+    case 1:\r
+      OemHeader.OemGuid.Data3 = (UINT16) Data;\r
+      break;\r
+\r
+    case 2:\r
+      OemHeader.OemGuid.Data4[1]  = (UINT8) Data;\r
+      OemHeader.OemGuid.Data4[0]  = (UINT8) (Data >> 8);\r
+      break;\r
+    }\r
+\r
+    if (!IsToken (SourceFile, L"-")) {\r
+      Error (\r
+        SourceFile->FileName,\r
+        SourceFile->LineNum,\r
+        0,\r
+        NULL,\r
+        "expected dash in GUID, not %S",\r
+        SourceFile->FileBufferPtr\r
+        );\r
+      goto Done;\r
+    }\r
+  }\r
+  //\r
+  // Pick up the last 6 bytes of the GUID\r
+  //\r
+  SaveFilePos = SourceFile->FileBufferPtr;\r
+  for (DigitCount = 0; DigitCount < 6; DigitCount++) {\r
+    if (GetHexValue (SourceFile, &Data, 2) != STATUS_SUCCESS) {\r
+      Error (SourceFile->FileName, SourceFile->LineNum, 0, "invalid GUID", NULL);\r
+      goto Done;\r
+    }\r
+\r
+    OemHeader.OemGuid.Data4[DigitCount + 2] = (UINT8) Data;\r
+  }\r
+  //\r
+  // Now read raw OEM data bytes. May or may not be present.\r
+  //    DATA = 0x01, 0x02, 0x02...\r
+  //\r
+  if (IsToken (SourceFile, CLOSE_BRACE_STRING)) {\r
+    Status = STATUS_SUCCESS;\r
+    goto Done;\r
+  }\r
+\r
+  if (!IsToken (SourceFile, DATA_STRING)) {\r
+    Error (\r
+      SourceFile->FileName,\r
+      SourceFile->LineNum,\r
+      0,\r
+      NULL,\r
+      "expected %S, not %.20S",\r
+      DATA_STRING,\r
+      SourceFile->FileBufferPtr\r
+      );\r
+    goto Done;\r
+  }\r
+\r
+  if (!IsToken (SourceFile, EQUAL_STRING)) {\r
+    Error (\r
+      SourceFile->FileName,\r
+      SourceFile->LineNum,\r
+      0,\r
+      NULL,\r
+      "expected %S, not %.20S",\r
+      EQUAL_STRING,\r
+      SourceFile->FileBufferPtr\r
+      );\r
+    goto Done;\r
+  }\r
+\r
+  while (!EndOfFile (SourceFile)) {\r
+    if (IsToken (SourceFile, CLOSE_BRACE_STRING)) {\r
+      Status = STATUS_SUCCESS;\r
+      goto Done;\r
+    }\r
+\r
+    if (IsToken (SourceFile, L"0x")) {\r
+      if (swscanf (SourceFile->FileBufferPtr, L"%x", &Data) != 1) {\r
+        Error (\r
+          SourceFile->FileName,\r
+          SourceFile->LineNum,\r
+          0,\r
+          NULL,\r
+          "expected hex byte value, not %.20S",\r
+          SourceFile->FileBufferPtr\r
+          );\r
+        goto Done;\r
+      }\r
+\r
+      if (Data &~0xFF) {\r
+        Error (\r
+          SourceFile->FileName,\r
+          SourceFile->LineNum,\r
+          0,\r
+          NULL,\r
+          "expected byte hex byte value at %.20S",\r
+          SourceFile->FileBufferPtr\r
+          );\r
+        goto Done;\r
+      }\r
+      //\r
+      // Skip over the hex digits, then write the data\r
+      //\r
+      while (iswxdigit (SourceFile->FileBufferPtr[0])) {\r
+        SourceFile->FileBufferPtr++;\r
+      }\r
+\r
+      ByteData = (UINT8) Data;\r
+      if (fwrite (&ByteData, 1, 1, OutFptr) != 1) {\r
+        Error (NULL, 0, 0, "failed to write OEM data to output file", NULL);\r
+        goto Done;\r
+      }\r
+\r
+      OemHeader.HeaderSize++;\r
+      //\r
+      // Optional comma\r
+      //\r
+      IsToken (SourceFile, L",");\r
+    } else {\r
+      Error (\r
+        SourceFile->FileName,\r
+        SourceFile->LineNum,\r
+        0,\r
+        NULL,\r
+        "expected hex OEM data, not %.20S",\r
+        SourceFile->FileBufferPtr\r
+        );\r
+      goto Done;\r
+    }\r
+  }\r
+\r
+  if (EndOfFile (SourceFile)) {\r
+    Error (\r
+      SourceFile->FileName,\r
+      SourceFile->LineNum,\r
+      0,\r
+      NULL,\r
+      "expected %S close to OEM header data",\r
+      CLOSE_BRACE_STRING\r
+      );\r
+    goto Done;\r
+  }\r
+\r
+  Status = STATUS_SUCCESS;\r
+Done:\r
+  //\r
+  // re-write the oem header if no errors\r
+  //\r
+  if (Status == STATUS_SUCCESS) {\r
+    fseek (OutFptr, OemHeaderOffset, SEEK_SET);\r
+    if (fwrite (&OemHeader, sizeof (EFI_CAPSULE_OEM_HEADER), 1, OutFptr) != 1) {\r
+      Error (NULL, 0, 0, "failed to write OEM header to output file", NULL);\r
+      goto Done;\r
+    }\r
+\r
+    fseek (OutFptr, 0, SEEK_END);\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
+static\r
+STATUS\r
+ParseCapsuleInfo (\r
+  SOURCE_FILE       *SourceFile,\r
+  FILE              *OutFptr,\r
+  WCHAR             *SectionName\r
+  )\r
+// GC_TODO: function comment should start with '/*++'\r
+//\r
+// GC_TODO: function comment is missing 'Routine Description:'\r
+// GC_TODO: function comment is missing 'Arguments:'\r
+// GC_TODO: function comment is missing 'Returns:'\r
+// GC_TODO:    SourceFile - add argument and description to function comment\r
+// GC_TODO:    OutFptr - add argument and description to function comment\r
+// GC_TODO:    SectionName - add argument and description to function comment\r
+// Parse:  eng "string " "parts"\r
+//          spa "string " "parts"\r
+// Write out: "eng string parts\0spa string parts\0\0\r
+//\r
+{\r
+  STATUS  Status;\r
+  int     StringCount;\r
+  WCHAR   Zero;\r
+  WCHAR   Spacebar;\r
+\r
+  Status    = STATUS_ERROR;\r
+  Zero      = 0;\r
+  Spacebar  = UNICODE_SPACE;\r
+\r
+  if (!IsToken (SourceFile, SectionName)) {\r
+    Error (\r
+      SourceFile->FileName,\r
+      SourceFile->LineNum,\r
+      0,\r
+      NULL,\r
+      "expected %S, not %.20S",\r
+      SectionName,\r
+      SourceFile->FileBufferPtr\r
+      );\r
+    goto Done;\r
+  }\r
+\r
+  if (!IsToken (SourceFile, EQUAL_STRING)) {\r
+    Error (\r
+      SourceFile->FileName,\r
+      SourceFile->LineNum,\r
+      0,\r
+      NULL,\r
+      "expected %S, not %.20S",\r
+      EQUAL_STRING,\r
+      SourceFile->FileBufferPtr\r
+      );\r
+    goto Done;\r
+  }\r
+\r
+  if (!IsToken (SourceFile, OPEN_BRACE_STRING)) {\r
+    Error (\r
+      SourceFile->FileName,\r
+      SourceFile->LineNum,\r
+      0,\r
+      NULL,\r
+      "expected %S, not %.20S",\r
+      OPEN_BRACE_STRING,\r
+      SourceFile->FileBufferPtr\r
+      );\r
+    goto Done;\r
+  }\r
+\r
+  while (!EndOfFile (SourceFile)) {\r
+    if (IsToken (SourceFile, CLOSE_BRACE_STRING)) {\r
+      break;\r
+    }\r
+    //\r
+    // Look for language identifier (3 lowercase chars)\r
+    //\r
+    if ((SourceFile->FileBufferPtr[0] >= UNICODE_a) &&\r
+        (SourceFile->FileBufferPtr[0] <= UNICODE_z) &&\r
+        (SourceFile->FileBufferPtr[1] >= UNICODE_a) &&\r
+        (SourceFile->FileBufferPtr[1] <= UNICODE_z) &&\r
+        (SourceFile->FileBufferPtr[2] >= UNICODE_a) &&\r
+        (SourceFile->FileBufferPtr[2] <= UNICODE_z) &&\r
+        IsWhiteSpace (SourceFile->FileBufferPtr[3])\r
+          ) {\r
+      //\r
+      // Write the 3 chars followed by a spacebar, and then look for opening quote\r
+      //\r
+      fwrite (SourceFile->FileBufferPtr, sizeof (WCHAR), 1, OutFptr);\r
+      SourceFile->FileBufferPtr++;\r
+      fwrite (SourceFile->FileBufferPtr, sizeof (WCHAR), 1, OutFptr);\r
+      SourceFile->FileBufferPtr++;\r
+      fwrite (SourceFile->FileBufferPtr, sizeof (WCHAR), 1, OutFptr);\r
+      SourceFile->FileBufferPtr++;\r
+      fwrite (&Spacebar, sizeof (WCHAR), 1, OutFptr);\r
+      StringCount = 0;\r
+      while (IsToken (SourceFile, L"\"")) {\r
+        StringCount++;\r
+        while (!EndOfFile (SourceFile)) {\r
+          if (SourceFile->FileBufferPtr[0] == UNICODE_DOUBLE_QUOTE) {\r
+            SourceFile->FileBufferPtr++;\r
+            break;\r
+          } else if ((SourceFile->FileBufferPtr[0] == UNICODE_LF) || (SourceFile->FileBufferPtr[0] == 0)) {\r
+            Error (SourceFile->FileName, SourceFile->LineNum, 0, "missing closing quote on string", NULL);\r
+            goto Done;\r
+          } else {\r
+            fwrite (SourceFile->FileBufferPtr, sizeof (WCHAR), 1, OutFptr);\r
+            SourceFile->FileBufferPtr++;\r
+          }\r
+        }\r
+      }\r
+\r
+      if (StringCount == 0) {\r
+        Error (\r
+          SourceFile->FileName,\r
+          SourceFile->LineNum,\r
+          0,\r
+          NULL,\r
+          "expected quoted string, not %.20S",\r
+          SourceFile->FileBufferPtr\r
+          );\r
+        goto Done;\r
+      }\r
+      //\r
+      // This string's null terminator\r
+      //\r
+      fwrite (&Zero, sizeof (WCHAR), 1, OutFptr);\r
+    } else {\r
+      Error (\r
+        SourceFile->FileName,\r
+        SourceFile->LineNum,\r
+        0,\r
+        NULL,\r
+        "expected valid language identifer, not %.20S",\r
+        SourceFile->FileBufferPtr\r
+        );\r
+      goto Done;\r
+    }\r
+  }\r
+  //\r
+  // Double null terminator\r
+  //\r
+  fwrite (&Zero, sizeof (WCHAR), 1, OutFptr);\r
+  Status = STATUS_SUCCESS;\r
+Done:\r
+  return Status;\r
+}\r
+\r
+static\r
+STATUS\r
+SplitCapsule (\r
+  INT8    *CapsuleFileName\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  We've created an entire capsule image. Now split it up into the \r
+  size pieces they requested.\r
+\r
+Arguments:\r
+  CapsuleFileName  - name of an existing capsule file on disk\r
+\r
+Returns:\r
+  STATUS_SUCCESS - if no problems\r
+\r
+Notes:\r
+  This implementation reads in the entire capsule image from\r
+  disk, then overwrites the original file with the first\r
+  in the series.\r
+\r
+--*/\r
+{\r
+#if 0\r
+  EFI_CAPSULE_HEADER  *CapHdr;\r
+\r
+  EFI_CAPSULE_HEADER  Hdr;\r
+  FILE                *CapFptr;\r
+  FILE                *OutFptr;\r
+  UINT32              SizeLeft;\r
+  UINT32              CurrentSize;\r
+  UINT32              DataSize;\r
+  UINT32              SequenceNumber;\r
+  INT8                *Buffer;\r
+  INT8                FileName[MAX_PATH];\r
+  STATUS              Status;\r
+  UINT32              FileSize;\r
+  //\r
+  // Figure out the total size, then rewind the input file and\r
+  // read the entire thing in\r
+  //\r
+  if ((CapFptr = fopen (CapsuleFileName, "rb")) == NULL) {\r
+    Error (NULL, 0, 0, CapsuleFileName, "failed to open capsule image for reading");\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  OutFptr = NULL;\r
+  Status  = STATUS_SUCCESS;\r
+  fseek (CapFptr, 0, SEEK_END);\r
+  SizeLeft = ftell (CapFptr);\r
+  fseek (CapFptr, 0, SEEK_SET);\r
+  CapHdr = (EFI_CAPSULE_HEADER *) malloc (SizeLeft);\r
+  if (CapHdr == NULL) {\r
+    Error (NULL, 0, 0, "memory allocation failure", NULL);\r
+    goto FailDone;\r
+  }\r
+\r
+  if (fread (CapHdr, SizeLeft, 1, CapFptr) != 1) {\r
+    Error (NULL, 0, 0, "failed to read capsule contents", "split failed");\r
+    goto FailDone;\r
+  }\r
+\r
+  fclose (CapFptr);\r
+  CapFptr = NULL;\r
+  //\r
+  // Get a GUID to fill in the InstanceId GUID in the header\r
+  //\r
+  CreateGuid (&CapHdr->InstanceId);\r
+  SequenceNumber = 0;\r
+  //\r
+  // If the split size is larger than the original capsule image, then\r
+  // we're done.\r
+  //\r
+  if (mOptions.SizeList->Size >= SizeLeft) {\r
+    mOptions.SizeList->Size = SizeLeft;\r
+    goto Done;\r
+  }\r
+  //\r
+  // First size has to be big enough for the original header\r
+  //\r
+  if (mOptions.SizeList->Size < CapHdr->OffsetToCapsuleBody) {\r
+    Error (NULL, 0, 0, "first split size is insufficient for the original capsule header", NULL);\r
+    goto FailDone;\r
+  }\r
+  //\r
+  // Initialize the header we'll use on all but the first part\r
+  //\r
+  memset (&Hdr, 0, sizeof (Hdr));\r
+  Hdr.CapsuleGuid         = CapHdr->CapsuleGuid;\r
+  Hdr.HeaderSize          = sizeof (Hdr);\r
+  Hdr.Flags               = CapHdr->Flags;\r
+  Hdr.InstanceId          = CapHdr->InstanceId;\r
+  Hdr.CapsuleImageSize    = CapHdr->CapsuleImageSize;\r
+  Hdr.OffsetToCapsuleBody = Hdr.HeaderSize;\r
+  Hdr.SequenceNumber      = 1;\r
+  //\r
+  // printf ("Created %s - 0x%X bytes\n", CapsuleFileName, mOptions.SizeList->Size);\r
+  //\r
+  Buffer = (UINT8 *) CapHdr;\r
+  //\r
+  // Walk the list of sizes and write out a capsule header, and\r
+  // then the raw capsule data.\r
+  //\r
+  //  SizeLeft -= mOptions.SizeList->Size;\r
+  //\r
+  mOptions.CurrentSize = mOptions.SizeList;\r
+  while (SizeLeft) {\r
+    CurrentSize = mOptions.CurrentSize->Size;\r
+    GetSplitFileName (mOptions.OutputFileName, FileName, SequenceNumber);\r
+    if ((OutFptr = fopen (FileName, "wb")) == NULL) {\r
+      Error (NULL, 0, 0, FileName, "failed to open split file for writing");\r
+      goto FailDone;\r
+    }\r
+\r
+    if (Buffer == (UINT8 *) CapHdr) {\r
+      //\r
+      // First part -- write out original header and data\r
+      //\r
+      if (fwrite (Buffer, CurrentSize, 1, OutFptr) != 1) {\r
+        Error (NULL, 0, 0, FileName, "failed to write to split image file");\r
+        goto FailDone;\r
+      }\r
+\r
+      SizeLeft -= CurrentSize;\r
+      Buffer += CurrentSize;\r
+      DataSize  = CurrentSize;\r
+      FileSize  = CurrentSize;\r
+    } else {\r
+      //\r
+      // Not the first part. Write the default header, and then the raw bytes from the\r
+      // original image.\r
+      //\r
+      if (CurrentSize <= sizeof (Hdr)) {\r
+        Error (NULL, 0, 0, "split size too small for capsule header + data", "0x%X", CurrentSize);\r
+        goto FailDone;\r
+      }\r
+\r
+      DataSize = CurrentSize - sizeof (Hdr);\r
+      if (DataSize > SizeLeft) {\r
+        DataSize = SizeLeft;\r
+      }\r
+\r
+      if (fwrite (&Hdr, sizeof (Hdr), 1, OutFptr) != 1) {\r
+        Error (NULL, 0, 0, FileName, "failed to write capsule header to output file");\r
+        fclose (OutFptr);\r
+        goto FailDone;\r
+      }\r
+\r
+      if (fwrite (Buffer, DataSize, 1, OutFptr) != 1) {\r
+        Error (NULL, 0, 0, FileName, "failed to write capsule data to output file");\r
+        fclose (OutFptr);\r
+        goto FailDone;\r
+      }\r
+\r
+      Hdr.SequenceNumber++;\r
+      Buffer += DataSize;\r
+      SizeLeft -= DataSize;\r
+      FileSize = DataSize + sizeof (Hdr);\r
+    }\r
+    //\r
+    // Next size in list if there is one\r
+    //\r
+    if (mOptions.CurrentSize->Next != NULL) {\r
+      mOptions.CurrentSize = mOptions.CurrentSize->Next;\r
+    }\r
+\r
+    SequenceNumber++;\r
+    fclose (OutFptr);\r
+    OutFptr = NULL;\r
+    printf ("Created %s - 0x%X bytes (0x%X bytes of data)\n", FileName, FileSize, DataSize);\r
+  }\r
+\r
+  goto Done;\r
+FailDone:\r
+  Status = STATUS_ERROR;\r
+Done:\r
+  if (CapHdr != NULL) {\r
+    free (CapHdr);\r
+  }\r
+\r
+  if (CapFptr != NULL) {\r
+    fclose (CapFptr);\r
+  }\r
+\r
+  if (OutFptr != NULL) {\r
+    fclose (OutFptr);\r
+  }\r
+\r
+  return Status;\r
+\r
+#endif\r
+   return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+BOOLEAN\r
+GetSplitFileName (\r
+  INT8    *BaseFileName,\r
+  INT8    *NewFileName,\r
+  UINT32  SequenceNumber\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  BaseFileName    - GC_TODO: add argument description\r
+  NewFileName     - GC_TODO: add argument description\r
+  SequenceNumber  - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+{\r
+  /*++\r
+\r
+Routine Description:\r
+  Given an initial split capsule file name and a sequence number,\r
+  create an appropriate file name for this split of a capsule image.\r
+\r
+Arguments:\r
+  BaseFileName   - name of of the first split file in the series\r
+  NewFileName    - output name of the split file\r
+  SequenceNumber - 0-based sequence number of split images\r
+\r
+Returns:\r
+  TRUE   - name created successfully\r
+  FALSE  - otherwise\r
+\r
+--*/\r
+  INT8    *Ptr;\r
+  INT8    *Part2Start;\r
+  UINT32  Digits;\r
+  UINT32  Len;\r
+  UINT32  BaseOffset;\r
+  //\r
+  // Work back from the end of the file name and see if there is a number somewhere\r
+  //\r
+  for (Ptr = BaseFileName + strlen (BaseFileName) - 1; (Ptr > BaseFileName) && !isdigit (*Ptr); Ptr--)\r
+    ;\r
+  if ((Ptr == BaseFileName) && (!isdigit (*Ptr))) {\r
+    //\r
+    // Found no number, so just add it to the end\r
+    //\r
+    sprintf (NewFileName, "%s%d", BaseFileName, SequenceNumber);\r
+    return TRUE;\r
+  } else {\r
+    //\r
+    // Found a number. Look back to find the first digit.\r
+    //\r
+    Part2Start = Ptr + 1;\r
+    for (Digits = 1; isdigit (*Ptr) && (Ptr > BaseFileName); Ptr--, Digits++)\r
+      ;\r
+    if (!isdigit (*Ptr)) {\r
+      Ptr++;\r
+      Digits--;\r
+    }\r
+\r
+    BaseOffset      = atoi (Ptr);\r
+    SequenceNumber  = SequenceNumber + BaseOffset;\r
+    if (Digits > 1) {\r
+      //\r
+      // Copy the first part of the original file name to the new filename\r
+      // This is the path for filenames with format path\name001.cap\r
+      //\r
+      Len = (UINT32) Ptr - (UINT32) BaseFileName;\r
+      strncpy (NewFileName, BaseFileName, Len);\r
+      sprintf (NewFileName + Len, "%0*d", Digits, SequenceNumber);\r
+      strcat (NewFileName, Part2Start);\r
+      return TRUE;\r
+    } else {\r
+      //\r
+      // Only one digit found. This is the path for filenames with\r
+      // format path\name1.cap\r
+      //\r
+      Len = (UINT32) Ptr - (UINT32) BaseFileName + 1;\r
+      strncpy (NewFileName, BaseFileName, Len);\r
+      sprintf (NewFileName + Len - 1, "%d", SequenceNumber);\r
+      strcat (NewFileName, Part2Start);\r
+      return TRUE;\r
+    }\r
+  }\r
+}\r
+\r
+static\r
+BOOLEAN\r
+IsWhiteSpace (\r
+  WCHAR  Char\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Char  - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+{\r
+  switch (Char) {\r
+  case UNICODE_SPACE:\r
+  case UNICODE_TAB:\r
+  case UNICODE_NULL:\r
+  case UNICODE_CR:\r
+  case UNICODE_LF:\r
+    return TRUE;\r
+\r
+  default:\r
+    return FALSE;\r
+  }\r
+}\r
+\r
+static\r
+BOOLEAN\r
+IsToken (\r
+  SOURCE_FILE *File,\r
+  WCHAR       *Token\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  File  - GC_TODO: add argument description\r
+  Token - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+{\r
+  SkipWhiteSpace (File);\r
+  if (EndOfFile (File)) {\r
+    return FALSE;\r
+  }\r
+\r
+  if (wcsncmp (Token, File->FileBufferPtr, wcslen (Token)) == 0) {\r
+    File->FileBufferPtr += wcslen (Token);\r
+    return TRUE;\r
+  }\r
+\r
+  return FALSE;\r
+}\r
+\r
+static\r
+STATUS\r
+CheckFirmwareVolumeHeader (\r
+  INT8    *FileName,\r
+  INT8    *Buffer,\r
+  UINT32  BufferSize\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  FileName    - GC_TODO: add argument description\r
+  Buffer      - GC_TODO: add argument description\r
+  BufferSize  - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+{\r
+  EFI_FIRMWARE_VOLUME_HEADER  *Hdr;\r
+  EFI_GUID                    FVHeaderGuid = EFI_FIRMWARE_FILE_SYSTEM_GUID;\r
+\r
+  Hdr           = (EFI_FIRMWARE_VOLUME_HEADER *) Buffer;\r
+  if (Hdr->Signature != EFI_FVH_SIGNATURE) {\r
+    Error (NULL, 0, 0, FileName, "file does not appear to be a firmware volume (bad signature)");\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  if (Hdr->Revision != EFI_FVH_REVISION) {\r
+    Error (NULL, 0, 0, FileName, "unsupported firmware volume header version");\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  if (Hdr->FvLength > BufferSize) {\r
+    Error (NULL, 0, 0, FileName, "malformed firmware volume -- FvLength > file size");\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  if (memcmp (&Hdr->FileSystemGuid, &FVHeaderGuid, sizeof (EFI_GUID)) != 0) {\r
+    Error (NULL, 0, 0, FileName, "invalid FFS GUID in firmware volume header");\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+void\r
+DumpCapsule (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  None\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+{\r
+#if 0\r
+  FILE                        *InFptr;\r
+  FILE_LIST                   *FileList;\r
+  EFI_CAPSULE_HEADER          CapsuleHeader;\r
+  EFI_FIRMWARE_VOLUME_HEADER  FVHeader;\r
+  EFI_CAPSULE_OEM_HEADER      *OemHeader;\r
+  UINT8                       *BPtr;\r
+  UINT32                      FileSize;\r
+  UINT32                      CapsuleHeaderDataSize;\r
+  UINT8                       ByteCount;\r
+  UINT8                       *CapsuleHeaderData;\r
+  BOOLEAN                     SplitImage;\r
+\r
+  InFptr            = NULL;\r
+  CapsuleHeaderData = NULL;\r
+  FileList          = mOptions.FileList;\r
+  while (FileList != NULL) {\r
+    if ((InFptr = fopen (FileList->FileName, "rb")) == NULL) {\r
+      Error (NULL, 0, 0, FileList->FileName, "failed to open file for reading");\r
+      goto Done;\r
+    }\r
+\r
+    if (fread (&CapsuleHeader, sizeof (EFI_CAPSULE_HEADER), 1, InFptr) != 1) {\r
+      Error (NULL, 0, 0, FileList->FileName, "failed to read capsule header");\r
+      goto Done;\r
+    }\r
+\r
+    fseek (InFptr, 0, SEEK_END);\r
+    FileSize = ftell (InFptr);\r
+    if (CapsuleHeader.CapsuleImageSize > FileSize) {\r
+      SplitImage = TRUE;\r
+    } else {\r
+      SplitImage = FALSE;\r
+    }\r
+\r
+    printf (\r
+      "Capsule %s Size=0x%X CargoSize=0x%X\n",\r
+      FileList->FileName,\r
+      FileSize,\r
+      FileSize - CapsuleHeader.OffsetToCapsuleBody\r
+      );\r
+    printf (\r
+      "  GUID                  %08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X",\r
+      CapsuleHeader.CapsuleGuid.Data1,\r
+      (UINT32) CapsuleHeader.CapsuleGuid.Data2,\r
+      (UINT32) CapsuleHeader.CapsuleGuid.Data3,\r
+      (UINT32) CapsuleHeader.CapsuleGuid.Data4[0],\r
+      (UINT32) CapsuleHeader.CapsuleGuid.Data4[1],\r
+      (UINT32) CapsuleHeader.CapsuleGuid.Data4[2],\r
+      (UINT32) CapsuleHeader.CapsuleGuid.Data4[3],\r
+      (UINT32) CapsuleHeader.CapsuleGuid.Data4[4],\r
+      (UINT32) CapsuleHeader.CapsuleGuid.Data4[5],\r
+      (UINT32) CapsuleHeader.CapsuleGuid.Data4[6],\r
+      (UINT32) CapsuleHeader.CapsuleGuid.Data4[7]\r
+      );\r
+    if (memcmp (&CapsuleHeader.CapsuleGuid, &mEfiCapsuleHeaderGuid, sizeof (EFI_GUID)) != 0) {\r
+      printf ("  INVALID GUID");\r
+    }\r
+\r
+    printf ("\n");\r
+    printf ("  Header size           0x%08X\n", CapsuleHeader.HeaderSize);\r
+    printf ("  Flags                 0x%08X\n", CapsuleHeader.Flags);\r
+    if (!SplitImage) {\r
+      printf ("  Capsule image size    0x%08X\n", CapsuleHeader.CapsuleImageSize);\r
+    } else {\r
+      printf ("  Capsule image size    0x%08X (split)\n", CapsuleHeader.CapsuleImageSize);\r
+    }\r
+\r
+    printf ("  Sequence number       %d\n", CapsuleHeader.SequenceNumber);\r
+    printf (\r
+      "  InstanceId            %08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X\n",\r
+      CapsuleHeader.InstanceId.Data1,\r
+      (UINT32) CapsuleHeader.InstanceId.Data2,\r
+      (UINT32) CapsuleHeader.InstanceId.Data3,\r
+      (UINT32) CapsuleHeader.InstanceId.Data4[0],\r
+      (UINT32) CapsuleHeader.InstanceId.Data4[1],\r
+      (UINT32) CapsuleHeader.InstanceId.Data4[2],\r
+      (UINT32) CapsuleHeader.InstanceId.Data4[3],\r
+      (UINT32) CapsuleHeader.InstanceId.Data4[4],\r
+      (UINT32) CapsuleHeader.InstanceId.Data4[5],\r
+      (UINT32) CapsuleHeader.InstanceId.Data4[6],\r
+      (UINT32) CapsuleHeader.InstanceId.Data4[7]\r
+      );\r
+    printf ("  Offset to capsule     0x%X\n", CapsuleHeader.OffsetToCapsuleBody);\r
+    //\r
+    // Dump header data if there\r
+    //\r
+    CapsuleHeaderDataSize = CapsuleHeader.OffsetToCapsuleBody - CapsuleHeader.HeaderSize;\r
+    if (CapsuleHeaderDataSize != 0) {\r
+      CapsuleHeaderData = (UINT8 *) malloc (CapsuleHeaderDataSize);\r
+      if (CapsuleHeaderData == NULL) {\r
+        Error (\r
+          NULL,\r
+          0,\r
+          0,\r
+          "failed to allocate memory to read in capsule header data",\r
+          "0x%X bytes",\r
+          CapsuleHeaderDataSize\r
+          );\r
+        goto Done;\r
+      }\r
+\r
+      fseek (InFptr, CapsuleHeader.HeaderSize, SEEK_SET);\r
+      if (fread (CapsuleHeaderData, CapsuleHeaderDataSize, 1, InFptr) != 1) {\r
+        Error (\r
+          NULL,\r
+          0,\r
+          0,\r
+          "failed to read capsule header data contents from file",\r
+          "0x%X bytes",\r
+          CapsuleHeaderDataSize\r
+          );\r
+        goto Done;\r
+      }\r
+      //\r
+      // ************************************************************************\r
+      //\r
+      // OEM HEADER\r
+      //\r
+      // ************************************************************************\r
+      //\r
+      if (CapsuleHeader.OffsetToOemDefinedHeader != 0) {\r
+        OemHeader = (EFI_CAPSULE_OEM_HEADER *) (CapsuleHeaderData + CapsuleHeader.OffsetToOemDefinedHeader - CapsuleHeader.HeaderSize);\r
+        printf ("  OEM Header\n");\r
+        printf (\r
+          "    GUID                %08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X\n",\r
+          OemHeader->OemGuid.Data1,\r
+          (UINT32) OemHeader->OemGuid.Data2,\r
+          (UINT32) OemHeader->OemGuid.Data3,\r
+          (UINT32) OemHeader->OemGuid.Data4[0],\r
+          (UINT32) OemHeader->OemGuid.Data4[1],\r
+          (UINT32) OemHeader->OemGuid.Data4[2],\r
+          (UINT32) OemHeader->OemGuid.Data4[3],\r
+          (UINT32) OemHeader->OemGuid.Data4[4],\r
+          (UINT32) OemHeader->OemGuid.Data4[5],\r
+          (UINT32) OemHeader->OemGuid.Data4[6],\r
+          (UINT32) OemHeader->OemGuid.Data4[7]\r
+          );\r
+        printf ("    Header size:        0x%X\n", OemHeader->HeaderSize);\r
+        printf ("    OEM data");\r
+        BPtr = (UINT8 *) (OemHeader + 1);\r
+        for (ByteCount = 0; ByteCount < OemHeader->HeaderSize - sizeof (EFI_CAPSULE_OEM_HEADER); ByteCount++) {\r
+          if ((ByteCount & 0x7) == 0) {\r
+            printf ("\n      ");\r
+          }\r
+\r
+          printf ("%02X ", (UINT32) *BPtr);\r
+          BPtr++;\r
+        }\r
+\r
+        printf ("\n");\r
+      }\r
+      //\r
+      // ************************************************************************\r
+      //\r
+      // Author, revision, short description, and long description information\r
+      //\r
+      // ************************************************************************\r
+      //\r
+      if (CapsuleHeader.OffsetToAuthorInformation != 0) {\r
+        if (DumpCapsuleHeaderStrings (\r
+              "Author information",\r
+              (WCHAR *) (CapsuleHeaderData + CapsuleHeader.OffsetToAuthorInformation - CapsuleHeader.HeaderSize)\r
+              ) != STATUS_SUCCESS) {\r
+          goto Done;\r
+        }\r
+      }\r
+\r
+      if (CapsuleHeader.OffsetToRevisionInformation != 0) {\r
+        if (DumpCapsuleHeaderStrings (\r
+              "Revision information",\r
+              (WCHAR *) (CapsuleHeaderData + CapsuleHeader.OffsetToRevisionInformation - CapsuleHeader.HeaderSize)\r
+              ) != STATUS_SUCCESS) {\r
+          goto Done;\r
+        }\r
+      }\r
+\r
+      if (CapsuleHeader.OffsetToShortDescription != 0) {\r
+        if (DumpCapsuleHeaderStrings (\r
+              "Short description",\r
+              (WCHAR *) (CapsuleHeaderData + CapsuleHeader.OffsetToShortDescription - CapsuleHeader.HeaderSize)\r
+              ) != STATUS_SUCCESS) {\r
+          goto Done;\r
+        }\r
+      }\r
+\r
+      if (CapsuleHeader.OffsetToLongDescription != 0) {\r
+        if (DumpCapsuleHeaderStrings (\r
+              "Long description",\r
+              (WCHAR *) (CapsuleHeaderData + CapsuleHeader.OffsetToLongDescription - CapsuleHeader.HeaderSize)\r
+              ) != STATUS_SUCCESS) {\r
+          goto Done;\r
+        }\r
+      }\r
+    }\r
+    //\r
+    // If it's not a split image, or it is a split image and this is the first in the series, then\r
+    // dump the cargo volume.\r
+    //\r
+    if ((!SplitImage) || (CapsuleHeader.SequenceNumber == 0)) {\r
+      printf ("  Cargo FV dump\n");\r
+      fseek (InFptr, CapsuleHeader.OffsetToCapsuleBody, SEEK_SET);\r
+      if (fread (&FVHeader, sizeof (EFI_FIRMWARE_VOLUME_HEADER), 1, InFptr) != 1) {\r
+        Error (NULL, 0, 0, FileList->FileName, "failed to read cargo FV header");\r
+        goto Done;\r
+      }\r
+\r
+      printf ("    FV length           0x%X", FVHeader.FvLength);\r
+      if (FileSize - CapsuleHeader.OffsetToCapsuleBody != FVHeader.FvLength) {\r
+        if (!SplitImage) {\r
+          printf (" ERROR: expected 0x%X to jive with file size on disk", FileSize - CapsuleHeader.OffsetToCapsuleBody);\r
+        }\r
+      }\r
+\r
+      printf ("\n");\r
+      printf ("    Signature           0x%X ", FVHeader.Signature);\r
+      if (FVHeader.Signature == EFI_FVH_SIGNATURE) {\r
+        printf ("_FVH\n");\r
+      } else {\r
+        printf ("INVALID\n");\r
+      }\r
+\r
+      printf ("    FV header length    0x%X\n", (UINT32) FVHeader.HeaderLength);\r
+      printf ("    Revision            0x%X\n", (UINT32) FVHeader.Revision);\r
+      printf ("\n");\r
+    }\r
+\r
+    FileList = FileList->Next;\r
+  }\r
+\r
+Done:\r
+  if (InFptr != NULL) {\r
+    fclose (InFptr);\r
+  }\r
+\r
+  if (CapsuleHeaderData != NULL) {\r
+    free (CapsuleHeaderData);\r
+  }\r
+#endif\r
+}\r
+\r
+static\r
+STATUS\r
+JoinCapsule (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Join split capsule images into a single image. This is the\r
+  support function for the -j command-line option.\r
+\r
+Arguments:\r
+  None.\r
+\r
+Returns:\r
+  STATUS_SUCCESS - no problems encountered\r
+\r
+--*/\r
+{\r
+#if 0\r
+  UINT32              Size;\r
+  FILE                *InFptr;\r
+  FILE                *OutFptr;\r
+  INT8                *Buffer;\r
+  FILE_LIST           *FileList;\r
+  STATUS              Status;\r
+  EFI_CAPSULE_HEADER  CapHdr;\r
+  EFI_CAPSULE_HEADER  *CapHdrPtr;\r
+  UINT32              SizeLeft;\r
+  UINT32              SequenceNumber;\r
+  //\r
+  // Must have at least two files for join mode\r
+  //\r
+  if ((mOptions.FileList == NULL) || (mOptions.FileList->Next == NULL)) {\r
+    Error (NULL, 0, 0, "must specify at least two file names to join", NULL);\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Open the output file\r
+  //\r
+  if ((OutFptr = fopen (mOptions.OutputFileName, "wb")) == NULL) {\r
+    Error (NULL, 0, 0, mOptions.OutputFileName, "failed to open output file for writing");\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  FileList        = mOptions.FileList;\r
+  Buffer          = NULL;\r
+  SequenceNumber  = 0;\r
+  InFptr          = NULL;\r
+  SizeLeft        = 0;\r
+  while (FileList != NULL) {\r
+    if ((InFptr = fopen (FileList->FileName, "rb")) == NULL) {\r
+      Error (NULL, 0, 0, FileList->FileName, "failed to open file for reading");\r
+      goto FailDone;\r
+    }\r
+    //\r
+    // Allocate a buffer into which we can read the file.\r
+    //\r
+    fseek (InFptr, 0, SEEK_END);\r
+    Size = ftell (InFptr);\r
+    rewind (InFptr);\r
+    Buffer = (char *) malloc (Size);\r
+    if (Buffer == NULL) {\r
+      Error (__FILE__, __LINE__, 0, FileList->FileName, "failed to allocate buffer to read file into");\r
+      goto FailDone;\r
+    }\r
+\r
+    CapHdrPtr = (EFI_CAPSULE_HEADER *) Buffer;\r
+    if (fread ((void *) Buffer, Size, 1, InFptr) != 1) {\r
+      Error (NULL, 0, 0, FileList->FileName, "failed to read file contents");\r
+      goto FailDone;\r
+    }\r
+    //\r
+    // Check the header for validity. Check size first.\r
+    //\r
+    if (Size < sizeof (EFI_CAPSULE_HEADER)) {\r
+      Error (NULL, 0, 0, FileList->FileName, "file size is insufficient for a capsule header");\r
+      goto FailDone;\r
+    }\r
+    //\r
+    // Check GUID\r
+    //\r
+    if (memcmp (&CapHdrPtr->CapsuleGuid, &mEfiCapsuleHeaderGuid, sizeof (EFI_GUID)) != 0) {\r
+      Error (NULL, 0, 0, FileList->FileName, "invalid capsule GUID");\r
+      goto FailDone;\r
+    }\r
+    //\r
+    // Check sequence number\r
+    //\r
+    if (CapHdrPtr->SequenceNumber != SequenceNumber) {\r
+      Error (\r
+        NULL,\r
+        0,\r
+        0,\r
+        FileList->FileName,\r
+        "invalid sequence number %d (expected %d)",\r
+        CapHdrPtr->SequenceNumber,\r
+        SequenceNumber\r
+        );\r
+      goto FailDone;\r
+    }\r
+    //\r
+    // If the first file, read save the capsule header\r
+    //\r
+    if (SequenceNumber == 0) {\r
+      memcpy (&CapHdr, CapHdrPtr, sizeof (EFI_CAPSULE_HEADER));\r
+      //\r
+      // Erase the InstanceId GUID\r
+      //\r
+      memset (&CapHdrPtr->InstanceId, 0, sizeof (EFI_GUID));\r
+      if (fwrite (Buffer, Size, 1, OutFptr) != 1) {\r
+        Error (NULL, 0, 0, FileList->FileName, "failed to write contents to output file");\r
+        goto FailDone;\r
+      }\r
+\r
+      if (CapHdr.CapsuleImageSize < Size) {\r
+        Error (NULL, 0, 0, FileList->FileName, "capsule image size in capsule header < image size");\r
+        goto FailDone;\r
+      }\r
+\r
+      SizeLeft = CapHdr.CapsuleImageSize - Size;\r
+    } else {\r
+      //\r
+      // Check the GUID against the first file's GUID\r
+      //\r
+      if (memcmp (&CapHdr.CapsuleGuid, &CapHdrPtr->CapsuleGuid, sizeof (EFI_GUID)) != 0) {\r
+        Error (NULL, 0, 0, FileList->FileName, "GUID does not match first file's GUID");\r
+        goto FailDone;\r
+      }\r
+      //\r
+      // Make sure we're not throwing out any header info\r
+      //\r
+      if (CapHdrPtr->OffsetToCapsuleBody > sizeof (EFI_CAPSULE_HEADER)) {\r
+        //\r
+        // Could be the split information, so just emit a warning\r
+        //\r
+        Warning (\r
+          NULL,\r
+          0,\r
+          0,\r
+          FileList->FileName,\r
+          "image appears to have additional capsule header information -- ignoring"\r
+          );\r
+      } else if (CapHdrPtr->OffsetToCapsuleBody < sizeof (EFI_CAPSULE_HEADER)) {\r
+        Error (NULL, 0, 0, FileList->FileName, "offset to capsule body in capsule header is insufficient");\r
+        goto FailDone;\r
+      }\r
+\r
+      if (fwrite (Buffer + CapHdrPtr->OffsetToCapsuleBody, Size - CapHdrPtr->OffsetToCapsuleBody, 1, OutFptr) != 1) {\r
+        Error (NULL, 0, 0, mOptions.OutputFileName, "failed to write to file");\r
+        goto FailDone;\r
+      }\r
+\r
+      if (SizeLeft < (Size - CapHdrPtr->OffsetToCapsuleBody)) {\r
+        Error (NULL, 0, 0, "sum of image sizes exceeds size specified in initial capsule header", NULL);\r
+        goto FailDone;\r
+      }\r
+      //\r
+      // printf ("FILE: %s OffsetToCapsuleBody=0x%X\n", FileList->FileName, CapHdrPtr->OffsetToCapsuleBody);\r
+      //\r
+      SizeLeft = SizeLeft - (Size - CapHdrPtr->OffsetToCapsuleBody);\r
+    }\r
+    //\r
+    // printf ("FILE: %s sizeleft=0x%X\n", FileList->FileName, SizeLeft);\r
+    //\r
+    fclose (InFptr);\r
+    InFptr = NULL;\r
+    free (Buffer);\r
+    Buffer    = NULL;\r
+    FileList  = FileList->Next;\r
+    SequenceNumber++;\r
+  }\r
+\r
+  if (SizeLeft) {\r
+    Error (NULL, 0, 0, "sum of capsule images is insufficient", "0x%X bytes missing", SizeLeft);\r
+    goto FailDone;\r
+  }\r
+\r
+  Status = STATUS_SUCCESS;\r
+  goto Done;\r
+FailDone:\r
+  Status = STATUS_ERROR;\r
+Done:\r
+  if (InFptr != NULL) {\r
+    fclose (InFptr);\r
+  }\r
+\r
+  if (OutFptr != NULL) {\r
+    fclose (OutFptr);\r
+  }\r
+\r
+  if (Buffer != NULL) {\r
+    free (Buffer);\r
+  }\r
+\r
+  return Status;\r
+\r
+#endif\r
+return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+STATUS\r
+DumpCapsuleHeaderStrings (\r
+  UINT8   *SectionName,\r
+  WCHAR   *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Given a pointer to string data from a capsule header, dump\r
+  the strings.\r
+\r
+Arguments:\r
+  SectionName  - name of the capsule header section to which\r
+                 the string data pertains\r
+  Buffer       - pointer to string data from a capsule header\r
+\r
+Returns:\r
+  STATUS_SUCCESS - all went well\r
+\r
+--*/\r
+{\r
+  printf ("  %s\n", SectionName);\r
+  while (*Buffer) {\r
+    printf ("    Language: %S\n", Buffer);\r
+    while (*Buffer) {\r
+      Buffer++;\r
+    }\r
+\r
+    Buffer++;\r
+    while (*Buffer) {\r
+      if (wcslen (Buffer) > 60) {\r
+        printf ("      %.60S\n", Buffer);\r
+        Buffer += 60;\r
+      } else {\r
+        printf ("      %S\n", Buffer);\r
+        Buffer += wcslen (Buffer);\r
+      }\r
+    }\r
+\r
+    Buffer++;\r
+  }\r
+\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+STATUS\r
+GetHexValue (\r
+  SOURCE_FILE  *SourceFile,\r
+  UINT32       *Value,\r
+  UINT32       NumDigits\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Scan a hex value from the input stream.\r
+  \r
+Arguments:\r
+  SourceFile   - input file contents\r
+  Value        - returned value\r
+  NumDigits    - number of digits to read\r
+\r
+Returns:\r
+  STATUS_SUCCESS - if NumDigits were read from the file\r
+  STATUS_ERROR   - otherwise\r
+\r
+  \r
+--*/\r
+{\r
+  WCHAR   *SaveFilePos;\r
+  UINT32  Digits;\r
+  WCHAR   Nibble;\r
+\r
+  SaveFilePos = SourceFile->FileBufferPtr;\r
+  *Value      = 0;\r
+  Digits      = NumDigits;\r
+  while (Digits > 0) {\r
+    Nibble = SourceFile->FileBufferPtr[0];\r
+    if ((Nibble >= UNICODE_0) && (Nibble <= UNICODE_9)) {\r
+      *Value = (*Value << 4) | (Nibble - UNICODE_0);\r
+    } else if ((Nibble >= UNICODE_A) && (Nibble <= UNICODE_F)) {\r
+      *Value = (*Value << 4) | (Nibble - UNICODE_A + 0x10);\r
+    } else if ((Nibble >= UNICODE_a) && (Nibble <= UNICODE_f)) {\r
+      *Value = (*Value << 4) | (Nibble - UNICODE_a + 0x10);\r
+    } else {\r
+      Error (\r
+        SourceFile->FileName,\r
+        SourceFile->LineNum,\r
+        0,\r
+        NULL,\r
+        "expected %d valid hex nibbles at %.20S",\r
+        NumDigits,\r
+        SaveFilePos\r
+        );\r
+      return STATUS_ERROR;\r
+    }\r
+\r
+    SourceFile->FileBufferPtr++;\r
+    Digits--;\r
+  }\r
+\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+BOOLEAN\r
+EndOfFile (\r
+  SOURCE_FILE *File\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  File  - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+{\r
+  if ((UINT32) File->FileBufferPtr - (UINT32) File->FileBuffer >= File->FileSize) {\r
+    File->EndOfFile = TRUE;\r
+  }\r
+  //\r
+  // Reposition to the end of the file if we went beyond\r
+  //\r
+  if (File->EndOfFile) {\r
+    File->FileBufferPtr = File->FileBuffer + File->FileSize / sizeof (WCHAR);\r
+  }\r
+\r
+  return File->EndOfFile;\r
+}\r
+\r
+static\r
+void\r
+SkipWhiteSpace (\r
+  SOURCE_FILE *SourceFile\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  SourceFile  - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+{\r
+  while (!EndOfFile (SourceFile)) {\r
+    switch (*SourceFile->FileBufferPtr) {\r
+    case UNICODE_NULL:\r
+    case UNICODE_CR:\r
+    case UNICODE_SPACE:\r
+    case UNICODE_TAB:\r
+      SourceFile->FileBufferPtr++;\r
+      break;\r
+\r
+    case UNICODE_LF:\r
+      SourceFile->FileBufferPtr++;\r
+      SourceFile->LineNum++;\r
+      break;\r
+\r
+    default:\r
+      return ;\r
+    }\r
+  }\r
+}\r
+//\r
+// Parse a number. Possible format:\r
+//   1234\r
+//   1234k\r
+//   1234K\r
+//   1M\r
+//   1m\r
+//   0x100\r
+//\r
+static\r
+BOOLEAN\r
+GetNumber (\r
+  INT8    *Str,\r
+  UINT32  *Value\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Str   - GC_TODO: add argument description\r
+  Value - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+{\r
+  UINT32  LValue;\r
+\r
+  *Value  = 0;\r
+  LValue  = 0;\r
+  if (!isdigit (Str[0])) {\r
+    return FALSE;\r
+  }\r
+  //\r
+  // Look for hex number\r
+  //\r
+  if ((Str[0] == '0') && (tolower (Str[1]) == 'x')) {\r
+    Str += 2;\r
+    if (Str[0] == 0) {\r
+      return FALSE;\r
+    }\r
+\r
+    while (Str[0]) {\r
+      if ((Str[0] >= '0') && (Str[0] <= '9')) {\r
+        LValue = (LValue << 4) | (Str[0] - '0');\r
+      } else if ((Str[0] >= 'A') && (Str[0] <= 'F')) {\r
+        LValue = (LValue << 4) | (Str[0] - 'A' + 0x10);\r
+      } else if ((Str[0] >= 'a') && (Str[0] <= 'f')) {\r
+        LValue = (LValue << 4) | (Str[0] - 'a' + 0x10);\r
+      } else {\r
+        break;\r
+      }\r
+\r
+      Str++;\r
+    }\r
+  } else {\r
+    LValue = atoi (Str);\r
+    while (isdigit (*Str)) {\r
+      Str++;\r
+    }\r
+  }\r
+  //\r
+  // If string left over, better be one character we recognize\r
+  //\r
+  if (Str[0]) {\r
+    if (Str[1]) {\r
+      return FALSE;\r
+    }\r
+\r
+    switch (Str[0]) {\r
+    case 'k':\r
+    case 'K':\r
+      LValue *= 1024;\r
+      break;\r
+\r
+    case 'm':\r
+    case 'M':\r
+      LValue *= 1024 * 1024;\r
+      break;\r
+\r
+    default:\r
+      return FALSE;\r
+    }\r
+  }\r
+\r
+  *Value = LValue;\r
+  return TRUE;\r
+}\r
+//\r
+// Process the command-line arguments\r
+//\r
+static\r
+STATUS\r
+ProcessArgs (\r
+  int   Argc,\r
+  char  *Argv[]\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Processes command line arguments.\r
+\r
+Arguments:\r
+\r
+  Argc   - Number of command line arguments\r
+  Argv[] - Array of files input on command line  \r
+\r
+Returns:\r
+\r
+  STATUS_ERROR    - Function exited with an error\r
+  STATUS_SUCCESS  - Function executed successfully\r
+\r
+--*/\r
+{\r
+  FILE_LIST *NewFile;\r
+\r
+  FILE_LIST *LastFile;\r
+  SIZE_LIST *NewSize;\r
+  \r
+  NewFile = NULL;\r
+  NewSize = NULL;\r
+  \r
+  //\r
+  // Clear our globals\r
+  //\r
+  memset ((char *) &mOptions, 0, sizeof (mOptions));\r
+\r
+  //\r
+  // Skip program name\r
+  //\r
+  Argc--;\r
+  Argv++;\r
+\r
+  if (Argc == 0) {\r
+    Usage ();\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Process until no more options\r
+  //\r
+  while ((Argc > 0) && (Argv[0][0] == '-')) {\r
+    if (stricmp (Argv[0], "-script") == 0) {\r
+      //\r
+      // Check for one more arg\r
+      //\r
+      if (Argc > 1) {\r
+        //\r
+        // Save the file name\r
+        //\r
+        if (strlen (Argv[1]) >= sizeof (mOptions.ScriptFileName)) {\r
+          Error (NULL, 0, 0, NULL, "input script file name length exceeds internal buffer size");\r
+          \r
+          if (NewFile != NULL) {\r
+            free (NewFile);\r
+          }\r
+          if (NewSize != NULL) {\r
+            free (NewSize);\r
+          }\r
+          \r
+          return STATUS_ERROR;\r
+        }\r
+\r
+        strcpy (mOptions.ScriptFileName, Argv[1]);\r
+      } else {\r
+        Error (NULL, 0, 0, Argv[0], "missing script file name with option");\r
+        Usage ();\r
+        \r
+        if (NewFile != NULL) {\r
+          free (NewFile);\r
+        }\r
+        if (NewSize != NULL) {\r
+          free (NewSize);\r
+        }       \r
+\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      Argc--;\r
+      Argv++;\r
+      //\r
+      // -o outfilename -- specify output file name (required)\r
+      //\r
+    } else if (stricmp (Argv[0], "-o") == 0) {\r
+      //\r
+      // check for one more arg\r
+      //\r
+      if (Argc > 1) {\r
+        //\r
+        // Try to open the file\r
+        //\r
+        // if ((mOptions.OutFptr = fopen (Argv[1], "wb")) == NULL) {\r
+        //  Error (NULL, 0, 0, Argv[1], "failed to open output file for writing");\r
+        //  return STATUS_ERROR;\r
+        // }\r
+        //\r
+        strcpy (mOptions.OutputFileName, Argv[1]);\r
+      } else {\r
+        Error (NULL, 0, 0, Argv[0], "missing output filename with option");\r
+        Usage ();\r
+        \r
+        if (NewFile != NULL) {\r
+          free (NewFile);\r
+        }\r
+        if (NewSize != NULL) {\r
+          free (NewSize);\r
+        }\r
+                \r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      Argc--;\r
+      Argv++;\r
+    } else if (stricmp (Argv[0], "-j") == 0) {\r
+      mOptions.JoinMode = TRUE;\r
+      //\r
+      // -split <size> option (multiple allowed)\r
+      //\r
+    } else if (stricmp (Argv[0], "-split") == 0) {\r
+      if (Argc > 1) {\r
+        NewSize = (SIZE_LIST *) malloc (sizeof (SIZE_LIST));\r
+        if (NewSize == NULL) {\r
+          Error (NULL, 0, 0, "memory allocation failure", NULL);\r
+\r
+          if (NewFile != NULL) {\r
+            free (NewFile);\r
+          }\r
+          if (NewSize != NULL) {\r
+            free (NewSize);\r
+          }\r
+          \r
+          return STATUS_ERROR;\r
+        }\r
+\r
+        memset (NewSize, 0, sizeof (SIZE_LIST));\r
+        //\r
+        // Get the size from the next arg, and then add this size\r
+        // to our size list\r
+        //\r
+        if (!GetNumber (Argv[1], &NewSize->Size)) {\r
+          Error (NULL, 0, 0, Argv[1], "invalid split size argument");\r
+\r
+          if (NewFile != NULL) {\r
+            free (NewFile);\r
+          }\r
+          if (NewSize != NULL) {\r
+            free (NewSize);\r
+          }       \r
+          \r
+          return STATUS_ERROR;\r
+        }\r
+\r
+        if (mOptions.SizeList == NULL) {\r
+          mOptions.SizeList     = NewSize;\r
+          mOptions.CurrentSize  = NewSize;\r
+        } else {\r
+          mOptions.LastSize->Next = NewSize;\r
+        }\r
+\r
+        mOptions.LastSize = NewSize;\r
+        free (NewSize);\r
+      } else {\r
+        Error (NULL, 0, 0, Argv[0], "missing size parameter with option");\r
+        Usage ();\r
+\r
+        if (NewFile != NULL) {\r
+          free (NewFile);\r
+        }\r
+        if (NewSize != NULL) {\r
+          free (NewSize);\r
+        }\r
+        \r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      Argc--;\r
+      Argv++;      \r
+    } else if ((stricmp (Argv[0], "-h") == 0) || (strcmp (Argv[0], "-?") == 0)) {\r
+      Usage ();\r
+      \r
+      if (NewFile != NULL) {\r
+        free (NewFile);\r
+      }\r
+      if (NewSize != NULL) {\r
+        free (NewSize);\r
+      }\r
+      \r
+      return STATUS_ERROR;\r
+      //\r
+      // Default minimum header\r
+      //\r
+    } else if (stricmp (Argv[0], "-dump") == 0) {\r
+      mOptions.Dump = TRUE;\r
+    } else if (stricmp (Argv[0], "-v") == 0) {\r
+      mOptions.Verbose = TRUE;\r
+    } else {\r
+      Error (NULL, 0, 0, Argv[0], "unrecognized option");\r
+      Usage ();\r
+      \r
+      if (NewFile != NULL) {\r
+        free (NewFile);\r
+      }\r
+      if (NewSize != NULL) {\r
+        free (NewSize);\r
+      }\r
+      \r
+      return STATUS_ERROR;\r
+    }\r
+\r
+    Argc--;\r
+    Argv++;\r
+  }\r
+  //\r
+  // Can't -j join files and -s split output capsule\r
+  //\r
+  if ((mOptions.SizeList != NULL) && (mOptions.JoinMode)) {\r
+    Error (NULL, 0, 0, "cannot specify both -j and -size", NULL);\r
+    \r
+    if (NewFile != NULL) {\r
+      free (NewFile);\r
+    }\r
+    if (NewSize != NULL) {\r
+      free (NewSize);\r
+    }\r
+    \r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Must have specified an output file name if not -dump\r
+  //\r
+  if ((mOptions.Dump == 0) && (mOptions.OutputFileName[0] == 0)) {\r
+    Error (NULL, 0, 0, NULL, "-o OutputFileName must be specified");\r
+    Usage ();\r
+    \r
+    if (NewFile != NULL) {\r
+      free (NewFile);\r
+    }\r
+    if (NewSize != NULL) {\r
+      free (NewSize);\r
+    }\r
+    \r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Rest of arguments are input files. The first one is a firmware\r
+  // volume image, and the rest are FFS files that are to be inserted\r
+  // into the firmware volume.\r
+  //\r
+  LastFile = NULL;\r
+  while (Argc > 0) {\r
+    NewFile = (FILE_LIST *) malloc (sizeof (FILE_LIST));\r
+    if (NewFile == NULL) {\r
+      Error (NULL, 0, 0, "memory allocation failure", NULL);\r
+\r
+      if (NewFile != NULL) {\r
+        free (NewFile);\r
+      }\r
+      if (NewSize != NULL) {\r
+        free (NewSize);\r
+      }\r
+    \r
+      return STATUS_ERROR;\r
+    }\r
+\r
+    memset ((char *) NewFile, 0, sizeof (FILE_LIST));\r
+    strcpy (NewFile->FileName, Argv[0]);\r
+    if (mOptions.FileList == NULL) {\r
+      mOptions.FileList = NewFile;\r
+    } else {\r
+      if (LastFile == NULL) {\r
+        LastFile = NewFile;\r
+      } else {\r
+        LastFile->Next = NewFile;\r
+      }      \r
+    }\r
+\r
+    LastFile = NewFile;\r
+    Argc--;\r
+    Argv++;\r
+  }\r
+\r
+  //\r
+  // Must have provided at least one file name\r
+  //\r
+  if (mOptions.FileList == NULL) {\r
+    Error (NULL, 0, 0, "must specify at least one file name", NULL);\r
+    Usage ();\r
+    \r
+    if (NewFile != NULL) {\r
+      free (NewFile);\r
+    }\r
+    if (NewSize != NULL) {\r
+      free (NewSize);\r
+    }\r
+    \r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+void\r
+Usage (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Print usage information for this utility.\r
+  \r
+Arguments:\r
+\r
+  None.\r
+\r
+Returns:\r
+\r
+  Nothing.\r
+  \r
+--*/\r
+{\r
+  int               Index;\r
+  static const char *Str[] = {\r
+    PROGRAM_NAME " -- create a capsule header",\r
+    "  Usage: "PROGRAM_NAME " {options} [CapsuleFV]",\r
+    //\r
+    // {FfsFileNames}",\r
+    //\r
+    "    Options include:",\r
+    "      -h or -?         for this help information",\r
+    "      -script fname    to take capsule header info from unicode script",\r
+    "                       file fname",\r
+    "      -o fname         write output to file fname (required)",\r
+    "      -split size      split capsule image into multiple output files",\r
+    "      -dump            to dump a capsule header",\r
+    "      -v               for verbose output\n",\r
+    "      -j               to join split capsule images into a single image",\r
+    "",\r
+    "    CapsuleFV is the name of an existing well-formed Tiano firmware",\r
+    "    volume file.",\r
+    //\r
+    // FfsFileNames are the names of one or more Tiano FFS files to",\r
+    // "    insert into the output capsule image.",\r
+    //\r
+    NULL\r
+  };\r
+  for (Index = 0; Str[Index] != NULL; Index++) {\r
+    fprintf (stdout, "%s\n", Str[Index]);\r
+  }\r
+}\r
diff --git a/Tools/CodeTools/Source/GenCapsuleHdr/build.xml b/Tools/CodeTools/Source/GenCapsuleHdr/build.xml
new file mode 100644 (file)
index 0000000..7c43d0a
--- /dev/null
@@ -0,0 +1,72 @@
+<?xml version="1.0" ?>\r
+<!--\r
+Copyright (c) 2006, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+-->\r
+<project default="GenTool" basedir=".">\r
+<!--\r
+    EDK GenCapsuleHdr Tool\r
+  Copyright (c) 2006, Intel Corporation\r
+-->\r
+  <property name="ToolName" value="GenCapsuleHdr"/>\r
+  <property name="FileSet" value="GenCapsuleHdr.c"/>\r
+\r
+  <taskdef resource="cpptasks.tasks"/>\r
+  <typedef resource="cpptasks.types"/>\r
+  <taskdef resource="net/sf/antcontrib/antlib.xml"/>\r
+\r
+  <property name="LINK_OUTPUT_TYPE" value="static"/>\r
+  <property name="BUILD_DIR" value="${PACKAGE_DIR}/${ToolName}/tmp"/>\r
+\r
+  <target name="GenTool" depends="init, Tool">\r
+    <echo message="The EDK Tool: ${ToolName} build has completed!"/>\r
+  </target>\r
+\r
+  <target name="init">\r
+    <echo message="Building the EDK Tool: ${ToolName}"/>\r
+    <mkdir dir="${BUILD_DIR}"/>\r
+  </target>\r
+\r
+  <target name="Tool" depends="init">\r
+    <cc name="${ToolChain}" objdir="${BUILD_DIR}" \r
+        outfile="${BIN_DIR}/${ToolName}"\r
+        outtype="executable"\r
+        optimize="speed" \r
+        debug="true">\r
+      <compilerarg value="${ExtraArgus}" if="ExtraArgus" />\r
+\r
+      <fileset dir="${basedir}/${ToolName}" \r
+        includes="${FileSet}" \r
+        defaultexcludes="TRUE" \r
+        excludes="*.xml *.inf"/>\r
+\r
+      <includepath path="${PACKAGE_DIR}/Include"/>\r
+      <includepath path="${PACKAGE_DIR}/Include/${HostArch}"/>\r
+      <includepath path="${PACKAGE_DIR}/Common"/>\r
+      <libset dir="${LIB_DIR}" libs="CommonTools"/>\r
+      <syslibset dir="${env.CYGWIN_HOME}/lib/mingw" libs="msvcr71" if="cygwin"/>\r
+    </cc>\r
+  </target>\r
+\r
+  <target name="clean">\r
+    <echo message="Removing Intermediate Files Only"/>  \r
+    <delete>\r
+      <fileset dir="${BUILD_DIR}" includes="*.obj"/>\r
+    </delete>\r
+  </target>\r
+\r
+  <target name="cleanall">\r
+    <echo message="Removing Object Files and the Executable: ${ToolName}${ext_exe}"/>  \r
+    <delete failonerror="false" quiet="true" includeEmptyDirs="true">\r
+      <fileset dir="${BUILD_DIR}"/>\r
+      <fileset file="${BIN_DIR}/${ToolName}${ext_exe}"/>\r
+    </delete>\r
+  </target>\r
+\r
+</project>\r
diff --git a/Tools/CodeTools/Source/GenDepex/DepexParser.c b/Tools/CodeTools/Source/GenDepex/DepexParser.c
new file mode 100644 (file)
index 0000000..9f0a0cb
--- /dev/null
@@ -0,0 +1,903 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  DepexParser.c\r
+\r
+Abstract:\r
+\r
+  Validate Dependency Expression syntax\r
+  recursive descent Algorithm\r
+\r
+  The original BNF grammar(taken from "Pre EFI Initialization Core Interface Specification \r
+  draft review 0.9") is thus:\r
+       <depex>    ::= BEFORE <guid> END\r
+                    | AFTER <guid> END\r
+                    | SOR <bool> END\r
+                    | <bool> END    \r
+       <bool>     ::= <bool> AND <term> \r
+                    | <bool> OR <term>  \r
+                    | <term>            \r
+       <term>     ::= NOT <factor>      \r
+                    | <factor>          \r
+       <factor>   ::= <bool>            \r
+                    | TRUE \r
+                    | FALSE \r
+                    | GUID\r
+\r
+       <guid>     ::= '{' <hex32> ',' <hex16> ',' <hex16> ','\r
+                      <hex8> ',' <hex8> ',' <hex8> ',' <hex8> ',' \r
+                      <hex8> ',' <hex8> ',' <hex8> ',' <hex8> '}'\r
+       <hex32>    ::= <hexprefix> <hexvalue>\r
+       <hex16>    ::= <hexprefix> <hexvalue>\r
+       <hex8>     ::= <hexprefix> <hexvalue>\r
+       <hexprefix>::= '0' 'x'\r
+                    | '0' 'X'\r
+       <hexvalue> ::= <hexdigit> <hexvalue>\r
+                    | <hexdigit>\r
+       <hexdigit> ::= [0-9]\r
+                    | [a-f]\r
+                    | [A-F]\r
+\r
+  After cleaning left recursive and parentheses supported, the BNF grammar used in this module is thus:\r
+       <depex>    ::= BEFORE <guid>\r
+                    | AFTER <guid>\r
+                    | SOR <bool>\r
+                    | <bool>\r
+       <bool>     ::= <term><rightbool>\r
+       <rightbool>::= AND <term><rightbool>\r
+                    | OR <term><rightbool>\r
+                    | ''\r
+       <term>     ::= NOT <factor>\r
+                    | <factor>\r
+       <factor>   ::= '('<bool>')'<rightfactor>\r
+                    | NOT <factor> <rightbool> <rightfactor>\r
+                    | TRUE <rightfactor>\r
+                    | FALSE <rightfactor>\r
+                    | END <rightfactor>\r
+                    | <guid> <rightfactor>                    \r
+       <rightfactor> ::=AND <term><rightbool> <rightfactor>   \r
+                    | OR <term><rightbool> <rightfactor>                 \r
+                    | ''\r
+       <guid>     ::= '{' <hex32> ',' <hex16> ',' <hex16> ','\r
+                      <hex8> ',' <hex8> ',' <hex8> ',' <hex8> ',' \r
+                      <hex8> ',' <hex8> ',' <hex8> ',' <hex8> '}'\r
+       <hex32>    ::= <hexprefix> <hexvalue>\r
+       <hex16>    ::= <hexprefix> <hexvalue>\r
+       <hex8>     ::= <hexprefix> <hexvalue>\r
+       <hexprefix>::= '0' 'x'\r
+                    | '0' 'X'\r
+       <hexvalue> ::= <hexdigit> <hexvalue>\r
+                    | <hexdigit>\r
+       <hexdigit> ::= [0-9]\r
+                    | [a-f]\r
+                    | [A-F]\r
\r
+  Note: 1. There's no precedence in operators except parentheses;\r
+        2. For hex32, less and equal than 8 bits is valid, more than 8 bits is invalid.\r
+           Same constraint for hex16 is 4, hex8 is 2. All hex should contains at least 1 bit.\r
+        3. "<factor>   ::= '('<bool>')'<rightfactor>" is added to support parentheses;\r
+        4. "<factor>   ::= GUID" is changed to "<factor>   ::= <guid>";\r
+        5. "DEPENDENCY_END" is the terminal of the expression. But it has been filtered by caller. \r
+           During parsing, "DEPENDENCY_END" will be treated as illegal factor;\r
+    \r
+  This code should build in any environment that supports a standard C-library w/ string\r
+  operations and File I/O services.\r
+\r
+  As an example of usage, consider the following:\r
+\r
+  The input string could be something like: \r
+    \r
+      NOT ({ 0xce345171, 0xba0b, 0x11d2, 0x8e, 0x4f, 0x0, 0xa0, 0xc9, 0x69, 0x72,\r
+        0x3b } AND { 0x964e5b22, 0x6459, 0x11d2, 0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69,\r
+        0x72, 0x3b }) OR { 0x03c4e603, 0xac28, 0x11d3, 0x9a, 0x2d, 0x00, 0x90, 0x27,\r
+        0x3f, 0xc1, 0x4d } AND\r
+\r
+  It's invalid for an extra "AND" in the end.\r
+\r
+  Complies with Tiano C Coding Standards Document, version 0.33, 16 Aug 2001.\r
+\r
+--*/\r
+\r
+#include "DepexParser.h"\r
+\r
+BOOLEAN\r
+ParseBool (\r
+  IN      INT8      *Pbegin,\r
+  IN      UINT32    length,\r
+  IN OUT  INT8      **Pindex\r
+  );\r
+\r
+BOOLEAN\r
+ParseTerm (\r
+  IN      INT8      *Pbegin,\r
+  IN      UINT32    length,\r
+  IN OUT  INT8      **Pindex\r
+  );\r
+\r
+BOOLEAN\r
+ParseRightBool (\r
+  IN      INT8      *Pbegin,\r
+  IN      UINT32    length,\r
+  IN OUT  INT8      **Pindex\r
+  );\r
+\r
+BOOLEAN\r
+ParseFactor (\r
+  IN      INT8      *Pbegin,\r
+  IN      UINT32    length,\r
+  IN OUT  INT8      **Pindex\r
+  );\r
+\r
+VOID\r
+LeftTrim (\r
+  IN      INT8      *Pbegin,\r
+  IN      UINT32    length,\r
+  IN OUT  INT8      **Pindex\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Left trim the space, '\n' and '\r' character in string.\r
+  The space at the end does not need trim.\r
+\r
+\r
+Arguments:\r
+\r
+  Pbegin    The pointer to the string  \r
+  length    length of the string\r
+  Pindex    The pointer of pointer to the next parse character in the string\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+\r
+--*/\r
+{\r
+  while\r
+  (\r
+    ((*Pindex) < (Pbegin + length)) &&\r
+    ((strncmp (*Pindex, " ", 1) == 0) || (strncmp (*Pindex, "\n", 1) == 0) || (strncmp (*Pindex, "\r", 1) == 0))\r
+  ) {\r
+    (*Pindex)++;\r
+  }\r
+}\r
+\r
+BOOLEAN\r
+ParseHexdigit (\r
+  IN      INT8      *Pbegin,\r
+  IN      UINT32    length,\r
+  IN OUT  INT8      **Pindex\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Parse Hex bit in dependency expression.  \r
+\r
+Arguments:\r
+\r
+  Pbegin    The pointer to the string  \r
+  length    Length of the string\r
+  Pindex    The pointer of pointer to the next parse character in the string\r
+\r
+Returns:\r
+\r
+  BOOLEAN   If parses a valid hex bit, return TRUE, otherwise FALSE\r
+\r
+\r
+--*/\r
+{\r
+  //\r
+  // <hexdigit> ::= [0-9] | [a-f] | [A-F]\r
+  //\r
+  if (((**Pindex) >= '0' && (**Pindex) <= '9') ||\r
+      ((**Pindex) >= 'a' && (**Pindex) <= 'f') ||\r
+      ((**Pindex) >= 'A' && (**Pindex) <= 'F')\r
+      ) {\r
+    (*Pindex)++;\r
+    return TRUE;\r
+  } else {\r
+    return FALSE;\r
+  }\r
+}\r
+\r
+BOOLEAN\r
+ParseHex32 (\r
+  IN      INT8      *Pbegin,\r
+  IN      UINT32    length,\r
+  IN OUT  INT8      **Pindex\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Parse Hex32 in dependency expression.  \r
+\r
+Arguments:\r
+\r
+  Pbegin    The pointer to the string  \r
+  length    Length of the string\r
+  Pindex    The pointer of point to the next parse character in the string\r
+\r
+Returns:\r
+\r
+  BOOLEAN   If parses a valid hex32, return TRUE, otherwise FALSE\r
+\r
+\r
+--*/\r
+{\r
+  INT32 Index;\r
+  INT8  *Pin;\r
+\r
+  Index = 0;\r
+  Pin   = *Pindex;\r
+  LeftTrim (Pbegin, length, Pindex);\r
+\r
+  if ((strncmp (*Pindex, "0x", 2) != 0) && (strncmp (*Pindex, "0X", 2) != 0)) {\r
+    return FALSE;\r
+  }\r
+  (*Pindex) += 2;\r
+\r
+  while (ParseHexdigit (Pbegin, length, Pindex)) {\r
+    Index++;\r
+  }\r
+\r
+  if (Index > 0 && Index <= 8) {\r
+    return TRUE;\r
+  } else {\r
+    *Pindex = Pin;\r
+    return FALSE;\r
+  }\r
+}\r
+\r
+BOOLEAN\r
+ParseHex16 (\r
+  IN      INT8      *Pbegin,\r
+  IN      UINT32    length,\r
+  IN OUT  INT8      **Pindex\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Parse Hex16 in dependency expression.  \r
+\r
+Arguments:\r
+\r
+  Pbegin    The pointer to the string  \r
+  length    Length of the string\r
+  Pindex    The pointer of pointer to the next parse character in the string\r
+\r
+Returns:\r
+\r
+  BOOLEAN   If parses a valid hex16, return TRUE, otherwise FALSE\r
+\r
+\r
+--*/\r
+{\r
+  int   Index;\r
+  INT8  *Pin;\r
+\r
+  Index = 0;\r
+  Pin   = *Pindex;\r
+  LeftTrim (Pbegin, length, Pindex);\r
+\r
+  if ((strncmp (*Pindex, "0x", 2) != 0) && (strncmp (*Pindex, "0X", 2) != 0)) {\r
+    return FALSE;\r
+  }\r
+  (*Pindex) += 2;\r
+\r
+  while (ParseHexdigit (Pbegin, length, Pindex)) {\r
+    Index++;\r
+  }\r
+\r
+  if (Index > 0 && Index <= 4) {\r
+    return TRUE;\r
+  } else {\r
+    *Pindex = Pin;\r
+    return FALSE;\r
+  }\r
+}\r
+\r
+BOOLEAN\r
+ParseHex8 (\r
+  IN      INT8      *Pbegin,\r
+  IN      UINT32    length,\r
+  IN OUT  INT8      **Pindex\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Parse Hex8 in dependency expression.  \r
+\r
+Arguments:\r
+\r
+  Pbegin    The pointer to the string  \r
+  length    Length of the string\r
+  Pindex    The pointer of pointer to the next parse character in the string\r
+\r
+Returns:\r
+\r
+  BOOLEAN   If parses a valid hex8, return TRUE, otherwise FALSE\r
+\r
+\r
+--*/\r
+{\r
+  int   Index;\r
+  INT8  *Pin;\r
+\r
+  Index = 0;\r
+  Pin   = *Pindex;\r
+  LeftTrim (Pbegin, length, Pindex);\r
+\r
+  if ((strncmp (*Pindex, "0x", 2) != 0) && (strncmp (*Pindex, "0X", 2) != 0)) {\r
+    return FALSE;\r
+  }\r
+  (*Pindex) += 2;\r
+\r
+  while (ParseHexdigit (Pbegin, length, Pindex)) {\r
+    Index++;\r
+  }\r
+\r
+  if (Index > 0 && Index <= 2) {\r
+    return TRUE;\r
+  } else {\r
+    *Pindex = Pin;\r
+    return FALSE;\r
+  }\r
+}\r
+\r
+BOOLEAN\r
+ParseGuid (\r
+  IN      INT8      *Pbegin,\r
+  IN      UINT32    length,\r
+  IN OUT  INT8      **Pindex\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Parse guid in dependency expression.\r
+  There can be any number of spaces between '{' and hexword, ',' and hexword, \r
+  hexword and ',', hexword and '}'. The hexword include hex32, hex16 and hex8.\r
+\r
+Arguments:\r
+\r
+  Pbegin    The pointer to the string  \r
+  length    length of the string\r
+  Pindex    The pointer of pointer to the next parse character in the string\r
+\r
+Returns:\r
+\r
+  BOOLEAN   If parses a valid guid, return TRUE, otherwise FALSE\r
+\r
+\r
+--*/\r
+{\r
+  INT32 Index;\r
+  INT8  *Pin;\r
+  Pin = *Pindex;\r
+  LeftTrim (Pbegin, length, Pindex);\r
+  if (strncmp (*Pindex, "{", 1) != 0) {\r
+    return FALSE;\r
+  }\r
+  (*Pindex)++;\r
+\r
+  LeftTrim (Pbegin, length, Pindex);\r
+  if (!ParseHex32 (Pbegin, length, Pindex)) {\r
+    *Pindex = Pin;\r
+    return FALSE;\r
+  }\r
+\r
+  LeftTrim (Pbegin, length, Pindex);\r
+  if (strncmp (*Pindex, ",", 1) != 0) {\r
+    return FALSE;\r
+  } else {\r
+    (*Pindex)++;\r
+  }\r
+\r
+  for (Index = 0; Index < 2; Index++) {\r
+    LeftTrim (Pbegin, length, Pindex);\r
+    if (!ParseHex16 (Pbegin, length, Pindex)) {\r
+      *Pindex = Pin;\r
+      return FALSE;\r
+    }\r
+\r
+    LeftTrim (Pbegin, length, Pindex);\r
+    if (strncmp (*Pindex, ",", 1) != 0) {\r
+      return FALSE;\r
+    } else {\r
+      (*Pindex)++;\r
+    }\r
+  }\r
+\r
+  LeftTrim (Pbegin, length, Pindex);\r
+  if (strncmp (*Pindex, "{", 1) != 0) {\r
+    return FALSE;\r
+  }\r
+  (*Pindex)++;\r
+\r
+  for (Index = 0; Index < 7; Index++) {\r
+    LeftTrim (Pbegin, length, Pindex);\r
+    if (!ParseHex8 (Pbegin, length, Pindex)) {\r
+      *Pindex = Pin;\r
+      return FALSE;\r
+    }\r
+\r
+    LeftTrim (Pbegin, length, Pindex);\r
+    if (strncmp (*Pindex, ",", 1) != 0) {\r
+      return FALSE;\r
+    } else {\r
+      (*Pindex)++;\r
+    }\r
+  }\r
+\r
+  LeftTrim (Pbegin, length, Pindex);\r
+  if (!ParseHex8 (Pbegin, length, Pindex)) {\r
+    *Pindex = Pin;\r
+    return FALSE;\r
+  }\r
+\r
+  LeftTrim (Pbegin, length, Pindex);\r
+  if (strncmp (*Pindex, "}", 1) != 0) {\r
+    return FALSE;\r
+  } else {\r
+    (*Pindex)++;\r
+  }\r
+\r
+  LeftTrim (Pbegin, length, Pindex);\r
+  if (strncmp (*Pindex, "}", 1) != 0) {\r
+    return FALSE;\r
+  } else {\r
+    (*Pindex)++;\r
+  }\r
+\r
+  return TRUE;\r
+}\r
+\r
+BOOLEAN\r
+ParseRightFactor (\r
+  IN      INT8      *Pbegin,\r
+  IN      UINT32    length,\r
+  IN OUT  INT8      **Pindex\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Parse rightfactor in bool expression.\r
+\r
+Arguments:\r
+\r
+  Pbegin    The pointer to the string  \r
+  length    length of the string\r
+  Pindex    The pointer of pointer to the next parse character in the string\r
+\r
+Returns:\r
+\r
+  BOOLEAN   If string is a valid rightfactor expression, return TRUE, otherwise FALSE\r
+\r
+\r
+--*/\r
+{\r
+  INT8  *Pin;\r
+\r
+  Pin = *Pindex;\r
+  LeftTrim (Pbegin, length, Pindex);\r
+\r
+  //\r
+  // <rightfactor> ::=AND <term> <rightbool> <rightfactor>\r
+  //\r
+  if (strncmp (*Pindex, OPERATOR_AND, strlen (OPERATOR_AND)) == 0) {\r
+    *Pindex += strlen (OPERATOR_AND);\r
+    LeftTrim (Pbegin, length, Pindex);\r
+\r
+    if (ParseTerm (Pbegin, length, Pindex)) {\r
+      LeftTrim (Pbegin, length, Pindex);\r
+\r
+      if (ParseRightBool (Pbegin, length, Pindex)) {\r
+        LeftTrim (Pbegin, length, Pindex);\r
+        if (ParseRightFactor (Pbegin, length, Pindex)) {\r
+          return TRUE;\r
+        } else {\r
+          *Pindex = Pin;\r
+        }\r
+      } else {\r
+        *Pindex = Pin;\r
+      }\r
+    } else {\r
+      *Pindex = Pin;\r
+    }\r
+  }\r
+  //\r
+  // <rightfactor> ::=OR <term> <rightbool> <rightfactor>\r
+  //\r
+  if (strncmp (*Pindex, OPERATOR_OR, strlen (OPERATOR_OR)) == 0) {\r
+    *Pindex += strlen (OPERATOR_OR);\r
+    LeftTrim (Pbegin, length, Pindex);\r
+\r
+    if (ParseTerm (Pbegin, length, Pindex)) {\r
+      LeftTrim (Pbegin, length, Pindex);\r
+\r
+      if (ParseRightBool (Pbegin, length, Pindex)) {\r
+        LeftTrim (Pbegin, length, Pindex);\r
+        if (ParseRightFactor (Pbegin, length, Pindex)) {\r
+          return TRUE;\r
+        } else {\r
+          *Pindex = Pin;\r
+        }\r
+      } else {\r
+        *Pindex = Pin;\r
+      }\r
+    } else {\r
+      *Pindex = Pin;\r
+    }\r
+  }\r
+  //\r
+  // <rightfactor> ::= ''\r
+  //\r
+  *Pindex = Pin;\r
+  return TRUE;\r
+}\r
+\r
+BOOLEAN\r
+ParseRightBool (\r
+  IN      INT8      *Pbegin,\r
+  IN      UINT32    length,\r
+  IN OUT  INT8      **Pindex\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Parse rightbool in bool expression.\r
+\r
+Arguments:\r
+\r
+  Pbegin    The pointer to the string  \r
+  length    length of the string\r
+  Pindex    The pointer of pointer to the next parse character in the string\r
+\r
+Returns:\r
+\r
+  BOOLEAN   If string is a valid rightbool expression, return TRUE, otherwise FALSE\r
+\r
+\r
+--*/\r
+{\r
+  INT8  *Pin;\r
+\r
+  Pin = *Pindex;\r
+  LeftTrim (Pbegin, length, Pindex);\r
+\r
+  //\r
+  // <rightbool>::= AND <term><rightbool>\r
+  //\r
+  if (strncmp (*Pindex, OPERATOR_AND, strlen (OPERATOR_AND)) == 0) {\r
+    *Pindex += strlen (OPERATOR_AND);\r
+    LeftTrim (Pbegin, length, Pindex);\r
+\r
+    if (ParseTerm (Pbegin, length, Pindex)) {\r
+      LeftTrim (Pbegin, length, Pindex);\r
+\r
+      if (ParseRightBool (Pbegin, length, Pindex)) {\r
+        return TRUE;\r
+      } else {\r
+        *Pindex = Pin;\r
+      }\r
+    } else {\r
+      *Pindex = Pin;\r
+    }\r
+  }\r
+  //\r
+  // <rightbool>::=  OR <term><rightbool>\r
+  //\r
+  if (strncmp (*Pindex, OPERATOR_OR, strlen (OPERATOR_OR)) == 0) {\r
+    *Pindex += strlen (OPERATOR_OR);\r
+    LeftTrim (Pbegin, length, Pindex);\r
+\r
+    if (ParseTerm (Pbegin, length, Pindex)) {\r
+      LeftTrim (Pbegin, length, Pindex);\r
+\r
+      if (ParseRightBool (Pbegin, length, Pindex)) {\r
+        return TRUE;\r
+      } else {\r
+        *Pindex = Pin;\r
+      }\r
+    } else {\r
+      *Pindex = Pin;\r
+    }\r
+  }\r
+  //\r
+  // <rightbool>::= ''\r
+  //\r
+  *Pindex = Pin;\r
+  return TRUE;\r
+}\r
+\r
+BOOLEAN\r
+ParseFactor (\r
+  IN      INT8      *Pbegin,\r
+  IN      UINT32    length,\r
+  IN OUT  INT8      **Pindex\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Parse factor in bool expression.\r
+\r
+Arguments:\r
+\r
+  Pbegin    The pointer to the string  \r
+  length    length of the string\r
+  Pindex    The pointer of pointer to the next parse character in the string\r
+\r
+Returns:\r
+\r
+  BOOLEAN   If string is a valid factor, return TRUE, otherwise FALSE\r
+\r
+\r
+--*/\r
+{\r
+  INT8  *Pin;\r
+\r
+  Pin = *Pindex;\r
+  LeftTrim (Pbegin, length, Pindex);\r
+\r
+  //\r
+  // <factor>   ::= '('<bool>')'<rightfactor>\r
+  //\r
+  if (strncmp (*Pindex, OPERATOR_LEFT_PARENTHESIS, strlen (OPERATOR_LEFT_PARENTHESIS)) == 0) {\r
+    *Pindex += strlen (OPERATOR_LEFT_PARENTHESIS);\r
+    LeftTrim (Pbegin, length, Pindex);\r
+\r
+    if (!ParseBool (Pbegin, length, Pindex)) {\r
+      *Pindex = Pin;\r
+    } else {\r
+      LeftTrim (Pbegin, length, Pindex);\r
+\r
+      if (strncmp (*Pindex, OPERATOR_RIGHT_PARENTHESIS, strlen (OPERATOR_RIGHT_PARENTHESIS)) == 0) {\r
+        *Pindex += strlen (OPERATOR_RIGHT_PARENTHESIS);\r
+        LeftTrim (Pbegin, length, Pindex);\r
+\r
+        if (ParseRightFactor (Pbegin, length, Pindex)) {\r
+          return TRUE;\r
+        } else {\r
+          *Pindex = Pin;\r
+        }\r
+      }\r
+    }\r
+  }\r
+  //\r
+  // <factor>   ::= NOT <factor> <rightbool> <rightfactor>\r
+  //\r
+  if (strncmp (*Pindex, OPERATOR_NOT, strlen (OPERATOR_NOT)) == 0) {\r
+    *Pindex += strlen (OPERATOR_NOT);\r
+    LeftTrim (Pbegin, length, Pindex);\r
+\r
+    if (ParseFactor (Pbegin, length, Pindex)) {\r
+      LeftTrim (Pbegin, length, Pindex);\r
+\r
+      if (ParseRightBool (Pbegin, length, Pindex)) {\r
+        LeftTrim (Pbegin, length, Pindex);\r
+\r
+        if (ParseRightFactor (Pbegin, length, Pindex)) {\r
+          return TRUE;\r
+        } else {\r
+          *Pindex = Pin;\r
+        }\r
+      } else {\r
+        *Pindex = Pin;\r
+      }\r
+    } else {\r
+      *Pindex = Pin;\r
+    }\r
+  }\r
+  //\r
+  // <factor>   ::= TRUE <rightfactor>\r
+  //\r
+  if (strncmp (*Pindex, OPERATOR_TRUE, strlen (OPERATOR_TRUE)) == 0) {\r
+    *Pindex += strlen (OPERATOR_TRUE);\r
+    LeftTrim (Pbegin, length, Pindex);\r
+\r
+    if (ParseRightFactor (Pbegin, length, Pindex)) {\r
+      return TRUE;\r
+    } else {\r
+      *Pindex = Pin;\r
+    }\r
+  }\r
+  //\r
+  // <factor>   ::= FALSE <rightfactor>\r
+  //\r
+  if (strncmp (*Pindex, OPERATOR_FALSE, strlen (OPERATOR_FALSE)) == 0) {\r
+    *Pindex += strlen (OPERATOR_FALSE);\r
+    LeftTrim (Pbegin, length, Pindex);\r
+\r
+    if (ParseRightFactor (Pbegin, length, Pindex)) {\r
+      return TRUE;\r
+    } else {\r
+      *Pindex = Pin;\r
+    }\r
+  }\r
+  //\r
+  // <factor>   ::= <guid> <rightfactor>\r
+  //\r
+  if (ParseGuid (Pbegin, length, Pindex)) {\r
+    LeftTrim (Pbegin, length, Pindex);\r
+\r
+    if (ParseRightFactor (Pbegin, length, Pindex)) {\r
+      return TRUE;\r
+    } else {\r
+      *Pindex = Pin;\r
+      return FALSE;\r
+    }\r
+  } else {\r
+    *Pindex = Pin;\r
+    return FALSE;\r
+  }\r
+}\r
+\r
+BOOLEAN\r
+ParseTerm (\r
+  IN      INT8      *Pbegin,\r
+  IN      UINT32    length,\r
+  IN OUT  INT8      **Pindex\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Parse term in bool expression.\r
+\r
+Arguments:\r
+\r
+  Pbegin    The pointer to the string  \r
+  length    length of the string\r
+  Pindex    The pointer of pointer to the next parse character in the string\r
+\r
+Returns:\r
+\r
+  BOOLEAN   If string is a valid term, return TRUE, otherwise FALSE\r
+\r
+\r
+--*/\r
+{\r
+  INT8  *Pin;\r
+\r
+  Pin = *Pindex;\r
+  LeftTrim (Pbegin, length, Pindex);\r
+\r
+  //\r
+  // <term>     ::= NOT <factor>\r
+  //\r
+  if (strncmp (*Pindex, OPERATOR_NOT, strlen (OPERATOR_NOT)) == 0) {\r
+    *Pindex += strlen (OPERATOR_NOT);\r
+    LeftTrim (Pbegin, length, Pindex);\r
+\r
+    if (!ParseFactor (Pbegin, length, Pindex)) {\r
+      *Pindex = Pin;\r
+    } else {\r
+      return TRUE;\r
+    }\r
+  }\r
+  //\r
+  // <term>     ::=<factor>\r
+  //\r
+  if (ParseFactor (Pbegin, length, Pindex)) {\r
+    return TRUE;\r
+  } else {\r
+    *Pindex = Pin;\r
+    return FALSE;\r
+  }\r
+}\r
+\r
+BOOLEAN\r
+ParseBool (\r
+  IN      INT8      *Pbegin,\r
+  IN      UINT32    length,\r
+  IN OUT  INT8      **Pindex\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Parse bool expression.\r
+\r
+Arguments:\r
+\r
+  Pbegin    The pointer to the string  \r
+  length    length of the string\r
+  Pindex    The pointer of pointer to the next parse character in the string\r
+\r
+Returns:\r
+\r
+  BOOLEAN   If string is a valid bool expression, return TRUE, otherwise FALSE\r
+\r
+\r
+--*/\r
+{\r
+  INT8  *Pin;\r
+  Pin = *Pindex;\r
+  LeftTrim (Pbegin, length, Pindex);\r
+\r
+  if (ParseTerm (Pbegin, length, Pindex)) {\r
+    LeftTrim (Pbegin, length, Pindex);\r
+\r
+    if (!ParseRightBool (Pbegin, length, Pindex)) {\r
+      *Pindex = Pin;\r
+      return FALSE;\r
+    } else {\r
+      return TRUE;\r
+    }\r
+  } else {\r
+    *Pindex = Pin;\r
+    return FALSE;\r
+  }\r
+}\r
+\r
+BOOLEAN\r
+ParseDepex (\r
+  IN      INT8      *Pbegin,\r
+  IN      UINT32    length\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Parse whole dependency expression.\r
+\r
+Arguments:\r
+\r
+  Pbegin    The pointer to the string  \r
+  length    length of the string\r
+\r
+Returns:\r
+\r
+  BOOLEAN   If string is a valid dependency expression, return TRUE, otherwise FALSE\r
+\r
+\r
+--*/\r
+{\r
+  BOOLEAN Result;\r
+  INT8    **Pindex;\r
+  INT8    *temp;\r
+\r
+  Result  = FALSE;\r
+  temp    = Pbegin;\r
+  Pindex  = &temp;\r
+\r
+  LeftTrim (Pbegin, length, Pindex);\r
+  if (strncmp (*Pindex, OPERATOR_BEFORE, strlen (OPERATOR_BEFORE)) == 0) {\r
+    (*Pindex) += strlen (OPERATOR_BEFORE);\r
+    Result = ParseGuid (Pbegin, length, Pindex);\r
+\r
+  } else if (strncmp (*Pindex, OPERATOR_AFTER, strlen (OPERATOR_AFTER)) == 0) {\r
+    (*Pindex) += strlen (OPERATOR_AFTER);\r
+    Result = ParseGuid (Pbegin, length, Pindex);\r
+\r
+  } else if (strncmp (*Pindex, OPERATOR_SOR, strlen (OPERATOR_SOR)) == 0) {\r
+    (*Pindex) += strlen (OPERATOR_SOR);\r
+    Result = ParseBool (Pbegin, length, Pindex);\r
+\r
+  } else {\r
+    Result = ParseBool (Pbegin, length, Pindex);\r
+\r
+  }\r
+\r
+  LeftTrim (Pbegin, length, Pindex);\r
+  return (BOOLEAN) (Result && (*Pindex) >= (Pbegin + length));\r
+}\r
diff --git a/Tools/CodeTools/Source/GenDepex/DepexParser.h b/Tools/CodeTools/Source/GenDepex/DepexParser.h
new file mode 100644 (file)
index 0000000..29e0884
--- /dev/null
@@ -0,0 +1,26 @@
+/*++\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+  Module Name:  \r
+          GenDepex.h\r
+\r
+  Abstract:\r
+          This file contains the relevant declarations required\r
+          to generate a binary Dependency File\r
+\r
+  Complies with Tiano C Coding Standards Document, version 0.31, 12 Dec 2000.\r
+\r
+--*/\r
+\r
+// TODO: fix comment to set correct module name: DepexParser.h\r
+#ifndef _EFI_DEPEX_PARSER_H_\r
+#define _EFI_DEPEX_PARSER_H_\r
+#include "GenDepex.h"\r
+#endif\r
diff --git a/Tools/CodeTools/Source/GenDepex/GenDepex.c b/Tools/CodeTools/Source/GenDepex/GenDepex.c
new file mode 100644 (file)
index 0000000..3818649
--- /dev/null
@@ -0,0 +1,919 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  GenDepex.c\r
+\r
+Abstract:\r
+\r
+  Generate Dependency Expression ("GenDepex")\r
+\r
+  Infix to Postfix Algorithm\r
+\r
+  This code has been scrubbed to be free of having any EFI core tree dependencies.\r
+  It should build in any environment that supports a standard C-library w/ string\r
+  operations and File I/O services.\r
+\r
+  As an example of usage, consider the following:\r
+\r
+  The input user file could be something like "Sample.DXS" whose contents are\r
+\r
+    #include "Tiano.h"\r
+\r
+    DEPENDENCY_START\r
+      NOT (DISK_IO_PROTOCOL AND SIMPLE_FILE_SYSTEM_PROTOCOL) \r
+        OR EFI_PXE_BASE_CODE_PROTOCOL\r
+    DEPENDENCY_END\r
+\r
+  This file is then washed through the C-preprocessor, viz.,\r
+\r
+    cl /EP Sample.DXS > Sample.TMP1\r
+\r
+  This yields the following file "Sample.TMP1" whose contents are\r
+\r
+    DEPENDENCY_START\r
+      NOT ({ 0xce345171, 0xba0b, 0x11d2, 0x8e, 0x4f, 0x0, 0xa0, 0xc9, 0x69, 0x72,\r
+        0x3b } AND { 0x964e5b22, 0x6459, 0x11d2, 0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69,\r
+        0x72, 0x3b }) OR { 0x03c4e603, 0xac28, 0x11d3, 0x9a, 0x2d, 0x00, 0x90, 0x27,\r
+        0x3f, 0xc1, 0x4d }\r
+    DEPENDENCY_END\r
+\r
+  This file, in turn, will be fed into the utility, viz.,\r
+\r
+    GenDepex Sample.TMP1 Sample.TMP2\r
+\r
+  With a file that is 55 bytes long:\r
+\r
+     55 bytes for the grammar binary\r
+        PUSH opcode         - 1  byte\r
+        GUID Instance       - 16 bytes\r
+        PUSH opcode         - 1  byte\r
+        GUID Instance       - 16 bytes\r
+        AND opcode          - 1  byte\r
+        NOT opcode          - 1  byte\r
+        PUSH opcode         - 1  byte\r
+        GUID Instance       - 16 bytes\r
+        OR opcode           - 1  byte\r
+        END opcode          - 1  byte\r
+\r
+  The file "Sample.TMP2" could be fed via a Section-builder utility \r
+  (GenSection) that would be used for the creation of a dependency\r
+  section file (.DPX) which in turn would be used by a generate FFS\r
+  utility (GenFfsFile) to produce a DXE driver/core (.DXE) or \r
+  a DXE application (.APP) file.\r
+\r
+  Complies with Tiano C Coding Standards Document, version 0.31, 12 Dec 2000.\r
+\r
+--*/\r
+\r
+#include "GenDepex.h"\r
+\r
+#define TOOL_NAME "GenDepex"\r
+\r
+extern\r
+ParseDepex (\r
+  IN      INT8      *Pbegin,\r
+  IN      UINT32    length\r
+  );\r
+\r
+VOID\r
+PrintGenDepexUtilityInfo (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Displays the standard utility information to SDTOUT.\r
+\r
+Arguments:\r
+\r
+  None\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+{\r
+  printf (\r
+    "%s, Tiano Dependency Expression Generation Utility. Version %d.%d.\n",\r
+    UTILITY_NAME,\r
+    UTILITY_MAJOR_VERSION,\r
+    UTILITY_MINOR_VERSION\r
+    );\r
+  printf ("Copyright (C) 1996-2002 Intel Corporation.  All rights reserved.\n\n");\r
+}\r
+\r
+VOID\r
+PrintGenDepexUsageInfo (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Displays the utility usage syntax to STDOUT.\r
+\r
+Arguments:\r
+\r
+  None\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+{\r
+  printf (\r
+    "Usage: %s -I <INFILE> -O <OUTFILE> [-P <Optional Boundary for padding up>] \n",\r
+    UTILITY_NAME\r
+    );\r
+  printf (" Where:\n");\r
+  printf ("  <INFILE> is the input pre-processed dependency text files name.\n");\r
+  printf ("  <OUTFILE> is the output binary dependency files name.\n");\r
+  printf ("  <Optional Boundary for padding up> is the padding integer value.\n");\r
+  printf ("    This is the boundary to align the output file size to.\n");\r
+}\r
+\r
+DEPENDENCY_OPCODE\r
+PopOpCode (\r
+  IN OUT VOID **Stack\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Pop an element from the Opcode stack.\r
+\r
+Arguments:\r
+\r
+  Stack               Current top of the OpCode stack location\r
+\r
+Returns:\r
+\r
+  DEPENDENCY_OPCODE   OpCode at the top of the OpCode stack.\r
+  Stack               New top of the OpCode stack location\r
+\r
+\r
+--*/\r
+{\r
+  DEPENDENCY_OPCODE *OpCodePtr;\r
+\r
+  OpCodePtr = *Stack;\r
+  OpCodePtr--;\r
+  *Stack = OpCodePtr;\r
+  return *OpCodePtr;\r
+}\r
+\r
+VOID\r
+PushOpCode (\r
+  IN OUT  VOID                **Stack,\r
+  IN      DEPENDENCY_OPCODE   OpCode\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Push an element onto the Opcode Stack\r
+\r
+Arguments:\r
+\r
+  Stack     Current top of the OpCode stack location\r
+  OpCode    OpCode to push onto the stack\r
+\r
+Returns:\r
+\r
+  Stack     New top of the OpCode stack location\r
+\r
+--*/\r
+{\r
+  DEPENDENCY_OPCODE *OpCodePtr;\r
+\r
+  OpCodePtr   = *Stack;\r
+  *OpCodePtr  = OpCode;\r
+  OpCodePtr++;\r
+  *Stack = OpCodePtr;\r
+}\r
+\r
+EFI_STATUS\r
+GenerateDependencyExpression (\r
+  IN     FILE           *InFile,\r
+  IN OUT FILE           *OutFile,\r
+  IN     INT8           Padding  OPTIONAL\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This takes the pre-compiled dependency text file and \r
+  converts it into a binary dependency file.\r
+\r
+  The BNF for the dependency expression is as follows \r
+  (from the DXE 1.0 Draft specification).\r
+\r
+  The inputted BNF grammar is thus:\r
+    <depex> ::= sor <dep> | \r
+                before GUID <dep> | \r
+                after GUID <dep> | \r
+                <bool>\r
+\r
+    <dep> ::=   <bool> |\r
+\r
+    <bool> ::=  <bool> and <term> | \r
+                <bool> or <term> | \r
+                <term>\r
+\r
+    <term> ::=  not <factor> | \r
+                <factor>\r
+\r
+    <factor> ::= ( <bool> ) | \r
+                 <term> <term> | \r
+                 GUID | \r
+                 <boolval>\r
+\r
+    <boolval> ::= true | \r
+                  false\r
+\r
+  The outputed binary grammer is thus:\r
+    <depex> ::= sor <dep> | \r
+                before <depinst> <dep> | \r
+                after <depinst> <dep> | \r
+                <bool>\r
+\r
+    <dep> ::=   <bool> |\r
+\r
+    <bool> ::=  <bool> and <term> | \r
+                <bool> or <term> | <term>\r
+\r
+    <term> ::=  not <factor> | \r
+                <factor>\r
+\r
+    <factor> ::= ( <bool> ) | \r
+                 <term> <term> | \r
+                 <boolval> | \r
+                 <depinst> | \r
+                 <termval>\r
+\r
+    <boolval> ::= true | \r
+                  false\r
+\r
+    <depinst> ::= push GUID\r
+\r
+    <termval> ::= end\r
+\r
+  BugBug: A correct grammer is parsed correctly. A file that violates the\r
+          grammer may parse when it should generate an error. There is some\r
+          error checking and it covers most of the case when it's an include\r
+          of definition issue. An ill formed expresion may not be detected.\r
+\r
+Arguments:\r
+\r
+  InFile -  Input pre-compiled text file of the dependency expression.\r
+            This needs to be in ASCII.\r
+            The file pointer can not be NULL.\r
+\r
+  OutFile - Binary dependency file.\r
+            The file pointer can not be NULL.\r
+\r
+  Padding - OPTIONAL integer value to pad the output file to.\r
+\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS             The function completed successfully.\r
+  EFI_INVALID_PARAMETER   One of the parameters in the text file was invalid.\r
+  EFI_OUT_OF_RESOURCES    Unable to allocate memory.\r
+  EFI_ABORTED             An misc error occurred.\r
+\r
+--*/\r
+{\r
+  INT8              *Ptrx;\r
+  INT8              *Pend;\r
+  INT8              *EvaluationStack;\r
+  INT8              *StackPtr;\r
+  INT8              *Buffer;\r
+  INT8              Line[LINESIZE];\r
+  UINTN             Index;\r
+  UINTN             OutFileSize;\r
+  UINTN             FileSize;\r
+  UINTN             Results;\r
+  BOOLEAN           NotDone;\r
+  BOOLEAN           Before_Flag;\r
+  BOOLEAN           After_Flag;\r
+  BOOLEAN           Dep_Flag;\r
+  BOOLEAN           SOR_Flag;\r
+  EFI_GUID          Guid;\r
+  UINTN             ArgCountParsed;\r
+  DEPENDENCY_OPCODE Opcode;\r
+\r
+  Before_Flag = FALSE;\r
+  After_Flag  = FALSE;\r
+  Dep_Flag    = FALSE;\r
+  SOR_Flag    = FALSE;\r
+\r
+  memset (Line, 0, LINESIZE);\r
+\r
+  OutFileSize     = 0;\r
+\r
+  EvaluationStack = (INT8 *) malloc (EVAL_STACK_SIZE);\r
+\r
+  if (EvaluationStack != NULL) {\r
+    StackPtr = EvaluationStack;\r
+  } else {\r
+    printf ("Unable to allocate memory to EvaluationStack - Out of resources\n");\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+\r
+  Results = (UINTN) fseek (InFile, 0, SEEK_END);\r
+\r
+  if (Results != 0) {\r
+    printf ("FSEEK failed - Aborted\n");\r
+    return EFI_ABORTED;\r
+  }\r
+\r
+  FileSize = ftell (InFile);\r
+\r
+  if (FileSize == -1L) {\r
+    printf ("FTELL failed - Aborted\n");\r
+    return EFI_ABORTED;\r
+  }\r
+\r
+  Buffer = (INT8 *) malloc (FileSize + BUFFER_SIZE);\r
+\r
+  if (Buffer == NULL) {\r
+    printf ("Unable to allocate memory to Buffer - Out of resources\n");\r
+    free (EvaluationStack);\r
+\r
+    Results = (UINTN) fclose (InFile);\r
+    if (Results != 0) {\r
+      printf ("FCLOSE failed\n");\r
+    }\r
+\r
+    Results = (UINTN) fclose (OutFile);\r
+    if (Results != 0) {\r
+      printf ("FCLOSE failed\n");\r
+    }\r
+\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+\r
+  Results = (UINTN) fseek (InFile, 0, SEEK_SET);\r
+\r
+  if (Results != 0) {\r
+    printf ("FSEEK failed - Aborted\n");\r
+    return EFI_ABORTED;\r
+  }\r
+\r
+  memset (Buffer, 0, FileSize + BUFFER_SIZE);\r
+  fread (Buffer, FileSize, 1, InFile);\r
+\r
+  Ptrx    = Buffer;\r
+  Pend    = Ptrx + FileSize - strlen (DEPENDENCY_END);\r
+  Index   = FileSize;\r
+\r
+  NotDone = TRUE;\r
+  while ((Index--) && NotDone) {\r
+\r
+    if (strncmp (Pend, DEPENDENCY_END, strlen (DEPENDENCY_END)) == 0) {\r
+      NotDone = FALSE;\r
+    } else {\r
+      Pend--;\r
+    }\r
+  }\r
+\r
+  if (NotDone) {\r
+    printf ("Couldn't find end string %s\n", DEPENDENCY_END);\r
+\r
+    Results = (UINTN) fclose (InFile);\r
+    if (Results != 0) {\r
+      printf ("FCLOSE failed\n");\r
+    }\r
+\r
+    Results = (UINTN) fclose (OutFile);\r
+    if (Results != 0) {\r
+      printf ("FCLOSE failed\n");\r
+    }\r
+\r
+    free (Buffer);\r
+    free (EvaluationStack);\r
+\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  Index   = FileSize;\r
+\r
+  NotDone = TRUE;\r
+  while ((Index--) && NotDone) {\r
+\r
+    if (strncmp (Ptrx, DEPENDENCY_START, strlen (DEPENDENCY_START)) == 0) {\r
+      Ptrx += sizeof (DEPENDENCY_START);\r
+      NotDone = FALSE;\r
+      //\r
+      // BUGBUG -- should Index be decremented by sizeof(DEPENDENCY_START)?\r
+      //\r
+    } else {\r
+      Ptrx++;\r
+    }\r
+  }\r
+\r
+  if (NotDone) {\r
+    printf ("Couldn't find start string %s\n", DEPENDENCY_START);\r
+\r
+    Results = (UINTN) fclose (InFile);\r
+    if (Results != 0) {\r
+      printf ("FCLOSE failed\n");\r
+    }\r
+\r
+    Results = (UINTN) fclose (OutFile);\r
+    if (Results != 0) {\r
+      printf ("FCLOSE failed\n");\r
+    }\r
+\r
+    free (Buffer);\r
+    free (EvaluationStack);\r
+\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+  //\r
+  //  validate the syntax of expression\r
+  //\r
+  if (!ParseDepex (Ptrx, Pend - Ptrx - 1)) {\r
+    printf ("The syntax of expression is wrong\n");\r
+\r
+    Results = (UINTN) fclose (InFile);\r
+    if (Results != 0) {\r
+      printf ("FCLOSE failed\n");\r
+    }\r
+\r
+    Results = (UINTN) fclose (OutFile);\r
+    if (Results != 0) {\r
+      printf ("FCLOSE failed\n");\r
+    }\r
+\r
+    free (Buffer);\r
+    free (EvaluationStack);\r
+\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  NotDone = TRUE;\r
+\r
+  while ((Index--) && NotDone) {\r
+\r
+    if (*Ptrx == ' ') {\r
+      Ptrx++;\r
+    } else if (*Ptrx == '\n' || *Ptrx == '\r') {\r
+      Ptrx++;\r
+    } else if (strncmp (Ptrx, OPERATOR_SOR, strlen (OPERATOR_SOR)) == 0) {\r
+      //\r
+      //  Checks for some invalid dependencies\r
+      //\r
+      if (Before_Flag) {\r
+\r
+        printf ("A BEFORE operator was detected.\n");\r
+        printf ("There can only be one SOR or one AFTER or one BEFORE operator\n");\r
+        return EFI_INVALID_PARAMETER;\r
+\r
+      } else if (After_Flag) {\r
+\r
+        printf ("An AFTER operator was detected.\n");\r
+        printf ("There can only be one SOR or one AFTER or one BEFORE operator\n");\r
+        return EFI_INVALID_PARAMETER;\r
+\r
+      } else if (SOR_Flag) {\r
+\r
+        printf ("Another SOR operator was detected.\n");\r
+        printf ("There can only be one SOR or one AFTER or one BEFORE operator\n");\r
+        return EFI_INVALID_PARAMETER;\r
+\r
+      } else if (Dep_Flag) {\r
+\r
+        printf ("The Schedule On Request - SOR operator must be the first operator following DEPENDENCY_START\n");\r
+        return EFI_INVALID_PARAMETER;\r
+\r
+      } else {\r
+        //\r
+        //  BUGBUG - This was not in the spec but is in the CORE code\r
+        //  An OPERATOR_SOR has to be first - following the DEPENDENCY_START\r
+        //\r
+        fputc (EFI_DEP_SOR, OutFile);\r
+        OutFileSize++;\r
+        Ptrx += sizeof (OPERATOR_SOR);\r
+        SOR_Flag = TRUE;\r
+\r
+      }\r
+    } else if (strncmp (Ptrx, OPERATOR_BEFORE, strlen (OPERATOR_BEFORE)) == 0) {\r
+      //\r
+      //  Checks for some invalid dependencies\r
+      //\r
+      if (Before_Flag) {\r
+\r
+        printf ("Another BEFORE operator was detected.\n");\r
+        printf ("There can only be one SOR or one AFTER or one BEFORE operator\n");\r
+        return EFI_INVALID_PARAMETER;\r
+\r
+      } else if (After_Flag) {\r
+\r
+        printf ("An AFTER operator was detected.\n");\r
+        printf ("There can only be one SOR or one AFTER or one BEFORE operator\n");\r
+        return EFI_INVALID_PARAMETER;\r
+\r
+      } else if (SOR_Flag) {\r
+\r
+        printf ("A SOR operator was detected.\n");\r
+        printf ("There can only be one SOR or one AFTER or one BEFORE operator\n");\r
+        return EFI_INVALID_PARAMETER;\r
+\r
+      } else if (Dep_Flag) {\r
+\r
+        printf ("The BEFORE operator must be the first operator following DEPENDENCY_START\n");\r
+        return EFI_INVALID_PARAMETER;\r
+\r
+      } else {\r
+        fputc (EFI_DEP_BEFORE, OutFile);\r
+        OutFileSize++;\r
+        Ptrx += sizeof (OPERATOR_BEFORE);\r
+        Before_Flag = TRUE;\r
+      }\r
+    } else if (strncmp (Ptrx, OPERATOR_AFTER, strlen (OPERATOR_AFTER)) == 0) {\r
+      //\r
+      //  Checks for some invalid dependencies\r
+      //\r
+      if (Before_Flag) {\r
+\r
+        printf ("A BEFORE operator was detected.\n");\r
+        printf ("There can only be one SOR or one AFTER or one BEFORE operator\n");\r
+        return EFI_INVALID_PARAMETER;\r
+\r
+      } else if (After_Flag) {\r
+\r
+        printf ("Another AFTER operator was detected.\n");\r
+        printf ("There can only be one SOR or one AFTER or one BEFORE operator\n");\r
+        return EFI_INVALID_PARAMETER;\r
+\r
+      } else if (SOR_Flag) {\r
+\r
+        printf ("A SOR operator was detected.\n");\r
+        printf ("There can only be one SOR or one AFTER or one BEFORE operator\n");\r
+        return EFI_INVALID_PARAMETER;\r
+\r
+      } else if (Dep_Flag) {\r
+\r
+        printf ("The AFTER operator must be the first operator following DEPENDENCY_START\n");\r
+        return EFI_INVALID_PARAMETER;\r
+\r
+      } else {\r
+        fputc (EFI_DEP_AFTER, OutFile);\r
+        OutFileSize++;\r
+        Ptrx += sizeof (OPERATOR_AFTER);\r
+        Dep_Flag    = TRUE;\r
+        After_Flag  = TRUE;\r
+      }\r
+    } else if (strncmp (Ptrx, OPERATOR_AND, strlen (OPERATOR_AND)) == 0) {\r
+      while (StackPtr != EvaluationStack) {\r
+        Opcode = PopOpCode ((VOID **) &StackPtr);\r
+        if (Opcode != DXE_DEP_LEFT_PARENTHESIS) {\r
+          fputc (Opcode, OutFile);\r
+          OutFileSize++;\r
+        } else {\r
+          PushOpCode ((VOID **) &StackPtr, DXE_DEP_LEFT_PARENTHESIS);\r
+          break;\r
+        }\r
+      }\r
+\r
+      PushOpCode ((VOID **) &StackPtr, EFI_DEP_AND);\r
+      Ptrx += sizeof (OPERATOR_AND);\r
+      Dep_Flag = TRUE;\r
+\r
+    } else if (strncmp (Ptrx, OPERATOR_OR, strlen (OPERATOR_OR)) == 0) {\r
+      while (StackPtr != EvaluationStack) {\r
+        Opcode = PopOpCode ((VOID **) &StackPtr);\r
+        if (Opcode != DXE_DEP_LEFT_PARENTHESIS) {\r
+          fputc (Opcode, OutFile);\r
+          OutFileSize++;\r
+        } else {\r
+          PushOpCode ((VOID **) &StackPtr, DXE_DEP_LEFT_PARENTHESIS);\r
+          break;\r
+        }\r
+      }\r
+\r
+      PushOpCode ((VOID **) &StackPtr, EFI_DEP_OR);\r
+      Ptrx += sizeof (OPERATOR_OR);\r
+      Dep_Flag = TRUE;\r
+\r
+    } else if (strncmp (Ptrx, OPERATOR_NOT, strlen (OPERATOR_NOT)) == 0) {\r
+      while (StackPtr != EvaluationStack) {\r
+        Opcode = PopOpCode ((VOID **) &StackPtr);\r
+        if (Opcode != DXE_DEP_LEFT_PARENTHESIS) {\r
+          fputc (Opcode, OutFile);\r
+          OutFileSize++;\r
+        } else {\r
+          PushOpCode ((VOID **) &StackPtr, DXE_DEP_LEFT_PARENTHESIS);\r
+          break;\r
+        }\r
+      }\r
+\r
+      PushOpCode ((VOID **) &StackPtr, EFI_DEP_NOT);\r
+      Ptrx += sizeof (OPERATOR_NOT);\r
+      Dep_Flag = TRUE;\r
+\r
+    } else if (*Ptrx == '\t') {\r
+\r
+      printf ("File contains tabs. This violates the coding standard\n");\r
+      return EFI_INVALID_PARAMETER;\r
+\r
+    } else if (*Ptrx == '\n') {\r
+      //\r
+      // Skip the newline character in the file\r
+      //\r
+      Ptrx++;\r
+\r
+    } else if (strncmp (Ptrx, OPERATOR_LEFT_PARENTHESIS, strlen (OPERATOR_LEFT_PARENTHESIS)) == 0) {\r
+      PushOpCode ((VOID **) &StackPtr, DXE_DEP_LEFT_PARENTHESIS);\r
+\r
+      Ptrx += strlen (OPERATOR_LEFT_PARENTHESIS);\r
+      Dep_Flag = TRUE;\r
+\r
+    } else if (strncmp (Ptrx, OPERATOR_RIGHT_PARENTHESIS, strlen (OPERATOR_RIGHT_PARENTHESIS)) == 0) {\r
+      while (StackPtr != EvaluationStack) {\r
+        Opcode = PopOpCode ((VOID **) &StackPtr);\r
+        if (Opcode != DXE_DEP_LEFT_PARENTHESIS) {\r
+          fputc (Opcode, OutFile);\r
+          OutFileSize++;\r
+        } else {\r
+          break;\r
+        }\r
+      }\r
+\r
+      Ptrx += strlen (OPERATOR_RIGHT_PARENTHESIS);\r
+      Dep_Flag = TRUE;\r
+\r
+    } else if (strncmp (Ptrx, OPERATOR_TRUE, strlen (OPERATOR_TRUE)) == 0) {\r
+\r
+      fputc (EFI_DEP_TRUE, OutFile);\r
+\r
+      OutFileSize++;\r
+\r
+      //\r
+      // OutFileSize += sizeof (EFI_DEP_TRUE);\r
+      //\r
+      Dep_Flag = TRUE;\r
+\r
+      Ptrx += strlen (OPERATOR_TRUE);\r
+\r
+    } else if (strncmp (Ptrx, OPERATOR_FALSE, strlen (OPERATOR_FALSE)) == 0) {\r
+\r
+      fputc (EFI_DEP_FALSE, OutFile);\r
+\r
+      OutFileSize++;\r
+\r
+      //\r
+      // OutFileSize += sizeof (EFI_DEP_FALSE);\r
+      //\r
+      Dep_Flag = TRUE;\r
+\r
+      Ptrx += strlen (OPERATOR_FALSE);\r
+\r
+    } else if (*Ptrx == '{') {\r
+      Ptrx++;\r
+\r
+      if (*Ptrx == ' ') {\r
+        Ptrx++;\r
+      }\r
+\r
+      {\r
+        int byte_index;\r
+        // This is an array of UINT32s. sscanf will trash memory\r
+        // if you try to read into a UINT8 with a %x formatter.\r
+        UINT32 Guid_Data4[8];\r
+\r
+        ArgCountParsed = sscanf (\r
+                         Ptrx,\r
+            "%x, %x, %x, { %x, %x, %x, %x, %x, %x, %x, %x }",\r
+                         &Guid.Data1,\r
+                         &Guid.Data2,\r
+                         &Guid.Data3,\r
+                         &Guid_Data4[0],\r
+                         &Guid_Data4[1],\r
+                         &Guid_Data4[2],\r
+                         &Guid_Data4[3],\r
+                         &Guid_Data4[4],\r
+                         &Guid_Data4[5],\r
+                         &Guid_Data4[6],\r
+                         &Guid_Data4[7]\r
+                         );\r
+        \r
+        // Now we can copy the 32 bit ints into the GUID.\r
+        for (byte_index=0; byte_index<8; byte_index++) {\r
+          Guid.Data4[byte_index] = (UINT8) Guid_Data4[byte_index];\r
+        }\r
+      }\r
+\r
+      if (ArgCountParsed != 11) {\r
+        printf ("We have found an illegal GUID\n");\r
+        printf ("Fix your depex\n");\r
+        exit (-1);\r
+      }\r
+\r
+      while (*Ptrx != '}') {\r
+        Ptrx++;\r
+      }\r
+\r
+    Ptrx++;\r
+      while (*Ptrx != '}') {\r
+        Ptrx++;\r
+      }\r
+    //\r
+      // Absorb the closing }\r
+      //\r
+      Ptrx++;\r
+\r
+      //\r
+      // Don't provide a PUSH Opcode for the Before and After case\r
+      //\r
+      if ((!Before_Flag) && (!After_Flag)) {\r
+        fputc (EFI_DEP_PUSH, OutFile);\r
+        OutFileSize++;\r
+      }\r
+\r
+      fwrite (&Guid, sizeof (EFI_GUID), 1, OutFile);\r
+\r
+      OutFileSize += sizeof (EFI_GUID);\r
+      Dep_Flag = TRUE;\r
+\r
+    } else if (strncmp (Ptrx, DEPENDENCY_END, strlen (DEPENDENCY_END)) == 0) {\r
+      NotDone = FALSE;\r
+    } else {\r
+      //\r
+      // Not a valid construct. Null terminate somewhere out there and\r
+      // print an error message.\r
+      //\r
+      *(Ptrx + 20) = 0;\r
+      printf (TOOL_NAME " ERROR: Unrecognized input at: \"%s\"...\n", Ptrx);\r
+      return EFI_INVALID_PARAMETER;\r
+    }\r
+  }\r
+  //\r
+  //  DRAIN();\r
+  //\r
+  while (StackPtr != EvaluationStack) {\r
+    fputc (PopOpCode ((VOID **) &StackPtr), OutFile);\r
+    OutFileSize++;\r
+  }\r
+\r
+  if (OutFileSize == 0) {\r
+    printf ("Grammer contains no operators or constants\n");\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  fputc (EFI_DEP_END, OutFile);\r
+\r
+  OutFileSize++;\r
+\r
+  //\r
+  //  Checks for invalid padding values\r
+  //\r
+  if (Padding < 0) {\r
+\r
+    printf ("The inputted padding value was %d\n", Padding);\r
+    printf ("The optional padding value can not be less than ZERO\n");\r
+    return EFI_INVALID_PARAMETER;\r
+\r
+  } else if (Padding > 0) {\r
+\r
+    while ((OutFileSize % Padding) != 0) {\r
+\r
+      fputc (' ', OutFile);\r
+      OutFileSize++;\r
+    }\r
+  }\r
+\r
+  Results = (UINTN) fclose (InFile);\r
+  if (Results != 0) {\r
+    printf ("FCLOSE failed\n");\r
+  }\r
+\r
+  Results = (UINTN) fclose (OutFile);\r
+  if (Results != 0) {\r
+    printf ("FCLOSE failed\n");\r
+  }\r
+\r
+  free (Buffer);\r
+  free (EvaluationStack);\r
+\r
+  return EFI_SUCCESS;\r
+} // End GenerateDependencyExpression function\r
+\r
+int\r
+main (\r
+  IN UINTN argc,\r
+  IN CHAR8 *argv[]\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Parse user entries.  Print some rudimentary help\r
+\r
+Arguments:\r
+\r
+  argc    The count of input arguments\r
+  argv    The input arguments string array\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS             The function completed successfully.\r
+  EFI_INVALID_PARAMETER   One of the input parameters was invalid or one of the parameters in the text file was invalid.\r
+  EFI_OUT_OF_RESOURCES    Unable to allocate memory.\r
+  EFI_ABORTED             Unable to open/create a file or a misc error.\r
+\r
+--*/\r
+// TODO:    ] - add argument and description to function comment\r
+{\r
+  FILE    *OutFile;\r
+  FILE    *InFile;\r
+  UINT8   Padding;\r
+  UINTN   Index;\r
+  BOOLEAN Input_Flag;\r
+  BOOLEAN Output_Flag;\r
+  BOOLEAN Pad_Flag;\r
+\r
+  InFile      = NULL;\r
+  OutFile     = NULL;\r
+  Padding     = 0;\r
+  Input_Flag  = FALSE;\r
+  Output_Flag = FALSE;\r
+  Pad_Flag    = FALSE;\r
+\r
+  if (argc < 5) {\r
+    printf ("Not enough arguments\n");\r
+    PrintGenDepexUsageInfo ();\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  for (Index = 1; Index < argc - 1; Index++) {\r
+\r
+    if ((strcmp (argv[Index], "-I") == 0) || (strcmp (argv[Index], "-i") == 0)) {\r
+\r
+      if (!Input_Flag) {\r
+\r
+        InFile      = fopen (argv[Index + 1], "rb");\r
+        Input_Flag  = TRUE;\r
+\r
+      } else {\r
+        printf ("GenDepex only allows one INPUT (-I) argument\n");\r
+        return EFI_INVALID_PARAMETER;\r
+      }\r
+\r
+    } else if ((strcmp (argv[Index], "-O") == 0) || (strcmp (argv[Index], "-o") == 0)) {\r
+\r
+      if (!Output_Flag) {\r
+\r
+        OutFile     = fopen (argv[Index + 1], "wb");\r
+        Output_Flag = TRUE;\r
+\r
+      } else {\r
+        printf ("GenDepex only allows one OUTPUT (-O) argument\n");\r
+        return EFI_INVALID_PARAMETER;\r
+      }\r
+\r
+    } else if ((strcmp (argv[Index], "-P") == 0) || (strcmp (argv[Index], "-p") == 0)) {\r
+\r
+      if (!Pad_Flag) {\r
+\r
+        Padding   = (UINT8) atoi (argv[Index + 1]);\r
+        Pad_Flag  = TRUE;\r
+\r
+      } else {\r
+        printf ("GenDepex only allows one PADDING (-P) argument\n");\r
+        return EFI_INVALID_PARAMETER;\r
+      }\r
+    }\r
+  }\r
+\r
+  PrintGenDepexUtilityInfo ();\r
+\r
+  if (InFile == NULL) {\r
+    printf ("Can not open <INFILE> for reading.\n");\r
+    PrintGenDepexUsageInfo ();\r
+    return EFI_ABORTED;\r
+  }\r
+\r
+  if (OutFile == NULL) {\r
+    printf ("Can not open <OUTFILE> for writting.\n");\r
+    PrintGenDepexUsageInfo ();\r
+    return EFI_ABORTED;\r
+  }\r
+\r
+  return GenerateDependencyExpression (InFile, OutFile, Padding);\r
+}\r
diff --git a/Tools/CodeTools/Source/GenDepex/GenDepex.h b/Tools/CodeTools/Source/GenDepex/GenDepex.h
new file mode 100644 (file)
index 0000000..b198156
--- /dev/null
@@ -0,0 +1,71 @@
+/*++\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+  Module Name:  \r
+          GenDepex.h\r
+\r
+  Abstract:\r
+          This file contains the relevant declarations required\r
+          to generate a binary Dependency File\r
+\r
+  Complies with Tiano C Coding Standards Document, version 0.31, 12 Dec 2000.\r
+\r
+--*/\r
+\r
+#ifndef _EFI_GEN_DEPEX_H\r
+#define _EFI_GEN_DEPEX_H\r
+\r
+\r
+#include <stdio.h>\r
+#include <stdlib.h>\r
+#include <memory.h>\r
+#include <string.h>\r
+#ifndef __GNUC__\r
+#include <malloc.h>\r
+#endif\r
+\r
+#include <Common/UefiBaseTypes.h>\r
+#include <Common/Dependency.h>\r
+\r
+#define DEPENDENCY_START            "DEPENDENCY_START"\r
+#define OPERATOR_BEFORE             "BEFORE"\r
+#define OPERATOR_AFTER              "AFTER"\r
+#define OPERATOR_AND                "AND"\r
+#define OPERATOR_OR                 "OR"\r
+#define OPERATOR_NOT                "NOT"\r
+#define OPERATOR_TRUE               "TRUE"\r
+#define OPERATOR_FALSE              "FALSE"\r
+#define OPERATOR_SOR                "SOR"\r
+#define OPERATOR_END                "END"\r
+#define OPERATOR_LEFT_PARENTHESIS   "("\r
+#define OPERATOR_RIGHT_PARENTHESIS  ")"\r
+#define DEPENDENCY_END              "DEPENDENCY_END"\r
+\r
+#define DXE_DEP_LEFT_PARENTHESIS    0x0a\r
+#define DXE_DEP_RIGHT_PARENTHESIS   0x0b\r
+\r
+#define LINESIZE                    320\r
+#define SIZE_A_SYMBOL               60\r
+#define DEPENDENCY_OPCODE           UINT8\r
+#define EVAL_STACK_SIZE             0x1024\r
+#define BUFFER_SIZE                 0x100\r
+\r
+//\r
+// Utility Name\r
+//\r
+#define UTILITY_NAME  "GenDepex"\r
+\r
+//\r
+// Utility version information\r
+//\r
+#define UTILITY_MAJOR_VERSION 0\r
+#define UTILITY_MINOR_VERSION 5\r
+\r
+#endif\r
diff --git a/Tools/CodeTools/Source/GenDepex/build.xml b/Tools/CodeTools/Source/GenDepex/build.xml
new file mode 100644 (file)
index 0000000..568177a
--- /dev/null
@@ -0,0 +1,68 @@
+<?xml version="1.0" ?>\r
+<!--\r
+Copyright (c) 2006, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+-->\r
+<project default="GenTool" basedir=".">\r
+<!--\r
+    EDK GenDepex Tool\r
+  Copyright (c) 2006, Intel Corporation\r
+-->\r
+  <property name="ToolName" value="GenDepex"/>\r
+  <property name="FileSet" value="DepexParser.c GenDepex.c GenDepex.h"/>\r
+\r
+  <taskdef resource="cpptasks.tasks"/>\r
+  <typedef resource="cpptasks.types"/>\r
+  <taskdef resource="net/sf/antcontrib/antlib.xml"/>\r
+\r
+  <property name="LINK_OUTPUT_TYPE" value="static"/>\r
+  <property name="BUILD_DIR" value="${PACKAGE_DIR}/${ToolName}/tmp"/>\r
+\r
+  <target name="GenTool" depends="init, Tool">\r
+    <echo message="The EDK Tool: ${ToolName} build has completed!"/>\r
+  </target>\r
+\r
+  <target name="init">\r
+    <echo message="Building the EDK Tool: ${ToolName}"/>\r
+    <mkdir dir="${BUILD_DIR}"/>\r
+  </target>\r
+\r
+  <target name="Tool" depends="init">\r
+    <cc name="${ToolChain}" objdir="${BUILD_DIR}" \r
+        outfile="${BIN_DIR}/${ToolName}"\r
+        outtype="executable"\r
+        debug="true"\r
+        optimize="speed">\r
+      <compilerarg value="${ExtraArgus}" if="ExtraArgus" />\r
+\r
+      <fileset dir="${basedir}/${ToolName}" \r
+        includes="${FileSet}" />\r
+\r
+      <includepath path="${PACKAGE_DIR}/Include"/>\r
+      <includepath path="${PACKAGE_DIR}/Include/Ia32"/>\r
+      <includepath path="${PACKAGE_DIR}/Common"/>\r
+    </cc>\r
+  </target>\r
+\r
+  <target name="clean">\r
+    <echo message="Removing Intermediate Files Only"/>  \r
+    <delete>\r
+      <fileset dir="${BUILD_DIR}" includes="*.obj"/>\r
+    </delete>\r
+  </target>\r
+\r
+  <target name="cleanall">\r
+    <echo message="Removing Object Files and the Executable: ${ToolName}${ext_exe}"/>  \r
+    <delete failonerror="false" quiet="true" includeEmptyDirs="true">\r
+      <fileset dir="${BUILD_DIR}"/>\r
+      <fileset file="${BIN_DIR}/${ToolName}${ext_exe}"/>\r
+    </delete>\r
+  </target>\r
+\r
+</project>\r
diff --git a/Tools/CodeTools/Source/GenFfsFile/GenFfsFile.c b/Tools/CodeTools/Source/GenFfsFile/GenFfsFile.c
new file mode 100644 (file)
index 0000000..1eea09f
--- /dev/null
@@ -0,0 +1,2646 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  GenFfsFile.c\r
+\r
+Abstract:\r
+\r
+  This file contains functions required to generate a Firmware File System\r
+  file.\r
+\r
+--*/\r
+\r
+#include <stdio.h>\r
+#include <ctype.h>  // for isalpha()\r
+//\r
+// include file for _spawnv\r
+//\r
+#ifndef __GNUC__\r
+#include <process.h>\r
+#endif\r
+#include <stdlib.h>\r
+#include <string.h>\r
+\r
+#include <Common/UefiBaseTypes.h>\r
+#include <Common/FirmwareVolumeImageFormat.h>\r
+#include <Common/FirmwareFileSystem.h>\r
+#include <Common/FirmwareVolumeHeader.h>\r
+#include <Common/FirmwareVolumeImageFormat.h>\r
+\r
+#include "ParseInf.h"\r
+#include "EfiCompress.h"\r
+#include "EfiCustomizedCompress.h"\r
+#include "Crc32.h"\r
+#include "GenFfsFile.h"\r
+#include "CommonLib.h"\r
+#include "EfiUtilityMsgs.h"\r
+#include "SimpleFileParsing.h"\r
+\r
+#define UTILITY_NAME    "GenFfsFile"\r
+#define TOOLVERSION     "0.32"\r
+#define MAX_ARRAY_SIZE  100\r
+\r
+static\r
+INT32\r
+GetNextLine (\r
+  OUT CHAR8       *Destination,\r
+  IN FILE         *Package,\r
+  IN OUT UINT32   *LineNumber\r
+  );\r
+\r
+static\r
+void\r
+CheckSlash (\r
+  IN OUT CHAR8  *String,\r
+  IN FILE       *In,\r
+  IN OUT UINT32 *LineNumber\r
+  );\r
+\r
+static\r
+INT32\r
+FindSectionInPackage (\r
+  IN CHAR8        *BuildDirectory,\r
+  IN FILE         *OverridePackage,\r
+  IN OUT UINT32   *LineNumber\r
+  );\r
+\r
+static\r
+STATUS\r
+ProcessCommandLineArgs (\r
+  int     Argc,\r
+  char    *Argv[]\r
+  );\r
+\r
+static\r
+void\r
+PrintUsage (\r
+  void\r
+  );\r
+\r
+//\r
+// Keep globals in this structure\r
+//\r
+static struct {\r
+  UINT8   BuildDirectory[_MAX_PATH];\r
+  UINT8   PrimaryPackagePath[_MAX_PATH];\r
+  UINT8   OverridePackagePath[_MAX_PATH];\r
+  BOOLEAN Verbose;\r
+} mGlobals;\r
+\r
+static EFI_GUID mZeroGuid = { 0 };\r
+\r
+static\r
+void\r
+StripQuotes (\r
+  IN OUT CHAR8 *String\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Removes quotes and/or whitespace from around a string\r
+\r
+Arguments:\r
+\r
+ String    - String to remove quotes from\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+{\r
+  UINTN Index;\r
+  UINTN Index2;\r
+  UINTN StrLen;\r
+\r
+  Index2  = strspn (String, "\" \t\n");\r
+  StrLen  = strlen (String);\r
+\r
+  for (Index = Index2; String[Index] != '\"', Index < StrLen; Index++) {\r
+    String[Index - Index2] = String[Index];\r
+  }\r
+\r
+  String[Index - Index2] = 0;\r
+}\r
+\r
+static\r
+void\r
+PrintUsage (\r
+  void\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Print Error / Help message.\r
+\r
+Arguments:\r
+\r
+  void\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+{\r
+  printf ("Usage:\n");\r
+  printf (UTILITY_NAME " -b \"build directory\" -p1 \"package1.inf\" -p2 \"package2.inf\" -v\n");\r
+  printf ("   -b \"build directory\":\n ");\r
+  printf ("       specifies the full path to the component build directory.\n");\r
+  printf ("   -p1 \"P1_path\":\n");\r
+  printf ("       specifies fully qualified file name to the primary package file.\n");\r
+  printf ("       This file will normally exist in the same directory as the makefile\n");\r
+  printf ("       for the component. Required.\n");\r
+  printf ("   -p2 \"P2_path\":\n");\r
+  printf ("       specifies fully qualified file name to the override package file.\n");\r
+  printf ("       This file will normally exist in the build tip. Optional.\n");\r
+}\r
+\r
+static\r
+INT32\r
+TestComment (\r
+  IN CHAR8  *String,\r
+  IN FILE   *In\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Tests input string to see if it is a comment, and if so goes to the next line in the file that is not a comment\r
+\r
+Arguments:\r
+\r
+  String      - String to test\r
+\r
+  In          - Open file to move pointer within\r
+\r
+Returns:\r
+\r
+  -1          - End of file reached\r
+   0          - Not a comment\r
+   1          - Comment bypassed\r
+\r
+--*/\r
+{\r
+  CHAR8 CharBuffer;\r
+\r
+  CharBuffer = 0;\r
+  if ((String[0] == '/') && (String[1] == '/')) {\r
+    while (CharBuffer != '\n') {\r
+      fscanf (In, "%c", &CharBuffer);\r
+      if (feof (In)) {\r
+        return -1;\r
+      }\r
+    }\r
+  } else {\r
+    return 0;\r
+  }\r
+\r
+  return 1;\r
+}\r
+\r
+static\r
+void\r
+BreakString (\r
+  IN CONST CHAR8 *Source,\r
+  OUT CHAR8      *Destination,\r
+  IN INTN        Direction\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Takes an input string and returns either the part before the =, or the part after the =, depending on direction\r
+\r
+Arguments:\r
+\r
+  Source      - String to break\r
+\r
+  Destination - Buffer to place new string in\r
+\r
+  Direction   - 0 to return all of source string before =\r
+                1 to return all of source string after =\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+{\r
+  UINTN Index;\r
+  UINTN Index2;\r
+\r
+  Index   = 0;\r
+  Index2  = 0;\r
+\r
+  if (strchr (Source, '=') == NULL) {\r
+    strcpy (Destination, Source);\r
+\r
+    return ;\r
+  }\r
+\r
+  if (Direction == 0) {\r
+    //\r
+    // return part of string before =\r
+    //\r
+    while (Source[Index] != '=') {\r
+      Destination[Index] = Source[Index++];\r
+    }\r
+\r
+    Destination[Index] = 0;\r
+  } else {\r
+    //\r
+    // return part of string after =\r
+    //\r
+    strcpy (Destination, strchr (Source, '=') + 1);\r
+  }\r
+}\r
+\r
+static\r
+INT32\r
+GetNextLine (\r
+  OUT CHAR8       *Destination,\r
+  IN FILE         *Package,\r
+  IN OUT UINT32   *LineNumber\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Gets the next non-commented line from the file\r
+\r
+Arguments:\r
+\r
+  Destination - Where to put string\r
+\r
+  Package     - Package to get string from\r
+  \r
+  LineNumber  - The actual line number.\r
+\r
+Returns:\r
+\r
+  -1          - End of file reached\r
+   0          - Success\r
+\r
+--*/\r
+{\r
+  CHAR8 String[_MAX_PATH];\r
+  fscanf (Package, "%s", &String);\r
+  if (feof (Package)) {\r
+    return -1;\r
+  }\r
+\r
+  while (TestComment (String, Package) == 1) {\r
+    fscanf (Package, "%s", &String);\r
+    if (feof (Package)) {\r
+      return -1;\r
+    }\r
+  }\r
+\r
+  strcpy (Destination, String);\r
+  return 0;\r
+}\r
+\r
+static\r
+VOID\r
+CheckSlash (\r
+  IN OUT CHAR8  *String,\r
+  IN FILE       *In,\r
+  IN OUT UINT32 *LineNumber\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Checks to see if string is line continuation character, if so goes to next valid line\r
+\r
+Arguments:\r
+\r
+  String      - String to test\r
+\r
+  In          - Open file to move pointer within\r
+  \r
+  LineNumber  - The line number.\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+{\r
+  CHAR8 ByteBuffer;\r
+  ByteBuffer = 0;\r
+\r
+  switch (String[0]) {\r
+\r
+  case '\\':\r
+    while (String[0] == '\\') {\r
+      while (ByteBuffer != '\n') {\r
+        fscanf (In, "%c", &ByteBuffer);\r
+      }\r
+      (*LineNumber)++;\r
+      if (GetNextLine (String, In, LineNumber) == -1) {\r
+        return ;\r
+      }\r
+    }\r
+    break;\r
+\r
+  case '\n':\r
+    (*LineNumber)++;\r
+    while (String[0] == '\n') {\r
+      if (GetNextLine (String, In, LineNumber) == -1) {\r
+        return ;\r
+      }\r
+    }\r
+    break;\r
+\r
+  default:\r
+    break;\r
+\r
+  }\r
+\r
+}\r
+\r
+static\r
+INT32\r
+FindSectionInPackage (\r
+  IN CHAR8        *BuildDirectory,\r
+  IN FILE         *OverridePackage,\r
+  IN OUT UINT32   *LineNumber\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Finds the matching section within the package\r
+\r
+Arguments:\r
+\r
+  BuildDirectory  - name of section to find\r
+\r
+  OverridePackage - Package file to search within\r
+  \r
+  LineNumber      - The line number.\r
+\r
+Returns:\r
+\r
+  -1          - End of file reached\r
+   0          - Success\r
+\r
+--*/\r
+{\r
+  CHAR8 String[_MAX_PATH];\r
+  CHAR8 NewString[_MAX_PATH];\r
+  String[0] = 0;\r
+\r
+  while (strcmp (BuildDirectory, String) != 0) {\r
+    if (GetNextLine (NewString, OverridePackage, LineNumber) != 0) {\r
+      return -1;\r
+    }\r
+\r
+    if (NewString[0] == '[') {\r
+      if (NewString[strlen (NewString) - 1] != ']') {\r
+        //\r
+        // have to construct string.\r
+        //\r
+        strcpy (String, NewString + 1);\r
+\r
+        while (1) {\r
+          fscanf (OverridePackage, "%s", &NewString);\r
+          if (feof (OverridePackage)) {\r
+            return -1;\r
+          }\r
+\r
+          if (NewString[0] != ']') {\r
+            if (strlen (String) != 0) {\r
+              strcat (String, " ");\r
+            }\r
+\r
+            strcat (String, NewString);\r
+            if (String[strlen (String) - 1] == ']') {\r
+              String[strlen (String) - 1] = 0;\r
+              break;\r
+            }\r
+          } else {\r
+            break;\r
+          }\r
+        }\r
+      } else {\r
+        NewString[strlen (NewString) - 1] = 0;\r
+        strcpy (String, NewString + 1);\r
+      }\r
+    }\r
+  }\r
+\r
+  return 0;\r
+}\r
+\r
+static\r
+EFI_STATUS\r
+GenSimpleGuidSection (\r
+  IN OUT UINT8  *FileBuffer,\r
+  IN OUT UINT32 *BufferSize,\r
+  IN UINT32     DataSize,\r
+  IN EFI_GUID   SignGuid,\r
+  IN UINT16     GuidedSectionAttributes\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  add GUIDed section header for the data buffer.\r
+  data stays in same location (overwrites source data).\r
+\r
+Arguments:\r
+\r
+  FileBuffer  - Buffer containing data to sign\r
+\r
+  BufferSize  - On input, the size of FileBuffer. On output, the size of\r
+                actual section data (including added section header).\r
+\r
+  DataSize    - Length of data to Sign\r
+\r
+  SignGuid    - Guid to be add.\r
+  \r
+  GuidedSectionAttributes - The section attribute.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS           - Successful\r
+  EFI_OUT_OF_RESOURCES  - Not enough resource.\r
+\r
+--*/\r
+{\r
+  UINT32                    TotalSize;\r
+\r
+  EFI_GUID_DEFINED_SECTION  GuidSectionHeader;\r
+  UINT8                     *SwapBuffer;\r
+\r
+  SwapBuffer = NULL;\r
+\r
+  if (DataSize == 0) {\r
+    *BufferSize = 0;\r
+\r
+    return EFI_SUCCESS;\r
+  }\r
+\r
+  TotalSize = DataSize + sizeof (EFI_GUID_DEFINED_SECTION);\r
+  GuidSectionHeader.CommonHeader.Type     = EFI_SECTION_GUID_DEFINED;\r
+  GuidSectionHeader.CommonHeader.Size[0]  = (UINT8) (TotalSize & 0xff);\r
+  GuidSectionHeader.CommonHeader.Size[1]  = (UINT8) ((TotalSize & 0xff00) >> 8);\r
+  GuidSectionHeader.CommonHeader.Size[2]  = (UINT8) ((TotalSize & 0xff0000) >> 16);\r
+  memcpy (&(GuidSectionHeader.SectionDefinitionGuid), &SignGuid, sizeof (EFI_GUID));\r
+  GuidSectionHeader.Attributes  = GuidedSectionAttributes;\r
+  GuidSectionHeader.DataOffset  = sizeof (EFI_GUID_DEFINED_SECTION);\r
+\r
+  SwapBuffer                    = (UINT8 *) malloc (DataSize);\r
+  if (SwapBuffer == NULL) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+\r
+  memcpy (SwapBuffer, FileBuffer, DataSize);\r
+  memcpy (FileBuffer, &GuidSectionHeader, sizeof (EFI_GUID_DEFINED_SECTION));\r
+  memcpy (FileBuffer + sizeof (EFI_GUID_DEFINED_SECTION), SwapBuffer, DataSize);\r
+\r
+  //\r
+  // Make sure section ends on a DWORD boundary\r
+  //\r
+  while ((TotalSize & 0x03) != 0) {\r
+    FileBuffer[TotalSize] = 0;\r
+    TotalSize++;\r
+  }\r
+\r
+  *BufferSize = TotalSize;\r
+\r
+  if (SwapBuffer != NULL) {\r
+    free (SwapBuffer);\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+static\r
+EFI_STATUS\r
+CompressSection (\r
+  UINT8  *FileBuffer,\r
+  UINT32 *BufferSize,\r
+  UINT32 DataSize,\r
+  CHAR8  *Type\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Compress the data and add section header for the compressed data.\r
+  Compressed data (with section header) stays in same location as the source\r
+  (overwrites source data).\r
+\r
+Arguments:\r
+\r
+  FileBuffer  - Buffer containing data to Compress\r
+\r
+  BufferSize  - On input, the size of FileBuffer. On output, the size of\r
+                actual compressed data (including added section header).\r
+                When buffer is too small, this value indicates the size needed.\r
+\r
+  DataSize    - The size of data to compress\r
+\r
+  Type        - The compression type (not used currently).\r
+                Assume EFI_HEAVY_COMPRESSION.\r
+\r
+Returns:\r
+\r
+  EFI_BUFFER_TOO_SMALL - Buffer size is too small.\r
+  EFI_UNSUPPORTED      - Compress type can not be supported.\r
+  EFI_SUCCESS          - Successful\r
+  EFI_OUT_OF_RESOURCES - Not enough resource.\r
+\r
+--*/\r
+{\r
+  EFI_STATUS              Status;\r
+  UINT8                   *CompData;\r
+  UINT32                  CompSize;\r
+  UINT32                  TotalSize;\r
+  EFI_COMPRESSION_SECTION CompressionSet;\r
+  UINT8                   CompressionType;\r
+  COMPRESS_FUNCTION       CompressFunction;\r
+\r
+  Status            = EFI_SUCCESS;\r
+  CompData          = NULL;\r
+  CompSize          = 0;\r
+  TotalSize         = 0;\r
+  CompressFunction  = NULL;\r
+\r
+  //\r
+  // Get the compress type\r
+  //\r
+  if (strcmpi (Type, "Dummy") == 0) {\r
+    //\r
+    // Added "Dummy" to keep backward compatibility.\r
+    //\r
+    CompressionType   = EFI_STANDARD_COMPRESSION;\r
+    CompressFunction  = (COMPRESS_FUNCTION) Compress;\r
+\r
+  } else if (strcmpi (Type, "LZH") == 0) {\r
+    //\r
+    // EFI stardard compression (LZH)\r
+    //\r
+    CompressionType   = EFI_STANDARD_COMPRESSION;\r
+    CompressFunction  = (COMPRESS_FUNCTION) Compress;\r
+\r
+  } else {\r
+    //\r
+    // Customized compression\r
+    //\r
+    Status = SetCustomizedCompressionType (Type);\r
+    if (EFI_ERROR (Status)) {\r
+      return Status;\r
+    }\r
+\r
+    CompressionType   = EFI_CUSTOMIZED_COMPRESSION;\r
+    CompressFunction  = (COMPRESS_FUNCTION) CustomizedCompress;\r
+  }\r
+  //\r
+  // Compress the raw data\r
+  //\r
+  Status = CompressFunction (FileBuffer, DataSize, CompData, &CompSize);\r
+  if (Status == EFI_BUFFER_TOO_SMALL) {\r
+    CompData = malloc (CompSize);\r
+    if (!CompData) {\r
+      return EFI_OUT_OF_RESOURCES;\r
+    }\r
+\r
+    Status = CompressFunction (FileBuffer, DataSize, CompData, &CompSize);\r
+  }\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    if (CompData != NULL) {\r
+      free (CompData);\r
+    }\r
+\r
+    return Status;\r
+  }\r
+\r
+  TotalSize = CompSize + sizeof (EFI_COMPRESSION_SECTION);\r
+\r
+  //\r
+  // Buffer too small?\r
+  //\r
+  if (TotalSize > *BufferSize) {\r
+    *BufferSize = TotalSize;\r
+    if (CompData != NULL) {\r
+      free (CompData);\r
+    }\r
+\r
+    return EFI_BUFFER_TOO_SMALL;\r
+  }\r
+  //\r
+  // Add the section header for the compressed data\r
+  //\r
+  CompressionSet.CommonHeader.Type    = EFI_SECTION_COMPRESSION;\r
+  CompressionSet.CommonHeader.Size[0] = (UINT8) (TotalSize & 0xff);\r
+  CompressionSet.CommonHeader.Size[1] = (UINT8) ((TotalSize & 0xff00) >> 8);\r
+  CompressionSet.CommonHeader.Size[2] = (UINT8) ((TotalSize & 0xff0000) >> 16);\r
+  CompressionSet.CompressionType      = CompressionType;\r
+  CompressionSet.UncompressedLength   = DataSize;\r
+\r
+  //\r
+  // Copy header and data to the buffer\r
+  //\r
+  memcpy (FileBuffer, &CompressionSet, sizeof (EFI_COMPRESSION_SECTION));\r
+  memcpy (FileBuffer + sizeof (CompressionSet), CompData, CompSize);\r
+\r
+  //\r
+  // Make sure section ends on a DWORD boundary\r
+  //\r
+  while ((TotalSize & 0x03) != 0) {\r
+    FileBuffer[TotalSize] = 0;\r
+    TotalSize++;\r
+  }\r
+\r
+  *BufferSize = TotalSize;\r
+\r
+  if (CompData != NULL) {\r
+    free (CompData);\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+static\r
+void\r
+StripParens (\r
+  IN OUT CHAR8 *String\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Removes Parenthesis from around a string\r
+\r
+Arguments:\r
+\r
+ String    - String to remove parens from\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+{\r
+  INT32 Index;\r
+\r
+  if (String[0] != '(') {\r
+    return ;\r
+  }\r
+\r
+  for (Index = 1; String[Index] != ')'; Index++) {\r
+    String[Index - 1] = String[Index];\r
+    if (String[Index] == 0) {\r
+      return ;\r
+    }\r
+  }\r
+\r
+  String[Index - 1] = 0;\r
+\r
+  return ;\r
+}\r
+\r
+static\r
+void\r
+StripEqualMark (\r
+  IN OUT CHAR8 *String\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Removes Equal Mark from around a string\r
+\r
+Arguments:\r
+\r
+ String    - String to remove equal mark from\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+{\r
+  INT32 Index;\r
+\r
+  if (String[0] != '=' && String[strlen (String) - 1] != '=') {\r
+    return ;\r
+  }\r
+\r
+  if (String[0] == '=') {\r
+\r
+    for (Index = 1; String[Index] != 0; Index++) {\r
+      String[Index - 1] = String[Index];\r
+    }\r
+\r
+    String[Index - 1] = 0;\r
+  }\r
+\r
+  if (String[strlen (String) - 1] == '=') {\r
+    String[strlen (String) - 1] = 0;\r
+  }\r
+\r
+  return ;\r
+}\r
+\r
+static\r
+INT32\r
+ProcessEnvironmentVariable (\r
+  IN CHAR8  *Buffer,\r
+  OUT CHAR8 *NewBuffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Converts environment variables to values\r
+\r
+Arguments:\r
+\r
+  Buffer      - Buffer containing Environment Variable String\r
+\r
+  NewBuffer   - Buffer containing value of environment variable\r
+\r
+\r
+Returns:\r
+\r
+  Number of characters from Buffer used\r
+\r
+--*/\r
+{\r
+  INT32 Index;\r
+  INT32 Index2;\r
+  CHAR8 VariableBuffer[_MAX_PATH];\r
+\r
+  Index   = 2;\r
+  Index2  = 0;\r
+\r
+  while (Buffer[Index] != ')') {\r
+    VariableBuffer[Index - 2] = Buffer[Index++];\r
+  }\r
+\r
+  VariableBuffer[Index - 2] = 0;\r
+  Index++;\r
+\r
+  if (getenv (VariableBuffer) != NULL) {\r
+    strcpy (NewBuffer, getenv (VariableBuffer));\r
+  } else {\r
+    printf ("Environment variable %s not found!\n", VariableBuffer);\r
+  }\r
+\r
+  return Index;\r
+}\r
+\r
+static\r
+void\r
+SplitAttributesField (\r
+  IN CHAR8       *Buffer,\r
+  IN CHAR8       *AttributesArray[],\r
+  IN OUT UINT32  *NumberOfAttributes\r
+  )\r
+/*\r
+  NumberOfAttributes: on input, it specifies the current number of attributes\r
+                      stored in AttributeArray.\r
+                      on output, it is updated to the latest number of attributes\r
+                      stored in AttributesArray.\r
+*/\r
+{\r
+  UINT32  Index;\r
+  UINT32  Index2;\r
+  UINT32  z;\r
+  CHAR8   *CharBuffer;\r
+\r
+  CharBuffer  = NULL;\r
+  CharBuffer  = (CHAR8 *) malloc (_MAX_PATH);\r
+  ZeroMem (CharBuffer, _MAX_PATH);\r
+\r
+  for (Index = 0, z = 0, Index2 = 0; Index < strlen (Buffer); Index++) {\r
+\r
+    if (Buffer[Index] != '|') {\r
+      CharBuffer[z] = Buffer[Index];\r
+      z++;\r
+    } else {\r
+\r
+      CharBuffer[z] = 0;\r
+      AttributesArray[*NumberOfAttributes + Index2] = CharBuffer;\r
+      Index2++;\r
+\r
+      //\r
+      // allocate new char buffer for the next attributes string\r
+      //\r
+      CharBuffer = (CHAR8 *) malloc (_MAX_PATH);\r
+      ZeroMem (CharBuffer, _MAX_PATH);\r
+      z = 0;\r
+    }\r
+  }\r
+\r
+  CharBuffer[z] = 0;\r
+  //\r
+  // record the last attributes string in the Buffer\r
+  //\r
+  AttributesArray[*NumberOfAttributes + Index2] = CharBuffer;\r
+  Index2++;\r
+\r
+  *NumberOfAttributes += Index2;\r
+\r
+  return ;\r
+}\r
+\r
+static\r
+INT32\r
+GetToolArguments (\r
+  CHAR8       *ToolArgumentsArray[],\r
+  FILE        *Package,\r
+  CHAR8       **PtrInputFileName,\r
+  CHAR8       **PtrOutputFileName,\r
+  EFI_GUID    *Guid,\r
+  UINT16      *GuidedSectionAttributes\r
+  )\r
+{\r
+  CHAR8       Buffer[_MAX_PATH];\r
+  BOOLEAN     ArgumentsFlag;\r
+  BOOLEAN     InputFlag;\r
+  BOOLEAN     OutputFlag;\r
+  BOOLEAN     GuidFlag;\r
+  BOOLEAN     AttributesFlag;\r
+  UINT32      argc;\r
+  UINT32      Index2;\r
+  UINT32      z;\r
+  CHAR8       *CharBuffer;\r
+  INT32       Index;\r
+  INT32       ReturnValue;\r
+  EFI_STATUS  Status;\r
+\r
+  CHAR8       *AttributesArray[MAX_ARRAY_SIZE];\r
+  UINT32      NumberOfAttributes;\r
+  CHAR8       *InputFileName;\r
+  CHAR8       *OutputFileName;\r
+  UINT32      LineNumber;\r
+  Buffer[_MAX_PATH];\r
+\r
+  ArgumentsFlag   = FALSE;\r
+  InputFlag       = FALSE;\r
+  OutputFlag      = FALSE;\r
+  GuidFlag        = FALSE;\r
+  AttributesFlag  = FALSE;\r
+  //\r
+  // Start at 1, since ToolArgumentsArray[0]\r
+  // is the program name.\r
+  //\r
+  argc            = 1;\r
+  Index2              = 0;\r
+\r
+  z                   = 0;\r
+  ReturnValue         = 0;\r
+  NumberOfAttributes  = 0;\r
+  InputFileName       = NULL;\r
+  OutputFileName      = NULL;\r
+\r
+  ZeroMem (Buffer, _MAX_PATH);\r
+  ZeroMem (AttributesArray, sizeof (CHAR8 *) * MAX_ARRAY_SIZE);\r
+  LineNumber = 0;\r
+  while (Buffer[0] != ')') {\r
+\r
+    if (GetNextLine (Buffer, Package, &LineNumber) != -1) {\r
+      CheckSlash (Buffer, Package, &LineNumber);\r
+      StripEqualMark (Buffer);\r
+    } else {\r
+      Error (NULL, 0, 0, "failed to get next line from package file", NULL);\r
+      return -1;\r
+    }\r
+\r
+    if (Buffer[0] == ')') {\r
+      break;\r
+    } else if (strcmpi (Buffer, "ARGS") == 0) {\r
+\r
+      ArgumentsFlag   = TRUE;\r
+      AttributesFlag  = FALSE;\r
+      continue;\r
+\r
+    } else if (strcmpi (Buffer, "INPUT") == 0) {\r
+\r
+      InputFlag       = TRUE;\r
+      ArgumentsFlag   = FALSE;\r
+      AttributesFlag  = FALSE;\r
+      continue;\r
+\r
+    } else if (strcmpi (Buffer, "OUTPUT") == 0) {\r
+\r
+      OutputFlag      = TRUE;\r
+      ArgumentsFlag   = FALSE;\r
+      AttributesFlag  = FALSE;\r
+      continue;\r
+\r
+    } else if (strcmpi (Buffer, "GUID") == 0) {\r
+\r
+      GuidFlag        = TRUE;\r
+      ArgumentsFlag   = FALSE;\r
+      AttributesFlag  = FALSE;\r
+      //\r
+      // fetch the GUID for the section\r
+      //\r
+      continue;\r
+\r
+    } else if (strcmpi (Buffer, "ATTRIBUTES") == 0) {\r
+\r
+      AttributesFlag  = TRUE;\r
+      ArgumentsFlag   = FALSE;\r
+      //\r
+      // fetch the GUIDed Section's Attributes\r
+      //\r
+      continue;\r
+\r
+    } else if (strcmpi (Buffer, "") == 0) {\r
+      continue;\r
+    }\r
+    //\r
+    // get all command arguments into ToolArgumentsArray\r
+    //\r
+    if (ArgumentsFlag) {\r
+\r
+      StripEqualMark (Buffer);\r
+\r
+      CharBuffer = (CHAR8 *) malloc (_MAX_PATH);\r
+      if (CharBuffer == NULL) {\r
+        goto ErrorExit;\r
+      }\r
+\r
+      ZeroMem (CharBuffer, sizeof (_MAX_PATH));\r
+\r
+      ToolArgumentsArray[argc] = CharBuffer;\r
+\r
+      if (Buffer[0] == '$') {\r
+        Index = ProcessEnvironmentVariable (&Buffer[0], ToolArgumentsArray[argc]);\r
+        //\r
+        // if there is string after the environment variable, cat it.\r
+        //\r
+        if ((UINT32) Index < strlen (Buffer)) {\r
+          strcat (ToolArgumentsArray[argc], &Buffer[Index]);\r
+        }\r
+      } else {\r
+        strcpy (ToolArgumentsArray[argc], Buffer);\r
+      }\r
+\r
+      argc += 1;\r
+      ToolArgumentsArray[argc] = NULL;\r
+      continue;\r
+    }\r
+\r
+    if (InputFlag) {\r
+\r
+      StripEqualMark (Buffer);\r
+\r
+      InputFileName = (CHAR8 *) malloc (_MAX_PATH);\r
+      if (InputFileName == NULL) {\r
+        goto ErrorExit;\r
+      }\r
+\r
+      ZeroMem (InputFileName, sizeof (_MAX_PATH));\r
+\r
+      if (Buffer[0] == '$') {\r
+        Index = ProcessEnvironmentVariable (&Buffer[0], InputFileName);\r
+        //\r
+        // if there is string after the environment variable, cat it.\r
+        //\r
+        if ((UINT32) Index < strlen (Buffer)) {\r
+          strcat (InputFileName, &Buffer[Index]);\r
+        }\r
+      } else {\r
+        strcpy (InputFileName, Buffer);\r
+      }\r
+\r
+      InputFlag = FALSE;\r
+      continue;\r
+    }\r
+\r
+    if (OutputFlag) {\r
+\r
+      StripEqualMark (Buffer);\r
+\r
+      OutputFileName = (CHAR8 *) malloc (_MAX_PATH);\r
+      if (OutputFileName == NULL) {\r
+        goto ErrorExit;\r
+      }\r
+\r
+      ZeroMem (OutputFileName, sizeof (_MAX_PATH));\r
+\r
+      if (Buffer[0] == '$') {\r
+        Index = ProcessEnvironmentVariable (&Buffer[0], OutputFileName);\r
+        //\r
+        // if there is string after the environment variable, cat it.\r
+        //\r
+        if ((UINT32) Index < strlen (Buffer)) {\r
+          strcat (OutputFileName, &Buffer[Index]);\r
+        }\r
+      } else {\r
+        strcpy (OutputFileName, Buffer);\r
+      }\r
+\r
+      OutputFlag = FALSE;\r
+      continue;\r
+    }\r
+\r
+    if (GuidFlag) {\r
+\r
+      StripEqualMark (Buffer);\r
+\r
+      Status = StringToGuid (Buffer, Guid);\r
+      if (EFI_ERROR (Status)) {\r
+        ReturnValue = -1;\r
+        goto ErrorExit;\r
+      }\r
+\r
+      GuidFlag = FALSE;\r
+    }\r
+\r
+    if (AttributesFlag) {\r
+\r
+      StripEqualMark (Buffer);\r
+\r
+      //\r
+      // there might be no space between each attribute in the statement,\r
+      // split them aside and return each attribute string\r
+      // in the AttributesArray\r
+      //\r
+      SplitAttributesField (Buffer, AttributesArray, &NumberOfAttributes);\r
+    }\r
+  }\r
+  //\r
+  // ReplaceVariableInBuffer (ToolArgumentsArray,&i,"INPUT",InputVariable,j);\r
+  // ReplaceVariableInBuffer (ToolArgumentsArray,&i,"OUTPUT",&TargetFileName,1);\r
+  //\r
+  for (z = 0; z < NumberOfAttributes; z++) {\r
+    if (strcmpi (AttributesArray[z], "PROCESSING_REQUIRED") == 0) {\r
+      *GuidedSectionAttributes |= EFI_GUIDED_SECTION_PROCESSING_REQUIRED;\r
+    } else if (strcmpi (AttributesArray[z], "AUTH_STATUS_VALID") == 0) {\r
+      *GuidedSectionAttributes |= EFI_GUIDED_SECTION_AUTH_STATUS_VALID;\r
+    }\r
+  }\r
+\r
+ErrorExit:\r
+\r
+  for (Index2 = 0; Index2 < MAX_ARRAY_SIZE; Index2++) {\r
+    if (AttributesArray[Index2] == NULL) {\r
+      break;\r
+    }\r
+\r
+    free (AttributesArray[Index2]);\r
+  }\r
+\r
+  *PtrInputFileName   = InputFileName;\r
+  *PtrOutputFileName  = OutputFileName;\r
+\r
+  return ReturnValue;\r
+}\r
+\r
+static\r
+INT32\r
+ProcessScript (\r
+  IN OUT UINT8   *FileBuffer,\r
+  IN FILE        *Package,\r
+  IN CHAR8       *BuildDirectory,\r
+  IN BOOLEAN     ForceUncompress\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Signs the section, data stays in same location\r
+\r
+Arguments:\r
+\r
+  FileBuffer  - Data Buffer\r
+\r
+  Package     - Points to curly brace in Image Script\r
+\r
+  BuildDirectory     - Name of the source directory parameter\r
+  \r
+  ForceUncompress   - Whether to force uncompress.\r
+\r
+Returns:\r
+\r
+  Number of bytes added to file buffer\r
+  -1 on error\r
+\r
+--*/\r
+{\r
+  EFI_STATUS  Status;\r
+  UINT32      Size;\r
+  CHAR8       Buffer[_MAX_PATH];\r
+  CHAR8       Type[_MAX_PATH];\r
+  CHAR8       FileName[_MAX_PATH];\r
+  CHAR8       NewBuffer[_MAX_PATH];\r
+  INT32       Index3;\r
+  INT32       Index2;\r
+  UINT32      ReturnValue;\r
+  UINT8       ByteBuffer;\r
+  FILE        *InFile;\r
+  UINT32      SourceDataSize;\r
+  CHAR8       *ToolArgumentsArray[MAX_ARRAY_SIZE];\r
+  CHAR8       *OutputFileName;\r
+  CHAR8       *InputFileName;\r
+  CHAR8       ToolName[_MAX_PATH];\r
+  FILE        *OutputFile;\r
+  FILE        *InputFile;\r
+  UINT8       Temp;\r
+  int         returnint;\r
+  INT32       Index;\r
+  UINT32      LineNumber;\r
+  BOOLEAN     IsError;\r
+  EFI_GUID    SignGuid;\r
+  UINT16      GuidedSectionAttributes;\r
+  UINT8       *TargetFileBuffer;\r
+\r
+  OutputFileName          = NULL;\r
+  InputFileName           = NULL;\r
+  OutputFile              = NULL;\r
+  InputFile               = NULL;\r
+  IsError                 = FALSE;\r
+  GuidedSectionAttributes = 0;\r
+  TargetFileBuffer        = NULL;\r
+\r
+  Size                    = 0;\r
+  LineNumber              = 0;\r
+  Buffer[0]               = 0;\r
+  for (Index3 = 0; Index3 < MAX_ARRAY_SIZE; ++Index3) {\r
+    ToolArgumentsArray[Index3] = NULL;\r
+  }\r
+\r
+  while (Buffer[0] != '}') {\r
+    if (GetNextLine (Buffer, Package, &LineNumber) != -1) {\r
+      CheckSlash (Buffer, Package, &LineNumber);\r
+    } else {\r
+      printf ("ERROR in IMAGE SCRIPT!\n");\r
+      IsError = TRUE;\r
+      goto Done;\r
+    }\r
+\r
+    if (strcmpi (Buffer, "Compress") == 0) {\r
+      //\r
+      // Handle compress\r
+      //\r
+      //\r
+      // read compression type\r
+      //\r
+      if (GetNextLine (Buffer, Package, &LineNumber) != -1) {\r
+        CheckSlash (Buffer, Package, &LineNumber);\r
+      }\r
+\r
+      StripParens (Buffer);\r
+      if (Buffer[0] == '$') {\r
+        ProcessEnvironmentVariable (&Buffer[0], Type);\r
+      } else {\r
+        strcpy (Type, Buffer);\r
+      }\r
+      //\r
+      // build buffer\r
+      //\r
+      while (Buffer[0] != '{') {\r
+        if (GetNextLine (Buffer, Package, &LineNumber) != -1) {\r
+          CheckSlash (Buffer, Package, &LineNumber);\r
+        }\r
+      }\r
+\r
+      ReturnValue = ProcessScript (&FileBuffer[Size], Package, BuildDirectory, ForceUncompress);\r
+      if (ReturnValue == -1) {\r
+        IsError = TRUE;\r
+        goto Done;\r
+      }\r
+      //\r
+      // Call compress routine on buffer.\r
+      // Occasionally, compressed data + section header would\r
+      // be largere than the source and EFI_BUFFER_TOO_SMALL is\r
+      // returned from CompressSection()\r
+      //\r
+      SourceDataSize = ReturnValue;\r
+\r
+      if (!ForceUncompress) {\r
+\r
+        Status = CompressSection (\r
+                  &FileBuffer[Size],\r
+                  &ReturnValue,\r
+                  SourceDataSize,\r
+                  Type\r
+                  );\r
+\r
+        if (Status == EFI_BUFFER_TOO_SMALL) {\r
+          Status = CompressSection (\r
+                    &FileBuffer[Size],\r
+                    &ReturnValue,\r
+                    SourceDataSize,\r
+                    Type\r
+                    );\r
+        }\r
+\r
+        if (EFI_ERROR (Status)) {\r
+          IsError = TRUE;\r
+          goto Done;\r
+        }\r
+      }\r
+\r
+      Size += ReturnValue;\r
+\r
+    } else if (strcmpi (Buffer, "Tool") == 0) {\r
+\r
+      ZeroMem (ToolName, _MAX_PATH);\r
+      ZeroMem (ToolArgumentsArray, sizeof (CHAR8 *) * MAX_ARRAY_SIZE);\r
+      ZeroMem (&SignGuid, sizeof (EFI_GUID));\r
+\r
+      //\r
+      // handle signing Tool\r
+      //\r
+      while (Buffer[0] != '(') {\r
+        if (GetNextLine (Buffer, Package, &LineNumber) != -1) {\r
+          CheckSlash (Buffer, Package, &LineNumber);\r
+        }\r
+      }\r
+\r
+      if (strcmpi (Buffer, "(") == 0) {\r
+        if (GetNextLine (Buffer, Package, &LineNumber) != -1) {\r
+          CheckSlash (Buffer, Package, &LineNumber);\r
+        }\r
+      }\r
+\r
+      StripParens (Buffer);\r
+\r
+      if (Buffer[0] == '$') {\r
+        Index = ProcessEnvironmentVariable (&Buffer[0], ToolName);\r
+        //\r
+        // if there is string after the environment variable, cat it.\r
+        //\r
+        if ((UINT32) Index < strlen (Buffer)) {\r
+          strcat (ToolName, &Buffer[Index]);\r
+        }\r
+      } else {\r
+        strcpy (ToolName, Buffer);\r
+      }\r
+\r
+      ToolArgumentsArray[0] = ToolName;\r
+\r
+      //\r
+      // read ARGS\r
+      //\r
+      if (GetToolArguments (\r
+            ToolArgumentsArray,\r
+            Package,\r
+            &InputFileName,\r
+            &OutputFileName,\r
+            &SignGuid,\r
+            &GuidedSectionAttributes\r
+            ) == -1) {\r
+        IsError = TRUE;\r
+        goto Done;\r
+      }\r
+      //\r
+      // if the tool need input file,\r
+      // dump the file buffer to the specified input file.\r
+      //\r
+      if (InputFileName != NULL) {\r
+        InputFile = fopen (InputFileName, "wb");\r
+        if (InputFile == NULL) {\r
+          Error (NULL, 0, 0, InputFileName, "failed to open output file for writing");\r
+          IsError = TRUE;\r
+          goto Done;\r
+        }\r
+\r
+        fwrite (FileBuffer, sizeof (UINT8), Size, InputFile);\r
+        fclose (InputFile);\r
+        InputFile = NULL;\r
+        free (InputFileName);\r
+        InputFileName = NULL;\r
+      }\r
+      //\r
+      // dispatch signing tool\r
+      //\r
+#ifdef __GNUC__\r
+      {\r
+        char CommandLine[1000];\r
+        sprintf(CommandLine, "%s %s", ToolName, ToolArgumentsArray);\r
+        returnint = system(CommandLine);\r
+      }\r
+#else\r
+      returnint = _spawnv (_P_WAIT, ToolName, ToolArgumentsArray);\r
+#endif\r
+      if (returnint != 0) {\r
+        Error (NULL, 0, 0, ToolName, "external tool failed");\r
+        IsError = TRUE;\r
+        goto Done;\r
+      }\r
+      //\r
+      // if the tool has output file,\r
+      // dump the output file to the file buffer\r
+      //\r
+      if (OutputFileName != NULL) {\r
+\r
+        OutputFile = fopen (OutputFileName, "rb");\r
+        if (OutputFile == NULL) {\r
+          Error (NULL, 0, 0, OutputFileName, "failed to open output file for writing");\r
+          IsError = TRUE;\r
+          goto Done;\r
+        }\r
+\r
+        TargetFileBuffer  = &FileBuffer[Size];\r
+        SourceDataSize    = Size;\r
+\r
+        fread (&Temp, sizeof (UINT8), 1, OutputFile);\r
+        while (!feof (OutputFile)) {\r
+          FileBuffer[Size++] = Temp;\r
+          fread (&Temp, sizeof (UINT8), 1, OutputFile);\r
+        }\r
+\r
+        while ((Size & 0x03) != 0) {\r
+          FileBuffer[Size] = 0;\r
+          Size++;\r
+        }\r
+\r
+        SourceDataSize = Size - SourceDataSize;\r
+\r
+        fclose (OutputFile);\r
+        OutputFile = NULL;\r
+        free (OutputFileName);\r
+        OutputFileName = NULL;\r
+\r
+        if (CompareGuid (&SignGuid, &mZeroGuid) != 0) {\r
+          ReturnValue = SourceDataSize;\r
+          Status = GenSimpleGuidSection (\r
+                    TargetFileBuffer,\r
+                    &ReturnValue,\r
+                    SourceDataSize,\r
+                    SignGuid,\r
+                    GuidedSectionAttributes\r
+                    );\r
+          if (EFI_ERROR (Status)) {\r
+            IsError = TRUE;\r
+            goto Done;\r
+          }\r
+\r
+          Size = ReturnValue;\r
+        }\r
+      }\r
+\r
+    } else if (Buffer[0] != '}') {\r
+      //\r
+      // if we are here, we should see either a file name,\r
+      // or a }.\r
+      //\r
+      Index3      = 0;\r
+      FileName[0] = 0;\r
+      //\r
+      // Prepend the build directory to the file name if the\r
+      // file name does not already contain a full path.\r
+      //\r
+      if (!isalpha (Buffer[0]) || (Buffer[1] != ':')) {\r
+        sprintf (FileName, "%s\\", BuildDirectory);\r
+      }\r
+\r
+      while (Buffer[Index3] != '\n') {\r
+        if (Buffer[Index3] == '$') {\r
+          Index3 += ProcessEnvironmentVariable (&Buffer[Index3], NewBuffer);\r
+          strcat (FileName, NewBuffer);\r
+        }\r
+\r
+        if (Buffer[Index3] == 0) {\r
+          break;\r
+        } else {\r
+          Index2              = strlen (FileName);\r
+          FileName[Index2++]  = Buffer[Index3++];\r
+          FileName[Index2]    = 0;\r
+        }\r
+      }\r
+\r
+      InFile = fopen (FileName, "rb");\r
+      if (InFile == NULL) {\r
+        Error (NULL, 0, 0, FileName, "failed to open file for reading");\r
+        IsError = TRUE;\r
+        goto Done;\r
+      }\r
+\r
+      fread (&ByteBuffer, sizeof (UINT8), 1, InFile);\r
+      while (!feof (InFile)) {\r
+        FileBuffer[Size++] = ByteBuffer;\r
+        fread (&ByteBuffer, sizeof (UINT8), 1, InFile);\r
+      }\r
+\r
+      fclose (InFile);\r
+      InFile = NULL;\r
+\r
+      //\r
+      // Make sure section ends on a DWORD boundary\r
+      //\r
+      while ((Size & 0x03) != 0) {\r
+        FileBuffer[Size] = 0;\r
+        Size++;\r
+      }\r
+\r
+    }\r
+  }\r
+\r
+Done:\r
+  for (Index3 = 1; Index3 < MAX_ARRAY_SIZE; Index3++) {\r
+    if (ToolArgumentsArray[Index3] == NULL) {\r
+      break;\r
+    }\r
+\r
+    free (ToolArgumentsArray[Index3]);\r
+  }\r
+\r
+  if (IsError) {\r
+    return -1;\r
+  }\r
+\r
+  return Size;\r
+\r
+}\r
+\r
+static\r
+UINT8\r
+StringToType (\r
+  IN CHAR8 *String\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Converts File Type String to value.  EFI_FV_FILETYPE_ALL indicates that an\r
+  unrecognized file type was specified.\r
+\r
+Arguments:\r
+\r
+  String    - File type string\r
+\r
+Returns:\r
+\r
+  File Type Value\r
+\r
+--*/\r
+{\r
+  if (strcmpi (String, "EFI_FV_FILETYPE_RAW") == 0) {\r
+    return EFI_FV_FILETYPE_RAW;\r
+  }\r
+\r
+  if (strcmpi (String, "EFI_FV_FILETYPE_FREEFORM") == 0) {\r
+    return EFI_FV_FILETYPE_FREEFORM;\r
+  }\r
+\r
+  if (strcmpi (String, "EFI_FV_FILETYPE_SECURITY_CORE") == 0) {\r
+    return EFI_FV_FILETYPE_SECURITY_CORE;\r
+  }\r
+\r
+  if (strcmpi (String, "EFI_FV_FILETYPE_PEI_CORE") == 0) {\r
+    return EFI_FV_FILETYPE_PEI_CORE;\r
+  }\r
+\r
+  if (strcmpi (String, "EFI_FV_FILETYPE_DXE_CORE") == 0) {\r
+    return EFI_FV_FILETYPE_DXE_CORE;\r
+  }\r
+\r
+  if (strcmpi (String, "EFI_FV_FILETYPE_PEIM") == 0) {\r
+    return EFI_FV_FILETYPE_PEIM;\r
+  }\r
+\r
+  if (strcmpi (String, "EFI_FV_FILETYPE_DRIVER") == 0) {\r
+    return EFI_FV_FILETYPE_DRIVER;\r
+  }\r
+\r
+  if (strcmpi (String, "EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER") == 0) {\r
+    return EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER;\r
+  }\r
+\r
+  if (strcmpi (String, "EFI_FV_FILETYPE_APPLICATION") == 0) {\r
+    return EFI_FV_FILETYPE_APPLICATION;\r
+  }\r
+\r
+  if (strcmpi (String, "EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE") == 0) {\r
+    return EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE;\r
+  }\r
+\r
+  return EFI_FV_FILETYPE_ALL;\r
+}\r
+\r
+static\r
+UINT32\r
+AdjustFileSize (\r
+  IN UINT8  *FileBuffer,\r
+  IN UINT32 FileSize\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Adjusts file size to insure sectioned file is exactly the right length such\r
+  that it ends on exactly the last byte of the last section.  ProcessScript()\r
+  may have padded beyond the end of the last section out to a 4 byte boundary.\r
+  This padding is stripped.\r
+\r
+Arguments:\r
+  FileBuffer  - Data Buffer - contains a section stream\r
+  FileSize    - Size of FileBuffer as returned from ProcessScript()\r
+\r
+Returns:\r
+  Corrected size of file.\r
+\r
+--*/\r
+{\r
+  UINT32                    TotalLength;\r
+  UINT32                    CurrentLength;\r
+  UINT32                    SectionLength;\r
+  UINT32                    SectionStreamLength;\r
+  EFI_COMMON_SECTION_HEADER *SectionHeader;\r
+  EFI_COMMON_SECTION_HEADER *NextSectionHeader;\r
+\r
+  TotalLength         = 0;\r
+  CurrentLength       = 0;\r
+  SectionStreamLength = FileSize;\r
+\r
+  SectionHeader       = (EFI_COMMON_SECTION_HEADER *) FileBuffer;\r
+\r
+  while (TotalLength < SectionStreamLength) {\r
+    SectionLength = *((UINT32 *) SectionHeader->Size) & 0x00ffffff;\r
+    TotalLength += SectionLength;\r
+\r
+    if (TotalLength == SectionStreamLength) {\r
+      return TotalLength;\r
+    }\r
+    //\r
+    // Move to the next byte following the section...\r
+    //\r
+    SectionHeader = (EFI_COMMON_SECTION_HEADER *) ((UINT8 *) SectionHeader + SectionLength);\r
+    CurrentLength = (UINTN) SectionHeader - (UINTN) FileBuffer;\r
+\r
+    //\r
+    // Figure out where the next section begins\r
+    //\r
+    NextSectionHeader = (EFI_COMMON_SECTION_HEADER *) ((UINT8 *) SectionHeader + 3);\r
+    NextSectionHeader = (EFI_COMMON_SECTION_HEADER *) ((UINTN) NextSectionHeader &~ (UINTN) 3);\r
+    TotalLength += (UINTN) NextSectionHeader - (UINTN) SectionHeader;\r
+    SectionHeader = NextSectionHeader;\r
+  }\r
+\r
+  return CurrentLength;\r
+}\r
+\r
+static\r
+INT32\r
+MainEntry (\r
+  INT32     argc,\r
+  CHAR8     *argv[],\r
+  BOOLEAN   ForceUncompress\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  MainEntry function.\r
+\r
+Arguments:\r
+\r
+  argc            - Number of command line parameters.\r
+  argv            - Array of pointers to command line parameter strings.\r
+  ForceUncompress - If TRUE, force to do not compress the sections even if compression\r
+                    is specified in the script. Otherwise, FALSE.\r
+\r
+Returns:\r
+  STATUS_SUCCESS  - Function exits successfully.\r
+  STATUS_ERROR    - Some error occurred during execution.\r
+\r
+--*/\r
+{\r
+  FILE                    *PrimaryPackage;\r
+  FILE                    *OverridePackage;\r
+  FILE                    *Out;\r
+  CHAR8                   BaseName[_MAX_PATH];\r
+  EFI_GUID                FfsGuid;\r
+  CHAR8                   GuidString[_MAX_PATH];\r
+  EFI_FFS_FILE_HEADER     FileHeader;\r
+  CHAR8                   FileType[_MAX_PATH];\r
+  EFI_FFS_FILE_ATTRIBUTES FfsAttrib;\r
+  EFI_FFS_FILE_ATTRIBUTES FfsAttribDefined;\r
+  UINT64                  FfsAlignment;\r
+  UINT32                  FfsAlignment32;\r
+  CHAR8                   InputString[_MAX_PATH];\r
+  BOOLEAN                 ImageScriptInOveride;\r
+  UINT32                  FileSize;\r
+  UINT8                   *FileBuffer;\r
+  EFI_STATUS              Status;\r
+  UINT32                  LineNumber;\r
+  EFI_FFS_FILE_TAIL       TailValue;\r
+\r
+  BaseName[0]       = 0;\r
+  FileType[0]       = 0;\r
+  FfsAttrib         = 0;\r
+  FfsAttribDefined  = 0;\r
+  FfsAlignment      = 0;\r
+  FfsAlignment32    = 0;\r
+  PrimaryPackage    = NULL;\r
+  Out               = NULL;\r
+  OverridePackage   = NULL;\r
+  FileBuffer        = NULL;\r
+\r
+  strcpy (GuidString, "00000000-0000-0000-0000-000000000000");\r
+  Status = StringToGuid (GuidString, &FfsGuid);\r
+  if (Status != 0) {\r
+    Error (NULL, 0, 0, GuidString, "error parsing GUID string");\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  GuidString[0]         = 0;\r
+  ImageScriptInOveride  = FALSE;\r
+  //\r
+  // Initialize the simple file parsing routines. Then open\r
+  // the primary package file for parsing.\r
+  //\r
+  SFPInit ();\r
+  if (SFPOpenFile (mGlobals.PrimaryPackagePath) != STATUS_SUCCESS) {\r
+    Error (NULL, 0, 0, mGlobals.PrimaryPackagePath, "unable to open primary package file");\r
+    goto Done;\r
+  }\r
+  //\r
+  // First token in the file must be "PACKAGE.INF"\r
+  //\r
+  if (!SFPIsToken ("PACKAGE.INF")) {\r
+    Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "expected 'PACKAGE.INF'", NULL);\r
+    goto Done;\r
+  }\r
+  //\r
+  // Find the [.] section\r
+  //\r
+  if (!SFPSkipToToken ("[.]")) {\r
+    Error (mGlobals.PrimaryPackagePath, 1, 0, "could not locate [.] section in package file", NULL);\r
+    goto Done;\r
+  }\r
+  //\r
+  // Start parsing the data. The algorithm is essentially the same for each keyword:\r
+  //   1. Identify the keyword\r
+  //   2. Verify that the keyword/value pair has not already been defined\r
+  //   3. Set some flag indicating that the keyword/value pair has been defined\r
+  //   4. Skip over the "="\r
+  //   5. Get the value, which may be a number, TRUE, FALSE, or a string.\r
+  //\r
+  while (1) {\r
+    if (SFPIsToken ("BASE_NAME")) {\r
+      //\r
+      // Found BASE_NAME, format:\r
+      //   BASE_NAME = MyBaseName\r
+      //\r
+      if (BaseName[0] != 0) {\r
+        Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "BASE_NAME already defined", NULL);\r
+        goto Done;\r
+      }\r
+\r
+      if (!SFPIsToken ("=")) {\r
+        Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "expected '='", NULL);\r
+        goto Done;\r
+      }\r
+\r
+      if (!SFPGetNextToken (BaseName, sizeof (BaseName))) {\r
+        Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "expected valid base name", NULL);\r
+        goto Done;\r
+      }\r
+    } else if (SFPIsToken ("IMAGE_SCRIPT")) {\r
+      //\r
+      // Found IMAGE_SCRIPT. Break out and process below.\r
+      //\r
+      break;\r
+    } else if (SFPIsToken ("FFS_FILEGUID")) {\r
+      //\r
+      // found FILEGUID, format:\r
+      //   FFS_FILEGUID = F7845C4F-EDF5-42C5-BD8F-A02AF63DD93A\r
+      //\r
+      if (GuidString[0] != 0) {\r
+        Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "FFS_FILEGUID already defined", NULL);\r
+        goto Done;\r
+      }\r
+\r
+      if (!SFPIsToken ("=")) {\r
+        Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "expected '='", NULL);\r
+        goto Done;\r
+      }\r
+\r
+      if (SFPGetGuidToken (GuidString, sizeof (GuidString)) != TRUE) {\r
+        Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "expected file GUID", NULL);\r
+        goto Done;\r
+      }\r
+\r
+      Status = StringToGuid (GuidString, &FfsGuid);\r
+      if (Status != 0) {\r
+        Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "expected valid file GUID", NULL);\r
+        goto Done;\r
+      }\r
+    } else if (SFPIsToken ("FFS_FILETYPE")) {\r
+      //\r
+      // ***********************************************************************\r
+      //\r
+      // Found FFS_FILETYPE, format:\r
+      //  FFS_FILETYPE = EFI_FV_FILETYPE_APPLICATION\r
+      //\r
+      if (FileType[0] != 0) {\r
+        Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "FFS_FILETYPE previously defined", NULL);\r
+        goto Done;\r
+      }\r
+\r
+      if (!SFPIsToken ("=")) {\r
+        Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "expected '='", NULL);\r
+        goto Done;\r
+      }\r
+\r
+      if (!SFPGetNextToken (FileType, sizeof (FileType))) {\r
+        Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "expected valid FFS_FILETYPE", NULL);\r
+        goto Done;\r
+      }\r
+    } else if (SFPIsToken ("FFS_ATTRIB_HEADER_EXTENSION")) {\r
+      //\r
+      // ***********************************************************************\r
+      //\r
+      // Found: FFS_ATTRIB_HEADER_EXTENSION = FALSE\r
+      // Spec says the bit is for future expansion, and must be false.\r
+      //\r
+      if (FfsAttribDefined & FFS_ATTRIB_HEADER_EXTENSION) {\r
+        Error (\r
+          mGlobals.PrimaryPackagePath,\r
+          SFPGetLineNumber (),\r
+          0,\r
+          "FFS_ATTRIB_HEADER_EXTENSION previously defined",\r
+          NULL\r
+          );\r
+        goto Done;\r
+      }\r
+\r
+      FfsAttribDefined |= FFS_ATTRIB_HEADER_EXTENSION;\r
+      if (!SFPIsToken ("=")) {\r
+        Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "expected '='", NULL);\r
+        goto Done;\r
+      }\r
+\r
+      if (SFPIsToken ("TRUE")) {\r
+        Error (\r
+          mGlobals.PrimaryPackagePath,\r
+          SFPGetLineNumber (),\r
+          0,\r
+          "only FFS_ATTRIB_HEADER_EXTENSION = FALSE is supported",\r
+          NULL\r
+          );\r
+        goto Done;\r
+      } else if (SFPIsToken ("FALSE")) {\r
+        //\r
+        // Default is FALSE\r
+        //\r
+      } else {\r
+        Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "expected 'FALSE'", NULL);\r
+        goto Done;\r
+      }\r
+    } else if (SFPIsToken ("FFS_ATTRIB_TAIL_PRESENT")) {\r
+      //\r
+      // ***********************************************************************\r
+      //\r
+      // Found: FFS_ATTRIB_TAIL_PRESENT = TRUE | FALSE\r
+      //\r
+      if (FfsAttribDefined & FFS_ATTRIB_TAIL_PRESENT) {\r
+        Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "FFS_ATTRIB_TAIL_PRESENT previously defined", NULL);\r
+        goto Done;\r
+      }\r
+\r
+      FfsAttribDefined |= FFS_ATTRIB_TAIL_PRESENT;\r
+      if (!SFPIsToken ("=")) {\r
+        Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "expected '='", NULL);\r
+        goto Done;\r
+      }\r
+\r
+      if (SFPIsToken ("TRUE")) {\r
+        FfsAttrib |= FFS_ATTRIB_TAIL_PRESENT;\r
+      } else if (SFPIsToken ("FALSE")) {\r
+        //\r
+        // Default is FALSE\r
+        //\r
+      } else {\r
+        Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "expected 'TRUE' or 'FALSE'", NULL);\r
+        goto Done;\r
+      }\r
+    } else if (SFPIsToken ("FFS_ATTRIB_RECOVERY")) {\r
+      //\r
+      // ***********************************************************************\r
+      //\r
+      // Found: FFS_ATTRIB_RECOVERY = TRUE | FALSE\r
+      //\r
+      if (FfsAttribDefined & FFS_ATTRIB_RECOVERY) {\r
+        Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "FFS_ATTRIB_RECOVERY previously defined", NULL);\r
+        goto Done;\r
+      }\r
+\r
+      FfsAttribDefined |= FFS_ATTRIB_RECOVERY;\r
+      if (!SFPIsToken ("=")) {\r
+        Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "expected '='", NULL);\r
+        goto Done;\r
+      }\r
+\r
+      if (SFPIsToken ("TRUE")) {\r
+        FfsAttrib |= FFS_ATTRIB_RECOVERY;\r
+      } else if (SFPIsToken ("FALSE")) {\r
+        //\r
+        // Default is FALSE\r
+        //\r
+      } else {\r
+        Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "expected 'TRUE' or 'FALSE'", NULL);\r
+        goto Done;\r
+      }\r
+    } else if (SFPIsToken ("FFS_ATTRIB_CHECKSUM")) {\r
+      //\r
+      // ***********************************************************************\r
+      //\r
+      // Found: FFS_ATTRIB_CHECKSUM = TRUE | FALSE\r
+      //\r
+      if (FfsAttribDefined & FFS_ATTRIB_CHECKSUM) {\r
+        Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "FFS_ATTRIB_CHECKSUM previously defined", NULL);\r
+        goto Done;\r
+      }\r
+\r
+      FfsAttribDefined |= FFS_ATTRIB_CHECKSUM;\r
+      if (!SFPIsToken ("=")) {\r
+        Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "expected '='", NULL);\r
+        goto Done;\r
+      }\r
+\r
+      if (SFPIsToken ("TRUE")) {\r
+        FfsAttrib |= FFS_ATTRIB_CHECKSUM;\r
+      } else if (SFPIsToken ("FALSE")) {\r
+        //\r
+        // Default is FALSE\r
+        //\r
+      } else {\r
+        Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "expected 'TRUE' or 'FALSE'", NULL);\r
+        goto Done;\r
+      }\r
+    } else if (SFPIsToken ("FFS_ALIGNMENT") || SFPIsToken ("FFS_ATTRIB_DATA_ALIGNMENT")) {\r
+      //\r
+      // ***********************************************************************\r
+      //\r
+      // Found FFS_ALIGNMENT, formats:\r
+      //   FFS_ALIGNMENT = 0-7\r
+      //   FFS_ATTRIB_DATA_ALIGNMENT = 0-7\r
+      //\r
+      if (FfsAttribDefined & FFS_ATTRIB_DATA_ALIGNMENT) {\r
+        Error (\r
+          mGlobals.PrimaryPackagePath,\r
+          SFPGetLineNumber (),\r
+          0,\r
+          "FFS_ALIGNMENT/FFS_ATTRIB_DATA_ALIGNMENT previously defined",\r
+          NULL\r
+          );\r
+        goto Done;\r
+      }\r
+\r
+      FfsAttribDefined |= FFS_ATTRIB_DATA_ALIGNMENT;\r
+      if (!SFPIsToken ("=")) {\r
+        Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "expected '='", NULL);\r
+        goto Done;\r
+      }\r
+\r
+      if (!SFPGetNumber (&FfsAlignment32)) {\r
+        Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "expected numeric value for alignment", NULL);\r
+        goto Done;\r
+      }\r
+\r
+      if (FfsAlignment32 > 7) {\r
+        Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "expected 0 <= alignment <= 7", NULL);\r
+        goto Done;\r
+      }\r
+\r
+      FfsAttrib |= (((EFI_FFS_FILE_ATTRIBUTES) FfsAlignment32) << 3);\r
+    } else {\r
+      SFPGetNextToken (InputString, sizeof (InputString));\r
+      Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, InputString, "unrecognized/unexpected token");\r
+      goto Done;\r
+    }\r
+  }\r
+  //\r
+  // Close the primary package file\r
+  //\r
+  SFPCloseFile ();\r
+  //\r
+  // TODO: replace code below with basically a copy of the code above. Don't\r
+  // forget to reset the FfsAttribDefined variable first. Also, you'll need\r
+  // to somehow keep track of whether or not the basename is defined multiple\r
+  // times in the override package. Ditto on the file GUID.\r
+  //\r
+  if (mGlobals.OverridePackagePath[0] != 0) {\r
+    OverridePackage = fopen (mGlobals.OverridePackagePath, "r");\r
+    //\r
+    // NOTE: For package override to work correctly, the code below must be modified to\r
+    //       SET or CLEAR bits properly. For example, if the primary package set\r
+    //       FFS_ATTRIB_CHECKSUM = TRUE, and the override set FFS_ATTRIB_CHECKSUM = FALSE, then\r
+    //       we'd need to clear the bit below. Since this is not happening, I'm guessing that\r
+    //       the override functionality is not being used, so should be made obsolete. If I'm\r
+    //       wrong, and it is being used, then it needs to be fixed. Thus emit an error if it is\r
+    //       used, and we'll address it then.  4/10/2003\r
+    //\r
+    Error (__FILE__, __LINE__, 0, "package override functionality is not implemented correctly", NULL);\r
+    goto Done;\r
+  } else {\r
+    OverridePackage = NULL;\r
+  }\r
+\r
+#ifdef OVERRIDE_SUPPORTED\r
+  if (OverridePackage != NULL) {\r
+    //\r
+    // Parse override package file\r
+    //\r
+    fscanf (OverridePackage, "%s", &InputString);\r
+    if (strcmpi (InputString, "PACKAGE.INF") != 0) {\r
+      Error (mGlobals.OverridePackagePath, 1, 0, "invalid package file", "expected 'PACKAGE.INF'");\r
+      goto Done;\r
+    }\r
+    //\r
+    // Match [dir] to Build Directory\r
+    //\r
+    if (FindSectionInPackage (mGlobals.BuildDirectory, OverridePackage, &LineNumber) != 0) {\r
+      Error (mGlobals.OverridePackagePath, 1, 0, mGlobals.BuildDirectory, "section not found in package file");\r
+      goto Done;\r
+    }\r
+\r
+    InputString[0] = 0;\r
+    while ((InputString[0] != '[') && (!feof (OverridePackage))) {\r
+      if (GetNextLine (InputString, OverridePackage, &LineNumber) != -1) {\r
+        if (InputString[0] != '[') {\r
+here:\r
+          if (strcmpi (InputString, "BASE_NAME") == 0) {\r
+            //\r
+            // found BASE_NAME, next is = and string.\r
+            //\r
+            fscanf (OverridePackage, "%s", &InputString);\r
+            CheckSlash (InputString, OverridePackage, &LineNumber);\r
+            if (strlen (InputString) == 1) {\r
+              //\r
+              // string is just =\r
+              //\r
+              fscanf (OverridePackage, "%s", &InputString);\r
+              CheckSlash (InputString, OverridePackage, &LineNumber);\r
+              strcpy (BaseName, InputString);\r
+            } else {\r
+              BreakString (InputString, InputString, 1);\r
+              strcpy (BaseName, InputString);\r
+            }\r
+          } else if (strcmpi (InputString, "IMAGE_SCRIPT") == 0) {\r
+            //\r
+            // found IMAGE_SCRIPT, come back later to process it\r
+            //\r
+            ImageScriptInOveride = TRUE;\r
+            fscanf (OverridePackage, "%s", &InputString);\r
+          } else if (strcmpi (InputString, "FFS_FILEGUID") == 0) {\r
+            //\r
+            // found FILEGUID, next is = and string.\r
+            //\r
+            fscanf (OverridePackage, "%s", &InputString);\r
+            CheckSlash (InputString, OverridePackage, &LineNumber);\r
+            if (strlen (InputString) == 1) {\r
+              //\r
+              // string is just =\r
+              //\r
+              fscanf (OverridePackage, "%s", &InputString);\r
+              CheckSlash (InputString, OverridePackage, &LineNumber);\r
+              Status = StringToGuid (InputString, &FfsGuid);\r
+              if (Status != 0) {\r
+                Error (mGlobals.OverridePackagePath, 1, 0, InputString, "bad FFS_FILEGUID format");\r
+                goto Done;\r
+              }\r
+            } else {\r
+              BreakString (InputString, InputString, 1);\r
+              Status = StringToGuid (InputString, &FfsGuid);\r
+              if (Status != 0) {\r
+                Error (mGlobals.OverridePackagePath, 1, 0, InputString, "bad FFS_FILEGUID format");\r
+                goto Done;\r
+              }\r
+            }\r
+          } else if (strcmpi (InputString, "FFS_FILETYPE") == 0) {\r
+            //\r
+            // found FILETYPE, next is = and string.\r
+            //\r
+            fscanf (OverridePackage, "%s", &InputString);\r
+            CheckSlash (InputString, OverridePackage, &LineNumber);\r
+            if (strlen (InputString) == 1) {\r
+              //\r
+              // string is just =\r
+              //\r
+              fscanf (OverridePackage, "%s", &InputString);\r
+              CheckSlash (InputString, OverridePackage, &LineNumber);\r
+              strcpy (FileType, InputString);\r
+            } else {\r
+              BreakString (InputString, InputString, 1);\r
+              strcpy (FileType, InputString);\r
+            }\r
+\r
+          } else if (strcmpi (InputString, "FFS_ATTRIB_RECOVERY") == 0) {\r
+            //\r
+            // found FFS_ATTRIB_RECOVERY, next is = and string.\r
+            //\r
+            fscanf (OverridePackage, "%s", &InputString);\r
+            CheckSlash (InputString, OverridePackage, &LineNumber);\r
+            if (strlen (InputString) == 1) {\r
+              //\r
+              // string is just =\r
+              //\r
+              fscanf (OverridePackage, "%s", &InputString);\r
+              CheckSlash (InputString, OverridePackage, &LineNumber);\r
+              if (strcmpi (InputString, "TRUE") == 0) {\r
+                FfsAttrib |= FFS_ATTRIB_RECOVERY;\r
+              }\r
+            } else {\r
+              BreakString (InputString, InputString, 1);\r
+              if (strcmpi (InputString, "TRUE") == 0) {\r
+                FfsAttrib |= FFS_ATTRIB_RECOVERY;\r
+              }\r
+            }\r
+          } else if (strcmpi (InputString, "FFS_ATTRIB_CHECKSUM") == 0) {\r
+            //\r
+            // found FFS_ATTRIB_CHECKSUM, next is = and string.\r
+            //\r
+            fscanf (OverridePackage, "%s", &InputString);\r
+            CheckSlash (InputString, OverridePackage, &LineNumber);\r
+            if (strlen (InputString) == 1) {\r
+              //\r
+              // string is just =\r
+              //\r
+              fscanf (OverridePackage, "%s", &InputString);\r
+              CheckSlash (InputString, OverridePackage, &LineNumber);\r
+              if (strcmpi (InputString, "TRUE") == 0) {\r
+                FfsAttrib |= FFS_ATTRIB_CHECKSUM;\r
+              }\r
+            } else {\r
+              BreakString (InputString, InputString, 1);\r
+              if (strcmpi (InputString, "TRUE") == 0) {\r
+                FfsAttrib |= FFS_ATTRIB_CHECKSUM;\r
+              }\r
+            }\r
+          } else if (strcmpi (InputString, "FFS_ALIGNMENT") == 0) {\r
+            //\r
+            // found FFS_ALIGNMENT, next is = and string.\r
+            //\r
+            fscanf (OverridePackage, "%s", &InputString);\r
+            CheckSlash (InputString, OverridePackage, &LineNumber);\r
+            if (strlen (InputString) == 1) {\r
+              //\r
+              // string is just =\r
+              //\r
+              fscanf (OverridePackage, "%s", &InputString);\r
+              CheckSlash (InputString, OverridePackage, &LineNumber);\r
+            } else {\r
+              BreakString (InputString, InputString, 1);\r
+            }\r
+\r
+            AsciiStringToUint64 (InputString, FALSE, &FfsAlignment);\r
+            if (FfsAlignment > 7) {\r
+              Error (mGlobals.OverridePackagePath, 1, 0, InputString, "invalid FFS_ALIGNMENT value");\r
+              goto Done;\r
+            }\r
+\r
+            FfsAttrib |= (((EFI_FFS_FILE_ATTRIBUTES) FfsAlignment) << 3);\r
+          } else if (strchr (InputString, '=') != NULL) {\r
+            BreakString (InputString, String, 1);\r
+            fseek (OverridePackage, (-1 * (strlen (String) + 1)), SEEK_CUR);\r
+            BreakString (InputString, InputString, 0);\r
+            goto here;\r
+          }\r
+        }\r
+      }\r
+    }\r
+  }\r
+#endif // #ifdef OVERRIDE_SUPPORTED\r
+  //\r
+  // Require that they specified a file GUID at least, since that's how we're\r
+  // naming the file.\r
+  //\r
+  if (GuidString[0] == 0) {\r
+    Error (mGlobals.PrimaryPackagePath, 1, 0, "FFS_FILEGUID must be specified", NULL);\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Build Header and process image script\r
+  //\r
+  FileBuffer = (UINT8 *) malloc ((1024 * 1024 * 16) * sizeof (UINT8));\r
+  if (FileBuffer == NULL) {\r
+    Error (__FILE__, __LINE__, 0, "memory allocation failed", NULL);\r
+    goto Done;\r
+  }\r
+\r
+  FileSize = 0;\r
+  if (ImageScriptInOveride) {\r
+#ifdef OVERRIDE_SUPORTED\r
+    rewind (OverridePackage);\r
+    LineNumber = 0;\r
+    FindSectionInPackage (mGlobals.BuildDirectory, OverridePackage, &LineNumber);\r
+    while (strcmpi (InputString, "IMAGE_SCRIPT") != 0) {\r
+      GetNextLine (InputString, OverridePackage, &LineNumber);\r
+      CheckSlash (InputString, OverridePackage, &LineNumber);\r
+      if (strchr (InputString, '=') != NULL) {\r
+        BreakString (InputString, InputString, 0);\r
+      }\r
+    }\r
+\r
+    while (InputString[0] != '{') {\r
+      GetNextLine (InputString, OverridePackage, &LineNumber);\r
+      CheckSlash (InputString, OverridePackage, &LineNumber);\r
+    }\r
+    //\r
+    // Found start of image script, process it\r
+    //\r
+    FileSize += ProcessScript (FileBuffer, OverridePackage, mGlobals.BuildDirectory, ForceUncompress);\r
+    if (FileSize == -1) {\r
+      return -1;\r
+    }\r
+\r
+    if (StringToType (FileType) != EFI_FV_FILETYPE_RAW) {\r
+      FileSize = AdjustFileSize (FileBuffer, FileSize);\r
+    }\r
+\r
+    if (BaseName[0] == '\"') {\r
+      StripQuotes (BaseName);\r
+    }\r
+\r
+    if (BaseName[0] != 0) {\r
+      sprintf (InputString, "%s-%s", GuidString, BaseName);\r
+    } else {\r
+      strcpy (InputString, GuidString);\r
+    }\r
+\r
+    switch (StringToType (FileType)) {\r
+\r
+    case EFI_FV_FILETYPE_SECURITY_CORE:\r
+      strcat (InputString, ".SEC");\r
+      break;\r
+\r
+    case EFI_FV_FILETYPE_PEIM:\r
+    case EFI_FV_FILETYPE_PEI_CORE:\r
+    case EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER:\r
+      strcat (InputString, ".PEI");\r
+      break;\r
+\r
+    case EFI_FV_FILETYPE_DRIVER:\r
+    case EFI_FV_FILETYPE_DXE_CORE:\r
+      strcat (InputString, ".DXE");\r
+      break;\r
+\r
+    case EFI_FV_FILETYPE_APPLICATION:\r
+      strcat (InputString, ".APP");\r
+      break;\r
+\r
+    case EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE:\r
+      strcat (InputString, ".FVI");\r
+      break;\r
+\r
+    case EFI_FV_FILETYPE_ALL:\r
+      Error (mGlobals.OverridePackagePath, 1, 0, "invalid FFS file type for this utility", NULL);\r
+      goto Done;\r
+\r
+    default:\r
+      strcat (InputString, ".FFS");\r
+      break;\r
+    }\r
+\r
+    if (ForceUncompress) {\r
+      strcat (InputString, ".ORG");\r
+    }\r
+\r
+    Out = fopen (InputString, "wb");\r
+    if (Out == NULL) {\r
+      Error (NULL, 0, 0, InputString, "could not open output file for writing");\r
+      goto Done;\r
+    }\r
+    //\r
+    // create ffs header\r
+    //\r
+    memset (&FileHeader, 0, sizeof (EFI_FFS_FILE_HEADER));\r
+    memcpy (&FileHeader.Name, &FfsGuid, sizeof (EFI_GUID));\r
+    FileHeader.Type       = StringToType (FileType);\r
+    FileHeader.Attributes = FfsAttrib;\r
+    //\r
+    // Now FileSize includes the EFI_FFS_FILE_HEADER\r
+    //\r
+    FileSize += sizeof (EFI_FFS_FILE_HEADER);\r
+    FileHeader.Size[0]  = (UINT8) (FileSize & 0xFF);\r
+    FileHeader.Size[1]  = (UINT8) ((FileSize & 0xFF00) >> 8);\r
+    FileHeader.Size[2]  = (UINT8) ((FileSize & 0xFF0000) >> 16);\r
+    //\r
+    // Fill in checksums and state, these must be zero for checksumming\r
+    //\r
+    // FileHeader.IntegrityCheck.Checksum.Header = 0;\r
+    // FileHeader.IntegrityCheck.Checksum.File = 0;\r
+    // FileHeader.State = 0;\r
+    //\r
+    FileHeader.IntegrityCheck.Checksum.Header = CalculateChecksum8 (\r
+                                                  (UINT8 *) &FileHeader,\r
+                                                  sizeof (EFI_FFS_FILE_HEADER)\r
+                                                  );\r
+    if (FileHeader.Attributes & FFS_ATTRIB_CHECKSUM) {\r
+      FileHeader.IntegrityCheck.Checksum.File = CalculateChecksum8 ((UINT8 *) &FileHeader, FileSize);\r
+    } else {\r
+      FileHeader.IntegrityCheck.Checksum.File = FFS_FIXED_CHECKSUM;\r
+    }\r
+\r
+    FileHeader.State = EFI_FILE_HEADER_CONSTRUCTION | EFI_FILE_HEADER_VALID | EFI_FILE_DATA_VALID;\r
+    //\r
+    // write header\r
+    //\r
+    if (fwrite (&FileHeader, sizeof (FileHeader), 1, Out) != 1) {\r
+      Error (NULL, 0, 0, "failed to write file header to output file", NULL);\r
+      goto Done;\r
+    }\r
+    //\r
+    // write data\r
+    //\r
+    if (fwrite (FileBuffer, FileSize - sizeof (EFI_FFS_FILE_HEADER), 1, Out) != 1) {\r
+      Error (NULL, 0, 0, "failed to write all bytes to output file", NULL);\r
+      goto Done;\r
+    }\r
+\r
+    fclose (Out);\r
+    Out = NULL;\r
+#endif // #ifdef OVERRIDE_SUPPORTED\r
+  } else {\r
+    //\r
+    // Open primary package file and process the IMAGE_SCRIPT section\r
+    //\r
+    PrimaryPackage = fopen (mGlobals.PrimaryPackagePath, "r");\r
+    if (PrimaryPackage == NULL) {\r
+      Error (NULL, 0, 0, mGlobals.PrimaryPackagePath, "unable to open primary package file");\r
+      goto Done;\r
+    }\r
+\r
+    LineNumber = 1;\r
+    FindSectionInPackage (".", PrimaryPackage, &LineNumber);\r
+    while (strcmpi (InputString, "IMAGE_SCRIPT") != 0) {\r
+      GetNextLine (InputString, PrimaryPackage, &LineNumber);\r
+      CheckSlash (InputString, PrimaryPackage, &LineNumber);\r
+      if (strchr (InputString, '=') != NULL) {\r
+        BreakString (InputString, InputString, 0);\r
+      }\r
+    }\r
+\r
+    while (InputString[0] != '{') {\r
+      GetNextLine (InputString, PrimaryPackage, &LineNumber);\r
+      CheckSlash (InputString, PrimaryPackage, &LineNumber);\r
+    }\r
+    //\r
+    // Found start of image script, process it\r
+    //\r
+    FileSize += ProcessScript (FileBuffer, PrimaryPackage, mGlobals.BuildDirectory, ForceUncompress);\r
+    if (FileSize == -1) {\r
+      goto Done;\r
+    }\r
+\r
+    if (StringToType (FileType) != EFI_FV_FILETYPE_RAW) {\r
+      FileSize = AdjustFileSize (FileBuffer, FileSize);\r
+    }\r
+\r
+    if (BaseName[0] == '\"') {\r
+      StripQuotes (BaseName);\r
+    }\r
+\r
+    if (BaseName[0] != 0) {\r
+      sprintf (InputString, "%s-%s", GuidString, BaseName);\r
+    } else {\r
+      strcpy (InputString, GuidString);\r
+    }\r
+\r
+    switch (StringToType (FileType)) {\r
+\r
+    case EFI_FV_FILETYPE_SECURITY_CORE:\r
+      strcat (InputString, ".SEC");\r
+      break;\r
+\r
+    case EFI_FV_FILETYPE_PEIM:\r
+    case EFI_FV_FILETYPE_PEI_CORE:\r
+    case EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER:\r
+      strcat (InputString, ".PEI");\r
+      break;\r
+\r
+    case EFI_FV_FILETYPE_DRIVER:\r
+    case EFI_FV_FILETYPE_DXE_CORE:\r
+      strcat (InputString, ".DXE");\r
+      break;\r
+\r
+    case EFI_FV_FILETYPE_APPLICATION:\r
+      strcat (InputString, ".APP");\r
+      break;\r
+\r
+    case EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE:\r
+      strcat (InputString, ".FVI");\r
+      break;\r
+\r
+    case EFI_FV_FILETYPE_ALL:\r
+      Error (mGlobals.PrimaryPackagePath, 1, 0, "invalid FFS file type for this utility", NULL);\r
+      goto Done;\r
+\r
+    default:\r
+      strcat (InputString, ".FFS");\r
+      break;\r
+    }\r
+\r
+    if (ForceUncompress) {\r
+      strcat (InputString, ".ORG");\r
+    }\r
+\r
+    Out = fopen (InputString, "wb");\r
+    if (Out == NULL) {\r
+      Error (NULL, 0, 0, InputString, "failed to open output file for writing");\r
+      goto Done;\r
+    }\r
+    //\r
+    // Initialize the FFS file header\r
+    //\r
+    memset (&FileHeader, 0, sizeof (EFI_FFS_FILE_HEADER));\r
+    memcpy (&FileHeader.Name, &FfsGuid, sizeof (EFI_GUID));\r
+    FileHeader.Type       = StringToType (FileType);\r
+    FileHeader.Attributes = FfsAttrib;\r
+    //\r
+    // From this point on FileSize includes the size of the EFI_FFS_FILE_HEADER\r
+    //\r
+    FileSize += sizeof (EFI_FFS_FILE_HEADER);\r
+    //\r
+    // If using a tail, then it adds two bytes\r
+    //\r
+    if (FileHeader.Attributes & FFS_ATTRIB_TAIL_PRESENT) {\r
+      //\r
+      // Tail is not allowed for pad and 0-length files\r
+      //\r
+      if ((FileHeader.Type == EFI_FV_FILETYPE_FFS_PAD) || (FileSize == sizeof (EFI_FFS_FILE_HEADER))) {\r
+        Error (\r
+          mGlobals.PrimaryPackagePath,\r
+          1,\r
+          0,\r
+          "FFS_ATTRIB_TAIL_PRESENT=TRUE is invalid for PAD or 0-length files",\r
+          NULL\r
+          );\r
+        goto Done;\r
+      }\r
+\r
+      FileSize += sizeof (EFI_FFS_FILE_TAIL);\r
+    }\r
+\r
+    FileHeader.Size[0]  = (UINT8) (FileSize & 0xFF);\r
+    FileHeader.Size[1]  = (UINT8) ((FileSize & 0xFF00) >> 8);\r
+    FileHeader.Size[2]  = (UINT8) ((FileSize & 0xFF0000) >> 16);\r
+    //\r
+    // Fill in checksums and state, they must be 0 for checksumming.\r
+    //\r
+    // FileHeader.IntegrityCheck.Checksum.Header = 0;\r
+    // FileHeader.IntegrityCheck.Checksum.File = 0;\r
+    // FileHeader.State = 0;\r
+    //\r
+    FileHeader.IntegrityCheck.Checksum.Header = CalculateChecksum8 (\r
+                                                  (UINT8 *) &FileHeader,\r
+                                                  sizeof (EFI_FFS_FILE_HEADER)\r
+                                                  );\r
+    if (FileHeader.Attributes & FFS_ATTRIB_CHECKSUM) {\r
+      //\r
+      // Cheating here.  Since the header checksums, just calculate the checksum of the body.\r
+      // Checksum does not include the tail\r
+      //\r
+      if (FileHeader.Attributes & FFS_ATTRIB_TAIL_PRESENT) {\r
+        FileHeader.IntegrityCheck.Checksum.File = CalculateChecksum8 (\r
+                                                    FileBuffer,\r
+                                                    FileSize - sizeof (EFI_FFS_FILE_HEADER) - sizeof (EFI_FFS_FILE_TAIL)\r
+                                                    );\r
+      } else {\r
+        FileHeader.IntegrityCheck.Checksum.File = CalculateChecksum8 (\r
+                                                    FileBuffer,\r
+                                                    FileSize - sizeof (EFI_FFS_FILE_HEADER)\r
+                                                    );\r
+      }\r
+    } else {\r
+      FileHeader.IntegrityCheck.Checksum.File = FFS_FIXED_CHECKSUM;\r
+    }\r
+    //\r
+    // Set the state now. Spec says the checksum assumes the state is 0\r
+    //\r
+    FileHeader.State = EFI_FILE_HEADER_CONSTRUCTION | EFI_FILE_HEADER_VALID | EFI_FILE_DATA_VALID;\r
+    //\r
+    // If there is a tail, then set it\r
+    //\r
+    if (FileHeader.Attributes & FFS_ATTRIB_TAIL_PRESENT) {\r
+      TailValue = FileHeader.IntegrityCheck.TailReference;\r
+      TailValue = (UINT16) (~TailValue);\r
+      memcpy (\r
+        (UINT8 *) FileBuffer + FileSize - sizeof (EFI_FFS_FILE_HEADER) - sizeof (EFI_FFS_FILE_TAIL),\r
+        &TailValue,\r
+        sizeof (TailValue)\r
+        );\r
+    }\r
+    //\r
+    // Write the FFS file header\r
+    //\r
+    if (fwrite (&FileHeader, sizeof (FileHeader), 1, Out) != 1) {\r
+      Error (NULL, 0, 0, "failed to write file header contents", NULL);\r
+      goto Done;\r
+    }\r
+    //\r
+    // Write data\r
+    //\r
+    if (fwrite (FileBuffer, FileSize - sizeof (EFI_FFS_FILE_HEADER), 1, Out) != 1) {\r
+      Error (NULL, 0, 0, "failed to write file contents", NULL);\r
+      goto Done;\r
+    }\r
+  }\r
+\r
+Done:\r
+  SFPCloseFile ();\r
+  if (Out != NULL) {\r
+    fclose (Out);\r
+  }\r
+\r
+  if (PrimaryPackage != NULL) {\r
+    fclose (PrimaryPackage);\r
+  }\r
+\r
+  if (FileBuffer != NULL) {\r
+    free (FileBuffer);\r
+  }\r
+\r
+  if (OverridePackage != NULL) {\r
+    fclose (OverridePackage);\r
+  }\r
+\r
+  return GetUtilityStatus ();\r
+}\r
+\r
+int\r
+main (\r
+  INT32 argc,\r
+  CHAR8 *argv[]\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Main function.\r
+\r
+Arguments:\r
+\r
+  argc - Number of command line parameters.\r
+  argv - Array of pointers to parameter strings.\r
+\r
+Returns:\r
+  STATUS_SUCCESS - Utility exits successfully.\r
+  STATUS_ERROR   - Some error occurred during execution.\r
+\r
+--*/\r
+{\r
+  STATUS  Status;\r
+  //\r
+  // Set the name of our utility for error reporting purposes.\r
+  //\r
+  SetUtilityName (UTILITY_NAME);\r
+  Status = ProcessCommandLineArgs (argc, argv);\r
+  if (Status != STATUS_SUCCESS) {\r
+    return Status;\r
+  }\r
+\r
+  Status = MainEntry (argc, argv, TRUE);\r
+  if (Status == STATUS_SUCCESS) {\r
+    MainEntry (argc, argv, FALSE);\r
+  }\r
+  //\r
+  // If any errors were reported via the standard error reporting\r
+  // routines, then the status has been saved. Get the value and\r
+  // return it to the caller.\r
+  //\r
+  return GetUtilityStatus ();\r
+}\r
+\r
+static\r
+STATUS\r
+ProcessCommandLineArgs (\r
+  int     Argc,\r
+  char    *Argv[]\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Process the command line arguments.\r
+\r
+Arguments:\r
+  Argc - as passed in to main()\r
+  Argv - as passed in to main()\r
+\r
+Returns:\r
+  STATUS_SUCCESS    - arguments all ok\r
+  STATUS_ERROR      - problem with args, so caller should exit\r
+\r
+--*/\r
+{\r
+  //\r
+  // If no args, then print usage instructions and return an error\r
+  //\r
+  if (Argc == 1) {\r
+    PrintUsage ();\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  memset (&mGlobals, 0, sizeof (mGlobals));\r
+  Argc--;\r
+  Argv++;\r
+  while (Argc > 0) {\r
+    if (strcmpi (Argv[0], "-b") == 0) {\r
+      //\r
+      // OPTION: -b BuildDirectory\r
+      // Make sure there is another argument, then save it to our globals.\r
+      //\r
+      if (Argc < 2) {\r
+        Error (NULL, 0, 0, "-b option requires the build directory name", NULL);\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      if (mGlobals.BuildDirectory[0]) {\r
+        Error (NULL, 0, 0, Argv[0], "option can only be specified once");\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      strcpy (mGlobals.BuildDirectory, Argv[1]);\r
+      Argc--;\r
+      Argv++;\r
+    } else if (strcmpi (Argv[0], "-p1") == 0) {\r
+      //\r
+      // OPTION: -p1 PrimaryPackageFile\r
+      // Make sure there is another argument, then save it to our globals.\r
+      //\r
+      if (Argc < 2) {\r
+        Error (NULL, 0, 0, Argv[0], "option requires the primary package file name");\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      if (mGlobals.PrimaryPackagePath[0]) {\r
+        Error (NULL, 0, 0, Argv[0], "option can only be specified once");\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      strcpy (mGlobals.PrimaryPackagePath, Argv[1]);\r
+      Argc--;\r
+      Argv++;\r
+    } else if (strcmpi (Argv[0], "-p2") == 0) {\r
+      //\r
+      // OPTION: -p2 OverridePackageFile\r
+      // Make sure there is another argument, then save it to our globals.\r
+      //\r
+      if (Argc < 2) {\r
+        Error (NULL, 0, 0, Argv[0], "option requires the override package file name");\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      if (mGlobals.OverridePackagePath[0]) {\r
+        Error (NULL, 0, 0, Argv[0], "option can only be specified once");\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      strcpy (mGlobals.OverridePackagePath, Argv[1]);\r
+      Argc--;\r
+      Argv++;\r
+    } else if (strcmpi (Argv[0], "-v") == 0) {\r
+      //\r
+      // OPTION: -v       verbose\r
+      //\r
+      mGlobals.Verbose = TRUE;\r
+    } else if (strcmpi (Argv[0], "-h") == 0) {\r
+      //\r
+      // OPTION: -h      help\r
+      //\r
+      PrintUsage ();\r
+      return STATUS_ERROR;\r
+    } else if (strcmpi (Argv[0], "-?") == 0) {\r
+      //\r
+      // OPTION:  -?      help\r
+      //\r
+      PrintUsage ();\r
+      return STATUS_ERROR;\r
+    } else {\r
+      Error (NULL, 0, 0, Argv[0], "unrecognized option");\r
+      PrintUsage ();\r
+      return STATUS_ERROR;\r
+    }\r
+\r
+    Argv++;\r
+    Argc--;\r
+  }\r
+  //\r
+  // Must have at least specified the package file name\r
+  //\r
+  if (mGlobals.PrimaryPackagePath[0] == 0) {\r
+    Error (NULL, 0, 0, "must specify primary package file", NULL);\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  return STATUS_SUCCESS;\r
+}\r
diff --git a/Tools/CodeTools/Source/GenFfsFile/GenFfsFile.h b/Tools/CodeTools/Source/GenFfsFile/GenFfsFile.h
new file mode 100644 (file)
index 0000000..f5bc718
--- /dev/null
@@ -0,0 +1,36 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  GenFfsFile.h \r
+\r
+Abstract:\r
+\r
+  Header file for GenFfsFile.\r
+\r
+--*/\r
+\r
+//\r
+// Module Coded to Tiano Coding Conventions\r
+//\r
+#ifndef _EFI_GEN_FFSFILE_H\r
+#define _EFI_GEN_FFSFILE_H\r
+\r
+//\r
+// External Files Referenced\r
+//\r
+#include <Common/UefiBaseTypes.h>\r
+#include <Common/FirmwareVolumeImageFormat.h>\r
+\r
+#include "MyAlloc.h"\r
+\r
+#endif\r
diff --git a/Tools/CodeTools/Source/GenFfsFile/SimpleFileParsing.c b/Tools/CodeTools/Source/GenFfsFile/SimpleFileParsing.c
new file mode 100644 (file)
index 0000000..5fa5a22
--- /dev/null
@@ -0,0 +1,969 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  SimpleFileParsing.c  \r
+\r
+Abstract:\r
+\r
+  Generic but simple file parsing routines.\r
+\r
+--*/\r
+\r
+#include <stdio.h>\r
+#include <string.h>\r
+#include <stdlib.h>\r
+#include <ctype.h>\r
+\r
+#include <Common/UefiBaseTypes.h>\r
+\r
+#include "EfiUtilityMsgs.h"\r
+#include "SimpleFileParsing.h"\r
+\r
+#define MAX_PATH                    255\r
+#define MAX_NEST_DEPTH              20  // just in case we get in an endless loop.\r
+#define MAX_STRING_IDENTIFIER_NAME  100 // number of wchars\r
+#define MAX_LINE_LEN                400\r
+\r
+#define T_CHAR_SPACE                ' '\r
+#define T_CHAR_NULL                 0\r
+#define T_CHAR_CR                   '\r'\r
+#define T_CHAR_TAB                  '\t'\r
+#define T_CHAR_LF                   '\n'\r
+#define T_CHAR_SLASH                '/'\r
+#define T_CHAR_BACKSLASH            '\\'\r
+#define T_CHAR_DOUBLE_QUOTE         '"'\r
+#define T_CHAR_LC_X                 'x'\r
+#define T_CHAR_0                    '0'\r
+\r
+//\r
+// We keep a linked list of these for the source files we process\r
+//\r
+typedef struct _SOURCE_FILE {\r
+  FILE                *Fptr;\r
+  T_CHAR              *FileBuffer;\r
+  T_CHAR              *FileBufferPtr;\r
+  UINT32              FileSize;\r
+  INT8                FileName[MAX_PATH];\r
+  UINT32              LineNum;\r
+  BOOLEAN             EndOfFile;\r
+  BOOLEAN             SkipToHash;\r
+  struct _SOURCE_FILE *Previous;\r
+  struct _SOURCE_FILE *Next;\r
+  T_CHAR              ControlCharacter;\r
+} SOURCE_FILE;\r
+\r
+//\r
+// Here's all our module globals.\r
+//\r
+static struct {\r
+  SOURCE_FILE SourceFile;\r
+  BOOLEAN     Verbose;\r
+} mGlobals;\r
+\r
+static\r
+UINT32\r
+t_strcmp (\r
+  T_CHAR *Buffer,\r
+  T_CHAR *Str\r
+  );\r
+\r
+static\r
+UINT32\r
+t_strncmp (\r
+  T_CHAR *Str1,\r
+  T_CHAR *Str2,\r
+  UINT32 Len\r
+  );\r
+\r
+static\r
+UINT32\r
+t_strlen (\r
+  T_CHAR *Str\r
+  );\r
+\r
+static\r
+void\r
+RewindFile (\r
+  SOURCE_FILE *SourceFile\r
+  );\r
+\r
+static\r
+BOOLEAN\r
+SkipTo (\r
+  SOURCE_FILE *SourceFile,\r
+  T_CHAR      TChar,\r
+  BOOLEAN     StopAfterNewline\r
+  );\r
+\r
+static\r
+BOOLEAN\r
+IsWhiteSpace (\r
+  SOURCE_FILE *SourceFile\r
+  );\r
+\r
+static\r
+UINT32\r
+SkipWhiteSpace (\r
+  SOURCE_FILE *SourceFile\r
+  );\r
+\r
+static\r
+BOOLEAN\r
+EndOfFile (\r
+  SOURCE_FILE *SourceFile\r
+  );\r
+\r
+static\r
+void\r
+PreprocessFile (\r
+  SOURCE_FILE *SourceFile\r
+  );\r
+\r
+//\r
+// static\r
+// T_CHAR *\r
+// GetQuotedString (\r
+//  SOURCE_FILE *SourceFile,\r
+//  BOOLEAN     Optional\r
+//  );\r
+//\r
+static\r
+T_CHAR  *\r
+t_strcpy (\r
+  T_CHAR *Dest,\r
+  T_CHAR *Src\r
+  );\r
+\r
+static\r
+STATUS\r
+ProcessIncludeFile (\r
+  SOURCE_FILE *SourceFile,\r
+  SOURCE_FILE *ParentSourceFile\r
+  );\r
+\r
+static\r
+STATUS\r
+ParseFile (\r
+  SOURCE_FILE *SourceFile\r
+  );\r
+\r
+static\r
+FILE    *\r
+FindFile (\r
+  IN INT8     *FileName,\r
+  OUT INT8    *FoundFileName,\r
+  IN UINT32   FoundFileNameLen\r
+  );\r
+\r
+static\r
+STATUS\r
+ProcessFile (\r
+  SOURCE_FILE *SourceFile\r
+  );\r
+\r
+STATUS\r
+SFPInit (\r
+  VOID\r
+  )\r
+{\r
+  memset ((void *) &mGlobals, 0, sizeof (mGlobals));\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+UINT32\r
+SFPGetLineNumber (\r
+  VOID\r
+  )\r
+{\r
+  return mGlobals.SourceFile.LineNum;\r
+}\r
+\r
+/*++\r
+\r
+Routine Description:\r
+  Return the line number of the file we're parsing. Used\r
+  for error reporting purposes.\r
+\r
+Arguments:\r
+  None.\r
+\r
+Returns:\r
+  The line number, or 0 if no file is being processed\r
+\r
+--*/\r
+T_CHAR *\r
+SFPGetFileName (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Return the name of the file we're parsing. Used\r
+  for error reporting purposes.\r
+\r
+Arguments:\r
+  None.\r
+\r
+Returns:\r
+  A pointer to the file name. Null if no file is being\r
+  processed.\r
+\r
+--*/\r
+{\r
+  if (mGlobals.SourceFile.FileName[0]) {\r
+    return mGlobals.SourceFile.FileName;\r
+  }\r
+\r
+  return NULL;\r
+}\r
+\r
+STATUS\r
+SFPOpenFile (\r
+  IN INT8   *FileName\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Open a file for parsing.\r
+\r
+Arguments:\r
+  FileName  - name of the file to parse\r
+\r
+Returns:\r
+  \r
+\r
+--*/\r
+{\r
+  STATUS  Status;\r
+  t_strcpy (mGlobals.SourceFile.FileName, FileName);\r
+  Status = ProcessIncludeFile (&mGlobals.SourceFile, NULL);\r
+  return Status;\r
+}\r
+\r
+BOOLEAN\r
+SFPIsToken (\r
+  T_CHAR *Str\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Check to see if the specified token is found at\r
+  the current position in the input file.\r
+\r
+Arguments:\r
+  Str - the token to look for\r
+\r
+Returns:\r
+  TRUE - the token is next\r
+  FALSE - the token is not next\r
+\r
+Notes:\r
+  We do a simple string comparison on this function. It is\r
+  the responsibility of the caller to ensure that the token\r
+  is not a subset of some other token.\r
+\r
+  The file pointer is advanced past the token in the input file.\r
+\r
+--*/\r
+{\r
+  UINT32  Len;\r
+  SkipWhiteSpace (&mGlobals.SourceFile);\r
+\r
+  if ((Len = t_strcmp (mGlobals.SourceFile.FileBufferPtr, Str)) > 0) {\r
+    mGlobals.SourceFile.FileBufferPtr += Len;\r
+    return TRUE;\r
+  }\r
+\r
+  return FALSE;\r
+\r
+}\r
+\r
+BOOLEAN\r
+SFPGetNextToken (\r
+  T_CHAR *Str,\r
+  UINT32 Len\r
+  )\r
+{\r
+  UINT32  Index;\r
+  SkipWhiteSpace (&mGlobals.SourceFile);\r
+  Index = 0;\r
+  while (!EndOfFile (&mGlobals.SourceFile) && (Index < Len)) {\r
+    if (IsWhiteSpace (&mGlobals.SourceFile)) {\r
+      if (Index > 0) {\r
+        Str[Index] = 0;\r
+        return TRUE;\r
+      }\r
+\r
+      return FALSE;\r
+    } else {\r
+      Str[Index] = mGlobals.SourceFile.FileBufferPtr[0];\r
+      mGlobals.SourceFile.FileBufferPtr++;\r
+      Index++;\r
+    }\r
+  }\r
+\r
+  return FALSE;\r
+}\r
+\r
+BOOLEAN\r
+SFPSkipToToken (\r
+  T_CHAR *Str\r
+  )\r
+{\r
+  UINT32  Len;\r
+  T_CHAR  *SavePos;\r
+  Len     = t_strlen (Str);\r
+  SavePos = mGlobals.SourceFile.FileBufferPtr;\r
+  SkipWhiteSpace (&mGlobals.SourceFile);\r
+  while (!EndOfFile (&mGlobals.SourceFile)) {\r
+    if (t_strncmp (Str, mGlobals.SourceFile.FileBufferPtr, Len) == 0) {\r
+      mGlobals.SourceFile.FileBufferPtr += Len;\r
+      return TRUE;\r
+    }\r
+\r
+    mGlobals.SourceFile.FileBufferPtr++;\r
+    SkipWhiteSpace (&mGlobals.SourceFile);\r
+  }\r
+\r
+  mGlobals.SourceFile.FileBufferPtr = SavePos;\r
+  return FALSE;\r
+}\r
+\r
+BOOLEAN\r
+SFPGetNumber (\r
+  UINT32   *Value\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Check the token at the current file position for a numeric value.\r
+  May be either decimal or hex.\r
+\r
+Arguments:\r
+  Value  - pointer where to store the value\r
+\r
+Returns:\r
+  FALSE    - current token is not a number\r
+  TRUE     - current token is a number\r
+\r
+--*/\r
+{\r
+  //\r
+  //  UINT32 Len;\r
+  //\r
+  SkipWhiteSpace (&mGlobals.SourceFile);\r
+  if (EndOfFile (&mGlobals.SourceFile)) {\r
+    return FALSE;\r
+  }\r
+\r
+  if (isdigit (mGlobals.SourceFile.FileBufferPtr[0])) {\r
+    //\r
+    // Check for hex value\r
+    //\r
+    if ((mGlobals.SourceFile.FileBufferPtr[0] == T_CHAR_0) && (mGlobals.SourceFile.FileBufferPtr[1] == T_CHAR_LC_X)) {\r
+      if (!isxdigit (mGlobals.SourceFile.FileBufferPtr[2])) {\r
+        return FALSE;\r
+      }\r
+\r
+      mGlobals.SourceFile.FileBufferPtr += 2;\r
+      sscanf (mGlobals.SourceFile.FileBufferPtr, "%x", Value);\r
+      while (isxdigit (mGlobals.SourceFile.FileBufferPtr[0])) {\r
+        mGlobals.SourceFile.FileBufferPtr++;\r
+      }\r
+\r
+      return TRUE;\r
+    } else {\r
+      *Value = atoi (mGlobals.SourceFile.FileBufferPtr);\r
+      while (isdigit (mGlobals.SourceFile.FileBufferPtr[0])) {\r
+        mGlobals.SourceFile.FileBufferPtr++;\r
+      }\r
+\r
+      return TRUE;\r
+    }\r
+  } else {\r
+    return FALSE;\r
+  }\r
+}\r
+\r
+STATUS\r
+SFPCloseFile (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Close the file being parsed.\r
+\r
+Arguments:\r
+  None.\r
+\r
+Returns:\r
+  STATUS_SUCCESS - the file was closed \r
+  STATUS_ERROR   - no file is currently open\r
+\r
+--*/\r
+{\r
+  if (mGlobals.SourceFile.FileBuffer != NULL) {\r
+    free (mGlobals.SourceFile.FileBuffer);\r
+    memset (&mGlobals.SourceFile, 0, sizeof (mGlobals.SourceFile));\r
+    return STATUS_SUCCESS;\r
+  }\r
+\r
+  return STATUS_ERROR;\r
+}\r
+\r
+static\r
+STATUS\r
+ProcessIncludeFile (\r
+  SOURCE_FILE *SourceFile,\r
+  SOURCE_FILE *ParentSourceFile\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Given a source file, open the file and parse it\r
+  \r
+Arguments:\r
+\r
+  SourceFile        - name of file to parse\r
+  ParentSourceFile  - for error reporting purposes, the file that #included SourceFile.\r
+\r
+Returns:\r
+\r
+  Standard status.\r
+  \r
+--*/\r
+{\r
+  static UINT32 NestDepth = 0;\r
+  INT8          FoundFileName[MAX_PATH];\r
+  STATUS        Status;\r
+\r
+  Status = STATUS_SUCCESS;\r
+  NestDepth++;\r
+  //\r
+  // Print the file being processed. Indent so you can tell the include nesting\r
+  // depth.\r
+  //\r
+  if (mGlobals.Verbose) {\r
+    fprintf (stdout, "%*cProcessing file '%s'\n", NestDepth * 2, ' ', SourceFile->FileName);\r
+  }\r
+\r
+  //\r
+  // Make sure we didn't exceed our maximum nesting depth\r
+  //\r
+  if (NestDepth > MAX_NEST_DEPTH) {\r
+    Error (NULL, 0, 0, SourceFile->FileName, "max nesting depth (%d) exceeded", NestDepth);\r
+    Status = STATUS_ERROR;\r
+    goto Finish;\r
+  }\r
+  //\r
+  // Try to open the file locally, and if that fails try along our include paths.\r
+  //\r
+  strcpy (FoundFileName, SourceFile->FileName);\r
+  if ((SourceFile->Fptr = fopen (FoundFileName, "r")) == NULL) {\r
+    //\r
+    // Try to find it among the paths if it has a parent (that is, it is included\r
+    // by someone else).\r
+    //\r
+    Error (NULL, 0, 0, SourceFile->FileName, "file not found");\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Process the file found\r
+  //\r
+  ProcessFile (SourceFile);\r
+Finish:\r
+  //\r
+  // Close open files and return status\r
+  //\r
+  if (SourceFile->Fptr != NULL) {\r
+    fclose (SourceFile->Fptr);\r
+    SourceFile->Fptr = NULL;\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
+static\r
+STATUS\r
+ProcessFile (\r
+  SOURCE_FILE *SourceFile\r
+  )\r
+{\r
+  //\r
+  // Get the file size, and then read the entire thing into memory.\r
+  // Allocate space for a terminator character.\r
+  //\r
+  fseek (SourceFile->Fptr, 0, SEEK_END);\r
+  SourceFile->FileSize = ftell (SourceFile->Fptr);\r
+  fseek (SourceFile->Fptr, 0, SEEK_SET);\r
+  SourceFile->FileBuffer = (T_CHAR *) malloc (SourceFile->FileSize + sizeof (T_CHAR));\r
+  if (SourceFile->FileBuffer == NULL) {\r
+    Error (NULL, 0, 0, "memory allocation failure", NULL);\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  fread ((VOID *) SourceFile->FileBuffer, SourceFile->FileSize, 1, SourceFile->Fptr);\r
+  SourceFile->FileBuffer[(SourceFile->FileSize / sizeof (T_CHAR))] = T_CHAR_NULL;\r
+  //\r
+  // Pre-process the file to replace comments with spaces\r
+  //\r
+  PreprocessFile (SourceFile);\r
+  SourceFile->LineNum = 1;\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+void\r
+PreprocessFile (\r
+  SOURCE_FILE *SourceFile\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Preprocess a file to replace all carriage returns with NULLs so\r
+  we can print lines from the file to the screen.\r
+  \r
+Arguments:\r
+  SourceFile - structure that we use to keep track of an input file.\r
+\r
+Returns:\r
+  Nothing.\r
+  \r
+--*/\r
+{\r
+  BOOLEAN InComment;\r
+\r
+  RewindFile (SourceFile);\r
+  InComment = FALSE;\r
+  while (!EndOfFile (SourceFile)) {\r
+    //\r
+    // If a line-feed, then no longer in a comment\r
+    //\r
+    if (SourceFile->FileBufferPtr[0] == T_CHAR_LF) {\r
+      SourceFile->FileBufferPtr++;\r
+      SourceFile->LineNum++;\r
+      InComment = 0;\r
+    } else if (SourceFile->FileBufferPtr[0] == T_CHAR_CR) {\r
+      //\r
+      // Replace all carriage returns with a NULL so we can print stuff\r
+      //\r
+      SourceFile->FileBufferPtr[0] = 0;\r
+      SourceFile->FileBufferPtr++;\r
+    } else if (InComment) {\r
+      SourceFile->FileBufferPtr[0] = T_CHAR_SPACE;\r
+      SourceFile->FileBufferPtr++;\r
+    } else if ((SourceFile->FileBufferPtr[0] == T_CHAR_SLASH) && (SourceFile->FileBufferPtr[1] == T_CHAR_SLASH)) {\r
+      SourceFile->FileBufferPtr += 2;\r
+      InComment = TRUE;\r
+    } else {\r
+      SourceFile->FileBufferPtr++;\r
+    }\r
+  }\r
+  //\r
+  // Could check for end-of-file and still in a comment, but\r
+  // should not be necessary. So just restore the file pointers.\r
+  //\r
+  RewindFile (SourceFile);\r
+}\r
+\r
+#if 0\r
+static\r
+T_CHAR *\r
+GetQuotedString (\r
+  SOURCE_FILE *SourceFile,\r
+  BOOLEAN     Optional\r
+  )\r
+{\r
+  T_CHAR  *String;\r
+  T_CHAR  *Start;\r
+  T_CHAR  *Ptr;\r
+  UINT32  Len;\r
+  BOOLEAN PreviousBackslash;\r
+\r
+  if (SourceFile->FileBufferPtr[0] != T_CHAR_DOUBLE_QUOTE) {\r
+    if (!Optional) {\r
+      Error (SourceFile->FileName, SourceFile->LineNum, 0, "expected quoted string", "%S", SourceFile->FileBufferPtr);\r
+    }\r
+\r
+    return NULL;\r
+  }\r
+\r
+  Len = 0;\r
+  SourceFile->FileBufferPtr++;\r
+  Start             = Ptr = SourceFile->FileBufferPtr;\r
+  PreviousBackslash = FALSE;\r
+  while (!EndOfFile (SourceFile)) {\r
+    if ((SourceFile->FileBufferPtr[0] == T_CHAR_DOUBLE_QUOTE) && (!PreviousBackslash)) {\r
+      break;\r
+    } else if (SourceFile->FileBufferPtr[0] == T_CHAR_CR) {\r
+      Warning (SourceFile->FileName, SourceFile->LineNum, 0, "carriage return found in quoted string", "%S", Start);\r
+      PreviousBackslash = FALSE;\r
+    } else if (SourceFile->FileBufferPtr[0] == T_CHAR_BACKSLASH) {\r
+      PreviousBackslash = TRUE;\r
+    } else {\r
+      PreviousBackslash = FALSE;\r
+    }\r
+\r
+    SourceFile->FileBufferPtr++;\r
+    Len++;\r
+  }\r
+\r
+  if (SourceFile->FileBufferPtr[0] != T_CHAR_DOUBLE_QUOTE) {\r
+    Warning (SourceFile->FileName, SourceFile->LineNum, 0, "missing closing quote on string", "%S", Start);\r
+  } else {\r
+    SourceFile->FileBufferPtr++;\r
+  }\r
+  //\r
+  // Now allocate memory for the string and save it off\r
+  //\r
+  String = (T_CHAR *) malloc ((Len + 1) * sizeof (T_CHAR));\r
+  if (String == NULL) {\r
+    Error (NULL, 0, 0, "memory allocation failed", NULL);\r
+    return NULL;\r
+  }\r
+  //\r
+  // Copy the string from the file buffer to the local copy.\r
+  // We do no reformatting of it whatsoever at this point.\r
+  //\r
+  Ptr = String;\r
+  while (Len > 0) {\r
+    *Ptr = *Start;\r
+    Start++;\r
+    Ptr++;\r
+    Len--;\r
+  }\r
+\r
+  *Ptr = 0;\r
+  return String;\r
+}\r
+#endif\r
+static\r
+BOOLEAN\r
+EndOfFile (\r
+  SOURCE_FILE *SourceFile\r
+  )\r
+{\r
+  //\r
+  // The file buffer pointer will typically get updated before the End-of-file flag in the\r
+  // source file structure, so check it first.\r
+  //\r
+  if (SourceFile->FileBufferPtr >= SourceFile->FileBuffer + SourceFile->FileSize / sizeof (T_CHAR)) {\r
+    SourceFile->EndOfFile = TRUE;\r
+    return TRUE;\r
+  }\r
+\r
+  if (SourceFile->EndOfFile) {\r
+    return TRUE;\r
+  }\r
+\r
+  return FALSE;\r
+}\r
+\r
+#if 0\r
+static\r
+void\r
+ProcessTokenInclude (\r
+  SOURCE_FILE *SourceFile\r
+  )\r
+{\r
+  INT8        IncludeFileName[MAX_PATH];\r
+  INT8        *To;\r
+  UINT32      Len;\r
+  BOOLEAN     ReportedError;\r
+  SOURCE_FILE IncludedSourceFile;\r
+\r
+  ReportedError = FALSE;\r
+  if (SkipWhiteSpace (SourceFile) == 0) {\r
+    Warning (SourceFile->FileName, SourceFile->LineNum, 0, "expected whitespace following #include keyword", NULL);\r
+  }\r
+  //\r
+  // Should be quoted file name\r
+  //\r
+  if (SourceFile->FileBufferPtr[0] != T_CHAR_DOUBLE_QUOTE) {\r
+    Error (SourceFile->FileName, SourceFile->LineNum, 0, "expected quoted include file name", NULL);\r
+    goto FailDone;\r
+  }\r
+\r
+  SourceFile->FileBufferPtr++;\r
+  //\r
+  // Copy the filename as ascii to our local string\r
+  //\r
+  To  = IncludeFileName;\r
+  Len = 0;\r
+  while (!EndOfFile (SourceFile)) {\r
+    if ((SourceFile->FileBufferPtr[0] == T_CHAR_CR) || (SourceFile->FileBufferPtr[0] == T_CHAR_LF)) {\r
+      Error (SourceFile->FileName, SourceFile->LineNum, 0, "end-of-line found in quoted include file name", NULL);\r
+      goto FailDone;\r
+    }\r
+\r
+    if (SourceFile->FileBufferPtr[0] == T_CHAR_DOUBLE_QUOTE) {\r
+      SourceFile->FileBufferPtr++;\r
+      break;\r
+    }\r
+    //\r
+    // If too long, then report the error once and process until the closing quote\r
+    //\r
+    Len++;\r
+    if (!ReportedError && (Len >= sizeof (IncludeFileName))) {\r
+      Error (SourceFile->FileName, SourceFile->LineNum, 0, "length of include file name exceeds limit", NULL);\r
+      ReportedError = TRUE;\r
+    }\r
+\r
+    if (!ReportedError) {\r
+      //\r
+      // *To = UNICODE_TO_ASCII(SourceFile->FileBufferPtr[0]);\r
+      //\r
+      *To = (T_CHAR) SourceFile->FileBufferPtr[0];\r
+      To++;\r
+    }\r
+\r
+    SourceFile->FileBufferPtr++;\r
+  }\r
+\r
+  if (!ReportedError) {\r
+    *To = 0;\r
+    memset ((char *) &IncludedSourceFile, 0, sizeof (SOURCE_FILE));\r
+    strcpy (IncludedSourceFile.FileName, IncludeFileName);\r
+    //\r
+    // IncludedSourceFile.ControlCharacter = DEFAULT_CONTROL_CHARACTER;\r
+    //\r
+    ProcessIncludeFile (&IncludedSourceFile, SourceFile);\r
+    //\r
+    // printf ("including file '%s'\n", IncludeFileName);\r
+    //\r
+  }\r
+\r
+  return ;\r
+FailDone:\r
+  //\r
+  // Error recovery -- skip to next #\r
+  //\r
+  SourceFile->SkipToHash = TRUE;\r
+}\r
+#endif\r
+static\r
+BOOLEAN\r
+IsWhiteSpace (\r
+  SOURCE_FILE *SourceFile\r
+  )\r
+{\r
+  switch (*SourceFile->FileBufferPtr) {\r
+  case T_CHAR_NULL:\r
+  case T_CHAR_CR:\r
+  case T_CHAR_SPACE:\r
+  case T_CHAR_TAB:\r
+  case T_CHAR_LF:\r
+    return TRUE;\r
+\r
+  default:\r
+    return FALSE;\r
+  }\r
+}\r
+\r
+UINT32\r
+SkipWhiteSpace (\r
+  SOURCE_FILE *SourceFile\r
+  )\r
+{\r
+  UINT32  Count;\r
+\r
+  Count = 0;\r
+  while (!EndOfFile (SourceFile)) {\r
+    Count++;\r
+    switch (*SourceFile->FileBufferPtr) {\r
+    case T_CHAR_NULL:\r
+    case T_CHAR_CR:\r
+    case T_CHAR_SPACE:\r
+    case T_CHAR_TAB:\r
+      SourceFile->FileBufferPtr++;\r
+      break;\r
+\r
+    case T_CHAR_LF:\r
+      SourceFile->FileBufferPtr++;\r
+      SourceFile->LineNum++;\r
+      if (mGlobals.Verbose) {\r
+        printf ("%d: %S\n", SourceFile->LineNum, SourceFile->FileBufferPtr);\r
+      }\r
+      break;\r
+\r
+    default:\r
+      return Count - 1;\r
+    }\r
+  }\r
+  //\r
+  // Some tokens require trailing whitespace. If we're at the end of the\r
+  // file, then we count that as well.\r
+  //\r
+  if ((Count == 0) && (EndOfFile (SourceFile))) {\r
+    Count++;\r
+  }\r
+\r
+  return Count;\r
+}\r
+\r
+static\r
+UINT32\r
+t_strcmp (\r
+  T_CHAR *Buffer,\r
+  T_CHAR *Str\r
+  )\r
+{\r
+  UINT32  Len;\r
+\r
+  Len = 0;\r
+  while (*Str == *Buffer) {\r
+    Buffer++;\r
+    Str++;\r
+    Len++;\r
+  }\r
+\r
+  if (*Str) {\r
+    return 0;\r
+  }\r
+\r
+  return Len;\r
+}\r
+\r
+static\r
+UINT32\r
+t_strlen (\r
+  T_CHAR *Str\r
+  )\r
+{\r
+  UINT32  Len;\r
+  Len = 0;\r
+  while (*Str) {\r
+    Len++;\r
+    Str++;\r
+  }\r
+\r
+  return Len;\r
+}\r
+\r
+static\r
+UINT32\r
+t_strncmp (\r
+  T_CHAR *Str1,\r
+  T_CHAR *Str2,\r
+  UINT32 Len\r
+  )\r
+{\r
+  while (Len > 0) {\r
+    if (*Str1 != *Str2) {\r
+      return Len;\r
+    }\r
+\r
+    Len--;\r
+    Str1++;\r
+    Str2++;\r
+  }\r
+\r
+  return 0;\r
+}\r
+\r
+static\r
+T_CHAR *\r
+t_strcpy (\r
+  T_CHAR *Dest,\r
+  T_CHAR *Src\r
+  )\r
+{\r
+  T_CHAR  *SaveDest;\r
+  SaveDest = Dest;\r
+  while (*Src) {\r
+    *Dest = *Src;\r
+    Dest++;\r
+    Src++;\r
+  }\r
+\r
+  *Dest = 0;\r
+  return SaveDest;\r
+}\r
+\r
+#if 0\r
+static\r
+BOOLEAN\r
+IsValidIdentifierChar (\r
+  INT8      Char,\r
+  BOOLEAN   FirstChar\r
+  )\r
+{\r
+  //\r
+  // If it's the first character of an identifier, then\r
+  // it must be one of [A-Za-z_].\r
+  //\r
+  if (FirstChar) {\r
+    if (isalpha (Char) || (Char == '_')) {\r
+      return TRUE;\r
+    }\r
+  } else {\r
+    //\r
+    // If it's not the first character, then it can\r
+    // be one of [A-Za-z_0-9]\r
+    //\r
+    if (isalnum (Char) || (Char == '_')) {\r
+      return TRUE;\r
+    }\r
+  }\r
+\r
+  return FALSE;\r
+}\r
+#endif\r
+static\r
+void\r
+RewindFile (\r
+  SOURCE_FILE *SourceFile\r
+  )\r
+{\r
+  SourceFile->LineNum       = 1;\r
+  SourceFile->FileBufferPtr = SourceFile->FileBuffer;\r
+  SourceFile->EndOfFile     = 0;\r
+}\r
+\r
+#if 0\r
+static\r
+BOOLEAN\r
+SkipTo (\r
+  SOURCE_FILE  *SourceFile,\r
+  T_CHAR       TChar,\r
+  BOOLEAN      StopAfterNewline\r
+  )\r
+{\r
+  while (!EndOfFile (SourceFile)) {\r
+    //\r
+    // Check for the character of interest\r
+    //\r
+    if (SourceFile->FileBufferPtr[0] == TChar) {\r
+      return TRUE;\r
+    } else {\r
+      if (SourceFile->FileBufferPtr[0] == T_CHAR_LF) {\r
+        SourceFile->LineNum++;\r
+        if (StopAfterNewline) {\r
+          SourceFile->FileBufferPtr++;\r
+          if (SourceFile->FileBufferPtr[0] == 0) {\r
+            SourceFile->FileBufferPtr++;\r
+          }\r
+\r
+          return FALSE;\r
+        }\r
+      }\r
+\r
+      SourceFile->FileBufferPtr++;\r
+    }\r
+  }\r
+\r
+  return FALSE;\r
+}\r
+#endif\r
diff --git a/Tools/CodeTools/Source/GenFfsFile/build.xml b/Tools/CodeTools/Source/GenFfsFile/build.xml
new file mode 100644 (file)
index 0000000..b7f8681
--- /dev/null
@@ -0,0 +1,71 @@
+<?xml version="1.0" ?>\r
+<!--\r
+Copyright (c) 2006, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+-->\r
+<project default="GenTool" basedir=".">\r
+<!--\r
+    EDK GenFfsFile Tool\r
+  Copyright (c) 2006, Intel Corporation\r
+-->\r
+  <property name="ToolName" value="GenFfsFile"/>\r
+  <property name="FileSet" value="GenFfsFile.c"/>\r
+\r
+  <taskdef resource="cpptasks.tasks"/>\r
+  <typedef resource="cpptasks.types"/>\r
+  <taskdef resource="net/sf/antcontrib/antlib.xml"/>\r
+\r
+  <property name="LINK_OUTPUT_TYPE" value="static"/>\r
+  <property name="BUILD_DIR" value="${PACKAGE_DIR}/${ToolName}/tmp"/>\r
+\r
+  <target name="GenTool" depends="init, Tool">\r
+    <echo message="The EDK Tool: ${ToolName} build has completed!"/>\r
+  </target>\r
+\r
+  <target name="init">\r
+    <echo message="Building the EDK Tool: ${ToolName}"/>\r
+    <mkdir dir="${BUILD_DIR}"/>\r
+  </target>\r
+\r
+  <target name="Tool" depends="init">\r
+    <cc name="${ToolChain}" objdir="${BUILD_DIR}" \r
+        outfile="${BIN_DIR}/${ToolName}"\r
+        outtype="executable"\r
+        debug="true"\r
+        optimize="speed">\r
+      <compilerarg value="${ExtraArgus}" if="ExtraArgus" />\r
+\r
+      <fileset dir="${basedir}/${ToolName}" \r
+        includes="${FileSet}" \r
+        defaultexcludes="TRUE" \r
+        excludes="*.xml *.inf"/>\r
+\r
+      <includepath path="${PACKAGE_DIR}/Include"/>\r
+      <includepath path="${PACKAGE_DIR}/Include/${HostArch}"/>\r
+      <includepath path="${PACKAGE_DIR}/Common"/>\r
+      <libset dir="${LIB_DIR}" libs="CommonTools CustomizedCompress"/>\r
+    </cc>\r
+  </target>\r
+\r
+  <target name="clean">\r
+    <echo message="Removing Intermediate Files Only"/>  \r
+    <delete>\r
+      <fileset dir="${BUILD_DIR}" includes="*.obj"/>\r
+    </delete>\r
+  </target>\r
+\r
+  <target name="cleanall">\r
+    <echo message="Removing Object Files and the Executable: ${ToolName}${ext_exe}"/>  \r
+    <delete failonerror="false" quiet="true" includeEmptyDirs="true">\r
+      <fileset dir="${BUILD_DIR}"/>\r
+      <fileset file="${BIN_DIR}/${ToolName}${ext_exe}"/>\r
+    </delete>\r
+  </target>\r
+\r
+</project>\r
diff --git a/Tools/CodeTools/Source/GenFvImage/Ebc/PeCoffLoaderEx.c b/Tools/CodeTools/Source/GenFvImage/Ebc/PeCoffLoaderEx.c
new file mode 100644 (file)
index 0000000..e8cf8b6
--- /dev/null
@@ -0,0 +1,57 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+    PeCoffLoaderEx.c\r
+\r
+Abstract:\r
+\r
+    EBC Specific relocation fixups\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+\r
+\r
+\r
+RETURN_STATUS\r
+PeCoffLoaderRelocateImageEx (\r
+  IN UINT16      *Reloc,\r
+  IN OUT CHAR8   *Fixup,\r
+  IN OUT CHAR8   **FixupData,\r
+  IN UINT64      Adjust\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Performs an IA-32 specific relocation fixup\r
+\r
+Arguments:\r
+\r
+  Reloc      - Pointer to the relocation record\r
+\r
+  Fixup      - Pointer to the address to fix up\r
+\r
+  FixupData  - Pointer to a buffer to log the fixups\r
+\r
+  Adjust     - The offset to adjust the fixup\r
+\r
+Returns:\r
+\r
+  EFI_UNSUPPORTED   - Unsupported now\r
+\r
+--*/\r
+{\r
+  return RETURN_UNSUPPORTED;\r
+}\r
diff --git a/Tools/CodeTools/Source/GenFvImage/GenFvImageExe.c b/Tools/CodeTools/Source/GenFvImage/GenFvImageExe.c
new file mode 100644 (file)
index 0000000..d0117b8
--- /dev/null
@@ -0,0 +1,299 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  GenFvImageExe.c\r
+\r
+Abstract:\r
+\r
+  This contains all code necessary to build the GenFvImage.exe utility.       \r
+  This utility relies heavily on the GenFvImage Lib.  Definitions for both\r
+  can be found in the Tiano Firmware Volume Generation Utility \r
+  Specification, review draft.\r
+\r
+--*/\r
+\r
+//\r
+// File included in build\r
+//\r
+#include "GenFvImageExe.h"\r
+#include "CommonLib.h"\r
+#include "EfiUtilityMsgs.h"\r
+\r
+VOID\r
+PrintUtilityInfo (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Displays the standard utility information to SDTOUT\r
+\r
+Arguments:\r
+\r
+  None\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+{\r
+  printf (\r
+    "%s - Tiano Firmware Volume Generation Utility."" Version %i.%i\n\n",\r
+    UTILITY_NAME,\r
+    UTILITY_MAJOR_VERSION,\r
+    UTILITY_MINOR_VERSION\r
+    );\r
+}\r
+\r
+VOID\r
+PrintUsage (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Displays the utility usage syntax to STDOUT\r
+\r
+Arguments:\r
+\r
+  None\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+{\r
+  printf ("Usage: %s -I FvInfFileName\n", UTILITY_NAME);\r
+  printf ("  Where:\n");\r
+  printf ("\tFvInfFileName is the name of the image description file.\n\n");\r
+}\r
+\r
+int\r
+main (\r
+  IN INTN   argc,\r
+  IN CHAR8  **argv\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This utility uses GenFvImage.Lib to build a firmware volume image.\r
+\r
+Arguments:\r
+\r
+  FvInfFileName      The name of an FV image description file.\r
+\r
+  Arguments come in pair in any order.\r
+    -I FvInfFileName \r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS            No error conditions detected.\r
+  EFI_INVALID_PARAMETER  One or more of the input parameters is invalid.\r
+  EFI_OUT_OF_RESOURCES   A resource required by the utility was unavailable.  \r
+                         Most commonly this will be memory allocation \r
+                         or file creation.\r
+  EFI_LOAD_ERROR         GenFvImage.lib could not be loaded.\r
+  EFI_ABORTED            Error executing the GenFvImage lib.\r
+\r
+--*/\r
+{\r
+  EFI_STATUS  Status;\r
+  CHAR8       InfFileName[_MAX_PATH];\r
+  CHAR8       *InfFileImage;\r
+  UINTN       InfFileSize;\r
+  UINT8       *FvImage;\r
+  UINTN       FvImageSize;\r
+  UINT8       Index;\r
+  CHAR8       FvFileNameBuffer[_MAX_PATH];\r
+  CHAR8       *FvFileName;\r
+  FILE        *FvFile;\r
+  FILE        *SymFile;\r
+  CHAR8       SymFileNameBuffer[_MAX_PATH];\r
+  CHAR8       *SymFileName;\r
+  UINT8       *SymImage;\r
+  UINTN       SymImageSize;\r
+  CHAR8       *CurrentSymString;\r
+\r
+  FvFileName  = FvFileNameBuffer;\r
+  SymFileName = SymFileNameBuffer;\r
+\r
+  SetUtilityName (UTILITY_NAME);\r
+  //\r
+  // Display utility information\r
+  //\r
+  PrintUtilityInfo ();\r
+\r
+  //\r
+  // Verify the correct number of arguments\r
+  //\r
+  if (argc != MAX_ARGS) {\r
+    Error (NULL, 0, 0, "invalid number of input parameters specified", NULL);\r
+    PrintUsage ();\r
+    return GetUtilityStatus ();\r
+  }\r
+  //\r
+  // Initialize variables\r
+  //\r
+  strcpy (InfFileName, "");\r
+\r
+  //\r
+  // Parse the command line arguments\r
+  //\r
+  for (Index = 1; Index < MAX_ARGS; Index += 2) {\r
+    //\r
+    // Make sure argument pair begin with - or /\r
+    //\r
+    if (argv[Index][0] != '-' && argv[Index][0] != '/') {\r
+      Error (NULL, 0, 0, argv[Index], "argument pair must begin with \"-\" or \"/\"");\r
+      PrintUsage ();\r
+      return GetUtilityStatus ();\r
+    }\r
+    //\r
+    // Make sure argument specifier is only one letter\r
+    //\r
+    if (argv[Index][2] != 0) {\r
+      Error (NULL, 0, 0, argv[Index], "unrecognized argument");\r
+      PrintUsage ();\r
+      return GetUtilityStatus ();\r
+    }\r
+    //\r
+    // Determine argument to read\r
+    //\r
+    switch (argv[Index][1]) {\r
+\r
+    case 'I':\r
+    case 'i':\r
+      if (strlen (InfFileName) == 0) {\r
+        strcpy (InfFileName, argv[Index + 1]);\r
+      } else {\r
+        Error (NULL, 0, 0, argv[Index + 1], "FvInfFileName may only be specified once");\r
+        PrintUsage ();\r
+        return GetUtilityStatus ();\r
+      }\r
+      break;\r
+\r
+    default:\r
+      Error (NULL, 0, 0, argv[Index], "unrecognized argument");\r
+      PrintUsage ();\r
+      return GetUtilityStatus ();\r
+      break;\r
+    }\r
+  }\r
+  //\r
+  // Read the INF file image\r
+  //\r
+  Status = GetFileImage (InfFileName, &InfFileImage, &InfFileSize);\r
+  if (EFI_ERROR (Status)) {\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Call the GenFvImage lib\r
+  //\r
+  Status = GenerateFvImage (\r
+            InfFileImage,\r
+            InfFileSize,\r
+            &FvImage,\r
+            &FvImageSize,\r
+            &FvFileName,\r
+            &SymImage,\r
+            &SymImageSize,\r
+            &SymFileName\r
+            );\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    switch (Status) {\r
+\r
+    case EFI_INVALID_PARAMETER:\r
+      Error (NULL, 0, 0, "invalid parameter passed to GenFvImage Lib", NULL);\r
+      return GetUtilityStatus ();\r
+      break;\r
+\r
+    case EFI_ABORTED:\r
+      Error (NULL, 0, 0, "error detected while creating the file image", NULL);\r
+      return GetUtilityStatus ();\r
+      break;\r
+\r
+    case EFI_OUT_OF_RESOURCES:\r
+      Error (NULL, 0, 0, "GenFvImage Lib could not allocate required resources", NULL);\r
+      return GetUtilityStatus ();\r
+      break;\r
+\r
+    case EFI_VOLUME_CORRUPTED:\r
+      Error (NULL, 0, 0, "no base address was specified, but the FV.INF included a PEI or BSF file", NULL);\r
+      return GetUtilityStatus ();\r
+      break;\r
+\r
+    case EFI_LOAD_ERROR:\r
+      Error (NULL, 0, 0, "could not load FV image generation library", NULL);\r
+      return GetUtilityStatus ();\r
+      break;\r
+\r
+    default:\r
+      Error (NULL, 0, 0, "GenFvImage Lib returned unknown status", "status returned = 0x%X", Status);\r
+      return GetUtilityStatus ();\r
+      break;\r
+    }\r
+  }\r
+  //\r
+  // Write file\r
+  //\r
+  FvFile = fopen (FvFileName, "wb");\r
+  if (FvFile == NULL) {\r
+    Error (NULL, 0, 0, FvFileName, "could not open output file");\r
+    free (FvImage);\r
+    free (SymImage);\r
+    return GetUtilityStatus ();\r
+  }\r
+\r
+  if (fwrite (FvImage, 1, FvImageSize, FvFile) != FvImageSize) {\r
+    Error (NULL, 0, 0, FvFileName, "failed to write to output file");\r
+    free (FvImage);\r
+    free (SymImage);\r
+    fclose (FvFile);\r
+    return GetUtilityStatus ();\r
+  }\r
+\r
+  fclose (FvFile);\r
+  free (FvImage);\r
+\r
+  //\r
+  // Write symbol file\r
+  //\r
+  if (strcmp (SymFileName, "")) {\r
+    SymFile = fopen (SymFileName, "wt");\r
+    if (SymFile == NULL) {\r
+      Error (NULL, 0, 0, SymFileName, "could not open output symbol file");\r
+      free (SymImage);\r
+      return GetUtilityStatus ();\r
+    }\r
+\r
+    fprintf (SymFile, "TEXTSYM format | V1.0\n");\r
+\r
+    CurrentSymString = SymImage;\r
+    while (((UINTN) CurrentSymString - (UINTN) SymImage) < SymImageSize) {\r
+      fprintf (SymFile, "%s", CurrentSymString);\r
+      CurrentSymString = (CHAR8 *) (((UINTN) CurrentSymString) + strlen (CurrentSymString) + 1);\r
+    }\r
+\r
+    fclose (SymFile);\r
+  }\r
+\r
+  free (SymImage);\r
+\r
+  return GetUtilityStatus ();\r
+}\r
diff --git a/Tools/CodeTools/Source/GenFvImage/GenFvImageExe.h b/Tools/CodeTools/Source/GenFvImage/GenFvImageExe.h
new file mode 100644 (file)
index 0000000..9b97935
--- /dev/null
@@ -0,0 +1,98 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+  GenFvImageExe.h\r
+\r
+Abstract:\r
+\r
+  Definitions for the PeimFixup exe utility.\r
+\r
+--*/\r
+\r
+//\r
+// Coded to Tiano Coding Standards\r
+//\r
+#ifndef _EFI_GEN_FV_IMAGE_EXE_H\r
+#define _EFI_GEN_FV_IMAGE_EXE_H\r
+\r
+#include <stdio.h>\r
+#include <string.h>\r
+#include <stdlib.h>\r
+#include "GenFvImageLib.h"\r
+\r
+//\r
+// Utility Name\r
+//\r
+#define UTILITY_NAME  "GenFvImage"\r
+\r
+//\r
+// Utility version information\r
+//\r
+#define UTILITY_MAJOR_VERSION 0\r
+#define UTILITY_MINOR_VERSION 1\r
+#define UTILITY_DATE          __DATE__\r
+\r
+//\r
+// The maximum number of arguments accepted from the command line.\r
+//\r
+#define MAX_ARGS  3\r
+\r
+//\r
+// The function that displays general utility information\r
+//\r
+VOID\r
+PrintUtilityInfo (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  None\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+//\r
+// The function that displays the utility usage message.\r
+//\r
+VOID\r
+PrintUsage (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  None\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+#endif\r
diff --git a/Tools/CodeTools/Source/GenFvImage/GenFvImageLib.c b/Tools/CodeTools/Source/GenFvImage/GenFvImageLib.c
new file mode 100644 (file)
index 0000000..888656a
--- /dev/null
@@ -0,0 +1,2727 @@
+/*++\r
+i\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  GenFvImageLib.c\r
+\r
+Abstract:\r
+\r
+  This file contains functions required to generate a Firmware Volume.\r
+\r
+--*/\r
+\r
+//\r
+// Include files\r
+//\r
+#ifdef __GNUC__\r
+#include <uuid/uuid.h>\r
+#include <sys/stat.h>\r
+#endif\r
+#include <string.h>\r
+#ifndef __GNUC__\r
+#include <io.h>\r
+#endif\r
+#include <assert.h>\r
+\r
+#include <Common/UefiBaseTypes.h>\r
+#include <Common/FirmwareVolumeImageFormat.h>\r
+#include <Common/Variable.h>\r
+#include <Common/WorkingBlockHeader.h>\r
+#include <Guid/FirmwareFileSystem.h>\r
+\r
+#include "GenFvImageLib.h"\r
+#include "GenFvImageLibInternal.h"\r
+#include "CommonLib.h"\r
+#include "Crc32.h"\r
+#include "EfiUtilityMsgs.h"\r
+#include "FvLib.h"\r
+#include "EfiCompress.h"\r
+#include "WinNtInclude.h"\r
+\r
+\r
+//\r
+// Local function prototypes\r
+//\r
+EFI_STATUS\r
+GetPe32Info (\r
+  IN UINT8                  *Pe32,\r
+  OUT UINT32                *EntryPoint,\r
+  OUT UINT32                *BaseOfCode,\r
+  OUT UINT16                *MachineType\r
+  );\r
+\r
+//\r
+// Local function implementations.\r
+//\r
+EFI_GUID  FfsGuid = EFI_FIRMWARE_FILE_SYSTEM_GUID;\r
+EFI_GUID  DefaultFvPadFileNameGuid = { 0x78f54d4, 0xcc22, 0x4048, 0x9e, 0x94, 0x87, 0x9c, 0x21, 0x4d, 0x56, 0x2f };\r
+\r
+//\r
+// This data array will be located at the base of the Firmware Volume Header (FVH)\r
+// in the boot block.  It must not exceed 14 bytes of code.  The last 2 bytes\r
+// will be used to keep the FVH checksum consistent.\r
+// This code will be run in response to a starutp IPI for HT-enabled systems.\r
+//\r
+#define SIZEOF_STARTUP_DATA_ARRAY 0x10\r
+\r
+UINT8                                   m128kRecoveryStartupApDataArray[SIZEOF_STARTUP_DATA_ARRAY] = {\r
+  //\r
+  // EA D0 FF 00 F0               ; far jmp F000:FFD0\r
+  // 0, 0, 0, 0, 0, 0, 0, 0, 0,   ; Reserved bytes\r
+  // 0, 0                         ; Checksum Padding\r
+  //\r
+  0xEA,\r
+  0xD0,\r
+  0xFF,\r
+  0x0,\r
+  0xF0,\r
+  0x00,\r
+  0x00,\r
+  0x00,\r
+  0x00,\r
+  0x00,\r
+  0x00,\r
+  0x00,\r
+  0x00,\r
+  0x00,\r
+  0x00,\r
+  0x00\r
+};\r
+\r
+UINT8                                   m64kRecoveryStartupApDataArray[SIZEOF_STARTUP_DATA_ARRAY] = {\r
+  //\r
+  // EB CE                               ; jmp short ($-0x30)\r
+  // ; (from offset 0x0 to offset 0xFFD0)\r
+  // 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ; Reserved bytes\r
+  // 0, 0                                ; Checksum Padding\r
+  //\r
+  0xEB,\r
+  0xCE,\r
+  0x00,\r
+  0x00,\r
+  0x00,\r
+  0x00,\r
+  0x00,\r
+  0x00,\r
+  0x00,\r
+  0x00,\r
+  0x00,\r
+  0x00,\r
+  0x00,\r
+  0x00,\r
+  0x00,\r
+  0x00\r
+};\r
+\r
+EFI_STATUS\r
+ParseFvInf (\r
+  IN MEMORY_FILE  *InfFile,\r
+  IN FV_INFO      *FvInfo\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function parses a FV.INF file and copies info into a FV_INFO structure.\r
+\r
+Arguments:\r
+\r
+  InfFile         Memory file image.\r
+  FvInfo          Information read from INF file.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS       INF file information successfully retrieved.\r
+  EFI_ABORTED       INF file has an invalid format.\r
+  EFI_NOT_FOUND     A required string was not found in the INF file.\r
+--*/\r
+{\r
+  CHAR8       Value[_MAX_PATH];\r
+  UINT64      Value64;\r
+  UINTN       Index;\r
+  EFI_STATUS  Status;\r
+\r
+  //\r
+  // Initialize FV info\r
+  //\r
+  memset (FvInfo, 0, sizeof (FV_INFO));\r
+\r
+  //\r
+  // Read the FV base address\r
+  //\r
+  Status = FindToken (InfFile, OPTIONS_SECTION_STRING, EFI_FV_BASE_ADDRESS_STRING, 0, Value);\r
+\r
+  if (Status == EFI_SUCCESS) {\r
+    //\r
+    // Get the base address\r
+    //\r
+    Status = AsciiStringToUint64 (Value, FALSE, &Value64);\r
+    if (EFI_ERROR (Status)) {\r
+      Error (NULL, 0, 0, EFI_FV_BASE_ADDRESS_STRING, "invalid value");\r
+      return EFI_ABORTED;\r
+    }\r
+\r
+    FvInfo->BaseAddress = Value64;\r
+  } else {\r
+    Error (NULL, 0, 0, EFI_FV_BASE_ADDRESS_STRING, "could not find value");\r
+    return EFI_ABORTED;\r
+  }\r
+  //\r
+  // Read the FV Guid\r
+  //\r
+  Status = FindToken (InfFile, OPTIONS_SECTION_STRING, EFI_FV_GUID_STRING, 0, Value);\r
+\r
+  if (Status == EFI_SUCCESS) {\r
+    //\r
+    // Get the guid value\r
+    //\r
+    Status = StringToGuid (Value, &FvInfo->FvGuid);\r
+    if (EFI_ERROR (Status)) {\r
+      memcpy (&FvInfo->FvGuid, &FfsGuid, sizeof (EFI_GUID));\r
+    }\r
+  } else {\r
+    memcpy (&FvInfo->FvGuid, &FfsGuid, sizeof (EFI_GUID));\r
+  }\r
+  //\r
+  // Read the FV file name\r
+  //\r
+  Status = FindToken (InfFile, OPTIONS_SECTION_STRING, EFI_FV_FILE_NAME_STRING, 0, Value);\r
+\r
+  if (Status == EFI_SUCCESS) {\r
+    //\r
+    // copy the file name\r
+    //\r
+    strcpy (FvInfo->FvName, Value);\r
+  } else {\r
+    Error (NULL, 0, 0, EFI_FV_FILE_NAME_STRING, "value not specified");\r
+    return EFI_ABORTED;\r
+  }\r
+  //\r
+  // Read the Sym file name\r
+  //\r
+  Status = FindToken (InfFile, OPTIONS_SECTION_STRING, EFI_SYM_FILE_NAME_STRING, 0, Value);\r
+\r
+  if (Status == EFI_SUCCESS) {\r
+    //\r
+    // copy the file name\r
+    //\r
+    strcpy (FvInfo->SymName, Value);\r
+  } else {\r
+    //\r
+    // Symbols not required, so init to NULL.\r
+    //\r
+    strcpy (FvInfo->SymName, "");\r
+  }\r
+  //\r
+  // Read the read disabled capability attribute\r
+  //\r
+  Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_READ_DISABLED_CAP_STRING, 0, Value);\r
+\r
+  if (Status == EFI_SUCCESS) {\r
+    //\r
+    // Update the read disabled flag\r
+    //\r
+    if (strcmp (Value, TRUE_STRING) == 0) {\r
+      FvInfo->FvAttributes |= EFI_FVB_READ_DISABLED_CAP;\r
+    } else if (strcmp (Value, FALSE_STRING) != 0) {\r
+      Error (NULL, 0, 0, EFI_FVB_READ_DISABLED_CAP_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING);\r
+      return EFI_ABORTED;\r
+    }\r
+  } else {\r
+    Error (NULL, 0, 0, EFI_FVB_READ_DISABLED_CAP_STRING, "value not specified");\r
+    return Status;\r
+  }\r
+  //\r
+  // Read the read enabled capability attribute\r
+  //\r
+  Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_READ_ENABLED_CAP_STRING, 0, Value);\r
+\r
+  if (Status == EFI_SUCCESS) {\r
+    //\r
+    // Update the read disabled flag\r
+    //\r
+    if (strcmp (Value, TRUE_STRING) == 0) {\r
+      FvInfo->FvAttributes |= EFI_FVB_READ_ENABLED_CAP;\r
+    } else if (strcmp (Value, FALSE_STRING) != 0) {\r
+      Error (NULL, 0, 0, EFI_FVB_READ_ENABLED_CAP_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING);\r
+      return EFI_ABORTED;\r
+    }\r
+  } else {\r
+    Error (NULL, 0, 0, EFI_FVB_READ_ENABLED_CAP_STRING, "value not specified");\r
+    return Status;\r
+  }\r
+  //\r
+  // Read the read status attribute\r
+  //\r
+  Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_READ_STATUS_STRING, 0, Value);\r
+\r
+  if (Status == EFI_SUCCESS) {\r
+    //\r
+    // Update the read disabled flag\r
+    //\r
+    if (strcmp (Value, TRUE_STRING) == 0) {\r
+      FvInfo->FvAttributes |= EFI_FVB_READ_STATUS;\r
+    } else if (strcmp (Value, FALSE_STRING) != 0) {\r
+      Error (NULL, 0, 0, EFI_FVB_READ_STATUS_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING);\r
+      return EFI_ABORTED;\r
+    }\r
+  } else {\r
+    Error (NULL, 0, 0, EFI_FVB_READ_STATUS_STRING, "value not specified");\r
+    return Status;\r
+  }\r
+  //\r
+  // Read the write disabled capability attribute\r
+  //\r
+  Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_WRITE_DISABLED_CAP_STRING, 0, Value);\r
+\r
+  if (Status == EFI_SUCCESS) {\r
+    //\r
+    // Update the write disabled flag\r
+    //\r
+    if (strcmp (Value, TRUE_STRING) == 0) {\r
+      FvInfo->FvAttributes |= EFI_FVB_WRITE_DISABLED_CAP;\r
+    } else if (strcmp (Value, FALSE_STRING) != 0) {\r
+      Error (NULL, 0, 0, EFI_FVB_WRITE_DISABLED_CAP_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING);\r
+      return EFI_ABORTED;\r
+    }\r
+  } else {\r
+    Error (NULL, 0, 0, EFI_FVB_WRITE_DISABLED_CAP_STRING, "value not specified");\r
+    return Status;\r
+  }\r
+  //\r
+  // Read the write enabled capability attribute\r
+  //\r
+  Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_WRITE_ENABLED_CAP_STRING, 0, Value);\r
+\r
+  if (Status == EFI_SUCCESS) {\r
+    //\r
+    // Update the write disabled flag\r
+    //\r
+    if (strcmp (Value, TRUE_STRING) == 0) {\r
+      FvInfo->FvAttributes |= EFI_FVB_WRITE_ENABLED_CAP;\r
+    } else if (strcmp (Value, FALSE_STRING) != 0) {\r
+      Error (NULL, 0, 0, EFI_FVB_WRITE_ENABLED_CAP_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING);\r
+      return EFI_ABORTED;\r
+    }\r
+  } else {\r
+    Error (NULL, 0, 0, EFI_FVB_WRITE_ENABLED_CAP_STRING, "value not specified");\r
+    return Status;\r
+  }\r
+  //\r
+  // Read the write status attribute\r
+  //\r
+  Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_WRITE_STATUS_STRING, 0, Value);\r
+\r
+  if (Status == EFI_SUCCESS) {\r
+    //\r
+    // Update the write disabled flag\r
+    //\r
+    if (strcmp (Value, TRUE_STRING) == 0) {\r
+      FvInfo->FvAttributes |= EFI_FVB_WRITE_STATUS;\r
+    } else if (strcmp (Value, FALSE_STRING) != 0) {\r
+      Error (NULL, 0, 0, EFI_FVB_WRITE_STATUS_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING);\r
+      return EFI_ABORTED;\r
+    }\r
+  } else {\r
+    Error (NULL, 0, 0, EFI_FVB_WRITE_STATUS_STRING, "value not specified");\r
+    return Status;\r
+  }\r
+  //\r
+  // Read the lock capability attribute\r
+  //\r
+  Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_LOCK_CAP_STRING, 0, Value);\r
+\r
+  if (Status == EFI_SUCCESS) {\r
+    //\r
+    // Update the attribute flag\r
+    //\r
+    if (strcmp (Value, TRUE_STRING) == 0) {\r
+      FvInfo->FvAttributes |= EFI_FVB_LOCK_CAP;\r
+    } else if (strcmp (Value, FALSE_STRING) != 0) {\r
+      Error (NULL, 0, 0, EFI_FVB_LOCK_CAP_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING);\r
+      return EFI_ABORTED;\r
+    }\r
+  } else {\r
+    Error (NULL, 0, 0, EFI_FVB_LOCK_CAP_STRING, "value not specified");\r
+    return Status;\r
+  }\r
+  //\r
+  // Read the lock status attribute\r
+  //\r
+  Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_LOCK_STATUS_STRING, 0, Value);\r
+\r
+  if (Status == EFI_SUCCESS) {\r
+    //\r
+    // Update the attribute flag\r
+    //\r
+    if (strcmp (Value, TRUE_STRING) == 0) {\r
+      FvInfo->FvAttributes |= EFI_FVB_LOCK_STATUS;\r
+    } else if (strcmp (Value, FALSE_STRING) != 0) {\r
+      Error (NULL, 0, 0, EFI_FVB_LOCK_STATUS_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING);\r
+      return EFI_ABORTED;\r
+    }\r
+  } else {\r
+    Error (NULL, 0, 0, EFI_FVB_LOCK_STATUS_STRING, "value not specified");\r
+    return Status;\r
+  }\r
+  //\r
+  // Read the sticky write attribute\r
+  //\r
+  Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_STICKY_WRITE_STRING, 0, Value);\r
+\r
+  if (Status == EFI_SUCCESS) {\r
+    //\r
+    // Update the attribute flag\r
+    //\r
+    if (strcmp (Value, TRUE_STRING) == 0) {\r
+      FvInfo->FvAttributes |= EFI_FVB_STICKY_WRITE;\r
+    } else if (strcmp (Value, FALSE_STRING) != 0) {\r
+      Error (NULL, 0, 0, EFI_FVB_STICKY_WRITE_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING);\r
+      return EFI_ABORTED;\r
+    }\r
+  } else {\r
+    Error (NULL, 0, 0, EFI_FVB_STICKY_WRITE_STRING, "value not specified");\r
+    return Status;\r
+  }\r
+  //\r
+  // Read the memory mapped attribute\r
+  //\r
+  Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_MEMORY_MAPPED_STRING, 0, Value);\r
+\r
+  if (Status == EFI_SUCCESS) {\r
+    //\r
+    // Update the attribute flag\r
+    //\r
+    if (strcmp (Value, TRUE_STRING) == 0) {\r
+      FvInfo->FvAttributes |= EFI_FVB_MEMORY_MAPPED;\r
+    } else if (strcmp (Value, FALSE_STRING) != 0) {\r
+      Error (NULL, 0, 0, EFI_FVB_MEMORY_MAPPED_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING);\r
+      return EFI_ABORTED;\r
+    }\r
+  } else {\r
+    Error (NULL, 0, 0, EFI_FVB_MEMORY_MAPPED_STRING, "value not specified");\r
+    return Status;\r
+  }\r
+  //\r
+  // Read the erase polarity attribute\r
+  //\r
+  Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_ERASE_POLARITY_STRING, 0, Value);\r
+\r
+  if (Status == EFI_SUCCESS) {\r
+    //\r
+    // Update the attribute flag\r
+    //\r
+    if (strcmp (Value, ONE_STRING) == 0) {\r
+      FvInfo->FvAttributes |= EFI_FVB_ERASE_POLARITY;\r
+    } else if (strcmp (Value, ZERO_STRING) != 0) {\r
+      Error (NULL, 0, 0, EFI_FVB_ERASE_POLARITY_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING);\r
+      return EFI_ABORTED;\r
+    }\r
+  } else {\r
+    Error (NULL, 0, 0, EFI_FVB_ERASE_POLARITY_STRING, "value not specified");\r
+    return Status;\r
+  }\r
+  //\r
+  // Read the alignment capabilities attribute\r
+  //\r
+  Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_ALIGNMENT_CAP_STRING, 0, Value);\r
+\r
+  if (Status == EFI_SUCCESS) {\r
+    //\r
+    // Update attribute\r
+    //\r
+    if (strcmp (Value, TRUE_STRING) == 0) {\r
+      FvInfo->FvAttributes |= EFI_FVB_ALIGNMENT_CAP;\r
+    } else if (strcmp (Value, FALSE_STRING) != 0) {\r
+      Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_CAP_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING);\r
+      return EFI_ABORTED;\r
+    }\r
+  } else {\r
+    Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_CAP_STRING, "value not specified");\r
+    return Status;\r
+  }\r
+  //\r
+  // Read the word alignment capability attribute\r
+  //\r
+  Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_ALIGNMENT_2_STRING, 0, Value);\r
+\r
+  if (Status == EFI_SUCCESS) {\r
+    //\r
+    // Update attribute\r
+    //\r
+    if (strcmp (Value, TRUE_STRING) == 0) {\r
+      FvInfo->FvAttributes |= EFI_FVB_ALIGNMENT_2;\r
+    } else if (strcmp (Value, FALSE_STRING) != 0) {\r
+      Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_2_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING);\r
+      return EFI_ABORTED;\r
+    }\r
+  } else {\r
+    Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_2_STRING, "value not specified");\r
+    return Status;\r
+  }\r
+  //\r
+  // Read the dword alignment capability attribute\r
+  //\r
+  Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_ALIGNMENT_4_STRING, 0, Value);\r
+\r
+  if (Status == EFI_SUCCESS) {\r
+    //\r
+    // Update attribute\r
+    //\r
+    if (strcmp (Value, TRUE_STRING) == 0) {\r
+      FvInfo->FvAttributes |= EFI_FVB_ALIGNMENT_4;\r
+    } else if (strcmp (Value, FALSE_STRING) != 0) {\r
+      Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_4_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING);\r
+      return EFI_ABORTED;\r
+    }\r
+  } else {\r
+    Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_4_STRING, "value not specified");\r
+    return Status;\r
+  }\r
+  //\r
+  // Read the word alignment capability attribute\r
+  //\r
+  Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_ALIGNMENT_8_STRING, 0, Value);\r
+\r
+  if (Status == EFI_SUCCESS) {\r
+    //\r
+    // Update attribute\r
+    //\r
+    if (strcmp (Value, TRUE_STRING) == 0) {\r
+      FvInfo->FvAttributes |= EFI_FVB_ALIGNMENT_8;\r
+    } else if (strcmp (Value, FALSE_STRING) != 0) {\r
+      Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_8_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING);\r
+      return EFI_ABORTED;\r
+    }\r
+  } else {\r
+    Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_8_STRING, "value not specified");\r
+    return Status;\r
+  }\r
+  //\r
+  // Read the qword alignment capability attribute\r
+  //\r
+  Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_ALIGNMENT_16_STRING, 0, Value);\r
+\r
+  if (Status == EFI_SUCCESS) {\r
+    //\r
+    // Update attribute\r
+    //\r
+    if (strcmp (Value, TRUE_STRING) == 0) {\r
+      FvInfo->FvAttributes |= EFI_FVB_ALIGNMENT_16;\r
+    } else if (strcmp (Value, FALSE_STRING) != 0) {\r
+      Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_16_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING);\r
+      return EFI_ABORTED;\r
+    }\r
+  } else {\r
+    Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_16_STRING, "value not specified");\r
+    return Status;\r
+  }\r
+  //\r
+  // Read the 32 byte alignment capability attribute\r
+  //\r
+  Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_ALIGNMENT_32_STRING, 0, Value);\r
+\r
+  if (Status == EFI_SUCCESS) {\r
+    //\r
+    // Update attribute\r
+    //\r
+    if (strcmp (Value, TRUE_STRING) == 0) {\r
+      FvInfo->FvAttributes |= EFI_FVB_ALIGNMENT_32;\r
+    } else if (strcmp (Value, FALSE_STRING) != 0) {\r
+      Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_32_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING);\r
+      return EFI_ABORTED;\r
+    }\r
+  } else {\r
+    Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_32_STRING, "value not specified");\r
+    return Status;\r
+  }\r
+  //\r
+  // Read the 64 byte alignment capability attribute\r
+  //\r
+  Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_ALIGNMENT_64_STRING, 0, Value);\r
+\r
+  if (Status == EFI_SUCCESS) {\r
+    //\r
+    // Update attribute\r
+    //\r
+    if (strcmp (Value, TRUE_STRING) == 0) {\r
+      FvInfo->FvAttributes |= EFI_FVB_ALIGNMENT_64;\r
+    } else if (strcmp (Value, FALSE_STRING) != 0) {\r
+      Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_64_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING);\r
+      return EFI_ABORTED;\r
+    }\r
+  } else {\r
+    Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_64_STRING, "value not specified");\r
+    return Status;\r
+  }\r
+  //\r
+  // Read the 128 byte alignment capability attribute\r
+  //\r
+  Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_ALIGNMENT_128_STRING, 0, Value);\r
+\r
+  if (Status == EFI_SUCCESS) {\r
+    //\r
+    // Update attribute\r
+    //\r
+    if (strcmp (Value, TRUE_STRING) == 0) {\r
+      FvInfo->FvAttributes |= EFI_FVB_ALIGNMENT_128;\r
+    } else if (strcmp (Value, FALSE_STRING) != 0) {\r
+      Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_128_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING);\r
+      return EFI_ABORTED;\r
+    }\r
+  } else {\r
+    Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_128_STRING, "value not specified");\r
+    return Status;\r
+  }\r
+  //\r
+  // Read the 256 byte alignment capability attribute\r
+  //\r
+  Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_ALIGNMENT_256_STRING, 0, Value);\r
+\r
+  if (Status == EFI_SUCCESS) {\r
+    //\r
+    // Update attribute\r
+    //\r
+    if (strcmp (Value, TRUE_STRING) == 0) {\r
+      FvInfo->FvAttributes |= EFI_FVB_ALIGNMENT_256;\r
+    } else if (strcmp (Value, FALSE_STRING) != 0) {\r
+      Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_256_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING);\r
+      return EFI_ABORTED;\r
+    }\r
+  } else {\r
+    Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_256_STRING, "value not specified");\r
+    return Status;\r
+  }\r
+  //\r
+  // Read the 512 byte alignment capability attribute\r
+  //\r
+  Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_ALIGNMENT_512_STRING, 0, Value);\r
+\r
+  if (Status == EFI_SUCCESS) {\r
+    //\r
+    // Update attribute\r
+    //\r
+    if (strcmp (Value, TRUE_STRING) == 0) {\r
+      FvInfo->FvAttributes |= EFI_FVB_ALIGNMENT_512;\r
+    } else if (strcmp (Value, FALSE_STRING) != 0) {\r
+      Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_512_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING);\r
+      return EFI_ABORTED;\r
+    }\r
+  } else {\r
+    Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_512_STRING, "value not specified");\r
+    return Status;\r
+  }\r
+  //\r
+  // Read the 1K byte alignment capability attribute\r
+  //\r
+  Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_ALIGNMENT_1K_STRING, 0, Value);\r
+\r
+  if (Status == EFI_SUCCESS) {\r
+    //\r
+    // Update attribute\r
+    //\r
+    if (strcmp (Value, TRUE_STRING) == 0) {\r
+      FvInfo->FvAttributes |= EFI_FVB_ALIGNMENT_1K;\r
+    } else if (strcmp (Value, FALSE_STRING) != 0) {\r
+      Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_1K_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING);\r
+      return EFI_ABORTED;\r
+    }\r
+  } else {\r
+    Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_1K_STRING, "value not specified");\r
+    return Status;\r
+  }\r
+  //\r
+  // Read the 2K byte alignment capability attribute\r
+  //\r
+  Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_ALIGNMENT_2K_STRING, 0, Value);\r
+\r
+  if (Status == EFI_SUCCESS) {\r
+    //\r
+    // Update attribute\r
+    //\r
+    if (strcmp (Value, TRUE_STRING) == 0) {\r
+      FvInfo->FvAttributes |= EFI_FVB_ALIGNMENT_2K;\r
+    } else if (strcmp (Value, FALSE_STRING) != 0) {\r
+      Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_2K_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING);\r
+      return EFI_ABORTED;\r
+    }\r
+  } else {\r
+    Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_2K_STRING, "value not specified");\r
+    return Status;\r
+  }\r
+  //\r
+  // Read the 4K byte alignment capability attribute\r
+  //\r
+  Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_ALIGNMENT_4K_STRING, 0, Value);\r
+\r
+  if (Status == EFI_SUCCESS) {\r
+    //\r
+    // Update attribute\r
+    //\r
+    if (strcmp (Value, TRUE_STRING) == 0) {\r
+      FvInfo->FvAttributes |= EFI_FVB_ALIGNMENT_4K;\r
+    } else if (strcmp (Value, FALSE_STRING) != 0) {\r
+      Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_4K_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING);\r
+      return EFI_ABORTED;\r
+    }\r
+  } else {\r
+    Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_4K_STRING, "value not specified");\r
+    return Status;\r
+  }\r
+  //\r
+  // Read the 8K byte alignment capability attribute\r
+  //\r
+  Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_ALIGNMENT_8K_STRING, 0, Value);\r
+\r
+  if (Status == EFI_SUCCESS) {\r
+    //\r
+    // Update attribute\r
+    //\r
+    if (strcmp (Value, TRUE_STRING) == 0) {\r
+      FvInfo->FvAttributes |= EFI_FVB_ALIGNMENT_8K;\r
+    } else if (strcmp (Value, FALSE_STRING) != 0) {\r
+      Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_8K_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING);\r
+      return EFI_ABORTED;\r
+    }\r
+  } else {\r
+    Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_8K_STRING, "value not specified");\r
+    return Status;\r
+  }\r
+  //\r
+  // Read the 16K byte alignment capability attribute\r
+  //\r
+  Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_ALIGNMENT_16K_STRING, 0, Value);\r
+\r
+  if (Status == EFI_SUCCESS) {\r
+    //\r
+    // Update attribute\r
+    //\r
+    if (strcmp (Value, TRUE_STRING) == 0) {\r
+      FvInfo->FvAttributes |= EFI_FVB_ALIGNMENT_16K;\r
+    } else if (strcmp (Value, FALSE_STRING) != 0) {\r
+      Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_16K_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING);\r
+      return EFI_ABORTED;\r
+    }\r
+  } else {\r
+    Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_16K_STRING, "value not specified");\r
+    return Status;\r
+  }\r
+  //\r
+  // Read the 32K byte alignment capability attribute\r
+  //\r
+  Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_ALIGNMENT_32K_STRING, 0, Value);\r
+\r
+  if (Status == EFI_SUCCESS) {\r
+    //\r
+    // Update attribute\r
+    //\r
+    if (strcmp (Value, TRUE_STRING) == 0) {\r
+      FvInfo->FvAttributes |= EFI_FVB_ALIGNMENT_32K;\r
+    } else if (strcmp (Value, FALSE_STRING) != 0) {\r
+      Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_32K_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING);\r
+      return EFI_ABORTED;\r
+    }\r
+  } else {\r
+    Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_32K_STRING, "value not specified");\r
+    return Status;\r
+  }\r
+  //\r
+  // Read the 64K byte alignment capability attribute\r
+  //\r
+  Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_ALIGNMENT_64K_STRING, 0, Value);\r
+\r
+  if (Status == EFI_SUCCESS) {\r
+    //\r
+    // Update attribute\r
+    //\r
+    if (strcmp (Value, TRUE_STRING) == 0) {\r
+      FvInfo->FvAttributes |= EFI_FVB_ALIGNMENT_64K;\r
+    } else if (strcmp (Value, FALSE_STRING) != 0) {\r
+      Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_64K_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING);\r
+      return EFI_ABORTED;\r
+    }\r
+  } else {\r
+    Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_64K_STRING, "value not specified");\r
+    return Status;\r
+  }\r
+\r
+  if (!(FvInfo->FvAttributes & EFI_FVB_ALIGNMENT_CAP) &&\r
+      (\r
+        (FvInfo->FvAttributes & EFI_FVB_ALIGNMENT_2) ||\r
+        (FvInfo->FvAttributes & EFI_FVB_ALIGNMENT_4) ||\r
+        (FvInfo->FvAttributes & EFI_FVB_ALIGNMENT_8) ||\r
+        (FvInfo->FvAttributes & EFI_FVB_ALIGNMENT_16) ||\r
+        (FvInfo->FvAttributes & EFI_FVB_ALIGNMENT_32) ||\r
+        (FvInfo->FvAttributes & EFI_FVB_ALIGNMENT_64) ||\r
+        (FvInfo->FvAttributes & EFI_FVB_ALIGNMENT_128) ||\r
+        (FvInfo->FvAttributes & EFI_FVB_ALIGNMENT_256) ||\r
+        (FvInfo->FvAttributes & EFI_FVB_ALIGNMENT_512) ||\r
+        (FvInfo->FvAttributes & EFI_FVB_ALIGNMENT_1K) ||\r
+        (FvInfo->FvAttributes & EFI_FVB_ALIGNMENT_2K) ||\r
+        (FvInfo->FvAttributes & EFI_FVB_ALIGNMENT_4K) ||\r
+        (FvInfo->FvAttributes & EFI_FVB_ALIGNMENT_8K) ||\r
+        (FvInfo->FvAttributes & EFI_FVB_ALIGNMENT_16K) ||\r
+        (FvInfo->FvAttributes & EFI_FVB_ALIGNMENT_32K) ||\r
+        (FvInfo->FvAttributes & EFI_FVB_ALIGNMENT_64K)\r
+      )\r
+     ) {\r
+    Error (\r
+      NULL,\r
+      0,\r
+      0,\r
+      "illegal combination of alignment attributes",\r
+      "if %s is not %s, no individual alignments can be %s",\r
+      EFI_FVB_ALIGNMENT_CAP_STRING,\r
+      TRUE_STRING,\r
+      TRUE_STRING\r
+      );\r
+    return EFI_ABORTED;\r
+  }\r
+  //\r
+  // Read block maps\r
+  //\r
+  for (Index = 0; Index < MAX_NUMBER_OF_FV_BLOCKS; Index++) {\r
+    //\r
+    // Read the number of blocks\r
+    //\r
+    Status = FindToken (InfFile, OPTIONS_SECTION_STRING, EFI_NUM_BLOCKS_STRING, Index, Value);\r
+\r
+    if (Status == EFI_SUCCESS) {\r
+      //\r
+      // Update the number of blocks\r
+      //\r
+      Status = AsciiStringToUint64 (Value, FALSE, &Value64);\r
+      if (EFI_ERROR (Status)) {\r
+        Error (NULL, 0, 0, Value, "invalid value for %s", EFI_NUM_BLOCKS_STRING);\r
+        return EFI_ABORTED;\r
+      }\r
+\r
+      FvInfo->FvBlocks[Index].NumBlocks = (UINT32) Value64;\r
+    } else {\r
+      //\r
+      // If there is no number of blocks, but there is a size, then we have a mismatched pair\r
+      // and should return an error.\r
+      //\r
+      Status = FindToken (InfFile, OPTIONS_SECTION_STRING, EFI_BLOCK_SIZE_STRING, Index, Value);\r
+      if (!EFI_ERROR (Status)) {\r
+        Error (NULL, 0, 0, "must specify both", "%s and %s", EFI_NUM_BLOCKS_STRING, EFI_BLOCK_SIZE_STRING);\r
+        return EFI_ABORTED;\r
+      } else {\r
+        //\r
+        // We are done\r
+        //\r
+        break;\r
+      }\r
+    }\r
+    //\r
+    // Read the size of blocks\r
+    //\r
+    Status = FindToken (InfFile, OPTIONS_SECTION_STRING, EFI_BLOCK_SIZE_STRING, Index, Value);\r
+\r
+    if (Status == EFI_SUCCESS) {\r
+      //\r
+      // Update the number of blocks\r
+      //\r
+      Status = AsciiStringToUint64 (Value, FALSE, &Value64);\r
+      if (EFI_ERROR (Status)) {\r
+        Error (NULL, 0, 0, Value, "invalid value specified for %s", EFI_BLOCK_SIZE_STRING);\r
+        return EFI_ABORTED;\r
+      }\r
+\r
+      FvInfo->FvBlocks[Index].BlockLength = (UINT32) Value64;\r
+    } else {\r
+      //\r
+      // There is a number of blocks, but there is no size, so we have a mismatched pair\r
+      // and should return an error.\r
+      //\r
+      Error (NULL, 0, 0, "must specify both", "%s and %s", EFI_NUM_BLOCKS_STRING, EFI_BLOCK_SIZE_STRING);\r
+      return EFI_ABORTED;\r
+    }\r
+  }\r
+  //\r
+  // Read files\r
+  //\r
+  for (Index = 0; Index < MAX_NUMBER_OF_FILES_IN_FV; Index++) {\r
+    //\r
+    // Read the number of blocks\r
+    //\r
+    Status = FindToken (InfFile, FILES_SECTION_STRING, EFI_FILE_NAME_STRING, Index, Value);\r
+\r
+    if (Status == EFI_SUCCESS) {\r
+      //\r
+      // Add the file\r
+      //\r
+      strcpy (FvInfo->FvFiles[Index], Value);\r
+    } else {\r
+      break;\r
+    }\r
+  }\r
+\r
+  if (FindSection (InfFile, COMPONENT_SECTION_STRING)) {\r
+    Index = 0;\r
+    //\r
+    // Read component FV_VARIABLE\r
+    //\r
+    Status = FindToken (InfFile, COMPONENT_SECTION_STRING, EFI_NV_VARIABLE_STRING, 0, Value);\r
+\r
+    if (Status == EFI_SUCCESS) {\r
+      //\r
+      // Add the component\r
+      //\r
+      strcpy (FvInfo->FvComponents[Index].ComponentName, EFI_NV_VARIABLE_STRING);\r
+      Status = AsciiStringToUint64 (Value, FALSE, &Value64);\r
+      if (EFI_ERROR (Status)) {\r
+        printf ("ERROR: %s is not a valid integer.\n", EFI_NV_VARIABLE_STRING);\r
+        return EFI_ABORTED;\r
+      }\r
+\r
+      FvInfo->FvComponents[Index].Size = (UINTN) Value64;\r
+    } else {\r
+      printf ("WARNING: Could not read %s.\n", EFI_NV_VARIABLE_STRING);\r
+    }\r
+\r
+    Index++;\r
+    //\r
+    // Read component FV_EVENT_LOG\r
+    //\r
+    Status = FindToken (InfFile, COMPONENT_SECTION_STRING, EFI_NV_EVENT_LOG_STRING, 0, Value);\r
+\r
+    if (Status == EFI_SUCCESS) {\r
+      //\r
+      // Add the component\r
+      //\r
+      strcpy (FvInfo->FvComponents[Index].ComponentName, EFI_NV_EVENT_LOG_STRING);\r
+      Status = AsciiStringToUint64 (Value, FALSE, &Value64);\r
+      if (EFI_ERROR (Status)) {\r
+        printf ("ERROR: %s is not a valid integer.\n", EFI_NV_EVENT_LOG_STRING);\r
+        return EFI_ABORTED;\r
+      }\r
+\r
+      FvInfo->FvComponents[Index].Size = (UINTN) Value64;\r
+    } else {\r
+      printf ("WARNING: Could not read %s.\n", EFI_NV_EVENT_LOG_STRING);\r
+    }\r
+\r
+    Index++;\r
+    //\r
+    // Read component FV_FTW_WORKING\r
+    //\r
+    Status = FindToken (InfFile, COMPONENT_SECTION_STRING, EFI_NV_FTW_WORKING_STRING, 0, Value);\r
+\r
+    if (Status == EFI_SUCCESS) {\r
+      //\r
+      // Add the component\r
+      //\r
+      strcpy (FvInfo->FvComponents[Index].ComponentName, EFI_NV_FTW_WORKING_STRING);\r
+      Status = AsciiStringToUint64 (Value, FALSE, &Value64);\r
+      if (EFI_ERROR (Status)) {\r
+        printf ("ERROR: %s is not a valid integer.\n", EFI_NV_FTW_WORKING_STRING);\r
+        return EFI_ABORTED;\r
+      }\r
+\r
+      FvInfo->FvComponents[Index].Size = (UINTN) Value64;\r
+    } else {\r
+      printf ("WARNING: Could not read %s.\n", EFI_NV_FTW_WORKING_STRING);\r
+    }\r
+\r
+    Index++;\r
+    //\r
+    // Read component FV_FTW_SPARE\r
+    //\r
+    Status = FindToken (InfFile, COMPONENT_SECTION_STRING, EFI_NV_FTW_SPARE_STRING, 0, Value);\r
+\r
+    if (Status == EFI_SUCCESS) {\r
+      //\r
+      // Add the component\r
+      //\r
+      strcpy (FvInfo->FvComponents[Index].ComponentName, EFI_NV_FTW_SPARE_STRING);\r
+      Status = AsciiStringToUint64 (Value, FALSE, &Value64);\r
+      if (EFI_ERROR (Status)) {\r
+        printf ("ERROR: %s is not a valid integer.\n", EFI_NV_FTW_SPARE_STRING);\r
+        return EFI_ABORTED;\r
+      }\r
+\r
+      FvInfo->FvComponents[Index].Size = (UINTN) Value64;\r
+    } else {\r
+      printf ("WARNING: Could not read %s.\n", EFI_NV_FTW_SPARE_STRING);\r
+    }\r
+  }\r
+  //\r
+  // Compute size for easy access later\r
+  //\r
+  FvInfo->Size = 0;\r
+  for (Index = 0; FvInfo->FvBlocks[Index].NumBlocks; Index++) {\r
+    FvInfo->Size += FvInfo->FvBlocks[Index].NumBlocks * FvInfo->FvBlocks[Index].BlockLength;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+VOID\r
+UpdateFfsFileState (\r
+  IN EFI_FFS_FILE_HEADER          *FfsFile,\r
+  IN EFI_FIRMWARE_VOLUME_HEADER   *FvHeader\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function changes the FFS file attributes based on the erase polarity\r
+  of the FV.\r
+\r
+Arguments:\r
+\r
+  FfsFile   File header.\r
+  FvHeader  FV header.\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+{\r
+  if (FvHeader->Attributes & EFI_FVB_ERASE_POLARITY) {\r
+    FfsFile->State = (UINT8)~(FfsFile->State);\r
+  }\r
+}\r
+\r
+EFI_STATUS\r
+ReadFfsAlignment (\r
+  IN EFI_FFS_FILE_HEADER    *FfsFile,\r
+  IN OUT UINT32             *Alignment\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function determines the alignment of the FFS input file from the file\r
+  attributes.\r
+\r
+Arguments:\r
+\r
+  FfsFile       FFS file to parse\r
+  Alignment     The minimum required alignment of the FFS file, in bytes\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS              The function completed successfully.\r
+  EFI_INVALID_PARAMETER    One of the input parameters was invalid.\r
+  EFI_ABORTED              An error occurred.\r
+\r
+--*/\r
+{\r
+  //\r
+  // Verify input parameters.\r
+  //\r
+  if (FfsFile == NULL || Alignment == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  switch ((FfsFile->Attributes >> 3) & 0x07) {\r
+\r
+  case 0:\r
+    //\r
+    // 1 byte alignment\r
+    //\r
+    *Alignment = (1 << 0);\r
+    break;\r
+\r
+  case 1:\r
+    //\r
+    // 16 byte alignment\r
+    //\r
+    *Alignment = (1 << 4);\r
+    break;\r
+\r
+  case 2:\r
+    //\r
+    // 128 byte alignment\r
+    //\r
+    *Alignment = (1 << 7);\r
+    break;\r
+\r
+  case 3:\r
+    //\r
+    // 512 byte alignment\r
+    //\r
+    *Alignment = (1 << 9);\r
+    break;\r
+\r
+  case 4:\r
+    //\r
+    // 1K byte alignment\r
+    //\r
+    *Alignment = (1 << 10);\r
+    break;\r
+\r
+  case 5:\r
+    //\r
+    // 4K byte alignment\r
+    //\r
+    *Alignment = (1 << 12);\r
+    break;\r
+\r
+  case 6:\r
+    //\r
+    // 32K byte alignment\r
+    //\r
+    *Alignment = (1 << 15);\r
+    break;\r
+\r
+  case 7:\r
+    //\r
+    // 64K byte alignment\r
+    //\r
+    *Alignment = (1 << 16);\r
+    break;\r
+\r
+  default:\r
+    Error (NULL, 0, 0, "nvalid file attribute calculated, this is most likely a utility error", NULL);\r
+    return EFI_ABORTED;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+AddPadFile (\r
+  IN OUT MEMORY_FILE  *FvImage,\r
+  IN UINT32           DataAlignment\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function adds a pad file to the FV image if it required to align the\r
+  data of the next file.\r
+\r
+Arguments:\r
+\r
+  FvImage         The memory image of the FV to add it to.  The current offset\r
+                  must be valid.\r
+  DataAlignment   The data alignment of the next FFS file.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS              The function completed successfully.\r
+  EFI_INVALID_PARAMETER    One of the input parameters was invalid.\r
+  EFI_OUT_OF_RESOURCES     Insufficient resources exist in the FV to complete\r
+                           the pad file add.\r
+\r
+--*/\r
+{\r
+  EFI_FFS_FILE_HEADER *PadFile;\r
+  EFI_GUID            PadFileGuid;\r
+  UINTN               PadFileSize;\r
+\r
+  //\r
+  // Verify input parameters.\r
+  //\r
+  if (FvImage == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+  //\r
+  // Basic assumption is we start from an 8 byte aligned address\r
+  // and our file header is a multiple of 8 bytes\r
+  //\r
+  assert ((UINTN) FvImage->CurrentFilePointer % 8 == 0);\r
+  assert (sizeof (EFI_FFS_FILE_HEADER) % 8 == 0);\r
+\r
+  //\r
+  // Check if a pad file is necessary\r
+  //\r
+  if (((UINTN) FvImage->CurrentFilePointer - (UINTN) FvImage->FileImage + sizeof (EFI_FFS_FILE_HEADER)) % DataAlignment == 0) {\r
+    return EFI_SUCCESS;\r
+  }\r
+  //\r
+  // Write pad file header\r
+  //\r
+  PadFile = (EFI_FFS_FILE_HEADER *) FvImage->CurrentFilePointer;\r
+\r
+  //\r
+  // Verify that we have enough space for the file header\r
+  //\r
+  if ((UINTN) (PadFile + sizeof (EFI_FFS_FILE_HEADER)) >= (UINTN) FvImage->Eof) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+\r
+#ifdef __GNUC__\r
+  {\r
+    uuid_t tmp_id;\r
+    uuid_generate (tmp_id);\r
+    memcpy (&PadFileGuid, tmp_id, sizeof (EFI_GUID));\r
+  }\r
+#else\r
+  UuidCreate (&PadFileGuid);\r
+#endif\r
+  memset (PadFile, 0, sizeof (EFI_FFS_FILE_HEADER));\r
+  memcpy (&PadFile->Name, &PadFileGuid, sizeof (EFI_GUID));\r
+  PadFile->Type       = EFI_FV_FILETYPE_FFS_PAD;\r
+  PadFile->Attributes = 0;\r
+\r
+  //\r
+  // Calculate the pad file size\r
+  //\r
+  //\r
+  // This is the earliest possible valid offset (current plus pad file header\r
+  // plus the next file header)\r
+  //\r
+  PadFileSize = (UINTN) FvImage->CurrentFilePointer - (UINTN) FvImage->FileImage + (sizeof (EFI_FFS_FILE_HEADER) * 2);\r
+\r
+  //\r
+  // Add whatever it takes to get to the next aligned address\r
+  //\r
+  while ((PadFileSize % DataAlignment) != 0) {\r
+    PadFileSize++;\r
+  }\r
+  //\r
+  // Subtract the next file header size\r
+  //\r
+  PadFileSize -= sizeof (EFI_FFS_FILE_HEADER);\r
+\r
+  //\r
+  // Subtract the starting offset to get size\r
+  //\r
+  PadFileSize -= (UINTN) FvImage->CurrentFilePointer - (UINTN) FvImage->FileImage;\r
+\r
+  //\r
+  // Write pad file size (calculated size minus next file header size)\r
+  //\r
+  PadFile->Size[0]  = (UINT8) (PadFileSize & 0xFF);\r
+  PadFile->Size[1]  = (UINT8) ((PadFileSize >> 8) & 0xFF);\r
+  PadFile->Size[2]  = (UINT8) ((PadFileSize >> 16) & 0xFF);\r
+\r
+  //\r
+  // Fill in checksums and state, they must be 0 for checksumming.\r
+  //\r
+  PadFile->IntegrityCheck.Checksum.Header = 0;\r
+  PadFile->IntegrityCheck.Checksum.File   = 0;\r
+  PadFile->State                          = 0;\r
+  PadFile->IntegrityCheck.Checksum.Header = CalculateChecksum8 ((UINT8 *) PadFile, sizeof (EFI_FFS_FILE_HEADER));\r
+  if (PadFile->Attributes & FFS_ATTRIB_CHECKSUM) {\r
+    PadFile->IntegrityCheck.Checksum.File = CalculateChecksum8 ((UINT8 *) PadFile, PadFileSize);\r
+  } else {\r
+    PadFile->IntegrityCheck.Checksum.File = FFS_FIXED_CHECKSUM;\r
+  }\r
+\r
+  PadFile->State = EFI_FILE_HEADER_CONSTRUCTION | EFI_FILE_HEADER_VALID | EFI_FILE_DATA_VALID;\r
+  UpdateFfsFileState (\r
+    (EFI_FFS_FILE_HEADER *) PadFile,\r
+    (EFI_FIRMWARE_VOLUME_HEADER *) FvImage->FileImage\r
+    );\r
+\r
+  //\r
+  // Verify that we have enough space (including the padding\r
+  //\r
+  if ((UINTN) (PadFile + sizeof (EFI_FFS_FILE_HEADER)) >= (UINTN) FvImage->Eof) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+  //\r
+  // Update the current FV pointer\r
+  //\r
+  FvImage->CurrentFilePointer += PadFileSize;\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+BOOLEAN\r
+IsVtfFile (\r
+  IN EFI_FFS_FILE_HEADER    *FileBuffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function checks the header to validate if it is a VTF file\r
+\r
+Arguments:\r
+\r
+  FileBuffer     Buffer in which content of a file has been read.\r
+\r
+Returns:\r
+\r
+  TRUE    If this is a VTF file\r
+  FALSE   If this is not a VTF file\r
+\r
+--*/\r
+{\r
+  EFI_GUID  VtfGuid = EFI_FFS_VOLUME_TOP_FILE_GUID;\r
+  if (!memcmp (&FileBuffer->Name, &VtfGuid, sizeof (EFI_GUID))) {\r
+    return TRUE;\r
+  } else {\r
+    return FALSE;\r
+  }\r
+}\r
+\r
+EFI_STATUS\r
+FfsRebaseImageRead (\r
+  IN     VOID    *FileHandle,\r
+  IN     UINTN   FileOffset,\r
+  IN OUT UINT32  *ReadSize,\r
+  OUT    VOID    *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Support routine for the PE/COFF Loader that reads a buffer from a PE/COFF file\r
+\r
+Arguments:\r
+\r
+  FileHandle - The handle to the PE/COFF file\r
+\r
+  FileOffset - The offset, in bytes, into the file to read\r
+\r
+  ReadSize   - The number of bytes to read from the file starting at FileOffset\r
+\r
+  Buffer     - A pointer to the buffer to read the data into.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS - ReadSize bytes of data were read into Buffer from the PE/COFF file starting at FileOffset\r
+\r
+--*/\r
+{\r
+  CHAR8   *Destination8;\r
+  CHAR8   *Source8;\r
+  UINT32  Length;\r
+\r
+  Destination8  = Buffer;\r
+  Source8       = (CHAR8 *) ((UINTN) FileHandle + FileOffset);\r
+  Length        = *ReadSize;\r
+  while (Length--) {\r
+    *(Destination8++) = *(Source8++);\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+EFI_STATUS\r
+AddSymFile (\r
+  IN UINT64               BaseAddress,\r
+  IN EFI_FFS_FILE_HEADER  *FfsFile,\r
+  IN OUT MEMORY_FILE      *SymImage,\r
+  IN CHAR8                *SourceFileName\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function adds the SYM tokens in the source file to the destination file.\r
+  The SYM tokens are updated to reflect the base address.\r
+\r
+Arguments:\r
+\r
+  BaseAddress     The base address for the new SYM tokens.\r
+  FfsFile         Pointer to the beginning of the FFS file in question.\r
+  SymImage        The memory file to update with symbol information.\r
+  SourceFileName  The source file.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS              The function completed successfully.\r
+  EFI_INVALID_PARAMETER    One of the input parameters was invalid.\r
+  EFI_ABORTED              An error occurred.\r
+\r
+--*/\r
+{\r
+  FILE                      *SourceFile;\r
+\r
+  CHAR8                     Buffer[_MAX_PATH];\r
+  CHAR8                     Type[_MAX_PATH];\r
+  CHAR8                     Address[_MAX_PATH];\r
+  CHAR8                     Section[_MAX_PATH];\r
+  CHAR8                     Token[_MAX_PATH];\r
+  CHAR8                     SymFileName[_MAX_PATH];\r
+  CHAR8                     CodeModuleName[_MAX_PATH];\r
+  CHAR8                     *Ptr;\r
+\r
+  UINT64                    TokenAddress;\r
+\r
+  EFI_STATUS                Status;\r
+  EFI_FILE_SECTION_POINTER  Pe32Section;\r
+  UINT32                    EntryPoint;\r
+  UINT32                    BaseOfCode;\r
+  UINT16                    MachineType;\r
+\r
+  //\r
+  // Verify input parameters.\r
+  //\r
+  if (BaseAddress == 0 || FfsFile == NULL || SymImage == NULL || SourceFileName == NULL) {\r
+    Error (NULL, 0, 0, "invalid parameter passed to AddSymFile()", NULL);\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+  //\r
+  // Check if we want to add this file\r
+  //\r
+  //\r
+  // Get the file name\r
+  //\r
+  strcpy (Buffer, SourceFileName);\r
+\r
+  //\r
+  // Copy the file name for the path of the sym file and truncate the name portion.\r
+  //\r
+  strcpy (SymFileName, Buffer);\r
+  Ptr = strrchr (SymFileName, '\\');\r
+  assert (Ptr);\r
+  Ptr[0] = 0;\r
+\r
+  //\r
+  // Find the file extension and make it lower case\r
+  //\r
+  Ptr = strrchr (SymFileName, '.');\r
+  if (Ptr != NULL) {\r
+    strlwr (Ptr);\r
+  }\r
+  //\r
+  // Check if it is PEI file\r
+  //\r
+  if (strstr (Buffer, ".pei") != NULL) {\r
+    //\r
+    // Find the human readable portion\r
+    //\r
+    if (!strtok (Buffer, "-") ||\r
+        !strtok (NULL, "-") ||\r
+        !strtok (NULL, "-") ||\r
+        !strtok (NULL, "-") ||\r
+        !strtok (NULL, "-") ||\r
+        !strcpy (Buffer, strtok (NULL, "."))\r
+          ) {\r
+      Error (NULL, 0, 0, "failed to find human readable portion of the file name in AddSymFile()", NULL);\r
+      return EFI_ABORTED;\r
+    }\r
+    //\r
+    // Save code module name\r
+    //\r
+    strcpy (CodeModuleName, Buffer);\r
+\r
+    //\r
+    // Add the symbol file name and extension to the file path.\r
+    //\r
+    strcat (Buffer, ".sym");\r
+    strcat (SymFileName, "\\");\r
+    strcat (SymFileName, Buffer);\r
+  } else {\r
+    //\r
+    // Only handle PEIM files.\r
+    //\r
+    return EFI_SUCCESS;\r
+  }\r
+  //\r
+  // Find PE32 section\r
+  //\r
+  Status = GetSectionByType (FfsFile, EFI_SECTION_PE32, 1, &Pe32Section);\r
+\r
+  //\r
+  // BUGBUG: Assume if no PE32 section it is PIC and hardcode base address\r
+  //\r
+  if (Status == EFI_NOT_FOUND) {\r
+    Status = GetSectionByType (FfsFile, EFI_SECTION_TE, 1, &Pe32Section);\r
+  }\r
+\r
+  if (Status == EFI_SUCCESS) {\r
+    Status = GetPe32Info (\r
+              (VOID *) ((UINTN) Pe32Section.Pe32Section + sizeof (EFI_SECTION_PE32)),\r
+              &EntryPoint,\r
+              &BaseOfCode,\r
+              &MachineType\r
+              );\r
+  } else if (Status == EFI_NOT_FOUND) {\r
+    //\r
+    // For PIC, hardcode.\r
+    //\r
+    BaseOfCode = 0x60;\r
+    Status = EFI_SUCCESS;\r
+  } else {\r
+    Error (NULL, 0, 0, "could not parse a PE32 section from the PEI file", NULL);\r
+    return Status;\r
+  }\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    Error (NULL, 0, 0, "GetPe32Info() could not get PE32 entry point for PEI file", NULL);\r
+    return Status;\r
+  }\r
+\r
+  //\r
+  // Open the source file\r
+  //\r
+  SourceFile = fopen (SymFileName, "r");\r
+  if (SourceFile == NULL) {\r
+    //\r
+    // SYM files are not required.\r
+    //\r
+    return EFI_SUCCESS;\r
+  }\r
+  //\r
+  // Read the first line\r
+  //\r
+  if (fgets (Buffer, _MAX_PATH, SourceFile) == NULL) {\r
+    Buffer[0] = 0;\r
+  }\r
+  //\r
+  // Make sure it matches the expected sym format\r
+  //\r
+  if (strcmp (Buffer, "TEXTSYM format | V1.0\n")) {\r
+    fclose (SourceFile);\r
+    Error (NULL, 0, 0, "AddSymFile() found unexpected sym format in input file", NULL);\r
+    return EFI_ABORTED;\r
+  }\r
+  //\r
+  // Read in the file\r
+  //\r
+  while (feof (SourceFile) == 0) {\r
+    //\r
+    // Read a line\r
+    //\r
+    if (fscanf (\r
+          SourceFile,\r
+          "%s | %s | %s | %s\n",\r
+          Type,\r
+          Address,\r
+          Section,\r
+          Token\r
+          ) == 4) {\r
+      //\r
+      // If the token starts with "??" ignore it\r
+      //\r
+      if (Token[0] == '?' && Token[1] == '?') {\r
+        continue;\r
+      }\r
+      //\r
+      // Get the token address\r
+      //\r
+      AsciiStringToUint64 (Address, TRUE, &TokenAddress);\r
+\r
+      //\r
+      // Add the base address\r
+      //\r
+      TokenAddress += BaseAddress;\r
+\r
+      //\r
+      // If PE32 or TE section then find the start of code.  For PIC it is hardcoded.\r
+      //\r
+      if (Pe32Section.Pe32Section) {\r
+        //\r
+        // Add the offset of the PE32 section\r
+        //\r
+        TokenAddress += (UINTN) Pe32Section.Pe32Section - (UINTN) FfsFile;\r
+\r
+        //\r
+        // Add the size of the PE32 section header\r
+        //\r
+        TokenAddress += sizeof (EFI_PE32_SECTION);\r
+      } else {\r
+        //\r
+        // For PIC hardcoded.\r
+        //\r
+        TokenAddress += 0x28;\r
+      }\r
+\r
+      //\r
+      // Add the beginning of the code\r
+      //\r
+      TokenAddress += BaseOfCode;\r
+\r
+      sprintf (\r
+        Buffer,\r
+        "%s | %016I64X | %s | _%s%s\n",\r
+        Type,\r
+        TokenAddress,\r
+        Section,\r
+        CodeModuleName,\r
+        Token\r
+        );\r
+      memcpy (SymImage->CurrentFilePointer, Buffer, strlen (Buffer) + 1);\r
+      SymImage->CurrentFilePointer = (UINT8 *) (((UINTN) SymImage->CurrentFilePointer) + strlen (Buffer) + 1);\r
+    }\r
+  }\r
+\r
+  fclose (SourceFile);\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+AddFile (\r
+  IN OUT MEMORY_FILE          *FvImage,\r
+  IN FV_INFO                  *FvInfo,\r
+  IN UINTN                    Index,\r
+  IN OUT EFI_FFS_FILE_HEADER  **VtfFileImage,\r
+  IN OUT MEMORY_FILE          *SymImage\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function adds a file to the FV image.  The file will pad to the\r
+  appropriate alignment if required.\r
+\r
+Arguments:\r
+\r
+  FvImage       The memory image of the FV to add it to.  The current offset\r
+                must be valid.\r
+  FvInfo        Pointer to information about the FV.\r
+  Index         The file in the FvInfo file list to add.\r
+  VtfFileImage  A pointer to the VTF file within the FvImage.  If this is equal\r
+                to the end of the FvImage then no VTF previously found.\r
+  SymImage      The memory image of the Sym file to update if symbols are present.\r
+                The current offset must be valid.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS              The function completed successfully.\r
+  EFI_INVALID_PARAMETER    One of the input parameters was invalid.\r
+  EFI_ABORTED              An error occurred.\r
+  EFI_OUT_OF_RESOURCES     Insufficient resources exist to complete the add.\r
+\r
+--*/\r
+{\r
+  FILE                  *NewFile;\r
+  UINTN                 FileSize;\r
+  UINT8                 *FileBuffer;\r
+  UINTN                 NumBytesRead;\r
+  UINT32                CurrentFileAlignment;\r
+  EFI_STATUS            Status;\r
+  EFI_PHYSICAL_ADDRESS  CurrentFileBaseAddress;\r
+  UINT8                 VtfHeaderChecksum;\r
+  UINT8                 VtfFileChecksum;\r
+  UINT8                 FileState;\r
+  EFI_FFS_FILE_TAIL     TailValue;\r
+  UINT32                TailSize;\r
+  //\r
+  // Verify input parameters.\r
+  //\r
+  if (FvImage == NULL || FvInfo == NULL || FvInfo->FvFiles[Index][0] == 0 || VtfFileImage == NULL || SymImage == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+  //\r
+  // Read the file to add\r
+  //\r
+  NewFile = fopen (FvInfo->FvFiles[Index], "rb");\r
+\r
+  if (NewFile == NULL) {\r
+    Error (NULL, 0, 0, FvInfo->FvFiles[Index], "failed to open file for reading");\r
+    return EFI_ABORTED;\r
+  }\r
+  //\r
+  // Get the file size\r
+  //\r
+#ifdef __GNUC__\r
+  {\r
+    struct stat stat_buf;\r
+    fstat(fileno(NewFile), &stat_buf);\r
+    FileSize = stat_buf.st_size;\r
+  }\r
+#else\r
+  FileSize = _filelength (fileno (NewFile));\r
+#endif\r
+\r
+  //\r
+  // Read the file into a buffer\r
+  //\r
+  FileBuffer = malloc (FileSize);\r
+  if (FileBuffer == NULL) {\r
+    Error (NULL, 0, 0, "memory allocation failure", NULL);\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+\r
+  NumBytesRead = fread (FileBuffer, sizeof (UINT8), FileSize, NewFile);\r
+\r
+  //\r
+  // Done with the file, from this point on we will just use the buffer read.\r
+  //\r
+  fclose (NewFile);\r
+\r
+  //\r
+  // Verify read successful\r
+  //\r
+  if (NumBytesRead != sizeof (UINT8) * FileSize) {\r
+    free (FileBuffer);\r
+    Error (NULL, 0, 0, FvInfo->FvFiles[Index], "failed to read input file contents");\r
+    return EFI_ABORTED;\r
+  }\r
+  //\r
+  // Verify space exists to add the file\r
+  //\r
+  if (FileSize > (UINTN) ((UINTN) *VtfFileImage - (UINTN) FvImage->CurrentFilePointer)) {\r
+    Error (NULL, 0, 0, FvInfo->FvFiles[Index], "insufficient space remains to add the file");\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+  //\r
+  // Update the file state based on polarity of the FV.\r
+  //\r
+  UpdateFfsFileState (\r
+    (EFI_FFS_FILE_HEADER *) FileBuffer,\r
+    (EFI_FIRMWARE_VOLUME_HEADER *) FvImage->FileImage\r
+    );\r
+\r
+  //\r
+  // If we have a VTF file, add it at the top.\r
+  //\r
+  if (IsVtfFile ((EFI_FFS_FILE_HEADER *) FileBuffer)) {\r
+    if ((UINTN) *VtfFileImage == (UINTN) FvImage->Eof) {\r
+      //\r
+      // No previous VTF, add this one.\r
+      //\r
+      *VtfFileImage = (EFI_FFS_FILE_HEADER *) (UINTN) ((UINTN) FvImage->FileImage + FvInfo->Size - FileSize);\r
+      //\r
+      // Sanity check. The file MUST align appropriately\r
+      //\r
+      if ((((UINTN) *VtfFileImage) & 0x07) != 0) {\r
+        Error (NULL, 0, 0, "VTF file does not align on 8-byte boundary", NULL);\r
+      }\r
+      //\r
+      // copy VTF File Header\r
+      //\r
+      memcpy (*VtfFileImage, FileBuffer, sizeof (EFI_FFS_FILE_HEADER));\r
+\r
+      //\r
+      // Copy VTF body\r
+      //\r
+      memcpy (\r
+        (UINT8 *) *VtfFileImage + sizeof (EFI_FFS_FILE_HEADER),\r
+        FileBuffer + sizeof (EFI_FFS_FILE_HEADER),\r
+        FileSize - sizeof (EFI_FFS_FILE_HEADER)\r
+        );\r
+\r
+      //\r
+      // re-calculate the VTF File Header\r
+      //\r
+      FileState = (*VtfFileImage)->State;\r
+      (*VtfFileImage)->State = 0;\r
+      *(UINT32 *) ((*VtfFileImage)->Size) = FileSize;\r
+      (*VtfFileImage)->IntegrityCheck.Checksum.Header = 0;\r
+      (*VtfFileImage)->IntegrityCheck.Checksum.File = 0;\r
+\r
+      VtfHeaderChecksum = CalculateChecksum8 ((UINT8 *) *VtfFileImage, sizeof (EFI_FFS_FILE_HEADER));\r
+      (*VtfFileImage)->IntegrityCheck.Checksum.Header = VtfHeaderChecksum;\r
+      //\r
+      // Determine if it has a tail\r
+      //\r
+      if ((*VtfFileImage)->Attributes & FFS_ATTRIB_TAIL_PRESENT) {\r
+        TailSize = sizeof (EFI_FFS_FILE_TAIL);\r
+      } else {\r
+        TailSize = 0;\r
+      }\r
+\r
+      if ((*VtfFileImage)->Attributes & FFS_ATTRIB_CHECKSUM) {\r
+        VtfFileChecksum = CalculateChecksum8 ((UINT8 *) *VtfFileImage, FileSize - TailSize);\r
+        (*VtfFileImage)->IntegrityCheck.Checksum.File = VtfFileChecksum;\r
+      } else {\r
+        (*VtfFileImage)->IntegrityCheck.Checksum.File = FFS_FIXED_CHECKSUM;\r
+      }\r
+      //\r
+      // If it has a file tail, update it\r
+      //\r
+      if ((*VtfFileImage)->Attributes & FFS_ATTRIB_TAIL_PRESENT) {\r
+        TailValue = (EFI_FFS_FILE_TAIL) (~((*VtfFileImage)->IntegrityCheck.TailReference));\r
+        *(EFI_FFS_FILE_TAIL *) (((UINTN) (*VtfFileImage) + GetLength ((*VtfFileImage)->Size) - sizeof (EFI_FFS_FILE_TAIL))) = TailValue;\r
+      }\r
+      (*VtfFileImage)->State = FileState;\r
+      free (FileBuffer);\r
+      return EFI_SUCCESS;\r
+    } else {\r
+      //\r
+      // Already found a VTF file.\r
+      //\r
+      Error (NULL, 0, 0, "multiple VTF files are illegal in a single FV", NULL);\r
+      free (FileBuffer);\r
+      return EFI_ABORTED;\r
+    }\r
+  }\r
+  //\r
+  // Check if alignment is required\r
+  //\r
+  Status = ReadFfsAlignment ((EFI_FFS_FILE_HEADER *) FileBuffer, &CurrentFileAlignment);\r
+  if (EFI_ERROR (Status)) {\r
+    printf ("ERROR: Could not determine alignment of file %s.\n", FvInfo->FvFiles[Index]);\r
+    free (FileBuffer);\r
+    return EFI_ABORTED;\r
+  }\r
+  //\r
+  // Add pad file if necessary\r
+  //\r
+  Status = AddPadFile (FvImage, CurrentFileAlignment);\r
+  if (EFI_ERROR (Status)) {\r
+    printf ("ERROR: Could not align the file data properly.\n");\r
+    free (FileBuffer);\r
+    return EFI_ABORTED;\r
+  }\r
+  //\r
+  // Add file\r
+  //\r
+  if ((FvImage->CurrentFilePointer + FileSize) < FvImage->Eof) {\r
+    //\r
+    // Copy the file\r
+    //\r
+    memcpy (FvImage->CurrentFilePointer, FileBuffer, FileSize);\r
+\r
+    //\r
+    // If the file is XIP, rebase\r
+    //\r
+    CurrentFileBaseAddress = FvInfo->BaseAddress + ((UINTN) FvImage->CurrentFilePointer - (UINTN) FvImage->FileImage);\r
+    //\r
+    //    Status = RebaseFfsFile ((EFI_FFS_FILE_HEADER*) FvImage->CurrentFilePointer, CurrentFileBaseAddress);\r
+    //    if (EFI_ERROR(Status)) {\r
+    //      printf ("ERROR: Could not rebase the file %s.\n", FvInfo->FvFiles[Index]);\r
+    //      return EFI_ABORTED;\r
+    //    }\r
+    //\r
+    // Update Symbol file\r
+    //\r
+    Status = AddSymFile (\r
+              CurrentFileBaseAddress,\r
+              (EFI_FFS_FILE_HEADER *) FvImage->CurrentFilePointer,\r
+              SymImage,\r
+              FvInfo->FvFiles[Index]\r
+              );\r
+    assert (!EFI_ERROR (Status));\r
+\r
+    //\r
+    // Update the current pointer in the FV image\r
+    //\r
+    FvImage->CurrentFilePointer += FileSize;\r
+  } else {\r
+    printf ("ERROR: The firmware volume is out of space, could not add file %s.\n", FvInfo->FvFiles[Index]);\r
+    return EFI_ABORTED;\r
+  }\r
+  //\r
+  // Make next file start at QWord Boundry\r
+  //\r
+  while (((UINTN) FvImage->CurrentFilePointer & 0x07) != 0) {\r
+    FvImage->CurrentFilePointer++;\r
+  }\r
+  //\r
+  // Free allocated memory.\r
+  //\r
+  free (FileBuffer);\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+AddVariableBlock (\r
+  IN UINT8                    *FvImage,\r
+  IN UINTN                    Size,\r
+  IN FV_INFO                  *FvInfo\r
+  )\r
+{\r
+  EFI_FIRMWARE_VOLUME_HEADER  *FvHeader;\r
+  VARIABLE_STORE_HEADER       *VarStoreHeader;\r
+  //\r
+  // Variable block should exclude FvHeader. Since the length of\r
+  // FvHeader depends on the block map, which is variable length,\r
+  // we could only decide the actual variable block length here.\r
+  //\r
+  FvHeader                  = (EFI_FIRMWARE_VOLUME_HEADER *) FvImage;\r
+  FvImage                   = FvImage + FvHeader->HeaderLength;\r
+\r
+  VarStoreHeader            = (VARIABLE_STORE_HEADER *) FvImage;\r
+\r
+  VarStoreHeader->Signature = VARIABLE_STORE_SIGNATURE;\r
+  VarStoreHeader->Size      = Size - FvHeader->HeaderLength;\r
+  VarStoreHeader->Format    = VARIABLE_STORE_FORMATTED;\r
+  VarStoreHeader->State     = VARIABLE_STORE_HEALTHY;\r
+  VarStoreHeader->Reserved  = 0;\r
+  VarStoreHeader->Reserved1 = 0;\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+AddEventLogBlock (\r
+  IN UINT8                    *FvImage,\r
+  IN UINTN                    Size,\r
+  IN FV_INFO                  *FvInfo\r
+  )\r
+{\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+AddFTWWorkingBlock (\r
+  IN UINT8                    *FvImage,\r
+  IN UINTN                    Size,\r
+  IN FV_INFO                  *FvInfo\r
+  )\r
+{\r
+  EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER *FTWHeader;\r
+  UINT32                                  Crc32;\r
+\r
+  Crc32     = 0;\r
+  FTWHeader = (EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER *) FvImage;\r
+  memcpy (&FTWHeader->Signature, &(FvInfo->FvGuid), sizeof (EFI_GUID));\r
+  FTWHeader->WriteQueueSize = Size - sizeof (EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER);\r
+  CalculateCrc32 (FvImage, sizeof (EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER), &Crc32);\r
+  FTWHeader->Crc = Crc32;\r
+  if (FvInfo->FvAttributes & EFI_FVB_ERASE_POLARITY) {\r
+    FTWHeader->WorkingBlockValid    = 0;\r
+    FTWHeader->WorkingBlockInvalid  = 1;\r
+  } else {\r
+    FTWHeader->WorkingBlockValid    = 1;\r
+    FTWHeader->WorkingBlockInvalid  = 0;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+AddFTWSpareBlock (\r
+  IN UINT8                    *FvImage,\r
+  IN UINTN                    Size,\r
+  IN FV_INFO                  *FvInfo\r
+  )\r
+{\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+GenNonFFSFv (\r
+  IN UINT8                    *FvImage,\r
+  IN FV_INFO                  *FvInfo\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function generate the non FFS FV image, such as the working block\r
+  and spare block. How each component of the FV is built is component\r
+  specific.\r
+\r
+Arguments:\r
+\r
+  FvImage       The memory image of the FV to add it to.  The current offset\r
+                must be valid.\r
+  FvInfo        Pointer to information about the FV.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS              The function completed successfully.\r
+  EFI_INVALID_PARAMETER    One of the input parameters was invalid.\r
+  EFI_ABORTED              An error occurred.\r
+  EFI_OUT_OF_RESOURCES     Insufficient resources exist to complete the add.\r
+\r
+--*/\r
+{\r
+  UINTN                       Index;\r
+  EFI_FIRMWARE_VOLUME_HEADER  *FvHeader;\r
+  UINT64                      TotalSize;\r
+\r
+  FvHeader  = (EFI_FIRMWARE_VOLUME_HEADER *) FvImage;\r
+  TotalSize = 0;\r
+\r
+  for (Index = 0; FvInfo->FvComponents[Index].Size != 0; Index++) {\r
+    if (stricmp (FvInfo->FvComponents[Index].ComponentName, EFI_NV_VARIABLE_STRING) == 0) {\r
+      AddVariableBlock (FvImage, FvInfo->FvComponents[Index].Size, FvInfo);\r
+    } else if (stricmp (FvInfo->FvComponents[Index].ComponentName, EFI_NV_EVENT_LOG_STRING) == 0) {\r
+      AddEventLogBlock (FvImage, FvInfo->FvComponents[Index].Size, FvInfo);\r
+    } else if (stricmp (FvInfo->FvComponents[Index].ComponentName, EFI_NV_FTW_WORKING_STRING) == 0) {\r
+      AddFTWWorkingBlock (FvImage, FvInfo->FvComponents[Index].Size, FvInfo);\r
+    } else if (stricmp (FvInfo->FvComponents[Index].ComponentName, EFI_NV_FTW_SPARE_STRING) == 0) {\r
+      AddFTWSpareBlock (FvImage, FvInfo->FvComponents[Index].Size, FvInfo);\r
+    } else {\r
+      printf ("Error. Unknown Non-FFS block %s \n", FvInfo->FvComponents[Index].ComponentName);\r
+      return EFI_ABORTED;\r
+    }\r
+\r
+    FvImage   = FvImage + FvInfo->FvComponents[Index].Size;\r
+    TotalSize = TotalSize + FvInfo->FvComponents[Index].Size;\r
+  }\r
+  //\r
+  // Index and TotalSize is zero mean there's no component, so this is an empty fv\r
+  //\r
+  if ((Index != 0 || TotalSize != 0) && TotalSize != FvInfo->Size) {\r
+    printf ("Error. Component size does not sum up to FV size.\n");\r
+    return EFI_ABORTED;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+PadFvImage (\r
+  IN MEMORY_FILE          *FvImage,\r
+  IN EFI_FFS_FILE_HEADER  *VtfFileImage\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function places a pad file between the last file in the FV and the VTF\r
+  file if the VTF file exists.\r
+\r
+Arguments:\r
+\r
+  FvImage       Memory file for the FV memory image\r
+  VtfFileImage  The address of the VTF file.  If this is the end of the FV\r
+                image, no VTF exists and no pad file is needed.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS             Completed successfully.\r
+  EFI_INVALID_PARAMETER   One of the input parameters was NULL.\r
+\r
+--*/\r
+{\r
+  EFI_FFS_FILE_HEADER *PadFile;\r
+  UINTN               FileSize;\r
+\r
+  //\r
+  // If there is no VTF or the VTF naturally follows the previous file without a\r
+  // pad file, then there's nothing to do\r
+  //\r
+  if ((UINTN) VtfFileImage == (UINTN) FvImage->Eof || (void *) FvImage->CurrentFilePointer == (void *) VtfFileImage) {\r
+    return EFI_SUCCESS;\r
+  }\r
+  //\r
+  // Pad file starts at beginning of free space\r
+  //\r
+  PadFile = (EFI_FFS_FILE_HEADER *) FvImage->CurrentFilePointer;\r
+\r
+  //\r
+  // write header\r
+  //\r
+  memset (PadFile, 0, sizeof (EFI_FFS_FILE_HEADER));\r
+  memcpy (&PadFile->Name, &DefaultFvPadFileNameGuid, sizeof (EFI_GUID));\r
+  PadFile->Type       = EFI_FV_FILETYPE_FFS_PAD;\r
+  PadFile->Attributes = 0;\r
+\r
+  //\r
+  // FileSize includes the EFI_FFS_FILE_HEADER\r
+  //\r
+  FileSize          = (UINTN) VtfFileImage - (UINTN) FvImage->CurrentFilePointer;\r
+  PadFile->Size[0]  = (UINT8) (FileSize & 0x000000FF);\r
+  PadFile->Size[1]  = (UINT8) ((FileSize & 0x0000FF00) >> 8);\r
+  PadFile->Size[2]  = (UINT8) ((FileSize & 0x00FF0000) >> 16);\r
+\r
+  //\r
+  // Fill in checksums and state, must be zero during checksum calculation.\r
+  //\r
+  PadFile->IntegrityCheck.Checksum.Header = 0;\r
+  PadFile->IntegrityCheck.Checksum.File   = 0;\r
+  PadFile->State                          = 0;\r
+  PadFile->IntegrityCheck.Checksum.Header = CalculateChecksum8 ((UINT8 *) PadFile, sizeof (EFI_FFS_FILE_HEADER));\r
+  if (PadFile->Attributes & FFS_ATTRIB_CHECKSUM) {\r
+    PadFile->IntegrityCheck.Checksum.File = CalculateChecksum8 ((UINT8 *) PadFile, FileSize);\r
+  } else {\r
+    PadFile->IntegrityCheck.Checksum.File = FFS_FIXED_CHECKSUM;\r
+  }\r
+\r
+  PadFile->State = EFI_FILE_HEADER_CONSTRUCTION | EFI_FILE_HEADER_VALID | EFI_FILE_DATA_VALID;\r
+\r
+  UpdateFfsFileState (\r
+    (EFI_FFS_FILE_HEADER *) PadFile,\r
+    (EFI_FIRMWARE_VOLUME_HEADER *) FvImage->FileImage\r
+    );\r
+  //\r
+  // Update the current FV pointer\r
+  //\r
+  FvImage->CurrentFilePointer = FvImage->Eof;\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+UpdateResetVector (\r
+  IN MEMORY_FILE            *FvImage,\r
+  IN FV_INFO                *FvInfo,\r
+  IN EFI_FFS_FILE_HEADER    *VtfFile\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This parses the FV looking for the PEI core and then plugs the address into\r
+  the SALE_ENTRY point of the BSF/VTF for IPF and does BUGBUG TBD action to\r
+  complete an IA32 Bootstrap FV.\r
+\r
+Arguments:\r
+\r
+  FvImage       Memory file for the FV memory image\r
+  FvInfo        Information read from INF file.\r
+  VtfFile       Pointer to the VTF file in the FV image.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS             Function Completed successfully.\r
+  EFI_ABORTED             Error encountered.\r
+  EFI_INVALID_PARAMETER   A required parameter was NULL.\r
+  EFI_NOT_FOUND           PEI Core file not found.\r
+\r
+--*/\r
+{\r
+  EFI_FFS_FILE_HEADER       *PeiCoreFile;\r
+  EFI_FFS_FILE_HEADER       *SecCoreFile;\r
+  EFI_STATUS                Status;\r
+  EFI_FILE_SECTION_POINTER  Pe32Section;\r
+  UINT32                    EntryPoint;\r
+  UINT32                    BaseOfCode;\r
+  UINT16                    MachineType;\r
+  EFI_PHYSICAL_ADDRESS      PeiCorePhysicalAddress;\r
+  EFI_PHYSICAL_ADDRESS      SecCorePhysicalAddress;\r
+  EFI_PHYSICAL_ADDRESS      *SecCoreEntryAddressPtr;\r
+  UINT32                    *Ia32ResetAddressPtr;\r
+  UINT8                     *BytePointer;\r
+  UINT8                     *BytePointer2;\r
+  UINT16                    *WordPointer;\r
+  UINT16                    CheckSum;\r
+  UINTN                     Index;\r
+  EFI_FFS_FILE_STATE        SavedState;\r
+  EFI_FFS_FILE_TAIL         TailValue;\r
+  UINT32                    TailSize;\r
+  UINT64                    FitAddress;\r
+  FIT_TABLE                 *FitTablePtr;\r
+\r
+  //\r
+  // Verify input parameters\r
+  //\r
+  if (FvImage == NULL || FvInfo == NULL || VtfFile == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+  //\r
+  // Initialize FV library\r
+  //\r
+  InitializeFvLib (FvImage->FileImage, (UINTN) FvImage->Eof - (UINTN) FvImage->FileImage);\r
+\r
+  //\r
+  // Verify VTF file\r
+  //\r
+  Status = VerifyFfsFile (VtfFile);\r
+  if (EFI_ERROR (Status)) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+  //\r
+  // Find the PEI Core\r
+  //\r
+  Status = GetFileByType (EFI_FV_FILETYPE_PEI_CORE, 1, &PeiCoreFile);\r
+  if (EFI_ERROR (Status) || PeiCoreFile == NULL) {\r
+    Error (NULL, 0, 0, "could not find the PEI core in the FV", NULL);\r
+    return EFI_ABORTED;\r
+  }\r
+\r
+  //\r
+  // PEI Core found, now find PE32 or TE section\r
+  //\r
+  Status = GetSectionByType (PeiCoreFile, EFI_SECTION_PE32, 1, &Pe32Section);\r
+  if (Status == EFI_NOT_FOUND) {\r
+    Status = GetSectionByType (PeiCoreFile, EFI_SECTION_TE, 1, &Pe32Section);\r
+  }\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    Error (NULL, 0, 0, "could not find PE32 or TE section in PEI core file", NULL);\r
+    return EFI_ABORTED;\r
+  }\r
+\r
+  Status = GetPe32Info (\r
+            (VOID *) ((UINTN) Pe32Section.Pe32Section + sizeof (EFI_SECTION_PE32)),\r
+            &EntryPoint,\r
+            &BaseOfCode,\r
+            &MachineType\r
+            );\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    Error (NULL, 0, 0, "could not get PE32 entry point for PEI core", NULL);\r
+    return EFI_ABORTED;\r
+  }\r
+  //\r
+  // Physical address is FV base + offset of PE32 + offset of the entry point\r
+  //\r
+  PeiCorePhysicalAddress = FvInfo->BaseAddress;\r
+  PeiCorePhysicalAddress += (UINTN) Pe32Section.Pe32Section + sizeof (EFI_SECTION_PE32) - (UINTN) FvImage->FileImage;\r
+  PeiCorePhysicalAddress += EntryPoint;\r
+\r
+  if (MachineType == EFI_IMAGE_MACHINE_IA64) {\r
+    //\r
+    // Update PEI_CORE address\r
+    //\r
+    //\r
+    // Set the uncached attribute bit in the physical address\r
+    //\r
+    PeiCorePhysicalAddress |= 0x8000000000000000ULL;\r
+\r
+    //\r
+    // Check if address is aligned on a 16 byte boundary\r
+    //\r
+    if (PeiCorePhysicalAddress & 0xF) {\r
+      printf (\r
+        "ERROR: PEI_CORE entry point is not aligned on a 16 byte boundary, address specified is %Xh.\n",\r
+        PeiCorePhysicalAddress\r
+        );\r
+      return EFI_ABORTED;\r
+    }\r
+    //\r
+    // First Get the FIT table address\r
+    //\r
+    FitAddress  = (*(UINT64 *) (FvImage->Eof - IPF_FIT_ADDRESS_OFFSET)) & 0xFFFFFFFF;\r
+\r
+    FitTablePtr = (FIT_TABLE *) (FvImage->FileImage + (FitAddress - FvInfo->BaseAddress));\r
+\r
+    Status      = UpdatePeiCoreEntryInFit (FitTablePtr, PeiCorePhysicalAddress);\r
+\r
+    if (!EFI_ERROR (Status)) {\r
+      UpdateFitCheckSum (FitTablePtr);\r
+    }\r
+    //\r
+    // Find the Sec Core\r
+    //\r
+    Status = GetFileByType (EFI_FV_FILETYPE_SECURITY_CORE, 1, &SecCoreFile);\r
+    if (EFI_ERROR (Status) || SecCoreFile == NULL) {\r
+      Error (NULL, 0, 0, "could not find the Sec core in the FV", NULL);\r
+      return EFI_ABORTED;\r
+    }\r
+    //\r
+    // Sec Core found, now find PE32 section\r
+    //\r
+    Status = GetSectionByType (SecCoreFile, EFI_SECTION_PE32, 1, &Pe32Section);\r
+    if (EFI_ERROR (Status)) {\r
+      Error (NULL, 0, 0, "could not find PE32 section in SEC core file", NULL);\r
+      return EFI_ABORTED;\r
+    }\r
+\r
+    Status = GetPe32Info (\r
+              (VOID *) ((UINTN) Pe32Section.Pe32Section + sizeof (EFI_SECTION_PE32)),\r
+              &EntryPoint,\r
+              &BaseOfCode,\r
+              &MachineType\r
+              );\r
+    if (EFI_ERROR (Status)) {\r
+      Error (NULL, 0, 0, "could not get PE32 entry point for SEC core", NULL);\r
+      return EFI_ABORTED;\r
+    }\r
+    //\r
+    // Physical address is FV base + offset of PE32 + offset of the entry point\r
+    //\r
+    SecCorePhysicalAddress = FvInfo->BaseAddress;\r
+    SecCorePhysicalAddress += (UINTN) Pe32Section.Pe32Section + sizeof (EFI_SECTION_PE32) - (UINTN) FvImage->FileImage;\r
+    SecCorePhysicalAddress += EntryPoint;\r
+\r
+    //\r
+    // Update SEC_CORE address\r
+    //\r
+    //\r
+    // Set the uncached attribute bit in the physical address\r
+    //\r
+    SecCorePhysicalAddress |= 0x8000000000000000ULL;\r
+\r
+    //\r
+    // Update the address\r
+    //\r
+    SecCoreEntryAddressPtr  = (EFI_PHYSICAL_ADDRESS *) ((UINTN) FvImage->Eof - IPF_SALE_ENTRY_ADDRESS_OFFSET);\r
+    *SecCoreEntryAddressPtr = SecCorePhysicalAddress;\r
+\r
+    //\r
+    // Check if address is aligned on a 16 byte boundary\r
+    //\r
+    if (SecCorePhysicalAddress & 0xF) {\r
+      printf (\r
+        "ERROR: SALE_ENTRY entry point is not aligned on a 16 byte boundary, address specified is %Xh.\n",\r
+        SecCorePhysicalAddress\r
+        );\r
+      return EFI_ABORTED;\r
+    }\r
+  } else if (MachineType == EFI_IMAGE_MACHINE_IA32) {\r
+    //\r
+    // Get the location to update\r
+    //\r
+    Ia32ResetAddressPtr = (UINT32 *) ((UINTN) FvImage->Eof - IA32_PEI_CORE_ENTRY_OFFSET);\r
+\r
+    //\r
+    // Write lower 32 bits of physical address\r
+    //\r
+    *Ia32ResetAddressPtr = (UINT32) PeiCorePhysicalAddress;\r
+\r
+    //\r
+    // Update the BFV base address\r
+    //\r
+    Ia32ResetAddressPtr   = (UINT32 *) ((UINTN) FvImage->Eof - 4);\r
+    *Ia32ResetAddressPtr  = (UINT32) (FvInfo->BaseAddress);\r
+\r
+    CheckSum              = 0x0000;\r
+\r
+    //\r
+    // Update the Startup AP in the FVH header block ZeroVector region.\r
+    //\r
+    BytePointer   = (UINT8 *) ((UINTN) FvImage->FileImage);\r
+    BytePointer2  = (FvInfo->Size == 0x10000) ? m64kRecoveryStartupApDataArray : m128kRecoveryStartupApDataArray;\r
+    for (Index = 0; Index < SIZEOF_STARTUP_DATA_ARRAY; Index++) {\r
+      *BytePointer++ = *BytePointer2++;\r
+    }\r
+    //\r
+    // Calculate the checksum\r
+    //\r
+    WordPointer = (UINT16 *) ((UINTN) FvImage->FileImage);\r
+    for (Index = 0; Index < SIZEOF_STARTUP_DATA_ARRAY / 2; Index++) {\r
+      CheckSum = (UINT16) (CheckSum + ((UINT16) *WordPointer));\r
+      WordPointer++;\r
+    }\r
+    //\r
+    // Update the checksum field\r
+    //\r
+    BytePointer = (UINT8 *) ((UINTN) FvImage->FileImage);\r
+    BytePointer += (SIZEOF_STARTUP_DATA_ARRAY - 2);\r
+    WordPointer   = (UINT16 *) BytePointer;\r
+    *WordPointer  = (UINT16) (0x10000 - (UINT32) CheckSum);\r
+  } else {\r
+    Error (NULL, 0, 0, "invalid machine type in PEI core", "machine type=0x%X", (UINT32) MachineType);\r
+    return EFI_ABORTED;\r
+  }\r
+  //\r
+  // Determine if it has an FFS file tail.\r
+  //\r
+  if (VtfFile->Attributes & FFS_ATTRIB_TAIL_PRESENT) {\r
+    TailSize = sizeof (EFI_FFS_FILE_TAIL);\r
+  } else {\r
+    TailSize = 0;\r
+  }\r
+  //\r
+  // Now update file checksum\r
+  //\r
+  SavedState  = VtfFile->State;\r
+  VtfFile->IntegrityCheck.Checksum.File = 0;\r
+  VtfFile->State                        = 0;\r
+  if (VtfFile->Attributes & FFS_ATTRIB_CHECKSUM) {\r
+    VtfFile->IntegrityCheck.Checksum.File = CalculateChecksum8 (\r
+                                              (UINT8 *) VtfFile,\r
+                                              GetLength (VtfFile->Size) - TailSize\r
+                                              );\r
+  } else {\r
+    VtfFile->IntegrityCheck.Checksum.File = FFS_FIXED_CHECKSUM;\r
+  }\r
+\r
+  VtfFile->State = SavedState;\r
+\r
+  //\r
+  // Update tail if present\r
+  //\r
+  if (VtfFile->Attributes & FFS_ATTRIB_TAIL_PRESENT) {\r
+    TailValue = (EFI_FFS_FILE_TAIL) (~(VtfFile->IntegrityCheck.TailReference));\r
+    *(EFI_FFS_FILE_TAIL *) (((UINTN) (VtfFile) + GetLength (VtfFile->Size) - sizeof (EFI_FFS_FILE_TAIL))) = TailValue;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+GetPe32Info (\r
+  IN UINT8                  *Pe32,\r
+  OUT UINT32                *EntryPoint,\r
+  OUT UINT32                *BaseOfCode,\r
+  OUT UINT16                *MachineType\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Retrieves the PE32 entry point offset and machine type from PE image or TeImage.  \r
+  See EfiImage.h for machine types.  The entry point offset is from the beginning \r
+  of the PE32 buffer passed in.\r
+\r
+Arguments:\r
+\r
+  Pe32          Beginning of the PE32.\r
+  EntryPoint    Offset from the beginning of the PE32 to the image entry point.\r
+  BaseOfCode    Base address of code.\r
+  MachineType   Magic number for the machine type.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS             Function completed successfully.\r
+  EFI_ABORTED             Error encountered.\r
+  EFI_INVALID_PARAMETER   A required parameter was NULL.\r
+  EFI_UNSUPPORTED         The operation is unsupported.\r
+\r
+--*/\r
+{\r
+  EFI_IMAGE_DOS_HEADER  *DosHeader;\r
+  EFI_IMAGE_NT_HEADERS  *NtHeader;\r
+  EFI_TE_IMAGE_HEADER   *TeHeader;\r
+\r
+  //\r
+  // Verify input parameters\r
+  //\r
+  if (Pe32 == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  //\r
+  // First check whether it is one TE Image.\r
+  //\r
+  TeHeader = (EFI_TE_IMAGE_HEADER *) Pe32;\r
+  if (TeHeader->Signature == EFI_TE_IMAGE_HEADER_SIGNATURE) {\r
+    //\r
+    // By TeImage Header to get output\r
+    //\r
+    *EntryPoint   = TeHeader->AddressOfEntryPoint + sizeof (EFI_TE_IMAGE_HEADER) - TeHeader->StrippedSize;\r
+    *BaseOfCode   = TeHeader->BaseOfCode + sizeof (EFI_TE_IMAGE_HEADER) - TeHeader->StrippedSize;\r
+    *MachineType  = TeHeader->Machine;\r
+  } else {\r
+  \r
+    //\r
+    // Then check whether \r
+    // First is the DOS header\r
+    //\r
+    DosHeader = (EFI_IMAGE_DOS_HEADER *) Pe32;\r
+  \r
+    //\r
+    // Verify DOS header is expected\r
+    //\r
+    if (DosHeader->e_magic != EFI_IMAGE_DOS_SIGNATURE) {\r
+      printf ("ERROR: Unknown magic number in the DOS header, 0x%04X.\n", DosHeader->e_magic);\r
+      return EFI_UNSUPPORTED;\r
+    }\r
+    //\r
+    // Immediately following is the NT header.\r
+    //\r
+    NtHeader = (EFI_IMAGE_NT_HEADERS *) ((UINTN) Pe32 + DosHeader->e_lfanew);\r
+  \r
+    //\r
+    // Verify NT header is expected\r
+    //\r
+    if (NtHeader->Signature != EFI_IMAGE_NT_SIGNATURE) {\r
+      printf ("ERROR: Unrecognized image signature 0x%08X.\n", NtHeader->Signature);\r
+      return EFI_UNSUPPORTED;\r
+    }\r
+    //\r
+    // Get output\r
+    //\r
+    *EntryPoint   = NtHeader->OptionalHeader.AddressOfEntryPoint;\r
+    *BaseOfCode   = NtHeader->OptionalHeader.BaseOfCode;\r
+    *MachineType  = NtHeader->FileHeader.Machine;\r
+  }\r
+\r
+  //\r
+  // Verify machine type is supported\r
+  //\r
+  if (*MachineType != EFI_IMAGE_MACHINE_IA32 && *MachineType != EFI_IMAGE_MACHINE_IA64 && *MachineType != EFI_IMAGE_MACHINE_X64 && *MachineType != EFI_IMAGE_MACHINE_EBC) {\r
+    printf ("ERROR: Unrecognized machine type in the PE32 file.\n");\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+//\r
+// Exposed function implementations (prototypes are defined in GenFvImageLib.h)\r
+//\r
+EFI_STATUS\r
+GenerateFvImage (\r
+  IN CHAR8    *InfFileImage,\r
+  IN UINTN    InfFileSize,\r
+  OUT UINT8   **FvImage,\r
+  OUT UINTN   *FvImageSize,\r
+  OUT CHAR8   **FvFileName,\r
+  OUT UINT8   **SymImage,\r
+  OUT UINTN   *SymImageSize,\r
+  OUT CHAR8   **SymFileName\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This is the main function which will be called from application.\r
+\r
+Arguments:\r
+\r
+  InfFileImage  Buffer containing the INF file contents.\r
+  InfFileSize   Size of the contents of the InfFileImage buffer.\r
+  FvImage       Pointer to the FV image created.\r
+  FvImageSize   Size of the FV image created and pointed to by FvImage.\r
+  FvFileName    Requested name for the FV file.\r
+  SymImage      Pointer to the Sym image created.\r
+  SymImageSize  Size of the Sym image created and pointed to by SymImage.\r
+  SymFileName   Requested name for the Sym file.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS             Function completed successfully.\r
+  EFI_OUT_OF_RESOURCES    Could not allocate required resources.\r
+  EFI_ABORTED             Error encountered.\r
+  EFI_INVALID_PARAMETER   A required parameter was NULL.\r
+\r
+--*/\r
+{\r
+  EFI_STATUS                  Status;\r
+  MEMORY_FILE                 InfMemoryFile;\r
+  MEMORY_FILE                 FvImageMemoryFile;\r
+  MEMORY_FILE                 SymImageMemoryFile;\r
+  FV_INFO                     FvInfo;\r
+  UINTN                       Index;\r
+  EFI_FIRMWARE_VOLUME_HEADER  *FvHeader;\r
+  EFI_FFS_FILE_HEADER         *VtfFileImage;\r
+\r
+  //\r
+  // Check for invalid parameter\r
+  //\r
+  if (InfFileImage == NULL || FvImage == NULL || FvImageSize == NULL || FvFileName == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+  //\r
+  // Initialize file structures\r
+  //\r
+  InfMemoryFile.FileImage           = InfFileImage;\r
+  InfMemoryFile.CurrentFilePointer  = InfFileImage;\r
+  InfMemoryFile.Eof                 = InfFileImage + InfFileSize;\r
+\r
+  //\r
+  // Parse the FV inf file for header information\r
+  //\r
+  Status = ParseFvInf (&InfMemoryFile, &FvInfo);\r
+  if (EFI_ERROR (Status)) {\r
+    printf ("ERROR: Could not parse the input INF file.\n");\r
+    return EFI_ABORTED;\r
+  }\r
+  //\r
+  // Update the file name return values\r
+  //\r
+  strcpy (*FvFileName, FvInfo.FvName);\r
+  strcpy (*SymFileName, FvInfo.SymName);\r
+\r
+  //\r
+  // Calculate the FV size\r
+  //\r
+  *FvImageSize = FvInfo.Size;\r
+\r
+  //\r
+  // Allocate the FV\r
+  //\r
+  *FvImage = malloc (*FvImageSize);\r
+  if (*FvImage == NULL) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+  //\r
+  // Allocate space for symbol file storage\r
+  //\r
+  *SymImage = malloc (SYMBOL_FILE_SIZE);\r
+  if (*SymImage == NULL) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+  //\r
+  // Initialize the FV to the erase polarity\r
+  //\r
+  if (FvInfo.FvAttributes & EFI_FVB_ERASE_POLARITY) {\r
+    memset (*FvImage, -1, *FvImageSize);\r
+  } else {\r
+    memset (*FvImage, 0, *FvImageSize);\r
+  }\r
+  //\r
+  // Initialize FV header\r
+  //\r
+  FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *) *FvImage;\r
+\r
+  //\r
+  // Initialize the zero vector to all zeros.\r
+  //\r
+  memset (FvHeader->ZeroVector, 0, 16);\r
+\r
+  //\r
+  // Copy the FFS GUID\r
+  //\r
+  memcpy (&FvHeader->FileSystemGuid, &FvInfo.FvGuid, sizeof (EFI_GUID));\r
+\r
+  FvHeader->FvLength    = *FvImageSize;\r
+  FvHeader->Signature   = EFI_FVH_SIGNATURE;\r
+  FvHeader->Attributes  = FvInfo.FvAttributes;\r
+  FvHeader->Revision    = EFI_FVH_REVISION;\r
+  FvHeader->Reserved[0] = 0;\r
+  FvHeader->Reserved[1] = 0;\r
+  FvHeader->Reserved[2] = 0;\r
+\r
+  //\r
+  // Copy firmware block map\r
+  //\r
+  for (Index = 0; FvInfo.FvBlocks[Index].NumBlocks != 0; Index++) {\r
+    FvHeader->FvBlockMap[Index].NumBlocks   = FvInfo.FvBlocks[Index].NumBlocks;\r
+    FvHeader->FvBlockMap[Index].BlockLength = FvInfo.FvBlocks[Index].BlockLength;\r
+  }\r
+  //\r
+  // Add block map terminator\r
+  //\r
+  FvHeader->FvBlockMap[Index].NumBlocks   = 0;\r
+  FvHeader->FvBlockMap[Index].BlockLength = 0;\r
+\r
+  //\r
+  // Complete the header\r
+  //\r
+  FvHeader->HeaderLength  = (UINT16) (((UINTN) &(FvHeader->FvBlockMap[Index + 1])) - (UINTN) *FvImage);\r
+  FvHeader->Checksum      = 0;\r
+  FvHeader->Checksum      = CalculateChecksum16 ((UINT16 *) FvHeader, FvHeader->HeaderLength / sizeof (UINT16));\r
+\r
+  //\r
+  // If there is no FFS file, find and generate each components of the FV\r
+  //\r
+  if (FvInfo.FvFiles[0][0] == 0) {\r
+    Status = GenNonFFSFv (*FvImage, &FvInfo);\r
+    if (EFI_ERROR (Status)) {\r
+      printf ("ERROR: Could not generate NonFFS FV.\n");\r
+      free (*FvImage);\r
+      return EFI_ABORTED;\r
+    }\r
+\r
+    return EFI_SUCCESS;\r
+  }\r
+  //\r
+  // Initialize our "file" view of the buffer\r
+  //\r
+  FvImageMemoryFile.FileImage           = *FvImage;\r
+  FvImageMemoryFile.CurrentFilePointer  = *FvImage + FvHeader->HeaderLength;\r
+  FvImageMemoryFile.Eof                 = *FvImage +*FvImageSize;\r
+\r
+  //\r
+  // Initialize our "file" view of the symbol file.\r
+  //\r
+  SymImageMemoryFile.FileImage          = *SymImage;\r
+  SymImageMemoryFile.CurrentFilePointer = *SymImage;\r
+  SymImageMemoryFile.Eof                = *FvImage + SYMBOL_FILE_SIZE;\r
+\r
+  //\r
+  // Initialize the FV library.\r
+  //\r
+  InitializeFvLib (FvImageMemoryFile.FileImage, FvInfo.Size);\r
+\r
+  //\r
+  // Files start on 8 byte alignments, so move to the next 8 byte aligned\r
+  // address.  For now, just assert if it isn't.  Currently FV header is\r
+  // always a multiple of 8 bytes.\r
+  // BUGBUG: Handle this better\r
+  //\r
+  assert ((((UINTN) FvImageMemoryFile.CurrentFilePointer) % 8) == 0);\r
+\r
+  //\r
+  // Initialize the VTF file address.\r
+  //\r
+  VtfFileImage = (EFI_FFS_FILE_HEADER *) FvImageMemoryFile.Eof;\r
+\r
+  //\r
+  // Add files to FV\r
+  //\r
+  for (Index = 0; FvInfo.FvFiles[Index][0] != 0; Index++) {\r
+    //\r
+    // Add the file\r
+    //\r
+    Status = AddFile (&FvImageMemoryFile, &FvInfo, Index, &VtfFileImage, &SymImageMemoryFile);\r
+\r
+    //\r
+    // Exit if error detected while adding the file\r
+    //\r
+    if (EFI_ERROR (Status)) {\r
+      printf ("ERROR: Could not add file %s.\n", FvInfo.FvFiles[Index]);\r
+      free (*FvImage);\r
+      return EFI_ABORTED;\r
+    }\r
+  }\r
+  //\r
+  // If there is a VTF file, some special actions need to occur.\r
+  //\r
+  if ((UINTN) VtfFileImage != (UINTN) FvImageMemoryFile.Eof) {\r
+    //\r
+    // Pad from the end of the last file to the beginning of the VTF file.\r
+    //\r
+    Status = PadFvImage (&FvImageMemoryFile, VtfFileImage);\r
+    if (EFI_ERROR (Status)) {\r
+      printf ("ERROR: Could not create the pad file between the last file and the VTF file.\n");\r
+      free (*FvImage);\r
+      return EFI_ABORTED;\r
+    }\r
+    //\r
+    // Update reset vector (SALE_ENTRY for IPF)\r
+    // Now for IA32 and IA64 platform, the fv which has bsf file must have the \r
+    // EndAddress of 0xFFFFFFFF. Thus, only this type fv needs to update the   \r
+    // reset vector. If the PEI Core is found, the VTF file will probably get  \r
+    // corrupted by updating the entry point.                                  \r
+    //\r
+    if ((FvInfo.BaseAddress + FvInfo.Size) == FV_IMAGES_TOP_ADDRESS) {       \r
+      Status = UpdateResetVector (&FvImageMemoryFile, &FvInfo, VtfFileImage);\r
+      if (EFI_ERROR(Status)) {                                               \r
+        printf ("ERROR: Could not update the reset vector.\n");              \r
+        free (*FvImage);                                                     \r
+        return EFI_ABORTED;                                                  \r
+      }                                                                      \r
+    }\r
+  } \r
+  //\r
+  // Determine final Sym file size\r
+  //\r
+  *SymImageSize = SymImageMemoryFile.CurrentFilePointer - SymImageMemoryFile.FileImage;\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+UpdatePeiCoreEntryInFit (\r
+  IN FIT_TABLE     *FitTablePtr,\r
+  IN UINT64        PeiCorePhysicalAddress\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function is used to update the Pei Core address in FIT, this can be used by Sec core to pass control from\r
+  Sec to Pei Core\r
+\r
+Arguments:\r
+\r
+  FitTablePtr             - The pointer of FIT_TABLE.\r
+  PeiCorePhysicalAddress  - The address of Pei Core entry.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS             - The PEI_CORE FIT entry was updated successfully.\r
+  EFI_NOT_FOUND           - Not found the PEI_CORE FIT entry.\r
+\r
+--*/\r
+{\r
+  FIT_TABLE *TmpFitPtr;\r
+  UINTN     Index;\r
+  UINTN     NumFitComponents;\r
+\r
+  TmpFitPtr         = FitTablePtr;\r
+  NumFitComponents  = TmpFitPtr->CompSize;\r
+\r
+  for (Index = 0; Index < NumFitComponents; Index++) {\r
+    if ((TmpFitPtr->CvAndType & FIT_TYPE_MASK) == COMP_TYPE_FIT_PEICORE) {\r
+      TmpFitPtr->CompAddress = PeiCorePhysicalAddress;\r
+      return EFI_SUCCESS;\r
+    }\r
+\r
+    TmpFitPtr++;\r
+  }\r
+\r
+  return EFI_NOT_FOUND;\r
+}\r
+\r
+VOID\r
+UpdateFitCheckSum (\r
+  IN FIT_TABLE   *FitTablePtr\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function is used to update the checksum for FIT.\r
+\r
+\r
+Arguments:\r
+\r
+  FitTablePtr             - The pointer of FIT_TABLE.\r
+\r
+Returns:\r
+\r
+  None.\r
+\r
+--*/\r
+{\r
+  if ((FitTablePtr->CvAndType & CHECKSUM_BIT_MASK) >> 7) {\r
+    FitTablePtr->CheckSum = 0;\r
+    FitTablePtr->CheckSum = CalculateChecksum8 ((UINT8 *) FitTablePtr, FitTablePtr->CompSize * 16);\r
+  }\r
+}\r
diff --git a/Tools/CodeTools/Source/GenFvImage/GenFvImageLib.h b/Tools/CodeTools/Source/GenFvImage/GenFvImageLib.h
new file mode 100644 (file)
index 0000000..47a5a3b
--- /dev/null
@@ -0,0 +1,142 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+  GenFvImageLib.h\r
+\r
+Abstract:\r
+\r
+  This file contains describes the public interfaces to the GenFvImage Library.\r
+  The basic purpose of the library is to create Firmware Volume images.\r
+\r
+--*/\r
+\r
+#ifndef _EFI_GEN_FV_IMAGE_LIB_H\r
+#define _EFI_GEN_FV_IMAGE_LIB_H\r
+\r
+//\r
+// Include files\r
+//\r
+#include <Common/UefiBaseTypes.h>\r
+#include <Common/MultiPhase.h>\r
+\r
+#include "ParseInf.h"\r
+\r
+//\r
+// Following definition is used for FIT in IPF\r
+//\r
+#define COMP_TYPE_FIT_PEICORE 0x10\r
+#define COMP_TYPE_FIT_UNUSED  0x7F\r
+\r
+#define FIT_TYPE_MASK         0x7F\r
+#define CHECKSUM_BIT_MASK     0x80\r
+\r
+#pragma pack(1)\r
+\r
+typedef struct {\r
+  UINT64  CompAddress;\r
+  UINT32  CompSize;\r
+  UINT16  CompVersion;\r
+  UINT8   CvAndType;\r
+  UINT8   CheckSum;\r
+} FIT_TABLE;\r
+\r
+#pragma pack()\r
+//\r
+// Exported function prototypes\r
+//\r
+EFI_STATUS\r
+GenerateFvImage (\r
+  IN CHAR8    *InfFileImage,\r
+  IN UINTN    InfFileSize,\r
+  OUT UINT8   **FvImage,\r
+  OUT UINTN   *FvImageSize,\r
+  OUT CHAR8   **FvFileName,\r
+  OUT UINT8   **SymImage,\r
+  OUT UINTN   *SymImageSize,\r
+  OUT CHAR8   **SymFileName\r
+  )\r
+;\r
+\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This is the main function which will be called from application.\r
+\r
+Arguments:\r
+\r
+  InfFileImage  Buffer containing the INF file contents.\r
+  InfFileSize   Size of the contents of the InfFileImage buffer.\r
+  FvImage       Pointer to the FV image created.\r
+  FvImageSize   Size of the FV image created and pointed to by FvImage.\r
+  FvFileName    Requested name for the FV file.\r
+  SymImage      Pointer to the Sym image created.\r
+  SymImageSize  Size of the Sym image created and pointed to by SymImage.\r
+  SymFileName   Requested name for the Sym file.\r
+    \r
+Returns:\r
\r
+  EFI_SUCCESS             Function completed successfully.\r
+  EFI_OUT_OF_RESOURCES    Could not allocate required resources.\r
+  EFI_ABORTED             Error encountered.\r
+  EFI_INVALID_PARAMETER   A required parameter was NULL.\r
+\r
+--*/\r
+EFI_STATUS\r
+UpdatePeiCoreEntryInFit (\r
+  IN FIT_TABLE     *FitTablePtr,\r
+  IN UINT64        PeiCorePhysicalAddress\r
+  )\r
+;\r
+\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function is used to update the Pei Core address in FIT, this can be used by Sec core to pass control from\r
+  Sec to Pei Core\r
+\r
+Arguments:\r
+\r
+  FitTablePtr             - The pointer of FIT_TABLE.\r
+  PeiCorePhysicalAddress  - The address of Pei Core entry.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS             - The PEI_CORE FIT entry was updated successfully.\r
+  EFI_NOT_FOUND           - Not found the PEI_CORE FIT entry.\r
+\r
+--*/\r
+VOID\r
+UpdateFitCheckSum (\r
+  IN FIT_TABLE   *FitTablePtr\r
+  )\r
+;\r
+\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function is used to update the checksum for FIT.\r
+\r
+\r
+Arguments:\r
+\r
+  FitTablePtr             - The pointer of FIT_TABLE.\r
+\r
+Returns:\r
+\r
+  None.\r
+\r
+--*/\r
+#endif\r
diff --git a/Tools/CodeTools/Source/GenFvImage/GenFvImageLibInternal.h b/Tools/CodeTools/Source/GenFvImage/GenFvImageLibInternal.h
new file mode 100644 (file)
index 0000000..cff3b1a
--- /dev/null
@@ -0,0 +1,172 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+  GenFvImageLibInternal.h\r
+\r
+Abstract:\r
+\r
+  This file contains describes the private declarations for the GenFvImage Library.\r
+  The basic purpose of the library is to create Firmware Volume images.\r
+\r
+--*/\r
+\r
+#ifndef _EFI_GEN_FV_IMAGE_LIB_INTERNAL_H\r
+#define _EFI_GEN_FV_IMAGE_LIB_INTERNAL_H\r
+\r
+//\r
+// Include files\r
+//\r
+#include <stdlib.h>\r
+\r
+#include <Common/FirmwareVolumeHeader.h>\r
+\r
+#include "CommonLib.h"\r
+#include "GenFvImageLib.h"\r
+\r
+//\r
+// Private data declarations\r
+//\r
+//\r
+// The maximum number of block map entries supported by the library\r
+//\r
+#define MAX_NUMBER_OF_FV_BLOCKS 100\r
+\r
+//\r
+// The maximum number of files in the FV supported by the library\r
+//\r
+#define MAX_NUMBER_OF_FILES_IN_FV       1000\r
+#define MAX_NUMBER_OF_COMPONENTS_IN_FV  10\r
+\r
+//\r
+// INF file strings\r
+//\r
+#define OPTIONS_SECTION_STRING            "[options]"\r
+#define ATTRIBUTES_SECTION_STRING         "[attributes]"\r
+#define FILES_SECTION_STRING              "[files]"\r
+#define COMPONENT_SECTION_STRING          "[components]"\r
+\r
+#define EFI_FV_BASE_ADDRESS_STRING        "EFI_BASE_ADDRESS"\r
+#define EFI_FV_FILE_NAME_STRING           "EFI_FILE_NAME"\r
+#define EFI_SYM_FILE_NAME_STRING          "EFI_SYM_FILE_NAME"\r
+#define EFI_NUM_BLOCKS_STRING             "EFI_NUM_BLOCKS"\r
+#define EFI_BLOCK_SIZE_STRING             "EFI_BLOCK_SIZE"\r
+#define EFI_FV_GUID_STRING                "EFI_FV_GUID"\r
+\r
+#define EFI_FVB_READ_DISABLED_CAP_STRING  "EFI_READ_DISABLED_CAP"\r
+#define EFI_FVB_READ_ENABLED_CAP_STRING   "EFI_READ_ENABLED_CAP"\r
+#define EFI_FVB_READ_STATUS_STRING        "EFI_READ_STATUS"\r
+\r
+#define EFI_FVB_WRITE_DISABLED_CAP_STRING "EFI_WRITE_DISABLED_CAP"\r
+#define EFI_FVB_WRITE_ENABLED_CAP_STRING  "EFI_WRITE_ENABLED_CAP"\r
+#define EFI_FVB_WRITE_STATUS_STRING       "EFI_WRITE_STATUS"\r
+\r
+#define EFI_FVB_LOCK_CAP_STRING           "EFI_LOCK_CAP"\r
+#define EFI_FVB_LOCK_STATUS_STRING        "EFI_LOCK_STATUS"\r
+\r
+#define EFI_FVB_STICKY_WRITE_STRING       "EFI_STICKY_WRITE"\r
+#define EFI_FVB_MEMORY_MAPPED_STRING      "EFI_MEMORY_MAPPED"\r
+#define EFI_FVB_ERASE_POLARITY_STRING     "EFI_ERASE_POLARITY"\r
+\r
+#define EFI_FVB_ALIGNMENT_CAP_STRING      "EFI_ALIGNMENT_CAP"\r
+#define EFI_FVB_ALIGNMENT_2_STRING        "EFI_ALIGNMENT_2"\r
+#define EFI_FVB_ALIGNMENT_4_STRING        "EFI_ALIGNMENT_4"\r
+#define EFI_FVB_ALIGNMENT_8_STRING        "EFI_ALIGNMENT_8"\r
+#define EFI_FVB_ALIGNMENT_16_STRING       "EFI_ALIGNMENT_16"\r
+#define EFI_FVB_ALIGNMENT_32_STRING       "EFI_ALIGNMENT_32"\r
+#define EFI_FVB_ALIGNMENT_64_STRING       "EFI_ALIGNMENT_64"\r
+#define EFI_FVB_ALIGNMENT_128_STRING      "EFI_ALIGNMENT_128"\r
+#define EFI_FVB_ALIGNMENT_256_STRING      "EFI_ALIGNMENT_256"\r
+#define EFI_FVB_ALIGNMENT_512_STRING      "EFI_ALIGNMENT_512"\r
+#define EFI_FVB_ALIGNMENT_1K_STRING       "EFI_ALIGNMENT_1K"\r
+#define EFI_FVB_ALIGNMENT_2K_STRING       "EFI_ALIGNMENT_2K"\r
+#define EFI_FVB_ALIGNMENT_4K_STRING       "EFI_ALIGNMENT_4K"\r
+#define EFI_FVB_ALIGNMENT_8K_STRING       "EFI_ALIGNMENT_8K"\r
+#define EFI_FVB_ALIGNMENT_16K_STRING      "EFI_ALIGNMENT_16K"\r
+#define EFI_FVB_ALIGNMENT_32K_STRING      "EFI_ALIGNMENT_32K"\r
+#define EFI_FVB_ALIGNMENT_64K_STRING      "EFI_ALIGNMENT_64K"\r
+\r
+//\r
+// Component sections\r
+//\r
+#define EFI_NV_VARIABLE_STRING    "EFI_NV_VARIABLE"\r
+#define EFI_NV_EVENT_LOG_STRING   "EFI_NV_EVENT_LOG"\r
+#define EFI_NV_FTW_WORKING_STRING "EFI_NV_FTW_WORKING"\r
+#define EFI_NV_FTW_SPARE_STRING   "EFI_NV_FTW_SPARE"\r
+\r
+#define EFI_FILE_NAME_STRING      "EFI_FILE_NAME"\r
+\r
+#define ONE_STRING                "1"\r
+#define ZERO_STRING               "0"\r
+#define TRUE_STRING               "TRUE"\r
+#define FALSE_STRING              "FALSE"\r
+#define NULL_STRING               "NULL"\r
+\r
+//\r
+// Defines to calculate the offset for PEI CORE entry points\r
+//\r
+#define IA32_PEI_CORE_ENTRY_OFFSET  0x20\r
+\r
+//\r
+// Defines to calculate the FIT table\r
+//\r
+#define IPF_FIT_ADDRESS_OFFSET  0x20\r
+\r
+//\r
+// Defines to calculate the offset for SALE_ENTRY\r
+//\r
+#define IPF_SALE_ENTRY_ADDRESS_OFFSET 0x18\r
+\r
+//\r
+// Symbol file definitions, current max size if 512K\r
+//\r
+#define SYMBOL_FILE_SIZE  0x80000\r
+\r
+#define FV_IMAGES_TOP_ADDRESS             0x100000000ULL\r
+\r
+//\r
+// Private data types\r
+//\r
+//\r
+// Component information\r
+//\r
+typedef struct {\r
+  UINTN Size;\r
+  CHAR8 ComponentName[_MAX_PATH];\r
+} COMPONENT_INFO;\r
+\r
+//\r
+// FV information holder\r
+//\r
+typedef struct {\r
+  EFI_PHYSICAL_ADDRESS    BaseAddress;\r
+  EFI_GUID                FvGuid;\r
+  UINTN                   Size;\r
+  CHAR8                   FvName[_MAX_PATH];\r
+  CHAR8                   SymName[_MAX_PATH];\r
+  EFI_FV_BLOCK_MAP_ENTRY  FvBlocks[MAX_NUMBER_OF_FV_BLOCKS];\r
+  EFI_FVB_ATTRIBUTES      FvAttributes;\r
+  CHAR8                   FvFiles[MAX_NUMBER_OF_FILES_IN_FV][_MAX_PATH];\r
+  COMPONENT_INFO          FvComponents[MAX_NUMBER_OF_COMPONENTS_IN_FV];\r
+} FV_INFO;\r
+\r
+//\r
+// Private function prototypes\r
+//\r
+EFI_STATUS\r
+ParseFvInf (\r
+  IN MEMORY_FILE  *InfFile,\r
+  IN FV_INFO      *FvInfo\r
+  )\r
+;\r
+\r
+#endif\r
diff --git a/Tools/CodeTools/Source/GenFvImage/build.xml b/Tools/CodeTools/Source/GenFvImage/build.xml
new file mode 100644 (file)
index 0000000..ae930b0
--- /dev/null
@@ -0,0 +1,124 @@
+<?xml version="1.0" ?>\r
+<!--\r
+Copyright (c) 2006, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+-->\r
+<project default="GenTool" basedir=".">\r
+<!--\r
+    EDK GenFvImage Tool\r
+  Copyright (c) 2006, Intel Corporation\r
+-->\r
+  <property name="ToolName" value="GenFvImage"/>\r
+  <property name="FileSet" value="GenFvImageLib.c GenFvImageExe.c"/>\r
+\r
+  <taskdef resource="cpptasks.tasks"/>\r
+  <typedef resource="cpptasks.types"/>\r
+  <taskdef resource="net/sf/antcontrib/antlib.xml"/>\r
+\r
+  <property name="LINK_OUTPUT_TYPE" value="static"/>\r
+  <property name="BUILD_DIR" value="${PACKAGE_DIR}/${ToolName}/tmp"/>\r
+\r
+  <target name="GenTool" depends="init, Tool">\r
+    <echo message="The EDK Tool: ${ToolName} build has completed"/>\r
+  </target>\r
+\r
+  <target name="init">\r
+    <echo message="Building the EDK Tool: ${ToolName}"/>\r
+    <mkdir dir="${BUILD_DIR}"/>\r
+    <if>\r
+      <istrue value="${OSX}"/>\r
+      <then>\r
+        <property name="syslibdirs" value=""/>\r
+        <property name="syslibs" value=""/>\r
+      </then>\r
+    </if>\r
+\r
+    <if>\r
+      <istrue value="${cygwin}"/>\r
+      <then>\r
+        <property name="syslibdirs" value="${env.CYGWIN_HOME}/lib/e2fsprogs"/>\r
+        <property name="syslibs" value="uuid"/>\r
+      </then>\r
+    </if>\r
+    \r
+    <if>\r
+      <istrue value="${msft}"/>\r
+      <then>\r
+        <property name="syslibdirs" value=""/>\r
+        <property name="syslibs" value="uuid"/>\r
+      </then>\r
+    </if>\r
+    \r
+    <if>\r
+      <istrue value="${linux}"/>\r
+      <then>\r
+        <if>\r
+          <istrue value="${x86_64_linux}"/>\r
+          <then>\r
+            <property name="syslibdirs" value="/lib64"/>\r
+          </then>\r
+          <else>\r
+            <property name="syslibdirs" value="/usr/lib"/>\r
+          </else>\r
+        </if>\r
+        <property name="syslibs" value="uuid"/>\r
+      </then>\r
+    </if>\r
+    <echo message="syslibdirs set to: ${syslibdirs}"/>\r
+  </target>\r
+\r
+  <target name="Tool" depends="init, GenFvImage"/>\r
+\r
+  <target name="GenFvImage" >\r
+    <cc name="${ToolChain}" objdir="${BUILD_DIR}" \r
+        outfile="${BIN_DIR}/${ToolName}"\r
+        outtype="executable"\r
+        debug="true"\r
+        optimize="speed">\r
+      <compilerarg value="${ExtraArgus}" if="ExtraArgus" />\r
+\r
+      <defineset>\r
+        <define name="BUILDING_TOOLS"/>\r
+        <define name="TOOL_BUILD_IA32_TARGET"/>\r
+      </defineset>\r
+    \r
+      <fileset dir="${basedir}/${ToolName}" \r
+        includes="${FileSet}"/>\r
+\r
+      <includepath path="${PACKAGE_DIR}/${ToolName}"/>\r
+      <includepath path="${PACKAGE_DIR}/Include"/>\r
+      <includepath path="${PACKAGE_DIR}/Include/${HostArch}"/>\r
+      <includepath path="${PACKAGE_DIR}/Common"/>\r
+      <libset dir="${LIB_DIR}" libs="CommonTools"/>\r
+\r
+      <linkerarg value="/nodefaultlib:libc.lib" if="msft"/>\r
+      <syslibset dir="${syslibdirs}" libs="${syslibs}" if="cyglinux"/>\r
+      <syslibset libs="RpcRT4" if="msft"/>\r
+    </cc>\r
+  </target>\r
+\r
+  <target name="clean">\r
+    <echo message="Removing Intermediate Files Only"/>  \r
+    <delete>\r
+      <fileset dir="${BUILD_DIR}" includes="*.obj"/>\r
+    </delete>\r
+  </target>\r
+\r
+  <target name="cleanall">\r
+    <echo message="Removing Object Files and the Executable: ${ToolName}${ext_exe}"/>  \r
+    <delete failonerror="false" quiet="true" includeEmptyDirs="true">\r
+      <fileset dir="${BUILD_DIR}"/>\r
+      <fileset file="${BIN_DIR}/${ToolName}_Ia32${ext_exe}"/>\r
+      <fileset file="${BIN_DIR}/${ToolName}_X64${ext_exe}"/>\r
+      <fileset file="${BIN_DIR}/${ToolName}${ext_exe}"/>\r
+      <fileset file="${BIN_DIR}/${ToolName}_Ipf${ext_exe}"/>\r
+    </delete>\r
+  </target>\r
+\r
+</project>\r
diff --git a/Tools/CodeTools/Source/GenSection/GenSection.c b/Tools/CodeTools/Source/GenSection/GenSection.c
new file mode 100644 (file)
index 0000000..353b1a3
--- /dev/null
@@ -0,0 +1,938 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  GenSection.c\r
+\r
+Abstract:\r
+\r
+  Creates output file that is a properly formed section per the FV spec.\r
+\r
+--*/\r
+\r
+#include <stdio.h>\r
+#include <stdlib.h>\r
+#include <string.h>\r
+\r
+#include <Common/UefiBaseTypes.h>\r
+#include <Common/FirmwareVolumeImageFormat.h>\r
+#include <Protocol/GuidedSectionExtraction.h>\r
+\r
+#include "CommonLib.h"\r
+#include "EfiCompress.h"\r
+#include "EfiCustomizedCompress.h"\r
+#include "Crc32.h"\r
+#include "EfiUtilityMsgs.h"\r
+#include "GenSection.h"\r
+\r
+\r
+#define UTILITY_NAME            "GenSection"\r
+\r
+#define PARAMETER_NOT_SPECIFIED "Parameter not specified"\r
+#define MAXIMUM_INPUT_FILE_NUM  10\r
+\r
+char      *SectionTypeName[] = {\r
+  NULL,                                 // 0x00 - reserved\r
+  "EFI_SECTION_COMPRESSION",            // 0x01\r
+  "EFI_SECTION_GUID_DEFINED",           // 0x02\r
+  NULL,                                 // 0x03 - reserved\r
+  NULL,                                 // 0x04 - reserved\r
+  NULL,                                 // 0x05 - reserved\r
+  NULL,                                 // 0x06 - reserved\r
+  NULL,                                 // 0x07 - reserved\r
+  NULL,                                 // 0x08 - reserved\r
+  NULL,                                 // 0x09 - reserved\r
+  NULL,                                 // 0x0A - reserved\r
+  NULL,                                 // 0x0B - reserved\r
+  NULL,                                 // 0x0C - reserved\r
+  NULL,                                 // 0x0D - reserved\r
+  NULL,                                 // 0x0E - reserved\r
+  NULL,                                 // 0x0F - reserved\r
+  "EFI_SECTION_PE32",                   // 0x10\r
+  "EFI_SECTION_PIC",                    // 0x11\r
+  "EFI_SECTION_TE",                     // 0x12\r
+  "EFI_SECTION_DXE_DEPEX",              // 0x13\r
+  "EFI_SECTION_VERSION",                // 0x14\r
+  "EFI_SECTION_USER_INTERFACE",         // 0x15\r
+  "EFI_SECTION_COMPATIBILITY16",        // 0x16\r
+  "EFI_SECTION_FIRMWARE_VOLUME_IMAGE",  // 0x17\r
+  "EFI_SECTION_FREEFORM_SUBTYPE_GUID",  // 0x18\r
+  "EFI_SECTION_RAW",                    // 0x19\r
+  NULL,                                 // 0x1A\r
+  "EFI_SECTION_PEI_DEPEX"               // 0x1B\r
+};\r
+\r
+char      *CompressionTypeName[]    = { "NONE", "STANDARD" };\r
+char      *GUIDedSectionTypeName[]  = { "CRC32" };\r
+EFI_GUID  gEfiCrc32SectionGuid      = EFI_CRC32_GUIDED_SECTION_EXTRACTION_PROTOCOL_GUID;\r
+\r
+static\r
+VOID\r
+PrintUsageMessage (\r
+  VOID\r
+  )\r
+{\r
+  UINTN SectionType;\r
+  UINTN DisplayCount;\r
+\r
+  printf ("Usage: "UTILITY_NAME "  -i InputFile -o OutputFile -s SectionType [SectionType params]\n\n");\r
+  printf ("    Where SectionType is one of the following section types:\n\n");\r
+\r
+  DisplayCount = 0;\r
+  for (SectionType = 0; SectionType <= EFI_SECTION_LAST_SECTION_TYPE; SectionType++) {\r
+    if (SectionTypeName[SectionType] != NULL) {\r
+      printf ("       %s\n", SectionTypeName[SectionType]);\r
+    }\r
+  }\r
+\r
+  printf ("\n    and SectionType dependent parameters are as follows:\n\n");\r
+  printf (\r
+    "       %s:       -t < %s | %s >\n",\r
+    SectionTypeName[EFI_SECTION_COMPRESSION],\r
+    CompressionTypeName[EFI_NOT_COMPRESSED],\r
+    CompressionTypeName[EFI_STANDARD_COMPRESSION]\r
+    );\r
+  printf (\r
+    "       %s:      -t < %s >\n""                          // Currently only CRC32 is supported\n\n",\r
+    SectionTypeName[EFI_SECTION_GUID_DEFINED],\r
+    GUIDedSectionTypeName[EFI_SECTION_CRC32_GUID_DEFINED]\r
+    );\r
+  printf (\r
+    "       %s:           -v VersionNumber\n""                          [-a \"Version string\"]\n\n",\r
+    SectionTypeName[EFI_SECTION_VERSION]\r
+    );\r
+  printf (\r
+    "       %s:    -a \"Human readable name\"\n\n",\r
+    SectionTypeName[EFI_SECTION_USER_INTERFACE]\r
+    );\r
+}\r
+\r
+VOID\r
+Ascii2UnicodeWriteString (\r
+  char    *String,\r
+  FILE    *OutFile,\r
+  BOOLEAN WriteLangCode\r
+  )\r
+{\r
+  UINTN Index;\r
+  UINT8 AsciiNull;\r
+  //\r
+  // BUGBUG need to get correct language code...\r
+  //\r
+  char  *EnglishLangCode = "eng";\r
+  AsciiNull = 0;\r
+  //\r
+  // first write the language code (english only)\r
+  //\r
+  if (WriteLangCode) {\r
+    fwrite (EnglishLangCode, 1, 4, OutFile);\r
+  }\r
+  //\r
+  // Next, write out the string... Convert ASCII to Unicode in the process.\r
+  //\r
+  Index = 0;\r
+  do {\r
+    fwrite (&String[Index], 1, 1, OutFile);\r
+    fwrite (&AsciiNull, 1, 1, OutFile);\r
+  } while (String[Index++] != 0);\r
+}\r
+\r
+STATUS\r
+GenSectionCommonLeafSection (\r
+  char    **InputFileName,\r
+  int     InputFileNum,\r
+  UINTN   SectionType,\r
+  FILE    *OutFile\r
+  )\r
+/*++\r
+        \r
+Routine Description:\r
+           \r
+  Generate a leaf section of type other than EFI_SECTION_VERSION\r
+  and EFI_SECTION_USER_INTERFACE. Input file must be well formed.\r
+  The function won't validate the input file's contents. For\r
+  common leaf sections, the input file may be a binary file.\r
+  The utility will add section header to the file.\r
+            \r
+Arguments:\r
+               \r
+  InputFileName  - Name of the input file.\r
+                \r
+  InputFileNum   - Number of input files. Should be 1 for leaf section.\r
+\r
+  SectionType    - A valid section type string\r
+\r
+  OutFile        - Output file handle\r
+\r
+Returns:\r
+                       \r
+  STATUS_ERROR            - can't continue\r
+  STATUS_SUCCESS          - successful return\r
+\r
+--*/\r
+{\r
+  UINT64                    InputFileLength;\r
+  FILE                      *InFile;\r
+  UINT8                     *Buffer;\r
+  INTN                      TotalLength;\r
+  EFI_COMMON_SECTION_HEADER CommonSect;\r
+  STATUS                    Status;\r
+\r
+  if (InputFileNum > 1) {\r
+    Error (NULL, 0, 0, "invalid parameter", "more than one input file specified");\r
+    return STATUS_ERROR;\r
+  } else if (InputFileNum < 1) {\r
+    Error (NULL, 0, 0, "no input file specified", NULL);\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Open the input file\r
+  //\r
+  InFile = fopen (InputFileName[0], "rb");\r
+  if (InFile == NULL) {\r
+    Error (NULL, 0, 0, InputFileName[0], "failed to open input file");\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  Status  = STATUS_ERROR;\r
+  Buffer  = NULL;\r
+  //\r
+  // Seek to the end of the input file so we can determine its size\r
+  //\r
+  fseek (InFile, 0, SEEK_END);\r
+  fgetpos (InFile, &InputFileLength);\r
+  fseek (InFile, 0, SEEK_SET);\r
+  //\r
+  // Fill in the fields in the local section header structure\r
+  //\r
+  CommonSect.Type = (EFI_SECTION_TYPE) SectionType;\r
+  TotalLength     = sizeof (CommonSect) + (INTN) InputFileLength;\r
+  //\r
+  // Size must fit in 3 bytes\r
+  //\r
+  if (TotalLength >= 0x1000000) {\r
+    Error (NULL, 0, 0, InputFileName[0], "file size (0x%X) exceeds section size limit", TotalLength);\r
+    goto Done;\r
+  }\r
+  //\r
+  // Now copy the size into the section header and write out the section header\r
+  //\r
+  memcpy (&CommonSect.Size, &TotalLength, 3);\r
+  fwrite (&CommonSect, sizeof (CommonSect), 1, OutFile);\r
+  //\r
+  // Allocate a buffer to read in the contents of the input file. Then\r
+  // read it in as one block and write it to the output file.\r
+  //\r
+  if (InputFileLength != 0) {\r
+    Buffer = (UINT8 *) malloc ((size_t) InputFileLength);\r
+    if (Buffer == NULL) {\r
+      Error (__FILE__, __LINE__, 0, "memory allocation failure", NULL);\r
+      goto Done;\r
+    }\r
+\r
+    if (fread (Buffer, (size_t) InputFileLength, 1, InFile) != 1) {\r
+      Error (NULL, 0, 0, InputFileName[0], "failed to read contents of file");\r
+      goto Done;\r
+    }\r
+\r
+    if (fwrite (Buffer, (size_t) InputFileLength, 1, OutFile) != 1) {\r
+      Error (NULL, 0, 0, "failed to write to output file", NULL);\r
+      goto Done;\r
+    }\r
+  }\r
+\r
+  Status = STATUS_SUCCESS;\r
+Done:\r
+  fclose (InFile);\r
+  if (Buffer != NULL) {\r
+    free (Buffer);\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
+EFI_STATUS\r
+GetSectionContents (\r
+  char    **InputFileName,\r
+  int     InputFileNum,\r
+  UINT8   *FileBuffer,\r
+  UINTN   *BufferLength\r
+  )\r
+/*++\r
+        \r
+Routine Description:\r
+           \r
+  Get the contents of all section files specified in InputFileName\r
+  into FileBuffer.\r
+            \r
+Arguments:\r
+               \r
+  InputFileName  - Name of the input file.\r
+                \r
+  InputFileNum   - Number of input files. Should be at least 1.\r
+\r
+  FileBuffer     - Output buffer to contain data\r
+\r
+  BufferLength   - Actual length of the data \r
+\r
+Returns:\r
+                       \r
+  EFI_SUCCESS on successful return\r
+  EFI_INVALID_PARAMETER if InputFileNum is less than 1\r
+  EFI_ABORTED if unable to open input file.\r
+\r
+--*/\r
+{\r
+  UINTN   Size;\r
+  UINTN   FileSize;\r
+  INTN    Index;\r
+  FILE    *InFile;\r
+\r
+  if (InputFileNum < 1) {\r
+    Error (NULL, 0, 0, "must specify at least one input file", NULL);\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  Size = 0;\r
+  //\r
+  // Go through our array of file names and copy their contents\r
+  // to the output buffer.\r
+  //\r
+  for (Index = 0; Index < InputFileNum; Index++) {\r
+    InFile = fopen (InputFileName[Index], "rb");\r
+    if (InFile == NULL) {\r
+      Error (NULL, 0, 0, InputFileName[Index], "failed to open input file");\r
+      return EFI_ABORTED;\r
+    }\r
+\r
+    fseek (InFile, 0, SEEK_END);\r
+    FileSize = ftell (InFile);\r
+    fseek (InFile, 0, SEEK_SET);\r
+    //\r
+    // Now read the contents of the file into the buffer\r
+    //\r
+    if (FileSize > 0) {\r
+      if (fread (FileBuffer + Size, (size_t) FileSize, 1, InFile) != 1) {\r
+        Error (NULL, 0, 0, InputFileName[Index], "failed to read contents of input file");\r
+        fclose (InFile);\r
+        return EFI_ABORTED;\r
+      }\r
+    }\r
+\r
+    fclose (InFile);\r
+    Size += (UINTN) FileSize;\r
+    //\r
+    // make sure section ends on a DWORD boundary\r
+    //\r
+    while ((Size & 0x03) != 0) {\r
+      FileBuffer[Size] = 0;\r
+      Size++;\r
+    }\r
+  }\r
+\r
+  *BufferLength = Size;\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+GenSectionCompressionSection (\r
+  char    **InputFileName,\r
+  int     InputFileNum,\r
+  UINTN   SectionType,\r
+  UINTN   SectionSubType,\r
+  FILE    *OutFile\r
+  )\r
+/*++\r
+        \r
+Routine Description:\r
+           \r
+  Generate an encapsulating section of type EFI_SECTION_COMPRESSION\r
+  Input file must be already sectioned. The function won't validate\r
+  the input files' contents. Caller should hand in files already \r
+  with section header.\r
+            \r
+Arguments:\r
+               \r
+  InputFileName  - Name of the input file.\r
+                \r
+  InputFileNum   - Number of input files. Should be at least 1.\r
+\r
+  SectionType    - Section type to generate. Should be \r
+                   EFI_SECTION_COMPRESSION\r
+\r
+  SectionSubType - Specify the compression algorithm requested. \r
+  \r
+  OutFile        - Output file handle\r
+\r
+Returns:\r
+                       \r
+  EFI_SUCCESS           on successful return\r
+  EFI_INVALID_PARAMETER if InputFileNum is less than 1\r
+  EFI_ABORTED           if unable to open input file.\r
+  EFI_OUT_OF_RESOURCES  No resource to complete the operation.\r
+--*/\r
+{\r
+  UINTN                   TotalLength;\r
+  UINTN                   InputLength;\r
+  UINTN                   CompressedLength;\r
+  UINT8                   *FileBuffer;\r
+  UINT8                   *OutputBuffer;\r
+  EFI_STATUS              Status;\r
+  EFI_COMPRESSION_SECTION CompressionSect;\r
+  COMPRESS_FUNCTION       CompressFunction;\r
+\r
+  if (SectionType != EFI_SECTION_COMPRESSION) {\r
+    Error (NULL, 0, 0, "parameter must be EFI_SECTION_COMPRESSION", NULL);\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  InputLength       = 0;\r
+  FileBuffer        = NULL;\r
+  OutputBuffer      = NULL;\r
+  CompressedLength  = 0;\r
+  FileBuffer        = (UINT8 *) malloc ((1024 * 1024 * 4) * sizeof (UINT8));\r
+  if (FileBuffer == NULL) {\r
+    Error (__FILE__, __LINE__, 0, "application error", "failed to allocate memory");\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+  //\r
+  // read all input file contents into a buffer\r
+  //\r
+  Status = GetSectionContents (\r
+            InputFileName,\r
+            InputFileNum,\r
+            FileBuffer,\r
+            &InputLength\r
+            );\r
+  if (EFI_ERROR (Status)) {\r
+    free (FileBuffer);\r
+    return Status;\r
+  }\r
+\r
+  CompressFunction = NULL;\r
+\r
+  //\r
+  // Now data is in FileBuffer, compress the data\r
+  //\r
+  switch (SectionSubType) {\r
+  case EFI_NOT_COMPRESSED:\r
+    CompressedLength = InputLength;\r
+    break;\r
+\r
+  case EFI_STANDARD_COMPRESSION:\r
+    CompressFunction = (COMPRESS_FUNCTION) Compress;\r
+    break;\r
+\r
+  case EFI_CUSTOMIZED_COMPRESSION:\r
+    CompressFunction = (COMPRESS_FUNCTION) CustomizedCompress;\r
+    break;\r
+\r
+  default:\r
+    Error (NULL, 0, 0, "unknown compression type", NULL);\r
+    free (FileBuffer);\r
+    return EFI_ABORTED;\r
+  }\r
+\r
+  if (CompressFunction != NULL) {\r
+\r
+    Status = CompressFunction (FileBuffer, InputLength, OutputBuffer, &CompressedLength);\r
+    if (Status == EFI_BUFFER_TOO_SMALL) {\r
+      OutputBuffer = malloc (CompressedLength);\r
+      if (!OutputBuffer) {\r
+        free (FileBuffer);\r
+        return EFI_OUT_OF_RESOURCES;\r
+      }\r
+\r
+      Status = CompressFunction (FileBuffer, InputLength, OutputBuffer, &CompressedLength);\r
+    }\r
+\r
+    free (FileBuffer);\r
+    FileBuffer = OutputBuffer;\r
+\r
+    if (EFI_ERROR (Status)) {\r
+      if (FileBuffer != NULL) {\r
+        free (FileBuffer);\r
+      }\r
+\r
+      return Status;\r
+    }\r
+  }\r
+\r
+  TotalLength = CompressedLength + sizeof (EFI_COMPRESSION_SECTION);\r
+  //\r
+  // Add the section header for the compressed data\r
+  //\r
+  CompressionSect.CommonHeader.Type     = (EFI_SECTION_TYPE) SectionType;\r
+  CompressionSect.CommonHeader.Size[0]  = (UINT8) (TotalLength & 0xff);\r
+  CompressionSect.CommonHeader.Size[1]  = (UINT8) ((TotalLength & 0xff00) >> 8);\r
+  CompressionSect.CommonHeader.Size[2]  = (UINT8) ((TotalLength & 0xff0000) >> 16);\r
+  CompressionSect.CompressionType       = (UINT8) SectionSubType;\r
+  CompressionSect.UncompressedLength    = InputLength;\r
+\r
+  fwrite (&CompressionSect, sizeof (CompressionSect), 1, OutFile);\r
+  fwrite (FileBuffer, CompressedLength, 1, OutFile);\r
+  free (FileBuffer);\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+GenSectionGuidDefinedSection (\r
+  char    **InputFileName,\r
+  int     InputFileNum,\r
+  UINTN   SectionType,\r
+  UINTN   SectionSubType,\r
+  FILE    *OutFile\r
+  )\r
+/*++\r
+        \r
+Routine Description:\r
+           \r
+  Generate an encapsulating section of type EFI_SECTION_GUID_DEFINED\r
+  Input file must be already sectioned. The function won't validate\r
+  the input files' contents. Caller should hand in files already \r
+  with section header.\r
+            \r
+Arguments:\r
+               \r
+  InputFileName  - Name of the input file.\r
+                \r
+  InputFileNum   - Number of input files. Should be at least 1.\r
+\r
+  SectionType    - Section type to generate. Should be \r
+                   EFI_SECTION_GUID_DEFINED\r
+\r
+  SectionSubType - Specify the authentication algorithm requested. \r
+  \r
+  OutFile        - Output file handle\r
+\r
+Returns:\r
+                       \r
+  EFI_SUCCESS on successful return\r
+  EFI_INVALID_PARAMETER if InputFileNum is less than 1\r
+  EFI_ABORTED if unable to open input file.\r
+  EFI_OUT_OF_RESOURCES  No resource to complete the operation.\r
+\r
+--*/\r
+{\r
+  INTN                  TotalLength;\r
+  INTN                  InputLength;\r
+  UINT8                 *FileBuffer;\r
+  UINT32                Crc32Checksum;\r
+  EFI_STATUS            Status;\r
+  CRC32_SECTION_HEADER  Crc32GuidSect;\r
+\r
+  if (SectionType != EFI_SECTION_GUID_DEFINED) {\r
+    Error (NULL, 0, 0, "parameter must be EFI_SECTION_GUID_DEFINED", NULL);\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  InputLength = 0;\r
+  FileBuffer  = NULL;\r
+  FileBuffer  = (UINT8 *) malloc ((1024 * 1024 * 4) * sizeof (UINT8));\r
+  if (FileBuffer == NULL) {\r
+    Error (__FILE__, __LINE__, 0, "application error", "failed to allocate memory");\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+  //\r
+  // read all input file contents into a buffer\r
+  //\r
+  Status = GetSectionContents (\r
+            InputFileName,\r
+            InputFileNum,\r
+            FileBuffer,\r
+            &InputLength\r
+            );\r
+  if (EFI_ERROR (Status)) {\r
+    free (FileBuffer);\r
+    return Status;\r
+  }\r
+  //\r
+  // Now data is in FileBuffer, compress the data\r
+  //\r
+  switch (SectionSubType) {\r
+  case EFI_SECTION_CRC32_GUID_DEFINED:\r
+    Crc32Checksum = 0;\r
+    CalculateCrc32 (FileBuffer, InputLength, &Crc32Checksum);\r
+    if (EFI_ERROR (Status)) {\r
+      free (FileBuffer);\r
+      return Status;\r
+    }\r
+\r
+    TotalLength = InputLength + CRC32_SECTION_HEADER_SIZE;\r
+    Crc32GuidSect.GuidSectionHeader.CommonHeader.Type     = (EFI_SECTION_TYPE) SectionType;\r
+    Crc32GuidSect.GuidSectionHeader.CommonHeader.Size[0]  = (UINT8) (TotalLength & 0xff);\r
+    Crc32GuidSect.GuidSectionHeader.CommonHeader.Size[1]  = (UINT8) ((TotalLength & 0xff00) >> 8);\r
+    Crc32GuidSect.GuidSectionHeader.CommonHeader.Size[2]  = (UINT8) ((TotalLength & 0xff0000) >> 16);\r
+    memcpy (&(Crc32GuidSect.GuidSectionHeader.SectionDefinitionGuid), &gEfiCrc32SectionGuid, sizeof (EFI_GUID));\r
+    Crc32GuidSect.GuidSectionHeader.Attributes  = EFI_GUIDED_SECTION_AUTH_STATUS_VALID;\r
+    Crc32GuidSect.GuidSectionHeader.DataOffset  = CRC32_SECTION_HEADER_SIZE;\r
+    Crc32GuidSect.CRC32Checksum                 = Crc32Checksum;\r
+\r
+    break;\r
+\r
+  default:\r
+    Error (NULL, 0, 0, "invalid parameter", "unknown GUID defined type");\r
+    free (FileBuffer);\r
+    return EFI_ABORTED;\r
+  }\r
+\r
+  fwrite (&Crc32GuidSect, sizeof (Crc32GuidSect), 1, OutFile);\r
+  fwrite (FileBuffer, InputLength, 1, OutFile);\r
+\r
+  free (FileBuffer);\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+int\r
+main (\r
+  int  argc,\r
+  char *argv[]\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Main\r
+\r
+Arguments:\r
+\r
+  command line parameters\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS    Section header successfully generated and section concatenated.\r
+  EFI_ABORTED    Could not generate the section\r
+  EFI_OUT_OF_RESOURCES  No resource to complete the operation.\r
+\r
+--*/\r
+{\r
+  INTN                      Index;\r
+  INTN                      VersionNumber;\r
+  UINTN                     SectionType;\r
+  UINTN                     SectionSubType;\r
+  BOOLEAN                   InputFileRequired;\r
+  BOOLEAN                   SubTypeRequired;\r
+  FILE                      *InFile;\r
+  FILE                      *OutFile;\r
+  INTN                      InputFileNum;\r
+\r
+  char                      **InputFileName;\r
+  char                      *OutputFileName;\r
+  char                      AuxString[500] = { 0 };\r
+\r
+  char                      *ParamSectionType;\r
+  char                      *ParamSectionSubType;\r
+  char                      *ParamLength;\r
+  char                      *ParamVersion;\r
+  char                      *ParamDigitalSignature;\r
+\r
+  EFI_STATUS                Status;\r
+  EFI_COMMON_SECTION_HEADER CommonSect;\r
+\r
+  InputFileName         = NULL;\r
+  OutputFileName        = PARAMETER_NOT_SPECIFIED;\r
+  ParamSectionType      = PARAMETER_NOT_SPECIFIED;\r
+  ParamSectionSubType   = PARAMETER_NOT_SPECIFIED;\r
+  ParamLength           = PARAMETER_NOT_SPECIFIED;\r
+  ParamVersion          = PARAMETER_NOT_SPECIFIED;\r
+  ParamDigitalSignature = PARAMETER_NOT_SPECIFIED;\r
+  Status                = EFI_SUCCESS;\r
+\r
+  VersionNumber         = 0;\r
+  SectionType           = 0;\r
+  SectionSubType        = 0;\r
+  InputFileRequired     = TRUE;\r
+  SubTypeRequired       = FALSE;\r
+  InFile                = NULL;\r
+  OutFile               = NULL;\r
+  InputFileNum          = 0;\r
+  Status                = EFI_SUCCESS;\r
+\r
+  SetUtilityName (UTILITY_NAME);\r
+  if (argc == 1) {\r
+    PrintUsageMessage ();\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Parse command line\r
+  //\r
+  Index = 1;\r
+  while (Index < argc) {\r
+    if (strcmpi (argv[Index], "-i") == 0) {\r
+      //\r
+      // Input File found\r
+      //\r
+      Index++;\r
+      InputFileName = (char **) malloc (MAXIMUM_INPUT_FILE_NUM * sizeof (char *));\r
+      if (InputFileName == NULL) {\r
+        Error (__FILE__, __LINE__, 0, "application error", "failed to allocate memory");\r
+        return EFI_OUT_OF_RESOURCES;\r
+      }\r
+\r
+      memset (InputFileName, 0, (MAXIMUM_INPUT_FILE_NUM * sizeof (char *)));\r
+      InputFileName[InputFileNum] = argv[Index];\r
+      InputFileNum++;\r
+      Index++;\r
+      //\r
+      // Parse subsequent parameters until another switch is encountered\r
+      //\r
+      while ((Index < argc) && (argv[Index][0] != '-')) {\r
+        if ((InputFileNum % MAXIMUM_INPUT_FILE_NUM) == 0) {\r
+          //\r
+          // InputFileName buffer too small, need to realloc\r
+          //\r
+          InputFileName = (char **) realloc (\r
+                                      InputFileName,\r
+                                      (InputFileNum + MAXIMUM_INPUT_FILE_NUM) * sizeof (char *)\r
+                                      );\r
+          if (InputFileName == NULL) {\r
+            Error (__FILE__, __LINE__, 0, "application error", "failed to allocate memory");\r
+            return EFI_OUT_OF_RESOURCES;\r
+          }\r
+\r
+          memset (&(InputFileName[InputFileNum]), 0, (MAXIMUM_INPUT_FILE_NUM * sizeof (char *)));\r
+        }\r
+\r
+        InputFileName[InputFileNum] = argv[Index];\r
+        InputFileNum++;\r
+        Index++;\r
+      }\r
+\r
+    }\r
+\r
+    if (strcmpi (argv[Index], "-o") == 0) {\r
+      //\r
+      // Output file found\r
+      //\r
+      Index++;\r
+      OutputFileName = argv[Index];\r
+    } else if (strcmpi (argv[Index], "-s") == 0) {\r
+      //\r
+      // Section Type found\r
+      //\r
+      Index++;\r
+      ParamSectionType = argv[Index];\r
+    } else if (strcmpi (argv[Index], "-t") == 0) {\r
+      //\r
+      // Compression or Authentication type\r
+      //\r
+      Index++;\r
+      ParamSectionSubType = argv[Index];\r
+    } else if (strcmpi (argv[Index], "-l") == 0) {\r
+      //\r
+      // Length\r
+      //\r
+      Index++;\r
+      ParamLength = argv[Index];\r
+    } else if (strcmpi (argv[Index], "-v") == 0) {\r
+      //\r
+      // VersionNumber\r
+      //\r
+      Index++;\r
+      ParamVersion = argv[Index];\r
+    } else if (strcmpi (argv[Index], "-a") == 0) {\r
+      //\r
+      // Aux string\r
+      //\r
+      Index++;\r
+      //\r
+      // Note, the MSVC C-Start parses out and consolidates quoted strings from the command\r
+      // line.  Quote characters are stripped.  If this tool is ported to other environments\r
+      // this will need to be taken into account\r
+      //\r
+      strncpy (AuxString, argv[Index], 499);\r
+    } else if (strcmpi (argv[Index], "-d") == 0) {\r
+      //\r
+      // Digital signature for EFI_TEST_AUTHENTICAION (must be 0 or 1)\r
+      //\r
+      Index++;\r
+      ParamDigitalSignature = argv[Index];\r
+    } else if (strcmpi (argv[Index], "-?") == 0) {\r
+      PrintUsageMessage ();\r
+      return STATUS_ERROR;\r
+    } else {\r
+      Error (NULL, 0, 0, argv[Index], "unknown option");\r
+      return GetUtilityStatus ();\r
+    }\r
+\r
+    Index++;\r
+  }\r
+  //\r
+  // At this point, all command line parameters are verified as not being totally\r
+  // bogus.  Next verify the command line parameters are complete and make\r
+  // sense...\r
+  //\r
+  if (stricmp (ParamSectionType, SectionTypeName[EFI_SECTION_COMPRESSION]) == 0) {\r
+    SectionType     = EFI_SECTION_COMPRESSION;\r
+    SubTypeRequired = TRUE;\r
+    if (stricmp (ParamSectionSubType, CompressionTypeName[EFI_NOT_COMPRESSED]) == 0) {\r
+      SectionSubType = EFI_NOT_COMPRESSED;\r
+    } else if (stricmp (ParamSectionSubType, CompressionTypeName[EFI_STANDARD_COMPRESSION]) == 0) {\r
+      SectionSubType = EFI_STANDARD_COMPRESSION;\r
+    } else {\r
+      Error (NULL, 0, 0, ParamSectionSubType, "unknown compression type");\r
+      PrintUsageMessage ();\r
+      return GetUtilityStatus ();\r
+    }\r
+  } else if (stricmp (ParamSectionType, SectionTypeName[EFI_SECTION_GUID_DEFINED]) == 0) {\r
+    SectionType     = EFI_SECTION_GUID_DEFINED;\r
+    SubTypeRequired = TRUE;\r
+    if (stricmp (ParamSectionSubType, GUIDedSectionTypeName[EFI_SECTION_CRC32_GUID_DEFINED]) == 0) {\r
+      SectionSubType = EFI_SECTION_CRC32_GUID_DEFINED;\r
+    } else {\r
+      Error (NULL, 0, 0, ParamSectionSubType, "unknown GUID defined section type", ParamSectionSubType);\r
+      PrintUsageMessage ();\r
+      return GetUtilityStatus ();\r
+    }\r
+  } else if (stricmp (ParamSectionType, SectionTypeName[EFI_SECTION_PE32]) == 0) {\r
+    SectionType = EFI_SECTION_PE32;\r
+  } else if (stricmp (ParamSectionType, SectionTypeName[EFI_SECTION_PIC]) == 0) {\r
+    SectionType = EFI_SECTION_PIC;\r
+  } else if (stricmp (ParamSectionType, SectionTypeName[EFI_SECTION_TE]) == 0) {\r
+    SectionType = EFI_SECTION_TE;\r
+  } else if (stricmp (ParamSectionType, SectionTypeName[EFI_SECTION_DXE_DEPEX]) == 0) {\r
+    SectionType = EFI_SECTION_DXE_DEPEX;\r
+  } else if (stricmp (ParamSectionType, SectionTypeName[EFI_SECTION_VERSION]) == 0) {\r
+    SectionType       = EFI_SECTION_VERSION;\r
+    InputFileRequired = FALSE;\r
+    Index             = sscanf (ParamVersion, "%d", &VersionNumber);\r
+    if (Index != 1 || VersionNumber < 0 || VersionNumber > 65565) {\r
+      Error (NULL, 0, 0, ParamVersion, "illegal version number");\r
+      PrintUsageMessage ();\r
+      return GetUtilityStatus ();\r
+    }\r
+\r
+    if (strcmp (AuxString, PARAMETER_NOT_SPECIFIED) == 0) {\r
+      AuxString[0] = 0;\r
+    }\r
+  } else if (stricmp (ParamSectionType, SectionTypeName[EFI_SECTION_USER_INTERFACE]) == 0) {\r
+    SectionType       = EFI_SECTION_USER_INTERFACE;\r
+    InputFileRequired = FALSE;\r
+    if (strcmp (AuxString, PARAMETER_NOT_SPECIFIED) == 0) {\r
+      Error (NULL, 0, 0, "user interface string not specified", NULL);\r
+      PrintUsageMessage ();\r
+      return GetUtilityStatus ();\r
+    }\r
+  } else if (stricmp (ParamSectionType, SectionTypeName[EFI_SECTION_COMPATIBILITY16]) == 0) {\r
+    SectionType = EFI_SECTION_COMPATIBILITY16;\r
+  } else if (stricmp (ParamSectionType, SectionTypeName[EFI_SECTION_FIRMWARE_VOLUME_IMAGE]) == 0) {\r
+    SectionType = EFI_SECTION_FIRMWARE_VOLUME_IMAGE;\r
+  } else if (stricmp (ParamSectionType, SectionTypeName[EFI_SECTION_FREEFORM_SUBTYPE_GUID]) == 0) {\r
+    SectionType = EFI_SECTION_FREEFORM_SUBTYPE_GUID;\r
+  } else if (stricmp (ParamSectionType, SectionTypeName[EFI_SECTION_RAW]) == 0) {\r
+    SectionType = EFI_SECTION_RAW;\r
+  } else if (stricmp (ParamSectionType, SectionTypeName[EFI_SECTION_PEI_DEPEX]) == 0) {\r
+    SectionType = EFI_SECTION_PEI_DEPEX;\r
+  } else {\r
+    Error (NULL, 0, 0, ParamSectionType, "unknown section type");\r
+    PrintUsageMessage ();\r
+    return GetUtilityStatus ();\r
+  }\r
+  //\r
+  // Open output file\r
+  //\r
+  OutFile = fopen (OutputFileName, "wb");\r
+  if (OutFile == NULL) {\r
+    Error (NULL, 0, 0, OutputFileName, "failed to open output file for writing");\r
+    if (InFile != NULL) {\r
+      fclose (InFile);\r
+    }\r
+\r
+    return GetUtilityStatus ();\r
+  }\r
+  //\r
+  // At this point, we've fully validated the command line, and opened appropriate\r
+  // files, so let's go and do what we've been asked to do...\r
+  //\r
+  //\r
+  // Within this switch, build and write out the section header including any\r
+  // section type specific pieces.  If there's an input file, it's tacked on later\r
+  //\r
+  switch (SectionType) {\r
+  case EFI_SECTION_COMPRESSION:\r
+    Status = GenSectionCompressionSection (\r
+              InputFileName,\r
+              InputFileNum,\r
+              SectionType,\r
+              SectionSubType,\r
+              OutFile\r
+              );\r
+    break;\r
+\r
+  case EFI_SECTION_GUID_DEFINED:\r
+    Status = GenSectionGuidDefinedSection (\r
+              InputFileName,\r
+              InputFileNum,\r
+              SectionType,\r
+              SectionSubType,\r
+              OutFile\r
+              );\r
+    break;\r
+\r
+  case EFI_SECTION_VERSION:\r
+    CommonSect.Type = (EFI_SECTION_TYPE) SectionType;\r
+\r
+    Index           = sizeof (CommonSect);\r
+    //\r
+    // 2 characters for the build number\r
+    //\r
+    Index += 2;\r
+    //\r
+    // Aux string is ascii.. unicode is 2X + 2 bytes for terminating unicode null.\r
+    //\r
+    Index += (strlen (AuxString) * 2) + 2;\r
+    memcpy (&CommonSect.Size, &Index, 3);\r
+    fwrite (&CommonSect, sizeof (CommonSect), 1, OutFile);\r
+    fwrite (&VersionNumber, 2, 1, OutFile);\r
+    Ascii2UnicodeWriteString (AuxString, OutFile, FALSE);\r
+    break;\r
+\r
+  case EFI_SECTION_USER_INTERFACE:\r
+    CommonSect.Type = (EFI_SECTION_TYPE) SectionType;\r
+    Index           = sizeof (CommonSect);\r
+    //\r
+    // Aux string is ascii.. unicode is 2X + 2 bytes for terminating unicode null.\r
+    //\r
+    Index += (strlen (AuxString) * 2) + 2;\r
+    memcpy (&CommonSect.Size, &Index, 3);\r
+    fwrite (&CommonSect, sizeof (CommonSect), 1, OutFile);\r
+    Ascii2UnicodeWriteString (AuxString, OutFile, FALSE);\r
+    break;\r
+\r
+  default:\r
+    //\r
+    // All other section types are caught by default (they're all the same)\r
+    //\r
+    Status = GenSectionCommonLeafSection (\r
+              InputFileName,\r
+              InputFileNum,\r
+              SectionType,\r
+              OutFile\r
+              );\r
+    break;\r
+  }\r
+\r
+  if (InputFileName != NULL) {\r
+    free (InputFileName);\r
+  }\r
+\r
+  fclose (OutFile);\r
+  //\r
+  // If we had errors, then delete the output file\r
+  //\r
+  if (GetUtilityStatus () == STATUS_ERROR) {\r
+    remove (OutputFileName);\r
+  }\r
+\r
+  return GetUtilityStatus ();\r
+}\r
diff --git a/Tools/CodeTools/Source/GenSection/GenSection.h b/Tools/CodeTools/Source/GenSection/GenSection.h
new file mode 100644 (file)
index 0000000..3606463
--- /dev/null
@@ -0,0 +1,42 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  GenSection.h \r
+\r
+Abstract:\r
+\r
+  Header file for GenSection.\r
+\r
+--*/\r
+\r
+//\r
+// Module Coded to Tiano Coding Conventions\r
+//\r
+#ifndef _EFI_GEN_SECTION_H\r
+#define _EFI_GEN_SECTION_H\r
+\r
+//\r
+// External Files Referenced\r
+//\r
+#include <Common/UefiBaseTypes.h>\r
+#include <Common/FirmwareVolumeImageFormat.h>\r
+\r
+typedef struct {\r
+  EFI_GUID_DEFINED_SECTION  GuidSectionHeader;\r
+  UINT32                    CRC32Checksum;\r
+} CRC32_SECTION_HEADER;\r
+\r
+#define EFI_SECTION_CRC32_GUID_DEFINED  0\r
+#define CRC32_SECTION_HEADER_SIZE       (sizeof (CRC32_SECTION_HEADER))\r
+\r
+#endif\r
diff --git a/Tools/CodeTools/Source/GenSection/build.xml b/Tools/CodeTools/Source/GenSection/build.xml
new file mode 100644 (file)
index 0000000..63ffccd
--- /dev/null
@@ -0,0 +1,71 @@
+<?xml version="1.0" ?>\r
+<!--\r
+Copyright (c) 2006, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+-->\r
+<project default="GenTool" basedir=".">\r
+<!--\r
+    EDK GenSection Tool\r
+  Copyright (c) 2006, Intel Corporation\r
+-->\r
+  <property name="ToolName" value="GenSection"/>\r
+  <property name="FileSet" value="GenSection.c"/>\r
+\r
+  <taskdef resource="cpptasks.tasks"/>\r
+  <typedef resource="cpptasks.types"/>\r
+  <taskdef resource="net/sf/antcontrib/antlib.xml"/>\r
+\r
+  <property name="LINK_OUTPUT_TYPE" value="static"/>\r
+  <property name="BUILD_DIR" value="${PACKAGE_DIR}/${ToolName}/tmp"/>\r
+\r
+  <target name="GenTool" depends="init, Tool">\r
+    <echo message="The EDK Tool: ${ToolName} build has completed!"/>\r
+  </target>\r
+\r
+  <target name="init">\r
+    <echo message="Building the EDK Tool: ${ToolName}"/>\r
+    <mkdir dir="${BUILD_DIR}"/>\r
+  </target>\r
+\r
+  <target name="Tool" depends="init">\r
+    <cc name="${ToolChain}" objdir="${BUILD_DIR}" \r
+        outfile="${BIN_DIR}/${ToolName}"\r
+        outtype="executable"\r
+        debug="true"\r
+        optimize="speed">\r
+      <compilerarg value="${ExtraArgus}" if="ExtraArgus" />\r
+\r
+      <fileset dir="${basedir}/${ToolName}" \r
+        includes="${FileSet}" \r
+        defaultexcludes="TRUE" \r
+        excludes="*.xml *.inf"/>\r
+\r
+      <includepath path="${PACKAGE_DIR}/Include"/>\r
+      <includepath path="${PACKAGE_DIR}/Include/${HostArch}"/>\r
+      <includepath path="${PACKAGE_DIR}/Common"/>\r
+      <libset dir="${LIB_DIR}" libs="CommonTools CustomizedCompress"/>\r
+    </cc>\r
+  </target>\r
+\r
+  <target name="clean">\r
+    <echo message="Removing Intermediate Files Only"/>  \r
+    <delete>\r
+      <fileset dir="${BUILD_DIR}" includes="*.obj"/>\r
+    </delete>\r
+  </target>\r
+\r
+  <target name="cleanall">\r
+    <echo message="Removing Object Files and the Executable: ${ToolName}${ext_exe}"/>  \r
+    <delete failonerror="false" quiet="true" includeEmptyDirs="true">\r
+      <fileset dir="${BUILD_DIR}"/>\r
+      <fileset file="${BIN_DIR}/${ToolName}${ext_exe}"/>\r
+    </delete>\r
+  </target>\r
+\r
+</project>\r
diff --git a/Tools/CodeTools/Source/GenTEImage/GenTEImage.c b/Tools/CodeTools/Source/GenTEImage/GenTEImage.c
new file mode 100644 (file)
index 0000000..90f3b39
--- /dev/null
@@ -0,0 +1,916 @@
+/*++\r
+\r
+Copyright (c)  1999-2006 Intel Corporation. All rights reserved\r
+This program and the accompanying materials are licensed and made available \r
+under the terms and conditions of the BSD License which accompanies this \r
+distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+Module Name:\r
+\r
+  GenTEImage.c\r
+  \r
+Abstract:\r
+\r
+  Utility program to shrink a PE32 image down by replacing\r
+  the DOS, PE, and optional headers with a minimal header.\r
+\r
+--*/\r
+\r
+#include <stdio.h>\r
+#include <string.h>\r
+#include <stdlib.h>\r
+\r
+#include <Common/UefiBaseTypes.h>\r
+#include <Common/EfiImage.h> // for PE32 structure definitions\r
+\r
+#include "CommonLib.h"\r
+#include "EfiUtilityMsgs.h"\r
+\r
+//\r
+// Version of this utility\r
+//\r
+#define UTILITY_NAME    "GenTEImage"\r
+#define UTILITY_VERSION "v0.11"\r
+\r
+//\r
+// Define the max length of a filename\r
+//\r
+#define MAX_PATH                  256\r
+#define DEFAULT_OUTPUT_EXTENSION  ".te"\r
+\r
+//\r
+// Use this to track our command-line options and globals\r
+//\r
+struct {\r
+  INT8  OutFileName[MAX_PATH];\r
+  INT8  InFileName[MAX_PATH];\r
+  INT8  Verbose;\r
+  INT8  Dump;\r
+} mOptions;\r
+\r
+//\r
+// Use these to convert from machine type value to a named type\r
+//\r
+typedef struct {\r
+  UINT16  Value;\r
+  INT8    *Name;\r
+} STRING_LOOKUP;\r
+\r
+static STRING_LOOKUP  mMachineTypes[] = {\r
+  EFI_IMAGE_MACHINE_IA32,\r
+  "IA32",\r
+  EFI_IMAGE_MACHINE_IA64,\r
+  "IA64",\r
+  EFI_IMAGE_MACHINE_EBC,\r
+  "EBC",\r
+  0,\r
+  NULL\r
+};\r
+\r
+static STRING_LOOKUP  mSubsystemTypes[] = {\r
+  EFI_IMAGE_SUBSYSTEM_EFI_APPLICATION,\r
+  "EFI application",\r
+  EFI_IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER,\r
+  "EFI boot service driver",\r
+  EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER,\r
+  "EFI runtime driver",\r
+  0,\r
+  NULL\r
+};\r
+//\r
+//  Function prototypes\r
+//\r
+static\r
+void\r
+Usage (\r
+  VOID\r
+  );\r
+\r
+static\r
+STATUS\r
+ParseCommandLine (\r
+  int       Argc,\r
+  char      *Argv[]\r
+  );\r
+\r
+static\r
+STATUS\r
+CheckPE32File (\r
+  INT8      *FileName,\r
+  FILE      *Fptr,\r
+  UINT16    *MachineType,\r
+  UINT16    *SubSystem\r
+  );\r
+\r
+static\r
+STATUS\r
+ProcessFile (\r
+  INT8      *InFileName,\r
+  INT8      *OutFileName\r
+  );\r
+\r
+static\r
+void\r
+DumpImage (\r
+  INT8      *FileName\r
+  );\r
+\r
+static\r
+INT8                  *\r
+GetMachineTypeStr (\r
+  UINT16    MachineType\r
+  );\r
+\r
+static\r
+INT8                  *\r
+GetSubsystemTypeStr (\r
+  UINT16  SubsystemType\r
+  );\r
+\r
+main (\r
+  int   Argc,\r
+  char  *Argv[]\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+\r
+Arguments:\r
+\r
+  Argc            - standard C main() argument count\r
+\r
+  Argv            - standard C main() argument list\r
+\r
+Returns:\r
+\r
+  0             success\r
+  non-zero      otherwise\r
+\r
+--*/\r
+// GC_TODO:    ] - add argument and description to function comment\r
+{\r
+  INT8    *Ext;\r
+  UINT32  Status;\r
+\r
+  SetUtilityName (UTILITY_NAME);\r
+  //\r
+  // Parse the command line arguments\r
+  //\r
+  if (ParseCommandLine (Argc, Argv)) {\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // If dumping an image, then do that and quit\r
+  //\r
+  if (mOptions.Dump) {\r
+    DumpImage (mOptions.InFileName);\r
+    goto Finish;\r
+  }\r
+  //\r
+  // Determine the output filename. Either what they specified on\r
+  // the command line, or the first input filename with a different extension.\r
+  //\r
+  if (!mOptions.OutFileName[0]) {\r
+    strcpy (mOptions.OutFileName, mOptions.InFileName);\r
+    //\r
+    // Find the last . on the line and replace the filename extension with\r
+    // the default\r
+    //\r
+    for (Ext = mOptions.OutFileName + strlen (mOptions.OutFileName) - 1;\r
+         (Ext >= mOptions.OutFileName) && (*Ext != '.') && (*Ext != '\\');\r
+         Ext--\r
+        )\r
+      ;\r
+    //\r
+    // If dot here, then insert extension here, otherwise append\r
+    //\r
+    if (*Ext != '.') {\r
+      Ext = mOptions.OutFileName + strlen (mOptions.OutFileName);\r
+    }\r
+\r
+    strcpy (Ext, DEFAULT_OUTPUT_EXTENSION);\r
+  }\r
+  //\r
+  // Make sure we don't have the same filename for input and output files\r
+  //\r
+  if (stricmp (mOptions.OutFileName, mOptions.InFileName) == 0) {\r
+    Error (NULL, 0, 0, mOptions.OutFileName, "input and output file names must be different");\r
+    goto Finish;\r
+  }\r
+  //\r
+  // Process the file\r
+  //\r
+  ProcessFile (mOptions.InFileName, mOptions.OutFileName);\r
+Finish:\r
+  Status = GetUtilityStatus ();\r
+  return Status;\r
+}\r
+\r
+static\r
+STATUS\r
+ProcessFile (\r
+  INT8      *InFileName,\r
+  INT8      *OutFileName\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  Process a PE32 EFI file.\r
+\r
+Arguments:\r
+  \r
+  InFileName      - the file name pointer to the input file\r
+  OutFileName     - the file name pointer to the output file\r
+\r
+Returns:\r
+\r
+  STATUS_SUCCESS  - the process has been finished successfully\r
+  STATUS_ERROR    - error occured during the processing\r
+\r
+--*/\r
+{\r
+  STATUS                      Status;\r
+  FILE                        *InFptr;\r
+  FILE                        *OutFptr;\r
+  UINT16                      MachineType;\r
+  UINT16                      SubSystem;\r
+  EFI_TE_IMAGE_HEADER         TEImageHeader;\r
+  UINT32                      PESigOffset;\r
+  EFI_IMAGE_FILE_HEADER       FileHeader;\r
+  EFI_IMAGE_OPTIONAL_HEADER32 OptionalHeader32;\r
+  EFI_IMAGE_OPTIONAL_HEADER64 OptionalHeader64;\r
+  UINT32                      BytesStripped;\r
+  UINT32                      FileSize;\r
+  UINT8                       *Buffer;\r
+  long                        SaveFilePosition;\r
+\r
+  InFptr  = NULL;\r
+  OutFptr = NULL;\r
+  Buffer  = NULL;\r
+  Status  = STATUS_ERROR;\r
+\r
+  //\r
+  // Try to open the input file\r
+  //\r
+  if ((InFptr = fopen (InFileName, "rb")) == NULL) {\r
+    Error (NULL, 0, 0, InFileName, "failed to open input file for reading");\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Double-check the file to make sure it's what we expect it to be\r
+  //\r
+  if (CheckPE32File (InFileName, InFptr, &MachineType, &SubSystem) != STATUS_SUCCESS) {\r
+    goto Finish;\r
+  }\r
+  //\r
+  // Initialize our new header\r
+  //\r
+  memset (&TEImageHeader, 0, sizeof (EFI_TE_IMAGE_HEADER));\r
+\r
+  //\r
+  // Seek to the end to get the file size\r
+  //\r
+  fseek (InFptr, 0, SEEK_END);\r
+  FileSize = ftell (InFptr);\r
+  fseek (InFptr, 0, SEEK_SET);\r
+\r
+  //\r
+  // Per the PE/COFF specification, at offset 0x3C in the file is a 32-bit\r
+  // offset (from the start of the file) to the PE signature, which always\r
+  // follows the MSDOS stub. The PE signature is immediately followed by the\r
+  // COFF file header.\r
+  //\r
+  //\r
+  if (fseek (InFptr, 0x3C, SEEK_SET) != 0) {\r
+    Error (NULL, 0, 0, InFileName, "failed to seek to PE signature in file", NULL);\r
+    goto Finish;\r
+  }\r
+\r
+  if (fread (&PESigOffset, sizeof (PESigOffset), 1, InFptr) != 1) {\r
+    Error (NULL, 0, 0, InFileName, "failed to read PE signature offset from file");\r
+    goto Finish;\r
+  }\r
+\r
+  if (fseek (InFptr, PESigOffset + 4, SEEK_SET) != 0) {\r
+    Error (NULL, 0, 0, InFileName, "failed to seek to PE signature");\r
+    goto Finish;\r
+  }\r
+  //\r
+  // We should now be at the COFF file header. Read it in and verify it's\r
+  // of an image type we support.\r
+  //\r
+  if (fread (&FileHeader, sizeof (EFI_IMAGE_FILE_HEADER), 1, InFptr) != 1) {\r
+    Error (NULL, 0, 0, InFileName, "failed to read file header from image");\r
+    goto Finish;\r
+  }\r
+\r
+  if ((FileHeader.Machine != EFI_IMAGE_MACHINE_IA32) && (FileHeader.Machine != EFI_IMAGE_MACHINE_IA64)) {\r
+    Error (NULL, 0, 0, InFileName, "image is of an unsupported machine type 0x%X", (UINT32) FileHeader.Machine);\r
+    goto Finish;\r
+  }\r
+  //\r
+  // Calculate the total number of bytes we're going to strip off. The '4' is for the\r
+  // PE signature PE\0\0. Then sanity check the size.\r
+  //\r
+  BytesStripped = PESigOffset + 4 + sizeof (EFI_IMAGE_FILE_HEADER) + FileHeader.SizeOfOptionalHeader;\r
+  if (BytesStripped >= FileSize) {\r
+    Error (NULL, 0, 0, InFileName, "attempt to strip more bytes than the total file size");\r
+    goto Finish;\r
+  }\r
+\r
+  if (BytesStripped &~0xFFFF) {\r
+    Error (NULL, 0, 0, InFileName, "attempt to strip more than 64K bytes", NULL);\r
+    goto Finish;\r
+  }\r
+\r
+  TEImageHeader.StrippedSize = (UINT16) BytesStripped;\r
+\r
+  //\r
+  // Read in the optional header. Assume PE32, and if not, then re-read as PE32+\r
+  //\r
+  SaveFilePosition = ftell (InFptr);\r
+  if (fread (&OptionalHeader32, sizeof (EFI_IMAGE_OPTIONAL_HEADER32), 1, InFptr) != 1) {\r
+    Error (NULL, 0, 0, InFileName, "failed to read optional header from input file");\r
+    goto Finish;\r
+  }\r
+\r
+  if (OptionalHeader32.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {\r
+    //\r
+    // Fill in our new header with required data directory entries\r
+    //\r
+    TEImageHeader.AddressOfEntryPoint = OptionalHeader32.AddressOfEntryPoint;\r
+    //\r
+    // - BytesStripped + sizeof (EFI_TE_IMAGE_HEADER);\r
+    //\r
+    // We're going to pack the subsystem into 1 byte. Make sure it fits\r
+    //\r
+    if (OptionalHeader32.Subsystem &~0xFF) {\r
+      Error (\r
+        NULL,\r
+        0,\r
+        0,\r
+        InFileName,\r
+        NULL,\r
+        "image subsystem 0x%X cannot be packed into 1 byte",\r
+        (UINT32) OptionalHeader32.Subsystem\r
+        );\r
+      goto Finish;\r
+    }\r
+\r
+    TEImageHeader.Subsystem   = (UINT8) OptionalHeader32.Subsystem;\r
+    TEImageHeader.BaseOfCode  = OptionalHeader32.BaseOfCode;\r
+    TEImageHeader.ImageBase = (UINT64) (OptionalHeader32.ImageBase + TEImageHeader.StrippedSize - sizeof (EFI_TE_IMAGE_HEADER));\r
+    if (OptionalHeader32.NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC) {\r
+      TEImageHeader.DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_BASERELOC].VirtualAddress = OptionalHeader32.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC].VirtualAddress;\r
+      TEImageHeader.DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_BASERELOC].Size = OptionalHeader32.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC].Size;\r
+    }\r
+\r
+    if (OptionalHeader32.NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_DEBUG) {\r
+      TEImageHeader.DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG].VirtualAddress = OptionalHeader32.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG].VirtualAddress;\r
+      TEImageHeader.DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG].Size = OptionalHeader32.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG].Size;\r
+    }\r
+  } else if (OptionalHeader32.Magic == EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC) {\r
+    //\r
+    // Rewind and re-read the optional header\r
+    //\r
+    fseek (InFptr, SaveFilePosition, SEEK_SET);\r
+    if (fread (&OptionalHeader64, sizeof (EFI_IMAGE_OPTIONAL_HEADER64), 1, InFptr) != 1) {\r
+      Error (NULL, 0, 0, InFileName, "failed to re-read optional header from input file");\r
+      goto Finish;\r
+    }\r
+\r
+    TEImageHeader.AddressOfEntryPoint = OptionalHeader64.AddressOfEntryPoint;\r
+    //\r
+    // - BytesStripped + sizeof (EFI_TE_IMAGE_HEADER);\r
+    //\r
+    // We're going to pack the subsystem into 1 byte. Make sure it fits\r
+    //\r
+    if (OptionalHeader64.Subsystem &~0xFF) {\r
+      Error (\r
+        NULL,\r
+        0,\r
+        0,\r
+        InFileName,\r
+        NULL,\r
+        "image subsystem 0x%X cannot be packed into 1 byte",\r
+        (UINT32) OptionalHeader64.Subsystem\r
+        );\r
+      goto Finish;\r
+    }\r
+\r
+    TEImageHeader.Subsystem   = (UINT8) OptionalHeader64.Subsystem;\r
+    TEImageHeader.BaseOfCode  = OptionalHeader32.BaseOfCode;\r
+    TEImageHeader.ImageBase = (UINT64) (OptionalHeader64.ImageBase + TEImageHeader.StrippedSize - sizeof (EFI_TE_IMAGE_HEADER));\r
+    if (OptionalHeader64.NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC) {\r
+      TEImageHeader.DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_BASERELOC].VirtualAddress = OptionalHeader64.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC].VirtualAddress;\r
+      TEImageHeader.DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_BASERELOC].Size = OptionalHeader64.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC].Size;\r
+    }\r
+\r
+    if (OptionalHeader64.NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_DEBUG) {\r
+      TEImageHeader.DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG].VirtualAddress = OptionalHeader64.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG].VirtualAddress;\r
+      TEImageHeader.DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG].Size = OptionalHeader64.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG].Size;\r
+    }\r
+  } else {\r
+    Error (\r
+      NULL,\r
+      0,\r
+      0,\r
+      InFileName,\r
+      "unsupported magic number 0x%X found in optional header",\r
+      (UINT32) OptionalHeader32.Magic\r
+      );\r
+    goto Finish;\r
+  }\r
+  //\r
+  // Fill in the remainder of our new image header\r
+  //\r
+  TEImageHeader.Signature = EFI_TE_IMAGE_HEADER_SIGNATURE;\r
+  TEImageHeader.Machine   = FileHeader.Machine;\r
+  //\r
+  // We're going to pack the number of sections into a single byte. Make sure it fits.\r
+  //\r
+  if (FileHeader.NumberOfSections &~0xFF) {\r
+    Error (\r
+      NULL,\r
+      0,\r
+      0,\r
+      InFileName,\r
+      NULL,\r
+      "image's number of sections 0x%X cannot be packed into 1 byte",\r
+      (UINT32) FileHeader.NumberOfSections\r
+      );\r
+    goto Finish;\r
+  }\r
+\r
+  TEImageHeader.NumberOfSections = (UINT8) FileHeader.NumberOfSections;\r
+\r
+  //\r
+  // Now open our output file\r
+  //\r
+  if ((OutFptr = fopen (OutFileName, "wb")) == NULL) {\r
+    Error (NULL, 0, 0, OutFileName, "failed to open output file for writing");\r
+    goto Finish;\r
+  }\r
+  //\r
+  // Write the TE header\r
+  //\r
+  if (fwrite (&TEImageHeader, sizeof (EFI_TE_IMAGE_HEADER), 1, OutFptr) != 1) {\r
+    Error (NULL, 0, 0, "failed to write image header to output file", NULL);\r
+    goto Finish;\r
+  }\r
+  //\r
+  // Position into the input file, read the part we're not stripping, and\r
+  // write it out.\r
+  //\r
+  fseek (InFptr, BytesStripped, SEEK_SET);\r
+  Buffer = (UINT8 *) malloc (FileSize - BytesStripped);\r
+  if (Buffer == NULL) {\r
+    Error (NULL, 0, 0, "application error", "failed to allocate memory");\r
+    goto Finish;\r
+  }\r
+\r
+  if (fread (Buffer, FileSize - BytesStripped, 1, InFptr) != 1) {\r
+    Error (NULL, 0, 0, InFileName, "failed to read remaining contents of input file");\r
+    goto Finish;\r
+  }\r
+\r
+  if (fwrite (Buffer, FileSize - BytesStripped, 1, OutFptr) != 1) {\r
+    Error (NULL, 0, 0, OutFileName, "failed to write all bytes to output file");\r
+    goto Finish;\r
+  }\r
+\r
+  Status = STATUS_SUCCESS;\r
+\r
+Finish:\r
+  if (InFptr != NULL) {\r
+    fclose (InFptr);\r
+  }\r
+  //\r
+  // Close the output file. If there was an error, delete the output file so\r
+  // that a subsequent build will rebuild it.\r
+  //\r
+  if (OutFptr != NULL) {\r
+    fclose (OutFptr);\r
+    if (GetUtilityStatus () == STATUS_ERROR) {\r
+      remove (OutFileName);\r
+    }\r
+  }\r
+\r
+  //\r
+  // Free up our buffer\r
+  //\r
+  if (Buffer != NULL) {\r
+    free (Buffer);\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
+static\r
+STATUS\r
+CheckPE32File (\r
+  INT8      *FileName,\r
+  FILE      *Fptr,\r
+  UINT16    *MachineType,\r
+  UINT16    *SubSystem\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  FileName    - GC_TODO: add argument description\r
+  Fptr        - GC_TODO: add argument description\r
+  MachineType - GC_TODO: add argument description\r
+  SubSystem   - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+{\r
+  /*++\r
+\r
+Routine Description:\r
+  \r
+  Given a file pointer to a supposed PE32 image file, verify that it is indeed a\r
+  PE32 image file, and then return the machine type in the supplied pointer.\r
+\r
+Arguments:\r
+\r
+  Fptr          File pointer to the already-opened PE32 file\r
+  MachineType   Location to stuff the machine type of the PE32 file. This is needed\r
+                because the image may be Itanium-based, IA32, or EBC.\r
+\r
+Returns:\r
+\r
+  0             success\r
+  non-zero      otherwise\r
+\r
+--*/\r
+  EFI_IMAGE_DOS_HEADER      DosHeader;\r
+  EFI_IMAGE_FILE_HEADER     FileHdr;\r
+  EFI_IMAGE_OPTIONAL_HEADER OptionalHdr;\r
+  UINT32                    PESig;\r
+  STATUS                    Status;\r
+\r
+  Status = STATUS_ERROR;\r
+  //\r
+  // Position to the start of the file\r
+  //\r
+  fseek (Fptr, 0, SEEK_SET);\r
+  //\r
+  // Read the DOS header\r
+  //\r
+  if (fread (&DosHeader, sizeof (DosHeader), 1, Fptr) != 1) {\r
+    Error (NULL, 0, 0, FileName, "failed to read the DOS stub from the input file");\r
+    goto Finish;\r
+  }\r
+  //\r
+  // Check the magic number (0x5A4D)\r
+  //\r
+  if (DosHeader.e_magic != EFI_IMAGE_DOS_SIGNATURE) {\r
+    Error (NULL, 0, 0, FileName, "input file does not appear to be a PE32 image (magic number)");\r
+    goto Finish;\r
+  }\r
+  //\r
+  // Position into the file and check the PE signature\r
+  //\r
+  fseek (Fptr, (long) DosHeader.e_lfanew, SEEK_SET);\r
+  if (fread (&PESig, sizeof (PESig), 1, Fptr) != 1) {\r
+    Error (NULL, 0, 0, FileName, "failed to read PE signature bytes");\r
+    goto Finish;\r
+  }\r
+  //\r
+  // Check the PE signature in the header "PE\0\0"\r
+  //\r
+  if (PESig != EFI_IMAGE_NT_SIGNATURE) {\r
+    Error (NULL, 0, 0, FileName, "file does not appear to be a PE32 image (signature)");\r
+    goto Finish;\r
+  }\r
+  //\r
+  // Read the file header\r
+  //\r
+  if (fread (&FileHdr, sizeof (FileHdr), 1, Fptr) != 1) {\r
+    Error (NULL, 0, 0, FileName, "failed to read PE file header from input file");\r
+    goto Finish;\r
+  }\r
+  //\r
+  // Read the optional header so we can get the subsystem\r
+  //\r
+  if (fread (&OptionalHdr, sizeof (OptionalHdr), 1, Fptr) != 1) {\r
+    Error (NULL, 0, 0, FileName, "failed to read COFF optional header from input file");\r
+    goto Finish;\r
+  }\r
+\r
+  *SubSystem = OptionalHdr.Subsystem;\r
+  if (mOptions.Verbose) {\r
+    fprintf (stdout, "  Got subsystem = 0x%X from image\n", (int) *SubSystem);\r
+  }\r
+  //\r
+  // Good to go\r
+  //\r
+  Status = STATUS_SUCCESS;\r
+Finish:\r
+  fseek (Fptr, 0, SEEK_SET);\r
+  return Status;\r
+}\r
+\r
+static\r
+int\r
+ParseCommandLine (\r
+  int         Argc,\r
+  char        *Argv[]\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  Given the Argc/Argv program arguments, and a pointer to an options structure,\r
+  parse the command-line options and check their validity.\r
+\r
+\r
+Arguments:\r
+\r
+  Argc            - standard C main() argument count\r
+  Argv            - standard C main() argument list\r
+\r
+Returns:\r
+\r
+  STATUS_SUCCESS    success\r
+  non-zero          otherwise\r
+\r
+--*/\r
+// GC_TODO:    ] - add argument and description to function comment\r
+{\r
+  //\r
+  // Clear out the options\r
+  //\r
+  memset ((char *) &mOptions, 0, sizeof (mOptions));\r
+  //\r
+  // Skip over the program name\r
+  //\r
+  Argc--;\r
+  Argv++;\r
+  //\r
+  // If no arguments, assume they want usage info\r
+  //\r
+  if (Argc == 0) {\r
+    Usage ();\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Process until no more arguments\r
+  //\r
+  while ((Argc > 0) && (Argv[0][0] == '-')) {\r
+    if (stricmp (Argv[0], "-o") == 0) {\r
+      //\r
+      // Output filename specified with -o\r
+      // Make sure there's another parameter\r
+      //\r
+      if (Argc > 1) {\r
+        strcpy (mOptions.OutFileName, Argv[1]);\r
+      } else {\r
+        Error (NULL, 0, 0, Argv[0], "missing output file name with option");\r
+        Usage ();\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      Argv++;\r
+      Argc--;\r
+    } else if ((stricmp (Argv[0], "-h") == 0) || (strcmp (Argv[0], "-?") == 0)) {\r
+      //\r
+      // Help option\r
+      //\r
+      Usage ();\r
+      return STATUS_ERROR;\r
+    } else if (stricmp (Argv[0], "-v") == 0) {\r
+      //\r
+      // -v for verbose\r
+      //\r
+      mOptions.Verbose = 1;\r
+    } else if (stricmp (Argv[0], "-dump") == 0) {\r
+      //\r
+      // -dump for dumping an image\r
+      //\r
+      mOptions.Dump = 1;\r
+    } else {\r
+      Error (NULL, 0, 0, Argv[0], "unrecognized option");\r
+      Usage ();\r
+      return STATUS_ERROR;\r
+    }\r
+    //\r
+    // Next argument\r
+    //\r
+    Argv++;\r
+    Argc--;\r
+  }\r
+  //\r
+  // Better be one more arg for input file name\r
+  //\r
+  if (Argc == 0) {\r
+    Error (NULL, 0, 0, "input file name required", NULL);\r
+    Usage ();\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  if (Argc != 1) {\r
+    Error (NULL, 0, 0, Argv[1], "extra arguments on command line");\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  strcpy (mOptions.InFileName, Argv[0]);\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+void\r
+Usage (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  Print usage information for this utility.\r
+\r
+Arguments:\r
+\r
+  None.\r
+\r
+Returns:\r
+\r
+  Nothing.\r
+\r
+--*/\r
+{\r
+  int               Index;\r
+  static const char *Msg[] = {\r
+    UTILITY_NAME " version "UTILITY_VERSION " - TE image utility",\r
+    "  Generate a TE image from an EFI PE32 image",\r
+    "  Usage: "UTILITY_NAME " {-v} {-dump} {-h|-?} {-o OutFileName} InFileName",\r
+    "                [-e|-b] [FileName(s)]",\r
+    "    where:",\r
+    "      -v             - for verbose output",\r
+    "      -dump          - to dump the input file to a text file",\r
+    "      -h -?          - for this help information",\r
+    "      -o OutFileName - to write output to OutFileName rather than InFileName"DEFAULT_OUTPUT_EXTENSION,\r
+    "      InFileName     - name of the input PE32 file",\r
+    "",\r
+    NULL\r
+  };\r
+  for (Index = 0; Msg[Index] != NULL; Index++) {\r
+    fprintf (stdout, "%s\n", Msg[Index]);\r
+  }\r
+}\r
+\r
+static\r
+VOID\r
+DumpImage (\r
+  INT8    *FileName\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  Dump a specified image information\r
+\r
+Arguments:\r
+  \r
+  FileName - File name pointer to the image to dump\r
+\r
+Returns:\r
+\r
+  Nothing.\r
+\r
+--*/\r
+{\r
+  FILE                *InFptr;\r
+  EFI_TE_IMAGE_HEADER TEImageHeader;\r
+  INT8                *NamePtr;\r
+\r
+  //\r
+  // Open the input file\r
+  //\r
+  InFptr  = NULL;\r
+\r
+  if ((InFptr = fopen (FileName, "rb")) == NULL) {\r
+    Error (NULL, 0, 0, FileName, "failed to open input file for reading");\r
+    return ;\r
+  }\r
+\r
+  if (fread (&TEImageHeader, sizeof (EFI_TE_IMAGE_HEADER), 1, InFptr) != 1) {\r
+    Error (NULL, 0, 0, FileName, "failed to read image header from input file");\r
+    goto Finish;\r
+  }\r
+\r
+  if (TEImageHeader.Signature != EFI_TE_IMAGE_HEADER_SIGNATURE) {\r
+    Error (NULL, 0, 0, FileName, "Image does not appear to be a TE image (bad signature)");\r
+    goto Finish;\r
+  }\r
+  //\r
+  // Dump the header\r
+  //\r
+  fprintf (stdout, "Header (%d bytes):\n", sizeof (EFI_TE_IMAGE_HEADER));\r
+  fprintf (stdout, "  Signature:          0x%04X (TE)\n", (UINT32) TEImageHeader.Signature);\r
+  NamePtr = GetMachineTypeStr (TEImageHeader.Machine);\r
+  fprintf (stdout, "  Machine:            0x%04X (%s)\n", (UINT32) TEImageHeader.Machine, NamePtr);\r
+  NamePtr = GetSubsystemTypeStr (TEImageHeader.Subsystem);\r
+  fprintf (stdout, "  Subsystem:          0x%02X (%s)\n", (UINT32) TEImageHeader.Subsystem, NamePtr);\r
+  fprintf (stdout, "  Number of sections  0x%02X\n", (UINT32) TEImageHeader.NumberOfSections);\r
+  fprintf (stdout, "  Stripped size:      0x%04X\n", (UINT32) TEImageHeader.StrippedSize);\r
+  fprintf (stdout, "  Entry point:        0x%08X\n", TEImageHeader.AddressOfEntryPoint);\r
+  fprintf (stdout, "  Base of code:       0x%08X\n", TEImageHeader.BaseOfCode);\r
+  fprintf (stdout, "  Data directories:\n");\r
+  fprintf (\r
+    stdout,\r
+    "    %8X [%8X] RVA [size] of Base Relocation Directory\n",\r
+    TEImageHeader.DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_BASERELOC].VirtualAddress,\r
+    TEImageHeader.DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_BASERELOC].Size\r
+    );\r
+  fprintf (\r
+    stdout,\r
+    "    %8X [%8X] RVA [size] of Debug Directory\n",\r
+    TEImageHeader.DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG].VirtualAddress,\r
+    TEImageHeader.DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG].Size\r
+    );\r
+\r
+Finish:\r
+  if (InFptr != NULL) {\r
+    fclose (InFptr);\r
+  }\r
+}\r
+\r
+static\r
+INT8 *\r
+GetMachineTypeStr (\r
+  UINT16    MachineType\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  MachineType - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+{\r
+  int Index;\r
+\r
+  for (Index = 0; mMachineTypes[Index].Name != NULL; Index++) {\r
+    if (mMachineTypes[Index].Value == MachineType) {\r
+      return mMachineTypes[Index].Name;\r
+    }\r
+  }\r
+\r
+  return "unknown";\r
+}\r
+\r
+static\r
+INT8 *\r
+GetSubsystemTypeStr (\r
+  UINT16  SubsystemType\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  SubsystemType - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+{\r
+  int Index;\r
+\r
+  for (Index = 0; mSubsystemTypes[Index].Name != NULL; Index++) {\r
+    if (mSubsystemTypes[Index].Value == SubsystemType) {\r
+      return mSubsystemTypes[Index].Name;\r
+    }\r
+  }\r
+\r
+  return "unknown";\r
+}\r
diff --git a/Tools/CodeTools/Source/GenTEImage/build.xml b/Tools/CodeTools/Source/GenTEImage/build.xml
new file mode 100644 (file)
index 0000000..e79f957
--- /dev/null
@@ -0,0 +1,72 @@
+<?xml version="1.0" ?>\r
+<!--\r
+Copyright (c) 2006, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+-->\r
+<project default="GenTool" basedir=".">\r
+<!--\r
+    EDK GenTEImage Tool\r
+  Copyright (c) 2006, Intel Corporation\r
+-->\r
+  <property name="ToolName" value="GenTEImage"/>\r
+  <property name="FileSet" value="*.c"/>\r
+\r
+  <taskdef resource="cpptasks.tasks"/>\r
+  <typedef resource="cpptasks.types"/>\r
+  <taskdef resource="net/sf/antcontrib/antlib.xml"/>\r
+\r
+\r
+  <property name="LINK_OUTPUT_TYPE" value="static"/>\r
+  <property name="BUILD_DIR" value="${PACKAGE_DIR}/${ToolName}/tmp"/>\r
+\r
+  <target name="GenTool" depends="init, Tool">\r
+    <echo message="The EDK Tool: ${ToolName} build has completed!"/>\r
+  </target>\r
+\r
+  <target name="init">\r
+    <echo message="Building the EDK Tool: ${ToolName}"/>\r
+    <mkdir dir="${BUILD_DIR}"/>\r
+  </target>\r
+\r
+  <target name="Tool" depends="init">\r
+    <cc name="${ToolChain}" objdir="${BUILD_DIR}" \r
+        outfile="${BIN_DIR}/${ToolName}"\r
+        outtype="executable"\r
+        debug="true"\r
+        optimize="speed">\r
+      <compilerarg value="${ExtraArgus}" if="ExtraArgus" />\r
+\r
+      <fileset dir="${basedir}/${ToolName}" \r
+        includes="${FileSet}" \r
+        defaultexcludes="TRUE" \r
+        excludes="*.xml *.inf"/>\r
+\r
+      <includepath path="${PACKAGE_DIR}/Include"/>\r
+      <includepath path="${PACKAGE_DIR}/Include/${HostArch}"/>\r
+      <includepath path="${PACKAGE_DIR}/Common"/>\r
+      <libset dir="${LIB_DIR}" libs="CommonTools"/>\r
+    </cc>\r
+  </target>\r
+\r
+  <target name="clean">\r
+    <echo message="Removing Intermediate Files Only"/>  \r
+    <delete>\r
+      <fileset dir="${BUILD_DIR}" includes="*.obj"/>\r
+    </delete>\r
+  </target>\r
+\r
+  <target name="cleanall">\r
+    <echo message="Removing Object Files and the Executable: ${ToolName}${ext_exe}"/>  \r
+    <delete failonerror="false" quiet="true" includeEmptyDirs="true">\r
+      <fileset dir="${BUILD_DIR}"/>\r
+      <fileset file="${BIN_DIR}/${ToolName}${ext_exe}"/>\r
+    </delete>\r
+  </target>\r
+\r
+</project>\r
diff --git a/Tools/CodeTools/Source/GuidChk/CommonUtils.h b/Tools/CodeTools/Source/GuidChk/CommonUtils.h
new file mode 100644 (file)
index 0000000..f7a331e
--- /dev/null
@@ -0,0 +1,57 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:  \r
+\r
+  CommonUtils.h\r
+  \r
+Abstract:\r
+\r
+  Common utility defines and structure definitions.\r
+  \r
+--*/\r
+\r
+#ifndef _COMMON_UTILS_H_\r
+#define _COMMON_UTILS_H_\r
+\r
+//\r
+// Basic types\r
+//\r
+typedef unsigned char UINT8;\r
+typedef char INT8;\r
+typedef unsigned short UINT16;\r
+typedef unsigned int UINT32;\r
+\r
+typedef UINT8 BOOLEAN;\r
+typedef UINT32 STATUS;\r
+\r
+#define TRUE            1\r
+#define FALSE           0\r
+\r
+#define STATUS_SUCCESS  0\r
+#define STATUS_WARNING  1\r
+#define STATUS_ERROR    2\r
+\r
+//\r
+// Linked list of strings\r
+//\r
+typedef struct _STRING_LIST {\r
+  struct _STRING_LIST *Next;\r
+  char                *Str;\r
+} STRING_LIST;\r
+\r
+int\r
+CreateGuidList (\r
+  INT8    *OutFileName\r
+  )\r
+;\r
+\r
+#endif // #ifndef _COMMON_UTILS_H_\r
diff --git a/Tools/CodeTools/Source/GuidChk/FileSearch.c b/Tools/CodeTools/Source/GuidChk/FileSearch.c
new file mode 100644 (file)
index 0000000..8b5b58f
--- /dev/null
@@ -0,0 +1,285 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:  \r
+\r
+  FileSearch.c\r
+  \r
+Abstract:\r
+\r
+  Module used to support file searches on the system.\r
+  \r
+--*/\r
+\r
+#include <stdio.h>\r
+\r
+#include "CommonUtils.h"\r
+#include "FileSearch.h"\r
+#include "UtilsMsgs.h"\r
+\r
+//\r
+// Internal file search flag for sanity checks\r
+//\r
+#define FILE_SEARCH_STARTED 0x8000\r
+#define FILE_SEARCH_INITED  0x4000\r
+\r
+static\r
+BOOLEAN\r
+FileSearchMeetsCriteria (\r
+  FILE_SEARCH_DATA    *FSData\r
+  );\r
+\r
+/*****************************************************************************/\r
+STATUS\r
+FileSearchInit (\r
+  FILE_SEARCH_DATA    *FSData\r
+  )\r
+{\r
+  memset ((char *) FSData, 0, sizeof (FILE_SEARCH_DATA));\r
+  FSData->Handle          = INVALID_HANDLE_VALUE;\r
+  FSData->FileSearchFlags = FILE_SEARCH_INITED;\r
+  FSData->FileName[0]     = 0;\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+STATUS\r
+FileSearchStart (\r
+  FILE_SEARCH_DATA    *FSData,\r
+  char                *FileMask,\r
+  UINT32              SearchFlags\r
+  )\r
+{\r
+  BOOLEAN Done;\r
+\r
+  //\r
+  // Save their flags, and set a flag to indicate that they called this\r
+  // start function so we can perform extended checking in the other\r
+  // routines we have in this module.\r
+  //\r
+  FSData->FileSearchFlags |= (SearchFlags | FILE_SEARCH_STARTED);\r
+  FSData->FileName[0] = 0;\r
+\r
+  //\r
+  // Begin the search\r
+  //\r
+  FSData->Handle = FindFirstFile (FileMask, &(FSData->FindData));\r
+  if (FSData->Handle == INVALID_HANDLE_VALUE) {\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Keep looping through until we find a file meeting the caller's\r
+  // criteria per the search flags\r
+  //\r
+  Done = FALSE;\r
+  while (!Done) {\r
+    //\r
+    // If we're done (we found a match) copy the file name found and return\r
+    //\r
+    Done = FileSearchMeetsCriteria (FSData);\r
+    if (Done) {\r
+      return STATUS_SUCCESS;\r
+    }\r
+    //\r
+    // Go on to next file\r
+    //\r
+    if (!FindNextFile (FSData->Handle, &(FSData->FindData))) {\r
+      return STATUS_NOT_FOUND;\r
+    }\r
+  }\r
+  //\r
+  // Not reached\r
+  //\r
+  return STATUS_NOT_FOUND;\r
+}\r
+\r
+//\r
+// Find the next file meeting their criteria and return it.\r
+//\r
+STATUS\r
+FileSearchFindNext (\r
+  FILE_SEARCH_DATA    *FSData\r
+  )\r
+{\r
+  BOOLEAN Done;\r
+\r
+  Done = FALSE;\r
+  while (!Done) {\r
+    if (!FindNextFile (FSData->Handle, &(FSData->FindData))) {\r
+      return STATUS_NOT_FOUND;\r
+    }\r
+    //\r
+    // See if it matches their criteria\r
+    //\r
+    Done = FileSearchMeetsCriteria (FSData);\r
+    if (Done) {\r
+      return STATUS_SUCCESS;\r
+    }\r
+  }\r
+  //\r
+  // Not reached\r
+  //\r
+  return STATUS_NOT_FOUND;\r
+}\r
+//\r
+// Perform any cleanup necessary to close down a search\r
+//\r
+STATUS\r
+FileSearchDestroy (\r
+  FILE_SEARCH_DATA    *FSData\r
+  )\r
+{\r
+  if (FSData->Handle != INVALID_HANDLE_VALUE) {\r
+    FindClose (FSData->Handle);\r
+    FSData->Handle = INVALID_HANDLE_VALUE;\r
+  }\r
+\r
+  FSData->FileName[0]     = 0;\r
+  FSData->FileSearchFlags = 0;\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+BOOLEAN\r
+FileSearchMeetsCriteria (\r
+  FILE_SEARCH_DATA    *FSData\r
+  )\r
+{\r
+  BOOLEAN     Status;\r
+  STRING_LIST *StrList;\r
+  UINT32      ExtLen;\r
+  UINT32      FileNameLen;\r
+\r
+  Status = FALSE;\r
+\r
+  //\r
+  // First clear the flag indicating this is neither a file or a\r
+  // directory.\r
+  //\r
+  FSData->FileFlags &= ~(FILE_SEARCH_DIR | FILE_SEARCH_FILE);\r
+\r
+  //\r
+  // We found a file. See if it matches the user's search criteria. First\r
+  // check for this being a directory, and they want directories, and\r
+  // it's not "." and it's not ".."\r
+  //\r
+  if ((FSData->FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) &&\r
+      (FSData->FileSearchFlags & FILE_SEARCH_DIR) &&\r
+      (strcmp (FSData->FindData.cFileName, ".")) &&\r
+      (strcmp (FSData->FindData.cFileName, ".."))\r
+      ) {\r
+    //\r
+    // Assume we'll make it past this check\r
+    //\r
+    Status = TRUE;\r
+    //\r
+    // If they have a list of exclude directories, then check for those\r
+    //\r
+    StrList = FSData->ExcludeDirs;\r
+    while (StrList != NULL) {\r
+      if (stricmp (FSData->FindData.cFileName, StrList->Str) == 0) {\r
+        Status = FALSE;\r
+        break;\r
+      }\r
+\r
+      StrList = StrList->Next;\r
+    }\r
+    //\r
+    // If we didn't fail due to excluded directories, then set the dir flag\r
+    //\r
+    if (Status) {\r
+      FSData->FileFlags |= FILE_SEARCH_DIR;\r
+    }\r
+    //\r
+    // Else check for a file, and they want files....\r
+    //\r
+  } else if (((FSData->FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0) &&\r
+           (FSData->FileSearchFlags & FILE_SEARCH_FILE)\r
+          ) {\r
+    //\r
+    // See if it's in our list of excluded files\r
+    //\r
+    Status  = TRUE;\r
+    StrList = FSData->ExcludeFiles;\r
+    while (StrList != NULL) {\r
+      if (stricmp (FSData->FindData.cFileName, StrList->Str) == 0) {\r
+        Status = FALSE;\r
+        break;\r
+      }\r
+\r
+      StrList = StrList->Next;\r
+    }\r
+\r
+    if (Status) {\r
+      //\r
+      // See if it's in our list of excluded file extensions\r
+      //\r
+      FileNameLen = strlen (FSData->FindData.cFileName);\r
+      StrList     = FSData->ExcludeExtensions;\r
+      while (StrList != NULL) {\r
+        ExtLen = strlen (StrList->Str);\r
+        if (stricmp (\r
+              FSData->FindData.cFileName + FileNameLen - ExtLen,\r
+              StrList->Str\r
+              ) == 0) {\r
+          Status = FALSE;\r
+          break;\r
+        }\r
+\r
+        StrList = StrList->Next;\r
+      }\r
+    }\r
+\r
+    if (Status) {\r
+      FSData->FileFlags |= FILE_SEARCH_FILE;\r
+    }\r
+  }\r
+  //\r
+  // If it's a match, copy the filename into another field of the structure\r
+  // for portability.\r
+  //\r
+  if (Status) {\r
+    strcpy (FSData->FileName, FSData->FindData.cFileName);\r
+  }\r
+\r
+  return Status;\r
+}\r
+//\r
+// Exclude a list of subdirectories.\r
+//\r
+STATUS\r
+FileSearchExcludeDirs (\r
+  FILE_SEARCH_DATA    *FSData,\r
+  STRING_LIST         *StrList\r
+  )\r
+{\r
+  FSData->ExcludeDirs = StrList;\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+STATUS\r
+FileSearchExcludeFiles (\r
+  FILE_SEARCH_DATA    *FSData,\r
+  STRING_LIST         *StrList\r
+  )\r
+{\r
+  FSData->ExcludeFiles = StrList;\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+STATUS\r
+FileSearchExcludeExtensions (\r
+  FILE_SEARCH_DATA    *FSData,\r
+  STRING_LIST         *StrList\r
+  )\r
+{\r
+  FSData->ExcludeExtensions = StrList;\r
+  return STATUS_SUCCESS;\r
+}\r
diff --git a/Tools/CodeTools/Source/GuidChk/FileSearch.h b/Tools/CodeTools/Source/GuidChk/FileSearch.h
new file mode 100644 (file)
index 0000000..bc40265
--- /dev/null
@@ -0,0 +1,108 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:  \r
+\r
+  FileSearch.h\r
+  \r
+Abstract:\r
+\r
+  Header file to support file searching.\r
+  \r
+--*/\r
+\r
+#ifndef _FILE_SEARCH_H_\r
+#define _FILE_SEARCH_H_\r
+\r
+//\r
+// Since the file searching routines are OS dependent, put the\r
+// necessary include paths in this header file so that the non-OS-dependent\r
+// files don't need to include these windows-specific header files.\r
+//\r
+#include <stdio.h>\r
+#include <string.h>\r
+#include <ctype.h>\r
+#include <direct.h>\r
+#include <windows.h>\r
+\r
+//\r
+// Return codes of some of the file search routines\r
+//\r
+#define STATUS_NOT_FOUND  0x1000\r
+\r
+//\r
+// Flags for what to search for. Also used in the FileFlags return field.\r
+//\r
+#define FILE_SEARCH_DIR   0x0001\r
+#define FILE_SEARCH_FILE  0x0002\r
+\r
+//\r
+// Here's our class definition\r
+//\r
+typedef struct {\r
+  HANDLE          Handle;\r
+  WIN32_FIND_DATA FindData;\r
+  UINT32          FileSearchFlags;    // DIRS, FILES, etc\r
+  UINT32          FileFlags;\r
+  INT8            FileName[MAX_PATH]; // for portability\r
+  STRING_LIST     *ExcludeDirs;\r
+  STRING_LIST     *ExcludeFiles;\r
+  STRING_LIST     *ExcludeExtensions;\r
+} FILE_SEARCH_DATA;\r
+\r
+//\r
+// Here's our member functions\r
+//\r
+STATUS\r
+FileSearchInit (\r
+  FILE_SEARCH_DATA    *FSData\r
+  )\r
+;\r
+\r
+STATUS\r
+FileSearchDestroy (\r
+  FILE_SEARCH_DATA    *FSData\r
+  )\r
+;\r
+\r
+STATUS\r
+FileSearchStart (\r
+  FILE_SEARCH_DATA    *FSData,\r
+  char                *FileMask,\r
+  UINT32              SearchFlags\r
+  )\r
+;\r
+\r
+STATUS\r
+FileSearchFindNext (\r
+  FILE_SEARCH_DATA    *FSData\r
+  )\r
+;\r
+\r
+STATUS\r
+FileSearchExcludeDirs (\r
+  FILE_SEARCH_DATA    *FSData,\r
+  STRING_LIST         *StrList\r
+  )\r
+;\r
+STATUS\r
+FileSearchExcludeExtensions (\r
+  FILE_SEARCH_DATA    *FSData,\r
+  STRING_LIST         *StrList\r
+  )\r
+;\r
+STATUS\r
+FileSearchExcludeFiles (\r
+  FILE_SEARCH_DATA    *FSData,\r
+  STRING_LIST         *StrList\r
+  )\r
+;\r
+#endif\r
diff --git a/Tools/CodeTools/Source/GuidChk/GuidChk.c b/Tools/CodeTools/Source/GuidChk/GuidChk.c
new file mode 100644 (file)
index 0000000..de88405
--- /dev/null
@@ -0,0 +1,2348 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:  \r
+\r
+  GuidChk.c \r
+  \r
+Abstract:\r
+\r
+  Parse files in a directory and subdirectories to find all guid definitions.\r
+  Then check them against each other to make sure there are no duplicates.\r
+  \r
+--*/\r
+\r
+#include <stdio.h>\r
+#include <string.h>\r
+#include <stdlib.h>\r
+#include <ctype.h>\r
+\r
+#include "CommonUtils.h"\r
+#include "FileSearch.h"\r
+#include "UtilsMsgs.h"\r
+\r
+#define MAX_LINE_LEN  180 // we concatenate two lines sometimes\r
+// Define a structure that correlates filename extensions to an enumerated\r
+// type.\r
+//\r
+typedef struct {\r
+  INT8  *Extension;\r
+  INT8  ExtensionCode;\r
+} FILE_TYPE_TABLE_ENTRY;\r
+\r
+#define FILE_EXTENSION_UNKNOWN  0\r
+#define FILE_EXTENSION_C        1\r
+#define FILE_EXTENSION_H        2\r
+#define FILE_EXTENSION_IA32_ASM 3\r
+#define FILE_EXTENSION_IA32_INC 4\r
+#define FILE_EXTENSION_IA64_ASM 5\r
+#define FILE_EXTENSION_IA64_INC 6\r
+#define FILE_EXTENSION_PKG      7\r
+#define FILE_EXTENSION_INF      8\r
+\r
+FILE_TYPE_TABLE_ENTRY FileTypeTable[] = {\r
+  ".c",\r
+  FILE_EXTENSION_C,\r
+  ".h",\r
+  FILE_EXTENSION_H,\r
+  ".inc",\r
+  FILE_EXTENSION_IA32_INC,\r
+  ".asm",\r
+  FILE_EXTENSION_IA32_ASM,\r
+  ".s",\r
+  FILE_EXTENSION_IA64_ASM,\r
+  ".pkg",\r
+  FILE_EXTENSION_PKG,\r
+  ".inf",\r
+  FILE_EXTENSION_INF,\r
+  ".i",\r
+  FILE_EXTENSION_IA64_INC,\r
+  NULL,\r
+  0\r
+};\r
+\r
+typedef struct EFI_GUID {\r
+  UINT32  Data1;\r
+  UINT16  Data2;\r
+  UINT16  Data3;\r
+  UINT8   Data4[8];\r
+} EFI_GUID;\r
+\r
+typedef struct {\r
+  INT8  Data[4];\r
+  INT8  DataLen;\r
+} EFI_SIGNATURE;\r
+\r
+typedef struct _GUID_RECORD {\r
+  struct _GUID_RECORD *Next;\r
+  BOOLEAN             Reported;\r
+  INT8                *FileName;\r
+  INT8                *SymName;\r
+  EFI_GUID            Guid;\r
+} GUID_RECORD;\r
+\r
+typedef struct _SIGNATURE_RECORD {\r
+  struct _SIGNATURE_RECORD  *Next;\r
+  BOOLEAN                   Reported;\r
+  INT8                      *FileName;\r
+  EFI_SIGNATURE             Signature;\r
+} SIGNATURE_RECORD;\r
+\r
+//\r
+// Utility options\r
+//\r
+typedef struct {\r
+  INT8        DatabaseOutputFileName[MAX_PATH]; // with -b option\r
+  STRING_LIST *ExcludeDirs;                     // list of directory names not to process\r
+  STRING_LIST *ExcludeSubDirs;                  // list of directory names to not process subdirectories (build)\r
+  STRING_LIST *ExcludeFiles;                    // list of files to exclude (make.inf)\r
+  STRING_LIST *ExcludeExtensions;               // list of filename extensions to exclude (.inf, .pkg)\r
+  BOOLEAN     Verbose;\r
+  BOOLEAN     PrintFound;\r
+  BOOLEAN     CheckGuids;\r
+  BOOLEAN     CheckSignatures;\r
+  BOOLEAN     GuidXReference;\r
+} OPTIONS;\r
+\r
+static\r
+STATUS\r
+ProcessArgs (\r
+  int     Argc,\r
+  char    *Argv[]\r
+  );\r
+\r
+static\r
+VOID\r
+Usage (\r
+  VOID\r
+  );\r
+\r
+static\r
+STATUS\r
+ProcessDirectory (\r
+  INT8        *Path,\r
+  INT8        *DirectoryName\r
+  );\r
+\r
+static\r
+STATUS\r
+ProcessFile (\r
+  INT8                *DirectoryName,\r
+  INT8                *FileName\r
+  );\r
+\r
+static\r
+UINT32\r
+GetFileExtension (\r
+  INT8        *FileName\r
+  );\r
+\r
+static\r
+UINT32\r
+SkipWhiteSpace (\r
+  INT8    *Str\r
+  );\r
+\r
+static\r
+UINT32\r
+ValidSymbolName (\r
+  INT8    *Name\r
+  );\r
+\r
+static\r
+STATUS\r
+ProcessCFileGuids (\r
+  INT8    *FileName\r
+  );\r
+\r
+static\r
+STATUS\r
+AddSignature (\r
+  INT8      *FileName,\r
+  INT8      *StrDef,\r
+  UINT32    SigSize\r
+  );\r
+\r
+static\r
+STATUS\r
+ProcessCFileSigs (\r
+  INT8    *FileName\r
+  );\r
+\r
+static\r
+STATUS\r
+ProcessINFFileGuids (\r
+  INT8    *FileName\r
+  );\r
+\r
+static\r
+STATUS\r
+ProcessPkgFileGuids (\r
+  INT8    *FileName\r
+  );\r
+\r
+static\r
+STATUS\r
+ProcessIA32FileGuids (\r
+  INT8    *FileName\r
+  );\r
+\r
+static\r
+STATUS\r
+ProcessIA64FileGuids (\r
+  INT8    *FileName\r
+  );\r
+\r
+static\r
+BOOLEAN\r
+IsIA64GuidLine (\r
+  INT8      *Line,\r
+  UINT32    *GuidHigh,\r
+  UINT32    *GuidLow,\r
+  BOOLEAN   *Low,\r
+  INT8      *SymName\r
+  );\r
+\r
+static\r
+STATUS\r
+AddGuid11 (\r
+  INT8      *FileName,\r
+  UINT32    *Data,\r
+  INT8      *SymName\r
+  );\r
+\r
+static\r
+STATUS\r
+AddPkgGuid (\r
+  INT8      *FileName,\r
+  UINT32    *Data,\r
+  UINT64    *Data64\r
+  );\r
+\r
+static\r
+STATUS\r
+AddGuid16 (\r
+  INT8      *FileName,\r
+  UINT32    *Data\r
+  );\r
+\r
+static\r
+STATUS\r
+AddGuid64x2 (\r
+  INT8      *FileName,\r
+  UINT32    DataHH,                             // Upper 32-bits of upper 64 bits of guid\r
+  UINT32    DataHL,                             // Lower 32-bits of upper 64 bits\r
+  UINT32    DataLH,\r
+  UINT32    DataLL\r
+  );\r
+\r
+static\r
+VOID\r
+FreeGuids (\r
+  VOID\r
+  );\r
+\r
+static\r
+VOID\r
+FreeSigs (\r
+  VOID\r
+  );\r
+\r
+static\r
+STATUS\r
+CheckDuplicates (\r
+  VOID\r
+  );\r
+\r
+//\r
+// static\r
+// VOID\r
+// ReportGuid (\r
+//  INT8        *FileName,\r
+//  GUID_RECORD *FileRecord\r
+//  );\r
+//\r
+static\r
+VOID\r
+FreeOptions (\r
+  VOID\r
+  );\r
+\r
+static\r
+BOOLEAN\r
+CheckGuidData (\r
+  UINT32    *GuidData,\r
+  UINT32    DataCount\r
+  );\r
+\r
+/**************************** GLOBALS ****************************************/\r
+static GUID_RECORD      *gGuidList      = NULL;\r
+static SIGNATURE_RECORD *gSignatureList = NULL;\r
+static OPTIONS          gOptions;\r
+\r
+/*****************************************************************************/\r
+int\r
+main (\r
+  int     Argc,\r
+  char    *Argv[]\r
+  )\r
+{\r
+  INT8    *Cwd;\r
+  STATUS  Status;\r
+\r
+  SetUtilityName ("GuidChk");\r
+  //\r
+  // Get the current working directory and then process the command line\r
+  // arguments.\r
+  //\r
+  Cwd     = _getcwd (NULL, 0);\r
+  Status  = ProcessArgs (Argc, Argv);\r
+  if (Status != STATUS_SUCCESS) {\r
+    return Status;\r
+  }\r
+\r
+  if (gOptions.CheckGuids || gOptions.CheckSignatures) {\r
+    Status = ProcessDirectory (Cwd, NULL);\r
+    if (Status == STATUS_SUCCESS) {\r
+      //\r
+      // Check for duplicates\r
+      //\r
+      Status = CheckDuplicates ();\r
+    }\r
+  }\r
+\r
+  if (gOptions.DatabaseOutputFileName[0] != 0) {\r
+    CreateGuidList (gOptions.DatabaseOutputFileName);\r
+  }\r
+  //\r
+  // Free up the memory\r
+  //\r
+  free (Cwd);\r
+  FreeGuids ();\r
+  FreeSigs ();\r
+  FreeOptions ();\r
+  return GetUtilityStatus ();\r
+}\r
+\r
+static\r
+STATUS\r
+ProcessArgs (\r
+  int     Argc,\r
+  char    *Argv[]\r
+  )\r
+{\r
+  STRING_LIST *StrList;\r
+\r
+  memset ((char *) &gOptions, 0, sizeof (gOptions));\r
+  //\r
+  // skip over program name\r
+  //\r
+  Argc--;\r
+  Argv++;\r
+\r
+  if (Argc == 0) {\r
+    Usage ();\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  while (Argc > 0) {\r
+    //\r
+    // Look for options\r
+    //\r
+    if ((Argv[0][0] == '-') || (Argv[0][0] == '/')) {\r
+      switch (Argv[0][1]) {\r
+      //\r
+      // Help option\r
+      //\r
+      case 'h':\r
+      case 'H':\r
+      case '?':\r
+        Usage ();\r
+        return STATUS_ERROR;\r
+        break;\r
+\r
+      //\r
+      // Check guids option\r
+      //\r
+      case 'g':\r
+      case 'G':\r
+        gOptions.CheckGuids = TRUE;\r
+        break;\r
+\r
+      //\r
+      // Check signatures option\r
+      //\r
+      case 's':\r
+      case 'S':\r
+        gOptions.CheckSignatures = TRUE;\r
+        break;\r
+\r
+      //\r
+      // Print guids found option\r
+      //\r
+      case 'p':\r
+      case 'P':\r
+        gOptions.PrintFound = TRUE;\r
+        break;\r
+\r
+      //\r
+      // Exclude files option\r
+      //\r
+      case 'f':\r
+      case 'F':\r
+        //\r
+        // Check for another arg\r
+        //\r
+        if (Argc < 2) {\r
+          Error (NULL, 0, 0, Argv[0], "missing argument with option");\r
+          Usage ();\r
+          return STATUS_ERROR;\r
+        }\r
+\r
+        StrList = malloc (sizeof (STRING_LIST));\r
+        if (StrList == NULL) {\r
+          Error (NULL, 0, 0, "memory allocation failure", NULL);\r
+          return STATUS_ERROR;\r
+        }\r
+\r
+        memset ((char *) StrList, 0, sizeof (STRING_LIST));\r
+        StrList->Str          = Argv[1];\r
+        StrList->Next         = gOptions.ExcludeFiles;\r
+        gOptions.ExcludeFiles = StrList;\r
+        Argc--;\r
+        Argv++;\r
+        break;\r
+\r
+      //\r
+      // Exclude directories option\r
+      //\r
+      case 'd':\r
+      case 'D':\r
+        //\r
+        // Check for another arg\r
+        //\r
+        if (Argc < 2) {\r
+          Error (NULL, 0, 0, Argv[0], "missing argument with option");\r
+          Usage ();\r
+          return STATUS_ERROR;\r
+        }\r
+\r
+        StrList = malloc (sizeof (STRING_LIST));\r
+        if (StrList == NULL) {\r
+          Error (NULL, 0, 0, "memory allocation failure", NULL);\r
+          return STATUS_ERROR;\r
+        }\r
+\r
+        memset ((char *) StrList, 0, sizeof (STRING_LIST));\r
+        StrList->Str          = Argv[1];\r
+        StrList->Next         = gOptions.ExcludeDirs;\r
+        gOptions.ExcludeDirs  = StrList;\r
+        Argc--;\r
+        Argv++;\r
+        break;\r
+\r
+      //\r
+      // -u  exclude all subdirectories of a given directory option\r
+      //\r
+      case 'u':\r
+      case 'U':\r
+        //\r
+        // Check for another arg\r
+        //\r
+        if (Argc < 2) {\r
+          Error (NULL, 0, 0, Argv[0], "missing argument with option");\r
+          Usage ();\r
+          return STATUS_ERROR;\r
+        }\r
+\r
+        StrList = malloc (sizeof (STRING_LIST));\r
+        if (StrList == NULL) {\r
+          Error (NULL, 0, 0, "memory allocation failure", NULL);\r
+          return STATUS_ERROR;\r
+        }\r
+\r
+        memset ((char *) StrList, 0, sizeof (STRING_LIST));\r
+        StrList->Str            = Argv[1];\r
+        StrList->Next           = gOptions.ExcludeSubDirs;\r
+        gOptions.ExcludeSubDirs = StrList;\r
+        Argc--;\r
+        Argv++;\r
+        break;\r
+\r
+      //\r
+      // -e  exclude by filename extension option\r
+      //\r
+      case 'e':\r
+      case 'E':\r
+        //\r
+        // Check for another arg\r
+        //\r
+        if (Argc < 2) {\r
+          Error (NULL, 0, 0, Argv[0], "missing argument with option");\r
+          Usage ();\r
+          return STATUS_ERROR;\r
+        }\r
+\r
+        StrList = malloc (sizeof (STRING_LIST));\r
+        if (StrList == NULL) {\r
+          Error (NULL, 0, 0, "memory allocation failure", NULL);\r
+          return STATUS_ERROR;\r
+        }\r
+\r
+        memset ((char *) StrList, 0, sizeof (STRING_LIST));\r
+        //\r
+        // Let them put a * in front of the filename extension\r
+        //\r
+        StrList->Str = Argv[1];\r
+        if (StrList->Str[0] == '*') {\r
+          StrList->Str++;\r
+        }\r
+\r
+        StrList->Next               = gOptions.ExcludeExtensions;\r
+        gOptions.ExcludeExtensions  = StrList;\r
+        Argc--;\r
+        Argv++;\r
+        break;\r
+\r
+      //\r
+      // Print guid with matching symbol name for guid definitions found\r
+      //\r
+      case 'x':\r
+      case 'X':\r
+        gOptions.GuidXReference = 1;\r
+        break;\r
+\r
+      //\r
+      // -b   Print the internal database list to a file\r
+      //\r
+      case 'b':\r
+      case 'B':\r
+        //\r
+        // Check for one more arg\r
+        //\r
+        if (Argc < 2) {\r
+          Error (NULL, 0, 0, Argv[0], "must specify file name with option");\r
+          Usage ();\r
+          return STATUS_ERROR;\r
+        }\r
+\r
+        strcpy (gOptions.DatabaseOutputFileName, Argv[1]);\r
+        Argc--;\r
+        Argv++;\r
+        break;\r
+\r
+      default:\r
+        Error (NULL, 0, 0, Argv[0], "invalid option");\r
+        Usage ();\r
+        return STATUS_ERROR;\r
+      }\r
+    } else {\r
+      break;\r
+    }\r
+    //\r
+    // Next arg\r
+    //\r
+    Argc--;\r
+    Argv++;\r
+  }\r
+\r
+  if (Argc > 0) {\r
+    Error (NULL, 0, 0, Argv[0], "invalid argument");\r
+    Usage ();\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Have to check signatures, GUIDs, or dump the GUID database.\r
+  //\r
+  if ((!gOptions.CheckGuids) && (!gOptions.CheckSignatures) && (gOptions.DatabaseOutputFileName[0] == 0)) {\r
+    Error (NULL, 0, 0, "nothing to do", "must specify -g, -s, and/or -b");\r
+    Usage ();\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  return STATUS_SUCCESS;\r
+}\r
+//\r
+// Print usage instructions\r
+//\r
+static\r
+VOID\r
+Usage (\r
+  VOID\r
+  )\r
+{\r
+  int   Index;\r
+  char  *Str[] = {\r
+    "GuidChk - scan files for duplicate GUID or signature definitions",\r
+    "",\r
+    "Usage:  GuidChk {options}\n",\r
+    "  Options: ",\r
+    "    -d dirname     exclude searching of a directory",\r
+    "    -f filename    exclude searching of a file",\r
+    "    -e extension   exclude searching of files by extension",\r
+    "    -p             print all GUIDS found",\r
+    "    -g             check for duplicate guids",\r
+    "    -s             check for duplicate signatures",\r
+    "    -x             print guid+defined symbol name",\r
+    "    -b outfile     write internal GUID+basename list to outfile",\r
+    "    -u dirname     exclude searching all subdirectories of a directory",\r
+    "    -h -?          print this help text",\r
+    " ",\r
+    "   Example: GuidChk -g -u build -d fv -f make.inf -e .pkg",\r
+    "",\r
+    NULL\r
+  };\r
+  for (Index = 0; Str[Index] != NULL; Index++) {\r
+    fprintf (stdout, "%s\n", Str[Index]);\r
+  }\r
+}\r
+//\r
+// Process an entire directory by name\r
+//\r
+static\r
+STATUS\r
+ProcessDirectory (\r
+  INT8          *Path,\r
+  INT8          *DirectoryName\r
+  )\r
+{\r
+  FILE_SEARCH_DATA  FSData;\r
+  char              *FileMask;\r
+  BOOLEAN           Done;\r
+  UINT32            Len;\r
+  BOOLEAN           NoSubdirs;\r
+  STRING_LIST       *SLPtr;\r
+\r
+  //\r
+  // Root directory may be null\r
+  //\r
+  if (DirectoryName != NULL) {\r
+    //\r
+    // printf ("Processing directory: %s\n", DirectoryName);\r
+    //\r
+  }\r
+  //\r
+  // Initialize our file searching\r
+  //\r
+  FileSearchInit (&FSData);\r
+\r
+  //\r
+  // Exclude some directories, files, and extensions\r
+  //\r
+  FileSearchExcludeDirs (&FSData, gOptions.ExcludeDirs);\r
+  FileSearchExcludeExtensions (&FSData, gOptions.ExcludeExtensions);\r
+  FileSearchExcludeFiles (&FSData, gOptions.ExcludeFiles);\r
+  //\r
+  // See if this directory is in the list of directories that they\r
+  // don't want to process subdirectories of\r
+  //\r
+  NoSubdirs = FALSE;\r
+  if (DirectoryName != NULL) {\r
+    for (SLPtr = gOptions.ExcludeSubDirs; SLPtr != NULL; SLPtr = SLPtr->Next) {\r
+      if (stricmp (SLPtr->Str, DirectoryName) == 0) {\r
+        //\r
+        // printf ("not processing subdirectories of %s\n", DirectoryName);\r
+        //\r
+        NoSubdirs = TRUE;\r
+        break;\r
+      }\r
+    }\r
+  }\r
+  //\r
+  // Create a filemask of files to search for. We'll append "\*.*" on the\r
+  // end, so allocate some extra bytes.\r
+  //\r
+  Len = strlen (Path) + 10;\r
+  if (DirectoryName != NULL) {\r
+    Len += strlen (DirectoryName);\r
+  }\r
+\r
+  FileMask = malloc (Len);\r
+  if (FileMask == NULL) {\r
+    Error (NULL, 0, 0, "memory allocation failure", NULL);\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Now put it all together\r
+  //\r
+  strcpy (FileMask, Path);\r
+  if ((DirectoryName != NULL) && (strlen (DirectoryName) > 0)) {\r
+    strcat (FileMask, "\\");\r
+    strcat (FileMask, DirectoryName);\r
+  }\r
+\r
+  strcat (FileMask, "\\*.*");\r
+\r
+  //\r
+  // Start file searching for files and directories\r
+  //\r
+  FileSearchStart (&FSData, FileMask, FILE_SEARCH_FILE | FILE_SEARCH_DIR);\r
+\r
+  //\r
+  // Now hack the "\*.*" off the end of the filemask so we can use it to pass\r
+  // the full directory path on recursive calls to process directories.\r
+  //\r
+  FileMask[strlen (FileMask) - 4] = 0;\r
+\r
+  //\r
+  // Loop until no more files\r
+  //\r
+  Done = FALSE;\r
+  while (!Done) {\r
+    //\r
+    // printf ("Found %s...", FSData.FileName);\r
+    //\r
+    if (FSData.FileFlags & FILE_SEARCH_DIR) {\r
+      //\r
+      // printf ("directory\n");\r
+      //\r
+      if (!NoSubdirs) {\r
+        ProcessDirectory (FileMask, FSData.FileName);\r
+      }\r
+    } else if (FSData.FileFlags & FILE_SEARCH_FILE) {\r
+      //\r
+      // printf ("file\n");\r
+      //\r
+      ProcessFile (FileMask, FSData.FileName);\r
+    } else {\r
+      //\r
+      // printf ("unknown\n");\r
+      //\r
+    }\r
+\r
+    if (FileSearchFindNext (&FSData) != STATUS_SUCCESS) {\r
+      Done = TRUE;\r
+    }\r
+  }\r
+  //\r
+  // Free up allocated memory\r
+  //\r
+  free (FileMask);\r
+\r
+  //\r
+  // Free up our file searching\r
+  //\r
+  FileSearchDestroy (&FSData);\r
+\r
+  return STATUS_SUCCESS;\r
+}\r
+//\r
+// Process a single file.\r
+//\r
+static\r
+STATUS\r
+ProcessFile (\r
+  INT8                *DirectoryName,\r
+  INT8                *FileName\r
+  )\r
+{\r
+  STATUS  Status;\r
+  UINT32  FileExtension;\r
+  INT8    FullFileName[MAX_PATH];\r
+\r
+  Status = STATUS_SUCCESS;\r
+\r
+  sprintf (FullFileName, "%s\\%s", DirectoryName, FileName);\r
+  //\r
+  // printf ("Found file: %s\n", FullFileName);\r
+  //\r
+  FileExtension = GetFileExtension (FileName);\r
+\r
+  //\r
+  // Process these for GUID checks\r
+  //\r
+  if (gOptions.CheckGuids) {\r
+    switch (FileExtension) {\r
+    case FILE_EXTENSION_C:\r
+    case FILE_EXTENSION_H:\r
+      Status = ProcessCFileGuids (FullFileName);\r
+      break;\r
+\r
+    case FILE_EXTENSION_PKG:\r
+      Status = ProcessPkgFileGuids (FullFileName);\r
+      break;\r
+\r
+    case FILE_EXTENSION_IA32_INC:\r
+    case FILE_EXTENSION_IA32_ASM:\r
+      Status = ProcessIA32FileGuids (FullFileName);\r
+      break;\r
+\r
+    case FILE_EXTENSION_INF:\r
+      Status = ProcessINFFileGuids (FullFileName);\r
+      break;\r
+\r
+    case FILE_EXTENSION_IA64_INC:\r
+    case FILE_EXTENSION_IA64_ASM:\r
+      Status = ProcessIA64FileGuids (FullFileName);\r
+      break;\r
+\r
+    default:\r
+      //\r
+      // No errors anyway\r
+      //\r
+      Status = STATUS_SUCCESS;\r
+      break;\r
+    }\r
+  }\r
+\r
+  if (gOptions.CheckSignatures) {\r
+    switch (FileExtension) {\r
+    case FILE_EXTENSION_C:\r
+    case FILE_EXTENSION_H:\r
+      Status = ProcessCFileSigs (FullFileName);\r
+      break;\r
+\r
+    default:\r
+      //\r
+      // No errors anyway\r
+      //\r
+      Status = STATUS_SUCCESS;\r
+      break;\r
+    }\r
+  }\r
+\r
+  return Status;\r
+}\r
+//\r
+// Return a code indicating the file name extension.\r
+//\r
+static\r
+UINT32\r
+GetFileExtension (\r
+  INT8        *FileName\r
+  )\r
+{\r
+  INT8  *Extension;\r
+  int   Index;\r
+\r
+  //\r
+  // Look back for a filename extension\r
+  //\r
+  for (Extension = FileName + strlen (FileName) - 1; Extension >= FileName; Extension--) {\r
+    if (*Extension == '.') {\r
+      for (Index = 0; FileTypeTable[Index].Extension != NULL; Index++) {\r
+        if (stricmp (FileTypeTable[Index].Extension, Extension) == 0) {\r
+          return FileTypeTable[Index].ExtensionCode;\r
+        }\r
+      }\r
+    }\r
+  }\r
+\r
+  return FILE_TYPE_UNKNOWN;\r
+}\r
+//\r
+// Process a .pkg file.\r
+//\r
+// Look for FFS_FILEGUID=35b898ca-b6a9-49ce-8c72-904735cc49b7\r
+//\r
+static\r
+STATUS\r
+ProcessPkgFileGuids (\r
+  INT8    *FileName\r
+  )\r
+{\r
+  FILE    *Fptr;\r
+  INT8    Line[MAX_LINE_LEN * 2];\r
+  INT8    *Cptr;\r
+  INT8    *Cptr2;\r
+  UINT32  GuidScan[11];\r
+  UINT64  Guid64;\r
+\r
+  if ((Fptr = fopen (FileName, "r")) == NULL) {\r
+    Error (NULL, 0, 0, FileName, "could not open input file for reading");\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Read lines from the file until done\r
+  //\r
+  while (fgets (Line, sizeof (Line), Fptr) != NULL) {\r
+    Cptr = Line;\r
+    Cptr += SkipWhiteSpace (Line);\r
+    if (strncmp (Cptr, "FFS_FILEGUID", 12) == 0) {\r
+      Cptr += 12;\r
+      Cptr += SkipWhiteSpace (Cptr);\r
+      if (*Cptr == '=') {\r
+        Cptr++;\r
+        Cptr += SkipWhiteSpace (Cptr + 1);\r
+        //\r
+        // Blank out dashes on the line.\r
+        //\r
+        for (Cptr2 = Cptr; *Cptr2; Cptr2++) {\r
+          if (*Cptr2 == '-') {\r
+            *Cptr2 = ' ';\r
+          }\r
+        }\r
+\r
+        if (sscanf (\r
+              Cptr,\r
+              "%X %X %X %X %I64X",\r
+              &GuidScan[0],\r
+              &GuidScan[1],\r
+              &GuidScan[2],\r
+              &GuidScan[3],\r
+              &Guid64\r
+              ) == 5) {\r
+          AddPkgGuid (FileName, GuidScan, &Guid64);\r
+        } else {\r
+          DebugMsg (NULL, 0, 0, FileName, "GUID scan failed");\r
+        }\r
+      }\r
+    }\r
+  }\r
+\r
+  fclose (Fptr);\r
+  return STATUS_SUCCESS;\r
+}\r
+//\r
+// Process an IA32 assembly file.\r
+//\r
+// Look for:\r
+// FIND_FD_GUID_VAL equ  01h, 01h, 01h, 01h, 01h, 01h, 01h, 01h, 01h, 01h, 01h, 01h, 01h, 01h, 01h, 01h\r
+// PEI_GUID_FileNameGuid_Gmch815  equ  081818181h, 08181h, 08181h, 081h, 081h, 081h, 081h, 081h, 081h, 081h, 081h\r
+//\r
+static\r
+STATUS\r
+ProcessIA32FileGuids (\r
+  INT8    *FileName\r
+  )\r
+{\r
+  FILE    *Fptr;\r
+  INT8    Line[MAX_LINE_LEN];\r
+  INT8    *Cptr;\r
+  INT8    CSave;\r
+  INT8    *CSavePtr;\r
+  UINT32  Len;\r
+  UINT32  GuidData[16];\r
+  UINT32  Index;\r
+\r
+  if ((Fptr = fopen (FileName, "r")) == NULL) {\r
+    Error (NULL, 0, 0, FileName, "could not open input file for reading");\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Read lines from the file until done\r
+  //\r
+  while (fgets (Line, sizeof (Line), Fptr) != NULL) {\r
+    Cptr = Line;\r
+    Cptr += SkipWhiteSpace (Line);\r
+    //\r
+    // Look for xxxGUIDyyy equ 01h, 02h, 03h, ...\r
+    //\r
+    Len = ValidSymbolName (Cptr);\r
+    if (Len) {\r
+      //\r
+      // Terminate the line after the symbol name, then look for "guid" in\r
+      // the name.\r
+      //\r
+      CSavePtr  = Cptr + Len;\r
+      CSave     = *CSavePtr;\r
+      *CSavePtr = 0;\r
+      while (*Cptr) {\r
+        if (strnicmp (Cptr, "guid", 4) == 0) {\r
+          break;\r
+        }\r
+\r
+        Cptr++;\r
+      }\r
+      //\r
+      // If we found the string "guid", continue\r
+      //\r
+      if (*Cptr) {\r
+        //\r
+        // Restore the character on the line where we null-terminated the symbol\r
+        //\r
+        *CSavePtr = CSave;\r
+        Cptr      = CSavePtr;\r
+        Len       = SkipWhiteSpace (Cptr);\r
+        //\r
+        // Had to be some white space\r
+        //\r
+        if (Len) {\r
+          Cptr += Len;\r
+          //\r
+          // now look for "equ"\r
+          //\r
+          if (strnicmp (Cptr, "equ", 3) == 0) {\r
+            Cptr += 3;\r
+            Cptr += SkipWhiteSpace (Cptr);\r
+            //\r
+            // Now scan all the data\r
+            //\r
+            for (Index = 0; Index < 16; Index++) {\r
+              if (sscanf (Cptr, "%X", &GuidData[Index]) != 1) {\r
+                break;\r
+              }\r
+              //\r
+              // Skip to next\r
+              //\r
+              while (isxdigit (*Cptr)) {\r
+                Cptr++;\r
+              }\r
+\r
+              if ((*Cptr != 'h') && (*Cptr != 'H')) {\r
+                break;\r
+              } else {\r
+                Cptr++;\r
+                while (*Cptr && (isspace (*Cptr) || (*Cptr == ','))) {\r
+                  Cptr++;\r
+                }\r
+              }\r
+            }\r
+            //\r
+            // Now see which form we had\r
+            //\r
+            if (Index == 16) {\r
+              AddGuid16 (FileName, GuidData);\r
+            } else if (Index == 11) {\r
+              AddGuid11 (FileName, GuidData, NULL);\r
+            }\r
+          }\r
+        }\r
+      }\r
+    }\r
+  }\r
+\r
+  fclose (Fptr);\r
+  return STATUS_SUCCESS;\r
+}\r
+//\r
+// Found and parsed an IA32 assembly code guid. Save the 16 bytes off in the list\r
+// of guids.\r
+//\r
+static\r
+STATUS\r
+AddGuid16 (\r
+  INT8      *FileName,\r
+  UINT32    *Data\r
+  )\r
+{\r
+  GUID_RECORD *NewRec;\r
+  int         Index;\r
+\r
+  //\r
+  // Sanity check the data\r
+  //\r
+  if (!CheckGuidData (Data, 16)) {\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Allocate memory for a new guid structure\r
+  //\r
+  NewRec = malloc (sizeof (GUID_RECORD));\r
+  if (NewRec == NULL) {\r
+    Error (NULL, 0, 0, "memory allocation failure", NULL);\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  memset ((char *) NewRec, 0, sizeof (GUID_RECORD));\r
+  NewRec->FileName = malloc (strlen (FileName) + 1);\r
+  if (NewRec->FileName == NULL) {\r
+    free (NewRec);\r
+    Error (NULL, 0, 0, "memory allocation failure", NULL);\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  strcpy (NewRec->FileName, FileName);\r
+  NewRec->Guid.Data1  = (UINT32) (Data[0] | (Data[1] << 8) | (Data[2] << 16) | (Data[3] << 24));\r
+  NewRec->Guid.Data2  = (UINT16) (Data[4] | (Data[5] << 8));\r
+  NewRec->Guid.Data3  = (UINT16) (Data[6] | (Data[7] << 8));\r
+  for (Index = 0; Index < 8; Index++) {\r
+    NewRec->Guid.Data4[Index] = (UINT8) Data[Index + 8];\r
+  }\r
+  //\r
+  // Add it to the list\r
+  //\r
+  NewRec->Next  = gGuidList;\r
+  gGuidList     = NewRec;\r
+\r
+  //\r
+  // Report it\r
+  // ReportGuid (FileName, NewRec);\r
+  //\r
+  return STATUS_SUCCESS;\r
+}\r
+//\r
+// Add a GUID defined as GuidLow: 0x1122334455667788\r
+//                       GuidHi:  0x99AABBCCDDEEFF00\r
+//\r
+// These are equivalent:\r
+// { 0x11223344, 0x5566, 0x7788, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF, 0x00 }\r
+//    and:\r
+// Low: 00FFEEDDCCBBAA99\r
+// Hi:  7788556611223344\r
+//\r
+static\r
+STATUS\r
+AddGuid64x2 (\r
+  INT8      *FileName,\r
+  UINT32    DataHH, // Upper 32-bits of upper 64 bits of guid\r
+  UINT32    DataHL, // Lower 32-bits of upper 64 bits\r
+  UINT32    DataLH,\r
+  UINT32    DataLL\r
+  )\r
+{\r
+  GUID_RECORD *NewRec;\r
+  int         Index;\r
+\r
+  //\r
+  // Allocate memory for a new guid structure\r
+  //\r
+  NewRec = malloc (sizeof (GUID_RECORD));\r
+  if (NewRec == NULL) {\r
+    Error (NULL, 0, 0, "memory allocation failure", NULL);\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  memset ((char *) NewRec, 0, sizeof (GUID_RECORD));\r
+  NewRec->FileName = malloc (strlen (FileName) + 1);\r
+  if (NewRec->FileName == NULL) {\r
+    free (NewRec);\r
+    Error (NULL, 0, 0, "memory allocation failure", NULL);\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  strcpy (NewRec->FileName, FileName);\r
+  NewRec->Guid.Data1  = DataHL;\r
+  NewRec->Guid.Data2  = (UINT16) DataHH;\r
+  NewRec->Guid.Data3  = (UINT16) (DataHH >> 16);\r
+  for (Index = 0; Index < 4; Index++) {\r
+    NewRec->Guid.Data4[Index] = (UINT8) DataLL;\r
+    DataLL >>= 8;\r
+  }\r
+\r
+  for (Index = 0; Index < 4; Index++) {\r
+    NewRec->Guid.Data4[Index + 4] = (UINT8) DataLH;\r
+    DataLH >>= 8;\r
+  }\r
+  //\r
+  // Add it to the list\r
+  //\r
+  NewRec->Next  = gGuidList;\r
+  gGuidList     = NewRec;\r
+\r
+  //\r
+  // Report it\r
+  // ReportGuid (FileName, NewRec);\r
+  //\r
+  return STATUS_SUCCESS;\r
+}\r
+//\r
+// Process INF files. Look for:\r
+// FILE_GUID            = 240612B6-A063-11d4-9A3A-0090273FC14D\r
+//\r
+static\r
+STATUS\r
+ProcessINFFileGuids (\r
+  INT8    *FileName\r
+  )\r
+{\r
+  FILE    *Fptr;\r
+  INT8    Line[MAX_LINE_LEN * 2];\r
+  INT8    *Cptr;\r
+  INT8    *Cptr2;\r
+  UINT32  GuidScan[11];\r
+  UINT64  Guid64;\r
+\r
+  if ((Fptr = fopen (FileName, "r")) == NULL) {\r
+    Error (NULL, 0, 0, FileName, "could not open input file for reading");\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Read lines from the file until done\r
+  //\r
+  while (fgets (Line, sizeof (Line), Fptr) != NULL) {\r
+    Cptr = Line;\r
+    Cptr += SkipWhiteSpace (Line);\r
+    if (strncmp (Cptr, "FILE_GUID", 9) == 0) {\r
+      Cptr += 9;\r
+      Cptr += SkipWhiteSpace (Cptr);\r
+      if (*Cptr == '=') {\r
+        Cptr++;\r
+        Cptr += SkipWhiteSpace (Cptr + 1);\r
+        //\r
+        // Blank out dashes on the line.\r
+        //\r
+        for (Cptr2 = Cptr; *Cptr2; Cptr2++) {\r
+          if (*Cptr2 == '-') {\r
+            *Cptr2 = ' ';\r
+          }\r
+        }\r
+\r
+        if (sscanf (\r
+              Cptr,\r
+              "%X %X %X %X %I64X",\r
+              &GuidScan[0],\r
+              &GuidScan[1],\r
+              &GuidScan[2],\r
+              &GuidScan[3],\r
+              &Guid64\r
+              ) == 5) {\r
+          AddPkgGuid (FileName, GuidScan, &Guid64);\r
+        } else {\r
+          DebugMsg (NULL, 0, 0, FileName, "GUID scan failed");\r
+        }\r
+      }\r
+    }\r
+  }\r
+\r
+  fclose (Fptr);\r
+  return STATUS_SUCCESS;\r
+}\r
+//\r
+// Parse ('g','m','a','p','a','b','c','d')\r
+//\r
+static\r
+STATUS\r
+AddSignature (\r
+  INT8      *FileName,\r
+  INT8      *StrDef,\r
+  UINT32    SigSize\r
+  )\r
+{\r
+  SIGNATURE_RECORD  *NewRec;\r
+  INT8              *Cptr;\r
+  UINT32            Index;\r
+  BOOLEAN           Fail;\r
+\r
+  //\r
+  // Allocate memory for the new record\r
+  //\r
+  Fail    = FALSE;\r
+  NewRec  = malloc (sizeof (SIGNATURE_RECORD));\r
+  if (NewRec == NULL) {\r
+    Error (NULL, 0, 0, "memory allocation failure", NULL);\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Allocate memory to save the file name\r
+  //\r
+  NewRec->FileName = malloc (strlen (FileName) + 1);\r
+  if (NewRec->FileName == NULL) {\r
+    Error (NULL, 0, 0, "memory allocation failure", NULL);\r
+    free (NewRec);\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Fill in the fields\r
+  //\r
+  strcpy (NewRec->FileName, FileName);\r
+  NewRec->Signature.DataLen = (UINT8) SigSize;\r
+  //\r
+  // Skip to open parenthesis\r
+  //\r
+  Cptr = StrDef;\r
+  Cptr += SkipWhiteSpace (Cptr);\r
+  if (*Cptr != '(') {\r
+    Fail = TRUE;\r
+    goto Done;\r
+  }\r
+\r
+  Cptr++;\r
+  //\r
+  // Skip to first ' and start processing\r
+  //\r
+  while (*Cptr && (*Cptr != '\'')) {\r
+    Cptr++;\r
+  }\r
+\r
+  for (Index = 0; Index < SigSize; Index++) {\r
+    if (*Cptr == '\'') {\r
+      Cptr++;\r
+      NewRec->Signature.Data[Index] = (INT8) *Cptr;\r
+      //\r
+      // Skip to closing quote\r
+      //\r
+      Cptr++;\r
+      if (*Cptr != '\'') {\r
+        Fail = TRUE;\r
+        break;\r
+      }\r
+      //\r
+      // Skip over closing quote, go to next one\r
+      //\r
+      Cptr++;\r
+      while (*Cptr && (*Cptr != '\'')) {\r
+        Cptr++;\r
+      }\r
+    } else {\r
+      Fail = TRUE;\r
+      DebugMsg (NULL, 0, 0, StrDef, "failed to parse signature");\r
+      break;\r
+    }\r
+  }\r
+\r
+Done:\r
+  if (Fail) {\r
+    free (NewRec->FileName);\r
+    free (NewRec);\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  NewRec->Next    = gSignatureList;\r
+  gSignatureList  = NewRec;\r
+  return STATUS_SUCCESS;\r
+}\r
+//\r
+// Look for:\r
+// #define POOL_HEAD_SIGNATURE         EFI_SIGNATURE_16('p','h')\r
+// #define GCD_MEMORY_MAP_SIGNATURE    EFI_SIGNATURE_32('g','m','a','p')\r
+// #define GCD_MEMORY_MAP_SIGNATURE    EFI_SIGNATURE_64('g','m','a','p','a','b','c','d')\r
+//\r
+static\r
+STATUS\r
+ProcessCFileSigs (\r
+  INT8    *FileName\r
+  )\r
+{\r
+  FILE    *Fptr;\r
+  INT8    Line[MAX_LINE_LEN * 2];\r
+  INT8    *Cptr;\r
+  UINT32  Len;\r
+  UINT32  LineLen;\r
+\r
+  if ((Fptr = fopen (FileName, "r")) == NULL) {\r
+    Error (NULL, 0, 0, FileName, "could not open input file for reading");\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Read lines from the file until done\r
+  //\r
+  while (fgets (Line, sizeof (Line), Fptr) != NULL) {\r
+    Cptr = Line;\r
+    Cptr += SkipWhiteSpace (Line);\r
+    //\r
+    // look for #define xxxGUIDxxx value\r
+    //\r
+    if (*Cptr == '#') {\r
+      Cptr++;\r
+      Cptr += SkipWhiteSpace (Cptr);\r
+      //\r
+      // Look for "define"\r
+      //\r
+      if (!strncmp (Cptr, "define", 6)) {\r
+        Cptr += 6;\r
+        //\r
+        // Better be whitespace\r
+        //\r
+        Len = SkipWhiteSpace (Cptr);\r
+        if (Len) {\r
+          Cptr += Len;\r
+          //\r
+          // See if it's a valid symbol name\r
+          //\r
+          Len = ValidSymbolName (Cptr);\r
+          if (Len) {\r
+            //\r
+            // It is a valid symbol name. See if there's a line continuation,\r
+            // and if so, read one more line.\r
+            // Skip over the symbol name and look for the string "EFI_SIGNATURE_xx"\r
+            //\r
+            LineLen = strlen (Line);\r
+            if ((Line[LineLen - 1] == '\n') && (Line[LineLen - 2] == '\\')) {\r
+              fgets (Line + LineLen - 2, sizeof (Line) - LineLen, Fptr);\r
+            } else if (Line[LineLen - 1] == '\\') {\r
+              fgets (Line + LineLen - 1, sizeof (Line) - LineLen, Fptr);\r
+            }\r
+\r
+            Cptr += Len;\r
+            Cptr += SkipWhiteSpace (Cptr);\r
+            if (strncmp (Cptr, "EFI_SIGNATURE_16", 16) == 0) {\r
+              AddSignature (FileName, Cptr + 16, 2);\r
+            } else if (strncmp (Cptr, "EFI_SIGNATURE_32", 16) == 0) {\r
+              AddSignature (FileName, Cptr + 16, 4);\r
+            } else if (strncmp (Cptr, "EFI_SIGNATURE_64", 16) == 0) {\r
+              AddSignature (FileName, Cptr + 16, 8);\r
+            }\r
+          }\r
+        }\r
+      }\r
+    }\r
+  }\r
+\r
+  fclose (Fptr);\r
+  return STATUS_SUCCESS;\r
+}\r
+//\r
+// look for #define xxxGUIDyyy { 0x...}\r
+// xxx EFI_GUID  GuidName = { 0x... };\r
+//\r
+static\r
+STATUS\r
+ProcessCFileGuids (\r
+  INT8    *FileName\r
+  )\r
+{\r
+  FILE    *Fptr;\r
+  INT8    Line[MAX_LINE_LEN * 2];\r
+  INT8    *Cptr;\r
+  INT8    CSave;\r
+  INT8    *CSavePtr;\r
+  INT8    *TempCptr;\r
+  INT8    *SymName;\r
+  UINT32  Len;\r
+  UINT32  LineLen;\r
+  UINT32  GuidScan[11];\r
+\r
+  if ((Fptr = fopen (FileName, "r")) == NULL) {\r
+    Error (NULL, 0, 0, FileName, "could not open input file for reading");\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Read lines from the file until done\r
+  //\r
+  while (fgets (Line, sizeof (Line), Fptr) != NULL) {\r
+    Cptr = Line;\r
+    Cptr += SkipWhiteSpace (Line);\r
+    //\r
+    // look for #define xxxGUIDxxx value\r
+    //\r
+    if (*Cptr == '#') {\r
+      Cptr++;\r
+      Cptr += SkipWhiteSpace (Cptr);\r
+      //\r
+      // Look for "define"\r
+      //\r
+      if (!strncmp (Cptr, "define", 6)) {\r
+        Cptr += 6;\r
+        //\r
+        // Better be whitespace\r
+        //\r
+        Len = SkipWhiteSpace (Cptr);\r
+        if (Len) {\r
+          Cptr += Len;\r
+          //\r
+          // See if it's a valid symbol name\r
+          //\r
+          Len = ValidSymbolName (Cptr);\r
+          if (Len) {\r
+            //\r
+            // It is a valid symbol name. See if there's a line continuation,\r
+            // and if so, read one more line.\r
+            // Then truncate after the symbol name, look for the string "GUID",\r
+            // and continue.\r
+            //\r
+            SymName = Cptr;\r
+            LineLen = strlen (Line);\r
+            if ((Line[LineLen - 1] == '\n') && (Line[LineLen - 2] == '\\')) {\r
+              fgets (Line + LineLen - 2, sizeof (Line) - LineLen, Fptr);\r
+            } else if (Line[LineLen - 1] == '\\') {\r
+              fgets (Line + LineLen - 1, sizeof (Line) - LineLen, Fptr);\r
+            }\r
+\r
+            CSavePtr  = Cptr + Len;\r
+            CSave     = *CSavePtr;\r
+            *CSavePtr = 0;\r
+            while (*Cptr) {\r
+              if (strncmp (Cptr, "GUID", 4) == 0) {\r
+                break;\r
+              }\r
+\r
+              Cptr++;\r
+            }\r
+            //\r
+            // If we didn't run out of string, then we found the GUID string.\r
+            // Now look for { 0x....... }\r
+            //\r
+            if (*Cptr) {\r
+              Cptr      = CSavePtr;\r
+              *CSavePtr = CSave;\r
+              Cptr += SkipWhiteSpace (Cptr);\r
+              if (*Cptr == '{') {\r
+                *Cptr = 0;\r
+                Cptr++;\r
+                //\r
+                // 0x665E3FF6, 0x46CC, 0x11d4, 0x9A, 0x38, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0x4D }\r
+                // If you have one suffixed with "L", then it doesn't work. So hack off 'L' characters\r
+                // in the string.\r
+                //\r
+                for (TempCptr = Cptr; *TempCptr; TempCptr++) {\r
+                  if (*TempCptr == 'L') {\r
+                    if (*(TempCptr + 1) == ',') {\r
+                      *TempCptr       = ',';\r
+                      *(TempCptr + 1) = ' ';\r
+                    }\r
+                  }\r
+                }\r
+\r
+                if (sscanf (\r
+                      Cptr,\r
+                      "%X, %X, %X, %X, %X, %X, %X, %X, %X, %X, %X",\r
+                      &GuidScan[0],\r
+                      &GuidScan[1],\r
+                      &GuidScan[2],\r
+                      &GuidScan[3],\r
+                      &GuidScan[4],\r
+                      &GuidScan[5],\r
+                      &GuidScan[6],\r
+                      &GuidScan[7],\r
+                      &GuidScan[8],\r
+                      &GuidScan[9],\r
+                      &GuidScan[10]\r
+                      ) == 11) {\r
+                  AddGuid11 (FileName, GuidScan, SymName);\r
+                }\r
+              }\r
+            }\r
+          }\r
+        }\r
+      }\r
+      //\r
+      // Else look for "static EFI_GUID xxxGUIDxxx = { 0x.... };\r
+      //\r
+    } else if ((CSavePtr = strstr (Line, "EFI_GUID")) != NULL) {\r
+      //\r
+      // Read the next line if line continuation\r
+      //\r
+      LineLen = strlen (Line);\r
+      if ((Line[LineLen - 1] == '\n') && (Line[LineLen - 2] == '\\')) {\r
+        fgets (Line + LineLen - 2, sizeof (Line) - LineLen, Fptr);\r
+      } else if (Line[LineLen - 1] == '\\') {\r
+        fgets (Line + LineLen - 1, sizeof (Line) - LineLen, Fptr);\r
+      }\r
+\r
+      Cptr = CSavePtr + 8;\r
+      Cptr += SkipWhiteSpace (Cptr);\r
+      //\r
+      // Should be variable name next\r
+      //\r
+      Len     = ValidSymbolName (Cptr);\r
+      SymName = Cptr;\r
+      Cptr += Len;\r
+      Cptr += SkipWhiteSpace (Cptr);\r
+      if (*Cptr == '=') {\r
+        Cptr++;\r
+        Cptr += SkipWhiteSpace (Cptr);\r
+        //\r
+        // Should be open-brace next to define guid\r
+        //\r
+        if (*Cptr == '{') {\r
+          Cptr++;\r
+          //\r
+          // 0x665E3FF6, 0x46CC, 0x11d4, 0x9A, 0x38, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0x4D }\r
+          //\r
+          if (sscanf (\r
+                Cptr,\r
+                "%X, %X, %X, %X, %X, %X, %X, %X, %X, %X, %X",\r
+                &GuidScan[0],\r
+                &GuidScan[1],\r
+                &GuidScan[2],\r
+                &GuidScan[3],\r
+                &GuidScan[4],\r
+                &GuidScan[5],\r
+                &GuidScan[6],\r
+                &GuidScan[7],\r
+                &GuidScan[8],\r
+                &GuidScan[9],\r
+                &GuidScan[10]\r
+                ) == 11) {\r
+            AddGuid11 (FileName, GuidScan, Cptr);\r
+            //\r
+            // printf ("Found guid: %s", Cptr);\r
+            //\r
+          }\r
+        }\r
+      }\r
+    }\r
+  }\r
+\r
+  fclose (Fptr);\r
+  return STATUS_SUCCESS;\r
+}\r
+//\r
+// Process Intel Itanium(TM) GUID definitions. Look for:\r
+// #define Cs870MemoryTestPEIMGuidL 0x9C2403386E1C8FAA\r
+// #define Cs870MemoryTestPEIMGuidH 0xE89E95C6180342f0\r
+// in either order.\r
+// This function assumes no blank lines between definitions.\r
+//\r
+static\r
+STATUS\r
+ProcessIA64FileGuids (\r
+  INT8    *FileName\r
+  )\r
+{\r
+  FILE    *Fptr;\r
+  INT8    Line[MAX_LINE_LEN];\r
+  UINT32  Guid1H;\r
+  UINT32  Guid1L;\r
+  UINT32  Guid2H;\r
+  UINT32  Guid2L;\r
+  INT8    SymName1[MAX_LINE_LEN];\r
+  INT8    SymName2[MAX_LINE_LEN];\r
+  BOOLEAN Done;\r
+  BOOLEAN LowFirst;\r
+  BOOLEAN FoundLow;\r
+\r
+  if ((Fptr = fopen (FileName, "r")) == NULL) {\r
+    Error (NULL, 0, 0, FileName, "could not open input file for reading");\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  Done = FALSE;\r
+  if (fgets (Line, sizeof (Line), Fptr) == NULL) {\r
+    Done = 1;\r
+  }\r
+  //\r
+  // Read lines from the file until done. Since the guid definition takes\r
+  // two lines, we read lines in different places to recover gracefully\r
+  // from mismatches. For example, if you thought you found the first half,\r
+  // but the next line had a symbol mismatch, then you have to process the\r
+  // line again in case it's the start of a new definition.\r
+  //\r
+  while (!Done) {\r
+    //\r
+    // Check current line for GUID definition. Assume low define first.\r
+    //\r
+    if (IsIA64GuidLine (Line, &Guid1H, &Guid1L, &FoundLow, SymName1)) {\r
+      //\r
+      // Might have to swap guids later. Save off if we found the LOW first\r
+      //\r
+      if (FoundLow) {\r
+        LowFirst = TRUE;\r
+      } else {\r
+        LowFirst = FALSE;\r
+      }\r
+      //\r
+      // Read the next line and try for the rest of the guid definition\r
+      //\r
+      if (fgets (Line, sizeof (Line), Fptr) == NULL) {\r
+        Done = 1;\r
+      } else {\r
+        if (IsIA64GuidLine (Line, &Guid2H, &Guid2L, &FoundLow, SymName2)) {\r
+          //\r
+          // Found another. If the symbol names match, then save it off.\r
+          //\r
+          if (strcmp (SymName1, SymName2) == 0) {\r
+            //\r
+            // Yea, found one. Save it off.\r
+            //\r
+            if (LowFirst) {\r
+              AddGuid64x2 (FileName, Guid2H, Guid2L, Guid1H, Guid1L);\r
+            } else {\r
+              AddGuid64x2 (FileName, Guid1H, Guid1L, Guid2H, Guid2L);\r
+            }\r
+            //\r
+            // Read the next line for processing\r
+            //\r
+            if (fgets (Line, sizeof (Line), Fptr) == NULL) {\r
+              Done = 1;\r
+            }\r
+          } else {\r
+            //\r
+            // Don't get another line so that we reprocess this line in case it\r
+            // contains the start of a new definition.\r
+            // fprintf (stdout, "Symbol name mismatch: %s: %s != %s\n",\r
+            //    FileName, SymName1, SymName2);\r
+            //\r
+          }\r
+        } else {\r
+          //\r
+          // Second line was not a guid definition. Get the next line from the\r
+          // file.\r
+          //\r
+          if (fgets (Line, sizeof (Line), Fptr) == NULL) {\r
+            Done = 1;\r
+          }\r
+        }\r
+      }\r
+    } else {\r
+      //\r
+      // Not a guid define line. Next.\r
+      //\r
+      if (fgets (Line, sizeof (Line), Fptr) == NULL) {\r
+        Done = 1;\r
+      }\r
+    }\r
+  }\r
+\r
+  fclose (Fptr);\r
+  return STATUS_SUCCESS;\r
+}\r
+//\r
+// Given a line from an Itanium-based assembly file, check the line for a guid\r
+// defininition. One of either:\r
+// #define Cs870MemoryTestPEIMGuidL 0x9C2403386E1C8FAA\r
+// #define Cs870MemoryTestPEIMGuidH 0xE89E95C6180342f0\r
+// Return the defined value as two 32-bit values, and whether it's a high\r
+// or low guid.\r
+//\r
+static\r
+BOOLEAN\r
+IsIA64GuidLine (\r
+  INT8      *Line,\r
+  UINT32    *GuidHigh,\r
+  UINT32    *GuidLow,\r
+  BOOLEAN   *FoundLow,\r
+  INT8      *SymName\r
+  )\r
+{\r
+  INT8    *Cptr;\r
+  INT8    CSave;\r
+  INT8    *CSavePtr;\r
+  INT8    *SymStart;\r
+  UINT32  Len;\r
+\r
+  Cptr = Line;\r
+  Cptr += SkipWhiteSpace (Cptr);\r
+  //\r
+  // look for #define xxxGUID[L|H] 0xHexValue\r
+  //\r
+  if (*Cptr == '#') {\r
+    Cptr++;\r
+    Cptr += SkipWhiteSpace (Cptr);\r
+    //\r
+    // Look for "define"\r
+    //\r
+    if (!strncmp (Cptr, "define", 6)) {\r
+      Cptr += 6;\r
+      //\r
+      // Better be whitespace\r
+      //\r
+      Len = SkipWhiteSpace (Cptr);\r
+      if (Len) {\r
+        Cptr += Len;\r
+        //\r
+        // See if it's a valid symbol name\r
+        //\r
+        Len = ValidSymbolName (Cptr);\r
+        if (Len) {\r
+          //\r
+          // Save the start so we can copy it to their string if later checks are ok\r
+          //\r
+          SymStart = Cptr;\r
+          //\r
+          // It is a valid symbol name, look for the string GuidL or GuidH\r
+          //\r
+          CSavePtr  = Cptr + Len;\r
+          CSave     = *CSavePtr;\r
+          *CSavePtr = 0;\r
+          while (*Cptr) {\r
+            if (strncmp (Cptr, "GuidL", 5) == 0) {\r
+              *FoundLow = 1;\r
+              break;\r
+            } else if (strncmp (Cptr, "GuidH", 5) == 0) {\r
+              *FoundLow = 0;\r
+              break;\r
+            }\r
+\r
+            Cptr++;\r
+          }\r
+          //\r
+          // If we didn't run out of string, then we found the GUID string.\r
+          // Restore the null character we inserted above and continue.\r
+          // Now look for  0x.......\r
+          //\r
+          if (*Cptr) {\r
+            //\r
+            // Return symbol name less the "L" or "H"\r
+            //\r
+            strcpy (SymName, SymStart);\r
+            SymName[strlen (SymName) - 1] = 0;\r
+            Cptr                          = CSavePtr;\r
+            *CSavePtr                     = CSave;\r
+            Cptr += SkipWhiteSpace (Cptr);\r
+            if ((*Cptr == '0') && (*(Cptr + 1) == 'x')) {\r
+              //\r
+              // skip over "0x"\r
+              //\r
+              Cptr += 2;\r
+              //\r
+              // 0x0123456789ABCDEF -- null terminate after 8 characters,\r
+              // scan, replace the character and scan at that point.\r
+              //\r
+              CSave       = *(Cptr + 8);\r
+              *(Cptr + 8) = 0;\r
+              if (sscanf (Cptr, "%X", GuidHigh) == 1) {\r
+                *(Cptr + 8) = CSave;\r
+                if (sscanf (Cptr + 8, "%X", GuidLow) == 1) {\r
+                  return TRUE;\r
+                }\r
+              }\r
+            }\r
+          }\r
+        }\r
+      }\r
+    }\r
+  }\r
+\r
+  return FALSE;\r
+}\r
+//\r
+// Look at the characters in the string and determine if it's a valid\r
+// symbol name. Basically [a-zA-Z_][a-zA-Z_0-9]*\r
+//\r
+static\r
+UINT32\r
+ValidSymbolName (\r
+  INT8    *Name\r
+  )\r
+{\r
+  int Len;\r
+\r
+  Len = 0;\r
+\r
+  //\r
+  // Test first character\r
+  //\r
+  if (((*Name >= 'a') && (*Name <= 'z')) || ((*Name >= 'A') && (*Name <= 'Z')) || (*Name == '_')) {\r
+    Name++;\r
+    Len = 1;\r
+    while (*Name) {\r
+      if (((*Name >= 'a') && (*Name <= 'z')) ||\r
+          ((*Name >= 'A') && (*Name <= 'Z')) ||\r
+          ((*Name >= '0') && (*Name <= '9')) ||\r
+          (*Name == '_')\r
+          ) {\r
+        Name++;\r
+        Len++;\r
+      } else {\r
+        break;\r
+      }\r
+    }\r
+  }\r
+\r
+  return Len;\r
+}\r
+\r
+static\r
+UINT32\r
+SkipWhiteSpace (\r
+  INT8    *Str\r
+  )\r
+{\r
+  UINT32  Len;\r
+  Len = 0;\r
+  while (isspace (*Str) && *Str) {\r
+    Len++;\r
+    Str++;\r
+  }\r
+\r
+  return Len;\r
+}\r
+//\r
+// found FFS_FILEGUID=35b898ca-b6a9-49ce-8c72-904735cc49b7\r
+//\r
+static\r
+STATUS\r
+AddPkgGuid (\r
+  INT8      *FileName,\r
+  UINT32    *Data,\r
+  UINT64    *Data64\r
+  )\r
+{\r
+  GUID_RECORD *NewRec;\r
+  int         Index;\r
+\r
+  //\r
+  // Sanity check the data\r
+  //\r
+  if ((Data[1] | Data[2] | Data[3]) & 0xFFFF0000) {\r
+    Error (NULL, 0, 0, "out of range value for GUID data word(s) [1] - [3]", NULL);\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // More checks for Data64?\r
+  // Allocate memory for a new one guid structure\r
+  //\r
+  NewRec = malloc (sizeof (GUID_RECORD));\r
+  if (NewRec == NULL) {\r
+    Error (NULL, 0, 0, "memory allocation failure", NULL);\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  memset ((char *) NewRec, 0, sizeof (GUID_RECORD));\r
+  NewRec->FileName = malloc (strlen (FileName) + 1);\r
+  if (NewRec->FileName == NULL) {\r
+    free (NewRec);\r
+    Error (NULL, 0, 0, "memory allocation failure", NULL);\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  strcpy (NewRec->FileName, FileName);\r
+  NewRec->Guid.Data1    = Data[0];\r
+  NewRec->Guid.Data2    = (UINT16) Data[1];\r
+  NewRec->Guid.Data3    = (UINT16) Data[2];\r
+  NewRec->Guid.Data4[0] = (UINT8) Data[3];\r
+  NewRec->Guid.Data4[1] = (UINT8) (Data[3] >> 8);\r
+  for (Index = 2; Index < 8; Index++) {\r
+    NewRec->Guid.Data4[Index] = (UINT8) *Data64;\r
+    *Data64 >>= 8;\r
+  }\r
+  //\r
+  // Add it to the list\r
+  //\r
+  NewRec->Next  = gGuidList;\r
+  gGuidList     = NewRec;\r
+\r
+  //\r
+  // Report it\r
+  // ReportGuid (FileName, NewRec);\r
+  //\r
+  return STATUS_SUCCESS;\r
+}\r
+//\r
+// Add a guid consisting of 11 fields to our list of guids\r
+//\r
+static\r
+STATUS\r
+AddGuid11 (\r
+  INT8      *FileName,\r
+  UINT32    *Data,\r
+  INT8      *SymName\r
+  )\r
+{\r
+  GUID_RECORD *NewRec;\r
+  int         Index;\r
+\r
+  //\r
+  // Sanity check the data\r
+  //\r
+  if (!CheckGuidData (Data, 11)) {\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Allocate memory for a new one guid structure\r
+  //\r
+  NewRec = malloc (sizeof (GUID_RECORD));\r
+  if (NewRec == NULL) {\r
+    Error (NULL, 0, 0, "memory allocation failure", NULL);\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  memset ((char *) NewRec, 0, sizeof (GUID_RECORD));\r
+  NewRec->FileName = malloc (strlen (FileName) + 1);\r
+  if (NewRec->FileName == NULL) {\r
+    free (NewRec);\r
+    Error (NULL, 0, 0, "memory allocation failure", NULL);\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  strcpy (NewRec->FileName, FileName);\r
+  if (SymName != NULL) {\r
+    NewRec->SymName = malloc (strlen (SymName) + 1);\r
+    if (NewRec->SymName == NULL) {\r
+      free (NewRec);\r
+      Error (NULL, 0, 0, "memory allocation failure", NULL);\r
+      return STATUS_ERROR;\r
+    }\r
+  }\r
+\r
+  strcpy (NewRec->SymName, SymName);\r
+\r
+  NewRec->Guid.Data1  = Data[0];\r
+  NewRec->Guid.Data2  = (UINT16) Data[1];\r
+  NewRec->Guid.Data3  = (UINT16) Data[2];\r
+  for (Index = 0; Index < 8; Index++) {\r
+    NewRec->Guid.Data4[Index] = (UINT8) Data[3 + Index];\r
+  }\r
+  //\r
+  // Add it to the list\r
+  //\r
+  NewRec->Next  = gGuidList;\r
+  gGuidList     = NewRec;\r
+\r
+  //\r
+  // Report it\r
+  // ReportGuid (FileName, NewRec);\r
+  //\r
+  return STATUS_SUCCESS;\r
+}\r
+//\r
+// For debug purposes, print each guid found\r
+//\r
+// static\r
+// VOID\r
+// ReportGuid (\r
+//  INT8        *FileName,\r
+// GUID_RECORD *NewGuid\r
+//  )\r
+// {\r
+//  //fprintf (stdout, "%s: 0x%08X\n", FileName, NewGuid->Guid.Data1);\r
+// }\r
+//\r
+// Free up memory we allocated to keep track of guids defined.\r
+//\r
+static\r
+VOID\r
+FreeGuids (\r
+  VOID\r
+  )\r
+{\r
+  GUID_RECORD *NextRec;\r
+  while (gGuidList != NULL) {\r
+    NextRec = gGuidList->Next;\r
+    if (gGuidList->FileName != NULL) {\r
+      free (gGuidList->FileName);\r
+    }\r
+\r
+    if (gGuidList->SymName != NULL) {\r
+      free (gGuidList->SymName);\r
+    }\r
+\r
+    free (gGuidList);\r
+    gGuidList = NextRec;\r
+  }\r
+}\r
+\r
+static\r
+VOID\r
+FreeSigs (\r
+  VOID\r
+  )\r
+{\r
+  SIGNATURE_RECORD  *NextRec;\r
+  while (gSignatureList != NULL) {\r
+    NextRec = gSignatureList->Next;\r
+    if (gSignatureList->FileName != NULL) {\r
+      free (gSignatureList->FileName);\r
+    }\r
+\r
+    free (gSignatureList);\r
+    gSignatureList = NextRec;\r
+  }\r
+}\r
+//\r
+// Scan through all guids defined and compare each for duplicates.\r
+//\r
+static\r
+STATUS\r
+CheckDuplicates (\r
+  VOID\r
+  )\r
+{\r
+  GUID_RECORD       *CurrentFile;\r
+\r
+  GUID_RECORD       *TempFile;\r
+  SIGNATURE_RECORD  *CurrentSig;\r
+  SIGNATURE_RECORD  *TempSig;\r
+  STATUS            Status;\r
+  int               Index;\r
+  int               DupCount;\r
+  int               Len;\r
+  BOOLEAN           Same;\r
+  UINT32            GuidSum;\r
+  INT8              *SymName;\r
+\r
+  Status = STATUS_SUCCESS;\r
+\r
+  //\r
+  // If we're checking guids.....\r
+  //\r
+  if (gOptions.CheckGuids) {\r
+    //\r
+    // If -p option, print all guids found\r
+    //\r
+    if (gOptions.PrintFound) {\r
+      CurrentFile = gGuidList;\r
+      while (CurrentFile != NULL) {\r
+        fprintf (\r
+          stdout,\r
+          "GUID:  0x%08X 0x%04X 0x%04X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X %s\n",\r
+          (UINT32) CurrentFile->Guid.Data1,\r
+          (UINT32) CurrentFile->Guid.Data2,\r
+          (UINT32) CurrentFile->Guid.Data3,\r
+          (UINT32) CurrentFile->Guid.Data4[0],\r
+          (UINT32) CurrentFile->Guid.Data4[1],\r
+          (UINT32) CurrentFile->Guid.Data4[2],\r
+          (UINT32) CurrentFile->Guid.Data4[3],\r
+          (UINT32) CurrentFile->Guid.Data4[4],\r
+          (UINT32) CurrentFile->Guid.Data4[5],\r
+          (UINT32) CurrentFile->Guid.Data4[6],\r
+          (UINT32) CurrentFile->Guid.Data4[7],\r
+          CurrentFile->FileName\r
+          );\r
+        CurrentFile = CurrentFile->Next;\r
+      }\r
+    }\r
+\r
+    if (gOptions.GuidXReference) {\r
+      CurrentFile = gGuidList;\r
+      while (CurrentFile != NULL) {\r
+        //\r
+        // If no symbol name, print "unknown"\r
+        //\r
+        SymName = CurrentFile->SymName;\r
+        if (SymName == NULL) {\r
+          SymName = "unknown";\r
+        }\r
+\r
+        fprintf (\r
+          stdout,\r
+          "%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X %s\n",\r
+          (UINT32) CurrentFile->Guid.Data1,\r
+          (UINT32) CurrentFile->Guid.Data2,\r
+          (UINT32) CurrentFile->Guid.Data3,\r
+          (UINT32) CurrentFile->Guid.Data4[0],\r
+          (UINT32) CurrentFile->Guid.Data4[1],\r
+          (UINT32) CurrentFile->Guid.Data4[2],\r
+          (UINT32) CurrentFile->Guid.Data4[3],\r
+          (UINT32) CurrentFile->Guid.Data4[4],\r
+          (UINT32) CurrentFile->Guid.Data4[5],\r
+          (UINT32) CurrentFile->Guid.Data4[6],\r
+          (UINT32) CurrentFile->Guid.Data4[7],\r
+          SymName\r
+          );\r
+        CurrentFile = CurrentFile->Next;\r
+      }\r
+    }\r
+    //\r
+    // Now go through all guids and report duplicates.\r
+    //\r
+    CurrentFile = gGuidList;\r
+    while (CurrentFile != NULL) {\r
+      DupCount  = 0;\r
+      TempFile  = CurrentFile->Next;\r
+      while (TempFile) {\r
+        //\r
+        // Compare the guids\r
+        //\r
+        if ((CurrentFile->Guid.Data1 == TempFile->Guid.Data1) &&\r
+            (CurrentFile->Guid.Data2 == TempFile->Guid.Data2) &&\r
+            (CurrentFile->Guid.Data3 == TempFile->Guid.Data3)\r
+            ) {\r
+          //\r
+          // OR in all the guid bytes so we can ignore NULL-guid definitions.\r
+          //\r
+          GuidSum = CurrentFile->Guid.Data1 | CurrentFile->Guid.Data2 | CurrentFile->Guid.Data3;\r
+          Same    = TRUE;\r
+          for (Index = 0; Index < 8; Index++) {\r
+            GuidSum |= CurrentFile->Guid.Data4[Index];\r
+            if (CurrentFile->Guid.Data4[Index] != TempFile->Guid.Data4[Index]) {\r
+              Same = FALSE;\r
+              break;\r
+            }\r
+          }\r
+          //\r
+          // If they're the same, and the guid was non-zero, print a message.\r
+          //\r
+          if (Same && GuidSum) {\r
+            if (DupCount == 0) {\r
+              Error (NULL, 0, 0, "duplicate GUIDS found", NULL);\r
+              fprintf (stdout, "   FILE1: %s\n", CurrentFile->FileName);\r
+            }\r
+\r
+            DupCount++;\r
+            fprintf (stdout, "   FILE%d: %s\n", DupCount + 1, TempFile->FileName);\r
+            //\r
+            // Flag it as reported so we don't report it again if there's three or more\r
+            //\r
+            TempFile->Reported = TRUE;\r
+          }\r
+        }\r
+        //\r
+        // Next one\r
+        //\r
+        TempFile = TempFile->Next;\r
+      }\r
+      //\r
+      // Print the guid if we found duplicates\r
+      //\r
+      if (DupCount) {\r
+        fprintf (\r
+          stdout,\r
+          "   GUID:  0x%08X 0x%04X 0x%04X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X\n",\r
+          (UINT32) CurrentFile->Guid.Data1,\r
+          (UINT32) CurrentFile->Guid.Data2,\r
+          (UINT32) CurrentFile->Guid.Data3,\r
+          (UINT32) CurrentFile->Guid.Data4[0],\r
+          (UINT32) CurrentFile->Guid.Data4[1],\r
+          (UINT32) CurrentFile->Guid.Data4[2],\r
+          (UINT32) CurrentFile->Guid.Data4[3],\r
+          (UINT32) CurrentFile->Guid.Data4[4],\r
+          (UINT32) CurrentFile->Guid.Data4[5],\r
+          (UINT32) CurrentFile->Guid.Data4[6],\r
+          (UINT32) CurrentFile->Guid.Data4[7]\r
+          );\r
+        //\r
+        // return STATUS_ERROR;\r
+        //\r
+      }\r
+      //\r
+      // Find the next one that hasn't been reported\r
+      //\r
+      do {\r
+        CurrentFile = CurrentFile->Next;\r
+      } while ((CurrentFile != NULL) && (CurrentFile->Reported));\r
+    }\r
+  }\r
+\r
+  if (gOptions.CheckSignatures) {\r
+    //\r
+    // Print ones found if specified\r
+    //\r
+    if (gOptions.PrintFound) {\r
+      CurrentSig = gSignatureList;\r
+      while (CurrentSig != NULL) {\r
+        Len = CurrentSig->Signature.DataLen;\r
+        for (Index = 0; Index < Len; Index++) {\r
+          fprintf (stdout, "%c", CurrentSig->Signature.Data[Index]);\r
+        }\r
+\r
+        fprintf (stdout, "  %s\n", CurrentSig->FileName);\r
+        CurrentSig = CurrentSig->Next;\r
+      }\r
+    }\r
+\r
+    CurrentSig = gSignatureList;\r
+    while (CurrentSig != NULL) {\r
+      DupCount  = 0;\r
+      TempSig   = CurrentSig->Next;\r
+      Len       = CurrentSig->Signature.DataLen;\r
+      while (TempSig) {\r
+        //\r
+        // Check for same length, then do string compare\r
+        //\r
+        if (Len == TempSig->Signature.DataLen) {\r
+          if (strncmp (CurrentSig->Signature.Data, TempSig->Signature.Data, Len) == 0) {\r
+            //\r
+            // Print header message if first failure for this sig\r
+            //\r
+            if (DupCount == 0) {\r
+              Error (NULL, 0, 0, "duplicate signatures found", NULL);\r
+              fprintf (stdout, "   FILE1: %s\n", CurrentSig->FileName);\r
+            }\r
+\r
+            DupCount++;\r
+            fprintf (stdout, "   FILE%d: %s\n", DupCount + 1, TempSig->FileName);\r
+            TempSig->Reported = TRUE;\r
+          }\r
+        }\r
+\r
+        TempSig = TempSig->Next;\r
+      }\r
+\r
+      if (DupCount) {\r
+        fprintf (stdout, "   SIG:   ");\r
+        for (Index = 0; Index < Len; Index++) {\r
+          fprintf (stdout, "%c", CurrentSig->Signature.Data[Index]);\r
+        }\r
+\r
+        fprintf (stdout, "\n");\r
+      }\r
+      //\r
+      // On to the next one that hasn't been reported\r
+      //\r
+      do {\r
+        CurrentSig = CurrentSig->Next;\r
+      } while ((CurrentSig != NULL) && (CurrentSig->Reported));\r
+    }\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
+static\r
+VOID\r
+FreeOptions (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Free up any memory we allocated when processing command-line options.\r
+\r
+Arguments:\r
+  None.\r
+\r
+Returns:\r
+  NA\r
+\r
+Notes:\r
+  We don't free up the ->Str fields because we did not allocate them.\r
+  Instead, we just set the pointer to point to the actual parameter\r
+  from the command line.\r
+\r
+--*/\r
+{\r
+  STRING_LIST *Ptr;\r
+  while (gOptions.ExcludeDirs != NULL) {\r
+    Ptr = gOptions.ExcludeDirs->Next;\r
+    //\r
+    // free (gOptions.ExcludeDirs->Str);\r
+    //\r
+    free (gOptions.ExcludeDirs);\r
+    gOptions.ExcludeDirs = Ptr;\r
+  }\r
+\r
+  while (gOptions.ExcludeSubDirs != NULL) {\r
+    Ptr = gOptions.ExcludeSubDirs->Next;\r
+    //\r
+    // free (gOptions.ExcludeSubDirs->Str);\r
+    //\r
+    free (gOptions.ExcludeSubDirs);\r
+    gOptions.ExcludeSubDirs = Ptr;\r
+  }\r
+\r
+  while (gOptions.ExcludeExtensions != NULL) {\r
+    Ptr = gOptions.ExcludeExtensions->Next;\r
+    //\r
+    // free (gOptions.ExcludeExtensions->Str);\r
+    //\r
+    free (gOptions.ExcludeExtensions);\r
+    gOptions.ExcludeExtensions = Ptr;\r
+  }\r
+\r
+  while (gOptions.ExcludeFiles != NULL) {\r
+    Ptr = gOptions.ExcludeFiles->Next;\r
+    //\r
+    // free (gOptions.ExcludeFiles->Str);\r
+    //\r
+    free (gOptions.ExcludeFiles);\r
+    gOptions.ExcludeFiles = Ptr;\r
+  }\r
+}\r
+//\r
+// Given an array of 32-bit data, validate the data for the given number of\r
+// guid data. For example, it might have been scanned as 16 bytes of data, or\r
+// 11 fields of data.\r
+//\r
+static\r
+BOOLEAN\r
+CheckGuidData (\r
+  UINT32    *Data,\r
+  UINT32    DataCount\r
+  )\r
+{\r
+  UINT32  Index;\r
+\r
+  if (DataCount == 16) {\r
+    for (Index = 0; Index < 16; Index++) {\r
+      if (Data[Index] &~0xFF) {\r
+        return FALSE;\r
+      }\r
+    }\r
+\r
+    return TRUE;\r
+  } else if (DataCount == 11) {\r
+    //\r
+    // Data[0] never out of range (32-bit)\r
+    //\r
+    if ((Data[1] | Data[2]) &~0xFFFF) {\r
+      //\r
+      // Error ("Out of range value for GUID data word(s) [1] and/or [2]");\r
+      //\r
+      return FALSE;\r
+    }\r
+\r
+    for (Index = 0; Index < 8; Index++) {\r
+      if (Data[Index + 3] &~0xFF) {\r
+        //\r
+        // Error ("Out of range value for GUID data byte(s) [4] - [11]");\r
+        //\r
+        return FALSE;\r
+      }\r
+    }\r
+\r
+    return TRUE;\r
+  }\r
+\r
+  return FALSE;\r
+}\r
diff --git a/Tools/CodeTools/Source/GuidChk/GuidList.c b/Tools/CodeTools/Source/GuidChk/GuidList.c
new file mode 100644 (file)
index 0000000..bb6a44d
--- /dev/null
@@ -0,0 +1,186 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  GuidList.c  \r
+\r
+Abstract:\r
+\r
+  Utility to create a GUID-to-name listing file that can\r
+  be used by other utilities. Basic operation is to take the\r
+  table of name+GUIDs that we have compiled into this utility,\r
+  and create a text file that can be parsed by other utilities\r
+  to do replacement of "name" with "GUID".\r
+\r
+Notes:\r
+  To add a new GUID to this database:\r
+    1. Add a "#include EFI_GUID_DEFINITION(name)" statement below\r
+    2. Modify the mGuidList[] array below to add the new GUID name\r
+\r
+  The only issue that may come up is that, if the source GUID file\r
+  is not in the standard GUID directory, then this utility won't\r
+  compile because the #include fails. In this case you'd need\r
+  to define a new macro (if it's in a standard place) or modify\r
+  this utility's makefile to add the path to your new .h file.\r
+\r
+--*/\r
+\r
+#include <stdio.h>\r
+#include <string.h>\r
+#include <stdlib.h>\r
+#include <ctype.h>\r
+\r
+#include <Common/UefiBaseTypes.h>\r
+#include <Guid/Apriori.h>\r
+#include <Guid/AcpiTableStorage.h>\r
+\r
+#include "EfiUtilityMsgs.h"\r
+\r
+\r
+#define GUID_XREF(varname, guid) { \\r
+    #varname, #guid, guid \\r
+  }\r
+\r
+#define NULL_GUID \\r
+  { \\r
+    0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 \\r
+  }\r
+\r
+typedef struct {\r
+  INT8      *VariableName;\r
+  INT8      *DefineName;\r
+  EFI_GUID  Guid;\r
+} GUID_LIST;\r
+\r
+//\r
+// This is our table of all GUIDs we want to print out to create\r
+// a GUID-to-name cross reference.\r
+// Use the #defined name from the GUID definition's source .h file.\r
+//\r
+static GUID_LIST  mGuidList[] = {\r
+  GUID_XREF(gAprioriGuid, EFI_APRIORI_GUID),\r
+  GUID_XREF(gEfiAcpiTableStorageGuid, EFI_ACPI_TABLE_STORAGE_GUID),\r
+  // FIXME The next line was removed in the port to R9.\r
+  // GUID_XREF(gEfiDefaultBmpLogoGuid, EFI_DEFAULT_BMP_LOGO_GUID),\r
+  GUID_XREF(gEfiAcpiTableStorageGuid, EFI_ACPI_TABLE_STORAGE_GUID),\r
+  //\r
+  // Terminator\r
+  //\r
+  {\r
+    NULL,\r
+    NULL,\r
+    NULL_GUID\r
+  }\r
+};\r
+\r
+void\r
+PrintGuidText (\r
+  FILE      *OutFptr,\r
+  INT8      *VariableName,\r
+  INT8      *DefineName,\r
+  EFI_GUID  *Guid\r
+  );\r
+\r
+int\r
+CreateGuidList (\r
+  INT8    *OutFileName\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Print our GUID/name list to the specified output file.\r
+  \r
+Arguments:\r
+  OutFileName  - name of the output file to write our results to.\r
+\r
+Returns:\r
+  0       if successful\r
+  nonzero otherwise\r
+  \r
+--*/\r
+{\r
+  FILE  *OutFptr;\r
+  int   Index;\r
+\r
+  //\r
+  // Open output file for writing. If the name is NULL, then write to stdout\r
+  //\r
+  if (OutFileName != NULL) {\r
+    OutFptr = fopen (OutFileName, "w");\r
+    if (OutFptr == NULL) {\r
+      Error (NULL, 0, 0, OutFileName, "failed to open output file for writing");\r
+      return STATUS_ERROR;\r
+    }\r
+  } else {\r
+    OutFptr = stdout;\r
+  }\r
+\r
+  for (Index = 0; mGuidList[Index].VariableName != NULL; Index++) {\r
+    PrintGuidText (OutFptr, mGuidList[Index].VariableName, mGuidList[Index].DefineName, &mGuidList[Index].Guid);\r
+  }\r
+  //\r
+  // Close the output file if they specified one.\r
+  //\r
+  if (OutFileName != NULL) {\r
+    fclose (OutFptr);\r
+  }\r
+\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+void\r
+PrintGuidText (\r
+  FILE      *OutFptr,\r
+  INT8      *VariableName,\r
+  INT8      *DefineName,\r
+  EFI_GUID  *Guid\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Print a GUID/name combo in INF-style format\r
+\r
+  guid-guid-guid-guid DEFINE_NAME gName\r
+\r
+Arguments:\r
+  OutFptr       - file pointer to which to write the output\r
+  VariableName  - the GUID variable's name\r
+  DefineName    - the name used in the #define\r
+  Guid          - pointer to the GUID value\r
+\r
+Returns:\r
+  NA\r
+\r
+--*/\r
+{\r
+  if (OutFptr == NULL) {\r
+    OutFptr = stdout;\r
+  }\r
+\r
+  fprintf (\r
+    OutFptr,\r
+    "%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X %s %s\n",\r
+    Guid->Data1,\r
+    Guid->Data2,\r
+    Guid->Data3,\r
+    Guid->Data4[0],\r
+    Guid->Data4[1],\r
+    Guid->Data4[2],\r
+    Guid->Data4[3],\r
+    Guid->Data4[4],\r
+    Guid->Data4[5],\r
+    Guid->Data4[6],\r
+    Guid->Data4[7],\r
+    DefineName,\r
+    VariableName\r
+    );\r
+}\r
diff --git a/Tools/CodeTools/Source/GuidChk/UtilsMsgs.c b/Tools/CodeTools/Source/GuidChk/UtilsMsgs.c
new file mode 100644 (file)
index 0000000..8aa343f
--- /dev/null
@@ -0,0 +1,490 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:  \r
+\r
+  UtilsMsgs.c\r
+  \r
+Abstract:\r
+\r
+  EFI tools utility functions to display warning, error, and informational\r
+  messages.\r
+  \r
+--*/\r
+\r
+#include <stdio.h>\r
+#include <string.h>\r
+#include <ctype.h>\r
+#include <stdarg.h>\r
+\r
+#include <Common/UefiBaseTypes.h>\r
+\r
+#include "EfiUtilityMsgs.h"\r
+\r
+#define MAX_LINE_LEN  200\r
+\r
+//\r
+// Declare module globals for keeping track of the the utility's\r
+// name and other settings.\r
+//\r
+static STATUS mStatus             = STATUS_SUCCESS;\r
+static INT8   mUtilityName[50]    = { 0 };\r
+static INT8   *mSourceFileName    = NULL;\r
+static UINT32 mSourceFileLineNum  = 0;\r
+static UINT32 mErrorCount         = 0;\r
+static UINT32 mWarningCount       = 0;\r
+static UINT32 mDebugMsgMask       = 0;\r
+\r
+static\r
+void\r
+PrintMessage (\r
+  INT8    *Type,\r
+  INT8    *FileName,\r
+  UINT32  LineNumber,\r
+  UINT32  MessageCode,\r
+  INT8    *Text,\r
+  INT8    *MsgFmt,\r
+  va_list List\r
+  );\r
+\r
+void\r
+Error (\r
+  INT8    *FileName,\r
+  UINT32  LineNumber,\r
+  UINT32  MessageCode,\r
+  INT8    *Text,\r
+  INT8    *MsgFmt,\r
+  ...\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Prints an error message.\r
+  \r
+Arguments:\r
+  All arguments are optional, though the printed message may be useless if\r
+  at least something valid is not specified.\r
+  \r
+  FileName - name of the file or application. If not specified, then the\r
+             utilty name (as set by the utility calling SetUtilityName()\r
+             earlier) is used. Otherwise "Unknown utility" is used.\r
+  \r
+  LineNumber - the line number of error, typically used by parsers. If the\r
+               utility is not a parser, then 0 should be specified. Otherwise\r
+               the FileName and LineNumber info can be used to cause\r
+               MS Visual Studio to jump to the error.\r
+               \r
+  MessageCode - an application-specific error code that can be referenced in\r
+              other documentation. \r
+\r
+  Text        - the text in question, typically used by parsers.\r
+  \r
+  MsgFmt - the format string for the error message. Can contain formatting\r
+           controls for use with the varargs.\r
+           \r
+Returns:\r
+  None.\r
+  \r
+Notes:\r
+  We print the following (similar to the Warn() and Debug() \r
+  W\r
+  Typical error/warning message format:\r
+\r
+  bin\VfrCompile.cpp(330) : error C2660: 'AddVfrDataStructField' : function does not take 2 parameters\r
+\r
+  BUGBUG -- these three utility functions are almost identical, and\r
+  should be modified to share code.\r
+\r
+  Visual Studio does not find error messages with:\r
+  \r
+     " error :"\r
+     " error 1:"\r
+     " error c1:"\r
+     " error 1000:"\r
+     " error c100:"\r
+\r
+  It does find:\r
+     " error c1000:"     \r
+--*/\r
+{\r
+  va_list List;\r
+  mErrorCount++;\r
+  va_start (List, MsgFmt);\r
+  PrintMessage ("error", FileName, LineNumber, MessageCode, Text, MsgFmt, List);\r
+  va_end (List);\r
+  //\r
+  // Set status accordingly\r
+  //\r
+  if (mStatus < STATUS_ERROR) {\r
+    mStatus = STATUS_ERROR;\r
+  }\r
+}\r
+\r
+void\r
+ParserError (\r
+  UINT32  MessageCode,\r
+  INT8    *Text,\r
+  INT8    *MsgFmt,\r
+  ...\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Print a parser error, using the source file name and line number\r
+  set by a previous call to SetParserPosition().\r
+\r
+Arguments:\r
+  MessageCode   - application-specific error code\r
+  Text          - text to print in the error message\r
+  MsgFmt        - format string to print at the end of the error message\r
+  ...\r
+\r
+Returns:\r
+  NA\r
+\r
+--*/\r
+{\r
+  va_list List;\r
+  mErrorCount++;\r
+  va_start (List, MsgFmt);\r
+  PrintMessage ("error", mSourceFileName, mSourceFileLineNum, MessageCode, Text, MsgFmt, List);\r
+  va_end (List);\r
+  //\r
+  // Set status accordingly\r
+  //\r
+  if (mStatus < STATUS_ERROR) {\r
+    mStatus = STATUS_ERROR;\r
+  }\r
+}\r
+\r
+void\r
+ParserWarning (\r
+  UINT32  ErrorCode,\r
+  INT8    *OffendingText,\r
+  INT8    *MsgFmt,\r
+  ...\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Print a parser warning, using the source file name and line number\r
+  set by a previous call to SetParserPosition().\r
+\r
+Arguments:\r
+  ErrorCode     - application-specific error code\r
+  OffendingText - text to print in the warning message\r
+  MsgFmt        - format string to print at the end of the warning message\r
+  ...\r
+\r
+Returns:\r
+  NA\r
+\r
+--*/\r
+{\r
+  va_list List;\r
+  mWarningCount++;\r
+  va_start (List, MsgFmt);\r
+  PrintMessage ("warning", mSourceFileName, mSourceFileLineNum, ErrorCode, OffendingText, MsgFmt, List);\r
+  va_end (List);\r
+  //\r
+  // Set status accordingly\r
+  //\r
+  if (mStatus < STATUS_WARNING) {\r
+    mStatus = STATUS_WARNING;\r
+  }\r
+}\r
+\r
+void\r
+Warning (\r
+  INT8    *FileName,\r
+  UINT32  LineNumber,\r
+  UINT32  MessageCode,\r
+  INT8    *Text,\r
+  INT8    *MsgFmt,\r
+  ...\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Print a warning message.\r
+\r
+Arguments:\r
+  FileName    - name of the file where the warning was detected, or the name\r
+                of the application that detected the warning\r
+  \r
+  LineNumber  - the line number where the warning was detected (parsers).\r
+                0 should be specified if the utility is not a parser.\r
+               \r
+  MessageCode - an application-specific warning code that can be referenced in\r
+                other documentation. \r
+\r
+  Text        - the text in question (parsers)\r
+  \r
+  MsgFmt      - the format string for the warning message. Can contain formatting\r
+                controls for use with varargs.\r
+                \r
+  ...\r
+           \r
+Returns:\r
+  None.\r
+\r
+--*/\r
+{\r
+  va_list List;\r
+  mWarningCount++;\r
+  va_start (List, MsgFmt);\r
+  PrintMessage ("warning", FileName, LineNumber, MessageCode, Text, MsgFmt, List);\r
+  va_end (List);\r
+  //\r
+  // Set status accordingly\r
+  //\r
+  if (mStatus < STATUS_WARNING) {\r
+    mStatus = STATUS_WARNING;\r
+  }\r
+}\r
+\r
+void\r
+DebugMsg (\r
+  INT8    *FileName,\r
+  UINT32  LineNumber,\r
+  UINT32  MsgMask,\r
+  INT8    *Text,\r
+  INT8    *MsgFmt,\r
+  ...\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Print a warning message.\r
+\r
+Arguments:\r
+  FileName    - typically the name of the utility printing the debug message, but\r
+                can be the name of a file being parsed.\r
+  \r
+  LineNumber  - the line number in FileName (parsers) \r
+               \r
+  MsgMask     - an application-specific bitmask that, in combination with mDebugMsgMask,\r
+                determines if the debug message gets printed.\r
+\r
+  Text        - the text in question (parsers)\r
+  \r
+  MsgFmt      - the format string for the debug message. Can contain formatting\r
+                controls for use with varargs.\r
+          \r
+  ... \r
+Returns:\r
+  None.\r
+\r
+--*/\r
+{\r
+  va_list List;\r
+  //\r
+  // If the debug mask is not applicable, then do nothing.\r
+  //\r
+  if ((MsgMask != 0) && ((mDebugMsgMask & MsgMask) == 0)) {\r
+    return ;\r
+  }\r
+\r
+  va_start (List, MsgFmt);\r
+  PrintMessage ("debug", FileName, LineNumber, 0, Text, MsgFmt, List);\r
+  va_end (List);\r
+}\r
+\r
+static\r
+void\r
+PrintMessage (\r
+  INT8    *Type,\r
+  INT8    *FileName,\r
+  UINT32  LineNumber,\r
+  UINT32  MessageCode,\r
+  INT8    *Text,\r
+  INT8    *MsgFmt,\r
+  va_list List\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Worker routine for all the utility printing services. Prints the message in\r
+  a format that Visual Studio will find when scanning build outputs for\r
+  errors or warnings.\r
+\r
+Arguments:\r
+  Type        - "warning" or "error" string to insert into the message to be\r
+                printed. The first character of this string (converted to uppercase)\r
+                is used to preceed the MessageCode value in the output string.\r
+\r
+  FileName    - name of the file where the warning was detected, or the name\r
+                of the application that detected the warning\r
+  \r
+  LineNumber  - the line number where the warning was detected (parsers).\r
+                0 should be specified if the utility is not a parser.\r
+               \r
+  MessageCode - an application-specific warning code that can be referenced in\r
+                other documentation. \r
+\r
+  Text        - part of the message to print\r
+  \r
+  MsgFmt      - the format string for the message. Can contain formatting\r
+                controls for use with varargs.\r
+\r
+  List        - Variable function parameter list.           \r
+Returns:\r
+  None.\r
+\r
+Notes:\r
+  If FileName == NULL then this utility will use the string passed into SetUtilityName(). \r
+  \r
+  LineNumber is only used if the caller is a parser, in which case FileName refers to the\r
+  file being parsed.\r
+\r
+  Text and MsgFmt are both optional, though it would be of little use calling this function with\r
+  them both NULL.\r
+\r
+  Output will typically be of the form:\r
+    <FileName>(<LineNumber>) : <Type> <Type[0]><MessageCode>: <Text> : <MsgFmt>\r
+\r
+    Parser (LineNumber != 0)\r
+      VfrCompile.cpp(330) : error E2660: AddVfrDataStructField : function does not take 2 parameters\r
+    Generic utility (LineNumber == 0) \r
+      UtilityName : error E1234 : Text string : MsgFmt string and args\r
+\r
+--*/\r
+{\r
+  INT8  Line[MAX_LINE_LEN];\r
+  INT8  Line2[MAX_LINE_LEN];\r
+  INT8  *Cptr;\r
+  //\r
+  // If given a filename, then add it (and the line number) to the string.\r
+  // If there's no filename, then use the program name if provided.\r
+  //\r
+  if (FileName != NULL) {\r
+    Cptr = FileName;\r
+  } else if (mUtilityName[0] != 0) {\r
+    Cptr = mUtilityName;\r
+  } else {\r
+    Cptr = "Unknown utility";\r
+  }\r
+\r
+  strcpy (Line, Cptr);\r
+  if (LineNumber != 0) {\r
+    sprintf (Line2, "(%d)", LineNumber);\r
+    strcat (Line, Line2);\r
+  }\r
+  //\r
+  // Have to print an error code or Visual Studio won't find the\r
+  // message for you. It has to be decimal digits too.\r
+  //\r
+  sprintf (Line2, " : %s %c%04d", Type, toupper (Type[0]), MessageCode);\r
+  strcat (Line, Line2);\r
+  fprintf (stdout, "%s", Line);\r
+  //\r
+  // If offending text was provided, then print it\r
+  //\r
+  if (Text != NULL) {\r
+    fprintf (stdout, ": %s ", Text);\r
+  }\r
+  //\r
+  // Print formatted message if provided\r
+  //\r
+  if (MsgFmt != NULL) {\r
+    vsprintf (Line2, MsgFmt, List);\r
+    fprintf (stdout, ": %s", Line2);\r
+  }\r
+\r
+  fprintf (stdout, "\n");\r
+}\r
+\r
+void\r
+ParserSetPosition (\r
+  INT8    *SourceFileName,\r
+  UINT32  LineNum\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Set the position in a file being parsed. This can be used to \r
+  print error messages deeper down in a parser.\r
+\r
+Arguments:\r
+  SourceFileName - name of the source file being parsed\r
+  LineNum        - line number of the source file being parsed\r
+\r
+Returns:\r
+  NA\r
+\r
+--*/\r
+{\r
+  mSourceFileName     = SourceFileName;\r
+  mSourceFileLineNum  = LineNum;\r
+}\r
+\r
+void\r
+SetUtilityName (\r
+  INT8    *UtilityName\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  All printed error/warning/debug messages follow the same format, and\r
+  typically will print a filename or utility name followed by the error\r
+  text. However if a filename is not passed to the print routines, then\r
+  they'll print the utility name if you call this function early in your\r
+  app to set the utility name.\r
+  \r
+Arguments:\r
+  UtilityName  -  name of the utility, which will be printed with all\r
+                  error/warning/debug messags.\r
+\r
+Returns:\r
+  NA\r
+  \r
+--*/\r
+{\r
+  //\r
+  // Save the name of the utility in our local variable. Make sure its\r
+  // length does not exceed our buffer.\r
+  //\r
+  if (UtilityName != NULL) {\r
+    if (strlen (UtilityName) >= sizeof (mUtilityName)) {\r
+      Error (UtilityName, 0, 0, "application error", "utility name length exceeds internal buffer size");\r
+      strncpy (mUtilityName, UtilityName, sizeof (mUtilityName) - 1);\r
+      mUtilityName[sizeof (mUtilityName) - 1] = 0;\r
+      return ;\r
+    } else {\r
+      strcpy (mUtilityName, UtilityName);\r
+    }\r
+  } else {\r
+    Error (NULL, 0, 0, "application error", "SetUtilityName() called with NULL utility name");\r
+  }\r
+}\r
+\r
+STATUS\r
+GetUtilityStatus (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  When you call Error() or Warning(), this module keeps track of it and\r
+  sets a local mStatus to STATUS_ERROR or STATUS_WARNING. When the utility\r
+  exits, it can call this function to get the status and use it as a return\r
+  value.\r
+  \r
+Arguments:\r
+  None.\r
+\r
+Returns:\r
+  Worst-case status reported, as defined by which print function was called.\r
+  \r
+--*/\r
+{\r
+  return mStatus;\r
+}\r
diff --git a/Tools/CodeTools/Source/GuidChk/UtilsMsgs.h b/Tools/CodeTools/Source/GuidChk/UtilsMsgs.h
new file mode 100644 (file)
index 0000000..5f6c701
--- /dev/null
@@ -0,0 +1,106 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:  \r
+\r
+  UtilsMsgs.h\r
+  \r
+Abstract:\r
+\r
+  Prototypes for the EFI tools utility functions.\r
+  \r
+--*/\r
+\r
+#ifndef _UTILS_MESSAGES_H_\r
+#define _UTILS_MESSAGES_H_\r
+\r
+STATUS\r
+GetUtilityStatus (\r
+  VOID\r
+  )\r
+;\r
+\r
+//\r
+// If someone prints an error message and didn't specify a source file name,\r
+// then we print the utility name instead. However they must tell us the\r
+// utility name early on via this function.\r
+//\r
+VOID\r
+SetUtilityName (\r
+  INT8 *ProgramName\r
+  )\r
+;\r
+\r
+void\r
+Error (\r
+  INT8    *FileName,\r
+  UINT32  LineNumber,\r
+  UINT32  ErrorCode,\r
+  INT8    *OffendingText,\r
+  INT8    *MsgFmt,\r
+  ...\r
+  )\r
+;\r
+\r
+void\r
+Warning (\r
+  INT8    *FileName,\r
+  UINT32  LineNumber,\r
+  UINT32  ErrorCode,\r
+  INT8    *OffendingText,\r
+  INT8    *MsgFmt,\r
+  ...\r
+  )\r
+;\r
+\r
+void\r
+DebugMsg (\r
+  INT8    *FileName,\r
+  UINT32  LineNumber,\r
+  UINT32  MsgLevel,\r
+  INT8    *OffendingText,\r
+  INT8    *MsgFmt,\r
+  ...\r
+  )\r
+;\r
+\r
+void\r
+SetDebugMsgMask (\r
+  UINT32    MsgMask\r
+  )\r
+;\r
+\r
+void\r
+ParserSetPosition (\r
+  INT8    *SourceFileName,\r
+  UINT32  LineNum\r
+  )\r
+;\r
+\r
+void\r
+ParserError (\r
+  UINT32  ErrorCode,\r
+  INT8    *OffendingText,\r
+  INT8    *MsgFmt,\r
+  ...\r
+  )\r
+;\r
+\r
+void\r
+ParserWarning (\r
+  UINT32  ErrorCode,\r
+  INT8    *OffendingText,\r
+  INT8    *MsgFmt,\r
+  ...\r
+  )\r
+;\r
+\r
+#endif\r
diff --git a/Tools/CodeTools/Source/GuidChk/build.xml b/Tools/CodeTools/Source/GuidChk/build.xml
new file mode 100644 (file)
index 0000000..aec3ad1
--- /dev/null
@@ -0,0 +1,84 @@
+<?xml version="1.0" ?>\r
+<!--\r
+Copyright (c) 2006, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+-->\r
+<project default="GenTool" basedir=".">\r
+<!--\r
+    EDK GuidChk Tool\r
+  Copyright (c) 2006, Intel Corporation\r
+-->\r
+  <property name="ToolName" value="GuidChk"/>\r
+  <property name="FileSet" value="*.c *.h"/>\r
+\r
+  <taskdef resource="cpptasks.tasks"/>\r
+  <typedef resource="cpptasks.types"/>\r
+  <taskdef resource="net/sf/antcontrib/antlib.xml"/>\r
+\r
+  <property name="LINK_OUTPUT_TYPE" value="static"/>\r
+  <property name="BUILD_DIR" value="${PACKAGE_DIR}/${ToolName}/tmp"/>\r
+\r
+  <target name="GenTool" depends="init, Tool">\r
+    <if>\r
+      <isfalse value="${gcc}"/>\r
+      <then>\r
+        <echo message="The EDK Tool: ${ToolName} build has completed!"/>\r
+      </then>\r
+    </if>\r
+  </target>\r
+\r
+  <target name="init">\r
+    <if>\r
+      <istrue value="${gcc}"/>\r
+      <then>\r
+        <echo message="The EDK Tool: ${ToolName} is not built for GCC!"/>\r
+      </then>\r
+      <else>\r
+        <echo message="Building the EDK Tool: ${ToolName}"/>\r
+        <mkdir dir="${BUILD_DIR}"/>\r
+      </else>\r
+    </if>\r
+  </target>\r
+\r
+  <target name="Tool" depends="init" unless="gcc">\r
+    <cc name="${ToolChain}" objdir="${BUILD_DIR}" \r
+        outfile="${BIN_DIR}/${ToolName}"\r
+        outtype="executable"\r
+        debug="true"\r
+        optimize="speed">\r
+\r
+      <fileset dir="${basedir}/${ToolName}" \r
+        includes="${FileSet}" \r
+        defaultexcludes="TRUE" \r
+        excludes="*.xml *.inf"/>\r
+\r
+      <includepath path="${PACKAGE_DIR}/Include"/>\r
+      <includepath path="${PACKAGE_DIR}/Include/Ia32"/>\r
+      <includepath path="${PACKAGE_DIR}/Common"/>\r
+      <libset dir="${LIB_DIR}" libs="CommonTools"/>\r
+\r
+    </cc>\r
+  </target>\r
+\r
+  <target name="clean">\r
+    <echo message="Removing Intermediate Files Only"/>  \r
+    <delete failonerror="false" quiet="true" includeEmptyDirs="true">\r
+      <fileset dir="${BUILD_DIR}"/>\r
+    </delete>\r
+  </target>\r
+\r
+  <target name="cleanall">\r
+    <echo message="Removing Object Files and the Executable: ${ToolName}${ext_exe}"/>  \r
+    <delete failonerror="false" quiet="true" includeEmptyDirs="true">\r
+      <fileset dir="${BUILD_DIR}"/>\r
+      <fileset file="${BIN_DIR}/${ToolName}${ext_exe}"/>\r
+    </delete>\r
+  </target>\r
+\r
+</project>\r
diff --git a/Tools/CodeTools/Source/Include/Common/BaseTypes.h b/Tools/CodeTools/Source/Include/Common/BaseTypes.h
new file mode 100644 (file)
index 0000000..b87e714
--- /dev/null
@@ -0,0 +1,212 @@
+/** @file\r
+  Processor or Compiler specific defines for all supported processors.\r
+\r
+  This file is stand alone self consistent set of definitions. \r
+\r
+  Copyright (c) 2006, Intel Corporation                                                         \r
+  All rights reserved. This program and the accompanying materials                          \r
+  are licensed and made available under the terms and conditions of the BSD License         \r
+  which accompanies this distribution.  The full text of the license may be found at        \r
+  http://opensource.org/licenses/bsd-license.php                                            \r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+  Module Name:  BaseTypes.h\r
+\r
+**/\r
+\r
+#ifndef __BASE_TYPES_H__\r
+#define __BASE_TYPES_H__\r
+\r
+//\r
+// Include processor specific binding\r
+//\r
+#include <ProcessorBind.h>\r
+#include <stdarg.h>\r
+\r
+#define MEMORY_FENCE()  MemoryFence ()\r
+#define BREAKPOINT()    CpuBreakpoint ()\r
+#define DEADLOOP()      CpuDeadLoop ()\r
+\r
+typedef struct {\r
+  UINT32  Data1;\r
+  UINT16  Data2;\r
+  UINT16  Data3;\r
+  UINT8   Data4[8];\r
+} GUID;\r
+\r
+\r
+//\r
+// Modifiers to absract standard types to aid in debug of problems\r
+//\r
+#define CONST     const\r
+#define STATIC    static\r
+#define VOID      void\r
+\r
+//\r
+// Modifiers for Data Types used to self document code.\r
+// This concept is borrowed for UEFI specification.\r
+//\r
+#ifndef IN\r
+//\r
+// Some other envirnments use this construct, so #ifndef to prevent\r
+// mulitple definition.\r
+//\r
+#define IN\r
+#define OUT\r
+#define OPTIONAL\r
+#endif\r
+\r
+//\r
+// Constants. They may exist in other build structures, so #ifndef them.\r
+//\r
+#ifndef TRUE\r
+//\r
+// BugBug: UEFI specification claims 1 and 0. We are concerned about the \r
+//  complier portability so we did it this way.\r
+//\r
+#define TRUE  ((BOOLEAN)(1==1))\r
+#endif\r
+\r
+#ifndef FALSE\r
+#define FALSE ((BOOLEAN)(0==1))\r
+#endif\r
+\r
+#ifndef NULL\r
+#define NULL  ((VOID *) 0)\r
+#endif\r
+\r
+//\r
+//  Support for variable length argument lists using the ANSI standard.\r
+//  \r
+//  Since we are using the ANSI standard we used the standard nameing and\r
+//  did not folow the coding convention\r
+//\r
+//  VA_LIST  - typedef for argument list.\r
+//  VA_START (VA_LIST Marker, argument before the ...) - Init Marker for use.\r
+//  VA_END (VA_LIST Marker) - Clear Marker\r
+//  VA_ARG (VA_LIST Marker, var arg size) - Use Marker to get an argumnet from\r
+//    the ... list. You must know the size and pass it in this macro.\r
+//\r
+//  example:\r
+//\r
+//  UINTN\r
+//  ExampleVarArg (\r
+//    IN UINTN  NumberOfArgs,\r
+//    ...\r
+//    )\r
+//  {\r
+//    VA_LIST Marker;\r
+//    UINTN   Index;\r
+//    UINTN   Result;\r
+//\r
+//    //\r
+//    // Initialize the Marker\r
+//    //\r
+//    VA_START (Marker, NumberOfArgs);\r
+//    for (Index = 0, Result = 0; Index < NumberOfArgs; Index++) {\r
+//      //\r
+//      // The ... list is a series of UINTN values, so average them up.\r
+//      //\r
+//      Result += VA_ARG (Marker, UINTN);\r
+//    }\r
+//\r
+//    VA_END (Marker);\r
+//    return Result\r
+//  }\r
+//\r
+\r
+#define _INT_SIZE_OF(n) ((sizeof (n) + sizeof (UINTN) - 1) &~(sizeof (UINTN) - 1))\r
+\r
+//\r
+// Also support coding convention rules for var arg macros\r
+//\r
+#ifndef VA_START\r
+\r
+// typedef CHAR8 *VA_LIST;\r
+// #define VA_START(ap, v) (ap = (VA_LIST) & (v) + _INT_SIZE_OF (v))\r
+// #define VA_ARG(ap, t)   (*(t *) ((ap += _INT_SIZE_OF (t)) - _INT_SIZE_OF (t)))\r
+// #define VA_END(ap)      (ap = (VA_LIST) 0)\r
+// Use the native arguments for tools.\r
+#define VA_START va_start\r
+#define VA_ARG   va_arg\r
+#define VA_END   va_end\r
+#define VA_LIST  va_list\r
+\r
+#endif\r
+\r
+///\r
+///  CONTAINING_RECORD - returns a pointer to the structure\r
+///      from one of it's elements.\r
+///\r
+#define _CR(Record, TYPE, Field)  ((TYPE *) ((CHAR8 *) (Record) - (CHAR8 *) &(((TYPE *) 0)->Field)))\r
+\r
+///\r
+///  ALIGN_POINTER - aligns a pointer to the lowest boundry\r
+///\r
+#define ALIGN_POINTER(p, s) ((VOID *) ((p) + (((s) - ((UINTN) (p))) & ((s) - 1))))\r
+\r
+///\r
+///  ALIGN_VARIABLE - aligns a variable up to the next natural boundry for int size of a processor\r
+///\r
+#define ALIGN_VARIABLE(Value, Adjustment) \\r
+  Adjustment = 0U; \\r
+  if ((UINTN) (Value) % sizeof (UINTN)) { \\r
+    (Adjustment) = (UINTN)(sizeof (UINTN) - ((UINTN) (Value) % sizeof (UINTN))); \\r
+  } \\r
+  (Value) = (UINTN)((UINTN) (Value) + (UINTN) (Adjustment))\r
+\r
+//\r
+// EFI Error Codes common to all execution phases\r
+//\r
+\r
+typedef INTN RETURN_STATUS;\r
+\r
+///\r
+/// Set the upper bit to indicate EFI Error.\r
+///\r
+#define ENCODE_ERROR(a)              (MAX_BIT | (a))\r
+\r
+#define ENCODE_WARNING(a)            (a)\r
+#define RETURN_ERROR(a)              ((a) < 0)\r
+\r
+#define RETURN_SUCCESS               0\r
+#define RETURN_LOAD_ERROR            ENCODE_ERROR (1)\r
+#define RETURN_INVALID_PARAMETER     ENCODE_ERROR (2)\r
+#define RETURN_UNSUPPORTED           ENCODE_ERROR (3)\r
+#define RETURN_BAD_BUFFER_SIZE       ENCODE_ERROR (4)\r
+#define RETURN_BUFFER_TOO_SMALL      ENCODE_ERROR (5)\r
+#define RETURN_NOT_READY             ENCODE_ERROR (6)\r
+#define RETURN_DEVICE_ERROR          ENCODE_ERROR (7)\r
+#define RETURN_WRITE_PROTECTED       ENCODE_ERROR (8)\r
+#define RETURN_OUT_OF_RESOURCES      ENCODE_ERROR (9)\r
+#define RETURN_VOLUME_CORRUPTED      ENCODE_ERROR (10)\r
+#define RETURN_VOLUME_FULL           ENCODE_ERROR (11)\r
+#define RETURN_NO_MEDIA              ENCODE_ERROR (12)\r
+#define RETURN_MEDIA_CHANGED         ENCODE_ERROR (13)\r
+#define RETURN_NOT_FOUND             ENCODE_ERROR (14)\r
+#define RETURN_ACCESS_DENIED         ENCODE_ERROR (15)\r
+#define RETURN_NO_RESPONSE           ENCODE_ERROR (16)\r
+#define RETURN_NO_MAPPING            ENCODE_ERROR (17)\r
+#define RETURN_TIMEOUT               ENCODE_ERROR (18)\r
+#define RETURN_NOT_STARTED           ENCODE_ERROR (19)\r
+#define RETURN_ALREADY_STARTED       ENCODE_ERROR (20)\r
+#define RETURN_ABORTED               ENCODE_ERROR (21)\r
+#define RETURN_ICMP_ERROR            ENCODE_ERROR (22)\r
+#define RETURN_TFTP_ERROR            ENCODE_ERROR (23)\r
+#define RETURN_PROTOCOL_ERROR        ENCODE_ERROR (24)\r
+#define RETURN_INCOMPATIBLE_VERSION  ENCODE_ERROR (25)\r
+#define RETURN_SECURITY_VIOLATION    ENCODE_ERROR (26)\r
+#define RETURN_CRC_ERROR             ENCODE_ERROR (27)\r
+#define RETURN_END_OF_MEDIA          ENCODE_ERROR (28)\r
+#define RETURN_END_OF_FILE           ENCODE_ERROR (31)\r
+\r
+#define RETURN_WARN_UNKNOWN_GLYPH    ENCODE_WARNING (1)\r
+#define RETURN_WARN_DELETE_FAILURE   ENCODE_WARNING (2)\r
+#define RETURN_WARN_WRITE_FAILURE    ENCODE_WARNING (3)\r
+#define RETURN_WARN_BUFFER_TOO_SMALL ENCODE_WARNING (4)\r
+\r
+typedef UINT64 PHYSICAL_ADDRESS;\r
+\r
+#endif\r
diff --git a/Tools/CodeTools/Source/Include/Common/Capsule.h b/Tools/CodeTools/Source/Include/Common/Capsule.h
new file mode 100644 (file)
index 0000000..0434fdf
--- /dev/null
@@ -0,0 +1,67 @@
+/** @file\r
+  Defines for the EFI Capsule functionality.\r
+\r
+  Copyright (c) 2006, Intel Corporation                                                         \r
+  All rights reserved. This program and the accompanying materials                          \r
+  are licensed and made available under the terms and conditions of the BSD License         \r
+  which accompanies this distribution.  The full text of the license may be found at        \r
+  http://opensource.org/licenses/bsd-license.php                                            \r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+  Module Name:  Capsule.h\r
+\r
+  @par Revision Reference:\r
+  These definitions are from Capsule Spec Version 0.9.\r
+\r
+**/\r
+\r
+#ifndef _EFI_CAPSULE_H_\r
+#define _EFI_CAPSULE_H_\r
+\r
+//\r
+// Bits in the flags field of the capsule header\r
+//\r
+#define EFI_CAPSULE_HEADER_FLAG_SETUP 0x00000001  // supports setup changes\r
+\r
+\r
+#define CAPSULE_BLOCK_DESCRIPTOR_SIGNATURE  EFI_SIGNATURE_32 ('C', 'B', 'D', 'S')\r
+\r
+//\r
+// An array of these describe the blocks that make up a capsule for\r
+// a capsule update.\r
+//\r
+typedef struct {\r
+  UINT64                Length;     // length of the data block\r
+  EFI_PHYSICAL_ADDRESS  Data;       // physical address of the data block\r
+  UINT32                Signature;  // CBDS\r
+  UINT32                CheckSum;   // to sum this structure to 0\r
+} EFI_CAPSULE_BLOCK_DESCRIPTOR;\r
+\r
+typedef struct {\r
+  EFI_GUID  OemGuid;\r
+  UINT32    HeaderSize;\r
+  //\r
+  // UINT8                       OemHdrData[];\r
+  //\r
+} EFI_CAPSULE_OEM_HEADER;\r
+\r
+typedef struct {\r
+  EFI_GUID  CapsuleGuid;\r
+  UINT32    HeaderSize;\r
+  UINT32    Flags;\r
+  UINT32    CapsuleImageSize;\r
+  UINT32    SequenceNumber;\r
+  EFI_GUID  InstanceId;\r
+  UINT32    OffsetToSplitInformation;\r
+  UINT32    OffsetToCapsuleBody;\r
+  UINT32    OffsetToOemDefinedHeader;\r
+  UINT32    OffsetToAuthorInformation;\r
+  UINT32    OffsetToRevisionInformation;\r
+  UINT32    OffsetToShortDescription;\r
+  UINT32    OffsetToLongDescription;\r
+  UINT32    OffsetToApplicableDevices;\r
+} EFI_CAPSULE_HEADER;\r
+\r
+#endif // #ifndef _EFI_CAPSULE_H_\r
diff --git a/Tools/CodeTools/Source/Include/Common/Dependency.h b/Tools/CodeTools/Source/Include/Common/Dependency.h
new file mode 100644 (file)
index 0000000..744027d
--- /dev/null
@@ -0,0 +1,50 @@
+/** @file\r
+  This module contains data specific to dependency expressions\r
+  and local function prototypes.\r
+\r
+  Copyright (c) 2006, Intel Corporation                                                         \r
+  All rights reserved. This program and the accompanying materials                          \r
+  are licensed and made available under the terms and conditions of the BSD License         \r
+  which accompanies this distribution.  The full text of the license may be found at        \r
+  http://opensource.org/licenses/bsd-license.php                                            \r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+  Module Name:  Dependency.h\r
+\r
+**/\r
+\r
+#ifndef __DEPENDENCY_H__\r
+#define __DEPENDENCY_H__\r
+\r
+/// EFI_DEP_BEFORE       - If present, this must be the first and only opcode\r
+#define EFI_DEP_BEFORE        0x00\r
+\r
+/// EFI_DEP_AFTER        - If present, this must be the first and only opcode\r
+#define EFI_DEP_AFTER         0x01\r
+\r
+#define EFI_DEP_PUSH          0x02\r
+#define EFI_DEP_AND           0x03\r
+#define EFI_DEP_OR            0x04\r
+#define EFI_DEP_NOT           0x05\r
+#define EFI_DEP_TRUE          0x06\r
+#define EFI_DEP_FALSE         0x07\r
+#define EFI_DEP_END           0x08\r
+\r
+/// EFI_DEP_SOR          - If present, this must be the first opcode\r
+#define EFI_DEP_SOR           0x09\r
+\r
+///\r
+/// EFI_DEP_REPLACE_TRUE - Used to dynamically patch the dependecy expression\r
+///                        to save time.  A EFI_DEP_PUSH is evauated one an\r
+///                        replaced with EFI_DEP_REPLACE_TRUE\r
+///\r
+#define EFI_DEP_REPLACE_TRUE  0xff\r
+\r
+///\r
+/// Define the initial size of the dependency expression evaluation stack\r
+///\r
+#define DEPEX_STACK_SIZE_INCREMENT  0x1000\r
+\r
+#endif\r
diff --git a/Tools/CodeTools/Source/Include/Common/EfiImage.h b/Tools/CodeTools/Source/Include/Common/EfiImage.h
new file mode 100644 (file)
index 0000000..2f5c580
--- /dev/null
@@ -0,0 +1,716 @@
+/** @file\r
+  EFI image format for PE32+. Please note some data structures are different\r
+  for IA-32 and Itanium-based images, look for UINTN and the #ifdef EFI_IA64\r
+\r
+  @bug Fix text - doc as defined in MSFT EFI specification.\r
+\r
+  Copyright (c) 2006, Intel Corporation                                                         \r
+  All rights reserved. This program and the accompanying materials                          \r
+  are licensed and made available under the terms and conditions of the BSD License         \r
+  which accompanies this distribution.  The full text of the license may be found at        \r
+  http://opensource.org/licenses/bsd-license.php                                            \r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+  Module Name:  EfiImage.h\r
+\r
+**/\r
+\r
+#ifndef __EFI_IMAGE_H__\r
+#define __EFI_IMAGE_H__\r
+\r
+//\r
+// PE32+ Subsystem type for EFI images\r
+//\r
+#define EFI_IMAGE_SUBSYSTEM_EFI_APPLICATION         10\r
+#define EFI_IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER 11\r
+#define EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER      12\r
+#define EFI_IMAGE_SUBSYSTEM_SAL_RUNTIME_DRIVER      13\r
+\r
+//\r
+// BugBug: Need to get a real answer for this problem. This is not in the\r
+//         PE specification.\r
+//\r
+//         A SAL runtime driver does not get fixed up when a transition to\r
+//         virtual mode is made. In all other cases it should be treated\r
+//         like a EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER image\r
+//\r
+#define EFI_IMAGE_SUBSYSTEM_SAL_RUNTIME_DRIVER  13\r
+\r
+//\r
+// PE32+ Machine type for EFI images\r
+//\r
+#define IMAGE_FILE_MACHINE_I386     0x014c\r
+#define IMAGE_FILE_MACHINE_IA64     0x0200\r
+#define IMAGE_FILE_MACHINE_EBC      0x0EBC\r
+#define IMAGE_FILE_MACHINE_X64      0x8664\r
+//\r
+// Support old names for backward compatible\r
+//\r
+#define EFI_IMAGE_MACHINE_IA32      IMAGE_FILE_MACHINE_I386 \r
+#define EFI_IMAGE_MACHINE_IA64      IMAGE_FILE_MACHINE_IA64  \r
+#define EFI_IMAGE_MACHINE_IPF       IMAGE_FILE_MACHINE_IA64  \r
+#define EFI_IMAGE_MACHINE_EBC       IMAGE_FILE_MACHINE_EBC  \r
+#define EFI_IMAGE_MACHINE_X64       IMAGE_FILE_MACHINE_X64\r
+\r
+#define EFI_IMAGE_DOS_SIGNATURE     0x5A4D      // MZ\r
+#define EFI_IMAGE_OS2_SIGNATURE     0x454E      // NE\r
+#define EFI_IMAGE_OS2_SIGNATURE_LE  0x454C      // LE\r
+#define EFI_IMAGE_NT_SIGNATURE      0x00004550  // PE00\r
+#define EFI_IMAGE_EDOS_SIGNATURE    0x44454550  // PEED\r
+\r
+///\r
+/// PE images can start with an optional DOS header, so if an image is run\r
+///  under DOS it can print an error message.\r
+///\r
+typedef struct {\r
+  UINT16  e_magic;    // Magic number\r
+  UINT16  e_cblp;     // Bytes on last page of file\r
+  UINT16  e_cp;       // Pages in file\r
+  UINT16  e_crlc;     // Relocations\r
+  UINT16  e_cparhdr;  // Size of header in paragraphs\r
+  UINT16  e_minalloc; // Minimum extra paragraphs needed\r
+  UINT16  e_maxalloc; // Maximum extra paragraphs needed\r
+  UINT16  e_ss;       // Initial (relative) SS value\r
+  UINT16  e_sp;       // Initial SP value\r
+  UINT16  e_csum;     // Checksum\r
+  UINT16  e_ip;       // Initial IP value\r
+  UINT16  e_cs;       // Initial (relative) CS value\r
+  UINT16  e_lfarlc;   // File address of relocation table\r
+  UINT16  e_ovno;     // Overlay number\r
+  UINT16  e_res[4];   // Reserved words\r
+  UINT16  e_oemid;    // OEM identifier (for e_oeminfo)\r
+  UINT16  e_oeminfo;  // OEM information; e_oemid specific\r
+  UINT16  e_res2[10]; // Reserved words\r
+  UINT32  e_lfanew;   // File address of new exe header\r
+} EFI_IMAGE_DOS_HEADER;\r
+\r
+///\r
+/// File header format.\r
+///\r
+typedef struct {\r
+  UINT16  Machine;\r
+  UINT16  NumberOfSections;\r
+  UINT32  TimeDateStamp;\r
+  UINT32  PointerToSymbolTable;\r
+  UINT32  NumberOfSymbols;\r
+  UINT16  SizeOfOptionalHeader;\r
+  UINT16  Characteristics;\r
+} EFI_IMAGE_FILE_HEADER;\r
+\r
+#define EFI_IMAGE_SIZEOF_FILE_HEADER        20\r
+\r
+#define EFI_IMAGE_FILE_RELOCS_STRIPPED      0x0001  // Relocation info stripped from file.\r
+#define EFI_IMAGE_FILE_EXECUTABLE_IMAGE     0x0002  // File is executable  (i.e. no unresolved externel references).\r
+#define EFI_IMAGE_FILE_LINE_NUMS_STRIPPED   0x0004  // Line nunbers stripped from file.\r
+#define EFI_IMAGE_FILE_LOCAL_SYMS_STRIPPED  0x0008  // Local symbols stripped from file.\r
+#define EFI_IMAGE_FILE_BYTES_REVERSED_LO    0x0080  // Bytes of machine word are reversed.\r
+#define EFI_IMAGE_FILE_32BIT_MACHINE        0x0100  // 32 bit word machine.\r
+#define EFI_IMAGE_FILE_DEBUG_STRIPPED       0x0200  // Debugging info stripped from file in .DBG file\r
+#define EFI_IMAGE_FILE_SYSTEM               0x1000  // System File.\r
+#define EFI_IMAGE_FILE_DLL                  0x2000  // File is a DLL.\r
+#define EFI_IMAGE_FILE_BYTES_REVERSED_HI    0x8000  // Bytes of machine word are reversed.\r
+#define EFI_IMAGE_FILE_MACHINE_UNKNOWN      0\r
+#define EFI_IMAGE_FILE_MACHINE_I386         0x14c   // Intel 386.\r
+#define EFI_IMAGE_FILE_MACHINE_R3000        0x162   // MIPS* little-endian, 0540 big-endian\r
+#define EFI_IMAGE_FILE_MACHINE_R4000        0x166   // MIPS* little-endian\r
+#define EFI_IMAGE_FILE_MACHINE_ALPHA        0x184   // Alpha_AXP*\r
+#define EFI_IMAGE_FILE_MACHINE_POWERPC      0x1F0   // IBM* PowerPC Little-Endian\r
+#define EFI_IMAGE_FILE_MACHINE_TAHOE        0x7cc   // Intel EM machine\r
+//\r
+// * Other names and brands may be claimed as the property of others.\r
+//\r
+\r
+///\r
+/// Directory format.\r
+///\r
+typedef struct {\r
+  UINT32  VirtualAddress;\r
+  UINT32  Size;\r
+} EFI_IMAGE_DATA_DIRECTORY;\r
+\r
+#define EFI_IMAGE_NUMBER_OF_DIRECTORY_ENTRIES 16\r
+\r
+typedef struct {\r
+  UINT16  Magic;\r
+  UINT8   MajorLinkerVersion;\r
+  UINT8   MinorLinkerVersion;\r
+  UINT32  SizeOfCode;\r
+  UINT32  SizeOfInitializedData;\r
+  UINT32  SizeOfUninitializedData;\r
+  UINT32  AddressOfEntryPoint;\r
+  UINT32  BaseOfCode;\r
+  UINT32  BaseOfData;\r
+  UINT32  BaseOfBss;\r
+  UINT32  GprMask;\r
+  UINT32  CprMask[4];\r
+  UINT32  GpValue;\r
+} EFI_IMAGE_ROM_OPTIONAL_HEADER;\r
+\r
+#define EFI_IMAGE_ROM_OPTIONAL_HDR_MAGIC      0x107\r
+#define EFI_IMAGE_SIZEOF_ROM_OPTIONAL_HEADER  sizeof (EFI_IMAGE_ROM_OPTIONAL_HEADER)\r
+\r
+typedef struct {\r
+  EFI_IMAGE_FILE_HEADER         FileHeader;\r
+  EFI_IMAGE_ROM_OPTIONAL_HEADER OptionalHeader;\r
+} EFI_IMAGE_ROM_HEADERS;\r
+\r
+///\r
+/// @attention\r
+/// EFI_IMAGE_OPTIONAL_HEADER32 and EFI_IMAGE_OPTIONAL_HEADER64\r
+/// are for use ONLY by tools.  All proper EFI code MUST use\r
+/// EFI_IMAGE_OPTIONAL_HEADER ONLY!!!\r
+///\r
+#define EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC 0x10b\r
+\r
+typedef struct {\r
+  //\r
+  // Standard fields.\r
+  //\r
+  UINT16                    Magic;\r
+  UINT8                     MajorLinkerVersion;\r
+  UINT8                     MinorLinkerVersion;\r
+  UINT32                    SizeOfCode;\r
+  UINT32                    SizeOfInitializedData;\r
+  UINT32                    SizeOfUninitializedData;\r
+  UINT32                    AddressOfEntryPoint;\r
+  UINT32                    BaseOfCode;\r
+  UINT32                    BaseOfData;\r
+  //\r
+  // NT additional fields.\r
+  //\r
+  UINT32                    ImageBase;\r
+  UINT32                    SectionAlignment;\r
+  UINT32                    FileAlignment;\r
+  UINT16                    MajorOperatingSystemVersion;\r
+  UINT16                    MinorOperatingSystemVersion;\r
+  UINT16                    MajorImageVersion;\r
+  UINT16                    MinorImageVersion;\r
+  UINT16                    MajorSubsystemVersion;\r
+  UINT16                    MinorSubsystemVersion;\r
+  UINT32                    Win32VersionValue;\r
+  UINT32                    SizeOfImage;\r
+  UINT32                    SizeOfHeaders;\r
+  UINT32                    CheckSum;\r
+  UINT16                    Subsystem;\r
+  UINT16                    DllCharacteristics;\r
+  UINT32                    SizeOfStackReserve;\r
+  UINT32                    SizeOfStackCommit;\r
+  UINT32                    SizeOfHeapReserve;\r
+  UINT32                    SizeOfHeapCommit;\r
+  UINT32                    LoaderFlags;\r
+  UINT32                    NumberOfRvaAndSizes;\r
+  EFI_IMAGE_DATA_DIRECTORY  DataDirectory[EFI_IMAGE_NUMBER_OF_DIRECTORY_ENTRIES];\r
+} EFI_IMAGE_OPTIONAL_HEADER32;\r
+\r
+///\r
+/// @attention\r
+/// EFI_IMAGE_OPTIONAL_HEADER32 and EFI_IMAGE_OPTIONAL_HEADER64\r
+/// are for use ONLY by tools.  All proper EFI code MUST use\r
+/// EFI_IMAGE_OPTIONAL_HEADER ONLY!!!\r
+///\r
+#define EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC 0x20b\r
+\r
+typedef struct {\r
+  //\r
+  // Standard fields.\r
+  //\r
+  UINT16                    Magic;\r
+  UINT8                     MajorLinkerVersion;\r
+  UINT8                     MinorLinkerVersion;\r
+  UINT32                    SizeOfCode;\r
+  UINT32                    SizeOfInitializedData;\r
+  UINT32                    SizeOfUninitializedData;\r
+  UINT32                    AddressOfEntryPoint;\r
+  UINT32                    BaseOfCode;\r
+  //\r
+  // NT additional fields.\r
+  //\r
+  UINT64                    ImageBase;\r
+  UINT32                    SectionAlignment;\r
+  UINT32                    FileAlignment;\r
+  UINT16                    MajorOperatingSystemVersion;\r
+  UINT16                    MinorOperatingSystemVersion;\r
+  UINT16                    MajorImageVersion;\r
+  UINT16                    MinorImageVersion;\r
+  UINT16                    MajorSubsystemVersion;\r
+  UINT16                    MinorSubsystemVersion;\r
+  UINT32                    Win32VersionValue;\r
+  UINT32                    SizeOfImage;\r
+  UINT32                    SizeOfHeaders;\r
+  UINT32                    CheckSum;\r
+  UINT16                    Subsystem;\r
+  UINT16                    DllCharacteristics;\r
+  UINT64                    SizeOfStackReserve;\r
+  UINT64                    SizeOfStackCommit;\r
+  UINT64                    SizeOfHeapReserve;\r
+  UINT64                    SizeOfHeapCommit;\r
+  UINT32                    LoaderFlags;\r
+  UINT32                    NumberOfRvaAndSizes;\r
+  EFI_IMAGE_DATA_DIRECTORY  DataDirectory[EFI_IMAGE_NUMBER_OF_DIRECTORY_ENTRIES];\r
+} EFI_IMAGE_OPTIONAL_HEADER64;\r
+\r
+///\r
+/// @attention\r
+/// EFI_IMAGE_NT_HEADERS32 and EFI_IMAGE_HEADERS64 are for use ONLY\r
+/// by tools.  All proper EFI code MUST use EFI_IMAGE_NT_HEADERS ONLY!!!\r
+///\r
+typedef struct {\r
+  UINT32                      Signature;\r
+  EFI_IMAGE_FILE_HEADER       FileHeader;\r
+  EFI_IMAGE_OPTIONAL_HEADER32 OptionalHeader;\r
+} EFI_IMAGE_NT_HEADERS32;\r
+\r
+#define EFI_IMAGE_SIZEOF_NT_OPTIONAL32_HEADER sizeof (EFI_IMAGE_NT_HEADERS32)\r
+\r
+typedef struct {\r
+  UINT32                      Signature;\r
+  EFI_IMAGE_FILE_HEADER       FileHeader;\r
+  EFI_IMAGE_OPTIONAL_HEADER64 OptionalHeader;\r
+} EFI_IMAGE_NT_HEADERS64;\r
+\r
+#define EFI_IMAGE_SIZEOF_NT_OPTIONAL64_HEADER sizeof (EFI_IMAGE_NT_HEADERS64)\r
+\r
+//\r
+// Processor specific definition of EFI_IMAGE_OPTIONAL_HEADER so the\r
+// type name EFI_IMAGE_OPTIONAL_HEADER is appropriate to the build.  Same for\r
+// EFI_IMAGE_NT_HEADERS.  These definitions MUST be used by ALL EFI code.\r
+//\r
+#if   defined (MDE_CPU_IA32)\r
+\r
+typedef EFI_IMAGE_OPTIONAL_HEADER32     EFI_IMAGE_OPTIONAL_HEADER;\r
+typedef EFI_IMAGE_NT_HEADERS32          EFI_IMAGE_NT_HEADERS;\r
+\r
+#define EFI_IMAGE_NT_OPTIONAL_HDR_MAGIC EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC\r
+#define EFI_IMAGE_MACHINE_TYPE_SUPPORTED(Machine) \\r
+  (((Machine) == EFI_IMAGE_MACHINE_IA32) || ((Machine) == EFI_IMAGE_MACHINE_EBC))\r
+\r
+#elif defined (MDE_CPU_IPF)\r
+\r
+typedef EFI_IMAGE_OPTIONAL_HEADER64     EFI_IMAGE_OPTIONAL_HEADER;\r
+typedef EFI_IMAGE_NT_HEADERS64          EFI_IMAGE_NT_HEADERS;\r
+\r
+#define EFI_IMAGE_NT_OPTIONAL_HDR_MAGIC EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC\r
+#define EFI_IMAGE_MACHINE_TYPE_SUPPORTED(Machine) \\r
+  (((Machine) == EFI_IMAGE_MACHINE_IPF) || ((Machine) == EFI_IMAGE_MACHINE_EBC))\r
+\r
+#elif defined (MDE_CPU_X64)\r
+\r
+typedef EFI_IMAGE_OPTIONAL_HEADER64     EFI_IMAGE_OPTIONAL_HEADER;\r
+typedef EFI_IMAGE_NT_HEADERS64          EFI_IMAGE_NT_HEADERS;\r
+\r
+#define EFI_IMAGE_NT_OPTIONAL_HDR_MAGIC EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC\r
+#define EFI_IMAGE_MACHINE_TYPE_SUPPORTED(Machine) \\r
+  (((Machine) == EFI_IMAGE_MACHINE_X64) || ((Machine) == EFI_IMAGE_MACHINE_EBC))\r
+\r
+#elif defined (MDE_CPU_EBC)\r
+\r
+//\r
+// This is just to make sure you can cross compile with the EBC compiiler.\r
+// It does not make sense to have a PE loader coded in EBC. You need to \r
+// understand the basic \r
+//\r
+typedef EFI_IMAGE_OPTIONAL_HEADER64     EFI_IMAGE_OPTIONAL_HEADER;\r
+typedef EFI_IMAGE_NT_HEADERS64          EFI_IMAGE_NT_HEADERS;\r
+\r
+#define EFI_IMAGE_NT_OPTIONAL_HDR_MAGIC EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC\r
+#define EFI_IMAGE_MACHINE_TYPE_SUPPORTED(Machine) ((Machine) == EFI_IMAGE_MACHINE_EBC)\r
+\r
+#else\r
+#error Unknown Processor Type\r
+#endif\r
+\r
+\r
+#define EFI_IMAGE_FIRST_SECTION(ntheader) \\r
+    ( \\r
+      (EFI_IMAGE_SECTION_HEADER *) \\r
+        ( \\r
+          (UINT32) ntheader + \\r
+          FIELD_OFFSET (EFI_IMAGE_NT_HEADERS, OptionalHeader) + \\r
+          ((EFI_IMAGE_NT_HEADERS *) (ntheader))->FileHeader.SizeOfOptionalHeader \\r
+        ) \\r
+    )\r
+\r
+//\r
+// Subsystem Values\r
+//\r
+#define EFI_IMAGE_SUBSYSTEM_UNKNOWN     0\r
+#define EFI_IMAGE_SUBSYSTEM_NATIVE      1\r
+#define EFI_IMAGE_SUBSYSTEM_WINDOWS_GUI 2\r
+#define EFI_IMAGE_SUBSYSTEM_WINDOWS_CUI 3.\r
+#define EFI_IMAGE_SUBSYSTEM_OS2_CUI     5\r
+#define EFI_IMAGE_SUBSYSTEM_POSIX_CUI   7\r
+\r
+//\r
+// Directory Entries\r
+//\r
+#define EFI_IMAGE_DIRECTORY_ENTRY_EXPORT      0\r
+#define EFI_IMAGE_DIRECTORY_ENTRY_IMPORT      1\r
+#define EFI_IMAGE_DIRECTORY_ENTRY_RESOURCE    2\r
+#define EFI_IMAGE_DIRECTORY_ENTRY_EXCEPTION   3\r
+#define EFI_IMAGE_DIRECTORY_ENTRY_SECURITY    4\r
+#define EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC   5\r
+#define EFI_IMAGE_DIRECTORY_ENTRY_DEBUG       6\r
+#define EFI_IMAGE_DIRECTORY_ENTRY_COPYRIGHT   7\r
+#define EFI_IMAGE_DIRECTORY_ENTRY_GLOBALPTR   8\r
+#define EFI_IMAGE_DIRECTORY_ENTRY_TLS         9\r
+#define EFI_IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG 10\r
+\r
+//\r
+// Section header format.\r
+//\r
+#define EFI_IMAGE_SIZEOF_SHORT_NAME 8\r
+\r
+typedef struct {\r
+  UINT8 Name[EFI_IMAGE_SIZEOF_SHORT_NAME];\r
+  union {\r
+    UINT32  PhysicalAddress;\r
+    UINT32  VirtualSize;\r
+  } Misc;\r
+  UINT32  VirtualAddress;\r
+  UINT32  SizeOfRawData;\r
+  UINT32  PointerToRawData;\r
+  UINT32  PointerToRelocations;\r
+  UINT32  PointerToLinenumbers;\r
+  UINT16  NumberOfRelocations;\r
+  UINT16  NumberOfLinenumbers;\r
+  UINT32  Characteristics;\r
+} EFI_IMAGE_SECTION_HEADER;\r
+\r
+#define EFI_IMAGE_SIZEOF_SECTION_HEADER       40\r
+\r
+#define EFI_IMAGE_SCN_TYPE_NO_PAD             0x00000008  // Reserved.\r
+#define EFI_IMAGE_SCN_CNT_CODE                0x00000020\r
+#define EFI_IMAGE_SCN_CNT_INITIALIZED_DATA    0x00000040\r
+#define EFI_IMAGE_SCN_CNT_UNINITIALIZED_DATA  0x00000080\r
+\r
+#define EFI_IMAGE_SCN_LNK_OTHER               0x00000100  // Reserved.\r
+#define EFI_IMAGE_SCN_LNK_INFO                0x00000200  // Section contains comments or some other type of information.\r
+#define EFI_IMAGE_SCN_LNK_REMOVE              0x00000800  // Section contents will not become part of image.\r
+#define EFI_IMAGE_SCN_LNK_COMDAT              0x00001000\r
+\r
+#define EFI_IMAGE_SCN_ALIGN_1BYTES            0x00100000\r
+#define EFI_IMAGE_SCN_ALIGN_2BYTES            0x00200000\r
+#define EFI_IMAGE_SCN_ALIGN_4BYTES            0x00300000\r
+#define EFI_IMAGE_SCN_ALIGN_8BYTES            0x00400000\r
+#define EFI_IMAGE_SCN_ALIGN_16BYTES           0x00500000\r
+#define EFI_IMAGE_SCN_ALIGN_32BYTES           0x00600000\r
+#define EFI_IMAGE_SCN_ALIGN_64BYTES           0x00700000\r
+\r
+#define EFI_IMAGE_SCN_MEM_DISCARDABLE         0x02000000\r
+#define EFI_IMAGE_SCN_MEM_NOT_CACHED          0x04000000\r
+#define EFI_IMAGE_SCN_MEM_NOT_PAGED           0x08000000\r
+#define EFI_IMAGE_SCN_MEM_SHARED              0x10000000\r
+#define EFI_IMAGE_SCN_MEM_EXECUTE             0x20000000\r
+#define EFI_IMAGE_SCN_MEM_READ                0x40000000\r
+#define EFI_IMAGE_SCN_MEM_WRITE               0x80000000\r
+\r
+///\r
+/// Symbol format.\r
+///\r
+#define EFI_IMAGE_SIZEOF_SYMBOL 18\r
+\r
+//\r
+// Section values.\r
+//\r
+// Symbols have a section number of the section in which they are\r
+// defined. Otherwise, section numbers have the following meanings:\r
+//\r
+#define EFI_IMAGE_SYM_UNDEFINED (UINT16) 0  // Symbol is undefined or is common.\r
+#define EFI_IMAGE_SYM_ABSOLUTE  (UINT16) -1 // Symbol is an absolute value.\r
+#define EFI_IMAGE_SYM_DEBUG     (UINT16) -2 // Symbol is a special debug item.\r
+//\r
+// Type (fundamental) values.\r
+//\r
+#define EFI_IMAGE_SYM_TYPE_NULL   0   // no type.\r
+#define EFI_IMAGE_SYM_TYPE_VOID   1   //\r
+#define EFI_IMAGE_SYM_TYPE_CHAR   2   // type character.\r
+#define EFI_IMAGE_SYM_TYPE_SHORT  3   // type short integer.\r
+#define EFI_IMAGE_SYM_TYPE_INT    4\r
+#define EFI_IMAGE_SYM_TYPE_LONG   5\r
+#define EFI_IMAGE_SYM_TYPE_FLOAT  6\r
+#define EFI_IMAGE_SYM_TYPE_DOUBLE 7\r
+#define EFI_IMAGE_SYM_TYPE_STRUCT 8\r
+#define EFI_IMAGE_SYM_TYPE_UNION  9\r
+#define EFI_IMAGE_SYM_TYPE_ENUM   10  // enumeration.\r
+#define EFI_IMAGE_SYM_TYPE_MOE    11  // member of enumeration.\r
+#define EFI_IMAGE_SYM_TYPE_BYTE   12\r
+#define EFI_IMAGE_SYM_TYPE_WORD   13\r
+#define EFI_IMAGE_SYM_TYPE_UINT   14\r
+#define EFI_IMAGE_SYM_TYPE_DWORD  15\r
+\r
+//\r
+// Type (derived) values.\r
+//\r
+#define EFI_IMAGE_SYM_DTYPE_NULL      0 // no derived type.\r
+#define EFI_IMAGE_SYM_DTYPE_POINTER   1\r
+#define EFI_IMAGE_SYM_DTYPE_FUNCTION  2\r
+#define EFI_IMAGE_SYM_DTYPE_ARRAY     3\r
+\r
+//\r
+// Storage classes.\r
+//\r
+#define EFI_IMAGE_SYM_CLASS_END_OF_FUNCTION   (UINT8) -1\r
+#define EFI_IMAGE_SYM_CLASS_NULL              0\r
+#define EFI_IMAGE_SYM_CLASS_AUTOMATIC         1\r
+#define EFI_IMAGE_SYM_CLASS_EXTERNAL          2\r
+#define EFI_IMAGE_SYM_CLASS_STATIC            3\r
+#define EFI_IMAGE_SYM_CLASS_REGISTER          4\r
+#define EFI_IMAGE_SYM_CLASS_EXTERNAL_DEF      5\r
+#define EFI_IMAGE_SYM_CLASS_LABEL             6\r
+#define EFI_IMAGE_SYM_CLASS_UNDEFINED_LABEL   7\r
+#define EFI_IMAGE_SYM_CLASS_MEMBER_OF_STRUCT  8\r
+#define EFI_IMAGE_SYM_CLASS_ARGUMENT          9\r
+#define EFI_IMAGE_SYM_CLASS_STRUCT_TAG        10\r
+#define EFI_IMAGE_SYM_CLASS_MEMBER_OF_UNION   11\r
+#define EFI_IMAGE_SYM_CLASS_UNION_TAG         12\r
+#define EFI_IMAGE_SYM_CLASS_TYPE_DEFINITION   13\r
+#define EFI_IMAGE_SYM_CLASS_UNDEFINED_STATIC  14\r
+#define EFI_IMAGE_SYM_CLASS_ENUM_TAG          15\r
+#define EFI_IMAGE_SYM_CLASS_MEMBER_OF_ENUM    16\r
+#define EFI_IMAGE_SYM_CLASS_REGISTER_PARAM    17\r
+#define EFI_IMAGE_SYM_CLASS_BIT_FIELD         18\r
+#define EFI_IMAGE_SYM_CLASS_BLOCK             100\r
+#define EFI_IMAGE_SYM_CLASS_FUNCTION          101\r
+#define EFI_IMAGE_SYM_CLASS_END_OF_STRUCT     102\r
+#define EFI_IMAGE_SYM_CLASS_FILE              103\r
+#define EFI_IMAGE_SYM_CLASS_SECTION           104\r
+#define EFI_IMAGE_SYM_CLASS_WEAK_EXTERNAL     105\r
+\r
+//\r
+// type packing constants\r
+//\r
+#define EFI_IMAGE_N_BTMASK  017\r
+#define EFI_IMAGE_N_TMASK   060\r
+#define EFI_IMAGE_N_TMASK1  0300\r
+#define EFI_IMAGE_N_TMASK2  0360\r
+#define EFI_IMAGE_N_BTSHFT  4\r
+#define EFI_IMAGE_N_TSHIFT  2\r
+\r
+//\r
+// Communal selection types.\r
+//\r
+#define EFI_IMAGE_COMDAT_SELECT_NODUPLICATES    1\r
+#define EFI_IMAGE_COMDAT_SELECT_ANY             2\r
+#define EFI_IMAGE_COMDAT_SELECT_SAME_SIZE       3\r
+#define EFI_IMAGE_COMDAT_SELECT_EXACT_MATCH     4\r
+#define EFI_IMAGE_COMDAT_SELECT_ASSOCIATIVE     5\r
+\r
+#define EFI_IMAGE_WEAK_EXTERN_SEARCH_NOLIBRARY  1\r
+#define EFI_IMAGE_WEAK_EXTERN_SEARCH_LIBRARY    2\r
+#define EFI_IMAGE_WEAK_EXTERN_SEARCH_ALIAS      3\r
+\r
+///\r
+/// Relocation format.\r
+///\r
+typedef struct {\r
+  UINT32  VirtualAddress;\r
+  UINT32  SymbolTableIndex;\r
+  UINT16  Type;\r
+} EFI_IMAGE_RELOCATION;\r
+\r
+#define EFI_IMAGE_SIZEOF_RELOCATION 10\r
+\r
+//\r
+// I386 relocation types.\r
+//\r
+#define EFI_IMAGE_REL_I386_ABSOLUTE 0   // Reference is absolute, no relocation is necessary\r
+#define EFI_IMAGE_REL_I386_DIR16    01  // Direct 16-bit reference to the symbols virtual address\r
+#define EFI_IMAGE_REL_I386_REL16    02  // PC-relative 16-bit reference to the symbols virtual address\r
+#define EFI_IMAGE_REL_I386_DIR32    06  // Direct 32-bit reference to the symbols virtual address\r
+#define EFI_IMAGE_REL_I386_DIR32NB  07  // Direct 32-bit reference to the symbols virtual address, base not included\r
+#define EFI_IMAGE_REL_I386_SEG12    011 // Direct 16-bit reference to the segment-selector bits of a 32-bit virtual address\r
+#define EFI_IMAGE_REL_I386_SECTION  012\r
+#define EFI_IMAGE_REL_I386_SECREL   013\r
+#define EFI_IMAGE_REL_I386_REL32    024 // PC-relative 32-bit reference to the symbols virtual address\r
+\r
+///\r
+/// Based relocation format.\r
+///\r
+typedef struct {\r
+  UINT32  VirtualAddress;\r
+  UINT32  SizeOfBlock;\r
+} EFI_IMAGE_BASE_RELOCATION;\r
+\r
+#define EFI_IMAGE_SIZEOF_BASE_RELOCATION  8\r
+\r
+//\r
+// Based relocation types.\r
+//\r
+#define EFI_IMAGE_REL_BASED_ABSOLUTE      0\r
+#define EFI_IMAGE_REL_BASED_HIGH          1\r
+#define EFI_IMAGE_REL_BASED_LOW           2\r
+#define EFI_IMAGE_REL_BASED_HIGHLOW       3\r
+#define EFI_IMAGE_REL_BASED_HIGHADJ       4\r
+#define EFI_IMAGE_REL_BASED_MIPS_JMPADDR  5\r
+#define EFI_IMAGE_REL_BASED_IA64_IMM64    9\r
+#define EFI_IMAGE_REL_BASED_DIR64         10\r
+\r
+///\r
+/// Line number format.\r
+///\r
+typedef struct {\r
+  union {\r
+    UINT32  SymbolTableIndex; // Symbol table index of function name if Linenumber is 0.\r
+    UINT32  VirtualAddress;   // Virtual address of line number.\r
+  } Type;\r
+  UINT16  Linenumber;         // Line number.\r
+} EFI_IMAGE_LINENUMBER;\r
+\r
+#define EFI_IMAGE_SIZEOF_LINENUMBER 6\r
+\r
+//\r
+// Archive format.\r
+//\r
+#define EFI_IMAGE_ARCHIVE_START_SIZE        8\r
+#define EFI_IMAGE_ARCHIVE_START             "!<arch>\n"\r
+#define EFI_IMAGE_ARCHIVE_END               "`\n"\r
+#define EFI_IMAGE_ARCHIVE_PAD               "\n"\r
+#define EFI_IMAGE_ARCHIVE_LINKER_MEMBER     "/               "\r
+#define EFI_IMAGE_ARCHIVE_LONGNAMES_MEMBER  "//              "\r
+\r
+typedef struct {\r
+  UINT8 Name[16];     // File member name - `/' terminated.\r
+  UINT8 Date[12];     // File member date - decimal.\r
+  UINT8 UserID[6];    // File member user id - decimal.\r
+  UINT8 GroupID[6];   // File member group id - decimal.\r
+  UINT8 Mode[8];      // File member mode - octal.\r
+  UINT8 Size[10];     // File member size - decimal.\r
+  UINT8 EndHeader[2]; // String to end header.\r
+} EFI_IMAGE_ARCHIVE_MEMBER_HEADER;\r
+\r
+#define EFI_IMAGE_SIZEOF_ARCHIVE_MEMBER_HDR 60\r
+\r
+//\r
+// DLL support.\r
+//\r
+\r
+///\r
+/// DLL Export Format\r
+///\r
+typedef struct {\r
+  UINT32  Characteristics;\r
+  UINT32  TimeDateStamp;\r
+  UINT16  MajorVersion;\r
+  UINT16  MinorVersion;\r
+  UINT32  Name;\r
+  UINT32  Base;\r
+  UINT32  NumberOfFunctions;\r
+  UINT32  NumberOfNames;\r
+  UINT32  AddressOfFunctions;\r
+  UINT32  AddressOfNames;\r
+  UINT32  AddressOfNameOrdinals;\r
+} EFI_IMAGE_EXPORT_DIRECTORY;\r
+\r
+///\r
+/// DLL support.\r
+/// Import Format\r
+///\r
+typedef struct {\r
+  UINT16  Hint;\r
+  UINT8   Name[1];\r
+} EFI_IMAGE_IMPORT_BY_NAME;\r
+\r
+typedef struct {\r
+  union {\r
+    UINT32                    Function;\r
+    UINT32                    Ordinal;\r
+    EFI_IMAGE_IMPORT_BY_NAME  *AddressOfData;\r
+  } u1;\r
+} EFI_IMAGE_THUNK_DATA;\r
+\r
+#define EFI_IMAGE_ORDINAL_FLAG              0x80000000\r
+#define EFI_IMAGE_SNAP_BY_ORDINAL(Ordinal)  ((Ordinal & EFI_IMAGE_ORDINAL_FLAG) != 0)\r
+#define EFI_IMAGE_ORDINAL(Ordinal)          (Ordinal & 0xffff)\r
+\r
+typedef struct {\r
+  UINT32                Characteristics;\r
+  UINT32                TimeDateStamp;\r
+  UINT32                ForwarderChain;\r
+  UINT32                Name;\r
+  EFI_IMAGE_THUNK_DATA  *FirstThunk;\r
+} EFI_IMAGE_IMPORT_DESCRIPTOR;\r
+\r
+///\r
+/// Debug Format\r
+///\r
+#define EFI_IMAGE_DEBUG_TYPE_CODEVIEW 2\r
+\r
+typedef struct {\r
+  UINT32  Characteristics;\r
+  UINT32  TimeDateStamp;\r
+  UINT16  MajorVersion;\r
+  UINT16  MinorVersion;\r
+  UINT32  Type;\r
+  UINT32  SizeOfData;\r
+  UINT32  RVA;\r
+  UINT32  FileOffset;\r
+} EFI_IMAGE_DEBUG_DIRECTORY_ENTRY;\r
+\r
+#define CODEVIEW_SIGNATURE_NB10 0x3031424E  // "NB10"\r
+typedef struct {\r
+  UINT32  Signature;                        // "NB10"\r
+  UINT32  Unknown;\r
+  UINT32  Unknown2;\r
+  UINT32  Unknown3;\r
+  //\r
+  // Filename of .PDB goes here\r
+  //\r
+} EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY;\r
+\r
+#define CODEVIEW_SIGNATURE_RSDS 0x53445352  // "RSDS"\r
+typedef struct {\r
+  UINT32  Signature;                        // "RSDS"\r
+  UINT32  Unknown;\r
+  UINT32  Unknown2;\r
+  UINT32  Unknown3;\r
+  UINT32  Unknown4;\r
+  UINT32  Unknown5;\r
+  //\r
+  // Filename of .PDB goes here\r
+  //\r
+} EFI_IMAGE_DEBUG_CODEVIEW_RSDS_ENTRY;\r
+\r
+//\r
+// .pdata entries for X64\r
+//\r
+typedef struct {\r
+  UINT32  FunctionStartAddress;\r
+  UINT32  FunctionEndAddress;\r
+  UINT32  UnwindInfoAddress;\r
+} RUNTIME_FUNCTION;\r
+\r
+typedef struct {\r
+  UINT8  Version:3;\r
+  UINT8  Flags:5;\r
+  UINT8  SizeOfProlog;\r
+  UINT8  CountOfUnwindCodes;\r
+  UINT8  FrameRegister:4;\r
+  UINT8  FrameRegisterOffset:4;\r
+} UNWIND_INFO;\r
+\r
+///\r
+/// Header format for TE images\r
+///\r
+typedef struct {\r
+  UINT16                    Signature;            // signature for TE format = "VZ"\r
+  UINT16                    Machine;              // from the original file header\r
+  UINT8                     NumberOfSections;     // from the original file header\r
+  UINT8                     Subsystem;            // from original optional header\r
+  UINT16                    StrippedSize;         // how many bytes we removed from the header\r
+  UINT32                    AddressOfEntryPoint;  // offset to entry point -- from original optional header\r
+  UINT32                    BaseOfCode;           // from original image -- required for ITP debug\r
+  UINT64                    ImageBase;            // from original file header\r
+  EFI_IMAGE_DATA_DIRECTORY  DataDirectory[2];     // only base relocation and debug directory\r
+} EFI_TE_IMAGE_HEADER;\r
+\r
+#define EFI_TE_IMAGE_HEADER_SIGNATURE 0x5A56      // "VZ"\r
+\r
+//\r
+// Data directory indexes in our TE image header\r
+//\r
+#define EFI_TE_IMAGE_DIRECTORY_ENTRY_BASERELOC  0\r
+#define EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG      1\r
+\r
+#endif\r
diff --git a/Tools/CodeTools/Source/Include/Common/FirmwareFileSystem.h b/Tools/CodeTools/Source/Include/Common/FirmwareFileSystem.h
new file mode 100644 (file)
index 0000000..5678a95
--- /dev/null
@@ -0,0 +1,98 @@
+/** @file\r
+  This file defines the data structures that comprise the FFS file system.\r
+\r
+  Copyright (c) 2006, Intel Corporation                                                         \r
+  All rights reserved. This program and the accompanying materials                          \r
+  are licensed and made available under the terms and conditions of the BSD License         \r
+  which accompanies this distribution.  The full text of the license may be found at        \r
+  http://opensource.org/licenses/bsd-license.php                                            \r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+  Module Name:  FirmwareFileSystem.h\r
+\r
+  @par Revision Reference:\r
+  These definitions are from Firmware File System Spec 0.9.\r
+\r
+**/\r
+\r
+#ifndef __EFI_FFS_FILE_SYSTEM_H__\r
+#define __EFI_FFS_FILE_SYSTEM_H__\r
+\r
+///\r
+/// FFS specific file types\r
+///\r
+#define EFI_FV_FILETYPE_FFS_PAD 0xF0\r
+\r
+//\r
+// FFS File Attributes\r
+//\r
+#define FFS_ATTRIB_TAIL_PRESENT     0x01\r
+#define FFS_ATTRIB_RECOVERY         0x02\r
+#define FFS_ATTRIB_HEADER_EXTENSION 0x04\r
+#define FFS_ATTRIB_DATA_ALIGNMENT   0x38\r
+#define FFS_ATTRIB_CHECKSUM         0x40\r
+\r
+///\r
+/// FFS_FIXED_CHECKSUM is the default checksum value used when the\r
+/// FFS_ATTRIB_CHECKSUM attribute bit is clear\r
+/// note this is NOT an architecturally defined value, but is in this file for\r
+/// implementation convenience\r
+///\r
+#define FFS_FIXED_CHECKSUM  0x5A\r
+\r
+//\r
+// File state definitions\r
+//\r
+#define EFI_FILE_HEADER_CONSTRUCTION  0x01\r
+#define EFI_FILE_HEADER_VALID         0x02\r
+#define EFI_FILE_DATA_VALID           0x04\r
+#define EFI_FILE_MARKED_FOR_UPDATE    0x08\r
+#define EFI_FILE_DELETED              0x10\r
+#define EFI_FILE_HEADER_INVALID       0x20\r
+\r
+#define EFI_FILE_ALL_STATE_BITS       (EFI_FILE_HEADER_CONSTRUCTION | \\r
+                                 EFI_FILE_HEADER_VALID | \\r
+                                 EFI_FILE_DATA_VALID | \\r
+                                 EFI_FILE_MARKED_FOR_UPDATE | \\r
+                                 EFI_FILE_DELETED | \\r
+                                 EFI_FILE_HEADER_INVALID \\r
+          )\r
+\r
+#define EFI_TEST_FFS_ATTRIBUTES_BIT(FvbAttributes, TestAttributes, Bit) \\r
+    ( \\r
+      (BOOLEAN) ( \\r
+          (FvbAttributes & EFI_FVB_ERASE_POLARITY) ? (((~TestAttributes) & Bit) == Bit) : ((TestAttributes & Bit) == Bit) \\r
+        ) \\r
+    )\r
+\r
+typedef UINT16  EFI_FFS_FILE_TAIL;\r
+\r
+///\r
+/// FFS file integrity check structure\r
+///\r
+typedef union {\r
+  struct {\r
+    UINT8 Header;\r
+    UINT8 File;\r
+  } Checksum;\r
+  UINT16  TailReference;\r
+} EFI_FFS_INTEGRITY_CHECK;\r
+\r
+//\r
+// FFS file header definition\r
+//\r
+typedef UINT8 EFI_FFS_FILE_ATTRIBUTES;\r
+typedef UINT8 EFI_FFS_FILE_STATE;\r
+\r
+typedef struct {\r
+  EFI_GUID                Name;\r
+  EFI_FFS_INTEGRITY_CHECK IntegrityCheck;\r
+  EFI_FV_FILETYPE         Type;\r
+  EFI_FFS_FILE_ATTRIBUTES Attributes;\r
+  UINT8                   Size[3];\r
+  EFI_FFS_FILE_STATE      State;\r
+} EFI_FFS_FILE_HEADER;\r
+\r
+#endif\r
diff --git a/Tools/CodeTools/Source/Include/Common/FirmwareVolumeHeader.h b/Tools/CodeTools/Source/Include/Common/FirmwareVolumeHeader.h
new file mode 100644 (file)
index 0000000..038dce6
--- /dev/null
@@ -0,0 +1,109 @@
+/** @file\r
+  Defines data structure that is the volume header found at the beginning of\r
+  all firmware volumes that are either memory mapped, or have an\r
+  associated FirmwareVolumeBlock protocol.\r
+\r
+  Copyright (c) 2006, Intel Corporation                                                         \r
+  All rights reserved. This program and the accompanying materials                          \r
+  are licensed and made available under the terms and conditions of the BSD License         \r
+  which accompanies this distribution.  The full text of the license may be found at        \r
+  http://opensource.org/licenses/bsd-license.php                                            \r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+  Module Name:  FirmwareVolumeHeader.h\r
+\r
+  @par Revision Reference:\r
+  These definitions are from Firmware Volume Block Spec 0.9.\r
+\r
+**/\r
+\r
+#ifndef __EFI_FIRMWARE_VOLUME_HEADER_H__\r
+#define __EFI_FIRMWARE_VOLUME_HEADER_H__\r
+\r
+//\r
+// Firmware Volume Block Attributes definition\r
+//\r
+typedef UINT32  EFI_FVB_ATTRIBUTES;\r
+\r
+//\r
+// Firmware Volume Block Attributes bit definitions\r
+//\r
+#define EFI_FVB_READ_DISABLED_CAP   0x00000001\r
+#define EFI_FVB_READ_ENABLED_CAP    0x00000002\r
+#define EFI_FVB_READ_STATUS         0x00000004\r
+\r
+#define EFI_FVB_WRITE_DISABLED_CAP  0x00000008\r
+#define EFI_FVB_WRITE_ENABLED_CAP   0x00000010\r
+#define EFI_FVB_WRITE_STATUS        0x00000020\r
+\r
+#define EFI_FVB_LOCK_CAP            0x00000040\r
+#define EFI_FVB_LOCK_STATUS         0x00000080\r
+\r
+#define EFI_FVB_STICKY_WRITE        0x00000200\r
+#define EFI_FVB_MEMORY_MAPPED       0x00000400\r
+#define EFI_FVB_ERASE_POLARITY      0x00000800\r
+\r
+#define EFI_FVB_ALIGNMENT_CAP       0x00008000\r
+#define EFI_FVB_ALIGNMENT_2         0x00010000\r
+#define EFI_FVB_ALIGNMENT_4         0x00020000\r
+#define EFI_FVB_ALIGNMENT_8         0x00040000\r
+#define EFI_FVB_ALIGNMENT_16        0x00080000\r
+#define EFI_FVB_ALIGNMENT_32        0x00100000\r
+#define EFI_FVB_ALIGNMENT_64        0x00200000\r
+#define EFI_FVB_ALIGNMENT_128       0x00400000\r
+#define EFI_FVB_ALIGNMENT_256       0x00800000\r
+#define EFI_FVB_ALIGNMENT_512       0x01000000\r
+#define EFI_FVB_ALIGNMENT_1K        0x02000000\r
+#define EFI_FVB_ALIGNMENT_2K        0x04000000\r
+#define EFI_FVB_ALIGNMENT_4K        0x08000000\r
+#define EFI_FVB_ALIGNMENT_8K        0x10000000\r
+#define EFI_FVB_ALIGNMENT_16K       0x20000000\r
+#define EFI_FVB_ALIGNMENT_32K       0x40000000\r
+#define EFI_FVB_ALIGNMENT_64K       0x80000000\r
+\r
+#define EFI_FVB_CAPABILITIES  (EFI_FVB_READ_DISABLED_CAP | \\r
+                              EFI_FVB_READ_ENABLED_CAP | \\r
+                              EFI_FVB_WRITE_DISABLED_CAP | \\r
+                              EFI_FVB_WRITE_ENABLED_CAP | \\r
+                              EFI_FVB_LOCK_CAP \\r
+                              )\r
+\r
+#define EFI_FVB_STATUS    (EFI_FVB_READ_STATUS | EFI_FVB_WRITE_STATUS | EFI_FVB_LOCK_STATUS)\r
+\r
+///\r
+/// Firmware Volume Header Revision definition\r
+///\r
+#define EFI_FVH_REVISION  0x01\r
+\r
+///\r
+/// Firmware Volume Header Signature definition\r
+///\r
+#define EFI_FVH_SIGNATURE EFI_SIGNATURE_32 ('_', 'F', 'V', 'H')\r
+\r
+///\r
+/// Firmware Volume Header Block Map Entry definition\r
+///\r
+typedef struct {\r
+  UINT32  NumBlocks;\r
+  UINT32  BlockLength;\r
+} EFI_FV_BLOCK_MAP_ENTRY;\r
+\r
+///\r
+/// Firmware Volume Header definition\r
+///\r
+typedef struct {\r
+  UINT8                   ZeroVector[16];\r
+  EFI_GUID                FileSystemGuid;\r
+  UINT64                  FvLength;\r
+  UINT32                  Signature;\r
+  EFI_FVB_ATTRIBUTES      Attributes;\r
+  UINT16                  HeaderLength;\r
+  UINT16                  Checksum;\r
+  UINT8                   Reserved[3];\r
+  UINT8                   Revision;\r
+  EFI_FV_BLOCK_MAP_ENTRY  FvBlockMap[1];\r
+} EFI_FIRMWARE_VOLUME_HEADER;\r
+\r
+#endif\r
diff --git a/Tools/CodeTools/Source/Include/Common/FirmwareVolumeImageFormat.h b/Tools/CodeTools/Source/Include/Common/FirmwareVolumeImageFormat.h
new file mode 100644 (file)
index 0000000..14fa41b
--- /dev/null
@@ -0,0 +1,277 @@
+/** @file\r
+  This file defines the data structures that are architecturally defined for file\r
+  images loaded via the FirmwareVolume protocol.  The Firmware Volume specification\r
+  is the basis for these definitions.\r
+\r
+  Copyright (c) 2006, Intel Corporation                                                         \r
+  All rights reserved. This program and the accompanying materials                          \r
+  are licensed and made available under the terms and conditions of the BSD License         \r
+  which accompanies this distribution.  The full text of the license may be found at        \r
+  http://opensource.org/licenses/bsd-license.php                                            \r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+  Module Name:  FimrwareVolumeImageFormat.h\r
+\r
+  @par Revision Reference:\r
+  These definitions are from Firmware Volume Spec 0.9.\r
+\r
+**/\r
+\r
+#ifndef __FIRMWARE_VOLUME_IMAGE_FORMAT_H__\r
+#define __FIRMWARE_VOLUME_IMAGE_FORMAT_H__\r
+\r
+//\r
+// pack all data structures since this is actually a binary format and we cannot\r
+// allow internal padding in the data structures because of some compilerism..\r
+//\r
+#pragma pack(1)\r
+//\r
+// ////////////////////////////////////////////////////////////////////////////\r
+//\r
+// Architectural file types\r
+//\r
+typedef UINT8 EFI_FV_FILETYPE;\r
+\r
+#define EFI_FV_FILETYPE_ALL                   0x00\r
+#define EFI_FV_FILETYPE_RAW                   0x01\r
+#define EFI_FV_FILETYPE_FREEFORM              0x02\r
+#define EFI_FV_FILETYPE_SECURITY_CORE         0x03\r
+#define EFI_FV_FILETYPE_PEI_CORE              0x04\r
+#define EFI_FV_FILETYPE_DXE_CORE              0x05\r
+#define EFI_FV_FILETYPE_PEIM                  0x06\r
+#define EFI_FV_FILETYPE_DRIVER                0x07\r
+#define EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER  0x08\r
+#define EFI_FV_FILETYPE_APPLICATION           0x09\r
+//\r
+// File type 0x0A is reserved and should not be used\r
+//\r
+#define EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE 0x0B\r
+\r
+//\r
+// ////////////////////////////////////////////////////////////////////////////\r
+//\r
+// Section types\r
+//\r
+typedef UINT8 EFI_SECTION_TYPE;\r
+\r
+//\r
+// ************************************************************\r
+// The section type EFI_SECTION_ALL is a psuedo type.  It is\r
+// used as a wildcard when retrieving sections.  The section\r
+// type EFI_SECTION_ALL matches all section types.\r
+// ************************************************************\r
+//\r
+#define EFI_SECTION_ALL 0x00\r
+\r
+//\r
+// ************************************************************\r
+// Encapsulation section Type values\r
+// ************************************************************\r
+//\r
+#define EFI_SECTION_COMPRESSION   0x01\r
+#define EFI_SECTION_GUID_DEFINED  0x02\r
+\r
+//\r
+// ************************************************************\r
+// Leaf section Type values\r
+// ************************************************************\r
+//\r
+#define EFI_SECTION_FIRST_LEAF_SECTION_TYPE 0x10\r
+\r
+#define EFI_SECTION_PE32                    0x10\r
+#define EFI_SECTION_PIC                     0x11\r
+#define EFI_SECTION_TE                      0x12\r
+#define EFI_SECTION_DXE_DEPEX               0x13\r
+#define EFI_SECTION_VERSION                 0x14\r
+#define EFI_SECTION_USER_INTERFACE          0x15\r
+#define EFI_SECTION_COMPATIBILITY16         0x16\r
+#define EFI_SECTION_FIRMWARE_VOLUME_IMAGE   0x17\r
+#define EFI_SECTION_FREEFORM_SUBTYPE_GUID   0x18\r
+#define EFI_SECTION_RAW                     0x19\r
+#define EFI_SECTION_PEI_DEPEX               0x1B\r
+\r
+#define EFI_SECTION_LAST_LEAF_SECTION_TYPE  0x1B\r
+#define EFI_SECTION_LAST_SECTION_TYPE       0x1B\r
+\r
+//\r
+// ////////////////////////////////////////////////////////////////////////////\r
+//\r
+// Common section header\r
+//\r
+typedef struct {\r
+  UINT8 Size[3];\r
+  UINT8 Type;\r
+} EFI_COMMON_SECTION_HEADER;\r
+\r
+#define SECTION_SIZE(SectionHeaderPtr) \\r
+    ((UINT32) (*((UINT32 *) ((EFI_COMMON_SECTION_HEADER *) SectionHeaderPtr)->Size) & 0x00ffffff))\r
+\r
+//\r
+// ////////////////////////////////////////////////////////////////////////////\r
+//\r
+// Compression section\r
+//\r
+//\r
+// CompressionType values\r
+//\r
+#define EFI_NOT_COMPRESSED          0x00\r
+#define EFI_STANDARD_COMPRESSION    0x01\r
+#define EFI_CUSTOMIZED_COMPRESSION  0x02\r
+\r
+typedef struct {\r
+  EFI_COMMON_SECTION_HEADER CommonHeader;\r
+  UINT32                    UncompressedLength;\r
+  UINT8                     CompressionType;\r
+} EFI_COMPRESSION_SECTION;\r
+\r
+//\r
+// ////////////////////////////////////////////////////////////////////////////\r
+//\r
+// GUID defined section\r
+//\r
+typedef struct {\r
+  EFI_COMMON_SECTION_HEADER CommonHeader;\r
+  EFI_GUID                  SectionDefinitionGuid;\r
+  UINT16                    DataOffset;\r
+  UINT16                    Attributes;\r
+} EFI_GUID_DEFINED_SECTION;\r
+\r
+//\r
+// Bit values for Attributes\r
+//\r
+#define EFI_GUIDED_SECTION_PROCESSING_REQUIRED  0x01\r
+#define EFI_GUIDED_SECTION_AUTH_STATUS_VALID    0x02\r
+\r
+//\r
+// Bit values for AuthenticationStatus\r
+//\r
+#define EFI_AGGREGATE_AUTH_STATUS_PLATFORM_OVERRIDE 0x000001\r
+#define EFI_AGGREGATE_AUTH_STATUS_IMAGE_SIGNED      0x000002\r
+#define EFI_AGGREGATE_AUTH_STATUS_NOT_TESTED        0x000004\r
+#define EFI_AGGREGATE_AUTH_STATUS_TEST_FAILED       0x000008\r
+#define EFI_AGGREGATE_AUTH_STATUS_ALL               0x00000f\r
+\r
+#define EFI_LOCAL_AUTH_STATUS_PLATFORM_OVERRIDE     0x010000\r
+#define EFI_LOCAL_AUTH_STATUS_IMAGE_SIGNED          0x020000\r
+#define EFI_LOCAL_AUTH_STATUS_NOT_TESTED            0x040000\r
+#define EFI_LOCAL_AUTH_STATUS_TEST_FAILED           0x080000\r
+#define EFI_LOCAL_AUTH_STATUS_ALL                   0x0f0000\r
+\r
+//\r
+// ////////////////////////////////////////////////////////////////////////////\r
+//\r
+// PE32+ section\r
+//\r
+typedef struct {\r
+  EFI_COMMON_SECTION_HEADER CommonHeader;\r
+} EFI_PE32_SECTION;\r
+\r
+//\r
+// ////////////////////////////////////////////////////////////////////////////\r
+//\r
+// PIC section\r
+//\r
+typedef struct {\r
+  EFI_COMMON_SECTION_HEADER CommonHeader;\r
+} EFI_PIC_SECTION;\r
+\r
+//\r
+// ////////////////////////////////////////////////////////////////////////////\r
+//\r
+// PEIM header section\r
+//\r
+typedef struct {\r
+  EFI_COMMON_SECTION_HEADER CommonHeader;\r
+} EFI_PEIM_HEADER_SECTION;\r
+\r
+//\r
+// ////////////////////////////////////////////////////////////////////////////\r
+//\r
+// DEPEX section\r
+//\r
+typedef struct {\r
+  EFI_COMMON_SECTION_HEADER CommonHeader;\r
+} EFI_DEPEX_SECTION;\r
+\r
+//\r
+// ////////////////////////////////////////////////////////////////////////////\r
+//\r
+// Version section\r
+//\r
+typedef struct {\r
+  EFI_COMMON_SECTION_HEADER CommonHeader;\r
+  UINT16                    BuildNumber;\r
+  INT16                     VersionString[1];\r
+} EFI_VERSION_SECTION;\r
+\r
+//\r
+// ////////////////////////////////////////////////////////////////////////////\r
+//\r
+// User interface section\r
+//\r
+typedef struct {\r
+  EFI_COMMON_SECTION_HEADER CommonHeader;\r
+  INT16                     FileNameString[1];\r
+} EFI_USER_INTERFACE_SECTION;\r
+\r
+//\r
+// ////////////////////////////////////////////////////////////////////////////\r
+//\r
+// Code16 section\r
+//\r
+typedef struct {\r
+  EFI_COMMON_SECTION_HEADER CommonHeader;\r
+} EFI_CODE16_SECTION;\r
+\r
+//\r
+// ////////////////////////////////////////////////////////////////////////////\r
+//\r
+// Firmware Volume Image section\r
+//\r
+typedef struct {\r
+  EFI_COMMON_SECTION_HEADER CommonHeader;\r
+} EFI_FIRMWARE_VOLUME_IMAGE_SECTION;\r
+\r
+//\r
+// ////////////////////////////////////////////////////////////////////////////\r
+//\r
+// Freeform subtype GUID section\r
+//\r
+typedef struct {\r
+  EFI_COMMON_SECTION_HEADER CommonHeader;\r
+  EFI_GUID                  SubTypeGuid;\r
+} EFI_FREEFORM_SUBTYPE_GUID_SECTION;\r
+\r
+//\r
+// ////////////////////////////////////////////////////////////////////////////\r
+//\r
+// Raw section\r
+//\r
+typedef struct {\r
+  EFI_COMMON_SECTION_HEADER CommonHeader;\r
+} EFI_RAW_SECTION;\r
+\r
+//\r
+// undo the pragma from the beginning...\r
+//\r
+#pragma pack()\r
+\r
+typedef union {\r
+  EFI_COMMON_SECTION_HEADER         *CommonHeader;\r
+  EFI_COMPRESSION_SECTION           *CompressionSection;\r
+  EFI_GUID_DEFINED_SECTION          *GuidDefinedSection;\r
+  EFI_PE32_SECTION                  *Pe32Section;\r
+  EFI_PIC_SECTION                   *PicSection;\r
+  EFI_PEIM_HEADER_SECTION           *PeimHeaderSection;\r
+  EFI_DEPEX_SECTION                 *DependencySection;\r
+  EFI_VERSION_SECTION               *VersionSection;\r
+  EFI_USER_INTERFACE_SECTION        *UISection;\r
+  EFI_CODE16_SECTION                *Code16Section;\r
+  EFI_FIRMWARE_VOLUME_IMAGE_SECTION *FVImageSection;\r
+  EFI_FREEFORM_SUBTYPE_GUID_SECTION *FreeformSubtypeSection;\r
+  EFI_RAW_SECTION                   *RawSection;\r
+} EFI_FILE_SECTION_POINTER;\r
+\r
+#endif\r
diff --git a/Tools/CodeTools/Source/Include/Common/InternalFormRepresentation.h b/Tools/CodeTools/Source/Include/Common/InternalFormRepresentation.h
new file mode 100644 (file)
index 0000000..bf3d824
--- /dev/null
@@ -0,0 +1,422 @@
+/** @file\r
+  This file defines the encoding for the VFR (Visual Form Representation) language.\r
+  IFR is primarily consumed by the EFI presentation engine, and produced by EFI\r
+  internal application and drivers as well as all add-in card option-ROM drivers\r
+\r
+  Copyright (c) 2006, Intel Corporation                                                         \r
+  All rights reserved. This program and the accompanying materials                          \r
+  are licensed and made available under the terms and conditions of the BSD License         \r
+  which accompanies this distribution.  The full text of the license may be found at        \r
+  http://opensource.org/licenses/bsd-license.php                                            \r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+  Module Name:  InternalFormRepresentation.h\r
+\r
+  @par Revision Reference:\r
+  These definitions are from Human Interface Infrastructure Spec Version 0.92.\r
+\r
+**/\r
+\r
+#ifndef __EFI_INTERNAL_FORM_REPRESENTATION_H__\r
+#define __EFI_INTERNAL_FORM_REPRESENTATION_H__\r
+\r
+//\r
+// The following types are currently defined:\r
+//\r
+typedef UINT32  RELOFST;\r
+typedef CHAR16  *EFI_STRING;\r
+\r
+//\r
+// IFR Op codes\r
+//\r
+#define EFI_IFR_FORM_OP                 0x01\r
+#define EFI_IFR_SUBTITLE_OP             0x02\r
+#define EFI_IFR_TEXT_OP                 0x03\r
+#define EFI_IFR_GRAPHIC_OP              0x04\r
+#define EFI_IFR_ONE_OF_OP               0x05\r
+#define EFI_IFR_CHECKBOX_OP             0x06\r
+#define EFI_IFR_NUMERIC_OP              0x07\r
+#define EFI_IFR_PASSWORD_OP             0x08\r
+#define EFI_IFR_ONE_OF_OPTION_OP        0x09  // ONEOF OPTION field\r
+#define EFI_IFR_SUPPRESS_IF_OP          0x0A\r
+#define EFI_IFR_END_FORM_OP             0x0B\r
+#define EFI_IFR_HIDDEN_OP               0x0C\r
+#define EFI_IFR_END_FORM_SET_OP         0x0D\r
+#define EFI_IFR_FORM_SET_OP             0x0E\r
+#define EFI_IFR_REF_OP                  0x0F\r
+#define EFI_IFR_END_ONE_OF_OP           0x10\r
+#define EFI_IFR_END_OP                  EFI_IFR_END_ONE_OF_OP\r
+#define EFI_IFR_INCONSISTENT_IF_OP      0x11\r
+#define EFI_IFR_EQ_ID_VAL_OP            0x12\r
+#define EFI_IFR_EQ_ID_ID_OP             0x13\r
+#define EFI_IFR_EQ_ID_LIST_OP           0x14\r
+#define EFI_IFR_AND_OP                  0x15\r
+#define EFI_IFR_OR_OP                   0x16\r
+#define EFI_IFR_NOT_OP                  0x17\r
+#define EFI_IFR_END_IF_OP               0x18  // for endif of inconsistentif, suppressif, grayoutif\r
+#define EFI_IFR_GRAYOUT_IF_OP           0x19\r
+#define EFI_IFR_DATE_OP                 0x1A\r
+#define EFI_IFR_TIME_OP                 0x1B\r
+#define EFI_IFR_STRING_OP               0x1C\r
+#define EFI_IFR_LABEL_OP                0x1D\r
+#define EFI_IFR_SAVE_DEFAULTS_OP        0x1E\r
+#define EFI_IFR_RESTORE_DEFAULTS_OP     0x1F\r
+#define EFI_IFR_BANNER_OP               0x20\r
+#define EFI_IFR_INVENTORY_OP            0x21\r
+#define EFI_IFR_EQ_VAR_VAL_OP           0x22\r
+#define EFI_IFR_ORDERED_LIST_OP         0x23\r
+#define EFI_IFR_VARSTORE_OP             0x24\r
+#define EFI_IFR_VARSTORE_SELECT_OP      0x25\r
+#define EFI_IFR_VARSTORE_SELECT_PAIR_OP 0x26\r
+#define EFI_IFR_TRUE_OP                 0x27\r
+#define EFI_IFR_FALSE_OP                0x28\r
+#define EFI_IFR_GT_OP                   0x29\r
+#define EFI_IFR_GE_OP                   0x2A\r
+#define EFI_IFR_OEM_DEFINED_OP          0x2B\r
+#define EFI_IFR_LAST_OPCODE             EFI_IFR_OEM_DEFINED_OP\r
+#define EFI_IFR_OEM_OP                  0xFE\r
+#define EFI_IFR_NV_ACCESS_COMMAND       0xFF\r
+\r
+//\r
+// Define values for the flags fields in some VFR opcodes. These are\r
+// bitmasks.\r
+//\r
+#define EFI_IFR_FLAG_DEFAULT              0x01\r
+#define EFI_IFR_FLAG_MANUFACTURING        0x02\r
+#define EFI_IFR_FLAG_INTERACTIVE          0x04\r
+#define EFI_IFR_FLAG_NV_ACCESS            0x08\r
+#define EFI_IFR_FLAG_RESET_REQUIRED       0x10\r
+#define EFI_IFR_FLAG_LATE_CHECK           0x20\r
+\r
+#define EFI_NON_DEVICE_CLASS              0x00  // Useful when you do not want something in the Device Manager\r
+#define EFI_DISK_DEVICE_CLASS             0x01\r
+#define EFI_VIDEO_DEVICE_CLASS            0x02\r
+#define EFI_NETWORK_DEVICE_CLASS          0x04\r
+#define EFI_INPUT_DEVICE_CLASS            0x08\r
+#define EFI_ON_BOARD_DEVICE_CLASS         0x10\r
+#define EFI_OTHER_DEVICE_CLASS            0x20\r
+\r
+#define EFI_SETUP_APPLICATION_SUBCLASS    0x00\r
+#define EFI_GENERAL_APPLICATION_SUBCLASS  0x01\r
+#define EFI_FRONT_PAGE_SUBCLASS           0x02\r
+#define EFI_SINGLE_USE_SUBCLASS           0x03  // Used to display a single entity and then exit\r
+\r
+//\r
+// Used to flag dynamically created op-codes. This is meaningful to the IFR Library set\r
+// and the browser since we need to distinguish between compiled NV map data and created data.\r
+// We do not allow new entries to be created in the NV map dynamically however we still need\r
+// to display this information correctly.  To dynamically create op-codes and assume that their\r
+// data will be saved, ensure that the NV starting location they refer to is pre-defined in the\r
+// NV map.\r
+//\r
+#define EFI_IFR_FLAG_CREATED  128\r
+\r
+#pragma pack(1)\r
+//\r
+// IFR Structure definitions\r
+//\r
+typedef struct {\r
+  UINT8 OpCode;\r
+  UINT8 Length;\r
+} EFI_IFR_OP_HEADER;\r
+\r
+typedef struct {\r
+  EFI_IFR_OP_HEADER     Header;\r
+  EFI_GUID              Guid;\r
+  STRING_REF            FormSetTitle;\r
+  STRING_REF            Help;\r
+  EFI_PHYSICAL_ADDRESS  CallbackHandle;\r
+  UINT16                Class;\r
+  UINT16                SubClass;\r
+  UINT16                NvDataSize; // set once, size of the NV data as defined in the script\r
+} EFI_IFR_FORM_SET;\r
+\r
+typedef struct {\r
+  EFI_IFR_OP_HEADER Header;\r
+  UINT16            FormId;\r
+  STRING_REF        FormTitle;\r
+} EFI_IFR_FORM;\r
+\r
+typedef struct {\r
+  EFI_IFR_OP_HEADER Header;\r
+  UINT16            LabelId;\r
+} EFI_IFR_LABEL;\r
+\r
+typedef struct {\r
+  EFI_IFR_OP_HEADER Header;\r
+  STRING_REF        SubTitle;\r
+} EFI_IFR_SUBTITLE;\r
+\r
+typedef struct {\r
+  EFI_IFR_OP_HEADER Header;\r
+  STRING_REF        Help;\r
+  STRING_REF        Text;\r
+  STRING_REF        TextTwo;\r
+  UINT8             Flags;          // This is included solely for purposes of interactive/dynamic support.\r
+  UINT16            Key;            // Value to be passed to caller to identify this particular op-code\r
+} EFI_IFR_TEXT;\r
+\r
+//\r
+// goto\r
+//\r
+typedef struct {\r
+  EFI_IFR_OP_HEADER Header;\r
+  UINT16            FormId;\r
+  STRING_REF        Prompt;\r
+  STRING_REF        Help;   // The string Token for the context-help\r
+  UINT8             Flags;  // This is included solely for purposes of interactive/dynamic support.\r
+  UINT16            Key;    // Value to be passed to caller to identify this particular op-code\r
+} EFI_IFR_REF;\r
+\r
+typedef struct {\r
+  EFI_IFR_OP_HEADER Header;\r
+} EFI_IFR_END_FORM;\r
+\r
+typedef struct {\r
+  EFI_IFR_OP_HEADER Header;\r
+} EFI_IFR_END_FORM_SET;\r
+\r
+//\r
+// Also notice that the IFR_ONE_OF and IFR_CHECK_BOX are identical in structure......code assumes this to be true, if this ever\r
+// changes we need to revisit the InitializeTagStructures code\r
+//\r
+typedef struct {\r
+  EFI_IFR_OP_HEADER Header;\r
+  UINT16            QuestionId; // The ID designating what the question is about...sucked in from a #define, likely in the form of a variable name\r
+  UINT8             Width;      // The Size of the Data being saved\r
+  STRING_REF        Prompt;     // The String Token for the Prompt\r
+  STRING_REF        Help;       // The string Token for the context-help\r
+} EFI_IFR_ONE_OF;\r
+\r
+typedef struct {\r
+  EFI_IFR_OP_HEADER Header;\r
+  UINT16            QuestionId; // The offset in NV for storage of the data\r
+  UINT8             MaxEntries; // The maximum number of options in the ordered list (=size of NVStore)\r
+  STRING_REF        Prompt;     // The string token for the prompt\r
+  STRING_REF        Help;       // The string token for the context-help\r
+} EFI_IFR_ORDERED_LIST;\r
+\r
+typedef struct {\r
+  EFI_IFR_OP_HEADER Header;\r
+  UINT16            QuestionId; // The ID designating what the question is about...sucked in from a #define, likely in the form of a variable name\r
+  UINT8             Width;      // The Size of the Data being saved\r
+  STRING_REF        Prompt;     // The String Token for the Prompt\r
+  STRING_REF        Help;       // The string Token for the context-help\r
+  UINT8             Flags;      // For now, if non-zero, means that it is the default option, - further definition likely\r
+  UINT16            Key;        // Value to be passed to caller to identify this particular op-code\r
+} EFI_IFR_CHECKBOX, EFI_IFR_CHECK_BOX;\r
+\r
+typedef struct {\r
+  EFI_IFR_OP_HEADER Header;\r
+  STRING_REF        Option;     // The string token describing the option\r
+  UINT16            Value;      // The value associated with this option that is stored in the NVRAM if chosen\r
+  UINT8             Flags;      // For now, if non-zero, means that it is the default option, - further definition likely above\r
+  UINT16            Key;        // Value to be passed to caller to identify this particular op-code\r
+} EFI_IFR_ONE_OF_OPTION;\r
+\r
+typedef struct {\r
+  EFI_IFR_OP_HEADER Header;\r
+  UINT16            QuestionId; // The ID designating what the question is about...sucked in from a #define, likely in the form of a variable name\r
+  UINT8             Width;      // The Size of the Data being saved\r
+  STRING_REF        Prompt;     // The String Token for the Prompt\r
+  STRING_REF        Help;       // The string Token for the context-help\r
+  UINT8             Flags;      // This is included solely for purposes of interactive/dynamic support.\r
+  UINT16            Key;        // Value to be passed to caller to identify this particular op-code\r
+  UINT16            Minimum;\r
+  UINT16            Maximum;\r
+  UINT16            Step;       // If step is 0, then manual input is specified, otherwise, left/right arrow selection is called for\r
+  UINT16            Default;\r
+} EFI_IFR_NUMERIC;\r
+\r
+//\r
+// There is an interesting twist with regards to Time and Date.  This is one of the few items which can accept input from\r
+// a user, however may or may not need to use storage in the NVRAM space.  The decided method for determining if NVRAM space\r
+// will be used (only for a TimeOp or DateOp) is:  If .QuestionId == 0 && .Width == 0 (normally an impossibility) then use system\r
+// resources to store the data away and not NV resources.  In other words, the setup engine will call gRT->SetTime, and gRT->SetDate\r
+// for the saving of data, and the values displayed will be from the gRT->GetXXXX series of calls.\r
+//\r
+typedef struct {\r
+  EFI_IFR_NUMERIC Hour;\r
+  EFI_IFR_NUMERIC Minute;\r
+  EFI_IFR_NUMERIC Second;\r
+} EFI_IFR_TIME;\r
+\r
+typedef struct {\r
+  EFI_IFR_NUMERIC Year;\r
+  EFI_IFR_NUMERIC Month;\r
+  EFI_IFR_NUMERIC Day;\r
+} EFI_IFR_DATE;\r
+\r
+typedef struct {\r
+  EFI_IFR_OP_HEADER Header;\r
+  UINT16            QuestionId;   // The ID designating what the question is about...sucked in from a #define, likely in the form of a variable name\r
+  UINT8             Width;        // The Size of the Data being saved -- BUGBUG -- remove someday\r
+  STRING_REF        Prompt;       // The String Token for the Prompt\r
+  STRING_REF        Help;         // The string Token for the context-help\r
+  UINT8             Flags;        // This is included solely for purposes of interactive/dynamic support.\r
+  UINT16            Key;          // Value to be passed to caller to identify this particular op-code\r
+  UINT8             MinSize;      // Minimum allowable sized password\r
+  UINT8             MaxSize;      // Maximum allowable sized password\r
+  UINT16            Encoding;\r
+} EFI_IFR_PASSWORD;\r
+\r
+typedef struct {\r
+  EFI_IFR_OP_HEADER Header;\r
+  UINT16            QuestionId;   // The ID designating what the question is about...sucked in from a #define, likely in the form of a variable name\r
+  UINT8             Width;        // The Size of the Data being saved -- BUGBUG -- remove someday\r
+  STRING_REF        Prompt;       // The String Token for the Prompt\r
+  STRING_REF        Help;         // The string Token for the context-help\r
+  UINT8             Flags;        // This is included solely for purposes of interactive/dynamic support.\r
+  UINT16            Key;          // Value to be passed to caller to identify this particular op-code\r
+  UINT8             MinSize;      // Minimum allowable sized password\r
+  UINT8             MaxSize;      // Maximum allowable sized password\r
+} EFI_IFR_STRING;\r
+\r
+typedef struct {\r
+  EFI_IFR_OP_HEADER Header;\r
+} EFI_IFR_END_ONE_OF;\r
+\r
+typedef struct {\r
+  EFI_IFR_OP_HEADER Header;\r
+  UINT16            Value;\r
+  UINT16            Key;\r
+} EFI_IFR_HIDDEN;\r
+\r
+typedef struct {\r
+  EFI_IFR_OP_HEADER Header;\r
+  UINT8             Flags;\r
+} EFI_IFR_SUPPRESS;\r
+\r
+typedef struct {\r
+  EFI_IFR_OP_HEADER Header;\r
+  UINT8             Flags;\r
+} EFI_IFR_GRAY_OUT;\r
+\r
+typedef struct {\r
+  EFI_IFR_OP_HEADER Header;\r
+  STRING_REF        Popup;\r
+  UINT8             Flags;\r
+} EFI_IFR_INCONSISTENT;\r
+\r
+typedef struct {\r
+  EFI_IFR_OP_HEADER Header;\r
+  UINT16            QuestionId;   // offset into variable storage\r
+  UINT8             Width;        // size of variable storage\r
+  UINT16            Value;        // value to compare against\r
+} EFI_IFR_EQ_ID_VAL;\r
+\r
+typedef struct {\r
+  EFI_IFR_OP_HEADER Header;\r
+  UINT16            QuestionId;   // offset into variable storage\r
+  UINT8             Width;        // size of variable storage\r
+  UINT16            ListLength;\r
+  UINT16            ValueList[1];\r
+} EFI_IFR_EQ_ID_LIST;\r
+\r
+typedef struct {\r
+  EFI_IFR_OP_HEADER Header;\r
+  UINT16            QuestionId1;  // offset into variable storage for first value to compare\r
+  UINT8             Width;        // size of variable storage (must be same for both)\r
+  UINT16            QuestionId2;  // offset into variable storage for second value to compare\r
+} EFI_IFR_EQ_ID_ID;\r
+\r
+typedef struct {\r
+  EFI_IFR_OP_HEADER Header;\r
+  UINT16            VariableId;   // offset into variable storage\r
+  UINT16            Value;        // value to compare against\r
+} EFI_IFR_EQ_VAR_VAL;\r
+\r
+typedef struct {\r
+  EFI_IFR_OP_HEADER Header;\r
+} EFI_IFR_AND;\r
+\r
+typedef struct {\r
+  EFI_IFR_OP_HEADER Header;\r
+} EFI_IFR_OR;\r
+\r
+typedef struct {\r
+  EFI_IFR_OP_HEADER Header;\r
+} EFI_IFR_NOT;\r
+\r
+typedef struct {\r
+  EFI_IFR_OP_HEADER Header;\r
+} EFI_IFR_END_EXPR, EFI_IFR_END_IF;\r
+\r
+typedef struct {\r
+  EFI_IFR_OP_HEADER Header;\r
+  UINT16            FormId;\r
+  STRING_REF        Prompt;\r
+  STRING_REF        Help;\r
+  UINT8             Flags;\r
+  UINT16            Key;\r
+} EFI_IFR_SAVE_DEFAULTS;\r
+\r
+typedef struct {\r
+  EFI_IFR_OP_HEADER Header;\r
+  STRING_REF        Help;\r
+  STRING_REF        Text;\r
+  STRING_REF        TextTwo;      // optional text\r
+} EFI_IFR_INVENTORY;\r
+\r
+typedef struct {\r
+  EFI_IFR_OP_HEADER Header;\r
+  EFI_GUID          Guid;         // GUID for the variable\r
+  UINT16            VarId;        // variable store ID, as referenced elsewhere in the form\r
+  UINT16            Size;         // size of the variable storage\r
+} EFI_IFR_VARSTORE;\r
+\r
+typedef struct {\r
+  EFI_IFR_OP_HEADER Header;\r
+  UINT16            VarId;        // variable store ID, as referenced elsewhere in the form\r
+} EFI_IFR_VARSTORE_SELECT;\r
+\r
+//\r
+// Used for the ideqid VFR statement where two variable stores may be referenced in the\r
+// same VFR statement.\r
+// A browser should treat this as an EFI_IFR_VARSTORE_SELECT statement and assume that all following\r
+// IFR opcodes use the VarId as defined here.\r
+//\r
+typedef struct {\r
+  EFI_IFR_OP_HEADER Header;\r
+  UINT16            VarId;          // variable store ID, as referenced elsewhere in the form\r
+  UINT16            SecondaryVarId; // variable store ID, as referenced elsewhere in the form\r
+} EFI_IFR_VARSTORE_SELECT_PAIR;\r
+\r
+typedef struct {\r
+  EFI_IFR_OP_HEADER Header;\r
+} EFI_IFR_TRUE;\r
+\r
+typedef struct {\r
+  EFI_IFR_OP_HEADER Header;\r
+} EFI_IFR_FALSE;\r
+\r
+typedef struct {\r
+  EFI_IFR_OP_HEADER Header;\r
+} EFI_IFR_GT;\r
+\r
+typedef struct {\r
+  EFI_IFR_OP_HEADER Header;\r
+} EFI_IFR_GE;\r
+\r
+//\r
+// Save defaults and restore defaults have same structure\r
+//\r
+#define EFI_IFR_RESTORE_DEFAULTS  EFI_IFR_SAVE_DEFAULTS\r
+\r
+typedef struct {\r
+  EFI_IFR_OP_HEADER Header;\r
+  STRING_REF        Title;        // The string token for the banner title\r
+  UINT16            LineNumber;   // 1-based line number\r
+  UINT8             Alignment;    // left, center, or right-aligned\r
+} EFI_IFR_BANNER;\r
+\r
+#define EFI_IFR_BANNER_ALIGN_LEFT   0\r
+#define EFI_IFR_BANNER_ALIGN_CENTER 1\r
+#define EFI_IFR_BANNER_ALIGN_RIGHT  2\r
+#define EFI_IFR_BANNER_TIMEOUT      0xFF\r
+\r
+#pragma pack()\r
+\r
+#endif\r
diff --git a/Tools/CodeTools/Source/Include/Common/MultiPhase.h b/Tools/CodeTools/Source/Include/Common/MultiPhase.h
new file mode 100644 (file)
index 0000000..93867a5
--- /dev/null
@@ -0,0 +1,84 @@
+/** @file\r
+  This includes some definitions that will be used in both PEI and DXE phases.\r
+\r
+  Copyright (c) 2006, Intel Corporation                                                         \r
+  All rights reserved. This program and the accompanying materials                          \r
+  are licensed and made available under the terms and conditions of the BSD License         \r
+  which accompanies this distribution.  The full text of the license may be found at        \r
+  http://opensource.org/licenses/bsd-license.php                                            \r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+  Module Name:  MultiPhase.h\r
+\r
+**/\r
+\r
+#ifndef __MULTI_PHASE_H__\r
+#define __MULTI_PHASE_H__\r
+\r
+//\r
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\r
+//\r
+// Needed EFI defines for PEI\r
+//\r
+typedef UINT64  EFI_PHYSICAL_ADDRESS;\r
+\r
+typedef enum {\r
+  EfiReservedMemoryType,\r
+  EfiLoaderCode,\r
+  EfiLoaderData,\r
+  EfiBootServicesCode,\r
+  EfiBootServicesData,\r
+  EfiRuntimeServicesCode,\r
+  EfiRuntimeServicesData,\r
+  EfiConventionalMemory,\r
+  EfiUnusableMemory,\r
+  EfiACPIReclaimMemory,\r
+  EfiACPIMemoryNVS,\r
+  EfiMemoryMappedIO,\r
+  EfiMemoryMappedIOPortSpace,\r
+  EfiPalCode,\r
+  EfiMaxMemoryType\r
+} EFI_MEMORY_TYPE;\r
+\r
+typedef UINT32  EFI_STATUS_CODE_TYPE;\r
+typedef UINT32  EFI_STATUS_CODE_VALUE;\r
+\r
+typedef struct {\r
+  UINT16    HeaderSize;\r
+  UINT16    Size;\r
+  EFI_GUID  Type;\r
+} EFI_STATUS_CODE_DATA;\r
+\r
+typedef struct {\r
+  UINT64  Signature;\r
+  UINT32  Revision;\r
+  UINT32  HeaderSize;\r
+  UINT32  CRC32;\r
+  UINT32  Reserved;\r
+} EFI_TABLE_HEADER;\r
+\r
+#define EFI_PAGE_SIZE         4096\r
+\r
+\r
+typedef VOID    *EFI_HANDLE;\r
+typedef UINT16  EFI_HII_HANDLE;\r
+typedef UINT16  STRING_REF;\r
+typedef struct {\r
+  INT16     Value;\r
+  INT16     Exponent;\r
+} EFI_EXP_BASE10_DATA;\r
+\r
+//\r
+// Define macros to build data structure signatures from characters.\r
+//\r
+#define EFI_SIGNATURE_16(A, B)        ((A) | (B << 8))\r
+#define EFI_SIGNATURE_32(A, B, C, D)  (EFI_SIGNATURE_16 (A, B) | (EFI_SIGNATURE_16 (C, D) << 16))\r
+#define EFI_SIGNATURE_64(A, B, C, D, E, F, G, H) \\r
+    (EFI_SIGNATURE_32 (A, B, C, D) | ((UINT64) (EFI_SIGNATURE_32 (E, F, G, H)) << 32))\r
+\r
+\r
+#include <Protocol/DevicePath.h>\r
+\r
+#endif\r
diff --git a/Tools/CodeTools/Source/Include/Common/UefiBaseTypes.h b/Tools/CodeTools/Source/Include/Common/UefiBaseTypes.h
new file mode 100644 (file)
index 0000000..4954c10
--- /dev/null
@@ -0,0 +1,85 @@
+/** @file\r
+  This file makes the BaseTypes.h backward compatible with the ones used in the \r
+  past for EFI and Tiano development. It's mostly just prepending an EFI_ on the \r
+  definitions.\r
+\r
+  Copyright (c) 2006, Intel Corporation                                                         \r
+  All rights reserved. This program and the accompanying materials                          \r
+  are licensed and made available under the terms and conditions of the BSD License         \r
+  which accompanies this distribution.  The full text of the license may be found at        \r
+  http://opensource.org/licenses/bsd-license.php                                            \r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+  Module Name:  UefiBaseTypes.h\r
+\r
+**/\r
+\r
+#ifndef __UEFI_BASE_TYPES_H__\r
+#define __UEFI_BASE_TYPES_H__\r
+\r
+#include <Common/BaseTypes.h>\r
+\r
+typedef UINT64    EFI_LBA;\r
+\r
+#define EFIERR(_a)                    ENCODE_ERROR(_a)\r
+\r
+#define EFI_MAX_BIT                   MAX_BIT\r
+#define EFI_MAX_ADDRESS               MAX_ADDRESS\r
+#define EFI_BREAKPOINT()              CpuBreakpoint ()\r
+#define EFI_DEADLOOP()                CpuDeadLoop ()\r
+#define EFI_ERROR(A)                  RETURN_ERROR(A)\r
+\r
+typedef GUID          EFI_GUID;\r
+typedef RETURN_STATUS EFI_STATUS;\r
+\r
+#define EFI_SUCCESS               RETURN_SUCCESS              \r
+#define EFI_LOAD_ERROR            RETURN_LOAD_ERROR           \r
+#define EFI_INVALID_PARAMETER     RETURN_INVALID_PARAMETER    \r
+#define EFI_UNSUPPORTED           RETURN_UNSUPPORTED          \r
+#define EFI_BAD_BUFFER_SIZE       RETURN_BAD_BUFFER_SIZE      \r
+#define EFI_BUFFER_TOO_SMALL      RETURN_BUFFER_TOO_SMALL     \r
+#define EFI_NOT_READY             RETURN_NOT_READY            \r
+#define EFI_DEVICE_ERROR          RETURN_DEVICE_ERROR         \r
+#define EFI_WRITE_PROTECTED       RETURN_WRITE_PROTECTED      \r
+#define EFI_OUT_OF_RESOURCES      RETURN_OUT_OF_RESOURCES     \r
+#define EFI_VOLUME_CORRUPTED      RETURN_VOLUME_CORRUPTED     \r
+#define EFI_VOLUME_FULL           RETURN_VOLUME_FULL          \r
+#define EFI_NO_MEDIA              RETURN_NO_MEDIA             \r
+#define EFI_MEDIA_CHANGED         RETURN_MEDIA_CHANGED        \r
+#define EFI_NOT_FOUND             RETURN_NOT_FOUND            \r
+#define EFI_ACCESS_DENIED         RETURN_ACCESS_DENIED        \r
+#define EFI_NO_RESPONSE           RETURN_NO_RESPONSE          \r
+#define EFI_NO_MAPPING            RETURN_NO_MAPPING           \r
+#define EFI_TIMEOUT               RETURN_TIMEOUT              \r
+#define EFI_NOT_STARTED           RETURN_NOT_STARTED          \r
+#define EFI_ALREADY_STARTED       RETURN_ALREADY_STARTED      \r
+#define EFI_ABORTED               RETURN_ABORTED              \r
+#define EFI_ICMP_ERROR            RETURN_ICMP_ERROR           \r
+#define EFI_TFTP_ERROR            RETURN_TFTP_ERROR           \r
+#define EFI_PROTOCOL_ERROR        RETURN_PROTOCOL_ERROR       \r
+#define EFI_INCOMPATIBLE_VERSION  RETURN_INCOMPATIBLE_VERSION \r
+#define EFI_SECURITY_VIOLATION    RETURN_SECURITY_VIOLATION   \r
+#define EFI_CRC_ERROR             RETURN_CRC_ERROR   \r
+#define EFI_END_OF_MEDIA          RETURN_END_OF_MEDIA\r
+#define EFI_END_OF_FILE           RETURN_END_OF_FILE\r
+\r
+#define EFI_WARN_UNKNOWN_GLYPH    RETURN_WARN_UNKNOWN_GLYPH   \r
+#define EFI_WARN_DELETE_FAILURE   RETURN_WARN_DELETE_FAILURE  \r
+#define EFI_WARN_WRITE_FAILURE    RETURN_WARN_WRITE_FAILURE   \r
+#define EFI_WARN_BUFFER_TOO_SMALL RETURN_WARN_BUFFER_TOO_SMALL\r
+\r
+//\r
+// The EFI memory allocation functions work in units of EFI_PAGEs that are\r
+// 4K. This should in no way be confused with the page size of the processor.\r
+// An EFI_PAGE is just the quanta of memory in EFI.\r
+//\r
+#define EFI_PAGE_MASK         0xFFF\r
+#define EFI_PAGE_SHIFT        12\r
+\r
+#define EFI_SIZE_TO_PAGES(a)  (((a) >> EFI_PAGE_SHIFT) + (((a) & EFI_PAGE_MASK) ? 1 : 0))\r
+\r
+#define EFI_PAGES_TO_SIZE(a)   ( (a) << EFI_PAGE_SHIFT)\r
+\r
+#endif\r
diff --git a/Tools/CodeTools/Source/Include/Common/Variable.h b/Tools/CodeTools/Source/Include/Common/Variable.h
new file mode 100644 (file)
index 0000000..bc0d640
--- /dev/null
@@ -0,0 +1,78 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  EfiVariable.h\r
+  \r
+Abstract:\r
+  \r
+  Header file for EFI Variable Services\r
+\r
+--*/\r
+\r
+#ifndef _EFI_VARIABLE_H_\r
+#define _EFI_VARIABLE_H_\r
+\r
+#define VARIABLE_STORE_SIGNATURE  EFI_SIGNATURE_32 ('$', 'V', 'S', 'S')\r
+\r
+#define MAX_VARIABLE_SIZE         1024\r
+\r
+#define VARIABLE_DATA             0x55AA\r
+\r
+//\r
+// Variable Store Header flags\r
+//\r
+#define VARIABLE_STORE_FORMATTED  0x5a\r
+#define VARIABLE_STORE_HEALTHY    0xfe\r
+\r
+//\r
+// Variable Store Status\r
+//\r
+typedef enum {\r
+  EfiRaw,\r
+  EfiValid,\r
+  EfiInvalid,\r
+  EfiUnknown\r
+} VARIABLE_STORE_STATUS;\r
+\r
+//\r
+// Variable State flags\r
+//\r
+#define VAR_IN_DELETED_TRANSITION     0xfe  // Variable is in obsolete transistion\r
+#define VAR_DELETED                   0xfd  // Variable is obsolete\r
+#define VAR_ADDED                     0x7f  // Variable has been completely added\r
+#define IS_VARIABLE_STATE(_c, _Mask)  (BOOLEAN) (((~_c) & (~_Mask)) != 0)\r
+\r
+#pragma pack(1)\r
+\r
+typedef struct {\r
+  UINT32  Signature;\r
+  UINT32  Size;\r
+  UINT8   Format;\r
+  UINT8   State;\r
+  UINT16  Reserved;\r
+  UINT32  Reserved1;\r
+} VARIABLE_STORE_HEADER;\r
+\r
+typedef struct {\r
+  UINT16    StartId;\r
+  UINT8     State;\r
+  UINT8     Reserved;\r
+  UINT32    Attributes;\r
+  UINTN     NameSize;\r
+  UINTN     DataSize;\r
+  EFI_GUID  VendorGuid;\r
+} VARIABLE_HEADER;\r
+\r
+#pragma pack()\r
+\r
+#endif // _EFI_VARIABLE_H_\r
diff --git a/Tools/CodeTools/Source/Include/Common/WorkingBlockHeader.h b/Tools/CodeTools/Source/Include/Common/WorkingBlockHeader.h
new file mode 100644 (file)
index 0000000..235b740
--- /dev/null
@@ -0,0 +1,47 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  EfiWorkingBlockHeader.h\r
+\r
+Abstract:\r
+\r
+  Defines data structure that is the headers found at the runtime \r
+  updatable firmware volumes, such as the FileSystemGuid of the \r
+  working block, the header structure of the variable block, FTW\r
+  working block, or event log block.\r
+\r
+--*/\r
+\r
+#ifndef _EFI_WORKING_BLOCK_HEADER_H_\r
+#define _EFI_WORKING_BLOCK_HEADER_H_\r
+\r
+//\r
+// EFI Fault tolerant working block header\r
+// The header is immediately followed by the write queue.\r
+//\r
+typedef struct {\r
+  EFI_GUID  Signature;\r
+  UINT32    Crc;\r
+  UINT32    WorkingBlockValid : 1;\r
+  UINT32    WorkingBlockInvalid : 1;\r
+#define WORKING_BLOCK_VALID   0x1\r
+#define WORKING_BLOCK_INVALID 0x2\r
+  UINT32    Reserved : 6;\r
+  UINT8     Reserved3[3];\r
+  UINTN     WriteQueueSize;\r
+  //\r
+  // UINT8                WriteQueue[WriteQueueSize];\r
+  //\r
+} EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER;\r
+\r
+#endif\r
diff --git a/Tools/CodeTools/Source/Include/Guid/AcpiTableStorage.h b/Tools/CodeTools/Source/Include/Guid/AcpiTableStorage.h
new file mode 100644 (file)
index 0000000..80b1154
--- /dev/null
@@ -0,0 +1,30 @@
+/** @file\r
+  The ACPI table storage file is fully FFS compliant. \r
+  The file is a number of sections of type EFI_SECTION_RAW.\r
+  This GUID is used to identify the file as an ACPI table storage file.\r
+\r
+  Copyright (c) 2006, Intel Corporation                                                         \r
+  All rights reserved. This program and the accompanying materials                          \r
+  are licensed and made available under the terms and conditions of the BSD License         \r
+  which accompanies this distribution.  The full text of the license may be found at        \r
+  http://opensource.org/licenses/bsd-license.php                                            \r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+  Module Name:  AcpiTableStorage.h\r
+\r
+  @par Revision Reference:\r
+  GUID defined in ACPI Table Storage Spec Version 0.9.\r
+\r
+**/\r
+\r
+#ifndef _ACPI_TABLE_STORAGE_H_\r
+#define _ACPI_TABLE_STORAGE_H_\r
+\r
+#define EFI_ACPI_TABLE_STORAGE_GUID \\r
+  { 0x7e374e25, 0x8e01, 0x4fee, {0x87, 0xf2, 0x39, 0xc, 0x23, 0xc6, 0x6, 0xcd } }\r
+\r
+extern EFI_GUID gEfiAcpiTableStorageGuid;\r
+\r
+#endif\r
diff --git a/Tools/CodeTools/Source/Include/Guid/Apriori.h b/Tools/CodeTools/Source/Include/Guid/Apriori.h
new file mode 100644 (file)
index 0000000..ba92560
--- /dev/null
@@ -0,0 +1,32 @@
+/** @file\r
+  GUID used as an FV filename for A Priori file. The A Priori file contains a\r
+  list of FV filenames that the DXE dispatcher will schedule reguardless of\r
+  the dependency grammer.\r
+\r
+  Copyright (c) 2006, Intel Corporation                                                         \r
+  All rights reserved. This program and the accompanying materials                          \r
+  are licensed and made available under the terms and conditions of the BSD License         \r
+  which accompanies this distribution.  The full text of the license may be found at        \r
+  http://opensource.org/licenses/bsd-license.php                                            \r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+  Module Name:  Apriori.h\r
+\r
+  @par Revision Reference:\r
+  GUID defined in DXE CIS spec version 0.91B\r
+\r
+**/\r
+\r
+#ifndef __APRIORI_GUID_H__\r
+#define __APRIORI_GUID_H__\r
+\r
+#define EFI_APRIORI_GUID \\r
+  { \\r
+    0xfc510ee7, 0xffdc, 0x11d4, {0xbd, 0x41, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 } \\r
+  }\r
+\r
+extern EFI_GUID gAprioriGuid;\r
+\r
+#endif\r
diff --git a/Tools/CodeTools/Source/Include/Guid/Capsule.h b/Tools/CodeTools/Source/Include/Guid/Capsule.h
new file mode 100644 (file)
index 0000000..7864b92
--- /dev/null
@@ -0,0 +1,43 @@
+/** @file\r
+  GUIDs used for EFI Capsule\r
+\r
+  Copyright (c) 2006, Intel Corporation                                                         \r
+  All rights reserved. This program and the accompanying materials                          \r
+  are licensed and made available under the terms and conditions of the BSD License         \r
+  which accompanies this distribution.  The full text of the license may be found at        \r
+  http://opensource.org/licenses/bsd-license.php                                            \r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+  Module Name:  Capsule.h\r
+\r
+  @par Revision Reference:\r
+  GUIDs defined in Capsule Spec Version 0.9\r
+\r
+**/\r
+\r
+#ifndef __CAPSULE_GUID_H__\r
+#define __CAPSULE_GUID_H__\r
+\r
+//\r
+// This is the GUID of the capsule header of the image on disk.\r
+//\r
+#define EFI_CAPSULE_GUID \\r
+  { \\r
+    0x3B6686BD, 0x0D76, 0x4030, {0xB7, 0x0E, 0xB5, 0x51, 0x9E, 0x2F, 0xC5, 0xA0 } \\r
+  }\r
+\r
+//\r
+// This is the GUID of the configuration results file created by the capsule\r
+// application.\r
+//\r
+#define EFI_CONFIG_FILE_NAME_GUID \\r
+  { \\r
+    0x98B8D59B, 0xE8BA, 0x48EE, {0x98, 0xDD, 0xC2, 0x95, 0x39, 0x2F, 0x1E, 0xDB } \\r
+  }\r
+\r
+extern EFI_GUID gEfiCapsuleGuid;\r
+extern EFI_GUID gEfiConfigFileNameGuid;\r
+\r
+#endif\r
diff --git a/Tools/CodeTools/Source/Include/Guid/FirmwareFileSystem.h b/Tools/CodeTools/Source/Include/Guid/FirmwareFileSystem.h
new file mode 100644 (file)
index 0000000..06bfa7d
--- /dev/null
@@ -0,0 +1,40 @@
+/** @file\r
+  Guid used to define the Firmware File System.  See the Framework Firmware \r
+  File System Specification for more details.\r
+\r
+  Copyright (c) 2006, Intel Corporation                                                         \r
+  All rights reserved. This program and the accompanying materials                          \r
+  are licensed and made available under the terms and conditions of the BSD License         \r
+  which accompanies this distribution.  The full text of the license may be found at        \r
+  http://opensource.org/licenses/bsd-license.php                                            \r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+  Module Name:  FirmwareFileSystem.h\r
+\r
+  @par Revision Reference:\r
+  Guids defined in Firmware File System Spec 0.9\r
+\r
+**/\r
+\r
+#ifndef __FIRMWARE_FILE_SYSTEM_GUID_H__\r
+#define __FIRMWARE_FILE_SYSTEM_GUID_H__\r
+\r
+//\r
+// GUIDs defined by the FFS specification.\r
+//\r
+#define EFI_FIRMWARE_FILE_SYSTEM_GUID \\r
+  { \\r
+    0x7A9354D9, 0x0468, 0x444a, {0x81, 0xCE, 0x0B, 0xF6, 0x17, 0xD8, 0x90, 0xDF } \\r
+  }\r
+\r
+#define EFI_FFS_VOLUME_TOP_FILE_GUID \\r
+  { \\r
+    0x1BA0062E, 0xC779, 0x4582, {0x85, 0x66, 0x33, 0x6A, 0xE8, 0xF7, 0x8F, 0x9 } \\r
+  }\r
+\r
+extern EFI_GUID gEfiFirmwareFileSystemGuid;\r
+extern EFI_GUID gEfiFirmwareVolumeTopFileGuid;\r
+\r
+#endif\r
diff --git a/Tools/CodeTools/Source/Include/Ia32/ProcessorBind.h b/Tools/CodeTools/Source/Include/Ia32/ProcessorBind.h
new file mode 100644 (file)
index 0000000..587d8a6
--- /dev/null
@@ -0,0 +1,167 @@
+/** @file\r
+  Processor or Compiler specific defines and types for x64.\r
+\r
+  Copyright (c) 2006, Intel Corporation                                                         \r
+  All rights reserved. This program and the accompanying materials                          \r
+  are licensed and made available under the terms and conditions of the BSD License         \r
+  which accompanies this distribution.  The full text of the license may be found at        \r
+  http://opensource.org/licenses/bsd-license.php                                            \r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+  Module Name:  ProcessorBind.h\r
+\r
+**/\r
+\r
+#ifndef __PROCESSOR_BIND_H__\r
+#define __PROCESSOR_BIND_H__\r
+\r
+//\r
+// Define the processor type so other code can make processor based choices\r
+//\r
+#define MDE_CPU_IA32\r
+\r
+//\r
+// Make sure we are useing the correct packing rules per EFI specification\r
+//\r
+#ifndef __GNUC__\r
+#pragma pack()\r
+#endif\r
+\r
+#if _MSC_EXTENSIONS\r
+\r
+//\r
+// Disable warning that make it impossible to compile at /W4\r
+// This only works for Microsoft* tools\r
+//\r
+\r
+//\r
+// Disabling bitfield type checking warnings.\r
+//\r
+#pragma warning ( disable : 4214 )\r
+\r
+//\r
+// Disabling the unreferenced formal parameter warnings.\r
+//\r
+#pragma warning ( disable : 4100 )\r
+\r
+//\r
+// Disable slightly different base types warning as CHAR8 * can not be set\r
+// to a constant string.\r
+//\r
+#pragma warning ( disable : 4057 )\r
+\r
+//\r
+// ASSERT(FALSE) or while (TRUE) are legal constructes so supress this warning\r
+//\r
+#pragma warning ( disable : 4127 )\r
+\r
+\r
+#endif\r
+\r
+\r
+#if !defined(__GNUC__) && (__STDC_VERSION__ < 199901L)\r
+  //\r
+  // No ANSI C 2000 stdint.h integer width declarations, so define equivalents\r
+  //\r
\r
+  #if _MSC_EXTENSIONS \r
+    \r
+    //\r
+    // use Microsoft* C complier dependent interger width types \r
+    //\r
+    typedef unsigned __int64    UINT64;\r
+    typedef __int64             INT64;\r
+    typedef unsigned __int32    UINT32;\r
+    typedef __int32             INT32;\r
+    typedef unsigned short      UINT16;\r
+    typedef unsigned short      CHAR16;\r
+    typedef short               INT16;\r
+    typedef unsigned char       BOOLEAN;\r
+    typedef unsigned char       UINT8;\r
+    typedef char                CHAR8;\r
+    typedef char                INT8;\r
+  #else\r
+\r
+    //\r
+    // Assume standard IA-32 alignment. \r
+    // BugBug: Need to check portability of long long\r
+    //\r
+    typedef unsigned long long  UINT64;\r
+    typedef long long           INT64;\r
+    typedef unsigned int        UINT32;\r
+    typedef int                 INT32;\r
+    typedef unsigned short      UINT16;\r
+    typedef unsigned short      CHAR16;\r
+    typedef short               INT16;\r
+    typedef unsigned char       BOOLEAN;\r
+    typedef unsigned char       UINT8;\r
+    typedef char                CHAR8;\r
+    typedef char                INT8;\r
+  #endif\r
+\r
+  #define UINT8_MAX 0xff\r
+\r
+#else\r
+  //\r
+  // Use ANSI C 2000 stdint.h integer width declarations\r
+  //\r
+  #include "stdint.h"\r
+  typedef uint8_t   BOOLEAN;\r
+  typedef int8_t    INT8;\r
+  typedef uint8_t   UINT8;\r
+  typedef int16_t   INT16;\r
+  typedef uint16_t  UINT16;\r
+  typedef int32_t   INT32;\r
+  typedef uint32_t  UINT32;\r
+  typedef int64_t   INT64;\r
+  typedef uint64_t  UINT64;\r
+  typedef char      CHAR8;\r
+  typedef uint16_t  CHAR16;\r
+\r
+#endif\r
+\r
+typedef UINT32  UINTN;\r
+typedef INT32   INTN;\r
+\r
+\r
+//\r
+// Processor specific defines\r
+//\r
+#define MAX_BIT     0x80000000\r
+#define MAX_2_BITS  0xC0000000\r
+\r
+//\r
+// Maximum legal IA-32 address\r
+//\r
+#define MAX_ADDRESS   0xFFFFFFFF\r
+\r
+//\r
+// Modifier to ensure that all protocol member functions and EFI intrinsics\r
+// use the correct C calling convention. All protocol member functions and\r
+// EFI intrinsics are required to modify thier member functions with EFIAPI.\r
+//\r
+#if _MSC_EXTENSIONS\r
+  //\r
+  // Microsoft* compiler requires _EFIAPI useage, __cdecl is Microsoft* specific C.\r
+  // \r
+  #define EFIAPI __cdecl  \r
+#endif\r
+\r
+#if __GNUC__\r
+  #define EFIAPI __attribute__((cdecl))    \r
+#endif\r
+\r
+//\r
+// The Microsoft* C compiler can removed references to unreferenced data items\r
+//  if the /OPT:REF linker option is used. We defined a macro as this is a \r
+//  a non standard extension\r
+//\r
+#if _MSC_EXTENSIONS\r
+  #define GLOBAL_REMOVE_IF_UNREFERENCED __declspec(selectany)\r
+#else\r
+  #define GLOBAL_REMOVE_IF_UNREFERENCED\r
+#endif\r
+\r
+#endif\r
diff --git a/Tools/CodeTools/Source/Include/IndustryStandard/pci22.h b/Tools/CodeTools/Source/Include/IndustryStandard/pci22.h
new file mode 100644 (file)
index 0000000..7fee279
--- /dev/null
@@ -0,0 +1,481 @@
+/** @file\r
+  Support for PCI 2.2 standard.\r
+\r
+  Copyright (c) 2006, Intel Corporation                                                         \r
+  All rights reserved. This program and the accompanying materials                          \r
+  are licensed and made available under the terms and conditions of the BSD License         \r
+  which accompanies this distribution.  The full text of the license may be found at        \r
+  http://opensource.org/licenses/bsd-license.php                                            \r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+  Module Name:  pci22.h\r
+\r
+**/\r
+\r
+#ifndef _PCI22_H\r
+#define _PCI22_H\r
+\r
+#define PCI_MAX_SEGMENT 0\r
+\r
+#define PCI_MAX_BUS     255\r
+\r
+#define PCI_MAX_DEVICE  31\r
+#define PCI_MAX_FUNC    7\r
+\r
+//\r
+// Command\r
+//\r
+#define PCI_VGA_PALETTE_SNOOP_DISABLED  0x20\r
+\r
+#pragma pack(push, 1)\r
+typedef struct {\r
+  UINT16  VendorId;\r
+  UINT16  DeviceId;\r
+  UINT16  Command;\r
+  UINT16  Status;\r
+  UINT8   RevisionID;\r
+  UINT8   ClassCode[3];\r
+  UINT8   CacheLineSize;\r
+  UINT8   LatencyTimer;\r
+  UINT8   HeaderType;\r
+  UINT8   BIST;\r
+} PCI_DEVICE_INDEPENDENT_REGION;\r
+\r
+typedef struct {\r
+  UINT32  Bar[6];\r
+  UINT32  CISPtr;\r
+  UINT16  SubsystemVendorID;\r
+  UINT16  SubsystemID;\r
+  UINT32  ExpansionRomBar;\r
+  UINT8   CapabilityPtr;\r
+  UINT8   Reserved1[3];\r
+  UINT32  Reserved2;\r
+  UINT8   InterruptLine;\r
+  UINT8   InterruptPin;\r
+  UINT8   MinGnt;\r
+  UINT8   MaxLat;\r
+} PCI_DEVICE_HEADER_TYPE_REGION;\r
+\r
+typedef struct {\r
+  PCI_DEVICE_INDEPENDENT_REGION Hdr;\r
+  PCI_DEVICE_HEADER_TYPE_REGION Device;\r
+} PCI_TYPE00;\r
+\r
+typedef struct {\r
+  UINT32  Bar[2];\r
+  UINT8   PrimaryBus;\r
+  UINT8   SecondaryBus;\r
+  UINT8   SubordinateBus;\r
+  UINT8   SecondaryLatencyTimer;\r
+  UINT8   IoBase;\r
+  UINT8   IoLimit;\r
+  UINT16  SecondaryStatus;\r
+  UINT16  MemoryBase;\r
+  UINT16  MemoryLimit;\r
+  UINT16  PrefetchableMemoryBase;\r
+  UINT16  PrefetchableMemoryLimit;\r
+  UINT32  PrefetchableBaseUpper32;\r
+  UINT32  PrefetchableLimitUpper32;\r
+  UINT16  IoBaseUpper16;\r
+  UINT16  IoLimitUpper16;\r
+  UINT8   CapabilityPtr;\r
+  UINT8   Reserved[3];\r
+  UINT32  ExpansionRomBAR;\r
+  UINT8   InterruptLine;\r
+  UINT8   InterruptPin;\r
+  UINT16  BridgeControl;\r
+} PCI_BRIDGE_CONTROL_REGISTER;\r
+\r
+typedef struct {\r
+  PCI_DEVICE_INDEPENDENT_REGION Hdr;\r
+  PCI_BRIDGE_CONTROL_REGISTER   Bridge;\r
+} PCI_TYPE01;\r
+\r
+typedef union {\r
+  PCI_TYPE00  Device;\r
+  PCI_TYPE01  Bridge;\r
+} PCI_TYPE_GENERIC;\r
+\r
+typedef struct {\r
+  UINT32  CardBusSocketReg; // Cardus Socket/ExCA Base\r
+  // Address Register\r
+  //\r
+  UINT16  Reserved;\r
+  UINT16  SecondaryStatus;      // Secondary Status\r
+  UINT8   PciBusNumber;         // PCI Bus Number\r
+  UINT8   CardBusBusNumber;     // CardBus Bus Number\r
+  UINT8   SubordinateBusNumber; // Subordinate Bus Number\r
+  UINT8   CardBusLatencyTimer;  // CardBus Latency Timer\r
+  UINT32  MemoryBase0;          // Memory Base Register 0\r
+  UINT32  MemoryLimit0;         // Memory Limit Register 0\r
+  UINT32  MemoryBase1;\r
+  UINT32  MemoryLimit1;\r
+  UINT32  IoBase0;\r
+  UINT32  IoLimit0;             // I/O Base Register 0\r
+  UINT32  IoBase1;              // I/O Limit Register 0\r
+  UINT32  IoLimit1;\r
+  UINT8   InterruptLine;        // Interrupt Line\r
+  UINT8   InterruptPin;         // Interrupt Pin\r
+  UINT16  BridgeControl;        // Bridge Control\r
+} PCI_CARDBUS_CONTROL_REGISTER;\r
+\r
+//\r
+// Definitions of PCI class bytes and manipulation macros.\r
+//\r
+#define PCI_CLASS_OLD                 0x00\r
+#define PCI_CLASS_OLD_OTHER           0x00\r
+#define PCI_CLASS_OLD_VGA             0x01\r
+\r
+#define PCI_CLASS_MASS_STORAGE        0x01\r
+#define PCI_CLASS_MASS_STORAGE_SCSI   0x00\r
+#define PCI_CLASS_MASS_STORAGE_IDE    0x01  // obsolete\r
+#define PCI_CLASS_IDE                 0x01\r
+#define PCI_CLASS_MASS_STORAGE_FLOPPY 0x02\r
+#define PCI_CLASS_MASS_STORAGE_IPI    0x03\r
+#define PCI_CLASS_MASS_STORAGE_RAID   0x04\r
+#define PCI_CLASS_MASS_STORAGE_OTHER  0x80\r
+\r
+#define PCI_CLASS_NETWORK             0x02\r
+#define PCI_CLASS_NETWORK_ETHERNET    0x00\r
+#define PCI_CLASS_ETHERNET            0x00  // obsolete\r
+#define PCI_CLASS_NETWORK_TOKENRING   0x01\r
+#define PCI_CLASS_NETWORK_FDDI        0x02\r
+#define PCI_CLASS_NETWORK_ATM         0x03\r
+#define PCI_CLASS_NETWORK_ISDN        0x04\r
+#define PCI_CLASS_NETWORK_OTHER       0x80\r
+\r
+#define PCI_CLASS_DISPLAY             0x03\r
+#define PCI_CLASS_DISPLAY_CTRL        0x03  // obsolete\r
+#define PCI_CLASS_DISPLAY_VGA         0x00\r
+#define PCI_CLASS_VGA                 0x00  // obsolete\r
+#define PCI_CLASS_DISPLAY_XGA         0x01\r
+#define PCI_CLASS_DISPLAY_3D          0x02\r
+#define PCI_CLASS_DISPLAY_OTHER       0x80\r
+#define PCI_CLASS_DISPLAY_GFX         0x80\r
+#define PCI_CLASS_GFX                 0x80  // obsolete\r
+#define PCI_CLASS_BRIDGE              0x06\r
+#define PCI_CLASS_BRIDGE_HOST         0x00\r
+#define PCI_CLASS_BRIDGE_ISA          0x01\r
+#define PCI_CLASS_ISA                 0x01  // obsolete\r
+#define PCI_CLASS_BRIDGE_EISA         0x02\r
+#define PCI_CLASS_BRIDGE_MCA          0x03\r
+#define PCI_CLASS_BRIDGE_P2P          0x04\r
+#define PCI_CLASS_BRIDGE_PCMCIA       0x05\r
+#define PCI_CLASS_BRIDGE_NUBUS        0x06\r
+#define PCI_CLASS_BRIDGE_CARDBUS      0x07\r
+#define PCI_CLASS_BRIDGE_RACEWAY      0x08\r
+#define PCI_CLASS_BRIDGE_ISA_PDECODE  0x80\r
+#define PCI_CLASS_ISA_POSITIVE_DECODE 0x80  // obsolete\r
+#define PCI_CLASS_SERIAL              0x0C\r
+#define PCI_CLASS_SERIAL_FIREWIRE     0x00\r
+#define PCI_CLASS_SERIAL_ACCESS_BUS   0x01\r
+#define PCI_CLASS_SERIAL_SSA          0x02\r
+#define PCI_CLASS_SERIAL_USB          0x03\r
+#define PCI_CLASS_SERIAL_FIBRECHANNEL 0x04\r
+#define PCI_CLASS_SERIAL_SMB          0x05\r
+\r
+#define IS_CLASS1(_p, c)              ((_p)->Hdr.ClassCode[2] == (c))\r
+#define IS_CLASS2(_p, c, s)           (IS_CLASS1 (_p, c) && ((_p)->Hdr.ClassCode[1] == (s)))\r
+#define IS_CLASS3(_p, c, s, p)        (IS_CLASS2 (_p, c, s) && ((_p)->Hdr.ClassCode[0] == (p)))\r
+\r
+#define IS_PCI_DISPLAY(_p)            IS_CLASS1 (_p, PCI_CLASS_DISPLAY)\r
+#define IS_PCI_VGA(_p)                IS_CLASS3 (_p, PCI_CLASS_DISPLAY, PCI_CLASS_DISPLAY_VGA, 0)\r
+#define IS_PCI_8514(_p)               IS_CLASS3 (_p, PCI_CLASS_DISPLAY, PCI_CLASS_DISPLAY_VGA, 1)\r
+#define IS_PCI_GFX(_p)                IS_CLASS3 (_p, PCI_CLASS_DISPLAY, PCI_CLASS_DISPLAY_GFX, 0)\r
+#define IS_PCI_OLD(_p)                IS_CLASS1 (_p, PCI_CLASS_OLD)\r
+#define IS_PCI_OLD_VGA(_p)            IS_CLASS2 (_p, PCI_CLASS_OLD, PCI_CLASS_OLD_VGA)\r
+#define IS_PCI_IDE(_p)                IS_CLASS2 (_p, PCI_CLASS_MASS_STORAGE, PCI_CLASS_MASS_STORAGE_IDE)\r
+#define IS_PCI_SCSI(_p)               IS_CLASS3 (_p, PCI_CLASS_MASS_STORAGE, PCI_CLASS_MASS_STORAGE_SCSI, 0)\r
+#define IS_PCI_RAID(_p)               IS_CLASS3 (_p, PCI_CLASS_MASS_STORAGE, PCI_CLASS_MASS_STORAGE_RAID, 0)\r
+#define IS_PCI_LPC(_p)                IS_CLASS3 (_p, PCI_CLASS_BRIDGE, PCI_CLASS_BRIDGE_ISA, 0)\r
+#define IS_PCI_P2P(_p)                IS_CLASS3 (_p, PCI_CLASS_BRIDGE, PCI_CLASS_BRIDGE_P2P, 0)\r
+#define IS_PCI_P2P_SUB(_p)            IS_CLASS3 (_p, PCI_CLASS_BRIDGE, PCI_CLASS_BRIDGE_P2P, 1)\r
+#define IS_PCI_USB(_p)                IS_CLASS2 (_p, PCI_CLASS_SERIAL, PCI_CLASS_SERIAL_USB)\r
+\r
+#define HEADER_TYPE_DEVICE            0x00\r
+#define HEADER_TYPE_PCI_TO_PCI_BRIDGE 0x01\r
+#define HEADER_TYPE_CARDBUS_BRIDGE    0x02\r
+\r
+#define HEADER_TYPE_MULTI_FUNCTION    0x80\r
+#define HEADER_LAYOUT_CODE            0x7f\r
+\r
+#define IS_PCI_BRIDGE(_p)             (((_p)->Hdr.HeaderType & HEADER_LAYOUT_CODE) == (HEADER_TYPE_PCI_TO_PCI_BRIDGE))\r
+#define IS_CARDBUS_BRIDGE(_p)         (((_p)->Hdr.HeaderType & HEADER_LAYOUT_CODE) == (HEADER_TYPE_CARDBUS_BRIDGE))\r
+#define IS_PCI_MULTI_FUNC(_p)         ((_p)->Hdr.HeaderType & HEADER_TYPE_MULTI_FUNCTION)\r
+\r
+#define PCI_DEVICE_ROMBAR             0x30\r
+#define PCI_BRIDGE_ROMBAR             0x38\r
+\r
+#define PCI_MAX_BAR                   6\r
+#define PCI_MAX_CONFIG_OFFSET         0x100\r
+//\r
+// bugbug: this is supported in PCI spec v2.3\r
+//\r
+#define PCI_EXP_MAX_CONFIG_OFFSET                   0x1000\r
+\r
+#define PCI_VENDOR_ID_OFFSET                        0x00\r
+#define PCI_DEVICE_ID_OFFSET                        0x02\r
+#define PCI_COMMAND_OFFSET                          0x04\r
+#define PCI_PRIMARY_STATUS_OFFSET                   0x06\r
+#define PCI_REVISION_ID_OFFSET                      0x08\r
+#define PCI_CLASSCODE_OFFSET                        0x09\r
+#define PCI_CACHELINE_SIZE_OFFSET                   0x0C\r
+#define PCI_LATENCY_TIMER_OFFSET                    0x0D\r
+#define PCI_HEADER_TYPE_OFFSET                      0x0E\r
+#define PCI_BIST_OFFSET                             0x0F\r
+\r
+#define PCI_BRIDGE_CONTROL_REGISTER_OFFSET          0x3E\r
+#define PCI_BRIDGE_STATUS_REGISTER_OFFSET           0x1E\r
+\r
+#define PCI_BRIDGE_PRIMARY_BUS_REGISTER_OFFSET      0x18\r
+#define PCI_BRIDGE_SECONDARY_BUS_REGISTER_OFFSET    0x19\r
+#define PCI_BRIDGE_SUBORDINATE_BUS_REGISTER_OFFSET  0x1a\r
+\r
+typedef struct {\r
+  UINT8 Register;\r
+  UINT8 Function;\r
+  UINT8 Device;\r
+  UINT8 Bus;\r
+  UINT8 Reserved[4];\r
+} DEFIO_PCI_ADDR;\r
+\r
+typedef union {\r
+  struct {\r
+    UINT32  Reg : 8;\r
+    UINT32  Func : 3;\r
+    UINT32  Dev : 5;\r
+    UINT32  Bus : 8;\r
+    UINT32  Reserved : 7;\r
+    UINT32  Enable : 1;\r
+  } Bits;\r
+  UINT32  Uint32;\r
+} PCI_CONFIG_ACCESS_CF8;\r
+\r
+#pragma pack()\r
+\r
+#define EFI_ROOT_BRIDGE_LIST                            'eprb'\r
+#define PCI_EXPANSION_ROM_HEADER_SIGNATURE              0xaa55\r
+#define EFI_PCI_EXPANSION_ROM_HEADER_EFISIGNATURE       0x0EF1\r
+#define PCI_DATA_STRUCTURE_SIGNATURE                    EFI_SIGNATURE_32 ('P', 'C', 'I', 'R')\r
+#define PCI_CODE_TYPE_PCAT_IMAGE                        0x00\r
+#define PCI_CODE_TYPE_EFI_IMAGE                         0x03\r
+#define EFI_PCI_EXPANSION_ROM_HEADER_COMPRESSED         0x0001\r
+\r
+#define EFI_PCI_COMMAND_IO_SPACE                        0x0001\r
+#define EFI_PCI_COMMAND_MEMORY_SPACE                    0x0002\r
+#define EFI_PCI_COMMAND_BUS_MASTER                      0x0004\r
+#define EFI_PCI_COMMAND_SPECIAL_CYCLE                   0x0008\r
+#define EFI_PCI_COMMAND_MEMORY_WRITE_AND_INVALIDATE     0x0010\r
+#define EFI_PCI_COMMAND_VGA_PALETTE_SNOOP               0x0020\r
+#define EFI_PCI_COMMAND_PARITY_ERROR_RESPOND            0x0040\r
+#define EFI_PCI_COMMAND_STEPPING_CONTROL                0x0080\r
+#define EFI_PCI_COMMAND_SERR                            0x0100\r
+#define EFI_PCI_COMMAND_FAST_BACK_TO_BACK               0x0200\r
+\r
+#define EFI_PCI_BRIDGE_CONTROL_PARITY_ERROR_RESPONSE    0x0001\r
+#define EFI_PCI_BRIDGE_CONTROL_SERR                     0x0002\r
+#define EFI_PCI_BRIDGE_CONTROL_ISA                      0x0004\r
+#define EFI_PCI_BRIDGE_CONTROL_VGA                      0x0008\r
+#define EFI_PCI_BRIDGE_CONTROL_VGA_16                   0x0010\r
+#define EFI_PCI_BRIDGE_CONTROL_MASTER_ABORT             0x0020\r
+#define EFI_PCI_BRIDGE_CONTROL_RESET_SECONDARY_BUS      0x0040\r
+#define EFI_PCI_BRIDGE_CONTROL_FAST_BACK_TO_BACK        0x0080\r
+#define EFI_PCI_BRIDGE_CONTROL_PRIMARY_DISCARD_TIMER    0x0100\r
+#define EFI_PCI_BRIDGE_CONTROL_SECONDARY_DISCARD_TIMER  0x0200\r
+#define EFI_PCI_BRIDGE_CONTROL_TIMER_STATUS             0x0400\r
+#define EFI_PCI_BRIDGE_CONTROL_DISCARD_TIMER_SERR       0x0800\r
+\r
+//\r
+// Following are the PCI-CARDBUS bridge control bit\r
+//\r
+#define EFI_PCI_BRIDGE_CONTROL_IREQINT_ENABLE       0x0080\r
+#define EFI_PCI_BRIDGE_CONTROL_RANGE0_MEMORY_TYPE   0x0100\r
+#define EFI_PCI_BRIDGE_CONTROL_RANGE1_MEMORY_TYPE   0x0200\r
+#define EFI_PCI_BRIDGE_CONTROL_WRITE_POSTING_ENABLE 0x0400\r
+\r
+//\r
+// Following are the PCI status control bit\r
+//\r
+#define EFI_PCI_STATUS_CAPABILITY             0x0010\r
+#define EFI_PCI_STATUS_66MZ_CAPABLE           0x0020\r
+#define EFI_PCI_FAST_BACK_TO_BACK_CAPABLE     0x0080\r
+#define EFI_PCI_MASTER_DATA_PARITY_ERROR      0x0100\r
+\r
+#define EFI_PCI_CAPABILITY_PTR                0x34\r
+#define EFI_PCI_CARDBUS_BRIDGE_CAPABILITY_PTR 0x14\r
+\r
+#pragma pack(1)\r
+typedef struct {\r
+  UINT16  Signature;    // 0xaa55\r
+  UINT8   Reserved[0x16];\r
+  UINT16  PcirOffset;\r
+} PCI_EXPANSION_ROM_HEADER;\r
+\r
+typedef struct {\r
+  UINT16  Signature;    // 0xaa55\r
+  UINT16  InitializationSize;\r
+  UINT32  EfiSignature; // 0x0EF1\r
+  UINT16  EfiSubsystem;\r
+  UINT16  EfiMachineType;\r
+  UINT16  CompressionType;\r
+  UINT8   Reserved[8];\r
+  UINT16  EfiImageHeaderOffset;\r
+  UINT16  PcirOffset;\r
+} EFI_PCI_EXPANSION_ROM_HEADER;\r
+\r
+typedef struct {\r
+  UINT16  Signature;    // 0xaa55\r
+  UINT8   Size512;\r
+  UINT8   Reserved[15];\r
+  UINT16  PcirOffset;\r
+} EFI_LEGACY_EXPANSION_ROM_HEADER;\r
+\r
+typedef union {\r
+  UINT8                           *Raw;\r
+  PCI_EXPANSION_ROM_HEADER        *Generic;\r
+  EFI_PCI_EXPANSION_ROM_HEADER    *Efi;\r
+  EFI_LEGACY_EXPANSION_ROM_HEADER *PcAt;\r
+} EFI_PCI_ROM_HEADER;\r
+\r
+typedef struct {\r
+  UINT32  Signature;    // "PCIR"\r
+  UINT16  VendorId;\r
+  UINT16  DeviceId;\r
+  UINT16  Reserved0;\r
+  UINT16  Length;\r
+  UINT8   Revision;\r
+  UINT8   ClassCode[3];\r
+  UINT16  ImageLength;\r
+  UINT16  CodeRevision;\r
+  UINT8   CodeType;\r
+  UINT8   Indicator;\r
+  UINT16  Reserved1;\r
+} PCI_DATA_STRUCTURE;\r
+\r
+//\r
+// PCI Capability List IDs and records\r
+//\r
+#define EFI_PCI_CAPABILITY_ID_PMI     0x01\r
+#define EFI_PCI_CAPABILITY_ID_AGP     0x02\r
+#define EFI_PCI_CAPABILITY_ID_VPD     0x03\r
+#define EFI_PCI_CAPABILITY_ID_SLOTID  0x04\r
+#define EFI_PCI_CAPABILITY_ID_MSI     0x05\r
+#define EFI_PCI_CAPABILITY_ID_HOTPLUG 0x06\r
+#define EFI_PCI_CAPABILITY_ID_PCIX    0x07\r
+//\r
+// bugbug: this ID is defined in PCI spec v2.3\r
+//\r
+#define EFI_PCI_CAPABILITY_ID_PCIEXP  0x10\r
+\r
+typedef struct {\r
+  UINT8 CapabilityID;\r
+  UINT8 NextItemPtr;\r
+} EFI_PCI_CAPABILITY_HDR;\r
+\r
+//\r
+// Capability EFI_PCI_CAPABILITY_ID_PMI\r
+//\r
+typedef struct {\r
+  EFI_PCI_CAPABILITY_HDR  Hdr;\r
+  UINT16                  PMC;\r
+  UINT16                  PMCSR;\r
+  UINT8                   BridgeExtention;\r
+  UINT8                   Data;\r
+} EFI_PCI_CAPABILITY_PMI;\r
+\r
+//\r
+// Capability EFI_PCI_CAPABILITY_ID_AGP\r
+//\r
+typedef struct {\r
+  EFI_PCI_CAPABILITY_HDR  Hdr;\r
+  UINT8                   Rev;\r
+  UINT8                   Reserved;\r
+  UINT32                  Status;\r
+  UINT32                  Command;\r
+} EFI_PCI_CAPABILITY_AGP;\r
+\r
+//\r
+// Capability EFI_PCI_CAPABILITY_ID_VPD\r
+//\r
+typedef struct {\r
+  EFI_PCI_CAPABILITY_HDR  Hdr;\r
+  UINT16                  AddrReg;\r
+  UINT32                  DataReg;\r
+} EFI_PCI_CAPABILITY_VPD;\r
+\r
+//\r
+// Capability EFI_PCI_CAPABILITY_ID_SLOTID\r
+//\r
+typedef struct {\r
+  EFI_PCI_CAPABILITY_HDR  Hdr;\r
+  UINT8                   ExpnsSlotReg;\r
+  UINT8                   ChassisNo;\r
+} EFI_PCI_CAPABILITY_SLOTID;\r
+\r
+//\r
+// Capability EFI_PCI_CAPABILITY_ID_MSI\r
+//\r
+typedef struct {\r
+  EFI_PCI_CAPABILITY_HDR  Hdr;\r
+  UINT16                  MsgCtrlReg;\r
+  UINT32                  MsgAddrReg;\r
+  UINT16                  MsgDataReg;\r
+} EFI_PCI_CAPABILITY_MSI32;\r
+\r
+typedef struct {\r
+  EFI_PCI_CAPABILITY_HDR  Hdr;\r
+  UINT16                  MsgCtrlReg;\r
+  UINT32                  MsgAddrRegLsdw;\r
+  UINT32                  MsgAddrRegMsdw;\r
+  UINT16                  MsgDataReg;\r
+} EFI_PCI_CAPABILITY_MSI64;\r
+\r
+//\r
+// Capability EFI_PCI_CAPABILITY_ID_HOTPLUG\r
+//\r
+typedef struct {\r
+  EFI_PCI_CAPABILITY_HDR  Hdr;\r
+  //\r
+  // not finished - fields need to go here\r
+  //\r
+} EFI_PCI_CAPABILITY_HOTPLUG;\r
+\r
+//\r
+// Capability EFI_PCI_CAPABILITY_ID_PCIX\r
+//\r
+typedef struct {\r
+  EFI_PCI_CAPABILITY_HDR  Hdr;\r
+  UINT16                  CommandReg;\r
+  UINT32                  StatusReg;\r
+} EFI_PCI_CAPABILITY_PCIX;\r
+\r
+typedef struct {\r
+  EFI_PCI_CAPABILITY_HDR  Hdr;\r
+  UINT16                  SecStatusReg;\r
+  UINT32                  StatusReg;\r
+  UINT32                  SplitTransCtrlRegUp;\r
+  UINT32                  SplitTransCtrlRegDn;\r
+} EFI_PCI_CAPABILITY_PCIX_BRDG;\r
+\r
+#define DEVICE_ID_NOCARE    0xFFFF\r
+\r
+#define PCI_ACPI_UNUSED     0\r
+#define PCI_BAR_NOCHANGE    0\r
+#define PCI_BAR_OLD_ALIGN   0xFFFFFFFFFFFFFFFFULL\r
+#define PCI_BAR_EVEN_ALIGN  0xFFFFFFFFFFFFFFFEULL\r
+#define PCI_BAR_SQUAD_ALIGN 0xFFFFFFFFFFFFFFFDULL\r
+#define PCI_BAR_DQUAD_ALIGN 0xFFFFFFFFFFFFFFFCULL\r
+\r
+#define PCI_BAR_IDX0        0x00\r
+#define PCI_BAR_IDX1        0x01\r
+#define PCI_BAR_IDX2        0x02\r
+#define PCI_BAR_IDX3        0x03\r
+#define PCI_BAR_IDX4        0x04\r
+#define PCI_BAR_IDX5        0x05\r
+#define PCI_BAR_ALL         0xFF\r
+\r
+#pragma pack(pop)\r
+\r
+#endif\r
diff --git a/Tools/CodeTools/Source/Include/Library/PeCoffLib.h b/Tools/CodeTools/Source/Include/Library/PeCoffLib.h
new file mode 100644 (file)
index 0000000..08e8195
--- /dev/null
@@ -0,0 +1,131 @@
+/** @file\r
+       Memory Only PE COFF loader\r
+\r
+       Copyright (c) 2006, Intel Corporation                                                         \r
+       All rights reserved. This program and the accompanying materials                          \r
+       are licensed and made available under the terms and conditions of the BSD License         \r
+       which accompanies this distribution.  The full text of the license may be found at        \r
+       http://opensource.org/licenses/bsd-license.php                                            \r
+\r
+       THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+       WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+       Module Name:    PeCoffLib.h\r
+\r
+**/\r
+\r
+#ifndef __BASE_PE_COFF_LIB_H__\r
+#define __BASE_PE_COFF_LIB_H__\r
+\r
+//\r
+// Return status codes from the PE/COFF Loader services\r
+// BUGBUG: Find where used and see if can be replaced by RETURN_STATUS codes\r
+//\r
+#define IMAGE_ERROR_SUCCESS                      0\r
+#define IMAGE_ERROR_IMAGE_READ                   1  \r
+#define IMAGE_ERROR_INVALID_PE_HEADER_SIGNATURE  2\r
+#define IMAGE_ERROR_INVALID_MACHINE_TYPE         3\r
+#define IMAGE_ERROR_INVALID_SUBSYSTEM            4\r
+#define IMAGE_ERROR_INVALID_IMAGE_ADDRESS        5\r
+#define IMAGE_ERROR_INVALID_IMAGE_SIZE           6\r
+#define IMAGE_ERROR_INVALID_SECTION_ALIGNMENT    7\r
+#define IMAGE_ERROR_SECTION_NOT_LOADED           8\r
+#define IMAGE_ERROR_FAILED_RELOCATION            9\r
+#define IMAGE_ERROR_FAILED_ICACHE_FLUSH          10\r
+\r
+\r
+//\r
+// PE/COFF Loader Read Function passed in by caller\r
+//\r
+typedef\r
+RETURN_STATUS\r
+(EFIAPI *PE_COFF_LOADER_READ_FILE) (\r
+  IN     VOID   *FileHandle,\r
+  IN     UINTN  FileOffset,\r
+  IN OUT UINTN  *ReadSize,\r
+  OUT    VOID   *Buffer\r
+  );\r
+\r
+//\r
+// Context structure used while PE/COFF image is being loaded and relocated\r
+//\r
+typedef struct {\r
+  PHYSICAL_ADDRESS                  ImageAddress;\r
+  UINT64                            ImageSize;\r
+  PHYSICAL_ADDRESS                  DestinationAddress;\r
+  PHYSICAL_ADDRESS                  EntryPoint;\r
+  PE_COFF_LOADER_READ_FILE          ImageRead;\r
+  VOID                              *Handle;\r
+  VOID                              *FixupData;\r
+  UINT32                            SectionAlignment;\r
+  UINT32                            PeCoffHeaderOffset;\r
+  UINT32                            DebugDirectoryEntryRva;\r
+  VOID                              *CodeView;\r
+  CHAR8                             *PdbPointer;\r
+  UINTN                             SizeOfHeaders;\r
+  UINT32                            ImageCodeMemoryType;\r
+  UINT32                            ImageDataMemoryType;\r
+  UINT32                            ImageError;\r
+  UINTN                             FixupDataSize;\r
+  UINT16                            Machine;\r
+  UINT16                            ImageType;\r
+  BOOLEAN                           RelocationsStripped;\r
+  BOOLEAN                           IsTeImage;\r
+} PE_COFF_LOADER_IMAGE_CONTEXT;\r
+\r
+\r
+/**\r
+       Retrieves information on a PE/COFF image\r
+\r
+       @param  ImageContext The context of the image being loaded\r
+\r
+       @retval EFI_SUCCESS The information on the PE/COFF image was collected.\r
+       @retval EFI_INVALID_PARAMETER ImageContext is NULL.\r
+       @retval EFI_UNSUPPORTED The PE/COFF image is not supported.\r
+       @retval Otherwise The error status from reading the PE/COFF image using the\r
+       ImageContext->ImageRead() function\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+PeCoffLoaderGetImageInfo (\r
+  IN OUT PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext\r
+  )\r
+;\r
+\r
+/**\r
+       Relocates a PE/COFF image in memory\r
+\r
+       @param  ImageContext Contains information on the loaded image to relocate\r
+\r
+       @retval EFI_SUCCESS      if the PE/COFF image was relocated\r
+       @retval EFI_LOAD_ERROR   if the image is not a valid PE/COFF image\r
+       @retval EFI_UNSUPPORTED  not support\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+PeCoffLoaderRelocateImage (\r
+  IN OUT PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext\r
+  )\r
+;\r
+\r
+/**\r
+       Loads a PE/COFF image into memory\r
+\r
+       @param  ImageContext Contains information on image to load into memory\r
+\r
+       @retval EFI_SUCCESS            if the PE/COFF image was loaded\r
+       @retval EFI_BUFFER_TOO_SMALL   if the caller did not provide a large enough buffer\r
+       @retval EFI_LOAD_ERROR         if the image is a runtime driver with no relocations\r
+       @retval EFI_INVALID_PARAMETER  if the image address is invalid\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+PeCoffLoaderLoadImage (\r
+  IN OUT PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext\r
+  )\r
+;\r
+\r
+#endif\r
diff --git a/Tools/CodeTools/Source/Include/Library/PrintLib.h b/Tools/CodeTools/Source/Include/Library/PrintLib.h
new file mode 100644 (file)
index 0000000..9c65459
--- /dev/null
@@ -0,0 +1,406 @@
+/** @file\r
+       Library that provides print services\r
+\r
+       Copyright (c) 2006, Intel Corporation                                                         \r
+       All rights reserved. This program and the accompanying materials                          \r
+       are licensed and made available under the terms and conditions of the BSD License         \r
+       which accompanies this distribution.  The full text of the license may be found at        \r
+       http://opensource.org/licenses/bsd-license.php                                            \r
+\r
+       THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+       WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+       Module Name:    PrintLib.h\r
+\r
+**/\r
+\r
+#ifndef __PRINT_LIB_H__\r
+#define __PRINT_LIB_H__\r
+\r
+//\r
+// Print primitives\r
+//\r
+#define LEFT_JUSTIFY      0x01\r
+#define COMMA_TYPE        0x08\r
+#define PREFIX_ZERO       0x20\r
+\r
+/**\r
+  Produces a Null-terminated Unicode string in an output buffer based on \r
+  a Null-terminated Unicode format string and a VA_LIST argument list\r
+  \r
+  Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer\r
+  and BufferSize.  \r
+  The Unicode string is produced by parsing the format string specified by FormatString.  \r
+  Arguments are pulled from the variable argument list specified by Marker based on the \r
+  contents of the format string.  \r
+  The length of the produced output buffer is returned.\r
+  If BufferSize is 0, then no output buffer is produced and 0 is returned.\r
+\r
+  If BufferSize is not 0 and StartOfBuffer is NULL, then ASSERT().\r
+  If BufferSize is not 0 and FormatString is NULL, then ASSERT().\r
+  If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than \r
+  PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().\r
+  If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string\r
+  contains more than PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().\r
+\r
+  @param  StartOfBuffer   APointer to the output buffer for the produced Null-terminated \r
+                          Unicode string.\r
+  @param  BufferSize      The size, in bytes, of the output buffer specified by StartOfBuffer.\r
+  @param  FormatString    Null-terminated Unicode format string.\r
+  @param  Marker          VA_LIST marker for the variable argument list.\r
+  \r
+  @return return Length of the produced output buffer.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+UnicodeVSPrint (\r
+  OUT CHAR16        *StartOfBuffer,\r
+  IN  UINTN         BufferSize,\r
+  IN  CONST CHAR16  *FormatString,\r
+  IN  VA_LIST       Marker\r
+  );\r
+\r
+/**\r
+  Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated \r
+  Unicode format string and variable argument list.\r
+  \r
+  Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer\r
+  and BufferSize.\r
+  The Unicode string is produced by parsing the format string specified by FormatString.\r
+  Arguments are pulled from the variable argument list based on the contents of the format string.\r
+  The length of the produced output buffer is returned.  \r
+  If BufferSize is 0, then no output buffer is produced and 0 is returned.\r
+\r
+  If BufferSize is not 0 and StartOfBuffer is NULL, then ASSERT().\r
+  If BufferSize is not 0 and FormatString is NULL, then ASSERT().\r
+  If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than \r
+  PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().\r
+  If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string\r
+  contains more than PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().\r
+\r
+  @param  StartOfBuffer   APointer to the output buffer for the produced Null-terminated \r
+                          Unicode string.\r
+  @param  BufferSize      The size, in bytes, of the output buffer specified by StartOfBuffer.\r
+  @param  FormatString    Null-terminated Unicode format string.\r
+  \r
+  @return Length of the produced output buffer.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+UnicodeSPrint (\r
+  OUT CHAR16        *StartOfBuffer,\r
+  IN  UINTN         BufferSize,\r
+  IN  CONST CHAR16  *FormatString,\r
+  ...\r
+  );\r
+\r
+/**\r
+  Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated\r
+  ASCII format string and a VA_LIST argument list\r
+  \r
+  Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer\r
+  and BufferSize.\r
+  The Unicode string is produced by parsing the format string specified by FormatString.\r
+  Arguments are pulled from the variable argument list specified by Marker based on the \r
+  contents of the format string.\r
+  The length of the produced output buffer is returned.\r
+  If BufferSize is 0, then no output buffer is produced and 0 is returned.\r
+\r
+  If BufferSize is not 0 and StartOfBuffer is NULL, then ASSERT().\r
+  If BufferSize is not 0 and FormatString is NULL, then ASSERT().\r
+  If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than \r
+  PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().\r
+  If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string\r
+  contains more than PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().\r
+\r
+  @param  StartOfBuffer   APointer to the output buffer for the produced Null-terminated \r
+                          Unicode string.\r
+  @param  BufferSize      The size, in bytes, of the output buffer specified by StartOfBuffer.\r
+  @param  FormatString    Null-terminated Unicode format string.\r
+  @param  Marker          VA_LIST marker for the variable argument list.\r
+  \r
+  @return Length of the produced output buffer.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+UnicodeVSPrintAsciiFormat (\r
+  OUT CHAR16       *StartOfBuffer,\r
+  IN  UINTN        BufferSize,\r
+  IN  CONST CHAR8  *FormatString,\r
+  IN  VA_LIST      Marker\r
+  );\r
+\r
+/**\r
+  Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated \r
+  ASCII format string and  variable argument list.\r
+  \r
+  Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer\r
+  and BufferSize.\r
+  The Unicode string is produced by parsing the format string specified by FormatString.\r
+  Arguments are pulled from the variable argument list based on the contents of the \r
+  format string.\r
+  The length of the produced output buffer is returned.\r
+  If BufferSize is 0, then no output buffer is produced and 0 is returned.\r
+\r
+  If BufferSize is not 0 and StartOfBuffer is NULL, then ASSERT().\r
+  If BufferSize is not 0 and FormatString is NULL, then ASSERT().\r
+  If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than \r
+  PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().\r
+  If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string\r
+  contains more than PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().\r
+\r
+  @param  StartOfBuffer   APointer to the output buffer for the produced Null-terminated \r
+                          Unicode string.\r
+  @param  BufferSize      The size, in bytes, of the output buffer specified by StartOfBuffer.\r
+  @param  FormatString    Null-terminated Unicode format string.\r
+  \r
+  @return Length of the produced output buffer.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+UnicodeSPrintAsciiFormat (\r
+  OUT CHAR16       *StartOfBuffer,\r
+  IN  UINTN        BufferSize,\r
+  IN  CONST CHAR8  *FormatString,\r
+  ...\r
+  );\r
+\r
+/**\r
+  Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated\r
+  ASCII format string and a VA_LIST argument list.\r
+  \r
+  Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer\r
+  and BufferSize.\r
+  The ASCII string is produced by parsing the format string specified by FormatString.\r
+  Arguments are pulled from the variable argument list specified by Marker based on \r
+  the contents of the format string.\r
+  The length of the produced output buffer is returned.\r
+  If BufferSize is 0, then no output buffer is produced and 0 is returned.\r
+\r
+  If BufferSize is not 0 and StartOfBuffer is NULL, then ASSERT().\r
+  If BufferSize is not 0 and FormatString is NULL, then ASSERT().\r
+  If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than \r
+  PcdMaximumUnicodeStringLength ASCII characters, then ASSERT().\r
+  If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string\r
+  contains more than PcdMaximumUnicodeStringLength ASCII characters, then ASSERT().\r
+\r
+  @param  StartOfBuffer   APointer to the output buffer for the produced Null-terminated \r
+                          ASCII string.\r
+  @param  BufferSize      The size, in bytes, of the output buffer specified by StartOfBuffer.\r
+  @param  FormatString    Null-terminated Unicode format string.\r
+  @param  Marker          VA_LIST marker for the variable argument list.\r
+  \r
+  @return Length of the produced output buffer.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+AsciiVSPrint (\r
+  OUT CHAR8         *StartOfBuffer,\r
+  IN  UINTN         BufferSize,\r
+  IN  CONST CHAR8   *FormatString,\r
+  IN  VA_LIST       Marker\r
+  );\r
+\r
+/**\r
+  Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated\r
+  ASCII format string and  variable argument list.\r
+  \r
+  Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer\r
+  and BufferSize.\r
+  The ASCII string is produced by parsing the format string specified by FormatString.\r
+  Arguments are pulled from the variable argument list based on the contents of the \r
+  format string.\r
+  The length of the produced output buffer is returned.\r
+  If BufferSize is 0, then no output buffer is produced and 0 is returned.\r
+\r
+  If BufferSize is not 0 and StartOfBuffer is NULL, then ASSERT().\r
+  If BufferSize is not 0 and FormatString is NULL, then ASSERT().\r
+  If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than \r
+  PcdMaximumUnicodeStringLength ASCII characters, then ASSERT().\r
+  If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string\r
+  contains more than PcdMaximumUnicodeStringLength ASCII characters, then ASSERT().\r
+\r
+  @param  StartOfBuffer   APointer to the output buffer for the produced Null-terminated \r
+                          ASCII string.\r
+  @param  BufferSize      The size, in bytes, of the output buffer specified by StartOfBuffer.\r
+  @param  FormatString    Null-terminated Unicode format string.\r
+  \r
+  @return Length of the produced output buffer.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+AsciiSPrint (\r
+  OUT CHAR8        *StartOfBuffer,\r
+  IN  UINTN        BufferSize,\r
+  IN  CONST CHAR8  *FormatString,\r
+  ...\r
+  );\r
+\r
+/**\r
+  Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated\r
+  ASCII format string and a VA_LIST argument list.\r
+  \r
+  Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer\r
+  and BufferSize.\r
+  The ASCII string is produced by parsing the format string specified by FormatString.\r
+  Arguments are pulled from the variable argument list specified by Marker based on \r
+  the contents of the format string.\r
+  The length of the produced output buffer is returned.\r
+  If BufferSize is 0, then no output buffer is produced and 0 is returned.\r
+\r
+  If BufferSize is not 0 and StartOfBuffer is NULL, then ASSERT().\r
+  If BufferSize is not 0 and FormatString is NULL, then ASSERT().\r
+  If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than \r
+  PcdMaximumUnicodeStringLength ASCII characters, then ASSERT().\r
+  If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string\r
+  contains more than PcdMaximumUnicodeStringLength ASCII characters, then ASSERT().\r
+\r
+  @param  StartOfBuffer   APointer to the output buffer for the produced Null-terminated \r
+                          ASCII string.\r
+  @param  BufferSize      The size, in bytes, of the output buffer specified by StartOfBuffer.\r
+  @param  FormatString    Null-terminated Unicode format string.\r
+  @param  Marker          VA_LIST marker for the variable argument list.\r
+  \r
+  @return Length of the produced output buffer.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+AsciiVSPrintUnicodeFormat (\r
+  OUT CHAR8         *StartOfBuffer,\r
+  IN  UINTN         BufferSize,\r
+  IN  CONST CHAR16  *FormatString,\r
+  IN  VA_LIST       Marker\r
+  );\r
+\r
+/**\r
+  Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated\r
+  ASCII format string and  variable argument list.\r
+  \r
+  Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer\r
+  and BufferSize.\r
+  The ASCII string is produced by parsing the format string specified by FormatString.\r
+  Arguments are pulled from the variable argument list based on the contents of the \r
+  format string.\r
+  The length of the produced output buffer is returned.\r
+  If BufferSize is 0, then no output buffer is produced and 0 is returned.\r
+\r
+  If BufferSize is not 0 and StartOfBuffer is NULL, then ASSERT().\r
+  If BufferSize is not 0 and FormatString is NULL, then ASSERT().\r
+  If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than \r
+  PcdMaximumUnicodeStringLength ASCII characters, then ASSERT().\r
+  If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string\r
+  contains more than PcdMaximumUnicodeStringLength ASCII characters, then ASSERT().\r
+\r
+  @param  StartOfBuffer   APointer to the output buffer for the produced Null-terminated \r
+                          ASCII string.\r
+  @param  BufferSize      The size, in bytes, of the output buffer specified by StartOfBuffer.\r
+  @param  FormatString    Null-terminated Unicode format string.\r
+  \r
+  @return Length of the produced output buffer.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+AsciiSPrintUnicodeFormat (\r
+  OUT CHAR8         *StartOfBuffer,\r
+  IN  UINTN         BufferSize,\r
+  IN  CONST CHAR16  *FormatString,\r
+  ...\r
+  );\r
+\r
+/**\r
+  Converts a decimal value to a Null-terminated Unicode string.\r
+  \r
+  Converts the decimal number specified by Value to a Null-terminated Unicode \r
+  string specified by Buffer containing at most Width characters.\r
+  If Width is 0 then a width of  MAXIMUM_VALUE_CHARACTERS is assumed.\r
+  The total number of characters placed in Buffer is returned.\r
+  If the conversion contains more than Width characters, then only the first\r
+  Width characters are returned, and the total number of characters \r
+  required to perform the conversion is returned.\r
+  Additional conversion parameters are specified in Flags.  \r
+  The Flags bit LEFT_JUSTIFY is always ignored.\r
+  All conversions are left justified in Buffer.\r
+  If Width is 0, PREFIX_ZERO is ignored in Flags.\r
+  If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and commas\r
+  are inserted every 3rd digit starting from the right.\r
+  If Value is < 0, then the fist character in Buffer is a '-'.\r
+  If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored, \r
+  then Buffer is padded with '0' characters so the combination of the optional '-' \r
+  sign character, '0' characters, digit characters for Value, and the Null-terminator\r
+  add up to Width characters.\r
+\r
+  If Buffer is NULL, then ASSERT().\r
+  If unsupported bits are set in Flags, then ASSERT().\r
+  If Width >= MAXIMUM_VALUE_CHARACTERS, then ASSERT()\r
+\r
+  @param  Buffer  Pointer to the output buffer for the produced Null-terminated\r
+                  Unicode string.\r
+  @param  Flags   The bitmask of flags that specify left justification, zero pad, and commas.\r
+  @param  Value   The 64-bit signed value to convert to a string.\r
+  @param  Width          The maximum number of Unicode characters to place in Buffer.\r
+  \r
+  @return Total number of characters required to perform the conversion.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+UnicodeValueToString (\r
+  IN OUT CHAR16  *Buffer,\r
+  IN UINTN       Flags,\r
+  IN INT64       Value,\r
+  IN UINTN       Width\r
+  );\r
+\r
+/**\r
+  Converts a decimal value to a Null-terminated ASCII string.\r
+  \r
+  Converts the decimal number specified by Value to a Null-terminated ASCII string \r
+  specified by Buffer containing at most Width characters.\r
+  If Width is 0 then a width of  MAXIMUM_VALUE_CHARACTERS is assumed.\r
+  The total number of characters placed in Buffer is returned.\r
+  If the conversion contains more than Width characters, then only the first Width\r
+  characters are returned, and the total number of characters required to perform\r
+  the conversion is returned.\r
+  Additional conversion parameters are specified in Flags.  \r
+  The Flags bit LEFT_JUSTIFY is always ignored.\r
+  All conversions are left justified in Buffer.\r
+  If Width is 0, PREFIX_ZERO is ignored in Flags.\r
+  If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and commas \r
+  are inserted every 3rd digit starting from the right.\r
+  If Value is < 0, then the fist character in Buffer is a '-'.\r
+  If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored, then Buffer\r
+  is padded with '0' characters so the combination of the optional '-'\r
+  sign character, '0' characters, digit characters for Value, and the \r
+  Null-terminator add up to Width characters.\r
+\r
+  If Buffer is NULL, then ASSERT().\r
+  If unsupported bits are set in Flags, then ASSERT().\r
+  If Width >= MAXIMUM_VALUE_CHARACTERS, then ASSERT()\r
+\r
+  @param  Buffer  Pointer to the output buffer for the produced Null-terminated\r
+                  ASCII string.\r
+  @param  Flags   The bitmask of flags that specify left justification, zero pad, and commas.\r
+  @param  Value   The 64-bit signed value to convert to a string.\r
+  @param  Width          The maximum number of ASCII characters to place in Buffer.\r
+  \r
+  @return Total number of characters required to perform the conversion.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+AsciiValueToString (\r
+  IN OUT CHAR8  *Buffer,\r
+  IN UINTN      Flags,\r
+  IN INT64      Value,\r
+  IN UINTN      Width\r
+  );\r
+\r
+#endif\r
diff --git a/Tools/CodeTools/Source/Include/Protocol/DevicePath.h b/Tools/CodeTools/Source/Include/Protocol/DevicePath.h
new file mode 100644 (file)
index 0000000..d019999
--- /dev/null
@@ -0,0 +1,94 @@
+/** @file\r
+  The device path protocol as defined in EFI 1.0.\r
+\r
+  The device path represents a programatic path to a device. It's the view\r
+  from a software point of view. It also must persist from boot to boot, so \r
+  it can not contain things like PCI bus numbers that change from boot to boot.\r
+\r
+  Copyright (c) 2006, Intel Corporation                                                         \r
+  All rights reserved. This program and the accompanying materials                          \r
+  are licensed and made available under the terms and conditions of the BSD License         \r
+  which accompanies this distribution.  The full text of the license may be found at        \r
+  http://opensource.org/licenses/bsd-license.php                                            \r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+  Module Name:  DevicePath.h\r
+\r
+**/\r
+\r
+#ifndef __EFI_DEVICE_PATH_PROTOCOL_H__\r
+#define __EFI_DEVICE_PATH_PROTOCOL_H__\r
+\r
+//\r
+// Device Path protocol\r
+//\r
+#define EFI_DEVICE_PATH_PROTOCOL_GUID \\r
+  { \\r
+    0x9576e91, 0x6d3f, 0x11d2, {0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b } \\r
+  }\r
+\r
+#pragma pack(1)\r
+\r
+typedef struct {\r
+  UINT8 Type;\r
+  UINT8 SubType;\r
+  UINT8 Length[2];\r
+} EFI_DEVICE_PATH_PROTOCOL;\r
+\r
+#pragma pack()\r
+                                             \r
+#define EFI_DP_TYPE_MASK                     0x7F\r
+#define EFI_DP_TYPE_UNPACKED                 0x80\r
+#define END_DEVICE_PATH_TYPE                 0x7f\r
+                                             \r
+#define EFI_END_ENTIRE_DEVICE_PATH           0xff\r
+#define EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE   0xff\r
+#define EFI_END_INSTANCE_DEVICE_PATH         0x01\r
+#define END_ENTIRE_DEVICE_PATH_SUBTYPE       EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE\r
+#define END_INSTANCE_DEVICE_PATH_SUBTYPE     EFI_END_INSTANCE_DEVICE_PATH\r
+                                             \r
+#define EFI_END_DEVICE_PATH_LENGTH           (sizeof (EFI_DEVICE_PATH_PROTOCOL))\r
+#define END_DEVICE_PATH_LENGTH               EFI_END_DEVICE_PATH_LENGTH\r
+                                             \r
+#define DP_IS_END_TYPE(a)                    \r
+#define DP_IS_END_SUBTYPE(a)                 (((a)->SubType == END_ENTIRE_DEVICE_PATH_SUBTYPE)\r
+#define DevicePathSubType(a)                 ((a)->SubType)\r
+#define IsDevicePathUnpacked(a)              ((a)->Type & EFI_DP_TYPE_UNPACKED)\r
+                                             \r
+#define EfiDevicePathNodeLength(a)           (((a)->Length[0]) | ((a)->Length[1] << 8))\r
+#define DevicePathNodeLength(a)              (EfiDevicePathNodeLength(a))\r
+#define EfiNextDevicePathNode(a)             ((EFI_DEVICE_PATH_PROTOCOL *) (((UINT8 *) (a)) + EfiDevicePathNodeLength (a)))\r
+#define NextDevicePathNode(a)                (EfiNextDevicePathNode(a)) \r
+                                             \r
+#define EfiDevicePathType(a)                 (((a)->Type) & EFI_DP_TYPE_MASK)\r
+#define DevicePathType(a)                    (EfiDevicePathType(a))\r
+#define EfiIsDevicePathEndType(a)            (EfiDevicePathType (a) == END_DEVICE_PATH_TYPE)\r
+#define IsDevicePathEndType(a)               (EfiIsDevicePathEndType(a)) \r
+                                             \r
+                                             \r
+#define EfiIsDevicePathEndSubType(a)         ((a)->SubType == EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE)\r
+#define IsDevicePathEndSubType(a)            (EfiIsDevicePathEndSubType(a))\r
+#define EfiIsDevicePathEndInstanceSubType(a) ((a)->SubType == EFI_END_INSTANCE_DEVICE_PATH)\r
+                                             \r
+#define EfiIsDevicePathEnd(a)                (EfiIsDevicePathEndType (a) && EfiIsDevicePathEndSubType (a))\r
+#define IsDevicePathEnd(a)                   (EfiIsDevicePathEnd(a))\r
+#define EfiIsDevicePathEndInstance(a)        (EfiIsDevicePathEndType (a) && EfiIsDevicePathEndInstanceSubType (a))\r
+\r
+\r
+#define SetDevicePathNodeLength(a,l) {                           \\r
+          (a)->Length[0] = (UINT8) (l);                          \\r
+          (a)->Length[1] = (UINT8) ((l) >> 8);                   \\r
+          }\r
+\r
+#define SetDevicePathEndNode(a)  {                               \\r
+          (a)->Type = END_DEVICE_PATH_TYPE;                      \\r
+          (a)->SubType = END_ENTIRE_DEVICE_PATH_SUBTYPE;         \\r
+          (a)->Length[0] = sizeof(EFI_DEVICE_PATH_PROTOCOL);     \\r
+          (a)->Length[1] = 0;                                    \\r
+          }\r
+\r
+extern EFI_GUID gEfiDevicePathProtocolGuid;\r
+\r
+#endif\r
diff --git a/Tools/CodeTools/Source/Include/Protocol/GuidedSectionExtraction.h b/Tools/CodeTools/Source/Include/Protocol/GuidedSectionExtraction.h
new file mode 100644 (file)
index 0000000..d98c56a
--- /dev/null
@@ -0,0 +1,102 @@
+/** @file\r
+  This file declares GUIDed section extraction protocol.\r
+\r
+  This interface provides a means of decoding a GUID defined encapsulation \r
+  section. There may be multiple different GUIDs associated with the GUIDed\r
+  section extraction protocol. That is, all instances of the GUIDed section\r
+  extraction protocol must have the same interface structure.\r
+\r
+  Copyright (c) 2006, Intel Corporation                                                         \r
+  All rights reserved. This program and the accompanying materials                          \r
+  are licensed and made available under the terms and conditions of the BSD License         \r
+  which accompanies this distribution.  The full text of the license may be found at        \r
+  http://opensource.org/licenses/bsd-license.php                                            \r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+  Module Name:  GuidedSectionExtraction.h\r
+\r
+  @par Revision Reference:\r
+  This protocol is defined in Firmware Volume Specification.\r
+  Version 0.9\r
+\r
+**/\r
+\r
+#ifndef __GUIDED_SECTION_EXTRACTION_PROTOCOL_H__\r
+#define __GUIDED_SECTION_EXTRACTION_PROTOCOL_H__\r
+\r
+\r
+//\r
+// Protocol GUID definition. Each GUIDed section extraction protocol has the\r
+// same interface but with different GUID. All the GUIDs is defined here.\r
+// May add multiple GUIDs here.\r
+//\r
+#define EFI_CRC32_GUIDED_SECTION_EXTRACTION_PROTOCOL_GUID \\r
+  { \\r
+    0xFC1BCDB0, 0x7D31, 0x49aa, {0x93, 0x6A, 0xA4, 0x60, 0x0D, 0x9D, 0xD0, 0x83 } \\r
+  }\r
+\r
+//\r
+// Forward reference for pure ANSI compatability\r
+//\r
+typedef struct _EFI_GUIDED_SECTION_EXTRACTION_PROTOCOL  EFI_GUIDED_SECTION_EXTRACTION_PROTOCOL;\r
+\r
+//\r
+// Protocol member functions\r
+//\r
+/**\r
+  Processes the input section and returns the data contained therein along \r
+  with the authentication status.\r
+\r
+  @param  This                  Indicates the EFI_GUIDED_SECTION_EXTRACTION_PROTOCOL instance.  \r
+  @param  InputSection          Buffer containing the input GUIDed section to be processed.  \r
+  @param  OutputBuffer          *OutputBuffer is allocated from boot services pool memory \r
+                                and contains the new section stream.  \r
+  @param  OutputSize            A pointer to a caller-allocated UINTN in which the size \r
+                                of *OutputBuffer allocation is stored.   \r
+  @param  AuthenticationStatus  A pointer to a caller-allocated UINT32 that \r
+                                indicates the authentication status of the output buffer.\r
+                                \r
+  @retval EFI_SUCCESS           The InputSection was successfully processed and the \r
+                                section contents were returned.\r
+  @retval EFI_OUT_OF_RESOURCES  The system has insufficient resources to \r
+                                process the request.\r
+  @retval EFI_INVALID_PARAMETER The GUID in InputSection does not match \r
+                                this instance of the GUIDed Section Extraction Protocol.\r
+\r
+**/\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_EXTRACT_GUIDED_SECTION) (\r
+  IN  EFI_GUIDED_SECTION_EXTRACTION_PROTOCOL          *This,\r
+  IN  VOID                                            *InputSection,\r
+  OUT VOID                                            **OutputBuffer,\r
+  OUT UINTN                                           *OutputSize,\r
+  OUT UINT32                                          *AuthenticationStatus\r
+  );\r
+\r
+//\r
+// Protocol definition\r
+//\r
+/**\r
+  @par Protocol Description:\r
+  If a GUID-defined section is encountered when doing section extraction, \r
+  the section extraction driver calls the appropriate instance of the GUIDed \r
+  Section Extraction Protocol to extract the section stream contained therein.\r
+\r
+  @param ExtractSection\r
+  Takes the GUIDed section as input and produces the section stream data. \r
+\r
+**/\r
+struct _EFI_GUIDED_SECTION_EXTRACTION_PROTOCOL {\r
+  EFI_EXTRACT_GUIDED_SECTION  ExtractSection;\r
+};\r
+\r
+//\r
+// may add other GUID here\r
+//\r
+extern EFI_GUID gEfiCrc32GuidedSectionExtractionProtocolGuid;\r
+\r
+#endif\r
diff --git a/Tools/CodeTools/Source/Include/Protocol/Hii.h b/Tools/CodeTools/Source/Include/Protocol/Hii.h
new file mode 100644 (file)
index 0000000..ceeba1c
--- /dev/null
@@ -0,0 +1,1024 @@
+/** @file\r
+  This file defines the Human Interface Infrastructure protocol which will \r
+  be used by resources which want to publish IFR/Font/String data and have it \r
+  collected by the Configuration engine.\r
+\r
+  Copyright (c) 2006, Intel Corporation                                                         \r
+  All rights reserved. This program and the accompanying materials                          \r
+  are licensed and made available under the terms and conditions of the BSD License         \r
+  which accompanies this distribution.  The full text of the license may be found at        \r
+  http://opensource.org/licenses/bsd-license.php                                            \r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+  Module Name:  Hii.h\r
+\r
+  @par Revision Reference:\r
+  This protocol is defined in HII spec 0.92.\r
+\r
+**/\r
+\r
+#ifndef __HII_H__\r
+#define __HII_H__\r
+\r
+\r
+#define EFI_HII_PROTOCOL_GUID \\r
+  { \\r
+    0xea816d2c, 0xcee5, 0x4f02, {0x99, 0xb5, 0xd3, 0x90, 0x5c, 0xbb, 0xd0, 0x77 } \\r
+  }\r
+\r
+// BugBug:\r
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\r
+// If UGA goes away we need to put this some place. I'm not sure where?\r
+//\r
+//typedef struct {\r
+//  UINT8 Blue;\r
+//  UINT8 Green;\r
+//  UINT8 Red;\r
+//  UINT8 Reserved;\r
+//} EFI_UGA_PIXEL;\r
+\r
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\r
+//\r
+\r
+typedef struct _EFI_HII_PROTOCOL  EFI_HII_PROTOCOL;\r
+\r
+//\r
+// Global definition\r
+//\r
+#define NARROW_CHAR         0xFFF0\r
+#define WIDE_CHAR           0xFFF1\r
+#define NON_BREAKING_CHAR   0xFFF2\r
+#define GLYPH_WIDTH         8\r
+#define GLYPH_HEIGHT        19\r
+\r
+#define EFI_HII_FONT        1\r
+#define EFI_HII_STRING      2\r
+#define EFI_HII_IFR         3\r
+#define EFI_HII_KEYBOARD    4\r
+#define EFI_HII_HANDLES     5\r
+#define EFI_HII_VARIABLE    6\r
+#define EFI_HII_DEVICE_PATH 7\r
+\r
+\r
+// References to string tokens must use this macro to enable scanning for\r
+// token usages.\r
+//\r
+#define STRING_TOKEN(t) t\r
+\r
+//\r
+// The following types are currently defined:\r
+//\r
+typedef UINT16  EFI_FORM_ID;\r
+typedef UINT16  EFI_FORM_LABEL;\r
+\r
+#pragma pack(1)\r
+\r
+typedef struct {\r
+  UINT32  Length;\r
+  UINT16  Type;\r
+} EFI_HII_PACK_HEADER;\r
+\r
+//\r
+// A form list consists of a large variety of structure\r
+// possibilities so to represent the binary blob of data\r
+// associated with a package of forms, we will assume a\r
+// pointer to a self-describing data buffer.\r
+//\r
+typedef struct {\r
+  EFI_HII_PACK_HEADER Header;\r
+} EFI_HII_IFR_PACK;\r
+\r
+typedef struct {\r
+  EFI_HII_PACK_HEADER Header;           // Must be filled in\r
+  EFI_HANDLE          ImageHandle;      // Must be filled in\r
+  EFI_HANDLE          DeviceHandle;     // Optional\r
+  EFI_HANDLE          ControllerHandle; // Optional\r
+  EFI_HANDLE          CallbackHandle;   // Optional\r
+  EFI_HANDLE          COBExportHandle;  // Optional\r
+} EFI_HII_HANDLE_PACK;\r
+\r
+//\r
+// ********************************************************\r
+// EFI_VARIABLE_CONTENTS\r
+// ********************************************************\r
+//\r
+typedef struct {\r
+  EFI_HII_PACK_HEADER Header;\r
+  EFI_GUID            VariableGuid;\r
+  UINT32              VariableNameLength;\r
+  UINT16              VariableId;\r
+  //\r
+  //  CHAR16                VariableName[]; //Null-terminated\r
+  //\r
+} EFI_HII_VARIABLE_PACK;\r
+\r
+//\r
+// ********************************************************\r
+// EFI_DEVICE_PATH_PACK\r
+// ********************************************************\r
+//\r
+typedef struct {\r
+  EFI_HII_PACK_HEADER Header;\r
+  //\r
+  //  EFI_DEVICE_PATH       DevicePath[];\r
+  //\r
+} EFI_HII_DEVICE_PATH_PACK;\r
+\r
+//\r
+// ********************************************************\r
+// EFI_HII_DATA_TABLE\r
+// ********************************************************\r
+//\r
+typedef struct {\r
+  EFI_HII_HANDLE  HiiHandle;\r
+  EFI_GUID        PackageGuid;\r
+  UINT32          DataTableSize;\r
+  UINT32          IfrDataOffset;\r
+  UINT32          StringDataOffset;\r
+  UINT32          VariableDataOffset;\r
+  UINT32          DevicePathOffset;\r
+  UINT32          NumberOfVariableData;\r
+  UINT32          NumberOfLanguages;\r
+  //\r
+  // EFI_HII_DEVICE_PATH_PACK DevicePath[];\r
+  // EFI_HII_VARIABLE_PACK VariableData[];\r
+  // EFI_HII_IFR_PACK IfrData;\r
+  // EFI_HII_STRING_PACK StringData[];\r
+  //\r
+} EFI_HII_DATA_TABLE;\r
+\r
+//\r
+// ********************************************************\r
+// EFI_HII_EXPORT_TABLE\r
+// ********************************************************\r
+//\r
+typedef struct {\r
+  UINT32    NumberOfHiiDataTables;\r
+  EFI_GUID  Revision;\r
+  //\r
+  // EFI_HII_DATA_TABLE HiiDataTable[];\r
+  //\r
+} EFI_HII_EXPORT_TABLE;\r
+\r
+typedef struct {\r
+  BOOLEAN               FormSetUpdate;      // If TRUE, next variable is significant\r
+  EFI_PHYSICAL_ADDRESS  FormCallbackHandle; // If not 0, will update Formset with this info\r
+  BOOLEAN               FormUpdate;         // If TRUE, next variable is significant\r
+  UINT16                FormValue;          // specify which form is to be updated if FormUpdate value is TRUE.\r
+  STRING_REF            FormTitle;          // If not 0, will update Form with this info\r
+  UINT16                DataCount;          // The number of Data entries in this structure\r
+  UINT8                 *Data;              // An array of 1+ op-codes, specified by DataCount\r
+} EFI_HII_UPDATE_DATA;\r
+\r
+//\r
+// String attributes\r
+//\r
+#define LANG_RIGHT_TO_LEFT  0x00000001\r
+\r
+//\r
+// A string package is used to localize strings to a particular\r
+// language.  The package is associated with a particular driver\r
+// or set of drivers.  Tools are used to associate tokens with\r
+// string references in forms and in programs.  These tokens are\r
+// language agnostic.  When paired with a language pack (directly\r
+// or indirectly), the string token resolves into an actual\r
+// UNICODE string.  The NumStringPointers determines how many\r
+// StringPointers (offset values) there are as well as the total\r
+// number of Strings that are defined.\r
+//\r
+typedef struct {\r
+  EFI_HII_PACK_HEADER Header;\r
+  RELOFST             LanguageNameString;\r
+  RELOFST             PrintableLanguageName;\r
+  UINT32              NumStringPointers;\r
+  UINT32              Attributes;\r
+  //\r
+  //  RELOFST               StringPointers[];\r
+  //  EFI_STRING            Strings[];\r
+  //\r
+} EFI_HII_STRING_PACK;\r
+\r
+//\r
+// Glyph Attributes\r
+//\r
+#define EFI_GLYPH_NON_SPACING   1\r
+#define EFI_GLYPH_WIDE          2\r
+\r
+typedef struct {\r
+  CHAR16  UnicodeWeight;\r
+  UINT8   Attributes;\r
+  UINT8   GlyphCol1[GLYPH_HEIGHT];\r
+} EFI_NARROW_GLYPH;\r
+\r
+typedef struct {\r
+  CHAR16  UnicodeWeight;\r
+  UINT8   Attributes;\r
+  UINT8   GlyphCol1[GLYPH_HEIGHT];\r
+  UINT8   GlyphCol2[GLYPH_HEIGHT];\r
+  UINT8   Pad[3];\r
+} EFI_WIDE_GLYPH;\r
+\r
+//\r
+// A font list consists of a font header followed by a series\r
+// of glyph structures.  Note that fonts are not language specific.\r
+//\r
+typedef struct {\r
+  EFI_HII_PACK_HEADER Header;\r
+  UINT16              NumberOfNarrowGlyphs;\r
+  UINT16              NumberOfWideGlyphs;\r
+} EFI_HII_FONT_PACK;\r
+\r
+//\r
+// The IfrData in the EFI_HII_IFR_PACK structure definition\r
+// is variable length, and not really part of the header. To\r
+// simplify from code the size of the header, define an\r
+// identical structure that does not include the IfrData field.\r
+// Then use sizeof() this new structure to determine the\r
+// actual size of the header.\r
+//\r
+typedef struct {\r
+  EFI_HII_PACK_HEADER Header;\r
+} EFI_HII_IFR_PACK_HEADER;\r
+\r
+//\r
+// pedef EFI_HII_PACK_HEADER EFI_HII_IFR_PACK_HEADER;\r
+//\r
+typedef enum {\r
+  EfiKeyLCtrl,\r
+  EfiKeyA0,\r
+  EfiKeyLAlt,\r
+  EfiKeySpaceBar,\r
+  EfiKeyA2,\r
+  EfiKeyA3,\r
+  EfiKeyA4,\r
+  EfiKeyRCtrl,\r
+  EfiKeyLeftArrow,\r
+  EfiKeyDownArrow,\r
+  EfiKeyRightArrow,\r
+  EfiKeyZero,\r
+  EfiKeyPeriod,\r
+  EfiKeyEnter,\r
+  EfiKeyLShift,\r
+  EfiKeyB0,\r
+  EfiKeyB1,\r
+  EfiKeyB2,\r
+  EfiKeyB3,\r
+  EfiKeyB4,\r
+  EfiKeyB5,\r
+  EfiKeyB6,\r
+  EfiKeyB7,\r
+  EfiKeyB8,\r
+  EfiKeyB9,\r
+  EfiKeyB10,\r
+  EfiKeyRshift,\r
+  EfiKeyUpArrow,\r
+  EfiKeyOne,\r
+  EfiKeyTwo,\r
+  EfiKeyThree,\r
+  EfiKeyCapsLock,\r
+  EfiKeyC1,\r
+  EfiKeyC2,\r
+  EfiKeyC3,\r
+  EfiKeyC4,\r
+  EfiKeyC5,\r
+  EfiKeyC6,\r
+  EfiKeyC7,\r
+  EfiKeyC8,\r
+  EfiKeyC9,\r
+  EfiKeyC10,\r
+  EfiKeyC11,\r
+  EfiKeyC12,\r
+  EfiKeyFour,\r
+  EfiKeyFive,\r
+  EfiKeySix,\r
+  EfiKeyPlus,\r
+  EfiKeyTab,\r
+  EfiKeyD1,\r
+  EfiKeyD2,\r
+  EfiKeyD3,\r
+  EfiKeyD4,\r
+  EfiKeyD5,\r
+  EfiKeyD6,\r
+  EfiKeyD7,\r
+  EfiKeyD8,\r
+  EfiKeyD9,\r
+  EfiKeyD10,\r
+  EfiKeyD11,\r
+  EfiKeyD12,\r
+  EfiKeyD13,\r
+  EfiKeyDel,\r
+  EfiKeyEnd,\r
+  EfiKeyPgDn,\r
+  EfiKeySeven,\r
+  EfiKeyEight,\r
+  EfiKeyNine,\r
+  EfiKeyE0,\r
+  EfiKeyE1,\r
+  EfiKeyE2,\r
+  EfiKeyE3,\r
+  EfiKeyE4,\r
+  EfiKeyE5,\r
+  EfiKeyE6,\r
+  EfiKeyE7,\r
+  EfiKeyE8,\r
+  EfiKeyE9,\r
+  EfiKeyE10,\r
+  EfiKeyE11,\r
+  EfiKeyE12,\r
+  EfiKeyBackSpace,\r
+  EfiKeyIns,\r
+  EfiKeyHome,\r
+  EfiKeyPgUp,\r
+  EfiKeyNLck,\r
+  EfiKeySlash,\r
+  EfiKeyAsterisk,\r
+  EfiKeyMinus,\r
+  EfiKeyEsc,\r
+  EfiKeyF1,\r
+  EfiKeyF2,\r
+  EfiKeyF3,\r
+  EfiKeyF4,\r
+  EfiKeyF5,\r
+  EfiKeyF6,\r
+  EfiKeyF7,\r
+  EfiKeyF8,\r
+  EfiKeyF9,\r
+  EfiKeyF10,\r
+  EfiKeyF11,\r
+  EfiKeyF12,\r
+  EfiKeyPrint,\r
+  EfiKeySLck,\r
+  EfiKeyPause\r
+} EFI_KEY;\r
+\r
+typedef struct {\r
+  EFI_KEY Key;\r
+  CHAR16  Unicode;\r
+  CHAR16  ShiftedUnicode;\r
+  CHAR16  AltGrUnicode;\r
+  CHAR16  ShiftedAltGrUnicode;\r
+  UINT16  Modifier;\r
+} EFI_KEY_DESCRIPTOR;\r
+\r
+//\r
+// This structure allows a sparse set of keys to be redefined\r
+// or a complete redefinition of the keyboard layout.  Most\r
+// keyboards have a lot of commonality in their layouts, therefore\r
+// only defining those keys that need to change from the default\r
+// minimizes the passed in information.\r
+//\r
+// Additionally, when an update occurs, the active keyboard layout\r
+// will be switched to the newly updated keyboard layout.  This\r
+// allows for situations that when a keyboard layout driver is\r
+// loaded as part of system initialization, the system will default\r
+// the keyboard behavior to the new layout.\r
+//\r
+// Each call to update the keyboard mapping should contain the\r
+// complete set of key descriptors to be updated, since every\r
+// call to the HII which contains an EFI_HII_KEYBOARD_PACK will\r
+// wipe the previous set of overrides.  A call to\r
+//\r
+typedef struct {\r
+  EFI_HII_PACK_HEADER Header;\r
+  EFI_KEY_DESCRIPTOR  *Descriptor;\r
+  UINT8               DescriptorCount;\r
+} EFI_HII_KEYBOARD_PACK;\r
+\r
+//\r
+// The EFI_HII_PACKAGES can contain different types of packages just\r
+// after the structure as inline data.\r
+//\r
+typedef struct {\r
+  UINTN     NumberOfPackages;\r
+  EFI_GUID  *GuidId;\r
+  //\r
+  // EFI_HII_HANDLE_PACK    *HandlePack;        // Only one pack.\r
+  // EFI_HII_IFR_PACK       *IfrPack;           // Only one pack.\r
+  // EFI_HII_FONT_PACK      *FontPack[];        // Multiple packs ok\r
+  // EFI_HII_STRING_PACK    *StringPack[];      // Multiple packs ok\r
+  // EFI_HII_KEYBOARD_PACK  *KeyboardPack[];    // Multiple packs ok\r
+  //\r
+} EFI_HII_PACKAGES;\r
+\r
+typedef struct _EFI_HII_VARIABLE_PACK_LIST {\r
+  struct _EFI_HII_VARIABLE_PACK_LIST   *NextVariablePack;\r
+  EFI_HII_VARIABLE_PACK                *VariablePack;\r
+} EFI_HII_VARIABLE_PACK_LIST;\r
+\r
+#pragma pack()\r
+\r
+/**\r
+  Registers the various packs that are passed in via the Packages parameter. \r
+\r
+  @param  This A pointer to the EFI_HII_PROTOCOL instance.\r
+  \r
+  @param  Packages A pointer to an EFI_HII_PACKAGES package instance.\r
+  \r
+  @param  Handle A pointer to the EFI_HII_HANDLE instance.\r
+\r
+  @retval EFI_SUCCESS Data was extracted from Packages, the database \r
+  was updated with the data, and Handle returned successfully.\r
+  \r
+  @retval EFI_INVALID_PARAMETER The content of Packages  was invalid. \r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_HII_NEW_PACK) (\r
+  IN  EFI_HII_PROTOCOL    *This,\r
+  IN  EFI_HII_PACKAGES    *Packages,\r
+  OUT EFI_HII_HANDLE      *Handle\r
+  );\r
+\r
+/**\r
+  Removes a package from the HII database. \r
+\r
+  @param  This A pointer to the EFI_HII_PROTOCOL instance.\r
+  \r
+  @param  Handle The handle that was registered to the data that is requested \r
+  for removal. \r
+\r
+  @retval EFI_SUCCESS The data associated with the Handle was removed \r
+  from the HII database.\r
+  \r
+  @retval EFI_INVALID_PARAMETER The Handle was not valid. \r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_HII_REMOVE_PACK) (\r
+  IN EFI_HII_PROTOCOL    *This,\r
+  IN EFI_HII_HANDLE      Handle\r
+  );\r
+\r
+/**\r
+  Determines the handles that are currently active in the database.\r
+\r
+  @param  This A pointer to the EFI_HII_PROTOCOL instance.\r
+  \r
+  @param  HandleBufferLength On input, a pointer to the length of the handle \r
+  buffer. On output, the length of the handle buffer that is required \r
+  for the handles found.\r
+  \r
+  @param  Handle An array of EFI_HII_HANDLE instances returned.\r
+\r
+  @retval EFI_SUCCESS Handle was updated successfully.\r
+  \r
+  @retval EFI_BUFFER_TOO_SMALL The HandleBufferLength parameter indicates \r
+  that Handle is too small to support the number of handles.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_HII_FIND_HANDLES) (\r
+  IN     EFI_HII_PROTOCOL *This,\r
+  IN OUT UINT16           *HandleBufferLength,\r
+  OUT    EFI_HII_HANDLE   *Handle\r
+  );\r
+\r
+/**\r
+  Exports the contents of the database into a buffer.\r
+\r
+  @param  This A pointer to the EFI_HII_PROTOCOL instance.\r
+  \r
+  @param  Handle An EFI_HII_HANDLE that corresponds to the desired \r
+  handle to export. If the value is 0, the entire database will be exported.\r
+  In either case, the data will be exported in a format described by the \r
+  structure definition of EFI_HII_EXPORT_TABLE.\r
+  \r
+  @param  BufferSize\r
+  On input, a pointer to the length of the buffer. On output, the length \r
+  of the buffer that is required for the export data.\r
+  \r
+  @param  Buffer A pointer to a buffer that will contain the results of the export function.\r
+\r
+  @retval EFI_SUCCESS The buffer was successfully filled with BufferSize amount of data.\r
+  \r
+  @retval EFI_BUFFER_TOO_SMALL The value in BufferSize was too small to contain the export data.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_HII_EXPORT) (\r
+  IN     EFI_HII_PROTOCOL *This,\r
+  IN     EFI_HII_HANDLE   Handle,\r
+  IN OUT UINTN            *BufferSize,\r
+  OUT    VOID             *Buffer\r
+  );\r
+\r
+/**\r
+  Remove any new strings that were added after the initial string export \r
+  for this handle.\r
+\r
+  @param  This A pointer to the EFI_HII_PROTOCOL instance.\r
+  \r
+  @param  Handle The handle on which the string resides.\r
+\r
+  @retval EFI_SUCCESS Remove strings from the handle successfully.\r
+  \r
+  @retval EFI_INVALID_PARAMETER The Handle was unknown.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_HII_RESET_STRINGS) (\r
+  IN     EFI_HII_PROTOCOL   *This,\r
+  IN     EFI_HII_HANDLE     Handle\r
+  );\r
+\r
+/**\r
+  Tests if all of the characters in a string have corresponding font characters.\r
+\r
+  @param  This A pointer to the EFI_HII_PROTOCOL instance.\r
+  \r
+  @param  StringToTest A pointer to a Unicode string.\r
+  \r
+  @param  FirstMissing A pointer to an index into the string. On input, \r
+  the index of the first character in the StringToTest to examine. On exit, \r
+  the index of the first character encountered for which a glyph is unavailable.\r
+  If all glyphs in the string are available, the index is the index of the \r
+  terminator of the string.\r
+  \r
+  @param  GlyphBufferSize A pointer to a value. On output, if the function \r
+  returns EFI_SUCCESS, it contains the amount of memory that is required to \r
+  store the string¡¯s glyph equivalent.\r
+\r
+  @retval EFI_SUCCESS All glyphs are available. Note that an empty string \r
+  always returns this value.\r
+  \r
+  @retval EFI_NOT_FOUND A glyph was not found for a character.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_HII_TEST_STRING) (\r
+  IN     EFI_HII_PROTOCOL  *This,\r
+  IN     CHAR16            *StringToTest,\r
+  IN OUT UINT32            *FirstMissing,\r
+  OUT    UINT32            *GlyphBufferSize\r
+  );\r
+\r
+/**\r
+  Translates a Unicode character into the corresponding font glyph.\r
+\r
+  @param  This A pointer to the EFI_HII_PROTOCOL instance.\r
+  \r
+  @param  Source A pointer to a Unicode string.\r
+  \r
+  @param  Index On input, the offset into the string from which to fetch \r
+  the character.On successful completion, the index is updated to the first \r
+  character past the character(s) making up the just extracted glyph. \r
+  \r
+  @param  GlyphBuffer Pointer to an array where the glyphs corresponding \r
+  to the characters in the source may be stored. GlyphBuffer is assumed \r
+  to be wide enough to accept a wide glyph character.\r
+  \r
+  @param  BitWidth If EFI_SUCCESS was returned, the UINT16 pointed to by \r
+  this value is filled with the length of the glyph in pixels. It is unchanged \r
+  if the call was unsuccessful.\r
+  \r
+  @param  InternalStatus The cell pointed to by this parameter must be \r
+  initialized to zero prior to invoking the call the first time for any string.\r
+\r
+  @retval EFI_SUCCESS It worked.\r
+  \r
+  @retval EFI_NOT_FOUND A glyph for a character was not found.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_HII_GET_GLYPH) (\r
+  IN     EFI_HII_PROTOCOL  *This,\r
+  IN     CHAR16            *Source,\r
+  IN OUT UINT16            *Index,\r
+  OUT    UINT8             **GlyphBuffer,\r
+  OUT    UINT16            *BitWidth,\r
+  IN OUT UINT32            *InternalStatus\r
+  );\r
+\r
+/**\r
+  Translates a glyph into the format required for input to the Universal \r
+  Graphics Adapter (UGA) Block Transfer (BLT) routines.\r
+\r
+  @param  This A pointer to the EFI_HII_PROTOCOL instance.\r
+  \r
+  @param  GlyphBuffer A pointer to the buffer that contains glyph data.\r
+  \r
+  @param  Foreground The foreground setting requested to be used for the \r
+  generated BltBuffer data. \r
+  \r
+  @param  Background The background setting requested to be used for the \r
+  generated BltBuffer data.\r
+  \r
+  @param  Count The entry in the BltBuffer upon which to act.\r
+  \r
+  @param  Width The width in bits of the glyph being converted.\r
+  \r
+  @param  Height The height in bits of the glyph being converted\r
+  \r
+  @param  BltBuffer A pointer to the buffer that contains the data that is \r
+  ready to be used by the UGA BLT routines. \r
+\r
+  @retval EFI_SUCCESS It worked.\r
+  \r
+  @retval EFI_NOT_FOUND A glyph for a character was not found.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_HII_GLYPH_TO_BLT) (\r
+  IN     EFI_HII_PROTOCOL   *This,\r
+  IN     UINT8              *GlyphBuffer,\r
+  IN     EFI_UGA_PIXEL      Foreground,\r
+  IN     EFI_UGA_PIXEL      Background,\r
+  IN     UINTN              Count,\r
+  IN     UINTN              Width,\r
+  IN     UINTN              Height,\r
+  IN OUT EFI_UGA_PIXEL      *BltBuffer\r
+  );\r
+\r
+/**\r
+  Allows a new string to be added to an already existing string package.\r
+\r
+  @param  This A pointer to the EFI_HII_PROTOCOL instance.\r
+  \r
+  @param  Pointer to a NULL-terminated string containing a single ISO 639-2 \r
+  language identifier, indicating the language in which the string is translated. \r
+  \r
+  @param  Handle The handle of the language pack to which the string is to be added.\r
+  \r
+  @param  Reference The identifier of the string to be added. If the reference \r
+  value is zero, then the string will be assigned a new identifier on that \r
+  handle for the language specified. Otherwise, the string will be updated \r
+  with the NewString Value. \r
+  \r
+  @param  NewString The string to be added.\r
+\r
+  @retval EFI_SUCCESS The string was effectively registered.\r
+  \r
+  @retval EFI_INVALID_PARAMETER The Handle was unknown.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_HII_NEW_STRING) (\r
+  IN     EFI_HII_PROTOCOL      *This,\r
+  IN     CHAR16                *Language,\r
+  IN     EFI_HII_HANDLE        Handle,\r
+  IN OUT STRING_REF            *Reference,\r
+  IN     CHAR16                *NewString\r
+  );\r
+\r
+/**\r
+  Allows a program to determine the primary languages that are supported \r
+  on a given handle.\r
+\r
+  @param  This A pointer to the EFI_HII_PROTOCOL instance.\r
+  \r
+  @param  Handle The handle on which the strings reside.\r
+  \r
+  @param  LanguageString A string allocated by GetPrimaryLanguages() that \r
+  contains a list of all primary languages registered on the handle. \r
+\r
+  @retval EFI_SUCCESS LanguageString was correctly returned.\r
+  \r
+  @retval EFI_INVALID_PARAMETER The Handle was unknown.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_HII_GET_PRI_LANGUAGES) (\r
+  IN  EFI_HII_PROTOCOL    *This,\r
+  IN  EFI_HII_HANDLE      Handle,\r
+  OUT EFI_STRING          *LanguageString\r
+  );\r
+\r
+/**\r
+  Allows a program to determine which secondary languages are supported \r
+  on a given handle for a given primary language.\r
+\r
+  @param  This A pointer to the EFI_HII_PROTOCOL instance.\r
+  \r
+  @param  Handle The handle on which the strings reside.\r
+  \r
+  @param  PrimaryLanguage Pointer to a NULL-terminated string containing a single \r
+  ISO 639-2 language identifier, indicating the primary language.\r
+  \r
+  @param  LanguageString A string allocated by GetSecondaryLanguages() \r
+  containing a list of all secondary languages registered on the handle.\r
+\r
+  @retval EFI_SUCCESS LanguageString was correctly returned.\r
+  \r
+  @retval EFI_INVALID_PARAMETER The Handle was unknown.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_HII_GET_SEC_LANGUAGES) (\r
+  IN  EFI_HII_PROTOCOL    *This,\r
+  IN  EFI_HII_HANDLE      Handle,\r
+  IN  CHAR16              *PrimaryLanguage,\r
+  OUT EFI_STRING          *LanguageString\r
+  );\r
+\r
+/**\r
+  Extracts a string from a package already registered with the EFI HII database.\r
+\r
+  @param  This A pointer to the EFI_HII_PROTOCOL instance.\r
+  \r
+  @param  Handle The handle on which the string resides.\r
+  \r
+  @param  Token The string token assigned to the string.\r
+  \r
+  @param  Raw If TRUE, the string is returned unedited in the internal \r
+  storage format described above. If false, the string returned is edited \r
+  by replacing <cr> with <space> and by removing special characters such \r
+  as the <wide> prefix.\r
+  \r
+  @param  LanguageString Pointer to a NULL-terminated string containing a \r
+  single ISO 639-2 language identifier, indicating the language to print. \r
+  If the LanguageString is empty (starts with a NULL), the default system \r
+  language will be used to determine the language.\r
+  \r
+  @param  BufferLength Length of the StringBuffer.\r
+  \r
+  @param  StringBuffer The buffer designed to receive the characters in the string.\r
+\r
+  @retval EFI_SUCCESS StringBuffer is filled with a NULL-terminated string.\r
+  \r
+  @retval EFI_INVALID_PARAMETER The handle or string token is unknown.\r
+  \r
+  @retval EFI_BUFFER_TOO_SMALL The buffer provided was not large enough to \r
+  allow the entire string to be stored. \r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_HII_GET_STRING) (\r
+  IN     EFI_HII_PROTOCOL  *This,\r
+  IN     EFI_HII_HANDLE    Handle,\r
+  IN     STRING_REF        Token,\r
+  IN     BOOLEAN           Raw,\r
+  IN     CHAR16            *LanguageString,\r
+  IN OUT UINTN             *BufferLength,\r
+  OUT    EFI_STRING        StringBuffer\r
+  );\r
+\r
+/**\r
+  Allows a program to extract a part of a string of not more than a given width. \r
+\r
+  @param  This A pointer to the EFI_HII_PROTOCOL instance.\r
+  \r
+  @param  Handle The handle on which the string resides.\r
+  \r
+  @param  Token The string token assigned to the string. \r
+  \r
+  @param  Index On input, the offset into the string where the line is to start.\r
+  On output, the index is updated to point to beyond the last character returned \r
+  in the call.\r
+  \r
+  @param  LineWidth The maximum width of the line in units of narrow glyphs.\r
+  \r
+  @param  LanguageString Pointer to a NULL-terminated string containing a \r
+  single ISO 639-2 language identifier, indicating the language to print.\r
+  \r
+  @param  BufferLength Pointer to the length of the StringBuffer. \r
+  \r
+  @param  StringBuffer The buffer designed to receive the characters in the string. \r
+\r
+  @retval EFI_SUCCESS StringBuffer filled with characters that will fit on the line.\r
+  \r
+  @retval EFI_NOT_FOUND The font glyph for at least one of the characters in \r
+  the string is not in the font database.\r
+  \r
+  @retval EFI_BUFFER_TOO_SMALL The buffer provided was not large enough \r
+  to allow the entire string to be stored.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_HII_GET_LINE) (\r
+  IN     EFI_HII_PROTOCOL  *This,\r
+  IN     EFI_HII_HANDLE    Handle,\r
+  IN     STRING_REF        Token,\r
+  IN OUT UINT16            *Index,\r
+  IN     UINT16            LineWidth,\r
+  IN     CHAR16            *LanguageString,\r
+  IN OUT UINT16            *BufferLength,\r
+  OUT    EFI_STRING        StringBuffer\r
+  );\r
+\r
+/**\r
+  Allows a program to extract a form or form package that has previously \r
+  been registered with the HII database.\r
+\r
+  @param  This A pointer to the EFI_HII_PROTOCOL instance.\r
+  \r
+  @param  Handle Handle on which the form resides.\r
+  \r
+  @param  FormId The ID of the form to return. If the ID is zero, \r
+  the entire form package is returned. \r
+  \r
+  @param  BufferLength On input, the length of the Buffer. On output, \r
+  the length of the returned buffer, \r
+  \r
+  @param  Buffer The buffer designed to receive the form(s).\r
+\r
+  @retval EFI_SUCCESS Buffer filled with the requested forms. BufferLength \r
+  was updated.\r
+  \r
+  @retval EFI_INVALID_PARAMETER The handle is unknown.\r
+  \r
+  @retval EFI_NOT_FOUND A form on the requested handle cannot be found with \r
+  the requested FormId.\r
+  \r
+  @retval EFI_BUFFER_TOO_SMALL The buffer provided was not large enough \r
+  to allow the form to be stored. \r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_HII_GET_FORMS) (\r
+  IN     EFI_HII_PROTOCOL  *This,\r
+  IN     EFI_HII_HANDLE    Handle,\r
+  IN     EFI_FORM_ID       FormId,\r
+  IN OUT UINTN             *BufferLength,\r
+  OUT    UINT8             *Buffer\r
+  );\r
+\r
+/**\r
+  Extracts the defaults that are associated with a given handle in the HII database.\r
+\r
+  @param  This A pointer to the EFI_HII_PROTOCOL instance.\r
+  \r
+  @param  Handle The HII handle from which will have default data retrieved.\r
+  \r
+  @param  DefaultMask The mask used to specify some type of default override when extracting \r
+  the default image data.\r
+  \r
+  @param  VariablePackList A indirect pointer to the first entry of a link list with \r
+  type EFI_HII_VARIABLE_PACK_LIST. \r
+\r
+  @retval EFI_SUCCESS The VariablePackList was populated with the appropriate \r
+  default setting data.\r
+  \r
+  @retval EFI_NOT_FOUND The IFR does not have any explicit or default map(s).\r
+  \r
+  @retval EFI_INVALID_PARAMETER The HII database entry associated with Handle \r
+  contain invalid data.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_HII_GET_DEFAULT_IMAGE) (\r
+  IN     EFI_HII_PROTOCOL           *This,\r
+  IN     EFI_HII_HANDLE             Handle,\r
+  IN     UINTN                      DefaultMask,\r
+  OUT    EFI_HII_VARIABLE_PACK_LIST **VariablePackList\r
+  );\r
+\r
+/**\r
+  Allows the caller to update a form or form package that has previously been \r
+  registered with the EFI HII database.\r
+\r
+  @param  This A pointer to the EFI_HII_PROTOCOL instance.\r
+  \r
+  @param  Handle Handle of the package where the form to be updated resides.\r
+  \r
+  @param  Label The label inside the form package where the update is to take place.\r
+  \r
+  @param  AddData If TRUE, adding data at a given Label; otherwise, \r
+  if FALSE, removing data at a given Label.\r
+  \r
+  @param  Data The buffer containing the new tags to insert after the Label\r
+\r
+  @retval EFI_SUCCESS The form was updated with the new tags.\r
+  \r
+  @retval EFI_INVALID_PARAMETER The buffer for the buffer length does not \r
+  contain an integral number of tags.\r
+  \r
+  @retval EFI_NOT_FOUND The Handle, Label, or FormId was not found. \r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_HII_UPDATE_FORM) (\r
+  IN EFI_HII_PROTOCOL     *This,\r
+  IN EFI_HII_HANDLE       Handle,\r
+  IN EFI_FORM_LABEL       Label,\r
+  IN BOOLEAN              AddData,\r
+  IN EFI_HII_UPDATE_DATA  *Data\r
+  );\r
+\r
+/**\r
+  Retrieves the current keyboard layout. \r
+\r
+  @param  This A pointer to the EFI_HII_PROTOCOL instance.\r
+  \r
+  @param  DescriptorCount A pointer to the number of Descriptor entries being \r
+  described in the keyboard layout being retrieved.\r
+  \r
+  @param  Descriptor A pointer to a buffer containing an array of EFI_KEY_DESCRIPTOR \r
+  entries. Each entry will reflect the definition of a specific physical key.\r
+\r
+  @retval EFI_SUCCESS The keyboard layout was retrieved successfully.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_HII_GET_KEYBOARD_LAYOUT) (\r
+  IN     EFI_HII_PROTOCOL    *This,\r
+  OUT    UINT16              *DescriptorCount,\r
+  OUT    EFI_KEY_DESCRIPTOR  *Descriptor\r
+  );\r
+\r
+/**\r
+  @par Protocol Description:\r
+  The HII Protocol manages the HII database, which is a repository for data \r
+  having to do with fonts, strings, forms, keyboards, and other future human \r
+  interface items.\r
+\r
+  @param NewPack\r
+  Extracts the various packs from a package list.\r
+\r
+  @param RemovePack\r
+  Removes a package from the HII database.\r
+\r
+  @param FindHandles\r
+  Determines the handles that are currently active in the database.\r
+\r
+  @param ExportDatabase\r
+  Export the entire contents of the database to a buffer.\r
+\r
+  @param TestString\r
+  Tests if all of the characters in a string have corresponding font characters.\r
+\r
+  @param GetGlyph\r
+  Translates a Unicode character into the corresponding font glyph. \r
+\r
+  @param GlyphToBlt\r
+  Converts a glyph value into a format that is ready for a UGA BLT command. \r
+\r
+  @param NewString\r
+  Allows a new string to be added to an already existing string package.\r
+\r
+  @param GetPrimaryLanguages\r
+  Allows a program to determine the primary languages that are supported \r
+  on a given handle. \r
+\r
+  @param GetSecondaryLanguages\r
+  Allows a program to determine which secondary languages are supported \r
+  on a given handle for a given primary language.\r
+\r
+  @param GetString\r
+  Extracts a string from a package that is already registered with the \r
+  EFI HII database. \r
+\r
+  @param ResetString\r
+  Remove any new strings that were added after the initial string export \r
+  for this handle.\r
+\r
+  @param GetLine\r
+  Allows a program to extract a part of a string of not more than a given width.\r
+\r
+  @param GetForms\r
+  Allows a program to extract a form or form package that has been previously registered.\r
+\r
+  @param GetDefaultImage\r
+  Allows a program to extract the nonvolatile image that represents the default storage image. \r
+\r
+  @param UpdateForm\r
+  Allows a program to update a previously registered form. \r
+\r
+  @param GetKeyboardLayout\r
+  Allows a program to extract the current keyboard layout.\r
+\r
+**/\r
+struct _EFI_HII_PROTOCOL {\r
+  EFI_HII_NEW_PACK            NewPack;\r
+  EFI_HII_REMOVE_PACK         RemovePack;\r
+  EFI_HII_FIND_HANDLES        FindHandles;\r
+  EFI_HII_EXPORT              ExportDatabase;\r
+\r
+  EFI_HII_TEST_STRING         TestString;\r
+  EFI_HII_GET_GLYPH           GetGlyph;\r
+  EFI_HII_GLYPH_TO_BLT        GlyphToBlt;\r
+\r
+  EFI_HII_NEW_STRING          NewString;\r
+  EFI_HII_GET_PRI_LANGUAGES   GetPrimaryLanguages;\r
+  EFI_HII_GET_SEC_LANGUAGES   GetSecondaryLanguages;\r
+  EFI_HII_GET_STRING          GetString;\r
+  EFI_HII_RESET_STRINGS       ResetStrings;\r
+  EFI_HII_GET_LINE            GetLine;\r
+  EFI_HII_GET_FORMS           GetForms;\r
+  EFI_HII_GET_DEFAULT_IMAGE   GetDefaultImage;\r
+  EFI_HII_UPDATE_FORM         UpdateForm;\r
+\r
+  EFI_HII_GET_KEYBOARD_LAYOUT GetKeyboardLayout;\r
+};\r
+\r
+extern EFI_GUID gEfiHiiProtocolGuid;\r
+\r
+#endif\r
diff --git a/Tools/CodeTools/Source/Include/Protocol/UgaDraw.h b/Tools/CodeTools/Source/Include/Protocol/UgaDraw.h
new file mode 100644 (file)
index 0000000..5586bdf
--- /dev/null
@@ -0,0 +1,168 @@
+/** @file\r
+  UGA Draw protocol from the EFI 1.1 specification.\r
+\r
+  Abstraction of a very simple graphics device.\r
+\r
+  Copyright (c) 2006, Intel Corporation                                                         \r
+  All rights reserved. This program and the accompanying materials                          \r
+  are licensed and made available under the terms and conditions of the BSD License         \r
+  which accompanies this distribution.  The full text of the license may be found at        \r
+  http://opensource.org/licenses/bsd-license.php                                            \r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+  Module Name:  UgaDraw.h\r
+\r
+**/\r
+\r
+#ifndef __UGA_DRAW_H__\r
+#define __UGA_DRAW_H__\r
+\r
+#define EFI_UGA_DRAW_PROTOCOL_GUID \\r
+  { \\r
+    0x982c298b, 0xf4fa, 0x41cb, {0xb8, 0x38, 0x77, 0xaa, 0x68, 0x8f, 0xb8, 0x39 } \\r
+  }\r
+\r
+typedef struct _EFI_UGA_DRAW_PROTOCOL EFI_UGA_DRAW_PROTOCOL;\r
+\r
+/**\r
+  Return the current video mode information.\r
+\r
+  @param  This                  Protocol instance pointer.\r
+  @param  HorizontalResolution  Current video horizontal resolution in pixels\r
+  @param  VerticalResolution    Current video vertical resolution in pixels\r
+  @param  ColorDepth            Current video color depth in bits per pixel\r
+  @param  RefreshRate           Current video refresh rate in Hz.\r
+\r
+  @retval EFI_SUCCESS           Mode information returned.\r
+  @retval EFI_NOT_STARTED       Video display is not initialized. Call SetMode ()\r
+  @retval EFI_INVALID_PARAMETER One of the input args was NULL.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_UGA_DRAW_PROTOCOL_GET_MODE) (\r
+  IN  EFI_UGA_DRAW_PROTOCOL *This,\r
+  OUT UINT32                *HorizontalResolution,\r
+  OUT UINT32                *VerticalResolution,\r
+  OUT UINT32                *ColorDepth,\r
+  OUT UINT32                *RefreshRate\r
+  )\r
+;\r
+\r
+/**\r
+  Return the current video mode information.\r
+\r
+  @param  This                 Protocol instance pointer.\r
+  @param  HorizontalResolution Current video horizontal resolution in pixels\r
+  @param  VerticalResolution   Current video vertical resolution in pixels\r
+  @param  ColorDepth           Current video color depth in bits per pixel\r
+  @param  RefreshRate          Current video refresh rate in Hz.\r
+\r
+  @retval EFI_SUCCESS          Mode information returned.\r
+  @retval EFI_NOT_STARTED      Video display is not initialized. Call SetMode ()\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_UGA_DRAW_PROTOCOL_SET_MODE) (\r
+  IN  EFI_UGA_DRAW_PROTOCOL *This,\r
+  IN  UINT32                HorizontalResolution,\r
+  IN  UINT32                VerticalResolution,\r
+  IN  UINT32                ColorDepth,\r
+  IN  UINT32                RefreshRate\r
+  )\r
+;\r
+\r
+typedef struct {\r
+  UINT8 Blue;\r
+  UINT8 Green;\r
+  UINT8 Red;\r
+  UINT8 Reserved;\r
+} EFI_UGA_PIXEL;\r
+\r
+typedef union {\r
+  EFI_UGA_PIXEL Pixel;\r
+  UINT32        Raw;\r
+} EFI_UGA_PIXEL_UNION;\r
+\r
+typedef enum {\r
+  EfiUgaVideoFill,\r
+  EfiUgaVideoToBltBuffer,\r
+  EfiUgaBltBufferToVideo,\r
+  EfiUgaVideoToVideo,\r
+  EfiUgaBltMax\r
+} EFI_UGA_BLT_OPERATION;\r
+\r
+/**\r
+  Type specifying a pointer to a function to perform an UGA Blt operation.\r
+\r
+    The following table defines actions for BltOperations:\r
+\r
+    <B>EfiUgaVideoFill</B> - Write data from the  BltBuffer pixel (SourceX, SourceY) \r
+      directly to every pixel of the video display rectangle \r
+      (DestinationX, DestinationY) (DestinationX + Width, DestinationY + Height). \r
+      Only one pixel will be used from the BltBuffer. Delta is NOT used.\r
+\r
+    <B>EfiUgaVideoToBltBuffer</B> - Read data from the video display rectangle \r
+      (SourceX, SourceY) (SourceX + Width, SourceY + Height) and place it in \r
+      the BltBuffer rectangle (DestinationX, DestinationY ) \r
+      (DestinationX + Width, DestinationY + Height). If DestinationX or \r
+      DestinationY is not zero then Delta must be set to the length in bytes \r
+      of a row in the BltBuffer.\r
+\r
+    <B>EfiUgaBltBufferToVideo</B> - Write data from the  BltBuffer rectangle \r
+      (SourceX, SourceY) (SourceX + Width, SourceY + Height) directly to the \r
+      video display rectangle (DestinationX, DestinationY) \r
+      (DestinationX + Width, DestinationY + Height). If SourceX or SourceY is \r
+      not zero then Delta must be set to the length in bytes of a row in the \r
+      BltBuffer.\r
+\r
+    <B>EfiUgaVideoToVideo</B> - Copy from the video display rectangle (SourceX, SourceY)\r
+     (SourceX + Width, SourceY + Height) .to the video display rectangle \r
+     (DestinationX, DestinationY) (DestinationX + Width, DestinationY + Height). \r
+     The BltBuffer and Delta  are not used in this mode.\r
+\r
+\r
+    @param[in] This          - Protocol instance pointer.\r
+    @param[in] BltBuffer     - Buffer containing data to blit into video buffer. This \r
+                               buffer has a size of Width*Height*sizeof(EFI_UGA_PIXEL)\r
+    @param[in] BltOperation  - Operation to perform on BlitBuffer and video memory\r
+    @param[in] SourceX       - X coordinate of source for the BltBuffer.\r
+    @param[in] SourceY       - Y coordinate of source for the BltBuffer.\r
+    @param[in] DestinationX  - X coordinate of destination for the BltBuffer.\r
+    @param[in] DestinationY  - Y coordinate of destination for the BltBuffer.\r
+    @param[in] Width         - Width of rectangle in BltBuffer in pixels.\r
+    @param[in] Height        - Hight of rectangle in BltBuffer in pixels.\r
+    @param[in] Delta         - OPTIONAL\r
+  \r
+    @retval EFI_SUCCESS           - The Blt operation completed.\r
+    @retval EFI_INVALID_PARAMETER - BltOperation is not valid.\r
+    @retval EFI_DEVICE_ERROR      - A hardware error occured writting to the video buffer.\r
+\r
+--*/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_UGA_DRAW_PROTOCOL_BLT) (\r
+  IN  EFI_UGA_DRAW_PROTOCOL                   * This,\r
+  IN  EFI_UGA_PIXEL                           * BltBuffer, OPTIONAL\r
+  IN  EFI_UGA_BLT_OPERATION                   BltOperation,\r
+  IN  UINTN                                   SourceX,\r
+  IN  UINTN                                   SourceY,\r
+  IN  UINTN                                   DestinationX,\r
+  IN  UINTN                                   DestinationY,\r
+  IN  UINTN                                   Width,\r
+  IN  UINTN                                   Height,\r
+  IN  UINTN                                   Delta         OPTIONAL\r
+  );\r
+\r
+struct _EFI_UGA_DRAW_PROTOCOL {\r
+  EFI_UGA_DRAW_PROTOCOL_GET_MODE  GetMode;\r
+  EFI_UGA_DRAW_PROTOCOL_SET_MODE  SetMode;\r
+  EFI_UGA_DRAW_PROTOCOL_BLT       Blt;\r
+};\r
+\r
+extern EFI_GUID gEfiUgaDrawProtocolGuid;\r
+\r
+#endif\r
diff --git a/Tools/CodeTools/Source/Include/X64/ProcessorBind.h b/Tools/CodeTools/Source/Include/X64/ProcessorBind.h
new file mode 100644 (file)
index 0000000..f865ce8
--- /dev/null
@@ -0,0 +1,193 @@
+/** @file\r
+  Processor or Compiler specific defines and types x64 (Intel(r) EM64T, AMD64).\r
+\r
+  Copyright (c) 2006, Intel Corporation                                                         \r
+  All rights reserved. This program and the accompanying materials                          \r
+  are licensed and made available under the terms and conditions of the BSD License         \r
+  which accompanies this distribution.  The full text of the license may be found at        \r
+  http://opensource.org/licenses/bsd-license.php                                            \r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+  Module Name:  ProcessorBind.h\r
+\r
+**/\r
+\r
+#ifndef __PROCESSOR_BIND_H__\r
+#define __PROCESSOR_BIND_H__\r
+\r
+//\r
+// Define the processor type so other code can make processor based choices\r
+//\r
+#define MDE_CPU_X64\r
+\r
+\r
+//\r
+// Make sure we are useing the correct packing rules per EFI specification\r
+//\r
+#pragma pack()\r
+\r
+\r
+#if _MSC_EXTENSIONS \r
+    \r
+//\r
+// Disable warning that make it impossible to compile at /W4\r
+// This only works for Microsoft* tools\r
+//\r
+\r
+//\r
+// Disabling bitfield type checking warnings.\r
+//\r
+#pragma warning ( disable : 4214 )\r
+\r
+//\r
+// Disabling the unreferenced formal parameter warnings.\r
+//\r
+#pragma warning ( disable : 4100 )\r
+\r
+//\r
+// Disable slightly different base types warning as CHAR8 * can not be set\r
+// to a constant string.\r
+//\r
+#pragma warning ( disable : 4057 )\r
+\r
+//\r
+// ASSERT(FALSE) or while (TRUE) are legal constructes so supress this warning\r
+//\r
+#pragma warning ( disable : 4127 )\r
+\r
+\r
+#endif\r
+\r
+\r
+#if (__STDC_VERSION__ < 199901L)\r
+  //\r
+  // No ANSI C 2000 stdint.h integer width declarations, so define equivalents\r
+  //\r
\r
+  #if _MSC_EXTENSIONS \r
+    \r
+\r
+    //\r
+    // use Microsoft C complier dependent interger width types \r
+    //\r
+    typedef unsigned __int64    UINT64;\r
+    typedef __int64             INT64;\r
+    typedef unsigned __int32    UINT32;\r
+    typedef __int32             INT32;\r
+    typedef unsigned short      UINT16;\r
+    typedef unsigned short      CHAR16;\r
+    typedef short               INT16;\r
+    typedef unsigned char       BOOLEAN;\r
+    typedef unsigned char       UINT8;\r
+    typedef char                CHAR8;\r
+    typedef char                INT8;\r
+  #else\r
+    #ifdef _EFI_P64 \r
+      //\r
+      // P64 - is Intel Itanium(TM) speak for pointers being 64-bit and longs and ints \r
+      //  are 32-bits\r
+      //\r
+      typedef unsigned long long  UINT64;\r
+      typedef long long           INT64;\r
+      typedef unsigned int        UINT32;\r
+      typedef int                 INT32;\r
+      typedef unsigned short      CHAR16;\r
+      typedef unsigned short      UINT16;\r
+      typedef short               INT16;\r
+      typedef unsigned char       BOOLEAN;\r
+      typedef unsigned char       UINT8;\r
+      typedef char                CHAR8;\r
+      typedef char                INT8;\r
+    #else\r
+      //\r
+      // Assume LP64 - longs and pointers are 64-bit. Ints are 32-bit.\r
+      //\r
+      typedef unsigned long   UINT64;\r
+      typedef long            INT64;\r
+      typedef unsigned int    UINT32;\r
+      typedef int             INT32;\r
+      typedef unsigned short  UINT16;\r
+      typedef unsigned short  CHAR16;\r
+      typedef short           INT16;\r
+      typedef unsigned char   BOOLEAN;\r
+      typedef unsigned char   UINT8;\r
+      typedef char            CHAR8;\r
+      typedef char            INT8;\r
+    #endif\r
+  #endif\r
+\r
+  #define UINT8_MAX 0xff\r
+\r
+#else\r
+  //\r
+  // Use ANSI C 2000 stdint.h integer width declarations\r
+  //\r
+  #include <stdint.h>\r
+  typedef uint8_t   BOOLEAN;\r
+  typedef int8_t    INT8;\r
+  typedef uint8_t   UINT8;\r
+  typedef int16_t   INT16;\r
+  typedef uint16_t  UINT16;\r
+  typedef int32_t   INT32;\r
+  typedef uint32_t  UINT32;\r
+  typedef int64_t   INT64;\r
+  typedef uint64_t  UINT64;\r
+  typedef char      CHAR8;\r
+  typedef uint16_t  CHAR16;\r
+\r
+#endif\r
+\r
+typedef UINT64  UINTN;\r
+typedef INT64   INTN;\r
+\r
+\r
+//\r
+// Processor specific defines\r
+//\r
+#define MAX_BIT     0x8000000000000000\r
+#define MAX_2_BITS  0xC000000000000000\r
+\r
+//\r
+// Maximum legal Itanium-based address\r
+//\r
+#define MAX_ADDRESS   0xFFFFFFFFFFFFFFFF\r
+\r
+//\r
+// Modifier to ensure that all protocol member functions and EFI intrinsics\r
+// use the correct C calling convention. All protocol member functions and\r
+// EFI intrinsics are required to modify thier member functions with EFIAPI.\r
+//\r
+#if _MSC_EXTENSIONS \r
+  ///\r
+  /// Define the standard calling convention reguardless of optimization level.\r
+  /// __cdecl is Microsoft* specific C extension.\r
+  /// \r
+  #define EFIAPI __cdecl  \r
+#elif __GNUC__\r
+  ///\r
+  /// Define the standard calling convention reguardless of optimization level.\r
+  /// efidecl is an extension to GCC that supports the differnece between x64\r
+  /// GCC ABI and x64 Microsoft* ABI. EFI is closer to the Microsoft* ABI and\r
+  /// EFIAPI makes sure the right ABI is used for public interfaces. \r
+  /// eficecl is a work in progress and we do not yet have the compiler\r
+  ///\r
+  #define EFIAPI \r
+#else\r
+  #define EFIAPI       \r
+#endif\r
+\r
+//\r
+// The Microsoft* C compiler can removed references to unreferenced data items\r
+//  if the /OPT:REF linker option is used. We defined a macro as this is a \r
+//  a non standard extension\r
+//\r
+#if _MSC_EXTENSIONS\r
+  #define GLOBAL_REMOVE_IF_UNREFERENCED __declspec(selectany)\r
+#else\r
+  #define GLOBAL_REMOVE_IF_UNREFERENCED\r
+#endif\r
+\r
+#endif\r
+\r
diff --git a/Tools/CodeTools/Source/MakeDeps/MakeDeps.c b/Tools/CodeTools/Source/MakeDeps/MakeDeps.c
new file mode 100755 (executable)
index 0000000..3943df0
--- /dev/null
@@ -0,0 +1,1284 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  MakeDeps.c  \r
+\r
+Abstract:\r
+\r
+  Recursively scan source files to find include files and emit them to \r
+  create dependency lists.\r
+\r
+--*/\r
+\r
+#include <stdio.h>\r
+#include <string.h>\r
+#include <stdlib.h>\r
+#include <ctype.h>\r
+\r
+#include <Common/UefiBaseTypes.h>\r
+\r
+#include "EfiUtilityMsgs.h"\r
+#include "CommonLib.h"\r
+\r
+//\r
+// Structure to maintain a linked list of strings\r
+//\r
+typedef struct _STRING_LIST {\r
+  struct _STRING_LIST *Next;\r
+  char                *Str;\r
+} STRING_LIST;\r
+\r
+#define UTILITY_NAME      "MakeDeps"\r
+\r
+#define MAX_LINE_LEN      2048\r
+#define MAX_PATH          2048\r
+#define START_NEST_DEPTH  1\r
+#define MAX_NEST_DEPTH    1000  // just in case we get in an endless loop.\r
+//\r
+// Define the relative paths used by the special #include macros\r
+//\r
+#define PROTOCOL_DIR_PATH       "Protocol/"\r
+#define GUID_DIR_PATH           "Guid/"\r
+#define ARCH_PROTOCOL_DIR_PATH  "ArchProtocol/"\r
+#define PPI_PROTOCOL_DIR_PATH   "Ppi/"\r
+\r
+//\r
+// Use this structure to keep track of all the special #include forms\r
+//\r
+typedef struct {\r
+  INT8  *IncludeMacroName;\r
+  INT8  *PathName;\r
+} INCLUDE_MACRO_CONVERSION;\r
+\r
+//\r
+// This data is used to convert #include macros like:\r
+//    #include EFI_PROTOCOL_DEFINITION(xxx)\r
+// into\r
+//    #include Protocol/xxx/xxx.h\r
+//\r
+static const INCLUDE_MACRO_CONVERSION mMacroConversion[] = {\r
+  "EFI_PROTOCOL_DEFINITION",\r
+  PROTOCOL_DIR_PATH,\r
+  "EFI_GUID_DEFINITION",\r
+  GUID_DIR_PATH,\r
+  "EFI_ARCH_PROTOCOL_DEFINITION",\r
+  ARCH_PROTOCOL_DIR_PATH,\r
+  "EFI_PROTOCOL_PRODUCER",\r
+  PROTOCOL_DIR_PATH,\r
+  "EFI_PROTOCOL_CONSUMER",\r
+  PROTOCOL_DIR_PATH,\r
+  "EFI_PROTOCOL_DEPENDENCY",\r
+  PROTOCOL_DIR_PATH,\r
+  "EFI_ARCH_PROTOCOL_PRODUCER",\r
+  ARCH_PROTOCOL_DIR_PATH,\r
+  "EFI_ARCH_PROTOCOL_CONSUMER",\r
+  ARCH_PROTOCOL_DIR_PATH,\r
+  "EFI_ARCH_PROTOCOL_DEPENDENCY",\r
+  ARCH_PROTOCOL_DIR_PATH,\r
+  "EFI_PPI_DEFINITION",\r
+  PPI_PROTOCOL_DIR_PATH,\r
+  "EFI_PPI_PRODUCER",\r
+  PPI_PROTOCOL_DIR_PATH,\r
+  "EFI_PPI_CONSUMER",\r
+  PPI_PROTOCOL_DIR_PATH,\r
+  "EFI_PPI_DEPENDENCY",\r
+  PPI_PROTOCOL_DIR_PATH,\r
+  NULL,\r
+  NULL\r
+};\r
+\r
+typedef struct _SYMBOL {\r
+  struct _SYMBOL  *Next;\r
+  INT8            *Name;\r
+  INT8            *Value;\r
+} SYMBOL;\r
+\r
+//\r
+// Here's all our globals. We need a linked list of include paths, a linked\r
+// list of source files, a linked list of subdirectories (appended to each\r
+// include path when searching), and flags to keep track of command-line options.\r
+//\r
+static struct {\r
+  STRING_LIST *IncludePaths;            // all include paths to search\r
+  STRING_LIST *SourceFiles;             // all source files to parse\r
+  STRING_LIST *SubDirs;                 // appended to each include path when searching\r
+  SYMBOL      *SymbolTable;             // for replacement strings\r
+  FILE        *OutFptr;                 // output dependencies to this file\r
+  BOOLEAN     Verbose;                  // for more detailed output\r
+  BOOLEAN     IgnoreNotFound;           // no warnings if files not found\r
+  BOOLEAN     QuietMode;                // -q - don't print missing file warnings\r
+  BOOLEAN     NoSystem;                 // don't process #include <system> files\r
+  BOOLEAN     NeverFail;                // always return success\r
+  BOOLEAN     NoDupes;                  // to not list duplicate dependency files (for timing purposes)\r
+  BOOLEAN     UseSumDeps;               // use summary dependency files if found\r
+  INT8        TargetFileName[MAX_PATH]; // target object filename\r
+  INT8        SumDepsPath[MAX_PATH];    // path to summary files\r
+  INT8        *OutFileName;             // -o option\r
+} mGlobals;\r
+\r
+static\r
+STATUS\r
+ProcessFile (\r
+  INT8            *TargetFileName,\r
+  INT8            *FileName,\r
+  UINT32          NestDepth,\r
+  STRING_LIST     *ProcessedFiles\r
+  );\r
+\r
+static\r
+FILE  *\r
+FindFile (\r
+  INT8    *FileName,\r
+  UINT32  FileNameLen\r
+  );\r
+\r
+static\r
+void\r
+PrintDependency (\r
+  INT8    *Target,\r
+  INT8    *DependentFile\r
+  );\r
+\r
+static\r
+void\r
+ReplaceSymbols (\r
+  INT8    *Str,\r
+  UINT32  StrSize\r
+  );\r
+\r
+static\r
+STATUS\r
+ProcessArgs (\r
+  int   Argc,\r
+  char  *Argv[]\r
+  );\r
+\r
+static\r
+void\r
+Usage (\r
+  VOID\r
+  );\r
+\r
+static\r
+void\r
+FreeLists (\r
+  VOID\r
+  );\r
+\r
+int\r
+main (\r
+  int   Argc,\r
+  char  *Argv[]\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Call the routine to parse the command-line options, then process each file\r
+  to build dependencies.\r
+  \r
+Arguments:\r
+\r
+  Argc - Standard C main() argc.\r
+  Argv - Standard C main() argv.\r
+\r
+Returns:\r
+\r
+  0       if successful\r
+  nonzero otherwise\r
+  \r
+--*/\r
+{\r
+  STRING_LIST *File;\r
+  STRING_LIST ProcessedFiles;\r
+  STRING_LIST *TempList;\r
+  STATUS      Status;\r
+  INT8        *Cptr;\r
+  INT8        TargetFileName[MAX_PATH];\r
+\r
+  SetUtilityName (UTILITY_NAME);\r
+  //\r
+  // Process the command-line arguments\r
+  //\r
+  Status = ProcessArgs (Argc, Argv);\r
+  if (Status != STATUS_SUCCESS) {\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Go through the list of source files and process each.\r
+  //\r
+  memset (&ProcessedFiles, 0, sizeof (STRING_LIST));\r
+  File = mGlobals.SourceFiles;\r
+  while (File != NULL) {\r
+    //\r
+    // Clear out our list of processed files\r
+    //\r
+    TempList = ProcessedFiles.Next;\r
+    while (ProcessedFiles.Next != NULL) {\r
+      TempList = ProcessedFiles.Next->Next;\r
+      free (ProcessedFiles.Next->Str);\r
+      free (ProcessedFiles.Next);\r
+      ProcessedFiles.Next = TempList;\r
+    }\r
+    //\r
+    // Replace filename extension with ".obj" if they did not\r
+    // specifically specify the target file\r
+    //\r
+    if (mGlobals.TargetFileName[0] == 0) {\r
+      strcpy (TargetFileName, File->Str);\r
+      //\r
+      // Find the .extension\r
+      //\r
+      for (Cptr = TargetFileName + strlen (TargetFileName) - 1;\r
+           (*Cptr != '\\' && *Cptr != '/') && (Cptr > TargetFileName) && (*Cptr != '.');\r
+           Cptr--\r
+          )\r
+        ;\r
+      if (Cptr == TargetFileName) {\r
+        Error (NULL, 0, 0, File->Str, "could not locate extension in filename");\r
+        goto Finish;\r
+      }\r
+      //\r
+      // Tack on the ".obj"\r
+      //\r
+      strcpy (Cptr, ".obj");\r
+    } else {\r
+      //\r
+      // Copy the target filename they specified\r
+      //\r
+      strcpy (TargetFileName, mGlobals.TargetFileName);\r
+    }\r
+\r
+    Status = ProcessFile (TargetFileName, File->Str, START_NEST_DEPTH, &ProcessedFiles);\r
+    if (Status != STATUS_SUCCESS) {\r
+      goto Finish;\r
+    }\r
+\r
+    File = File->Next;\r
+  }\r
+\r
+Finish:\r
+  //\r
+  // Free up memory\r
+  //\r
+  FreeLists ();\r
+  //\r
+  // Free up our processed files list\r
+  //\r
+  TempList = ProcessedFiles.Next;\r
+  while (ProcessedFiles.Next != NULL) {\r
+    TempList = ProcessedFiles.Next->Next;\r
+    free (ProcessedFiles.Next->Str);\r
+    free (ProcessedFiles.Next);\r
+    ProcessedFiles.Next = TempList;\r
+  }\r
+  //\r
+  // Close our output file\r
+  //\r
+  if ((mGlobals.OutFptr != stdout) && (mGlobals.OutFptr != NULL)) {\r
+    fprintf(mGlobals.OutFptr, "\t\n");  // file ending flag\r
+    fclose (mGlobals.OutFptr);\r
+  }\r
+\r
+  if (mGlobals.NeverFail) {\r
+    return STATUS_SUCCESS;\r
+  }\r
+  //\r
+  // If any errors, then delete our output so that it will get created\r
+  // again on a rebuild.\r
+  //\r
+  if ((GetUtilityStatus () == STATUS_ERROR) && (mGlobals.OutFileName != NULL)) {\r
+    remove (mGlobals.OutFileName);\r
+  }\r
+\r
+  return GetUtilityStatus ();\r
+}\r
+\r
+static\r
+STATUS\r
+ProcessFile (\r
+  INT8            *TargetFileName,\r
+  INT8            *FileName,\r
+  UINT32          NestDepth,\r
+  STRING_LIST     *ProcessedFiles\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Given a source file name, open the file and parse all #include lines.\r
+  \r
+Arguments:\r
+\r
+  TargetFileName - name of the usually .obj target\r
+  FileName       - name of the file to process\r
+  NestDepth      - how deep we're nested in includes\r
+  ProcessedFiles - list of processed files.\r
+\r
+Returns:\r
+\r
+  standard status.\r
+  \r
+--*/\r
+{\r
+  FILE        *Fptr;\r
+  INT8        Line[MAX_LINE_LEN];\r
+  INT8        *Cptr;\r
+  INT8        *EndPtr;\r
+  INT8        *SaveCptr;\r
+  INT8        EndChar;\r
+  INT8        FileNameCopy[MAX_PATH];\r
+  INT8        MacroIncludeFileName[MAX_LINE_LEN];\r
+  INT8        SumDepsFile[MAX_PATH];\r
+  STATUS      Status;\r
+  UINT32      Index;\r
+  UINT32      LineNum;\r
+  STRING_LIST *ListPtr;\r
+\r
+  Status  = STATUS_SUCCESS;\r
+  Fptr    = NULL;\r
+  //\r
+  // Print the file being processed. Indent so you can tell the include nesting\r
+  // depth.\r
+  //\r
+  if (mGlobals.Verbose) {\r
+    fprintf (stdout, "%*cProcessing file '%s'\n", NestDepth * 2, ' ', FileName);\r
+  }\r
+  //\r
+  // If we're using summary dependency files, and a matching .dep file is\r
+  // found for this file, then just emit the summary dependency file as\r
+  // a dependency and return.\r
+  //\r
+  if (mGlobals.UseSumDeps) {\r
+    strcpy (SumDepsFile, mGlobals.SumDepsPath);\r
+    strcat (SumDepsFile, FileName);\r
+    for (Cptr = SumDepsFile + strlen (SumDepsFile) - 1;\r
+         (*Cptr != '\\' && *Cptr != '/') && (Cptr > SumDepsFile) && (*Cptr != '.');\r
+         Cptr--\r
+        )\r
+      ;\r
+    if (*Cptr == '.') {\r
+      strcpy (Cptr, ".dep");\r
+    } else {\r
+      strcat (SumDepsFile, ".dep");\r
+    }\r
+    //\r
+    // See if the summary dep file exists. Could use _stat() function, but\r
+    // it's less portable.\r
+    //\r
+    if ((Fptr = fopen (SumDepsFile, "r")) != NULL) {\r
+      PrintDependency (TargetFileName, SumDepsFile);\r
+      return STATUS_SUCCESS;\r
+    }\r
+  }\r
+  //\r
+  // If we're not doing duplicates, and we've already seen this filename,\r
+  // then return\r
+  //\r
+  if (mGlobals.NoDupes) {\r
+    for (ListPtr = ProcessedFiles->Next; ListPtr != NULL; ListPtr = ListPtr->Next) {\r
+      if (stricmp (FileName, ListPtr->Str) == 0) {\r
+        break;\r
+      }\r
+    }\r
+    //\r
+    // If we found a match, we're done. If we didn't, create a new element\r
+    // and add it to the list.\r
+    //\r
+    if (ListPtr != NULL) {\r
+      //\r
+      // Print a message if verbose mode\r
+      //\r
+      if (mGlobals.Verbose) {\r
+        DebugMsg (NULL, 0, 0, FileName, "duplicate include -- not processed again");\r
+      }\r
+\r
+      return STATUS_SUCCESS;\r
+    }\r
+\r
+    ListPtr       = malloc (sizeof (STRING_LIST));\r
+    ListPtr->Str  = malloc (strlen (FileName) + 1);\r
+    strcpy (ListPtr->Str, FileName);\r
+    ListPtr->Next         = ProcessedFiles->Next;\r
+    ProcessedFiles->Next  = ListPtr;\r
+  }\r
+\r
+  //\r
+  // Make sure we didn't exceed our maximum nesting depth\r
+  //\r
+  if (NestDepth > MAX_NEST_DEPTH) {\r
+    Error (NULL, 0, 0, FileName, "max nesting depth exceeded on file");\r
+    goto Finish;\r
+  }\r
+  //\r
+  // Make a local copy of the filename. Then we can manipulate it\r
+  // if we have to.\r
+  //\r
+  strcpy (FileNameCopy, FileName);\r
+  //\r
+  // Try to open the file locally\r
+  //\r
+  if ((Fptr = fopen (FileNameCopy, "r")) == NULL) {\r
+    //\r
+    // Try to find it among the paths.\r
+    //\r
+    Fptr = FindFile (FileNameCopy, sizeof (FileNameCopy));\r
+    if (Fptr == NULL) {\r
+      //\r
+      // If this is not the top-level file, and the command-line argument\r
+      // said to ignore missing files, then return ok\r
+      //\r
+      if (NestDepth != START_NEST_DEPTH) {\r
+        if (mGlobals.IgnoreNotFound) {\r
+          if (!mGlobals.QuietMode) {\r
+            DebugMsg (NULL, 0, 0, FileNameCopy, "could not find file");\r
+          }\r
+\r
+          return STATUS_SUCCESS;\r
+        } else {\r
+          Error (NULL, 0, 0, FileNameCopy, "could not find file");\r
+          return STATUS_ERROR;\r
+        }\r
+      } else {\r
+        //\r
+        // Top-level (first) file. Emit an error.\r
+        //\r
+        Error (NULL, 0, 0, FileNameCopy, "could not find file");\r
+        return STATUS_ERROR;\r
+      }\r
+    }\r
+  }\r
+  //\r
+  // Print the dependency, with string substitution\r
+  //\r
+  PrintDependency (TargetFileName, FileNameCopy);\r
+\r
+  //\r
+  // Now read in lines and find all #include lines. Allow them to indent, and\r
+  // to put spaces between the # and include.\r
+  //\r
+  LineNum = 0;\r
+  while ((fgets (Line, sizeof (Line), Fptr) != NULL) && (Status == STATUS_SUCCESS)) {\r
+    LineNum++;\r
+    Cptr = Line;\r
+    //\r
+    // Skip preceeding spaces on the line\r
+    //\r
+    while (*Cptr && (isspace (*Cptr))) {\r
+      Cptr++;\r
+    }\r
+    //\r
+    // Check for # character\r
+    //\r
+    if (*Cptr == '#') {\r
+      Cptr++;\r
+      //\r
+      // Check for "include"\r
+      //\r
+      while (*Cptr && (isspace (*Cptr))) {\r
+        Cptr++;\r
+      }\r
+\r
+      if (strncmp (Cptr, "include", 7) == 0) {\r
+        //\r
+        // Skip over "include" and move on to filename as "file" or <file>\r
+        //\r
+        Cptr += 7;\r
+        while (*Cptr && (isspace (*Cptr))) {\r
+          Cptr++;\r
+        }\r
+\r
+        if (*Cptr == '<') {\r
+          EndChar = '>';\r
+        } else if (*Cptr == '"') {\r
+          EndChar = '"';\r
+        } else {\r
+          //\r
+          // Handle special #include MACRO_NAME(file)\r
+          // Set EndChar to null so we fall through on processing below.\r
+          //\r
+          EndChar = 0;\r
+          //\r
+          // Look for all the special include macros and convert accordingly.\r
+          //\r
+          for (Index = 0; mMacroConversion[Index].IncludeMacroName != NULL; Index++) {\r
+            //\r
+            // Save the start of the string in case some macros are substrings\r
+            // of others.\r
+            //\r
+            SaveCptr = Cptr;\r
+            if (strncmp (\r
+                  Cptr,\r
+                  mMacroConversion[Index].IncludeMacroName,\r
+                  strlen (mMacroConversion[Index].IncludeMacroName)\r
+                  ) == 0) {\r
+              //\r
+              // Skip over the macro name\r
+              //\r
+              Cptr += strlen (mMacroConversion[Index].IncludeMacroName);\r
+              //\r
+              // Skip over open parenthesis, blank spaces, then find closing\r
+              // parenthesis or blank space\r
+              //\r
+              while (*Cptr && (isspace (*Cptr))) {\r
+                Cptr++;\r
+              }\r
+\r
+              if (*Cptr == '(') {\r
+                Cptr++;\r
+                while (*Cptr && (isspace (*Cptr))) {\r
+                  Cptr++;\r
+                }\r
+\r
+                EndPtr = Cptr;\r
+                while (*EndPtr && !isspace (*EndPtr) && (*EndPtr != ')')) {\r
+                  EndPtr++;\r
+                }\r
+\r
+                *EndPtr = 0;\r
+                //\r
+                // Create the path\r
+                //\r
+                strcpy (MacroIncludeFileName, mMacroConversion[Index].PathName);\r
+                strcat (MacroIncludeFileName, Cptr);\r
+                strcat (MacroIncludeFileName, "/");\r
+                strcat (MacroIncludeFileName, Cptr);\r
+                strcat (MacroIncludeFileName, ".h");\r
+                //\r
+                // Process immediately, then break out of the outside FOR loop.\r
+                //\r
+                Status = ProcessFile (TargetFileName, MacroIncludeFileName, NestDepth + 1, ProcessedFiles);\r
+                break;\r
+              }\r
+            }\r
+            //\r
+            // Restore the start\r
+            //\r
+            Cptr = SaveCptr;\r
+          }\r
+          //\r
+          // Don't recognize the include line? Ignore it. We assume that the\r
+          // file compiles anyway.\r
+          //\r
+          if (mMacroConversion[Index].IncludeMacroName == NULL) {\r
+            //\r
+            // Warning (FileNameCopy, LineNum, 0, "could not parse line", NULL);\r
+            // Status = STATUS_WARNING;\r
+            //\r
+          }\r
+        }\r
+        //\r
+        // Process "normal" includes. If the endchar is 0, then the\r
+        // file has already been processed. Otherwise look for the\r
+        // endchar > or ", and process the include file.\r
+        //\r
+        if (EndChar != 0) {\r
+          Cptr++;\r
+          EndPtr = Cptr;\r
+          while (*EndPtr && (*EndPtr != EndChar)) {\r
+            EndPtr++;\r
+          }\r
+\r
+          if (*EndPtr == EndChar) {\r
+            //\r
+            // If we're processing it, do it\r
+            //\r
+            if ((EndChar != '>') || (!mGlobals.NoSystem)) {\r
+              //\r
+              // Null terminate the filename and try to process it.\r
+              //\r
+              *EndPtr = 0;\r
+              Status  = ProcessFile (TargetFileName, Cptr, NestDepth + 1, ProcessedFiles);\r
+            }\r
+          } else {\r
+            Warning (FileNameCopy, LineNum, 0, "malformed include", "missing closing %c", EndChar);\r
+            Status = STATUS_WARNING;\r
+            goto Finish;\r
+          }\r
+        }\r
+      }\r
+    }\r
+  }\r
+\r
+Finish:\r
+  //\r
+  // Close open files and return status\r
+  //\r
+  if (Fptr != NULL) {\r
+    fclose (Fptr);\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
+static\r
+void\r
+PrintDependency (\r
+  INT8    *TargetFileName,\r
+  INT8    *DependentFile\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Given a target (.obj) file name, and a dependent file name, do any string\r
+  substitutions (per the command line options) on the file names, then\r
+  print the dependency line of form:\r
+  \r
+  TargetFileName : DependentFile\r
+  \r
+Arguments:\r
+\r
+  TargetFileName - build target file name\r
+  DependentFile  - file on which TargetFileName depends\r
+\r
+Returns:\r
+\r
+  None\r
+  \r
+--*/\r
+{\r
+  INT8  Str[MAX_PATH];\r
+\r
+  //\r
+  // Go through the symbols and do replacements\r
+  //\r
+  strcpy (Str, DependentFile);\r
+  ReplaceSymbols (Str, sizeof (Str));\r
+  fprintf (mGlobals.OutFptr, "%s\n", Str);\r
+}\r
+\r
+static\r
+void\r
+ReplaceSymbols (\r
+  INT8    *Str,\r
+  UINT32  StrSize\r
+  )\r
+{\r
+  SYMBOL  *Sym;\r
+  INT8    StrCopy[MAX_LINE_LEN];\r
+  INT8    *From;\r
+  INT8    *To;\r
+  BOOLEAN Replaced;\r
+\r
+  //\r
+  // Go through the entire string to look for replacement strings at\r
+  // every position.\r
+  //\r
+  From  = Str;\r
+  To    = StrCopy;\r
+  while (*From) {\r
+    //\r
+    // Copy the character\r
+    //\r
+    *To       = *From;\r
+    Replaced  = FALSE;\r
+    //\r
+    // Go through each symbol and try to find a string substitution\r
+    //\r
+    Sym = mGlobals.SymbolTable;\r
+    while (Sym != NULL) {\r
+      if (strnicmp (From, Sym->Value, strlen (Sym->Value)) == 0) {\r
+        //\r
+        // Replace the string, then advance the pointers past the\r
+        // replaced strings\r
+        //\r
+        strcpy (To, Sym->Name);\r
+        To += strlen (Sym->Name);\r
+        From += strlen (Sym->Value);\r
+        Replaced = TRUE;\r
+        //\r
+        // Break from the while()\r
+        //\r
+        break;\r
+      } else {\r
+        Sym = Sym->Next;\r
+      }\r
+    }\r
+\r
+    if (!Replaced) {\r
+      From++;\r
+      To++;\r
+    }\r
+  }\r
+  //\r
+  // Null terminate, and return it\r
+  //\r
+  *To = 0;\r
+  if (strlen (StrCopy) < StrSize) {\r
+    strcpy (Str, StrCopy);\r
+  }\r
+}\r
+//\r
+// Given a filename, try to find it along the include paths.\r
+//\r
+static\r
+FILE *\r
+FindFile (\r
+  INT8    *FileName,\r
+  UINT32  FileNameLen\r
+  )\r
+{\r
+  FILE        *Fptr;\r
+  STRING_LIST *List;\r
+  STRING_LIST *SubDir;\r
+  INT8        FullFileName[MAX_PATH * 2];\r
+\r
+  //\r
+  // Traverse the list of paths and try to find the file\r
+  //\r
+  List = mGlobals.IncludePaths;\r
+  while (List != NULL) {\r
+    //\r
+    // Put the path and filename together\r
+    //\r
+    if (strlen (List->Str) + strlen (FileName) + 1 > sizeof (FullFileName)) {\r
+      Error (\r
+        __FILE__,\r
+        __LINE__,\r
+        0,\r
+        "application error",\r
+        "cannot concatenate '%s' + '%s'",\r
+        List->Str,\r
+        FileName\r
+        );\r
+      return NULL;\r
+    }\r
+    //\r
+    // Append the filename to this include path and try to open the file.\r
+    //\r
+    strcpy (FullFileName, List->Str);\r
+    strcat (FullFileName, FileName);\r
+    if ((Fptr = fopen (FullFileName, "r")) != NULL) {\r
+      //\r
+      // Return the file name\r
+      //\r
+      if (FileNameLen <= strlen (FullFileName)) {\r
+        Error (__FILE__, __LINE__, 0, "application error", "internal path name of insufficient length");\r
+        //\r
+        // fprintf (stdout, "File length > %d: %s\n", FileNameLen, FullFileName);\r
+        //\r
+        return NULL;\r
+      }\r
+\r
+      strcpy (FileName, FullFileName);\r
+      return Fptr;\r
+    }\r
+    //\r
+    // Didn't find it there. Now try this directory with every subdirectory\r
+    // the user specified on the command line\r
+    //\r
+    for (SubDir = mGlobals.SubDirs; SubDir != NULL; SubDir = SubDir->Next) {\r
+      strcpy (FullFileName, List->Str);\r
+      strcat (FullFileName, SubDir->Str);\r
+      strcat (FullFileName, FileName);\r
+      if ((Fptr = fopen (FullFileName, "r")) != NULL) {\r
+        //\r
+        // Return the file name\r
+        //\r
+        if (FileNameLen <= strlen (FullFileName)) {\r
+          Error (__FILE__, __LINE__, 0, "application error", "internal path name of insufficient length");\r
+          return NULL;\r
+        }\r
+\r
+        strcpy (FileName, FullFileName);\r
+        return Fptr;\r
+      }\r
+    }\r
+\r
+    List = List->Next;\r
+  }\r
+  //\r
+  // Not found\r
+  //\r
+  return NULL;\r
+}\r
+//\r
+// Process the command-line arguments\r
+//\r
+static\r
+STATUS\r
+ProcessArgs (\r
+  int   Argc,\r
+  char  *Argv[]\r
+  )\r
+{\r
+  STRING_LIST *NewList;\r
+  STRING_LIST *LastIncludePath;\r
+  STRING_LIST *LastSourceFile;\r
+  SYMBOL      *Symbol;\r
+  int         Index;\r
+  //\r
+  // Clear our globals\r
+  //\r
+  memset ((char *) &mGlobals, 0, sizeof (mGlobals));\r
+  mGlobals.NoDupes = TRUE;\r
+  //\r
+  // Skip program name\r
+  //\r
+  Argc--;\r
+  Argv++;\r
+  //\r
+  // Initialize locals\r
+  //\r
+  LastIncludePath = NULL;\r
+  LastSourceFile  = NULL;\r
+  //\r
+  // Process until no more args\r
+  //\r
+  while (Argc) {\r
+    //\r
+    // -i path    add include search path\r
+    //\r
+    if (stricmp (Argv[0], "-i") == 0) {\r
+      //\r
+      // check for one more arg\r
+      //\r
+      if (Argc > 1) {\r
+        //\r
+        // Allocate memory for a new list element, fill it in, and\r
+        // add it to our list of include paths. Always make sure it\r
+        // has a "\" on the end of it.\r
+        //\r
+        NewList = malloc (sizeof (STRING_LIST));\r
+        if (NewList == NULL) {\r
+          Error (__FILE__, __LINE__, 0, "memory allocation failure", NULL);\r
+          return STATUS_ERROR;\r
+        }\r
+\r
+        NewList->Next = NULL;\r
+        NewList->Str  = malloc (strlen (Argv[1]) + 2);\r
+        if (NewList->Str == NULL) {\r
+          free (NewList);\r
+          Error (__FILE__, __LINE__, 0, "memory allocation failure", NULL);\r
+          return STATUS_ERROR;\r
+        }\r
+\r
+        strcpy (NewList->Str, Argv[1]);\r
+        if (NewList->Str[strlen (NewList->Str) - 1] != '\\' && NewList->Str[strlen (NewList->Str) - 1] != '/') {\r
+          strcat (NewList->Str, "/");\r
+        }\r
+        //\r
+        // Add it to the end of the our list of include paths\r
+        //\r
+        if (mGlobals.IncludePaths == NULL) {\r
+          mGlobals.IncludePaths = NewList;\r
+        } else {\r
+          LastIncludePath->Next = NewList;\r
+        }\r
+\r
+        LastIncludePath = NewList;\r
+        //\r
+        // fprintf (stdout, "Added path: %s\n", NewList->Str);\r
+        //\r
+      } else {\r
+        Error (NULL, 0, 0, Argv[0], "option requires an include path");\r
+        Usage ();\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      Argc--;\r
+      Argv++;\r
+    } else if (stricmp (Argv[0], "-f") == 0) {\r
+      //\r
+      // Check for one more arg\r
+      //\r
+      if (Argc > 1) {\r
+        //\r
+        // Allocate memory for a new list element, fill it in, and\r
+        // add it to our list of source files.\r
+        //\r
+        NewList = malloc (sizeof (STRING_LIST));\r
+        if (NewList == NULL) {\r
+          Error (__FILE__, __LINE__, 0, "memory allocation failure", NULL);\r
+          return STATUS_ERROR;\r
+        }\r
+\r
+        NewList->Next = NULL;\r
+        //\r
+        // Allocate space to replace ".c" with ".obj", plus null termination\r
+        //\r
+        NewList->Str = malloc (strlen (Argv[1]) + 5);\r
+        if (NewList->Str == NULL) {\r
+          free (NewList);\r
+          Error (__FILE__, __LINE__, 0, "memory allocation failure", NULL);\r
+          return STATUS_ERROR;\r
+        }\r
+\r
+        strcpy (NewList->Str, Argv[1]);\r
+        if (mGlobals.SourceFiles == NULL) {\r
+          mGlobals.SourceFiles = NewList;\r
+        } else {\r
+          LastSourceFile->Next = NewList;\r
+        }\r
+\r
+        LastSourceFile = NewList;\r
+      } else {\r
+        Error (NULL, 0, 0, Argv[0], "option requires a file name");\r
+        Usage ();\r
+        return STATUS_ERROR;\r
+      }\r
+      //\r
+      // The C compiler first looks for #include files in the directory where\r
+      // the source file came from. Add the file's source directory to the\r
+      // list of include paths.\r
+      //\r
+      NewList = malloc (sizeof (STRING_LIST));\r
+      if (NewList == NULL) {\r
+        Error (__FILE__, __LINE__, 0, "memory allocation failure", NULL);\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      NewList->Next = NULL;\r
+      NewList->Str  = malloc (strlen (Argv[1]) + 3);\r
+      if (NewList->Str == NULL) {\r
+        free (NewList);\r
+        Error (__FILE__, __LINE__, 0, "memory allocation failure", NULL);\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      strcpy (NewList->Str, Argv[1]);\r
+      //\r
+      // Back up in the source file name to the last backslash and terminate after it.\r
+      //\r
+      for (Index = strlen (NewList->Str) - 1; (Index > 0) && (NewList->Str[Index] != '\\' && NewList->Str[Index] != '/'); Index--)\r
+        ;\r
+      if (Index < 0) {\r
+        strcpy (NewList->Str, "./");\r
+      } else {\r
+        NewList->Str[Index + 1] = 0;\r
+      }\r
+      //\r
+      // Add it to the end of the our list of include paths\r
+      //\r
+      if (mGlobals.IncludePaths == NULL) {\r
+        mGlobals.IncludePaths = NewList;\r
+      } else {\r
+        LastIncludePath->Next = NewList;\r
+      }\r
+\r
+      if (mGlobals.Verbose) {\r
+        fprintf (stdout, "Adding include path: %s\n", NewList->Str);\r
+      }\r
+\r
+      LastIncludePath = NewList;\r
+      Argc--;\r
+      Argv++;\r
+    } else if (stricmp (Argv[0], "-s") == 0) {\r
+      //\r
+      // -s subdir    add subdirectory subdir to list of subdirecties to scan.\r
+      // Check for one more arg first.\r
+      //\r
+      if (Argc > 1) {\r
+        //\r
+        // Allocate memory for a new list element, fill it in, and\r
+        // add it to our list of subdirectory include paths. Always\r
+        // make sure it has a "\" on the end of it.\r
+        //\r
+        NewList = malloc (sizeof (STRING_LIST));\r
+        if (NewList == NULL) {\r
+          Error (__FILE__, __LINE__, 0, "memory allocation failure", NULL);\r
+          return STATUS_ERROR;\r
+        }\r
+\r
+        NewList->Str = malloc (strlen (Argv[1]) + 2);\r
+        if (NewList->Str == NULL) {\r
+          free (NewList);\r
+          Error (__FILE__, __LINE__, 0, "memory allocation failure", NULL);\r
+          return STATUS_ERROR;\r
+        }\r
+\r
+        strcpy (NewList->Str, Argv[1]);\r
+        if (NewList->Str[strlen (NewList->Str) - 1] != '\\' && NewList->Str[strlen (NewList->Str) - 1] != '/') {\r
+          strcat (NewList->Str, "/");\r
+        }\r
+\r
+        NewList->Next     = mGlobals.SubDirs;\r
+        mGlobals.SubDirs  = NewList;\r
+      } else {\r
+        Error (NULL, 0, 0, Argv[0], "option requires a subdirectory name");\r
+        Usage ();\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      Argc--;\r
+      Argv++;\r
+    } else if (stricmp (Argv[0], "-sub") == 0) {\r
+      //\r
+      // -sub symname symvalue  to do string substitution in the output\r
+      //\r
+      if (Argc > 2) {\r
+        //\r
+        // Allocate memory for the symbol object\r
+        //\r
+        Symbol = malloc (sizeof (SYMBOL));\r
+        if (Symbol == NULL) {\r
+          Error (__FILE__, __LINE__, 0, "memory allocation failure", NULL);\r
+          return STATUS_ERROR;\r
+        }\r
+        //\r
+        // Allocate memory for the symbol name and value, then save copies\r
+        //\r
+        Symbol->Name = malloc (strlen (Argv[1]) + 1);\r
+        if (Symbol->Name == NULL) {\r
+          free (Symbol);\r
+          Error (__FILE__, __LINE__, 0, "memory allocation failure", NULL);\r
+          return STATUS_ERROR;\r
+        }\r
+\r
+        strcpy (Symbol->Name, Argv[1]);\r
+        Symbol->Value = malloc (strlen (Argv[2]) + 1);\r
+        if (Symbol->Value == NULL) {\r
+          free (Symbol->Name);\r
+          free (Symbol);\r
+          Error (__FILE__, __LINE__, 0, "memory allocation failure", NULL);\r
+          return STATUS_ERROR;\r
+        }\r
+\r
+        strcpy (Symbol->Value, Argv[2]);\r
+        //\r
+        // Add it to the list\r
+        //\r
+        Symbol->Next          = mGlobals.SymbolTable;\r
+        mGlobals.SymbolTable  = Symbol;\r
+      } else {\r
+        Error (NULL, 0, 0, Argv[0], "option requires a symbol name and value");\r
+        Usage ();\r
+        return STATUS_ERROR;\r
+      }\r
+      //\r
+      // Skip over args\r
+      //\r
+      Argc -= 2;\r
+      Argv += 2;\r
+    } else if (stricmp (Argv[0], "-nosystem") == 0) {\r
+      mGlobals.NoSystem = TRUE;\r
+    } else if (stricmp (Argv[0], "-nodupes") == 0) {\r
+      mGlobals.NoDupes = TRUE;\r
+    } else if (stricmp (Argv[0], "-nodups") == 0) {\r
+      mGlobals.NoDupes = TRUE;\r
+    } else if (stricmp (Argv[0], "-target") == 0) {\r
+      //\r
+      // -target TargetFileName  - Target object file (only one allowed right\r
+      // now) is TargetFileName rather than SourceFile.obj\r
+      //\r
+      if (Argc > 1) {\r
+        strcpy (mGlobals.TargetFileName, Argv[1]);\r
+      } else {\r
+        Error (NULL, 0, 0, Argv[0], "option requires a target file name");\r
+        Usage ();\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      Argc--;\r
+      Argv++;\r
+    } else if (stricmp (Argv[0], "-usesumdeps") == 0) {\r
+      //\r
+      // -usesumdeps Path - if we find an included file xxx.h, and file\r
+      // Path/xxx.dep exists, list Path/xxx.dep as a dependency rather than\r
+      // xxx.h and don't parse xxx.h. This allows you to create a dependency\r
+      // file for a commonly included file, and have its dependency file updated\r
+      // only if its included files are updated. Then anyone else including this\r
+      // common include file can simply have a dependency on that file's .dep file\r
+      // rather than on all the files included by it. Confusing enough?\r
+      //\r
+      mGlobals.UseSumDeps = 1;\r
+      if (Argc > 1) {\r
+        strcpy (mGlobals.SumDepsPath, Argv[1]);\r
+        //\r
+        // Add slash on end if not there\r
+        //\r
+        if (mGlobals.SumDepsPath[strlen (mGlobals.SumDepsPath) - 1] != '\\' && mGlobals.SumDepsPath[strlen (mGlobals.SumDepsPath) - 1] != '/') {\r
+          strcat (mGlobals.SumDepsPath, "/");\r
+        }\r
+      } else {\r
+        Error (NULL, 0, 0, Argv[0], "option requires path to summary dependency files");\r
+        Usage ();\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      Argc--;\r
+      Argv++;\r
+\r
+    } else if (stricmp (Argv[0], "-o") == 0) {\r
+      //\r
+      // -o OutputFileName    - specify an output filename for dependency list\r
+      // check for one more arg\r
+      //\r
+      if (Argc > 1) {\r
+        //\r
+        // Try to open the file\r
+        //\r
+        if ((mGlobals.OutFptr = fopen (Argv[1], "w")) == NULL) {\r
+          Error (NULL, 0, 0, Argv[1], "could not open file for writing");\r
+          return STATUS_ERROR;\r
+        }\r
+\r
+        mGlobals.OutFileName = Argv[1];\r
+      } else {\r
+        Error (NULL, 0, 0, Argv[0], "option requires output file name");\r
+        Usage ();\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      Argc--;\r
+      Argv++;\r
+    } else if (stricmp (Argv[0], "-v") == 0) {\r
+      mGlobals.Verbose = TRUE;\r
+    } else if (stricmp (Argv[0], "-neverfail") == 0) {\r
+      mGlobals.NeverFail = TRUE;\r
+    } else if (stricmp (Argv[0], "-q") == 0) {\r
+      mGlobals.QuietMode = TRUE;\r
+    } else if (stricmp (Argv[0], "-ignorenotfound") == 0) {\r
+      mGlobals.IgnoreNotFound = TRUE;\r
+    } else if ((stricmp (Argv[0], "-h") == 0) || (strcmp (Argv[0], "-?") == 0)) {\r
+      Usage ();\r
+      return STATUS_ERROR;\r
+    } else {\r
+      Error (NULL, 0, 0, Argv[0], "unrecognized option");\r
+      Usage ();\r
+      return STATUS_ERROR;\r
+    }\r
+\r
+    Argc--;\r
+    Argv++;\r
+  }\r
+  //\r
+  // Had to specify at least one source file\r
+  //\r
+  if (mGlobals.SourceFiles == NULL) {\r
+    Error (NULL, 0, 0, "must specify one source file name", NULL);\r
+    Usage ();\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Assume output to stdout if not specified\r
+  //\r
+  if (mGlobals.OutFptr == NULL) {\r
+    mGlobals.OutFptr = stdout;\r
+  }\r
+\r
+  return STATUS_SUCCESS;\r
+}\r
+//\r
+// Free the global string lists we allocated memory for\r
+//\r
+static\r
+void\r
+FreeLists (\r
+  VOID\r
+  )\r
+{\r
+  STRING_LIST *Temp;\r
+  SYMBOL      *NextSym;\r
+\r
+  //\r
+  // printf ("Free lists.....");\r
+  //\r
+  // Traverse the include paths, freeing each\r
+  // printf ("freeing include paths\n");\r
+  //\r
+  while (mGlobals.IncludePaths != NULL) {\r
+    Temp = mGlobals.IncludePaths->Next;\r
+    //\r
+    // printf ("Freeing include path string '%s' at 0x%X\n",\r
+    //  mGlobals.IncludePaths->Str, (int)(mGlobals.IncludePaths->Str));\r
+    //\r
+    free (mGlobals.IncludePaths->Str);\r
+    //\r
+    // printf ("Freeing include path object at 0x%X\n", (int)(mGlobals.IncludePaths));\r
+    //\r
+    free (mGlobals.IncludePaths);\r
+    mGlobals.IncludePaths = Temp;\r
+  }\r
+  //\r
+  // Traverse the source files, freeing each\r
+  //\r
+  while (mGlobals.SourceFiles != NULL) {\r
+    Temp = mGlobals.SourceFiles->Next;\r
+    free (mGlobals.SourceFiles->Str);\r
+    free (mGlobals.SourceFiles);\r
+    mGlobals.SourceFiles = Temp;\r
+  }\r
+  //\r
+  // Traverse the subdirectory list, freeing each\r
+  //\r
+  while (mGlobals.SubDirs != NULL) {\r
+    Temp = mGlobals.SubDirs->Next;\r
+    free (mGlobals.SubDirs->Str);\r
+    free (mGlobals.SubDirs);\r
+    mGlobals.SubDirs = Temp;\r
+  }\r
+  //\r
+  // Free the symbol table\r
+  //\r
+  while (mGlobals.SymbolTable != NULL) {\r
+    NextSym = mGlobals.SymbolTable->Next;\r
+    free (mGlobals.SymbolTable->Name);\r
+    free (mGlobals.SymbolTable->Value);\r
+    mGlobals.SymbolTable = NextSym;\r
+  }\r
+  //\r
+  // printf ("done\n");\r
+  //\r
+}\r
+\r
+static\r
+void\r
+Usage (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Print usage information for this utility.\r
+  \r
+Arguments:\r
+\r
+  None.\r
+\r
+Returns:\r
+\r
+  Nothing.\r
+  \r
+--*/\r
+{\r
+  int               Index;\r
+  static const char *Str[] = {\r
+    UTILITY_NAME " -- make dependencies",\r
+    "  Usage: MakeDeps [options]",\r
+    "    Options include:",\r
+    "      -h or -?         for this help information",\r
+    "      -f SourceFile    add SourceFile to list of files to scan",\r
+    "      -i IncludePath   add IncludePath to list of search paths",\r
+    "      -o OutputFile    write output dependencies to OutputFile",\r
+    "      -s SubDir        for each IncludePath, also search IncludePath\\SubDir",\r
+    "      -v               for verbose output",\r
+    "      -ignorenotfound  don't warn for files not found",\r
+    "      -target Target   for single SourceFile, target is Target, not SourceFile.obj",\r
+    "      -q               quiet mode to not report files not found if ignored",\r
+    "      -sub sym str     replace all occurrances of 'str' with 'sym' in the output",\r
+    "      -nosystem        not process system <include> files",\r
+    "      -neverfail       always return a success return code",\r
+    //\r
+    //    "      -nodupes         keep track of include files, don't rescan duplicates",\r
+    //\r
+    "      -usesumdeps path use summary dependency files in 'path' directory.",\r
+    "",\r
+    NULL\r
+  };\r
+  for (Index = 0; Str[Index] != NULL; Index++) {\r
+    fprintf (stdout, "%s\n", Str[Index]);\r
+  }\r
+}\r
diff --git a/Tools/CodeTools/Source/MakeDeps/build.xml b/Tools/CodeTools/Source/MakeDeps/build.xml
new file mode 100755 (executable)
index 0000000..60c34c2
--- /dev/null
@@ -0,0 +1,71 @@
+<?xml version="1.0" ?>\r
+<!--\r
+Copyright (c) 2006, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+-->\r
+<project default="GenTool" basedir=".">\r
+<!--\r
+    EDK MakeDeps Tool\r
+  Copyright (c) 2006, Intel Corporation\r
+-->\r
+  <property name="ToolName" value="MakeDeps"/>\r
+  <property name="FileSet" value="*.c *.h"/>\r
+\r
+  <taskdef resource="cpptasks.tasks"/>\r
+  <typedef resource="cpptasks.types"/>\r
+  <taskdef resource="net/sf/antcontrib/antlib.xml"/>\r
+\r
+  <property name="LINK_OUTPUT_TYPE" value="static"/>\r
+  <property name="BUILD_DIR" value="${PACKAGE_DIR}/${ToolName}/tmp"/>\r
+\r
+  <target name="GenTool" depends="init, Tool">\r
+    <echo message="The EDK Tool: ${ToolName} build has completed!"/>\r
+  </target>\r
+\r
+  <target name="init">\r
+    <echo message="Building the EDK Tool: ${ToolName}"/>\r
+    <mkdir dir="${BUILD_DIR}"/>\r
+  </target>\r
+\r
+  <target name="Tool" depends="init">\r
+    <cc name="${ToolChain}" objdir="${BUILD_DIR}" \r
+        outfile="${BIN_DIR}/${ToolName}"\r
+        outtype="executable"\r
+        debug="true"\r
+        optimize="speed">\r
+      <compilerarg value="${ExtraArgus}" if="ExtraArgus" />   \r
+       \r
+      <fileset dir="${basedir}/${ToolName}" \r
+        includes="${FileSet}" \r
+        defaultexcludes="TRUE" \r
+        excludes="*.xml *.inf"/>\r
+\r
+      <includepath path="${PACKAGE_DIR}/Include"/>\r
+      <includepath path="${PACKAGE_DIR}/Include/${HostArch}"/>\r
+      <includepath path="${PACKAGE_DIR}/Common"/>\r
+      <libset dir="${LIB_DIR}" libs="CommonTools"/>\r
+    </cc>\r
+  </target>\r
+\r
+  <target name="clean">\r
+    <echo message="Removing Intermediate Files Only"/>  \r
+    <delete>\r
+      <fileset dir="${BUILD_DIR}" includes="*.obj"/>\r
+    </delete>\r
+  </target>\r
+\r
+  <target name="cleanall">\r
+    <echo message="Removing Object Files and the Executable: ${ToolName}${ext_exe}"/>  \r
+    <delete failonerror="false" quiet="true" includeEmptyDirs="true">\r
+      <fileset dir="${BUILD_DIR}"/>\r
+      <fileset file="${BIN_DIR}/${ToolName}${ext_exe}"/>\r
+    </delete>\r
+  </target>\r
+\r
+</project>\r
diff --git a/Tools/CodeTools/Source/ModifyInf/ModifyInf.c b/Tools/CodeTools/Source/ModifyInf/ModifyInf.c
new file mode 100755 (executable)
index 0000000..6008feb
--- /dev/null
@@ -0,0 +1,321 @@
+/*++\r
+\r
+Copyright (c)  1999-2006 Intel Corporation. All rights reserved\r
+This program and the accompanying materials are licensed and made available \r
+under the terms and conditions of the BSD License which accompanies this \r
+distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+\r
+Module Name:\r
+\r
+  ModifyInf.c\r
+\r
+Abstract:\r
+\r
+  It is a simple tool to modify some fields in a FV inf file \r
+  and output a new FV inf file.  \r
+\r
+--*/\r
+\r
+#include "stdio.h"\r
+#include "string.h"\r
+\r
+//\r
+// Read a line into buffer including '\r\n'\r
+//\r
+int\r
+ReadLine (\r
+  char *LineBuffer,\r
+  FILE *fp\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  LineBuffer  - GC_TODO: add argument description\r
+  fp          - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+{\r
+  int   CharC;\r
+  char  *Line;\r
+\r
+  Line = LineBuffer;\r
+\r
+  while ((CharC = fgetc (fp)) != EOF) {\r
+    *Line++ = (char) CharC;\r
+    if (CharC == 0x0a) {\r
+      break;\r
+    }\r
+  }\r
+\r
+  *Line = 0;\r
+\r
+  if (CharC == EOF) {\r
+    return 0;\r
+  } else {\r
+    return 1;\r
+  }\r
+\r
+}\r
+//\r
+// Write a line into output file\r
+//\r
+int\r
+WriteLine (\r
+  char *Line,\r
+  FILE *fp\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Line  - GC_TODO: add argument description\r
+  fp    - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+{\r
+  fwrite (Line, strlen (Line), 1, fp);\r
+  return 0;\r
+}\r
+//\r
+// Apply patterns to a line\r
+// Currently there are 2 patterns to support\r
+// '==' replace a field value with a new value\r
+// '+=' append a string at the end of original line\r
+// '-'  prevent the line from applying any patterns\r
+//      it has the highest priority\r
+//\r
+int\r
+ApplyPattern (\r
+  char *Line,\r
+  char *argv[],\r
+  int  argc\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Line  - GC_TODO: add argument description\r
+  ]     - GC_TODO: add argument description\r
+  argc  - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+{\r
+  static char Section[256];\r
+  char        PatternBuffer[256];\r
+  char        *Pattern;\r
+  char        *Pattern1;\r
+  char        *Pattern2;\r
+  int         PatternNum;\r
+  char        *Ptr;\r
+\r
+  Pattern     = PatternBuffer;\r
+\r
+  PatternNum  = argc;\r
+\r
+  //\r
+  // For section field\r
+  // record current scope section into static buffer\r
+  //\r
+  Ptr = Line;\r
+  if (*Ptr == '[') {\r
+    while (*Ptr != ']') {\r
+      if (!(*Ptr++)) {\r
+        return -1;\r
+      }\r
+    }\r
+\r
+    strcpy (Section, Line);\r
+    Section[Ptr - Line + 1] = 0;\r
+  }\r
+  //\r
+  // Apply each pattern on the line\r
+  //\r
+  while (PatternNum-- > 3) {\r
+\r
+    strcpy (Pattern, argv[PatternNum]);\r
+\r
+    //\r
+    // For pattern '-'\r
+    // keep it unmodified by other patterns\r
+    //\r
+    if (*Pattern == '-') {\r
+      if (strstr (Line, Pattern + 1)) {\r
+        return 0;\r
+      } else {\r
+        continue;\r
+      }\r
+    }\r
+    //\r
+    // For other patterns\r
+    // get its section at first if it has\r
+    //\r
+    if (*Pattern == '[') {\r
+      if (strncmp (Section, Pattern, strlen (Section))) {\r
+        //\r
+        // This pattern can't be appied for current section\r
+        //\r
+        continue;\r
+      }\r
+      //\r
+      // Strip the section field\r
+      //\r
+      while (*Pattern != ']') {\r
+        if (!(*Pattern++)) {\r
+          return -1;\r
+        }\r
+      }\r
+\r
+      Pattern++;\r
+    }\r
+    //\r
+    // Apply patterns\r
+    //\r
+    Pattern1  = strstr (Pattern, "==");\r
+    Pattern2  = strstr (Pattern, "+=");\r
+    if (Pattern1) {\r
+      //\r
+      // For pattern '=='\r
+      // replace the field value with a new string\r
+      //\r
+      if (!strncmp (Line, Pattern, Pattern1 - Pattern)) {\r
+        Pattern1 += 2;\r
+        Ptr = strstr (Line, "=");\r
+        if (!Ptr) {\r
+          return -1;\r
+        }\r
+\r
+        while (*(++Ptr) == ' ')\r
+          ;\r
+        *Ptr = 0;\r
+        strcat (Line, Pattern1);\r
+        strcat (Line, "\r\n");\r
+      }\r
+    } else if (Pattern2) {\r
+      //\r
+      // For pattern '+='\r
+      // append a string at end of the original string\r
+      //\r
+      if (!strncmp (Line, Pattern, Pattern2 - Pattern)) {\r
+        Pattern2 += 2;\r
+        Ptr = Line;\r
+        while (*Ptr != 0x0D && *Ptr != 0x0A) {\r
+          Ptr++;\r
+        }\r
+\r
+        *Ptr = 0;\r
+        strcat (Line, Pattern2);\r
+        strcat (Line, "\r\n");\r
+      }\r
+    }\r
+  }\r
+\r
+  return 0;\r
+}\r
+\r
+void\r
+Usage (\r
+  void\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  None\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+{\r
+  printf ("ModifyInf InputFVInfFileName OutputFVInfFileName [Pattern strings]\r\n");\r
+}\r
+\r
+int\r
+main (\r
+  int argc,\r
+  char*argv[]\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  argc  - GC_TODO: add argument description\r
+  ]     - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+{\r
+  char  LineBuffer[256];\r
+  FILE  *fpin;\r
+  FILE  *fpout;\r
+\r
+  if (argc < 3) {\r
+    Usage ();\r
+    return -1;\r
+  }\r
+\r
+  fpin = fopen (argv[1], "rb");\r
+  if (!fpin) {\r
+    printf ("Can't open input file!\r\n");\r
+    return -1;\r
+  }\r
+\r
+  fpout = fopen (argv[2], "wb");\r
+  if (!fpout) {\r
+    fclose (fpin);\r
+    printf ("Can't create output file!\r\n");\r
+    return -1;\r
+  }\r
+\r
+  while (ReadLine (LineBuffer, fpin)) {\r
+    ApplyPattern (LineBuffer, argv, argc);\r
+    WriteLine (LineBuffer, fpout);\r
+  }\r
+\r
+  fclose (fpin);\r
+  fclose (fpout);\r
+\r
+  return 0;\r
+}\r
diff --git a/Tools/CodeTools/Source/ModifyInf/build.xml b/Tools/CodeTools/Source/ModifyInf/build.xml
new file mode 100644 (file)
index 0000000..a695ae0
--- /dev/null
@@ -0,0 +1,70 @@
+<?xml version="1.0" ?>\r
+<!--\r
+Copyright (c) 2006, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+-->\r
+<project default="GenTool" basedir=".">\r
+<!--\r
+    EDK ModifyInf Tool\r
+  Copyright (c) 2006, Intel Corporation\r
+-->\r
+  <property name="ToolName" value="ModifyInf"/>\r
+  <property name="FileSet" value="ModifyInf.c"/>\r
+\r
+  <taskdef resource="cpptasks.tasks"/>\r
+  <typedef resource="cpptasks.types"/>\r
+  <taskdef resource="net/sf/antcontrib/antlib.xml"/>\r
+\r
+  <property name="LINK_OUTPUT_TYPE" value="static"/>\r
+  <property name="BUILD_DIR" value="${PACKAGE_DIR}/${ToolName}/tmp"/>\r
+\r
+  <target name="GenTool" depends="init, Tool">\r
+    <echo message="The EDK Tool: ${ToolName} build has completed!"/>\r
+  </target>\r
+\r
+  <target name="init">\r
+    <echo message="Building the EDK Tool: ${ToolName}"/>\r
+    <mkdir dir="${BUILD_DIR}"/>\r
+  </target>\r
+\r
+  <target name="Tool" depends="init">\r
+    <cc name="${ToolChain}" objdir="${BUILD_DIR}" \r
+        outfile="${BIN_DIR}/${ToolName}"\r
+        outtype="executable"\r
+        debug="true"\r
+        optimize="speed">\r
+\r
+      <fileset dir="${basedir}/${ToolName}" \r
+        includes="${FileSet}" \r
+        defaultexcludes="TRUE" \r
+        excludes="*.xml *.inf"/>\r
+\r
+      <includepath path="${PACKAGE_DIR}/Include"/>\r
+      <includepath path="${PACKAGE_DIR}/Include/${HostArch}"/>\r
+      <includepath path="${PACKAGE_DIR}/Common"/>\r
+\r
+    </cc>\r
+  </target>\r
+\r
+  <target name="clean">\r
+    <echo message="Removing Intermediate Files Only"/>  \r
+    <delete>\r
+      <fileset dir="${BUILD_DIR}" includes="*.obj"/>\r
+    </delete>\r
+  </target>\r
+\r
+  <target name="cleanall">\r
+    <echo message="Removing Object Files and the Executable: ${ToolName}${ext_exe}"/>  \r
+    <delete failonerror="false" quiet="true" includeEmptyDirs="true">\r
+      <fileset dir="${BUILD_DIR}"/>\r
+      <fileset file="${BIN_DIR}/${ToolName}${ext_exe}"/>\r
+    </delete>\r
+  </target>\r
+\r
+</project>\r
diff --git a/Tools/CodeTools/Source/Pccts/CHANGES_FROM_131.txt b/Tools/CodeTools/Source/Pccts/CHANGES_FROM_131.txt
new file mode 100644 (file)
index 0000000..500d84f
--- /dev/null
@@ -0,0 +1,522 @@
+CHANGES FROM 1.31\r
+\r
+This file contains the migration of PCCTS from 1.31 in the order that\r
+changes were made.  1.32b7 is the last beta before full 1.32.\r
+Terence Parr, Parr Research Corporation 1995.\r
+\r
+\r
+======================================================================\r
+1.32b1\r
+Added Russell Quong to banner, changed banner for output slightly\r
+Fixed it so that you have before / after actions for C++ in class def\r
+Fixed bug in optimizer that made it sometimes forget to set internal\r
+        token pointers.  Only showed up when a {...} was in the "wrong spot".\r
+\r
+======================================================================\r
+1.32b2\r
+Added fixes by Dave Seidel for PC compilers in 32 bit mode (config.h\r
+and set.h).\r
+\r
+======================================================================\r
+1.32b3\r
+Fixed hideous bug in code generator for wildcard and for ~token op.\r
+\r
+from Dave Seidel\r
+\r
+   Added pcnames.bat\r
+   1. in antlr/main.c: change strcasecmp() to stricmp()\r
+\r
+   2. in dlg/output.c: use DLEXER_C instead on "DLexer.C"\r
+\r
+   3. in h/PBlackBox.h: use <iostream.h> instead of <stream.h>\r
+\r
+======================================================================\r
+1.32b4\r
+When the -ft option was used, any path prefix screwed up\r
+the gate on the .h files\r
+\r
+Fixed yet another bug due to the optimizer.\r
+\r
+The exception handling thing was a bit wacko:\r
+\r
+a : ( A B )? A B\r
+  | A C\r
+  ;\r
+  exception ...\r
+\r
+caused an exception if "A C" was the input.  In other words,\r
+it found that A C didn't match the (A B)? pred and caused\r
+an exception rather than trying the next alt.  All I did\r
+was to change the zzmatch_wsig() macros.\r
+\r
+Fixed some problems in gen.c relating to the name of token\r
+class bit sets in the output.\r
+\r
+Added the tremendously cool generalized predicate.  For the\r
+moment, I'll give this bried description.\r
+\r
+a : <<predicate>>? blah\r
+  | foo\r
+  ;\r
+\r
+This implies that (assuming blah and foo are syntactically\r
+ambiguous) "predicate" indicates the semantic validity of\r
+applying "blah".  If "predicate" is false, "foo" is attempted.\r
+\r
+Previously, you had to say:\r
+\r
+a : <<LA(1)==ID ? predicate : 1>>? ID\r
+  | ID\r
+  ;\r
+\r
+Now, you can simply use "predicate" without the ?: operator\r
+if you turn on ANTLR command line option: "-prc on".  This\r
+tells ANTLR to compute that all by itself.  It computes n\r
+tokens of lookahead where LT(n) or LATEXT(n) is the farthest\r
+ahead you look.\r
+\r
+If you give a predicate using "-prc on" that is followed\r
+by a construct that can recognize more than one n-sequence,\r
+you will get a warning from ANTLR.  For example,\r
+\r
+a : <<isTypeName(LT(1)->getText())>>? (ID|INT)\r
+  ;\r
+\r
+This is wrong because the predicate will be applied to INTs\r
+as well as ID's.  You should use this syntax to make\r
+the predicate more specific:\r
+\r
+a : (ID)? => <<isTypeName(LT(1)->getText())>>? (ID|INT)\r
+  ;\r
+\r
+which says "don't apply the predicate unless ID is the\r
+current lookahead context".\r
+\r
+You cannot currently have anything in the "(context)? =>"\r
+except sequences such as:\r
+\r
+( LPAREN ID | LPAREN SCOPE )? => <<pred>>?\r
+\r
+I haven't tested this THAT much, but it does work for the\r
+C++ grammar.\r
+\r
+======================================================================\r
+1.32b5\r
+\r
+Added getLine() to the ANTLRTokenBase and DLGBasedToken classes\r
+left line() for backward compatibility.\r
+----\r
+Removed SORCERER_TRANSFORM from the ast.h stuff.\r
+-------\r
+Fixed bug in code gen of ANTLR such that nested syn preds work more\r
+efficiently now.  The ANTLRTokenBuffer was getting very large\r
+with nested predicates.\r
+------\r
+Memory leak is now gone from ANTLRTokenBuf; all tokens are deleted.\r
+For backward compatibility reasons, you have to say parser->deleteTokens()\r
+or mytokenbuffer->deleteTokens() but later it will be the default mode.\r
+Say this after the parser is constructed. E.g.,\r
+\r
+    ParserBlackBox<DLGLexer, MyParser, ANTLRToken> p(stdin);\r
+    p.parser()->deleteTokens();\r
+    p.parser()->start_symbol();\r
+\r
+\r
+==============================\r
+1.32b6\r
+\r
+Changed so that deleteTokens() will do a delete ((ANTLRTokenBase *))\r
+on the ptr.  This gets the virtual destructor.\r
+\r
+Fixed some weird things in the C++ header files (a few return types).\r
+\r
+Made the AST routines correspond to the book and SORCERER stuff.\r
+\r
+New token stuff:  See testcpp/14/test.g\r
+\r
+ANTLR accepts a #pragma gc_tokens which says\r
+[1]     Generate label = copy(LT(1)) instead of label=LT(1) for\r
+        all labeled token references.\r
+[2]     User now has to define ANTLRTokenPtr (as a class or a typedef\r
+        to just a pointer) as well as the ANTLRToken class itself.\r
+               See the example.\r
+\r
+To delete tokens in token buffer, use deleteTokens() message on parser.\r
+\r
+        All tokens that fall off the ANTLRTokenBuffer get deleted\r
+        which is what currently happens when deleteTokens() message\r
+        has been sent to token buffer.\r
+\r
+We always generate ANTLRTokenPtr instead of 'ANTLRToken *' now.\r
+Then if no pragma set, ANTLR generates a\r
+\r
+        class ANTLRToken;\r
+        typedef ANTLRToken *ANTLRTokenPtr;\r
+\r
+in each file.\r
+\r
+Made a warning for x:rule_ref <<$x>>; still no warning for $i's, however.\r
+class BB {\r
+\r
+a : x:b y:A <<$x\r
+$y>>\r
+  ;\r
+\r
+b : B;\r
+\r
+}\r
+generates\r
+Antlr parser generator   Version 1.32b6   1989-1995\r
+test.g, line 3: error: There are no token ptrs for rule references: '$x'\r
+\r
+===================\r
+1.32b7:\r
+\r
+[With respect to token object garbage collection (GC), 1.32b7\r
+ backtracks from 1.32b6, but results in better and less intrusive GC.\r
+ This is the last beta version before full 1.32.]\r
+\r
+BIGGEST CHANGES:\r
+\r
+o      The "#pragma gc_tokens" is no longer used.\r
+\r
+o      .C files are now .cpp files (hence, makefiles will have to\r
+       be changed; or you can rerun genmk).  This is a good move,\r
+       but causes some backward incompatibility problems.  You can\r
+       avoid this by changing CPP_FILE_SUFFIX to ".C" in pccts/h/config.h.\r
+\r
+o      The token object class hierarchy has been flattened to include\r
+       only three classes: ANTLRAbstractToken, ANTLRCommonToken, and\r
+       ANTLRCommonNoRefCountToken.  The common token now does garbage\r
+       collection via ref counting.\r
+\r
+o      "Smart" pointers are now used for garbage collection.  That is,\r
+       ANTLRTokenPtr is used instead of "ANTLRToken *".\r
+\r
+o      The antlr.1 man page has been cleaned up slightly.\r
+\r
+o      The SUN C++ compiler now complains less about C++ support code.\r
+\r
+o      Grammars which subclass ANTLRCommonToken must wrap all token\r
+       pointer references in mytoken(token_ptr).  This is the only\r
+       serious backward incompatibility.  See below.\r
+\r
+\r
+MINOR CHANGES:\r
+\r
+--------------------------------------------------------\r
+1      deleteTokens()\r
+\r
+The deleteTokens() message to the parser or token buffer has been changed\r
+to one of:\r
+\r
+    void noGarbageCollectTokens()   { inputTokens->noGarbageCollectTokens(); }\r
+    void garbageCollectTokens()     { inputTokens->garbageCollectTokens(); }\r
+\r
+The token buffer deletes all non-referenced tokens by default now.\r
+\r
+--------------------------------------------------------\r
+2      makeToken()\r
+\r
+The makeToken() message returns a new type.  The function should look\r
+like:\r
+\r
+    virtual ANTLRAbstractToken *makeToken(ANTLRTokenType tt,\r
+                                          ANTLRChar *txt,\r
+                                          int line)\r
+    {\r
+        ANTLRAbstractToken *t = new ANTLRCommonToken(tt,txt);\r
+        t->setLine(line);\r
+        return t;\r
+    }\r
+\r
+--------------------------------------------------------\r
+3      TokenType\r
+\r
+Changed TokenType-> ANTLRTokenType  (often forces changes in AST defs due\r
+to #[] constructor called to AST(tokentype, string)).\r
+\r
+--------------------------------------------------------\r
+4      AST()\r
+\r
+You must define AST(ANTLRTokenPtr t) now in your AST class definition.\r
+You might also have to include ATokPtr.h above the definition; e.g.,\r
+if AST is defined in a separate file, such as AST.h, it's a good idea\r
+to include ATOKPTR_H (ATokPtr.h).  For example,\r
+\r
+       #include ATOKPTR_H\r
+       class AST : public ASTBase {\r
+       protected:\r
+           ANTLRTokenPtr token;\r
+       public:\r
+           AST(ANTLRTokenPtr t) { token = t; }\r
+           void preorder_action() {\r
+               char *s = token->getText();\r
+               printf(" %s", s);\r
+           }\r
+       };\r
+\r
+Note the use of smart pointers rather than "ANTLRToken *".\r
+\r
+--------------------------------------------------------\r
+5      SUN C++\r
+\r
+From robertb oakhill.sps.mot.com Bob Bailey. Changed ANTLR C++ output\r
+to avoid an error in Sun C++ 3.0.1.  Made "public" return value\r
+structs created to hold multiple return values public.\r
+\r
+--------------------------------------------------------\r
+6      genmk\r
+\r
+Fixed genmk so that target List.* is not included anymore.  It's\r
+called SList.* anyway.\r
+\r
+--------------------------------------------------------\r
+7      \r vs \n\r
+\r
+Scott Vorthmann <vorth cmu.edu> fixed antlr.g in ANTLR so that \r\r
+is allowed as the return character as well as \n.\r
+\r
+--------------------------------------------------------\r
+8      Exceptions\r
+\r
+Bug in exceptions attached to labeled token/tokclass references.  Didn't gen\r
+code for exceptions.  This didn't work:\r
+\r
+a : "help" x:ID\r
+  ;\r
+        exception[x]\r
+        catch MismatchedToken : <<printf("eh?\n");>>\r
+\r
+Now ANTLR generates (which is kinda big, but necessary):\r
+\r
+        if ( !_match_wsig(ID) ) {\r
+                if ( guessing ) goto fail;\r
+                _signal=MismatchedToken;\r
+                switch ( _signal ) {\r
+                case MismatchedToken :\r
+                        printf("eh?\n");\r
+                        _signal = NoSignal;\r
+                        break;\r
+                default :\r
+                        goto _handler;\r
+                }\r
+        }\r
+\r
+which implies that you can recover and continue parsing after a missing/bad\r
+token reference.\r
+\r
+--------------------------------------------------------\r
+9      genmk\r
+\r
+genmk now correctly uses config file for CPP_FILE_SUFFIX stuff.\r
+\r
+--------------------------------------------------------\r
+10     general cleanup / PURIFY\r
+\r
+Anthony Green <green vizbiz.com> suggested a bunch of good general\r
+clean up things for the code; he also suggested a few things to\r
+help out the "PURIFY" memory allocation checker.\r
+\r
+--------------------------------------------------------\r
+11     $-variable references.\r
+\r
+Manuel ORNATO indicated that a $-variable outside of a rule caused\r
+ANTLR to crash.  I fixed this.\r
+\r
+12     Tom Moog suggestion\r
+\r
+Fail action of semantic predicate needs "{}" envelope.  FIXED.\r
+\r
+13     references to LT(1).\r
+\r
+I have enclosed all assignments such as:\r
+\r
+             _t22 = (ANTLRTokenPtr)LT(1);\r
+\r
+in "if ( !guessing )" so that during backtracking the reference count\r
+for token objects is not increased.\r
+\r
+\r
+TOKEN OBJECT GARBAGE COLLECTION\r
+\r
+1      INTRODUCTION\r
+\r
+The class ANTLRCommonToken is now garbaged collected through a "smart"\r
+pointer called ANTLRTokenPtr using reference counting.  Any token\r
+object not referenced by your grammar actions is destroyed by the\r
+ANTLRTokenBuffer when it must make room for more token objects.\r
+Referenced tokens are then destroyed in your parser when local\r
+ANTLRTokenPtr objects are deleted.  For example,\r
+\r
+a : label:ID ;\r
+\r
+would be converted to something like:\r
+\r
+void yourclass::a(void)\r
+{\r
+       zzRULE;\r
+       ANTLRTokenPtr label=NULL;       // used to be ANTLRToken *label;\r
+        zzmatch(ID);\r
+        label = (ANTLRTokenPtr)LT(1);\r
+       consume();\r
+       ...\r
+}\r
+\r
+When the "label" object is destroyed (it's just a pointer to your\r
+input token object LT(1)), it decrements the reference count on the\r
+object created for the ID.  If the count goes to zero, the object\r
+pointed by label is deleted.\r
+\r
+To correctly manage the garbage collection, you should use\r
+ANTLRTokenPtr instead of "ANTLRToken *".  Most ANTLR support code\r
+(visible to the user) has been modified to use the smart pointers.\r
+\r
+***************************************************************\r
+Remember that any local objects that you create are not deleted when a\r
+lonjmp() is executed.  Unfortunately, the syntactic predicates (...)?\r
+use setjmp()/longjmp().  There are some situations when a few tokens\r
+will "leak".\r
+***************************************************************\r
+\r
+2      DETAILS\r
+\r
+o      The default is to perform token object garbage collection.\r
+       You may use parser->noGarbageCollectTokens() to turn off\r
+       garbage collection.\r
+\r
+\r
+o      The type ANTLRTokenPtr is always defined now (automatically).\r
+       If you do not wish to use smart pointers, you will have to\r
+       redefined ANTLRTokenPtr by subclassing, changing the header\r
+       file or changing ANTLR's code generation (easy enough to\r
+       do in gen.c).\r
+\r
+o      If you don't use ParserBlackBox, the new initialization sequence is:\r
+\r
+           ANTLRTokenPtr aToken = new ANTLRToken;\r
+           scan.setToken(mytoken(aToken));\r
+\r
+       where mytoken(aToken) gets an ANTLRToken * from the smart pointer.\r
+\r
+o      Define C++ preprocessor symbol DBG_REFCOUNTTOKEN to see a bunch of\r
+       debugging stuff for reference counting if you suspect something.\r
+\r
+\r
+3      WHY DO I HAVE TO TYPECAST ALL MY TOKEN POINTERS NOW??????\r
+\r
+If you subclass ANTLRCommonToken and then attempt to refer to one of\r
+your token members via a token pointer in your grammar actions, the\r
+C++ compiler will complain that your token object does not have that\r
+member.  For example, if you used to do this\r
+\r
+<<\r
+class ANTLRToken : public ANTLRCommonToken {\r
+        int muck;\r
+       ...\r
+};\r
+>>\r
+\r
+class Foo {\r
+a : t:ID << t->muck = ...; >> ;\r
+}\r
+\r
+Now, you must do change the t->muck reference to:\r
+\r
+a : t:ID << mytoken(t)->muck = ...; >> ;\r
+\r
+in order to downcast 't' to be an "ANTLRToken *" not the\r
+"ANTLRAbstractToken *" resulting from ANTLRTokenPtr::operator->().\r
+The macro is defined as:\r
+\r
+/*\r
+ * Since you cannot redefine operator->() to return one of the user's\r
+ * token object types, we must down cast.  This is a drag.  Here's\r
+ * a macro that helps.  template: "mytoken(a-smart-ptr)->myfield".\r
+ */\r
+#define mytoken(tp) ((ANTLRToken *)(tp.operator->()))\r
+\r
+You have to use macro mytoken(grammar-label) now because smart\r
+pointers are not specific to a parser's token objects.  In other\r
+words, the ANTLRTokenPtr class has a pointer to a generic\r
+ANTLRAbstractToken not your ANTLRToken; the ANTLR support code must\r
+use smart pointers too, but be able to work with any kind of\r
+ANTLRToken.  Sorry about this, but it's C++'s fault not mine.  Some\r
+nebulous future version of the C++ compilers should obviate the need\r
+to downcast smart pointers with runtime type checking (and by allowing\r
+different return type of overridden functions).\r
+\r
+A way to have backward compatible code is to shut off the token object\r
+garbage collection; i.e., use parser->noGarbageCollectTokens() and\r
+change the definition of ANTLRTokenPtr (that's why you get source code\r
+<wink>).\r
+\r
+\r
+PARSER EXCEPTION HANDLING\r
+\r
+I've noticed some weird stuff with the exception handling.  I intend\r
+to give this top priority for the "book release" of ANTLR.\r
+\r
+==========\r
+1.32 Full Release\r
+\r
+o      Changed Token class hierarchy to be (Thanks to Tom Moog):\r
+\r
+        ANTLRAbstractToken\r
+          ANTLRRefCountToken\r
+             ANTLRCommonToken\r
+          ANTLRNoRefCountCommonToken\r
+\r
+o      Added virtual panic() to ANTLRAbstractToken.  Made ANTLRParser::panic()\r
+       virtual also.\r
+\r
+o      Cleaned up the dup() stuff in AST hierarchy to use shallowCopy() to\r
+       make node copies.  John Farr at Medtronic suggested this.  I.e.,\r
+       if you want to use dup() with either ANTLR or SORCERER or -transform\r
+       mode with SORCERER, you must defined shallowCopy() as:\r
+\r
+       virtual PCCTS_AST *shallowCopy()\r
+       {\r
+           return new AST;\r
+           p->setDown(NULL);\r
+           p->setRight(NULL);\r
+           return p;\r
+       }\r
+\r
+       or\r
+\r
+       virtual PCCTS_AST *shallowCopy()\r
+       {\r
+           return new AST(*this);\r
+       }\r
+       \r
+       if you have defined a copy constructor such as\r
+\r
+       AST(const AST &t)       // shallow copy constructor\r
+       {\r
+               token = t.token;\r
+               iconst = t.iconst;\r
+               setDown(NULL);\r
+               setRight(NULL);\r
+       }\r
+\r
+o      Added a warning with -CC and -gk are used together.  This is broken,\r
+       hence a warning is appropriate.\r
+\r
+o      Added warning when #-stuff is used w/o -gt option.\r
+\r
+o      Updated MPW installation.\r
+\r
+o      "Miller, Philip W." <MILLERPW f1groups.fsd.jhuapl.edu> suggested\r
+       that genmk be use RENAME_OBJ_FLAG RENAME_EXE_FLAG instead of\r
+       hardcoding "-o" in genmk.c.\r
+\r
+o      made all exit() calls use EXIT_SUCCESS or EXIT_FAILURE.\r
+\r
+===========================================================================\r
+1.33\r
+\r
+EXIT_FAILURE and EXIT_SUCCESS were not always defined.  I had to modify\r
+a bunch of files to use PCCTS_EXIT_XXX, which forces a new version.  Sorry\r
+about that.\r
+\r
diff --git a/Tools/CodeTools/Source/Pccts/CHANGES_FROM_133.txt b/Tools/CodeTools/Source/Pccts/CHANGES_FROM_133.txt
new file mode 100644 (file)
index 0000000..2128c4f
--- /dev/null
@@ -0,0 +1,2448 @@
+=======================================================================\r
+List of Implemented Fixes and Changes for Maintenance Releases of PCCTS\r
+=======================================================================\r
+\r
+                               DISCLAIMER\r
+\r
+ The software and these notes are provided "as is".  They may include\r
+ typographical or technical errors and their authors disclaims all\r
+ liability of any kind or nature for damages due to error, fault,\r
+ defect, or deficiency regardless of cause.  All warranties of any\r
+ kind, either express or implied, including, but not limited to, the\r
+ implied  warranties of merchantability and fitness for a particular\r
+ purpose are disclaimed.\r
+\r
+\r
+        -------------------------------------------------------\r
+        Note:  Items #153 to #1 are now in a separate file named\r
+                CHANGES_FROM_133_BEFORE_MR13.txt\r
+        -------------------------------------------------------\r
+        \r
+#312. (Changed in MR33) Bug caused by change #299.\r
+\r
+       In change #299 a warning message was suppressed when there was\r
+       no LT(1) in a semantic predicate and max(k,ck) was 1.  The \r
+       changed caused the code which set a default predicate depth for\r
+       the semantic predicate to be left as 0 rather than set to 1.\r
+       \r
+       This manifested as an error at line #1559 of mrhost.c\r
+       \r
+       Reported by Peter Dulimov.\r
+           \r
+#311. (Changed in MR33) Added sorcer/lib to Makefile.\r
+\r
+    Reported by Dale Martin.\r
+            \r
+#310. (Changed in MR32) In C mode zzastPush was spelled zzastpush in one case.\r
+\r
+    Reported by Jean-Claude Durand\r
+    \r
+#309. (Changed in MR32) Renamed baseName because of VMS name conflict\r
+\r
+    Renamed baseName to pcctsBaseName to avoid library name conflict with\r
+    VMS library routine.  Reported by Jean-François PIÉRONNE.\r
+    \r
+#308. (Changed in MR32) Used "template" as name of formal in C routine\r
+\r
+       In astlib.h routine ast_scan a formal was named "template".  This caused\r
+       problems when the C code was compiled with a C++ compiler.  Reported by\r
+       Sabyasachi Dey.\r
+            \r
+#307. (Changed in MR31) Compiler dependent bug in function prototype generation\r
+    \r
+    The code which generated function prototypes contained a bug which\r
+    was compiler/optimization dependent.  Under some circumstance an\r
+    extra character would be included in portions of a function prototype.\r
+    \r
+    Reported by David Cook.\r
+    \r
+#306. (Changed in MR30) Validating predicate following a token\r
+\r
+    A validating predicate which immediately followed a token match \r
+    consumed the token after the predicate rather than before.  Prior\r
+    to this fix (in the following example) isValidTimeScaleValue() in\r
+    the predicate would test the text for TIMESCALE rather than for\r
+    NUMBER:\r
+     \r
+               time_scale :\r
+               TIMESCALE\r
+               <<isValidTimeScaleValue(LT(1)->getText())>>?\r
+               ts:NUMBER\r
+               ( us:MICROSECOND << tVal = ...>>\r
+               | ns:NANOSECOND << tVal = ...  >>\r
+               )\r
+       \r
+       Reported by Adalbert Perbandt.\r
+       \r
+#305. (Changed in MR30) Alternatives with guess blocks inside (...)* blocks.\r
+\r
+       In MR14 change #175 fixed a bug in the prediction expressions for guess\r
+       blocks which were of the form (alpha)? beta.  Unfortunately, this\r
+       resulted in a new bug as exemplified by the example below, which computed\r
+       the first set for r as {B} rather than {B C}:\r
+       \r
+                                       r : ( (A)? B\r
+                                           | C\r
+                                               )*\r
+  \r
+    This example doesn't make any sense as A is not a prefix of B, but it\r
+    illustrates the problem.  This bug did not appear for:\r
+    \r
+                               r : ( (A)?\r
+                                   | C\r
+                                   )*\r
+\r
+       because it does not use the (alpha)? beta form.\r
+\r
+       Item #175 fixed an asymmetry in ambiguity messages for the following\r
+       constructs which appear to have identical ambiguities (between repeating\r
+       the loop vs. exiting the loop).  MR30 retains this fix, but the implementation\r
+       is slightly different.\r
+       \r
+                 r_star : ( (A B)? )* A ;\r
+                 r_plus : ( (A B)? )+ A ;\r
+\r
+    Reported by Arpad Beszedes (beszedes inf.u-szeged.hu).\r
+    \r
+#304. (Changed in MR30) Crash when mismatch between output value counts.\r
+\r
+       For a rule such as:\r
+       \r
+               r1 : r2>[i,j];\r
+               r2 >[int i, int j] : A;\r
+               \r
+       If there were extra actuals for the reference to rule r2 from rule r1\r
+       there antlr would crash.  This bug was introduced by change #276.\r
+\r
+       Reported by Sinan Karasu.\r
+       \r
+#303. (Changed in MR30) DLGLexerBase::replchar\r
+\r
+       DLGLexerBase::replchar and the C mode routine zzreplchar did not work \r
+       properly when the new character was 0.\r
+      \r
+    Reported with fix by Philippe Laporte\r
+\r
+#302. (Changed in MR28) Fix significant problems in initial release of MR27.\r
+\r
+#301. (Changed in MR27) Default tab stops set to 2 spaces.\r
+\r
+    To have antlr generate true tabs rather than spaces, use "antlr -tab 0".\r
+    To generate 4 spaces per tab stop use "antlr -tab 4"\r
+    \r
+#300. (Changed in MR27)\r
+\r
+       Consider the following methods of constructing an AST from ID:\r
+       \r
+        rule1!\r
+                : id:ID << #0 = #[id]; >> ;\r
+        \r
+        rule2!\r
+                : id:ID << #0 = #id; >> ;\r
+        \r
+        rule3\r
+                : ID ;\r
+        \r
+        rule4\r
+                : id:ID << #0 = #id; >> ;\r
+        \r
+    For rule_2, the AST corresponding to id would always be NULL.  This\r
+    is because the user explicitly suppressed AST construction using the\r
+    "!" operator on the rule.  In MR27 the use of an AST expression\r
+    such as #id overrides the "!" operator and forces construction of\r
+    the AST.\r
+    \r
+    This fix does not apply to C mode ASTs when the ASTs are referenced\r
+    using numbers rather than symbols.\r
+\r
+       For C mode, this requires that the (optional) function/macro zzmk_ast\r
+       be defined.  This functions copies information from an attribute into\r
+       a previously allocated AST.\r
+\r
+    Reported by Jan Langer (jan langernetz.de)\r
+\r
+#299. (Changed in MR27) Don't warn if k=1 and semantic predicate missing LT(i)\r
+\r
+    If a semantic does not have a reference to LT(i) or (C mode LATEXT(i))\r
+    then pccts doesn't know how many lookahead tokens to use for context.\r
+    However, if max(k,ck) is 1 then there is really only one choice and\r
+    the warning is unnecessary.\r
+    \r
+#298. (Changed in MR27) Removed "register" for lastpos in dlgauto.c zzgettok\r
+\r
+#297. (Changed in MR27) Incorrect prototypes when used with classic C\r
+\r
+    There were a number of errors in function headers when antlr was\r
+    built with compilers that do not have __STDC__ or __cplusplus set.\r
+    \r
+    The functions which have variable length argument lists now use\r
+    PCCTS_USE_STDARG rather than __USE_PROTOTYPES__ to determine\r
+    whether to use stdargs or varargs.\r
+\r
+#296. (Changed in MR27) Complex return types in rules.\r
+\r
+    The following return type was not properly handled when \r
+    unpacking a struct with containing multiple return values:\r
+    \r
+      rule > [int i, IIR_Bool (IIR_Decl::*constraint)()] : ...    \r
+\r
+    Instead of using "constraint", the program got lost and used\r
+    an empty string.\r
+    \r
+    Reported by P.A. Wilsey.\r
+\r
+#295. (Changed in MR27) Extra ";" following zzGUESS_DONE sometimes.\r
+\r
+    Certain constructs with guess blocks in MR23 led to extra ";"\r
+    preceding the "else" clause of an "if".\r
+\r
+    Reported by P.A. Wilsey.\r
+    \r
+#294. (Changed in MR27) Infinite loop in antlr for nested blocks\r
+\r
+    An oversight in detecting an empty alternative sometimes led\r
+    to an infinite loop in antlr when it encountered a rule with\r
+    nested blocks and guess blocks.\r
+    \r
+    Reported by P.A. Wilsey.\r
+    \r
+#293. (Changed in MR27) Sorcerer optimization of _t->type()\r
+\r
+    Sorcerer generated code may contain many calls to _t->type() in a\r
+    single statement.  This change introduces a temporary variable\r
+    to eliminate unnnecesary function calls.\r
+\r
+    Change implemented by Tom Molteno (tim videoscript.com).\r
+\r
+#292. (Changed in MR27)\r
+\r
+    WARNING:  Item #267 changes the signature of methods in the AST class.\r
+\r
+    **** Be sure to revise your AST functions of the same name  ***\r
+\r
+#291. (Changed in MR24)\r
+\r
+    Fix to serious code generation error in MR23 for (...)+ block.\r
+\r
+#290. (Changed in MR23) \r
+\r
+    Item #247 describes a change in the way {...} blocks handled\r
+    an error.  Consider:\r
+\r
+            r1 : {A} b ;\r
+            b  : B;\r
+                \r
+                with input "C".\r
+\r
+    Prior to change #247, the error would resemble "expected B -\r
+    found C".  This is correct but incomplete, and therefore\r
+    misleading.  In #247 it was changed to "expected A, B - found\r
+    C".  This was fine, except for users of parser exception\r
+    handling because the exception was generated in the epilogue \r
+    for {...} block rather than in rule b.  This made it difficult\r
+    for users of parser exception handling because B was not\r
+    expected in that context. Those not using parser exception\r
+    handling didn't notice the difference.\r
+\r
+    The current change restores the behavior prior to #247 when\r
+    parser exceptions are present, but retains the revised behavior\r
+    otherwise.  This change should be visible only when exceptions\r
+    are in use and only for {...} blocks and sub-blocks of the form\r
+    (something|something | something | epsilon) where epsilon represents\r
+    an empty production and it is the last alternative of a sub-block.\r
+    In contrast, (something | epsilon | something) should generate the\r
+    same code as before, even when exceptions are used.\r
+    \r
+    Reported by Philippe Laporte (philippe at transvirtual.com).\r
+\r
+#289. (Changed in MR23) Bug in matching complement of a #tokclass\r
+\r
+    Prior to MR23 when a #tokclass was matched in both its complemented form\r
+    and uncomplemented form, the bit set generated for its first use was used\r
+    for both cases.  However, the prediction expression was correctly computed\r
+    in both cases.  This meant that the second case would never be matched\r
+    because, for the second appearance, the prediction expression and the \r
+    set to be matched would be complements of each other.\r
+        \r
+    Consider:\r
+        \r
+                #token A "a"\r
+                #token B "b"\r
+                #token C "c"\r
+                #tokclass AB {A B}\r
+                \r
+                r1 : AB    /* alt 1x */\r
+                   | ~AB   /* alt 1y */\r
+                   ;\r
+        \r
+    Prior to MR23, this resulted in alternative 1y being unreachable.  Had it\r
+    been written:\r
+        \r
+                r2 : ~AB  /* alt 2x */\r
+                   : AB   /* alt 2y */\r
+                   \r
+    then alternative 2y would have become unreachable.        \r
+        \r
+    This bug was only for the case of complemented #tokclass.  For complemented\r
+    #token the proper code was generated.           \r
+        \r
+#288. (Changed in MR23) #errclass not restricted to choice points\r
+\r
+    The #errclass directive is supposed to allow a programmer to define\r
+    print strings which should appear in syntax error messages as a replacement\r
+    for some combinations of tokens. For instance:\r
+    \r
+            #errclass Operator {PLUS MINUS TIMES DIVIDE}\r
+            \r
+    If a syntax message includes all four of these tokens, and there is no\r
+    "better" choice of error class, the word "Operator" will be used rather\r
+    than a list of the four token names.\r
+        \r
+    Prior to MR23 the #errclass definitions were used only at choice points\r
+    (which call the FAIL macro). In other cases where there was no choice\r
+    (e.g. where a single token or token class were matched) the #errclass\r
+    information was not used.\r
+\r
+    With MR23 the #errclass declarations are used for syntax error messages\r
+    when matching a #tokclass, a wildcard (i.e. "*"), or the complement of a\r
+    #token or #tokclass (e.g. ~Operator).\r
+\r
+    Please note that #errclass may now be defined using #tokclass names \r
+    (see Item #284).\r
+\r
+    Reported by Philip A. Wilsey.\r
+\r
+#287. (Changed in MR23) Print name for #tokclass\r
+\r
+    Item #148 describes how to give a print name to a #token so that,for\r
+    example, #token ID could have the expression "identifier" in syntax\r
+    error messages.  This has been extended to #tokclass:\r
+    \r
+            #token ID("identifier")  "[a-zA-Z]+"\r
+            #tokclass Primitive("primitive type") \r
+                                    {INT, FLOAT, CHAR, FLOAT, DOUBLE, BOOL} \r
+\r
+    This is really a cosmetic change, since #tokclass names do not appear\r
+    in any error messages.\r
+        \r
+#286. (Changed in MR23) Makefile change to use of cd\r
+\r
+    In cases where a pccts subdirectory name matched a directory identified\r
+    in a $CDPATH environment variable the build would fail.  All makefile\r
+    cd commands have been changed from "cd xyz" to "cd ./xyz" in order\r
+    to avoid this problem.\r
+        \r
+#285. (Changed in MR23) Check for null pointers in some dlg structures\r
+\r
+    An invalid regular expression can cause dlg to build an invalid\r
+    structure to represent the regular expression even while it issues \r
+    error messages.  Additional pointer checks were added.\r
+\r
+    Reported by Robert Sherry.\r
+\r
+#284. (Changed in MR23) Allow #tokclass in #errclass definitions\r
+\r
+    Previously, a #tokclass reference in the definition of an\r
+    #errclass was not handled properly. Instead of being expanded\r
+    into the set of tokens represented by the #tokclass it was\r
+    treated somewhat like an #errclass.  However, in a later phase\r
+    when all #errclass were expanded into the corresponding tokens\r
+    the #tokclass reference was not expanded (because it wasn't an\r
+    #errclass).  In effect the reference was ignored.\r
+\r
+    This has been fixed.\r
+\r
+    Problem reported by Mike Dimmick (mike dimmick.demon.co.uk).\r
+\r
+#283. (Changed in MR23) Option -tmake invoke's parser's tmake \r
+\r
+    When the string #(...) appears in an action antlr replaces it with\r
+    a call to ASTBase::tmake(...) to construct an AST.  It is sometimes\r
+    useful to change the tmake routine so that it has access to information\r
+    in the parser - something which is not possible with a static method\r
+    in an application where they may be multiple parsers active.\r
+\r
+    The antlr option -tmake replaces the call to ASTBase::tmake with a call\r
+    to a user supplied tmake routine.\r
+   \r
+#282. (Changed in MR23) Initialization error for DBG_REFCOUNTTOKEN\r
+\r
+    When the pre-processor symbol DBG_REFCOUNTTOKEN is defined \r
+    incorrect code is generated to initialize ANTLRRefCountToken::ctor and\r
+    dtor.\r
+\r
+    Fix reported by Sven Kuehn (sven sevenkuehn.de).\r
+   \r
+#281. (Changed in MR23) Addition of -noctor option for Sorcerer\r
+\r
+    Added a -noctor option to suppress generation of the blank ctor\r
+    for users who wish to define their own ctor.\r
+\r
+    Contributed by Jan Langer (jan langernetz.de).\r
+\r
+#280. (Changed in MR23) Syntax error message for EOF token\r
+\r
+    The EOF token now receives special treatment in syntax error messages\r
+    because there is no text matched by the eof token.  The token name\r
+    of the eof token is used unless it is "@" - in which case the string\r
+    "<eof>" is used.\r
+\r
+    Problem reported by Erwin Achermann (erwin.achermann switzerland.org).\r
+\r
+#279. (Changed in MR23) Exception groups\r
+\r
+    There was a bug in the way that exception groups were attached to\r
+    alternatives which caused problems when there was a block contained\r
+    in an alternative.  For instance, in the following rule;\r
+\r
+        statement : IF S { ELSE S } \r
+                        exception ....\r
+        ;\r
+\r
+    the exception would be attached to the {...} block instead of the \r
+    entire alternative because it was attached, in error, to the last\r
+    alternative instead of the last OPEN alternative.\r
+\r
+    Reported by Ty Mordane (tymordane hotmail.com).\r
+    \r
+#278. (Changed in MR23) makefile changes\r
+\r
+    Contributed by Tomasz Babczynski (faster lab05-7.ict.pwr.wroc.pl).\r
+\r
+    The -cfile option is not absolutely needed: when extension of\r
+    source file is one of the well-known C/C++ extensions it is \r
+    treated as C/C++ source\r
+\r
+    The gnu make defines the CXX variable as the default C++ compiler\r
+    name, so I added a line to copy this (if defined) to the CCC var.\r
+\r
+    Added a -sor option: after it any -class command defines the class\r
+    name for sorcerer, not for ANTLR.  A file extended with .sor is \r
+    treated as sorcerer input.  Because sorcerer can be called multiple\r
+    times, -sor option can be repeated.  Any files and classes (one class\r
+    per group) after each -sor makes one tree parser.\r
+\r
+    Not implemented:\r
+\r
+        1. Generate dependences for user c/c++ files.\r
+        2. Support for -sor in c mode not.\r
+\r
+    I have left the old genmk program in the directory as genmk_old.c.\r
+\r
+#277. (Changed in MR23) Change in macro for failed semantic predicates\r
+\r
+    In the past, a semantic predicate that failed generated a call to\r
+    the macro zzfailed_pred:\r
+\r
+        #ifndef zzfailed_pred\r
+        #define zzfailed_pred(_p) \\r
+          if (guessing) { \\r
+            zzGUESS_FAIL; \\r
+          } else { \\r
+            something(_p)\r
+          }\r
+        #endif\r
+\r
+    If a user wished to use the failed action option for semantic predicates:\r
+\r
+        rule : <<my_predicate>>? [my_fail_action] A\r
+             | ...\r
+\r
+           \r
+    the code for my_fail_action would have to contain logic for handling\r
+    the guess part of the zzfailed_pred macro.  The user should not have\r
+    to be aware of the guess logic in writing the fail action.\r
+\r
+    The zzfailed_pred has been rewritten to have three arguments:\r
+\r
+            arg 1: the stringized predicate of the semantic predicate\r
+            arg 2: 0 => there is no user-defined fail action\r
+                   1 => there is a user-defined fail action\r
+            arg 3: the user-defined fail action (if defined)\r
+                   otherwise a no-operation\r
+\r
+    The zzfailed_pred macro is now defined as:\r
+\r
+        #ifndef zzfailed_pred\r
+        #define zzfailed_pred(_p,_hasuseraction,_useraction) \\r
+          if (guessing) { \\r
+            zzGUESS_FAIL; \\r
+          } else { \\r
+            zzfailed_pred_action(_p,_hasuseraction,_useraction) \\r
+          }\r
+        #endif\r
+\r
+\r
+    With zzfailed_pred_action defined as:\r
+\r
+        #ifndef zzfailed_pred_action\r
+        #define zzfailed_pred_action(_p,_hasuseraction,_useraction) \\r
+            if (_hasUserAction) { _useraction } else { failedSemanticPredicate(_p); }\r
+        #endif\r
+\r
+    In C++ mode failedSemanticPredicate() is a virtual function.\r
+    In C mode the default action is a fprintf statement.\r
+\r
+    Suggested by Erwin Achermann (erwin.achermann switzerland.org).\r
+\r
+#276. (Changed in MR23) Addition of return value initialization syntax\r
+\r
+    In an attempt to reduce the problems caused by the PURIFY macro I have\r
+    added new syntax for initializing the return value of rules and the\r
+    antlr option "-nopurify".\r
+\r
+    A rule with a single return argument:\r
+\r
+        r1 > [Foo f = expr] :\r
+\r
+    now generates code that resembles:\r
+\r
+        Foo r1(void) {\r
+          Foo _retv = expr;\r
+          ...\r
+        }\r
+  \r
+    A rule with more than one return argument:\r
+\r
+        r2 > [Foo f = expr1, Bar b = expr2 ] :\r
+\r
+    generates code that resembles:\r
+\r
+        struct _rv1 {\r
+            Foo f;\r
+            Bar b;\r
+        }\r
+\r
+        _rv1 r2(void) {\r
+          struct _rv1 _retv;\r
+          _retv.f = expr1;\r
+          _retv.b = expr2;\r
+          ...\r
+        }\r
+\r
+    C++ style comments appearing in the initialization list may cause problems.\r
+\r
+#275. (Changed in MR23) Addition of -nopurify option to antlr\r
+\r
+    A long time ago the PURIFY macro was introduced to initialize\r
+    return value arguments and get rid of annying messages from program\r
+    that checked for unitialized variables.\r
+\r
+    This has caused significant annoyance for C++ users that had\r
+    classes with virtual functions or non-trivial contructors because\r
+    it would zero the object, including the pointer to the virtual\r
+    function table.  This could be defeated by redefining\r
+    the PURIFY macro to be empty, but it was a constant surprise to\r
+    new C++ users of pccts.\r
+\r
+    I would like to remove it, but I fear that some existing programs\r
+    depend on it and would break.  My temporary solution is to add\r
+    an antlr option -nopurify which disables generation of the PURIFY\r
+    macro call.\r
+\r
+    The PURIFY macro should be avoided in favor of the new syntax\r
+    for initializing return arguments described in item #275.\r
+\r
+    To avoid name clash, the PURIFY macro has been renamed PCCTS_PURIFY.\r
+\r
+#274. (Changed in MR23) DLexer.cpp renamed to DLexer.h\r
+      (Changed in MR23) ATokPtr.cpp renamed to ATokPtrImpl.h\r
+\r
+    These two files had .cpp extensions but acted like .h files because\r
+    there were included in other files. This caused problems for many IDE.\r
+    I have renamed them.  The ATokPtrImpl.h was necessary because there was\r
+    already an ATokPtr.h.\r
+\r
+#273. (Changed in MR23) Default win32 library changed to multi-threaded DLL\r
+\r
+    The model used for building the Win32 debug and release libraries has changed\r
+    to multi-threaded DLL.\r
+\r
+    To make this change in your MSVC 6 project:\r
+\r
+        Project -> Settings\r
+        Select the C++ tab in the right pane of the dialog box\r
+        Select "Category: Code Generation"\r
+        Under "Use run-time library" select one of the following:\r
+\r
+            Multi-threaded DLL\r
+            Debug Multi-threaded DLL\r
+           \r
+    Suggested by Bill Menees (bill.menees gogallagher.com) \r
+    \r
+#272. (Changed in MR23) Failed semantic predicate reported via virtual function\r
+\r
+    In the past, a failed semantic predicated reported the problem via a\r
+    macro which used fprintf().  The macro now expands into a call on \r
+    the virtual function ANTLRParser::failedSemanticPredicate().\r
+\r
+#271. (Changed in MR23) Warning for LT(i), LATEXT(i) in token match actions\r
+\r
+    An bug (or at least an oddity) is that a reference to LT(1), LA(1),\r
+    or LATEXT(1) in an action which immediately follows a token match\r
+    in a rule refers to the token matched, not the token which is in\r
+    the lookahead buffer.  Consider:\r
+\r
+        r : abc <<action alpha>> D <<action beta>> E;\r
+\r
+    In this case LT(1) in action alpha will refer to the next token in\r
+    the lookahead buffer ("D"), but LT(1) in action beta will refer to\r
+    the token matched by D - the preceding token.\r
+\r
+    A warning has been added for users about this when an action\r
+    following a token match contains a reference to LT(1), LA(1), or LATEXT(1).\r
+\r
+    This behavior should be changed, but it appears in too many programs\r
+    now.  Another problem, perhaps more significant, is that the obvious\r
+    fix (moving the consume() call to before the action) could change the \r
+    order in which input is requested and output appears in existing programs.\r
+\r
+    This problem was reported, along with a fix by Benjamin Mandel\r
+    (beny sd.co.il).  However, I felt that changing the behavior was too\r
+    dangerous for existing code.\r
+\r
+#270. (Changed in MR23) Removed static objects from PCCTSAST.cpp\r
+\r
+    There were some statically allocated objects in PCCTSAST.cpp\r
+    These were changed to non-static.\r
+\r
+#269. (Changed in MR23) dlg output for initializing static array\r
+\r
+    The output from dlg contains a construct similar to the\r
+    following:\r
+   \r
+        struct XXX {\r
+          static const int size;\r
+          static int array1[5];\r
+        };\r
+\r
+        const int XXX::size = 4;\r
+        int XXX::array1[size+1];\r
+\r
+    \r
+    The problem is that although the expression "size+1" used in\r
+    the definition of array1 is equal to 5 (the expression used to\r
+    declare array), it is not considered equivalent by some compilers.\r
+\r
+    Reported with fix by Volker H. Simonis (simonis informatik.uni-tuebingen.de)\r
+\r
+#268. (Changed in MR23) syn() routine output when k > 1\r
+\r
+    The syn() routine is supposed to print out the text of the\r
+    token causing the syntax error.  It appears that it always\r
+    used the text from the first lookahead token rather than the\r
+    appropriate one.  The appropriate one is computed by comparing\r
+    the token codes of lookahead token i (for i = 1 to k) with\r
+    the FIRST(i) set.\r
+    \r
+    This has been corrected in ANTLRParser::syn().\r
+\r
+    Reported by Bill Menees (bill.menees gogallagher.com) \r
+\r
+#267. (Changed in MR23) AST traversal functions client data argument\r
+\r
+    The AST traversal functions now take an extra (optional) parameter\r
+    which can point to client data:\r
+\r
+        preorder_action(void* pData = NULL)\r
+        preorder_before_action(void* pData = NULL)\r
+        preorder_after_action(void* pData = NULL)\r
+\r
+    ****       Warning: this changes the AST signature.         ***\r
+    **** Be sure to revise your AST functions of the same name  ***\r
+\r
+    Bill Menees (bill.menees gogallagher.com) \r
+    \r
+#266. (Changed in MR23) virtual function printMessage()\r
+\r
+    Bill Menees (bill.menees gogallagher.com) has completed the\r
+    tedious taks of replacing all calls to fprintf() with calls\r
+    to the virtual function printMessage().  For classes which\r
+    have a pointer to the parser it forwards the printMessage()\r
+    call to the parser's printMessage() routine.\r
+\r
+    This should make it significanly easier to redirect pccts\r
+    error and warning messages.\r
+\r
+#265. (Changed in MR23) Remove "labase++" in C++ mode\r
+\r
+    In C++ mode labase++ is called when a token is matched.\r
+    It appears that labase is not used in C++ mode at all, so\r
+    this code has been commented out.\r
+    \r
+#264. (Changed in MR23) Complete rewrite of ParserBlackBox.h\r
+\r
+    The parser black box (PBlackBox.h) was completely rewritten\r
+    by Chris Uzdavinis (chris atdesk.com) to improve its robustness.\r
+\r
+#263. (Changed in MR23) -preamble and -preamble_first rescinded\r
+\r
+    Changes for item #253 have been rescinded.\r
+\r
+#262. (Changed in MR23) Crash with -alpha option during traceback\r
+\r
+    Under some circumstances a -alpha traceback was started at the\r
+    "wrong" time.  As a result, internal data structures were not\r
+    initialized.\r
+\r
+    Reported by Arpad Beszedes (beszedes inf.u-szeged.hu).\r
+\r
+#261. (Changed in MR23) Defer token fetch for C++ mode\r
+\r
+    Item #216 has been revised to indicate that use of the defer fetch\r
+    option (ZZDEFER_FETCH) requires dlg option -i.\r
+\r
+#260. (MR22) Raise default lex buffer size from 8,000 to 32,000 bytes.\r
+\r
+    ZZLEXBUFSIZE is the size (in bytes) of the buffer used by dlg \r
+    generated lexers.  The default value has been raised to 32,000 and\r
+    the value used by antlr, dlg, and sorcerer has also been raised to\r
+    32,000.\r
+\r
+#259. (MR22) Default function arguments in C++ mode.\r
+\r
+    If a rule is declared:\r
+\r
+            rr [int i = 0] : ....\r
+\r
+    then the declaration generated by pccts resembles:\r
+\r
+            void rr(int i = 0);\r
+\r
+    however, the definition must omit the default argument:\r
+\r
+            void rr(int i) {...}\r
+\r
+    In the past the default value was not omitted.  In MR22\r
+    the generated code resembles:\r
+\r
+            void rr(int i /* = 0 */ ) {...}\r
+\r
+    Implemented by Volker H. Simonis (simonis informatik.uni-tuebingen.de)\r
+\r
+\r
+    Note: In MR23 this was changed so that nested C style comments\r
+    ("/* ... */") would not cause problems.\r
+\r
+#258. (MR22)  Using a base class for your parser\r
+\r
+    In item #102 (MR10) the class statement was extended to allow one\r
+    to specify a base class other than ANTLRParser for the generated\r
+    parser.  It turned out that this was less than useful because\r
+    the constructor still specified ANTLRParser as the base class.\r
+\r
+    The class statement now uses the first identifier appearing after\r
+    the ":" as the name of the base class.  For example:\r
+\r
+        class MyParser : public FooParser {\r
+\r
+    Generates in MyParser.h:\r
+\r
+            class MyParser : public FooParser {\r
+\r
+    Generates in MyParser.cpp something that resembles:\r
+\r
+            MyParser::MyParser(ANTLRTokenBuffer *input) :\r
+                                         FooParser(input,1,0,0,4)\r
+            {\r
+                token_tbl = _token_tbl;\r
+                traceOptionValueDefault=1;    // MR10 turn trace ON\r
+            }\r
+\r
+    The base class constructor must have a signature similar to\r
+    that of ANTLRParser.\r
+\r
+#257. (MR21a) Removed dlg statement that -i has no effect in C++ mode.\r
+\r
+    This was incorrect.\r
+\r
+#256. (MR21a) Malformed syntax graph causes crash after error message.\r
+\r
+    In the past, certain kinds of errors in the very first grammar\r
+    element could cause the construction of a malformed graph \r
+    representing the grammar.  This would eventually result in a\r
+    fatal internal error.  The code has been changed to be more\r
+    resistant to this particular error.\r
+\r
+#255. (MR21a) ParserBlackBox(FILE* f) \r
+\r
+    This constructor set openByBlackBox to the wrong value.\r
+\r
+    Reported by Kees Bakker (kees_bakker tasking.nl).\r
+\r
+#254. (MR21a) Reporting syntax error at end-of-file\r
+\r
+    When there was a syntax error at the end-of-file the syntax\r
+    error routine would substitute "<eof>" for the programmer's\r
+    end-of-file symbol.  This substitution is now done only when\r
+    the programmer does not define his own end-of-file symbol\r
+    or the symbol begins with the character "@".\r
+\r
+    Reported by Kees Bakker (kees_bakker tasking.nl).\r
+\r
+#253. (MR21) Generation of block preamble (-preamble and -preamble_first)\r
+\r
+        *** This change was rescinded by item #263 ***\r
+\r
+    The antlr option -preamble causes antlr to insert the code\r
+    BLOCK_PREAMBLE at the start of each rule and block.  It does\r
+    not insert code before rules references, token references, or\r
+    actions.  By properly defining the macro BLOCK_PREAMBLE the\r
+    user can generate code which is specific to the start of blocks.\r
+\r
+    The antlr option -preamble_first is similar, but inserts the\r
+    code BLOCK_PREAMBLE_FIRST(PreambleFirst_123) where the symbol\r
+    PreambleFirst_123 is equivalent to the first set defined by\r
+    the #FirstSetSymbol described in Item #248.\r
+\r
+    I have not investigated how these options interact with guess\r
+    mode (syntactic predicates).\r
+\r
+#252. (MR21) Check for null pointer in trace routine\r
+\r
+    When some trace options are used when the parser is generated\r
+    without the trace enabled, the current rule name may be a\r
+    NULL pointer.  A guard was added to check for this in\r
+    restoreState.\r
+\r
+    Reported by Douglas E. Forester (dougf projtech.com).\r
+\r
+#251. (MR21) Changes to #define zzTRACE_RULES\r
+\r
+    The macro zzTRACE_RULES was being use to pass information to\r
+    AParser.h.  If this preprocessor symbol was not properly\r
+    set the first time AParser.h was #included, the declaration\r
+    of zzTRACEdata would be omitted (it is used by the -gd option).\r
+    Subsequent #includes of AParser.h would be skipped because of \r
+    the #ifdef guard, so the declaration of zzTracePrevRuleName would\r
+    never be made.  The result was that proper compilation was very \r
+    order dependent.\r
+\r
+    The declaration of zzTRACEdata was made unconditional and the\r
+    problem of removing unused declarations will be left to optimizers.\r
+    \r
+    Diagnosed by Douglas E. Forester (dougf projtech.com).\r
+\r
+#250. (MR21) Option for EXPERIMENTAL change to error sets for blocks\r
+\r
+    The antlr option -mrblkerr turns on an experimental feature\r
+    which is supposed to provide more accurate syntax error messages\r
+    for k=1, ck=1 grammars.  When used with k>1 or ck>1 grammars the\r
+    behavior should be no worse than the current behavior.\r
+\r
+    There is no problem with the matching of elements or the computation\r
+    of prediction expressions in pccts.  The task is only one of listing\r
+    the most appropriate tokens in the error message.  The error sets used\r
+    in pccts error messages are approximations of the exact error set when\r
+    optional elements in (...)* or (...)+ are involved.  While entirely\r
+    correct, the error messages are sometimes not 100% accurate.  \r
+\r
+    There is also a minor philosophical issue.  For example, suppose the\r
+    grammar expects the token to be an optional A followed by Z, and it \r
+    is X.  X, of course, is neither A nor Z, so an error message is appropriate.\r
+    Is it appropriate to say "Expected Z" ?  It is correct, it is accurate,\r
+    but it is not complete.  \r
+\r
+    When k>1 or ck>1 the problem of providing the exactly correct\r
+    list of tokens for the syntax error messages ends up becoming\r
+    equivalent to evaluating the prediction expression for the\r
+    alternatives twice. However, for k=1 ck=1 grammars the prediction\r
+    expression can be computed easily and evaluated cheaply, so I\r
+    decided to try implementing it to satisfy a particular application.\r
+    This application uses the error set in an interactive command language\r
+    to provide prompts which list the alternatives available at that\r
+    point in the parser.  The user can then enter additional tokens to\r
+    complete the command line.  To do this required more accurate error \r
+    sets then previously provided by pccts.\r
+\r
+    In some cases the default pccts behavior may lead to more robust error\r
+    recovery or clearer error messages then having the exact set of tokens.\r
+    This is because (a) features like -ge allow the use of symbolic names for\r
+    certain sets of tokens, so having extra tokens may simply obscure things\r
+    and (b) the error set is use to resynchronize the parser, so a good\r
+    choice is sometimes more important than having the exact set.\r
+\r
+    Consider the following example:\r
+\r
+            Note:  All examples code has been abbreviated\r
+            to the absolute minimum in order to make the\r
+            examples concise.\r
+\r
+        star1 : (A)* Z;\r
+\r
+    The generated code resembles:\r
+\r
+           old                new (with -mrblkerr)\r
+        --//-----------         --------------------\r
+        for (;;) {            for (;;) {\r
+            match(A);           match(A);\r
+        }                     }\r
+        match(Z);             if (! A and ! Z) then\r
+                                FAIL(...{A,Z}...);\r
+                              }\r
+                              match(Z);\r
+\r
+\r
+        With input X\r
+            old message: Found X, expected Z\r
+            new message: Found X, expected A, Z\r
+\r
+    For the example:\r
+\r
+        star2 : (A|B)* Z;\r
+\r
+           old                      new (with -mrblkerr)\r
+        -------------               --------------------\r
+        for (;;) {                  for (;;) {\r
+          if (!A and !B) break;       if (!A and !B) break;\r
+          if (...) {                  if (...) {\r
+            <same ...>                  <same ...>\r
+          }                           }\r
+          else {                      else {\r
+            FAIL(...{A,B,Z}...)         FAIL(...{A,B}...);\r
+          }                           }\r
+        }                           }\r
+        match(B);                   if (! A and ! B and !Z) then\r
+                                        FAIL(...{A,B,Z}...);\r
+                                    }\r
+                                    match(B);\r
+\r
+        With input X\r
+            old message: Found X, expected Z\r
+            new message: Found X, expected A, B, Z\r
+        With input A X\r
+            old message: Found X, expected Z\r
+            new message: Found X, expected A, B, Z\r
+\r
+            This includes the choice of looping back to the\r
+            star block.\r
+\r
+    The code for plus blocks:\r
+\r
+        plus1 : (A)+ Z;\r
+\r
+    The generated code resembles:\r
+\r
+           old                  new (with -mrblkerr)\r
+        -------------           --------------------\r
+        do {                    do {\r
+          match(A);               match(A);\r
+        } while (A)             } while (A)\r
+        match(Z);               if (! A and ! Z) then\r
+                                  FAIL(...{A,Z}...);\r
+                                }\r
+                                match(Z);\r
+\r
+        With input A X\r
+            old message: Found X, expected Z\r
+            new message: Found X, expected A, Z\r
+\r
+            This includes the choice of looping back to the\r
+            plus block.\r
+\r
+    For the example:\r
+\r
+        plus2 : (A|B)+ Z;\r
+\r
+           old                    new (with -mrblkerr)\r
+        -------------             --------------------\r
+        do {                        do {\r
+          if (A) {                    <same>\r
+            match(A);                 <same>\r
+          } else if (B) {             <same>\r
+            match(B);                 <same>\r
+          } else {                    <same>\r
+            if (cnt > 1) break;       <same>\r
+            FAIL(...{A,B,Z}...)         FAIL(...{A,B}...);\r
+          }                           }\r
+          cnt++;                      <same>\r
+        }                           }\r
+\r
+        match(Z);                   if (! A and ! B and !Z) then\r
+                                        FAIL(...{A,B,Z}...);\r
+                                    }\r
+                                    match(B);\r
+\r
+        With input X\r
+            old message: Found X, expected A, B, Z\r
+            new message: Found X, expected A, B\r
+        With input A X\r
+            old message: Found X, expected Z\r
+            new message: Found X, expected A, B, Z\r
+\r
+            This includes the choice of looping back to the\r
+            star block.\r
+    \r
+#249. (MR21) Changes for DEC/VMS systems\r
+\r
+    Jean-François Piéronne (jfp altavista.net) has updated some\r
+    VMS related command files and fixed some minor problems related\r
+    to building pccts under the DEC/VMS operating system.  For DEC/VMS\r
+    users the most important differences are:\r
+\r
+        a.  Revised makefile.vms\r
+        b.  Revised genMMS for genrating VMS style makefiles.\r
+\r
+#248. (MR21) Generate symbol for first set of an alternative\r
+\r
+    pccts can generate a symbol which represents the tokens which may\r
+    appear at the start of a block:\r
+\r
+        rr : #FirstSetSymbol(rr_FirstSet)  ( Foo | Bar ) ;\r
+\r
+    This will generate the symbol rr_FirstSet of type SetWordType with\r
+    elements Foo and Bar set. The bits can be tested using code similar \r
+    to the following:\r
+\r
+        if (set_el(Foo, &rr_FirstSet)) { ...\r
+\r
+    This can be combined with the C array zztokens[] or the C++ routine\r
+    tokenName() to get the print name of the token in the first set.\r
+\r
+    The size of the set is given by the newly added enum SET_SIZE, a \r
+    protected member of the generated parser's class.  The number of\r
+    elements in the generated set will not be exactly equal to the \r
+    value of SET_SIZE because of synthetic tokens created by #tokclass,\r
+    #errclass, the -ge option, and meta-tokens such as epsilon, and\r
+    end-of-file.\r
+\r
+    The #FirstSetSymbol must appear immediately before a block\r
+    such as (...)+, (...)*, and {...}, and (...).  It may not appear\r
+    immediately before a token, a rule reference, or action.  However\r
+    a token or rule reference can be enclosed in a (...) in order to\r
+    make the use of #pragma FirstSetSymbol legal.\r
+\r
+            rr_bad : #FirstSetSymbol(rr_bad_FirstSet) Foo;   //  Illegal\r
+\r
+            rr_ok :  #FirstSetSymbol(rr_ok_FirstSet) (Foo);  //  Legal\r
+    \r
+    Do not confuse FirstSetSymbol sets with the sets used for testing\r
+    lookahead. The sets used for FirstSetSymbol have one element per bit,\r
+    so the number of bytes  is approximately the largest token number\r
+    divided by 8.  The sets used for testing lookahead store 8 lookahead \r
+    sets per byte, so the length of the array is approximately the largest\r
+    token number.\r
+\r
+    If there is demand, a similar routine for follow sets can be added.\r
+\r
+#247. (MR21) Misleading error message on syntax error for optional elements.\r
+\r
+        ===================================================\r
+        The behavior has been revised when parser exception\r
+        handling is used.  See Item #290\r
+        ===================================================\r
+\r
+    Prior to MR21, tokens which were optional did not appear in syntax\r
+    error messages if the block which immediately followed detected a \r
+    syntax error.\r
+\r
+    Consider the following grammar which accepts Number, Word, and Other:\r
+\r
+            rr : {Number} Word;\r
+\r
+    For this rule the code resembles:\r
+\r
+            if (LA(1) == Number) {\r
+                match(Number);\r
+                consume();\r
+            }\r
+            match(Word);\r
+\r
+    Prior to MR21, the error message for input "$ a" would be:\r
+\r
+            line 1: syntax error at "$" missing Word\r
+\r
+    With MR21 the message will be:\r
+\r
+            line 1: syntax error at "$" expecting Word, Number.\r
+\r
+    The generate code resembles:\r
+\r
+            if ( (LA(1)==Number) ) {\r
+                zzmatch(Number);\r
+                consume();\r
+            }\r
+            else {\r
+                if ( (LA(1)==Word) ) {\r
+                    /* nothing */\r
+                }\r
+                else {\r
+                    FAIL(... message for both Number and Word ...);\r
+                }\r
+            }\r
+            match(Word);\r
+        \r
+    The code generated for optional blocks in MR21 is slightly longer\r
+    than the previous versions, but it should give better error messages.\r
+\r
+    The code generated for:\r
+\r
+            { a | b | c }\r
+\r
+    should now be *identical* to:\r
+\r
+            ( a | b | c | )\r
+\r
+    which was not the case prior to MR21.\r
+\r
+    Reported by Sue Marvin (sue siara.com).\r
+\r
+#246. (Changed in MR21) Use of $(MAKE) for calls to make\r
+\r
+    Calls to make from the makefiles were replaced with $(MAKE)\r
+    because of problems when using gmake.\r
+\r
+    Reported with fix by Sunil K.Vallamkonda (sunil siara.com).\r
+\r
+#245. (Changed in MR21) Changes to genmk\r
+\r
+    The following command line options have been added to genmk:\r
+\r
+        -cfiles ... \r
+            \r
+            To add a user's C or C++ files into makefile automatically.\r
+            The list of files must be enclosed in apostrophes.  This\r
+            option may be specified multiple times.\r
+\r
+        -compiler ...\r
+    \r
+            The name of the compiler to use for $(CCC) or $(CC).  The\r
+            default in C++ mode is "CC".  The default in C mode is "cc".\r
+\r
+        -pccts_path ...\r
+\r
+            The value for $(PCCTS), the pccts directory.  The default\r
+            is /usr/local/pccts.\r
+\r
+    Contributed by Tomasz Babczynski (t.babczynski ict.pwr.wroc.pl).\r
+\r
+#244. (Changed in MR21) Rename variable "not" in antlr.g\r
+\r
+    When antlr.g is compiled with a C++ compiler, a variable named\r
+    "not" causes problems.  Reported by Sinan Karasu\r
+    (sinan.karasu boeing.com).\r
+\r
+#243  (Changed in MR21) Replace recursion with iteration in zzfree_ast\r
+\r
+    Another refinement to zzfree_ast in ast.c to limit recursion.\r
+\r
+    NAKAJIMA Mutsuki (muc isr.co.jp).\r
+\r
+\r
+#242.  (Changed in MR21) LineInfoFormatStr\r
+\r
+    Added an #ifndef/#endif around LineInfoFormatStr in pcctscfg.h.\r
+\r
+#241. (Changed in MR21) Changed macro PURIFY to a no-op\r
+\r
+                ***********************\r
+                *** NOT IMPLEMENTED ***\r
+                ***********************\r
+\r
+        The PURIFY macro was changed to a no-op because it was causing \r
+        problems when passing C++ objects.\r
+    \r
+        The old definition:\r
+    \r
+            #define PURIFY(r,s)     memset((char *) &(r),'\\0',(s));\r
+    \r
+        The new definition:\r
+    \r
+            #define PURIFY(r,s)     /* nothing */\r
+#endif\r
+\r
+#240. (Changed in MR21) sorcerer/h/sorcerer.h _MATCH and _MATCHRANGE\r
+\r
+    Added test for NULL token pointer.\r
+\r
+    Suggested by Peter Keller (keller ebi.ac.uk)\r
+\r
+#239. (Changed in MR21) C++ mode AParser::traceGuessFail\r
+\r
+    If tracing is turned on when the code has been generated\r
+    without trace code, a failed guess generates a trace report\r
+    even though there are no other trace reports.  This\r
+    make the behavior consistent with other parts of the\r
+    trace system.\r
+\r
+    Reported by David Wigg (wiggjd sbu.ac.uk).\r
+\r
+#238. (Changed in MR21) Namespace version #include files\r
+\r
+    Changed reference from CStdio to cstdio (and other\r
+    #include file names) in the namespace version of pccts.\r
+    Should have known better.\r
+\r
+#237. (Changed in MR21) ParserBlackBox(FILE*)\r
+    \r
+    In the past, ParserBlackBox would close the FILE in the dtor\r
+    even though it was not opened by ParserBlackBox.  The problem\r
+    is that there were two constructors, one which accepted a file   \r
+    name and did an fopen, the other which accepted a FILE and did\r
+    not do an fopen.  There is now an extra member variable which\r
+    remembers whether ParserBlackBox did the open or not.\r
+\r
+    Suggested by Mike Percy (mpercy scires.com).\r
+\r
+#236. (Changed in MR21) tmake now reports down pointer problem\r
+\r
+    When ASTBase::tmake attempts to update the down pointer of \r
+    an AST it checks to see if the down pointer is NULL.  If it\r
+    is not NULL it does not do the update and returns NULL.\r
+    An attempt to update the down pointer is almost always a\r
+    result of a user error.  This can lead to difficult to find\r
+    problems during tree construction.\r
+\r
+    With this change, the routine calls a virtual function\r
+    reportOverwriteOfDownPointer() which calls panic to\r
+    report the problem.  Users who want the old behavior can\r
+    redefined the virtual function in their AST class.\r
+\r
+    Suggested by Sinan Karasu (sinan.karasu boeing.com)\r
+\r
+#235. (Changed in MR21) Made ANTLRParser::resynch() virtual\r
+\r
+    Suggested by Jerry Evans (jerry swsl.co.uk).\r
+\r
+#234. (Changed in MR21) Implicit int for function return value\r
+\r
+    ATokenBuffer:bufferSize() did not specify a type for the\r
+    return value.\r
+\r
+    Reported by Hai Vo-Ba (hai fc.hp.com).\r
+\r
+#233. (Changed in MR20) Converted to MSVC 6.0\r
+\r
+    Due to external circumstances I have had to convert to MSVC 6.0\r
+    The MSVC 5.0 project files (.dsw and .dsp) have been retained as\r
+    xxx50.dsp and xxx50.dsw.  The MSVC 6.0 files are named xxx60.dsp\r
+    and xxx60.dsw (where xxx is the related to the directory/project).\r
+\r
+#232. (Changed in MR20) Make setwd bit vectors protected in parser.h\r
+\r
+    The access for the setwd array in the parser header was not\r
+    specified.  As a result, it would depend on the code which \r
+    preceded it.  In MR20 it will always have access "protected".\r
+\r
+    Reported by Piotr Eljasiak (eljasiak zt.gdansk.tpsa.pl).\r
+\r
+#231. (Changed in MR20) Error in token buffer debug code.\r
+\r
+    When token buffer debugging is selected via the pre-processor\r
+    symbol DEBUG_TOKENBUFFER there is an erroneous check in\r
+    AParser.cpp:\r
+\r
+        #ifdef DEBUG_TOKENBUFFER\r
+            if (i >= inputTokens->bufferSize() ||\r
+                inputTokens->minTokens() < LLk )     /* MR20 Was "<=" */\r
+        ...\r
+        #endif\r
+\r
+    Reported by David Wigg (wiggjd sbu.ac.uk).\r
+\r
+#230. (Changed in MR20) Fixed problem with #define for -gd option\r
+\r
+    There was an error in setting zzTRACE_RULES for the -gd (trace) option.\r
+\r
+    Reported by Gary Funck (gary intrepid.com).\r
+\r
+#229. (Changed in MR20) Additional "const" for literals\r
+\r
+    "const" was added to the token name literal table.\r
+    "const" was added to some panic() and similar routine\r
+\r
+#228. (Changed in MR20) dlg crashes on "()"\r
+\r
+    The following token defintion will cause DLG to crash.\r
+\r
+        #token "()"\r
+\r
+    When there is a syntax error in a regular expression\r
+    many of the dlg routines return a structure which has\r
+    null pointers.  When this is accessed by callers it\r
+    generates the crash.\r
+\r
+    I have attempted to fix the more common cases.\r
+\r
+    Reported by  Mengue Olivier (dolmen bigfoot.com).\r
+\r
+#227. (Changed in MR20) Array overwrite\r
+\r
+    Steveh Hand (sassth unx.sas.com) reported a problem which\r
+    was traced to a temporary array which was not properly\r
+    resized for deeply nested blocks.  This has been fixed.\r
+\r
+#226. (Changed in MR20) -pedantic conformance\r
+   \r
+    G. Hobbelt (i_a mbh.org) and THM made many, many minor \r
+    changes to create prototypes for all the functions and\r
+    bring antlr, dlg, and sorcerer into conformance with\r
+    the gcc -pedantic option.\r
+\r
+    This may require uses to add pccts/h/pcctscfg.h to some\r
+    files or makefiles in order to have __USE_PROTOS defined.\r
+\r
+#225  (Changed in MR20) AST stack adjustment in C mode\r
+\r
+    The fix in #214 for AST stack adjustment in C mode missed \r
+    some cases.\r
+\r
+    Reported with fix by Ger Hobbelt (i_a mbh.org).\r
+\r
+#224  (Changed in MR20) LL(1) and LL(2) with #pragma approx\r
+\r
+    This may take a record for the oldest, most trival, lexical\r
+    error in pccts.  The regular expressions for LL(1) and LL(2)\r
+    lacked an escape for the left and right parenthesis.\r
+\r
+    Reported by Ger Hobbelt (i_a mbh.org).\r
+\r
+#223  (Changed in MR20) Addition of IBM_VISUAL_AGE directory\r
+\r
+    Build files for antlr, dlg, and sorcerer under IBM Visual Age \r
+    have been contributed by Anton Sergeev (ags mlc.ru).  They have\r
+    been placed in the pccts/IBM_VISUAL_AGE directory.\r
+\r
+#222  (Changed in MR20) Replace __STDC__ with __USE_PROTOS\r
+\r
+    Most occurrences of __STDC__ replaced with __USE_PROTOS due to\r
+    complaints from several users.\r
+\r
+#221  (Changed in MR20) Added #include for DLexerBase.h to PBlackBox.\r
+\r
+    Added #include for DLexerBase.h to PBlackBox.\r
+\r
+#220  (Changed in MR19) strcat arguments reversed in #pred parse\r
+\r
+    The arguments to strcat are reversed when creating a print\r
+    name for a hash table entry for use with #pred feature.\r
+\r
+    Problem diagnosed and fix reported by Scott Harrington \r
+    (seh4 ix.netcom.com).\r
+\r
+#219. (Changed in MR19) C Mode routine zzfree_ast\r
+\r
+    Changes to reduce use of recursion for AST trees with only right\r
+    links or only left links in the C mode routine zzfree_ast.\r
+\r
+    Implemented by SAKAI Kiyotaka (ksakai isr.co.jp).\r
+\r
+#218. (Changed in MR19) Changes to support unsigned char in C mode\r
+\r
+    Changes to antlr.h and err.h to fix omissions in use of zzchar_t\r
+\r
+    Implemented by SAKAI Kiyotaka (ksakai isr.co.jp).\r
+\r
+#217. (Changed in MR19) Error message when dlg -i and -CC options selected\r
+    \r
+    *** This change was rescinded by item #257 ***\r
+\r
+    The parsers generated by pccts in C++ mode are not able to support the\r
+    interactive lexer option (except, perhaps, when using the deferred fetch\r
+    parser option.(Item #216).\r
+\r
+    DLG now warns when both -i and -CC are selected.\r
+\r
+    This warning was suggested by David Venditti (07751870267-0001 t-online.de).\r
+\r
+#216. (Changed in MR19) Defer token fetch for C++ mode\r
+\r
+    Implemented by Volker H. Simonis (simonis informatik.uni-tuebingen.de)\r
+\r
+    Normally, pccts keeps the lookahead token buffer completely filled.\r
+    This requires max(k,ck) tokens of lookahead.  For some applications\r
+    this can cause deadlock problems.  For example, there may be cases\r
+    when the parser can't tell when the input has been completely consumed\r
+    until the parse is complete, but the parse can't be completed because \r
+    the input routines are waiting for additional tokens to fill the\r
+    lookahead buffer.\r
+    \r
+    When the ANTLRParser class is built with the pre-processor option \r
+    ZZDEFER_FETCH defined, the fetch of new tokens by consume() is deferred\r
+    until LA(i) or LT(i) is called. \r
+\r
+    To test whether this option has been built into the ANTLRParser class\r
+    use "isDeferFetchEnabled()".\r
+\r
+    Using the -gd trace option with the default tracein() and traceout()\r
+    routines will defeat the effort to defer the fetch because the\r
+    trace routines print out information about the lookahead token at\r
+    the start of the rule.\r
+    \r
+    Because the tracein and traceout routines are virtual it is \r
+    easy to redefine them in your parser:\r
+\r
+        class MyParser {\r
+        <<\r
+            virtual void tracein(ANTLRChar * ruleName)\r
+                { fprintf(stderr,"Entering: %s\n", ruleName); }\r
+            virtual void traceout(ANTLRChar * ruleName)\r
+                { fprintf(stderr,"Leaving: %s\n", ruleName); }\r
+        >>\r
\r
+    The originals for those routines are pccts/h/AParser.cpp\r
\r
+    This requires use of the dlg option -i (interactive lexer).\r
+\r
+    This is implemented only for C++ mode.\r
+\r
+    This is experimental.  The interaction with guess mode (syntactic\r
+    predicates)is not known.\r
+\r
+#215. (Changed in MR19) Addition of reset() to DLGLexerBase\r
+\r
+    There was no obvious way to reset the lexer for reuse.  The\r
+    reset() method now does this.\r
+\r
+    Suggested by David Venditti (07751870267-0001 t-online.de).\r
+\r
+#214. (Changed in MR19)  C mode: Adjust AST stack pointer at exit\r
+\r
+    In C mode the AST stack pointer needs to be reset if there will\r
+    be multiple calls to the ANTLRx macros.\r
+\r
+    Reported with fix by Paul D. Smith (psmith baynetworks.com).\r
+\r
+#213. (Changed in MR18)  Fatal error with -mrhoistk (k>1 hoisting)\r
+\r
+    When rearranging code I forgot to un-comment a critical line of\r
+    code that handles hoisting of predicates with k>1 lookahead.  This\r
+    is now fixed.\r
+\r
+    Reported by Reinier van den Born (reinier vnet.ibm.com).\r
+\r
+#212. (Changed in MR17)  Mac related changes by Kenji Tanaka\r
+\r
+    Kenji Tanaka (kentar osa.att.ne.jp) has made a number of changes for\r
+    Macintosh users.\r
+\r
+    a.  The following Macintosh MPW files aid in installing pccts on Mac:\r
+\r
+            pccts/MPW_Read_Me\r
+\r
+            pccts/install68K.mpw\r
+            pccts/installPPC.mpw\r
+\r
+            pccts/antlr/antlr.r\r
+            pccts/antlr/antlr68K.make\r
+            pccts/antlr/antlrPPC.make\r
+\r
+            pccts/dlg/dlg.r\r
+            pccts/dlg/dlg68K.make\r
+            pccts/dlg/dlgPPC.make\r
+\r
+            pccts/sorcerer/sor.r\r
+            pccts/sorcerer/sor68K.make\r
+            pccts/sorcerer/sorPPC.make\r
+    \r
+       They completely replace the previous Mac installation files.\r
+            \r
+    b. The most significant is a change in the MAC_FILE_CREATOR symbol\r
+       in pcctscfg.h:\r
+\r
+        old: #define MAC_FILE_CREATOR 'MMCC'   /* Metrowerks C/C++ Text files */\r
+        new: #define MAC_FILE_CREATOR 'CWIE'   /* Metrowerks C/C++ Text files */\r
+\r
+    c.  Added calls to special_fopen_actions() where necessary.\r
+\r
+#211. (Changed in MR16a)  C++ style comment in dlg\r
+\r
+    This has been fixed.\r
+\r
+#210. (Changed in MR16a)  Sor accepts \r\n, \r, or \n for end-of-line\r
+\r
+    A user requested that Sorcerer be changed to accept other forms\r
+    of end-of-line.\r
+\r
+#209. (Changed in MR16) Name of files changed.\r
+\r
+        Old:  CHANGES_FROM_1.33\r
+        New:  CHANGES_FROM_133.txt\r
+\r
+        Old:  KNOWN_PROBLEMS\r
+        New:  KNOWN_PROBLEMS.txt\r
+\r
+#208. (Changed in MR16) Change in use of pccts #include files\r
+\r
+    There were problems with MS DevStudio when mixing Sorcerer and\r
+    PCCTS in the same source file.  The problem is caused by the\r
+    redefinition of setjmp in the MS header file setjmp.h.  In\r
+    setjmp.h the pre-processor symbol setjmp was redefined to be\r
+    _setjmp.  A later effort to execute #include <setjmp.h> resulted \r
+    in an effort to #include <_setjmp.h>.  I'm not sure whether this\r
+    is a bug or a feature.  In any case, I decided to fix it by\r
+    avoiding the use of pre-processor symbols in #include statements\r
+    altogether.  This has the added benefit of making pre-compiled\r
+    headers work again.\r
+\r
+    I've replaced statements:\r
+\r
+        old: #include PCCTS_SETJMP_H\r
+        new: #include "pccts_setjmp.h"\r
+\r
+    Where pccts_setjmp.h contains:\r
+\r
+            #ifndef __PCCTS_SETJMP_H__\r
+            #define __PCCTS_SETJMP_H__\r
+    \r
+            #ifdef PCCTS_USE_NAMESPACE_STD\r
+            #include <Csetjmp>\r
+            #else\r
+            #include <setjmp.h>\r
+            #endif\r
+\r
+            #endif\r
+        \r
+    A similar change has been made for other standard header files\r
+    required by pccts and sorcerer: stdlib.h, stdarg.h, stdio.h, etc.\r
+\r
+    Reported by Jeff Vincent (JVincent novell.com) and Dale Davis\r
+    (DalDavis spectrace.com).\r
+\r
+#207. (Changed in MR16) dlg reports an invalid range for: [\0x00-\0xff]\r
+\r
+     -----------------------------------------------------------------\r
+     Note from MR23:  This fix does not work.  I am investigating why.\r
+     -----------------------------------------------------------------\r
+\r
+    dlg will report that this is an invalid range.\r
+\r
+    Diagnosed by Piotr Eljasiak (eljasiak no-spam.zt.gdansk.tpsa.pl):\r
+\r
+        I think this problem is not specific to unsigned chars\r
+        because dlg reports no error for the range [\0x00-\0xfe].\r
+\r
+        I've found that information on range is kept in field\r
+        letter (unsigned char) of Attrib struct. Unfortunately\r
+        the letter value internally is for some reasons increased\r
+        by 1, so \0xff is represented here as 0.\r
+\r
+        That's why dlg complains about the range [\0x00-\0xff] in\r
+        dlg_p.g:\r
+\r
+        if ($$.letter > $2.letter) {\r
+          error("invalid range  ", zzline);\r
+        } \r
+\r
+    The fix is:\r
+\r
+        if ($$.letter > $2.letter && 255 != $$2.letter) {\r
+          error("invalid range  ", zzline);\r
+        } \r
+\r
+#206. (Changed in MR16) Free zzFAILtext in ANTLRParser destructor\r
+\r
+    The ANTLRParser destructor now frees zzFAILtext.\r
+\r
+    Problem and fix reported by Manfred Kogler (km cast.uni-linz.ac.at).\r
+\r
+#205. (Changed in MR16) DLGStringReset argument now const\r
+\r
+    Changed: void DLGStringReset(DLGChar *s) {...}\r
+    To:      void DLGStringReset(const DLGChar *s) {...}\r
+\r
+    Suggested by Dale Davis (daldavis spectrace.com)\r
+\r
+#204. (Changed in MR15a) Change __WATCOM__ to __WATCOMC__ in pcctscfg.h\r
+    \r
+    Reported by Oleg Dashevskii (olegdash my-dejanews.com).\r
+\r
+#203. (Changed in MR15) Addition of sorcerer to distribution kit\r
+\r
+    I have finally caved in to popular demand.  The pccts 1.33mr15\r
+    kit will include sorcerer.  The separate sorcerer kit will be\r
+    discontinued.\r
+\r
+#202. (Changed) in MR15) Organization of MS Dev Studio Projects in Kit\r
+\r
+    Previously there was one workspace that contained projects for\r
+    all three parts of pccts: antlr, dlg, and sorcerer.  Now each\r
+    part (and directory) has its own workspace/project and there\r
+    is an additional workspace/project to build a library from the\r
+    .cpp files in the pccts/h directory.\r
+\r
+    The library build will create pccts_debug.lib or pccts_release.lib\r
+    according to the configuration selected.  \r
+\r
+    If you don't want to build pccts 1.33MR15 you can download a\r
+    ready-to-run kit for win32 from http://www.polhode.com/win32.zip.\r
+    The ready-to-run for win32 includes executables, a pre-built static\r
+    library for the .cpp files in the pccts/h directory, and a  sample\r
+    application\r
+\r
+    You will need to define the environment variable PCCTS to point to\r
+    the root of the pccts directory hierarchy.\r
+\r
+#201. (Changed in MR15) Several fixes by K.J. Cummings (cummings peritus.com)\r
+\r
+      Generation of SETJMP rather than SETJMP_H in gen.c.\r
+\r
+      (Sor B19) Declaration of ref_vars_inits for ref_var_inits in\r
+      pccts/sorcerer/sorcerer.h.\r
+\r
+#200. (Changed in MR15) Remove operator=() in AToken.h\r
+\r
+      User reported that WatCom couldn't handle use of\r
+      explicit operator =().  Replace with equivalent\r
+      using cast operator.\r
+\r
+#199. (Changed in MR15) Don't allow use of empty #tokclass\r
+\r
+      Change antlr.g to disallow empty #tokclass sets.\r
+\r
+      Reported by Manfred Kogler (km cast.uni-linz.ac.at).\r
+\r
+#198. Revised ANSI C grammar due to efforts by Manuel Kessler\r
+\r
+      Manuel Kessler (mlkessler cip.physik.uni-wuerzburg.de)\r
+\r
+          Allow trailing ... in function parameter lists.\r
+          Add bit fields.\r
+          Allow old-style function declarations.\r
+          Support cv-qualified pointers.\r
+          Better checking of combinations of type specifiers.\r
+          Release of memory for local symbols on scope exit.\r
+          Allow input file name on command line as well as by redirection.\r
+\r
+              and other miscellaneous tweaks.\r
+\r
+      This is not part of the pccts distribution kit. It must be\r
+      downloaded separately from:\r
+\r
+            http://www.polhode.com/ansi_mr15.zip\r
+\r
+#197. (Changed in MR14) Resetting the lookahead buffer of the parser\r
+\r
+      Explanation and fix by Sinan Karasu (sinan.karasu boeing.com)\r
+\r
+      Consider the code used to prime the lookahead buffer LA(i)\r
+      of the parser when init() is called:\r
+\r
+        void\r
+        ANTLRParser::\r
+        prime_lookahead()\r
+        {\r
+            int i;\r
+            for(i=1;i<=LLk; i++) consume();\r
+            dirty=0;\r
+            //lap = 0;      // MR14 - Sinan Karasu (sinan.karusu boeing.com)\r
+            //labase = 0;   // MR14\r
+            labase=lap;     // MR14\r
+        }\r
+\r
+      When the parser is instantiated, lap=0,labase=0 is set.\r
+\r
+      The "for" loop runs LLk times. In consume(), lap = lap +1 (mod LLk) is\r
+      computed.  Therefore, lap(before the loop) == lap (after the loop).\r
+\r
+      Now the only problem comes in when one does an init() of the parser\r
+      after an Eof has been seen. At that time, lap could be non zero.\r
+      Assume it was lap==1. Now we do a prime_lookahead(). If LLk is 2,\r
+      then\r
+\r
+        consume()\r
+        {\r
+            NLA = inputTokens->getToken()->getType();\r
+            dirty--;\r
+            lap = (lap+1)&(LLk-1);\r
+        }\r
+\r
+      or expanding NLA,\r
+\r
+        token_type[lap&(LLk-1)]) = inputTokens->getToken()->getType();\r
+        dirty--;\r
+        lap = (lap+1)&(LLk-1);\r
+\r
+      so now we prime locations 1 and 2.  In prime_lookahead it used to set\r
+      lap=0 and labase=0.  Now, the next token will be read from location 0,\r
+      NOT 1 as it should have been.\r
+\r
+      This was never caught before, because if a parser is just instantiated,\r
+      then lap and labase are 0, the offending assignment lines are\r
+      basically no-ops, since the for loop wraps around back to 0.\r
+\r
+#196. (Changed in MR14) Problems with "(alpha)? beta" guess\r
+\r
+    Consider the following syntactic predicate in a grammar\r
+    with 2 tokens of lookahead (k=2 or ck=2):\r
+\r
+        rule  : ( alpha )? beta ;\r
+        alpha : S t ;\r
+        t     : T U\r
+              | T\r
+              ;\r
+        beta  : S t Z ;\r
+\r
+    When antlr computes the prediction expression with one token\r
+    of lookahead for alts 1 and 2 of rule t it finds an ambiguity.\r
+\r
+    Because the grammar has a lookahead of 2 it tries to compute\r
+    two tokens of lookahead for alts 1 and 2 of t.  Alt 1 clearly\r
+    has a lookahead of (T U).  Alt 2 is one token long so antlr\r
+    tries to compute the follow set of alt 2, which means finding\r
+    the things which can follow rule t in the context of (alpha)?.\r
+    This cannot be computed, because alpha is only part of a rule,\r
+    and antlr can't tell what part of beta is matched by alpha and\r
+    what part remains to be matched.  Thus it impossible for antlr\r
+    to  properly determine the follow set of rule t.\r
+\r
+    Prior to 1.33MR14, the follow of (alpha)? was computed as\r
+    FIRST(beta) as a result of the internal representation of\r
+    guess blocks.\r
+\r
+    With MR14 the follow set will be the empty set for that context.\r
+\r
+    Normally, one expects a rule appearing in a guess block to also\r
+    appear elsewhere.  When the follow context for this other use\r
+    is "ored" with the empty set, the context from the other use\r
+    results, and a reasonable follow context results.  However if\r
+    there is *no* other use of the rule, or it is used in a different\r
+    manner then the follow context will be inaccurate - it was\r
+    inaccurate even before MR14, but it will be inaccurate in a\r
+    different way.\r
+\r
+    For the example given earlier, a reasonable way to rewrite the\r
+    grammar:\r
+\r
+        rule  : ( alpha )? beta\r
+        alpha : S t ;\r
+        t     : T U\r
+              | T\r
+              ;\r
+        beta  : alpha Z ;\r
+\r
+    If there are no other uses of the rule appearing in the guess\r
+    block it will generate a test for EOF - a workaround for\r
+    representing a null set in the lookahead tests.\r
+\r
+    If you encounter such a problem you can use the -alpha option\r
+    to get additional information:\r
+\r
+    line 2: error: not possible to compute follow set for alpha\r
+              in an "(alpha)? beta" block.\r
+\r
+    With the antlr -alpha command line option the following information\r
+    is inserted into the generated file:\r
+\r
+    #if 0\r
+\r
+      Trace of references leading to attempt to compute the follow set of\r
+      alpha in an "(alpha)? beta" block. It is not possible for antlr to\r
+      compute this follow set because it is not known what part of beta has\r
+      already been matched by alpha and what part remains to be matched.\r
+\r
+      Rules which make use of the incorrect follow set will also be incorrect\r
+\r
+         1 #token T              alpha/2   line 7     brief.g\r
+         2 end alpha             alpha/3   line 8     brief.g\r
+         2 end (...)? block at   start/1   line 2     brief.g\r
+\r
+    #endif\r
+\r
+    At the moment, with the -alpha option selected the program marks\r
+    any rules which appear in the trace back chain (above) as rules with\r
+    possible problems computing follow set.\r
+\r
+    Reported by Greg Knapen (gregory.knapen bell.ca).\r
+\r
+#195. (Changed in MR14) #line directive not at column 1\r
+\r
+      Under certain circunstances a predicate test could generate\r
+      a #line directive which was not at column 1.\r
+\r
+      Reported with fix by David KÃ¥gedal  (davidk lysator.liu.se)\r
+      (http://www.lysator.liu.se/~davidk/).\r
+\r
+#194. (Changed in MR14) (C Mode only) Demand lookahead with #tokclass\r
+\r
+      In C mode with the demand lookahead option there is a bug in the\r
+      code which handles matches for #tokclass (zzsetmatch and\r
+      zzsetmatch_wsig).\r
+\r
+      The bug causes the lookahead pointer to get out of synchronization\r
+      with the current token pointer.\r
+\r
+      The problem was reported with a fix by Ger Hobbelt (hobbelt axa.nl).\r
+\r
+#193. (Changed in MR14) Use of PCCTS_USE_NAMESPACE_STD\r
+\r
+      The pcctscfg.h now contains the following definitions:\r
+\r
+        #ifdef PCCTS_USE_NAMESPACE_STD\r
+        #define PCCTS_STDIO_H     <Cstdio>\r
+        #define PCCTS_STDLIB_H    <Cstdlib>\r
+        #define PCCTS_STDARG_H    <Cstdarg>\r
+        #define PCCTS_SETJMP_H    <Csetjmp>\r
+        #define PCCTS_STRING_H    <Cstring>\r
+        #define PCCTS_ASSERT_H    <Cassert>\r
+        #define PCCTS_ISTREAM_H   <istream>\r
+        #define PCCTS_IOSTREAM_H  <iostream>\r
+        #define PCCTS_NAMESPACE_STD     namespace std {}; using namespace std;\r
+        #else\r
+        #define PCCTS_STDIO_H     <stdio.h>\r
+        #define PCCTS_STDLIB_H    <stdlib.h>\r
+        #define PCCTS_STDARG_H    <stdarg.h>\r
+        #define PCCTS_SETJMP_H    <setjmp.h>\r
+        #define PCCTS_STRING_H    <string.h>\r
+        #define PCCTS_ASSERT_H    <assert.h>\r
+        #define PCCTS_ISTREAM_H   <istream.h>\r
+        #define PCCTS_IOSTREAM_H  <iostream.h>\r
+        #define PCCTS_NAMESPACE_STD\r
+        #endif\r
+\r
+      The runtime support in pccts/h uses these pre-processor symbols\r
+      consistently.\r
+\r
+      Also, antlr and dlg have been changed to generate code which uses\r
+      these pre-processor symbols rather than having the names of the\r
+      #include files hard-coded in the generated code.\r
+\r
+      This required the addition of "#include pcctscfg.h" to a number of\r
+      files in pccts/h.\r
+\r
+      It appears that this sometimes causes problems for MSVC 5 in\r
+      combination with the "automatic" option for pre-compiled headers.\r
+      In such cases disable the "automatic" pre-compiled headers option.\r
+\r
+      Suggested by Hubert Holin (Hubert.Holin Bigfoot.com).\r
+\r
+#192. (Changed in MR14) Change setText() to accept "const ANTLRChar *"\r
+\r
+      Changed ANTLRToken::setText(ANTLRChar *) to setText(const ANTLRChar *).\r
+      This allows literal strings to be used to initialize tokens.  Since\r
+      the usual token implementation (ANTLRCommonToken)  makes a copy of the\r
+      input string, this was an unnecessary limitation.\r
+\r
+      Suggested by Bob McWhirter (bob netwrench.com).\r
+\r
+#191. (Changed in MR14) HP/UX aCC compiler compatibility problem\r
+\r
+      Needed to explicitly declare zzINF_DEF_TOKEN_BUFFER_SIZE and\r
+      zzINF_BUFFER_TOKEN_CHUNK_SIZE as ints in pccts/h/AParser.cpp.\r
+\r
+      Reported by David Cook (dcook bmc.com).\r
+\r
+#190. (Changed in MR14) IBM OS/2 CSet compiler compatibility problem\r
+\r
+      Name conflict with "_cs" in pccts/h/ATokenBuffer.cpp\r
+\r
+      Reported by David Cook (dcook bmc.com).\r
+\r
+#189. (Changed in MR14) -gxt switch in C mode\r
+\r
+      The -gxt switch in C mode didn't work because of incorrect\r
+      initialization.\r
+\r
+      Reported by Sinan Karasu (sinan boeing.com).\r
+\r
+#188. (Changed in MR14) Added pccts/h/DLG_stream_input.h\r
+\r
+      This is a DLG stream class based on C++ istreams.\r
+\r
+      Contributed by Hubert Holin (Hubert.Holin Bigfoot.com).\r
+\r
+#187. (Changed in MR14) Rename config.h to pcctscfg.h\r
+\r
+      The PCCTS configuration file has been renamed from config.h to\r
+      pcctscfg.h.  The problem with the original name is that it led\r
+      to name collisions when pccts parsers were combined with other\r
+      software.\r
+\r
+      All of the runtime support routines in pccts/h/* have been\r
+      changed to use the new name.  Existing software can continue\r
+      to use pccts/h/config.h. The contents of pccts/h/config.h is\r
+      now just "#include "pcctscfg.h".\r
+\r
+      I don't have a record of the user who suggested this.\r
+\r
+#186. (Changed in MR14) Pre-processor symbol DllExportPCCTS class modifier\r
+\r
+      Classes in the C++ runtime support routines are now declared:\r
+\r
+        class DllExportPCCTS className ....\r
+\r
+      By default, the pre-processor symbol is defined as the empty\r
+      string.  This if for use by MSVC++ users to create DLL classes.\r
+\r
+      Suggested by Manfred Kogler (km cast.uni-linz.ac.at).\r
+\r
+#185. (Changed in MR14) Option to not use PCCTS_AST base class for ASTBase\r
+\r
+      Normally, the ASTBase class is derived from PCCTS_AST which contains\r
+      functions useful to Sorcerer.  If these are not necessary then the\r
+      user can define the pre-processor symbol "PCCTS_NOT_USING_SOR" which\r
+      will cause the ASTBase class to replace references to PCCTS_AST with\r
+      references to ASTBase where necessary.\r
+\r
+      The class ASTDoublyLinkedBase will contain a pure virtual function\r
+      shallowCopy() that was formerly defined in class PCCTS_AST.\r
+\r
+      Suggested by Bob McWhirter (bob netwrench.com).\r
+\r
+#184. (Changed in MR14) Grammars with no tokens generate invalid tokens.h\r
+\r
+      Reported by Hubert Holin (Hubert.Holin bigfoot.com).\r
+\r
+#183. (Changed in MR14) -f to specify file with names of grammar files\r
+\r
+      In DEC/VMS it is difficult to specify very long command lines.\r
+      The -f option allows one to place the names of the grammar files\r
+      in a data file in order to bypass limitations of the DEC/VMS\r
+      command language interpreter.\r
+\r
+      Addition supplied by Bernard Giroud (b_giroud decus.ch).\r
+\r
+#182. (Changed in MR14) Output directory option for DEC/VMS\r
+\r
+      Fix some problems with the -o option under DEC/VMS.\r
+\r
+      Fix supplied by Bernard Giroud (b_giroud decus.ch).\r
+\r
+#181. (Changed in MR14) Allow chars > 127 in DLGStringInput::nextChar()\r
+\r
+      Changed DLGStringInput to cast the character using (unsigned char)\r
+      so that languages with character codes greater than 127 work\r
+      without changes.\r
+\r
+      Suggested by Manfred Kogler (km cast.uni-linz.ac.at).\r
+\r
+#180. (Added in MR14) ANTLRParser::getEofToken()\r
+\r
+      Added "ANTLRToken ANTLRParser::getEofToken() const" to match the\r
+      setEofToken routine.\r
+\r
+      Requested by Manfred Kogler (km cast.uni-linz.ac.at).\r
+\r
+#179. (Fixed in MR14) Memory leak for BufFileInput subclass of DLGInputStream\r
+\r
+      The BufFileInput class described in Item #142 neglected to release\r
+      the allocated buffer when an instance was destroyed.\r
+\r
+      Reported by Manfred Kogler (km cast.uni-linz.ac.at).\r
+\r
+#178. (Fixed in MR14) Bug in "(alpha)? beta" guess blocks first sets\r
+\r
+      In 1.33 vanilla, and all maintenance releases prior to MR14\r
+      there is a bug in the handling of guess blocks which use the\r
+      "long" form:\r
+\r
+                  (alpha)? beta\r
+\r
+      inside a (...)*, (...)+, or {...} block.\r
+\r
+      This problem does *not* apply to the case where beta is omitted\r
+      or when the syntactic predicate is on the leading edge of an\r
+      alternative.\r
+\r
+      The problem is that both alpha and beta are stored in the\r
+      syntax diagram, and that some analysis routines would fail\r
+      to skip the alpha portion when it was not on the leading edge.\r
+      Consider the following grammar with -ck 2:\r
+\r
+                r : ( (A)? B )* C D\r
+\r
+                  | A B      /* forces -ck 2 computation for old antlr    */\r
+                             /*              reports ambig for alts 1 & 2 */\r
+\r
+                  | B C      /* forces -ck 2 computation for new antlr    */\r
+                             /*              reports ambig for alts 1 & 3 */\r
+                  ;\r
+\r
+      The prediction expression for the first alternative should be\r
+      LA(1)={B C} LA(2)={B C D}, but previous versions of antlr\r
+      would compute the prediction expression as LA(1)={A C} LA(2)={B D}\r
+\r
+      Reported by Arpad Beszedes (beszedes inf.u-szeged.hu) who provided\r
+      a very clear example of the problem and identified the probable cause.\r
+\r
+#177. (Changed in MR14) #tokdefs and #token with regular expression\r
+\r
+      In MR13 the change described by Item #162 caused an existing\r
+      feature of antlr to fail.  Prior to the change it was possible\r
+      to give regular expression definitions and actions to tokens\r
+      which were defined via the #tokdefs directive.\r
+\r
+      This now works again.\r
+\r
+      Reported by Manfred Kogler (km cast.uni-linz.ac.at).\r
+\r
+#176. (Changed in MR14) Support for #line in antlr source code\r
+\r
+      Note: this was implemented by Arpad Beszedes (beszedes inf.u-szeged.hu).\r
+\r
+      In 1.33MR14 it is possible for a pre-processor to generate #line\r
+      directives in the antlr source and have those line numbers and file\r
+      names used in antlr error messages and in the #line directives\r
+      generated by antlr.\r
+\r
+      The #line directive may appear in the following forms:\r
+\r
+            #line ll "sss" xx xx ...\r
+\r
+      where ll represents a line number, "sss" represents the name of a file\r
+      enclosed in quotation marks, and xxx are arbitrary integers.\r
+\r
+      The following form (without "line") is not supported at the moment:\r
+\r
+            # ll "sss" xx xx ...\r
+\r
+      The result:\r
+\r
+        zzline\r
+\r
+            is replaced with ll from the # or #line directive\r
+\r
+        FileStr[CurFile]\r
+\r
+            is updated with the contents of the string (if any)\r
+            following the line number\r
+\r
+      Note\r
+      ----\r
+      The file-name string following the line number can be a complete\r
+      name with a directory-path. Antlr generates the output files from\r
+      the input file name (by replacing the extension from the file-name\r
+      with .c or .cpp).\r
+\r
+      If the input file (or the file-name from the line-info) contains\r
+      a path:\r
+\r
+        "../grammar.g"\r
+\r
+      the generated source code will be placed in "../grammar.cpp" (i.e.\r
+      in the parent directory).  This is inconvenient in some cases\r
+      (even the -o switch can not be used) so the path information is\r
+      removed from the #line directive.  Thus, if the line-info was\r
+\r
+        #line 2 "../grammar.g"\r
+\r
+      then the current file-name will become "grammar.g"\r
+\r
+      In this way, the generated source code according to the grammar file\r
+      will always be in the current directory, except when the -o switch\r
+      is used.\r
+\r
+#175. (Changed in MR14) Bug when guess block appears at start of (...)*\r
+\r
+      In 1.33 vanilla and all maintenance releases prior to 1.33MR14\r
+      there is a bug when a guess block appears at the start of a (...)+.\r
+      Consider the following k=1 (ck=1) grammar:\r
+\r
+            rule :\r
+                  ( (STAR)? ZIP )* ID ;\r
+\r
+      Prior to 1.33MR14, the generated code resembled:\r
+\r
+        ...\r
+        zzGUESS_BLOCK\r
+        while ( 1 ) {\r
+            if ( ! LA(1)==STAR) break;\r
+            zzGUESS\r
+            if ( !zzrv ) {\r
+                zzmatch(STAR);\r
+                zzCONSUME;\r
+                zzGUESS_DONE\r
+                zzmatch(ZIP);\r
+                zzCONSUME;\r
+            ...\r
+\r
+      Note that the routine uses STAR for the prediction expression\r
+      rather than ZIP.  With 1.33MR14 the generated code resembles:\r
+\r
+        ...\r
+        while ( 1 ) {\r
+            if ( ! LA(1)==ZIP) break;\r
+        ...\r
+\r
+      This problem existed only with (...)* blocks and was caused\r
+      by the slightly more complicated graph which represents (...)*\r
+      blocks.  This caused the analysis routine to compute the first\r
+      set for the alpha part of the "(alpha)? beta" rather than the\r
+      beta part.\r
+\r
+      Both (...)+ and {...} blocks handled the guess block correctly.\r
+\r
+      Reported by Arpad Beszedes (beszedes inf.u-szeged.hu) who provided\r
+      a very clear example of the problem and identified the probable cause.\r
+\r
+#174. (Changed in MR14) Bug when action precedes syntactic predicate\r
+\r
+      In 1.33 vanilla, and all maintenance releases prior to MR14,\r
+      there was a bug when a syntactic predicate was immediately\r
+      preceded by an action.  Consider the following -ck 2 grammar:\r
+\r
+            rule :\r
+                   <<int i;>>\r
+                   (alpha)? beta C\r
+                 | A B\r
+                 ;\r
+\r
+            alpha : A ;\r
+            beta  : A B;\r
+\r
+      Prior to MR14, the code generated for the first alternative\r
+      resembled:\r
+\r
+        ...\r
+        zzGUESS\r
+        if ( !zzrv && LA(1)==A && LA(2)==A) {\r
+            alpha();\r
+            zzGUESS_DONE\r
+            beta();\r
+            zzmatch(C);\r
+            zzCONSUME;\r
+        } else {\r
+        ...\r
+\r
+      The prediction expression (i.e. LA(1)==A && LA(2)==A) is clearly\r
+      wrong because LA(2) should be matched to B (first[2] of beta is {B}).\r
+\r
+      With 1.33MR14 the prediction expression is:\r
+\r
+        ...\r
+        if ( !zzrv && LA(1)==A && LA(2)==B) {\r
+            alpha();\r
+            zzGUESS_DONE\r
+            beta();\r
+            zzmatch(C);\r
+            zzCONSUME;\r
+        } else {\r
+        ...\r
+\r
+      This will only affect users in which alpha is shorter than\r
+      than max(k,ck) and there is an action immediately preceding\r
+      the syntactic predicate.\r
+\r
+      This problem was reported by reported by Arpad Beszedes\r
+      (beszedes inf.u-szeged.hu) who provided a very clear example\r
+      of the problem and identified the presence of the init-action\r
+      as the likely culprit.\r
+\r
+#173. (Changed in MR13a) -glms for Microsoft style filenames with -gl\r
+\r
+      With the -gl option antlr generates #line directives using the\r
+      exact name of the input files specified on the command line.\r
+      An oddity of the Microsoft C and C++ compilers is that they\r
+      don't accept file names in #line directives containing "\"\r
+      even though these are names from the native file system.\r
+\r
+      With -glms option, the "\" in file names appearing in #line\r
+      directives is replaced with a "/" in order to conform to\r
+      Microsoft compiler requirements.\r
+\r
+      Reported by Erwin Achermann (erwin.achermann switzerland.org).\r
+\r
+#172. (Changed in MR13) \r\n in antlr source counted as one line\r
+\r
+      Some MS software uses \r\n to indicate a new line.  Antlr\r
+      now recognizes this in counting lines.\r
+\r
+      Reported by Edward L. Hepler (elh ece.vill.edu).\r
+\r
+#171. (Changed in MR13) #tokclass L..U now allowed\r
+\r
+      The following is now allowed:\r
+\r
+            #tokclass ABC { A..B C }\r
+\r
+      Reported by Dave Watola (dwatola amtsun.jpl.nasa.gov)\r
+\r
+#170. (Changed in MR13) Suppression for predicates with lookahead depth >1\r
+\r
+      In MR12 the capability for suppression of predicates with lookahead\r
+      depth=1 was introduced.  With MR13 this had been extended to\r
+      predicates with lookahead depth > 1 and released for use by users\r
+      on an experimental basis.\r
+\r
+      Consider the following grammar with -ck 2 and the predicate in rule\r
+      "a" with depth 2:\r
+\r
+            r1  : (ab)* "@"\r
+                ;\r
+\r
+            ab  : a\r
+                | b\r
+                ;\r
+\r
+            a   : (A B)? => <<p(LATEXT(2))>>? A B C\r
+                ;\r
+\r
+            b   : A B C\r
+                ;\r
+\r
+      Normally, the predicate would be hoisted into rule r1 in order to\r
+      determine whether to call rule "ab".  However it should *not* be\r
+      hoisted because, even if p is false, there is a valid alternative\r
+      in rule b.  With "-mrhoistk on" the predicate will be suppressed.\r
+\r
+      If "-info p" command line option is present the following information\r
+      will appear in the generated code:\r
+\r
+                while ( (LA(1)==A)\r
+        #if 0\r
+\r
+        Part (or all) of predicate with depth > 1 suppressed by alternative\r
+            without predicate\r
+\r
+        pred  <<  p(LATEXT(2))>>?\r
+                  depth=k=2  ("=>" guard)  rule a  line 8  t1.g\r
+          tree context:\r
+            (root = A\r
+               B\r
+            )\r
+\r
+        The token sequence which is suppressed: ( A B )\r
+        The sequence of references which generate that sequence of tokens:\r
+\r
+           1 to ab          r1/1       line 1     t1.g\r
+           2 ab             ab/1       line 4     t1.g\r
+           3 to b           ab/2       line 5     t1.g\r
+           4 b              b/1        line 11    t1.g\r
+           5 #token A       b/1        line 11    t1.g\r
+           6 #token B       b/1        line 11    t1.g\r
+\r
+        #endif\r
+\r
+      A slightly more complicated example:\r
+\r
+            r1  : (ab)* "@"\r
+                ;\r
+\r
+            ab  : a\r
+                | b\r
+                ;\r
+\r
+            a   : (A B)? => <<p(LATEXT(2))>>? (A  B | D E)\r
+                ;\r
+\r
+            b   : <<q(LATEXT(2))>>? D E\r
+                ;\r
+\r
+\r
+      In this case, the sequence (D E) in rule "a" which lies behind\r
+      the guard is used to suppress the predicate with context (D E)\r
+      in rule b.\r
+\r
+                while ( (LA(1)==A || LA(1)==D)\r
+            #if 0\r
+\r
+            Part (or all) of predicate with depth > 1 suppressed by alternative\r
+                without predicate\r
+\r
+            pred  <<  q(LATEXT(2))>>?\r
+                              depth=k=2  rule b  line 11  t2.g\r
+              tree context:\r
+                (root = D\r
+                   E\r
+                )\r
+\r
+            The token sequence which is suppressed: ( D E )\r
+            The sequence of references which generate that sequence of tokens:\r
+\r
+               1 to ab          r1/1       line 1     t2.g\r
+               2 ab             ab/1       line 4     t2.g\r
+               3 to a           ab/1       line 4     t2.g\r
+               4 a              a/1        line 8     t2.g\r
+               5 #token D       a/1        line 8     t2.g\r
+               6 #token E       a/1        line 8     t2.g\r
+\r
+            #endif\r
+            &&\r
+            #if 0\r
+\r
+            pred  <<  p(LATEXT(2))>>?\r
+                              depth=k=2  ("=>" guard)  rule a  line 8  t2.g\r
+              tree context:\r
+                (root = A\r
+                   B\r
+                )\r
+\r
+            #endif\r
+\r
+            (! ( LA(1)==A && LA(2)==B ) || p(LATEXT(2)) )  {\r
+                ab();\r
+                ...\r
+\r
+#169. (Changed in MR13) Predicate test optimization for depth=1 predicates\r
+\r
+      When the MR12 generated a test of a predicate which had depth 1\r
+      it would use the depth >1 routines, resulting in correct but\r
+      inefficient behavior.  In MR13, a bit test is used.\r
+\r
+#168. (Changed in MR13) Token expressions in context guards\r
+\r
+      The token expressions appearing in context guards such as:\r
+\r
+            (A B)? => <<test(LT(1))>>?  someRule\r
+\r
+      are computed during an early phase of antlr processing.  As\r
+      a result, prior to MR13, complex expressions such as:\r
+\r
+            ~B\r
+            L..U\r
+            ~L..U\r
+            TokClassName\r
+            ~TokClassName\r
+\r
+      were not computed properly.  This resulted in incorrect\r
+      context being computed for such expressions.\r
+\r
+      In MR13 these context guards are verified for proper semantics\r
+      in the initial phase and then re-evaluated after complex token\r
+      expressions have been computed in order to produce the correct\r
+      behavior.\r
+\r
+      Reported by Arpad Beszedes (beszedes inf.u-szeged.hu).\r
+\r
+#167. (Changed in MR13) ~L..U\r
+\r
+      Prior to MR13, the complement of a token range was\r
+      not properly computed.\r
+\r
+#166. (Changed in MR13) token expression L..U\r
+\r
+      The token U was represented as an unsigned char, restricting\r
+      the use of L..U to cases where U was assigned a token number\r
+      less than 256.  This is corrected in MR13.\r
+\r
+#165. (Changed in MR13) option -newAST\r
+\r
+      To create ASTs from an ANTLRTokenPtr antlr usually calls\r
+      "new AST(ANTLRTokenPtr)".  This option generates a call\r
+      to "newAST(ANTLRTokenPtr)" instead.  This allows a user\r
+      to define a parser member function to create an AST object.\r
+\r
+      Similar changes for ASTBase::tmake and ASTBase::link were not\r
+      thought necessary since they do not create AST objects, only\r
+      use existing ones.\r
+\r
+#164. (Changed in MR13) Unused variable _astp\r
+\r
+      For many compilations, we have lived with warnings about\r
+      the unused variable _astp.  It turns out that this varible\r
+      can *never* be used because the code which references it was\r
+      commented out.\r
+\r
+      This investigation was sparked by a note from Erwin Achermann\r
+      (erwin.achermann switzerland.org).\r
+\r
+#163. (Changed in MR13) Incorrect makefiles for testcpp examples\r
+\r
+      All the examples in pccts/testcpp/* had incorrect definitions\r
+      in the makefiles for the symbol "CCC".  Instead of CCC=CC they\r
+      had CC=$(CCC).\r
+\r
+      There was an additional problem in testcpp/1/test.g due to the\r
+      change in ANTLRToken::getText() to a const member function\r
+      (Item #137).\r
+\r
+      Reported by Maurice Mass (maas cuci.nl).\r
+\r
+#162. (Changed in MR13) Combining #token with #tokdefs\r
+\r
+      When it became possible to change the print-name of a\r
+      #token (Item #148) it became useful to give a #token\r
+      statement whose only purpose was to giving a print name\r
+      to the #token.  Prior to this change this could not be\r
+      combined with the #tokdefs feature.\r
+\r
+#161. (Changed in MR13) Switch -gxt inhibits generation of tokens.h\r
+\r
+#160. (Changed in MR13) Omissions in list of names for remap.h\r
+\r
+      When a user selects the -gp option antlr creates a list\r
+      of macros in remap.h to rename some of the standard\r
+      antlr routines from zzXXX to userprefixXXX.\r
+\r
+      There were number of omissions from the remap.h name\r
+      list related to the new trace facility.  This was reported,\r
+      along with a fix, by Bernie Solomon (bernard ug.eds.com).\r
+\r
+#159. (Changed in MR13) Violations of classic C rules\r
+\r
+      There were a number of violations of classic C style in\r
+      the distribution kit.  This was reported, along with fixes,\r
+      by Bernie Solomon (bernard ug.eds.com).\r
+\r
+#158. (Changed in MR13) #header causes problem for pre-processors\r
+\r
+      A user who runs the C pre-processor on antlr source suggested\r
+      that another syntax be allowed.  With MR13 such directives\r
+      such as #header, #pragma, etc. may be written as "\#header",\r
+      "\#pragma", etc.  For escaping pre-processor directives inside\r
+      a #header use something like the following:\r
+\r
+            \#header\r
+            <<\r
+                \#include <stdio.h>\r
+            >>\r
+\r
+#157. (Fixed in MR13) empty error sets for rules with infinite recursion\r
+\r
+      When the first set for a rule cannot be computed due to infinite\r
+      left recursion and it is the only alternative for a block then\r
+      the error set for the block would be empty.  This would result\r
+      in a fatal error.\r
+\r
+      Reported by Darin Creason (creason genedax.com)\r
+\r
+#156. (Changed in MR13) DLGLexerBase::getToken() now public\r
+\r
+#155. (Changed in MR13) Context behind predicates can suppress\r
+\r
+      With -mrhoist enabled the context behind a guarded predicate can\r
+      be used to suppress other predicates.  Consider the following grammar:\r
+\r
+        r0 : (r1)+;\r
+\r
+        r1  : rp\r
+            | rq\r
+            ;\r
+        rp  : <<p LATEXT(1)>>? B ;\r
+        rq : (A)? => <<q LATEXT(1)>>? (A|B);\r
+\r
+      In earlier versions both predicates "p" and "q" would be hoisted into\r
+      rule r0. With MR12c predicate p is suppressed because the context which\r
+      follows predicate q includes "B" which can "cover" predicate "p".  In\r
+      other words, in trying to decide in r0 whether to call r1, it doesn't\r
+      really matter whether p is false or true because, either way, there is\r
+      a valid choice within r1.\r
+\r
+#154. (Changed in MR13) Making hoist suppression explicit using <<nohoist>>\r
+\r
+      A common error, even among experienced pccts users, is to code\r
+      an init-action to inhibit hoisting rather than a leading action.\r
+      An init-action does not inhibit hoisting.\r
+\r
+      This was coded:\r
+\r
+        rule1 : <<;>> rule2\r
+\r
+      This is what was meant:\r
+\r
+        rule1 : <<;>> <<;>> rule2\r
+\r
+      With MR13, the user can code:\r
+\r
+        rule1 : <<;>> <<nohoist>> rule2\r
+\r
+      The following will give an error message:\r
+\r
+        rule1 : <<nohoist>> rule2\r
+\r
+      If the <<nohoist>> appears as an init-action rather than a leading\r
+      action an error message is issued.  The meaning of an init-action\r
+      containing "nohoist" is unclear: does it apply to just one\r
+      alternative or to all alternatives ?\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+        -------------------------------------------------------\r
+        Note:  Items #153 to #1 are now in a separate file named\r
+                CHANGES_FROM_133_BEFORE_MR13.txt\r
+        -------------------------------------------------------\r
diff --git a/Tools/CodeTools/Source/Pccts/CHANGES_FROM_133_BEFORE_MR13.txt b/Tools/CodeTools/Source/Pccts/CHANGES_FROM_133_BEFORE_MR13.txt
new file mode 100644 (file)
index 0000000..bba5ecd
--- /dev/null
@@ -0,0 +1,3666 @@
+\r
+    ------------------------------------------------------------\r
+           This is the second part of a two part file.\r
+      This is a list of changes to pccts 1.33 prior to MR13\r
+       For more recent information see CHANGES_FROM_133.txt\r
+    ------------------------------------------------------------\r
+\r
+                               DISCLAIMER\r
+\r
+ The software and these notes are provided "as is".  They may include\r
+ typographical or technical errors and their authors disclaims all\r
+ liability of any kind or nature for damages due to error, fault,\r
+ defect, or deficiency regardless of cause.  All warranties of any\r
+ kind, either express or implied, including, but not limited to, the\r
+ implied  warranties of merchantability and fitness for a particular\r
+ purpose are disclaimed.\r
+\r
+\r
+#153. (Changed in MR12b) Bug in computation of -mrhoist suppression set\r
+\r
+      Consider the following grammar with k=1 and "-mrhoist on":\r
+\r
+            r1  : (A)? => ((p>>? x      /* l1 */\r
+                | r2                    /* l2 */\r
+                ;\r
+            r2  :  A                    /* l4 */\r
+                | (B)? => <<q>>? y      /* l5 */\r
+                ;\r
+\r
+      In earlier versions the mrhoist routine would see that both l1 and\r
+      l2 contained predicates and would assume that this prevented either\r
+      from acting to suppress the other predicate.  In the example above\r
+      it didn't realize the A at line l4 is capable of suppressing the\r
+      predicate at l1 even though alt l2 contains (indirectly) a predicate.\r
+\r
+      This is fixed  in MR12b.\r
+\r
+      Reported by Reinier van den Born (reinier@vnet.ibm.com)\r
+\r
+#153. (Changed in MR12a) Bug in computation of -mrhoist suppression set\r
+\r
+      An oversight similar to that described in Item #152 appeared in\r
+      the computation of the set that "covered" a predicate.  If a\r
+      predicate expression included a term such as p=AND(q,r) the context\r
+      of p was taken to be context(q) & context(r), when it should have\r
+      been context(q) | context(r).  This is fixed in MR12a.\r
+\r
+#152. (Changed in MR12) Bug in generation of predicate expressions\r
+\r
+      The primary purpose for MR12 is to make quite clear that MR11 is\r
+      obsolete and to fix the bug related to predicate expressions.\r
+\r
+      In MR10 code was added to optimize the code generated for\r
+      predicate expression tests.  Unfortunately, there was a\r
+      significant oversight in the code which resulted in a bug in\r
+      the generation of code for predicate expression tests which\r
+      contained predicates combined using AND:\r
+\r
+            r0 : (r1)* "@" ;\r
+            r1 : (AAA)? => <<p LATEXT(1)>>? r2 ;\r
+            r2 : (BBB)? => <<q LATEXT(1)>>? Q\r
+               | (BBB)? => <<r LATEXT(1)>>? Q\r
+               ;\r
+\r
+      In MR11 (and MR10 when using "-mrhoist on") the code generated\r
+      for r0 to predict r1 would be equivalent to:\r
+\r
+        if ( LA(1)==Q &&\r
+                (LA(1)==AAA && LA(1)==BBB) &&\r
+                    ( p && ( q || r )) ) {\r
+\r
+      This is incorrect because it expresses the idea that LA(1)\r
+      *must* be AAA in order to attempt r1, and *must* be BBB to\r
+      attempt r2.  The result was that r1 became unreachable since\r
+      both condition can not be simultaneously true.\r
+\r
+      The general philosophy of code generation for predicates\r
+      can be summarized as follows:\r
+\r
+            a. If the context is true don't enter an alt\r
+               for which the corresponding predicate is false.\r
+\r
+               If the context is false then it is okay to enter\r
+               the alt without evaluating the predicate at all.\r
+\r
+            b. A predicate created by ORing of predicates has\r
+               context which is the OR of their individual contexts.\r
+\r
+            c. A predicate created by ANDing of predicates has\r
+               (surprise) context which is the OR of their individual\r
+               contexts.\r
+\r
+            d. Apply these rules recursively.\r
+\r
+            e. Remember rule (a)\r
+\r
+      The correct code should express the idea that *if* LA(1) is\r
+      AAA then p must be true to attempt r1, but if LA(1) is *not*\r
+      AAA then it is okay to attempt r1, provided that *if* LA(1) is\r
+      BBB then one of q or r must be true.\r
+\r
+        if ( LA(1)==Q &&\r
+                ( !(LA(1)==AAA || LA(1)==BBB) ||\r
+                    ( ! LA(1) == AAA || p) &&\r
+                    ( ! LA(1) == BBB || q || r ) ) ) {\r
+\r
+      I believe this is fixed in MR12.\r
+\r
+      Reported by Reinier van den Born (reinier@vnet.ibm.com)\r
+\r
+#151a. (Changed in MR12) ANTLRParser::getLexer()\r
+\r
+      As a result of several requests, I have added public methods to\r
+      get a pointer to the lexer belonging to a parser.\r
+\r
+            ANTLRTokenStream *ANTLRParser::getLexer() const\r
+\r
+                Returns a pointer to the lexer being used by the\r
+                parser.  ANTLRTokenStream is the base class of\r
+                DLGLexer\r
+\r
+            ANTLRTokenStream *ANTLRTokenBuffer::getLexer() const\r
+\r
+                Returns a pointer to the lexer being used by the\r
+                ANTLRTokenBuffer.  ANTLRTokenStream is the base\r
+                class of DLGLexer\r
+\r
+      You must manually cast the ANTLRTokenStream to your program's\r
+      lexer class. Because the name of the lexer's class is not fixed.\r
+      Thus it is impossible to incorporate it into the DLGLexerBase\r
+      class.\r
+\r
+#151b.(Changed in MR12) ParserBlackBox member getLexer()\r
+\r
+      The template class ParserBlackBox now has a member getLexer()\r
+      which returns a pointer to the lexer.\r
+\r
+#150. (Changed in MR12) syntaxErrCount and lexErrCount now public\r
+\r
+      See Item #127 for more information.\r
+\r
+#149. (Changed in MR12) antlr option -info o (letter o for orphan)\r
+\r
+      If there is more than one rule which is not referenced by any\r
+      other rule then all such rules are listed.  This is useful for\r
+      alerting one to rules which are not used, but which can still\r
+      contribute to ambiguity.  For example:\r
+\r
+            start : a Z ;\r
+            unused: a A ;\r
+            a     : (A)+ ;\r
+\r
+      will cause an ambiguity report for rule "a" which will be\r
+      difficult to understand if the user forgets about rule "unused"\r
+      simply because it is not used in the grammar.\r
+\r
+#148. (Changed in MR11) #token names appearing in zztokens,token_tbl\r
+\r
+      In a #token statement like the following:\r
+\r
+            #token Plus "\+"\r
+\r
+      the string "Plus" appears in the zztokens array (C mode) and\r
+      token_tbl (C++ mode).  This string is used in most error\r
+      messages.  In MR11 one has the option of using some other string,\r
+      (e.g.  "+") in those tables.\r
+\r
+      In MR11 one can write:\r
+\r
+            #token Plus ("+")             "\+"\r
+            #token RP   ("(")             "\("\r
+            #token COM  ("comment begin") "/\*"\r
+\r
+      A #token statement is allowed to appear in more than one #lexclass\r
+      with different regular expressions.  However, the token name appears\r
+      only once in the zztokens/token_tbl array.  This means that only\r
+      one substitute can be specified for a given #token name.  The second\r
+      attempt to define a substitute name (different from the first) will\r
+      result in an error message.\r
+\r
+#147. (Changed in MR11) Bug in follow set computation\r
+\r
+      There is a bug in 1.33 vanilla and all maintenance releases\r
+      prior to MR11 in the computation of the follow set.  The bug is\r
+      different than that described in Item #82 and probably more\r
+      common.  It was discovered in the ansi.g grammar while testing\r
+      the "ambiguity aid" (Item #119). The search for a bug started\r
+      when the ambiguity aid was unable to discover the actual source\r
+      of an ambiguity reported by antlr.\r
+\r
+      The problem appears when an optimization of the follow set\r
+      computation is used inappropriately.  The result is that the\r
+      follow set used is the "worst case".  In other words, the error\r
+      can lead to false reports of ambiguity.  The good news is that\r
+      if you have a grammar in which you have addressed all reported\r
+      ambiguities you are ok.  The bad news is that you may have spent\r
+      time fixing ambiguities that were not real, or used k=2 when\r
+      ck=2 might have been sufficient, and so on.\r
+\r
+      The following grammar demonstrates the problem:\r
+\r
+        ------------------------------------------------------------\r
+            expr          :   ID ;\r
+\r
+            start         :   stmt SEMI ;\r
+\r
+            stmt          :   CASE expr COLON\r
+                          |   expr SEMI\r
+                          |   plain_stmt\r
+                          ;\r
+\r
+            plain_stmt    :   ID COLON ;\r
+        ------------------------------------------------------------\r
+\r
+      When compiled with k=1 and ck=2 it will report:\r
+\r
+         warning: alts 2 and 3 of the rule itself ambiguous upon\r
+                                             { IDENTIFIER }, { COLON }\r
+\r
+      When antlr analyzes "stmt" it computes the first[1] set of all\r
+      alternatives.  It finds an ambiguity between alts 2 and 3 for ID.\r
+      It then computes the first[2] set for alternatives 2 and 3 to resolve\r
+      the ambiguity.  In computing the first[2] set of "expr" (which is\r
+      only one token long) it needs to determine what could follow "expr".\r
+      Under a certain combination of circumstances antlr forgets that it\r
+      is trying to analyze "stmt" which can only be followed by SEMI and\r
+      adds to the first[2] set of "expr" the "global" follow set (including\r
+      "COLON") which could follow "expr" (under other conditions) in the\r
+      phrase "CASE expr COLON".\r
+\r
+#146. (Changed in MR11) Option -treport for locating "difficult" alts\r
+\r
+      It can be difficult to determine which alternatives are causing\r
+      pccts to work hard to resolve an ambiguity.  In some cases the\r
+      ambiguity is successfully resolved after much CPU time so there\r
+      is no message at all.\r
+\r
+      A rough measure of the amount of work being peformed which is\r
+      independent of the CPU speed and system load is the number of\r
+      tnodes created.  Using "-info t" gives information about the\r
+      total number of tnodes created and the peak number of tnodes.\r
+\r
+        Tree Nodes:  peak 1300k  created 1416k  lost 0\r
+\r
+      It also puts in the generated C or C++ file the number of tnodes\r
+      created for a rule (at the end of the rule).  However this\r
+      information is not sufficient to locate the alternatives within\r
+      a rule which are causing the creation of tnodes.\r
+\r
+      Using:\r
+\r
+             antlr -treport 100000 ....\r
+\r
+      causes antlr to list on stdout any alternatives which require the\r
+      creation of more than 100,000 tnodes, along with the lookahead sets\r
+      for those alternatives.\r
+\r
+      The following is a trivial case from the ansi.g grammar which shows\r
+      the format of the report.  This report might be of more interest\r
+      in cases where 1,000,000 tuples were created to resolve the ambiguity.\r
+\r
+      -------------------------------------------------------------------------\r
+        There were 0 tuples whose ambiguity could not be resolved\r
+             by full lookahead\r
+        There were 157 tnodes created to resolve ambiguity between:\r
+\r
+          Choice 1: statement/2  line 475  file ansi.g\r
+          Choice 2: statement/3  line 476  file ansi.g\r
+\r
+            Intersection of lookahead[1] sets:\r
+\r
+               IDENTIFIER\r
+\r
+            Intersection of lookahead[2] sets:\r
+\r
+               LPARENTHESIS     COLON            AMPERSAND        MINUS\r
+               STAR             PLUSPLUS         MINUSMINUS       ONESCOMPLEMENT\r
+               NOT              SIZEOF           OCTALINT         DECIMALINT\r
+               HEXADECIMALINT   FLOATONE         FLOATTWO         IDENTIFIER\r
+               STRING           CHARACTER\r
+      -------------------------------------------------------------------------\r
+\r
+#145. (Documentation)  Generation of Expression Trees\r
+\r
+      Item #99 was misleading because it implied that the optimization\r
+      for tree expressions was available only for trees created by\r
+      predicate expressions and neglected to mention that it required\r
+      the use of "-mrhoist on".  The optimization applies to tree\r
+      expressions created for grammars with k>1 and for predicates with\r
+      lookahead depth >1.\r
+\r
+      In MR11 the optimized version is always used so the -mrhoist on\r
+      option need not be specified.\r
+\r
+#144. (Changed in MR11) Incorrect test for exception group\r
+\r
+      In testing for a rule's exception group the label a pointer\r
+      is compared against '\0'.  The intention is "*pointer".\r
+\r
+      Reported by Jeffrey C. Fried (Jeff@Fried.net).\r
+\r
+#143. (Changed in MR11) Optional ";" at end of #token statement\r
+\r
+      Fixes problem of:\r
+\r
+            #token X "x"\r
+\r
+            <<\r
+                parser action\r
+            >>\r
+\r
+      Being confused with:\r
+\r
+            #token X "x" <<lexical action>>\r
+\r
+#142. (Changed in MR11) class BufFileInput subclass of DLGInputStream\r
+\r
+      Alexey Demakov (demakov@kazbek.ispras.ru) has supplied class\r
+      BufFileInput derived from DLGInputStream which provides a\r
+      function lookahead(char *string) to test characters in the\r
+      input stream more than one character ahead.\r
+\r
+      The default amount of lookahead is specified by the constructor\r
+      and defaults to 8 characters.  This does *not* include the one\r
+      character of lookahead maintained internally by DLG in member "ch"\r
+      and which is not available for testing via BufFileInput::lookahead().\r
+\r
+      This is a useful class for overcoming the one-character-lookahead\r
+      limitation of DLG without resorting to a lexer capable of\r
+      backtracking (like flex) which is not integrated with antlr as is\r
+      DLG.\r
+\r
+      There are no restrictions on copying or using BufFileInput.* except\r
+      that the authorship and related information must be retained in the\r
+      source code.\r
+\r
+      The class is located in pccts/h/BufFileInput.* of the kit.\r
+\r
+#141. (Changed in MR11) ZZDEBUG_CONSUME for ANTLRParser::consume()\r
+\r
+      A debug aid has been added to file ANTLRParser::consume() in\r
+      file AParser.cpp:\r
+\r
+            #ifdef ZZDEBUG_CONSUME_ACTION\r
+                zzdebug_consume_action();\r
+            #endif\r
+\r
+      Suggested by Sramji Ramanathan (ps@kumaran.com).\r
+\r
+#140. (Changed in MR11) #pred to define predicates\r
+\r
+      +---------------------------------------------------+\r
+      | Note: Assume "-prc on" for this entire discussion |\r
+      +---------------------------------------------------+\r
+\r
+      A problem with predicates is that each one is regarded as\r
+      unique and capable of disambiguating cases where two\r
+      alternatives have identical lookahead.  For example:\r
+\r
+        rule : <<pred(LATEXT(1))>>? A\r
+             | <<pred(LATEXT(1))>>? A\r
+             ;\r
+\r
+      will not cause any error messages or warnings to be issued\r
+      by earlier versions of pccts.  To compare the text of the\r
+      predicates is an incomplete solution.\r
+\r
+      In 1.33MR11 I am introducing the #pred statement in order to\r
+      solve some problems with predicates.  The #pred statement allows\r
+      one to give a symbolic name to a "predicate literal" or a\r
+      "predicate expression" in order to refer to it in other predicate\r
+      expressions or in the rules of the grammar.\r
+\r
+      The predicate literal associated with a predicate symbol is C\r
+      or C++ code which can be used to test the condition.  A\r
+      predicate expression defines a predicate symbol in terms of other\r
+      predicate symbols using "!", "&&", and "||".  A predicate symbol\r
+      can be defined in terms of a predicate literal, a predicate\r
+      expression, or *both*.\r
+\r
+      When a predicate symbol is defined with both a predicate literal\r
+      and a predicate expression, the predicate literal is used to generate\r
+      code, but the predicate expression is used to check for two\r
+      alternatives with identical predicates in both alternatives.\r
+\r
+      Here are some examples of #pred statements:\r
+\r
+        #pred  IsLabel       <<isLabel(LATEXT(1))>>?\r
+        #pred  IsLocalVar    <<isLocalVar(LATEXT(1))>>?\r
+        #pred  IsGlobalVar   <<isGlobalVar(LATEXT(1)>>?\r
+        #pred  IsVar         <<isVar(LATEXT(1))>>?       IsLocalVar || IsGlobalVar\r
+        #pred  IsScoped      <<isScoped(LATEXT(1))>>?    IsLabel || IsLocalVar\r
+\r
+      I hope that the use of EBNF notation to describe the syntax of the\r
+      #pred statement will not cause problems for my readers (joke).\r
+\r
+        predStatement : "#pred"\r
+                            CapitalizedName\r
+                              (\r
+                                  "<<predicate_literal>>?"\r
+                                | "<<predicate_literal>>?"  predOrExpr\r
+                                | predOrExpr\r
+                              )\r
+                      ;\r
+\r
+        predOrExpr    : predAndExpr ( "||" predAndExpr ) * ;\r
+\r
+        predAndExpr   : predPrimary ( "&&" predPrimary ) * ;\r
+\r
+        predPrimary   : CapitalizedName\r
+                      | "!" predPrimary\r
+                      | "(" predOrExpr ")"\r
+                      ;\r
+\r
+      What is the purpose of this nonsense ?\r
+\r
+      To understand how predicate symbols help, you need to realize that\r
+      predicate symbols are used in two different ways with two different\r
+      goals.\r
+\r
+        a. Allow simplification of predicates which have been combined\r
+           during predicate hoisting.\r
+\r
+        b. Allow recognition of identical predicates which can't disambiguate\r
+           alternatives with common lookahead.\r
+\r
+      First we will discuss goal (a).  Consider the following rule:\r
+\r
+            rule0: rule1\r
+                 | ID\r
+                 | ...\r
+                 ;\r
+\r
+            rule1: rule2\r
+                 | rule3\r
+                 ;\r
+\r
+            rule2: <<isX(LATEXT(1))>>? ID ;\r
+            rule3: <<!isX(LATEXT(1)>>? ID ;\r
+\r
+      When the predicates in rule2 and rule3 are combined by hoisting\r
+      to create a prediction expression for rule1 the result is:\r
+\r
+            if ( LA(1)==ID\r
+                && ( isX(LATEXT(1) || !isX(LATEXT(1) ) ) { rule1(); ...\r
+\r
+      This is inefficient, but more importantly, can lead to false\r
+      assumptions that the predicate expression distinguishes the rule1\r
+      alternative with some other alternative with lookahead ID.  In\r
+      MR11 one can write:\r
+\r
+            #pred IsX     <<isX(LATEXT(1))>>?\r
+\r
+            ...\r
+\r
+            rule2: <<IsX>>? ID  ;\r
+            rule3: <<!IsX>>? ID ;\r
+\r
+      During hoisting MR11 recognizes this as a special case and\r
+      eliminates the predicates.  The result is a prediction\r
+      expression like the following:\r
+\r
+            if ( LA(1)==ID ) { rule1(); ...\r
+\r
+      Please note that the following cases which appear to be equivalent\r
+      *cannot* be simplified by MR11 during hoisting because the hoisting\r
+      logic only checks for a "!" in the predicate action, not in the\r
+      predicate expression for a predicate symbol.\r
+\r
+        *Not* equivalent and is not simplified during hoisting:\r
+\r
+            #pred IsX      <<isX(LATEXT(1))>>?\r
+            #pred NotX     <<!isX(LATEXT(1))>>?\r
+            ...\r
+            rule2: <<IsX>>? ID  ;\r
+            rule3: <<NotX>>? ID ;\r
+\r
+        *Not* equivalent and is not simplified during hoisting:\r
+\r
+            #pred IsX      <<isX(LATEXT(1))>>?\r
+            #pred NotX     !IsX\r
+            ...\r
+            rule2: <<IsX>>? ID  ;\r
+            rule3: <<NotX>>? ID ;\r
+\r
+      Now we will discuss goal (b).\r
+\r
+      When antlr discovers that there is a lookahead ambiguity between\r
+      two alternatives it attempts to resolve the ambiguity by searching\r
+      for predicates in both alternatives.  In the past any predicate\r
+      would do, even if the same one appeared in both alternatives:\r
+\r
+            rule: <<p(LATEXT(1))>>? X\r
+                | <<p(LATEXT(1))>>? X\r
+                ;\r
+\r
+      The #pred statement is a start towards solving this problem.\r
+      During ambiguity resolution (*not* predicate hoisting) the\r
+      predicates for the two alternatives are expanded and compared.\r
+      Consider the following example:\r
+\r
+            #pred Upper     <<isUpper(LATEXT(1))>>?\r
+            #pred Lower     <<isLower(LATEXT(1))>>?\r
+            #pred Alpha     <<isAlpha(LATEXT(1))>>?  Upper || Lower\r
+\r
+            rule0: rule1\r
+                 | <<Alpha>>? ID\r
+                 ;\r
+\r
+            rule1:\r
+                 | rule2\r
+                 | rule3\r
+                 ...\r
+                 ;\r
+\r
+            rule2: <<Upper>>? ID;\r
+            rule3: <<Lower>>? ID;\r
+\r
+      The definition of #pred Alpha expresses:\r
+\r
+            a. to test the predicate use the C code "isAlpha(LATEXT(1))"\r
+\r
+            b. to analyze the predicate use the information that\r
+               Alpha is equivalent to the union of Upper and Lower,\r
+\r
+      During ambiguity resolution the definition of Alpha is expanded\r
+      into "Upper || Lower" and compared with the predicate in the other\r
+      alternative, which is also "Upper || Lower".  Because they are\r
+      identical MR11 will report a problem.\r
+\r
+    -------------------------------------------------------------------------\r
+      t10.g, line 5: warning: the predicates used to disambiguate rule rule0\r
+             (file t10.g alt 1 line 5 and alt 2 line 6)\r
+             are identical when compared without context and may have no\r
+             resolving power for some lookahead sequences.\r
+    -------------------------------------------------------------------------\r
+\r
+      If you use the "-info p" option the output file will contain:\r
+\r
+    +----------------------------------------------------------------------+\r
+    |#if 0                                                                 |\r
+    |                                                                      |\r
+    |The following predicates are identical when compared without          |\r
+    |  lookahead context information.  For some ambiguous lookahead        |\r
+    |  sequences they may not have any power to resolve the ambiguity.     |\r
+    |                                                                      |\r
+    |Choice 1: rule0/1  alt 1  line 5  file t10.g                          |\r
+    |                                                                      |\r
+    |  The original predicate for choice 1 with available context          |\r
+    |    information:                                                      |\r
+    |                                                                      |\r
+    |    OR expr                                                           |\r
+    |                                                                      |\r
+    |      pred  <<  Upper>>?                                              |\r
+    |                        depth=k=1  rule rule2  line 14  t10.g         |\r
+    |        set context:                                                  |\r
+    |           ID                                                         |\r
+    |                                                                      |\r
+    |      pred  <<  Lower>>?                                              |\r
+    |                        depth=k=1  rule rule3  line 15  t10.g         |\r
+    |        set context:                                                  |\r
+    |           ID                                                         |\r
+    |                                                                      |\r
+    |  The predicate for choice 1 after expansion (but without context     |\r
+    |    information):                                                     |\r
+    |                                                                      |\r
+    |    OR expr                                                           |\r
+    |                                                                      |\r
+    |      pred  <<  isUpper(LATEXT(1))>>?                                 |\r
+    |                        depth=k=1  rule   line 1  t10.g               |\r
+    |                                                                      |\r
+    |      pred  <<  isLower(LATEXT(1))>>?                                 |\r
+    |                        depth=k=1  rule   line 2  t10.g               |\r
+    |                                                                      |\r
+    |                                                                      |\r
+    |Choice 2: rule0/2  alt 2  line 6  file t10.g                          |\r
+    |                                                                      |\r
+    |  The original predicate for choice 2 with available context          |\r
+    |    information:                                                      |\r
+    |                                                                      |\r
+    |  pred  <<  Alpha>>?                                                  |\r
+    |                    depth=k=1  rule rule0  line 6  t10.g              |\r
+    |    set context:                                                      |\r
+    |       ID                                                             |\r
+    |                                                                      |\r
+    |  The predicate for choice 2 after expansion (but without context     |\r
+    |    information):                                                     |\r
+    |                                                                      |\r
+    |  OR expr                                                             |\r
+    |                                                                      |\r
+    |    pred  <<  isUpper(LATEXT(1))>>?                                   |\r
+    |                      depth=k=1  rule   line 1  t10.g                 |\r
+    |                                                                      |\r
+    |    pred  <<  isLower(LATEXT(1))>>?                                   |\r
+    |                      depth=k=1  rule   line 2  t10.g                 |\r
+    |                                                                      |\r
+    |                                                                      |\r
+    |#endif                                                                |\r
+    +----------------------------------------------------------------------+\r
+\r
+      The comparison of the predicates for the two alternatives takes\r
+      place without context information, which means that in some cases\r
+      the predicates will be considered identical even though they operate\r
+      on disjoint lookahead sets.  Consider:\r
+\r
+            #pred Alpha\r
+\r
+            rule1: <<Alpha>>? ID\r
+                 | <<Alpha>>? Label\r
+                 ;\r
+\r
+      Because the comparison of predicates takes place without context\r
+      these will be considered identical.  The reason for comparing\r
+      without context is that otherwise it would be necessary to re-evaluate\r
+      the entire predicate expression for each possible lookahead sequence.\r
+      This would require more code to be written and more CPU time during\r
+      grammar analysis, and it is not yet clear whether anyone will even make\r
+      use of the new #pred facility.\r
+\r
+      A temporary workaround might be to use different #pred statements\r
+      for predicates you know have different context.  This would avoid\r
+      extraneous warnings.\r
+\r
+      The above example might be termed a "false positive".  Comparison\r
+      without context will also lead to "false negatives".  Consider the\r
+      following example:\r
+\r
+            #pred Alpha\r
+            #pred Beta\r
+\r
+            rule1: <<Alpha>>? A\r
+                 | rule2\r
+                 ;\r
+\r
+            rule2: <<Alpha>>? A\r
+                 | <<Beta>>?  B\r
+                 ;\r
+\r
+      The predicate used for alt 2 of rule1 is (Alpha || Beta).  This\r
+      appears to be different than the predicate Alpha used for alt1.\r
+      However, the context of Beta is B.  Thus when the lookahead is A\r
+      Beta will have no resolving power and Alpha will be used for both\r
+      alternatives.  Using the same predicate for both alternatives isn't\r
+      very helpful, but this will not be detected with 1.33MR11.\r
+\r
+      To properly handle this the predicate expression would have to be\r
+      evaluated for each distinct lookahead context.\r
+\r
+      To determine whether two predicate expressions are identical is\r
+      difficult.  The routine may fail to identify identical predicates.\r
+\r
+      The #pred feature also compares predicates to see if a choice between\r
+      alternatives which is resolved by a predicate which makes the second\r
+      choice unreachable.  Consider the following example:\r
+\r
+            #pred A         <<A(LATEXT(1)>>?\r
+            #pred B         <<B(LATEXT(1)>>?\r
+            #pred A_or_B    A || B\r
+\r
+            r   : s\r
+                | t\r
+                ;\r
+            s   : <<A_or_B>>? ID\r
+                ;\r
+            t   : <<A>>? ID\r
+                ;\r
+\r
+        ----------------------------------------------------------------------------\r
+        t11.g, line 5: warning: the predicate used to disambiguate the\r
+               first choice of  rule r\r
+             (file t11.g alt 1 line 5 and alt 2 line 6)\r
+             appears to "cover" the second predicate when compared without context.\r
+             The second predicate may have no resolving power for some lookahead\r
+               sequences.\r
+        ----------------------------------------------------------------------------\r
+\r
+#139. (Changed in MR11) Problem with -gp in C++ mode\r
+\r
+      The -gp option to add a prefix to rule names did not work in\r
+      C++ mode.  This has been fixed.\r
+\r
+      Reported by Alexey Demakov (demakov@kazbek.ispras.ru).\r
+\r
+#138. (Changed in MR11) Additional makefiles for non-MSVC++ MS systems\r
+\r
+      Sramji Ramanathan (ps@kumaran.com) has supplied makefiles for\r
+      building antlr and dlg with Win95/NT development tools that\r
+      are not based on MSVC5.  They are pccts/antlr/AntlrMS.mak and\r
+      pccts/dlg/DlgMS.mak.\r
+\r
+      The first line of the makefiles require a definition of PCCTS_HOME.\r
+\r
+      These are in additiion to the AntlrMSVC50.* and DlgMSVC50.*\r
+      supplied by Jeff Vincent (JVincent@novell.com).\r
+\r
+#137. (Changed in MR11) Token getType(), getText(), getLine() const members\r
+\r
+      --------------------------------------------------------------------\r
+      If you use ANTLRCommonToken this change probably does not affect you.\r
+      --------------------------------------------------------------------\r
+\r
+      For a long time it has bothered me that these accessor functions\r
+      in ANTLRAbstractToken were not const member functions.  I have\r
+      refrained from changing them because it require users to modify\r
+      existing token class definitions which are derived directly\r
+      from ANTLRAbstractToken.  I think it is now time.\r
+\r
+      For those who are not used to C++, a "const member function" is a\r
+      member function which does not modify its own object - the thing\r
+      to which "this" points. This is quite different from a function\r
+      which does not modify its arguments\r
+\r
+      Most token definitions based on ANTLRAbstractToken have something like\r
+      the following in order to create concrete definitions of the pure\r
+      virtual methods in ANTLRAbstractToken:\r
+\r
+        class MyToken : public ANTLRAbstractToken {\r
+            ...\r
+            ANTLRTokenType getType() {return _type; }\r
+            int getLine()            {return _line; }\r
+            ANTLRChar * getText()    {return _text; }\r
+            ...\r
+        }\r
+\r
+      The required change is simply to put "const" following the function\r
+      prototype in the header (.h file) and the definition file (.cpp if\r
+      it is not inline):\r
+\r
+        class MyToken : public ANTLRAbstractToken {\r
+            ...\r
+            ANTLRTokenType getType() const {return _type; }\r
+            int getLine() const            {return _line; }\r
+            ANTLRChar * getText() const    {return _text; }\r
+            ...\r
+        }\r
+\r
+      This was originally proposed a long time ago by Bruce\r
+      Guenter (bruceg@qcc.sk.ca).\r
+\r
+#136. (Changed in MR11) Added getLength() to ANTLRCommonToken\r
+\r
+      Classes ANTLRCommonToken and ANTLRCommonTokenNoRefCountToken\r
+      now have a member function:\r
+\r
+            int getLength() const { return strlen(getText()) }\r
+\r
+      Suggested by Sramji Ramanathan (ps@kumaran.com).\r
+\r
+#135. (Changed in MR11) Raised antlr's own default ZZLEXBUFSIZE to 8k\r
+\r
+#134a. (ansi_mr10.zip)  T.J. Parr's ANSI C grammar made 1.33MR11 compatible\r
+\r
+       There is a typographical error in the definition of BITWISEOREQ:\r
+\r
+        #token BITWISEOREQ "!=" should be "\|="\r
+\r
+       When this change is combined with the bugfix to the follow set cache\r
+       problem (Item #147) and a minor rearrangement of the grammar\r
+       (Item #134b) it becomes a k=1 ck=2 grammar.\r
+\r
+#134b. (ansi_mr10.zip)  T.J. Parr's ANSI C grammar made 1.33MR11 compatible\r
+\r
+      The following changes were made in the ansi.g grammar (along with\r
+      using -mrhoist on):\r
+\r
+        ansi.g\r
+        ======\r
+        void tracein(char *)     ====>    void tracein(const char *)\r
+        void traceout(char *)    ====>    void traceout(const char *)\r
+\r
+        <LT(1)->getType()==IDENTIFIER ? isTypeName(LT(1)->getText()) : 1>>?\r
+        ====> <<isTypeName(LT(1)->getText())>>?\r
+\r
+        <<(LT(1)->getType()==LPARENTHESIS && LT(2)->getType()==IDENTIFIER) ? \\r
+                        isTypeName(LT(2)->getText()) : 1>>?\r
+        ====> (LPARENTHESIS IDENTIFIER)? => <<isTypeName(LT(2)->getText())>>?\r
+\r
+        <<(LT(1)->getType()==LPARENTHESIS && LT(2)->getType()==IDENTIFIER) ? \\r
+                        isTypeName(LT(2)->getText()) : 1>>?\r
+        ====> (LPARENTHESIS IDENTIFIER)? => <<isTypeName(LT(2)->getText())>>?\r
+\r
+        added to init(): traceOptionValueDefault=0;\r
+        added to init(): traceOption(-1);\r
+\r
+        change rule "statement":\r
+\r
+            statement\r
+                :   plain_label_statement\r
+                |   case_label_statement\r
+                |   <<;>> expression SEMICOLON\r
+                |   compound_statement\r
+                |   selection_statement\r
+                |   iteration_statement\r
+                |   jump_statement\r
+                |   SEMICOLON\r
+                ;\r
+\r
+            plain_label_statement\r
+                :   IDENTIFIER COLON statement\r
+                ;\r
+\r
+            case_label_statement\r
+                :   CASE constant_expression COLON statement\r
+                |   DEFAULT COLON statement\r
+            ;\r
+\r
+        support.cpp\r
+        ===========\r
+        void tracein(char *)     ====>    void tracein(const char *)\r
+        void traceout(char *)    ====>    void traceout(const char *)\r
+\r
+        added to tracein():  ANTLRParser::tracein(r);  // call superclass method\r
+        added to traceout(): ANTLRParser::traceout(r); // call superclass method\r
+\r
+        Makefile\r
+        ========\r
+        added to AFLAGS: -mrhoist on -prc on\r
+\r
+#133. (Changed in 1.33MR11) Make trace options public in ANTLRParser\r
+\r
+      In checking T.J. Parr's ANSI C grammar for compatibility with\r
+      1.33MR11 discovered that it was inconvenient to have the\r
+      trace facilities with protected access.\r
+\r
+#132. (Changed in 1.33MR11) Recognition of identical predicates in alts\r
+\r
+      Prior to 1.33MR11, there would be no ambiguity warning when the\r
+      very same predicate was used to disambiguate both alternatives:\r
+\r
+        test: ref B\r
+            | ref C\r
+            ;\r
+\r
+        ref : <<pred(LATEXT(1)>>? A\r
+\r
+      In 1.33MR11 this will cause the warning:\r
+\r
+        warning: the predicates used to disambiguate rule test\r
+            (file v98.g alt 1 line 1 and alt 2 line 2)\r
+             are identical and have no resolving power\r
+\r
+        -----------------  Note  -----------------\r
+\r
+          This is different than the following case\r
+\r
+                test: <<pred(LATEXT(1))>>? A B\r
+                    | <<pred(LATEXT(1)>>?  A C\r
+                    ;\r
+\r
+          In this case there are two distinct predicates\r
+          which have exactly the same text.  In the first\r
+          example there are two references to the same\r
+          predicate.  The problem represented by this\r
+          grammar will be addressed later.\r
+\r
+#131. (Changed in 1.33MR11) Case insensitive command line options\r
+\r
+      Command line switches like "-CC" and keywords like "on", "off",\r
+      and "stdin" are no longer case sensitive in antlr, dlg, and sorcerer.\r
+\r
+#130. (Changed in 1.33MR11) Changed ANTLR_VERSION to int from string\r
+\r
+      The ANTLR_VERSION was not an integer, making it difficult to\r
+      perform conditional compilation based on the antlr version.\r
+\r
+      Henceforth, ANTLR_VERSION will be:\r
+\r
+            (base_version * 10000) + release number\r
+\r
+            thus 1.33MR11 will be: 133*100+11 = 13311\r
+\r
+      Suggested by Rainer Janssen (Rainer.Janssen@Informatik.Uni-Oldenburg.DE).\r
+\r
+#129. (Changed in 1.33MR11) Addition of ANTLR_VERSION to <parserName>.h\r
+\r
+      The following code is now inserted into <parserName>.h amd\r
+      stdpccts.h:\r
+\r
+            #ifndef ANTLR_VERSION\r
+            #define ANTLR_VERSION 13311\r
+            #endif\r
+\r
+      Suggested by Rainer Janssen (Rainer.Janssen@Informatik.Uni-Oldenburg.DE)\r
+\r
+#128. (Changed in 1.33MR11) Redundant predicate code in (<<pred>>? ...)+\r
+\r
+      Prior to 1.33MR11, the following grammar would generate\r
+      redundant tests for the "while" condition.\r
+\r
+        rule2 : (<<pred>>? X)+ X\r
+              | B\r
+              ;\r
+\r
+      The code would resemble:\r
+\r
+            if (LA(1)==X) {\r
+                if (pred) {\r
+                    do {\r
+                        if (!pred) {zzfailed_pred("  pred");}\r
+                        zzmatch(X); zzCONSUME;\r
+                    } while (LA(1)==X && pred && pred);\r
+            } else {...\r
+\r
+      With 1.33MR11 the redundant predicate test is omitted.\r
+\r
+#127. (Changed in 1.33MR11)\r
+\r
+                    Count Syntax Errors     Count DLG Errors\r
+                    -------------------     ----------------\r
+\r
+       C++ mode     ANTLRParser::           DLGLexerBase::\r
+                      syntaxErrCount          lexErrCount\r
+       C mode       zzSyntaxErrCount        zzLexErrCount\r
+\r
+       The C mode variables are global and initialized to 0.\r
+       They are *not* reset to 0 automatically when antlr is\r
+       restarted.\r
+\r
+       The C++ mode variables are public.  They are initialized\r
+       to 0 by the constructors.  They are *not* reset to 0 by the\r
+       ANTLRParser::init() method.\r
+\r
+       Suggested by Reinier van den Born (reinier@vnet.ibm.com).\r
+\r
+#126. (Changed in 1.33MR11) Addition of #first <<...>>\r
+\r
+       The #first <<...>> inserts the specified text in the output\r
+       files before any other #include statements required by pccts.\r
+       The only things before the #first text are comments and\r
+       a #define ANTLR_VERSION.\r
+\r
+       Requested by  and Esa Pulkkinen (esap@cs.tut.fi) and Alexin\r
+       Zoltan (alexin@inf.u-szeged.hu).\r
+\r
+#125. (Changed in 1.33MR11) Lookahead for (guard)? && <<p>>? predicates\r
+\r
+       When implementing the new style of guard predicate (Item #113)\r
+       in 1.33MR10 I decided to temporarily ignore the problem of\r
+       computing the "narrowest" lookahead context.\r
+\r
+       Consider the following k=1 grammar:\r
+\r
+            start : a\r
+                  | b\r
+                  ;\r
+\r
+            a     : (A)? && <<pred1(LATEXT(1))>>? ab ;\r
+            b     : (B)? && <<pred2(LATEXT(1))>>? ab ;\r
+\r
+            ab    : A | B ;\r
+\r
+       In MR10 the context for both "a" and "b" was {A B} because this is\r
+       the first set of rule "ab".  Normally, this is not a problem because\r
+       the predicate which follows the guard inhibits any ambiguity report\r
+       by antlr.\r
+\r
+       In MR11 the first set for rule "a" is {A} and for rule "b" it is {B}.\r
+\r
+#124. A Note on the New "&&" Style Guarded Predicates\r
+\r
+        I've been asked several times, "What is the difference between\r
+        the old "=>" style guard predicates and the new style "&&" guard\r
+        predicates, and how do you choose one over the other" ?\r
+\r
+        The main difference is that the "=>" does not apply the\r
+        predicate if the context guard doesn't match, whereas\r
+        the && form always does.  What is the significance ?\r
+\r
+        If you have a predicate which is not on the "leading edge"\r
+        it cannot be hoisted.  Suppose you need a predicate that\r
+        looks at LA(2).  You must introduce it manually.  The\r
+        classic example is:\r
+\r
+            castExpr :\r
+                     LP typeName RP\r
+                     | ....\r
+                     ;\r
+\r
+            typeName : <<isTypeName(LATEXT(1))>>?  ID\r
+                     | STRUCT ID\r
+                     ;\r
+\r
+        The problem  is that typeName isn't on the leading edge\r
+        of castExpr, so the predicate isTypeName won't be hoisted into\r
+        castExpr to help make a decision on which production to choose.\r
+\r
+        The *first* attempt to fix it is this:\r
+\r
+            castExpr :\r
+                     <<isTypeName(LATEXT(2))>>?\r
+                                        LP typeName RP\r
+                     | ....\r
+                     ;\r
+\r
+        Unfortunately, this won't work because it ignores\r
+        the problem of STRUCT.  The solution is to apply\r
+        isTypeName() in castExpr if LA(2) is an ID and\r
+        don't apply it when LA(2) is STRUCT:\r
+\r
+            castExpr :\r
+                     (LP ID)? => <<isTypeName(LATEXT(2))>>?\r
+                                        LP typeName RP\r
+                     | ....\r
+                     ;\r
+\r
+        In conclusion, the "=>" style guarded predicate is\r
+        useful when:\r
+\r
+            a. the tokens required for the predicate\r
+               are not on the leading edge\r
+            b. there are alternatives in the expression\r
+               selected by the predicate for which the\r
+               predicate is inappropriate\r
+\r
+        If (b) were false, then one could use a simple\r
+        predicate (assuming "-prc on"):\r
+\r
+            castExpr :\r
+                     <<isTypeName(LATEXT(2))>>?\r
+                                        LP typeName RP\r
+                     | ....\r
+                     ;\r
+\r
+            typeName : <<isTypeName(LATEXT(1))>>?  ID\r
+                     ;\r
+\r
+        So, when do you use the "&&" style guarded predicate ?\r
+\r
+        The new-style "&&" predicate should always be used with\r
+        predicate context.  The context guard is in ADDITION to\r
+        the automatically computed context.  Thus it useful for\r
+        predicates which depend on the token type for reasons\r
+        other than context.\r
+\r
+        The following example is contributed by Reinier van den Born\r
+        (reinier@vnet.ibm.com).\r
+\r
+ +-------------------------------------------------------------------------+\r
+ | This grammar has two ways to call functions:                            |\r
+ |                                                                         |\r
+ |  - a "standard" call syntax with parens and comma separated args        |\r
+ |  - a shell command like syntax (no parens and spacing separated args)   |\r
+ |                                                                         |\r
+ | The former also allows a variable to hold the name of the function,     |\r
+ | the latter can also be used to call external commands.                  |\r
+ |                                                                         |\r
+ | The grammar (simplified) looks like this:                               |\r
+ |                                                                         |\r
+ |   fun_call   :     ID "(" { expr ("," expr)* } ")"                      |\r
+ |                                  /* ID is function name */              |\r
+ |              | "@" ID "(" { expr ("," expr)* } ")"                      |\r
+ |                                  /* ID is var containing fun name */    |\r
+ |              ;                                                          |\r
+ |                                                                         |\r
+ |   command    : ID expr*          /* ID is function name */              |\r
+ |              | path expr*        /* path is external command name */    |\r
+ |              ;                                                          |\r
+ |                                                                         |\r
+ |   path       : ID                /* left out slashes and such */        |\r
+ |              | "@" ID            /* ID is environment var */            |\r
+ |              ;                                                          |\r
+ |                                                                         |\r
+ |   expr       : ....                                                     |\r
+ |              | "(" expr ")";                                            |\r
+ |                                                                         |\r
+ |   call       : fun_call                                                 |\r
+ |              | command                                                  |\r
+ |              ;                                                          |\r
+ |                                                                         |\r
+ | Obviously the call is wildly ambiguous. This is more or less how this   |\r
+ | is to be resolved:                                                      |\r
+ |                                                                         |\r
+ |    A call begins with an ID or an @ followed by an ID.                  |\r
+ |                                                                         |\r
+ |    If it is an ID and if it is an ext. command name  -> command         |\r
+ |                       if followed by a paren         -> fun_call        |\r
+ |                       otherwise                      -> command         |\r
+ |                                                                         |\r
+ |    If it is an @  and if the ID is a var name        -> fun_call        |\r
+ |                       otherwise                      -> command         |\r
+ |                                                                         |\r
+ | One can implement these rules quite neatly using && predicates:         |\r
+ |                                                                         |\r
+ |   call       : ("@" ID)? && <<isVarName(LT(2))>>? fun_call              |\r
+ |              | (ID)?     && <<isExtCmdName>>?     command               |\r
+ |              | (ID "(")?                          fun_call              |\r
+ |              |                                    command               |\r
+ |              ;                                                          |\r
+ |                                                                         |\r
+ | This can be done better, so it is not an ideal example, but it          |\r
+ | conveys the principle.                                                  |\r
+ +-------------------------------------------------------------------------+\r
+\r
+#123. (Changed in 1.33MR11) Correct definition of operators in ATokPtr.h\r
+\r
+        The return value of operators in ANTLRTokenPtr:\r
+\r
+        changed: unsigned ... operator !=(...)\r
+             to: int ... operator != (...)\r
+        changed: unsigned ... operator ==(...)\r
+             to: int ... operator == (...)\r
+\r
+        Suggested by R.A. Nelson (cowboy@VNET.IBM.COM)\r
+\r
+#122. (Changed in 1.33MR11)  Member functions to reset DLG in C++ mode\r
+\r
+         void DLGFileReset(FILE *f) { input = f; found_eof = 0; }\r
+         void DLGStringReset(DLGChar *s) { input = s; p = &input[0]; }\r
+\r
+        Supplied by R.A. Nelson (cowboy@VNET.IBM.COM)\r
+\r
+#121. (Changed in 1.33MR11)  Another attempt to fix -o (output dir) option\r
+\r
+      Another attempt is made to improve the -o option of antlr, dlg,\r
+      and sorcerer.  This one by JVincent (JVincent@novell.com).\r
+\r
+      The current rule:\r
+\r
+        a. If -o  is not specified than any explicit directory\r
+           names are retained.\r
+\r
+        b. If -o is specified than the -o directory name overrides any\r
+           explicit directory names.\r
+\r
+        c. The directory name of the grammar file is *not* stripped\r
+           to create the main output file.  However it is stil subject\r
+           to override by the -o directory name.\r
+\r
+#120. (Changed in 1.33MR11) "-info f" output to stdout rather than stderr\r
+\r
+      Added option 0 (e.g. "-info 0") which is a noop.\r
+\r
+#119. (Changed in 1.33MR11) Ambiguity aid for grammars\r
+\r
+      The user can ask for additional information on ambiguities reported\r
+      by antlr to stdout.  At the moment, only one ambiguity report can\r
+      be created in an antlr run.\r
+\r
+      This feature is enabled using the "-aa" (Ambiguity Aid)  option.\r
+\r
+      The following options control the reporting of ambiguities:\r
+\r
+          -aa ruleName       Selects reporting by name of rule\r
+          -aa lineNumber     Selects reporting by line number\r
+                               (file name not compared)\r
+\r
+          -aam               Selects "multiple" reporting for a token\r
+                             in the intersection set of the\r
+                             alternatives.\r
+\r
+                             For instance, the token ID may appear dozens\r
+                             of times in various paths as the program\r
+                             explores the rules which are reachable from\r
+                             the point of an ambiguity. With option -aam\r
+                             every possible path the search program\r
+                             encounters is reported.\r
+\r
+                             Without -aam only the first encounter is\r
+                             reported.  This may result in incomplete\r
+                             information, but the information may be\r
+                             sufficient and much shorter.\r
+\r
+          -aad depth         Selects the depth of the search.\r
+                             The default value is 1.\r
+\r
+                             The number of paths to be searched, and the\r
+                             size of the report can grow geometrically\r
+                             with the -ck value if a full search for all\r
+                             contributions to the source of the ambiguity\r
+                             is explored.\r
+\r
+                             The depth represents the number of tokens\r
+                             in the lookahead set which are matched against\r
+                             the set of ambiguous tokens.  A depth of 1\r
+                             means that the search stops when a lookahead\r
+                             sequence of just one token is matched.\r
+\r
+                             A k=1 ck=6 grammar might generate 5,000 items\r
+                             in a report if a full depth 6 search is made\r
+                             with the Ambiguity Aid.  The source of the\r
+                             problem may be in the first token and obscured\r
+                             by the volume of data - I hesitate to call\r
+                             it information.\r
+\r
+                             When the user selects a depth > 1, the search\r
+                             is first performed at depth=1 for both\r
+                             alternatives, then depth=2 for both alternatives,\r
+                             etc.\r
+\r
+      Sample output for rule grammar in antlr.g itself:\r
+\r
+  +---------------------------------------------------------------------+\r
+  | Ambiguity Aid                                                       |\r
+  |                                                                     |\r
+  |   Choice 1: grammar/70                 line 632  file a.g           |\r
+  |   Choice 2: grammar/82                 line 644  file a.g           |\r
+  |                                                                     |\r
+  |   Intersection of lookahead[1] sets:                                |\r
+  |                                                                     |\r
+  |      "\}"             "class"          "#errclass"      "#tokclass" |\r
+  |                                                                     |\r
+  |    Choice:1  Depth:1  Group:1  ("#errclass")                        |\r
+  |  1 in (...)* block                grammar/70       line 632   a.g   |\r
+  |  2 to error                       grammar/73       line 635   a.g   |\r
+  |  3 error                          error/1          line 894   a.g   |\r
+  |  4 #token "#errclass"             error/2          line 895   a.g   |\r
+  |                                                                     |\r
+  |    Choice:1  Depth:1  Group:2  ("#tokclass")                        |\r
+  |  2 to tclass                      grammar/74       line 636   a.g   |\r
+  |  3 tclass                         tclass/1         line 937   a.g   |\r
+  |  4 #token "#tokclass"             tclass/2         line 938   a.g   |\r
+  |                                                                     |\r
+  |    Choice:1  Depth:1  Group:3  ("class")                            |\r
+  |  2 to class_def                   grammar/75       line 637   a.g   |\r
+  |  3 class_def                      class_def/1      line 669   a.g   |\r
+  |  4 #token "class"                 class_def/3      line 671   a.g   |\r
+  |                                                                     |\r
+  |    Choice:1  Depth:1  Group:4  ("\}")                               |\r
+  |  2 #token "\}"                    grammar/76       line 638   a.g   |\r
+  |                                                                     |\r
+  |    Choice:2  Depth:1  Group:5  ("#errclass")                        |\r
+  |  1 in (...)* block                grammar/83       line 645   a.g   |\r
+  |  2 to error                       grammar/93       line 655   a.g   |\r
+  |  3 error                          error/1          line 894   a.g   |\r
+  |  4 #token "#errclass"             error/2          line 895   a.g   |\r
+  |                                                                     |\r
+  |    Choice:2  Depth:1  Group:6  ("#tokclass")                        |\r
+  |  2 to tclass                      grammar/94       line 656   a.g   |\r
+  |  3 tclass                         tclass/1         line 937   a.g   |\r
+  |  4 #token "#tokclass"             tclass/2         line 938   a.g   |\r
+  |                                                                     |\r
+  |    Choice:2  Depth:1  Group:7  ("class")                            |\r
+  |  2 to class_def                   grammar/95       line 657   a.g   |\r
+  |  3 class_def                      class_def/1      line 669   a.g   |\r
+  |  4 #token "class"                 class_def/3      line 671   a.g   |\r
+  |                                                                     |\r
+  |    Choice:2  Depth:1  Group:8  ("\}")                               |\r
+  |  2 #token "\}"                    grammar/96       line 658   a.g   |\r
+  +---------------------------------------------------------------------+\r
+\r
+      For a linear lookahead set ambiguity (where k=1 or for k>1 but\r
+      when all lookahead sets [i] with i<k all have degree one) the\r
+      reports appear in the following order:\r
+\r
+        for (depth=1 ; depth <= "-aad depth" ; depth++) {\r
+          for (alternative=1; alternative <=2 ; alternative++) {\r
+            while (matches-are-found) {\r
+              group++;\r
+              print-report\r
+            };\r
+          };\r
+       };\r
+\r
+      For reporting a k-tuple ambiguity, the reports appear in the\r
+      following order:\r
+\r
+        for (depth=1 ; depth <= "-aad depth" ; depth++) {\r
+          while (matches-are-found) {\r
+            for (alternative=1; alternative <=2 ; alternative++) {\r
+              group++;\r
+              print-report\r
+            };\r
+          };\r
+       };\r
+\r
+      This is because matches are generated in different ways for\r
+      linear lookahead and k-tuples.\r
+\r
+#118. (Changed in 1.33MR11) DEC VMS makefile and VMS related changes\r
+\r
+      Revised makefiles for DEC/VMS operating system for antlr, dlg,\r
+      and sorcerer.\r
+\r
+      Reduced names of routines with external linkage to less than 32\r
+      characters to conform to DEC/VMS linker limitations.\r
+\r
+      Jean-Francois Pieronne discovered problems with dlg and antlr\r
+      due to the VMS linker not being case sensitive for names with\r
+      external linkage.  In dlg the problem was with "className" and\r
+      "ClassName".  In antlr the problem was with "GenExprSets" and\r
+      "genExprSets".\r
+\r
+      Added genmms, a version of genmk for the DEC/VMS version of make.\r
+      The source is in directory pccts/support/DECmms.\r
+\r
+      All VMS contributions by Jean-Francois Pieronne (jfp@iname.com).\r
+\r
+#117. (Changed in 1.33MR10) new EXPERIMENTAL predicate hoisting code\r
+\r
+      The hoisting of predicates into rules to create prediction\r
+      expressions is a problem in antlr.  Consider the following\r
+      example (k=1 with -prc on):\r
+\r
+        start   : (a)* "@" ;\r
+        a       : b | c ;\r
+        b       : <<isUpper(LATEXT(1))>>? A ;\r
+        c       : A ;\r
+\r
+      Prior to 1.33MR10 the code generated for "start" would resemble:\r
+\r
+        while {\r
+            if (LA(1)==A &&\r
+                    (!LA(1)==A || isUpper())) {\r
+              a();\r
+            }\r
+        };\r
+\r
+      This code is wrong because it makes rule "c" unreachable from\r
+      "start".  The essence of the problem is that antlr fails to\r
+      recognize that there can be a valid alternative within "a" even\r
+      when the predicate <<isUpper(LATEXT(1))>>? is false.\r
+\r
+      In 1.33MR10 with -mrhoist the hoisting of the predicate into\r
+      "start" is suppressed because it recognizes that "c" can\r
+      cover all the cases where the predicate is false:\r
+\r
+        while {\r
+            if (LA(1)==A) {\r
+              a();\r
+            }\r
+        };\r
+\r
+      With the antlr "-info p" switch the user will receive information\r
+      about the predicate suppression in the generated file:\r
+\r
+      --------------------------------------------------------------\r
+        #if 0\r
+\r
+        Hoisting of predicate suppressed by alternative without predicate.\r
+        The alt without the predicate includes all cases where\r
+            the predicate is false.\r
+\r
+           WITH predicate: line 7  v1.g\r
+           WITHOUT predicate: line 7  v1.g\r
+\r
+        The context set for the predicate:\r
+\r
+             A\r
+\r
+        The lookahead set for the alt WITHOUT the semantic predicate:\r
+\r
+             A\r
+\r
+        The predicate:\r
+\r
+          pred <<  isUpper(LATEXT(1))>>?\r
+                          depth=k=1  rule b  line 9  v1.g\r
+            set context:\r
+               A\r
+            tree context: null\r
+\r
+        Chain of referenced rules:\r
+\r
+            #0  in rule start (line 5 v1.g) to rule a\r
+            #1  in rule a (line 7 v1.g)\r
+\r
+        #endif\r
+      --------------------------------------------------------------\r
+\r
+      A predicate can be suppressed by a combination of alternatives\r
+      which, taken together, cover a predicate:\r
+\r
+        start   : (a)* "@" ;\r
+\r
+        a       : b | ca | cb | cc ;\r
+\r
+        b       : <<isUpper(LATEXT(1))>>? ( A | B | C ) ;\r
+\r
+        ca      : A ;\r
+        cb      : B ;\r
+        cc      : C ;\r
+\r
+      Consider a more complex example in which "c" covers only part of\r
+      a predicate:\r
+\r
+        start   : (a)* "@" ;\r
+\r
+        a       : b\r
+                | c\r
+                ;\r
+\r
+        b       : <<isUpper(LATEXT(1))>>?\r
+                    ( A\r
+                    | X\r
+                    );\r
+\r
+        c       : A\r
+                ;\r
+\r
+      Prior to 1.33MR10 the code generated for "start" would resemble:\r
+\r
+        while {\r
+            if ( (LA(1)==A || LA(1)==X) &&\r
+                    (! (LA(1)==A || LA(1)==X) || isUpper()) {\r
+              a();\r
+            }\r
+        };\r
+\r
+      With 1.33MR10 and -mrhoist the predicate context is restricted to\r
+      the non-covered lookahead.  The code resembles:\r
+\r
+        while {\r
+            if ( (LA(1)==A || LA(1)==X) &&\r
+                  (! (LA(1)==X) || isUpper()) {\r
+              a();\r
+            }\r
+        };\r
+\r
+      With the antlr "-info p" switch the user will receive information\r
+      about the predicate restriction in the generated file:\r
+\r
+      --------------------------------------------------------------\r
+        #if 0\r
+\r
+        Restricting the context of a predicate because of overlap\r
+          in the lookahead set between the alternative with the\r
+          semantic predicate and one without\r
+        Without this restriction the alternative without the predicate\r
+          could not be reached when input matched the context of the\r
+          predicate and the predicate was false.\r
+\r
+           WITH predicate: line 11  v4.g\r
+           WITHOUT predicate: line 12  v4.g\r
+\r
+        The original context set for the predicate:\r
+\r
+             A                X\r
+\r
+        The lookahead set for the alt WITHOUT the semantic predicate:\r
+\r
+             A\r
+\r
+        The intersection of the two sets\r
+\r
+             A\r
+\r
+        The original predicate:\r
+\r
+          pred <<  isUpper(LATEXT(1))>>?\r
+                          depth=k=1  rule b  line 15  v4.g\r
+            set context:\r
+               A                X\r
+            tree context: null\r
+\r
+        The new (modified) form of the predicate:\r
+\r
+          pred <<  isUpper(LATEXT(1))>>?\r
+                          depth=k=1  rule b  line 15  v4.g\r
+            set context:\r
+               X\r
+            tree context: null\r
+\r
+        #endif\r
+      --------------------------------------------------------------\r
+\r
+      The bad news about -mrhoist:\r
+\r
+        (a) -mrhoist does not analyze predicates with lookahead\r
+            depth > 1.\r
+\r
+        (b) -mrhoist does not look past a guarded predicate to\r
+            find context which might cover other predicates.\r
+\r
+      For these cases you might want to use syntactic predicates.\r
+      When a semantic predicate fails during guess mode the guess\r
+      fails and the next alternative is tried.\r
+\r
+      Limitation (a) is illustrated by the following example:\r
+\r
+        start    : (stmt)* EOF ;\r
+\r
+        stmt     : cast\r
+                 | expr\r
+                 ;\r
+        cast     : <<isTypename(LATEXT(2))>>? LP ID RP ;\r
+\r
+        expr     : LP ID RP ;\r
+\r
+      This is not much different from the first example, except that\r
+      it requires two tokens of lookahead context to determine what\r
+      to do.  This predicate is NOT suppressed because the current version\r
+      is unable to handle predicates with depth > 1.\r
+\r
+      A predicate can be combined with other predicates during hoisting.\r
+      In those cases the depth=1 predicates are still handled.  Thus,\r
+      in the following example the isUpper() predicate will be suppressed\r
+      by line #4 when hoisted from "bizarre" into "start", but will still\r
+      be present in "bizarre" in order to predict "stmt".\r
+\r
+        start    : (bizarre)* EOF ;     // #1\r
+                                        // #2\r
+        bizarre  : stmt                 // #3\r
+                 | A                    // #4\r
+                 ;\r
+\r
+        stmt     : cast\r
+                 | expr\r
+                 ;\r
+\r
+        cast     : <<isTypename(LATEXT(2))>>? LP ID RP ;\r
+\r
+        expr     : LP ID RP ;\r
+                 | <<isUpper(LATEXT(1))>>? A\r
+\r
+      Limitation (b) is illustrated by the following example of a\r
+      context guarded predicate:\r
+\r
+        rule : (A)? <<p>>?          // #1\r
+                     (A             // #2\r
+                     |B             // #3\r
+                     )              // #4\r
+             | <<q>> B              // #5\r
+             ;\r
+\r
+      Recall that this means that when the lookahead is NOT A then\r
+      the predicate "p" is ignored and it attempts to match "A|B".\r
+      Ideally, the "B" at line #3 should suppress predicate "q".\r
+      However, the current version does not attempt to look past\r
+      the guard predicate to find context which might suppress other\r
+      predicates.\r
+\r
+      In some cases -mrhoist will lead to the reporting of ambiguities\r
+      which were not visible before:\r
+\r
+        start   : (a)* "@";\r
+        a       : bc | d;\r
+        bc      : b  | c ;\r
+\r
+        b       : <<isUpper(LATEXT(1))>>? A;\r
+        c       : A ;\r
+\r
+        d       : A ;\r
+\r
+      In this case there is a true ambiguity in "a" between "bc" and "d"\r
+      which can both match "A".  Without -mrhoist the predicate in "b"\r
+      is hoisted into "a" and there is no ambiguity reported.  However,\r
+      with -mrhoist, the predicate in "b" is suppressed by "c" (as it\r
+      should be) making the ambiguity in "a" apparent.\r
+\r
+      The motivations for these changes were hoisting problems reported\r
+      by Reinier van den Born (reinier@vnet.ibm.com) and several others.\r
+\r
+#116. (Changed in 1.33MR10) C++ mode: tracein/traceout rule name is (const char *)\r
+\r
+      The prototype for C++ mode routine tracein (and traceout) has changed from\r
+      "char *" to "const char *".\r
+\r
+#115. (Changed in 1.33MR10) Using guess mode with exception handlers in C mode\r
+\r
+      The definition of the C mode macros zzmatch_wsig and zzsetmatch_wsig\r
+      neglected to consider guess mode.  When control passed to the rule's\r
+      parse exception handler the routine would exit without ever closing the\r
+      guess block. This would lead to unpredictable behavior.\r
+\r
+      In 1.33MR10 the behavior of exceptions in C mode and C++ mode should be\r
+      identical.\r
+\r
+#114. (Changed in 1.33MR10) difference in [zz]resynch() between C and C++ modes\r
+\r
+      There was a slight difference in the way C and C++ mode resynchronized\r
+      following a parsing error.  The C routine would sometimes skip an extra\r
+      token before attempting to resynchronize.\r
+\r
+      The C routine was changed to match the C++ routine.\r
+\r
+#113. (Changed in 1.33MR10) new context guarded pred: (g)? && <<p>>? expr\r
+\r
+      The existing context guarded predicate:\r
+\r
+            rule : (guard)? => <<p>>? expr\r
+                 | next_alternative\r
+                 ;\r
+\r
+      generates code which resembles:\r
+\r
+            if (lookahead(expr) && (!guard || pred)) {\r
+              expr()\r
+            } else ....\r
+\r
+      This is not suitable for some applications because it allows\r
+      expr() to be invoked when the predicate is false.  This is\r
+      intentional because it is meant to mimic automatically computed\r
+      predicate context.\r
+\r
+      The new context guarded predicate uses the guard information\r
+      differently because it has a different goal.  Consider:\r
+\r
+            rule : (guard)? && <<p>>? expr\r
+                 | next_alternative\r
+                 ;\r
+\r
+      The new style of context guarded predicate is equivalent to:\r
+\r
+            rule : <<guard==true && pred>>? expr\r
+                 | next_alternative\r
+                 ;\r
+\r
+      It generates code which resembles:\r
+\r
+            if (lookahead(expr) && guard && pred) {\r
+                expr();\r
+            } else ...\r
+\r
+      Both forms of guarded predicates severely restrict the form of\r
+      the context guard: it can contain no rule references, no\r
+      (...)*, no (...)+, and no {...}.  It may contain token and\r
+      token class references, and alternation ("|").\r
+\r
+      Addition for 1.33MR11: in the token expression all tokens must\r
+      be at the same height of the token tree:\r
+\r
+            (A ( B | C))? && ...            is ok (all height 2)\r
+            (A ( B |  ))? && ...            is not ok (some 1, some 2)\r
+            (A B C D | E F G H)? && ...     is ok (all height 4)\r
+            (A B C D | E )? && ...          is not ok (some 4, some 1)\r
+\r
+      This restriction is required in order to properly compute the lookahead\r
+      set for expressions like:\r
+\r
+            rule1 : (A B C)? && <<pred>>? rule2 ;\r
+            rule2 : (A|X) (B|Y) (C|Z);\r
+\r
+      This addition was suggested by Rienier van den Born (reinier@vnet.ibm.com)\r
+\r
+#112. (Changed in 1.33MR10) failed validation predicate in C guess mode\r
+\r
+      John Lilley (jlilley@empathy.com) suggested that failed validation\r
+      predicates abort a guess rather than reporting a failed error.\r
+      This was installed in C++ mode (Item #4).  Only now was it noticed\r
+      that the fix was never installed for C mode.\r
+\r
+#111. (Changed in 1.33MR10) moved zzTRACEIN to before init action\r
+\r
+      When the antlr -gd switch is present antlr generates calls to\r
+      zzTRACEIN at the start of a rule and zzTRACEOUT at the exit\r
+      from a rule.  Prior to 1.33MR10 Tthe call to zzTRACEIN was\r
+      after the init-action, which could cause confusion because the\r
+      init-actions were reported with the name of the enclosing rule,\r
+      rather than the active rule.\r
+\r
+#110. (Changed in 1.33MR10) antlr command line copied to generated file\r
+\r
+      The antlr command line is now copied to the generated file near\r
+      the start.\r
+\r
+#109. (Changed in 1.33MR10) improved trace information\r
+\r
+      The quality of the trace information provided by the "-gd"\r
+      switch has been improved significantly.  Here is an example\r
+      of the output from a test program.  It shows the rule name,\r
+      the first token of lookahead, the call depth, and the guess\r
+      status:\r
+\r
+        exit rule gusxx {"?"} depth 2\r
+        enter rule gusxx {"?"} depth 2\r
+        enter rule gus1 {"o"} depth 3 guessing\r
+        guess done - returning to rule gus1 {"o"} at depth 3\r
+                    (guess mode continues - an enclosing guess is still active)\r
+        guess done - returning to rule gus1 {"Z"} at depth 3\r
+                    (guess mode continues - an enclosing guess is still active)\r
+        exit rule gus1 {"Z"} depth 3 guessing\r
+        guess done - returning to rule gusxx {"o"} at depth 2 (guess mode ends)\r
+        enter rule gus1 {"o"} depth 3\r
+        guess done - returning to rule gus1 {"o"} at depth 3 (guess mode ends)\r
+        guess done - returning to rule gus1 {"Z"} at depth 3 (guess mode ends)\r
+        exit rule gus1 {"Z"} depth 3\r
+        line 1: syntax error at "Z" missing SC\r
+            ...\r
+\r
+      Rule trace reporting is controlled by the value of the integer\r
+      [zz]traceOptionValue:  when it is positive tracing is enabled,\r
+      otherwise it is disabled.  Tracing during guess mode is controlled\r
+      by the value of the integer [zz]traceGuessOptionValue.  When\r
+      it is positive AND [zz]traceOptionValue is positive rule trace\r
+      is reported in guess mode.\r
+\r
+      The values of [zz]traceOptionValue and [zz]traceGuessOptionValue\r
+      can be adjusted by subroutine calls listed below.\r
+\r
+      Depending on the presence or absence of the antlr -gd switch\r
+      the variable [zz]traceOptionValueDefault is set to 0 or 1.  When\r
+      the parser is initialized or [zz]traceReset() is called the\r
+      value of [zz]traceOptionValueDefault is copied to [zz]traceOptionValue.\r
+      The value of [zz]traceGuessOptionValue is always initialzed to 1,\r
+      but, as noted earlier, nothing will be reported unless\r
+      [zz]traceOptionValue is also positive.\r
+\r
+      When the parser state is saved/restored the value of the trace\r
+      variables are also saved/restored.  If a restore causes a change in\r
+      reporting behavior from on to off or vice versa this will be reported.\r
+\r
+      When the -gd option is selected, the macro "#define zzTRACE_RULES"\r
+      is added to appropriate output files.\r
+\r
+        C++ mode\r
+        --------\r
+        int     traceOption(int delta)\r
+        int     traceGuessOption(int delta)\r
+        void    traceReset()\r
+        int     traceOptionValueDefault\r
+\r
+        C mode\r
+        --------\r
+        int     zzTraceOption(int delta)\r
+        int     zzTraceGuessOption(int delta)\r
+        void    zzTraceReset()\r
+        int     zzTraceOptionValueDefault\r
+\r
+      The argument "delta" is added to the traceOptionValue.  To\r
+      turn on trace when inside a particular rule one:\r
+\r
+        rule : <<traceOption(+1);>>\r
+               (\r
+                rest-of-rule\r
+               )\r
+               <<traceOption(-1);>>\r
+       ;  /* fail clause */ <<traceOption(-1);>>\r
+\r
+      One can use the same idea to turn *off* tracing within a\r
+      rule by using a delta of (-1).\r
+\r
+      An improvement in the rule trace was suggested by Sramji\r
+      Ramanathan (ps@kumaran.com).\r
+\r
+#108. A Note on Deallocation of Variables Allocated in Guess Mode\r
+\r
+                            NOTE\r
+        ------------------------------------------------------\r
+        This mechanism only works for heap allocated variables\r
+        ------------------------------------------------------\r
+\r
+      The rewrite of the trace provides the machinery necessary\r
+      to properly free variables or undo actions following a\r
+      failed guess.\r
+\r
+      The macro zzUSER_GUESS_HOOK(guessSeq,zzrv) is expanded\r
+      as part of the zzGUESS macro.  When a guess is opened\r
+      the value of zzrv is 0.  When a longjmp() is executed to\r
+      undo the guess, the value of zzrv will be 1.\r
+\r
+      The macro zzUSER_GUESS_DONE_HOOK(guessSeq) is expanded\r
+      as part of the zzGUESS_DONE macro.  This is executed\r
+      whether the guess succeeds or fails as part of closing\r
+      the guess.\r
+\r
+      The guessSeq is a sequence number which is assigned to each\r
+      guess and is incremented by 1 for each guess which becomes\r
+      active.  It is needed by the user to associate the start of\r
+      a guess with the failure and/or completion (closing) of a\r
+      guess.\r
+\r
+      Guesses are nested.  They must be closed in the reverse\r
+      of the order that they are opened.\r
+\r
+      In order to free memory used by a variable during a guess\r
+      a user must write a routine which can be called to\r
+      register the variable along with the current guess sequence\r
+      number provided by the zzUSER_GUESS_HOOK macro. If the guess\r
+      fails, all variables tagged with the corresponding guess\r
+      sequence number should be released.  This is ugly, but\r
+      it would require a major rewrite of antlr 1.33 to use\r
+      some mechanism other than setjmp()/longjmp().\r
+\r
+      The order of calls for a *successful* guess would be:\r
+\r
+        zzUSER_GUESS_HOOK(guessSeq,0);\r
+        zzUSER_GUESS_DONE_HOOK(guessSeq);\r
+\r
+      The order of calls for a *failed* guess would be:\r
+\r
+        zzUSER_GUESS_HOOK(guessSeq,0);\r
+        zzUSER_GUESS_HOOK(guessSeq,1);\r
+        zzUSER_GUESS_DONE_HOOK(guessSeq);\r
+\r
+      The default definitions of these macros are empty strings.\r
+\r
+      Here is an example in C++ mode.  The zzUSER_GUESS_HOOK and\r
+      zzUSER_GUESS_DONE_HOOK macros and myGuessHook() routine\r
+      can be used without change in both C and C++ versions.\r
+\r
+      ----------------------------------------------------------------------\r
+        <<\r
+\r
+        #include "AToken.h"\r
+\r
+        typedef ANTLRCommonToken ANTLRToken;\r
+\r
+        #include "DLGLexer.h"\r
+\r
+        int main() {\r
+\r
+          {\r
+            DLGFileInput     in(stdin);\r
+            DLGLexer         lexer(&in,2000);\r
+            ANTLRTokenBuffer pipe(&lexer,1);\r
+            ANTLRCommonToken aToken;\r
+            P                parser(&pipe);\r
+\r
+            lexer.setToken(&aToken);\r
+            parser.init();\r
+            parser.start();\r
+          };\r
+\r
+          fclose(stdin);\r
+          fclose(stdout);\r
+          return 0;\r
+        }\r
+\r
+        >>\r
+\r
+        <<\r
+        char *s=NULL;\r
+\r
+        #undef zzUSER_GUESS_HOOK\r
+        #define zzUSER_GUESS_HOOK(guessSeq,zzrv) myGuessHook(guessSeq,zzrv);\r
+        #undef zzUSER_GUESS_DONE_HOOK\r
+        #define zzUSER_GUESS_DONE_HOOK(guessSeq)   myGuessHook(guessSeq,2);\r
+\r
+        void myGuessHook(int guessSeq,int zzrv) {\r
+          if (zzrv == 0) {\r
+            fprintf(stderr,"User hook: starting guess #%d\n",guessSeq);\r
+          } else if (zzrv == 1) {\r
+            free (s);\r
+            s=NULL;\r
+            fprintf(stderr,"User hook: failed guess #%d\n",guessSeq);\r
+          } else if (zzrv == 2) {\r
+            free (s);\r
+            s=NULL;\r
+            fprintf(stderr,"User hook: ending guess #%d\n",guessSeq);\r
+          };\r
+        }\r
+\r
+        >>\r
+\r
+        #token A    "a"\r
+        #token      "[\t \ \n]"     <<skip();>>\r
+\r
+        class P {\r
+\r
+        start : (top)+\r
+              ;\r
+\r
+        top   : (which) ?   <<fprintf(stderr,"%s is a which\n",s); free(s); s=NULL; >>\r
+              | other       <<fprintf(stderr,"%s is an other\n",s); free(s); s=NULL; >>\r
+              ; <<if (s != NULL) free(s); s=NULL; >>\r
+\r
+        which : which2\r
+              ;\r
+\r
+        which2 : which3\r
+              ;\r
+        which3\r
+              : (label)?         <<fprintf(stderr,"%s is a label\n",s);>>\r
+              | (global)?        <<fprintf(stderr,"%s is a global\n",s);>>\r
+              | (exclamation)?   <<fprintf(stderr,"%s is an exclamation\n",s);>>\r
+              ;\r
+\r
+        label :       <<s=strdup(LT(1)->getText());>> A ":" ;\r
+\r
+        global :      <<s=strdup(LT(1)->getText());>> A "::" ;\r
+\r
+        exclamation : <<s=strdup(LT(1)->getText());>> A "!" ;\r
+\r
+        other :       <<s=strdup(LT(1)->getText());>> "other" ;\r
+\r
+        }\r
+      ----------------------------------------------------------------------\r
+\r
+      This is a silly example, but illustrates the idea.  For the input\r
+      "a ::" with tracing enabled the output begins:\r
+\r
+      ----------------------------------------------------------------------\r
+        enter rule "start" depth 1\r
+        enter rule "top" depth 2\r
+        User hook: starting guess #1\r
+        enter rule "which" depth 3 guessing\r
+        enter rule "which2" depth 4 guessing\r
+        enter rule "which3" depth 5 guessing\r
+        User hook: starting guess #2\r
+        enter rule "label" depth 6 guessing\r
+        guess failed\r
+        User hook: failed guess #2\r
+        guess done - returning to rule "which3" at depth 5 (guess mode continues\r
+                                                 - an enclosing guess is still active)\r
+        User hook: ending guess #2\r
+        User hook: starting guess #3\r
+        enter rule "global" depth 6 guessing\r
+        exit rule "global" depth 6 guessing\r
+        guess done - returning to rule "which3" at depth 5 (guess mode continues\r
+                                                 - an enclosing guess is still active)\r
+        User hook: ending guess #3\r
+        enter rule "global" depth 6 guessing\r
+        exit rule "global" depth 6 guessing\r
+        exit rule "which3" depth 5 guessing\r
+        exit rule "which2" depth 4 guessing\r
+        exit rule "which" depth 3 guessing\r
+        guess done - returning to rule "top" at depth 2 (guess mode ends)\r
+        User hook: ending guess #1\r
+        enter rule "which" depth 3\r
+        .....\r
+      ----------------------------------------------------------------------\r
+\r
+      Remember:\r
+\r
+        (a) Only init-actions are executed during guess mode.\r
+        (b) A rule can be invoked multiple times during guess mode.\r
+        (c) If the guess succeeds the rule will be called once more\r
+              without guess mode so that normal actions will be executed.\r
+            This means that the init-action might need to distinguish\r
+              between guess mode and non-guess mode using the variable\r
+              [zz]guessing.\r
+\r
+#107. (Changed in 1.33MR10) construction of ASTs in guess mode\r
+\r
+      Prior to 1.33MR10, when using automatic AST construction in C++\r
+      mode for a rule, an AST would be constructed for elements of the\r
+      rule even while in guess mode.  In MR10 this no longer occurs.\r
+\r
+#106. (Changed in 1.33MR10) guess variable confusion\r
+\r
+      In C++ mode a guess which failed always restored the parser state\r
+      using zzGUESS_DONE as part of zzGUESS_FAIL. Prior to 1.33MR10,\r
+      C mode required an explicit call to zzGUESS_DONE after the\r
+      call to zzGUESS_FAIL.\r
+\r
+      Consider:\r
+\r
+        rule : (alpha)? beta\r
+             | ...\r
+             ;\r
+\r
+      The generated code resembles:\r
+\r
+            zzGUESS\r
+            if (!zzrv && LA(1)==ID) {   <==== line #1\r
+                alpha\r
+                zzGUESS_DONE\r
+                beta\r
+            } else {\r
+              if (! zzrv) zzGUESS_DONE  <==== line #2a\r
+              ....\r
+\r
+      However, in some cases line #2 was rendered:\r
+\r
+              if (guessing) zzGUESS_DONE  <==== line #2b\r
+\r
+      This would work for simple test cases, but would fail in\r
+      some cases where there was a guess while another guess was active.\r
+      One kind of failure would be to match up the zzGUESS_DONE at line\r
+      #2b with the "outer" guess which was still active.  The outer\r
+      guess would "succeed" when only the inner guess should have\r
+      succeeded.\r
+\r
+      In 1.33MR10 the behavior of zzGUESS and zzGUESS_FAIL in C and\r
+      and C++ mode should be identical.\r
+\r
+      The same problem appears in 1.33 vanilla in some places.  For\r
+      example:\r
+\r
+            start : { (sub)? } ;\r
+\r
+      or:\r
+\r
+            start : (\r
+                       B\r
+                    |  ( sub )?\r
+                    |  C\r
+                    )+\r
+                    ;\r
+\r
+      generates incorrect code.\r
+\r
+      The general principle is:\r
+\r
+        (a) use [zz]guessing only when deciding between a call to zzFAIL\r
+              or zzGUESS_FAIL\r
+\r
+        (b) use zzrv in all other cases\r
+\r
+      This problem was discovered while testing changes to item #105.\r
+      I believe this is now fixed.  My apologies.\r
+\r
+#105. (Changed in 1.33MR10) guess block as single alt of (...)+\r
+\r
+      Prior to 1.33MR10 the following constructs:\r
+\r
+        rule_plus : (\r
+                       (sub)?\r
+                    )+\r
+                    ;\r
+\r
+        rule_star : (\r
+                      (sub)?\r
+                    )*\r
+                    ;\r
+\r
+      generated incorrect code for the guess block (which could result\r
+      in runtime errors) because of an incorrect optimization of a\r
+      block with only a single alternative.\r
+\r
+      The fix caused some changes to the fix described in Item #49\r
+      because there are now three code generation sequences for (...)+\r
+      blocks containing a guess block:\r
+\r
+        a. single alternative which is a guess block\r
+        b. multiple alternatives in which the last is a guess block\r
+        c. all other cases\r
+\r
+      Forms like "rule_star" can have unexpected behavior when there\r
+      is a syntax error: if the subrule "sub" is not matched *exactly*\r
+      then "rule_star" will consume no tokens.\r
+\r
+      Reported by Esa Pulkkinen (esap@cs.tut.fi).\r
+\r
+#104. (Changed in 1.33MR10) -o option for dlg\r
+\r
+      There was problem with the code added by item #74 to handle the\r
+      -o option of dlg.  This should fix it.\r
+\r
+#103. (Changed in 1.33MR10) ANDed semantic predicates\r
+\r
+      Rescinded.\r
+\r
+      The optimization was a mistake.\r
+      The resulting problem is described in Item #150.\r
+\r
+#102. (Changed in 1.33MR10) allow "class parser : .... {"\r
+\r
+      The syntax of the class statement ("class parser-name {")\r
+      has been extended to allow for the specification of base\r
+      classes.  An arbirtrary number of tokens may now appear\r
+      between the class name and the "{".  They are output\r
+      again when the class declaration is generated.  For\r
+      example:\r
+\r
+        class Parser : public MyBaseClassANTLRparser {\r
+\r
+      This was suggested by a user, but I don't have a record\r
+      of who it was.\r
+\r
+#101. (Changed in 1.33MR10) antlr -info command line switch\r
+\r
+        -info\r
+\r
+            p   - extra predicate information in generated file\r
+\r
+            t   - information about tnode use:\r
+                    at the end of each rule in generated file\r
+                    summary on stderr at end of program\r
+\r
+            m   - monitor progress\r
+                    prints name of each rule as it is started\r
+                    flushes output at start of each rule\r
+\r
+            f   - first/follow set information to stdout\r
+\r
+            0   - no operation (added in 1.33MR11)\r
+\r
+      The options may be combined and may appear in any order.\r
+      For example:\r
+\r
+        antlr -info ptm -CC -gt -mrhoist on mygrammar.g\r
+\r
+#100a. (Changed in 1.33MR10) Predicate tree simplification\r
+\r
+      When the same predicates can be referenced in more than one\r
+      alternative of a block large predicate trees can be formed.\r
+\r
+      The difference that these optimizations make is so dramatic\r
+      that I have decided to use it even when -mrhoist is not selected.\r
+\r
+      Consider the following grammar:\r
+\r
+        start : ( all )* ;\r
+\r
+        all   : a\r
+              | d\r
+              | e\r
+              | f\r
+              ;\r
+\r
+        a     : c A B\r
+              | c A C\r
+              ;\r
+\r
+        c     : <<AAA(LATEXT(2))>>?\r
+              ;\r
+\r
+        d     : <<BBB(LATEXT(2))>>? B C\r
+              ;\r
+\r
+        e     : <<CCC(LATEXT(2))>>? B C\r
+              ;\r
+\r
+        f     : e X Y\r
+              ;\r
+\r
+      In rule "a" there is a reference to rule "c" in both alternatives.\r
+      The length of the predicate AAA is k=2 and it can be followed in\r
+      alternative 1 only by (A B) while in alternative 2 it can be\r
+      followed only by (A C).  Thus they do not have identical context.\r
+\r
+      In rule "all" the alternatives which refer to rules "e" and "f" allow\r
+      elimination of the duplicate reference to predicate CCC.\r
+\r
+      The table below summarized the kind of simplification performed by\r
+      1.33MR10.  In the table, X and Y stand for single predicates\r
+      (not trees).\r
+\r
+        (OR X (OR Y (OR Z)))  => (OR X Y Z)\r
+        (AND X (AND Y (AND Z)))  => (AND X Y Z)\r
+\r
+        (OR X  (... (OR  X Y) ... ))     => (OR X (... Y ... ))\r
+        (AND X (... (AND X Y) ... ))     => (AND X (... Y ... ))\r
+        (OR X  (... (AND X Y) ... ))     => (OR X (...  ... ))\r
+        (AND X (... (OR  X Y) ... ))     => (AND X (...  ... ))\r
+\r
+        (AND X)               => X\r
+        (OR X)                => X\r
+\r
+      In a test with a complex grammar for a real application, a predicate\r
+      tree with six OR nodes and 12 leaves was reduced to "(OR X Y Z)".\r
+\r
+      In 1.33MR10 there is a greater effort to release memory used\r
+      by predicates once they are no longer in use.\r
+\r
+#100b. (Changed in 1.33MR10) Suppression of extra predicate tests\r
+\r
+      The following optimizations require that -mrhoist be selected.\r
+\r
+      It is relatively easy to optimize the code generated for predicate\r
+      gates when they are of the form:\r
+\r
+            (AND X Y Z ...)\r
+        or  (OR  X Y Z ...)\r
+\r
+      where X, Y, Z, and "..." represent individual predicates (leaves) not\r
+      predicate trees.\r
+\r
+      If the predicate is an AND the contexts of the X, Y, Z, etc. are\r
+      ANDed together to create a single Tree context for the group and\r
+      context tests for the individual predicates are suppressed:\r
+\r
+            --------------------------------------------------\r
+            Note: This was incorrect.  The contexts should be\r
+            ORed together.  This has been fixed.  A more \r
+            complete description is available in item #152.\r
+            ---------------------------------------------------\r
+\r
+      Optimization 1:  (AND X Y Z ...)\r
+\r
+        Suppose the context for Xtest is LA(1)==LP and the context for\r
+        Ytest is LA(1)==LP && LA(2)==ID.\r
+\r
+            Without the optimization the code would resemble:\r
+\r
+                if (lookaheadContext &&\r
+                    !(LA(1)==LP && LA(1)==LP && LA(2)==ID) ||\r
+                        ( (! LA(1)==LP || Xtest) &&\r
+                          (! (LA(1)==LP || LA(2)==ID) || Xtest)\r
+                        )) {...\r
+\r
+            With the -mrhoist optimization the code would resemble:\r
+\r
+                if (lookaheadContext &&\r
+                    ! (LA(1)==LP && LA(2)==ID) || (Xtest && Ytest) {...\r
+\r
+      Optimization 2: (OR X Y Z ...) with identical contexts\r
+\r
+        Suppose the context for Xtest is LA(1)==ID and for Ytest\r
+        the context is also LA(1)==ID.\r
+\r
+            Without the optimization the code would resemble:\r
+\r
+                if (lookaheadContext &&\r
+                    ! (LA(1)==ID || LA(1)==ID) ||\r
+                        (LA(1)==ID && Xtest) ||\r
+                        (LA(1)==ID && Ytest) {...\r
+\r
+            With the -mrhoist optimization the code would resemble:\r
+\r
+                if (lookaheadContext &&\r
+                    (! LA(1)==ID) || (Xtest || Ytest) {...\r
+\r
+      Optimization 3: (OR X Y Z ...) with distinct contexts\r
+\r
+        Suppose the context for Xtest is LA(1)==ID and for Ytest\r
+        the context is LA(1)==LP.\r
+\r
+            Without the optimization the code would resemble:\r
+\r
+                if (lookaheadContext &&\r
+                    ! (LA(1)==ID || LA(1)==LP) ||\r
+                        (LA(1)==ID && Xtest) ||\r
+                        (LA(1)==LP && Ytest) {...\r
+\r
+            With the -mrhoist optimization the code would resemble:\r
+\r
+                if (lookaheadContext &&\r
+                        (zzpf=0,\r
+                            (LA(1)==ID && (zzpf=1) && Xtest) ||\r
+                            (LA(1)==LP && (zzpf=1) && Ytest) ||\r
+                            !zzpf) {\r
+\r
+            These may appear to be of similar complexity at first,\r
+            but the non-optimized version contains two tests of each\r
+            context while the optimized version contains only one\r
+            such test, as well as eliminating some of the inverted\r
+            logic (" !(...) || ").\r
+\r
+      Optimization 4: Computation of predicate gate trees\r
+\r
+        When generating code for the gates of predicate expressions\r
+        antlr 1.33 vanilla uses a recursive procedure to generate\r
+        "&&" and "||" expressions for testing the lookahead. As each\r
+        layer of the predicate tree is exposed a new set of "&&" and\r
+        "||" expressions on the lookahead are generated.  In many\r
+        cases the lookahead being tested has already been tested.\r
+\r
+        With -mrhoist a lookahead tree is computed for the entire\r
+        lookahead expression.  This means that predicates with identical\r
+        context or context which is a subset of another predicate's\r
+        context disappear.\r
+\r
+        This is especially important for predicates formed by rules\r
+        like the following:\r
+\r
+            uppperCaseVowel : <<isUpperCase(LATEXT(1))>>?  vowel;\r
+            vowel:          : <<isVowel(LATEXT(1))>>? LETTERS;\r
+\r
+        These predicates are combined using AND since both must be\r
+        satisfied for rule upperCaseVowel.  They have identical\r
+        context which makes this optimization very effective.\r
+\r
+      The affect of Items #100a and #100b together can be dramatic.  In\r
+      a very large (but real world) grammar one particular predicate\r
+      expression was reduced from an (unreadable) 50 predicate leaves,\r
+      195 LA(1) terms, and 5500 characters to an (easily comprehensible)\r
+      3 predicate leaves (all different) and a *single* LA(1) term.\r
+\r
+#99.  (Changed in 1.33MR10) Code generation for expression trees\r
+\r
+      Expression trees are used for k>1 grammars and predicates with\r
+      lookahead depth >1.  This optimization must be enabled using\r
+      "-mrhoist on".  (Clarification added for 1.33MR11).\r
+\r
+      In the processing of expression trees, antlr can generate long chains\r
+      of token comparisons.  Prior to 1.33MR10 there were many redundant\r
+      parenthesis which caused problems for compilers which could handle\r
+      expressions of only limited complexity.  For example, to test an\r
+      expression tree (root R A B C D), antlr would generate something\r
+      resembling:\r
+\r
+        (LA(1)==R && (LA(2)==A || (LA(2)==B || (LA(2)==C || LA(2)==D)))))\r
+\r
+      If there were twenty tokens to test then there would be twenty\r
+      parenthesis at the end of the expression.\r
+\r
+      In 1.33MR10 the generated code for tree expressions resembles:\r
+\r
+        (LA(1)==R && (LA(2)==A || LA(2)==B || LA(2)==C || LA(2)==D))\r
+\r
+      For "complex" expressions the output is indented to reflect the LA\r
+      number being tested:\r
+\r
+        (LA(1)==R\r
+            && (LA(2)==A || LA(2)==B || LA(2)==C || LA(2)==D\r
+               || LA(2)==E || LA(2)==F)\r
+        || LA(1)==S\r
+            && (LA(2)==G || LA(2)==H))\r
+\r
+\r
+      Suggested by S. Bochnak (S.Bochnak@@microTool.com.pl),\r
+\r
+#98.  (Changed in 1.33MR10) Option "-info p"\r
+\r
+      When the user selects option "-info p" the program will generate\r
+      detailed information about predicates.  If the user selects\r
+      "-mrhoist on" additional detail will be provided explaining\r
+      the promotion and suppression of predicates.  The output is part\r
+      of the generated file and sandwiched between #if 0/#endif statements.\r
+\r
+      Consider the following k=1 grammar:\r
+\r
+        start : ( all ) * ;\r
+\r
+        all   : ( a\r
+                | b\r
+                )\r
+                ;\r
+\r
+        a     : c B\r
+              ;\r
+\r
+        c     : <<LATEXT(1)>>?\r
+              | B\r
+              ;\r
+\r
+        b     : <<LATEXT(1)>>? X\r
+              ;\r
+\r
+      Below is an excerpt of the output for rule "start" for the three\r
+      predicate options (off, on, and maintenance release style hoisting).\r
+\r
+      For those who do not wish to use the "-mrhoist on" option for code\r
+      generation the option can be used in a "diagnostic" mode to provide\r
+      valuable information:\r
+\r
+            a. where one should insert null actions to inhibit hoisting\r
+            b. a chain of rule references which shows where predicates are\r
+               being hoisted\r
+\r
+      ======================================================================\r
+      Example of "-info p" with "-mrhoist on"\r
+      ======================================================================\r
+        #if 0\r
+\r
+        Hoisting of predicate suppressed by alternative without predicate.\r
+        The alt without the predicate includes all cases where the\r
+           predicate is false.\r
+\r
+           WITH predicate: line 11  v36.g\r
+           WITHOUT predicate: line 12  v36.g\r
+\r
+        The context set for the predicate:\r
+\r
+             B\r
+\r
+        The lookahead set for alt WITHOUT the semantic predicate:\r
+\r
+             B\r
+\r
+        The predicate:\r
+\r
+          pred <<  LATEXT(1)>>?  depth=k=1  rule c  line 11  v36.g\r
+\r
+            set context:\r
+               B\r
+            tree context: null\r
+\r
+        Chain of referenced rules:\r
+\r
+            #0  in rule start (line 1 v36.g) to rule all\r
+            #1  in rule all (line 3 v36.g) to rule a\r
+            #2  in rule a (line 8 v36.g) to rule c\r
+            #3  in rule c (line 11 v36.g)\r
+\r
+        #endif\r
+        &&\r
+        #if 0\r
+\r
+        pred <<  LATEXT(1)>>?  depth=k=1  rule b  line 15  v36.g\r
+\r
+          set context:\r
+             X\r
+          tree context: null\r
+\r
+        #endif\r
+      ======================================================================\r
+      Example of "-info p"  with the default -prc setting ( "-prc off")\r
+      ======================================================================\r
+        #if 0\r
+\r
+        OR\r
+          pred <<  LATEXT(1)>>?  depth=k=1  rule c  line 11  v36.g\r
+\r
+            set context:\r
+              nil\r
+            tree context: null\r
+\r
+          pred <<  LATEXT(1)>>?  depth=k=1  rule b  line 15  v36.g\r
+\r
+            set context:\r
+              nil\r
+            tree context: null\r
+\r
+        #endif\r
+      ======================================================================\r
+      Example of "-info p" with "-prc on" and "-mrhoist off"\r
+      ======================================================================\r
+        #if 0\r
+\r
+        OR\r
+          pred <<  LATEXT(1)>>?  depth=k=1  rule c  line 11  v36.g\r
+\r
+            set context:\r
+               B\r
+            tree context: null\r
+\r
+          pred <<  LATEXT(1)>>?  depth=k=1  rule b  line 15  v36.g\r
+\r
+            set context:\r
+               X\r
+            tree context: null\r
+\r
+        #endif\r
+      ======================================================================\r
+\r
+#97.  (Fixed in 1.33MR10) "Predicate applied for more than one ... "\r
+\r
+      In 1.33 vanilla, the grammar listed below produced this message for\r
+      the first alternative (only) of rule "b":\r
+\r
+            warning: predicate applied for >1 lookahead 1-sequences\r
+                [you may only want one lookahead 1-sequence to apply.\r
+                Try using a context guard '(...)? =>'\r
+\r
+      In 1.33MR10 the message is issued for both alternatives.\r
+\r
+          top     : (a)*;\r
+          a       : b | c ;\r
+\r
+          b       : <<PPP(LATEXT(1))>>? ( AAA | BBB )\r
+                  | <<QQQ(LATEXT(1))>>? ( XXX | YYY )\r
+                  ;\r
+\r
+          c       : AAA | XXX;\r
+\r
+#96.  (Fixed in 1.33MR10) Guard predicates ignored when -prc off\r
+\r
+      Prior to 1.33MR10, guard predicate code was not generated unless\r
+      "-prc on" was selected.\r
+\r
+      This was incorrect, since "-prc off"  (the default) is supposed to\r
+      disable only AUTOMATIC computation of predicate context, not the\r
+      programmer specified context supplied by guard predicates.\r
+\r
+#95.  (Fixed in 1.33MR10) Predicate guard context length was k, not max(k,ck)\r
+\r
+      Prior to 1.33MR10, predicate guards were computed to k tokens rather\r
+      than max(k,ck).  Consider the following grammar:\r
+\r
+        a     : ( A B C)? => <<AAA(LATEXT(1))>>? (A|X) (B|Y) (C|Z) ;\r
+\r
+      The code generated by 1.33 vanilla with "-k 1 -ck 3 -prc on"\r
+      for the predicate in "a" resembles:\r
+\r
+        if ( (! LA(1)==A) || AAA(LATEXT(1))) {...\r
+\r
+      With 1.33MR10 and the same options the code resembles:\r
+\r
+        if ( (! (LA(1)==A && LA(2)==B && LA(3)==C) || AAA(LATEXT(1))) {...\r
+\r
+#94.  (Fixed in 1.33MR10) Predicates followed by rule references\r
+\r
+      Prior to 1.33MR10, a semantic predicate which referenced a token\r
+      which was off the end of the rule caused an incomplete context\r
+      to be computed (with "-prc on") for the predicate under some circum-\r
+      stances.  In some cases this manifested itself as illegal C code\r
+      (e.g. "LA(2)==[Ep](1)" in the k=2 examples below:\r
+\r
+          all     : ( a ) *;\r
+\r
+          a       : <<AAA(LATEXT(2))>>? ID X\r
+                  | <<BBB(LATEXT(2))>>? Y\r
+                  | Z\r
+                  ;\r
+\r
+      This might also occur when the semantic predicate was followed\r
+      by a rule reference which was shorter than the length of the\r
+      semantic predicate:\r
+\r
+        all       : ( a ) *;\r
+\r
+        a         : <<AAA(LATEXT(2))>>? ID X\r
+                  | <<BBB(LATEXT(2))>>? y\r
+                  | Z\r
+                  ;\r
+\r
+        y         : Y ;\r
+\r
+      Depending on circumstance, the resulting context might be too\r
+      generous because it was too short, or too restrictive because\r
+      of missing alternatives.\r
+\r
+#93.  (Changed in 1.33MR10) Definition of Purify macro\r
+\r
+      Ofer Ben-Ami (gremlin@cs.huji.ac.il) has supplied a definition\r
+      for the Purify macro:\r
+\r
+        #define PURIFY(r, s) memset((char *) &(r), '\0', (s));\r
+\r
+      Note: This may not be the right thing to do for C++ objects that\r
+      have constructors.  Reported by Bonny Rais (bonny@werple.net.au).\r
+\r
+      For those cases one should #define PURIFY to an empty macro in the\r
+      #header or #first actions.\r
+\r
+#92.  (Fixed in 1.33MR10) Guarded predicates and hoisting\r
+\r
+      When a guarded predicate participates in hoisting it is linked into\r
+      a predicate expression tree.  Prior to 1.33MR10 this link was never\r
+      cleared and the next time the guard was used to construct a new\r
+      tree the link could contain a spurious reference to another element\r
+      which had previosly been joined to it in the semantic predicate tree.\r
+\r
+      For example:\r
+\r
+        start  : ( all ) *;\r
+        all    : ( a | b ) ;\r
+\r
+        start2 : ( all2 ) *;\r
+        all2    : ( a ) ;\r
+\r
+        a     : (A)? => <<AAA(LATEXT(1))>>?  A ;\r
+        b     : (B)? => <<BBB(LATEXT(1))>>?  B ;\r
+\r
+      Prior to 1.33MR10 the code for "start2" would include a spurious\r
+      reference to the BBB predicate which was left from constructing\r
+      the predicate tree for rule "start" (i.e. or(AAA,BBB) ).\r
+\r
+      In 1.33MR10 this problem is avoided by cloning the original guard\r
+      each time it is linked into a predicate tree.\r
+\r
+#91.  (Changed in 1.33MR10) Extensive changes to semantic pred hoisting\r
+\r
+            ============================================\r
+            This has been rendered obsolete by Item #117\r
+            ============================================\r
+\r
+#90.  (Fixed in 1.33MR10) Semantic pred with LT(i) and i>max(k,ck)\r
+\r
+      There is a bug in antlr 1.33 vanilla and all maintenance releases\r
+      prior to 1.33MR10 which allows semantic predicates to reference\r
+      an LT(i) or LATEXT(i) where i is larger than max(k,ck).  When\r
+      this occurs antlr will attempt to mark the ith element of an array\r
+      in which there are only max(k,ck) elements.  The result cannot\r
+      be predicted.\r
+\r
+      Using LT(i) or LATEXT(i) for i>max(k,ck) is reported as an error\r
+      in 1.33MR10.\r
+\r
+#89.  Rescinded\r
+\r
+#88.  (Fixed in 1.33MR10) Tokens used in semantic predicates in guess mode\r
+\r
+        Consider the behavior of a semantic predicate during guess mode:\r
+\r
+            rule : a:A (\r
+                         <<test($a)>>? b:B\r
+                         | c:C\r
+                       );\r
+\r
+        Prior to MR10 the assignment of the token or attribute to\r
+        $a did not occur during guess mode, which would cause the\r
+        semantic predicate to misbehave because $a would be null.\r
+\r
+        In 1.33MR10 a semantic predicate with a reference to an\r
+        element label (such as $a) forces the assignment to take\r
+        place even in guess mode.\r
+\r
+        In order to work, this fix REQUIRES use of the $label format\r
+        for token pointers and attributes referenced in semantic\r
+        predicates.\r
+\r
+        The fix does not apply to semantic predicates using the\r
+        numeric form to refer to attributes (e.g. <<test($1)>>?).\r
+        The user will receive a warning for this case.\r
+\r
+        Reported by Rob Trout (trout@mcs.cs.kent.edu).\r
+\r
+#87.  (Fixed in 1.33MR10) Malformed guard predicates\r
+\r
+      Context guard predicates may contain only references to\r
+      tokens.  They may not contain references to (...)+ and\r
+      (...)* blocks.  This is now checked.  This replaces the\r
+      fatal error message in item #78 with an appropriate\r
+      (non-fatal) error messge.\r
+\r
+      In theory, context guards should be allowed to reference\r
+      rules.  However, I have not had time to fix this.\r
+      Evaluation of the guard takes place before all rules have\r
+      been read, making it difficult to resolve a forward reference\r
+      to rule "zzz" - it hasn't been read yet !  To postpone evaluation\r
+      of the guard until all rules have been read is too much\r
+      for the moment.\r
+\r
+#86.  (Fixed in 1.33MR10) Unequal set size in set_sub\r
+\r
+      Routine set_sub() in pccts/support/set/set.h  did not work\r
+      correctly when the sets were of unequal sizes.  Rewrote\r
+      set_equ to make it simpler and remove unnecessary and\r
+      expensive calls to set_deg().  This routine was not used\r
+      in 1.33 vanila.\r
+\r
+#85.  (Changed in 1.33MR10) Allow redefinition of MaxNumFiles\r
+\r
+      Raised the maximum number of input files to 99 from 20.\r
+      Put a #ifndef/#endif around the "#define MaxNumFiles 99".\r
+\r
+#84.  (Fixed in 1.33MR10) Initialize zzBadTok in macro zzRULE\r
+\r
+      Initialize zzBadTok to NULL in zzRULE macro of AParser.h.\r
+      in order to get rid of warning messages.\r
+\r
+#83.  (Fixed in 1.33MR10) False warnings with -w2 for #tokclass\r
+\r
+      When -w2 is selected antlr gives inappropriate warnings about\r
+      #tokclass names not having any associated regular expressions.\r
+      Since a #tokclass is not a "real" token it will never have an\r
+      associated regular expression and there should be no warning.\r
+\r
+      Reported by Derek Pappas (derek.pappas@eng.sun.com)\r
+\r
+#82.  (Fixed in 1.33MR10) Computation of follow sets with multiple cycles\r
+\r
+      Reinier van den Born (reinier@vnet.ibm.com) reported a problem\r
+      in the computation of follow sets by antlr.  The problem (bug)\r
+      exists in 1.33 vanilla and all maintenance releases prior to 1.33MR10.\r
+\r
+      The problem involves the computation of follow sets when there are\r
+      cycles - rules which have mutual references.  I believe the problem\r
+      is restricted to cases where there is  more than one cycle AND\r
+      elements of those cycles have rules in common.  Even when this\r
+      occurs it may not affect the code generated - but it might.  It\r
+      might also lead to undetected ambiguities.\r
+\r
+      There were no changes in antlr or dlg output from the revised version.\r
+\r
+      The following fragment demonstates the problem by giving different\r
+      follow sets (option -pa) for var_access when built with k=1 and ck=2 on\r
+      1.33 vanilla and 1.33MR10:\r
+\r
+        echo_statement : ECHO ( echo_expr )*\r
+                       ;\r
+\r
+        echo_expr      : ( command )?\r
+                       | expression\r
+                       ;\r
+\r
+        command        : IDENTIFIER\r
+                             { concat }\r
+                       ;\r
+\r
+        expression     : operand ( OPERATOR operand )*\r
+                       ;\r
+\r
+        operand        : value\r
+                       | START command END\r
+                       ;\r
+\r
+        value          : concat\r
+                       | TYPE operand\r
+                       ;\r
+\r
+        concat         : var_access { CONCAT value }\r
+                       ;\r
+\r
+        var_access     : IDENTIFIER { INDEX }\r
+\r
+                       ;\r
+#81.  (Changed in 1.33MR10) C mode use of attributes and ASTs\r
+\r
+       Reported by Isaac Clark (irclark@mindspring.com).\r
+\r
+       C mode code ignores attributes returned by rules which are\r
+       referenced using element labels when ASTs are enabled (-gt option).\r
+\r
+         1. start : r:rule t:Token <<$start=$r;>>\r
+\r
+                The $r refrence will not work when combined with\r
+                the -gt option.\r
+\r
+         2. start : t:Token         <<$start=$t;>>\r
+\r
+                The $t reference works in all cases.\r
+\r
+         3. start : rule            <<$0=$1;>>\r
+\r
+                Numeric labels work in all cases.\r
+\r
+       With MR10 the user will receive an error message for case 1 when\r
+       the -gt option is used.\r
+\r
+#80.  (Fixed in 1.33MR10) (...)? as last alternative of block\r
+\r
+        A construct like the following:\r
+\r
+            rule : a\r
+                 | (b)?\r
+                 ;\r
+\r
+        does not make sense because there is no alternative when\r
+        the guess block fails.  This is now reported as a warning\r
+        to the user.\r
+\r
+        Previously, there was a code generation error for this case:\r
+        the guess block was not "closed"  when the guess failed.\r
+        This could cause an infinite loop or other problems.  This\r
+        is now fixed.\r
+\r
+        Example problem:\r
+\r
+            #header<<\r
+            #include <stdio.h>\r
+            #include "charptr.h"\r
+            >>\r
+\r
+            <<\r
+            #include "charptr.c"\r
+            main ()\r
+            {\r
+             ANTLR(start(),stdin);\r
+            }\r
+            >>\r
+\r
+            #token "[\ \t]+"        << zzskip(); >>\r
+            #token "[\n]"           << zzline++; zzskip(); >>\r
+\r
+            #token Word     "[a-z]+"\r
+            #token Number   "[0-9]+"\r
+\r
+\r
+            start : (test1)?\r
+                  | (test2)?\r
+                  ;\r
+            test1 : (Word Word Word Word)?\r
+                  | (Word Word Word Number)?\r
+                  ;\r
+            test2 : (Word Word Number Word)?\r
+                  | (Word Word Number Number)?\r
+            ;\r
+\r
+        Test data which caused infinite loop:\r
+\r
+            a 1 a a\r
+\r
+#79.  (Changed in 1.33MR10) Use of -fh with multiple parsers\r
+\r
+        Previously, antlr always used the pre-processor symbol\r
+        STDPCCTS_H as a gate for the file stdpccts.h.  This\r
+        caused problems when there were multiple parsers defined\r
+        because they used the same gate symbol.\r
+\r
+        In 1.33MR10, the -fh filename is used to generate the\r
+        gate file for stdpccts.h.  For instance:\r
+\r
+            antlr -fh std_parser1.h\r
+\r
+        generates the pre-processor symbol "STDPCCTS_std_parser1_H".\r
+\r
+        Reported by Ramanathan Santhanam (ps@kumaran.com).\r
+\r
+#78.  (Changed in 1.33MR9) Guard predicates that refer to rules\r
+\r
+                ------------------------\r
+                Please refer to Item #87\r
+                ------------------------\r
+\r
+        Guard predicates are processed during an early phase\r
+        of antlr (during parsing) before all data structures\r
+        are completed.\r
+\r
+        There is an apparent bug in earlier versions of 1.33\r
+        which caused guard predicates which contained references\r
+        to rules (rather than tokens) to reference a structure\r
+        which hadn't yet been initialized.\r
+\r
+        In some cases (perhaps all cases) references to rules\r
+        in guard predicates resulted in the use of "garbage".\r
+\r
+#79.  (Changed in 1.33MR9) Jeff Vincent (JVincent@novell.com)\r
+\r
+        Previously, the maximum length file name was set\r
+        arbitrarily to 300 characters in antlr, dlg, and sorcerer.\r
+\r
+        The config.h file now attempts to define the maximum length\r
+        filename using _MAX_PATH from stdlib.h before falling back\r
+        to using the value 300.\r
+\r
+#78.  (Changed in 1.33MR9) Jeff Vincent (JVincent@novell.com)\r
+\r
+        Put #ifndef/#endif around definition of ZZLEXBUFSIZE in\r
+        antlr.\r
+\r
+#77.  (Changed in 1.33MR9) Arithmetic overflow for very large grammars\r
+\r
+        In routine HandleAmbiguities() antlr attempts to compute the\r
+        number of possible elements in a set that is order of\r
+        number-of-tokens raised to the number-of-lookahead-tokens power.\r
+        For large grammars or large lookahead (e.g. -ck 7) this can\r
+        cause arithmetic overflow.\r
+\r
+        With 1.33MR9, arithmetic overflow in this computation is reported\r
+        the first time it happens.  The program continues to run and\r
+        the program branches based on the assumption that the computed\r
+        value is larger than any number computed by counting actual cases\r
+        because 2**31 is larger than the number of bits in most computers.\r
+\r
+        Before 1.33MR9 overflow was not reported.  The behavior following\r
+        overflow is not predictable by anyone but the original author.\r
+\r
+                            NOTE\r
+\r
+            In 1.33MR10 the warning message is suppressed.\r
+            The code which detects the overflow allows the\r
+            computation to continue without an error.  The\r
+            error message itself made made users worry.\r
+\r
+#76.  (Changed in 1.33MR9) Jeff Vincent (JVincent@novell.com)\r
+\r
+        Jeff Vincent has convinced me to make ANTLRCommonToken and\r
+        ANTLRCommonNoRefCountToken use variable length strings\r
+        allocated from the heap rather than fixed length strings.\r
+        By suitable definition of setText(), the copy constructor,\r
+        and operator =() it is possible to maintain "copy" semantics.\r
+        By "copy" semantics I mean that when a token is copied from\r
+        an existing token it receives its own, distinct, copy of the\r
+        text allocated from the heap rather than simply a pointer\r
+        to the original token's text.\r
+\r
+        ============================================================\r
+                        W * A * R * N * I * N * G\r
+        ============================================================\r
+\r
+        It is possible that this may cause problems for some users.\r
+        For those users I have included the old version of AToken.h as\r
+        pccts/h/AToken_traditional.h.\r
+\r
+#75.  (Changed in 1.33MR9) Bruce Guenter (bruceg@qcc.sk.ca)\r
+\r
+        Make DLGStringInput const correct.  Since this is infrequently\r
+        subclassed, it should affect few users, I hope.\r
+\r
+#74.  (Changed in 1.33MR9) -o (output directory) option\r
+\r
+        Antlr does not properly handle the -o output directory option\r
+        when the filename of the grammar contains a directory part.  For\r
+        example:\r
+\r
+            antlr -o outdir pccts_src/myfile.g\r
+\r
+        causes antlr create a file called "outdir/pccts_src/myfile.cpp.\r
+        It SHOULD create outdir/myfile.cpp\r
+\r
+        The suggested code fix has been installed in antlr, dlg, and\r
+        Sorcerer.\r
+\r
+#73.  (Changed in 1.33MR9) Hoisting of semantic predicates and -mrhoist\r
+\r
+            ============================================\r
+            This has been rendered obsolete by Item #117\r
+            ============================================\r
+\r
+#72.  (Changed in 1.33MR9) virtual saveState()/restoreState()/guess_XXX\r
+\r
+        The following methods in ANTLRParser were made virtual at\r
+        the request of S. Bochnak (S.Bochnak@microTool.com.pl):\r
+\r
+            saveState() and restoreState()\r
+            guess(), guess_fail(), and guess_done()\r
+\r
+#71.  (Changed in 1.33MR9) Access to omitted command line argument\r
+\r
+        If a switch requiring arguments is the last thing on the\r
+        command line, and the argument is omitted, antlr would core.\r
+\r
+            antlr test.g -prc\r
+\r
+        instead of\r
+\r
+            antlr test.g -prc off\r
+\r
+#70.  (Changed in 1.33MR9) Addition of MSVC .dsp and .mak build files\r
+\r
+        The following MSVC .dsp and .mak files for pccts and sorcerer\r
+        were contributed by Stanislaw Bochnak (S.Bochnak@microTool.com.pl)\r
+        and Jeff Vincent (JVincent@novell.com)\r
+\r
+        PCCTS Distribution Kit\r
+        ----------------------\r
+        pccts/PCCTSMSVC50.dsw\r
+\r
+        pccts/antlr/AntlrMSVC50.dsp\r
+        pccts/antlr/AntlrMSVC50.mak\r
+\r
+        pccts/dlg/DlgMSVC50.dsp\r
+        pccts/dlg/DlgMSVC50.mak\r
+\r
+        pccts/support/msvc.dsp\r
+\r
+        Sorcerer Distribution Kit\r
+        -------------------------\r
+        pccts/sorcerer/SorcererMSVC50.dsp\r
+        pccts/sorcerer/SorcererMSVC50.mak\r
+\r
+        pccts/sorcerer/lib/msvc.dsp\r
+\r
+#69.  (Changed in 1.33MR9) Change "unsigned int" to plain "int"\r
+\r
+       Declaration of max_token_num in misc.c as "unsigned int"\r
+       caused comparison between signed and unsigned ints giving\r
+       warning message without any special benefit.\r
+\r
+#68.  (Changed in 1.33MR9) Add void return for dlg internal_error()\r
+\r
+       Get rid of "no return value" message in internal_error()\r
+       in file dlg/support.c and dlg/dlg.h.\r
+\r
+#67.  (Changed in Sor) sor.g: lisp() has no return value\r
+\r
+       Added a "void" for the return type.\r
+\r
+#66.  (Added to Sor) sor.g: ZZLEXBUFSIZE enclosed in #ifndef/#endif\r
+\r
+       A user needed to be able to change the ZZLEXBUFSIZE for\r
+       sor. Put the definition of ZZLEXBUFSIZE inside #ifndef/#endif\r
+\r
+#65.  (Changed in 1.33MR9) PCCTSAST::deepCopy() and ast_dup() bug\r
+\r
+       Jeff Vincent (JVincent@novell.com) found that deepCopy()\r
+       made new copies of only the direct descendents.  No new\r
+       copies were made of sibling nodes,  Sibling pointers are\r
+       set to zero by shallowCopy().\r
+\r
+           PCCTS_AST::deepCopy() has been changed to make a\r
+           deep copy in the traditional sense.\r
+\r
+           The deepCopy() routine depends on the behavior of\r
+           shallowCopy().  In all sor examples I've found,\r
+           shallowCopy() zeroes the right and down pointers.\r
+\r
+       Original Tree       Original deepCopy()     Revised deepCopy\r
+       -------------       -------------------     ----------------\r
+            a->b->c         A                       A\r
+            |               |                       |\r
+            d->e->f         D                       D->E->F\r
+            |               |                       |\r
+            g->h->i         G                       G->H->I\r
+               |                                       |\r
+               j->k                                    J->K\r
+\r
+        While comparing deepCopy() for C++ mode with ast_dup for\r
+        C mode I found a problem with ast_dup().\r
+\r
+           Routine ast_dup() has been changed to make a deep copy\r
+           in the traditional sense.\r
+\r
+       Original Tree       Original ast_dup()      Revised ast_dup()\r
+       -------------       -------------------     ----------------\r
+            a->b->c         A->B->C                 A\r
+            |               |                       |\r
+            d->e->f         D->E->F                 D->E->F\r
+            |               |                       |\r
+            g->h->i         G->H->I                 G->H->I\r
+               |               |                       |\r
+               j->k            J->K                    J->K\r
+\r
+\r
+        I believe this affects transform mode sorcerer programs only.\r
+\r
+#64.  (Changed in 1.33MR9) anltr/hash.h prototype for killHashTable()\r
+\r
+#63.  (Changed in 1.33MR8) h/charptr.h does not zero pointer after free\r
+\r
+        The charptr.h routine now zeroes the pointer after free().\r
+\r
+        Reported by Jens Tingleff (jensting@imaginet.fr)\r
+\r
+#62.  (Changed in 1.33MR8) ANTLRParser::resynch had static variable\r
+\r
+        The static variable "consumed" in ANTLRParser::resynch was\r
+        changed into an instance variable of the class with the\r
+        name "resynchConsumed".\r
+\r
+        Reported by S.Bochnak@microTool.com.pl\r
+\r
+#61.  (Changed in 1.33MR8) Using rule>[i,j] when rule has no return values\r
+\r
+        Previously, the following code would cause antlr to core when\r
+        it tried to generate code for rule1 because rule2 had no return\r
+        values ("upward inheritance"):\r
+\r
+            rule1 : <<int i; int j>>\r
+                    rule2 > [i,j]\r
+                  ;\r
+\r
+            rule2 : Anything ;\r
+\r
+        Reported by S.Bochnak@microTool.com.pl\r
+\r
+        Verified correct operation of antlr MR8 when missing or extra\r
+        inheritance arguments for all combinations.  When there are\r
+        missing or extra arguments code will still be generated even\r
+        though this might cause the invocation of a subroutine with\r
+        the wrong number of arguments.\r
+\r
+#60.  (Changed in 1.33MR7) Major changes to exception handling\r
+\r
+        There were significant problems in the handling of exceptions\r
+        in 1.33 vanilla.  The general problem is that it can only\r
+        process one level of exception handler.  For example, a named\r
+        exception handler, an exception handler for an alternative, or\r
+        an exception for a subrule  always went to the rule's exception\r
+        handler if there was no "catch" which matched the exception.\r
+\r
+        In 1.33MR7 the exception handlers properly "nest".  If an\r
+        exception handler does not have a matching "catch" then the\r
+        nextmost outer exception handler is checked for an appropriate\r
+        "catch" clause, and so on until an exception handler with an\r
+        appropriate "catch" is found.\r
+\r
+        There are still undesirable features in the way exception\r
+        handlers are implemented, but I do not have time to fix them\r
+        at the moment:\r
+\r
+            The exception handlers for alternatives are outside the\r
+            block containing the alternative.  This makes it impossible\r
+            to access variables declared in a block or to resume the\r
+            parse by "falling through".  The parse can still be easily\r
+            resumed in other ways, but not in the most natural fashion.\r
+\r
+            This results in an inconsistentcy between named exception\r
+            handlers and exception handlers for alternatives.  When\r
+            an exception handler for an alternative "falls through"\r
+            it goes to the nextmost outer handler - not the "normal\r
+            action".\r
+\r
+        A major difference between 1.33MR7 and 1.33 vanilla is\r
+        the default action after an exception is caught:\r
+\r
+            1.33 Vanilla\r
+            ------------\r
+            In 1.33 vanilla the signal value is set to zero ("NoSignal")\r
+            and the code drops through to the code following the exception.\r
+            For named exception handlers this is the "normal action".\r
+            For alternative exception handlers this is the rule's handler.\r
+\r
+            1.33MR7\r
+            -------\r
+            In 1.33MR7 the signal value is NOT automatically set to zero.\r
+\r
+            There are two cases:\r
+\r
+                For named exception handlers: if the signal value has been\r
+                set to zero the code drops through to the "normal action".\r
+\r
+                For all other cases the code branches to the nextmost outer\r
+                exception handler until it reaches the handler for the rule.\r
+\r
+        The following macros have been defined for convenience:\r
+\r
+            C/C++ Mode Name\r
+            --------------------\r
+            (zz)suppressSignal\r
+                  set signal & return signal arg to 0 ("NoSignal")\r
+            (zz)setSignal(intValue)\r
+                  set signal & return signal arg to some value\r
+            (zz)exportSignal\r
+                  copy the signal value to the return signal arg\r
+\r
+        I'm not sure why PCCTS make a distinction between the local\r
+        signal value and the return signal argument, but I'm loathe\r
+        to change the code. The burden of copying the local signal\r
+        value to the return signal argument can be given to the\r
+        default signal handler, I suppose.\r
+\r
+#59.  (Changed in 1.33MR7) Prototypes for some functions\r
+\r
+        Added prototypes for the following functions to antlr.h\r
+\r
+            zzconsumeUntil()\r
+            zzconsumeUntilToken()\r
+\r
+#58.  (Changed in 1.33MR7) Added defintion of zzbufsize to dlgauto.h\r
+\r
+#57.  (Changed in 1.33MR7) Format of #line directive\r
+\r
+        Previously, the -gl directive for line 1234 would\r
+        resemble:  "# 1234 filename.g".  This caused problems\r
+        for some compilers/pre-processors.  In MR7 it generates\r
+        "#line 1234 filename.g".\r
+\r
+#56.  (Added in 1.33MR7) Jan Mikkelsen <janm@zeta.org.au>\r
+\r
+        Move PURIFY macro invocaton to after rule's init action.\r
+\r
+#55.  (Fixed in 1.33MR7) Unitialized variables in ANTLRParser\r
+\r
+        Member variables inf_labase and inf_last were not initialized.\r
+        (See item #50.)\r
+\r
+#54.  (Fixed in 1.33MR6) Brad Schick (schick@interacess.com)\r
+\r
+        Previously, the following constructs generated the same\r
+        code:\r
+\r
+        rule1 : (A B C)?\r
+              | something-else\r
+              ;\r
+\r
+        rule2 : (A B C)? ()\r
+              | something-else\r
+              ;\r
+\r
+        In all versions of pccts rule1 guesses (A B C) and then\r
+        consume all three tokens if the guess succeeds.  In MR6\r
+        rule2 guesses (A B C)  but consumes NONE of the tokens\r
+        when the guess succeeds because "()" matches epsilon.\r
+\r
+#53.  (Explanation for 1.33MR6) What happens after an exception is caught ?\r
+\r
+        The Book is silent about what happens after an exception\r
+        is caught.\r
+\r
+        The following code fragment prints "Error Action" followed\r
+        by "Normal Action".\r
+\r
+        test : Word ex:Number <<printf("Normal Action\n");>>\r
+                exception[ex]\r
+                   catch NoViableAlt:\r
+                        <<printf("Error Action\n");>>\r
+        ;\r
+\r
+        The reason for "Normal Action" is that the normal flow of the\r
+        program after a user-written exception handler is to "drop through".\r
+        In the case of an exception handler for a rule this results in\r
+        the exection of a "return" statement.  In the case of an\r
+        exception handler attached to an alternative, rule, or token\r
+        this is the code that would have executed had there been no\r
+        exception.\r
+\r
+        The user can achieve the desired result by using a "return"\r
+        statement.\r
+\r
+        test : Word ex:Number <<printf("Normal Action\n");>>\r
+                exception[ex]\r
+                   catch NoViableAlt:\r
+                        <<printf("Error Action\n"); return;>>\r
+        ;\r
+\r
+        The most powerful mechanism for recovery from parse errors\r
+        in pccts is syntactic predicates because they provide\r
+        backtracking.  Exceptions allow "return", "break",\r
+        "consumeUntil(...)", "goto _handler", "goto _fail", and\r
+        changing the _signal value.\r
+\r
+#52.  (Fixed in 1.33MR6) Exceptions without syntactic predicates\r
+\r
+        The following generates bad code in 1.33 if no syntactic\r
+        predicates are present in the grammar.\r
+\r
+        test : Word ex:Number <<printf("Normal Action\n");>>\r
+                exception[ex]\r
+                   catch NoViableAlt:\r
+                        <<printf("Error Action\n");>>\r
+\r
+        There is a reference to a guess variable.  In C mode\r
+        this causes a compiler error.  In C++ mode it generates\r
+        an extraneous check on member "guessing".\r
+\r
+        In MR6 correct code is generated for both C and C++ mode.\r
+\r
+#51.  (Added to 1.33MR6) Exception operator "@" used without exceptions\r
+\r
+        In MR6 added a warning when the exception operator "@" is\r
+        used and no exception group is defined.  This is probably\r
+        a case where "\@" or "@" is meant.\r
+\r
+#50.  (Fixed in 1.33MR6) Gunnar Rxnning (gunnar@candleweb.no)\r
+                                    http://www.candleweb.no/~gunnar/\r
+\r
+        Routines zzsave_antlr_state and zzrestore_antlr_state don't\r
+        save and restore all the data needed when switching states.\r
+\r
+        Suggested patch applied to antlr.h and err.h for MR6.\r
+\r
+#49.  (Fixed in 1.33MR6) Sinan Karasu (sinan@boeing.com)\r
+\r
+        Generated code failed to turn off guess mode when leaving a\r
+        (...)+ block which contained a guess block.  The result was\r
+        an infinite loop.  For example:\r
+\r
+                rule : (\r
+                         (x)?\r
+                         | y\r
+                       )+\r
+\r
+        Suggested code fix implemented in MR6.  Replaced\r
+\r
+            ... else if (zzcnt>1) break;\r
+\r
+        with:\r
+\r
+          C++ mode:\r
+              ... else if (zzcnt>1) {if (!zzrv) zzGUESS_DONE; break;};\r
+          C mode:\r
+              ... else if (zzcnt>1) {if (zzguessing) zzGUESS_DONE; break;};\r
+\r
+#48.  (Fixed in 1.33MR6) Invalid exception element causes core\r
+\r
+        A label attached to an invalid construct can cause\r
+        pccts to crash while processing the exception associated\r
+        with the label.  For example:\r
+\r
+        rule : t:(B C)\r
+                exception[t] catch MismatchedToken: <<printf(...);>>\r
+\r
+        Version MR6 generates the message:\r
+\r
+           reference in exception handler to undefined label 't'\r
+\r
+#47.  (Fixed in 1.33MR6) Manuel Ornato\r
+\r
+        Under some circumstances involving a k >1 or ck >1\r
+        grammar and a loop block (i.e.  (...)* ) pccts will\r
+        fail to detect a syntax error and loop indefinitely.\r
+        The problem did not exist in 1.20, but has existed\r
+        from 1.23 to the present.\r
+\r
+        Fixed in MR6.\r
+\r
+        ---------------------------------------------------\r
+        Complete test program\r
+        ---------------------------------------------------\r
+        #header<<\r
+        #include <stdio.h>\r
+        #include "charptr.h"\r
+        >>\r
+\r
+        <<\r
+        #include "charptr.c"\r
+        main ()\r
+        {\r
+         ANTLR(global(),stdin);\r
+        }\r
+        >>\r
+\r
+        #token "[\ \t]+"        << zzskip(); >>\r
+        #token "[\n]"           << zzline++; zzskip(); >>\r
+\r
+        #token B        "b"\r
+        #token C        "c"\r
+        #token D        "d"\r
+        #token E        "e"\r
+        #token LP       "\("\r
+        #token RP       "\)"\r
+\r
+        #token ANTLREOF "@"\r
+\r
+        global : (\r
+                   (E liste)\r
+                 | liste\r
+                 | listed\r
+                 )  ANTLREOF\r
+        ;\r
+\r
+        listeb : LP ( B ( B | C )* ) RP ;\r
+        listec : LP ( C ( B | C )* ) RP ;\r
+        listed : LP ( D ( B | C )* ) RP ;\r
+        liste : ( listeb | listec )* ;\r
+\r
+        ---------------------------------------------------\r
+        Sample data causing infinite loop\r
+        ---------------------------------------------------\r
+        e (d c)\r
+        ---------------------------------------------------\r
+\r
+#46.  (Fixed in 1.33MR6) Robert Richter\r
+                (Robert.Richter@infotech.tu-chemnitz.de)\r
+\r
+        This item from the list of known problems was\r
+        fixed by item #18 (below).\r
+\r
+#45.  (Fixed in 1.33MR6) Brad Schick (schick@interaccess.com)\r
+\r
+        The dependency scanner in VC++ mistakenly sees a\r
+        reference to an MPW #include file even though properly\r
+        #ifdef/#endif in config.h.  The suggested workaround\r
+        has been implemented:\r
+\r
+                #ifdef MPW\r
+                .....\r
+                #define MPW_CursorCtl_Header <CursorCtl.h>\r
+                #include MPW_CursorCtl_Header\r
+                .....\r
+                #endif\r
+\r
+#44.  (Fixed in 1.33MR6) cast malloc() to (char *) in charptr.c\r
+\r
+        Added (char *) cast for systems where malloc returns "void *".\r
+\r
+#43.  (Added to 1.33MR6) Bruce Guenter (bruceg@qcc.sk.ca)\r
+\r
+        Add setLeft() and setUp methods to ASTDoublyLinkedBase\r
+        for symmetry with setRight() and setDown() methods.\r
+\r
+#42.  (Fixed in 1.33MR6) Jeff Katcher (jkatcher@nortel.ca)\r
+\r
+        C++ style comment in antlr.c corrected.\r
+\r
+#41.  (Added in 1.33MR6) antlr -stdout\r
+\r
+        Using "antlr -stdout ..." forces the text that would\r
+        normally go to the grammar.c or grammar.cpp file to\r
+        stdout.\r
+\r
+#40.  (Added in 1.33MR6) antlr -tab to change tab stops\r
+\r
+        Using "antlr -tab number ..." changes the tab stops\r
+        for the grammar.c or grammar.cpp file.  The number\r
+        must be between 0 and 8.  Using 0 gives tab characters,\r
+        values between 1 and 8 give the appropriate number of\r
+        space characters.\r
+\r
+#39.  (Fixed in 1.33MR5) Jan Mikkelsen <janm@zeta.org.au>\r
+\r
+        Commas in function prototype still not correct under\r
+        some circumstances.  Suggested code fix installed.\r
+\r
+#38.  (Fixed in 1.33MR5) ANTLRTokenBuffer constructor\r
+\r
+        Have ANTLRTokenBuffer ctor initialize member "parser" to null.\r
+\r
+#37.  (Fixed in 1.33MR4) Bruce Guenter (bruceg@qcc.sk.ca)\r
+\r
+        In ANTLRParser::FAIL(int k,...) released memory pointed to by\r
+        f[i] (as well as f itself.  Should only free f itself.\r
+\r
+#36.  (Fixed in 1.33MR3) Cortland D. Starrett (cort@shay.ecn.purdue.edu)\r
+\r
+        Neglected to properly declare isDLGmaxToken() when fixing problem\r
+        reported by Andreas Magnusson.\r
+\r
+        Undo "_retv=NULL;" change which caused problems for return values\r
+        from rules whose return values weren't pointers.\r
+\r
+        Failed to create bin directory if it didn't exist.\r
+\r
+#35.  (Fixed in 1.33MR2) Andreas Magnusson\r
+(Andreas.Magnusson@mailbox.swipnet.se)\r
+\r
+        Repair bug introduced by 1.33MR1 for #tokdefs.  The original fix\r
+        placed "DLGmaxToken=9999" and "DLGminToken=0" in the TokenType enum\r
+        in order to fix a problem with an aggresive compiler assigning an 8\r
+        bit enum which might be too narrow.  This caused #tokdefs to assume\r
+        that there were 9999 real tokens.  The repair to the fix causes antlr to\r
+        ignore TokenTypes "DLGmaxToken" and "DLGminToken" in a #tokdefs file.\r
+\r
+#34.  (Added to 1.33MR1) Add public DLGLexerBase::set_line(int newValue)\r
+\r
+        Previously there was no public function for changing the line\r
+        number maintained by the lexer.\r
+\r
+#33.  (Fixed in 1.33MR1) Franklin Chen   (chen@adi.com)\r
+\r
+        Accidental use of EXIT_FAILURE rather than PCCTS_EXIT_FAILURE\r
+        in pccts/h/AParser.cpp.\r
+\r
+#32.  (Fixed in 1.33MR1) Franklin Chen   (chen@adi.com)\r
+\r
+        In PCCTSAST.cpp lines 405 and 466:  Change\r
+\r
+                free (t)\r
+           to\r
+                free ( (char *)t );\r
+\r
+        to match prototype.\r
+\r
+#31.   (Added to 1.33MR1) Pointer to parser in ANTLRTokenBuffer\r
+                        Pointer to parser in DLGLexerBase\r
+\r
+        The ANTLRTokenBuffer class now contains a pointer to the\r
+        parser which is using it.  This is established by the\r
+        ANTLRParser constructor calling ANTLRTokenBuffer::\r
+        setParser(ANTLRParser *p).\r
+\r
+        When ANTLRTokenBuffer::setParser(ANTLRParser *p) is\r
+        called it saves the pointer to the parser and then\r
+        calls ANTLRTokenStream::setParser(ANTLRParser *p)\r
+        so that the lexer can also save a pointer to the\r
+        parser.\r
+\r
+        There is also a function getParser() in each class\r
+        with the obvious purpose.\r
+\r
+        It is possible that these functions will return NULL\r
+        under some circumstances (e.g. a non-DLG lexer is used).\r
+\r
+#30.   (Added to 1.33MR1) function tokenName(int token) standard\r
+\r
+        The generated parser class now includes the\r
+        function:\r
+\r
+          static const ANTLRChar * tokenName(int token)\r
+\r
+        which returns a pointer to the "name" corresponding\r
+        to the token.\r
+\r
+        The base class (ANTLRParser) always includes the\r
+        member function:\r
+\r
+          const ANTLRChar * parserTokenName(int token)\r
+\r
+        which can be accessed by objects which have a pointer\r
+        to an ANTLRParser, but do not know the name of the\r
+        parser class (e.g. ANTLRTokenBuffer and DLGLexerBase).\r
+\r
+#29.   (Added to 1.33MR1) Debugging DLG lexers\r
+\r
+        If the pre-processor symbol DEBUG_LEXER is defined\r
+        then DLexerBase will include code for printing out\r
+        key information about tokens which are recognized.\r
+\r
+        The debug feature of the lexer is controlled by:\r
+\r
+          int previousDebugValue=lexer.debugLexer(newValue);\r
+\r
+                        a value of 0 disables output\r
+                        a value of 1 enables output\r
+\r
+        Even if the lexer debug code is compiled into DLexerBase\r
+        it must be enabled before any output is generated.  For\r
+        example:\r
+\r
+           DLGFileInput         in(stdin);\r
+           MyDLG                lexer(&in,2000);\r
+\r
+           lexer.setToken(&aToken);\r
+\r
+           #if DEBUG_LEXER\r
+             lexer.debugLexer(1);       // enable debug information\r
+           #endif\r
+\r
+#28.   (Added to 1.33MR1) More control over DLG header\r
+\r
+        Version 1.33MR1 adds the following directives to PCCTS\r
+        for C++ mode:\r
+\r
+          #lexprefix  <<source code>>\r
+\r
+                Adds source code to the DLGLexer.h file\r
+                after the #include "DLexerBase.h" but\r
+                before the start of the class definition.\r
+\r
+          #lexmember  <<source code>>\r
+\r
+                Adds source code to the DLGLexer.h file\r
+                as part of the DLGLexer class body.  It\r
+                appears immediately after the start of\r
+                the class and a "public: statement.\r
+\r
+#27.   (Fixed in 1.33MR1) Comments in DLG actions\r
+\r
+        Previously, DLG would not recognize comments as a special case.\r
+        Thus, ">>" in the comments would cause errors.  This is fixed.\r
+\r
+#26.   (Fixed in 1.33MR1) Removed static variables from error routines\r
+\r
+        Previously, the existence of statically allocated variables\r
+        in some of the parser's member functions posed a danger when\r
+        there was more than one parser active.\r
+\r
+        Replaced with dynamically allocated/freed variables in 1.33MR1.\r
+\r
+#25.  (Fixed in 1.33MR1)  Use of string literals in semantic predicates\r
+\r
+        Previously, it was not possible to place a string literal in\r
+        a semantic predicate because it was not properly "stringized"\r
+        for the report of a failed predicate.\r
+\r
+#24.  (Fixed in 1.33MR1)  Continuation lines for semantic predicates\r
+\r
+        Previously, it was not possible to continue semantic\r
+        predicates across a line because it was not properly\r
+        "stringized" for the report of a failed predicate.\r
+\r
+                rule : <<ifXYZ()>>?[ a very\r
+                                        long statement ]\r
+\r
+#23.  (Fixed in 1.33MR1)  {...} envelope for failed semantic predicates\r
+\r
+        Previously, there was a code generation error for failed\r
+        semantic predicates:\r
+\r
+          rule : <<xyz()>>?[ stmt1; stmt2; ]\r
+\r
+        which generated code which resembled:\r
+\r
+          if (! xyz()) stmt1; stmt2;\r
+\r
+        It now puts the statements in a {...} envelope:\r
+\r
+          if (! xyz()) { stmt1; stmt2; };\r
+\r
+#22.  (Fixed in 1.33MR1)  Continuation of #token across lines using "\"\r
+\r
+        Previously, it was not possible to continue a #token regular\r
+        expression across a line.  The trailing "\" and newline caused\r
+        a newline to be inserted into the regular expression by DLG.\r
+\r
+        Fixed in 1.33MR1.\r
+\r
+#21.  (Fixed in 1.33MR1)  Use of ">>" (right shift operator in DLG actions\r
+\r
+        It is now possible to use the C++ right shift operator ">>"\r
+        in DLG actions by using the normal escapes:\r
+\r
+                #token "shift-right"     << value=value \>\> 1;>>\r
+\r
+#20.  (Version 1.33/19-Jan-97 Karl Eccleson <karle@microrobotics.co.uk>\r
+                            P.A. Keller (P.A.Keller@bath.ac.uk)\r
+\r
+        There is a problem due to using exceptions with the -gh option.\r
+\r
+        Suggested fix now in 1.33MR1.\r
+\r
+#19.  (Fixed in 1.33MR1)             Tom Piscotti and John Lilley\r
+\r
+        There were problems suppressing messages to stdin and stdout\r
+        when running in a window environment because some functions\r
+        which uses fprint were not virtual.\r
+\r
+        Suggested change now in 1.33MR1.\r
+\r
+        I believe all functions containing error messages (excluding those\r
+        indicating internal inconsistency) have been placed in functions\r
+        which are virtual.\r
+\r
+#18.  (Version 1.33/ 22-Nov-96)  John Bair (jbair@iftime.com)\r
+\r
+        Under some combination of options a required "return _retv" is\r
+        not generated.\r
+\r
+        Suggested fix now in 1.33MR1.\r
+\r
+#17.  (Version 1.33/3-Sep-96) Ron House  (house@helios.usq.edu.au)\r
+\r
+        The routine ASTBase::predorder_action omits two "tree->"\r
+        prefixes, which results in the preorder_action belonging\r
+        to the wrong node to be invoked.\r
+\r
+        Suggested fix now in 1.33MR1.\r
+\r
+#16.  (Version 1.33/7-Jun-96)       Eli Sternheim <eli@interhdl.com>\r
+\r
+        Routine consumeUntilToken() does not check for end-of-file\r
+        condition.\r
+\r
+        Suggested fix now in 1.33MR1.\r
+\r
+#15.  (Version 1.33/8 Apr 96)   Asgeir Olafsson <olafsson@cstar.ac.com>\r
+\r
+        Problem with tree duplication of doubly linked ASTs in ASTBase.cpp.\r
+\r
+        Suggested fix now in 1.33MR1.\r
+\r
+#14.  (Version 1.33/28-Feb-96)   Andreas.Magnusson@mailbox.swipnet.se\r
+\r
+        Problem with definition of operator = (const ANTLRTokenPtr rhs).\r
+\r
+        Suggested fix now in 1.33MR1.\r
+\r
+#13.  (Version 1.33/13-Feb-96) Franklin Chen (chen@adi.com)\r
+\r
+        Sun C++ Compiler 3.0.1 can't compile testcpp/1 due to goto in\r
+        block with destructors.\r
+\r
+        Apparently fixed. Can't locate "goto".\r
+\r
+#12.  (Version 1.33/10-Nov-95)  Minor problems with 1.33 code\r
+\r
+        The following items have been fixed in 1.33MR1:\r
+\r
+          1.  pccts/antlr/main.c line 142\r
+\r
+                "void" appears in classic C code\r
+\r
+          2.  no makefile in support/genmk\r
+\r
+          3.  EXIT_FAILURE/_SUCCESS instead of PCCTS_EXIT_FAILURE/_SUCCESS\r
+\r
+                pccts/h/PCCTSAST.cpp\r
+                pccts/h/DLexerBase.cpp\r
+                pccts/testcpp/6/test.g\r
+\r
+          4.  use of "signed int" isn't accepted by AT&T cfront\r
+\r
+                pccts/h/PCCTSAST.h line 42\r
+\r
+          5.  in call to ANTLRParser::FAIL the var arg err_k is passed as\r
+              "int" but is declared "unsigned int".\r
+\r
+          6.  I believe that a failed validation predicate still does not\r
+              get put in a "{...}" envelope, despite the release notes.\r
+\r
+          7. The #token ">>" appearing in the DLG grammar description\r
+             causes DLG to generate the string literal "\>\>" which\r
+             is non-conforming and will cause some compilers to\r
+             complain (scan.c function act10 line 143 of source code).\r
+\r
+#11.  (Version 1.32b6)  Dave Kuhlman     (dkuhlman@netcom.com)\r
+\r
+        Problem with file close in gen.c.  Already fixed in 1.33.\r
+\r
+#10.  (Version 1.32b6/29-Aug-95)\r
+\r
+        pccts/antlr/main.c contains a C++ style comments on lines 149\r
+        and 176 which causes problems for most C compilers.\r
+\r
+         Already fixed in 1.33.\r
+\r
+#9.   (Version 1.32b4/14-Mar-95) dlgauto.h #include "config.h"\r
+\r
+        The file pccts/h/dlgauto.h should probably contain a #include\r
+        "config.h" as it uses the #define symbol __USE_PROTOS.\r
+\r
+        Added to 1.33MR1.\r
+\r
+#8.   (Version 1.32b4/6-Mar-95)  Michael T. Richter (mtr@igs.net)\r
+\r
+        In C++ output mode anonymous tokens from in-line regular expressions\r
+        can create enum values which are too wide for the datatype of the enum\r
+        assigned by the C++ compiler.\r
+\r
+        Fixed in 1.33MR1.\r
+\r
+#7.   (Version 1.32b4/6-Mar-95)  C++ does not imply __STDC__\r
+\r
+        In err.h the combination of # directives assumes that a C++\r
+        compiler has __STDC__ defined.  This is not necessarily true.\r
+\r
+        This problem also appears in the use of __USE_PROTOS which\r
+        is appropriate for both Standard C and C++ in antlr/gen.c\r
+        and antlr/lex.c\r
+\r
+        Fixed in 1.33MR1.\r
+\r
+#6.   (Version 1.32 ?/15-Feb-95) Name conflict for "TokenType"\r
+\r
+        Already fixed in 1.33.\r
+\r
+#5.   (23-Jan-95)        Douglas_Cuthbertson.JTIDS@jtids_qmail.hanscom.af.mil\r
+\r
+        The fail action following a semantic predicate is not enclosed in\r
+        "{...}". This can lead to problems when the fail action contains\r
+        more than one statement.\r
+\r
+        Fixed in 1.33MR1.\r
+\r
+#4 .  (Version 1.33/31-Mar-96)   jlilley@empathy.com (John Lilley)\r
+\r
+        Put briefly, a semantic predicate ought to abort a guess if it fails.\r
+\r
+        Correction suggested by J. Lilley has been added to 1.33MR1.\r
+\r
+#3 .  (Version 1.33)             P.A.Keller@bath.ac.uk\r
+\r
+        Extra commas are placed in the K&R style argument list for rules\r
+        when using both exceptions and ASTs.\r
+\r
+        Fixed in 1.33MR1.\r
+\r
+#2.   (Version 1.32b6/2-Oct-95)  Brad Schick <schick@interaccess.com>\r
+\r
+        Construct #[] generates zzastnew() in C++ mode.\r
+\r
+        Already fixed in 1.33.\r
+\r
+#1.   (Version 1.33)     Bob Bailey (robert@oakhill.sps.mot.com)\r
+\r
+        Previously, config.h assumed that all PC systems required\r
+        "short" file names.  The user can now override that\r
+        assumption with "#define LONGFILENAMES".\r
+\r
+        Added to 1.33MR1.\r
diff --git a/Tools/CodeTools/Source/Pccts/CHANGES_SUMMARY.txt b/Tools/CodeTools/Source/Pccts/CHANGES_SUMMARY.txt
new file mode 100644 (file)
index 0000000..91defae
--- /dev/null
@@ -0,0 +1,2049 @@
+======================================================================\r
+\r
+                       CHANGES_SUMMARY.TXT\r
+\r
+        A QUICK overview of changes from 1.33 in reverse order\r
+\r
+  A summary of additions rather than bug fixes and minor code changes.\r
+\r
+          Numbers refer to items in CHANGES_FROM_133*.TXT\r
+             which may contain additional information.\r
+\r
+                          DISCLAIMER\r
+\r
+ The software and these notes are provided "as is".  They may include\r
+ typographical or technical errors and their authors disclaims all\r
+ liability of any kind or nature for damages due to error, fault,\r
+ defect, or deficiency regardless of cause.  All warranties of any\r
+ kind, either express or implied, including, but not limited to, the\r
+ implied  warranties of merchantability and fitness for a particular\r
+ purpose are disclaimed.\r
+\r
+======================================================================\r
+\r
+#258. You can specify a user-defined base class for your parser\r
+\r
+    The base class must constructor must have a signature similar to\r
+    that of ANTLRParser.\r
+\r
+#253. Generation of block preamble (-preamble and -preamble_first)\r
+\r
+    The antlr option -preamble causes antlr to insert the code\r
+    BLOCK_PREAMBLE at the start of each rule and block.\r
+\r
+    The antlr option -preamble_first is similar, but inserts the\r
+    code BLOCK_PREAMBLE_FIRST(PreambleFirst_123) where the symbol\r
+    PreambleFirst_123 is equivalent to the first set defined by\r
+    the #FirstSetSymbol described in Item #248.\r
+\r
+#248. Generate symbol for first set of an alternative\r
+\r
+        rr : #FirstSetSymbol(rr_FirstSet)  ( Foo | Bar ) ;\r
+\r
+#216. Defer token fetch for C++ mode\r
+\r
+    When the ANTLRParser class is built with the pre-processor option \r
+    ZZDEFER_FETCH defined, the fetch of new tokens by consume() is deferred\r
+    until LA(i) or LT(i) is called. \r
+\r
+#215. Use reset() to reset DLGLexerBase\r
+#188. Added pccts/h/DLG_stream_input.h\r
+#180. Added ANTLRParser::getEofToken()\r
+#173. -glms for Microsoft style filenames with -gl\r
+#170. Suppression for predicates with lookahead depth >1\r
+\r
+      Consider the following grammar with -ck 2 and the predicate in rule\r
+      "a" with depth 2:\r
+\r
+            r1  : (ab)* "@"\r
+                ;\r
+\r
+            ab  : a\r
+                | b\r
+                ;\r
+\r
+            a   : (A B)? => <<p(LATEXT(2))>>? A B C\r
+                ;\r
+\r
+            b   : A B C\r
+                ;\r
+\r
+      Normally, the predicate would be hoisted into rule r1 in order to\r
+      determine whether to call rule "ab".  However it should *not* be\r
+      hoisted because, even if p is false, there is a valid alternative\r
+      in rule b.  With "-mrhoistk on" the predicate will be suppressed.\r
+\r
+      If "-info p" command line option is present the following information\r
+      will appear in the generated code:\r
+\r
+                while ( (LA(1)==A)\r
+        #if 0\r
+\r
+        Part (or all) of predicate with depth > 1 suppressed by alternative\r
+            without predicate\r
+\r
+        pred  <<  p(LATEXT(2))>>?\r
+                  depth=k=2  ("=>" guard)  rule a  line 8  t1.g\r
+          tree context:\r
+            (root = A\r
+               B\r
+            )\r
+\r
+        The token sequence which is suppressed: ( A B )\r
+        The sequence of references which generate that sequence of tokens:\r
+\r
+           1 to ab          r1/1       line 1     t1.g\r
+           2 ab             ab/1       line 4     t1.g\r
+           3 to b           ab/2       line 5     t1.g\r
+           4 b              b/1        line 11    t1.g\r
+           5 #token A       b/1        line 11    t1.g\r
+           6 #token B       b/1        line 11    t1.g\r
+\r
+        #endif\r
+\r
+      A slightly more complicated example:\r
+\r
+            r1  : (ab)* "@"\r
+                ;\r
+\r
+            ab  : a\r
+                | b\r
+                ;\r
+\r
+            a   : (A B)? => <<p(LATEXT(2))>>? (A  B | D E)\r
+                ;\r
+\r
+            b   : <<q(LATEXT(2))>>? D E\r
+                ;\r
+\r
+\r
+      In this case, the sequence (D E) in rule "a" which lies behind\r
+      the guard is used to suppress the predicate with context (D E)\r
+      in rule b.\r
+\r
+                while ( (LA(1)==A || LA(1)==D)\r
+            #if 0\r
+\r
+            Part (or all) of predicate with depth > 1 suppressed by alternative\r
+                without predicate\r
+\r
+            pred  <<  q(LATEXT(2))>>?\r
+                              depth=k=2  rule b  line 11  t2.g\r
+              tree context:\r
+                (root = D\r
+                   E\r
+                )\r
+\r
+            The token sequence which is suppressed: ( D E )\r
+            The sequence of references which generate that sequence of tokens:\r
+\r
+               1 to ab          r1/1       line 1     t2.g\r
+               2 ab             ab/1       line 4     t2.g\r
+               3 to a           ab/1       line 4     t2.g\r
+               4 a              a/1        line 8     t2.g\r
+               5 #token D       a/1        line 8     t2.g\r
+               6 #token E       a/1        line 8     t2.g\r
+\r
+            #endif\r
+            &&\r
+            #if 0\r
+\r
+            pred  <<  p(LATEXT(2))>>?\r
+                              depth=k=2  ("=>" guard)  rule a  line 8  t2.g\r
+              tree context:\r
+                (root = A\r
+                   B\r
+                )\r
+\r
+            #endif\r
+\r
+            (! ( LA(1)==A && LA(2)==B ) || p(LATEXT(2)) )  {\r
+                ab();\r
+                ...\r
+\r
+#165. (Changed in MR13) option -newAST\r
+\r
+      To create ASTs from an ANTLRTokenPtr antlr usually calls\r
+      "new AST(ANTLRTokenPtr)".  This option generates a call\r
+      to "newAST(ANTLRTokenPtr)" instead.  This allows a user\r
+      to define a parser member function to create an AST object.\r
+\r
+#161. (Changed in MR13) Switch -gxt inhibits generation of tokens.h\r
+\r
+#158. (Changed in MR13) #header causes problem for pre-processors\r
+\r
+      A user who runs the C pre-processor on antlr source suggested\r
+      that another syntax be allowed.  With MR13 such directives\r
+      such as #header, #pragma, etc. may be written as "\#header",\r
+      "\#pragma", etc.  For escaping pre-processor directives inside\r
+      a #header use something like the following:\r
+\r
+            \#header\r
+            <<\r
+                \#include <stdio.h>\r
+            >>\r
+\r
+#155. (Changed in MR13) Context behind predicates can suppress\r
+\r
+      With -mrhoist enabled the context behind a guarded predicate can\r
+      be used to suppress other predicates.  Consider the following grammar:\r
+\r
+        r0 : (r1)+;\r
+\r
+        r1  : rp\r
+            | rq\r
+            ;\r
+        rp  : <<p LATEXT(1)>>? B ;\r
+        rq : (A)? => <<q LATEXT(1)>>? (A|B);\r
+\r
+      In earlier versions both predicates "p" and "q" would be hoisted into\r
+      rule r0. With MR12c predicate p is suppressed because the context which\r
+      follows predicate q includes "B" which can "cover" predicate "p".  In\r
+      other words, in trying to decide in r0 whether to call r1, it doesn't\r
+      really matter whether p is false or true because, either way, there is\r
+      a valid choice within r1.\r
+\r
+#154. (Changed in MR13) Making hoist suppression explicit using <<nohoist>>\r
+\r
+      A common error, even among experienced pccts users, is to code\r
+      an init-action to inhibit hoisting rather than a leading action.\r
+      An init-action does not inhibit hoisting.\r
+\r
+      This was coded:\r
+\r
+        rule1 : <<;>> rule2\r
+\r
+      This is what was meant:\r
+\r
+        rule1 : <<;>> <<;>> rule2\r
+\r
+      With MR13, the user can code:\r
+\r
+        rule1 : <<;>> <<nohoist>> rule2\r
+\r
+      The following will give an error message:\r
+\r
+        rule1 : <<nohoist>> rule2\r
+\r
+      If the <<nohoist>> appears as an init-action rather than a leading\r
+      action an error message is issued.  The meaning of an init-action\r
+      containing "nohoist" is unclear: does it apply to just one\r
+      alternative or to all alternatives ?\r
+\r
+#151a. Addition of ANTLRParser::getLexer(), ANTLRTokenStream::getLexer()\r
+\r
+      You must manually cast the ANTLRTokenStream to your program's\r
+      lexer class. Because the name of the lexer's class is not fixed.\r
+      Thus it is impossible to incorporate it into the DLGLexerBase\r
+      class.\r
+\r
+#151b.(Changed in MR12) ParserBlackBox member getLexer()\r
+\r
+#150. (Changed in MR12) syntaxErrCount and lexErrCount now public\r
+\r
+#149. (Changed in MR12) antlr option -info o (letter o for orphan)\r
+\r
+      If there is more than one rule which is not referenced by any\r
+      other rule then all such rules are listed.  This is useful for\r
+      alerting one to rules which are not used, but which can still\r
+      contribute to ambiguity.\r
+\r
+#148. (Changed in MR11) #token names appearing in zztokens,token_tbl\r
+\r
+      One can write:\r
+\r
+            #token Plus ("+")             "\+"\r
+            #token RP   ("(")             "\("\r
+            #token COM  ("comment begin") "/\*"\r
+\r
+      The string in parenthesis will be used in syntax error messages.\r
+\r
+#146. (Changed in MR11) Option -treport for locating "difficult" alts\r
+\r
+      It can be difficult to determine which alternatives are causing\r
+      pccts to work hard to resolve an ambiguity.  In some cases the\r
+      ambiguity is successfully resolved after much CPU time so there\r
+      is no message at all.\r
+\r
+      A rough measure of the amount of work being peformed which is\r
+      independent of the CPU speed and system load is the number of\r
+      tnodes created.  Using "-info t" gives information about the\r
+      total number of tnodes created and the peak number of tnodes.\r
+\r
+        Tree Nodes:  peak 1300k  created 1416k  lost 0\r
+\r
+      It also puts in the generated C or C++ file the number of tnodes\r
+      created for a rule (at the end of the rule).  However this\r
+      information is not sufficient to locate the alternatives within\r
+      a rule which are causing the creation of tnodes.\r
+\r
+      Using:\r
+\r
+             antlr -treport 100000 ....\r
+\r
+      causes antlr to list on stdout any alternatives which require the\r
+      creation of more than 100,000 tnodes, along with the lookahead sets\r
+      for those alternatives.\r
+\r
+      The following is a trivial case from the ansi.g grammar which shows\r
+      the format of the report.  This report might be of more interest\r
+      in cases where 1,000,000 tuples were created to resolve the ambiguity.\r
+\r
+      -------------------------------------------------------------------------\r
+        There were 0 tuples whose ambiguity could not be resolved\r
+             by full lookahead\r
+        There were 157 tnodes created to resolve ambiguity between:\r
+\r
+          Choice 1: statement/2  line 475  file ansi.g\r
+          Choice 2: statement/3  line 476  file ansi.g\r
+\r
+            Intersection of lookahead[1] sets:\r
+\r
+               IDENTIFIER\r
+\r
+            Intersection of lookahead[2] sets:\r
+\r
+               LPARENTHESIS     COLON            AMPERSAND        MINUS\r
+               STAR             PLUSPLUS         MINUSMINUS       ONESCOMPLEMENT\r
+               NOT              SIZEOF           OCTALINT         DECIMALINT\r
+               HEXADECIMALINT   FLOATONE         FLOATTWO         IDENTIFIER\r
+               STRING           CHARACTER\r
+      -------------------------------------------------------------------------\r
+\r
+#143. (Changed in MR11) Optional ";" at end of #token statement\r
+\r
+      Fixes problem of:\r
+\r
+            #token X "x"\r
+\r
+            <<\r
+                parser action\r
+            >>\r
+\r
+      Being confused with:\r
+\r
+            #token X "x" <<lexical action>>\r
+\r
+#142. (Changed in MR11) class BufFileInput subclass of DLGInputStream\r
+\r
+      Alexey Demakov (demakov@kazbek.ispras.ru) has supplied class\r
+      BufFileInput derived from DLGInputStream which provides a\r
+      function lookahead(char *string) to test characters in the\r
+      input stream more than one character ahead.\r
+      The class is located in pccts/h/BufFileInput.* of the kit.\r
+\r
+#140. #pred to define predicates\r
+\r
+      +---------------------------------------------------+\r
+      | Note: Assume "-prc on" for this entire discussion |\r
+      +---------------------------------------------------+\r
+\r
+      A problem with predicates is that each one is regarded as\r
+      unique and capable of disambiguating cases where two\r
+      alternatives have identical lookahead.  For example:\r
+\r
+        rule : <<pred(LATEXT(1))>>? A\r
+             | <<pred(LATEXT(1))>>? A\r
+             ;\r
+\r
+      will not cause any error messages or warnings to be issued\r
+      by earlier versions of pccts.  To compare the text of the\r
+      predicates is an incomplete solution.\r
+\r
+      In 1.33MR11 I am introducing the #pred statement in order to\r
+      solve some problems with predicates.  The #pred statement allows\r
+      one to give a symbolic name to a "predicate literal" or a\r
+      "predicate expression" in order to refer to it in other predicate\r
+      expressions or in the rules of the grammar.\r
+\r
+      The predicate literal associated with a predicate symbol is C\r
+      or C++ code which can be used to test the condition.  A\r
+      predicate expression defines a predicate symbol in terms of other\r
+      predicate symbols using "!", "&&", and "||".  A predicate symbol\r
+      can be defined in terms of a predicate literal, a predicate\r
+      expression, or *both*.\r
+\r
+      When a predicate symbol is defined with both a predicate literal\r
+      and a predicate expression, the predicate literal is used to generate\r
+      code, but the predicate expression is used to check for two\r
+      alternatives with identical predicates in both alternatives.\r
+\r
+      Here are some examples of #pred statements:\r
+\r
+        #pred  IsLabel       <<isLabel(LATEXT(1))>>?\r
+        #pred  IsLocalVar    <<isLocalVar(LATEXT(1))>>?\r
+        #pred  IsGlobalVar   <<isGlobalVar(LATEXT(1)>>?\r
+        #pred  IsVar         <<isVar(LATEXT(1))>>?       IsLocalVar || IsGlobalVar\r
+        #pred  IsScoped      <<isScoped(LATEXT(1))>>?    IsLabel || IsLocalVar\r
+\r
+      I hope that the use of EBNF notation to describe the syntax of the\r
+      #pred statement will not cause problems for my readers (joke).\r
+\r
+        predStatement : "#pred"\r
+                            CapitalizedName\r
+                              (\r
+                                  "<<predicate_literal>>?"\r
+                                | "<<predicate_literal>>?"  predOrExpr\r
+                                | predOrExpr\r
+                              )\r
+                      ;\r
+\r
+        predOrExpr    : predAndExpr ( "||" predAndExpr ) * ;\r
+\r
+        predAndExpr   : predPrimary ( "&&" predPrimary ) * ;\r
+\r
+        predPrimary   : CapitalizedName\r
+                      | "!" predPrimary\r
+                      | "(" predOrExpr ")"\r
+                      ;\r
+\r
+      What is the purpose of this nonsense ?\r
+\r
+      To understand how predicate symbols help, you need to realize that\r
+      predicate symbols are used in two different ways with two different\r
+      goals.\r
+\r
+        a. Allow simplification of predicates which have been combined\r
+           during predicate hoisting.\r
+\r
+        b. Allow recognition of identical predicates which can't disambiguate\r
+           alternatives with common lookahead.\r
+\r
+      First we will discuss goal (a).  Consider the following rule:\r
+\r
+            rule0: rule1\r
+                 | ID\r
+                 | ...\r
+                 ;\r
+\r
+            rule1: rule2\r
+                 | rule3\r
+                 ;\r
+\r
+            rule2: <<isX(LATEXT(1))>>? ID ;\r
+            rule3: <<!isX(LATEXT(1)>>? ID ;\r
+\r
+      When the predicates in rule2 and rule3 are combined by hoisting\r
+      to create a prediction expression for rule1 the result is:\r
+\r
+            if ( LA(1)==ID\r
+                && ( isX(LATEXT(1) || !isX(LATEXT(1) ) ) { rule1(); ...\r
+\r
+      This is inefficient, but more importantly, can lead to false\r
+      assumptions that the predicate expression distinguishes the rule1\r
+      alternative with some other alternative with lookahead ID.  In\r
+      MR11 one can write:\r
+\r
+            #pred IsX     <<isX(LATEXT(1))>>?\r
+\r
+            ...\r
+\r
+            rule2: <<IsX>>? ID  ;\r
+            rule3: <<!IsX>>? ID ;\r
+\r
+      During hoisting MR11 recognizes this as a special case and\r
+      eliminates the predicates.  The result is a prediction\r
+      expression like the following:\r
+\r
+            if ( LA(1)==ID ) { rule1(); ...\r
+\r
+      Please note that the following cases which appear to be equivalent\r
+      *cannot* be simplified by MR11 during hoisting because the hoisting\r
+      logic only checks for a "!" in the predicate action, not in the\r
+      predicate expression for a predicate symbol.\r
+\r
+        *Not* equivalent and is not simplified during hoisting:\r
+\r
+            #pred IsX      <<isX(LATEXT(1))>>?\r
+            #pred NotX     <<!isX(LATEXT(1))>>?\r
+            ...\r
+            rule2: <<IsX>>? ID  ;\r
+            rule3: <<NotX>>? ID ;\r
+\r
+        *Not* equivalent and is not simplified during hoisting:\r
+\r
+            #pred IsX      <<isX(LATEXT(1))>>?\r
+            #pred NotX     !IsX\r
+            ...\r
+            rule2: <<IsX>>? ID  ;\r
+            rule3: <<NotX>>? ID ;\r
+\r
+      Now we will discuss goal (b).\r
+\r
+      When antlr discovers that there is a lookahead ambiguity between\r
+      two alternatives it attempts to resolve the ambiguity by searching\r
+      for predicates in both alternatives.  In the past any predicate\r
+      would do, even if the same one appeared in both alternatives:\r
+\r
+            rule: <<p(LATEXT(1))>>? X\r
+                | <<p(LATEXT(1))>>? X\r
+                ;\r
+\r
+      The #pred statement is a start towards solving this problem.\r
+      During ambiguity resolution (*not* predicate hoisting) the\r
+      predicates for the two alternatives are expanded and compared.\r
+      Consider the following example:\r
+\r
+            #pred Upper     <<isUpper(LATEXT(1))>>?\r
+            #pred Lower     <<isLower(LATEXT(1))>>?\r
+            #pred Alpha     <<isAlpha(LATEXT(1))>>?  Upper || Lower\r
+\r
+            rule0: rule1\r
+                 | <<Alpha>>? ID\r
+                 ;\r
+\r
+            rule1:\r
+                 | rule2\r
+                 | rule3\r
+                 ...\r
+                 ;\r
+\r
+            rule2: <<Upper>>? ID;\r
+            rule3: <<Lower>>? ID;\r
+\r
+      The definition of #pred Alpha expresses:\r
+\r
+            a. to test the predicate use the C code "isAlpha(LATEXT(1))"\r
+\r
+            b. to analyze the predicate use the information that\r
+               Alpha is equivalent to the union of Upper and Lower,\r
+\r
+      During ambiguity resolution the definition of Alpha is expanded\r
+      into "Upper || Lower" and compared with the predicate in the other\r
+      alternative, which is also "Upper || Lower".  Because they are\r
+      identical MR11 will report a problem.\r
+\r
+    -------------------------------------------------------------------------\r
+      t10.g, line 5: warning: the predicates used to disambiguate rule rule0\r
+             (file t10.g alt 1 line 5 and alt 2 line 6)\r
+             are identical when compared without context and may have no\r
+             resolving power for some lookahead sequences.\r
+    -------------------------------------------------------------------------\r
+\r
+      If you use the "-info p" option the output file will contain:\r
+\r
+    +----------------------------------------------------------------------+\r
+    |#if 0                                                                 |\r
+    |                                                                      |\r
+    |The following predicates are identical when compared without          |\r
+    |  lookahead context information.  For some ambiguous lookahead        |\r
+    |  sequences they may not have any power to resolve the ambiguity.     |\r
+    |                                                                      |\r
+    |Choice 1: rule0/1  alt 1  line 5  file t10.g                          |\r
+    |                                                                      |\r
+    |  The original predicate for choice 1 with available context          |\r
+    |    information:                                                      |\r
+    |                                                                      |\r
+    |    OR expr                                                           |\r
+    |                                                                      |\r
+    |      pred  <<  Upper>>?                                              |\r
+    |                        depth=k=1  rule rule2  line 14  t10.g         |\r
+    |        set context:                                                  |\r
+    |           ID                                                         |\r
+    |                                                                      |\r
+    |      pred  <<  Lower>>?                                              |\r
+    |                        depth=k=1  rule rule3  line 15  t10.g         |\r
+    |        set context:                                                  |\r
+    |           ID                                                         |\r
+    |                                                                      |\r
+    |  The predicate for choice 1 after expansion (but without context     |\r
+    |    information):                                                     |\r
+    |                                                                      |\r
+    |    OR expr                                                           |\r
+    |                                                                      |\r
+    |      pred  <<  isUpper(LATEXT(1))>>?                                 |\r
+    |                        depth=k=1  rule   line 1  t10.g               |\r
+    |                                                                      |\r
+    |      pred  <<  isLower(LATEXT(1))>>?                                 |\r
+    |                        depth=k=1  rule   line 2  t10.g               |\r
+    |                                                                      |\r
+    |                                                                      |\r
+    |Choice 2: rule0/2  alt 2  line 6  file t10.g                          |\r
+    |                                                                      |\r
+    |  The original predicate for choice 2 with available context          |\r
+    |    information:                                                      |\r
+    |                                                                      |\r
+    |  pred  <<  Alpha>>?                                                  |\r
+    |                    depth=k=1  rule rule0  line 6  t10.g              |\r
+    |    set context:                                                      |\r
+    |       ID                                                             |\r
+    |                                                                      |\r
+    |  The predicate for choice 2 after expansion (but without context     |\r
+    |    information):                                                     |\r
+    |                                                                      |\r
+    |  OR expr                                                             |\r
+    |                                                                      |\r
+    |    pred  <<  isUpper(LATEXT(1))>>?                                   |\r
+    |                      depth=k=1  rule   line 1  t10.g                 |\r
+    |                                                                      |\r
+    |    pred  <<  isLower(LATEXT(1))>>?                                   |\r
+    |                      depth=k=1  rule   line 2  t10.g                 |\r
+    |                                                                      |\r
+    |                                                                      |\r
+    |#endif                                                                |\r
+    +----------------------------------------------------------------------+\r
+\r
+      The comparison of the predicates for the two alternatives takes\r
+      place without context information, which means that in some cases\r
+      the predicates will be considered identical even though they operate\r
+      on disjoint lookahead sets.  Consider:\r
+\r
+            #pred Alpha\r
+\r
+            rule1: <<Alpha>>? ID\r
+                 | <<Alpha>>? Label\r
+                 ;\r
+\r
+      Because the comparison of predicates takes place without context\r
+      these will be considered identical.  The reason for comparing\r
+      without context is that otherwise it would be necessary to re-evaluate\r
+      the entire predicate expression for each possible lookahead sequence.\r
+      This would require more code to be written and more CPU time during\r
+      grammar analysis, and it is not yet clear whether anyone will even make\r
+      use of the new #pred facility.\r
+\r
+      A temporary workaround might be to use different #pred statements\r
+      for predicates you know have different context.  This would avoid\r
+      extraneous warnings.\r
+\r
+      The above example might be termed a "false positive".  Comparison\r
+      without context will also lead to "false negatives".  Consider the\r
+      following example:\r
+\r
+            #pred Alpha\r
+            #pred Beta\r
+\r
+            rule1: <<Alpha>>? A\r
+                 | rule2\r
+                 ;\r
+\r
+            rule2: <<Alpha>>? A\r
+                 | <<Beta>>?  B\r
+                 ;\r
+\r
+      The predicate used for alt 2 of rule1 is (Alpha || Beta).  This\r
+      appears to be different than the predicate Alpha used for alt1.\r
+      However, the context of Beta is B.  Thus when the lookahead is A\r
+      Beta will have no resolving power and Alpha will be used for both\r
+      alternatives.  Using the same predicate for both alternatives isn't\r
+      very helpful, but this will not be detected with 1.33MR11.\r
+\r
+      To properly handle this the predicate expression would have to be\r
+      evaluated for each distinct lookahead context.\r
+\r
+      To determine whether two predicate expressions are identical is\r
+      difficult.  The routine may fail to identify identical predicates.\r
+\r
+      The #pred feature also compares predicates to see if a choice between\r
+      alternatives which is resolved by a predicate which makes the second\r
+      choice unreachable.  Consider the following example:\r
+\r
+            #pred A         <<A(LATEXT(1)>>?\r
+            #pred B         <<B(LATEXT(1)>>?\r
+            #pred A_or_B    A || B\r
+\r
+            r   : s\r
+                | t\r
+                ;\r
+            s   : <<A_or_B>>? ID\r
+                ;\r
+            t   : <<A>>? ID\r
+                ;\r
+\r
+        ----------------------------------------------------------------------------\r
+        t11.g, line 5: warning: the predicate used to disambiguate the\r
+               first choice of  rule r\r
+             (file t11.g alt 1 line 5 and alt 2 line 6)\r
+             appears to "cover" the second predicate when compared without context.\r
+             The second predicate may have no resolving power for some lookahead\r
+               sequences.\r
+        ----------------------------------------------------------------------------\r
+\r
+#132. (Changed in 1.33MR11) Recognition of identical predicates in alts\r
+\r
+      Prior to 1.33MR11, there would be no ambiguity warning when the\r
+      very same predicate was used to disambiguate both alternatives:\r
+\r
+        test: ref B\r
+            | ref C\r
+            ;\r
+\r
+        ref : <<pred(LATEXT(1)>>? A\r
+\r
+      In 1.33MR11 this will cause the warning:\r
+\r
+        warning: the predicates used to disambiguate rule test\r
+            (file v98.g alt 1 line 1 and alt 2 line 2)\r
+             are identical and have no resolving power\r
+\r
+        -----------------  Note  -----------------\r
+\r
+          This is different than the following case\r
+\r
+                test: <<pred(LATEXT(1))>>? A B\r
+                    | <<pred(LATEXT(1)>>?  A C\r
+                    ;\r
+\r
+          In this case there are two distinct predicates\r
+          which have exactly the same text.  In the first\r
+          example there are two references to the same\r
+          predicate.  The problem represented by this\r
+          grammar will be addressed later.\r
+\r
+\r
+#127. (Changed in 1.33MR11)\r
+\r
+                    Count Syntax Errors     Count DLG Errors\r
+                    -------------------     ----------------\r
+\r
+       C++ mode     ANTLRParser::           DLGLexerBase::\r
+                      syntaxErrCount          lexErrCount\r
+       C mode       zzSyntaxErrCount        zzLexErrCount\r
+\r
+       The C mode variables are global and initialized to 0.\r
+       They are *not* reset to 0 automatically when antlr is\r
+       restarted.\r
+\r
+       The C++ mode variables are public.  They are initialized\r
+       to 0 by the constructors.  They are *not* reset to 0 by the\r
+       ANTLRParser::init() method.\r
+\r
+       Suggested by Reinier van den Born (reinier@vnet.ibm.com).\r
+\r
+#126. (Changed in 1.33MR11) Addition of #first <<...>>\r
+\r
+       The #first <<...>> inserts the specified text in the output\r
+       files before any other #include statements required by pccts.\r
+       The only things before the #first text are comments and\r
+       a #define ANTLR_VERSION.\r
+\r
+       Requested by  and Esa Pulkkinen (esap@cs.tut.fi) and Alexin\r
+       Zoltan (alexin@inf.u-szeged.hu).\r
+\r
+#124. A Note on the New "&&" Style Guarded Predicates\r
+\r
+        I've been asked several times, "What is the difference between\r
+        the old "=>" style guard predicates and the new style "&&" guard\r
+        predicates, and how do you choose one over the other" ?\r
+\r
+        The main difference is that the "=>" does not apply the\r
+        predicate if the context guard doesn't match, whereas\r
+        the && form always does.  What is the significance ?\r
+\r
+        If you have a predicate which is not on the "leading edge"\r
+        it is cannot be hoisted.  Suppose you need a predicate that\r
+        looks at LA(2).  You must introduce it manually.  The\r
+        classic example is:\r
+\r
+            castExpr :\r
+                     LP typeName RP\r
+                     | ....\r
+                     ;\r
+\r
+            typeName : <<isTypeName(LATEXT(1))>>?  ID\r
+                     | STRUCT ID\r
+                     ;\r
+\r
+        The problem  is that isTypeName() isn't on the leading edge\r
+        of typeName, so it won't be hoisted into castExpr to help\r
+        make a decision on which production to choose.\r
+\r
+        The *first* attempt to fix it is this:\r
+\r
+            castExpr :\r
+                     <<isTypeName(LATEXT(2))>>?\r
+                                        LP typeName RP\r
+                     | ....\r
+                     ;\r
+\r
+        Unfortunately, this won't work because it ignores\r
+        the problem of STRUCT.  The solution is to apply\r
+        isTypeName() in castExpr if LA(2) is an ID and\r
+        don't apply it when LA(2) is STRUCT:\r
+\r
+            castExpr :\r
+                     (LP ID)? => <<isTypeName(LATEXT(2))>>?\r
+                                        LP typeName RP\r
+                     | ....\r
+                     ;\r
+\r
+        In conclusion, the "=>" style guarded predicate is\r
+        useful when:\r
+\r
+            a. the tokens required for the predicate\r
+               are not on the leading edge\r
+            b. there are alternatives in the expression\r
+               selected by the predicate for which the\r
+               predicate is inappropriate\r
+\r
+        If (b) were false, then one could use a simple\r
+        predicate (assuming "-prc on"):\r
+\r
+            castExpr :\r
+                     <<isTypeName(LATEXT(2))>>?\r
+                                        LP typeName RP\r
+                     | ....\r
+                     ;\r
+\r
+            typeName : <<isTypeName(LATEXT(1))>>?  ID\r
+                     ;\r
+\r
+        So, when do you use the "&&" style guarded predicate ?\r
+\r
+        The new-style "&&" predicate should always be used with\r
+        predicate context.  The context guard is in ADDITION to\r
+        the automatically computed context.  Thus it useful for\r
+        predicates which depend on the token type for reasons\r
+        other than context.\r
+\r
+        The following example is contributed by Reinier van den Born\r
+        (reinier@vnet.ibm.com).\r
+\r
+ +-------------------------------------------------------------------------+\r
+ | This grammar has two ways to call functions:                            |\r
+ |                                                                         |\r
+ |  - a "standard" call syntax with parens and comma separated args        |\r
+ |  - a shell command like syntax (no parens and spacing separated args)   |\r
+ |                                                                         |\r
+ | The former also allows a variable to hold the name of the function,     |\r
+ | the latter can also be used to call external commands.                  |\r
+ |                                                                         |\r
+ | The grammar (simplified) looks like this:                               |\r
+ |                                                                         |\r
+ |   fun_call   :     ID "(" { expr ("," expr)* } ")"                      |\r
+ |                                  /* ID is function name */              |\r
+ |              | "@" ID "(" { expr ("," expr)* } ")"                      |\r
+ |                                  /* ID is var containing fun name */    |\r
+ |              ;                                                          |\r
+ |                                                                         |\r
+ |   command    : ID expr*          /* ID is function name */              |\r
+ |              | path expr*        /* path is external command name */    |\r
+ |              ;                                                          |\r
+ |                                                                         |\r
+ |   path       : ID                /* left out slashes and such */        |\r
+ |              | "@" ID            /* ID is environment var */            |\r
+ |              ;                                                          |\r
+ |                                                                         |\r
+ |   expr       : ....                                                     |\r
+ |              | "(" expr ")";                                            |\r
+ |                                                                         |\r
+ |   call       : fun_call                                                 |\r
+ |              | command                                                  |\r
+ |              ;                                                          |\r
+ |                                                                         |\r
+ | Obviously the call is wildly ambiguous. This is more or less how this   |\r
+ | is to be resolved:                                                      |\r
+ |                                                                         |\r
+ |    A call begins with an ID or an @ followed by an ID.                  |\r
+ |                                                                         |\r
+ |    If it is an ID and if it is an ext. command name  -> command         |\r
+ |                       if followed by a paren         -> fun_call        |\r
+ |                       otherwise                      -> command         |\r
+ |                                                                         |\r
+ |    If it is an @  and if the ID is a var name        -> fun_call        |\r
+ |                       otherwise                      -> command         |\r
+ |                                                                         |\r
+ | One can implement these rules quite neatly using && predicates:         |\r
+ |                                                                         |\r
+ |   call       : ("@" ID)? && <<isVarName(LT(2))>>? fun_call              |\r
+ |              | (ID)?     && <<isExtCmdName>>?     command               |\r
+ |              | (ID "(")?                          fun_call              |\r
+ |              |                                    command               |\r
+ |              ;                                                          |\r
+ |                                                                         |\r
+ | This can be done better, so it is not an ideal example, but it          |\r
+ | conveys the principle.                                                  |\r
+ +-------------------------------------------------------------------------+\r
+\r
+#122. (Changed in 1.33MR11)  Member functions to reset DLG in C++ mode\r
+\r
+         void DLGFileReset(FILE *f) { input = f; found_eof = 0; }\r
+         void DLGStringReset(DLGChar *s) { input = s; p = &input[0]; }\r
+\r
+        Supplied by R.A. Nelson (cowboy@VNET.IBM.COM)\r
+\r
+#119. (Changed in 1.33MR11) Ambiguity aid for grammars\r
+\r
+      The user can ask for additional information on ambiguities reported\r
+      by antlr to stdout.  At the moment, only one ambiguity report can\r
+      be created in an antlr run.\r
+\r
+      This feature is enabled using the "-aa" (Ambiguity Aid)  option.\r
+\r
+      The following options control the reporting of ambiguities:\r
+\r
+          -aa ruleName       Selects reporting by name of rule\r
+          -aa lineNumber     Selects reporting by line number\r
+                               (file name not compared)\r
+\r
+          -aam               Selects "multiple" reporting for a token\r
+                             in the intersection set of the\r
+                             alternatives.\r
+\r
+                             For instance, the token ID may appear dozens\r
+                             of times in various paths as the program\r
+                             explores the rules which are reachable from\r
+                             the point of an ambiguity. With option -aam\r
+                             every possible path the search program\r
+                             encounters is reported.\r
+\r
+                             Without -aam only the first encounter is\r
+                             reported.  This may result in incomplete\r
+                             information, but the information may be\r
+                             sufficient and much shorter.\r
+\r
+          -aad depth         Selects the depth of the search.\r
+                             The default value is 1.\r
+\r
+                             The number of paths to be searched, and the\r
+                             size of the report can grow geometrically\r
+                             with the -ck value if a full search for all\r
+                             contributions to the source of the ambiguity\r
+                             is explored.\r
+\r
+                             The depth represents the number of tokens\r
+                             in the lookahead set which are matched against\r
+                             the set of ambiguous tokens.  A depth of 1\r
+                             means that the search stops when a lookahead\r
+                             sequence of just one token is matched.\r
+\r
+                             A k=1 ck=6 grammar might generate 5,000 items\r
+                             in a report if a full depth 6 search is made\r
+                             with the Ambiguity Aid.  The source of the\r
+                             problem may be in the first token and obscured\r
+                             by the volume of data - I hesitate to call\r
+                             it information.\r
+\r
+                             When the user selects a depth > 1, the search\r
+                             is first performed at depth=1 for both\r
+                             alternatives, then depth=2 for both alternatives,\r
+                             etc.\r
+\r
+      Sample output for rule grammar in antlr.g itself:\r
+\r
+  +---------------------------------------------------------------------+\r
+  | Ambiguity Aid                                                       |\r
+  |                                                                     |\r
+  |   Choice 1: grammar/70                 line 632  file a.g           |\r
+  |   Choice 2: grammar/82                 line 644  file a.g           |\r
+  |                                                                     |\r
+  |   Intersection of lookahead[1] sets:                                |\r
+  |                                                                     |\r
+  |      "\}"             "class"          "#errclass"      "#tokclass" |\r
+  |                                                                     |\r
+  |    Choice:1  Depth:1  Group:1  ("#errclass")                        |\r
+  |  1 in (...)* block                grammar/70       line 632   a.g   |\r
+  |  2 to error                       grammar/73       line 635   a.g   |\r
+  |  3 error                          error/1          line 894   a.g   |\r
+  |  4 #token "#errclass"             error/2          line 895   a.g   |\r
+  |                                                                     |\r
+  |    Choice:1  Depth:1  Group:2  ("#tokclass")                        |\r
+  |  2 to tclass                      grammar/74       line 636   a.g   |\r
+  |  3 tclass                         tclass/1         line 937   a.g   |\r
+  |  4 #token "#tokclass"             tclass/2         line 938   a.g   |\r
+  |                                                                     |\r
+  |    Choice:1  Depth:1  Group:3  ("class")                            |\r
+  |  2 to class_def                   grammar/75       line 637   a.g   |\r
+  |  3 class_def                      class_def/1      line 669   a.g   |\r
+  |  4 #token "class"                 class_def/3      line 671   a.g   |\r
+  |                                                                     |\r
+  |    Choice:1  Depth:1  Group:4  ("\}")                               |\r
+  |  2 #token "\}"                    grammar/76       line 638   a.g   |\r
+  |                                                                     |\r
+  |    Choice:2  Depth:1  Group:5  ("#errclass")                        |\r
+  |  1 in (...)* block                grammar/83       line 645   a.g   |\r
+  |  2 to error                       grammar/93       line 655   a.g   |\r
+  |  3 error                          error/1          line 894   a.g   |\r
+  |  4 #token "#errclass"             error/2          line 895   a.g   |\r
+  |                                                                     |\r
+  |    Choice:2  Depth:1  Group:6  ("#tokclass")                        |\r
+  |  2 to tclass                      grammar/94       line 656   a.g   |\r
+  |  3 tclass                         tclass/1         line 937   a.g   |\r
+  |  4 #token "#tokclass"             tclass/2         line 938   a.g   |\r
+  |                                                                     |\r
+  |    Choice:2  Depth:1  Group:7  ("class")                            |\r
+  |  2 to class_def                   grammar/95       line 657   a.g   |\r
+  |  3 class_def                      class_def/1      line 669   a.g   |\r
+  |  4 #token "class"                 class_def/3      line 671   a.g   |\r
+  |                                                                     |\r
+  |    Choice:2  Depth:1  Group:8  ("\}")                               |\r
+  |  2 #token "\}"                    grammar/96       line 658   a.g   |\r
+  +---------------------------------------------------------------------+\r
+\r
+      For a linear lookahead set ambiguity (where k=1 or for k>1 but\r
+      when all lookahead sets [i] with i<k all have degree one) the\r
+      reports appear in the following order:\r
+\r
+        for (depth=1 ; depth <= "-aad depth" ; depth++) {\r
+          for (alternative=1; alternative <=2 ; alternative++) {\r
+            while (matches-are-found) {\r
+              group++;\r
+              print-report\r
+            };\r
+          };\r
+       };\r
+\r
+      For reporting a k-tuple ambiguity, the reports appear in the\r
+      following order:\r
+\r
+        for (depth=1 ; depth <= "-aad depth" ; depth++) {\r
+          while (matches-are-found) {\r
+            for (alternative=1; alternative <=2 ; alternative++) {\r
+              group++;\r
+              print-report\r
+            };\r
+          };\r
+       };\r
+\r
+      This is because matches are generated in different ways for\r
+      linear lookahead and k-tuples.\r
+\r
+#117. (Changed in 1.33MR10) new EXPERIMENTAL predicate hoisting code\r
+\r
+      The hoisting of predicates into rules to create prediction\r
+      expressions is a problem in antlr.  Consider the following\r
+      example (k=1 with -prc on):\r
+\r
+        start   : (a)* "@" ;\r
+        a       : b | c ;\r
+        b       : <<isUpper(LATEXT(1))>>? A ;\r
+        c       : A ;\r
+\r
+      Prior to 1.33MR10 the code generated for "start" would resemble:\r
+\r
+        while {\r
+            if (LA(1)==A &&\r
+                    (!LA(1)==A || isUpper())) {\r
+              a();\r
+            }\r
+        };\r
+\r
+      This code is wrong because it makes rule "c" unreachable from\r
+      "start".  The essence of the problem is that antlr fails to\r
+      recognize that there can be a valid alternative within "a" even\r
+      when the predicate <<isUpper(LATEXT(1))>>? is false.\r
+\r
+      In 1.33MR10 with -mrhoist the hoisting of the predicate into\r
+      "start" is suppressed because it recognizes that "c" can\r
+      cover all the cases where the predicate is false:\r
+\r
+        while {\r
+            if (LA(1)==A) {\r
+              a();\r
+            }\r
+        };\r
+\r
+      With the antlr "-info p" switch the user will receive information\r
+      about the predicate suppression in the generated file:\r
+\r
+      --------------------------------------------------------------\r
+        #if 0\r
+\r
+        Hoisting of predicate suppressed by alternative without predicate.\r
+        The alt without the predicate includes all cases where\r
+            the predicate is false.\r
+\r
+           WITH predicate: line 7  v1.g\r
+           WITHOUT predicate: line 7  v1.g\r
+\r
+        The context set for the predicate:\r
+\r
+             A\r
+\r
+        The lookahead set for the alt WITHOUT the semantic predicate:\r
+\r
+             A\r
+\r
+        The predicate:\r
+\r
+          pred <<  isUpper(LATEXT(1))>>?\r
+                          depth=k=1  rule b  line 9  v1.g\r
+            set context:\r
+               A\r
+            tree context: null\r
+\r
+        Chain of referenced rules:\r
+\r
+            #0  in rule start (line 5 v1.g) to rule a\r
+            #1  in rule a (line 7 v1.g)\r
+\r
+        #endif\r
+      --------------------------------------------------------------\r
+\r
+      A predicate can be suppressed by a combination of alternatives\r
+      which, taken together, cover a predicate:\r
+\r
+        start   : (a)* "@" ;\r
+\r
+        a       : b | ca | cb | cc ;\r
+\r
+        b       : <<isUpper(LATEXT(1))>>? ( A | B | C ) ;\r
+\r
+        ca      : A ;\r
+        cb      : B ;\r
+        cc      : C ;\r
+\r
+      Consider a more complex example in which "c" covers only part of\r
+      a predicate:\r
+\r
+        start   : (a)* "@" ;\r
+\r
+        a       : b\r
+                | c\r
+                ;\r
+\r
+        b       : <<isUpper(LATEXT(1))>>?\r
+                    ( A\r
+                    | X\r
+                    );\r
+\r
+        c       : A\r
+                ;\r
+\r
+      Prior to 1.33MR10 the code generated for "start" would resemble:\r
+\r
+        while {\r
+            if ( (LA(1)==A || LA(1)==X) &&\r
+                    (! (LA(1)==A || LA(1)==X) || isUpper()) {\r
+              a();\r
+            }\r
+        };\r
+\r
+      With 1.33MR10 and -mrhoist the predicate context is restricted to\r
+      the non-covered lookahead.  The code resembles:\r
+\r
+        while {\r
+            if ( (LA(1)==A || LA(1)==X) &&\r
+                  (! (LA(1)==X) || isUpper()) {\r
+              a();\r
+            }\r
+        };\r
+\r
+      With the antlr "-info p" switch the user will receive information\r
+      about the predicate restriction in the generated file:\r
+\r
+      --------------------------------------------------------------\r
+        #if 0\r
+\r
+        Restricting the context of a predicate because of overlap\r
+          in the lookahead set between the alternative with the\r
+          semantic predicate and one without\r
+        Without this restriction the alternative without the predicate\r
+          could not be reached when input matched the context of the\r
+          predicate and the predicate was false.\r
+\r
+           WITH predicate: line 11  v4.g\r
+           WITHOUT predicate: line 12  v4.g\r
+\r
+        The original context set for the predicate:\r
+\r
+             A                X\r
+\r
+        The lookahead set for the alt WITHOUT the semantic predicate:\r
+\r
+             A\r
+\r
+        The intersection of the two sets\r
+\r
+             A\r
+\r
+        The original predicate:\r
+\r
+          pred <<  isUpper(LATEXT(1))>>?\r
+                          depth=k=1  rule b  line 15  v4.g\r
+            set context:\r
+               A                X\r
+            tree context: null\r
+\r
+        The new (modified) form of the predicate:\r
+\r
+          pred <<  isUpper(LATEXT(1))>>?\r
+                          depth=k=1  rule b  line 15  v4.g\r
+            set context:\r
+               X\r
+            tree context: null\r
+\r
+        #endif\r
+      --------------------------------------------------------------\r
+\r
+      The bad news about -mrhoist:\r
+\r
+        (a) -mrhoist does not analyze predicates with lookahead\r
+            depth > 1.\r
+\r
+        (b) -mrhoist does not look past a guarded predicate to\r
+            find context which might cover other predicates.\r
+\r
+      For these cases you might want to use syntactic predicates.\r
+      When a semantic predicate fails during guess mode the guess\r
+      fails and the next alternative is tried.\r
+\r
+      Limitation (a) is illustrated by the following example:\r
+\r
+        start    : (stmt)* EOF ;\r
+\r
+        stmt     : cast\r
+                 | expr\r
+                 ;\r
+        cast     : <<isTypename(LATEXT(2))>>? LP ID RP ;\r
+\r
+        expr     : LP ID RP ;\r
+\r
+      This is not much different from the first example, except that\r
+      it requires two tokens of lookahead context to determine what\r
+      to do.  This predicate is NOT suppressed because the current version\r
+      is unable to handle predicates with depth > 1.\r
+\r
+      A predicate can be combined with other predicates during hoisting.\r
+      In those cases the depth=1 predicates are still handled.  Thus,\r
+      in the following example the isUpper() predicate will be suppressed\r
+      by line #4 when hoisted from "bizarre" into "start", but will still\r
+      be present in "bizarre" in order to predict "stmt".\r
+\r
+        start    : (bizarre)* EOF ;     // #1\r
+                                        // #2\r
+        bizarre  : stmt                 // #3\r
+                 | A                    // #4\r
+                 ;\r
+\r
+        stmt     : cast\r
+                 | expr\r
+                 ;\r
+\r
+        cast     : <<isTypename(LATEXT(2))>>? LP ID RP ;\r
+\r
+        expr     : LP ID RP ;\r
+                 | <<isUpper(LATEXT(1))>>? A\r
+\r
+      Limitation (b) is illustrated by the following example of a\r
+      context guarded predicate:\r
+\r
+        rule : (A)? <<p>>?          // #1\r
+                     (A             // #2\r
+                     |B             // #3\r
+                     )              // #4\r
+             | <<q>> B              // #5\r
+             ;\r
+\r
+      Recall that this means that when the lookahead is NOT A then\r
+      the predicate "p" is ignored and it attempts to match "A|B".\r
+      Ideally, the "B" at line #3 should suppress predicate "q".\r
+      However, the current version does not attempt to look past\r
+      the guard predicate to find context which might suppress other\r
+      predicates.\r
+\r
+      In some cases -mrhoist will lead to the reporting of ambiguities\r
+      which were not visible before:\r
+\r
+        start   : (a)* "@";\r
+        a       : bc | d;\r
+        bc      : b  | c ;\r
+\r
+        b       : <<isUpper(LATEXT(1))>>? A;\r
+        c       : A ;\r
+\r
+        d       : A ;\r
+\r
+      In this case there is a true ambiguity in "a" between "bc" and "d"\r
+      which can both match "A".  Without -mrhoist the predicate in "b"\r
+      is hoisted into "a" and there is no ambiguity reported.  However,\r
+      with -mrhoist, the predicate in "b" is suppressed by "c" (as it\r
+      should be) making the ambiguity in "a" apparent.\r
+\r
+      The motivations for these changes were hoisting problems reported\r
+      by Reinier van den Born (reinier@vnet.ibm.com) and several others.\r
+\r
+#113. (Changed in 1.33MR10) new context guarded pred: (g)? && <<p>>? expr\r
+\r
+      The existing context guarded predicate:\r
+\r
+            rule : (guard)? => <<p>>? expr\r
+                 | next_alternative\r
+                 ;\r
+\r
+      generates code which resembles:\r
+\r
+            if (lookahead(expr) && (!guard || pred)) {\r
+              expr()\r
+            } else ....\r
+\r
+      This is not suitable for some applications because it allows\r
+      expr() to be invoked when the predicate is false.  This is\r
+      intentional because it is meant to mimic automatically computed\r
+      predicate context.\r
+\r
+      The new context guarded predicate uses the guard information\r
+      differently because it has a different goal.  Consider:\r
+\r
+            rule : (guard)? && <<p>>? expr\r
+                 | next_alternative\r
+                 ;\r
+\r
+      The new style of context guarded predicate is equivalent to:\r
+\r
+            rule : <<guard==true && pred>>? expr\r
+                 | next_alternative\r
+                 ;\r
+\r
+      It generates code which resembles:\r
+\r
+            if (lookahead(expr) && guard && pred) {\r
+                expr();\r
+            } else ...\r
+\r
+      Both forms of guarded predicates severely restrict the form of\r
+      the context guard: it can contain no rule references, no\r
+      (...)*, no (...)+, and no {...}.  It may contain token and\r
+      token class references, and alternation ("|").\r
+\r
+      Addition for 1.33MR11: in the token expression all tokens must\r
+      be at the same height of the token tree:\r
+\r
+            (A ( B | C))? && ...            is ok (all height 2)\r
+            (A ( B |  ))? && ...            is not ok (some 1, some 2)\r
+            (A B C D | E F G H)? && ...     is ok (all height 4)\r
+            (A B C D | E )? && ...          is not ok (some 4, some 1)\r
+\r
+      This restriction is required in order to properly compute the lookahead\r
+      set for expressions like:\r
+\r
+            rule1 : (A B C)? && <<pred>>? rule2 ;\r
+            rule2 : (A|X) (B|Y) (C|Z);\r
+\r
+      This addition was suggested by Rienier van den Born (reinier@vnet.ibm.com)\r
+\r
+#109. (Changed in 1.33MR10) improved trace information\r
+\r
+      The quality of the trace information provided by the "-gd"\r
+      switch has been improved significantly.  Here is an example\r
+      of the output from a test program.  It shows the rule name,\r
+      the first token of lookahead, the call depth, and the guess\r
+      status:\r
+\r
+        exit rule gusxx {"?"} depth 2\r
+        enter rule gusxx {"?"} depth 2\r
+        enter rule gus1 {"o"} depth 3 guessing\r
+        guess done - returning to rule gus1 {"o"} at depth 3\r
+                    (guess mode continues - an enclosing guess is still active)\r
+        guess done - returning to rule gus1 {"Z"} at depth 3\r
+                    (guess mode continues - an enclosing guess is still active)\r
+        exit rule gus1 {"Z"} depth 3 guessing\r
+        guess done - returning to rule gusxx {"o"} at depth 2 (guess mode ends)\r
+        enter rule gus1 {"o"} depth 3\r
+        guess done - returning to rule gus1 {"o"} at depth 3 (guess mode ends)\r
+        guess done - returning to rule gus1 {"Z"} at depth 3 (guess mode ends)\r
+        exit rule gus1 {"Z"} depth 3\r
+        line 1: syntax error at "Z" missing SC\r
+            ...\r
+\r
+      Rule trace reporting is controlled by the value of the integer\r
+      [zz]traceOptionValue:  when it is positive tracing is enabled,\r
+      otherwise it is disabled.  Tracing during guess mode is controlled\r
+      by the value of the integer [zz]traceGuessOptionValue.  When\r
+      it is positive AND [zz]traceOptionValue is positive rule trace\r
+      is reported in guess mode.\r
+\r
+      The values of [zz]traceOptionValue and [zz]traceGuessOptionValue\r
+      can be adjusted by subroutine calls listed below.\r
+\r
+      Depending on the presence or absence of the antlr -gd switch\r
+      the variable [zz]traceOptionValueDefault is set to 0 or 1.  When\r
+      the parser is initialized or [zz]traceReset() is called the\r
+      value of [zz]traceOptionValueDefault is copied to [zz]traceOptionValue.\r
+      The value of [zz]traceGuessOptionValue is always initialzed to 1,\r
+      but, as noted earlier, nothing will be reported unless\r
+      [zz]traceOptionValue is also positive.\r
+\r
+      When the parser state is saved/restored the value of the trace\r
+      variables are also saved/restored.  If a restore causes a change in\r
+      reporting behavior from on to off or vice versa this will be reported.\r
+\r
+      When the -gd option is selected, the macro "#define zzTRACE_RULES"\r
+      is added to appropriate output files.\r
+\r
+        C++ mode\r
+        --------\r
+        int     traceOption(int delta)\r
+        int     traceGuessOption(int delta)\r
+        void    traceReset()\r
+        int     traceOptionValueDefault\r
+\r
+        C mode\r
+        --------\r
+        int     zzTraceOption(int delta)\r
+        int     zzTraceGuessOption(int delta)\r
+        void    zzTraceReset()\r
+        int     zzTraceOptionValueDefault\r
+\r
+      The argument "delta" is added to the traceOptionValue.  To\r
+      turn on trace when inside a particular rule one:\r
+\r
+        rule : <<traceOption(+1);>>\r
+               (\r
+                rest-of-rule\r
+               )\r
+               <<traceOption(-1);>>\r
+       ;  /* fail clause */ <<traceOption(-1);>>\r
+\r
+      One can use the same idea to turn *off* tracing within a\r
+      rule by using a delta of (-1).\r
+\r
+      An improvement in the rule trace was suggested by Sramji\r
+      Ramanathan (ps@kumaran.com).\r
+\r
+#108. A Note on Deallocation of Variables Allocated in Guess Mode\r
+\r
+                            NOTE\r
+        ------------------------------------------------------\r
+        This mechanism only works for heap allocated variables\r
+        ------------------------------------------------------\r
+\r
+      The rewrite of the trace provides the machinery necessary\r
+      to properly free variables or undo actions following a\r
+      failed guess.\r
+\r
+      The macro zzUSER_GUESS_HOOK(guessSeq,zzrv) is expanded\r
+      as part of the zzGUESS macro.  When a guess is opened\r
+      the value of zzrv is 0.  When a longjmp() is executed to\r
+      undo the guess, the value of zzrv will be 1.\r
+\r
+      The macro zzUSER_GUESS_DONE_HOOK(guessSeq) is expanded\r
+      as part of the zzGUESS_DONE macro.  This is executed\r
+      whether the guess succeeds or fails as part of closing\r
+      the guess.\r
+\r
+      The guessSeq is a sequence number which is assigned to each\r
+      guess and is incremented by 1 for each guess which becomes\r
+      active.  It is needed by the user to associate the start of\r
+      a guess with the failure and/or completion (closing) of a\r
+      guess.\r
+\r
+      Guesses are nested.  They must be closed in the reverse\r
+      of the order that they are opened.\r
+\r
+      In order to free memory used by a variable during a guess\r
+      a user must write a routine which can be called to\r
+      register the variable along with the current guess sequence\r
+      number provided by the zzUSER_GUESS_HOOK macro. If the guess\r
+      fails, all variables tagged with the corresponding guess\r
+      sequence number should be released.  This is ugly, but\r
+      it would require a major rewrite of antlr 1.33 to use\r
+      some mechanism other than setjmp()/longjmp().\r
+\r
+      The order of calls for a *successful* guess would be:\r
+\r
+        zzUSER_GUESS_HOOK(guessSeq,0);\r
+        zzUSER_GUESS_DONE_HOOK(guessSeq);\r
+\r
+      The order of calls for a *failed* guess would be:\r
+\r
+        zzUSER_GUESS_HOOK(guessSeq,0);\r
+        zzUSER_GUESS_HOOK(guessSeq,1);\r
+        zzUSER_GUESS_DONE_HOOK(guessSeq);\r
+\r
+      The default definitions of these macros are empty strings.\r
+\r
+      Here is an example in C++ mode.  The zzUSER_GUESS_HOOK and\r
+      zzUSER_GUESS_DONE_HOOK macros and myGuessHook() routine\r
+      can be used without change in both C and C++ versions.\r
+\r
+      ----------------------------------------------------------------------\r
+        <<\r
+\r
+        #include "AToken.h"\r
+\r
+        typedef ANTLRCommonToken ANTLRToken;\r
+\r
+        #include "DLGLexer.h"\r
+\r
+        int main() {\r
+\r
+          {\r
+            DLGFileInput     in(stdin);\r
+            DLGLexer         lexer(&in,2000);\r
+            ANTLRTokenBuffer pipe(&lexer,1);\r
+            ANTLRCommonToken aToken;\r
+            P                parser(&pipe);\r
+\r
+            lexer.setToken(&aToken);\r
+            parser.init();\r
+            parser.start();\r
+          };\r
+\r
+          fclose(stdin);\r
+          fclose(stdout);\r
+          return 0;\r
+        }\r
+\r
+        >>\r
+\r
+        <<\r
+        char *s=NULL;\r
+\r
+        #undef zzUSER_GUESS_HOOK\r
+        #define zzUSER_GUESS_HOOK(guessSeq,zzrv) myGuessHook(guessSeq,zzrv);\r
+        #undef zzUSER_GUESS_DONE_HOOK\r
+        #define zzUSER_GUESS_DONE_HOOK(guessSeq)   myGuessHook(guessSeq,2);\r
+\r
+        void myGuessHook(int guessSeq,int zzrv) {\r
+          if (zzrv == 0) {\r
+            fprintf(stderr,"User hook: starting guess #%d\n",guessSeq);\r
+          } else if (zzrv == 1) {\r
+            free (s);\r
+            s=NULL;\r
+            fprintf(stderr,"User hook: failed guess #%d\n",guessSeq);\r
+          } else if (zzrv == 2) {\r
+            free (s);\r
+            s=NULL;\r
+            fprintf(stderr,"User hook: ending guess #%d\n",guessSeq);\r
+          };\r
+        }\r
+\r
+        >>\r
+\r
+        #token A    "a"\r
+        #token      "[\t \ \n]"     <<skip();>>\r
+\r
+        class P {\r
+\r
+        start : (top)+\r
+              ;\r
+\r
+        top   : (which) ?   <<fprintf(stderr,"%s is a which\n",s); free(s); s=NULL; >>\r
+              | other       <<fprintf(stderr,"%s is an other\n",s); free(s); s=NULL; >>\r
+              ; <<if (s != NULL) free(s); s=NULL; >>\r
+\r
+        which : which2\r
+              ;\r
+\r
+        which2 : which3\r
+              ;\r
+        which3\r
+              : (label)?         <<fprintf(stderr,"%s is a label\n",s);>>\r
+              | (global)?        <<fprintf(stderr,"%s is a global\n",s);>>\r
+              | (exclamation)?   <<fprintf(stderr,"%s is an exclamation\n",s);>>\r
+              ;\r
+\r
+        label :       <<s=strdup(LT(1)->getText());>> A ":" ;\r
+\r
+        global :      <<s=strdup(LT(1)->getText());>> A "::" ;\r
+\r
+        exclamation : <<s=strdup(LT(1)->getText());>> A "!" ;\r
+\r
+        other :       <<s=strdup(LT(1)->getText());>> "other" ;\r
+\r
+        }\r
+      ----------------------------------------------------------------------\r
+\r
+      This is a silly example, but illustrates the idea.  For the input\r
+      "a ::" with tracing enabled the output begins:\r
+\r
+      ----------------------------------------------------------------------\r
+        enter rule "start" depth 1\r
+        enter rule "top" depth 2\r
+        User hook: starting guess #1\r
+        enter rule "which" depth 3 guessing\r
+        enter rule "which2" depth 4 guessing\r
+        enter rule "which3" depth 5 guessing\r
+        User hook: starting guess #2\r
+        enter rule "label" depth 6 guessing\r
+        guess failed\r
+        User hook: failed guess #2\r
+        guess done - returning to rule "which3" at depth 5 (guess mode continues\r
+                                                 - an enclosing guess is still active)\r
+        User hook: ending guess #2\r
+        User hook: starting guess #3\r
+        enter rule "global" depth 6 guessing\r
+        exit rule "global" depth 6 guessing\r
+        guess done - returning to rule "which3" at depth 5 (guess mode continues\r
+                                                 - an enclosing guess is still active)\r
+        User hook: ending guess #3\r
+        enter rule "global" depth 6 guessing\r
+        exit rule "global" depth 6 guessing\r
+        exit rule "which3" depth 5 guessing\r
+        exit rule "which2" depth 4 guessing\r
+        exit rule "which" depth 3 guessing\r
+        guess done - returning to rule "top" at depth 2 (guess mode ends)\r
+        User hook: ending guess #1\r
+        enter rule "which" depth 3\r
+        .....\r
+      ----------------------------------------------------------------------\r
+\r
+      Remember:\r
+\r
+        (a) Only init-actions are executed during guess mode.\r
+        (b) A rule can be invoked multiple times during guess mode.\r
+        (c) If the guess succeeds the rule will be called once more\r
+              without guess mode so that normal actions will be executed.\r
+            This means that the init-action might need to distinguish\r
+              between guess mode and non-guess mode using the variable\r
+              [zz]guessing.\r
+\r
+#101. (Changed in 1.33MR10) antlr -info command line switch\r
+\r
+        -info\r
+\r
+            p   - extra predicate information in generated file\r
+\r
+            t   - information about tnode use:\r
+                    at the end of each rule in generated file\r
+                    summary on stderr at end of program\r
+\r
+            m   - monitor progress\r
+                    prints name of each rule as it is started\r
+                    flushes output at start of each rule\r
+\r
+            f   - first/follow set information to stdout\r
+\r
+            0   - no operation (added in 1.33MR11)\r
+\r
+      The options may be combined and may appear in any order.\r
+      For example:\r
+\r
+        antlr -info ptm -CC -gt -mrhoist on mygrammar.g\r
+\r
+#100a. (Changed in 1.33MR10) Predicate tree simplification\r
+\r
+      When the same predicates can be referenced in more than one\r
+      alternative of a block large predicate trees can be formed.\r
+\r
+      The difference that these optimizations make is so dramatic\r
+      that I have decided to use it even when -mrhoist is not selected.\r
+\r
+      Consider the following grammar:\r
+\r
+        start : ( all )* ;\r
+\r
+        all   : a\r
+              | d\r
+              | e\r
+              | f\r
+              ;\r
+\r
+        a     : c A B\r
+              | c A C\r
+              ;\r
+\r
+        c     : <<AAA(LATEXT(2))>>?\r
+              ;\r
+\r
+        d     : <<BBB(LATEXT(2))>>? B C\r
+              ;\r
+\r
+        e     : <<CCC(LATEXT(2))>>? B C\r
+              ;\r
+\r
+        f     : e X Y\r
+              ;\r
+\r
+      In rule "a" there is a reference to rule "c" in both alternatives.\r
+      The length of the predicate AAA is k=2 and it can be followed in\r
+      alternative 1 only by (A B) while in alternative 2 it can be\r
+      followed only by (A C).  Thus they do not have identical context.\r
+\r
+      In rule "all" the alternatives which refer to rules "e" and "f" allow\r
+      elimination of the duplicate reference to predicate CCC.\r
+\r
+      The table below summarized the kind of simplification performed by\r
+      1.33MR10.  In the table, X and Y stand for single predicates\r
+      (not trees).\r
+\r
+        (OR X (OR Y (OR Z)))  => (OR X Y Z)\r
+        (AND X (AND Y (AND Z)))  => (AND X Y Z)\r
+\r
+        (OR X  (... (OR  X Y) ... ))     => (OR X (... Y ... ))\r
+        (AND X (... (AND X Y) ... ))     => (AND X (... Y ... ))\r
+        (OR X  (... (AND X Y) ... ))     => (OR X (...  ... ))\r
+        (AND X (... (OR  X Y) ... ))     => (AND X (...  ... ))\r
+\r
+        (AND X)               => X\r
+        (OR X)                => X\r
+\r
+      In a test with a complex grammar for a real application, a predicate\r
+      tree with six OR nodes and 12 leaves was reduced to "(OR X Y Z)".\r
+\r
+      In 1.33MR10 there is a greater effort to release memory used\r
+      by predicates once they are no longer in use.\r
+\r
+#100b. (Changed in 1.33MR10) Suppression of extra predicate tests\r
+\r
+      The following optimizations require that -mrhoist be selected.\r
+\r
+      It is relatively easy to optimize the code generated for predicate\r
+      gates when they are of the form:\r
+\r
+            (AND X Y Z ...)\r
+        or  (OR  X Y Z ...)\r
+\r
+      where X, Y, Z, and "..." represent individual predicates (leaves) not\r
+      predicate trees.\r
+\r
+      If the predicate is an AND the contexts of the X, Y, Z, etc. are\r
+      ANDed together to create a single Tree context for the group and\r
+      context tests for the individual predicates are suppressed:\r
+\r
+            --------------------------------------------------\r
+            Note: This was incorrect.  The contexts should be\r
+            ORed together.  This has been fixed.  A more \r
+            complete description is available in item #152.\r
+            ---------------------------------------------------\r
+\r
+      Optimization 1:  (AND X Y Z ...)\r
+\r
+        Suppose the context for Xtest is LA(1)==LP and the context for\r
+        Ytest is LA(1)==LP && LA(2)==ID.\r
+\r
+            Without the optimization the code would resemble:\r
+\r
+                if (lookaheadContext &&\r
+                    !(LA(1)==LP && LA(1)==LP && LA(2)==ID) ||\r
+                        ( (! LA(1)==LP || Xtest) &&\r
+                          (! (LA(1)==LP || LA(2)==ID) || Xtest)\r
+                        )) {...\r
+\r
+            With the -mrhoist optimization the code would resemble:\r
+\r
+                if (lookaheadContext &&\r
+                    ! (LA(1)==LP && LA(2)==ID) || (Xtest && Ytest) {...\r
+\r
+      Optimization 2: (OR X Y Z ...) with identical contexts\r
+\r
+        Suppose the context for Xtest is LA(1)==ID and for Ytest\r
+        the context is also LA(1)==ID.\r
+\r
+            Without the optimization the code would resemble:\r
+\r
+                if (lookaheadContext &&\r
+                    ! (LA(1)==ID || LA(1)==ID) ||\r
+                        (LA(1)==ID && Xtest) ||\r
+                        (LA(1)==ID && Ytest) {...\r
+\r
+            With the -mrhoist optimization the code would resemble:\r
+\r
+                if (lookaheadContext &&\r
+                    (! LA(1)==ID) || (Xtest || Ytest) {...\r
+\r
+      Optimization 3: (OR X Y Z ...) with distinct contexts\r
+\r
+        Suppose the context for Xtest is LA(1)==ID and for Ytest\r
+        the context is LA(1)==LP.\r
+\r
+            Without the optimization the code would resemble:\r
+\r
+                if (lookaheadContext &&\r
+                    ! (LA(1)==ID || LA(1)==LP) ||\r
+                        (LA(1)==ID && Xtest) ||\r
+                        (LA(1)==LP && Ytest) {...\r
+\r
+            With the -mrhoist optimization the code would resemble:\r
+\r
+                if (lookaheadContext &&\r
+                        (zzpf=0,\r
+                            (LA(1)==ID && (zzpf=1) && Xtest) ||\r
+                            (LA(1)==LP && (zzpf=1) && Ytest) ||\r
+                            !zzpf) {\r
+\r
+            These may appear to be of similar complexity at first,\r
+            but the non-optimized version contains two tests of each\r
+            context while the optimized version contains only one\r
+            such test, as well as eliminating some of the inverted\r
+            logic (" !(...) || ").\r
+\r
+      Optimization 4: Computation of predicate gate trees\r
+\r
+        When generating code for the gates of predicate expressions\r
+        antlr 1.33 vanilla uses a recursive procedure to generate\r
+        "&&" and "||" expressions for testing the lookahead. As each\r
+        layer of the predicate tree is exposed a new set of "&&" and\r
+        "||" expressions on the lookahead are generated.  In many\r
+        cases the lookahead being tested has already been tested.\r
+\r
+        With -mrhoist a lookahead tree is computed for the entire\r
+        lookahead expression.  This means that predicates with identical\r
+        context or context which is a subset of another predicate's\r
+        context disappear.\r
+\r
+        This is especially important for predicates formed by rules\r
+        like the following:\r
+\r
+            uppperCaseVowel : <<isUpperCase(LATEXT(1))>>?  vowel;\r
+            vowel:          : <<isVowel(LATEXT(1))>>? LETTERS;\r
+\r
+        These predicates are combined using AND since both must be\r
+        satisfied for rule upperCaseVowel.  They have identical\r
+        context which makes this optimization very effective.\r
+\r
+      The affect of Items #100a and #100b together can be dramatic.  In\r
+      a very large (but real world) grammar one particular predicate\r
+      expression was reduced from an (unreadable) 50 predicate leaves,\r
+      195 LA(1) terms, and 5500 characters to an (easily comprehensible)\r
+      3 predicate leaves (all different) and a *single* LA(1) term.\r
+\r
+#98.  (Changed in 1.33MR10) Option "-info p"\r
+\r
+      When the user selects option "-info p" the program will generate\r
+      detailed information about predicates.  If the user selects\r
+      "-mrhoist on" additional detail will be provided explaining\r
+      the promotion and suppression of predicates.  The output is part\r
+      of the generated file and sandwiched between #if 0/#endif statements.\r
+\r
+      Consider the following k=1 grammar:\r
+\r
+        start : ( all ) * ;\r
+\r
+        all   : ( a\r
+                | b\r
+                )\r
+                ;\r
+\r
+        a     : c B\r
+              ;\r
+\r
+        c     : <<LATEXT(1)>>?\r
+              | B\r
+              ;\r
+\r
+        b     : <<LATEXT(1)>>? X\r
+              ;\r
+\r
+      Below is an excerpt of the output for rule "start" for the three\r
+      predicate options (off, on, and maintenance release style hoisting).\r
+\r
+      For those who do not wish to use the "-mrhoist on" option for code\r
+      generation the option can be used in a "diagnostic" mode to provide\r
+      valuable information:\r
+\r
+            a. where one should insert null actions to inhibit hoisting\r
+            b. a chain of rule references which shows where predicates are\r
+               being hoisted\r
+\r
+      ======================================================================\r
+      Example of "-info p" with "-mrhoist on"\r
+      ======================================================================\r
+        #if 0\r
+\r
+        Hoisting of predicate suppressed by alternative without predicate.\r
+        The alt without the predicate includes all cases where the\r
+           predicate is false.\r
+\r
+           WITH predicate: line 11  v36.g\r
+           WITHOUT predicate: line 12  v36.g\r
+\r
+        The context set for the predicate:\r
+\r
+             B\r
+\r
+        The lookahead set for alt WITHOUT the semantic predicate:\r
+\r
+             B\r
+\r
+        The predicate:\r
+\r
+          pred <<  LATEXT(1)>>?  depth=k=1  rule c  line 11  v36.g\r
+\r
+            set context:\r
+               B\r
+            tree context: null\r
+\r
+        Chain of referenced rules:\r
+\r
+            #0  in rule start (line 1 v36.g) to rule all\r
+            #1  in rule all (line 3 v36.g) to rule a\r
+            #2  in rule a (line 8 v36.g) to rule c\r
+            #3  in rule c (line 11 v36.g)\r
+\r
+        #endif\r
+        &&\r
+        #if 0\r
+\r
+        pred <<  LATEXT(1)>>?  depth=k=1  rule b  line 15  v36.g\r
+\r
+          set context:\r
+             X\r
+          tree context: null\r
+\r
+        #endif\r
+      ======================================================================\r
+      Example of "-info p"  with the default -prc setting ( "-prc off")\r
+      ======================================================================\r
+        #if 0\r
+\r
+        OR\r
+          pred <<  LATEXT(1)>>?  depth=k=1  rule c  line 11  v36.g\r
+\r
+            set context:\r
+              nil\r
+            tree context: null\r
+\r
+          pred <<  LATEXT(1)>>?  depth=k=1  rule b  line 15  v36.g\r
+\r
+            set context:\r
+              nil\r
+            tree context: null\r
+\r
+        #endif\r
+      ======================================================================\r
+      Example of "-info p" with "-prc on" and "-mrhoist off"\r
+      ======================================================================\r
+        #if 0\r
+\r
+        OR\r
+          pred <<  LATEXT(1)>>?  depth=k=1  rule c  line 11  v36.g\r
+\r
+            set context:\r
+               B\r
+            tree context: null\r
+\r
+          pred <<  LATEXT(1)>>?  depth=k=1  rule b  line 15  v36.g\r
+\r
+            set context:\r
+               X\r
+            tree context: null\r
+\r
+        #endif\r
+      ======================================================================\r
+\r
+#60.  (Changed in 1.33MR7) Major changes to exception handling\r
+\r
+        There were significant problems in the handling of exceptions\r
+        in 1.33 vanilla.  The general problem is that it can only\r
+        process one level of exception handler.  For example, a named\r
+        exception handler, an exception handler for an alternative, or\r
+        an exception for a subrule  always went to the rule's exception\r
+        handler if there was no "catch" which matched the exception.\r
+\r
+        In 1.33MR7 the exception handlers properly "nest".  If an\r
+        exception handler does not have a matching "catch" then the\r
+        nextmost outer exception handler is checked for an appropriate\r
+        "catch" clause, and so on until an exception handler with an\r
+        appropriate "catch" is found.\r
+\r
+        There are still undesirable features in the way exception\r
+        handlers are implemented, but I do not have time to fix them\r
+        at the moment:\r
+\r
+            The exception handlers for alternatives are outside the\r
+            block containing the alternative.  This makes it impossible\r
+            to access variables declared in a block or to resume the\r
+            parse by "falling through".  The parse can still be easily\r
+            resumed in other ways, but not in the most natural fashion.\r
+\r
+            This results in an inconsistentcy between named exception\r
+            handlers and exception handlers for alternatives.  When\r
+            an exception handler for an alternative "falls through"\r
+            it goes to the nextmost outer handler - not the "normal\r
+            action".\r
+\r
+        A major difference between 1.33MR7 and 1.33 vanilla is\r
+        the default action after an exception is caught:\r
+\r
+            1.33 Vanilla\r
+            ------------\r
+            In 1.33 vanilla the signal value is set to zero ("NoSignal")\r
+            and the code drops through to the code following the exception.\r
+            For named exception handlers this is the "normal action".\r
+            For alternative exception handlers this is the rule's handler.\r
+\r
+            1.33MR7\r
+            -------\r
+            In 1.33MR7 the signal value is NOT automatically set to zero.\r
+\r
+            There are two cases:\r
+\r
+                For named exception handlers: if the signal value has been\r
+                set to zero the code drops through to the "normal action".\r
+\r
+                For all other cases the code branches to the nextmost outer\r
+                exception handler until it reaches the handler for the rule.\r
+\r
+        The following macros have been defined for convenience:\r
+\r
+            C/C++ Mode Name\r
+            --------------------\r
+            (zz)suppressSignal\r
+                  set signal & return signal arg to 0 ("NoSignal")\r
+            (zz)setSignal(intValue)\r
+                  set signal & return signal arg to some value\r
+            (zz)exportSignal\r
+                  copy the signal value to the return signal arg\r
+\r
+        I'm not sure why PCCTS make a distinction between the local\r
+        signal value and the return signal argument, but I'm loathe\r
+        to change the code. The burden of copying the local signal\r
+        value to the return signal argument can be given to the\r
+        default signal handler, I suppose.\r
+\r
+#53.  (Explanation for 1.33MR6) What happens after an exception is caught ?\r
+\r
+        The Book is silent about what happens after an exception\r
+        is caught.\r
+\r
+        The following code fragment prints "Error Action" followed\r
+        by "Normal Action".\r
+\r
+        test : Word ex:Number <<printf("Normal Action\n");>>\r
+                exception[ex]\r
+                   catch NoViableAlt:\r
+                        <<printf("Error Action\n");>>\r
+        ;\r
+\r
+        The reason for "Normal Action" is that the normal flow of the\r
+        program after a user-written exception handler is to "drop through".\r
+        In the case of an exception handler for a rule this results in\r
+        the exection of a "return" statement.  In the case of an\r
+        exception handler attached to an alternative, rule, or token\r
+        this is the code that would have executed had there been no\r
+        exception.\r
+\r
+        The user can achieve the desired result by using a "return"\r
+        statement.\r
+\r
+        test : Word ex:Number <<printf("Normal Action\n");>>\r
+                exception[ex]\r
+                   catch NoViableAlt:\r
+                        <<printf("Error Action\n"); return;>>\r
+        ;\r
+\r
+        The most powerful mechanism for recovery from parse errors\r
+        in pccts is syntactic predicates because they provide\r
+        backtracking.  Exceptions allow "return", "break",\r
+        "consumeUntil(...)", "goto _handler", "goto _fail", and\r
+        changing the _signal value.\r
+\r
+#41.  (Added in 1.33MR6) antlr -stdout\r
+\r
+        Using "antlr -stdout ..." forces the text that would\r
+        normally go to the grammar.c or grammar.cpp file to\r
+        stdout.\r
+\r
+#40.  (Added in 1.33MR6) antlr -tab to change tab stops\r
+\r
+        Using "antlr -tab number ..." changes the tab stops\r
+        for the grammar.c or grammar.cpp file.  The number\r
+        must be between 0 and 8.  Using 0 gives tab characters,\r
+        values between 1 and 8 give the appropriate number of\r
+        space characters.\r
+\r
+#34.  (Added to 1.33MR1) Add public DLGLexerBase::set_line(int newValue)\r
+\r
+        Previously there was no public function for changing the line\r
+        number maintained by the lexer.\r
+\r
+#28.   (Added to 1.33MR1) More control over DLG header\r
+\r
+        Version 1.33MR1 adds the following directives to PCCTS\r
+        for C++ mode:\r
+\r
+          #lexprefix  <<source code>>\r
+\r
+                Adds source code to the DLGLexer.h file\r
+                after the #include "DLexerBase.h" but\r
+                before the start of the class definition.\r
+\r
+          #lexmember  <<source code>>\r
+\r
+                Adds source code to the DLGLexer.h file\r
+                as part of the DLGLexer class body.  It\r
+                appears immediately after the start of\r
+                the class and a "public: statement.\r
+\r
diff --git a/Tools/CodeTools/Source/Pccts/KNOWN_PROBLEMS.txt b/Tools/CodeTools/Source/Pccts/KNOWN_PROBLEMS.txt
new file mode 100644 (file)
index 0000000..5a9b22e
--- /dev/null
@@ -0,0 +1,241 @@
+\r
+    =======================================================\r
+    Known Problems In PCCTS - Last revised 14 November 1998\r
+    =======================================================\r
+\r
+#17. The dlg fix for handling characters up to 255 is incorrect.\r
+\r
+    See item #207.\r
+\r
+    Reported by Frank Hartmann.\r
+        \r
+#16. A note about "&&" predicates (Mike Dimmick)\r
+\r
+    Mike Dimmick has pointed out a potential pitfall in the use of the\r
+    "&&" style predicate.  Consider:\r
+    \r
+         r0: (g)? => <<P>>?  r1\r
+             | ...\r
+             ;\r
+         r1: A | B;\r
+         \r
+    If the context guard g is not a subset of the lookahead context for r1\r
+    (in other words g is neither A nor B) then the code may execute r1 \r
+    even when the lookahead context is not satisfied.  This is an error\r
+    by the person coding the grammer, and the error should be reported to\r
+    the user, but it isn't. expect.  Some examples I've run seem to\r
+    indicate that such an error actually results in the rule becoming\r
+    unreachable.\r
+    \r
+    When g is properly coded the code is correct, the problem is when g\r
+    is not properly coded.\r
+    \r
+    A second problem reported by Mike Dimmick is that the test for a\r
+    failed validation predicate is equivalent to a test on the predicate\r
+    along.  In other words, if the "&&" has not been hoisted then it may\r
+    falsely report a validation error.\r
+\r
+#15. (Changed in MR23) Warning for LT(i), LATEXT(i) in token match actions\r
+\r
+    An bug (or at least an oddity) is that a reference to LT(1), LA(1),\r
+    or LATEXT(1) in an action which immediately follows a token match\r
+    in a rule refers to the token matched, not the token which is in\r
+    the lookahead buffer.  Consider:\13\r
+\r
+        r : abc <<action alpha>> D <<action beta>> E;\r
+\r
+    In this case LT(1) in action alpha will refer to the next token in\r
+    the lookahead buffer ("D"), but LT(1) in action beta will refer to\r
+    the token matched by D - the preceding token.\r
+\r
+    A warning has been added which warns users about this when an action\r
+    following a token match contains a reference to LT(1), LA(1), or LATEXT(1).\r
+\r
+    This behavior should be changed, but it appears in too many programs\r
+    now.  Another problem, perhaps more significant, is that the obvious\r
+    fix (moving the consume() call to before the action) could change the \r
+    order in which input is requested and output appears in existing programs.\r
+\r
+    This problem was reported, along with a fix by Benjamin Mandel\r
+    (beny@sd.co.il).  However, I felt that changing the behavior was too\r
+    dangerous for existing code.\r
+\r
+#14. Parsing bug in dlg\r
+\r
+    THM: I have been unable to reproduce this problem.\r
+\r
+    Reported by Rick Howard Mijenix Corporation (rickh@mijenix.com).\r
+\r
+    The regular expression parser (in rexpr.c) fails while\r
+    trying to parse the following regular expression:\r
+\r
+            {[a-zA-Z]:}(\\\\[a-zA-Z0-9]*)+\r
+\r
+    See my comment in the following excerpt from rexpr.c:\r
+\r
+    /*\r
+     * <regExpr>        ::= <andExpr> ( '|' {<andExpr>} )*\r
+     *\r
+     * Return -1 if syntax error\r
+     * Return  0 if none found\r
+     * Return  1 if a regExrp was found\r
+     */\r
+       static\r
+       regExpr(g)\r
+       GraphPtr g;\r
+       {\r
+           Graph g1, g2;\r
+       \r
+           if ( andExpr(&g1) == -1 )\r
+           {\r
+               return -1;\r
+           }\r
+       \r
+           while ( token == '|' )\r
+           {\r
+               int a;\r
+               next();\r
+               a = andExpr(&g2);\r
+               if ( a == -1 ) return -1;   /* syntax error below */\r
+               else if ( !a ) return 1;    /* empty alternative */\r
+               g1 = BuildNFA_AorB(g1, g2);\r
+           }\r
+       \r
+           if ( token!='\0' ) return -1;\r
+       *****\r
+       ***** It appears to fail here becuause token is 125 - the closing '}'\r
+       ***** If I change it to:\r
+       *****    if ( token!='\0' && token!='}' && token!= ')' ) return -1;\r
+       *****\r
+       ***** It succeeds, but I'm not sure this is the corrrect approach.\r
+       *****\r
+           *g = g1;\r
+           return 1;\r
+       }\r
+\r
+#13. dlg reports an invalid range for: [\0x00-\0xff]\r
+\r
+    Diagnosed by Piotr Eljasiak (eljasiak@no-spam.zt.gdansk.tpsa.pl):\r
+\r
+    Fixed in MR16.\r
+\r
+#12. Strings containing comment actions\r
+\r
+     Sequences that looked like C style comments appearing in string\r
+     literals are improperly parsed by antlr/dlg.\r
+\r
+        << fprintf(out," /* obsolete */ ");\r
+\r
+     For this case use:\r
+\r
+        << fprintf(out," \/\* obsolete \*\/ ");\r
+\r
+     Reported by K.J. Cummings (cummings@peritus.com).\r
+\r
+#11. User hook for deallocation of variables on guess fail\r
+\r
+     The mechanism outlined in Item #108 works only for\r
+     heap allocated variables.\r
+\r
+#10. Label re-initialization in ( X {y:Y} )*\r
+\r
+     If a label assignment is optional and appears in a\r
+     (...)* or (...)+ block it will not be reset to NULL\r
+     when it is skipped by a subsequent iteration.\r
+\r
+     Consider the example:\r
+\r
+            ( X { y:Y })* Z\r
+\r
+     with input:\r
+\r
+            X Y X Z\r
+\r
+     The first time through the block Y will be matched and\r
+     y will be set to point to the token.  On the second\r
+     iteration of the (...)* block there is no match for Y.\r
+     But y will not be reset to NULL, as the user might\r
+     expect, it will contain a reference to the Y that was\r
+     matched in the first iteration.\r
+\r
+     The work-around is to manually reset y:\r
+\r
+            ( X << y = NULL; >> { y:Y } )* Z\r
+\r
+        or\r
+\r
+            ( X ( y:Y | << y = NULL; >> /* epsilon */ ) )* Z\r
+\r
+     Reported by Jeff Vincent (JVincent@novell.com).\r
+\r
+#9. PCCTAST.h PCCTSAST::setType() is a noop\r
+\r
+#8. #tokdefs with ~Token and .\r
+\r
+    THM: I have been unable to reproduce this problem.\r
+\r
+    When antlr uses #tokdefs to define tokens the fields of\r
+    #errclass and #tokclass do not get properly defined.\r
+    When it subsequently attempts to take the complement of\r
+    the set of tokens (using ~Token or .) it can refer to\r
+    tokens which don't have names, generating a fatal error.\r
+\r
+#7. DLG crashes on some invalid inputs\r
+\r
+    THM:  In MR20 have fixed the most common cases.\r
+\r
+    The following token defintion will cause DLG to crash.\r
+\r
+        #token "()"\r
+\r
+    Reported by  Mengue Olivier (dolmen@bigfoot.com).\r
+\r
+#6. On MS systems \n\r is treated as two new lines\r
+\r
+    Fixed.\r
+\r
+#5. Token expressions in #tokclass\r
+\r
+    #errclass does not support TOK1..TOK2 or ~TOK syntax.\r
+    #tokclass does not support ~TOKEN syntax\r
+\r
+    A workaround for #errclass TOK1..TOK2 is to use a\r
+    #tokclass.\r
+\r
+    Reported by Dave Watola (dwatola@amtsun.jpl.nasa.gov)\r
+\r
+#4. A #tokdef must appear "early" in the grammar file.\r
+\r
+    The "early" section of the grammar file is the only\r
+    place where the following directives may appear:\r
+\r
+        #header\r
+        #first\r
+        #tokdefs\r
+        #parser\r
+\r
+    Any other kind of statement signifiies the end of the\r
+    "early" section.\r
+\r
+#3. Use of PURIFY macro for C++ mode\r
+\r
+    Item #93 of the CHANGES_FROM_1.33 describes the use of\r
+    the PURIFY macro to zero arguments to be passed by\r
+    upward inheritance.\r
+\r
+        #define PURIFY(r, s) memset((char *) &(r), '\0', (s));\r
+\r
+    This may not be the right thing to do for C++ objects that\r
+    have constructors.  Reported by Bonny Rais (bonny@werple.net.au).\r
+\r
+    For those cases one should #define PURIFY to be an empty macro\r
+    in the #header or #first actions.\r
+\r
+#2. Fixed in 1.33MR10 - See CHANGES_FROM_1.33 Item #80.\r
+\r
+#1. The quality of support for systems with 8.3 file names leaves\r
+    much to be desired.  Since the kit is distributed using the\r
+    long file names and the make file uses long file names it requires\r
+    some effort to generate.  This will probably not be changed due\r
+    to the large number of systems already written using the long\r
+    file names.\r
diff --git a/Tools/CodeTools/Source/Pccts/MPW_Read_Me b/Tools/CodeTools/Source/Pccts/MPW_Read_Me
new file mode 100644 (file)
index 0000000..70a9d1b
--- /dev/null
@@ -0,0 +1,21 @@
+\r
+1. You can control the creator type of generated files by changing a value of\r
+   #if control statement.\r
+\r
+\r
+   pccts:h:pcctscfg.h\r
+\r
+   line 225-231\r
+\r
+       #if 0\r
+       #define MAC_FILE_CREATOR 'MPS '   /* MPW Text files */\r
+       #endif\r
+       #if 0\r
+       #define MAC_FILE_CREATOR 'KAHL'   /* THINK C/Symantec C++ Text files */\r
+       #endif\r
+       #if 0\r
+       #define MAC_FILE_CREATOR 'CWIE'   /* Metrowerks C/C++ Text files */\r
+       #endif\r
+\r
+2.  If you want to build 68K version. You must convert all source files to Macintosh\r
+    format before compile.\r
diff --git a/Tools/CodeTools/Source/Pccts/NOTES.bcc b/Tools/CodeTools/Source/Pccts/NOTES.bcc
new file mode 100644 (file)
index 0000000..1ac05b1
--- /dev/null
@@ -0,0 +1,184 @@
+March 95\r
+Version 1.32 of pccts\r
\r
+At the moment this file is available via anonymous FTP at\r
\r
+        Node: marvin.ecn.purdue.edu\r
+        File: pub/pccts/1.32/NOTES.BCC\r
\r
+Mail corrections or additions to David Seidel <71333.1575@compuserve.com>\r
+===============================================================================\r
+Notes on Building PCCTS 1.32 with Borland C++\r
\r
+David Seidel, Innovative Data Concepts Incorporated\r
+CompuServe: 71333,1575\r
+Internet:   71333.1575@compuserve.com\r
+            dseidel@delphi.com\r
\r
+I have gotten ANTLR and DLG to succesfully build with BCC 4.0, but have found\r
+from experience that ANTLR, in particular, is likely to run out of memory\r
+with grammars over a certain size, or with larger values for the -k and -ck\r
+options.  Now that BCC 4.02 and the new Borland Power Pack for DOS is now\r
+available, I feel that there is no excuse not to build these tools as\r
+32-bit executables, as they ought to be.\r
\r
+For people without the Power Pack, the makefiles below should be fairly easily\r
+modified to build 16-bit real-mode executables, but I don't really recommend\r
+it.  As an alternative, you might consider the highly regarded DJGPP compiler\r
+(a DOS port of the Gnu GCC compiler, with a DOS extender included).  Hopefully\r
+some other PCCTS who has DJGPP can provode whatever advice is necessary.  The\r
+Watcom compiler is also an excellent possibility (albeit a commercial one),\r
+and I hope to make available Watcom makefiles in the near future.\r
\r
+Here are the makefiles I am using.  Both makefiles use a compiler configuration\r
+file that contains compiler switches such as optimization settings.  I call\r
+this file bor32.cfg and keep a copy in both the ANTLR and DLG subdirectories.\r
\r
+==== File: bor32.cfg (cut here) ===============================================\r
+-w-\r
+-RT-\r
+-x-\r
+-N-\r
+-k-\r
+-d\r
+-O2-e-l\r
+-Z\r
+-D__STDC__=1\r
+==== End of file bor32.cfg (cut here) =========================================\r
\r
+==== File: antlr\bor32.mak (cut here) =========================================\r
+#\r
+#  ANTLR 1.32 Makefile for Borland C++ 4.02 with DPMI 32-bit DOS extender by\r
+#  David Seidel\r
+#  Innovative Data Concepts Incorporated\r
+#  71333.1575@compuserve.com (or) dseidel@delphi.com\r
+#\r
+#  Notes:   1. Compiler switches (optimization etc.) are contained in the\r
+#              file bor32.cfg.\r
+#           2. This makefile requires Borland C++ 4.02 or greater with\r
+#              the DOS Power Pack add-on package.\r
+#           3. Change the BCCDIR macro below to the topmost directory in\r
+#              which BCC is installed on your system.\r
+#\r
\r
+BCCDIR   =  d:\bc4\r
+CC       =  bcc32\r
+SET      =  ..\support\set\r
+PCCTS_H  =  ..\h\r
+ANTLR    =  ..\bin\antlr\r
+DLG      =  ..\bin\dlg\r
+CFLAGS   =  -I$(BCCDIR)\include -I. -I$(SET) -I$(PCCTS_H) -DUSER_ZZSYN \\r
+ +bor32.cfg\r
+LIBS     =  dpmi32 cw32\r
+OBJ_EXT  =  obj\r
+OBJS     =  antlr.obj scan.obj err.obj bits.obj build.obj fset2.obj fset.obj \\r
+ gen.obj globals.obj hash.obj lex.obj main.obj misc.obj pred.obj dialog.obj \\r
+ set.obj\r
\r
+.c.obj:\r
+      $(CC) -c $(CFLAGS) {$&.c }\r
\r
+antlr.exe: $(OBJS)\r
+   tlink32 @&&|\r
+-Tpe -ax -c -s -L$(BCCDIR)\lib +\r
+$(BCCDIR)\lib\c0x32 $**\r
+$@\r
\r
+$(LIBS)\r
+;\r
+|\r
+   copy *.exe ..\bin\r
\r
\r
+# *********** Target list of PC machines ***********\r
+#\r
+# Don't worry about the ambiguity messages coming from antlr\r
+# for making antlr.c etc...  [should be 10 of them, I think]\r
+#\r
\r
+# leave this commented out for initial build!\r
+#antlr.c stdpccts.h parser.dlg tokens.h err.c : antlr.g\r
+#   $(ANTLR) antlr.g\r
\r
+antlr.$(OBJ_EXT): antlr.c mode.h tokens.h\r
\r
+scan.$(OBJ_EXT): scan.c mode.h tokens.h\r
\r
+# leave this commented out for initial build!\r
+#scan.c mode.h: parser.dlg\r
+#   $(DLG) -C2 parser.dlg scan.c\r
\r
+set.$(OBJ_EXT): $(SET)\set.c\r
+   $(CC) -c $(CFLAGS) $(SET)\set.c\r
\r
+==== End of file antlr\bor32.mak (cut here) ===================================\r
\r
+==== File: dlg\bor32.mak (cut here) ===========================================\r
+#\r
+#  DLG 1.32 Makefile for Borland C++ 4.02 with DPMI 32-bit DOS extender by\r
+#  David Seidel\r
+#  Innovative Data Concepts Incorporated\r
+#  71333.1575@compuserve.com (or) dseidel@delphi.com\r
+#\r
+#  Notes:   1. Compiler switches (optimization etc.) are contained in the\r
+#              file bor32.cfg.\r
+#           2. This makefile requires Borland C++ 4.02 or greater with\r
+#              the DOS Power Pack add-on package.\r
+#           3. Change the BCCDIR macro below to the topmost directory in\r
+#              which BCC is installed on your system.\r
+#\r
\r
\r
+BCCDIR   =  d:\bc4\r
+CC       =  bcc32\r
+SET      =  ..\support\set\r
+PCCTS_H  =  ..\h\r
+ANTLR    =  ..\bin\antlr\r
+DLG      =  ..\bin\dlg\r
+CFLAGS   =  -I$(BCCDIR)\include -I. -I$(SET) -I$(PCCTS_H) -DUSER_ZZSYN \\r
+ +bor32.cfg\r
+LIBS     =  dpmi32 cw32\r
+OBJ_EXT  =  obj\r
+OBJS     =  dlg_p.obj dlg_a.obj main.obj err.obj support.obj \\r
+ output.obj relabel.obj automata.obj set.obj\r
\r
+.c.obj:\r
+      $(CC) -c $(CFLAGS) {$&.c }\r
\r
+dlg.exe : $(OBJS)\r
+   tlink32 @&&|\r
+-Tpe -ax -c -s -L$(BCCDIR)\lib +\r
+c0x32 $**\r
+$@\r
\r
+$(LIBS)\r
+;\r
+|\r
+   copy *.exe ..\bin\r
\r
+dlg_p.obj:  dlg_p.c\r
\r
+dlg_a.obj:  dlg_a.c\r
\r
+main.obj:   main.c\r
\r
+err.obj:    err.c\r
\r
+support.obj:   support.c\r
\r
+output.obj: output.c\r
\r
+relabel.obj:   relabel.c\r
\r
+automata.obj:  automata.c\r
\r
+set.$(OBJ_EXT): $(SET)\set.c\r
+   $(CC) -c $(CFLAGS) $(SET)\set.c\r
\r
+==== End of file dlg\bor32.mak (cut here) =====================================\r
\r
\r
\r
+\r
+\r
+\r
diff --git a/Tools/CodeTools/Source/Pccts/NOTES.msvc b/Tools/CodeTools/Source/Pccts/NOTES.msvc
new file mode 100644 (file)
index 0000000..86f8ed6
--- /dev/null
@@ -0,0 +1,189 @@
+\r
+                        Microsoft Visual C Stuff\r
+\r
+\r
+[Tom Moog 2-Oct-98\r
+\r
+    Users of Microsoft Visual C++ should download a separate\r
+    ready-to-run zip file from my web site.  It contains \r
+    binaries, static library, and a sample project.\r
+]\r
+\r
+[\r
+  Two notes added by Tom Moog 23-Sep-97.  I believe the *.dsp and\r
+  *.mak files that were once at the end of this file are now obsolete.\r
+  \r
+  The following MSVC .dsp and .mak files for pccts and sorcerer\r
+  were contributed by Stanislaw Bochnak (S.Bochnak@microtool.com.pl)\r
+  and Jeff Vincent (jvincent@novell.com)\r
+\r
+        PCCTS Distribution Kit\r
+        ----------------------\r
+        pccts/antlr/AntlrMSVC50.dsp\r
+        pccts/antlr/AntlrMSVC50.mak\r
+\r
+        pccts/dlg/DlgMSVC50.dsp\r
+        pccts/dlg/DlgMSVC50.mak\r
+\r
+        pccts/support/genmk/watgenmk.mak\r
+        pccts/support/msvc.dsp\r
+\r
+        Sorcerer Distribution Kit\r
+        -------------------------\r
+        pccts/sorcerer/SorcererMSVC50.dsp\r
+        pccts/sorcerer/SorcererMSVC50.mak\r
+\r
+        pccts/sorcerer/lib/msvc.dsp\r
+\r
+  I do not have an MS based computer.  If you discover problems\r
+  please report them so as to save trouble for others in the future.\r
+]\r
+\r
+[\r
+ Modified by Terence Parr (September 1995) to change .C to .cpp\r
+]\r
+\r
+[\r
+ This file contains notes on MSVC for Windows NT console execs by Dave\r
+ Seidel and an explanation of flags etc.. by John Hall; good luck,\r
+ Terence\r
+]\r
+\r
+===============================================================================\r
+Date: Sat, 31 Dec 1994 11:40:36 -0500 (EST)\r
+From: David Seidel <75342.2034@compuserve.com>\r
+\r
+I've succesfully build 1.31b3 with djgpp for DOS and MSVC 2.0 for Windows \r
+NT.  The only (minor) problem I had was that GNU make (version 3.71, in the \r
+djgpp port) complained about "multiple targets" in both the antlr and dlg \r
+makefiles.  I got around the error by, in each makefile, commenting out the \r
+$(SRC) dependency, for example:\r
+\r
+   antlr: $(OBJ) #$(SRC)\r
+\r
+I don't know why this is happenning, since you haven't changed that part of \r
+the makefile at all, and I think this used to work ok...\r
+\r
+Here are the makefiles I built from within the MSVC 2.0 environment for antlr \r
+and dlg and Windows NT console executables.  Please feel free to pass them \r
+on.  Of course, as soon as 1.31 "goes gold", I will send you nice new \r
+binaries.  I'm not going to bother to keep doing both Borland and djgpp for \r
+DOS however.  Instead, I'll just keep the djgpp version up to date and also \r
+provide WinNT binaries.\r
+\r
+Dave\r
+===============================================================================\r
+\r
+         How to port PCCTS 1.10 (and 1.32 hopefully) to Visual C++\r
+\r
+                                   By\r
+\r
+                       John Hall <jhall@ivy.wpi.edu>\r
+\r
+Here is how to compile an ANTLR grammar in Visual C++.  These steps\r
+describe how to have your ANTLR grammar parse the input file the user\r
+selects when they choose File Open in your Windows application.  (Even\r
+if you aren't using Visual C++, the steps should be portable enough to\r
+other compilers.)\r
+\r
+ * Make sure that ANTLR and DLG generate ANSI code (use the -ga\r
+   switch).\r
+\r
+ * Set the following compiler flags in Visual C++ (these are in the\r
+   Memory Model category of the compiler options in the Project\r
+   Options menu):\r
+\r
+   FLAG MEANING\r
+   ==== ==============================================================\r
+   /AL  Large memory model (multiple data segments; data items must be\r
+    smaller than 64K).\r
+\r
+   /Gtn Allocates all items whose size is greater than or equal to n\r
+    in a new data segment.  (I let n be 256: /Gt256.)\r
+\r
+   /Gx- All references to data items are done with far addressing in\r
+    case they are placed in a far segment.\r
+\r
+ * Add the following member variable to the attributes section of your\r
+   derived CDocument class (you will need to make sure you also\r
+   include stdio.h):\r
+\r
+   FILE *fp;\r
+\r
+ * Add the following method to your derived CDocument class:\r
+\r
+   BOOL CAppDoc::OnOpenDocument(const char* pszPathName)\r
+   {\r
+       // Call CDocument's OnOpenDocument to do housekeeping for us\r
+       // DON'T add anything to the loading section of Serialize\r
+       if (!CDocument::OnOpenDocument(pszPathName))\r
+           return FALSE;\r
+   \r
+       // Open input file\r
+       if ((fp = fopen(pszPathName, "r")) == NULL)\r
+           return FALSE;\r
+   \r
+       // Parse input file\r
+       ANTLR(start(), fp);\r
+   \r
+       // Close input file\r
+       fclose(fp);\r
+       return TRUE;\r
+   }\r
+\r
+   (Note: additional code may be necessary, depending on your parser.\r
+   For example, if your parser uses PCCTS's symbol table library, you\r
+   will need to insert calls to zzs_init and zzs_done.)\r
+\r
+ * Compile the generated C files as C++ files.  (I renamed the files\r
+   to have a .CPP extension to fool Visual C++ into thinking they were\r
+   C++ files.  One might also use the /Tp switch, but that switch\r
+   requires you separately include the filename.)  [I used this step\r
+   as an easy out for all the external linking errors I was getting\r
+   that I couldn't fix by declaring things extern "C".]\r
+\r
+ * Make sure the __STDC__ portion of the generated files gets\r
+   compiled.  (Either define __STDC__ yourself or else change all\r
+   occurrences of __STDC__ to __cplusplus in the generated files.  You\r
+   can define __STDC__ in the Preprocessor category of the compiler\r
+   options.)\r
+\r
+        ================================================================\r
+        = Note 23-Sep-97: This is probably not necessary any more.     =\r
+        = With 1.33MRxxx the use of __STDC__ was replaced with the     =\r
+        = macro __USE_PROTOS to control the compilation of prototypes. =\r
+        ================================================================\r
+                        \r
+That last step is important for Visual C++, but may not apply to other\r
+compilers.  For C++ compilers, whether __STDC__ is defined is\r
+implementation dependent (ARM, page 379).  Apparently, Visual C++ does\r
+not to define it; it also does not support "old style" C function\r
+definitions (which is okay, according to page 404 of the ARM).  Those\r
+two things together caused problems when trying to port the code.\r
+When it saw this:\r
+\r
+#ifdef __STDC__\r
+void\r
+globals(AST **_root)\r
+#else\r
+globals(_root)\r
+AST **_root;\r
+#endif\r
+\r
+it skipped the __STDC__ section and tried to process the "old style"\r
+function definition, where it choked.\r
+\r
+When you finally get your parser to compile and link without error,\r
+you may get General Protection Fault errors at run time.  The problem\r
+I had was that a NULL was passed to a variable argument function\r
+without an explicit cast.  The function grabbed a pointer (32-bits)\r
+off the stack using va_arg, but the NULL was passed silently as the\r
+integer 0 (16 bits), making the resulting pointer was invalid.  (This\r
+was in PCCTS's sample C parser.)\r
+\r
+There is one other thing I might suggest to help you avoid a run-time\r
+error.  Make sure you redefine the default error reporting function,\r
+zzsyn.  To do this, put "#define USER_ZZSYN" in your #header section\r
+and put your own zzsyn somewhere.  You can then pop up a MessageBox or\r
+print the error to some output window.\r
+===============================================================================\r
diff --git a/Tools/CodeTools/Source/Pccts/README b/Tools/CodeTools/Source/Pccts/README
new file mode 100644 (file)
index 0000000..d089b63
--- /dev/null
@@ -0,0 +1,159 @@
+\r
+                          Parr Research Corporation\r
+                                    with\r
+                  Purdue University Electrical Engineering\r
+                                    and\r
+                       University of Minnesota, AHPCRC\r
+\r
+                                Terence Parr\r
+                                Russell Quong\r
+                                 Will Cohen\r
+                                 Hank Dietz\r
+\r
+\r
+A central place for information about PCCTS 1.33 is:\r
+\r
+        http://www.polhode.com/pccts.html\r
+\r
+The maintenance release is available from:\r
+\r
+        http://www.polhode.com/pccts133mr.zip\r
+\r
+There is a ready-to-run version for win32 for Microsoft Visual Studio\r
+at the same site.  It is available from:\r
+\r
+        http://www.polhode.com/win32.zip\r
+\r
+New users should visit http://www.polhode.com/pccts.html in\r
+order to get the following document:\r
+\r
+        "Notes For New Users of PCCTS"\r
+\r
+This is a Postscript file of about 40 pages which is extremely \r
+useful for someone starting out. It is a based on 1.33mr21\r
+\r
+When you have a little more experience, be sure to review the\r
+following documents in the distribution kit:\r
+\r
+            CHANGES_FROM_133.txt\r
+            CHANGES_FROM_133_BEFORE_MR13.txt\r
+            KNOWN_PROBLEMS.txt\r
+\r
+-------------------------------------------------------------------------\r
+                      INSTALLATION (Unix)\r
+-------------------------------------------------------------------------\r
+0. Download http://www.polhode.com/pccts133mr.zip\r
+\r
+1. Unzip the distribution kit to your preferred location.  \r
+   If there are newline problems try using zip -a ...\r
+\r
+2. cd to the main pccts directory.\r
+\r
+3. make\r
+\r
+   This will create:\r
+\r
+        antlr\r
+        dlg\r
+        sorcerer\r
+        genmk\r
+\r
+4. Copy to /usr/local/bin or /usr/local/bin if you like.  If you\r
+   don't wish to then add pccts/bin to your path.\r
+\r
+5. To get an up-to-date list of program options execute the\r
+   program with no command line options.  To get up-to-date\r
+   documentation read CHANGES_FROM_133*.txt and KNOWN_PROBLEMS.txt\r
+   at:\r
+\r
+           http://www.polhode.com/pccts.html\r
+\r
+6. You need not create a library.  The makefile created by genmk\r
+   assumes that the files are not part of a library. \r
+\r
+   If you wish to create a library from elements of pccts/h:\r
+\r
+   If the first letter of the filename is lowercase (uppercase) it is\r
+   related to the code generated using the pccts C mode (C++ mode).\r
+   Some of the .c and .cpp files in the h directory are not meant to\r
+   be placed in a library and will not compile because they are meant\r
+   to be #include in pccts generated files which are grammar specific.\r
+\r
+   For C++ users place the following elements in the library:\r
+\r
+        AParser.cpp\r
+        ASTBase.cpp\r
+        ATokenBuffer.cpp\r
+        BufFileInput.cpp (optional)\r
+        DLexerBase.cpp\r
+        PCCTSAST.cpp\r
+        SList.cpp\r
+\r
+-------------------------------------------------------------------------\r
+                    INSTALLATION (Win32)\r
+-------------------------------------------------------------------------\r
+\r
+I've tried to keep the win32 kit to the minimum necessary to get \r
+up and running.  The complete kit contains additional information\r
+(some historical), source code, and DevStudio projects for \r
+rebuilding pccts from the source code.\r
+\r
+The kit is now distributed with both MSVC 5 and MSVC6 style projects.\r
+\r
+0. Download http://www.polhode.com/win32.zip.\r
+\r
+   You may also wish to download:\r
+\r
+        http://www.polhode.com/CHANGES_FROM_133.txt\r
+        http://www.polhode.com/CHANGES_FROM_133_BEFORE_MR13.txt\r
+        http://www.polhode.com/KNOWN_PROBLEMS.txt\r
+\r
+1. Unzip the distribution kit to your preferred location.\r
+\r
+   This will create:\r
+\r
+         a pccts directory tree\r
+            pccts/bin/*.exe\r
+            pccts/lib/*.lib\r
+            pccts/h/*\r
+            sorcerer/lib/*\r
+            sorcerer/h/*\r
+\r
+         an example directory tree\r
+            pccts\example\calcAST\*\r
+            pccts\example\simple\*\r
+\r
+2. Define the environment variable PCCTS to point to the main\r
+   pccts directory.\r
+\r
+3. Try building the simple project: pccts\example\simple\simple50.dsw\r
+   or simple60.dsw.\r
+\r
+4. Try building the complex project: pccts\example\calcAST\calcAST50.dsw\r
+   or calcAST60.dsw.\r
+\r
+-------------------------------------------------------------------------\r
+                      INSTALLATION (DEC/VMS)\r
+-------------------------------------------------------------------------\r
+\r
+DEC/VMS support added by Piéronne Jean-François (jfp@altavista.net)\r
+\r
+0. Download http://www.polhode.com/pccts133mr.zip\r
+\r
+1. Unzip the distribution kit to your preferred location.\r
+\r
+2. set default to the main pccts directory.\r
+\r
+3. @makefile.vms\r
+\r
+   This will create in directory [.bin]:\r
+\r
+        antlr.exe\r
+        dlg.exe\r
+        sorcerer.exe\r
+        genmk.exe\r
+\r
+5. To get an up-to-date list of program options execute the\r
+   program with no command line options.  To get up-to-date\r
+   documentation read CHANGES_FROM_133*.txt and KNOWN_PROBLEMS.txt\r
+   at http://www.polhode.com/pccts.html.\r
diff --git a/Tools/CodeTools/Source/Pccts/RIGHTS b/Tools/CodeTools/Source/Pccts/RIGHTS
new file mode 100644 (file)
index 0000000..9db175f
--- /dev/null
@@ -0,0 +1,26 @@
+\r
+SOFTWARE RIGHTS\r
+\r
+We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
+Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
+company may do whatever they wish with source code distributed with\r
+PCCTS or the code generated by PCCTS, including the incorporation of\r
+PCCTS, or its output, into commerical software.\r
+\r
+We encourage users to develop software with PCCTS.  However, we do ask\r
+that credit is given to us for developing PCCTS.  By "credit", we mean\r
+that if you incorporate our source code into one of your programs\r
+(commercial product, research project, or otherwise) that you\r
+acknowledge this fact somewhere in the documentation, research report,\r
+etc...  If you like PCCTS and have developed a nice tool with the\r
+output, please mention that you developed it using PCCTS.  In\r
+addition, we ask that this header remain intact in our source code.\r
+As long as these guidelines are kept, we expect to continue enhancing\r
+this system and expect to make other tools available as they are\r
+completed.\r
+\r
+ANTLR 1.33\r
+Terence Parr\r
+Parr Research Corporation\r
+with Purdue University and AHPCRC, University of Minnesota\r
+1989-1995\r
diff --git a/Tools/CodeTools/Source/Pccts/antlr/AntlrMS.mak b/Tools/CodeTools/Source/Pccts/antlr/AntlrMS.mak
new file mode 100644 (file)
index 0000000..7c14993
--- /dev/null
@@ -0,0 +1,233 @@
+# PCCTS directory\r
+\r
+# You will need to set the LIB variable similar to this.\r
+# LIB="C:/Program Files/Microsoft Visual Studio .NET 2003/Vc7/lib;c:/Microsoft Visual Studio .NET 2003/Vc7/PlatformSDK/Lib"\r
+\r
+# PCCTS_HOME=<your PCCTS_HOME>\r
+PCCTS_HOME=$(WORKSPACE)\Tools\Source\TianoTools\Pccts\r
+ANTLR_SRC=$(PCCTS_HOME)\antlr\r
+PCCTS_H=$(PCCTS_HOME)\h\r
+\r
+\r
+# Support directories\r
+SET=$(PCCTS_HOME)\support\set\r
+\r
+\r
+# Compiler stuff\r
+CC = cl\r
+CFLAGS = /nologo -I "." -I "$(PCCTS_H)" -I "$(SET)" -D "USER_ZZSYN" -D "PC" \\r
+        -D "ZZLEXBUFSIZE=65536"  /D "LONGFILENAMES" /Zi /W3 -D__USE_PROTOS /wd4700\r
+\r
+ANTLR_OBJS = antlr.obj scan.obj err.obj bits.obj build.obj fset2.obj \\r
+            fset.obj gen.obj globals.obj hash.obj lex.obj main.obj \\r
+            misc.obj pred.obj egman.obj mrhoist.obj fcache.obj\r
+\r
+SUPPORT_OBJS = set.obj\r
+\r
+# Dependencies\r
+\r
+$(WORKSPACE)\Tools\bin\antlr.exe: $(ANTLR_OBJS) $(SUPPORT_OBJS)\r
+    $(CC) $(CFLAGS) -o antlr.exe $(ANTLR_OBJS) $(SUPPORT_OBJS)\r
+    del *.obj\r
+               move antlr.exe $(WORKSPACE)\Tools\bin\r
+\r
+\r
+antlr.obj: $(ANTLR_SRC)\antlr.c \\r
+                       $(PCCTS_H)\antlr.h \\r
+                       $(PCCTS_H)\config.h \\r
+                       $(PCCTS_H)\dlgdef.h \\r
+                                       $(SET)\set.h \\r
+                                       $(ANTLR_SRC)\generic.h \\r
+                                       $(ANTLR_SRC)\hash.h \\r
+                                       $(ANTLR_SRC)\mode.h \\r
+                                       $(ANTLR_SRC)\proto.h \\r
+                                       $(ANTLR_SRC)\syn.h \\r
+                                       $(ANTLR_SRC)\tokens.h \\r
+\r
+    $(CC) -c $(CFLAGS) $(ANTLR_SRC)\antlr.c\r
+\r
+scan.obj: $(ANTLR_SRC)\scan.c \\r
+                       $(PCCTS_H)\antlr.h \\r
+                                       $(PCCTS_H)\config.h \\r
+                                       $(PCCTS_H)\dlgauto.h \\r
+                                       $(PCCTS_H)\dlgdef.h \\r
+                                       $(SET)\set.h \\r
+                                       $(ANTLR_SRC)\generic.h \\r
+                                       $(ANTLR_SRC)\hash.h \\r
+                                       $(ANTLR_SRC)\mode.h \\r
+                                       $(ANTLR_SRC)\proto.h \\r
+                                       $(ANTLR_SRC)\syn.h \\r
+                                       $(ANTLR_SRC)\tokens.h \\r
+\r
+    $(CC) -c $(CFLAGS) $(ANTLR_SRC)\scan.c\r
+\r
+err.obj: $(ANTLR_SRC)\err.c \\r
+                                       $(PCCTS_H)\antlr.h \\r
+                                       $(PCCTS_H)\config.h \\r
+                                       $(PCCTS_H)\dlgdef.h \\r
+                                       $(PCCTS_H)\err.h \\r
+                                       $(SET)\set.h \\r
+                                       $(ANTLR_SRC)\generic.h \\r
+                                       $(ANTLR_SRC)\hash.h \\r
+                                       $(ANTLR_SRC)\proto.h \\r
+                                       $(ANTLR_SRC)\syn.h \\r
+                                       $(ANTLR_SRC)\tokens.h \\r
+\r
+    $(CC) -c $(CFLAGS) $(ANTLR_SRC)\err.c\r
+\r
+bits.obj: $(ANTLR_SRC)\bits.c \\r
+                                       $(PCCTS_H)\config.h \\r
+                                       $(PCCTS_H)\dlgdef.h \\r
+                                       $(SET)\set.h \\r
+                                       $(ANTLR_SRC)\generic.h \\r
+                                       $(ANTLR_SRC)\hash.h \\r
+                                       $(ANTLR_SRC)\proto.h \\r
+                                       $(ANTLR_SRC)\syn.h \\r
+\r
+    $(CC) -c $(CFLAGS) $(ANTLR_SRC)\bits.c\r
+\r
+build.obj: $(ANTLR_SRC)\build.c \\r
+                                       $(PCCTS_H)\config.h \\r
+                                       $(PCCTS_H)\dlgdef.h \\r
+                                       $(SET)\set.h \\r
+                                       $(ANTLR_SRC)\generic.h \\r
+                                       $(ANTLR_SRC)\hash.h \\r
+                                       $(ANTLR_SRC)\proto.h \\r
+                                       $(ANTLR_SRC)\syn.h \\r
+\r
+    $(CC) -c $(CFLAGS) $(ANTLR_SRC)\build.c\r
+\r
+fset2.obj: $(ANTLR_SRC)\fset2.c \\r
+                                       $(PCCTS_H)\config.h \\r
+                                       $(PCCTS_H)\dlgdef.h \\r
+                                       $(SET)\set.h \\r
+                                       $(ANTLR_SRC)\generic.h \\r
+                                       $(ANTLR_SRC)\hash.h \\r
+                                       $(ANTLR_SRC)\proto.h \\r
+                                       $(ANTLR_SRC)\syn.h \\r
+\r
+    $(CC) -c $(CFLAGS) $(ANTLR_SRC)\fset2.c\r
+\r
+fset.obj: $(ANTLR_SRC)\fset.c \\r
+                                       $(PCCTS_H)\config.h \\r
+                                       $(PCCTS_H)\dlgdef.h \\r
+                                       $(SET)\set.h \\r
+                                       $(ANTLR_SRC)\generic.h \\r
+                                       $(ANTLR_SRC)\hash.h \\r
+                                       $(ANTLR_SRC)\proto.h \\r
+                                       $(ANTLR_SRC)\syn.h \\r
+\r
+    $(CC) -c $(CFLAGS) $(ANTLR_SRC)\fset.c\r
+\r
+gen.obj: $(ANTLR_SRC)\gen.c \\r
+                                       $(PCCTS_H)\config.h \\r
+                                       $(PCCTS_H)\dlgdef.h \\r
+                                       $(SET)\set.h \\r
+                                       $(ANTLR_SRC)\generic.h \\r
+                                       $(ANTLR_SRC)\hash.h \\r
+                                       $(ANTLR_SRC)\proto.h \\r
+                                       $(ANTLR_SRC)\syn.h \\r
+\r
+    $(CC) -c $(CFLAGS) $(ANTLR_SRC)\gen.c\r
+\r
+globals.obj: $(ANTLR_SRC)\globals.c \\r
+                                       $(PCCTS_H)\config.h \\r
+                                       $(SET)\set.h \\r
+                                       $(ANTLR_SRC)\generic.h \\r
+                                       $(ANTLR_SRC)\hash.h \\r
+                                       $(ANTLR_SRC)\proto.h \\r
+                                       $(ANTLR_SRC)\syn.h \\r
+\r
+    $(CC) -c $(CFLAGS) $(ANTLR_SRC)\globals.c\r
+\r
+hash.obj: $(ANTLR_SRC)\hash.c \\r
+                                       $(PCCTS_H)\config.h \\r
+                                       $(ANTLR_SRC)\hash.h \\r
+\r
+    $(CC) -c $(CFLAGS) $(ANTLR_SRC)\hash.c\r
+\r
+lex.obj: $(ANTLR_SRC)\lex.c \\r
+                                       $(PCCTS_H)\config.h \\r
+                                       $(SET)\set.h \\r
+                                       $(ANTLR_SRC)\generic.h \\r
+                                       $(ANTLR_SRC)\hash.h \\r
+                                       $(ANTLR_SRC)\proto.h \\r
+                                       $(ANTLR_SRC)\syn.h \\r
+\r
+    $(CC) -c $(CFLAGS) $(ANTLR_SRC)\lex.c\r
+\r
+main.obj: $(ANTLR_SRC)\main.c \\r
+                                       $(PCCTS_H)\antlr.h \\r
+                                       $(PCCTS_H)\config.h \\r
+                                       $(PCCTS_H)\dlgdef.h \\r
+                                       $(SET)\set.h \\r
+                                       $(ANTLR_SRC)\generic.h \\r
+                                       $(ANTLR_SRC)\hash.h \\r
+                                       $(ANTLR_SRC)\mode.h \\r
+                                       $(ANTLR_SRC)\proto.h \\r
+                                       $(ANTLR_SRC)\stdpccts.h \\r
+                                       $(ANTLR_SRC)\syn.h \\r
+                                       $(ANTLR_SRC)\tokens.h \\r
+\r
+    $(CC) -c $(CFLAGS) $(ANTLR_SRC)\main.c\r
+\r
+misc.obj: $(ANTLR_SRC)\misc.c \\r
+                                       $(PCCTS_H)\config.h \\r
+                                       $(PCCTS_H)\dlgdef.h \\r
+                                       $(SET)\set.h \\r
+                                       $(ANTLR_SRC)\generic.h \\r
+                                       $(ANTLR_SRC)\hash.h \\r
+                                       $(ANTLR_SRC)\proto.h \\r
+                                       $(ANTLR_SRC)\syn.h \\r
+\r
+    $(CC) -c $(CFLAGS) $(ANTLR_SRC)\misc.c\r
+\r
+pred.obj: $(ANTLR_SRC)\pred.c \\r
+                                       $(PCCTS_H)\config.h \\r
+                                       $(PCCTS_H)\dlgdef.h \\r
+                                       $(SET)\set.h \\r
+                                       $(ANTLR_SRC)\generic.h \\r
+                                       $(ANTLR_SRC)\hash.h \\r
+                                       $(ANTLR_SRC)\proto.h \\r
+                                       $(ANTLR_SRC)\syn.h \\r
+\r
+    $(CC) -c $(CFLAGS) $(ANTLR_SRC)\pred.c\r
+\r
+egman.obj: $(ANTLR_SRC)\egman.c \\r
+                                       $(PCCTS_H)\config.h \\r
+                                       $(SET)\set.h \\r
+                                       $(ANTLR_SRC)\generic.h \\r
+                                       $(ANTLR_SRC)\hash.h \\r
+                                       $(ANTLR_SRC)\proto.h \\r
+                                       $(ANTLR_SRC)\syn.h \\r
+\r
+    $(CC) -c $(CFLAGS) $(ANTLR_SRC)\egman.c\r
+\r
+mrhoist.obj: $(ANTLR_SRC)\mrhoist.c \\r
+                                       $(ANTLR_SRC)\generic.h \\r
+                                       $(ANTLR_SRC)\hash.h \\r
+                                       $(ANTLR_SRC)\proto.h \\r
+                                       $(ANTLR_SRC)\syn.h \\r
+\r
+    $(CC) -c $(CFLAGS) $(ANTLR_SRC)\mrhoist.c\r
+\r
+fcache.obj: $(ANTLR_SRC)\fcache.c \\r
+                                       $(ANTLR_SRC)\generic.h \\r
+                                       $(ANTLR_SRC)\hash.h \\r
+                                       $(ANTLR_SRC)\proto.h \\r
+                                       $(ANTLR_SRC)\syn.h \\r
+\r
+    $(CC) -c $(CFLAGS) $(ANTLR_SRC)\fcache.c\r
+\r
+set.obj: $(SET)\set.c \\r
+                                       $(PCCTS_H)\config.h \\r
+                                       $(SET)\set.h \\r
+\r
+    $(CC) -c $(CFLAGS) $(SET)\set.c\r
+\r
+clean: \r
+    del *.obj\r
+\r
+distclean:\r
+    del *.obj\r
+    del $(WORKSPACE)\Tools\bin\antlr.exe\r
diff --git a/Tools/CodeTools/Source/Pccts/antlr/AntlrPPC.mak b/Tools/CodeTools/Source/Pccts/antlr/AntlrPPC.mak
new file mode 100644 (file)
index 0000000..9ede60d
--- /dev/null
@@ -0,0 +1,101 @@
+#   Target:     antlrPPC\r
+#   Sources:    ::support:set:set.c\r
+#               antlr.c\r
+#               bits.c\r
+#               build.c\r
+#               egman.c\r
+#               err.c\r
+#               fcache.c\r
+#               fset2.c\r
+#               fset.c\r
+#               gen.c\r
+#               globals.c\r
+#               hash.c\r
+#               lex.c\r
+#               main.c\r
+#               misc.c\r
+#               mrhoist.c\r
+#               pred.c\r
+#               scan.c\r
+#   Created:    Sunday, May 17, 1998 10:24:53 PM\r
+#      Author:         Kenji Tanaka\r
+MAKEFILE     = antlrPPC.make\r
+Â¥MondoBuildÂ¥ = {MAKEFILE}  # Make blank to avoid rebuilds when makefile is modified\r
+Includes     = Â¶\r
+               -i "::h:" Â¶\r
+               -i "::support:set:"\r
+SymÂ¥PPC      = \r
+ObjDirÂ¥PPC   = :Obj:\r
+PPCCOptions  = {Includes} {SymÂ¥PPC} -w off -d MPW -d __STDC__=1 -d USER_ZZSYN\r
+ObjectsÂ¥PPC  = Â¶\r
+               "{ObjDirÂ¥PPC}set.c.x" Â¶\r
+               "{ObjDirÂ¥PPC}antlr.c.x" Â¶\r
+               "{ObjDirÂ¥PPC}bits.c.x" Â¶\r
+               "{ObjDirÂ¥PPC}build.c.x" Â¶\r
+               "{ObjDirÂ¥PPC}egman.c.x" Â¶\r
+               "{ObjDirÂ¥PPC}err.c.x" Â¶\r
+               "{ObjDirÂ¥PPC}fcache.c.x" Â¶\r
+               "{ObjDirÂ¥PPC}fset2.c.x" Â¶\r
+               "{ObjDirÂ¥PPC}fset.c.x" Â¶\r
+               "{ObjDirÂ¥PPC}gen.c.x" Â¶\r
+               "{ObjDirÂ¥PPC}globals.c.x" Â¶\r
+               "{ObjDirÂ¥PPC}hash.c.x" Â¶\r
+               "{ObjDirÂ¥PPC}lex.c.x" Â¶\r
+               "{ObjDirÂ¥PPC}main.c.x" Â¶\r
+               "{ObjDirÂ¥PPC}misc.c.x" Â¶\r
+               "{ObjDirÂ¥PPC}mrhoist.c.x" Â¶\r
+               "{ObjDirÂ¥PPC}pred.c.x" Â¶\r
+               "{ObjDirÂ¥PPC}scan.c.x"\r
+antlrPPC Ã„Ä {Â¥MondoBuildÂ¥} {ObjectsÂ¥PPC}\r
+       PPCLink Â¶\r
+               -o {Targ} {SymÂ¥PPC} Â¶\r
+               {ObjectsÂ¥PPC} Â¶\r
+               -t 'MPST' Â¶\r
+               -c 'MPS ' Â¶\r
+               "{SharedLibraries}InterfaceLib" Â¶\r
+               "{SharedLibraries}StdCLib" Â¶\r
+               #"{SharedLibraries}MathLib" Â¶\r
+               "{PPCLibraries}StdCRuntime.o" Â¶\r
+               "{PPCLibraries}PPCCRuntime.o" Â¶\r
+               "{PPCLibraries}PPCToolLibs.o"\r
+"{ObjDirÂ¥PPC}set.c.x" Ã„ {Â¥MondoBuildÂ¥} "::support:set:set.c"\r
+       {PPCC} "::support:set:set.c" -o {Targ} {PPCCOptions}\r
+"{ObjDirÂ¥PPC}antlr.c.x" Ã„ {Â¥MondoBuildÂ¥} antlr.c\r
+       {PPCC} antlr.c -o {Targ} {PPCCOptions}\r
+"{ObjDirÂ¥PPC}bits.c.x" Ã„ {Â¥MondoBuildÂ¥} bits.c\r
+       {PPCC} bits.c -o {Targ} {PPCCOptions}\r
+"{ObjDirÂ¥PPC}build.c.x" Ã„ {Â¥MondoBuildÂ¥} build.c\r
+       {PPCC} build.c -o {Targ} {PPCCOptions}\r
+"{ObjDirÂ¥PPC}egman.c.x" Ã„ {Â¥MondoBuildÂ¥} egman.c\r
+       {PPCC} egman.c -o {Targ} {PPCCOptions}\r
+"{ObjDirÂ¥PPC}err.c.x" Ã„ {Â¥MondoBuildÂ¥} err.c\r
+       {PPCC} err.c -o {Targ} {PPCCOptions}\r
+"{ObjDirÂ¥PPC}fcache.c.x" Ã„ {Â¥MondoBuildÂ¥} fcache.c\r
+       {PPCC} fcache.c -o {Targ} {PPCCOptions}\r
+"{ObjDirÂ¥PPC}fset2.c.x" Ã„ {Â¥MondoBuildÂ¥} fset2.c\r
+       {PPCC} fset2.c -o {Targ} {PPCCOptions}\r
+"{ObjDirÂ¥PPC}fset.c.x" Ã„ {Â¥MondoBuildÂ¥} fset.c\r
+       {PPCC} fset.c -o {Targ} {PPCCOptions}\r
+"{ObjDirÂ¥PPC}gen.c.x" Ã„ {Â¥MondoBuildÂ¥} gen.c\r
+       {PPCC} gen.c -o {Targ} {PPCCOptions}\r
+"{ObjDirÂ¥PPC}globals.c.x" Ã„ {Â¥MondoBuildÂ¥} globals.c\r
+       {PPCC} globals.c -o {Targ} {PPCCOptions}\r
+"{ObjDirÂ¥PPC}hash.c.x" Ã„ {Â¥MondoBuildÂ¥} hash.c\r
+       {PPCC} hash.c -o {Targ} {PPCCOptions}\r
+"{ObjDirÂ¥PPC}lex.c.x" Ã„ {Â¥MondoBuildÂ¥} lex.c\r
+       {PPCC} lex.c -o {Targ} {PPCCOptions}\r
+"{ObjDirÂ¥PPC}main.c.x" Ã„ {Â¥MondoBuildÂ¥} main.c\r
+       {PPCC} main.c -o {Targ} {PPCCOptions}\r
+"{ObjDirÂ¥PPC}misc.c.x" Ã„ {Â¥MondoBuildÂ¥} misc.c\r
+       {PPCC} misc.c -o {Targ} {PPCCOptions}\r
+"{ObjDirÂ¥PPC}mrhoist.c.x" Ã„ {Â¥MondoBuildÂ¥} mrhoist.c\r
+       {PPCC} mrhoist.c -o {Targ} {PPCCOptions}\r
+"{ObjDirÂ¥PPC}pred.c.x" Ã„ {Â¥MondoBuildÂ¥} pred.c\r
+       {PPCC} pred.c -o {Targ} {PPCCOptions}\r
+"{ObjDirÂ¥PPC}scan.c.x" Ã„ {Â¥MondoBuildÂ¥} scan.c\r
+       {PPCC} scan.c -o {Targ} {PPCCOptions}\r
+\r
+antlrPPC Ã„Ä antlr.r\r
+       Rez antlr.r -o antlrPPC -a\r
+Install  Ã„ antlrPPC\r
+       Duplicate -y antlrPPC "{MPW}"Tools:antlr\r
diff --git a/Tools/CodeTools/Source/Pccts/antlr/README b/Tools/CodeTools/Source/Pccts/antlr/README
new file mode 100644 (file)
index 0000000..d7fc959
--- /dev/null
@@ -0,0 +1,19 @@
+                            ANTLR 1.33\r
+\r
+This directory contains the files necessary to build ANTLR.\r
+\r
+If you do a "make scrub", ANTLR will have to run on antlr.g and DLG\r
+will have to run on parser.dlg.  Either\r
+\r
+(1)     ANTLR uses the previous antlr in that directory to rebuild itself\r
+(2)     Needs to find antlr on the search path\r
+\r
+You will find that running "antlr -gh antlr.g" will result in about\r
+10 ambiguity warnings.  These are normal.  Don't worry.\r
+\r
+If you do a "make clean" right after installation, ANTLR and DLG should\r
+not need to run; only the C files will compile.\r
+\r
+Don't forget to go into the makefile to uncomment the appropriate\r
+definitions for your OS/architecture/compiler or see the appropriate\r
+NOTES.?? file.\r
diff --git a/Tools/CodeTools/Source/Pccts/antlr/antlr.1 b/Tools/CodeTools/Source/Pccts/antlr/antlr.1
new file mode 100644 (file)
index 0000000..acfa85b
--- /dev/null
@@ -0,0 +1,209 @@
+.TH ANTLR 1 "September 1995" "ANTLR" "PCCTS Manual Pages"\r
+.SH NAME\r
+antlr \- ANother Tool for Language Recognition\r
+.SH SYNTAX\r
+.LP\r
+\fBantlr\fR [\fIoptions\fR] \fIgrammar_files\fR\r
+.SH DESCRIPTION\r
+.PP\r
+\fIAntlr\fP converts an extended form of context-free grammar into a\r
+set of C functions which directly implement an efficient form of\r
+deterministic recursive-descent LL(k) parser.  Context-free grammars\r
+may be augmented with predicates to allow semantics to influence\r
+parsing; this allows a form of context-sensitive parsing.  Selective\r
+backtracking is also available to handle non-LL(k) and even\r
+non-LALR(k) constructs.  \fIAntlr\fP also produces a definition of a\r
+lexer which can be automatically converted into C code for a DFA-based\r
+lexer by \fIdlg\fR.  Hence, \fIantlr\fR serves a function much like\r
+that of \fIyacc\fR, however, it is notably more flexible and is more\r
+integrated with a lexer generator (\fIantlr\fR directly generates\r
+\fIdlg\fR code, whereas \fIyacc\fR and \fIlex\fR are given independent\r
+descriptions).  Unlike \fIyacc\fR which accepts LALR(1) grammars,\r
+\fIantlr\fR accepts LL(k) grammars in an extended BNF notation \(em\r
+which eliminates the need for precedence rules.\r
+.PP\r
+Like \fIyacc\fR grammars, \fIantlr\fR grammars can use\r
+automatically-maintained symbol attribute values referenced as dollar\r
+variables.  Further, because \fIantlr\fR generates top-down parsers,\r
+arbitrary values may be inherited from parent rules (passed like\r
+function parameters).  \fIAntlr\fP also has a mechanism for creating\r
+and manipulating abstract-syntax-trees.\r
+.PP\r
+There are various other niceties in \fIantlr\fR, including the ability to\r
+spread one grammar over multiple files or even multiple grammars in a single\r
+file, the ability to generate a version of the grammar with actions stripped\r
+out (for documentation purposes), and lots more.\r
+.SH OPTIONS\r
+.IP "\fB-ck \fIn\fR"\r
+Use up to \fIn\fR symbols of lookahead when using compressed (linear\r
+approximation) lookahead.  This type of lookahead is very cheap to\r
+compute and is attempted before full LL(k) lookahead, which is of\r
+exponential complexity in the worst case.  In general, the compressed\r
+lookahead can be much deeper (e.g, \f(CW-ck 10\fP) than the full\r
+lookahead (which usually must be less than 4).\r
+.IP \fB-CC\fP\r
+Generate C++ output from both ANTLR and DLG.\r
+.IP \fB-cr\fP\r
+Generate a cross-reference for all rules.  For each rule, print a list\r
+of all other rules that reference it.\r
+.IP \fB-e1\fP\r
+Ambiguities/errors shown in low detail (default).\r
+.IP \fB-e2\fP\r
+Ambiguities/errors shown in more detail.\r
+.IP \fB-e3\fP\r
+Ambiguities/errors shown in excruciating detail.\r
+.IP "\fB-fe\fP file"\r
+Rename \fBerr.c\fP to file.\r
+.IP "\fB-fh\fP file"\r
+Rename \fBstdpccts.h\fP header (turns on \fB-gh\fP) to file.\r
+.IP "\fB-fl\fP file"\r
+Rename lexical output, \fBparser.dlg\fP, to file.\r
+.IP "\fB-fm\fP file"\r
+Rename file with lexical mode definitions, \fBmode.h\fP, to file.\r
+.IP "\fB-fr\fP file"\r
+Rename file which remaps globally visible symbols, \fBremap.h\fP, to file.\r
+.IP "\fB-ft\fP file"\r
+Rename \fBtokens.h\fP to file.\r
+.IP \fB-ga\fP\r
+Generate ANSI-compatible code (default case).  This has not been\r
+rigorously tested to be ANSI XJ11 C compliant, but it is close.  The\r
+normal output of \fIantlr\fP is currently compilable under both K&R,\r
+ANSI C, and C++\(emthis option does nothing because \fIantlr\fP\r
+generates a bunch of #ifdef's to do the right thing depending on the\r
+language.\r
+.IP \fB-gc\fP\r
+Indicates that \fIantlr\fP should generate no C code, i.e., only\r
+perform analysis on the grammar.\r
+.IP \fB-gd\fP\r
+C code is inserted in each of the \fIantlr\fR generated parsing functions to\r
+provide for user-defined handling of a detailed parse trace.  The inserted\r
+code consists of calls to the user-supplied macros or functions called\r
+\fBzzTRACEIN\fR and \fBzzTRACEOUT\fP.  The only argument is a\r
+\fIchar *\fR pointing to a C-style string which is the grammar rule\r
+recognized by the current parsing function.  If no definition is given\r
+for the trace functions, upon rule entry and exit, a message will be\r
+printed indicating that a particular rule as been entered or exited.\r
+.IP \fB-ge\fP\r
+Generate an error class for each non-terminal.\r
+.IP \fB-gh\fP\r
+Generate \fBstdpccts.h\fP for non-ANTLR-generated files to include.\r
+This file contains all defines needed to describe the type of parser\r
+generated by \fIantlr\fP (e.g. how much lookahead is used and whether\r
+or not trees are constructed) and contains the \fBheader\fP action\r
+specified by the user.\r
+.IP \fB-gk\fP\r
+Generate parsers that delay lookahead fetches until needed.  Without\r
+this option, \fIantlr\fP generates parsers which always have \fIk\fP\r
+tokens of lookahead available.\r
+.IP \fB-gl\fP\r
+Generate line info about grammar actions in C parser of the form\r
+\fB#\ \fIline\fP\ "\fIfile\fP"\fR which makes error messages from\r
+the C/C++ compiler make more sense as they will \*Qpoint\*U into the\r
+grammar file not the resulting C file.  Debugging is easier as well,\r
+because you will step through the grammar not C file.\r
+.IP \fB-gs\fR\r
+Do not generate sets for token expression lists; instead generate a\r
+\fB||\fP-separated sequence of \fBLA(1)==\fItoken_number\fR.  The\r
+default is to generate sets.\r
+.IP \fB-gt\fP\r
+Generate code for Abstract-Syntax Trees.\r
+.IP \fB-gx\fP\r
+Do not create the lexical analyzer files (dlg-related).  This option\r
+should be given when the user wishes to provide a customized lexical\r
+analyzer.  It may also be used in \fImake\fR scripts to cause only the\r
+parser to be rebuilt when a change not affecting the lexical structure\r
+is made to the input grammars.\r
+.IP "\fB-k \fIn\fR"\r
+Set k of LL(k) to \fIn\fR; i.e. set tokens of look-ahead (default==1).\r
+.IP "\fB-o\fP dir\r
+Directory where output files should go (default=".").  This is very\r
+nice for keeping the source directory clear of ANTLR and DLG spawn.\r
+.IP \fB-p\fP\r
+The complete grammar, collected from all input grammar files and\r
+stripped of all comments and embedded actions, is listed to\r
+\fBstdout\fP.  This is intended to aid in viewing the entire grammar\r
+as a whole and to eliminate the need to keep actions concisely stated\r
+so that the grammar is easier to read.  Hence, it is preferable to\r
+embed even complex actions directly in the grammar, rather than to\r
+call them as subroutines, since the subroutine call overhead will be\r
+saved.\r
+.IP \fB-pa\fP\r
+This option is the same as \fB-p\fP except that the output is\r
+annotated with the first sets determined from grammar analysis.\r
+.IP "\fB-prc on\fR\r
+Turn on the computation and hoisting of predicate context.\r
+.IP "\fB-prc off\fR\r
+Turn off the computation and hoisting of predicate context.  This\r
+option makes 1.10 behave like the 1.06 release with option \fB-pr\fR\r
+on.  Context computation is off by default.\r
+.IP "\fB-rl \fIn\fR\r
+Limit the maximum number of tree nodes used by grammar analysis to\r
+\fIn\fP.  Occasionally, \fIantlr\fP is unable to analyze a grammar\r
+submitted by the user.  This rare situation can only occur when the\r
+grammar is large and the amount of lookahead is greater than one.  A\r
+nonlinear analysis algorithm is used by PCCTS to handle the general\r
+case of LL(k) parsing.  The average complexity of analysis, however, is\r
+near linear due to some fancy footwork in the implementation which\r
+reduces the number of calls to the full LL(k) algorithm.  An error\r
+message will be displayed, if this limit is reached, which indicates\r
+the grammar construct being analyzed when \fIantlr\fP hit a\r
+non-linearity.  Use this option if \fIantlr\fP seems to go out to\r
+lunch and your disk start thrashing; try \fIn\fP=10000 to start.  Once\r
+the offending construct has been identified, try to remove the\r
+ambiguity that \fIantlr\fP was trying to overcome with large lookahead\r
+analysis.  The introduction of (...)? backtracking blocks eliminates\r
+some of these problems\ \(em \fIantlr\fP does not analyze alternatives\r
+that begin with (...)? (it simply backtracks, if necessary, at run\r
+time).\r
+.IP \fB-w1\fR\r
+Set low warning level.  Do not warn if semantic predicates and/or\r
+(...)? blocks are assumed to cover ambiguous alternatives.\r
+.IP \fB-w2\fR\r
+Ambiguous parsing decisions yield warnings even if semantic predicates\r
+or (...)? blocks are used.  Warn if predicate context computed and\r
+semantic predicates incompletely disambiguate alternative productions.\r
+.IP \fB-\fR\r
+Read grammar from standard input and generate \fBstdin.c\fP as the\r
+parser file.\r
+.SH "SPECIAL CONSIDERATIONS"\r
+.PP\r
+\fIAntlr\fP works...  we think.  There is no implicit guarantee of\r
+anything.  We reserve no \fBlegal\fP rights to the software known as\r
+the Purdue Compiler Construction Tool Set (PCCTS) \(em PCCTS is in the\r
+public domain.  An individual or company may do whatever they wish\r
+with source code distributed with PCCTS or the code generated by\r
+PCCTS, including the incorporation of PCCTS, or its output, into\r
+commercial software.  We encourage users to develop software with\r
+PCCTS.  However, we do ask that credit is given to us for developing\r
+PCCTS.  By "credit", we mean that if you incorporate our source code\r
+into one of your programs (commercial product, research project, or\r
+otherwise) that you acknowledge this fact somewhere in the\r
+documentation, research report, etc...  If you like PCCTS and have\r
+developed a nice tool with the output, please mention that you\r
+developed it using PCCTS.  As long as these guidelines are followed,\r
+we expect to continue enhancing this system and expect to make other\r
+tools available as they are completed.\r
+.SH FILES\r
+.IP *.c\r
+output C parser.\r
+.IP *.cpp\r
+output C++ parser when C++ mode is used.\r
+.IP \fBparser.dlg\fP\r
+output \fIdlg\fR lexical analyzer.\r
+.IP \fBerr.c\fP\r
+token string array, error sets and error support routines.  Not used in\r
+C++ mode.\r
+.IP \fBremap.h\fP\r
+file that redefines all globally visible parser symbols.  The use of\r
+the #parser directive creates this file.  Not used in\r
+C++ mode.\r
+.IP \fBstdpccts.h\fP\r
+list of definitions needed by C files, not generated by PCCTS, that\r
+reference PCCTS objects.  This is not generated by default.  Not used in\r
+C++ mode.\r
+.IP \fBtokens.h\fP\r
+output \fI#defines\fR for tokens used and function prototypes for\r
+functions generated for rules.\r
+.SH "SEE ALSO"\r
+.LP\r
+dlg(1), pccts(1)\r
diff --git a/Tools/CodeTools/Source/Pccts/antlr/antlr.c b/Tools/CodeTools/Source/Pccts/antlr/antlr.c
new file mode 100644 (file)
index 0000000..8aaef79
--- /dev/null
@@ -0,0 +1,3564 @@
+/*\r
+ * A n t l r  T r a n s l a t i o n  H e a d e r\r
+ *\r
+ * Terence Parr, Will Cohen, and Hank Dietz: 1989-2001\r
+ * Purdue University Electrical Engineering\r
+ * With AHPCRC, University of Minnesota\r
+ * ANTLR Version 1.33MR33\r
+ *\r
+ *   ..\bin\antlr -gh antlr.g\r
+ *\r
+ */\r
+\r
+#define ANTLR_VERSION  13333\r
+#include "pcctscfg.h"\r
+#include "pccts_stdio.h"\r
+\r
+#include "pcctscfg.h"\r
+#include "set.h"\r
+#include <ctype.h>\r
+#include "syn.h"\r
+#include "hash.h"\r
+#include "generic.h"\r
+#define zzcr_attr(attr,tok,t)\r
+#define zzSET_SIZE 20\r
+#include "antlr.h"\r
+#include "tokens.h"\r
+#include "dlgdef.h"\r
+#include "mode.h"\r
+\r
+/* MR23 In order to remove calls to PURIFY use the antlr -nopurify option */\r
+\r
+#ifndef PCCTS_PURIFY\r
+#define PCCTS_PURIFY(r,s) memset((char *) &(r),'\0',(s));\r
+#endif\r
+\r
+ANTLR_INFO\r
+\r
+\r
+/* MR20 G. Hobbelt For Borland C++ 4.x & 5.x compiling with ALL warnings enabled */\r
+#if defined(__TURBOC__)\r
+#pragma warn -aus  /* unused assignment of 'xxx' */\r
+#endif\r
+\r
+\r
+#ifdef __USE_PROTOS\r
+static void chkToken(char *, char *, char *, int);\r
+#else\r
+static void chkToken();\r
+#endif\r
+\r
+#ifdef __USE_PROTOS\r
+static int isDLGmaxToken(char *Token);                              /* MR3 */\r
+#else\r
+static int isDLGmaxToken();                                                         /* MR3 */\r
+#endif\r
+\r
+static int class_nest_level = 0;\r
+\r
+/* MR20 G. Hobbelt extern definitions moved to antlr.h */\r
+\r
+  \r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+grammar(void)\r
+#else\r
+grammar()\r
+#endif\r
+{\r
+  zzRULE;\r
+  zzBLOCK(zztasp1);\r
+  zzMake0;\r
+  {\r
+  Graph g;\r
+  {\r
+    zzBLOCK(zztasp2);\r
+    zzMake0;\r
+    {\r
+    for (;;) {\r
+      if ( !((setwd1[LA(1)]&0x1))) break;\r
+      if ( (LA(1)==94) ) {\r
+        zzmatch(94); zzCONSUME;\r
+        zzmatch(Action);\r
+        \r
+        if ( HdrAction==NULL ) {\r
+          HdrAction = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));\r
+          require(HdrAction!=NULL, "rule grammar: cannot allocate header action");\r
+          strcpy(HdrAction, LATEXT(1));\r
+        }\r
+        else warn("additional #header statement ignored");\r
+ zzCONSUME;\r
+\r
+      }\r
+      else {\r
+        if ( (LA(1)==95) ) {\r
+          zzmatch(95); zzCONSUME;\r
+          zzmatch(Action);\r
+          \r
+          if ( FirstAction==NULL ) {\r
+            FirstAction = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));\r
+            require(FirstAction!=NULL, "rule grammar: cannot allocate #first action");\r
+            strcpy(FirstAction, LATEXT(1));\r
+          } else {\r
+            warn("additional #first statement ignored");\r
+          };\r
+ zzCONSUME;\r
+\r
+        }\r
+        else {\r
+          if ( (LA(1)==96) ) {\r
+            zzmatch(96); zzCONSUME;\r
+            zzmatch(QuotedTerm);\r
+            \r
+            if ( GenCC ) {\r
+              warn("#parser meta-op incompatible with -CC; ignored");\r
+            }\r
+            else {\r
+              if ( strcmp(ParserName,"zzparser")==0 ) {\r
+                ParserName=StripQuotes(mystrdup(LATEXT(1)));\r
+                if ( RulePrefix[0]!='\0' )\r
+                {\r
+                  warn("#parser meta-op incompatible with '-gp prefix'; '-gp' ignored");\r
+                  RulePrefix[0]='\0';\r
+                }\r
+              }\r
+              else warn("additional #parser statement ignored");\r
+            }\r
+ zzCONSUME;\r
+\r
+          }\r
+          else {\r
+            if ( (LA(1)==97) ) {\r
+              zzmatch(97); zzCONSUME;\r
+              zzmatch(QuotedTerm);\r
+              {\r
+                char *fname;\r
+                zzantlr_state st; FILE *f; struct zzdlg_state dst;\r
+                UserTokenDefsFile = mystrdup(LATEXT(1));\r
+                zzsave_antlr_state(&st);\r
+                zzsave_dlg_state(&dst);\r
+                fname = mystrdup(LATEXT(1));\r
+                f = fopen(StripQuotes(fname), "r");\r
+                if ( f==NULL ) {warn(eMsg1("cannot open token defs file '%s'", fname+1));}\r
+                else {\r
+                  ANTLRm(enum_file(fname+1), f, PARSE_ENUM_FILE);\r
+                  UserDefdTokens = 1;\r
+                }\r
+                zzrestore_antlr_state(&st);\r
+                zzrestore_dlg_state(&dst);\r
+              }\r
+ zzCONSUME;\r
+\r
+            }\r
+            else break; /* MR6 code for exiting loop "for sure" */\r
+          }\r
+        }\r
+      }\r
+      zzLOOP(zztasp2);\r
+    }\r
+    zzEXIT(zztasp2);\r
+    }\r
+  }\r
+  {\r
+    zzBLOCK(zztasp2);\r
+    zzMake0;\r
+    {\r
+    for (;;) {\r
+      if ( !((setwd1[LA(1)]&0x2))) break;\r
+      if ( (LA(1)==Action) ) {\r
+        zzmatch(Action);\r
+        {\r
+          UserAction *ua = newUserAction(LATEXT(1));\r
+          ua->file = action_file; ua->line = action_line;\r
+          if ( class_nest_level>0 ) list_add(&class_before_actions, ua);\r
+          else list_add(&BeforeActions, ua);\r
+        }\r
+ zzCONSUME;\r
+\r
+      }\r
+      else {\r
+        if ( (LA(1)==108) ) {\r
+          laction();\r
+        }\r
+        else {\r
+          if ( (LA(1)==109) ) {\r
+            lmember();\r
+          }\r
+          else {\r
+            if ( (LA(1)==110) ) {\r
+              lprefix();\r
+            }\r
+            else {\r
+              if ( (LA(1)==116) ) {\r
+                aLexclass();\r
+              }\r
+              else {\r
+                if ( (LA(1)==120) ) {\r
+                  token();\r
+                }\r
+                else {\r
+                  if ( (LA(1)==117) ) {\r
+                    error();\r
+                  }\r
+                  else {\r
+                    if ( (LA(1)==118) ) {\r
+                      tclass();\r
+                    }\r
+                    else {\r
+                      if ( (LA(1)==111) ) {\r
+                        aPred();\r
+                      }\r
+                      else {\r
+                        if ( (LA(1)==133) ) {\r
+                          default_exception_handler();\r
+                        }\r
+                        else {\r
+                          if ( (LA(1)==99) ) {\r
+                            class_def();\r
+                          }\r
+                          else {\r
+                            if ( (LA(1)==98) ) {\r
+                              zzmatch(98);\r
+                              \r
+                              if ( class_nest_level==0 )\r
+                              warn("missing class definition for trailing '}'");\r
+                              class_nest_level--;\r
+ zzCONSUME;\r
+\r
+                            }\r
+                            else break; /* MR6 code for exiting loop "for sure" */\r
+                          }\r
+                        }\r
+                      }\r
+                    }\r
+                  }\r
+                }\r
+              }\r
+            }\r
+          }\r
+        }\r
+      }\r
+      zzLOOP(zztasp2);\r
+    }\r
+    zzEXIT(zztasp2);\r
+    }\r
+  }\r
+  rule();\r
+  g=zzaArg(zztasp1,3); SynDiag = (Junction *) zzaArg(zztasp1,3 ).left;\r
+  {\r
+    zzBLOCK(zztasp2);\r
+    zzMake0;\r
+    {\r
+    for (;;) {\r
+      if ( !((setwd1[LA(1)]&0x4))) break;\r
+      if ( (LA(1)==NonTerminal) ) {\r
+        rule();\r
+        if ( zzaArg(zztasp2,1 ).left!=NULL ) {\r
+          g.right = NULL;\r
+          \r
+/* MR21a */             /*  Avoid use of a malformed graph when CannotContinue */\r
+          /* MR21a */             /*  is already set                                     */\r
+          /* MR21a */\r
+          /* MR21a */             if (! (CannotContinue && g.left == NULL)) {\r
+            /* MR21a */               g = Or(g, zzaArg(zztasp2,1));\r
+            /* MR21a */             }\r
+          /* MR21a */                }\r
+      }\r
+      else {\r
+        if ( (LA(1)==116) ) {\r
+          aLexclass();\r
+        }\r
+        else {\r
+          if ( (LA(1)==120) ) {\r
+            token();\r
+          }\r
+          else {\r
+            if ( (LA(1)==117) ) {\r
+              error();\r
+            }\r
+            else {\r
+              if ( (LA(1)==118) ) {\r
+                tclass();\r
+              }\r
+              else {\r
+                if ( (LA(1)==111) ) {\r
+                  aPred();\r
+                }\r
+                else {\r
+                  if ( (LA(1)==99) ) {\r
+                    class_def();\r
+                  }\r
+                  else {\r
+                    if ( (LA(1)==98) ) {\r
+                      zzmatch(98);\r
+                      \r
+                      if ( class_nest_level==0 )\r
+                      warn("missing class definition for trailing '}'");\r
+                      class_nest_level--;\r
+ zzCONSUME;\r
+\r
+                    }\r
+                    else break; /* MR6 code for exiting loop "for sure" */\r
+                  }\r
+                }\r
+              }\r
+            }\r
+          }\r
+        }\r
+      }\r
+      zzLOOP(zztasp2);\r
+    }\r
+    zzEXIT(zztasp2);\r
+    }\r
+  }\r
+  {\r
+    zzBLOCK(zztasp2);\r
+    zzMake0;\r
+    {\r
+    for (;;) {\r
+      if ( !((setwd1[LA(1)]&0x8))) break;\r
+      if ( (LA(1)==Action) ) {\r
+        zzmatch(Action);\r
+        {\r
+          UserAction *ua = newUserAction(LATEXT(1));\r
+          ua->file = action_file; ua->line = action_line;\r
+          if ( class_nest_level>0 ) list_add(&class_after_actions, ua);\r
+          else list_add(&AfterActions, ua);\r
+        }\r
+ zzCONSUME;\r
+\r
+      }\r
+      else {\r
+        if ( (LA(1)==108) ) {\r
+          laction();\r
+        }\r
+        else {\r
+          if ( (LA(1)==109) ) {\r
+            lmember();\r
+          }\r
+          else {\r
+            if ( (LA(1)==110) ) {\r
+              lprefix();\r
+            }\r
+            else {\r
+              if ( (LA(1)==117) ) {\r
+                error();\r
+              }\r
+              else {\r
+                if ( (LA(1)==118) ) {\r
+                  tclass();\r
+                }\r
+                else {\r
+                  if ( (LA(1)==99) ) {\r
+                    class_def();\r
+                  }\r
+                  else {\r
+                    if ( (LA(1)==111) ) {\r
+                      aPred();\r
+                    }\r
+                    else {\r
+                      if ( (LA(1)==98) ) {\r
+                        zzmatch(98);\r
+                        \r
+                        if ( class_nest_level==0 )\r
+                        warn("missing class definition for trailing '}'");\r
+                        class_nest_level--;\r
+ zzCONSUME;\r
+\r
+                      }\r
+                      else break; /* MR6 code for exiting loop "for sure" */\r
+                    }\r
+                  }\r
+                }\r
+              }\r
+            }\r
+          }\r
+        }\r
+      }\r
+      zzLOOP(zztasp2);\r
+    }\r
+    zzEXIT(zztasp2);\r
+    }\r
+  }\r
+  zzmatch(Eof); zzCONSUME;\r
+  zzEXIT(zztasp1);\r
+  return;\r
+fail:\r
+  zzEXIT(zztasp1);\r
+  CannotContinue=TRUE;  \r
+  zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);\r
+  zzresynch(setwd1, 0x10);\r
+  }\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+class_def(void)\r
+#else\r
+class_def()\r
+#endif\r
+{\r
+  zzRULE;\r
+  zzBLOCK(zztasp1);\r
+  zzMake0;\r
+  {\r
+  int go=1; char name[MaxRuleName+1];\r
+  zzmatch(99); zzCONSUME;\r
+  {\r
+    zzBLOCK(zztasp2);\r
+    zzMake0;\r
+    {\r
+    if ( (LA(1)==NonTerminal) ) {\r
+      zzmatch(NonTerminal);\r
+      if(go) strncpy(name,LATEXT(1),MaxRuleName);\r
+ zzCONSUME;\r
+\r
+    }\r
+    else {\r
+      if ( (LA(1)==TokenTerm) ) {\r
+        zzmatch(TokenTerm);\r
+        if(go) strncpy(name,LATEXT(1),MaxRuleName);\r
+ zzCONSUME;\r
+\r
+      }\r
+      else {zzFAIL(1,zzerr1,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
+    }\r
+    zzEXIT(zztasp2);\r
+    }\r
+  }\r
+  \r
+  if ( CurrentClassName[0]!='\0' && strcmp(CurrentClassName,name)!=0\r
+  && GenCC ) {\r
+    err("only one grammar class allowed in this release");\r
+    go = 0;\r
+  }\r
+  else strcpy(CurrentClassName, name);\r
+  if ( !GenCC ) { err("class meta-op used without C++ option"); }\r
+  {\r
+    zzBLOCK(zztasp2);\r
+    zzMake0;\r
+    {\r
+    while ( (setwd1[LA(1)]&0x20) ) {\r
+      zzsetmatch(zzerr2, zzerr3);\r
+      if (ClassDeclStuff == NULL) {\r
+        /* MR10 */                   ClassDeclStuff=(char *)calloc(MaxClassDeclStuff+1,sizeof(char));\r
+        /* MR10 */              };\r
+      /* MR10 */              strncat(ClassDeclStuff," ",MaxClassDeclStuff);\r
+      /* MR10 */              strncat(ClassDeclStuff,LATEXT(1),MaxClassDeclStuff);\r
+      /* MR22 */              do {\r
+        /* MR22 */                if (0 == strcmp(LATEXT(1),"public")) break;\r
+        /* MR22 */                if (0 == strcmp(LATEXT(1),"private")) break;\r
+        /* MR22 */                if (0 == strcmp(LATEXT(1),"protected")) break;\r
+        /* MR22 */                if (0 == strcmp(LATEXT(1),"virtual")) break;\r
+        /* MR22 */                if (0 == strcmp(LATEXT(1),",")) break;\r
+        /* MR22 */                if (0 == strcmp(LATEXT(1),":")) break;\r
+        /* MR22 */                if (BaseClassName != NULL) break;\r
+        /* MR22 */                BaseClassName=(char *)calloc(strlen(LATEXT(1))+1,sizeof(char));\r
+        /* MR22 */                require(BaseClassName!=NULL, "rule grammar: cannot allocate base class name");\r
+        /* MR22 */                               strcpy(BaseClassName,LATEXT(1));\r
+        /* MR22 */              } while (0);\r
+      /* MR10 */\r
+ zzCONSUME;\r
+\r
+      zzLOOP(zztasp2);\r
+    }\r
+    zzEXIT(zztasp2);\r
+    }\r
+  }\r
+  zzmatch(102);\r
+  \r
+  no_classes_found = 0;\r
+  if ( class_nest_level>=1 ) {warn("cannot have nested classes");}\r
+  else class_nest_level++;\r
+ zzCONSUME;\r
+\r
+  zzEXIT(zztasp1);\r
+  return;\r
+fail:\r
+  zzEXIT(zztasp1);\r
+  CannotContinue=TRUE;  \r
+  zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);\r
+  zzresynch(setwd1, 0x40);\r
+  }\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+rule(void)\r
+#else\r
+rule()\r
+#endif\r
+{\r
+  zzRULE;\r
+  zzBLOCK(zztasp1);\r
+  zzMake0;\r
+  {\r
+  \r
+  \r
+                       ExceptionGroup *eg;\r
+  RuleEntry *q; Junction *p; Graph r; int f, l; ECnode *e;\r
+  set toksrefd, rulesrefd;\r
+  char *pdecl=NULL, *ret=NULL, *a; CurRetDef = CurParmDef = NULL;\r
+  CurExGroups = NULL;\r
+  CurElementLabels = NULL;\r
+  CurAstLabelsInActions = NULL; /* MR27 */\r
+  /* We want a new element label hash table for each rule */\r
+  if ( Elabel!=NULL ) killHashTable(Elabel);\r
+  Elabel = newHashTable();\r
+  attribsRefdFromAction = empty;\r
+  zzmatch(NonTerminal);\r
+  q=NULL;\r
+  if ( hash_get(Rname, LATEXT(1))!=NULL ) {\r
+    err(eMsg1("duplicate rule definition: '%s'",LATEXT(1)));\r
+    CannotContinue=TRUE;\r
+  }\r
+  else\r
+  {\r
+    q = (RuleEntry *)hash_add(Rname,\r
+    LATEXT(1),\r
+    (Entry *)newRuleEntry(LATEXT(1)));\r
+    CurRule = q->str;\r
+  }\r
+  CurRuleNode = q;\r
+  f = CurFile; l = zzline;\r
+  NumRules++;\r
+ zzCONSUME;\r
+\r
+  {\r
+    zzBLOCK(zztasp2);\r
+    zzMake0;\r
+    {\r
+    if ( (LA(1)==103) ) {\r
+      zzmatch(103);\r
+      if ( q!=NULL ) q->noAST = TRUE;\r
+ zzCONSUME;\r
+\r
+    }\r
+    else {\r
+      if ( (setwd1[LA(1)]&0x80) ) {\r
+      }\r
+      else {zzFAIL(1,zzerr4,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
+    }\r
+    zzEXIT(zztasp2);\r
+    }\r
+  }\r
+  {\r
+    zzBLOCK(zztasp2);\r
+    zzMake0;\r
+    {\r
+    ;\r
+    if ( (setwd2[LA(1)]&0x1) ) {\r
+      {\r
+        zzBLOCK(zztasp3);\r
+        zzMake0;\r
+        {\r
+        if ( (LA(1)==104) ) {\r
+          zzmatch(104); zzCONSUME;\r
+        }\r
+        else {\r
+          if ( (LA(1)==PassAction) ) {\r
+          }\r
+          else {zzFAIL(1,zzerr5,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
+        }\r
+        zzEXIT(zztasp3);\r
+        }\r
+      }\r
+      zzmatch(PassAction);\r
+      pdecl = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));\r
+      require(pdecl!=NULL, "rule rule: cannot allocate param decl");\r
+      strcpy(pdecl, LATEXT(1));\r
+      CurParmDef = pdecl;\r
+ zzCONSUME;\r
+\r
+    }\r
+    else {\r
+      if ( (setwd2[LA(1)]&0x2) ) {\r
+      }\r
+      else {zzFAIL(1,zzerr6,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
+    }\r
+    zzEXIT(zztasp2);\r
+    }\r
+  }\r
+  {\r
+    zzBLOCK(zztasp2);\r
+    zzMake0;\r
+    {\r
+    if ( (LA(1)==105) ) {\r
+      zzmatch(105); zzCONSUME;\r
+      zzmatch(PassAction);\r
+      ret = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));\r
+      require(ret!=NULL, "rule rule: cannot allocate ret type");\r
+      strcpy(ret, LATEXT(1));\r
+      CurRetDef = ret;\r
+ zzCONSUME;\r
+\r
+    }\r
+    else {\r
+      if ( (setwd2[LA(1)]&0x4) ) {\r
+      }\r
+      else {zzFAIL(1,zzerr7,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
+    }\r
+    zzEXIT(zztasp2);\r
+    }\r
+  }\r
+  {\r
+    zzBLOCK(zztasp2);\r
+    zzMake0;\r
+    {\r
+    if ( (LA(1)==QuotedTerm) ) {\r
+      zzmatch(QuotedTerm);\r
+      if ( q!=NULL ) q->egroup=mystrdup(LATEXT(1));\r
+ zzCONSUME;\r
+\r
+    }\r
+    else {\r
+      if ( (LA(1)==106) ) {\r
+      }\r
+      else {zzFAIL(1,zzerr8,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
+    }\r
+    zzEXIT(zztasp2);\r
+    }\r
+  }\r
+  \r
+  if ( GenEClasseForRules && q!=NULL ) {\r
+    e = newECnode;\r
+    require(e!=NULL, "cannot allocate error class node");\r
+    if ( q->egroup == NULL ) {a = q->str; a[0] = (char)toupper(a[0]);}\r
+    else a = q->egroup;\r
+    if ( Tnum( a ) == 0 )\r
+    {\r
+      e->tok = addTname( a );\r
+      list_add(&eclasses, (char *)e);\r
+      if ( q->egroup == NULL ) a[0] = (char)tolower(a[0]);\r
+      /* refers to itself */\r
+      list_add(&(e->elist), mystrdup(q->str));\r
+    }\r
+    else {\r
+      warn(eMsg1("default errclass for '%s' would conflict with token/errclass/tokclass",a));\r
+      if ( q->egroup == NULL ) a[0] = (char)tolower(a[0]);\r
+      free((char *)e);\r
+    }\r
+  }\r
+  BlkLevel++;\r
+  if (BlkLevel >= MAX_BLK_LEVEL) fatal("Blocks nested too deeply");\r
+  /* MR23 */    CurBlockID_array[BlkLevel] = CurBlockID;\r
+  /* MR23 */    CurAltNum_array[BlkLevel] = CurAltNum;\r
+  zzmatch(106);\r
+  inAlt=1;\r
+ zzCONSUME;\r
+\r
+  block( &toksrefd, &rulesrefd );\r
+  r = makeBlk(zzaArg(zztasp1,7),0, NULL /* pFirstSetSymbol */ );\r
+  CurRuleBlk = (Junction *)r.left;\r
+  CurRuleBlk->blockid = CurBlockID;\r
+  CurRuleBlk->jtype = RuleBlk;\r
+  if ( q!=NULL ) CurRuleBlk->rname = q->str;\r
+  CurRuleBlk->file = f;\r
+  CurRuleBlk->line = l;\r
+  CurRuleBlk->pdecl = pdecl;\r
+  CurRuleBlk->ret = ret;\r
+  CurRuleBlk->lock = makelocks();\r
+  CurRuleBlk->pred_lock = makelocks();\r
+  CurRuleBlk->tokrefs = toksrefd;\r
+  CurRuleBlk->rulerefs = rulesrefd;\r
+  p = newJunction();   /* add EndRule Node */\r
+  ((Junction *)r.right)->p1 = (Node *)p;\r
+  r.right = (Node *) p;\r
+  p->jtype = EndRule;\r
+  p->lock = makelocks();\r
+  p->pred_lock = makelocks();\r
+  CurRuleBlk->end = p;\r
+  if ( q!=NULL ) q->rulenum = NumRules;\r
+  zzaArg(zztasp1,7) = r;\r
+  \r
+  /* MR23 */      CurBlockID_array[BlkLevel] = (-1);\r
+  /* MR23 */      CurAltNum_array[BlkLevel] = (-1);                \r
+  --BlkLevel;\r
+  altFixup();leFixup();egFixup();\r
+  zzmatch(107);\r
+  inAlt=0;\r
+ zzCONSUME;\r
+\r
+  {\r
+    zzBLOCK(zztasp2);\r
+    zzMake0;\r
+    {\r
+    if ( (LA(1)==Action) ) {\r
+      zzmatch(Action);\r
+      a = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));\r
+      require(a!=NULL, "rule rule: cannot allocate error action");\r
+      strcpy(a, LATEXT(1));\r
+      CurRuleBlk->erraction = a;\r
+ zzCONSUME;\r
+\r
+    }\r
+    else {\r
+      if ( (setwd2[LA(1)]&0x8) ) {\r
+      }\r
+      else {zzFAIL(1,zzerr9,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
+    }\r
+    zzEXIT(zztasp2);\r
+    }\r
+  }\r
+  {\r
+    zzBLOCK(zztasp2);\r
+    zzMake0;\r
+    {\r
+    while ( (LA(1)==133) ) {\r
+       eg  = exception_group();\r
+\r
+      if ( eg!=NULL ) {\r
+        list_add(&CurExGroups, (void *)eg);\r
+        if (eg->label == NULL || *eg->label=='\0' ) q->has_rule_exception = 1;\r
+      }\r
+      zzLOOP(zztasp2);\r
+    }\r
+    zzEXIT(zztasp2);\r
+    }\r
+  }\r
+  if ( q==NULL ) zzaArg(zztasp1,0 ).left = NULL; else zzaArg(zztasp1,0) = zzaArg(zztasp1,7);\r
+  CurRuleBlk->exceptions = CurExGroups;\r
+  CurRuleBlk->el_labels = CurElementLabels;\r
+  CurRuleNode->ast_labels_in_actions = CurAstLabelsInActions;\r
+  CurRuleNode = NULL;\r
+  zzEXIT(zztasp1);\r
+  return;\r
+fail:\r
+  zzEXIT(zztasp1);\r
+  CannotContinue=TRUE;  \r
+  zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);\r
+  zzresynch(setwd2, 0x10);\r
+  }\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+laction(void)\r
+#else\r
+laction()\r
+#endif\r
+{\r
+  zzRULE;\r
+  zzBLOCK(zztasp1);\r
+  zzMake0;\r
+  {\r
+  char *a;\r
+  zzmatch(108); zzCONSUME;\r
+  zzmatch(Action);\r
+  \r
+  a = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));\r
+  require(a!=NULL, "rule laction: cannot allocate action");\r
+  strcpy(a, LATEXT(1));\r
+  list_add(&LexActions, a);\r
+ zzCONSUME;\r
+\r
+  zzEXIT(zztasp1);\r
+  return;\r
+fail:\r
+  zzEXIT(zztasp1);\r
+  CannotContinue=TRUE;  \r
+  zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);\r
+  zzresynch(setwd2, 0x20);\r
+  }\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+lmember(void)\r
+#else\r
+lmember()\r
+#endif\r
+{\r
+  zzRULE;\r
+  zzBLOCK(zztasp1);\r
+  zzMake0;\r
+  {\r
+  char *a;\r
+  zzmatch(109); zzCONSUME;\r
+  zzmatch(Action);\r
+  \r
+  /* MR1 */            if (! GenCC) {\r
+    /* MR1 */            err("Use #lexmember only in C++ mode (to insert code in DLG class header");\r
+    /* MR1 */          } else {\r
+    /* MR1 */            a = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));\r
+    /* MR1 */            require(a!=NULL, "rule lmember: cannot allocate action");\r
+    /* MR1 */            strcpy(a, LATEXT(1));\r
+    /* MR1 */            list_add(&LexMemberActions, a);\r
+    /* MR1 */          };\r
+  /* MR1 */\r
+ zzCONSUME;\r
+\r
+  zzEXIT(zztasp1);\r
+  return;\r
+fail:\r
+  zzEXIT(zztasp1);\r
+  CannotContinue=TRUE;  \r
+  zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);\r
+  zzresynch(setwd2, 0x40);\r
+  }\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+lprefix(void)\r
+#else\r
+lprefix()\r
+#endif\r
+{\r
+  zzRULE;\r
+  zzBLOCK(zztasp1);\r
+  zzMake0;\r
+  {\r
+  char *a;\r
+  zzmatch(110); zzCONSUME;\r
+  zzmatch(Action);\r
+  \r
+  /* MR1 */            if (! GenCC) {\r
+    /* MR1 */            err("Use #lexprefix only in C++ mode (to insert code in DLG class header");\r
+    /* MR1 */          } else {\r
+    /* MR1 */            a = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));\r
+    /* MR1 */            require(a!=NULL, "rule lprefix: cannot allocate action");\r
+    /* MR1 */            strcpy(a, LATEXT(1));\r
+    /* MR1 */            list_add(&LexPrefixActions, a);\r
+    /* MR1 */          };\r
+  /* MR1 */\r
+ zzCONSUME;\r
+\r
+  zzEXIT(zztasp1);\r
+  return;\r
+fail:\r
+  zzEXIT(zztasp1);\r
+  CannotContinue=TRUE;  \r
+  zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);\r
+  zzresynch(setwd2, 0x80);\r
+  }\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+aPred(void)\r
+#else\r
+aPred()\r
+#endif\r
+{\r
+  zzRULE;\r
+  zzBLOCK(zztasp1);\r
+  zzMake0;\r
+  {\r
+  PredEntry     *predEntry=NULL;\r
+  char          *name=NULL;\r
+  Predicate     *predExpr=NULL;\r
+  char          *predLiteral=NULL;\r
+  int           save_file;\r
+  int           save_line;\r
+  int           predExprPresent=0;\r
+  zzmatch(111);\r
+  \r
+  MR_usingPredNames=1;      /* will need to use -mrhoist version of genPredTree */\r
+ zzCONSUME;\r
+\r
+  zzmatch(TokenTerm);\r
+  name=mystrdup(LATEXT(1));\r
+ zzCONSUME;\r
+\r
+  \r
+  /* don't free - referenced in predicates */\r
+  \r
+            CurPredName=(char *)calloc(1,strlen(name) + 10);\r
+  strcat(CurPredName,"#pred ");\r
+  strcat(CurPredName,name);\r
+  \r
+            predEntry=(PredEntry *) hash_get(Pname,name);\r
+  if (predEntry != NULL) {\r
+  warnFL(eMsg1("#pred %s previously defined - ignored",name),\r
+  FileStr[action_file],action_line);\r
+  name=NULL;\r
+};\r
+  {\r
+    zzBLOCK(zztasp2);\r
+    zzMake0;\r
+    {\r
+    if ( (LA(1)==Pred) ) {\r
+      zzmatch(Pred);\r
+      predLiteral=mystrdup(LATEXT(1));\r
+      save_line=action_line;\r
+      save_file=action_file;\r
+ zzCONSUME;\r
+\r
+      {\r
+        zzBLOCK(zztasp3);\r
+        zzMake0;\r
+        {\r
+        if ( (setwd3[LA(1)]&0x1) ) {\r
+           predExpr  = predOrExpr();\r
+\r
+          predExprPresent=1;\r
+        }\r
+        else {\r
+          if ( (setwd3[LA(1)]&0x2) ) {\r
+          }\r
+          else {zzFAIL(1,zzerr10,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
+        }\r
+        zzEXIT(zztasp3);\r
+        }\r
+      }\r
+      if (predLiteral != NULL && name != NULL) {\r
+        \r
+                      /*\r
+        *  predExpr may be NULL due to syntax errors\r
+        *    or simply omitted by the user\r
+        */\r
+        \r
+                      predEntry=newPredEntry(name);\r
+        predEntry->file=save_file;\r
+        predEntry->line=save_line;\r
+        predExpr=MR_predFlatten(predExpr);\r
+        predEntry->predLiteral=predLiteral;\r
+        if (! predExprPresent || predExpr == NULL) {\r
+          predExpr=new_pred();\r
+          predExpr->expr=predLiteral;\r
+          predExpr->source=newActionNode();\r
+          predExpr->source->action=predExpr->expr;\r
+          predExpr->source->rname=CurPredName;\r
+          predExpr->source->line=action_line;\r
+          predExpr->source->file=action_file;\r
+          predExpr->source->is_predicate=1;\r
+          predExpr->k=predicateLookaheadDepth(predExpr->source);\r
+        };\r
+        predEntry->pred=predExpr;\r
+        hash_add(Pname,name,(Entry *)predEntry);\r
+        predExpr=NULL;\r
+      };\r
+      predicate_free(predExpr);\r
+    }\r
+    else {\r
+      if ( (setwd3[LA(1)]&0x4) ) {\r
+        save_line=zzline; save_file=CurFile;\r
+         predExpr  = predOrExpr();\r
+\r
+        if (predExpr != NULL && name != NULL) {\r
+          predEntry=newPredEntry(name);\r
+          predEntry->file=CurFile;\r
+          predEntry->line=zzline;\r
+          predExpr=MR_predFlatten(predExpr);\r
+          predEntry->pred=predExpr;\r
+          hash_add(Pname,name,(Entry *)predEntry);\r
+          predExpr=NULL;\r
+        };\r
+        predicate_free(predExpr);\r
+      }\r
+      else {zzFAIL(1,zzerr11,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
+    }\r
+    zzEXIT(zztasp2);\r
+    }\r
+  }\r
+  {\r
+    zzBLOCK(zztasp2);\r
+    zzMake0;\r
+    {\r
+    if ( (LA(1)==107) ) {\r
+      zzmatch(107); zzCONSUME;\r
+    }\r
+    else {\r
+      if ( (setwd3[LA(1)]&0x8) ) {\r
+      }\r
+      else {zzFAIL(1,zzerr12,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
+    }\r
+    zzEXIT(zztasp2);\r
+    }\r
+  }\r
+  zzEXIT(zztasp1);\r
+  return;\r
+fail:\r
+  zzEXIT(zztasp1);\r
+  predicate_free(predExpr);\r
+  zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);\r
+  zzresynch(setwd3, 0x10);\r
+  }\r
+}\r
+\r
+Predicate *\r
+#ifdef __USE_PROTOS\r
+predOrExpr(void)\r
+#else\r
+predOrExpr()\r
+#endif\r
+{\r
+  Predicate *   _retv;\r
+  zzRULE;\r
+  zzBLOCK(zztasp1);\r
+  PCCTS_PURIFY(_retv,sizeof(Predicate *  ))\r
+  zzMake0;\r
+  {\r
+  Predicate     *ORnode;\r
+  Predicate     *predExpr;\r
+  Predicate     **tail=NULL;\r
+   predExpr  = predAndExpr();\r
+\r
+  \r
+  ORnode=new_pred();\r
+  ORnode->expr=PRED_OR_LIST;\r
+  if (predExpr != NULL) {\r
+    ORnode->down=predExpr;\r
+    tail=&predExpr->right;\r
+  };\r
+  {\r
+    zzBLOCK(zztasp2);\r
+    zzMake0;\r
+    {\r
+    while ( (LA(1)==112) ) {\r
+      zzmatch(112); zzCONSUME;\r
+       predExpr  = predAndExpr();\r
+\r
+      \r
+      if (predExpr != NULL) {\r
+        *tail=predExpr;\r
+        tail=&predExpr->right;\r
+      };\r
+      zzLOOP(zztasp2);\r
+    }\r
+    zzEXIT(zztasp2);\r
+    }\r
+  }\r
+  \r
+  _retv=ORnode;\r
+  ORnode=NULL;\r
+  zzEXIT(zztasp1);\r
+  return _retv;\r
+fail:\r
+  zzEXIT(zztasp1);\r
+  predicate_free(ORnode);  \r
+  zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);\r
+  zzresynch(setwd3, 0x20);\r
+  return _retv;\r
+  }\r
+}\r
+\r
+Predicate *\r
+#ifdef __USE_PROTOS\r
+predAndExpr(void)\r
+#else\r
+predAndExpr()\r
+#endif\r
+{\r
+  Predicate *   _retv;\r
+  zzRULE;\r
+  zzBLOCK(zztasp1);\r
+  PCCTS_PURIFY(_retv,sizeof(Predicate *  ))\r
+  zzMake0;\r
+  {\r
+  Predicate     *ANDnode;\r
+  Predicate     *predExpr;\r
+  Predicate     **tail=NULL;\r
+   predExpr  = predPrimary();\r
+\r
+  \r
+  ANDnode=new_pred();\r
+  ANDnode->expr=PRED_AND_LIST;\r
+  if (predExpr != NULL) {\r
+    ANDnode->down=predExpr;\r
+    tail=&predExpr->right;\r
+  };\r
+  {\r
+    zzBLOCK(zztasp2);\r
+    zzMake0;\r
+    {\r
+    while ( (LA(1)==113) ) {\r
+      zzmatch(113); zzCONSUME;\r
+       predExpr  = predPrimary();\r
+\r
+      \r
+      if (predExpr != NULL) {\r
+        *tail=predExpr;\r
+        tail=&predExpr->right;\r
+      };\r
+      zzLOOP(zztasp2);\r
+    }\r
+    zzEXIT(zztasp2);\r
+    }\r
+  }\r
+  \r
+  _retv=ANDnode;\r
+  ANDnode=NULL;\r
+  zzEXIT(zztasp1);\r
+  return _retv;\r
+fail:\r
+  zzEXIT(zztasp1);\r
+  predicate_free(ANDnode);  \r
+  zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);\r
+  zzresynch(setwd3, 0x40);\r
+  return _retv;\r
+  }\r
+}\r
+\r
+Predicate *\r
+#ifdef __USE_PROTOS\r
+predPrimary(void)\r
+#else\r
+predPrimary()\r
+#endif\r
+{\r
+  Predicate *   _retv;\r
+  zzRULE;\r
+  zzBLOCK(zztasp1);\r
+  PCCTS_PURIFY(_retv,sizeof(Predicate *  ))\r
+  zzMake0;\r
+  {\r
+  \r
+  char          *name=NULL;\r
+  PredEntry     *predEntry=NULL;\r
+  Predicate     *predExpr=NULL;\r
+  if ( (LA(1)==TokenTerm) ) {\r
+    zzmatch(TokenTerm);\r
+    name=mystrdup(LATEXT(1));\r
+ zzCONSUME;\r
+\r
+    \r
+    predEntry=(PredEntry *) hash_get(Pname,name);\r
+    if (predEntry == NULL) {\r
+      warnFL(eMsg1("no previously defined #pred with name \"%s\"",name),\r
+      FileStr[CurFile],zzline);\r
+      name=NULL;\r
+      _retv=NULL;\r
+    } else {\r
+      predExpr=predicate_dup(predEntry->pred);\r
+      predExpr->predEntry=predEntry;\r
+      _retv=predExpr;\r
+    };\r
+  }\r
+  else {\r
+    if ( (LA(1)==114) ) {\r
+      zzmatch(114); zzCONSUME;\r
+       predExpr  = predOrExpr();\r
+\r
+      zzmatch(115);\r
+      \r
+      _retv=predExpr;\r
+ zzCONSUME;\r
+\r
+    }\r
+    else {\r
+      if ( (LA(1)==103) ) {\r
+        zzmatch(103); zzCONSUME;\r
+         predExpr  = predPrimary();\r
+\r
+        \r
+        predExpr->inverted=!predExpr->inverted;\r
+        _retv=predExpr;\r
+      }\r
+      else {zzFAIL(1,zzerr13,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
+    }\r
+  }\r
+  zzEXIT(zztasp1);\r
+  return _retv;\r
+fail:\r
+  zzEXIT(zztasp1);\r
+  \r
+  predicate_free(predExpr);\r
+  zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);\r
+  zzresynch(setwd3, 0x80);\r
+  return _retv;\r
+  }\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+aLexclass(void)\r
+#else\r
+aLexclass()\r
+#endif\r
+{\r
+  zzRULE;\r
+  zzBLOCK(zztasp1);\r
+  zzMake0;\r
+  {\r
+  zzmatch(116); zzCONSUME;\r
+  zzmatch(TokenTerm);\r
+  lexclass(mystrdup(LATEXT(1)));\r
+ zzCONSUME;\r
+\r
+  zzEXIT(zztasp1);\r
+  return;\r
+fail:\r
+  zzEXIT(zztasp1);\r
+  CannotContinue=TRUE;  \r
+  zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);\r
+  zzresynch(setwd4, 0x1);\r
+  }\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+error(void)\r
+#else\r
+error()\r
+#endif\r
+{\r
+  zzRULE;\r
+  zzBLOCK(zztasp1);\r
+  zzMake0;\r
+  {\r
+  char *t=NULL; ECnode *e; int go=1; TermEntry *p;\r
+  zzmatch(117); zzCONSUME;\r
+  {\r
+    zzBLOCK(zztasp2);\r
+    zzMake0;\r
+    {\r
+    ;\r
+    if ( (LA(1)==TokenTerm) ) {\r
+      zzmatch(TokenTerm);\r
+      t=mystrdup(LATEXT(1));\r
+ zzCONSUME;\r
+\r
+    }\r
+    else {\r
+      if ( (LA(1)==QuotedTerm) ) {\r
+        zzmatch(QuotedTerm);\r
+        t=mystrdup(LATEXT(1));\r
+ zzCONSUME;\r
+\r
+      }\r
+      else {zzFAIL(1,zzerr14,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
+    }\r
+    zzEXIT(zztasp2);\r
+    }\r
+  }\r
+  e = newECnode;\r
+  require(e!=NULL, "cannot allocate error class node");\r
+  e->lexclass = CurrentLexClass;\r
+  if ( Tnum( (t=StripQuotes(t)) ) == 0 )\r
+  {\r
+    if ( hash_get(Texpr, t) != NULL )\r
+    warn(eMsg1("errclass name conflicts with regular expression  '%s'",t));\r
+    e->tok = addTname( t );\r
+    set_orel(e->tok, &imag_tokens);\r
+    require((p=(TermEntry *)hash_get(Tname, t)) != NULL,\r
+    "hash table mechanism is broken");\r
+    p->classname = 1;  /* entry is errclass name, not token */\r
+    list_add(&eclasses, (char *)e);\r
+  }\r
+  else\r
+  {\r
+  warn(eMsg1("redefinition of errclass or conflict w/token or tokclass '%s'; ignored",t));\r
+  free( (char *)e );\r
+  go=0;\r
+}\r
+  zzmatch(102); zzCONSUME;\r
+  {\r
+    zzBLOCK(zztasp2);\r
+    zzMake0;\r
+    {\r
+    if ( (LA(1)==NonTerminal) ) {\r
+      zzmatch(NonTerminal);\r
+      if ( go ) t=mystrdup(LATEXT(1));\r
+ zzCONSUME;\r
+\r
+    }\r
+    else {\r
+      if ( (LA(1)==TokenTerm) ) {\r
+        zzmatch(TokenTerm);\r
+        if ( go ) t=mystrdup(LATEXT(1));\r
+ zzCONSUME;\r
+\r
+      }\r
+      else {\r
+        if ( (LA(1)==QuotedTerm) ) {\r
+          zzmatch(QuotedTerm);\r
+          if ( go ) t=mystrdup(LATEXT(1));\r
+ zzCONSUME;\r
+\r
+        }\r
+        else {zzFAIL(1,zzerr15,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
+      }\r
+    }\r
+    zzEXIT(zztasp2);\r
+    }\r
+  }\r
+  if ( go ) list_add(&(e->elist), t);\r
+  {\r
+    zzBLOCK(zztasp2);\r
+    zzMake0;\r
+    {\r
+    while ( (setwd4[LA(1)]&0x2) ) {\r
+      {\r
+        zzBLOCK(zztasp3);\r
+        zzMake0;\r
+        {\r
+        if ( (LA(1)==NonTerminal) ) {\r
+          zzmatch(NonTerminal);\r
+          if ( go ) t=mystrdup(LATEXT(1));\r
+ zzCONSUME;\r
+\r
+        }\r
+        else {\r
+          if ( (LA(1)==TokenTerm) ) {\r
+            zzmatch(TokenTerm);\r
+            if ( go ) t=mystrdup(LATEXT(1));\r
+ zzCONSUME;\r
+\r
+          }\r
+          else {\r
+            if ( (LA(1)==QuotedTerm) ) {\r
+              zzmatch(QuotedTerm);\r
+              if ( go ) t=mystrdup(LATEXT(1));\r
+ zzCONSUME;\r
+\r
+            }\r
+            else {zzFAIL(1,zzerr16,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
+          }\r
+        }\r
+        zzEXIT(zztasp3);\r
+        }\r
+      }\r
+      if ( go ) list_add(&(e->elist), t);\r
+      zzLOOP(zztasp2);\r
+    }\r
+    zzEXIT(zztasp2);\r
+    }\r
+  }\r
+  zzmatch(98); zzCONSUME;\r
+  zzEXIT(zztasp1);\r
+  return;\r
+fail:\r
+  zzEXIT(zztasp1);\r
+  CannotContinue=TRUE;  \r
+  zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);\r
+  zzresynch(setwd4, 0x4);\r
+  }\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+tclass(void)\r
+#else\r
+tclass()\r
+#endif\r
+{\r
+  zzRULE;\r
+  zzBLOCK(zztasp1);\r
+  zzMake0;\r
+  {\r
+  char *t=NULL; TCnode *e; int go=1,tok,totok; TermEntry *p, *term, *toterm;\r
+  char *akaString=NULL; int save_file; int save_line;\r
+  char *totext=NULL;\r
+  zzmatch(118); zzCONSUME;\r
+  zzmatch(TokenTerm);\r
+  t=mystrdup(LATEXT(1));\r
+ zzCONSUME;\r
+\r
+  e = newTCnode;\r
+  require(e!=NULL, "cannot allocate token class node");\r
+  e->lexclass = CurrentLexClass;\r
+  if ( Tnum( t ) == 0 )\r
+  {\r
+    e->tok = addTname( t );\r
+    set_orel(e->tok, &imag_tokens);\r
+    set_orel(e->tok, &tokclasses);\r
+    require((p=(TermEntry *)hash_get(Tname, t)) != NULL,\r
+    "hash table mechanism is broken");\r
+    p->classname = 1;  /* entry is class name, not token */\r
+    p->tclass = e;             /* save ptr to this tclass def */\r
+    list_add(&tclasses, (char *)e);\r
+  }\r
+  else\r
+  {\r
+  warn(eMsg1("redefinition of tokclass or conflict w/token '%s'; ignored",t));\r
+  free( (char *)e );\r
+  go=0;\r
+}\r
+  {\r
+    zzBLOCK(zztasp2);\r
+    zzMake0;\r
+    {\r
+    if ( (LA(1)==114) ) {\r
+      zzmatch(114); zzCONSUME;\r
+      zzmatch(QuotedTerm);\r
+      akaString=mystrdup(StripQuotes(LATEXT(1)));\r
+      /* MR11 */                   save_file=CurFile;save_line=zzline;\r
+      /* MR23 */\r
+ zzCONSUME;\r
+\r
+      zzmatch(115); zzCONSUME;\r
+    }\r
+    else {\r
+      if ( (LA(1)==102) ) {\r
+      }\r
+      else {zzFAIL(1,zzerr17,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
+    }\r
+    zzEXIT(zztasp2);\r
+    }\r
+  }\r
+  \r
+  /* MR23 */         if (p!= NULL && akaString != NULL) {\r
+    /* MR23 */           if (p->akaString != NULL) {\r
+      /* MR23 */             if (strcmp(p->akaString,akaString) != 0) {\r
+        /* MR23 */                warnFL(eMsg2("this #tokclass statment conflicts with a previous #tokclass %s(\"%s\") statement",\r
+        /* MR23 */                              t,p->akaString),\r
+        /* MR23 */                                         FileStr[save_file],save_line);\r
+        /* MR23 */             };\r
+      /* MR23 */            } else {\r
+      /* MR23 */              p->akaString=akaString;\r
+      /* MR23 */            };\r
+    /* MR23 */          };\r
+  /* MR23 */\r
+  zzmatch(102); zzCONSUME;\r
+  {\r
+    zzBLOCK(zztasp2);\r
+    int zzcnt=1;\r
+    zzMake0;\r
+    {\r
+    do {\r
+      {\r
+        zzBLOCK(zztasp3);\r
+        zzMake0;\r
+        {\r
+        if ( (LA(1)==TokenTerm) ) {\r
+          zzmatch(TokenTerm);\r
+          if ( go ) {\r
+            term = (TermEntry *) hash_get(Tname, LATEXT(1));\r
+            if ( term==NULL && UserDefdTokens ) {\r
+              err("implicit token definition not allowed with #tokdefs");\r
+              go = 0;\r
+            }\r
+            else {t=mystrdup(LATEXT(1)); tok=addTname(LATEXT(1));}\r
+          }\r
+ zzCONSUME;\r
+\r
+          {\r
+            zzBLOCK(zztasp4);\r
+            zzMake0;\r
+            {\r
+            if ( (LA(1)==119) ) {\r
+              zzmatch(119); zzCONSUME;\r
+              zzmatch(TokenTerm);\r
+              if ( go ) {\r
+                toterm = (TermEntry *) hash_get(Tname, LATEXT(1));\r
+                if ( toterm==NULL && UserDefdTokens ) {\r
+                  err("implicit token definition not allowed with #tokdefs");\r
+                  go = 0;\r
+                } else {\r
+                  totext=mystrdup(LATEXT(1)); totok=addTname(LATEXT(1));\r
+                }\r
+              }\r
+ zzCONSUME;\r
+\r
+            }\r
+            else {\r
+              if ( (setwd4[LA(1)]&0x8) ) {\r
+              }\r
+              else {zzFAIL(1,zzerr18,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
+            }\r
+            zzEXIT(zztasp4);\r
+            }\r
+          }\r
+        }\r
+        else {\r
+          if ( (LA(1)==QuotedTerm) ) {\r
+            zzmatch(QuotedTerm);\r
+            if ( go ) {\r
+              term = (TermEntry *) hash_get(Texpr, LATEXT(1));\r
+              if ( term==NULL && UserDefdTokens ) {\r
+                err("implicit token definition not allowed with #tokdefs");\r
+                go = 0;\r
+              }\r
+              else {t=mystrdup(LATEXT(1)); tok=addTexpr(LATEXT(1));}\r
+            }\r
+ zzCONSUME;\r
+\r
+          }\r
+          else {zzFAIL(1,zzerr19,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
+        }\r
+        zzEXIT(zztasp3);\r
+        }\r
+      }\r
+      if ( go ) {\r
+        if (totext == NULL) {\r
+          list_add(&(e->tlist), t);\r
+        } else {\r
+          list_add(&(e->tlist),"..");\r
+          list_add(&(e->tlist),t);\r
+          list_add(&(e->tlist),totext);\r
+        }\r
+        totext=NULL;\r
+      }\r
+      zzLOOP(zztasp2);\r
+    } while ( (setwd4[LA(1)]&0x10) );\r
+    zzEXIT(zztasp2);\r
+    }\r
+  }\r
+  zzmatch(98); zzCONSUME;\r
+  zzEXIT(zztasp1);\r
+  return;\r
+fail:\r
+  zzEXIT(zztasp1);\r
+  CannotContinue=TRUE;  \r
+  zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);\r
+  zzresynch(setwd4, 0x20);\r
+  }\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+token(void)\r
+#else\r
+token()\r
+#endif\r
+{\r
+  zzRULE;\r
+  zzBLOCK(zztasp1);\r
+  zzMake0;\r
+  {\r
+  char *t=NULL, *e=NULL, *a=NULL; int tnum=0;\r
+  char *akaString=NULL; TermEntry *te;int save_file=0,save_line=0;\r
+  zzmatch(120);\r
+  tokenActionActive=1;\r
+ zzCONSUME;\r
+\r
+  {\r
+    zzBLOCK(zztasp2);\r
+    zzMake0;\r
+    {\r
+    if ( (LA(1)==TokenTerm) ) {\r
+      zzmatch(TokenTerm);\r
+      t=mystrdup(LATEXT(1));\r
+ zzCONSUME;\r
+\r
+      {\r
+        zzBLOCK(zztasp3);\r
+        zzMake0;\r
+        {\r
+        if ( (LA(1)==114) ) {\r
+          zzmatch(114); zzCONSUME;\r
+          zzmatch(QuotedTerm);\r
+          akaString=mystrdup(StripQuotes(LATEXT(1)));\r
+          /* MR11 */                   save_file=CurFile;save_line=zzline;\r
+          /* MR11 */\r
+ zzCONSUME;\r
+\r
+          zzmatch(115); zzCONSUME;\r
+        }\r
+        else {\r
+          if ( (setwd4[LA(1)]&0x40) ) {\r
+          }\r
+          else {zzFAIL(1,zzerr20,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
+        }\r
+        zzEXIT(zztasp3);\r
+        }\r
+      }\r
+      {\r
+        zzBLOCK(zztasp3);\r
+        zzMake0;\r
+        {\r
+        if ( (LA(1)==121) ) {\r
+          zzmatch(121); zzCONSUME;\r
+          zzmatch(122);\r
+          tnum = atoi(LATEXT(1));\r
+ zzCONSUME;\r
+\r
+        }\r
+        else {\r
+          if ( (setwd4[LA(1)]&0x80) ) {\r
+          }\r
+          else {zzFAIL(1,zzerr21,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
+        }\r
+        zzEXIT(zztasp3);\r
+        }\r
+      }\r
+    }\r
+    else {\r
+      if ( (setwd5[LA(1)]&0x1) ) {\r
+      }\r
+      else {zzFAIL(1,zzerr22,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
+    }\r
+    zzEXIT(zztasp2);\r
+    }\r
+  }\r
+  {\r
+    zzBLOCK(zztasp2);\r
+    zzMake0;\r
+    {\r
+    if ( (LA(1)==QuotedTerm) ) {\r
+      zzmatch(QuotedTerm);\r
+      e=mystrdup(LATEXT(1));\r
+ zzCONSUME;\r
+\r
+    }\r
+    else {\r
+      if ( (setwd5[LA(1)]&0x2) ) {\r
+      }\r
+      else {zzFAIL(1,zzerr23,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
+    }\r
+    zzEXIT(zztasp2);\r
+    }\r
+  }\r
+  {\r
+    zzBLOCK(zztasp2);\r
+    zzMake0;\r
+    {\r
+    if ( (LA(1)==Action) ) {\r
+      zzmatch(Action);\r
+      \r
+      a = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));\r
+      require(a!=NULL, "rule token: cannot allocate action");\r
+      strcpy(a, LATEXT(1));\r
+ zzCONSUME;\r
+\r
+    }\r
+    else {\r
+      if ( (setwd5[LA(1)]&0x4) ) {\r
+      }\r
+      else {zzFAIL(1,zzerr24,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
+    }\r
+    zzEXIT(zztasp2);\r
+    }\r
+  }\r
+  {\r
+    zzBLOCK(zztasp2);\r
+    zzMake0;\r
+    {\r
+    if ( (LA(1)==107) ) {\r
+      zzmatch(107); zzCONSUME;\r
+    }\r
+    else {\r
+      if ( (setwd5[LA(1)]&0x8) ) {\r
+      }\r
+      else {zzFAIL(1,zzerr25,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
+    }\r
+    zzEXIT(zztasp2);\r
+    }\r
+  }\r
+  chkToken(t, e, a, tnum);\r
+  if (t != NULL) {\r
+    te=(TermEntry *)hash_get(Tname,t);\r
+    if (te != NULL && akaString != NULL) {\r
+      if (te->akaString != NULL) {\r
+        if (strcmp(te->akaString,akaString) != 0) {\r
+          warnFL(eMsg2("this #token statment conflicts with a previous #token %s(\"%s\") statement",\r
+          t,te->akaString),\r
+          FileStr[save_file],save_line);\r
+        };\r
+      } else {\r
+        te->akaString=akaString;\r
+      };\r
+    };\r
+  };\r
+  zzEXIT(zztasp1);\r
+  return;\r
+fail:\r
+  zzEXIT(zztasp1);\r
+  CannotContinue=TRUE;  \r
+  zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);\r
+  zzresynch(setwd5, 0x10);\r
+  }\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+block(set * toksrefd,set * rulesrefd)\r
+#else\r
+block(toksrefd,rulesrefd)\r
+ set *toksrefd;\r
+set *rulesrefd ;\r
+#endif\r
+{\r
+  zzRULE;\r
+  zzBLOCK(zztasp1);\r
+  zzMake0;\r
+  {\r
+  \r
+  Graph g, b;\r
+  set saveblah;\r
+  int saveinalt = inAlt;\r
+  ExceptionGroup *eg;\r
+  * toksrefd = empty;\r
+  * rulesrefd = empty;\r
+  set_clr(AST_nodes_refd_in_actions);\r
+  CurBlockID++;\r
+  /* MR23 */      CurBlockID_array[BlkLevel] = CurBlockID;\r
+  CurAltNum = 1;\r
+  /* MR23 */      CurAltNum_array[BlkLevel] = CurAltNum;                \r
+  saveblah = attribsRefdFromAction;\r
+  attribsRefdFromAction = empty;\r
+  alt( toksrefd,rulesrefd );\r
+  b = g = zzaArg(zztasp1,1);\r
+  \r
+  if ( ((Junction *)g.left)->p1->ntype == nAction )\r
+  {\r
+    ActionNode *actionNode=(ActionNode *)\r
+    ( ( (Junction *)g.left) ->p1);\r
+    if (!actionNode->is_predicate )\r
+    {\r
+      actionNode->init_action = TRUE;\r
+      /* MR12c */              if (actionNode->noHoist) {\r
+        /* MR12c */           errFL("<<nohoist>> appears as init-action - use <<>> <<nohoist>>",\r
+        /* MR12c */                       FileStr[actionNode->file],actionNode->line);\r
+        /* MR12c */         };\r
+    }\r
+  }\r
+  ((Junction *)g.left)->blockid = CurBlockID;\r
+  {\r
+    zzBLOCK(zztasp2);\r
+    zzMake0;\r
+    {\r
+    while ( (LA(1)==133) ) {\r
+       eg  = exception_group();\r
+\r
+      \r
+      if ( eg!=NULL ) {\r
+        /* MR7 *****           eg->altID = makeAltID(CurBlockID,CurAltNum);        *****/\r
+        /* MR7 *****           CurAltStart->exception_label = eg->altID;           *****/\r
+        list_add(&CurExGroups, (void *)eg);\r
+      }\r
+      zzLOOP(zztasp2);\r
+    }\r
+    zzEXIT(zztasp2);\r
+    }\r
+  }\r
+  CurAltNum++;\r
+  /* MR23 */    CurAltNum_array[BlkLevel] = CurAltNum;\r
+  {\r
+    zzBLOCK(zztasp2);\r
+    zzMake0;\r
+    {\r
+    while ( (LA(1)==123) ) {\r
+      zzmatch(123);\r
+      inAlt=1;\r
+ zzCONSUME;\r
+\r
+      alt( toksrefd,rulesrefd );\r
+      g = Or(g, zzaArg(zztasp2,2));\r
+      \r
+      ((Junction *)g.left)->blockid = CurBlockID;\r
+      {\r
+        zzBLOCK(zztasp3);\r
+        zzMake0;\r
+        {\r
+        while ( (LA(1)==133) ) {\r
+           eg  = exception_group();\r
+\r
+          \r
+          if ( eg!=NULL ) {\r
+            /* MR7 *****               eg->altID = makeAltID(CurBlockID,CurAltNum);        *****/\r
+            /* MR7 *****               CurAltStart->exception_label = eg->altID;           *****/\r
+            list_add(&CurExGroups, (void *)eg);\r
+          }\r
+          zzLOOP(zztasp3);\r
+        }\r
+        zzEXIT(zztasp3);\r
+        }\r
+      }\r
+      CurAltNum++;\r
+      /* MR23 */        CurAltNum_array[BlkLevel] = CurAltNum;\r
+      zzLOOP(zztasp2);\r
+    }\r
+    zzEXIT(zztasp2);\r
+    }\r
+  }\r
+  zzaArg(zztasp1,0) = b;\r
+  attribsRefdFromAction = saveblah; inAlt = saveinalt;\r
+  zzEXIT(zztasp1);\r
+  return;\r
+fail:\r
+  zzEXIT(zztasp1);\r
+  CannotContinue=TRUE;  \r
+  zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);\r
+  zzresynch(setwd5, 0x20);\r
+  }\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+alt(set * toksrefd,set * rulesrefd)\r
+#else\r
+alt(toksrefd,rulesrefd)\r
+ set *toksrefd;\r
+set *rulesrefd ;\r
+#endif\r
+{\r
+  zzRULE;\r
+  zzBLOCK(zztasp1);\r
+  zzMake0;\r
+  {\r
+  int n=0; Graph g; int e_num=0, old_not=0; Node *node; set elems, dif;\r
+  int first_on_line = 1, use_def_MT_handler = 0;\r
+  g.left=NULL; g.right=NULL;\r
+  \r
+                       CurAltStart = NULL;\r
+  elems = empty;\r
+  inAlt = 1;\r
+  {\r
+    zzBLOCK(zztasp2);\r
+    zzMake0;\r
+    {\r
+    if ( (LA(1)==88) ) {\r
+      zzmatch(88);\r
+      use_def_MT_handler = 1;\r
+ zzCONSUME;\r
+\r
+    }\r
+    else {\r
+      if ( (setwd5[LA(1)]&0x40) ) {\r
+      }\r
+      else {zzFAIL(1,zzerr26,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
+    }\r
+    zzEXIT(zztasp2);\r
+    }\r
+  }\r
+  {\r
+    zzBLOCK(zztasp2);\r
+    zzMake0;\r
+    {\r
+    ;\r
+    while ( (setwd5[LA(1)]&0x80) ) {\r
+      {\r
+        zzBLOCK(zztasp3);\r
+        zzMake0;\r
+        {\r
+        old_not=0;\r
+        if ( (LA(1)==124) ) {\r
+          zzmatch(124);\r
+          old_not=1;\r
+ zzCONSUME;\r
+\r
+        }\r
+        else {\r
+          if ( (setwd6[LA(1)]&0x1) ) {\r
+          }\r
+          else {zzFAIL(1,zzerr27,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
+        }\r
+        zzEXIT(zztasp3);\r
+        }\r
+      }\r
+       node  = element( old_not, first_on_line, use_def_MT_handler );\r
+\r
+      if ( node!=NULL && node->ntype!=nAction ) first_on_line = 0;\r
+      \r
+      if ( zzaArg(zztasp2,2 ).left!=NULL ) {\r
+        g = Cat(g, zzaArg(zztasp2,2));\r
+        n++;\r
+        if ( node!=NULL ) {\r
+          if ( node->ntype!=nAction ) e_num++;\r
+          /* record record number of all rule and token refs */\r
+          if ( node->ntype==nToken ) {\r
+            TokNode *tk = (TokNode *)((Junction *)zzaArg(zztasp2,2 ).left)->p1;\r
+            tk->elnum = e_num;\r
+            set_orel(e_num, &elems);\r
+          }\r
+          else if ( node->ntype==nRuleRef ) {\r
+            RuleRefNode *rn = (RuleRefNode *)((Junction *)zzaArg(zztasp2,2 ).left)->p1;\r
+            rn->elnum = e_num;\r
+            set_orel(e_num,  rulesrefd);\r
+          }\r
+        }\r
+      }\r
+      zzLOOP(zztasp2);\r
+    }\r
+    zzEXIT(zztasp2);\r
+    }\r
+  }\r
+  if ( n == 0 ) g = emptyAlt();\r
+  zzaArg(zztasp1,0) = g;\r
+  /* We want to reduce number of LT(i) calls and the number of\r
+  * local attribute variables in C++ mode (for moment, later we'll\r
+  * do for C also).  However, if trees are being built, they\r
+  * require most of the attrib variables to create the tree nodes\r
+  * with; therefore, we gen a token ptr for each token ref in C++\r
+  */\r
+  if ( GenCC && !GenAST )\r
+  {\r
+  /* This now free's the temp set -ATG 5/6/95 */\r
+  set temp;\r
+  temp = set_and(elems, attribsRefdFromAction);\r
+  set_orin( toksrefd, temp);\r
+  set_free(temp);\r
+}\r
+else set_orin( toksrefd, elems);\r
+if ( GenCC ) {\r
+  dif = set_dif(attribsRefdFromAction, elems);\r
+  if ( set_deg(dif)>0 )\r
+  err("one or more $i in action(s) refer to non-token elements");\r
+  set_free(dif);\r
+}\r
+set_free(elems);\r
+set_free(attribsRefdFromAction);\r
+inAlt = 0;\r
+  zzEXIT(zztasp1);\r
+  return;\r
+fail:\r
+  zzEXIT(zztasp1);\r
+  CannotContinue=TRUE;  \r
+  zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);\r
+  zzresynch(setwd6, 0x2);\r
+  }\r
+}\r
+\r
+LabelEntry *\r
+#ifdef __USE_PROTOS\r
+element_label(void)\r
+#else\r
+element_label()\r
+#endif\r
+{\r
+  LabelEntry *   _retv;\r
+  zzRULE;\r
+  zzBLOCK(zztasp1);\r
+  PCCTS_PURIFY(_retv,sizeof(LabelEntry *  ))\r
+  zzMake0;\r
+  {\r
+  TermEntry *t=NULL; LabelEntry *l=NULL; RuleEntry *r=NULL; char *lab;\r
+  zzmatch(LABEL);\r
+  lab = mystrdup(LATEXT(1));\r
+ zzCONSUME;\r
+\r
+  \r
+  UsedNewStyleLabel = 1;\r
+  if ( UsedOldStyleAttrib ) err("cannot mix with new-style labels with old-style $i");\r
+  t = (TermEntry *) hash_get(Tname, lab);\r
+  if ( t==NULL ) t = (TermEntry *) hash_get(Texpr, lab);\r
+  if ( t==NULL ) r = (RuleEntry *) hash_get(Rname, lab);\r
+  if ( t!=NULL ) {\r
+    err(eMsg1("label definition clashes with token/tokclass definition: '%s'", lab));\r
+    _retv = NULL;\r
+  }\r
+  else if ( r!=NULL ) {\r
+    err(eMsg1("label definition clashes with rule definition: '%s'", lab));\r
+    _retv = NULL;\r
+  }\r
+  else {\r
+    /* we don't clash with anybody else */\r
+    l = (LabelEntry *) hash_get(Elabel, lab);\r
+    if ( l==NULL ) {   /* ok to add new element label */\r
+    l = (LabelEntry *)hash_add(Elabel,\r
+    lab,\r
+    (Entry *)newLabelEntry(lab));\r
+    /* add to list of element labels for this rule */\r
+    list_add(&CurElementLabels, (void *)lab);\r
+    /* MR7 */       leAdd(l);  /* list of labels waiting for exception group definitions */\r
+    _retv = l;\r
+  }\r
+  else {\r
+  err(eMsg1("label definitions must be unique per rule: '%s'", lab));\r
+  _retv = NULL;\r
+}\r
+}\r
+  zzmatch(106); zzCONSUME;\r
+  zzEXIT(zztasp1);\r
+  return _retv;\r
+fail:\r
+  zzEXIT(zztasp1);\r
+  zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);\r
+  zzresynch(setwd6, 0x4);\r
+  return _retv;\r
+  }\r
+}\r
+\r
+Node *\r
+#ifdef __USE_PROTOS\r
+element(int old_not,int first_on_line,int use_def_MT_handler)\r
+#else\r
+element(old_not,first_on_line,use_def_MT_handler)\r
+ int old_not;\r
+int first_on_line;\r
+int use_def_MT_handler ;\r
+#endif\r
+{\r
+  Node *   _retv;\r
+  zzRULE;\r
+  zzBLOCK(zztasp1);\r
+  PCCTS_PURIFY(_retv,sizeof(Node *  ))\r
+  zzMake0;\r
+  {\r
+  \r
+  Attrib blk;\r
+  Predicate *pred = NULL;\r
+  int local_use_def_MT_handler=0;\r
+  ActionNode *act;\r
+  RuleRefNode *rr;\r
+  set toksrefd, rulesrefd;\r
+  TermEntry *term;\r
+  TokNode *p=NULL; RuleRefNode *q; int approx=0;\r
+  LabelEntry *label=NULL;\r
+  int predMsgDone=0;\r
+  int semDepth=0;\r
+  int   ampersandStyle;\r
+  int   height;         /* MR11 */\r
+  int   equal_height;   /* MR11 */\r
+  \r
+          char* pFirstSetSymbol = NULL; /* MR21 */\r
+  \r
+                 _retv = NULL;\r
+  if ( (setwd6[LA(1)]&0x8) ) {\r
+    {\r
+      zzBLOCK(zztasp2);\r
+      zzMake0;\r
+      {\r
+      if ( (LA(1)==LABEL) ) {\r
+         label  = element_label();\r
+\r
+      }\r
+      else {\r
+        if ( (setwd6[LA(1)]&0x10) ) {\r
+        }\r
+        else {zzFAIL(1,zzerr28,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
+      }\r
+      zzEXIT(zztasp2);\r
+      }\r
+    }\r
+    {\r
+      zzBLOCK(zztasp2);\r
+      zzMake0;\r
+      {\r
+      if ( (LA(1)==TokenTerm) ) {\r
+        zzmatch(TokenTerm);\r
+        \r
+        term = (TermEntry *) hash_get(Tname, LATEXT(1));\r
+        if ( term==NULL && UserDefdTokens ) {\r
+          err("implicit token definition not allowed with #tokdefs");\r
+          zzaRet.left = zzaRet.right = NULL;\r
+        }\r
+        else {\r
+          zzaRet = buildToken(LATEXT(1));\r
+          p=((TokNode *)((Junction *)zzaRet.left)->p1);\r
+          term = (TermEntry *) hash_get(Tname, LATEXT(1));\r
+          require( term!= NULL, "hash table mechanism is broken");\r
+          p->tclass = term->tclass;\r
+          p->complement =  old_not;\r
+          if ( label!=NULL ) {\r
+            p->el_label = label->str;\r
+            label->elem = (Node *)p;\r
+          }\r
+        }\r
+ zzCONSUME;\r
+\r
+        {\r
+          zzBLOCK(zztasp3);\r
+          zzMake0;\r
+          {\r
+          if ( (LA(1)==119) ) {\r
+            zzmatch(119); zzCONSUME;\r
+            {\r
+              zzBLOCK(zztasp4);\r
+              zzMake0;\r
+              {\r
+              if ( (LA(1)==QuotedTerm) ) {\r
+                zzmatch(QuotedTerm);\r
+                if ( p!=NULL ) setUpperRange(p, LATEXT(1));\r
+ zzCONSUME;\r
+\r
+              }\r
+              else {\r
+                if ( (LA(1)==TokenTerm) ) {\r
+                  zzmatch(TokenTerm);\r
+                  if ( p!=NULL ) setUpperRange(p, LATEXT(1));\r
+ zzCONSUME;\r
+\r
+                }\r
+                else {zzFAIL(1,zzerr29,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
+              }\r
+              zzEXIT(zztasp4);\r
+              }\r
+            }\r
+          }\r
+          else {\r
+            if ( (setwd6[LA(1)]&0x20) ) {\r
+            }\r
+            else {zzFAIL(1,zzerr30,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
+          }\r
+          zzEXIT(zztasp3);\r
+          }\r
+        }\r
+        \r
+        if ( p!=NULL && (p->upper_range!=0 || p->tclass ||  old_not) )\r
+        list_add(&MetaTokenNodes, (void *)p);\r
+        {\r
+          zzBLOCK(zztasp3);\r
+          zzMake0;\r
+          {\r
+          if ( (LA(1)==125) ) {\r
+            zzmatch(125);\r
+            if ( p!=NULL ) p->astnode=ASTroot;\r
+ zzCONSUME;\r
+\r
+          }\r
+          else {\r
+            if ( (setwd6[LA(1)]&0x40) ) {\r
+              if ( p!=NULL ) p->astnode=ASTchild;\r
+            }\r
+            else {\r
+              if ( (LA(1)==103) ) {\r
+                zzmatch(103);\r
+                if ( p!=NULL ) p->astnode=ASTexclude;\r
+ zzCONSUME;\r
+\r
+              }\r
+              else {zzFAIL(1,zzerr31,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
+            }\r
+          }\r
+          zzEXIT(zztasp3);\r
+          }\r
+        }\r
+        {\r
+          zzBLOCK(zztasp3);\r
+          zzMake0;\r
+          {\r
+          if ( (LA(1)==88) ) {\r
+            zzmatch(88);\r
+            local_use_def_MT_handler = 1;\r
+ zzCONSUME;\r
+\r
+          }\r
+          else {\r
+            if ( (setwd6[LA(1)]&0x80) ) {\r
+            }\r
+            else {zzFAIL(1,zzerr32,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
+          }\r
+          zzEXIT(zztasp3);\r
+          }\r
+        }\r
+        \r
+        if ( p!=NULL &&  first_on_line ) {\r
+          CurAltStart = (Junction *)zzaRet.left;\r
+          altAdd(CurAltStart);                                 /* MR7 */\r
+          p->altstart = CurAltStart;\r
+        }\r
+        if ( p!=NULL )\r
+        p->use_def_MT_handler =  use_def_MT_handler || local_use_def_MT_handler;\r
+        _retv = (Node *)p;\r
+      }\r
+      else {\r
+        if ( (LA(1)==QuotedTerm) ) {\r
+          zzmatch(QuotedTerm);\r
+          \r
+          term = (TermEntry *) hash_get(Texpr, LATEXT(1));\r
+          if ( term==NULL && UserDefdTokens ) {\r
+            err("implicit token definition not allowed with #tokdefs");\r
+            zzaRet.left = zzaRet.right = NULL;\r
+          }\r
+          else {\r
+            zzaRet = buildToken(LATEXT(1)); p=((TokNode *)((Junction *)zzaRet.left)->p1);\r
+            p->complement =  old_not;\r
+            if ( label!=NULL ) {\r
+              p->el_label = label->str;\r
+              label->elem = (Node *)p;\r
+            }\r
+          }\r
+ zzCONSUME;\r
+\r
+          {\r
+            zzBLOCK(zztasp3);\r
+            zzMake0;\r
+            {\r
+            if ( (LA(1)==119) ) {\r
+              zzmatch(119); zzCONSUME;\r
+              {\r
+                zzBLOCK(zztasp4);\r
+                zzMake0;\r
+                {\r
+                if ( (LA(1)==QuotedTerm) ) {\r
+                  zzmatch(QuotedTerm);\r
+                  if ( p!=NULL ) setUpperRange(p, LATEXT(1));\r
+ zzCONSUME;\r
+\r
+                }\r
+                else {\r
+                  if ( (LA(1)==TokenTerm) ) {\r
+                    zzmatch(TokenTerm);\r
+                    if ( p!=NULL ) setUpperRange(p, LATEXT(1));\r
+ zzCONSUME;\r
+\r
+                  }\r
+                  else {zzFAIL(1,zzerr33,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
+                }\r
+                zzEXIT(zztasp4);\r
+                }\r
+              }\r
+            }\r
+            else {\r
+              if ( (setwd7[LA(1)]&0x1) ) {\r
+              }\r
+              else {zzFAIL(1,zzerr34,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
+            }\r
+            zzEXIT(zztasp3);\r
+            }\r
+          }\r
+          {\r
+            zzBLOCK(zztasp3);\r
+            zzMake0;\r
+            {\r
+            if ( (LA(1)==125) ) {\r
+              zzmatch(125);\r
+              if ( p!=NULL ) p->astnode=ASTroot;\r
+ zzCONSUME;\r
+\r
+            }\r
+            else {\r
+              if ( (setwd7[LA(1)]&0x2) ) {\r
+                if ( p!=NULL ) p->astnode=ASTchild;\r
+              }\r
+              else {\r
+                if ( (LA(1)==103) ) {\r
+                  zzmatch(103);\r
+                  if ( p!=NULL ) p->astnode=ASTexclude;\r
+ zzCONSUME;\r
+\r
+                }\r
+                else {zzFAIL(1,zzerr35,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
+              }\r
+            }\r
+            zzEXIT(zztasp3);\r
+            }\r
+          }\r
+          {\r
+            zzBLOCK(zztasp3);\r
+            zzMake0;\r
+            {\r
+            if ( (LA(1)==88) ) {\r
+              zzmatch(88);\r
+              local_use_def_MT_handler = 1;\r
+ zzCONSUME;\r
+\r
+            }\r
+            else {\r
+              if ( (setwd7[LA(1)]&0x4) ) {\r
+              }\r
+              else {zzFAIL(1,zzerr36,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
+            }\r
+            zzEXIT(zztasp3);\r
+            }\r
+          }\r
+          \r
+          if ( p!=NULL && (p->upper_range!=0 || p->tclass ||  old_not) )\r
+          list_add(&MetaTokenNodes, (void *)p);\r
+          \r
+          if (  first_on_line ) {\r
+            CurAltStart = (Junction *)zzaRet.left;\r
+            altAdd(CurAltStart);                                 /* MR7 */\r
+            p->altstart = CurAltStart;\r
+          }\r
+          if ( p!=NULL )\r
+          p->use_def_MT_handler =  use_def_MT_handler || local_use_def_MT_handler;\r
+          _retv = (Node *)p;\r
+        }\r
+        else {\r
+          if ( (LA(1)==WildCard) ) {\r
+            if (  old_not ) warn("~ WILDCARD is an undefined operation (implies 'nothing')");\r
+            zzmatch(WildCard);\r
+            zzaRet = buildWildCard(LATEXT(1)); p=((TokNode *)((Junction *)zzaRet.left)->p1);\r
+ zzCONSUME;\r
+\r
+            {\r
+              zzBLOCK(zztasp3);\r
+              zzMake0;\r
+              {\r
+              if ( (LA(1)==125) ) {\r
+                zzmatch(125);\r
+                p->astnode=ASTroot;\r
+ zzCONSUME;\r
+\r
+              }\r
+              else {\r
+                if ( (setwd7[LA(1)]&0x8) ) {\r
+                  p->astnode=ASTchild;\r
+                }\r
+                else {\r
+                  if ( (LA(1)==103) ) {\r
+                    zzmatch(103);\r
+                    p->astnode=ASTexclude;\r
+ zzCONSUME;\r
+\r
+                  }\r
+                  else {zzFAIL(1,zzerr37,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
+                }\r
+              }\r
+              zzEXIT(zztasp3);\r
+              }\r
+            }\r
+            list_add(&MetaTokenNodes, (void *)p);\r
+            \r
+            if (  first_on_line ) {\r
+              CurAltStart = (Junction *)zzaRet.left;\r
+              altAdd(CurAltStart);                                 /* MR7 */\r
+              p->altstart = CurAltStart;\r
+              if ( label!=NULL ) {\r
+                p->el_label = label->str;\r
+                label->elem = (Node *)p;\r
+              }\r
+            }\r
+            _retv = (Node *)p;\r
+          }\r
+          else {\r
+            if ( (LA(1)==NonTerminal) ) {\r
+              if (  old_not ) warn("~ NONTERMINAL is an undefined operation");\r
+              zzmatch(NonTerminal);\r
+              zzaRet = buildRuleRef(LATEXT(1));\r
+ zzCONSUME;\r
+\r
+              {\r
+                zzBLOCK(zztasp3);\r
+                zzMake0;\r
+                {\r
+                if ( (LA(1)==103) ) {\r
+                  zzmatch(103);\r
+                  q = (RuleRefNode *) ((Junction *)zzaRet.left)->p1;\r
+                  q->astnode=ASTexclude;\r
+ zzCONSUME;\r
+\r
+                }\r
+                else {\r
+                  if ( (setwd7[LA(1)]&0x10) ) {\r
+                  }\r
+                  else {zzFAIL(1,zzerr38,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
+                }\r
+                zzEXIT(zztasp3);\r
+                }\r
+              }\r
+              {\r
+                zzBLOCK(zztasp3);\r
+                zzMake0;\r
+                {\r
+                if ( (setwd7[LA(1)]&0x20) ) {\r
+                  {\r
+                    zzBLOCK(zztasp4);\r
+                    zzMake0;\r
+                    {\r
+                    if ( (LA(1)==104) ) {\r
+                      zzmatch(104); zzCONSUME;\r
+                    }\r
+                    else {\r
+                      if ( (LA(1)==PassAction) ) {\r
+                      }\r
+                      else {zzFAIL(1,zzerr39,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
+                    }\r
+                    zzEXIT(zztasp4);\r
+                    }\r
+                  }\r
+                  zzmatch(PassAction);\r
+                  addParm(((Junction *)zzaRet.left)->p1, LATEXT(1));\r
+ zzCONSUME;\r
+\r
+                }\r
+                else {\r
+                  if ( (setwd7[LA(1)]&0x40) ) {\r
+                  }\r
+                  else {zzFAIL(1,zzerr40,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
+                }\r
+                zzEXIT(zztasp3);\r
+                }\r
+              }\r
+              rr=(RuleRefNode *) ((Junction *)zzaRet.left)->p1;\r
+              {\r
+                zzBLOCK(zztasp3);\r
+                zzMake0;\r
+                {\r
+                char *a;\r
+                if ( (LA(1)==105) ) {\r
+                  zzmatch(105); zzCONSUME;\r
+                  zzmatch(PassAction);\r
+                  \r
+                  a = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));\r
+                  require(a!=NULL, "rule element: cannot allocate assignment");\r
+                  strcpy(a, LATEXT(1));\r
+                  rr->assign = a;\r
+ zzCONSUME;\r
+\r
+                }\r
+                else {\r
+                  if ( (setwd7[LA(1)]&0x80) ) {\r
+                  }\r
+                  else {zzFAIL(1,zzerr41,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
+                }\r
+                zzEXIT(zztasp3);\r
+                }\r
+              }\r
+              \r
+              if ( label!=NULL ) {\r
+                rr->el_label = label->str;\r
+                label->elem = (Node *)rr;\r
+              }\r
+              if (  first_on_line ) {\r
+                CurAltStart = (Junction *)zzaRet.left;\r
+                altAdd(CurAltStart);                                 /* MR7 */\r
+                ((RuleRefNode *)((Junction *)zzaRet.left)->p1)->altstart = CurAltStart;\r
+              }\r
+              _retv = (Node *)rr;\r
+            }\r
+            else {zzFAIL(1,zzerr42,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
+          }\r
+        }\r
+      }\r
+      zzEXIT(zztasp2);\r
+      }\r
+    }\r
+  }\r
+  else {\r
+    if ( (LA(1)==Action) ) {\r
+      if (  old_not )  warn("~ ACTION is an undefined operation");\r
+      zzmatch(Action);\r
+      zzaArg(zztasp1,0) = buildAction(LATEXT(1),action_file,action_line, 0);\r
+ zzCONSUME;\r
+\r
+      if (  first_on_line ) {                                /* MR7 */\r
+        CurAltStart = (Junction *)zzaArg(zztasp1,0 ).left;                   /* MR7 */\r
+        altAdd(CurAltStart);                                 /* MR7 */\r
+      };\r
+      _retv = (Node *) ((Junction *)zzaArg(zztasp1,0 ).left)->p1;\r
+    }\r
+    else {\r
+      if ( (LA(1)==Pred) ) {\r
+        if (  old_not )        warn("~ SEMANTIC-PREDICATE is an undefined operation");\r
+        zzmatch(Pred);\r
+        zzaArg(zztasp1,0) = buildAction(LATEXT(1),action_file,action_line, 1);\r
+ zzCONSUME;\r
+\r
+        act = (ActionNode *) ((Junction *)zzaArg(zztasp1,0 ).left)->p1;\r
+        if (numericActionLabel) {             /* MR10 */\r
+          list_add(&NumericPredLabels,act);   /* MR10 */\r
+          numericActionLabel=0;               /* MR10 */\r
+        };                                    /* MR10 */\r
+        {\r
+          zzBLOCK(zztasp2);\r
+          zzMake0;\r
+          {\r
+          char *a;\r
+          if ( (LA(1)==PassAction) ) {\r
+            zzmatch(PassAction);\r
+            \r
+            a = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));\r
+            require(a!=NULL, "rule element: cannot allocate predicate fail action");\r
+            strcpy(a, LATEXT(1));\r
+            act->pred_fail = a;\r
+ zzCONSUME;\r
+\r
+          }\r
+          else {\r
+            if ( (setwd8[LA(1)]&0x1) ) {\r
+            }\r
+            else {zzFAIL(1,zzerr43,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
+          }\r
+          zzEXIT(zztasp2);\r
+          }\r
+        }\r
+        if (  first_on_line ) {                                /* MR7 */\r
+          CurAltStart = (Junction *)zzaArg(zztasp1,0 ).left;                   /* MR7 */\r
+          altAdd(CurAltStart);                                 /* MR7 */\r
+        };\r
+        _retv = (Node *)act;\r
+      }\r
+      else {\r
+        if ( (setwd8[LA(1)]&0x2) ) {\r
+          if (  old_not )      warn("~ BLOCK is an undefined operation");\r
+          BlkLevel++;\r
+          if (BlkLevel >= MAX_BLK_LEVEL) fatal("Blocks nested too deeply");\r
+          /* MR23 */    CurBlockID_array[BlkLevel] = CurBlockID;\r
+          /* MR23 */    CurAltNum_array[BlkLevel] = CurAltNum;\r
+          {\r
+            zzBLOCK(zztasp2);\r
+            zzMake0;\r
+            {\r
+            if ( (LA(1)==Pragma) ) {\r
+              zzmatch(Pragma); zzCONSUME;\r
+              {\r
+                zzBLOCK(zztasp3);\r
+                zzMake0;\r
+                {\r
+                if ( (LA(1)==126) ) {\r
+                  zzmatch(126);\r
+                  approx=LL_k;\r
+ zzCONSUME;\r
+\r
+                }\r
+                else {\r
+                  if ( (LA(1)==127) ) {\r
+                    zzmatch(127);\r
+                    approx = 1;\r
+ zzCONSUME;\r
+\r
+                  }\r
+                  else {\r
+                    if ( (LA(1)==128) ) {\r
+                      zzmatch(128);\r
+                      approx = 2;\r
+ zzCONSUME;\r
+\r
+                    }\r
+                    else {zzFAIL(1,zzerr44,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
+                  }\r
+                }\r
+                zzEXIT(zztasp3);\r
+                }\r
+              }\r
+            }\r
+            else {\r
+              if ( (setwd8[LA(1)]&0x4) ) {\r
+              }\r
+              else {zzFAIL(1,zzerr45,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
+            }\r
+            zzEXIT(zztasp2);\r
+            }\r
+          }\r
+          {\r
+            zzBLOCK(zztasp2);\r
+            zzMake0;\r
+            {\r
+            if ( (LA(1)==FirstSetSymbol) ) {\r
+              zzmatch(FirstSetSymbol); zzCONSUME;\r
+              zzmatch(114); zzCONSUME;\r
+              {\r
+                zzBLOCK(zztasp3);\r
+                zzMake0;\r
+                {\r
+                if ( (LA(1)==NonTerminal) ) {\r
+                  zzmatch(NonTerminal);\r
+                  \r
+                  /* MR21 */                     pFirstSetSymbol = (char *) calloc(strlen(LATEXT(1))+1,\r
+                  /* MR21 */                                                    sizeof(char));\r
+                  /* MR21 */                          require(pFirstSetSymbol!=NULL,\r
+                  /* MR21 */                                  "cannot allocate first set name");\r
+                  /* MR21 */                          strcpy(pFirstSetSymbol, LATEXT(1));\r
+                  /* MR21 */\r
+ zzCONSUME;\r
+\r
+                }\r
+                else {\r
+                  if ( (LA(1)==TokenTerm) ) {\r
+                    zzmatch(TokenTerm);\r
+                    \r
+                    /* MR21 */                      pFirstSetSymbol = (char *) calloc(strlen(LATEXT(1))+1,\r
+                    /* MR21 */                                                        sizeof(char));\r
+                    /* MR21 */                      require(pFirstSetSymbol!=NULL,\r
+                    /* MR21 */                              "cannot allocate first set name");\r
+                    /* MR21 */                      strcpy(pFirstSetSymbol, LATEXT(1));\r
+                    /* MR21 */\r
+ zzCONSUME;\r
+\r
+                  }\r
+                  else {zzFAIL(1,zzerr46,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
+                }\r
+                zzEXIT(zztasp3);\r
+                }\r
+              }\r
+              zzmatch(115); zzCONSUME;\r
+            }\r
+            else {\r
+              if ( (setwd8[LA(1)]&0x8) ) {\r
+              }\r
+              else {zzFAIL(1,zzerr47,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
+            }\r
+            zzEXIT(zztasp2);\r
+            }\r
+          }\r
+          {\r
+            zzBLOCK(zztasp2);\r
+            zzMake0;\r
+            {\r
+            if ( (LA(1)==114) ) {\r
+              zzmatch(114); zzCONSUME;\r
+              block( &toksrefd,&rulesrefd );\r
+              zzmatch(115);\r
+              blk = zzaRet = zzaArg(zztasp2,2);\r
+              /* MR23 */      CurBlockID_array[BlkLevel] = (-1);\r
+              /* MR23 */      CurAltNum_array[BlkLevel] = (-1);                \r
+              --BlkLevel;\r
+ zzCONSUME;\r
+\r
+              {\r
+                zzBLOCK(zztasp3);\r
+                zzMake0;\r
+                {\r
+                if ( (LA(1)==129) ) {\r
+                  zzmatch(129);\r
+                  zzaRet = makeLoop(zzaRet,approx,pFirstSetSymbol);\r
+ zzCONSUME;\r
+\r
+                }\r
+                else {\r
+                  if ( (LA(1)==130) ) {\r
+                    zzmatch(130);\r
+                    zzaRet = makePlus(zzaRet,approx,pFirstSetSymbol);\r
+ zzCONSUME;\r
+\r
+                  }\r
+                  else {\r
+                    if ( (LA(1)==131) ) {\r
+                      zzmatch(131); zzCONSUME;\r
+                      {\r
+                        zzBLOCK(zztasp4);\r
+                        zzMake0;\r
+                        {\r
+                        if ( (setwd8[LA(1)]&0x10) ) {\r
+                          {\r
+                            zzBLOCK(zztasp5);\r
+                            zzMake0;\r
+                            {\r
+                            if ( (LA(1)==132) ) {\r
+                              zzmatch(132);\r
+                              ampersandStyle=0;\r
+ zzCONSUME;\r
+\r
+                            }\r
+                            else {\r
+                              if ( (LA(1)==113) ) {\r
+                                zzmatch(113);\r
+                                ampersandStyle=1;\r
+ zzCONSUME;\r
+\r
+                              }\r
+                              else {zzFAIL(1,zzerr48,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
+                            }\r
+                            zzEXIT(zztasp5);\r
+                            }\r
+                          }\r
+                          zzmatch(Pred);\r
+                          zzaRet = buildAction(LATEXT(1),action_file,action_line,1);\r
+ zzCONSUME;\r
+\r
+                          act = (ActionNode *) ((Junction *)zzaRet.left)->p1;\r
+                          semDepth=predicateLookaheadDepth(act);\r
+                          if (numericActionLabel) {             /* MR10 */\r
+                            list_add(&NumericPredLabels,act);   /* MR10 */\r
+                            numericActionLabel=0;               /* MR10 */\r
+                          };                                    /* MR10 */\r
+                          {\r
+                            zzBLOCK(zztasp5);\r
+                            zzMake0;\r
+                            {\r
+                            char *a;\r
+                            if ( (LA(1)==PassAction) ) {\r
+                              zzmatch(PassAction);\r
+                              \r
+                              a = (char *)calloc(strlen(LATEXT(1))+1, sizeof(char));\r
+                              require(a!=NULL, "rule element: cannot allocate predicate fail action");\r
+                              strcpy(a, LATEXT(1));\r
+                              act->pred_fail = a;\r
+ zzCONSUME;\r
+\r
+                            }\r
+                            else {\r
+                              if ( (setwd8[LA(1)]&0x20) ) {\r
+                              }\r
+                              else {zzFAIL(1,zzerr49,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
+                            }\r
+                            zzEXIT(zztasp5);\r
+                            }\r
+                          }\r
+                          if ( first_on_line) {                      /* MR7 */\r
+                            CurAltStart=(Junction *)zzaRet.left;         /* MR7 */\r
+                            altAdd(CurAltStart);                     /* MR7 */\r
+                          };\r
+                          _retv = (Node *)act;\r
+                          \r
+                          pred = computePredFromContextGuard(blk,&predMsgDone);           /* MR10 */\r
+                          if ( pred==NULL) {                                              /* MR10 */\r
+                            if ( !predMsgDone) err("invalid or missing context guard");   /* MR10 */\r
+                            predMsgDone=1;                                                /* MR10 */\r
+                          } else {                                                        /* MR10 */\r
+                            act->guardNodes=(Junction *)blk.left;                       /* MR11 */\r
+                            pred->expr = act->action;\r
+                            pred->source = act;\r
+                            /* MR10 */                  pred->ampersandStyle = ampersandStyle;  /* 0 means (g)? => ... 1 means (g)? && ... */\r
+                            /* MR13 */                  if (pred->tcontext != NULL) {\r
+                              /* MR13 */                    height=MR_max_height_of_tree(pred->tcontext);\r
+                              /* MR13 */                    equal_height=MR_all_leaves_same_height(pred->tcontext,height);\r
+                              /* MR13 */                    if (! equal_height) {\r
+                                /* MR13 */                       errFL("in guarded predicates all tokens in the guard must be at the same height",\r
+                                /* MR13 */                              FileStr[act->file],act->line);\r
+                                /* MR13 */                    };\r
+                              /* MR13 */                  }\r
+                            /* MR10 */                  if (ampersandStyle) {\r
+                              /* MR10 */                                         act->ampersandPred = pred;\r
+                              /* MR11 */                    if (! HoistPredicateContext) {\r
+                                /* MR11 */                      errFL("without \"-prc on\" (guard)? && <<pred>>? ... doesn't make sense",\r
+                                /* MR11 */                              FileStr[act->file],act->line);\r
+                                /* MR11 */                    };\r
+                              /* MR10 */                  } else {\r
+                              /* MR10 */                                         act->guardpred = pred;\r
+                              /* MR10 */                  };\r
+                            /* MR10 */                  if (pred->k != semDepth) {\r
+                              /* MR10 */                     warn(eMsgd2("length of guard (%d) does not match the length of semantic predicate (%d)",\r
+                              /* MR10 */                                  pred->k,semDepth));\r
+                              /* MR10 */                  };\r
+                          }\r
+                        }\r
+                        else {\r
+                          if ( (setwd8[LA(1)]&0x40) ) {\r
+                            zzaRet = makeBlk(zzaRet,approx,pFirstSetSymbol);\r
+                            FoundGuessBlk = 1;\r
+                            ((Junction *) ((Junction *)zzaRet.left)->p1)->guess=1;\r
+                            if ( ! first_on_line ) {\r
+                              err("(...)? predicate must be first element of production");\r
+                            }\r
+                          }\r
+                          else {zzFAIL(1,zzerr50,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
+                        }\r
+                        zzEXIT(zztasp4);\r
+                        }\r
+                      }\r
+                    }\r
+                    else {\r
+                      if ( (setwd8[LA(1)]&0x80) ) {\r
+                        zzaRet = makeBlk(zzaRet,approx,pFirstSetSymbol);\r
+                      }\r
+                      else {zzFAIL(1,zzerr51,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
+                    }\r
+                  }\r
+                }\r
+                zzEXIT(zztasp3);\r
+                }\r
+              }\r
+              \r
+              if ( pred==NULL && !predMsgDone) {                                      /* MR10 */\r
+                ((Junction *)((Junction *)zzaRet.left)->p1)->blockid = CurBlockID;\r
+                ((Junction *)((Junction *)zzaRet.left)->p1)->tokrefs = toksrefd;\r
+                ((Junction *)((Junction *)zzaRet.left)->p1)->rulerefs = rulesrefd;\r
+                if (  first_on_line ) {                         /* MR7 */\r
+                  CurAltStart = (Junction *)((Junction *)((Junction *)zzaRet.left)->p1);  /* MR7 */\r
+                  altAdd(CurAltStart);                         /* MR7 */\r
+                };                                              /* MR7 */\r
+                _retv = (Node *) ((Junction *)zzaRet.left)->p1;\r
+              }\r
+            }\r
+            else {\r
+              if ( (LA(1)==102) ) {\r
+                zzmatch(102); zzCONSUME;\r
+                block( &toksrefd,&rulesrefd );\r
+                zzaRet = makeOpt(zzaArg(zztasp2,2),approx,pFirstSetSymbol);\r
+                /* MR23 */      CurBlockID_array[BlkLevel] = (-1);\r
+                /* MR23 */      CurAltNum_array[BlkLevel] = (-1);                \r
+                --BlkLevel;\r
+                zzmatch(98);\r
+                \r
+                ((Junction *)((Junction *)zzaRet.left)->p1)->blockid = CurBlockID;\r
+                ((Junction *)((Junction *)zzaRet.left)->p1)->tokrefs = toksrefd;\r
+                ((Junction *)((Junction *)zzaRet.left)->p1)->rulerefs = rulesrefd;\r
+ zzCONSUME;\r
+\r
+                if (  first_on_line ) {                            /* MR7 */\r
+                  CurAltStart = (Junction *) ((Junction *)((Junction *)zzaRet.left)->p1);  /* MR7 */\r
+                  altAdd(CurAltStart);                             /* MR7 */\r
+                };\r
+                _retv = (Node *) ((Junction *)zzaRet.left)->p1;\r
+              }\r
+              else {zzFAIL(1,zzerr52,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
+            }\r
+            zzEXIT(zztasp2);\r
+            }\r
+          }\r
+        }\r
+        else {\r
+          if ( (LA(1)==129) ) {\r
+            zzmatch(129);\r
+            warn("don't you want a ')' with that '*'?"); CannotContinue=TRUE;\r
+ zzCONSUME;\r
+\r
+          }\r
+          else {\r
+            if ( (LA(1)==130) ) {\r
+              zzmatch(130);\r
+              warn("don't you want a ')' with that '+'?"); CannotContinue=TRUE;\r
+ zzCONSUME;\r
+\r
+            }\r
+            else {\r
+              if ( (LA(1)==105) ) {\r
+                zzmatch(105);\r
+                warn("'>' can only appear after a nonterminal"); CannotContinue=TRUE;\r
+ zzCONSUME;\r
+\r
+              }\r
+              else {\r
+                if ( (LA(1)==PassAction) ) {\r
+                  zzmatch(PassAction);\r
+                  warn("[...] out of context 'rule > [...]'");\r
+                  CannotContinue=TRUE;\r
+ zzCONSUME;\r
+\r
+                }\r
+                else {zzFAIL(1,zzerr53,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
+              }\r
+            }\r
+          }\r
+        }\r
+      }\r
+    }\r
+  }\r
+  zzEXIT(zztasp1);\r
+  return _retv;\r
+fail:\r
+  zzEXIT(zztasp1);\r
+  CannotContinue=TRUE;  \r
+  zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);\r
+  zzresynch(setwd9, 0x1);\r
+  return _retv;\r
+  }\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+default_exception_handler(void)\r
+#else\r
+default_exception_handler()\r
+#endif\r
+{\r
+  zzRULE;\r
+  zzBLOCK(zztasp1);\r
+  zzMake0;\r
+  {\r
+   DefaultExGroup  = exception_group();\r
+\r
+  zzEXIT(zztasp1);\r
+  return;\r
+fail:\r
+  zzEXIT(zztasp1);\r
+  zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);\r
+  zzresynch(setwd9, 0x2);\r
+  }\r
+}\r
+\r
+ExceptionGroup *\r
+#ifdef __USE_PROTOS\r
+exception_group(void)\r
+#else\r
+exception_group()\r
+#endif\r
+{\r
+  ExceptionGroup *   _retv;\r
+  zzRULE;\r
+  zzBLOCK(zztasp1);\r
+  PCCTS_PURIFY(_retv,sizeof(ExceptionGroup *  ))\r
+  zzMake0;\r
+  {\r
+  ExceptionHandler *h; LabelEntry *label=NULL;   /* MR6 */\r
+  FoundException = 1; FoundExceptionGroup = 1;\r
+  zzmatch(133);\r
+  _retv = (ExceptionGroup *)calloc(1, sizeof(ExceptionGroup));\r
+ zzCONSUME;\r
+\r
+  {\r
+    zzBLOCK(zztasp2);\r
+    zzMake0;\r
+    {\r
+    char *p;\r
+    if ( (LA(1)==PassAction) ) {\r
+      zzmatch(PassAction);\r
+      \r
+      p = LATEXT(1)+1;\r
+      p[strlen(p)-1] = '\0';           /* kill trailing space */\r
+      label = (LabelEntry *) hash_get(Elabel, LATEXT(1)+1);\r
+      if ( label==NULL )\r
+      {\r
+        err(eMsg1("unknown label in exception handler: '%s'", LATEXT(1)+1));\r
+      }\r
+ zzCONSUME;\r
+\r
+    }\r
+    else {\r
+      if ( (setwd9[LA(1)]&0x4) ) {\r
+      }\r
+      else {zzFAIL(1,zzerr54,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
+    }\r
+    zzEXIT(zztasp2);\r
+    }\r
+  }\r
+  {\r
+    zzBLOCK(zztasp2);\r
+    zzMake0;\r
+    {\r
+    while ( (LA(1)==135) ) {\r
+       h  = exception_handler();\r
+\r
+      list_add(&(_retv->handlers), (void *)h);\r
+      zzLOOP(zztasp2);\r
+    }\r
+    zzEXIT(zztasp2);\r
+    }\r
+  }\r
+  {\r
+    zzBLOCK(zztasp2);\r
+    zzMake0;\r
+    {\r
+    if ( (LA(1)==134) ) {\r
+      zzmatch(134); zzCONSUME;\r
+      zzmatch(106); zzCONSUME;\r
+      zzmatch(Action);\r
+      {\r
+        ExceptionHandler *eh = (ExceptionHandler *)\r
+        calloc(1, sizeof(ExceptionHandler));\r
+        char *a = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));\r
+        require(eh!=NULL, "exception: cannot allocate handler");\r
+        require(a!=NULL, "exception: cannot allocate action");\r
+        strcpy(a, LATEXT(1));\r
+        eh->action = a;\r
+        eh->signalname = (char *) calloc(strlen("default")+1, sizeof(char));\r
+        require(eh->signalname!=NULL, "exception: cannot allocate sig name");\r
+        strcpy(eh->signalname, "default");\r
+        list_add(&(_retv->handlers), (void *)eh);\r
+      }\r
+ zzCONSUME;\r
+\r
+    }\r
+    else {\r
+      if ( (setwd9[LA(1)]&0x8) ) {\r
+      }\r
+      else {zzFAIL(1,zzerr55,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
+    }\r
+    zzEXIT(zztasp2);\r
+    }\r
+  }\r
+  \r
+  if ( label!=NULL ) {\r
+    /* Record ex group in sym tab for this label */\r
+    if ( label->ex_group!=NULL ) {\r
+      err(eMsg1("duplicate exception handler for label '%s'",label->str));\r
+    } else {\r
+      label->ex_group = _retv;\r
+      /* Label the exception group itself */\r
+      _retv->label = label->str;\r
+      /* Make the labelled element pt to the exception also */\r
+      /* MR6 */          if (label->elem == NULL) {\r
+        /* MR6 */           err(eMsg1("reference in exception handler to undefined label '%s'",label->str));\r
+        /* MR6 */        } else {\r
+        switch ( label->elem->ntype ) {\r
+          case nRuleRef :\r
+          {\r
+            RuleRefNode *r = (RuleRefNode *)label->elem;\r
+            r->ex_group = _retv;\r
+            break;\r
+          }\r
+          case nToken :\r
+          {\r
+            TokNode *t = (TokNode *)label->elem;\r
+            t->ex_group = _retv;\r
+            break;\r
+          }\r
+        } /* end switch */\r
+        /* MR6 */        }; /* end test on label->elem */\r
+    } /* end test on label->ex_group */\r
+    \r
+               } /* end test on exception label */\r
+  \r
+/* MR7 */\r
+  /* MR7 */   if (BlkLevel == 1 && label == NULL) {\r
+    /* MR7 */     _retv->forRule=1;\r
+    /* MR7 */   } else if (label == NULL) {\r
+    /* MR7 */     _retv->altID = makeAltID(CurBlockID_array[BlkLevel], CurAltNum_array[BlkLevel]);\r
+    /* MR7 */     egAdd(_retv);\r
+    /* MR7 */   } else {\r
+    /* MR7 */     _retv->labelEntry=label;\r
+    /* MR7 */   };\r
+  /* MR7 */\r
+  /* MR7 */        /* You may want to remove this exc from the rule list  */\r
+  /* MR7 */            /* and handle at the labeled element site.             */\r
+  /* MR7 */\r
+  /* MR7 */   if (label != NULL) {\r
+    /* MR7 */     _retv = NULL;\r
+    /* MR7 */   };\r
+  zzEXIT(zztasp1);\r
+  return _retv;\r
+fail:\r
+  zzEXIT(zztasp1);\r
+  CannotContinue=TRUE;  \r
+  zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);\r
+  zzresynch(setwd9, 0x10);\r
+  return _retv;\r
+  }\r
+}\r
+\r
+ExceptionHandler *\r
+#ifdef __USE_PROTOS\r
+exception_handler(void)\r
+#else\r
+exception_handler()\r
+#endif\r
+{\r
+  ExceptionHandler *   _retv;\r
+  zzRULE;\r
+  zzBLOCK(zztasp1);\r
+  PCCTS_PURIFY(_retv,sizeof(ExceptionHandler *  ))\r
+  zzMake0;\r
+  {\r
+  ;\r
+  zzmatch(135);\r
+  \r
+  _retv = (ExceptionHandler *)calloc(1, sizeof(ExceptionHandler));\r
+  require(_retv!=NULL, "exception: cannot allocate handler");\r
+ zzCONSUME;\r
+\r
+  {\r
+    zzBLOCK(zztasp2);\r
+    zzMake0;\r
+    {\r
+    if ( (LA(1)==NonTerminal) ) {\r
+      zzmatch(NonTerminal);\r
+      \r
+      _retv->signalname = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));\r
+      require(_retv->signalname!=NULL, "exception: cannot allocate sig name");\r
+      strcpy(_retv->signalname, LATEXT(1));\r
+ zzCONSUME;\r
+\r
+    }\r
+    else {\r
+      if ( (LA(1)==TokenTerm) ) {\r
+        zzmatch(TokenTerm);\r
+        \r
+        _retv->signalname = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));\r
+        require(_retv->signalname!=NULL, "exception: cannot allocate sig name");\r
+        strcpy(_retv->signalname, LATEXT(1));\r
+ zzCONSUME;\r
+\r
+      }\r
+      else {zzFAIL(1,zzerr56,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
+    }\r
+    zzEXIT(zztasp2);\r
+    }\r
+  }\r
+  zzmatch(106); zzCONSUME;\r
+  {\r
+    zzBLOCK(zztasp2);\r
+    zzMake0;\r
+    {\r
+    _retv->action = NULL;\r
+    if ( (LA(1)==Action) ) {\r
+      zzmatch(Action);\r
+      \r
+      _retv->action = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));\r
+      require(_retv->action!=NULL, "exception: cannot allocate action");\r
+      strcpy(_retv->action, LATEXT(1));\r
+ zzCONSUME;\r
+\r
+    }\r
+    else {\r
+      if ( (setwd9[LA(1)]&0x20) ) {\r
+      }\r
+      else {zzFAIL(1,zzerr57,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
+    }\r
+    zzEXIT(zztasp2);\r
+    }\r
+  }\r
+  zzEXIT(zztasp1);\r
+  return _retv;\r
+fail:\r
+  zzEXIT(zztasp1);\r
+  CannotContinue=TRUE;  \r
+  zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);\r
+  zzresynch(setwd9, 0x40);\r
+  return _retv;\r
+  }\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+enum_file(char * fname)\r
+#else\r
+enum_file(fname)\r
+ char *fname ;\r
+#endif\r
+{\r
+  zzRULE;\r
+  zzBLOCK(zztasp1);\r
+  zzMake0;\r
+  {\r
+  if ( (setwd9[LA(1)]&0x80) ) {\r
+    {\r
+      zzBLOCK(zztasp2);\r
+      zzMake0;\r
+      {\r
+      if ( (LA(1)==143) ) {\r
+        zzmatch(143); zzCONSUME;\r
+        zzmatch(ID); zzCONSUME;\r
+        {\r
+          zzBLOCK(zztasp3);\r
+          zzMake0;\r
+          {\r
+          if ( (LA(1)==149) ) {\r
+            zzmatch(149); zzCONSUME;\r
+            zzmatch(ID); zzCONSUME;\r
+          }\r
+          else {\r
+            if ( (setwd10[LA(1)]&0x1) ) {\r
+            }\r
+            else {zzFAIL(1,zzerr58,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
+          }\r
+          zzEXIT(zztasp3);\r
+          }\r
+        }\r
+      }\r
+      else {\r
+        if ( (setwd10[LA(1)]&0x2) ) {\r
+        }\r
+        else {zzFAIL(1,zzerr59,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
+      }\r
+      zzEXIT(zztasp2);\r
+      }\r
+    }\r
+    {\r
+      zzBLOCK(zztasp2);\r
+      zzMake0;\r
+      {\r
+      if ( (LA(1)==151) ) {\r
+        {\r
+          zzBLOCK(zztasp3);\r
+          int zzcnt=1;\r
+          zzMake0;\r
+          {\r
+          do {\r
+            enum_def(  fname );\r
+            zzLOOP(zztasp3);\r
+          } while ( (LA(1)==151) );\r
+          zzEXIT(zztasp3);\r
+          }\r
+        }\r
+      }\r
+      else {\r
+        if ( (LA(1)==149) ) {\r
+          defines(  fname );\r
+        }\r
+        else {zzFAIL(1,zzerr60,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
+      }\r
+      zzEXIT(zztasp2);\r
+      }\r
+    }\r
+  }\r
+  else {\r
+    if ( (LA(1)==Eof) ) {\r
+    }\r
+    else {zzFAIL(1,zzerr61,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
+  }\r
+  zzEXIT(zztasp1);\r
+  return;\r
+fail:\r
+  zzEXIT(zztasp1);\r
+  zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);\r
+  zzresynch(setwd10, 0x4);\r
+  }\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+defines(char * fname)\r
+#else\r
+defines(fname)\r
+ char *fname ;\r
+#endif\r
+{\r
+  zzRULE;\r
+  zzBLOCK(zztasp1);\r
+  zzMake0;\r
+  {\r
+  int v; int maxt=(-1); char *t;\r
+  {\r
+    zzBLOCK(zztasp2);\r
+    int zzcnt=1;\r
+    zzMake0;\r
+    {\r
+    do {\r
+      zzmatch(149); zzCONSUME;\r
+      zzmatch(ID);\r
+      t = mystrdup(LATEXT(1));\r
+ zzCONSUME;\r
+\r
+      zzmatch(INT);\r
+      \r
+      v = atoi(LATEXT(1));\r
+      /*                       fprintf(stderr, "#token %s=%d\n", t, v);*/\r
+      \r
+       /* MR2 Andreas Magnusson (Andreas.Magnusson@mailbox.swipnet.se) */\r
+      /* MR2 Fix to bug introduced by 1.33MR1 for #tokdefs            */\r
+      /* MR2 Don't let #tokdefs be confused by                         */\r
+      /* MR2   DLGminToken and DLGmaxToken                             */\r
+      \r
+                       if ( ! isDLGmaxToken(t)) {              /* MR2 */\r
+      TokenNum = v;\r
+      if ( v>maxt ) maxt=v;\r
+      if ( Tnum( t ) == 0 ) {\r
+      addForcedTname( t, v );\r
+    } else {\r
+    warnFL(eMsg1("redefinition of token %s; ignored",t), fname,zzline);\r
+  };\r
+};\r
+ zzCONSUME;\r
+\r
+      zzLOOP(zztasp2);\r
+    } while ( (LA(1)==149) );\r
+    zzEXIT(zztasp2);\r
+    }\r
+  }\r
+  TokenNum = maxt + 1;\r
+  zzEXIT(zztasp1);\r
+  return;\r
+fail:\r
+  zzEXIT(zztasp1);\r
+  zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);\r
+  zzresynch(setwd10, 0x8);\r
+  }\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+enum_def(char * fname)\r
+#else\r
+enum_def(fname)\r
+ char *fname ;\r
+#endif\r
+{\r
+  zzRULE;\r
+  zzBLOCK(zztasp1);\r
+  zzMake0;\r
+  {\r
+  int v= 0; int maxt=(-1); char *t;\r
+  zzmatch(151); zzCONSUME;\r
+  zzmatch(ID); zzCONSUME;\r
+  zzmatch(152); zzCONSUME;\r
+  zzmatch(ID);\r
+  t = mystrdup(LATEXT(1));\r
+ zzCONSUME;\r
+\r
+  {\r
+    zzBLOCK(zztasp2);\r
+    zzMake0;\r
+    {\r
+    if ( (LA(1)==153) ) {\r
+      zzmatch(153); zzCONSUME;\r
+      zzmatch(INT);\r
+      v=atoi(LATEXT(1));\r
+ zzCONSUME;\r
+\r
+    }\r
+    else {\r
+      if ( (setwd10[LA(1)]&0x10) ) {\r
+        v++;\r
+      }\r
+      else {zzFAIL(1,zzerr62,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
+    }\r
+    zzEXIT(zztasp2);\r
+    }\r
+  }\r
+  \r
+  /*                   fprintf(stderr, "#token %s=%d\n", t, v);*/\r
+  TokenNum = v;\r
+  if ( v>maxt ) maxt=v;                                /* MR3 */\r
+  if ( Tnum( t ) == 0 ) addForcedTname( t, v );\r
+  else {\r
+    warnFL(eMsg1("redefinition of token %s; ignored",t), fname,zzline);\r
+  }\r
+  {\r
+    zzBLOCK(zztasp2);\r
+    zzMake0;\r
+    {\r
+    while ( (LA(1)==154) ) {\r
+      zzmatch(154); zzCONSUME;\r
+      {\r
+        zzBLOCK(zztasp3);\r
+        zzMake0;\r
+        {\r
+        if ( (LA(1)==ID)&&(isDLGmaxToken(LATEXT(1))) ) {\r
+          if (!(isDLGmaxToken(LATEXT(1)))            ) {zzfailed_pred("  isDLGmaxToken(LATEXT(1))",0 /* report */, { 0; /* no user action */ } );}\r
+          zzmatch(ID); zzCONSUME;\r
+          {\r
+            zzBLOCK(zztasp4);\r
+            zzMake0;\r
+            {\r
+            if ( (LA(1)==153) ) {\r
+              zzmatch(153); zzCONSUME;\r
+              zzmatch(INT); zzCONSUME;\r
+            }\r
+            else {\r
+              if ( (setwd10[LA(1)]&0x20) ) {\r
+              }\r
+              else {zzFAIL(1,zzerr63,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
+            }\r
+            zzEXIT(zztasp4);\r
+            }\r
+          }\r
+        }\r
+        else {\r
+          if ( (LA(1)==ID) ) {\r
+            zzmatch(ID);\r
+            t = mystrdup(LATEXT(1));\r
+ zzCONSUME;\r
+\r
+            {\r
+              zzBLOCK(zztasp4);\r
+              zzMake0;\r
+              {\r
+              if ( (LA(1)==153) ) {\r
+                zzmatch(153); zzCONSUME;\r
+                zzmatch(INT);\r
+                v=atoi(LATEXT(1));\r
+ zzCONSUME;\r
+\r
+              }\r
+              else {\r
+                if ( (setwd10[LA(1)]&0x40) ) {\r
+                  v++;\r
+                }\r
+                else {zzFAIL(1,zzerr64,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
+              }\r
+              zzEXIT(zztasp4);\r
+              }\r
+            }\r
+            \r
+            /*                                 fprintf(stderr, "#token %s=%d\n", t, v);*/\r
+            TokenNum = v;\r
+            if ( v>maxt ) maxt=v;                              /* MR3 */\r
+            if ( Tnum( t ) == 0 ) addForcedTname( t, v );\r
+            else {\r
+              warnFL(eMsg1("redefinition of token %s; ignored",t), fname,zzline);\r
+            }\r
+          }\r
+          else {\r
+            if ( (setwd10[LA(1)]&0x80) ) {\r
+            }\r
+            else {zzFAIL(1,zzerr65,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
+          }\r
+        }\r
+        zzEXIT(zztasp3);\r
+        }\r
+      }\r
+      zzLOOP(zztasp2);\r
+    }\r
+    zzEXIT(zztasp2);\r
+    }\r
+  }\r
+  zzmatch(155); zzCONSUME;\r
+  zzmatch(156);\r
+  TokenNum = maxt + 1;\r
+ zzCONSUME;\r
+\r
+  zzEXIT(zztasp1);\r
+  return;\r
+fail:\r
+  zzEXIT(zztasp1);\r
+  zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);\r
+  zzresynch(setwd11, 0x1);\r
+  }\r
+}\r
+\r
+\r
+/* MR2 Andreas Magnusson (Andreas.Magnusson@mailbox.swipnet.se) */\r
+/* MR2 Fix to bug introduced by 1.33MR1 for #tokdefs            */\r
+/* MR2 Don't let #tokdefs be confused by                       */\r
+/* MR2   DLGminToken and DLGmaxToken                           */\r
+\r
+/* semantic check on DLGminToken and DLGmaxmaxToken in #tokdefs */\r
+\r
+#ifdef __USE_PROTOS\r
+static int isDLGmaxToken(char *Token)\r
+#else\r
+static int isDLGmaxToken(Token)\r
+char * Token;\r
+#endif\r
+{\r
+static char checkStr1[] = "DLGmaxToken";\r
+static char checkStr2[] = "DLGminToken";\r
+\r
+   if (strcmp(Token, checkStr1) == 0)\r
+return 1;\r
+else if (strcmp(Token, checkStr2) == 0)\r
+return 1;\r
+else\r
+return 0;\r
+}\r
+\r
+/* semantics of #token */\r
+static void\r
+#ifdef __USE_PROTOS\r
+chkToken(char *t, char *e, char *a, int tnum)\r
+#else\r
+chkToken(t,e,a,tnum)\r
+char *t, *e, *a;\r
+int tnum;\r
+#endif\r
+{\r
+TermEntry *p;\r
+\r
+       /* check to see that they don't try to redefine a token as a token class */\r
+if ( t!=NULL ) {\r
+p = (TermEntry *) hash_get(Tname, t);\r
+if ( p!=NULL && p->classname ) {\r
+  err(eMsg1("redefinition of #tokclass '%s' to #token not allowed; ignored",t));\r
+  if ( a!=NULL ) free((char *)a);\r
+  return;\r
+}\r
+}\r
+\r
+       if ( t==NULL && e==NULL ) {                     /* none found */\r
+err("#token requires at least token name or rexpr");\r
+}\r
+else if ( t!=NULL && e!=NULL ) {       /* both found */\r
+if ( UserDefdTokens ) {                        /* if #tokdefs, must not define new */\r
+  p = (TermEntry *) hash_get(Tname, t);\r
+  if ( p == NULL) {\r
+    err(eMsg1("new token definition '%s' not allowed - only #token with name already defined by #tokdefs file allowed",t));\r
+    return;\r
+  };\r
+}\r
+Tklink(t, e);\r
+if ( a!=NULL ) {\r
+  if ( hasAction(e) ) {\r
+    err(eMsg1("redefinition of action for %s; ignored",e));\r
+  }\r
+  else setHasAction(e, a);\r
+}\r
+}\r
+else if ( t!=NULL ) {                          /* only one found */\r
+if ( UserDefdTokens ) {\r
+  p = (TermEntry *) hash_get(Tname, t);\r
+  if (p == NULL) {\r
+    err(eMsg1("new token definition '%s' not allowed - only #token with name already defined by #tokdefs file allowed",t));\r
+  };\r
+  return;\r
+}\r
+if ( Tnum( t ) == 0 ) addTname( t );\r
+else {\r
+  err(eMsg1("redefinition of token %s; ignored",t));\r
+}\r
+if ( a!=NULL ) {\r
+  err(eMsg1("action cannot be attached to a token name (%s); ignored",t));\r
+  free((char *)a);\r
+}\r
+}\r
+else if ( e!=NULL ) {\r
+if ( Tnum( e ) == 0 ) addTexpr( e );\r
+else {\r
+  if ( hasAction(e) ) {\r
+    err(eMsg1("redefinition of action for expr %s; ignored",e));\r
+  }\r
+  else if ( a==NULL ) {\r
+    err(eMsg1("redefinition of expr %s; ignored",e));\r
+  }\r
+}\r
+if ( a!=NULL ) setHasAction(e, a);\r
+}\r
+\r
+       /* if a token type number was specified, then add the token ID and 'tnum'\r
+* pair to the ForcedTokens list.  (only applies if an id was given)\r
+*/\r
+if ( t!=NULL && tnum>0 )\r
+{\r
+if ( set_el(tnum, reserved_positions) )\r
+{\r
+  err(eMsgd("a token has already been forced to token number %d; ignored", tnum));\r
+}\r
+else\r
+{\r
+  list_add(&ForcedTokens, newForcedToken(t,tnum));\r
+  set_orel(tnum, &reserved_positions);\r
+}\r
+}\r
+}\r
+\r
+static int\r
+#ifdef __USE_PROTOS\r
+match_token(char *s, char **nxt)\r
+#else\r
+match_token(s,nxt)\r
+char *s;\r
+char **nxt;\r
+#endif\r
+{\r
+  if ( !(*s>='A' && *s<='Z') ) return 0;\r
+  s++;\r
+  while ( (*s>='a' && *s<='z') ||\r
+  (*s>='A' && *s<='Z') ||\r
+  (*s>='0' && *s<='9') ||\r
+  *s=='_' )\r
+  {\r
+    s++;\r
+  }\r
+  if ( *s!=' ' && *s!='}' ) return 0;\r
+  *nxt = s;\r
+  return 1;\r
+}\r
+\r
+static int\r
+#ifdef __USE_PROTOS\r
+match_rexpr(char *s, char **nxt)\r
+#else\r
+match_rexpr(s,nxt)\r
+char *s;\r
+char **nxt;\r
+#endif\r
+{\r
+  if ( *s!='"' ) return 0;\r
+  s++;\r
+  while ( *s!='"' )\r
+  {\r
+    if ( *s=='\n' || *s=='\r' )                   /* MR13 */\r
+    warn("eoln found in regular expression");\r
+    if ( *s=='\\' ) s++;\r
+    s++;\r
+  }\r
+  *nxt = s+1;\r
+  return 1;\r
+}\r
+\r
+/*\r
+* Walk a string "{ A .. Z }" where A..Z is a space separated list\r
+* of token references (either labels or reg exprs).  Return a\r
+* string "inlineX_set" for some unique integer X.  Basically,\r
+* we pretend as if we had seen "#tokclass inlineX { A .. Z }"\r
+* on the input stream outside of an action.\r
+*/\r
+char *\r
+#ifdef __USE_PROTOS\r
+inline_set(char *s)\r
+#else\r
+inline_set(s)\r
+char *s;\r
+#endif\r
+{\r
+  char *nxt;\r
+  fprintf(stderr, "found consumeUntil( {...} )\n");\r
+  while ( *s==' ' || *s=='\t' || *s=='\n' || *s=='\r' ) {s++;}\r
+  if ( *s!='{' )\r
+  {\r
+    err("malformed consumeUntil( {...} ); missing '{'");\r
+    return "bad_set";\r
+  }\r
+  s++;\r
+  while ( *s==' ' || *s=='\t' || *s=='\n' || *s=='\r' ) {s++;}\r
+  while ( *s!='}' )\r
+  {\r
+    if ( match_token(s,&nxt) ) fprintf(stderr, "found token %s\n", s);\r
+    else if ( match_rexpr(s,&nxt) ) fprintf(stderr, "found rexpr %s\n", s);\r
+    else {\r
+      err("invalid element in consumeUntil( {...} )");\r
+      return "bad_set";\r
+    }\r
+    s = nxt;\r
+    while ( *s==' ' || *s=='\t' || *s=='\n' || *s=='\r' ) {s++;}\r
+  }\r
+  return "inlineX_set";\r
+}\r
+\r
+/* ANTLR-specific syntax error message generator\r
+* (define USER_ZZSYN when compiling so don't get 2 definitions)\r
+*/\r
+void\r
+#ifdef __USE_PROTOS\r
+zzsyn(char *text, int tok, char *egroup, SetWordType *eset, int etok,\r
+int k, char *bad_text)\r
+#else\r
+zzsyn(text, tok, egroup, eset, etok, k, bad_text)\r
+char *text, *egroup, *bad_text;\r
+int tok;\r
+int etok;\r
+int k;\r
+SetWordType *eset;\r
+#endif\r
+{\r
+fprintf(stderr, ErrHdr, FileStr[CurFile]!=NULL?FileStr[CurFile]:"stdin", zzline);\r
+fprintf(stderr, " syntax error at \"%s\"", (tok==zzEOF_TOKEN)?"EOF":text);\r
+if ( !etok && !eset ) {fprintf(stderr, "\n"); return;}\r
+if ( k==1 ) fprintf(stderr, " missing");\r
+else\r
+{\r
+fprintf(stderr, "; \"%s\" not", bad_text);\r
+if ( zzset_deg(eset)>1 ) fprintf(stderr, " in");\r
+}\r
+if ( zzset_deg(eset)>0 ) zzedecode(eset);\r
+else fprintf(stderr, " %s", zztokens[etok]);\r
+if ( strlen(egroup) > (size_t)0 ) fprintf(stderr, " in %s", egroup);\r
+fprintf(stderr, "\n");\r
+}\r
diff --git a/Tools/CodeTools/Source/Pccts/antlr/antlr.g b/Tools/CodeTools/Source/Pccts/antlr/antlr.g
new file mode 100644 (file)
index 0000000..e6eda60
--- /dev/null
@@ -0,0 +1,2586 @@
+/*\r
+ * antlr.g     --      PCCTS Version 1.xx ANTLR\r
+ *\r
+ * Parse an antlr input grammar and build a syntax-diagram.\r
+ *\r
+ * Written in itself (needs at least 1.06 to work)\r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
+ * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
+ * company may do whatever they wish with source code distributed with\r
+ * PCCTS or the code generated by PCCTS, including the incorporation of\r
+ * PCCTS, or its output, into commerical software.\r
+ *\r
+ * We encourage users to develop software with PCCTS.  However, we do ask\r
+ * that credit is given to us for developing PCCTS.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like PCCTS and have developed a nice tool with the\r
+ * output, please mention that you developed it using PCCTS.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * ANTLR 1.33\r
+ * Terence Parr\r
+ * Parr Research Corporation\r
+ * with Purdue University and AHPCRC, University of Minnesota\r
+ * 1989-1995\r
+ */\r
+\r
+/* MR1                                                                 */\r
+/* MR1 10-Apr-97 MR1   Replace #if logic with #include "pcctscfg.h"    */\r
+/* MR1                                                                 */\r
+\r
+#header <<\r
+       #include "pcctscfg.h"\r
+       #include "set.h"\r
+       #include <ctype.h>\r
+       #include "syn.h"\r
+       #include "hash.h"\r
+       #include "generic.h"\r
+       #define zzcr_attr(attr,tok,t)\r
+       >>\r
+\r
+<<\r
+\r
+/* MR20 G. Hobbelt For Borland C++ 4.x & 5.x compiling with ALL warnings enabled */\r
+#if defined(__TURBOC__)\r
+#pragma warn -aus  /* unused assignment of 'xxx' */\r
+#endif\r
+\r
+\r
+#ifdef __USE_PROTOS\r
+static void chkToken(char *, char *, char *, int);\r
+#else\r
+static void chkToken();\r
+#endif\r
+\r
+#ifdef __USE_PROTOS\r
+static int isDLGmaxToken(char *Token);                              /* MR3 */\r
+#else\r
+static int isDLGmaxToken();                                                         /* MR3 */\r
+#endif\r
+\r
+static int class_nest_level = 0;\r
+\r
+/* MR20 G. Hobbelt extern definitions moved to antlr.h */\r
+\r
+>>\r
+\r
+#lexaction <<\r
+/* maintained, but not used for now */\r
+set AST_nodes_refd_in_actions = set_init;\r
+int inAlt = 0;\r
+set attribsRefdFromAction = set_init; /* MR20 */\r
+int UsedOldStyleAttrib = 0;\r
+int UsedNewStyleLabel = 0;\r
+#ifdef __USE_PROTOS\r
+char *inline_set(char *);\r
+#else\r
+char *inline_set();\r
+#endif\r
+\r
+/* MR1 10-Apr-97  MR1  Previously unable to put right shift operator       */\r
+/* MR1                                 in DLG action                                       */\r
+\r
+int tokenActionActive=0;                                            /* MR1 */\r
+\r
+>>\r
+\r
+#lexclass STRINGS\r
+#token QuotedTerm "\""         << zzmode(START); >>\r
+#token "\n|\r|\r\n"            <<\r
+                                                       zzline++;\r
+                                                       warn("eoln found in string");\r
+                                                       zzskip();\r
+                                                       >>\r
+#token "\\(\n|\r|\r\n)"                << zzline++; zzmore(); >>\r
+#token "\\~[]"                         << zzmore(); >>\r
+#token "~[\n\r\"\\]+"          << zzmore(); >>\r
+\r
+#lexclass ACTION_STRINGS\r
+#token "\""                                    << zzmode(ACTIONS); zzmore(); >>\r
+#token "\n|\r|\r\n"                    <<\r
+                                                       zzline++;\r
+                                                       warn("eoln found in string (in user action)");\r
+                                                       zzskip();\r
+                                                       >>\r
+#token "\\(\n|\r|\r\n)"                << zzline++; zzmore(); >>\r
+#token "\\~[]"                         << zzmore(); >>\r
+#token "~[\n\r\"\\]+"                  << zzmore(); >>\r
+\r
+#lexclass ACTION_CHARS\r
+#token "'"                                     << zzmode(ACTIONS); zzmore(); >>\r
+#token "\n|\r|\r\n"                    <<\r
+                                                       zzline++;\r
+                                                       warn("eoln found in char literal (in user action)");\r
+                                                       zzskip();\r
+                                                       >>\r
+#token "\\~[]"                         << zzmore(); >>\r
+#token "~[\n\r'\\]+"           << zzmore(); >>\r
+\r
+#lexclass ACTION_COMMENTS\r
+#token "\*/"                           << zzmode(ACTIONS); zzmore(); >>\r
+#token "\*"                                    << zzmore(); >>\r
+#token "\n|\r|\r\n"                    << zzline++; zzmore(); DAWDLE; >>\r
+#token "~[\n\r\*]+"                    << zzmore(); >>\r
+\r
+#lexclass TOK_DEF_COMMENTS\r
+#token "\*/"                           << zzmode(PARSE_ENUM_FILE);\r
+                              zzmore(); >>\r
+#token "\*"                                    << zzmore(); >>\r
+#token "\n|\r|\r\n"                    << zzline++; zzmore(); DAWDLE; >>\r
+#token "~[\n\r\*]+"                    << zzmore(); >>\r
+\r
+#lexclass TOK_DEF_CPP_COMMENTS\r
+#token "\n|\r|\r\n"                    << zzline++; zzmode(PARSE_ENUM_FILE); zzskip(); DAWDLE; >>\r
+#token "~[\n\r]+"                      << zzskip(); >>\r
+\r
+#lexclass ACTION_CPP_COMMENTS\r
+#token "\n|\r|\r\n"                    << zzline++; zzmode(ACTIONS); zzmore(); DAWDLE; >>\r
+#token "~[\n\r]+"                      << zzmore(); >>\r
+\r
+#lexclass CPP_COMMENTS\r
+#token "\n|\r|\r\n"                    << zzline++; zzmode(START); zzskip(); DAWDLE; >>\r
+#token "~[\n\r]+"                      << zzskip(); >>\r
+\r
+#lexclass COMMENTS\r
+#token "\*/"                           << zzmode(START); zzskip(); >>\r
+#token "\*"                                    << zzskip(); >>\r
+#token "\n|\r|\r\n"                    << zzline++; zzskip(); DAWDLE; >>\r
+#token "~[\n\r\*]+"                    << zzskip(); >>\r
+\r
+/*\r
+ * This lexical class accepts actions of type [..] and <<..>>\r
+ *\r
+ * It translates the following special items for C:\r
+ *\r
+ * $j          --> "zzaArg(current zztasp, j)"\r
+ * $i.j                --> "zzaArg(zztaspi, j)"\r
+ * $i.nondigit> "zzaArg(current zztasp, i).nondigit"\r
+ * $$          --> "zzaRet"\r
+ * $alnum      --> "alnum"                     (used to ref parameters)\r
+ * $rule       --> "zzaRet"\r
+ * $retval     --> "_retv.retval" if > 1 return values else "_retv"\r
+ * $[token, text] --> "zzconstr_attr(token, text)"\r
+ * $[]         --> "zzempty_attr()"\r
+ *\r
+ * It translates the following special items for C++:\r
+ * (attributes are now stored with 'Token' and $i's are only\r
+ *  pointers to the Tokens.  Rules don't have attributes now.)\r
+ *\r
+ * $j          --> "_tbj" where b is the block level\r
+ * $i.j                --> "_tij"\r
+ * $j->nondigit> "_tbj->nondigit"\r
+ * $$          --> "$$"\r
+ * $alnum      --> "alnum"                     (used to ref parameters)\r
+ * $rule       --> "$rule"\r
+ * $retval     --> "_retv.retval" if > 1 return values else "_retv"\r
+ * $[token, text] --> invalid\r
+ * $[]         --> invalid\r
+ *\r
+ * And, for trees:\r
+ *\r
+ * #0          -->     "(*_root)"\r
+ * #i          --> "zzastArg(i)"\r
+ * #[args]     --> "zzmk_ast(zzastnew(), args)"\r
+ * #[]         --> "zzastnew()"\r
+ * #( root, child1, ..., childn )\r
+ *                     --> "zztmake(root, child1, ...., childn, NULL)"\r
+ * #()         --> "NULL"\r
+ *\r
+ * For C++, ...\r
+ *\r
+ * #0          -->     "(*_root)"\r
+ * #i          --> "_astbi" where b is the block level\r
+ * #alnum      --> "alnum_ast" (used to ref #label)\r
+ * #[args]     --> "new AST(args)"\r
+ * #[]         --> "new AST"\r
+ * #( root, child1, ..., childn )\r
+ *                     --> "AST::tmake(root, child1, ...., childn, NULL)"\r
+ * #()         --> "NULL"\r
+ *\r
+ * To escape,\r
+ *\r
+ * \]          --> ]\r
+ * \)          --> )\r
+ * \$          --> $\r
+ * \#          --> #\r
+ *\r
+ * A stack is used to nest action terminators because they can be nested\r
+ * like crazy:  << #[$[..],..] >>\r
+ */\r
+#lexclass ACTIONS\r
+#token Action "\>\>"        << /* these do not nest */\r
+                              zzmode(START);\r
+                              NLATEXT[0] = ' ';\r
+                              NLATEXT[1] = ' ';\r
+                              zzbegexpr[0] = ' ';\r
+                              zzbegexpr[1] = ' ';\r
+                                                         if ( zzbufovf ) {\r
+                                                               err( eMsgd("action buffer overflow; size %d",ZZLEXBUFSIZE));\r
+                                                         }\r
+\r
+/* MR1 10-Apr-97  MR1  Previously unable to put right shift operator   */\r
+/* MR1                                 in DLG action                   */\r
+/* MR1                 Doesn't matter what kind of action it is - reset*/\r
+\r
+                             tokenActionActive=0;               /* MR1 */\r
+                            >>\r
+#token Pred "\>\>?"                    << /* these do not nest */\r
+                              zzmode(START);\r
+                              NLATEXT[0] = ' ';\r
+                              NLATEXT[1] = ' ';\r
+                              zzbegexpr[0] = '\0';\r
+                                                         if ( zzbufovf ) {\r
+                                                               err( eMsgd("predicate buffer overflow; size %d",ZZLEXBUFSIZE));\r
+                                                         };\r
+#ifdef __cplusplus__\r
+/* MR10 */                    list_apply(CurActionLabels, (void (*)(void *))mark_label_used_in_sem_pred);\r
+#else\r
+#ifdef __STDC__\r
+/* MR10 */                    list_apply(CurActionLabels, (void (*)(void *))mark_label_used_in_sem_pred);\r
+#else\r
+#ifdef __USE_PROTOS\r
+/* MRxx */                    list_apply(CurActionLabels, (void (*)(void *))mark_label_used_in_sem_pred);\r
+#else\r
+/* MR10 */                    list_apply(CurActionLabels,mark_label_used_in_sem_pred);\r
+#endif\r
+#endif\r
+#endif\r
+                            >>\r
+#token PassAction "\]"         << if ( topint() == ']' ) {\r
+                                                                 popint();\r
+                                                                 if ( istackempty() )  /* terminate action */\r
+                                                                 {\r
+                                                                         zzmode(START);\r
+                                                                         NLATEXT[0] = ' ';\r
+                                                                         zzbegexpr[0] = ' ';\r
+                                                                         if ( zzbufovf ) {\r
+                                                                               err( eMsgd("parameter buffer overflow; size %d",ZZLEXBUFSIZE));\r
+                                                                         }\r
+                                                                 }\r
+                                                                 else {\r
+                                                                         /* terminate $[..] and #[..] */\r
+                                                                         if ( GenCC ) zzreplstr("))");\r
+                                                                         else zzreplstr(")");\r
+                                                                         zzmore();\r
+                                                                 }\r
+                                                          }\r
+                                                          else if ( topint() == '|' ) { /* end of simple [...] */\r
+                                                                 popint();\r
+                                                                 zzmore();\r
+                                                          }\r
+                                                          else zzmore();\r
+                                                       >>\r
+#token "consumeUntil\( [\ \t]* \{~[\}]+\} [\ \t]* \)"\r
+                                                       <<\r
+                                                       zzmore();\r
+                                                       zzreplstr(inline_set(zzbegexpr+\r
+                                                                         strlen("consumeUntil(")));\r
+                                                       >>\r
+#token "consumeUntil\( ~[\)]+ \)"\r
+                                                       << zzmore(); >>\r
+#token "\n|\r|\r\n"                    << zzline++; zzmore(); DAWDLE; >>\r
+#token "\>"                                    << zzmore(); >>\r
+#token "$"                                     << zzmore(); >>\r
+#token "$$"                                    << if ( !GenCC ) {zzreplstr("zzaRet"); zzmore();}\r
+                                                          else err("$$ use invalid in C++ mode"); >>\r
+\r
+#token "$\[\]"                         << if ( !GenCC ) {zzreplstr("zzempty_attr"); zzmore();}\r
+                                                          else err("$[] use invalid in C++ mode"); >>\r
+#token "$\["                           <<\r
+                                                       pushint(']');\r
+                                                       if ( !GenCC ) zzreplstr("zzconstr_attr(");\r
+                                                       else err("$[..] use invalid in C++ mode");\r
+                                                       zzmore();\r
+                                                       >>\r
+#token "$[0-9]+"                       <<{\r
+                                                       static char buf[100];\r
+                            numericActionLabel=1;       /* MR10 */\r
+                                                       if ( strlen(zzbegexpr)>(size_t)85 )\r
+                                                               fatal("$i attrib ref too big");\r
+                                                       set_orel(atoi(zzbegexpr+1), &attribsRefdFromAction);\r
+                                                       if ( !GenCC ) sprintf(buf,"zzaArg(zztasp%d,%s)",\r
+                                                                               BlkLevel-1,zzbegexpr+1);\r
+                                                       else sprintf(buf,"_t%d%s",\r
+                                                                               BlkLevel-1,zzbegexpr+1);\r
+                                                       zzreplstr(buf);\r
+                                                       zzmore();\r
+                                                       UsedOldStyleAttrib = 1;\r
+                                                       if ( UsedNewStyleLabel )\r
+                                                               err("cannot mix old-style $i with new-style labels");\r
+                                                       }\r
+                                                       >>\r
+#token "$[0-9]+."                      <<{\r
+                                                       static char buf[100];\r
+                            numericActionLabel=1;       /* MR10 */\r
+                                                       if ( strlen(zzbegexpr)>(size_t)85 )\r
+                                                               fatal("$i.field attrib ref too big");\r
+                                                       zzbegexpr[strlen(zzbegexpr)-1] = ' ';\r
+                                                       set_orel(atoi(zzbegexpr+1), &attribsRefdFromAction);\r
+                                                       if ( !GenCC ) sprintf(buf,"zzaArg(zztasp%d,%s).",\r
+                                                                               BlkLevel-1,zzbegexpr+1);\r
+                                                       else sprintf(buf,"_t%d%s.",\r
+                                                                               BlkLevel-1,zzbegexpr+1);\r
+                                                       zzreplstr(buf);\r
+                                                       zzmore();\r
+                                                       UsedOldStyleAttrib = 1;\r
+                                                       if ( UsedNewStyleLabel )\r
+                                                               err("cannot mix old-style $i with new-style labels");\r
+                                                       }\r
+                                                       >>\r
+#token "$[0-9]+.[0-9]+"                <<{\r
+                                                       static char buf[100];\r
+                                                       static char i[20], j[20];\r
+                                                       char *p,*q;\r
+                            numericActionLabel=1;       /* MR10 */\r
+                                                       if (strlen(zzbegexpr)>(size_t)85) fatal("$i.j attrib ref too big");\r
+                                                       for (p=zzbegexpr+1,q= &i[0]; *p!='.'; p++) {\r
+                                                               if ( q == &i[20] )\r
+                                                                        fatalFL("i of $i.j attrib ref too big",\r
+                                                                                        FileStr[CurFile], zzline );\r
+                                                               *q++ = *p;\r
+                                                       }\r
+                                                       *q = '\0';\r
+                                                       for (p++, q= &j[0]; *p!='\0'; p++) {\r
+                                                               if ( q == &j[20] )\r
+                                                                       fatalFL("j of $i.j attrib ref too big",\r
+                                                                                       FileStr[CurFile], zzline );\r
+                                                               *q++ = *p;\r
+                                                       }\r
+                                                       *q = '\0';\r
+                                                       if ( !GenCC ) sprintf(buf,"zzaArg(zztasp%s,%s)",i,j);\r
+                                                       else sprintf(buf,"_t%s%s",i,j);\r
+                                                       zzreplstr(buf);\r
+                                                       zzmore();\r
+                                                       UsedOldStyleAttrib = 1;\r
+                                                       if ( UsedNewStyleLabel )\r
+                                                               err("cannot mix old-style $i with new-style labels");\r
+                                                       }\r
+                                                       >>\r
+#token "$[_a-zA-Z][_a-zA-Z0-9]*"\r
+                                                       <<{ static char buf[300]; LabelEntry *el;\r
+                                                       zzbegexpr[0] = ' ';\r
+                                                       if ( CurRule != NULL &&\r
+                                                                strcmp(CurRule, &zzbegexpr[1])==0 ) {\r
+                                                               if ( !GenCC ) zzreplstr("zzaRet");\r
+                                                       }\r
+                                                       else if ( CurRetDef != NULL &&\r
+                                                                         strmember(CurRetDef, &zzbegexpr[1])) {\r
+                                                                if ( hasMultipleOperands( CurRetDef ) ) {\r
+                                                                       require (strlen(zzbegexpr)<=(size_t)285,\r
+                                                                                        "$retval attrib ref too big");\r
+                                                                       sprintf(buf,"_retv.%s",&zzbegexpr[1]);\r
+                                                                       zzreplstr(buf);\r
+                                                               }\r
+                                                               else zzreplstr("_retv");\r
+                                                       }\r
+                                                       else if ( CurParmDef != NULL &&\r
+                                                                         strmember(CurParmDef, &zzbegexpr[1])) {\r
+                                                               ;\r
+                                                       }\r
+                                                       else if ( Elabel==NULL ) {\r
+                                                               { err("$-variables in actions outside of rules are not allowed"); }\r
+                                                       } else if ( (el=(LabelEntry *)hash_get(Elabel, &zzbegexpr[1]))!=NULL ) {\r
+/* MR10 */\r
+/* MR10 */                      /* element labels might exist without an elem when */\r
+/* MR10 */                      /*  it is a forward reference (to a rule)          */\r
+/* MR10 */\r
+/* MR10 */                                             if ( GenCC && (el->elem == NULL || el->elem->ntype==nRuleRef) )\r
+/* MR10 */                                                     { err(eMsg1("There are no token ptrs for rule references: '$%s'",&zzbegexpr[1])); }\r
+/* MR10 */\r
+/* MR10 */                                             if ( !GenCC && (el->elem == NULL || el->elem->ntype==nRuleRef) && GenAST) {\r
+/* MR10 */                          err("You can no longer use attributes returned by rules when also using ASTs");\r
+/* MR10 */                          err("   Use upward inheritance (\"rule >[Attrib a] : ... <<$a=...\>\>\")");\r
+/* MR10 */                      };\r
+/* MR10 */\r
+/* MR10 */                      /* keep track of <<... $label ...>> for semantic predicates in guess mode */\r
+/* MR10 */                      /* element labels contain pointer to the owners node                      */\r
+/* MR10 */\r
+/* MR10 */                      if (el->elem != NULL && el->elem->ntype == nToken) {\r
+/* MR10 */                        list_add(&CurActionLabels,el);\r
+/* MR10 */                      };\r
+                                                       }\r
+                                                       else\r
+                                                               warn(eMsg1("$%s not parameter, return value, (defined) element label",&zzbegexpr[1]));\r
+                                                       }\r
+                                                       zzmore();\r
+                                                       >>\r
+#token "#0"                                    << zzreplstr("(*_root)"); zzmore(); chkGTFlag(); >>\r
+#token "#\[\]"                         << if ( GenCC ) {\r
+                                    if (NewAST) zzreplstr("(newAST)");\r
+                                        else zzreplstr("(new AST)");}\r
+                                                          else {zzreplstr("zzastnew()");} zzmore();\r
+                                                          chkGTFlag();\r
+                                                       >>\r
+#token "#\(\)"                         << zzreplstr("NULL"); zzmore(); chkGTFlag(); >>\r
+#token "#[0-9]+"                       <<{\r
+                                                       static char buf[100];\r
+                                                       if ( strlen(zzbegexpr)>(size_t)85 )\r
+                                                               fatal("#i AST ref too big");\r
+                                                       if ( GenCC ) sprintf(buf,"_ast%d%s",BlkLevel-1,zzbegexpr+1);\r
+                                                       else sprintf(buf,"zzastArg(%s)",zzbegexpr+1);\r
+                                                       zzreplstr(buf);\r
+                                                       zzmore();\r
+                                                       set_orel(atoi(zzbegexpr+1), &AST_nodes_refd_in_actions);\r
+                                                       chkGTFlag();\r
+                                                       }\r
+                                                       >>\r
+\r
+/* MR14 Arpad Beszedes  26-May-98\r
+        Add support for #line directives when antlr source is pre-processed\r
+        #lexclass ACTIONS\r
+*/\r
+\r
+#token "#line[\ \t]* [0-9]+ {[\ \t]* \"~[\"]+\" ([\ \t]* [0-9]*)* } (\n|\r|\r\n)"\r
+        <<\r
+        zzline = atoi(zzbegexpr+5) - 1; zzline++; zzmore();\r
+        getFileNameFromTheLineInfo(FileStr[CurFile], zzbegexpr);\r
+        >>\r
+\r
+#token "#line ~[\n\r]* (\n|\r|\r\n)"\r
+        <<\r
+        zzline++; zzmore();\r
+        >>\r
+\r
+/* MR14 end of a block to support #line in antlr source code */\r
+\r
+#token "#[_a-zA-Z][_a-zA-Z0-9]*"\r
+                                                       <<\r
+                                                       if ( !(strcmp(zzbegexpr, "#ifdef")==0 ||\r
+                                                                strcmp(zzbegexpr, "#if")==0 ||\r
+                                                                strcmp(zzbegexpr, "#else")==0 ||\r
+                                                                strcmp(zzbegexpr, "#endif")==0 ||\r
+                                                                strcmp(zzbegexpr, "#ifndef")==0 ||\r
+                                                                strcmp(zzbegexpr, "#define")==0 ||\r
+                                                                strcmp(zzbegexpr, "#pragma")==0 ||\r
+                                                                strcmp(zzbegexpr, "#undef")==0 ||\r
+                                                                strcmp(zzbegexpr, "#import")==0 ||\r
+                                                                strcmp(zzbegexpr, "#line")==0 ||\r
+                                                                strcmp(zzbegexpr, "#include")==0 ||\r
+                                                                strcmp(zzbegexpr, "#error")==0) )\r
+                                                       {\r
+                                                               static char buf[100];\r
+                                                               sprintf(buf, "%s_ast", zzbegexpr+1);\r
+/* MR27 */                                             list_add(&CurAstLabelsInActions, mystrdup(zzbegexpr+1));\r
+                                                               zzreplstr(buf);\r
+                                                               chkGTFlag();\r
+                                                       }\r
+                                                       zzmore();\r
+                                                       >>\r
+#token "#\["                           <<\r
+                                                       pushint(']');\r
+                                                       if ( GenCC ) {\r
+                                if (NewAST) zzreplstr("(newAST(");\r
+                                    else zzreplstr("(new AST("); }\r
+                                                       else zzreplstr("zzmk_ast(zzastnew(),");\r
+                                                       zzmore();\r
+                                                       chkGTFlag();\r
+                                                       >>\r
+#token "#\("                           <<\r
+                                                       pushint('}');\r
+                                                       if ( GenCC ) {\r
+                                                               if (tmakeInParser) {\r
+                                                                       zzreplstr("tmake(");\r
+                                                               }\r
+                                                               else {\r
+                                                                       zzreplstr("ASTBase::tmake(");\r
+                                                               }\r
+                                                       }\r
+                                                       else {\r
+                                                               zzreplstr("zztmake(");\r
+                                                       }\r
+                                                       zzmore();\r
+                                                       chkGTFlag();\r
+                                                       >>\r
+#token "#"                                     << zzmore(); >>\r
+#token "\)"                                    <<\r
+                                                       if ( istackempty() )\r
+                                                               zzmore();\r
+                                                       else if ( topint()==')' ) {\r
+                                                               popint();\r
+                                                       }\r
+                                                       else if ( topint()=='}' ) {\r
+                                                               popint();\r
+                                                               /* terminate #(..) */\r
+                                                               zzreplstr(", NULL)");\r
+                                                       }\r
+                                                       zzmore();\r
+                                                       >>\r
+#token "\["                                    <<\r
+                                                       pushint('|');   /* look for '|' to terminate simple [...] */\r
+                                                       zzmore();\r
+                                                       >>\r
+#token "\("                                    <<\r
+                                                       pushint(')');\r
+                                                       zzmore();\r
+                                                       >>\r
+\r
+#token "\\\]"                          << zzreplstr("]");  zzmore(); >>\r
+#token "\\\)"                          << zzreplstr(")");  zzmore(); >>\r
+\r
+/* MR1 10-Apr-97  MR1  Previously unable to put right shift operator   */\r
+/* MR1                                 in DLG action                   */\r
+\r
+#token "\\>"   << if (! tokenActionActive) zzreplstr(">");      /* MR1 */\r
+                  zzmore();                                     /* MR1 */\r
+               >>                                               /* MR1 */\r
+\r
+\r
+#token "'"                                     << zzmode(ACTION_CHARS); zzmore();>>\r
+#token "\""                                    << zzmode(ACTION_STRINGS); zzmore();>>\r
+#token "\\$"                           << zzreplstr("$");  zzmore(); >>\r
+#token "\\#"                           << zzreplstr("#");  zzmore(); >>\r
+#token "\\(\n|\r|\r\n)"                << zzline++; zzmore(); >>\r
+#token "\\~[\]\)>$#]"          << zzmore(); >> /* escaped char, always ignore */\r
+#token "/"                                     << zzmore(); >>\r
+#token "/\*"                           << zzmode(ACTION_COMMENTS); zzmore(); >>\r
+#token "\*/"                           << warn("Missing /*; found dangling */ in action"); zzmore(); >>\r
+#token "//"                                    << zzmode(ACTION_CPP_COMMENTS); zzmore(); >>\r
+#token "~[\n\r\)\(\\$#\>\]\[\"'/]+" << zzmore(); >>\r
+\r
+#lexclass START\r
+#token "[\t\ ]+"                       << zzskip(); >>                         /* Ignore White */\r
+#token "\n|\r|\r\n"                    << zzline++; zzskip(); >>       /* Track Line # */\r
+#token "\["                 << zzmode(ACTIONS); zzmore();\r
+                               istackreset();\r
+                               pushint(']'); >>\r
+#token "\<\<"               << action_file=CurFile; action_line=zzline;\r
+                               zzmode(ACTIONS); zzmore();\r
+                               list_free(&CurActionLabels,0);       /* MR10 */\r
+                               numericActionLabel=0;                /* MR10 */\r
+                               istackreset();\r
+                               pushint('>'); >>\r
+#token "\""                                    << zzmode(STRINGS); zzmore(); >>\r
+#token "/\*"                           << zzmode(COMMENTS); zzskip(); >>\r
+#token "\*/"                           << warn("Missing /*; found dangling */"); zzskip(); >>\r
+#token "//"                                    << zzmode(CPP_COMMENTS); zzskip(); >>\r
+\r
+/* MR14 Arpad Beszedes  26-May-98\r
+        Add support for #line directives when antlr source is pre-processed\r
+        #lexclass START\r
+*/\r
+\r
+#token "#line[\ \t]* [0-9]+ {[\ \t]* \"~[\"]+\" ([\ \t]* [0-9]*)* } (\n|\r|\r\n)"\r
+        <<\r
+        zzline = atoi(zzbegexpr+5) - 1; zzline++; zzmore();\r
+        getFileNameFromTheLineInfo(FileStr[CurFile], zzbegexpr);\r
+        >>\r
+\r
+#token "#line ~[\n\r]* (\n|\r|\r\n)"\r
+        <<\r
+        zzline++; zzmore();\r
+        >>\r
+\r
+/* MR14 end of a block to support #line in antlr source code */\r
+\r
+/*                                                                          */\r
+/*  8-Apr-97   Regularize escape sequence for ">>"                         */\r
+/*                     appearing in string literals                                    */\r
+/*                                                                          */\r
+\r
+#token "\>\>"                  << warn("Missing <<; found dangling \>\>"); zzskip(); >> /* MR1 */\r
+#token WildCard "."\r
+#token "\@"                    <<FoundException = 1;           /* MR6 */\r
+                                 FoundAtOperator = 1;>>        /* MR6 */\r
+#token Eof                                     "@"\r
+                                                       <<      /* L o o k  F o r  A n o t h e r  F i l e */\r
+                                                       {\r
+                                                       FILE *new_input;\r
+                                                       new_input = NextFile();\r
+                                                       if ( new_input == NULL ) { NLA=Eof; return; }\r
+                                                       fclose( input );\r
+                                                       input = new_input;\r
+                                                       zzrdstream( input );\r
+                                                       zzskip();       /* Skip the Eof (@) char i.e continue */\r
+                                                       }\r
+                                                       >>\r
+\r
+#token LABEL\r
+\r
+#errclass "grammar-element" { element }\r
+#errclass "meta-symbol"                { "\}" "!" ";" "\|" "\~" "^" "\)" }\r
+\r
+#token Pragma                  "{\\}#pragma"                   /* MR21 */\r
+#token FirstSetSymbol  "{\\}#FirstSetSymbol"   /* MR21 */\r
+/*\r
+ * Get a grammar -- Build a list of rules like:\r
+ *\r
+ *     o-->Rule1--o\r
+ *     |\r
+ *     o-->Rule2--o\r
+ *     |\r
+ *     ...\r
+ *     |\r
+ *     o-->RuleN--o\r
+ */\r
+\r
+/* rule grammar */\r
+\r
+grammar :      <<Graph g;>>\r
+                       (       "{\\}#header" Action    /* MR13 */\r
+                               <<\r
+                               if ( HdrAction==NULL ) {\r
+                               HdrAction = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));\r
+                               require(HdrAction!=NULL, "rule grammar: cannot allocate header action");\r
+                               strcpy(HdrAction, LATEXT(1));\r
+                               }\r
+                               else warn("additional #header statement ignored");\r
+                               >>\r
+            |   "{\\}#first" Action\r
+                               <<\r
+                               if ( FirstAction==NULL ) {\r
+                                       FirstAction = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));\r
+                                       require(FirstAction!=NULL, "rule grammar: cannot allocate #first action");\r
+                                       strcpy(FirstAction, LATEXT(1));\r
+                               } else {\r
+                        warn("additional #first statement ignored");\r
+                    };\r
+                               >>\r
+\r
+                       |       "{\\}#parser" QuotedTerm\r
+                               <<\r
+                               if ( GenCC ) {\r
+                                       warn("#parser meta-op incompatible with -CC; ignored");\r
+                               }\r
+                               else {\r
+                                       if ( strcmp(ParserName,"zzparser")==0 ) {\r
+                                               ParserName=StripQuotes(mystrdup(LATEXT(1)));\r
+                                               if ( RulePrefix[0]!='\0' )\r
+                                               {\r
+                                                       warn("#parser meta-op incompatible with '-gp prefix'; '-gp' ignored");\r
+                                                       RulePrefix[0]='\0';\r
+                                               }\r
+                                       }\r
+                                       else warn("additional #parser statement ignored");\r
+                               }\r
+                               >>\r
+                       |       "{\\}#tokdefs" QuotedTerm\r
+                               <<{\r
+                               char *fname;\r
+                               zzantlr_state st; FILE *f; struct zzdlg_state dst;\r
+                               UserTokenDefsFile = mystrdup(LATEXT(1));\r
+                               zzsave_antlr_state(&st);\r
+                               zzsave_dlg_state(&dst);\r
+                               fname = mystrdup(LATEXT(1));\r
+                               f = fopen(StripQuotes(fname), "r");\r
+                               if ( f==NULL ) {warn(eMsg1("cannot open token defs file '%s'", fname+1));}\r
+                               else {\r
+                                       ANTLRm(enum_file(fname+1), f, PARSE_ENUM_FILE);\r
+                                       UserDefdTokens = 1;\r
+                               }\r
+                               zzrestore_antlr_state(&st);\r
+                               zzrestore_dlg_state(&dst);\r
+                               }>>\r
+                       )*\r
+                       (       Action\r
+                               <<{\r
+                               UserAction *ua = newUserAction(LATEXT(1));\r
+                               ua->file = action_file; ua->line = action_line;\r
+                               if ( class_nest_level>0 ) list_add(&class_before_actions, ua);\r
+                               else list_add(&BeforeActions, ua);\r
+                               }>>\r
+                       |       laction\r
+                       |       lmember                         /* MR1 */\r
+                       |       lprefix                         /* MR1 */\r
+                       |       aLexclass\r
+                       |       token\r
+                       |       error\r
+                       |       tclass\r
+            |   aPred               /* MR11 */\r
+                       |       default_exception_handler\r
+                       |       class_def\r
+                       |       "\}"\r
+                               <<\r
+                               if ( class_nest_level==0 )\r
+                                       warn("missing class definition for trailing '}'");\r
+                               class_nest_level--;\r
+                               >>\r
+                       )*\r
+            \r
+                       rule            <<g=$3; SynDiag = (Junction *) $3.left;>>\r
+                       (       rule\r
+\r
+                       <<if ( $1.left!=NULL ) {\r
+                        g.right = NULL;\r
+\r
+/* MR21a */             /*  Avoid use of a malformed graph when CannotContinue */\r
+/* MR21a */             /*  is already set                                     */\r
+/* MR21a */\r
+/* MR21a */             if (! (CannotContinue && g.left == NULL)) {\r
+/* MR21a */               g = Or(g, $1);\r
+/* MR21a */             }\r
+/* MR21a */                  }\r
+                    >>\r
+\r
+                       |       aLexclass\r
+                       |       token\r
+                       |       error\r
+                       |       tclass\r
+            |   aPred               /* MR11 */\r
+                       |       class_def\r
+                       |       "\}"\r
+                               <<\r
+                               if ( class_nest_level==0 )\r
+                                       warn("missing class definition for trailing '}'");\r
+                               class_nest_level--;\r
+                               >>\r
+                       )*\r
+                       (       Action\r
+                               <<{\r
+                               UserAction *ua = newUserAction(LATEXT(1));\r
+                               ua->file = action_file; ua->line = action_line;\r
+                               if ( class_nest_level>0 ) list_add(&class_after_actions, ua);\r
+                               else list_add(&AfterActions, ua);\r
+                               }>>\r
+                       |       laction\r
+                       |       lmember                         /* MR1 */\r
+                       |       lprefix                         /* MR1 */\r
+                       |       error\r
+                       |       tclass\r
+                       |       class_def\r
+            |   aPred               /* MR11 */\r
+                       |       "\}"\r
+                               <<\r
+                               if ( class_nest_level==0 )\r
+                                       warn("missing class definition for trailing '}'");\r
+                               class_nest_level--;\r
+                               >>\r
+                       )*\r
+                       Eof\r
+               ;\r
+               <<CannotContinue=TRUE;>>\r
+\r
+/* rule class_def */\r
+\r
+class_def\r
+       :       <<int go=1; char name[MaxRuleName+1];>>\r
+               "class"\r
+               (       NonTerminal             <<if(go) strncpy(name,LATEXT(1),MaxRuleName);>>\r
+               |       TokenTerm               <<if(go) strncpy(name,LATEXT(1),MaxRuleName);>>\r
+               )\r
+               <<\r
+               if ( CurrentClassName[0]!='\0' && strcmp(CurrentClassName,name)!=0\r
+                        && GenCC ) {\r
+                       err("only one grammar class allowed in this release");\r
+                       go = 0;\r
+               }\r
+               else strcpy(CurrentClassName, name);\r
+               >>\r
+               <<if ( !GenCC ) { err("class meta-op used without C++ option"); }>>\r
+\r
+/* MR10 */  (~ "\{"\r
+/* MR10 */            <<if (ClassDeclStuff == NULL) {\r
+/* MR10 */                   ClassDeclStuff=(char *)calloc(MaxClassDeclStuff+1,sizeof(char));\r
+/* MR10 */              };\r
+/* MR10 */              strncat(ClassDeclStuff," ",MaxClassDeclStuff);\r
+/* MR10 */              strncat(ClassDeclStuff,LATEXT(1),MaxClassDeclStuff);\r
+/* MR22 */              do {\r
+/* MR22 */                if (0 == strcmp(LATEXT(1),"public")) break;\r
+/* MR22 */                if (0 == strcmp(LATEXT(1),"private")) break;\r
+/* MR22 */                if (0 == strcmp(LATEXT(1),"protected")) break;\r
+/* MR22 */                if (0 == strcmp(LATEXT(1),"virtual")) break;\r
+/* MR22 */                if (0 == strcmp(LATEXT(1),",")) break;\r
+/* MR22 */                if (0 == strcmp(LATEXT(1),":")) break;\r
+/* MR22 */                if (BaseClassName != NULL) break;\r
+/* MR22 */                BaseClassName=(char *)calloc(strlen(LATEXT(1))+1,sizeof(char));\r
+/* MR22 */                require(BaseClassName!=NULL, "rule grammar: cannot allocate base class name");\r
+/* MR22 */                               strcpy(BaseClassName,LATEXT(1));\r
+/* MR22 */              } while (0);\r
+/* MR10 */            >>\r
+/* MR10 */  )*\r
+\r
+               "\{"\r
+               <<\r
+               no_classes_found = 0;\r
+               if ( class_nest_level>=1 ) {warn("cannot have nested classes");}\r
+               else class_nest_level++;\r
+               >>\r
+       ;\r
+       <<CannotContinue=TRUE;>>\r
+\r
+/*\r
+ * Build -o-->o-R-o-->o-       where -o-R-o- is the block from rule 'block'.\r
+ * Construct the RuleBlk front and EndRule node on the end of the\r
+ * block.  This is used to add FOLLOW pointers to the rule end.  Add the\r
+ * new rule name to the Rname hash table and sets its rulenum.\r
+ * Store the parameter definitions if any are found.\r
+ *\r
+ * Note that locks are required on the RuleBlk and EndRule nodes to thwart\r
+ * infinite recursion.\r
+ *\r
+ * Return the left graph pointer == NULL to indicate error/dupl rule def.\r
+ */\r
+\r
+/* rule rule */\r
+\r
+rule   :       <<\r
+\r
+                       ExceptionGroup *eg;\r
+                       RuleEntry *q; Junction *p; Graph r; int f, l; ECnode *e;\r
+                       set toksrefd, rulesrefd;\r
+                       char *pdecl=NULL, *ret=NULL, *a; CurRetDef = CurParmDef = NULL;\r
+                       CurExGroups = NULL;\r
+                       CurElementLabels = NULL;\r
+                       CurAstLabelsInActions = NULL; /* MR27 */\r
+                       /* We want a new element label hash table for each rule */\r
+                       if ( Elabel!=NULL ) killHashTable(Elabel);\r
+                       Elabel = newHashTable();\r
+                       attribsRefdFromAction = empty;\r
+                       >>\r
+                       NonTerminal\r
+                       <<q=NULL;\r
+                         if ( hash_get(Rname, LATEXT(1))!=NULL ) {\r
+                                 err(eMsg1("duplicate rule definition: '%s'",LATEXT(1)));\r
+                                 CannotContinue=TRUE;\r
+                         }\r
+                         else\r
+                         {\r
+                                 q = (RuleEntry *)hash_add(Rname,\r
+                                                                                       LATEXT(1),\r
+                                                                                       (Entry *)newRuleEntry(LATEXT(1)));\r
+                             CurRule = q->str;\r
+                         }\r
+                         CurRuleNode = q;\r
+                         f = CurFile; l = zzline;\r
+                         NumRules++;\r
+                       >>\r
+                       {       "!"  <<if ( q!=NULL ) q->noAST = TRUE;>> }\r
+                       {       <<;>>\r
+                               {"\<"}\r
+                               PassAction\r
+                               <<      pdecl = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));\r
+                                       require(pdecl!=NULL, "rule rule: cannot allocate param decl");\r
+                                       strcpy(pdecl, LATEXT(1));\r
+                                       CurParmDef = pdecl;\r
+                               >>\r
+                       }\r
+                       {       "\>"\r
+                               PassAction\r
+                               <<      ret = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));\r
+                                   require(ret!=NULL, "rule rule: cannot allocate ret type");\r
+                                       strcpy(ret, LATEXT(1));\r
+                                       CurRetDef = ret;\r
+                               >>\r
+                       }\r
+                       { QuotedTerm <<if ( q!=NULL ) q->egroup=mystrdup(LATEXT(1));>> }\r
+                       <<\r
+                       if ( GenEClasseForRules && q!=NULL ) {\r
+                               e = newECnode;\r
+                               require(e!=NULL, "cannot allocate error class node");\r
+                               if ( q->egroup == NULL ) {a = q->str; a[0] = (char)toupper(a[0]);}\r
+                               else a = q->egroup;\r
+                               if ( Tnum( a ) == 0 )\r
+                               {\r
+                                       e->tok = addTname( a );\r
+                                       list_add(&eclasses, (char *)e);\r
+                                       if ( q->egroup == NULL ) a[0] = (char)tolower(a[0]);\r
+                                       /* refers to itself */\r
+                                       list_add(&(e->elist), mystrdup(q->str));\r
+                               }\r
+                               else {\r
+                                       warn(eMsg1("default errclass for '%s' would conflict with token/errclass/tokclass",a));\r
+                                       if ( q->egroup == NULL ) a[0] = (char)tolower(a[0]);\r
+                                       free((char *)e);\r
+                               }\r
+                       }\r
+                       >>\r
+                       <<BlkLevel++;\r
+              if (BlkLevel >= MAX_BLK_LEVEL) fatal("Blocks nested too deeply");\r
+/* MR23 */    CurBlockID_array[BlkLevel] = CurBlockID;\r
+/* MR23 */    CurAltNum_array[BlkLevel] = CurAltNum;                \r
+            >>\r
+\r
+                       ":" <<inAlt=1;>>\r
+                       block[&toksrefd, &rulesrefd]\r
+                       <<r = makeBlk($7,0, NULL /* pFirstSetSymbol */ );\r
+                         CurRuleBlk = (Junction *)r.left;\r
+                         CurRuleBlk->blockid = CurBlockID;\r
+                         CurRuleBlk->jtype = RuleBlk;\r
+                         if ( q!=NULL ) CurRuleBlk->rname = q->str;\r
+                         CurRuleBlk->file = f;\r
+                         CurRuleBlk->line = l;\r
+                         CurRuleBlk->pdecl = pdecl;\r
+                         CurRuleBlk->ret = ret;\r
+                         CurRuleBlk->lock = makelocks();\r
+                         CurRuleBlk->pred_lock = makelocks();\r
+                         CurRuleBlk->tokrefs = toksrefd;\r
+                         CurRuleBlk->rulerefs = rulesrefd;\r
+                         p = newJunction();    /* add EndRule Node */\r
+                         ((Junction *)r.right)->p1 = (Node *)p;\r
+                         r.right = (Node *) p;\r
+                         p->jtype = EndRule;\r
+                         p->lock = makelocks();\r
+                         p->pred_lock = makelocks();\r
+                         CurRuleBlk->end = p;\r
+                         if ( q!=NULL ) q->rulenum = NumRules;\r
+                         $7 = r;\r
+                       >>\r
+                       <<\r
+                /* MR23 */      CurBlockID_array[BlkLevel] = (-1);\r
+                /* MR23 */      CurAltNum_array[BlkLevel] = (-1);                \r
+                --BlkLevel;\r
+            >>\r
+            <<altFixup();leFixup();egFixup();>>                      /* MR7 */\r
+                       ";" <<inAlt=0;>>\r
+                       {       Action\r
+                               <<      a = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));\r
+                                       require(a!=NULL, "rule rule: cannot allocate error action");\r
+                                       strcpy(a, LATEXT(1));\r
+                                       CurRuleBlk->erraction = a;\r
+                               >>\r
+                       }\r
+                       (       exception_group > [eg]\r
+                               <<if ( eg!=NULL ) {\r
+                                       list_add(&CurExGroups, (void *)eg);\r
+                                       if (eg->label == NULL || *eg->label=='\0' ) q->has_rule_exception = 1;\r
+                           }\r
+                               >>\r
+                       )*\r
+                       <<if ( q==NULL ) $0.left = NULL; else $0 = $7;>>\r
+                       <<CurRuleBlk->exceptions = CurExGroups;>>\r
+                       <<CurRuleBlk->el_labels = CurElementLabels;>>\r
+                       <<CurRuleNode->ast_labels_in_actions = CurAstLabelsInActions;>> /* MR27 */\r
+                       <<CurRuleNode = NULL;>> /* MR27 Moved */\r
+               ;\r
+               <<CannotContinue=TRUE;>>\r
+\r
+/*\r
+ * pragma      :       "{\\}#pragma" "dup\-labeled\-tokens"\r
+ *                     <<Pragma_DupLabeledTokens=1;>>\r
+ *             ;\r
+ */\r
+\r
+/* rule laction */\r
+\r
+laction        :       <<char *a;>>\r
+\r
+                       "{\\}#lexaction"\r
+                       Action\r
+                       <<\r
+                       a = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));\r
+                       require(a!=NULL, "rule laction: cannot allocate action");\r
+                       strcpy(a, LATEXT(1));\r
+                       list_add(&LexActions, a);\r
+                       >>\r
+               ;\r
+               <<CannotContinue=TRUE;>>\r
+\r
+/* MR1                                                                     */\r
+/* MR1  11-Apr-97      Provide mechanism for inserting code into DLG class */\r
+/* MR1                   via #lexmember <<....>> & #lexprefix <<...>>      */\r
+/* MR1                                                                     */\r
+\r
+/* rule lmember */\r
+\r
+lmember:       <<char *a;>>                                         /* MR1 */\r
+\r
+/* MR1 */              "{\\}#lexmember"\r
+/* MR1 */              Action\r
+/* MR1 */              <<\r
+/* MR1 */              if (! GenCC) {\r
+/* MR1 */                err("Use #lexmember only in C++ mode (to insert code in DLG class header");\r
+/* MR1 */              } else {\r
+/* MR1 */                a = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));\r
+/* MR1 */                require(a!=NULL, "rule lmember: cannot allocate action");\r
+/* MR1 */                strcpy(a, LATEXT(1));\r
+/* MR1 */                list_add(&LexMemberActions, a);\r
+/* MR1 */              };\r
+/* MR1 */              >>\r
+/* MR1 */      ;\r
+/* MR1 */      <<CannotContinue=TRUE;>>\r
+\r
+/* rule lprefix */\r
+\r
+lprefix:       <<char *a;>>                                         /* MR1 */\r
+\r
+/* MR1 */              "{\\}#lexprefix"\r
+/* MR1 */              Action\r
+/* MR1 */              <<\r
+/* MR1 */              if (! GenCC) {\r
+/* MR1 */                err("Use #lexprefix only in C++ mode (to insert code in DLG class header");\r
+/* MR1 */              } else {\r
+/* MR1 */                a = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));\r
+/* MR1 */                require(a!=NULL, "rule lprefix: cannot allocate action");\r
+/* MR1 */                strcpy(a, LATEXT(1));\r
+/* MR1 */                list_add(&LexPrefixActions, a);\r
+/* MR1 */              };\r
+/* MR1 */              >>\r
+/* MR1 */      ;\r
+/* MR1 */      <<CannotContinue=TRUE;>>\r
+\r
+/*\r
+ * #pred upper        <<isupper()>>?            predicate literal\r
+ * #pred lower        <<islower()>>?            predicate literal\r
+ * #pred up_or_low    upper || lower            predicate expression\r
+ *                                                concealed interdependence\r
+ * #pred up_or_low_2  <<isletter()>>?  A || B   predicate literal equals predicate expr\r
+ *                                                analyze using lower||upper\r
+ *                                                generate using isLetter()\r
+ */\r
+\r
+/* rule aPref */\r
+\r
+aPred:  <<PredEntry     *predEntry=NULL;\r
+          char          *name=NULL;\r
+          Predicate     *predExpr=NULL;\r
+          char          *predLiteral=NULL;\r
+          int           save_file;\r
+          int           save_line;\r
+          int           predExprPresent=0;\r
+        >>\r
+\r
+        "{\\}#pred"\r
+\r
+        <<\r
+          MR_usingPredNames=1;      /* will need to use -mrhoist version of genPredTree */\r
+        >>\r
+\r
+                                    /* used to allow NonTerminal but it caused problems\r
+                                       when a rule name immediately followed a #pred statement */\r
+\r
+        TokenTerm     <<name=mystrdup(LATEXT(1));>>\r
+\r
+          <<\r
+            /* don't free - referenced in predicates */\r
+\r
+            CurPredName=(char *)calloc(1,strlen(name) + 10);\r
+            strcat(CurPredName,"#pred ");\r
+            strcat(CurPredName,name);\r
+\r
+            predEntry=(PredEntry *) hash_get(Pname,name);\r
+            if (predEntry != NULL) {\r
+              warnFL(eMsg1("#pred %s previously defined - ignored",name),\r
+                                              FileStr[action_file],action_line);\r
+              name=NULL;\r
+            };\r
+          >>\r
+\r
+        (\r
+\r
+            Pred    <<predLiteral=mystrdup(LATEXT(1));\r
+                      save_line=action_line;\r
+                      save_file=action_file;\r
+                    >>\r
+\r
+              {\r
+                    predOrExpr>[predExpr]   <<predExprPresent=1;>>\r
+              }\r
+\r
+              <<if (predLiteral != NULL && name != NULL) {\r
+\r
+                      /*\r
+                       *  predExpr may be NULL due to syntax errors\r
+                       *    or simply omitted by the user\r
+                      */\r
+\r
+                      predEntry=newPredEntry(name);\r
+                      predEntry->file=save_file;\r
+                      predEntry->line=save_line;\r
+                      predExpr=MR_predFlatten(predExpr);\r
+                      predEntry->predLiteral=predLiteral;\r
+                      if (! predExprPresent || predExpr == NULL) {\r
+                        predExpr=new_pred();\r
+                        predExpr->expr=predLiteral;\r
+                        predExpr->source=newActionNode();\r
+                        predExpr->source->action=predExpr->expr;\r
+                        predExpr->source->rname=CurPredName;\r
+                        predExpr->source->line=action_line;\r
+                        predExpr->source->file=action_file;\r
+                        predExpr->source->is_predicate=1;\r
+                        predExpr->k=predicateLookaheadDepth(predExpr->source);\r
+                      };\r
+                      predEntry->pred=predExpr;\r
+                      hash_add(Pname,name,(Entry *)predEntry);\r
+                      predExpr=NULL;\r
+                };\r
+                predicate_free(predExpr);\r
+              >>\r
+\r
+            |\r
+               <<save_line=zzline; save_file=CurFile;>>\r
+\r
+                predOrExpr>[predExpr]\r
+\r
+              <<if (predExpr != NULL && name != NULL) {\r
+                  predEntry=newPredEntry(name);\r
+                  predEntry->file=CurFile;\r
+                  predEntry->line=zzline;\r
+                  predExpr=MR_predFlatten(predExpr);\r
+                  predEntry->pred=predExpr;\r
+                  hash_add(Pname,name,(Entry *)predEntry);\r
+                  predExpr=NULL;\r
+                };\r
+                predicate_free(predExpr);\r
+              >>\r
+        )\r
+        {";"}\r
+;\r
+\r
+/* fail */\r
+\r
+<<predicate_free(predExpr);\r
+>>\r
+\r
+/* rule predOrExpr */\r
+\r
+predOrExpr>[Predicate *result] :\r
+            <<Predicate     *ORnode;\r
+              Predicate     *predExpr;\r
+              Predicate     **tail=NULL;\r
+            >>\r
+        predAndExpr>[predExpr]\r
+            <<\r
+                ORnode=new_pred();\r
+                ORnode->expr=PRED_OR_LIST;\r
+                if (predExpr != NULL) {\r
+                    ORnode->down=predExpr;\r
+                    tail=&predExpr->right;\r
+                };\r
+            >>\r
+        ( "\|\|"  predAndExpr>[predExpr]\r
+            <<\r
+                if (predExpr != NULL) {\r
+                    *tail=predExpr;\r
+                    tail=&predExpr->right;\r
+                };\r
+            >>\r
+        )*\r
+        <<\r
+            $result=ORnode;\r
+            ORnode=NULL;\r
+        >>\r
+;\r
+\r
+/* fail */\r
+\r
+<<predicate_free(ORnode);>>\r
+\r
+/* rule predAndExpr */\r
+\r
+predAndExpr>[Predicate *result] :\r
+            <<Predicate     *ANDnode;\r
+              Predicate     *predExpr;\r
+              Predicate     **tail=NULL;\r
+            >>\r
+        predPrimary>[predExpr]\r
+            <<\r
+                ANDnode=new_pred();\r
+                ANDnode->expr=PRED_AND_LIST;\r
+                if (predExpr != NULL) {\r
+                    ANDnode->down=predExpr;\r
+                    tail=&predExpr->right;\r
+                };\r
+            >>\r
+        ( "&&"  predPrimary>[predExpr]\r
+            <<\r
+                if (predExpr != NULL) {\r
+                    *tail=predExpr;\r
+                    tail=&predExpr->right;\r
+                };\r
+            >>\r
+        )*\r
+        <<\r
+            $result=ANDnode;\r
+            ANDnode=NULL;\r
+        >>\r
+;\r
+\r
+/* fail */\r
+\r
+<<predicate_free(ANDnode);>>\r
+\r
+\r
+/* rule predPrimary */\r
+\r
+predPrimary>[Predicate *result] :\r
+            <<\r
+              char          *name=NULL;\r
+              PredEntry     *predEntry=NULL;\r
+              Predicate     *predExpr=NULL;\r
+            >>\r
+\r
+        TokenTerm            <<name=mystrdup(LATEXT(1));>>\r
+\r
+            <<\r
+                predEntry=(PredEntry *) hash_get(Pname,name);\r
+                if (predEntry == NULL) {\r
+                  warnFL(eMsg1("no previously defined #pred with name \"%s\"",name),\r
+                        FileStr[CurFile],zzline);\r
+                  name=NULL;\r
+                  $result=NULL;\r
+                } else {\r
+                  predExpr=predicate_dup(predEntry->pred);\r
+                  predExpr->predEntry=predEntry;\r
+                  $result=predExpr;\r
+                };\r
+            >>\r
+\r
+        | "\(" predOrExpr>[predExpr] "\)"\r
+            <<\r
+                $result=predExpr;\r
+            >>\r
+\r
+        | "!" predPrimary>[predExpr]\r
+            <<\r
+                predExpr->inverted=!predExpr->inverted;\r
+                $result=predExpr;\r
+            >>\r
+;\r
+\r
+/* fail */  <<\r
+              predicate_free(predExpr);\r
+            >>\r
+\r
+/* rule aLexclass */\r
+\r
+aLexclass:     "{\\}#lexclass" TokenTerm <<lexclass(mystrdup(LATEXT(1)));>>\r
+               ;\r
+               <<CannotContinue=TRUE;>>\r
+\r
+/* rule error */\r
+\r
+error  :       <<char *t=NULL; ECnode *e; int go=1; TermEntry *p;>>\r
+                       "{\\}#errclass"\r
+                       (<<;>>  TokenTerm  <<t=mystrdup(LATEXT(1));>>\r
+                       |               QuotedTerm <<t=mystrdup(LATEXT(1));>>\r
+                       )\r
+                       <<e = newECnode;\r
+                         require(e!=NULL, "cannot allocate error class node");\r
+                         e->lexclass = CurrentLexClass;\r
+                         if ( Tnum( (t=StripQuotes(t)) ) == 0 )\r
+                         {\r
+                               if ( hash_get(Texpr, t) != NULL )\r
+                                       warn(eMsg1("errclass name conflicts with regular expression  '%s'",t));\r
+                               e->tok = addTname( t );\r
+                               set_orel(e->tok, &imag_tokens);\r
+                               require((p=(TermEntry *)hash_get(Tname, t)) != NULL,\r
+                                               "hash table mechanism is broken");\r
+                               p->classname = 1;       /* entry is errclass name, not token */\r
+                               list_add(&eclasses, (char *)e);\r
+                         }\r
+                         else\r
+                         {\r
+                               warn(eMsg1("redefinition of errclass or conflict w/token or tokclass '%s'; ignored",t));\r
+                               free( (char *)e );\r
+                               go=0;\r
+                         }\r
+                       >>\r
+                       "\{"\r
+                               ( NonTerminal <<if ( go ) t=mystrdup(LATEXT(1));>>\r
+                               | TokenTerm <<if ( go ) t=mystrdup(LATEXT(1));>>\r
+                               | QuotedTerm <<if ( go ) t=mystrdup(LATEXT(1));>>\r
+                               )\r
+                               <<if ( go ) list_add(&(e->elist), t);>>\r
+                               (\r
+                                       ( NonTerminal <<if ( go ) t=mystrdup(LATEXT(1));>>\r
+                                       | TokenTerm <<if ( go ) t=mystrdup(LATEXT(1));>>\r
+                                       | QuotedTerm <<if ( go ) t=mystrdup(LATEXT(1));>>\r
+                                       )\r
+                                       <<if ( go ) list_add(&(e->elist), t);>>\r
+                               )*\r
+                       "\}"\r
+               ;\r
+               <<CannotContinue=TRUE;>>\r
+\r
+/* rule tclass */\r
+\r
+tclass :       <<char *t=NULL; TCnode *e; int go=1,tok,totok; TermEntry *p, *term, *toterm;>>\r
+            <<char *akaString=NULL; int save_file; int save_line;>>\r
+            <<char *totext=NULL; >>\r
+                       "{\\}#tokclass" TokenTerm <<t=mystrdup(LATEXT(1));>>\r
+                       <<e = newTCnode;\r
+                         require(e!=NULL, "cannot allocate token class node");\r
+                         e->lexclass = CurrentLexClass;\r
+                         if ( Tnum( t ) == 0 )\r
+                         {\r
+                               e->tok = addTname( t );\r
+                               set_orel(e->tok, &imag_tokens);\r
+                               set_orel(e->tok, &tokclasses);\r
+                               require((p=(TermEntry *)hash_get(Tname, t)) != NULL,\r
+                                               "hash table mechanism is broken");\r
+                               p->classname = 1;       /* entry is class name, not token */\r
+                               p->tclass = e;          /* save ptr to this tclass def */\r
+                               list_add(&tclasses, (char *)e);\r
+                         }\r
+                         else\r
+                         {\r
+                               warn(eMsg1("redefinition of tokclass or conflict w/token '%s'; ignored",t));\r
+                               free( (char *)e );\r
+                               go=0;\r
+                         }\r
+                       >>\r
+/* MR23 */      {\r
+/* MR23 */          "\("\r
+/* MR23 */          QuotedTerm\r
+/* MR23 */                 <<akaString=mystrdup(StripQuotes(LATEXT(1)));\r
+/* MR11 */                   save_file=CurFile;save_line=zzline;\r
+/* MR23 */                 >>\r
+/* MR23 */          "\)"\r
+/* MR23 */      }\r
+/* MR23 */\r
+/* MR23 */\r
+/* MR23 */             <<\r
+/* MR23 */         if (p!= NULL && akaString != NULL) {\r
+/* MR23 */           if (p->akaString != NULL) {\r
+/* MR23 */             if (strcmp(p->akaString,akaString) != 0) {\r
+/* MR23 */                warnFL(eMsg2("this #tokclass statment conflicts with a previous #tokclass %s(\"%s\") statement",\r
+/* MR23 */                              t,p->akaString),\r
+/* MR23 */                                         FileStr[save_file],save_line);\r
+/* MR23 */             };\r
+/* MR23 */            } else {\r
+/* MR23 */              p->akaString=akaString;\r
+/* MR23 */            };\r
+/* MR23 */          };\r
+/* MR23 */             >>\r
+\r
+                       "\{"\r
+                               (\r
+                               ( TokenTerm\r
+                                 <<if ( go ) {\r
+                                       term = (TermEntry *) hash_get(Tname, LATEXT(1));\r
+                                       if ( term==NULL && UserDefdTokens ) {\r
+                                               err("implicit token definition not allowed with #tokdefs");\r
+                                               go = 0;\r
+                                       }\r
+                                       else {t=mystrdup(LATEXT(1)); tok=addTname(LATEXT(1));}\r
+                                       }>>\r
+\r
+                        {\r
+                            ".."\r
+                            TokenTerm\r
+\r
+                                         <<if ( go ) {\r
+                                                       toterm = (TermEntry *) hash_get(Tname, LATEXT(1));\r
+                                                       if ( toterm==NULL && UserDefdTokens ) {\r
+                                                               err("implicit token definition not allowed with #tokdefs");\r
+                                                               go = 0;\r
+                                                       } else {\r
+                                        totext=mystrdup(LATEXT(1)); totok=addTname(LATEXT(1));\r
+                                    }\r
+                                           }\r
+                              >>\r
+                        }\r
+\r
+                               | QuotedTerm\r
+                                 <<if ( go ) {\r
+                                       term = (TermEntry *) hash_get(Texpr, LATEXT(1));\r
+                                       if ( term==NULL && UserDefdTokens ) {\r
+                                               err("implicit token definition not allowed with #tokdefs");\r
+                                               go = 0;\r
+                                               }\r
+                                       else {t=mystrdup(LATEXT(1)); tok=addTexpr(LATEXT(1));}\r
+                                       }>>\r
+                               )\r
+                               <<if ( go ) {\r
+                        if (totext == NULL) {\r
+                            list_add(&(e->tlist), t);\r
+                        } else {\r
+                            list_add(&(e->tlist),"..");\r
+                            list_add(&(e->tlist),t);\r
+                            list_add(&(e->tlist),totext);\r
+                        }\r
+                        totext=NULL;\r
+                      }\r
+                    >>\r
+                               )+  // MR15 Manfred Kogler - forbid empty #tokclass sets (was "+")\r
+                       "\}"\r
+               ;\r
+               <<CannotContinue=TRUE;>>\r
+\r
+/* rule token */\r
+\r
+token  :       <<char *t=NULL, *e=NULL, *a=NULL; int tnum=0;>>\r
+            <<char *akaString=NULL; TermEntry *te;int save_file=0,save_line=0;>>           /* MR11 */\r
+                       "{\\}#token"\r
+\r
+/* MR1 10-Apr-97 MR1 Allow shift right operator in DLG actions            */\r
+/* MR1                 Danger when parser feedback to lexer                       */\r
+/* MR1                                                                */\r
+\r
+                       <<tokenActionActive=1;>>                                    /* MR1 */\r
+                       {       TokenTerm  <<t=mystrdup(LATEXT(1));>>\r
+\r
+/* MR11 */      {\r
+/* MR11 */          "\("\r
+/* MR11 */          QuotedTerm\r
+/* MR11 */                 <<akaString=mystrdup(StripQuotes(LATEXT(1)));\r
+/* MR11 */                   save_file=CurFile;save_line=zzline;\r
+/* MR11 */                 >>\r
+/* MR11 */          "\)"\r
+/* MR11 */      }\r
+\r
+                               {       "=" "[0-9]+"            /* define the token type number */\r
+                                       <<tnum = atoi(LATEXT(1));>>\r
+                               }\r
+                       }\r
+                       { QuotedTerm <<e=mystrdup(LATEXT(1));>> }\r
+                       {       Action\r
+                               <<\r
+                                       a = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));\r
+                                       require(a!=NULL, "rule token: cannot allocate action");\r
+                                       strcpy(a, LATEXT(1));\r
+                               >>\r
+                       }\r
+\r
+            { ";" }     /* MR11 */\r
+\r
+                       <<chkToken(t, e, a, tnum);>>\r
+\r
+            <<if (t != NULL) {\r
+                te=(TermEntry *)hash_get(Tname,t);\r
+                if (te != NULL && akaString != NULL) {\r
+                  if (te->akaString != NULL) {\r
+                    if (strcmp(te->akaString,akaString) != 0) {\r
+                      warnFL(eMsg2("this #token statment conflicts with a previous #token %s(\"%s\") statement",\r
+                                    t,te->akaString),\r
+                        FileStr[save_file],save_line);\r
+                    };\r
+                  } else {\r
+                    te->akaString=akaString;\r
+                  };\r
+                };\r
+              };\r
+            >>\r
+               ;\r
+               <<CannotContinue=TRUE;>>\r
+\r
+/* rule block */\r
+\r
+block[set *toksrefd, set *rulesrefd]\r
+               :       <<\r
+                       Graph g, b;\r
+                       set saveblah;\r
+                       int saveinalt = inAlt;\r
+                       ExceptionGroup *eg;\r
+                       *$toksrefd = empty;\r
+                       *$rulesrefd = empty;\r
+                       set_clr(AST_nodes_refd_in_actions);\r
+                       CurBlockID++;\r
+/* MR23 */      CurBlockID_array[BlkLevel] = CurBlockID;\r
+                       CurAltNum = 1;\r
+/* MR23 */      CurAltNum_array[BlkLevel] = CurAltNum;                \r
+                       saveblah = attribsRefdFromAction;\r
+                       attribsRefdFromAction = empty;\r
+                       >>\r
+\r
+                       alt[toksrefd,rulesrefd]         <<b = g = $1;>>\r
+\r
+                       <<\r
+                       if ( ((Junction *)g.left)->p1->ntype == nAction )\r
+                       {\r
+                ActionNode *actionNode=(ActionNode *)\r
+                                         ( ( (Junction *)g.left) ->p1);\r
+                               if (!actionNode->is_predicate )\r
+                               {\r
+                                       actionNode->init_action = TRUE;\r
+/* MR12c */            if (actionNode->noHoist) {\r
+/* MR12c */           errFL("<<nohoist>> appears as init-action - use <<>> <<nohoist>>",\r
+/* MR12c */                       FileStr[actionNode->file],actionNode->line);\r
+/* MR12c */         };\r
+                               }\r
+                       }\r
+                       ((Junction *)g.left)->blockid = CurBlockID;\r
+                       >>\r
+\r
+                       (       exception_group > [eg]\r
+                               <<\r
+                               if ( eg!=NULL ) {\r
+/* MR7 *****           eg->altID = makeAltID(CurBlockID,CurAltNum);        *****/\r
+/* MR7 *****           CurAltStart->exception_label = eg->altID;           *****/\r
+                                       list_add(&CurExGroups, (void *)eg);\r
+                               }\r
+                               >>\r
+                       )*\r
+                       <<CurAltNum++;\r
+/* MR23 */    CurAltNum_array[BlkLevel] = CurAltNum;\r
+            >>\r
+\r
+                       (       "\|" <<inAlt=1;>>\r
+                               alt[toksrefd,rulesrefd]         <<g = Or(g, $2);>>\r
+                               <<\r
+                               ((Junction *)g.left)->blockid = CurBlockID;\r
+                               >>\r
+\r
+                               (       exception_group > [eg]\r
+                                       <<\r
+                                       if ( eg!=NULL ) {\r
+/* MR7 *****           eg->altID = makeAltID(CurBlockID,CurAltNum);        *****/\r
+/* MR7 *****           CurAltStart->exception_label = eg->altID;           *****/\r
+                                               list_add(&CurExGroups, (void *)eg);\r
+                                       }\r
+                                       >>\r
+                               )*\r
+\r
+                               <<CurAltNum++;\r
+/* MR23 */        CurAltNum_array[BlkLevel] = CurAltNum;                \r
+                >>\r
+\r
+                       )*\r
+                       <<$0 = b;>>\r
+                       <<attribsRefdFromAction = saveblah; inAlt = saveinalt;>>\r
+               ;\r
+               <<CannotContinue=TRUE;>>\r
+\r
+/* rule alt */\r
+\r
+alt[set *toksrefd, set *rulesrefd]\r
+               :       <<int n=0; Graph g; int e_num=0, old_not=0; Node *node; set elems, dif;\r
+                       int first_on_line = 1, use_def_MT_handler = 0;\r
+                       g.left=NULL; g.right=NULL;\r
+\r
+                       CurAltStart = NULL;\r
+                       elems = empty;\r
+                       inAlt = 1;\r
+                       >>\r
+                       {       "\@"    /* handle MismatchedToken signals with default handler */\r
+                               <<use_def_MT_handler = 1;>>\r
+                       }\r
+\r
+                       (       <<;>>       /* MR9 Removed unreferenced variable "tok" */\r
+                               { <<old_not=0;>> "\~" <<old_not=1;>> }\r
+                               element[old_not, first_on_line, use_def_MT_handler] > [node]\r
+                               <<if ( node!=NULL && node->ntype!=nAction ) first_on_line = 0;>>\r
+                               <<\r
+                               if ( $2.left!=NULL ) {\r
+                                       g = Cat(g, $2);\r
+                                       n++;\r
+                                       if ( node!=NULL ) {\r
+                                               if ( node->ntype!=nAction ) e_num++;\r
+                                               /* record record number of all rule and token refs */\r
+                                               if ( node->ntype==nToken ) {\r
+                                                       TokNode *tk = (TokNode *)((Junction *)$2.left)->p1;\r
+                                                       tk->elnum = e_num;\r
+                                                       set_orel(e_num, &elems);\r
+                                               }\r
+                                               else if ( node->ntype==nRuleRef ) {\r
+                                                       RuleRefNode *rn = (RuleRefNode *)((Junction *)$2.left)->p1;\r
+                                                       rn->elnum = e_num;\r
+                                                       set_orel(e_num, $rulesrefd);\r
+                                               }\r
+                                       }\r
+                               }\r
+                               >>\r
+                       )*\r
+                       <<if ( n == 0 ) g = emptyAlt();\r
+                         $0 = g;\r
+                         /* We want to reduce number of LT(i) calls and the number of\r
+                          * local attribute variables in C++ mode (for moment, later we'll\r
+                          * do for C also).  However, if trees are being built, they\r
+                          * require most of the attrib variables to create the tree nodes\r
+                          * with; therefore, we gen a token ptr for each token ref in C++\r
+                          */\r
+                         if ( GenCC && !GenAST )\r
+                         {\r
+                                 /* This now free's the temp set -ATG 5/6/95 */\r
+                                 set temp;\r
+                                 temp = set_and(elems, attribsRefdFromAction);\r
+                                 set_orin($toksrefd, temp);\r
+                                 set_free(temp);\r
+                         }\r
+                         else set_orin($toksrefd, elems);\r
+                         if ( GenCC ) {\r
+                               dif = set_dif(attribsRefdFromAction, elems);\r
+                               if ( set_deg(dif)>0 )\r
+                                       err("one or more $i in action(s) refer to non-token elements");\r
+                               set_free(dif);\r
+                         }\r
+                         set_free(elems);\r
+                         set_free(attribsRefdFromAction);\r
+                         inAlt = 0;\r
+                       >>\r
+               ;\r
+               <<CannotContinue=TRUE;>>\r
+\r
+/* rule element_label */\r
+\r
+element_label > [LabelEntry *label]\r
+       :       <<TermEntry *t=NULL; LabelEntry *l=NULL; RuleEntry *r=NULL; char *lab;>>\r
+               LABEL   <<lab = mystrdup(LATEXT(1));>>\r
+               <<\r
+               UsedNewStyleLabel = 1;\r
+               if ( UsedOldStyleAttrib ) err("cannot mix with new-style labels with old-style $i");\r
+               t = (TermEntry *) hash_get(Tname, lab);\r
+               if ( t==NULL ) t = (TermEntry *) hash_get(Texpr, lab);\r
+               if ( t==NULL ) r = (RuleEntry *) hash_get(Rname, lab);\r
+               if ( t!=NULL ) {\r
+                       err(eMsg1("label definition clashes with token/tokclass definition: '%s'", lab));\r
+                       $label = NULL;\r
+               }\r
+               else if ( r!=NULL ) {\r
+                       err(eMsg1("label definition clashes with rule definition: '%s'", lab));\r
+                       $label = NULL;\r
+               }\r
+               else {\r
+                       /* we don't clash with anybody else */\r
+                       l = (LabelEntry *) hash_get(Elabel, lab);\r
+                       if ( l==NULL ) {        /* ok to add new element label */\r
+                               l = (LabelEntry *)hash_add(Elabel,\r
+                                                                                  lab,\r
+                                                                                  (Entry *)newLabelEntry(lab));\r
+                               /* add to list of element labels for this rule */\r
+                               list_add(&CurElementLabels, (void *)lab);\r
+/* MR7 */       leAdd(l);  /* list of labels waiting for exception group definitions */\r
+                               $label = l;\r
+                       }\r
+                       else {\r
+                               err(eMsg1("label definitions must be unique per rule: '%s'", lab));\r
+                               $label = NULL;\r
+                       }\r
+               }\r
+               >>\r
+               ":"\r
+       ;\r
+\r
+/* rule element */\r
+\r
+element[int old_not, int first_on_line, int use_def_MT_handler] > [Node *node]\r
+               : <<\r
+                 Attrib blk;\r
+                 Predicate *pred = NULL;\r
+                 int local_use_def_MT_handler=0;\r
+                 ActionNode *act;\r
+                 RuleRefNode *rr;\r
+                 set toksrefd, rulesrefd;\r
+                 TermEntry *term;\r
+                 TokNode *p=NULL; RuleRefNode *q; int approx=0;\r
+                 LabelEntry *label=NULL;\r
+          int predMsgDone=0;\r
+          int semDepth=0;\r
+          int   ampersandStyle;\r
+          int   height;         /* MR11 */\r
+          int   equal_height;   /* MR11 */\r
+\r
+          char* pFirstSetSymbol = NULL; /* MR21 */\r
+\r
+                 $node = NULL;\r
+                 >>\r
+                 {element_label>[label]}\r
+                 ( TokenTerm\r
+                       <<\r
+                       term = (TermEntry *) hash_get(Tname, LATEXT(1));\r
+                       if ( term==NULL && UserDefdTokens ) {\r
+                               err("implicit token definition not allowed with #tokdefs");\r
+                               $$.left = $$.right = NULL;\r
+                       }\r
+                       else {\r
+                               $$ = buildToken(LATEXT(1));\r
+                               p=((TokNode *)((Junction *)$$.left)->p1);\r
+                               term = (TermEntry *) hash_get(Tname, LATEXT(1));\r
+                               require( term!= NULL, "hash table mechanism is broken");\r
+                               p->tclass = term->tclass;\r
+                               p->complement = $old_not;\r
+                               if ( label!=NULL ) {\r
+                                       p->el_label = label->str;\r
+                                       label->elem = (Node *)p;\r
+                               }\r
+                       }\r
+                       >>\r
+                       {       ".."\r
+                               (       QuotedTerm\r
+                                       <<if ( p!=NULL ) setUpperRange(p, LATEXT(1));>>\r
+                               |       TokenTerm\r
+                                       <<if ( p!=NULL ) setUpperRange(p, LATEXT(1));>>\r
+                               )\r
+                       }\r
+                       <<\r
+                       if ( p!=NULL && (p->upper_range!=0 || p->tclass || $old_not) )\r
+                               list_add(&MetaTokenNodes, (void *)p);\r
+                       >>\r
+                       (       "^"     <<if ( p!=NULL ) p->astnode=ASTroot;>>\r
+                       |               <<if ( p!=NULL ) p->astnode=ASTchild;>>\r
+                       |       "!" <<if ( p!=NULL ) p->astnode=ASTexclude;>>\r
+                       )\r
+                       { "\@" <<local_use_def_MT_handler = 1;>> }\r
+                       <<\r
+                       if ( p!=NULL && $first_on_line ) {\r
+                               CurAltStart = (Junction *)$$.left;\r
+                altAdd(CurAltStart);                                 /* MR7 */\r
+                               p->altstart = CurAltStart;\r
+                       }\r
+                       if ( p!=NULL )\r
+                               p->use_def_MT_handler = $use_def_MT_handler || local_use_def_MT_handler;\r
+                       $node = (Node *)p;\r
+                       >>\r
+                 | QuotedTerm\r
+                       <<\r
+                       term = (TermEntry *) hash_get(Texpr, LATEXT(1));\r
+                       if ( term==NULL && UserDefdTokens ) {\r
+                               err("implicit token definition not allowed with #tokdefs");\r
+                               $$.left = $$.right = NULL;\r
+                       }\r
+                       else {\r
+                               $$ = buildToken(LATEXT(1)); p=((TokNode *)((Junction *)$$.left)->p1);\r
+                               p->complement = $old_not;\r
+                               if ( label!=NULL ) {\r
+                                       p->el_label = label->str;\r
+                                       label->elem = (Node *)p;\r
+                               }\r
+                       }\r
+                       >>\r
+                       {       ".."\r
+                               (       QuotedTerm\r
+                                       <<if ( p!=NULL ) setUpperRange(p, LATEXT(1));>>\r
+                               |       TokenTerm\r
+                                       <<if ( p!=NULL ) setUpperRange(p, LATEXT(1));>>\r
+                               )\r
+                       }\r
+                       (       "^"     <<if ( p!=NULL ) p->astnode=ASTroot;>>\r
+                       |               <<if ( p!=NULL ) p->astnode=ASTchild;>>\r
+                       |       "!" <<if ( p!=NULL ) p->astnode=ASTexclude;>>\r
+                       )\r
+                       { "\@" <<local_use_def_MT_handler = 1;>> }\r
+                       <<\r
+                       if ( p!=NULL && (p->upper_range!=0 || p->tclass || $old_not) )\r
+                               list_add(&MetaTokenNodes, (void *)p);\r
+                       >>\r
+                       <<\r
+                       if ( $first_on_line ) {\r
+                               CurAltStart = (Junction *)$$.left;\r
+                altAdd(CurAltStart);                                 /* MR7 */\r
+                               p->altstart = CurAltStart;\r
+                       }\r
+                       if ( p!=NULL )\r
+                               p->use_def_MT_handler = $use_def_MT_handler || local_use_def_MT_handler;\r
+                       $node = (Node *)p;\r
+                       >>\r
+\r
+                 | <<if ( $old_not ) warn("~ WILDCARD is an undefined operation (implies 'nothing')");>>\r
+                       "."\r
+                       <<$$ = buildWildCard(LATEXT(1)); p=((TokNode *)((Junction *)$$.left)->p1);>>\r
+                       (       "^"     <<p->astnode=ASTroot;>>\r
+                       |               <<p->astnode=ASTchild;>>\r
+                       |       "!" <<p->astnode=ASTexclude;>>\r
+                       )\r
+                       <<list_add(&MetaTokenNodes, (void *)p);>>\r
+                       <<\r
+                       if ( $first_on_line ) {\r
+                               CurAltStart = (Junction *)$$.left;\r
+                altAdd(CurAltStart);                                 /* MR7 */\r
+                               p->altstart = CurAltStart;\r
+                               if ( label!=NULL ) {\r
+                                       p->el_label = label->str;\r
+                                       label->elem = (Node *)p;\r
+                               }\r
+                       }\r
+                       $node = (Node *)p;\r
+                       >>\r
+\r
+                 | <<if ( $old_not ) warn("~ NONTERMINAL is an undefined operation");>>\r
+                       NonTerminal\r
+                       <<$$ = buildRuleRef(LATEXT(1));>>\r
+                       { "!" <<q = (RuleRefNode *) ((Junction *)$$.left)->p1;\r
+                                       q->astnode=ASTexclude;>>\r
+                       }\r
+                       {       {"\<"}\r
+                               PassAction <<addParm(((Junction *)$$.left)->p1, LATEXT(1));>>\r
+                       }\r
+                       <<rr=(RuleRefNode *) ((Junction *)$$.left)->p1;>>\r
+                       {       <<char *a;>>\r
+                               "\>"\r
+                               PassAction\r
+                               <<\r
+                                       a = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));\r
+                                       require(a!=NULL, "rule element: cannot allocate assignment");\r
+                                       strcpy(a, LATEXT(1));\r
+                                       rr->assign = a;\r
+                               >>\r
+                       }\r
+                       <<\r
+                       if ( label!=NULL ) {\r
+                               rr->el_label = label->str;\r
+                               label->elem = (Node *)rr;\r
+                       }\r
+                       if ( $first_on_line ) {\r
+                               CurAltStart = (Junction *)$$.left;\r
+                altAdd(CurAltStart);                                 /* MR7 */\r
+                               ((RuleRefNode *)((Junction *)$$.left)->p1)->altstart = CurAltStart;\r
+                       }\r
+                       $node = (Node *)rr;\r
+                       >>\r
+                 )\r
+\r
+               |       <<if ( $old_not )       warn("~ ACTION is an undefined operation");>>\r
+                       Action <<$0 = buildAction(LATEXT(1),action_file,action_line, 0);>>\r
+                       <<if ( $first_on_line ) {                                /* MR7 */\r
+                CurAltStart = (Junction *)$0.left;                   /* MR7 */\r
+                altAdd(CurAltStart);                                 /* MR7 */\r
+              };>>                                                   /* MR7 */\r
+                       <<$node = (Node *) ((Junction *)$0.left)->p1;>>\r
+\r
+               |       <<if ( $old_not )       warn("~ SEMANTIC-PREDICATE is an undefined operation");>>\r
+                       Pred   <<$0 = buildAction(LATEXT(1),action_file,action_line, 1);>>\r
+                       <<act = (ActionNode *) ((Junction *)$0.left)->p1;>>\r
+            <<if (numericActionLabel) {             /* MR10 */\r
+                list_add(&NumericPredLabels,act);   /* MR10 */\r
+                numericActionLabel=0;               /* MR10 */\r
+              };                                    /* MR10 */\r
+            >>\r
+                       {       <<char *a;>>\r
+                               PassAction\r
+                               <<\r
+                               a = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));\r
+                               require(a!=NULL, "rule element: cannot allocate predicate fail action");\r
+                               strcpy(a, LATEXT(1));\r
+                               act->pred_fail = a;\r
+                               >>\r
+                       }\r
+                       <<if ( $first_on_line ) {                                /* MR7 */\r
+                CurAltStart = (Junction *)$0.left;                   /* MR7 */\r
+                altAdd(CurAltStart);                                 /* MR7 */\r
+              };>>                                                   /* MR7 */\r
+                       <<$node = (Node *)act;>>\r
+\r
+               |       <<if ( $old_not )       warn("~ BLOCK is an undefined operation");>>\r
+                       <<BlkLevel++;\r
+              if (BlkLevel >= MAX_BLK_LEVEL) fatal("Blocks nested too deeply");\r
+/* MR23 */    CurBlockID_array[BlkLevel] = CurBlockID;\r
+/* MR23 */    CurAltNum_array[BlkLevel] = CurAltNum;                \r
+            >>\r
+                       {       Pragma\r
+                               (       "approx" <<approx=LL_k;>>\r
+                               |       "LL\(1\)"  <<approx = 1;>>  /* MR20 */\r
+                               |       "LL\(2\)"  <<approx = 2;>>  /* MR20 */\r
+                )\r
+            }\r
+\r
+/* MR21 */  {  FirstSetSymbol\r
+/* MR21 */     "\("\r
+/* MR21 */             (       NonTerminal\r
+/* MR21 */                <<\r
+/* MR21 */                     pFirstSetSymbol = (char *) calloc(strlen(LATEXT(1))+1,\r
+/* MR21 */                                                    sizeof(char));\r
+/* MR21 */                          require(pFirstSetSymbol!=NULL,\r
+/* MR21 */                                  "cannot allocate first set name");\r
+/* MR21 */                          strcpy(pFirstSetSymbol, LATEXT(1));\r
+/* MR21 */                      >>\r
+/* MR21 */          |    TokenTerm\r
+/* MR21 */                  <<\r
+/* MR21 */                      pFirstSetSymbol = (char *) calloc(strlen(LATEXT(1))+1,\r
+/* MR21 */                                                        sizeof(char));\r
+/* MR21 */                      require(pFirstSetSymbol!=NULL,\r
+/* MR21 */                              "cannot allocate first set name");\r
+/* MR21 */                      strcpy(pFirstSetSymbol, LATEXT(1));\r
+/* MR21 */                  >>\r
+/* MR21 */          )\r
+/* MR21 */      "\)"\r
+/* MR21 */  }\r
+\r
+            (\r
+\r
+               "\(" block[&toksrefd,&rulesrefd] "\)"\r
+                               <<blk = $$ = $2;\r
+                        /* MR23 */      CurBlockID_array[BlkLevel] = (-1);\r
+                        /* MR23 */      CurAltNum_array[BlkLevel] = (-1);                \r
+                  --BlkLevel;\r
+            >>\r
+\r
+                               (       "\*"            <<$$ = makeLoop($$,approx,pFirstSetSymbol);>>\r
+                               |       "\+"            <<$$ = makePlus($$,approx,pFirstSetSymbol);>>\r
+                               |       "?"\r
+                                       (       \r
+                        ( "=>" <<ampersandStyle=0;>>\r
+                        | "&&" <<ampersandStyle=1;>>  /* MR10 (g)? && <<p>>? */\r
+                        )\r
+                        Pred   /* generalized predicate */\r
+                                               /* first make into a predicate */\r
+                                           <<$$ = buildAction(LATEXT(1),action_file,action_line,1);>>\r
+                                           <<act = (ActionNode *) ((Junction *)$$.left)->p1;>>\r
+                        <<semDepth=predicateLookaheadDepth(act);>>  /* MR10 */\r
+                        <<if (numericActionLabel) {             /* MR10 */\r
+                            list_add(&NumericPredLabels,act);   /* MR10 */\r
+                            numericActionLabel=0;               /* MR10 */\r
+                          };                                    /* MR10 */\r
+                        >>\r
+                                               {       <<char *a;>>\r
+                                                       PassAction\r
+                                                       <<\r
+                                                       a = (char *)calloc(strlen(LATEXT(1))+1, sizeof(char));\r
+                                                       require(a!=NULL, "rule element: cannot allocate predicate fail action");\r
+                                                       strcpy(a, LATEXT(1));\r
+                                                       act->pred_fail = a;\r
+                                                       >>\r
+                                               }\r
+                                               <<if ($first_on_line) {                      /* MR7 */\r
+                            CurAltStart=(Junction *)$$.left;         /* MR7 */\r
+                            altAdd(CurAltStart);                     /* MR7 */\r
+                          };>>\r
+                                               <<$node = (Node *)act;>>\r
+\r
+                                               /* for now, just snag context */\r
+                                               <<\r
+                                               pred = computePredFromContextGuard(blk,&predMsgDone);           /* MR10 */\r
+                                               if ( pred==NULL) {                                              /* MR10 */\r
+                          if ( !predMsgDone) err("invalid or missing context guard");   /* MR10 */\r
+                          predMsgDone=1;                                                /* MR10 */\r
+                                               } else {                                                        /* MR10 */\r
+                            act->guardNodes=(Junction *)blk.left;                       /* MR11 */\r
+                                                       pred->expr = act->action;\r
+                                                       pred->source = act;\r
+/* MR10 */                  pred->ampersandStyle = ampersandStyle;  /* 0 means (g)? => ... 1 means (g)? && ... */\r
+/* MR13 */                  if (pred->tcontext != NULL) {\r
+/* MR13 */                    height=MR_max_height_of_tree(pred->tcontext);\r
+/* MR13 */                    equal_height=MR_all_leaves_same_height(pred->tcontext,height);\r
+/* MR13 */                    if (! equal_height) {\r
+/* MR13 */                       errFL("in guarded predicates all tokens in the guard must be at the same height",\r
+/* MR13 */                              FileStr[act->file],act->line);\r
+/* MR13 */                    };\r
+/* MR13 */                  }\r
+/* MR10 */                  if (ampersandStyle) {\r
+/* MR10 */                                       act->ampersandPred = pred;\r
+/* MR11 */                    if (! HoistPredicateContext) {\r
+/* MR11 */                      errFL("without \"-prc on\" (guard)? && <<pred>>? ... doesn't make sense",\r
+/* MR11 */                              FileStr[act->file],act->line);\r
+/* MR11 */                    };\r
+/* MR10 */                  } else {\r
+/* MR10 */                                       act->guardpred = pred;\r
+/* MR10 */                  };\r
+/* MR10 */                  if (pred->k != semDepth) {\r
+/* MR10 */                     warn(eMsgd2("length of guard (%d) does not match the length of semantic predicate (%d)",\r
+/* MR10 */                                  pred->k,semDepth));\r
+/* MR10 */                  };\r
+                                               }\r
+                                               >>\r
+                                       |       <<$$ = makeBlk($$,approx,pFirstSetSymbol);\r
+                                                 FoundGuessBlk = 1;\r
+                                                 ((Junction *) ((Junction *)$$.left)->p1)->guess=1;\r
+                                                 if ( !$first_on_line ) {\r
+                                                       err("(...)? predicate must be first element of production");\r
+                                                 }\r
+                                               >>\r
+                                       )\r
+                               |       <<$$ = makeBlk($$,approx,pFirstSetSymbol);>>\r
+                               )\r
+                               <<\r
+                               if ( pred==NULL && !predMsgDone) {                                      /* MR10 */\r
+                                       ((Junction *)((Junction *)$$.left)->p1)->blockid = CurBlockID;\r
+                                       ((Junction *)((Junction *)$$.left)->p1)->tokrefs = toksrefd;\r
+                                       ((Junction *)((Junction *)$$.left)->p1)->rulerefs = rulesrefd;\r
+                                       if ( $first_on_line ) {                         /* MR7 */\r
+                                          CurAltStart = (Junction *)((Junction *)((Junction *)$$.left)->p1);  /* MR7 */\r
+                       altAdd(CurAltStart);                         /* MR7 */\r
+                    };                                              /* MR7 */\r
+                                       $node = (Node *) ((Junction *)$$.left)->p1;\r
+                               }\r
+                               >>\r
+\r
+                       |       "\{"    block[&toksrefd,&rulesrefd]\r
+                                               <<$$ = makeOpt($2,approx,pFirstSetSymbol);\r
+                                /* MR23 */      CurBlockID_array[BlkLevel] = (-1);\r
+                                /* MR23 */      CurAltNum_array[BlkLevel] = (-1);                \r
+                                --BlkLevel;\r
+                        >>\r
+                               "\}"\r
+                               <<\r
+                               ((Junction *)((Junction *)$$.left)->p1)->blockid = CurBlockID;\r
+                               ((Junction *)((Junction *)$$.left)->p1)->tokrefs = toksrefd;\r
+                               ((Junction *)((Junction *)$$.left)->p1)->rulerefs = rulesrefd;\r
+                               >>\r
+                               <<if ( $first_on_line ) {                            /* MR7 */\r
+                                       CurAltStart = (Junction *) ((Junction *)((Junction *)$$.left)->p1);  /* MR7 */\r
+                    altAdd(CurAltStart);                             /* MR7 */\r
+                  };\r
+                               >>\r
+                               <<$node = (Node *) ((Junction *)$$.left)->p1;>>\r
+\r
+                       )\r
+\r
+/* Error catching alternatives */\r
+               |       "\*"    <<warn("don't you want a ')' with that '*'?"); CannotContinue=TRUE;>>\r
+               |       "\+"    <<warn("don't you want a ')' with that '+'?"); CannotContinue=TRUE;>>\r
+               |       "\>"    <<warn("'>' can only appear after a nonterminal"); CannotContinue=TRUE;>>\r
+               |       PassAction <<warn("[...] out of context 'rule > [...]'");\r
+                                                CannotContinue=TRUE;>>\r
+               ;\r
+               <<CannotContinue=TRUE;>>\r
+\r
+/* rule default_exception_handler */\r
+\r
+default_exception_handler\r
+       :       exception_group > [DefaultExGroup]\r
+       ;\r
+\r
+/* rule exception_group */\r
+\r
+exception_group > [ExceptionGroup *eg]\r
+       :       <<ExceptionHandler *h; LabelEntry *label=NULL;    /* MR6 */\r
+                 FoundException = 1; FoundExceptionGroup = 1;>>  /* MR6 */\r
+\r
+               "exception"      <<$eg = (ExceptionGroup *)calloc(1, sizeof(ExceptionGroup));>>\r
+               {       <<char *p;>>\r
+                       PassAction              /* did they attach a label? */\r
+                       <<\r
+                       p = LATEXT(1)+1;\r
+                       p[strlen(p)-1] = '\0';          /* kill trailing space */\r
+                       label = (LabelEntry *) hash_get(Elabel, LATEXT(1)+1);\r
+                       if ( label==NULL )\r
+                       {\r
+                               err(eMsg1("unknown label in exception handler: '%s'", LATEXT(1)+1));\r
+                       }\r
+                       >>\r
+               }\r
+               (       exception_handler > [h]\r
+                       <<list_add(&($eg->handlers), (void *)h);>>\r
+               )*\r
+               {       "default" ":" Action\r
+                       <<{\r
+                       ExceptionHandler *eh = (ExceptionHandler *)\r
+                               calloc(1, sizeof(ExceptionHandler));\r
+                       char *a = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));\r
+                       require(eh!=NULL, "exception: cannot allocate handler");\r
+                       require(a!=NULL, "exception: cannot allocate action");\r
+                       strcpy(a, LATEXT(1));\r
+                       eh->action = a;\r
+                       eh->signalname = (char *) calloc(strlen("default")+1, sizeof(char));\r
+                       require(eh->signalname!=NULL, "exception: cannot allocate sig name");\r
+                       strcpy(eh->signalname, "default");\r
+                       list_add(&($eg->handlers), (void *)eh);\r
+                       }>>\r
+               }\r
+\r
+               <<\r
+               if ( label!=NULL ) {\r
+               /* Record ex group in sym tab for this label */\r
+                  if ( label->ex_group!=NULL ) {\r
+                     err(eMsg1("duplicate exception handler for label '%s'",label->str));\r
+                  } else {\r
+                         label->ex_group = $eg;\r
+                               /* Label the exception group itself */\r
+                         $eg->label = label->str;\r
+                               /* Make the labelled element pt to the exception also */\r
+/* MR6 */        if (label->elem == NULL) {\r
+/* MR6 */           err(eMsg1("reference in exception handler to undefined label '%s'",label->str));\r
+/* MR6 */        } else {\r
+                                switch ( label->elem->ntype ) {\r
+                                   case nRuleRef :\r
+                        {\r
+                                           RuleRefNode *r = (RuleRefNode *)label->elem;\r
+                                           r->ex_group = $eg;\r
+                                       break;\r
+                        }\r
+                   case nToken :\r
+                                       {\r
+                                               TokNode *t = (TokNode *)label->elem;\r
+                                               t->ex_group = $eg;\r
+                                               break;\r
+                                       }\r
+                                } /* end switch */\r
+/* MR6 */        }; /* end test on label->elem */\r
+                   } /* end test on label->ex_group */\r
+\r
+               } /* end test on exception label */\r
+\r
+/* MR7 */\r
+/* MR7 */   if (BlkLevel == 1 && label == NULL) {\r
+/* MR7 */     $eg->forRule=1;\r
+/* MR7 */   } else if (label == NULL) {\r
+/* MR7 */     $eg->altID = makeAltID(CurBlockID_array[BlkLevel], CurAltNum_array[BlkLevel]);\r
+/* MR7 */     egAdd($eg);\r
+/* MR7 */   } else {\r
+/* MR7 */     $eg->labelEntry=label;\r
+/* MR7 */   };\r
+/* MR7 */\r
+/* MR7 */          /* You may want to remove this exc from the rule list  */\r
+/* MR7 */              /* and handle at the labeled element site.             */\r
+/* MR7 */\r
+/* MR7 */   if (label != NULL) {\r
+/* MR7 */     $eg = NULL;\r
+/* MR7 */   };\r
+\r
+               >>\r
+       ;\r
+       <<CannotContinue=TRUE;>>\r
+\r
+/* rule exception_handler */\r
+\r
+exception_handler > [ExceptionHandler *eh]\r
+       :       <<;>>                               /* MR9 Removed unreferenced variable "a" */\r
+               "catch"\r
+               <<\r
+               $eh = (ExceptionHandler *)calloc(1, sizeof(ExceptionHandler));\r
+               require($eh!=NULL, "exception: cannot allocate handler");\r
+               >>\r
+               (       NonTerminal\r
+                       <<\r
+                       $eh->signalname = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));\r
+                       require($eh->signalname!=NULL, "exception: cannot allocate sig name");\r
+                       strcpy($eh->signalname, LATEXT(1));\r
+                       >>\r
+               |       TokenTerm\r
+                       <<\r
+                       $eh->signalname = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));\r
+                       require($eh->signalname!=NULL, "exception: cannot allocate sig name");\r
+                       strcpy($eh->signalname, LATEXT(1));\r
+                       >>\r
+               )\r
+               ":"\r
+               {       <<$eh->action = NULL;>>\r
+                       Action\r
+                       <<\r
+                       $eh->action = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));\r
+                       require($eh->action!=NULL, "exception: cannot allocate action");\r
+                       strcpy($eh->action, LATEXT(1));\r
+                       >>\r
+               }\r
+       ;\r
+       <<CannotContinue=TRUE;>>\r
+\r
+#token NonTerminal             "[a-z] [A-Za-z0-9_]*"\r
+                                                       <<\r
+                                                       while ( zzchar==' ' || zzchar=='\t' ) {\r
+                                                               zzadvance();\r
+                                                       }\r
+                                                       if ( zzchar == ':' && inAlt ) NLA = LABEL;\r
+                                                       >>\r
+#token TokenTerm               "[A-Z] [A-Za-z0-9_]*"\r
+                                                       <<\r
+                                                       while ( zzchar==' ' || zzchar=='\t' ) {\r
+                                                               zzadvance();\r
+                                                       }\r
+                                                       if ( zzchar == ':' && inAlt ) NLA = LABEL;\r
+                                                       >>\r
+#token "{\\}#[A-Za-z0-9_]*"    <<warn(eMsg1("unknown meta-op: %s",LATEXT(1))); zzskip(); >>\r
+\r
+#lexclass PARSE_ENUM_FILE\r
+\r
+#token "[\t\ ]+"                       << zzskip(); >>                         /* Ignore White */\r
+#token "\n|\r|\r\n"                    << zzline++; zzskip(); >>       /* Track Line # */\r
+#token "//"                                    << zzmode(TOK_DEF_CPP_COMMENTS); zzmore(); >>\r
+#token "/\*"                           << zzmode(TOK_DEF_COMMENTS); zzskip(); >>\r
+#token "#ifdef"                                << zzmode(TOK_DEF_CPP_COMMENTS); zzskip(); >>\r
+#token "#if"                           << zzmode(TOK_DEF_CPP_COMMENTS); zzskip(); >>\r
+#token "#ifndef"                       << ; >>\r
+#token "#else"                         << zzmode(TOK_DEF_CPP_COMMENTS); zzskip(); >>\r
+#token "#endif"                                << zzmode(TOK_DEF_CPP_COMMENTS); zzskip(); >>\r
+#token "#undef"                                << zzmode(TOK_DEF_CPP_COMMENTS); zzskip(); >>\r
+#token "#import"                       << zzmode(TOK_DEF_CPP_COMMENTS); zzskip(); >>\r
+#token "@"                                     << ; >>\r
+\r
+/* rule enum_file */\r
+\r
+enum_file[char *fname]\r
+       :       {       "#ifndef" ID\r
+                       {       "#define" ID /* ignore if it smells like a gate */\r
+                               /* First #define after the first #ifndef (if any) is ignored */\r
+                       }\r
+               }\r
+               (       ( enum_def[$fname] )+\r
+               |       defines[$fname]\r
+               )\r
+       |\r
+       ;\r
+\r
+/* rule defines */\r
+\r
+defines[char *fname]\r
+       :       <<int v; int maxt=(-1); char *t;>>              /* MR3 */\r
+               (\r
+                       "#define" ID\r
+                       <<t = mystrdup(LATEXT(1));>>\r
+                       INT\r
+                       <<\r
+                       v = atoi(LATEXT(1));\r
+/*                     fprintf(stderr, "#token %s=%d\n", t, v);*/\r
+\r
+       /* MR2 Andreas Magnusson (Andreas.Magnusson@mailbox.swipnet.se) */\r
+       /* MR2 Fix to bug introduced by 1.33MR1 for #tokdefs            */\r
+       /* MR2 Don't let #tokdefs be confused by                        */\r
+       /* MR2   DLGminToken and DLGmaxToken                            */\r
+\r
+                       if ( ! isDLGmaxToken(t)) {              /* MR2 */\r
+                         TokenNum = v;\r
+                         if ( v>maxt ) maxt=v;\r
+                         if ( Tnum( t ) == 0 ) {\r
+                           addForcedTname( t, v );\r
+                         } else {\r
+                           warnFL(eMsg1("redefinition of token %s; ignored",t),$fname,zzline);\r
+                         };\r
+                       };\r
+                       >>\r
+               )+\r
+               <<TokenNum = maxt + 1;>>\r
+       ;\r
+\r
+/* rule enum_def */\r
+\r
+enum_def[char *fname]\r
+       :       <<int v= 0; int maxt=(-1); char *t;>>                   /* MR3 */\r
+               "enum" ID\r
+               "\{"\r
+                       ID\r
+                       <<t = mystrdup(LATEXT(1));>>\r
+                       (       "=" INT <<v=atoi(LATEXT(1));>>\r
+                       |                       <<v++;>>\r
+                       )\r
+                       <<\r
+/*                     fprintf(stderr, "#token %s=%d\n", t, v);*/\r
+                       TokenNum = v;\r
+                       if ( v>maxt ) maxt=v;                           /* MR3 */\r
+                       if ( Tnum( t ) == 0 ) addForcedTname( t, v );\r
+                       else {\r
+                               warnFL(eMsg1("redefinition of token %s; ignored",t),$fname,zzline);\r
+                       }\r
+                       >>\r
+                       (       ","\r
+\r
+                               /* MR2 Andreas Magnusson (Andreas.Magnusson@mailbox.swipnet.se) */\r
+                               /* MR2 Fix to bug introduced by 1.33MR1 for #tokdefs            */\r
+                               /* MR2 Don't let #tokdefs be confused by                        */\r
+                               /* MR2   DLGminToken and DLGmaxToken                            */\r
+\r
+                               {\r
+                                 <<isDLGmaxToken(LATEXT(1))>>? ID { "=" INT }          /* MR2 */\r
+                               | ID                                                    /* MR2 */\r
+                                       <<t = mystrdup(LATEXT(1));>>\r
+                                       (       "=" INT <<v=atoi(LATEXT(1));>>\r
+                                       |                       <<v++;>>\r
+                                       )\r
+                                       <<\r
+/*                                     fprintf(stderr, "#token %s=%d\n", t, v);*/\r
+                                       TokenNum = v;\r
+                                       if ( v>maxt ) maxt=v;                           /* MR3 */\r
+                                       if ( Tnum( t ) == 0 ) addForcedTname( t, v );\r
+                                       else {\r
+                                               warnFL(eMsg1("redefinition of token %s; ignored",t),$fname,zzline);\r
+                                       }\r
+                                       >>\r
+                               }\r
+                       )*\r
+               "\}"\r
+               ";"\r
+               <<TokenNum = maxt + 1;>>                                        /* MR3 */\r
+       ;\r
+\r
+#token INT     "[0-9]+"\r
+#token ID      "[a-zA-Z_][_a-zA-Z0-9]*"\r
+\r
+#lexclass START\r
+\r
+/* MR14 Arpad Beszedes  26-May-98\r
+        Add support for #line directives when antlr source is pre-processed\r
+*/\r
+\r
+#lexaction\r
+<<\r
+\r
+static char *\r
+#ifdef __USE_PROTOS\r
+getFileNameFromTheLineInfo(char *toStr, char *fromStr)\r
+#else\r
+getFileNameFromTheLineInfo(toStr, fromStr)\r
+char *toStr, *fromStr;\r
+#endif\r
+{\r
+  int i, j, k;\r
+\r
+  if (!fromStr || !toStr) return toStr;\r
+\r
+  /* find the first " */\r
+\r
+  for (i=0;\r
+        (i<MaxFileName) &&\r
+        (fromStr[i] != '\n') &&\r
+        (fromStr[i] != '\r') &&\r
+        (fromStr[i] != '\"');\r
+      i++) /* nothing */ ;\r
+\r
+  if ( (i == MaxFileName) ||\r
+       (fromStr[i] == '\n') ||\r
+       (fromStr[i] == '\r') ) {\r
+    return toStr;\r
+  }\r
+\r
+  /* find the second " */\r
+\r
+  for (j=i+1;\r
+        (j<MaxFileName) &&\r
+        (fromStr[j] != '\n') &&\r
+        (fromStr[j] != '\r') &&\r
+        (fromStr[j] != '\"');\r
+       j++) /* nothing */ ;\r
+\r
+  if ((j == MaxFileName) ||\r
+      (fromStr[j] == '\n') ||\r
+      (fromStr[j] == '\r') ) {\r
+    return toStr;\r
+  }\r
+\r
+  /* go back until the last / or \ */\r
+\r
+  for (k=j-1;\r
+        (fromStr[k] != '\"') &&\r
+        (fromStr[k] != '/') &&\r
+        (fromStr[k] != '\\');\r
+       k--) /* nothing */ ;\r
+\r
+  /* copy the string after " / or \ into toStr */\r
+\r
+  for (i=k+1; fromStr[i] != '\"'; i++) {\r
+    toStr[i-k-1] = fromStr[i];\r
+  }\r
+\r
+  toStr[i-k-1] = '\0';\r
+\r
+  return toStr;\r
+}\r
+\r
+/* MR14 end of a block to support #line in antlr source code */\r
+\r
+>>\r
+\r
+<<\r
+\r
+/* MR2 Andreas Magnusson (Andreas.Magnusson@mailbox.swipnet.se) */\r
+/* MR2 Fix to bug introduced by 1.33MR1 for #tokdefs            */\r
+/* MR2 Don't let #tokdefs be confused by                       */\r
+/* MR2   DLGminToken and DLGmaxToken                           */\r
+\r
+/* semantic check on DLGminToken and DLGmaxmaxToken in #tokdefs */\r
+\r
+#ifdef __USE_PROTOS\r
+static int isDLGmaxToken(char *Token)\r
+#else\r
+static int isDLGmaxToken(Token)\r
+  char *       Token;\r
+#endif\r
+{\r
+   static char checkStr1[] = "DLGmaxToken";\r
+   static char checkStr2[] = "DLGminToken";\r
+\r
+   if (strcmp(Token, checkStr1) == 0)\r
+      return 1;\r
+   else if (strcmp(Token, checkStr2) == 0)\r
+      return 1;\r
+   else\r
+      return 0;\r
+}\r
+\r
+/* semantics of #token */\r
+static void\r
+#ifdef __USE_PROTOS\r
+chkToken(char *t, char *e, char *a, int tnum)\r
+#else\r
+chkToken(t,e,a,tnum)\r
+char *t, *e, *a;\r
+int tnum;\r
+#endif\r
+{\r
+       TermEntry *p;\r
+\r
+       /* check to see that they don't try to redefine a token as a token class */\r
+       if ( t!=NULL ) {\r
+               p = (TermEntry *) hash_get(Tname, t);\r
+               if ( p!=NULL && p->classname ) {\r
+                       err(eMsg1("redefinition of #tokclass '%s' to #token not allowed; ignored",t));\r
+                       if ( a!=NULL ) free((char *)a);\r
+                       return;\r
+               }\r
+       }\r
+\r
+       if ( t==NULL && e==NULL ) {                     /* none found */\r
+               err("#token requires at least token name or rexpr");\r
+       }\r
+       else if ( t!=NULL && e!=NULL ) {        /* both found */\r
+               if ( UserDefdTokens ) {                 /* if #tokdefs, must not define new */\r
+                       p = (TermEntry *) hash_get(Tname, t);\r
+                       if ( p == NULL) {\r
+err(eMsg1("new token definition '%s' not allowed - only #token with name already defined by #tokdefs file allowed",t));\r
+                       return;\r
+            };\r
+               }\r
+               Tklink(t, e);\r
+               if ( a!=NULL ) {\r
+                       if ( hasAction(e) ) {\r
+                               err(eMsg1("redefinition of action for %s; ignored",e));\r
+                       }\r
+                       else setHasAction(e, a);\r
+               }\r
+       }\r
+       else if ( t!=NULL ) {                           /* only one found */\r
+               if ( UserDefdTokens ) {\r
+                       p = (TermEntry *) hash_get(Tname, t);\r
+            if (p == NULL) {\r
+err(eMsg1("new token definition '%s' not allowed - only #token with name already defined by #tokdefs file allowed",t));\r
+            };\r
+                   return;\r
+               }\r
+               if ( Tnum( t ) == 0 ) addTname( t );\r
+               else {\r
+                       err(eMsg1("redefinition of token %s; ignored",t));\r
+               }\r
+               if ( a!=NULL ) {\r
+                       err(eMsg1("action cannot be attached to a token name (%s); ignored",t));\r
+                       free((char *)a);\r
+               }\r
+       }\r
+       else if ( e!=NULL ) {\r
+               if ( Tnum( e ) == 0 ) addTexpr( e );\r
+               else {\r
+                       if ( hasAction(e) ) {\r
+                               err(eMsg1("redefinition of action for expr %s; ignored",e));\r
+                       }\r
+                       else if ( a==NULL ) {\r
+                               err(eMsg1("redefinition of expr %s; ignored",e));\r
+                       }\r
+               }\r
+               if ( a!=NULL ) setHasAction(e, a);\r
+       }\r
+\r
+       /* if a token type number was specified, then add the token ID and 'tnum'\r
+        * pair to the ForcedTokens list.  (only applies if an id was given)\r
+        */\r
+       if ( t!=NULL && tnum>0 )\r
+       {\r
+               if ( set_el(tnum, reserved_positions) )\r
+               {\r
+                       err(eMsgd("a token has already been forced to token number %d; ignored", tnum));\r
+               }\r
+               else\r
+               {\r
+                       list_add(&ForcedTokens, newForcedToken(t,tnum));\r
+                       set_orel(tnum, &reserved_positions);\r
+               }\r
+       }\r
+}\r
+>>\r
+\r
+<<\r
+static int\r
+#ifdef __USE_PROTOS\r
+match_token(char *s, char **nxt)\r
+#else\r
+match_token(s,nxt)\r
+char *s;\r
+char **nxt;\r
+#endif\r
+{\r
+    if ( !(*s>='A' && *s<='Z') ) return 0;\r
+       s++;\r
+    while ( (*s>='a' && *s<='z') ||\r
+                   (*s>='A' && *s<='Z') ||\r
+                   (*s>='0' && *s<='9') ||\r
+                   *s=='_' )\r
+    {\r
+          s++;\r
+       }\r
+       if ( *s!=' ' && *s!='}' ) return 0;\r
+       *nxt = s;\r
+       return 1;\r
+}\r
+\r
+static int\r
+#ifdef __USE_PROTOS\r
+match_rexpr(char *s, char **nxt)\r
+#else\r
+match_rexpr(s,nxt)\r
+char *s;\r
+char **nxt;\r
+#endif\r
+{\r
+    if ( *s!='"' ) return 0;\r
+       s++;\r
+    while ( *s!='"' )\r
+    {\r
+          if ( *s=='\n' || *s=='\r' )                   /* MR13 */\r
+                 warn("eoln found in regular expression");\r
+          if ( *s=='\\' ) s++;\r
+          s++;\r
+       }\r
+       *nxt = s+1;\r
+       return 1;\r
+}\r
+\r
+/*\r
+ * Walk a string "{ A .. Z }" where A..Z is a space separated list\r
+ * of token references (either labels or reg exprs).  Return a\r
+ * string "inlineX_set" for some unique integer X.  Basically,\r
+ * we pretend as if we had seen "#tokclass inlineX { A .. Z }"\r
+ * on the input stream outside of an action.\r
+ */\r
+char *\r
+#ifdef __USE_PROTOS\r
+inline_set(char *s)\r
+#else\r
+inline_set(s)\r
+char *s;\r
+#endif\r
+{\r
+       char *nxt;\r
+    fprintf(stderr, "found consumeUntil( {...} )\n");\r
+       while ( *s==' ' || *s=='\t' || *s=='\n' || *s=='\r' ) {s++;}\r
+       if ( *s!='{' )\r
+       {\r
+          err("malformed consumeUntil( {...} ); missing '{'");\r
+          return "bad_set";\r
+       }\r
+       s++;\r
+       while ( *s==' ' || *s=='\t' || *s=='\n' || *s=='\r' ) {s++;}\r
+       while ( *s!='}' )\r
+       {\r
+           if ( match_token(s,&nxt) ) fprintf(stderr, "found token %s\n", s);\r
+               else if ( match_rexpr(s,&nxt) ) fprintf(stderr, "found rexpr %s\n", s);\r
+               else {\r
+                   err("invalid element in consumeUntil( {...} )");\r
+                       return "bad_set";\r
+               }\r
+               s = nxt;\r
+               while ( *s==' ' || *s=='\t' || *s=='\n' || *s=='\r' ) {s++;}\r
+       }\r
+       return "inlineX_set";\r
+}\r
+>>\r
+\r
+<<\r
+/* ANTLR-specific syntax error message generator\r
+ * (define USER_ZZSYN when compiling so don't get 2 definitions)\r
+ */\r
+void\r
+#ifdef __USE_PROTOS\r
+zzsyn(char *text, int tok, char *egroup, SetWordType *eset, int etok,\r
+int k, char *bad_text)\r
+#else\r
+zzsyn(text, tok, egroup, eset, etok, k, bad_text)\r
+char *text, *egroup, *bad_text;\r
+int tok;\r
+int etok;\r
+int k;\r
+SetWordType *eset;\r
+#endif\r
+{\r
+       fprintf(stderr, ErrHdr, FileStr[CurFile]!=NULL?FileStr[CurFile]:"stdin", zzline);\r
+       fprintf(stderr, " syntax error at \"%s\"", (tok==zzEOF_TOKEN)?"EOF":text);\r
+       if ( !etok && !eset ) {fprintf(stderr, "\n"); return;}\r
+       if ( k==1 ) fprintf(stderr, " missing");\r
+       else\r
+       {\r
+               fprintf(stderr, "; \"%s\" not", bad_text);\r
+               if ( zzset_deg(eset)>1 ) fprintf(stderr, " in");\r
+       }\r
+       if ( zzset_deg(eset)>0 ) zzedecode(eset);\r
+       else fprintf(stderr, " %s", zztokens[etok]);\r
+       if ( strlen(egroup) > (size_t)0 ) fprintf(stderr, " in %s", egroup);\r
+       fprintf(stderr, "\n");\r
+}\r
+>>\r
+\r
+#lexaction <<\r
+#ifdef __USE_PROTOS\r
+void mark_label_used_in_sem_pred(LabelEntry *le)              /* MR10 */\r
+#else\r
+void mark_label_used_in_sem_pred(le)                          /* MR10 */\r
+  LabelEntry    *le;\r
+#endif\r
+{\r
+  TokNode   *tn;\r
+  require (le->elem->ntype == nToken,"mark_label_used... ntype != nToken");\r
+  tn=(TokNode *)le->elem;\r
+  require (tn->label != 0,"mark_label_used... TokNode has no label");\r
+  tn->label_used_in_semantic_pred=1;\r
+}\r
+>>\r
diff --git a/Tools/CodeTools/Source/Pccts/antlr/antlr.r b/Tools/CodeTools/Source/Pccts/antlr/antlr.r
new file mode 100644 (file)
index 0000000..e3de387
--- /dev/null
@@ -0,0 +1,787 @@
+/*\r
+       File:           antlrMPW.r\r
+       Target:         antlr 133MR\r
+       Created:    Monday, June 15, 1998 4:41:11 AM\r
+       Author:         Kenji Tanaka (kentar@osa.att.ne.jp)\r
+*/\r
+\r
+#include "cmdo.r"\r
+\r
+resource 'cmdo' (128, "Antlr") {\r
+       {       /* array dialogs: 5 elements */\r
+               /* [1] */\r
+               295,\r
+               "ANTLR -- Purdue Compiler Construction To"\r
+               "ol Set (PCCTS) LL(k) parser generator.",\r
+               {       /* array itemArray: 12 elements */\r
+                       /* [1] */\r
+                       NotDependent {\r
+\r
+                       },\r
+                       CheckOption {\r
+                               NotSet,\r
+                               {18, 23, 33, 223},\r
+                               "Read grammar from stdin",\r
+                               "-",\r
+                               "Read grammar from stdin."\r
+                       },\r
+                       /* [2] */\r
+                       NotDependent {\r
+\r
+                       },\r
+                       CheckOption {\r
+                               NotSet,\r
+                               {38, 23, 53, 310},\r
+                               "Send grammar.c/grammar.cpp to stdout",\r
+                               "-stdout",\r
+                               "Send grammar.c/grammar.cpp to stdout."\r
+                       },\r
+                       /* [3] */\r
+                       NotDependent {\r
+\r
+                       },\r
+                       MultiFiles {\r
+                               "Grammar File(s)É",\r
+                               "Choose the grammar specification files y"\r
+                               "ou wish to have ANTLR process.",\r
+                               {79, 22, 98, 152},\r
+                               "Grammar specification:",\r
+                               "",\r
+                               MultiInputFiles {\r
+                                       {       /* array MultiTypesArray: 1 elements */\r
+                                               /* [1] */\r
+                                               text\r
+                                       },\r
+                                       ".g",\r
+                                       "Files ending in .g",\r
+                                       "All text files"\r
+                               }\r
+                       },\r
+                       /* [4] */\r
+                       NotDependent {\r
+\r
+                       },\r
+                       Files {\r
+                               DirOnly,\r
+                               OptionalFile {\r
+                                       {58, 168, 74, 298},\r
+                                       {79, 169, 98, 299},\r
+                                       "Output Directory",\r
+                                       ":",\r
+                                       "-o",\r
+                                       "",\r
+                                       "Choose the directory where ANTLR will pu"\r
+                                       "t its output.",\r
+                                       dim,\r
+                                       "Output DirectoryÉ",\r
+                                       "",\r
+                                       ""\r
+                               },\r
+                               NoMore {\r
+\r
+                               }\r
+                       },\r
+                       /* [5] */\r
+                       NotDependent {\r
+\r
+                       },\r
+                       Redirection {\r
+                               StandardOutput,\r
+                               {126, 27}\r
+                       },\r
+                       /* [6] */\r
+                       NotDependent {\r
+\r
+                       },\r
+                       Redirection {\r
+                               DiagnosticOutput,\r
+                               {126, 178}\r
+                       },\r
+                       /* [7] */\r
+                       NotDependent {\r
+\r
+                       },\r
+                       TextBox {\r
+                               gray,\r
+                               {117, 20, 167, 300},\r
+                               "Redirection"\r
+                       },\r
+                       /* [8] */\r
+                       NotDependent {\r
+\r
+                       },\r
+                       NestedDialog {\r
+                               5,\r
+                               {20, 324, 40, 460},\r
+                               "Parse OptionsÉ",\r
+                               "Parse control options may be set with th"\r
+                               "is button."\r
+                       },\r
+                       /* [9] */\r
+                       NotDependent {\r
+\r
+                       },\r
+                       NestedDialog {\r
+                               2,\r
+                               {50, 324, 70, 460},\r
+                               "Generate OptionsÉ",\r
+                               "Various command line options may be set "\r
+                               "with this button."\r
+                       },\r
+                       /* [10] */\r
+                       NotDependent {\r
+\r
+                       },\r
+                       NestedDialog {\r
+                               3,\r
+                               {78, 324, 98, 460},\r
+                               "More OptionsÉ",\r
+                               "Antlr has ALOT of options. There are eve"\r
+                               "n more to be found with this button."\r
+                       },\r
+                       /* [11] */\r
+                       NotDependent {\r
+\r
+                       },\r
+                       NestedDialog {\r
+                               4,\r
+                               {106, 324, 126, 460},\r
+                               "Rename OptionsÉ",\r
+                               "Options for renaming output files may be"\r
+                               " set with this button."\r
+                       },\r
+                       /* [12] */\r
+                       NotDependent {\r
+\r
+                       },\r
+                       VersionDialog {\r
+                               VersionString {\r
+                                       "1.33MR"\r
+                               },\r
+                               "PCCTS was written by Terence Parr, Russe"\r
+                               "ll Quong, Will Cohen, and Hank Dietz: 19"\r
+                               "89-1998. MPW port by Scott Haney.",\r
+                               noDialog\r
+                       }\r
+               },\r
+               /* [2] */\r
+               295,\r
+               "Use this dialog to specify command line "\r
+               "Generate Options.",\r
+               {       /* array itemArray: 15 elements */\r
+                       /* [1] */\r
+                       NotDependent {\r
+\r
+                       },\r
+                       CheckOption {\r
+                               NotSet,\r
+                               {18, 25, 33, 225},\r
+                               "Generate C++ code",\r
+                               "-CC",\r
+                               "Generate C++ output from both ANTLR and "\r
+                               "DLG."\r
+                       },\r
+                       /* [2] */\r
+                       NotDependent {\r
+\r
+                       },\r
+                       CheckOption {\r
+                               NotSet,\r
+                               {38, 25, 53, 225},\r
+                               "Generate ASTs",\r
+                               "-gt",\r
+                               "Generate code for Abstract-Syntax-Trees "\r
+                               "(ASTs)."\r
+                       },\r
+                       /* [3] */\r
+                       NotDependent {\r
+\r
+                       },\r
+                       CheckOption {\r
+                               NotSet,\r
+                               {58, 25, 73, 225},\r
+                               "Generate line info",\r
+                               "-gl",\r
+                               "If this option is checked, ANTLR will ge"\r
+                               "nerate line info about grammaractions, t"\r
+                               "hereby making debugging easier since com"\r
+                               "pile errors will point to the grammar fi"\r
+                               "le."\r
+                       },\r
+                       /* [4] */\r
+                       NotDependent {\r
+\r
+                       },\r
+                       CheckOption {\r
+                               NotSet,\r
+                               {78, 25, 93, 225},\r
+                               "Generate error classes",\r
+                               "-ge",\r
+                               "If this option is checked, ANTLR will ge"\r
+                               "nerate an error class foreach non-termin"\r
+                               "al."\r
+                       },\r
+                       /* [5] */\r
+                       NotDependent {\r
+\r
+                       },\r
+                       CheckOption {\r
+                               NotSet,\r
+                               {98, 25, 113, 225},\r
+                               "Don't generate Code",\r
+                               "-gc",\r
+                               "If this option is checked, ANTLR will ge"\r
+                               "nerate no code, i.e. it will only perfor"\r
+                               "m analysis on the grammar."\r
+                       },\r
+                       /* [6] */\r
+                       NotDependent {\r
+\r
+                       },\r
+                       CheckOption {\r
+                               NotSet,\r
+                               {118, 25, 133, 225},\r
+                               "Delay lookahead fetches",\r
+                               "-gk",\r
+                               "If this option is checked, ANTLR will ge"\r
+                               "nerate a parser that delays lookahead fe"\r
+                               "tches until needed."\r
+                       },\r
+                       /* [7] */\r
+                       NotDependent {\r
+\r
+                       },\r
+                       CheckOption {\r
+                               NotSet,\r
+                               {138, 25, 153, 225},\r
+                               "Use newAST(...)",\r
+                               "-newAST",\r
+                               "In C++ mode use \"newAST(...)\" rather tha"\r
+                               "n \"new AST(...)\""\r
+                       },\r
+                       /* [8] */\r
+                       NotDependent {\r
+\r
+                       },\r
+                       CheckOption {\r
+                               NotSet,\r
+                               {18, 235, 33, 435},\r
+                               "Support parse traces",\r
+                               "-gd",\r
+                               "If this option is checked, ANTLR inserts"\r
+                               " code in each parsing function to provid"\r
+                               "e for user-defined handling of a detaile"\r
+                               "d parse trace. The code consists of call"\r
+                               "s to zzTRACEIN and zzTRACEOUT."\r
+                       },\r
+                       /* [9] */\r
+                       NotDependent {\r
+\r
+                       },\r
+                       CheckOption {\r
+                               NotSet,\r
+                               {38, 235, 53, 435},\r
+                               "Generate cross-references",\r
+                               "-cr",\r
+                               "If this option is checked, ANTLR will ge"\r
+                               "nerate a cross reference for all rules. "\r
+                               "For each rule it will print a list of al"\r
+                               "l other rules that refrence it."\r
+                       },\r
+                       /* [10] */\r
+                       NotDependent {\r
+\r
+                       },\r
+                       CheckOption {\r
+                               NotSet,\r
+                               {58, 235, 73, 435},\r
+                               "Don't create Lexer files",\r
+                               "-gx",\r
+                               "If this option is checked, ANTLR will no"\r
+                               "t generate DLG-related output files. Thi"\r
+                               "s option should be used if one wants a c"\r
+                               "ustom lexical analyzer or if one has mad"\r
+                               "e changes to the grammar not affecting t"\r
+                               "he lexical structure."\r
+                       },\r
+                       /* [11] */\r
+                       NotDependent {\r
+\r
+                       },\r
+                       CheckOption {\r
+                               NotSet,\r
+                               {78, 235, 93, 460},\r
+                               "Don't generate token expr sets",\r
+                               "-gs",\r
+                               "If this option is checked, ANTLR will no"\r
+                               "t generate sets for token expression set"\r
+                               "s; instead, it will generate a || separa"\r
+                               "ted sequence of LA(1)==token #. "\r
+                       },\r
+                       /* [12] */\r
+                       NotDependent {\r
+\r
+                       },\r
+                       CheckOption {\r
+                               NotSet,\r
+                               {98, 235, 113, 460},\r
+                               "Generate ANSI-compatible",\r
+                               "-ga",\r
+                               "Generate ANSI-compatible code (default=F"\r
+                               "ALSE)"\r
+                       },\r
+                       /* [13] */\r
+                       NotDependent {\r
+\r
+                       },\r
+                       CheckOption {\r
+                               NotSet,\r
+                               {118, 235, 133, 460},\r
+                               "Don't generate tokens.h",\r
+                               "-gxt",\r
+                               "Do not generate tokens.h (default=FALSE)"\r
+                       },\r
+                       /* [13] */\r
+                       NotDependent {\r
+\r
+                       },\r
+                       CheckOption {\r
+                               NotSet,\r
+                               {138, 235, 153, 460},\r
+                               "Provide \"(alpha)? beta\" info",\r
+                               "-alpha",\r
+                               "Provide additional information for \"(alpha)? beta\" error messages"\r
+                       },\r
+                       /* [14] */\r
+                       NotDependent {\r
+\r
+                       },\r
+                       RegularEntry {\r
+                               "Tabs(1 to 8):",\r
+                               {162, 23, 177, 117},\r
+                               {163, 125, 179, 196},\r
+                               "",\r
+                               keepCase,\r
+                               "-tab",\r
+                               "Width of tabs (1 to 8) for grammar.c/gra"\r
+                               "mmar.cpp files."\r
+                       },\r
+                       /* [15] */\r
+                       NotDependent {\r
+\r
+                       },\r
+                       RegularEntry {\r
+                               "Function Prefix:",\r
+                               {161, 236, 177, 342},\r
+                               {162, 345, 177, 454},\r
+                               "",\r
+                               keepCase,\r
+                               "-gp",\r
+                               "Prefix all generated rule functions with"\r
+                               " a string."\r
+                       }\r
+               },\r
+               /* [3] */\r
+               295,\r
+               "Use this dialog to specify still more co"\r
+               "mmand line options.",\r
+               {       /* array itemArray: 12 elements */\r
+                       /* [1] */\r
+                       NotDependent {\r
+\r
+                       },\r
+                       RadioButtons {\r
+                               {       /* array radioArray: 3 elements */\r
+                                       /* [1] */\r
+                                       {38, 25, 53, 85}, "None", "", Set, "When this option is selected, ANTLR will"\r
+                                       " not print the grammar to stdout.",\r
+                                       /* [2] */\r
+                                       {38, 100, 53, 160}, "Yes", "-p", NotSet, "When this option is selected, ANTLR will"\r
+                                       " print the grammar, stripped of all acti"\r
+                                       "ons and comments, to stdout.",\r
+                                       /* [3] */\r
+                                       {38, 175, 53, 235}, "More", "-pa", NotSet, "When this option is selected, ANTLR will"\r
+                                       " print the grammar, stripped of all acti"\r
+                                       "ons and comments, to stdout. It will als"\r
+                                       "o annotate the output with the first set"\r
+                                       "s determined from grammar analysis."\r
+                               }\r
+                       },\r
+                       /* [2] */\r
+                       NotDependent {\r
+\r
+                       },\r
+                       TextBox {\r
+                               gray,\r
+                               {28, 15, 60, 250},\r
+                               "Grammar Printing"\r
+                       },\r
+                       /* [3] */\r
+                       NotDependent {\r
+\r
+                       },\r
+                       RadioButtons {\r
+                               {       /* array radioArray: 3 elements */\r
+                                       /* [1] */\r
+                                       {88, 25, 103, 85}, "Low", "", Set, "When this option is selected, ANTLR will"\r
+                                       " show ambiguities/errors in low detail.",\r
+                                       /* [2] */\r
+                                       {88, 100, 103, 160}, "Medium", "-e2", NotSet, "When this option is selected, ANTLR will"\r
+                                       " show ambiguities/errors in more detail.",\r
+                                       /* [3] */\r
+                                       {88, 175, 103, 235}, "High", "-e3", NotSet, "When this option is selected, ANTLR will"\r
+                                       " show ambiguities/errors in excruciating"\r
+                                       " detail."\r
+                               }\r
+                       },\r
+                       /* [4] */\r
+                       NotDependent {\r
+\r
+                       },\r
+                       TextBox {\r
+                               gray,\r
+                               {78, 15, 110, 250},\r
+                               "Error reporting"\r
+                       },\r
+                       /* [5] */\r
+                       NotDependent {\r
+\r
+                       },\r
+                       CheckOption {\r
+                               NotSet,\r
+                               {130, 22, 145, 222},\r
+                               "More warnings",\r
+                               "-w2",\r
+                               "If this option is checked, ANTLR will wa"\r
+                               "rn if semantic predicates and/or (É)? bl"\r
+                               "ocks are assumed to cover ambiguous alte"\r
+                               "rnatives."\r
+                       },\r
+                       /* [6] */\r
+                       NotDependent {\r
+\r
+                       },\r
+                       RegularEntry {\r
+                               "Report when tnode usage exceeds:",\r
+                               {162, 23, 180, 253},\r
+                               {162, 255, 178, 326},\r
+                               "",\r
+                               keepCase,\r
+                               "-treport",\r
+                               "Report when tnode usage exceeds value du"\r
+                               "ring ambiguity resolution."\r
+                       },\r
+                       /* [7] */\r
+                       NotDependent {\r
+\r
+                       },\r
+                       CheckOption {\r
+                               NotSet,\r
+                               {40, 292, 55, 431},\r
+                               "Predicate",\r
+                               "-info p",\r
+                               "With the antlr \"-info p\" switch the user"\r
+                               " will receive information about the pred"\r
+                               "icate suppression in the generated file."\r
+                       },\r
+                       /* [8] */\r
+                       NotDependent {\r
+\r
+                       },\r
+                       CheckOption {\r
+                               NotSet,\r
+                               {60, 292, 75, 430},\r
+                               "Tree Nodes",\r
+                               "-info t",\r
+                               "Using \"-info t\" gives information about "\r
+                               "the total number of tnodes created and t"\r
+                               "he peak number of tnodes."\r
+                       },\r
+                       /* [9] */\r
+                       NotDependent {\r
+\r
+                       },\r
+                       CheckOption {\r
+                               NotSet,\r
+                               {80, 292, 95, 425},\r
+                               "First/follow",\r
+                               "-info f",\r
+                               "first/follow set information."\r
+                       },\r
+                       /* [10] */\r
+                       NotDependent {\r
+\r
+                       },\r
+                       CheckOption {\r
+                               NotSet,\r
+                               {100, 292, 115, 425},\r
+                               "Monitor progress",\r
+                               "-info m",\r
+                               "prints name of each rule as it is starte"\r
+                               "d and flushes output at start of each rule."\r
+                       },\r
+                       /* [11] */\r
+                       NotDependent {\r
+\r
+                       },\r
+                       CheckOption {\r
+                               NotSet,\r
+                               {120, 292, 135, 416},\r
+                               "Orphan rules",\r
+                               "-info o",\r
+                               "If there is more than one rule which is "\r
+                               "not referenced by any other rule then al"\r
+                               "l such rules are listed."\r
+                       },\r
+                       /* [12] */\r
+                       NotDependent {\r
+\r
+                       },\r
+                       TextBox {\r
+                               gray,\r
+                               {28, 279, 147, 451},\r
+                               "Extra info"\r
+                       }\r
+               },\r
+               /* [4] */\r
+               295,\r
+               "Use this dialog to specify command line "\r
+               "options relating to renaming output file"\r
+               "s.",\r
+               {       /* array itemArray: 7 elements */\r
+                       /* [1] */\r
+                       NotDependent {\r
+\r
+                       },\r
+                       RegularEntry {\r
+                               "Errors file name:",\r
+                               {35, 25, 50, 205},\r
+                               {35, 205, 51, 300},\r
+                               "err.c",\r
+                               keepCase,\r
+                               "-fe",\r
+                               "This entry specifies the name ANTLR uses"\r
+                               " for the errors file."\r
+                       },\r
+                       /* [2] */\r
+                       NotDependent {\r
+\r
+                       },\r
+                       RegularEntry {\r
+                               "Lexical output name:",\r
+                               {60, 25, 75, 205},\r
+                               {60, 205, 76, 300},\r
+                               "parser.dlg",\r
+                               keepCase,\r
+                               "-fl",\r
+                               "This entry specifies the name ANTLR uses"\r
+                               " for the lexical output file."\r
+                       },\r
+                       /* [3] */\r
+                       NotDependent {\r
+\r
+                       },\r
+                       RegularEntry {\r
+                               "Lexical modes name:",\r
+                               {85, 25, 100, 205},\r
+                               {85, 205, 101, 300},\r
+                               "mode.h",\r
+                               keepCase,\r
+                               "-fm",\r
+                               "This entry specifies the name ANTLR uses"\r
+                               " for the lexical mode definitions file."\r
+                       },\r
+                       /* [4] */\r
+                       NotDependent {\r
+\r
+                       },\r
+                       RegularEntry {\r
+                               "Remap file name:",\r
+                               {110, 25, 125, 205},\r
+                               {110, 205, 126, 300},\r
+                               "remap.h",\r
+                               keepCase,\r
+                               "-fr",\r
+                               "This entry specifies the name ANTLR uses"\r
+                               " for the file that remaps globally visib"\r
+                               "le symbols."\r
+                       },\r
+                       /* [5] */\r
+                       NotDependent {\r
+\r
+                       },\r
+                       RegularEntry {\r
+                               "Tokens file name:",\r
+                               {135, 25, 150, 205},\r
+                               {135, 205, 151, 300},\r
+                               "tokens.h",\r
+                               keepCase,\r
+                               "-ft",\r
+                               "This entry specifies the name ANTLR uses"\r
+                               " for the tokens file."\r
+                       },\r
+                       /* [6] */\r
+                       NotDependent {\r
+\r
+                       },\r
+                       CheckOption {\r
+                               NotSet,\r
+                               {160, 25, 175, 175},\r
+                               "Create std header",\r
+                               "-gh",\r
+                               "If this option is checked, ANTLR will cr"\r
+                               "eate a standard header file named, by de"\r
+                               "fault 'stdpccts.h'. This name can be alt"\r
+                               "ered using the entry right next door."\r
+                       },\r
+                       /* [7] */\r
+                       Or {\r
+                               {       /* array OrArray: 1 elements */\r
+                                       /* [1] */\r
+                                       6\r
+                               }\r
+                       },\r
+                       RegularEntry {\r
+                               "Std header file name:",\r
+                               {160, 175, 175, 355},\r
+                               {160, 355, 176, 450},\r
+                               "stdpccts.h",\r
+                               keepCase,\r
+                               "-fh",\r
+                               "This entry specifies the name ANTLR uses"\r
+                               " for the standard header file."\r
+                       }\r
+               },\r
+               /* [5] */\r
+               295,\r
+               "Use this dialog to specify parse options"\r
+               ".",\r
+               {       /* array itemArray: 9 elements */\r
+                       /* [1] */\r
+                       NotDependent {\r
+\r
+                       },\r
+                       RegularEntry {\r
+                               "Lookahead:",\r
+                               {23, 27, 38, 152},\r
+                               {46, 29, 62, 154},\r
+                               "1",\r
+                               keepCase,\r
+                               "-k",\r
+                               "This entry specifies the number of token"\r
+                               "s of lookahead."\r
+                       },\r
+                       /* [2] */\r
+                       NotDependent {\r
+\r
+                       },\r
+                       RegularEntry {\r
+                               "Compr lookahead:",\r
+                               {22, 167, 37, 292},\r
+                               {46, 172, 62, 297},\r
+                               "",\r
+                               keepCase,\r
+                               "-ck",\r
+                               "This entry specifies the number of token"\r
+                               "s of lookahead when using compressed (li"\r
+                               "near approximation) lookahead. In genera"\r
+                               "l, the compressed lookahead is much deep"\r
+                               "er than the full lookahead."\r
+                       },\r
+                       /* [3] */\r
+                       NotDependent {\r
+\r
+                       },\r
+                       RegularEntry {\r
+                               "Max tree nodes:",\r
+                               {22, 312, 37, 437},\r
+                               {46, 315, 62, 445},\r
+                               "",\r
+                               keepCase,\r
+                               "-rl",\r
+                               "This entry specifies the maximum number "\r
+                               "of tokens of tree nodes used by the gram"\r
+                               "mar analysis."\r
+                       },\r
+                       /* [4] */\r
+                       NotDependent {\r
+\r
+                       },\r
+                       CheckOption {\r
+                               NotSet,\r
+                               {76, 25, 91, 350},\r
+                               "Maintenance Release style hoisting",\r
+                               "-mrhoist",\r
+                               "Turn on/off k=1 Maintenance Release styl"\r
+                               "e hoisting."\r
+                       },\r
+                       /* [5] */\r
+                       NotDependent {\r
+\r
+                       },\r
+                       CheckOption {\r
+                               NotSet,\r
+                               {96, 25, 111, 431},\r
+                               "EXPERIMENTAL Maintenance Release style h"\r
+                               "oisting",\r
+                               "-mrhoistk",\r
+                               "Turn on/off k>1 EXPERIMENTAL Maintenance"\r
+                               " Release style hoisting."\r
+                       },\r
+                       /* [6] */\r
+                       NotDependent {\r
+\r
+                       },\r
+                       CheckOption {\r
+                               NotSet,\r
+                               {116, 25, 131, 363},\r
+                               "Compute context for hoisted predicates",\r
+                               "-prc on",\r
+                               "Turn on/off computation of context for h"\r
+                               "oisted predicates."\r
+                       },\r
+                       /* [7] */\r
+                       NotDependent {\r
+\r
+                       },\r
+                       RegularEntry {\r
+                               "Ambiguity aid:",\r
+                               {140, 27, 155, 125},\r
+                               {141, 135, 155, 209},\r
+                               "",\r
+                               keepCase,\r
+                               "-aa",\r
+                               "Ambiguity aid for a rule (rule name or l"\r
+                               "ine number)."\r
+                       },\r
+                       /* [8] */\r
+                       NotDependent {\r
+\r
+                       },\r
+                       RegularEntry {\r
+                               "Limits exp growth:",\r
+                               {140, 236, 155, 361},\r
+                               {139, 372, 155, 452},\r
+                               "",\r
+                               keepCase,\r
+                               "-aad",\r
+                               "Limits exp growth of -aa listing - defau"\r
+                               "lt=1 (max=ck value)."\r
+                       },\r
+                       /* [9] */\r
+                       NotDependent {\r
+\r
+                       },\r
+                       CheckOption {\r
+                               NotSet,\r
+                               {164, 26, 179, 366},\r
+                               "Lookahead token may appear multiple time"\r
+                               "s",\r
+                               "-aam",\r
+                               "Lookahead token may appear multiple time"\r
+                               "s in -aa listing."\r
+                       }\r
+               }\r
+       }\r
+};\r
+\r
diff --git a/Tools/CodeTools/Source/Pccts/antlr/antlr1.txt b/Tools/CodeTools/Source/Pccts/antlr/antlr1.txt
new file mode 100644 (file)
index 0000000..4a7d22e
--- /dev/null
@@ -0,0 +1,264 @@
+\r
+\r
+\r
+ANTLR(1)               PCCTS Manual Pages                ANTLR(1)\r
+\r
+\r
+\r
+NAME\r
+     antlr - ANother Tool for Language Recognition\r
+\r
+SYNTAX\r
+     antlr [_\bo_\bp_\bt_\bi_\bo_\bn_\bs] _\bg_\br_\ba_\bm_\bm_\ba_\br__\bf_\bi_\bl_\be_\bs\r
+\r
+DESCRIPTION\r
+     _\bA_\bn_\bt_\bl_\br converts an extended form of context-free grammar into\r
+     a set of C functions which directly implement an efficient\r
+     form of deterministic recursive-descent LL(k) parser.\r
+     Context-free grammars may be augmented with predicates to\r
+     allow semantics to influence parsing; this allows a form of\r
+     context-sensitive parsing.  Selective backtracking is also\r
+     available to handle non-LL(k) and even non-LALR(k) con-\r
+     structs.  _\bA_\bn_\bt_\bl_\br also produces a definition of a lexer which\r
+     can be automatically converted into C code for a DFA-based\r
+     lexer by _\bd_\bl_\bg.  Hence, _\ba_\bn_\bt_\bl_\br serves a function much like that\r
+     of _\by_\ba_\bc_\bc, however, it is notably more flexible and is more\r
+     integrated with a lexer generator (_\ba_\bn_\bt_\bl_\br directly generates\r
+     _\bd_\bl_\bg code, whereas _\by_\ba_\bc_\bc and _\bl_\be_\bx are given independent\r
+     descriptions).  Unlike _\by_\ba_\bc_\bc which accepts LALR(1) grammars,\r
+     _\ba_\bn_\bt_\bl_\br accepts LL(k) grammars in an extended BNF notation -\r
+     which eliminates the need for precedence rules.\r
+\r
+     Like _\by_\ba_\bc_\bc grammars, _\ba_\bn_\bt_\bl_\br grammars can use automatically-\r
+     maintained symbol attribute values referenced as dollar\r
+     variables.  Further, because _\ba_\bn_\bt_\bl_\br generates top-down\r
+     parsers, arbitrary values may be inherited from parent rules\r
+     (passed like function parameters).  _\bA_\bn_\bt_\bl_\br also has a mechan-\r
+     ism for creating and manipulating abstract-syntax-trees.\r
+\r
+     There are various other niceties in _\ba_\bn_\bt_\bl_\br, including the\r
+     ability to spread one grammar over multiple files or even\r
+     multiple grammars in a single file, the ability to generate\r
+     a version of the grammar with actions stripped out (for\r
+     documentation purposes), and lots more.\r
+\r
+OPTIONS\r
+     -ck _\bn\r
+          Use up to _\bn symbols of lookahead when using compressed\r
+          (linear approximation) lookahead.  This type of looka-\r
+          head is very cheap to compute and is attempted before\r
+          full LL(k) lookahead, which is of exponential complex-\r
+          ity in the worst case.  In general, the compressed loo-\r
+          kahead can be much deeper (e.g, -ck 10) _\bt_\bh_\ba_\bn _\bt_\bh_\be _\bf_\bu_\bl_\bl\r
+          _\bl_\bo_\bo_\bk_\ba_\bh_\be_\ba_\bd (_\bw_\bh_\bi_\bc_\bh _\bu_\bs_\bu_\ba_\bl_\bl_\by _\bm_\bu_\bs_\bt _\bb_\be _\bl_\be_\bs_\bs _\bt_\bh_\ba_\bn _\b4).\r
+\r
+     -CC  Generate C++ output from both ANTLR and DLG.\r
+\r
+     -cr  Generate a cross-reference for all rules.  For each\r
+          rule, print a list of all other rules that reference\r
+          it.\r
+\r
+     -e1  Ambiguities/errors shown in low detail (default).\r
+\r
+     -e2  Ambiguities/errors shown in more detail.\r
+\r
+     -e3  Ambiguities/errors shown in excruciating detail.\r
+\r
+     -fe file\r
+          Rename err.c to file.\r
+\r
+     -fh file\r
+          Rename stdpccts.h header (turns on -gh) to file.\r
+\r
+     -fl file\r
+          Rename lexical output, parser.dlg, to file.\r
+\r
+     -fm file\r
+          Rename file with lexical mode definitions, mode.h, to\r
+          file.\r
+\r
+     -fr file\r
+          Rename file which remaps globally visible symbols,\r
+          remap.h, to file.\r
+\r
+     -ft file\r
+          Rename tokens.h to file.\r
+\r
+     -ga  Generate ANSI-compatible code (default case).  This has\r
+          not been rigorously tested to be ANSI XJ11 C compliant,\r
+          but it is close.  The normal output of _\ba_\bn_\bt_\bl_\br is\r
+          currently compilable under both K&R, ANSI C, and C++-\r
+          this option does nothing because _\ba_\bn_\bt_\bl_\br generates a\r
+          bunch of #ifdef's to do the right thing depending on\r
+          the language.\r
+\r
+     -gc  Indicates that _\ba_\bn_\bt_\bl_\br should generate no C code, i.e.,\r
+          only perform analysis on the grammar.\r
+\r
+     -gd  C code is inserted in each of the _\ba_\bn_\bt_\bl_\br generated pars-\r
+          ing functions to provide for user-defined handling of a\r
+          detailed parse trace.  The inserted code consists of\r
+          calls to the user-supplied macros or functions called\r
+          zzTRACEIN and zzTRACEOUT.  The only argument is a _\bc_\bh_\ba_\br\r
+          * pointing to a C-style string which is the grammar\r
+          rule recognized by the current parsing function.  If no\r
+          definition is given for the trace functions, upon rule\r
+          entry and exit, a message will be printed indicating\r
+          that a particular rule as been entered or exited.\r
+\r
+     -ge  Generate an error class for each non-terminal.\r
+\r
+     -gh  Generate stdpccts.h for non-ANTLR-generated files to\r
+          include.  This file contains all defines needed to\r
+          describe the type of parser generated by _\ba_\bn_\bt_\bl_\br (e.g.\r
+          how much lookahead is used and whether or not trees are\r
+          constructed) and contains the header action specified\r
+          by the user.\r
+\r
+     -gk  Generate parsers that delay lookahead fetches until\r
+          needed.  Without this option, _\ba_\bn_\bt_\bl_\br generates parsers\r
+          which always have _\bk tokens of lookahead available.\r
+\r
+     -gl  Generate line info about grammar actions in C parser of\r
+          the form # _\bl_\bi_\bn_\be "_\bf_\bi_\bl_\be" which makes error messages from\r
+          the C/C++ compiler make more sense as they will point\r
+          into the grammar file not the resulting C file.\r
+          Debugging is easier as well, because you will step\r
+          through the grammar not C file.\r
+\r
+     -gs  Do not generate sets for token expression lists;\r
+          instead generate a ||-separated sequence of\r
+          LA(1)==_\bt_\bo_\bk_\be_\bn__\bn_\bu_\bm_\bb_\be_\br.  The default is to generate sets.\r
+\r
+     -gt  Generate code for Abstract-Syntax Trees.\r
+\r
+     -gx  Do not create the lexical analyzer files (dlg-related).\r
+          This option should be given when the user wishes to\r
+          provide a customized lexical analyzer.  It may also be\r
+          used in _\bm_\ba_\bk_\be scripts to cause only the parser to be\r
+          rebuilt when a change not affecting the lexical struc-\r
+          ture is made to the input grammars.\r
+\r
+     -k _\bn Set k of LL(k) to _\bn; i.e. set tokens of look-ahead\r
+          (default==1).\r
+\r
+     -o dir\r
+          Directory where output files should go (default=".").\r
+          This is very nice for keeping the source directory\r
+          clear of ANTLR and DLG spawn.\r
+\r
+     -p   The complete grammar, collected from all input grammar\r
+          files and stripped of all comments and embedded\r
+          actions, is listed to stdout.  This is intended to aid\r
+          in viewing the entire grammar as a whole and to elim-\r
+          inate the need to keep actions concisely stated so that\r
+          the grammar is easier to read.  Hence, it is preferable\r
+          to embed even complex actions directly in the grammar,\r
+          rather than to call them as subroutines, since the sub-\r
+          routine call overhead will be saved.\r
+\r
+     -pa  This option is the same as -p except that the output is\r
+          annotated with the first sets determined from grammar\r
+          analysis.\r
+\r
+     -prc on\r
+          Turn on the computation and hoisting of predicate con-\r
+          text.\r
+\r
+     -prc off\r
+          Turn off the computation and hoisting of predicate con-\r
+          text.  This option makes 1.10 behave like the 1.06\r
+          release with option -pr on.  Context computation is off\r
+          by default.\r
+\r
+     -rl _\bn\r
+          Limit the maximum number of tree nodes used by grammar\r
+          analysis to _\bn.  Occasionally, _\ba_\bn_\bt_\bl_\br is unable to\r
+          analyze a grammar submitted by the user.  This rare\r
+          situation can only occur when the grammar is large and\r
+          the amount of lookahead is greater than one.  A non-\r
+          linear analysis algorithm is used by PCCTS to handle\r
+          the general case of LL(k) parsing.  The average com-\r
+          plexity of analysis, however, is near linear due to\r
+          some fancy footwork in the implementation which reduces\r
+          the number of calls to the full LL(k) algorithm.  An\r
+          error message will be displayed, if this limit is\r
+          reached, which indicates the grammar construct being\r
+          analyzed when _\ba_\bn_\bt_\bl_\br hit a non-linearity.  Use this\r
+          option if _\ba_\bn_\bt_\bl_\br seems to go out to lunch and your disk\r
+          start thrashing; try _\bn=10000 to start.  Once the\r
+          offending construct has been identified, try to remove\r
+          the ambiguity that _\ba_\bn_\bt_\bl_\br was trying to overcome with\r
+          large lookahead analysis.  The introduction of (...)?\r
+          backtracking blocks eliminates some of these problems -\r
+          _\ba_\bn_\bt_\bl_\br does not analyze alternatives that begin with\r
+          (...)? (it simply backtracks, if necessary, at run\r
+          time).\r
+\r
+     -w1  Set low warning level.  Do not warn if semantic\r
+          predicates and/or (...)? blocks are assumed to cover\r
+          ambiguous alternatives.\r
+\r
+     -w2  Ambiguous parsing decisions yield warnings even if\r
+          semantic predicates or (...)? blocks are used.  Warn if\r
+          predicate context computed and semantic predicates\r
+          incompletely disambiguate alternative productions.\r
+\r
+     -    Read grammar from standard input and generate stdin.c\r
+          as the parser file.\r
+\r
+SPECIAL CONSIDERATIONS\r
+     _\bA_\bn_\bt_\bl_\br works...  we think.  There is no implicit guarantee of\r
+     anything.  We reserve no legal rights to the software known\r
+     as the Purdue Compiler Construction Tool Set (PCCTS) - PCCTS\r
+     is in the public domain.  An individual or company may do\r
+     whatever they wish with source code distributed with PCCTS\r
+     or the code generated by PCCTS, including the incorporation\r
+     of PCCTS, or its output, into commercial software.  We\r
+     encourage users to develop software with PCCTS.  However, we\r
+     do ask that credit is given to us for developing PCCTS.  By\r
+     "credit", we mean that if you incorporate our source code\r
+     into one of your programs (commercial product, research pro-\r
+     ject, or otherwise) that you acknowledge this fact somewhere\r
+     in the documentation, research report, etc...  If you like\r
+     PCCTS and have developed a nice tool with the output, please\r
+     mention that you developed it using PCCTS.  As long as these\r
+     guidelines are followed, we expect to continue enhancing\r
+     this system and expect to make other tools available as they\r
+     are completed.\r
+\r
+FILES\r
+     *.c  output C parser.\r
+\r
+     *.cpp\r
+          output C++ parser when C++ mode is used.\r
+\r
+     parser.dlg\r
+          output _\bd_\bl_\bg lexical analyzer.\r
+\r
+     err.c\r
+          token string array, error sets and error support rou-\r
+          tines.  Not used in C++ mode.\r
+\r
+     remap.h\r
+          file that redefines all globally visible parser sym-\r
+          bols.  The use of the #parser directive creates this\r
+          file.  Not used in C++ mode.\r
+\r
+     stdpccts.h\r
+          list of definitions needed by C files, not generated by\r
+          PCCTS, that reference PCCTS objects.  This is not gen-\r
+          erated by default.  Not used in C++ mode.\r
+\r
+     tokens.h\r
+          output #_\bd_\be_\bf_\bi_\bn_\be_\bs for tokens used and function prototypes\r
+          for functions generated for rules.\r
+\r
+\r
+SEE ALSO\r
+     dlg(1), pccts(1)\r
+\r
+\r
+\r
+\r
+\r
diff --git a/Tools/CodeTools/Source/Pccts/antlr/bits.c b/Tools/CodeTools/Source/Pccts/antlr/bits.c
new file mode 100644 (file)
index 0000000..ddd9bd6
--- /dev/null
@@ -0,0 +1,1025 @@
+/* bits.c -- manage creation and output of bit sets used by the parser.\r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
+ * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
+ * company may do whatever they wish with source code distributed with\r
+ * PCCTS or the code generated by PCCTS, including the incorporation of\r
+ * PCCTS, or its output, into commerical software.\r
+ *\r
+ * We encourage users to develop software with PCCTS.  However, we do ask\r
+ * that credit is given to us for developing PCCTS.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like PCCTS and have developed a nice tool with the\r
+ * output, please mention that you developed it using PCCTS.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * ANTLR 1.33\r
+ * Terence Parr\r
+ * Parr Research Corporation\r
+ * with Purdue University and AHPCRC, University of Minnesota\r
+ * 1989-2001\r
+ */\r
+\r
+#include <stdio.h>\r
+#include <stdlib.h>\r
+#include <ctype.h>\r
+#include <assert.h>\r
+#include "pcctscfg.h"\r
+#include "set.h"\r
+#include "syn.h"\r
+#include "hash.h"\r
+#include "generic.h"\r
+#include "dlgdef.h"\r
+\r
+/* char is only thing that is pretty much always known == 8 bits\r
+ * This allows output of antlr (set stuff, anyway) to be androgynous (portable)\r
+ */\r
+typedef unsigned char SetWordType;\r
+#define BitsPerByte            8\r
+#define BitsPerWord            BitsPerByte*sizeof(SetWordType)\r
+\r
+static SetWordType *setwd = NULL;\r
+int setnum = -1;\r
+int wordnum = 0;\r
+\r
+int esetnum = 0;\r
+\r
+/* Used to convert native wordsize, which ANTLR uses (via set.c) to manipulate sets,\r
+   to bytes that are most portable size-wise.\r
+   */\r
+void\r
+#ifdef __USE_PROTOS\r
+DumpIntAsChars( FILE *f, char *format, unsigned wd )\r
+#else\r
+DumpIntAsChars( f, format, wd )\r
+FILE *f;\r
+char *format;\r
+unsigned wd;\r
+#endif\r
+{\r
+       int i;\r
+       /* uses max of 32 bit unsigned integer for the moment */\r
+       static unsigned long byte_mask[sizeof(unsigned long)] =\r
+                               { 0xFF, 0xFF00UL, 0xFF0000UL, 0xFF000000UL };  /* MR20 G. Hobbelt */\r
+/*                               0xFF00000000, 0xFF0000000000, 0xFF000000000000, 0xFF00000000000000 };*/\r
+\r
+       /* for each byte in the word */\r
+       assert(sizeof(unsigned) <= 4); /* M20 G. Hobbelt Sanity check */\r
+       for (i=0; i<sizeof(unsigned); i++)\r
+       {\r
+               /* mask out the ith byte and shift down to the first 8 bits */\r
+               fprintf(f, format, (wd&byte_mask[i])>>(i*BitsPerByte));\r
+               if ( i<sizeof(unsigned)-1) fprintf(f, ",");\r
+       }\r
+}\r
+\r
+/* Create a new setwd (ignoring [Ep] token on end) */\r
+void\r
+#ifdef __USE_PROTOS\r
+NewSetWd( void )\r
+#else\r
+NewSetWd( )\r
+#endif\r
+{\r
+       SetWordType *p;\r
+\r
+       if ( setwd == NULL )\r
+       {\r
+               setwd = (SetWordType *) calloc(TokenNum, sizeof(SetWordType));\r
+               require(setwd!=NULL, "NewSetWd: cannot alloc set wd\n");\r
+       }\r
+       for (p = setwd; p<&(setwd[TokenNum]); p++)  {*p=0;}\r
+       wordnum++;\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+DumpSetWd( void )\r
+#else\r
+DumpSetWd( )\r
+#endif\r
+{\r
+       if ( GenCC ) DumpSetWdForCC();\r
+       else DumpSetWdForC();\r
+}\r
+\r
+/* Dump the current setwd to ErrFile. 0..MaxTokenVal */\r
+void\r
+#ifdef __USE_PROTOS\r
+DumpSetWdForC( void )\r
+#else\r
+DumpSetWdForC( )\r
+#endif\r
+{\r
+       int i,c=1;\r
+\r
+       if ( setwd==NULL ) return;\r
+       fprintf(DefFile, "extern SetWordType setwd%d[];\n", wordnum);\r
+       fprintf(ErrFile,\r
+                       "SetWordType setwd%d[%d] = {", wordnum, TokenNum-1);\r
+       for (i=0; i<TokenNum-1; i++)\r
+       {\r
+               DAWDLE;\r
+               if ( i!=0 ) fprintf(ErrFile, ",");\r
+               if ( c == 8 ) {fprintf(ErrFile, "\n\t"); c=1;} else c++;\r
+               fprintf(ErrFile, "0x%x", setwd[i]);\r
+       }\r
+       fprintf(ErrFile, "};\n");\r
+}\r
+\r
+/* Dump the current setwd to Parser.C file. 0..MaxTokenVal;\r
+ * Only used if -CC on.\r
+ */\r
+void\r
+#ifdef __USE_PROTOS\r
+DumpSetWdForCC( void )\r
+#else\r
+DumpSetWdForCC( )\r
+#endif\r
+{\r
+       int i,c=1;\r
+\r
+       if ( setwd==NULL ) return;\r
+       fprintf(Parser_h, "\tstatic SetWordType setwd%d[%d];\n", wordnum, TokenNum-1);\r
+       fprintf(Parser_c,\r
+                       "SetWordType %s::setwd%d[%d] = {", CurrentClassName, wordnum,\r
+                       TokenNum-1);\r
+       for (i=0; i<TokenNum-1; i++)\r
+       {\r
+               DAWDLE;\r
+               if ( i!=0 ) fprintf(Parser_c, ",");\r
+               if ( c == 8 ) {fprintf(Parser_c, "\n\t"); c=1;} else c++;\r
+               fprintf(Parser_c, "0x%x", setwd[i]);\r
+       }\r
+       fprintf(Parser_c, "};\n");\r
+}\r
+\r
+/* Make a new set.  Dump old setwd and create new setwd if current setwd is full */\r
+void\r
+#ifdef __USE_PROTOS\r
+NewSet( void )\r
+#else\r
+NewSet( )\r
+#endif\r
+{\r
+       setnum++;\r
+       if ( setnum==BitsPerWord )              /* is current setwd full? */\r
+       {\r
+               DumpSetWd(); NewSetWd(); setnum = 0;\r
+       }\r
+}\r
+\r
+/* s is a set of tokens.  Turn on bit at each token position in set 'setnum' */\r
+void\r
+#ifdef __USE_PROTOS\r
+FillSet( set s )\r
+#else\r
+FillSet( s )\r
+set s;\r
+#endif\r
+{\r
+       SetWordType mask=(((unsigned)1)<<setnum);\r
+       unsigned int e;\r
+\r
+       while ( !set_nil(s) )\r
+       {\r
+               e = set_int(s);\r
+               set_rm(e, s);\r
+               setwd[e] |= mask;\r
+       }\r
+}\r
+\r
+                                       /* E r r o r  C l a s s  S t u f f */\r
+\r
+/* compute the FIRST of a rule for the error class stuff */\r
+static set\r
+#ifdef __USE_PROTOS\r
+Efirst( char *rule, ECnode *eclass )\r
+#else\r
+Efirst( rule, eclass )\r
+char *rule;\r
+ECnode *eclass;\r
+#endif\r
+{\r
+       set rk, a;\r
+       Junction *r;\r
+       RuleEntry *q = (RuleEntry *) hash_get(Rname, rule);\r
+\r
+       if ( q == NULL )\r
+       {\r
+               warnNoFL(eMsg2("undefined rule '%s' referenced in errclass '%s'; ignored",\r
+                                               rule, TokenString(eclass->tok)));\r
+               return empty;\r
+       }\r
+       r = RulePtr[q->rulenum];\r
+       r->end->halt = TRUE;            /* don't let reach fall off end of rule here */\r
+       rk = empty;\r
+       REACH(r, 1, &rk, a);\r
+       r->end->halt = FALSE;\r
+       return a;\r
+}\r
+\r
+/*\r
+ * scan the list of tokens/eclasses/nonterminals filling the new eclass\r
+ * with the set described by the list.  Note that an eclass can be\r
+ * quoted to allow spaces etc... However, an eclass must not conflict\r
+ * with a reg expr found elsewhere.  The reg expr will be taken over\r
+ * the eclass name.\r
+ */\r
+static void\r
+#ifdef __USE_PROTOS\r
+doEclass( char *eclass )\r
+#else\r
+doEclass( eclass )\r
+char *eclass;\r
+#endif\r
+{\r
+       TermEntry *q;\r
+       ECnode *p;\r
+       TCnode *tcnode;\r
+       ListNode *e;\r
+       unsigned int t;\r
+       unsigned deg=0;\r
+       set a;\r
+       require(eclass!=NULL, "doEclass: NULL eset");\r
+       \r
+       p = (ECnode *) eclass;\r
+       lexmode(p->lexclass);   /* switch to lexclass where errclass is defined */\r
+       p->eset = empty;\r
+       for (e = (p->elist)->next; e!=NULL; e=e->next)\r
+       {\r
+               q = NULL;                                                               /* MR23 */\r
+\r
+               if ( islower( *((char *)e->elem) ) )    /* is it a rule ref? (alias FIRST request) */\r
+               {\r
+                       a = Efirst((char *)e->elem, p);\r
+                       set_orin(&p->eset, a);\r
+                       deg += set_deg(a);\r
+                       set_free( a );\r
+                       continue;\r
+               }\r
+               else if ( *((char *)e->elem)=='"' )\r
+               {\r
+                       t = 0;\r
+                       q = (TermEntry *) hash_get(Texpr, (char *) e->elem);\r
+                       if ( q == NULL )\r
+                       {\r
+                               /* if quoted and not an expr look for eclass name */\r
+                               q = (TermEntry *) hash_get(Tname, *((char **)&(e->elem))=StripQuotes((char *)e->elem));\r
+                               if ( q != NULL ) t = q->token;\r
+                       }\r
+                       else t = q->token;\r
+               }\r
+               else    /* labelled token/eclass/tokclass */\r
+               {\r
+                       q = (TermEntry *) hash_get(Tname, (char *)e->elem);\r
+                       if ( q != NULL )\r
+                       {\r
+                               if ( strcmp((char *)e->elem, TokenString(p->tok))==0 )\r
+                               {\r
+                                       warnNoFL(eMsg1("self-referential error class '%s'; ignored",\r
+                                                                  (char *)e->elem));\r
+                                       continue;\r
+                               }\r
+                               else\r
+                                       t = q->token;\r
+                       }\r
+                       else t=0;\r
+               }\r
+               if ( t!=0 )\r
+               {\r
+                       if (isTermEntryTokClass(q))  {                  /* MR23 */\r
+                           tcnode = q->tclass;                                 /* MR23 */\r
+                               set_orin(&p->eset, tcnode->tset);       /* MR23 */\r
+                               deg = set_deg(p->eset);                         /* MR23 */\r
+                       }                                                                               /* MR23 */\r
+                       else {\r
+                               set_orel(t, &p->eset);\r
+                               deg++;\r
+                       }\r
+               }\r
+               else warnNoFL(eMsg2("undefined token '%s' referenced in errclass '%s'; ignored",\r
+                                                       (char *)e->elem, TokenString(p->tok)));\r
+       }\r
+       p->setdeg = deg;\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+ComputeErrorSets( void )\r
+#else\r
+ComputeErrorSets( )\r
+#endif\r
+{\r
+#ifdef __cplusplus\r
+    list_apply(eclasses, (void (*)(void *)) doEclass);\r
+#else\r
+#ifdef __USE_PROTOS\r
+    list_apply(eclasses, (void (*)(void *)) doEclass);\r
+#else\r
+    list_apply(eclasses, doEclass);\r
+#endif\r
+#endif\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+ComputeTokSets( void )\r
+#else\r
+ComputeTokSets( )\r
+#endif\r
+{\r
+       ListNode *t, *e = NULL, *e1, *e2;\r
+       int something_changed;\r
+    int i;\r
+       TCnode *p;\r
+       TermEntry *q, *q1, *q2;\r
+\r
+       if ( tclasses == NULL ) return;\r
+\r
+       /* turn lists of token/tokclass references into sets */\r
+       for (t = tclasses->next; t!=NULL; t=t->next)\r
+       {\r
+               p = (TCnode *) t->elem;\r
+\r
+               /* if wild card, then won't have entries in tclass, assume all_tokens */\r
+               if ( p->tok == WildCardToken )\r
+               {\r
+                       p->tset = set_dup(all_tokens);\r
+                       continue;\r
+               }\r
+\r
+               lexmode(p->lexclass);   /* switch to lexclass where tokclass is defined */\r
+               p->tset = empty;\r
+\r
+               /* instantiate all tokens/token_classes into the tset */\r
+               for (e = (p->tlist)->next; e!=NULL; e=e->next)\r
+               {\r
+                       char *tokstr;\r
+                       tokstr = (char *)e->elem;\r
+                       if ( *tokstr == '"' ) {\r
+                q = (TermEntry *) hash_get(Texpr, tokstr);\r
+                       require(q!=NULL, "ComputeTokSets: no token def");\r
+                       set_orel(q->token, &p->tset);\r
+                       } else if (tokstr[0] == '.') {\r
+                e1=e->next;\r
+                e2=e1->next;\r
+                e=e2;\r
+                q1= (TermEntry *) hash_get(Tname, (char *)e1->elem);\r
+                       require(q1!=NULL, "ComputeTokSets: no token def");\r
+                q2= (TermEntry *) hash_get(Tname, (char *)e2->elem);\r
+                       require(q2!=NULL, "ComputeTokSets: no token def");\r
+\r
+                if (set_el(q1->token,imag_tokens)) {\r
+errNoFL(eMsg2("can't define #tokclass %s using #tokclass or #errclass %s",\r
+                        TokenString(p->tok),(char *)e1->elem) );\r
+                }\r
+                if (set_el(q2->token,imag_tokens)) {\r
+errNoFL(eMsg2("can't define #tokclass %s using #tokclass or #errclass %s",\r
+                        TokenString(p->tok),(char *)e2->elem) );\r
+                }\r
+                if (q1->token > q2->token) {\r
+errNoFL(eMsg3("for #tokclass %s %s..%s - first token number > second token number",\r
+                        TokenString(p->tok),(char *)e1->elem,(char *)e2->elem) );\r
+                  for (i=q2->token; i<=q1->token; i++) { set_orel(i, &p->tset); }\r
+                } else {\r
+                  for (i=q1->token; i<=q2->token; i++) { set_orel(i, &p->tset); }\r
+                }\r
+            } else {\r
+                q = (TermEntry *) hash_get(Tname, tokstr);\r
+                       require(q!=NULL, "ComputeTokSets: no token def");\r
+                       set_orel(q->token, &p->tset);\r
+            }\r
+               }\r
+       }\r
+\r
+       /* Go thru list of tokclasses again looking for tokclasses in sets */\r
+again:\r
+       something_changed = 0;\r
+       for (t = tclasses->next; t!=NULL; t=t->next)\r
+       {\r
+               set tcl;\r
+               p = (TCnode *) t->elem;\r
+               tcl = set_and(p->tset, tokclasses);\r
+               if ( !set_nil(tcl) )\r
+               {\r
+                       int tk;\r
+                       /* replace refs to tokclasses with the associated set of tokens */\r
+                       something_changed = 1;\r
+                       while ( !set_nil(tcl) )\r
+                       {\r
+                               tk = set_int(tcl);              /* grab one of the tok class refs */\r
+                               set_rm(tk, tcl);\r
+                               if ( p->tok != tk )             /* tokclass ref to yourself? */\r
+                               {\r
+                                       q = (TermEntry *) hash_get(Tname, TokenString(tk));\r
+                                       require(q!=NULL, "#tokclass not in hash table");\r
+                                       set_orin(&p->tset, q->tclass->tset);\r
+                               }\r
+                               set_rm(tk, p->tset);    /* remove ref that we replaced */\r
+                       }\r
+               }\r
+               set_free(tcl);\r
+       }\r
+       if ( something_changed ) goto again;\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+DumpRemainingTokSets(void)\r
+#else\r
+DumpRemainingTokSets()\r
+#endif\r
+{\r
+       TCnode *p;\r
+       ListNode *t;\r
+\r
+       /* Go thru tclasses (for the last time) and dump the sets not dumped\r
+        * during code gen; yes, this is a bogus way to do this, but ComputeTokSets()\r
+        * can't dump the defs as the error file and tok file has not been created\r
+        * yet etc...\r
+        */\r
+       if ( tclasses==NULL ) return;\r
+       for (t = tclasses->next; t!=NULL; t=t->next)\r
+       {\r
+               unsigned e;\r
+               p = (TCnode *) t->elem;\r
+               if ( p->dumped ) continue;\r
+               e = DefErrSet(&(p->tset), 0, TokenString(p->tok));\r
+               p->dumped = 1;\r
+               p->setnum = e;\r
+       }\r
+}\r
+\r
+\r
+/* replace a subset of an error set with an error class name if a subset is found\r
+ * repeat process until no replacements made\r
+ */\r
+void\r
+#ifdef __USE_PROTOS\r
+SubstErrorClass( set *f )\r
+#else\r
+SubstErrorClass( f )\r
+set *f;\r
+#endif\r
+{\r
+       int max, done = 0;\r
+       ListNode *p;\r
+       ECnode *ec, *maxclass = NULL;\r
+       set a;\r
+       require(f!=NULL, "SubstErrorClass: NULL eset");\r
+\r
+       if ( eclasses == NULL ) return;\r
+       while ( !done )\r
+       {\r
+               max = 0;\r
+               maxclass = NULL;\r
+               for (p=eclasses->next; p!=NULL; p=p->next)      /* chk all error classes */\r
+               {\r
+                       ec = (ECnode *) p->elem;\r
+                       if ( ec->setdeg > max )\r
+                       {\r
+                               if ( set_sub(ec->eset, *f) || set_equ(ec->eset, *f) )\r
+                                       {maxclass = ec; max=ec->setdeg;}\r
+                       }\r
+               }\r
+               if ( maxclass != NULL ) /* if subset found, replace with token */\r
+               {\r
+                       a = set_dif(*f, maxclass->eset);\r
+                       set_orel((unsigned)maxclass->tok, &a);\r
+                       set_free(*f);\r
+                       *f = a;\r
+               }\r
+               else done = 1;\r
+       }\r
+}\r
+\r
+int\r
+#ifdef __USE_PROTOS\r
+DefErrSet1(int nilOK, set *f, int subst, char *name )\r
+#else\r
+DefErrSet1(nilOK, f, subst, name )\r
+int nilOK;\r
+set *f;\r
+int subst;                     /* should be substitute error classes? */\r
+char *name;\r
+#endif\r
+{\r
+       if ( GenCC ) return DefErrSetForCC1(nilOK, f, subst, name, "_set");\r
+       else return DefErrSetForC1(nilOK, f, subst, name, "_set");\r
+}\r
+\r
+int\r
+#ifdef __USE_PROTOS\r
+DefErrSet( set *f, int subst, char *name )\r
+#else\r
+DefErrSet( f, subst, name )\r
+set *f;\r
+int subst;                     /* should be substitute error classes? */\r
+char *name;\r
+#endif\r
+{\r
+    return DefErrSet1(0,f,subst,name);\r
+}\r
+\r
+int\r
+#ifdef __USE_PROTOS\r
+DefErrSetWithSuffix(int nilOK, set *f, int subst, char *name, const char* suffix)\r
+#else\r
+DefErrSetWithSuffix(nilOK, f, subst, name, suffix )\r
+int nilOK;\r
+set *f;\r
+int subst;                     /* should be substitute error classes? */\r
+char *name;\r
+char *suffix;\r
+#endif\r
+{\r
+       if ( GenCC ) return DefErrSetForCC1(nilOK, f, subst, name, suffix );\r
+       else return DefErrSetForC1(nilOK, f, subst, name, suffix);\r
+}\r
+\r
+/* Define a new error set.  WARNING...set-implementation dependent.\r
+ */\r
+int\r
+#ifdef __USE_PROTOS\r
+DefErrSetForC1(int nilOK, set *f, int subst, char * name, const char * suffix)\r
+#else\r
+DefErrSetForC1(nilOK, f, subst, name, suffix)\r
+int nilOK;          /* MR13 */\r
+set *f;\r
+int subst;                     /* should be substitute error classes? */\r
+char *name;\r
+const char *suffix;\r
+#endif\r
+{\r
+       unsigned *p, *endp;\r
+       int e=1;\r
+\r
+    if (!nilOK)        require(!set_nil(*f), "DefErrSetForC1: nil set to dump?");\r
+\r
+       if ( subst ) SubstErrorClass(f);\r
+       p = f->setword;\r
+       endp = &(f->setword[f->n]);\r
+       esetnum++;\r
+       if ( name!=NULL )\r
+               fprintf(DefFile, "extern SetWordType %s%s[];\n", name, suffix);\r
+       else\r
+               fprintf(DefFile, "extern SetWordType zzerr%d[];\n", esetnum);\r
+       if ( name!=NULL ) {\r
+               fprintf(ErrFile, "SetWordType %s%s[%d] = {",\r
+                               name,\r
+                suffix,\r
+                               NumWords(TokenNum-1)*sizeof(unsigned));\r
+       }\r
+       else {\r
+               fprintf(ErrFile, "SetWordType zzerr%d[%d] = {",\r
+                               esetnum,\r
+                               NumWords(TokenNum-1)*sizeof(unsigned));\r
+       }\r
+       while ( p < endp )\r
+       {\r
+               if ( e > 1 ) fprintf(ErrFile, ", ");\r
+               DumpIntAsChars(ErrFile, "0x%x", *p++);\r
+               if ( e == 3 )\r
+               {\r
+                       DAWDLE;\r
+                       if ( p < endp ) fprintf(ErrFile, ",");\r
+                       fprintf(ErrFile, "\n\t");\r
+                       e=1;\r
+               }\r
+               else e++;\r
+       }\r
+       fprintf(ErrFile, "};\n");\r
+\r
+       return esetnum;\r
+}\r
+\r
+int\r
+#ifdef __USE_PROTOS\r
+DefErrSetForC( set *f, int subst, char *name )\r
+#else\r
+DefErrSetForC( f, subst, name )\r
+set *f;\r
+int subst;                     /* should be substitute error classes? */\r
+char *name;\r
+#endif\r
+{\r
+  return DefErrSetForC1(0,f,subst,name, "_set");\r
+}\r
+\r
+/* Define a new error set.  WARNING...set-implementation dependent;\r
+ * Only used when -CC on.\r
+ */\r
+\r
+int\r
+#ifdef __USE_PROTOS\r
+DefErrSetForCC1(int nilOK, set *f, int subst, char *name, const char *suffix )\r
+#else\r
+DefErrSetForCC1(nilOK, f, subst, name, suffix )\r
+int nilOK;          /* MR13 */\r
+set *f;\r
+int subst;                     /* should be substitute error classes? */\r
+char *name;\r
+const char *suffix;\r
+#endif\r
+{\r
+       unsigned *p, *endp;\r
+       int e=1;\r
+\r
+    if (!nilOK)        require(!set_nil(*f), "DefErrSetForCC1: nil set to dump?");\r
+\r
+       if ( subst ) SubstErrorClass(f);\r
+       p = f->setword;\r
+       endp = &(f->setword[f->n]);\r
+       esetnum++;\r
+\r
+       if ( name!=NULL ) {\r
+               fprintf(Parser_h, "\tstatic SetWordType %s%s[%d];\n", name, suffix,\r
+                               NumWords(TokenNum-1)*sizeof(unsigned));\r
+               fprintf(Parser_c, "SetWordType %s::%s%s[%d] = {",\r
+                               CurrentClassName,\r
+                               name,\r
+                               suffix,\r
+                               NumWords(TokenNum-1)*sizeof(unsigned));\r
+       }\r
+       else {\r
+               fprintf(Parser_c, "SetWordType %s::err%d[%d] = {",\r
+                               CurrentClassName,\r
+                               esetnum,\r
+                               NumWords(TokenNum-1)*sizeof(unsigned));\r
+               fprintf(Parser_h, "\tstatic SetWordType err%d[%d];\n", esetnum,\r
+                               NumWords(TokenNum-1)*sizeof(unsigned));\r
+       }\r
+\r
+       while ( p < endp )\r
+       {\r
+               if ( e > 1 ) fprintf(Parser_c, ", ");\r
+               DumpIntAsChars(Parser_c, "0x%x", *p++);\r
+               if ( e == 3 )\r
+               {\r
+                       if ( p < endp ) fprintf(Parser_c, ",");\r
+                       fprintf(Parser_c, "\n\t");\r
+                       e=1;\r
+               }\r
+               else e++;\r
+       }\r
+       fprintf(Parser_c, "};\n");\r
+\r
+       return esetnum;\r
+}\r
+\r
+int\r
+#ifdef __USE_PROTOS\r
+DefErrSetForCC( set *f, int subst, char *name )\r
+#else\r
+DefErrSetForCC( f, subst, name )\r
+set *f;\r
+int subst;                     /* should be substitute error classes? */\r
+char *name;\r
+#endif\r
+{\r
+  return DefErrSetForCC1(0,f,subst,name, "_set");\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+GenParser_c_Hdr(void)\r
+#else\r
+GenParser_c_Hdr()\r
+#endif\r
+{\r
+       int i,j;\r
+    TermEntry   *te;\r
+    char * hasAkaName = NULL;                                                                  /* MR23 */\r
+\r
+       hasAkaName = (char *) malloc(TokenNum+1);                                       /* MR23 */\r
+       require(hasAkaName!=NULL, "Cannot alloc hasAkaName\n");         /* MR23 */\r
+       for (i = 0; i < TokenNum; i++) hasAkaName[i]='0';                       /* MR23 */\r
+       hasAkaName[TokenNum] = 0;                                   /* MR23 */\r
+\r
+       fprintf(Parser_c, "/*\n");\r
+       fprintf(Parser_c, " * %s: P a r s e r  S u p p o r t\n", CurrentClassName);\r
+       fprintf(Parser_c, " *\n");\r
+       fprintf(Parser_c, " * Generated from:");\r
+       for (i=0; i<NumFiles; i++) fprintf(Parser_c, " %s", FileStr[i]);\r
+       fprintf(Parser_c, "\n");\r
+       fprintf(Parser_c, " *\n");\r
+       fprintf(Parser_c, " * Terence Parr, Russell Quong, Will Cohen, and Hank Dietz: 1989-2001\n");\r
+       fprintf(Parser_c, " * Parr Research Corporation\n");\r
+       fprintf(Parser_c, " * with Purdue University Electrical Engineering\n");\r
+       fprintf(Parser_c, " * with AHPCRC, University of Minnesota\n");\r
+       fprintf(Parser_c, " * ANTLR Version %s\n", Version);\r
+       fprintf(Parser_c, " */\n\n");\r
+       \r
+  if ( FirstAction != NULL ) dumpAction(FirstAction,Parser_c, 0, -1, 0, 1);    /* MR11 MR15b */\r
+\r
+       fprintf(Parser_c, "#define ANTLR_VERSION        %s\n", VersionDef);\r
+\r
+       fprintf(Parser_c, "#include \"pcctscfg.h\"\n");\r
+       fprintf(Parser_c, "#include \"pccts_stdio.h\"\n");\r
+       fprintf(Parser_c, "#define ANTLR_SUPPORT_CODE\n");\r
+       if ( UserTokenDefsFile != NULL )\r
+          fprintf(Parser_c, "#include %s\n", UserTokenDefsFile);\r
+       else\r
+          fprintf(Parser_c, "#include \"%s\"\n", DefFileName);\r
+\r
+       fprintf(Parser_c, "#include \"%s.h\"\n\n", CurrentClassName);\r
+\r
+       fprintf(Parser_c, "const ANTLRChar *%s::tokenName(int tok) ",   /* MR1 */\r
+                                       CurrentClassName);                              /* MR1 */\r
+       fprintf(Parser_c, "  { return _token_tbl[tok]; }\n");           /* MR1 */ /* MR10 */\r
+       /* Dump a Parser::tokens for each automaton */\r
+       fprintf(Parser_c, "\nconst ANTLRChar *%s::_token_tbl[]={\n",\r
+                                                 CurrentClassName); /* MR20 */\r
+       fprintf(Parser_c, "\t/* 00 */\t\"Invalid\"");\r
+\r
+       for (i=1; i<TokenNum-1; i++)\r
+       {\r
+               DAWDLE;\r
+               if ( i == EpToken ) continue;\r
+               /* remapped to invalid token? */\r
+               if ( TokenInd!=NULL && TokenInd[i]>=LastTokenCounted )\r
+               {\r
+                       fprintf(Parser_c, ",\n\t/* %02d */\t\"invalid\"", i);\r
+                       continue;\r
+               }\r
+               if ( TokenString(i) != NULL ) {\r
+           te=(TermEntry *) hash_get(Tname,TokenString(i));                     /* MR11 */\r
+            if (te == NULL || te->akaString == NULL) {                          /* MR11 */\r
+                     fprintf(Parser_c, ",\n\t/* %02d */\t\"%s\"", i, TokenString(i));\r
+            } else {\r
+                         hasAkaName[i] = '1';                                                                                      /* MR23 */\r
+                     fprintf(Parser_c, ",\n\t/* %02d */\t\"%s\"", i, te->akaString);   /* MR11 */\r
+            }\r
+        }\r
+               else\r
+               {\r
+                       /* look in all lexclasses for the reg expr */\r
+                       for (j=0; j<NumLexClasses; j++)\r
+                       {\r
+                               lexmode(j);\r
+                               if ( ExprString(i) != NULL )\r
+                               {\r
+                                       fprintf(Parser_c, ",\n\t/* %02d */\t", i);\r
+                                       dumpExpr(Parser_c, ExprString(i));\r
+                                       break;\r
+                               }\r
+                       }\r
+                       if ( j>=NumLexClasses )\r
+                       {\r
+                               if ( UserDefdTokens )\r
+                               {\r
+                                       fprintf(Parser_c, ",\n\t/* %02d */\t\"\"", i);\r
+                               }\r
+                               else\r
+                                       fatal_internal(eMsgd("No label or expr for token %d",i));\r
+                       }\r
+               }\r
+       }\r
+       fprintf(Parser_c, "\n};\n");\r
+\r
+       /* Build constructors */\r
+       fprintf(Parser_c, "\n%s::", CurrentClassName);\r
+       fprintf(Parser_c,       "%s(ANTLRTokenBuffer *input) : %s(input,%d,%d,%d,%d)\n",\r
+                                               CurrentClassName,\r
+                                               (BaseClassName == NULL ? "ANTLRParser" : BaseClassName),\r
+                                               OutputLL_k,\r
+                                               FoundGuessBlk,\r
+                                               DemandLookahead,\r
+                                               NumWords(TokenNum-1)*sizeof(unsigned));\r
+       fprintf(Parser_c, "{\n");\r
+       fprintf(Parser_c, "\ttoken_tbl = _token_tbl;\n");\r
+    if (TraceGen) {\r
+      fprintf(Parser_c, "\ttraceOptionValueDefault=1;\t\t// MR10 turn trace ON\n");\r
+    } else {\r
+      fprintf(Parser_c, "\ttraceOptionValueDefault=0;\t\t// MR10 turn trace OFF\n");\r
+    };\r
+       fprintf(Parser_c, "}\n\n");\r
+       free ( (void *) hasAkaName);\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+GenParser_h_Hdr(void)\r
+#else\r
+GenParser_h_Hdr()\r
+#endif\r
+{\r
+       int i;\r
+\r
+       fprintf(Parser_h, "/*\n");\r
+       fprintf(Parser_h, " * %s: P a r s e r  H e a d e r \n", CurrentClassName);\r
+       fprintf(Parser_h, " *\n");\r
+       fprintf(Parser_h, " * Generated from:");\r
+       for (i=0; i<NumFiles; i++) fprintf(Parser_h, " %s", FileStr[i]);\r
+       fprintf(Parser_h, "\n");\r
+       fprintf(Parser_h, " *\n");\r
+       fprintf(Parser_h, " * Terence Parr, Russell Quong, Will Cohen, and Hank Dietz: 1989-2001\n");\r
+       fprintf(Parser_h, " * Parr Research Corporation\n");\r
+       fprintf(Parser_h, " * with Purdue University Electrical Engineering\n");\r
+       fprintf(Parser_h, " * with AHPCRC, University of Minnesota\n");\r
+       fprintf(Parser_h, " * ANTLR Version %s\n", Version);\r
+       fprintf(Parser_h, " */\n\n");\r
+\r
+  if ( FirstAction != NULL ) dumpAction( FirstAction, Parser_h, 0, -1, 0, 1);         /* MR11 MR15b */\r
+\r
+       fprintf(Parser_h, "#ifndef %s_h\n", CurrentClassName);\r
+       fprintf(Parser_h, "#define %s_h\n\n", CurrentClassName);\r
+\r
+    fprintf(Parser_h, "#ifndef ANTLR_VERSION\n");\r
+    fprintf(Parser_h, "#define ANTLR_VERSION %s\n",VersionDef);\r
+    fprintf(Parser_h, "#endif\n\n");\r
+\r
+       if ( GenAST ) fprintf(Parser_h, "class ASTBase;\n");\r
+    if (TraceGen) {\r
+      fprintf(Parser_h,"#ifndef zzTRACE_RULES\n");  /* MR20 */\r
+      fprintf(Parser_h,"#define zzTRACE_RULES\n");  /* MR20 */\r
+      fprintf(Parser_h,"#endif\n");                 /* MR22 */\r
+    };\r
+       fprintf(Parser_h, "#include \"%s\"\n\n", APARSER_H);\r
+\r
+       if ( HdrAction != NULL ) dumpAction( HdrAction, Parser_h, 0, -1, 0, 1);\r
+       \r
+/* MR10 */    if (ClassDeclStuff == NULL) {\r
+/* MR10 */     fprintf(Parser_h, "class %s : public ANTLRParser {\n", CurrentClassName);\r
+/* MR10 */    } else {\r
+/* MR10 */      fprintf(Parser_h, "class %s %s {\n",CurrentClassName,ClassDeclStuff);\r
+/* MR10 */    };\r
+\r
+       fprintf(Parser_h, "public:\n");                                           /* MR1 */\r
+       fprintf(Parser_h, "\tstatic  const ANTLRChar *tokenName(int tk);\n");/* MR1 */\r
+    fprintf(Parser_h, "\tenum { SET_SIZE = %i };\n",TokenNum-1);         /* MR21 */\r
+       fprintf(Parser_h, "protected:\n");\r
+       fprintf(Parser_h, "\tstatic const ANTLRChar *_token_tbl[];\n");     /* MR20 */\r
+       fprintf(Parser_h, "private:\n");\r
+}\r
+\r
+/* Currently, this is only used in !GenCC mode */\r
+void\r
+#ifdef __USE_PROTOS\r
+GenErrHdr( void )\r
+#else\r
+GenErrHdr( )\r
+#endif\r
+{\r
+       int i, j;\r
+    TermEntry   *te;\r
+\r
+       fprintf(ErrFile, "/*\n");\r
+       fprintf(ErrFile, " * A n t l r  S e t s / E r r o r  F i l e  H e a d e r\n");\r
+       fprintf(ErrFile, " *\n");\r
+       fprintf(ErrFile, " * Generated from:");\r
+       for (i=0; i<NumFiles; i++) fprintf(ErrFile, " %s", FileStr[i]);\r
+       fprintf(ErrFile, "\n");\r
+       fprintf(ErrFile, " *\n");\r
+       fprintf(ErrFile, " * Terence Parr, Russell Quong, Will Cohen, and Hank Dietz: 1989-2001\n");\r
+       fprintf(ErrFile, " * Parr Research Corporation\n");\r
+       fprintf(ErrFile, " * with Purdue University Electrical Engineering\n");\r
+       fprintf(ErrFile, " * With AHPCRC, University of Minnesota\n");\r
+       fprintf(ErrFile, " * ANTLR Version %s\n", Version);\r
+       fprintf(ErrFile, " */\n\n");\r
+\r
+  if ( FirstAction != NULL ) dumpAction( FirstAction, ErrFile, 0, -1, 0, 1);         /* MR11 MR15b */\r
+       \r
+  fprintf(ErrFile, "#define ANTLR_VERSION      %s\n", VersionDef);\r
+\r
+  fprintf(ErrFile, "#include \"pcctscfg.h\"\n");\r
+       fprintf(ErrFile, "#include \"pccts_stdio.h\"\n");\r
+       if ( strcmp(ParserName, DefaultParserName)!=0 )\r
+               fprintf(ErrFile, "#define %s %s\n", DefaultParserName, ParserName);\r
+       if ( strcmp(ParserName, DefaultParserName)!=0 )\r
+               fprintf(ErrFile, "#include \"%s\"\n", RemapFileName);\r
+       if ( HdrAction != NULL ) dumpAction( HdrAction, ErrFile, 0, -1, 0, 1 );\r
+       if ( FoundGuessBlk )\r
+       {\r
+               fprintf(ErrFile, "#define ZZCAN_GUESS\n");\r
+               fprintf(ErrFile, "#include \"pccts_setjmp.h\"\n");\r
+       }\r
+    if (TraceGen) {\r
+      fprintf(ErrFile,"#ifndef zzTRACE_RULES\n");  /* MR20 */\r
+      fprintf(ErrFile,"#define zzTRACE_RULES\n");  /* MR20 */\r
+      fprintf(ErrFile,"#endif\n");                 /* MR22 */\r
+    };\r
+\r
+       if ( OutputLL_k > 1 ) fprintf(ErrFile, "#define LL_K %d\n", OutputLL_k);\r
+#ifdef DUM\r
+       if ( LexGen ) fprintf(ErrFile, "#define zzEOF_TOKEN %d\n", (TokenInd!=NULL?TokenInd[EofToken]:EofToken));\r
+#endif\r
+       fprintf(ErrFile, "#define zzSET_SIZE %d\n", NumWords(TokenNum-1)*sizeof(unsigned));\r
+       if ( DemandLookahead ) fprintf(ErrFile, "#define DEMAND_LOOK\n");\r
+       fprintf(ErrFile, "#include \"antlr.h\"\n");\r
+       if ( GenAST ) fprintf(ErrFile, "#include \"ast.h\"\n");\r
+                       \r
+    if ( UserDefdTokens ) fprintf(ErrFile, "#include %s\n", UserTokenDefsFile);\r
+       /* still need this one as it has the func prototypes */\r
+       fprintf(ErrFile, "#include \"%s\"\n", DefFileName);\r
+       fprintf(ErrFile, "#include \"dlgdef.h\"\n");\r
+       fprintf(ErrFile, "#include \"err.h\"\n\n");\r
+\r
+       /* Dump a zztokens for each automaton */\r
+       if ( strcmp(ParserName, DefaultParserName)!=0 )\r
+       {\r
+               fprintf(ErrFile, "ANTLRChar *%s_zztokens[%d]={\n", ParserName, TokenNum-1);\r
+       }\r
+       else\r
+       {\r
+               fprintf(ErrFile, "ANTLRChar *zztokens[%d]={\n", TokenNum-1);\r
+       }\r
+       fprintf(ErrFile, "\t/* 00 */\t\"Invalid\"");\r
+       for (i=1; i<TokenNum-1; i++)\r
+       {\r
+               DAWDLE;\r
+               if ( i == EpToken ) continue;\r
+               /* remapped to invalid token? */\r
+               if ( TokenInd!=NULL && TokenInd[i]>=LastTokenCounted )\r
+               {\r
+                       fprintf(ErrFile, ",\n\t/* %02d */\t\"invalid\"", i);\r
+                       continue;\r
+               }\r
+               if ( TokenString(i) != NULL ) {\r
+            te=(TermEntry *) hash_get(Tname,TokenString(i));                     /* MR11 */\r
+            if (te == NULL || te->akaString == NULL) {                          /* MR11 */\r
+                         fprintf(ErrFile, ",\n\t/* %02d */\t\"%s\"", i, TokenString(i));\r
+            } else {\r
+                         fprintf(ErrFile, ",\n\t/* %02d */\t\"%s\"", i, te->akaString);    /* MR11 */\r
+            }\r
+        }\r
+               else\r
+               {\r
+                       /* look in all lexclasses for the reg expr */\r
+                       for (j=0; j<NumLexClasses; j++)\r
+                       {\r
+                               lexmode(j);\r
+                               if ( ExprString(i) != NULL )\r
+                               {\r
+                                       fprintf(ErrFile, ",\n\t/* %02d */\t", i);\r
+                                       dumpExpr(ErrFile, ExprString(i));\r
+                                       break;\r
+                               }\r
+                       }\r
+                       if ( j>=NumLexClasses )\r
+                       {\r
+                               if ( UserDefdTokens )\r
+                               {\r
+                                       fprintf(ErrFile, ",\n\t/* %02d */\t\"\"", i);\r
+                               }\r
+                               else\r
+                                       fatal_internal(eMsgd("No label or expr for token %d",i));\r
+                       }\r
+               }\r
+       }\r
+       fprintf(ErrFile, "\n};\n");\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+dumpExpr( FILE *f, char *e )\r
+#else\r
+dumpExpr( f, e )\r
+FILE *f;\r
+char *e;\r
+#endif\r
+{\r
+       while ( *e!='\0' )\r
+       {\r
+               if ( *e=='\\' && *(e+1)=='\\' )\r
+                       {putc('\\', f); putc('\\', f); e+=2;}\r
+               else if ( *e=='\\' && *(e+1)=='"' )\r
+                       {putc('\\', f); putc('"', f); e+=2;}\r
+               else if ( *e=='\\' ) {putc('\\', f); putc('\\', f); e++;}\r
+               else {putc(*e, f); e++;}\r
+       }\r
+}\r
+\r
+int\r
+#ifdef __USE_PROTOS\r
+isTermEntryTokClass(TermEntry *te)\r
+#else\r
+isTermEntryTokClass(te)\r
+TermEntry *te;\r
+#endif\r
+{\r
+       ListNode *t;\r
+       TCnode *p;\r
+       TermEntry *q;\r
+       char *tokstr;\r
+\r
+       if (tclasses == NULL) return 0;\r
+\r
+       for (t = tclasses->next; t!=NULL; t=t->next)\r
+       {\r
+               p = (TCnode *) t->elem;\r
+               tokstr = TokenString(p->tok);\r
+               lexmode(p->lexclass);   /* switch to lexclass where tokclass is defined */\r
+        q = (TermEntry *) hash_get(Tname, tokstr);\r
+               if (q == te) return 1;\r
+       }\r
+       return 0;\r
+}\r
diff --git a/Tools/CodeTools/Source/Pccts/antlr/build.c b/Tools/CodeTools/Source/Pccts/antlr/build.c
new file mode 100644 (file)
index 0000000..4eb3b02
--- /dev/null
@@ -0,0 +1,813 @@
+/*\r
+ * build.c -- functions associated with building syntax diagrams.\r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
+ * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
+ * company may do whatever they wish with source code distributed with\r
+ * PCCTS or the code generated by PCCTS, including the incorporation of\r
+ * PCCTS, or its output, into commerical software.\r
+ *\r
+ * We encourage users to develop software with PCCTS.  However, we do ask\r
+ * that credit is given to us for developing PCCTS.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like PCCTS and have developed a nice tool with the\r
+ * output, please mention that you developed it using PCCTS.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * ANTLR 1.33\r
+ * Terence Parr\r
+ * Parr Research Corporation\r
+ * with Purdue University and AHPCRC, University of Minnesota\r
+ * 1989-2001\r
+ */\r
+\r
+#include <stdio.h>\r
+#include <stdlib.h>\r
+#include <ctype.h>\r
+#include "pcctscfg.h"\r
+#include "set.h"\r
+#include "syn.h"\r
+#include "hash.h"\r
+#include "generic.h"\r
+#include "dlgdef.h"\r
+\r
+#define SetBlk(g, t, approx, first_set_symbol) {                               \\r
+                       ((Junction *)g.left)->jtype = t;                                                \\r
+                       ((Junction *)g.left)->approx = approx;                                  \\r
+                       ((Junction *)g.left)->pFirstSetSymbol = first_set_symbol;   \\r
+                       ((Junction *)g.left)->end = (Junction *) g.right;               \\r
+                       ((Junction *)g.right)->jtype = EndBlk;}\r
+\r
+/* Add the parameter string 'parm' to the parms field of a block-type junction\r
+ * g.left points to the sentinel node on a block.  i.e. g.left->p1 points to\r
+ * the actual junction with its jtype == some block-type.\r
+ */\r
+void\r
+#ifdef __USE_PROTOS\r
+addParm( Node *p, char *parm )\r
+#else\r
+addParm( p, parm )\r
+Node *p;\r
+char *parm;\r
+#endif\r
+{\r
+       char *q = (char *) malloc( strlen(parm) + 1 );\r
+       require(p!=NULL, "addParm: NULL object\n");\r
+       require(q!=NULL, "addParm: unable to alloc parameter\n");\r
+\r
+       strcpy(q, parm);\r
+       if ( p->ntype == nRuleRef )\r
+       {\r
+               ((RuleRefNode *)p)->parms = q;\r
+       }\r
+       else if ( p->ntype == nJunction )\r
+       {\r
+               ((Junction *)p)->parm = q;      /* only one parameter allowed on subrules */\r
+       }\r
+       else fatal_internal("addParm: invalid node for adding parm");\r
+}\r
+\r
+/*\r
+ * Build an action node for the syntax diagram\r
+ *\r
+ * buildAction(ACTION) ::= --o-->ACTION-->o--\r
+ *\r
+ * Where o is a junction node.\r
+ */\r
+Graph\r
+#ifdef __USE_PROTOS\r
+buildAction( char *action, int file, int line, int is_predicate )\r
+#else\r
+buildAction( action, file, line, is_predicate )\r
+char *action;\r
+int file;\r
+int line;\r
+int is_predicate;\r
+#endif\r
+{\r
+       Junction *j1, *j2;\r
+       Graph g;\r
+       ActionNode *a;\r
+       require(action!=NULL, "buildAction: invalid action");\r
+       \r
+       j1 = newJunction();\r
+       j2 = newJunction();\r
+       a = newActionNode();\r
+       a->action = (char *) malloc( strlen(action)+1 );\r
+       require(a->action!=NULL, "buildAction: cannot alloc space for action\n");\r
+       strcpy(a->action, action);\r
+       j1->p1 = (Node *) a;\r
+       a->next = (Node *) j2;\r
+       a->is_predicate = is_predicate;\r
+\r
+    if (is_predicate) {\r
+        PredEntry   *predEntry;\r
+        char        *t;\r
+        char        *key;\r
+        char        *u;\r
+        int         inverted=0;\r
+\r
+        t=key=(char *)calloc(1,strlen(a->action)+1);\r
+\r
+        for (u=a->action; *u != '\0' ; u++) {\r
+          if (*u != ' ') {\r
+            if (t==key && *u=='!') {\r
+              inverted=!inverted;\r
+            } else {\r
+              *t++=*u;\r
+            };\r
+          };\r
+        };\r
+\r
+        *t='\0';\r
+\r
+\r
+        predEntry=(PredEntry *)hash_get(Pname,key);\r
+        a->predEntry=predEntry;\r
+        if (predEntry != NULL) a->inverted=inverted;\r
+    } else {\r
+/* MR12c */      char  *strStart=a->action;\r
+/* MR12c */      char  *strEnd;\r
+/* MR12c */      strEnd=strStart+strlen(strStart)-1;\r
+/* MR12c */      for ( ; strEnd >= strStart &&  isspace(*strEnd); strEnd--) *strEnd=0;\r
+/* MR12c */      while (*strStart != '\0' && isspace(*strStart)) strStart++;\r
+/* MR12c */      if (ci_strequ(strStart,"nohoist")) {\r
+/* MR12c */        a->noHoist=1;\r
+/* MR12c */      }\r
+       }\r
+\r
+       g.left = (Node *) j1; g.right = (Node *) j2;\r
+       a->file = file;\r
+       a->line = line;\r
+       a->rname = CurRule;     /* MR10 */\r
+       return g;\r
+}\r
+\r
+/*\r
+ * Build a token node for the syntax diagram\r
+ *\r
+ * buildToken(TOKEN) ::= --o-->TOKEN-->o--\r
+ *\r
+ * Where o is a junction node.\r
+ */\r
+Graph\r
+#ifdef __USE_PROTOS\r
+buildToken( char *text )\r
+#else\r
+buildToken( text )\r
+char *text;\r
+#endif\r
+{\r
+       Junction *j1, *j2;\r
+       Graph g;\r
+       TokNode *t;\r
+       require(text!=NULL, "buildToken: invalid token name");\r
+       \r
+       j1 = newJunction();\r
+       j2 = newJunction();\r
+       t = newTokNode();\r
+       t->altstart = CurAltStart;\r
+       if ( *text == '"' ) {t->label=FALSE; t->token = addTexpr( text );}\r
+       else {t->label=TRUE; t->token = addTname( text );}\r
+       j1->p1 = (Node *) t;\r
+       t->next = (Node *) j2;\r
+       g.left = (Node *) j1; g.right = (Node *) j2;\r
+       return g;\r
+}\r
+\r
+/*\r
+ * Build a wild-card node for the syntax diagram\r
+ *\r
+ * buildToken(TOKEN) ::= --o-->'.'-->o--\r
+ *\r
+ * Where o is a junction node.\r
+ */\r
+Graph\r
+#ifdef __USE_PROTOS\r
+buildWildCard( char *text )\r
+#else\r
+buildWildCard( text )\r
+char *text;\r
+#endif\r
+{\r
+       Junction *j1, *j2;\r
+       Graph g;\r
+       TokNode *t;\r
+       TCnode *w;\r
+       TermEntry *p;\r
+       require(text!=NULL, "buildWildCard: invalid token name");\r
+       \r
+       j1 = newJunction();\r
+       j2 = newJunction();\r
+       t = newTokNode();\r
+\r
+       /* If the ref a wild card, make a token class for it */\r
+       if ( Tnum(WildCardString) == 0 )\r
+       {\r
+               w = newTCnode;\r
+               w->tok = addTname( WildCardString );\r
+               set_orel(w->tok, &imag_tokens);\r
+               set_orel(w->tok, &tokclasses);\r
+               WildCardToken = w->tok;\r
+               require((p=(TermEntry *)hash_get(Tname, WildCardString)) != NULL,\r
+                               "hash table mechanism is broken");\r
+               p->classname = 1;       /* entry is class name, not token */\r
+               p->tclass = w;          /* save ptr to this tclass def */\r
+               list_add(&tclasses, (char *)w);\r
+       }\r
+       else {\r
+               p=(TermEntry *)hash_get(Tname, WildCardString);\r
+               require( p!= NULL, "hash table mechanism is broken");\r
+               w = p->tclass;\r
+       }\r
+\r
+       t->token = w->tok;\r
+       t->wild_card = 1;\r
+       t->tclass = w;\r
+\r
+       t->altstart = CurAltStart;\r
+       j1->p1 = (Node *) t;\r
+       t->next = (Node *) j2;\r
+       g.left = (Node *) j1; g.right = (Node *) j2;\r
+       return g;\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+setUpperRange(TokNode *t, char *text)\r
+#else\r
+setUpperRange(t, text)\r
+TokNode *t;\r
+char *text;\r
+#endif\r
+{\r
+       require(t!=NULL, "setUpperRange: NULL token node");\r
+       require(text!=NULL, "setUpperRange: NULL token string");\r
+\r
+       if ( *text == '"' ) {t->upper_range = addTexpr( text );}\r
+       else {t->upper_range = addTname( text );}\r
+}\r
+\r
+/*\r
+ * Build a rule reference node of the syntax diagram\r
+ *\r
+ * buildRuleRef(RULE) ::= --o-->RULE-->o--\r
+ *\r
+ * Where o is a junction node.\r
+ *\r
+ * If rule 'text' has been defined already, don't alloc new space to store string.\r
+ * Set r->text to point to old copy in string table.\r
+ */\r
+Graph\r
+#ifdef __USE_PROTOS\r
+buildRuleRef( char *text )\r
+#else\r
+buildRuleRef( text )\r
+char *text;\r
+#endif\r
+{\r
+       Junction *j1, *j2;\r
+       Graph g;\r
+       RuleRefNode *r;\r
+       RuleEntry *p;\r
+       require(text!=NULL, "buildRuleRef: invalid rule name");\r
+       \r
+       j1 = newJunction();\r
+       j2 = newJunction();\r
+       r = newRNode();\r
+       r->altstart = CurAltStart;\r
+       r->assign = NULL;\r
+       if ( (p=(RuleEntry *)hash_get(Rname, text)) != NULL ) r->text = p->str;\r
+       else r->text = mystrdup( text );\r
+       j1->p1  = (Node *) r;\r
+       r->next = (Node *) j2;\r
+       g.left = (Node *) j1; g.right = (Node *) j2;\r
+       return g;\r
+}\r
+\r
+/*\r
+ * Or two subgraphs into one graph via:\r
+ *\r
+ * Or(G1, G2) ::= --o-G1-o--\r
+ *                  |    ^\r
+ *                                     v    |\r
+ *                  o-G2-o\r
+ *\r
+ * Set the altnum of junction starting G2 to 1 + altnum of junction starting G1.\r
+ * If, however, the G1 altnum is 0, make it 1 and then\r
+ * make G2 altnum = G1 altnum + 1.\r
+ */\r
+Graph\r
+#ifdef __USE_PROTOS\r
+Or( Graph g1, Graph g2 )\r
+#else\r
+Or( g1, g2 )\r
+Graph g1;\r
+Graph g2;\r
+#endif\r
+{\r
+       Graph g;\r
+       require(g1.left != NULL, "Or: invalid graph");\r
+       require(g2.left != NULL && g2.right != NULL, "Or: invalid graph");\r
+\r
+       ((Junction *)g1.left)->p2 = g2.left;\r
+       ((Junction *)g2.right)->p1 = g1.right;\r
+       /* set altnums */\r
+       if ( ((Junction *)g1.left)->altnum == 0 ) ((Junction *)g1.left)->altnum = 1;\r
+       ((Junction *)g2.left)->altnum = ((Junction *)g1.left)->altnum + 1;\r
+       g.left = g2.left;\r
+       g.right = g1.right;\r
+       return g;\r
+}\r
+\r
+/*\r
+ * Catenate two subgraphs\r
+ *\r
+ * Cat(G1, G2) ::= --o-G1-o-->o-G2-o--\r
+ * Cat(NULL,G2)::= --o-G2-o--\r
+ * Cat(G1,NULL)::= --o-G1-o--\r
+ */\r
+Graph\r
+#ifdef __USE_PROTOS\r
+Cat( Graph g1, Graph g2 )\r
+#else\r
+Cat( g1, g2 )\r
+Graph g1;\r
+Graph g2;\r
+#endif\r
+{\r
+       Graph g;\r
+       \r
+       if ( g1.left == NULL && g1.right == NULL ) return g2;\r
+       if ( g2.left == NULL && g2.right == NULL ) return g1;\r
+       ((Junction *)g1.right)->p1 = g2.left;\r
+       g.left = g1.left;\r
+       g.right = g2.right;\r
+       return g;\r
+}\r
+\r
+/*\r
+ * Make a subgraph an optional block\r
+ *\r
+ * makeOpt(G) ::= --o-->o-G-o-->o--\r
+ *                      |          ^\r
+ *                                             v           |\r
+ *                                         o-------o\r
+ *\r
+ * Note that this constructs {A|B|...|Z} as if (A|B|...|Z|) was found.\r
+ *\r
+ * The node on the far right is added so that every block owns its own\r
+ * EndBlk node.\r
+ */\r
+Graph\r
+#ifdef __USE_PROTOS\r
+makeOpt( Graph g1, int approx, char * pFirstSetSymbol )\r
+#else\r
+makeOpt( g1, approx, pFirstSetSymbol )\r
+Graph g1;\r
+int approx;\r
+char * pFirstSetSymbol;\r
+#endif\r
+{\r
+       Junction *j1,*j2,*p;\r
+       Graph g;\r
+       require(g1.left != NULL && g1.right != NULL, "makeOpt: invalid graph");\r
+\r
+       j1 = newJunction();\r
+       j2 = newJunction();\r
+       ((Junction *)g1.right)->p1 = (Node *) j2;       /* add node to G at end */\r
+\r
+    /*  MR21\r
+     *\r
+     *  There is code in genBlk which recognizes the node created\r
+     *  by emptyAlt() as a special case and bypasses it.  We don't\r
+     *  want this to happen for the optBlk.\r
+     */\r
+\r
+       g = emptyAlt3(); /* MR21 */\r
+       if ( ((Junction *)g1.left)->altnum == 0 ) ((Junction *)g1.left)->altnum = 1;\r
+       ((Junction *)g.left)->altnum = ((Junction *)g1.left)->altnum + 1;\r
+       for(p=(Junction *)g1.left; p->p2!=NULL; p=(Junction *)p->p2)\r
+               {;}                                                                             /* find last alt */\r
+       p->p2 = g.left;                                                         /* add optional alternative */\r
+       ((Junction *)g.right)->p1 = (Node *)j2;         /* opt alt points to EndBlk */\r
+       g1.right = (Node *)j2;\r
+       SetBlk(g1, aOptBlk, approx, pFirstSetSymbol);\r
+       j1->p1 = g1.left;                                                       /* add generic node in front */\r
+       g.left = (Node *) j1;\r
+       g.right = g1.right;\r
+       return g;\r
+}\r
+\r
+/*\r
+ * Make a graph into subblock\r
+ *\r
+ * makeBlk(G) ::= --o-->o-G-o-->o--\r
+ *\r
+ * The node on the far right is added so that every block owns its own\r
+ * EndBlk node.\r
+ */\r
+Graph\r
+#ifdef __USE_PROTOS\r
+makeBlk( Graph g1, int approx, char * pFirstSetSymbol )\r
+#else\r
+makeBlk( g1, approx, pFirstSetSymbol )\r
+Graph g1;\r
+int approx;\r
+char * pFirstSetSymbol;\r
+#endif\r
+{\r
+       Junction *j,*j2;\r
+       Graph g;\r
+       require(g1.left != NULL && g1.right != NULL, "makeBlk: invalid graph");\r
+\r
+       j = newJunction();\r
+       j2 = newJunction();\r
+       ((Junction *)g1.right)->p1 = (Node *) j2;       /* add node to G at end */\r
+       g1.right = (Node *)j2;\r
+       SetBlk(g1, aSubBlk, approx, pFirstSetSymbol);\r
+       j->p1 = g1.left;                                                        /* add node in front */\r
+       g.left = (Node *) j;\r
+       g.right = g1.right;\r
+\r
+       return g;\r
+}\r
+\r
+/*\r
+ * Make a subgraph into a loop (closure) block -- (...)*\r
+ *\r
+ * makeLoop(G) ::=       |---|\r
+ *                                          v   |\r
+ *                        --o-->o-->o-G-o-->o--\r
+ *                   |           ^\r
+ *                   v           |\r
+ *                                      o-----------o\r
+ *\r
+ * After making loop, always place generic node out front.  It becomes\r
+ * the start of enclosing block.  The aLoopBlk is the target of the loop.\r
+ *\r
+ * Loop blks have TWO EndBlk nodes--the far right and the node that loops back\r
+ * to the aLoopBlk node.  Node with which we can branch past loop == aLoopBegin and\r
+ * one which is loop target == aLoopBlk.\r
+ * The branch-past (initial) aLoopBegin node has end\r
+ * pointing to the last EndBlk node.  The loop-target node has end==NULL.\r
+ *\r
+ * Loop blocks have a set of locks (from 1..CLL_k) on the aLoopBlk node.\r
+ */\r
+Graph\r
+#ifdef __USE_PROTOS\r
+makeLoop( Graph g1, int approx, char * pFirstSetSymbol )\r
+#else\r
+makeLoop( g1, approx, pFirstSetSymbol)\r
+Graph g1;\r
+int approx;\r
+char * pFirstSetSymbol;\r
+#endif\r
+{\r
+       Junction *back, *front, *begin;\r
+       Graph g;\r
+       require(g1.left != NULL && g1.right != NULL, "makeLoop: invalid graph");\r
+\r
+       back = newJunction();\r
+       front = newJunction();\r
+       begin = newJunction();\r
+       g = emptyAlt3();\r
+       ((Junction *)g1.right)->p2 = g1.left;           /* add loop branch to G */\r
+       ((Junction *)g1.right)->p1 = (Node *) back;     /* add node to G at end */\r
+       ((Junction *)g1.right)->jtype = EndBlk;         /* mark 1st EndBlk node */\r
+       ((Junction *)g1.left)->jtype = aLoopBlk;        /* mark 2nd aLoopBlk node */\r
+       ((Junction *)g1.left)->end = (Junction *) g1.right;\r
+       ((Junction *)g1.left)->lock = makelocks();\r
+       ((Junction *)g1.left)->pred_lock = makelocks();\r
+       g1.right = (Node *) back;\r
+       begin->p1 = (Node *) g1.left;\r
+       g1.left = (Node *) begin;\r
+       begin->p2 = (Node *) g.left;                            /* make bypass arc */\r
+       ((Junction *)g.right)->p1 = (Node *) back;\r
+       SetBlk(g1, aLoopBegin, approx, pFirstSetSymbol);\r
+       front->p1 = g1.left;                                            /* add node to front */\r
+       g1.left = (Node *) front;\r
+\r
+       return g1;\r
+}\r
+\r
+/*\r
+ * Make a subgraph into a plus block -- (...)+ -- 1 or more times\r
+ *\r
+ * makePlus(G) ::=      |---|\r
+ *                                      v   |\r
+ *                        --o-->o-G-o-->o--\r
+ *\r
+ * After making loop, always place generic node out front.  It becomes\r
+ * the start of enclosing block.  The aPlusBlk is the target of the loop.\r
+ *\r
+ * Plus blks have TWO EndBlk nodes--the far right and the node that loops back\r
+ * to the aPlusBlk node.\r
+ *\r
+ * Plus blocks have a set of locks (from 1..CLL_k) on the aPlusBlk node.\r
+ */\r
+Graph\r
+#ifdef __USE_PROTOS\r
+makePlus( Graph g1, int approx, char * pFirstSetSymbol)\r
+#else\r
+makePlus( g1, approx, pFirstSetSymbol)\r
+Graph g1;\r
+int approx;\r
+char * pFirstSetSymbol;\r
+#endif\r
+{\r
+       int has_empty_alt_already = 0;\r
+       Graph g;\r
+       Junction *j2, *j3, *first_alt;\r
+       Junction *last_alt=NULL, *p;\r
+       require(g1.left != NULL && g1.right != NULL, "makePlus: invalid graph");\r
+\r
+       first_alt = (Junction *)g1.left;\r
+       j2 = newJunction();\r
+       j3 = newJunction();\r
+       if ( ((Junction *)g1.left)->altnum == 0 ) ((Junction *)g1.left)->altnum = 1;\r
+       ((Junction *)g1.right)->p2 = g1.left;           /* add loop branch to G */\r
+       ((Junction *)g1.right)->p1 = (Node *) j2;       /* add node to G at end */\r
+       ((Junction *)g1.right)->jtype = EndBlk;         /* mark 1st EndBlk node */\r
+       g1.right = (Node *) j2;\r
+       SetBlk(g1, aPlusBlk, approx, pFirstSetSymbol);\r
+       ((Junction *)g1.left)->lock = makelocks();\r
+       ((Junction *)g1.left)->pred_lock = makelocks();\r
+       j3->p1 = g1.left;                                                       /* add node to front */\r
+       g1.left = (Node *) j3;\r
+\r
+       /* add an optional branch which is the "exit" branch of loop */\r
+       /* FIRST, check to ensure that there does not already exist\r
+        * an optional path.\r
+        */\r
+       /* find last alt */\r
+       for(p=first_alt; p!=NULL; p=(Junction *)p->p2)\r
+       {\r
+               if ( p->p1->ntype == nJunction &&\r
+                        p->p1!=NULL &&\r
+                        ((Junction *)p->p1)->jtype==Generic &&\r
+                        ((Junction *)p->p1)->p1!=NULL &&\r
+                        ((Junction *)((Junction *)p->p1)->p1)->jtype==EndBlk )\r
+               {\r
+                       has_empty_alt_already = 1;\r
+               }\r
+               last_alt = p;\r
+       }\r
+       if ( !has_empty_alt_already )\r
+       {\r
+               require(last_alt!=NULL, "last_alt==NULL; bad (..)+");\r
+               g = emptyAlt();\r
+               last_alt->p2 = g.left;\r
+               ((Junction *)g.right)->p1 = (Node *) j2;\r
+\r
+               /* make sure lookahead computation ignores this alt for\r
+               * FIRST("(..)+"); but it's still used for computing the FIRST\r
+               * of each alternative.\r
+               */\r
+               ((Junction *)g.left)->ignore = 1;\r
+       }\r
+\r
+       return g1;\r
+}\r
+\r
+/*\r
+ * Return an optional path:  --o-->o--\r
+ */\r
+\r
+Graph\r
+#ifdef __USE_PROTOS\r
+emptyAlt( void )\r
+#else\r
+emptyAlt( )\r
+#endif\r
+{\r
+       Junction *j1, *j2;\r
+       Graph g;\r
+\r
+       j1 = newJunction();\r
+       j2 = newJunction();\r
+       j1->p1 = (Node *) j2;\r
+       g.left = (Node *) j1;\r
+       g.right = (Node *) j2;\r
+       \r
+       return g;\r
+}\r
+\r
+/*  MR21\r
+ *\r
+ *  There is code in genBlk which recognizes the node created\r
+ *  by emptyAlt() as a special case and bypasses it.  We don't\r
+ *  want this to happen for the optBlk.\r
+ */\r
+\r
+Graph\r
+#ifdef __USE_PROTOS\r
+emptyAlt3( void )\r
+#else\r
+emptyAlt3( )\r
+#endif\r
+{\r
+       Junction *j1, *j2, *j3;\r
+       Graph g;\r
+\r
+       j1 = newJunction();\r
+       j2 = newJunction();\r
+    j3 = newJunction();\r
+       j1->p1 = (Node *) j2;\r
+       j2->p1 = (Node *) j3;\r
+       g.left = (Node *) j1;\r
+       g.right = (Node *) j3;\r
+       \r
+       return g;\r
+}\r
+\r
+/* N o d e  A l l o c a t i o n */\r
+\r
+TokNode *\r
+#ifdef __USE_PROTOS\r
+newTokNode( void )\r
+#else\r
+newTokNode( )\r
+#endif\r
+{\r
+       static TokNode *FreeList = NULL;\r
+       TokNode *p, *newblk;\r
+\r
+       if ( FreeList == NULL )\r
+       {\r
+               newblk = (TokNode *)calloc(TokenBlockAllocSize, sizeof(TokNode));\r
+               if ( newblk == NULL )\r
+                       fatal_internal(eMsg1("out of memory while building rule '%s'",CurRule));\r
+               for (p=newblk; p<&(newblk[TokenBlockAllocSize]); p++)\r
+               {\r
+                       p->next = (Node *)FreeList;     /* add all new token nodes to FreeList */\r
+                       FreeList = p;\r
+               }\r
+       }\r
+       p = FreeList;\r
+       FreeList = (TokNode *)FreeList->next;/* remove a TokNode node */\r
+       p->next = NULL;                                         /* NULL the ptr we used */\r
+    memset( (char *) p, 0, sizeof(TokNode));        /* MR10 */\r
+       p->ntype = nToken;\r
+       p->rname = CurRule;\r
+       p->file = CurFile;\r
+       p->line = zzline;\r
+       p->altstart = NULL;\r
+\r
+       return p;\r
+}\r
+\r
+RuleRefNode *\r
+#ifdef __USE_PROTOS\r
+newRNode( void )\r
+#else\r
+newRNode( )\r
+#endif\r
+{\r
+       static RuleRefNode *FreeList = NULL;\r
+       RuleRefNode *p, *newblk;\r
+\r
+       if ( FreeList == NULL )\r
+       {\r
+               newblk = (RuleRefNode *)calloc(RRefBlockAllocSize, sizeof(RuleRefNode));\r
+               if ( newblk == NULL )\r
+                       fatal_internal(eMsg1("out of memory while building rule '%s'",CurRule));\r
+               for (p=newblk; p<&(newblk[RRefBlockAllocSize]); p++)\r
+               {\r
+                       p->next = (Node *)FreeList;     /* add all new rref nodes to FreeList */\r
+                       FreeList = p;\r
+               }\r
+       }\r
+       p = FreeList;\r
+       FreeList = (RuleRefNode *)FreeList->next;/* remove a Junction node */\r
+       p->next = NULL;                                         /* NULL the ptr we used */\r
+    memset( (char *) p, 0, sizeof(RuleRefNode));        /* MR10 */\r
+       p->ntype = nRuleRef;\r
+       p->rname = CurRule;\r
+       p->file = CurFile;\r
+       p->line = zzline;\r
+       p->astnode = ASTinclude;\r
+       p->altstart = NULL;\r
+       \r
+       return p;\r
+}\r
+\r
+static int junctionSeqNumber=0;         /* MR10 */\r
+\r
+Junction *\r
+#ifdef __USE_PROTOS\r
+newJunction( void )\r
+#else\r
+newJunction( )\r
+#endif\r
+{\r
+       static Junction *FreeList = NULL;\r
+       Junction *p, *newblk;\r
+\r
+       if ( FreeList == NULL )\r
+       {\r
+               newblk = (Junction *)calloc(JunctionBlockAllocSize, sizeof(Junction));\r
+               if ( newblk == NULL )\r
+                       fatal_internal(eMsg1("out of memory while building rule '%s'",CurRule));\r
+               for (p=newblk; p<&(newblk[JunctionBlockAllocSize]); p++)\r
+               {\r
+                       p->p1 = (Node *)FreeList;       /* add all new Junction nodes to FreeList */\r
+                       FreeList = p;\r
+               }\r
+       }\r
+       p = FreeList;\r
+       FreeList = (Junction *)FreeList->p1;/* remove a Junction node */\r
+       p->p1 = NULL;                                           /* NULL the ptr we used */\r
+    memset( (char *) p, 0, sizeof(Junction));       /* MR10 */\r
+       p->ntype = nJunction;\r
+       p->visited = 0;\r
+       p->jtype = Generic;\r
+       p->rname = CurRule;\r
+       p->file = CurFile;\r
+       p->line = zzline;\r
+       p->exception_label = NULL;\r
+       p->fset = (set *) calloc(CLL_k+1, sizeof(set));\r
+       require(p->fset!=NULL, "cannot allocate fset in newJunction");\r
+    p->seq=++junctionSeqNumber;     /* MR10 */\r
+\r
+       return p;\r
+}\r
+\r
+ActionNode *\r
+#ifdef __USE_PROTOS\r
+newActionNode( void )\r
+#else\r
+newActionNode( )\r
+#endif\r
+{\r
+       static ActionNode *FreeList = NULL;\r
+       ActionNode *p, *newblk;\r
+\r
+       if ( FreeList == NULL )\r
+       {\r
+               newblk = (ActionNode *)calloc(ActionBlockAllocSize, sizeof(ActionNode));\r
+               if ( newblk == NULL )\r
+                       fatal_internal(eMsg1("out of memory while building rule '%s'",CurRule));\r
+               for (p=newblk; p<&(newblk[ActionBlockAllocSize]); p++)\r
+               {\r
+                       p->next = (Node *)FreeList;     /* add all new Action nodes to FreeList */\r
+                       FreeList = p;\r
+               }\r
+       }\r
+       p = FreeList;\r
+       FreeList = (ActionNode *)FreeList->next;/* remove an Action node */\r
+    memset( (char *) p, 0, sizeof(ActionNode));     /* MR10 */\r
+       p->ntype = nAction;\r
+       p->next = NULL;                                         /* NULL the ptr we used */\r
+       p->done = 0;\r
+       p->pred_fail = NULL;\r
+       p->guardpred = NULL;\r
+    p->ampersandPred = NULL;\r
+       return p;\r
+}\r
+\r
+/*\r
+ * allocate the array of locks (1..CLL_k) used to inhibit infinite recursion.\r
+ * Infinite recursion can occur in (..)* blocks, FIRST calcs and FOLLOW calcs.\r
+ * Therefore, we need locks on aLoopBlk, RuleBlk, EndRule nodes.\r
+ *\r
+ * if ( lock[k]==TRUE ) then we have been here before looking for k tokens\r
+ * of lookahead.\r
+ */\r
+char *\r
+#ifdef __USE_PROTOS\r
+makelocks( void )\r
+#else\r
+makelocks( )\r
+#endif\r
+{\r
+       char *p = (char *) calloc(CLL_k+1, sizeof(char));\r
+       require(p!=NULL, "cannot allocate lock array");\r
+       \r
+       return p;\r
+}\r
+\r
+#if 0\r
+** #ifdef __USE_PROTOS\r
+** void my_memset(char *p,char value,int count)\r
+** #else\r
+** void my_memset(p,value,count)\r
+**   char      *p;\r
+**   char      value;\r
+**   int       count;\r
+** #endif\r
+** {\r
+**    int      i;\r
+**\r
+**    for (i=0; i<count; i++) {\r
+**     p[i]=value;\r
+**   };\r
+** }\r
+#endif\r
diff --git a/Tools/CodeTools/Source/Pccts/antlr/build.xml b/Tools/CodeTools/Source/Pccts/antlr/build.xml
new file mode 100644 (file)
index 0000000..dfc1455
--- /dev/null
@@ -0,0 +1,129 @@
+<?xml version="1.0" ?>\r
+<!--\r
+Copyright (c) 2006, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+-->\r
+<project default="GenTool" basedir=".">\r
+<!--\r
+    EDK antlr Tool\r
+  Copyright (c) 2006, Intel Corporation\r
+-->\r
+  <property name="ToolName" value="antlr"/>\r
+\r
+  <taskdef resource="cpptasks.tasks"/>\r
+  <typedef resource="cpptasks.types"/>\r
+  <taskdef resource="net/sf/antcontrib/antlib.xml"/>\r
+\r
+  <target name="init">\r
+               <condition property="CheckDepends">\r
+                 <uptodate targetfile="${WORKSPACE}/Tools/bin/antlr.exe">\r
+                         <srcfiles dir="." includes="*.c *.h *.g"/>\r
+                       </uptodate>\r
+               </condition>\r
+               <if>\r
+                 <equals arg1="${CheckDepends}" arg2="true"/>\r
+                       <then>\r
+                               <echo message="Executable, antlr.exe, is up to date."/>\r
+                       </then>\r
+      <else>\r
+        <echo message="Building the EDK Pccts Tool: ${ToolName}"/>\r
+      </else>\r
+               </if>\r
+  </target>\r
+\r
+  <target name="GenTool" depends="init" unless="CheckDepends">\r
+    <if>\r
+      <equals arg1="${ToolChain}" arg2="msvc"/>\r
+                       <then>\r
+         <exec dir="${PACKAGE_DIR}/Pccts/antlr" executable="nmake" failonerror="TRUE">\r
+                 <arg line="-f AntlrMS.mak"/>\r
+               </exec>\r
+                 </then>\r
+               <elseif>\r
+        <istrue value="${cygwin}"/>\r
+                   <then>\r
+           <exec dir="${PACKAGE_DIR}/Pccts/antlr" executable="make" failonerror="TRUE">\r
+                 <arg line="-f makefile.cygwin"/>\r
+               </exec>\r
+                   </then>\r
+      </elseif>\r
+      <elseif>\r
+        <istrue value="${gcc}"/>\r
+        <then>\r
+           <exec dir="${PACKAGE_DIR}/Pccts/antlr" executable="make" failonerror="TRUE">\r
+                 <arg line="-f makefile BIN_DIR=${BIN_DIR}"/>\r
+               </exec>\r
+        </then>\r
+                 </elseif>\r
+               </if>\r
+    <echo message="The EDK Tool: ${ToolName} build has completed!"/>\r
+       </target>\r
+\r
+  <target name="clean">\r
+    <echo message="Removing Intermediate Files Only"/>  \r
+    <if>\r
+      <equals arg1="${ToolChain}" arg2="msvc"/>\r
+                       <then>\r
+         <exec dir="${PACKAGE_DIR}/Pccts/antlr" executable="nmake" failonerror="TRUE">\r
+                 <arg line="-f AntlrMS.mak clean"/>\r
+               </exec>\r
+                 </then>\r
+    <elseif>\r
+      <istrue value="${cygwin}"/>\r
+      <then>\r
+         <exec dir="${PACKAGE_DIR}/Pccts/antlr" executable="make" failonerror="TRUE">\r
+                 <arg line="-f makefile.cygwin clean"/>\r
+               </exec>\r
+      </then>\r
+               </elseif>\r
+               <elseif>\r
+      <istrue value="${gcc}"/>\r
+      <then>\r
+         <exec dir="${PACKAGE_DIR}/Pccts/antlr" executable="make" failonerror="TRUE">\r
+                 <arg line="-f makefile clean"/>\r
+               </exec>\r
+      </then>\r
+               </elseif>\r
+               </if>\r
+  </target>\r
+\r
+  <target name="cleanall">\r
+    <echo message="Removing Object Files and the Executable: ${ToolName}${ext_exe}"/>  \r
+    <if>\r
+      <equals arg1="${ToolChain}" arg2="msvc"/>\r
+                       <then>\r
+         <exec dir="${PACKAGE_DIR}/Pccts/antlr" executable="nmake" failonerror="FALSE">\r
+                 <arg line="-f AntlrMS.mak clean"/>\r
+               </exec>\r
+                 </then>\r
+               <elseif>\r
+      <istrue value="${cygwin}"/>\r
+                       <then>\r
+        <echo message="Building antlr with cygwin gcc"/>\r
+         <exec dir="${PACKAGE_DIR}/Pccts/antlr" executable="make" failonerror="FALSE">\r
+                 <arg line="-f makefile.cygwin clean"/>\r
+               </exec>\r
+                 </then>\r
+               </elseif>\r
+               <elseif>\r
+      <istrue value="${gcc}"/>\r
+      <then>\r
+        <echo message="Building antlr with gcc"/>\r
+         <exec dir="${PACKAGE_DIR}/Pccts/antlr" executable="make" failonerror="FALSE">\r
+                 <arg line="-f makefile clean"/>\r
+               </exec>\r
+      </then>\r
+               </elseif>\r
+               </if>\r
+    <delete failonerror="false" quiet="true" includeEmptyDirs="true">\r
+      <fileset file="${BIN_DIR}/${ToolName}${ext_exe}"/>\r
+    </delete>\r
+  </target>\r
+\r
+</project>\r
diff --git a/Tools/CodeTools/Source/Pccts/antlr/dumpcycles.c b/Tools/CodeTools/Source/Pccts/antlr/dumpcycles.c
new file mode 100644 (file)
index 0000000..8156159
--- /dev/null
@@ -0,0 +1,67 @@
+#include <stdio.h>\r
+#include <ctype.h>\r
+\r
+#include "set.h"\r
+#include "syn.h"\r
+#include "hash.h"\r
+#include "generic.h"\r
+\r
+void \r
+#ifdef __USE_PROTOS\r
+dumpcycles(void)\r
+#else\r
+dumpcycles()\r
+#endif\r
+{\r
+  Cycle         *c;\r
+  CacheEntry    *f;\r
+  ListNode      *p;\r
+  int           i=0;\r
+  int           k;\r
+  int           degree;\r
+\r
+  for (k=1; k <= CLL_k; k++) {\r
+    if (Cycles[k] == NULL) continue;\r
+\r
+    for (p = Cycles[k]->next; p!=NULL; p=p->next) {\r
+         c = (Cycle *) p->elem;\r
+      degree=set_deg(c->cyclicDep);\r
+         fprintf(stderr,"Cycle %d: (degree %d) %s -->\n", i++, degree, RulePtr[c->croot]->rname);\r
+      fprintf(stderr,"    *self*\n");\r
+      MR_dumpRuleSet(c->cyclicDep);\r
+      fprintf(stderr,"\n");\r
+         f = (CacheEntry *)\r
+                       hash_get(Fcache,Fkey(RulePtr[c->croot]->rname,'o',k));\r
+      if (f == NULL) {\r
+        fprintf(stderr,"    *** FOLLOW(%s) must be in cache but isn't ***\n",\r
+                                         RulePtr[c->croot]->rname);\r
+      };\r
+    };\r
+  };\r
+}\r
+\r
+void \r
+#ifdef __USE_PROTOS\r
+dumpfostack(int k) \r
+#else\r
+dumpfostack(k) \r
+int k;\r
+#endif\r
+{\r
+  int   i=0;\r
+  int   *pi;\r
+\r
+  fprintf(stderr,"\n");\r
+  if (FoStack[k] == NULL) {\r
+    fprintf(stderr,"FoStack[%d] is null\n",k);\r
+  };\r
+  if (FoTOS[k] == NULL) {\r
+    fprintf(stderr,"FoTOS[%d] is null\n",k);\r
+  }\r
+  if (FoTOS[k] != NULL && FoStack[k] != NULL) {\r
+    for (pi=FoStack[k]; pi <= FoTOS[k]; pi++) {\r
+      i++;\r
+      fprintf(stderr,"#%d  rule %d  %s\n",i,*pi,RulePtr[*pi]->rname);\r
+    }\r
+  }\r
+}\r
diff --git a/Tools/CodeTools/Source/Pccts/antlr/dumpnode.c b/Tools/CodeTools/Source/Pccts/antlr/dumpnode.c
new file mode 100644 (file)
index 0000000..2a34c6f
--- /dev/null
@@ -0,0 +1,423 @@
+#include <stdio.h>\r
+#include <ctype.h>\r
+\r
+#include "set.h"\r
+#include "syn.h"\r
+#include "hash.h"\r
+#include "generic.h"\r
+\r
+#ifdef __USE_PROTOS\r
+void dumpset1(set s)\r
+#else\r
+void dumpset1(s)\r
+  set   s;\r
+#endif\r
+{\r
+  if (set_nil(s)) {\r
+    fprintf(stderr,"{}");\r
+  } else {\r
+    s_fprT(stderr,s);\r
+  };\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+void dumpset(set s)\r
+#else\r
+void dumpset(s)\r
+  set   s;\r
+#endif\r
+{\r
+  dumpset1(s);\r
+  fprintf(stderr,"\n");\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+int isEndRule(Node * p)\r
+#else\r
+int isEndRule(p)\r
+  Node *    p;\r
+#endif\r
+{\r
+  int       result=0;\r
+  if ( p->ntype == nJunction &&\r
+       ( (Junction *) p)->jtype == EndRule) {\r
+    result=1;\r
+  };\r
+  return result;\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+void dumppred1(int depth,Predicate *p)\r
+#else\r
+void dumppred1(depth,p)\r
+  int           depth;\r
+  Predicate     *p;\r
+#endif\r
+{\r
+  int       i;\r
+  int       k;\r
+\r
+  for (i=0; i<depth ; i++) {\r
+    fprintf(stderr,"  ");\r
+  };\r
+  if (p->expr == PRED_AND_LIST ||\r
+      p->expr == PRED_OR_LIST) {\r
+    fprintf(stderr," %s", (p->expr == NULL ? "null expr" : p->expr));\r
+    if (p->inverted) fprintf(stderr," predicate inverted !");\r
+    if (p->redundant) {\r
+      fprintf(stderr," Redundant!");\r
+    };\r
+    if (p->isConst) fprintf(stderr," const %d !",p->constValue);\r
+    fprintf(stderr,"\n");\r
+  } else {\r
+    fprintf(stderr,"predicate k=%d",p->k);\r
+    k=set_int(p->completionSet);\r
+    if (k >= 0) {\r
+      fprintf(stderr," Incomplete Set=%d !",k);\r
+    };\r
+    k=set_int(p->completionTree);\r
+    if (k >= 0) {\r
+      fprintf(stderr," Incomplete Tree=%d !",k);\r
+    };\r
+    if (p->redundant) {\r
+      fprintf(stderr," Redundant!");\r
+    };\r
+    fprintf(stderr," \"%s\" (%x)", (p->expr == NULL ? "null expr" : p->expr) ,p);\r
+    if (p->source != NULL) {\r
+       fprintf(stderr,"line %d",p->source->line);\r
+    };\r
+    if (p->inverted) fprintf(stderr," predicate inverted !");\r
+    fprintf(stderr,"\n");\r
+    for (i=0; i<depth ; i++) {\r
+      fprintf(stderr,"  ");\r
+    };\r
+    fprintf(stderr,"scontext: ");\r
+    dumpset(p->scontext[1]);\r
+    for (i=0; i<depth ; i++) {\r
+      fprintf(stderr,"  ");\r
+    };\r
+    fprintf(stderr,"tcontext: ");\r
+    preorder(p->tcontext);\r
+    fprintf(stderr,"\n");\r
+  };\r
+  fprintf(stderr,"\n");\r
+  if (p->down != NULL) {\r
+    dumppred1(depth+1,p->down);\r
+  };\r
+  if (p->right != NULL) {\r
+    dumppred1(depth,p->right);\r
+  };\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+void dumppred(Predicate *p)\r
+#else\r
+void dumppred(p)\r
+  Predicate     *p;\r
+#endif\r
+{\r
+  fprintf(stderr,"---------------------------------\n");\r
+  dumppred1(0,p);\r
+  fprintf(stderr,"\n");\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+void dumppredtree(Predicate *p)\r
+#else\r
+void dumppredtree(p)\r
+  Predicate     *p;\r
+#endif\r
+{\r
+  fprintf(stderr,"predicate k=%d \"%s\" line %d\n",p->k,p->expr,p->source->line);\r
+  dumpset(p->scontext[1]);\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+void dumppredexpr(Predicate *p)\r
+#else\r
+void dumppredexpr(p)\r
+  Predicate     *p;\r
+#endif\r
+{\r
+  fprintf(stderr,"    pred expr \"%s\"\n",p->expr);\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+void dt(Tree *t)\r
+#else\r
+void dt(t)\r
+  Tree  *t;\r
+#endif\r
+{\r
+  MR_dumpTreeF(stderr,0,t,5);\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+void d(Node * p)\r
+#else\r
+void d(p)\r
+  Node *    p;\r
+#endif\r
+{\r
+\r
+  Junction      *j;\r
+  RuleRefNode   *r;\r
+  TokNode       *t;\r
+  ActionNode    *a;\r
+\r
+  if (p==NULL) {\r
+    fprintf(stderr,"dumpNode: Node is NULL");\r
+    return;\r
+  };\r
+\r
+  switch (p->ntype) {\r
+    case nJunction :\r
+      j = (Junction *) p;\r
+      fprintf(stderr, "Junction (#%d in rule %s line %d) ",j->seq,j->rname,j->line);\r
+      if (j->guess) fprintf(stderr,"guess block ");\r
+      switch (j->jtype ) {\r
+        case aSubBlk :\r
+          fprintf(stderr,"aSubBlk");\r
+          break;\r
+        case aOptBlk :\r
+          fprintf(stderr,"aOptBlk");\r
+          break;\r
+        case aLoopBegin :\r
+          fprintf(stderr,"aLoopBeginBlk");\r
+          break;\r
+        case aLoopBlk :\r
+          fprintf(stderr,"aLoopBlk");\r
+          break;\r
+        case aPlusBlk :\r
+          fprintf(stderr,"aPlusBlk");\r
+          break;\r
+        case EndBlk :\r
+          fprintf(stderr,"EndBlk");\r
+          break;\r
+        case RuleBlk :\r
+          fprintf(stderr,"RuleBlk");\r
+          break;\r
+        case Generic :\r
+          fprintf(stderr,"Generic");\r
+          break;\r
+        case EndRule :\r
+          fprintf(stderr,"EndRule");\r
+          break;\r
+      };\r
+      if (j->halt) fprintf(stderr,"  halt!");\r
+      if (j->p1) fprintf(stderr," p1 valid");\r
+      if (j->p2) {\r
+        if (j->p2->ntype == nJunction) {\r
+           fprintf(stderr," (p2=#%d)",( (Junction *) j->p2)->seq);\r
+        } else {\r
+           fprintf(stderr," (p2 valid)");\r
+        };\r
+      };\r
+         if (j->ignore) fprintf(stderr, " ignore/plus-block-bypass");\r
+      if (j->fset != NULL && set_deg(*j->fset) != 0) {\r
+         fprintf(stderr,"\nfset:\n");\r
+         dumpset(*j->fset);\r
+      };\r
+      if (j->ftree != NULL) {\r
+         fprintf(stderr,"\nftree:\n");\r
+         preorder(j->ftree);\r
+      };\r
+      fprintf(stderr,"\n");\r
+      break;\r
+    case nRuleRef :\r
+       r = (RuleRefNode *) p;\r
+       fprintf(stderr, "RuleRefNode (in rule %s line %d) to rule %s\n", r->rname,r->line,r->text);\r
+       break;\r
+    case nToken :\r
+       t = (TokNode *) p;\r
+       fprintf(stderr, "TokNode (in rule %s line %d) token %s\n",t->rname,t->line,TerminalString(t->token));\r
+       break;\r
+    case nAction :\r
+       a =(ActionNode *) p;\r
+       if (a->is_predicate) {\r
+         fprintf(stderr, "Predicate (in rule %s line %d) %s",a->rname,a->line,a->action);\r
+         if (a->inverted) fprintf(stderr," action inverted !");\r
+         if (a->guardpred != NULL) {\r
+           fprintf(stderr," guarded");\r
+           dumppredexpr(a->guardpred);\r
+           if (a->ampersandPred) {\r
+             fprintf(stderr," \"&&\" style");\r
+           } else {\r
+             fprintf(stderr," \"=>\" style");\r
+           };\r
+         };\r
+         if (a->predEntry != NULL) fprintf(stderr," predEntry \"%s\" ",a->predEntry->str);\r
+         fprintf(stderr,"\n");\r
+       } else if (a->init_action) {\r
+         fprintf(stderr, "Init-Action (in rule %s line %d) %s\n",a->rname,a->line,a->action);\r
+       } else {\r
+         fprintf(stderr, "Action (in rule %s line %d) %s\n",a->rname,a->line,a->action);\r
+       };\r
+       break;\r
+   };\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+Node * dp1(Node * p)\r
+#else\r
+Node * dp1(p)\r
+  Node *    p;\r
+#endif\r
+{\r
+  Node  *result=NULL;\r
+\r
+  if (p->ntype == nJunction) {\r
+    result=( (Junction *) p )->p1;\r
+    d(result);\r
+  } else {\r
+    fprintf(stderr,"dp1: Not a Junction node");\r
+  };\r
+  return result;\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+Node * dp2(Node * p)\r
+#else\r
+Node * dp2(p)\r
+  Node *    p;\r
+#endif\r
+{\r
+  Node  *result=NULL;\r
+\r
+  if (p->ntype == nJunction) {\r
+    result=( (Junction *) p )->p2;\r
+    d(result);\r
+  } else {\r
+    fprintf(stderr,"dp2: Not a Junction node");\r
+  };\r
+  return result;\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+Node * dn(Node * p)\r
+#else\r
+Node * dn(p)\r
+  Node *    p;\r
+#endif\r
+\r
+{\r
+  Node  *result=NULL;\r
+\r
+  if (p->ntype == nRuleRef) {\r
+    result=( (RuleRefNode *)p )->next;\r
+  } else if (p->ntype == nAction) {\r
+    result=( (ActionNode *)p )->next;\r
+  } else if (p->ntype == nToken) {\r
+    result=( (TokNode *)p )->next;\r
+  } else {\r
+    fprintf(stderr,"No next field: Neither a RuleRefNode, ActionNode, nor TokNode");\r
+  };\r
+  if (result != NULL) d(result);\r
+  return result;\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+void df(Node * p)\r
+#else\r
+void df(p)\r
+  Node *    p;\r
+#endif\r
+{\r
+  int       count=0;\r
+  Node      *next;\r
+\r
+  fprintf(stderr,"\n#%d ",++count);\r
+  d(p);\r
+\r
+  for (next=p; next != NULL && !isEndRule(next) ; ) {\r
+    fprintf(stderr,"#%d ",++count);\r
+    if (next->ntype == nJunction) {\r
+      next=dp1(next);\r
+    } else {\r
+      next=dn(next);\r
+    };\r
+  };\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+Node * dfn(Node * p,int target)\r
+#else\r
+Node * dfn(p,target)\r
+  Node *    p;\r
+  int       target;\r
+#endif\r
+{\r
+  Node      *result=NULL;\r
+  int       count=0;\r
+  Node      *next;\r
+\r
+  fprintf(stderr,"#%d ",++count);\r
+  d(p);\r
+\r
+  for (next=p; next != NULL && !isEndRule(next) ; ) {\r
+    fprintf(stderr,"#%d ",++count);\r
+    if (next->ntype == nJunction) {\r
+      next=dp1(next);\r
+    } else {\r
+      next=dn(next);\r
+    };\r
+    if (count == target) {\r
+      result=next;\r
+      break;\r
+    };\r
+  };\r
+  return result;\r
+}\r
+\r
+\r
+static int findnodeMatch;\r
+\r
+#ifdef __USE_PROTOS\r
+Junction *findnode1(Node *n)\r
+#else\r
+Junction *findnode1(n)\r
+  Node  *n;\r
+#endif\r
+{\r
+   Node         *next;\r
+   Junction     *j;\r
+   Junction     *match;\r
+\r
+   if (n == NULL) return NULL;\r
+   if (n->ntype == nJunction) {\r
+     j=(Junction *) n;\r
+     if (j->seq == findnodeMatch) return j;\r
+     if (j->jtype == EndRule) return NULL;\r
+     if (j->jtype != RuleBlk && j->jtype != EndBlk) {\r
+       if (j->p2 != NULL && !j->ignore) {\r
+          match=findnode1(j->p2);\r
+          if (match != NULL) return match;\r
+       };\r
+     };\r
+   };\r
+   next=MR_advance(n);\r
+   return findnode1(next);\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+Junction *findnode(int match)\r
+#else\r
+Junction *findnode(match)\r
+  int   match;\r
+#endif\r
+{\r
+  Junction  *j;\r
+  Junction  *result=NULL;\r
+\r
+  findnodeMatch=match;\r
+\r
+  for (j=SynDiag; j != NULL; j=(Junction *)j->p2) {\r
+    require (j->ntype == nJunction && j->jtype == RuleBlk,"Not a rule block");\r
+    result=findnode1( (Node *) j);\r
+    if (result != NULL) break;\r
+  };\r
+  if (result != NULL) {\r
+    d( (Node *) result);\r
+  };\r
+  return result;\r
+}\r
diff --git a/Tools/CodeTools/Source/Pccts/antlr/egman.c b/Tools/CodeTools/Source/Pccts/antlr/egman.c
new file mode 100644 (file)
index 0000000..c8a633f
--- /dev/null
@@ -0,0 +1,328 @@
+/*\r
+ * egman.c\r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
+ * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
+ * company may do whatever they wish with source code distributed with\r
+ * PCCTS or the code generated by PCCTS, including the incorporation of\r
+ * PCCTS, or its output, into commerical software.\r
+ *\r
+ * We encourage users to develop software with PCCTS.  However, we do ask\r
+ * that credit is given to us for developing PCCTS.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like PCCTS and have developed a nice tool with the\r
+ * output, please mention that you developed it using PCCTS.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * ANTLR 1.33MR10\r
+ * 2001\r
+ *\r
+ */\r
+\r
+#include <stdio.h>\r
+#include <stdlib.h>\r
+\r
+#include "set.h"\r
+#include "syn.h"\r
+#include "hash.h"\r
+#include "generic.h"\r
+#include "proto.h"\r
+\r
+static ExceptionGroup **egArray=NULL;   /* ExceptionGroup by BlkLevel */\r
+static LabelEntry     **leArray=NULL;   /* LabelEntry by BlkLevel     */\r
+static Junction       **altArray=NULL;  /* start of alternates        */\r
+static int              arraySize=0;\r
+static int              highWater=0;\r
+static ExceptionGroup *lastEG=NULL;     /* used in altFixup()         */\r
+static int             lastBlkLevel=0;  /* used in altFixup()         */\r
+\r
+#ifdef __USE_PROTOS\r
+static void arrayCheck(void);\r
+#else\r
+static void arrayCheck();\r
+#endif\r
+\r
+/* Called to add an exception group for an alternative EG */\r
+\r
+#ifdef __USE_PROTOS\r
+void egAdd(ExceptionGroup * eg)\r
+#else\r
+void egAdd(eg)\r
+ExceptionGroup *eg;\r
+#endif\r
+{\r
+  int               i;\r
+\r
+  ExceptionGroup    *nextEG;\r
+  ExceptionGroup    *innerEG;\r
+\r
+  LabelEntry        *nextLE;\r
+  LabelEntry        *innerLE;\r
+\r
+  Junction          *nextAlt;\r
+  Junction          *innerAlt;\r
+\r
+  lastEG=eg;\r
+  lastBlkLevel=BlkLevel;\r
+\r
+  arrayCheck();\r
+  eg->pendingLink=egArray[BlkLevel];\r
+  egArray[BlkLevel]=eg;\r
+\r
+  /* EG for alternates already have their altID filled in      */\r
+\r
+  for (i=BlkLevel+1; i<=highWater ; i++) {\r
+    for (innerEG=egArray[i]; innerEG != NULL ; innerEG=nextEG) {\r
+      nextEG=innerEG->pendingLink;\r
+      innerEG->pendingLink=NULL;\r
+      innerEG->outerEG=eg;\r
+    };\r
+    egArray[i]=NULL;\r
+  };\r
+\r
+  /*\r
+   *  for patching up the LabelEntry you might use an EG for the\r
+   *  current alternative - unlike patching up an alternative EG\r
+   *    i.e. start the loop at BlkLevel rather than (BlkLevel+1)\r
+   *  fill it in only if the EG and the LE are for the very\r
+   *    same alternative if they're at the same BlkLevel\r
+   *  it's easier to leave the LE on this list (filled in) rather than\r
+   *    trying to selectively remove it.  It will eventually be\r
+   *    removed anyway when the BlkLevel gets small enough.\r
+   */\r
+\r
+  for (i=BlkLevel; i<=highWater ; i++) {\r
+    for (innerLE=leArray[i]; innerLE != NULL ; innerLE=nextLE) {\r
+      nextLE=innerLE->pendingLink;\r
+      if (BlkLevel != i ||\r
+        innerLE->curAltNum == CurAltNum_array[BlkLevel]) {\r
+        if (innerLE->outerEG == NULL) {\r
+          innerLE->outerEG=eg;\r
+        };\r
+      };\r
+    };\r
+    if (BlkLevel != i) leArray[i]=NULL;\r
+  };\r
+\r
+/*\r
+ * For the start of alternatives it is necessary to make a\r
+ * distinction between the exception group for the current\r
+ * alternative and the "fallback" EG for the block which\r
+ * contains the alternative\r
+ *\r
+ * The fallback outerEG is used to handle the case where\r
+ * no alternative of a block matches.  In that case the\r
+ * signal is "NoViableAlt" (or "NoSemViableAlt" and the\r
+ * generator needs the EG of the block CONTAINING the\r
+ * current one.\r
+ *\r
+ *      rule: ( ( ( a\r
+ *                | b\r
+ *                )\r
+ *              | c\r
+ *              )\r
+ *            | d\r
+ *            );\r
+ */\r
+\r
+  for (i=BlkLevel; i <= highWater ; i++) {\r
+    for (innerAlt=altArray[i]; innerAlt != NULL ; innerAlt=nextAlt) {\r
+      nextAlt=innerAlt->pendingLink;\r
+\r
+      /*  first fill in the EG for the current alternative         */\r
+      /*  but leave it on the list in order to get the fallback EG */\r
+      /*  if the EG is at the same LEVEL as the alternative then   */\r
+      /*    fill it in only if in the very same alternative        */\r
+      /*                                                           */\r
+      /*        rule: ( a                                          */\r
+      /*              | b                                          */\r
+      /*              | c  exception ...                           */\r
+      /*              )                                            */\r
+      /*                                                           */\r
+      /*  if the EG is outside the alternative (e.g. BlkLevel < i) */\r
+      /*    then it doesn't matter about the alternative           */\r
+      /*                                                           */\r
+      /*        rule: ( a                                          */\r
+      /*              | b                                          */\r
+      /*              | c                                          */\r
+      /*              )   exception ...                            */\r
+      /*                                                           */\r
+\r
+#if 0\r
+      printf("BlkLevel=%d i=%d altnum=%d CurAltNum=%d altID=%s\n",\r
+        BlkLevel,i,innerAlt->curAltNum,CurAltNum_array[BlkLevel],eg->altID);\r
+#endif\r
+      if (BlkLevel != i ||\r
+          innerAlt->curAltNum == CurAltNum_array[BlkLevel]) {\r
+        if (innerAlt->exception_label == NULL) {\r
+          innerAlt->exception_label=eg->altID;\r
+        };\r
+      };\r
+\r
+      /*  ocurs at a later pass then for the exception_label       */\r
+      /*  if an outerEG has been found then fill in the outer EG   */\r
+      /*  remove if from the list when the BlkLevel gets smaller   */\r
+\r
+      if (BlkLevel != i) {\r
+        if (innerAlt->outerEG == NULL) {\r
+          innerAlt->outerEG=eg;\r
+        };\r
+      };\r
+    };\r
+    if (BlkLevel != i) altArray[i]=NULL;\r
+  };\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+void leAdd(LabelEntry * le)\r
+#else\r
+void leAdd(le)\r
+LabelEntry *le;\r
+#endif\r
+\r
+{\r
+  arrayCheck();\r
+  le->pendingLink=leArray[BlkLevel];\r
+  le->curAltNum=CurAltNum_array[BlkLevel];\r
+  leArray[BlkLevel]=le;\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+void altAdd(Junction *alt)\r
+#else\r
+void altAdd(alt)\r
+Junction *alt;\r
+#endif\r
+\r
+{\r
+  arrayCheck();\r
+#if 0\r
+  printf("BlkLevel=%d CurAltNum=%d\n",\r
+            BlkLevel,CurAltNum_array[BlkLevel]);\r
+#endif\r
+  alt->curAltNum=CurAltNum_array[BlkLevel];\r
+  alt->pendingLink=altArray[BlkLevel];\r
+  altArray[BlkLevel]=alt;\r
+}\r
+\r
+static void \r
+#ifdef __USE_PROTOS\r
+arrayCheck(void)\r
+#else\r
+arrayCheck()\r
+#endif\r
+{\r
+  ExceptionGroup    **egArrayNew;\r
+  LabelEntry        **leArrayNew;\r
+  Junction          **altArrayNew;\r
+  int               arraySizeNew;\r
+  int               i;\r
+\r
+  if (BlkLevel > highWater) highWater=BlkLevel;\r
+\r
+  if (BlkLevel >= arraySize) {\r
+    arraySizeNew=BlkLevel+5;   /* MR20 */\r
+    egArrayNew=(ExceptionGroup **)\r
+        calloc(arraySizeNew,sizeof(ExceptionGroup *));\r
+    leArrayNew=(LabelEntry **)\r
+        calloc(arraySizeNew,sizeof(LabelEntry *));\r
+    altArrayNew=(Junction **)\r
+        calloc(arraySizeNew,sizeof(Junction *));\r
+    for (i=0; i<arraySize ; i++) {\r
+      egArrayNew[i]=egArray[i];\r
+      leArrayNew[i]=leArray[i];\r
+      altArrayNew[i]=altArray[i];\r
+    };\r
+    arraySize=arraySizeNew;\r
+    if (egArray != NULL) free( (char *) egArray);\r
+    if (leArray != NULL) free( (char *) leArray);\r
+    if (altArray != NULL) free( (char *) altArray);\r
+    egArray=egArrayNew;\r
+    leArray=leArrayNew;\r
+    altArray=altArrayNew;\r
+  };\r
+}\r
+\r
+/* always call leFixup() BEFORE egFixup() */\r
+\r
+void \r
+#ifdef __USE_PROTOS\r
+egFixup(void) \r
+#else\r
+egFixup()\r
+#endif\r
+{\r
+  int               i;\r
+  ExceptionGroup    *nextEG;\r
+  ExceptionGroup    *innerEG;\r
+\r
+  for (i=1; i<=highWater ; i++) {\r
+    for (innerEG=egArray[i]; innerEG != NULL ; innerEG=nextEG) {\r
+      nextEG=innerEG->pendingLink;\r
+      innerEG->pendingLink=NULL;\r
+    };\r
+    egArray[i]=NULL;\r
+  };\r
+  lastEG=NULL;\r
+  lastBlkLevel=0;\r
+}\r
+\r
+/* always call leFixup() BEFORE egFixup() */\r
+\r
+#ifdef __USE_PROTOS\r
+void leFixup(void) \r
+#else\r
+void leFixup() \r
+#endif\r
+{\r
+\r
+  int               i;\r
+  LabelEntry        *nextLE;\r
+  LabelEntry        *innerLE;\r
+\r
+  for (i=BlkLevel; i<=highWater ; i++) {\r
+    for (innerLE=leArray[i]; innerLE != NULL ; innerLE=nextLE) {\r
+      nextLE=innerLE->pendingLink;\r
+      innerLE->pendingLink=NULL;\r
+    };\r
+    leArray[i]=NULL;\r
+  };\r
+}\r
+\r
+/* always call altFixup() BEFORE egFixup() */\r
+\r
+#ifdef __USE_PROTOS\r
+void altFixup(void)\r
+#else\r
+void altFixup() \r
+#endif\r
+{\r
+\r
+  int               i;\r
+  Junction          *nextAlt;\r
+  Junction          *innerAlt;\r
+\r
+  for (i=BlkLevel; i<=highWater ; i++) {\r
+    for (innerAlt=altArray[i]; innerAlt != NULL ; innerAlt=nextAlt) {\r
+\r
+      /*  if an outerEG has been found then fill in the outer EG   */\r
+\r
+      if (lastBlkLevel <= i) {\r
+        if (innerAlt->outerEG == NULL) {\r
+          innerAlt->outerEG=lastEG;\r
+        };\r
+      };\r
+      nextAlt=innerAlt->pendingLink;\r
+      innerAlt->pendingLink=NULL;\r
+    };\r
+    altArray[i]=NULL;\r
+  };\r
+}\r
+\r
diff --git a/Tools/CodeTools/Source/Pccts/antlr/err.c b/Tools/CodeTools/Source/Pccts/antlr/err.c
new file mode 100644 (file)
index 0000000..ca23939
--- /dev/null
@@ -0,0 +1,538 @@
+/*\r
+ * A n t l r  S e t s / E r r o r  F i l e  H e a d e r\r
+ *\r
+ * Generated from: antlr.g\r
+ *\r
+ * Terence Parr, Russell Quong, Will Cohen, and Hank Dietz: 1989-2001\r
+ * Parr Research Corporation\r
+ * with Purdue University Electrical Engineering\r
+ * With AHPCRC, University of Minnesota\r
+ * ANTLR Version 1.33MR33\r
+ */\r
+\r
+#define ANTLR_VERSION  13333\r
+#include "pcctscfg.h"\r
+#include "pccts_stdio.h"\r
+\r
+#include "pcctscfg.h"\r
+#include "set.h"\r
+#include <ctype.h>\r
+#include "syn.h"\r
+#include "hash.h"\r
+#include "generic.h"\r
+#define zzcr_attr(attr,tok,t)\r
+#define zzSET_SIZE 20\r
+#include "antlr.h"\r
+#include "tokens.h"\r
+#include "dlgdef.h"\r
+#include "err.h"\r
+\r
+ANTLRChar *zztokens[157]={\r
+       /* 00 */        "Invalid",\r
+       /* 01 */        "Eof",\r
+       /* 02 */        "QuotedTerm",\r
+       /* 03 */        "\\n|\\r|\\r\\n",\r
+       /* 04 */        "\\(\\n|\\r|\\r\\n)",\r
+       /* 05 */        "\\~[]",\r
+       /* 06 */        "~[\\n\\r\"\\]+",\r
+       /* 07 */        "\"",\r
+       /* 08 */        "\\n|\\r|\\r\\n",\r
+       /* 09 */        "\\(\\n|\\r|\\r\\n)",\r
+       /* 10 */        "\\~[]",\r
+       /* 11 */        "~[\\n\\r\"\\]+",\r
+       /* 12 */        "'",\r
+       /* 13 */        "\\n|\\r|\\r\\n",\r
+       /* 14 */        "\\~[]",\r
+       /* 15 */        "~[\\n\\r'\\]+",\r
+       /* 16 */        "\\*/",\r
+       /* 17 */        "\\*",\r
+       /* 18 */        "\\n|\\r|\\r\\n",\r
+       /* 19 */        "~[\\n\\r\\*]+",\r
+       /* 20 */        "\\*/",\r
+       /* 21 */        "\\*",\r
+       /* 22 */        "\\n|\\r|\\r\\n",\r
+       /* 23 */        "~[\\n\\r\\*]+",\r
+       /* 24 */        "\\n|\\r|\\r\\n",\r
+       /* 25 */        "~[\\n\\r]+",\r
+       /* 26 */        "\\n|\\r|\\r\\n",\r
+       /* 27 */        "~[\\n\\r]+",\r
+       /* 28 */        "\\n|\\r|\\r\\n",\r
+       /* 29 */        "~[\\n\\r]+",\r
+       /* 30 */        "\\*/",\r
+       /* 31 */        "\\*",\r
+       /* 32 */        "\\n|\\r|\\r\\n",\r
+       /* 33 */        "~[\\n\\r\\*]+",\r
+       /* 34 */        "Action",\r
+       /* 35 */        "Pred",\r
+       /* 36 */        "PassAction",\r
+       /* 37 */        "consumeUntil\\( [\\ \\t]* \\{~[\\}]+\\} [\\ \\t]* \\)",\r
+       /* 38 */        "consumeUntil\\( ~[\\)]+ \\)",\r
+       /* 39 */        "\\n|\\r|\\r\\n",\r
+       /* 40 */        "\\>",\r
+       /* 41 */        "$",\r
+       /* 42 */        "$$",\r
+       /* 43 */        "$\\[\\]",\r
+       /* 44 */        "$\\[",\r
+       /* 45 */        "$[0-9]+",\r
+       /* 46 */        "$[0-9]+.",\r
+       /* 47 */        "$[0-9]+.[0-9]+",\r
+       /* 48 */        "$[_a-zA-Z][_a-zA-Z0-9]*",\r
+       /* 49 */        "#0",\r
+       /* 50 */        "#\\[\\]",\r
+       /* 51 */        "#\\(\\)",\r
+       /* 52 */        "#[0-9]+",\r
+       /* 53 */        "#line[\\ \\t]* [0-9]+ {[\\ \\t]* \"~[\"]+\" ([\\ \\t]* [0-9]*)* } (\\n|\\r|\\r\\n)",\r
+       /* 54 */        "#line ~[\\n\\r]* (\\n|\\r|\\r\\n)",\r
+       /* 55 */        "#[_a-zA-Z][_a-zA-Z0-9]*",\r
+       /* 56 */        "#\\[",\r
+       /* 57 */        "#\\(",\r
+       /* 58 */        "#",\r
+       /* 59 */        "\\)",\r
+       /* 60 */        "\\[",\r
+       /* 61 */        "\\(",\r
+       /* 62 */        "\\\\]",\r
+       /* 63 */        "\\\\)",\r
+       /* 64 */        "\\>",\r
+       /* 65 */        "'",\r
+       /* 66 */        "\"",\r
+       /* 67 */        "\\$",\r
+       /* 68 */        "\\#",\r
+       /* 69 */        "\\(\\n|\\r|\\r\\n)",\r
+       /* 70 */        "\\~[\\]\\)>$#]",\r
+       /* 71 */        "/",\r
+       /* 72 */        "/\\*",\r
+       /* 73 */        "\\*/",\r
+       /* 74 */        "//",\r
+       /* 75 */        "~[\\n\\r\\)\\(\\$#\\>\\]\\[\"'/]+",\r
+       /* 76 */        "[\\t\\ ]+",\r
+       /* 77 */        "\\n|\\r|\\r\\n",\r
+       /* 78 */        "\\[",\r
+       /* 79 */        "\\<\\<",\r
+       /* 80 */        "\"",\r
+       /* 81 */        "/\\*",\r
+       /* 82 */        "\\*/",\r
+       /* 83 */        "//",\r
+       /* 84 */        "#line[\\ \\t]* [0-9]+ {[\\ \\t]* \"~[\"]+\" ([\\ \\t]* [0-9]*)* } (\\n|\\r|\\r\\n)",\r
+       /* 85 */        "#line ~[\\n\\r]* (\\n|\\r|\\r\\n)",\r
+       /* 86 */        "\\>\\>",\r
+       /* 87 */        "WildCard",\r
+       /* 88 */        "\\@",\r
+       /* 89 */        "LABEL",\r
+       /* 90 */        "grammar-element",\r
+       /* 91 */        "meta-symbol",\r
+       /* 92 */        "Pragma",\r
+       /* 93 */        "FirstSetSymbol",\r
+       /* 94 */        "{\\}#header",\r
+       /* 95 */        "{\\}#first",\r
+       /* 96 */        "{\\}#parser",\r
+       /* 97 */        "{\\}#tokdefs",\r
+       /* 98 */        "\\}",\r
+       /* 99 */        "class",\r
+       /* 100 */       "NonTerminal",\r
+       /* 101 */       "TokenTerm",\r
+       /* 102 */       "\\{",\r
+       /* 103 */       "!",\r
+       /* 104 */       "\\<",\r
+       /* 105 */       "\\>",\r
+       /* 106 */       ":",\r
+       /* 107 */       ";",\r
+       /* 108 */       "{\\}#lexaction",\r
+       /* 109 */       "{\\}#lexmember",\r
+       /* 110 */       "{\\}#lexprefix",\r
+       /* 111 */       "{\\}#pred",\r
+       /* 112 */       "\\|\\|",\r
+       /* 113 */       "&&",\r
+       /* 114 */       "\\(",\r
+       /* 115 */       "\\)",\r
+       /* 116 */       "{\\}#lexclass",\r
+       /* 117 */       "{\\}#errclass",\r
+       /* 118 */       "{\\}#tokclass",\r
+       /* 119 */       "..",\r
+       /* 120 */       "{\\}#token",\r
+       /* 121 */       "=",\r
+       /* 122 */       "[0-9]+",\r
+       /* 123 */       "\\|",\r
+       /* 124 */       "\\~",\r
+       /* 125 */       "^",\r
+       /* 126 */       "approx",\r
+       /* 127 */       "LL\\(1\\)",\r
+       /* 128 */       "LL\\(2\\)",\r
+       /* 129 */       "\\*",\r
+       /* 130 */       "\\+",\r
+       /* 131 */       "?",\r
+       /* 132 */       "=>",\r
+       /* 133 */       "exception",\r
+       /* 134 */       "default",\r
+       /* 135 */       "catch",\r
+       /* 136 */       "{\\}#[A-Za-z0-9_]*",\r
+       /* 137 */       "[\\t\\ ]+",\r
+       /* 138 */       "\\n|\\r|\\r\\n",\r
+       /* 139 */       "//",\r
+       /* 140 */       "/\\*",\r
+       /* 141 */       "#ifdef",\r
+       /* 142 */       "#if",\r
+       /* 143 */       "#ifndef",\r
+       /* 144 */       "#else",\r
+       /* 145 */       "#endif",\r
+       /* 146 */       "#undef",\r
+       /* 147 */       "#import",\r
+       /* 148 */       "ID",\r
+       /* 149 */       "#define",\r
+       /* 150 */       "INT",\r
+       /* 151 */       "enum",\r
+       /* 152 */       "\\{",\r
+       /* 153 */       "=",\r
+       /* 154 */       ",",\r
+       /* 155 */       "\\}",\r
+       /* 156 */       ";"\r
+};\r
+SetWordType zzerr1[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,\r
+       0x30,0x0,0x0,0x0, 0x0,0x0,0x0,0x0};\r
+SetWordType zzerr2[20] = {0xfc,0xff,0xff,0xff, 0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xf3,\r
+       0xbf,0xff,0xff,0xff, 0xff,0xff,0xff,0x1f};\r
+SetWordType zzerr3[20] = {0xfc,0xff,0xff,0xff, 0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xfb,\r
+       0x3b,0xf7,0xf7,0xc7, 0xff,0xff,0xff,0x1f};\r
+SetWordType zzerr4[20] = {0x4,0x0,0x0,0x0, 0x10,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,\r
+       0x80,0x7,0x0,0x0, 0x0,0x0,0x0,0x0};\r
+SetWordType setwd1[157] = {0x0,0x50,0xa0,0x20,0x20,0x20,0x20,\r
+       0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,\r
+       0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,\r
+       0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,\r
+       0x20,0x20,0x20,0x6a,0x20,0xa0,0x20,0x20,\r
+       0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,\r
+       0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,\r
+       0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,\r
+       0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,\r
+       0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,\r
+       0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,\r
+       0x20,0x20,0x20,0x0,0x0,0x20,0x20,0x21,\r
+       0x21,0x21,0x21,0x6e,0x6e,0x64,0x20,0x0,\r
+       0x20,0xa0,0xa0,0xa0,0x20,0x6a,0x6a,0x6a,\r
+       0x6e,0x20,0x20,0x20,0x20,0x66,0x6e,0x6e,\r
+       0x20,0x66,0x20,0x20,0x20,0x20,0x20,0x20,\r
+       0x20,0x20,0x20,0x20,0x20,0x20,0x62,0x20,\r
+       0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,\r
+       0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,\r
+       0x20,0x20,0x20,0x20,0x20,0x20};\r
+SetWordType zzerr5[20] = {0x0,0x0,0x0,0x0, 0x10,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,\r
+       0x0,0x1,0x0,0x0, 0x0,0x0,0x0,0x0};\r
+SetWordType zzerr6[20] = {0x4,0x0,0x0,0x0, 0x10,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,\r
+       0x0,0x7,0x0,0x0, 0x0,0x0,0x0,0x0};\r
+SetWordType zzerr7[20] = {0x4,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,\r
+       0x0,0x6,0x0,0x0, 0x0,0x0,0x0,0x0};\r
+SetWordType zzerr8[20] = {0x4,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,\r
+       0x0,0x4,0x0,0x0, 0x0,0x0,0x0,0x0};\r
+SetWordType zzerr9[20] = {0x2,0x0,0x0,0x0, 0x4,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,\r
+       0x1c,0xf0,0x70,0x1, 0x20,0x0,0x0,0x0};\r
+SetWordType setwd2[157] = {0x0,0xf8,0x6,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0xf8,0x0,0x1,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0xf8,0xf8,0xf8,0x0,0x0,\r
+       0x0,0x1,0x2,0x6,0x0,0xf8,0xf8,0xf8,\r
+       0xf8,0x0,0x0,0x0,0x0,0xf8,0xf8,0xf8,\r
+       0x0,0xf8,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0xe8,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0};\r
+SetWordType zzerr10[20] = {0x2,0x0,0x0,0x0, 0x4,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,\r
+       0xbc,0xf8,0x74,0x1, 0x20,0x0,0x0,0x0};\r
+SetWordType zzerr11[20] = {0x0,0x0,0x0,0x0, 0x8,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,\r
+       0xa0,0x0,0x4,0x0, 0x0,0x0,0x0,0x0};\r
+SetWordType zzerr12[20] = {0x2,0x0,0x0,0x0, 0x4,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,\r
+       0x1c,0xf8,0x70,0x1, 0x20,0x0,0x0,0x0};\r
+SetWordType zzerr13[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,\r
+       0xa0,0x0,0x4,0x0, 0x0,0x0,0x0,0x0};\r
+SetWordType setwd3[157] = {0x0,0xfa,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0xfa,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0xfa,0xfa,0xfa,0x5,0x0,\r
+       0x5,0x0,0x0,0x0,0xe2,0xfa,0xfa,0xfa,\r
+       0xfa,0xc0,0x80,0x5,0xe0,0xfa,0xfa,0xfa,\r
+       0x0,0xfa,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0xfa,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0};\r
+SetWordType zzerr14[20] = {0x4,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,\r
+       0x20,0x0,0x0,0x0, 0x0,0x0,0x0,0x0};\r
+SetWordType zzerr15[20] = {0x4,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,\r
+       0x30,0x0,0x0,0x0, 0x0,0x0,0x0,0x0};\r
+SetWordType zzerr16[20] = {0x4,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,\r
+       0x30,0x0,0x0,0x0, 0x0,0x0,0x0,0x0};\r
+SetWordType zzerr17[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,\r
+       0x40,0x0,0x4,0x0, 0x0,0x0,0x0,0x0};\r
+SetWordType zzerr18[20] = {0x4,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,\r
+       0x24,0x0,0x80,0x0, 0x0,0x0,0x0,0x0};\r
+SetWordType zzerr19[20] = {0x4,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,\r
+       0x20,0x0,0x0,0x0, 0x0,0x0,0x0,0x0};\r
+SetWordType zzerr20[20] = {0x6,0x0,0x0,0x0, 0x4,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,\r
+       0x1c,0xf8,0x74,0x3, 0x20,0x0,0x0,0x0};\r
+SetWordType zzerr21[20] = {0x6,0x0,0x0,0x0, 0x4,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,\r
+       0x1c,0xf8,0x70,0x3, 0x20,0x0,0x0,0x0};\r
+SetWordType setwd4[157] = {0x0,0xe5,0xda,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0xe5,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0xed,0xe5,0xe7,0x1a,0x0,\r
+       0x0,0x0,0x0,0x0,0xc0,0xe5,0xe5,0xe5,\r
+       0xe5,0x0,0x0,0x0,0x0,0xe5,0xe5,0xe5,\r
+       0x0,0xe5,0x40,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0xe5,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0};\r
+SetWordType zzerr22[20] = {0x6,0x0,0x0,0x0, 0x4,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,\r
+       0x3c,0xf8,0x70,0x1, 0x20,0x0,0x0,0x0};\r
+SetWordType zzerr23[20] = {0x6,0x0,0x0,0x0, 0x4,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,\r
+       0x1c,0xf8,0x70,0x1, 0x20,0x0,0x0,0x0};\r
+SetWordType zzerr24[20] = {0x2,0x0,0x0,0x0, 0x4,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,\r
+       0x1c,0xf8,0x70,0x1, 0x20,0x0,0x0,0x0};\r
+SetWordType zzerr25[20] = {0x2,0x0,0x0,0x0, 0x4,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,\r
+       0x1c,0xf8,0x70,0x1, 0x20,0x0,0x0,0x0};\r
+SetWordType zzerr26[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x5,\r
+       0x4,0x8,0x8,0x18, 0x20,0x0,0x0,0x0};\r
+SetWordType setwd5[157] = {0x0,0x1f,0xc1,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0xdf,0xc0,0xc0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0xc0,0x0,0xc0,0x0,0x0,0xc0,0xc0,0x0,\r
+       0x0,0x0,0x0,0x7f,0x1f,0xdf,0xc0,0xc0,\r
+       0x0,0x0,0xc0,0x0,0x67,0x1f,0x1f,0x1f,\r
+       0x1f,0x0,0x0,0xc0,0x60,0x1f,0x1f,0x1f,\r
+       0x0,0x1f,0x0,0x0,0x40,0xc0,0x0,0x0,\r
+       0x0,0x0,0xc0,0xc0,0x0,0x0,0x5f,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0};\r
+SetWordType zzerr27[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x4,\r
+       0x0,0x0,0x0,0x10, 0x0,0x0,0x0,0x0};\r
+SetWordType zzerr28[20] = {0x4,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x80,0x2,\r
+       0x30,0x0,0x0,0x0, 0x0,0x0,0x0,0x0};\r
+SetWordType zzerr29[20] = {0x4,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,\r
+       0x20,0x0,0x0,0x0, 0x0,0x0,0x0,0x0};\r
+SetWordType zzerr30[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0xd,\r
+       0x0,0x0,0x80,0x0, 0x20,0x0,0x0,0x0};\r
+SetWordType zzerr31[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0xd,\r
+       0x0,0x0,0x0,0x0, 0x20,0x0,0x0,0x0};\r
+SetWordType zzerr32[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x5,\r
+       0x4,0x8,0x8,0x18, 0x20,0x0,0x0,0x0};\r
+SetWordType zzerr33[20] = {0x4,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,\r
+       0x20,0x0,0x0,0x0, 0x0,0x0,0x0,0x0};\r
+SetWordType setwd6[157] = {0x0,0x0,0xfd,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0xe1,0xe1,0xe1,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0xfd,0x60,0xe9,0x0,0x0,0xe1,0xe1,0x0,\r
+       0x0,0x0,0x0,0xe2,0x0,0xfd,0xfd,0xe1,\r
+       0x20,0x0,0xe1,0x0,0xe2,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0xe1,0xe2,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0xe2,0xe0,0x20,0x0,\r
+       0x0,0x0,0xe1,0xe1,0x0,0x0,0xe2,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0};\r
+SetWordType zzerr34[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0xd,\r
+       0x0,0x0,0x80,0x0, 0x20,0x0,0x0,0x0};\r
+SetWordType zzerr35[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0xd,\r
+       0x0,0x0,0x0,0x0, 0x20,0x0,0x0,0x0};\r
+SetWordType zzerr36[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x5,\r
+       0x4,0x8,0x8,0x18, 0x20,0x0,0x0,0x0};\r
+SetWordType zzerr37[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0xc,\r
+       0x0,0x0,0x0,0x0, 0x20,0x0,0x0,0x0};\r
+SetWordType zzerr38[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x4,\r
+       0x84,0x9,0x8,0x18, 0x20,0x0,0x0,0x0};\r
+SetWordType zzerr39[20] = {0x0,0x0,0x0,0x0, 0x10,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,\r
+       0x0,0x1,0x0,0x0, 0x0,0x0,0x0,0x0};\r
+SetWordType zzerr40[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x4,\r
+       0x4,0x9,0x8,0x18, 0x20,0x0,0x0,0x0};\r
+SetWordType zzerr41[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x4,\r
+       0x4,0x8,0x8,0x18, 0x20,0x0,0x0,0x0};\r
+SetWordType zzerr42[20] = {0x4,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x80,0x0,\r
+       0x30,0x0,0x0,0x0, 0x0,0x0,0x0,0x0};\r
+SetWordType setwd7[157] = {0x0,0x0,0xdf,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0xdf,0xdf,0xff,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0xdf,0x3,0xdf,0x0,0x0,0xdf,0xdf,0x0,\r
+       0x0,0x0,0x0,0xdf,0x0,0xdf,0xdf,0xdf,\r
+       0x1,0x30,0xdf,0x0,0xdf,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0xdf,0xdf,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0xdf,0xdf,0x1,0x0,\r
+       0x0,0x0,0xdf,0xdf,0x0,0x0,0xdf,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0};\r
+SetWordType zzerr43[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x4,\r
+       0x4,0x8,0x8,0x18, 0x20,0x0,0x0,0x0};\r
+SetWordType zzerr44[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0xc0, 0x1,0x0,0x0,0x0};\r
+SetWordType zzerr45[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x30,\r
+       0x40,0x0,0x4,0x0, 0x0,0x0,0x0,0x0};\r
+SetWordType zzerr46[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,\r
+       0x30,0x0,0x0,0x0, 0x0,0x0,0x0,0x0};\r
+SetWordType zzerr47[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x20,\r
+       0x40,0x0,0x4,0x0, 0x0,0x0,0x0,0x0};\r
+SetWordType zzerr48[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x2,0x0, 0x10,0x0,0x0,0x0};\r
+SetWordType zzerr49[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x4,\r
+       0x4,0x8,0x8,0x18, 0x20,0x0,0x0,0x0};\r
+SetWordType zzerr50[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x4,\r
+       0x4,0x8,0xa,0x18, 0x30,0x0,0x0,0x0};\r
+SetWordType zzerr51[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x4,\r
+       0x4,0x8,0x8,0x18, 0x28,0x0,0x0,0x0};\r
+SetWordType zzerr52[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,\r
+       0x40,0x0,0x4,0x0, 0x0,0x0,0x0,0x0};\r
+SetWordType zzerr53[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x4,\r
+       0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0};\r
+SetWordType setwd8[157] = {0x0,0x0,0xe1,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0xe1,0xe1,0xe1,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0xe1,0x0,0xe1,0x0,0x0,0xe3,0xe7,0x0,\r
+       0x0,0x0,0x0,0xe1,0x0,0xe1,0xe1,0xef,\r
+       0x0,0x0,0xe1,0x0,0xe1,0x0,0x0,0x0,\r
+       0x0,0x0,0x10,0xef,0xe1,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0xe1,0xe1,0x0,0x0,\r
+       0x0,0x0,0xe1,0xe1,0x0,0x10,0xe1,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0};\r
+SetWordType zzerr54[20] = {0x2,0x0,0x0,0x0, 0x14,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,\r
+       0x1c,0xf8,0x78,0x9, 0xe0,0x0,0x0,0x0};\r
+SetWordType zzerr55[20] = {0x2,0x0,0x0,0x0, 0x4,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,\r
+       0x1c,0xf8,0x78,0x9, 0x60,0x0,0x0,0x0};\r
+SetWordType zzerr56[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,\r
+       0x30,0x0,0x0,0x0, 0x0,0x0,0x0,0x0};\r
+SetWordType zzerr57[20] = {0x2,0x0,0x0,0x0, 0x4,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,\r
+       0x1c,0xf8,0x78,0x9, 0xe0,0x0,0x0,0x0};\r
+SetWordType setwd9[157] = {0x0,0x7c,0x1,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x7f,0x1,0x1,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x1,0x0,0x1,0x0,0x0,0x1,0x1,0x0,\r
+       0x0,0x0,0x0,0x7f,0x7e,0x7f,0x1,0x1,\r
+       0x0,0x0,0x1,0x0,0x7d,0x7e,0x7e,0x7e,\r
+       0x7e,0x0,0x0,0x1,0x7d,0x7e,0x7e,0x7e,\r
+       0x0,0x7e,0x0,0x0,0x7d,0x1,0x0,0x0,\r
+       0x0,0x0,0x1,0x1,0x0,0x0,0x7f,0x64,\r
+       0x64,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x80,0x0,0x0,0x0,0x0,0x0,0x80,0x0,\r
+       0x80,0x0,0x0,0x0,0x0,0x0};\r
+SetWordType zzerr58[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0, 0x0,0x0,0xa0,0x0};\r
+SetWordType zzerr59[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0, 0x0,0x80,0xa0,0x0};\r
+SetWordType zzerr60[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0, 0x0,0x0,0xa0,0x0};\r
+SetWordType zzerr61[20] = {0x2,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0, 0x0,0x80,0xa0,0x0};\r
+SetWordType zzerr62[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0xe};\r
+SetWordType zzerr63[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0xe};\r
+SetWordType zzerr64[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0xe};\r
+SetWordType zzerr65[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0, 0x0,0x0,0x10,0xc};\r
+SetWordType setwd10[157] = {0x0,0xc,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x3,0x0,\r
+       0x3,0x0,0x0,0xf0,0xf0,0x0};\r
+SetWordType setwd11[157] = {0x0,0x1,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
+       0x1,0x0,0x0,0x0,0x0,0x0};\r
diff --git a/Tools/CodeTools/Source/Pccts/antlr/fcache.c b/Tools/CodeTools/Source/Pccts/antlr/fcache.c
new file mode 100644 (file)
index 0000000..ff7dcdf
--- /dev/null
@@ -0,0 +1,123 @@
+/*\r
+ * fcache.c\r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
+ * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
+ * company may do whatever they wish with source code distributed with\r
+ * PCCTS or the code generated by PCCTS, including the incorporation of\r
+ * PCCTS, or its output, into commerical software.\r
+ *\r
+ * We encourage users to develop software with PCCTS.  However, we do ask\r
+ * that credit is given to us for developing PCCTS.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like PCCTS and have developed a nice tool with the\r
+ * output, please mention that you developed it using PCCTS.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * ANTLR 1.33MR10\r
+ *\r
+ */\r
+\r
+#include <stdio.h>\r
+#include <ctype.h>\r
+\r
+#include "pcctscfg.h"\r
+\r
+#include "set.h"\r
+#include "syn.h"\r
+#include "hash.h"\r
+#include "generic.h"\r
+\r
+#ifdef __USE_PROTOS\r
+CacheEntry *dumpFcache1(char *prev)\r
+#else\r
+CacheEntry *dumpFcache1(prev)\r
+  char  *prev;\r
+#endif\r
+{\r
+    Entry   **table=Fcache;\r
+\r
+    int     low=0;\r
+    int     hi=0;\r
+\r
+    CacheEntry  *least=NULL;\r
+\r
+       Entry   **p;\r
+\r
+       for (p=table; p<&(table[HashTableSize]); p++) {\r
+\r
+               CacheEntry *q =(CacheEntry *) *p;\r
+               \r
+               if ( q != NULL && low==0 ) low = p-table;\r
+               while ( q != NULL ) {\r
+            if (strcmp(q->str,prev) > 0) {\r
+              if (least == NULL) {\r
+                least=q;\r
+              } else {\r
+                if (strcmp(q->str,least->str) < 0) {\r
+                  least=q;\r
+                };\r
+              };\r
+            };\r
+                       q = q->next;\r
+               };\r
+\r
+               if ( *p != NULL ) hi = p-table;\r
+       }\r
+    return least;\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+void reportFcache(CacheEntry *q)\r
+#else\r
+void reportFcache(q)\r
+  CacheEntry    *q;\r
+#endif\r
+{\r
+    char        *qstr;\r
+\r
+    fprintf(stdout,"\nrule ");\r
+    for (qstr=q->str; *qstr != '*' ; qstr++) {\r
+      fprintf(stdout,"%c",*qstr);\r
+    };\r
+\r
+    qstr++;\r
+    if (*qstr == 'i') fprintf(stdout," First[");\r
+    if (*qstr == 'o') fprintf(stdout," Follow[");\r
+    qstr++;\r
+    fprintf(stdout,"%s]",qstr);\r
+    if (q->incomplete) fprintf(stdout," *** incomplete ***");\r
+    fprintf(stdout,"\n");\r
+    MR_dumpTokenSet(stdout,1,q->fset);\r
+}\r
+\r
+void \r
+#ifdef __USE_PROTOS\r
+DumpFcache(void) \r
+#else\r
+DumpFcache() \r
+#endif\r
+{\r
+\r
+    char        *prev="";\r
+    int          n=0;\r
+    CacheEntry  *next;\r
+\r
+    fprintf(stdout,"\n\nDump of First/Follow Cache\n");\r
+\r
+    for(;;) {\r
+      next=dumpFcache1(prev);\r
+      if (next == NULL) break;\r
+      reportFcache(next);\r
+      ++n;\r
+      prev=next->str;\r
+    };\r
+    fprintf(stdout,"\nEnd dump of First/Follow Cache\n");\r
+}\r
diff --git a/Tools/CodeTools/Source/Pccts/antlr/fset.c b/Tools/CodeTools/Source/Pccts/antlr/fset.c
new file mode 100644 (file)
index 0000000..e1a76ec
--- /dev/null
@@ -0,0 +1,1555 @@
+/*\r
+ * fset.c\r
+ *\r
+ * Compute FIRST and FOLLOW sets.\r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
+ * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
+ * company may do whatever they wish with source code distributed with\r
+ * PCCTS or the code generated by PCCTS, including the incorporation of\r
+ * PCCTS, or its output, into commerical software.\r
+ *\r
+ * We encourage users to develop software with PCCTS.  However, we do ask\r
+ * that credit is given to us for developing PCCTS.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like PCCTS and have developed a nice tool with the\r
+ * output, please mention that you developed it using PCCTS.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * ANTLR 1.33\r
+ * Terence Parr\r
+ * Parr Research Corporation\r
+ * with Purdue University and AHPCRC, University of Minnesota\r
+ * 1989-2001\r
+ */\r
+\r
+#include <stdio.h>\r
+#include <stdlib.h>\r
+\r
+#include "pcctscfg.h"\r
+\r
+#include "set.h"\r
+#include "syn.h"\r
+#include "hash.h"\r
+#include "generic.h"\r
+#include "dlgdef.h"\r
+#include "limits.h"\r
+\r
+#ifdef __USE_PROTOS\r
+static void ensure_predicates_cover_ambiguous_lookahead_sequences\r
+                                    (Junction *, Junction *, char *, Tree *);\r
+#else\r
+static void ensure_predicates_cover_ambiguous_lookahead_sequences();\r
+#endif\r
+\r
+/*\r
+ * What tokens are k tokens away from junction q?\r
+ *\r
+ * Follow both p1 and p2 paths (unless RuleBlk) to collect the tokens k away from this\r
+ * node.\r
+ * We lock the junction according to k--the lookahead.  If we have been at this\r
+ * junction before looking for the same, k, number of lookahead tokens, we will\r
+ * do it again and again...until we blow up the stack.  Locks are only used on aLoopBlk,\r
+ * RuleBlk, aPlusBlk and EndRule junctions to remove/detect infinite recursion from\r
+ * FIRST and FOLLOW calcs.\r
+ *\r
+ * If p->jtype == EndRule we are going to attempt a FOLLOW.  (FOLLOWs are really defined\r
+ * in terms of FIRST's, however).  To proceed with the FOLLOW, p->halt cannot be\r
+ * set.  p->halt is set to indicate that a reference to the current rule is in progress\r
+ * and the FOLLOW is not desirable.\r
+ *\r
+ * If we attempt a FOLLOW and find that there is no FOLLOW or REACHing beyond the EndRule\r
+ * junction yields an empty set, replace the empty set with EOF.  No FOLLOW means that\r
+ * only EOF can follow the current rule.  This normally occurs only on the start symbol\r
+ * since all other rules are referenced by another rule somewhere.\r
+ *\r
+ * Normally, both p1 and p2 are followed.  However, checking p2 on a RuleBlk node is\r
+ * the same as checking the next rule which is clearly incorrect.\r
+ *\r
+ * Cycles in the FOLLOW sense are possible.  e.g. Fo(c) requires Fo(b) which requires\r
+ * Fo(c).  Both Fo(b) and Fo(c) are defined to be Fo(b) union Fo(c).  Let's say\r
+ * Fo(c) is attempted first.  It finds all of the FOLLOW symbols and then attempts\r
+ * to do Fo(b) which finds of its FOLLOW symbols.  So, we have:\r
+ *\r
+ *                  Fo(c)\r
+ *                 /     \\r
+ *              a set    Fo(b)\r
+ *                      /     \\r
+ *                   a set    Fo(c) .....Hmmmm..... Infinite recursion!\r
+ *\r
+ * The 2nd Fo(c) is not attempted and Fo(b) is left deficient, but Fo(c) is now\r
+ * correctly Fo(c) union Fo(b).  We wish to pick up where we left off, so the fact\r
+ * that Fo(b) terminated early means that we lack Fo(c) in the Fo(b) set already\r
+ * laying around.  SOOOOoooo, we track FOLLOW cycles.  All FOLLOW computations are\r
+ * cached in a hash table.  After the sequence of FOLLOWs finish, we reconcile all\r
+ * cycles --> correct all Fo(rule) sets in the cache.\r
+ *\r
+ * Confused? Good! Read my MS thesis [Purdue Technical Report TR90-30].\r
+ * TJP 8/93 -- can now read PhD thesis from Purdue.\r
+ *\r
+ * Also, FIRST sets are cached in the hash table.  Keys are (rulename,Fi/Fo,k).\r
+ * Only FIRST sets, for which the FOLLOW is not included, are stored.\r
+ *\r
+ * SPECIAL CASE of (...)+ blocks:\r
+ * I added an optional alt so that the alts could see what\r
+ * was behind the (...)+ block--thus using enough lookahead\r
+ * to branch out rather than just enough to distinguish\r
+ * between alts in the (...)+.  However, when the FIRST("(...)+") is\r
+ * is needed, must not use this last "optional" alt.  This routine\r
+ * turns off this path by setting a new 'ignore' flag for\r
+ * the alt and then resetting it afterwards.\r
+ */\r
+\r
+set\r
+#ifdef __USE_PROTOS\r
+rJunc( Junction *p, int k, set *rk )\r
+#else\r
+rJunc( p, k, rk )\r
+Junction *p;\r
+int k;\r
+set *rk;\r
+#endif\r
+{\r
+       set     a, b;\r
+\r
+       require(p!=NULL,                                "rJunc: NULL node");\r
+       require(p->ntype==nJunction,    "rJunc: not junction");\r
+\r
+#ifdef DBG_LL1\r
+       if ( p->jtype == RuleBlk ) fprintf(stderr, "FIRST(%s,%d) \n",((Junction *)p)->rname,k);\r
+       else fprintf(stderr, "rJunc: %s in rule %s\n",\r
+                       decodeJType[p->jtype], ((Junction *)p)->rname);\r
+#endif\r
+       /* if this is one of the added optional alts for (...)+ then return */\r
+\r
+    /* no need to pop backtrace - hasn't been pushed */\r
+\r
+       if ( p->ignore ) return empty;\r
+\r
+    if (MR_MaintainBackTrace) MR_pointerStackPush(&MR_BackTraceStack,p);\r
+\r
+/* MR14 */    if (AlphaBetaTrace && p->alpha_beta_guess_end) {\r
+/* MR14 */         warnFL(\r
+/* MR14 */           "not possible to compute follow set for alpha in an \"(alpha)? beta\" block.  ",\r
+/* MR14 */                 FileStr[p->file],p->line);\r
+/* MR14 */         MR_alphaBetaTraceReport();\r
+/* MR14 */    };\r
+\r
+/* MR14 */    if (p->alpha_beta_guess_end) {\r
+/* MR14 */      if (MR_MaintainBackTrace) MR_pointerStackPop(&MR_BackTraceStack);\r
+/* MR14 */      return empty;\r
+/* MR14 */    }\r
+\r
+       /* locks are valid for aLoopBlk,aPlusBlk,RuleBlk,EndRule junctions only */\r
+       if ( p->jtype==aLoopBlk || p->jtype==RuleBlk ||\r
+                p->jtype==aPlusBlk || p->jtype==EndRule )\r
+       {\r
+               require(p->lock!=NULL, "rJunc: lock array is NULL");\r
+               if ( p->lock[k] )\r
+               {\r
+                       if ( p->jtype == EndRule )      /* FOLLOW cycle? */\r
+                       {\r
+#ifdef DBG_LL1\r
+                               fprintf(stderr, "FOLLOW cycle to %s: panic!\n", p->rname);\r
+#endif\r
+                if (! MR_AmbSourceSearch) RegisterCycle(p->rname, k);\r
+                       }\r
+            if (MR_MaintainBackTrace) MR_pointerStackPop(&MR_BackTraceStack);\r
+                       return empty;\r
+               }\r
+               if ( p->jtype == RuleBlk &&\r
+                 p->end->halt  &&\r
+                     ! MR_AmbSourceSearch)     /* check for FIRST cache */\r
+               {\r
+                       CacheEntry *q = (CacheEntry *) hash_get(Fcache, Fkey(p->rname,'i',k));\r
+                       if ( q != NULL )\r
+                       {\r
+                               set_orin(rk, q->rk);\r
+                if (MR_MaintainBackTrace) MR_pointerStackPop(&MR_BackTraceStack);\r
+                               return set_dup( q->fset );\r
+                       }\r
+               }\r
+               if ( p->jtype == EndRule &&\r
+                !p->halt &&                     /* MR11 was using cache even when halt set */\r
+                     ! MR_AmbSourceSearch)             /* FOLLOW set cached already? */\r
+               {\r
+                       CacheEntry *q = (CacheEntry *) hash_get(Fcache, Fkey(p->rname,'o',k));\r
+                       if ( q != NULL )\r
+                       {\r
+#ifdef DBG_LL1\r
+                               fprintf(stderr, "cache for FOLLOW(%s,%d):", p->rname,k);\r
+                               s_fprT(stderr, q->fset);\r
+                               if ( q->incomplete ) fprintf(stderr, " (incomplete)");\r
+                               fprintf(stderr, "\n");\r
+#endif\r
+                               if ( !q->incomplete )\r
+                               {\r
+                    if (MR_MaintainBackTrace) MR_pointerStackPop(&MR_BackTraceStack);\r
+                                       return set_dup( q->fset );\r
+                               }\r
+                       }\r
+               }\r
+               p->lock[k] = TRUE;      /* This rule is busy */\r
+       }\r
+\r
+       a = b = empty;\r
+\r
+       if ( p->jtype == EndRule )\r
+       {\r
+               if (p->halt )                   /* don't want FOLLOW here? */ /* unless MR10 hoisting */\r
+               {\r
+                     p->lock[k] = FALSE;\r
+                         set_orel(k, rk);                                              /* indicate this k value needed */\r
+              if (MR_MaintainBackTrace) MR_pointerStackPop(&MR_BackTraceStack);\r
+                         return empty;\r
+               }\r
+               if (! MR_AmbSourceSearch) FoPush(p->rname, k);          /* Attempting FOLLOW */\r
+               if ( p->p1 == NULL ) set_orel((TokenInd!=NULL?TokenInd[EofToken]:EofToken), &a);/* if no FOLLOW assume EOF */\r
+#ifdef DBG_LL1\r
+               fprintf(stderr, "-->FOLLOW(%s,%d)\n", p->rname,k);\r
+#endif\r
+       }\r
+\r
+       if ( p->p1 != NULL ) {\r
+/* MR14 */      if (p->guess) {\r
+/* MR14 */        if (p->guess_analysis_point == NULL) {\r
+/* MR14 */           Node * guess_point;\r
+/* MR14 */           guess_point=(Node *)analysis_point(p);\r
+/* MR14 */           if (guess_point == (Node *)p) {\r
+/* MR14 */             guess_point=p->p1;\r
+/* MR14 */           }\r
+/* MR14 */           p->guess_analysis_point=guess_point;\r
+/* MR14 */        }\r
+/* MR14 */        REACH(p->guess_analysis_point, k, rk, a);\r
+                } else {\r
+                  REACH(p->p1, k, rk, a);\r
+                }\r
+    }  \r
+\r
+       /* C a c h e  R e s u l t s */\r
+\r
+       if ( p->jtype == RuleBlk && p->end->halt && ! MR_AmbSourceSearch)               /* can save FIRST set? */\r
+       {\r
+               CacheEntry *q = newCacheEntry( Fkey(p->rname,'i',k) );\r
+               /*fprintf(stderr, "Caching %s FIRST %d\n", p->rname, k);*/\r
+               hash_add(Fcache, Fkey(p->rname,'i',k), (Entry *)q);\r
+               q->fset = set_dup( a );\r
+               q->rk = set_dup( *rk );\r
+       }\r
+\r
+       if ( p->jtype == EndRule &&\r
+            !p->halt &&                         /* MR11 was using cache even with halt set */\r
+                 ! MR_AmbSourceSearch)                 /* just completed FOLLOW? */\r
+       {\r
+               /* Cache Follow set */\r
+               CacheEntry *q = (CacheEntry *) hash_get(Fcache, Fkey(p->rname,'o',k));\r
+               if ( q==NULL )\r
+               {\r
+                       q = newCacheEntry( Fkey(p->rname,'o',k) );\r
+                       hash_add(Fcache, Fkey(p->rname,'o',k), (Entry *)q);\r
+               }\r
+               /*fprintf(stderr, "Caching %s FOLLOW %d\n", p->rname, k);*/\r
+               if ( set_nil(a) && !q->incomplete )\r
+               {\r
+                       /* Don't ever save a nil set as complete.\r
+                        * Turn it into an eof set.\r
+                        */\r
+                       set_orel(EofToken, &a);\r
+               }\r
+               set_orin(&(q->fset), a);\r
+               FoPop( k );\r
+               if ( FoTOS[k] == NULL && Cycles[k] != NULL ) ResolveFoCycles(k);\r
+#ifdef DBG_LL1\r
+               fprintf(stderr, "saving FOLLOW(%s,%d):", p->rname, k);\r
+               s_fprT(stderr, q->fset);\r
+               if ( q->incomplete ) fprintf(stderr, " (incomplete)");\r
+               fprintf(stderr, "\n");\r
+#endif\r
+       }\r
+       \r
+    if (p->jtype != RuleBlk && p->p2 != NULL && /* MR14 */ ! p->guess) {\r
+       REACH(p->p2, k, rk, b);\r
+    }  \r
+\r
+       if ( p->jtype==aLoopBlk || p->jtype==RuleBlk ||\r
+                p->jtype==aPlusBlk || p->jtype==EndRule )\r
+               p->lock[k] = FALSE;                                                     /* unlock node */\r
+\r
+       set_orin(&a, b);\r
+       set_free(b);\r
+    if (MR_MaintainBackTrace) MR_pointerStackPop(&MR_BackTraceStack);\r
+       return a;\r
+}\r
+\r
+set\r
+#ifdef __USE_PROTOS\r
+rRuleRef( RuleRefNode *p, int k, set *rk_out )\r
+#else\r
+rRuleRef( p, k, rk_out )\r
+RuleRefNode *p;\r
+int k;\r
+set *rk_out;\r
+#endif\r
+{\r
+       set rk;\r
+       Junction *r;\r
+       int k2;\r
+       set a, rk2, b;\r
+       int save_halt;\r
+       RuleEntry *q = (RuleEntry *) hash_get(Rname, p->text);\r
+       require(p!=NULL,                        "rRuleRef: NULL node");\r
+       require(p->ntype==nRuleRef,     "rRuleRef: not rule ref");\r
+\r
+#ifdef DBG_LL1\r
+       fprintf(stderr, "rRuleRef: %s\n", p->text);\r
+#endif\r
+\r
+    if (MR_MaintainBackTrace) MR_pointerStackPush(&MR_BackTraceStack,p);\r
+\r
+       if ( q == NULL )\r
+       {\r
+               warnFL( eMsg1("rule %s not defined",p->text), FileStr[p->file], p->line );\r
+               REACH(p->next, k, rk_out, a);\r
+        if (MR_MaintainBackTrace) MR_pointerStackPop(&MR_BackTraceStack);\r
+               return a;\r
+       }\r
+       rk2 = empty;\r
+\r
+/* MR9 Problems with rule references in guarded predicates */\r
+/* MR9    Perhaps can use hash table to find rule ?        */\r
+\r
+/* MR9 */    if (RulePtr == NULL) {\r
+/* MR9 */        fatalFL(eMsg2("Rule %s uses rule %s via RulePtr before it has been initialized",\r
+/* MR9 */                                p->rname,q->str),FileStr[p->file],p->line);\r
+/* MR9 */    };\r
+\r
+       r = RulePtr[q->rulenum];\r
+       if ( r->lock[k] )\r
+       {\r
+               errNoFL( eMsg2("infinite left-recursion to rule %s from rule %s",\r
+                                               r->rname, p->rname) );\r
+\r
+        if (MR_MaintainBackTrace) MR_pointerStackPop(&MR_BackTraceStack);\r
+\r
+               return empty;\r
+       }\r
+\r
+       save_halt = r->end->halt;\r
+       r->end->halt = TRUE;            /* don't let reach fall off end of rule here */\r
+       rk = empty;\r
+       REACH(r, k, &rk, a);\r
+       r->end->halt = save_halt;\r
+       while ( !set_nil(rk) ) {\r
+               k2 = set_int(rk);               /* MR11 this messes up the ambiguity search routine */\r
+               set_rm(k2, rk);\r
+               REACH(p->next, k2, &rk2, b);    /* MR11 by changing the value of k                  */\r
+               set_orin(&a, b);\r
+               set_free(b);\r
+       }\r
+       set_free(rk);                           /* this has no members, but free it's memory */\r
+       set_orin(rk_out, rk2);          /* remember what we couldn't do */\r
+       set_free(rk2);\r
+    if (MR_MaintainBackTrace) MR_pointerStackPop(&MR_BackTraceStack);\r
+       return a;\r
+}\r
+\r
+/*\r
+ * Return FIRST sub k ( token_node )\r
+ *\r
+ * TJP 10/11/93 modified this so that token nodes that are actually\r
+ * ranges (T1..T2) work.\r
+ */\r
+set\r
+#ifdef __USE_PROTOS\r
+rToken( TokNode *p, int k, set *rk )\r
+#else\r
+rToken( p, k, rk )\r
+TokNode *p;\r
+int k;\r
+set *rk;\r
+#endif\r
+{\r
+       set a;\r
+\r
+       require(p!=NULL,                        "rToken: NULL node");\r
+       require(p->ntype==nToken,       "rToken: not token node");\r
+\r
+#ifdef DBG_LL1\r
+       fprintf(stderr, "rToken: %s\n", (TokenString(p->token)!=NULL)?TokenString(p->token):\r
+                                                                       ExprString(p->token));\r
+#endif\r
+\r
+\r
+    if (MR_MaintainBackTrace) MR_pointerStackPush(&MR_BackTraceStack,p);\r
+\r
+    if (MR_AmbSourceSearch && (k-1) == 0) {\r
+\r
+      set       localConstrain;\r
+      set       intersection;\r
+\r
+      localConstrain=fset[maxk-k+1];\r
+\r
+      if (! set_nil(p->tset)) {\r
+        intersection=set_and(localConstrain,p->tset);\r
+        if (! set_nil(intersection)) {\r
+          MR_backTraceReport();\r
+        };\r
+        set_free(intersection);\r
+      } else {\r
+        if (set_el( (unsigned) p->token,localConstrain)) {\r
+          MR_backTraceReport();\r
+        }\r
+      };\r
+    };\r
+\r
+       if ( k-1 == 0 ) {\r
+\r
+        if (MR_MaintainBackTrace) MR_pointerStackPop(&MR_BackTraceStack);\r
+\r
+               if ( !set_nil(p->tset) ) {\r
+            return set_dup(p->tset);\r
+        } else {\r
+               return set_of(p->token);\r
+        };\r
+       }\r
+\r
+       REACH(p->next, k-1, rk, a);\r
+       \r
+    if (MR_MaintainBackTrace) MR_pointerStackPop(&MR_BackTraceStack);\r
+\r
+       return a;\r
+}\r
+\r
+set\r
+#ifdef __USE_PROTOS\r
+rAction( ActionNode *p, int k, set *rk )\r
+#else\r
+rAction( p, k, rk )\r
+ActionNode *p;\r
+int k;\r
+set *rk;\r
+#endif\r
+{\r
+       set a;\r
+\r
+       require(p!=NULL,                        "rJunc: NULL node");\r
+       require(p->ntype==nAction,      "rJunc: not action");\r
+       \r
+/* MR11 */    if (p->is_predicate && p->ampersandPred != NULL) {\r
+/* MR11 */      Predicate   *pred=p->ampersandPred;\r
+/* MR11 */      if (k <= pred->k) {\r
+/* MR11 */        REACH(p->guardNodes,k,rk,a);\r
+/* MR11 */        return a;\r
+/* MR11 */      };\r
+/* MR11 */    };\r
+\r
+    /* it might be a good idea when doing an MR_AmbSourceSearch\r
+       to *not* look behind predicates under some circumstances\r
+       we'll look into that later\r
+    */\r
+\r
+       REACH(p->next, k, rk, a);       /* ignore actions */\r
+       return a;\r
+}\r
+\r
+                               /* A m b i g u i t y  R e s o l u t i o n */\r
+\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+dumpAmbigMsg( set *fset, FILE *f, int want_nls )\r
+#else\r
+dumpAmbigMsg( fset, f, want_nls )\r
+set *fset;\r
+FILE *f;\r
+int want_nls;\r
+#endif\r
+{\r
+       int i;\r
+\r
+    set     copy;               /* MR11 */\r
+\r
+       if ( want_nls ) fprintf(f, "\n\t");\r
+       else fprintf(f, " ");\r
+\r
+       for (i=1; i<=CLL_k; i++)\r
+       {\r
+        copy=set_dup(fset[i]);  /* MR11 */\r
+\r
+               if ( i>1 )\r
+               {\r
+                       if ( !want_nls ) fprintf(f, ", ");\r
+               }\r
+               if ( set_deg(copy) > 3 && elevel == 1 )\r
+               {\r
+                       int e,m;\r
+                       fprintf(f, "{");\r
+                       for (m=1; m<=3; m++)\r
+                       {\r
+                               e=set_int(copy);\r
+                               fprintf(f, " %s", TerminalString(e));\r
+                               set_rm(e, copy);\r
+                       }\r
+                       fprintf(f, " ... }");\r
+               }\r
+               else s_fprT(f, copy);\r
+               if ( want_nls ) fprintf(f, "\n\t");\r
+        set_free(copy);\r
+       }\r
+       fprintf(f, "\n");\r
+\r
+}\r
+\r
+static void\r
+#ifdef __USE_PROTOS\r
+verify_context(Predicate *predicate)\r
+#else\r
+verify_context(predicate)\r
+Predicate *predicate;\r
+#endif\r
+{\r
+       if ( predicate == NULL ) return;\r
+\r
+       if ( predicate->expr == PRED_OR_LIST ||\r
+                predicate->expr == PRED_AND_LIST )\r
+       {\r
+               verify_context(predicate->down);\r
+               verify_context(predicate->right);       /* MR10 */\r
+               return;\r
+       }\r
+\r
+       if ( !predicate->source->ctxwarned && predicate->source->guardpred==NULL &&\r
+                ((predicate->k > 1 &&\r
+                !is_single_tuple(predicate->tcontext)) ||\r
+                ( predicate->k == 1 &&\r
+                         set_deg(predicate->scontext[1])>1 )) )\r
+       {\r
+\r
+/* MR9 Suppress annoying messages caused by our own clever(?) fix */\r
+\r
+               fprintf(stderr, ErrHdr, FileStr[predicate->source->file],\r
+                               predicate->source->line);\r
+               fprintf(stderr, " warning: predicate applied for >1 lookahead %d-sequences\n", predicate->k);\r
+               fprintf(stderr, ErrHdr, FileStr[predicate->source->file],\r
+                               predicate->source->line);\r
+               fprintf(stderr, "     predicate text: \"%s\"\n",\r
+                        (predicate->expr == NULL ? "(null)" : predicate->expr) );\r
+               fprintf(stderr, ErrHdr, FileStr[predicate->source->file],\r
+                               predicate->source->line);\r
+               fprintf(stderr, "     You may only want one lookahead %d-sequence to apply\n", predicate->k);\r
+               fprintf(stderr, ErrHdr, FileStr[predicate->source->file],\r
+                               predicate->source->line);\r
+               fprintf(stderr, "     Try using a context guard '(...)? =>'\n");\r
+               predicate->source->ctxwarned = 1;\r
+       }\r
+    verify_context(predicate->right);       /* MR10 */\r
+}\r
+\r
+/*\r
+ * If delta is the set of ambiguous lookahead sequences, then make sure that\r
+ * the predicate(s) for productions alt1,alt2 cover the sequences in delta.\r
+ *\r
+ * For example,\r
+ *     a : <<PRED1>>? (A B|A C)\r
+ *       | b\r
+ *    ;\r
+ *     b : <<PRED2>>? A B\r
+ *       | A C\r
+ *       ;\r
+ *\r
+ * This should give a warning that (A C) predicts both productions and alt2\r
+ * does not have a predicate in the production that generates (A C).\r
+ *\r
+ * The warning detection is simple.  Let delta = LOOK(alt1) intersection LOOK(alt2).\r
+ * Now, if ( delta set-difference context(predicates-for-alt1) != empty then\r
+ * alt1 does not "cover" all ambiguous sequences.\r
+ *\r
+ * If ambig is nonempty, then ambig in LL(k) sense -> use tree info; else use fset\r
+ * info.  Actually, sets are used only if k=1 for this grammar.\r
+ */\r
+static void\r
+#ifdef __USE_PROTOS\r
+ensure_predicates_cover_ambiguous_lookahead_sequences\r
+                        ( Junction *alt1, Junction *alt2, char *sub, Tree *ambig )\r
+#else\r
+ensure_predicates_cover_ambiguous_lookahead_sequences( alt1, alt2, sub, ambig )\r
+Junction *alt1;\r
+Junction *alt2;\r
+char *sub;\r
+Tree *ambig;\r
+#endif\r
+{\r
+       if ( !ParseWithPredicates ) return;\r
+\r
+       if ( ambig!=NULL )\r
+       {\r
+               Tree *non_covered = NULL;\r
+               if ( alt1->predicate!=NULL )\r
+                       non_covered = tdif(ambig, alt1->predicate, alt1->fset, alt2->fset);\r
+               if ( (non_covered!=NULL || alt1->predicate==NULL) && WarningLevel>1 )\r
+               {\r
+                       fprintf(stderr, ErrHdr, FileStr[alt1->file], alt1->line);\r
+                       fprintf(stderr, " warning: alt %d %shas no predicate to resolve ambiguity",\r
+                                                       alt1->altnum, sub);\r
+                       if ( alt1->predicate!=NULL && non_covered!=NULL )\r
+                       {\r
+                               fprintf(stderr, " upon");\r
+                               preorder(non_covered);\r
+                       }\r
+                       else if ( alt1->predicate==NULL )\r
+                       {\r
+                               fprintf(stderr, " upon");\r
+                               preorder(ambig->down);\r
+                       }\r
+                       fprintf(stderr, "\n");\r
+               }\r
+               Tfree(non_covered);\r
+               non_covered = NULL;\r
+               if ( alt2->predicate!=NULL )\r
+                       non_covered = tdif(ambig, alt2->predicate, alt1->fset, alt2->fset);\r
+               if ( (non_covered!=NULL || alt2->predicate==NULL) && WarningLevel>1 )\r
+               {\r
+                       fprintf(stderr, ErrHdr, FileStr[alt2->file], alt2->line);\r
+                       fprintf(stderr, " warning: alt %d %shas no predicate to resolve ambiguity",\r
+                                                       alt2->altnum, sub);\r
+                       if ( alt2->predicate!=NULL && non_covered!=NULL )\r
+                       {\r
+                               fprintf(stderr, " upon");\r
+                               preorder(non_covered);\r
+                       }\r
+                       else if ( alt2->predicate==NULL )\r
+                       {\r
+                               fprintf(stderr, " upon");\r
+                               preorder(ambig->down);\r
+                       }\r
+                       fprintf(stderr, "\n");\r
+               }\r
+               Tfree(non_covered);\r
+       }\r
+       else if ( !set_nil(alt1->fset[1]) )\r
+       {\r
+               set delta, non_covered;\r
+               delta = set_and(alt1->fset[1], alt2->fset[1]);\r
+               non_covered = set_dif(delta, covered_set(alt1->predicate));\r
+               if ( set_deg(non_covered)>0 && WarningLevel>1 )\r
+               {\r
+                       fprintf(stderr, ErrHdr, FileStr[alt1->file], alt1->line);\r
+                       fprintf(stderr, " warning: alt %d %shas no predicate to resolve ambiguity",\r
+                                                       alt1->altnum, sub);\r
+                       if ( alt1->predicate!=NULL )\r
+                       {\r
+                               fprintf(stderr, " upon ");\r
+                               s_fprT(stderr, non_covered);\r
+                       }\r
+                       fprintf(stderr, "\n");\r
+               }\r
+               set_free( non_covered );\r
+               non_covered = set_dif(delta, covered_set(alt2->predicate));\r
+               if ( set_deg(non_covered)>0 && WarningLevel>1 )\r
+               {\r
+                       fprintf(stderr, ErrHdr, FileStr[alt2->file], alt2->line);\r
+                       fprintf(stderr, " warning: alt %d %shas no predicate to resolve ambiguity",\r
+                                                       alt2->altnum, sub);\r
+                       if ( alt2->predicate!=NULL )\r
+                       {\r
+                               fprintf(stderr, " upon ");\r
+                               s_fprT(stderr, non_covered);\r
+                       }\r
+                       fprintf(stderr, "\n");\r
+               }\r
+               set_free( non_covered );\r
+               set_free( delta );\r
+       }\r
+       else fatal_internal("productions have no lookahead in predicate checking routine");\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+void MR_doPredicatesHelp(int inGuessBlock,Junction *alt1,Junction *alt2,int jtype,char *sub)\r
+#else\r
+void MR_doPredicatesHelp(inGuessBlock,alt1,alt2,jtype,sub)\r
+  int       inGuessBlock;\r
+  Junction  *alt1;\r
+  Junction  *alt2;\r
+  int       jtype;\r
+  char      *sub;\r
+#endif\r
+{\r
+    Predicate   *p1;\r
+    Predicate   *p2;\r
+\r
+    Junction    *parentRule=MR_nameToRuleBlk(alt1->rname);\r
+\r
+    if (inGuessBlock && WarningLevel <= 1) return;\r
+\r
+    /* let antlr give the usual error message */\r
+\r
+    if (alt1->predicate == NULL && alt2->predicate == NULL) return;\r
+\r
+    if ( (jtype == RuleBlk || jtype == aSubBlk)\r
+             && (alt1->predicate == NULL && alt2->predicate != NULL)) {\r
+        fprintf(stderr, ErrHdr, FileStr[parentRule->file],parentRule->line);\r
+        fprintf(stderr," warning: alt %d line %d and alt %d line %d of %s\n%s%s%s",\r
+          alt1->altnum,\r
+          alt1->line,\r
+          alt2->altnum,\r
+          alt2->line,\r
+          sub,\r
+          "     These alts have ambig lookahead sequences resolved by a predicate for\n",\r
+          "     the second choice. The second choice may not be reachable.\n",\r
+          "     You may want to use a complementary predicate or rearrange the alts\n"\r
+        );\r
+        return;\r
+    };\r
+\r
+    /* first do the easy comparison.  then do the hard one */\r
+\r
+    if (MR_comparePredicates(alt1->predicate,alt2->predicate)) {\r
+\r
+      if (jtype == aLoopBegin || jtype == aPlusBlk ) {\r
+\r
+        /* I'm not sure this code is reachable.\r
+           Predicates following a (...)+ or (...)* block are probably\r
+             considered validation predicates and therefore not\r
+             participate in the predication expression\r
+        */\r
+\r
+       fprintf(stderr, ErrHdr,FileStr[parentRule->file],parentRule->line);\r
+        fprintf(stderr," warning: %s of %s in rule %s\n     (file %s alt %d line %d and alt %d line %d)\n%s",\r
+          "the predicates used to disambiguate optional/exit paths of ",\r
+          sub,\r
+          CurRule,\r
+          FileStr[alt1->file],\r
+          alt1->altnum,\r
+          alt1->line,\r
+          alt2->altnum,\r
+          alt2->line,\r
+          "     are identical and have no resolving power\n");\r
+      } else {\r
+       fprintf(stderr, ErrHdr, FileStr[parentRule->file], parentRule->line);\r
+        fprintf(stderr," warning: %s rule %s\n     (file %s alt %d line %d and alt %d line %d)\n%s",\r
+          "the predicates used to disambiguate",\r
+          CurRule,\r
+          FileStr[alt1->file],\r
+          alt1->altnum,\r
+          alt1->line,\r
+          alt2->altnum,\r
+          alt2->line,\r
+          "     are identical and have no resolving power\n");\r
+      };\r
+    } else {\r
+      p1=predicate_dup_without_context(alt1->predicate);\r
+      p1=MR_unfold(p1);\r
+      MR_clearPredEntry(p1);\r
+      MR_simplifyInverted(p1,0);\r
+      p1=MR_predSimplifyALL(p1);\r
+      p2=predicate_dup_without_context(alt2->predicate);\r
+      p2=MR_unfold(p2);\r
+      MR_clearPredEntry(p2);\r
+      MR_simplifyInverted(p2,0);\r
+      p2=MR_predSimplifyALL(p2);\r
+      if (MR_comparePredicates(p1,p2)) {\r
+        if (jtype == aLoopBegin || jtype == aPlusBlk ) {\r
+          fprintf(stderr, ErrHdr, FileStr[parentRule->file], parentRule->line);\r
+          fprintf(stderr," warning: %s of %s in rule %s\n     (file %s alt %d line %d and alt %d line %d)\n%s%s",\r
+            "the predicates used to disambiguate optional/exit paths of ",\r
+            sub,\r
+            CurRule,\r
+            FileStr[alt1->file],\r
+            alt1->altnum,\r
+            alt1->line,\r
+            alt2->altnum,\r
+            alt2->line,\r
+            "     are identical when compared without context and may have no\n",\r
+            "     resolving power for some lookahead sequences.\n");\r
+        } else {\r
+          fprintf(stderr, ErrHdr, FileStr[parentRule->file], parentRule->line);\r
+          fprintf(stderr," warning: %s rule %s\n     (file %s alt %d line %d and alt %d line %d)\n%s%s",\r
+            "the predicates used to disambiguate",\r
+            CurRule,\r
+            FileStr[alt1->file],\r
+            alt1->altnum,\r
+            alt1->line,\r
+            alt2->altnum,\r
+            alt2->line,\r
+            "     are identical when compared without context and may have no\n",\r
+            "     resolving power for some lookahead sequences.\n");\r
+        };\r
+        if (InfoP) {\r
+          fprintf(output,"\n#if 0\n\n");\r
+          fprintf(output,"The following predicates are identical when compared without\n");\r
+          fprintf(output,"  lookahead context information.  For some ambiguous lookahead\n");\r
+          fprintf(output,"  sequences they may not have any power to resolve the ambiguity.\n");\r
+          fprintf(output,"\n");\r
+\r
+          fprintf(output,"Choice 1: %s  alt %d  line %d  file %s\n\n",\r
+                  MR_ruleNamePlusOffset( (Node *) alt1),\r
+                  alt1->altnum,\r
+                  alt1->line,\r
+                  FileStr[alt1->file]);\r
+          fprintf(output,"  The original predicate for choice 1 with available context information:\n\n");\r
+          MR_dumpPred1(2,alt1->predicate,1);\r
+          fprintf(output,"  The predicate for choice 1 after expansion (but without context information):\n\n");\r
+          MR_dumpPred1(2,p1,0);\r
+          if (p1 == NULL) {\r
+            Predicate   *phelp;\r
+            fprintf(output,"  The predicate for choice 1 after expansion (but before simplification)\n\n");\r
+            phelp=predicate_dup_without_context(alt1->predicate);\r
+            phelp=MR_unfold(phelp);\r
+            MR_clearPredEntry(phelp);\r
+            MR_simplifyInverted(phelp,0);\r
+            phelp=MR_predSimplifyALLX(phelp,1);\r
+            MR_dumpPred1(2,phelp,0);\r
+            predicate_free(phelp);\r
+          };\r
+          fprintf(output,"\n");\r
+\r
+          fprintf(output,"Choice 2: %s  alt %d  line %d  file %s\n\n",\r
+                  MR_ruleNamePlusOffset( (Node *) alt2),\r
+                  alt2->altnum,\r
+                  alt2->line,\r
+                  FileStr[alt2->file]);\r
+          fprintf(output,"  The original predicate for choice 2 with available context information:\n\n");\r
+          MR_dumpPred1(1,alt2->predicate,1);\r
+          fprintf(output,"  The predicate for choice 2 after expansion (but without context information):\n\n");\r
+          MR_dumpPred1(1,p2,0);\r
+          if (p2 == NULL) {\r
+            Predicate   *phelp;\r
+            fprintf(output,"  The predicate for choice 2 after expansion (but before simplification)\n\n");\r
+            phelp=predicate_dup_without_context(alt2->predicate);\r
+            phelp=MR_unfold(phelp);\r
+            MR_clearPredEntry(phelp);\r
+            MR_simplifyInverted(phelp,0);\r
+            phelp=MR_predSimplifyALLX(phelp,1);\r
+            MR_dumpPred1(2,phelp,0);\r
+            predicate_free(phelp);\r
+          };\r
+          fprintf(output,"\n#endif\n");\r
+        };\r
+      } else if (MR_secondPredicateUnreachable(p1,p2)) {\r
+        if (jtype == aLoopBegin || jtype == aPlusBlk ) {\r
+          fprintf(stderr, ErrHdr, FileStr[parentRule->file], parentRule->line);\r
+          fprintf(stderr," warning: %s of %s in rule %s\n     (file %s alt %d line %d and alt %d line %d)\n%s%s",\r
+            "the predicate used to disambiguate the first choice of the optional/exit paths of ",\r
+            sub,\r
+            CurRule,\r
+            FileStr[alt1->file],\r
+            alt1->altnum,\r
+            alt1->line,\r
+            alt2->altnum,\r
+            alt2->line,\r
+            "     appears to \"cover\" the second predicate when compared without context.\n",\r
+            "     The second predicate may have no resolving power for some lookahead sequences.\n");\r
+        } else {\r
+          fprintf(stderr, ErrHdr, FileStr[parentRule->file], parentRule->line);\r
+          fprintf(stderr," warning: %s rule %s\n     (file %s alt %d line %d and alt %d line %d)\n%s%s",\r
+            "the predicate used to disambiguate the first choice of",\r
+            CurRule,\r
+            FileStr[alt1->file],\r
+            alt1->altnum,\r
+            alt1->line,\r
+            alt2->altnum,\r
+            alt2->line,\r
+            "     appears to \"cover\" the second predicate when compared without context.\n",\r
+            "     The second predicate may have no resolving power for some lookahead sequences.\n");\r
+        };\r
+        if (InfoP) {\r
+          fprintf(output,"\n#if 0\n\n");\r
+          fprintf(output,"The first predicate appears to \"cover\" the second predicate when they\n");\r
+          fprintf(output,"  are compared without lookahead context information.  For some ambiguous\n");\r
+          fprintf(output,"  lookahead sequences the second predicate may not have any power to\n");\r
+          fprintf(output,"  resolve the ambiguity.\n");\r
+          fprintf(output,"\n");\r
+          fprintf(output,"Choice 1: %s  alt %d  line %d  file %s\n\n",\r
+                  MR_ruleNamePlusOffset( (Node *) alt1),\r
+                  alt1->altnum,\r
+                  alt1->line,\r
+                  FileStr[alt1->file]);\r
+          fprintf(output,"  The original predicate for choice 1 with available context information:\n\n");\r
+          MR_dumpPred1(2,alt1->predicate,1);\r
+          fprintf(output,"  The predicate for choice 1 after expansion (but without context information):\n\n");\r
+          MR_dumpPred1(2,p1,0);\r
+          if (p1 == NULL) {\r
+            Predicate   *phelp;\r
+            fprintf(output,"  The predicate for choice 1 after expansion (but before simplification)\n\n");\r
+            phelp=predicate_dup_without_context(alt1->predicate);\r
+            phelp=MR_unfold(phelp);\r
+            MR_clearPredEntry(phelp);\r
+            MR_simplifyInverted(phelp,0);\r
+            phelp=MR_predSimplifyALLX(phelp,1);\r
+            MR_dumpPred1(2,phelp,0);\r
+            predicate_free(phelp);\r
+          };\r
+          fprintf(output,"\n");\r
+\r
+          fprintf(output,"Choice 2: %s  alt %d  line %d  file %s\n\n",\r
+                  MR_ruleNamePlusOffset( (Node *) alt2),\r
+                  alt2->altnum,\r
+                  alt2->line,\r
+                  FileStr[alt2->file]);\r
+          fprintf(output,"  The original predicate for choice 2 with available context information:\n\n");\r
+          MR_dumpPred1(1,alt2->predicate,1);\r
+          fprintf(output,"  The predicate for choice 2 after expansion (but without context information):\n\n");\r
+          MR_dumpPred1(1,p2,0);\r
+          if (p2 == NULL) {\r
+            Predicate   *phelp;\r
+            fprintf(output,"  The predicate for choice 2 after expansion (but before simplification)\n\n");\r
+            phelp=predicate_dup_without_context(alt2->predicate);\r
+            phelp=MR_unfold(phelp);\r
+            MR_clearPredEntry(phelp);\r
+            MR_simplifyInverted(phelp,0);\r
+            phelp=MR_predSimplifyALLX(phelp,1);\r
+            MR_dumpPred1(2,phelp,0);\r
+            predicate_free(phelp);\r
+          };\r
+          fprintf(output,"\n#endif\n");\r
+        };\r
+      };\r
+      predicate_free(p1);\r
+      predicate_free(p2);\r
+    };\r
+}\r
+\r
+static  int     totalOverflow=0;                /* MR9 */\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+HandleAmbiguity( Junction *block, Junction *alt1, Junction *alt2, int jtype )\r
+#else\r
+HandleAmbiguity( block, alt1, alt2, jtype )\r
+Junction *block;\r
+Junction *alt1;\r
+Junction *alt2;\r
+int jtype;\r
+#endif\r
+{\r
+       unsigned **ftbl;\r
+       set *fset, b;\r
+       int i, numAmbig,n2;\r
+       Tree *ambig=NULL, *t, *u;\r
+       char *sub = "";\r
+    long    n;\r
+    int     thisOverflow=0;             /* MR9 */\r
+    long    set_deg_value;              /* MR10 */\r
+    long    threshhold;                 /* MR10 */\r
+\r
+       require(block!=NULL, "NULL block");\r
+       require(block->ntype==nJunction, "invalid block");\r
+\r
+       /* These sets are used to constrain LL_k set, but are made CLL_k long anyway */\r
+       fset = (set *) calloc(CLL_k+1, sizeof(set));\r
+       require(fset!=NULL, "cannot allocate fset");\r
+       ftbl = (unsigned **) calloc(CLL_k+1, sizeof(unsigned *));\r
+       require(ftbl!=NULL, "cannot allocate ftbl");\r
+\r
+       /* create constraint table and count number of possible ambiguities (use<=LL_k) */\r
+       for (n=1,i=1; i<=CLL_k; i++)\r
+       {\r
+                       b = set_and(alt1->fset[i], alt2->fset[i]);\r
+/* MR9 */       set_deg_value = set_deg(b);\r
+/* MR10 */      if (n > 0) {\r
+/* MR10 */        threshhold = LONG_MAX / n;\r
+/* MR10 */        if (set_deg_value <= threshhold) {\r
+/* MR10 */             n *= set_deg_value;\r
+/* MR10 */        } else {\r
+/* MR10 */          n=LONG_MAX;\r
+/* MR9 */           if (totalOverflow == 0) {\r
+#if 0\r
+                      /* MR10 comment this out because it just makes users worry */\r
+\r
+/* MR9 */             warnNoFL("Overflow in computing number of possible ambiguities in HandleAmbiguity\n");\r
+#endif\r
+/* MR9 */           };\r
+/* MR9 */           thisOverflow++;\r
+/* MR9 */           totalOverflow++;\r
+/* MR9 */         };\r
+/* MR10 */      } else {\r
+/* MR10 */        n *= set_deg_value;\r
+/* MR9 */       };\r
+               fset[i] = set_dup(b);\r
+               ftbl[i] = set_pdq(b);\r
+               set_free(b);\r
+       }\r
+\r
+       switch ( jtype )\r
+       {\r
+               case aSubBlk: sub = "of (..) "; break;\r
+               case aOptBlk: sub = "of {..} "; break;\r
+               case aLoopBegin: sub = "of (..)* "; break;\r
+               case aLoopBlk: sub = "of (..)* "; break;\r
+               case aPlusBlk: sub = "of (..)+ "; break;\r
+               case RuleBlk: sub = "of the rule itself "; break;\r
+               default : sub = ""; break;\r
+       }\r
+\r
+       /* If the block is marked as a compressed lookahead only block, then\r
+        * simply return; ambiguity warning is given only at warning level 2.\r
+        */\r
+       if ( block->approx>0 )\r
+       {\r
+               if ( ParseWithPredicates )\r
+               {\r
+            if (alt1->predicate != NULL) predicate_free(alt1->predicate);  /* MR12 */\r
+            if (alt2->predicate != NULL) predicate_free(alt2->predicate);  /* MR12 */\r
+\r
+            require(MR_PredRuleRefStack.count == 0,"PredRuleRef stack not empty");\r
+               alt1->predicate = MR_find_predicates_and_supp((Node *)alt1->p1);\r
+            require(MR_PredRuleRefStack.count == 0,"PredRuleRef stack not empty");\r
+            require (MR_predicate_context_completed(alt1->predicate),"predicate alt 1 not completed");\r
+            alt1->predicate=MR_predSimplifyALL(alt1->predicate);\r
+\r
+            require(MR_PredRuleRefStack.count == 0,"PredRuleRef stack not empty");\r
+               alt2->predicate = MR_find_predicates_and_supp((Node *)alt2->p1);\r
+            require(MR_PredRuleRefStack.count == 0,"PredRuleRef stack not empty");\r
+            require (MR_predicate_context_completed(alt2->predicate),"predicate alt 2 not completed");\r
+            alt2->predicate=MR_predSimplifyALL(alt2->predicate);\r
+\r
+            MR_doPredicatesHelp(0,alt1,alt2,jtype,sub);\r
+\r
+                       if ( HoistPredicateContext\r
+                    && (alt1->predicate!=NULL||alt2->predicate!=NULL) )\r
+                       {\r
+                               verify_context(alt1->predicate);\r
+                               verify_context(alt2->predicate);\r
+                       }\r
+\r
+                       if ( HoistPredicateContext\r
+                     && (alt1->predicate!=NULL||alt2->predicate!=NULL)\r
+                     && WarningLevel>1 )\r
+                       ensure_predicates_cover_ambiguous_lookahead_sequences(alt1, alt2, sub, ambig);\r
+               }\r
+\r
+               if ( WarningLevel>1 )\r
+               {\r
+                       fprintf(stderr, ErrHdr, FileStr[alt1->file], alt1->line);\r
+                       if ( jtype == aLoopBegin || jtype == aPlusBlk )\r
+                               fprintf(stderr, " warning: optional/exit path and alt(s) %sambiguous upon", sub);\r
+                       else\r
+                               fprintf(stderr, " warning(approx): alts %d and %d %sambiguous upon",\r
+                                               alt1->altnum, alt2->altnum, sub);\r
+                       dumpAmbigMsg(fset, stderr, 0);\r
+            MR_traceAmbSource(fset,alt1,alt2);\r
+               }\r
+               for (i=1; i<=CLL_k; i++) set_free( fset[i] );\r
+               free((char *)fset);\r
+               for (i=1; i<=CLL_k; i++) free( (char *)ftbl[i] );\r
+               free((char *)ftbl);\r
+               return;\r
+    }\r
+\r
+       /* if all sets have degree 1 for k<LL_k, then must be ambig upon >=1 permutation;\r
+        * don't bother doing full LL(k) analysis.\r
+        * (This "if" block handles the LL(1) case)\r
+        */\r
+\r
+       n2 = 0;\r
+       for (i=1; i<LL_k; i++) n2 += set_deg(alt1->fset[i])+set_deg(alt2->fset[i]);\r
+\r
+    /* here STARTS the special case in which the lookahead sets for alt1 and alt2\r
+       all have degree 1 for k<LL_k (including LL_k=1)\r
+    */\r
+\r
+       if ( n2==2*(LL_k-1) )\r
+       {\r
+\r
+        /* TJP: added to fix the case where LL(1) and syntactic predicates didn't\r
+         * work.  It now recognizes syntactic predicates, but does not like combo:\r
+         * LL(1)/syn/sem predicates. (10/24/93)\r
+         */\r
+\r
+               if ( first_item_is_guess_block_extra((Junction *)alt1->p1)!=NULL )\r
+               {\r
+                       if ( WarningLevel==1 )\r
+                       {\r
+                               for (i=1; i<=CLL_k; i++) set_free( fset[i] );\r
+                               free((char *)fset);\r
+                               for (i=1; i<=CLL_k; i++) free( (char *)ftbl[i] );\r
+                               free((char *)ftbl);\r
+                               return;\r
+                       }\r
+\r
+                       fprintf(stderr, ErrHdr, FileStr[alt1->file], alt1->line);\r
+                       if ( jtype == aLoopBegin || jtype == aPlusBlk )\r
+                          fprintf(stderr, " warning: optional/exit path and alt(s) %sambiguous upon", sub);\r
+                       else\r
+                          fprintf(stderr, " warning: alts %d and %d %sambiguous upon",\r
+                                          alt1->altnum, alt2->altnum, sub);\r
+                       dumpAmbigMsg(fset, stderr, 0);\r
+            MR_traceAmbSource(fset,alt1,alt2);\r
+               }\r
+\r
+               ambig = NULL;\r
+               if ( LL_k>1 ) ambig = make_tree_from_sets(alt1->fset, alt2->fset);\r
+               if ( ParseWithPredicates )\r
+               {\r
+           if (alt1->predicate != NULL) predicate_free(alt1->predicate);  /* MR12 */\r
+           if (alt2->predicate != NULL) predicate_free(alt2->predicate);  /* MR12 */\r
+\r
+           require(MR_PredRuleRefStack.count == 0,"PredRuleRef stack not empty");\r
+           alt1->predicate = MR_find_predicates_and_supp((Node *)alt1->p1);\r
+           require(MR_PredRuleRefStack.count == 0,"PredRuleRef stack not empty");\r
+           require (MR_predicate_context_completed(alt1->predicate),"predicate alt 1 not completed");\r
+           alt1->predicate=MR_predSimplifyALL(alt1->predicate);\r
+\r
+           require(MR_PredRuleRefStack.count == 0,"PredRuleRef stack not empty");\r
+          alt2->predicate = MR_find_predicates_and_supp((Node *)alt2->p1);\r
+           require(MR_PredRuleRefStack.count == 0,"PredRuleRef stack not empty");\r
+           require (MR_predicate_context_completed(alt2->predicate),"predicate alt 2 not completed");\r
+           alt2->predicate=MR_predSimplifyALL(alt2->predicate);\r
+\r
+           MR_doPredicatesHelp(0,alt1,alt2,jtype,sub);\r
+\r
+                  if ( HoistPredicateContext && (alt1->predicate!=NULL||alt2->predicate!=NULL) )\r
+                  {\r
+                               verify_context(alt1->predicate);\r
+                               verify_context(alt2->predicate);\r
+                  }\r
+                  if (HoistPredicateContext&&(alt1->predicate!=NULL||alt2->predicate!=NULL) && WarningLevel>1)\r
+                         ensure_predicates_cover_ambiguous_lookahead_sequences(alt1, alt2, sub, ambig);\r
+                  if ( WarningLevel == 1 &&\r
+                          (alt1->predicate!=NULL||alt2->predicate!=NULL))\r
+                  {\r
+                         for (i=1; i<=CLL_k; i++) set_free( fset[i] );\r
+                         free((char *)fset);\r
+                         for (i=1; i<=CLL_k; i++) free( (char *)ftbl[i] );\r
+                         free((char *)ftbl);\r
+                         Tfree(ambig);\r
+                         return;\r
+                  }\r
+               }\r
+/* end TJP (10/24/93) */\r
+\r
+               fprintf(stderr, ErrHdr, FileStr[alt1->file], alt1->line);\r
+               if ( jtype == aLoopBegin || jtype == aPlusBlk )\r
+                       fprintf(stderr, " warning: optional/exit path and alt(s) %sambiguous upon", sub);\r
+               else\r
+                  fprintf(stderr, " warning: alts %d and %d %sambiguous upon",\r
+                                  alt1->altnum, alt2->altnum, sub);\r
+               if ( elevel == 3 && LL_k>1 )\r
+               {\r
+                  preorder(ambig);\r
+                  fprintf(stderr, "\n");\r
+              for (i=1; i<=CLL_k; i++) set_free( fset[i] );\r
+          free((char *)fset);\r
+                  for (i=1; i<=CLL_k; i++) free( (char *)ftbl[i] );\r
+                  free((char *)ftbl);\r
+                  Tfree(ambig);\r
+                  return;\r
+        };\r
+\r
+               Tfree(ambig);\r
+               dumpAmbigMsg(fset, stderr, 0);\r
+\r
+        /* because this is a special case in which both alt1 and alt2 have\r
+           lookahead sets of degree 1 for k<LL_k (including k=1) the linear\r
+           lookahead style search is adequate\r
+        */\r
+\r
+        MR_traceAmbSource(fset,alt1,alt2);\r
+\r
+               for (i=1; i<=CLL_k; i++) set_free( fset[i] );\r
+               free((char *)fset);\r
+               for (i=1; i<=CLL_k; i++) free( (char *)ftbl[i] );\r
+               free((char *)ftbl);\r
+               return;\r
+       }\r
+\r
+    /* here ENDS the special case in which the lookahead sets for alt1 and alt2\r
+       all have degree 1 for k<LL_k (including LL_k=1)\r
+    */\r
+\r
+       /* in case tree construction runs out of memory, set info to make good err msg */\r
+\r
+       CurAmbigAlt1 = alt1->altnum;\r
+       CurAmbigAlt2 = alt2->altnum;\r
+       CurAmbigbtype = sub;\r
+       CurAmbigfile = alt1->file;\r
+       CurAmbigline = alt1->line;\r
+       \r
+       /* Don't do full LL(n) analysis if (...)? block because the block,\r
+          by definition, defies LL(n) analysis.\r
+          If guess (...)? block and ambiguous then don't remove anything from\r
+          2nd alt to resolve ambig.\r
+          Want to predict with LL sup 1 ( n ) decision not LL(n) if guess block\r
+          since it is much cheaper than LL(n).  LL sup 1 ( n ) "covers" the LL(n)\r
+          lookahead information.\r
+\r
+          Note: LL(n) context cannot be computed for semantic predicates when\r
+          followed by (..)?.\r
+\r
+          If (..)? then we scream "AAAHHHH!  No LL(n) analysis will help"\r
+\r
+       Is 'ambig' always defined if we enter this if?  I hope so\r
+          because the 'ensure...()' func references it. TJP Nov 1993.\r
+          */\r
+\r
+       /* THM MR30:  Instead of using first_item_is_guss_block we use\r
+          first_item_is_guess_block_extra which will look inside a\r
+          loop block for a guess block.  In other words ( (...)? )*.\r
+          It there is an ambiguity in this circumstance then we suppress\r
+          the normal methods of resolving ambiguities.\r
+       */\r
+\r
+       if ( first_item_is_guess_block_extra((Junction *)alt1->p1)!=NULL )\r
+       {\r
+               if ( ParseWithPredicates )\r
+               {\r
+            if (alt1->predicate != NULL) predicate_free(alt1->predicate);  /* MR12 */\r
+            if (alt2->predicate != NULL) predicate_free(alt2->predicate);  /* MR12 */\r
+            require(MR_PredRuleRefStack.count == 0,"PredRuleRef stack not empty");\r
+               alt1->predicate = MR_find_predicates_and_supp((Node *)alt1->p1);\r
+            require(MR_PredRuleRefStack.count == 0,"PredRuleRef stack not empty");\r
+            require (MR_predicate_context_completed(alt1->predicate),"predicate alt 1 not completed");\r
+            alt1->predicate=MR_predSimplifyALL(alt1->predicate);\r
+\r
+            require(MR_PredRuleRefStack.count == 0,"PredRuleRef stack not empty");\r
+               alt2->predicate = MR_find_predicates_and_supp((Node *)alt2->p1);\r
+            require(MR_PredRuleRefStack.count == 0,"PredRuleRef stack not empty");\r
+            require (MR_predicate_context_completed(alt2->predicate),"predicate alt 2 not completed");\r
+            alt2->predicate=MR_predSimplifyALL(alt2->predicate);\r
+\r
+            MR_doPredicatesHelp(1,alt1,alt2,jtype,sub);\r
+\r
+                       if ( HoistPredicateContext && (alt1->predicate!=NULL||alt2->predicate!=NULL) )\r
+                       {\r
+                               verify_context(alt1->predicate);\r
+                               verify_context(alt2->predicate);\r
+                       }\r
+                       if ( HoistPredicateContext && (alt1->predicate!=NULL||alt2->predicate!=NULL) && WarningLevel>1 )\r
+                               ensure_predicates_cover_ambiguous_lookahead_sequences(alt1, alt2, sub, ambig);\r
+                       if ( WarningLevel==1 &&\r
+                               (alt1->predicate!=NULL||alt2->predicate!=NULL))\r
+                       {\r
+                               for (i=1; i<=CLL_k; i++) set_free( fset[i] );\r
+                               free((char *)fset);\r
+                               for (i=1; i<=CLL_k; i++) free( (char *)ftbl[i] );\r
+                               free((char *)ftbl);\r
+                               return;\r
+                       }\r
+               }\r
+\r
+               if ( WarningLevel>1 )\r
+               {\r
+                       fprintf(stderr, ErrHdr, FileStr[alt1->file], alt1->line);\r
+                       if ( jtype == aLoopBegin || jtype == aPlusBlk )\r
+                               fprintf(stderr, " warning: optional/exit path and alt(s) %sambiguous upon", sub);\r
+                       else\r
+                               fprintf(stderr, " warning: alts %d and %d %sambiguous upon",\r
+                                               alt1->altnum, alt2->altnum, sub);\r
+                       dumpAmbigMsg(fset, stderr, 0);\r
+            MR_traceAmbSource(fset,alt1,alt2);\r
+               }\r
+\r
+               for (i=1; i<=CLL_k; i++) set_free( fset[i] );\r
+               free((char *)fset);\r
+               for (i=1; i<=CLL_k; i++) free( (char *)ftbl[i] );\r
+               free((char *)ftbl);\r
+               return;\r
+       }\r
+       \r
+       /* Not resolved with (..)? block.  Do full LL(n) analysis */\r
+       \r
+       /* ambig is the set of k-tuples truly in common between alt 1 and alt 2 */\r
+    /* MR11 VerifyAmbig once used fset destructively */\r
+\r
+       ambig = VerifyAmbig(alt1, alt2, ftbl, fset, &t, &u, &numAmbig);\r
+\r
+       /* are all things in intersection really ambigs? */\r
+\r
+       if (thisOverflow ||  numAmbig < n )                     /* MR9 */\r
+       {\r
+               Tree *v;\r
+\r
+               /* remove ambig permutation from 2nd alternative to resolve ambig;\r
+                * We want to compute the set of artificial tuples, arising from\r
+                * LL sup 1 (n) compression, that collide with real tuples from the\r
+                * 2nd alternative.  This is the set of "special case" tuples that\r
+                * the LL sup 1 (n) decision template maps incorrectly.\r
+                */\r
+\r
+        /* when generating code in genExpr() it does\r
+         *\r
+         *      if ( genExprSets(j->fset) && !genExprTree(j->ftree)) {...\r
+         *\r
+         * Sooooo the j->ftree is the tree of alt2\r
+         *               after removal of conflicts, not alt1 !\r
+         */\r
+\r
+               if ( ambig!=NULL )\r
+               {\r
+            /* at the top of ambig is an ALT node */\r
+\r
+                       for (v=ambig->down; v!=NULL; v=v->right)\r
+                       {\r
+                               u = trm_perm(u, v);     /* remove v FROM u */\r
+                       }\r
+/*                     fprintf(stderr, "after rm alt2:"); preorder(u); fprintf(stderr, "\n");*/\r
+               }\r
+               Tfree( t );\r
+               alt1->ftree = tappend(alt1->ftree, u);\r
+               alt1->ftree = tleft_factor(alt1->ftree);\r
+       }\r
+\r
+       if ( ambig==NULL )\r
+       {\r
+               for (i=1; i<=CLL_k; i++) set_free( fset[i] );\r
+               free((char *)fset);\r
+               for (i=1; i<=CLL_k; i++) free( (char *)ftbl[i] );\r
+               free((char *)ftbl);\r
+               return;\r
+       }\r
+\r
+       ambig = tleft_factor(ambig);\r
+\r
+/* TJP:\r
+ * At this point, we surely have an LL(k) ambiguity.  Check for predicates\r
+ */\r
+       if ( ParseWithPredicates )\r
+       {\r
+        if (alt1->predicate != NULL) predicate_free(alt1->predicate);  /* MR12 */\r
+        if (alt2->predicate != NULL) predicate_free(alt2->predicate);  /* MR12 */\r
+        require(MR_PredRuleRefStack.count == 0,"PredRuleRef stack not empty");\r
+       alt1->predicate = MR_find_predicates_and_supp((Node *)alt1->p1);\r
+        require(MR_PredRuleRefStack.count == 0,"PredRuleRef stack not empty");\r
+        require (MR_predicate_context_completed(alt1->predicate),"predicate alt 1 not completed");\r
+        alt1->predicate=MR_predSimplifyALL(alt1->predicate);\r
+\r
+        require(MR_PredRuleRefStack.count == 0,"PredRuleRef stack not empty");\r
+               alt2->predicate = MR_find_predicates_and_supp((Node *)alt2->p1);\r
+        require(MR_PredRuleRefStack.count == 0,"PredRuleRef stack not empty");\r
+        require (MR_predicate_context_completed(alt2->predicate),"predicate alt 2 not completed");\r
+        alt2->predicate=MR_predSimplifyALL(alt2->predicate);\r
+\r
+        MR_doPredicatesHelp(0,alt1,alt2,jtype,sub);\r
+\r
+               if ( HoistPredicateContext && (alt1->predicate!=NULL||alt2->predicate!=NULL) )\r
+               {\r
+                       verify_context(alt1->predicate);\r
+                       verify_context(alt2->predicate);\r
+               }\r
+               if ( HoistPredicateContext && (alt1->predicate!=NULL||alt2->predicate!=NULL) && WarningLevel>1 )\r
+                  ensure_predicates_cover_ambiguous_lookahead_sequences(alt1, alt2, sub, ambig);\r
+               if ( WarningLevel==1 &&\r
+                       (alt1->predicate!=NULL||alt2->predicate!=NULL))\r
+               {\r
+\r
+                       /* We found at least one pred for at least one of the alts;\r
+                        * If warnings are low, just return.\r
+                        */\r
+\r
+                       Tfree(ambig);\r
+            for (i=1; i<=CLL_k; i++) set_free( fset[i] );\r
+           free((char *)fset);\r
+               for (i=1; i<=CLL_k; i++) free( (char *)ftbl[i] );\r
+               free((char *)ftbl);\r
+                       return;\r
+               }\r
+               /* else we're gonna give a warning */\r
+       }\r
+/* end TJP addition */\r
+\r
+       fprintf(stderr, ErrHdr, FileStr[alt1->file], alt1->line);\r
+       if ( jtype == aLoopBegin || jtype == aPlusBlk )\r
+               fprintf(stderr, " warning: optional/exit path and alt(s) %sambiguous upon", sub);\r
+       else\r
+               fprintf(stderr, " warning: alts %d and %d %sambiguous upon",\r
+                                       alt1->altnum, alt2->altnum, sub);\r
+       if ( elevel == 3 )\r
+       {\r
+               preorder(ambig->down);      /* <===== k>1 ambiguity message data */\r
+               fprintf(stderr, "\n");\r
+       } else {\r
+        MR_skipped_e3_report=1;\r
+       dumpAmbigMsg(fset, stderr, 0);\r
+    };\r
+\r
+    MR_traceAmbSourceK(ambig,alt1,alt2);     /* <====== k>1 ambiguity aid */\r
+\r
+       Tfree(ambig);\r
+\r
+    for (i=1; i<=CLL_k; i++) set_free( fset[i] );\r
+       free((char *)fset);\r
+       for (i=1; i<=CLL_k; i++) free( (char *)ftbl[i] );\r
+       free((char *)ftbl);\r
+}\r
+\r
+/* Don't analyze alpha block of (alpha)?beta; if (alpha)? then analyze\r
+ * Return the 1st node of the beta block if present else return j.\r
+ */\r
+Junction *\r
+#ifdef __USE_PROTOS\r
+analysis_point( Junction *j )\r
+#else\r
+analysis_point( j )\r
+Junction *j;\r
+#endif\r
+{\r
+       Junction *gblock;\r
+\r
+    /* MR13b  When there was an action/predicate preceding a guess block\r
+              the guess block became invisible at the analysis_point.\r
+\r
+              first_item_is_guess_block accepts any kind of node,\r
+              despite the fact that the formal is a junction.  But\r
+              I don't want to have to change it all over the place\r
+              until I know it works.\r
+    */\r
+\r
+       if ( j->ntype != nJunction && j->ntype != nAction) return j;\r
+\r
+       gblock = first_item_is_guess_block((Junction *)j);\r
+\r
+       if ( gblock!=NULL )\r
+       {\r
+               Junction *past = gblock->end;\r
+               Junction *p;\r
+               require(past!=NULL, "analysis_point: no end block on (...)? block");\r
+\r
+               for (p=(Junction *)past->p1; p!=NULL; )\r
+               {\r
+                       if ( p->ntype==nAction )\r
+                       {\r
+                               p=(Junction *)((ActionNode *)p)->next;\r
+                               continue;\r
+                       }\r
+                       if ( p->ntype!=nJunction )\r
+                       {\r
+                past->alpha_beta_guess_end=1;           /* MR14 */\r
+                               return (Junction *)past->p1;\r
+                       }\r
+                       if ( p->jtype==EndBlk || p->jtype==EndRule )\r
+                       {\r
+                               return j;\r
+                       }\r
+/* MR6                                                                                                       */\r
+/* MR6 A guess block is of the form "(alpha)? beta" or "(alpha)?".           */\r
+/* MR6  When beta is omitted (second form) this means "(alpha)? alpha".       */\r
+/* MR6  The program does not store another copy of alpha in this case.        */\r
+/* MR6  During analysis when the program needs to know what follows the       */\r
+/* MR6    guess clause.  It calls this routine.                               */\r
+/* MR6                                                                        */\r
+/* MR6      If it is of the form "(alpha)? beta" it returns a pointer to beta.*/\r
+/* MR6                                                                        */\r
+/* MR6      If it is of the form "(alpha)?" it returns a pointer to the guess */\r
+/* MR6        block itself thereby reusing the junction tree.                 */\r
+/* MR6                                                                        */\r
+/* MR6  It works by searching the "next in sequence" chain (skipping actions) */\r
+/* MR6    searching for a RuleRef or Token node.  (Those are the only 4 kinds */\r
+/* MR6    of nodes: Junctions, RuleRef, Token, and Action.)                   */\r
+/* MR6                                                                        */\r
+/* MR6  This won't work for the special case "(alpha)? ()" because it has no  */\r
+/* MR6    rule references or token nodes.  It eventually encounters a         */\r
+/* MR6   junction of type EndBlk or EndRule and says to its caller: nothing  */\r
+/* MR6    more here to analyze - must be of the form "(alpha)?".              */\r
+/* MR6                                                                        */\r
+/* MR6  In the case of "(alpha)? ()" it should return a pointer to "()"       */\r
+/* MR6                                                                        */\r
+/* MR6  I think.                                                              */\r
+/* MR6                                                                        */\r
+                       if ( p->jtype!=Generic) {                                          /* MR6 */\r
+                past->alpha_beta_guess_end=1;                          /* MR14 */\r
+                               return (Junction *)past->p1;                           /* MR6 */\r
+                       };                                                                             /* MR6 */\r
+                       p=(Junction *)p->p1;\r
+               }\r
+       }\r
+       return j;\r
+}\r
+\r
+set\r
+#ifdef __USE_PROTOS\r
+First( Junction *j, int k, int jtype, int *max_k )\r
+#else\r
+First( j, k, jtype, max_k )\r
+Junction *j;\r
+int k;\r
+int jtype;\r
+int *max_k;\r
+#endif\r
+{\r
+       Junction *alt1, *alt2;\r
+       set a, rk, fCurBlk;\r
+       int savek;\r
+       int p1, p2;\r
+\r
+    int     save_maintainBackTrace;\r
+\r
+       require(j->ntype==nJunction, "First: non junction passed");\r
+\r
+       /* C o m p u t e  F I R S T  s e t  w i t h  k  l o o k a h e a d */\r
+       fCurBlk = rk = empty;\r
+       for (alt1=j; alt1!=NULL; alt1 = (Junction *)alt1->p2 )\r
+       {\r
+               Junction * p = NULL;\r
+               Junction * p1junction = NULL;\r
+               p = analysis_point((Junction *)alt1->p1);\r
+               p1junction = (Junction *) (alt1->p1);\r
+#if 0\r
+               if (p != p1junction) {\r
+                       fprintf(stdout,"Analysis point for #%d is #%d", p1junction->seq, p->seq); /* debug */\r
+               }\r
+#endif\r
+               REACH(p, k, &rk, alt1->fset[k]);\r
+               require(set_nil(rk), "rk != nil");\r
+               set_free(rk);\r
+               set_orin(&fCurBlk, alt1->fset[k]);\r
+       }\r
+\r
+       /* D e t e c t  A m b i g u i t i e s */\r
+       *max_k = 1;\r
+       for (p1=1,alt1=j; alt1!=NULL; alt1 = (Junction *)alt1->p2, p1++)\r
+       {\r
+               for (p2=1,alt2=(Junction *)alt1->p2; alt2!=NULL; alt2 = (Junction *)alt2->p2, p2++)\r
+               {\r
+                       savek = k;\r
+                       a = set_and(alt1->fset[k], alt2->fset[k]);\r
+                       while ( !set_nil(a) )\r
+                       {\r
+                               /* if we have hit the max k requested, just give warning */\r
+                               if ( j->approx==k ) {\r
+                               }\r
+\r
+                               if ( k==CLL_k )\r
+                               {\r
+#ifdef NOT_USED\r
+***                                    int save_LL_k = LL_k;\r
+***                                    int save_CLL_k = CLL_k;\r
+***                                    /* Get new LL_k from interactive feature if enabled */\r
+***                                    if ( AImode )\r
+***                                            AmbiguityDialog(j, jtype, alt1, alt2, &CLL_k, &LL_k);\r
+#endif\r
+                                       *max_k = CLL_k;\r
+                    save_maintainBackTrace=MR_MaintainBackTrace;\r
+                    if (AlphaBetaTrace) MR_MaintainBackTrace=0;\r
+                                       HandleAmbiguity(j, alt1, alt2, jtype);\r
+                    MR_MaintainBackTrace=save_maintainBackTrace;\r
+                                       break;\r
+                               }\r
+                               else\r
+                               {\r
+                                       Junction *p = analysis_point((Junction *)alt1->p1);\r
+                                       Junction *q = analysis_point((Junction *)alt2->p1);\r
+                                       k++;    /* attempt ambig alts again with more lookahead */\r
+\r
+                                       REACH(p, k, &rk, alt1->fset[k]);\r
+                                       require(set_nil(rk), "rk != nil");\r
+                                       REACH(q, k, &rk, alt2->fset[k]);\r
+                                       require(set_nil(rk), "rk != nil");\r
+                                       set_free(a);\r
+                                       a = set_and(alt1->fset[k], alt2->fset[k]);\r
+                                       if ( k > *max_k ) *max_k = k;\r
+                               }\r
+                       }\r
+                       set_free(a);\r
+                       k = savek;\r
+               }\r
+       }\r
+\r
+       return fCurBlk;\r
+}\r
diff --git a/Tools/CodeTools/Source/Pccts/antlr/fset2.c b/Tools/CodeTools/Source/Pccts/antlr/fset2.c
new file mode 100644 (file)
index 0000000..7f686a5
--- /dev/null
@@ -0,0 +1,2250 @@
+/*\r
+ * fset2.c\r
+ *\r
+ * Compute FIRST sets for full LL(k)\r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
+ * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
+ * company may do whatever they wish with source code distributed with\r
+ * PCCTS or the code generated by PCCTS, including the incorporation of\r
+ * PCCTS, or its output, into commerical software.\r
+ *\r
+ * We encourage users to develop software with PCCTS.  However, we do ask\r
+ * that credit is given to us for developing PCCTS.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like PCCTS and have developed a nice tool with the\r
+ * output, please mention that you developed it using PCCTS.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * ANTLR 1.33\r
+ * Terence Parr\r
+ * Parr Research Corporation\r
+ * with Purdue University and AHPCRC, University of Minnesota\r
+ * 1989-2001\r
+ */\r
+\r
+#include <stdio.h>\r
+#include "pcctscfg.h"\r
+#include <stdlib.h>\r
+\r
+#ifdef PCCTS_USE_STDARG\r
+#include <stdarg.h>\r
+#else\r
+#include <varargs.h>\r
+#endif\r
+\r
+#include "set.h"\r
+#include "syn.h"\r
+#include "hash.h"\r
+#include "generic.h"\r
+#include "dlgdef.h"\r
+\r
+/* ick! globals.  Used by permute() to track which elements of a set have been used */\r
+\r
+static int *findex;\r
+set *fset;              /* MR11 make global */\r
+static unsigned **ftbl;\r
+static set *constrain; /* pts into fset. constrains tToken() to 'constrain' */\r
+int ConstrainSearch;\r
+int maxk;               /* set to initial k upon tree construction request */\r
+                        /* MR11 make global */\r
+static Tree *FreeList = NULL;\r
+\r
+#ifdef __USE_PROTOS\r
+static int tmember_of_context(Tree *, Predicate *);\r
+#else\r
+static int tmember_of_context();\r
+#endif\r
+\r
+#if TREE_DEBUG\r
+set     set_of_tnodes_in_use;\r
+int     stop_on_tnode_seq_number=(-1);     /* (-1) to disable */\r
+#endif\r
+\r
+/* Do root\r
+ * Then each sibling\r
+ */\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+preorder( Tree *tree )\r
+#else\r
+preorder( tree )\r
+Tree *tree;\r
+#endif\r
+{\r
+       if ( tree == NULL ) return;\r
+       if ( tree->down != NULL ) fprintf(stderr, " (");\r
+       if ( tree->token == ALT ) fprintf(stderr, " ALT");\r
+       else fprintf(stderr, " %s", TerminalString(tree->token));\r
+       if ( tree->token==EpToken ) fprintf(stderr, "(%d)", tree->v.rk);\r
+       preorder(tree->down);\r
+       if ( tree->down != NULL ) fprintf(stderr, " )");\r
+       preorder(tree->right);\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+int MR_tree_matches_constraints(int k,set * constrain,Tree *t)\r
+#else\r
+int MR_tree_matches_constraints(k,constrain,t)\r
+  int       k;\r
+  set *     constrain;\r
+  Tree *    t;\r
+#endif\r
+{\r
+  int       i;\r
+  Tree      *u;\r
+\r
+  if (k == 0) return 1;\r
+\r
+  /* for testing guard predicates: if the guard tree is shorter\r
+     than the constraint then it is a match.  The reason is that\r
+     a guard of (A B) should be equivalent to a guard of (A B . . .)\r
+     where "." matches every token.  Thus a match which runs out\r
+     of tree before constraint is a match.\r
+  */\r
+\r
+  if (t == NULL) return 1;\r
+  require (set_deg(constrain[0]) == 1,\r
+            "MR_tree_matches_constraints: set_deg != 1");\r
+  i=set_int(constrain[0]);\r
+  if (t->token != i) return 0;\r
+  if (k-1 == 0) return 1;\r
+  for (u=t->down; u != NULL; u=u->right) {\r
+    if (MR_tree_matches_constraints(k-1,&constrain[1],u)) {\r
+       return 1;\r
+    };\r
+  };\r
+  return 0;\r
+}\r
+\r
+/* check the depth of each primary sibling to see that it is exactly\r
+ * k deep. e.g.;\r
+ *\r
+ *     ALT\r
+ *   |\r
+ *   A ------- B\r
+ *   |         |\r
+ *   C -- D    E\r
+ *\r
+ * Remove all branches <= k deep.\r
+ *\r
+ * Added by TJP 9-23-92 to make the LL(k) constraint mechanism to work.\r
+ */\r
+\r
+static int pruneCount=0;\r
+static int prunePeak=200;\r
+\r
+Tree *\r
+#ifdef __USE_PROTOS\r
+prune( Tree *t, int k )\r
+#else\r
+prune( t, k )\r
+Tree *t;\r
+int k;\r
+#endif\r
+{\r
+    pruneCount++;\r
+    if (pruneCount > prunePeak+100) {\r
+      prunePeak=pruneCount;\r
+#if 0\r
+***   fprintf(stderr,"pruneCount=%d\n",pruneCount);\r
+/***  preorder(t);   ***/\r
+***   fprintf(stderr,"\n",pruneCount);\r
+#endif\r
+    };\r
+    if ( t == NULL ) {\r
+        pruneCount--;\r
+        return NULL;\r
+    };\r
+    if ( t->token == ALT ) fatal_internal("prune: ALT node in FIRST tree");\r
+    if ( t->right!=NULL ) t->right = prune(t->right, k);\r
+    if ( k>1 )\r
+       {\r
+               if ( t->down!=NULL ) t->down = prune(t->down, k-1);\r
+               if ( t->down == NULL )\r
+               {\r
+                       Tree *r = t->right;\r
+                       t->right = NULL;\r
+                       Tfree(t);\r
+            pruneCount--;\r
+                       return r;\r
+               }\r
+       }\r
+    pruneCount--;\r
+    return t;\r
+}\r
+\r
+/* build a tree (root child1 child2 ... NULL) */\r
+#ifdef PCCTS_USE_STDARG\r
+Tree *tmake(Tree *root, ...)\r
+#else\r
+Tree *tmake(va_alist)\r
+va_dcl\r
+#endif\r
+{\r
+       Tree *w;\r
+       va_list ap;\r
+       Tree *child, *sibling=NULL, *tail=NULL;\r
+#ifndef PCCTS_USE_STDARG\r
+       Tree *root;\r
+#endif\r
+\r
+#ifdef PCCTS_USE_STDARG\r
+       va_start(ap, root);\r
+#else\r
+       va_start(ap);\r
+       root = va_arg(ap, Tree *);\r
+#endif\r
+       child = va_arg(ap, Tree *);\r
+       while ( child != NULL )\r
+       {\r
+#ifdef DUM\r
+               /* added "find end of child" thing TJP March 1994 */\r
+               for (w=child; w->right!=NULL; w=w->right) {;} /* find end of child */\r
+#else\r
+               w = child;\r
+#endif\r
+\r
+               if ( sibling == NULL ) {sibling = child; tail = w;}\r
+               else {tail->right = child; tail = w;}\r
+               child = va_arg(ap, Tree *);\r
+       }\r
+\r
+       /* was "root->down = sibling;" */\r
+       if ( root==NULL ) root = sibling;\r
+       else root->down = sibling;\r
+\r
+       va_end(ap);\r
+       return root;\r
+}\r
+\r
+Tree *\r
+#ifdef __USE_PROTOS\r
+tnode( int tok )\r
+#else\r
+tnode( tok )\r
+int tok;\r
+#endif\r
+{\r
+       Tree *p, *newblk;\r
+       static int n=0;\r
+       \r
+       if ( FreeList == NULL )\r
+       {\r
+               /*fprintf(stderr, "tnode: %d more nodes\n", TreeBlockAllocSize);*/\r
+               if ( TreeResourceLimit > 0 )\r
+               {\r
+                       if ( (n+TreeBlockAllocSize) >= TreeResourceLimit )\r
+                       {\r
+                               fprintf(stderr, ErrHdr, FileStr[CurAmbigfile], CurAmbigline);\r
+                               fprintf(stderr, " hit analysis resource limit while analyzing alts %d and %d %s\n",\r
+                                                               CurAmbigAlt1,\r
+                                                               CurAmbigAlt2,\r
+                                                               CurAmbigbtype);\r
+                               exit(PCCTS_EXIT_FAILURE);\r
+                       }\r
+               }\r
+               newblk = (Tree *)calloc(TreeBlockAllocSize, sizeof(Tree));\r
+               if ( newblk == NULL )\r
+               {\r
+                       fprintf(stderr, ErrHdr, FileStr[CurAmbigfile], CurAmbigline);\r
+                       fprintf(stderr, " out of memory while analyzing alts %d and %d %s\n",\r
+                                                       CurAmbigAlt1,\r
+                                                       CurAmbigAlt2,\r
+                                                       CurAmbigbtype);\r
+                       exit(PCCTS_EXIT_FAILURE);\r
+               }\r
+               n += TreeBlockAllocSize;\r
+               for (p=newblk; p<&(newblk[TreeBlockAllocSize]); p++)\r
+               {\r
+                       p->right = FreeList;    /* add all new Tree nodes to Free List */\r
+                       FreeList = p;\r
+               }\r
+       }\r
+       p = FreeList;\r
+       FreeList = FreeList->right;             /* remove a tree node */\r
+       p->right = NULL;                                /* zero out ptrs */\r
+       p->down = NULL;\r
+       p->token = tok;\r
+\r
+    TnodesAllocated++;                                      /* MR10 */\r
+    TnodesInUse++;                                          /* MR10 */\r
+    if (TnodesInUse > TnodesPeak) TnodesPeak=TnodesInUse;   /* MR10 */\r
+\r
+#ifdef TREE_DEBUG\r
+       require(!p->in_use, "tnode: node in use!");\r
+       p->in_use = 1;\r
+    p->seq=TnodesAllocated;\r
+    set_orel( (unsigned) TnodesAllocated,&set_of_tnodes_in_use);\r
+    if (stop_on_tnode_seq_number == p->seq) {\r
+      fprintf(stderr,"\n*** just allocated tnode #%d ***\n",\r
+            stop_on_tnode_seq_number);\r
+    };\r
+#endif\r
+       return p;\r
+}\r
+\r
+static Tree *\r
+#ifdef __USE_PROTOS\r
+eofnode( int k )\r
+#else\r
+eofnode( k )\r
+int k;\r
+#endif\r
+{\r
+       Tree *t=NULL;\r
+       int i;\r
+\r
+       for (i=1; i<=k; i++)\r
+       {\r
+               t = tmake(tnode((TokenInd!=NULL?TokenInd[EofToken]:EofToken)), t, NULL);\r
+       }\r
+       return t;\r
+}\r
+\r
+\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+_Tfree( Tree *t )\r
+#else\r
+_Tfree( t )\r
+Tree *t;\r
+#endif\r
+{\r
+       if ( t!=NULL )\r
+       {\r
+#ifdef TREE_DEBUG\r
+        if (t->seq == stop_on_tnode_seq_number) {\r
+           fprintf(stderr,"\n*** just freed tnode #%d ***\n",t->seq);\r
+        };\r
+               require(t->in_use, "_Tfree: node not in use!");\r
+               t->in_use = 0;\r
+        set_rm( (unsigned) t->seq,set_of_tnodes_in_use);\r
+#endif\r
+               t->right = FreeList;\r
+               FreeList = t;\r
+        TnodesInUse--;                   /* MR10 */\r
+       }\r
+}\r
+\r
+/* tree duplicate */\r
+Tree *\r
+#ifdef __USE_PROTOS\r
+tdup( Tree *t )\r
+#else\r
+tdup( t )\r
+Tree *t;\r
+#endif\r
+{\r
+       Tree *u;\r
+       \r
+       if ( t == NULL ) return NULL;\r
+       u = tnode(t->token);\r
+       u->v.rk = t->v.rk;\r
+       u->right = tdup(t->right);\r
+       u->down = tdup(t->down);\r
+       return u;\r
+}\r
+\r
+/* tree duplicate (assume tree is a chain downwards) */\r
+Tree *\r
+#ifdef __USE_PROTOS\r
+tdup_chain( Tree *t )\r
+#else\r
+tdup_chain( t )\r
+Tree *t;\r
+#endif\r
+{\r
+       Tree *u;\r
+       \r
+       if ( t == NULL ) return NULL;\r
+       u = tnode(t->token);\r
+       u->v.rk = t->v.rk;\r
+       u->down = tdup(t->down);\r
+       return u;\r
+}\r
+\r
+Tree *\r
+#ifdef __USE_PROTOS\r
+tappend( Tree *t, Tree *u )\r
+#else\r
+tappend( t, u )\r
+Tree *t;\r
+Tree *u;\r
+#endif\r
+{\r
+       Tree *w;\r
+\r
+/*** fprintf(stderr, "tappend(");\r
+ *** preorder(t); fprintf(stderr, ",");\r
+ *** preorder(u); fprintf(stderr, " )\n");\r
+*/\r
+       if ( t == NULL ) return u;\r
+       if ( t->token == ALT && t->right == NULL ) return tappend(t->down, u);\r
+       for (w=t; w->right!=NULL; w=w->right) {;}\r
+       w->right = u;\r
+       return t;\r
+}\r
+\r
+/* dealloc all nodes in a tree */\r
+void\r
+#ifdef __USE_PROTOS\r
+Tfree( Tree *t )\r
+#else\r
+Tfree( t )\r
+Tree *t;\r
+#endif\r
+{\r
+       if ( t == NULL ) return;\r
+       Tfree( t->down );\r
+       Tfree( t->right );\r
+       _Tfree( t );\r
+}\r
+\r
+/* find all children (alts) of t that require remaining_k nodes to be LL_k\r
+ * tokens long.\r
+ *\r
+ * t-->o\r
+ *     |\r
+ *     a1--a2--...--an         <-- LL(1) tokens\r
+ *     |   |        |\r
+ *     b1  b2  ...  bn         <-- LL(2) tokens\r
+ *     |   |        |\r
+ *     .   .        .\r
+ *     .   .        .\r
+ *     z1  z2  ...  zn         <-- LL(LL_k) tokens\r
+ *\r
+ * We look for all [Ep] needing remaining_k nodes and replace with u.\r
+ * u is not destroyed or actually used by the tree (a copy is made).\r
+ */\r
+Tree *\r
+#ifdef __USE_PROTOS\r
+tlink( Tree *t, Tree *u, int remaining_k )\r
+#else\r
+tlink( t, u, remaining_k )\r
+Tree *t;\r
+Tree *u;\r
+int remaining_k;\r
+#endif\r
+{\r
+       Tree *p;\r
+       require(remaining_k!=0, "tlink: bad tree");\r
+\r
+       if ( t==NULL ) return NULL;\r
+       /*fprintf(stderr, "tlink: u is:"); preorder(u); fprintf(stderr, "\n");*/\r
+       if ( t->token == EpToken && t->v.rk == remaining_k )\r
+       {\r
+               require(t->down==NULL, "tlink: invalid tree");\r
+               if ( u == NULL ) {\r
+/* MR10 */  Tree  *tt=t->right;\r
+/* MR10 */  _Tfree(t);\r
+/* MR10 */  return tt;\r
+        };\r
+               p = tdup( u );\r
+               p->right = t->right;\r
+               _Tfree( t );\r
+               return p;\r
+       }\r
+       t->down = tlink(t->down, u, remaining_k);\r
+       t->right = tlink(t->right, u, remaining_k);\r
+       return t;\r
+}\r
+\r
+/* remove as many ALT nodes as possible while still maintaining semantics */\r
+Tree *\r
+#ifdef __USE_PROTOS\r
+tshrink( Tree *t )\r
+#else\r
+tshrink( t )\r
+Tree *t;\r
+#endif\r
+{\r
+       if ( t == NULL ) return NULL;\r
+       t->down = tshrink( t->down );\r
+       t->right = tshrink( t->right );\r
+       if ( t->down == NULL )\r
+       {\r
+               if ( t->token == ALT )\r
+               {\r
+                       Tree *u = t->right;\r
+                       _Tfree(t);\r
+                       return u;                       /* remove useless alts */\r
+               }\r
+               return t;\r
+       }\r
+\r
+       /* (? (ALT (? ...)) s) ==> (? (? ...) s) where s = sibling, ? = match any */\r
+       if ( t->token == ALT && t->down->right == NULL)\r
+       {\r
+               Tree *u = t->down;\r
+               u->right = t->right;\r
+               _Tfree( t );\r
+               return u;\r
+       }\r
+       /* (? (A (ALT t)) s) ==> (? (A t) s) where A is a token; s,t siblings */\r
+       if ( t->token != ALT && t->down->token == ALT && t->down->right == NULL )\r
+       {\r
+               Tree *u = t->down->down;\r
+               _Tfree( t->down );\r
+               t->down = u;\r
+               return t;\r
+       }\r
+       return t;\r
+}\r
+\r
+Tree *\r
+#ifdef __USE_PROTOS\r
+tflatten( Tree *t )\r
+#else\r
+tflatten( t )\r
+Tree *t;\r
+#endif\r
+{\r
+       if ( t == NULL ) return NULL;\r
+       t->down = tflatten( t->down );\r
+       t->right = tflatten( t->right );\r
+       if ( t->down == NULL ) return t;\r
+       \r
+       if ( t->token == ALT )\r
+       {\r
+               Tree *u;\r
+               /* find tail of children */\r
+               for (u=t->down; u->right!=NULL; u=u->right) {;}\r
+               u->right = t->right;\r
+               u = t->down;\r
+               _Tfree( t );\r
+               return u;\r
+       }\r
+       return t;\r
+}\r
+\r
+Tree *\r
+#ifdef __USE_PROTOS\r
+tJunc( Junction *p, int k, set *rk )\r
+#else\r
+tJunc( p, k, rk )\r
+Junction *p;\r
+int k;\r
+set *rk;\r
+#endif\r
+{\r
+       Tree *t=NULL, *u=NULL;\r
+       Junction *alt;\r
+       Tree *tail=NULL, *r;\r
+\r
+#ifdef DBG_TRAV\r
+       fprintf(stderr, "tJunc(%d): %s in rule %s\n", k,\r
+                       decodeJType[p->jtype], ((Junction *)p)->rname);\r
+#endif\r
+\r
+/* MR14 */    if (AlphaBetaTrace && p->alpha_beta_guess_end) {\r
+/* MR14 */         warnFL(\r
+/* MR14 */           "not possible to compute follow set for alpha in an \"(alpha)? beta\" block.  ",\r
+/* MR14 */                 FileStr[p->file],p->line);\r
+/* MR14 */         MR_alphaBetaTraceReport();\r
+/* MR14 */    };\r
+\r
+/* MR14 */    if (p->alpha_beta_guess_end) {\r
+/* MR14 */      return NULL;\r
+/* MR14 */    }\r
+\r
+       if ( p->jtype==aLoopBlk || p->jtype==RuleBlk ||\r
+                p->jtype==aPlusBlk || p->jtype==aSubBlk || p->jtype==aOptBlk )\r
+       {\r
+               if ( p->jtype!=aSubBlk && p->jtype!=aOptBlk ) {\r
+                       require(p->lock!=NULL, "rJunc: lock array is NULL");\r
+                       if ( p->lock[k] ) return NULL;\r
+                       p->lock[k] = TRUE;\r
+               }\r
+\r
+/* MR10 */    if (MR_MaintainBackTrace) {\r
+/* MR10 */      if (p->jtype != Generic) MR_pointerStackPush(&MR_BackTraceStack,p);\r
+/* MR10 */    };\r
+\r
+               TRAV(p->p1, k, rk, tail);\r
+\r
+/* MR10 */    if (MR_MaintainBackTrace) {\r
+/* MR10 */      if (p->jtype != Generic) MR_pointerStackPop(&MR_BackTraceStack);\r
+/* MR10 */    };\r
+\r
+               if ( p->jtype==RuleBlk ) {p->lock[k] = FALSE; return tail;}\r
+               r = tmake(tnode(ALT), tail, NULL);\r
+               for (alt=(Junction *)p->p2; alt!=NULL; alt = (Junction *)alt->p2)\r
+               {\r
+                       /* if this is one of the added optional alts for (...)+ then break */\r
+                       if ( alt->ignore ) break;\r
+\r
+                       if ( tail==NULL ) {TRAV(alt->p1, k, rk, tail); r->down = tail;}\r
+                       else\r
+                       {\r
+/* MR10 */    if (MR_MaintainBackTrace) {\r
+/* MR10 */      if (p->jtype != Generic) MR_pointerStackPush(&MR_BackTraceStack,p);\r
+/* MR10 */    };\r
+\r
+                               TRAV(alt->p1, k, rk, tail->right);\r
+\r
+/* MR10 */    if (MR_MaintainBackTrace) {\r
+/* MR10 */      if (p->jtype != Generic) MR_pointerStackPop(&MR_BackTraceStack);\r
+/* MR10 */    };\r
+                               if ( tail->right != NULL ) tail = tail->right;\r
+                       }\r
+               }\r
+               if ( p->jtype!=aSubBlk && p->jtype!=aOptBlk ) p->lock[k] = FALSE;\r
+#ifdef DBG_TREES\r
+               fprintf(stderr, "blk(%s) returns:",((Junction *)p)->rname); preorder(r); fprintf(stderr, "\n");\r
+#endif\r
+               if ( r->down == NULL ) {_Tfree(r); return NULL;}\r
+               return r;\r
+       }\r
+\r
+       if ( p->jtype==EndRule )\r
+       {\r
+               if ( p->halt )                                          /* don't want FOLLOW here? */\r
+               {\r
+/****          if ( ContextGuardTRAV ) return NULL; ****/\r
+                       set_orel( (unsigned) k, rk);    /* indicate this k value needed */ /* MR10 cast */\r
+                       t = tnode(EpToken);\r
+                       t->v.rk = k;\r
+                       return t;\r
+               }\r
+               require(p->lock!=NULL, "rJunc: lock array is NULL");\r
+               if ( p->lock[k] ) return NULL;\r
+               /* if no FOLLOW assume k EOF's */\r
+               if ( p->p1 == NULL ) return eofnode(k);\r
+               p->lock[k] = TRUE;\r
+       }\r
+\r
+/* MR14 */     if (p->p1 != NULL && p->guess &&  p->guess_analysis_point == NULL) {\r
+/* MR14 */    Node * guess_point;\r
+/* MR14 */    guess_point=(Node *)analysis_point(p);\r
+/* MR14 */    if (guess_point == (Node *)p) {\r
+/* MR14 */      guess_point=p->p1;\r
+/* MR14 */    }\r
+/* MR14 */    p->guess_analysis_point=guess_point;\r
+/* MR14 */  }  \r
+\r
+       if ( p->p2 == NULL )\r
+       {\r
+\r
+/* MR10 */    if (MR_MaintainBackTrace) {\r
+/* MR10 */      if (p->jtype != Generic) MR_pointerStackPush(&MR_BackTraceStack,p);\r
+/* MR10 */    };\r
+\r
+/* M14 */        if (p->guess_analysis_point != NULL) {\r
+/* M14 */                 TRAV(p->guess_analysis_point, k, rk,t);\r
+/* M14 */        } else {\r
+                          TRAV(p->p1, k, rk,t);\r
+/* M14 */        }\r
+\r
+/* MR10 */    if (MR_MaintainBackTrace) {\r
+/* MR10 */      if (p->jtype != Generic) MR_pointerStackPop(&MR_BackTraceStack);\r
+/* MR10 */    };\r
+\r
+               if ( p->jtype==EndRule ) p->lock[k]=FALSE;\r
+               return t;\r
+       }\r
+\r
+/* MR10 */    if (MR_MaintainBackTrace) {\r
+/* MR10 */      if (p->jtype != Generic) MR_pointerStackPush(&MR_BackTraceStack,p);\r
+/* MR10 */    };\r
+\r
+/* M14 */        if (p->guess_analysis_point != NULL) {\r
+/* M14 */                 TRAV(p->guess_analysis_point, k, rk,t);\r
+/* M14 */        } else {\r
+                          TRAV(p->p1, k, rk,t);\r
+/* M14 */        }\r
+\r
+/* MR10 */    if (MR_MaintainBackTrace) {\r
+/* MR10 */      if (p->jtype != Generic) MR_pointerStackPop(&MR_BackTraceStack);\r
+/* MR10 */    };\r
+\r
+       if ( p->jtype!=RuleBlk && /* MR14 */ !p->guess) TRAV(p->p2, k, rk, u);\r
+\r
+       if ( p->jtype==EndRule ) p->lock[k] = FALSE;/* unlock node */\r
+\r
+       if ( t==NULL ) return tmake(tnode(ALT), u, NULL);\r
+       return tmake(tnode(ALT), t, u, NULL);\r
+}\r
+\r
+Tree *\r
+#ifdef __USE_PROTOS\r
+tRuleRef( RuleRefNode *p, int k, set *rk_out )\r
+#else\r
+tRuleRef( p, k, rk_out )\r
+RuleRefNode *p;\r
+int k;\r
+set *rk_out;\r
+#endif\r
+{\r
+       int k2;\r
+       Tree *t=NULL, *u=NULL;\r
+       Junction *r;\r
+       set rk, rk2;\r
+       int save_halt;\r
+       RuleEntry *q = (RuleEntry *) hash_get(Rname, p->text);\r
+       \r
+#ifdef DBG_TRAV\r
+       fprintf(stderr, "tRuleRef: %s\n", p->text);\r
+#endif\r
+       if ( q == NULL )\r
+       {\r
+               TRAV(p->next, k, rk_out, t);/* ignore undefined rules */\r
+               return t;\r
+       }\r
+       rk = rk2 = empty;\r
+    if (RulePtr == NULL) fatal("RulePtr==NULL");\r
+       r = RulePtr[q->rulenum];\r
+       if ( r->lock[k] ) return NULL;\r
+       save_halt = r->end->halt;\r
+       r->end->halt = TRUE;            /* don't let reach fall off end of rule here */\r
+\r
+/* MR10 */    if (MR_MaintainBackTrace) {\r
+/* MR10 */      MR_pointerStackPush(&MR_BackTraceStack,p);\r
+/* MR10 */    };\r
+\r
+       TRAV(r, k, &rk, t);\r
+\r
+/* MR10 */    if (MR_MaintainBackTrace) {\r
+/* MR10 */      MR_pointerStackPop(&MR_BackTraceStack);\r
+/* MR10 */    };\r
+\r
+       r->end->halt = save_halt;\r
+#ifdef DBG_TREES\r
+       fprintf(stderr, "after ruleref, t is:"); preorder(t); fprintf(stderr, "\n");\r
+#endif\r
+       t = tshrink( t );\r
+       while ( !set_nil(rk) ) {        /* any k left to do? if so, link onto tree */\r
+               k2 = set_int(rk);\r
+               set_rm(k2, rk);\r
+\r
+/* MR10 */    if (MR_MaintainBackTrace) {\r
+/* MR10 */      MR_pointerStackPush(&MR_BackTraceStack,p);\r
+/* MR10 */    };\r
+\r
+               TRAV(p->next, k2, &rk2, u);\r
+\r
+/* MR10 */    if (MR_MaintainBackTrace) {\r
+/* MR10 */      MR_pointerStackPop(&MR_BackTraceStack);\r
+/* MR10 */    };\r
+\r
+               t = tlink(t, u, k2);    /* any alts missing k2 toks, add u onto end */\r
+        Tfree(u);               /* MR10 */\r
+       }\r
+       set_free(rk);                           /* rk is empty, but free it's memory */\r
+       set_orin(rk_out, rk2);          /* remember what we couldn't do */\r
+       set_free(rk2);\r
+       return t;\r
+}\r
+\r
+Tree *\r
+#ifdef __USE_PROTOS\r
+tToken( TokNode *p, int k, set *rk )\r
+#else\r
+tToken( p, k, rk )\r
+TokNode *p;\r
+int k;\r
+set *rk;\r
+#endif\r
+{\r
+       Tree *t=NULL, *tset=NULL, *u;\r
+\r
+       if (ConstrainSearch) {\r
+      if (MR_AmbSourceSearch) {\r
+               require(constrain>=fset&&constrain<=&(fset[CLL_k]),"tToken: constrain is not a valid set");\r
+      } else {\r
+               require(constrain>=fset&&constrain<=&(fset[LL_k]),"tToken: constrain is not a valid set");\r
+      };\r
+      constrain = &fset[maxk-k+1];\r
+       }\r
+\r
+#ifdef DBG_TRAV\r
+               fprintf(stderr, "tToken(%d): %s\n", k, TerminalString(p->token));\r
+               if ( ConstrainSearch ) {\r
+                       fprintf(stderr, "constrain is:"); s_fprT(stderr, *constrain); fprintf(stderr, "\n");\r
+               }\r
+#endif\r
+\r
+       /* is it a meta token (set of tokens)? */\r
+\r
+       if ( !set_nil(p->tset) )\r
+       {\r
+               unsigned e=0;\r
+               set a;\r
+               Tree *n, *tail = NULL;\r
+\r
+               if ( ConstrainSearch ) {\r
+          a = set_and(p->tset, *constrain);\r
+          if (set_nil(a)) {         /* MR10 */\r
+            set_free(a);            /* MR11 */\r
+            return NULL;            /* MR10 */\r
+          };                        /* MR10 */\r
+               } else {\r
+          a = set_dup(p->tset);\r
+        };\r
+\r
+               for (; !set_nil(a); set_rm(e, a))\r
+               {\r
+                       e = set_int(a);\r
+                       n = tnode(e);\r
+                       if ( tset==NULL ) { tset = n; tail = n; }\r
+                       else { tail->right = n; tail = n; }\r
+               }\r
+               set_free( a );\r
+       }\r
+       else if ( ConstrainSearch && !set_el(p->token, *constrain) )\r
+    {\r
+/*      fprintf(stderr, "ignoring token %s(%d)\n", TerminalString(p->token),\r
+                k);*/\r
+        return NULL;\r
+    }\r
+       else {\r
+        tset = tnode( p->token );\r
+    };\r
+\r
+/* MR10 */    if (MR_MaintainBackTrace) {\r
+/* MR10 */      if (k == 1) {\r
+/* MR10 */        MR_pointerStackPush(&MR_BackTraceStack,p);\r
+/* MR13 */        if (MR_SuppressSearch) {\r
+/* MR13 */          MR_suppressSearchReport();\r
+/* MR13 */        } else {\r
+/* MR10 */          MR_backTraceReport();\r
+/* MR13 */        };\r
+/* MR10 */        MR_pointerStackPop(&MR_BackTraceStack);\r
+/* MR11 */        Tfree(tset);\r
+/* MR11 */        return NULL;\r
+/* MR10 */      };\r
+/* MR10 */    };\r
+\r
+       if ( k == 1 ) return tset;\r
+\r
+    if (MR_MaintainBackTrace) {\r
+      MR_pointerStackPush(&MR_BackTraceStack,p);\r
+    };\r
+\r
+       TRAV(p->next, k-1, rk, t);\r
+\r
+    if (MR_MaintainBackTrace) {\r
+      Tfree(t);\r
+      Tfree(tset);\r
+      MR_pointerStackPop(&MR_BackTraceStack);\r
+      return NULL;\r
+    };\r
+\r
+       /* here, we are positive that, at least, this tree will not contribute\r
+        * to the LL(2) tree since it will be too shallow, IF t==NULL.\r
+        * If doing a context guard walk, then don't prune.\r
+        */\r
+       if ( t == NULL && !ContextGuardTRAV )   /* tree will be too shallow */\r
+       {\r
+               if ( tset!=NULL ) Tfree( tset );\r
+               return NULL;\r
+       }\r
+#ifdef DBG_TREES\r
+       fprintf(stderr, "tToken(%d)->next:",k); preorder(t); fprintf(stderr, "\n");\r
+#endif\r
+\r
+       /* if single token root, then just make new tree and return */\r
+    /* MR10 - set_nil(p->tset) isn't a good test because of ConstraintSearch */\r
+\r
+       if (tset->right == NULL) return tmake(tset, t, NULL);    /* MR10 */\r
+\r
+       /* here we must make a copy of t as a child of each element of the tset;\r
+        * e.g., "T1..T3 A" would yield ( nil ( T1 A ) ( T2 A ) ( T3 A ) )\r
+        */\r
+       for (u=tset; u!=NULL; u=u->right)\r
+       {\r
+               /* make a copy of t and hook it onto bottom of u */\r
+               u->down = tdup(t);\r
+       }\r
+       Tfree( t );\r
+#ifdef DBG_TREES\r
+       fprintf(stderr, "range is:"); preorder(tset); fprintf(stderr, "\n");\r
+#endif\r
+       return tset;\r
+}\r
+\r
+Tree *\r
+#ifdef __USE_PROTOS\r
+tAction( ActionNode *p, int k, set *rk )\r
+#else\r
+tAction( p, k, rk )\r
+ActionNode *p;\r
+int k;\r
+set *rk;\r
+#endif\r
+{\r
+       Tree        *t=NULL;\r
+    set         *save_fset=NULL;\r
+    int         i;\r
+\r
+       /* fprintf(stderr, "tAction\n"); */\r
+\r
+/*  An MR_SuppressSearch is looking for things that can be\r
+      reached even when the predicate is false.\r
+\r
+    There are three kinds of predicates:\r
+        plain:              r1: <<p>>? r2\r
+        guarded:            r1: (A)? => <<p>>? r2\r
+        ampersand style:    r1: (A)? && <<p>>? r2\r
+\r
+    Of the three kinds of predicates, only a guard predicate\r
+      has things which are reachable even when the predicate\r
+      is false.  To be reachable the constraint must *not*\r
+      match the guard.\r
+\r
+*/\r
+\r
+    if (p->is_predicate && MR_SuppressSearch) {\r
+\r
+      Predicate     *pred=p->guardpred;\r
+\r
+      if (pred == NULL) {\r
+        t=NULL;\r
+        goto EXIT;\r
+      };\r
+      constrain = &fset[maxk-k+1];\r
+      if (pred->k == 1) {\r
+        set     dif;\r
+        dif=set_dif(*constrain,pred->scontext[1]);\r
+        if (set_nil(dif)) {\r
+          set_free(dif);\r
+          t=NULL;\r
+          goto EXIT;\r
+        };\r
+        set_free(dif);\r
+      } else {\r
+        if (MR_tree_matches_constraints(k,constrain,pred->tcontext)) {\r
+          t=NULL;\r
+          goto EXIT;\r
+        };\r
+      }\r
+    };\r
+\r
+    /* The ampersand predicate differs from the\r
+         other predicates because its first set\r
+         is a subset of the first set behind the predicate\r
+\r
+            r1: (A)? && <<p>>? r2 ;\r
+            r2: A | B;\r
+\r
+       In this case first[1] of r1 is A, even\r
+         though first[1] of r2 is {A B}.\r
+    */\r
+\r
+    if (p->is_predicate && p->ampersandPred != NULL) {\r
+\r
+      Predicate     *pred=p->ampersandPred;\r
+      Tree          *tAND;\r
+      Tree          *tset;\r
+\r
+      if (k <= pred->k) {\r
+        if (MR_MaintainBackTrace) MR_pointerStackPush(&MR_BackTraceStack,p);\r
+        TRAV(p->guardNodes,k,rk,t);\r
+        if (MR_MaintainBackTrace) MR_pointerStackPop(&MR_BackTraceStack);\r
+        return t;\r
+      } else {\r
+        require (k>1,"tAction for ampersandpred: k <= 1");\r
+        if (ConstrainSearch) {\r
+          if (MR_AmbSourceSearch) {\r
+               require(constrain>=fset&&constrain<=&(fset[CLL_k]),\r
+                                "tToken: constrain is not a valid set");\r
+          } else {\r
+               require(constrain>=fset&&constrain<=&(fset[LL_k]),\r
+                                "tToken: constrain is not a valid set");\r
+          };\r
+          save_fset=(set *) calloc (CLL_k+1,sizeof(set));\r
+          require (save_fset != NULL,"tAction save_fset alloc");\r
+          for (i=1; i <= CLL_k ; i++) {\r
+            save_fset[i]=set_dup(fset[i]);\r
+          };\r
+          if (pred->k == 1) {\r
+            constrain = &fset[maxk-k+1];\r
+            set_andin(constrain,pred->scontext[1]);\r
+            if (set_nil(*constrain)) {\r
+              t=NULL;\r
+              goto EXIT;\r
+            };\r
+          } else {\r
+            constrain = &fset[maxk-k+1];\r
+            if (! MR_tree_matches_constraints(pred->k,constrain,pred->tcontext)) {\r
+               t=NULL;\r
+               goto EXIT;\r
+            };  /* end loop on i          */\r
+          }; /* end loop on pred scontext/tcontext */\r
+        }; /* end if on k > pred->k     */\r
+      }; /* end if on constrain search  */\r
+\r
+      TRAV(p->next,k,rk,t);\r
+\r
+      if (t != NULL) {\r
+        t=tshrink(t);\r
+        t=tflatten(t);\r
+        t=tleft_factor(t);\r
+        if (pred->tcontext != NULL) {\r
+          tAND=MR_computeTreeAND(t,pred->tcontext);\r
+        } else {\r
+          tset=MR_make_tree_from_set(pred->scontext[1]);\r
+          tAND=MR_computeTreeAND(t,tset);\r
+          Tfree(tset);\r
+        };\r
+        Tfree(t);\r
+        t=tAND;\r
+      };\r
+      goto EXIT;\r
+\r
+    }; /* end if on ampersand predicate */\r
+\r
+    TRAV(p->next,k,rk,t);\r
+\r
+EXIT:\r
+    if (save_fset != NULL) {\r
+      for (i=1 ; i <= CLL_k ; i++) {\r
+        set_free(fset[i]);\r
+        fset[i]=save_fset[i];\r
+      };\r
+      free ( (char *) save_fset);\r
+    };\r
+       return t;\r
+}\r
+\r
+/* see if e exists in s as a possible input permutation (e is always a chain) */\r
+\r
+int\r
+#ifdef __USE_PROTOS\r
+tmember( Tree *e, Tree *s )\r
+#else\r
+tmember( e, s )\r
+Tree *e;\r
+Tree *s;\r
+#endif\r
+{\r
+       if ( e==NULL||s==NULL ) return 0;\r
+/** fprintf(stderr, "tmember(");\r
+***    preorder(e); fprintf(stderr, ",");\r
+***    preorder(s); fprintf(stderr, " )\n");\r
+*/\r
+       if ( s->token == ALT && s->right == NULL ) return tmember(e, s->down);\r
+       if ( e->token!=s->token )\r
+       {\r
+               if ( s->right==NULL ) return 0;\r
+               return tmember(e, s->right);\r
+       }\r
+       if ( e->down==NULL && s->down == NULL ) return 1;\r
+       if ( tmember(e->down, s->down) ) return 1;\r
+       if ( s->right==NULL ) return 0;\r
+       return tmember(e, s->right);\r
+}\r
+\r
+/* see if e exists in s as a possible input permutation (e is always a chain);\r
+ * Only check s to the depth of e.  In other words, 'e' can be a shorter\r
+ * sequence than s.\r
+ */\r
+int\r
+#ifdef __USE_PROTOS\r
+tmember_constrained( Tree *e, Tree *s)\r
+#else\r
+tmember_constrained( e, s )\r
+Tree *e;\r
+Tree *s;\r
+#endif\r
+{\r
+       if ( e==NULL||s==NULL ) return 0;\r
+/**    fprintf(stderr, "tmember_constrained(");\r
+***    preorder(e); fprintf(stderr, ",");\r
+***    preorder(s); fprintf(stderr, " )\n");\r
+**/\r
+       if ( s->token == ALT && s->right == NULL )\r
+               return tmember_constrained(e, s->down);\r
+       if ( e->token!=s->token )\r
+       {\r
+               if ( s->right==NULL ) return 0;\r
+               return tmember_constrained(e, s->right);\r
+       }\r
+       if ( e->down == NULL ) return 1; /* if s is matched to depth of e return */\r
+       if ( tmember_constrained(e->down, s->down) ) return 1;\r
+       if ( s->right==NULL ) return 0;\r
+       return tmember_constrained(e, s->right);\r
+}\r
+\r
+/* combine (? (A t) ... (A u) ...) into (? (A t u)) */\r
+Tree *\r
+#ifdef __USE_PROTOS\r
+tleft_factor( Tree *t )\r
+#else\r
+tleft_factor( t )\r
+Tree *t;\r
+#endif\r
+{\r
+       Tree *u, *v, *trail, *w;\r
+\r
+       /* left-factor what is at this level */\r
+       if ( t == NULL ) return NULL;\r
+       for (u=t; u!=NULL; u=u->right)\r
+       {\r
+               trail = u;\r
+               v=u->right;\r
+               while ( v!=NULL )\r
+               {\r
+                       if ( u->token == v->token )\r
+                       {\r
+                               if ( u->down!=NULL )\r
+                               {\r
+                                       for (w=u->down; w->right!=NULL; w=w->right) {;}\r
+                                       w->right = v->down;     /* link children together */\r
+                               }\r
+                               else u->down = v->down;\r
+                               trail->right = v->right;                /* unlink factored node */\r
+                               _Tfree( v );\r
+                               v = trail->right;\r
+                       }\r
+                       else {trail = v; v=v->right;}\r
+               }\r
+       }\r
+       /* left-factor what is below */\r
+       for (u=t; u!=NULL; u=u->right) u->down = tleft_factor( u->down );\r
+       return t;\r
+}\r
+\r
+/* remove the permutation p from t if present */\r
+Tree *\r
+#ifdef __USE_PROTOS\r
+trm_perm( Tree *t, Tree *p )\r
+#else\r
+trm_perm( t, p )\r
+Tree *t;\r
+Tree *p;\r
+#endif\r
+{\r
+       /*\r
+       fprintf(stderr, "trm_perm(");\r
+       preorder(t); fprintf(stderr, ",");\r
+       preorder(p); fprintf(stderr, " )\n");\r
+       */\r
+       if ( t == NULL || p == NULL ) return NULL;\r
+       if ( t->token == ALT )\r
+       {\r
+               t->down = trm_perm(t->down, p);\r
+               if ( t->down == NULL )                          /* nothing left below, rm cur node */\r
+               {\r
+                       Tree *u = t->right;\r
+                       _Tfree( t );\r
+                       return trm_perm(u, p);\r
+               }\r
+               t->right = trm_perm(t->right, p);       /* look for more instances of p */\r
+               return t;\r
+       }\r
+       if ( p->token != t->token )                             /* not found, try a sibling */\r
+       {\r
+               t->right = trm_perm(t->right, p);\r
+               return t;\r
+       }\r
+       t->down = trm_perm(t->down, p->down);\r
+       if ( t->down == NULL )                                  /* nothing left below, rm cur node */\r
+       {\r
+               Tree *u = t->right;\r
+               _Tfree( t );\r
+               return trm_perm(u, p);\r
+       }\r
+       t->right = trm_perm(t->right, p);               /* look for more instances of p */\r
+       return t;\r
+}\r
+\r
+/* add the permutation 'perm' to the LL_k sets in 'fset' */\r
+void\r
+#ifdef __USE_PROTOS\r
+tcvt( set *fset, Tree *perm )\r
+#else\r
+tcvt( fset, perm )\r
+set *fset;\r
+Tree *perm;\r
+#endif\r
+{\r
+       if ( perm==NULL ) return;\r
+       set_orel(perm->token, fset);\r
+       tcvt(fset+1, perm->down);\r
+}\r
+\r
+/* for each element of ftbl[k], make it the root of a tree with permute(ftbl[k+1])\r
+ * as a child.\r
+ */\r
+Tree *\r
+#ifdef __USE_PROTOS\r
+permute( int k, int max_k )\r
+#else\r
+permute( k, max_k )\r
+int k, max_k;\r
+#endif\r
+{\r
+       Tree *t, *u;\r
+       \r
+       if ( k>max_k ) return NULL;\r
+       if ( ftbl[k][findex[k]] == nil ) return NULL;\r
+       t = permute(k+1, max_k);\r
+       if ( t==NULL&&k<max_k )         /* no permutation left below for k+1 tokens? */\r
+       {\r
+               findex[k+1] = 0;\r
+               (findex[k])++;                  /* try next token at this k */\r
+               return permute(k, max_k);\r
+       }\r
+       \r
+       u = tmake(tnode(ftbl[k][findex[k]]), t, NULL);\r
+       if ( k == max_k ) (findex[k])++;\r
+       return u;\r
+}\r
+\r
+/* Compute LL(k) trees for alts alt1 and alt2 of p.\r
+ * function result is tree of ambiguous input permutations\r
+ *\r
+ * ALGORITHM may change to look for something other than LL_k size\r
+ * trees ==> maxk will have to change.\r
+ */\r
+Tree *\r
+#ifdef __USE_PROTOS\r
+VerifyAmbig( Junction *alt1, Junction *alt2, unsigned **ft, set *fs, Tree **t, Tree **u, int *numAmbig )\r
+#else\r
+VerifyAmbig( alt1, alt2, ft, fs, t, u, numAmbig )\r
+Junction *alt1;\r
+Junction *alt2;\r
+unsigned **ft;\r
+set *fs;\r
+Tree **t;\r
+Tree **u;\r
+int *numAmbig;\r
+#endif\r
+{\r
+       set rk;\r
+       Tree *perm, *ambig=NULL;\r
+       Junction *p;\r
+       int k;\r
+    int    tnodes_at_start=TnodesAllocated;\r
+    int    tnodes_at_end;\r
+    int    tnodes_used;\r
+    set    *save_fs;\r
+    int    j;\r
+\r
+    save_fs=(set *) calloc(CLL_k+1,sizeof(set));\r
+    require(save_fs != NULL,"save_fs calloc");\r
+\r
+    for (j=0; j <= CLL_k ; j++) save_fs[j]=set_dup(fs[j]);\r
+\r
+       maxk = LL_k;                            /* NOTE: for now, we look for LL_k */\r
+       ftbl = ft;\r
+       fset = fs;\r
+       constrain = &(fset[1]);\r
+       findex = (int *) calloc(LL_k+1, sizeof(int));\r
+       if ( findex == NULL )\r
+       {\r
+               fprintf(stderr, ErrHdr, FileStr[CurAmbigfile], CurAmbigline);\r
+               fprintf(stderr, " out of memory while analyzing alts %d and %d of %s\n",\r
+                                               CurAmbigAlt1,\r
+                                               CurAmbigAlt2,\r
+                                               CurAmbigbtype);\r
+               exit(PCCTS_EXIT_FAILURE);\r
+       }\r
+       for (k=1; k<=LL_k; k++) findex[k] = 0;\r
+\r
+       rk = empty;\r
+       ConstrainSearch = 1;    /* consider only tokens in ambig sets */\r
+\r
+       p = analysis_point((Junction *)alt1->p1);\r
+       TRAV(p, LL_k, &rk, *t);\r
+       *t = tshrink( *t );\r
+       *t = tflatten( *t );\r
+       *t = tleft_factor( *t );    /* MR10 */\r
+       *t = prune(*t, LL_k);\r
+       *t = tleft_factor( *t );\r
+\r
+/***   fprintf(stderr, "after shrink&flatten&prune&left_factor:"); preorder(*t); fprintf(stderr, "\n");*/\r
+       if ( *t == NULL )\r
+       {\r
+/***   fprintf(stderr, "TreeIncomplete --> no LL(%d) ambiguity\n", LL_k);*/\r
+               Tfree( *t );    /* kill if impossible to have ambig */\r
+               *t = NULL;\r
+       }\r
+\r
+       p = analysis_point((Junction *)alt2->p1);\r
+\r
+       TRAV(p, LL_k, &rk, *u);\r
+       *u = tshrink( *u );\r
+       *u = tflatten( *u );\r
+       *t = tleft_factor( *t );    /* MR10 */\r
+       *u = prune(*u, LL_k);\r
+       *u = tleft_factor( *u );\r
+/*     fprintf(stderr, "after shrink&flatten&prune&lfactor:"); preorder(*u); fprintf(stderr, "\n");*/\r
+       if ( *u == NULL )\r
+       {\r
+/*             fprintf(stderr, "TreeIncomplete --> no LL(%d) ambiguity\n", LL_k);*/\r
+               Tfree( *u );\r
+               *u = NULL;\r
+       }\r
+\r
+       for (k=1; k<=LL_k; k++) set_clr( fs[k] );\r
+\r
+       ambig = tnode(ALT);\r
+       k = 0;\r
+       if ( *t!=NULL && *u!=NULL )\r
+       {\r
+               while ( (perm=permute(1,LL_k))!=NULL )\r
+               {\r
+/*                     fprintf(stderr, "chk perm:"); preorder(perm); fprintf(stderr, "\n");*/\r
+                       if ( tmember(perm, *t) && tmember(perm, *u) )\r
+                       {\r
+/*                             fprintf(stderr, "ambig upon"); preorder(perm); fprintf(stderr, "\n");*/\r
+\r
+                               k++;\r
+                               perm->right = ambig->down;\r
+                               ambig->down = perm;\r
+                               tcvt(&(fs[1]), perm);\r
+                       }\r
+                       else Tfree( perm );\r
+               }\r
+       }\r
+\r
+    for (j=0; j <= CLL_k ; j++) fs[j]=save_fs[j];\r
+    free( (char *) save_fs);\r
+\r
+    tnodes_at_end=TnodesAllocated;\r
+    tnodes_used=tnodes_at_end - tnodes_at_start;\r
+\r
+    if (TnodesReportThreshold > 0 && tnodes_used > TnodesReportThreshold) {\r
+      fprintf(stdout,"There were %d tuples whose ambiguity could not be resolved by full lookahead\n",k);\r
+      fprintf(stdout,"There were %d tnodes created to resolve ambiguity between:\n\n",tnodes_used);\r
+      fprintf(stdout,"  Choice 1: %s  line %d  file %s\n",\r
+                                 MR_ruleNamePlusOffset( (Node *) alt1),alt1->line,FileStr[alt1->file]);\r
+      fprintf(stdout,"  Choice 2: %s  line %d  file %s\n",\r
+                                 MR_ruleNamePlusOffset( (Node *) alt2),alt2->line,FileStr[alt2->file]);\r
+      for (j=1; j <= CLL_k ; j++) {\r
+        fprintf(stdout,"\n    Intersection of lookahead[%d] sets:\n",j);\r
+        MR_dumpTokenSet(stdout,2,fs[j]);\r
+      };\r
+      fprintf(stdout,"\n");\r
+    };\r
+\r
+       *numAmbig = k;\r
+       if ( ambig->down == NULL ) {_Tfree(ambig); ambig = NULL;}\r
+       free( (char *)findex );\r
+/*     fprintf(stderr, "final ambig:"); preorder(ambig); fprintf(stderr, "\n");*/\r
+       return ambig;\r
+}\r
+\r
+static Tree *\r
+#ifdef __USE_PROTOS\r
+bottom_of_chain( Tree *t )\r
+#else\r
+bottom_of_chain( t )\r
+Tree *t;\r
+#endif\r
+{\r
+    if ( t==NULL ) return NULL;\r
+    for (; t->down != NULL; t=t->down) {;}\r
+    return t;\r
+}\r
+\r
+/*\r
+ * Make a tree from k sets where the degree of the first k-1 sets is 1.\r
+ */\r
+Tree *\r
+#ifdef __USE_PROTOS\r
+make_tree_from_sets( set *fset1, set *fset2 )\r
+#else\r
+make_tree_from_sets( fset1, fset2 )\r
+set *fset1;\r
+set *fset2;\r
+#endif\r
+{\r
+       set inter;\r
+       int i;\r
+       Tree *t=NULL, *n, *u;\r
+       unsigned *p,*q;\r
+       require(LL_k>1, "make_tree_from_sets: LL_k must be > 1");\r
+\r
+       /* do the degree 1 sets first */\r
+       for (i=1; i<=LL_k-1; i++)\r
+       {\r
+               inter = set_and(fset1[i], fset2[i]);\r
+               require(set_deg(inter)==1, "invalid set to tree conversion");\r
+               n = tnode(set_int(inter));\r
+               if (t==NULL) t=n; else tmake(t, n, NULL);\r
+               set_free(inter);\r
+       }\r
+\r
+       /* now add the chain of tokens at depth k */\r
+       u = bottom_of_chain(t);\r
+       inter = set_and(fset1[LL_k], fset2[LL_k]);\r
+       if ( (q=p=set_pdq(inter)) == NULL ) fatal_internal("Can't alloc space for set_pdq");\r
+       /* first one is linked to bottom, then others are sibling linked */\r
+       n = tnode(*p++);\r
+       u->down = n;\r
+       u = u->down;\r
+       while ( *p != nil )\r
+       {\r
+               n = tnode(*p);\r
+               u->right = n;\r
+               u = u->right;\r
+               p++;\r
+       }\r
+       free((char *)q);\r
+\r
+       return t;\r
+}\r
+\r
+/* create and return the tree of lookahead k-sequences that are in t, but not\r
+ * in the context of predicates in predicate list p.\r
+ */\r
+Tree *\r
+#ifdef __USE_PROTOS\r
+tdif( Tree *ambig_tuples, Predicate *p, set *fset1, set *fset2 )\r
+#else\r
+tdif( ambig_tuples, p, fset1, fset2 )\r
+Tree *ambig_tuples;\r
+Predicate *p;\r
+set *fset1;\r
+set *fset2;\r
+#endif\r
+{\r
+       unsigned **ft;\r
+       Tree *dif=NULL;\r
+       Tree *perm;\r
+       set b;\r
+       int i,k;\r
+\r
+       if ( p == NULL ) return tdup(ambig_tuples);\r
+\r
+       ft = (unsigned **) calloc(CLL_k+1, sizeof(unsigned *));\r
+       require(ft!=NULL, "cannot allocate ft");\r
+       for (i=1; i<=CLL_k; i++)\r
+       {\r
+               b = set_and(fset1[i], fset2[i]);\r
+               ft[i] = set_pdq(b);\r
+               set_free(b);\r
+       }\r
+       findex = (int *) calloc(LL_k+1, sizeof(int));\r
+       if ( findex == NULL )\r
+       {\r
+               fatal_internal("out of memory in tdif while checking predicates");\r
+       }\r
+       for (k=1; k<=LL_k; k++) findex[k] = 0;\r
+\r
+#ifdef DBG_TRAV\r
+       fprintf(stderr, "tdif_%d[", p->k);\r
+       preorder(ambig_tuples);\r
+       fprintf(stderr, ",");\r
+       preorder(p->tcontext);\r
+       fprintf(stderr, "] =");\r
+#endif\r
+\r
+       ftbl = ft;\r
+       while ( (perm=permute(1,p->k))!=NULL )\r
+       {\r
+#ifdef DBG_TRAV\r
+               fprintf(stderr, "test perm:"); preorder(perm); fprintf(stderr, "\n");\r
+#endif\r
+               if ( tmember_constrained(perm, ambig_tuples) &&\r
+                        !tmember_of_context(perm, p) )\r
+               {\r
+#ifdef DBG_TRAV\r
+                       fprintf(stderr, "satisfied upon"); preorder(perm); fprintf(stderr, "\n");\r
+#endif\r
+                       k++;\r
+                       if ( dif==NULL ) dif = perm;\r
+                       else\r
+                       {\r
+                               perm->right = dif;\r
+                               dif = perm;\r
+                       }\r
+               }\r
+               else Tfree( perm );\r
+       }\r
+\r
+#ifdef DBG_TRAV\r
+       preorder(dif);\r
+       fprintf(stderr, "\n");\r
+#endif\r
+\r
+       for (i=1; i<=CLL_k; i++) free( (char *)ft[i] );\r
+       free((char *)ft);\r
+       free((char *)findex);\r
+\r
+       return dif;\r
+}\r
+\r
+/* is lookahead sequence t a member of any context tree for any\r
+ * predicate in p?\r
+ */\r
+static int\r
+#ifdef __USE_PROTOS\r
+tmember_of_context( Tree *t, Predicate *p )\r
+#else\r
+tmember_of_context( t, p )\r
+Tree *t;\r
+Predicate *p;\r
+#endif\r
+{\r
+       for (; p!=NULL; p=p->right)\r
+       {\r
+               if ( p->expr==PRED_AND_LIST || p->expr==PRED_OR_LIST )\r
+                       return tmember_of_context(t, p->down);\r
+               if ( tmember_constrained(t, p->tcontext) ) return 1;\r
+               if ( tmember_of_context(t, p->down) ) return 1;\r
+       }\r
+       return 0;\r
+}\r
+\r
+int\r
+#ifdef __USE_PROTOS\r
+is_single_tuple( Tree *t )\r
+#else\r
+is_single_tuple( t )\r
+Tree *t;\r
+#endif\r
+{\r
+       if ( t == NULL ) return 0;\r
+       if ( t->right != NULL ) return 0;\r
+       if ( t->down == NULL ) return 1;\r
+       return is_single_tuple(t->down);\r
+}\r
+\r
+\r
+/* MR10 Check that a context guard contains only allowed things */\r
+/* MR10   (mainly token references).                            */\r
+\r
+#ifdef __USE_PROTOS\r
+int contextGuardOK(Node *p,int h,int *hmax)\r
+#else\r
+int contextGuardOK(p,h,hmax)\r
+  Node  *p;\r
+  int   h;\r
+  int   *hmax;\r
+#endif\r
+{\r
+    Junction     *j;\r
+    TokNode      *tn;\r
+\r
+    if (p == NULL) return 1;\r
+    if (p->ntype == nToken) {\r
+      h++;\r
+      if (h > *hmax) *hmax=h;\r
+      tn=(TokNode *)p;\r
+      if (tn->el_label != NULL) {\r
+        warnFL(eMsg1("a label (\"%s\") for a context guard element is meaningless",tn->el_label),\r
+                             FileStr[p->file],p->line);\r
+      };\r
+      return contextGuardOK( ( (TokNode *) p)->next,h,hmax);\r
+    } else if (p->ntype == nAction) {\r
+      goto Fail;\r
+    } else if (p->ntype == nRuleRef) {\r
+      goto Fail;\r
+    } else {\r
+      require (p->ntype == nJunction,"Unexpected ntype");\r
+      j=(Junction *) p;\r
+      if (j->jtype != Generic &&\r
+          j->jtype != aSubBlk &&        /* pretty sure this one is allowed */\r
+/****     j->jtype != aOptBlk && ****/  /* pretty sure this one is allowed */ /* MR11 not any more ! */\r
+          j->jtype != EndBlk) {\r
+        errFL("A context guard may not contain an option block: {...} or looping block: (...)* or (...)+",\r
+                  FileStr[p->file],p->line);\r
+        contextGuardOK(j->p1,h,hmax);\r
+        return 0;\r
+      };\r
+      /* do both p1 and p2 so use | rather than ||  */\r
+      return contextGuardOK(j->p2,h,hmax) | contextGuardOK(j->p1,h,hmax);\r
+    };\r
+Fail:\r
+    errFL("A context guard may contain only Token references - guard will be ignored",\r
+                             FileStr[p->file],p->line);\r
+    contextGuardOK( ( (ActionNode *) p)->next,h,hmax);\r
+    return 0;\r
+}\r
+\r
+/*\r
+ * Look at a (...)? generalized-predicate context-guard and compute\r
+ * either a lookahead set (k==1) or a lookahead tree for k>1.  The\r
+ * k level is determined by the guard itself rather than the LL_k\r
+ * variable.  For example, ( A B )? is an LL(2) guard and ( ID )?\r
+ * is an LL(1) guard.  For the moment, you can only have a single\r
+ * tuple in the guard.  Physically, the block must look like this\r
+ *   --o-->TOKEN-->o-->o-->TOKEN-->o-- ... -->o-->TOKEN-->o--\r
+ * An error is printed for any other type.\r
+ */\r
+Predicate *\r
+#ifdef __USE_PROTOS\r
+computePredFromContextGuard(Graph blk,int *msgDone)    /* MR10 */\r
+#else\r
+computePredFromContextGuard(blk,msgDone)               /* MR10 */\r
+  Graph     blk;\r
+  int       *msgDone;                                       /* MR10 */\r
+#endif\r
+{\r
+    Junction *junc = (Junction *)blk.left, *p;\r
+    Tree        *t=NULL;\r
+       Predicate   *pred = NULL;\r
+       set         scontext, rk;\r
+    int         ok;\r
+    int         hmax=0;\r
+\r
+    require(junc!=NULL && junc->ntype == nJunction, "bad context guard");\r
+\r
+/* MR10 Check for anything other than Tokens and generic junctions */\r
+\r
+    *msgDone=0;                                             /* MR10 */\r
+    ok=contextGuardOK( (Node *)junc,0,&hmax);               /* MR10 */\r
+    if (! ok) {                                             /* MR10 */\r
+      *msgDone=1;                                           /* MR10 */\r
+      return NULL;                                          /* MR10 */\r
+    };                                                      /* MR10 */\r
+    if (hmax == 0) {\r
+errFL("guard is 0 tokens long",FileStr[junc->file],junc->line);          /* MR11 */\r
+      *msgDone=1;\r
+      return NULL;\r
+    };\r
+    if (hmax > CLL_k) {                                     /* MR10 */\r
+errFL(eMsgd2("guard is %d tokens long - lookahead is limited to max(k,ck)==%d", /* MR10 */\r
+        hmax,CLL_k),                                        /* MR10 */\r
+        FileStr[junc->file],junc->line);                    /* MR10 */\r
+      *msgDone=1;                                           /* MR10 */\r
+      return NULL;                                          /* MR10 */\r
+    };                                                      /* MR10 */\r
+\r
+       rk = empty;\r
+       p = junc;\r
+       pred = new_pred();\r
+       pred->k = hmax;     /* MR10 should be CLL_k, not LLK ? */\r
+       if (hmax > 1 )      /* MR10 was LL_k                   */\r
+       {\r
+               ConstrainSearch = 0;\r
+               ContextGuardTRAV = 1;\r
+               TRAV(p, hmax, &rk, t);  /* MR10 was LL_k */\r
+               ContextGuardTRAV = 0;\r
+               set_free(rk);\r
+               t = tshrink( t );\r
+               t = tflatten( t );\r
+               t = tleft_factor( t );\r
+/*\r
+               fprintf(stderr, "ctx guard:");\r
+               preorder(t);\r
+               fprintf(stderr, "\n");\r
+*/\r
+               pred->tcontext = t;\r
+       }\r
+       else\r
+       {\r
+               REACH(p, 1, &rk, scontext);\r
+               require(set_nil(rk), "rk != nil");\r
+               set_free(rk);\r
+/*\r
+               fprintf(stderr, "LL(1) ctx guard is:");\r
+               s_fprT(stderr, scontext);\r
+               fprintf(stderr, "\n");\r
+*/\r
+               pred->scontext[1] = scontext;\r
+       }\r
+\r
+    list_add(&ContextGuardPredicateList,pred);     /* MR13 */\r
+\r
+       return pred;\r
+}\r
+\r
+/* MR13\r
+   When the context guard is originally computed the\r
+   meta-tokens are not known.\r
+*/\r
+\r
+#ifdef __USE_PROTOS\r
+void recomputeContextGuard(Predicate *pred)\r
+#else\r
+void recomputeContextGuard(pred)\r
+    Predicate   *pred;\r
+#endif\r
+{\r
+    Tree *          t=NULL;\r
+       set             scontext;\r
+    set             rk;\r
+    ActionNode *    actionNode;\r
+    Junction *      p;\r
+\r
+    actionNode=pred->source;\r
+    require (actionNode != NULL,"context predicate's source == NULL");\r
+\r
+    p=actionNode->guardNodes;\r
+    require (p != NULL,"context predicate's guardNodes == NULL");\r
+\r
+       rk = empty;\r
+       if (pred->k > 1 )\r
+       {\r
+               ConstrainSearch = 0;\r
+               ContextGuardTRAV = 1;\r
+               TRAV(p, pred->k, &rk, t);\r
+               ContextGuardTRAV = 0;\r
+               set_free(rk);\r
+               t = tshrink( t );\r
+               t = tflatten( t );\r
+               t = tleft_factor( t );\r
+        Tfree(pred->tcontext);\r
+               pred->tcontext = t;\r
+       }\r
+       else\r
+       {\r
+               REACH(p, 1, &rk, scontext);\r
+               require(set_nil(rk), "rk != nil");\r
+               set_free(rk);\r
+        set_free(pred->scontext[1]);\r
+               pred->scontext[1] = scontext;\r
+       }\r
+}\r
+\r
+/* MR11 - had enough of flags yet ? */\r
+\r
+int     MR_AmbSourceSearch=0;\r
+int     MR_AmbSourceSearchGroup=0;\r
+int     MR_AmbSourceSearchChoice=0;\r
+int     MR_AmbSourceSearchLimit=0;\r
+int     MR_matched_AmbAidRule=0;\r
+\r
+static    set         *matchSets[2]={NULL,NULL};\r
+static    int         *tokensInChain=NULL;\r
+static    Junction    *MR_AmbSourceSearchJ[2];\r
+\r
+void MR_traceAmbSourceKclient()\r
+{\r
+  int       i;\r
+  set       *save_fset;\r
+  int       save_ConstrainSearch;\r
+  set       incomplete;\r
+  Tree      *t;\r
+\r
+  if (matchSets[0] == NULL) {\r
+    matchSets[0]=(set *) calloc (CLL_k+1,sizeof(set));\r
+    require (matchSets[0] != NULL,"matchSets[0] alloc");\r
+    matchSets[1]=(set *) calloc (CLL_k+1,sizeof(set));\r
+    require (matchSets[1] != NULL,"matchSets[1] alloc");\r
+  };\r
+\r
+  for (i=1 ; i <= MR_AmbSourceSearchLimit ; i++) {\r
+    set_clr(matchSets[0][i]);\r
+    set_orel( (unsigned) tokensInChain[i],\r
+                              &matchSets[0][i]);\r
+    set_clr(matchSets[1][i]);\r
+    set_orel( (unsigned) tokensInChain[i],\r
+                              &matchSets[1][i]);\r
+  };\r
+\r
+  save_fset=fset;\r
+  save_ConstrainSearch=ConstrainSearch;\r
+\r
+\r
+\r
+  for (i=0 ; i < 2 ; i++) {\r
+\r
+#if 0\r
+**    fprintf(stdout,"  Choice:%d  Depth:%d  ",i+1,MR_AmbSourceSearchLimit);\r
+**    fprintf(stdout,"(");\r
+**    for (j=1 ; j <= MR_AmbSourceSearchLimit ; j++) {\r
+**      if (j != 1) fprintf(stdout," ");\r
+**      fprintf(stdout,"%s",TerminalString(tokensInChain[j]));\r
+**    };\r
+**    fprintf(stdout,")\n\n");\r
+#endif\r
+\r
+    fset=matchSets[i];\r
+\r
+    MR_AmbSourceSearch=1;\r
+    MR_MaintainBackTrace=1;\r
+    MR_AmbSourceSearchChoice=i;\r
+    ConstrainSearch=1;\r
+\r
+    maxk = MR_AmbSourceSearchLimit;\r
+\r
+    incomplete=empty;\r
+    t=NULL;\r
+\r
+    constrain = &(fset[1]);\r
+    MR_pointerStackReset(&MR_BackTraceStack);\r
+\r
+    TRAV(MR_AmbSourceSearchJ[i],maxk,&incomplete,t);\r
+\r
+    Tfree(t);\r
+\r
+    require (set_nil(incomplete),"MR_traceAmbSourceK TRAV incomplete");\r
+    require (MR_BackTraceStack.count == 0,"K: MR_BackTraceStack.count != 0");\r
+\r
+    set_free(incomplete);\r
+  };\r
+\r
+  ConstrainSearch=save_ConstrainSearch;\r
+  fset=save_fset;\r
+  MR_AmbSourceSearch=0;\r
+  MR_MaintainBackTrace=0;\r
+  MR_AmbSourceSearchChoice=0;\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+Tree *tTrunc(Tree *t,int depth)\r
+#else\r
+Tree *tTrunc(t,depth)\r
+  Tree  *t;\r
+#endif\r
+{\r
+    Tree    *u;\r
+\r
+    require ( ! (t == NULL && depth > 0),"tree too short");\r
+\r
+    if (depth == 0) return NULL;\r
+\r
+    if (t->token == ALT) {\r
+      u=tTrunc(t->down,depth);\r
+    } else {\r
+      u=tnode(t->token);\r
+      u->down=tTrunc(t->down,depth-1);\r
+    };\r
+    if (t->right != NULL) u->right=tTrunc(t->right,depth);\r
+    return u;\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+void MR_iterateOverTree(Tree *t,int chain[])\r
+#else\r
+void MR_iterateOverTree(t,chain)\r
+  Tree          *t;\r
+  int           chain[];\r
+#endif\r
+{\r
+  if (t == NULL) return;\r
+  chain[0]=t->token;\r
+  if (t->down != NULL) {\r
+    MR_iterateOverTree(t->down,&chain[1]);\r
+  } else {\r
+    MR_traceAmbSourceKclient();\r
+  };\r
+  MR_iterateOverTree(t->right,&chain[0]);\r
+  chain[0]=0;\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+void MR_traceAmbSourceK(Tree *t,Junction *alt1,Junction *alt2)\r
+#else\r
+void MR_traceAmbSourceK(t,alt1,alt2)\r
+  Tree      *t;\r
+  Junction  *alt1;\r
+  Junction  *alt2;\r
+#endif\r
+{\r
+    int         i;\r
+    int         depth;\r
+    int         maxDepth;\r
+    Tree        *truncatedTree;\r
+\r
+    if (MR_AmbAidRule == NULL) return;\r
+\r
+    if ( ! (\r
+            strcmp(MR_AmbAidRule,alt1->rname) == 0 ||\r
+            strcmp(MR_AmbAidRule,alt2->rname) == 0 ||\r
+            MR_AmbAidLine==alt1->line ||\r
+            MR_AmbAidLine==alt2->line\r
+           )\r
+       ) return;\r
+\r
+    MR_matched_AmbAidRule++;\r
+\r
+    /* there are no token sets in trees, only in TokNodes */\r
+\r
+    MR_AmbSourceSearchJ[0]=analysis_point( (Junction *) alt1->p1);\r
+    MR_AmbSourceSearchJ[1]=analysis_point( (Junction *) alt2->p1);\r
+\r
+    if (tokensInChain == NULL) {\r
+      tokensInChain=(int *) calloc (CLL_k+1,sizeof(int));\r
+      require (tokensInChain != NULL,"tokensInChain alloc");\r
+    };\r
+\r
+    MR_AmbSourceSearchGroup=0;\r
+\r
+    fprintf(stdout,"\n");\r
+    fprintf(stdout,"  Ambiguity Aid                 ");\r
+    fprintf(stdout,\r
+                (MR_AmbAidDepth <= LL_k ?\r
+                    "(-k %d  -aa %s  %s  -aad %d)\n\n" :\r
+                        "(-k %d  -aa %s  %s  [-k value limits -aad %d])\n\n"),\r
+                LL_k,\r
+                MR_AmbAidRule,\r
+                (MR_AmbAidMultiple ? "-aam" : ""),\r
+                MR_AmbAidDepth);\r
+\r
+    for (i=0 ; i < 2 ; i++) {\r
+      fprintf(stdout,"    Choice %d: %-25s  line %d  file %s\n",\r
+                  (i+1),\r
+                  MR_ruleNamePlusOffset( (Node *) MR_AmbSourceSearchJ[i]),\r
+                  MR_AmbSourceSearchJ[i]->line,\r
+                  FileStr[MR_AmbSourceSearchJ[i]->file]);\r
+    };\r
+\r
+    fprintf(stdout,"\n");\r
+\r
+    if (MR_AmbAidDepth < LL_k) {\r
+      maxDepth=MR_AmbAidDepth;\r
+    } else {\r
+      maxDepth=LL_k;\r
+    };\r
+\r
+    for (depth=1 ; depth <= maxDepth; depth++) {\r
+      MR_AmbSourceSearchLimit=depth;\r
+      if (depth < LL_k) {\r
+        truncatedTree=tTrunc(t,depth);\r
+        truncatedTree=tleft_factor(truncatedTree);\r
+        MR_iterateOverTree(truncatedTree,&tokensInChain[1]);    /* <===== */\r
+        Tfree(truncatedTree);\r
+      } else {\r
+        MR_iterateOverTree(t,tokensInChain);                /* <===== */\r
+      };\r
+      fflush(stdout);\r
+      fflush(stderr);\r
+    };\r
+\r
+    fprintf(stdout,"\n");\r
+    MR_AmbSourceSearch=0;\r
+    MR_MaintainBackTrace=0;\r
+    MR_AmbSourceSearchGroup=0;\r
+    MR_AmbSourceSearchChoice=0;\r
+    MR_AmbSourceSearchLimit=0;\r
+\r
+}\r
+\r
+\r
+/* this if for k=1 grammars only\r
+\r
+   this is approximate only because of the limitations of linear\r
+   approximation lookahead.  Don't want to do a k=3 search when\r
+   the user only specified a ck=3 grammar\r
+*/\r
+\r
+#ifdef __USE_PROTOS\r
+void MR_traceAmbSource(set *matchSets,Junction *alt1, Junction *alt2)\r
+#else\r
+void MR_traceAmbSource(matchSets,alt1,alt2)\r
+  set       *matchSets;\r
+  Junction  *alt1;\r
+  Junction  *alt2;\r
+#endif\r
+{\r
+    set         *save_fset;\r
+    Junction    *p[2];\r
+    int         i;\r
+    int         j;\r
+    set         *dup_matchSets;\r
+    set         intersection;\r
+    set         incomplete;\r
+    set         tokensUsed;\r
+    int         depth;\r
+\r
+    if (MR_AmbAidRule == NULL) return;\r
+    if ( ! (\r
+            strcmp(MR_AmbAidRule,alt1->rname) == 0 ||\r
+            strcmp(MR_AmbAidRule,alt2->rname) == 0 ||\r
+            MR_AmbAidLine==alt1->line ||\r
+            MR_AmbAidLine==alt2->line\r
+           )\r
+       ) return;\r
+\r
+    MR_matched_AmbAidRule++;\r
+\r
+    save_fset=fset;\r
+\r
+    dup_matchSets=(set *) calloc(CLL_k+1,sizeof(set));\r
+    require (dup_matchSets != NULL,"Can't allocate dup_matchSets");\r
+\r
+    p[0]=analysis_point( (Junction *) alt1->p1);\r
+    p[1]=analysis_point( (Junction *) alt2->p1);\r
+\r
+    fprintf(stdout,"\n");\r
+\r
+    fprintf(stdout,"  Ambiguity Aid                 ");\r
+    fprintf(stdout,\r
+                (MR_AmbAidDepth <= CLL_k ?\r
+                    "(-ck %d  -aa %s  %s  -aad %d)\n\n" :\r
+                        "(-ck %d  -aa %s  %s  [-ck value limits -aad %d])\n\n"),\r
+                CLL_k,\r
+                MR_AmbAidRule,\r
+                (MR_AmbAidMultiple ? "-aam" : ""),\r
+                MR_AmbAidDepth);\r
+\r
+    for (i=0 ; i < 2 ; i++) {\r
+      fprintf(stdout,"    Choice %d: %-25s  line %d  file %s\n",\r
+                            (i+1),\r
+                            MR_ruleNamePlusOffset( (Node *) p[i]),\r
+                            p[i]->line,FileStr[p[i]->file]);\r
+    };\r
+\r
+    for (j=1; j <= CLL_k ; j++) {\r
+      fprintf(stdout,"\n    Intersection of lookahead[%d] sets:\n",j);\r
+      intersection=set_and(alt1->fset[j],alt2->fset[j]);\r
+      MR_dumpTokenSet(stdout,2,intersection);\r
+      set_free(intersection);\r
+    };\r
+\r
+    fprintf(stdout,"\n");\r
+\r
+    require (1 <= MR_AmbAidDepth && MR_AmbAidDepth <= CLL_k,\r
+                "illegal MR_AmbAidDepth");\r
+\r
+    MR_AmbSourceSearchGroup=0;\r
+    for (depth=1; depth <= MR_AmbAidDepth; depth++) {\r
+        MR_AmbSourceSearchLimit=depth;\r
+        for (i=0 ; i < 2 ; i++) {\r
+\r
+/***        fprintf(stdout,"  Choice:%d  Depth:%d\n\n",i+1,depth);  ***/\r
+\r
+            for (j=0 ; j <= CLL_k ; j++) { dup_matchSets[j]=set_dup(matchSets[j]); };\r
+            fset=dup_matchSets;\r
+\r
+            fflush(output);\r
+            fflush(stdout);\r
+\r
+            MR_AmbSourceSearch=1;\r
+            MR_MaintainBackTrace=1;\r
+            MR_AmbSourceSearchChoice=i;\r
+\r
+            maxk = depth;\r
+            tokensUsed=empty;\r
+            incomplete=empty;\r
+\r
+            constrain = &(fset[1]);\r
+            MR_pointerStackReset(&MR_BackTraceStack);\r
+\r
+            REACH(p[i],depth,&incomplete,tokensUsed);\r
+\r
+            fflush(output);\r
+            fflush(stdout);\r
+\r
+            require (set_nil(incomplete),"MR_traceAmbSource REACH incomplete");\r
+            require (MR_BackTraceStack.count == 0,"1: MR_BackTraceStack.count != 0");\r
+\r
+            set_free(incomplete);\r
+            set_free(tokensUsed);\r
+\r
+            for (j=0 ; j <= CLL_k ; j++) { set_free(dup_matchSets[j]); };\r
+        };\r
+    };\r
+\r
+    fprintf(stdout,"\n");\r
+\r
+    MR_AmbSourceSearch=0;\r
+    MR_MaintainBackTrace=0;\r
+    MR_AmbSourceSearchGroup=0;\r
+    MR_AmbSourceSearchChoice=0;\r
+    MR_AmbSourceSearchLimit=0;\r
+\r
+    fset=save_fset;\r
+    free ( (char *) dup_matchSets);\r
+}\r
+\r
+static int itemCount;\r
+\r
+void MR_backTraceDumpItemReset() {\r
+  itemCount=0;\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+void MR_backTraceDumpItem(FILE *f,int skip,Node *n)\r
+#else\r
+void MR_backTraceDumpItem(f,skip,n)\r
+  FILE      *f;\r
+  int       skip;\r
+  Node      *n;\r
+#endif\r
+{\r
+  TokNode       *tn;\r
+  RuleRefNode   *rrn;\r
+  Junction      *j;\r
+  ActionNode    *a;\r
+\r
+  switch (n->ntype) {\r
+    case nToken:\r
+        itemCount++; if (skip) goto EXIT;\r
+        tn=(TokNode *)n;\r
+        if (set_nil(tn->tset)) {\r
+          fprintf(f,"  %2d #token %-23s",itemCount,TerminalString(tn->token));\r
+        } else {\r
+          fprintf(f,"  %2d #tokclass %-20s",itemCount,TerminalString(tn->token));\r
+        };\r
+        break;\r
+    case nRuleRef:\r
+        itemCount++; if (skip) goto EXIT;\r
+        rrn=(RuleRefNode *)n;\r
+        fprintf(f,"  %2d to %-27s",itemCount,rrn->text);\r
+        break;\r
+    case nAction:\r
+        a=(ActionNode *)n;\r
+        goto EXIT;\r
+    case nJunction:\r
+\r
+      j=(Junction *)n;\r
+\r
+      switch (j->jtype) {\r
+        case aSubBlk:\r
+            if (j->guess) {\r
+              itemCount++; if (skip) goto EXIT;\r
+              fprintf(f,"  %2d %-30s",itemCount,"in (...)? block at");\r
+              break;\r
+            };\r
+/******     fprintf(f,"  %2d %-32s",itemCount,"in (...) block at");  *******/\r
+/******     break;                                                          *******/\r
+            goto EXIT;\r
+        case aOptBlk:\r
+            itemCount++; if (skip) goto EXIT;\r
+            fprintf(f,"  %2d %-30s",itemCount,"in {...} block");\r
+            break;\r
+        case aLoopBlk:\r
+            itemCount++; if (skip) goto EXIT;\r
+            fprintf(f,"  %2d %-30s",itemCount,"in (...)* block");\r
+            break;\r
+        case EndBlk:\r
+            if (j->alpha_beta_guess_end) {\r
+              itemCount++; if (skip) goto EXIT;\r
+              fprintf(f,"  %2d %-30s",itemCount,"end (...)? block at");\r
+              break;\r
+            };\r
+            goto EXIT;\r
+/******     fprintf(f,"  %2d %-32s",itemCount,"end of a block at");     *****/\r
+/******     break;                                                             *****/\r
+        case RuleBlk:\r
+            itemCount++; if (skip) goto EXIT;\r
+            fprintf(f,"  %2d %-30s",itemCount,j->rname);\r
+            break;\r
+        case Generic:\r
+            goto EXIT;\r
+        case EndRule:\r
+            itemCount++; if (skip) goto EXIT;\r
+            fprintf (f,"  %2d end %-26s",itemCount,j->rname);\r
+            break;\r
+        case aPlusBlk:\r
+            itemCount++; if (skip) goto EXIT;\r
+            fprintf(f,"  %2d %-30s",itemCount,"in (...)+ block");\r
+            break;\r
+        case aLoopBegin:\r
+            goto EXIT;\r
+      };\r
+      break;\r
+  };\r
+  fprintf(f," %-23s line %-4d  %s\n",MR_ruleNamePlusOffset(n),n->line,FileStr[n->file]);\r
+EXIT:\r
+  return;\r
+}\r
+\r
+\r
+static PointerStack     previousBackTrace={0,0,NULL};\r
+\r
+#ifdef __USE_PROTOS\r
+void MR_backTraceReport(void)\r
+#else\r
+void MR_backTraceReport()\r
+#endif\r
+{\r
+  int       i;\r
+  int       match = 0;\r
+  int       limitMatch;\r
+\r
+  Node      *p;\r
+  TokNode   *tn;\r
+  set       remainder;\r
+  int       depth;\r
+\r
+  /* Even when doing a k=2 search this routine can get\r
+       called when there is only 1 token on the stack.\r
+     This is because something like rRuleRef can change\r
+       the search value of k from 2 to 1 temporarily.\r
+     It does this because the it wants to know the k=1\r
+       first set before it does a k=2 search\r
+  */\r
+\r
+  depth=0;\r
+  for (i=0; i < MR_BackTraceStack.count ; i++) {\r
+    p=(Node *) MR_BackTraceStack.data[i];\r
+    if (p->ntype == nToken) depth++;\r
+  };\r
+\r
+/* MR14 */  if (MR_AmbSourceSearch) {\r
+/* MR14 */     require (depth <= MR_AmbSourceSearchLimit,"depth > MR_AmbSourceSearchLimit");\r
+/* MR14 */  }\r
+\r
+  /* MR23 THM - Traceback report was being called at the wrong time for -alpha reports */\r
+  /*            Reported by Arpad Beszedes (beszedes@inf.u-szeged.hu)                  */\r
+\r
+  if (MR_AmbSourceSearchLimit == 0 || depth < MR_AmbSourceSearchLimit) {\r
+    return;\r
+  };\r
+\r
+  MR_backTraceDumpItemReset();\r
+\r
+  limitMatch=MR_BackTraceStack.count;\r
+  if (limitMatch > previousBackTrace.count) {\r
+    limitMatch=previousBackTrace.count;\r
+  };\r
+\r
+  for (match=0; match < limitMatch; match++) {\r
+    if (MR_BackTraceStack.data[match] !=\r
+        previousBackTrace.data[match]) {\r
+      break;\r
+    };\r
+  };\r
+\r
+  /* not sure at the moment why there would be duplicates */\r
+\r
+  if (match != MR_BackTraceStack.count) {\r
+\r
+    fprintf(stdout,"     Choice:%d  Depth:%d  Group:%d",\r
+        (MR_AmbSourceSearchChoice+1),\r
+        MR_AmbSourceSearchLimit,\r
+        ++MR_AmbSourceSearchGroup);\r
+\r
+    depth=0;\r
+    fprintf(stdout,"  (");\r
+    for (i=0; i < MR_BackTraceStack.count ; i++) {\r
+      p=(Node *) MR_BackTraceStack.data[i];\r
+      if (p->ntype != nToken) continue;\r
+      tn=(TokNode *)p;\r
+      if (depth != 0) fprintf(stdout," ");\r
+      fprintf(stdout,TerminalString(tn->token));\r
+      depth++;\r
+      if (! MR_AmbAidMultiple) {\r
+        if (set_nil(tn->tset)) {\r
+          set_rm( (unsigned) tn->token,fset[depth]);\r
+        } else {\r
+          remainder=set_dif(fset[depth],tn->tset);\r
+          set_free(fset[depth]);\r
+          fset[depth]=remainder;\r
+        };\r
+      };\r
+    };\r
+    fprintf(stdout,")\n");\r
+\r
+    for (i=0; i < MR_BackTraceStack.count ; i++) {\r
+      MR_backTraceDumpItem(stdout, (i<match) ,(Node *) MR_BackTraceStack.data[i]);\r
+    };\r
+    fprintf(stdout,"\n");\r
+    fflush(stdout);\r
+\r
+    MR_pointerStackReset(&previousBackTrace);\r
+\r
+    for (i=0; i < MR_BackTraceStack.count ; i++) {\r
+      MR_pointerStackPush(&previousBackTrace,MR_BackTraceStack.data[i]);\r
+    };\r
+\r
+  };\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+void MR_setConstrainPointer(set * newConstrainValue)\r
+#else\r
+void MR_setConstrainPointer(newConstrainValue)\r
+  set * newConstrainValue;\r
+#endif\r
+{\r
+       constrain=newConstrainValue;\r
+}\r
diff --git a/Tools/CodeTools/Source/Pccts/antlr/gen.c b/Tools/CodeTools/Source/Pccts/antlr/gen.c
new file mode 100644 (file)
index 0000000..368a96b
--- /dev/null
@@ -0,0 +1,4797 @@
+/*\r
+ * gen.c\r
+ *\r
+ * Generate C code (ANSI, K&R, C++)\r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
+ * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
+ * company may do whatever they wish with source code distributed with\r
+ * PCCTS or the code generated by PCCTS, including the incorporation of\r
+ * PCCTS, or its output, into commerical software.\r
+ *\r
+ * We encourage users to develop software with PCCTS.  However, we do ask\r
+ * that credit is given to us for developing PCCTS.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like PCCTS and have developed a nice tool with the\r
+ * output, please mention that you developed it using PCCTS.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * ANTLR 1.33\r
+ * Terence Parr\r
+ * Parr Research Corporation\r
+ * with Purdue University and AHPCRC, University of Minnesota\r
+ * 1989-2001\r
+ */\r
+\r
+#include <stdio.h>\r
+#include <stdlib.h>\r
+#include <ctype.h>\r
+#include "pcctscfg.h"\r
+#include "set.h"\r
+#include "syn.h"\r
+#include "hash.h"\r
+#include "generic.h"\r
+#include "dlgdef.h"\r
+\r
+#define NumExprPerLine 4\r
+static int on1line=0;\r
+static set tokensRefdInBlock;\r
+\r
+                                       /* T r a n s l a t i o n  T a b l e s */\r
+\r
+/* C_Trans[node type] == pointer to function that knows how to translate that node. */\r
+#ifdef __cplusplus\r
+void (*C_Trans[NumNodeTypes+1])(...) = {\r
+       NULL,\r
+       NULL,                                   /* See next table.\r
+Junctions have many types */\r
+       (void (*)(...)) genRuleRef,\r
+       (void (*)(...)) genToken,\r
+       (void (*)(...)) genAction\r
+ };\r
+#else\r
+void (*C_Trans[NumNodeTypes+1])() = {\r
+       NULL,\r
+       NULL,                                   /* See next table.\r
+Junctions have many types */\r
+       genRuleRef,\r
+       genToken,\r
+       genAction\r
+ };\r
+#endif\r
+\r
+/* C_JTrans[Junction type] == pointer to function that knows how to translate that\r
+ * kind of junction node.\r
+ */\r
+#ifdef __cplusplus\r
+void (*C_JTrans[NumJuncTypes+1])(...) = {\r
+       NULL,\r
+       (void (*)(...)) genSubBlk,\r
+       (void (*)(...)) genOptBlk,\r
+       (void (*)(...)) genLoopBlk,\r
+       (void (*)(...)) genEndBlk,\r
+       (void (*)(...)) genRule,\r
+       (void (*)(...)) genJunction,\r
+       (void (*)(...)) genEndRule,\r
+       (void (*)(...)) genPlusBlk,\r
+       (void (*)(...)) genLoopBegin\r
+ };\r
+#else\r
+void (*C_JTrans[NumJuncTypes+1])() = {\r
+       NULL,\r
+       genSubBlk,\r
+       genOptBlk,\r
+       genLoopBlk,\r
+       genEndBlk,\r
+       genRule,\r
+       genJunction,\r
+       genEndRule,\r
+       genPlusBlk,\r
+       genLoopBegin\r
+ };\r
+#endif\r
+\r
+#define PastWhiteSpace(s)      while (*(s) == ' ' || *(s) == '\t') {s++;}\r
+\r
+static int tabs = 0;\r
+\r
+/* MR6 Got tired of text running off page when using standard tab stops */\r
+\r
+#define TAB { int i;                                                                   \\r
+             if (TabWidth==0) {                                                        \\r
+                for (i=0; i<tabs; i++) fputc('\t', output);                            \\r
+             } else {                                                                  \\r
+                for (i=0; i<tabs*TabWidth; i++) fputc(' ',output);                     \\r
+             };                                                                        \\r
+           }\r
+\r
+static void\r
+#ifdef __USE_PROTOS\r
+tab( void )\r
+#else\r
+tab( )\r
+#endif\r
+TAB\r
+\r
+#ifdef __USE_PROTOS\r
+static char *tokenFollowSet(TokNode *);\r
+static ActionNode *findImmedAction( Node * );\r
+static void dumpRetValAssign(char *, char *, RuleRefNode *);           /* MR30 */\r
+static void dumpAfterActions(FILE *output);\r
+static set ComputeErrorSet(Junction *, int, int);\r
+static void makeErrorClause(Junction *, set, int, int);\r
+static void DumpFuncHeader( Junction *, RuleEntry * );\r
+static int has_guess_block_as_first_item(Junction *);\r
+static int genExprSets(set *, int);\r
+static void genExprTree( Tree *t, int k );\r
+static void genExprTreeOriginal( Tree *t, int k );                  /* MR10 */\r
+static char * findOuterHandlerLabel(ExceptionGroup *eg);            /* MR7 */\r
+static void OutLineInfo(FILE *file,int line,char *fileName);        /* MR14 */\r
+#else\r
+static char *tokenFollowSet();\r
+static ActionNode *findImmedAction();\r
+static void dumpRetValAssign();\r
+static void dumpAfterActions();\r
+static set ComputeErrorSet();\r
+static void makeErrorClause();\r
+static void DumpFuncHeader();\r
+static int has_guess_block_as_first_item();\r
+static int genExprSets();\r
+static void genExprTree();\r
+static void genExprTreeOriginal();                                  /* MR10 */\r
+static char * findOuterHandlerLabel();                              /* MR7 */\r
+static void OutLineInfo();                                          /* MR14 */\r
+#endif\r
+\r
+#define gen(s)                 {tab(); fprintf(output, s);}\r
+#define gen1(s,a)              {tab(); fprintf(output, s,a);}\r
+#define gen2(s,a,b)            {tab(); fprintf(output, s,a,b);}\r
+#define gen3(s,a,b,c)  {tab(); fprintf(output, s,a,b,c);}\r
+#define gen4(s,a,b,c,d)        {tab(); fprintf(output, s,a,b,c,d);}\r
+#define gen5(s,a,b,c,d,e)      {tab(); fprintf(output, s,a,b,c,d,e);}\r
+#define gen6(s,a,b,c,d,e,f)    {tab(); fprintf(output, s,a,b,c,d,e,f);}\r
+#define gen7(s,a,b,c,d,e,f,g)  {tab(); fprintf(output, s,a,b,c,d,e,f,g);}\r
+\r
+#define _gen(s)                        {fprintf(output, s);}\r
+#define _gen1(s,a)             {fprintf(output, s,a);}\r
+#define _gen2(s,a,b)   {fprintf(output, s,a,b);}\r
+#define _gen3(s,a,b,c) {fprintf(output, s,a,b,c);}\r
+#define _gen4(s,a,b,c,d){fprintf(output, s,a,b,c,d);}\r
+#define _gen5(s,a,b,c,d,e){fprintf(output, s,a,b,c,d,e);}\r
+#define _gen6(s,a,b,c,d,e,f){fprintf(output, s,a,b,c,d,e,f);}\r
+#define _gen7(s,a,b,c,d,e,f,g){fprintf(output, s,a,b,c,d,e,f,g);}\r
+\r
+\r
+/* MR11 a convenient place to set a break point */\r
+\r
+#ifdef __USE_PROTOS\r
+void MR_break(void) \r
+#else\r
+void MR_break() \r
+#endif\r
+{\r
+  return;\r
+}\r
+\r
+/* MR10 genTraceOut(Junction *)      */\r
+\r
+#ifdef __USE_PROTOS\r
+static void genTraceOut(Junction *q)\r
+#else\r
+static void genTraceOut(q)\r
+  Junction  *q;\r
+#endif\r
+{\r
+  if ( TraceGen ) {\r
+               if ( GenCC ) {gen1("zzTRACEOUT(\"%s\");\n", q->rname);}\r
+               else gen1("zzTRACEOUT((ANTLRChar *)\"%s\");\n", q->rname);\r
+  }\r
+}\r
+\r
+static void\r
+#ifdef __USE_PROTOS\r
+warn_about_using_gk_option(void)\r
+#else\r
+warn_about_using_gk_option()\r
+#endif\r
+{\r
+       static int warned_already=0;\r
+\r
+       if ( !DemandLookahead || warned_already ) return;\r
+       warned_already = 1;\r
+       warnNoFL("-gk option could cause trouble for <<...>>? predicates");\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+freeBlkFsets( Junction *q )\r
+#else\r
+freeBlkFsets( q )\r
+Junction *q;\r
+#endif\r
+{\r
+       int i;\r
+       Junction *alt;\r
+       require(q!=NULL, "freeBlkFsets: invalid node");\r
+\r
+       for (alt=q; alt != NULL; alt= (Junction *) alt->p2 )\r
+       {\r
+               for (i=1; i<=CLL_k; i++) set_free(alt->fset[i]);\r
+       }\r
+}\r
+\r
+/*\r
+ * Generate a local variable allocation for each token references\r
+ * in this block.\r
+ */\r
+static void\r
+#ifdef __USE_PROTOS\r
+genTokenPointers( Junction *q )\r
+#else\r
+genTokenPointers( q )\r
+Junction *q;\r
+#endif\r
+{\r
+       /* Rule refs are counted and can be referenced, but their\r
+        * value is not set to anything useful ever.\r
+        *\r
+     * The ptrs are to be named _tij where i is the current level\r
+        * and j is the element number within an alternative.\r
+        */\r
+       int first=1, t=0;\r
+       set a;\r
+       tokensRefdInBlock = q->tokrefs;\r
+\r
+       if ( set_deg(q->tokrefs) == 0 ) return;\r
+       a = set_dup(q->tokrefs);\r
+       gen("ANTLRTokenPtr ");\r
+       for (; !set_nil(a); set_rm(t, a))\r
+       {\r
+               t = set_int(a);\r
+               if ( first ) first = 0;\r
+               else _gen(",");\r
+               if ( !DontCopyTokens ) _gen2("_tv%d%d,", BlkLevel, t);\r
+               _gen2("_t%d%d", BlkLevel, t);\r
+               if ( !DontCopyTokens ) {_gen2("= &_tv%d%d", BlkLevel, t);}\r
+               else _gen("=NULL");\r
+       }\r
+       _gen(";\n");\r
+       set_free(a);\r
+}\r
+\r
+static int\r
+#ifdef __USE_PROTOS\r
+hasDefaultException(ExceptionGroup *eg)\r
+#else\r
+hasDefaultException(eg)\r
+ExceptionGroup *eg;\r
+#endif\r
+{\r
+    ListNode *q;\r
+\r
+    for (q = eg->handlers->next; q!=NULL; q=q->next)\r
+    {\r
+        ExceptionHandler *eh = (ExceptionHandler *)q->elem;\r
+        if ( strcmp("default", eh->signalname)==0 ) {\r
+            return 1;\r
+        }\r
+    }\r
+    return 0;\r
+}\r
+static void\r
+#ifdef __USE_PROTOS\r
+dumpException(ExceptionGroup *eg, int no_default_case)\r
+#else\r
+dumpException(eg, no_default_case)\r
+ExceptionGroup *eg;\r
+int no_default_case;\r
+#endif\r
+{\r
+    char    *outerLabel;                                             /* MR7 */\r
+    int     altHandler=0;                                            /* MR7 */\r
+    int     namedHandler=0;                                          /* MR7 */\r
+\r
+    outerLabel=findOuterHandlerLabel(eg);                            /* MR7 */\r
+\r
+    if (eg->label != NULL) {                                         /* MR7 */\r
+      namedHandler=1;                                                /* MR7 */\r
+    } else if (eg->forRule) {                                        /* MR7 */\r
+      /* nothing */                                                  /* MR20 */\r
+    } else {                                                         /* MR7 */\r
+      altHandler=1;                                                  /* MR7 */\r
+    };                                                               /* MR7 */\r
+\r
+#if 0\r
+**     if (! eg->used) {                                             /* MR7 */\r
+**             warnFL("exception group never used",                         /* MR7 */\r
+**             FileStr[eg->altstart->file],eg->altstart->line);      /* MR7 */\r
+**     };                                                            /* MR7 */\r
+#endif\r
+\r
+    if (namedHandler) {                                              /* MR7 */\r
+         gen1("switch ( _signal ) {  /* [%s] */\n",eg->label);          /* MR7 */\r
+    } else {                                                         /* MR7 */\r
+         gen("switch ( _signal ) {\n");                                 /* MR7 */\r
+      gen("case NoSignal: break;  /* MR7 */\n");                     /* MR7 */\r
+    };                                                               /* MR7 */\r
+       {\r
+               ListNode *q;\r
+               for (q = eg->handlers->next; q!=NULL; q=q->next)\r
+               {\r
+                       ExceptionHandler *eh = (ExceptionHandler *)q->elem;\r
+                       if ( strcmp("default", eh->signalname)==0 ) {\r
+                               gen("default :\n");\r
+                               tabs++;\r
+                               dumpAction(eh->action, output, tabs, -1, 1, 1);\r
+                gen("_signal=NoSignal;  /* MR7 */\n");                  /* MR7 */\r
+                gen("break;  /* MR7 */\n");                             /* MR7 */\r
+                               tabs--;\r
+                               gen("}\n");\r
+\r
+                /* copied from later code in dumpException */        /* MR7 */\r
+\r
+                if (namedHandler) {                                  /* MR7 */\r
+                  gen("if (_signal != NoSignal)");                   /* MR7 */\r
+                  _gen1(" goto %s_handler;  /* MR7 */\n",outerLabel);/* MR7 */\r
+                } else if (altHandler) {                             /* MR7 */\r
+                  gen1("goto %s_handler;  /* MR7 */\n",outerLabel);  /* MR7 */\r
+                };\r
+                               return;\r
+                       }\r
+                       gen1("case %s :\n", eh->signalname);\r
+                       tabs++;\r
+                       if ( eh->action != NULL )\r
+                       {\r
+                               dumpAction(eh->action, output, tabs, -1, 1, 1);\r
+                gen("break;  /* MR7 */\n");                          /* MR7 */\r
+                       }\r
+                       tabs--;\r
+               }\r
+       }\r
+       if ( no_default_case ) return;\r
+\r
+       gen("default :\n");\r
+    tabs++;                                                         /* MR7 */\r
+    gen("break;  /* MR7 */\n");                                     /* MR7 */\r
+    tabs--;                                                         /* MR7 */\r
+\r
+       tabs++;\r
+/***** gen("*_retsignal = _signal;\n"); *****/\r
+\r
+       tabs--;\r
+       gen("}\n");\r
+\r
+    if (namedHandler) {                                             /* MR7 */\r
+      gen("if (_signal != NoSignal)");                              /* MR7 */\r
+      _gen1(" goto %s_handler;  /* MR7 */\n",outerLabel);           /* MR7 */\r
+    } else if (altHandler) {                                        /* MR7 */\r
+      gen1("goto %s_handler;  /* MR7 */\n",outerLabel);             /* MR7 */\r
+    };\r
+\r
+}\r
+\r
+static void\r
+#ifdef __USE_PROTOS\r
+dumpExceptions(ListNode *list)\r
+#else\r
+dumpExceptions(list)\r
+ListNode *list;\r
+#endif\r
+{\r
+       ListNode *p;\r
+\r
+       for (p = list->next; p!=NULL; p=p->next)\r
+       {\r
+               ExceptionGroup *eg = (ExceptionGroup *) p->elem;\r
+               _gen2("%s%s_handler:\n",\r
+                         eg->label==NULL?"":eg->label,\r
+                         eg->altID==NULL?"":eg->altID);\r
+               if ( eg->altID!=NULL ) dumpException(eg, 0);\r
+               else {\r
+                       /* This must be the rule exception handler */\r
+                       dumpException(eg, 1);\r
+                       if ( !hasDefaultException(eg) )\r
+            {\r
+                gen("default :\n");\r
+                tabs++;\r
+                gen("zzdflthandlers(_signal,_retsignal);\n");\r
+                tabs--;\r
+                gen("}\n");\r
+            }\r
+               }\r
+       }\r
+}\r
+\r
+/* For each element label that is found in a rule, generate a unique\r
+ * Attribute (and AST pointer if GenAST) variable.\r
+ */\r
+void\r
+#ifdef __USE_PROTOS\r
+genElementLabels(ListNode *list)\r
+#else\r
+genElementLabels(list)\r
+ListNode *list;\r
+#endif\r
+{\r
+       int first=1;\r
+       ListNode *p;\r
+\r
+       if ( GenCC ) {gen("ANTLRTokenPtr");}\r
+       else {gen("Attrib");}\r
+       for (p = list->next; p!=NULL; p=p->next)\r
+       {\r
+               char *ep = (char *)p->elem;\r
+               if ( first ) first = 0;\r
+               else _gen(",");\r
+               if ( GenCC ) {_gen1(" %s=NULL",ep);}\r
+               else {_gen1(" %s",ep);}\r
+       }\r
+       _gen(";\n");\r
+\r
+       if ( !GenAST ) return;\r
+\r
+       first = 1;\r
+       gen("AST");\r
+       for (p = list->next; p!=NULL; p=p->next)\r
+       {\r
+               char *ep = (char *)p->elem;\r
+               if ( first ) first = 0;\r
+               else _gen(",");\r
+               _gen1(" *%s_ast=NULL",ep);\r
+       }\r
+       _gen(";\n");\r
+}\r
+\r
+/*\r
+ * Generate a local variable allocation for each token or rule reference\r
+ * in this block.\r
+ */\r
+static void\r
+#ifdef __USE_PROTOS\r
+genASTPointers( Junction *q )\r
+#else\r
+genASTPointers( q )\r
+Junction *q;\r
+#endif\r
+{\r
+       int first=1, t;\r
+       set a;\r
+\r
+       a = set_or(q->tokrefs, q->rulerefs);\r
+       if ( set_deg(a) > 0 )\r
+       {\r
+               gen("AST ");\r
+               for (; !set_nil(a); set_rm(t, a))\r
+               {\r
+                       t = set_int(a);\r
+                       if ( first ) first = 0;\r
+                       else _gen(",");\r
+                       _gen2("*_ast%d%d=NULL", BlkLevel, t);\r
+               }\r
+               set_free(a);\r
+       }\r
+       _gen(";\n");\r
+}\r
+\r
+static void\r
+#ifdef __USE_PROTOS\r
+BLOCK_Head( void )\r
+#else\r
+BLOCK_Head( )\r
+#endif\r
+{\r
+       gen("{\n");\r
+       tabs++;\r
+       if ( !GenCC ) gen1("zzBLOCK(zztasp%d);\n", BlkLevel);\r
+}\r
+\r
+static void\r
+#ifdef __USE_PROTOS\r
+BLOCK_Tail( void )\r
+#else\r
+BLOCK_Tail( )\r
+#endif\r
+{\r
+       if ( !GenCC ) gen1("zzEXIT(zztasp%d);\n", BlkLevel);\r
+       if ( !GenCC ) gen("}\n");\r
+       tabs--;\r
+       gen("}\n");\r
+}\r
+\r
+static void\r
+#ifdef __USE_PROTOS\r
+BLOCK_Preamble( Junction *q )\r
+#else\r
+BLOCK_Preamble( q )\r
+Junction *q;\r
+#endif\r
+{\r
+       ActionNode *a;\r
+       Junction *begin;\r
+\r
+       BLOCK_Head();\r
+       if ( GenCC ) genTokenPointers(q);\r
+       if ( GenCC&&GenAST ) genASTPointers(q);\r
+       if ( q->jtype == aPlusBlk ) gen("int zzcnt=1;\n");\r
+       if ( q->parm != NULL && !q->predparm ) gen1("zzaPush(%s);\n", q->parm)\r
+       else if ( !GenCC ) gen("zzMake0;\n");\r
+       if ( !GenCC ) gen("{\n");\r
+       if ( q->jtype == aLoopBegin ) begin = (Junction *) ((Junction *)q->p1);\r
+       else begin = q;\r
+       if ( has_guess_block_as_first_item(begin) )\r
+       {\r
+               gen("zzGUESS_BLOCK\n");\r
+       }\r
+       if ( q->jtype == aLoopBegin )\r
+               a = findImmedAction( ((Junction *)q->p1)->p1 ); /* look at aLoopBlk */\r
+       else\r
+               a = findImmedAction( q->p1 );\r
+       if ( a!=NULL && !a->is_predicate) {\r
+/* MR21 */ if (!a->noHoist) dumpActionPlus(a, a->action, output, tabs, a->file, a->line, 1);\r
+                  a->done = 1; /* remove action. We have already handled it */\r
+       }\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+genCombinedPredTreeContextOrig( Predicate *p )\r
+#else\r
+genCombinedPredTreeContextOrig( p )\r
+Predicate *p;\r
+#endif\r
+{\r
+       static set *ctx=NULL;           /* genExprSets() is destructive, make copy*/\r
+       require(p!=NULL, "can't make context tree for NULL pred tree");\r
+\r
+#ifdef DBG_PRED\r
+       fprintf(stderr, "enter genCombinedPredTreeContextOrig(%s,0x%x) with sets:\n", p->expr, p);\r
+       s_fprT(stderr, p->scontext[1]);\r
+       fprintf(stderr, "\n");\r
+#endif\r
+       if ( p->down == NULL )\r
+       {\r
+/***   if ( p->k>1 && p->tcontext!=NULL ) ***/\r
+               if ( p->tcontext!=NULL )\r
+               {\r
+                       _gen("(");\r
+                       genExprTree(p->tcontext, 1);\r
+                       _gen(")");\r
+               }\r
+/***   else if ( p->k==1 && set_deg(p->scontext[1])>0 ) ***/\r
+               else if ( set_deg(p->scontext[1])>0 )\r
+               {\r
+                       if ( ctx==NULL ) ctx = (set *)calloc(CLL_k+1, sizeof(set));\r
+                       require(ctx!=NULL, "ctx cannot allocate");\r
+                       ctx[0]=empty;\r
+                       ctx[1]=set_dup(p->scontext[1]);\r
+                       _gen("(");\r
+                       genExprSets(&(ctx[0]), p->k);\r
+                       _gen(")");\r
+                       set_free(ctx[1]);\r
+               }\r
+               else if ( p->expr==PRED_AND_LIST || p->expr==PRED_OR_LIST ) {\r
+                       fatal_internal("pred tree is orphan OR or AND list");\r
+               }\r
+               else {\r
+            if (! HoistPredicateContext) {\r
+              _gen(" 1 /* no context: prc is off */ ");\r
+            } else {\r
+              fatal_internal("pred tree context is empty");\r
+            };\r
+               }\r
+               return;\r
+       }\r
+\r
+/* MR10 - make AND just like OR */\r
+\r
+       if ( p->expr == PRED_AND_LIST )\r
+       {\r
+        Predicate *list = p->down;\r
+        for (; list!=NULL; list=list->right)\r
+        {\r
+            genCombinedPredTreeContextOrig(list);\r
+                        if ( list->right!=NULL ) _gen("|| /* MR10 was wrong */ ");\r
+        };\r
+               return;\r
+       }\r
+\r
+       if ( p->expr == PRED_OR_LIST )\r
+       {\r
+        Predicate *list = p->down;\r
+        for (; list!=NULL; list=list->right)\r
+        {\r
+           genCombinedPredTreeContextOrig(list);\r
+           if ( list->right!=NULL ) _gen("||");\r
+        };\r
+        return;\r
+     };\r
+\r
+       fatal("pred tree is really wacked");\r
+}\r
+\r
+/* [genCombinedPredTreeContext] */\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+genCombinedPredTreeContext( Predicate *p )\r
+#else\r
+genCombinedPredTreeContext( p )\r
+Predicate *p;\r
+#endif\r
+{\r
+  Tree  *t;\r
+  int   predDepth=0;\r
+\r
+  if (0 && ! MR_usingPredNames && ! MRhoisting) {\r
+    genCombinedPredTreeContextOrig(p);\r
+  } else {\r
+/* MR13 */    MR_pred_depth(p,&predDepth);\r
+/* MR13 */    if (predDepth == 1) {\r
+/* MR13 */\r
+/* MR13 */      set   scontext[2];\r
+/* MR13 */      scontext[0]=empty;\r
+/* MR13 */      scontext[1]=MR_compute_pred_set(p);\r
+/* MR13 */      if (set_nil(scontext[1])) {\r
+/* MR13 */        _gen(" 1 /* MR12 no context (-prc off) */ ");\r
+/* MR13 */      } else {\r
+/* MR13 */        _gen("(");\r
+/* MR13 */        genExprSets(&scontext[0], 1);\r
+/* MR13 */        set_free(scontext[1]);\r
+/* MR13 */        _gen(")");\r
+/* MR13 */      };\r
+\r
+    } else {\r
+      t=MR_compute_pred_tree_context(p);\r
+      if (t == NULL) {\r
+        _gen(" 1 /* MR12 no context (-prc off) */ ");\r
+      } else {\r
+        _gen("(");\r
+        genExprTree(t, 1);\r
+        Tfree(t);   /* MR10 */\r
+        _gen(")");\r
+      };\r
+    };\r
+  };\r
+}\r
+\r
+/* [genPredTreeGate] */\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+genPredTreeGate( Predicate *p, int in_and_expr )\r
+#else\r
+genPredTreeGate( p, in_and_expr )\r
+Predicate *p;\r
+int in_and_expr;\r
+#endif\r
+{\r
+       if ( in_and_expr )\r
+       {\r
+               _gen("!(");\r
+               genCombinedPredTreeContext(p);\r
+               _gen(")||");\r
+               if ( p->down!=NULL ) _gen("\n");\r
+       }\r
+       else\r
+       {\r
+               _gen("(");\r
+               genCombinedPredTreeContext(p);\r
+               _gen(")&&");\r
+               if ( p->down!=NULL ) _gen("\n");\r
+       }\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+void genPredEntry(Predicate *p,int outer)\r
+#else\r
+void genPredEntry(p,outer)\r
+  Predicate     *p;\r
+  int           outer;\r
+#endif\r
+{\r
+    int         inverted=0;\r
+    Predicate   *q;\r
+    int         localOuter=outer;\r
+    int         needRP=0;\r
+\r
+    if (p == NULL) return;\r
+\r
+    if (p->predEntry != NULL && p->predEntry->predLiteral != NULL) {\r
+      if (p->inverted != p->predEntry->pred->inverted) {\r
+        _gen("! /* inverted pred */ (");\r
+        needRP=1;\r
+      } else {\r
+        if (!localOuter) _gen("(");\r
+        needRP=1;\r
+      };\r
+      dumpAction(p->predEntry->predLiteral,output,0,p->source->file,p->source->line,0);\r
+      if (needRP) _gen(")");\r
+      return;\r
+    };\r
+\r
+    inverted=p->inverted;\r
+\r
+    if (inverted) {\r
+      _gen(" ! /* inverted pred */ (");\r
+      localOuter=1;\r
+    };\r
+\r
+    if (p->expr == PRED_OR_LIST) {\r
+      if (!localOuter) _gen("(");\r
+      for (q=p->down; q != NULL ; q=q->right) {\r
+        genPredEntry(q,0);\r
+        if (q->right != NULL) _gen(" || ");\r
+      };\r
+      if (!localOuter) _gen(")");\r
+    } else if (p->expr == PRED_AND_LIST) {\r
+      if (!localOuter) _gen("(");\r
+      for (q=p->down; q != NULL ; q=q->right) {\r
+        genPredEntry(q,0);\r
+        if (q->right != NULL) _gen(" && ");\r
+      };\r
+      if (!localOuter) _gen(")");\r
+    } else {\r
+      if (!localOuter) _gen("(");\r
+      require (p->source != NULL,"predEntry->source == NULL");\r
+      require (p->source->inverted == 0,"dumpPredEntry p->source->inverted != 0");\r
+      dumpAction(p->source->action,output,0,p->source->file,p->source->line,0);\r
+      if (!localOuter) _gen(")");\r
+    };\r
+\r
+    if (inverted) {\r
+        _gen(")");\r
+    }\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+dumpPredAction(ActionNode *anode,\r
+                    char *s,FILE *output,int tabs,int file,int line,int final_newline)\r
+#else\r
+dumpPredAction(anode,\r
+                    s,output,tabs,file,line,final_newline)\r
+\r
+    ActionNode  *anode;\r
+    char        *s;\r
+    FILE        *output;\r
+    int         tabs;\r
+    int         file;\r
+    int         line;\r
+    int         final_newline;\r
+#endif\r
+{\r
+    PredEntry   *predEntry=anode->predEntry;\r
+    int         inverted=anode->inverted;\r
+    Predicate   *workPred;\r
+\r
+    if (predEntry == NULL) {\r
+\r
+      /* inline predicate literal */\r
+\r
+      require(inverted == 0,"dumpPredAction action->inverted");\r
+         dumpAction(s,output,tabs,file,line,final_newline);\r
+\r
+    } else {\r
+\r
+      /* a reference to a predicate - possibly with an inverted source */\r
+\r
+      if (predEntry->predLiteral != NULL) {\r
+        if (inverted) _gen("! /* inverted pred */ (");\r
+        dumpAction(predEntry->predLiteral,output,0,anode->file,anode->line,0);\r
+        if (inverted) _gen(")");\r
+      } else {\r
+        workPred=predicate_dup(predEntry->pred);\r
+        if (inverted) workPred->inverted=!workPred->inverted;\r
+        genPredEntry(workPred,1);\r
+        predicate_free(workPred);\r
+      };\r
+    };\r
+}\r
+\r
+/* [genPred] */\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+genPred(Predicate *p, Node *j,int suppress_sva)\r
+#else\r
+genPred(p,j,suppress_sva)\r
+    Predicate   *p;\r
+    Node        *j;\r
+    int         suppress_sva;\r
+#endif\r
+{\r
+       if ( FoundException && !suppress_sva) {_gen("(_sva=(");}    /* MR11 suppress_sva */\r
+       else {_gen("(");}\r
+       if ( GenLineInfo && j->file != -1 ) _gen("\n");\r
+    if (p->source != NULL && p->source->ampersandPred != NULL) {\r
+      if (p->source->ampersandPred->k == 1) {\r
+\r
+            set     ctx[2];\r
+\r
+                       ctx[0]=empty;\r
+                       ctx[1]=set_dup(p->source->ampersandPred->scontext[1]);\r
+\r
+                       _gen("(");\r
+                       genExprSets(&(ctx[0]), p->k);\r
+                       _gen(") && ");\r
+                       set_free(ctx[1]);\r
+      } else {\r
+        _gen("( ");\r
+        genExprTree(p->source->ampersandPred->tcontext,1);\r
+               _gen(" ) && ");\r
+      };\r
+    };\r
+\r
+    dumpPredAction((ActionNode *)p->source,\r
+                p->expr, output, 0, -1 /*indicates no line info*/, j->line, 0);\r
+\r
+       if ( FoundException && !suppress_sva)   /* MR11 suppress_sva */\r
+         {_gen("),_sva)");}    /* MR10 - get red of "meant ==" messages */\r
+       else {_gen(")");}\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+MR_distinctORcontextOpt(Predicate *p,Node *j,int in_and_expr)\r
+#else\r
+MR_distinctORcontextOpt(p,j,in_and_expr)\r
+    Predicate   *p;\r
+    Node        *j;\r
+    int         in_and_expr;\r
+#endif\r
+{\r
+    Predicate   *q;\r
+\r
+    _gen(" /* MR10 Distinct OR context optimization */ \n");\r
+\r
+    if (in_and_expr) {\r
+      gen("zzpf=0,\n");\r
+      for (q=p->down; q != NULL; q=q->right) {\r
+        gen("(  ");\r
+        genCombinedPredTreeContext(q);\r
+        _gen(" && (zzpf=1, ");\r
+        genPred(q,j,0);\r
+        _gen("  )) ||\n");\r
+      };\r
+      gen("!zzpf)");\r
+    } else {\r
+      require (0,\r
+            "MR_distinctORcontextOpt: can't get here when using MR_predSimplify");\r
+#if 0\r
+**      for (q=p->down; q != NULL; q=q->right) {\r
+**        gen("(  ");\r
+**        genCombinedPredTreeContext(q);\r
+**        _gen(" && ");\r
+**        genPred(q,j);\r
+**        if (q->right != NULL) {\r
+**          _gen("  ) ||\n");\r
+**        };\r
+**      };\r
+**      gen(")");\r
+#endif\r
+   };\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+genPredTreeOrig( Predicate *p, Node *j, int in_and_expr )\r
+#else\r
+genPredTreeOrig( p, j, in_and_expr )\r
+Predicate *p;\r
+Node *j;\r
+int in_and_expr;\r
+#endif\r
+{\r
+\r
+/* MR10 */  int     allHaveContext=1;\r
+/* MR10 */  int     noneHaveContext=1;\r
+\r
+/* MR10 */  MR_predContextPresent(p,&allHaveContext,&noneHaveContext);\r
+\r
+       if ( ! noneHaveContext )                  /* MR10 context guards ignored when -prc off */\r
+       {\r
+               _gen("(");\r
+               genPredTreeGate(p, in_and_expr);\r
+       }\r
+\r
+       /* if leaf node, just gen predicate */\r
+\r
+       if ( p->down==NULL )\r
+       {\r
+               genPred(p,j,0);\r
+               if ( ! noneHaveContext ) _gen(")");   /* MR10 context guards ignored when -prc off */\r
+               return;\r
+       }\r
+\r
+       /* if AND list, do both preds (only two possible) */\r
+       if ( p->expr == PRED_AND_LIST )\r
+       {\r
+#if 0\r
+**             _gen("(");\r
+**             genPredTreeOrig(p->down, j, 1);\r
+**             _gen("&&");\r
+**             genPredTreeOrig(p->down->right, j, 1);\r
+**             _gen(")");\r
+**             if ( ! noneHaveContext ) _gen(")");    /* MR10 context guards ignored when -prc off */\r
+**             return;\r
+#endif\r
+        /* MR11 - make it work with AND with more than two children - like OR */\r
+\r
+               Predicate *list;\r
+               _gen("(");\r
+               list = p->down;\r
+               for (; list!=NULL; list=list->right)\r
+               {\r
+                       genPredTreeOrig(list, j, 1);\r
+                       if ( list->right!=NULL ) _gen("&&");\r
+               }\r
+               _gen(")");\r
+               if ( ! noneHaveContext ) _gen(")");    /* MR10 context guards ignored when -prc off */\r
+               return;\r
+    };\r
+\r
+       if ( p->expr == PRED_OR_LIST )\r
+       {\r
+               Predicate *list;\r
+               _gen("(");\r
+               list = p->down;\r
+               for (; list!=NULL; list=list->right)\r
+               {\r
+                       genPredTreeOrig(list, j, 0);\r
+                       if ( list->right!=NULL ) _gen("||");\r
+               }\r
+               _gen(")");\r
+               if ( ! noneHaveContext ) _gen(")");    /* MR10 context guards ignored when -prc off */\r
+               return;\r
+       }\r
+\r
+       fatal_internal("genPredTreeOrig: predicate tree is wacked");\r
+}\r
+\r
+#if 0\r
+**   Predicate member dummyPredDepth is no longer used in MR10\r
+**     but we might need it again in the future\r
+**\r
+**   if (MRhoisting) {\r
+**     if ( !noneHaveContext &&\r
+**          ! in_and_expr &&\r
+**          p->source != NULL &&\r
+**          p->source->dummyPredicateDepth > 0 &&\r
+**          p->down == NULL) {\r
+**             _gen("(");\r
+**             genCombinedPredTreeContext(p);\r
+**             _gen("  )\n");\r
+**             return;\r
+**     };\r
+**   };\r
+#endif\r
+\r
+/* [genPredTree] */\r
+\r
+/* in_and_expr\r
+\r
+   what to do if the context is wrong\r
+   what to do if the context is correct but the predicate is false\r
+\r
+   remember: if the context is wrong it's the same as if the\r
+             predicate is true as far as enabling an alternative\r
+\r
+        Consider (AND p q r)\r
+\r
+        if in an ... && ... expression then you don't want\r
+        the entire predicate chain to fail just because the\r
+        context for one component is wrong: so return true\r
+\r
+        Consider (OR p q r)\r
+\r
+        if in an ... || ... expression then you don't want\r
+        the entire predicate chain to succeed just because\r
+        the context for one component is correct when the\r
+        corresponding test is false: so return false when\r
+        the context is correct but the test is false.\r
+*/\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+genPredTree( Predicate *p, Node *j, int in_and_expr, int suppress_sva )\r
+#else\r
+genPredTree( p, j, in_and_expr, suppress_sva)\r
+  Predicate     *p;\r
+  Node          *j;\r
+  int           in_and_expr;\r
+  int           suppress_sva;\r
+#endif\r
+{\r
+\r
+    int         allHaveContext=1;\r
+    int         noneHaveContext=1;\r
+    Tree        *groupTree;\r
+    Tree        *oneTree;\r
+    Predicate   *q;\r
+    int         identicalORcontextOptimization=0;\r
+    int         identicalANDcontextOptimization=0;\r
+\r
+    if (0 && !MR_usingPredNames && !MRhoisting) {\r
+      genPredTreeOrig(p,j,in_and_expr);\r
+      return;\r
+    };\r
+\r
+    MR_predContextPresent(p,&allHaveContext,&noneHaveContext);\r
+\r
+       if ( ! noneHaveContext ) {                 /* MR10 context guards ignored when -prc off */\r
+\r
+      _gen("(");\r
+\r
+            /* MR10 optimize OR predicates which are all leaves */\r
+\r
+      if (p->expr == PRED_OR_LIST && MR_allPredLeaves(p->down)) {\r
+        groupTree=MR_compute_pred_tree_context(p);\r
+        for (q=p->down ; q != NULL ; q=q->right) {\r
+          oneTree=MR_compute_pred_tree_context(q);\r
+          if (! MR_tree_equ(groupTree,oneTree)) {\r
+            Tfree(oneTree);\r
+            break;\r
+          };\r
+          Tfree(oneTree);\r
+        };\r
+        Tfree(groupTree);\r
+        if (q == NULL) {\r
+          _gen("/* MR10 individual OR gates suppressed when all predicates are leaves");\r
+          _gen(" with identical context */\n");\r
+          genPredTreeGate(p,in_and_expr);   /* use the parent's in_and_expr for this gate */\r
+          identicalORcontextOptimization=1;\r
+        } else {\r
+          MR_distinctORcontextOpt(p,j,in_and_expr);\r
+          return;\r
+        };\r
+      } else if (p->expr == PRED_AND_LIST && MR_allPredLeaves(p->down)) {\r
+\r
+            /* MR12 optimize AND predicates which are all leaves */\r
+\r
+        groupTree=MR_compute_pred_tree_context(p);\r
+        for (q=p->down ; q != NULL ; q=q->right) {\r
+          oneTree=MR_compute_pred_tree_context(q);\r
+          if (! MR_tree_equ(groupTree,oneTree)) {\r
+            Tfree(oneTree);\r
+            break;\r
+          };\r
+          Tfree(oneTree);\r
+        };\r
+        Tfree(groupTree);\r
+        if (q == NULL) {\r
+          _gen("/* MR12 individual AND gates suppressed when all predicates are leaves");\r
+          _gen(" with identical context */\n");\r
+          genPredTreeGate(p,in_and_expr);   /* use the parent's in_and_expr for this gate */\r
+          identicalANDcontextOptimization=1;\r
+        } else {\r
+          genPredTreeGate(p, in_and_expr);\r
+        };\r
+      } else {\r
+           genPredTreeGate(p, in_and_expr);\r
+      };\r
+       }\r
+\r
+       /* if leaf node, just gen predicate */\r
+\r
+       if ( p->down==NULL )\r
+       {\r
+               genPred(p,j,suppress_sva);\r
+               if ( ! noneHaveContext ) _gen(")");   /* MR10 context guards ignored when -prc off */\r
+               return;\r
+       }\r
+\r
+       /* if AND list, do both preds (only two possible) */\r
+    /* MR10    not any more ! */\r
+\r
+       if ( p->expr == PRED_AND_LIST )\r
+       {\r
+               Predicate *list;\r
+               _gen("(");\r
+               list = p->down;\r
+        for (; list != NULL; list=list->right) {\r
+          if (identicalANDcontextOptimization) {\r
+            genPred(list, j,suppress_sva);\r
+          } else {\r
+                   genPredTree(list, j, 1, suppress_sva);  /* in and context */\r
+          };\r
+          if ( list->right!=NULL ) _gen("&&");\r
+        };\r
+               _gen(")");\r
+               if ( ! noneHaveContext ) _gen(")");    /* MR10 context guards ignored when -prc off */\r
+               return;\r
+       }\r
+\r
+       if ( p->expr == PRED_OR_LIST )\r
+       {\r
+               Predicate *list;\r
+               _gen("(");\r
+               list = p->down;\r
+               for (; list!=NULL; list=list->right)\r
+               {\r
+            if (identicalORcontextOptimization) {\r
+                 genPred(list, j,suppress_sva);\r
+            } else {\r
+                     genPredTree(list, j, 0, suppress_sva);\r
+            };\r
+                       if ( list->right!=NULL ) _gen("||");\r
+               }\r
+               _gen(")");\r
+               if ( ! noneHaveContext ) _gen(")");    /* MR10 context guards ignored when -prc off */\r
+               return;\r
+       }\r
+\r
+       fatal_internal("predicate tree is wacked");\r
+}\r
+\r
+/* [genPredTreeMainXX] */\r
+\r
+Predicate *     /* MR10 */\r
+#ifdef __USE_PROTOS\r
+genPredTreeMainXX( Predicate *p, Node *j ,int in_and_expr)\r
+#else\r
+genPredTreeMainXX( p, j ,in_and_expr)\r
+    Predicate   *p;\r
+    Node        *j;\r
+    int         in_and_expr;\r
+#endif\r
+{\r
+\r
+    int     allHaveContext=1;\r
+    int     noneHaveContext=1;\r
+\r
+#if 0\r
+    fprintf(stderr,"Pred before\n");\r
+    dumppred(p);\r
+    fprintf(stderr,"\n");\r
+    fprintf(stderr,"Pred after\n");\r
+    dumppred(p);\r
+    fprintf(stderr,"\n");\r
+#endif\r
+\r
+    p=MR_predSimplifyALL(p);    /* MR10 */\r
+\r
+    require (MR_predicate_context_completed(p),"predicate context is not complete");\r
+\r
+    MR_cleanup_pred_trees(p);   /* MR10 */\r
+\r
+    MR_predContextPresent(p,&allHaveContext,&noneHaveContext);\r
+    if (!noneHaveContext & !allHaveContext) {\r
+      warnFL("predicate contains elements both with and without context",\r
+                FileStr[j->file],j->line);\r
+    };\r
+\r
+    if (InfoP) {\r
+       _gen("\n#if 0\n\n");\r
+       MR_dumpPred(p,1);\r
+       _gen("#endif\n");\r
+    };\r
+       genPredTree(p,j,in_and_expr,0);\r
+    return p;\r
+}\r
+\r
+Predicate *     /* MR10 */\r
+#ifdef __USE_PROTOS\r
+genPredTreeMain( Predicate *p, Node *j)\r
+#else\r
+genPredTreeMain( p, j)\r
+    Predicate   *p;\r
+    Node        *j;\r
+#endif\r
+{\r
+  return genPredTreeMainXX(p,j,1);\r
+}\r
+\r
+static void\r
+#ifdef __USE_PROTOS\r
+genExprTreeOriginal( Tree *t, int k )\r
+#else\r
+genExprTreeOriginal( t, k )\r
+Tree *t;\r
+int k;\r
+#endif\r
+{\r
+       require(t!=NULL, "genExprTreeOriginal: NULL tree");\r
+       \r
+       if ( t->token == ALT )\r
+       {\r
+               _gen("("); genExprTreeOriginal(t->down, k); _gen(")");\r
+               if ( t->right!=NULL )\r
+               {\r
+                       _gen("||");\r
+                       on1line++;\r
+                       if ( on1line > NumExprPerLine ) { on1line=0; _gen("\n"); }\r
+                       _gen("("); genExprTreeOriginal(t->right, k); _gen(")");\r
+               }\r
+               return;\r
+       }\r
+       if ( t->down!=NULL ) _gen("(");\r
+       _gen1("LA(%d)==",k);\r
+       if ( TokenString(t->token) == NULL ) _gen1("%d", t->token)\r
+       else _gen1("%s", TokenString(t->token));\r
+       if ( t->down!=NULL )\r
+       {\r
+               _gen("&&");\r
+               on1line++;\r
+               if ( on1line > NumExprPerLine ) { on1line=0; _gen("\n"); }\r
+               _gen("("); genExprTreeOriginal(t->down, k+1); _gen(")");\r
+       }\r
+       if ( t->down!=NULL ) _gen(")");\r
+       if ( t->right!=NULL )\r
+       {\r
+               _gen("||");\r
+               on1line++;\r
+               if ( on1line > NumExprPerLine ) { on1line=0; _gen("\n"); }\r
+               _gen("("); genExprTreeOriginal(t->right, k); _gen(")");\r
+       }\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+static void MR_LAtokenString(int k,int token)\r
+#else\r
+static void MR_LAtokenString(k,token)\r
+  int   k;\r
+  int   token;\r
+#endif\r
+{\r
+    char    *ts;\r
+\r
+    ts=TokenString(token);\r
+    if (ts == NULL) {\r
+      _gen2(" LA(%d)==%d",k,token);\r
+    } else {\r
+      _gen2(" LA(%d)==%s",k,ts);\r
+    };\r
+}\r
+\r
+\r
+#ifdef __USE_PROTOS\r
+static int MR_countLeaves(Tree *t)\r
+#else\r
+static int MR_countLeaves(t)\r
+  Tree  *t;\r
+#endif\r
+{\r
+  if (t == NULL) return 0;\r
+  if (t->token == ALT) {\r
+    return MR_countLeaves(t->down)+MR_countLeaves(t->right);\r
+  } else {\r
+    return 1+MR_countLeaves(t->down)+MR_countLeaves(t->right);\r
+  };\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+static void MR_genOneLine(Tree *tree,int k)\r
+#else\r
+static void MR_genOneLine(tree,k)\r
+  Tree      *tree;\r
+  int       k;\r
+#endif\r
+{\r
+    if (tree == NULL) return;\r
+    if (tree->token == ALT) {\r
+       MR_genOneLine(tree->down,k);\r
+    } else {\r
+       MR_LAtokenString(k,tree->token);\r
+       if (tree->down != NULL &&\r
+           tree->down->right == NULL) {\r
+          _gen(" &&");\r
+          MR_genOneLine(tree->down,k+1);\r
+       } else if (tree->down != NULL) {\r
+         _gen(" && (");\r
+         MR_genOneLine(tree->down,k+1);\r
+         _gen(")");\r
+       };\r
+    };\r
+    if (tree->right != NULL) {\r
+      _gen(" ||");\r
+      MR_genOneLine(tree->right,k);\r
+    };\r
+}\r
+\r
+static int across;\r
+static int depth;\r
+static int lastkonline;\r
+\r
+#ifdef __USE_PROTOS\r
+static void MR_genMultiLine(Tree *tree,int k)\r
+#else\r
+static void MR_genMultiLine(tree,k)\r
+  Tree  *tree;\r
+  int   k;\r
+#endif\r
+{\r
+    int     i;\r
+\r
+    if (tree == NULL) return;\r
+    if (tree->token == ALT) {\r
+      MR_genMultiLine(tree,k);\r
+    } else {\r
+      MR_LAtokenString(k,tree->token);\r
+      lastkonline=k;\r
+      across++;\r
+      if (tree->down != NULL && tree->down->right == NULL) {\r
+        if (across > 3) {\r
+          _gen("\n");\r
+          across=0;\r
+          lastkonline=0;\r
+          for (i=0 ; i < depth+k ; i++) _gen("   ");\r
+          _gen("&&");\r
+        } else {\r
+          _gen(" &&");\r
+        };\r
+        MR_genMultiLine(tree->down,k+1);\r
+      } else if (tree->down != NULL) {\r
+        _gen("\n");\r
+        lastkonline=0;\r
+        across=0;\r
+        for (i=0 ; i < depth+k ; i++) _gen("   ");\r
+        _gen("&& (");\r
+        MR_genMultiLine(tree->down,k+1);\r
+        _gen(")");\r
+      };\r
+    };\r
+    if (tree->right != NULL) {\r
+      if (k < lastkonline) {\r
+        _gen("\n");\r
+        across=0;\r
+        lastkonline=0;\r
+        for (i=0; i < depth+k-1 ; i++) _gen("   ");\r
+        _gen("||");\r
+      } else if (across > 3 ) {\r
+        _gen("\n");\r
+        across=0;\r
+        lastkonline=0;\r
+        for (i=0; i < depth+k ; i++) _gen("   ");\r
+        _gen("||");\r
+      } else {\r
+        _gen(" ||");\r
+      };\r
+      MR_genMultiLine(tree->right,k);\r
+    };\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+static void genExprTree(Tree *tree,int k)\r
+#else\r
+static void genExprTree(tree,k)\r
+  Tree  *tree;\r
+  int   k;\r
+#endif\r
+{\r
+    int     count;\r
+\r
+#if 0\r
+    /* MR20 THM This was probably an error.\r
+            The routine should probably reference that static \r
+            "across" and this declaration hides it.\r
+    */\r
+\r
+    int     across;\r
+#endif\r
+  \r
+    require (tree != NULL,"genExprTree: tree is NULL");\r
+    require (k > 0,"genExprTree: k <= 0");\r
+\r
+    if (0 && !MRhoisting) {   /* MR11 make new version standard */\r
+      genExprTreeOriginal(tree,k);\r
+    } else {\r
+      count=MR_countLeaves(tree);\r
+      if (count < 5) {\r
+        MR_genOneLine(tree,k);\r
+      } else {\r
+        _gen("\n");\r
+        across=0;\r
+        depth=0;\r
+        lastkonline=0;\r
+        MR_genMultiLine(tree,k);\r
+        _gen("\n");\r
+      };\r
+    };\r
+}\r
+\r
+\r
+/*\r
+ * Generate LL(k) type expressions of the form:\r
+ *\r
+ *              (LA(1) == T1 || LA(1) == T2 || ... || LA(1) == Tn) &&\r
+ *              (LA(2) == T1 || LA(2) == T2 || ... || LA(2) == Tn) &&\r
+ *                     .....\r
+ *              (LA(k) == T1 || LA(k) == T2 || ... || LA(k) == Tn)\r
+ *\r
+ * If GenExprSetsOpt generate:\r
+ *\r
+ *             (setwdi[LA(1)]&(1<<j)) && (setwdi[LA(2)]&(1<<j)) ...\r
+ *\r
+ * where n is set_deg(expr) and Ti is some random token and k is the last nonempty\r
+ * set in fset <=CLL_k.\r
+ * k=1..CLL_k where CLL_k >= 1.\r
+ *\r
+ * This routine is visible only to this file and cannot answer a TRANS message.\r
+ *\r
+ */\r
+\r
+/*  [genExpr] */\r
+\r
+static int\r
+#ifdef __USE_PROTOS\r
+genExpr( Junction *j )\r
+#else\r
+genExpr( j )\r
+Junction *j;\r
+#endif\r
+{\r
+       int max_k;\r
+\r
+       /* if full LL(k) is sufficient, then don't use approximate (-ck) lookahead\r
+        * from CLL_k..LL_k\r
+        */\r
+       {\r
+               int limit;\r
+               if ( j->ftree!=NULL ) limit = LL_k;\r
+               else limit = CLL_k;\r
+               max_k = genExprSets(j->fset, limit);\r
+       }\r
+\r
+       /* Do tests for real tuples from other productions that conflict with\r
+        * artificial tuples generated by compression (using sets of tokens\r
+        * rather than k-trees).\r
+        */\r
+       if ( j->ftree != NULL )\r
+       {\r
+               _gen(" && !("); genExprTree(j->ftree, 1); _gen(")");\r
+       }\r
+\r
+       if ( ParseWithPredicates && j->predicate!=NULL )\r
+       {\r
+               Predicate *p = j->predicate;\r
+               warn_about_using_gk_option();\r
+               _gen("&&");\r
+               j->predicate=genPredTreeMain(p, (Node *)j);     /* MR10 */\r
+       }\r
+\r
+       return max_k;\r
+}\r
+\r
+static int\r
+#ifdef __USE_PROTOS\r
+genExprSets( set *fset, int limit )\r
+#else\r
+genExprSets( fset, limit )\r
+set *fset;\r
+int limit;\r
+#endif\r
+{\r
+       int k = 1;\r
+       int max_k = 0;\r
+       unsigned *e, *g, firstTime=1;\r
+\r
+    if (set_nil(fset[1])) {\r
+      _gen(" 0 /* MR13 empty set expression  - undefined rule ? infinite left recursion ? */ ");\r
+      MR_BadExprSets++;\r
+    };\r
+\r
+       if ( GenExprSetsOpt )\r
+       {\r
+               while ( k <= limit && !set_nil(fset[k]) )   /* MR11 */\r
+               {\r
+                       if ( set_deg(fset[k])==1 )      /* too simple for a set? */\r
+                       {\r
+                               int e;\r
+                               _gen1("(LA(%d)==",k);\r
+                               e = set_int(fset[k]);\r
+                               if ( TokenString(e) == NULL ) _gen1("%d)", e)\r
+                               else _gen1("%s)", TokenString(e));\r
+                       }\r
+                       else\r
+                       {\r
+                               NewSet();\r
+                               FillSet( fset[k] );\r
+                               _gen3("(setwd%d[LA(%d)]&0x%x)", wordnum, k, 1<<setnum);\r
+                       }\r
+                       if ( k>max_k ) max_k = k;\r
+                       if ( k == CLL_k ) break;\r
+                       k++;\r
+                       if ( k<=limit && !set_nil(fset[k]) ) _gen(" && ");  /* MR11 */\r
+                       on1line++;\r
+                       if ( on1line > NumExprPerLine ) { on1line=0; _gen("\n"); }\r
+               }\r
+               return max_k;\r
+       }\r
+\r
+       while ( k<= limit &&  !set_nil(fset[k]) )       /* MR11 */\r
+       {\r
+               if ( (e=g=set_pdq(fset[k])) == NULL ) fatal_internal("genExpr: cannot allocate IF expr pdq set");\r
+               for (; *e!=nil; e++)\r
+               {\r
+                       if ( !firstTime ) _gen(" || ") else { _gen("("); firstTime = 0; }\r
+                       on1line++;\r
+                       if ( on1line > NumExprPerLine ) { on1line=0; _gen("\n"); }\r
+                       _gen1("LA(%d)==",k);\r
+                       if ( TokenString(*e) == NULL ) _gen1("%d", *e)\r
+                       else _gen1("%s", TokenString(*e));\r
+               }\r
+               free( (char *)g );\r
+               _gen(")");\r
+               if ( k>max_k ) max_k = k;\r
+               if ( k == CLL_k ) break;\r
+               k++;\r
+               if ( k <= limit && !set_nil(fset[k]) ) { firstTime=1; _gen(" && "); }   /* MR11 */\r
+               on1line++;\r
+               if ( on1line > NumExprPerLine ) { on1line=0; _gen("\n"); }\r
+       }\r
+       return max_k;\r
+}\r
+\r
+/*\r
+ * Generate code for any type of block.  If the last alternative in the block is\r
+ * empty (not even an action) don't bother doing it.  This permits us to handle\r
+ * optional and loop blocks as well.\r
+ *\r
+ * Only do this block, return after completing the block.\r
+ * This routine is visible only to this file and cannot answer a TRANS message.\r
+ */\r
+static set\r
+#ifdef __USE_PROTOS\r
+genBlk( Junction *q, int jtype, int *max_k, int *need_right_curly, int * lastAltEmpty /* MR23 */)\r
+#else\r
+genBlk( q, jtype, max_k, need_right_curly, lastAltEmpty /* MR23 */)\r
+Junction *q;\r
+int jtype;\r
+int *max_k;\r
+int *need_right_curly;\r
+int *lastAltEmpty; /* MR23 */\r
+#endif\r
+{\r
+       set f;\r
+       Junction *alt;\r
+       int a_guess_in_block = 0;\r
+       require(q!=NULL,                                "genBlk: invalid node");\r
+       require(q->ntype == nJunction,  "genBlk: not junction");\r
+       *need_right_curly=0;\r
+       *lastAltEmpty = 0;              /* MR23 */\r
+       if ( q->p2 == NULL )    /* only one alternative?  Then don't need if */\r
+       {       \r
+               if (first_item_is_guess_block((Junction *)q->p1)!=NULL )\r
+               {\r
+            if (jtype != aLoopBlk && jtype != aOptBlk && jtype != aPlusBlk) {\r
+                         warnFL("(...)? as only alternative of block is unnecessary", FileStr[q->file], q->line);\r
+            };\r
+                   gen("zzGUESS\n");   /* guess anyway to make output code consistent */\r
+/* MR10 disable */  /**** gen("if ( !zzrv )\n"); ****/\r
+/* MR10 */          gen("if ( !zzrv ) {\n"); tabs++; (*need_right_curly)++;\r
+        };\r
+               TRANS(q->p1);\r
+               return empty;           /* no decision to be made-->no error set */\r
+       }\r
+\r
+       f = First(q, 1, jtype, max_k);\r
+       for (alt=q; alt != NULL; alt= (Junction *) alt->p2 )\r
+       {\r
+               if ( alt->p2 == NULL )                                  /* chk for empty alt */\r
+               {       \r
+                       Node *p = alt->p1;\r
+                       if ( p->ntype == nJunction )\r
+                       {\r
+                               /* we have empty alt */\r
+/* MR23\r
+   There is a conflict between giving good error information for non-exceptions\r
+   and making life easy for those using parser exception handling.  Consider:\r
+\r
+         r: { A } b;\r
+                b: B;\r
+                \r
+                  with input "C"\r
+\r
+   Before MR21 the error message would be "expecting B - found C".  After MR21\r
+   the error message would be "expcect A, B - found C".  This was good, but it\r
+   caused problems for those using parser exceptions because the reference to\r
+   B was generated inside the {...} where B really wasn't part of the block.\r
+\r
+   In MR23 this has been changed for the case where exceptions are in use to\r
+   not generate the extra check in the tail of the {A} block.\r
+*/\r
+\r
+\r
+/* MR23 */     if (isEmptyAlt( ((Junction *)p)->p1, (Node *)q->end)) {\r
+/* MR23 */      *lastAltEmpty = 1;\r
+/* MR23 */             if (FoundException) {\r
+/* MR23 */                     /* code to restore state if a prev alt didn't follow guess */\r
+/* MR23 */                     if ( a_guess_in_block && jtype != aPlusBlk) {\r
+/* MR23 */                             gen("if ( !zzrv ) zzGUESS_DONE; /* MR28 */\n");\r
+/* MR23 */                     }\r
+/* MR23 */                     break;\r
+/* MR23 */             };\r
+/* MR28 */      if (jtype == aPlusBlk) {\r
+/* MR28 */          break;\r
+/* MR28 */      }\r
+/* MR23 */     }\r
+               }\r
+       } /* end of for loop on alt */\r
+\r
+/* MR10 */        if (alt->p2 == NULL &&\r
+/* MR10 */               ( q->jtype == aSubBlk || q->jtype == RuleBlk) ) {\r
+/* MR10 */          if (first_item_is_guess_block(alt)) {\r
+/* MR10 */               warnFL("(...)? as last alternative of block is unnecessary",\r
+/* MR10 */                                FileStr[alt->file],alt->line);\r
+/* MR10 */          };\r
+/* MR10 */        };\r
+\r
+               if ( alt != q ) gen("else ")\r
+               else\r
+               {\r
+                       if ( DemandLookahead ) {\r
+                               if ( !GenCC ) {gen1("LOOK(%d);\n", *max_k);}\r
+                               else gen1("look(%d);\n", *max_k);\r
+                       }\r
+               }\r
+\r
+               if ( alt!=q )\r
+               {\r
+                       _gen("{\n");\r
+                       tabs++;\r
+                       (*need_right_curly)++;\r
+                       /* code to restore state if a prev alt didn't follow guess */\r
+                       if ( a_guess_in_block )\r
+                               gen("if ( !zzrv ) zzGUESS_DONE;\n");\r
+               }\r
+               if ( first_item_is_guess_block((Junction *)alt->p1)!=NULL )\r
+               {\r
+                       a_guess_in_block = 1;\r
+                       gen("zzGUESS\n");\r
+               }\r
+               gen("if ( ");\r
+               if ( first_item_is_guess_block((Junction *)alt->p1)!=NULL ) _gen("!zzrv && ");\r
+               genExpr(alt);\r
+               _gen(" ) ");\r
+               _gen("{\n");\r
+               tabs++;\r
+               TRANS(alt->p1);\r
+               --tabs;\r
+               gen("}\n");\r
+/* MR10 */        if (alt->p2 == NULL) {\r
+/* MR10 */          if (first_item_is_guess_block(alt)) {\r
+/* MR10 */            gen("/* MR10 */ else {\n");\r
+/* MR10 */            tabs++;\r
+/* MR10 */               (*need_right_curly)++;\r
+/* MR10 */               /* code to restore state if a prev alt didn't follow guess */\r
+/* MR10 */            gen("/* MR10 */ if ( !zzrv ) zzGUESS_DONE;\n");\r
+/* MR10 */            gen("/* MR10 */ if (0) {}     /* last alternative of block is guess block */\n");\r
+/* MR10 */          };\r
+/* MR10 */        };\r
+       }\r
+       return f;\r
+}\r
+\r
+static int\r
+#ifdef __USE_PROTOS\r
+has_guess_block_as_first_item( Junction *q )\r
+#else\r
+has_guess_block_as_first_item( q )\r
+Junction *q;\r
+#endif\r
+{\r
+       Junction *alt;\r
+\r
+       for (alt=q; alt != NULL; alt= (Junction *) alt->p2 )\r
+       {\r
+               if ( first_item_is_guess_block((Junction *)alt->p1)!=NULL ) return 1;\r
+       }\r
+       return 0;\r
+}\r
+\r
+static int\r
+#ifdef __USE_PROTOS\r
+has_guess_block_as_last_item( Junction *q )\r
+#else\r
+has_guess_block_as_last_item( q )\r
+Junction *q;\r
+#endif\r
+{\r
+       Junction *alt;\r
+\r
+    if (q == NULL) return 0;\r
+       for (alt=q; alt->p2 != NULL && !( (Junction *) alt->p2)->ignore; alt= (Junction *) alt->p2 ) {};\r
+    return first_item_is_guess_block( (Junction *) alt->p1) != NULL;\r
+}\r
+\r
+/* MR30 See description of first_item_is_guess_block for background */\r
+\r
+Junction *\r
+#ifdef __USE_PROTOS\r
+first_item_is_guess_block_extra(Junction *q )\r
+#else\r
+first_item_is_guess_block_extra(q)\r
+Junction *q;\r
+#endif\r
+{\r
+       while ( q!=NULL &&\r
+            (  ( q->ntype==nAction ) ||\r
+               ( q->ntype==nJunction &&\r
+                    (q->jtype==Generic || q->jtype == aLoopBlk) \r
+               )\r
+            )\r
+          )\r
+       {\r
+               if ( q->ntype==nJunction ) q = (Junction *)q->p1;\r
+               else q = (Junction *) ((ActionNode *)q)->next;\r
+       }\r
+\r
+       if ( q==NULL ) return NULL;\r
+       if ( q->ntype!=nJunction ) return NULL;\r
+       if ( q->jtype!=aSubBlk ) return NULL;\r
+       if ( !q->guess ) return NULL;\r
+\r
+       return q;\r
+}\r
+\r
+/* return NULL if 1st item of alt is NOT (...)? block; else return ptr to aSubBlk node\r
+ * of (...)?;  This function ignores actions and predicates.\r
+ */\r
+\r
+Junction *\r
+#ifdef __USE_PROTOS\r
+first_item_is_guess_block( Junction *q )\r
+#else\r
+first_item_is_guess_block( q )\r
+Junction *q;\r
+#endif\r
+{\r
+       Junction * qOriginal = q;       /* DEBUG */\r
+\r
+    /* MR14  Couldn't find aSubBlock which was a guess block when it lay\r
+             behind aLoopBlk.  The aLoopBlk only appear in conjunction with\r
+             aLoopBegin, but the routine didn't know that.  I think.\r
+\r
+       MR14a Added extra parentheses to clarify precedence\r
+\r
+          MR30  This appears to have been a mistake.  The First set was then\r
+                computed incorrectly for:\r
+\r
+                                       r : ( (A)? B\r
+                                           | C\r
+                                               )*\r
+                        \r
+                        The routine analysis_point was seeing the guess block when\r
+                        it was still analyzing the loopBegin block.  As a consequence,\r
+                        when it looked for the analysis_point it was processing the B, but\r
+                        skipping over the C alternative altogether because it thought\r
+                        it was looking at a guess block, not realizing there was a loop\r
+                        block in front of the loopBegin.\r
+\r
+             loopBegin  loopBlk  subBlk/guess  A  G  EB  G  B EB EB  EB  ER\r
+                           |          |          |                     ^   ^\r
+                               |                  |                                |   |\r
+                |          +-> G  C G ----------------------+   |\r
+                |                                               |\r
+                               +--- G G G -------------------------------------+\r
+    \r
+                        Reported by Arpad Beszedes (beszedes@inf.u-szeged.hu).\r
+\r
+               MR30  This is still more complicated.  This fix caused ambiguity messages\r
+               to be reported for "( (A B)? )* A B" but not for "( (A B)? )+".  Why is\r
+               there a difference when these are outwardly identical ?  It is because the\r
+               start of a (...)* block is represented by two nodes: a loopBegin block\r
+               followed by a loopBlock whereas the start of a (...)+ block is\r
+               represented as a single node: a plusBlock.  So if first_item_is_guess_block\r
+               is called when the current node is a loopBegin it starts with the\r
+               loop block rather than the the sub block which follows the loop block.\r
+               However, we can't just skip past the loop block because some routines\r
+               depend on the old implementation.  So, we provide a new implementation\r
+               which does skip the loopBlock.  However, which should be called when ?\r
+               I'm not sure, but my guess is that first_item_is_guess_block_extra (the\r
+               new one) should only be called for the ambiguity routines.\r
+\r
+    */\r
+\r
+       while ( q!=NULL &&\r
+            (  ( q->ntype==nAction ) ||\r
+               ( q->ntype==nJunction &&\r
+                    (q->jtype==Generic /*** || q->jtype == aLoopBlk ***/ ) /*** MR30 Undo MR14 change ***/\r
+               )\r
+            )\r
+          )\r
+       {\r
+               if ( q->ntype==nJunction ) q = (Junction *)q->p1;\r
+               else q = (Junction *) ((ActionNode *)q)->next;\r
+       }\r
+\r
+       if ( q==NULL ) return NULL;\r
+       if ( q->ntype!=nJunction ) return NULL;\r
+       if ( q->jtype!=aSubBlk ) return NULL;\r
+       if ( !q->guess ) return NULL;\r
+\r
+       return q;\r
+}\r
+\r
+/* MR1                                                                                     */\r
+/* MR1  10-Apr-97 MR1 Routine to stringize failed semantic predicates msgs  */\r
+/* MR1                                                                                 */\r
+\r
+#define STRINGIZEBUFSIZE 1024\r
+\r
+static char stringizeBuf[STRINGIZEBUFSIZE];\r
+char *\r
+#ifdef __USE_PROTOS\r
+stringize(char * s)\r
+#else\r
+stringize(s)\r
+char *s;\r
+#endif\r
+\r
+{\r
+  char         *p;\r
+  char         *stop;\r
+\r
+  p=stringizeBuf;\r
+  stop=&stringizeBuf[1015];\r
+\r
+  if (s != 0) {\r
+    while (*s != 0) {\r
+      if (p >= stop) {\r
+       goto stringizeStop;\r
+      } else if (*s == '\n') {\r
+        *p++='\\';\r
+        *p++='n';\r
+        *p++='\\';\r
+       *p++=*s++;\r
+      } else if (*s == '\\') {\r
+       *p++=*s;\r
+       *p++=*s++;\r
+      } else if (*s == '\"') {\r
+        *p++='\\';\r
+       *p++=*s++;\r
+        while (*s != 0) {\r
+          if (p >= stop) {\r
+            goto stringizeStop;\r
+         } else if (*s == '\n') {\r
+           *p++='\\';\r
+           *p++=*s++;\r
+         } else if (*s == '\\') {\r
+           *p++=*s++;\r
+           *p++=*s++;\r
+         } else if (*s == '\"') {\r
+           *p++='\\';\r
+           *p++=*s++;\r
+           break;\r
+         } else {\r
+           *p++=*s++;\r
+          };\r
+        };\r
+      } else if (*s == '\'') {\r
+       *p++=*s++;\r
+        while (*s != 0) {\r
+          if (p >= stop) {\r
+            goto stringizeStop;\r
+         } else if (*s == '\'') {\r
+           *p++=*s++;\r
+           break;\r
+         } else if (*s == '\\') {\r
+           *p++=*s++;\r
+           *p++=*s++;\r
+         } else if (*s == '\"') {\r
+           *p++='\\';\r
+           *p++=*s++;\r
+           break;\r
+         } else {\r
+           *p++=*s++;\r
+          };\r
+        };\r
+      } else {\r
+        *p++=*s++;\r
+      };\r
+    };\r
+  };\r
+  goto stringizeExit;\r
+stringizeStop:\r
+  *p++='.';            \r
+  *p++='.';            \r
+  *p++='.';            \r
+stringizeExit:\r
+  *p=0;\r
+  return stringizeBuf;\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+int isNullAction(char *s)\r
+#else\r
+int isNullAction(s)\r
+  char  *s;\r
+#endif\r
+{\r
+  char  *p;\r
+  for (p=s; *p != '\0' ; p++) {\r
+    if (*p != ';' && *p !=' ') return 0;\r
+  };\r
+  return 1;\r
+}\r
+/* MR1                                                                                                     */\r
+/* MR1 End of Routine to stringize code for failed predicates msgs         */\r
+/* MR1                                                                                 */\r
+\r
+/* Generate an action.  Don't if action is NULL which means that it was already\r
+ * handled as an init action.\r
+ */\r
+void\r
+#ifdef __USE_PROTOS\r
+genAction( ActionNode *p )\r
+#else\r
+genAction( p )\r
+ActionNode *p;\r
+#endif\r
+{\r
+       require(p!=NULL,                        "genAction: invalid node and/or rule");\r
+       require(p->ntype==nAction,      "genAction: not action");\r
+\r
+       if ( !p->done )  /* MR10 */ /* MR11 */\r
+       {\r
+               if ( p->is_predicate)\r
+               {\r
+                       if ( p->guardpred != NULL )\r
+                       {\r
+                Predicate *guardDup=predicate_dup(p->guardpred); /* MR10 */\r
+                gen("if (!");\r
+                               guardDup=genPredTreeMain(guardDup, (Node *)p);\r
+                predicate_free(guardDup);\r
+                       }\r
+/* MR10 */  else if (p->ampersandPred != NULL) {\r
+/* MR10 */      gen("if (!");\r
+/* MR10 */      p->ampersandPred=genPredTreeMain(p->ampersandPred, (Node *)p);\r
+/* MR10 */  }\r
+                       else\r
+                       {\r
+                               gen("if (!(");\r
+                               /* make sure that '#line n' is on front of line */\r
+                               if ( GenLineInfo && p->file != -1 ) _gen("\n");\r
+                               dumpPredAction(p,p->action, output, 0, p->file, p->line, 0);\r
+                               _gen(")");\r
+                       }\r
+\r
+/* MR23 Change failed predicate macro to have three arguments:\r
+\r
+        macro arg 1: The stringized predicate itself\r
+        macro arg 2: 0 => no user-defined error action\r
+                     1 => user-defined error action\r
+        macro arg 3: The user-defined error action\r
+\r
+   This gives the user more control of the error action.\r
+*/\r
+                       tabs++;\r
+                       gen3(") {zzfailed_pred(\"%s\",%s, { %s } );}\n",         /* MR23 */\r
+                                       stringize(p->action),                            /* MR23 */\r
+                    (p->pred_fail == NULL ?                          /* MR23/MR27 */\r
+                               "0 /* report */" : "1 /* user action */"),   /* MR23/MR27 */\r
+                    (p->pred_fail == NULL ?                          /* MR23 */\r
+                        "0; /* no user action */" : p->pred_fail));  /* MR23 */\r
+                       tabs--;\r
+               }\r
+               else    /* not a predicate */\r
+               {\r
+            if (! isNullAction(p->action) && !p->noHoist) {\r
+                         if ( FoundGuessBlk ) {\r
+                               if ( GenCC ) {\r
+                  gen("if ( !guessing ) {\n");\r
+                } else {\r
+                                 gen("zzNON_GUESS_MODE {\n");\r
+                };\r
+              };\r
+                         dumpActionPlus(p, p->action, output, tabs, p->file, p->line, 1); /* MR21 */\r
+                         if ( FoundGuessBlk ) gen("}\n");\r
+            };\r
+               }\r
+       }\r
+       TRANS(p->next)\r
+}\r
+\r
+/*\r
+ *             if invoking rule has !noAST pass zzSTR to rule ref and zzlink it in\r
+ *             else pass addr of temp root ptr (&_ast) (don't zzlink it in).\r
+ *\r
+ *             if ! modifies rule-ref, then never link it in and never pass zzSTR.\r
+ *             Always pass address of temp root ptr.\r
+ */\r
+void\r
+#ifdef __USE_PROTOS\r
+genRuleRef( RuleRefNode *p )\r
+#else\r
+genRuleRef( p )\r
+RuleRefNode *p;\r
+#endif\r
+{\r
+       Junction *q;\r
+       char *handler_id = "";\r
+       RuleEntry *r, *r2;\r
+       char *parm = "", *exsig = "";\r
+\r
+    int     genRuleRef_emittedGuessGuard=0;     /* MR10 */\r
+\r
+       require(p!=NULL,                        "genRuleRef: invalid node and/or rule");\r
+       require(p->ntype==nRuleRef, "genRuleRef: not rule reference");\r
+       \r
+       if ( p->altstart!=NULL && p->altstart->exception_label!=NULL )\r
+               handler_id = p->altstart->exception_label;\r
+\r
+       r = (RuleEntry *) hash_get(Rname, p->text);\r
+       if ( r == NULL )\r
+       {\r
+               warnFL( eMsg1("rule %s not defined",\r
+                                         p->text), FileStr[p->file], p->line );\r
+               return;\r
+       }\r
+\r
+/* MR8 5-Aug-97     Reported by S.Bochnak@microtool.com.pl                  */\r
+/*                  Don't do assign when no return values declared          */\r
+/*                  Move definition of q up and use it to guard p->assign   */\r
+\r
+       q = RulePtr[r->rulenum];        /* find definition of ref'd rule */  /* MR8 */\r
+\r
+       r2 = (RuleEntry *) hash_get(Rname, p->rname);\r
+       if ( r2 == NULL ) {warnNoFL("Rule hash table is screwed up beyond belief"); return;}\r
+\r
+    OutLineInfo(output,p->line,FileStr[p->file]);\r
+\r
+       if ( GenCC && GenAST ) {\r
+               gen("_ast = NULL;\n");\r
+       }\r
+\r
+       if ( FoundGuessBlk && p->assign!=NULL && q->ret != NULL ) {      /* MR8 */\r
+               if ( GenCC ) {\r
+          gen("if ( !guessing ) {\n");\r
+        } else {\r
+          gen("zzNON_GUESS_MODE {\n");\r
+        };\r
+        tabs++;                                                      /* MR11 */\r
+        genRuleRef_emittedGuessGuard=1;                              /* MR11 */\r
+    };\r
+\r
+       if ( FoundException ) exsig = "&_signal";\r
+\r
+       tab();\r
+       if ( GenAST )\r
+       {\r
+               if ( GenCC ) {\r
+/****                  if ( r2->noAST || p->astnode==ASTexclude )\r
+****/\r
+                       {\r
+/****                          _gen("_ast = NULL;\n");\r
+****/\r
+                               parm = "&_ast";\r
+                       }\r
+/*** we always want to set just a pointer now, then set correct\r
+pointer after\r
+\r
+                       else {\r
+                               _gen("_astp =\r
+(_tail==NULL)?(&_sibling):(&(_tail->_right));\n");\r
+                               parm = "_astp";\r
+                       }\r
+****/\r
+               }\r
+               else {\r
+                       if ( r2->noAST || p->astnode==ASTexclude )\r
+                       {\r
+                               _gen("_ast = NULL; ");\r
+                               parm = "&_ast";\r
+                       }\r
+                       else parm = "zzSTR";\r
+               }\r
+               if ( p->assign!=NULL && q->ret!=NULL )                       /* MR8 */\r
+               {\r
+                       if ( !hasMultipleOperands(p->assign) ) {_gen1("%s = ",p->assign);} /* MR23 */\r
+                       else _gen1("{ struct _rv%d _trv; _trv = ", r->rulenum);\r
+               }\r
+               if ( FoundException ) {\r
+                       _gen5("%s%s(%s,&_signal%s%s); ",\r
+                                 RulePrefix,\r
+                                 p->text,\r
+                                 parm,\r
+                                 (p->parms!=NULL)?",":"",\r
+                                 (p->parms!=NULL)?p->parms:"");\r
+                       if ( p->ex_group!=NULL ) {\r
+                               _gen("\n");\r
+                               gen("if (_signal) {\n");\r
+                               tabs++;\r
+                               dumpException(p->ex_group, 0);\r
+                               tabs--;\r
+                               gen("}");\r
+                       }\r
+                       else {\r
+                               _gen1("if (_signal) goto %s_handler;", handler_id);\r
+                       }\r
+               }\r
+               else {\r
+                       _gen5("%s%s(%s%s%s);",\r
+                                 RulePrefix,\r
+                                 p->text,\r
+                                 parm,\r
+                                 (p->parms!=NULL)?",":"",\r
+                                 (p->parms!=NULL)?p->parms:"");\r
+               }\r
+               if ( GenCC && (r2->noAST || p->astnode==ASTexclude) )\r
+               {\r
+                       /* rule has a ! or element does */\r
+                       /* still need to assign to #i so we can play with it */\r
+                       _gen("\n");\r
+                       gen2("_ast%d%d = (AST *)_ast;", BlkLevel-1, p->elnum);\r
+               }\r
+               else if ( !r2->noAST && p->astnode == ASTinclude )\r
+               {\r
+                       /* rule doesn't have a ! and neither does element */\r
+/* MR10 */  if (FoundGuessBlk && !genRuleRef_emittedGuessGuard) {\r
+/* MR10 */    _gen("\n");\r
+/* MR10 */    if (GenCC) gen ("if (!guessing) {    /* MR10 */")\r
+/* MR10 */          else gen ("if (!zzguessing) {    /* MR10 */\n");\r
+/* MR10 */    tabs++;\r
+/* MR10 */  };\r
+                       if ( GenCC ) {\r
+                               _gen("\n");\r
+                               gen("if ( _tail==NULL ) _sibling = _ast; else _tail->setRight(_ast);\n");\r
+                               gen2("_ast%d%d = (AST *)_ast;\n", BlkLevel-1, p->elnum);\r
+                               tab();\r
+                       }\r
+                       else _gen(" ");\r
+            if ( GenCC ) {\r
+                _gen("ASTBase::"); }\r
+                else _gen("zz");\r
+                       _gen("link(_root, &_sibling, &_tail);");\r
+\r
+/* MR10 */  if (FoundGuessBlk && !genRuleRef_emittedGuessGuard) {     /* MR10 */\r
+/* MR10 */    _gen("\n");\r
+/* MR10 */    tabs--;\r
+/* MR10 */    if (GenCC) gen ("};    /* MR10 */")\r
+/* MR10 */          else gen ("};    /* MR10 */");\r
+/* MR10 */  };\r
+               }\r
+       }\r
+       else\r
+       {\r
+               if ( p->assign!=NULL && q->ret!=NULL )                       /* MR8 */\r
+               {\r
+                       if ( !hasMultipleOperands(p->assign) ) {_gen1("%s = ",p->assign);} /* MR23 */\r
+                       else _gen1("{ struct _rv%d _trv; _trv = ", r->rulenum);\r
+               }\r
+               if ( FoundException ) {\r
+                       _gen4("%s%s(&_signal%s%s); ",\r
+                                 RulePrefix,\r
+                                 p->text,\r
+                                 (p->parms!=NULL)?",":"",\r
+                                 (p->parms!=NULL)?p->parms:"");\r
+                       if ( p->ex_group!=NULL ) {\r
+                               _gen("\n");\r
+                               gen("if (_signal) {\n");\r
+                               tabs++;\r
+                               dumpException(p->ex_group, 0);\r
+                               tabs--;\r
+                               gen("}");\r
+                       }\r
+                       else {\r
+                               _gen1("if (_signal) goto %s_handler;", handler_id);\r
+                       }\r
+               }\r
+               else {\r
+                       _gen3("%s%s(%s);",\r
+                                 RulePrefix,\r
+                                 p->text,\r
+                                 (p->parms!=NULL)?p->parms:"");\r
+               }\r
+               if ( p->assign!=NULL && q->ret!=NULL ) _gen("\n");           /* MR8 */\r
+       }\r
+\r
+       if ( p->assign!=NULL && q->ret!=NULL) {                          /* MR8 */\r
+               if ( hasMultipleOperands(p->assign) )                        /* MR23 */\r
+               {\r
+                       _gen("\n");\r
+                       dumpRetValAssign(p->assign, q->ret, p);                  /* MR30 */\r
+                       _gen("}");\r
+               }\r
+       }\r
+       _gen("\n");\r
+\r
+       /* Handle element labels now */\r
+       if ( p->el_label!=NULL )\r
+       {\r
+               if ( GenAST )\r
+               {\r
+                       if ( GenCC ) {\r
+                               gen3("%s_ast = _ast%d%d;\n", p->el_label, BlkLevel-1, p->elnum);\r
+                       }\r
+                       else {gen1("%s_ast = zzastCur;\n", p->el_label);}\r
+               }\r
+               else if (!GenCC ) {\r
+                       gen1("%s = zzaCur;\n", p->el_label);\r
+        }\r
+       }\r
+\r
+       if ( FoundGuessBlk && p->assign!=NULL && q->ret!=NULL ) {       /* MR8 */\r
+               /* in guessing mode, don't branch to handler upon error */\r
+        tabs--;                                                     /* MR11 */\r
+               gen("} else {\n");\r
+        tabs++;                                                     /* MR11 */\r
+               if ( FoundException ) {\r
+                       gen6("%s%s(%s%s&_signal%s%s);\n",\r
+                                RulePrefix,\r
+                                p->text,\r
+                                parm,\r
+                 (*parm!='\0')?",":"",\r
+                 (p->parms!=NULL)?",":"",\r
+                                (p->parms!=NULL)?p->parms:"");\r
+               }\r
+               else {\r
+                       gen5("%s%s(%s%s%s);\n",\r
+                                RulePrefix,\r
+                                p->text,\r
+                                parm,\r
+                                (p->parms!=NULL && *parm!='\0')?",":"",\r
+                                (p->parms!=NULL)?p->parms:"");\r
+               }\r
+        tabs--;                                                     /* MR11 */\r
+               gen("}\n");\r
+       }\r
+       TRANS(p->next)\r
+}\r
+\r
+/*\r
+ * Generate code to match a token.\r
+ *\r
+ * Getting the next token is tricky.  We want to ensure that any action\r
+ * following a token is executed before the next GetToken();\r
+ */\r
+void\r
+#ifdef __USE_PROTOS\r
+genToken( TokNode *p )\r
+#else\r
+genToken( p )\r
+TokNode *p;\r
+#endif\r
+{\r
+       RuleEntry *r;\r
+       char *handler_id = "";\r
+       ActionNode *a;\r
+       char *set_name;\r
+       char *set_nameErrSet;\r
+       int complement;\r
+       int ast_label_in_action = 0;    /* MR27 */\r
+       int pushedCmodeAST = 0;                 /* MR27 */\r
+\r
+       require(p!=NULL,                        "genToken: invalid node and/or rule");\r
+       require(p->ntype==nToken,       "genToken: not token");\r
+       if ( p->altstart!=NULL && p->altstart->exception_label!=NULL )\r
+               handler_id = p->altstart->exception_label;\r
+\r
+       r = (RuleEntry *) hash_get(Rname, p->rname);\r
+       if ( r == NULL ) {warnNoFL("Rule hash table is screwed up beyond belief"); return;}\r
+\r
+/*\r
+ * MR27 Has the element label been referenced as an AST (with the # operator) ?\r
+ *      If so, then we'll want to build the AST even though the user has used\r
+ *      the ! operator.\r
+ */\r
+/* MR27 */     if (GenAST && p->el_label != NULL) {\r
+/* MR27 */             ast_label_in_action = list_search_cstring(r->ast_labels_in_actions,\r
+/* MR27 */                                                       p->el_label);\r
+/* MR27 */     }\r
+       \r
+    OutLineInfo(output,p->line,FileStr[p->file]);\r
+\r
+       if ( !set_nil(p->tset) )        /* implies '.', ~Tok, or tokenclass */\r
+       {\r
+               unsigned e;\r
+               unsigned eErrSet = 0;\r
+               set b;\r
+               set bErrSet;                                    /* MR23 */\r
+               b = set_dup(p->tset);\r
+               bErrSet = set_dup(p->tset);         /* MR23 */\r
+               complement = p->complement; /* MR23 */\r
+               if ( p->tclass!=NULL  && complement == 0 /* MR23 */) { /* token class not complemented*/\r
+                       static char buf[MaxRuleName+20];            /* MR23 */\r
+                       static char bufErrSet[MaxRuleName+20];  /* MR23 */\r
+                       if ( p->tclass->dumped ) {\r
+                               e = p->tclass->setnum;\r
+                               eErrSet = p->tclass->setnumErrSet;\r
+                       }\r
+                       else {\r
+                               e = DefErrSet(&b, 0, TokenString(p->token));\r
+                               eErrSet = DefErrSetWithSuffix(0, &bErrSet, 1, TokenString(p->token), "_errset");\r
+                               p->tclass->dumped = 1;  /* indicate set has been created */\r
+                               p->tclass->setnum = e;\r
+                               p->tclass->setnumErrSet = eErrSet;                                      /* MR23 */\r
+                       }\r
+                       sprintf(buf, "%s_set", TokenString(p->token));\r
+                       sprintf(bufErrSet, "%s_errset", TokenString(p->token)); /* MR23 */\r
+                       set_name = buf;\r
+                       set_nameErrSet = bufErrSet;                                                             /* MR23 */\r
+               }\r
+\r
+               /* MR23 - Forgot about the case of ~TOKCLASS. */\r
+\r
+               else if ( p->tclass!=NULL  && complement != 0 /* MR23 */)\r
+               {\r
+                       static char buf[MaxRuleName+20];            /* MR23 */\r
+                       static char bufErrSet[MaxRuleName+20];  /* MR23 */\r
+                       if ( p->tclass->dumpedComplement ) {\r
+                               e = p->tclass->setnumComplement;\r
+                               eErrSet = p->tclass->setnumErrSetComplement;\r
+                       }\r
+                       else {\r
+                               e = DefErrSetWithSuffix(0, &b, 0, TokenString(p->token), "_setbar");\r
+                               eErrSet = DefErrSetWithSuffix(0, &bErrSet, 1, TokenString(p->token), "_errsetbar");\r
+                               p->tclass->dumpedComplement = 1;        /* indicate set has been created */\r
+                               p->tclass->setnumComplement = e;\r
+                               p->tclass->setnumErrSetComplement = eErrSet;                                    /* MR23 */\r
+                       }\r
+                       sprintf(buf, "%s_setbar", TokenString(p->token));\r
+                       sprintf(bufErrSet, "%s_errsetbar", TokenString(p->token));      /* MR23 */\r
+                       set_name = buf;\r
+                       set_nameErrSet = bufErrSet;                                                             /* MR23 */\r
+               }\r
+               else {                                  /* wild card */\r
+                       static char buf[sizeof("zzerr")+10];\r
+                       static char bufErrSet[sizeof("zzerr")+10];\r
+                       int n = DefErrSet( &b, 0, NULL );\r
+                       int nErrSet = DefErrSetWithSuffix(0, &bErrSet, 1, NULL, "_set");\r
+                       if ( GenCC ) sprintf(buf, "err%d", n);\r
+                       else sprintf(buf, "zzerr%d", n);\r
+                       if ( GenCC ) sprintf(bufErrSet, "err%d", nErrSet);\r
+                       else sprintf(bufErrSet, "zzerr%d", nErrSet);\r
+                       set_name = buf;\r
+                       set_nameErrSet = bufErrSet;\r
+               }\r
+\r
+               if ( !FoundException ) {\r
+/* MR23 */             gen2("zzsetmatch(%s, %s);", set_name, set_nameErrSet);\r
+               }\r
+               else if ( p->ex_group==NULL ) {\r
+            if ( p->use_def_MT_handler )\r
+                gen3("zzsetmatch_wdfltsig(%s,(ANTLRTokenType)%d,%s);",\r
+                     set_name,\r
+                     p->token,\r
+                     tokenFollowSet(p))\r
+            else\r
+                gen2("zzsetmatch_wsig(%s, %s_handler);",\r
+                     set_name,\r
+                     handler_id);\r
+               }\r
+               else\r
+               {\r
+                       gen1("if ( !_setmatch_wsig(%s) ) {\n", set_name);\r
+                       tabs++;\r
+/* MR6 */      if (FoundGuessBlk) {\r
+/* MR6 */        if ( GenCC ) {gen("if ( guessing ) goto fail;\n");}\r
+/* MR6 */        else gen("if ( zzguessing ) goto fail;\n");\r
+/* MR6 */      };\r
+                       gen("_signal=MismatchedToken;\n");\r
+                       dumpException(p->ex_group, 0);\r
+                       tabs--;\r
+                       gen("}\n");\r
+               }\r
+               set_free(b);\r
+               set_free(bErrSet);\r
+       }\r
+       else if ( TokenString(p->token)!=NULL )\r
+       {\r
+               if ( FoundException ) {\r
+                       if ( p->use_def_MT_handler )\r
+                               gen2("zzmatch_wdfltsig(%s,%s);",TokenString(p->token),tokenFollowSet(p))\r
+                       else if ( p->ex_group==NULL )\r
+                       {\r
+                               gen2("zzmatch_wsig(%s, %s_handler);",\r
+                                        TokenString(p->token),\r
+                                        handler_id);\r
+                       }\r
+                       else\r
+                       {\r
+/* MR6 */              if (GenCC) {\r
+/* MR6 */                gen1("if ( !_match_wsig(%s) ) {\n", TokenString(p->token));\r
+/* MR6 */              } else {\r
+/* MR6 */                gen1("if ( !_zzmatch_wsig(%s) ) {\n", TokenString(p->token));\r
+/* MR6 */              };\r
+                               tabs++;\r
+/* MR6 */              if (FoundGuessBlk) {\r
+/* MR6 */                if ( GenCC ) {gen("if ( guessing ) goto fail;\n");}\r
+/* MR6 */                else gen("if ( zzguessing ) goto fail;\n");\r
+/* MR6 */              };\r
+                               gen("_signal=MismatchedToken;\n");\r
+                               dumpException(p->ex_group, 0);\r
+                               tabs--;\r
+                               gen("}\n");\r
+                       }\r
+               }\r
+               else gen1("zzmatch(%s);", TokenString(p->token));\r
+       }\r
+       else {\r
+        if ( FoundException ) {\r
+            if ( p->use_def_MT_handler )\r
+                               gen2("zzmatch_wdfltsig((ANTLRTokenType)%d,%s);",\r
+                                        p->token,tokenFollowSet(p))\r
+            else\r
+                gen2("zzmatch_wsig(%d,%s_handler);",p->token,handler_id);\r
+        }\r
+               else {gen1("zzmatch(%d);", p->token);}\r
+       }\r
+\r
+       a = findImmedAction( p->next );\r
+       /* generate the token labels */\r
+       if ( GenCC && p->elnum>0 )\r
+       {\r
+               /* If building trees in C++, always gen the LT() assigns */\r
+               if ( set_el(p->elnum, tokensRefdInBlock) || GenAST )\r
+               {\r
+/* MR10 */     if ( FoundGuessBlk ) {\r
+/* MR10 */    gen("\n");\r
+/* MR10 */    if (p->label_used_in_semantic_pred) {\r
+/* MR10 */             gen2(" _t%d%d = (ANTLRTokenPtr)LT(1);  /* MR10 */\n", BlkLevel-1, p->elnum);\r
+/* MR10 */    } else {\r
+/* MR10 */             gen("if ( !guessing ) {\n"); tab();\r
+/* MR10 */             _gen2(" _t%d%d = (ANTLRTokenPtr)LT(1);\n", BlkLevel-1, p->elnum);\r
+/* MR10 */      gen("}\n");\r
+/* MR10 */    };\r
+/* MR10 */  } else {\r
+/* MR10 */       _gen2(" _t%d%d = (ANTLRTokenPtr)LT(1);", BlkLevel-1, p->elnum);\r
+/* MR10 */  };\r
+/* MR10 */\r
+               }\r
+\r
+/*\r
+ *  MR23 labase is never used in the C++ runtime library.\r
+ *       and this code is generated only in C++ mode\r
+ */\r
+\r
+/***           if ( LL_k>1 )                                    / * MR23 disabled */\r
+/***                   if ( !DemandLookahead ) _gen(" labase++;");  / * MR23 disabled */\r
+/***           _gen("\n");                                      / * MR23 disabled */\r
+/***           tab();                                           / * MR23 disabled */\r
+       }\r
+       if ( GenAST )\r
+       {\r
+               if ( FoundGuessBlk &&\r
+                               (ast_label_in_action || !(p->astnode == ASTexclude || r->noAST)) )\r
+               {\r
+                       if ( GenCC ) {_gen("if ( !guessing ) {\n"); tab();}\r
+                       else {_gen("zzNON_GUESS_MODE {\n"); tab();}\r
+               }\r
+\r
+/* MR27 addition when labels referenced when operator ! used */\r
+\r
+               pushedCmodeAST = 0; /* MR27 */\r
+               if (ast_label_in_action && (p->astnode == ASTexclude || r->noAST)) {\r
+                       _gen("\n");\r
+                       if (GenCC) {\r
+/* MR13 */      if (NewAST) {\r
+/* MR13 */         gen4("_ast%d%d = newAST(_t%d%d); /* MR27 */\n", BlkLevel-1, p->elnum, BlkLevel-1, p->elnum);\r
+/* MR13 */      } else {\r
+/* MR13 */         gen4("_ast%d%d = new AST(_t%d%d); /* MR27 */\n", BlkLevel-1, p->elnum, BlkLevel-1, p->elnum);\r
+/* MR13 */      }\r
+                       }\r
+                       else {\r
+                               pushedCmodeAST = 1;\r
+                               gen("zzastPush(zzmk_ast(zzastnew(),zzaCur)); /* MR27 */");\r
+                       }\r
+               }\r
+\r
+/* end MR27 addition for labels referenced when operator ! used */\r
+\r
+               if (!r->noAST )\r
+               {\r
+                       if (GenCC && !(p->astnode == ASTexclude) ) {\r
+                               _gen("\n");\r
+/* MR13 */      if (NewAST) {\r
+/* MR13 */         gen4("_ast%d%d = newAST(_t%d%d);\n", BlkLevel-1, p->elnum, BlkLevel-1, p->elnum);\r
+/* MR13 */      } else {\r
+/* MR13 */         gen4("_ast%d%d = new AST(_t%d%d);\n", BlkLevel-1, p->elnum, BlkLevel-1, p->elnum);\r
+/* MR13 */      }\r
+                               tab();\r
+                       }\r
+                       if ( GenCC && !(p->astnode == ASTexclude) )\r
+                               {_gen2("_ast%d%d->", BlkLevel-1, p->elnum);}\r
+                       else _gen(" ");\r
+                       if ( p->astnode==ASTchild ) {\r
+                               if ( !GenCC ) _gen("zz");\r
+                               _gen("subchild(_root, &_sibling, &_tail);");\r
+                       }\r
+                       else if ( p->astnode==ASTroot ) {\r
+                               if ( !GenCC ) _gen("zz");\r
+                               _gen("subroot(_root, &_sibling, &_tail);");\r
+                       }\r
+                       if ( GenCC && !(p->astnode == ASTexclude) ) {\r
+                               _gen("\n");\r
+                               tab();\r
+                       }\r
+               }\r
+               else if ( !GenCC ) {\r
+                       if (! pushedCmodeAST) _gen(" zzastDPush;");\r
+               }\r
+               if ( FoundGuessBlk &&\r
+                               (ast_label_in_action || !(p->astnode == ASTexclude || r->noAST)) )\r
+                       {gen("}\n"); tab();}\r
+       }\r
+\r
+       /* Handle element labels now */\r
+       if ( p->el_label!=NULL )\r
+       {\r
+        int     done_NON_GUESSMODE=0;\r
+\r
+               _gen("\n");\r
+\r
+/* MR10 */    /* do Attrib / Token ptr for token label used in semantic pred */\r
+/* MR10 */    /* for these cases do assign even in guess mode                */\r
+/* MR10 */\r
+/* MR10 */    if (p->label_used_in_semantic_pred) {\r
+/* MR10 */      if ( GenCC ) {\r
+/* MR10 */        if ( set_el(p->elnum, tokensRefdInBlock) || GenAST ) {\r
+/* MR10 */          gen3("%s = _t%d%d;", p->el_label, BlkLevel-1, p->elnum);\r
+/* MR10 */        } else {\r
+/* MR10 */          gen1("%s = (ANTLRTokenPtr)LT(1);\n", p->el_label);\r
+/* MR10 */        };\r
+/* MR10 */      } else {\r
+/* MR10 */               gen1("%s = zzaCur;", p->el_label);\r
+/* MR10 */      };\r
+/* MR10 */      if (FoundGuessBlk) _gen("  /* MR10 */");\r
+/* MR10 */      _gen("\n");\r
+/* MR10 */    };\r
+\r
+               /* Do Attrib / Token ptr */\r
+\r
+/* MR10 */  if (! p->label_used_in_semantic_pred) {\r
+/* MR10 */\r
+/* MR10 */      if ( FoundGuessBlk ) {\r
+/* MR10 */        if (! done_NON_GUESSMODE) {\r
+/* MR10 */          done_NON_GUESSMODE=1;\r
+/* MR10 */          if ( GenCC ) {gen("if ( !guessing ) {\n"); tab();}\r
+/* MR10 */          else {gen("zzNON_GUESS_MODE {\n"); tab();}\r
+/* MR10 */        };\r
+/* MR10 */      };\r
+/* MR10 */\r
+/* MR10 */      if ( GenCC ) {\r
+/* MR10 */        if ( set_el(p->elnum, tokensRefdInBlock) || GenAST ) {\r
+/* MR10 */          gen3("%s = _t%d%d;\n", p->el_label, BlkLevel-1, p->elnum);\r
+/* MR10 */        } else {\r
+/* MR10 */          gen1("%s = (ANTLRTokenPtr)LT(1);\n", p->el_label);\r
+/* MR10 */        };\r
+/* MR10 */      } else {\r
+/* MR10 */        gen1("%s = zzaCur;\n", p->el_label);\r
+/* MR10 */      };\r
+/* MR10 */  };\r
+\r
+               /* Do AST ptr */\r
+\r
+               if (GenAST && (ast_label_in_action || !(p->astnode == ASTexclude || r->noAST) )) /* MR27 */\r
+               {\r
+\r
+/* MR10 */      if ( FoundGuessBlk ) {\r
+/* MR10 */        if (! done_NON_GUESSMODE) {\r
+/* MR10 */          done_NON_GUESSMODE=1;\r
+/* MR10 */          if ( GenCC ) {gen("if ( !guessing ) {\n"); tab();}\r
+/* MR10 */          else {gen("zzNON_GUESS_MODE {\n"); tab();}\r
+/* MR10 */        };\r
+/* MR10 */      };\r
+\r
+                       if ( GenCC ) {\r
+                               gen3("%s_ast = _ast%d%d;\n", p->el_label, BlkLevel-1, p->elnum);\r
+                       }\r
+                       else {gen1("%s_ast = zzastCur;\n", p->el_label);}\r
+               }\r
+\r
+/* MR10 */  if (done_NON_GUESSMODE) {\r
+/* MR10 */    gen("}\n"); tab();\r
+/* MR10 */  };\r
+\r
+       }\r
+\r
+       /* Handle any actions immediately following action */\r
+       if ( a != NULL )  /* MR10 */ /* MR11 */\r
+    {\r
+       /* delay next token fetch until after action */\r
+               _gen("\n");\r
+               if ( a->is_predicate)\r
+               {\r
+#if 0\r
+/* Disabled in MR30 ************************************************************\r
+   And moved into genAction\r
+   *****************************************************************************\r
+*/\r
\r
+           gen("if (!(");\r
+\r
+                       /* make sure that '#line n' is on front of line */  /* MR14 */\r
+                       if ( GenLineInfo && p->file != -1 ) _gen("\n");     /* MR14 */\r
+                       dumpPredAction(a,a->action, output, 0, a->file, a->line, 0);\r
+\r
+/* MR23 Change failed predicate macro to have three arguments:\r
+\r
+        macro arg 1: The stringized predicate itself\r
+        macro arg 2: 0 => no user-defined error action\r
+                     1 => user-defined error action\r
+        macro arg 3: The user-defined error action\r
+\r
+   This gives the user more control of the error action.\r
+*/\r
+                       _gen(")) \n");\r
+                       tabs++;\r
+                       gen3(" {zzfailed_pred(\"%s\",%s,{ %s } );}\n",           /* MR23 */\r
+                                       stringize(a->action),                            /* MR23 */\r
+                    (a->pred_fail == NULL ?                          /* MR23/MR27 */\r
+                               "0 /* report */" : "1 /* user action */"),   /* MR23/MR27 */\r
+                    (a->pred_fail == NULL ?                          /* MR23 */\r
+                        "0; /* no user action */" : a->pred_fail));  /* MR23 */\r
+                       tabs--;\r
+/* Disabled in MR30 ************************************************************\r
+   And moved into genAction\r
+   *****************************************************************************\r
+*/\r
+#endif\r
+               }\r
+               else    /* MR9 a regular action - not a predicate action */\r
+               {\r
+\r
+/* MR23: Search an action which is not a predicate for LT(i),\r
+         LA(i), or LATEXT(i) in order to warn novice users that\r
+         it refers to the previous matched token, not the next\r
+         one.  This is different than the case for semantic\r
+         predicates.\r
+*/\r
+                                 \r
+/* MR23 */    if (GenCC) {\r
+/* MR23 */         if (strstr(a->action, "LT(") != NULL) LTinTokenAction = 1;\r
+/* MR23 */    }\r
+/* MR23 */    else {\r
+/* MR23 */      if (strstr(a->action, "LA(") != NULL) LTinTokenAction = 1;            \r
+/* MR23 */      if (strstr(a->action, "LATEXT(") != NULL) LTinTokenAction = 1;\r
+/* MR23 */    }\r
+\r
+                       if ( FoundGuessBlk ) {\r
+                               if ( GenCC ) {gen("if ( !guessing ) {\n");}\r
+                               else gen("zzNON_GUESS_MODE {\n");\r
+                       }\r
+                       dumpActionPlus(a, a->action, output, tabs, a->file, a->line, 1); /* MR21 */\r
+                       if ( FoundGuessBlk ) gen("}\n");\r
+                       a->done = 1; /* MR30 */\r
+               }\r
+/***    a->done = 1;  MR30 Moved up into then branch for true actions, but not predicates ***/\r
+               if ( !DemandLookahead ) {\r
+                       if ( GenCC ) {\r
+                               if ( FoundException && p->use_def_MT_handler ) gen("if (!_signal)");\r
+                               _gen(" consume();")\r
+                if ( FoundException && p->use_def_MT_handler )\r
+                    _gen(" _signal=NoSignal;");\r
+                _gen("\n");\r
+                       }\r
+            else\r
+            {\r
+                if ( FoundException && p->use_def_MT_handler ) _gen("if (!_signal)");\r
+                                       _gen(" zzCONSUME;\n");\r
+                if ( FoundException && p->use_def_MT_handler ) _gen(" _signal=NoSignal;");\r
+                _gen("\n");\r
+            }\r
+               }\r
+               else gen("\n");\r
+               if (a->done) {                  /* MR30 */\r
+                       TRANS( a->next );   /* MR30 */\r
+               }                                               /* MR30 */\r
+               else {                                  /* MR30 */\r
+                       TRANS( p->next );       /* MR30 */\r
+               }                                               /* MR30 */\r
+       }\r
+       else\r
+       {\r
+        if ( !DemandLookahead ) {\r
+                       if ( GenCC ) {\r
+                               if (FoundException && p->use_def_MT_handler) _gen("if (!_signal)");\r
+                               _gen(" consume();")\r
+                               if (FoundException&&p->use_def_MT_handler) _gen(" _signal=NoSignal;");\r
+                               _gen("\n");\r
+                       }\r
+                       else {\r
+                               if (FoundException && p->use_def_MT_handler) _gen("if (!_signal)");\r
+                               _gen(" zzCONSUME;");\r
+                               if ( FoundException && p->use_def_MT_handler ) _gen(" _signal=NoSignal;");\r
+                               _gen("\n");\r
+                       }\r
+               }\r
+               else _gen("\n");\r
+               TRANS(p->next);\r
+       }\r
+}\r
+\r
+/*  MR21\r
+ *\r
+ *  There was a bug in the code generation for {...} which causes it\r
+ *  to omit the optional tokens from the error messages.  The easiest\r
+ *  way to fix this was to make the opt block look like a sub block:\r
+ *\r
+ *          { a | b | c }\r
+ *\r
+ *  becomes (internally):\r
+ *\r
+ *          ( a | b | c | )\r
+ *\r
+ *  The code for genOptBlk is now identical to genSubBlk except for\r
+ *  cosmetic changes.\r
+ */\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+genOptBlk( Junction *q )\r
+#else\r
+genOptBlk( q )\r
+Junction *q;\r
+#endif\r
+{\r
+       int max_k;\r
+       set f;\r
+       int need_right_curly;\r
+       set savetkref;\r
+       int lastAltEmpty;                       /* MR23 */\r
+       savetkref = tokensRefdInBlock;\r
+       require(q->ntype == nJunction,  "genOptBlk: not junction");\r
+       require(q->jtype == aOptBlk,    "genOptBlk: not opt block");\r
+\r
+    OutLineInfo(output,q->line,FileStr[q->file]);\r
+       BLOCK_Preamble(q);\r
+       BlkLevel++;\r
+    BlockPreambleOption(q,q->pFirstSetSymbol); /* MR21 */\r
+       f = genBlk(q, aOptBlk, &max_k, &need_right_curly, &lastAltEmpty /* MR23 */);\r
+/* MR23\r
+   Bypass error clause generation when exceptions are used in {...} block \r
+   See multi-line note in genBlk near call to isEmptyAlt.\r
+*/\r
+       if (! FoundException) {\r
+           if ( q->p2 != NULL ) {tab(); makeErrorClause(q,f,max_k,0 /* use plus block bypass ? */ );}\r
+       }\r
+       else {\r
+               gen("/* MR23 skip error clause for {...} when exceptions in use */\n");\r
+       }\r
+       { int i; for (i=1; i<=need_right_curly; i++) {tabs--; gen("}\n");} }\r
+       freeBlkFsets(q);\r
+       --BlkLevel;\r
+       BLOCK_Tail();\r
+\r
+       if ( q->guess )\r
+       {\r
+               gen("zzGUESS_DONE\n");\r
+       }\r
+\r
+       /* must duplicate if (alpha)?; one guesses (validates), the\r
+        * second pass matches */\r
+       if ( q->guess && analysis_point(q)==q )\r
+       {\r
+        OutLineInfo(output,q->line,FileStr[q->file]);\r
+               BLOCK_Preamble(q);\r
+               BlkLevel++;\r
+               f = genBlk(q, aSubBlk, &max_k, &need_right_curly, &lastAltEmpty /* MR23 */);\r
+               if ( q->p2 != NULL ) {tab(); makeErrorClause(q,f,max_k,0 /* use plus block bypass ? */ );}\r
+               { int i; for (i=1; i<=need_right_curly; i++) {tabs--; gen("}\n");} }\r
+               freeBlkFsets(q);\r
+               --BlkLevel;\r
+               BLOCK_Tail();\r
+       }\r
+\r
+       tokensRefdInBlock = savetkref;\r
+       if (q->end->p1 != NULL) TRANS(q->end->p1);\r
+}\r
+\r
+/*\r
+ * Generate code for a loop blk of form:\r
+ *\r
+ *                              |---|\r
+ *                              v   |\r
+ *                        --o-G-o-->o--\r
+ */\r
+void\r
+#ifdef __USE_PROTOS\r
+genLoopBlk( Junction *begin, Junction *q, Junction *start, int max_k )\r
+#else\r
+genLoopBlk( begin, q, start, max_k )\r
+Junction *begin;\r
+Junction *q;\r
+Junction *start;       /* where to start generating code from */\r
+int max_k;\r
+#endif\r
+{\r
+       set         f;\r
+       int         need_right_curly;\r
+       set         savetkref;\r
+    Junction    *guessBlock;    /* MR10 */\r
+    int         singleAlt;      /* MR10 */\r
+       int                     lastAltEmpty;   /* MR23 */\r
+\r
+       savetkref = tokensRefdInBlock;\r
+       require(q->ntype == nJunction,  "genLoopBlk: not junction");\r
+       require(q->jtype == aLoopBlk,   "genLoopBlk: not loop block");\r
+\r
+       if ( q->visited ) return;\r
+       q->visited = TRUE;\r
+\r
+    /* first_item_is_guess_block doesn't care what kind of node it is */\r
+\r
+    guessBlock=first_item_is_guess_block( (Junction *) q->p1);  /* MR10 */\r
+    singleAlt=q->p2==NULL;                                      /* MR10 */\r
+\r
+       if (singleAlt && !guessBlock)       /* MR10 */ /* only one alternative? */\r
+       {\r
+               if ( DemandLookahead ) {\r
+                       if ( !GenCC ) {gen1("LOOK(%d);\n", max_k);}\r
+                       else gen1("look(%d);\n", max_k);\r
+               }\r
+               gen("while ( ");\r
+               if ( begin!=NULL ) genExpr(begin);\r
+               else genExpr(q);\r
+               /* if no predicates have been hoisted for this single alt (..)*\r
+                * do so now\r
+                */\r
+        require(MR_PredRuleRefStack.count == 0,"PredRuleRef stack not empty");\r
+               if ( ParseWithPredicates && begin->predicate==NULL )\r
+               {\r
+                       Predicate *a = MR_find_predicates_and_supp((Node *)q->p1);\r
+            require(MR_PredRuleRefStack.count == 0,"PredRuleRef stack not empty");\r
+\r
+                       if ( a!=NULL )\r
+                       {\r
+                               _gen("&&");\r
+                               a=genPredTreeMain(a, (Node *)q);    /* MR10 */\r
+                       }\r
+/* MR10 */  if (MRhoisting) {\r
+/* MR10 */    predicate_free(a);\r
+/* MR10 */  };\r
+               }\r
+               _gen(" ) {\n");\r
+               tabs++;\r
+               TRANS(q->p1);\r
+               if ( !GenCC ) gen1("zzLOOP(zztasp%d);\n", BlkLevel-1);\r
+               if ( DemandLookahead ) {\r
+                       if ( !GenCC ) {gen1("LOOK(%d);\n", max_k);}\r
+                       else gen1("look(%d);\n", max_k);\r
+               }\r
+               --tabs;\r
+               gen("}\n");\r
+               freeBlkFsets(q);\r
+               q->visited = FALSE;\r
+               tokensRefdInBlock = savetkref;\r
+               return;\r
+       }\r
+       gen("for (;;) {\n");        /* MR20 G. Hobbelt */\r
+       tabs++;\r
+/* MR6                                                                                 */\r
+/* MR6            "begin" can never be null when called from genLoopBegin      */\r
+/* MR6     because q==(Junction *)begin->p1 and we know q is valid     */\r
+/* MR6                                                                                         */\r
+/* MR6    from genLoopBegin:                                                           */\r
+/* MR6                                                                                             */\r
+/* MR6          if ( LL_k>1 && !set_nil(q->fset[2]) )                          */\r
+/* MR6            genLoopBlk( q, (Junction *)q->p1, q, max_k );            */\r
+/* MR6         else genLoopBlk( q, (Junction *)q->p1, NULL, max_k );   */\r
+/* MR6                                                                                         */\r
+       if ( begin!=NULL )\r
+       {\r
+               if ( DemandLookahead )\r
+               {\r
+                       if ( !GenCC ) {gen1("LOOK(%d);\n", max_k);}\r
+                       else gen1("look(%d);\n", max_k);\r
+               }\r
+               /* The bypass arc of the (...)* predicts what to do when you fail, but\r
+                * ONLY after having tested the loop start expression.  To avoid this,\r
+                * we simply break out of the (...)* loop when we find something that\r
+                * is not in the prediction of the loop (all alts thereof).\r
+                */\r
+               gen("if ( !(");\r
+\r
+/***   TJP says: It used to use the prediction expression for the bypass arc\r
+       of the (...)*.  HOWEVER, if a non LL^1(k) decision was found, this\r
+       thing would miss the ftree stored in the aLoopBegin node and generate\r
+       an LL^1(k) decision anyway.\r
+\r
+ ***           genExpr((Junction *)begin->p2);\r
+ ***/\r
+\r
+            genExpr((Junction *)begin);\r
+            _gen(")) break;\n");\r
+\r
+       }\r
+\r
+       /* generate code for terminating loop (this is optional branch) */\r
+\r
+       f = genBlk(q, aLoopBlk, &max_k, &need_right_curly, &lastAltEmpty /* MR23 */);\r
+       set_free(f);\r
+       freeBlkFsets(q);\r
+\r
+       /* generate code for terminating loop (this is optional branch) */\r
+\r
+/* MR6                                                                                                     */\r
+/* MR6  30-May-97 Bug reported by Manuel Ornato                                            */\r
+/* MR6            A definite bug involving the exit from a loop block   */\r
+/* MR6                   In 1.23 and later versions (including 1.33) Instead       */\r
+/* MR6              exiting the block and reporting a syntax error the  */\r
+/* MR6             code loops forever.                                                 */\r
+/* MR6           Looking at 1.20 which generates proper code it is not */\r
+/* MR6             clear which of two changes should be undone.            */\r
+/* MR6           This is my best guess.                                    */\r
+/* MR6           From earlier MR6 note we know that begin can never be     */\r
+/* MR6             null when genLoopBlk called from genLoopBegin           */\r
+/* MR6 */\r
+/* MR6 */ if ( begin==NULL) {\r
+/* MR6 */   /* code for exiting loop "for sure" */\r
+/* MR6 */   gen("/* Suppressed by MR6 */ /*** else break; ***/\n");\r
+/* MR6 */ };\r
+\r
+/* MR10 */if (singleAlt && guessBlock) {\r
+/* MR10 */  tabs--;\r
+/* MR6 */   gen("} else break; /* MR6 code for exiting loop \"for sure\" */\n");\r
+/* MR10 */  need_right_curly--;\r
+/* MR10 */ } else {\r
+/* MR6 */   gen("else break; /* MR6 code for exiting loop \"for sure\" */\n");\r
+/* MR10 */ };\r
+\r
+       { int i; for (i=1; i<=need_right_curly; i++) {tabs--; gen("}\n");} }\r
+       if ( !GenCC ) gen1("zzLOOP(zztasp%d);\n", BlkLevel-1);\r
+       --tabs;\r
+       gen("}\n");\r
+       q->visited = FALSE;\r
+       tokensRefdInBlock = savetkref;\r
+}\r
+\r
+/*\r
+ * Generate code for a loop blk of form:\r
+ *\r
+ *                                      |---|\r
+ *                                          v   |\r
+ *                        --o-->o-->o-G-o-->o--\r
+ *                   |           ^\r
+ *                   v           |\r
+ *                                      o-----------o\r
+ *\r
+ * q->end points to the last node (far right) in the blk.\r
+ *\r
+ * Note that q->end->jtype must be 'EndBlk'.\r
+ *\r
+ * Generate code roughly of the following form:\r
+ *\r
+ *     do {\r
+ *             ... code for alternatives ...\r
+ *  } while ( First Set of aLoopBlk );\r
+ *\r
+ *     OR if > 1 alternative\r
+ *\r
+ *     do {\r
+ *             ... code for alternatives ...\r
+ *             else break;\r
+ *  } while ( 1 );\r
+ */\r
+void\r
+#ifdef __USE_PROTOS\r
+genLoopBegin( Junction *q )\r
+#else\r
+genLoopBegin( q )\r
+Junction *q;\r
+#endif\r
+{\r
+       set f;\r
+       int i;\r
+       int max_k;\r
+       set savetkref;\r
+       savetkref = tokensRefdInBlock;\r
+       require(q!=NULL,                                "genLoopBegin: invalid node and/or rule");\r
+       require(q->ntype == nJunction,  "genLoopBegin: not junction");\r
+       require(q->jtype == aLoopBegin, "genLoopBegin: not loop block");\r
+       require(q->p2!=NULL,                    "genLoopBegin: invalid Loop Graph");\r
+\r
+    OutLineInfo(output,q->line,FileStr[q->file]);\r
+\r
+       BLOCK_Preamble(q);\r
+       BlkLevel++;\r
+    BlockPreambleOption(q,q->pFirstSetSymbol);       /* MR21 */\r
+       f = First(q, 1, aLoopBegin, &max_k);\r
+       /* If not simple LL(1), must specify to start at LoopBegin, not LoopBlk */\r
+       if ( LL_k>1 && !set_nil(q->fset[2]) )\r
+               genLoopBlk( q, (Junction *)q->p1, q, max_k );\r
+       else genLoopBlk( q, (Junction *)q->p1, NULL, max_k );\r
+\r
+       for (i=1; i<=CLL_k; i++) set_free(q->fset[i]);\r
+       for (i=1; i<=CLL_k; i++) set_free(((Junction *)q->p2)->fset[i]);\r
+       --BlkLevel;\r
+       BLOCK_Tail();\r
+       set_free(f);\r
+       tokensRefdInBlock = savetkref;\r
+/* MR21 */     if (MR_BlkErr) {\r
+/* MR21 */             set f, fArray[2];\r
+/* MR21 */             f = ComputeErrorSet(q,1,0 /* use plus block bypass ? */ );\r
+/* MR21 */      fArray[0]= empty;\r
+/* MR21 */             fArray[1]= set_dup(f);\r
+/* MR21 */      gen("if (");\r
+/* MR21 */      genExprSets(fArray,1);  /* note: destroys set arguments */\r
+/* MR21 */      _gen(") { /* MR21 option -mrblksynerr */\n");\r
+/* MR21 */      tabs++;\r
+/* MR21 */      tab();\r
+/* MR21 */      _gen("/* nothing */ }\n");\r
+/* MR21 */      tab();\r
+/* MR21 */      makeErrorClause(q,f,1,0 /* use plus block bypass ? */ );  /* frees set */\r
+/* MR21 */      tabs--;\r
+/* MR21 */     };\r
+       if (q->end->p1 != NULL) TRANS(q->end->p1);\r
+}\r
+\r
+/*\r
+ * Generate code for a loop blk of form:\r
+ *\r
+ *                                      |---|\r
+ *                                      v   |\r
+ *                            --o-G-o-->o--\r
+ *\r
+ * q->end points to the last node (far right) in the blk.\r
+ * Note that q->end->jtype must be 'EndBlk'.\r
+ *\r
+ * Generate code roughly of the following form:\r
+ *\r
+ *     do {\r
+ *             ... code for alternatives ...\r
+ *  } while ( First Set of aPlusBlk );\r
+ *\r
+ *     OR if > 1 alternative\r
+ *\r
+ *     do {\r
+ *             ... code for alternatives ...\r
+ *             else if not 1st time through, break;\r
+ *  } while ( 1 );\r
+ */\r
+void\r
+#ifdef __USE_PROTOS\r
+genPlusBlk( Junction *q )\r
+#else\r
+genPlusBlk( q )\r
+Junction *q;\r
+#endif\r
+{\r
+       int         max_k;\r
+       set         f;\r
+       int         need_right_curly;\r
+       int                     lastAltEmpty;   /* MR23 */\r
+       set         savetkref;\r
+    Junction    *guessBlock;    /* MR10 */\r
+    int         singleAlt;      /* MR10 */\r
+\r
+       savetkref = tokensRefdInBlock;\r
+       require(q!=NULL,                                "genPlusBlk: invalid node and/or rule");\r
+       require(q->ntype == nJunction,  "genPlusBlk: not junction");\r
+       require(q->jtype == aPlusBlk,   "genPlusBlk: not Plus block");\r
+       require(q->p2 != NULL,                  "genPlusBlk: not a valid Plus block");\r
+\r
+       if ( q->visited ) return;\r
+       q->visited = TRUE;\r
+    OutLineInfo(output,q->line,FileStr[q->file]);\r
+       BLOCK_Preamble(q);\r
+       BlkLevel++;\r
+\r
+    BlockPreambleOption((Junction *)q, q->pFirstSetSymbol);       /* MR21 */\r
+    \r
+    /* first_item_is_guess_block  doesn't care what kind of node it is */\r
+\r
+    guessBlock=first_item_is_guess_block( (Junction *)q->p1);   /* MR10 */\r
+\r
+       /* if the ignore flag is set on the 2nd alt and that alt is empty,\r
+        * then it is the implied optional alternative that we added for (...)+\r
+        * and, hence, only 1 alt.\r
+        */\r
+\r
+/* MR10  Reported by Pulkkinen Esa (esap@cs.tut.fi)\r
+ *       Outer code for guess blocks ignored when there is only one alt\r
+ *         for a (...)+ block.\r
+ *       Force use of regular code rather than "optimized" code for that case\r
+ */\r
+\r
+    singleAlt=( ( (Junction *) q->p2)->p2 == NULL) &&\r
+                 ( ( (Junction *) q->p2)->ignore );                    /* only one alternative? */\r
+\r
+    if (singleAlt && !guessBlock)   /* MR10 */\r
+       {\r
+\r
+               Predicate *a=NULL;\r
+               /* if the only alt has a semantic predicate, hoist it; must test before\r
+                * entering loop.\r
+                */\r
+               if ( ParseWithPredicates )\r
+               {\r
+            require(MR_PredRuleRefStack.count == 0,"PredRuleRef stack not empty");\r
+                       a = MR_find_predicates_and_supp((Node *)q);\r
+            require(MR_PredRuleRefStack.count == 0,"PredRuleRef stack not empty");\r
+\r
+                       if ( a!=NULL ) {\r
+                               gen("if (");\r
+                               a=genPredTreeMain(a, (Node *)q);    /* MR10 */\r
+                               _gen(") {\n");\r
+                       }\r
+               }\r
+               gen("do {\n");\r
+               tabs++;\r
+               TRANS(q->p1);\r
+               if ( !GenCC ) gen1("zzLOOP(zztasp%d);\n", BlkLevel-1);\r
+               f = First(q, 1, aPlusBlk, &max_k);\r
+               if ( DemandLookahead ) {\r
+                       if ( !GenCC ) {gen1("LOOK(%d);\n", max_k);}\r
+                       else gen1("look(%d);\n", max_k);\r
+               }\r
+               --tabs;\r
+               gen("} while ( ");\r
+               if ( q->parm!=NULL && q->predparm ) _gen1("(%s) && ", q->parm);\r
+               genExpr(q);\r
+               if ( ParseWithPredicates && a!=NULL )\r
+               {\r
+            if (! MR_comparePredicates(q->predicate,a)) {\r
+                       _gen("&&");\r
+                       a=genPredTreeMain(a, (Node *)q);    /* MR10 */\r
+            };\r
+               }\r
+               _gen(" );\n");\r
+               if ( ParseWithPredicates && a!=NULL ) gen("}\n");\r
+               --BlkLevel;\r
+               BLOCK_Tail();\r
+               q->visited = FALSE;\r
+               freeBlkFsets(q);\r
+               set_free(f);\r
+               tokensRefdInBlock = savetkref;\r
+/* MR21 */     if (MR_BlkErr) {\r
+/* MR21 */             set f, fArray[2];\r
+/* MR21 */             f = ComputeErrorSet(q,1,1 /* use plus block bypass ? */ );\r
+/* MR21 */      fArray[0]= empty;\r
+/* MR21 */             fArray[1]= set_dup(f);\r
+/* MR21 */      gen("if (");\r
+/* MR21 */      genExprSets(fArray,1);  /* note: destroys set arguments */\r
+/* MR21 */      _gen(") { /* MR21 option -mrblksynerr */\n");\r
+/* MR21 */      tabs++;\r
+/* MR21 */      tab();\r
+/* MR21 */      _gen("/* nothing */ }\n");\r
+/* MR21 */      tab();\r
+/* MR21 */      makeErrorClause(q,f,1,1 /* use plus block bypass ? */ );  /* frees set */\r
+/* MR21 */      tabs--;\r
+/* MR21 */     };\r
+               if (q->end->p1 != NULL) TRANS(q->end->p1);\r
+/* MR10 */  if (MRhoisting) {\r
+/* MR10 */    predicate_free(a);\r
+/* MR10 */  };\r
+               return;\r
+       }\r
+       gen("do {\n");\r
+       tabs++;\r
+       f = genBlk(q, aPlusBlk, &max_k, &need_right_curly, &lastAltEmpty /* MR23 */);\r
+/* MR6                                                                                         */\r
+/* MR6 Sinan Karasu    (sinan@tardis.ds.boeing.com)                    */\r
+/* MR6    Failed to turn off guess mode when leaving block             */\r
+/* MR6                                                                                         */\r
+/* MR6  */ if ( has_guess_block_as_last_item(q) ) {\r
+/* MR10 */   gen("/* MR10 ()+ */ else {\n");\r
+/* MR10 */   tabs++;\r
+/* MR10 */   need_right_curly++;\r
+/* MR10 */   gen("/* MR10 ()+ */ if ( !zzrv ) zzGUESS_DONE;\n");\r
+/* MR6  */   gen("/* MR10 ()+ */ if ( zzcnt > 1 ) break;\n");\r
+/* MR10 */ } else {\r
+/* MR10 */   gen("/* MR10 ()+ */ else {\n");\r
+/* MR10 */   tabs++;\r
+/* MR10 */   need_right_curly++;\r
+/* MR10 */   gen("if ( zzcnt > 1 ) break;\n");\r
+/* MR10 */ };\r
+\r
+/* MR21 */     if (MR_BlkErr && 1 >= max_k) {\r
+/* MR21 */             set f;\r
+/* MR21 */             f = ComputeErrorSet(q,1,0 /* use plus block bypass ? */ );\r
+/* MR21 */      tabs++;\r
+/* MR21 */      tab();\r
+/* MR21 */      makeErrorClause(q,f,1,0 /* use plus block bypass ? */ );  /* frees set */\r
+/* MR21 */      tabs--;\r
+/* MR21 */     }\r
+/* MR21 */  else {\r
+                               tab();\r
+                makeErrorClause(q,f,max_k,1 /* use plus block bypass ? */);\r
+                                                                                   /* MR21 I think this generates the wrong set ? */\r
+                                            /* MR21 because it includes the plus block bypass ? */\r
+                                                                                   /* MR21 but I'm afraid to change it without additional checking */\r
+            }\r
+\r
+       { int i; for (i=1; i<=need_right_curly; i++) {tabs--; gen("}\n");} }\r
+       freeBlkFsets(q);\r
+       gen("zzcnt++;");\r
+       if ( !GenCC ) _gen1(" zzLOOP(zztasp%d);", BlkLevel-1);\r
+       _gen("\n");\r
+       if ( DemandLookahead ) {\r
+               if ( !GenCC ) {gen1("LOOK(%d);\n", max_k);}\r
+               else gen1("look(%d);\n", max_k);\r
+       }\r
+       --tabs;\r
+       if ( q->parm!=NULL && q->predparm ) {gen1("} while (%s);\n", q->parm);}\r
+       else gen("} while ( 1 );\n");\r
+       --BlkLevel;\r
+       BLOCK_Tail();\r
+       q->visited = FALSE;\r
+       tokensRefdInBlock = savetkref;\r
+/* MR21 */     if (MR_BlkErr) {\r
+/* MR21 */             set f, fArray[2];\r
+/* MR21 */             f = ComputeErrorSet(q,1,1 /* use plus block bypass ? */ );\r
+/* MR21 */      fArray[0]= empty;\r
+/* MR21 */             fArray[1]= set_dup(f);\r
+/* MR21 */      gen("if (");\r
+/* MR21 */      genExprSets(fArray,1);  /* note: destroys set arguments */\r
+/* MR21 */      _gen(") { /* MR21 option -mrblksynerr */\n");\r
+/* MR21 */      tabs++;\r
+/* MR21 */      tab();\r
+/* MR21 */      _gen("/* nothing */ }\n");\r
+/* MR21 */      tab();\r
+/* MR21 */      makeErrorClause(q,f,1,1 /* use plus block bypass ? */ );  /* frees set */\r
+/* MR21 */      tabs--;\r
+/* MR21 */     };\r
+       if (q->end->p1 != NULL) TRANS(q->end->p1);\r
+}\r
+\r
+/*\r
+ * Generate code for a sub blk of alternatives of form:\r
+ *\r
+ *                            --o-G1--o--\r
+ *                                      |     ^\r
+ *                                      v    /|\r
+ *                              o-G2-o|\r
+ *                                      |     ^\r
+ *                                      v     |\r
+ *                                ..........\r
+ *                                      |     ^\r
+ *                                      v    /\r
+ *                              o-Gn-o\r
+ *\r
+ * q points to the 1st junction of blk (upper-left).\r
+ * q->end points to the last node (far right) in the blk.\r
+ * Note that q->end->jtype must be 'EndBlk'.\r
+ * The last node in every alt points to q->end.\r
+ *\r
+ * Generate code of the following form:\r
+ *     if ( First(G1) ) {\r
+ *             ...code for G1...\r
+ *     }\r
+ *     else if ( First(G2) ) {\r
+ *             ...code for G2...\r
+ *     }\r
+ *     ...\r
+ *     else {\r
+ *             ...code for Gn...\r
+ *     }\r
+ */\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+genSubBlk( Junction *q )\r
+#else\r
+genSubBlk( q )\r
+Junction *q;\r
+#endif\r
+{\r
+       int max_k;\r
+       set f;\r
+       int need_right_curly;\r
+       int lastAltEmpty;               /* MR23 */\r
+       set savetkref;\r
+       savetkref = tokensRefdInBlock;\r
+       require(q->ntype == nJunction,  "genSubBlk: not junction");\r
+       require(q->jtype == aSubBlk,    "genSubBlk: not subblock");\r
+\r
+    OutLineInfo(output,q->line,FileStr[q->file]);\r
+       BLOCK_Preamble(q);\r
+       BlkLevel++;\r
+    BlockPreambleOption(q,q->pFirstSetSymbol);       /* MR21 */\r
+       f = genBlk(q, aSubBlk, &max_k, &need_right_curly, &lastAltEmpty /* MR23 */);\r
+\r
+/* MR23\r
+   Bypass error clause generation when exceptions are used in a sub block\r
+   in which the last alternative is epsilon.  Example: "(A | B | )". \r
+   See multi-line note in genBlk near call to isEmptyAlt.\r
+*/\r
+       if (FoundException && lastAltEmpty) {\r
+               gen("/* MR23 skip error clause for (...| epsilon) when exceptions in use */\n");\r
+       }\r
+       else {\r
+               if ( q->p2 != NULL ) {tab(); makeErrorClause(q,f,max_k,0 /* use plus block bypass ? */ );}\r
+       }\r
+    \r
+       { int i; for (i=1; i<=need_right_curly; i++) {tabs--; gen("}\n");} }\r
+       freeBlkFsets(q);\r
+       --BlkLevel;\r
+       BLOCK_Tail();\r
+\r
+       if ( q->guess )\r
+       {\r
+               gen("zzGUESS_DONE\n");\r
+       }\r
+\r
+       /* must duplicate if (alpha)?; one guesses (validates), the\r
+        * second pass matches */\r
+       if ( q->guess && analysis_point(q)==q )\r
+       {\r
+        OutLineInfo(output,q->line,FileStr[q->file]);\r
+               BLOCK_Preamble(q);\r
+               BlkLevel++;\r
+               f = genBlk(q, aSubBlk, &max_k, &need_right_curly, &lastAltEmpty /* MR23 */);\r
+               if ( q->p2 != NULL ) {tab(); makeErrorClause(q,f,max_k,0 /* use plus block bypass ? */);}\r
+               { int i; for (i=1; i<=need_right_curly; i++) {tabs--; gen("}\n");} }\r
+               freeBlkFsets(q);\r
+               --BlkLevel;\r
+               BLOCK_Tail();\r
+       }\r
+\r
+       tokensRefdInBlock = savetkref;\r
+       if (q->end->p1 != NULL) TRANS(q->end->p1);\r
+}\r
+\r
+static int TnodesAllocatedPrevRule=0;\r
+\r
+/*\r
+ * Generate code for a rule.\r
+ *\r
+ *             rule--> o-->o-Alternatives-o-->o\r
+ * Or,\r
+ *             rule--> o-->o-Alternative-o-->o\r
+ *\r
+ * The 1st junction is a RuleBlk.  The second can be a SubBlk or just a junction\r
+ * (one alternative--no block), the last is EndRule.\r
+ * The second to last is EndBlk if more than one alternative exists in the rule.\r
+ *\r
+ * To get to the init-action for a rule, we must bypass the RuleBlk,\r
+ * and possible SubBlk.\r
+ * Mark any init-action as generated so genBlk() does not regenerate it.\r
+ */\r
+void\r
+#ifdef __USE_PROTOS\r
+genRule( Junction *q )\r
+#else\r
+genRule( q )\r
+Junction *q;\r
+#endif\r
+{\r
+\r
+       const char * returnValueInitializer;\r
+\r
+do {    /* MR10     Change recursion into iteration         */\r
+\r
+       int max_k;\r
+       set follow, rk, f;\r
+       ActionNode *a;\r
+       RuleEntry *r;\r
+       int lastAltEmpty;               /* MR23 */\r
+       static int file = -1;\r
+       int need_right_curly;\r
+       require(q->ntype == nJunction,  "genRule: not junction");\r
+       require(q->jtype == RuleBlk,    "genRule: not rule");\r
+\r
+/* MR14 */    require (MR_BackTraceStack.count == 0,"-alpha MR_BackTraceStack.count != 0");\r
+/* MR14 */    MR_pointerStackReset(&MR_BackTraceStack);\r
+/* MR14 */    if (AlphaBetaTrace) MR_MaintainBackTrace=1;\r
+\r
+    CurRule=q->rname;                               /* MR11 */\r
+\r
+       r = (RuleEntry *) hash_get(Rname, q->rname);\r
+       if ( r == NULL ) warnNoFL("Rule hash table is screwed up beyond belief");\r
+       if ( q->file != file )          /* open new output file if need to */\r
+       {\r
+/* MR6                                                                                 */\r
+/* MR6  Simpler to debug when output goes to stdout rather than a file         */\r
+/* MR6                                                                                 */\r
+/* MR6 */      if (UseStdout) {\r
+/* MR6 */        output = stdout;\r
+/* MR6 */      } else {\r
+/* MR6 */        if ( output != NULL) fclose( output );\r
+/* MR6 */        output = fopen(OutMetaName(outname(FileStr[q->file])), "w");\r
+/* MR6 */      };\r
+               require(output != NULL, "genRule: can't open output file");\r
+\r
+#ifdef SPECIAL_FOPEN\r
+       special_fopen_actions(OutMetaName(outname(FileStr[q->file]))); /* MR1 */\r
+#endif\r
+               if ( file == -1 ) genHdr1(q->file);\r
+               else genHdr(q->file);\r
+               file = q->file;\r
+       }\r
+\r
+    if (InfoM) {\r
+      fprintf(stderr,"    rule %s\n",q->rname);\r
+      fflush(output);\r
+    };\r
+\r
+#if 0\r
+    if (strcmp(q->rname,"***debug***") == 0) {\r
+      fprintf(stderr,"***debug*** %s reached\n",q->rname);\r
+      MR_break();\r
+    };\r
+#endif\r
+\r
+       DumpFuncHeader(q,r);\r
+       tabs++;\r
+\r
+       /* MR23 \r
+          \r
+          If there is a single return value then it can be initialized in \r
+          the declaration using assignment syntax.  If there are multiple\r
+          return values then antlr creates a struct and initialization takes\r
+          place element by element for each element of the struct.  For\r
+       multiple elements the initialization is by assignment so we have\r
+       to wait until all declarations are done before emitting that code -\r
+       because of restrictions in C which don't exist in C++.\r
+\r
+       In the past (before MR23) the only kind of initialization was\r
+          the PURIFY macro which was just a memset() of 0.  Now we allow\r
+          the user to specify an initial value.  PURIFY is still used in C\r
+          mode because C does not have constructors.  However, PURIFY is\r
+          not used in C++ mode because it might overwrite information created\r
+          by elements which have their own ctor.\r
+       \r
+       */\r
+\r
+       if ( q->ret!=NULL )\r
+       {\r
+               if ( hasMultipleOperands(q->ret) )                         /* MR23 */\r
+               {\r
+\r
+            /* Emit initialization code later. */\r
+\r
+                       gen1("struct _rv%d _retv;\n",r->rulenum);\r
+               }\r
+               else\r
+               {\r
+            /* Emit initialization code now. */\r
+\r
+                       tab();\r
+                       DumpType(q->ret, output);\r
+            returnValueInitializer = getInitializer(q->ret);\r
+            if (returnValueInitializer == NULL) {                  /* MR23 */\r
+                       gen(" _retv;\n");                                   /* MR1 MR3 */\r
+            }                                                      /* MR23 */\r
+            else {                                                 /* MR23 */\r
+                gen1(" _retv = %s;\n", returnValueInitializer);    /* MR23 */\r
+            }                                                      /* MR23 */\r
+               }\r
+       }\r
+\r
+    OutLineInfo(output,q->line,FileStr[q->file]);\r
+\r
+    if (InfoM) {\r
+      fflush(output);\r
+    };\r
+\r
+       gen("zzRULE;\n");\r
+       if ( FoundException )\r
+       {\r
+               gen("int _sva=1;\n");\r
+       }\r
+       if ( GenCC && GenAST )\r
+               gen("ASTBase *_ast = NULL, *_sibling = NULL, *_tail = NULL;\n");\r
+       if ( GenCC ) genTokenPointers(q);\r
+       if ( GenCC&&GenAST ) genASTPointers(q);\r
+       if ( q->el_labels!=NULL ) genElementLabels(q->el_labels);\r
+       if ( FoundException ) gen("int _signal=NoSignal;\n");\r
+\r
+       if ( !GenCC ) gen1("zzBLOCK(zztasp%d);\n", BlkLevel);\r
+\r
+/* MR10 */  /* move zzTRACEIN to before init action */\r
+\r
+/* MR10 */     if ( TraceGen ) {\r
+/* MR10 */             if ( GenCC ) {gen1("zzTRACEIN(\"%s\");\n", q->rname);}\r
+/* MR10 */             else gen1("zzTRACEIN((ANTLRChar *)\"%s\");\n", q->rname);\r
+/* MR10 */     }\r
+\r
+/* MR7      Moved PURIFY() to after all local variables have been declared */\r
+/* MR7      so that the generated code is valid C as well as C++           */\r
+/* MR7        Jan Mikkelsen 10-June-1997                                   */\r
+\r
+\r
+     /*\r
+       MR23    Do the PURIFY macro only for C mode.\r
+               C++ users should use constructors or initialization expressions.\r
+     */\r
+\r
+       if ( q->ret != NULL )                                            /* MR7 */\r
+       {                                                                /* MR7 */\r
+               if (hasMultipleOperands(q->ret)) {                           /* MR23 */\r
+                       if (PURIFY == TRUE) {\r
+                gen1("PCCTS_PURIFY(_retv,sizeof(struct _rv%d))\n",r->rulenum); /* MR23 */\r
+            }\r
+        }                                                            /* MR7 */\r
+               else {                                                       /* MR7 */\r
+\r
+                       /* MR23\r
+                          If there were only one return value operand and\r
+                          it had an initializer then it would have been\r
+                          initiailized in the declaration.\r
+                       */\r
+\r
+                       returnValueInitializer = getInitializer(q->ret);         /* MR23 */\r
+                       if (returnValueInitializer == NULL) {                    /* MR23 */\r
+                       if (PURIFY == TRUE) {\r
+                               gen("PCCTS_PURIFY(_retv,sizeof(");               /* MR23 */\r
+                               DumpType(q->ret, output);                        /* MR7 */\r
+                                       gen("))\n");                                     /* MR7 */\r
+                               }\r
+                       }                                                        /* MR23 */\r
+               }                                                            /* MR7 */\r
+\r
+        if (hasMultipleOperands(q->ret)) {                           /* MR23 */\r
+          DumpInitializers(output, r, q->ret);                       /* MR23 */\r
+        }\r
+\r
+       }\r
+       if ( !GenCC ) gen("zzMake0;\n");\r
+       if ( FoundException ) gen("*_retsignal = NoSignal;\n");\r
+\r
+       if ( !GenCC ) gen("{\n");\r
+\r
+       if ( has_guess_block_as_first_item((Junction *)q->p1) )\r
+       {\r
+               gen("zzGUESS_BLOCK\n");\r
+       }\r
+\r
+       /* L o o k  F o r  I n i t  A c t i o n */\r
+       if ( ((Junction *)q->p1)->jtype == aSubBlk )\r
+               a = findImmedAction( ((Junction *)q->p1)->p1 );\r
+       else\r
+               a = findImmedAction( q->p1 );   /* only one alternative in rule */\r
+       if ( a!=NULL && !a->is_predicate)\r
+       {\r
+ /* MR21 */ if (!a->noHoist) dumpActionPlus(a, a->action, output, tabs, a->file, a->line, 1);\r
+                   a->done = 1;        /* ignore action. We have already handled it */\r
+       }\r
+\r
+       BlkLevel++;\r
+       q->visited = TRUE;                              /* mark RULE as visited for FIRST/FOLLOW */\r
+    BlockPreambleOption((Junction *)q->p1, NULL);   /* MR21 */\r
+       f = genBlk((Junction *)q->p1, RuleBlk, &max_k, &need_right_curly, &lastAltEmpty /* MR23 */);\r
+       if ( q->p1 != NULL )\r
+               if ( ((Junction *)q->p1)->p2 != NULL )\r
+                       {tab(); makeErrorClause((Junction *)q->p1,f,max_k,0 /* use plus block bypass ? */);}\r
+       { int i; for (i=1; i<=need_right_curly; i++) {tabs--; gen("}\n");} }\r
+       freeBlkFsets((Junction *)q->p1);\r
+       q->visited = FALSE;\r
+       --BlkLevel;\r
+       if ( !GenCC ) gen1("zzEXIT(zztasp%d);\n", BlkLevel);\r
+\r
+    genTraceOut(q);\r
+\r
+       if ( q->ret!=NULL ) gen("return _retv;\n") else gen("return;\n");\r
+       /* E r r o r  R e c o v e r y */\r
+       NewSet();\r
+       rk = empty;\r
+\r
+/* MR14 */    if (r->dontComputeErrorSet) {\r
+/* MR14 */      follow=empty;\r
+              } else {\r
+                MR_pointerStackReset(&MR_BackTraceStack);   /* MR14 */\r
+                MR_ErrorSetComputationActive=1;\r
+                REACH(q->end, 1, &rk, follow);\r
+                MR_ErrorSetComputationActive=0;\r
+                require (MR_BackTraceStack.count == 0,"K: MR_BackTraceStack.count != 0");\r
+              }\r
+\r
+  FillSet( follow );\r
+       set_free( follow );\r
+\r
+  /* MR20 G. Hobbelt \r
+     Isn't it so that "fail:" is ONLY referenced when:\r
+\r
+        !FoundException || FoundGuessBlk ?\r
+\r
+     Therefore add the "if" around this piece of code generation...\r
+\r
+     Should guessing mode also use _handler label instead of "fail"\r
+     when exception handling is active? gen can automatically put \r
+     "if (guessing)" there so as to skip all kinds of user code.\r
+\r
+   */\r
+\r
+       if ( !FoundException || FoundGuessBlk )  /* MR20 G. Hobbelt */\r
+  {                                          /* MR20 G. Hobbelt */\r
+       _gen("fail:\n");\r
+       if ( !GenCC ) gen("zzEXIT(zztasp1);\n");\r
+       if ( FoundGuessBlk ) {\r
+               if ( !GenCC ) {gen("if ( zzguessing ) zzGUESS_FAIL;\n");}\r
+               else gen("if ( guessing ) zzGUESS_FAIL;\n");\r
+       }\r
+       if ( q->erraction!=NULL )\r
+               dumpAction(q->erraction, output, tabs, q->file, q->line, 1);\r
+       if ( GenCC )\r
+       {\r
+               gen1("syn(zzBadTok, %s, zzMissSet, zzMissTok, zzErrk);\n",\r
+                        r->egroup==NULL?"(ANTLRChar *)\"\"":r->egroup);\r
+       }\r
+       else\r
+       {\r
+               gen1("zzsyn(zzMissText, zzBadTok, %s, zzMissSet, zzMissTok, zzErrk, zzBadText);\n",\r
+                        r->egroup==NULL?"(ANTLRChar *)\"\"":r->egroup);\r
+       }\r
+       gen3("%sresynch(setwd%d, 0x%x);\n", GenCC?"":"zz", wordnum, 1<<setnum);\r
+\r
+       if ( q->ret!=NULL ) {\r
+      genTraceOut(q);\r
+      gen("return _retv;\n");\r
+    } else if ( q->exceptions!=NULL ) {\r
+      genTraceOut(q);\r
+      gen("return;\n");\r
+    } else if (!FoundException) {       /* MR10 */\r
+      genTraceOut(q);                   /* MR10 */\r
+    };\r
+\r
+  }                                        /* MR20 G. Hobbelt */\r
+\r
+       if ( !GenCC ) gen("}\n");\r
+\r
+       /* Gen code for exception handlers */\r
+    /* make sure each path out contains genTraceOut() */\r
+\r
+       if ( q->exceptions!=NULL )\r
+       {\r
+\r
+               gen("/* exception handlers */\n");\r
+\r
+               dumpExceptions(q->exceptions);\r
+\r
+        if ( !r->has_rule_exception )\r
+        {\r
+            _gen("_handler:\n");\r
+            gen("zzdflthandlers(_signal,_retsignal);\n");\r
+        }\r
+/*  MR20 G. Gobbelt   The label "adios" is never referenced */\r
+\r
+#if 0\r
+       _gen("_adios:\n");\r
+#endif\r
+    if ( q->ret!=NULL ) {\r
+            genTraceOut(q);\r
+            gen("return _retv;\n");\r
+        }\r
+               else {\r
+            genTraceOut(q);\r
+            gen("return;\n");\r
+        }\r
+       }\r
+       else if ( FoundException )\r
+       {\r
+      _gen("_handler:\n");\r
+      gen("zzdflthandlers(_signal,_retsignal);\n");\r
+\r
+/* MR1                                                                      */\r
+/* MR1  7-Apr-97 Fix suggested by: John Bair (jbair@iftime.com)            */\r
+/* MR1                                                                                             */\r
+\r
+         if ( q->ret != NULL) {                                                     /* MR1 */\r
+            genTraceOut(q);                                          /* MR10 */\r
+            gen("return _retv;\n");                                             /* MR1 */\r
+      } else {                                                                      /* MR1 */\r
+            genTraceOut(q);                                          /* MR10 */\r
+            gen("return;\n")    ;                                                   /* MR1 */\r
+      };                                                                                    /* MR1 */\r
+       }\r
+\r
+       tabs--;\r
+       gen("}\n");\r
+\r
+/* MR10     Tired of looking at stacks that are as deep as the number of    */\r
+/* MR10       rules.  Changes recursion to iteration.                       */\r
+\r
+    MR_releaseResourcesUsedInRule( (Node *) q );      /* MR10 */\r
+\r
+    if (InfoT) {\r
+      fprintf(output,"\n/* tnodes created for rule %s:  %d */\n",\r
+                q->rname, (TnodesAllocated-TnodesAllocatedPrevRule) );\r
+    };\r
+\r
+    TnodesAllocatedPrevRule=TnodesAllocated;\r
+\r
+    if (q->p2 == NULL) dumpAfterActions( output );\r
+    q=(Junction *)q->p2;\r
+    require(q==NULL || q->jtype==RuleBlk,"RuleBlk p2 does not point to another RuleBlk");\r
+\r
+} while (q != NULL);\r
+\r
+/**** The old code                           ****/\r
+/****  if ( q->p2 != NULL ) {TRANS(q->p2);} ****/ /* generate code for next rule too */\r
+/****  else dumpAfterActions( output );     ****/\r
+\r
+}\r
+\r
+\r
+/* This is for the function definition, not the declaration. */\r
+\r
+static void\r
+#ifdef __USE_PROTOS\r
+DumpFuncHeader( Junction *q, RuleEntry *r )\r
+#else\r
+DumpFuncHeader( q, r )\r
+Junction *q;\r
+RuleEntry *r;\r
+#endif\r
+{\r
+/*                                                                                                         */\r
+/*  MR1 10-Apr-97  MR1  Simplify insertion of commas in function header     */\r
+/*                                                                                                         */\r
+       int     needComma;                                                                       /* MR1 */\r
+\r
+\r
+       /* A N S I */\r
+       _gen("\n");\r
+       if ( q->ret!=NULL )\r
+       {\r
+               if ( hasMultipleOperands(q->ret) )                            /* MR23 */\r
+               {\r
+                       if (GenCC) gen2("%s::_rv%d\n", CurrentClassName, r->rulenum)\r
+                       else gen1("struct _rv%d\n",r->rulenum);\r
+               }\r
+               else\r
+               {\r
+                       DumpType(q->ret, output);\r
+                       gen("\n");\r
+               }\r
+       }\r
+       else\r
+       {\r
+               _gen("void\n");\r
+       }\r
+/*  MR1                                                                                    */\r
+/*  MR1        10-Apr-97  133MR1       Replace __STDC__ with __USE_PROTOS              */\r
+/*  MR1                                                                                                        */\r
+       if ( !GenCC ) _gen("#ifdef __USE_PROTOS\n");                 /* MR1 */\r
+       if ( !GenCC ) gen2("%s%s(", RulePrefix, q->rname)\r
+       else gen3("%s::%s%s(", CurrentClassName, RulePrefix,q->rname);\r
+\r
+       /* If we generate C++ method names, we must hide default arguments */\r
+        /* which can appear in the parameter declaration list.             */\r
+        /* NOTICE: this is done only here, for the method definition, but  */\r
+        /*         not for the method declaration inside the class         */\r
+        /*         definition. This is exactly the behaviour defined in    */\r
+        /*         C++ standard for default paramters.                     */\r
+\r
+       DumpANSIFunctionArgDef(output,q, 0 /* emit initializers ? */);\r
+       _gen("\n");\r
+\r
+       if ( GenCC ) {\r
+      gen("{\n");\r
+      return;\r
+    }\r
+\r
+       /* K & R */\r
+       gen("#else\n");\r
+       gen2("%s%s(", RulePrefix, q->rname);\r
+       needComma=0;                                                                         /* MR1 */\r
+       if ( GenAST )                                                                        /* MR1 */\r
+       {                                                                                            /* MR1 */\r
+               _gen("_root");                                                               /* MR1 */\r
+               needComma=1;                                                                 /* MR1 */\r
+       }                                                                                            /* MR1 */\r
+       if ( FoundException )                                                            /* MR1 */\r
+       {                                                                                            /* MR1 */\r
+               if (needComma) {_gen(",");needComma=0;};                         /* MR1 */\r
+               _gen("_retsignal");                                                          /* MR1 */\r
+               needComma=1;                                                                 /* MR1 */\r
+       }                                                                                            /* MR1 */\r
+/* MR5 Change below by Jan Mikkelsen (janm@zeta.org.au) 26-May-97      MR5 */\r
+       DumpListOfParmNames( q->pdecl, output, needComma );                  /* MR5 */\r
+       gen(")\n");\r
+       if ( GenAST ) gen("AST **_root;\n");\r
+       if ( FoundException ) gen("int *_retsignal;\n");\r
+       DumpOldStyleParms( q->pdecl, output );\r
+       gen("#endif\n");\r
+    gen("{\n");\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+DumpANSIFunctionArgDef(FILE *f, Junction *q, int bInitializer)\r
+#else\r
+DumpANSIFunctionArgDef(f,q,bInitializer)\r
+FILE *f;\r
+Junction *q;\r
+int bInitializer;\r
+#endif\r
+{\r
+       if ( GenAST )\r
+       {\r
+               if ( GenCC ) {fprintf(f,"ASTBase **_root");}\r
+               else fprintf(f,"AST**_root");\r
+               if ( !FoundException && q->pdecl!=NULL ) fprintf(f,",");\r
+       }\r
+       if ( FoundException )\r
+       {\r
+               if ( GenAST ) fprintf(f,",");\r
+               fprintf(f,"int *_retsignal");\r
+               if ( q->pdecl!=NULL ) {\r
+            fprintf(f,",");\r
+        }\r
+       }\r
+       if ( q->pdecl!=NULL ) {\r
+        DumpFormals(f, q->pdecl, bInitializer);     /* MR23 */\r
+    }\r
+       else {\r
+        if ( !GenAST && !FoundException ) {\r
+            fprintf(f,"void");\r
+        }\r
+    }\r
+       fprintf(f,")");\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+genJunction( Junction *q )\r
+#else\r
+genJunction( q )\r
+Junction *q;\r
+#endif\r
+{\r
+       require(q->ntype == nJunction,  "genJunction: not junction");\r
+       require(q->jtype == Generic,    "genJunction: not generic junction");\r
+\r
+       if ( q->p1 != NULL ) TRANS(q->p1);\r
+       if ( q->p2 != NULL ) TRANS(q->p2);\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+genEndBlk( Junction *q )\r
+#else\r
+genEndBlk( q )\r
+Junction *q;\r
+#endif\r
+{\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+genEndRule( Junction *q )\r
+#else\r
+genEndRule( q )\r
+Junction *q;\r
+#endif\r
+{\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+genHdr( int file )\r
+#else\r
+genHdr( file )\r
+int file;\r
+#endif\r
+{\r
+    int     i;\r
+\r
+       _gen("/*\n");\r
+       _gen(" * A n t l r  T r a n s l a t i o n  H e a d e r\n");\r
+       _gen(" *\n");\r
+       _gen(" * Terence Parr, Will Cohen, and Hank Dietz: 1989-2001\n");\r
+       _gen(" * Purdue University Electrical Engineering\n");\r
+       _gen(" * With AHPCRC, University of Minnesota\n");\r
+       _gen1(" * ANTLR Version %s\n", Version);\r
+       _gen(" *\n");\r
+/* MR10 */    _gen(" *  ");\r
+/* MR10 */    for (i=0 ; i < Save_argc ; i++) {\r
+/* MR10 */      _gen(" ");\r
+/* MR10 */      _gen(Save_argv[i]);\r
+/* MR10 */    };\r
+       _gen("\n");\r
+       _gen(" *\n");\r
+    _gen(" */\n\n");\r
+       if (FirstAction != NULL ) dumpAction( FirstAction, output, 0, -1, 0, 1);    /* MR11 MR15b */\r
+       _gen1("#define ANTLR_VERSION    %s\n", VersionDef);\r
+       _gen("#include \"pcctscfg.h\"\n");\r
+       _gen("#include \"pccts_stdio.h\"\n");\r
+       if ( strcmp(ParserName, DefaultParserName)!=0 )\r
+               _gen2("#define %s %s\n", DefaultParserName, ParserName);\r
+       if ( strcmp(ParserName, DefaultParserName)!=0 )\r
+               {_gen1("#include \"%s\"\n", RemapFileName);}\r
+    OutLineInfo(output,1,FileStr[file]);\r
+       if ( GenCC ) {\r
+               if ( UserTokenDefsFile != NULL )\r
+                       fprintf(output, "#include %s\n", UserTokenDefsFile);\r
+               else\r
+                       fprintf(output, "#include \"%s\"\n", DefFileName);\r
+       }\r
+\r
+       if ( HdrAction != NULL ) dumpAction( HdrAction, output, 0, -1, 0, 1);\r
+       if ( !GenCC && FoundGuessBlk )\r
+       {\r
+               _gen("#define ZZCAN_GUESS\n");\r
+               _gen("#include \"pccts_setjmp.h\"\n");  /* MR15 K.J. Cummings (cummings@peritus.com) */\r
+       }\r
+       if ( FoundException )\r
+       {\r
+               _gen("#define EXCEPTION_HANDLING\n");\r
+               _gen1("#define NUM_SIGNALS %d\n", NumSignals);\r
+       }\r
+       if ( !GenCC && OutputLL_k > 1 ) _gen1("#define LL_K %d\n", OutputLL_k);\r
+       if ( GenAST&&!GenCC ) _gen("#define GENAST\n\n");\r
+       if ( GenAST ) {\r
+               if ( GenCC ) {_gen1("#include \"%s\"\n\n", ASTBASE_H);}\r
+               else _gen("#include \"ast.h\"\n\n");\r
+       }\r
+       if ( !GenCC && DemandLookahead ) _gen("#define DEMAND_LOOK\n\n");\r
+#ifdef DUM\r
+       if ( !GenCC && LexGen ) {\r
+               _gen1("#define zzEOF_TOKEN %d\n", (TokenInd!=NULL?TokenInd[EofToken]:EofToken));\r
+       }\r
+#endif\r
+       /* ###WARNING: This will have to change when SetWordSize changes */\r
+       if ( !GenCC ) _gen1("#define zzSET_SIZE %d\n", NumWords(TokenNum-1)*sizeof(unsigned));\r
+    if (TraceGen) {\r
+      _gen("#ifndef zzTRACE_RULES\n");  /* MR20 */\r
+      _gen("#define zzTRACE_RULES\n");  /* MR20 */\r
+      _gen("#endif\n");                 /* MR22 */\r
+    };\r
+       if ( !GenCC ) {_gen("#include \"antlr.h\"\n");}\r
+       else {\r
+               _gen1("#include \"%s\"\n", APARSER_H);\r
+               _gen1("#include \"%s.h\"\n", CurrentClassName);\r
+       }\r
+       if ( !GenCC ) {\r
+               if ( UserDefdTokens )\r
+                       {_gen1("#include %s\n", UserTokenDefsFile);}\r
+               /* still need this one as it has the func prototypes */\r
+               _gen1("#include \"%s\"\n", DefFileName);\r
+       }\r
+       /* still need this one as it defines the DLG interface */\r
+       if ( !GenCC ) _gen("#include \"dlgdef.h\"\n");\r
+       if ( LexGen && GenCC ) _gen1("#include \"%s\"\n", DLEXERBASE_H);\r
+       if ( GenCC ) _gen1("#include \"%s\"\n", ATOKPTR_H);\r
+       if ( !GenCC && LexGen ) _gen1("#include \"%s\"\n", ModeFileName);\r
+\r
+/* MR10  Ofer Ben-Ami (gremlin@cs.huji.ac.il)           */\r
+/* MR10    Finally, a definition of the Purify macro    */\r
+\r
+    if (PURIFY == TRUE) {                                                   /* MR23 */\r
+        _gen("\n/* MR23 In order to remove calls to PURIFY use the antlr"); /* MR23 */\r
+        _gen(" -nopurify option */\n\n");                                   /* MR23 */\r
+       _gen("#ifndef PCCTS_PURIFY\n");\r
+        _gen("#define PCCTS_PURIFY(r,s) memset((char *) &(r),'\\0',(s));\n");\r
+        _gen("#endif\n\n");\r
+    }                                                                       /* MR23 */\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+genHdr1( int file )\r
+#else\r
+genHdr1( file )\r
+int file;\r
+#endif\r
+{\r
+       ListNode *p;\r
+\r
+       genHdr(file);\r
+       if ( GenAST )\r
+       {\r
+               if ( !GenCC ) {\r
+                       _gen("#include \"ast.c\"\n");\r
+                       _gen("zzASTgvars\n\n");\r
+               }\r
+       }\r
+       if ( !GenCC ) _gen("ANTLR_INFO\n");\r
+       if ( BeforeActions != NULL )\r
+       {\r
+               for (p = BeforeActions->next; p!=NULL; p=p->next)\r
+               {\r
+                       UserAction *ua = (UserAction *)p->elem;\r
+                       dumpAction( ua->action, output, 0, ua->file, ua->line, 1);\r
+               }\r
+       }\r
+\r
+       if ( !FoundException ) return;\r
+\r
+       if ( GenCC )\r
+       {\r
+               _gen1("\nvoid %s::\n", CurrentClassName);\r
+               _gen("zzdflthandlers( int _signal, int *_retsignal )\n");\r
+               _gen("{\n");\r
+       }\r
+       else\r
+       {\r
+               _gen("\nvoid\n");\r
+/*  MR1                                                                                        */\r
+/*  MR1        10-Apr-97  133MR1       Replace __STDC__ with __USE_PROTOS              */\r
+/*  MR1                                                                            */\r
+           _gen("#ifdef __USE_PROTOS\n");                               /* MR1 */\r
+               _gen("zzdflthandlers( int _signal, int *_retsignal )\n");\r
+               _gen("#else\n");\r
+               _gen("zzdflthandlers( _signal, _retsignal )\n");\r
+               _gen("int _signal;\n");\r
+               _gen("int *_retsignal;\n");\r
+               _gen("#endif\n");\r
+               _gen("{\n");\r
+       }\r
+       tabs++;\r
+       if ( DefaultExGroup!=NULL )\r
+       {\r
+               dumpException(DefaultExGroup, 1);\r
+               if ( !hasDefaultException(DefaultExGroup) )\r
+               {\r
+                       gen("default :\n");\r
+                       tabs++;\r
+                       gen("*_retsignal = _signal;\n");\r
+                       tabs--;\r
+                       gen("}\n");\r
+               }\r
+       }\r
+       else {\r
+               gen("*_retsignal = _signal;\n");\r
+       }\r
+\r
+       tabs--;\r
+       _gen("}\n\n");\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+genStdPCCTSIncludeFile( FILE *f,char *gate )    /* MR10 */\r
+#else\r
+genStdPCCTSIncludeFile( f , gate)               /* MR10 */\r
+FILE *f;\r
+char * gate;                                    /* MR10 */\r
+#endif\r
+{\r
+/* MR10 Ramanathan Santhanam (ps@kumaran.com)           */\r
+/* MR10 Same preprocessor symbol use to gate stdpccts.h */\r
+/* MR10   even when two grammars are in use.            */\r
+/* MR10 Derive gate symbol from -fh filename            */\r
+\r
+    if (gate == NULL) {\r
+      fprintf(f,"#ifndef STDPCCTS_H\n");          /* MR10 */\r
+      fprintf(f,"#define STDPCCTS_H\n");          /* MR10 */\r
+    } else {\r
+      fprintf(f,"#ifndef STDPCCTS_%s_H\n",gate);  /* MR10 */\r
+      fprintf(f,"#define STDPCCTS_%s_H\n",gate);  /* MR10 */\r
+    };\r
+       fprintf(f,"/*\n");\r
+    if (gate == NULL) {\r
+         fprintf(f," * %s -- P C C T S  I n c l u d e\n", stdpccts);\r
+    } else {\r
+         fprintf(f," * Standard PCCTS include file with -fh %s -- P C C T S  I n c l u d e\n", stdpccts);\r
+    }\r
+       fprintf(f," *\n");\r
+       fprintf(f," * Terence Parr, Will Cohen, and Hank Dietz: 1989-2001\n");\r
+       fprintf(f," * Purdue University Electrical Engineering\n");\r
+       fprintf(f," * With AHPCRC, University of Minnesota\n");\r
+       fprintf(f," * ANTLR Version %s\n", Version);\r
+       fprintf(f," */\n\n");\r
+\r
+    fprintf(f,"#ifndef ANTLR_VERSION\n");\r
+       fprintf(f,"#define ANTLR_VERSION        %s\n", VersionDef);\r
+    fprintf(f,"#endif\n\n");\r
+\r
+    if (FirstAction != NULL ) dumpAction(FirstAction, f, 0, -1, 0, 1);  /* MR11 */\r
+\r
+       fprintf(f,"#include \"pcctscfg.h\"\n");\r
+       fprintf(f,"#include \"pccts_stdio.h\"\n");\r
+       if ( GenCC )\r
+       {\r
+               if ( UserDefdTokens )\r
+                       fprintf(f, "#include %s\n", UserTokenDefsFile);\r
+               else {\r
+                       fprintf(f, "#include \"%s\"\n", DefFileName);\r
+               }\r
+\r
+               fprintf(f, "#include \"%s\"\n", ATOKEN_H);\r
+\r
+               if ( HdrAction != NULL ) dumpAction( HdrAction, f, 0, -1, 0, 1);\r
+\r
+               fprintf(f, "#include \"%s\"\n", ATOKENBUFFER_H);\r
+\r
+               if ( OutputLL_k > 1 ) fprintf(f,"static const unsigned LL_K=%d;\n", OutputLL_k);\r
+               if ( GenAST ) {\r
+                       fprintf(f, "#include \"%s\"\n", ASTBASE_H);\r
+               }\r
+\r
+        if (TraceGen) {\r
+          fprintf(f,"#ifndef zzTRACE_RULES\n");  /* MR20 */\r
+          fprintf(f,"#define zzTRACE_RULES\n");  /* MR20 */\r
+          fprintf(f,"#endif\n");                 /* MR22 */\r
+        };\r
+\r
+               fprintf(f,"#include \"%s\"\n", APARSER_H);\r
+               fprintf(f,"#include \"%s.h\"\n", CurrentClassName);\r
+               if ( LexGen ) fprintf(f,"#include \"%s\"\n", DLEXERBASE_H);\r
+               fprintf(f, "#endif\n");\r
+               return;\r
+       }\r
+\r
+       if ( strcmp(ParserName, DefaultParserName)!=0 )\r
+               fprintf(f, "#define %s %s\n", DefaultParserName, ParserName);\r
+       if ( strcmp(ParserName, DefaultParserName)!=0 )\r
+               fprintf(f, "#include \"%s\"\n", RemapFileName);\r
+       if ( UserTokenDefsFile != NULL )\r
+          fprintf(f, "#include %s\n", UserTokenDefsFile);\r
+       if ( HdrAction != NULL ) dumpAction( HdrAction, f, 0, -1, 0, 1);\r
+       if ( FoundGuessBlk )\r
+       {\r
+               fprintf(f,"#define ZZCAN_GUESS\n");\r
+               fprintf(f,"#include \"pccts_setjmp.h\"\n");\r
+       }\r
+    if (TraceGen) {\r
+      fprintf(f,"#ifndef zzTRACE_RULES\n");  /* MR20 */\r
+      fprintf(f,"#define zzTRACE_RULES\n");  /* MR20 */\r
+      fprintf(f,"#endif\n");                 /* MR22 */\r
+    };\r
+       if ( OutputLL_k > 1 ) fprintf(f,"#define LL_K %d\n", OutputLL_k);\r
+       if ( GenAST ) fprintf(f,"#define GENAST\n");\r
+       if ( FoundException )\r
+       {\r
+/* MR1  7-Apr-97  1.33MR1                                                                 */\r
+/* MR1            Fix suggested by:                                               */\r
+/* MR1            Francois-Xavier Fontaine (fontaine_f@istvax.ist.lu)         */\r
+\r
+               fprintf(f,"#define EXCEPTION_HANDLING\n");                  /* MR1 */\r
+               fprintf(f,"#define NUM_SIGNALS %d\n", NumSignals);          /* MR1 */\r
+       }\r
+       if ( DemandLookahead ) fprintf(f,"#define DEMAND_LOOK\n");\r
+#ifdef DUM\r
+       if ( LexGen ) fprintf(f, "#define zzEOF_TOKEN %d\n", (TokenInd!=NULL?TokenInd[EofToken]:EofToken));\r
+#endif\r
+       /* ###WARNING: This will have to change when SetWordSize changes */\r
+       fprintf(f, "#define zzSET_SIZE %d\n", NumWords(TokenNum-1)*sizeof(unsigned));\r
+    if (TraceGen) {\r
+      fprintf(f,"#ifndef zzTRACE_RULES\n");  /* MR20 */\r
+      fprintf(f,"#define zzTRACE_RULES\n");  /* MR20 */\r
+      fprintf(f,"#endif\n");                 /* MR22 */\r
+    };\r
+       fprintf(f,"#include \"antlr.h\"\n");\r
+       if ( GenAST ) fprintf(f,"#include \"ast.h\"\n");\r
+       if ( UserDefdTokens )\r
+               fprintf(f, "#include %s\n", UserTokenDefsFile);\r
+       /* still need this one as it has the func prototypes */\r
+       fprintf(f, "#include \"%s\"\n", DefFileName);\r
+       /* still need this one as it defines the DLG interface */\r
+       fprintf(f,"#include \"dlgdef.h\"\n");\r
+       /* don't need this one unless DLG is used */\r
+       if ( LexGen ) fprintf(f,"#include \"%s\"\n", ModeFileName);\r
+       fprintf(f,"#endif\n");\r
+}\r
+\r
+/* dump action 's' to file 'output' starting at "local" tab 'tabs'\r
+   Dump line information in front of action if GenLineInfo is set\r
+   If file == -1 then GenLineInfo is ignored.\r
+   The user may redefine the LineInfoFormatStr to his/her liking\r
+   most compilers will like the default, however.\r
+\r
+   June '93; changed so that empty lines are left alone so that\r
+   line information is correct for the compiler/debuggers.\r
+*/\r
+void\r
+#ifdef __USE_PROTOS\r
+dumpAction( char *s, FILE *output, int tabs, int file, int line,\r
+int final_newline )\r
+#else\r
+dumpAction( s, output, tabs, file, line, final_newline )\r
+char *s;\r
+FILE *output;\r
+int tabs;\r
+int file;\r
+int line;\r
+int final_newline;\r
+#endif\r
+{\r
+    int inDQuote, inSQuote;\r
+    require(s!=NULL,           "dumpAction: NULL action");\r
+    require(output!=NULL,      eMsg1("dumpAction: output FILE is NULL for %s",s));\r
+\r
+       if ( GenLineInfo && file != -1 )\r
+       {\r
+        OutLineInfo(output,line,FileStr[file]);\r
+       }\r
+    PastWhiteSpace( s );\r
+       /* don't print a tab if first non-white char is a # (preprocessor command) */\r
+       if ( *s!='#' ) {TAB;}\r
+    inDQuote = inSQuote = FALSE;\r
+    while ( *s != '\0' )\r
+    {\r
+        if ( *s == '\\' )\r
+        {\r
+            fputc( *s++, output ); /* Avoid '"' Case */\r
+            if ( *s == '\0' ) return;\r
+            if ( *s == '\'' ) fputc( *s++, output );\r
+            if ( *s == '\"' ) fputc( *s++, output );\r
+        }\r
+        if ( *s == '\'' )\r
+        {\r
+            if ( !inDQuote ) inSQuote = !inSQuote;\r
+        }\r
+        if ( *s == '"' )\r
+        {\r
+            if ( !inSQuote ) inDQuote = !inDQuote;\r
+        }\r
+        if ( *s == '\n' )\r
+        {\r
+            fputc('\n', output);\r
+                       s++;\r
+            PastWhiteSpace( s );\r
+            if ( *s == '}' )\r
+            {\r
+                --tabs;\r
+                               TAB;\r
+                fputc( *s++, output );\r
+                continue;\r
+            }\r
+            if ( *s == '\0' ) return;\r
+                       if ( *s != '#' )        /* #define, #endif etc.. start at col 1 */\r
+            {\r
+                               TAB;\r
+                       }\r
+        }\r
+        if ( *s == '}' && !(inSQuote || inDQuote) )\r
+        {\r
+            --tabs;            /* Indent one fewer */\r
+        }\r
+        if ( *s == '{' && !(inSQuote || inDQuote) )\r
+        {\r
+            tabs++;            /* Indent one more */\r
+        }\r
+        fputc( *s, output );\r
+        s++;\r
+    }\r
+    if ( final_newline ) fputc('\n', output);\r
+}\r
+\r
+static void\r
+#ifdef __USE_PROTOS\r
+dumpAfterActions( FILE *output )\r
+#else\r
+dumpAfterActions( output )\r
+FILE *output;\r
+#endif\r
+{\r
+       ListNode *p;\r
+       require(output!=NULL, "dumpAfterActions: output file was NULL for some reason");\r
+       if ( AfterActions != NULL )\r
+       {\r
+               for (p = AfterActions->next; p!=NULL; p=p->next)\r
+               {\r
+                       UserAction *ua = (UserAction *)p->elem;\r
+                       dumpAction( ua->action, output, 0, ua->file, ua->line, 1);\r
+               }\r
+       }\r
+       fclose( output );\r
+}\r
+\r
+/*\r
+ * Find the next action in the stream of execution.  Do not pass\r
+ * junctions with more than one path leaving them.\r
+ * Only pass generic junctions.\r
+ *\r
+ *     Scan forward while (generic junction with p2==NULL)\r
+ *     If we stop on an action, return ptr to the action\r
+ *     else return NULL;\r
+ */\r
+static ActionNode *\r
+#ifdef __USE_PROTOS\r
+findImmedAction( Node *q )\r
+#else\r
+findImmedAction( q )\r
+Node *q;\r
+#endif\r
+{\r
+       Junction *j;\r
+       require(q!=NULL, "findImmedAction: NULL node");\r
+       require(q->ntype>=1 && q->ntype<=NumNodeTypes, "findImmedAction: invalid node");\r
+       \r
+       while ( q->ntype == nJunction )\r
+       {\r
+               j = (Junction *)q;\r
+               if ( j->jtype != Generic || j->p2 != NULL ) return NULL;\r
+               q = j->p1;\r
+               if ( q == NULL ) return NULL;\r
+       }\r
+       if ( q->ntype == nAction ) return (ActionNode *)q;\r
+       return NULL;\r
+}\r
+\r
+static void\r
+#ifdef __USE_PROTOS\r
+dumpRetValAssign( char *retval, char *ret_def, RuleRefNode * ruleRef /* MR30 */)\r
+#else\r
+dumpRetValAssign( retval, ret_def, ruleRef /* MR30 */)\r
+char *retval;\r
+char *ret_def;\r
+RuleRefNode *ruleRefNode;\r
+#endif\r
+{\r
+       char *q = ret_def;\r
+       \r
+       tab();\r
+       while ( *retval != '\0' && *q != '\0')\r
+       {\r
+               while ( isspace((*retval)) ) retval++;\r
+               while ( *retval!=',' && *retval!='\0' ) fputc(*retval++, output);\r
+               fprintf(output, " = _trv.");\r
+               \r
+               DumpNextNameInDef(&q, output);\r
+               while ( isspace(*q) ) q++;\r
+               fputc(';', output); fputc(' ', output);\r
+               if ( *retval == ',' ) retval++;\r
+       }\r
+       if (*retval == '\0' && *q != '\0') {\r
+/* MR30 */    errFL("Fewer output values than output formals for rule reference",\r
+/* MR30 */                 FileStr[ruleRef->file],ruleRef->line);\r
+       }\r
+       if (*retval != '\0' && *q == '\0') {\r
+/* MR30 */    errFL("More output actuals than output formals for rule reference",\r
+/* MR30 */                 FileStr[ruleRef->file],ruleRef->line);\r
+       }\r
+}\r
+\r
+/* This function computes the set of tokens that can possibly be seen k\r
+ * tokens in the future from point j\r
+ */\r
+\r
+static set\r
+#ifdef __USE_PROTOS\r
+ComputeErrorSet( Junction *j, int k, int usePlusBlockBypass)\r
+#else\r
+ComputeErrorSet( j, k, usePlusBlockBypass )\r
+Junction *j;\r
+int k;\r
+int usePlusBlockBypass;\r
+#endif\r
+{\r
+       Junction *alt1;\r
+       set a, rk, f;\r
+       require(j->ntype==nJunction, "ComputeErrorSet: non junction passed");\r
+\r
+       f = rk = empty;\r
+       for (alt1=j; alt1!=NULL; alt1 = (Junction *)alt1->p2)\r
+       {\r
+        if (alt1->ignore && ! usePlusBlockBypass) continue;     /* MR21 - Ignore aPlusBlk forward p2 */\r
+               REACH(alt1->p1, k, &rk, a);\r
+               require(set_nil(rk), "ComputeErrorSet: rk != nil");\r
+               set_free(rk);\r
+               set_orin(&f, a);\r
+               set_free(a);\r
+       }\r
+       return f;\r
+}\r
+\r
+static char *\r
+#ifdef __USE_PROTOS\r
+tokenFollowSet(TokNode *p)\r
+#else\r
+tokenFollowSet(p)\r
+TokNode *p;\r
+#endif\r
+{\r
+    static char buf[100];\r
+    set rk, a;\r
+    int n;\r
+    rk = empty;\r
+\r
+    REACH(p->next, 1, &rk, a);\r
+    require(set_nil(rk), "rk != nil");\r
+    set_free(rk);\r
+    n = DefErrSet( &a, 0, NULL );\r
+    set_free(a);\r
+    if ( GenCC )\r
+        sprintf(buf, "err%d", n);\r
+    else\r
+        sprintf(buf, "zzerr%d", n);\r
+    return buf;\r
+}\r
+\r
+static void\r
+#ifdef __USE_PROTOS\r
+makeErrorClause( Junction *q, set f, int max_k, int usePlusBlockBypass )\r
+#else\r
+makeErrorClause( q, f, max_k, usePlusBlockBypass )\r
+Junction *q;\r
+set f;\r
+int max_k;\r
+int usePlusBlockBypass;\r
+#endif\r
+{\r
+    char *  handler_id="";                                           /* MR7 */\r
+    int     nilf=0;                                                  /* MR13 */\r
+    RuleEntry *ruleEntry;                                            /* MR14 */\r
+\r
+       if ( FoundException )\r
+       {\r
+               _gen("else {\n");\r
+               tabs++;\r
+               if ( FoundGuessBlk )\r
+               {\r
+                       if ( GenCC ) {gen("if ( guessing ) goto fail;\n");}\r
+                       else gen("if ( zzguessing ) goto fail;\n");\r
+               }\r
+               gen("if (_sva) _signal=NoViableAlt;\n");\r
+               gen("else _signal=NoSemViableAlt;\n");\r
+        if (q->outerEG != NULL) {\r
+          handler_id=q->outerEG->altID;\r
+#if 0\r
+        } else {\r
+          printf("q->curAltNum=%d q->exception_label=%s\n",q->curAltNum,q->exception_label);\r
+          gen("*** DEBUG *** outerEG==NULL\n");\r
+#endif\r
+        };\r
+               gen1("goto %s_handler;  /* MR7 */\n",handler_id);    /* MR7 */\r
+               tabs--;\r
+               gen("}\n");\r
+               return;\r
+       }\r
+\r
+       if ( max_k == 1 )\r
+       {\r
+/* MR13 */  nilf=set_nil(f);\r
+               if ( GenCC ) {\r
+              _gen1("else {FAIL(1,err%d", DefErrSet1(1,&f,1,NULL));\r
+            } else {\r
+               _gen1("else {zzFAIL(1,zzerr%d", DefErrSet1(1,&f,1,NULL));\r
+            };\r
+               set_free(f);\r
+       }\r
+       else\r
+       {\r
+               int i;\r
+               set_free(f);\r
+               if ( GenCC ) {_gen1("else {FAIL(%d", max_k);}\r
+               else _gen1("else {zzFAIL(%d", max_k);\r
+\r
+    ruleEntry = (RuleEntry *) hash_get(Rname,q->rname);\r
+\r
+               for (i=1; i<=max_k; i++)\r
+               {\r
+/* MR14 */  if (ruleEntry->dontComputeErrorSet) {\r
+/* MR14 */    f=empty;\r
+            } else {\r
+             f = ComputeErrorSet(q, i, usePlusBlockBypass /* use plus block bypass ? */ );\r
+            }\r
+\r
+      if ( GenCC ) {_gen1(",err%d", DefErrSet( &f, 1, NULL ));}\r
+                       else _gen1(",zzerr%d", DefErrSet( &f, 1, NULL ));\r
+                       \r
+                       set_free(f);\r
+               }\r
+       }\r
+       _gen(",&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\n");\r
+/* MR13 */  if (nilf) {\r
+/* MR13 */    errFL("empty error set for alt - probably because of undefined rule or infinite left recursion",\r
+/* MR13 */                 FileStr[q->file],q->line);\r
+/* MR13 */    gen(" /* MR13 empty error set for this alt - undef rule ? infinite left recursion ? */");\r
+/* MR13 */  };\r
+}\r
+\r
+static                                                               /* MR7 */\r
+#ifdef __USE_PROTOS\r
+char * findOuterHandlerLabel(ExceptionGroup *eg)                     /* MR7 */\r
+#else\r
+char * findOuterHandlerLabel(eg)                                     /* MR7 */\r
+ExceptionGroup *eg;                                                  /* MR7 */\r
+#endif\r
+{\r
+  char              *label=NULL;                                     /* MR7 */\r
+  ExceptionGroup    *outerEG;                                        /* MR7 */\r
+\r
+  if (eg->forRule == 0) {                                            /* MR7 */\r
+    if (eg->labelEntry != NULL) {                                    /* MR7 */\r
+      outerEG=eg->labelEntry->outerEG;                               /* MR7 */\r
+      if (outerEG != NULL) {                                         /* MR7 */\r
+        label=outerEG->altID;                                        /* MR7 */\r
+        outerEG->used=1;                                             /* MR7 */\r
+      };                                                             /* MR7 */\r
+    } else if (eg->outerEG != NULL) {                                /* MR7 */\r
+      outerEG=eg->outerEG;                                           /* MR7 */\r
+      label=outerEG->altID;                                          /* MR7 */\r
+      outerEG->used=1;                                               /* MR7 */\r
+    };                                                               /* MR7 */\r
+  };                                                                 /* MR7 */\r
+  return (label==NULL ? "" : label);                                 /* MR7 */\r
+}                                                                    /* MR7 */\r
+\r
+/*** debug ***/\r
+#if 0\r
+** static                                                               /* MR7 */\r
+** #ifdef __USE_PROTOS\r
+** char * findOuterAltHandlerLabel(Junction *startJ)                    /* MR7 */\r
+** #else\r
+** char * findOuterAltHandlerLabel(startJ)                              /* MR7 */\r
+** Junction *startJ;                                                    /* MR7 */\r
+** #endif\r
+** {                                                                    /* MR7 */\r
+**   char      *label=NULL;                                             /* MR7 */\r
+**   Junction  *alt;                                                    /* MR7 */\r
+**                                                                      /* MR7 */\r
+**   for (alt=startJ; alt != NULL; alt=alt->outerAltstart) {            /* MR7 */\r
+**     label=alt->exception_label;                                      /* MR7 */\r
+**     if (label != NULL) break;                                        /* MR7 */\r
+**   };                                                                 /* MR7 */\r
+**   return (label==NULL ? "" : label);                                 /* MR7 */\r
+** }                                                                    /* MR7 */\r
+#endif\r
+\r
+#ifdef __USE_PROTOS\r
+static void OutLineInfo(FILE *file,int line,char *fileName)\r
+#else\r
+static void OutLineInfo(file,line,fileName)\r
+  FILE *    file;\r
+  int       line;\r
+  char *    fileName;\r
+#endif\r
+{\r
+    static  char * prevFileName=NULL;\r
+    static  char * prevFileNameMS=NULL;\r
+\r
+    char *  p;\r
+    char *  q;\r
+\r
+    if (! GenLineInfo) return;\r
+\r
+    if (!GenLineInfoMS) {\r
+           fprintf(file, LineInfoFormatStr,line,fileName);\r
+    } else {\r
+      if (fileName == prevFileName) {\r
+           fprintf(file, LineInfoFormatStr,line,prevFileNameMS);\r
+      } else {\r
+        if (prevFileNameMS != NULL) free (prevFileNameMS);\r
+        prevFileNameMS=(char *)calloc(1,strlen(fileName)+1);\r
+        require(prevFileNameMS != NULL,"why not do this in calloc wrapper");\r
+        q=prevFileNameMS;\r
+        for (p=fileName; *p != 0; p++) {\r
+            *q=*p;\r
+            if (*q == '\\') *q='/';\r
+            q++;\r
+        }\r
+      }\r
+      prevFileName=fileName;\r
+    };\r
+}\r
+\r
+#if 0\r
+\r
+/* MR21 */\r
+\r
+#ifdef __USE_PROTOS\r
+void OutFirstSetSymbol(Junction *q, char * pSymbol)\r
+#else\r
+void OutFirstSetSymbol(q, pSymbol)\r
+    Junction* q;\r
+       char * pSymbol\r
+#endif\r
+{\r
+\r
+       set f;\r
+    if (pSymbol == NULL) return;\r
+       gen1("/** #FirstSetSymbol(%s) **/\n",pSymbol);\r
+    f = ComputeErrorSet(q, 1, 0 /* use plus block bypass ? */);\r
+    DefErrSetWithSuffix (0 /* nil ok */, &f,0 /* no substitute */, pSymbol, "");\r
+    set_free(f);\r
+}\r
+#endif\r
+\r
+/* MR21 */\r
+\r
+#ifdef __USE_PROTOS\r
+void BlockPreambleOption(Junction *q, char * pSymbol)\r
+#else\r
+void BlockPreambleOption(q, pSymbol)\r
+    Junction* q;\r
+       char * pSymbol;\r
+#endif\r
+{\r
+       set f = empty;\r
+    if (pSymbol != NULL) {\r
+        f = ComputeErrorSet(q, 1, 0 /* use plus block bypass ? */);\r
+       gen1("/** #FirstSetSymbol(%s) **/\n",pSymbol);\r
+        DefErrSetWithSuffix (0 /* nil ok */, &f,0 /* no substitute */, pSymbol, "");\r
+    }\r
+    set_free(f);\r
+}\r
+\r
+/* MR21 */\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+dumpActionPlus(ActionNode *a, char *s, FILE *output, int tabs, int file, int line,\r
+int final_newline )\r
+#else\r
+dumpActionPlus(a, s, output, tabs, file, line, final_newline )\r
+ActionNode *a;\r
+char *s;\r
+FILE *output;\r
+int tabs;\r
+int file;\r
+int line;\r
+int final_newline;\r
+#endif\r
+{\r
+    dumpAction(s,output,tabs,file,line,final_newline);\r
+}\r
+\r
+\r
+#if 0\r
+** #ifdef __USE_PROTOS\r
+** void MR_ErrorSets(Junction *q, int max_k, int usePlusBlockBypass)\r
+** #else\r
+** void MR_ErrorSets(q, max_k, usePlusBlockBypass)\r
+** Junction *q;\r
+** int max_k;\r
+** int usePlusBlockBypass;\r
+** #endif\r
+** {\r
+**     int k;\r
+**     set setResult;\r
+**     Junction* alt1;\r
+**     Junction* p;\r
+**     set rk;\r
+** \r
+**     require (max_k <= CLL_k, "k > CLL_k");\r
+** \r
+** \r
+**     for (k = 1; k <= CLL_k; k++) {set_clr(q->fset[k]); }\r
+** \r
+**     for (k = 1; k <= max_k; k++) {\r
+**         for (alt1=q; alt1 != NULL; alt1 = (Junction *)alt1->p2)\r
+**             {\r
+**             if (alt1->ignore && ! usePlusBlockBypass) continue;\r
+**             p = analysis_point((Junction *)alt1->p1);\r
+**                     REACH(p, k, &rk, setResult);\r
+**                     require(set_nil(rk), "rk != nil");\r
+**             set_orin(&q->fset[k], setResult);\r
+**             }\r
+**     }\r
+** }\r
+#endif\r
+\r
+\r
+#ifdef __USE_PROTOS\r
+void DumpInitializers(FILE* output, RuleEntry *r, char * pReturn)\r
+#else\r
+void DumpInitializers(output, r, pReturn)\r
+FILE* output;\r
+RuleEntry *r;\r
+char * pReturn;\r
+#endif\r
+{\r
+       char *p = pReturn;\r
+       char *pDataType;\r
+       char *pSymbol;\r
+       char *pEqualSign;\r
+       char *pValue;\r
+       char *pSeparator;\r
+       int nest = 0;\r
+    char *q;\r
+\r
+       require(pReturn!=NULL, "DumpInitializer: invalid string"); \r
+\r
+    while (*p != 0) {\r
+       p = endFormal(p,\r
+                             &pDataType,\r
+                                 &pSymbol,\r
+                                 &pEqualSign,\r
+                                 &pValue,\r
+                                 &pSeparator,\r
+                                 &nest);\r
+        if (nest != 0) return;\r
+        if (pValue != NULL) {\r
+                       tab();\r
+            q = strBetween(pSymbol, pEqualSign, pSeparator);\r
+            fprintf(output, "_retv.%s", q);\r
+            q = strBetween(pValue, NULL, pSeparator);\r
+            fprintf(output, " = %s;\n", q);\r
+        }\r
+    }\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+void DumpFormals(FILE* output, char * pReturn, int bInitializer)\r
+#else\r
+void DumpFormals(output, pReturn, bInitializer)\r
+FILE* output;\r
+char * pReturn;\r
+int bInitializer;\r
+#endif\r
+{\r
+       char *p = pReturn;\r
+       char *pDataType;\r
+       char *pSymbol;\r
+       char *pEqualSign;\r
+       char *pValue;\r
+       char *pSeparator;\r
+       int nest = 0;\r
+    char *q;\r
+    int count = 0;\r
+\r
+       require(pReturn!=NULL, "DumpFormals: invalid string"); \r
+\r
+    while (*p != 0) {\r
+       p = endFormal(p,\r
+                             &pDataType,\r
+                                 &pSymbol,\r
+                                 &pEqualSign,\r
+                                 &pValue,\r
+                                 &pSeparator,\r
+                                 &nest);\r
+        if (nest != 0) return;\r
+        if (count > 0) fprintf(output,",");\r
+        if (pDataType != NULL && pSymbol != NULL) {\r
+            q = strBetween(pDataType, pSymbol, pSeparator);\r
+            fprintf(output, "%s", q);\r
+            q = strBetween(pSymbol, pEqualSign, pSeparator);\r
+            fprintf(output," %s",q);\r
+            if (pValue != NULL) {\r
+                q = strBetween(pValue, NULL, pSeparator);\r
+                if (bInitializer != 0) {\r
+                    fprintf(output, " = %s", q);\r
+                }\r
+            }\r
+        }\r
+        count++;\r
+    }\r
+}\r
+\r
+/* MR23 Check for empty alt in a more intelligent way.\r
+        Previously, an empty alt for genBlk had to point directly\r
+               to the endBlock.  This did not work once I changed {...}\r
+               blocks to look like (...|...| epsilon) since there were\r
+               intervening generics.  This fixes the problem for this\r
+               particular case.  Things like actions or empty blocks of\r
+               various kinds will still cause problems, but I wasnt't\r
+               prepared to handle pathological cases like (A|()*). It\r
+               does handle (A | ()), which is a recommended idiom for\r
+               epsilon.\r
+\r
+        Actually, this isn't quite correct since it doesn't handle\r
+               the case of the ignore bit in the plus block bypass, but\r
+               I'm too tired to figure out the correct fix, and will just\r
+               work around it.\r
+*/\r
+\r
+#ifdef __USE_PROTOS\r
+int isEmptyAlt(Node * alt, Node * endBlock)\r
+#else\r
+int isEmptyAlt(alt, endBlock)\r
+Node * alt;\r
+Node * endBlock;\r
+#endif\r
+{\r
+       Node * n = alt;\r
+       Junction * j;\r
+       while (n != endBlock) {\r
+               switch (n->ntype) {\r
+\r
+                       case nRuleRef:\r
+                               return 0;\r
+\r
+                       case nToken:\r
+                               return 0;\r
+\r
+                       case nAction:\r
+                               return 0;\r
+\r
+                       case nJunction:\r
+                               goto JUNCTION;\r
+\r
+                       default:\r
+                               fatal_internal("Invalid node type");\r
+                               return 0;\r
+               }\r
+JUNCTION:\r
+               j = (Junction *) n;\r
+\r
+               switch (j->jtype) {\r
+                       case Generic:\r
+                               {\r
+                                       n = j->p1;\r
+                                       goto NEXT;\r
+                               }\r
+\r
+                       case aSubBlk:\r
+                               {\r
+                                       n = j->p1;      /* MR26 */\r
+                                       goto NEXT;      /* MR26 */\r
+                               }\r
+\r
+                       case EndBlk:\r
+                                       return 0;\r
+\r
+                       case EndRule:\r
+                                       return 1;\r
+\r
+                       default:\r
+                                       return 0;\r
+               }\r
+NEXT: continue;\r
+       }\r
+       return 1;\r
+}\r
diff --git a/Tools/CodeTools/Source/Pccts/antlr/generic.h b/Tools/CodeTools/Source/Pccts/antlr/generic.h
new file mode 100644 (file)
index 0000000..8d736d5
--- /dev/null
@@ -0,0 +1,286 @@
+/*\r
+ * generic.h -- generic include stuff for new PCCTS ANTLR.\r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
+ * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
+ * company may do whatever they wish with source code distributed with\r
+ * PCCTS or the code generated by PCCTS, including the incorporation of\r
+ * PCCTS, or its output, into commerical software.\r
+ *\r
+ * We encourage users to develop software with PCCTS.  However, we do ask\r
+ * that credit is given to us for developing PCCTS.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like PCCTS and have developed a nice tool with the\r
+ * output, please mention that you developed it using PCCTS.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * ANTLR 1.33\r
+ * Terence Parr\r
+ * Parr Research Corporation\r
+ * with Purdue University and AHPCRC, University of Minnesota\r
+ * 1989-2001\r
+ */\r
+\r
+#define StrSame                        0\r
+\r
+#define DefaultParserName      "zzparser"\r
+\r
+/* MR9  JVincent@novell.com     Allow user to override default ZZLEXBUFSIZE  */\r
+/* MR11 thm                     Raise antlr's own default ZZLEXBUFSIZE to 8k */\r
+/* MR22 thm                     Raise antlr's own default ZZLEXBUFSIZE to 32k */\r
+\r
+#ifndef ZZLEXBUFSIZE\r
+#define ZZLEXBUFSIZE 32000\r
+#endif\r
+\r
+/* Tree/FIRST/FOLLOW defines -- valid only after all grammar has been read */\r
+#define ALT                    TokenNum+1\r
+#define SET                    TokenNum+2\r
+#define TREE_REF       TokenNum+3\r
+\r
+                                       /* E r r o r  M a c r o s */\r
+\r
+#define fatal(err)     fatalFL(err, __FILE__, __LINE__)\r
+#define fatal_internal(err)    fatal_intern(err, __FILE__, __LINE__)\r
+\r
+\r
+#define eMsg1(s,a)     eMsg3(s,a,NULL,NULL)\r
+#define eMsg2(s,a,b)   eMsg3(s,a,b,NULL)\r
+\r
+                               /* S a n i t y  C h e c k i n g */\r
+\r
+#ifndef require\r
+#define require(expr, err) {if ( !(expr) ) fatal_internal(err);}\r
+#endif\r
+\r
+                                       /* L i s t  N o d e s */\r
+\r
+typedef struct _ListNode {\r
+                       void *elem;                     /* pointer to any kind of element */\r
+                       struct _ListNode *next;\r
+               } ListNode;\r
+\r
+/* Define a Cycle node which is used to track lists of cycles for later\r
+ * reconciliation by ResolveFoCycles().\r
+ */\r
+typedef struct _c {\r
+                       int croot;                      /* cycle root */\r
+                       set cyclicDep;          /* cyclic dependents */\r
+                       unsigned deg;           /* degree of FOLLOW set of croot */\r
+               } Cycle;\r
+\r
+typedef struct _e {\r
+                       int tok;                        /* error class name == TokenStr[tok] */\r
+                       ListNode *elist;        /* linked list of elements in error set */\r
+                       set eset;\r
+                       int setdeg;                     /* how big is the set */\r
+                       int lexclass;           /* which lex class is it in? */\r
+               } ECnode;\r
+\r
+typedef struct _TCnode {\r
+                       int tok;                        /* token class name */\r
+                       ListNode *tlist;        /* linked list of elements in token set */\r
+                       set tset;\r
+                       int lexclass;           /* which lex class is it in? */\r
+                       unsigned char dumped; /* this def has been been dumped */\r
+                       unsigned char dumpedComplement; /* this def has been been dumped */\r
+                       unsigned setnum;        /* which set number is this guy? (if dumped) */\r
+                       unsigned setnumComplement;               /* MR23 */\r
+                       unsigned setnumErrSet;                   /* MR23 which set is this #tokclass error set (if dumped) */\r
+                       unsigned setnumErrSetComplement; /* MR23 */\r
+               } TCnode;\r
+\r
+typedef struct _ft {\r
+                       char *token;            /* id of token type to remap */\r
+                       int tnum;                       /* move token type to which token position */\r
+               } ForcedToken;\r
+\r
+typedef struct _ContextGuardPredicates {    /* MR13 */\r
+            Predicate *pred;                /* MR13 */\r
+        } ContextGuardPredicates;           /* MR13 */\r
+\r
+#define newListNode    (ListNode *) calloc(1, sizeof(ListNode));\r
+#define newCycle       (Cycle *) calloc(1, sizeof(Cycle));\r
+#define newECnode      (ECnode *) calloc(1, sizeof(ECnode));\r
+#define newTCnode      (TCnode *) calloc(1, sizeof(TCnode));\r
+\r
+\r
+                               /* H a s h  T a b l e  E n t r i e s */\r
+\r
+typedef struct _t {                            /* Token name or expression */\r
+                       char *str;\r
+                       struct _t *next;\r
+                       int token;                      /* token number */\r
+                       unsigned char classname;        /* is it a err/tok class name or token */\r
+                       TCnode *tclass;         /* ptr to token class */\r
+                       char *action;\r
+            char *akaString;\r
+               } TermEntry;\r
+\r
+typedef struct _r {                            /* Rule name and ptr to start of rule */\r
+                       char *str;\r
+                       struct _t *next;\r
+                       int rulenum;            /* RulePtr[rulenum]== ptr to RuleBlk junction */\r
+                       unsigned char noAST;/* gen AST construction code? (def==gen code) */\r
+                       char *egroup;           /* which error group (err reporting stuff) */\r
+#if 0\r
+                       /* MR27  This appears to never be used.  Delete this code later. */\r
+\r
+                       ListNode *el_labels;/* list of element labels ref in all of rule */\r
+#endif\r
+                       ListNode *ast_labels_in_actions; /* MR27 */\r
+            unsigned char has_rule_exception;\r
+            char dontComputeErrorSet;    /* MR14 - don't compute error set\r
+                                          special for rule in alpha part of\r
+                                          (alpha)? beta block */\r
+               } RuleEntry;\r
+\r
+typedef struct _f {                            /* cache Fi/Fo set */\r
+                       char *str;                      /* key == (rulename, computation, k) */\r
+                       struct _f *next;\r
+                       set fset;                       /* First/Follow of rule */\r
+                       set rk;                         /* set of k's remaining to be done after ruleref */\r
+                       int incomplete;         /* only w/FOLLOW sets.  Use only if complete */\r
+               } CacheEntry;\r
+\r
+typedef struct _LabelEntry {   /* element labels */\r
+                       char *str;\r
+                       struct _f *next;\r
+                       Node *elem;                     /* which element does it point to? */\r
+                       ExceptionGroup *ex_group;\r
+                                                               /* Is there an exception attached to label? */\r
+            ExceptionGroup *outerEG;                                 /* MR7 */\r
+                                /* next EG if ex_group doesn't catch it MR7 */\r
+            struct _LabelEntry  *pendingLink;                        /* MR7 */\r
+                                /* too lazy to use ListNode ?           MR7 */\r
+            int     curAltNum;                                       /* MR7 */\r
+               } LabelEntry;\r
+\r
+typedef struct _SignalEntry {\r
+                       char *str;\r
+                       struct _f *next;\r
+                       int signum;                     /* unique signal number */\r
+               } SignalEntry;\r
+\r
+typedef struct _PredEntry {                            /* MR11 predicate name and ptr to string */\r
+                       char              *str;\r
+            struct _PredEntry *next;\r
+            int               file;\r
+            int               line;\r
+            Predicate         *pred;\r
+            char              *predLiteral;\r
+               } PredEntry;\r
+\r
+typedef struct _PointerStack {      /* MR10 */\r
+        int     count;\r
+        int     size;\r
+        void    **data;\r
+        } PointerStack;\r
+\r
+#define newTermEntry(s)                (TermEntry *) newEntry(s, sizeof(TermEntry))\r
+#define newRuleEntry(s)                (RuleEntry *) newEntry(s, sizeof(RuleEntry))\r
+#define newCacheEntry(s)       (CacheEntry *) newEntry(s, sizeof(CacheEntry))\r
+#define newLabelEntry(s)       (LabelEntry *) newEntry(s, sizeof(LabelEntry))\r
+#define newSignalEntry(s)      (SignalEntry *) newEntry(s, sizeof(SignalEntry))\r
+#define newPredEntry(s)     (PredEntry *) newEntry(s,sizeof(PredEntry))\r
+\r
+typedef struct _UserAction {\r
+                       char *action;\r
+                       int file, line;\r
+               } UserAction;\r
+\r
+\r
+                                       /* L e x i c a l  C l a s s */\r
+\r
+/* to switch lex classes, switch ExprStr and Texpr (hash table) */\r
+typedef struct _lc {\r
+                       char *classnum, **exprs;\r
+                       Entry **htable;\r
+               } LClass;\r
+\r
+typedef struct _exprOrder {\r
+                       char *expr;\r
+                       int lclass;\r
+               } Expr;\r
+\r
+\r
+typedef Graph Attrib;\r
+\r
+                                               /* M a x i m u m s */\r
+\r
+/* MR20 Note G. Hobbelt These values are superceded by values in hash.h */\r
+\r
+#ifndef HashTableSize\r
+#define HashTableSize  253\r
+#endif\r
+#ifndef StrTableSize\r
+#define StrTableSize   15000   /* all tokens, nonterminals, rexprs stored here */\r
+#endif\r
+#define MaxLexClasses  50              /* how many automatons */\r
+/* TokenStart and EofToken are ignored if #tokdefs meta-op is used */\r
+#define TokenStart             2               /* MUST be in 1 + EofToken */\r
+#define EofToken               1               /* Always predefined to be 1 */\r
+\r
+#ifndef MaxNumFiles\r
+#define MaxNumFiles            99\r
+#endif\r
+\r
+/**** MR9 JVincent@novell.com  Move to pcctscfg.h */\r
+/**** #define MaxFileName              300     ****/ /* MR9  Move to pcctscfg.h */ /* largest file name size */\r
+\r
+#define MaxRuleName            100             /* largest rule name size */\r
+#define TSChunk                        100             /* how much to expand TokenStr/ExprStr each time */\r
+#define TIChunk                        TSChunk /* expand TokenInd by same as TokenStr to mirror them */\r
+#define FoStackSize            100             /* deepest FOLLOW recursion possible */\r
+\r
+#define MaxClassDeclStuff   256    /* MR10 */\r
+\r
+#define NumPredefinedSignals 3\r
+\r
+           /* S t a n d a r d  S i g n a l s */\r
+\r
+#define sigNoSignal                            0\r
+#define sigMismatchedToken             1\r
+#define sigNoViableAlt                 2\r
+#define sigNoSemViableAlt              3\r
+\r
+\r
+\r
+/* AST token types */\r
+#define ASTexclude             0\r
+#define ASTchild               1\r
+#define ASTroot                        2\r
+#define ASTinclude             3               /* include subtree made by rule ref */\r
+\r
+\r
+#define PredictionVariable                             "zzpr_expr"\r
+#define PredictionLexClassSuffix               "_zzpred"\r
+\r
+#define WildCardString                                 "WildCard"\r
+\r
+#if 0\r
+    /*  Removed in version 1.33MR19\r
+        Don't understand why this never caused problems before\r
+    */\r
+\r
+    /*********************************************************\r
+    #ifndef ANTLRm\r
+       #define ANTLRm(st, f, _m)       zzbufsize = ZZLEXBUFSIZE;\\r
+                                       zzmode(_m);                                     \\r
+                                       zzenterANTLR(f);                        \\r
+                                       st; ++zzasp;                            \\r
+                                       zzleaveANTLR(f);\r
+       #endif                                          \r
+    *********************************************************/\r
+#endif\r
+\r
+#include "proto.h"\r
+#include "pcctscfg.h"   /* MR14 */\r
+#include <string.h>\r
diff --git a/Tools/CodeTools/Source/Pccts/antlr/globals.c b/Tools/CodeTools/Source/Pccts/antlr/globals.c
new file mode 100644 (file)
index 0000000..59d0032
--- /dev/null
@@ -0,0 +1,484 @@
+/*\r
+ * globals.c   --      File containing all variables/tables visible to all files.\r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
+ * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
+ * company may do whatever they wish with source code distributed with\r
+ * PCCTS or the code generated by PCCTS, including the incorporation of\r
+ * PCCTS, or its output, into commerical software.\r
+ *\r
+ * We encourage users to develop software with PCCTS.  However, we do ask\r
+ * that credit is given to us for developing PCCTS.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like PCCTS and have developed a nice tool with the\r
+ * output, please mention that you developed it using PCCTS.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * ANTLR 1.33\r
+ * Terence Parr\r
+ * Parr Research Corporation\r
+ * with Purdue University and AHPCRC, University of Minnesota\r
+ * 1989-2001\r
+ */\r
+\r
+#include <stdio.h>\r
+\r
+#include "pcctscfg.h"\r
+\r
+#include "set.h"\r
+#include "syn.h"\r
+#include "hash.h"\r
+#include "generic.h"\r
+\r
+char Version[] = "1.33MR33" ;  /* PCCTS version number */                         /* MRXXX */\r
+char VersionDef[] = "13333";    /* same (except int equiv for preproc symbol) */ /* MRXXX */\r
+\r
+char LexStartSymbol[] = "START";/* Name of starting lexical class/automaton */\r
+char *RemapFileName = "remap.h";\r
+char *DlgFileName = "parser.dlg";\r
+char *DefFileName = "tokens.h";\r
+char *ErrFileName = "err.c";\r
+char *ModeFileName = "mode.h";\r
+char *StdMsgName = NULL;\r
+\r
+char *ParserName = DefaultParserName;\r
+\r
+/* list of PCCTS supplied support symbols; these are renamed when more than\r
+ * one ANTLR-generated parsers are linked together to avoid name conflicts.\r
+ * Can't use '##' ANSIC preprocessor concat operator with K&R and:\r
+ *             #define zzskip  zzparser ## skip\r
+ * will not work for ANSI/C++ as 'zzparserskip' is created w/o zzparser\r
+ * being substituted--ack!!!\r
+ */\r
+char *StandardSymbols[] = {\r
+/* ANTLR stuff */\r
+       "zzStackOvfMsg",\r
+       "zzasp",\r
+       "zzaStack",\r
+       "inf_tokens",\r
+       "inf_text",\r
+       "inf_text_buffer",\r
+       "inf_text_buffer_ptr",\r
+       "inf_text_buffer_size",\r
+       "inf_labase",\r
+       "inf_last",\r
+       "inf_lap",\r
+       "zztokenLA",\r
+       "zztextLA",\r
+       "zzlap",\r
+       "zzlabase",\r
+       "zztoktext",\r
+       "zztoken",\r
+       "zzdirty",\r
+       "zzguessing",\r
+       "zzguess_start",\r
+       "zzresynch",\r
+       "zzinf_tokens",\r
+       "zzinf_text",\r
+       "zzinf_text_buffer",\r
+       "zzinf_labase",\r
+       "zzinf_last",\r
+       "zzfill_inf_look",\r
+       "zzFAIL",\r
+       "zzsave_antlr_state",\r
+       "zzrestore_antlr_state",\r
+       "zzsyn",\r
+       "zzset_el",\r
+       "zzset_deg",\r
+       "zzedecode",\r
+       "_zzsetmatch",\r
+       "_zzmatch",\r
+       "_inf_zzgettok",\r
+    "zzconsumeUntil",\r
+    "zzconsumeUntilToken",\r
+    "_zzmatch_wsig",\r
+    "_zzsetmatch_wsig",\r
+    "_zzmatch_wdfltsig",\r
+    "_zzsetmatch_wdfltsig",\r
+       "zzdflthandlers",\r
+/* DLG stuff */\r
+       "zzreal_line",\r
+       "zzcharfull",\r
+       "zzerr",\r
+       "zzlextext",\r
+       "zzbegexpr",\r
+       "zzendexpr",\r
+       "zzbufsize",\r
+       "zzbegcol",\r
+       "zzendcol",\r
+       "zzline",\r
+       "zzchar",\r
+       "zzbufovf",\r
+       "zzrdstream",\r
+       "zzrdfunc",\r
+       "zzrdstr",\r
+       "zzclose_stream",\r
+       "zzsave_dlg_state",\r
+       "zzrestore_dlg_state",\r
+       "zzmode",\r
+       "zzskip",\r
+       "zzmore",\r
+       "zzreplchar",\r
+       "zzreplstr",\r
+       "zzgettok",\r
+       "zzadvance",\r
+       "zzerrstd",\r
+       "zzerr_in",\r
+       "zzconstr_attr",\r
+       "zzempty_attr",\r
+       "zzerraction",\r
+       "zztokens",                     /* list of token regular expressions */\r
+       "dfa",\r
+       "accepts",\r
+       "actions",\r
+    "zzTraceOptionValue",       /* MR10 */\r
+    "zzTraceGuessOptionValue",  /* MR10 */\r
+    "zzTraceCurrentRuleName",   /* MR10 */\r
+    "zzTraceDepth",             /* MR10 */\r
+    "zzGuessSeq",               /* MR10 */\r
+    "zzSyntaxErrCount",         /* MR11 */\r
+    "zzLexErrCount",            /* MR11 */\r
+    "zzTraceGuessDone",         /* MR13 - BJS */\r
+    "zzTraceGuessFail",         /* MR13 - BJS */\r
+    "zzTraceGuessOption",       /* MR13 - BJS */\r
+    "zzTraceIn",                /* MR13 - BJS */\r
+    "zzTraceOption",            /* MR13 - BJS */\r
+    "zzTraceOut",               /* MR13 - BJS */\r
+    "zzTraceReset",             /* MR13 - BJS */\r
+       NULL            /* must be present */\r
+};\r
+\r
+/* list of PCCTS supplied support functions; these are renamed when more than\r
+ * one ANTLR-generated parsers are linked together to avoid name conflicts.\r
+ */\r
+char *ASTSymbols[] = {\r
+       "AST",\r
+       "zzast_sp",\r
+       "zzastStack",\r
+       "zzlink",\r
+       "zzastnew",\r
+       "zzsubchild",\r
+       "zzsubroot",\r
+       "zzpre_ast",\r
+       "zzfree_ast",\r
+       "zztmake",\r
+       "zzdup_ast",\r
+       "zztfree",\r
+       "zzdouble_link",\r
+       NULL            /* must be present */\r
+};\r
+\r
+/* Current ambiguity examination information */\r
+int CurAmbigAlt1, CurAmbigAlt2, CurAmbigline, CurAmbigfile;\r
+char *CurAmbigbtype;\r
+\r
+\r
+                                               /* M e t h o d  T a b l e s */\r
+/*\r
+ * The following tables are used to fill syntax diagram nodes with the correct\r
+ * function pointers for computing FIRST sets and printing themselves.\r
+ */\r
+\r
+/* fpTraverse[node type] == pointer to function that calculates trees\r
+ * representing the FIRST sets for that node (maintains spatial info).\r
+ * We use 'struct _tree' not 'tree' due to a g++ 2.4.3 bug.\r
+ */\r
+#ifdef __cplusplus\r
+struct _tree *(*fpTraverse[NumNodeTypes+1])(... /* Node *, int, set * */) = {\r
+       NULL,\r
+       (struct _tree *(*)(...)) tJunc,\r
+       (struct _tree *(*)(...)) tRuleRef,\r
+       (struct _tree *(*)(...)) tToken,\r
+       (struct _tree *(*)(...)) tAction\r
+};\r
+#else\r
+Tree *(*fpTraverse[NumNodeTypes+1])() = {\r
+       NULL,\r
+       tJunc,\r
+       tRuleRef,\r
+       tToken,\r
+       tAction\r
+};\r
+#endif\r
+\r
+/* fpReach[node type] == pointer to function that calculates FIRST set for\r
+ * that node. (r stands for reach).  We use 'struct _set' not 'set'\r
+ * due to a g++ 2.4.3 bug.\r
+ */\r
+#ifdef __cplusplus\r
+struct _set (*fpReach[NumNodeTypes+1])(... /* Node *, int, set * */) = {\r
+       NULL,\r
+       (struct _set (*)(...)) rJunc,\r
+       (struct _set (*)(...)) rRuleRef,\r
+       (struct _set (*)(...)) rToken,\r
+       (struct _set (*)(...)) rAction\r
+};\r
+#else\r
+set (*fpReach[NumNodeTypes+1])() = {\r
+       NULL,\r
+       rJunc,\r
+       rRuleRef,\r
+       rToken,\r
+       rAction\r
+};\r
+#endif\r
+\r
+/* fpPrint[node type] == pointer to function that knows how to print that node. */\r
+#ifdef __cplusplus\r
+void (*fpPrint[NumNodeTypes+1])(... /* Node * */) = {\r
+       NULL,\r
+       (void (*)(...)) pJunc,\r
+       (void (*)(...)) pRuleRef,\r
+       (void (*)(...)) pToken,\r
+       (void (*)(...)) pAction\r
+};\r
+#else\r
+void (*fpPrint[NumNodeTypes+1])() = {\r
+       NULL,\r
+       pJunc,\r
+       pRuleRef,\r
+       pToken,\r
+       pAction\r
+};\r
+#endif\r
+\r
+char *decodeJType[] = {\r
+       "invalid",\r
+       "aSubBlk",\r
+       "aOptBlk",\r
+       "aLoopBlk",\r
+       "EndBlk",\r
+       "RuleBlk",\r
+       "Generic",\r
+       "EndRule",\r
+       "aPlusBlk",\r
+       "aLoopBegin"\r
+};\r
+\r
+\r
+                                                       /* H a s h  T a b l e s */\r
+\r
+Entry  **Tname,                        /* Table of all token names (maps name to tok num)*/\r
+               **Texpr,                        /* Table of all token expressions\r
+                                                          (maps expr to tok num) */\r
+               **Rname,                        /* Table of all Rules (has ptr to start of rule) */\r
+               **Fcache,                       /* Cache of First/Follow Computations */\r
+               **Tcache;                       /* Tree cache; First/Follow for permute trees */\r
+Entry  **Elabel;                       /* Table of all element label names */\r
+Entry  **Sname;                        /* Signal names */\r
+Entry   **Pname;            /* symbolic predicate names MR11 */\r
+\r
+\r
+                                                       /* V a r i a b l e s */\r
+\r
+int     Save_argc;          /* MR10 */\r
+char    **Save_argv;        /* MR10 */\r
+int            EpToken=0;                      /* Imaginary Epsilon token number */\r
+int            WildCardToken=0;\r
+int            CurFile= -1;            /* Index into FileStr table */\r
+char    *CurPredName=NULL;  /* MR11 */\r
+char   *CurRule=NULL;          /* Pointer to current rule name */\r
+int     CurRuleDebug=0;     /* MR13 debug flag */\r
+RuleEntry *CurRuleNode=NULL;/* Pointer to current rule node in syntax tree */\r
+char   *CurRetDef=NULL;        /* Pointer to current return type definition */\r
+char   *CurParmDef=NULL;       /* Pointer to current parameter definition */\r
+Junction *CurRuleBlk=NULL;     /* Pointer to current block node for enclosing block */\r
+ListNode *CurExGroups=NULL;    /* Current list of exception groups for rule/alts */\r
+ListNode *CurElementLabels=NULL;\r
+ListNode *CurAstLabelsInActions=NULL; /* MR27 */\r
+\r
+/* MR10  used by <<>>? to set "label_used_in_semantic_pred"  */\r
+/* MR10  this will force LT(i) assignment even in guess mode */\r
+\r
+ListNode *CurActionLabels=NULL;     /* MR10 Element Labels appearing in last action */\r
+int      numericActionLabel=0 ;     /* MR10 << ... $1 ... >> or << ... $1 ... >>?   */\r
+ListNode *NumericPredLabels=NULL;   /* MR10 << ... $1 ... >>?  ONLY                 */\r
+ListNode *ContextGuardPredicateList=NULL;  /* MR13 for re-evaluating predicates\r
+                                                   after meta tokens are defined    */\r
+\r
+int            CurBlockID=0;           /* Unique int for each block */\r
+int            CurAltNum=0;\r
+Junction *CurAltStart = NULL;  /* Junction node that starts the alt */\r
+Junction *OuterAltStart = NULL; /* For chaining exception groups        MR7 */\r
+int            NumRules=0;                     /* Rules are from 1 to n */\r
+FILE   *output=NULL;           /* current parser output file */\r
+FILE   *input=NULL;            /* current grammar input file */\r
+char   *FileStr[MaxNumFiles];/* Ptr to array of file names on command-line */\r
+int            NumFiles=0;                     /* current grammar file number */\r
+#ifdef __cplusplus\r
+void   (**fpTrans)(...),       /* array of ptrs to funcs that translate nodes */\r
+               (**fpJTrans)(...);      /*  ... that translate junctions */\r
+#else\r
+void   (**fpTrans)(),          /* array of ptrs to funcs that translate nodes */\r
+               (**fpJTrans)();         /*  ... that translate junctions */\r
+#endif\r
+int            **FoStack;                      /* Array of LL_k ptrs to stacks of rule numbers */\r
+int            **FoTOS;                        /* FOLLOW stack top-of-stack pointers */\r
+Junction *SynDiag = NULL;      /* Pointer to start of syntax diagram */\r
+int            BlkLevel=1;                     /* Current block level.  Set by antlr.g, used by\r
+                                                        * scanner to translate $i.j attributes */\r
+set            reserved_positions;     /* set of token positions reserved by '#token T=i' cmds */\r
+set            all_tokens;                     /* set of all token types */\r
+set            imag_tokens;            /* set of all imaginary token types (EpToken, errclasses...) */\r
+set            tokclasses;                     /* set of all token class token types */\r
+ListNode *ForcedTokens = 0;    /* list of token_id/token_num pairs to remap */\r
+ListNode *MetaTokenNodes=NULL; /* list of meta token refs such as token classes etc... */\r
+int            *TokenInd=NULL;         /* an indirection level between token num and position\r
+                                                        * of that token def in TokenStr and ExprStr */\r
+int            LastTokenCounted=0;     /* ==TokenNum if no token renumbering (same as old TokenNum) */\r
+int            TokenNum=TokenStart;\r
+char   **TokenStr=NULL;        /* map token # to token name */\r
+char   **ExprStr=NULL;         /* map token # to expr */\r
+Junction **RulePtr=NULL;       /* map rule # to RuleBlk node of rule */\r
+ListNode *ExprOrder=NULL;      /* list of exprs as they are found in grammar */\r
+ListNode *BeforeActions=NULL;/* list of grammar actions before rules */\r
+ListNode *AfterActions=NULL;/* list of grammar actions after rules */\r
+ListNode *LexActions=NULL;     /* list of lexical actions */\r
+\r
+/* MR1                                                                                     */\r
+/* MR1  11-Apr-97      Provide mechanism for inserting code into DLG class     */\r
+/* MR1                         via #lexmember <<....>>                             */\r
+/* MR1                         via #lexprefix <<....>>                             */\r
+/* MR1                                                                                     */\r
+\r
+ListNode *LexMemberActions=NULL;/* list of lexical header member decl   MR1 */\r
+ListNode *LexPrefixActions=NULL;/* list of lexical header #include decl MR1 */\r
+ListNode **Cycles=NULL;                /* list of cycles (for each k) found when\r
+                                                          doing FOLLOWs */\r
+ListNode *eclasses=NULL;       /* list of error classes */\r
+ListNode *tclasses=NULL;       /* list of token classes */\r
+LClass  lclass[MaxLexClasses]; /* array of lex class definitions */\r
+int             CurrentLexClass;       /* index into lclass */\r
+int             NumLexClasses=0;       /* in range 1..MaxLexClasses (init 0) */\r
+\r
+char   *HdrAction=NULL;        /* action defined with #header */\r
+char    *FirstAction=NULL;  /* action defined with #first MR11 */\r
+FILE   *ErrFile;                       /* sets and error recovery stuff */\r
+FILE   *DefFile=NULL;          /* list of tokens, return value structs, setwd defs */\r
+FILE    *MRinfoFile=NULL;   /* MR10 information file */\r
+int     MRinfo=0;           /* MR10 */\r
+int     MRinfoSeq=0;        /* MR10 */\r
+int     InfoP=0;            /* MR10 predicates        */\r
+int     InfoT=0;            /* MR10 tnodes            */\r
+int     InfoF=0;            /* MR10 first/follow sets */\r
+int     InfoM=0;            /* MR10 monitor progress  */\r
+int     InfoO=0;            /* MR12 orphan rules      */\r
+int     TnodesInUse=0;      /* MR10 */\r
+int     TnodesPeak=0;       /* MR10 */\r
+int     TnodesAllocated=0;  /* MR10 */\r
+int     TnodesReportThreshold=0;    /* MR11 */\r
+int     PotentialSuppression=0; /* MR10 */\r
+int     PotentialDummy=0;       /* MR10 */\r
+int            CannotContinue=FALSE;\r
+int            OutputLL_k = 1;         /* LL_k for parsing must be power of 2 */\r
+int            action_file;            /* used to track start of action */\r
+int            action_line;\r
+int            FoundGuessBlk=0;        /* there is a (...)? block somewhere in grammar */\r
+int            FoundException=0;       /* there is an exception somewhere in grammar */\r
+/* MR6 Distinguish between @ operator and real exception                   */\r
+/* MR6    by keeping separate flags for @ operator and real exceptions             */\r
+int            FoundAtOperator=0;                                                           /* MR6 */\r
+int            FoundExceptionGroup=0;                                               /* MR6 */\r
+int            pLevel=0;                       /* print Level */\r
+int            pAlt1,pAlt2;            /* print "==>" in front of these alts */\r
+\r
+/* C++ output stuff */\r
+FILE   *Parser_h,                      /* where subclass of ANTLRParser goes */\r
+               *Parser_c;                      /* where code for subclass of ANTLRParser goes */\r
+char   Parser_h_Name[MaxFileName+1] = "";\r
+char   Parser_c_Name[MaxFileName+1] = "";\r
+char    MRinfoFile_Name[MaxFileName+1] = "";                /* MR10 */\r
+char    *ClassDeclStuff=NULL;                               /* MR10 */\r
+char    *BaseClassName=NULL;                                /* MR22 */\r
+/* list of actions inside the #class {...} defs */\r
+ListNode *class_before_actions=NULL;\r
+ListNode *class_after_actions=NULL;\r
+\r
+char   CurrentClassName[MaxRuleName]="";\r
+int            no_classes_found=1;\r
+char   *UserTokenDefsFile;\r
+int            UserDefdTokens=0;       /* found #tokdefs? */\r
+char   *OutputDirectory=TopDirectory;\r
+ExceptionGroup *DefaultExGroup = NULL;\r
+int            NumSignals = NumPredefinedSignals;\r
+int            ContextGuardTRAV=0;\r
+\r
+char    *MR_AmbAidRule=NULL;        /* MR11 */\r
+int     MR_AmbAidLine=0;            /* MR11 */\r
+int     MR_AmbAidDepth=0;           /* MR11 */\r
+int     MR_AmbAidMultiple=0;        /* MR11 */\r
+int     MR_skipped_e3_report=0;     /* MR11 */\r
+int     MR_usingPredNames=0;        /* MR11 */\r
+int     MR_BadExprSets=0;           /* MR13 */\r
+int     MR_Inhibit_Tokens_h_Gen=0;  /* MR13 */\r
+int     NewAST=0;                   /* MR13 */\r
+int            tmakeInParser=0;            /* MR23 */\r
+int     AlphaBetaTrace=0;           /* MR14 */\r
+int            MR_BlkErr=0;                            /* MR21 */\r
+int     MR_AlphaBetaMessageCount=0; /* MR14 */\r
+int     MR_AlphaBetaWarning=0;      /* MR14 */\r
+int     MR_ErrorSetComputationActive=0;     /* MR14 */\r
+int     MR_MaintainBackTrace=0;             /* MR14 */\r
+set     MR_CompromisedRules;        /* MR14 */\r
+\r
+Junction    *MR_RuleBlkWithHalt;    /* MR10 */\r
+\r
+                                       /* C m d - L i n e  O p t i o n s */\r
+\r
+int            LL_k=1;                         /* how many tokens of full lookahead */\r
+int            CLL_k= -1;                      /* how many tokens of compressed lookahead */\r
+int            PrintOut = FALSE;       /* print out the grammar */\r
+int            PrintAnnotate = FALSE;/* annotate printout with FIRST sets */\r
+int            CodeGen=TRUE;           /* Generate output code? */\r
+int            LexGen=TRUE;            /* Generate lexical files? (tokens.h, parser.dlg) */\r
+int            GenAST=FALSE;           /* Generate AST's? */\r
+int            GenANSI=FALSE;          /* Generate ANSI code where necessary */\r
+int            GenExprSetsOpt=TRUE;/* use sets not (LA(1)==tok) expression lists */\r
+int            GenCR=FALSE;            /* Generate cross reference? */\r
+int            GenLineInfo=FALSE;      /* Generate # line "file" stuff? */\r
+int            GenLineInfoMS=FALSE;/* Like -gl but replace "\" with "/" for MS C/C++ systems */\r
+int            TraceGen=FALSE;         /* Generate code to trace rule invocation */\r
+int            elevel=1;                       /* error level for ambiguity messages */\r
+int            GenEClasseForRules=0;/* don't generate eclass for each rule */\r
+int            TreeResourceLimit= -1;/* don't limit tree resource */\r
+int            DemandLookahead = 0;/* demand/delayed lookahead or not */\r
+char   *RulePrefix = "";       /* prefix each generated rule with this */\r
+char   *stdpccts = "stdpccts.h";/* where to generate std pccts include file */\r
+int            GenStdPccts = 0;        /* don't gen stdpccts.h? */\r
+int            ParseWithPredicates = 1;\r
+int            WarningLevel = 1;\r
+int            UseStdout = 0;                                  /* MR6 */\r
+int            TabWidth = 2;                                   /* MR6 */ /* MR27 */\r
+int            HoistPredicateContext = 0;\r
+int     MRhoisting = 0;                 /* MR9 */\r
+int     MRhoistingk = 0;                /* MR13 */\r
+int     MR_debugGenRule=0;              /* MR11 */\r
+\r
+int            GenCC = 0;                      /* Generate C++ output */\r
+\r
+PointerStack MR_BackTraceStack={0,0,NULL};            /* MR10 */\r
+PointerStack MR_PredRuleRefStack={0,0,NULL};          /* MR10 */\r
+PointerStack MR_RuleBlkWithHaltStack={0,0,NULL};      /* MR10 */\r
+\r
+/* DontCopyTokens and Pragma_DupLabeledTokens were a bad idea.  I've just\r
+   turned them off rather than backpatching the code.  Who knows?  We\r
+   may need them in the future.\r
+ */\r
+int            DontCopyTokens = 1;     /* in C++, don't copy ANTLRToken passed to ANTLR */\r
+\r
+/* Remember if LT(i), LA(i), or LATEXT(i) used in an action which is not\r
+   a predicate.  If so, give a warning for novice users.\r
+*/\r
+\r
+int     LTinTokenAction = 0; /* MR23 */\r
+int     PURIFY = 1;          /* MR23 */\r
+\r
+int     CurBlockID_array[MAX_BLK_LEVEL]; /* MR23 */\r
+int     CurAltNum_array[MAX_BLK_LEVEL]; /* MR23 */\r
diff --git a/Tools/CodeTools/Source/Pccts/antlr/hash.c b/Tools/CodeTools/Source/Pccts/antlr/hash.c
new file mode 100644 (file)
index 0000000..68fe8fd
--- /dev/null
@@ -0,0 +1,221 @@
+/*\r
+ * hash.c\r
+ *\r
+ * Manage hash tables.\r
+ *\r
+ * The following functions are visible:\r
+ *\r
+ *             char    *mystrdup(char *);              Make space and copy string\r
+ *             Entry   **newHashTable();               Create and return initialized hash table\r
+ *             Entry   *hash_add(Entry **, char *, Entry *)\r
+ *             Entry   *hash_get(Entry **, char *)\r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
+ * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
+ * company may do whatever they wish with source code distributed with\r
+ * PCCTS or the code generated by PCCTS, including the incorporation of\r
+ * PCCTS, or its output, into commerical software.\r
+ *\r
+ * We encourage users to develop software with PCCTS.  However, we do ask\r
+ * that credit is given to us for developing PCCTS.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like PCCTS and have developed a nice tool with the\r
+ * output, please mention that you developed it using PCCTS.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * ANTLR 1.33\r
+ * Terence Parr\r
+ * Parr Research Corporation\r
+ * with Purdue University and AHPCRC, University of Minnesota\r
+ * 1989-2001\r
+ */\r
+\r
+#include <stdio.h>\r
+#include "pcctscfg.h"\r
+#include "hash.h"\r
+\r
+#ifdef __USE_PROTOS\r
+#include <stdlib.h>\r
+#else\r
+#ifdef VAXC\r
+#include <stdlib.h>\r
+#else\r
+#include <malloc.h>\r
+#endif\r
+#endif\r
+#include <string.h>\r
+\r
+#define StrSame                0\r
+\r
+#define fatal(err)                                                                                                                     \\r
+                       {fprintf(stderr, "%s(%d):", __FILE__, __LINE__);                                \\r
+                       fprintf(stderr, " %s\n", err); exit(PCCTS_EXIT_FAILURE);}\r
+#define require(expr, err) {if ( !(expr) ) fatal(err);}\r
+\r
+static unsigned size = HashTableSize;\r
+static char *strings = NULL;\r
+static char *strp;\r
+static unsigned strsize = StrTableSize;\r
+\r
+/* create the hash table and string table for terminals (string table only once) */\r
+Entry **\r
+#ifdef __USE_PROTOS\r
+newHashTable( void )\r
+#else\r
+newHashTable( )\r
+#endif\r
+{\r
+       Entry **table;\r
+       \r
+       table = (Entry **) calloc(size, sizeof(Entry *));\r
+       require( table != NULL, "cannot allocate hash table");\r
+       if ( strings == NULL )\r
+       {\r
+               strings = (char *) calloc(strsize, sizeof(char));\r
+               require( strings != NULL, "cannot allocate string table");\r
+               strp = strings;\r
+       }\r
+       return table;\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+killHashTable( Entry **table )\r
+#else\r
+killHashTable( table )\r
+Entry **table;\r
+#endif\r
+{\r
+       /* for now, just free table, forget entries */\r
+       free( (char *) table );     /* MR10 cast */\r
+}\r
+\r
+/* Given a table, add 'rec' with key 'key' (add to front of list). return ptr to entry */\r
+Entry *\r
+#ifdef __USE_PROTOS\r
+hash_add( Entry **table, char *key, Entry *rec )\r
+#else\r
+hash_add( table, key, rec )\r
+Entry **table;\r
+char *key;\r
+Entry *rec;\r
+#endif\r
+{\r
+       unsigned h=0;\r
+       char *p=key;\r
+       require(table!=NULL && key!=NULL && rec!=NULL, "add: invalid addition");\r
+       \r
+       Hash(p,h,size);\r
+       rec->next = table[h];                   /* Add to singly-linked list */\r
+       table[h] = rec;\r
+       return rec;\r
+}\r
+\r
+/* Return ptr to 1st entry found in table under key (return NULL if none found) */\r
+Entry *\r
+#ifdef __USE_PROTOS\r
+hash_get( Entry **table, char *key )\r
+#else\r
+hash_get( table, key )\r
+Entry **table;\r
+char *key;\r
+#endif\r
+{\r
+       unsigned h=0;\r
+       char *p=key;\r
+       Entry *q;\r
+/*     require(table!=NULL && key!=NULL, "get: invalid table and/or key");*/\r
+       if ( !(table!=NULL && key!=NULL) ) *((char *) 34) = 3;\r
+       \r
+       Hash(p,h,size);\r
+       for (q = table[h]; q != NULL; q = q->next)\r
+       {\r
+               if ( strcmp(key, q->str) == StrSame ) return( q );\r
+       }\r
+       return( NULL );\r
+}\r
+\r
+#ifdef DEBUG_HASH\r
+void\r
+#ifdef __USE_PROTOS\r
+hashStat( Entry **table )\r
+#else\r
+hashStat( table )\r
+Entry **table;\r
+#endif\r
+{\r
+       static unsigned short count[20];\r
+       int i,n=0,low=0, hi=0;\r
+       Entry **p;\r
+       float avg=0.0;\r
+       \r
+       for (i=0; i<20; i++) count[i] = 0;\r
+       for (p=table; p<&(table[size]); p++)\r
+       {\r
+               Entry *q = *p;\r
+               int len;\r
+               \r
+               if ( q != NULL && low==0 ) low = p-table;\r
+               len = 0;\r
+               if ( q != NULL ) fprintf(stderr, "[%d]", p-table);\r
+               while ( q != NULL )\r
+               {\r
+                       len++;\r
+                       n++;\r
+                       fprintf(stderr, " %s", q->str);\r
+                       q = q->next;\r
+                       if ( q == NULL ) fprintf(stderr, "\n");\r
+               }\r
+               count[len]++;\r
+               if ( *p != NULL ) hi = p-table;\r
+       }\r
+\r
+       fprintf(stderr, "Storing %d recs used %d hash positions out of %d\n",\r
+                                       n, size-count[0], size);\r
+       fprintf(stderr, "%f %% utilization\n",\r
+                                       ((float)(size-count[0]))/((float)size));\r
+       for (i=0; i<20; i++)\r
+       {\r
+               if ( count[i] != 0 )\r
+               {\r
+                       avg += (((float)(i*count[i]))/((float)n)) * i;\r
+                       fprintf(stderr, "Bucket len %d == %d (%f %% of recs)\n",\r
+                                                       i, count[i], ((float)(i*count[i]))/((float)n));\r
+               }\r
+       }\r
+       fprintf(stderr, "Avg bucket length %f\n", avg);\r
+       fprintf(stderr, "Range of hash function: %d..%d\n", low, hi);\r
+}\r
+#endif\r
+\r
+/* Add a string to the string table and return a pointer to it.\r
+ * Bump the pointer into the string table to next avail position.\r
+ */\r
+char *\r
+#ifdef __USE_PROTOS\r
+mystrdup( char *s )\r
+#else\r
+mystrdup( s )\r
+char *s;\r
+#endif\r
+{\r
+       char *start=strp;\r
+       require(s!=NULL, "mystrdup: NULL string");\r
+\r
+       while ( *s != '\0' )\r
+       {\r
+               require( strp <= &(strings[strsize-2]),\r
+                                "string table overflow\nIncrease StrTableSize in hash.h and recompile hash.c\n");\r
+               *strp++ = *s++;\r
+       }\r
+       *strp++ = '\0';\r
+\r
+       return( start );\r
+}\r
diff --git a/Tools/CodeTools/Source/Pccts/antlr/hash.h b/Tools/CodeTools/Source/Pccts/antlr/hash.h
new file mode 100644 (file)
index 0000000..3969c40
--- /dev/null
@@ -0,0 +1,73 @@
+/*\r
+ * hash.h -- define hash table entries, sizes, hash function...\r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
+ * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
+ * company may do whatever they wish with source code distributed with\r
+ * PCCTS or the code generated by PCCTS, including the incorporation of\r
+ * PCCTS, or its output, into commerical software.\r
+ *\r
+ * We encourage users to develop software with PCCTS.  However, we do ask\r
+ * that credit is given to us for developing PCCTS.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like PCCTS and have developed a nice tool with the\r
+ * output, please mention that you developed it using PCCTS.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * ANTLR 1.33\r
+ * Terence Parr\r
+ * Parr Research Corporation\r
+ * with Purdue University and AHPCRC, University of Minnesota\r
+ * 1989-2001\r
+ */\r
+\r
+                               /* H a s h  T a b l e  S t u f f */\r
+\r
+#ifndef HashTableSize\r
+#define HashTableSize  553\r
+#endif\r
+\r
+#ifndef StrTableSize\r
+#ifdef PC32\r
+#define StrTableSize   1000000\r
+#endif\r
+#endif\r
+\r
+#ifndef StrTableSize\r
+#ifdef PC\r
+#define StrTableSize 655200\r
+#endif\r
+#endif\r
+\r
+#ifndef StrTableSize\r
+#define StrTableSize 1000000\r
+#endif\r
+\r
+typedef struct _entry {                /* Minimum hash table entry -- superclass */\r
+                       char *str;\r
+                       struct _entry *next;\r
+               } Entry;\r
+\r
+/* Hash 's' using 'size', place into h (s is modified) */\r
+#define Hash(s,h,size)                                                         \\r
+       {while ( *s != '\0' ) h = (h<<1) + *s++;                \\r
+       h %= size;}\r
+\r
+#ifdef __USE_PROTOS\r
+Entry  *hash_get(Entry **, char *),\r
+               **newHashTable(void),\r
+               *hash_add(Entry **, char *, Entry *);\r
+\r
+void   killHashTable(Entry **);\r
+\r
+#else\r
+Entry *hash_get(), **newHashTable(), *hash_add();\r
+void   killHashTable();        /* MR9 23-Sep-97 */\r
+#endif\r
diff --git a/Tools/CodeTools/Source/Pccts/antlr/lex.c b/Tools/CodeTools/Source/Pccts/antlr/lex.c
new file mode 100644 (file)
index 0000000..8c524fe
--- /dev/null
@@ -0,0 +1,878 @@
+/*\r
+ * lex.c       --      Generate all of the lexical type files: parser.dlg tokens.h\r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
+ * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
+ * company may do whatever they wish with source code distributed with\r
+ * PCCTS or the code generated by PCCTS, including the incorporation of\r
+ * PCCTS, or its output, into commerical software.\r
+ *\r
+ * We encourage users to develop software with PCCTS.  However, we do ask\r
+ * that credit is given to us for developing PCCTS.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like PCCTS and have developed a nice tool with the\r
+ * output, please mention that you developed it using PCCTS.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * ANTLR 1.33\r
+ * Terence Parr\r
+ * Parr Research Corporation\r
+ * with Purdue University and AHPCRC, University of Minnesota\r
+ * 1989-2001\r
+ */\r
+\r
+#include <stdio.h>\r
+#include <ctype.h>\r
+/* MR1                                                                                         */\r
+/* MR1  10-Apr-97  MR1 Replace use of __STDC__ with __USE_PROTOS           */\r
+/* MR1                                                                                 */\r
+#include "pcctscfg.h"\r
+#include "set.h"\r
+#include "syn.h"\r
+#include "hash.h"\r
+#include "generic.h"\r
+\r
+#define DLGErrorString "invalid token"\r
+\r
+/* Generate a complete lexical description of the lexemes found in the grammar */\r
+void\r
+#ifdef __USE_PROTOS\r
+genLexDescr( void )\r
+#else\r
+genLexDescr( )\r
+#endif\r
+{\r
+       ListNode *p;\r
+       FILE *dlgFile = fopen(OutMetaName(DlgFileName), "w");\r
+       require(dlgFile!=NULL, eMsg1("genLexFile: cannot open %s", OutMetaName(DlgFileName)) );\r
+#ifdef SPECIAL_FOPEN\r
+       special_fopen_actions(OutMetaName(DlgFileName));                     /* MR1 */\r
+#endif\r
+       fprintf(dlgFile, "<<\n");\r
+       fprintf(dlgFile, "/* %s -- DLG Description of scanner\n", DlgFileName);\r
+       fprintf(dlgFile, " *\n");\r
+       fprintf(dlgFile, " * Generated from:");\r
+       {int i; for (i=0; i<NumFiles; i++) fprintf(dlgFile, " %s", FileStr[i]);}\r
+       fprintf(dlgFile, "\n");\r
+       fprintf(dlgFile, " *\n");\r
+       fprintf(dlgFile, " * Terence Parr, Will Cohen, and Hank Dietz: 1989-2001\n");\r
+       fprintf(dlgFile, " * Purdue University Electrical Engineering\n");\r
+       fprintf(dlgFile, " * With AHPCRC, University of Minnesota\n");\r
+       fprintf(dlgFile, " * ANTLR Version %s\n", Version);\r
+       fprintf(dlgFile, " */\n\n");\r
+    if (FirstAction != NULL ) dumpAction( FirstAction, dlgFile, 0, -1, 0, 1 );  /* MR11 MR15b */\r
+    fprintf(dlgFile, "#define ANTLR_VERSION    %s\n", VersionDef);\r
+       if ( GenCC )\r
+       {\r
+               if ( !UserDefdTokens ) fprintf(dlgFile, "#include \"%s\"\n", DefFileName);\r
+               else fprintf(dlgFile, "#include %s\n", UserTokenDefsFile);\r
+               fprintf(dlgFile, "#include \"%s\"\n", ATOKEN_H);\r
+               if ( GenAST ) fprintf(dlgFile, "#include \"%s\"\n", ASTBASE_H);\r
+               if ( HdrAction != NULL ) dumpAction( HdrAction, dlgFile, 0, -1, 0, 1 );\r
+       }\r
+       else\r
+       {\r
+               fprintf(dlgFile, "#include \"pcctscfg.h\"\n");\r
+               fprintf(dlgFile, "#include \"pccts_stdio.h\"\n");\r
+               if ( strcmp(ParserName, DefaultParserName)!=0 )\r
+                       fprintf(dlgFile, "#define %s %s\n", DefaultParserName, ParserName);\r
+               if ( strcmp(ParserName, DefaultParserName)!=0 )\r
+                       fprintf(dlgFile, "#include \"%s\"\n", RemapFileName);\r
+               if ( HdrAction != NULL ) dumpAction( HdrAction, dlgFile, 0, -1, 0, 1 );\r
+               if ( FoundGuessBlk )\r
+               {\r
+                       fprintf(dlgFile, "#define ZZCAN_GUESS\n");\r
+                       fprintf(dlgFile, "#include \"pccts_setjmp.h\"\n");\r
+               }\r
+               if ( OutputLL_k > 1 ) fprintf(dlgFile, "#define LL_K %d\n", OutputLL_k);\r
+               if ( DemandLookahead ) fprintf(dlgFile, "#define DEMAND_LOOK\n");\r
+        if (TraceGen) {\r
+          fprintf(dlgFile,"#ifndef zzTRACE_RULES\n");  /* MR20 */\r
+          fprintf(dlgFile,"#define zzTRACE_RULES\n");  /* MR20 */\r
+          fprintf(dlgFile,"#endif\n");  /* MR22 */\r
+        };\r
+               fprintf(dlgFile, "#include \"antlr.h\"\n");\r
+               if ( GenAST ) {\r
+                       fprintf(dlgFile, "#include \"ast.h\"\n");\r
+               }\r
+               if ( UserDefdTokens )\r
+                       fprintf(dlgFile, "#include %s\n", UserTokenDefsFile);\r
+               /* still need this one as it has the func prototypes */\r
+               fprintf(dlgFile, "#include \"%s\"\n", DefFileName);\r
+               fprintf(dlgFile, "#include \"dlgdef.h\"\n");\r
+               fprintf(dlgFile, "LOOKAHEAD\n");\r
+               fprintf(dlgFile, "\n");\r
+               fprintf(dlgFile, "void\n");\r
+               fprintf(dlgFile, "#ifdef __USE_PROTOS\n");\r
+               fprintf(dlgFile, "zzerraction(void)\n");\r
+               fprintf(dlgFile, "#else\n");\r
+               fprintf(dlgFile, "zzerraction()\n");\r
+               fprintf(dlgFile, "#endif\n");\r
+               fprintf(dlgFile, "{\n");\r
+               fprintf(dlgFile, "\t(*zzerr)(\"%s\");\n", DLGErrorString);\r
+               fprintf(dlgFile, "\tzzadvance();\n");\r
+               fprintf(dlgFile, "\tzzskip();\n");\r
+               fprintf(dlgFile, "}\n");\r
+       }\r
+       fprintf(dlgFile, ">>\n\n");\r
+\r
+       /* dump all actions */\r
+\r
+/* MR1                                                                                                     */\r
+/* MR1  11-Apr-97      Provide mechanism for inserting code into DLG class     */\r
+/* MR1                   via <<%%lexmember ....>> & <<%%lexprefix ...>>            */\r
+/* MR1                                                                                     */\r
+          if (LexActions != NULL) {\r
+            for (p = LexActions->next; p!=NULL; p=p->next)\r
+               {\r
+/* MR1 */      fprintf(dlgFile, "<<%%%%lexaction\n");\r
+                       dumpAction( (char *)p->elem, dlgFile, 0, -1, 0, 1 );\r
+                       fprintf(dlgFile, ">>\n\n");\r
+               }\r
+         };\r
+\r
+/* MR1 */ if (GenCC) {\r
+/* MR1 */   fprintf(dlgFile,"<<%%%%parserclass %s>>\n\n",CurrentClassName);\r
+/* MR1 */ };\r
+\r
+/* MR1 */ if (LexPrefixActions != NULL) {\r
+/* MR1 */   for (p = LexPrefixActions->next; p!=NULL; p=p->next)\r
+/* MR1 */       {\r
+/* MR1 */               fprintf(dlgFile, "<<%%%%lexprefix\n");\r
+/* MR1 */               dumpAction( (char *)p->elem, dlgFile, 0, -1, 0, 1 );\r
+/* MR1 */               fprintf(dlgFile, ">>\n\n");\r
+/* MR1 */       }\r
+/* MR1 */ };\r
+\r
+/* MR1 */ if (LexMemberActions != NULL) {\r
+/* MR1 */   for (p = LexMemberActions->next; p!=NULL; p=p->next)\r
+/* MR1 */       {\r
+/* MR1 */               fprintf(dlgFile, "<<%%%%lexmember\n");\r
+/* MR1 */               dumpAction( (char *)p->elem, dlgFile, 0, -1, 0, 1 );\r
+/* MR1 */               fprintf(dlgFile, ">>\n\n");\r
+/* MR1 */       }\r
+/* MR1 */ };\r
+\r
+       /* dump all regular expression rules/actions (skip sentinel node) */\r
+       if ( ExprOrder == NULL ) {\r
+               warnNoFL("no regular expressions found in grammar");\r
+       }\r
+       else dumpLexClasses(dlgFile);\r
+       fprintf(dlgFile, "%%%%\n");\r
+       fclose( dlgFile );\r
+}\r
+\r
+/* For each lexical class, scan ExprOrder looking for expressions\r
+ * in that lexical class.  Print out only those that match.\r
+ * Each element of the ExprOrder list has both an expr and an lclass\r
+ * field.\r
+ */\r
+void\r
+#ifdef __USE_PROTOS\r
+dumpLexClasses( FILE *dlgFile )\r
+#else\r
+dumpLexClasses( dlgFile )\r
+FILE *dlgFile;\r
+#endif\r
+{\r
+       int i;\r
+       TermEntry *t;\r
+       ListNode *p;\r
+       Expr *q;\r
+\r
+       for (i=0; i<NumLexClasses; i++)\r
+       {\r
+               fprintf(dlgFile, "\n%%%%%s\n\n", lclass[i].classnum);\r
+               for (p=ExprOrder->next; p!=NULL; p=p->next)\r
+               {\r
+                       q = (Expr *) p->elem;\r
+                       if ( q->lclass != i ) continue;\r
+                       lexmode(i);\r
+                       t = (TermEntry *) hash_get(Texpr, q->expr);\r
+                       require(t!=NULL, eMsg1("genLexDescr: rexpr %s not in hash table",q->expr) );\r
+                       if ( t->token == EpToken ) continue;\r
+                       fprintf(dlgFile, "%s\n\t<<\n", StripQuotes(q->expr));\r
+                       /* replace " killed by StripQuotes() */\r
+                       q->expr[ strlen(q->expr) ] = '"';\r
+                       if ( !GenCC ) {\r
+                               if ( TokenString(t->token) != NULL )\r
+                                       fprintf(dlgFile, "\t\tNLA = %s;\n", TokenString(t->token));\r
+                               else\r
+                                       fprintf(dlgFile, "\t\tNLA = %d;\n", t->token);\r
+                       }\r
+                       if ( t->action != NULL ) dumpAction( t->action, dlgFile, 2,-1,0,1 );\r
+                       if ( GenCC ) {\r
+                               if ( TokenString(t->token) != NULL )\r
+                                       fprintf(dlgFile, "\t\treturn %s;\n", TokenString(t->token));\r
+                               else\r
+                                       fprintf(dlgFile, "\t\treturn (ANTLRTokenType)%d;\n", t->token);\r
+                       }\r
+                       fprintf(dlgFile, "\t>>\n\n");\r
+               }\r
+       }\r
+}\r
+\r
+/* Strip the leading path (if any) from a filename */\r
+char *\r
+#ifdef __USE_PROTOS\r
+StripPath( char *fileName )\r
+#else\r
+StripPath( fileName )\r
+char *fileName;\r
+#endif\r
+{\r
+       char *p;\r
+       static char dirSym[2] = DirectorySymbol;\r
+\r
+       if(NULL != (p = strrchr(fileName, dirSym[0])))\r
+               p++;\r
+       else\r
+               p = fileName;\r
+\r
+       return(p);\r
+}\r
+\r
+/* Generate a list of #defines && list of struct definitions for\r
+ * aggregate retv's */\r
+void\r
+#ifdef __USE_PROTOS\r
+genDefFile( void )\r
+#else\r
+genDefFile( )\r
+#endif\r
+{\r
+       int i;\r
+\r
+       /* If C++ mode and #tokdef used, then don't need anything in here since\r
+        * C++ puts all definitions in the class file name.\r
+        */\r
+       if ( GenCC && UserTokenDefsFile ) return;\r
+    if ( MR_Inhibit_Tokens_h_Gen) return;\r
+\r
+       DefFile = fopen(OutMetaName(DefFileName), "w");\r
+       require(DefFile!=NULL, eMsg1("genDefFile: cannot open %s", OutMetaName(DefFileName)) );\r
+#ifdef SPECIAL_FOPEN\r
+       special_fopen_actions(OutMetaName(DefFileName));                     /* MR1 */\r
+#endif\r
+       fprintf(DefFile, "#ifndef %s\n", StripPath(gate_symbol(DefFileName)));\r
+       fprintf(DefFile, "#define %s\n", StripPath(gate_symbol(DefFileName)));\r
+\r
+       fprintf(DefFile, "/* %s -- List of labelled tokens and stuff\n", DefFileName);\r
+       fprintf(DefFile, " *\n");\r
+       fprintf(DefFile, " * Generated from:");\r
+       for (i=0; i<NumFiles; i++) fprintf(DefFile, " %s", FileStr[i]);\r
+       fprintf(DefFile, "\n");\r
+       fprintf(DefFile, " *\n");\r
+       fprintf(DefFile, " * Terence Parr, Will Cohen, and Hank Dietz: 1989-2001\n");\r
+       fprintf(DefFile, " * Purdue University Electrical Engineering\n");\r
+       fprintf(DefFile, " * ANTLR Version %s\n", Version);\r
+       fprintf(DefFile, " */\n");\r
+\r
+       if ( !GenCC && LexGen ) {\r
+               fprintf(DefFile,"#define zzEOF_TOKEN %d\n",\r
+                               TokenInd!=NULL?TokenInd[EofToken]:EofToken);\r
+       }\r
+\r
+       if ( !UserDefdTokens )\r
+       {\r
+               int first=1;\r
+\r
+               if ( GenCC ) fprintf(DefFile, "enum ANTLRTokenType {\n");\r
+               for (i=1; i<TokenNum; i++)\r
+               {\r
+                       /* Don't do EpToken or expr w/o labels */\r
+                       if ( TokenString(i)!=NULL && i != EpToken )\r
+                       {\r
+                               TermEntry *p;\r
+                               \r
+                               if ( WarningLevel>1 )\r
+                               {\r
+                                       int j;\r
+                                       /* look in all lexclasses for the reg expr */\r
+\r
+/* MR10  Derek Pappas                                                */\r
+/* MR10     A #tokclass doesn't have associated regular expressiones */\r
+/* MR10        so don't warn user about it's omission                */\r
+\r
+                    p = (TermEntry *) hash_get(Tname, TokenString(i));\r
+\r
+                    if (p != NULL && ! p->classname) {\r
+                                       for (j=0; j<NumLexClasses; j++)\r
+                                       {\r
+                                               lexmode(j);\r
+                                               if ( ExprString(i)!=NULL ) break;\r
+                                       }\r
+                                       if ( j>=NumLexClasses )\r
+                                       {\r
+                                               warnNoFL(eMsg1("token label has no associated rexpr: %s",TokenString(i)));\r
+                                       }\r
+                    };\r
+                               }\r
+                               require((p=(TermEntry *)hash_get(Tname, TokenString(i))) != NULL,\r
+                                               "token not in sym tab when it should be");\r
+                               if ( !p->classname )\r
+                               {\r
+                                       if ( GenCC ) {\r
+                                               if ( !first ) fprintf(DefFile, ",\n");\r
+                                               first = 0;\r
+                                               fprintf(DefFile, "\t%s=%d", TokenString(i), i);\r
+                                       }\r
+                                       else\r
+                                               fprintf(DefFile, "#define %s %d\n", TokenString(i), i);\r
+                               }\r
+                       }\r
+               }\r
+/* MR1                                                                                                     */\r
+/* MR1  10-Apr-97 133MR1       Prevent use of varying sizes of integer     */\r
+/* MR1                         for the enum ANTLRTokenType                             */\r
+/* MR1                                                                    */\r
+               if ( GenCC ) {                                                           /* MR1 */\r
+                        if ( !first ) fprintf(DefFile, ",\n");                  /* MR14 */\r
+                    fprintf(DefFile, "\tDLGminToken=0");                 /* MR1 */\r
+                    fprintf(DefFile, ",\n\tDLGmaxToken=9999};\n");          /* MR1 */\r
+                };                                                                          /* MR1 */\r
+       }\r
+\r
+       if ( !GenCC ) GenRulePrototypes(DefFile, SynDiag);\r
+\r
+       fprintf(DefFile, "\n#endif\n");\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+GenRemapFile( void )\r
+#else\r
+GenRemapFile( )\r
+#endif\r
+{\r
+       if ( strcmp(ParserName, DefaultParserName)!=0 )\r
+       {\r
+               FILE *f;\r
+               int i;\r
+\r
+               f = fopen(OutMetaName(RemapFileName), "w");\r
+               require(f!=NULL, eMsg1("GenRemapFile: cannot open %s", OutMetaName(RemapFileName)) );\r
+#ifdef SPECIAL_FOPEN\r
+               special_fopen_actions(OutMetaName(RemapFileName));           /* MR1 */\r
+#endif\r
+               fprintf(f, "/* %s -- List of symbols to remap\n", RemapFileName);\r
+               fprintf(f, " *\n");\r
+               fprintf(f, " * Generated from:");\r
+               for (i=0; i<NumFiles; i++) fprintf(f, " %s", FileStr[i]);\r
+               fprintf(f, "\n");\r
+               fprintf(f, " *\n");\r
+               fprintf(f, " * Terence Parr, Will Cohen, and Hank Dietz: 1989-2001\n");\r
+               fprintf(f, " * Purdue University Electrical Engineering\n");\r
+               fprintf(f, " * ANTLR Version %s\n", Version);\r
+               fprintf(f, " */\n");\r
+\r
+               GenRuleFuncRedefs(f, SynDiag);\r
+               GenPredefinedSymbolRedefs(f);\r
+               if ( GenAST ) GenASTSymbolRedefs(f);\r
+               GenSetRedefs(f);\r
+\r
+               fclose(f);\r
+       }\r
+}\r
+\r
+/* Generate a bunch of #defines that rename all functions to be "ParserName_func" */\r
+void\r
+#ifdef __USE_PROTOS\r
+GenRuleFuncRedefs( FILE *f, Junction *p )\r
+#else\r
+GenRuleFuncRedefs( f, p )\r
+FILE *f;\r
+Junction *p;\r
+#endif\r
+{\r
+       fprintf(f, "\n/* rename rule functions to be 'ParserName_func' */\n");\r
+       while ( p!=NULL )\r
+       {\r
+               fprintf(f, "#define %s %s_%s\n", p->rname, ParserName, p->rname);\r
+               p = (Junction *)p->p2;\r
+       }\r
+}\r
+\r
+/* Generate a bunch of #defines that rename all standard symbols to be\r
+ * "ParserName_symbol".  The list of standard symbols to change is in\r
+ * globals.c.\r
+ */\r
+void\r
+#ifdef __USE_PROTOS\r
+GenPredefinedSymbolRedefs( FILE *f )\r
+#else\r
+GenPredefinedSymbolRedefs( f )\r
+FILE *f;\r
+#endif\r
+{\r
+       char **p;\r
+\r
+       fprintf(f, "\n/* rename PCCTS-supplied symbols to be 'ParserName_symbol' */\n");\r
+       for (p = &StandardSymbols[0]; *p!=NULL; p++)\r
+       {\r
+               fprintf(f, "#define %s %s_%s\n", *p, ParserName, *p);\r
+       }\r
+}\r
+\r
+/* Generate a bunch of #defines that rename all AST symbols to be\r
+ * "ParserName_symbol".  The list of AST symbols to change is in\r
+ * globals.c.\r
+ */\r
+void\r
+#ifdef __USE_PROTOS\r
+GenASTSymbolRedefs( FILE *f )\r
+#else\r
+GenASTSymbolRedefs( f )\r
+FILE *f;\r
+#endif\r
+{\r
+       char **p;\r
+\r
+       fprintf(f, "\n/* rename PCCTS-supplied AST symbols to be 'ParserName_symbol' */\n");\r
+       for (p = &ASTSymbols[0]; *p!=NULL; p++)\r
+       {\r
+               fprintf(f, "#define %s %s_%s\n", *p, ParserName, *p);\r
+       }\r
+}\r
+\r
+/* redefine all sets generated by ANTLR; WARNING:  'zzerr', 'setwd' must match\r
+ * use in bits.c (DumpSetWd() etc...)\r
+ */\r
+void\r
+#ifdef __USE_PROTOS\r
+GenSetRedefs( FILE *f )\r
+#else\r
+GenSetRedefs( f )\r
+FILE *f;\r
+#endif\r
+{\r
+       int i;\r
+\r
+       for (i=1; i<=wordnum; i++)\r
+       {\r
+               fprintf(f, "#define setwd%d %s_setwd%d\n", i, ParserName, i);\r
+       }\r
+       for (i=1; i<=esetnum; i++)\r
+       {\r
+               fprintf(f, "#define zzerr%d %s_err%d\n", i, ParserName, i);\r
+       }\r
+}\r
+\r
+/* Find all return types/parameters that require structs and def\r
+ * all rules with ret types.\r
+ *\r
+ * This is for the declaration, not the definition.\r
+ */\r
+void\r
+#ifdef __USE_PROTOS\r
+GenRulePrototypes( FILE *f, Junction *p )\r
+#else\r
+GenRulePrototypes( f, p )\r
+FILE *f;\r
+Junction *p;\r
+#endif\r
+{\r
+       int i;\r
+\r
+       i = 1;\r
+       while ( p!=NULL )\r
+       {\r
+               if ( p->ret != NULL )\r
+               {\r
+/* MR23 */     if ( hasMultipleOperands(p->ret) )\r
+                       {\r
+                               DumpRetValStruct(f, p->ret, i);\r
+                       }\r
+                       fprintf(f, "\n#ifdef __USE_PROTOS\n");\r
+/* MR23 */     if ( hasMultipleOperands(p->ret) ) \r
+                       {\r
+                               fprintf(f, "extern struct _rv%d", i);\r
+                       }\r
+                       else\r
+                       {\r
+                               fprintf(f, "extern ");\r
+                               DumpType(p->ret, f);\r
+                       }\r
+                       fprintf(f, " %s%s(", RulePrefix, p->rname);\r
+                       DumpANSIFunctionArgDef(f,p,1 /* emit initializers ? */);\r
+                       fprintf(f, ";\n");\r
+                       fprintf(f, "#else\n");\r
+/* MR23 */     if ( hasMultipleOperands(p->ret) )\r
+                       {\r
+                               fprintf(f, "extern struct _rv%d", i);\r
+                       }\r
+                       else\r
+                       {\r
+                               fprintf(f, "extern ");\r
+                               DumpType(p->ret, f);\r
+                       }\r
+                       fprintf(f, " %s%s();\n", RulePrefix, p->rname);\r
+                       fprintf(f, "#endif\n");\r
+               }\r
+               else\r
+               {\r
+                       fprintf(f, "\n#ifdef __USE_PROTOS\n");\r
+                       fprintf(f, "void %s%s(", RulePrefix, p->rname);\r
+                       DumpANSIFunctionArgDef(f,p, 1 /* emit initializers ? */ );\r
+                       fprintf(f, ";\n");\r
+#ifdef OLD\r
+                       if ( p->pdecl != NULL || GenAST )\r
+                       {\r
+                               if ( GenAST ) {\r
+                                       fprintf(f, "AST **%s",(p->pdecl!=NULL)?",":"");\r
+                               }\r
+                               if ( p->pdecl!=NULL ) fprintf(f, "%s", p->pdecl);\r
+                       }\r
+                       else fprintf(f, "void");\r
+                       fprintf(f, ");\n");\r
+#endif\r
+                       fprintf(f, "#else\n");\r
+                       fprintf(f, "extern void %s%s();\n", RulePrefix, p->rname);\r
+                       fprintf(f, "#endif\n");\r
+               }\r
+               i++;\r
+               p = (Junction *)p->p2;\r
+       }\r
+}\r
+\r
+/* Define all rules in the class.h file; generate any required\r
+ * struct definitions first, however.\r
+ */\r
+void\r
+#ifdef __USE_PROTOS\r
+GenRuleMemberDeclarationsForCC( FILE *f, Junction *q )\r
+#else\r
+GenRuleMemberDeclarationsForCC( f, q )\r
+FILE *f;\r
+Junction *q;\r
+#endif\r
+{\r
+       Junction *p = q;\r
+       int i;\r
+\r
+       fprintf(f, "private:\n");\r
+\r
+       /* Dump dflt handler declaration */\r
+       fprintf(f, "\tvoid zzdflthandlers( int _signal, int *_retsignal );\n\n");\r
+\r
+       fprintf(f, "public:\n");\r
+\r
+       /* Dump return value structs */\r
+       i = 1;\r
+       while ( p!=NULL )\r
+       {\r
+               if ( p->ret != NULL )\r
+               {\r
+/* MR23 */     if ( hasMultipleOperands(p->ret) )\r
+                       {\r
+                               DumpRetValStruct(f, p->ret, i);\r
+                       }\r
+               }\r
+               i++;\r
+               p = (Junction *)p->p2;\r
+       }\r
+\r
+       /* Dump member func defs && CONSTRUCTOR */\r
+       fprintf(f, "\t%s(ANTLRTokenBuffer *input);\n", CurrentClassName);\r
+/*\r
+       fprintf(f, "\t%s(ANTLRTokenBuffer *input, ANTLRTokenType eof);\n",\r
+                          CurrentClassName);\r
+*/\r
+\r
+       i = 1;\r
+       p = q;\r
+       while ( p!=NULL )\r
+       {\r
+               if ( p->ret != NULL )\r
+               {\r
+/* MR23 */     if ( hasMultipleOperands(p->ret) )\r
+                       {\r
+                               fprintf(f, "\tstruct _rv%d", i);\r
+                       }\r
+                       else\r
+                       {\r
+                               fprintf(f, "\t");\r
+                               DumpType(p->ret, f);\r
+                       }\r
+                       fprintf(f, " %s%s(",RulePrefix,p->rname);\r
+                       DumpANSIFunctionArgDef(f,p, 1 /* emit initializers ? */ );\r
+                       fprintf(f, ";\n");\r
+#ifdef OLD\r
+                       if ( p->pdecl != NULL || GenAST )\r
+                       {\r
+                               if ( GenAST ) fprintf(f, "ASTBase **%s",(p->pdecl!=NULL)?",":"");\r
+                               if ( p->pdecl!=NULL ) fprintf(f, "%s", p->pdecl);\r
+                       }\r
+                       fprintf(f, ");\n");\r
+#endif\r
+               }\r
+               else\r
+               {\r
+                       fprintf(f, "\tvoid %s%s(",RulePrefix,p->rname);\r
+                       DumpANSIFunctionArgDef(f,p, 1 /* emit initializers ? */);\r
+                       fprintf(f, ";\n");\r
+#ifdef OLD\r
+                       if ( p->pdecl != NULL || GenAST )\r
+                       {\r
+                               if ( GenAST ) fprintf(f, "ASTBase **%s",(p->pdecl!=NULL)?",":"");\r
+                               if ( p->pdecl!=NULL ) fprintf(f, "%s", p->pdecl);\r
+                       }\r
+                       fprintf(f, ");\n");\r
+#endif\r
+               }\r
+               i++;\r
+               p = (Junction *)p->p2;\r
+       }\r
+}\r
+\r
+/* Given a list of ANSI-style parameter declarations, print out a\r
+ * comma-separated list of the symbols (w/o types).\r
+ * Basically, we look for a comma, then work backwards until start of\r
+ * the symbol name.  Then print it out until 1st non-alnum char.  Now,\r
+ * move on to next parameter.\r
+ *\r
+ */\r
+\r
+/* MR5         Jan Mikkelsen 26-May-97 - added initalComma parameter              */\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+DumpListOfParmNames(char *pdecl, FILE *output, int initialComma)    /* MR5 */\r
+#else\r
+DumpListOfParmNames(pdecl, output, initialComma)                           /* MR5 */\r
+char *pdecl;                                                                           /* MR5 */\r
+FILE *output;                                                                              /* MR5 */\r
+int initialComma;                                                              /* MR5 */\r
+#endif\r
+{\r
+       int firstTime = 1, done = 0;\r
+       require(output!=NULL, "DumpListOfParmNames: NULL parm");\r
+\r
+       if ( pdecl == NULL ) return;\r
+       while ( !done )\r
+       {\r
+               if ( !firstTime || initialComma ) putc(',', output);        /* MR5 */\r
+               done = DumpNextNameInDef(&pdecl, output);\r
+               firstTime = 0;\r
+       }\r
+}\r
+\r
+/* given a list of parameters or return values, dump the next\r
+ * name to output.  Return 1 if last one just printed, 0 if more to go.\r
+ */\r
+\r
+/* MR23 Total rewrite */\r
+\r
+int\r
+#ifdef __USE_PROTOS\r
+DumpNextNameInDef( char **q, FILE *output )\r
+#else\r
+DumpNextNameInDef( q, output )\r
+char **q;\r
+FILE *output;\r
+#endif\r
+{\r
+       char *p;\r
+       char *t;\r
+       char *pDataType;\r
+       char *pSymbol;\r
+       char *pEqualSign;\r
+       char *pValue;\r
+       char *pSeparator;\r
+       int nest = 0;\r
+\r
+       p = endFormal(*q,\r
+                             &pDataType,\r
+                                 &pSymbol,\r
+                                 &pEqualSign,\r
+                                 &pValue,\r
+                                 &pSeparator,\r
+                                 &nest);\r
+\r
+    /* MR26 Handle rule arguments such as: IIR_Bool (IIR_Decl::*contstraint)()\r
+       For this we need to strip off anything which follows the symbol.\r
+     */\r
+\r
+/* MR26 */  t = pSymbol;\r
+/* MR26 */     if (t != NULL) {\r
+/* MR26 */             for (t = pSymbol; *t != 0; t++) {\r
+/* MR26 */                     if (! (isalpha(*t) || isdigit(*t) || *t == '_' || *t == '$')) break;\r
+/* MR26 */             }\r
+/* MR26 */     }\r
+/* MR26 */     fprintf(output,strBetween(pSymbol, t, pSeparator));\r
+\r
+    *q = p;\r
+    return (*pSeparator  == 0);\r
+}\r
+\r
+/* Given a list of ANSI-style parameter declarations, dump K&R-style\r
+ * declarations, one per line for each parameter.  Basically, convert\r
+ * comma to semi-colon, newline.\r
+ */\r
+void\r
+#ifdef __USE_PROTOS\r
+DumpOldStyleParms( char *pdecl, FILE *output )\r
+#else\r
+DumpOldStyleParms( pdecl, output )\r
+char *pdecl;\r
+FILE *output;\r
+#endif\r
+{\r
+       require(output!=NULL, "DumpOldStyleParms: NULL parm");\r
+\r
+       if ( pdecl == NULL ) return;\r
+       while ( *pdecl != '\0' )\r
+       {\r
+               if ( *pdecl == ',' )\r
+               {\r
+                       pdecl++;\r
+                       putc(';', output); putc('\n', output);\r
+                       while ( *pdecl==' ' || *pdecl=='\t' || *pdecl=='\n' ) pdecl++;\r
+               }\r
+               else {putc(*pdecl, output); pdecl++;}\r
+       }\r
+       putc(';', output);\r
+       putc('\n', output);\r
+}\r
+\r
+/* Take in a type definition (type + symbol) and print out type only */\r
+/* MR23 Total rewrite */\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+DumpType( char *s, FILE *f )\r
+#else\r
+DumpType( s, f )\r
+char *s;\r
+FILE *f;\r
+#endif\r
+{\r
+       char *p;\r
+       char *pDataType;\r
+       char *pSymbol;\r
+       char *pEqualSign;\r
+       char *pValue;\r
+       char *pSeparator;\r
+       int nest = 0;\r
+\r
+       require(s!=NULL, "DumpType: invalid type string"); \r
+\r
+       p = endFormal(s,\r
+                             &pDataType,\r
+                                 &pSymbol,\r
+                                 &pEqualSign,\r
+                                 &pValue,\r
+                                 &pSeparator,\r
+                                 &nest);\r
+       fprintf(f,strBetween(pDataType, pSymbol, pSeparator));\r
+}\r
+\r
+/* check to see if string e is a word in string s */\r
+int\r
+#ifdef __USE_PROTOS\r
+strmember( char *s, char *e )\r
+#else\r
+strmember( s, e )\r
+char *s;\r
+char *e;\r
+#endif\r
+{\r
+    register char *p;\r
+    require(s!=NULL&&e!=NULL, "strmember: NULL string");\r
+\r
+    if ( *e=='\0' ) return 1;   /* empty string is always member */\r
+    do {\r
+       while ( *s!='\0' && !isalnum(*s) && *s!='_' )\r
+       ++s;\r
+       p = e;\r
+       while ( *p!='\0' && *p==*s ) {p++; s++;}\r
+       if ( *p=='\0' ) {\r
+           if ( *s=='\0' ) return 1;\r
+           if ( !isalnum (*s) && *s != '_' ) return 1;\r
+       }\r
+       while ( isalnum(*s) || *s == '_' )\r
+       ++s;\r
+    } while ( *s!='\0' );\r
+    return 0;\r
+}\r
+\r
+#if 0\r
+\r
+/* MR23 Replaced by hasMultipleOperands() */\r
+\r
+int\r
+#ifdef __USE_PROTOS\r
+HasComma( char *s )\r
+#else\r
+HasComma( s )\r
+char *s;\r
+#endif\r
+{\r
+       while (*s!='\0')\r
+               if ( *s++ == ',' ) return 1;\r
+       return 0;\r
+}\r
+#endif\r
+\r
+\r
+/* MR23 Total rewrite */\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+DumpRetValStruct( FILE *f, char *ret, int i )\r
+#else\r
+DumpRetValStruct( f, ret, i )\r
+FILE *f;\r
+char *ret;\r
+int i;\r
+#endif\r
+{\r
+       char *p = ret;\r
+       char *pDataType;\r
+       char *pSymbol;\r
+       char *pEqualSign;\r
+       char *pValue;\r
+       char *pSeparator;\r
+    int nest = 0;\r
+\r
+       fprintf(f, "\nstruct _rv%d {\n", i);\r
+       while (*p != 0 && nest == 0) {\r
+               p = endFormal(p,\r
+                                 &pDataType,\r
+                                         &pSymbol,\r
+                                         &pEqualSign,\r
+                                         &pValue,\r
+                                         &pSeparator,\r
+                                         &nest);\r
+               fprintf(f,"\t");\r
+               fprintf(f,strBetween(pDataType, pSymbol, pSeparator));\r
+               fprintf(f," ");\r
+               fprintf(f,strBetween(pSymbol, pEqualSign, pSeparator));\r
+               fprintf(f,";\n");\r
+    }\r
+       fprintf(f,"};\n");\r
+}\r
+\r
+/* given "s" yield s -- DESTRUCTIVE (we modify s if starts with " else return s) */\r
+char *\r
+#ifdef __USE_PROTOS\r
+StripQuotes( char *s )\r
+#else\r
+StripQuotes( s )\r
+char *s;\r
+#endif\r
+{\r
+       if ( *s == '"' )\r
+       {\r
+               s[ strlen(s)-1 ] = '\0';    /* remove last quote */\r
+               return( s+1 );                          /* return address past initial quote */\r
+       }\r
+       return( s );\r
+}\r
diff --git a/Tools/CodeTools/Source/Pccts/antlr/main.c b/Tools/CodeTools/Source/Pccts/antlr/main.c
new file mode 100644 (file)
index 0000000..051ee4e
--- /dev/null
@@ -0,0 +1,1747 @@
+/*\r
+ * main.c -- main program for PCCTS ANTLR.\r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
+ * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
+ * company may do whatever they wish with source code distributed with\r
+ * PCCTS or the code generated by PCCTS, including the incorporation of\r
+ * PCCTS, or its output, into commerical software.\r
+ *\r
+ * We encourage users to develop software with PCCTS.  However, we do ask\r
+ * that credit is given to us for developing PCCTS.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like PCCTS and have developed a nice tool with the\r
+ * output, please mention that you developed it using PCCTS.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * ANTLR 1.33\r
+ * Terence Parr\r
+ * Parr Research Corporation\r
+ * with Purdue University and AHPCRC, University of Minnesota\r
+ * 1989-2001\r
+ */\r
+\r
+/* To set a breakpoint just before exit look for "cleanUp".    */\r
+/* To set a breakpoint for fatal error look for "fatal_intern" */\r
+\r
+#include <stdio.h>\r
+\r
+#include "pcctscfg.h"\r
+#include "stdpccts.h"\r
+\r
+#define MAX_INT_STACK 50\r
+static int istack[MAX_INT_STACK];              /* Int stack */\r
+static int isp = MAX_INT_STACK;\r
+\r
+static int DontAcceptFiles = 0;                        /* if stdin, don't read files */\r
+static int DontAcceptStdin = 0;                        /* if files seen first, don't accept stdin */\r
+\r
+static int tnodes_used_in_guard_predicates_etc;     /* MR10 */\r
+\r
+               /* C m d - L i n e  O p t i o n  S t r u c t  &  F u n c s */\r
+\r
+typedef struct _Opt {\r
+                       char *option;\r
+                       int  arg;\r
+#ifdef __cplusplus\r
+                       void (*process)(...);\r
+#else\r
+                       void (*process)();\r
+#endif\r
+                       char *descr;\r
+               } Opt;\r
+\r
+#ifdef __USE_PROTOS\r
+extern void ProcessArgs(int, char **, Opt *);\r
+#else\r
+extern void ProcessArgs();\r
+#endif\r
+\r
+#ifdef __USE_PROTOS\r
+int ci_strequ(char *a,char *b)\r
+#else\r
+int ci_strequ(a,b)\r
+  char  *a;\r
+  char  *b;\r
+#endif\r
+{\r
+  for ( ;*a != 0 && *b != 0; a++, b++) {\r
+    if (toupper(*a) != toupper(*b)) return 0;\r
+  }\r
+  return (*a == *b);\r
+}\r
+\r
+static void\r
+#ifdef __USE_PROTOS\r
+pStdin( void )\r
+#else\r
+pStdin( )\r
+#endif\r
+{\r
+       if ( DontAcceptStdin )\r
+       {\r
+               warnNoFL("'-' (stdin) ignored as files were specified first");\r
+               return;\r
+       }\r
+\r
+       require(NumFiles<MaxNumFiles,"exceeded max # of input files");\r
+       FileStr[NumFiles++] = "stdin";\r
+       DontAcceptFiles = 1;\r
+}\r
+\r
+static void\r
+#ifdef __USE_PROTOS\r
+pFile( char *s )\r
+#else\r
+pFile( s )\r
+char *s;\r
+#endif\r
+{\r
+       if ( *s=='-' ) { warnNoFL( eMsg1("invalid option: '%s'",s) ); return; }\r
+       if ( DontAcceptFiles )\r
+       {\r
+               warnNoFL(eMsg1("file '%s' ignored as '-' (stdin option) was specified first",s));\r
+               return;\r
+       }\r
+\r
+       require(NumFiles<MaxNumFiles,"exceeded max # of input files");\r
+       FileStr[NumFiles++] = s;\r
+       DontAcceptStdin = 1;\r
+}\r
+\r
+/* MR14\r
+        Allow input to be a file containing a list of files\r
+        Bernard Giroud (b_giroud@decus.ch)\r
+*/\r
+\r
+static void\r
+#ifdef __USE_PROTOS\r
+pFileList( char *s, char *t )\r
+#else\r
+pFileList( s, t )\r
+char *s;\r
+char *t;\r
+#endif\r
+{\r
+#define MaxFLArea 1024\r
+       FILE *fl;\r
+       static char Fn_in_Fl[MaxFLArea] = "";\r
+        char one_fn[MaxFileName];\r
+       char *flp = &Fn_in_Fl[0];\r
+       int fnl, left = MaxFLArea, i;\r
+\r
+       if ( *t=='-' ) { warnNoFL( eMsg1("invalid option: '%s'",t) ); return; }\r
+       if ( DontAcceptFiles )\r
+       {\r
+               warnNoFL(eMsg1("file '%s' ignored as '-' (stdin option) was specified first",t));\r
+               return;\r
+       }\r
+\r
+        if ((fl = fopen(t, "r")) == NULL)\r
+       {\r
+               warnNoFL(eMsg1("file '%s' can't be opened", t));\r
+               return;\r
+       }\r
+        for (;;)\r
+       {\r
+               if (fgets(one_fn, 128 - 1, fl) == NULL)\r
+                       break;\r
+               fnl = strlen(one_fn);\r
+               require(fnl<=left, "no more room in File List Area");\r
+               /* drop the trailing LF */\r
+               if (one_fn[fnl - 1] == 0x0a) one_fn[fnl - 1] = ' ';\r
+               strcat(Fn_in_Fl, one_fn);\r
+               left = left - fnl;\r
+               require(NumFiles<MaxNumFiles,"exceeded max # of input files");\r
+               FileStr[NumFiles++] = flp;\r
+               flp = flp + fnl;\r
+       }\r
+       fclose(fl);\r
+       for (i=0;i < MaxFLArea;i++) if (Fn_in_Fl[i] == ' ') Fn_in_Fl[i] = '\0';\r
+       DontAcceptStdin = 1;\r
+}\r
+\r
+static void\r
+#ifdef __USE_PROTOS\r
+pLLK( char *s, char *t )\r
+#else\r
+pLLK( s, t )\r
+char *s;\r
+char *t;\r
+#endif\r
+{\r
+       LL_k = atoi(t);\r
+       if ( LL_k <= 0 ) {\r
+               warnNoFL("must have at least one token of lookahead (setting to 1)");\r
+               LL_k = 1;\r
+       }\r
+}\r
+\r
+static void\r
+#ifdef __USE_PROTOS\r
+pCk( char *s, char *t )\r
+#else\r
+pCk( s, t )\r
+char *s;\r
+char *t;\r
+#endif\r
+{\r
+       CLL_k = atoi(t);\r
+       if ( CLL_k <= 0 ) {\r
+               warnNoFL("must have at least one token of look-ahead (setting to 1)");\r
+               CLL_k = 1;\r
+       }\r
+}\r
+\r
+static void                                                                                 /* MR6 */\r
+#ifdef __USE_PROTOS\r
+pTab( char *s, char *t )                                                            /* MR6 */\r
+#else\r
+pTab( s, t )                                                                        /* MR6 */\r
+char *s;                                                                                        /* MR6 */\r
+char *t;                                                                                        /* MR6 */\r
+#endif\r
+{                                                                                                   /* MR6 */\r
+       TabWidth = atoi(t);                                                                  /* MR6 */\r
+       if ( TabWidth < 0 || TabWidth > 8 ) {                                /* MR6 */\r
+               warnNoFL("tab width must be between 1 and 8");               /* MR6 */\r
+         TabWidth=0;                                                                        /* MR6 */\r
+       }                                                                                            /* MR6 */\r
+}                                                                                               /* MR6 */\r
+\r
+static int ambAidDepthSpecified=0;                                   /* MR11 */\r
+\r
+static void                                                                                 /* MR11 */\r
+#ifdef __USE_PROTOS\r
+pAAd( char *s, char *t )                                                            /* MR11 */\r
+#else\r
+pAAd( s, t )                                                                        /* MR11 */\r
+char *s;                                                                                        /* MR11 */\r
+char *t;                                                                                        /* MR11 */\r
+#endif\r
+{                                                                                                   /* MR11 */\r
+    ambAidDepthSpecified=1;                                          /* MR11 */\r
+       MR_AmbAidDepth = atoi(t);                                                        /* MR11 */\r
+}                                                                                               /* MR11 */\r
+\r
+static void                                                                                 /* MR11 */\r
+#ifdef __USE_PROTOS\r
+pTreport( char *s, char *t )                                                /* MR11 */\r
+#else\r
+pTreport( s, t )                                                                            /* MR11 */\r
+    char *s;                                                                                /* MR11 */\r
+    char *t;                                                                                /* MR11 */\r
+#endif\r
+{                                                                                                   /* MR11 */\r
+       TnodesReportThreshold = atoi(t);                                                 /* MR11 */\r
+}                                                                                               /* MR11 */\r
+\r
+#ifdef __USE_PROTOS\r
+void chkGTFlag(void)                                       /* 7-Apr-97 MR1 */\r
+#else\r
+void chkGTFlag()                                            /* 7-Apr-97 MR1 */\r
+#endif\r
+{\r
+       if ( !GenAST )\r
+               warn("#-variable or other AST item referenced w/o -gt option");\r
+}\r
+\r
+\r
+#ifdef __USE_PROTOS\r
+static void pInfo(char *s, char *t)                         /* MR10 */\r
+#else\r
+static void pInfo(s,t)                                      /* MR10 */\r
+  char  *s;\r
+  char  *t;\r
+#endif\r
+{\r
+  char  *p;\r
+  int   q;\r
+  for (p=t; *p != 0; p++) {\r
+    q=tolower(*p);\r
+    if (q=='t') {\r
+      InfoT=1;\r
+    } else if (q=='p') {\r
+      InfoP=1;\r
+    } else if (q=='m') {\r
+      InfoM=1;\r
+    } else if (q=='o') {\r
+      InfoO=1;\r
+    } else if (q=='0') {\r
+      ; /* nothing */\r
+    } else if (q=='f') {\r
+      InfoF=1;\r
+    } else {\r
+      warnNoFL(eMsgd("unrecognized -info option \"%c\"",(int)*p));\r
+    };\r
+  };\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+static void pCGen(void)        { CodeGen = FALSE; LexGen = FALSE; }\r
+static void pLGen(void)        { LexGen = FALSE; }\r
+static void pXTGen(void){ MR_Inhibit_Tokens_h_Gen = TRUE; }\r
+static void pTGen(void)        { TraceGen = TRUE; }\r
+static void pSGen(void)        { GenExprSetsOpt = FALSE; }\r
+static void pPrt(void) { PrintOut = TRUE; pCGen(); pLGen(); }\r
+static void pPrtA(void)        { PrintOut = TRUE; PrintAnnotate = TRUE; pCGen(); pLGen(); }\r
+static void pAst(void) { GenAST = TRUE; }\r
+static void pANSI(void)        { GenANSI = TRUE; }\r
+static void pCr(void)  { GenCR = TRUE; }\r
+static void pNOPURIFY(void)    { PURIFY = FALSE; }\r
+/*static void pCt(void)        { warnNoFL("-ct option is now the default"); }*/\r
+static void pLI(void)  { GenLineInfo = TRUE; GenLineInfoMS = FALSE; } /* MR14 */\r
+static void pLIms(void)        { GenLineInfo = TRUE; GenLineInfoMS = TRUE; }  /* MR14 */\r
+static void pFr(char *s, char *t) {RemapFileName = t;}\r
+static void pFe(char *s, char *t) {ErrFileName = t;}\r
+static void pFl(char *s, char *t) {DlgFileName = t;}\r
+static void pFm(char *s, char *t) {ModeFileName = t;}\r
+static void pFt(char *s, char *t) {DefFileName = t;}\r
+\r
+static void pE1(void)  { elevel = 1; }\r
+static void pE2(void)  { elevel = 2; }\r
+static void pE3(void)  { elevel = 3; }\r
+static void pEGen(void)        { GenEClasseForRules = 1; }\r
+static void pDL(void)\r
+       {\r
+           DemandLookahead = 1;\r
+           if ( GenCC ) {\r
+                       warnNoFL("-gk does not work currently in C++ mode; -gk turned off");\r
+                       DemandLookahead = 0;\r
+           }\r
+       }\r
+\r
+static void pAA(char *s,char *t) {MR_AmbAidRule = t;}               /* MR11 */\r
+static void pAAm(char *s){MR_AmbAidMultiple = 1;}                   /* MR11 */\r
+static void pGHdr(void)        { GenStdPccts = 1; }\r
+static void pFHdr(char *s, char *t) { stdpccts = t; pGHdr(); }\r
+static void pW1(void) { WarningLevel = 1; }\r
+static void pNewAST(void) { NewAST = 1; }                           /* MR13 */\r
+static void ptmakeInParser(void) { tmakeInParser = 1; }             /* MR23 */\r
+static void pAlpha(void) { AlphaBetaTrace = 1; }                    /* MR14 */\r
+static void pMR_BlkErr(void) { MR_BlkErr = 1; }                     /* MR21 */\r
+static void pStdout(void) {UseStdout = 1; }                                /* MR6 */\r
+static void pW2(void) { WarningLevel = 2; }\r
+static void pCC(void) { GenCC = TRUE; }\r
+#else\r
+static void pCGen()    { CodeGen = FALSE; LexGen = FALSE; }\r
+static void pLGen()    { LexGen = FALSE; }\r
+static void pXTGen(){ MR_Inhibit_Tokens_h_Gen = TRUE; }             /* MR14 */\r
+static void pTGen()    { TraceGen = TRUE; }\r
+static void pSGen()    { GenExprSetsOpt = FALSE; }\r
+static void pPrt()             { PrintOut = TRUE; pCGen(); pLGen(); }\r
+static void pPrtA()    { PrintOut = TRUE; PrintAnnotate = TRUE; pCGen(); pLGen(); }\r
+static void pAst()             { GenAST = TRUE; }\r
+static void pANSI()    { GenANSI = TRUE; }\r
+static void pCr()              { GenCR = TRUE; }\r
+static void pNOPURIFY()        { PURIFY = FALSE; }\r
+\r
+/*static void pCt()            { warnNoFL("-ct option is now the default"); }*/\r
+static void pLI()          { GenLineInfo = TRUE; GenLineInfoMS = FALSE; }  /* MR14 */\r
+static void pLIms()        { GenLineInfo = TRUE; GenLineInfoMS = TRUE; }   /* MR14 */\r
+static void pFr(s,t) char *s, *t; {RemapFileName = t;}\r
+static void pFe(s,t) char *s, *t; {ErrFileName = t;}\r
+static void pFl(s,t) char *s, *t; {DlgFileName = t;}\r
+static void pFm(s,t) char *s, *t; {ModeFileName = t;}\r
+static void pFt(s,t) char *s, *t; {DefFileName = t;}\r
+\r
+static void pE1()              { elevel = 1; }\r
+static void pE2()              { elevel = 2; }\r
+static void pE3()              { elevel = 3; }\r
+static void pEGen()    { GenEClasseForRules = 1; }\r
+static void pDL()\r
+       {\r
+           DemandLookahead = 1;\r
+           if ( GenCC ) {\r
+          warnNoFL("-gk does not work currently in C++ mode; -gk turned off");\r
+             DemandLookahead = 0;\r
+           }\r
+       }\r
+\r
+static void pAA(s,t) char *s; char *t; {MR_AmbAidRule = t;}          /* MR11 BJS 20-Mar-98 */\r
+static void pAAm(s) char *s; {MR_AmbAidMultiple = 1;}                /* MR11 BJS 20-Mar-98 */\r
+static void pGHdr()    { GenStdPccts = 1; }\r
+static void pFHdr(s,t) char *s, *t; { stdpccts = t; pGHdr(); }\r
+static void pW1() { WarningLevel = 1; }\r
+static void pNewAST() { NewAST = 1; }                                /* MR13 */\r
+static void ptmakeInParser() { tmakeInParser = 1; }                  /* MR23 */\r
+static void pAlpha() { AlphaBetaTrace = 1; }                         /* MR14 */\r
+static void pMR_BlkErr() { MR_BlkErr = 1; }                          /* MR21 */\r
+static void pStdout() {UseStdout = 1; }                                     /* MR6 */\r
+static void pW2() { WarningLevel = 2; }\r
+static void pCC() { GenCC = TRUE; }\r
+#endif\r
+\r
+static void\r
+#ifdef __USE_PROTOS\r
+pPre( char *s, char *t )\r
+#else\r
+pPre( s, t )\r
+char *s;\r
+char *t;\r
+#endif\r
+{\r
+       RulePrefix = t;\r
+}\r
+\r
+static void\r
+#ifdef __USE_PROTOS\r
+pOut( char *s, char *t )\r
+#else\r
+pOut( s, t )\r
+char *s;\r
+char *t;\r
+#endif\r
+{\r
+       OutputDirectory = t;\r
+}\r
+\r
+static void\r
+#ifdef __USE_PROTOS\r
+pPred( void )\r
+#else\r
+pPred( )\r
+#endif\r
+{\r
+       warnNoFL("-pr is no longer used (predicates employed if present); see -prc, -mrhoist, -mrhoistk");\r
+/*\r
+**     if ( DemandLookahead )\r
+**             warnNoFL("-gk conflicts with -pr; -gk turned off");\r
+**     DemandLookahead = 0;\r
+**     HoistPredicateContext = 0;\r
+*/\r
+}\r
+\r
+static void\r
+#ifdef __USE_PROTOS\r
+pPredCtx( char *s, char *t )\r
+#else\r
+pPredCtx(s,t)\r
+char *s;\r
+char *t;\r
+#endif\r
+{\r
+       if ( ci_strequ(t,"on")) HoistPredicateContext = 1;\r
+       else if ( ci_strequ(t,"off")) HoistPredicateContext = 0;\r
+       if ( DemandLookahead )\r
+       {\r
+               warnNoFL("-gk incompatible with semantic predicate usage; -gk turned off");\r
+               DemandLookahead = 0;\r
+       }\r
+}\r
+\r
+static void\r
+#ifdef __USE_PROTOS\r
+pMRhoist( char *s, char *t )\r
+#else\r
+pMRhoist(s,t)\r
+char *s;\r
+char *t;\r
+#endif\r
+{\r
+       if ( ci_strequ(t,"on")) MRhoisting = 1;\r
+       else if ( ci_strequ(t,"off")==0 ) MRhoisting = 0;\r
+    if (MRhoisting) {\r
+        fprintf(stderr,"Maintenance Release style hoisting enabled for predicates with lookahead depth = 1\n");\r
+        fprintf(stderr,"  No longer considered experimental\n");\r
+        fprintf(stderr,"  Can't consider suppression for predicates with lookahead depth > 1\n");\r
+        fprintf(stderr,"  Implies -prc on but does *not* imply -mrhoistk for k>1 predicates\n");\r
+        fprintf(stderr,"  This is a reminder, not a warning or error.\n");\r
+    };\r
+}\r
+\r
+static void\r
+#ifdef __USE_PROTOS\r
+pMRhoistk( char *s, char *t )\r
+#else\r
+pMRhoistk(s,t)\r
+char *s;\r
+char *t;\r
+#endif\r
+{\r
+       if ( ci_strequ(t,"on")) MRhoistingk = 1;\r
+       else if ( ci_strequ(t,"off")==0 ) MRhoistingk = 0;\r
+    if (MRhoistingk) {\r
+        fprintf(stderr,"EXPERIMENTAL Maintenance Release style hoisting enabled\n");\r
+        fprintf(stderr,"  Applies to predicates with lookahead depth > 1\n");\r
+        fprintf(stderr,"  Implies -prc on and -mrhoist on\n");\r
+    };\r
+}\r
+\r
+static void\r
+#ifdef __USE_PROTOS\r
+pTRes( char *s, char *t )\r
+#else\r
+pTRes( s, t )\r
+char *s;\r
+char *t;\r
+#endif\r
+{\r
+       TreeResourceLimit = atoi(t);\r
+       if ( TreeResourceLimit <= 0 )\r
+       {\r
+               warnNoFL("analysis resource limit (# of tree nodes) must be greater than 0");\r
+               TreeResourceLimit = -1; /* set to no limit */\r
+       }\r
+}\r
+\r
+Opt options[] = {\r
+#ifdef __cplusplus\r
+    { "-CC", 0, (void (*)(...)) pCC,   "Generate C++ output (default=FALSE)"},\r
+    { "-ck", 1, (void (*)(...)) pCk,   "Set compressed lookahead depth; fast approximate lookahead"},\r
+    { "-cr", 0, (void (*)(...)) pCr,   "Generate cross reference (default=FALSE)"},\r
+    { "-e1", 0, (void (*)(...)) pE1,   "Ambiguities/errors shown in low detail (default)"},\r
+    { "-e2", 0, (void (*)(...)) pE2,   "Ambiguities/errors shown in more detail"},\r
+    { "-e3", 0, (void (*)(...)) pE3,\r
+       "Ambiguities for k>1 grammars shown with exact tuples (not lookahead sets)"},\r
+    { "-f",  1, (void (*)(...)) pFileList,"Read names of grammar files from specified file"}, /* MR14 */\r
+    { "-fe", 1, (void (*)(...)) pFe,   "Rename err.c"},\r
+    { "-fh", 1, (void (*)(...)) pFHdr, "Rename stdpccts.h header (turns on -gh)"},\r
+    { "-fl", 1, (void (*)(...)) pFl,   "Rename lexical output--parser.dlg"},\r
+    { "-fm", 1, (void (*)(...)) pFm,   "Rename mode.h"},\r
+    { "-fr", 1, (void (*)(...)) pFr,   "Rename remap.h"},\r
+    { "-ft", 1, (void (*)(...)) pFt,   "Rename tokens.h"},\r
+    { "-ga", 0, (void (*)(...)) pANSI, "Generate ANSI-compatible code (default=FALSE)"},\r
+    { "-gc", 0, (void (*)(...)) pCGen, "Do not generate output parser code (default=FALSE)"},\r
+    { "-gd", 0, (void (*)(...)) pTGen, "Generate code to trace rule invocation (default=FALSE)"},\r
+    { "-ge", 0, (void (*)(...)) pEGen, "Generate an error class for each non-terminal (default=FALSE)"},\r
+    { "-gh", 0, (void (*)(...)) pGHdr, "Generate stdpccts.h for non-ANTLR-generated-files to include"},\r
+    { "-gk", 0, (void (*)(...)) pDL,   "Generate parsers that delay lookahead fetches until needed"},\r
+    { "-gl", 0, (void (*)(...)) pLI,   "Generate line info about grammar actions in parser"},\r
+    { "-glms", 0, (void (*)(...)) pLIms,"Like -gl but replace '\\' with '/' in #line filenames for MS C/C++ systems"},\r
+    { "-gp", 1, (void (*)(...)) pPre,  "Prefix all generated rule functions with a string"},\r
+    { "-gs", 0, (void (*)(...)) pSGen, "Do not generate sets for token expression lists (default=FALSE)"},\r
+    { "-gt", 0, (void (*)(...)) pAst,  "Generate code for Abstract-Syntax-Trees (default=FALSE)"},\r
+    { "-gx", 0, (void (*)(...)) pLGen, "Do not generate lexical (dlg-related) files (default=FALSE)"},\r
+    { "-gxt",0, (void (*)(...)) pXTGen,        "Do not generate tokens.h (default=FALSE)"},\r
+    { "-k",  1, (void (*)(...)) pLLK,  "Set full LL(k) lookahead depth (default==1)"},\r
+    { "-o",  1, (void (*)(...)) pOut,  OutputDirectoryOption},\r
+    { "-p",  0, (void (*)(...)) pPrt,  "Print out the grammar w/o actions (default=no)"},\r
+    { "-pa", 0, (void (*)(...)) pPrtA, "Print out the grammar w/o actions & w/FIRST sets (default=no)"},\r
+    { "-pr",0, (void (*)(...)) pPred,  "no longer used; predicates employed if present"},\r
+    { "-prc", 1, (void (*)(...)) pPredCtx,"Turn on/off computation of context for hoisted predicates"},\r
+       { "-rl", 1, (void (*)(...)) pTRes,      "Limit max # of tree nodes used by grammar analysis"},\r
+    { "-stdout",0,  (void (*)(...)) pStdout,"Send grammar.c/grammar.cpp to stdout"},           /* MR6 */\r
+       { "-tab", 1, (void (*)(...)) pTab,      "Width of tabs (1 to 8) for grammar.c/grammar.cpp files"}, /* MR6 */\r
+       { "-w1", 0, (void (*)(...)) pW1,        "Set the warning level to 1 (default)"},\r
+       { "-w2", 0, (void (*)(...)) pW2,        "Ambiguities yield warnings even if predicates or (...)? block"},\r
+       { "-",   0, (void (*)(...)) pStdin,     "Read grammar from stdin" },\r
+    { "-mrhoist",1, (void (*)(...)) pMRhoist,                                                  /* MR9 */\r
+                                        "Turn on/off k=1 Maintenance Release style hoisting"},  /* MR9 */\r
+    { "-mrhoistk",1, (void (*)(...)) pMRhoistk,                                                  /* MR9 */\r
+                                        "Turn on/off EXPERIMENTAL k>1 Maintenance Release style hoisting"},  /* MR13 */\r
+    { "-aa"  , 1, (void (*)(...)) pAA,  "Ambiguity aid for a rule (rule name or line number)"},          /* MR11 */\r
+    { "-aam" , 0, (void (*)(...)) pAAm,\r
+                                         "Lookahead token may appear multiple times in -aa listing"},    /* MR11 */\r
+    { "-aad" , 1, (void (*)(...)) pAAd,\r
+                                         "Limits exp growth of -aa listing - default=1 (max=ck value)"}, /* MR11 */\r
+       { "-info", 1, (void (*)(...)) pInfo,\r
+      "Extra info: p=pred t=tnodes f=first/follow m=monitor o=orphans 0=noop"},                          /* MR12 */\r
+    { "-treport",1,(void (*)(...)) pTreport,\r
+                        "Report when tnode usage exceeds value during ambiguity resolution"},            /* MR11 */\r
+       { "-newAST", 0, (void (*)(...)) pNewAST,\r
+                 "In C++ mode use \"newAST(...)\" rather than \"new AST(...)\""},                        /* MR13 */\r
+       { "-tmake", 0, (void (*)(...)) ptmakeInParser,\r
+                 "In C++ mode use parser's tmake method rather than \"ASTBase::tmake(...)\""},                  /* MR23 */\r
+    { "-alpha",0,(void (*)(...)) pAlpha,\r
+                 "Provide additional information for \"(alpha)? beta\" error messages"},                 /* MR14 */\r
+    { "-mrblkerr",0,(void (*)(...)) pMR_BlkErr,                                        /* MR21 */\r
+                 "EXPERIMENTAL change to (...)* and (...)+ syntax error sets"},        /* MR21 */\r
+       { "-nopurify",0,(void (*)(...)) pNOPURIFY,\r
+               "Don't use the notorious PURIFY macro (replaced by MR23 initial value syntax) to zero return arguments of rules"},   /* MR23 */\r
+    { "*",   0, (void (*)(...)) pFile,         "" },   /* anything else is a file */\r
+#else\r
+    { "-CC", 0, pCC,   "Generate C++ output (default=FALSE)"},\r
+    { "-cr", 0, pCr,   "Generate cross reference (default=FALSE)"},\r
+    { "-ck", 1, pCk,   "Set compressed lookahead depth; fast approximate lookahead"},\r
+    { "-e1", 0, pE1,   "Ambiguities/errors shown in low detail (default)"},\r
+    { "-e2", 0, pE2,   "Ambiguities/errors shown in more detail"},\r
+    { "-e3", 0, pE3,           "Ambiguities for k>1 grammars shown with exact tuples (not lookahead sets)"},\r
+    { "-f",  1, pFileList,"Read names of grammar files from specified file"},   /* MR14 */\r
+    { "-fe", 1, pFe,   "Rename err.c"},\r
+    { "-fh", 1, pFHdr, "Rename stdpccts.h header (turns on -gh)"},\r
+    { "-fl", 1, pFl,   "Rename lexical output--parser.dlg"},\r
+    { "-fm", 1, pFm,   "Rename mode.h"},\r
+    { "-fr", 1, pFr,   "Rename remap.h"},\r
+    { "-ft", 1, pFt,   "Rename tokens.h"},\r
+    { "-ga", 0, pANSI, "Generate ANSI-compatible code (default=FALSE)"},\r
+    { "-gc", 0, pCGen, "Do not generate output parser code (default=FALSE)"},\r
+    { "-gd", 0, pTGen, "Generate code to trace rule invocation (default=FALSE)"},\r
+    { "-ge", 0, pEGen, "Generate an error class for each non-terminal (default=FALSE)"},\r
+    { "-gh", 0, pGHdr, "Generate stdpccts.h for non-ANTLR-generated-files to include"},\r
+    { "-gk", 0, pDL,   "Generate parsers that delay lookahead fetches until needed"},\r
+    { "-gl", 0, pLI,   "Generate line info about grammar actions in C parser"},\r
+    { "-glms", 0, pLIms,"Like -gl but replace '\\' with '/' in #line filenames for MS C/C++ systems"},\r
+    { "-gp", 1, pPre,  "Prefix all generated rule functions with a string"},\r
+    { "-gs", 0, pSGen, "Do not generate sets for token expression lists (default=FALSE)"},\r
+    { "-gt", 0, pAst,  "Generate code for Abstract-Syntax-Trees (default=FALSE)"},\r
+    { "-gx", 0, pLGen, "Do not generate lexical (dlg-related) files (default=FALSE)"},\r
+    { "-gxt",0, pXTGen,        "Do not generate tokens.h (default=FALSE)"},\r
+    { "-k",  1, pLLK,  "Set full LL(k) lookahead depth (default==1)"},\r
+    { "-o",  1, pOut,  OutputDirectoryOption},\r
+    { "-p",  0, pPrt,  "Print out the grammar w/o actions (default=no)"},\r
+    { "-pa", 0, pPrtA, "Print out the grammar w/o actions & w/FIRST sets (default=no)"},\r
+    { "-pr",0, pPred,  "no longer used; predicates employed if present"},\r
+    { "-prc", 1, pPredCtx,"Turn on/off computation of context for hoisted predicates"},\r
+    { "-rl", 1, pTRes, "Limit max # of tree nodes used by grammar analysis"},\r
+    { "-stdout",0, pStdout,    "Send grammar.c/grammar.cpp to stdout"},               /* MR6 */\r
+    { "-tab", 1, pTab, "Width of tabs (1 to 8) for grammar.c/grammar.cpp files"}, /* MR6 */\r
+       { "-w1", 0, pW1,        "Set the warning level to 1 (default)"},\r
+       { "-w2", 0, pW2,        "Ambiguities yield warnings even if predicates or (...)? block"},\r
+    { "-mrhoist",1,pMRhoist,                                                       /* MR9 */\r
+                         "Turn on/off k=1 Maintenance Release style hoisting"},  /* MR9 */\r
+    { "-mrhoistk",1,pMRhoistk,                                                       /* MR13 */\r
+                         "Turn on/off k>1 EXPERIMENTAL Maintenance Release style hoisting"},  /* MR13 */\r
+    { "-aa"  ,1,pAA,     "Ambiguity aid for a rule (rule name or line number)"},          /* MR11 */\r
+    { "-aam" ,0,pAAm,\r
+                         "Lookahead token may appear multiple times in -aa listing"},     /* MR11 */\r
+    { "-aad" ,1,pAAd,\r
+                         "Limits exp growth of -aa listing - default=1 (max=ck value)"},  /* MR11 */\r
+       { "-info",1,pInfo,\r
+      "Extra info: p=pred t=tnodes f=first/follow m=monitor o=orphans 0=noop"},           /* MR11 */\r
+    { "-treport",1,pTreport,\r
+                        "Report when tnode usage exceeds value during ambiguity resolution"},   /* MR11 */\r
+       { "-newAST", 0, pNewAST,\r
+                 "In C++ mode use \"newAST(...)\" rather than \"new AST(...)\""},         /* MR13 */\r
+       { "-tmake", 0, ptmakeInParser,\r
+                 "In C++ mode use parser's tmake method rather than \"ASTBase::tmake(...)\""},   /* MR23 */\r
+    { "-alpha",0, pAlpha,\r
+                 "Provide additional information for \"(alpha)? beta\" error messages"},  /* MR14 */\r
+    { "-mrblkerr",0,pMR_BlkErr,                                                           /* MR21 */\r
+                 "EXPERIMENTAL change to (...)* and (...)+ syntax error sets"},           /* MR21 */\r
+       { "-nopurify",0,pNOPURIFY,\r
+               "Don't use the notorious PURIFY macro (replaced by MR23 initial value syntax) to zero return arguments of rules"},   /* MR23 */\r
+       { "-",   0, pStdin,     "Read grammar from stdin" },\r
+       { "*",   0, pFile,      "" },   /* anything else is a file */\r
+#endif\r
+       { NULL,  0, NULL }\r
+ };\r
+\r
+void readDescr();\r
+void cleanUp();\r
+\r
+#ifdef __USE_PROTOS\r
+static void buildRulePtr( void );\r
+static void help( void );\r
+static void init( void );\r
+static void CompleteTokenSetRefs( void );\r
+static void ensure_no_C_file_collisions(char *);\r
+static void CompleteContextGuards(void);\r
+#else\r
+static void buildRulePtr( );\r
+static void help( );\r
+static void init( );\r
+static void CompleteTokenSetRefs( );\r
+static void ensure_no_C_file_collisions();\r
+static void CompleteContextGuards();\r
+#endif\r
+\r
+static void\r
+#ifdef __USE_PROTOS  /* <BJS> */\r
+report_numericPredLabels(ActionNode *a)\r
+#else\r
+report_numericPredLabels(a)\r
+ActionNode *a;\r
+#endif\r
+{                                                                           /* MR10 */\r
+  warnFL("numeric references to attributes (e.g. $i or $i.j) in semantic pred will be null during guess mode",  /* MR10 */\r
+            FileStr[a->file],a->line);                                      /* MR10 */\r
+}                                                                           /* MR10 */\r
+\r
+                                                               /* M a i n */\r
+\r
+int\r
+#ifdef __USE_PROTOS\r
+main( int argc, char *argv[] )\r
+#else\r
+main( argc, argv )\r
+int argc;\r
+char *argv[];\r
+#endif\r
+{\r
+       int i;\r
+       static char EPSTR[] = "[Ep]";\r
+\r
+    Save_argc=argc;                                                  /* MR10 */\r
+    Save_argv=argv;                                                  /* MR10 */\r
+\r
+/*     malloc_debug(8);*/\r
+\r
+#ifdef SPECIAL_INITS\r
+    special_inits();                                                 /* MR1 */\r
+#endif\r
+       fprintf(stderr, "Antlr parser generator   Version %s   1989-2001\n", Version);\r
+       if ( argc == 1 ) { help(); zzDIE; }\r
+       ProcessArgs(argc-1, &(argv[1]), options);\r
+\r
+/* MR14 */    if (MR_AmbAidRule && AlphaBetaTrace) {\r
+/* MR14 */       fatal("Can't specify both -aa (ambiguity aid) and -alpha (\"(alpha)? beta\" aid)");\r
+/* MR14 */    }\r
+\r
+    if (MRhoistingk) {              /* MR13 */\r
+      HoistPredicateContext=1;      /* MR13 */\r
+      MRhoisting=1;                 /* MR13 */\r
+    };                              /* MR13 */\r
+    if (MRhoisting && ! HoistPredicateContext) {\r
+/***      warnNoFL("Using \"-mrhoist\" forces \"-prc on\"");    ***/\r
+      HoistPredicateContext=1;\r
+    };\r
+    if (HoistPredicateContext && ! MRhoisting) {\r
+        warnNoFL("When using predicate context (-prc on) -mrhoist on is recommended");\r
+    }\r
+       /* Fix lookahead depth */\r
+       /* Compressed lookahead must always be larger than or equal to full lookahead */\r
+       if ( CLL_k < LL_k  && CLL_k>0 )\r
+       {\r
+               warnNoFL("must have compressed lookahead >= full LL(k) lookahead (setting -ck to -k)");\r
+               CLL_k = LL_k;\r
+       }\r
+       if ( CLL_k == -1 ) CLL_k = LL_k;\r
+       OutputLL_k = CLL_k;\r
+       if ( ((CLL_k-1)&CLL_k)!=0 ) { /* output ll(k) must be power of 2 */\r
+               int n;\r
+               for(n=1; n<CLL_k; n<<=1) {;}\r
+               OutputLL_k = n;\r
+       };\r
+\r
+       if (MR_BlkErr) {\r
+               warnNoFL("The -mrblkerr option is EXPERIMENTAL");\r
+        if (LL_k > 1) {\r
+               warnNoFL("The -mrblkerr option is designed only for k=1 ck=1 grammars");\r
+        }\r
+       };\r
+\r
+    if ( ! ambAidDepthSpecified) {\r
+      MR_AmbAidDepth=1;\r
+    } else {\r
+      if (MR_AmbAidDepth > CLL_k || MR_AmbAidDepth <= 0) {\r
+        warnNoFL(eMsgd(\r
+            "Ambiguity aid depth (\"-aad ...\") must be a number between 1 and max(k,ck)=%d",CLL_k));\r
+        MR_AmbAidDepth=1;\r
+      };\r
+      if (MR_AmbAidDepth == 0) {\r
+        MR_AmbAidDepth=2;\r
+      };\r
+    };\r
+\r
+    if (MR_AmbAidRule != NULL) MR_AmbAidLine=atoi(MR_AmbAidRule);\r
+\r
+       fpTrans = &(C_Trans[0]);                /* Translate to C Language */\r
+       fpJTrans = &(C_JTrans[0]);\r
+       init();\r
+       lexclass(LexStartSymbol);\r
+\r
+       readDescr();\r
+       LastTokenCounted = TokenNum;\r
+       RemapForcedTokens();\r
+       if ( CannotContinue ) {cleanUp(); zzDIE;}\r
+       if ( GenCC && no_classes_found ) fatal("required grammar class not found (exiting...)");\r
+       if ( WarningLevel>1 && HdrAction == NULL )\r
+          warnNoFL("no #header action was found");\r
+       if ( FoundAtOperator && ! FoundExceptionGroup) {\r
+          warnNoFL("found the exception operator '@' - but no exception group was found");\r
+       };\r
+       EpToken = addTname(EPSTR);              /* add imaginary token epsilon */\r
+       set_orel(EpToken, &imag_tokens);\r
+\r
+       /* this won't work for hand-built scanners since EofToken is not\r
+        * known.  Forces EOF to be token type 1.\r
+        */\r
+       set_orel(EofToken, &imag_tokens);\r
+\r
+       set_size(NumWords(TokenNum-1));\r
+\r
+       /* compute the set of all known token types\r
+        * It represents the set of tokens from 1 to last_token_num + the\r
+        * reserved positions above that (if any).  Don't include the set of\r
+        * imaginary tokens such as the token/error classes or EOF.\r
+        */\r
+       {\r
+               set a;\r
+               a = set_dup(reserved_positions);\r
+               for (i=1; i<TokenNum; i++) { set_orel(i, &a); }\r
+               all_tokens = set_dif(a, imag_tokens);\r
+               set_free(a);\r
+       }\r
+\r
+       ComputeTokSets();                               /* Compute #tokclass sets */\r
+       CompleteTokenSetRefs();                 /* Change complex nodes in syn diag */\r
+    CompleteContextGuards();        /* MR13 */\r
+\r
+       if ( CodeGen ) genDefFile();    /* create tokens.h */\r
+       if ( LexGen ) genLexDescr();    /* create parser.dlg */\r
+\r
+       if ( GenStdPccts )\r
+       {\r
+               FILE *f = fopen(OutMetaName(stdpccts), "w");\r
+               if ( f==NULL ) {warnNoFL( eMsg1("can't create %s",OutMetaName(stdpccts)) );}\r
+               else\r
+               {\r
+#ifdef SPECIAL_FOPEN\r
+                       special_fopen_actions(OutMetaName(stdpccts));            /* MR1 */\r
+#endif\r
+            if (strcmp(stdpccts,"stdpccts.h") == 0) {                /* MR10 */\r
+                     genStdPCCTSIncludeFile(f,NULL);                        /* MR10 */\r
+            } else {                                                 /* MR10 */\r
+                     genStdPCCTSIncludeFile(f,pcctsBaseName(stdpccts));     /* MR32 */\r
+            };\r
+                       fclose(f);\r
+               }\r
+       }\r
+\r
+       buildRulePtr();                                 /* create mapping from rule # to RuleBlk junction */\r
+       ComputeErrorSets();\r
+       FoLink( (Node *)SynDiag );              /* add follow links to end of all rules */\r
+       \r
+       if ( GenCR ) GenCrossRef( SynDiag );\r
+\r
+       if ( CodeGen )\r
+       {\r
+               if ( SynDiag == NULL )\r
+               {\r
+                       warnNoFL("no grammar description recognized");\r
+                       cleanUp();\r
+                       zzDIE;\r
+               }\r
+               else if ( !GenCC ) {\r
+                       ErrFile = fopen(OutMetaName(ErrFileName), "w");\r
+                       require(ErrFile != NULL, "main: can't open err file");\r
+#ifdef SPECIAL_FOPEN\r
+                     special_fopen_actions(OutMetaName(ErrFileName));   /* MR1 */\r
+#endif\r
+                       NewSetWd();\r
+                       GenErrHdr();\r
+                       TRANS(SynDiag);                 /* Translate to the target language */\r
+                       DumpSetWd();\r
+                       DumpRemainingTokSets();\r
+                       fclose( ErrFile );\r
+               }\r
+               else {\r
+                       strcpy(Parser_h_Name, CurrentClassName);\r
+                       strcat(Parser_h_Name, ".h");\r
+                       strcpy(Parser_c_Name, CurrentClassName);\r
+                       strcat(Parser_c_Name, CPP_FILE_SUFFIX);\r
+                       ensure_no_C_file_collisions(Parser_c_Name);\r
+                       Parser_h = fopen(OutMetaName(Parser_h_Name), "w");\r
+                       require(Parser_h != NULL, "main: can't open class Parserx.h file");\r
+#ifdef SPECIAL_FOPEN\r
+                   special_fopen_actions(OutMetaName(Parser_h_Name));       /* MR1 */\r
+#endif\r
+                       Parser_c = fopen(OutMetaName(Parser_c_Name), "w");\r
+                       require(Parser_c != NULL, "main: can't open class Parserx.c file");\r
+#ifdef SPECIAL_FOPEN\r
+                   special_fopen_actions(OutMetaName(Parser_c_Name));       /* MR1 */\r
+#endif\r
+                       GenParser_h_Hdr();\r
+                       if ( class_before_actions != NULL )\r
+                       {\r
+                               ListNode *p;\r
+                               for (p = class_before_actions->next; p!=NULL; p=p->next)\r
+                               {\r
+                                       UserAction *ua = (UserAction *)p->elem;\r
+                                       dumpAction( ua->action, Parser_h, 0, ua->file, ua->line, 1);\r
+                               }\r
+                       }\r
+                       GenParser_c_Hdr();\r
+                       fprintf(Parser_h, "protected:\n");  /* MR20 */\r
+                       NewSetWd();\r
+                       TRANS(SynDiag);                 /* Translate to the target language */\r
+                       DumpSetWd();\r
+                       GenRuleMemberDeclarationsForCC(Parser_h, SynDiag);\r
+                       if ( class_after_actions != NULL )\r
+                       {\r
+                               ListNode *p;\r
+                               for (p = class_after_actions->next; p!=NULL; p=p->next)\r
+                               {\r
+                                       UserAction *ua = (UserAction *)p->elem;\r
+                                       dumpAction( ua->action, Parser_h, 0, ua->file, ua->line, 1);\r
+                               }\r
+                       }\r
+                       DumpRemainingTokSets();\r
+                       fprintf(Parser_h, "};\n");\r
+                       fprintf(Parser_h, "\n#endif /* %s_h */\n", CurrentClassName);\r
+                       fclose( Parser_h );\r
+                       fclose( Parser_c );\r
+               }\r
+       }\r
+\r
+    MR_orphanRules(stderr);\r
+    if (LTinTokenAction && WarningLevel >= 2) {\r
+               if (GenCC) {\r
+                       warnNoFL("At least one <<action>> following a token match contains a reference to LT(...)\n      this will reference the immediately preceding token,\n      not the one which follows as is the case with semantic predicates.");\r
+               }\r
+                       warnNoFL("At least one <<action>> following a token match contains a reference to LA(...) or LATEXT(...)\n      this will reference the immediately preceding token,\n      not the one which follows as is the case with semantic predicates.");\r
+       }\r
+\r
+       if ( PrintOut )\r
+       {\r
+               if ( SynDiag == NULL ) {warnNoFL("no grammar description recognized");}\r
+               else PRINT(SynDiag);\r
+       }\r
+\r
+#ifdef DBG_LL1\r
+#endif\r
+       GenRemapFile();                                 /* create remap.h */\r
+/* MR10 */    if (FoundGuessBlk) {\r
+#ifdef __cplusplus__\r
+/* MR10 */      list_apply(NumericPredLabels, (void (*)(void *))report_numericPredLabels);\r
+#else\r
+#ifdef __USE_PROTOS\r
+/* MR10 */      list_apply(NumericPredLabels, (void (*)(void *))report_numericPredLabels);\r
+#else\r
+/* MR10 */      list_apply(NumericPredLabels,report_numericPredLabels);\r
+#endif\r
+#endif\r
+/* MR10 */    };\r
+\r
+    if (InfoT && TnodesAllocated > 0) {\r
+      if (TnodesPeak > 10000) {\r
+        fprintf(stdout,"\nTree Nodes:  peak %dk  created %dk  lost %d\n",\r
+                        (TnodesPeak/1000),\r
+                        (TnodesAllocated/1000),\r
+                        TnodesInUse-tnodes_used_in_guard_predicates_etc);\r
+       } else {\r
+         fprintf(stdout,"\nTree Nodes:  peak %d  created %d  lost %d\n",\r
+                        TnodesPeak,\r
+                        TnodesAllocated,\r
+                        TnodesInUse-tnodes_used_in_guard_predicates_etc);\r
+       };\r
+    };\r
+    if (InfoF) {\r
+      DumpFcache();\r
+    };\r
+    if (MR_skipped_e3_report) {\r
+      fprintf(stderr,"note: use -e3 to get exact information on ambiguous tuples\n");\r
+    };\r
+    if (MR_BadExprSets != 0) {\r
+      fprintf(stderr,"note: Unreachable C or C++ code was generated for empty expression sets,\n");\r
+      fprintf(stderr,"        probably due to undefined rules or infinite left recursion.\n");\r
+      fprintf(stderr,"      To locate: search the generated code for \"empty set expression\"\n");\r
+    };\r
+    if (MR_AmbAidRule != NULL && MR_matched_AmbAidRule==0) {\r
+      RuleEntry *q = (RuleEntry *) hash_get(Rname,MR_AmbAidRule);\r
+      if (MR_AmbAidLine == 0 && q == NULL) {\r
+         warnNoFL(eMsg2("there is no rule \"%s\" so \"-aa %s\" will never match",\r
+                                                        MR_AmbAidRule,MR_AmbAidRule));\r
+      } else {\r
+        warnNoFL(eMsg1("there was no ambiguity that matched \"-aa %s\"",MR_AmbAidRule));\r
+      };\r
+    };\r
+    if (AlphaBetaTrace) {\r
+\r
+      if (MR_AlphaBetaMessageCount == 0) {\r
+         fprintf(stderr,"note: there were no messages about \"(alpha)? beta\" blocks added to the generated code\n");\r
+      } else {\r
+         fprintf(stderr,"note: there were %d messages about \"(alpha)? beta\" blocks added to the generated code\n",\r
+                    MR_AlphaBetaMessageCount);\r
+      }\r
+\r
+      if (set_null(MR_CompromisedRules)) {\r
+         fprintf(stderr,"note: the list of rules with compromised follow sets is empty\n");\r
+      } else {\r
+         fprintf(stderr,"note: the following is a list of rules which *may* have incorrect\n");\r
+         fprintf(stderr,"      follow sets computed as a result of an \"(alpha)? beta\" block\n");\r
+         fprintf(stderr,"\n");\r
+         MR_dumpRuleSet(MR_CompromisedRules);\r
+         fprintf(stderr,"\n");\r
+      }\r
+    }\r
+       cleanUp();\r
+       exit(PCCTS_EXIT_SUCCESS);\r
+    return 0;           /* MR11 make compilers happy */ \r
+}\r
+\r
+static void \r
+#ifdef __USE_PROTOS \r
+init( void )\r
+#else\r
+init( )\r
+#endif\r
+{\r
+       SignalEntry *q;\r
+\r
+       Tname = newHashTable();\r
+       Rname = newHashTable();\r
+       Fcache = newHashTable();\r
+       Tcache = newHashTable();\r
+       Sname = newHashTable();\r
+    Pname = newHashTable();     /* MR11 */\r
+\r
+       /* Add default signal names */\r
+       q = (SignalEntry *)hash_add(Sname,\r
+                                                         "NoViableAlt",\r
+                                                         (Entry *)newSignalEntry("NoViableAlt"));\r
+       require(q!=NULL, "cannot alloc signal entry");\r
+       q->signum = sigNoViableAlt;\r
+       q = (SignalEntry *)hash_add(Sname,\r
+                                                         "MismatchedToken",\r
+                                                         (Entry *)newSignalEntry("MismatchedToken"));\r
+       require(q!=NULL, "cannot alloc signal entry");\r
+       q->signum = sigMismatchedToken;\r
+       q = (SignalEntry *)hash_add(Sname,\r
+                                                         "NoSemViableAlt",\r
+                                                         (Entry *)newSignalEntry("NoSemViableAlt"));\r
+       require(q!=NULL, "cannot alloc signal entry");\r
+       q->signum = sigNoSemViableAlt;\r
+       \r
+       reserved_positions = empty;\r
+       all_tokens = empty;\r
+       imag_tokens = empty;\r
+       tokclasses = empty;\r
+       TokenStr = (char **) calloc(TSChunk, sizeof(char *));\r
+       require(TokenStr!=NULL, "main: cannot allocate TokenStr");\r
+       FoStack = (int **) calloc(CLL_k+1, sizeof(int *));\r
+       require(FoStack!=NULL, "main: cannot allocate FoStack");\r
+       FoTOS = (int **) calloc(CLL_k+1, sizeof(int *));\r
+       require(FoTOS!=NULL, "main: cannot allocate FoTOS");\r
+       Cycles = (ListNode **) calloc(CLL_k+1, sizeof(ListNode *));\r
+       require(Cycles!=NULL, "main: cannot allocate Cycles List");\r
+    MR_CompromisedRules=empty;  /* MR14 */\r
+}\r
+\r
+static void\r
+#ifdef __USE_PROTOS\r
+help( void )\r
+#else\r
+help( )\r
+#endif\r
+{\r
+       Opt *p = options;\r
+       fprintf(stderr, "antlr [options] f1 f2 ... fn\n");\r
+       while ( *(p->option) != '*' )\r
+       {\r
+               fprintf(stderr, "    %-9s%s   %s\n",\r
+                                               p->option,\r
+                                               (p->arg)?"___":"   ",\r
+                                               p->descr);\r
+               p++;\r
+       }\r
+}\r
+\r
+/* The RulePtr array is filled in here.  RulePtr exists primarily\r
+ * so that sets of rules can be maintained for the FOLLOW caching\r
+ * mechanism found in rJunc().  RulePtr maps a rule num from 1 to n\r
+ * to a pointer to its RuleBlk junction where n is the number of rules.\r
+ */\r
+static void\r
+#ifdef __USE_PROTOS\r
+buildRulePtr( void )\r
+#else\r
+buildRulePtr( )\r
+#endif\r
+{\r
+       int r=1;\r
+       Junction *p  = SynDiag;\r
+       RulePtr = (Junction **) calloc(NumRules+1, sizeof(Junction *));\r
+       require(RulePtr!=NULL, "cannot allocate RulePtr array");\r
+       \r
+       while ( p!=NULL )\r
+       {\r
+               require(r<=NumRules, "too many rules???");\r
+               RulePtr[r++] = p;\r
+               p = (Junction *)p->p2;\r
+       }\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+dlgerror(const char *s)\r
+#else\r
+dlgerror(s)\r
+char *s;\r
+#endif\r
+{\r
+       fprintf(stderr, ErrHdr, FileStr[CurFile], zzline);\r
+       fprintf(stderr, " lexical error: %s (text was '%s')\n",\r
+                                       ((s == NULL) ? "Lexical error" : s), zzlextext);\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+readDescr( void )\r
+#else\r
+readDescr( )\r
+#endif\r
+{\r
+       zzerr = dlgerror;\r
+       input = NextFile();\r
+       if ( input==NULL ) fatal("No grammar description found (exiting...)");\r
+       ANTLR(grammar(), input);\r
+    tnodes_used_in_guard_predicates_etc=TnodesInUse;    /* MR10 */\r
+}\r
+\r
+FILE *\r
+#ifdef __USE_PROTOS\r
+NextFile( void )\r
+#else\r
+NextFile( )\r
+#endif\r
+{\r
+       FILE *f;\r
+\r
+       for (;;)\r
+       {\r
+               CurFile++;\r
+               if ( CurFile >= NumFiles ) return(NULL);\r
+               if ( ci_strequ(FileStr[CurFile],"stdin")) return stdin;\r
+               f = fopen(FileStr[CurFile], "r");\r
+               if ( f == NULL )\r
+               {\r
+                       warnNoFL( eMsg1("file %s doesn't exist; ignored", FileStr[CurFile]) );\r
+               }\r
+               else\r
+               {\r
+                       return(f);\r
+               }\r
+       }\r
+}\r
+\r
+/*\r
+ * Return a string corresponding to the output file name associated\r
+ * with the input file name passed in.\r
+ *\r
+ * Observe the following rules:\r
+ *\r
+ *             f.e             --> f".c"\r
+ *             f               --> f".c"\r
+ *             f.              --> f".c"\r
+ *             f.e.g   --> f.e".c"\r
+ *\r
+ * Where f,e,g are arbitrarily long sequences of characters in a file\r
+ * name.\r
+ *\r
+ * In other words, if a ".x" appears on the end of a file name, make it\r
+ * ".c".  If no ".x" appears, append ".c" to the end of the file name.\r
+ *\r
+ * C++ mode using .cpp not .c.\r
+ *\r
+ * Use malloc() for new string.\r
+ */\r
+\r
+char *\r
+#ifdef __USE_PROTOS\r
+outname( char *fs )\r
+#else\r
+outname( fs )\r
+char *fs;\r
+#endif\r
+{\r
+    if ( GenCC) {\r
+      return outnameX(fs,CPP_FILE_SUFFIX);\r
+    } else {\r
+      return outnameX(fs,".c");\r
+    };\r
+}\r
+\r
+char *\r
+#ifdef __USE_PROTOS\r
+outnameX( char *fs ,char *suffix)\r
+#else\r
+outnameX( fs , suffix )\r
+char *fs;\r
+char *suffix;\r
+#endif\r
+{\r
+       static char buf[MaxFileName+1];\r
+       char *p;\r
+       require(fs!=NULL&&*fs!='\0', "outname: NULL filename");\r
+\r
+       p = buf;\r
+       strcpy(buf, fs);\r
+       while ( *p != '\0' )  {p++;}                    /* Stop on '\0' */\r
+       while ( *p != '.' && p != buf ) {--p;}  /* Find '.' */\r
+       if ( p != buf ) *p = '\0';                              /* Found '.' */\r
+       require(strlen(buf) + 2 < (size_t)MaxFileName, "outname: filename too big");\r
+    strcat(buf,suffix);\r
+       return( buf );\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+fatalFL( char *err_, char *f, int l )\r
+#else\r
+fatalFL( err_, f, l )\r
+char *err_;\r
+char *f;\r
+int l;\r
+#endif\r
+{\r
+       fprintf(stderr, ErrHdr, f, l);\r
+       fprintf(stderr, " %s\n", err_);\r
+       cleanUp();\r
+       exit(PCCTS_EXIT_FAILURE);\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+fatal_intern( char *err_, char *f, int l )\r
+#else\r
+fatal_intern( err_, f, l )\r
+char *err_;\r
+char *f;\r
+int l;\r
+#endif\r
+{\r
+       fprintf(stderr, ErrHdr, f, l);\r
+       fprintf(stderr, " #$%%*&@# internal error: %s\n", err_);\r
+       fprintf(stderr, ErrHdr, f, l);\r
+       fprintf(stderr, " [complain to nearest government official\n");\r
+       fprintf(stderr, ErrHdr, f, l);\r
+       fprintf(stderr, "  or send hate-mail to parrt@parr-research.com;\n");\r
+       fprintf(stderr, ErrHdr, f, l);\r
+       fprintf(stderr, "  please pray to the ``bug'' gods that there is a trival fix.]\n");\r
+       cleanUp();\r
+       exit(PCCTS_EXIT_FAILURE);\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+cleanUp( void )\r
+#else\r
+cleanUp( )\r
+#endif\r
+{\r
+       if ( DefFile != NULL) fclose( DefFile );\r
+}\r
+\r
+/* sprintf up to 3 strings */\r
+char *\r
+#ifdef __USE_PROTOS\r
+eMsg3( char *s, char *a1, char *a2, char *a3 )\r
+#else\r
+eMsg3( s, a1, a2, a3 )\r
+char *s;\r
+char *a1;\r
+char *a2;\r
+char *a3;\r
+#endif\r
+{\r
+       static char buf[250];                   /* DANGEROUS as hell !!!!!! */\r
+       \r
+       sprintf(buf, s, a1, a2, a3);\r
+       return( buf );\r
+}\r
+\r
+/* sprintf a decimal */\r
+char *\r
+#ifdef __USE_PROTOS\r
+eMsgd( char *s, int d )\r
+#else\r
+eMsgd( s, d )\r
+char *s;\r
+int d;\r
+#endif\r
+{\r
+       static char buf[250];                   /* DANGEROUS as hell !!!!!! */\r
+       \r
+       sprintf(buf, s, d);\r
+       return( buf );\r
+}\r
+\r
+char *\r
+#ifdef __USE_PROTOS\r
+eMsgd2( char *s, int d1,int d2)\r
+#else\r
+eMsgd2( s, d1, d2 )\r
+char *s;\r
+int d1;\r
+int d2;\r
+#endif\r
+{\r
+       static char buf[250];                   /* DANGEROUS as hell !!!!!! */\r
+       \r
+       sprintf(buf, s, d1, d2);\r
+       return( buf );\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+s_fprT( FILE *f, set e )\r
+#else\r
+s_fprT( f, e )\r
+FILE *f;\r
+set e;\r
+#endif\r
+{\r
+       register unsigned *p;\r
+       unsigned *q;\r
+\r
+       if ( set_nil(e) ) return;\r
+       if ( (q=p=set_pdq(e)) == NULL ) fatal_internal("Can't alloc space for set_pdq");\r
+       fprintf(f, "{");\r
+       while ( *p != nil )\r
+       {\r
+               fprintf(f, " %s", TerminalString(*p));\r
+               p++;\r
+       }\r
+       fprintf(f, " }");\r
+       free((char *)q);\r
+}\r
+\r
+/* Return the token name or regular expression for a token number. */\r
+char *\r
+#ifdef __USE_PROTOS\r
+TerminalString( int token )\r
+#else\r
+TerminalString( token )\r
+int token;\r
+#endif\r
+{\r
+       int     j;\r
+        static    char    imag_name[20];\r
+\r
+       /* look in all lexclasses for the token */\r
+       if ( TokenString(token) != NULL ) return TokenString(token);\r
+       for (j=0; j<NumLexClasses; j++)\r
+       {\r
+               lexmode(j);\r
+               if ( ExprString(token) != NULL ) return ExprString(token);\r
+       }\r
+\r
+    if (1) {\r
+      sprintf(imag_name,"UnknownToken#%d",token);           /* MR13 */\r
+      return imag_name;                                     /* MR13 */\r
+    }\r
+\r
+       require(j<NumLexClasses, eMsgd("No label or expr for token %d",token));\r
+       return "invalid";\r
+}\r
+\r
+                    /* S i m p l e  I n t  S t a c k */\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+pushint( int i )\r
+#else\r
+pushint( i )\r
+int i;\r
+#endif\r
+{\r
+       require(isp>0, "pushint: stack overflow");\r
+       istack[--isp] = i;\r
+}\r
+\r
+int\r
+#ifdef __USE_PROTOS\r
+popint( void )\r
+#else\r
+popint( )\r
+#endif\r
+{\r
+       require(isp<MAX_INT_STACK, "popint: stack underflow");\r
+       return istack[isp++];\r
+}\r
+\r
+int\r
+#ifdef __USE_PROTOS\r
+istacksize( void )\r
+#else\r
+istacksize( )\r
+#endif\r
+{\r
+       return MAX_INT_STACK-isp;\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+istackreset( void )\r
+#else\r
+istackreset( )\r
+#endif\r
+{\r
+       isp = MAX_INT_STACK;\r
+}\r
+\r
+int\r
+#ifdef __USE_PROTOS\r
+istackempty( void )\r
+#else\r
+istackempty( )\r
+#endif\r
+{\r
+       return isp==MAX_INT_STACK;\r
+}\r
+\r
+int\r
+#ifdef __USE_PROTOS\r
+topint( void )\r
+#else\r
+topint( )\r
+#endif\r
+{\r
+       require(isp<MAX_INT_STACK, "topint: stack underflow");\r
+       return istack[isp];\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+ProcessArgs( int argc, char **argv, Opt *options )\r
+#else\r
+ProcessArgs( argc, argv, options )\r
+int argc;\r
+char **argv;\r
+Opt *options;\r
+#endif\r
+{\r
+       Opt *p;\r
+       require(argv!=NULL, "ProcessArgs: command line NULL");\r
+\r
+       while ( argc-- > 0 )\r
+       {\r
+               p = options;\r
+               while ( p->option != NULL )\r
+               {\r
+                       if ( strcmp(p->option, "*") == 0 ||\r
+                                ci_strequ(p->option, *argv) == 1 )\r
+                       {\r
+                               if ( p->arg )\r
+                               {\r
+/* MR9  26-Sep-97   Check for argv valid                */\r
+                    if (argc-- > 0) {\r
+                                       (*p->process)( *argv, *(argv+1) );\r
+                                           argv++;\r
+                    } else {\r
+fprintf(stderr,"error: required argument for option %s omitted\n",*argv);\r
+exit(PCCTS_EXIT_FAILURE);\r
+                    };\r
+                               }\r
+                               else\r
+                                       (*p->process)( *argv );\r
+                               break;\r
+                       }\r
+                       p++;\r
+               }\r
+               argv++;\r
+       }\r
+}\r
+\r
+static void \r
+#ifdef __USE_PROTOS\r
+CompleteContextGuards(void)\r
+#else\r
+CompleteContextGuards()\r
+#endif\r
+{\r
+    ListNode *      p;\r
+    Predicate *     pred;\r
+\r
+    if (ContextGuardPredicateList == NULL) return;\r
+\r
+    for (p=ContextGuardPredicateList->next; p != NULL; p=p->next) {\r
+      pred=(Predicate *)p->elem;\r
+      recomputeContextGuard(pred);\r
+    }\r
+}\r
+\r
+/* Go back into the syntax diagram and compute all meta tokens; i.e.\r
+ * turn all '.', ranges, token class refs etc... into actual token sets\r
+ */\r
+static void\r
+#ifdef __USE_PROTOS\r
+CompleteTokenSetRefs(void)\r
+#else\r
+CompleteTokenSetRefs()\r
+#endif\r
+{\r
+       ListNode *p;\r
+\r
+       if ( MetaTokenNodes==NULL ) return;\r
+       for (p = MetaTokenNodes->next; p!=NULL; p=p->next)\r
+       {\r
+               set a,b;\r
+\r
+               TokNode *q = (TokNode *)p->elem;\r
+               if ( q->wild_card )\r
+               {\r
+                       q->tset = all_tokens;\r
+               }\r
+               else if ( q->tclass!=NULL )\r
+               {\r
+                       if ( q->complement ) q->tset = set_dif(all_tokens, q->tclass->tset);\r
+                       else q->tset = q->tclass->tset;\r
+               }\r
+               else if ( q->upper_range!=0 )\r
+               {\r
+                       /* we have a range on our hands: make a set from q->token .. q->upper_range */\r
+                       int i;\r
+                       a = empty;\r
+                       for (i=q->token; i<=q->upper_range; i++) { set_orel(i, &a); }   /* MR13 */\r
+\r
+/* MR13 */    if (q->complement) {\r
+/* MR13 */      q->tset = set_dif(all_tokens, a);\r
+/* MR13 */        set_free(a);\r
+/* MR13 */      } else {\r
+/* MR13 */           q->tset = a;\r
+/* MR13 */      }\r
+\r
+        }\r
+\r
+               /* at this point, it can only be a complemented single token */\r
+               else if ( q->complement )\r
+               {\r
+                       a = set_of(q->token);\r
+                       b = set_dif(all_tokens, a);\r
+                       set_free(a);\r
+                       q->tset=b;\r
+               }\r
+               else fatal("invalid meta token");\r
+       }\r
+}\r
+\r
+/* MR10: Jeff Vincent\r
+   MR10: Changed to remove directory information from n only if\r
+   MR10: if OutputDirectory was changed by user (-o option)\r
+*/\r
+\r
+char *\r
+#ifdef __USE_PROTOS\r
+OutMetaName(char *n)\r
+#else\r
+OutMetaName(n)\r
+char *n;\r
+#endif\r
+{      \r
+    static char *dir_sym = DirectorySymbol;\r
+    static char newname[MaxFileName+1];\r
+    char *p;\r
+\r
+       /* If OutputDirectory is same as TopDirectory (platform default) then leave n alone. */\r
+    if (strcmp(OutputDirectory, TopDirectory) == 0)            /* TopDirectory is "." on Unix. */\r
+               return n;\r
+\r
+       /* p will point to filename without path information */\r
+       if ((p = strrchr(n, *dir_sym)) != NULL)                         /* Directory symbol is "/" on Unix. */\r
+               p++;\r
+       else\r
+               p = n;\r
+\r
+       /* Copy new output directory into newname[] */\r
+       strcpy(newname, OutputDirectory);\r
+\r
+       /* if new output directory does not have trailing dir_sym, add it! */\r
+       if (newname[strlen(newname)-1] != *dir_sym) {\r
+               strcat(newname, dir_sym);\r
+       }\r
+       strcat(newname, p);\r
+       return newname;\r
+}\r
+\r
+char *\r
+#ifdef __USE_PROTOS\r
+pcctsBaseName(char *n) /* MR32 */\r
+#else\r
+pcctsBaseName(n)\r
+char *n;\r
+#endif\r
+{\r
+    static char newname[MaxFileName+1];\r
+    static char* dir_sym = DirectorySymbol;\r
+    int count = 0;\r
+    char *p;\r
+\r
+    p = n;\r
+\r
+    while ( *p != '\0' )  {p++;}                    /* go to end of string */\r
+    while ( (*p != *dir_sym) && (p != n) ) {--p;}   /* Find last DirectorySymbol */\r
+    while ( *p == *dir_sym) p++;                    /* step forward if we're on a dir symbol */\r
+    while ( *p != '\0' && *p != '.')\r
+    {\r
+        newname[count++] = *p;\r
+        p++;\r
+    }                                               /* create a new name */\r
+    newname[count] = '\0';\r
+    return newname;\r
+}\r
+\r
+static void\r
+#ifdef __USE_PROTOS\r
+ensure_no_C_file_collisions(char *class_c_file)\r
+#else\r
+ensure_no_C_file_collisions(class_c_file)\r
+char *class_c_file;\r
+#endif\r
+{\r
+       int i;\r
+\r
+       for (i=0; i<NumFiles; i++)\r
+       {\r
+\r
+#ifdef PCCTS_CASE_INSENSITIVE_FILE_NAME\r
+               /* assume that file names are case insensitive */\r
+               if ( STRICMP(outname(FileStr[i]), class_c_file)==0 )\r
+#else\r
+               if ( strcmp(outname(FileStr[i]), class_c_file)==0 )\r
+#endif\r
+               {\r
+                       fatal(eMsg1("class def output file conflicts with parser output file: %s",\r
+                                               outname(FileStr[i])));\r
+               }\r
+       }\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+warnNoFL(char *err)\r
+#else\r
+warnNoFL(err)\r
+char *err;\r
+#endif\r
+{\r
+       fprintf(stderr, "warning: %s\n", err);\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+warnFL(char *err,char *f,int l)\r
+#else\r
+warnFL(err,f,l)\r
+char *f;\r
+int l;\r
+char *err;\r
+#endif\r
+{\r
+       fprintf(stderr, ErrHdr, f, l);                                          \r
+       fprintf(stderr, " warning: %s\n", err);\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+warn(char *err)                                                                                                \r
+#else\r
+warn(err)                                                                                              \r
+char *err;\r
+#endif\r
+{\r
+       /* back up the file number if we hit an error at the end of the last file */\r
+       if ( CurFile >= NumFiles && CurFile >= 1 ) CurFile--;\r
+       fprintf(stderr, ErrHdr, FileStr[CurFile], zzline);\r
+       fprintf(stderr, " warning: %s\n", err);\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+warnNoCR( char *err )\r
+#else\r
+warnNoCR( err )                                                                                        \r
+char *err;\r
+#endif\r
+{\r
+       /* back up the file number if we hit an error at the end of the last file */\r
+       if ( CurFile >= NumFiles && CurFile >= 1 ) CurFile--;\r
+       fprintf(stderr, ErrHdr, FileStr[CurFile], zzline);\r
+       fprintf(stderr, " warning: %s", err);\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+errNoFL(char *err)\r
+#else\r
+errNoFL(err)\r
+char *err;\r
+#endif\r
+{\r
+       fprintf(stderr, "error: %s\n", err);\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+errFL(char *err,char *f,int l)\r
+#else\r
+errFL(err,f,l)\r
+char *err;\r
+char *f;\r
+int l;\r
+#endif\r
+{\r
+       fprintf(stderr, ErrHdr, f, l);                                          \r
+       fprintf(stderr, " error: %s\n", err);\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+err(char *err)                                                                                         \r
+#else\r
+err(err)                                                                                               \r
+char *err;\r
+#endif\r
+{\r
+       /* back up the file number if we hit an error at the end of the last file */\r
+       if ( CurFile >= NumFiles && CurFile >= 1 ) CurFile--;\r
+       fprintf(stderr, ErrHdr, FileStr[CurFile], zzline);\r
+       fprintf(stderr, " error: %s\n", err);\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+errNoCR( char *err )                                                                                   \r
+#else\r
+errNoCR( err )                                                                                 \r
+char *err;\r
+#endif\r
+{\r
+       /* back up the file number if we hit an error at the end of the last file */\r
+       if ( CurFile >= NumFiles && CurFile >= 1 ) CurFile--;\r
+       fprintf(stderr, ErrHdr, FileStr[CurFile], zzline);\r
+       fprintf(stderr, " error: %s", err);\r
+}\r
+\r
+UserAction *\r
+#ifdef __USE_PROTOS\r
+newUserAction(char *s)\r
+#else\r
+newUserAction(s)\r
+char *s;\r
+#endif\r
+{\r
+       UserAction *ua = (UserAction *) calloc(1, sizeof(UserAction));\r
+       require(ua!=NULL, "cannot allocate UserAction");\r
+\r
+       ua->action = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));\r
+       strcpy(ua->action, s);\r
+       return ua;\r
+}\r
+\r
+/* Added by TJP September 1994 */\r
+/* Take in file.h and return file_h; names w/o '.'s are left alone */\r
+char *\r
+#ifdef __USE_PROTOS\r
+gate_symbol(char *name)\r
+#else\r
+gate_symbol(name)\r
+char *name;\r
+#endif\r
+{\r
+       static char buf[100];\r
+       char *p;\r
+       sprintf(buf, "%s", name);\r
+\r
+       for (p=buf; *p!='\0'; p++)\r
+       {\r
+               if ( *p=='.' ) *p = '_';\r
+       }\r
+       return buf;\r
+}\r
+\r
+char *\r
+#ifdef __USE_PROTOS\r
+makeAltID(int blockid, int altnum)\r
+#else\r
+makeAltID(blockid, altnum)\r
+int blockid;\r
+int altnum;\r
+#endif\r
+{\r
+       static char buf[100];\r
+       char *p;\r
+       sprintf(buf, "_blk%d_alt%d", blockid, altnum);\r
+       p = (char *)malloc(strlen(buf)+1);\r
+       strcpy(p, buf);\r
+       return p;\r
+}\r
diff --git a/Tools/CodeTools/Source/Pccts/antlr/makefile b/Tools/CodeTools/Source/Pccts/antlr/makefile
new file mode 100644 (file)
index 0000000..2aa6cdf
--- /dev/null
@@ -0,0 +1,218 @@
+#\r
+# Makefile for ANTLR 1.33\r
+#\r
+# SOFTWARE RIGHTS\r
+#\r
+# We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
+# Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
+# company may do whatever they wish with source code distributed with\r
+# PCCTS or the code generated by PCCTS, including the incorporation of\r
+# PCCTS, or its output, into commerical software.\r
+# \r
+# We encourage users to develop software with PCCTS.  However, we do ask\r
+# that credit is given to us for developing PCCTS.  By "credit",\r
+# we mean that if you incorporate our source code into one of your\r
+# programs (commercial product, research project, or otherwise) that you\r
+# acknowledge this fact somewhere in the documentation, research report,\r
+# etc...  If you like PCCTS and have developed a nice tool with the\r
+# output, please mention that you developed it using PCCTS.  In\r
+# addition, we ask that this header remain intact in our source code.\r
+# As long as these guidelines are kept, we expect to continue enhancing\r
+# this system and expect to make other tools available as they are\r
+# completed.\r
+#\r
+# ANTLR 1.33\r
+# Terence Parr\r
+# Parr Research Corporation\r
+# with Purdue University\r
+# and AHPCRC, University of Minnesota\r
+# 1989-1995\r
+#\r
+# Ported to Borland C++, IBM C-Set/2 and Microsoft 6.0 by\r
+# Ed Harfmann\r
+# Micro Data Base Systems\r
+# Lafayette, Indiana\r
+#\r
+SET=../support/set\r
+PCCTS_H=../h\r
+\r
+##\r
+## Uncomment the appropriate section to build\r
+## (both targets and 'make' variable definitions)\r
+## Note that UNIX is the default\r
+##\r
+\r
+#\r
+#   OS/2 & DOS 16 bit using MSC 6.0\r
+#\r
+#CC=cl\r
+#ANTLR=..\bin\antlr\r
+#DLG=..\bin\dlg\r
+#CFLAGS= -I. -I$(SET) -I$(PCCTS_H) /AL /Za /W3 -DPC -DUSER_ZZSYN\r
+#OUT_OBJ = -Fo\r
+#LIBS=/NOD:LLIBCE LLIBCEP\r
+#OBJ_EXT = obj\r
+#\r
+#antlr.exe: antlr.obj scan.obj err.obj bits.obj build.obj fset2.obj \\r
+#        fset.obj gen.obj globals.obj hash.obj lex.obj main.obj \\r
+#        misc.obj set.obj pred.obj egamn.obj\r
+#       link @<<\r
+#$** /NOI\r
+#$@ /STACK:14336\r
+#\r
+#$(LIBS: = +^\r
+#)\r
+#$(DEF_FILE) $(LFLAGS) ;\r
+#<<\r
+#        bind $@ c:\os2\doscalls.lib\r
+#        copy *.exe ..\bin\r
+#\r
+\r
+#\r
+#   Borland C++ for DOS\r
+#\r
+#CC=bcc\r
+#ANTLR=..\bin\antlr\r
+#DLG=..\bin\dlg\r
+#CFLAGS= -I. -I$(SET) -I$(PCCTS_H) -ml -ff- -w- -DPC -DUSER_ZZSYN\r
+#OUT_OBJ = -o\r
+#LIBS= emu mathl cl\r
+#OBJ_EXT = obj\r
+#\r
+#antlr.exe: antlr.obj scan.obj err.obj bits.obj build.obj fset2.obj \\r
+#        fset.obj gen.obj globals.obj hash.obj lex.obj main.obj \\r
+#        misc.obj set.obj pred.obj egman.obj mrhoist.obj fcache.obj\r
+#       tlink @&&|\r
+#C0L $**\r
+#$@ /Tde /c\r
+#\r
+#$(LIBS)\r
+#$(DEF_FILE) $(LFLAGS) ;\r
+#|\r
+#        copy *.exe ..\bin\r
+#\r
+\r
+#\r
+# C-Set/2 for OS/2\r
+#\r
+#CC=icc\r
+#CFLAGS= -I. -I$(SET) -I$(PCCTS_H) /Sa /W3 -DUSER_ZZSYN -D__STDC__\r
+#OUT_OBJ = -Fo\r
+#LIBS=\r
+#ANTLR=..\bin\antlr\r
+#DLG=..\bin\dlg\r
+#OBJ_EXT = obj\r
+#\r
+#antlr.exe: antlr.obj scan.obj err.obj bits.obj build.obj fset2.obj \\r
+#        fset.obj gen.obj globals.obj hash.obj lex.obj main.obj \\r
+#        misc.obj set.obj pred.obj egman.obj mrhoist.obj fcache.obj\r
+#        link386 @<<\r
+#$** /NOI\r
+#$@ /STACK:32768\r
+#\r
+#$(LIBS: = +^\r
+#)\r
+#$(DEF_FILE) $(LFLAGS) ;\r
+#<<\r
+#        copy *.exe ..\bin\r
+#\r
+\r
+#\r
+# Borland C++ for OS/2\r
+#\r
+#CC=bcc\r
+#CFLAGS= -I. -I$(SET) -I$(PCCTS_H) -w- -v -DUSER_ZZSYN\r
+#OUT_OBJ = -o\r
+#LIBS= c2 os2\r
+#\r
+#ANTLR=..\bin\antlr\r
+#DLG=..\bin\dlg\r
+#OBJ_EXT = obj\r
+#antlr.exe: antlr.obj scan.obj err.obj bits.obj build.obj fset2.obj \\r
+#        fset.obj gen.obj globals.obj hash.obj lex.obj main.obj \\r
+#        misc.obj set.obj pred.obj egman.obj mrhoist.obj fcache.obj\r
+#        tlink @&&|\r
+#c02 $** -c -v\r
+#antlr.exe\r
+#\r
+#C2 os2\r
+#\r
+#|\r
+#        copy *.exe ..\bin\r
+#\r
+\r
+# *********** Target list of PC machines ***********\r
+#\r
+# Don't worry about the ambiguity messages coming from antlr\r
+# for making antlr.c etc...  [should be 10 of them, I think]\r
+#\r
+#antlr.c stdpccts.h parser.dlg tokens.h err.c : antlr.g\r
+#      $(ANTLR) antlr.g\r
+#\r
+#antlr.$(OBJ_EXT): antlr.c mode.h tokens.h\r
+#\r
+#scan.$(OBJ_EXT): scan.c mode.h tokens.h\r
+#\r
+#scan.c mode.h: parser.dlg\r
+#      $(DLG) -C2 parser.dlg scan.c\r
+#\r
+#set.$(OBJ_EXT): $(SET)/set.c\r
+#      $(CC) $(CFLAGS) -c $(OUT_OBJ)set.$(OBJ_EXT) $(SET)/set.c\r
+\r
+\r
+\r
+#\r
+#   UNIX  (default)\r
+#\r
+CC=gcc\r
+COPT=-O\r
+ANTLR=${BIN_DIR}/antlr\r
+DLG=${BIN_DIR}/dlg\r
+OBJ_EXT=o\r
+OUT_OBJ = -o\r
+CFLAGS= $(COPT) -I. -I$(SET) -I$(PCCTS_H) -DUSER_ZZSYN $(COTHER) -DZZLEXBUFSIZE=65536\r
+#\r
+# SGI Users, use this CFLAGS\r
+#\r
+#CFLAGS= -O -I. -I$(SET) -I$(PCCTS_H) -DUSER_ZZSYN -woff 3262\r
+OBJ=antlr.o scan.o err.o bits.o build.o fset2.o fset.o gen.o  \\r
+        globals.o hash.o lex.o main.o misc.o set.o pred.o egman.o mrhoist.o fcache.o\r
+\r
+antlr : $(OBJ) $(SRC)\r
+               $(CC) $(CFLAGS) -o $(BIN_DIR)/antlr $(OBJ)\r
+\r
+# what files does PCCTS generate (both ANTLR and DLG)\r
+PCCTS_GEN=antlr.c scan.c err.c tokens.h mode.h parser.dlg stdpccts.h remap.h\r
+\r
+SRC=antlr.c scan.c err.c bits.c build.c fset2.c fset.c gen.c globals.c \\r
+       hash.c lex.c main.c misc.c $(SET)/set.c pred.c egman.c mrhoist.c fcache.c\r
+\r
+#\r
+# Don't worry about the ambiguity messages coming from antlr\r
+# for making antlr.c etc...  [should be 10 of them, I think]\r
+#\r
+#antlr.c stdpccts.h parser.dlg tokens.h err.c : antlr.g\r
+#      $(ANTLR) -gh antlr.g\r
+\r
+antlr.o : antlr.c mode.h tokens.h\r
+\r
+scan.o : scan.c mode.h tokens.h\r
+\r
+#scan.c mode.h: parser.dlg\r
+#      $(DLG) -C2 parser.dlg scan.c\r
+\r
+set.o : $(SET)/set.c\r
+       $(CC) $(CFLAGS) -c -o set.o $(SET)/set.c\r
+\r
+\r
+#\r
+# ****** These next targets are common to UNIX and PC world ********\r
+#\r
+\r
+#clean up all the intermediate files\r
+clean:\r
+       rm -f *.$(OBJ_EXT) core\r
+\r
+#remove everything in clean plus the PCCTS files generated\r
+scrub:\r
+       rm -f $(PCCTS_GEN) *.$(OBJ_EXT) core\r
diff --git a/Tools/CodeTools/Source/Pccts/antlr/makefile.cygwin b/Tools/CodeTools/Source/Pccts/antlr/makefile.cygwin
new file mode 100644 (file)
index 0000000..956de0b
--- /dev/null
@@ -0,0 +1,219 @@
+#\r
+# Makefile for ANTLR 1.33\r
+#\r
+# SOFTWARE RIGHTS\r
+#\r
+# We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
+# Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
+# company may do whatever they wish with source code distributed with\r
+# PCCTS or the code generated by PCCTS, including the incorporation of\r
+# PCCTS, or its output, into commerical software.\r
+# \r
+# We encourage users to develop software with PCCTS.  However, we do ask\r
+# that credit is given to us for developing PCCTS.  By "credit",\r
+# we mean that if you incorporate our source code into one of your\r
+# programs (commercial product, research project, or otherwise) that you\r
+# acknowledge this fact somewhere in the documentation, research report,\r
+# etc...  If you like PCCTS and have developed a nice tool with the\r
+# output, please mention that you developed it using PCCTS.  In\r
+# addition, we ask that this header remain intact in our source code.\r
+# As long as these guidelines are kept, we expect to continue enhancing\r
+# this system and expect to make other tools available as they are\r
+# completed.\r
+#\r
+# ANTLR 1.33\r
+# Terence Parr\r
+# Parr Research Corporation\r
+# with Purdue University\r
+# and AHPCRC, University of Minnesota\r
+# 1989-1995\r
+#\r
+# Ported to Borland C++, IBM C-Set/2 and Microsoft 6.0 by\r
+# Ed Harfmann\r
+# Micro Data Base Systems\r
+# Lafayette, Indiana\r
+#\r
+SET=../support/set\r
+PCCTS_H=../h\r
+\r
+##\r
+## Uncomment the appropriate section to build\r
+## (both targets and 'make' variable definitions)\r
+## Note that UNIX is the default\r
+##\r
+\r
+#\r
+#   OS/2 & DOS 16 bit using MSC 6.0\r
+#\r
+#CC=cl\r
+#ANTLR=..\bin\antlr\r
+#DLG=..\bin\dlg\r
+#CFLAGS= -I. -I$(SET) -I$(PCCTS_H) /AL /Za /W3 -DPC -DUSER_ZZSYN\r
+#OUT_OBJ = -Fo\r
+#LIBS=/NOD:LLIBCE LLIBCEP\r
+#OBJ_EXT = obj\r
+#\r
+#antlr.exe: antlr.obj scan.obj err.obj bits.obj build.obj fset2.obj \\r
+#        fset.obj gen.obj globals.obj hash.obj lex.obj main.obj \\r
+#        misc.obj set.obj pred.obj egamn.obj\r
+#       link @<<\r
+#$** /NOI\r
+#$@ /STACK:14336\r
+#\r
+#$(LIBS: = +^\r
+#)\r
+#$(DEF_FILE) $(LFLAGS) ;\r
+#<<\r
+#        bind $@ c:\os2\doscalls.lib\r
+#        copy *.exe ..\bin\r
+#\r
+\r
+#\r
+#   Borland C++ for DOS\r
+#\r
+#CC=bcc\r
+#ANTLR=..\bin\antlr\r
+#DLG=..\bin\dlg\r
+#CFLAGS= -I. -I$(SET) -I$(PCCTS_H) -ml -ff- -w- -DPC -DUSER_ZZSYN\r
+#OUT_OBJ = -o\r
+#LIBS= emu mathl cl\r
+#OBJ_EXT = obj\r
+#\r
+#antlr.exe: antlr.obj scan.obj err.obj bits.obj build.obj fset2.obj \\r
+#        fset.obj gen.obj globals.obj hash.obj lex.obj main.obj \\r
+#        misc.obj set.obj pred.obj egman.obj mrhoist.obj fcache.obj\r
+#       tlink @&&|\r
+#C0L $**\r
+#$@ /Tde /c\r
+#\r
+#$(LIBS)\r
+#$(DEF_FILE) $(LFLAGS) ;\r
+#|\r
+#        copy *.exe ..\bin\r
+#\r
+\r
+#\r
+# C-Set/2 for OS/2\r
+#\r
+#CC=icc\r
+#CFLAGS= -I. -I$(SET) -I$(PCCTS_H) /Sa /W3 -DUSER_ZZSYN -D__STDC__\r
+#OUT_OBJ = -Fo\r
+#LIBS=\r
+#ANTLR=..\bin\antlr\r
+#DLG=..\bin\dlg\r
+#OBJ_EXT = obj\r
+#\r
+#antlr.exe: antlr.obj scan.obj err.obj bits.obj build.obj fset2.obj \\r
+#        fset.obj gen.obj globals.obj hash.obj lex.obj main.obj \\r
+#        misc.obj set.obj pred.obj egman.obj mrhoist.obj fcache.obj\r
+#        link386 @<<\r
+#$** /NOI\r
+#$@ /STACK:32768\r
+#\r
+#$(LIBS: = +^\r
+#)\r
+#$(DEF_FILE) $(LFLAGS) ;\r
+#<<\r
+#        copy *.exe ..\bin\r
+#\r
+\r
+#\r
+# Borland C++ for OS/2\r
+#\r
+#CC=bcc\r
+#CFLAGS= -I. -I$(SET) -I$(PCCTS_H) -w- -v -DUSER_ZZSYN\r
+#OUT_OBJ = -o\r
+#LIBS= c2 os2\r
+#\r
+#ANTLR=..\bin\antlr\r
+#DLG=..\bin\dlg\r
+#OBJ_EXT = obj\r
+#antlr.exe: antlr.obj scan.obj err.obj bits.obj build.obj fset2.obj \\r
+#        fset.obj gen.obj globals.obj hash.obj lex.obj main.obj \\r
+#        misc.obj set.obj pred.obj egman.obj mrhoist.obj fcache.obj\r
+#        tlink @&&|\r
+#c02 $** -c -v\r
+#antlr.exe\r
+#\r
+#C2 os2\r
+#\r
+#|\r
+#        copy *.exe ..\bin\r
+#\r
+\r
+# *********** Target list of PC machines ***********\r
+#\r
+# Don't worry about the ambiguity messages coming from antlr\r
+# for making antlr.c etc...  [should be 10 of them, I think]\r
+#\r
+#antlr.c stdpccts.h parser.dlg tokens.h err.c : antlr.g\r
+#      $(ANTLR) antlr.g\r
+#\r
+#antlr.$(OBJ_EXT): antlr.c mode.h tokens.h\r
+#\r
+#scan.$(OBJ_EXT): scan.c mode.h tokens.h\r
+#\r
+#scan.c mode.h: parser.dlg\r
+#      $(DLG) -C2 parser.dlg scan.c\r
+#\r
+#set.$(OBJ_EXT): $(SET)/set.c\r
+#      $(CC) $(CFLAGS) -c $(OUT_OBJ)set.$(OBJ_EXT) $(SET)/set.c\r
+\r
+\r
+\r
+#\r
+#   UNIX  (default)\r
+#\r
+BIN_DIR=../../../../bin\r
+CC=gcc\r
+COPT=-O\r
+ANTLR=$(BIN_DIR)/antlr.exe\r
+DLG=${BIN_DIR}/dlg.exe\r
+OBJ_EXT=o\r
+OUT_OBJ = -o\r
+CFLAGS= $(COPT) -I. -I$(SET) -I$(PCCTS_H) -DUSER_ZZSYN $(COTHER) -DZZLEXBUFSIZE=65536\r
+#\r
+# SGI Users, use this CFLAGS\r
+#\r
+#CFLAGS= -O -I. -I$(SET) -I$(PCCTS_H) -DUSER_ZZSYN -woff 3262\r
+OBJ=antlr.o scan.o err.o bits.o build.o fset2.o fset.o gen.o  \\r
+        globals.o hash.o lex.o main.o misc.o set.o pred.o egman.o mrhoist.o fcache.o\r
+\r
+antlr : $(OBJ) $(SRC)\r
+               $(CC) $(CFLAGS) -o $(BIN_DIR)/antlr.exe $(OBJ)\r
+\r
+# what files does PCCTS generate (both ANTLR and DLG)\r
+PCCTS_GEN=antlr.c scan.c err.c tokens.h mode.h parser.dlg stdpccts.h remap.h\r
+\r
+SRC=antlr.c scan.c err.c bits.c build.c fset2.c fset.c gen.c globals.c \\r
+       hash.c lex.c main.c misc.c $(SET)/set.c pred.c egman.c mrhoist.c fcache.c\r
+\r
+#\r
+# Don't worry about the ambiguity messages coming from antlr\r
+# for making antlr.c etc...  [should be 10 of them, I think]\r
+#\r
+#antlr.c stdpccts.h parser.dlg tokens.h err.c : antlr.g\r
+#      $(ANTLR) -gh antlr.g\r
+\r
+antlr.o : antlr.c mode.h tokens.h\r
+\r
+scan.o : scan.c mode.h tokens.h\r
+\r
+#scan.c mode.h: parser.dlg\r
+#      $(DLG) -C2 parser.dlg scan.c\r
+\r
+set.o : $(SET)/set.c\r
+       $(CC) $(CFLAGS) -c -o set.o $(SET)/set.c\r
+\r
+\r
+#\r
+# ****** These next targets are common to UNIX and PC world ********\r
+#\r
+\r
+#clean up all the intermediate files\r
+clean:\r
+       rm -f *.$(OBJ_EXT) core\r
+\r
+#remove everything in clean plus the PCCTS files generated\r
+scrub:\r
+       rm -f $(PCCTS_GEN) *.$(OBJ_EXT) core\r
diff --git a/Tools/CodeTools/Source/Pccts/antlr/makefile1 b/Tools/CodeTools/Source/Pccts/antlr/makefile1
new file mode 100644 (file)
index 0000000..dffc709
--- /dev/null
@@ -0,0 +1,96 @@
+#\r
+# Makefile for ANTLR 1.33\r
+#\r
+# SOFTWARE RIGHTS\r
+#\r
+# We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
+# Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
+# company may do whatever they wish with source code distributed with\r
+# PCCTS or the code generated by PCCTS, including the incorporation of\r
+# PCCTS, or its output, into commerical software.\r
+# \r
+# We encourage users to develop software with PCCTS.  However, we do ask\r
+# that credit is given to us for developing PCCTS.  By "credit",\r
+# we mean that if you incorporate our source code into one of your\r
+# programs (commercial product, research project, or otherwise) that you\r
+# acknowledge this fact somewhere in the documentation, research report,\r
+# etc...  If you like PCCTS and have developed a nice tool with the\r
+# output, please mention that you developed it using PCCTS.  In\r
+# addition, we ask that this header remain intact in our source code.\r
+# As long as these guidelines are kept, we expect to continue enhancing\r
+# this system and expect to make other tools available as they are\r
+# completed.\r
+#\r
+# ANTLR 1.33\r
+# Terence Parr\r
+# Parr Research Corporation\r
+# with Purdue University\r
+# and AHPCRC, University of Minnesota\r
+# 1989-1995\r
+#\r
+# Ported to Borland C++, IBM C-Set/2 and Microsoft 6.0 by\r
+# Ed Harfmann\r
+# Micro Data Base Systems\r
+# Lafayette, Indiana\r
+#\r
+SET=../support/set\r
+PCCTS_H=../h\r
+\r
+#\r
+#   UNIX  (default)\r
+#\r
+CC=cc\r
+ANTLR=${WORKSPACE}/Tools/bin/antlr\r
+DLG=${WORKSPACE}/Tools/bin/dlg\r
+OBJ_EXT=o\r
+OUT_OBJ = -o\r
+ANSI=-ansi\r
+AOTHER=\r
+CFLAGS= -O0 -g -I. -I$(SET) -I$(PCCTS_H) -DUSER_ZZSYN $(COTHER) $(ANSI) -DZZLEXBUFSIZE=32000\r
+#\r
+# SGI Users, use this CFLAGS\r
+#\r
+#CFLAGS= -O -I. -I$(SET) -I$(PCCTS_H) -DUSER_ZZSYN -woff 3262\r
+\r
+OBJ=antlr.o scan.o err.o bits.o build.o fset2.o fset.o gen.o \\r
+        globals.o hash.o lex.o main.o misc.o set.o pred.o egman.o mrhoist.o fcache.o $(OBJOTHER)\r
+\r
+antlr : $(OBJ) $(SRC)\r
+               $(CC) $(CFLAGS) -o antlr $(OBJ)\r
+               mv antlr ${WORKSPACE}/Tools/bin\r
+\r
+# what files does PCCTS generate (both ANTLR and DLG)\r
+PCCTS_GEN=antlr.c scan.c err.c tokens.h mode.h parser.dlg stdpccts.h remap.h\r
+\r
+SRC=antlr.c scan.c err.c bits.c build.c fset2.c fset.c gen.c globals.c \\r
+       hash.c lex.c main.c misc.c $(SET)/set.c pred.c egman.c mrhoist.c fcache.c\r
+\r
+#\r
+# Don't worry about the ambiguity messages coming from antlr\r
+# for making antlr.c etc...  [should be 10 of them, I think]\r
+#\r
+antlr.c stdpccts.h parser.dlg tokens.h err.c : antlr.g\r
+       $(ANTLR) -gh antlr.g $(AOTHER)\r
+\r
+antlr.o : antlr.c mode.h tokens.h\r
+\r
+scan.o : scan.c mode.h tokens.h\r
+\r
+scan.c mode.h: parser.dlg\r
+       $(DLG) -C2 parser.dlg scan.c\r
+\r
+set.o : $(SET)/set.c\r
+       $(CC) $(CFLAGS) -c -o set.o $(SET)/set.c\r
+\r
+\r
+#\r
+# ****** These next targets are common to UNIX and PC world ********\r
+#\r
+\r
+#clean up all the intermediate files\r
+clean:\r
+       rm -f *.$(OBJ_EXT) core\r
+\r
+#remove everything in clean plus the PCCTS files generated\r
+scrub:\r
+       rm -f $(PCCTS_GEN) *.$(OBJ_EXT) core\r
diff --git a/Tools/CodeTools/Source/Pccts/antlr/misc.c b/Tools/CodeTools/Source/Pccts/antlr/misc.c
new file mode 100644 (file)
index 0000000..3f58da3
--- /dev/null
@@ -0,0 +1,1864 @@
+/*\r
+ * misc.c\r
+ *\r
+ * Manage tokens, regular expressions.\r
+ * Print methods for debugging\r
+ * Compute follow lists onto tail ends of rules.\r
+ *\r
+ * The following functions are visible:\r
+ *\r
+ *             int             addTname(char *);               Add token name\r
+ *             int             addTexpr(char *);               Add token expression\r
+ *             int             Tnum(char *);                   Get number of expr/token\r
+ *             void    Tklink(char *, char *); Link a name with an expression\r
+ *             int             hasAction(expr);                Does expr already have action assigned?\r
+ *             void    setHasAction(expr);             Indicate that expr now has an action\r
+ *             Entry   *newEntry(char *,int);  Create new table entry with certain size\r
+ *             void    list_add(ListNode **list, char *e)\r
+ *      void    list_free(ListNode **list, int freeData);   *** MR10 ***\r
+ *             void    list_apply(ListNode *list, void (*f)())\r
+ *             void    lexclass(char *m);              switch to new/old lexical class\r
+ *             void    lexmode(int i);                 switch to old lexical class i\r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
+ * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
+ * company may do whatever they wish with source code distributed with\r
+ * PCCTS or the code generated by PCCTS, including the incorporation of\r
+ * PCCTS, or its output, into commerical software.\r
+ *\r
+ * We encourage users to develop software with PCCTS.  However, we do ask\r
+ * that credit is given to us for developing PCCTS.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like PCCTS and have developed a nice tool with the\r
+ * output, please mention that you developed it using PCCTS.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * ANTLR 1.33\r
+ * Terence Parr\r
+ * Parr Research Corporation\r
+ * with Purdue University and AHPCRC, University of Minnesota\r
+ * 1989-2001\r
+ */\r
+\r
+#include <stdio.h>\r
+#include "pcctscfg.h"\r
+#include "set.h"\r
+#include "syn.h"\r
+#include "hash.h"\r
+#include "generic.h"\r
+#include "dlgdef.h"\r
+#include <ctype.h>\r
+\r
+static int tsize=TSChunk;              /* size of token str arrays */\r
+\r
+static void\r
+#ifdef __USE_PROTOS\r
+RemapForcedTokensInSyntaxDiagram(Node *);\r
+#else\r
+RemapForcedTokensInSyntaxDiagram();\r
+#endif\r
+\r
+                               /* T o k e n  M a n i p u l a t i o n */\r
+\r
+/*\r
+ * add token 't' to the TokenStr/Expr array.  Make more room if necessary.\r
+ * 't' is either an expression or a token name.\r
+ *\r
+ * There is only one TokenStr array, but multiple ExprStr's.  Therefore,\r
+ * for each lex class (element of lclass) we must extend the ExprStr array.\r
+ * ExprStr's and TokenStr are always all the same size.\r
+ *\r
+ * Also, there is a Texpr hash table for each automaton.\r
+ */\r
+static void\r
+#ifdef __USE_PROTOS\r
+Ttrack( char *t )\r
+#else\r
+Ttrack( t )\r
+char *t;\r
+#endif\r
+{\r
+       if ( TokenNum >= tsize )        /* terminal table overflow? */\r
+       {\r
+               char **p;\r
+               int i, more, j;\r
+\r
+               more = TSChunk * (1 + ((TokenNum-tsize) / TSChunk));\r
+               tsize += more;\r
+               TokenStr = (char **) realloc((char *)TokenStr, tsize*sizeof(char *));\r
+               require(TokenStr != NULL, "Ttrack: can't extend TokenStr");\r
+               for (i=0; i<NumLexClasses; i++)\r
+               {\r
+                       lclass[i].exprs = (char **)\r
+                                                         realloc((char *)lclass[i].exprs, tsize*sizeof(char *));\r
+                       require(lclass[i].exprs != NULL, "Ttrack: can't extend ExprStr");\r
+                       for (p= &lclass[i].exprs[tsize-more],j=1; j<=more; j++) *p++ = NULL;\r
+               }\r
+               for (p= &TokenStr[tsize-more],i=1; i<=more; i++) *p++ = NULL;\r
+               lexmode( CurrentLexClass ); /* reset ExprStr in case table moved */\r
+       }\r
+       /* note: we use the actual ExprStr/TokenStr array\r
+        * here as TokenInd doesn't exist yet\r
+        */\r
+       if ( *t == '"' ) ExprStr[TokenNum] = t;\r
+       else TokenStr[TokenNum] = t;\r
+}\r
+\r
+static Expr *\r
+#ifdef __USE_PROTOS\r
+newExpr( char *e )\r
+#else\r
+newExpr( e )\r
+char *e;\r
+#endif\r
+{\r
+       Expr *p = (Expr *) calloc(1, sizeof(Expr));\r
+       require(p!=NULL, "newExpr: cannot alloc Expr node");\r
+\r
+       p->expr = e;\r
+       p->lclass = CurrentLexClass;\r
+       return p;\r
+}\r
+\r
+/* switch to lexical class/mode m.  This amounts to creating a new\r
+ * lex mode if one does not already exist and making ExprStr point\r
+ * to the correct char string array.  We must also switch Texpr tables.\r
+ *\r
+ * BTW, we need multiple ExprStr arrays because more than one automaton\r
+ * may have the same label for a token, but with different expressions.\r
+ * We need to track an expr for each automaton.  If we disallowed this\r
+ * feature, only one ExprStr would be required.\r
+ */\r
+void\r
+#ifdef __USE_PROTOS\r
+lexclass( char *m )\r
+#else\r
+lexclass( m )\r
+char *m;\r
+#endif\r
+{\r
+       int i;\r
+       TermEntry *p;\r
+       static char EOFSTR[] = "\"@\"";\r
+\r
+       if ( hash_get(Tname, m) != NULL )\r
+       {\r
+               warn(eMsg1("lexclass name conflicts with token/errclass label '%s'",m));\r
+       }\r
+       /* does m already exist? */\r
+       i = LexClassIndex(m);\r
+       if ( i != -1 ) {lexmode(i); return;}\r
+       /* must make new one */\r
+       NumLexClasses++;\r
+       CurrentLexClass = NumLexClasses-1;\r
+       require(NumLexClasses<=MaxLexClasses, "number of allowable lexclasses exceeded\nIncrease MaxLexClasses in generic.h and recompile all C files");\r
+       lclass[CurrentLexClass].classnum = m;\r
+       lclass[CurrentLexClass].exprs = (char **) calloc(tsize, sizeof(char *));\r
+       require(lclass[CurrentLexClass].exprs!=NULL,\r
+                       "lexclass: cannot allocate ExprStr");\r
+       lclass[CurrentLexClass].htable = newHashTable();\r
+       ExprStr = lclass[CurrentLexClass].exprs;\r
+       Texpr = lclass[CurrentLexClass].htable;\r
+       /* define EOF for each automaton */\r
+       p = newTermEntry( EOFSTR );\r
+       p->token = EofToken;    /* couldn't have remapped tokens yet, use EofToken */\r
+       hash_add(Texpr, EOFSTR, (Entry *)p);\r
+       list_add(&ExprOrder, (void *)newExpr(EOFSTR));\r
+       /* note: we use the actual ExprStr array\r
+        * here as TokenInd doesn't exist yet\r
+        */\r
+       ExprStr[EofToken] = EOFSTR;\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+lexmode( int i )\r
+#else\r
+lexmode( i )\r
+int i;\r
+#endif\r
+{\r
+       require(i<NumLexClasses, "lexmode: invalid mode");\r
+       ExprStr = lclass[i].exprs;\r
+       Texpr = lclass[i].htable;\r
+       CurrentLexClass = i;\r
+}\r
+\r
+/* return index into lclass array of lexical class. return -1 if nonexistent */\r
+int\r
+#ifdef __USE_PROTOS\r
+LexClassIndex( char *cl )\r
+#else\r
+LexClassIndex( cl )\r
+char *cl;\r
+#endif\r
+{\r
+       int i;\r
+\r
+       for (i=0; i<NumLexClasses; i++)\r
+       {\r
+               if ( strcmp(lclass[i].classnum, cl) == 0 ) return i;\r
+       }\r
+       return -1;\r
+}\r
+\r
+int\r
+#ifdef __USE_PROTOS\r
+hasAction( char *expr )\r
+#else\r
+hasAction( expr )\r
+char *expr;\r
+#endif\r
+{\r
+       TermEntry *p;\r
+       require(expr!=NULL, "hasAction: invalid expr");\r
+\r
+       p = (TermEntry *) hash_get(Texpr, expr);\r
+       require(p!=NULL, eMsg1("hasAction: expr '%s' doesn't exist",expr));\r
+       return (p->action!=NULL);\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+setHasAction( char *expr, char *action )\r
+#else\r
+setHasAction( expr, action )\r
+char *expr;\r
+char *action;\r
+#endif\r
+{\r
+       TermEntry *p;\r
+       require(expr!=NULL, "setHasAction: invalid expr");\r
+\r
+       p = (TermEntry *) hash_get(Texpr, expr);\r
+       require(p!=NULL, eMsg1("setHasAction: expr '%s' doesn't exist",expr));\r
+       p->action = action;\r
+}\r
+\r
+ForcedToken *\r
+#ifdef __USE_PROTOS\r
+newForcedToken(char *token, int tnum)\r
+#else\r
+newForcedToken(token, tnum)\r
+char *token;\r
+int tnum;\r
+#endif\r
+{\r
+       ForcedToken *ft = (ForcedToken *) calloc(1, sizeof(ForcedToken));\r
+       require(ft!=NULL, "out of memory");\r
+       ft->token = token;\r
+       ft->tnum = tnum;\r
+       return ft;\r
+}\r
+\r
+/*\r
+ * Make a token indirection array that remaps token numbers and then walk\r
+ * the appropriate symbol tables and SynDiag to change token numbers\r
+ */\r
+void\r
+#ifdef __USE_PROTOS\r
+RemapForcedTokens(void)\r
+#else\r
+RemapForcedTokens()\r
+#endif\r
+{\r
+       ListNode *p;\r
+       ForcedToken *q;\r
+       int max_token_number=0;     /* MR9 23-Sep-97 Removed "unsigned" */\r
+       int i;\r
+\r
+       if ( ForcedTokens == NULL ) return;\r
+\r
+       /* find max token num */\r
+       for (p = ForcedTokens->next; p!=NULL; p=p->next)\r
+       {\r
+               q = (ForcedToken *) p->elem;\r
+               if ( q->tnum > max_token_number ) max_token_number = q->tnum;\r
+       }\r
+       fprintf(stderr, "max token number is %d\n", max_token_number);\r
+\r
+       /* make token indirection array */\r
+       TokenInd = (int *) calloc(max_token_number+1, sizeof(int));\r
+       LastTokenCounted = TokenNum;\r
+       TokenNum = max_token_number+1;\r
+       require(TokenInd!=NULL, "RemapForcedTokens: cannot allocate TokenInd");\r
+\r
+       /* fill token indirection array and change token id htable ; swap token indices */\r
+       for (i=1; i<TokenNum; i++) TokenInd[i] = i;\r
+       for (p = ForcedTokens->next; p!=NULL; p=p->next)\r
+       {\r
+               TermEntry *te;\r
+               int old_pos, t;\r
+\r
+               q = (ForcedToken *) p->elem;\r
+               fprintf(stderr, "%s forced to %d\n", q->token, q->tnum);\r
+               te = (TermEntry *) hash_get(Tname, q->token);\r
+               require(te!=NULL, "RemapForcedTokens: token not in hash table");\r
+               old_pos = te->token;\r
+               fprintf(stderr, "Before: TokenInd[old_pos==%d] is %d\n", old_pos, TokenInd[old_pos]);\r
+               fprintf(stderr, "Before: TokenInd[target==%d] is %d\n", q->tnum, TokenInd[q->tnum]);\r
+               q = (ForcedToken *) p->elem;\r
+               t = TokenInd[old_pos];\r
+               TokenInd[old_pos] = q->tnum;\r
+               TokenInd[q->tnum] = t;\r
+               te->token = q->tnum;            /* update token type id symbol table */\r
+               fprintf(stderr, "After: TokenInd[old_pos==%d] is %d\n", old_pos, TokenInd[old_pos]);\r
+               fprintf(stderr, "After: TokenInd[target==%d] is %d\n", q->tnum, TokenInd[q->tnum]);\r
+\r
+               /* Change the token number in the sym tab entry for the exprs\r
+                * at the old position of the token id and the target position\r
+                */\r
+               /* update expr at target (if any) of forced token id */\r
+               if ( q->tnum < TokenNum )       /* is it a valid position? */\r
+               {\r
+                       for (i=0; i<NumLexClasses; i++)\r
+                       {\r
+                               if ( lclass[i].exprs[q->tnum]!=NULL )\r
+                               {\r
+                                       /* update the symbol table for this expr */\r
+                                       TermEntry *e = (TermEntry *) hash_get(lclass[i].htable, lclass[i].exprs[q->tnum]);\r
+                                       require(e!=NULL, "RemapForcedTokens: expr not in hash table");\r
+                                       e->token = old_pos;\r
+                                       fprintf(stderr, "found expr '%s' at target %d in lclass[%d]; changed to %d\n",\r
+                                                       lclass[i].exprs[q->tnum], q->tnum, i, old_pos);\r
+                               }\r
+                       }\r
+               }\r
+               /* update expr at old position (if any) of forced token id */\r
+               for (i=0; i<NumLexClasses; i++)\r
+               {\r
+                       if ( lclass[i].exprs[old_pos]!=NULL )\r
+                       {\r
+                               /* update the symbol table for this expr */\r
+                               TermEntry *e = (TermEntry *) hash_get(lclass[i].htable, lclass[i].exprs[old_pos]);\r
+                               require(e!=NULL, "RemapForcedTokens: expr not in hash table");\r
+                               e->token = q->tnum;\r
+                               fprintf(stderr, "found expr '%s' for id %s in lclass[%d]; changed to %d\n",\r
+                                               lclass[i].exprs[old_pos], q->token, i, q->tnum);\r
+                       }\r
+               }\r
+       }\r
+\r
+       /* Update SynDiag */\r
+       RemapForcedTokensInSyntaxDiagram((Node *)SynDiag);\r
+}\r
+\r
+static void\r
+#ifdef __USE_PROTOS\r
+RemapForcedTokensInSyntaxDiagram(Node *p)\r
+#else\r
+RemapForcedTokensInSyntaxDiagram(p)\r
+Node *p;\r
+#endif\r
+{\r
+       Junction *j = (Junction *) p;\r
+       RuleRefNode *r = (RuleRefNode *) p;\r
+       TokNode *t = (TokNode *)p;\r
+\r
+       if ( p==NULL ) return;\r
+       require(p->ntype>=1 && p->ntype<=NumNodeTypes,  "Remap...: invalid diagram node");\r
+       switch ( p->ntype )\r
+       {\r
+               case nJunction :\r
+                       if ( j->visited ) return;\r
+                       if ( j->jtype == EndRule ) return;\r
+                       j->visited = TRUE;\r
+                       RemapForcedTokensInSyntaxDiagram( j->p1 );\r
+                       RemapForcedTokensInSyntaxDiagram( j->p2 );\r
+                       j->visited = FALSE;\r
+                       return;\r
+               case nRuleRef :\r
+                       RemapForcedTokensInSyntaxDiagram( r->next );\r
+                       return;\r
+               case nToken :\r
+                       if ( t->remapped ) return;      /* we've been here before */\r
+                       t->remapped = 1;\r
+                       fprintf(stderr, "remapping %d to %d\n", t->token, TokenInd[t->token]);\r
+                       t->token = TokenInd[t->token];\r
+                       RemapForcedTokensInSyntaxDiagram( t->next );\r
+                       return;\r
+               case nAction :\r
+                       RemapForcedTokensInSyntaxDiagram( ((ActionNode *)p)->next );\r
+                       return;\r
+               default :\r
+                       fatal_internal("invalid node type");\r
+       }\r
+}\r
+\r
+/*\r
+ * Add a token name.  Return the token number associated with it.  If it already\r
+ * exists, then return the token number assigned to it.\r
+ *\r
+ * Track the order in which tokens are found so that the DLG output maintains\r
+ * that order.  It also lets us map token numbers to strings.\r
+ */\r
+int\r
+#ifdef __USE_PROTOS\r
+addTname( char *token )\r
+#else\r
+addTname( token )\r
+char *token;\r
+#endif\r
+{\r
+       TermEntry *p;\r
+       require(token!=NULL, "addTname: invalid token name");\r
+\r
+       if ( (p=(TermEntry *)hash_get(Tname, token)) != NULL ) return p->token;\r
+       p = newTermEntry( token );\r
+       Ttrack( p->str );\r
+       p->token = TokenNum++;\r
+       hash_add(Tname, token, (Entry *)p);\r
+       return p->token;\r
+}\r
+\r
+/* This is the same as addTname except we force the TokenNum to be tnum.\r
+ * We don't have to use the Forced token stuff as no tokens will have\r
+ * been defined with #tokens when this is called.  This is only called\r
+ * when a #tokdefs meta-op is used.\r
+ */\r
+int\r
+#ifdef __USE_PROTOS\r
+addForcedTname( char *token, int tnum )\r
+#else\r
+addForcedTname( token, tnum )\r
+char *token;\r
+int tnum;\r
+#endif\r
+{\r
+       TermEntry *p;\r
+       require(token!=NULL, "addTname: invalid token name");\r
+\r
+       if ( (p=(TermEntry *)hash_get(Tname, token)) != NULL ) return p->token;\r
+       p = newTermEntry( token );\r
+       Ttrack( p->str );\r
+       p->token = tnum;\r
+       hash_add(Tname, token, (Entry *)p);\r
+       return p->token;\r
+}\r
+\r
+/*\r
+ * Add a token expr.  Return the token number associated with it.  If it already\r
+ * exists, then return the token number assigned to it.\r
+ */\r
+int\r
+#ifdef __USE_PROTOS\r
+addTexpr( char *expr )\r
+#else\r
+addTexpr( expr )\r
+char *expr;\r
+#endif\r
+{\r
+       TermEntry *p;\r
+       require(expr!=NULL, "addTexpr: invalid regular expression");\r
+\r
+       if ( (p=(TermEntry *)hash_get(Texpr, expr)) != NULL ) return p->token;\r
+       p = newTermEntry( expr );\r
+       Ttrack( p->str );\r
+       /* track the order in which they occur */\r
+       list_add(&ExprOrder, (void *)newExpr(p->str));\r
+       p->token = TokenNum++;\r
+       hash_add(Texpr, expr, (Entry *)p);\r
+       return p->token;\r
+}\r
+\r
+/* return the token number of 'term'.  Return 0 if no 'term' exists */\r
+int\r
+#ifdef __USE_PROTOS\r
+Tnum( char *term )\r
+#else\r
+Tnum( term )\r
+char *term;\r
+#endif\r
+{\r
+       TermEntry *p;\r
+       require(term!=NULL, "Tnum: invalid terminal");\r
+       \r
+       if ( *term=='"' ) p = (TermEntry *) hash_get(Texpr, term);\r
+       else p = (TermEntry *) hash_get(Tname, term);\r
+       if ( p == NULL ) return 0;\r
+       else return p->token;\r
+}\r
+\r
+/* associate a Name with an expr.  If both have been already assigned\r
+ * token numbers, then an error is reported.  Add the token or expr\r
+ * that has not been added if no error.  This 'represents' the #token\r
+ * ANTLR pseudo-op.  If both have not been defined, define them both\r
+ * linked to same token number.\r
+ */\r
+void\r
+#ifdef __USE_PROTOS\r
+Tklink( char *token, char *expr )\r
+#else\r
+Tklink( token, expr )\r
+char *token;\r
+char *expr;\r
+#endif\r
+{\r
+       TermEntry *p, *q;\r
+       require(token!=NULL && expr!=NULL, "Tklink: invalid token name and/or expr");\r
+\r
+       p = (TermEntry *) hash_get(Tname, token);\r
+       q = (TermEntry *) hash_get(Texpr, expr);\r
+       if ( p != NULL && q != NULL )   /* both defined */\r
+       {\r
+               warn( eMsg2("token name %s and rexpr %s already defined; ignored",\r
+                                       token, expr) );\r
+               return;\r
+       }\r
+       if ( p==NULL && q==NULL )               /* both not defined */\r
+       {\r
+               int t = addTname( token );\r
+               q = newTermEntry( expr );\r
+               hash_add(Texpr, expr, (Entry *)q);\r
+               q->token = t;\r
+               /* note: we use the actual ExprStr array\r
+                * here as TokenInd doesn't exist yet\r
+                */\r
+               ExprStr[t] = q->str;\r
+               /* track the order in which they occur */\r
+               list_add(&ExprOrder, (void *)newExpr(q->str));\r
+               return;\r
+       }\r
+       if ( p != NULL )                                /* one is defined, one is not */\r
+       {\r
+               q = newTermEntry( expr );\r
+               hash_add(Texpr, expr, (Entry *)q);\r
+               q->token = p->token;\r
+               ExprStr[p->token] = q->str;     /* both expr and token str defined now */\r
+               list_add(&ExprOrder, (void *)newExpr(q->str));\r
+       }\r
+       else                                                    /* trying to associate name with expr here*/\r
+       {\r
+               p = newTermEntry( token );\r
+               hash_add(Tname, token, (Entry *)p);\r
+               p->token = q->token;\r
+               TokenStr[p->token] = p->str;/* both expr and token str defined now */\r
+       }\r
+}\r
+\r
+/*\r
+ * Given a string, this function allocates and returns a pointer to a\r
+ * hash table record of size 'sz' whose "str" pointer is reset to a position\r
+ * in the string table.\r
+ */\r
+Entry *\r
+#ifdef __USE_PROTOS\r
+newEntry( char *text, int sz )\r
+#else\r
+newEntry( text, sz )\r
+char *text;\r
+int sz;\r
+#endif\r
+{\r
+       Entry *p;\r
+       require(text!=NULL, "new: NULL terminal");\r
+       \r
+       if ( (p = (Entry *) calloc(1,sz)) == 0 )\r
+       {\r
+               fatal_internal("newEntry: out of memory for terminals\n");\r
+               exit(PCCTS_EXIT_FAILURE);\r
+       }\r
+       p->str = mystrdup(text);\r
+       \r
+       return(p);\r
+}\r
+\r
+/*\r
+ * add an element to a list.\r
+ *\r
+ * Any non-empty list has a sentinel node whose 'elem' pointer is really\r
+ * a pointer to the last element.  (i.e. length(list) = #elemIn(list)+1).\r
+ * Elements are appended to the list.\r
+ */\r
+void\r
+#ifdef __USE_PROTOS\r
+list_add( ListNode **list, void *e )\r
+#else\r
+list_add( list, e )\r
+ListNode **list;\r
+void *e;\r
+#endif\r
+{\r
+       ListNode *p, *tail;\r
+       require(e!=NULL, "list_add: attempting to add NULL list element");\r
+\r
+       p = newListNode;\r
+       require(p!=NULL, "list_add: cannot alloc new list node");\r
+       p->elem = e;\r
+       if ( *list == NULL )\r
+       {\r
+               ListNode *sentinel = newListNode;\r
+               require(sentinel!=NULL, "list_add: cannot alloc sentinel node");\r
+               *list=sentinel;\r
+               sentinel->next = p;\r
+               sentinel->elem = (char *)p;             /* set tail pointer */\r
+       }\r
+       else                                                            /* find end of list */\r
+       {\r
+               tail = (ListNode *) (*list)->elem;      /* get tail pointer */\r
+               tail->next = p;\r
+               (*list)->elem = (char *) p;             /* reset tail */\r
+       }\r
+}\r
+\r
+/* MR10 list_free() frees the ListNode elements in the list       */\r
+/* MR10   if freeData then free the data elements of the list too */\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+list_free(ListNode **list,int freeData)\r
+#else\r
+list_free(list,freeData)\r
+  ListNode      **list;\r
+  int           freeData;\r
+#endif\r
+{\r
+       ListNode *p;\r
+    ListNode *next;\r
+\r
+       if (list == NULL) return;\r
+    if (*list == NULL) return;\r
+       for (p=*list; p != NULL; p=next) {\r
+      next=p->next;\r
+      if (freeData && p->elem != NULL) {\r
+        free( (char *) p->elem);\r
+      };\r
+      free( (char *) p);\r
+    };\r
+    *list=NULL;\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+list_apply( ListNode *list, void (*f)(void *) )\r
+#else\r
+list_apply( list, f )\r
+ListNode *list;\r
+void (*f)();\r
+#endif\r
+{\r
+       ListNode *p;\r
+       require(f!=NULL, "list_apply: NULL function to apply");\r
+\r
+       if ( list == NULL ) return;\r
+       for (p = list->next; p!=NULL; p=p->next) (*f)( p->elem );\r
+}\r
+\r
+/* MR27 */\r
+\r
+#ifdef __USE_PROTOS\r
+int list_search_cstring(ListNode *list, char * cstring)\r
+#else\r
+int list_search_cstring(list, cstring)\r
+  ListNode * list;\r
+  char * cstring;\r
+#endif\r
+{\r
+       ListNode *p;\r
+       if (list == NULL ) return 0;\r
+       for (p = list->next; p!=NULL; p=p->next) {\r
+               if (p->elem == NULL) continue;\r
+               if (0 == strcmp((char *) p->elem , cstring)) return 1;\r
+       }\r
+       return 0;\r
+}\r
+\r
+                       /* F O L L O W  C y c l e  S t u f f */\r
+               \r
+/* make a key based upon (rulename, computation, k value).\r
+ * Computation values are 'i'==FIRST, 'o'==FOLLOW.\r
+ */\r
+\r
+/* MR10  Make the key all characters so it can be read easily   */\r
+/* MR10    by a simple dump program.  Also, separates           */\r
+/* MR10   'o' and 'i' from rule name                            */\r
+\r
+char *\r
+#ifdef __USE_PROTOS\r
+Fkey( char *rule, int computation, int k )\r
+#else\r
+Fkey( rule, computation, k )\r
+char *rule;\r
+int computation;\r
+int k;\r
+#endif\r
+{\r
+       static char key[MaxRuleName+2+2+1];                                 /* MR10 */\r
+       int i;\r
+       \r
+       if ( k > 99 )                                                       /* MR10 */\r
+               fatal("k>99 is too big for this implementation of ANTLR!\n");   /* MR10 */\r
+       if ( (i=strlen(rule)) > MaxRuleName )                               /* MR10 */\r
+               fatal( eMsgd("rule name > max of %d\n", MaxRuleName) );         /* MR10 */\r
+       strcpy(key,rule);\r
+\r
+/* MR10 */     key[i]='*';\r
+/* MR10 */     key[i+1] = (char) computation; /* MR20 G. Hobbelt */\r
+/* MR10 */     if (k < 10) {\r
+/* MR10 */       key[i+2] = (char) ( '0' + k);\r
+/* MR10 */      key[i+3] = '\0';\r
+/* MR10 */     } else {\r
+/* MR10 */       key[i+2] = (char) ( '0' + k/10);\r
+/* MR10 */       key[i+3] = (char) ( '0' + k % 10);\r
+/* MR10 */       key[i+4] = '\0';\r
+/* MR10 */     };\r
+\r
+       return key;\r
+}\r
+\r
+/* Push a rule onto the kth FOLLOW stack */\r
+void\r
+#ifdef __USE_PROTOS\r
+FoPush( char *rule, int k )\r
+#else\r
+FoPush( rule, k )\r
+char *rule;\r
+int k;\r
+#endif\r
+{\r
+       RuleEntry *r;\r
+       require(rule!=NULL, "FoPush: tried to push NULL rule");\r
+       require(k<=CLL_k,       "FoPush: tried to access non-existent stack");\r
+\r
+       /*fprintf(stderr, "FoPush(%s)\n", rule);*/\r
+       r = (RuleEntry *) hash_get(Rname, rule);\r
+       if ( r == NULL ) {fatal_internal( eMsg1("rule %s must be defined but isn't", rule) );}\r
+       if ( FoStack[k] == NULL )               /* Does the kth stack exist yet? */\r
+       {\r
+               /*fprintf(stderr, "allocating FoStack\n");*/\r
+               FoStack[k] = (int *) calloc(FoStackSize, sizeof(int));\r
+               require(FoStack[k]!=NULL, "FoPush: cannot allocate FOLLOW stack\n");\r
+       }\r
+       if ( FoTOS[k] == NULL )\r
+       {\r
+               FoTOS[k]=FoStack[k];\r
+               *(FoTOS[k]) = r->rulenum;\r
+       }\r
+       else\r
+       {\r
+#ifdef MEMCHK\r
+               require(valid(FoStack[k]), "FoPush: invalid FoStack");\r
+#endif\r
+               if ( FoTOS[k] >= &(FoStack[k][FoStackSize-1]) )\r
+                       fatal( eMsgd("exceeded max depth of FOLLOW recursion (%d)\n",\r
+                                               FoStackSize) );\r
+               require(FoTOS[k]>=FoStack[k],\r
+                               eMsg1("FoPush: FoStack stack-ptr is playing out of its sandbox",\r
+                                         rule));\r
+               ++(FoTOS[k]);\r
+               *(FoTOS[k]) = r->rulenum;\r
+       }\r
+       {\r
+               /*\r
+****           int *p;\r
+****           fprintf(stderr, "FoStack[k=%d]:\n", k);\r
+****           for (p=FoStack[k]; p<=FoTOS[k]; p++)\r
+****           {\r
+****                   fprintf(stderr, "\t%s\n", RulePtr[*p]->rname);\r
+****           }\r
+               */\r
+       }\r
+}\r
+\r
+/* Pop one rule off of the FOLLOW stack.  TOS ptr is NULL if empty. */\r
+void\r
+#ifdef __USE_PROTOS\r
+FoPop( int k )\r
+#else\r
+FoPop( k )\r
+int k;\r
+#endif\r
+{\r
+       require(k<=CLL_k, "FoPop: tried to access non-existent stack");\r
+       /*fprintf(stderr, "FoPop\n");*/\r
+       require(FoTOS[k]>=FoStack[k]&&FoTOS[k]<=&(FoStack[k][FoStackSize-1]),\r
+                       "FoPop: FoStack stack-ptr is playing out of its sandbox");\r
+       if ( FoTOS[k] == FoStack[k] ) FoTOS[k] = NULL;\r
+       else (FoTOS[k])--;\r
+}\r
+\r
+/* Compute FOLLOW cycle.\r
+ * Mark all FOLLOW sets for rules in cycle as incomplete.\r
+ * Then, save cycle on the cycle list (Cycles) for later resolution.\r
+ * The Cycle is stored in the form:\r
+ *             (head of cycle==croot, rest of rules in cycle==cyclicDep)\r
+ *\r
+ * e.g. (Fo means "FOLLOW of", "-->" means requires or depends on)\r
+ *\r
+ *             Fo(x)-->Fo(a)-->Fo(b)-->Fo(c)-->Fo(x)\r
+ *                                                                                ^----Infinite recursion (cycle)\r
+ *\r
+ * the cycle would be: x -> {a,b,c} or stored as (x,{a,b,c}).  Fo(x) depends\r
+ * on the FOLLOW of a,b, and c.  The root of a cycle is always complete after\r
+ * Fo(x) finishes.  Fo(a,b,c) however are not.  It turns out that all rules\r
+ * in a FOLLOW cycle have the same FOLLOW set.\r
+ */\r
+void\r
+#ifdef __USE_PROTOS\r
+RegisterCycle( char *rule, int k )\r
+#else\r
+RegisterCycle( rule, k )\r
+char *rule;\r
+int k;\r
+#endif\r
+{\r
+       CacheEntry *f;\r
+       Cycle *c;\r
+       int *p;\r
+       RuleEntry *r;\r
+       require(rule!=NULL, "RegisterCycle: tried to register NULL rule");\r
+       require(k<=CLL_k,       "RegisterCycle: tried to access non-existent stack");\r
+\r
+       /*fprintf(stderr, "RegisterCycle(%s)\n", rule);*/\r
+       /* Find cycle start */\r
+       r = (RuleEntry *) hash_get(Rname, rule);\r
+       require(r!=NULL,eMsg1("rule %s must be defined but isn't", rule));\r
+       require(FoTOS[k]>=FoStack[k]&&FoTOS[k]<=&(FoStack[k][FoStackSize-1]),\r
+                       eMsg1("RegisterCycle(%s): FoStack stack-ptr is playing out of its sandbox",\r
+                                 rule));\r
+/***   if ( FoTOS[k]<FoStack[k]||FoTOS[k]>&(FoStack[k][FoStackSize-1]) )\r
+****   {\r
+****           fprintf(stderr, "RegisterCycle(%s): FoStack stack-ptr is playing out of its sandbox\n",\r
+****                                           rule);\r
+****           fprintf(stderr, "RegisterCycle: sp==0x%x out of bounds 0x%x...0x%x\n",\r
+****                                           FoTOS[k], FoStack[k], &(FoStack[k][FoStackSize-1]));\r
+****           exit(PCCTS_EXIT_FAILURE);\r
+****   }\r
+****/\r
+\r
+#ifdef MEMCHK\r
+       require(valid(FoStack[k]), "RegisterCycle: invalid FoStack");\r
+#endif\r
+       for (p=FoTOS[k]; *p != r->rulenum && p >= FoStack[k]; --p) {;}\r
+       require(p>=FoStack[k], "RegisterCycle: FoStack is screwed up beyond belief");\r
+       if ( p == FoTOS[k] ) return;    /* don't worry about cycles to oneself */\r
+       \r
+       /* compute cyclic dependents (rules in cycle except head) */\r
+       c = newCycle;\r
+       require(c!=NULL, "RegisterCycle: couldn't alloc new cycle");\r
+       c->cyclicDep = empty;\r
+       c->croot = *p++;                /* record root of cycle */\r
+       for (; p<=FoTOS[k]; p++)\r
+       {\r
+               /* Mark all dependent rules as incomplete */\r
+               f = (CacheEntry *) hash_get(Fcache, Fkey(RulePtr[*p]->rname,'o',k));\r
+               if ( f==NULL )\r
+               {\r
+                       f = newCacheEntry( Fkey(RulePtr[*p]->rname,'o',k) );\r
+                       hash_add(Fcache, Fkey(RulePtr[*p]->rname,'o',k), (Entry *)f);\r
+               }\r
+               f->incomplete = TRUE;\r
+               \r
+               set_orel(*p, &(c->cyclicDep)); /* mark rule as dependent of croot */\r
+       }\r
+       list_add(&(Cycles[k]), (void *)c);\r
+}\r
+\r
+/* make all rules in cycle complete\r
+ *\r
+ * while ( some set has changed ) do\r
+ *             for each cycle do\r
+ *                     if degree of FOLLOW set for croot > old degree then\r
+ *                             update all FOLLOW sets for rules in cyclic dependency\r
+ *                             change = TRUE\r
+ *                     endif\r
+ *             endfor\r
+ * endwhile\r
+ */\r
+void\r
+#ifdef __USE_PROTOS\r
+ResolveFoCycles( int k )\r
+#else\r
+ResolveFoCycles( k )\r
+int k;\r
+#endif\r
+{\r
+       ListNode *p, *q;\r
+       Cycle *c;\r
+       int changed = 1;\r
+       CacheEntry *f,*g;\r
+       int r;\r
+/*  int i;  */  /* MR10 not useful */\r
+       unsigned d;\r
+\r
+    unsigned    *cursor;        /* MR10 */\r
+    unsigned    *origin;        /* MR10 */\r
+       \r
+       /*fprintf(stderr, "Resolving following cycles for %d\n", k);*/\r
+       while ( changed )\r
+       {\r
+               changed = 0;\r
+/* MR10 i = 0;  */\r
+               for (p = Cycles[k]->next; p!=NULL; p=p->next)\r
+               {\r
+                       c = (Cycle *) p->elem;\r
+                       /*fprintf(stderr, "cycle %d: %s -->", i++, RulePtr[c->croot]->rname);*/\r
+                       /*s_fprT(stderr, c->cyclicDep);*/\r
+                       /*fprintf(stderr, "\n");*/\r
+                       f = (CacheEntry *)\r
+                                       hash_get(Fcache, Fkey(RulePtr[c->croot]->rname,'o',k));\r
+                       require(f!=NULL, eMsg1("FOLLOW(%s) must be in cache but isn't", RulePtr[c->croot]->rname) );\r
+                       if ( (d=set_deg(f->fset)) > c->deg )\r
+                       {\r
+                               /*fprintf(stderr, "Fo(%s) has changed\n", RulePtr[c->croot]->rname);*/\r
+                               changed = 1;\r
+                               c->deg = d;             /* update cycle FOLLOW set degree */\r
+\r
+/* MR10 */      origin=set_pdq(c->cyclicDep);\r
+/* MR10 */      for (cursor=origin; *cursor != nil; cursor++) {\r
+/* MR10 */         r=*cursor;\r
+\r
+/********              while ( !set_nil(c->cyclicDep) ) {      *****/\r
+/********                                      r = set_int(c->cyclicDep);  *****/\r
+/********                                      set_rm(r, c->cyclicDep);    *****/\r
+\r
+                                       /*fprintf(stderr, "updating Fo(%s)\n", RulePtr[r]->rname);*/\r
+                                       g = (CacheEntry *)\r
+                                                       hash_get(Fcache, Fkey(RulePtr[r]->rname,'o',k));\r
+                                       require(g!=NULL, eMsg1("FOLLOW(%s) must be in cache but isn't", RulePtr[r]->rname) );\r
+                                       set_orin(&(g->fset), f->fset);\r
+                                       g->incomplete = FALSE;\r
+                               }\r
+/* MR10 */      free( (char *) origin);\r
+/* MR10 */      origin=NULL;\r
+                       }\r
+               }\r
+/* MR10 - this if statement appears to be meaningless since i is always 0 */\r
+/* MR10                if ( i == 1 ) changed = 0;      */ /* if only 1 cycle, no need to repeat */\r
+       }\r
+       /* kill Cycle list */\r
+       for (q = Cycles[k]->next; q != NULL; q=p)\r
+       {\r
+               p = q->next;\r
+               set_free( ((Cycle *)q->elem)->cyclicDep );\r
+               free((char *)q);\r
+       }\r
+       free( (char *)Cycles[k] );\r
+       Cycles[k] = NULL;\r
+}\r
+\r
+\r
+                       /* P r i n t i n g  S y n t a x  D i a g r a m s */\r
+\r
+static void\r
+#ifdef __USE_PROTOS\r
+pBlk( Junction *q, int btype )\r
+#else\r
+pBlk( q, btype )\r
+Junction *q;\r
+int btype;\r
+#endif\r
+{\r
+       int k,a;\r
+       Junction *alt, *p;\r
+\r
+       q->end->pvisited = TRUE;\r
+       if ( btype == aLoopBegin )\r
+       {\r
+               require(q->p2!=NULL, "pBlk: invalid ()* block");\r
+               PRINT(q->p1);\r
+               alt = (Junction *)q->p2;\r
+               PRINT(alt->p1);\r
+               if ( PrintAnnotate )\r
+               {\r
+                       printf(" /* Opt ");\r
+                       k = 1;\r
+                       while ( !set_nil(alt->fset[k]) )\r
+                       {\r
+                               s_fprT(stdout, alt->fset[k]);\r
+                               if ( k++ == CLL_k ) break;\r
+                               if ( !set_nil(alt->fset[k]) ) printf(", ");\r
+                       }\r
+                       printf(" */\n");\r
+               }\r
+               return;\r
+       }\r
+       for (a=1,alt=q; alt != NULL; alt= (Junction *) alt->p2, a++)\r
+       {\r
+               if ( alt->p1 != NULL ) PRINT(alt->p1);\r
+               if ( PrintAnnotate )\r
+               {\r
+                       printf( " /* [%d] ", alt->altnum);\r
+                       k = 1;\r
+                       while ( !set_nil(alt->fset[k]) )\r
+                       {\r
+                               s_fprT(stdout, alt->fset[k]);\r
+                               if ( k++ == CLL_k ) break;\r
+                               if ( !set_nil(alt->fset[k]) ) printf(", ");\r
+                       }\r
+                       if ( alt->p2 == NULL && btype == aOptBlk )\r
+                               printf( " (optional branch) */\n");\r
+                       else printf( " */\n");\r
+               }\r
+\r
+               /* ignore implied empty alt of Plus blocks */\r
+               if ( alt->p2 != NULL && ((Junction *)alt->p2)->ignore ) break;\r
+\r
+               if ( alt->p2 != NULL && !(((Junction *)alt->p2)->p2==NULL && btype == aOptBlk) )\r
+               {\r
+                       if ( pLevel == 1 )\r
+                       {\r
+                               printf("\n");\r
+                               if ( a+1==pAlt1 || a+1==pAlt2 ) printf("=>");\r
+                               printf("\t");\r
+                       }\r
+                       else printf(" ");\r
+                       printf("|");\r
+                       if ( pLevel == 1 )\r
+                       {\r
+                               p = (Junction *) ((Junction *)alt->p2)->p1;\r
+                               while ( p!=NULL )\r
+                               {\r
+                                       if ( p->ntype==nAction )\r
+                                       {\r
+                                               p=(Junction *)((ActionNode *)p)->next;\r
+                                               continue;\r
+                                       }\r
+                                       if ( p->ntype!=nJunction )\r
+                                       {\r
+                                               break;\r
+                                       }\r
+                                       if ( p->jtype==EndBlk || p->jtype==EndRule )\r
+                                       {\r
+                                               p = NULL;\r
+                                               break;\r
+                                       }\r
+                                       p = (Junction *)p->p1;\r
+                               }\r
+                               if ( p==NULL ) printf("\n\t");  /* Empty alt? */\r
+                       }\r
+               }\r
+       }\r
+       q->end->pvisited = FALSE;\r
+}\r
+\r
+/* How to print out a junction */\r
+void\r
+#ifdef __USE_PROTOS\r
+pJunc( Junction *q )\r
+#else\r
+pJunc( q )\r
+Junction *q;\r
+#endif\r
+{\r
+       int dum_k;\r
+       int doing_rule;\r
+       require(q!=NULL, "pJunc: NULL node");\r
+       require(q->ntype==nJunction, "pJunc: not junction");\r
+       \r
+       if ( q->pvisited == TRUE ) return;\r
+       q->pvisited = TRUE;\r
+       switch ( q->jtype )\r
+       {\r
+               case aSubBlk :\r
+                       if ( PrintAnnotate ) First(q, 1, q->jtype, &dum_k);\r
+                       if ( q->end->p1 != NULL && ((Junction *)q->end->p1)->ntype==nJunction &&\r
+                                ((Junction *)q->end->p1)->jtype == EndRule ) doing_rule = 1;\r
+                       else doing_rule = 0;\r
+                       pLevel++;\r
+                       if ( pLevel==1 )\r
+                       {\r
+                               if ( pAlt1==1 ) printf("=>");\r
+                               printf("\t");\r
+                       }\r
+                       else printf(" ");\r
+                       if ( doing_rule )\r
+                       {\r
+                               if ( pLevel==1 ) printf(" ");\r
+                               pBlk(q,q->jtype);\r
+                       }\r
+                       else {\r
+                               printf("(");\r
+                               if ( pLevel==1 ) printf(" ");\r
+                               pBlk(q,q->jtype);\r
+                               if ( pLevel>1 ) printf(" ");\r
+                               printf(")");\r
+                       }\r
+                       if ( q->guess ) printf("?");\r
+                       pLevel--;\r
+                       if ( PrintAnnotate ) freeBlkFsets(q);\r
+                       if ( q->end->p1 != NULL ) PRINT(q->end->p1);\r
+                       break;\r
+               case aOptBlk :\r
+                       if ( PrintAnnotate ) First(q, 1, q->jtype, &dum_k);\r
+                       pLevel++;\r
+                       if ( pLevel==1 )\r
+                       {\r
+                               if ( pAlt1==1 ) printf("=>");\r
+                               printf("\t");\r
+                       }\r
+                       else printf(" ");\r
+                       printf("{");\r
+                       if ( pLevel==1 ) printf(" ");\r
+                       pBlk(q,q->jtype);\r
+                       if ( pLevel>1 ) printf(" ");\r
+                       else printf("\n\t");\r
+                       printf("}");\r
+                       pLevel--;\r
+                       if ( PrintAnnotate ) freeBlkFsets(q);\r
+                       if ( q->end->p1 != NULL ) PRINT(q->end->p1);\r
+                       break;\r
+               case aLoopBegin :\r
+                       if ( PrintAnnotate ) First(q, 1, q->jtype, &dum_k);\r
+                       pLevel++;\r
+                       if ( pLevel==1 )\r
+                       {\r
+                               if ( pAlt1==1 ) printf("=>");\r
+                               printf("\t");\r
+                       }\r
+                       else printf(" ");\r
+                       printf("(");\r
+                       if ( pLevel==1 ) printf(" ");\r
+                       pBlk(q,q->jtype);\r
+                       if ( pLevel>1 ) printf(" ");\r
+                       else printf("\n\t");\r
+                       printf(")*");\r
+                       pLevel--;\r
+                       if ( PrintAnnotate ) freeBlkFsets(q);\r
+                       if ( q->end->p1 != NULL ) PRINT(q->end->p1);\r
+                       break;\r
+               case aLoopBlk :\r
+                       if ( PrintAnnotate ) First(q, 1, q->jtype, &dum_k);\r
+                       pBlk(q,q->jtype);\r
+                       if ( PrintAnnotate ) freeBlkFsets(q);\r
+                       break;\r
+               case aPlusBlk :\r
+                       if ( PrintAnnotate ) First(q, 1, q->jtype, &dum_k);\r
+                       pLevel++;\r
+                       if ( pLevel==1 )\r
+                       {\r
+                               if ( pAlt1==1 ) printf("=>");\r
+                               printf("\t");\r
+                       }\r
+                       else printf(" ");\r
+                       printf("(");\r
+                       if ( pLevel==1 ) printf(" ");\r
+                       pBlk(q,q->jtype);\r
+                       if ( pLevel>1 ) printf(" ");\r
+                       printf(")+");\r
+                       pLevel--;\r
+                       if ( PrintAnnotate ) freeBlkFsets(q);\r
+                       if ( q->end->p1 != NULL ) PRINT(q->end->p1);\r
+                       break;\r
+               case EndBlk :\r
+                       break;\r
+               case RuleBlk :\r
+                       printf( "\n%s :\n", q->rname);\r
+                       PRINT(q->p1);\r
+                       if ( q->p2 != NULL ) PRINT(q->p2);\r
+                       break;\r
+               case Generic :\r
+                       if ( q->p1 != NULL ) PRINT(q->p1);\r
+                       q->pvisited = FALSE;\r
+                       if ( q->p2 != NULL ) PRINT(q->p2);\r
+                       break;\r
+               case EndRule :\r
+                       printf( "\n\t;\n");\r
+                       break;\r
+       }\r
+       q->pvisited = FALSE;\r
+}\r
+\r
+/* How to print out a rule reference node */\r
+void\r
+#ifdef __USE_PROTOS\r
+pRuleRef( RuleRefNode *p )\r
+#else\r
+pRuleRef( p )\r
+RuleRefNode *p;\r
+#endif\r
+{\r
+       require(p!=NULL, "pRuleRef: NULL node");\r
+       require(p->ntype==nRuleRef, "pRuleRef: not rule ref node");\r
+       \r
+       printf( " %s", p->text);\r
+       PRINT(p->next);\r
+}\r
+\r
+/* How to print out a terminal node */\r
+void\r
+#ifdef __USE_PROTOS\r
+pToken( TokNode *p )\r
+#else\r
+pToken( p )\r
+TokNode *p;\r
+#endif\r
+{\r
+       require(p!=NULL, "pToken: NULL node");\r
+       require(p->ntype==nToken, "pToken: not token node");\r
+\r
+       if ( p->wild_card ) printf(" .");\r
+       printf( " %s", TerminalString(p->token));\r
+       PRINT(p->next);\r
+}\r
+\r
+/* How to print out a terminal node */\r
+void\r
+#ifdef __USE_PROTOS\r
+pAction( ActionNode *p )\r
+#else\r
+pAction( p )\r
+ActionNode *p;\r
+#endif\r
+{\r
+       require(p!=NULL, "pAction: NULL node");\r
+       require(p->ntype==nAction, "pAction: not action node");\r
+       \r
+       PRINT(p->next);\r
+}\r
+\r
+                                       /* F i l l  F o l l o w  L i s t s */\r
+\r
+/*\r
+ * Search all rules for all rule reference nodes, q to rule, r.\r
+ * Add q->next to follow list dangling off of rule r.\r
+ * i.e.\r
+ *\r
+ *             r: -o-R-o-->o--> Ptr to node following rule r in another rule\r
+ *                                     |\r
+ *                                     o--> Ptr to node following another reference to r.\r
+ *\r
+ * This is the data structure employed to avoid FOLLOW set computation.  We\r
+ * simply compute the FIRST (reach) of the EndRule Node which follows the\r
+ * list found at the end of all rules which are referenced elsewhere.  Rules\r
+ * not invoked by other rules have no follow list (r->end->p1==NULL).\r
+ * Generally, only start symbols are not invoked by another rule.\r
+ *\r
+ * Note that this mechanism also gives a free cross-reference mechanism.\r
+ *\r
+ * The entire syntax diagram is layed out like this:\r
+ *\r
+ * SynDiag\r
+ *     |\r
+ *     v\r
+ *     o-->R1--o\r
+ *     |\r
+ *     o-->R2--o\r
+ *     |\r
+ *     ...\r
+ *     |\r
+ *     o-->Rn--o\r
+ *\r
+ */\r
+void\r
+#ifdef __USE_PROTOS\r
+FoLink( Node *p )\r
+#else\r
+FoLink( p )\r
+Node *p;\r
+#endif\r
+{\r
+       RuleEntry *q;\r
+       Junction *j = (Junction *) p;\r
+       RuleRefNode *r = (RuleRefNode *) p;\r
+\r
+       if ( p==NULL ) return;\r
+       require(p->ntype>=1 && p->ntype<=NumNodeTypes,\r
+                       eMsgd("FoLink: invalid diagram node: ntype==%d",p->ntype));\r
+       switch ( p->ntype )\r
+       {\r
+               case nJunction :\r
+                       if ( j->fvisited ) return;\r
+                       if ( j->jtype == EndRule ) return;\r
+                       j->fvisited = TRUE;\r
+                       FoLink( j->p1 );\r
+                       FoLink( j->p2 );\r
+/* MR14 */\r
+/* MR14 */  /* Need to determine whether the guess block is an         */\r
+/* MR14 */  /* of the form (alpha)? beta before follow sets are        */\r
+/* MR14 */  /* computed.  This is necessary to solve problem           */\r
+/* MR14 */  /* of doing follow on the alpha of an (alpha)? beta block. */\r
+/* MR14 */\r
+/* MR14 */  /* This is performed by analysis_point as a side-effect.   */\r
+/* MR14 */\r
+/* MR14 */\r
+/* MR14 */  if (j->jtype == aSubBlk && j->guess) {\r
+/* MR14 */    Junction *ignore;\r
+/* MR14 */    ignore=analysis_point(j);\r
+/* MR14 */  }\r
+/* MR14 */\r
+                       return;\r
+               case nRuleRef :\r
+                       if ( r->linked ) return;\r
+                       q = (RuleEntry *) hash_get(Rname, r->text);\r
+                       if ( q == NULL )\r
+                       {\r
+                               warnFL( eMsg1("rule %s not defined",r->text), FileStr[r->file], r->line );\r
+                       }\r
+                       else\r
+                       {\r
+                               if ( r->parms!=NULL && RulePtr[q->rulenum]->pdecl==NULL )\r
+                               {\r
+                                       warnFL( eMsg1("rule %s accepts no parameter(s)", r->text),\r
+                                                       FileStr[r->file], r->line );\r
+                               }\r
+                               if ( r->parms==NULL && RulePtr[q->rulenum]->pdecl!=NULL )\r
+                               {\r
+                                       warnFL( eMsg1("rule %s requires parameter(s)", r->text),\r
+                                                       FileStr[r->file], r->line );\r
+                               }\r
+                               if ( r->assign!=NULL && RulePtr[q->rulenum]->ret==NULL )\r
+                               {\r
+                                       warnFL( eMsg1("rule %s yields no return value(s)", r->text),\r
+                                                       FileStr[r->file], r->line );\r
+                               }\r
+                               if ( r->assign==NULL && RulePtr[q->rulenum]->ret!=NULL )\r
+                               {\r
+                                       warnFL( eMsg1("rule %s returns a value(s)", r->text),\r
+                                                       FileStr[r->file], r->line );\r
+                               }\r
+                               if ( !r->linked )\r
+                               {\r
+                                       addFoLink(      r->next, r->rname, RulePtr[q->rulenum] );\r
+                                       r->linked = TRUE;\r
+                               }\r
+                       }\r
+                       FoLink( r->next );\r
+                       return;\r
+               case nToken :\r
+                       FoLink( ((TokNode *)p)->next );\r
+                       return;\r
+               case nAction :\r
+                       FoLink( ((ActionNode *)p)->next );\r
+                       return;\r
+               default :\r
+                       fatal_internal("invalid node type");\r
+       }\r
+}\r
+\r
+/*\r
+ * Add a reference to the end of a rule.\r
+ *\r
+ * 'r' points to the RuleBlk node in a rule.  r->end points to the last node\r
+ * (EndRule jtype) in a rule.\r
+ *\r
+ * Initial:\r
+ *             r->end -->      o\r
+ *\r
+ * After:\r
+ *             r->end -->      o-->o--> Ptr to node following rule r in another rule\r
+ *                                             |\r
+ *                                             o--> Ptr to node following another reference to r.\r
+ *\r
+ * Note that the links are added to the head of the list so that r->end->p1\r
+ * always points to the most recently added follow-link.  At the end, it should\r
+ * point to the last reference found in the grammar (starting from the 1st rule).\r
+ */\r
+void\r
+#ifdef __USE_PROTOS\r
+addFoLink( Node *p, char *rname, Junction *r )\r
+#else\r
+addFoLink( p, rname, r )\r
+Node *p;\r
+char *rname;\r
+Junction *r;\r
+#endif\r
+{\r
+       Junction *j;\r
+       require(r!=NULL,                                "addFoLink: incorrect rule graph");\r
+       require(r->end!=NULL,                   "addFoLink: incorrect rule graph");\r
+       require(r->end->jtype==EndRule, "addFoLink: incorrect rule graph");\r
+       require(p!=NULL,                                "addFoLink: NULL FOLLOW link");\r
+\r
+       j = newJunction();\r
+       j->rname = rname;                       /* rname on follow links point to target rule */\r
+       j->p1 = p;                                      /* link to other rule */\r
+       j->p2 = (Node *) r->end->p1;/* point to head of list */\r
+       r->end->p1 = (Node *) j;        /* reset head to point to new node */\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+GenCrossRef( Junction *p )\r
+#else\r
+GenCrossRef( p )\r
+Junction *p;\r
+#endif\r
+{\r
+       set a;\r
+       Junction *j;\r
+       RuleEntry *q;\r
+       unsigned e;\r
+       require(p!=NULL, "GenCrossRef: why are you passing me a null grammar?");\r
+\r
+       printf("Cross Reference:\n\n");\r
+       a = empty;\r
+       for (; p!=NULL; p = (Junction *)p->p2)\r
+       {\r
+               printf("Rule %20s referenced by {", p->rname);\r
+               /* make a set of rules for uniqueness */\r
+               for (j = (Junction *)(p->end)->p1; j!=NULL; j = (Junction *)j->p2)\r
+               {\r
+                       q = (RuleEntry *) hash_get(Rname, j->rname);\r
+                       require(q!=NULL, "GenCrossRef: FoLinks are screwed up");\r
+                       set_orel(q->rulenum, &a);\r
+               }\r
+               for (; !set_nil(a); set_rm(e, a))\r
+               {\r
+                       e = set_int(a);\r
+                       printf(" %s", RulePtr[e]->rname);\r
+               }\r
+               printf(" }\n");\r
+       }\r
+       set_free( a );\r
+}\r
+\r
+/*\r
+   The single argument is a pointer to the start of an element of a\r
+   C++ style function prototypet list.  Given a pointer to the start of\r
+   an formal we must locate the comma (or the end of the string)\r
+   and locate the datatype, formal name, and initial value expression.\r
+\r
+   The function returns a pointer to the character following the comma\r
+   which terminates the formal declaration, or a pointer to the end of\r
+   the string if none was found.\r
+\r
+   I thought we were parsing specialists, how come I'm doing this by\r
+   hand written code ?\r
+\r
+   Examples of input:\r
\r
+        Foo f,\r
+        Foo f = Foo(1),\r
+        Foo f = Foo(1,2),\r
+        Foo f = &farray[1,2],\r
+        Foo f = ",",\r
+        Foo f = ',',\r
+        TFoo<int,char> f = TFoo<int,char>(1,2),\r
+\r
+   A non-zero value for nesting indicates a problem matching '(' and ')',\r
+   '[' and ']', '<' and '>', '{' and '}', or improperly terminated string\r
+   or character literal.\r
+\r
+*/\r
+\r
+\r
+/*\r
+ *  Don't care if it is a valid string literal or not, just find the end\r
+ *  Start with pointer to leading "\""\r
+ */\r
+\r
+#ifdef __USE_PROTOS\r
+char * skipStringLiteral(char *pCurrent)\r
+#else\r
+char * skipStringLiteral(pCurrent)\r
+char *pCurrent;\r
+#endif\r
+{\r
+  char *p = pCurrent;\r
+  if (*p == 0) return p;\r
+  require (*p == '\"', "skipStringLiteral")\r
+  p++;\r
+  for (p = p; *p != 0; p++) {\r
+    if (*p == '\\') {\r
+      p++;\r
+      if (*p == 0) break;\r
+      p++;\r
+    }\r
+    if (*p == '\"') {\r
+      p++;\r
+      break;\r
+    }\r
+  }\r
+  return p;\r
+}\r
+\r
+/*\r
+ *  Don't care if it is a valid character literal or not, just find the end\r
+ *  Start with pointer to leading "'"\r
+ */\r
+\r
+#ifdef __USE_PROTOS\r
+char * skipCharLiteral(char *pStart)\r
+#else\r
+char * skipCharLiteral(pStart)\r
+ char *pStart;\r
+#endif\r
+{\r
+  char *p = pStart;\r
+  if (*p == 0) return p;\r
+  require (*p == '\'', "skipCharLiteral")\r
+  p++;\r
+  for (p = p; *p != 0; p++) {\r
+    if (*p == '\\') {\r
+      p++;\r
+      if (*p == 0) break;\r
+      p++;\r
+    }\r
+    if (*p == '\'') {\r
+      p++;\r
+      break;\r
+    }\r
+  }\r
+  return p;\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+char * skipSpaces(char *pStart)\r
+#else\r
+char * skipSpaces(pStart)\r
+char * pStart;\r
+#endif\r
+{\r
+  char *p = pStart;\r
+  while (*p != 0 && isspace(*p)) p++;\r
+  return p;\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+char * skipToSeparatorOrEqualSign(char *pStart, int *pNest)\r
+#else\r
+char * skipToSeparatorOrEqualSign(pStart, pNest)\r
+char *pStart;\r
+int *pNest;\r
+#endif\r
+{\r
+  char *p = pStart;\r
+  \r
+  int nest = 0;\r
+\r
+  *pNest = (-1);\r
+\r
+  while (*p != 0) {\r
+    switch (*p) {\r
+\r
+      case '(' :\r
+      case '[' :\r
+      case '<' :\r
+      case '{' :\r
+        nest++;\r
+        p++;\r
+        break;\r
+\r
+      case ')' :\r
+      case ']' :\r
+      case '>' :\r
+      case '}' :\r
+        nest--;\r
+        p++;\r
+        break;\r
+      \r
+      case '"' :\r
+        p = skipStringLiteral(p);\r
+        break;\r
+  \r
+      case '\'' :\r
+        p = skipCharLiteral(p);\r
+        break;\r
+\r
+      case '\\':\r
+        p++;\r
+        if (*p == 0) goto EXIT;\r
+        p++;\r
+        break;\r
+\r
+      case ',':\r
+      case '=':\r
+        if (nest == 0) goto EXIT;\r
+               p++;\r
+        break;\r
+\r
+      default:\r
+        p++;\r
+    }\r
+  }\r
+EXIT:\r
+  *pNest = nest;\r
+  return p;\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+char * skipToSeparator(char *pStart, int *pNest)\r
+#else\r
+char * skipToSeparator(pStart, pNest)\r
+char *pStart;\r
+int *pNest;\r
+#endif\r
+{\r
+  char * p = pStart;\r
+  for ( ; ; ) {\r
+    p = skipToSeparatorOrEqualSign(p, pNest);\r
+    if (*pNest != 0) return p;\r
+    if (*p == ',') return p;\r
+    if (*p == 0) return p;\r
+       p++;\r
+  }\r
+}\r
+\r
+/* skip to just past the "=" separating the declaration from the initialization value */\r
+\r
+#ifdef __USE_PROTOS\r
+char * getInitializer(char *pStart)\r
+#else\r
+char * getInitializer(pStart)\r
+char * pStart;\r
+#endif\r
+{\r
+       char *p;\r
+       char *pDataType;\r
+       char *pSymbol;\r
+       char *pEqualSign;\r
+       char *pValue;\r
+       char *pSeparator;\r
+       int nest = 0;\r
+\r
+       require(pStart!=NULL, "getInitializer: invalid string"); \r
+\r
+       p = endFormal(pStart,\r
+                             &pDataType,\r
+                                 &pSymbol,\r
+                                 &pEqualSign,\r
+                                 &pValue,\r
+                                 &pSeparator,\r
+                                 &nest);\r
+    if (nest != 0) return NULL;\r
+    if (pEqualSign == NULL) return NULL;\r
+    if (pValue == NULL) return NULL;\r
+       return strBetween(pValue, NULL, pSeparator);\r
+}\r
+\r
+/*\r
+   Examines the string from pStart to pEnd-1.\r
+   If the string has 0 length or is entirely white space\r
+   returns 1.  Otherwise 0.\r
+*/\r
+\r
+#ifdef __USE_PROTOS\r
+int isWhiteString(const char *pStart, const char *pEnd)\r
+#else\r
+int isWhiteString(pStart, pEnd)\r
+const char *pStart;\r
+const char *pEnd;\r
+#endif\r
+{\r
+  const char *p;\r
+  for (p = pStart; p < pEnd; p++) {\r
+    if (! isspace(*p)) return 0;\r
+  }\r
+  return 1;\r
+}\r
+\r
+/*\r
+   This replaces HasComma() which couldn't distinguish\r
+\r
+        foo ["a,b"]\r
+\r
+   from:\r
+\r
+        foo[a,b]\r
+\r
+*/\r
+\r
+#ifdef __USE_PROTOS\r
+int hasMultipleOperands(char *pStart)\r
+#else\r
+int hasMultipleOperands(pStart)\r
+char *pStart;\r
+#endif\r
+{\r
+  char *p = pStart;\r
+  int nest = 0;\r
+\r
+  p = skipSpaces(p);\r
+  if (*p == 0) return 0;\r
+  p = skipToSeparator(p, &nest);\r
+  if (nest == 0 && *p == ',') return 1;\r
+  return 0;\r
+}\r
+\r
+\r
+#define MAX_STR_BETWEEN_WORK_AREA 1000\r
+\r
+static char strBetweenWorkArea[MAX_STR_BETWEEN_WORK_AREA];\r
+\r
+\r
+/*\r
+       strBetween(pStart, pNext, pStop)\r
+\r
+    Creates a null terminated string by copying the text between two pointers\r
+       to a work area.  The start of the string is pStart.  The end of the string\r
+       is the character before pNext, or if pNext is null then the character before\r
+       pStop.  Trailing spaces are not included in the copy operation.\r
+       \r
+       This is used when a string contains several parts.  The pNext part may be\r
+       optional.  The pStop will stop the scan when the optional part is not present\r
+       (is a null pointer).\r
+*/\r
+\r
+#ifdef __USE_PROTOS\r
+char *strBetween(char *pStart, char *pNext, char *pStop)\r
+#else\r
+char *strBetween(pStart, pNext, pStop)\r
+char *pStart;\r
+char *pNext;\r
+char *pStop;\r
+#endif\r
+{\r
+  char *p;\r
+  char *q = strBetweenWorkArea;\r
+  const char *pEnd;\r
+\r
+  pEnd = (pNext != NULL) ? pNext : pStop;\r
+\r
+  require (pEnd != NULL, "pEnd == NULL");\r
+  require (pEnd >= pStart, "pEnd < pStart");\r
+  for (pEnd--; pEnd >= pStart; pEnd--) { /* MR31 */\r
+       if (! isspace(*pEnd)) break;\r
+  }\r
+  for (p = pStart;\r
+       p <= pEnd && q < &strBetweenWorkArea[MAX_STR_BETWEEN_WORK_AREA-2];\r
+          p++, q++) {\r
+        *q = *p;\r
+  }\r
+  *q = 0;\r
+  return strBetweenWorkArea;\r
+}\r
+\r
+/*\r
+   function     Returns pointer to character following separator at\r
+   value        which to continue search for next formal.  If at the\r
+                end of the string a pointer to the null byte at the\r
+                end of the string is returned.\r
+\r
+   pStart       Pointer to the starting position of the formal list\r
+\r
+                This may be the middle of a longer string, for example\r
+                when looking for the end of formal #3 starting from\r
+                the middle of the complete formal list.\r
+\r
+   ppDataType   Returns a pointer to the start of the data type in the\r
+                formal. Example: pointer to "Foo".\r
+\r
+   ppSymbol     Returns a pointer to the start of the formal symbol.\r
+                Example: pointer to "f".\r
+\r
+   ppEqualSign  Returns a pointer to the equal sign separating the\r
+                formal symbol from the initial value.  If there is \r
+                no "=" then this will be NULL.\r
+\r
+   ppValue      Returns a pointer to the initial value part of the\r
+                formal declaration.  Example: pointer to "&farray[1,2]"\r
+\r
+   ppSeparator  Returns a pointer to the character which terminated the\r
+                scan.  This should be a pointer to a comma or a null\r
+                byte which terminates the string.\r
+\r
+   pNest        Returns the nesting level when a separator was found.\r
+                This is non-zero for any kind of error.  This is zero\r
+                for a successful parse of this portion of the formal\r
+                list.\r
+\r
+*/ \r
\r
+#ifdef __USE_PROTOS\r
+char * endFormal(char *pStart,\r
+                 char **ppDataType,\r
+                 char **ppSymbol,\r
+                 char **ppEqualSign,\r
+                 char **ppValue,\r
+                 char **ppSeparator,\r
+                 int *pNest)\r
+#else\r
+char * endFormal(pStart,\r
+                            ppDataType,\r
+                                ppSymbol,\r
+                                ppEqualSign,\r
+                                ppValue,\r
+                                ppSeparator,\r
+                                pNest)\r
+char *pStart;\r
+char **ppDataType;\r
+char **ppSymbol;\r
+char **ppEqualSign;\r
+char **ppValue;\r
+char **ppSeparator;\r
+int *pNest;\r
+\r
+#endif\r
+{\r
+  char *p = pStart;\r
+  char *q;\r
+\r
+  *ppDataType = NULL;\r
+  *ppSymbol = NULL;\r
+  *ppEqualSign = NULL;\r
+  *ppValue = NULL;\r
+  *ppSeparator = NULL;\r
+\r
+  *pNest = 0;\r
+\r
+  /* The first non-blank is the start of the datatype */\r
+\r
+  p = skipSpaces(p);\r
+  if (*p == 0) goto EXIT;\r
+  *ppDataType = p;\r
+\r
+  /* We are not looking for the symbol, we are looking\r
+     for the separator that follows the symbol.  Then\r
+     we'll back up.\r
+   \r
+     Search for the ',' or '=" or null terminator.\r
+   */\r
+\r
+  p = skipToSeparatorOrEqualSign(p, pNest);\r
+\r
+  if (*pNest != 0) goto EXIT;\r
+\r
+  /*\r
+     Work backwards to find start of symbol\r
+     Skip spaces between the end of symbol and separator\r
+     Assume that there are no spaces in the formal, but\r
+     there is a space preceding the formal\r
+  */\r
+\r
+  for (q = &p[-1]; q >= *ppDataType; q--) {\r
+    if (! isspace(*q)) break;\r
+  }\r
+  if (q < *ppDataType) goto EXIT;\r
+\r
+  /*\r
+     MR26 Handle things like: IIR_Bool (IIR_Decl::*constraint)()\r
+     Backup until we hit the end of a symbol string, then find the\r
+     start of the symbol string.  This wont' work for functions\r
+     with prototypes, but works for the most common cases.  For\r
+     others, use typedef names.\r
+   */\r
+\r
+/* MR26 */  for (q = q; q >= *ppDataType; q--) {\r
+/* MR26 */    if (isalpha(*q) || isdigit(*q) || *q == '_' || *q == '$') break;\r
+/* MR26 */  }\r
+/* MR26 */  if (q < *ppDataType) goto EXIT;\r
+\r
+  for (q = q; q >= *ppDataType; q--) {\r
+    if ( ! (isalpha(*q) || isdigit(*q) || *q == '_' || *q == '$')) break;\r
+  }\r
+\r
+  *ppSymbol = &q[1];\r
+\r
+  if (*p == ',' || *p == 0) {\r
+    *ppSeparator = p;\r
+    goto EXIT;\r
+  }\r
+\r
+  *ppEqualSign = p;\r
+  p = skipSpaces(++p);\r
+  *ppValue = p;\r
+  if (*p == 0) goto EXIT;\r
+\r
+\r
+  while (*p != 0 && *pNest == 0 && *p != ',') {\r
+      p = skipToSeparator(p, pNest);\r
+  }\r
+  if (*pNest == 0) *ppSeparator = p;\r
+\r
+EXIT:\r
+  if (*p == ',') p++;\r
+  return p;\r
+}\r
diff --git a/Tools/CodeTools/Source/Pccts/antlr/mode.h b/Tools/CodeTools/Source/Pccts/antlr/mode.h
new file mode 100644 (file)
index 0000000..c08bf31
--- /dev/null
@@ -0,0 +1,12 @@
+#define START 0\r
+#define STRINGS 1\r
+#define ACTION_STRINGS 2\r
+#define ACTION_CHARS 3\r
+#define ACTION_COMMENTS 4\r
+#define TOK_DEF_COMMENTS 5\r
+#define TOK_DEF_CPP_COMMENTS 6\r
+#define ACTION_CPP_COMMENTS 7\r
+#define CPP_COMMENTS 8\r
+#define COMMENTS 9\r
+#define ACTIONS 10\r
+#define PARSE_ENUM_FILE 11\r
diff --git a/Tools/CodeTools/Source/Pccts/antlr/mrhoist.c b/Tools/CodeTools/Source/Pccts/antlr/mrhoist.c
new file mode 100644 (file)
index 0000000..110bf59
--- /dev/null
@@ -0,0 +1,3030 @@
+/*\r
+ * mrhoist.c\r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
+ * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
+ * company may do whatever they wish with source code distributed with\r
+ * PCCTS or the code generated by PCCTS, including the incorporation of\r
+ * PCCTS, or its output, into commerical software.\r
+ *\r
+ * We encourage users to develop software with PCCTS.  However, we do ask\r
+ * that credit is given to us for developing PCCTS.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like PCCTS and have developed a nice tool with the\r
+ * output, please mention that you developed it using PCCTS.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * ANTLR 1.33MR10\r
+ *\r
+ */\r
+\r
+#include <stdio.h>\r
+\r
+#include "pcctscfg.h"\r
+\r
+#include "set.h"\r
+#include "syn.h"\r
+#include "hash.h"\r
+#include "generic.h"\r
+#include "dlgdef.h"\r
+#include <ctype.h>\r
+\r
+#ifdef __USE_PROTOS\r
+void dumppred(Predicate *);\r
+#else\r
+void dumppred();\r
+#endif\r
+\r
+/*\r
+  Try to determine whether predicate "first" is true for\r
+    all cases where "second" is true.  Comparison takes place\r
+    without regard to context.\r
+  Assumes that predicate symbols have been expanded.\r
+  Assumes that there are no NAND or NOR nodes\r
+\r
+*/\r
+\r
+#ifdef __USE_PROTOS\r
+int MR_secondPredicateUnreachable(Predicate *first,Predicate *second)\r
+#else\r
+int MR_secondPredicateUnreachable(first,second)\r
+  Predicate     *first;\r
+  Predicate     *second;\r
+#endif\r
+{\r
+  Predicate     *f;\r
+  Predicate     *s;\r
+\r
+  if (first == NULL) {\r
+    return 1;\r
+  } else if (second == NULL) {\r
+    return 0;\r
+  } else if (first->down == NULL && second->down == NULL) {\r
+    if (first->source == second->source &&\r
+        first->inverted == second->inverted) {\r
+      return 1; /* look identical - will never reach alt2 */\r
+    } else {\r
+      return 0; /* look different */\r
+    };\r
+  } else if (first->down == NULL && second->down != NULL) {\r
+\r
+    if (second->expr == PRED_AND_LIST) {\r
+\r
+      /* unreachable if first covers any child of second */\r
+\r
+      for (s=second->down; s != NULL; s=s->right) {\r
+        if (MR_secondPredicateUnreachable(first,s)) {\r
+          return 1;\r
+        };\r
+      };\r
+      return 0;\r
+    } else if (second->expr == PRED_OR_LIST) {\r
+\r
+      /* unreachable if first covers every child of second */\r
+\r
+      for (s=second->down; s != NULL; s=s->right) {\r
+        if (!MR_secondPredicateUnreachable(first,s)) {\r
+          return 0;\r
+        };\r
+      };\r
+      return 1;\r
+    } else {\r
+      require (0,"Illegal pred->expr");\r
+      return 0; /* MR20 Make compiler happy */\r
+    };\r
+  } else if (first->down != NULL && second->down == NULL) {\r
+    if (first->expr == PRED_AND_LIST) {\r
+\r
+      /* unreachable if every child of first covers second */\r
+\r
+      for (f=first->down; f != NULL; f=f->right) {\r
+        if (!MR_secondPredicateUnreachable(f,second)) {\r
+          return 0;\r
+        };\r
+      };\r
+      return 1;\r
+    } else if (first->expr == PRED_OR_LIST) {\r
+\r
+      /* unreachable if any child of first covers second */\r
+\r
+      for (f=first->down; f != NULL; f=f->right) {\r
+        if (MR_secondPredicateUnreachable(f,second)) {\r
+          return 1;\r
+        };\r
+      };\r
+      return 0;\r
+    } else {\r
+      require (0,"Illegal predicate->expr");\r
+      return 0; /* MR20 Make compiler happy */\r
+    };\r
+  } else {\r
+\r
+    if (first->expr == PRED_AND_LIST && second->expr == PRED_AND_LIST) {\r
+\r
+      /* unreachable if each child of first covers at least one child of second */\r
+\r
+      for (f=first->down; f != NULL ; f=f->right) {\r
+        for (s=second->down; s != NULL ; s=s->right) {\r
+          if (MR_secondPredicateUnreachable(f,s)) goto A_next_f;\r
+        };\r
+        return 0;\r
+A_next_f:\r
+        continue;\r
+      };\r
+      return 1;\r
+\r
+    } else if (first->expr == PRED_AND_LIST && second->expr == PRED_OR_LIST) {\r
+\r
+      /* unreachable if each child of first covers ALL of second's children */\r
+\r
+      for (f=first->down; f != NULL ; f=f->right) {\r
+        for (s=second->down; s != NULL ; s=s->right) {\r
+          if (!MR_secondPredicateUnreachable(f,s)) return 0;\r
+        };\r
+      };\r
+      return 1;\r
+\r
+    } else if (first->expr == PRED_OR_LIST && second->expr == PRED_AND_LIST) {\r
+\r
+      /* unreachable if any child of second is covered by any child of first */\r
+\r
+      for (f=first->down; f != NULL ; f=f->right) {\r
+        for (s=second->down; s != NULL ; s=s->right) {\r
+          if (MR_secondPredicateUnreachable(f,s)) return 1;\r
+        };\r
+      };\r
+      return 0;\r
+\r
+    } else if (first->expr == PRED_OR_LIST && second->expr == PRED_OR_LIST) {\r
+\r
+      /* unreachable if every child of second is covered by some child of first */\r
+\r
+      for (f=first->down; f != NULL ; f=f->right) {\r
+        for (s=second->down; s != NULL ; s=s->right) {\r
+          if (MR_secondPredicateUnreachable(f,s)) goto B_next_f;\r
+        };\r
+        return 0;\r
+B_next_f:\r
+       continue;\r
+      };\r
+      return 1;\r
+\r
+    } else {\r
+      require (0,"Illegal predicate->expr");\r
+      return 0; /* MR20 Make compiler happy */\r
+    };\r
+  };\r
+  return 0; /* MR20 MSVC 5.0 complains about missing return statement */\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+void MR_xxxIndent(FILE *f,int depth)\r
+#else\r
+void MR_xxxIndent(f,depth)\r
+  FILE  *f;\r
+  int   depth;\r
+#endif\r
+{\r
+  int   i;\r
+\r
+  for (i=0; i<depth ; i++) {\r
+    fprintf(f,"  ");\r
+  };\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+void MR_stderrIndent(int depth)\r
+#else\r
+void MR_stderrIndent(depth)\r
+  int   depth;\r
+#endif\r
+{\r
+  MR_xxxIndent(stderr,depth);\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+void MR_outputIndent(int depth)\r
+#else\r
+void MR_outputIndent(depth)\r
+  int   depth;\r
+#endif\r
+{\r
+  MR_xxxIndent(output,depth);\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+void MR_set_reuse(set *s)\r
+#else\r
+void MR_set_reuse(s)\r
+  set   *s;\r
+#endif\r
+{\r
+  set_free(*s);\r
+  *s=empty;\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+void MR_dumpPredRuleRefStack(FILE *iounit,int indent)\r
+#else\r
+void MR_dumpPredRuleRefStack(iounit,indent)\r
+  FILE  *iounit;\r
+  int   indent;\r
+#endif\r
+{\r
+    int             i;\r
+    int             j;\r
+    int             count=MR_PredRuleRefStack.count;\r
+    RuleRefNode     *rrn=NULL;\r
+    Junction        *lastOne;\r
+\r
+    if (count == 0) {\r
+      fprintf(iounit,"empty\n");\r
+      return;\r
+    };\r
+    for (i=0; i < count; i++) {\r
+      rrn=(RuleRefNode *) MR_PredRuleRefStack.data[i];\r
+      for (j=0; j<indent; j++) fprintf(iounit," ");\r
+      fprintf(iounit,"#%-2d in rule %s (line %d %s) to rule %s\n",\r
+            i,rrn->rname,rrn->line,FileStr[rrn->file],rrn->text);\r
+    };\r
+    lastOne=MR_ruleReferenced(rrn);\r
+    if (lastOne != NULL) {\r
+      for (j=0; j<indent; j++) fprintf(iounit," ");\r
+      fprintf(iounit,"#%-2d in rule %s (line %d %s)\n",\r
+        count,lastOne->rname,lastOne->line,FileStr[lastOne->file]);\r
+    };\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+void MR_dumpTreeF(FILE *f,int depth,Tree *tree,int across)\r
+#else\r
+void MR_dumpTreeF(f,depth,tree,across)\r
+  FILE  *f;\r
+  Tree  *tree;\r
+  int   depth;\r
+  int   across;\r
+#endif\r
+{\r
+    int     newAcross=across;\r
+\r
+       if (tree == NULL ) return;\r
+       if (tree->down != NULL ) {\r
+      fprintf(output,"\n");\r
+      MR_outputIndent(depth);\r
+      fprintf(output, "(root =");\r
+    };\r
+       if (tree->token == ALT ) {\r
+      fprintf(output," %-16s","Alt");\r
+       } else if (tree->token==EpToken ) {\r
+      fprintf(output,"(%d)%13s",tree->v.rk," ");\r
+       } else {\r
+      fprintf(output," %-16s",TerminalString(tree->token));\r
+    };\r
+    if (tree->down != NULL) {\r
+      fprintf(output,"\n");\r
+      MR_outputIndent(depth+1);\r
+      MR_dumpTreeF(f,depth+1,tree->down,1);\r
+      newAcross=0;\r
+      fprintf(output,"\n");\r
+      MR_outputIndent(depth);\r
+      fprintf(output,")");\r
+    };\r
+    if (newAcross > 3) {\r
+      fprintf(output,"\n");\r
+      MR_outputIndent(depth);\r
+      newAcross=0;\r
+    };\r
+    MR_dumpTreeF(f,depth,tree->right,newAcross+1);\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+void MR_dumpTreeX(int depth,Tree *tree,int across)\r
+#else\r
+void MR_dumpTreeX(depth,tree,across)\r
+  Tree  *tree;\r
+  int   depth;\r
+  int   across;\r
+#endif\r
+{\r
+  MR_dumpTreeF(output,depth,tree,across);\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+void MR_dumpTokenSet(FILE *f,int depth,set s)\r
+#else\r
+void MR_dumpTokenSet(f,depth,s)\r
+  FILE  *f;\r
+  int   depth;\r
+  set   s;\r
+#endif\r
+{\r
+    int     i;\r
+    int     j;\r
+\r
+    unsigned  *pdq;\r
+\r
+    if (set_nil(s)) {\r
+      fprintf(f,"\n");\r
+      MR_xxxIndent(f,depth+1);\r
+      fprintf(f,"nil\n");\r
+      return;\r
+    };\r
+\r
+    pdq=set_pdq(s);\r
+    require(pdq != NULL,"set_pdq failed");\r
+    i=0;\r
+    for (i=0 ; ; i=i+4) {\r
+      fprintf(f,"\n");\r
+      MR_xxxIndent(f,depth+1);\r
+      for (j=0; j < 4 ; j++) {\r
+        if (pdq[i+j] == nil) break;\r
+        fprintf(f," %-16s",TerminalString(pdq[i+j]));\r
+      };\r
+      if (pdq[i+j] == nil) break;\r
+    };\r
+    fprintf(f,"\n");\r
+    free( (char *) pdq);\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+void MR_dumpPred1(int depth,Predicate *p,int withContext)\r
+#else\r
+void MR_dumpPred1(depth,p,withContext)\r
+  int           depth;\r
+  Predicate     *p;\r
+  int           withContext;\r
+#endif\r
+{\r
+  unsigned      k;\r
+\r
+  if (p == NULL) {\r
+    MR_outputIndent(depth);\r
+    fprintf(output,"The predicate is empty (or always true)\n\n");\r
+    return;\r
+  };\r
+  if (p->down != NULL) {\r
+    MR_outputIndent(depth);\r
+    if (p->inverted) {\r
+\r
+        /* MR14a Left out print expression in fprintf\r
+                 Reported by Manuel Kessler (mlkessle@cip.physik.uni-wuerzburg.de)\r
+        */\r
+\r
+      if (p->expr == PRED_AND_LIST) fprintf(output,"%s NAND (not AND) expr\n\n",p->expr);\r
+      if (p->expr == PRED_OR_LIST) fprintf(output,"%s NOR (not OR) expr\n\n",p->expr);\r
+    } else {\r
+      fprintf(output,"%s expr\n\n",p->expr);\r
+    };\r
+  } else {\r
+    MR_outputIndent(depth);\r
+    fprintf(output,"pred %s <<%s>>?\n",\r
+            (p->inverted ? " *not*" : ""),\r
+            (p->expr == NULL ? "null expr" : p->expr));\r
+    MR_outputIndent(depth+1);\r
+    fprintf(output,"              ");\r
+    fprintf(output,"  depth=k=%d",p->k);\r
+    if (p->source != NULL && p->source->guardpred) {\r
+      fprintf(output,"  (\"=>\" guard)");\r
+    }\r
+    if (p->source != NULL && p->source->ampersandPred != NULL) {\r
+      fprintf(output,"  (\"&&\" guard)");\r
+    };\r
+    k=set_int(p->completionSet);\r
+    if (k != nil) {\r
+      fprintf(output," Incomplete Set at k=%d !",k);\r
+    };\r
+    k=set_int(p->completionTree);\r
+    if (k != nil) {\r
+      fprintf(output," Incomplete Tree at k=%d !",k);\r
+    };\r
+    if (p->source != NULL) {\r
+      fprintf(output,"  rule %s  line %d  %s",\r
+                    p->source->rname,p->source->line,FileStr[p->source->file]);\r
+    };\r
+    fprintf(output,"\n");\r
+    if (withContext &&\r
+            (HoistPredicateContext ||\r
+             ! set_nil(p->scontext[1]) ||\r
+             p->tcontext != NULL)) {\r
+      if (p->k == 1) {\r
+        MR_outputIndent(depth+1);\r
+        fprintf(output,"set context: ");\r
+        MR_dumpTokenSet(output,depth+1,p->scontext[1]);\r
+      }\r
+      if (p->k != 1) {\r
+        MR_outputIndent(depth+1);\r
+        fprintf(output,"tree context:");\r
+        if (p->tcontext == NULL) {\r
+          fprintf(output," null");\r
+        } else {\r
+          MR_dumpTreeX(depth+2,p->tcontext,0);\r
+        };\r
+        fprintf(output,"\n");\r
+      };\r
+    };\r
+    fprintf(output,"\n");\r
+  };\r
+  if (p->down != NULL) {\r
+    MR_dumpPred1(depth+1,p->down,withContext);\r
+  };\r
+  if (p->right != NULL) {\r
+    MR_dumpPred1(depth,p->right,withContext);\r
+  };\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+void MR_dumpPred(Predicate *p,int withContext)\r
+#else\r
+void MR_dumpPred(p,withContext)\r
+  Predicate     *p;\r
+  int           withContext;\r
+#endif\r
+{\r
+  MR_dumpPred1(0,p,withContext);\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+Tree * MR_make_tree_from_set(set s)\r
+#else\r
+Tree * MR_make_tree_from_set(s)\r
+  set   s;\r
+#endif\r
+{\r
+  Tree  *t=NULL;\r
+  Tree  *node;\r
+  Tree  **tp=&t;\r
+  int   i;\r
+\r
+  unsigned *pdq=set_pdq(s);\r
+\r
+  if (pdq != NULL) {\r
+    for (i=0 ; pdq[i] != nil ; i++) {\r
+      node=tnode( (int) pdq[i]);\r
+      *tp=node;\r
+      tp=&(node->right);\r
+    };\r
+    *tp=NULL;\r
+    free ( (char *) pdq);\r
+  };\r
+  return t;\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+void MR_check_pred_too_long(Predicate *p,set completion)\r
+#else\r
+void MR_check_pred_too_long(p,completion)\r
+  Predicate     *p;\r
+  set           completion;\r
+#endif\r
+{\r
+  if (p != NULL &&\r
+      p->source != NULL &&\r
+      ! p->source->predTooLong) {\r
+    if ( !set_nil(completion)) {\r
+      p->source->predTooLong=1;\r
+warnFL("It is unusual (but ok) for a semantic predicate to test context past the end of its own rule",\r
+                                FileStr[p->source->file],p->source->line);\r
+    };\r
+  };\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+int MR_predicate_context_completed(Predicate *p)\r
+#else\r
+int MR_predicate_context_completed(p)\r
+  Predicate     *p;\r
+#endif\r
+{\r
+  if (p == NULL) return 1;\r
+  if (p->expr != PRED_AND_LIST &&\r
+      p->expr != PRED_OR_LIST) {\r
+    if ( ! set_nil(p->completionSet)) return 0;\r
+    if ( ! set_nil(p->completionTree)) return 0;\r
+  };\r
+  return MR_predicate_context_completed(p->down) &\r
+         MR_predicate_context_completed(p->right);\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+Node * MR_advance(Node *n)\r
+#else\r
+Node * MR_advance(n)\r
+  Node  *n;\r
+#endif\r
+{\r
+    if (n == NULL) return NULL;\r
+    switch (n->ntype) {\r
+      case nJunction:   return ((Junction *)n)->p1;\r
+      case nToken:      return ((TokNode *)n)->next;\r
+      case nRuleRef:    return ((RuleRefNode *)n)->next;\r
+      case nAction:     return ((ActionNode *)n)->next;\r
+      default:          return NULL;\r
+    };\r
+  return NULL; /* MSVC 5.0 complains about missing return statement */\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+Junction * MR_find_endRule(Node *n)\r
+#else\r
+Junction * MR_find_endRule(n)\r
+  Node  *n;\r
+#endif\r
+{\r
+    Node    *next;\r
+    if (n == NULL) return NULL;\r
+    for (next=n; next != NULL; next=MR_advance(next)) {\r
+      if (next->ntype == nJunction &&\r
+            ( (Junction *) next)->jtype == EndRule) {\r
+        break;\r
+      };\r
+    };\r
+    return (Junction *)next;\r
+}\r
+\r
+/*\r
+   Intersection:  a branch which is shorter is chosen\r
+   over one which is longer: (A B C) intersect (A B) yields (A B).\r
+\r
+   AND: a branch which is longer is chosen over the one\r
+   which is shorter: (A B C) AND (A B) yields (A B C)\r
+\r
+*/\r
+\r
+#ifdef __USE_PROTOS\r
+Tree *MR_computeTreeIntersection(Tree *l,Tree *r)\r
+#else\r
+Tree *MR_computeTreeIntersection(l,r)\r
+    Tree    *l;\r
+    Tree    *r;\r
+#endif\r
+{\r
+    Tree    *result=NULL;\r
+    Tree    **tail;\r
+    Tree    *p;\r
+    Tree    *q;\r
+    Tree    *match;\r
+\r
+    if (l == NULL || r == NULL) return NULL;\r
+    for (p=l; p != NULL; p=p->right) {\r
+      require(p->token != EpToken,"MR_computeTreeIntersection: p->EpToken unexpected\n");\r
+      require (p->token != ALT,"MR_computeTreeIntersection: p->ALT unexpected\n");\r
+    };\r
+    for (q=r; q != NULL; q=q->right) {\r
+      require(q->token != EpToken,"MR_computeTreeIntersection: q->EpToken unexpected\n");\r
+      require(q->token != ALT,"MR_computeTreeIntersection: q->ALT unexpected\n");\r
+    };\r
+\r
+    result=tnode(ALT);\r
+    tail=&(result->down);\r
+\r
+    for (p=l; p != NULL ; p=p->right) {\r
+      for (q=r; q != NULL ; q=q->right) {\r
+        if (p->token == q->token) {\r
+          match=tnode(p->token);\r
+          match->down=MR_computeTreeIntersection(p->down,q->down);\r
+          *tail=match;\r
+          tail=&(match->right);\r
+        };\r
+      };\r
+    };\r
+\r
+    *tail=NULL;\r
+    result=tshrink(result);\r
+    result=tflatten( result );\r
+    result=tleft_factor( result );\r
+    return result;\r
+}\r
+\r
+/* the predicates which are ANDed together have a common\r
+   context:  they must all have common roots.  Thus the\r
+   AND operation is more like an OR operation because\r
+   branches which are longer are grafted onto shorter\r
+   branches of the AND tree.  For instance combining\r
+   (A B C) with (A B C D) gives (A B C D).  There\r
+   should never be a case of (A B C) and (A B D) because\r
+   they have the same context.\r
+\r
+   Actually, this may not be true once one throws in\r
+   guard predicates which are defined by the user, not\r
+   the context.\r
+*/\r
+\r
+/* requires input trees to be in "canonical" format */\r
+\r
+#ifdef __USE_PROTOS\r
+Tree *MR_computeTreeAND(Tree *l,Tree *r)\r
+#else\r
+Tree *MR_computeTreeAND(l,r)\r
+    Tree    *l;\r
+    Tree    *r;\r
+#endif\r
+{\r
+    Tree    *result=NULL;\r
+    Tree    **tail;\r
+    Tree    *p;\r
+    Tree    *q;\r
+    Tree    *match;\r
+\r
+    if (l == NULL) return tdup(r);\r
+    if (r == NULL) return tdup(l);\r
+\r
+    for (p=l; p != NULL; p=p->right) {\r
+/**** require(p->token != EpToken,"MR_computeTreeAND: p->EpToken unexpected\n"); ****/\r
+      require (p->token != ALT,"MR_computeTreeAND: p->ALT unexpected\n");\r
+    };\r
+    for (q=r; q != NULL; q=q->right) {\r
+/**** require(q->token != EpToken,"MR_computeTreeAND: q->EpToken unexpected\n"); ****/\r
+      require(q->token != ALT,"MR_computeTreeAND: q->ALT unexpected\n");\r
+    };\r
+\r
+    result=tnode(ALT);\r
+    tail=&(result->down);\r
+\r
+    for (p=l; p != NULL ; p=p->right) {\r
+      for (q=r; q != NULL ; q=q->right) {\r
+        if (p->token == q->token) {\r
+          match=tnode(p->token);\r
+          match->down=MR_computeTreeAND(p->down,q->down);\r
+          *tail=match;\r
+          tail=&(match->right);\r
+        };\r
+      };\r
+    };\r
+\r
+    *tail=NULL;\r
+    result=tshrink(result);\r
+    result=tflatten( result );\r
+    result=tleft_factor( result );\r
+    return result;\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+void MR_union_plain_sets1(Predicate *p,set *theUnion)\r
+#else\r
+void MR_union_plain_sets1(p,theUnion)\r
+  Predicate     *p;\r
+  set           *theUnion;\r
+#endif\r
+{\r
+  if (p == NULL) return;\r
+  MR_union_plain_sets1(p->down,theUnion);\r
+  MR_union_plain_sets1(p->right,theUnion);\r
+  set_orin(theUnion,p->plainSet);\r
+  return;\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+set MR_union_plain_sets(Predicate *p)\r
+#else\r
+set MR_union_plain_sets(p)\r
+  Predicate     *p;\r
+#endif\r
+{\r
+  set   theUnion;\r
+\r
+  theUnion=empty;\r
+\r
+  MR_union_plain_sets1(p,&theUnion);\r
+  return theUnion;\r
+}\r
+\r
+/* does NOT left factor: do not want to merge\r
+     (A B) with (A) to get (A B)\r
+   in fact the opposite: (A B) with (A) gives (A)\r
+*/\r
+\r
+#ifdef __USE_PROTOS\r
+Tree *MR_compute_pred_tree_ctxXX(Predicate *p)\r
+#else\r
+Tree *MR_compute_pred_tree_ctxXX(p)\r
+  Predicate     *p;\r
+#endif\r
+{\r
+    Tree        *result=NULL;\r
+    Predicate   *q;\r
+    Tree        *t;\r
+\r
+    if (p == NULL) return NULL;\r
+\r
+/* this appears strange: why do we OR the context\r
+   of and AND predicate ?  It is because of the way\r
+   that predicates are evaluated: if the context is\r
+   wrong then it's the same as if the predicate was\r
+   true.  That means that even when one leg of an\r
+   AND has unmatched context, if the other leg has\r
+   matched context and is true then the predicate\r
+   succeeds.  It's only when all the legs have unmatched\r
+   context that this one can skip evaluation of the\r
+   predicates.\r
+*/\r
+    if (p->expr == PRED_OR_LIST ||\r
+        p->expr == PRED_AND_LIST) {\r
+      for (q=p->down; q != NULL ; q=q->right) {\r
+        t=MR_compute_pred_tree_ctxXX(q);\r
+        result=tappend(result,t);\r
+        t=NULL;\r
+      };\r
+\r
+      result=tshrink(result);\r
+      result=tflatten( result );\r
+\r
+/* does NOT left factor: do not want to merge\r
+     (A B) with (A) to get (A B)\r
+   in fact the opposite: (A B) with (A) gives (A)\r
+*/\r
+\r
+/**** result=tleft_factor( result ); ****/\r
+      return result;\r
+    };\r
+\r
+#if 0\r
+**    if (p->expr == PRED_AND_LIST) {\r
+**\r
+**      Predicate     *l;\r
+**      Predicate     *r;\r
+**      Tree          *l1;\r
+**      Tree          *r1;\r
+**      Tree          *prevl1;\r
+**\r
+**      l=p->down;\r
+**      require (l->right != NULL,"MR_compute_pred_tree - AND has only one child");\r
+**\r
+**/* l1 and r1 should already be in "canonical" format */\r
+**\r
+**      l1=MR_compute_pred_tree(l);\r
+**      for (r=l->right; r != NULL; r=r->right) {\r
+**        r1=MR_compute_pred_tree(r);\r
+**        prevl1=l1;\r
+**        l1=MR_computeTreeAND(l1,r1);\r
+**        Tfree(r1);\r
+**        Tfree(prevl1);\r
+**      };\r
+**\r
+**/* result from computeTreeAND should be in "canonical" format */\r
+**\r
+**      result=l1;\r
+**\r
+**/* result of MR_computeTreeAND should be in "canonical" format */\r
+**\r
+**      return result;\r
+**    };\r
+#endif\r
+\r
+    if (p->k == 1) {\r
+      result=MR_make_tree_from_set(p->scontext[1]);\r
+    } else {\r
+      result=tdup(p->tcontext);\r
+      result=MR_remove_epsilon_from_tree(result);\r
+      result=tshrink(result);\r
+      result=tflatten(result);\r
+      result=tleft_factor(result);\r
+    };\r
+    return result;\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+void MR_pred_depth(Predicate *p,int *maxDepth)\r
+#else\r
+void MR_pred_depth(p,maxDepth)\r
+  Predicate     *p;\r
+  int           *maxDepth;\r
+#endif\r
+{\r
+  if (p == NULL) return;\r
+  if (p->expr != PRED_OR_LIST &&\r
+      p->expr != PRED_AND_LIST) {\r
+    if (p->k > *maxDepth) *maxDepth=p->k;\r
+  };\r
+  MR_pred_depth(p->down,maxDepth);\r
+  MR_pred_depth(p->right,maxDepth);\r
+}\r
+\r
+/* this computes the OR of all the contexts */\r
+\r
+#ifdef __USE_PROTOS\r
+set MR_compute_pred_set(Predicate *p)\r
+#else\r
+set MR_compute_pred_set(p)\r
+  Predicate     *p;\r
+#endif\r
+{\r
+    set         result;\r
+    Predicate   *q;\r
+\r
+    result=empty;\r
+\r
+    if (p == NULL) return empty;\r
+\r
+    if (p->expr == PRED_OR_LIST ||\r
+        p->expr == PRED_AND_LIST) {         /* yes, I do mean PRED_AND_LIST !   */\r
+                                            /* remember: r1: (A)? => <<p>>? r2; */\r
+                                            /*           r2: (B)? => <<q>>? r3; */\r
+      set   t;\r
+\r
+      t=empty;\r
+      result=empty;\r
+\r
+      for (q=p->down; q != NULL; q=q->right) {\r
+        t=MR_compute_pred_set(q);\r
+        set_orin(&result,t);\r
+        set_free(t);\r
+      };\r
+      return result;\r
+    } else if (p->k > 1) {\r
+      return empty;\r
+    } else {\r
+      return set_dup(p->scontext[1]);\r
+    };\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+set MR_First(int ck,Junction *j,set *incomplete)\r
+#else\r
+set MR_First(ck,j,incomplete)\r
+  int       ck;\r
+  Junction  *j;\r
+  set       *incomplete;\r
+#endif\r
+{\r
+    Junction    *p;\r
+    set         tokensUsed;\r
+\r
+    tokensUsed=empty;\r
+\r
+       require(j->ntype==nJunction, "MR_First: non junction passed");\r
+\r
+       p = analysis_point((Junction *)j->p1);\r
+\r
+       REACH(p,ck,incomplete,tokensUsed);\r
+\r
+    return tokensUsed;\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+void MR_cleanup_pred_trees(Predicate *p)\r
+#else\r
+void MR_cleanup_pred_trees(p)\r
+  Predicate     *p;\r
+#endif\r
+{\r
+  Tree      *t;\r
+\r
+  if (p == NULL) return;\r
+  if (p->expr != PRED_OR_LIST &&\r
+      p->expr != PRED_AND_LIST) {\r
+    t=p->tcontext;\r
+    t=tshrink(t);\r
+    t=tflatten(t);\r
+    t=tleft_factor(t);\r
+    p->tcontext=t;\r
+  };\r
+  MR_cleanup_pred_trees(p->down);\r
+  MR_cleanup_pred_trees(p->right);\r
+}\r
+\r
+/* does NOT return canonical tree */\r
+\r
+#ifdef __USE_PROTOS\r
+Tree * MR_remove_epsilon_from_tree(Tree *t)\r
+#else\r
+Tree * MR_remove_epsilon_from_tree(t)\r
+  Tree  *t;\r
+#endif\r
+{\r
+  if (t == NULL) return NULL;\r
+\r
+  /* I think ALT can be ignored as a special case */\r
+\r
+  if (t->token != EpToken) {\r
+    t->down=MR_remove_epsilon_from_tree(t->down);\r
+    t->right=MR_remove_epsilon_from_tree(t->right);\r
+    return t;\r
+  } else {\r
+    Tree    *u;\r
+    u=MR_remove_epsilon_from_tree(t->right);\r
+    t->right=NULL;\r
+    Tfree(t);\r
+    return u;\r
+  };\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+void MR_complete_set(int predDepth,set *tokensUsed,set *incomplete)\r
+#else\r
+void MR_complete_set(predDepth,tokensUsed,incomplete)\r
+  int       predDepth;\r
+  set       *tokensUsed;\r
+  set       *incomplete;\r
+#endif\r
+{\r
+    int             i;\r
+    RuleRefNode     *ruleRef;\r
+       set             rk2;\r
+    set             b;\r
+       int             k2;\r
+    Junction        *save_MR_RuleBlkWithHalt;\r
+\r
+    if (set_int(*incomplete) > (unsigned) predDepth) {\r
+      return;\r
+    };\r
+\r
+    require(MR_PredRuleRefStack.count == MR_RuleBlkWithHaltStack.count,\r
+                "RuleRefStack and RuleBlkWithHaltStack not same size");\r
+\r
+    require(MR_RuleBlkWithHalt == NULL ||\r
+         (MR_RuleBlkWithHalt->jtype == RuleBlk && MR_RuleBlkWithHalt->end->halt == TRUE),\r
+                     "RuleBlkWithHalt has no halt set");\r
+\r
+    save_MR_RuleBlkWithHalt=MR_RuleBlkWithHalt;\r
+\r
+    if (MR_RuleBlkWithHalt != NULL) {\r
+      MR_RuleBlkWithHalt->end->halt=FALSE;\r
+    };\r
+\r
+    for (i=MR_PredRuleRefStack.count-1; i >= 0 ; i--) {\r
+      ruleRef=(RuleRefNode *)MR_PredRuleRefStack.data[i];\r
+      if (ruleRef == NULL) continue;\r
+\r
+      MR_RuleBlkWithHalt=(Junction *)MR_RuleBlkWithHaltStack.data[i];\r
+      if (MR_RuleBlkWithHalt != NULL) MR_RuleBlkWithHalt->end->halt=TRUE;\r
+\r
+      rk2=empty;\r
+      b=empty;\r
+\r
+      while ( !set_nil(*incomplete) ) {\r
+               k2=set_int(*incomplete);\r
+        if (k2 > predDepth) break;                    /* <=== another exit from loop */\r
+               set_rm(k2,*incomplete);\r
+        REACH(ruleRef->next,k2,&rk2,b);\r
+               set_orin(tokensUsed,b);\r
+               set_free(b);\r
+      };\r
+\r
+      if (MR_RuleBlkWithHalt != NULL) MR_RuleBlkWithHalt->end->halt=FALSE;\r
+\r
+         set_orin(incomplete,rk2);                       /* remember what we couldn't do */\r
+      set_free(rk2);\r
+         if (set_int(*incomplete) > (unsigned) predDepth) break;    /* <=== another exit from loop */\r
+    };\r
+\r
+    MR_RuleBlkWithHalt=save_MR_RuleBlkWithHalt;\r
+    if (MR_RuleBlkWithHalt != NULL) {\r
+      MR_RuleBlkWithHalt->end->halt=TRUE;\r
+    };\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+void MR_complete_tree(int predDepth,Tree **t,set *incomplete)\r
+#else\r
+void MR_complete_tree(predDepth,t,incomplete)\r
+  int       predDepth;\r
+  Tree      **t;\r
+  set       *incomplete;\r
+#endif\r
+{\r
+    int             i;\r
+    RuleRefNode     *ruleRef;\r
+       set             rk2;\r
+    Tree            *u;\r
+       unsigned        k2;\r
+    Junction        *save_MR_RuleBlkWithHalt;\r
+    int             saveConstrainSearch;\r
+\r
+    if (set_int(*incomplete) > (unsigned) predDepth) {\r
+      return;\r
+    };\r
+\r
+    require(MR_PredRuleRefStack.count == MR_RuleBlkWithHaltStack.count,\r
+                "RuleRefStack and RuleBlkWithHaltStack not same size");\r
+\r
+    require(MR_RuleBlkWithHalt == NULL ||\r
+         (MR_RuleBlkWithHalt->jtype == RuleBlk && MR_RuleBlkWithHalt->end->halt == TRUE),\r
+                     "RuleBlkWithHalt has no halt set");\r
+\r
+    save_MR_RuleBlkWithHalt=MR_RuleBlkWithHalt;\r
+    saveConstrainSearch=ConstrainSearch;\r
+    ConstrainSearch=0;\r
+\r
+    if (MR_RuleBlkWithHalt != NULL) {\r
+      MR_RuleBlkWithHalt->end->halt=FALSE;\r
+    };\r
+\r
+    for (i=MR_PredRuleRefStack.count-1; i >= 0 ; i--) {\r
+      ruleRef=(RuleRefNode *)MR_PredRuleRefStack.data[i];\r
+      if (ruleRef == NULL) continue;\r
+\r
+      MR_RuleBlkWithHalt=(Junction *)MR_RuleBlkWithHaltStack.data[i];\r
+\r
+      if (MR_RuleBlkWithHalt != NULL) MR_RuleBlkWithHalt->end->halt=TRUE;\r
+\r
+      rk2=empty;\r
+\r
+      while ( !set_nil(*incomplete) ) {        \r
+               k2 = set_int(*incomplete);\r
+        if (k2 > (unsigned) predDepth) break;       /* <=== another exit from loop */\r
+               set_rm(k2,*incomplete);\r
+               u = NULL;\r
+\r
+        TRAV(ruleRef->next,k2,&rk2,u);\r
+\r
+                       /* any subtrees missing k2 tokens, add u onto end */\r
+\r
+               *t=tlink(*t,u,k2);\r
+        Tfree(u);\r
+      }\r
+\r
+         set_orin(incomplete,rk2);         /* remember what we couldn't do */\r
+      set_free(rk2);\r
+\r
+      if (MR_RuleBlkWithHalt != NULL) MR_RuleBlkWithHalt->end->halt=FALSE;\r
+\r
+         if (set_int(*incomplete) > (unsigned) predDepth) break;    /* <=== another exit from loop */\r
+    };\r
+\r
+    MR_RuleBlkWithHalt=save_MR_RuleBlkWithHalt;\r
+\r
+    if (MR_RuleBlkWithHalt != NULL) {\r
+      MR_RuleBlkWithHalt->end->halt=TRUE;\r
+    };\r
+    ConstrainSearch=saveConstrainSearch;\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+void MR_complete_predicates(int predDepth,Predicate *pred)\r
+#else\r
+void MR_complete_predicates(predDepth,pred)\r
+  int           predDepth;\r
+  Predicate     *pred;\r
+#endif\r
+{\r
+  if (pred == NULL) return;\r
+  if (pred->expr != PRED_AND_LIST &&\r
+      pred->expr != PRED_OR_LIST) {\r
+    MR_complete_set(predDepth,&(pred->scontext[1]),&(pred->completionSet));\r
+    MR_complete_tree(predDepth,&(pred->tcontext),&(pred->completionTree));\r
+  };\r
+  MR_complete_predicates(predDepth,pred->down);\r
+  MR_complete_predicates(predDepth,pred->right);\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+Junction * MR_junctionWithoutP2(Junction *j)\r
+#else\r
+Junction * MR_junctionWithoutP2(j)\r
+  Junction  *j;\r
+#endif\r
+{\r
+  Junction  *thisAlt;\r
+\r
+/* don't want to follow p2 to the next alternative of this rule */\r
+/* insert a generic node with null p2 if necessary              */\r
+/* however FIRST requires a junction                            */\r
+\r
+  thisAlt=j;\r
+  if (thisAlt->p2 != NULL) {\r
+    if (thisAlt->p1->ntype == nJunction) {\r
+      thisAlt=(Junction *) thisAlt->p1;\r
+    } else {\r
+      thisAlt=newJunction();\r
+      thisAlt->p1=j->p1;\r
+      thisAlt->rname=j->rname;\r
+      thisAlt->file=j->file;\r
+      thisAlt->line=j->line;\r
+      j->p1=(Node *)thisAlt;\r
+    };\r
+  };\r
+  return thisAlt;\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+int MR_tree_equ(Tree *big, Tree *small) {\r
+#else\r
+int MR_tree_equ(big,small)\r
+  Tree  *big;\r
+  Tree  *small;\r
+{\r
+#endif\r
+\r
+  Tree      *b;\r
+  Tree      *s;\r
+  int       bcount=0;\r
+  int       scount=0;\r
+\r
+  if (small == NULL && big == NULL) return 1;\r
+  if (small == NULL) return 0;\r
+  if (big == NULL) return 0;\r
+\r
+  if (small->token == ALT) {\r
+    require(small->right == NULL,\r
+                "MR_tree_equ: small: ALT node has siblings");\r
+    return MR_tree_equ(big,small->down);\r
+  };\r
+  if (big->token == ALT) {\r
+    require(big->right == NULL,\r
+                "MR_tree_equ: big: ALT node has siblings");\r
+    return MR_tree_equ(big->down,small);\r
+  };\r
+  for (s=small; s != NULL; s=s->right) {\r
+    scount++;\r
+    require(s->token != EpToken,"MR_tree_equ: s->EpToken unexpected\n");\r
+  };\r
+  for (b=big; b != NULL; b=b->right) {\r
+    bcount++;\r
+    require(b->token != EpToken,"MR_tree_equ: b->EpToken unexpected\n");\r
+  };\r
+\r
+  if (bcount != scount) return 0;\r
+\r
+  for (s=small; s != NULL; s=s->right) {\r
+    for (b=big; b!= NULL; b=b->right) {\r
+      if (s->token == b->token) {\r
+        if (MR_tree_equ(b->down,s->down)) goto next_s;\r
+      };\r
+    };\r
+    return 0;\r
+next_s:\r
+    continue;\r
+  };\r
+  return 1;\r
+}\r
+\r
+/* this does not compare sources - only contexts ! */\r
+\r
+#ifdef __USE_PROTOS\r
+int MR_identicalContext(Predicate *p,Predicate *q)\r
+#else\r
+int MR_identicalContext(p,q)\r
+  Predicate     *p;\r
+  Predicate     *q;\r
+#endif\r
+{\r
+  if (p->k != q->k) return 0;\r
+  require ( (p->tcontext == NULL) == (q->tcontext == NULL),\r
+        "tcontext inconsistent");\r
+  if (p->k == 1) {\r
+    return set_equ(p->scontext[1],q->scontext[1]);\r
+  } else {\r
+    return MR_tree_equ(p->tcontext,q->tcontext);\r
+  };\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+void MR_reportSetSuppression(int predDepth,\r
+            set predSet,set plainSet,Junction *jPred,Junction *jPlain,Predicate *p)\r
+#else\r
+void MR_reportSetSuppression(predDepth,predSet,plainSet,jPred,jPlain,p)\r
+  int       predDepth;\r
+  set       predSet;\r
+  set       plainSet;\r
+  Junction  *jPred;\r
+  Junction  *jPlain;\r
+  Predicate *p;\r
+#endif\r
+{\r
+  if (InfoP) {\r
+    fprintf(output,"\n#if 0\n\n");\r
+    fprintf(output,"Hoisting of predicate suppressed by alternative without predicate.\n");\r
+    fprintf(output,"The alt without the predicate includes all cases where the predicate is false.\n\n");\r
+    fprintf(output,"   WITH predicate: line %d  %s\n",jPred->line,FileStr[jPred->file]);\r
+    if (jPlain != NULL) {\r
+      fprintf(output,"   WITHOUT predicate: line %d  %s\n",jPlain->line,FileStr[jPlain->file]);\r
+    } else {\r
+      fprintf(output,"   WITHOUT predicate: all alternatives without predicates (combined)\n");\r
+    };\r
+    if (predDepth == 1) {\r
+      fprintf(output,"\nThe context set for the predicate:\n");\r
+      MR_dumpTokenSet(output,1,predSet);\r
+    };\r
+    fprintf(output,"\nThe lookahead set for the alt WITHOUT the semantic predicate:\n");\r
+    MR_dumpTokenSet(output,1,plainSet);\r
+    fprintf(output,"\nThe predicate:\n\n");\r
+    MR_dumpPred1(1,p,1);\r
+    fprintf(output,"Chain of referenced rules:\n\n");\r
+    MR_dumpPredRuleRefStack(output,4);\r
+    fprintf(output,"\n#endif\n");\r
+  };\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+void MR_reportSetRestriction(int predDepth,set predSet,set plainSet,\r
+            Junction *jPred,Junction *jPlain,Predicate *origPred,Predicate *newPred)\r
+#else\r
+void MR_reportSetRestriction(predDepth,predSet,plainSet,jPred,jPlain,origPred,newPred)\r
+  int       predDepth;\r
+  set       predSet;\r
+  set       plainSet;\r
+  Junction  *jPred;\r
+  Junction  *jPlain;\r
+  Predicate *origPred;\r
+  Predicate *newPred;\r
+#endif\r
+{\r
+  set       intersect;\r
+\r
+  intersect=empty;\r
+\r
+  if (! InfoP) return;\r
+  fprintf(output,"\n#if 0\n\n");\r
+  fprintf(output,"Restricting the context of a predicate because of overlap in the lookahead set\n");\r
+  fprintf(output,"  between the alternative with the semantic predicate and one without\n");\r
+  fprintf(output,"Without this restriction the alternative without the predicate could not\n");\r
+  fprintf(output,"  be reached when input matched the context of the predicate and the predicate\n");\r
+  fprintf(output,"  was false.\n\n");\r
+\r
+  fprintf(output,"   WITH predicate: line %d  %s\n",jPred->line,FileStr[jPred->file]);\r
+  if (jPlain != NULL) {\r
+    fprintf(output,"   WITHOUT predicate: line %d  %s\n",jPlain->line,FileStr[jPlain->file]);\r
+  } else {\r
+    fprintf(output,"   WITHOUT predicate: all alternatives without predicates (combined)\n");\r
+  };\r
+  if (predDepth == 1) {\r
+    fprintf(output,"\nThe original context set for the predicate:\n");\r
+    MR_dumpTokenSet(output,1,predSet);\r
+  };\r
+  fprintf(output,"\nThe lookahead set for the alt WITHOUT the semantic predicate:\n");\r
+  MR_dumpTokenSet(output,1,plainSet);\r
+  if (predDepth == 1) {\r
+    fprintf(output,"\nThe intersection of the two sets\n");\r
+    intersect=set_and(predSet,plainSet);\r
+    MR_dumpTokenSet(output,1,intersect);\r
+    set_free(intersect);\r
+  };\r
+  fprintf(output,"\nThe original predicate:\n\n");\r
+  MR_dumpPred1(1,origPred,1);\r
+  fprintf(output,"The new (modified) form of the predicate:\n\n");\r
+  MR_dumpPred1(1,newPred,1);\r
+  fprintf(output,"#endif\n");\r
+}\r
+\r
+/* don't use Pass3 by itself unless you know that inverted is not important */\r
+\r
+#ifdef __USE_PROTOS\r
+Predicate * MR_removeRedundantPredPass3(Predicate *p)\r
+#else\r
+Predicate * MR_removeRedundantPredPass3(p)\r
+  Predicate *p;\r
+#endif\r
+{\r
+  Predicate     *q;\r
+\r
+  if (p == NULL) return NULL;\r
+  p->right=MR_removeRedundantPredPass3(p->right);\r
+  p->down=MR_removeRedundantPredPass3(p->down);\r
+  if (p->redundant) {\r
+    q=p->right;\r
+    p->right=NULL;\r
+    predicate_free(p);\r
+    return q;\r
+  };\r
+  if (p->expr == PRED_AND_LIST ||\r
+      p->expr == PRED_OR_LIST) {\r
+    if (p->down == NULL) {\r
+      q=p->right;\r
+      p->right=NULL;\r
+      predicate_free(p);\r
+      return q;\r
+    };\r
+    if (p->down != NULL && p->down->right == NULL) {\r
+      q=p->down;\r
+      q->right=p->right;\r
+      p->right=NULL;\r
+      p->down=NULL;\r
+      return q;\r
+    };\r
+  };\r
+  return p;\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+void MR_removeRedundantPredPass2(Predicate *p)\r
+#else\r
+void MR_removeRedundantPredPass2(p)\r
+  Predicate *p;\r
+#endif\r
+{\r
+  Predicate     *q;\r
+\r
+  if (p == NULL) return;\r
+\r
+  if (p->expr == PRED_AND_LIST) {\r
+    for (q=p->down ; q != NULL ; q=q->right) {\r
+      MR_removeRedundantPredPass2(q);\r
+      if (q->isConst) {\r
+        if (q->constValue == 0) {\r
+          p->isConst=1;\r
+          p->constValue=0;\r
+          return;\r
+        } else {\r
+          q->redundant=1;\r
+        };\r
+      };\r
+    };\r
+  };\r
+\r
+  if (p->expr == PRED_OR_LIST) {\r
+    for (q=p->down ; q != NULL ; q=q->right) {\r
+      MR_removeRedundantPredPass2(q);\r
+      if (q->isConst) {\r
+        if (q->constValue == 0) {\r
+          q->redundant=1;\r
+        } else {\r
+          p->isConst=1;\r
+          p->constValue=1;\r
+          return;\r
+        };\r
+      };\r
+    };\r
+  };\r
+\r
+  return;\r
+}\r
+\r
+#if 0\r
+   this totally ignores the implications of guarded predicates\r
+     in which the part after the guard could possibly cover a predicate.\r
+   that would be much harder:\r
+\r
+        rule : (A)? => <<p>>? sub1;     /* 1 */\r
+             | (B)? => <<r>>? sub2      /* 2 */\r
+        sub1 : (A)? => <<q>>? A B       /* 3 */\r
+             | B                        /* 4 - suppresses line 2 */\r
+             ;\r
+#endif\r
+\r
+#ifdef __USE_PROTOS\r
+void MR_apply_restriction1(Predicate *pred,set *plainSet,int *changed)\r
+#else\r
+void MR_apply_restriction1(pred,plainSet,changed)\r
+  Predicate     *pred;\r
+  set           *plainSet;\r
+  int           *changed;\r
+#endif\r
+{\r
+  if (pred == NULL) return;\r
+  MR_apply_restriction1(pred->right,plainSet,changed);\r
+  if (pred->down != NULL) {\r
+    MR_apply_restriction1(pred->down,plainSet,changed);\r
+  } else {\r
+    set     t;\r
+    if (pred->k == 1) {\r
+      t=set_dif(pred->scontext[1],*plainSet);\r
+      if (*changed == 0 &&\r
+          !set_equ(t,pred->scontext[1])) {\r
+        *changed=1;\r
+      };\r
+      if (set_nil(t)) {\r
+        pred->redundant=1;\r
+      };\r
+      set_free(pred->scontext[1]);\r
+      pred->scontext[1]=t;\r
+    };\r
+  };\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+void MR_orin_plainSet(Predicate *p,set plainSet)\r
+#else\r
+void MR_orin_plainSet(p,plainSet)\r
+  Predicate     *p;\r
+  set           plainSet;\r
+#endif\r
+{\r
+  if (p == NULL) return;\r
+  MR_orin_plainSet(p->down,plainSet);\r
+  MR_orin_plainSet(p->right,plainSet);\r
+  set_orin(&p->plainSet,plainSet);\r
+}\r
+\r
+Predicate   *PRED_SUPPRESS;\r
+\r
+#ifdef __USE_PROTOS\r
+Predicate * MR_find_in_aSubBlk(Junction *alt)\r
+#else\r
+Predicate * MR_find_in_aSubBlk(alt)\r
+  Junction  *alt;\r
+#endif\r
+{\r
+    Predicate       *root=NULL;\r
+    Predicate       **tail=NULL;\r
+\r
+       Junction        *p;\r
+\r
+    int             nAlts=0;\r
+    Junction        **jList;\r
+    Predicate       **predList;\r
+    int             *matchList;\r
+    set             predSet;\r
+    int             i;\r
+    int             j;\r
+    int             m;\r
+    int             predDepth;\r
+    set             incomplete;\r
+    set             union_plainSet;\r
+    set             setChange;\r
+    int             changed;\r
+    Predicate       *newPred;\r
+    set             setDif;\r
+    Predicate       *origPred;\r
+    int             depth1=1;             /* const int */\r
+    set             *plainContext;\r
+    set             plainSet;\r
+\r
+    predSet=empty;\r
+    incomplete=empty;\r
+    union_plainSet=empty;\r
+    setChange=empty;\r
+    setDif=empty;\r
+    plainSet=empty;\r
+\r
+    if (PRED_SUPPRESS == NULL) {\r
+      PRED_SUPPRESS=new_pred();\r
+      PRED_SUPPRESS->expr="Predicate Suppressed";\r
+    };\r
+\r
+    /* this section just counts the number of "interesting" alternatives  */\r
+    /*   in order to allocate arrays                                      */\r
+\r
+       for (p=alt; p!=NULL; p=(Junction *)p->p2) {\r
+         /* ignore empty alts */\r
+         if ( p->p1->ntype != nJunction ||\r
+               ((Junction *)p->p1)->jtype != EndBlk )  {\r
+        nAlts++;\r
+      };\r
+    };\r
+\r
+    /* if this is a (...)+ block then don't count the last alt because\r
+       it can't be taken until at least one time through the block.\r
+       In other words it isn't a real choice until the (...)+ is entered\r
+         at which point the hoisting issue is moot.\r
+       Maybe look at "ignore" instead ?\r
+    */\r
+\r
+    if (alt->jtype == aPlusBlk) {\r
+      nAlts--;\r
+    };\r
+\r
+    jList=(Junction **)calloc(nAlts,sizeof(Junction *));\r
+    require(jList!=NULL,"cannot allocate MR_find_in_aSubBlk jList");\r
+\r
+    plainContext=(set *)calloc(nAlts,sizeof(set));\r
+    require(plainContext!=NULL,"cannot allocate MR_find_in_aSubBlk plainContext");\r
+    for (m=0; m < nAlts; m++) plainContext[m]=empty;\r
+\r
+    predList=(Predicate **)calloc(nAlts,sizeof(Predicate *));\r
+    require(predList!=NULL,"cannot allocate MR_find_in_aSubBlk predList");\r
+\r
+    matchList=(int *)calloc(nAlts,sizeof(int));\r
+    require(matchList!=NULL,"cannot allocate MR_find_in_aSubBlk matchList");\r
+\r
+    /* this section just fills in the arrays previously allocated       */\r
+    /* the most interesting one is matchList[]                          */\r
+    /*                                                                  */\r
+    /*   bit 0 => this alt has a semantic pred which is "covered"       */\r
+    /*              by an alt without a semantic pred.  Don't hoist.    */\r
+\r
+       for (i=0,p=alt;\r
+         p!=NULL && i<nAlts;\r
+         i++,p=(Junction *)p->p2) {\r
+\r
+         /* ignore empty alts */\r
+\r
+         if ( p->p1->ntype != nJunction ||\r
+               ((Junction *)p->p1)->jtype != EndBlk )  {\r
+        jList[i]=MR_junctionWithoutP2(p);\r
+        predList[i]=find_predicates(p->p1);      /* should be jList ????? */\r
+        if (predList[i] != NULL) {\r
+          MR_cleanup_pred_trees(predList[i]);    /* flatten & left factor */\r
+          plainContext[i]=MR_union_plain_sets(predList[i]);\r
+        } else {\r
+          MR_set_reuse(&plainSet);\r
+          MR_set_reuse(&incomplete);\r
+          plainSet=MR_First(depth1,jList[i],&incomplete);\r
+          MR_complete_set(depth1,&plainSet,&incomplete);\r
+          require(set_nil(incomplete),"couldn't complete k=1");\r
+          plainContext[i]=plainSet;\r
+          plainSet=empty;\r
+        };\r
+        set_orin(&union_plainSet,plainContext[i]);\r
+      };\r
+    };\r
+\r
+    if (nAlts == 1) {\r
+      goto EXIT_SIMPLE;\r
+    };\r
+\r
+/*\r
+ *  Looking for cases where alt i has a semantic pred and alt j does not.\r
+ *  Don't care about cases where lookahead for semantic predicates overlap\r
+ *    because normal predicate hoisting does the correct thing automatically.\r
+ *  Don't care about cases where lookahead for alts without semantic predicates\r
+ *    overlap because normal prediction does the correct thing automatically.\r
+ *\r
+ *  When we find such a case check for one of three subcases:\r
+ *\r
+ *      1.  if lookahead for alt i is contained in the lookahead for any\r
+ *          alt j then ignore semantic predicate of alt i\r
+ *      2.  if lookahead for alt i is not contained in the lookahead for\r
+ *          any alt j then add add predicate i to the OR list to be hoisted\r
+ *      3.  if lookahead for alt i overlaps the lookahead for some alt j then\r
+ *          add a dummy semantic predicate for alt j\r
+ *\r
+ *  There is an implicit assumption that the context of all alternatives following\r
+ *  the rule being processed here are identical (but may vary from hoist to\r
+ *  hoist depending on the place where the rule was invoked that led to hoisting\r
+ *  these predicates.  In othere words in the fragment:\r
+ *\r
+ *            ( <<a>>? a1 a2 a3 | <<b>>? b1 b2 b3 )\r
+ *\r
+ *  both a3 and b3 have the same follow sets  because they are both at the end of\r
+ *  alternatives in the same block.\r
+ */\r
+\r
+    for (i=0; i < nAlts; i++) {\r
+      if (jList[i] == NULL) continue;\r
+      if (predList[i] == NULL) continue;\r
+\r
+        /* if the predicate depth turns out to be one token only */\r
+        /*   then it is can be easily represented as a set and   */\r
+        /*   compared to the junction set create by MR_First()   */\r
+\r
+      predDepth=0;\r
+      MR_pred_depth(predList[i],&predDepth);\r
+      require (predDepth >= 1,"MR_find_in_aSubBlk: pred depth < 1");\r
+      require (predDepth <= CLL_k,"MR_find_in_aSubBlk: predDepth > CLL_k");\r
+\r
+        /* complete predicates to predDepth\r
+           If completed to depth=1 then the context would be incomplete.\r
+           The context would be truncated and the predicate simplify routine\r
+             would have incomplete information.  It would lead to\r
+             either false matches of failure to find true matches.\r
+        */\r
+\r
+      MR_complete_predicates(predDepth,predList[i]);\r
+\r
+      if (predList[i] != NULL) {\r
+        MR_cleanup_pred_trees(predList[i]);    /* flatten & left factor */\r
+      };\r
+\r
+      /* If the predicate depth is 1 then it is possible to suppress\r
+           a predicate completely using a single plain alt.  Check for suppression\r
+           by a single plain alt first because it gives better messages.  If that\r
+           fails try the union of all the plain alts.\r
+      */\r
+\r
+      if (predDepth == 1) {\r
+\r
+        MR_set_reuse(&predSet);\r
+        predSet=MR_compute_pred_set(predList[i]);   /* ignores k>1 predicates */\r
+\r
+        for (j=0; j < nAlts; j++) {\r
+          if (jList[j] == NULL) continue;\r
+          if (j == i) continue;\r
+\r
+          MR_set_reuse(&setDif);\r
+          setDif=set_dif(predSet,plainContext[j]);\r
+          if (set_nil(setDif)) {\r
+            matchList[i] |= 1;\r
+            MR_reportSetSuppression(predDepth,predSet,plainContext[j],jList[i],jList[j],predList[i]);\r
+            predicate_free(predList[i]);\r
+            predList[i]=PRED_SUPPRESS;\r
+            goto next_i;\r
+          };\r
+\r
+        }; /* end loop on j */\r
+\r
+        changed=0;\r
+\r
+        /* predicate_dup is only to give good error messages */\r
+        /* remember to do a predicate_free()                 */\r
+\r
+        origPred=predicate_dup(predList[i]);\r
+        MR_apply_restriction1(predList[i],&union_plainSet,&changed);\r
+        if (changed) {\r
+\r
+          /* don't use Pass3 by itself unless you know that inverted is not important */\r
+\r
+          newPred=MR_removeRedundantPredPass3(predList[i]);\r
+          newPred=MR_predSimplifyALL(newPred);\r
+          if (newPred == NULL) {\r
+            matchList[i] |= 1;\r
+            MR_reportSetSuppression(predDepth,predSet,union_plainSet,jList[i],\r
+                                                            NULL,origPred);\r
+            predList[i]=PRED_SUPPRESS;\r
+          } else {\r
+            MR_reportSetRestriction(predDepth,predSet,union_plainSet,jList[i],\r
+                                                    NULL,origPred,newPred);\r
+            predList[i]=newPred;\r
+          };\r
+        };\r
+        predicate_free(origPred);\r
+        origPred=NULL;\r
+      };\r
+\r
+      /*\r
+         If the predicate depth is > 1 then it can't be suppressed completely\r
+           because the code doesn't support inspection of such things.  They're\r
+           much messier than k=1 sets.\r
+      */\r
+\r
+      if (predDepth > 1 ) {\r
+\r
+        changed=0;\r
+\r
+        /* predicate_dup is only to give good error messages */\r
+        /* remember to do a predicate_free()                 */\r
+\r
+        origPred=predicate_dup(predList[i]);\r
+        MR_apply_restriction1(predList[i],&union_plainSet,&changed);\r
+        if (changed) {\r
+          newPred=MR_removeRedundantPredPass3(predList[i]);\r
+          newPred=MR_predSimplifyALL(newPred);\r
+          if (newPred == NULL) {\r
+            matchList[i] |= 1;\r
+            MR_reportSetSuppression(predDepth,predSet,union_plainSet,jList[i],\r
+                                                            NULL,origPred);\r
+            predList[i]=PRED_SUPPRESS;\r
+          } else {\r
+            MR_reportSetRestriction(predDepth,predSet,union_plainSet,jList[i],\r
+                                                    NULL,origPred,newPred);\r
+            predList[i]=newPred;\r
+          };\r
+        };\r
+        predicate_free(origPred);\r
+        origPred=NULL;\r
+      };\r
+next_i:\r
+      continue;\r
+    };\r
+\r
+EXIT_SIMPLE:\r
+\r
+    root = new_pred();\r
+    root->expr=PRED_OR_LIST;\r
+    tail = &(root->down);\r
+\r
+    for (i=0 ; i< nAlts ; i++) {\r
+      if (jList[i] == NULL) continue;\r
+\r
+      if (predList[i] == NULL) {\r
+        continue;\r
+      } else if ( (matchList[i] & 1) != 0) {\r
+        if (predList[i] != PRED_SUPPRESS) {\r
+          predicate_free(predList[i]);\r
+        };\r
+        continue;\r
+      };\r
+\r
+      /* make an OR list of predicates */\r
+\r
+      *tail=predList[i];\r
+      tail=&(predList[i]->right);\r
+    };\r
+\r
+       /* if just one pred, remove OR root */\r
+\r
+       if (root->down == NULL) {\r
+      predicate_free(root);\r
+      root=NULL;\r
+    } else if (root->down->right == NULL) {\r
+      Predicate     *p=root->down;\r
+      root->down=NULL;\r
+      predicate_free(root);\r
+      root=p;\r
+       }\r
+\r
+    root=MR_predSimplifyALL(root);\r
+\r
+    MR_orin_plainSet(root,union_plainSet);\r
+\r
+    set_free(predSet);\r
+    set_free(union_plainSet);\r
+    set_free(incomplete);\r
+    set_free(setChange);\r
+    set_free(setDif);\r
+\r
+    for (m=0; m < nAlts; m++) set_free(plainContext[m]);\r
+\r
+    free ( (char *) jList);\r
+    free ( (char *) predList);\r
+    free ( (char *) matchList);\r
+    free ( (char *) plainContext);\r
+\r
+       return root;\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+void MR_predContextPresent(Predicate *p,int *allHaveContext,int *noneHaveContext)\r
+#else\r
+void MR_predContextPresent(p,allHaveContext,noneHaveContext)\r
+  Predicate     *p;\r
+  int           *allHaveContext;\r
+  int           *noneHaveContext;\r
+#endif\r
+{\r
+  if (p == NULL) return;\r
+  MR_predContextPresent(p->right,allHaveContext,noneHaveContext);\r
+  if (p->expr != PRED_AND_LIST &&\r
+      p->expr != PRED_OR_LIST) {\r
+    if (set_nil(p->scontext[1]) == 0 ||\r
+            (p->tcontext != NULL)) {\r
+      *noneHaveContext=0;\r
+    } else {\r
+      *allHaveContext=0;\r
+    };\r
+  };\r
+  MR_predContextPresent(p->down,allHaveContext,noneHaveContext);\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+int MR_pointerStackPush(PointerStack *ps,void *dataPointer)\r
+#else\r
+int MR_pointerStackPush(ps,dataPointer)\r
+  PointerStack  *ps;\r
+  void          *dataPointer;\r
+#endif\r
+{\r
+  void             **newStack;\r
+  int              newSize;\r
+  int              i;\r
+\r
+  if (ps->count == ps->size) {\r
+    newSize=20+ps->size*2;\r
+    newStack=(void **)calloc(newSize,sizeof(void *));\r
+    require (newStack != NULL,"cannot allocate PointerStack");\r
+    for (i=0; i < ps->size; i++) {\r
+      newStack[i]=ps->data[i];\r
+    };\r
+    if (ps->data != NULL) free( (char *) ps->data);\r
+    ps->data=newStack;\r
+    ps->size=newSize;\r
+  };\r
+  ps->data[ps->count]=dataPointer;\r
+  ps->count++;\r
+  return ps->count-1;\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+void * MR_pointerStackPop(PointerStack *ps)\r
+#else\r
+void * MR_pointerStackPop(ps)\r
+  PointerStack  *ps;\r
+#endif\r
+{\r
+  void  *dataPointer;\r
+\r
+  require(ps->count > 0,"MR_pointerStackPop underflow");\r
+\r
+  dataPointer=ps->data[ps->count-1];\r
+  ps->data[ps->count-1]=NULL;\r
+  (ps->count)--;\r
+  return dataPointer;\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+void * MR_pointerStackTop(PointerStack *ps)\r
+#else\r
+void * MR_pointerStackTop(ps)\r
+  PointerStack  *ps;\r
+#endif\r
+{\r
+  require(ps->count > 0,"MR_pointerStackTop underflow");\r
+  return ps->data[ps->count-1];\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+void MR_pointerStackReset(PointerStack *ps)\r
+#else\r
+void MR_pointerStackReset(ps)\r
+  PointerStack  *ps;\r
+#endif\r
+{\r
+  int i;\r
+  if (ps->data != NULL) {\r
+    for (i=0; i < ps->count ; i++) {\r
+       ps->data[i]=NULL;\r
+    };\r
+  };\r
+  ps->count=0;\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+Junction *MR_nameToRuleBlk(char *name)\r
+#else\r
+Junction *MR_nameToRuleBlk(name)\r
+  char  *name;\r
+#endif\r
+{\r
+    RuleEntry *q;\r
+\r
+    require (RulePtr != NULL,"MR_nameToRule: RulePtr not initialized");\r
+\r
+    if (name == NULL) return NULL;\r
+\r
+    q = (RuleEntry *) hash_get(Rname,name);\r
+\r
+       if ( q == NULL ) {\r
+      return NULL;\r
+    } else {\r
+      return RulePtr[q->rulenum];\r
+    };\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+Junction * MR_ruleReferenced(RuleRefNode *rrn)\r
+#else\r
+Junction * MR_ruleReferenced(rrn)\r
+  RuleRefNode   *rrn;\r
+#endif\r
+{\r
+    return MR_nameToRuleBlk(rrn->text);\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+void MR_comparePredLeaves(Predicate *me,Predicate *myParent,Predicate *him,Predicate *hisParent)\r
+#else\r
+void MR_comparePredLeaves(me,myParent,him,hisParent)\r
+    Predicate *me;\r
+    Predicate *myParent;\r
+    Predicate *him;\r
+    Predicate *hisParent;\r
+#endif\r
+{\r
+    if (me == NULL) return;\r
+    if (me == him) {\r
+      MR_comparePredLeaves(me->right,myParent,him,hisParent);\r
+      return;\r
+    } else if (me->expr == PRED_AND_LIST ||\r
+               me->expr == PRED_OR_LIST) {\r
+      MR_comparePredLeaves(me->down,me,him,hisParent);\r
+      MR_comparePredLeaves(me->right,myParent,him,hisParent);\r
+      return;\r
+    } else {\r
+      if (me->source != NULL) {\r
+\r
+        /* predicate->invert can be set only in the predEntry predicates        */\r
+        /* thus they are only visible after the predEntry predicates have been "unfolded" */\r
+\r
+        int     sameSource=(me->source == him->source);\r
+        int     sameInvert=1 &\r
+                 (1 + me->inverted + him->inverted + me->source->inverted + him->source->inverted);\r
+        int     samePredEntry=(me->source->predEntry != NULL\r
+                                 && him->source->predEntry != NULL\r
+                                    && me->source->predEntry == him->source->predEntry);\r
+        if (sameInvert && (sameSource || samePredEntry)) {\r
+          if (MR_identicalContext(me,him)) {\r
+\r
+            /* identical predicates */\r
+\r
+            if (hisParent->expr == PRED_OR_LIST &&\r
+                myParent->expr == PRED_OR_LIST) {\r
+              me->redundant=1;\r
+            } else if (hisParent->expr == PRED_AND_LIST &&\r
+                       myParent->expr == PRED_AND_LIST) {\r
+              me->redundant=1;\r
+            } else if (  (hisParent->expr == PRED_OR_LIST &&\r
+                          myParent->expr == PRED_AND_LIST)\r
+                       ||\r
+                         (hisParent->expr == PRED_AND_LIST &&\r
+                          myParent->expr == PRED_OR_LIST)\r
+                      ) {\r
+              myParent->redundant=1;\r
+            } else {\r
+              require (0,"MR_comparePredLeaves: not both PRED_LIST");\r
+            };\r
+          };\r
+        };  /* end same source or same predEntrr with same invert sense */\r
+\r
+        /* same predEntry but opposite invert sense */\r
+\r
+        if (!sameInvert && (sameSource || samePredEntry)) {\r
+          if (MR_identicalContext(me,him)) {\r
+            if (hisParent->expr == PRED_OR_LIST &&\r
+                myParent->expr == PRED_OR_LIST) {\r
+              myParent->isConst=1;\r
+              myParent->constValue=1;\r
+            } else if (hisParent->expr == PRED_AND_LIST &&\r
+                       myParent->expr == PRED_AND_LIST) {\r
+              myParent->isConst=1;\r
+              myParent->constValue=0;\r
+            } else if (  (hisParent->expr == PRED_OR_LIST &&\r
+                          myParent->expr == PRED_AND_LIST)\r
+                       ||\r
+                         (hisParent->expr == PRED_AND_LIST &&\r
+                          myParent->expr == PRED_OR_LIST)\r
+                      ) {\r
+              me->redundant=1;\r
+            } else {\r
+              require (0,"MR_comparePredLeaves: not both PRED_LIST");\r
+            };\r
+          };\r
+        };  /* end same predEntry with opposite invert sense */\r
+      };\r
+\r
+      MR_comparePredLeaves(me->right,myParent,him,hisParent);\r
+      return;\r
+    };\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+void MR_removeRedundantPredPass1(Predicate *me,Predicate *myParent)\r
+#else\r
+void MR_removeRedundantPredPass1(me,myParent)\r
+  Predicate     *me;\r
+  Predicate     *myParent;\r
+#endif\r
+{\r
+    if (me == NULL) return;\r
+    if (me->redundant) {\r
+      MR_removeRedundantPredPass1(me->right,myParent);\r
+      return;\r
+    };\r
+    if (me->expr == PRED_AND_LIST ||\r
+        me->expr == PRED_OR_LIST) {\r
+      MR_removeRedundantPredPass1(me->down,me);\r
+      MR_removeRedundantPredPass1(me->right,myParent);\r
+    } else {\r
+      require (me->source != NULL,"me->source == NULL");\r
+      if (myParent != NULL) {\r
+        MR_comparePredLeaves(myParent->down,myParent,me,myParent);\r
+      };\r
+      MR_removeRedundantPredPass1(me->right,myParent);\r
+    };\r
+}\r
+\r
+/* pretty much ignores things with the inverted bit set */\r
+\r
+#ifdef __USE_PROTOS\r
+Predicate *MR_predFlatten(Predicate *p)\r
+#else\r
+Predicate *MR_predFlatten(p)\r
+  Predicate     *p;\r
+#endif\r
+{\r
+    if (p == NULL) return NULL;\r
+    if (p->expr == PRED_OR_LIST\r
+        || p->expr == PRED_AND_LIST) {\r
+\r
+      Predicate     *child;\r
+      Predicate     *gchild;\r
+      Predicate     **tail;\r
+      Predicate     *next;\r
+      char          *PRED_XXX_LIST=p->expr;\r
+\r
+      require (p->down != NULL,"MR_predFlatten AND/OR no child");\r
+\r
+\r
+      p->down=MR_predFlatten(p->down);\r
+      p->right=MR_predFlatten(p->right);\r
+      child=p->down;\r
+      if (child->right == NULL) {\r
+        child->right=p->right;\r
+        p->right=NULL;\r
+        p->down=NULL;\r
+        if (p->inverted) child->inverted=!child->inverted;\r
+        predicate_free(p);\r
+        return child;\r
+      };\r
+\r
+      /* make a single list of all children and grandchildren */\r
+\r
+      tail=&(p->down);\r
+      for (child=p->down; child != NULL; child=next) {\r
+        if (child->expr != PRED_XXX_LIST\r
+              || child->inverted\r
+                || child->predEntry != NULL) {\r
+          *tail=child;\r
+          tail=&(child->right);\r
+          next=child->right;\r
+        } else {\r
+          for (gchild=child->down;\r
+               gchild != NULL;\r
+               gchild=gchild->right) {\r
+            *tail=gchild;\r
+            tail=&(gchild->right);\r
+          };\r
+          next=child->right;\r
+          child->right=NULL;\r
+          child->down=NULL;\r
+          predicate_free(child);\r
+        };\r
+      };\r
+      *tail=NULL;\r
+      return p;\r
+    } else {\r
+      p->right=MR_predFlatten(p->right);\r
+      return p;\r
+    };\r
+}\r
+\r
+static char *alwaysFalseWarning=NULL;\r
+\r
+#ifdef __USE_PROTOS\r
+Predicate *checkPredicateConflict(Predicate *p)\r
+#else\r
+Predicate *checkPredicateConflict(p)\r
+  Predicate     *p;\r
+#endif\r
+{\r
+  if (p->isConst) {\r
+    if (p->constValue == 1) {\r
+      predicate_free(p);\r
+      return NULL;\r
+    } else {\r
+      if (InfoP && !p->conflictReported) {\r
+        p->conflictReported=1;\r
+        fprintf(output,"\n#if 0\n\n");\r
+        fprintf(output,"The following predicate expression will always be false:\n\n");\r
+        MR_dumpPred1(1,p,1);\r
+        fprintf(output,"\n#endif\n");\r
+      };\r
+\r
+      if (alwaysFalseWarning != CurRule) {\r
+        alwaysFalseWarning=CurRule;\r
+        if (InfoP) {\r
+          warnNoFL(eMsg1("one (or more) predicate expression hoisted into rule \"%s\" are always false \\r
+- see output file for more information",CurRule));\r
+        } else {\r
+          warnNoFL(eMsg1("one (or more) predicate expressions hoisted into rule \"%s\" are always false \\r
+- use \"-info p\" for more information",CurRule));\r
+        };\r
+      };\r
+    };\r
+  };\r
+  return p;\r
+}\r
+\r
+\r
+#ifdef __USE_PROTOS\r
+int MR_countPredNodes(Predicate *p)\r
+#else\r
+int MR_countPredNodes(p)\r
+  Predicate     *p;\r
+#endif\r
+{\r
+  if (p == NULL) return 0;\r
+  return 1 + MR_countPredNodes(p->down) + MR_countPredNodes(p->right);\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+Predicate *MR_predSimplifyALLX(Predicate *p,int skipPass3)\r
+#else\r
+Predicate *MR_predSimplifyALLX(p,skipPass3)\r
+  Predicate     *p;\r
+  int           skipPass3;\r
+#endif\r
+{\r
+  int       countBefore;\r
+  int       countAfter;\r
+\r
+  countAfter=MR_countPredNodes(p);\r
+\r
+  do {\r
+      if (p == NULL) return NULL;\r
+      if (p->right == NULL && p->down == NULL) return p;\r
+      countBefore=countAfter;\r
+      MR_simplifyInverted(p,0);\r
+      p=MR_predFlatten(p);\r
+      MR_removeRedundantPredPass1(p,NULL);\r
+      MR_removeRedundantPredPass2(p);\r
+      if (! skipPass3) {\r
+        p=checkPredicateConflict(p);\r
+        p=MR_removeRedundantPredPass3(p);\r
+      };\r
+      countAfter=MR_countPredNodes(p);\r
+  } while (countBefore != countAfter);\r
+\r
+  return p;\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+Predicate *MR_predSimplifyALL(Predicate *p)\r
+#else\r
+Predicate *MR_predSimplifyALL(p)\r
+  Predicate     *p;\r
+#endif\r
+{\r
+  return MR_predSimplifyALLX(p,0);\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+void MR_releaseResourcesUsedInRule(Node *n)\r
+#else\r
+void MR_releaseResourcesUsedInRule(n)\r
+  Node  *n;\r
+#endif\r
+{\r
+   Node         *next;\r
+   Junction     *j;\r
+   int          i;\r
+\r
+   if (n == NULL) return;\r
+   if (n->ntype == nJunction) {\r
+     j=(Junction *) n;\r
+\r
+     if (j->predicate != NULL) {\r
+       predicate_free(j->predicate);\r
+       j->predicate=NULL;\r
+     };\r
+     for (i=0; i< CLL_k; i++) {\r
+       set_free(j->fset[i]);\r
+       j->fset[i]=empty;\r
+     };\r
+     if (j->ftree != NULL) {\r
+       Tfree(j->ftree);\r
+       j->ftree=NULL;\r
+     };\r
+     if (j->jtype == EndRule) return;\r
+     if (j->jtype != RuleBlk && j->jtype != EndBlk) {\r
+       if (j->p2 != NULL && !j->ignore) {   /* MR11 */\r
+          MR_releaseResourcesUsedInRule(j->p2);\r
+       };\r
+     };\r
+   };\r
+   next=MR_advance(n);\r
+   MR_releaseResourcesUsedInRule(next);\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+int MR_allPredLeaves(Predicate *p)\r
+#else\r
+int MR_allPredLeaves(p)\r
+  Predicate *p;\r
+#endif\r
+{\r
+  Predicate     *q;\r
+\r
+  if (p == NULL) return 1;\r
+\r
+  for (q=p; q != NULL; q=q->right) {\r
+   if (q->down != NULL) return 0;\r
+  };\r
+  return 1;\r
+}\r
+\r
+/* make sure it works for the last rule in a file */\r
+\r
+#ifdef __USE_PROTOS\r
+int MR_offsetFromRule(Node *n)\r
+#else\r
+int MR_offsetFromRule(n)\r
+  Node      *n;\r
+#endif\r
+{\r
+  Junction  *j;\r
+  int       offset=(-1);\r
+\r
+  for (j=SynDiag; j != NULL; j=(Junction *)j->p2) {\r
+\r
+    require (j->ntype == nJunction && j->jtype == RuleBlk,"Not a rule block");\r
+\r
+    if (n->file < j->file) {\r
+      return offset;\r
+    };\r
+    if (n->file == j->file) {\r
+      if (n->line < j->line) {\r
+        return (offset < 0) ? 0 : offset;\r
+      } else {\r
+        offset=n->line - j->line;\r
+        if (offset == 0) return 0;\r
+      };\r
+    };\r
+  };\r
+  return offset;\r
+}\r
+\r
+#define ruleNameMax 50\r
+\r
+static char ruleNameStatic1[ruleNameMax];\r
+static char ruleNameStatic2[ruleNameMax+10];\r
+\r
+#ifdef __USE_PROTOS\r
+char * MR_ruleNamePlusOffset(Node *n)\r
+#else\r
+char * MR_ruleNamePlusOffset(n)\r
+  Node      *n;\r
+#endif\r
+{\r
+    int     offset=MR_offsetFromRule(n);\r
+\r
+    strncpy(ruleNameStatic1,n->rname,ruleNameMax);\r
+    if (offset < 0) {\r
+      sprintf(ruleNameStatic2,"%s/?",ruleNameStatic1);\r
+    } else {\r
+      sprintf(ruleNameStatic2,"%s/%d",ruleNameStatic1,offset+1);\r
+    };\r
+    return ruleNameStatic2;\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+int MR_max_height_of_tree(Tree *t)\r
+#else\r
+int MR_max_height_of_tree(t)\r
+  Tree  *t;\r
+#endif\r
+{\r
+  int       h;\r
+  int       height=0;\r
+  Tree      *u;\r
+\r
+  if (t == NULL) return 0;\r
+\r
+  require (t->token != ALT && t->token != EpToken,"MR_max_height_of_tree ALT or EpToken");\r
+\r
+  for (u=t; u != NULL; u=u->right) {\r
+    h=MR_max_height_of_tree(u->down)+1;\r
+    if (h > height) height=h;\r
+  };\r
+  return height;\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+int MR_all_leaves_same_height(Tree *t,int depth)\r
+#else\r
+int MR_all_leaves_same_height(t,depth)\r
+  Tree  *t;\r
+  int   depth;\r
+#endif\r
+{\r
+  if (t == NULL) {\r
+    return (depth==0);\r
+  };\r
+\r
+  require (t->token != ALT && t->token != EpToken,"MR_all_leaves_same_height ALT or EpToken");\r
+\r
+  if (depth == 0) {\r
+    return 0;\r
+  } else {\r
+    if ( ! MR_all_leaves_same_height(t->down,depth-1)) {\r
+      return 0;\r
+    };\r
+    if (t->right == NULL) {\r
+      return 1;\r
+    } else {\r
+      return MR_all_leaves_same_height(t->right,depth);\r
+    };\r
+  };\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+void MR_projectTreeOntoSet(Tree *tree,int ck,set *ckset)\r
+#else\r
+void MR_projectTreeOntoSet(tree,ck,ckset)\r
+  Tree  *tree;\r
+  int   ck;\r
+  set   *ckset;\r
+#endif\r
+{\r
+    if (tree == NULL) return;\r
+\r
+    require(tree->token != EpToken,"MR_projectTreeOntoSet: EpToken unexpected\n");\r
+\r
+    MR_projectTreeOntoSet(tree->right,ck,ckset);\r
+    if (tree->token == ALT) {\r
+      MR_projectTreeOntoSet(tree->down,ck,ckset);\r
+    } else {\r
+      if (ck > 1) {\r
+        MR_projectTreeOntoSet(tree->down,ck-1,ckset);\r
+      } else {\r
+        set_orel(tree->token,ckset);\r
+      };\r
+    };\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+int MR_comparePredicates(Predicate *a,Predicate *b)\r
+#else\r
+int MR_comparePredicates(a,b)\r
+  Predicate     *a;\r
+  Predicate     *b;\r
+#endif\r
+{\r
+  Predicate     *p;\r
+  Predicate     *q;\r
+\r
+  if (a == b) return 1;\r
+  if (a == NULL || b == NULL ) return 0;\r
+  if (a->down == NULL && b->down == NULL) {\r
+\r
+    /* predicate->invert can be set only in the predEntry predicates                  */\r
+    /* thus they are only visible after the predEntry predicates have been "unfolded" */\r
+\r
+    int     sameSource=(a->source == b->source);\r
+    int     sameInvert= 1 & (1 +a->inverted + b->inverted +\r
+                                a->source->inverted + b->source->inverted);\r
+    int     samePredEntry=(a->source->predEntry != NULL\r
+                                 && b->source->predEntry != NULL\r
+                                    && a->source->predEntry == b->source->predEntry);\r
+    if (sameInvert && (sameSource || samePredEntry)) {\r
+      if (MR_identicalContext(a,b)) {\r
+         return 1;\r
+      };\r
+    };\r
+    return 0;\r
+  };\r
+  if (a->down == NULL || b->down == NULL) return 0;\r
+  if (a->expr != b->expr) return 0;\r
+\r
+  for (p=a->down; p != NULL; p=p->right) {\r
+    for (q=b->down; q != NULL; q=q->right) {\r
+      if (MR_comparePredicates(p,q)) goto NEXT_P;\r
+    };\r
+    return 0;\r
+NEXT_P:\r
+    continue;\r
+  };\r
+  return 1;\r
+}\r
+\r
+/*\r
+ *  action->inverted can be set only when a predicate symbol appears in\r
+ *      a rule:  "rule : <<!XXX>>? X".  It cannot be set under any\r
+ *      other circumstances.  In particular it cannot be set by\r
+ *      "#pred NotA !A" or by "#pred Nota <<!A>>?".  The first case\r
+ *      creates a predEntry and the predicate expression of that predEntry\r
+ *      has inverted set.  In the second case, the code for handling "!"\r
+ *      is only present in buildAction, which is not called by the #pred\r
+ *      semantic routines, only when a <<...>>? is recognized as part of\r
+ *      a rule definition.\r
+ *\r
+ *  predicate->inverted can only be set by a predicate created by a #pred\r
+ *      expression, such as "#pred NotA !A" or "#pred NotXY ! (X && Y) or\r
+ *      "#pred XbarY !(X && Y)".  In particular, it cannot be set by any\r
+ *      predicate expression occurring under any other circumstances.\r
+ *      The #pred predicate expresssions are stored with in predEntry->pred\r
+ *      and do not normally appear anywhere else until the predicates are\r
+ *      "unfolded" in order to recognize redundancies, conflicts, and\r
+ *      tautologies.\r
+ *\r
+ *  The unfold routine expands all references to #pred expressions.\r
+ *\r
+ *  The simplifyInvert goes through and propagates the invert bit so that\r
+ *      all OR and AND nodes are un-inverted.\r
+ *\r
+ *  Note that !(A and B) => (!A or !B)\r
+ *            !(A or B)  => (!A and !B)\r
+ *\r
+ *  MR_unfold() is called to expand predicate symbols by replacing predicates\r
+ *    that reference predicate entries with the copies of the predicate entries.\r
+ *    Each reference receives a duplicate of the original.  This is necessary\r
+ *    because the next phase involves simplification and removal of redundant\r
+ *    predicate nodes.  Anyway, the point I'm making is that predicate->invert\r
+ *    should not be set in any predicate until it has been expanded.\r
+ *\r
+ *    This is a recursive structure, but there is no need for "recursive expansion"\r
+ *    by which I mean a predicate symbol refers to other predicate symbols which\r
+ *    must also be expanded.\r
+ *\r
+ *    Recursive expansion is *not* performed by this routine because it is not\r
+ *    necessary.  Expansion of references is performed by predPrimary when\r
+ *    a new predicate symbol is created by referring to others in the pred expr.\r
+ */\r
+\r
+#ifdef __USE_PROTOS\r
+Predicate *MR_unfold(Predicate *pred)\r
+#else\r
+Predicate *MR_unfold(pred)\r
+  Predicate     *pred;\r
+#endif\r
+{\r
+  Predicate     *result;\r
+\r
+  if (pred == NULL) return NULL;\r
+\r
+  pred->right=MR_unfold(pred->right);\r
+\r
+  if (pred->down == NULL) {\r
+    if (pred->source->predEntry != NULL) {\r
+      if (pred->source->predEntry->pred == NULL) {\r
+        ; /* do nothing */ /* a reference to a literal #pred (perhaps with "!" */\r
+      } else {\r
+        result=predicate_dup_without_context(pred->source->predEntry->pred);\r
+        if (pred->inverted) {\r
+          result->inverted=!result->inverted;\r
+        };\r
+        if (pred->source->inverted) {\r
+          result->inverted=!result->inverted;\r
+        };\r
+        result->right=pred->right;\r
+        pred->right=NULL;\r
+        predicate_free(pred);\r
+/***    result=MR_unfold(result); *** not necessary */    /* recursive expansion */\r
+        return result;\r
+      };\r
+    } else {\r
+      ; /* do nothing */ /* an inline literal predicate */\r
+    };\r
+  } else {\r
+    pred->down=MR_unfold(pred->down);\r
+  };\r
+  return pred;\r
+}\r
+\r
+/* this should be called immediately after MR_unfold() and\r
+   at no other times\r
+*/\r
+\r
+#ifdef __USE_PROTOS\r
+void MR_simplifyInverted(Predicate *pred,int inverted)\r
+#else\r
+void MR_simplifyInverted(pred,inverted)\r
+  Predicate     *pred;\r
+  int           inverted;\r
+#endif\r
+{\r
+  int       newInverted;\r
+\r
+  if (pred == NULL) return;\r
+\r
+  MR_simplifyInverted(pred->right,inverted);\r
+\r
+  newInverted= 1 & (inverted + pred->inverted);\r
+\r
+  if (pred->down == NULL) {\r
+    pred->inverted=newInverted;\r
+  } else {\r
+    if (newInverted != 0) {\r
+      if (pred->expr == PRED_AND_LIST) {\r
+        pred->expr=PRED_OR_LIST;\r
+      } else {\r
+        pred->expr=PRED_AND_LIST;\r
+      };\r
+    };\r
+    pred->inverted=0;\r
+    MR_simplifyInverted(pred->down,newInverted);\r
+  };\r
+}\r
+\r
+/* only remove it from AND and OR nodes, not leaves */\r
+\r
+#ifdef __USE_PROTOS\r
+void MR_clearPredEntry(Predicate *p)\r
+#else\r
+void MR_clearPredEntry(p)\r
+  Predicate     *p;\r
+#endif\r
+{\r
+   if (p == NULL) return;\r
+   MR_clearPredEntry(p->down);\r
+   MR_clearPredEntry(p->right);\r
+   if (p->down != NULL) p->predEntry=NULL;\r
+}\r
+\r
+\r
+#ifdef __USE_PROTOS\r
+void MR_orphanRules(FILE *f)\r
+#else\r
+void MR_orphanRules(f)\r
+  FILE      *f;\r
+#endif\r
+{\r
+       set         a;\r
+    Junction    *p;\r
+    unsigned    e;\r
+    RuleEntry   *re;\r
+\r
+       a=empty;\r
+\r
+    if (! InfoO) return;\r
+\r
+       for (p=SynDiag; p!=NULL; p = (Junction *)p->p2) {\r
+      if ( (Junction *) (p->end)->p1 == NULL) {\r
+        re=(RuleEntry *) hash_get(Rname,p->rname);\r
+        require (re != NULL,"RuleEntry == NULL");\r
+               set_orel(re->rulenum, &a);\r
+      }\r
+       }\r
+\r
+    if (set_deg(a) > 1) {\r
+      fprintf(f,"note: Start rules: {");\r
+      for (; !set_nil(a); set_rm(e,a)) {\r
+        e=set_int(a);\r
+        fprintf(f," %s",RulePtr[e]->rname);\r
+      };\r
+      fprintf(f," }\n");\r
+    };\r
+       set_free( a );\r
+}\r
+\r
+/*  merge (X Y) and (X) to create (X)  */\r
+\r
+static int      *mergeChain;\r
+static Tree     *mergeTree;\r
+\r
+#ifdef __USE_PROTOS\r
+Tree *MR_merge_tree_contexts_client(Tree *t,int chain[])\r
+#else\r
+Tree *MR_merge_tree_contexts_client(t,chain)\r
+  Tree  *t;\r
+  int   chain[];\r
+#endif\r
+{\r
+  if (t == NULL)  return NULL;\r
+  if (chain[0] == 0) {\r
+    Tree    *u=t->right;\r
+    t->right=NULL;\r
+    Tfree(t);\r
+    return MR_merge_tree_contexts_client(u,&chain[0]);\r
+  }\r
+  if (chain[0] == t->token) {\r
+    t->down=MR_merge_tree_contexts_client(t->down,&chain[1]);\r
+  };\r
+  t->right=MR_merge_tree_contexts_client(t->right,&chain[0]);\r
+  return t;\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+void MR_iterateOverTreeContexts(Tree *t,int chain[])\r
+#else\r
+void MR_iterateOverTreeContexts(t,chain)\r
+  Tree          *t;\r
+  int           chain[];\r
+#endif\r
+{\r
+  if (t == NULL) return;\r
+  chain[0]=t->token;\r
+  if (t->down != NULL) {\r
+    MR_iterateOverTreeContexts(t->down,&chain[1]);\r
+  } else {\r
+    MR_merge_tree_contexts_client(mergeTree,mergeChain);\r
+  };\r
+  MR_iterateOverTreeContexts(t->right,&chain[0]);\r
+  chain[0]=0;\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+Tree *MR_merge_tree_contexts(Tree *t)\r
+#else\r
+Tree *MR_merge_tree_contexts(t)\r
+  Tree  *t;\r
+#endif\r
+{\r
+    int     h=MR_max_height_of_tree(t);\r
+\r
+    mergeTree=t;\r
+    mergeChain=(int *) calloc(h+1,sizeof(int));\r
+    require (mergeChain != NULL,"MR_merge_tree_contexts: can't alloc chain");\r
+    MR_iterateOverTreeContexts(t,mergeChain);\r
+    t=tshrink(t);\r
+    t=tflatten(t);\r
+    t=tleft_factor(t);\r
+    free ( (char *) mergeChain);\r
+    mergeChain=NULL;\r
+    return t;\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+Tree *MR_compute_pred_tree_context(Predicate *p)\r
+#else\r
+Tree *MR_compute_pred_tree_context(p)\r
+  Predicate *p;\r
+#endif\r
+{\r
+  Tree  *t;\r
+\r
+  t=MR_compute_pred_tree_ctxXX(p);\r
+  MR_merge_tree_contexts(t);\r
+  return t;\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+void MR_guardPred_plainSet(ActionNode *anode,Predicate *pred)\r
+#else\r
+void MR_guardPred_plainSet(anode,pred)\r
+  ActionNode    *anode;\r
+  Predicate     *pred;\r
+#endif\r
+{\r
+  Junction      *j;\r
+  Predicate     *workPred;\r
+  set           maskSet;\r
+\r
+  maskSet=empty;\r
+\r
+  if (!MRhoisting) return;\r
+\r
+  /* it doesn't really matter whether the predicate has\r
+     depth k=1 or k>1 because we're not really looking\r
+     at the predicate itself, just the stuff "behind"\r
+     the predicate.\r
+  */\r
+\r
+  /* shouldn't have to worry about REACHing off the end\r
+     of the rule containing the predicate because the\r
+     Rule->end->halt should have been set already by the\r
+     the code which handles RuleRef nodes.\r
+\r
+     We don't want to REACH off the end of the rule because\r
+     this would give the "global" follow context rather than\r
+     the "local" context.\r
+\r
+         r1a : (A)? => <<p>>? r2 (A|B)\r
+         r1b : (A)? => <<p>>? r2 (A|C)\r
+         r2  : ();\r
+\r
+     For r1a we want follow of predicate = {A B}\r
+             we want plainSet = {B}\r
+     For r1b we want follow of predicate = {A C}\r
+             we want plainSet = {C}\r
+  */\r
+\r
+  require (anode->next->ntype == nJunction,"MR_guardpred_plainSet not Junction");\r
+  j=(Junction *)(anode->next);\r
+\r
+  workPred=predicate_dup_without_context(pred);\r
+  workPred->k=1;\r
+  workPred->scontext[1]=MR_First(1,j, &(workPred->completionSet) );\r
+  MR_complete_predicates(1,workPred);\r
+  if (pred->k == 1) {\r
+    maskSet=pred->scontext[1];\r
+  } else {\r
+    MR_projectTreeOntoSet(pred->tcontext,1,&maskSet);\r
+  }\r
+  pred->plainSet=set_dif(workPred->scontext[1],maskSet);\r
+  predicate_free(workPred);\r
+}\r
+\r
+/*******************************************************************************/\r
+\r
+static Tree *       suppressTree;\r
+static int *        suppressChain;  /* element 0 not used */\r
+static set *        suppressSets;\r
+static Node *       suppressNode;\r
+static int          suppressChainLength;\r
+int                 MR_SuppressSearch=0;\r
+static int          suppressSucceeded;\r
+static Predicate *  suppressPredicate;\r
+\r
+#ifdef __USE_PROTOS\r
+int MR_isChain(Tree *t)\r
+#else\r
+int MR_isChain(t)\r
+  Tree  *t;\r
+#endif\r
+{\r
+  Tree  *u;\r
+\r
+  for (u=t; u != NULL; u=u->down) {\r
+    if (u->right != NULL) return 0;\r
+  }\r
+  return 1;\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+int MR_suppressK_client(Tree *tree,int tokensInChain[])\r
+#else\r
+int MR_suppressK_client(tree,tokensInChain)\r
+  Tree      *tree;\r
+  int       tokensInChain[];\r
+#endif\r
+{\r
+  int       i;\r
+  set       *save_fset;\r
+  int       save_ConstrainSearch;\r
+  set       incomplete;\r
+  Tree      *t;\r
+\r
+  suppressSucceeded=0;  /* volatile */\r
+\r
+  if (suppressSets == NULL) {\r
+    suppressSets=(set *) calloc (CLL_k+1,sizeof(set));\r
+    require (suppressSets != NULL,"MR_suppressK_client: suppressSets alloc");\r
+  };\r
+\r
+  for (suppressChainLength=1;\r
+       tokensInChain[suppressChainLength+1] != 0;\r
+       suppressChainLength++) {};\r
+\r
+  require (suppressChainLength != 0,"MR_suppressK_client: chain empty");\r
+\r
+  for (i=1 ; i <= suppressChainLength ; i++) {\r
+    set_clr(suppressSets[i]);\r
+    set_orel( (unsigned) tokensInChain[i],\r
+                              &suppressSets[i]);\r
+  };\r
+\r
+  save_fset=fset;\r
+  save_ConstrainSearch=ConstrainSearch;\r
+\r
+  fset=suppressSets;\r
+\r
+  MR_SuppressSearch=1;\r
+  MR_AmbSourceSearch=1;\r
+  MR_MaintainBackTrace=1;\r
+  ConstrainSearch=1;\r
+\r
+  maxk = suppressChainLength;\r
+\r
+  incomplete=empty;\r
+  t=NULL;\r
+\r
+/***  constrain = &(fset[1]); ***/\r
+\r
+  MR_setConstrainPointer(&(fset[1]));  /* MR18 */\r
+  \r
+  MR_pointerStackReset(&MR_BackTraceStack);\r
+\r
+  TRAV(suppressNode,maxk,&incomplete,t);\r
+\r
+  Tfree(t);\r
+\r
+  require (set_nil(incomplete),"MR_suppressK_client TRAV incomplete");\r
+  require (MR_BackTraceStack.count == 0,\r
+            "MR_suppressK_client: MR_BackTraceStack.count != 0");\r
+  set_free(incomplete);\r
+\r
+  ConstrainSearch=save_ConstrainSearch;\r
+  fset=save_fset;\r
+\r
+  MR_AmbSourceSearch=0;\r
+  MR_MaintainBackTrace=0;\r
+  MR_SuppressSearch=0;\r
+  return suppressSucceeded;\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+Tree * MR_iterateOverTreeSuppressK(Tree *t,int chain[])\r
+#else\r
+Tree * MR_iterateOverTreeSuppressK(t,chain)\r
+  Tree          *t;\r
+  int           chain[];\r
+#endif\r
+{\r
+  if (t == NULL) return NULL;\r
+  t->right=MR_iterateOverTreeSuppressK(t->right,&chain[0]);\r
+  chain[0]=t->token;\r
+  if (t->down != NULL) {\r
+    t->down=MR_iterateOverTreeSuppressK(t->down,&chain[1]);\r
+    if (t->down == NULL) {\r
+      Tree *u=t->right;\r
+      t->right=NULL;\r
+      Tfree(t);\r
+      chain[0]=0;\r
+      return u;\r
+    };\r
+  } else {\r
+    MR_suppressK_client(suppressTree,suppressChain);\r
+    if (suppressSucceeded) {\r
+      Tree  *u=t->right;\r
+      t->right=NULL;\r
+      Tfree(t);\r
+      chain[0]=0;\r
+      return u;\r
+    };\r
+  };\r
+  chain[0]=0;\r
+  return t;\r
+}\r
+\r
+/* @@@ */\r
+\r
+#ifdef __USE_PROTOS\r
+Predicate * MR_suppressK(Node *j,Predicate *p)\r
+#else\r
+Predicate * MR_suppressK(j,p)\r
+  Node          *j;\r
+  Predicate     *p;\r
+#endif\r
+{\r
+  Predicate     *result;\r
+  int           guardPred=0;\r
+  int           ampersandPred=0;\r
+  Node          *nodePrime;\r
+\r
+  if (! MRhoistingk) {\r
+     return p;\r
+  }\r
+\r
+  if (! MRhoisting) return p;\r
+  if (CLL_k == 1) return p;\r
+\r
+  if (suppressChain == NULL) {\r
+    suppressChain=(int *) calloc(CLL_k+2,sizeof(int));\r
+    require (suppressChain != NULL,"MR_suppressK: can't allocate chain");\r
+  }\r
+\r
+  if (p == NULL) return NULL;\r
+\r
+  if (j->ntype == nJunction) {\r
+    nodePrime=(Node *) MR_junctionWithoutP2( (Junction *) j);\r
+  } else {\r
+    nodePrime=j;\r
+  };\r
+\r
+  p->down=MR_suppressK(j,p->down);\r
+  p->right=MR_suppressK(j,p->right);\r
+  if (p->down != NULL) {\r
+    result=p;\r
+    goto EXIT;\r
+  };\r
+  if (p->k == 1) {\r
+    result=p;\r
+    goto EXIT;\r
+  };\r
+\r
+  if (p->source != NULL) {\r
+    if (p->source->guardpred != NULL) guardPred=1;\r
+    if (p->source->ampersandPred != NULL) ampersandPred=1;\r
+  }\r
+\r
+  suppressPredicate=p;\r
+  suppressNode=nodePrime;   /* was j*/\r
+\r
+  suppressTree=p->tcontext;\r
+\r
+  if (guardPred || ampersandPred) {\r
+    p->tcontext=MR_iterateOverTreeSuppressK(suppressTree,&suppressChain[1]);\r
+    if (p->tcontext == NULL) {\r
+      predicate_free(p);\r
+      result=NULL;\r
+      goto EXIT;\r
+    };\r
+  } else {\r
+    if (MR_isChain(p->tcontext)) {\r
+      p->tcontext=MR_iterateOverTreeSuppressK(suppressTree,&suppressChain[1]);\r
+      if (p->tcontext == NULL) {\r
+        predicate_free(p);\r
+        result=NULL;\r
+        goto EXIT;\r
+      };\r
+    }\r
+  }\r
+  result=p;\r
+EXIT:\r
+  return result;\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+void MR_suppressSearchReport(void)\r
+#else\r
+void MR_suppressSearchReport()\r
+#endif\r
+{\r
+  int       i;\r
+  Node      *p;\r
+  TokNode   *tn;\r
+  int       depth;\r
+  set       setAnd;\r
+\r
+  /* number of tokens in back trace stack matches length of chain */\r
+\r
+  depth=0;\r
+  for (i=0; i < MR_BackTraceStack.count ; i++) {\r
+    p=(Node *) MR_BackTraceStack.data[i];\r
+    if (p->ntype == nToken) depth++;\r
+  };\r
+\r
+  require (depth == suppressChainLength,"depth > suppressChainLength");\r
+\r
+  /* token codes match chain */\r
+\r
+  depth=0;\r
+  for (i=0; i < MR_BackTraceStack.count ; i++) {\r
+    p=(Node *) MR_BackTraceStack.data[i];\r
+    if (p->ntype != nToken) continue;\r
+    tn=(TokNode *) p;\r
+    depth++;\r
+    if (set_nil(tn->tset)) {\r
+      require(set_el( (unsigned) tn->token,fset[depth]),\r
+        "MR_suppressSearchReport: no match to #token in chain");\r
+    } else {\r
+      setAnd=set_and(fset[depth],tn->tset);\r
+      require(!set_nil(setAnd),\r
+        "MR_suppressSearchReport: no match to #token set in chain");\r
+      set_free(setAnd);\r
+    };\r
+  };\r
+\r
+  /* have a match - now remove it from the predicate */\r
+\r
+  suppressSucceeded=1;\r
+\r
+  if (suppressSucceeded) {\r
+    fprintf(output,"\n");\r
+    fprintf(output,"#if 0\n");\r
+    fprintf(output,"\n");\r
+    fprintf(output,"Part (or all) of predicate with depth > 1 suppressed by ");\r
+        fprintf(output,"alternative without predicate\n\n");\r
+    MR_dumpPred(suppressPredicate,1);\r
+    fprintf(output,"The token sequence which is suppressed:");\r
+    fprintf(output," (");\r
+    for (i=1; i <= suppressChainLength; i++) {\r
+      fprintf(output," %s",TerminalString(suppressChain[i]));\r
+    };\r
+    fprintf(output," )\n");\r
+    fprintf(output,"The sequence of references which generate that sequence of tokens:\n\n");\r
+\r
+    MR_backTraceDumpItemReset();\r
+\r
+    for (i=0; i < MR_BackTraceStack.count ; i++) {\r
+       MR_backTraceDumpItem(output,0,(Node *) MR_BackTraceStack.data[i]);\r
+    };\r
+    fprintf(output,"\n");\r
+    fprintf(output,"#endif\n");\r
+  }\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+void MR_markCompromisedRule(Node *n)\r
+#else\r
+void MR_markCompromisedRule(n)\r
+  Node *n;\r
+#endif\r
+{\r
+  RuleEntry     *q;\r
+  Node          *mark=NULL;\r
+  Junction      *j;\r
+\r
+  if (n->ntype == nRuleRef) {\r
+    mark=(Node *) MR_ruleReferenced( (RuleRefNode *) n);\r
+  } else if (n->ntype == nToken) {\r
+    mark=n;\r
+  } else if (n->ntype == nJunction) {\r
+    j=(Junction *)n;\r
+    switch (j->jtype) {\r
+      case aOptBlk:\r
+      case aLoopBlk:\r
+      case RuleBlk:\r
+      case EndRule:\r
+      case aPlusBlk:\r
+      case aLoopBegin:\r
+        mark=n;\r
+        break;\r
+      default:\r
+        break;\r
+    };\r
+  }\r
+\r
+  if (mark == NULL) return;\r
+\r
+  require (RulePtr != NULL,"RulePtr not initialized");\r
+\r
+  q = (RuleEntry *) hash_get(Rname,mark->rname);\r
+  require (q != NULL,"RuleEntry not found");\r
+  set_orel(q->rulenum,&MR_CompromisedRules);\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+void MR_alphaBetaTraceReport(void)\r
+#else\r
+void MR_alphaBetaTraceReport()\r
+#endif\r
+{\r
+  int       i;\r
+\r
+  if (! AlphaBetaTrace) return;\r
+\r
+  MR_AlphaBetaMessageCount++;\r
+\r
+  fprintf(output,"\n");\r
+  fprintf(output,"#if 0\n");\r
+  fprintf(output,"\n");\r
+  fprintf(output,"Trace of references leading to attempt to compute the follow set of\n");\r
+  fprintf(output,"alpha in an \"(alpha)? beta\" block. It is not possible for antlr to\n");\r
+  fprintf(output,"compute this follow set because it is not known what part of beta has\n");\r
+  fprintf(output,"already been matched by alpha and what part remains to be matched.\n");\r
+  fprintf(output,"\n");\r
+  fprintf(output,"Rules which make use of the incorrect follow set will also be incorrect\n");\r
+  fprintf(output,"\n");\r
+\r
+  MR_backTraceDumpItemReset();\r
+\r
+  for (i=0; i < MR_BackTraceStack.count ; i++) {\r
+     MR_backTraceDumpItem(output,0,(Node *) MR_BackTraceStack.data[i]);\r
+     if (i < MR_BackTraceStack.count-1) {\r
+        MR_markCompromisedRule( (Node *) MR_BackTraceStack.data[i]);\r
+     };\r
+  };\r
+  fprintf(output,"\n");\r
+  fprintf(output,"#endif\n");\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+void MR_dumpRuleSet(set s)\r
+#else\r
+void MR_dumpRuleSet(s)\r
+  set   s;\r
+#endif\r
+{\r
+    unsigned    *cursor;\r
+    unsigned    *origin=set_pdq(s);\r
+\r
+    require(origin != NULL,"set_pdq failed");\r
+\r
+    if (RulePtr == NULL) {\r
+      fprintf(stderr,"RulePtr[] not yet initialized");\r
+    } else {\r
+      for (cursor=origin; *cursor != nil ; cursor++) {\r
+/****   if (cursor != origin) fprintf(stderr,","); ****/\r
+        fprintf(stderr,"    %s",RulePtr[*cursor]->rname);\r
+        fprintf(stderr,"\n");\r
+      };\r
+      free( (char *) origin);\r
+    };\r
+}\r
diff --git a/Tools/CodeTools/Source/Pccts/antlr/parser.dlg b/Tools/CodeTools/Source/Pccts/antlr/parser.dlg
new file mode 100644 (file)
index 0000000..8c43dff
--- /dev/null
@@ -0,0 +1,1387 @@
+<<\r
+/* parser.dlg -- DLG Description of scanner\r
+ *\r
+ * Generated from: antlr.g\r
+ *\r
+ * Terence Parr, Will Cohen, and Hank Dietz: 1989-2001\r
+ * Purdue University Electrical Engineering\r
+ * With AHPCRC, University of Minnesota\r
+ * ANTLR Version 1.33MR33\r
+ */\r
+\r
+#define ANTLR_VERSION  13333\r
+#include "pcctscfg.h"\r
+#include "pccts_stdio.h"\r
+\r
+#include "pcctscfg.h"\r
+#include "set.h"\r
+#include <ctype.h>\r
+#include "syn.h"\r
+#include "hash.h"\r
+#include "generic.h"\r
+#define zzcr_attr(attr,tok,t)\r
+#include "antlr.h"\r
+#include "tokens.h"\r
+#include "dlgdef.h"\r
+LOOKAHEAD\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+zzerraction(void)\r
+#else\r
+zzerraction()\r
+#endif\r
+{\r
+       (*zzerr)("invalid token");\r
+       zzadvance();\r
+       zzskip();\r
+}\r
+>>\r
+\r
+<<%%lexaction\r
+\r
+/* maintained, but not used for now */\r
+set AST_nodes_refd_in_actions = set_init;\r
+int inAlt = 0;\r
+set attribsRefdFromAction = set_init; /* MR20 */\r
+int UsedOldStyleAttrib = 0;\r
+int UsedNewStyleLabel = 0;\r
+#ifdef __USE_PROTOS\r
+char *inline_set(char *);\r
+#else\r
+char *inline_set();\r
+#endif\r
+\r
+/* MR1 10-Apr-97  MR1  Previously unable to put right shift operator       */\r
+/* MR1                                 in DLG action                                       */\r
+\r
+int tokenActionActive=0;                                            /* MR1 */\r
+\r
+  \r
+>>\r
+\r
+<<%%lexaction\r
+\r
+\r
+static char *\r
+#ifdef __USE_PROTOS\r
+getFileNameFromTheLineInfo(char *toStr, char *fromStr)\r
+#else\r
+getFileNameFromTheLineInfo(toStr, fromStr)\r
+char *toStr, *fromStr;\r
+#endif\r
+{\r
+  int i, j, k;\r
+  \r
+  if (!fromStr || !toStr) return toStr;\r
+  \r
+  /* find the first " */\r
+  \r
+  for (i=0;\r
+  (i<MaxFileName) &&\r
+  (fromStr[i] != '\n') &&\r
+  (fromStr[i] != '\r') &&\r
+  (fromStr[i] != '\"');\r
+  i++) /* nothing */ ;\r
+  \r
+  if ( (i == MaxFileName) ||\r
+  (fromStr[i] == '\n') ||\r
+  (fromStr[i] == '\r') ) {\r
+  return toStr;\r
+}\r
+\r
+  /* find the second " */\r
+\r
+  for (j=i+1;\r
+(j<MaxFileName) &&\r
+(fromStr[j] != '\n') &&\r
+(fromStr[j] != '\r') &&\r
+(fromStr[j] != '\"');\r
+j++) /* nothing */ ;\r
+\r
+  if ((j == MaxFileName) ||\r
+(fromStr[j] == '\n') ||\r
+(fromStr[j] == '\r') ) {\r
+  return toStr;\r
+}\r
+\r
+  /* go back until the last / or \ */\r
+\r
+  for (k=j-1;\r
+(fromStr[k] != '\"') &&\r
+(fromStr[k] != '/') &&\r
+(fromStr[k] != '\\');\r
+k--) /* nothing */ ;\r
+\r
+  /* copy the string after " / or \ into toStr */\r
+\r
+  for (i=k+1; fromStr[i] != '\"'; i++) {\r
+toStr[i-k-1] = fromStr[i];\r
+}\r
+\r
+  toStr[i-k-1] = '\0';\r
+\r
+  return toStr;\r
+}\r
+\r
+/* MR14 end of a block to support #line in antlr source code */\r
+\r
+  \r
+>>\r
+\r
+<<%%lexaction\r
+\r
+#ifdef __USE_PROTOS\r
+void mark_label_used_in_sem_pred(LabelEntry *le)              /* MR10 */\r
+#else\r
+void mark_label_used_in_sem_pred(le)                          /* MR10 */\r
+LabelEntry    *le;\r
+#endif\r
+{\r
+  TokNode   *tn;\r
+  require (le->elem->ntype == nToken,"mark_label_used... ntype != nToken");\r
+  tn=(TokNode *)le->elem;\r
+  require (tn->label != 0,"mark_label_used... TokNode has no label");\r
+  tn->label_used_in_semantic_pred=1;\r
+}\r
+>>\r
+\r
+\r
+%%START\r
+\r
+@\r
+       <<\r
+               NLA = Eof;\r
+    /* L o o k  F o r  A n o t h e r  F i l e */\r
+    {\r
+      FILE *new_input;\r
+      new_input = NextFile();\r
+      if ( new_input == NULL ) { NLA=Eof; return; }\r
+      fclose( input );\r
+      input = new_input;\r
+      zzrdstream( input );\r
+      zzskip();        /* Skip the Eof (@) char i.e continue */\r
+    }\r
+       >>\r
+\r
+[\t\ ]+\r
+       <<\r
+               NLA = 76;\r
+    zzskip();   \r
+       >>\r
+\r
+\n|\r|\r\n\r
+       <<\r
+               NLA = 77;\r
+    zzline++; zzskip();   \r
+       >>\r
+\r
+\[\r
+       <<\r
+               NLA = 78;\r
+    zzmode(ACTIONS); zzmore();\r
+    istackreset();\r
+    pushint(']');   \r
+       >>\r
+\r
+\<\<\r
+       <<\r
+               NLA = 79;\r
+    action_file=CurFile; action_line=zzline;\r
+    zzmode(ACTIONS); zzmore();\r
+    list_free(&CurActionLabels,0);       /* MR10 */\r
+    numericActionLabel=0;                /* MR10 */\r
+    istackreset();\r
+    pushint('>');   \r
+       >>\r
+\r
+\"\r
+       <<\r
+               NLA = 80;\r
+    zzmode(STRINGS); zzmore();   \r
+       >>\r
+\r
+/\*\r
+       <<\r
+               NLA = 81;\r
+    zzmode(COMMENTS); zzskip();   \r
+       >>\r
+\r
+\*/\r
+       <<\r
+               NLA = 82;\r
+    warn("Missing /*; found dangling */"); zzskip();   \r
+       >>\r
+\r
+//\r
+       <<\r
+               NLA = 83;\r
+    zzmode(CPP_COMMENTS); zzskip();   \r
+       >>\r
+\r
+#line[\ \t]* [0-9]+ {[\ \t]* \"~[\"]+\" ([\ \t]* [0-9]*)* } (\n|\r|\r\n)\r
+       <<\r
+               NLA = 84;\r
+    \r
+    zzline = atoi(zzbegexpr+5) - 1; zzline++; zzmore();\r
+    getFileNameFromTheLineInfo(FileStr[CurFile], zzbegexpr);\r
+       >>\r
+\r
+#line ~[\n\r]* (\n|\r|\r\n)\r
+       <<\r
+               NLA = 85;\r
+    \r
+    zzline++; zzmore();\r
+       >>\r
+\r
+\>\>\r
+       <<\r
+               NLA = 86;\r
+    warn("Missing <<; found dangling \>\>"); zzskip();   \r
+       >>\r
+\r
+.\r
+       <<\r
+               NLA = WildCard;\r
+       >>\r
+\r
+\@\r
+       <<\r
+               NLA = 88;\r
+    FoundException = 1;                /* MR6 */\r
+    FoundAtOperator = 1;  \r
+       >>\r
+\r
+{\\}#pragma\r
+       <<\r
+               NLA = Pragma;\r
+       >>\r
+\r
+{\\}#FirstSetSymbol\r
+       <<\r
+               NLA = FirstSetSymbol;\r
+       >>\r
+\r
+{\\}#header\r
+       <<\r
+               NLA = 94;\r
+       >>\r
+\r
+{\\}#first\r
+       <<\r
+               NLA = 95;\r
+       >>\r
+\r
+{\\}#parser\r
+       <<\r
+               NLA = 96;\r
+       >>\r
+\r
+{\\}#tokdefs\r
+       <<\r
+               NLA = 97;\r
+       >>\r
+\r
+\}\r
+       <<\r
+               NLA = 98;\r
+       >>\r
+\r
+class\r
+       <<\r
+               NLA = 99;\r
+       >>\r
+\r
+\{\r
+       <<\r
+               NLA = 102;\r
+       >>\r
+\r
+!\r
+       <<\r
+               NLA = 103;\r
+       >>\r
+\r
+\<\r
+       <<\r
+               NLA = 104;\r
+       >>\r
+\r
+\>\r
+       <<\r
+               NLA = 105;\r
+       >>\r
+\r
+:\r
+       <<\r
+               NLA = 106;\r
+       >>\r
+\r
+;\r
+       <<\r
+               NLA = 107;\r
+       >>\r
+\r
+{\\}#lexaction\r
+       <<\r
+               NLA = 108;\r
+       >>\r
+\r
+{\\}#lexmember\r
+       <<\r
+               NLA = 109;\r
+       >>\r
+\r
+{\\}#lexprefix\r
+       <<\r
+               NLA = 110;\r
+       >>\r
+\r
+{\\}#pred\r
+       <<\r
+               NLA = 111;\r
+       >>\r
+\r
+\|\|\r
+       <<\r
+               NLA = 112;\r
+       >>\r
+\r
+&&\r
+       <<\r
+               NLA = 113;\r
+       >>\r
+\r
+\(\r
+       <<\r
+               NLA = 114;\r
+       >>\r
+\r
+\)\r
+       <<\r
+               NLA = 115;\r
+       >>\r
+\r
+{\\}#lexclass\r
+       <<\r
+               NLA = 116;\r
+       >>\r
+\r
+{\\}#errclass\r
+       <<\r
+               NLA = 117;\r
+       >>\r
+\r
+{\\}#tokclass\r
+       <<\r
+               NLA = 118;\r
+       >>\r
+\r
+..\r
+       <<\r
+               NLA = 119;\r
+       >>\r
+\r
+{\\}#token\r
+       <<\r
+               NLA = 120;\r
+       >>\r
+\r
+=\r
+       <<\r
+               NLA = 121;\r
+       >>\r
+\r
+[0-9]+\r
+       <<\r
+               NLA = 122;\r
+       >>\r
+\r
+\|\r
+       <<\r
+               NLA = 123;\r
+       >>\r
+\r
+\~\r
+       <<\r
+               NLA = 124;\r
+       >>\r
+\r
+^\r
+       <<\r
+               NLA = 125;\r
+       >>\r
+\r
+approx\r
+       <<\r
+               NLA = 126;\r
+       >>\r
+\r
+LL\(1\)\r
+       <<\r
+               NLA = 127;\r
+       >>\r
+\r
+LL\(2\)\r
+       <<\r
+               NLA = 128;\r
+       >>\r
+\r
+\*\r
+       <<\r
+               NLA = 129;\r
+       >>\r
+\r
+\+\r
+       <<\r
+               NLA = 130;\r
+       >>\r
+\r
+?\r
+       <<\r
+               NLA = 131;\r
+       >>\r
+\r
+=>\r
+       <<\r
+               NLA = 132;\r
+       >>\r
+\r
+exception\r
+       <<\r
+               NLA = 133;\r
+       >>\r
+\r
+default\r
+       <<\r
+               NLA = 134;\r
+       >>\r
+\r
+catch\r
+       <<\r
+               NLA = 135;\r
+       >>\r
+\r
+[a-z] [A-Za-z0-9_]*\r
+       <<\r
+               NLA = NonTerminal;\r
+    \r
+    while ( zzchar==' ' || zzchar=='\t' ) {\r
+      zzadvance();\r
+    }\r
+    if ( zzchar == ':' && inAlt ) NLA = LABEL;\r
+       >>\r
+\r
+[A-Z] [A-Za-z0-9_]*\r
+       <<\r
+               NLA = TokenTerm;\r
+    \r
+    while ( zzchar==' ' || zzchar=='\t' ) {\r
+      zzadvance();\r
+    }\r
+    if ( zzchar == ':' && inAlt ) NLA = LABEL;\r
+       >>\r
+\r
+{\\}#[A-Za-z0-9_]*\r
+       <<\r
+               NLA = 136;\r
+    warn(eMsg1("unknown meta-op: %s",LATEXT(1))); zzskip();   \r
+       >>\r
+\r
+\r
+%%STRINGS\r
+\r
+@\r
+       <<\r
+               NLA = Eof;\r
+       >>\r
+\r
+\"\r
+       <<\r
+               NLA = QuotedTerm;\r
+    zzmode(START);   \r
+       >>\r
+\r
+\n|\r|\r\n\r
+       <<\r
+               NLA = 3;\r
+    \r
+    zzline++;\r
+    warn("eoln found in string");\r
+    zzskip();\r
+       >>\r
+\r
+\\(\n|\r|\r\n)\r
+       <<\r
+               NLA = 4;\r
+    zzline++; zzmore();   \r
+       >>\r
+\r
+\\~[]\r
+       <<\r
+               NLA = 5;\r
+    zzmore();   \r
+       >>\r
+\r
+~[\n\r\"\\]+\r
+       <<\r
+               NLA = 6;\r
+    zzmore();   \r
+       >>\r
+\r
+\r
+%%ACTION_STRINGS\r
+\r
+@\r
+       <<\r
+               NLA = Eof;\r
+       >>\r
+\r
+\"\r
+       <<\r
+               NLA = 7;\r
+    zzmode(ACTIONS); zzmore();   \r
+       >>\r
+\r
+\n|\r|\r\n\r
+       <<\r
+               NLA = 8;\r
+    \r
+    zzline++;\r
+    warn("eoln found in string (in user action)");\r
+    zzskip();\r
+       >>\r
+\r
+\\(\n|\r|\r\n)\r
+       <<\r
+               NLA = 9;\r
+    zzline++; zzmore();   \r
+       >>\r
+\r
+\\~[]\r
+       <<\r
+               NLA = 10;\r
+    zzmore();   \r
+       >>\r
+\r
+~[\n\r\"\\]+\r
+       <<\r
+               NLA = 11;\r
+    zzmore();   \r
+       >>\r
+\r
+\r
+%%ACTION_CHARS\r
+\r
+@\r
+       <<\r
+               NLA = Eof;\r
+       >>\r
+\r
+'\r
+       <<\r
+               NLA = 12;\r
+    zzmode(ACTIONS); zzmore();   \r
+       >>\r
+\r
+\n|\r|\r\n\r
+       <<\r
+               NLA = 13;\r
+    \r
+    zzline++;\r
+    warn("eoln found in char literal (in user action)");\r
+    zzskip();\r
+       >>\r
+\r
+\\~[]\r
+       <<\r
+               NLA = 14;\r
+    zzmore();   \r
+       >>\r
+\r
+~[\n\r'\\]+\r
+       <<\r
+               NLA = 15;\r
+    zzmore();   \r
+       >>\r
+\r
+\r
+%%ACTION_COMMENTS\r
+\r
+@\r
+       <<\r
+               NLA = Eof;\r
+       >>\r
+\r
+\*/\r
+       <<\r
+               NLA = 16;\r
+    zzmode(ACTIONS); zzmore();   \r
+       >>\r
+\r
+\*\r
+       <<\r
+               NLA = 17;\r
+    zzmore();   \r
+       >>\r
+\r
+\n|\r|\r\n\r
+       <<\r
+               NLA = 18;\r
+    zzline++; zzmore(); DAWDLE;   \r
+       >>\r
+\r
+~[\n\r\*]+\r
+       <<\r
+               NLA = 19;\r
+    zzmore();   \r
+       >>\r
+\r
+\r
+%%TOK_DEF_COMMENTS\r
+\r
+@\r
+       <<\r
+               NLA = Eof;\r
+       >>\r
+\r
+\*/\r
+       <<\r
+               NLA = 20;\r
+    zzmode(PARSE_ENUM_FILE);\r
+    zzmore();   \r
+       >>\r
+\r
+\*\r
+       <<\r
+               NLA = 21;\r
+    zzmore();   \r
+       >>\r
+\r
+\n|\r|\r\n\r
+       <<\r
+               NLA = 22;\r
+    zzline++; zzmore(); DAWDLE;   \r
+       >>\r
+\r
+~[\n\r\*]+\r
+       <<\r
+               NLA = 23;\r
+    zzmore();   \r
+       >>\r
+\r
+\r
+%%TOK_DEF_CPP_COMMENTS\r
+\r
+@\r
+       <<\r
+               NLA = Eof;\r
+       >>\r
+\r
+\n|\r|\r\n\r
+       <<\r
+               NLA = 24;\r
+    zzline++; zzmode(PARSE_ENUM_FILE); zzskip(); DAWDLE;   \r
+       >>\r
+\r
+~[\n\r]+\r
+       <<\r
+               NLA = 25;\r
+    zzskip();   \r
+       >>\r
+\r
+\r
+%%ACTION_CPP_COMMENTS\r
+\r
+@\r
+       <<\r
+               NLA = Eof;\r
+       >>\r
+\r
+\n|\r|\r\n\r
+       <<\r
+               NLA = 26;\r
+    zzline++; zzmode(ACTIONS); zzmore(); DAWDLE;   \r
+       >>\r
+\r
+~[\n\r]+\r
+       <<\r
+               NLA = 27;\r
+    zzmore();   \r
+       >>\r
+\r
+\r
+%%CPP_COMMENTS\r
+\r
+@\r
+       <<\r
+               NLA = Eof;\r
+       >>\r
+\r
+\n|\r|\r\n\r
+       <<\r
+               NLA = 28;\r
+    zzline++; zzmode(START); zzskip(); DAWDLE;   \r
+       >>\r
+\r
+~[\n\r]+\r
+       <<\r
+               NLA = 29;\r
+    zzskip();   \r
+       >>\r
+\r
+\r
+%%COMMENTS\r
+\r
+@\r
+       <<\r
+               NLA = Eof;\r
+       >>\r
+\r
+\*/\r
+       <<\r
+               NLA = 30;\r
+    zzmode(START); zzskip();   \r
+       >>\r
+\r
+\*\r
+       <<\r
+               NLA = 31;\r
+    zzskip();   \r
+       >>\r
+\r
+\n|\r|\r\n\r
+       <<\r
+               NLA = 32;\r
+    zzline++; zzskip(); DAWDLE;   \r
+       >>\r
+\r
+~[\n\r\*]+\r
+       <<\r
+               NLA = 33;\r
+    zzskip();   \r
+       >>\r
+\r
+\r
+%%ACTIONS\r
+\r
+@\r
+       <<\r
+               NLA = Eof;\r
+       >>\r
+\r
+\>\>\r
+       <<\r
+               NLA = Action;\r
+    /* these do not nest */\r
+    zzmode(START);\r
+    NLATEXT[0] = ' ';\r
+    NLATEXT[1] = ' ';\r
+    zzbegexpr[0] = ' ';\r
+    zzbegexpr[1] = ' ';\r
+    if ( zzbufovf ) {\r
+      err( eMsgd("action buffer overflow; size %d",ZZLEXBUFSIZE));\r
+    }\r
+    \r
+/* MR1 10-Apr-97  MR1  Previously unable to put right shift operator   */\r
+    /* MR1                                     in DLG action                   */\r
+    /* MR1                     Doesn't matter what kind of action it is - reset*/\r
+    \r
+                             tokenActionActive=0;               /* MR1 */\r
+       >>\r
+\r
+\>\>?\r
+       <<\r
+               NLA = Pred;\r
+    /* these do not nest */\r
+    zzmode(START);\r
+    NLATEXT[0] = ' ';\r
+    NLATEXT[1] = ' ';\r
+    zzbegexpr[0] = '\0';\r
+    if ( zzbufovf ) {\r
+      err( eMsgd("predicate buffer overflow; size %d",ZZLEXBUFSIZE));\r
+    };\r
+#ifdef __cplusplus__\r
+    /* MR10 */                    list_apply(CurActionLabels, (void (*)(void *))mark_label_used_in_sem_pred);\r
+#else\r
+#ifdef __STDC__\r
+    /* MR10 */                    list_apply(CurActionLabels, (void (*)(void *))mark_label_used_in_sem_pred);\r
+#else\r
+#ifdef __USE_PROTOS\r
+    /* MRxx */                    list_apply(CurActionLabels, (void (*)(void *))mark_label_used_in_sem_pred);\r
+#else\r
+    /* MR10 */                    list_apply(CurActionLabels,mark_label_used_in_sem_pred);\r
+#endif\r
+#endif\r
+#endif\r
+       >>\r
+\r
+\]\r
+       <<\r
+               NLA = PassAction;\r
+    if ( topint() == ']' ) {\r
+      popint();\r
+      if ( istackempty() )     /* terminate action */\r
+      {\r
+        zzmode(START);\r
+        NLATEXT[0] = ' ';\r
+        zzbegexpr[0] = ' ';\r
+        if ( zzbufovf ) {\r
+          err( eMsgd("parameter buffer overflow; size %d",ZZLEXBUFSIZE));\r
+        }\r
+      }\r
+      else {\r
+        /* terminate $[..] and #[..] */\r
+        if ( GenCC ) zzreplstr("))");\r
+        else zzreplstr(")");\r
+        zzmore();\r
+      }\r
+    }\r
+    else if ( topint() == '|' ) { /* end of simple [...] */\r
+      popint();\r
+      zzmore();\r
+    }\r
+    else zzmore();\r
+       >>\r
+\r
+consumeUntil\( [\ \t]* \{~[\}]+\} [\ \t]* \)\r
+       <<\r
+               NLA = 37;\r
+    \r
+    zzmore();\r
+    zzreplstr(inline_set(zzbegexpr+\r
+    strlen("consumeUntil(")));\r
+       >>\r
+\r
+consumeUntil\( ~[\)]+ \)\r
+       <<\r
+               NLA = 38;\r
+    zzmore();   \r
+       >>\r
+\r
+\n|\r|\r\n\r
+       <<\r
+               NLA = 39;\r
+    zzline++; zzmore(); DAWDLE;   \r
+       >>\r
+\r
+\>\r
+       <<\r
+               NLA = 40;\r
+    zzmore();   \r
+       >>\r
+\r
+$\r
+       <<\r
+               NLA = 41;\r
+    zzmore();   \r
+       >>\r
+\r
+$$\r
+       <<\r
+               NLA = 42;\r
+    if ( !GenCC ) {zzreplstr("zzaRet"); zzmore();}\r
+    else err("$$ use invalid in C++ mode");   \r
+       >>\r
+\r
+$\[\]\r
+       <<\r
+               NLA = 43;\r
+    if ( !GenCC ) {zzreplstr("zzempty_attr"); zzmore();}\r
+    else err("$[] use invalid in C++ mode");   \r
+       >>\r
+\r
+$\[\r
+       <<\r
+               NLA = 44;\r
+    \r
+    pushint(']');\r
+    if ( !GenCC ) zzreplstr("zzconstr_attr(");\r
+    else err("$[..] use invalid in C++ mode");\r
+    zzmore();\r
+       >>\r
+\r
+$[0-9]+\r
+       <<\r
+               NLA = 45;\r
+    {\r
+      static char buf[100];\r
+      numericActionLabel=1;       /* MR10 */\r
+      if ( strlen(zzbegexpr)>(size_t)85 )\r
+      fatal("$i attrib ref too big");\r
+      set_orel(atoi(zzbegexpr+1), &attribsRefdFromAction);\r
+      if ( !GenCC ) sprintf(buf,"zzaArg(zztasp%d,%s)",\r
+      BlkLevel-1,zzbegexpr+1);\r
+      else sprintf(buf,"_t%d%s",\r
+      BlkLevel-1,zzbegexpr+1);\r
+      zzreplstr(buf);\r
+      zzmore();\r
+      UsedOldStyleAttrib = 1;\r
+      if ( UsedNewStyleLabel )\r
+      err("cannot mix old-style $i with new-style labels");\r
+    }\r
+       >>\r
+\r
+$[0-9]+.\r
+       <<\r
+               NLA = 46;\r
+    {\r
+      static char buf[100];\r
+      numericActionLabel=1;       /* MR10 */\r
+      if ( strlen(zzbegexpr)>(size_t)85 )\r
+      fatal("$i.field attrib ref too big");\r
+      zzbegexpr[strlen(zzbegexpr)-1] = ' ';\r
+      set_orel(atoi(zzbegexpr+1), &attribsRefdFromAction);\r
+      if ( !GenCC ) sprintf(buf,"zzaArg(zztasp%d,%s).",\r
+      BlkLevel-1,zzbegexpr+1);\r
+      else sprintf(buf,"_t%d%s.",\r
+      BlkLevel-1,zzbegexpr+1);\r
+      zzreplstr(buf);\r
+      zzmore();\r
+      UsedOldStyleAttrib = 1;\r
+      if ( UsedNewStyleLabel )\r
+      err("cannot mix old-style $i with new-style labels");\r
+    }\r
+       >>\r
+\r
+$[0-9]+.[0-9]+\r
+       <<\r
+               NLA = 47;\r
+    {\r
+      static char buf[100];\r
+      static char i[20], j[20];\r
+      char *p,*q;\r
+      numericActionLabel=1;       /* MR10 */\r
+      if (strlen(zzbegexpr)>(size_t)85) fatal("$i.j attrib ref too big");\r
+      for (p=zzbegexpr+1,q= &i[0]; *p!='.'; p++) {\r
+        if ( q == &i[20] )\r
+        fatalFL("i of $i.j attrib ref too big",\r
+        FileStr[CurFile], zzline );\r
+        *q++ = *p;\r
+      }\r
+      *q = '\0';\r
+      for (p++, q= &j[0]; *p!='\0'; p++) {\r
+        if ( q == &j[20] )\r
+        fatalFL("j of $i.j attrib ref too big",\r
+        FileStr[CurFile], zzline );\r
+        *q++ = *p;\r
+      }\r
+      *q = '\0';\r
+      if ( !GenCC ) sprintf(buf,"zzaArg(zztasp%s,%s)",i,j);\r
+      else sprintf(buf,"_t%s%s",i,j);\r
+      zzreplstr(buf);\r
+      zzmore();\r
+      UsedOldStyleAttrib = 1;\r
+      if ( UsedNewStyleLabel )\r
+      err("cannot mix old-style $i with new-style labels");\r
+    }\r
+       >>\r
+\r
+$[_a-zA-Z][_a-zA-Z0-9]*\r
+       <<\r
+               NLA = 48;\r
+    { static char buf[300]; LabelEntry *el;\r
+      zzbegexpr[0] = ' ';\r
+      if ( CurRule != NULL &&\r
+      strcmp(CurRule, &zzbegexpr[1])==0 ) {\r
+        if ( !GenCC ) zzreplstr("zzaRet");\r
+      }\r
+      else if ( CurRetDef != NULL &&\r
+      strmember(CurRetDef, &zzbegexpr[1])) {\r
+        if ( hasMultipleOperands( CurRetDef ) ) {\r
+          require (strlen(zzbegexpr)<=(size_t)285,\r
+          "$retval attrib ref too big");\r
+          sprintf(buf,"_retv.%s",&zzbegexpr[1]);\r
+          zzreplstr(buf);\r
+        }\r
+        else zzreplstr("_retv");\r
+      }\r
+      else if ( CurParmDef != NULL &&\r
+      strmember(CurParmDef, &zzbegexpr[1])) {\r
+      ;\r
+    }\r
+    else if ( Elabel==NULL ) {\r
+    { err("$-variables in actions outside of rules are not allowed"); }\r
+  } else if ( (el=(LabelEntry *)hash_get(Elabel, &zzbegexpr[1]))!=NULL ) {\r
+  /* MR10 */\r
+  /* MR10 */                      /* element labels might exist without an elem when */\r
+  /* MR10 */                      /*  it is a forward reference (to a rule)          */\r
+  /* MR10 */\r
+  /* MR10 */                                           if ( GenCC && (el->elem == NULL || el->elem->ntype==nRuleRef) )\r
+  /* MR10 */                                                   { err(eMsg1("There are no token ptrs for rule references: '$%s'",&zzbegexpr[1])); }\r
+  /* MR10 */\r
+  /* MR10 */                                           if ( !GenCC && (el->elem == NULL || el->elem->ntype==nRuleRef) && GenAST) {\r
+  /* MR10 */                          err("You can no longer use attributes returned by rules when also using ASTs");\r
+  /* MR10 */                          err("   Use upward inheritance (\"rule >[Attrib a] : ... <<$a=...\>\>\")");\r
+  /* MR10 */                      };\r
+  /* MR10 */\r
+  /* MR10 */                      /* keep track of <<... $label ...>> for semantic predicates in guess mode */\r
+  /* MR10 */                      /* element labels contain pointer to the owners node                      */\r
+  /* MR10 */\r
+  /* MR10 */                      if (el->elem != NULL && el->elem->ntype == nToken) {\r
+  /* MR10 */                        list_add(&CurActionLabels,el);\r
+  /* MR10 */                      };\r
+}\r
+else\r
+warn(eMsg1("$%s not parameter, return value, (defined) element label",&zzbegexpr[1]));\r
+}\r
+zzmore();\r
+       >>\r
+\r
+#0\r
+       <<\r
+               NLA = 49;\r
+    zzreplstr("(*_root)"); zzmore(); chkGTFlag();   \r
+       >>\r
+\r
+#\[\]\r
+       <<\r
+               NLA = 50;\r
+    if ( GenCC ) {\r
+      if (NewAST) zzreplstr("(newAST)");\r
+      else zzreplstr("(new AST)");}\r
+    else {zzreplstr("zzastnew()");} zzmore();\r
+    chkGTFlag();\r
+       >>\r
+\r
+#\(\)\r
+       <<\r
+               NLA = 51;\r
+    zzreplstr("NULL"); zzmore(); chkGTFlag();   \r
+       >>\r
+\r
+#[0-9]+\r
+       <<\r
+               NLA = 52;\r
+    {\r
+      static char buf[100];\r
+      if ( strlen(zzbegexpr)>(size_t)85 )\r
+      fatal("#i AST ref too big");\r
+      if ( GenCC ) sprintf(buf,"_ast%d%s",BlkLevel-1,zzbegexpr+1);\r
+      else sprintf(buf,"zzastArg(%s)",zzbegexpr+1);\r
+      zzreplstr(buf);\r
+      zzmore();\r
+      set_orel(atoi(zzbegexpr+1), &AST_nodes_refd_in_actions);\r
+      chkGTFlag();\r
+    }\r
+       >>\r
+\r
+#line[\ \t]* [0-9]+ {[\ \t]* \"~[\"]+\" ([\ \t]* [0-9]*)* } (\n|\r|\r\n)\r
+       <<\r
+               NLA = 53;\r
+    \r
+    zzline = atoi(zzbegexpr+5) - 1; zzline++; zzmore();\r
+    getFileNameFromTheLineInfo(FileStr[CurFile], zzbegexpr);\r
+       >>\r
+\r
+#line ~[\n\r]* (\n|\r|\r\n)\r
+       <<\r
+               NLA = 54;\r
+    \r
+    zzline++; zzmore();\r
+       >>\r
+\r
+#[_a-zA-Z][_a-zA-Z0-9]*\r
+       <<\r
+               NLA = 55;\r
+    \r
+    if ( !(strcmp(zzbegexpr, "#ifdef")==0 ||\r
+    strcmp(zzbegexpr, "#if")==0 ||\r
+    strcmp(zzbegexpr, "#else")==0 ||\r
+    strcmp(zzbegexpr, "#endif")==0 ||\r
+    strcmp(zzbegexpr, "#ifndef")==0 ||\r
+    strcmp(zzbegexpr, "#define")==0 ||\r
+    strcmp(zzbegexpr, "#pragma")==0 ||\r
+    strcmp(zzbegexpr, "#undef")==0 ||\r
+    strcmp(zzbegexpr, "#import")==0 ||\r
+    strcmp(zzbegexpr, "#line")==0 ||\r
+    strcmp(zzbegexpr, "#include")==0 ||\r
+    strcmp(zzbegexpr, "#error")==0) )\r
+    {\r
+      static char buf[100];\r
+      sprintf(buf, "%s_ast", zzbegexpr+1);\r
+      /* MR27 */                                               list_add(&CurAstLabelsInActions, mystrdup(zzbegexpr+1));\r
+      zzreplstr(buf);\r
+      chkGTFlag();\r
+    }\r
+    zzmore();\r
+       >>\r
+\r
+#\[\r
+       <<\r
+               NLA = 56;\r
+    \r
+    pushint(']');\r
+    if ( GenCC ) {\r
+      if (NewAST) zzreplstr("(newAST(");\r
+      else zzreplstr("(new AST("); }\r
+    else zzreplstr("zzmk_ast(zzastnew(),");\r
+    zzmore();\r
+    chkGTFlag();\r
+       >>\r
+\r
+#\(\r
+       <<\r
+               NLA = 57;\r
+    \r
+    pushint('}');\r
+    if ( GenCC ) {\r
+      if (tmakeInParser) {\r
+        zzreplstr("tmake(");\r
+      }\r
+      else {\r
+        zzreplstr("ASTBase::tmake(");\r
+      }\r
+    }\r
+    else {\r
+      zzreplstr("zztmake(");\r
+    }\r
+    zzmore();\r
+    chkGTFlag();\r
+       >>\r
+\r
+#\r
+       <<\r
+               NLA = 58;\r
+    zzmore();   \r
+       >>\r
+\r
+\)\r
+       <<\r
+               NLA = 59;\r
+    \r
+    if ( istackempty() )\r
+    zzmore();\r
+    else if ( topint()==')' ) {\r
+      popint();\r
+    }\r
+    else if ( topint()=='}' ) {\r
+      popint();\r
+      /* terminate #(..) */\r
+      zzreplstr(", NULL)");\r
+    }\r
+    zzmore();\r
+       >>\r
+\r
+\[\r
+       <<\r
+               NLA = 60;\r
+    \r
+    pushint('|');      /* look for '|' to terminate simple [...] */\r
+    zzmore();\r
+       >>\r
+\r
+\(\r
+       <<\r
+               NLA = 61;\r
+    \r
+    pushint(')');\r
+    zzmore();\r
+       >>\r
+\r
+\\\]\r
+       <<\r
+               NLA = 62;\r
+    zzreplstr("]");  zzmore();   \r
+       >>\r
+\r
+\\\)\r
+       <<\r
+               NLA = 63;\r
+    zzreplstr(")");  zzmore();   \r
+       >>\r
+\r
+\\>\r
+       <<\r
+               NLA = 64;\r
+    if (! tokenActionActive) zzreplstr(">");    /* MR1 */\r
+    zzmore();                                   /* MR1 */\r
+       >>\r
+\r
+'\r
+       <<\r
+               NLA = 65;\r
+    zzmode(ACTION_CHARS); zzmore();  \r
+       >>\r
+\r
+\"\r
+       <<\r
+               NLA = 66;\r
+    zzmode(ACTION_STRINGS); zzmore();  \r
+       >>\r
+\r
+\\$\r
+       <<\r
+               NLA = 67;\r
+    zzreplstr("$");  zzmore();   \r
+       >>\r
+\r
+\\#\r
+       <<\r
+               NLA = 68;\r
+    zzreplstr("#");  zzmore();   \r
+       >>\r
+\r
+\\(\n|\r|\r\n)\r
+       <<\r
+               NLA = 69;\r
+    zzline++; zzmore();   \r
+       >>\r
+\r
+\\~[\]\)>$#]\r
+       <<\r
+               NLA = 70;\r
+    zzmore();   \r
+       >>\r
+\r
+/\r
+       <<\r
+               NLA = 71;\r
+    zzmore();   \r
+       >>\r
+\r
+/\*\r
+       <<\r
+               NLA = 72;\r
+    zzmode(ACTION_COMMENTS); zzmore();   \r
+       >>\r
+\r
+\*/\r
+       <<\r
+               NLA = 73;\r
+    warn("Missing /*; found dangling */ in action"); zzmore();   \r
+       >>\r
+\r
+//\r
+       <<\r
+               NLA = 74;\r
+    zzmode(ACTION_CPP_COMMENTS); zzmore();   \r
+       >>\r
+\r
+~[\n\r\)\(\\$#\>\]\[\"'/]+\r
+       <<\r
+               NLA = 75;\r
+    zzmore();   \r
+       >>\r
+\r
+\r
+%%PARSE_ENUM_FILE\r
+\r
+@\r
+       <<\r
+               NLA = Eof;\r
+    ;   \r
+       >>\r
+\r
+[\t\ ]+\r
+       <<\r
+               NLA = 137;\r
+    zzskip();   \r
+       >>\r
+\r
+\n|\r|\r\n\r
+       <<\r
+               NLA = 138;\r
+    zzline++; zzskip();   \r
+       >>\r
+\r
+//\r
+       <<\r
+               NLA = 139;\r
+    zzmode(TOK_DEF_CPP_COMMENTS); zzmore();   \r
+       >>\r
+\r
+/\*\r
+       <<\r
+               NLA = 140;\r
+    zzmode(TOK_DEF_COMMENTS); zzskip();   \r
+       >>\r
+\r
+#ifdef\r
+       <<\r
+               NLA = 141;\r
+    zzmode(TOK_DEF_CPP_COMMENTS); zzskip();   \r
+       >>\r
+\r
+#if\r
+       <<\r
+               NLA = 142;\r
+    zzmode(TOK_DEF_CPP_COMMENTS); zzskip();   \r
+       >>\r
+\r
+#ifndef\r
+       <<\r
+               NLA = 143;\r
+    ;   \r
+       >>\r
+\r
+#else\r
+       <<\r
+               NLA = 144;\r
+    zzmode(TOK_DEF_CPP_COMMENTS); zzskip();   \r
+       >>\r
+\r
+#endif\r
+       <<\r
+               NLA = 145;\r
+    zzmode(TOK_DEF_CPP_COMMENTS); zzskip();   \r
+       >>\r
+\r
+#undef\r
+       <<\r
+               NLA = 146;\r
+    zzmode(TOK_DEF_CPP_COMMENTS); zzskip();   \r
+       >>\r
+\r
+#import\r
+       <<\r
+               NLA = 147;\r
+    zzmode(TOK_DEF_CPP_COMMENTS); zzskip();   \r
+       >>\r
+\r
+#define\r
+       <<\r
+               NLA = 149;\r
+       >>\r
+\r
+enum\r
+       <<\r
+               NLA = 151;\r
+       >>\r
+\r
+\{\r
+       <<\r
+               NLA = 152;\r
+       >>\r
+\r
+=\r
+       <<\r
+               NLA = 153;\r
+       >>\r
+\r
+,\r
+       <<\r
+               NLA = 154;\r
+       >>\r
+\r
+\}\r
+       <<\r
+               NLA = 155;\r
+       >>\r
+\r
+;\r
+       <<\r
+               NLA = 156;\r
+       >>\r
+\r
+[0-9]+\r
+       <<\r
+               NLA = INT;\r
+       >>\r
+\r
+[a-zA-Z_][_a-zA-Z0-9]*\r
+       <<\r
+               NLA = ID;\r
+       >>\r
+\r
+%%\r
diff --git a/Tools/CodeTools/Source/Pccts/antlr/pred.c b/Tools/CodeTools/Source/Pccts/antlr/pred.c
new file mode 100644 (file)
index 0000000..eb11c4d
--- /dev/null
@@ -0,0 +1,821 @@
+/*\r
+ * pred.c -- source for predicate detection, manipulation\r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
+ * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
+ * company may do whatever they wish with source code distributed with\r
+ * PCCTS or the code generated by PCCTS, including the incorporation of\r
+ * PCCTS, or its output, into commerical software.\r
+ *\r
+ * We encourage users to develop software with PCCTS.  However, we do ask\r
+ * that credit is given to us for developing PCCTS.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like PCCTS and have developed a nice tool with the\r
+ * output, please mention that you developed it using PCCTS.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * ANTLR 1.33\r
+ * Terence Parr\r
+ * Parr Research Corporation\r
+ * with Purdue University and AHPCRC, University of Minnesota\r
+ * 1989-2001\r
+ */\r
+\r
+#include <stdio.h>\r
+#include "pcctscfg.h"\r
+#include "set.h"\r
+#include "syn.h"\r
+#include "hash.h"\r
+#include "generic.h"\r
+#include "dlgdef.h"\r
+#include <ctype.h>\r
+\r
+#ifdef __USE_PROTOS\r
+static void complete_context_sets(RuleRefNode *, Predicate *);\r
+static void complete_context_trees(RuleRefNode *, Predicate *);\r
+#else\r
+static void complete_context_sets();\r
+static void complete_context_trees();\r
+#endif\r
+\r
+char *PRED_AND_LIST = "AND";\r
+char *PRED_OR_LIST = "OR";\r
+\r
+/*\r
+ * In C mode, return the largest constant integer found as the\r
+ * sole argument to LATEXT(i).\r
+ *\r
+ * In C++ mode, return the largest constant integer found as the\r
+ * sole argument to LT(i) given that the char before is nonalpha.\r
+ */\r
+\r
+int\r
+#ifdef __USE_PROTOS\r
+predicateLookaheadDepth(ActionNode *a)\r
+#else\r
+predicateLookaheadDepth(a)\r
+ActionNode *a;\r
+#endif\r
+{\r
+       int     max_k=0;\r
+\r
+    if (a->predEntry != NULL) {\r
+       MR_pred_depth(a->predEntry->pred,&max_k);\r
+       goto PREDENTRY_EXIT;\r
+    }\r
+\r
+       if ( GenCC )\r
+       {\r
+               /* scan for LT(i) */\r
+               int k = 0;\r
+               char *p = a->action;\r
+               while ( p!=NULL )\r
+               {\r
+                       p = strstr(p, "LT(");\r
+                       if ( p!=NULL )\r
+                       {\r
+                               if ( p>=a->action && !isalpha(*(p-1)) )\r
+                               {\r
+                                       k = atoi(p+strlen("LT("));\r
+                                       if ( k>max_k ) max_k=k;\r
+                               }\r
+                               p += strlen("LT(");\r
+                       }\r
+               }\r
+       }\r
+       else {\r
+               /* scan for LATEXT(i) */\r
+               int k = 0;\r
+               char *p = a->action;\r
+               while ( p!=NULL )\r
+               {\r
+                       p = strstr(p, "LATEXT(");\r
+                       if ( p!=NULL )\r
+                       {\r
+                               p += strlen("LATEXT(");\r
+                               k = atoi(p);\r
+                               if ( k>max_k ) max_k=k;\r
+                       }\r
+               }\r
+       }\r
+\r
+       if (max_k==0) {\r
+               max_k = 1;         /* MR33 Badly designed if didn't set max_k when CLL_k = 1 */\r
+               if (CLL_k > 1) /* MR27 Don't warn if max(k,ck) == 1 */\r
+               {\r
+                       if ( !a->frmwarned )\r
+                       {\r
+                               a->frmwarned = 1;\r
+                               warnFL(eMsg1("predicate: %s missing, bad, or with i=0; assuming i=1",\r
+                                                        GenCC?"LT(i)":"LATEXT(i)"),\r
+                                          FileStr[a->file], a->line);\r
+                       }\r
+               }\r
+       }\r
+\r
+/* MR10 */    if ( max_k > CLL_k) {\r
+/* MR10 */             if ( !a->frmwarned )\r
+/* MR10 */        {\r
+/* MR10 */                     a->frmwarned = 1;\r
+/* MR11 */ errFL(eMsgd2("predicate refers to lookahead token %d. Semantic lookahead is limited to max(k,ck)==%d",\r
+/* MR10 */                        max_k,CLL_k),\r
+/* MR10 */                        FileStr[a->file],a->line);\r
+/* MR10 */          if (max_k >= OutputLL_k) {\r
+/* MR10 */            if (!GenCC) {\r
+/* MR10 */              errFL(eMsgd("    the lookahead buffer size in C mode is %d token(s) (including the one just recognized)",\r
+/* MR10 */                        OutputLL_k),\r
+/* MR10 */                        FileStr[a->file],a->line);\r
+/* MR10 */            };\r
+/* MR10 */          };\r
+/* MR10 */        };\r
+/* MR10 */        max_k= CLL_k;\r
+/* MR10 */    };\r
+\r
+PREDENTRY_EXIT:\r
+       return max_k;\r
+}\r
+\r
+/* Find all predicates in a block of alternatives.  DO NOT find predicates\r
+ * behind the block because that predicate could depend on things set in\r
+ * one of the nonoptional blocks\r
+ */\r
+\r
+Predicate *\r
+#ifdef __USE_PROTOS\r
+find_in_aSubBlk( Junction *alt )\r
+#else\r
+find_in_aSubBlk( alt )\r
+Junction *alt;\r
+#endif\r
+{\r
+       Predicate *a, *head=NULL, *tail=NULL, *root=NULL;\r
+       Junction *p = alt;\r
+\r
+    if (MRhoisting) {\r
+      return MR_find_in_aSubBlk(alt);\r
+    };\r
+       for (; p!=NULL; p=(Junction *)p->p2)\r
+       {\r
+               /* ignore empty alts */\r
+               if ( p->p1->ntype != nJunction ||\r
+                        ((Junction *)p->p1)->jtype != EndBlk )\r
+               {\r
+                       a = find_predicates(p->p1);     /* get preds for this alt */\r
+                       if ( a==NULL ) continue;\r
+\r
+                       /* make an OR list of predicates */\r
+                       if ( head==NULL )\r
+                       {\r
+                               root = new_pred();\r
+                               root->expr = PRED_OR_LIST;\r
+                               head = tail = a;\r
+                               root->down = head;\r
+                       }\r
+                       else {\r
+                               tail->right = a;\r
+                               a->left = tail;\r
+                               a->up = tail->up;\r
+                               tail = a;\r
+                       }\r
+               }\r
+       }\r
+\r
+       /* if just one pred, remove OR root */\r
+       if ( root!=NULL && root->down->right == NULL )\r
+       {\r
+               Predicate *d = root->down;\r
+               free( (char *) root);\r
+               return d;\r
+       }\r
+\r
+       return root;\r
+}\r
+\r
+Predicate *\r
+#ifdef __USE_PROTOS\r
+find_in_aOptBlk( Junction *alt )\r
+#else\r
+find_in_aOptBlk( alt )\r
+Junction *alt;\r
+#endif\r
+{\r
+       return find_in_aSubBlk( alt );\r
+}\r
+\r
+Predicate *\r
+#ifdef __USE_PROTOS\r
+find_in_aLoopBegin( Junction *alt )\r
+#else\r
+find_in_aLoopBegin( alt )\r
+Junction *alt;\r
+#endif\r
+{\r
+       return find_in_aSubBlk( (Junction *) alt->p1 ); /* get preds in alts */\r
+}\r
+\r
+Predicate *\r
+#ifdef __USE_PROTOS\r
+find_in_aPlusBlk( Junction *alt )\r
+#else\r
+find_in_aPlusBlk( alt )\r
+Junction *alt;\r
+#endif\r
+{\r
+       require(alt!=NULL&&alt->p2!=NULL, "invalid aPlusBlk");\r
+       return find_in_aSubBlk( alt );\r
+}\r
+\r
+/* Look for a predicate;\r
+ *\r
+ * Do not pass anything but Junction nodes; no Actions, Tokens, RuleRefs.\r
+ * This means that a "hoisting distance" of zero is the only distance\r
+ * allowable.  Init actions are ignored.\r
+ *\r
+ * WARNING:\r
+ *             Assumes no (..)? block after predicate for the moment.\r
+ *             Does not check to see if pred is in production that can generate\r
+ *                     a sequence contained in the set of ambiguous tuples.\r
+ *\r
+ * Return the predicate found if any.\r
+ */\r
+\r
+\r
+Predicate *\r
+#ifdef __USE_PROTOS\r
+find_predicates( Node *alt )\r
+#else\r
+find_predicates( alt )\r
+Node *alt;\r
+#endif\r
+{\r
+#ifdef DBG_PRED\r
+       Junction *j;\r
+       RuleRefNode *r;\r
+       TokNode *t;\r
+#endif\r
+       Predicate *pred;\r
+\r
+       if ( alt==NULL ) return NULL;\r
+\r
+#ifdef DBG_PRED\r
+       switch ( alt->ntype )\r
+       {\r
+               case nJunction :\r
+                       j = (Junction *) alt;\r
+                       fprintf(stderr, "Junction(in %s)", j->rname);\r
+                       switch ( j->jtype )\r
+                       {\r
+                               case aSubBlk :\r
+                                       fprintf(stderr,"aSubBlk\n");\r
+                                       break;\r
+                               case aOptBlk :\r
+                                       fprintf(stderr,"aOptBlk\n");\r
+                                       break;\r
+                               case aLoopBegin :\r
+                                       fprintf(stderr,"aLoopBeginBlk\n");\r
+                                       break;\r
+                               case aLoopBlk :\r
+                                       fprintf(stderr,"aLoopBlk\n");\r
+                                       break;\r
+                               case aPlusBlk :\r
+                                       fprintf(stderr,"aPlusBlk\n");\r
+                                       break;\r
+                               case EndBlk :\r
+                                       fprintf(stderr,"EndBlk\n");\r
+                                       break;\r
+                               case RuleBlk :\r
+                                       fprintf(stderr,"RuleBlk\n");\r
+                                       break;\r
+                               case Generic :\r
+                                       fprintf(stderr,"Generic\n");\r
+                                       break;\r
+                               case EndRule :\r
+                                       fprintf(stderr,"EndRule\n");\r
+                                       break;\r
+                       }\r
+                       break;\r
+               case nRuleRef :\r
+                       r = (RuleRefNode *) alt;\r
+                       fprintf(stderr, "RuleRef(in %s)\n", r->rname);\r
+                       break;\r
+               case nToken :\r
+                       t = (TokNode *) alt;\r
+                       fprintf(stderr, "TokenNode(in %s)%s\n", t->rname, TokenString(t->token));\r
+                       break;\r
+               case nAction :\r
+                       fprintf(stderr, "Action\n");\r
+                       break;\r
+       }\r
+#endif\r
+\r
+       switch ( alt->ntype )\r
+       {\r
+               case nJunction :\r
+               {\r
+                       Predicate *a, *b;\r
+                       Junction *p = (Junction *) alt; \r
+\r
+                       /* lock nodes */\r
+                       if ( p->jtype==aLoopBlk || p->jtype==RuleBlk ||\r
+                                p->jtype==aPlusBlk || p->jtype==EndRule )\r
+                       {\r
+                               require(p->pred_lock!=NULL, "rJunc: lock array is NULL");\r
+                               if ( p->pred_lock[1] )\r
+                               {\r
+                                       return NULL;\r
+                               }\r
+                               p->pred_lock[1] = TRUE;\r
+                       }\r
+\r
+                       switch ( p->jtype )\r
+                       {\r
+                               case aSubBlk :\r
+                                       a = find_in_aSubBlk(p);\r
+                                       return a;       /* nothing is visible past this guy */\r
+                               case aOptBlk :\r
+                                       a = find_in_aOptBlk(p);\r
+                                       return a;\r
+                               case aLoopBegin :\r
+                                       a = find_in_aLoopBegin(p);\r
+                                       return a;\r
+                               case aLoopBlk :\r
+                                       a = find_in_aSubBlk(p);\r
+                                       p->pred_lock[1] = FALSE;\r
+                                       return a;\r
+                               case aPlusBlk :\r
+                                       a = find_in_aPlusBlk(p);\r
+                                       p->pred_lock[1] = FALSE;\r
+                                       return a;       /* nothing is visible past this guy */\r
+                               case RuleBlk :\r
+                                       a = find_predicates(p->p1);\r
+                                       p->pred_lock[1] = FALSE;\r
+                                       return a;\r
+                               case Generic :\r
+                                       a = find_predicates(p->p1);\r
+                                       b = find_predicates(p->p2);\r
+                                       if ( p->pred_lock!=NULL ) p->pred_lock[1] = FALSE;\r
+                                       if ( a==NULL ) return b;\r
+                                       if ( b==NULL ) return a;\r
+                                       /* otherwise OR the two preds together */\r
+                                       {\r
+                                       fatal_internal("hit unknown situation during predicate hoisting");\r
+                                       }\r
+                               case EndBlk :\r
+                               case EndRule :  /* Find no predicates after a rule ref */\r
+                                       return NULL;\r
+                               default:\r
+                                       fatal_internal("this cannot be printed\n");\r
+                                       break;\r
+                       }\r
+               }\r
+               case nAction :\r
+               {\r
+                       ActionNode *p = (ActionNode *) alt;\r
+            if ( p->noHoist) return NULL;                           /* MR12c */\r
+                       if ( p->init_action ) return find_predicates(p->next);\r
+                       if ( p->is_predicate )\r
+                       {\r
+                               Tree *t=NULL;\r
+#ifdef DBG_PRED\r
+                               fprintf(stderr, "predicate: <<%s>>?\n", p->action);\r
+#endif\r
+                               if ( p->guardpred!=NULL )\r
+                               {\r
+                                       pred = predicate_dup(p->guardpred);\r
+                    MR_guardPred_plainSet(p,pred);                  /* MR12c */\r
+                               }\r
+                               else\r
+                               {\r
+                                       pred = new_pred();\r
+                                       pred->k = predicateLookaheadDepth(p);\r
+                                       pred->source = p;\r
+                                       pred->expr = p->action;\r
+                                       if ( HoistPredicateContext && pred->k > 1 )\r
+                                       {\r
+                                               /* MR30 No need to use first_item_is_guess_block_extra\r
+                                                  since we know this is an action, not a (...)* or\r
+                                                  (...)+ block.\r
+                                               */\r
+\r
+                                               if ( first_item_is_guess_block((Junction *)p->next) )\r
+                                               {\r
+                            warnFL("cannot compute context of predicate in front of (..)? block",\r
+                            FileStr[p->file], p->line);\r
+                                               }\r
+                                               else\r
+                                               {\r
+                                                       ConstrainSearch = 0;\r
+/* MR11 */                  if (p->ampersandPred != NULL) {\r
+/* MR11 */                                     TRAV(p,\r
+/* MR11 */                                                      pred->k,\r
+/* MR11 */                                              &(pred->completionTree), t);\r
+/* MR11 */                  } else {\r
+                                                       TRAV(p->next,\r
+                                                                pred->k,\r
+                                                                &(pred->completionTree), t);\r
+                            };\r
+                                                       pred->tcontext = t;\r
+                            MR_check_pred_too_long(pred,pred->completionTree);\r
+#ifdef DBG_PRED\r
+                                                       fprintf(stderr, "LL(%d) context:", pred->k);\r
+                                                       preorder(t);\r
+                                                       fprintf(stderr, "\n");\r
+#endif\r
+                                               }\r
+                                       }\r
+                                       else if ( HoistPredicateContext && pred->k == 1 )\r
+                                       {\r
+                                               pred->scontext[1] = empty;\r
+                                               /* MR30 No need to use first_item_is_guess_block_extra\r
+                                                  since we know this is an action.\r
+                                               */\r
+                                               if ( first_item_is_guess_block((Junction *)p->next) )\r
+                                               {\r
+                        warnFL("cannot compute context of predicate in front of (..)? block",\r
+                                             FileStr[p->file], p->line);\r
+                                               }\r
+                                               else\r
+                                               {\r
+                                                       REACH((Junction *)p->next,\r
+                                                                 1,\r
+                                                                 &(pred->completionSet),\r
+                                                                 pred->scontext[1]);\r
+                            MR_check_pred_too_long(pred,pred->completionSet);\r
+#ifdef DBG_PRED\r
+                                                       fprintf(stderr, "LL(1) context:");\r
+                                                       s_fprT(stderr, pred->scontext[1]);\r
+                                                       fprintf(stderr, "\n");\r
+#endif\r
+                                               }\r
+                                       }\r
+                               }\r
+                               {\r
+                                       Predicate  *d = find_predicates(p->next);\r
+                    Predicate  *root;\r
+\r
+/* Warning: Doesn't seem like the up pointers will all be set correctly;\r
+ * TJP: that's ok, we're not using them now.\r
+ */\r
+                                       if ( d!=NULL )\r
+                                       {\r
+                                               root = new_pred();\r
+                                               root->expr = PRED_AND_LIST;\r
+                                               root->down = pred;\r
+                                               pred->right = d;\r
+                                               pred->up = root;\r
+                                               d->left = pred;\r
+                                               d->up = pred->up;\r
+                                               return root;\r
+                                       }\r
+                               }\r
+                               return pred;\r
+                       }\r
+                       return NULL;\r
+               }\r
+               case nRuleRef :\r
+               {\r
+                       Predicate   *a;\r
+                       RuleRefNode *p = (RuleRefNode *) alt;\r
+                       Junction    *r;\r
+            Junction    *save_MR_RuleBlkWithHalt;\r
+\r
+                       RuleEntry *q = (RuleEntry *) hash_get(Rname, p->text);\r
+                       if ( q == NULL )\r
+                       {\r
+                               warnFL( eMsg1("rule %s not defined",p->text), FileStr[p->file], p->line );\r
+                               return NULL;\r
+                       }\r
+                       r = RulePtr[q->rulenum];\r
+                       if ( r->pred_lock[1] )\r
+                       {\r
+                               /* infinite left-recursion; ignore 'cause LL sup 1 (k) analysis\r
+                                * must have seen it earlier.\r
+                                */\r
+                               return NULL;\r
+                       }\r
+\r
+            /* MR10 There should only be one halt set at a time.        */\r
+            /* MR10 Life would have been easier with a global variable  */\r
+            /* MR10    (at least for this particular need)              */\r
+            /* MR10 Unset the old one and set the new one, later undo.  */\r
+\r
+            require(r->end->halt == FALSE,"should only have one halt at a time");\r
+\r
+/* MR10 */  require(MR_RuleBlkWithHalt == NULL ||\r
+/* MR10 */          (MR_RuleBlkWithHalt->jtype == RuleBlk && MR_RuleBlkWithHalt->end->halt == TRUE),\r
+/* MR10 */             "RuleBlkWithHalt->end not RuleBlk or does not have halt set");\r
+/* MR10 */  if (MR_RuleBlkWithHalt != NULL) {\r
+/* MR10 */    MR_RuleBlkWithHalt->end->halt=FALSE;\r
+/* MR10 */  };\r
+\r
+/***        fprintf(stderr,"\nSetting halt on junction #%d\n",r->end->seq);     ***/\r
+\r
+            require(r->end->halt == FALSE,"rule->end->halt already set");\r
+\r
+            save_MR_RuleBlkWithHalt=MR_RuleBlkWithHalt;\r
+\r
+/* MR10 */  MR_pointerStackPush(&MR_RuleBlkWithHaltStack,MR_RuleBlkWithHalt);\r
+/* MR10 */  MR_pointerStackPush(&MR_PredRuleRefStack,p);\r
+\r
+                       r->end->halt = TRUE;\r
+/* MR10 */  MR_RuleBlkWithHalt=r;\r
+\r
+                       a = find_predicates((Node *)r);\r
+\r
+            require(r->end->halt == TRUE,"rule->end->halt not set");\r
+            r->end->halt = FALSE;\r
+\r
+/* MR10 */  MR_pointerStackPop(&MR_PredRuleRefStack);\r
+/* MR10 */  MR_RuleBlkWithHalt=(Junction *) MR_pointerStackPop(&MR_RuleBlkWithHaltStack);\r
+\r
+            require (MR_RuleBlkWithHalt==save_MR_RuleBlkWithHalt,\r
+                    "RuleBlkWithHaltStack not consistent");\r
+\r
+/* MR10 */  require(MR_RuleBlkWithHalt == NULL ||\r
+/* MR10 */          (MR_RuleBlkWithHalt->jtype == RuleBlk && MR_RuleBlkWithHalt->end->halt == FALSE),\r
+/* MR10 */             "RuleBlkWithHalt->end not RuleBlk or has no halt set");\r
+/* MR10 */  if (MR_RuleBlkWithHalt != NULL) {\r
+/* MR10 */    MR_RuleBlkWithHalt->end->halt=TRUE;\r
+/* MR10 */  };\r
+\r
+/***        fprintf(stderr,"\nRestoring halt on junction #%d\n",r->end->seq);   ***/\r
+\r
+                       if ( a==NULL ) return NULL;\r
+\r
+                       /* attempt to compute the "local" FOLLOW just like in normal lookahead\r
+                        * computation if needed\r
+                        */\r
+\r
+                       complete_context_sets(p,a);\r
+                       complete_context_trees(p,a);\r
+\r
+/* MR10 */  MR_cleanup_pred_trees(a);\r
+\r
+                       return a;\r
+               }\r
+               case nToken :\r
+                       break;\r
+       }\r
+\r
+       return NULL;\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+Predicate *MR_find_predicates_and_supp(Node *alt)\r
+#else\r
+Predicate *MR_find_predicates_and_supp(alt)\r
+  Node      *alt;\r
+#endif\r
+{\r
+    Predicate   *p;\r
+\r
+    p=find_predicates(alt);\r
+    p=MR_suppressK(alt,p);\r
+    return p;\r
+}\r
+\r
+Predicate *\r
+#ifdef __USE_PROTOS\r
+new_pred( void )\r
+#else\r
+new_pred( )\r
+#endif\r
+{\r
+       Predicate *p = (Predicate *) calloc(1,sizeof(Predicate)); /* MR10 */\r
+       require(p!=NULL, "new_pred: cannot alloc predicate");\r
+    p->scontext[0]=empty;\r
+    p->scontext[1]=empty;\r
+    p->completionTree=empty;\r
+    p->completionSet=empty;\r
+    p->plainSet=empty;\r
+       return p;\r
+}\r
+\r
+static void\r
+#ifdef __USE_PROTOS\r
+complete_context_sets( RuleRefNode *p, Predicate *a )\r
+#else\r
+complete_context_sets( p, a )\r
+RuleRefNode *p;\r
+Predicate *a;\r
+#endif\r
+{\r
+       set rk2, b;\r
+       int k2;\r
+\r
+#ifdef DBG_PRED\r
+       fprintf(stderr, "enter complete_context_sets\n");\r
+#endif\r
+       for (; a!=NULL; a=a->right)\r
+       {\r
+               if ( a->expr == PRED_AND_LIST || a->expr == PRED_OR_LIST )\r
+               {\r
+                       complete_context_sets(p,a->down);\r
+                       continue;\r
+               }\r
+               rk2 = b = empty;\r
+               while ( !set_nil(a->completionSet) )\r
+               {\r
+                       k2 = set_int(a->completionSet);\r
+                       set_rm(k2, a->completionSet);\r
+\r
+            REACH(p->next, k2, &rk2, b);\r
+                       set_orin(&(a->scontext[1]), b);\r
+                       set_free(b);\r
+               }\r
+\r
+               set_orin(&(a->completionSet), rk2);/* remember what we couldn't do */\r
+               set_free(rk2);\r
+#ifdef DBG_PRED\r
+               fprintf(stderr, "LL(1) context for %s(addr 0x%x) after ruleref:", a->expr, a);\r
+               s_fprT(stderr, a->scontext[1]);\r
+               fprintf(stderr, "\n");\r
+#endif\r
+/*             complete_context_sets(p, a->down);*/\r
+       }\r
+#ifdef DBG_PRED\r
+       fprintf(stderr, "exit complete_context_sets\n");\r
+#endif\r
+}\r
+\r
+static void\r
+#ifdef __USE_PROTOS\r
+complete_context_trees( RuleRefNode *p, Predicate *a )\r
+#else\r
+complete_context_trees( p, a )\r
+RuleRefNode *p;\r
+Predicate *a;\r
+#endif\r
+{\r
+       set rk2;\r
+       int k2;\r
+       Tree *u;\r
+\r
+#ifdef DBG_PRED\r
+       fprintf(stderr, "enter complete_context_trees\n");\r
+#endif\r
+       for (; a!=NULL; a=a->right)\r
+       {\r
+               if ( a->expr == PRED_AND_LIST || a->expr == PRED_OR_LIST )\r
+               {\r
+                       complete_context_trees(p, a->down);\r
+                       continue;\r
+               }\r
+               rk2 = empty;\r
+\r
+               /* any k left to do? if so, link onto tree */\r
+               while ( !set_nil(a->completionTree) )\r
+               {       \r
+                       k2 = set_int(a->completionTree);\r
+                       set_rm(k2, a->completionTree);\r
+                       u = NULL;\r
+\r
+            TRAV(p->next, k2, &rk2, u);\r
+\r
+                       /* any subtrees missing k2 tokens, add u onto end */\r
+                       a->tcontext = tlink(a->tcontext, u, k2);\r
+            Tfree(u);   /* MR10 */\r
+               }\r
+               set_orin(&(a->completionTree), rk2);/* remember what we couldn't do */\r
+               set_free(rk2);\r
+#ifdef DBG_PRED\r
+               fprintf(stderr, "LL(i<%d) context after ruleref:", LL_k);\r
+               preorder(a->tcontext);\r
+               fprintf(stderr, "\n");\r
+#endif\r
+/*             complete_context_trees(p, a->down);*/\r
+       }\r
+#ifdef DBG_PRED\r
+       fprintf(stderr, "exit complete_context_trees\n");\r
+#endif\r
+}\r
+\r
+/* Walk a list of predicates and return the set of all tokens in scontext[1]'s */\r
+set\r
+#ifdef __USE_PROTOS\r
+covered_set( Predicate *p )\r
+#else\r
+covered_set( p )\r
+Predicate *p;\r
+#endif\r
+{\r
+       set a;\r
+\r
+       a = empty;\r
+       for (; p!=NULL; p=p->right)\r
+       {\r
+               if ( p->expr == PRED_AND_LIST || p->expr == PRED_OR_LIST )\r
+               {\r
+                       set_orin(&a, covered_set(p->down));\r
+                       continue;\r
+               }\r
+               set_orin(&a, p->scontext[1]);\r
+               set_orin(&a, covered_set(p->down));\r
+       }\r
+       return a;\r
+}\r
+\r
+/* MR10 predicate_free()\r
+   MR10 Don't free the leaf nodes since they are part of the action node\r
+*/\r
+\r
+#ifdef __USE_PROTOS\r
+void predicate_free(Predicate *p)\r
+#else\r
+void predicate_free(p)\r
+  Predicate     *p;\r
+#endif\r
+{\r
+  if (p == NULL) return;\r
+  predicate_free(p->right);\r
+  predicate_free(p->down);\r
+  if (p->cloned ||\r
+      p->source == NULL ||\r
+      p->source->guardpred == NULL ||\r
+      p->expr == PRED_AND_LIST ||\r
+      p->expr == PRED_OR_LIST) {\r
+    set_free(p->scontext[1]);\r
+    set_free(p->completionSet);\r
+    set_free(p->completionTree);\r
+    set_free(p->plainSet);\r
+    Tfree(p->tcontext);\r
+    free( (char *) p);\r
+  } else {\r
+    p->right=NULL;\r
+    p->down=NULL;  /* MR13 *** debug */\r
+  };\r
+}\r
+\r
+/* MR10 predicate_dup() */\r
+\r
+#ifdef __USE_PROTOS\r
+Predicate * predicate_dup_xxx(Predicate *p,int contextToo)\r
+#else\r
+Predicate * predicate_dup_xxx(p,contextToo)\r
+  Predicate     *p;\r
+  int           contextToo;\r
+#endif\r
+{\r
+  Predicate     *q;\r
+\r
+  if (p == NULL) return NULL;\r
+  q=new_pred();\r
+  q->down=predicate_dup(p->down);\r
+  q->right=predicate_dup(p->right);\r
+\r
+  /*\r
+     don't replicate expr - it is read-only\r
+     and address comparison is used to look\r
+     for identical predicates.\r
+  */\r
+\r
+  q->expr=p->expr;\r
+  q->k=p->k;\r
+  q->source=p->source;\r
+  q->cloned=1;\r
+  q->ampersandStyle=p->ampersandStyle;\r
+  q->inverted=p->inverted;\r
+  q->predEntry=p->predEntry;\r
+  q->plainSet=set_dup(p->plainSet);\r
+\r
+  if (contextToo) {\r
+    q->tcontext=tdup(p->tcontext);\r
+    q->scontext[0]=set_dup(p->scontext[0]);\r
+    q->scontext[1]=set_dup(p->scontext[1]);\r
+    q->completionTree=set_dup(p->completionTree);\r
+    q->completionSet=set_dup(p->completionSet);\r
+  };\r
+\r
+  /* don't need to dup "redundant" */\r
+\r
+  return q;\r
+\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+Predicate * predicate_dup_without_context(Predicate *p)\r
+#else\r
+Predicate * predicate_dup_without_context(p)\r
+  Predicate     *p;\r
+#endif\r
+{\r
+  return predicate_dup_xxx(p,0);\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+Predicate * predicate_dup(Predicate *p)\r
+#else\r
+Predicate * predicate_dup(p)\r
+  Predicate     *p;\r
+#endif\r
+{\r
+  return predicate_dup_xxx(p,1);\r
+}\r
+\r
diff --git a/Tools/CodeTools/Source/Pccts/antlr/proto.h b/Tools/CodeTools/Source/Pccts/antlr/proto.h
new file mode 100644 (file)
index 0000000..53035e7
--- /dev/null
@@ -0,0 +1,852 @@
+/*\r
+ * proto.h -- function prototypes\r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
+ * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
+ * company may do whatever they wish with source code distributed with\r
+ * PCCTS or the code generated by PCCTS, including the incorporation of\r
+ * PCCTS, or its output, into commerical software.\r
+ *\r
+ * We encourage users to develop software with PCCTS.  However, we do ask\r
+ * that credit is given to us for developing PCCTS.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like PCCTS and have developed a nice tool with the\r
+ * output, please mention that you developed it using PCCTS.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * ANTLR 1.33\r
+ * Terence Parr\r
+ * Parr Research Corporation\r
+ * with Purdue University and AHPCRC, University of Minnesota\r
+ * 1989-2001\r
+ */\r
+\r
+                           /* V a r i a b l e s */\r
+\r
+extern int tp;\r
+extern Junction *SynDiag;\r
+extern char Version[];\r
+extern char VersionDef[];\r
+#ifdef __cplusplus\r
+extern void (*fpPrint[])(...);\r
+#else\r
+extern void (*fpPrint[])();\r
+#endif\r
+#ifdef __cplusplus\r
+extern struct _set (*fpReach[])(...);\r
+#else\r
+extern struct _set (*fpReach[])();\r
+#endif\r
+#ifdef __cplusplus\r
+extern struct _tree *(*fpTraverse[])(...);\r
+#else\r
+extern struct _tree *(*fpTraverse[])();\r
+#endif\r
+#ifdef __cplusplus\r
+extern void (**fpTrans)(...);\r
+#else\r
+extern void (**fpTrans)();\r
+#endif\r
+#ifdef __cplusplus\r
+extern void (**fpJTrans)(...);\r
+#else\r
+extern void (**fpJTrans)();\r
+#endif\r
+#ifdef __cplusplus\r
+extern void (*C_Trans[NumNodeTypes+1])(...);\r
+#else\r
+extern void (*C_Trans[])();\r
+#endif\r
+#ifdef __cplusplus\r
+extern void (*C_JTrans[NumJuncTypes+1])(...);\r
+#else\r
+extern void (*C_JTrans[])();\r
+#endif\r
+extern int BlkLevel;\r
+extern int CurFile;\r
+extern char *CurPredName;\r
+extern char *CurRule;\r
+extern int  CurRuleDebug;                       /* MR13 */\r
+extern Junction *CurRuleBlk;\r
+extern RuleEntry *CurRuleNode;\r
+extern ListNode *CurElementLabels;\r
+extern ListNode *CurAstLabelsInActions;         /* MR27 */\r
+extern ListNode *ContextGuardPredicateList;     /* MR13 */\r
+extern ListNode *CurActionLabels;\r
+extern int numericActionLabel;        /* MR10 << ... $1 ... >> or << ... $1 ... >>?   */\r
+extern ListNode *NumericPredLabels;   /* MR10 << ... $1 ... >>?  ONLY                 */\r
+extern char *FileStr[];\r
+extern int NumFiles;\r
+extern int EpToken;\r
+extern int WildCardToken;\r
+extern Entry   **Tname,\r
+                               **Texpr,\r
+                               **Rname,\r
+                               **Fcache,\r
+                               **Tcache,\r
+                               **Elabel,\r
+                               **Sname,\r
+                **Pname;    /* MR11 */\r
+extern ListNode *ExprOrder;\r
+extern ListNode **Cycles;\r
+extern int TokenNum;\r
+extern int LastTokenCounted;\r
+extern ListNode *BeforeActions, *AfterActions, *LexActions;\r
+\r
+/* MR1                                                                                             */\r
+/* MR1  11-Apr-97      Provide mechanism for inserting code into DLG class     */\r
+/* MR1                   via #lexmember <<....>> & #lexprefix <<...>>              */\r
+/* MR1                                                                     */\r
+\r
+extern ListNode *LexMemberActions;                                          /* MR1 */\r
+extern ListNode *LexPrefixActions;                                          /* MR1 */\r
+\r
+extern set *fset;   /* for constrained search */             /* MR11 */\r
+extern int maxk;    /* for constrained search */             /* MR11 */\r
+extern int Save_argc;                                        /* MR10 */\r
+extern char **Save_argv;                                     /* MR10 */\r
+extern ListNode *eclasses, *tclasses;\r
+extern char    *HdrAction;\r
+extern char *FirstAction;                                    /* MR11 */\r
+extern FILE    *ErrFile;\r
+extern char *RemapFileName;\r
+extern char *ErrFileName;\r
+extern char *DlgFileName;\r
+extern char *DefFileName;\r
+extern char *ModeFileName;\r
+extern char *StdMsgName;\r
+extern int NumRules;\r
+extern Junction **RulePtr;\r
+extern int LL_k;\r
+extern int CLL_k;\r
+extern char *decodeJType[];\r
+extern int PrintOut;\r
+extern int PrintAnnotate;\r
+extern int CodeGen;\r
+extern int LexGen;\r
+extern int esetnum;\r
+extern int setnum;\r
+extern int wordnum;\r
+extern int GenAST;\r
+extern int GenANSI;\r
+extern int **FoStack;\r
+extern int **FoTOS;\r
+extern int GenExprSetsOpt;\r
+extern FILE *DefFile;\r
+extern int CannotContinue;\r
+extern int GenCR;\r
+extern int GenLineInfo;\r
+extern int GenLineInfoMS;\r
+extern int action_file, action_line;\r
+extern int TraceGen;\r
+extern int CurAmbigAlt1, CurAmbigAlt2, CurAmbigline, CurAmbigfile;\r
+extern char *CurAmbigbtype;\r
+extern int elevel;\r
+extern int GenEClasseForRules;\r
+extern FILE *input, *output;\r
+extern char **TokenStr, **ExprStr;\r
+extern int CurrentLexClass, NumLexClasses;\r
+extern LClass lclass[];\r
+extern char LexStartSymbol[];\r
+extern char    *CurRetDef;\r
+extern char    *CurParmDef;\r
+extern int OutputLL_k;\r
+extern int TreeResourceLimit;\r
+extern int DemandLookahead;\r
+extern char *RulePrefix;\r
+extern int GenStdPccts;\r
+extern char *stdpccts;\r
+extern int ParseWithPredicates;\r
+extern int ConstrainSearch;\r
+extern int PURIFY;                                                                                                     /* MR23 */\r
+\r
+extern set MR_CompromisedRules;                                     /* MR14 */\r
+extern int MR_AmbSourceSearch;                                      /* MR11 */\r
+extern int MR_SuppressSearch;                                       /* MR13 */\r
+extern int MR_AmbSourceSearchGroup;                                 /* MR11 */\r
+extern int MR_AmbSourceSearchChoice;                                /* MR11 */\r
+extern int MR_AmbSourceSearchLimit;                                 /* MR11 */\r
+extern int MR_usingPredNames;                                       /* MR11 */\r
+extern int MR_ErrorSetComputationActive;                            /* MR14 */\r
+extern char *MR_AmbAidRule;                                         /* MR11 */\r
+extern int   MR_AmbAidLine;                                         /* MR11 */\r
+extern int   MR_AmbAidMultiple;                                     /* MR11 */\r
+extern int MR_AmbAidDepth;                                          /* MR11 */\r
+extern int MR_skipped_e3_report;                                    /* MR11 */\r
+extern int MR_matched_AmbAidRule;                                   /* MR11 */\r
+extern int MR_Inhibit_Tokens_h_Gen;                                 /* MR13 */\r
+extern int NewAST;                                                  /* MR13 */\r
+extern int tmakeInParser;                                           /* MR23 */\r
+extern int AlphaBetaTrace;                                          /* MR14 */\r
+extern int MR_BlkErr;                                               /* MR21 */\r
+extern int MR_AlphaBetaWarning;                                     /* MR14 */\r
+extern int MR_AlphaBetaMessageCount;                                /* MR14 */\r
+extern int MR_MaintainBackTrace;                                    /* MR14 */\r
+extern int MR_BadExprSets;                                          /* MR13 */\r
+extern int FoundGuessBlk;\r
+extern int FoundException;\r
+extern int FoundAtOperator;                                                         /* MR6 */\r
+extern int FoundExceptionGroup;                                      /* MR6 */\r
+extern int WarningLevel;\r
+extern int UseStdout;                                                               /* MR6 */\r
+extern int TabWidth;                                                                /* MR6 */\r
+extern int pLevel;\r
+extern int pAlt1;\r
+extern int pAlt2;\r
+extern int AImode;\r
+extern int HoistPredicateContext;\r
+extern int MRhoisting;                                               /* MR9 */\r
+extern int MRhoistingk;                                              /* MR13 */\r
+extern int MR_debugGenRule;                                          /* MR11 */\r
+extern int GenCC;\r
+extern char *ParserName;\r
+extern char *StandardSymbols[];\r
+extern char *ASTSymbols[];\r
+extern set reserved_positions;\r
+extern set all_tokens;\r
+extern set imag_tokens;\r
+extern set tokclasses;\r
+extern ListNode *ForcedTokens;\r
+extern int *TokenInd;\r
+extern FILE *Parser_h, *Parser_c;\r
+extern char CurrentClassName[];\r
+extern int no_classes_found;\r
+extern char Parser_h_Name[];\r
+extern char Parser_c_Name[];\r
+extern char MRinfoFile_Name[];                                      /* MR10 */\r
+extern FILE *MRinfoFile;                                            /* MR10 */\r
+extern int MRinfo;                                                  /* MR10 */\r
+extern int MRinfoSeq;                                               /* MR10 */\r
+extern int InfoP;                                                   /* MR10 */\r
+extern int InfoT;                                                   /* MR10 */\r
+extern int InfoF;                                                   /* MR10 */\r
+extern int InfoM;                                                   /* MR10 */\r
+extern int InfoO;                                                   /* MR12 */\r
+extern int PotentialSuppression;                                    /* MR10 */\r
+extern int PotentialDummy;                                          /* MR10 */\r
+extern int TnodesInUse;                                             /* MR10 */\r
+extern int TnodesPeak;                                              /* MR10 */\r
+extern int TnodesReportThreshold;                                   /* MR11 */\r
+extern int TnodesAllocated;                                         /* MR10 */\r
+extern char *ClassDeclStuff;                                        /* MR10 */\r
+extern char *BaseClassName;                                         /* MR22 */\r
+extern ListNode *class_before_actions, *class_after_actions;\r
+extern char *UserTokenDefsFile;\r
+extern int UserDefdTokens;\r
+extern ListNode *MetaTokenNodes;\r
+extern char *OutputDirectory;\r
+extern int DontCopyTokens;\r
+extern int LTinTokenAction;                                         /* MR23 */\r
+extern set AST_nodes_refd_in_actions;\r
+extern ListNode *CurExGroups;\r
+extern int CurBlockID;\r
+extern int CurAltNum;\r
+extern Junction *CurAltStart;\r
+extern Junction *OuterAltStart;               /* chain exception groups MR7 */\r
+extern ExceptionGroup *DefaultExGroup;\r
+extern int NumSignals;\r
+extern int ContextGuardTRAV;\r
+extern Junction *MR_RuleBlkWithHalt;            /* MR10 */\r
+extern PointerStack MR_BackTraceStack;          /* MR10 */\r
+extern PointerStack MR_PredRuleRefStack;        /* MR10 */\r
+extern PointerStack MR_RuleBlkWithHaltStack;    /* MR10 */\r
+\r
+/*                                                                     */\r
+/* MR1 10-Apr-97  MR1  Previously unable to put right shift operator       */\r
+/* MR1                                 in DLG action                                       */\r
+/*                                                                                                         */\r
+extern int tokenActionActive;                                       /* MR1 */\r
+\r
+extern char *PRED_OR_LIST;                                          /* MR10 */\r
+extern char *PRED_AND_LIST;                                         /* MR10 */\r
+\r
+#ifdef __VMS\r
+#define STRICMP strcasecmp /* MR21 */\r
+#else\r
+#define STRICMP stricmp /* MR21 */\r
+#endif\r
+\r
+/* MR26 */\r
+#ifdef PCCTS_USE_STDARG\r
+extern Tree *tmake(Tree *root, ...);\r
+#else\r
+extern Tree *tmake();\r
+#endif\r
+\r
+#ifdef __USE_PROTOS\r
+extern int STRICMP(const char*, const char*);\r
+extern void istackreset(void);\r
+extern int istacksize(void);\r
+extern void pushint(int);\r
+extern int popint( void );\r
+extern int istackempty( void );\r
+extern int topint( void );\r
+extern void NewSetWd( void );\r
+extern void DumpSetWd( void );\r
+extern void DumpSetWdForC( void );\r
+extern void DumpSetWdForCC( void );\r
+extern void NewSet( void );\r
+extern void FillSet( set );\r
+extern void ComputeErrorSets( void );\r
+extern void ComputeTokSets( void );\r
+extern void SubstErrorClass( set * );\r
+extern int DefErrSet( set *, int, char * );\r
+extern int DefErrSetForC( set *, int, char * );\r
+extern int DefErrSetForCC( set *, int, char * );\r
+extern int DefErrSet1(int, set *, int, char *);                         /* MR21 */\r
+extern int DefErrSetForC1(int, set *, int, char *, const char* );       /* MR21 */\r
+extern int DefErrSetForCC1(int, set *, int, char *, const char* );      /* MR21 */\r
+extern int DefErrSetWithSuffix(int, set *, int, char *, const char *);  /* MR21 */\r
+extern void GenErrHdr( void );\r
+extern void dumpExpr( FILE *, char * );\r
+extern void addParm( Node *, char * );\r
+extern Graph buildAction( char *, int, int, int );\r
+extern Graph buildToken( char * );\r
+extern Graph buildWildCard( char * );\r
+extern Graph buildRuleRef( char * );\r
+extern Graph Or( Graph, Graph );\r
+extern Graph Cat( Graph, Graph );\r
+extern Graph makeOpt( Graph, int, char *);\r
+extern Graph makeBlk( Graph, int, char *);\r
+extern Graph makeLoop( Graph, int, char *);\r
+extern Graph makePlus( Graph, int, char *);\r
+extern Graph emptyAlt( void );\r
+extern Graph emptyAlt3( void );\r
+extern TokNode * newTokNode( void );\r
+extern RuleRefNode * newRNode( void );\r
+extern Junction * newJunction( void );\r
+extern ActionNode * newActionNode( void );\r
+extern char * makelocks( void );\r
+extern void preorder( Tree * );\r
+extern Tree * tnode( int );\r
+extern void _Tfree( Tree * );\r
+extern Tree * tdup( Tree * );\r
+extern int is_single_tuple( Tree * );\r
+extern Tree * tappend( Tree *, Tree * );\r
+extern void Tfree( Tree * );\r
+extern Tree * tlink( Tree *, Tree *, int );\r
+extern Tree * tshrink( Tree * );\r
+extern Tree * tflatten( Tree * );\r
+extern Tree * tJunc( Junction *, int, set * );\r
+extern Tree * tRuleRef( RuleRefNode *, int, set * );\r
+extern Tree * tToken( TokNode *, int, set * );\r
+extern Tree * tAction( ActionNode *, int, set * );\r
+extern int tmember( Tree *, Tree * );\r
+extern int tmember_constrained( Tree *, Tree * );\r
+extern Tree * tleft_factor( Tree * );\r
+extern Tree * trm_perm( Tree *, Tree * );\r
+extern void tcvt( set *, Tree * );\r
+extern Tree * permute( int, int );\r
+extern Tree * VerifyAmbig( Junction *, Junction *, unsigned **, set *, Tree **, Tree **, int * );\r
+extern set rJunc( Junction *, int, set * );\r
+extern set rRuleRef( RuleRefNode *, int, set * );\r
+extern set rToken( TokNode *, int, set * );\r
+extern set rAction( ActionNode *, int, set * );\r
+extern void HandleAmbiguity( Junction *, Junction *, Junction *, int );\r
+extern set First( Junction *, int, int, int * );\r
+extern void freeBlkFsets( Junction * );\r
+extern void genAction( ActionNode * );\r
+extern void genRuleRef( RuleRefNode * );\r
+extern void genToken( TokNode * );\r
+extern void genOptBlk( Junction * );\r
+extern void genLoopBlk( Junction *, Junction *, Junction *, int );\r
+extern void genLoopBegin( Junction * );\r
+extern void genPlusBlk( Junction * );\r
+extern void genSubBlk( Junction * );\r
+extern void genRule( Junction * );\r
+extern void genJunction( Junction * );\r
+extern void genEndBlk( Junction * );\r
+extern void genEndRule( Junction * );\r
+extern void genHdr( int );\r
+extern void genHdr1( int );\r
+extern void dumpAction( char *, FILE *, int, int, int, int );\r
+extern void dumpActionPlus(ActionNode*, char *, FILE *, int, int, int, int );   /* MR21 */\r
+extern Entry ** newHashTable( void );\r
+extern Entry * hash_add( Entry **, char *, Entry * );\r
+extern Entry * hash_get( Entry **, char * );\r
+extern void hashStat( Entry ** );\r
+extern char * mystrdup( char * );\r
+extern void genLexDescr( void );\r
+extern void dumpLexClasses( FILE * );\r
+extern void genDefFile( void );\r
+extern void DumpListOfParmNames( char *, FILE *, int );        /* MR5 janm 26-May-97 */\r
+extern int DumpNextNameInDef( char **, FILE * );\r
+extern void DumpOldStyleParms( char *, FILE * );\r
+extern void DumpType( char *, FILE * );\r
+extern int strmember( char *, char * );\r
+/* extern int HasComma( char * ); MR23 Replaced by hasMultipleOperands() */\r
+extern void DumpRetValStruct( FILE *, char *, int );\r
+extern char * StripQuotes( char * );\r
+extern int main( int, char *[] );\r
+extern void readDescr( void );\r
+extern FILE * NextFile( void );\r
+extern char * outnameX( char *, char *);\r
+extern char * outname( char * );\r
+extern void fatalFL( char *, char *, int );\r
+extern void fatal_intern( char *, char *, int );\r
+extern void cleanUp( void );\r
+extern char * eMsg3( char *, char *, char *, char * );\r
+extern char * eMsgd( char *, int );\r
+extern char * eMsgd2( char *, int, int );\r
+extern void s_fprT( FILE *, set );\r
+extern char * TerminalString( int );\r
+extern void lexclass( char * );\r
+extern void lexmode( int );\r
+extern int LexClassIndex( char * );\r
+extern int hasAction( char * );\r
+extern void setHasAction( char *, char * );\r
+extern int addTname( char * );\r
+extern int addTexpr( char * );\r
+extern int Tnum( char * );\r
+extern void Tklink( char *, char * );\r
+extern Entry * newEntry( char *, int );\r
+extern void list_add( ListNode **, void * );\r
+extern void list_free( ListNode **, int freeData );     /* MR10 */\r
+extern void list_apply( ListNode *, void (*)(void *) );\r
+extern int list_search_cstring (ListNode *, char *);    /* MR27 */\r
+extern char * Fkey( char *, int, int );\r
+extern void FoPush( char *, int );\r
+extern void FoPop( int );\r
+extern void RegisterCycle( char *, int );\r
+extern void ResolveFoCycles( int );\r
+extern void pJunc( Junction * );\r
+extern void pRuleRef( RuleRefNode * );\r
+extern void pToken( TokNode * );\r
+extern void pAction( ActionNode * );\r
+extern void FoLink( Node * );\r
+extern void addFoLink( Node *, char *, Junction * );\r
+extern void GenCrossRef( Junction * );\r
+extern void defErr( char *, long, long, long, long, long, long );\r
+extern void genStdPCCTSIncludeFile(FILE *,char *);                  /* MR10 */\r
+extern char * pcctsBaseName(char *);                                /* MR32 */\r
+extern Predicate *find_predicates(Node *);                          /* MR10 */\r
+extern Predicate *MR_find_predicates_and_supp(Node *);              /* MR13 */\r
+extern int predicateLookaheadDepth(ActionNode *);                   /* MR10 */\r
+extern void predicate_free(Predicate *);                            /* MR10 */\r
+extern Predicate * predicate_dup(Predicate *);                      /* MR10 */\r
+extern Predicate * predicate_dup_without_context(Predicate *);      /* MR11 */\r
+extern void GenRulePrototypes(FILE *, Junction *);\r
+extern Junction *first_item_is_guess_block(Junction *);\r
+extern Junction *first_item_is_guess_block_extra(Junction * q);                /* MR30 */\r
+extern Junction *analysis_point(Junction *);\r
+extern Tree *make_tree_from_sets(set *, set *);\r
+extern Tree *tdup_chain(Tree *);\r
+extern Tree *tdif(Tree *, Predicate *, set *, set *);\r
+extern set covered_set(Predicate *);\r
+extern void AmbiguityDialog(Junction *, int, Junction *, Junction *, int *, int *);\r
+extern void dumpAmbigMsg(set *, FILE *, int);\r
+extern void GenRuleFuncRedefs(FILE *, Junction *);\r
+extern void GenPredefinedSymbolRedefs(FILE *);\r
+extern void GenASTSymbolRedefs(FILE *);\r
+extern void GenRemapFile(void);\r
+extern void GenSetRedefs(FILE *);\r
+extern ForcedToken *newForcedToken(char *, int);\r
+extern void RemapForcedTokens(void);\r
+extern char *TokenOrExpr(int);\r
+extern void setUpperRange(TokNode *, char *);\r
+extern void GenParser_c_Hdr(void);\r
+extern void GenParser_h_Hdr(void);\r
+extern void GenRuleMemberDeclarationsForCC(FILE *, Junction *);\r
+extern int addForcedTname( char *, int );\r
+extern char *OutMetaName(char *);\r
+extern void OutFirstSetSymbol(Junction *q, char *);                 /* MR21 */\r
+extern void warnNoFL(char *err);\r
+extern void warnFL(char *err,char *f,int l);\r
+extern void warn(char *err);\r
+extern void warnNoCR( char *err );\r
+extern void errNoFL(char *err);\r
+extern void errFL(char *err,char *f,int l);\r
+extern void err(char *err);\r
+extern void errNoCR( char *err );\r
+extern void genPredTree( Predicate *p, Node *j, int ,int);\r
+extern UserAction *newUserAction(char *);\r
+extern char *gate_symbol(char *name);\r
+extern char *makeAltID(int blockid, int altnum);\r
+extern void DumpRemainingTokSets(void);\r
+extern void DumpANSIFunctionArgDef(FILE *f, Junction *q, int bInit);  /* MR23 */\r
+extern void DumpFormals(FILE *, char *, int bInit);                   /* MR23 */\r
+extern char* hideDefaultArgs(const char* pdecl);                      /* MR22 VHS */\r
+extern Predicate *computePredFromContextGuard(Graph,int *msgDone);    /* MR21 */\r
+extern void recomputeContextGuard(Predicate *);                       /* MR13 */\r
+extern Predicate *new_pred(void);\r
+extern void chkGTFlag(void);\r
+extern void leAdd(LabelEntry *);                                     /* MR7 */\r
+extern void leFixup(void);                                           /* MR7 */\r
+extern void egAdd(ExceptionGroup *);                                 /* MR7 */\r
+extern void egFixup(void);                                           /* MR7 */\r
+extern void altAdd(Junction *);                                      /* MR7 */\r
+extern void altFixup(void);                                          /* MR7 */\r
+extern Predicate * MR_find_in_aSubBlk(Junction *alt);                /* MR10 */\r
+extern Predicate * MR_predFlatten(Predicate *p);                                    /* MR10 */\r
+extern Predicate * MR_predSimplifyALL(Predicate *p);                /* MR10 */\r
+extern Predicate * MR_predSimplifyALLX(Predicate *p,int skipPass3);  /* MR10 */\r
+extern int MR_allPredLeaves(Predicate *p);                           /* MR10 */\r
+extern void MR_cleanup_pred_trees(Predicate *p);                     /* MR10 */\r
+extern int MR_predicate_context_completed(Predicate *p);             /* MR10 */\r
+extern void MR_check_pred_too_long(Predicate *p,set completion);     /* MR10 */\r
+extern Tree * MR_remove_epsilon_from_tree(Tree *t);                  /* MR10 */\r
+extern Tree * MR_computeTreeAND(Tree *l,Tree *r);                                       /* MR10 */\r
+extern int MR_tree_equ(Tree *big, Tree *small);                                         /* MR10 */\r
+extern set MR_First(int ck,Junction *j,set *incomplete);                    /* MR10 */\r
+extern set MR_compute_pred_set(Predicate *p);                       /* MR10 */\r
+extern Tree * MR_compute_pred_tree_context(Predicate *p);           /* MR10 */\r
+extern int MR_pointerStackPush(PointerStack *,void *);               /* MR10 */\r
+extern void * MR_pointerStackPop(PointerStack *);                    /* MR10 */\r
+extern void * MR_pointerStackTop(PointerStack *);                    /* MR10 */\r
+extern void MR_pointerStackReset(PointerStack *);                    /* MR10 */\r
+extern void MR_backTraceReport(void);                                /* MR10 */\r
+extern void MR_alphaBetaTraceReport(void);                           /* MR14 */\r
+extern void MR_dumpRuleSet(set);                                     /* MR14 */\r
+extern void MR_predContextPresent(Predicate *p,int *,int *);         /* MR10 */\r
+extern void MR_dumpPred(Predicate *p,int withContext);               /* MR10 */\r
+extern void MR_dumpPred1(int,Predicate *p,int withContext);          /* MR10 */\r
+extern void MR_xxxIndent(FILE *f,int depth);                         /* MR11 */\r
+extern void MR_outputIndent(int depth);                              /* MR11 */\r
+extern void MR_stderrIndent(int depth);                              /* MR11 */\r
+extern Junction * MR_ruleReferenced(RuleRefNode *rrn);               /* MR10 */\r
+extern Junction * MR_nameToRuleBlk(char *);                          /* MR10 */\r
+extern void MR_releaseResourcesUsedInRule(Node *);                   /* MR10 */\r
+extern void MR_dumpTreeX(int depth,Tree *t,int across);              /* MR10 */\r
+extern void MR_dumpTreeF(FILE *f,int depth,Tree *t,int across);      /* MR10 */\r
+extern void DumpFcache(void);                                        /* MR10 */\r
+extern void MR_dumpTokenSet(FILE *f,int depth,set s);                /* MR10 */\r
+extern void MR_traceAmbSource(set *,Junction *,Junction *);          /* MR11 */\r
+extern void MR_traceAmbSourceK(Tree *,Junction *a1,Junction *a2);    /* MR11 */\r
+extern void MR_traceAmbSourceKclient(void);                          /* MR20 */\r
+extern Node *MR_advance(Node *);                                     /* MR11 */\r
+extern int  MR_offsetFromRule(Node *);                               /* MR11 */\r
+extern char *MR_ruleNamePlusOffset(Node *);                          /* MR11 */\r
+extern int  MR_max_height_of_tree(Tree *);                           /* MR11 */\r
+extern int  MR_all_leaves_same_height(Tree *,int);                   /* MR11 */\r
+extern void MR_projectTreeOntoSet(Tree *t,int k,set *);              /* MR11 */\r
+extern Tree *MR_make_tree_from_set(set);                             /* MR11 */\r
+extern Predicate *MR_removeRedundantPredPass3(Predicate *);          /* MR11 */\r
+extern void MR_pred_depth(Predicate *,int *);                        /* MR11 */\r
+extern int  MR_comparePredicates(Predicate *,Predicate *);           /* MR11 */\r
+extern Predicate * MR_unfold(Predicate *);                           /* MR11 */\r
+extern void MR_simplifyInverted(Predicate *,int);                    /* MR11 */\r
+extern int  MR_secondPredicateUnreachable                            /* MR11 */\r
+            (Predicate *first,Predicate *second);                    /* MR11 */\r
+extern void MR_clearPredEntry(Predicate *);                          /* MR11 */\r
+extern void MR_orphanRules(FILE *);                                  /* MR12 */\r
+extern void MR_merge_contexts(Tree *);                               /* MR12 */\r
+extern int  ci_strequ(char *,char *);                                 /* MR12 */\r
+extern void MR_guardPred_plainSet(ActionNode *anode,Predicate *);    /* MR12c */\r
+extern void MR_suppressSearchReport(void);                           /* MR12c */\r
+extern Predicate * MR_suppressK(Node *,Predicate *);                 /* MR13 */\r
+extern void MR_backTraceDumpItem(FILE *,int skip,Node *n);           /* MR13 */\r
+extern void MR_backTraceDumpItemReset(void);                         /* MR13 */\r
+extern Junction * MR_junctionWithoutP2(Junction *);                  /* MR13 */\r
+extern void MR_setConstrainPointer(set *);                                                      /* MR18 */\r
+extern void BlockPreambleOption(Junction *q, char * pSymbol);        /* MR23 */\r
+extern char* getInitializer(char *);                                 /* MR23 */\r
+extern char *endFormal(char *pStart,                                 /* MR23 */\r
+                                          char **ppDataType,                            /* MR23 */\r
+                                          char **ppSymbol,                              /* MR23 */\r
+                                          char **ppEqualSign,                           /* MR23 */\r
+                                          char **ppValue,                               /* MR23 */\r
+                                          char **ppSeparator,                           /* MR23 */\r
+                                          int *pNext);                                  /* MR23 */\r
+extern char *strBetween(char *pStart,                                /* MR23 */\r
+                                               char *pNext,                                 /* MR23 */\r
+                                               char *pStop);                                /* MR23 */\r
+extern int hasMultipleOperands(char *);                              /* MR23 */\r
+extern void DumpInitializers(FILE*, RuleEntry*, char*);              /* MR23 */\r
+extern int isTermEntryTokClass(TermEntry *);                                            /* MR23 */\r
+extern int isEmptyAlt(Node *, Node *);                               /* MR23 */\r
+#else\r
+extern int STRICMP();\r
+extern void istackreset();\r
+extern int istacksize();\r
+extern void pushint();\r
+extern int popint();\r
+extern int istackempty();\r
+extern int topint();\r
+extern void NewSetWd();\r
+extern void DumpSetWd();\r
+extern void DumpSetWdForC();\r
+extern void DumpSetWdForCC();\r
+extern void NewSet();\r
+extern void FillSet();\r
+extern void ComputeErrorSets();\r
+extern void ComputeTokSets();\r
+extern void SubstErrorClass();\r
+extern int DefErrSet();\r
+extern int DefErrSetForC();\r
+extern int DefErrSetForCC();\r
+extern int DefErrSet1();\r
+extern int DefErrSetForC1();\r
+extern int DefErrSetForCC1();\r
+extern int DefErrSetWithSuffix();                                   /* MR21 */\r
+extern void GenErrHdr();\r
+extern void dumpExpr();\r
+extern void addParm();\r
+extern Graph buildAction();\r
+extern Graph buildToken();\r
+extern Graph buildWildCard();\r
+extern Graph buildRuleRef();\r
+extern Graph Or();\r
+extern Graph Cat();\r
+extern Graph makeOpt();\r
+extern Graph makeBlk();\r
+extern Graph makeLoop();\r
+extern Graph makePlus();\r
+extern Graph emptyAlt();\r
+extern Graph emptyAlt3();\r
+extern TokNode * newTokNode();\r
+extern RuleRefNode * newRNode();\r
+extern Junction * newJunction();\r
+extern ActionNode * newActionNode();\r
+extern char * makelocks();\r
+extern void preorder();\r
+extern Tree * tnode();\r
+extern void _Tfree();\r
+extern Tree * tdup();\r
+extern int is_single_tuple();\r
+extern Tree * tappend();\r
+extern void Tfree();\r
+extern Tree * tlink();\r
+extern Tree * tshrink();\r
+extern Tree * tflatten();\r
+extern Tree * tJunc();\r
+extern Tree * tRuleRef();\r
+extern Tree * tToken();\r
+extern Tree * tAction();\r
+extern int tmember();\r
+extern int tmember_constrained();\r
+extern Tree * tleft_factor();\r
+extern Tree * trm_perm();\r
+extern void tcvt();\r
+extern Tree * permute();\r
+extern Tree * VerifyAmbig();\r
+extern set rJunc();\r
+extern set rRuleRef();\r
+extern set rToken();\r
+extern set rAction();\r
+extern void HandleAmbiguity();\r
+extern set First();\r
+extern void freeBlkFsets();\r
+extern void genAction();\r
+extern void genRuleRef();\r
+extern void genToken();\r
+extern void genOptBlk();\r
+extern void genLoopBlk();\r
+extern void genLoopBegin();\r
+extern void genPlusBlk();\r
+extern void genSubBlk();\r
+extern void genRule();\r
+extern void genJunction();\r
+extern void genEndBlk();\r
+extern void genEndRule();\r
+extern void genHdr();\r
+extern void genHdr1();\r
+extern void dumpAction();\r
+extern void dumpActionPlus();                           /* MR21 */\r
+extern Entry ** newHashTable();\r
+extern Entry * hash_add();\r
+extern Entry * hash_get();\r
+extern void hashStat();\r
+extern char * mystrdup();\r
+extern void genLexDescr();\r
+extern void dumpLexClasses();\r
+extern void genDefFile();\r
+extern void DumpListOfParmNames();                    /* MR5 janm 26-May-97 */\r
+extern int DumpNextNameInDef();\r
+extern void DumpOldStyleParms();\r
+extern void DumpType();\r
+extern int strmember();\r
+/* extern int HasComma(); MR23 Replaced by hasMultipleOperands() */\r
+extern void DumpRetValStruct();\r
+extern char * StripQuotes();\r
+extern int main();\r
+extern void readDescr();\r
+extern FILE * NextFile();\r
+extern char * outnameX();\r
+extern char * outname();\r
+extern void fatalFL();\r
+extern void fatal_intern();\r
+extern void cleanUp();\r
+extern char * eMsg3();\r
+extern char * eMsgd();\r
+extern char * eMsgd2();\r
+extern void s_fprT();\r
+extern char * TerminalString();\r
+extern void lexclass();\r
+extern void lexmode();\r
+extern int LexClassIndex();\r
+extern int hasAction();\r
+extern void setHasAction();\r
+extern int addTname();\r
+extern int addTexpr();\r
+extern int Tnum();\r
+extern void Tklink();\r
+extern Entry * newEntry();\r
+extern void list_add();\r
+extern void list_free();                /* MR10 */\r
+extern void list_apply();\r
+extern int list_search_cstring ();      /* MR27 */\r
+extern char * Fkey();\r
+extern void FoPush();\r
+extern void FoPop();\r
+extern void RegisterCycle();\r
+extern void ResolveFoCycles();\r
+extern void pJunc();\r
+extern void pRuleRef();\r
+extern void pToken();\r
+extern void pAction();\r
+extern void FoLink();\r
+extern void addFoLink();\r
+extern void GenCrossRef();\r
+extern void defErr();\r
+extern void genStdPCCTSIncludeFile();\r
+extern char * pcctsBaseName();                                /* MR32 */\r
+extern Predicate *find_predicates();\r
+extern Predicate *MR_find_predicates_and_supp();              /* MR13 */\r
+extern int predicateLookaheadDepth();                         /* MR10 */\r
+extern void predicate_free();                                 /* MR10 */\r
+extern Predicate * predicate_dup();                           /* MR10 */\r
+extern Predicate * predicate_dup_without_context();           /* MR11 */\r
+extern void GenRulePrototypes();\r
+extern Junction *first_item_is_guess_block();\r
+extern Junction *first_item_is_guess_block_extra();                      /* MR30 */\r
+extern Junction *analysis_point();\r
+extern Tree *make_tree_from_sets();\r
+extern Tree *tdup_chain();\r
+extern Tree *tdif();\r
+extern set covered_set();\r
+extern void AmbiguityDialog();\r
+extern void dumpAmbigMsg();\r
+extern void GenRuleFuncRedefs();\r
+extern void GenPredefinedSymbolRedefs();\r
+extern void GenASTSymbolRedefs();\r
+extern void GenRemapFile();\r
+extern void GenSetRedefs();\r
+extern ForcedToken *newForcedToken();\r
+extern void RemapForcedTokens();\r
+extern char *TokenOrExpr();\r
+extern void setUpperRange();\r
+extern void GenParser_c_Hdr();\r
+extern void GenParser_h_Hdr();\r
+extern void GenRuleMemberDeclarationsForCC();\r
+extern int addForcedTname();\r
+extern char *OutMetaName();\r
+extern void OutFirstSetSymbol();                            /* MR21 */\r
+extern void warnNoFL();\r
+extern void warnFL();\r
+extern void warn();\r
+extern void warnNoCR();\r
+extern void errNoFL();\r
+extern void errFL();\r
+extern void err();\r
+extern void errNoCR();\r
+extern void genPredTree();\r
+extern UserAction *newUserAction();\r
+extern char *gate_symbol();\r
+extern char *makeAltID();\r
+extern void DumpRemainingTokSets();\r
+extern void DumpANSIFunctionArgDef();\r
+extern void DumpFormals();                                           /* MR23 */\r
+extern char* hideDefaultArgs();                                      /* MR22 VHS */\r
+extern Predicate *computePredFromContextGuard();\r
+extern void recomputeContextGuard();                                 /* MR13 */\r
+extern Predicate *new_pred();\r
+extern void chkGTFlag();\r
+extern void leAdd();                                                 /* MR7 */\r
+extern void leFixup();                                               /* MR7 */\r
+extern void egAdd();                                                 /* MR7 */\r
+extern void egFixup();                                               /* MR7 */\r
+extern void altAdd();                                                /* MR7 */\r
+extern void altFixup();                                              /* MR7 */\r
+extern Predicate * MR_find_in_aSubBlk();                                       /* MR10 */\r
+extern Predicate * MR_predFlatten();                                                   /* MR10 */\r
+extern Predicate * MR_predSimplifyALL();                            /* MR10 */\r
+extern Predicate * MR_predSimplifyALLX();                           /* MR10 */\r
+extern void MR_cleanup_pred_trees();                                /* MR10 */\r
+extern int MR_allPredLeaves();                                      /* MR10 */\r
+extern int MR_predicate_context_completed();                        /* MR10 */\r
+extern void MR_check_pred_too_long();                               /* MR10 */\r
+extern Tree * MR_remove_epsilon_from_tree();                                   /* MR10 */\r
+extern Tree * MR_computeTreeAND();                                                     /* MR10 */\r
+extern int MR_tree_equ();                                                      /* MR10 */\r
+extern set MR_First();                                                         /* MR10 */\r
+extern set MR_compute_pred_set();                                                  /* MR10 */\r
+extern Tree * MR_compute_pred_tree_context();                                  /* MR10 */\r
+extern int MR_pointerStackPush();                                   /* MR10 */\r
+extern void * MR_pointerStackPop();                                 /* MR10 */\r
+extern void * MR_pointerStackTop();                                 /* MR10 */\r
+extern void MR_pointerStackReset();                                 /* MR10 */\r
+extern void MR_backTraceReport();                                   /* MR10 */\r
+extern void MR_alphaBetaTraceReport();                              /* MR14 */\r
+extern void MR_dumpRuleSet();                                       /* MR14 */\r
+extern void MR_predContextPresent();                                /* MR10 */\r
+extern void MR_dumpPred();                                          /* MR10 */\r
+extern void MR_dumpPred1();                                         /* MR10 */\r
+extern void MR_xxxIndent();                                         /* MR11 */\r
+extern void MR_stderrIndent();                                      /* MR11 */\r
+extern void MR_outputIndent();                                      /* MR11 */\r
+extern Junction * MR_ruleReferenced();                              /* MR10 */\r
+extern void MR_releaseResourcesUsedInRule();                        /* MR10 */\r
+extern void MR_dumpTreeX();                                         /* MR10 */\r
+extern void MR_dumpTreeF();                                         /* MR10 */\r
+extern void DumpFcache();                                           /* MR10 */\r
+extern void MR_dumpTokenSet();                                      /* MR10 */\r
+extern void MR_traceAmbSource();                                    /* MR11 */\r
+extern Node *MR_advance();                                          /* MR11 */\r
+extern int  MR_offsetFromRule();                                    /* MR11 */\r
+extern char *MR_ruleNamePlusOffset();                               /* MR11 */\r
+extern void MR_traceAmbSourceK();                                   /* MR11 */\r
+extern void MR_traceAmbSourceKclient();                             /* [i_a] added */\r
+extern int  MR_max_height_of_tree();                                /* MR11 */\r
+extern int  MR_all_leaves_same_height();                            /* MR11 */\r
+extern void MR_projectTreeOntoSet();                                /* MR11 */\r
+extern Tree *MR_make_tree_from_set();                               /* MR11 */\r
+extern Predicate *MR_removeRedundantPredPass3();                    /* MR11 */\r
+extern void MR_pred_depth();                                        /* MR11 */\r
+extern int  MR_comparePredicates();                                 /* MR11 */\r
+extern Predicate * MR_unfold();                                     /* MR11 */\r
+extern void MR_simplifyInverted();                                  /* MR11 */\r
+extern int  MR_secondPredicateUnreachable();                        /* MR11 */\r
+extern Junction * MR_nameToRuleBlk();                               /* MR10 */\r
+extern void MR_clearPredEntry();                                    /* MR11 */\r
+extern void MR_orphanRules();                                       /* MR12 */\r
+extern void MR_merge_contexts();                                    /* MR12 */\r
+extern int ci_strequ();                                             /* MR12 */\r
+extern void MR_guardPred_plainSet();                                /* MR12c */\r
+extern void MR_suppressSearchReport();                              /* MR12c */\r
+extern Predicate * MR_suppressK();                                  /* MR13 */\r
+extern void MR_backTraceDumpItem();                                 /* MR13 */\r
+extern void MR_backTraceDumpItemReset();                            /* MR13 */\r
+extern Junction * MR_junctionWithoutP2();                           /* MR13 */\r
+extern void MR_setConstrainPointer();                                                      /* MR18 */\r
+extern void BlockPreambleOption();                                  /* MR23 */\r
+extern char* getInitializer();                                      /* MR23 */\r
+extern int hasMultipleOperands();                                   /* MR23 */\r
+extern char *endFormal();                                           /* MR23 */\r
+extern char *strBetween();                                          /* MR23 */\r
+extern void DumpInitializers();                                     /* MR23 */\r
+extern int isTermEntryTokClass();                                                                  /* MR23 */\r
+extern int isEmptyAlt();\r
+\r
+#endif\r
+\r
+#ifdef __USE_PROTOS\r
+#include <stdlib.h>\r
+#endif\r
+\r
+/* MR20 G. Hobbelt  Create proper externs for dlg variables */\r
+\r
+extern set attribsRefdFromAction;\r
+extern int inAlt;\r
+extern int UsedOldStyleAttrib;\r
+extern int UsedNewStyleLabel;\r
+\r
+#define MAX_BLK_LEVEL 100                       /* MR23 */\r
+extern int     CurBlockID_array[MAX_BLK_LEVEL]; /* MR23 */\r
+extern int     CurAltNum_array[MAX_BLK_LEVEL];  /* MR23 */\r
diff --git a/Tools/CodeTools/Source/Pccts/antlr/scan.c b/Tools/CodeTools/Source/Pccts/antlr/scan.c
new file mode 100644 (file)
index 0000000..9b4bde0
--- /dev/null
@@ -0,0 +1,5735 @@
+\r
+/* parser.dlg -- DLG Description of scanner\r
+ *\r
+ * Generated from: antlr.g\r
+ *\r
+ * Terence Parr, Will Cohen, and Hank Dietz: 1989-2001\r
+ * Purdue University Electrical Engineering\r
+ * With AHPCRC, University of Minnesota\r
+ * ANTLR Version 1.33MR33\r
+ */\r
+\r
+#define ANTLR_VERSION  13333\r
+#include "pcctscfg.h"\r
+#include "pccts_stdio.h"\r
+\r
+#include "pcctscfg.h"\r
+#include "set.h"\r
+#include <ctype.h>\r
+#include "syn.h"\r
+#include "hash.h"\r
+#include "generic.h"\r
+#define zzcr_attr(attr,tok,t)\r
+#include "antlr.h"\r
+#include "tokens.h"\r
+#include "dlgdef.h"\r
+LOOKAHEAD\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+zzerraction(void)\r
+#else\r
+zzerraction()\r
+#endif\r
+{\r
+       (*zzerr)("invalid token");\r
+       zzadvance();\r
+       zzskip();\r
+}\r
+/*\r
+ * D L G tables\r
+ *\r
+ * Generated from: parser.dlg\r
+ *\r
+ * 1989-2001 by  Will Cohen, Terence Parr, and Hank Dietz\r
+ * Purdue University Electrical Engineering\r
+ * DLG Version 1.33MR33\r
+ */\r
+\r
+#include "mode.h"\r
+\r
+\r
+\r
+\r
+/* maintained, but not used for now */\r
+set AST_nodes_refd_in_actions = set_init;\r
+int inAlt = 0;\r
+set attribsRefdFromAction = set_init; /* MR20 */\r
+int UsedOldStyleAttrib = 0;\r
+int UsedNewStyleLabel = 0;\r
+#ifdef __USE_PROTOS\r
+char *inline_set(char *);\r
+#else\r
+char *inline_set();\r
+#endif\r
+\r
+/* MR1 10-Apr-97  MR1  Previously unable to put right shift operator       */\r
+/* MR1                                 in DLG action                                       */\r
+\r
+int tokenActionActive=0;                                            /* MR1 */\r
+\r
+  \r
+\r
+\r
+\r
+static char *\r
+#ifdef __USE_PROTOS\r
+getFileNameFromTheLineInfo(char *toStr, char *fromStr)\r
+#else\r
+getFileNameFromTheLineInfo(toStr, fromStr)\r
+char *toStr, *fromStr;\r
+#endif\r
+{\r
+  int i, j, k;\r
+  \r
+  if (!fromStr || !toStr) return toStr;\r
+  \r
+  /* find the first " */\r
+  \r
+  for (i=0;\r
+  (i<MaxFileName) &&\r
+  (fromStr[i] != '\n') &&\r
+  (fromStr[i] != '\r') &&\r
+  (fromStr[i] != '\"');\r
+  i++) /* nothing */ ;\r
+  \r
+  if ( (i == MaxFileName) ||\r
+  (fromStr[i] == '\n') ||\r
+  (fromStr[i] == '\r') ) {\r
+  return toStr;\r
+}\r
+\r
+  /* find the second " */\r
+\r
+  for (j=i+1;\r
+(j<MaxFileName) &&\r
+(fromStr[j] != '\n') &&\r
+(fromStr[j] != '\r') &&\r
+(fromStr[j] != '\"');\r
+j++) /* nothing */ ;\r
+\r
+  if ((j == MaxFileName) ||\r
+(fromStr[j] == '\n') ||\r
+(fromStr[j] == '\r') ) {\r
+  return toStr;\r
+}\r
+\r
+  /* go back until the last / or \ */\r
+\r
+  for (k=j-1;\r
+(fromStr[k] != '\"') &&\r
+(fromStr[k] != '/') &&\r
+(fromStr[k] != '\\');\r
+k--) /* nothing */ ;\r
+\r
+  /* copy the string after " / or \ into toStr */\r
+\r
+  for (i=k+1; fromStr[i] != '\"'; i++) {\r
+toStr[i-k-1] = fromStr[i];\r
+}\r
+\r
+  toStr[i-k-1] = '\0';\r
+\r
+  return toStr;\r
+}\r
+\r
+/* MR14 end of a block to support #line in antlr source code */\r
+\r
+  \r
+\r
+\r
+#ifdef __USE_PROTOS\r
+void mark_label_used_in_sem_pred(LabelEntry *le)              /* MR10 */\r
+#else\r
+void mark_label_used_in_sem_pred(le)                          /* MR10 */\r
+LabelEntry    *le;\r
+#endif\r
+{\r
+  TokNode   *tn;\r
+  require (le->elem->ntype == nToken,"mark_label_used... ntype != nToken");\r
+  tn=(TokNode *)le->elem;\r
+  require (tn->label != 0,"mark_label_used... TokNode has no label");\r
+  tn->label_used_in_semantic_pred=1;\r
+}\r
+\r
+static void act1()\r
+{ \r
+               NLA = Eof;\r
+    /* L o o k  F o r  A n o t h e r  F i l e */\r
+    {\r
+      FILE *new_input;\r
+      new_input = NextFile();\r
+      if ( new_input == NULL ) { NLA=Eof; return; }\r
+      fclose( input );\r
+      input = new_input;\r
+      zzrdstream( input );\r
+      zzskip();        /* Skip the Eof (@) char i.e continue */\r
+    }\r
+       }\r
+\r
+\r
+static void act2()\r
+{ \r
+               NLA = 76;\r
+    zzskip();   \r
+       }\r
+\r
+\r
+static void act3()\r
+{ \r
+               NLA = 77;\r
+    zzline++; zzskip();   \r
+       }\r
+\r
+\r
+static void act4()\r
+{ \r
+               NLA = 78;\r
+    zzmode(ACTIONS); zzmore();\r
+    istackreset();\r
+    pushint(']');   \r
+       }\r
+\r
+\r
+static void act5()\r
+{ \r
+               NLA = 79;\r
+    action_file=CurFile; action_line=zzline;\r
+    zzmode(ACTIONS); zzmore();\r
+    list_free(&CurActionLabels,0);       /* MR10 */\r
+    numericActionLabel=0;                /* MR10 */\r
+    istackreset();\r
+    pushint('>');   \r
+       }\r
+\r
+\r
+static void act6()\r
+{ \r
+               NLA = 80;\r
+    zzmode(STRINGS); zzmore();   \r
+       }\r
+\r
+\r
+static void act7()\r
+{ \r
+               NLA = 81;\r
+    zzmode(COMMENTS); zzskip();   \r
+       }\r
+\r
+\r
+static void act8()\r
+{ \r
+               NLA = 82;\r
+    warn("Missing /*; found dangling */"); zzskip();   \r
+       }\r
+\r
+\r
+static void act9()\r
+{ \r
+               NLA = 83;\r
+    zzmode(CPP_COMMENTS); zzskip();   \r
+       }\r
+\r
+\r
+static void act10()\r
+{ \r
+               NLA = 84;\r
+    \r
+    zzline = atoi(zzbegexpr+5) - 1; zzline++; zzmore();\r
+    getFileNameFromTheLineInfo(FileStr[CurFile], zzbegexpr);\r
+       }\r
+\r
+\r
+static void act11()\r
+{ \r
+               NLA = 85;\r
+    \r
+    zzline++; zzmore();\r
+       }\r
+\r
+\r
+static void act12()\r
+{ \r
+               NLA = 86;\r
+    warn("Missing <<; found dangling >>"); zzskip();   \r
+       }\r
+\r
+\r
+static void act13()\r
+{ \r
+               NLA = WildCard;\r
+       }\r
+\r
+\r
+static void act14()\r
+{ \r
+               NLA = 88;\r
+    FoundException = 1;                /* MR6 */\r
+    FoundAtOperator = 1;  \r
+       }\r
+\r
+\r
+static void act15()\r
+{ \r
+               NLA = Pragma;\r
+       }\r
+\r
+\r
+static void act16()\r
+{ \r
+               NLA = FirstSetSymbol;\r
+       }\r
+\r
+\r
+static void act17()\r
+{ \r
+               NLA = 94;\r
+       }\r
+\r
+\r
+static void act18()\r
+{ \r
+               NLA = 95;\r
+       }\r
+\r
+\r
+static void act19()\r
+{ \r
+               NLA = 96;\r
+       }\r
+\r
+\r
+static void act20()\r
+{ \r
+               NLA = 97;\r
+       }\r
+\r
+\r
+static void act21()\r
+{ \r
+               NLA = 98;\r
+       }\r
+\r
+\r
+static void act22()\r
+{ \r
+               NLA = 99;\r
+       }\r
+\r
+\r
+static void act23()\r
+{ \r
+               NLA = 102;\r
+       }\r
+\r
+\r
+static void act24()\r
+{ \r
+               NLA = 103;\r
+       }\r
+\r
+\r
+static void act25()\r
+{ \r
+               NLA = 104;\r
+       }\r
+\r
+\r
+static void act26()\r
+{ \r
+               NLA = 105;\r
+       }\r
+\r
+\r
+static void act27()\r
+{ \r
+               NLA = 106;\r
+       }\r
+\r
+\r
+static void act28()\r
+{ \r
+               NLA = 107;\r
+       }\r
+\r
+\r
+static void act29()\r
+{ \r
+               NLA = 108;\r
+       }\r
+\r
+\r
+static void act30()\r
+{ \r
+               NLA = 109;\r
+       }\r
+\r
+\r
+static void act31()\r
+{ \r
+               NLA = 110;\r
+       }\r
+\r
+\r
+static void act32()\r
+{ \r
+               NLA = 111;\r
+       }\r
+\r
+\r
+static void act33()\r
+{ \r
+               NLA = 112;\r
+       }\r
+\r
+\r
+static void act34()\r
+{ \r
+               NLA = 113;\r
+       }\r
+\r
+\r
+static void act35()\r
+{ \r
+               NLA = 114;\r
+       }\r
+\r
+\r
+static void act36()\r
+{ \r
+               NLA = 115;\r
+       }\r
+\r
+\r
+static void act37()\r
+{ \r
+               NLA = 116;\r
+       }\r
+\r
+\r
+static void act38()\r
+{ \r
+               NLA = 117;\r
+       }\r
+\r
+\r
+static void act39()\r
+{ \r
+               NLA = 118;\r
+       }\r
+\r
+\r
+static void act40()\r
+{ \r
+               NLA = 119;\r
+       }\r
+\r
+\r
+static void act41()\r
+{ \r
+               NLA = 120;\r
+       }\r
+\r
+\r
+static void act42()\r
+{ \r
+               NLA = 121;\r
+       }\r
+\r
+\r
+static void act43()\r
+{ \r
+               NLA = 122;\r
+       }\r
+\r
+\r
+static void act44()\r
+{ \r
+               NLA = 123;\r
+       }\r
+\r
+\r
+static void act45()\r
+{ \r
+               NLA = 124;\r
+       }\r
+\r
+\r
+static void act46()\r
+{ \r
+               NLA = 125;\r
+       }\r
+\r
+\r
+static void act47()\r
+{ \r
+               NLA = 126;\r
+       }\r
+\r
+\r
+static void act48()\r
+{ \r
+               NLA = 127;\r
+       }\r
+\r
+\r
+static void act49()\r
+{ \r
+               NLA = 128;\r
+       }\r
+\r
+\r
+static void act50()\r
+{ \r
+               NLA = 129;\r
+       }\r
+\r
+\r
+static void act51()\r
+{ \r
+               NLA = 130;\r
+       }\r
+\r
+\r
+static void act52()\r
+{ \r
+               NLA = 131;\r
+       }\r
+\r
+\r
+static void act53()\r
+{ \r
+               NLA = 132;\r
+       }\r
+\r
+\r
+static void act54()\r
+{ \r
+               NLA = 133;\r
+       }\r
+\r
+\r
+static void act55()\r
+{ \r
+               NLA = 134;\r
+       }\r
+\r
+\r
+static void act56()\r
+{ \r
+               NLA = 135;\r
+       }\r
+\r
+\r
+static void act57()\r
+{ \r
+               NLA = NonTerminal;\r
+    \r
+    while ( zzchar==' ' || zzchar=='\t' ) {\r
+      zzadvance();\r
+    }\r
+    if ( zzchar == ':' && inAlt ) NLA = LABEL;\r
+       }\r
+\r
+\r
+static void act58()\r
+{ \r
+               NLA = TokenTerm;\r
+    \r
+    while ( zzchar==' ' || zzchar=='\t' ) {\r
+      zzadvance();\r
+    }\r
+    if ( zzchar == ':' && inAlt ) NLA = LABEL;\r
+       }\r
+\r
+\r
+static void act59()\r
+{ \r
+               NLA = 136;\r
+    warn(eMsg1("unknown meta-op: %s",LATEXT(1))); zzskip();   \r
+       }\r
+\r
+static unsigned char shift0[257] = {\r
+  0, 58, 58, 58, 58, 58, 58, 58, 58, 58, \r
+  1, 2, 58, 58, 3, 58, 58, 58, 58, 58, \r
+  58, 58, 58, 58, 58, 58, 58, 58, 58, 58, \r
+  58, 58, 58, 1, 40, 6, 9, 58, 58, 45, \r
+  58, 46, 47, 8, 52, 58, 58, 18, 7, 16, \r
+  14, 15, 16, 16, 16, 16, 16, 16, 16, 41, \r
+  42, 5, 48, 17, 53, 19, 56, 56, 56, 56, \r
+  56, 26, 56, 56, 56, 56, 56, 51, 56, 56, \r
+  56, 56, 56, 56, 29, 56, 56, 56, 56, 56, \r
+  56, 56, 4, 20, 58, 50, 57, 58, 23, 31, \r
+  38, 34, 13, 35, 24, 33, 11, 55, 36, 10, \r
+  25, 12, 32, 21, 55, 22, 27, 28, 54, 55, \r
+  55, 43, 30, 55, 39, 44, 37, 49, 58, 58, \r
+  58, 58, 58, 58, 58, 58, 58, 58, 58, 58, \r
+  58, 58, 58, 58, 58, 58, 58, 58, 58, 58, \r
+  58, 58, 58, 58, 58, 58, 58, 58, 58, 58, \r
+  58, 58, 58, 58, 58, 58, 58, 58, 58, 58, \r
+  58, 58, 58, 58, 58, 58, 58, 58, 58, 58, \r
+  58, 58, 58, 58, 58, 58, 58, 58, 58, 58, \r
+  58, 58, 58, 58, 58, 58, 58, 58, 58, 58, \r
+  58, 58, 58, 58, 58, 58, 58, 58, 58, 58, \r
+  58, 58, 58, 58, 58, 58, 58, 58, 58, 58, \r
+  58, 58, 58, 58, 58, 58, 58, 58, 58, 58, \r
+  58, 58, 58, 58, 58, 58, 58, 58, 58, 58, \r
+  58, 58, 58, 58, 58, 58, 58, 58, 58, 58, \r
+  58, 58, 58, 58, 58, 58, 58\r
+};\r
+\r
+\r
+static void act60()\r
+{ \r
+               NLA = Eof;\r
+       }\r
+\r
+\r
+static void act61()\r
+{ \r
+               NLA = QuotedTerm;\r
+    zzmode(START);   \r
+       }\r
+\r
+\r
+static void act62()\r
+{ \r
+               NLA = 3;\r
+    \r
+    zzline++;\r
+    warn("eoln found in string");\r
+    zzskip();\r
+       }\r
+\r
+\r
+static void act63()\r
+{ \r
+               NLA = 4;\r
+    zzline++; zzmore();   \r
+       }\r
+\r
+\r
+static void act64()\r
+{ \r
+               NLA = 5;\r
+    zzmore();   \r
+       }\r
+\r
+\r
+static void act65()\r
+{ \r
+               NLA = 6;\r
+    zzmore();   \r
+       }\r
+\r
+static unsigned char shift1[257] = {\r
+  0, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 2, 5, 5, 3, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 1, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 4, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5\r
+};\r
+\r
+\r
+static void act66()\r
+{ \r
+               NLA = Eof;\r
+       }\r
+\r
+\r
+static void act67()\r
+{ \r
+               NLA = 7;\r
+    zzmode(ACTIONS); zzmore();   \r
+       }\r
+\r
+\r
+static void act68()\r
+{ \r
+               NLA = 8;\r
+    \r
+    zzline++;\r
+    warn("eoln found in string (in user action)");\r
+    zzskip();\r
+       }\r
+\r
+\r
+static void act69()\r
+{ \r
+               NLA = 9;\r
+    zzline++; zzmore();   \r
+       }\r
+\r
+\r
+static void act70()\r
+{ \r
+               NLA = 10;\r
+    zzmore();   \r
+       }\r
+\r
+\r
+static void act71()\r
+{ \r
+               NLA = 11;\r
+    zzmore();   \r
+       }\r
+\r
+static unsigned char shift2[257] = {\r
+  0, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 2, 5, 5, 3, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 1, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 4, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5\r
+};\r
+\r
+\r
+static void act72()\r
+{ \r
+               NLA = Eof;\r
+       }\r
+\r
+\r
+static void act73()\r
+{ \r
+               NLA = 12;\r
+    zzmode(ACTIONS); zzmore();   \r
+       }\r
+\r
+\r
+static void act74()\r
+{ \r
+               NLA = 13;\r
+    \r
+    zzline++;\r
+    warn("eoln found in char literal (in user action)");\r
+    zzskip();\r
+       }\r
+\r
+\r
+static void act75()\r
+{ \r
+               NLA = 14;\r
+    zzmore();   \r
+       }\r
+\r
+\r
+static void act76()\r
+{ \r
+               NLA = 15;\r
+    zzmore();   \r
+       }\r
+\r
+static unsigned char shift3[257] = {\r
+  0, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 2, 5, 5, 3, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  1, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 4, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5\r
+};\r
+\r
+\r
+static void act77()\r
+{ \r
+               NLA = Eof;\r
+       }\r
+\r
+\r
+static void act78()\r
+{ \r
+               NLA = 16;\r
+    zzmode(ACTIONS); zzmore();   \r
+       }\r
+\r
+\r
+static void act79()\r
+{ \r
+               NLA = 17;\r
+    zzmore();   \r
+       }\r
+\r
+\r
+static void act80()\r
+{ \r
+               NLA = 18;\r
+    zzline++; zzmore(); DAWDLE;   \r
+       }\r
+\r
+\r
+static void act81()\r
+{ \r
+               NLA = 19;\r
+    zzmore();   \r
+       }\r
+\r
+static unsigned char shift4[257] = {\r
+  0, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 3, 5, 5, 4, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 1, 5, 5, 5, 5, 2, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5\r
+};\r
+\r
+\r
+static void act82()\r
+{ \r
+               NLA = Eof;\r
+       }\r
+\r
+\r
+static void act83()\r
+{ \r
+               NLA = 20;\r
+    zzmode(PARSE_ENUM_FILE);\r
+    zzmore();   \r
+       }\r
+\r
+\r
+static void act84()\r
+{ \r
+               NLA = 21;\r
+    zzmore();   \r
+       }\r
+\r
+\r
+static void act85()\r
+{ \r
+               NLA = 22;\r
+    zzline++; zzmore(); DAWDLE;   \r
+       }\r
+\r
+\r
+static void act86()\r
+{ \r
+               NLA = 23;\r
+    zzmore();   \r
+       }\r
+\r
+static unsigned char shift5[257] = {\r
+  0, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 3, 5, 5, 4, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 1, 5, 5, 5, 5, 2, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5\r
+};\r
+\r
+\r
+static void act87()\r
+{ \r
+               NLA = Eof;\r
+       }\r
+\r
+\r
+static void act88()\r
+{ \r
+               NLA = 24;\r
+    zzline++; zzmode(PARSE_ENUM_FILE); zzskip(); DAWDLE;   \r
+       }\r
+\r
+\r
+static void act89()\r
+{ \r
+               NLA = 25;\r
+    zzskip();   \r
+       }\r
+\r
+static unsigned char shift6[257] = {\r
+  0, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
+  3, 1, 3, 3, 2, 3, 3, 3, 3, 3, \r
+  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
+  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
+  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
+  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
+  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
+  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
+  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
+  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
+  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
+  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
+  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
+  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
+  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
+  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
+  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
+  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
+  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
+  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
+  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
+  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
+  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
+  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
+  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
+  3, 3, 3, 3, 3, 3, 3\r
+};\r
+\r
+\r
+static void act90()\r
+{ \r
+               NLA = Eof;\r
+       }\r
+\r
+\r
+static void act91()\r
+{ \r
+               NLA = 26;\r
+    zzline++; zzmode(ACTIONS); zzmore(); DAWDLE;   \r
+       }\r
+\r
+\r
+static void act92()\r
+{ \r
+               NLA = 27;\r
+    zzmore();   \r
+       }\r
+\r
+static unsigned char shift7[257] = {\r
+  0, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
+  3, 1, 3, 3, 2, 3, 3, 3, 3, 3, \r
+  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
+  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
+  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
+  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
+  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
+  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
+  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
+  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
+  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
+  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
+  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
+  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
+  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
+  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
+  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
+  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
+  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
+  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
+  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
+  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
+  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
+  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
+  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
+  3, 3, 3, 3, 3, 3, 3\r
+};\r
+\r
+\r
+static void act93()\r
+{ \r
+               NLA = Eof;\r
+       }\r
+\r
+\r
+static void act94()\r
+{ \r
+               NLA = 28;\r
+    zzline++; zzmode(START); zzskip(); DAWDLE;   \r
+       }\r
+\r
+\r
+static void act95()\r
+{ \r
+               NLA = 29;\r
+    zzskip();   \r
+       }\r
+\r
+static unsigned char shift8[257] = {\r
+  0, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
+  3, 1, 3, 3, 2, 3, 3, 3, 3, 3, \r
+  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
+  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
+  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
+  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
+  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
+  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
+  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
+  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
+  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
+  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
+  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
+  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
+  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
+  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
+  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
+  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
+  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
+  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
+  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
+  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
+  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
+  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
+  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
+  3, 3, 3, 3, 3, 3, 3\r
+};\r
+\r
+\r
+static void act96()\r
+{ \r
+               NLA = Eof;\r
+       }\r
+\r
+\r
+static void act97()\r
+{ \r
+               NLA = 30;\r
+    zzmode(START); zzskip();   \r
+       }\r
+\r
+\r
+static void act98()\r
+{ \r
+               NLA = 31;\r
+    zzskip();   \r
+       }\r
+\r
+\r
+static void act99()\r
+{ \r
+               NLA = 32;\r
+    zzline++; zzskip(); DAWDLE;   \r
+       }\r
+\r
+\r
+static void act100()\r
+{ \r
+               NLA = 33;\r
+    zzskip();   \r
+       }\r
+\r
+static unsigned char shift9[257] = {\r
+  0, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 3, 5, 5, 4, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 1, 5, 5, 5, 5, 2, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
+  5, 5, 5, 5, 5, 5, 5\r
+};\r
+\r
+\r
+static void act101()\r
+{ \r
+               NLA = Eof;\r
+       }\r
+\r
+\r
+static void act102()\r
+{ \r
+               NLA = Action;\r
+    /* these do not nest */\r
+    zzmode(START);\r
+    NLATEXT[0] = ' ';\r
+    NLATEXT[1] = ' ';\r
+    zzbegexpr[0] = ' ';\r
+    zzbegexpr[1] = ' ';\r
+    if ( zzbufovf ) {\r
+      err( eMsgd("action buffer overflow; size %d",ZZLEXBUFSIZE));\r
+    }\r
+    \r
+/* MR1 10-Apr-97  MR1  Previously unable to put right shift operator   */\r
+    /* MR1                                     in DLG action                   */\r
+    /* MR1                     Doesn't matter what kind of action it is - reset*/\r
+    \r
+                             tokenActionActive=0;               /* MR1 */\r
+       }\r
+\r
+\r
+static void act103()\r
+{ \r
+               NLA = Pred;\r
+    /* these do not nest */\r
+    zzmode(START);\r
+    NLATEXT[0] = ' ';\r
+    NLATEXT[1] = ' ';\r
+    zzbegexpr[0] = '\0';\r
+    if ( zzbufovf ) {\r
+      err( eMsgd("predicate buffer overflow; size %d",ZZLEXBUFSIZE));\r
+    };\r
+#ifdef __cplusplus__\r
+    /* MR10 */                    list_apply(CurActionLabels, (void (*)(void *))mark_label_used_in_sem_pred);\r
+#else\r
+#ifdef __STDC__\r
+    /* MR10 */                    list_apply(CurActionLabels, (void (*)(void *))mark_label_used_in_sem_pred);\r
+#else\r
+#ifdef __USE_PROTOS\r
+    /* MRxx */                    list_apply(CurActionLabels, (void (*)(void *))mark_label_used_in_sem_pred);\r
+#else\r
+    /* MR10 */                    list_apply(CurActionLabels,mark_label_used_in_sem_pred);\r
+#endif\r
+#endif\r
+#endif\r
+       }\r
+\r
+\r
+static void act104()\r
+{ \r
+               NLA = PassAction;\r
+    if ( topint() == ']' ) {\r
+      popint();\r
+      if ( istackempty() )     /* terminate action */\r
+      {\r
+        zzmode(START);\r
+        NLATEXT[0] = ' ';\r
+        zzbegexpr[0] = ' ';\r
+        if ( zzbufovf ) {\r
+          err( eMsgd("parameter buffer overflow; size %d",ZZLEXBUFSIZE));\r
+        }\r
+      }\r
+      else {\r
+        /* terminate $[..] and #[..] */\r
+        if ( GenCC ) zzreplstr("))");\r
+        else zzreplstr(")");\r
+        zzmore();\r
+      }\r
+    }\r
+    else if ( topint() == '|' ) { /* end of simple [...] */\r
+      popint();\r
+      zzmore();\r
+    }\r
+    else zzmore();\r
+       }\r
+\r
+\r
+static void act105()\r
+{ \r
+               NLA = 37;\r
+    \r
+    zzmore();\r
+    zzreplstr(inline_set(zzbegexpr+\r
+    strlen("consumeUntil(")));\r
+       }\r
+\r
+\r
+static void act106()\r
+{ \r
+               NLA = 38;\r
+    zzmore();   \r
+       }\r
+\r
+\r
+static void act107()\r
+{ \r
+               NLA = 39;\r
+    zzline++; zzmore(); DAWDLE;   \r
+       }\r
+\r
+\r
+static void act108()\r
+{ \r
+               NLA = 40;\r
+    zzmore();   \r
+       }\r
+\r
+\r
+static void act109()\r
+{ \r
+               NLA = 41;\r
+    zzmore();   \r
+       }\r
+\r
+\r
+static void act110()\r
+{ \r
+               NLA = 42;\r
+    if ( !GenCC ) {zzreplstr("zzaRet"); zzmore();}\r
+    else err("$$ use invalid in C++ mode");   \r
+       }\r
+\r
+\r
+static void act111()\r
+{ \r
+               NLA = 43;\r
+    if ( !GenCC ) {zzreplstr("zzempty_attr"); zzmore();}\r
+    else err("$[] use invalid in C++ mode");   \r
+       }\r
+\r
+\r
+static void act112()\r
+{ \r
+               NLA = 44;\r
+    \r
+    pushint(']');\r
+    if ( !GenCC ) zzreplstr("zzconstr_attr(");\r
+    else err("$[..] use invalid in C++ mode");\r
+    zzmore();\r
+       }\r
+\r
+\r
+static void act113()\r
+{ \r
+               NLA = 45;\r
+    {\r
+      static char buf[100];\r
+      numericActionLabel=1;       /* MR10 */\r
+      if ( strlen(zzbegexpr)>(size_t)85 )\r
+      fatal("$i attrib ref too big");\r
+      set_orel(atoi(zzbegexpr+1), &attribsRefdFromAction);\r
+      if ( !GenCC ) sprintf(buf,"zzaArg(zztasp%d,%s)",\r
+      BlkLevel-1,zzbegexpr+1);\r
+      else sprintf(buf,"_t%d%s",\r
+      BlkLevel-1,zzbegexpr+1);\r
+      zzreplstr(buf);\r
+      zzmore();\r
+      UsedOldStyleAttrib = 1;\r
+      if ( UsedNewStyleLabel )\r
+      err("cannot mix old-style $i with new-style labels");\r
+    }\r
+       }\r
+\r
+\r
+static void act114()\r
+{ \r
+               NLA = 46;\r
+    {\r
+      static char buf[100];\r
+      numericActionLabel=1;       /* MR10 */\r
+      if ( strlen(zzbegexpr)>(size_t)85 )\r
+      fatal("$i.field attrib ref too big");\r
+      zzbegexpr[strlen(zzbegexpr)-1] = ' ';\r
+      set_orel(atoi(zzbegexpr+1), &attribsRefdFromAction);\r
+      if ( !GenCC ) sprintf(buf,"zzaArg(zztasp%d,%s).",\r
+      BlkLevel-1,zzbegexpr+1);\r
+      else sprintf(buf,"_t%d%s.",\r
+      BlkLevel-1,zzbegexpr+1);\r
+      zzreplstr(buf);\r
+      zzmore();\r
+      UsedOldStyleAttrib = 1;\r
+      if ( UsedNewStyleLabel )\r
+      err("cannot mix old-style $i with new-style labels");\r
+    }\r
+       }\r
+\r
+\r
+static void act115()\r
+{ \r
+               NLA = 47;\r
+    {\r
+      static char buf[100];\r
+      static char i[20], j[20];\r
+      char *p,*q;\r
+      numericActionLabel=1;       /* MR10 */\r
+      if (strlen(zzbegexpr)>(size_t)85) fatal("$i.j attrib ref too big");\r
+      for (p=zzbegexpr+1,q= &i[0]; *p!='.'; p++) {\r
+        if ( q == &i[20] )\r
+        fatalFL("i of $i.j attrib ref too big",\r
+        FileStr[CurFile], zzline );\r
+        *q++ = *p;\r
+      }\r
+      *q = '\0';\r
+      for (p++, q= &j[0]; *p!='\0'; p++) {\r
+        if ( q == &j[20] )\r
+        fatalFL("j of $i.j attrib ref too big",\r
+        FileStr[CurFile], zzline );\r
+        *q++ = *p;\r
+      }\r
+      *q = '\0';\r
+      if ( !GenCC ) sprintf(buf,"zzaArg(zztasp%s,%s)",i,j);\r
+      else sprintf(buf,"_t%s%s",i,j);\r
+      zzreplstr(buf);\r
+      zzmore();\r
+      UsedOldStyleAttrib = 1;\r
+      if ( UsedNewStyleLabel )\r
+      err("cannot mix old-style $i with new-style labels");\r
+    }\r
+       }\r
+\r
+\r
+static void act116()\r
+{ \r
+               NLA = 48;\r
+    { static char buf[300]; LabelEntry *el;\r
+      zzbegexpr[0] = ' ';\r
+      if ( CurRule != NULL &&\r
+      strcmp(CurRule, &zzbegexpr[1])==0 ) {\r
+        if ( !GenCC ) zzreplstr("zzaRet");\r
+      }\r
+      else if ( CurRetDef != NULL &&\r
+      strmember(CurRetDef, &zzbegexpr[1])) {\r
+        if ( hasMultipleOperands( CurRetDef ) ) {\r
+          require (strlen(zzbegexpr)<=(size_t)285,\r
+          "$retval attrib ref too big");\r
+          sprintf(buf,"_retv.%s",&zzbegexpr[1]);\r
+          zzreplstr(buf);\r
+        }\r
+        else zzreplstr("_retv");\r
+      }\r
+      else if ( CurParmDef != NULL &&\r
+      strmember(CurParmDef, &zzbegexpr[1])) {\r
+      ;\r
+    }\r
+    else if ( Elabel==NULL ) {\r
+    { err("$-variables in actions outside of rules are not allowed"); }\r
+  } else if ( (el=(LabelEntry *)hash_get(Elabel, &zzbegexpr[1]))!=NULL ) {\r
+  /* MR10 */\r
+  /* MR10 */                      /* element labels might exist without an elem when */\r
+  /* MR10 */                      /*  it is a forward reference (to a rule)          */\r
+  /* MR10 */\r
+  /* MR10 */                                           if ( GenCC && (el->elem == NULL || el->elem->ntype==nRuleRef) )\r
+  /* MR10 */                                                   { err(eMsg1("There are no token ptrs for rule references: '$%s'",&zzbegexpr[1])); }\r
+  /* MR10 */\r
+  /* MR10 */                                           if ( !GenCC && (el->elem == NULL || el->elem->ntype==nRuleRef) && GenAST) {\r
+  /* MR10 */                          err("You can no longer use attributes returned by rules when also using ASTs");\r
+  /* MR10 */                          err("   Use upward inheritance (\"rule >[Attrib a] : ... <<$a=...>>\")");\r
+  /* MR10 */                      };\r
+  /* MR10 */\r
+  /* MR10 */                      /* keep track of <<... $label ...>> for semantic predicates in guess mode */\r
+  /* MR10 */                      /* element labels contain pointer to the owners node                      */\r
+  /* MR10 */\r
+  /* MR10 */                      if (el->elem != NULL && el->elem->ntype == nToken) {\r
+  /* MR10 */                        list_add(&CurActionLabels,el);\r
+  /* MR10 */                      };\r
+}\r
+else\r
+warn(eMsg1("$%s not parameter, return value, (defined) element label",&zzbegexpr[1]));\r
+}\r
+zzmore();\r
+       }\r
+\r
+\r
+static void act117()\r
+{ \r
+               NLA = 49;\r
+    zzreplstr("(*_root)"); zzmore(); chkGTFlag();   \r
+       }\r
+\r
+\r
+static void act118()\r
+{ \r
+               NLA = 50;\r
+    if ( GenCC ) {\r
+      if (NewAST) zzreplstr("(newAST)");\r
+      else zzreplstr("(new AST)");}\r
+    else {zzreplstr("zzastnew()");} zzmore();\r
+    chkGTFlag();\r
+       }\r
+\r
+\r
+static void act119()\r
+{ \r
+               NLA = 51;\r
+    zzreplstr("NULL"); zzmore(); chkGTFlag();   \r
+       }\r
+\r
+\r
+static void act120()\r
+{ \r
+               NLA = 52;\r
+    {\r
+      static char buf[100];\r
+      if ( strlen(zzbegexpr)>(size_t)85 )\r
+      fatal("#i AST ref too big");\r
+      if ( GenCC ) sprintf(buf,"_ast%d%s",BlkLevel-1,zzbegexpr+1);\r
+      else sprintf(buf,"zzastArg(%s)",zzbegexpr+1);\r
+      zzreplstr(buf);\r
+      zzmore();\r
+      set_orel(atoi(zzbegexpr+1), &AST_nodes_refd_in_actions);\r
+      chkGTFlag();\r
+    }\r
+       }\r
+\r
+\r
+static void act121()\r
+{ \r
+               NLA = 53;\r
+    \r
+    zzline = atoi(zzbegexpr+5) - 1; zzline++; zzmore();\r
+    getFileNameFromTheLineInfo(FileStr[CurFile], zzbegexpr);\r
+       }\r
+\r
+\r
+static void act122()\r
+{ \r
+               NLA = 54;\r
+    \r
+    zzline++; zzmore();\r
+       }\r
+\r
+\r
+static void act123()\r
+{ \r
+               NLA = 55;\r
+    \r
+    if ( !(strcmp(zzbegexpr, "#ifdef")==0 ||\r
+    strcmp(zzbegexpr, "#if")==0 ||\r
+    strcmp(zzbegexpr, "#else")==0 ||\r
+    strcmp(zzbegexpr, "#endif")==0 ||\r
+    strcmp(zzbegexpr, "#ifndef")==0 ||\r
+    strcmp(zzbegexpr, "#define")==0 ||\r
+    strcmp(zzbegexpr, "#pragma")==0 ||\r
+    strcmp(zzbegexpr, "#undef")==0 ||\r
+    strcmp(zzbegexpr, "#import")==0 ||\r
+    strcmp(zzbegexpr, "#line")==0 ||\r
+    strcmp(zzbegexpr, "#include")==0 ||\r
+    strcmp(zzbegexpr, "#error")==0) )\r
+    {\r
+      static char buf[100];\r
+      sprintf(buf, "%s_ast", zzbegexpr+1);\r
+      /* MR27 */                                               list_add(&CurAstLabelsInActions, mystrdup(zzbegexpr+1));\r
+      zzreplstr(buf);\r
+      chkGTFlag();\r
+    }\r
+    zzmore();\r
+       }\r
+\r
+\r
+static void act124()\r
+{ \r
+               NLA = 56;\r
+    \r
+    pushint(']');\r
+    if ( GenCC ) {\r
+      if (NewAST) zzreplstr("(newAST(");\r
+      else zzreplstr("(new AST("); }\r
+    else zzreplstr("zzmk_ast(zzastnew(),");\r
+    zzmore();\r
+    chkGTFlag();\r
+       }\r
+\r
+\r
+static void act125()\r
+{ \r
+               NLA = 57;\r
+    \r
+    pushint('}');\r
+    if ( GenCC ) {\r
+      if (tmakeInParser) {\r
+        zzreplstr("tmake(");\r
+      }\r
+      else {\r
+        zzreplstr("ASTBase::tmake(");\r
+      }\r
+    }\r
+    else {\r
+      zzreplstr("zztmake(");\r
+    }\r
+    zzmore();\r
+    chkGTFlag();\r
+       }\r
+\r
+\r
+static void act126()\r
+{ \r
+               NLA = 58;\r
+    zzmore();   \r
+       }\r
+\r
+\r
+static void act127()\r
+{ \r
+               NLA = 59;\r
+    \r
+    if ( istackempty() )\r
+    zzmore();\r
+    else if ( topint()==')' ) {\r
+      popint();\r
+    }\r
+    else if ( topint()=='}' ) {\r
+      popint();\r
+      /* terminate #(..) */\r
+      zzreplstr(", NULL)");\r
+    }\r
+    zzmore();\r
+       }\r
+\r
+\r
+static void act128()\r
+{ \r
+               NLA = 60;\r
+    \r
+    pushint('|');      /* look for '|' to terminate simple [...] */\r
+    zzmore();\r
+       }\r
+\r
+\r
+static void act129()\r
+{ \r
+               NLA = 61;\r
+    \r
+    pushint(')');\r
+    zzmore();\r
+       }\r
+\r
+\r
+static void act130()\r
+{ \r
+               NLA = 62;\r
+    zzreplstr("]");  zzmore();   \r
+       }\r
+\r
+\r
+static void act131()\r
+{ \r
+               NLA = 63;\r
+    zzreplstr(")");  zzmore();   \r
+       }\r
+\r
+\r
+static void act132()\r
+{ \r
+               NLA = 64;\r
+    if (! tokenActionActive) zzreplstr(">");    /* MR1 */\r
+    zzmore();                                   /* MR1 */\r
+       }\r
+\r
+\r
+static void act133()\r
+{ \r
+               NLA = 65;\r
+    zzmode(ACTION_CHARS); zzmore();  \r
+       }\r
+\r
+\r
+static void act134()\r
+{ \r
+               NLA = 66;\r
+    zzmode(ACTION_STRINGS); zzmore();  \r
+       }\r
+\r
+\r
+static void act135()\r
+{ \r
+               NLA = 67;\r
+    zzreplstr("$");  zzmore();   \r
+       }\r
+\r
+\r
+static void act136()\r
+{ \r
+               NLA = 68;\r
+    zzreplstr("#");  zzmore();   \r
+       }\r
+\r
+\r
+static void act137()\r
+{ \r
+               NLA = 69;\r
+    zzline++; zzmore();   \r
+       }\r
+\r
+\r
+static void act138()\r
+{ \r
+               NLA = 70;\r
+    zzmore();   \r
+       }\r
+\r
+\r
+static void act139()\r
+{ \r
+               NLA = 71;\r
+    zzmore();   \r
+       }\r
+\r
+\r
+static void act140()\r
+{ \r
+               NLA = 72;\r
+    zzmode(ACTION_COMMENTS); zzmore();   \r
+       }\r
+\r
+\r
+static void act141()\r
+{ \r
+               NLA = 73;\r
+    warn("Missing /*; found dangling */ in action"); zzmore();   \r
+       }\r
+\r
+\r
+static void act142()\r
+{ \r
+               NLA = 74;\r
+    zzmode(ACTION_CPP_COMMENTS); zzmore();   \r
+       }\r
+\r
+\r
+static void act143()\r
+{ \r
+               NLA = 75;\r
+    zzmore();   \r
+       }\r
+\r
+static unsigned char shift10[257] = {\r
+  0, 33, 33, 33, 33, 33, 33, 33, 33, 33, \r
+  16, 19, 33, 33, 20, 33, 33, 33, 33, 33, \r
+  33, 33, 33, 33, 33, 33, 33, 33, 33, 33, \r
+  33, 33, 33, 16, 33, 28, 27, 21, 33, 33, \r
+  30, 15, 18, 32, 33, 33, 33, 25, 31, 23, \r
+  24, 24, 24, 24, 24, 24, 24, 24, 24, 33, \r
+  33, 33, 33, 1, 2, 33, 26, 26, 26, 26, \r
+  26, 26, 26, 26, 26, 26, 26, 26, 26, 26, \r
+  26, 26, 26, 26, 26, 26, 11, 26, 26, 26, \r
+  26, 26, 22, 29, 3, 33, 26, 33, 26, 26, \r
+  4, 26, 10, 26, 26, 26, 13, 26, 26, 14, \r
+  9, 6, 5, 26, 26, 26, 7, 12, 8, 26, \r
+  26, 26, 26, 26, 17, 33, 34, 33, 33, 33, \r
+  33, 33, 33, 33, 33, 33, 33, 33, 33, 33, \r
+  33, 33, 33, 33, 33, 33, 33, 33, 33, 33, \r
+  33, 33, 33, 33, 33, 33, 33, 33, 33, 33, \r
+  33, 33, 33, 33, 33, 33, 33, 33, 33, 33, \r
+  33, 33, 33, 33, 33, 33, 33, 33, 33, 33, \r
+  33, 33, 33, 33, 33, 33, 33, 33, 33, 33, \r
+  33, 33, 33, 33, 33, 33, 33, 33, 33, 33, \r
+  33, 33, 33, 33, 33, 33, 33, 33, 33, 33, \r
+  33, 33, 33, 33, 33, 33, 33, 33, 33, 33, \r
+  33, 33, 33, 33, 33, 33, 33, 33, 33, 33, \r
+  33, 33, 33, 33, 33, 33, 33, 33, 33, 33, \r
+  33, 33, 33, 33, 33, 33, 33, 33, 33, 33, \r
+  33, 33, 33, 33, 33, 33, 33\r
+};\r
+\r
+\r
+static void act144()\r
+{ \r
+               NLA = Eof;\r
+    ;   \r
+       }\r
+\r
+\r
+static void act145()\r
+{ \r
+               NLA = 137;\r
+    zzskip();   \r
+       }\r
+\r
+\r
+static void act146()\r
+{ \r
+               NLA = 138;\r
+    zzline++; zzskip();   \r
+       }\r
+\r
+\r
+static void act147()\r
+{ \r
+               NLA = 139;\r
+    zzmode(TOK_DEF_CPP_COMMENTS); zzmore();   \r
+       }\r
+\r
+\r
+static void act148()\r
+{ \r
+               NLA = 140;\r
+    zzmode(TOK_DEF_COMMENTS); zzskip();   \r
+       }\r
+\r
+\r
+static void act149()\r
+{ \r
+               NLA = 141;\r
+    zzmode(TOK_DEF_CPP_COMMENTS); zzskip();   \r
+       }\r
+\r
+\r
+static void act150()\r
+{ \r
+               NLA = 142;\r
+    zzmode(TOK_DEF_CPP_COMMENTS); zzskip();   \r
+       }\r
+\r
+\r
+static void act151()\r
+{ \r
+               NLA = 143;\r
+    ;   \r
+       }\r
+\r
+\r
+static void act152()\r
+{ \r
+               NLA = 144;\r
+    zzmode(TOK_DEF_CPP_COMMENTS); zzskip();   \r
+       }\r
+\r
+\r
+static void act153()\r
+{ \r
+               NLA = 145;\r
+    zzmode(TOK_DEF_CPP_COMMENTS); zzskip();   \r
+       }\r
+\r
+\r
+static void act154()\r
+{ \r
+               NLA = 146;\r
+    zzmode(TOK_DEF_CPP_COMMENTS); zzskip();   \r
+       }\r
+\r
+\r
+static void act155()\r
+{ \r
+               NLA = 147;\r
+    zzmode(TOK_DEF_CPP_COMMENTS); zzskip();   \r
+       }\r
+\r
+\r
+static void act156()\r
+{ \r
+               NLA = 149;\r
+       }\r
+\r
+\r
+static void act157()\r
+{ \r
+               NLA = 151;\r
+       }\r
+\r
+\r
+static void act158()\r
+{ \r
+               NLA = 152;\r
+       }\r
+\r
+\r
+static void act159()\r
+{ \r
+               NLA = 153;\r
+       }\r
+\r
+\r
+static void act160()\r
+{ \r
+               NLA = 154;\r
+       }\r
+\r
+\r
+static void act161()\r
+{ \r
+               NLA = 155;\r
+       }\r
+\r
+\r
+static void act162()\r
+{ \r
+               NLA = 156;\r
+       }\r
+\r
+\r
+static void act163()\r
+{ \r
+               NLA = INT;\r
+       }\r
+\r
+\r
+static void act164()\r
+{ \r
+               NLA = ID;\r
+       }\r
+\r
+static unsigned char shift11[257] = {\r
+  0, 27, 27, 27, 27, 27, 27, 27, 27, 27, \r
+  1, 2, 27, 27, 3, 27, 27, 27, 27, 27, \r
+  27, 27, 27, 27, 27, 27, 27, 27, 27, 27, \r
+  27, 27, 27, 1, 27, 27, 6, 27, 27, 27, \r
+  27, 27, 27, 5, 27, 22, 27, 27, 4, 25, \r
+  25, 25, 25, 25, 25, 25, 25, 25, 25, 27, \r
+  24, 27, 21, 27, 27, 27, 26, 26, 26, 26, \r
+  26, 26, 26, 26, 26, 26, 26, 26, 26, 26, \r
+  26, 26, 26, 26, 26, 26, 26, 26, 26, 26, \r
+  26, 26, 27, 27, 27, 27, 26, 27, 26, 26, \r
+  26, 9, 10, 8, 26, 26, 7, 26, 26, 12, \r
+  15, 11, 17, 16, 26, 18, 13, 19, 14, 26, \r
+  26, 26, 26, 26, 20, 27, 23, 27, 27, 27, \r
+  27, 27, 27, 27, 27, 27, 27, 27, 27, 27, \r
+  27, 27, 27, 27, 27, 27, 27, 27, 27, 27, \r
+  27, 27, 27, 27, 27, 27, 27, 27, 27, 27, \r
+  27, 27, 27, 27, 27, 27, 27, 27, 27, 27, \r
+  27, 27, 27, 27, 27, 27, 27, 27, 27, 27, \r
+  27, 27, 27, 27, 27, 27, 27, 27, 27, 27, \r
+  27, 27, 27, 27, 27, 27, 27, 27, 27, 27, \r
+  27, 27, 27, 27, 27, 27, 27, 27, 27, 27, \r
+  27, 27, 27, 27, 27, 27, 27, 27, 27, 27, \r
+  27, 27, 27, 27, 27, 27, 27, 27, 27, 27, \r
+  27, 27, 27, 27, 27, 27, 27, 27, 27, 27, \r
+  27, 27, 27, 27, 27, 27, 27, 27, 27, 27, \r
+  27, 27, 27, 27, 27, 27, 27\r
+};\r
+\r
+#define DfaStates      436\r
+typedef unsigned short DfaState;\r
+\r
+static DfaState st0[60] = {\r
+  1, 2, 3, 4, 5, 6, 7, 8, 9, 10, \r
+  11, 11, 11, 12, 13, 13, 13, 14, 15, 16, \r
+  17, 11, 11, 18, 11, 11, 19, 11, 11, 19, \r
+  11, 11, 11, 11, 20, 11, 11, 21, 22, 23, \r
+  24, 25, 26, 11, 27, 28, 29, 30, 31, 32, \r
+  33, 34, 35, 36, 11, 11, 19, 436, 436, 436\r
+};\r
+\r
+static DfaState st1[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st2[60] = {\r
+  436, 2, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st3[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st4[60] = {\r
+  436, 436, 37, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st5[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st6[60] = {\r
+  436, 436, 436, 436, 436, 38, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st7[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st8[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 39, 40, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st9[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 41, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st10[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  42, 43, 43, 44, 43, 43, 43, 436, 436, 436, \r
+  436, 45, 43, 43, 43, 43, 46, 43, 47, 43, \r
+  43, 43, 43, 48, 43, 49, 43, 436, 43, 436, \r
+  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
+  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
+};\r
+\r
+static DfaState st11[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  50, 50, 50, 50, 50, 50, 50, 436, 436, 436, \r
+  436, 50, 50, 50, 50, 50, 50, 50, 50, 50, \r
+  50, 50, 50, 50, 50, 50, 50, 436, 50, 436, \r
+  436, 436, 436, 50, 436, 436, 436, 436, 436, 436, \r
+  436, 50, 436, 436, 50, 50, 50, 50, 436, 436\r
+};\r
+\r
+static DfaState st12[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  50, 50, 50, 50, 50, 50, 50, 436, 436, 436, \r
+  436, 50, 50, 50, 50, 50, 50, 50, 50, 50, \r
+  50, 50, 50, 50, 50, 50, 50, 436, 50, 436, \r
+  436, 436, 436, 51, 436, 436, 436, 436, 436, 436, \r
+  436, 50, 436, 436, 50, 50, 50, 50, 436, 436\r
+};\r
+\r
+static DfaState st13[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 13, 13, 13, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st14[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 52, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st15[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 53, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st16[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st17[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 54, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st18[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  50, 50, 50, 50, 50, 50, 50, 436, 436, 436, \r
+  436, 55, 50, 50, 50, 50, 50, 50, 50, 50, \r
+  50, 50, 50, 50, 50, 50, 50, 436, 50, 436, \r
+  436, 436, 436, 50, 436, 436, 436, 436, 436, 436, \r
+  436, 50, 436, 436, 50, 50, 50, 50, 436, 436\r
+};\r
+\r
+static DfaState st19[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  56, 56, 56, 56, 56, 56, 56, 436, 436, 436, \r
+  436, 56, 56, 56, 56, 56, 56, 56, 56, 56, \r
+  56, 56, 56, 56, 56, 56, 56, 436, 56, 436, \r
+  436, 436, 436, 56, 436, 436, 436, 436, 436, 436, \r
+  436, 56, 436, 436, 56, 56, 56, 56, 436, 436\r
+};\r
+\r
+static DfaState st20[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  50, 50, 50, 57, 50, 50, 50, 436, 436, 436, \r
+  436, 50, 50, 50, 50, 50, 50, 50, 50, 50, \r
+  50, 50, 50, 50, 50, 50, 50, 436, 50, 436, \r
+  436, 436, 436, 50, 436, 436, 436, 436, 436, 436, \r
+  436, 50, 436, 436, 50, 50, 50, 50, 436, 436\r
+};\r
+\r
+static DfaState st21[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st22[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  58, 50, 50, 50, 50, 50, 50, 436, 436, 436, \r
+  436, 50, 50, 59, 50, 50, 50, 50, 50, 50, \r
+  50, 50, 50, 50, 50, 50, 50, 436, 50, 436, \r
+  436, 436, 436, 50, 436, 436, 436, 436, 436, 436, \r
+  436, 50, 436, 436, 50, 50, 50, 50, 436, 436\r
+};\r
+\r
+static DfaState st23[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st24[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st25[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st26[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st27[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 60, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st28[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 61, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st29[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st30[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st31[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 62, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st32[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st33[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st34[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  56, 56, 56, 56, 56, 56, 56, 436, 436, 436, \r
+  436, 56, 56, 56, 56, 56, 56, 56, 56, 56, \r
+  56, 56, 56, 56, 56, 56, 56, 436, 56, 436, \r
+  436, 436, 436, 56, 436, 436, 436, 436, 436, 436, \r
+  436, 63, 436, 436, 56, 56, 56, 56, 436, 436\r
+};\r
+\r
+static DfaState st35[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st36[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st37[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st38[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st39[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st40[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st41[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st42[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  43, 64, 43, 65, 43, 43, 43, 436, 436, 436, \r
+  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
+  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
+  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
+};\r
+\r
+static DfaState st43[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
+  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
+  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
+  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
+};\r
+\r
+static DfaState st44[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
+  436, 43, 66, 43, 43, 43, 43, 43, 43, 43, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
+  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
+  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
+};\r
+\r
+static DfaState st45[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
+  436, 43, 67, 68, 43, 43, 43, 43, 43, 43, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
+  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
+  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
+};\r
+\r
+static DfaState st46[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  43, 69, 43, 43, 43, 43, 43, 436, 436, 436, \r
+  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
+  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
+  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
+};\r
+\r
+static DfaState st47[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
+  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
+  43, 43, 70, 43, 43, 43, 43, 436, 43, 436, \r
+  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
+  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
+};\r
+\r
+static DfaState st48[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  43, 43, 43, 71, 43, 43, 43, 436, 436, 436, \r
+  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
+  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
+  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
+};\r
+\r
+static DfaState st49[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  43, 72, 43, 43, 43, 43, 43, 436, 436, 436, \r
+  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
+  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
+  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
+};\r
+\r
+static DfaState st50[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  50, 50, 50, 50, 50, 50, 50, 436, 436, 436, \r
+  436, 50, 50, 50, 50, 50, 50, 50, 50, 50, \r
+  50, 50, 50, 50, 50, 50, 50, 436, 50, 436, \r
+  436, 436, 436, 50, 436, 436, 436, 436, 436, 436, \r
+  436, 50, 436, 436, 50, 50, 50, 50, 436, 436\r
+};\r
+\r
+static DfaState st51[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  50, 50, 50, 50, 50, 50, 50, 436, 436, 436, \r
+  436, 50, 50, 50, 50, 50, 50, 50, 50, 50, \r
+  50, 50, 50, 50, 50, 50, 50, 436, 73, 436, \r
+  436, 436, 436, 50, 436, 436, 436, 436, 436, 436, \r
+  436, 50, 436, 436, 50, 50, 50, 50, 436, 436\r
+};\r
+\r
+static DfaState st52[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st53[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st54[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  74, 43, 43, 44, 43, 43, 43, 436, 436, 436, \r
+  436, 45, 43, 43, 43, 43, 46, 43, 47, 43, \r
+  43, 43, 43, 48, 43, 49, 43, 436, 43, 436, \r
+  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
+  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
+};\r
+\r
+static DfaState st55[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  50, 50, 50, 50, 50, 50, 50, 436, 436, 436, \r
+  436, 75, 50, 50, 50, 50, 50, 50, 50, 50, \r
+  50, 50, 50, 50, 50, 50, 50, 436, 50, 436, \r
+  436, 436, 436, 50, 436, 436, 436, 436, 436, 436, \r
+  436, 50, 436, 436, 50, 50, 50, 50, 436, 436\r
+};\r
+\r
+static DfaState st56[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  56, 56, 56, 56, 56, 56, 56, 436, 436, 436, \r
+  436, 56, 56, 56, 56, 56, 56, 56, 56, 56, \r
+  56, 56, 56, 56, 56, 56, 56, 436, 56, 436, \r
+  436, 436, 436, 56, 436, 436, 436, 436, 436, 436, \r
+  436, 56, 436, 436, 56, 56, 56, 56, 436, 436\r
+};\r
+\r
+static DfaState st57[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  50, 50, 50, 50, 50, 50, 50, 436, 436, 436, \r
+  436, 50, 50, 50, 50, 50, 50, 50, 50, 50, \r
+  50, 50, 50, 50, 50, 76, 50, 436, 50, 436, \r
+  436, 436, 436, 50, 436, 436, 436, 436, 436, 436, \r
+  436, 50, 436, 436, 50, 50, 50, 50, 436, 436\r
+};\r
+\r
+static DfaState st58[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  50, 50, 50, 50, 50, 50, 50, 436, 436, 436, \r
+  436, 50, 50, 77, 50, 50, 50, 50, 50, 50, \r
+  50, 50, 50, 50, 50, 50, 50, 436, 50, 436, \r
+  436, 436, 436, 50, 436, 436, 436, 436, 436, 436, \r
+  436, 50, 436, 436, 50, 50, 50, 50, 436, 436\r
+};\r
+\r
+static DfaState st59[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  50, 50, 50, 50, 50, 50, 50, 436, 436, 436, \r
+  436, 50, 50, 50, 50, 50, 50, 50, 78, 50, \r
+  50, 50, 50, 50, 50, 50, 50, 436, 50, 436, \r
+  436, 436, 436, 50, 436, 436, 436, 436, 436, 436, \r
+  436, 50, 436, 436, 50, 50, 50, 50, 436, 436\r
+};\r
+\r
+static DfaState st60[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st61[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st62[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st63[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  56, 56, 56, 56, 56, 56, 56, 436, 436, 436, \r
+  436, 56, 56, 56, 56, 56, 56, 56, 56, 56, \r
+  56, 56, 56, 56, 56, 56, 56, 436, 56, 436, \r
+  436, 436, 436, 56, 436, 436, 79, 436, 436, 436, \r
+  436, 56, 436, 436, 56, 56, 56, 56, 436, 436\r
+};\r
+\r
+static DfaState st64[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  43, 43, 80, 43, 43, 43, 43, 436, 436, 436, \r
+  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
+  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
+  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
+};\r
+\r
+static DfaState st65[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
+  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
+  436, 436, 436, 81, 436, 436, 436, 436, 436, 436, \r
+  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
+};\r
+\r
+static DfaState st66[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
+  436, 43, 82, 43, 43, 43, 43, 43, 43, 43, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
+  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
+  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
+};\r
+\r
+static DfaState st67[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  43, 43, 43, 83, 43, 43, 43, 436, 436, 436, \r
+  436, 43, 43, 84, 43, 43, 43, 43, 43, 43, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
+  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
+  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
+};\r
+\r
+static DfaState st68[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
+  436, 43, 85, 43, 43, 43, 43, 43, 43, 43, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
+  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
+  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
+};\r
+\r
+static DfaState st69[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
+  436, 43, 86, 43, 43, 43, 43, 43, 43, 43, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
+  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
+  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
+};\r
+\r
+static DfaState st70[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
+  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
+  43, 43, 43, 43, 43, 43, 87, 436, 43, 436, \r
+  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
+  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
+};\r
+\r
+static DfaState st71[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
+  436, 43, 43, 88, 43, 43, 43, 43, 43, 43, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
+  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
+  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
+};\r
+\r
+static DfaState st72[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
+  436, 43, 89, 43, 43, 43, 43, 43, 43, 43, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
+  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
+  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
+};\r
+\r
+static DfaState st73[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  50, 50, 50, 90, 50, 50, 50, 436, 436, 436, \r
+  436, 50, 50, 50, 50, 50, 50, 50, 50, 50, \r
+  50, 50, 50, 50, 50, 50, 50, 436, 50, 436, \r
+  436, 436, 436, 50, 436, 436, 436, 436, 436, 436, \r
+  436, 50, 436, 436, 50, 50, 50, 50, 436, 436\r
+};\r
+\r
+static DfaState st74[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  43, 43, 43, 65, 43, 43, 43, 436, 436, 436, \r
+  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
+  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
+  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
+};\r
+\r
+static DfaState st75[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  50, 50, 50, 50, 50, 50, 50, 436, 436, 436, \r
+  436, 50, 91, 50, 50, 50, 50, 50, 50, 50, \r
+  50, 50, 50, 50, 50, 50, 50, 436, 50, 436, \r
+  436, 436, 436, 50, 436, 436, 436, 436, 436, 436, \r
+  436, 50, 436, 436, 50, 50, 50, 50, 436, 436\r
+};\r
+\r
+static DfaState st76[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  50, 50, 50, 50, 50, 50, 50, 436, 436, 436, \r
+  436, 50, 50, 92, 50, 50, 50, 50, 50, 50, \r
+  50, 50, 50, 50, 50, 50, 50, 436, 50, 436, \r
+  436, 436, 436, 50, 436, 436, 436, 436, 436, 436, \r
+  436, 50, 436, 436, 50, 50, 50, 50, 436, 436\r
+};\r
+\r
+static DfaState st77[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  50, 50, 50, 50, 50, 50, 50, 436, 436, 436, \r
+  436, 50, 50, 50, 50, 50, 50, 93, 50, 50, \r
+  50, 50, 50, 50, 50, 50, 50, 436, 50, 436, \r
+  436, 436, 436, 50, 436, 436, 436, 436, 436, 436, \r
+  436, 50, 436, 436, 50, 50, 50, 50, 436, 436\r
+};\r
+\r
+static DfaState st78[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  50, 50, 50, 50, 50, 50, 50, 436, 436, 436, \r
+  436, 50, 50, 50, 50, 50, 50, 50, 50, 50, \r
+  50, 50, 50, 50, 50, 50, 50, 436, 94, 436, \r
+  436, 436, 436, 50, 436, 436, 436, 436, 436, 436, \r
+  436, 50, 436, 436, 50, 50, 50, 50, 436, 436\r
+};\r
+\r
+static DfaState st79[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 95, 96, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st80[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  43, 43, 43, 97, 43, 43, 43, 436, 436, 436, \r
+  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
+  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
+  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
+};\r
+\r
+static DfaState st81[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
+  436, 98, 43, 99, 43, 100, 43, 43, 43, 43, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 101, 436, \r
+  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
+  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
+};\r
+\r
+static DfaState st82[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
+  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 102, 436, \r
+  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
+  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
+};\r
+\r
+static DfaState st83[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
+  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
+  43, 43, 43, 43, 103, 43, 43, 436, 43, 436, \r
+  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
+  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
+};\r
+\r
+static DfaState st84[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
+  436, 43, 43, 43, 104, 43, 43, 43, 43, 43, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
+  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
+  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
+};\r
+\r
+static DfaState st85[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
+  436, 43, 43, 43, 43, 43, 43, 105, 43, 43, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
+  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
+  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
+};\r
+\r
+static DfaState st86[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
+  436, 43, 43, 43, 43, 43, 43, 106, 43, 43, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
+  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
+  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
+};\r
+\r
+static DfaState st87[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  43, 43, 43, 107, 43, 43, 43, 436, 436, 436, \r
+  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
+  43, 43, 43, 43, 108, 43, 43, 436, 109, 436, \r
+  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
+  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
+};\r
+\r
+static DfaState st88[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
+  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
+  43, 43, 43, 43, 110, 43, 43, 436, 43, 436, \r
+  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
+  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
+};\r
+\r
+static DfaState st89[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
+  436, 43, 43, 43, 43, 43, 43, 111, 43, 43, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
+  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
+  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
+};\r
+\r
+static DfaState st90[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  50, 50, 50, 50, 50, 50, 50, 436, 436, 436, \r
+  436, 112, 50, 50, 50, 50, 50, 50, 50, 50, \r
+  50, 50, 50, 50, 50, 50, 50, 436, 50, 436, \r
+  436, 436, 436, 50, 436, 436, 436, 436, 436, 436, \r
+  436, 50, 436, 436, 50, 50, 50, 50, 436, 436\r
+};\r
+\r
+static DfaState st91[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  50, 50, 50, 50, 50, 50, 50, 436, 436, 436, \r
+  436, 50, 50, 50, 50, 50, 50, 50, 50, 50, \r
+  50, 50, 113, 50, 50, 50, 50, 436, 50, 436, \r
+  436, 436, 436, 50, 436, 436, 436, 436, 436, 436, \r
+  436, 50, 436, 436, 50, 50, 50, 50, 436, 436\r
+};\r
+\r
+static DfaState st92[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  50, 50, 50, 50, 50, 50, 50, 436, 436, 436, \r
+  436, 50, 50, 50, 50, 50, 50, 50, 50, 50, \r
+  50, 50, 50, 50, 50, 50, 50, 436, 50, 436, \r
+  436, 436, 436, 50, 436, 436, 436, 436, 436, 436, \r
+  436, 50, 436, 436, 114, 50, 50, 50, 436, 436\r
+};\r
+\r
+static DfaState st93[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  50, 50, 50, 50, 50, 50, 50, 436, 436, 436, \r
+  436, 50, 50, 50, 50, 50, 50, 115, 50, 50, \r
+  50, 50, 50, 50, 50, 50, 50, 436, 50, 436, \r
+  436, 436, 436, 50, 436, 436, 436, 436, 436, 436, \r
+  436, 50, 436, 436, 50, 50, 50, 50, 436, 436\r
+};\r
+\r
+static DfaState st94[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  50, 50, 50, 50, 50, 50, 50, 436, 436, 436, \r
+  436, 50, 50, 50, 50, 50, 50, 50, 50, 50, \r
+  50, 50, 50, 116, 50, 50, 50, 436, 50, 436, \r
+  436, 436, 436, 50, 436, 436, 436, 436, 436, 436, \r
+  436, 50, 436, 436, 50, 50, 50, 50, 436, 436\r
+};\r
+\r
+static DfaState st95[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 117, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st96[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 118, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st97[60] = {\r
+  436, 119, 120, 121, 122, 122, 122, 122, 122, 122, \r
+  123, 123, 123, 123, 124, 124, 124, 122, 122, 122, \r
+  122, 123, 123, 123, 123, 123, 123, 123, 123, 123, \r
+  123, 123, 123, 123, 123, 123, 123, 122, 123, 122, \r
+  122, 122, 122, 123, 122, 122, 122, 122, 122, 122, \r
+  122, 123, 122, 122, 123, 123, 123, 123, 122, 436\r
+};\r
+\r
+static DfaState st98[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
+  436, 43, 125, 43, 43, 43, 43, 43, 43, 43, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
+  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
+  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
+};\r
+\r
+static DfaState st99[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
+  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 126, 436, \r
+  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
+  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
+};\r
+\r
+static DfaState st100[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  43, 43, 43, 127, 43, 43, 43, 436, 436, 436, \r
+  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
+  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
+  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
+};\r
+\r
+static DfaState st101[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  128, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
+  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
+  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
+  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
+};\r
+\r
+static DfaState st102[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  129, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
+  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
+  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
+  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
+};\r
+\r
+static DfaState st103[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
+  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
+  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
+  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
+};\r
+\r
+static DfaState st104[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
+  436, 43, 43, 43, 43, 130, 43, 43, 43, 43, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
+  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
+  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
+};\r
+\r
+static DfaState st105[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  43, 43, 43, 131, 43, 43, 43, 436, 436, 436, \r
+  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
+  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
+  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
+};\r
+\r
+static DfaState st106[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
+  436, 43, 43, 43, 43, 43, 43, 43, 132, 43, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
+  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
+  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
+};\r
+\r
+static DfaState st107[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  43, 43, 133, 43, 43, 43, 43, 436, 436, 436, \r
+  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
+  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
+  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
+};\r
+\r
+static DfaState st108[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  43, 43, 43, 134, 43, 43, 43, 436, 436, 436, \r
+  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
+  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
+  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
+};\r
+\r
+static DfaState st109[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  135, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
+  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
+  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
+  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
+};\r
+\r
+static DfaState st110[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  43, 43, 43, 136, 43, 43, 43, 436, 436, 436, \r
+  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
+  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
+  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
+};\r
+\r
+static DfaState st111[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
+  436, 43, 43, 43, 43, 43, 43, 43, 137, 43, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
+  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
+  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
+};\r
+\r
+static DfaState st112[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  50, 50, 50, 50, 50, 50, 50, 436, 436, 436, \r
+  436, 50, 50, 50, 50, 50, 50, 50, 138, 50, \r
+  50, 50, 50, 50, 50, 50, 50, 436, 50, 436, \r
+  436, 436, 436, 50, 436, 436, 436, 436, 436, 436, \r
+  436, 50, 436, 436, 50, 50, 50, 50, 436, 436\r
+};\r
+\r
+static DfaState st113[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  50, 50, 50, 50, 50, 50, 50, 436, 436, 436, \r
+  436, 50, 50, 50, 50, 50, 50, 50, 50, 50, \r
+  50, 50, 50, 50, 50, 50, 50, 436, 50, 436, \r
+  436, 436, 436, 139, 436, 436, 436, 436, 436, 436, \r
+  436, 50, 436, 436, 50, 50, 50, 50, 436, 436\r
+};\r
+\r
+static DfaState st114[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  140, 50, 50, 50, 50, 50, 50, 436, 436, 436, \r
+  436, 50, 50, 50, 50, 50, 50, 50, 50, 50, \r
+  50, 50, 50, 50, 50, 50, 50, 436, 50, 436, \r
+  436, 436, 436, 50, 436, 436, 436, 436, 436, 436, \r
+  436, 50, 436, 436, 50, 50, 50, 50, 436, 436\r
+};\r
+\r
+static DfaState st115[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  50, 50, 50, 50, 50, 50, 50, 436, 436, 436, \r
+  436, 50, 50, 50, 50, 50, 50, 50, 50, 50, \r
+  50, 50, 50, 50, 50, 50, 50, 436, 50, 436, \r
+  436, 436, 436, 50, 436, 436, 436, 436, 436, 436, \r
+  436, 50, 436, 436, 50, 50, 50, 50, 436, 436\r
+};\r
+\r
+static DfaState st116[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  50, 50, 50, 50, 50, 50, 50, 436, 436, 436, \r
+  436, 50, 50, 50, 50, 50, 50, 50, 50, 50, \r
+  50, 50, 50, 50, 50, 50, 50, 436, 50, 436, \r
+  436, 436, 436, 50, 436, 436, 436, 436, 436, 436, \r
+  436, 50, 436, 436, 50, 50, 50, 50, 436, 436\r
+};\r
+\r
+static DfaState st117[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st118[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st119[60] = {\r
+  436, 119, 120, 121, 122, 122, 122, 122, 122, 122, \r
+  122, 122, 122, 122, 141, 141, 141, 122, 122, 122, \r
+  122, 122, 122, 122, 122, 122, 122, 122, 122, 122, \r
+  122, 122, 122, 122, 122, 122, 122, 122, 122, 122, \r
+  122, 122, 122, 122, 122, 122, 122, 122, 122, 122, \r
+  122, 122, 122, 122, 122, 122, 122, 122, 122, 436\r
+};\r
+\r
+static DfaState st120[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st121[60] = {\r
+  436, 436, 142, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st122[60] = {\r
+  436, 122, 120, 121, 122, 122, 122, 122, 122, 122, \r
+  122, 122, 122, 122, 122, 122, 122, 122, 122, 122, \r
+  122, 122, 122, 122, 122, 122, 122, 122, 122, 122, \r
+  122, 122, 122, 122, 122, 122, 122, 122, 122, 122, \r
+  122, 122, 122, 122, 122, 122, 122, 122, 122, 122, \r
+  122, 122, 122, 122, 122, 122, 122, 122, 122, 436\r
+};\r
+\r
+static DfaState st123[60] = {\r
+  436, 122, 120, 121, 122, 122, 122, 122, 122, 122, \r
+  123, 123, 123, 123, 123, 123, 123, 122, 122, 122, \r
+  122, 123, 123, 123, 123, 123, 123, 123, 123, 123, \r
+  123, 123, 123, 123, 123, 123, 123, 122, 123, 122, \r
+  122, 122, 122, 123, 122, 122, 122, 122, 122, 122, \r
+  122, 123, 122, 122, 123, 123, 123, 123, 122, 436\r
+};\r
+\r
+static DfaState st124[60] = {\r
+  436, 143, 144, 145, 122, 122, 146, 122, 122, 122, \r
+  123, 123, 123, 123, 124, 124, 124, 122, 122, 122, \r
+  122, 123, 123, 123, 123, 123, 123, 123, 123, 123, \r
+  123, 123, 123, 123, 123, 123, 123, 122, 123, 122, \r
+  122, 122, 122, 123, 122, 122, 122, 122, 122, 122, \r
+  122, 123, 122, 122, 123, 123, 123, 123, 122, 436\r
+};\r
+\r
+static DfaState st125[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  43, 43, 43, 147, 43, 43, 43, 436, 436, 436, \r
+  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
+  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
+  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
+};\r
+\r
+static DfaState st126[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
+  436, 43, 43, 43, 43, 43, 43, 43, 148, 43, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
+  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
+  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
+};\r
+\r
+static DfaState st127[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
+  436, 43, 43, 43, 43, 149, 43, 43, 43, 43, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
+  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
+  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
+};\r
+\r
+static DfaState st128[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
+  436, 43, 43, 150, 43, 43, 43, 43, 43, 43, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
+  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
+  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
+};\r
+\r
+static DfaState st129[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
+  436, 43, 43, 151, 43, 43, 43, 43, 43, 43, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
+  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
+  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
+};\r
+\r
+static DfaState st130[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
+  436, 43, 43, 152, 43, 43, 43, 43, 43, 43, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
+  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
+  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
+};\r
+\r
+static DfaState st131[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
+  436, 43, 153, 43, 43, 43, 43, 43, 43, 43, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
+  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
+  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
+};\r
+\r
+static DfaState st132[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
+  436, 43, 43, 43, 43, 43, 43, 43, 43, 154, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
+  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
+  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
+};\r
+\r
+static DfaState st133[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
+  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
+  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
+  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
+};\r
+\r
+static DfaState st134[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
+  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
+  43, 43, 43, 43, 43, 155, 43, 436, 43, 436, \r
+  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
+  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
+};\r
+\r
+static DfaState st135[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
+  436, 43, 43, 156, 43, 43, 43, 43, 43, 43, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
+  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
+  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
+};\r
+\r
+static DfaState st136[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
+  436, 43, 157, 43, 43, 43, 43, 43, 43, 43, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
+  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
+  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
+};\r
+\r
+static DfaState st137[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
+  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
+  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
+  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
+};\r
+\r
+static DfaState st138[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  50, 158, 50, 50, 50, 50, 50, 436, 436, 436, \r
+  436, 50, 50, 50, 50, 50, 50, 50, 50, 50, \r
+  50, 50, 50, 50, 50, 50, 50, 436, 50, 436, \r
+  436, 436, 436, 50, 436, 436, 436, 436, 436, 436, \r
+  436, 50, 436, 436, 50, 50, 50, 50, 436, 436\r
+};\r
+\r
+static DfaState st139[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  50, 50, 50, 50, 50, 50, 50, 436, 436, 436, \r
+  436, 50, 50, 50, 50, 50, 50, 50, 50, 50, \r
+  50, 50, 50, 50, 50, 50, 50, 436, 50, 436, \r
+  436, 436, 436, 50, 436, 436, 436, 436, 436, 436, \r
+  436, 50, 436, 436, 50, 50, 50, 50, 436, 436\r
+};\r
+\r
+static DfaState st140[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  50, 50, 50, 50, 50, 50, 50, 436, 436, 436, \r
+  436, 50, 50, 50, 50, 50, 50, 50, 159, 50, \r
+  50, 50, 50, 50, 50, 50, 50, 436, 50, 436, \r
+  436, 436, 436, 50, 436, 436, 436, 436, 436, 436, \r
+  436, 50, 436, 436, 50, 50, 50, 50, 436, 436\r
+};\r
+\r
+static DfaState st141[60] = {\r
+  436, 143, 144, 145, 122, 122, 146, 122, 122, 122, \r
+  122, 122, 122, 122, 141, 141, 141, 122, 122, 122, \r
+  122, 122, 122, 122, 122, 122, 122, 122, 122, 122, \r
+  122, 122, 122, 122, 122, 122, 122, 122, 122, 122, \r
+  122, 122, 122, 122, 122, 122, 122, 122, 122, 122, \r
+  122, 122, 122, 122, 122, 122, 122, 122, 122, 436\r
+};\r
+\r
+static DfaState st142[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st143[60] = {\r
+  436, 143, 120, 121, 122, 122, 146, 122, 122, 122, \r
+  122, 122, 122, 122, 122, 122, 122, 122, 122, 122, \r
+  122, 122, 122, 122, 122, 122, 122, 122, 122, 122, \r
+  122, 122, 122, 122, 122, 122, 122, 122, 122, 122, \r
+  122, 122, 122, 122, 122, 122, 122, 122, 122, 122, \r
+  122, 122, 122, 122, 122, 122, 122, 122, 122, 436\r
+};\r
+\r
+static DfaState st144[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st145[60] = {\r
+  436, 436, 160, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st146[60] = {\r
+  436, 161, 162, 163, 161, 161, 122, 161, 161, 161, \r
+  161, 161, 161, 161, 161, 161, 161, 161, 161, 161, \r
+  161, 161, 161, 161, 161, 161, 161, 161, 161, 161, \r
+  161, 161, 161, 161, 161, 161, 161, 161, 161, 161, \r
+  161, 161, 161, 161, 161, 161, 161, 161, 161, 161, \r
+  161, 161, 161, 161, 161, 161, 161, 161, 161, 436\r
+};\r
+\r
+static DfaState st147[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
+  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
+  43, 43, 43, 43, 43, 164, 43, 436, 43, 436, \r
+  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
+  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
+};\r
+\r
+static DfaState st148[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  43, 165, 43, 43, 43, 43, 43, 436, 436, 436, \r
+  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
+  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
+  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
+};\r
+\r
+static DfaState st149[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
+  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
+  43, 166, 43, 43, 43, 43, 43, 436, 43, 436, \r
+  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
+  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
+};\r
+\r
+static DfaState st150[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
+  436, 43, 43, 43, 43, 43, 43, 167, 43, 43, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
+  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
+  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
+};\r
+\r
+static DfaState st151[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
+  436, 43, 43, 43, 43, 43, 43, 168, 43, 43, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
+  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
+  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
+};\r
+\r
+static DfaState st152[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
+  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
+  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
+  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
+};\r
+\r
+static DfaState st153[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
+  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
+  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
+  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
+};\r
+\r
+static DfaState st154[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  43, 43, 43, 169, 43, 43, 43, 436, 436, 436, \r
+  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
+  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
+  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
+};\r
+\r
+static DfaState st155[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
+  436, 43, 43, 43, 43, 43, 43, 170, 43, 43, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
+  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
+  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
+};\r
+\r
+static DfaState st156[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
+  436, 43, 43, 43, 43, 43, 43, 171, 43, 43, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
+  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
+  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
+};\r
+\r
+static DfaState st157[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
+  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
+  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
+  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
+};\r
+\r
+static DfaState st158[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  50, 50, 50, 50, 50, 50, 50, 436, 436, 436, \r
+  436, 50, 50, 50, 50, 50, 50, 50, 50, 50, \r
+  50, 50, 172, 50, 50, 50, 50, 436, 50, 436, \r
+  436, 436, 436, 50, 436, 436, 436, 436, 436, 436, \r
+  436, 50, 436, 436, 50, 50, 50, 50, 436, 436\r
+};\r
+\r
+static DfaState st159[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  50, 50, 50, 50, 50, 50, 50, 436, 436, 436, \r
+  436, 50, 50, 50, 50, 50, 50, 50, 50, 50, \r
+  50, 50, 50, 50, 50, 50, 50, 436, 50, 436, \r
+  436, 436, 436, 50, 436, 436, 436, 436, 436, 436, \r
+  436, 50, 436, 436, 50, 50, 50, 50, 436, 436\r
+};\r
+\r
+static DfaState st160[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st161[60] = {\r
+  436, 161, 162, 163, 161, 161, 173, 161, 161, 161, \r
+  161, 161, 161, 161, 161, 161, 161, 161, 161, 161, \r
+  161, 161, 161, 161, 161, 161, 161, 161, 161, 161, \r
+  161, 161, 161, 161, 161, 161, 161, 161, 161, 161, \r
+  161, 161, 161, 161, 161, 161, 161, 161, 161, 161, \r
+  161, 161, 161, 161, 161, 161, 161, 161, 161, 436\r
+};\r
+\r
+static DfaState st162[60] = {\r
+  436, 174, 174, 174, 174, 174, 175, 174, 174, 174, \r
+  174, 174, 174, 174, 174, 174, 174, 174, 174, 174, \r
+  174, 174, 174, 174, 174, 174, 174, 174, 174, 174, \r
+  174, 174, 174, 174, 174, 174, 174, 174, 174, 174, \r
+  174, 174, 174, 174, 174, 174, 174, 174, 174, 174, \r
+  174, 174, 174, 174, 174, 174, 174, 174, 174, 436\r
+};\r
+\r
+static DfaState st163[60] = {\r
+  436, 174, 176, 174, 174, 174, 175, 174, 174, 174, \r
+  174, 174, 174, 174, 174, 174, 174, 174, 174, 174, \r
+  174, 174, 174, 174, 174, 174, 174, 174, 174, 174, \r
+  174, 174, 174, 174, 174, 174, 174, 174, 174, 174, \r
+  174, 174, 174, 174, 174, 174, 174, 174, 174, 174, \r
+  174, 174, 174, 174, 174, 174, 174, 174, 174, 436\r
+};\r
+\r
+static DfaState st164[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  43, 177, 43, 43, 43, 43, 43, 436, 436, 436, \r
+  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
+  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
+  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
+};\r
+\r
+static DfaState st165[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
+  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
+  43, 43, 178, 43, 43, 43, 43, 436, 43, 436, \r
+  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
+  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
+};\r
+\r
+static DfaState st166[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  43, 43, 43, 179, 43, 43, 43, 436, 436, 436, \r
+  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
+  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
+  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
+};\r
+\r
+static DfaState st167[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
+  436, 43, 43, 43, 43, 43, 43, 180, 43, 43, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
+  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
+  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
+};\r
+\r
+static DfaState st168[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
+  436, 43, 43, 43, 43, 43, 43, 181, 43, 43, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
+  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
+  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
+};\r
+\r
+static DfaState st169[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
+  436, 43, 43, 43, 43, 43, 43, 43, 182, 43, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
+  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
+  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
+};\r
+\r
+static DfaState st170[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
+  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
+  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
+  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
+};\r
+\r
+static DfaState st171[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
+  436, 43, 43, 43, 43, 43, 43, 183, 43, 43, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
+  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
+  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
+};\r
+\r
+static DfaState st172[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  50, 50, 184, 50, 50, 50, 50, 436, 436, 436, \r
+  436, 50, 50, 50, 50, 50, 50, 50, 50, 50, \r
+  50, 50, 50, 50, 50, 50, 50, 436, 50, 436, \r
+  436, 436, 436, 50, 436, 436, 436, 436, 436, 436, \r
+  436, 50, 436, 436, 50, 50, 50, 50, 436, 436\r
+};\r
+\r
+static DfaState st173[60] = {\r
+  436, 185, 144, 145, 122, 122, 122, 122, 122, 122, \r
+  122, 122, 122, 122, 186, 186, 186, 122, 122, 122, \r
+  122, 122, 122, 122, 122, 122, 122, 122, 122, 122, \r
+  122, 122, 122, 122, 122, 122, 122, 122, 122, 122, \r
+  122, 122, 122, 122, 122, 122, 122, 122, 122, 122, \r
+  122, 122, 122, 122, 122, 122, 122, 122, 122, 436\r
+};\r
+\r
+static DfaState st174[60] = {\r
+  436, 174, 174, 174, 174, 174, 175, 174, 174, 174, \r
+  174, 174, 174, 174, 174, 174, 174, 174, 174, 174, \r
+  174, 174, 174, 174, 174, 174, 174, 174, 174, 174, \r
+  174, 174, 174, 174, 174, 174, 174, 174, 174, 174, \r
+  174, 174, 174, 174, 174, 174, 174, 174, 174, 174, \r
+  174, 174, 174, 174, 174, 174, 174, 174, 174, 436\r
+};\r
+\r
+static DfaState st175[60] = {\r
+  436, 187, 188, 189, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 190, 190, 190, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st176[60] = {\r
+  436, 174, 174, 174, 174, 174, 175, 174, 174, 174, \r
+  174, 174, 174, 174, 174, 174, 174, 174, 174, 174, \r
+  174, 174, 174, 174, 174, 174, 174, 174, 174, 174, \r
+  174, 174, 174, 174, 174, 174, 174, 174, 174, 174, \r
+  174, 174, 174, 174, 174, 174, 174, 174, 174, 174, \r
+  174, 174, 174, 174, 174, 174, 174, 174, 174, 436\r
+};\r
+\r
+static DfaState st177[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
+  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
+  436, 436, 436, 191, 436, 436, 436, 436, 436, 436, \r
+  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
+};\r
+\r
+static DfaState st178[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  43, 43, 192, 43, 43, 43, 43, 436, 436, 436, \r
+  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
+  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
+  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
+};\r
+\r
+static DfaState st179[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
+  436, 43, 193, 43, 43, 43, 43, 43, 43, 43, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
+  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
+  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
+};\r
+\r
+static DfaState st180[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
+  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
+  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
+  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
+};\r
+\r
+static DfaState st181[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
+  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
+  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
+  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
+};\r
+\r
+static DfaState st182[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
+  436, 43, 43, 43, 43, 43, 43, 43, 43, 194, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
+  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
+  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
+};\r
+\r
+static DfaState st183[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
+  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
+  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
+  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
+};\r
+\r
+static DfaState st184[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  50, 50, 50, 50, 50, 50, 50, 436, 436, 436, \r
+  436, 50, 50, 50, 50, 50, 50, 50, 50, 50, \r
+  50, 50, 50, 50, 50, 50, 50, 436, 50, 436, \r
+  436, 436, 436, 50, 436, 436, 436, 436, 436, 436, \r
+  436, 50, 436, 436, 50, 50, 50, 50, 436, 436\r
+};\r
+\r
+static DfaState st185[60] = {\r
+  436, 185, 144, 145, 122, 122, 122, 122, 122, 122, \r
+  122, 122, 122, 122, 186, 186, 186, 122, 122, 122, \r
+  122, 122, 122, 122, 122, 122, 122, 122, 122, 122, \r
+  122, 122, 122, 122, 122, 122, 122, 122, 122, 122, \r
+  122, 122, 122, 122, 122, 122, 122, 122, 122, 122, \r
+  122, 122, 122, 122, 122, 122, 122, 122, 122, 436\r
+};\r
+\r
+static DfaState st186[60] = {\r
+  436, 185, 144, 145, 122, 122, 122, 122, 122, 122, \r
+  122, 122, 122, 122, 186, 186, 186, 122, 122, 122, \r
+  122, 122, 122, 122, 122, 122, 122, 122, 122, 122, \r
+  122, 122, 122, 122, 122, 122, 122, 122, 122, 122, \r
+  122, 122, 122, 122, 122, 122, 122, 122, 122, 122, \r
+  122, 122, 122, 122, 122, 122, 122, 122, 122, 436\r
+};\r
+\r
+static DfaState st187[60] = {\r
+  436, 187, 188, 189, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 190, 190, 190, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st188[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st189[60] = {\r
+  436, 436, 195, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st190[60] = {\r
+  436, 187, 188, 189, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 190, 190, 190, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st191[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
+  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
+  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
+  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
+};\r
+\r
+static DfaState st192[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
+  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
+  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
+  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
+};\r
+\r
+static DfaState st193[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
+  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
+  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
+  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
+};\r
+\r
+static DfaState st194[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
+  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
+  196, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
+  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
+  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
+};\r
+\r
+static DfaState st195[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st196[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
+  436, 43, 43, 43, 43, 197, 43, 43, 43, 43, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
+  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
+  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
+};\r
+\r
+static DfaState st197[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
+  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
+  43, 198, 43, 43, 43, 43, 43, 436, 43, 436, \r
+  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
+  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
+};\r
+\r
+static DfaState st198[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
+  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
+  43, 43, 199, 43, 43, 43, 43, 436, 43, 436, \r
+  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
+  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
+};\r
+\r
+static DfaState st199[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  200, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
+  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
+  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
+  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
+};\r
+\r
+static DfaState st200[60] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
+  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
+  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
+  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
+  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
+};\r
+\r
+static DfaState st201[7] = {\r
+  202, 203, 204, 205, 206, 207, 436\r
+};\r
+\r
+static DfaState st202[7] = {\r
+  436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st203[7] = {\r
+  436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st204[7] = {\r
+  436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st205[7] = {\r
+  436, 436, 208, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st206[7] = {\r
+  436, 209, 210, 211, 209, 209, 436\r
+};\r
+\r
+static DfaState st207[7] = {\r
+  436, 436, 436, 436, 436, 207, 436\r
+};\r
+\r
+static DfaState st208[7] = {\r
+  436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st209[7] = {\r
+  436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st210[7] = {\r
+  436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st211[7] = {\r
+  436, 436, 212, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st212[7] = {\r
+  436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st213[7] = {\r
+  214, 215, 216, 217, 218, 219, 436\r
+};\r
+\r
+static DfaState st214[7] = {\r
+  436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st215[7] = {\r
+  436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st216[7] = {\r
+  436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st217[7] = {\r
+  436, 436, 220, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st218[7] = {\r
+  436, 221, 222, 223, 221, 221, 436\r
+};\r
+\r
+static DfaState st219[7] = {\r
+  436, 436, 436, 436, 436, 219, 436\r
+};\r
+\r
+static DfaState st220[7] = {\r
+  436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st221[7] = {\r
+  436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st222[7] = {\r
+  436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st223[7] = {\r
+  436, 436, 224, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st224[7] = {\r
+  436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st225[7] = {\r
+  226, 227, 228, 229, 230, 231, 436\r
+};\r
+\r
+static DfaState st226[7] = {\r
+  436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st227[7] = {\r
+  436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st228[7] = {\r
+  436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st229[7] = {\r
+  436, 436, 232, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st230[7] = {\r
+  436, 233, 233, 233, 233, 233, 436\r
+};\r
+\r
+static DfaState st231[7] = {\r
+  436, 436, 436, 436, 436, 231, 436\r
+};\r
+\r
+static DfaState st232[7] = {\r
+  436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st233[7] = {\r
+  436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st234[7] = {\r
+  235, 236, 237, 238, 239, 237, 436\r
+};\r
+\r
+static DfaState st235[7] = {\r
+  436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st236[7] = {\r
+  436, 436, 240, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st237[7] = {\r
+  436, 436, 237, 436, 436, 237, 436\r
+};\r
+\r
+static DfaState st238[7] = {\r
+  436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st239[7] = {\r
+  436, 436, 436, 241, 436, 436, 436\r
+};\r
+\r
+static DfaState st240[7] = {\r
+  436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st241[7] = {\r
+  436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st242[7] = {\r
+  243, 244, 245, 246, 247, 245, 436\r
+};\r
+\r
+static DfaState st243[7] = {\r
+  436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st244[7] = {\r
+  436, 436, 248, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st245[7] = {\r
+  436, 436, 245, 436, 436, 245, 436\r
+};\r
+\r
+static DfaState st246[7] = {\r
+  436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st247[7] = {\r
+  436, 436, 436, 249, 436, 436, 436\r
+};\r
+\r
+static DfaState st248[7] = {\r
+  436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st249[7] = {\r
+  436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st250[5] = {\r
+  251, 252, 253, 254, 436\r
+};\r
+\r
+static DfaState st251[5] = {\r
+  436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st252[5] = {\r
+  436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st253[5] = {\r
+  436, 255, 436, 436, 436\r
+};\r
+\r
+static DfaState st254[5] = {\r
+  436, 436, 436, 254, 436\r
+};\r
+\r
+static DfaState st255[5] = {\r
+  436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st256[5] = {\r
+  257, 258, 259, 260, 436\r
+};\r
+\r
+static DfaState st257[5] = {\r
+  436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st258[5] = {\r
+  436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st259[5] = {\r
+  436, 261, 436, 436, 436\r
+};\r
+\r
+static DfaState st260[5] = {\r
+  436, 436, 436, 260, 436\r
+};\r
+\r
+static DfaState st261[5] = {\r
+  436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st262[5] = {\r
+  263, 264, 265, 266, 436\r
+};\r
+\r
+static DfaState st263[5] = {\r
+  436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st264[5] = {\r
+  436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st265[5] = {\r
+  436, 267, 436, 436, 436\r
+};\r
+\r
+static DfaState st266[5] = {\r
+  436, 436, 436, 266, 436\r
+};\r
+\r
+static DfaState st267[5] = {\r
+  436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st268[7] = {\r
+  269, 270, 271, 272, 273, 271, 436\r
+};\r
+\r
+static DfaState st269[7] = {\r
+  436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st270[7] = {\r
+  436, 436, 274, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st271[7] = {\r
+  436, 436, 271, 436, 436, 271, 436\r
+};\r
+\r
+static DfaState st272[7] = {\r
+  436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st273[7] = {\r
+  436, 436, 436, 275, 436, 436, 436\r
+};\r
+\r
+static DfaState st274[7] = {\r
+  436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st275[7] = {\r
+  436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st276[36] = {\r
+  277, 278, 279, 280, 281, 279, 279, 279, 279, 279, \r
+  279, 279, 279, 279, 279, 282, 279, 279, 283, 284, \r
+  285, 286, 287, 279, 279, 279, 279, 288, 289, 290, \r
+  291, 292, 293, 279, 279, 436\r
+};\r
+\r
+static DfaState st277[36] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st278[36] = {\r
+  436, 294, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st279[36] = {\r
+  436, 436, 279, 436, 279, 279, 279, 279, 279, 279, \r
+  279, 279, 279, 279, 279, 436, 279, 279, 436, 436, \r
+  436, 436, 436, 279, 279, 279, 279, 436, 436, 436, \r
+  436, 436, 279, 279, 279, 436\r
+};\r
+\r
+static DfaState st280[36] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st281[36] = {\r
+  436, 436, 279, 436, 279, 295, 279, 279, 279, 279, \r
+  279, 279, 279, 279, 279, 436, 279, 279, 436, 436, \r
+  436, 436, 436, 279, 279, 279, 279, 436, 436, 436, \r
+  436, 436, 279, 279, 279, 436\r
+};\r
+\r
+static DfaState st282[36] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st283[36] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st284[36] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st285[36] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 296, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st286[36] = {\r
+  436, 436, 436, 436, 297, 297, 297, 297, 297, 297, \r
+  297, 297, 297, 297, 297, 436, 436, 436, 436, 436, \r
+  436, 298, 299, 300, 300, 436, 297, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st287[36] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st288[36] = {\r
+  436, 436, 436, 436, 301, 301, 301, 301, 301, 301, \r
+  301, 301, 301, 301, 302, 303, 436, 436, 436, 436, \r
+  436, 436, 304, 305, 306, 436, 301, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st289[36] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st290[36] = {\r
+  436, 307, 308, 309, 308, 308, 308, 308, 308, 308, \r
+  308, 308, 308, 308, 308, 308, 308, 308, 310, 311, \r
+  312, 313, 308, 308, 308, 308, 308, 314, 308, 308, \r
+  308, 308, 308, 308, 308, 436\r
+};\r
+\r
+static DfaState st291[36] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st292[36] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 315, 316, 436, 436, 436\r
+};\r
+\r
+static DfaState st293[36] = {\r
+  436, 436, 279, 436, 279, 279, 279, 279, 279, 279, \r
+  279, 279, 279, 279, 279, 436, 279, 279, 436, 436, \r
+  436, 436, 436, 279, 279, 279, 279, 436, 436, 436, \r
+  436, 317, 279, 279, 279, 436\r
+};\r
+\r
+static DfaState st294[36] = {\r
+  436, 436, 318, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st295[36] = {\r
+  436, 436, 279, 436, 279, 279, 319, 279, 279, 279, \r
+  279, 279, 279, 279, 279, 436, 279, 279, 436, 436, \r
+  436, 436, 436, 279, 279, 279, 279, 436, 436, 436, \r
+  436, 436, 279, 279, 279, 436\r
+};\r
+\r
+static DfaState st296[36] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st297[36] = {\r
+  436, 436, 436, 436, 320, 320, 320, 320, 320, 320, \r
+  320, 320, 320, 320, 320, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 320, 320, 436, 320, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st298[36] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st299[36] = {\r
+  436, 436, 436, 321, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st300[36] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 300, 300, 322, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st301[36] = {\r
+  436, 436, 436, 436, 323, 323, 323, 323, 323, 323, \r
+  323, 323, 323, 323, 323, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 323, 323, 436, 323, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st302[36] = {\r
+  436, 436, 436, 436, 323, 323, 323, 323, 323, 323, \r
+  323, 323, 323, 324, 323, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 323, 323, 436, 323, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st303[36] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 325, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st304[36] = {\r
+  436, 436, 436, 326, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st305[36] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 306, 306, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st306[36] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 306, 306, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st307[36] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st308[36] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st309[36] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st310[36] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st311[36] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st312[36] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 327, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st313[36] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st314[36] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st315[36] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st316[36] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st317[36] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st318[36] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st319[36] = {\r
+  436, 436, 279, 436, 279, 279, 279, 328, 279, 279, \r
+  279, 279, 279, 279, 279, 436, 279, 279, 436, 436, \r
+  436, 436, 436, 279, 279, 279, 279, 436, 436, 436, \r
+  436, 436, 279, 279, 279, 436\r
+};\r
+\r
+static DfaState st320[36] = {\r
+  436, 436, 436, 436, 320, 320, 320, 320, 320, 320, \r
+  320, 320, 320, 320, 320, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 320, 320, 436, 320, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st321[36] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st322[36] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 329, 329, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st323[36] = {\r
+  436, 436, 436, 436, 323, 323, 323, 323, 323, 323, \r
+  323, 323, 323, 323, 323, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 323, 323, 436, 323, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st324[36] = {\r
+  436, 436, 436, 436, 323, 323, 330, 323, 323, 323, \r
+  323, 323, 323, 323, 323, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 323, 323, 436, 323, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st325[36] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st326[36] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st327[36] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st328[36] = {\r
+  436, 436, 279, 436, 279, 279, 279, 279, 331, 279, \r
+  279, 279, 279, 279, 279, 436, 279, 279, 436, 436, \r
+  436, 436, 436, 279, 279, 279, 279, 436, 436, 436, \r
+  436, 436, 279, 279, 279, 436\r
+};\r
+\r
+static DfaState st329[36] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 329, 329, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st330[36] = {\r
+  436, 436, 436, 436, 323, 323, 323, 323, 323, 323, \r
+  332, 323, 323, 323, 323, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 323, 323, 436, 323, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st331[36] = {\r
+  436, 436, 279, 436, 279, 279, 279, 279, 279, 333, \r
+  279, 279, 279, 279, 279, 436, 279, 279, 436, 436, \r
+  436, 436, 436, 279, 279, 279, 279, 436, 436, 436, \r
+  436, 436, 279, 279, 279, 436\r
+};\r
+\r
+static DfaState st332[36] = {\r
+  436, 334, 334, 334, 335, 335, 335, 335, 335, 335, \r
+  335, 335, 335, 335, 335, 334, 336, 334, 334, 337, \r
+  338, 334, 334, 339, 339, 334, 335, 334, 334, 334, \r
+  334, 334, 334, 334, 334, 436\r
+};\r
+\r
+static DfaState st333[36] = {\r
+  436, 436, 279, 436, 279, 279, 279, 279, 279, 279, \r
+  340, 279, 279, 279, 279, 436, 279, 279, 436, 436, \r
+  436, 436, 436, 279, 279, 279, 279, 436, 436, 436, \r
+  436, 436, 279, 279, 279, 436\r
+};\r
+\r
+static DfaState st334[36] = {\r
+  436, 334, 334, 334, 334, 334, 334, 334, 334, 334, \r
+  334, 334, 334, 334, 334, 334, 334, 334, 334, 337, \r
+  338, 334, 334, 334, 334, 334, 334, 334, 334, 334, \r
+  334, 334, 334, 334, 334, 436\r
+};\r
+\r
+static DfaState st335[36] = {\r
+  436, 334, 334, 334, 335, 335, 335, 335, 335, 335, \r
+  335, 335, 335, 335, 335, 334, 334, 334, 334, 337, \r
+  338, 334, 334, 335, 335, 334, 335, 334, 334, 334, \r
+  334, 334, 334, 334, 334, 436\r
+};\r
+\r
+static DfaState st336[36] = {\r
+  436, 334, 334, 334, 334, 334, 334, 334, 334, 334, \r
+  334, 334, 334, 334, 334, 334, 336, 334, 334, 337, \r
+  338, 334, 334, 341, 341, 334, 334, 334, 334, 334, \r
+  334, 334, 334, 334, 334, 436\r
+};\r
+\r
+static DfaState st337[36] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st338[36] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 342, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st339[36] = {\r
+  436, 334, 334, 334, 335, 335, 335, 335, 335, 335, \r
+  335, 335, 335, 335, 335, 334, 343, 334, 334, 344, \r
+  345, 334, 334, 339, 339, 334, 335, 334, 346, 334, \r
+  334, 334, 334, 334, 334, 436\r
+};\r
+\r
+static DfaState st340[36] = {\r
+  436, 436, 279, 436, 279, 279, 279, 279, 279, 279, \r
+  279, 347, 279, 279, 279, 436, 279, 279, 436, 436, \r
+  436, 436, 436, 279, 279, 279, 279, 436, 436, 436, \r
+  436, 436, 279, 279, 279, 436\r
+};\r
+\r
+static DfaState st341[36] = {\r
+  436, 334, 334, 334, 334, 334, 334, 334, 334, 334, \r
+  334, 334, 334, 334, 334, 334, 343, 334, 334, 344, \r
+  345, 334, 334, 341, 341, 334, 334, 334, 346, 334, \r
+  334, 334, 334, 334, 334, 436\r
+};\r
+\r
+static DfaState st342[36] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st343[36] = {\r
+  436, 334, 334, 334, 334, 334, 334, 334, 334, 334, \r
+  334, 334, 334, 334, 334, 334, 343, 334, 334, 337, \r
+  338, 334, 334, 334, 334, 334, 334, 334, 346, 334, \r
+  334, 334, 334, 334, 334, 436\r
+};\r
+\r
+static DfaState st344[36] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st345[36] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 348, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st346[36] = {\r
+  436, 349, 349, 349, 349, 349, 349, 349, 349, 349, \r
+  349, 349, 349, 349, 349, 349, 349, 349, 349, 350, \r
+  351, 349, 349, 349, 349, 349, 349, 349, 334, 349, \r
+  349, 349, 349, 349, 349, 436\r
+};\r
+\r
+static DfaState st347[36] = {\r
+  436, 436, 279, 436, 279, 279, 352, 279, 279, 279, \r
+  279, 279, 279, 279, 279, 436, 279, 279, 436, 436, \r
+  436, 436, 436, 279, 279, 279, 279, 436, 436, 436, \r
+  436, 436, 279, 279, 279, 436\r
+};\r
+\r
+static DfaState st348[36] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st349[36] = {\r
+  436, 349, 349, 349, 349, 349, 349, 349, 349, 349, \r
+  349, 349, 349, 349, 349, 349, 349, 349, 349, 350, \r
+  351, 349, 349, 349, 349, 349, 349, 349, 353, 349, \r
+  349, 349, 349, 349, 349, 436\r
+};\r
+\r
+static DfaState st350[36] = {\r
+  436, 354, 354, 354, 354, 354, 354, 354, 354, 354, \r
+  354, 354, 354, 354, 354, 354, 354, 354, 354, 354, \r
+  354, 354, 354, 354, 354, 354, 354, 354, 355, 354, \r
+  354, 354, 354, 354, 354, 436\r
+};\r
+\r
+static DfaState st351[36] = {\r
+  436, 354, 354, 354, 354, 354, 354, 354, 354, 354, \r
+  354, 354, 354, 354, 354, 354, 354, 354, 354, 356, \r
+  354, 354, 354, 354, 354, 354, 354, 354, 355, 354, \r
+  354, 354, 354, 354, 354, 436\r
+};\r
+\r
+static DfaState st352[36] = {\r
+  436, 436, 279, 436, 279, 279, 279, 279, 279, 279, \r
+  279, 279, 357, 279, 279, 436, 279, 279, 436, 436, \r
+  436, 436, 436, 279, 279, 279, 279, 436, 436, 436, \r
+  436, 436, 279, 279, 279, 436\r
+};\r
+\r
+static DfaState st353[36] = {\r
+  436, 334, 334, 334, 334, 334, 334, 334, 334, 334, \r
+  334, 334, 334, 334, 334, 334, 358, 334, 334, 344, \r
+  345, 334, 334, 359, 359, 334, 334, 334, 334, 334, \r
+  334, 334, 334, 334, 334, 436\r
+};\r
+\r
+static DfaState st354[36] = {\r
+  436, 354, 354, 354, 354, 354, 354, 354, 354, 354, \r
+  354, 354, 354, 354, 354, 354, 354, 354, 354, 354, \r
+  354, 354, 354, 354, 354, 354, 354, 354, 355, 354, \r
+  354, 354, 354, 354, 354, 436\r
+};\r
+\r
+static DfaState st355[36] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 360, 436, 436, 361, \r
+  362, 436, 436, 363, 363, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st356[36] = {\r
+  436, 354, 354, 354, 354, 354, 354, 354, 354, 354, \r
+  354, 354, 354, 354, 354, 354, 354, 354, 354, 354, \r
+  354, 354, 354, 354, 354, 354, 354, 354, 355, 354, \r
+  354, 354, 354, 354, 354, 436\r
+};\r
+\r
+static DfaState st357[36] = {\r
+  436, 436, 279, 436, 279, 279, 279, 279, 279, 279, \r
+  279, 279, 279, 364, 279, 436, 279, 279, 436, 436, \r
+  436, 436, 436, 279, 279, 279, 279, 436, 436, 436, \r
+  436, 436, 279, 279, 279, 436\r
+};\r
+\r
+static DfaState st358[36] = {\r
+  436, 334, 334, 334, 334, 334, 334, 334, 334, 334, \r
+  334, 334, 334, 334, 334, 334, 358, 334, 334, 344, \r
+  345, 334, 334, 359, 359, 334, 334, 334, 334, 334, \r
+  334, 334, 334, 334, 334, 436\r
+};\r
+\r
+static DfaState st359[36] = {\r
+  436, 334, 334, 334, 334, 334, 334, 334, 334, 334, \r
+  334, 334, 334, 334, 334, 334, 358, 334, 334, 344, \r
+  345, 334, 334, 359, 359, 334, 334, 334, 334, 334, \r
+  334, 334, 334, 334, 334, 436\r
+};\r
+\r
+static DfaState st360[36] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 360, 436, 436, 361, \r
+  362, 436, 436, 363, 363, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st361[36] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st362[36] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 365, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st363[36] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 360, 436, 436, 361, \r
+  362, 436, 436, 363, 363, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st364[36] = {\r
+  436, 436, 279, 436, 279, 279, 279, 279, 279, 279, \r
+  279, 279, 279, 279, 366, 436, 279, 279, 436, 436, \r
+  436, 436, 436, 279, 279, 279, 279, 436, 436, 436, \r
+  436, 436, 279, 279, 279, 436\r
+};\r
+\r
+static DfaState st365[36] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st366[36] = {\r
+  436, 436, 279, 436, 279, 279, 279, 279, 279, 279, \r
+  279, 279, 279, 279, 279, 367, 279, 279, 436, 436, \r
+  436, 436, 436, 279, 279, 279, 279, 436, 436, 436, \r
+  436, 436, 279, 279, 279, 436\r
+};\r
+\r
+static DfaState st367[36] = {\r
+  436, 368, 368, 368, 368, 368, 368, 368, 368, 368, \r
+  368, 368, 368, 368, 368, 368, 369, 370, 436, 368, \r
+  368, 368, 368, 368, 368, 368, 368, 368, 368, 368, \r
+  368, 368, 368, 368, 368, 436\r
+};\r
+\r
+static DfaState st368[36] = {\r
+  436, 368, 368, 368, 368, 368, 368, 368, 368, 368, \r
+  368, 368, 368, 368, 368, 368, 368, 368, 371, 368, \r
+  368, 368, 368, 368, 368, 368, 368, 368, 368, 368, \r
+  368, 368, 368, 368, 368, 436\r
+};\r
+\r
+static DfaState st369[36] = {\r
+  436, 368, 368, 368, 368, 368, 368, 368, 368, 368, \r
+  368, 368, 368, 368, 368, 368, 369, 370, 371, 368, \r
+  368, 368, 368, 368, 368, 368, 368, 368, 368, 368, \r
+  368, 368, 368, 368, 368, 436\r
+};\r
+\r
+static DfaState st370[36] = {\r
+  436, 372, 372, 372, 372, 372, 372, 372, 372, 372, \r
+  372, 372, 372, 372, 372, 372, 372, 372, 373, 372, \r
+  372, 372, 372, 372, 372, 372, 372, 372, 372, 372, \r
+  372, 372, 372, 372, 368, 436\r
+};\r
+\r
+static DfaState st371[36] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st372[36] = {\r
+  436, 372, 372, 372, 372, 372, 372, 372, 372, 372, \r
+  372, 372, 372, 372, 372, 372, 372, 372, 373, 372, \r
+  372, 372, 372, 372, 372, 372, 372, 372, 372, 372, \r
+  372, 372, 372, 372, 374, 436\r
+};\r
+\r
+static DfaState st373[36] = {\r
+  436, 375, 375, 375, 375, 375, 375, 375, 375, 375, \r
+  375, 375, 375, 375, 375, 375, 375, 375, 375, 375, \r
+  375, 375, 375, 375, 375, 375, 375, 375, 375, 375, \r
+  375, 375, 375, 375, 376, 436\r
+};\r
+\r
+static DfaState st374[36] = {\r
+  436, 368, 368, 368, 368, 368, 368, 368, 368, 368, \r
+  368, 368, 368, 368, 368, 368, 377, 368, 378, 368, \r
+  368, 368, 368, 368, 368, 368, 368, 368, 368, 368, \r
+  368, 368, 368, 368, 368, 436\r
+};\r
+\r
+static DfaState st375[36] = {\r
+  436, 375, 375, 375, 375, 375, 375, 375, 375, 375, \r
+  375, 375, 375, 375, 375, 375, 375, 375, 375, 375, \r
+  375, 375, 375, 375, 375, 375, 375, 375, 375, 375, \r
+  375, 375, 375, 375, 376, 436\r
+};\r
+\r
+static DfaState st376[36] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 379, 436, 380, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st377[36] = {\r
+  436, 368, 368, 368, 368, 368, 368, 368, 368, 368, \r
+  368, 368, 368, 368, 368, 368, 377, 368, 378, 368, \r
+  368, 368, 368, 368, 368, 368, 368, 368, 368, 368, \r
+  368, 368, 368, 368, 368, 436\r
+};\r
+\r
+static DfaState st378[36] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st379[36] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 379, 436, 380, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st380[36] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st381[28] = {\r
+  382, 383, 384, 385, 386, 436, 387, 388, 388, 388, \r
+  389, 388, 388, 388, 388, 388, 388, 388, 388, 388, \r
+  390, 391, 392, 393, 394, 395, 388, 436\r
+};\r
+\r
+static DfaState st382[28] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st383[28] = {\r
+  436, 383, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st384[28] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st385[28] = {\r
+  436, 436, 396, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st386[28] = {\r
+  436, 436, 436, 436, 397, 398, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st387[28] = {\r
+  436, 436, 436, 436, 436, 436, 436, 399, 436, 400, \r
+  401, 436, 436, 436, 402, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st388[28] = {\r
+  436, 436, 436, 436, 436, 436, 436, 403, 403, 403, \r
+  403, 403, 403, 403, 403, 403, 403, 403, 403, 403, \r
+  436, 436, 436, 436, 436, 403, 403, 436\r
+};\r
+\r
+static DfaState st389[28] = {\r
+  436, 436, 436, 436, 436, 436, 436, 403, 403, 403, \r
+  403, 404, 403, 403, 403, 403, 403, 403, 403, 403, \r
+  436, 436, 436, 436, 436, 403, 403, 436\r
+};\r
+\r
+static DfaState st390[28] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st391[28] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st392[28] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st393[28] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st394[28] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st395[28] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 395, 436, 436\r
+};\r
+\r
+static DfaState st396[28] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st397[28] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st398[28] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st399[28] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 405, 436, \r
+  436, 436, 436, 436, 436, 406, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st400[28] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  407, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st401[28] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 408, 409, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st402[28] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 410, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st403[28] = {\r
+  436, 436, 436, 436, 436, 436, 436, 403, 403, 403, \r
+  403, 403, 403, 403, 403, 403, 403, 403, 403, 403, \r
+  436, 436, 436, 436, 436, 403, 403, 436\r
+};\r
+\r
+static DfaState st404[28] = {\r
+  436, 436, 436, 436, 436, 436, 436, 403, 403, 403, \r
+  403, 403, 403, 403, 411, 403, 403, 403, 403, 403, \r
+  436, 436, 436, 436, 436, 403, 403, 436\r
+};\r
+\r
+static DfaState st405[28] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 412, \r
+  436, 413, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st406[28] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 414, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st407[28] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 415, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st408[28] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 416, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st409[28] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 417, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st410[28] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 418, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st411[28] = {\r
+  436, 436, 436, 436, 436, 436, 436, 403, 403, 403, \r
+  403, 403, 403, 403, 403, 419, 403, 403, 403, 403, \r
+  436, 436, 436, 436, 436, 403, 403, 436\r
+};\r
+\r
+static DfaState st412[28] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  420, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st413[28] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 421, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st414[28] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 422, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st415[28] = {\r
+  436, 436, 436, 436, 436, 436, 436, 423, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st416[28] = {\r
+  436, 436, 436, 436, 436, 436, 436, 424, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st417[28] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  425, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st418[28] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  426, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st419[28] = {\r
+  436, 436, 436, 436, 436, 436, 436, 403, 403, 403, \r
+  403, 403, 403, 403, 403, 403, 403, 403, 403, 403, \r
+  436, 436, 436, 436, 436, 403, 403, 436\r
+};\r
+\r
+static DfaState st420[28] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 427, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st421[28] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  428, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st422[28] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 429, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st423[28] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 430, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st424[28] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 431, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st425[28] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st426[28] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 432, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st427[28] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st428[28] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 433, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st429[28] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 434, \r
+  436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st430[28] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  435, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st431[28] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st432[28] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st433[28] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st434[28] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+static DfaState st435[28] = {\r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
+  436, 436, 436, 436, 436, 436, 436, 436\r
+};\r
+\r
+\r
+DfaState *dfa[436] = {\r
+       st0,\r
+       st1,\r
+       st2,\r
+       st3,\r
+       st4,\r
+       st5,\r
+       st6,\r
+       st7,\r
+       st8,\r
+       st9,\r
+       st10,\r
+       st11,\r
+       st12,\r
+       st13,\r
+       st14,\r
+       st15,\r
+       st16,\r
+       st17,\r
+       st18,\r
+       st19,\r
+       st20,\r
+       st21,\r
+       st22,\r
+       st23,\r
+       st24,\r
+       st25,\r
+       st26,\r
+       st27,\r
+       st28,\r
+       st29,\r
+       st30,\r
+       st31,\r
+       st32,\r
+       st33,\r
+       st34,\r
+       st35,\r
+       st36,\r
+       st37,\r
+       st38,\r
+       st39,\r
+       st40,\r
+       st41,\r
+       st42,\r
+       st43,\r
+       st44,\r
+       st45,\r
+       st46,\r
+       st47,\r
+       st48,\r
+       st49,\r
+       st50,\r
+       st51,\r
+       st52,\r
+       st53,\r
+       st54,\r
+       st55,\r
+       st56,\r
+       st57,\r
+       st58,\r
+       st59,\r
+       st60,\r
+       st61,\r
+       st62,\r
+       st63,\r
+       st64,\r
+       st65,\r
+       st66,\r
+       st67,\r
+       st68,\r
+       st69,\r
+       st70,\r
+       st71,\r
+       st72,\r
+       st73,\r
+       st74,\r
+       st75,\r
+       st76,\r
+       st77,\r
+       st78,\r
+       st79,\r
+       st80,\r
+       st81,\r
+       st82,\r
+       st83,\r
+       st84,\r
+       st85,\r
+       st86,\r
+       st87,\r
+       st88,\r
+       st89,\r
+       st90,\r
+       st91,\r
+       st92,\r
+       st93,\r
+       st94,\r
+       st95,\r
+       st96,\r
+       st97,\r
+       st98,\r
+       st99,\r
+       st100,\r
+       st101,\r
+       st102,\r
+       st103,\r
+       st104,\r
+       st105,\r
+       st106,\r
+       st107,\r
+       st108,\r
+       st109,\r
+       st110,\r
+       st111,\r
+       st112,\r
+       st113,\r
+       st114,\r
+       st115,\r
+       st116,\r
+       st117,\r
+       st118,\r
+       st119,\r
+       st120,\r
+       st121,\r
+       st122,\r
+       st123,\r
+       st124,\r
+       st125,\r
+       st126,\r
+       st127,\r
+       st128,\r
+       st129,\r
+       st130,\r
+       st131,\r
+       st132,\r
+       st133,\r
+       st134,\r
+       st135,\r
+       st136,\r
+       st137,\r
+       st138,\r
+       st139,\r
+       st140,\r
+       st141,\r
+       st142,\r
+       st143,\r
+       st144,\r
+       st145,\r
+       st146,\r
+       st147,\r
+       st148,\r
+       st149,\r
+       st150,\r
+       st151,\r
+       st152,\r
+       st153,\r
+       st154,\r
+       st155,\r
+       st156,\r
+       st157,\r
+       st158,\r
+       st159,\r
+       st160,\r
+       st161,\r
+       st162,\r
+       st163,\r
+       st164,\r
+       st165,\r
+       st166,\r
+       st167,\r
+       st168,\r
+       st169,\r
+       st170,\r
+       st171,\r
+       st172,\r
+       st173,\r
+       st174,\r
+       st175,\r
+       st176,\r
+       st177,\r
+       st178,\r
+       st179,\r
+       st180,\r
+       st181,\r
+       st182,\r
+       st183,\r
+       st184,\r
+       st185,\r
+       st186,\r
+       st187,\r
+       st188,\r
+       st189,\r
+       st190,\r
+       st191,\r
+       st192,\r
+       st193,\r
+       st194,\r
+       st195,\r
+       st196,\r
+       st197,\r
+       st198,\r
+       st199,\r
+       st200,\r
+       st201,\r
+       st202,\r
+       st203,\r
+       st204,\r
+       st205,\r
+       st206,\r
+       st207,\r
+       st208,\r
+       st209,\r
+       st210,\r
+       st211,\r
+       st212,\r
+       st213,\r
+       st214,\r
+       st215,\r
+       st216,\r
+       st217,\r
+       st218,\r
+       st219,\r
+       st220,\r
+       st221,\r
+       st222,\r
+       st223,\r
+       st224,\r
+       st225,\r
+       st226,\r
+       st227,\r
+       st228,\r
+       st229,\r
+       st230,\r
+       st231,\r
+       st232,\r
+       st233,\r
+       st234,\r
+       st235,\r
+       st236,\r
+       st237,\r
+       st238,\r
+       st239,\r
+       st240,\r
+       st241,\r
+       st242,\r
+       st243,\r
+       st244,\r
+       st245,\r
+       st246,\r
+       st247,\r
+       st248,\r
+       st249,\r
+       st250,\r
+       st251,\r
+       st252,\r
+       st253,\r
+       st254,\r
+       st255,\r
+       st256,\r
+       st257,\r
+       st258,\r
+       st259,\r
+       st260,\r
+       st261,\r
+       st262,\r
+       st263,\r
+       st264,\r
+       st265,\r
+       st266,\r
+       st267,\r
+       st268,\r
+       st269,\r
+       st270,\r
+       st271,\r
+       st272,\r
+       st273,\r
+       st274,\r
+       st275,\r
+       st276,\r
+       st277,\r
+       st278,\r
+       st279,\r
+       st280,\r
+       st281,\r
+       st282,\r
+       st283,\r
+       st284,\r
+       st285,\r
+       st286,\r
+       st287,\r
+       st288,\r
+       st289,\r
+       st290,\r
+       st291,\r
+       st292,\r
+       st293,\r
+       st294,\r
+       st295,\r
+       st296,\r
+       st297,\r
+       st298,\r
+       st299,\r
+       st300,\r
+       st301,\r
+       st302,\r
+       st303,\r
+       st304,\r
+       st305,\r
+       st306,\r
+       st307,\r
+       st308,\r
+       st309,\r
+       st310,\r
+       st311,\r
+       st312,\r
+       st313,\r
+       st314,\r
+       st315,\r
+       st316,\r
+       st317,\r
+       st318,\r
+       st319,\r
+       st320,\r
+       st321,\r
+       st322,\r
+       st323,\r
+       st324,\r
+       st325,\r
+       st326,\r
+       st327,\r
+       st328,\r
+       st329,\r
+       st330,\r
+       st331,\r
+       st332,\r
+       st333,\r
+       st334,\r
+       st335,\r
+       st336,\r
+       st337,\r
+       st338,\r
+       st339,\r
+       st340,\r
+       st341,\r
+       st342,\r
+       st343,\r
+       st344,\r
+       st345,\r
+       st346,\r
+       st347,\r
+       st348,\r
+       st349,\r
+       st350,\r
+       st351,\r
+       st352,\r
+       st353,\r
+       st354,\r
+       st355,\r
+       st356,\r
+       st357,\r
+       st358,\r
+       st359,\r
+       st360,\r
+       st361,\r
+       st362,\r
+       st363,\r
+       st364,\r
+       st365,\r
+       st366,\r
+       st367,\r
+       st368,\r
+       st369,\r
+       st370,\r
+       st371,\r
+       st372,\r
+       st373,\r
+       st374,\r
+       st375,\r
+       st376,\r
+       st377,\r
+       st378,\r
+       st379,\r
+       st380,\r
+       st381,\r
+       st382,\r
+       st383,\r
+       st384,\r
+       st385,\r
+       st386,\r
+       st387,\r
+       st388,\r
+       st389,\r
+       st390,\r
+       st391,\r
+       st392,\r
+       st393,\r
+       st394,\r
+       st395,\r
+       st396,\r
+       st397,\r
+       st398,\r
+       st399,\r
+       st400,\r
+       st401,\r
+       st402,\r
+       st403,\r
+       st404,\r
+       st405,\r
+       st406,\r
+       st407,\r
+       st408,\r
+       st409,\r
+       st410,\r
+       st411,\r
+       st412,\r
+       st413,\r
+       st414,\r
+       st415,\r
+       st416,\r
+       st417,\r
+       st418,\r
+       st419,\r
+       st420,\r
+       st421,\r
+       st422,\r
+       st423,\r
+       st424,\r
+       st425,\r
+       st426,\r
+       st427,\r
+       st428,\r
+       st429,\r
+       st430,\r
+       st431,\r
+       st432,\r
+       st433,\r
+       st434,\r
+       st435\r
+};\r
+\r
+\r
+DfaState accepts[437] = {\r
+  0, 1, 2, 3, 3, 4, 25, 6, 0, 50, \r
+  59, 57, 57, 43, 26, 13, 14, 0, 57, 58, \r
+  57, 21, 57, 23, 24, 27, 28, 44, 0, 35, \r
+  36, 42, 45, 46, 58, 51, 52, 3, 5, 9, \r
+  7, 8, 59, 59, 59, 59, 59, 59, 59, 59, \r
+  57, 57, 12, 40, 59, 57, 58, 57, 57, 57, \r
+  33, 34, 53, 58, 59, 59, 59, 59, 59, 59, \r
+  59, 59, 59, 57, 59, 57, 57, 57, 57, 0, \r
+  59, 59, 59, 59, 59, 59, 59, 59, 59, 59, \r
+  57, 57, 57, 57, 57, 0, 0, 59, 59, 59, \r
+  59, 59, 59, 32, 59, 59, 59, 59, 59, 59, \r
+  59, 59, 57, 57, 57, 22, 56, 48, 49, 0, \r
+  11, 11, 0, 59, 59, 59, 59, 59, 59, 59, \r
+  59, 59, 59, 41, 59, 59, 59, 18, 57, 47, \r
+  57, 0, 11, 0, 10, 10, 0, 59, 59, 59, \r
+  59, 59, 15, 19, 59, 59, 59, 17, 57, 55, \r
+  10, 0, 11, 11, 59, 59, 59, 59, 59, 59, \r
+  20, 59, 57, 0, 0, 0, 11, 59, 59, 59, \r
+  37, 38, 59, 39, 54, 0, 0, 0, 10, 10, \r
+  0, 31, 29, 30, 59, 10, 59, 59, 59, 59, \r
+  16, 0, 60, 61, 62, 62, 0, 65, 62, 64, \r
+  63, 63, 63, 0, 66, 67, 68, 68, 0, 71, \r
+  68, 70, 69, 69, 69, 0, 72, 73, 74, 74, \r
+  0, 76, 74, 75, 0, 77, 79, 81, 80, 80, \r
+  78, 80, 0, 82, 84, 86, 85, 85, 83, 85, \r
+  0, 87, 88, 88, 89, 88, 0, 90, 91, 91, \r
+  92, 91, 0, 93, 94, 94, 95, 94, 0, 96, \r
+  98, 100, 99, 99, 97, 99, 0, 101, 108, 143, \r
+  104, 143, 129, 127, 107, 107, 109, 128, 126, 134, \r
+  0, 133, 139, 143, 102, 143, 107, 116, 110, 112, \r
+  113, 123, 123, 125, 124, 117, 120, 132, 138, 130, \r
+  131, 137, 137, 135, 136, 142, 140, 141, 103, 143, \r
+  116, 111, 114, 123, 123, 119, 118, 137, 143, 115, \r
+  123, 143, 123, 143, 0, 123, 0, 122, 122, 123, \r
+  143, 0, 122, 0, 121, 121, 0, 143, 121, 0, \r
+  122, 122, 143, 0, 0, 0, 122, 143, 0, 0, \r
+  0, 121, 121, 0, 143, 121, 143, 0, 0, 0, \r
+  0, 106, 0, 106, 0, 0, 0, 0, 105, 0, \r
+  105, 0, 144, 145, 146, 146, 0, 0, 164, 164, \r
+  158, 159, 160, 161, 162, 163, 146, 147, 148, 0, \r
+  0, 0, 0, 164, 164, 150, 0, 0, 0, 0, \r
+  0, 164, 0, 0, 0, 0, 0, 0, 0, 157, \r
+  0, 0, 0, 0, 0, 152, 0, 149, 0, 0, \r
+  0, 153, 154, 151, 155, 156, 0\r
+};\r
+\r
+void (*actions[165])() = {\r
+       zzerraction,\r
+       act1,\r
+       act2,\r
+       act3,\r
+       act4,\r
+       act5,\r
+       act6,\r
+       act7,\r
+       act8,\r
+       act9,\r
+       act10,\r
+       act11,\r
+       act12,\r
+       act13,\r
+       act14,\r
+       act15,\r
+       act16,\r
+       act17,\r
+       act18,\r
+       act19,\r
+       act20,\r
+       act21,\r
+       act22,\r
+       act23,\r
+       act24,\r
+       act25,\r
+       act26,\r
+       act27,\r
+       act28,\r
+       act29,\r
+       act30,\r
+       act31,\r
+       act32,\r
+       act33,\r
+       act34,\r
+       act35,\r
+       act36,\r
+       act37,\r
+       act38,\r
+       act39,\r
+       act40,\r
+       act41,\r
+       act42,\r
+       act43,\r
+       act44,\r
+       act45,\r
+       act46,\r
+       act47,\r
+       act48,\r
+       act49,\r
+       act50,\r
+       act51,\r
+       act52,\r
+       act53,\r
+       act54,\r
+       act55,\r
+       act56,\r
+       act57,\r
+       act58,\r
+       act59,\r
+       act60,\r
+       act61,\r
+       act62,\r
+       act63,\r
+       act64,\r
+       act65,\r
+       act66,\r
+       act67,\r
+       act68,\r
+       act69,\r
+       act70,\r
+       act71,\r
+       act72,\r
+       act73,\r
+       act74,\r
+       act75,\r
+       act76,\r
+       act77,\r
+       act78,\r
+       act79,\r
+       act80,\r
+       act81,\r
+       act82,\r
+       act83,\r
+       act84,\r
+       act85,\r
+       act86,\r
+       act87,\r
+       act88,\r
+       act89,\r
+       act90,\r
+       act91,\r
+       act92,\r
+       act93,\r
+       act94,\r
+       act95,\r
+       act96,\r
+       act97,\r
+       act98,\r
+       act99,\r
+       act100,\r
+       act101,\r
+       act102,\r
+       act103,\r
+       act104,\r
+       act105,\r
+       act106,\r
+       act107,\r
+       act108,\r
+       act109,\r
+       act110,\r
+       act111,\r
+       act112,\r
+       act113,\r
+       act114,\r
+       act115,\r
+       act116,\r
+       act117,\r
+       act118,\r
+       act119,\r
+       act120,\r
+       act121,\r
+       act122,\r
+       act123,\r
+       act124,\r
+       act125,\r
+       act126,\r
+       act127,\r
+       act128,\r
+       act129,\r
+       act130,\r
+       act131,\r
+       act132,\r
+       act133,\r
+       act134,\r
+       act135,\r
+       act136,\r
+       act137,\r
+       act138,\r
+       act139,\r
+       act140,\r
+       act141,\r
+       act142,\r
+       act143,\r
+       act144,\r
+       act145,\r
+       act146,\r
+       act147,\r
+       act148,\r
+       act149,\r
+       act150,\r
+       act151,\r
+       act152,\r
+       act153,\r
+       act154,\r
+       act155,\r
+       act156,\r
+       act157,\r
+       act158,\r
+       act159,\r
+       act160,\r
+       act161,\r
+       act162,\r
+       act163,\r
+       act164\r
+};\r
+\r
+static DfaState dfa_base[] = {\r
+       0,\r
+       201,\r
+       213,\r
+       225,\r
+       234,\r
+       242,\r
+       250,\r
+       256,\r
+       262,\r
+       268,\r
+       276,\r
+       381\r
+};\r
+\r
+static unsigned char *b_class_no[] = {\r
+       shift0,\r
+       shift1,\r
+       shift2,\r
+       shift3,\r
+       shift4,\r
+       shift5,\r
+       shift6,\r
+       shift7,\r
+       shift8,\r
+       shift9,\r
+       shift10,\r
+       shift11\r
+};\r
+\r
+\r
+\r
+#define ZZSHIFT(c) (b_class_no[zzauto][1+c])\r
+#define MAX_MODE 12\r
+#include "dlgauto.h"\r
diff --git a/Tools/CodeTools/Source/Pccts/antlr/stdpccts.h b/Tools/CodeTools/Source/Pccts/antlr/stdpccts.h
new file mode 100644 (file)
index 0000000..ccdc21c
--- /dev/null
@@ -0,0 +1,31 @@
+#ifndef STDPCCTS_H\r
+#define STDPCCTS_H\r
+/*\r
+ * stdpccts.h -- P C C T S  I n c l u d e\r
+ *\r
+ * Terence Parr, Will Cohen, and Hank Dietz: 1989-2001\r
+ * Purdue University Electrical Engineering\r
+ * With AHPCRC, University of Minnesota\r
+ * ANTLR Version 1.33MR33\r
+ */\r
+\r
+#ifndef ANTLR_VERSION\r
+#define ANTLR_VERSION  13333\r
+#endif\r
+\r
+#include "pcctscfg.h"\r
+#include "pccts_stdio.h"\r
+\r
+#include "pcctscfg.h"\r
+#include "set.h"\r
+#include <ctype.h>\r
+#include "syn.h"\r
+#include "hash.h"\r
+#include "generic.h"\r
+#define zzcr_attr(attr,tok,t)\r
+#define zzSET_SIZE 20\r
+#include "antlr.h"\r
+#include "tokens.h"\r
+#include "dlgdef.h"\r
+#include "mode.h"\r
+#endif\r
diff --git a/Tools/CodeTools/Source/Pccts/antlr/syn.h b/Tools/CodeTools/Source/Pccts/antlr/syn.h
new file mode 100644 (file)
index 0000000..a23d196
--- /dev/null
@@ -0,0 +1,390 @@
+/*\r
+ * syn.h\r
+ *\r
+ * This file includes definitions and macros associated with syntax diagrams\r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
+ * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
+ * company may do whatever they wish with source code distributed with\r
+ * PCCTS or the code generated by PCCTS, including the incorporation of\r
+ * PCCTS, or its output, into commerical software.\r
+ *\r
+ * We encourage users to develop software with PCCTS.  However, we do ask\r
+ * that credit is given to us for developing PCCTS.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like PCCTS and have developed a nice tool with the\r
+ * output, please mention that you developed it using PCCTS.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * ANTLR 1.33\r
+ * Terence Parr\r
+ * Parr Research Corporation\r
+ * with Purdue University and AHPCRC, University of Minnesota\r
+ * 1989-2001\r
+ */\r
+\r
+#include "set.h"\r
+\r
+#define NumNodeTypes   4\r
+#define NumJuncTypes   9\r
+\r
+/* List the different node types */\r
+#define nJunction              1\r
+#define nRuleRef               2\r
+#define nToken                 3\r
+#define nAction                        4\r
+\r
+/* Different types of junctions */\r
+#define aSubBlk                        1\r
+#define aOptBlk                        2\r
+#define aLoopBlk               3\r
+#define EndBlk                 4\r
+#define RuleBlk                        5\r
+#define Generic                        6       /* just a junction--no unusual characteristics */\r
+#define EndRule                        7\r
+#define aPlusBlk               8\r
+#define aLoopBegin             9\r
+\r
+typedef int NodeType;\r
+\r
+#define TreeBlockAllocSize             500\r
+#define JunctionBlockAllocSize 200\r
+#define ActionBlockAllocSize   50\r
+#define RRefBlockAllocSize             100\r
+#define TokenBlockAllocSize            100\r
+\r
+#ifdef __cplusplus\r
+class ActionNode;\r
+class Junction;\r
+#endif\r
+\r
+/* note that 'right' is used by the tree node allocator as a ptr for linked list */\r
+typedef struct _tree {\r
+                       struct _tree *down, *right;\r
+                       int token;\r
+                       union {\r
+                               int rk; /* if token==EpToken, => how many more tokens req'd */\r
+                               struct _tree *tref;     /* if token==TREE_REF */\r
+                               set sref;                       /* if token==SET */\r
+                       } v;\r
+#ifdef TREE_DEBUG\r
+                       int in_use;\r
+            int seq;\r
+#endif\r
+               } Tree;\r
+\r
+\r
+/* a predicate is defined to be a predicate action and a token tree with\r
+ * context info (if used); later, this struct may include the\r
+ * "hoisting distance" when we hoist past tokens.\r
+ *\r
+ * A tree is used to indicate && vs ||\r
+ *\r
+ *    p\r
+ *    |\r
+ *    q--r\r
+ *\r
+ * indicates p && (q||r).\r
+ *\r
+ * If expr is PRED_AND_LIST or PRED_OR_LIST, then it's an operation node\r
+ * and indicates the start of an && or || list.\r
+ */\r
+\r
+typedef struct _Predicate {\r
+       struct _Predicate *down, *right;        /* these have to be first */\r
+       struct _Predicate *up, *left;           /* doubly-link me */\r
+       char *expr;\r
+       Tree *tcontext; /* used if lookahead depth of > one is needed (tree) */\r
+       int k;                  /* lookahead depth for this tcontext */\r
+       set scontext[2];/* used if lookahead depth of one is needed (set) */\r
+                                       /* scontext[0] is not used; only needed so genExprSets()\r
+                                          routine works (it expects an array)\r
+                                        */\r
+       set completionTree;     /* which lookahead depths are required to complete tcontext? */\r
+    set completionSet;  /* MR10 separate completion set for sets and trees           */\r
+    struct _PredEntry *predEntry;         /* MR11 */\r
+\r
+#ifdef __cplusplus\r
+       ActionNode *source;     /* where did this predicate come from? */\r
+#else\r
+       struct _anode *source;  /* where did this predicate come from? */\r
+#endif\r
+\r
+    char             cloned;               /* MR10 don't want to free original guard pred */\r
+    char             redundant;            /* MR10 predicate tree simplification          */\r
+    char             ampersandStyle;       /* MR10  (g)? && <<p>>?                        */\r
+    char             inverted;             /* MR11 ! predName */\r
+    char             isConst;              /* MR11 */\r
+    char             constValue;           /* MR11 */\r
+    char             conflictReported;     /* MR11 */\r
+\r
+    set              plainSet;             /* MR12b */\r
+\r
+    /*** remember to change new_predicate() and predicate_dup() when changing this ***/\r
+\r
+} Predicate;\r
+\r
+typedef struct _ExceptionHandler {\r
+                       char *signalname;\r
+                       char *action;\r
+               } ExceptionHandler;\r
+\r
+typedef struct _ExceptionGroup {\r
+                       struct _ListNode *handlers; /* list of ExceptionHandler's */\r
+                       char *label;            /* label==""; implies not attached to any\r
+                                                                * particular rule ref.\r
+                                                                */\r
+                       char *altID;            /* which alt did it come from (blk#:alt#) */\r
+\r
+            struct _ExceptionGroup  *pendingLink; /* for alternative EG MR7 */\r
+            struct _ExceptionGroup  *outerEG;     /* for alternative EG MR7 */\r
+            struct _LabelEntry      *labelEntry;  /* for alternative EG MR7 */\r
+            int                     forRule;                         /* MR7 */\r
+            int                     used;                            /* MR7 */\r
+               } ExceptionGroup ;\r
+\r
+\r
+#define TokenString(_i)                        ((TokenInd!=NULL)?TokenStr[TokenInd[_i]]:TokenStr[_i])\r
+#define ExprString(_i)                 ((TokenInd!=NULL)?ExprStr[TokenInd[_i]]:ExprStr[_i])\r
+\r
+\r
+                               /* M e s s a g e  P a s s i n g  T o  N o d e s */\r
+\r
+/*\r
+ * assumes a 'Junction *r' exists.  This macro calls a function with\r
+ * the pointer to the node to operate on and a pointer to the rule\r
+ * in which it is enclosed.\r
+ */\r
+#define TRANS(p)       {if ( (p)==NULL ) fatal("TRANS: NULL object");          \\r
+                                       if ( (p)->ntype == nJunction ) (*(fpJTrans[((Junction *)(p))->jtype]))( p );\\r
+                                       else (*(fpTrans[(p)->ntype]))( p );}\r
+\r
+#define PRINT(p)       {if ( (p)==NULL ) fatal("PRINT: NULL object");\\r
+                                       (*(fpPrint[(p)->ntype]))( p );}\r
+\r
+#define REACH(p,k,rk,a) {if ( (p)==NULL ) fatal("REACH: NULL object");\\r
+                                       (a) = (*(fpReach[(p)->ntype]))( p, k, rk );}\r
+\r
+#define TRAV(p,k,rk,a) {if ( (p)==NULL ) {\\r
+                                         if ( ContextGuardTRAV ) (a)=NULL; \\r
+                                         else fatal("TRAV: NULL object");\\r
+                                   } \\r
+                                       else (a) = (*(fpTraverse[(p)->ntype]))( p, k, rk );}\r
+\r
+/**\r
+*** #define TRAV(p,k,rk,a) {if ( (p)==NULL ) fatal("TRAV: NULL object");\\r
+***                                    (a) = (*(fpTraverse[(p)->ntype]))( p, k, rk );}\r
+**/\r
+\r
+/* All syntax diagram nodes derive from Node -- superclass\r
+ */\r
+#ifdef __cplusplus\r
+class Node {\r
+public:\r
+                       NodeType ntype;\r
+                       char *rname;            /* what rule does this element live in? */\r
+                       int file;                       /* index in FileStr */\r
+                       int line;                       /* line number that element occurs on */\r
+               };\r
+#else\r
+typedef struct _node {\r
+                       NodeType ntype;\r
+                       char *rname;            /* what rule does this element live in? */\r
+                       int file;                       /* index in FileStr */\r
+                       int line;                       /* line number that element occurs on */\r
+               } Node;\r
+#endif\r
+\r
+#ifdef __cplusplus\r
+class ActionNode : public Node {\r
+public:\r
+#else\r
+typedef struct _anode {\r
+                       NodeType ntype;\r
+                       char *rname;            /* what rule does this action live in? */\r
+                       int file;                       /* index in FileStr (name of file with action) */\r
+                       int line;                       /* line number that action occurs on */\r
+#endif\r
+                       Node *next;\r
+                       char *action;\r
+                       int is_predicate;       /* true if action is a <<...>>? predicate action */\r
+                       int done;                       /* don't dump if action dumped (used for predicates) */\r
+                       int init_action;        /* is this the 1st action of 1st prod of block? */\r
+                       char *pred_fail;        /* what to do/print when predicate fails */\r
+                       Predicate  *guardpred;  /* if '(context)? =>' was present, already done */\r
+                       unsigned char frmwarned;/* have we dumped a warning for pred yet? */\r
+                       unsigned char ctxwarned;/* have we dumped a warning for pred yet? */\r
+            unsigned char predTooLong;     /* MR10 have we dumped warning for pred yet */\r
+            unsigned char noHoist;         /* MR12 literally "noHoist" */\r
+            Predicate         *ampersandPred;     /* MR10   (g)? && <<p>>? expr   */\r
+#ifdef __cplusplus\r
+            Junction          *guardNodes;        /* MR11 */\r
+#else\r
+            struct _junct     *guardNodes;        /* MR11 */\r
+#endif\r
+            struct _PredEntry *predEntry;         /* MR11 */\r
+            int               inverted;           /* MR11 <<!predSymbol>>? */\r
+#ifdef __cplusplus\r
+               };\r
+#else\r
+               } ActionNode;\r
+#endif\r
+\r
+#ifdef __cplusplus\r
+class TokNode : public Node {\r
+public:\r
+#else\r
+typedef struct _toknode {\r
+                       NodeType ntype;\r
+                       char *rname;            /* name of rule it's in */\r
+                       int file;                       /* index in FileStr (name of file with rule) */\r
+                       int line;                       /* line number that token occurs on */\r
+#endif\r
+                       Node *next;\r
+                       int token;\r
+                       int astnode;            /* leaf/root/excluded (used to build AST's) */\r
+                       unsigned char label;/* token label or expression ? */\r
+                       unsigned char remapped;\r
+                                                               /* used if token id's are forced to certain positions;\r
+                                                                * a function walks the tree reassigning token numbers */\r
+                       int upper_range;    /* MR13 - was char */\r
+                                                               /* used only if Token is of type T1..T2; in this case,\r
+                                                                * use token..upper_range as the range; else\r
+                                                                * upper_range must be 0 */\r
+                       unsigned char wild_card;\r
+                                                               /* indicates that the token is the "." wild-card;\r
+                                                                * field token is ignored if wild_card is set\r
+                                                                */\r
+                       unsigned int elnum; /* element number within the alternative */\r
+#ifdef __cplusplus\r
+                       Junction *altstart;     /* pointer to node that starts alt */\r
+#else\r
+                       struct _junct *altstart;        /* pointer to node that starts alt */\r
+#endif\r
+                       struct _TCnode *tclass;         /* token class if tokclass ref */\r
+                       set tset;                       /* set of tokens represented by meta token */\r
+                       char *el_label;         /* el_label:toknode */\r
+                       unsigned char complement;       /* complement the set? */\r
+                       ExceptionGroup *ex_group;       /* any exception[el_label] attached? */\r
+            unsigned char use_def_MT_handler;\r
+            unsigned char label_used_in_semantic_pred;  /* MR10 */\r
+#ifdef __cplusplus\r
+               };\r
+#else\r
+               } TokNode;\r
+#endif\r
+\r
+#ifdef __cplusplus\r
+class RuleRefNode : public Node {\r
+public:\r
+#else\r
+typedef struct _rrnode {\r
+                       NodeType ntype;\r
+                       char *rname;            /* name of rule it's in */\r
+                       int file;                       /* index in FileStr (name of file with rule)\r
+                                                                  it's in */\r
+                       int line;                       /* line number that rule ref occurs on */\r
+#endif\r
+                       Node *next;\r
+                       char *text;                     /* reference to which rule */\r
+                       char *parms;            /* point to parameters of rule invocation\r
+                                                                  (if present) */\r
+                       char *assign;           /* point to left-hand-side of assignment\r
+                                                                  (if any) */\r
+                       int linked;                     /* Has a FoLink already been established? */\r
+                       int astnode;            /* excluded? (used to build AST's) */\r
+                       unsigned int elnum; /* element number within the alternative */\r
+#ifdef __cplusplus\r
+                       Junction *altstart;\r
+#else\r
+                       struct _junct *altstart;\r
+#endif\r
+                       char *el_label;         /* el_label:rrnode */\r
+                       ExceptionGroup *ex_group;       /* any exception[el_label] attached? */\r
+#ifdef __cplusplus\r
+               };\r
+#else\r
+               } RuleRefNode;\r
+#endif\r
+\r
+#ifdef __cplusplus\r
+class Junction : public Node {\r
+public:\r
+#else\r
+typedef struct _junct {\r
+                       NodeType ntype;\r
+                       char *rname;            /* name of rule junction is in */\r
+                       int file;                       /* index in FileStr (name of file with rule)\r
+                                                                  if blk == RuleBlk */\r
+                       int line;                       /* line number that rule occurs on */\r
+#endif\r
+            int seq;            /* MR10 sequence number */\r
+                       char ignore;            /* used by FIRST computation to ignore\r
+                                                                  empty alt added for the (...)+ blks */\r
+                       char visited;           /* used by recursive routines to avoid\r
+                                                                  infinite recursion */\r
+                       char pvisited;          /* used by print routines to avoid\r
+                                                                  infinite recursion */\r
+                       char fvisited;          /* used by FoLink() to avoid\r
+                                                                  infinite recursion */\r
+                       char *lock;                     /* used by REACH to track infinite recursion */\r
+                       char *pred_lock;        /* used by find_predicates to track infinite recursion */\r
+                       int altnum;                     /* used in subblocks. altnum==0 means not an\r
+                                                                  alt of subrule */\r
+                       int jtype;                      /* annotation for code-gen/FIRST/FOLLOW.\r
+                                                                  Junction type */\r
+#ifdef __cplusplus\r
+                       Junction *end;          /* pointer to node with EndBlk in it\r
+                                                                  if blk == a block type */\r
+#else\r
+                       struct _junct *end;     /* pointer to node with EndBlk in it\r
+                                                                  if blk == a block type */\r
+#endif\r
+                       Node *p1, *p2;\r
+                       char  halt;                     /* never move past a junction with halt==TRUE */ /* MR10 was int */\r
+                       char *pdecl;            /* point to declaration of parameters on rule\r
+                                                                  (if present) */\r
+                       char *parm;                     /* point to parameter of block invocation\r
+                                                                  (if present) */\r
+                       char predparm;          /* indicates that the 'parm' is a predicate\r
+                                                                * to be used in the while loop generated\r
+                                                                * for blocks */ /* MR10 was int */\r
+                       char *ret;                      /* point to return type of rule (if present) */\r
+                       char *erraction;        /* point to error action (if present) */\r
+                       int blockid;            /* this is a unique ID */\r
+                       char *exception_label;  /* goto label for this alt */\r
+                       set *fset;                      /* used for code generation */\r
+                       Tree *ftree;            /* used for code generation */\r
+                       Predicate *predicate;/* predicate that can be used to disambiguate */\r
+                       char guess;                     /* true if (...)? block */\r
+            char alpha_beta_guess_end;      /* MR14 1 => end block of guess sub block  */\r
+            Node *guess_analysis_point;     /* MR14 */\r
+                       char approx;            /* limit block to use linear approx lookahead? */\r
+                       set tokrefs;            /* if ith element of alt is tokref then i is member */\r
+                       set rulerefs;           /* if ith element of alt is rule ref then i is member */\r
+                       struct _ListNode *exceptions; /* list of exceptions groups for rule */\r
+                       struct _ListNode *el_labels;  /* list of element labels for rule */\r
+            ExceptionGroup   *outerEG;                               /* MR7 */\r
+            int              curAltNum;                              /* MR7 */\r
+            char* pFirstSetSymbol;   /* #pragma FirstSetSymbol(Foo)     MR21 */\r
+#ifdef __cplusplus\r
+            Junction         *pendingLink;                           /* MR7 */\r
+#else\r
+            struct _junct    *pendingLink;                           /* MR7 */\r
+#endif\r
+            char             overlap_warning;                        /* MR10 */\r
+#ifdef __cplusplus\r
+               };\r
+#else\r
+               } Junction;\r
+#endif\r
+\r
+typedef struct { Node *left, *right;} Graph;\r
+\r
diff --git a/Tools/CodeTools/Source/Pccts/antlr/tokens.h b/Tools/CodeTools/Source/Pccts/antlr/tokens.h
new file mode 100644 (file)
index 0000000..91a53a8
--- /dev/null
@@ -0,0 +1,246 @@
+#ifndef tokens_h\r
+#define tokens_h\r
+/* tokens.h -- List of labelled tokens and stuff\r
+ *\r
+ * Generated from: antlr.g\r
+ *\r
+ * Terence Parr, Will Cohen, and Hank Dietz: 1989-2001\r
+ * Purdue University Electrical Engineering\r
+ * ANTLR Version 1.33MR33\r
+ */\r
+#define zzEOF_TOKEN 1\r
+#define Eof 1\r
+#define QuotedTerm 2\r
+#define Action 34\r
+#define Pred 35\r
+#define PassAction 36\r
+#define WildCard 87\r
+#define LABEL 89\r
+#define Pragma 92\r
+#define FirstSetSymbol 93\r
+#define NonTerminal 100\r
+#define TokenTerm 101\r
+#define ID 148\r
+#define INT 150\r
+\r
+#ifdef __USE_PROTOS\r
+void grammar(void);\r
+#else\r
+extern void grammar();\r
+#endif\r
+\r
+#ifdef __USE_PROTOS\r
+void class_def(void);\r
+#else\r
+extern void class_def();\r
+#endif\r
+\r
+#ifdef __USE_PROTOS\r
+void rule(void);\r
+#else\r
+extern void rule();\r
+#endif\r
+\r
+#ifdef __USE_PROTOS\r
+void laction(void);\r
+#else\r
+extern void laction();\r
+#endif\r
+\r
+#ifdef __USE_PROTOS\r
+void lmember(void);\r
+#else\r
+extern void lmember();\r
+#endif\r
+\r
+#ifdef __USE_PROTOS\r
+void lprefix(void);\r
+#else\r
+extern void lprefix();\r
+#endif\r
+\r
+#ifdef __USE_PROTOS\r
+void aPred(void);\r
+#else\r
+extern void aPred();\r
+#endif\r
+\r
+#ifdef __USE_PROTOS\r
+extern Predicate * predOrExpr(void);\r
+#else\r
+extern Predicate * predOrExpr();\r
+#endif\r
+\r
+#ifdef __USE_PROTOS\r
+extern Predicate * predAndExpr(void);\r
+#else\r
+extern Predicate * predAndExpr();\r
+#endif\r
+\r
+#ifdef __USE_PROTOS\r
+extern Predicate * predPrimary(void);\r
+#else\r
+extern Predicate * predPrimary();\r
+#endif\r
+\r
+#ifdef __USE_PROTOS\r
+void aLexclass(void);\r
+#else\r
+extern void aLexclass();\r
+#endif\r
+\r
+#ifdef __USE_PROTOS\r
+void error(void);\r
+#else\r
+extern void error();\r
+#endif\r
+\r
+#ifdef __USE_PROTOS\r
+void tclass(void);\r
+#else\r
+extern void tclass();\r
+#endif\r
+\r
+#ifdef __USE_PROTOS\r
+void token(void);\r
+#else\r
+extern void token();\r
+#endif\r
+\r
+#ifdef __USE_PROTOS\r
+void block(set * toksrefd,set * rulesrefd);\r
+#else\r
+extern void block();\r
+#endif\r
+\r
+#ifdef __USE_PROTOS\r
+void alt(set * toksrefd,set * rulesrefd);\r
+#else\r
+extern void alt();\r
+#endif\r
+\r
+#ifdef __USE_PROTOS\r
+extern LabelEntry * element_label(void);\r
+#else\r
+extern LabelEntry * element_label();\r
+#endif\r
+\r
+#ifdef __USE_PROTOS\r
+extern Node * element(int old_not,int first_on_line,int use_def_MT_handler);\r
+#else\r
+extern Node * element();\r
+#endif\r
+\r
+#ifdef __USE_PROTOS\r
+void default_exception_handler(void);\r
+#else\r
+extern void default_exception_handler();\r
+#endif\r
+\r
+#ifdef __USE_PROTOS\r
+extern ExceptionGroup * exception_group(void);\r
+#else\r
+extern ExceptionGroup * exception_group();\r
+#endif\r
+\r
+#ifdef __USE_PROTOS\r
+extern ExceptionHandler * exception_handler(void);\r
+#else\r
+extern ExceptionHandler * exception_handler();\r
+#endif\r
+\r
+#ifdef __USE_PROTOS\r
+void enum_file(char * fname);\r
+#else\r
+extern void enum_file();\r
+#endif\r
+\r
+#ifdef __USE_PROTOS\r
+void defines(char * fname);\r
+#else\r
+extern void defines();\r
+#endif\r
+\r
+#ifdef __USE_PROTOS\r
+void enum_def(char * fname);\r
+#else\r
+extern void enum_def();\r
+#endif\r
+\r
+#endif\r
+extern SetWordType zzerr1[];\r
+extern SetWordType zzerr2[];\r
+extern SetWordType zzerr3[];\r
+extern SetWordType zzerr4[];\r
+extern SetWordType setwd1[];\r
+extern SetWordType zzerr5[];\r
+extern SetWordType zzerr6[];\r
+extern SetWordType zzerr7[];\r
+extern SetWordType zzerr8[];\r
+extern SetWordType zzerr9[];\r
+extern SetWordType setwd2[];\r
+extern SetWordType zzerr10[];\r
+extern SetWordType zzerr11[];\r
+extern SetWordType zzerr12[];\r
+extern SetWordType zzerr13[];\r
+extern SetWordType setwd3[];\r
+extern SetWordType zzerr14[];\r
+extern SetWordType zzerr15[];\r
+extern SetWordType zzerr16[];\r
+extern SetWordType zzerr17[];\r
+extern SetWordType zzerr18[];\r
+extern SetWordType zzerr19[];\r
+extern SetWordType zzerr20[];\r
+extern SetWordType zzerr21[];\r
+extern SetWordType setwd4[];\r
+extern SetWordType zzerr22[];\r
+extern SetWordType zzerr23[];\r
+extern SetWordType zzerr24[];\r
+extern SetWordType zzerr25[];\r
+extern SetWordType zzerr26[];\r
+extern SetWordType setwd5[];\r
+extern SetWordType zzerr27[];\r
+extern SetWordType zzerr28[];\r
+extern SetWordType zzerr29[];\r
+extern SetWordType zzerr30[];\r
+extern SetWordType zzerr31[];\r
+extern SetWordType zzerr32[];\r
+extern SetWordType zzerr33[];\r
+extern SetWordType setwd6[];\r
+extern SetWordType zzerr34[];\r
+extern SetWordType zzerr35[];\r
+extern SetWordType zzerr36[];\r
+extern SetWordType zzerr37[];\r
+extern SetWordType zzerr38[];\r
+extern SetWordType zzerr39[];\r
+extern SetWordType zzerr40[];\r
+extern SetWordType zzerr41[];\r
+extern SetWordType zzerr42[];\r
+extern SetWordType setwd7[];\r
+extern SetWordType zzerr43[];\r
+extern SetWordType zzerr44[];\r
+extern SetWordType zzerr45[];\r
+extern SetWordType zzerr46[];\r
+extern SetWordType zzerr47[];\r
+extern SetWordType zzerr48[];\r
+extern SetWordType zzerr49[];\r
+extern SetWordType zzerr50[];\r
+extern SetWordType zzerr51[];\r
+extern SetWordType zzerr52[];\r
+extern SetWordType zzerr53[];\r
+extern SetWordType setwd8[];\r
+extern SetWordType zzerr54[];\r
+extern SetWordType zzerr55[];\r
+extern SetWordType zzerr56[];\r
+extern SetWordType zzerr57[];\r
+extern SetWordType setwd9[];\r
+extern SetWordType zzerr58[];\r
+extern SetWordType zzerr59[];\r
+extern SetWordType zzerr60[];\r
+extern SetWordType zzerr61[];\r
+extern SetWordType zzerr62[];\r
+extern SetWordType zzerr63[];\r
+extern SetWordType zzerr64[];\r
+extern SetWordType zzerr65[];\r
+extern SetWordType setwd10[];\r
+extern SetWordType setwd11[];\r
diff --git a/Tools/CodeTools/Source/Pccts/build.xml b/Tools/CodeTools/Source/Pccts/build.xml
new file mode 100644 (file)
index 0000000..4f4e0a9
--- /dev/null
@@ -0,0 +1,50 @@
+<?xml version="1.0" ?>\r
+<!--\r
+Copyright (c) 2006, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+-->\r
+<project default="GenTool" basedir=".">\r
+<!--\r
+    EDK Pccts Tool\r
+  Copyright (c) 2006, Intel Corporation\r
+  <property name="ToolName" value="Pccts"/>\r
+-->\r
+\r
+  <taskdef resource="cpptasks.tasks"/>\r
+  <typedef resource="cpptasks.types"/>\r
+  <taskdef resource="net/sf/antcontrib/antlib.xml"/>\r
+\r
+  <target name="init">\r
+    <echo message="Building the EDK Pccts Tools"/>\r
+  </target>\r
+\r
+  <target name="GenTool" depends="init, Pccts">\r
+    <echo message="The EDK Pccts Tools build has completed!"/>\r
+  </target>\r
+\r
+  <target name="Pccts" depends="init">\r
+    <subant target="" inheritall="true">\r
+       <fileset dir="${PACKAGE_DIR}/Pccts/antlr" includes="build.xml"/>\r
+    </subant>\r
+    <subant target="" inheritall="true">\r
+      <fileset dir="${PACKAGE_DIR}/Pccts/dlg" includes="build.xml"/>\r
+    </subant>\r
+  </target>\r
+\r
+  <target name="clean">\r
+    <ant dir="${PACKAGE_DIR}/Pccts/antlr" target="clean" inheritAll="true"/>\r
+    <ant dir="${PACKAGE_DIR}/Pccts/dlg" target="clean" inheritAll="true"/>\r
+  </target>\r
+\r
+  <target name="cleanall">\r
+    <ant dir="${PACKAGE_DIR}/Pccts/antlr" target="cleanall" inheritAll="true"/>\r
+    <ant dir="${PACKAGE_DIR}/Pccts/dlg" target="cleanall" inheritAll="true"/>\r
+  </target>\r
+\r
+</project>\r
diff --git a/Tools/CodeTools/Source/Pccts/dlg/DlgMS.mak b/Tools/CodeTools/Source/Pccts/dlg/DlgMS.mak
new file mode 100644 (file)
index 0000000..4a9019b
--- /dev/null
@@ -0,0 +1,121 @@
+# PCCTS directory\r
+\r
+# You will need to set the LIB variable similar to this.\r
+# LIB="C:/Program Files/Microsoft Visual Studio .NET 2003/Vc7/lib;c:/Microsoft Visual Studio .NET 2003/Vc7/PlatformSDK/Lib"\r
+\r
+# PCCTS_HOME=<your PCCTS_HOME>\r
+PCCTS_HOME=$(WORKSPACE)\Tools\Source\TianoTools\Pccts\r
+DLG_SRC=$(PCCTS_HOME)\dlg\r
+PCCTS_H=$(PCCTS_HOME)\h\r
+\r
+\r
+# Support directories\r
+SET=$(PCCTS_HOME)\support\set\r
+\r
+\r
+# Compiler stuff\r
+CC = cl\r
+CFLAGS = /nologo -I "." -I "$(PCCTS_H)" -I "$(SET)" -D "USER_ZZSYN" -D "PC" \\r
+        -D "ZZLEXBUFSIZE=65536"  /D "LONGFILENAMES" /W3 /Zi\r
+\r
+DLG_OBJS = dlg_p.obj dlg_a.obj main.obj err.obj support.obj \\r
+           output.obj relabel.obj automata.obj\r
+\r
+SUPPORT_OBJS = set.obj\r
+\r
+# Dependencies\r
+\r
+dlg.exe: $(DLG_OBJS) $(SUPPORT_OBJS)\r
+    $(CC) $(CFLAGS) -o dlg.exe $(DLG_OBJS) $(SUPPORT_OBJS)\r
+    del *.obj\r
+    del *.ilk\r
+    del *.pdb\r
+               move dlg.exe $(WORKSPACE)\Tools\bin\.\r
+\r
+dlg_p.obj: $(DLG_SRC)\dlg_p.c \\r
+                                       $(PCCTS_H)\antlr.h \\r
+                                       $(PCCTS_H)\config.h \\r
+                                       $(PCCTS_H)\dlgdef.h \\r
+                                       $(SET)\set.h \\r
+                       $(DLG_SRC)\dlg.h \\r
+                       $(DLG_SRC)\mode.h \\r
+                       $(DLG_SRC)\tokens.h \\r
+\r
+    $(CC) -c $(CFLAGS) $(DLG_SRC)\dlg_p.c\r
+\r
+dlg_a.obj: $(DLG_SRC)\dlg_a.c \\r
+                                       $(PCCTS_H)\antlr.h \\r
+                                       $(PCCTS_H)\config.h \\r
+                                       $(PCCTS_H)\dlgauto.h \\r
+                                       $(PCCTS_H)\dlgdef.h \\r
+                                       $(SET)\set.h \\r
+                       $(DLG_SRC)\dlg.h \\r
+                       $(DLG_SRC)\mode.h \\r
+                       $(DLG_SRC)\tokens.h \\r
+\r
+    $(CC) -c $(CFLAGS) $(DLG_SRC)\dlg_a.c\r
+\r
+main.obj: $(DLG_SRC)\main.c \\r
+                                       $(PCCTS_H)\antlr.h \\r
+                                       $(PCCTS_H)\config.h \\r
+                                       $(PCCTS_H)\dlgdef.h \\r
+                                       $(SET)\set.h \\r
+                       $(DLG_SRC)\dlg.h \\r
+                       $(DLG_SRC)\mode.h \\r
+                       $(DLG_SRC)\stdpccts.h \\r
+                       $(DLG_SRC)\tokens.h \\r
+\r
+    $(CC) -c $(CFLAGS) $(DLG_SRC)\main.c\r
+\r
+err.obj: $(DLG_SRC)\err.c \\r
+                                       $(PCCTS_H)\antlr.h \\r
+                                       $(PCCTS_H)\config.h \\r
+                                       $(PCCTS_H)\dlgdef.h \\r
+                                       $(PCCTS_H)\err.h \\r
+                                       $(SET)\set.h \\r
+                       $(DLG_SRC)\dlg.h \\r
+                       $(DLG_SRC)\tokens.h \\r
+\r
+    $(CC) -c $(CFLAGS) $(DLG_SRC)\err.c\r
+\r
+support.obj: $(DLG_SRC)\support.c \\r
+                                       $(PCCTS_H)\config.h \\r
+                                       $(SET)\set.h \\r
+                       $(DLG_SRC)\dlg.h \\r
+\r
+    $(CC) -c $(CFLAGS) $(DLG_SRC)\support.c\r
+\r
+output.obj: $(DLG_SRC)\output.c \\r
+                                       $(PCCTS_H)\config.h \\r
+                                       $(SET)\set.h \\r
+                       $(DLG_SRC)\dlg.h \\r
+\r
+    $(CC) -c $(CFLAGS) $(DLG_SRC)\output.c\r
+\r
+relabel.obj: $(DLG_SRC)\relabel.c \\r
+                                       $(PCCTS_H)\config.h \\r
+                                       $(SET)\set.h \\r
+                       $(DLG_SRC)\dlg.h \\r
+\r
+    $(CC) -c $(CFLAGS) $(DLG_SRC)\relabel.c\r
+\r
+automata.obj: $(DLG_SRC)\automata.c \\r
+                                       $(PCCTS_H)\config.h \\r
+                                       $(SET)\set.h \\r
+                       $(DLG_SRC)\dlg.h \\r
+\r
+    $(CC) -c $(CFLAGS) $(DLG_SRC)\automata.c\r
+\r
+\r
+set.obj: $(SET)\set.c \\r
+                                       $(PCCTS_H)\config.h \\r
+                                       $(SET)\set.h \\r
+\r
+    $(CC) -c $(CFLAGS) $(SET)\set.c\r
+\r
+clean: \r
+    del *.obj\r
+\r
+distclean:\r
+    del *.obj\r
+    del $(WORKSPACE)\Tools\bin\dlg.exe\r
diff --git a/Tools/CodeTools/Source/Pccts/dlg/DlgPPC.mak b/Tools/CodeTools/Source/Pccts/dlg/DlgPPC.mak
new file mode 100644 (file)
index 0000000..55b643a
--- /dev/null
@@ -0,0 +1,84 @@
+#   File:       dlgPPC.make\r
+#   Target:     dlgPPC\r
+#   Sources:    automata.c\r
+#               dlg_a.c\r
+#               dlg_p.c\r
+#               err.c\r
+#               main.c\r
+#               output.c\r
+#               relabel.c\r
+#               support.c\r
+#               ::support:set:set.c\r
+#   Created:    Sunday, May 17, 1998 11:34:20 PM\r
+#      Author:         Kenji Tanaka\r
+\r
+\r
+MAKEFILE     = dlgPPC.make\r
+Â¥MondoBuildÂ¥ = {MAKEFILE}  # Make blank to avoid rebuilds when makefile is modified\r
+Includes     = Â¶\r
+               -i "::h:" Â¶\r
+               -i "::support:set:"\r
+SymÂ¥PPC      = \r
+ObjDirÂ¥PPC   = ":Obj:"\r
+\r
+PPCCOptions  = {Includes} {SymÂ¥PPC}  -w off -d MPW -d __STDC__=1 -d USER_ZZSYN\r
+\r
+ObjectsÂ¥PPC  = Â¶\r
+               "{ObjDirÂ¥PPC}automata.c.x" Â¶\r
+               "{ObjDirÂ¥PPC}dlg_a.c.x" Â¶\r
+               "{ObjDirÂ¥PPC}dlg_p.c.x" Â¶\r
+               "{ObjDirÂ¥PPC}err.c.x" Â¶\r
+               "{ObjDirÂ¥PPC}main.c.x" Â¶\r
+               "{ObjDirÂ¥PPC}output.c.x" Â¶\r
+               "{ObjDirÂ¥PPC}relabel.c.x" Â¶\r
+               "{ObjDirÂ¥PPC}support.c.x" Â¶\r
+               "{ObjDirÂ¥PPC}set.c.x"\r
+\r
+\r
+dlgPPC Ã„Ä {Â¥MondoBuildÂ¥} {ObjectsÂ¥PPC}\r
+       PPCLink Â¶\r
+               -o {Targ} {SymÂ¥PPC} Â¶\r
+               {ObjectsÂ¥PPC} Â¶\r
+               -t 'MPST' Â¶\r
+               -c 'MPS ' Â¶\r
+               "{SharedLibraries}InterfaceLib" Â¶\r
+               "{SharedLibraries}StdCLib" Â¶\r
+               "{SharedLibraries}MathLib" Â¶\r
+               "{PPCLibraries}StdCRuntime.o" Â¶\r
+               "{PPCLibraries}PPCCRuntime.o" Â¶\r
+               "{PPCLibraries}PPCToolLibs.o"\r
+\r
+\r
+"{ObjDirÂ¥PPC}automata.c.x" Ã„ {Â¥MondoBuildÂ¥} automata.c\r
+       {PPCC} automata.c -o {Targ} {PPCCOptions}\r
+\r
+"{ObjDirÂ¥PPC}dlg_a.c.x" Ã„ {Â¥MondoBuildÂ¥} dlg_a.c\r
+       {PPCC} dlg_a.c -o {Targ} {PPCCOptions}\r
+\r
+"{ObjDirÂ¥PPC}dlg_p.c.x" Ã„ {Â¥MondoBuildÂ¥} dlg_p.c\r
+       {PPCC} dlg_p.c -o {Targ} {PPCCOptions}\r
+\r
+"{ObjDirÂ¥PPC}err.c.x" Ã„ {Â¥MondoBuildÂ¥} err.c\r
+       {PPCC} err.c -o {Targ} {PPCCOptions}\r
+\r
+"{ObjDirÂ¥PPC}main.c.x" Ã„ {Â¥MondoBuildÂ¥} main.c\r
+       {PPCC} main.c -o {Targ} {PPCCOptions}\r
+\r
+"{ObjDirÂ¥PPC}output.c.x" Ã„ {Â¥MondoBuildÂ¥} output.c\r
+       {PPCC} output.c -o {Targ} {PPCCOptions}\r
+\r
+"{ObjDirÂ¥PPC}relabel.c.x" Ã„ {Â¥MondoBuildÂ¥} relabel.c\r
+       {PPCC} relabel.c -o {Targ} {PPCCOptions}\r
+\r
+"{ObjDirÂ¥PPC}support.c.x" Ã„ {Â¥MondoBuildÂ¥} support.c\r
+       {PPCC} support.c -o {Targ} {PPCCOptions}\r
+\r
+"{ObjDirÂ¥PPC}set.c.x" Ã„ {Â¥MondoBuildÂ¥} "::support:set:set.c"\r
+       {PPCC} "::support:set:set.c" -o {Targ} {PPCCOptions}\r
+\r
+\r
+dlgPPC Ã„Ä dlg.r\r
+       Rez dlg.r -o dlgPPC -a\r
+\r
+Install  Ã„ dlgPPC\r
+       Duplicate -y dlgPPC "{MPW}"Tools:dlg\r
diff --git a/Tools/CodeTools/Source/Pccts/dlg/automata.c b/Tools/CodeTools/Source/Pccts/dlg/automata.c
new file mode 100644 (file)
index 0000000..d6d5d78
--- /dev/null
@@ -0,0 +1,353 @@
+/* Automata conversion functions for DLG\r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
+ * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
+ * company may do whatever they wish with source code distributed with\r
+ * PCCTS or the code generated by PCCTS, including the incorporation of\r
+ * PCCTS, or its output, into commerical software.\r
+ *\r
+ * We encourage users to develop software with PCCTS.  However, we do ask\r
+ * that credit is given to us for developing PCCTS.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like PCCTS and have developed a nice tool with the\r
+ * output, please mention that you developed it using PCCTS.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * DLG 1.33\r
+ * Will Cohen\r
+ * With mods by Terence Parr; AHPCRC, University of Minnesota\r
+ * 1989-2001\r
+ */\r
+\r
+#include <stdio.h>\r
+#include "pcctscfg.h"\r
+#include "dlg.h"\r
+#ifdef MEMCHK\r
+#include "trax.h"\r
+#else\r
+#ifdef __STDC__\r
+#include <stdlib.h>\r
+#else\r
+#include <malloc.h>\r
+#endif /* __STDC__ */\r
+#endif\r
+\r
+#define hash_list struct _hash_list_\r
+hash_list{\r
+       hash_list *next;        /* next thing in list */\r
+       dfa_node *node;\r
+ };\r
+\r
+int    dfa_allocated = 0;      /* keeps track of number of dfa nodes */\r
+dfa_node       **dfa_array;    /* root of binary tree that stores dfa array */\r
+dfa_node       *dfa_model_node;\r
+hash_list      *dfa_hash[HASH_SIZE];   /* used to quickly find */\r
+                                       /* desired dfa node */\r
+\r
+void \r
+#ifdef __USE_PROTOS\r
+make_dfa_model_node(int width)\r
+#else\r
+make_dfa_model_node(width)\r
+int width;\r
+#endif\r
+{\r
+       register int i;\r
+       dfa_model_node = (dfa_node*) malloc(sizeof(dfa_node)\r
+                        + sizeof(int)*width);\r
+       dfa_model_node->node_no = -1; /* impossible value for real dfa node */\r
+       dfa_model_node->dfa_set = 0;\r
+       dfa_model_node->alternatives = FALSE;\r
+       dfa_model_node->done = FALSE;\r
+       dfa_model_node->nfa_states = empty;\r
+       for(i = 0; i<width; i++){\r
+               dfa_model_node->trans[i] = NIL_INDEX;\r
+       }\r
+}\r
+\r
+\r
+/* adds a new nfa to the binary tree and returns a pointer to it */\r
+dfa_node *\r
+#ifdef __USE_PROTOS\r
+new_dfa_node(set nfa_states)\r
+#else\r
+new_dfa_node(nfa_states)\r
+set nfa_states;\r
+#endif\r
+{\r
+       register int j;\r
+       register dfa_node *t;\r
+       static int dfa_size=0;  /* elements dfa_array[] can hold */\r
+\r
+       ++dfa_allocated;\r
+       if (dfa_size<=dfa_allocated){\r
+               /* need to redo array */\r
+               if (!dfa_array){\r
+                       /* need some to do inital allocation */\r
+                       dfa_size=dfa_allocated+DFA_MIN;\r
+                       dfa_array=(dfa_node **) malloc(sizeof(dfa_node*)*\r
+                               dfa_size);\r
+               }else{\r
+                       /* need more space */\r
+                       dfa_size=2*(dfa_allocated+1);\r
+                       dfa_array=(dfa_node **) realloc(dfa_array,\r
+                               sizeof(dfa_node*)*dfa_size);\r
+               }\r
+       }\r
+       /* fill out entry in array */\r
+       t = (dfa_node*) malloc(sizeof(nfa_node)+sizeof(int)*class_no);\r
+       *t = *dfa_model_node;\r
+       for (j=0; j<class_no; ++j)\r
+               t->trans[j] = NIL_INDEX;\r
+       t->node_no = dfa_allocated;\r
+       t->nfa_states = set_dup(nfa_states);\r
+       dfa_array[dfa_allocated] = t;\r
+       return t;\r
+}\r
+\r
+\r
+/* past a pointer to the start start of the nfa graph\r
+ * nfa_to_dfa convers this graph to dfa.  The function returns\r
+ * a pointer to the first dfa state.\r
+ * NOTE:  The function that prints out the table will have to figure out how\r
+ * to find the other dfa states given the first dfa_state and the number of dfa\r
+ * nodes allocated\r
+ */\r
+dfa_node **\r
+#ifdef __USE_PROTOS\r
+nfa_to_dfa(nfa_node *start)\r
+#else\r
+nfa_to_dfa(start)\r
+nfa_node *start;\r
+#endif\r
+{\r
+       register dfa_node *d_state, *trans_d_state;\r
+       register int a;\r
+       set t;\r
+       int last_done;\r
+       unsigned *nfa_list;\r
+       unsigned *reach_list;\r
+\r
+       reach_list = (unsigned *) malloc((2+nfa_allocated)*sizeof(unsigned));\r
+       if (!start) return NULL;\r
+       t = set_of(NFA_NO(start));\r
+       _set_pdq(t,reach_list);\r
+       closure(&t,reach_list);\r
+       /* Make t a dfa state */\r
+       d_state = dfastate(t);\r
+       last_done = DFA_NO(d_state);\r
+       \r
+       do {\r
+               /* Mark dfa state x as "done" */\r
+               d_state->done = TRUE;\r
+               nfa_list = set_pdq(d_state->nfa_states);\r
+               for (a = 0; a<class_no; ++a) {\r
+                       /* Add NFA states reached by a from d_state */\r
+                       reach(nfa_list,a,reach_list);\r
+                       /* Were any states found? */\r
+                       if ((*reach_list)!=nil) {\r
+                               /* was t=empty; */\r
+                               set_free(t);\r
+                               /* yes, compute closure */\r
+                               closure(&t,reach_list);\r
+                               /* Make DFA state of it ... */\r
+                               trans_d_state = dfastate(t);\r
+                               /* And make transition x->t, labeled with a */\r
+                               d_state->trans[a] = DFA_NO(trans_d_state);\r
+                               d_state->alternatives = TRUE;\r
+                       }\r
+               }\r
+               free(nfa_list);\r
+               ++last_done; /* move forward in queue */\r
+               /* And so forth until nothing isn't done */\r
+               d_state = DFA(last_done);\r
+       } while (last_done<=dfa_allocated);\r
+\r
+       free(reach_list);\r
+       set_free(t);\r
+\r
+       /* returns pointer to the array that holds the automaton */\r
+       return dfa_array;\r
+}\r
+\r
+void \r
+#ifdef __USE_PROTOS\r
+clear_hash(void)\r
+#else\r
+clear_hash()\r
+#endif\r
+{\r
+       register int i;\r
+\r
+       for(i=0; i<HASH_SIZE; ++i)\r
+               dfa_hash[i] = 0;\r
+}\r
+\r
+#if HASH_STAT\r
+void\r
+#ifdef __USE_PROTOS\r
+fprint_hash_stats(FILE *f)\r
+#else\r
+fprint_hash_stats(f)\r
+FILE *f;\r
+#endif\r
+{\r
+       register hash_list *p;\r
+       register int i,j;\r
+       register total;\r
+\r
+       total=0;\r
+       for(i=0; i<HASH_SIZE; ++i){\r
+               j=0;\r
+               p = dfa_hash[i];\r
+               while(p){\r
+                       ++j;\r
+                       p = p->next;\r
+               }\r
+               total+=j;\r
+               fprintf(f,"bin[%d] has %d\n",i,j);\r
+       }\r
+       fprintf(f,"total = %d\n",total);\r
+}\r
+#endif\r
+\r
+/* Returns a pointer to a dfa node that has the same nfa nodes in it.\r
+ * This may or maynot be a newly created node.\r
+ */\r
+dfa_node *\r
+#ifdef __USE_PROTOS\r
+dfastate(set nfa_states)\r
+#else\r
+dfastate(nfa_states)\r
+set nfa_states;\r
+#endif\r
+{\r
+       register hash_list *p;\r
+       int bin;\r
+\r
+       /* hash using set and see if it exists */\r
+       bin = set_hash(nfa_states,HASH_SIZE);\r
+       p = dfa_hash[bin];\r
+       while(p && !set_equ(nfa_states,(p->node)->nfa_states)){\r
+               p = p->next;\r
+       }\r
+       if(!p){\r
+               /* next state to add to hash table */\r
+               p = (hash_list*)malloc(sizeof(hash_list));\r
+               p->node = new_dfa_node(nfa_states);\r
+               p->next = dfa_hash[bin];\r
+               dfa_hash[bin] = p;\r
+       }\r
+       return (p->node);\r
+}\r
+\r
+\r
+/* this reach assumes the closure has been done already on set */\r
+int \r
+#ifdef __USE_PROTOS\r
+reach(unsigned *nfa_list, register int a, unsigned *reach_list)\r
+#else\r
+reach(nfa_list, a, reach_list)\r
+unsigned *nfa_list;\r
+register int a;\r
+unsigned *reach_list;\r
+#endif\r
+{\r
+       register unsigned *e;\r
+       register nfa_node *node;\r
+       int t=0;\r
+\r
+       e = nfa_list;\r
+       if (e){\r
+               while (*e != nil){\r
+                       node = NFA(*e);\r
+                       if (set_el(a,node->label)){\r
+                               t=1;\r
+                               *reach_list=NFA_NO(node->trans[0]);\r
+                               ++reach_list;\r
+                       }\r
+                       ++e;\r
+               }\r
+       }\r
+       *reach_list=nil;\r
+       return t;\r
+}\r
+\r
+/* finds all the nodes that can be reached by epsilon transitions\r
+   from the set of a nodes and returns puts them back in set b */\r
+set \r
+#ifdef __USE_PROTOS\r
+closure(set *b, unsigned *reach_list)\r
+#else\r
+closure(b, reach_list)\r
+set *b;\r
+unsigned *reach_list;\r
+#endif\r
+{\r
+       register nfa_node *node,*n;     /* current node being examined */\r
+       register unsigned *e;\r
+\r
+       ++operation_no;\r
+#if 0\r
+       t = e = set_pdq(*b);\r
+#else\r
+       e=reach_list;\r
+#endif\r
+       while (*e != nil){\r
+               node = NFA(*e);\r
+               set_orel(NFA_NO(node),b);\r
+               /* mark it done */\r
+               node->nfa_set = operation_no;\r
+               if ((n=node->trans[0]) != NIL_INDEX && set_nil(node->label) &&\r
+                 (n->nfa_set != operation_no)){\r
+                       /* put in b */\r
+                       set_orel(NFA_NO(n),b);\r
+                       close1(n,operation_no,b);\r
+               }\r
+               if ((n=node->trans[1]) != NIL_INDEX &&\r
+                 (n->nfa_set != operation_no)){\r
+                       /* put in b */\r
+                       set_orel(NFA_NO(node->trans[1]),b);\r
+                       close1(n,operation_no,b);\r
+               }\r
+               ++e;\r
+       }\r
+#if 0\r
+       free(t);\r
+#endif\r
+       return *b;\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+void close1(nfa_node *node, int o, set *b)\r
+#else\r
+void close1(node,o,b)\r
+nfa_node *node;\r
+int o; /* marker to avoid cycles */\r
+set *b;\r
+#endif\r
+{\r
+       register nfa_node *n;   /* current node being examined */\r
+\r
+       /* mark it done */\r
+       node->nfa_set = o;\r
+       if ((n=node->trans[0]) != NIL_INDEX && set_nil(node->label) &&\r
+         (n->nfa_set != o)){\r
+               /* put in b */\r
+               set_orel(NFA_NO(n),b);\r
+               close1(n,o,b);\r
+       }\r
+       if ((n=node->trans[1]) != NIL_INDEX &&\r
+         (n->nfa_set != o)){\r
+               /* put in b */\r
+               set_orel(NFA_NO(node->trans[1]),b);\r
+               close1(n,o,b);\r
+       }\r
+}\r
diff --git a/Tools/CodeTools/Source/Pccts/dlg/build.xml b/Tools/CodeTools/Source/Pccts/dlg/build.xml
new file mode 100644 (file)
index 0000000..4195950
--- /dev/null
@@ -0,0 +1,121 @@
+<?xml version="1.0" ?>\r
+<!--\r
+Copyright (c) 2006, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+-->\r
+<project default="GenTool" basedir=".">\r
+<!--\r
+    EDK Pccts Tool: dlg\r
+  Copyright (c) 2006, Intel Corporation\r
+-->\r
+  <property name="ToolName" value="dlg"/>\r
+\r
+  <taskdef resource="cpptasks.tasks"/>\r
+  <typedef resource="cpptasks.types"/>\r
+  <taskdef resource="net/sf/antcontrib/antlib.xml"/>\r
+\r
+  <property name="PACKAGE_DIR" value="${WORKSPACE}/Tools"/>\r
+\r
+  <target name="init">\r
+               <condition property="CheckDepends">\r
+                 <uptodate targetfile="${WORKSPACE}/Tools/bin/dlg.exe">\r
+                         <srcfiles dir="." includes="*.c *.h *.g"/>\r
+                       </uptodate>\r
+               </condition>\r
+               <if>\r
+                 <equals arg1="${CheckDepends}" arg2="true"/>\r
+                       <then>\r
+                               <echo message="Executable, dlg.exe, is up to date."/>\r
+                       </then>\r
+      <else>\r
+        <echo message="Building the EDK Pccts Tool: ${ToolName}"/>\r
+      </else>\r
+               </if>\r
+  </target>\r
+\r
+  <target name="GenTool" depends="init" unless="CheckDepends">\r
+    <if>\r
+      <equals arg1="${ToolChain}" arg2="msvc"/>\r
+                       <then>\r
+         <exec dir="${PACKAGE_DIR}/Pccts/dlg" executable="nmake" failonerror="TRUE">\r
+                 <arg line="-f DlgMS.mak"/>\r
+               </exec>\r
+                 </then>\r
+               <elseif>\r
+      <istrue value="${cygwin}"/>\r
+      <then>\r
+         <exec dir="${PACKAGE_DIR}/Pccts/dlg" executable="make" failonerror="TRUE">\r
+                 <arg line="-f makefile.cygwin"/>\r
+               </exec>\r
+      </then>\r
+    </elseif>\r
+               <elseif>\r
+      <equals arg1="${ToolChain}" arg2="gcc"/>\r
+                       <then>\r
+         <exec dir="${PACKAGE_DIR}/Pccts/dlg" executable="make" failonerror="TRUE">\r
+                 <arg line="-f makefile BIN_DIR=${BIN_DIR}"/>\r
+               </exec>\r
+                 </then>\r
+               </elseif>\r
+               </if>\r
+    <echo message="The EDK Tool: ${ToolName} build has completed!"/>\r
+       </target>\r
+\r
+  <target name="clean">\r
+    <echo message="Removing Intermediate Files Only"/>  \r
+    <if>\r
+      <equals arg1="${ToolChain}" arg2="msvc"/>\r
+                       <then>\r
+         <exec dir="${PACKAGE_DIR}/Pccts/dlg" executable="nmake" failonerror="TRUE">\r
+                 <arg line="-f DlgMS.mak clean"/>\r
+               </exec>\r
+                 </then>\r
+    <elseif>\r
+      <istrue value="${cygwin}"/>\r
+      <then>\r
+         <exec dir="${PACKAGE_DIR}/Pccts/dlg" executable="make" failonerror="TRUE">\r
+                 <arg line="-f makefile.cygwin clean"/>\r
+               </exec>\r
+      </then>\r
+               </elseif>\r
+               <elseif>\r
+      <equals arg1="${ToolChain}" arg2="gcc"/>\r
+                       <then>\r
+         <exec dir="${PACKAGE_DIR}/Pccts/dlg" executable="make" failonerror="TRUE">\r
+                 <arg line="-f makefile clean"/>\r
+               </exec>\r
+                 </then>\r
+               </elseif>\r
+               </if>\r
+  </target>\r
+\r
+  <target name="cleanall">\r
+    <echo message="Removing Object Files and the Executable: ${ToolName}${ext_exe}"/>  \r
+    <if>\r
+      <equals arg1="${ToolChain}" arg2="msvc"/>\r
+                       <then>\r
+         <exec dir="${PACKAGE_DIR}/Pccts/dlg" executable="nmake" failonerror="FALSE">\r
+                 <arg line="-f DlgMS.mak clean"/>\r
+               </exec>\r
+                 </then>\r
+               <elseif>\r
+      <equals arg1="${ToolChain}" arg2="gcc"/>\r
+                       <then>\r
+         <exec dir="${PACKAGE_DIR}/Pccts/dlg" executable="make" failonerror="FALSE">\r
+                 <arg line="-f makefile clean"/>\r
+               </exec>\r
+                 </then>\r
+               </elseif>\r
+               </if>\r
+    <delete failonerror="false" quiet="true" includeEmptyDirs="true">\r
+      <fileset file="${BIN_DIR}/${ToolName}${ext_exe}"/>\r
+    </delete>\r
+  </target>\r
+\r
+</project>\r
diff --git a/Tools/CodeTools/Source/Pccts/dlg/dlg.1 b/Tools/CodeTools/Source/Pccts/dlg/dlg.1
new file mode 100644 (file)
index 0000000..f68e3ae
--- /dev/null
@@ -0,0 +1,79 @@
+.TH dlg 1 "April 1994" "DLG" "PCCTS Manual Pages"\r
+.SH NAME\r
+dlg \- DFA Lexical Analyzer Generator\r
+.SH SYNTAX\r
+.LP\r
+\fBdlg\fR [\fIoptions\fR] \fIlexical_spec\fR [\fIoutput_file\fR]\r
+.SH DESCRIPTION\r
+.B dlg\r
+is a tool that produces fast deterministic finite automata for recognizing\r
+regular expressions in input.\r
+.SH OPTIONS\r
+.IP "\fB-CC\fR"\r
+Generate C++ output.  The \fIoutput_file\fP is not specified in this\r
+case.\r
+.IP "\fB-C\fR[\fP level\fR]\r
+Where \fPlevel\fR is the compression level used.  0 indications no\r
+compression, 1 removes all unused characters from the transition from table,\r
+and 2 maps equivalent characters into the same character classes.  It is\r
+suggested that level -C2 is used, since it will significantly reduce the size\r
+of the dfa produced for lexical analyzer.\r
+.IP "\fB-m\fP\r
+Produces the header file for the lexical mode with a name other than\r
+the default name of "mode.h".\r
+.IP \fB-i\fP\r
+An interactive, or as interactive as possible, parser is produced.  A character\r
+is only obtained when required to decide which state to go to.  Some care\r
+must be taken to obtain accept states that do not require look ahead at the\r
+next character to determine if that is the stop state.  Any regular expression\r
+with a Kleene closure at the end is guaranteed to require another character\r
+of look ahead.\r
+.IP "\fB-cl\fP class\r
+Specify a class name for DLG to generate.  The default is DLGLexer.\r
+'class' will be a subclass of DLGLexerBase; only used for -CC.\r
+.IP \fB-ci\fP\r
+The automaton will treat upper and lower case characters identically.\r
+This is accomplished in the automaton; the characters in the lexical\r
+buffer are unmodified.\r
+.IP \fB-cs\fP\r
+Upper and lower case characters are treated as distinct.  This is the\r
+default.\r
+.IP "\fB-o\fP dir\r
+Directory where output files should go (default=".").  This is very\r
+nice for keeping the source directory clear of ANTLR and DLG spawn.\r
+.IP \fB-Wambiguity\fP\r
+Warns if more than one regular expression could match the same character\r
+sequence.  The warnings give the numbers of the expressions in the dlg\r
+lexical specification file.  The numbering of the expressions starts at one.\r
+Multiple warnings may be print for the same expressions.\r
+.IP \-\r
+Used in place of file names to get input from standard in or send output\r
+to standard out.\r
+.SH "SPECIAL CONSIDERATIONS"\r
+.PP\r
+\fIDlg\fP works...  we think.  There is no implicit guarantee of\r
+anything.  We reserve no \fBlegal\fP rights to the software known as\r
+the Purdue Compiler Construction Tool Set (PCCTS) \(em PCCTS is in the\r
+public domain.  An individual or company may do whatever they wish\r
+with source code distributed with PCCTS or the code generated by\r
+PCCTS, including the incorporation of PCCTS, or its output, into\r
+commercial software.  We encourage users to develop software with\r
+PCCTS.  However, we do ask that credit is given to us for developing\r
+PCCTS.  By "credit", we mean that if you incorporate our source code\r
+into one of your programs (commercial product, research project, or\r
+otherwise) that you acknowledge this fact somewhere in the\r
+documentation, research report, etc...  If you like PCCTS and have\r
+developed a nice tool with the output, please mention that you\r
+developed it using PCCTS.  As long as these guidelines are followed, we\r
+expect to continue enhancing this system and expect to make other\r
+tools available as they are completed.\r
+.SH FILES\r
+.B mode.h\r
+,\r
+.B dlgauto.h\r
+,\r
+.B dlgdef.h\r
+.SH SEE ALSO\r
+.BR antlr (1),\r
+.BR pccts (1)\r
+.SH BUGS\r
diff --git a/Tools/CodeTools/Source/Pccts/dlg/dlg.h b/Tools/CodeTools/Source/Pccts/dlg/dlg.h
new file mode 100644 (file)
index 0000000..9f387c0
--- /dev/null
@@ -0,0 +1,250 @@
+/* dlg header file\r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
+ * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
+ * company may do whatever they wish with source code distributed with\r
+ * PCCTS or the code generated by PCCTS, including the incorporation of\r
+ * PCCTS, or its output, into commerical software.\r
+ *\r
+ * We encourage users to develop software with PCCTS.  However, we do ask\r
+ * that credit is given to us for developing PCCTS.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like PCCTS and have developed a nice tool with the\r
+ * output, please mention that you developed it using PCCTS.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * DLG 1.33\r
+ * Will Cohen\r
+ * With mods by Terence Parr; AHPCRC, University of Minnesota\r
+ * 1989-2001\r
+ */\r
+\r
+/* MR1 Move pcctscfg.h to top of file                                  */\r
+\r
+#include "pcctscfg.h"                                          \r
+\r
+/* turn off warnings for unreferenced labels */\r
+\r
+#ifdef _MSC_VER\r
+#pragma warning(disable:4102)\r
+#endif\r
+\r
+#include "set.h"\r
+\r
+#define TRUE   1\r
+#define FALSE  0\r
+\r
+/***** output related stuff *******************/\r
+#define IN     input_stream\r
+#define OUT    output_stream\r
+\r
+#define MAX_MODES      50      /* number of %%names allowed */\r
+#define MAX_ON_LINE    10\r
+\r
+#define NFA_MIN                64      /* minimum nfa_array size */\r
+#define DFA_MIN                64      /* minimum dfa_array size */\r
+\r
+#define DEFAULT_CLASSNAME "DLGLexer"\r
+\r
+/* these macros allow the size of the character set to be easily changed */\r
+/* NOTE: do NOT change MIN_CHAR since EOF is the lowest char, -1 */\r
+#define MIN_CHAR (-1)  /* lowest possible character possible on input */\r
+#define MAX_CHAR 255   /* highest possible character possible on input */\r
+#define CHAR_RANGE (1+(MAX_CHAR) - (MIN_CHAR))\r
+\r
+/* indicates that the not an "array" reference */\r
+#define NIL_INDEX 0\r
+\r
+/* size of hash table used to find dfa_states quickly */\r
+#define HASH_SIZE 211\r
+\r
+#define nfa_node struct _nfa_node\r
+nfa_node {\r
+       int             node_no;\r
+       int             nfa_set;\r
+       int             accept; /* what case to use */\r
+       nfa_node        *trans[2];\r
+       set             label;  /* one arc always labelled with epsilon */\r
+};\r
+\r
+#define dfa_node struct _dfa_node\r
+dfa_node {\r
+       int             node_no;\r
+       int             dfa_set;\r
+       int             alternatives;   /* used for interactive mode */\r
+                                       /* are more characters needed */\r
+       int             done;\r
+       set             nfa_states;\r
+       int             trans[1];/* size of transition table depends on\r
+                                 * number of classes required for automata.\r
+                                 */\r
+\r
+\r
+};\r
+\r
+/******** macros for accessing the NFA and DFA nodes ****/\r
+#define NFA(x) (nfa_array[x])\r
+#define DFA(x) (dfa_array[x])\r
+#define DFA_NO(x) ( (x) ? (x)->node_no : NIL_INDEX)\r
+#define NFA_NO(x) ( (x) ? (x)->node_no : NIL_INDEX)\r
+\r
+/******** wrapper for memory checking ***/\r
+/*#define malloc(x)    dlg_malloc((x),__FILE__,__LINE__)*/\r
+\r
+/*#define calloc(x,y)  dlg_calloc((x),(y),__FILE__,__LINE__)*/\r
+\r
+/******** antlr attributes *************/\r
+typedef struct {\r
+       unsigned char letter;\r
+       nfa_node *l,*r;\r
+       set label;\r
+       } Attrib;\r
+\r
+#define zzcr_attr(attr, token, text) {                                 \\r
+       (attr)->letter = text[0]; (attr)->l = NULL;                     \\r
+       (attr)->r = NULL; (attr)->label = empty;                        \\r
+}\r
+#define zzd_attr(a)    set_free((a)->label);\r
+\r
+/******************** Variable ******************************/\r
+extern char    program[];      /* tells what program this is */\r
+extern char    version[];      /* tells what version this is */\r
+extern char    *file_str[];    /* file names being used */\r
+extern int     err_found;      /* flag to indicate error occured */\r
+extern int     action_no;      /* last action function printed */\r
+extern int     func_action;    /* should actions be turned into functions?*/\r
+extern set     used_chars;     /* used to label trans. arcs */\r
+extern set     used_classes;   /* classes or chars used to label trans. arcs */\r
+extern int     class_no;       /* number of classes used */\r
+extern set     class_sets[];   /* shows char. in each class */\r
+extern set     normal_chars;   /* mask off unused portion of set */\r
+extern int     comp_level;     /* what compression level to use */\r
+extern int     interactive;    /* interactive scanner (avoid lookahead)*/\r
+extern int     mode_counter;   /* keeps track of the number of %%name */\r
+extern int     dfa_basep[];    /* start of each group of dfa */\r
+extern int     dfa_class_nop[];/* number of transistion arcs in */\r
+                               /* each dfa in each mode */\r
+extern int     nfa_allocated;\r
+extern int     dfa_allocated;\r
+extern nfa_node        **nfa_array;    /* start of nfa "array" */\r
+extern dfa_node        **dfa_array;    /* start of dfa "array" */\r
+extern int     operation_no;   /* unique number for each operation */\r
+extern FILE    *input_stream;  /* where description read from */\r
+extern FILE    *output_stream; /* where to put the output */\r
+extern FILE    *mode_stream;   /* where to put the mode output */\r
+extern FILE    *class_stream;\r
+extern char    *mode_file;     /* name of file for mode output */\r
+extern int     gen_ansi;       /* produce ansi compatible code */\r
+extern int     case_insensitive;/* ignore case of input spec. */\r
+extern int     warn_ambig;     /* show if regular expressions ambiguous */\r
+extern int     gen_cpp;\r
+extern char *cl_file_str;\r
+extern int     firstLexMember; /* MR1 */\r
+extern char *OutputDirectory;\r
+extern char    *class_name;\r
+\r
+/******************** Functions ******************************/\r
+#ifdef __USE_PROTOS\r
+extern char    *dlg_malloc(int, char *, int); /* wrapper malloc */\r
+extern char    *dlg_calloc(int, int, char *, int); /* wrapper calloc */\r
+extern int     reach(unsigned *, register int, unsigned *);\r
+extern set     closure(set *, unsigned *);\r
+extern dfa_node *new_dfa_node(set);\r
+extern nfa_node *new_nfa_node(void);\r
+extern dfa_node *dfastate(set);\r
+extern dfa_node **nfa_to_dfa(nfa_node *);\r
+extern void    internal_error(char *, char *, int);    /* MR9 23-Sep-97 */\r
+extern FILE    *read_stream(char *);   /* opens file for reading */\r
+extern FILE    *write_stream(char *);  /* opens file for writing */\r
+extern void    make_nfa_model_node(void);\r
+extern void    make_dfa_model_node(int);\r
+extern char *ClassName(char *);\r
+extern char *OutMetaName(char *);\r
+extern void error(char*, int);\r
+extern void warning(char*, int);\r
+extern void p_head(void);\r
+extern void p_class_hdr(void);\r
+extern void p_includes(void);\r
+extern void p_tables(void);\r
+extern void p_tail(void);                                      /* MR1 */\r
+extern void p_class_def1(void);                                /* MR1 */\r
+extern void new_automaton_mode(void);                  /* MR1 */\r
+extern int  relabel(nfa_node *,int);                   /* MR1 */\r
+extern void p_shift_table(int);                                /* MR1 */\r
+extern void p_bshift_table(void);                              /* MR1 */\r
+extern void p_class_table(void);                               /* MR1 */\r
+extern void p_mode_def(char *,int);                    /* MR1 */\r
+extern void init(void);                                        /* MR1 */\r
+extern void p_class_def2(void);                                /* MR1 */\r
+extern void clear_hash(void);                          /* MR1 */\r
+extern void p_alternative_table(void);                 /* MR1 */\r
+extern void p_node_table(void);                                /* MR1 */\r
+extern void p_dfa_table(void);                         /* MR1 */\r
+extern void p_accept_table(void);                              /* MR1 */\r
+extern void p_action_table(void);                              /* MR1 */\r
+extern void p_base_table(void);                                /* MR1 */\r
+extern void p_single_node(int,int);                    /* MR1 */\r
+extern char * minsize(int);                            /* MR1 */\r
+extern void close1(nfa_node *,int,set *);              /* MR1 */\r
+extern void partition(nfa_node *,int);                 /* MR1 */\r
+extern void intersect_nfa_labels(nfa_node *,set *);    /* MR1 */\r
+extern void r_intersect(nfa_node *,set *);             /* MR1 */\r
+extern void label_node(nfa_node *);                    /* MR1 */\r
+extern void label_with_classes(nfa_node *);            /* MR1 */\r
+\r
+#else\r
+extern char *dlg_malloc();     /* wrapper malloc */\r
+extern char *dlg_calloc();     /* wrapper calloc */\r
+extern int     reach();\r
+extern set     closure();\r
+extern dfa_node *new_dfa_node();\r
+extern nfa_node *new_nfa_node();\r
+extern dfa_node *dfastate();\r
+extern dfa_node **nfa_to_dfa();\r
+extern void    internal_error();   /* MR9 23-Sep-97 */\r
+extern FILE    *read_stream();         /* opens file for reading */\r
+extern FILE    *write_stream();        /* opens file for writing */\r
+extern void    make_nfa_model_node();\r
+extern void    make_dfa_model_node();\r
+extern char *ClassName();\r
+extern char *OutMetaName();\r
+extern void error();\r
+extern void warning();\r
+extern void p_head();                   /* MR9 */\r
+extern void p_class_hdr();              /* MR9 */\r
+extern void p_includes();               /* MR9 */\r
+extern void p_tables();                 /* MR9 */\r
+extern void p_tail();                                  /* MR1 */\r
+extern void p_class_def1();                            /* MR1 */\r
+extern void new_automaton_mode();                      /* MR1 */\r
+extern int  relabel();                                 /* MR1 */\r
+extern void p_shift_table();                           /* MR1 */\r
+extern void p_bshift_table();                          /* MR1 */\r
+extern void p_class_table();                           /* MR1 */\r
+extern void p_mode_def();                              /* MR1 */\r
+extern void init();                                    /* MR1 */\r
+extern void p_class_def2();                            /* MR1 */\r
+extern void clear_hash();                              /* MR1 */\r
+extern void p_alternative_table();                     /* MR1 */\r
+extern void p_node_table();                            /* MR1 */\r
+extern void p_dfa_table();                             /* MR1 */\r
+extern void p_accept_table();                          /* MR1 */\r
+extern void p_action_table();                          /* MR1 */\r
+extern void p_base_table();                            /* MR1 */\r
+extern void p_single_node();                           /* MR1 */\r
+extern char * minsize();                               /* MR1 */\r
+extern void close1();                                  /* MR1 */\r
+extern void partition();                               /* MR1 */\r
+extern void intersect_nfa_labels();                    /* MR1 */\r
+extern void r_intersect();                             /* MR1 */\r
+extern void label_node();                              /* MR1 */\r
+extern void label_with_classes();                      /* MR1 */\r
+\r
+#endif\r
diff --git a/Tools/CodeTools/Source/Pccts/dlg/dlg.r b/Tools/CodeTools/Source/Pccts/dlg/dlg.r
new file mode 100644 (file)
index 0000000..c5311fa
--- /dev/null
@@ -0,0 +1,275 @@
+/*\r
+       File:           dlgMPW.r\r
+       Target:         dlg 133MR\r
+       Created:    Monday, June 15, 1998 4:44:11 AM\r
+       Author:         Kenji Tanaka (kentar@osa.att.ne.jp)\r
+*/\r
+\r
+#include "cmdo.r"\r
+\r
+resource 'cmdo' (128, "Dlg") {\r
+       {       /* array dialogs: 1 elements */\r
+               /* [1] */\r
+               295,\r
+               "DLG -- Purdue Compiler Construction Tool"\r
+               " Set (PCCTS) lexical analyzer generator.",\r
+               {       /* array itemArray: 18 elements */\r
+                       /* [1] */\r
+                       NotDependent {\r
+\r
+                       },\r
+                       CheckOption {\r
+                               NotSet,\r
+                               {35, 175, 50, 225},\r
+                               "On",\r
+                               "-CC",\r
+                               "When this control is checked, DLG genera"\r
+                               "tes a scanner using C++ classes rather t"\r
+                               "han C functions."\r
+                       },\r
+                       /* [2] */\r
+                       Or {\r
+                               {       /* array OrArray: 1 elements */\r
+                                       /* [1] */\r
+                                       1\r
+                               }\r
+                       },\r
+                       RegularEntry {\r
+                               "Lexer Class Name:",\r
+                               {35, 225, 50, 355},\r
+                               {35, 355, 51, 450},\r
+                               "DLGLexer",\r
+                               keepCase,\r
+                               "-cl",\r
+                               "This entry specifies the name DLG uses f"\r
+                               "or the C++ lexer class."\r
+                       },\r
+                       /* [3] */\r
+                       NotDependent {\r
+\r
+                       },\r
+                       TextBox {\r
+                               gray,\r
+                               {25, 165, 60, 460},\r
+                               "C++ Code Generation"\r
+                       },\r
+                       /* [4] */\r
+                       NotDependent {\r
+\r
+                       },\r
+                       Files {\r
+                               InputFile,\r
+                               RequiredFile {\r
+                                       {37, 25, 56, 135},\r
+                                       "Input File",\r
+                                       "",\r
+                                       "Choose the lexical description file for "\r
+                                       "DLG to process."\r
+                               },\r
+                               Additional {\r
+                                       "",\r
+                                       "",\r
+                                       "",\r
+                                       "",\r
+                                       {       /* array TypesArray: 1 elements */\r
+                                               /* [1] */\r
+                                               text\r
+                                       }\r
+                               }\r
+                       },\r
+                       /* [5] */\r
+                       Or {\r
+                               {       /* array OrArray: 1 elements */\r
+                                       /* [1] */\r
+                                       -1\r
+                               }\r
+                       },\r
+                       Files {\r
+                               OutputFile,\r
+                               RequiredFile {\r
+                                       {66, 25, 85, 135},\r
+                                       "Output File",\r
+                                       "",\r
+                                       "Choose the name of the file that will ho"\r
+                                       "ld the DLG-produced scanner."\r
+                               },\r
+                               NoMore {\r
+\r
+                               }\r
+                       },\r
+                       /* [6] */\r
+                       Or {\r
+                               {       /* array OrArray: 2 elements */\r
+                                       /* [1] */\r
+                                       1,\r
+                                       /* [2] */\r
+                                       5\r
+                               }\r
+                       },\r
+                       Dummy {\r
+\r
+                       },\r
+                       /* [7] */\r
+                       NotDependent {\r
+\r
+                       },\r
+                       Redirection {\r
+                               DiagnosticOutput,\r
+                               {90, 25}\r
+                       },\r
+                       /* [8] */\r
+                       NotDependent {\r
+\r
+                       },\r
+                       TextBox {\r
+                               gray,\r
+                               {25, 20, 132, 145},\r
+                               "Files"\r
+                       },\r
+                       /* [9] */\r
+                       NotDependent {\r
+\r
+                       },\r
+                       Files {\r
+                               DirOnly,\r
+                               OptionalFile {\r
+                                       {68, 175, 84, 305},\r
+                                       {88, 175, 107, 305},\r
+                                       "Output Directory",\r
+                                       ":",\r
+                                       "-o",\r
+                                       "",\r
+                                       "Choose the directory where DLG will put "\r
+                                       "its output.",\r
+                                       dim,\r
+                                       "Output DirectoryI",\r
+                                       "",\r
+                                       ""\r
+                               },\r
+                               NoMore {\r
+\r
+                               }\r
+                       },\r
+                       /* [10] */\r
+                       NotDependent {\r
+\r
+                       },\r
+                       RegularEntry {\r
+                               "Mode File Name:",\r
+                               {68, 315, 83, 450},\r
+                               {88, 315, 104, 450},\r
+                               "mode.h",\r
+                               keepCase,\r
+                               "-m",\r
+                               "This entry specifies the name DLG uses f"\r
+                               "or its lexical mode output file."\r
+                       },\r
+                       /* [11] */\r
+                       NotDependent {\r
+\r
+                       },\r
+                       RadioButtons {\r
+                               {       /* array radioArray: 3 elements */\r
+                                       /* [1] */\r
+                                       {134, 175, 149, 255}, "None", "", Set, "When this option is selected, DLG will n"\r
+                                       "ot compress its tables.",\r
+                                       /* [2] */\r
+                                       {134, 265, 149, 345}, "Level 1", "-C1", NotSet, "When this option is selected, DLG will r"\r
+                                       "emove all unused characters from the tra"\r
+                                       "nsition-from table.",\r
+                                       /* [3] */\r
+                                       {134, 360, 149, 450}, "Level 2", "-C2", NotSet, "When this option is selected, DLG will p"\r
+                                       "erform level 1 compression plus it will "\r
+                                       "map equivalent characters into the same "\r
+                                       "character classes."\r
+                               }\r
+                       },\r
+                       /* [12] */\r
+                       NotDependent {\r
+\r
+                       },\r
+                       TextBox {\r
+                               gray,\r
+                               {124, 165, 156, 460},\r
+                               "Table Compression"\r
+                       },\r
+                       /* [13] */\r
+                       NotDependent {\r
+\r
+                       },\r
+                       CheckOption {\r
+                               Set,\r
+                               {165, 20, 180, 145},\r
+                               "Case Sensitive",\r
+                               "-ci",\r
+                               "When this control is checked, the DLG au"\r
+                               "tomaton will treat upper and lower case "\r
+                               "characters identically."\r
+                       },\r
+                       /* [14] */\r
+                       NotDependent {\r
+\r
+                       },\r
+                       CheckOption {\r
+                               NotSet,\r
+                               {165, 150, 180, 300},\r
+                               "Interactive Scanner",\r
+                               "-i",\r
+                               "When this control is checked, DLG will g"\r
+                               "enerate as interactive a scanner as poss"\r
+                               "ible."\r
+                       },\r
+                       /* [15] */\r
+                       NotDependent {\r
+\r
+                       },\r
+                       CheckOption {\r
+                               NotSet,\r
+                               {165, 310, 180, 460},\r
+                               "Ambiguity Warnings",\r
+                               "-Wambiguity",\r
+                               "When this control is checked, DLG warns "\r
+                               "if more than one regular expression coul"\r
+                               "d match the same character sequence."\r
+                       },\r
+                       /* [16] */\r
+                       NotDependent {\r
+\r
+                       },\r
+                       VersionDialog {\r
+                               VersionString {\r
+                                       "1.33MR"\r
+                               },\r
+                               "PCCTS was written by Terence Parr, Russe"\r
+                               "ll Quong, Will Cohen, and Hank Dietz: 19"\r
+                               "89-1998. MPW port by Scott Haney.",\r
+                               noDialog\r
+                       },\r
+                       /* [17] */\r
+                       And {\r
+                               {       /* array AndArray: 2 elements */\r
+                                       /* [1] */\r
+                                       4,\r
+                                       /* [2] */\r
+                                       6\r
+                               }\r
+                       },\r
+                       DoItButton {\r
+\r
+                       },\r
+                       /* [18] */\r
+                       NotDependent {\r
+\r
+                       },\r
+                       CheckOption {\r
+                               NotSet,\r
+                               {142, 20, 157, 148},\r
+                               "Generate ANSI C",\r
+                               "-ga",\r
+                               "When this control is checked, DLG genera"\r
+                               "tes ANSI C compatible code."\r
+                       }\r
+               }\r
+       }\r
+};\r
+\r
diff --git a/Tools/CodeTools/Source/Pccts/dlg/dlg1.txt b/Tools/CodeTools/Source/Pccts/dlg/dlg1.txt
new file mode 100644 (file)
index 0000000..06b320d
--- /dev/null
@@ -0,0 +1,132 @@
+\r
+\r
+\r
+dlg(1)                 PCCTS Manual Pages                  dlg(1)\r
+\r
+\r
+\r
+NAME\r
+     dlg - DFA Lexical Analyzer Generator\r
+\r
+SYNTAX\r
+     dlg [_\bo_\bp_\bt_\bi_\bo_\bn_\bs] _\bl_\be_\bx_\bi_\bc_\ba_\bl__\bs_\bp_\be_\bc [_\bo_\bu_\bt_\bp_\bu_\bt__\bf_\bi_\bl_\be]\r
+\r
+DESCRIPTION\r
+     dlg is a tool that produces fast deterministic finite auto-\r
+     mata for recognizing regular expressions in input.\r
+\r
+OPTIONS\r
+     -CC  Generate C++ output.  The _\bo_\bu_\bt_\bp_\bu_\bt__\bf_\bi_\bl_\be is not specified\r
+          in this case.\r
+\r
+     -C[ level]\r
+          Where level is the compression level used.  0 indica-\r
+          tions no compression, 1 removes all unused characters\r
+          from the transition from table, and 2 maps equivalent\r
+          characters into the same character classes.  It is sug-\r
+          gested that level -C2 is used, since it will signifi-\r
+          cantly reduce the size of the dfa produced for lexical\r
+          analyzer.\r
+\r
+     -m   Produces the header file for the lexical mode with a\r
+          name other than the default name of "mode.h".\r
+\r
+     -i   An interactive, or as interactive as possible, parser\r
+          is produced.  A character is only obtained when\r
+          required to decide which state to go to.  Some care\r
+          must be taken to obtain accept states that do not\r
+          require look ahead at the next character to determine\r
+          if that is the stop state.  Any regular expression with\r
+          a Kleene closure at the end is guaranteed to require\r
+          another character of look ahead.\r
+\r
+     -cl class\r
+          Specify a class name for DLG to generate.  The default\r
+          is DLGLexer.\r
+\r
+     -ci  The automaton will treat upper and lower case charac-\r
+          ters identically.  This is accomplished in the automa-\r
+          ton; the characters in the lexical buffer are unmodi-\r
+          fied.\r
+\r
+     -cs  Upper and lower case characters are treated as dis-\r
+          tinct.  This is the default.\r
+\r
+     -o dir\r
+          Directory where output files should go (default=".").\r
+          This is very nice for keeping the source directory\r
+          clear of ANTLR and DLG spawn.\r
+\r
+     -Wambiguity\r
+          Warns if more than one regular expression could match\r
+          the same character sequence.  The warnings give the\r
+          numbers of the expressions in the dlg lexical specifi-\r
+          cation file.  The numbering of the expressions starts\r
+          at one.  Multiple warnings may be print for the same\r
+          expressions.\r
+\r
+     -    Used in place of file names to get input from standard\r
+          in or send output to standard out.\r
+\r
+SPECIAL CONSIDERATIONS\r
+     _\bD_\bl_\bg works...  we think.  There is no implicit guarantee of\r
+     anything.  We reserve no legal rights to the software known\r
+     as the Purdue Compiler Construction Tool Set (PCCTS) - PCCTS\r
+     is in the public domain.  An individual or company may do\r
+     whatever they wish with source code distributed with PCCTS\r
+     or the code generated by PCCTS, including the incorporation\r
+     of PCCTS, or its output, into commercial software.  We\r
+     encourage users to develop software with PCCTS.  However, we\r
+     do ask that credit is given to us for developing PCCTS.  By\r
+     "credit", we mean that if you incorporate our source code\r
+     into one of your programs (commercial product, research pro-\r
+     ject, or otherwise) that you acknowledge this fact somewhere\r
+     in the documentation, research report, etc...  If you like\r
+     PCCTS and have developed a nice tool with the output, please\r
+     mention that you developed it using PCCTS.  As long as these\r
+     guidelines are followed, we expect to continue enhancing\r
+     this system and expect to make other tools available as they\r
+     are completed.\r
+\r
+FILES\r
+     mode.h , dlgauto.h , dlgdef.h\r
+\r
+SEE ALSO\r
+     antlr(1), pccts(1)\r
+\r
+BUGS\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
diff --git a/Tools/CodeTools/Source/Pccts/dlg/dlg_a.c b/Tools/CodeTools/Source/Pccts/dlg/dlg_a.c
new file mode 100644 (file)
index 0000000..0b8982c
--- /dev/null
@@ -0,0 +1,1414 @@
+\r
+/* parser.dlg -- DLG Description of scanner\r
+ *\r
+ * Generated from: dlg_p.g\r
+ *\r
+ * Terence Parr, Will Cohen, and Hank Dietz: 1989-2001\r
+ * Purdue University Electrical Engineering\r
+ * With AHPCRC, University of Minnesota\r
+ * ANTLR Version 1.33MR33\r
+ */\r
+\r
+#define ANTLR_VERSION  13333\r
+#include "pcctscfg.h"\r
+#include "pccts_stdio.h"\r
+\r
+#include <ctype.h>\r
+#include "dlg.h"\r
+#include "antlr.h"\r
+#include "tokens.h"\r
+#include "dlgdef.h"\r
+LOOKAHEAD\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+zzerraction(void)\r
+#else\r
+zzerraction()\r
+#endif\r
+{\r
+       (*zzerr)("invalid token");\r
+       zzadvance();\r
+       zzskip();\r
+}\r
+/*\r
+ * D L G tables\r
+ *\r
+ * Generated from: parser.dlg\r
+ *\r
+ * 1989-2001 by  Will Cohen, Terence Parr, and Hank Dietz\r
+ * Purdue University Electrical Engineering\r
+ * DLG Version 1.33MR33\r
+ */\r
+\r
+#include "mode.h"\r
+\r
+\r
+\r
+\r
+int    func_action;            /* should actions be turned into functions?*/\r
+int    lex_mode_counter = 0;   /* keeps track of the number of %%names */\r
+/* MR1                                                                     */\r
+/* MR1  11-Apr-97      Provide mechanism for inserting code into DLG class */\r
+/* MR1                         via <<%%lexmember...>>                      */\r
+/* MR1                                                                     */\r
+int    lexMember = 0;          /* <<%%lexmemeber ...>>                 MR1 */\r
+int    lexAction = 0;          /* <<%%lexaction ...>>                  MR1 */\r
+int    parserClass = 0;        /* <<%%parserclass ...>>        MR1 */\r
+int    lexPrefix = 0;          /* <<%%lexprefix ...>>                  MR1 */\r
+char   theClassName[100];                                                   /* MR11 */\r
+char   *pClassName=theClassName;                                        /* MR11 */\r
+int    firstLexMember=1;                                                    /* MR1 */\r
+\r
+#ifdef __USE_PROTOS\r
+void  xxputc(int c) {                                          /* MR1 */\r
+#else\r
+  void xxputc(c)                                                       /* MR1 */\r
+  int  c;                                                      /* MR1 */\r
+  {                                                            /* MR1 */\r
+#endif\r
+    if (parserClass) {                                         /* MR1 */\r
+      *pClassName++=c;                                         /* MR1 */\r
+      *pClassName=0;                                           /* MR1 */\r
+    } else if (lexMember || lexPrefix) {                               /* MR1 */\r
+      if (class_stream != NULL) fputc(c,class_stream);         /* MR1 */\r
+    } else {                                                   /* MR1 */\r
+      fputc(c,OUT);                                            /* MR1 */\r
+    };                                                         /* MR1 */\r
+  }                                                            /* MR1 */\r
+  \r
+#ifdef __USE_PROTOS\r
+  void xxprintf(char *format,char *string) {                   /* MR1 */\r
+#else\r
+    void xxprintf(format,string)                                       /* MR1 */\r
+    char *format;                                                      /* MR1 */\r
+    char *string;                                                      /* MR1 */\r
+    {                                                          /* MR1 */\r
+#endif\r
+      if (lexMember || lexPrefix || parserClass) {                     /* MR1 */\r
+        if (class_stream != NULL)                                      /* MR1 */\r
+        fprintf(class_stream,format,string);                   /* MR1 */\r
+      } else {                                                 /* MR1 */\r
+        fprintf(OUT,format,string);                                    /* MR1 */\r
+      };                                                               /* MR1 */\r
+    }                                                                  /* MR1 */\r
+\r
+static void act1()\r
+{ \r
+               NLA = 1;\r
+       }\r
+\r
+\r
+static void act2()\r
+{ \r
+               NLA = 2;\r
+    zzskip();   \r
+       }\r
+\r
+\r
+static void act3()\r
+{ \r
+               NLA = 3;\r
+    zzline++; zzskip(); DAWDLE;   \r
+       }\r
+\r
+\r
+static void act4()\r
+{ \r
+               NLA = L_EOF;\r
+       }\r
+\r
+\r
+static void act5()\r
+{ \r
+               NLA = PER_PER;\r
+       }\r
+\r
+\r
+static void act6()\r
+{ \r
+               NLA = NAME_PER_PER;\r
+    p_mode_def(&zzlextext[2],lex_mode_counter++);   \r
+       }\r
+\r
+\r
+static void act7()\r
+{ \r
+               NLA = LEXMEMBER;\r
+    lexMember=1;                                       /* MR1 */\r
+    if (firstLexMember != 0) {                 /* MR1 */\r
+      firstLexMember=0;                                /* MR1 */\r
+      p_class_def1();                          /* MR1 */\r
+    };                                         /* MR1 */\r
+    zzmode(ACT);                                       /* MR1 */\r
+       }\r
+\r
+\r
+static void act8()\r
+{ \r
+               NLA = LEXACTION;\r
+    lexAction=1;zzmode(ACT);  \r
+       }\r
+\r
+\r
+static void act9()\r
+{ \r
+               NLA = PARSERCLASS;\r
+    parserClass=1;                             /* MR1 */\r
+    zzmode(ACT);                                       /* MR1 */\r
+       }\r
+\r
+\r
+static void act10()\r
+{ \r
+               NLA = LEXPREFIX;\r
+    lexPrefix=1;zzmode(ACT);  \r
+       }\r
+\r
+\r
+static void act11()\r
+{ \r
+               NLA = ACTION;\r
+    if (func_action)\r
+    fprintf(OUT,"\n%s %sact%d()\n{ ",\r
+    gen_cpp?"ANTLRTokenType":"static void",\r
+    gen_cpp?ClassName("::"):"", ++action_no);\r
+    zzmode(ACT); zzskip();\r
+       }\r
+\r
+\r
+static void act12()\r
+{ \r
+               NLA = GREAT_GREAT;\r
+       }\r
+\r
+\r
+static void act13()\r
+{ \r
+               NLA = L_BRACE;\r
+       }\r
+\r
+\r
+static void act14()\r
+{ \r
+               NLA = R_BRACE;\r
+       }\r
+\r
+\r
+static void act15()\r
+{ \r
+               NLA = L_PAR;\r
+       }\r
+\r
+\r
+static void act16()\r
+{ \r
+               NLA = R_PAR;\r
+       }\r
+\r
+\r
+static void act17()\r
+{ \r
+               NLA = L_BRACK;\r
+       }\r
+\r
+\r
+static void act18()\r
+{ \r
+               NLA = R_BRACK;\r
+       }\r
+\r
+\r
+static void act19()\r
+{ \r
+               NLA = ZERO_MORE;\r
+       }\r
+\r
+\r
+static void act20()\r
+{ \r
+               NLA = ONE_MORE;\r
+       }\r
+\r
+\r
+static void act21()\r
+{ \r
+               NLA = OR;\r
+       }\r
+\r
+\r
+static void act22()\r
+{ \r
+               NLA = RANGE;\r
+       }\r
+\r
+\r
+static void act23()\r
+{ \r
+               NLA = NOT;\r
+       }\r
+\r
+\r
+static void act24()\r
+{ \r
+               NLA = OCTAL_VALUE;\r
+    {int t; sscanf(&zzlextext[1],"%o",&t); zzlextext[0] = t;}  \r
+       }\r
+\r
+\r
+static void act25()\r
+{ \r
+               NLA = HEX_VALUE;\r
+    {int t; sscanf(&zzlextext[3],"%x",&t); zzlextext[0] = t;}  \r
+       }\r
+\r
+\r
+static void act26()\r
+{ \r
+               NLA = DEC_VALUE;\r
+    {int t; sscanf(&zzlextext[1],"%d",&t); zzlextext[0] = t;}  \r
+       }\r
+\r
+\r
+static void act27()\r
+{ \r
+               NLA = TAB;\r
+    zzlextext[0] = '\t';  \r
+       }\r
+\r
+\r
+static void act28()\r
+{ \r
+               NLA = NL;\r
+    zzlextext[0] = '\n';  \r
+       }\r
+\r
+\r
+static void act29()\r
+{ \r
+               NLA = CR;\r
+    zzlextext[0] = '\r';  \r
+       }\r
+\r
+\r
+static void act30()\r
+{ \r
+               NLA = BS;\r
+    zzlextext[0] = '\b';  \r
+       }\r
+\r
+\r
+static void act31()\r
+{ \r
+               NLA = CONTINUATION;\r
+    zzline++; zzskip();  \r
+       }\r
+\r
+\r
+static void act32()\r
+{ \r
+               NLA = LIT;\r
+    zzlextext[0] = zzlextext[1];  \r
+       }\r
+\r
+\r
+static void act33()\r
+{ \r
+               NLA = REGCHAR;\r
+       }\r
+\r
+static unsigned char shift0[257] = {\r
+  0, 40, 40, 40, 40, 40, 40, 40, 40, 40, \r
+  1, 2, 40, 40, 1, 40, 40, 40, 40, 40, \r
+  40, 40, 40, 40, 40, 40, 40, 40, 40, 40, \r
+  40, 40, 40, 1, 40, 40, 40, 40, 4, 40, \r
+  40, 30, 31, 34, 35, 40, 37, 40, 40, 23, \r
+  24, 24, 24, 24, 24, 24, 24, 25, 25, 40, \r
+  40, 26, 40, 27, 40, 3, 21, 21, 21, 21, \r
+  21, 21, 22, 22, 22, 22, 22, 22, 22, 22, \r
+  22, 22, 22, 22, 22, 22, 22, 22, 22, 20, \r
+  22, 22, 32, 39, 33, 40, 22, 40, 11, 9, \r
+  12, 21, 6, 19, 22, 22, 14, 22, 22, 5, \r
+  8, 16, 15, 17, 22, 10, 18, 13, 22, 22, \r
+  22, 7, 22, 22, 28, 36, 29, 38, 40, 40, \r
+  40, 40, 40, 40, 40, 40, 40, 40, 40, 40, \r
+  40, 40, 40, 40, 40, 40, 40, 40, 40, 40, \r
+  40, 40, 40, 40, 40, 40, 40, 40, 40, 40, \r
+  40, 40, 40, 40, 40, 40, 40, 40, 40, 40, \r
+  40, 40, 40, 40, 40, 40, 40, 40, 40, 40, \r
+  40, 40, 40, 40, 40, 40, 40, 40, 40, 40, \r
+  40, 40, 40, 40, 40, 40, 40, 40, 40, 40, \r
+  40, 40, 40, 40, 40, 40, 40, 40, 40, 40, \r
+  40, 40, 40, 40, 40, 40, 40, 40, 40, 40, \r
+  40, 40, 40, 40, 40, 40, 40, 40, 40, 40, \r
+  40, 40, 40, 40, 40, 40, 40, 40, 40, 40, \r
+  40, 40, 40, 40, 40, 40, 40, 40, 40, 40, \r
+  40, 40, 40, 40, 40, 40, 40\r
+};\r
+\r
+\r
+static void act34()\r
+{ \r
+               NLA = 1;\r
+    error("unterminated action", zzline); zzmode(START);   \r
+       }\r
+\r
+\r
+static void act35()\r
+{ \r
+               NLA = ACTION;\r
+    if (func_action) fprintf(OUT,"}\n\n");\r
+    zzmode(START);\r
+    /* MR1                                                                         */\r
+    /* MR1  11-Apr-97  Provide mechanism for inserting code into DLG class */\r
+    /* MR1                             via <<%%lexmember ...>>                     */\r
+    /* MR1                     This is a consequence of not saving actions         */\r
+    /* MR1                                                                         */\r
+    /* MR1 */     parserClass=0;               \r
+    /* MR1 */     lexPrefix=0;\r
+    /* MR1 */     lexAction=0;\r
+    /* MR1 */     lexMember=0;\r
+       }\r
+\r
+\r
+static void act36()\r
+{ \r
+               NLA = 34;\r
+    xxputc(zzlextext[0]); zzskip();   \r
+       }\r
+\r
+\r
+static void act37()\r
+{ \r
+               NLA = 35;\r
+    xxputc('>'); zzskip();   \r
+       }\r
+\r
+\r
+static void act38()\r
+{ \r
+               NLA = 36;\r
+    xxputc('\\'); zzskip();   \r
+       }\r
+\r
+\r
+static void act39()\r
+{ \r
+               NLA = 37;\r
+    xxputc(zzlextext[0]); ++zzline; zzskip();   \r
+       }\r
+\r
+\r
+static void act40()\r
+{ \r
+               NLA = 38;\r
+    zzmode(ACTION_COMMENTS);                   /* MR1 */\r
+    xxprintf("%s", &(zzlextext[0])); zzskip(); /* MR1 */\r
+       }\r
+\r
+\r
+static void act41()\r
+{ \r
+               NLA = 39;\r
+    zzmode(ACTION_CPP_COMMENTS);                       /* MR1 */\r
+    xxprintf("%s", &(zzlextext[0])); zzskip(); /* MR1 */\r
+       }\r
+\r
+\r
+static void act42()\r
+{ \r
+               NLA = 40;\r
+    xxputc(zzlextext[0]); zzskip();   \r
+       }\r
+\r
+static unsigned char shift1[257] = {\r
+  0, 6, 6, 6, 6, 6, 6, 6, 6, 6, \r
+  6, 3, 6, 6, 6, 6, 6, 6, 6, 6, \r
+  6, 6, 6, 6, 6, 6, 6, 6, 6, 6, \r
+  6, 6, 6, 6, 6, 6, 6, 6, 6, 6, \r
+  6, 6, 6, 5, 6, 6, 6, 6, 4, 6, \r
+  6, 6, 6, 6, 6, 6, 6, 6, 6, 6, \r
+  6, 6, 6, 1, 6, 6, 6, 6, 6, 6, \r
+  6, 6, 6, 6, 6, 6, 6, 6, 6, 6, \r
+  6, 6, 6, 6, 6, 6, 6, 6, 6, 6, \r
+  6, 6, 6, 2, 6, 6, 6, 6, 6, 6, \r
+  6, 6, 6, 6, 6, 6, 6, 6, 6, 6, \r
+  6, 6, 6, 6, 6, 6, 6, 6, 6, 6, \r
+  6, 6, 6, 6, 6, 6, 6, 6, 6, 6, \r
+  6, 6, 6, 6, 6, 6, 6, 6, 6, 6, \r
+  6, 6, 6, 6, 6, 6, 6, 6, 6, 6, \r
+  6, 6, 6, 6, 6, 6, 6, 6, 6, 6, \r
+  6, 6, 6, 6, 6, 6, 6, 6, 6, 6, \r
+  6, 6, 6, 6, 6, 6, 6, 6, 6, 6, \r
+  6, 6, 6, 6, 6, 6, 6, 6, 6, 6, \r
+  6, 6, 6, 6, 6, 6, 6, 6, 6, 6, \r
+  6, 6, 6, 6, 6, 6, 6, 6, 6, 6, \r
+  6, 6, 6, 6, 6, 6, 6, 6, 6, 6, \r
+  6, 6, 6, 6, 6, 6, 6, 6, 6, 6, \r
+  6, 6, 6, 6, 6, 6, 6, 6, 6, 6, \r
+  6, 6, 6, 6, 6, 6, 6, 6, 6, 6, \r
+  6, 6, 6, 6, 6, 6, 6\r
+};\r
+\r
+\r
+static void act43()\r
+{ \r
+               NLA = 1;\r
+       }\r
+\r
+\r
+static void act44()\r
+{ \r
+               NLA = 41;\r
+    zzmode(ACT);                                       /* MR1 */\r
+    xxprintf("%s", &(zzlextext[0])); zzskip(); /* MR1 */\r
+       }\r
+\r
+\r
+static void act45()\r
+{ \r
+               NLA = 42;\r
+    zzline++; xxputc(zzlextext[0]); zzskip();  \r
+       }\r
+\r
+\r
+static void act46()\r
+{ \r
+               NLA = 43;\r
+    xxputc(zzlextext[0]); zzskip();  \r
+       }\r
+\r
+static unsigned char shift2[257] = {\r
+  0, 4, 4, 4, 4, 4, 4, 4, 4, 4, \r
+  4, 3, 4, 4, 3, 4, 4, 4, 4, 4, \r
+  4, 4, 4, 4, 4, 4, 4, 4, 4, 4, \r
+  4, 4, 4, 4, 4, 4, 4, 4, 4, 4, \r
+  4, 4, 4, 1, 4, 4, 4, 4, 2, 4, \r
+  4, 4, 4, 4, 4, 4, 4, 4, 4, 4, \r
+  4, 4, 4, 4, 4, 4, 4, 4, 4, 4, \r
+  4, 4, 4, 4, 4, 4, 4, 4, 4, 4, \r
+  4, 4, 4, 4, 4, 4, 4, 4, 4, 4, \r
+  4, 4, 4, 4, 4, 4, 4, 4, 4, 4, \r
+  4, 4, 4, 4, 4, 4, 4, 4, 4, 4, \r
+  4, 4, 4, 4, 4, 4, 4, 4, 4, 4, \r
+  4, 4, 4, 4, 4, 4, 4, 4, 4, 4, \r
+  4, 4, 4, 4, 4, 4, 4, 4, 4, 4, \r
+  4, 4, 4, 4, 4, 4, 4, 4, 4, 4, \r
+  4, 4, 4, 4, 4, 4, 4, 4, 4, 4, \r
+  4, 4, 4, 4, 4, 4, 4, 4, 4, 4, \r
+  4, 4, 4, 4, 4, 4, 4, 4, 4, 4, \r
+  4, 4, 4, 4, 4, 4, 4, 4, 4, 4, \r
+  4, 4, 4, 4, 4, 4, 4, 4, 4, 4, \r
+  4, 4, 4, 4, 4, 4, 4, 4, 4, 4, \r
+  4, 4, 4, 4, 4, 4, 4, 4, 4, 4, \r
+  4, 4, 4, 4, 4, 4, 4, 4, 4, 4, \r
+  4, 4, 4, 4, 4, 4, 4, 4, 4, 4, \r
+  4, 4, 4, 4, 4, 4, 4, 4, 4, 4, \r
+  4, 4, 4, 4, 4, 4, 4\r
+};\r
+\r
+\r
+static void act47()\r
+{ \r
+               NLA = 1;\r
+       }\r
+\r
+\r
+static void act48()\r
+{ \r
+               NLA = 44;\r
+    zzmode(ACT); zzline++;                     /* MR1 */\r
+    xxprintf("%s", &(zzlextext[0])); zzskip(); /* MR1 */\r
+       }\r
+\r
+\r
+static void act49()\r
+{ \r
+               NLA = 45;\r
+    xxputc(zzlextext[0]); zzskip();  \r
+       }\r
+\r
+static unsigned char shift3[257] = {\r
+  0, 2, 2, 2, 2, 2, 2, 2, 2, 2, \r
+  2, 1, 2, 2, 1, 2, 2, 2, 2, 2, \r
+  2, 2, 2, 2, 2, 2, 2, 2, 2, 2, \r
+  2, 2, 2, 2, 2, 2, 2, 2, 2, 2, \r
+  2, 2, 2, 2, 2, 2, 2, 2, 2, 2, \r
+  2, 2, 2, 2, 2, 2, 2, 2, 2, 2, \r
+  2, 2, 2, 2, 2, 2, 2, 2, 2, 2, \r
+  2, 2, 2, 2, 2, 2, 2, 2, 2, 2, \r
+  2, 2, 2, 2, 2, 2, 2, 2, 2, 2, \r
+  2, 2, 2, 2, 2, 2, 2, 2, 2, 2, \r
+  2, 2, 2, 2, 2, 2, 2, 2, 2, 2, \r
+  2, 2, 2, 2, 2, 2, 2, 2, 2, 2, \r
+  2, 2, 2, 2, 2, 2, 2, 2, 2, 2, \r
+  2, 2, 2, 2, 2, 2, 2, 2, 2, 2, \r
+  2, 2, 2, 2, 2, 2, 2, 2, 2, 2, \r
+  2, 2, 2, 2, 2, 2, 2, 2, 2, 2, \r
+  2, 2, 2, 2, 2, 2, 2, 2, 2, 2, \r
+  2, 2, 2, 2, 2, 2, 2, 2, 2, 2, \r
+  2, 2, 2, 2, 2, 2, 2, 2, 2, 2, \r
+  2, 2, 2, 2, 2, 2, 2, 2, 2, 2, \r
+  2, 2, 2, 2, 2, 2, 2, 2, 2, 2, \r
+  2, 2, 2, 2, 2, 2, 2, 2, 2, 2, \r
+  2, 2, 2, 2, 2, 2, 2, 2, 2, 2, \r
+  2, 2, 2, 2, 2, 2, 2, 2, 2, 2, \r
+  2, 2, 2, 2, 2, 2, 2, 2, 2, 2, \r
+  2, 2, 2, 2, 2, 2, 2\r
+};\r
+\r
+#define DfaStates      94\r
+typedef unsigned char DfaState;\r
+\r
+static DfaState st0[42] = {\r
+  1, 2, 3, 4, 5, 6, 6, 6, 6, 6, \r
+  6, 6, 6, 6, 6, 6, 6, 6, 6, 6, \r
+  6, 6, 6, 6, 6, 6, 7, 8, 9, 10, \r
+  11, 12, 13, 14, 15, 16, 17, 18, 19, 20, \r
+  6, 94\r
+};\r
+\r
+static DfaState st1[42] = {\r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94\r
+};\r
+\r
+static DfaState st2[42] = {\r
+  94, 21, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94\r
+};\r
+\r
+static DfaState st3[42] = {\r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94\r
+};\r
+\r
+static DfaState st4[42] = {\r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94\r
+};\r
+\r
+static DfaState st5[42] = {\r
+  94, 94, 94, 94, 22, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94\r
+};\r
+\r
+static DfaState st6[42] = {\r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94\r
+};\r
+\r
+static DfaState st7[42] = {\r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 23, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94\r
+};\r
+\r
+static DfaState st8[42] = {\r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 24, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94\r
+};\r
+\r
+static DfaState st9[42] = {\r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94\r
+};\r
+\r
+static DfaState st10[42] = {\r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94\r
+};\r
+\r
+static DfaState st11[42] = {\r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94\r
+};\r
+\r
+static DfaState st12[42] = {\r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94\r
+};\r
+\r
+static DfaState st13[42] = {\r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94\r
+};\r
+\r
+static DfaState st14[42] = {\r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94\r
+};\r
+\r
+static DfaState st15[42] = {\r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94\r
+};\r
+\r
+static DfaState st16[42] = {\r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94\r
+};\r
+\r
+static DfaState st17[42] = {\r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94\r
+};\r
+\r
+static DfaState st18[42] = {\r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94\r
+};\r
+\r
+static DfaState st19[42] = {\r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94\r
+};\r
+\r
+static DfaState st20[42] = {\r
+  94, 25, 26, 25, 25, 25, 25, 25, 25, 27, \r
+  28, 25, 25, 29, 25, 25, 30, 25, 25, 25, \r
+  25, 25, 25, 31, 32, 32, 25, 25, 25, 25, \r
+  25, 25, 25, 25, 25, 25, 25, 25, 25, 25, \r
+  25, 94\r
+};\r
+\r
+static DfaState st21[42] = {\r
+  94, 21, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94\r
+};\r
+\r
+static DfaState st22[42] = {\r
+  94, 94, 94, 94, 94, 33, 33, 33, 33, 33, \r
+  33, 33, 33, 33, 33, 33, 33, 33, 33, 33, \r
+  33, 33, 33, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94\r
+};\r
+\r
+static DfaState st23[42] = {\r
+  94, 94, 94, 94, 34, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94\r
+};\r
+\r
+static DfaState st24[42] = {\r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94\r
+};\r
+\r
+static DfaState st25[42] = {\r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94\r
+};\r
+\r
+static DfaState st26[42] = {\r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94\r
+};\r
+\r
+static DfaState st27[42] = {\r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94\r
+};\r
+\r
+static DfaState st28[42] = {\r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94\r
+};\r
+\r
+static DfaState st29[42] = {\r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94\r
+};\r
+\r
+static DfaState st30[42] = {\r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94\r
+};\r
+\r
+static DfaState st31[42] = {\r
+  94, 94, 94, 94, 94, 94, 94, 35, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  35, 94, 94, 36, 36, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94\r
+};\r
+\r
+static DfaState st32[42] = {\r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 37, 37, 37, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94\r
+};\r
+\r
+static DfaState st33[42] = {\r
+  94, 94, 94, 94, 94, 38, 38, 38, 38, 38, \r
+  38, 38, 38, 38, 38, 38, 38, 38, 38, 38, \r
+  38, 38, 38, 38, 38, 38, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94\r
+};\r
+\r
+static DfaState st34[42] = {\r
+  94, 94, 94, 94, 39, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94\r
+};\r
+\r
+static DfaState st35[42] = {\r
+  94, 94, 94, 94, 94, 94, 40, 94, 94, 40, \r
+  94, 40, 40, 94, 94, 94, 94, 94, 94, 40, \r
+  94, 40, 94, 40, 40, 40, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94\r
+};\r
+\r
+static DfaState st36[42] = {\r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 36, 36, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94\r
+};\r
+\r
+static DfaState st37[42] = {\r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 37, 37, 37, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94\r
+};\r
+\r
+static DfaState st38[42] = {\r
+  94, 94, 94, 94, 94, 38, 38, 38, 38, 38, \r
+  38, 38, 38, 38, 38, 38, 38, 38, 38, 38, \r
+  38, 38, 38, 38, 38, 38, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94\r
+};\r
+\r
+static DfaState st39[42] = {\r
+  94, 94, 94, 94, 94, 41, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 42, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94\r
+};\r
+\r
+static DfaState st40[42] = {\r
+  94, 94, 94, 94, 94, 94, 40, 94, 94, 40, \r
+  94, 40, 40, 94, 94, 94, 94, 94, 94, 40, \r
+  94, 40, 94, 40, 40, 40, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94\r
+};\r
+\r
+static DfaState st41[42] = {\r
+  94, 94, 94, 94, 94, 94, 43, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94\r
+};\r
+\r
+static DfaState st42[42] = {\r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 44, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94\r
+};\r
+\r
+static DfaState st43[42] = {\r
+  94, 94, 94, 94, 94, 94, 94, 45, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94\r
+};\r
+\r
+static DfaState st44[42] = {\r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  46, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94\r
+};\r
+\r
+static DfaState st45[42] = {\r
+  94, 94, 94, 94, 94, 94, 94, 94, 47, 94, \r
+  94, 48, 94, 94, 94, 94, 94, 49, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94\r
+};\r
+\r
+static DfaState st46[42] = {\r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 50, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94\r
+};\r
+\r
+static DfaState st47[42] = {\r
+  94, 94, 94, 94, 94, 94, 51, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94\r
+};\r
+\r
+static DfaState st48[42] = {\r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 52, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94\r
+};\r
+\r
+static DfaState st49[42] = {\r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  53, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94\r
+};\r
+\r
+static DfaState st50[42] = {\r
+  94, 94, 94, 94, 94, 94, 54, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94\r
+};\r
+\r
+static DfaState st51[42] = {\r
+  94, 94, 94, 94, 94, 94, 94, 94, 55, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94\r
+};\r
+\r
+static DfaState st52[42] = {\r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 56, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94\r
+};\r
+\r
+static DfaState st53[42] = {\r
+  94, 94, 94, 94, 94, 94, 57, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94\r
+};\r
+\r
+static DfaState st54[42] = {\r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  58, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94\r
+};\r
+\r
+static DfaState st55[42] = {\r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 59, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94\r
+};\r
+\r
+static DfaState st56[42] = {\r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 60, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94\r
+};\r
+\r
+static DfaState st57[42] = {\r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 61, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94\r
+};\r
+\r
+static DfaState st58[42] = {\r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 62, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94\r
+};\r
+\r
+static DfaState st59[42] = {\r
+  94, 94, 94, 94, 94, 94, 63, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94\r
+};\r
+\r
+static DfaState st60[42] = {\r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 64, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94\r
+};\r
+\r
+static DfaState st61[42] = {\r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 65, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94\r
+};\r
+\r
+static DfaState st62[42] = {\r
+  94, 94, 94, 94, 94, 66, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94\r
+};\r
+\r
+static DfaState st63[42] = {\r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  67, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94\r
+};\r
+\r
+static DfaState st64[42] = {\r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 68, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94\r
+};\r
+\r
+static DfaState st65[42] = {\r
+  94, 94, 94, 94, 94, 94, 94, 69, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94\r
+};\r
+\r
+static DfaState st66[42] = {\r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 70, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94\r
+};\r
+\r
+static DfaState st67[42] = {\r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94\r
+};\r
+\r
+static DfaState st68[42] = {\r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94\r
+};\r
+\r
+static DfaState st69[42] = {\r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94\r
+};\r
+\r
+static DfaState st70[42] = {\r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 71, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94\r
+};\r
+\r
+static DfaState st71[42] = {\r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 72, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94\r
+};\r
+\r
+static DfaState st72[42] = {\r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
+  94, 94\r
+};\r
+\r
+static DfaState st73[8] = {\r
+  74, 75, 76, 77, 78, 79, 79, 94\r
+};\r
+\r
+static DfaState st74[8] = {\r
+  94, 94, 94, 94, 94, 94, 94, 94\r
+};\r
+\r
+static DfaState st75[8] = {\r
+  94, 80, 94, 94, 94, 94, 94, 94\r
+};\r
+\r
+static DfaState st76[8] = {\r
+  94, 81, 94, 94, 94, 94, 94, 94\r
+};\r
+\r
+static DfaState st77[8] = {\r
+  94, 94, 94, 94, 94, 94, 94, 94\r
+};\r
+\r
+static DfaState st78[8] = {\r
+  94, 94, 94, 94, 82, 83, 94, 94\r
+};\r
+\r
+static DfaState st79[8] = {\r
+  94, 94, 94, 94, 94, 94, 94, 94\r
+};\r
+\r
+static DfaState st80[8] = {\r
+  94, 94, 94, 94, 94, 94, 94, 94\r
+};\r
+\r
+static DfaState st81[8] = {\r
+  94, 94, 94, 94, 94, 94, 94, 94\r
+};\r
+\r
+static DfaState st82[8] = {\r
+  94, 94, 94, 94, 94, 94, 94, 94\r
+};\r
+\r
+static DfaState st83[8] = {\r
+  94, 94, 94, 94, 94, 94, 94, 94\r
+};\r
+\r
+static DfaState st84[6] = {\r
+  85, 86, 87, 88, 87, 94\r
+};\r
+\r
+static DfaState st85[6] = {\r
+  94, 94, 94, 94, 94, 94\r
+};\r
+\r
+static DfaState st86[6] = {\r
+  94, 94, 89, 94, 94, 94\r
+};\r
+\r
+static DfaState st87[6] = {\r
+  94, 94, 94, 94, 94, 94\r
+};\r
+\r
+static DfaState st88[6] = {\r
+  94, 94, 94, 94, 94, 94\r
+};\r
+\r
+static DfaState st89[6] = {\r
+  94, 94, 94, 94, 94, 94\r
+};\r
+\r
+static DfaState st90[4] = {\r
+  91, 92, 93, 94\r
+};\r
+\r
+static DfaState st91[4] = {\r
+  94, 94, 94, 94\r
+};\r
+\r
+static DfaState st92[4] = {\r
+  94, 94, 94, 94\r
+};\r
+\r
+static DfaState st93[4] = {\r
+  94, 94, 94, 94\r
+};\r
+\r
+\r
+DfaState *dfa[94] = {\r
+       st0,\r
+       st1,\r
+       st2,\r
+       st3,\r
+       st4,\r
+       st5,\r
+       st6,\r
+       st7,\r
+       st8,\r
+       st9,\r
+       st10,\r
+       st11,\r
+       st12,\r
+       st13,\r
+       st14,\r
+       st15,\r
+       st16,\r
+       st17,\r
+       st18,\r
+       st19,\r
+       st20,\r
+       st21,\r
+       st22,\r
+       st23,\r
+       st24,\r
+       st25,\r
+       st26,\r
+       st27,\r
+       st28,\r
+       st29,\r
+       st30,\r
+       st31,\r
+       st32,\r
+       st33,\r
+       st34,\r
+       st35,\r
+       st36,\r
+       st37,\r
+       st38,\r
+       st39,\r
+       st40,\r
+       st41,\r
+       st42,\r
+       st43,\r
+       st44,\r
+       st45,\r
+       st46,\r
+       st47,\r
+       st48,\r
+       st49,\r
+       st50,\r
+       st51,\r
+       st52,\r
+       st53,\r
+       st54,\r
+       st55,\r
+       st56,\r
+       st57,\r
+       st58,\r
+       st59,\r
+       st60,\r
+       st61,\r
+       st62,\r
+       st63,\r
+       st64,\r
+       st65,\r
+       st66,\r
+       st67,\r
+       st68,\r
+       st69,\r
+       st70,\r
+       st71,\r
+       st72,\r
+       st73,\r
+       st74,\r
+       st75,\r
+       st76,\r
+       st77,\r
+       st78,\r
+       st79,\r
+       st80,\r
+       st81,\r
+       st82,\r
+       st83,\r
+       st84,\r
+       st85,\r
+       st86,\r
+       st87,\r
+       st88,\r
+       st89,\r
+       st90,\r
+       st91,\r
+       st92,\r
+       st93\r
+};\r
+\r
+\r
+DfaState accepts[95] = {\r
+  0, 1, 2, 3, 4, 33, 33, 33, 33, 13, \r
+  14, 15, 16, 17, 18, 19, 20, 21, 22, 23, \r
+  0, 2, 5, 11, 12, 32, 31, 30, 29, 27, \r
+  28, 24, 26, 6, 0, 0, 24, 26, 6, 0, \r
+  25, 0, 0, 0, 0, 0, 0, 0, 0, 0, \r
+  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \r
+  0, 0, 0, 0, 0, 0, 0, 7, 8, 10, \r
+  0, 0, 9, 0, 34, 36, 38, 39, 42, 42, \r
+  35, 37, 41, 40, 0, 43, 46, 46, 45, 44, \r
+  0, 47, 48, 49, 0\r
+};\r
+\r
+void (*actions[50])() = {\r
+       zzerraction,\r
+       act1,\r
+       act2,\r
+       act3,\r
+       act4,\r
+       act5,\r
+       act6,\r
+       act7,\r
+       act8,\r
+       act9,\r
+       act10,\r
+       act11,\r
+       act12,\r
+       act13,\r
+       act14,\r
+       act15,\r
+       act16,\r
+       act17,\r
+       act18,\r
+       act19,\r
+       act20,\r
+       act21,\r
+       act22,\r
+       act23,\r
+       act24,\r
+       act25,\r
+       act26,\r
+       act27,\r
+       act28,\r
+       act29,\r
+       act30,\r
+       act31,\r
+       act32,\r
+       act33,\r
+       act34,\r
+       act35,\r
+       act36,\r
+       act37,\r
+       act38,\r
+       act39,\r
+       act40,\r
+       act41,\r
+       act42,\r
+       act43,\r
+       act44,\r
+       act45,\r
+       act46,\r
+       act47,\r
+       act48,\r
+       act49\r
+};\r
+\r
+static DfaState dfa_base[] = {\r
+       0,\r
+       73,\r
+       84,\r
+       90\r
+};\r
+\r
+static unsigned char *b_class_no[] = {\r
+       shift0,\r
+       shift1,\r
+       shift2,\r
+       shift3\r
+};\r
+\r
+\r
+\r
+#define ZZSHIFT(c) (b_class_no[zzauto][1+c])\r
+#define MAX_MODE 4\r
+#include "dlgauto.h"\r
diff --git a/Tools/CodeTools/Source/Pccts/dlg/dlg_p.c b/Tools/CodeTools/Source/Pccts/dlg/dlg_p.c
new file mode 100644 (file)
index 0000000..e726ae3
--- /dev/null
@@ -0,0 +1,959 @@
+/*\r
+ * A n t l r  T r a n s l a t i o n  H e a d e r\r
+ *\r
+ * Terence Parr, Will Cohen, and Hank Dietz: 1989-2001\r
+ * Purdue University Electrical Engineering\r
+ * With AHPCRC, University of Minnesota\r
+ * ANTLR Version 1.33MR33\r
+ *\r
+ *   ..\bin\antlr dlg_p.g -gh\r
+ *\r
+ */\r
+\r
+#define ANTLR_VERSION  13333\r
+#include "pcctscfg.h"\r
+#include "pccts_stdio.h"\r
+\r
+#include <ctype.h>\r
+#include "dlg.h"\r
+#define zzSET_SIZE 8\r
+#include "antlr.h"\r
+#include "tokens.h"\r
+#include "dlgdef.h"\r
+#include "mode.h"\r
+\r
+/* MR23 In order to remove calls to PURIFY use the antlr -nopurify option */\r
+\r
+#ifndef PCCTS_PURIFY\r
+#define PCCTS_PURIFY(r,s) memset((char *) &(r),'\0',(s));\r
+#endif\r
+\r
+ANTLR_INFO\r
+\r
+\r
+/* MR20 G. Hobbelt \r
+Fix for Borland C++ 4.x & 5.x compiling with ALL warnings enabled\r
+*/\r
+\r
+#ifdef __TURBOC__\r
+#pragma warn -aus  /* unused assignment of 'xxx' */\r
+#endif\r
+\r
+int    action_no = 0;     /* keep track of actions outputed */\r
+int    nfa_allocated = 0; /* keeps track of number of nfa nodes */\r
+nfa_node **nfa_array = NULL;/* root of binary tree that stores nfa array */\r
+nfa_node nfa_model_node;   /* model to initialize new nodes */\r
+set    used_chars;        /* used to label trans. arcs */\r
+set    used_classes;      /* classes or chars used to label trans. arcs */\r
+set    normal_chars;      /* mask to get rid elements that aren't used\r
+in set */\r
+int    flag_paren = FALSE;\r
+int    flag_brace = FALSE;\r
+int    mode_counter = 0;  /* keep track of number of %%names */\r
+\r
+  \r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+grammar(void)\r
+#else\r
+grammar()\r
+#endif\r
+{\r
+  zzRULE;\r
+  zzBLOCK(zztasp1);\r
+  zzMake0;\r
+  {\r
+  p_head(); p_class_hdr(); func_action = FALSE;\r
+  {\r
+    zzBLOCK(zztasp2);\r
+    zzMake0;\r
+    {\r
+    while ( (setwd1[LA(1)]&0x1) ) {\r
+      {\r
+        zzBLOCK(zztasp3);\r
+        zzMake0;\r
+        {\r
+        if ( (LA(1)==LEXACTION) ) {\r
+          zzmatch(LEXACTION); zzCONSUME;\r
+        }\r
+        else {\r
+          if ( (LA(1)==LEXMEMBER) ) {\r
+            zzmatch(LEXMEMBER); zzCONSUME;\r
+          }\r
+          else {\r
+            if ( (LA(1)==LEXPREFIX) ) {\r
+              zzmatch(LEXPREFIX); zzCONSUME;\r
+            }\r
+            else {\r
+              if ( (LA(1)==PARSERCLASS) ) {\r
+                zzmatch(PARSERCLASS); zzCONSUME;\r
+              }\r
+              else {\r
+                if ( (LA(1)==ACTION) ) {\r
+                }\r
+                else {zzFAIL(1,zzerr1,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
+              }\r
+            }\r
+          }\r
+        }\r
+        zzEXIT(zztasp3);\r
+        }\r
+      }\r
+      zzmatch(ACTION); zzCONSUME;\r
+      zzLOOP(zztasp2);\r
+    }\r
+    zzEXIT(zztasp2);\r
+    }\r
+  }\r
+  if ( gen_cpp ) p_includes();\r
+  start_states();\r
+  func_action = FALSE; p_tables(); p_tail();\r
+  {\r
+    zzBLOCK(zztasp2);\r
+    zzMake0;\r
+    {\r
+    while ( (LA(1)==ACTION) ) {\r
+      zzmatch(ACTION); zzCONSUME;\r
+      zzLOOP(zztasp2);\r
+    }\r
+    zzEXIT(zztasp2);\r
+    }\r
+  }\r
+  zzmatch(1);\r
+  if (firstLexMember != 0) p_class_def1();\r
+ zzCONSUME;\r
+\r
+  zzEXIT(zztasp1);\r
+  return;\r
+fail:\r
+  zzEXIT(zztasp1);\r
+  zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);\r
+  zzresynch(setwd1, 0x2);\r
+  }\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+start_states(void)\r
+#else\r
+start_states()\r
+#endif\r
+{\r
+  zzRULE;\r
+  zzBLOCK(zztasp1);\r
+  zzMake0;\r
+  {\r
+  {\r
+    zzBLOCK(zztasp2);\r
+    zzMake0;\r
+    {\r
+    if ( (LA(1)==PER_PER) ) {\r
+      zzmatch(PER_PER); zzCONSUME;\r
+      do_conversion();\r
+    }\r
+    else {\r
+      if ( (LA(1)==NAME_PER_PER) ) {\r
+        zzmatch(NAME_PER_PER); zzCONSUME;\r
+        do_conversion();\r
+        {\r
+          zzBLOCK(zztasp3);\r
+          zzMake0;\r
+          {\r
+          while ( (LA(1)==NAME_PER_PER) ) {\r
+            zzmatch(NAME_PER_PER); zzCONSUME;\r
+            do_conversion();\r
+            zzLOOP(zztasp3);\r
+          }\r
+          zzEXIT(zztasp3);\r
+          }\r
+        }\r
+      }\r
+      else {zzFAIL(1,zzerr2,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
+    }\r
+    zzEXIT(zztasp2);\r
+    }\r
+  }\r
+  zzmatch(PER_PER); zzCONSUME;\r
+  zzEXIT(zztasp1);\r
+  return;\r
+fail:\r
+  zzEXIT(zztasp1);\r
+  zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);\r
+  zzresynch(setwd1, 0x4);\r
+  }\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+do_conversion(void)\r
+#else\r
+do_conversion()\r
+#endif\r
+{\r
+  zzRULE;\r
+  zzBLOCK(zztasp1);\r
+  zzMake0;\r
+  {\r
+  new_automaton_mode(); func_action = TRUE;\r
+  rule_list();\r
+  \r
+  dfa_class_nop[mode_counter] =\r
+  relabel(zzaArg(zztasp1,1 ).l,comp_level);\r
+  if (comp_level)\r
+  p_shift_table(mode_counter);\r
+  dfa_basep[mode_counter] = dfa_allocated+1;\r
+  make_dfa_model_node(dfa_class_nop[mode_counter]);\r
+  nfa_to_dfa(zzaArg(zztasp1,1 ).l);\r
+  ++mode_counter;\r
+  func_action = FALSE;\r
+#ifdef HASH_STAT\r
+  fprint_hash_stats(stderr);\r
+#endif\r
+  zzEXIT(zztasp1);\r
+  return;\r
+fail:\r
+  zzEXIT(zztasp1);\r
+  zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);\r
+  zzresynch(setwd1, 0x8);\r
+  }\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+rule_list(void)\r
+#else\r
+rule_list()\r
+#endif\r
+{\r
+  zzRULE;\r
+  zzBLOCK(zztasp1);\r
+  zzMake0;\r
+  {\r
+  if ( (setwd1[LA(1)]&0x10) ) {\r
+    rule();\r
+    zzaRet.l=zzaArg(zztasp1,1 ).l; zzaRet.r=zzaArg(zztasp1,1 ).r;\r
+    {\r
+      zzBLOCK(zztasp2);\r
+      zzMake0;\r
+      {\r
+      while ( (setwd1[LA(1)]&0x20) ) {\r
+        rule();\r
+        {nfa_node *t1;\r
+          t1 = new_nfa_node();\r
+          (t1)->trans[0]=zzaRet.l;\r
+          (t1)->trans[1]=zzaArg(zztasp2,1 ).l;\r
+          /* all accept nodes "dead ends" */\r
+          zzaRet.l=t1; zzaRet.r=NULL;\r
+        }\r
+        zzLOOP(zztasp2);\r
+      }\r
+      zzEXIT(zztasp2);\r
+      }\r
+    }\r
+  }\r
+  else {\r
+    if ( (setwd1[LA(1)]&0x40) ) {\r
+      zzaRet.l = new_nfa_node(); zzaRet.r = NULL;\r
+      warning("no regular expressions", zzline);\r
+    }\r
+    else {zzFAIL(1,zzerr3,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
+  }\r
+  zzEXIT(zztasp1);\r
+  return;\r
+fail:\r
+  zzEXIT(zztasp1);\r
+  zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);\r
+  zzresynch(setwd1, 0x80);\r
+  }\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+rule(void)\r
+#else\r
+rule()\r
+#endif\r
+{\r
+  zzRULE;\r
+  zzBLOCK(zztasp1);\r
+  zzMake0;\r
+  {\r
+  if ( (setwd2[LA(1)]&0x1) ) {\r
+    reg_expr();\r
+    zzmatch(ACTION);\r
+    if (zzaArg(zztasp1,1 ).r != NULL) {\r
+      zzaRet.l=zzaArg(zztasp1,1 ).l; zzaRet.r=zzaArg(zztasp1,1 ).r; (zzaArg(zztasp1,1 ).r)->accept=action_no;\r
+    }\r
+ zzCONSUME;\r
+\r
+  }\r
+  else {\r
+    if ( (LA(1)==ACTION) ) {\r
+      zzmatch(ACTION);\r
+      zzaRet.l = NULL; zzaRet.r = NULL;\r
+      error("no expression for action  ", zzline);\r
+ zzCONSUME;\r
+\r
+    }\r
+    else {zzFAIL(1,zzerr4,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
+  }\r
+  zzEXIT(zztasp1);\r
+  return;\r
+fail:\r
+  zzEXIT(zztasp1);\r
+  zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);\r
+  zzresynch(setwd2, 0x2);\r
+  }\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+reg_expr(void)\r
+#else\r
+reg_expr()\r
+#endif\r
+{\r
+  zzRULE;\r
+  zzBLOCK(zztasp1);\r
+  zzMake0;\r
+  {\r
+  and_expr();\r
+  zzaRet.l=zzaArg(zztasp1,1 ).l; zzaRet.r=zzaArg(zztasp1,1 ).r;\r
+  {\r
+    zzBLOCK(zztasp2);\r
+    zzMake0;\r
+    {\r
+    while ( (LA(1)==OR) ) {\r
+      zzmatch(OR); zzCONSUME;\r
+      and_expr();\r
+      {nfa_node *t1, *t2;\r
+        t1 = new_nfa_node(); t2 = new_nfa_node();\r
+        (t1)->trans[0]=zzaRet.l;\r
+        (t1)->trans[1]=zzaArg(zztasp2,2 ).l;\r
+        /* MR23 */                if (zzaRet.r != NULL) (zzaRet.r)->trans[1]=t2;\r
+        if (zzaArg(zztasp2,2 ).r) {\r
+          (zzaArg(zztasp2,2 ).r)->trans[1]=t2;     /* MR20 */\r
+        }\r
+        zzaRet.l=t1; zzaRet.r=t2;\r
+      }\r
+      zzLOOP(zztasp2);\r
+    }\r
+    zzEXIT(zztasp2);\r
+    }\r
+  }\r
+  zzEXIT(zztasp1);\r
+  return;\r
+fail:\r
+  zzEXIT(zztasp1);\r
+  zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);\r
+  zzresynch(setwd2, 0x4);\r
+  }\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+and_expr(void)\r
+#else\r
+and_expr()\r
+#endif\r
+{\r
+  zzRULE;\r
+  zzBLOCK(zztasp1);\r
+  zzMake0;\r
+  {\r
+  repeat_expr();\r
+  \r
+  zzaRet.l=zzaArg(zztasp1,1 ).l; zzaRet.r=zzaArg(zztasp1,1 ).r;\r
+  {\r
+    zzBLOCK(zztasp2);\r
+    zzMake0;\r
+    {\r
+    while ( (setwd2[LA(1)]&0x8) ) {\r
+      repeat_expr();\r
+      if (zzaRet.r != NULL) {\r
+        (zzaRet.r)->trans[1]=zzaArg(zztasp2,1 ).l;\r
+        zzaRet.r=zzaArg(zztasp2,1 ).r;\r
+      }\r
+      zzLOOP(zztasp2);\r
+    }\r
+    zzEXIT(zztasp2);\r
+    }\r
+  }\r
+  zzEXIT(zztasp1);\r
+  return;\r
+fail:\r
+  zzEXIT(zztasp1);\r
+  zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);\r
+  zzresynch(setwd2, 0x10);\r
+  }\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+repeat_expr(void)\r
+#else\r
+repeat_expr()\r
+#endif\r
+{\r
+  zzRULE;\r
+  zzBLOCK(zztasp1);\r
+  zzMake0;\r
+  {\r
+  if ( (setwd2[LA(1)]&0x20) ) {\r
+    expr();\r
+    zzaRet.l=zzaArg(zztasp1,1 ).l; zzaRet.r=zzaArg(zztasp1,1 ).r;\r
+    {\r
+      zzBLOCK(zztasp2);\r
+      zzMake0;\r
+      {\r
+      if ( (LA(1)==ZERO_MORE) ) {\r
+        zzmatch(ZERO_MORE);\r
+        {      nfa_node *t1,*t2;\r
+          /* MR23 */           if (zzaRet.r != NULL) (zzaRet.r)->trans[0] = zzaRet.l;\r
+          t1 = new_nfa_node(); t2 = new_nfa_node();\r
+          t1->trans[0]=zzaRet.l;\r
+          t1->trans[1]=t2;\r
+          /* MR23 */           if (zzaRet.r != NULL) (zzaRet.r)->trans[1]=t2;\r
+          zzaRet.l=t1;zzaRet.r=t2;\r
+        }\r
+ zzCONSUME;\r
+\r
+      }\r
+      else {\r
+        if ( (LA(1)==ONE_MORE) ) {\r
+          zzmatch(ONE_MORE);\r
+          if (zzaRet.r != NULL) (zzaRet.r)->trans[0] = zzaRet.l;\r
+ zzCONSUME;\r
+\r
+        }\r
+        else {\r
+          if ( (setwd2[LA(1)]&0x40) ) {\r
+          }\r
+          else {zzFAIL(1,zzerr5,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
+        }\r
+      }\r
+      zzEXIT(zztasp2);\r
+      }\r
+    }\r
+  }\r
+  else {\r
+    if ( (LA(1)==ZERO_MORE) ) {\r
+      zzmatch(ZERO_MORE);\r
+      error("no expression for *", zzline);\r
+ zzCONSUME;\r
+\r
+    }\r
+    else {\r
+      if ( (LA(1)==ONE_MORE) ) {\r
+        zzmatch(ONE_MORE);\r
+        error("no expression for +", zzline);\r
+ zzCONSUME;\r
+\r
+      }\r
+      else {zzFAIL(1,zzerr6,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
+    }\r
+  }\r
+  zzEXIT(zztasp1);\r
+  return;\r
+fail:\r
+  zzEXIT(zztasp1);\r
+  zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);\r
+  zzresynch(setwd2, 0x80);\r
+  }\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+expr(void)\r
+#else\r
+expr()\r
+#endif\r
+{\r
+  zzRULE;\r
+  zzBLOCK(zztasp1);\r
+  zzMake0;\r
+  {\r
+  zzaRet.l = new_nfa_node();\r
+  zzaRet.r = new_nfa_node();\r
+  if ( (LA(1)==L_BRACK) ) {\r
+    zzmatch(L_BRACK); zzCONSUME;\r
+    atom_list();\r
+    zzmatch(R_BRACK);\r
+    \r
+    /* MR23 */         if (zzaRet.l != NULL) {\r
+      (zzaRet.l)->trans[0] = zzaRet.r;\r
+      (zzaRet.l)->label = set_dup(zzaArg(zztasp1,2 ).label);\r
+      set_orin(&used_chars,(zzaRet.l)->label);\r
+    }\r
+ zzCONSUME;\r
+\r
+  }\r
+  else {\r
+    if ( (LA(1)==NOT) ) {\r
+      zzmatch(NOT); zzCONSUME;\r
+      zzmatch(L_BRACK); zzCONSUME;\r
+      atom_list();\r
+      zzmatch(R_BRACK);\r
+      \r
+      /* MR23 */               if (zzaRet.l != NULL) {\r
+        (zzaRet.l)->trans[0] = zzaRet.r;\r
+        (zzaRet.l)->label = set_dif(normal_chars,zzaArg(zztasp1,3 ).label);\r
+        set_orin(&used_chars,(zzaRet.l)->label);\r
+      }\r
+ zzCONSUME;\r
+\r
+    }\r
+    else {\r
+      if ( (LA(1)==L_PAR) ) {\r
+        zzmatch(L_PAR); zzCONSUME;\r
+        reg_expr();\r
+        zzmatch(R_PAR);\r
+        \r
+        /* MR23 */             if (zzaRet.l != NULL) {                         \r
+          (zzaRet.l)->trans[0] = zzaArg(zztasp1,2 ).l;\r
+          if (zzaArg(zztasp1,2 ).r) {\r
+            (zzaArg(zztasp1,2 ).r)->trans[1] = zzaRet.r;    /* MR20 */\r
+          }\r
+        }\r
+ zzCONSUME;\r
+\r
+      }\r
+      else {\r
+        if ( (LA(1)==L_BRACE) ) {\r
+          zzmatch(L_BRACE); zzCONSUME;\r
+          reg_expr();\r
+          zzmatch(R_BRACE);\r
+          \r
+          /* MR23 */           if (zzaRet.l != NULL) {\r
+            (zzaRet.l)->trans[0] = zzaArg(zztasp1,2 ).l;\r
+            (zzaRet.l)->trans[1] = zzaRet.r;\r
+            if (zzaArg(zztasp1,2 ).r) {\r
+              (zzaArg(zztasp1,2 ).r)->trans[1] = zzaRet.r;    /* MR20 */\r
+            }\r
+          }\r
+ zzCONSUME;\r
+\r
+        }\r
+        else {\r
+          if ( (setwd3[LA(1)]&0x1) ) {\r
+            atom();\r
+            \r
+            /* MR23 */         if (zzaRet.l != NULL) {\r
+              (zzaRet.l)->trans[0] = zzaRet.r;\r
+              (zzaRet.l)->label = set_dup(zzaArg(zztasp1,1 ).label);\r
+              set_orin(&used_chars,(zzaRet.l)->label);\r
+            }\r
+          }\r
+          else {zzFAIL(1,zzerr7,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
+        }\r
+      }\r
+    }\r
+  }\r
+  zzEXIT(zztasp1);\r
+  return;\r
+fail:\r
+  zzEXIT(zztasp1);\r
+  zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);\r
+  zzresynch(setwd3, 0x2);\r
+  }\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+atom_list(void)\r
+#else\r
+atom_list()\r
+#endif\r
+{\r
+  zzRULE;\r
+  zzBLOCK(zztasp1);\r
+  zzMake0;\r
+  {\r
+  set_free(zzaRet.label);\r
+  {\r
+    zzBLOCK(zztasp2);\r
+    zzMake0;\r
+    {\r
+    while ( (setwd3[LA(1)]&0x4) ) {\r
+      near_atom();\r
+      set_orin(&(zzaRet.label),zzaArg(zztasp2,1 ).label);\r
+      zzLOOP(zztasp2);\r
+    }\r
+    zzEXIT(zztasp2);\r
+    }\r
+  }\r
+  zzEXIT(zztasp1);\r
+  return;\r
+fail:\r
+  zzEXIT(zztasp1);\r
+  zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);\r
+  zzresynch(setwd3, 0x8);\r
+  }\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+near_atom(void)\r
+#else\r
+near_atom()\r
+#endif\r
+{\r
+  zzRULE;\r
+  zzBLOCK(zztasp1);\r
+  zzMake0;\r
+  {\r
+  register int i;\r
+  register int i_prime;\r
+  anychar();\r
+  zzaRet.letter=zzaArg(zztasp1,1 ).letter; zzaRet.label=set_of(zzaArg(zztasp1,1 ).letter);\r
+  i_prime = zzaArg(zztasp1,1 ).letter + MIN_CHAR;\r
+  if (case_insensitive && islower(i_prime))\r
+  set_orel(toupper(i_prime)-MIN_CHAR,\r
+  &(zzaRet.label));\r
+  if (case_insensitive && isupper(i_prime))\r
+  set_orel(tolower(i_prime)-MIN_CHAR,\r
+  &(zzaRet.label));\r
+  {\r
+    zzBLOCK(zztasp2);\r
+    zzMake0;\r
+    {\r
+    if ( (LA(1)==RANGE) ) {\r
+      zzmatch(RANGE); zzCONSUME;\r
+      anychar();\r
+      if (case_insensitive){\r
+        i_prime = zzaRet.letter+MIN_CHAR;\r
+        zzaRet.letter = (islower(i_prime) ?\r
+        toupper(i_prime) : i_prime)-MIN_CHAR;\r
+        i_prime = zzaArg(zztasp2,2 ).letter+MIN_CHAR;\r
+        zzaArg(zztasp2,2 ).letter = (islower(i_prime) ?\r
+        toupper(i_prime) : i_prime)-MIN_CHAR;\r
+      }\r
+      /* check to see if range okay */\r
+      {\r
+        int debugLetter1 = zzaRet.letter;\r
+        int debugLetter2 = zzaArg(zztasp2,2 ).letter;\r
+      }\r
+      if (zzaRet.letter > zzaArg(zztasp2,2 ).letter \r
+      && zzaArg(zztasp2,2 ).letter != 0xff){       /* MR16 */\r
+        error("invalid range  ", zzline);\r
+      }\r
+      for (i=zzaRet.letter; i<= (int)zzaArg(zztasp2,2 ).letter; ++i){\r
+        set_orel(i,&(zzaRet.label));\r
+        i_prime = i+MIN_CHAR;\r
+        if (case_insensitive && islower(i_prime))\r
+        set_orel(toupper(i_prime)-MIN_CHAR,\r
+        &(zzaRet.label));\r
+        if (case_insensitive && isupper(i_prime))\r
+        set_orel(tolower(i_prime)-MIN_CHAR,\r
+        &(zzaRet.label));\r
+      }\r
+    }\r
+    else {\r
+      if ( (setwd3[LA(1)]&0x10) ) {\r
+      }\r
+      else {zzFAIL(1,zzerr8,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
+    }\r
+    zzEXIT(zztasp2);\r
+    }\r
+  }\r
+  zzEXIT(zztasp1);\r
+  return;\r
+fail:\r
+  zzEXIT(zztasp1);\r
+  zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);\r
+  zzresynch(setwd3, 0x20);\r
+  }\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+atom(void)\r
+#else\r
+atom()\r
+#endif\r
+{\r
+  zzRULE;\r
+  zzBLOCK(zztasp1);\r
+  zzMake0;\r
+  {\r
+  register int i_prime;\r
+  anychar();\r
+  zzaRet.label = set_of(zzaArg(zztasp1,1 ).letter);\r
+  i_prime = zzaArg(zztasp1,1 ).letter + MIN_CHAR;\r
+  if (case_insensitive && islower(i_prime))\r
+  set_orel(toupper(i_prime)-MIN_CHAR,\r
+  &(zzaRet.label));\r
+  if (case_insensitive && isupper(i_prime))\r
+  set_orel(tolower(i_prime)-MIN_CHAR,\r
+  &(zzaRet.label));\r
+  zzEXIT(zztasp1);\r
+  return;\r
+fail:\r
+  zzEXIT(zztasp1);\r
+  zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);\r
+  zzresynch(setwd3, 0x40);\r
+  }\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+anychar(void)\r
+#else\r
+anychar()\r
+#endif\r
+{\r
+  zzRULE;\r
+  zzBLOCK(zztasp1);\r
+  zzMake0;\r
+  {\r
+  if ( (LA(1)==REGCHAR) ) {\r
+    zzmatch(REGCHAR);\r
+    zzaRet.letter = zzaArg(zztasp1,1 ).letter - MIN_CHAR;\r
+ zzCONSUME;\r
+\r
+  }\r
+  else {\r
+    if ( (LA(1)==OCTAL_VALUE) ) {\r
+      zzmatch(OCTAL_VALUE);\r
+      zzaRet.letter = zzaArg(zztasp1,1 ).letter - MIN_CHAR;\r
+ zzCONSUME;\r
+\r
+    }\r
+    else {\r
+      if ( (LA(1)==HEX_VALUE) ) {\r
+        zzmatch(HEX_VALUE);\r
+        zzaRet.letter = zzaArg(zztasp1,1 ).letter - MIN_CHAR;\r
+ zzCONSUME;\r
+\r
+      }\r
+      else {\r
+        if ( (LA(1)==DEC_VALUE) ) {\r
+          zzmatch(DEC_VALUE);\r
+          zzaRet.letter = zzaArg(zztasp1,1 ).letter - MIN_CHAR;\r
+ zzCONSUME;\r
+\r
+        }\r
+        else {\r
+          if ( (LA(1)==TAB) ) {\r
+            zzmatch(TAB);\r
+            zzaRet.letter = zzaArg(zztasp1,1 ).letter - MIN_CHAR;\r
+ zzCONSUME;\r
+\r
+          }\r
+          else {\r
+            if ( (LA(1)==NL) ) {\r
+              zzmatch(NL);\r
+              zzaRet.letter = zzaArg(zztasp1,1 ).letter - MIN_CHAR;\r
+ zzCONSUME;\r
+\r
+            }\r
+            else {\r
+              if ( (LA(1)==CR) ) {\r
+                zzmatch(CR);\r
+                zzaRet.letter = zzaArg(zztasp1,1 ).letter - MIN_CHAR;\r
+ zzCONSUME;\r
+\r
+              }\r
+              else {\r
+                if ( (LA(1)==BS) ) {\r
+                  zzmatch(BS);\r
+                  zzaRet.letter = zzaArg(zztasp1,1 ).letter - MIN_CHAR;\r
+ zzCONSUME;\r
+\r
+                }\r
+                else {\r
+                  if ( (LA(1)==LIT) ) {\r
+                    zzmatch(LIT);\r
+                    zzaRet.letter = zzaArg(zztasp1,1 ).letter - MIN_CHAR;\r
+ zzCONSUME;\r
+\r
+                  }\r
+                  else {\r
+                    if ( (LA(1)==L_EOF) ) {\r
+                      zzmatch(L_EOF);\r
+                      zzaRet.letter = 0;\r
+ zzCONSUME;\r
+\r
+                    }\r
+                    else {zzFAIL(1,zzerr9,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
+                  }\r
+                }\r
+              }\r
+            }\r
+          }\r
+        }\r
+      }\r
+    }\r
+  }\r
+  zzEXIT(zztasp1);\r
+  return;\r
+fail:\r
+  zzEXIT(zztasp1);\r
+  /* empty action */  \r
+  zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);\r
+  zzresynch(setwd3, 0x80);\r
+  }\r
+}\r
+\r
+/* adds a new nfa to the binary tree and returns a pointer to it */\r
+nfa_node *\r
+#ifdef __USE_PROTOS\r
+new_nfa_node(void)\r
+#else\r
+new_nfa_node()\r
+#endif\r
+{\r
+  register nfa_node *t;\r
+  static int nfa_size=0;       /* elements nfa_array[] can hold */\r
+  \r
+       ++nfa_allocated;\r
+  if (nfa_size<=nfa_allocated){\r
+    /* need to redo array */\r
+    if (!nfa_array){\r
+      /* need some to do inital allocation */\r
+      nfa_size=nfa_allocated+NFA_MIN;\r
+      nfa_array=(nfa_node **) malloc(sizeof(nfa_node*)*\r
+      nfa_size);\r
+    }else{\r
+      /* need more space */\r
+      nfa_size=2*(nfa_allocated+1);\r
+      nfa_array=(nfa_node **) realloc(nfa_array,\r
+      sizeof(nfa_node*)*nfa_size);\r
+    }\r
+  }\r
+  /* fill out entry in array */\r
+  t = (nfa_node*) malloc(sizeof(nfa_node));\r
+  nfa_array[nfa_allocated] = t;\r
+  *t = nfa_model_node;\r
+  t->node_no = nfa_allocated;\r
+  return t;\r
+}\r
+\r
+\r
+/* initialize the model node used to fill in newly made nfa_nodes */\r
+void\r
+#ifdef __USE_PROTOS\r
+make_nfa_model_node(void)\r
+#else\r
+make_nfa_model_node()\r
+#endif\r
+{\r
+  nfa_model_node.node_no = -1; /* impossible value for real nfa node */\r
+  nfa_model_node.nfa_set = 0;\r
+  nfa_model_node.accept = 0;   /* error state default*/\r
+  nfa_model_node.trans[0] = NULL;\r
+  nfa_model_node.trans[1] = NULL;\r
+  nfa_model_node.label = empty;\r
+}\r
+\r
+#if defined(DEBUG) || defined(_DEBUG)\r
+\r
+/* print out the pointer value and the node_number */\r
+void\r
+#ifdef __USE_PROTOS\r
+fprint_dfa_pair(FILE *f, nfa_node *p)\r
+#else\r
+fprint_dfa_pair(f, p)\r
+FILE *f;\r
+nfa_node *p;\r
+#endif\r
+{\r
+  if (p){\r
+    fprintf(f, "%x (%d)", p, p->node_no);\r
+  }else{\r
+    fprintf(f, "(nil)");\r
+  }\r
+}\r
+\r
+/* print out interest information on a set */\r
+void\r
+#ifdef __USE_PROTOS\r
+fprint_set(FILE *f, set s)\r
+#else\r
+fprint_set(f,s)\r
+FILE *f;\r
+set s;\r
+#endif\r
+{\r
+  unsigned int *x;\r
+  \r
+       fprintf(f, "n = %d,", s.n);\r
+  if (s.setword){\r
+    fprintf(f, "setword = %x,   ", s.setword);\r
+    /* print out all the elements in the set */\r
+    x = set_pdq(s);\r
+    while (*x!=nil){\r
+      fprintf(f, "%d ", *x);\r
+      ++x;\r
+    }\r
+  }else{\r
+    fprintf(f, "setword = (nil)");\r
+  }\r
+}\r
+\r
+/* code to be able to dump out the nfas\r
+return 0 if okay dump\r
+return 1 if screwed up\r
+*/\r
+int\r
+#ifdef __USE_PROTOS\r
+dump_nfas(int first_node, int last_node)\r
+#else\r
+dump_nfas(first_node, last_node)\r
+int first_node;\r
+int last_node;\r
+#endif\r
+{\r
+  register int i;\r
+  nfa_node *t;\r
+  \r
+       for (i=first_node; i<=last_node; ++i){\r
+    t = NFA(i);\r
+    if (!t) break;\r
+    fprintf(stderr, "nfa_node %d {\n", t->node_no);\r
+    fprintf(stderr, "\n\tnfa_set = %d\n", t->nfa_set);\r
+    fprintf(stderr, "\taccept\t=\t%d\n", t->accept);\r
+    fprintf(stderr, "\ttrans\t=\t(");\r
+    fprint_dfa_pair(stderr, t->trans[0]);\r
+    fprintf(stderr, ",");\r
+    fprint_dfa_pair(stderr, t->trans[1]);\r
+    fprintf(stderr, ")\n");\r
+    fprintf(stderr, "\tlabel\t=\t{ ");\r
+    fprint_set(stderr, t->label);\r
+    fprintf(stderr, "\t}\n");\r
+    fprintf(stderr, "}\n\n");\r
+  }\r
+  return 0;\r
+}\r
+#endif\r
+\r
+/* DLG-specific syntax error message generator\r
+* (define USER_ZZSYN when compiling so don't get 2 definitions)\r
+*/\r
+void\r
+#ifdef __USE_PROTOS\r
+zzsyn(char *text, int tok, char *egroup, SetWordType *eset, int etok, int k, char *bad_text)\r
+#else\r
+zzsyn(text, tok, egroup, eset, etok, k, bad_text)\r
+char *text, *egroup, *bad_text;\r
+int tok;\r
+int etok;\r
+int k;\r
+SetWordType *eset;\r
+#endif\r
+{\r
+fprintf(stderr, ErrHdr, file_str[0]!=NULL?file_str[0]:"stdin", zzline);\r
+fprintf(stderr, " syntax error at \"%s\"", (tok==zzEOF_TOKEN)?"EOF":text);\r
+if ( !etok && !eset ) {fprintf(stderr, "\n"); return;}\r
+if ( k==1 ) fprintf(stderr, " missing");\r
+else\r
+{\r
+fprintf(stderr, "; \"%s\" not", bad_text);\r
+if ( zzset_deg(eset)>1 ) fprintf(stderr, " in");\r
+}\r
+if ( zzset_deg(eset)>0 ) zzedecode(eset);\r
+else fprintf(stderr, " %s", zztokens[etok]);\r
+if ( strlen(egroup) > (size_t)0 ) fprintf(stderr, " in %s", egroup);\r
+fprintf(stderr, "\n");\r
+}\r
diff --git a/Tools/CodeTools/Source/Pccts/dlg/dlg_p.g b/Tools/CodeTools/Source/Pccts/dlg/dlg_p.g
new file mode 100644 (file)
index 0000000..58ca110
--- /dev/null
@@ -0,0 +1,614 @@
+/*  This is the parser for the dlg\r
+ *  This is a part of the Purdue Compiler Construction Tool Set\r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
+ * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
+ * company may do whatever they wish with source code distributed with\r
+ * PCCTS or the code generated by PCCTS, including the incorporation of\r
+ * PCCTS, or its output, into commerical software.\r
+ *\r
+ * We encourage users to develop software with PCCTS.  However, we do ask\r
+ * that credit is given to us for developing PCCTS.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like PCCTS and have developed a nice tool with the\r
+ * output, please mention that you developed it using PCCTS.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * DLG 1.33\r
+ * Will Cohen\r
+ * With mods by Terence Parr; AHPCRC, University of Minnesota\r
+ * 1989-1995\r
+ */\r
+\r
+#header        <<\r
+#include <ctype.h>\r
+#include "dlg.h"\r
+>>\r
+\r
+<<\r
+\r
+/* MR20 G. Hobbelt \r
+   Fix for Borland C++ 4.x & 5.x compiling with ALL warnings enabled\r
+*/\r
+\r
+#ifdef __TURBOC__\r
+#pragma warn -aus  /* unused assignment of 'xxx' */\r
+#endif\r
+\r
+int    action_no = 0;     /* keep track of actions outputed */\r
+int    nfa_allocated = 0; /* keeps track of number of nfa nodes */\r
+nfa_node **nfa_array = NULL;/* root of binary tree that stores nfa array */\r
+nfa_node nfa_model_node;   /* model to initialize new nodes */\r
+set    used_chars;        /* used to label trans. arcs */\r
+set    used_classes;      /* classes or chars used to label trans. arcs */\r
+set    normal_chars;      /* mask to get rid elements that aren't used\r
+                             in set */\r
+int    flag_paren = FALSE;\r
+int    flag_brace = FALSE;\r
+int    mode_counter = 0;  /* keep track of number of %%names */\r
+\r
+>>\r
+\r
+#lexaction <<\r
+int    func_action;            /* should actions be turned into functions?*/\r
+int    lex_mode_counter = 0;   /* keeps track of the number of %%names */\r
+/* MR1                                                                     */\r
+/* MR1  11-Apr-97      Provide mechanism for inserting code into DLG class */\r
+/* MR1                         via <<%%lexmember...>>                      */\r
+/* MR1                                                                     */\r
+int    lexMember = 0;          /* <<%%lexmemeber ...>>                 MR1 */\r
+int    lexAction = 0;          /* <<%%lexaction ...>>                  MR1 */\r
+int    parserClass = 0;        /* <<%%parserclass ...>>        MR1 */\r
+int    lexPrefix = 0;          /* <<%%lexprefix ...>>                  MR1 */\r
+char   theClassName[100];                                                   /* MR11 */\r
+char   *pClassName=theClassName;                                        /* MR11 */\r
+int    firstLexMember=1;                                                    /* MR1 */\r
+\r
+#ifdef __USE_PROTOS\r
+void  xxputc(int c) {                                          /* MR1 */\r
+#else\r
+void xxputc(c)                                                 /* MR1 */\r
+  int  c;                                                      /* MR1 */\r
+{                                                              /* MR1 */\r
+#endif\r
+  if (parserClass) {                                           /* MR1 */\r
+    *pClassName++=c;                                           /* MR1 */\r
+    *pClassName=0;                                             /* MR1 */\r
+  } else if (lexMember || lexPrefix) {                         /* MR1 */\r
+    if (class_stream != NULL) fputc(c,class_stream);           /* MR1 */\r
+  } else {                                                     /* MR1 */\r
+    fputc(c,OUT);                                              /* MR1 */\r
+  };                                                           /* MR1 */\r
+}                                                              /* MR1 */\r
+\r
+#ifdef __USE_PROTOS\r
+void xxprintf(char *format,char *string) {                     /* MR1 */\r
+#else\r
+void xxprintf(format,string)                                   /* MR1 */\r
+  char *format;                                                        /* MR1 */\r
+  char *string;                                                        /* MR1 */\r
+{                                                              /* MR1 */\r
+#endif\r
+  if (lexMember || lexPrefix || parserClass) {                 /* MR1 */\r
+    if (class_stream != NULL)                                  /* MR1 */\r
+        fprintf(class_stream,format,string);                   /* MR1 */\r
+  } else {                                                     /* MR1 */\r
+    fprintf(OUT,format,string);                                        /* MR1 */\r
+  };                                                           /* MR1 */\r
+}                                                              /* MR1 */\r
+>>\r
+\r
+#token "[\r\t\ ]+"     << zzskip(); >>                                         /* Ignore white */\r
+#token "\n"                    << zzline++; zzskip(); DAWDLE; >>       /* Track Line # */\r
+#token L_EOF           "\@"\r
+#token PER_PER         "\%\%"\r
+#token NAME_PER_PER    "\%\%[a-zA-Z_][a-zA-Z0-9_]*"\r
+               << p_mode_def(&zzlextext[2],lex_mode_counter++); >>\r
+\r
+#token LEXMEMBER       "\<\<\%\%lexmember"                     /* MR1 */\r
+               <<lexMember=1;                                  /* MR1 */\r
+                 if (firstLexMember != 0) {                    /* MR1 */\r
+                   firstLexMember=0;                           /* MR1 */\r
+                   p_class_def1();                             /* MR1 */\r
+                 };                                            /* MR1 */\r
+                 zzmode(ACT);                                  /* MR1 */\r
+                >>                                             /* MR1 */\r
+#token LEXACTION       "\<\<\%\%lexaction"                     /* MR1 */\r
+               <<lexAction=1;zzmode(ACT);>>                    /* MR1 */\r
+#token PARSERCLASS     "\<\<\%\%parserclass"                   /* MR1 */\r
+               <<parserClass=1;                                /* MR1 */\r
+                 zzmode(ACT);                                  /* MR1 */\r
+               >>                                              /* MR1 */\r
+#token LEXPREFIX       "\<\<\%\%lexprefix"                     /* MR1 */\r
+               <<lexPrefix=1;zzmode(ACT);>>                    /* MR1 */\r
+\r
+#token ACTION          "\<\<"\r
+               << if (func_action)\r
+                       fprintf(OUT,"\n%s %sact%d()\n{ ",\r
+                                       gen_cpp?"ANTLRTokenType":"static void",\r
+                                       gen_cpp?ClassName("::"):"", ++action_no);\r
+                  zzmode(ACT); zzskip();\r
+               >>\r
+#token GREAT_GREAT     "\>\>"\r
+#token L_BRACE         "\{"\r
+#token R_BRACE         "\}"\r
+#token L_PAR           "\("\r
+#token R_PAR           "\)"\r
+#token L_BRACK         "\["\r
+#token R_BRACK         "\]"\r
+#token ZERO_MORE       "\*"\r
+#token ONE_MORE                "\+"\r
+#token OR              "\|"\r
+#token RANGE           "\-"\r
+#token NOT             "\~"\r
+#token OCTAL_VALUE "\\0[0-7]*"         \r
+       << {int t; sscanf(&zzlextext[1],"%o",&t); zzlextext[0] = t;}>>\r
+#token HEX_VALUE   "\\0[Xx][0-9a-fA-F]+"\r
+       << {int t; sscanf(&zzlextext[3],"%x",&t); zzlextext[0] = t;}>>\r
+#token DEC_VALUE   "\\[1-9][0-9]*"\r
+       << {int t; sscanf(&zzlextext[1],"%d",&t); zzlextext[0] = t;}>>\r
+#token TAB             "\\t"           << zzlextext[0] = '\t';>>\r
+#token NL              "\\n"           << zzlextext[0] = '\n';>>\r
+#token CR              "\\r"           << zzlextext[0] = '\r';>>\r
+#token BS              "\\b"           << zzlextext[0] = '\b';>>\r
+\r
+/* MR1                                                                 */\r
+/* MR1 10-Apr-97 MR1   Allow #token regular expressions to cross lines */\r
+/* MR1                                                                 */\r
+#token CONTINUATION    "\\ \n"         << zzline++; zzskip();>> /* MR1 */\r
+\r
+/* NOTE: this takes ANYTHING after the \ */\r
+#token LIT             "\\~[tnrb]"     << zzlextext[0] = zzlextext[1];>>\r
+\r
+/* NOTE: this takes ANYTHING that doesn't match the other tokens */\r
+#token REGCHAR         "~[\\]"\r
+\r
+\r
+grammar                :   << p_head(); p_class_hdr(); func_action = FALSE;>>\r
+                ( {LEXACTION | LEXMEMBER | LEXPREFIX | PARSERCLASS } ACTION)* /* MR1 */\r
+                   <<if ( gen_cpp ) p_includes();>>\r
+                   start_states\r
+                   << func_action = FALSE; p_tables(); p_tail(); >>\r
+                   (ACTION)* "@"\r
+                       << if (firstLexMember != 0) p_class_def1(); >>          /* MR1 */\r
+               ;\r
+\r
+start_states   : ( PER_PER do_conversion\r
+                 | NAME_PER_PER do_conversion (NAME_PER_PER do_conversion)*)\r
+                   PER_PER\r
+               ;\r
+\r
+do_conversion  : <<new_automaton_mode(); func_action = TRUE;>>\r
+                       rule_list\r
+                       <<\r
+                               dfa_class_nop[mode_counter] =\r
+                                       relabel($1.l,comp_level);\r
+                               if (comp_level)\r
+                                       p_shift_table(mode_counter);\r
+                               dfa_basep[mode_counter] = dfa_allocated+1;\r
+                               make_dfa_model_node(dfa_class_nop[mode_counter]);\r
+                               nfa_to_dfa($1.l);\r
+                               ++mode_counter;\r
+                               func_action = FALSE;\r
+#ifdef HASH_STAT\r
+                               fprint_hash_stats(stderr);\r
+#endif\r
+                       >>\r
+               ;\r
+\r
+rule_list      : rule <<$$.l=$1.l; $$.r=$1.r;>>\r
+                       (rule\r
+                               <<{nfa_node *t1;\r
+                                  t1 = new_nfa_node();\r
+                                  (t1)->trans[0]=$$.l;\r
+                                  (t1)->trans[1]=$1.l;\r
+                                  /* all accept nodes "dead ends" */\r
+                                  $$.l=t1; $$.r=NULL;\r
+                                  }\r
+                               >>\r
+                       )*\r
+               | /* empty */\r
+                       <<$$.l = new_nfa_node(); $$.r = NULL;\r
+                          warning("no regular expressions", zzline);\r
+                       >>\r
+               ;\r
+\r
+rule   : reg_expr ACTION\r
+/* MR23 */             << if ($1.r != NULL) {\r
+                                       $$.l=$1.l; $$.r=$1.r; ($1.r)->accept=action_no;\r
+                                  }\r
+                               >>\r
+               | ACTION\r
+                       <<$$.l = NULL; $$.r = NULL;\r
+                         error("no expression for action  ", zzline);\r
+                       >>\r
+               ;\r
+\r
+reg_expr       : and_expr <<$$.l=$1.l; $$.r=$1.r;>>\r
+                       (OR and_expr\r
+                               <<{nfa_node *t1, *t2;\r
+                                  t1 = new_nfa_node(); t2 = new_nfa_node();\r
+                                  (t1)->trans[0]=$$.l;\r
+                                  (t1)->trans[1]=$2.l;\r
+/* MR23 */                if ($$.r != NULL) ($$.r)->trans[1]=t2;\r
+                   if ($2.r) {\r
+                                  ($2.r)->trans[1]=t2;     /* MR20 */\r
+                   }\r
+                                  $$.l=t1; $$.r=t2;\r
+                                 }\r
+                               >>\r
+                       )*\r
+               ;\r
+\r
+and_expr       : repeat_expr\r
+                                       <<\r
+                                               $$.l=$1.l; $$.r=$1.r;\r
+                                   >>\r
+                       (repeat_expr \r
+/* MR23 */                             << if ($$.r != NULL) {\r
+                                                       ($$.r)->trans[1]=$1.l;\r
+                                                       $$.r=$1.r;\r
+                                                  }\r
+                                               >>\r
+                       )*\r
+               ;\r
+\r
+repeat_expr    : expr <<$$.l=$1.l; $$.r=$1.r;>>\r
+                       { ZERO_MORE\r
+                       <<{     nfa_node *t1,*t2;\r
+/* MR23 */             if ($$.r != NULL) ($$.r)->trans[0] = $$.l;\r
+                               t1 = new_nfa_node(); t2 = new_nfa_node();\r
+                               t1->trans[0]=$$.l;\r
+                               t1->trans[1]=t2;\r
+/* MR23 */             if ($$.r != NULL) ($$.r)->trans[1]=t2;\r
+                               $$.l=t1;$$.r=t2;\r
+                         }\r
+                       >>\r
+                       | ONE_MORE\r
+/* MR23 */             <<if ($$.r != NULL) ($$.r)->trans[0] = $$.l;>>\r
+                       }\r
+               | ZERO_MORE\r
+                       << error("no expression for *", zzline);>>\r
+               | ONE_MORE\r
+                       << error("no expression for +", zzline);>>\r
+               ;\r
+\r
+expr   : << $$.l = new_nfa_node();\r
+                        $$.r = new_nfa_node();\r
+                 >>\r
+                 L_BRACK atom_list R_BRACK\r
+                       <<\r
+/* MR23 */             if ($$.l != NULL) {\r
+                                       ($$.l)->trans[0] = $$.r;\r
+                                       ($$.l)->label = set_dup($2.label);\r
+                                       set_orin(&used_chars,($$.l)->label);\r
+                               }\r
+                       >>\r
+               | NOT L_BRACK atom_list R_BRACK\r
+                       <<\r
+/* MR23 */             if ($$.l != NULL) {\r
+                                       ($$.l)->trans[0] = $$.r;\r
+                                       ($$.l)->label = set_dif(normal_chars,$3.label);\r
+                                       set_orin(&used_chars,($$.l)->label);\r
+                               }\r
+                       >>\r
+               | L_PAR reg_expr R_PAR\r
+                       <<\r
+/* MR23 */             if ($$.l != NULL) {                             \r
+                                       ($$.l)->trans[0] = $2.l;\r
+                                       if ($2.r) {\r
+                                       ($2.r)->trans[1] = $$.r;    /* MR20 */\r
+                                       }\r
+                               }\r
+                       >>\r
+               | L_BRACE reg_expr R_BRACE\r
+                       <<\r
+/* MR23 */             if ($$.l != NULL) {\r
+                                       ($$.l)->trans[0] = $2.l;\r
+                                       ($$.l)->trans[1] = $$.r;\r
+                               if ($2.r) {\r
+                                       ($2.r)->trans[1] = $$.r;    /* MR20 */\r
+                                       }\r
+                               }\r
+                       >>\r
+               | atom\r
+                       <<\r
+/* MR23 */             if ($$.l != NULL) {\r
+                                       ($$.l)->trans[0] = $$.r;\r
+                                       ($$.l)->label = set_dup($1.label);\r
+                                       set_orin(&used_chars,($$.l)->label);\r
+                               }\r
+                       >>\r
+               ;\r
+\r
+atom_list      : << set_free($$.label); >>\r
+                               (near_atom <<set_orin(&($$.label),$1.label);>>)*\r
+               ;\r
+\r
+near_atom      : << register int i;\r
+                    register int i_prime;\r
+                 >>\r
+                 anychar\r
+                       <<$$.letter=$1.letter; $$.label=set_of($1.letter);\r
+                       i_prime = $1.letter + MIN_CHAR;\r
+                       if (case_insensitive && islower(i_prime))\r
+                               set_orel(toupper(i_prime)-MIN_CHAR,\r
+                                       &($$.label));\r
+                       if (case_insensitive && isupper(i_prime))\r
+                               set_orel(tolower(i_prime)-MIN_CHAR,\r
+                                       &($$.label));\r
+                       >>\r
+                       { RANGE anychar\r
+                               << if (case_insensitive){\r
+                                       i_prime = $$.letter+MIN_CHAR;\r
+                                       $$.letter = (islower(i_prime) ?\r
+                                               toupper(i_prime) : i_prime)-MIN_CHAR;\r
+                                       i_prime = $2.letter+MIN_CHAR;\r
+                                       $2.letter = (islower(i_prime) ?\r
+                                               toupper(i_prime) : i_prime)-MIN_CHAR;\r
+                                  }\r
+                                  /* check to see if range okay */\r
+                                       {\r
+                                           int debugLetter1 = $$.letter;\r
+                                               int debugLetter2 = $2.letter;\r
+                                       }\r
+                                  if ($$.letter > $2.letter \r
+                                       && $2.letter != 0xff){       /* MR16 */\r
+                                         error("invalid range  ", zzline);\r
+                                  }\r
+                                  for (i=$$.letter; i<= (int)$2.letter; ++i){\r
+                                       set_orel(i,&($$.label));\r
+                                       i_prime = i+MIN_CHAR;\r
+                                       if (case_insensitive && islower(i_prime))\r
+                                               set_orel(toupper(i_prime)-MIN_CHAR,\r
+                                                       &($$.label));\r
+                                       if (case_insensitive && isupper(i_prime))\r
+                                               set_orel(tolower(i_prime)-MIN_CHAR,\r
+                                                       &($$.label));\r
+                                       }\r
+                               >>\r
+                       }\r
+               ;\r
+\r
+atom           : << register int i_prime;>>\r
+                 anychar\r
+                 <<$$.label = set_of($1.letter);\r
+                   i_prime = $1.letter + MIN_CHAR;\r
+                   if (case_insensitive && islower(i_prime))\r
+                       set_orel(toupper(i_prime)-MIN_CHAR,\r
+                               &($$.label));\r
+                   if (case_insensitive && isupper(i_prime))\r
+                       set_orel(tolower(i_prime)-MIN_CHAR,\r
+                               &($$.label));\r
+                 >>\r
+               ;\r
+\r
+anychar                : REGCHAR       <<$$.letter = $1.letter - MIN_CHAR;>>\r
+               | OCTAL_VALUE   <<$$.letter = $1.letter - MIN_CHAR;>>\r
+               | HEX_VALUE     <<$$.letter = $1.letter - MIN_CHAR;>>\r
+               | DEC_VALUE     <<$$.letter = $1.letter - MIN_CHAR;>>\r
+               | TAB           <<$$.letter = $1.letter - MIN_CHAR;>>\r
+               | NL            <<$$.letter = $1.letter - MIN_CHAR;>>\r
+               | CR            <<$$.letter = $1.letter - MIN_CHAR;>>\r
+               | BS            <<$$.letter = $1.letter - MIN_CHAR;>>\r
+               | LIT           <<$$.letter = $1.letter - MIN_CHAR;>>\r
+               /* NOTE: LEX_EOF is ALWAYS shifted to 0 = MIN_CHAR - MIN_CHAR*/\r
+               | L_EOF         <<$$.letter = 0;>>\r
+               ;\r
+\r
+<</* empty action */>>\r
+\r
+#lexclass ACT\r
+#token "@"     << error("unterminated action", zzline); zzmode(START); >>\r
+#token ACTION "\>\>"\r
+               << if (func_action) fprintf(OUT,"}\n\n");\r
+                  zzmode(START);\r
+/* MR1                                                                     */\r
+/* MR1  11-Apr-97      Provide mechanism for inserting code into DLG class */\r
+/* MR1                         via <<%%lexmember ...>>                     */\r
+/* MR1                 This is a consequence of not saving actions         */\r
+/* MR1                                                                     */\r
+/* MR1 */         parserClass=0;               \r
+/* MR1 */         lexPrefix=0;\r
+/* MR1 */         lexAction=0;\r
+/* MR1 */         lexMember=0;\r
+               >>\r
+#token "\>"            << xxputc(zzlextext[0]); zzskip(); >>           /* MR1 */\r
+#token "\\\>"          << xxputc('>'); zzskip(); >>                    /* MR1 */\r
+#token "\\"            << xxputc('\\'); zzskip(); >>                   /* MR1 */\r
+#token "\n"            << xxputc(zzlextext[0]); ++zzline; zzskip(); >> /* MR1 */\r
+#token "/\*"           << zzmode(ACTION_COMMENTS);                     /* MR1 */\r
+                          xxprintf("%s", &(zzlextext[0])); zzskip();   /* MR1 */\r
+                       >>                                              /* MR1 */\r
+#token "//"            << zzmode(ACTION_CPP_COMMENTS);                 /* MR1 */\r
+                          xxprintf("%s", &(zzlextext[0])); zzskip();   /* MR1 */\r
+                       >>                                              /* MR1 */\r
+#token "~[]"           << xxputc(zzlextext[0]); zzskip(); >>           /* MR1 */\r
+                                                                       /* MR1 */\r
+#lexclass ACTION_COMMENTS                                              /* MR1 */\r
+#token "\*/"           << zzmode(ACT);                                 /* MR1 */\r
+                          xxprintf("%s", &(zzlextext[0])); zzskip();   /* MR1 */\r
+                       >>                                              /* MR1 */\r
+#token "[\n\r]"                << zzline++; xxputc(zzlextext[0]); zzskip();>>  /* MR1 */\r
+#token "~[]"           << xxputc(zzlextext[0]); zzskip();>>            /* MR1 */\r
+                                                                       /* MR1 */\r
+#lexclass ACTION_CPP_COMMENTS                                          /* MR1 */\r
+#token "[\n\r]"                << zzmode(ACT); zzline++;                       /* MR1 */\r
+                          xxprintf("%s", &(zzlextext[0])); zzskip();   /* MR1 */\r
+                       >>                                              /* MR1 */\r
+#token "~[]"           << xxputc(zzlextext[0]); zzskip();>>            /* MR1 */\r
+\r
+<<\r
+/* adds a new nfa to the binary tree and returns a pointer to it */\r
+nfa_node *\r
+#ifdef __USE_PROTOS\r
+new_nfa_node(void)\r
+#else\r
+new_nfa_node()\r
+#endif\r
+{\r
+       register nfa_node *t;\r
+       static int nfa_size=0;  /* elements nfa_array[] can hold */\r
+\r
+       ++nfa_allocated;\r
+       if (nfa_size<=nfa_allocated){\r
+               /* need to redo array */\r
+               if (!nfa_array){\r
+                       /* need some to do inital allocation */\r
+                       nfa_size=nfa_allocated+NFA_MIN;\r
+                       nfa_array=(nfa_node **) malloc(sizeof(nfa_node*)*\r
+                               nfa_size);\r
+               }else{\r
+                       /* need more space */\r
+                       nfa_size=2*(nfa_allocated+1);\r
+                       nfa_array=(nfa_node **) realloc(nfa_array,\r
+                               sizeof(nfa_node*)*nfa_size);\r
+               }\r
+       }\r
+       /* fill out entry in array */\r
+       t = (nfa_node*) malloc(sizeof(nfa_node));\r
+       nfa_array[nfa_allocated] = t;\r
+       *t = nfa_model_node;\r
+       t->node_no = nfa_allocated;\r
+       return t;\r
+}\r
+\r
+\r
+/* initialize the model node used to fill in newly made nfa_nodes */\r
+void\r
+#ifdef __USE_PROTOS\r
+make_nfa_model_node(void)\r
+#else\r
+make_nfa_model_node()\r
+#endif\r
+{\r
+       nfa_model_node.node_no = -1; /* impossible value for real nfa node */\r
+       nfa_model_node.nfa_set = 0;\r
+       nfa_model_node.accept = 0;   /* error state default*/\r
+       nfa_model_node.trans[0] = NULL;\r
+       nfa_model_node.trans[1] = NULL;\r
+       nfa_model_node.label = empty;\r
+}\r
+>>\r
+\r
+<<\r
+#if defined(DEBUG) || defined(_DEBUG)\r
+\r
+/* print out the pointer value and the node_number */\r
+void\r
+#ifdef __USE_PROTOS\r
+fprint_dfa_pair(FILE *f, nfa_node *p)\r
+#else\r
+fprint_dfa_pair(f, p)\r
+FILE *f;\r
+nfa_node *p;\r
+#endif\r
+{\r
+       if (p){\r
+               fprintf(f, "%x (%d)", p, p->node_no);\r
+       }else{\r
+               fprintf(f, "(nil)");\r
+       }\r
+}\r
+\r
+/* print out interest information on a set */\r
+void\r
+#ifdef __USE_PROTOS\r
+fprint_set(FILE *f, set s)\r
+#else\r
+fprint_set(f,s)\r
+FILE *f;\r
+set s;\r
+#endif\r
+{\r
+       unsigned int *x;\r
+\r
+       fprintf(f, "n = %d,", s.n);\r
+       if (s.setword){\r
+               fprintf(f, "setword = %x,   ", s.setword);\r
+               /* print out all the elements in the set */\r
+               x = set_pdq(s);\r
+               while (*x!=nil){\r
+                       fprintf(f, "%d ", *x);\r
+                       ++x;\r
+               }\r
+       }else{\r
+               fprintf(f, "setword = (nil)");\r
+       }\r
+}\r
+\r
+/* code to be able to dump out the nfas\r
+       return 0 if okay dump\r
+       return 1 if screwed up\r
+ */\r
+int\r
+#ifdef __USE_PROTOS\r
+dump_nfas(int first_node, int last_node)\r
+#else\r
+dump_nfas(first_node, last_node)\r
+int first_node;\r
+int last_node;\r
+#endif\r
+{\r
+       register int i;\r
+       nfa_node *t;\r
+\r
+       for (i=first_node; i<=last_node; ++i){\r
+               t = NFA(i);\r
+               if (!t) break;\r
+               fprintf(stderr, "nfa_node %d {\n", t->node_no);\r
+               fprintf(stderr, "\n\tnfa_set = %d\n", t->nfa_set);\r
+               fprintf(stderr, "\taccept\t=\t%d\n", t->accept);\r
+               fprintf(stderr, "\ttrans\t=\t(");\r
+               fprint_dfa_pair(stderr, t->trans[0]);\r
+               fprintf(stderr, ",");\r
+               fprint_dfa_pair(stderr, t->trans[1]);\r
+               fprintf(stderr, ")\n");\r
+               fprintf(stderr, "\tlabel\t=\t{ ");\r
+               fprint_set(stderr, t->label);\r
+               fprintf(stderr, "\t}\n");\r
+               fprintf(stderr, "}\n\n");\r
+       }\r
+       return 0;\r
+}\r
+#endif\r
+>>\r
+\r
+<<\r
+/* DLG-specific syntax error message generator\r
+ * (define USER_ZZSYN when compiling so don't get 2 definitions)\r
+ */\r
+void\r
+#ifdef __USE_PROTOS\r
+zzsyn(char *text, int tok, char *egroup, SetWordType *eset, int etok, int k, char *bad_text)\r
+#else\r
+zzsyn(text, tok, egroup, eset, etok, k, bad_text)\r
+char *text, *egroup, *bad_text;\r
+int tok;\r
+int etok;\r
+int k;\r
+SetWordType *eset;\r
+#endif\r
+{\r
+       fprintf(stderr, ErrHdr, file_str[0]!=NULL?file_str[0]:"stdin", zzline);\r
+       fprintf(stderr, " syntax error at \"%s\"", (tok==zzEOF_TOKEN)?"EOF":text);\r
+       if ( !etok && !eset ) {fprintf(stderr, "\n"); return;}\r
+       if ( k==1 ) fprintf(stderr, " missing");\r
+       else\r
+       {\r
+               fprintf(stderr, "; \"%s\" not", bad_text);\r
+               if ( zzset_deg(eset)>1 ) fprintf(stderr, " in");\r
+       }\r
+       if ( zzset_deg(eset)>0 ) zzedecode(eset);\r
+       else fprintf(stderr, " %s", zztokens[etok]);\r
+       if ( strlen(egroup) > (size_t)0 ) fprintf(stderr, " in %s", egroup);\r
+       fprintf(stderr, "\n");\r
+}\r
+>>\r
diff --git a/Tools/CodeTools/Source/Pccts/dlg/err.c b/Tools/CodeTools/Source/Pccts/dlg/err.c
new file mode 100644 (file)
index 0000000..c3eaeae
--- /dev/null
@@ -0,0 +1,99 @@
+/*\r
+ * A n t l r  S e t s / E r r o r  F i l e  H e a d e r\r
+ *\r
+ * Generated from: dlg_p.g\r
+ *\r
+ * Terence Parr, Russell Quong, Will Cohen, and Hank Dietz: 1989-2001\r
+ * Parr Research Corporation\r
+ * with Purdue University Electrical Engineering\r
+ * With AHPCRC, University of Minnesota\r
+ * ANTLR Version 1.33MR33\r
+ */\r
+\r
+#define ANTLR_VERSION  13333\r
+#include "pcctscfg.h"\r
+#include "pccts_stdio.h"\r
+\r
+#include <ctype.h>\r
+#include "dlg.h"\r
+#define zzSET_SIZE 8\r
+#include "antlr.h"\r
+#include "tokens.h"\r
+#include "dlgdef.h"\r
+#include "err.h"\r
+\r
+ANTLRChar *zztokens[46]={\r
+       /* 00 */        "Invalid",\r
+       /* 01 */        "@",\r
+       /* 02 */        "[\\r\\t\\ ]+",\r
+       /* 03 */        "\\n",\r
+       /* 04 */        "L_EOF",\r
+       /* 05 */        "PER_PER",\r
+       /* 06 */        "NAME_PER_PER",\r
+       /* 07 */        "LEXMEMBER",\r
+       /* 08 */        "LEXACTION",\r
+       /* 09 */        "PARSERCLASS",\r
+       /* 10 */        "LEXPREFIX",\r
+       /* 11 */        "ACTION",\r
+       /* 12 */        "GREAT_GREAT",\r
+       /* 13 */        "L_BRACE",\r
+       /* 14 */        "R_BRACE",\r
+       /* 15 */        "L_PAR",\r
+       /* 16 */        "R_PAR",\r
+       /* 17 */        "L_BRACK",\r
+       /* 18 */        "R_BRACK",\r
+       /* 19 */        "ZERO_MORE",\r
+       /* 20 */        "ONE_MORE",\r
+       /* 21 */        "OR",\r
+       /* 22 */        "RANGE",\r
+       /* 23 */        "NOT",\r
+       /* 24 */        "OCTAL_VALUE",\r
+       /* 25 */        "HEX_VALUE",\r
+       /* 26 */        "DEC_VALUE",\r
+       /* 27 */        "TAB",\r
+       /* 28 */        "NL",\r
+       /* 29 */        "CR",\r
+       /* 30 */        "BS",\r
+       /* 31 */        "CONTINUATION",\r
+       /* 32 */        "LIT",\r
+       /* 33 */        "REGCHAR",\r
+       /* 34 */        "\\>",\r
+       /* 35 */        "\\\\>",\r
+       /* 36 */        "\\",\r
+       /* 37 */        "\\n",\r
+       /* 38 */        "/\\*",\r
+       /* 39 */        "//",\r
+       /* 40 */        "~[]",\r
+       /* 41 */        "\\*/",\r
+       /* 42 */        "[\\n\\r]",\r
+       /* 43 */        "~[]",\r
+       /* 44 */        "[\\n\\r]",\r
+       /* 45 */        "~[]"\r
+};\r
+SetWordType zzerr1[8] = {0x80,0xf,0x0,0x0, 0x0,0x0,0x0,0x0};\r
+SetWordType zzerr2[8] = {0x60,0x0,0x0,0x0, 0x0,0x0,0x0,0x0};\r
+SetWordType zzerr3[8] = {0x70,0xa8,0x9a,0x7f, 0x3,0x0,0x0,0x0};\r
+SetWordType setwd1[46] = {0x0,0x6,0x0,0x0,0x30,0xc8,0xc8,\r
+       0x1,0x1,0x1,0x1,0x35,0x0,0x30,0x0,\r
+       0x30,0x0,0x30,0x0,0x30,0x30,0x0,0x0,\r
+       0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,\r
+       0x0,0x30,0x30,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0};\r
+SetWordType zzerr4[8] = {0x10,0xa8,0x9a,0x7f, 0x3,0x0,0x0,0x0};\r
+SetWordType zzerr5[8] = {0x10,0xe8,0xbb,0x7f, 0x3,0x0,0x0,0x0};\r
+SetWordType zzerr6[8] = {0x10,0xa0,0x9a,0x7f, 0x3,0x0,0x0,0x0};\r
+SetWordType setwd2[46] = {0x0,0x0,0x0,0x0,0xeb,0x2,0x2,\r
+       0x0,0x0,0x0,0x0,0xd6,0x0,0xeb,0xd4,\r
+       0xeb,0xd4,0xeb,0x0,0xcb,0xcb,0xd0,0x0,\r
+       0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,\r
+       0x0,0xeb,0xeb,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0};\r
+SetWordType zzerr7[8] = {0x10,0xa0,0x82,0x7f, 0x3,0x0,0x0,0x0};\r
+SetWordType zzerr8[8] = {0x10,0x0,0x44,0x7f, 0x3,0x0,0x0,0x0};\r
+SetWordType zzerr9[8] = {0x10,0x0,0x0,0x7f, 0x3,0x0,0x0,0x0};\r
+SetWordType setwd3[46] = {0x0,0x0,0x0,0x0,0xf7,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0xc2,0x0,0xc2,0xc2,\r
+       0xc2,0xc2,0xc2,0xb8,0xc2,0xc2,0xc2,0x80,\r
+       0xc2,0xf7,0xf7,0xf7,0xf7,0xf7,0xf7,0xf7,\r
+       0x0,0xf7,0xf7,0x0,0x0,0x0,0x0,0x0,\r
+       0x0,0x0,0x0,0x0,0x0,0x0,0x0};\r
diff --git a/Tools/CodeTools/Source/Pccts/dlg/main.c b/Tools/CodeTools/Source/Pccts/dlg/main.c
new file mode 100644 (file)
index 0000000..35bd827
--- /dev/null
@@ -0,0 +1,281 @@
+/* Main function for dlg version\r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
+ * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
+ * company may do whatever they wish with source code distributed with\r
+ * PCCTS or the code generated by PCCTS, including the incorporation of\r
+ * PCCTS, or its output, into commerical software.\r
+ *\r
+ * We encourage users to develop software with PCCTS.  However, we do ask\r
+ * that credit is given to us for developing PCCTS.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like PCCTS and have developed a nice tool with the\r
+ * output, please mention that you developed it using PCCTS.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * DLG 1.33\r
+ * Will Cohen\r
+ * With mods by Terence Parr; AHPCRC, University of Minnesota\r
+ * 1989-2001\r
+ */\r
+\r
+#include <stdio.h>\r
+#include "stdpccts.h"\r
+\r
+char   program[] = "dlg";\r
+char   version[] = "1.33MR33";                                 /* MRXXX */\r
+int    numfiles = 0;\r
+char   *file_str[2] = {NULL, NULL};\r
+char   *mode_file = "mode.h";\r
+char   *class_name = DEFAULT_CLASSNAME;\r
+char   *OutputDirectory = TopDirectory;\r
+\r
+/* Option variables */\r
+int comp_level = 0;\r
+int interactive = FALSE;\r
+int case_insensitive = FALSE;\r
+int warn_ambig = FALSE;\r
+int gen_cpp = FALSE;\r
+\r
+#ifdef __USE_PROTOS\r
+static int ci_strequ(char *a,char *b)\r
+#else\r
+static int ci_strequ(a,b)\r
+  char  *a;\r
+  char  *b;\r
+#endif\r
+{\r
+  for ( ;*a != 0 && *b != 0; a++, b++) {\r
+    if (toupper(*a) != toupper(*b)) return 0;\r
+  }\r
+  return (*a == *b);\r
+}\r
+\r
+/* Option List Stuff */\r
+#ifdef __USE_PROTOS\r
+void p_comp0(void)             {comp_level = 0;}\r
+void p_comp1(void)             {comp_level = 1;}\r
+void p_comp2(void)             {comp_level = 2;}\r
+void p_stdio(void)             { file_str[numfiles++] = NULL;}\r
+void p_file(char *s)   { file_str[numfiles++] = s;}\r
+void p_cl_name(char *s, char *t)\r
+       {\r
+               if ( gen_cpp ) {\r
+                       class_name = t;\r
+               }\r
+               else {\r
+                       warning("-cl only valid in C++ mode; -cl ignored...",0);\r
+               }\r
+       }\r
+void p_mode_file(char *s, char *t){mode_file=t;}\r
+void p_outdir(char *s,char *t) {OutputDirectory=t;}\r
+void p_ansi(void)              {gen_ansi = TRUE;}\r
+void p_interactive(void)       {interactive = TRUE;}\r
+void p_case_s(void)            { case_insensitive = FALSE; }\r
+void p_case_i(void)            { case_insensitive = TRUE; }\r
+void p_warn_ambig(void)        { warn_ambig = TRUE; }\r
+void p_cpp(void)               { gen_cpp = TRUE; }\r
+#else\r
+void p_comp0()         {comp_level = 0;}\r
+void p_comp1()         {comp_level = 1;}\r
+void p_comp2()         {comp_level = 2;}\r
+void p_stdio()         { file_str[numfiles++] = NULL;}\r
+void p_file(s) char *s;        { file_str[numfiles++] = s;}\r
+void p_cl_name(s,t)\r
+       char *s, *t;\r
+       {\r
+               if ( gen_cpp ) {\r
+                       class_name = t;\r
+               }\r
+               else {\r
+                       warning("-cl only valid in C++ mode; -cl ignored...",0);\r
+               }\r
+       }\r
+void p_mode_file(s,t) char *s,*t;{mode_file=t;}\r
+void p_outdir(s,t) char *s,*t;{OutputDirectory=t;}\r
+void p_ansi()          {gen_ansi = TRUE;}\r
+void p_interactive()   {interactive = TRUE;}\r
+void p_case_s()                { case_insensitive = FALSE; }\r
+void p_case_i()                { case_insensitive = TRUE; }\r
+void p_warn_ambig()    { warn_ambig = TRUE; }\r
+void p_cpp()           { gen_cpp = TRUE; }\r
+#endif\r
+\r
+#ifdef __cplusplus\r
+typedef void (*WildFunc)(...);\r
+#else\r
+typedef void (*WildFunc)();\r
+#endif\r
+\r
+typedef struct {\r
+                       char *option;\r
+                       int  arg;\r
+                       WildFunc process;\r
+                       char *descr;\r
+               } Opt;\r
+\r
+Opt options[] = {\r
+       { "-CC", 0, (WildFunc)p_cpp, "Generate C++ output" },\r
+       { "-C0", 0, (WildFunc)p_comp0, "No compression (default)" },\r
+       { "-C1", 0, (WildFunc)p_comp1, "Compression level 1" },\r
+       { "-C2", 0, (WildFunc)p_comp2, "Compression level 2" },\r
+       { "-ga", 0, (WildFunc)p_ansi, "Generate ansi C"},\r
+       { "-Wambiguity", 0, (WildFunc)p_warn_ambig, "Warn if expressions ambiguous"},\r
+       { "-m", 1, (WildFunc)p_mode_file, "Rename lexical mode output file"},\r
+       { "-i", 0, (WildFunc)p_interactive, "Build interactive scanner (not valid for C++ mode)"},\r
+       { "-ci", 0, (WildFunc)p_case_i, "Make lexical analyzer case insensitive"},\r
+       { "-cl", 1, (WildFunc)p_cl_name, "Rename lexer class (DLGLexer); only used for -CC"},\r
+       { "-cs", 0, (WildFunc)p_case_s, "Make lexical analyzer case sensitive (default)"},\r
+       { "-o",  1, (WildFunc)p_outdir, OutputDirectoryOption},\r
+       { "-", 0, (WildFunc)p_stdio, "Use standard i/o rather than file"},\r
+       { "*", 0, (WildFunc)p_file, ""}, /* anything else is a file */\r
+       { NULL, 0, NULL }       \r
+ };\r
+\r
+#ifdef __USE_PROTOS\r
+void ProcessArgs(int argc, char **argv, Opt *options)\r
+#else\r
+void ProcessArgs(argc, argv, options)\r
+int argc;\r
+char **argv;\r
+Opt *options;\r
+#endif\r
+{\r
+       Opt *p;\r
+       \r
+       while ( argc-- > 0 )\r
+       {\r
+               p = options;\r
+               while ( p->option != NULL )\r
+               {\r
+                       if ( strcmp(p->option, "*") == 0 ||\r
+                                ci_strequ(p->option,*argv) )\r
+                       {\r
+                               if ( p->arg )\r
+                               {\r
+                                       (*p->process)( *argv, *(argv+1) );\r
+                                       argv++;\r
+                                       argc--;\r
+                               }\r
+                               else\r
+                                       (*p->process)( *argv );\r
+                               break;\r
+                       }\r
+                       p++;\r
+               }\r
+               argv++;\r
+       }\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+int main(int argc, char *argv[])\r
+#else\r
+int main(argc, argv)\r
+int argc;\r
+char *argv[];\r
+#endif\r
+{\r
+       init();\r
+       fprintf(stderr, "%s  Version %s   1989-2001\n", &(program[0]),\r
+               &(version[0]));\r
+       if ( argc == 1 )\r
+       {\r
+               Opt *p = options;\r
+               fprintf(stderr, "%s [options] f1 f2 ... fn\n",argv[0]);\r
+               while ( *(p->option) != '*' )\r
+               {\r
+                       fprintf(stderr, "\t%s %s\t%s\n",\r
+                                                       p->option,\r
+                                                       (p->arg)?"___":"   ",\r
+                                                       p->descr);\r
+                       p++;\r
+               }\r
+       }else{\r
+               ProcessArgs(argc-1, &(argv[1]), options);\r
+               if (interactive && gen_cpp) {\r
+                       fprintf(stderr,"\n");\r
+/***  MR21a This statement is wrong ! ***/\r
+#if 0\r
+***                    fprintf(stderr,"Interactive lexer option (\"-i\") has no effect when in C++ mode\n");\r
+***                    fprintf(stderr,"because of extra buffering provided by ANTLRTokenBuffer class.\n");\r
+***                    fprintf(stderr,"\n");\r
+#endif\r
+               }\r
+               input_stream = read_stream(file_str[0]);\r
+               if (input_stream) {\r
+                       /* don't overwrite unless input okay */\r
+                       if ( gen_cpp ) {\r
+                               output_stream = write_stream(ClassName(CPP_FILE_SUFFIX));\r
+                               if ( file_str[1]!=NULL ) {\r
+                                       warning("output file implicit in C++ mode; ignored...",0);\r
+                               }\r
+                               class_stream = write_stream(ClassName(".h"));\r
+                               mode_stream = class_stream;\r
+                       }\r
+                       else {\r
+                               output_stream = write_stream(file_str[1]);\r
+                               mode_stream = write_stream(mode_file);\r
+                       }\r
+               }\r
+               /* make sure that error reporting routines in grammar\r
+                  know what the file really is */\r
+               /* make sure that reading and writing somewhere */\r
+               if (input_stream && output_stream && mode_stream){\r
+                       ANTLR(grammar(), input_stream);\r
+               }\r
+               p_class_def2();                 /* MR1 */\r
+       }\r
+       if ( output_stream!=NULL ) fclose(output_stream);\r
+       if ( !gen_cpp && mode_stream!=NULL ) fclose(mode_stream);\r
+       if ( class_stream!=NULL ) fclose(class_stream);\r
+       exit(PCCTS_EXIT_SUCCESS);\r
+       return 0;               /* get rid of warning message MR1 */\r
+}\r
+\r
+/* initialize all the variables */\r
+void \r
+#ifdef __USE_PROTOS\r
+init(void)\r
+#else\r
+init()\r
+#endif\r
+{\r
+       register int i;\r
+\r
+#ifdef SPECIAL_INITS\r
+       special_inits();                                        /* MR1 */\r
+#endif\r
+       used_chars = empty;\r
+       used_classes = empty;\r
+       /* make the valid character set */\r
+       normal_chars = empty;\r
+       /* NOTE: MIN_CHAR is EOF */\r
+       /* NOTE: EOF is not quite a valid char, it is special. Skip it*/\r
+       for (i = 1; i<CHAR_RANGE; ++i){\r
+               set_orel(i,&normal_chars);\r
+       }\r
+       make_nfa_model_node();\r
+       clear_hash();\r
+       /* NOTE: need to set this flag before the lexer starts getting */\r
+       /* tokens */\r
+       func_action = FALSE;    \r
+}\r
+\r
+/* stuff that needs to be reset when a new automaton is being built */\r
+void \r
+#ifdef __USE_PROTOS\r
+new_automaton_mode(void)                                       /* MR1 */\r
+#else\r
+new_automaton_mode()                                   /* MR1 */\r
+#endif\r
+{\r
+       set_free(used_chars);\r
+       clear_hash();\r
+}\r
diff --git a/Tools/CodeTools/Source/Pccts/dlg/makefile b/Tools/CodeTools/Source/Pccts/dlg/makefile
new file mode 100644 (file)
index 0000000..d5cceb8
--- /dev/null
@@ -0,0 +1,156 @@
+#\r
+# Makefile for DLG 1.33\r
+# Terence Parr\r
+# Purdue University, U of MN, Parr Research Corporation\r
+# 1989-1994\r
+#\r
+# Ported to IBM C-Set/2 and Microsoft 6.0 by\r
+# Ed Harfmann\r
+# Micro Data Base Systems\r
+# Lafayette, Indiana\r
+#\r
+SET=../support/set\r
+PCCTS_H=../h\r
+\r
+##\r
+## Uncomment the appropriate section to build\r
+##\r
+\r
+#\r
+#   OS/2 & DOS 16 bit using MSC 6.0\r
+#\r
+#CC=cl\r
+#ANTLR=..\bin\antlr\r
+#DLG=..\bin\dlg\r
+#CFLAGS= -I. -I$(SET) -I$(PCCTS_H) /AL /Za /W3 -DPC -DUSER_ZZSYN\r
+#OUT_OBJ = -Fo\r
+#LIBS=/NOD:LLIBCE LLIBCEP\r
+#OBJ_EXT = obj\r
+#\r
+#dlg.exe : dlg_p.obj dlg_a.obj main.obj err.obj set.obj support.obj \\r
+#        output.obj relabel.obj automata.obj\r
+#        link @<<\r
+#$** /NOI\r
+#$@ /STACK:16384\r
+#\r
+#$(LIBS: = +^\r
+#)\r
+#$(DEF_FILE) $(LFLAGS) ;\r
+#<<\r
+#        bind $@ c:\os2\doscalls.lib\r
+#        copy *.exe ..\bin\r
+#\r
+\r
+#\r
+#   Borland C++ for DOS\r
+#\r
+#CC=bcc\r
+#ANTLR=..\bin\antlr\r
+#DLG=..\bin\dlg\r
+#CFLAGS= -I. -I$(SET) -I$(PCCTS_H) -ml -ff- -w- -DPC -DUSER_ZZSYN\r
+#OUT_OBJ = -o\r
+#LIBS= emu mathl cl\r
+#OBJ_EXT = obj\r
+#\r
+#dlg.exe : dlg_p.obj dlg_a.obj main.obj err.obj set.obj support.obj \\r
+#        output.obj relabel.obj automata.obj\r
+#       tlink @&&|\r
+#C0L $**\r
+#$@ /Tde /c\r
+#\r
+#$(LIBS)\r
+#$(DEF_FILE) $(LFLAGS) ;\r
+#|\r
+#        copy *.exe ..\bin\r
+#\r
+\r
+#\r
+# C-Set/2 for OS/2\r
+#\r
+#CC=icc\r
+#CFLAGS= -I. -I$(SET) -I$(PCCTS_H) /Sa /W3 /DUSER_ZZSYN\r
+#OUT_OBJ = -Fo\r
+#LIBS=\r
+#ANTLR=..\bin\antlr\r
+#DLG=..\bin\dlg\r
+#OBJ_EXT=obj\r
+#\r
+#dlg.exe : dlg_p.obj dlg_a.obj main.obj err.obj set.obj support.obj \\r
+#        output.obj relabel.obj automata.obj\r
+#        link386 @<<\r
+#$** /NOI\r
+#$@ /STACK:32768\r
+#\r
+#$(LIBS: = +^\r
+#)\r
+#$(DEF_FILE) $(LFLAGS) ;\r
+#<<\r
+#        copy *.exe ..\bin\r
+#\r
+\r
+#\r
+# Borland C++ for OS/2\r
+#\r
+#CC=bcc\r
+#CFLAGS= -I. -I$(SET) -I$(PCCTS_H) -w- -DUSER_ZZSYN\r
+#OUT_OBJ = -o\r
+#LIBS= c2 os2\r
+#\r
+#ANTLR=..\bin\antlr\r
+#DLG=..\bin\dlg\r
+#OBJ_EXT = obj\r
+#dlg.exe : dlg_p.obj dlg_a.obj main.obj err.obj set.obj support.obj \\r
+#        output.obj relabel.obj automata.obj\r
+#        tlink @&&|\r
+#c02 $** -c\r
+#dlg.exe\r
+#\r
+#C2 os2\r
+#\r
+#|\r
+#        copy *.exe ..\bin\r
+#\r
+\r
+#\r
+#   UNIX\r
+#\r
+CC=cc\r
+COPT=-O\r
+ANTLR=${BIN_DIR}/antlr\r
+DLG=${BIN_DIR}/dlg\r
+CFLAGS= $(COPT) -I. -I$(SET) -I$(PCCTS_H) -DUSER_ZZSYN -DZZLEXBUFSIZE=65536\r
+OBJ_EXT=o\r
+OUT_OBJ = -o\r
+OBJ = dlg_p.o dlg_a.o main.o err.o set.o support.o output.o \\r
+        relabel.o automata.o\r
+\r
+dlg : $(OBJ) $(SRC)\r
+               $(CC) $(CFLAGS) -o ${BIN_DIR}/dlg $(OBJ)\r
+\r
+SRC = dlg_p.c dlg_a.c main.c err.c $(SET)/set.c support.c output.c \\r
+        relabel.c automata.c\r
+\r
+#dlg_p.c parser.dlg err.c tokens.h : dlg_p.g\r
+#      $(ANTLR) dlg_p.g\r
+\r
+#dlg_a.c mode.h : parser.dlg\r
+#      $(DLG) -C2 parser.dlg dlg_a.c\r
+\r
+dlg_p.$(OBJ_EXT) : dlg_p.c dlg.h tokens.h mode.h\r
+       $(CC) $(CFLAGS) -c dlg_p.c\r
+\r
+dlg_a.$(OBJ_EXT) : dlg_a.c dlg.h tokens.h mode.h\r
+       $(CC) $(CFLAGS) -c dlg_a.c\r
+\r
+main.$(OBJ_EXT) : main.c dlg.h\r
+       $(CC) $(CFLAGS) -c main.c\r
+\r
+set.$(OBJ_EXT) : $(SET)/set.c\r
+       $(CC) -c $(CFLAGS) $(SET)/set.c\r
+\r
+lint:\r
+       lint *.c\r
+\r
+#clean up all the intermediate files\r
+clean:\r
+       rm -f *.$(OBJ_EXT) core\r
diff --git a/Tools/CodeTools/Source/Pccts/dlg/makefile.cygwin b/Tools/CodeTools/Source/Pccts/dlg/makefile.cygwin
new file mode 100644 (file)
index 0000000..bbba820
--- /dev/null
@@ -0,0 +1,157 @@
+#\r
+# Makefile for DLG 1.33\r
+# Terence Parr\r
+# Purdue University, U of MN, Parr Research Corporation\r
+# 1989-1994\r
+#\r
+# Ported to IBM C-Set/2 and Microsoft 6.0 by\r
+# Ed Harfmann\r
+# Micro Data Base Systems\r
+# Lafayette, Indiana\r
+#\r
+SET=../support/set\r
+PCCTS_H=../h\r
+\r
+##\r
+## Uncomment the appropriate section to build\r
+##\r
+\r
+#\r
+#   OS/2 & DOS 16 bit using MSC 6.0\r
+#\r
+#CC=cl\r
+#ANTLR=..\bin\antlr\r
+#DLG=..\bin\dlg\r
+#CFLAGS= -I. -I$(SET) -I$(PCCTS_H) /AL /Za /W3 -DPC -DUSER_ZZSYN\r
+#OUT_OBJ = -Fo\r
+#LIBS=/NOD:LLIBCE LLIBCEP\r
+#OBJ_EXT = obj\r
+#\r
+#dlg.exe : dlg_p.obj dlg_a.obj main.obj err.obj set.obj support.obj \\r
+#        output.obj relabel.obj automata.obj\r
+#        link @<<\r
+#$** /NOI\r
+#$@ /STACK:16384\r
+#\r
+#$(LIBS: = +^\r
+#)\r
+#$(DEF_FILE) $(LFLAGS) ;\r
+#<<\r
+#        bind $@ c:\os2\doscalls.lib\r
+#        copy *.exe ..\bin\r
+#\r
+\r
+#\r
+#   Borland C++ for DOS\r
+#\r
+#CC=bcc\r
+#ANTLR=..\bin\antlr\r
+#DLG=..\bin\dlg\r
+#CFLAGS= -I. -I$(SET) -I$(PCCTS_H) -ml -ff- -w- -DPC -DUSER_ZZSYN\r
+#OUT_OBJ = -o\r
+#LIBS= emu mathl cl\r
+#OBJ_EXT = obj\r
+#\r
+#dlg.exe : dlg_p.obj dlg_a.obj main.obj err.obj set.obj support.obj \\r
+#        output.obj relabel.obj automata.obj\r
+#       tlink @&&|\r
+#C0L $**\r
+#$@ /Tde /c\r
+#\r
+#$(LIBS)\r
+#$(DEF_FILE) $(LFLAGS) ;\r
+#|\r
+#        copy *.exe ..\bin\r
+#\r
+\r
+#\r
+# C-Set/2 for OS/2\r
+#\r
+#CC=icc\r
+#CFLAGS= -I. -I$(SET) -I$(PCCTS_H) /Sa /W3 /DUSER_ZZSYN\r
+#OUT_OBJ = -Fo\r
+#LIBS=\r
+#ANTLR=..\bin\antlr\r
+#DLG=..\bin\dlg\r
+#OBJ_EXT=obj\r
+#\r
+#dlg.exe : dlg_p.obj dlg_a.obj main.obj err.obj set.obj support.obj \\r
+#        output.obj relabel.obj automata.obj\r
+#        link386 @<<\r
+#$** /NOI\r
+#$@ /STACK:32768\r
+#\r
+#$(LIBS: = +^\r
+#)\r
+#$(DEF_FILE) $(LFLAGS) ;\r
+#<<\r
+#        copy *.exe ..\bin\r
+#\r
+\r
+#\r
+# Borland C++ for OS/2\r
+#\r
+#CC=bcc\r
+#CFLAGS= -I. -I$(SET) -I$(PCCTS_H) -w- -DUSER_ZZSYN\r
+#OUT_OBJ = -o\r
+#LIBS= c2 os2\r
+#\r
+#ANTLR=..\bin\antlr\r
+#DLG=..\bin\dlg\r
+#OBJ_EXT = obj\r
+#dlg.exe : dlg_p.obj dlg_a.obj main.obj err.obj set.obj support.obj \\r
+#        output.obj relabel.obj automata.obj\r
+#        tlink @&&|\r
+#c02 $** -c\r
+#dlg.exe\r
+#\r
+#C2 os2\r
+#\r
+#|\r
+#        copy *.exe ..\bin\r
+#\r
+\r
+#\r
+#   UNIX\r
+#\r
+BIN_DIR=../../../../bin\r
+CC=cc\r
+COPT=-O\r
+ANTLR=$(BIN_DIR)/antlr.exe\r
+DLG=${BIN_DIR}/dlg.exe\r
+CFLAGS= $(COPT) -I. -I$(SET) -I$(PCCTS_H) -DUSER_ZZSYN -DZZLEXBUFSIZE=65536\r
+OBJ_EXT=o\r
+OUT_OBJ = -o\r
+OBJ = dlg_p.o dlg_a.o main.o err.o set.o support.o output.o \\r
+        relabel.o automata.o\r
+\r
+dlg : $(OBJ) $(SRC)\r
+               $(CC) $(CFLAGS) -o $(BIN_DIR)/dlg.exe $(OBJ)\r
+\r
+SRC = dlg_p.c dlg_a.c main.c err.c $(SET)/set.c support.c output.c \\r
+        relabel.c automata.c\r
+\r
+#dlg_p.c parser.dlg err.c tokens.h : dlg_p.g\r
+#      $(ANTLR) dlg_p.g\r
+\r
+#dlg_a.c mode.h : parser.dlg\r
+#      $(DLG) -C2 parser.dlg dlg_a.c\r
+\r
+dlg_p.$(OBJ_EXT) : dlg_p.c dlg.h tokens.h mode.h\r
+       $(CC) $(CFLAGS) -c dlg_p.c\r
+\r
+dlg_a.$(OBJ_EXT) : dlg_a.c dlg.h tokens.h mode.h\r
+       $(CC) $(CFLAGS) -c dlg_a.c\r
+\r
+main.$(OBJ_EXT) : main.c dlg.h\r
+       $(CC) $(CFLAGS) -c main.c\r
+\r
+set.$(OBJ_EXT) : $(SET)/set.c\r
+       $(CC) -c $(CFLAGS) $(SET)/set.c\r
+\r
+lint:\r
+       lint *.c\r
+\r
+#clean up all the intermediate files\r
+clean:\r
+       rm -f *.$(OBJ_EXT) core\r
diff --git a/Tools/CodeTools/Source/Pccts/dlg/makefile1 b/Tools/CodeTools/Source/Pccts/dlg/makefile1
new file mode 100644 (file)
index 0000000..4d00f79
--- /dev/null
@@ -0,0 +1,63 @@
+#\r
+# Makefile for DLG 1.33\r
+# Terence Parr\r
+# Purdue University, U of MN, Parr Research Corporation\r
+# 1989-1994\r
+#\r
+# Ported to IBM C-Set/2 and Microsoft 6.0 by\r
+# Ed Harfmann\r
+# Micro Data Base Systems\r
+# Lafayette, Indiana\r
+#\r
+SET=../support/set\r
+PCCTS_H=../h\r
+\r
+##\r
+## Uncomment the appropriate section to build\r
+##\r
+\r
+\r
+#\r
+#   UNIX\r
+#\r
+CC=cc\r
+ANTLR=../bin/antlr\r
+DLG=../bin/dlg\r
+ANSI=-ansi\r
+CFLAGS= -O -I. -I$(SET) -I$(PCCTS_H) -DUSER_ZZSYN $(COTHER) $(ANSI) -DZZLEXBUFSIZE=32000\r
+OBJ_EXT=o\r
+OUT_OBJ = -o\r
+OBJ = dlg_p.o dlg_a.o main.o err.o set.o support.o output.o \\r
+        relabel.o automata.o\r
+\r
+dlg : $(OBJ) $(SRC)\r
+               $(CC) $(CFLAGS) -o dlg $(OBJ)\r
+               mv dlg ../bin\r
+\r
+SRC = dlg_p.c dlg_a.c main.c err.c $(SET)/set.c support.c output.c \\r
+        relabel.c automata.c\r
+\r
+dlg_p.c parser.dlg err.c tokens.h : dlg_p.g\r
+       $(ANTLR) dlg_p.g\r
+\r
+dlg_a.c mode.h : parser.dlg\r
+       $(DLG) -C2 parser.dlg dlg_a.c\r
+\r
+dlg_p.$(OBJ_EXT) : dlg_p.c dlg.h tokens.h mode.h\r
+       $(CC) $(CFLAGS) -c dlg_p.c\r
+\r
+dlg_a.$(OBJ_EXT) : dlg_a.c dlg.h tokens.h mode.h\r
+       $(CC) $(CFLAGS) -c dlg_a.c\r
+\r
+main.$(OBJ_EXT) : main.c dlg.h\r
+       $(CC) $(CFLAGS) -c main.c\r
+\r
+set.$(OBJ_EXT) : $(SET)/set.c\r
+       $(CC) -c $(CFLAGS) $(SET)/set.c\r
+\r
+lint:\r
+       lint *.c\r
+\r
+#clean up all the intermediate files\r
+clean:\r
+       rm -f *.$(OBJ_EXT) core\r
diff --git a/Tools/CodeTools/Source/Pccts/dlg/mode.h b/Tools/CodeTools/Source/Pccts/dlg/mode.h
new file mode 100644 (file)
index 0000000..3f3279e
--- /dev/null
@@ -0,0 +1,4 @@
+#define START 0\r
+#define ACT 1\r
+#define ACTION_COMMENTS 2\r
+#define ACTION_CPP_COMMENTS 3\r
diff --git a/Tools/CodeTools/Source/Pccts/dlg/output.c b/Tools/CodeTools/Source/Pccts/dlg/output.c
new file mode 100644 (file)
index 0000000..2e56a6d
--- /dev/null
@@ -0,0 +1,850 @@
+/* output.c, output generator for dlg\r
+ *\r
+ * Output Notes:\r
+ *\r
+ * DfaStates == number of dfa nodes in automaton (just a #define)\r
+ * DfaState == type large enough to index every node in automaton\r
+ *         <256 unsigned char, <65536 unsigned short, etc.\r
+ *\r
+ * Thus, the elements in each of the automaton states (st%d) are type DfaState\r
+ * and are size appropriately, since they must be able to index the next\r
+ * automaton state.\r
+ *\r
+ * dfa[] == a linear array that points to all the automaton states (st%d)\r
+ *         (dfa_base[] should be the same, but isn't right now)\r
+ *\r
+ * accepts[] == Taking a closer look at this one, it probably shouldn't be type\r
+ *         DfaState because there is no real requirement that the number of\r
+ *         accepts states is less than the number of dfa state.  However, if\r
+ *         the number of accept states was more than the number of DFA states\r
+ *         then the lexical specification would be really ambiguous.\r
+ *\r
+ *         Another note. Is that is should be possible to fold accepts[] and\r
+ *         actions[] together.  If this is done, I would suggest get rid of\r
+ *         accept[] and make actions[] have an entry for each state (st%d) in\r
+ *         the automaton.\r
+ *\r
+ * dfa_base[] == starting location for each lexical mode.  This should be\r
+ *         Dfastate type (but isn't right now), since it points to the states\r
+ *         in the automaton.\r
+ *\r
+ * dfa_class_no[] == indicates the number of columns each lexical mode has.\r
+ *\r
+ * b_class_no[] == pointer to the start of the translation array used to\r
+ *         convert from input character to character class.  This could cause\r
+ *         problems if there are more than 256 classes\r
+ *\r
+ * shift%d[] == the actual translation arrays that convert the input character\r
+ *         into the character class.  These will have to change if there are\r
+ *         more than 256 character classes.\r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
+ * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
+ * company may do whatever they wish with source code distributed with\r
+ * PCCTS or the code generated by PCCTS, including the incorporation of\r
+ * PCCTS, or its output, into commerical software.\r
+ *\r
+ * We encourage users to develop software with PCCTS.  However, we do ask\r
+ * that credit is given to us for developing PCCTS.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like PCCTS and have developed a nice tool with the\r
+ * output, please mention that you developed it using PCCTS.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * DLG 1.33\r
+ * Will Cohen\r
+ * With mods by Terence Parr; AHPCRC, University of Minnesota\r
+ * 1989-2001\r
+ */\r
+\r
+#include <stdio.h>\r
+#include <string.h>\r
+#include "dlg.h"\r
+#ifdef MEMCHK\r
+#include "trax.h"\r
+#else\r
+#ifdef __STDC__\r
+#include <stdlib.h>\r
+#else\r
+#include <malloc.h>\r
+#endif /* __STDC__ */\r
+#endif\r
+\r
+static char *mode_name[MAX_MODES];\r
+static int mode_number[MAX_MODES];\r
+static int cur_mode=0;\r
+\r
+int operation_no = 0; /* used to mark nodes so that infinite loops avoided */\r
+int dfa_basep[MAX_MODES];      /* start of each group of states */\r
+int dfa_class_nop[MAX_MODES];  /* number of elements in each group of states*/\r
+\r
+int gen_ansi = FALSE;          /* allows ansi code to be generated */\r
+\r
+FILE *input_stream;    /* where to read description from */\r
+FILE *output_stream;   /* where to put the output        */\r
+FILE *mode_stream;     /* where to put the mode.h stuff */\r
+FILE *class_stream;    /* where to put the scan.h stuff (if gen_cpp) */\r
+\r
+/* NOTE: This section is MACHINE DEPENDENT */\r
+#define DIF_SIZE 4\r
+#if defined(PC) && !defined(PC32)\r
+unsigned long typesize[DIF_SIZE]  = { 0x7f, 0x7fff, 0x7ffful, 0x7ffffffful }; /* MR20 */\r
+char t0[] = "unsigned char";\r
+char t1[] = "unsigned short";\r
+char t2[] = "unsigned int";\r
+char t3[] = "unsigned long";\r
+char *typevar[DIF_SIZE] = { t0, t1, t2, t3};\r
+#else\r
+unsigned long typesize[DIF_SIZE]  = { 0x7f, 0x7fff, 0x7ffffffful, 0x7ffffffful }; /* MR20 */\r
+char t0[] = "unsigned char";\r
+char t1[] = "unsigned short";\r
+char t2[] = "unsigned int";\r
+char t3[] = "unsigned long";\r
+char *typevar[DIF_SIZE] = { t0, t1, t2, t3};\r
+#endif\r
+\r
+/* Added by TJP August 1994 */\r
+/* Take in MyLexer and return MyLexer_h */\r
+\r
+static char *\r
+#ifdef __USE_PROTOS\r
+gate_symbol(char *name)\r
+#else\r
+gate_symbol(name)\r
+char *name;\r
+#endif\r
+{\r
+       static char buf[100];\r
+       sprintf(buf, "%s_h", name);\r
+       return buf;\r
+}\r
+\r
+/* Added by TJP August 1994 */\r
+static char *\r
+#ifdef __USE_PROTOS\r
+mystrdup(char *s)\r
+#else\r
+mystrdup(s)\r
+char *s;\r
+#endif\r
+{\r
+       char *p = (char *)malloc(strlen(s)+1);\r
+       strcpy(p, s);\r
+       return p;\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+void p_class_hdr(void)\r
+#else\r
+void p_class_hdr()                                             \r
+#endif\r
+{\r
+       if ( class_stream == NULL ) return;\r
+       fprintf(class_stream, "#ifndef %s\n", gate_symbol(ClassName("")));\r
+       fprintf(class_stream, "#define %s\n", gate_symbol(ClassName("")));\r
+       fprintf(class_stream, "/*\n");\r
+       fprintf(class_stream, " * D L G L e x e r  C l a s s  D e f i n i t i o n\n");\r
+       fprintf(class_stream, " *\n");\r
+       fprintf(class_stream, " * Generated from:");\r
+       fprintf(class_stream, " %s", file_str[0]);\r
+       fprintf(class_stream, "\n");\r
+       fprintf(class_stream, " *\n");\r
+       fprintf(class_stream, " * 1989-2001 by  Will Cohen, Terence Parr, and Hank Dietz\n");\r
+       fprintf(class_stream, " * Purdue University Electrical Engineering\n");\r
+       fprintf(class_stream, " * DLG Version %s\n", version);\r
+       fprintf(class_stream, " */\n\n");\r
+       fprintf(class_stream, "\n");\r
+       fprintf(class_stream, "#include \"%s\"\n", DLEXERBASE_H);\r
+}\r
+\r
+/* MR1                                                                 */\r
+/* MR1 16-Apr-97  Split printing of class header up into several parts  */\r
+/* MR1             so that #lexprefix <<...>>and #lexmember <<...>>    */\r
+/* MR1             can be inserted in the appropriate spots            */\r
+/* MR1                                                                 */\r
+\r
+#ifdef __USE_PROTOS\r
+void p_class_def1(void)\r
+#else\r
+void p_class_def1()\r
+#endif\r
+{\r
+       if ( class_stream == NULL ) return;\r
+       fprintf(class_stream, "\nclass %s : public DLGLexerBase {\n", ClassName(""));\r
+       fprintf(class_stream, "public:\n");\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+void p_class_def2(void)\r
+#else\r
+void p_class_def2()\r
+#endif\r
+{\r
+       int i, m;\r
+       if ( class_stream == NULL ) return;\r
+       fprintf(class_stream, "public:\n");\r
+       fprintf(class_stream, "\tstatic const int MAX_MODE;\n");\r
+       fprintf(class_stream, "\tstatic const int DfaStates;\n");\r
+       for (i=0; i<cur_mode; i++) {\r
+               fprintf(class_stream, "\tstatic const int %s;\n", mode_name[i]);\r
+       }\r
+\r
+       fprintf(class_stream, "\ttypedef %s DfaState;\n\n", minsize(dfa_allocated));\r
+       fprintf(class_stream, "\t%s(DLGInputStream *in,\n",ClassName(""));\r
+       fprintf(class_stream, "\t\tunsigned bufsize=2000)\n");\r
+       fprintf(class_stream, "\t\t: DLGLexerBase(in, bufsize, %d)\n", interactive);\r
+       fprintf(class_stream, "\t{\n");\r
+       fprintf(class_stream, "\t;\n");\r
+       fprintf(class_stream, "\t}\n");\r
+       fprintf(class_stream, "\tvoid     mode(int);\n");\r
+       fprintf(class_stream, "\tANTLRTokenType nextTokenType(void);\n");\r
+       fprintf(class_stream, "\tvoid     advance(void);\n");\r
+       fprintf(class_stream, "protected:\n");\r
+       for (i=1; i<=action_no; ++i) {\r
+               fprintf(class_stream, "\tANTLRTokenType act%d();\n", i);\r
+       }\r
+\r
+       for(m=0; m<(mode_counter-1); ++m){\r
+               for(i=dfa_basep[m]; i<dfa_basep[m+1]; ++i)\r
+                       fprintf(class_stream, "\tstatic DfaState st%d[%d];\n", i-1, dfa_class_nop[m]+1);\r
+       }\r
+       for(i=dfa_basep[m]; i<=dfa_allocated; ++i)\r
+               fprintf(class_stream, "\tstatic DfaState st%d[%d];\n", i-1, dfa_class_nop[m]+1);\r
+\r
+       fprintf(class_stream, "\tstatic DfaState *dfa[%d];\n", dfa_allocated);\r
+       fprintf(class_stream, "\tstatic DfaState dfa_base[];\n");\r
+/*     fprintf(class_stream, "\tstatic int dfa_base_no[];\n"); */\r
+       fprintf(class_stream, "\tstatic unsigned char *b_class_no[];\n");\r
+       fprintf(class_stream, "\tstatic DfaState accepts[%d];\n",dfa_allocated+1);\r
+       fprintf(class_stream, "\tstatic DLGChar alternatives[%d];\n",dfa_allocated+1);\r
+       /* WARNING: should be ANTLRTokenType for action table, but g++ 2.5.6 is hosed */\r
+       fprintf(class_stream, "\tstatic ANTLRTokenType (%s::*actions[%d])();\n", ClassName(""), action_no+1);\r
+       for(m=0; m<mode_counter; ++m) {\r
+               fprintf(class_stream, "\tstatic unsigned char shift%d[%d];\n",\r
+                       m, CHAR_RANGE);\r
+       }\r
+       if (comp_level)\r
+               fprintf(class_stream, "\tint ZZSHIFT(int c) { return b_class_no[automaton][1+c]; }\n");\r
+       else\r
+               fprintf(class_stream, "\tint ZZSHIFT(int c) { return 1+c; }\n");\r
+\r
+/* MR1                                                                   */\r
+/* MR1 11-APr-97   Kludge to allow inclusion of user-defined code in     */\r
+/* MR1                  DLGLexer class header                            */\r
+/* MR1            Deprecated in favor of 133MR1 addition #lexmember <<>> */\r
+/* MR1                                                                   */\r
+/* MR1 */      fprintf(class_stream,"//\n");\r
+/* MR1 */      fprintf(class_stream,\r
+/* MR1 */         "// 133MR1 Deprecated feature to allow inclusion of ");\r
+/* MR1 */      fprintf(class_stream,\r
+/* MR1 */         "user-defined code in DLG class header\n");\r
+/* MR1 */      fprintf(class_stream,"//\n");\r
+/* MR1 */\r
+/* MR1 */      fprintf(class_stream,"#ifdef DLGLexerIncludeFile\n");\r
+/* MR1 */      fprintf(class_stream,"#include DLGLexerIncludeFile\n");\r
+/* MR1 */      fprintf(class_stream,"#endif\n");\r
+\r
+       fprintf(class_stream, "};\n");\r
+\r
+       fprintf(class_stream, "typedef ANTLRTokenType (%s::*Ptr%sMemberFunc)();\n",\r
+                       ClassName(""), ClassName(""));\r
+\r
+       fprintf(class_stream, "#endif\n");\r
+}\r
+\r
+/* generate required header on output */\r
+\r
+#ifdef __USE_PROTOS\r
+void p_head(void)\r
+#else\r
+void p_head()\r
+#endif\r
+{\r
+       fprintf(OUT, "/*\n");\r
+       fprintf(OUT, " * D L G tables\n");\r
+       fprintf(OUT, " *\n");\r
+       fprintf(OUT, " * Generated from:");\r
+       fprintf(OUT, " %s", file_str[0]);\r
+       fprintf(OUT, "\n");\r
+       fprintf(OUT, " *\n");\r
+       fprintf(OUT, " * 1989-2001 by  Will Cohen, Terence Parr, and Hank Dietz\n");\r
+       fprintf(OUT, " * Purdue University Electrical Engineering\n");\r
+       fprintf(OUT, " * DLG Version %s\n", version);\r
+       fprintf(OUT, " */\n\n");\r
+       if ( gen_cpp)  fprintf(OUT, "#include \"pcctscfg.h\"\n");\r
+       if ( gen_cpp ) fprintf(OUT, "#include \"pccts_stdio.h\"\n");\r
+       if ( !gen_cpp ) fprintf(OUT, "#include \"%s\"\n\n", mode_file);\r
+       fprintf(OUT,"\n");\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+void p_includes(void)\r
+#else\r
+void p_includes()\r
+#endif\r
+{\r
+       fprintf(OUT, "#include \"%s\"\n", APARSER_H);\r
+       fprintf(OUT, "#include \"%s\"\n", DLEXERBASE_H);\r
+       fprintf(OUT, "#include \"%s\"\n", ClassName(".h"));\r
+}\r
+\r
+/* generate code to tie up any loose ends */\r
+\r
+#ifdef __USE_PROTOS\r
+void p_tail(void)                              /* MR1 */\r
+#else\r
+void p_tail()                                          /* MR1 */\r
+#endif\r
+{\r
+       if ( gen_cpp ) {\r
+               if ( strcmp(ClassName(""), DEFAULT_CLASSNAME)!=0 )\r
+                       fprintf(OUT, "#define DLGLexer %s\n", ClassName(""));\r
+               fprintf(OUT, "#include \"%s\"\n", DLEXER_H);  /* MR23 Rename DLexer.cpp to DLexer.h */\r
+               return;\r
+       }\r
+       fprintf(OUT, "\n");\r
+       fprintf(OUT, "\n");\r
+       if (comp_level)\r
+               fprintf(OUT, "#define ZZSHIFT(c) (b_class_no[zzauto][1+c])\n");\r
+       else\r
+               fprintf(OUT, "#define ZZSHIFT(c) (1+c)\n");\r
+       if ( !gen_cpp ) fprintf(OUT, "#define MAX_MODE %d\n",mode_counter);\r
+       fprintf(OUT, "#include \"dlgauto.h\"\n");\r
+}\r
+\r
+\r
+/* output the table of DFA for general use */\r
+\r
+#ifdef __USE_PROTOS\r
+void p_tables()\r
+#else\r
+void p_tables()\r
+#endif\r
+{\r
+       if ( !gen_cpp ) {\r
+               fprintf(OUT, "#define DfaStates\t%d\n", dfa_allocated);\r
+               fprintf(OUT, "typedef %s DfaState;\n\n", minsize(dfa_allocated));\r
+       }\r
+\r
+       if ( gen_cpp ) {\r
+               int i;\r
+               fprintf(OUT, "\n");\r
+               fprintf(OUT, "const int %s::MAX_MODE=%d;\n",\r
+                               ClassName(""),\r
+                               mode_counter);\r
+               fprintf(OUT, "const int %s::DfaStates=%d;\n",\r
+                               ClassName(""),\r
+                               dfa_allocated);\r
+               for (i=0; i<cur_mode; i++) {\r
+                       fprintf(OUT, "const int %s::%s=%d;\n",\r
+                                       ClassName(""), mode_name[i], mode_number[i]);\r
+               }\r
+               fprintf(OUT, "\n");\r
+       }\r
+\r
+       p_node_table();\r
+       p_dfa_table();\r
+       p_accept_table();\r
+       p_action_table();\r
+       p_base_table();\r
+       p_class_table();\r
+       if (comp_level)\r
+               p_bshift_table();\r
+       if (interactive || gen_cpp )\r
+               p_alternative_table();\r
+}\r
+\r
+\r
+/* figures out the smallest variable type that will hold the transitions\r
+ */\r
+\r
+#ifdef __USE_PROTOS\r
+char *minsize(int elements)\r
+#else\r
+char *minsize(elements)\r
+int elements;\r
+#endif\r
+{\r
+       int i = 0;\r
+\r
+       while ((unsigned long) elements > typesize[i]) /* MR20 */\r
+               ++i;\r
+       return typevar[i];\r
+}\r
+\r
+\r
+#ifdef __USE_PROTOS\r
+void p_node_table(void)\r
+#else\r
+void p_node_table()\r
+#endif\r
+{\r
+       register int    i;\r
+       register int    m = 0;\r
+\r
+       for(m=0; m<(mode_counter-1); ++m){\r
+               for(i=dfa_basep[m]; i<dfa_basep[m+1]; ++i)\r
+                       p_single_node(i,dfa_class_nop[m]);\r
+       }\r
+       for(i=dfa_basep[m]; i<=dfa_allocated; ++i)\r
+               p_single_node(i,dfa_class_nop[m]);\r
+}\r
+\r
+\r
+#ifdef __USE_PROTOS\r
+void p_single_node(int i,int classes)\r
+#else\r
+void p_single_node(i,classes)\r
+int i,classes;\r
+#endif\r
+{\r
+       register int    j;\r
+       register int    trans, items_on_line;\r
+\r
+#if 1\r
+       /* extra state (classes+1) for invalid characters */\r
+       fprintf(OUT, "%sDfaState %sst%d[%d] = {\n  ",\r
+               gen_cpp?ClassName("::"):"static ",\r
+               gen_cpp?ClassName("::"):"",(i-1), (classes+1));\r
+#else\r
+       fprintf(OUT, "static DfaState st%d[%d] = {\n  ", (i-1), classes);\r
+#endif\r
+       items_on_line = MAX_ON_LINE;\r
+       for(j=0; j<classes; ++j){\r
+               DAWDLE;\r
+               trans = DFA(i)->trans[j];\r
+               if (trans == NIL_INDEX)\r
+                       trans = dfa_allocated+1;\r
+               /* all of DFA moved down one in array */\r
+               fprintf(OUT, "%d", trans-1);\r
+               fprintf(OUT, ", ");\r
+               if (!(--items_on_line)){\r
+                       fprintf(OUT, "\n  ");\r
+                       items_on_line = MAX_ON_LINE;\r
+               }\r
+       }\r
+#if 1\r
+       /* put in jump to error state */\r
+       fprintf(OUT, "%d\n};\n\n", dfa_allocated);\r
+#else\r
+       fprintf(OUT, "\n};\n\n");\r
+#endif\r
+}\r
+\r
+\r
+#ifdef __USE_PROTOS\r
+void p_dfa_table(void)\r
+#else\r
+void p_dfa_table()\r
+#endif\r
+{\r
+       register int    i;\r
+\r
+       fprintf(OUT, "\n%sDfaState *%sdfa[%d] = {\n",\r
+               gen_cpp?ClassName("::"):"",gen_cpp?ClassName("::"):"", dfa_allocated);\r
+       for (i=0; i<(dfa_allocated-1); ++i){\r
+               fprintf(OUT, "\tst%d,\n", i);\r
+       }\r
+       fprintf(OUT, "\tst%d\n", i);\r
+       fprintf(OUT, "};\n\n");\r
+}\r
+\r
+\r
+#ifdef __USE_PROTOS\r
+void p_accept_table(void)\r
+#else\r
+void p_accept_table()\r
+#endif\r
+{\r
+       register int    i = 1;\r
+       register int    items_on_line = 0;\r
+       int             true_interactive = TRUE;\r
+\r
+       /* make sure element for one past (zzerraction) -WEC 12/16/92 */\r
+       fprintf(OUT,"\n%sDfaState %saccepts[%d] = {\n  ",\r
+                       gen_cpp?ClassName("::"):"",\r
+                       gen_cpp?ClassName("::"):"",\r
+                       dfa_allocated+1);\r
+       /* don't do anything if no dfa nodes */\r
+       if (i>dfa_allocated) goto skip_accepts;\r
+       for (;;) {\r
+               int accept=0;   /* MR14a - Manuel Kessler (mlkessle@cip.physik.uni-wuerzburg.de) */\r
+               set accept_set;\r
+               set nfa_states;\r
+               unsigned int *t, *nfa_i;\r
+               unsigned int *q, *regular_expr;\r
+\r
+               accept_set = empty;\r
+               nfa_states = DFA(i)->nfa_states;\r
+               t = nfa_i = set_pdq(nfa_states);\r
+               /* NOTE: picks lowest accept because accepts monotonic  */\r
+               /*      with respect to nfa node numbers and set_pdq    */\r
+               /*      returns in that order                           */\r
+               while((*nfa_i != nil) && (!(accept = NFA(*nfa_i)->accept))){\r
+                       nfa_i++;\r
+               }\r
+\r
+               /* figure out if more than one accept state there */\r
+               if (warn_ambig ){\r
+                       set_orel(accept, &accept_set);\r
+                       while(*nfa_i != nil){\r
+                               set_orel(NFA(*nfa_i)->accept, &accept_set);\r
+                               nfa_i++;\r
+                       }\r
+                       /* remove error action from consideration */\r
+                       set_rm(0, accept_set);\r
+\r
+                       if( set_deg(accept_set)>1){\r
+                               fprintf(stderr, "dlg warning: ambiguous regular expression ");\r
+                               q = regular_expr = set_pdq(accept_set);\r
+                               while(*regular_expr != nil){\r
+                                       fprintf(stderr," %d ", *regular_expr);\r
+                                       ++regular_expr;\r
+                               }\r
+                               fprintf(stderr, "\n");\r
+                               free(q);\r
+                       }\r
+               }\r
+\r
+               if ((DFA(i)->alternatives) && (accept != 0)){\r
+                       true_interactive = FALSE;\r
+               }\r
+               fprintf(OUT, "%d, ", accept);\r
+\r
+               /* free up memory before we "break" below -ATG 4/6/95 */\r
+               free(t);\r
+               set_free(accept_set);\r
+\r
+               if ((++i)>dfa_allocated)\r
+                       break;\r
+               if ((++items_on_line)>=MAX_ON_LINE){\r
+                       fprintf(OUT,"\n  ");\r
+                       items_on_line = 0;\r
+               }\r
+/*\r
+               free(t);\r
+               set_free(accept_set);\r
+*/\r
+       }\r
+       /* make sure element for one past (zzerraction) -WEC 12/16/92 */\r
+skip_accepts:\r
+       fprintf(OUT, "0\n};\n\n");\r
+}\r
+\r
+\r
+#ifdef __USE_PROTOS\r
+void p_action_table(void)\r
+#else\r
+void p_action_table()\r
+#endif\r
+{\r
+       register int    i;\r
+       char* theClassName = ClassName("");\r
+\r
+       if ( gen_cpp )\r
+               fprintf(OUT, "Ptr%sMemberFunc %s::actions[%d] = {\n", theClassName,\r
+                                       theClassName, action_no+1);\r
+       else\r
+               fprintf(OUT, "void (*actions[%d])() = {\n", action_no+1);\r
+       if ( gen_cpp )\r
+/*             fprintf(OUT, "\t(Ptr%sMemberFunc)&%s::erraction,\n", theClassName, theClassName);*/\r
+               fprintf(OUT, "\t&%s::erraction,\n", theClassName);\r
+       else\r
+               fprintf(OUT, "\tzzerraction,\n");\r
+       for (i=1; i<action_no; ++i) {\r
+               if ( gen_cpp )\r
+/*                     fprintf(OUT,"\t(Ptr%sMemberFunc)&%s::act%d,\n", theClassName, theClassName, i);*/\r
+                       fprintf(OUT,"\t&%s::act%d,\n", theClassName, i);\r
+               else\r
+                       fprintf(OUT,"\tact%d,\n", i);\r
+               DAWDLE;\r
+       }\r
+       if ( gen_cpp )\r
+/*             fprintf(OUT,"\t(Ptr%sMemberFunc)&%s::act%d\n", theClassName, theClassName, i);*/\r
+               fprintf(OUT,"\t&%s::act%d\n", theClassName, i);\r
+       else\r
+               fprintf(OUT,"\tact%d\n", i);\r
+       fprintf(OUT, "};\n\n");\r
+}\r
+\r
+\r
+#ifdef __USE_PROTOS\r
+void p_shift_table(int m)                                  /* MR1 */\r
+#else\r
+void p_shift_table(m)                                          /* MR1 */\r
+int m;\r
+#endif\r
+{\r
+       register int    i = 0, j;\r
+       register int    items_on_line = 0;\r
+\r
+       fprintf(OUT, "%s unsigned char %sshift%d[%d] = {\n  ",\r
+               gen_cpp?"":"static",\r
+               gen_cpp?ClassName("::"):"", m, CHAR_RANGE);\r
+       for (;;) {\r
+               /* find which partition character i is in */\r
+               for (j=0; j<dfa_class_nop[mode_counter]; ++j){\r
+                       if (set_el(i,class_sets[j]))\r
+                               break;\r
+                       }\r
+               fprintf(OUT,"%d",j);\r
+               if ((++i)>=CHAR_RANGE)\r
+                       break;\r
+               fprintf(OUT,", ");\r
+               if ((++items_on_line)>=MAX_ON_LINE){\r
+                       fprintf(OUT,"\n  ");\r
+                       items_on_line = 0;\r
+                       }\r
+               }\r
+       fprintf(OUT, "\n};\n\n");\r
+}\r
+\r
+\r
+#ifdef __USE_PROTOS\r
+void p_base_table(void)\r
+#else\r
+void p_base_table()\r
+#endif\r
+{\r
+       register int m;\r
+\r
+       fprintf(OUT, "%sDfaState %sdfa_base[] = {\n",\r
+                       gen_cpp?ClassName("::"):"static ",\r
+                       gen_cpp?ClassName("::"):"");\r
+       for(m=0; m<(mode_counter-1); ++m)\r
+               fprintf(OUT, "\t%d,\n", dfa_basep[m]-1);\r
+       fprintf(OUT, "\t%d\n};\n\n", dfa_basep[m]-1);\r
+}\r
+\r
+\r
+#ifdef __USE_PROTOS\r
+void p_class_table(void)                               /* MR1 */\r
+#else\r
+void p_class_table()                                           /* MR1 */\r
+#endif\r
+{\r
+#if 0\r
+       register int m;\r
+\r
+       fprintf(OUT,"%s int %sdfa_class_no[] = {\n",\r
+                       gen_cpp?"":"static",\r
+                       gen_cpp?ClassName("::"):"");\r
+       for(m=0; m<(mode_counter-1); ++m)\r
+               fprintf(OUT,"\t%d,\n", dfa_class_nop[m]);\r
+       fprintf(OUT,"\t%d\n};\n\n", dfa_class_nop[m]);\r
+#endif\r
+}\r
+\r
+\r
+#ifdef __USE_PROTOS\r
+void p_bshift_table(void)                                      /* MR1 */\r
+#else\r
+void p_bshift_table()                                          /* MR1 */\r
+#endif\r
+{\r
+       register int m;\r
+\r
+       fprintf(OUT,"%s unsigned char *%sb_class_no[] = {\n",\r
+               gen_cpp?"":"static",\r
+               gen_cpp?ClassName("::"):"");\r
+       for(m=0; m<(mode_counter-1); ++m)\r
+               fprintf(OUT, "\tshift%d,\n", m);\r
+       fprintf(OUT, "\tshift%d\n};\n\n", m);\r
+}\r
+\r
+\r
+#ifdef __USE_PROTOS\r
+void p_alternative_table(void)                         /* MR1 */\r
+#else\r
+void p_alternative_table()                                     /* MR1 */\r
+#endif\r
+{\r
+       register int i;\r
+\r
+       if ( !gen_cpp ) fprintf(OUT, "#define ZZINTERACTIVE\n\n");\r
+       if ( gen_cpp )\r
+               fprintf(OUT, "DLGChar %salternatives[%d] = {\n",  /* mr23 vhs %sDfaStates+1 */\r
+                               ClassName("::"),\r
+                               dfa_allocated+1); /* vhs ClassName("::")); */\r
+       else\r
+               fprintf(OUT, "static %s zzalternatives[DfaStates+1] = {\n",\r
+                               minsize(dfa_allocated));\r
+\r
+       for(i=1; i<=dfa_allocated; ++i)\r
+               fprintf(OUT, "\t%d,\n", DFA(i)->alternatives);\r
+       fprintf(OUT, "/* must have 0 for zzalternatives[DfaStates] */\n");\r
+       fprintf(OUT, "\t0\n};\n\n");\r
+}\r
+\r
+\r
+#ifdef __USE_PROTOS\r
+void p_mode_def(char *s,int m)                 /* MR1 */\r
+#else\r
+void p_mode_def(s,m)                                   /* MR1 */\r
+char *s;\r
+int m;\r
+#endif\r
+{\r
+       if ( gen_cpp )\r
+       {\r
+               mode_name[cur_mode] = mystrdup(s);\r
+               mode_number[cur_mode] = m;\r
+               cur_mode++;\r
+       }\r
+       else\r
+               fprintf(mode_stream, "#define %s %d\n", s, m);\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+char * ClassName(char *suffix)\r
+#else\r
+char * ClassName(suffix)\r
+char *suffix;\r
+#endif\r
+{\r
+       static char buf[200];\r
+       extern char *class_name;\r
+\r
+       sprintf(buf, "%s%s", class_name, suffix);\r
+       return buf;\r
+}\r
+\r
+#ifdef DEBUG\r
+\r
+/* print out a particular nfa node that is pointed to by p */\r
+\r
+#ifdef __USE_PROTOS\r
+void p_nfa_node(nfa_node *p)\r
+#else\r
+void p_nfa_node(p)\r
+nfa_node *p;\r
+#endif\r
+{\r
+        register nfa_node *t;\r
+\r
+       if (p != NIL_INDEX){\r
+               printf("NFA state : %d\naccept state : %d\n",\r
+                       NFA_NO(p),p->accept);\r
+               if (p->trans[0] != NIL_INDEX){\r
+                       printf("trans[0] => %d on ", NFA_NO(p->trans[0]));\r
+                       p_set(p->label);\r
+                       printf("\n");\r
+                       }\r
+               else\r
+                       printf("trans[0] => nil\n");\r
+               if (p->trans[1] != NIL_INDEX)\r
+                       printf("trans[1] => %d on epsilon\n",\r
+                               NFA_NO(p->trans[1]));\r
+               else\r
+                       printf("trans[1] => nil\n");\r
+               printf("\n");\r
+               }\r
+}\r
+#endif\r
+\r
+#ifdef  DEBUG\r
+\r
+/* code to print out special structures when using a debugger */\r
+\r
+#ifdef __USE_PROTOS\r
+void p_nfa(p)\r
+#else\r
+void p_nfa(nfa_node *p)\r
+nfa_node *p;   /* state number also index into array */\r
+#endif\r
+{\r
+/* each node has a marker on it so it only gets printed once */\r
+\r
+       operation_no++; /* get new number */\r
+       s_p_nfa(p);\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+void s_p_nfa(nfa_node *p)\r
+#else\r
+void s_p_nfa(p)\r
+nfa_node *p;   /* state number also index into array */\r
+#endif\r
+{\r
+       if ((p != NIL_INDEX) && (p->nfa_set != operation_no)){\r
+               /* so it is only printed once */\r
+               p->nfa_set = operation_no;\r
+               p_nfa_node(p);\r
+               s_p_nfa(p->trans[0]);\r
+               s_p_nfa(p->trans[1]);\r
+               }\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+void p_dfa_node(dfa_node *p)\r
+#else\r
+void p_dfa_node(p)\r
+dfa_node *p;\r
+#endif\r
+{\r
+       int i;\r
+\r
+       if (p != NIL_INDEX){\r
+               printf("DFA state :%d\n",NFA_NO(p));\r
+               if (p->done)\r
+                       printf("done\n");\r
+               else\r
+                       printf("undone\n");\r
+               printf("from nfa states : ");\r
+               p_set(p->nfa_states);\r
+               printf("\n");\r
+               /* NOTE: trans arcs stored as ints rather than pointer*/\r
+               for (i=0; i<class_no; i++){\r
+                       printf("%d ",p->trans[i]);\r
+                       }\r
+               printf("\n\n");\r
+               }\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+void p_dfa(void)\r
+#else\r
+void p_dfa()\r
+#endif\r
+{\r
+/* prints out all the dfa nodes actually allocated */\r
+\r
+       int i;\r
+\r
+       for (i = 1; i<=dfa_allocated; i++)\r
+               p_dfa_node(NFA(i));\r
+}\r
+\r
+\r
+/* print out numbers in the set label */\r
+\r
+#ifdef __USE_PROTOS\r
+void p_set(set label)\r
+#else\r
+void p_set(label)\r
+set label;\r
+#endif\r
+{\r
+       unsigned *t, *e;\r
+\r
+       if (set_nil(label)){\r
+               printf("epsilon\n");\r
+       }else{\r
+               t = e = set_pdq(label);\r
+               while(*e != nil){\r
+                       printf("%d ", (*e+MIN_CHAR));\r
+                       e++;\r
+               }\r
+               printf("\n");\r
+               free(t);\r
+       }\r
+       \r
+}\r
+#endif\r
diff --git a/Tools/CodeTools/Source/Pccts/dlg/parser.dlg b/Tools/CodeTools/Source/Pccts/dlg/parser.dlg
new file mode 100644 (file)
index 0000000..df9a637
--- /dev/null
@@ -0,0 +1,398 @@
+<<\r
+/* parser.dlg -- DLG Description of scanner\r
+ *\r
+ * Generated from: dlg_p.g\r
+ *\r
+ * Terence Parr, Will Cohen, and Hank Dietz: 1989-2001\r
+ * Purdue University Electrical Engineering\r
+ * With AHPCRC, University of Minnesota\r
+ * ANTLR Version 1.33MR33\r
+ */\r
+\r
+#define ANTLR_VERSION  13333\r
+#include "pcctscfg.h"\r
+#include "pccts_stdio.h"\r
+\r
+#include <ctype.h>\r
+#include "dlg.h"\r
+#include "antlr.h"\r
+#include "tokens.h"\r
+#include "dlgdef.h"\r
+LOOKAHEAD\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+zzerraction(void)\r
+#else\r
+zzerraction()\r
+#endif\r
+{\r
+       (*zzerr)("invalid token");\r
+       zzadvance();\r
+       zzskip();\r
+}\r
+>>\r
+\r
+<<%%lexaction\r
+\r
+int    func_action;            /* should actions be turned into functions?*/\r
+int    lex_mode_counter = 0;   /* keeps track of the number of %%names */\r
+/* MR1                                                                     */\r
+/* MR1  11-Apr-97      Provide mechanism for inserting code into DLG class */\r
+/* MR1                         via <<%%lexmember...>>                      */\r
+/* MR1                                                                     */\r
+int    lexMember = 0;          /* <<%%lexmemeber ...>>                 MR1 */\r
+int    lexAction = 0;          /* <<%%lexaction ...>>                  MR1 */\r
+int    parserClass = 0;        /* <<%%parserclass ...>>        MR1 */\r
+int    lexPrefix = 0;          /* <<%%lexprefix ...>>                  MR1 */\r
+char   theClassName[100];                                                   /* MR11 */\r
+char   *pClassName=theClassName;                                        /* MR11 */\r
+int    firstLexMember=1;                                                    /* MR1 */\r
+\r
+#ifdef __USE_PROTOS\r
+void  xxputc(int c) {                                          /* MR1 */\r
+#else\r
+  void xxputc(c)                                                       /* MR1 */\r
+  int  c;                                                      /* MR1 */\r
+  {                                                            /* MR1 */\r
+#endif\r
+    if (parserClass) {                                         /* MR1 */\r
+      *pClassName++=c;                                         /* MR1 */\r
+      *pClassName=0;                                           /* MR1 */\r
+    } else if (lexMember || lexPrefix) {                               /* MR1 */\r
+      if (class_stream != NULL) fputc(c,class_stream);         /* MR1 */\r
+    } else {                                                   /* MR1 */\r
+      fputc(c,OUT);                                            /* MR1 */\r
+    };                                                         /* MR1 */\r
+  }                                                            /* MR1 */\r
+  \r
+#ifdef __USE_PROTOS\r
+  void xxprintf(char *format,char *string) {                   /* MR1 */\r
+#else\r
+    void xxprintf(format,string)                                       /* MR1 */\r
+    char *format;                                                      /* MR1 */\r
+    char *string;                                                      /* MR1 */\r
+    {                                                          /* MR1 */\r
+#endif\r
+      if (lexMember || lexPrefix || parserClass) {                     /* MR1 */\r
+        if (class_stream != NULL)                                      /* MR1 */\r
+        fprintf(class_stream,format,string);                   /* MR1 */\r
+      } else {                                                 /* MR1 */\r
+        fprintf(OUT,format,string);                                    /* MR1 */\r
+      };                                                               /* MR1 */\r
+    }                                                                  /* MR1 */\r
+>>\r
+\r
+\r
+%%START\r
+\r
+@\r
+       <<\r
+               NLA = 1;\r
+       >>\r
+\r
+[\r\t\ ]+\r
+       <<\r
+               NLA = 2;\r
+    zzskip();   \r
+       >>\r
+\r
+\n\r
+       <<\r
+               NLA = 3;\r
+    zzline++; zzskip(); DAWDLE;   \r
+       >>\r
+\r
+\@\r
+       <<\r
+               NLA = L_EOF;\r
+       >>\r
+\r
+\%\%\r
+       <<\r
+               NLA = PER_PER;\r
+       >>\r
+\r
+\%\%[a-zA-Z_][a-zA-Z0-9_]*\r
+       <<\r
+               NLA = NAME_PER_PER;\r
+    p_mode_def(&zzlextext[2],lex_mode_counter++);   \r
+       >>\r
+\r
+\<\<\%\%lexmember\r
+       <<\r
+               NLA = LEXMEMBER;\r
+    lexMember=1;                                       /* MR1 */\r
+    if (firstLexMember != 0) {                 /* MR1 */\r
+      firstLexMember=0;                                /* MR1 */\r
+      p_class_def1();                          /* MR1 */\r
+    };                                         /* MR1 */\r
+    zzmode(ACT);                                       /* MR1 */\r
+       >>\r
+\r
+\<\<\%\%lexaction\r
+       <<\r
+               NLA = LEXACTION;\r
+    lexAction=1;zzmode(ACT);  \r
+       >>\r
+\r
+\<\<\%\%parserclass\r
+       <<\r
+               NLA = PARSERCLASS;\r
+    parserClass=1;                             /* MR1 */\r
+    zzmode(ACT);                                       /* MR1 */\r
+       >>\r
+\r
+\<\<\%\%lexprefix\r
+       <<\r
+               NLA = LEXPREFIX;\r
+    lexPrefix=1;zzmode(ACT);  \r
+       >>\r
+\r
+\<\<\r
+       <<\r
+               NLA = ACTION;\r
+    if (func_action)\r
+    fprintf(OUT,"\n%s %sact%d()\n{ ",\r
+    gen_cpp?"ANTLRTokenType":"static void",\r
+    gen_cpp?ClassName("::"):"", ++action_no);\r
+    zzmode(ACT); zzskip();\r
+       >>\r
+\r
+\>\>\r
+       <<\r
+               NLA = GREAT_GREAT;\r
+       >>\r
+\r
+\{\r
+       <<\r
+               NLA = L_BRACE;\r
+       >>\r
+\r
+\}\r
+       <<\r
+               NLA = R_BRACE;\r
+       >>\r
+\r
+\(\r
+       <<\r
+               NLA = L_PAR;\r
+       >>\r
+\r
+\)\r
+       <<\r
+               NLA = R_PAR;\r
+       >>\r
+\r
+\[\r
+       <<\r
+               NLA = L_BRACK;\r
+       >>\r
+\r
+\]\r
+       <<\r
+               NLA = R_BRACK;\r
+       >>\r
+\r
+\*\r
+       <<\r
+               NLA = ZERO_MORE;\r
+       >>\r
+\r
+\+\r
+       <<\r
+               NLA = ONE_MORE;\r
+       >>\r
+\r
+\|\r
+       <<\r
+               NLA = OR;\r
+       >>\r
+\r
+\-\r
+       <<\r
+               NLA = RANGE;\r
+       >>\r
+\r
+\~\r
+       <<\r
+               NLA = NOT;\r
+       >>\r
+\r
+\\0[0-7]*\r
+       <<\r
+               NLA = OCTAL_VALUE;\r
+    {int t; sscanf(&zzlextext[1],"%o",&t); zzlextext[0] = t;}  \r
+       >>\r
+\r
+\\0[Xx][0-9a-fA-F]+\r
+       <<\r
+               NLA = HEX_VALUE;\r
+    {int t; sscanf(&zzlextext[3],"%x",&t); zzlextext[0] = t;}  \r
+       >>\r
+\r
+\\[1-9][0-9]*\r
+       <<\r
+               NLA = DEC_VALUE;\r
+    {int t; sscanf(&zzlextext[1],"%d",&t); zzlextext[0] = t;}  \r
+       >>\r
+\r
+\\t\r
+       <<\r
+               NLA = TAB;\r
+    zzlextext[0] = '\t';  \r
+       >>\r
+\r
+\\n\r
+       <<\r
+               NLA = NL;\r
+    zzlextext[0] = '\n';  \r
+       >>\r
+\r
+\\r\r
+       <<\r
+               NLA = CR;\r
+    zzlextext[0] = '\r';  \r
+       >>\r
+\r
+\\b\r
+       <<\r
+               NLA = BS;\r
+    zzlextext[0] = '\b';  \r
+       >>\r
+\r
+\\ \n\r
+       <<\r
+               NLA = CONTINUATION;\r
+    zzline++; zzskip();  \r
+       >>\r
+\r
+\\~[tnrb]\r
+       <<\r
+               NLA = LIT;\r
+    zzlextext[0] = zzlextext[1];  \r
+       >>\r
+\r
+~[\\]\r
+       <<\r
+               NLA = REGCHAR;\r
+       >>\r
+\r
+\r
+%%ACT\r
+\r
+@\r
+       <<\r
+               NLA = 1;\r
+    error("unterminated action", zzline); zzmode(START);   \r
+       >>\r
+\r
+\>\>\r
+       <<\r
+               NLA = ACTION;\r
+    if (func_action) fprintf(OUT,"}\n\n");\r
+    zzmode(START);\r
+    /* MR1                                                                         */\r
+    /* MR1  11-Apr-97  Provide mechanism for inserting code into DLG class */\r
+    /* MR1                             via <<%%lexmember ...>>                     */\r
+    /* MR1                     This is a consequence of not saving actions         */\r
+    /* MR1                                                                         */\r
+    /* MR1 */     parserClass=0;               \r
+    /* MR1 */     lexPrefix=0;\r
+    /* MR1 */     lexAction=0;\r
+    /* MR1 */     lexMember=0;\r
+       >>\r
+\r
+\>\r
+       <<\r
+               NLA = 34;\r
+    xxputc(zzlextext[0]); zzskip();   \r
+       >>\r
+\r
+\\\>\r
+       <<\r
+               NLA = 35;\r
+    xxputc('>'); zzskip();   \r
+       >>\r
+\r
+\\\r
+       <<\r
+               NLA = 36;\r
+    xxputc('\\'); zzskip();   \r
+       >>\r
+\r
+\n\r
+       <<\r
+               NLA = 37;\r
+    xxputc(zzlextext[0]); ++zzline; zzskip();   \r
+       >>\r
+\r
+/\*\r
+       <<\r
+               NLA = 38;\r
+    zzmode(ACTION_COMMENTS);                   /* MR1 */\r
+    xxprintf("%s", &(zzlextext[0])); zzskip(); /* MR1 */\r
+       >>\r
+\r
+//\r
+       <<\r
+               NLA = 39;\r
+    zzmode(ACTION_CPP_COMMENTS);                       /* MR1 */\r
+    xxprintf("%s", &(zzlextext[0])); zzskip(); /* MR1 */\r
+       >>\r
+\r
+~[]\r
+       <<\r
+               NLA = 40;\r
+    xxputc(zzlextext[0]); zzskip();   \r
+       >>\r
+\r
+\r
+%%ACTION_COMMENTS\r
+\r
+@\r
+       <<\r
+               NLA = 1;\r
+       >>\r
+\r
+\*/\r
+       <<\r
+               NLA = 41;\r
+    zzmode(ACT);                                       /* MR1 */\r
+    xxprintf("%s", &(zzlextext[0])); zzskip(); /* MR1 */\r
+       >>\r
+\r
+[\n\r]\r
+       <<\r
+               NLA = 42;\r
+    zzline++; xxputc(zzlextext[0]); zzskip();  \r
+       >>\r
+\r
+~[]\r
+       <<\r
+               NLA = 43;\r
+    xxputc(zzlextext[0]); zzskip();  \r
+       >>\r
+\r
+\r
+%%ACTION_CPP_COMMENTS\r
+\r
+@\r
+       <<\r
+               NLA = 1;\r
+       >>\r
+\r
+[\n\r]\r
+       <<\r
+               NLA = 44;\r
+    zzmode(ACT); zzline++;                     /* MR1 */\r
+    xxprintf("%s", &(zzlextext[0])); zzskip(); /* MR1 */\r
+       >>\r
+\r
+~[]\r
+       <<\r
+               NLA = 45;\r
+    xxputc(zzlextext[0]); zzskip();  \r
+       >>\r
+\r
+%%\r
diff --git a/Tools/CodeTools/Source/Pccts/dlg/relabel.c b/Tools/CodeTools/Source/Pccts/dlg/relabel.c
new file mode 100644 (file)
index 0000000..0b8bc16
--- /dev/null
@@ -0,0 +1,217 @@
+/* This group of functions does the character class compression.\r
+   It goes over the dfa and relabels the arcs with the partitions\r
+   of characters in the NFA.  The partitions are stored in the\r
+   array class.\r
+\r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
+ * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
+ * company may do whatever they wish with source code distributed with\r
+ * PCCTS or the code generated by PCCTS, including the incorporation of\r
+ * PCCTS, or its output, into commerical software.\r
+ *\r
+ * We encourage users to develop software with PCCTS.  However, we do ask\r
+ * that credit is given to us for developing PCCTS.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like PCCTS and have developed a nice tool with the\r
+ * output, please mention that you developed it using PCCTS.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * DLG 1.33\r
+ * Will Cohen\r
+ * With mods by Terence Parr; AHPCRC, University of Minnesota\r
+ * 1989-2001\r
+ */\r
+\r
+#include <stdio.h>\r
+#include "dlg.h"\r
+#ifdef MEMCHK\r
+#include "trax.h"\r
+#else\r
+#ifdef __STDC__\r
+#include <stdlib.h>\r
+#else\r
+#include <malloc.h>\r
+#endif /* __STDC__ */\r
+#endif\r
+\r
+int    class_no = CHAR_RANGE;  /* number of classes for labels */\r
+int    first_el[CHAR_RANGE];   /* first element in each class partition */\r
+set    class_sets[CHAR_RANGE]; /* array holds partitions from class */\r
+                               /* compression */\r
+\r
+/* goes through labels on NFA graph and partitions the characters into\r
+ * character classes.  This reduces the amount of space required for each\r
+ * dfa node, since only one arc is required each class instead of one arc\r
+ * for each character\r
+ * level:\r
+ * 0 no compression done\r
+ * 1 remove unused characters from classes\r
+ * 2 compress equivalent characters into same class\r
+ *\r
+ * returns the number of character classes required\r
+ */\r
+#ifdef __USE_PROTOS\r
+int relabel(nfa_node* start,int level)\r
+#else\r
+int relabel(start,level)\r
+int level;\r
+nfa_node *start;\r
+#endif\r
+{\r
+       if (level){\r
+               set_free(used_classes); \r
+               partition(start,level);\r
+               label_with_classes(start);\r
+       }else{\r
+               /* classes equivalent to all characters in alphabet */\r
+               class_no = CHAR_RANGE;\r
+       }\r
+       return class_no;\r
+}\r
+\r
+/* makes character class sets for new labels */\r
+#ifdef __USE_PROTOS\r
+void partition(nfa_node* start,int level)\r
+#else\r
+void partition(start,level)\r
+nfa_node       *start; /* beginning of nfa graph */\r
+int            level;  /* compression level to uses */\r
+#endif\r
+{\r
+       set current_class;\r
+       set unpart_chars;\r
+       set temp;\r
+\r
+       unpart_chars = set_dup(used_chars);\r
+#if 0\r
+       /* EOF (-1+1) alway in class 0 */\r
+       class_sets[0] = set_of(0);\r
+       first_el[0] = 0;\r
+       used_classes = set_of(0);\r
+       temp = set_dif(unpart_chars, class_sets[0]);\r
+       set_free(unpart_chars);\r
+       unpart_chars = temp;\r
+       class_no = 1;\r
+#else\r
+       class_no = 0;\r
+#endif\r
+       while (!set_nil(unpart_chars)){\r
+               /* don't look for equivalent labels if c <= 1 */\r
+               if (level <= 1){\r
+                       current_class = set_of(set_int(unpart_chars));\r
+               }else{\r
+                       current_class = set_dup(unpart_chars);\r
+                       intersect_nfa_labels(start,&current_class);\r
+               }\r
+               set_orel(class_no,&used_classes);\r
+               first_el[class_no] = set_int(current_class);\r
+               class_sets[class_no] = current_class;\r
+               temp = set_dif(unpart_chars,current_class);\r
+               set_free(unpart_chars);\r
+               unpart_chars = temp;\r
+               ++class_no;\r
+       }\r
+\r
+       /* free unpart_chars -ATG 5/6/95 */\r
+       set_free(unpart_chars);\r
+\r
+#if 0\r
+       /* group all the other unused characters into a class */\r
+       set_orel(class_no,&used_classes);\r
+       first_el[class_no] = set_int(current_class);\r
+       class_sets[class_no] = set_dif(normal_chars,used_chars);\r
+       ++class_no;\r
+#endif\r
+}\r
+\r
+\r
+/* given pointer to beginning of graph and recursively walks it trying\r
+ * to find a maximal partition.  This partion in returned in maximal_class\r
+ */\r
+#ifdef __USE_PROTOS\r
+void intersect_nfa_labels(nfa_node* start,set* maximal_class)\r
+#else\r
+void intersect_nfa_labels(start,maximal_class)\r
+nfa_node *start;\r
+set *maximal_class;\r
+#endif\r
+{\r
+       /* pick a new operation number */\r
+       ++operation_no;\r
+       r_intersect(start,maximal_class);       \r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+void r_intersect(nfa_node* start,set* maximal_class)\r
+#else\r
+void r_intersect(start,maximal_class)\r
+nfa_node *start;\r
+set * maximal_class;\r
+#endif\r
+{\r
+       set temp;\r
+\r
+       if(start && start->nfa_set != operation_no)\r
+       {\r
+               start->nfa_set = operation_no;\r
+               temp = set_and(*maximal_class,start->label);\r
+               if (!set_nil(temp))\r
+               {\r
+                       set_free(*maximal_class);\r
+                       *maximal_class = temp;\r
+               }else{\r
+                       set_free(temp);\r
+               }\r
+               r_intersect(start->trans[0],maximal_class);\r
+               r_intersect(start->trans[1],maximal_class);\r
+       }\r
+}\r
+\r
+\r
+/* puts class labels in place of old character labels */\r
+#ifdef __USE_PROTOS\r
+void label_with_classes(nfa_node* start)\r
+#else\r
+void label_with_classes(start)\r
+nfa_node *start;\r
+#endif\r
+{\r
+       ++operation_no;\r
+       label_node(start);\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+void label_node(nfa_node *start)\r
+#else\r
+void label_node(start)\r
+nfa_node *start;\r
+#endif\r
+{\r
+       set new_label;\r
+       register int i;\r
+\r
+       /* only do node if it hasn't been done before */\r
+       if (start && start->nfa_set != operation_no){\r
+               start->nfa_set = operation_no;\r
+               new_label = empty;\r
+               for (i = 0; i<class_no; ++i){\r
+                       /* if one element of class in old_label,\r
+                          all elements are. */\r
+                       if (set_el(first_el[i],start->label))\r
+                               set_orel(i,&new_label);\r
+               }\r
+               set_free(start->label);\r
+               start->label = new_label;\r
+               /* do any nodes that can be reached from this one */\r
+               label_node(start->trans[0]);\r
+               label_node(start->trans[1]);\r
+       }\r
+}\r
diff --git a/Tools/CodeTools/Source/Pccts/dlg/stdpccts.h b/Tools/CodeTools/Source/Pccts/dlg/stdpccts.h
new file mode 100644 (file)
index 0000000..06ec67e
--- /dev/null
@@ -0,0 +1,26 @@
+#ifndef STDPCCTS_H\r
+#define STDPCCTS_H\r
+/*\r
+ * stdpccts.h -- P C C T S  I n c l u d e\r
+ *\r
+ * Terence Parr, Will Cohen, and Hank Dietz: 1989-2001\r
+ * Purdue University Electrical Engineering\r
+ * With AHPCRC, University of Minnesota\r
+ * ANTLR Version 1.33MR33\r
+ */\r
+\r
+#ifndef ANTLR_VERSION\r
+#define ANTLR_VERSION  13333\r
+#endif\r
+\r
+#include "pcctscfg.h"\r
+#include "pccts_stdio.h"\r
+\r
+#include <ctype.h>\r
+#include "dlg.h"\r
+#define zzSET_SIZE 8\r
+#include "antlr.h"\r
+#include "tokens.h"\r
+#include "dlgdef.h"\r
+#include "mode.h"\r
+#endif\r
diff --git a/Tools/CodeTools/Source/Pccts/dlg/support.c b/Tools/CodeTools/Source/Pccts/dlg/support.c
new file mode 100644 (file)
index 0000000..84fe99d
--- /dev/null
@@ -0,0 +1,240 @@
+/*\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
+ * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
+ * company may do whatever they wish with source code distributed with\r
+ * PCCTS or the code generated by PCCTS, including the incorporation of\r
+ * PCCTS, or its output, into commerical software.\r
+ *\r
+ * We encourage users to develop software with PCCTS.  However, we do ask\r
+ * that credit is given to us for developing PCCTS.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like PCCTS and have developed a nice tool with the\r
+ * output, please mention that you developed it using PCCTS.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * DLG 1.33\r
+ * Will Cohen\r
+ * With mods by Terence Parr; AHPCRC, University of Minnesota\r
+ * 1989-2001\r
+ */\r
+\r
+#include <stdio.h>\r
+#include <string.h>\r
+#include "dlg.h"\r
+#ifdef MEMCHK\r
+#include "trax.h"\r
+#else\r
+#ifdef __STDC__\r
+#include <stdlib.h>\r
+#else\r
+#include <malloc.h>\r
+#endif /* __STDC__ */\r
+#endif\r
+\r
+int    err_found = 0;                  /* indicates whether problem found */\r
+\r
+#ifdef __USE_PROTOS\r
+void internal_error(char *s, char *file,int line)    /* MR9 23-Sep-97 */\r
+#else\r
+void internal_error(s,file,line)    /* MR9 23-Sep-97 */\r
+char *s,*file;\r
+int line;\r
+#endif\r
+{\r
+       fprintf(stderr,s,file,line);\r
+       exit(PCCTS_EXIT_FAILURE);\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+char *dlg_malloc(int bytes,char *file,int line)\r
+#else\r
+char *dlg_malloc(bytes,file,line)\r
+int bytes;\r
+char *file;\r
+int line;\r
+#endif\r
+{\r
+       char *t;\r
+\r
+       t = (char *) malloc(bytes);\r
+       if (!t){\r
+               /* error */\r
+               internal_error("%s(%d): unable to allocate memory\n",\r
+                       file,line);\r
+       }\r
+       return t;\r
+}\r
+\r
+\r
+#ifdef __USE_PROTOS\r
+char *dlg_calloc(int n,int bytes,char *file,int line)\r
+#else\r
+char *dlg_calloc(n,bytes,file,line)\r
+int n,bytes;\r
+char *file;\r
+int line;\r
+#endif\r
+{\r
+       char *t;\r
+\r
+       t = (char *) calloc(n,bytes);\r
+       if (!t){\r
+               /* error */\r
+               internal_error("%s(%d): unable to allocate memory\n",\r
+                       file,line);\r
+       }\r
+       return t;\r
+}\r
+\r
+\r
+#ifdef __USE_PROTOS\r
+FILE *read_stream(char *name)\r
+#else\r
+FILE *read_stream(name)\r
+char *name;\r
+#endif\r
+{\r
+       FILE *f;\r
+\r
+       if (name){\r
+               if (name[0] == '-') {\r
+                       fprintf(stderr, "dlg: invalid option: '%s'\n", name);\r
+                       f = NULL;\r
+               }else{\r
+                       f = fopen(name, "r");\r
+                       if (f == NULL){\r
+                               /* couldn't open file */\r
+                               fprintf(stderr,\r
+                                       "dlg: Warning: Can't read file %s.\n",\r
+                                       name);\r
+                       }\r
+               }\r
+       }else{\r
+               /* open stdin if nothing there */\r
+               f = stdin;\r
+       }\r
+       return f;\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+FILE *write_stream(char *name)\r
+#else\r
+FILE *write_stream(name)\r
+char *name;\r
+#endif\r
+{\r
+       FILE *f;\r
+\r
+       if (name){\r
+               if (name[0] == '-') {\r
+                       fprintf(stderr, "dlg: invalid option: '%s'\n", name);\r
+                       f = NULL;\r
+               }else{\r
+                       f = fopen(OutMetaName(name), "w");\r
+                       if (f == NULL){\r
+                               /* couldn't open file */\r
+                               fprintf(stderr,\r
+                                       "dlg: Warning: Can't write to file %s.\n",\r
+                                       name);\r
+                       }\r
+                       else\r
+#ifdef SPECIAL_FOPEN\r
+                special_fopen_actions(OutMetaName(name));      /* MR1 */\r
+#else\r
+               ;                                               /* MR1 */\r
+#endif\r
+               }\r
+       }else{\r
+               /* open stdout if nothing there */\r
+               f = stdout;\r
+       }\r
+       return f;\r
+}\r
+\r
+\r
+#ifdef __USE_PROTOS\r
+void fatal(char *message,int line_no)\r
+#else\r
+void fatal(message,line_no)\r
+char *message;\r
+int line_no;\r
+#endif\r
+{\r
+       fprintf(stderr,ErrHdr,\r
+               (file_str[0] ? file_str[0] : "stdin"), line_no);\r
+       fprintf(stderr, " Fatal: %s\n", message);\r
+       exit(PCCTS_EXIT_FAILURE);\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+void error(char *message,int line_no)\r
+#else\r
+void error(message,line_no)\r
+char *message;\r
+int line_no;\r
+#endif\r
+{\r
+       fprintf(stderr,ErrHdr,\r
+               (file_str[0] ? file_str[0] : "stdin"), line_no);\r
+       fprintf(stderr, " Error: %s\n", message);\r
+       err_found = 1;\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+void warning(char *message,int line_no)\r
+#else\r
+void warning(message,line_no)\r
+char *message;\r
+int line_no;\r
+#endif\r
+{\r
+       fprintf(stderr,ErrHdr,\r
+               (file_str[0] ? file_str[0] : "stdin"), line_no);\r
+       fprintf(stderr, " Warning: %s\n", message);\r
+}\r
+\r
+/* MR10: Jeff Vincent\r
+   MR10: Changed to remove directory information from n only if\r
+   MR10: if OutputDirectory was changed by user (-o option)\r
+*/\r
+\r
+#ifdef __USE_PROTOS\r
+char *OutMetaName(char *n)\r
+#else\r
+char *OutMetaName(n)\r
+char *n;\r
+#endif\r
+{      \r
+    static char *dir_sym = DirectorySymbol;\r
+    static char newname[MaxFileName+1];\r
+    char *p;\r
+\r
+       /* If OutputDirectory is same as TopDirectory (platform default) then leave n alone. */\r
+    if (strcmp(OutputDirectory, TopDirectory) == 0)\r
+               return n;\r
+\r
+       /* p will point to filename without path information */\r
+       if ((p = strrchr(n, *dir_sym)) != NULL)\r
+               p++;\r
+       else\r
+               p = n;\r
+\r
+       /* Copy new output directory into newname[] */\r
+       strcpy(newname, OutputDirectory);\r
+\r
+       /* if new output directory does not have trailing dir_sym, add it! */\r
+       if (newname[strlen(newname)-1] != *dir_sym)\r
+               strcat(newname, dir_sym);\r
+\r
+       /* contatenate FILE NAME ONLY to new output directory */\r
+       strcat(newname, p);\r
+\r
+       return newname;\r
+}\r
diff --git a/Tools/CodeTools/Source/Pccts/dlg/tokens.h b/Tools/CodeTools/Source/Pccts/dlg/tokens.h
new file mode 100644 (file)
index 0000000..73e502b
--- /dev/null
@@ -0,0 +1,133 @@
+#ifndef tokens_h\r
+#define tokens_h\r
+/* tokens.h -- List of labelled tokens and stuff\r
+ *\r
+ * Generated from: dlg_p.g\r
+ *\r
+ * Terence Parr, Will Cohen, and Hank Dietz: 1989-2001\r
+ * Purdue University Electrical Engineering\r
+ * ANTLR Version 1.33MR33\r
+ */\r
+#define zzEOF_TOKEN 1\r
+#define L_EOF 4\r
+#define PER_PER 5\r
+#define NAME_PER_PER 6\r
+#define LEXMEMBER 7\r
+#define LEXACTION 8\r
+#define PARSERCLASS 9\r
+#define LEXPREFIX 10\r
+#define ACTION 11\r
+#define GREAT_GREAT 12\r
+#define L_BRACE 13\r
+#define R_BRACE 14\r
+#define L_PAR 15\r
+#define R_PAR 16\r
+#define L_BRACK 17\r
+#define R_BRACK 18\r
+#define ZERO_MORE 19\r
+#define ONE_MORE 20\r
+#define OR 21\r
+#define RANGE 22\r
+#define NOT 23\r
+#define OCTAL_VALUE 24\r
+#define HEX_VALUE 25\r
+#define DEC_VALUE 26\r
+#define TAB 27\r
+#define NL 28\r
+#define CR 29\r
+#define BS 30\r
+#define CONTINUATION 31\r
+#define LIT 32\r
+#define REGCHAR 33\r
+\r
+#ifdef __USE_PROTOS\r
+void grammar(void);\r
+#else\r
+extern void grammar();\r
+#endif\r
+\r
+#ifdef __USE_PROTOS\r
+void start_states(void);\r
+#else\r
+extern void start_states();\r
+#endif\r
+\r
+#ifdef __USE_PROTOS\r
+void do_conversion(void);\r
+#else\r
+extern void do_conversion();\r
+#endif\r
+\r
+#ifdef __USE_PROTOS\r
+void rule_list(void);\r
+#else\r
+extern void rule_list();\r
+#endif\r
+\r
+#ifdef __USE_PROTOS\r
+void rule(void);\r
+#else\r
+extern void rule();\r
+#endif\r
+\r
+#ifdef __USE_PROTOS\r
+void reg_expr(void);\r
+#else\r
+extern void reg_expr();\r
+#endif\r
+\r
+#ifdef __USE_PROTOS\r
+void and_expr(void);\r
+#else\r
+extern void and_expr();\r
+#endif\r
+\r
+#ifdef __USE_PROTOS\r
+void repeat_expr(void);\r
+#else\r
+extern void repeat_expr();\r
+#endif\r
+\r
+#ifdef __USE_PROTOS\r
+void expr(void);\r
+#else\r
+extern void expr();\r
+#endif\r
+\r
+#ifdef __USE_PROTOS\r
+void atom_list(void);\r
+#else\r
+extern void atom_list();\r
+#endif\r
+\r
+#ifdef __USE_PROTOS\r
+void near_atom(void);\r
+#else\r
+extern void near_atom();\r
+#endif\r
+\r
+#ifdef __USE_PROTOS\r
+void atom(void);\r
+#else\r
+extern void atom();\r
+#endif\r
+\r
+#ifdef __USE_PROTOS\r
+void anychar(void);\r
+#else\r
+extern void anychar();\r
+#endif\r
+\r
+#endif\r
+extern SetWordType zzerr1[];\r
+extern SetWordType zzerr2[];\r
+extern SetWordType zzerr3[];\r
+extern SetWordType setwd1[];\r
+extern SetWordType zzerr4[];\r
+extern SetWordType zzerr5[];\r
+extern SetWordType zzerr6[];\r
+extern SetWordType setwd2[];\r
+extern SetWordType zzerr7[];\r
+extern SetWordType zzerr8[];\r
+extern SetWordType zzerr9[];\r
+extern SetWordType setwd3[];\r
diff --git a/Tools/CodeTools/Source/Pccts/h/AParser.cpp b/Tools/CodeTools/Source/Pccts/h/AParser.cpp
new file mode 100644 (file)
index 0000000..720fe75
--- /dev/null
@@ -0,0 +1,871 @@
+/* ANTLRParser.C\r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
+ * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
+ * company may do whatever they wish with source code distributed with\r
+ * PCCTS or the code generated by PCCTS, including the incorporation of\r
+ * PCCTS, or its output, into commerical software.\r
+ *\r
+ * We encourage users to develop software with PCCTS.  However, we do ask\r
+ * that credit is given to us for developing PCCTS.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like PCCTS and have developed a nice tool with the\r
+ * output, please mention that you developed it using PCCTS.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * ANTLR 1.33\r
+ * Terence Parr\r
+ * Parr Research Corporation\r
+ * with Purdue University and AHPCRC, University of Minnesota\r
+ * 1989-2000\r
+ */\r
+\r
+#include "pcctscfg.h"\r
+\r
+#include "pccts_stdlib.h"\r
+#include "pccts_stdarg.h"\r
+#include "pccts_string.h"\r
+#include "pccts_stdio.h"\r
+\r
+PCCTS_NAMESPACE_STD\r
+\r
+/* I have to put this here due to C++ limitation\r
+ * that you can't have a 'forward' decl for enums.\r
+ * I hate C++!!!!!!!!!!!!!!!\r
+ * Of course, if I could use real templates, this would go away.\r
+ */\r
+// MR1\r
+// MR1  10-Apr-97  133MR1  Prevent use of varying sizes for the\r
+// MR1                         ANTLRTokenType enum\r
+// MR1\r
+\r
+enum ANTLRTokenType { TER_HATES_CPP=0, ITS_TOO_COMPLICATED=9999};          // MR1\r
+\r
+#define ANTLR_SUPPORT_CODE\r
+\r
+#include ATOKEN_H\r
+#include ATOKENBUFFER_H\r
+#include APARSER_H\r
+\r
+static const int zzINF_DEF_TOKEN_BUFFER_SIZE = 2000;    /* MR14 */\r
+static const int zzINF_BUFFER_TOKEN_CHUNK_SIZE = 1000;  /* MR14 */\r
+\r
+                 /* L o o k a h e a d  M a c r o s */\r
+\r
+/* maximum of 32 bits/unsigned int and must be 8 bits/byte;\r
+ * we only use 8 bits of it.\r
+ */\r
+SetWordType ANTLRParser::bitmask[sizeof(SetWordType)*8] = {\r
+       0x00000001, 0x00000002, 0x00000004, 0x00000008,\r
+       0x00000010, 0x00000020, 0x00000040, 0x00000080\r
+};\r
+\r
+char ANTLRParser::eMsgBuffer[500] = "";\r
+\r
+ANTLRParser::\r
+~ANTLRParser()\r
+{\r
+       delete [] token_type;\r
+    delete [] zzFAILtext;       // MR16 Manfred Kogler\r
+}\r
+\r
+ANTLRParser::\r
+ANTLRParser(ANTLRTokenBuffer *_inputTokens,\r
+                       int k,\r
+                       int use_inf_look,\r
+                       int dlook,\r
+                       int ssize)\r
+{\r
+       LLk = k;\r
+       can_use_inf_look = use_inf_look;\r
+/* MR14 */    if (dlook != 0) {\r
+/* MR14 */      panic("ANTLRParser::ANTLRParser - Demand lookahead not supported in C++ mode");\r
+/* MR14 */\r
+/* MR14 */    };\r
+    demand_look = 0;    /* demand_look = dlook; */\r
+    bsetsize = ssize;\r
+       guessing = 0;\r
+       token_tbl = NULL;\r
+       eofToken = (ANTLRTokenType)1;\r
+\r
+       // allocate lookahead buffer\r
+       token_type = new ANTLRTokenType[LLk];\r
+       lap = 0;\r
+       labase = 0;\r
+#ifdef ZZDEFER_FETCH\r
+       stillToFetch = 0;                                                   // MR19\r
+#endif\r
+       dirty = 0;\r
+    inf_labase = 0;                                                     // MR7\r
+    inf_last = 0;                                                       // MR7\r
+       /* prime lookahead buffer, point to inputTokens */\r
+       this->inputTokens = _inputTokens;\r
+       this->inputTokens->setMinTokens(k);\r
+       _inputTokens->setParser(this);                                                      // MR1\r
+    resynchConsumed=1;                                                  // MR8\r
+    zzFAILtext=NULL;                                                    // MR9\r
+    traceOptionValueDefault=0;                                          // MR10\r
+    traceReset();                                                       // MR10\r
+    zzGuessSeq=0;                                                       // MR10\r
+    syntaxErrCount=0;                                                   // MR11\r
+}\r
+\r
+void ANTLRParser::init()\r
+{\r
+   prime_lookahead();\r
+   resynchConsumed=1;                                                   // MR8\r
+   traceReset();                                                        // MR10\r
+}\r
+\r
+void ANTLRParser::traceReset()\r
+{\r
+   traceOptionValue=traceOptionValueDefault;\r
+   traceGuessOptionValue=1;\r
+   traceCurrentRuleName=NULL;\r
+   traceDepth=0;\r
+}\r
+\r
+\r
+#ifdef _MSC_VER  // MR23\r
+//Turn off warning:\r
+//interaction between '_setjmp' and C++ object destruction is non-portable\r
+#pragma warning(disable : 4611)\r
+#endif\r
+int ANTLRParser::\r
+guess(ANTLRParserState *st)\r
+{\r
+       saveState(st);\r
+       guessing = 1;\r
+       return setjmp(guess_start.state);\r
+}\r
+#ifdef _MSC_VER  // MR23\r
+#pragma warning(default: 4611)\r
+#endif\r
+\r
+void ANTLRParser::\r
+saveState(ANTLRParserState *buf)\r
+{\r
+       buf->guess_start = guess_start;\r
+       buf->guessing = guessing;\r
+       buf->inf_labase = inf_labase;\r
+       buf->inf_last = inf_last;\r
+       buf->dirty = dirty;\r
+    buf->traceOptionValue=traceOptionValue;            /* MR10 */\r
+    buf->traceGuessOptionValue=traceGuessOptionValue;  /* MR10 */\r
+    buf->traceCurrentRuleName=traceCurrentRuleName;    /* MR10 */\r
+    buf->traceDepth=traceDepth;                        /* MR10 */\r
+}\r
+\r
+void ANTLRParser::\r
+restoreState(ANTLRParserState *buf)\r
+{\r
+       int     i;\r
+    int     prevTraceOptionValue;\r
+\r
+       guess_start = buf->guess_start;\r
+       guessing = buf->guessing;\r
+       inf_labase = buf->inf_labase;\r
+       inf_last = buf->inf_last;\r
+       dirty = buf->dirty;\r
+\r
+       // restore lookahead buffer from k tokens before restored TokenBuffer position\r
+       // if demand_look, then I guess we don't look backwards for these tokens.\r
+       for (i=1; i<=LLk; i++) token_type[i-1] =\r
+               inputTokens->bufferedToken(i-LLk)->getType();\r
+       lap = 0;\r
+       labase = 0;\r
+\r
+    /* MR10 */\r
+\r
+    prevTraceOptionValue=traceOptionValue;\r
+    traceOptionValue=buf->traceOptionValue;\r
+    if ( (prevTraceOptionValue > 0) !=\r
+             (traceOptionValue > 0)) {\r
+      if (traceCurrentRuleName != NULL) {  /* MR21 */\r
+          if (traceOptionValue > 0) {\r
+            /* MR23 */ printMessage(stderr,\r
+                   "trace enable restored in rule %s depth %d\n",\r
+                   traceCurrentRuleName,\r
+                   traceDepth);\r
+          };\r
+          if (traceOptionValue <= 0) {\r
+            /* MR23 */ printMessage(stderr,\r
+            "trace disable restored in rule %s depth %d\n",\r
+            traceCurrentRuleName, /* MR21 */\r
+            traceDepth);\r
+          };\r
+       }\r
+    };\r
+    traceGuessOptionValue=buf->traceGuessOptionValue;\r
+    traceCurrentRuleName=buf->traceCurrentRuleName;\r
+    traceDepth=buf->traceDepth;\r
+    traceGuessDone(buf);\r
+}\r
+\r
+/* Get the next symbol from the input stream; put it into lookahead buffer;\r
+ * fill token_type[] fast reference cache also.  NLA is the next place where\r
+ * a lookahead ANTLRAbstractToken should go.\r
+ */\r
+void ANTLRParser::\r
+consume()\r
+{\r
+\r
+#ifdef ZZDEBUG_CONSUME_ACTION\r
+    zzdebug_consume_action();\r
+#endif\r
+\r
+// MR19 V.H. Simonis\r
+//      Defer Fetch feature\r
+//      Moves action of consume() into LA() function\r
+\r
+#ifdef ZZDEFER_FETCH\r
+      stillToFetch++;\r
+#else\r
+      NLA = inputTokens->getToken()->getType();\r
+      dirty--;\r
+      lap = (lap+1)&(LLk-1);\r
+#endif\r
+\r
+}\r
+\r
+_ANTLRTokenPtr ANTLRParser::\r
+LT(int i)\r
+{\r
+\r
+// MR19 V.H. Simonis\r
+//      Defer Fetch feature\r
+//      Moves action of consume() into LA() function\r
+\r
+#ifdef ZZDEFER_FETCH\r
+    undeferFetch();\r
+#endif\r
+\r
+#ifdef DEBUG_TOKENBUFFER\r
+       if ( i >= inputTokens->bufferSize() || inputTokens->minTokens() < LLk )     /* MR20 Was "<=" */\r
+       {\r
+               char buf[2000];                 /* MR20 Was "static" */\r
+        sprintf(buf, "The minimum number of tokens you requested that the\nANTLRTokenBuffer buffer is not enough to satisfy your\nLT(%d) request; increase 'k' argument to constructor for ANTLRTokenBuffer\n", i);\r
+               panic(buf);\r
+       }\r
+#endif\r
+       return inputTokens->bufferedToken(i-LLk);\r
+}\r
+\r
+void\r
+ANTLRParser::\r
+look(int k)\r
+{\r
+       int i, c = k - (LLk-dirty);\r
+       for (i=1; i<=c; i++) consume();\r
+}\r
+\r
+/* fill the lookahead buffer up with k symbols (even if DEMAND_LOOK);\r
+ */\r
+void\r
+ANTLRParser::\r
+prime_lookahead()\r
+{\r
+       int i;\r
+       for(i=1;i<=LLk; i++) consume();\r
+       dirty=0;\r
+       // lap = 0;     // MR14 Sinan Karasu (sinan.karasu@boeing.com)\r
+       // labase = 0;  // MR14\r
+    labase=lap;     // MR14\r
+}\r
+\r
+/* check to see if the current input symbol matches '_t'.\r
+ * During NON demand lookahead mode, dirty will always be 0 and\r
+ * hence the extra code for consuming tokens in _match is never\r
+ * executed; the same routine can be used for both modes.\r
+ */\r
+int ANTLRParser::\r
+_match(ANTLRTokenType _t, ANTLRChar **MissText,\r
+          ANTLRTokenType *MissTok, _ANTLRTokenPtr *BadTok,\r
+          SetWordType **MissSet)\r
+{\r
+       if ( dirty==LLk ) {\r
+               consume();\r
+       }\r
+       if ( LA(1)!=_t ) {\r
+               *MissText=NULL;\r
+               *MissTok= _t;\r
+               *BadTok = LT(1);\r
+               *MissSet=NULL;\r
+               return 0;\r
+       }\r
+       dirty++;\r
+       labase = (labase+1)&(LLk-1);    // labase maintained even if !demand look\r
+       return 1;\r
+}\r
+\r
+/* check to see if the current input symbol matches '_t'.\r
+ * Used during exception handling.\r
+ */\r
+int ANTLRParser::\r
+_match_wsig(ANTLRTokenType _t)\r
+{\r
+       if ( dirty==LLk ) {\r
+               consume();\r
+       }\r
+       if ( LA(1)!=_t ) return 0;\r
+       dirty++;\r
+       labase = (labase+1)&(LLk-1);    // labase maintained even if !demand look\r
+       return 1;\r
+}\r
+\r
+/* check to see if the current input symbol matches any token in a set.\r
+ * During NON demand lookahead mode, dirty will always be 0 and\r
+ * hence the extra code for consuming tokens in _match is never\r
+ * executed; the same routine can be used for both modes.\r
+ */\r
+int ANTLRParser::\r
+_setmatch(SetWordType *tset, ANTLRChar **MissText,\r
+          ANTLRTokenType *MissTok, _ANTLRTokenPtr *BadTok,\r
+          SetWordType **MissSet, SetWordType *tokclassErrset)\r
+{\r
+       if ( dirty==LLk ) {\r
+               consume();\r
+       }\r
+       if ( !set_el(LA(1), tset) ) {\r
+               *MissText=NULL;                                                                         /* MR23 */\r
+               *MissTok=(ANTLRTokenType) 0;                                            /* MR23 */\r
+               *BadTok=LT(1);                                                                          /* MR23 */\r
+               *MissSet=tokclassErrset;                                                        /* MR23 */\r
+               return 0;\r
+       }\r
+       dirty++;\r
+       labase = (labase+1)&(LLk-1);    // labase maintained even if !demand look\r
+       return 1;\r
+}\r
+\r
+int ANTLRParser::\r
+_setmatch_wsig(SetWordType *tset)\r
+{\r
+       if ( dirty==LLk ) {\r
+               consume();\r
+       }\r
+       if ( !set_el(LA(1), tset) ) return 0;\r
+       dirty++;\r
+       labase = (labase+1)&(LLk-1);    // labase maintained even if !demand look\r
+       return 1;\r
+}\r
+\r
+                   /* Exception handling routines */\r
+//\r
+//  7-Apr-97 133MR1\r
+//          Change suggested by Eli Sternheim (eli@interhdl.com)\r
+//\r
+void ANTLRParser::\r
+consumeUntil(SetWordType *st)\r
+{\r
+       ANTLRTokenType          tmp;                                                            // MR1\r
+       const                   int Eof=1;                                          // MR1\r
+       while ( !set_el( (tmp=LA(1)), st) && tmp!=Eof) { consume(); }       // MR1\r
+}\r
+\r
+//\r
+//  7-Apr-97 133MR1\r
+//          Change suggested by Eli Sternheim (eli@interhdl.com)\r
+//\r
+void ANTLRParser::\r
+consumeUntilToken(int t)\r
+{\r
+       int     tmp;                                                            // MR1\r
+       const   int Eof=1;                                                  // MR1\r
+       while ( (tmp=LA(1)) !=t && tmp!=Eof) { consume(); }                 // MR1\r
+}\r
+\r
+\r
+                        /* Old error stuff */\r
+\r
+void ANTLRParser::\r
+resynch(SetWordType *wd,SetWordType mask)\r
+{\r
+\r
+/* MR8              S.Bochnak@microtool.com.pl                          */\r
+/* MR8              Change file scope static "consumed" to instance var */\r
+\r
+       /* if you enter here without having consumed a token from last resynch\r
+        * force a token consumption.\r
+        */\r
+/* MR8 */      if ( !resynchConsumed ) {consume(); resynchConsumed=1; return;}\r
+\r
+       /* if current token is in resynch set, we've got what we wanted */\r
+\r
+/* MR8 */      if ( wd[LA(1)]&mask || LA(1) == eofToken ) {resynchConsumed=0; return;}\r
+       \r
+       /* scan until we find something in the resynch set */\r
+\r
+               while ( !(wd[LA(1)]&mask) && LA(1) != eofToken ) {consume();}\r
+\r
+/* MR8 */      resynchConsumed=1;\r
+}\r
+\r
+/* standard error reporting function that assumes DLG-based scanners;\r
+ * you should redefine in subclass to change it or if you use your\r
+ * own scanner.\r
+ */\r
+\r
+/* MR23 THM There appears to be a parameter "badText" passed to syn()\r
+            which is not present in the parameter list.  This may be\r
+            because in C mode there is no attribute function which\r
+            returns the text, so the text representation of the token\r
+            must be passed explicitly.  I think.\r
+*/\r
+           \r
+void ANTLRParser::\r
+syn(_ANTLRTokenPtr /*tok MR23*/, ANTLRChar *egroup, SetWordType *eset,\r
+       ANTLRTokenType etok, int k)\r
+{\r
+       int line;\r
+\r
+       line = LT(1)->getLine();\r
+\r
+    syntaxErrCount++;                                   /* MR11 */\r
+\r
+    /* MR23  If the token is not an EOF token, then use the ->getText() value.\r
+\r
+             If the token is the EOF token the text returned by ->getText() \r
+             may be garbage.  If the text from the token table is "@" use\r
+             "<eof>" instead, because end-users don't know what "@" means.\r
+             If the text is not "@" then use that text, which must have been\r
+             supplied by the grammar writer.\r
+     */\r
+       const char * errorAt = LT(1)->getText();\r
+       if (LA(1) == eofToken) {\r
+         errorAt = parserTokenName(LA(1));\r
+         if (errorAt[0] == '@') errorAt = "<eof>";\r
+       }\r
+       /* MR23 */ printMessage(stderr, "line %d: syntax error at \"%s\"",\r
+                                       line, errorAt);\r
+       if ( !etok && !eset ) {/* MR23 */ printMessage(stderr, "\n"); return;}\r
+       if ( k==1 ) /* MR23 */ printMessage(stderr, " missing");\r
+       else\r
+       {\r
+               /* MR23 */ printMessage(stderr, "; \"%s\" not", LT(k)->getText()); // MR23 use LT(k) since k>1\r
+               if ( set_deg(eset)>1 ) /* MR23 */ printMessage(stderr, " in");\r
+       }\r
+       if ( set_deg(eset)>0 ) edecode(eset);\r
+       else /* MR23 */ printMessage(stderr, " %s", token_tbl[etok]);\r
+       if ( strlen(egroup) > 0 ) /* MR23 */ printMessage(stderr, " in %s", egroup);\r
+       /* MR23 */ printMessage(stderr, "\n");\r
+}\r
+\r
+/* is b an element of set p? */\r
+int ANTLRParser::\r
+set_el(ANTLRTokenType b, SetWordType *p)\r
+{\r
+       return( p[DIVWORD(b)] & bitmask[MODWORD(b)] );\r
+}\r
+\r
+int ANTLRParser::\r
+set_deg(SetWordType *a)\r
+{\r
+       /* Fast compute degree of a set... the number\r
+          of elements present in the set.  Assumes\r
+          that all word bits are used in the set\r
+       */\r
+       register SetWordType *p = a;\r
+       register SetWordType *endp = &(a[bsetsize]);\r
+       register int degree = 0;\r
+\r
+       if ( a == NULL ) return 0;\r
+       while ( p < endp )\r
+       {\r
+               register SetWordType t = *p;\r
+               register SetWordType *b = &(bitmask[0]);\r
+               do {\r
+                       if (t & *b) ++degree;\r
+               } while (++b < &(bitmask[sizeof(SetWordType)*8]));\r
+               p++;\r
+       }\r
+\r
+       return(degree);\r
+}\r
+\r
+void ANTLRParser::\r
+edecode(SetWordType *a)\r
+{\r
+       register SetWordType *p = a;\r
+       register SetWordType *endp = &(p[bsetsize]);\r
+       register unsigned e = 0;\r
+\r
+       if ( set_deg(a)>1 ) /* MR23 */ printMessage(stderr, " {");\r
+       do {\r
+               register SetWordType t = *p;\r
+               register SetWordType *b = &(bitmask[0]);\r
+               do {\r
+                       if ( t & *b ) /* MR23 */ printMessage(stderr, " %s", token_tbl[e]);\r
+                       e++;\r
+               } while (++b < &(bitmask[sizeof(SetWordType)*8]));\r
+       } while (++p < endp);\r
+       if ( set_deg(a)>1 ) /* MR23 */ printMessage(stderr, " }");\r
+}\r
+\r
+/* input looks like:\r
+ *      zzFAIL(k, e1, e2, ...,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk)\r
+ * where the zzMiss stuff is set here to the token that did not match\r
+ * (and which set wasn't it a member of).\r
+ */\r
+\r
+// MR9 29-Sep-97    Stan Bochnak (S.Bochnak@microTool.com.pl)\r
+// MR9              Original fix to static allocated text didn't\r
+// MR9                work because a pointer to it was passed back\r
+// MR9                to caller.  Replace with instance variable.\r
+\r
+const int   SETWORDCOUNT=20;\r
+\r
+void\r
+ANTLRParser::FAIL(int k, ...)\r
+{\r
+//\r
+//  MR1 10-Apr-97      \r
+//\r
+\r
+    if (zzFAILtext == NULL) zzFAILtext=new char [1000];          // MR9\r
+    SetWordType **f=new SetWordType *[SETWORDCOUNT];             // MR1 // MR9\r
+    SetWordType **miss_set;\r
+    ANTLRChar **miss_text;\r
+    _ANTLRTokenPtr *bad_tok;\r
+    ANTLRChar **bad_text;\r
+//\r
+//  7-Apr-97 133MR1\r
+//             err_k is passed as a "int *", not "unsigned *"\r
+//\r
+    int        *err_k;                                                         // MR1\r
+    int i;\r
+    va_list ap;\r
+\r
+    va_start(ap, k);\r
+\r
+    zzFAILtext[0] = '\0';\r
+       if ( k > SETWORDCOUNT ) panic("FAIL: overflowed buffer");\r
+    for (i=1; i<=k; i++)    /* collect all lookahead sets */\r
+    {\r
+        f[i-1] = va_arg(ap, SetWordType *);\r
+    }\r
+    for (i=1; i<=k; i++)    /* look for offending token */\r
+    {\r
+        if ( i>1 ) strcat(zzFAILtext, " ");\r
+        strcat(zzFAILtext, LT(i)->getText());\r
+        if ( !set_el(LA(i), f[i-1]) ) break;\r
+    }\r
+    miss_set = va_arg(ap, SetWordType **);\r
+    miss_text = va_arg(ap, ANTLRChar **);\r
+    bad_tok = va_arg(ap, _ANTLRTokenPtr *);\r
+    bad_text = va_arg(ap, ANTLRChar **);\r
+    err_k = va_arg(ap, int *);                                                         // MR1\r
+    if ( i>k )\r
+    {\r
+        /* bad; lookahead is permutation that cannot be matched,\r
+         * but, the ith token of lookahead is valid at the ith position\r
+         * (The old LL sub 1 (k) versus LL(k) parsing technique)\r
+         */\r
+        *miss_set = NULL;\r
+        *miss_text = LT(1)->getText();\r
+        *bad_tok = LT(1);\r
+        *bad_text = (*bad_tok)->getText();\r
+        *err_k = k;\r
+//\r
+//  MR4 20-May-97      erroneously deleted contents of f[]\r
+//  MR4                                reported by Bruce Guenter (bruceg@qcc.sk.ca)\r
+//  MR1 10-Apr-97      release temporary storage\r
+//\r
+      delete [] f;                                                      // MR1\r
+      return;                                                           // MR1\r
+    }\r
+/*  MR23 printMessage(stderr, "%s not in %dth set\n", zztokens[LA(i)], i);*/\r
+    *miss_set = f[i-1];\r
+    *miss_text = zzFAILtext;\r
+    *bad_tok = LT(i);\r
+    *bad_text = (*bad_tok)->getText();\r
+    if ( i==1 ) *err_k = 1;\r
+    else *err_k = k;\r
+//\r
+//  MR4 20-May-97      erroneously deleted contents of f[]\r
+//  MR4                              reported by Bruce Guenter (bruceg@qcc.sk.ca)\r
+//  MR1 10-Apr-97      release temporary storage\r
+//\r
+    delete [] f;                                                        // MR1\r
+    return;                                                             // MR1\r
+}\r
+\r
+int ANTLRParser::\r
+_match_wdfltsig(ANTLRTokenType tokenWanted, SetWordType *whatFollows)\r
+{\r
+       if ( dirty==LLk ) consume();\r
+\r
+       if ( LA(1)!=tokenWanted )\r
+       {\r
+        syntaxErrCount++;                                   /* MR11 */\r
+               /* MR23 */ printMessage(stderr,\r
+                               "line %d: syntax error at \"%s\" missing %s\n",\r
+                               LT(1)->getLine(),\r
+                               (LA(1)==eofToken && LT(1)->getText()[0] == '@')?"<eof>":LT(1)->getText(), /* MR21a */\r
+                               token_tbl[tokenWanted]);\r
+               consumeUntil( whatFollows );\r
+               return 0;\r
+       }\r
+       else {\r
+               dirty++;\r
+               labase = (labase+1)&(LLk-1); // labase maintained even if !demand look\r
+/*             if ( !demand_look ) consume(); */\r
+               return 1;\r
+       }\r
+}\r
+\r
+\r
+int ANTLRParser::\r
+_setmatch_wdfltsig(SetWordType *tokensWanted,\r
+                                       ANTLRTokenType tokenTypeOfSet,\r
+                                       SetWordType *whatFollows)\r
+{\r
+       if ( dirty==LLk ) consume();\r
+       if ( !set_el(LA(1), tokensWanted) )\r
+       {\r
+        syntaxErrCount++;                                   /* MR11 */\r
+               /* MR23 */ printMessage(stderr,\r
+                               "line %d: syntax error at \"%s\" missing %s\n",\r
+                               LT(1)->getLine(),\r
+                               (LA(1)==eofToken && LT(1)->getText()[0] == '@')?"<eof>":LT(1)->getText(), /* MR21a */\r
+                               token_tbl[tokenTypeOfSet]);\r
+               consumeUntil( whatFollows );\r
+               return 0;\r
+       }\r
+       else {\r
+               dirty++;\r
+               labase = (labase+1)&(LLk-1); // labase maintained even if !demand look\r
+/*             if ( !demand_look ) consume(); */\r
+               return 1;\r
+       }\r
+}\r
+\r
+char *ANTLRParser::\r
+eMsgd(char *err,int d)\r
+{\r
+       sprintf(eMsgBuffer, err, d);    // dangerous, but I don't care\r
+       return eMsgBuffer;\r
+}\r
+\r
+char *ANTLRParser::\r
+eMsg(char *err, char *s)\r
+{\r
+       sprintf(eMsgBuffer, err, s);\r
+       return eMsgBuffer;\r
+}\r
+\r
+char *ANTLRParser::\r
+eMsg2(char *err,char *s, char *t)\r
+{\r
+       sprintf(eMsgBuffer, err, s, t);\r
+       return eMsgBuffer;\r
+}\r
+\r
+void ANTLRParser::\r
+panic(const char *msg)  // MR20 const\r
+{\r
+       /* MR23 */ printMessage(stderr, "ANTLR panic: %s\n", msg);\r
+       exit(PCCTS_EXIT_FAILURE);           // MR1\r
+}\r
+\r
+const ANTLRChar *ANTLRParser::          // MR1\r
+parserTokenName(int tok) {              // MR1\r
+       return token_tbl[tok];              // MR1\r
+}                                       // MR1\r
+\r
+void ANTLRParser::traceGuessDone(const ANTLRParserState *state) {\r
+\r
+  int   doIt=0;\r
+\r
+  if (traceCurrentRuleName == NULL) return;\r
+\r
+  if (traceOptionValue <= 0) {\r
+    doIt=0;\r
+  } else if (traceGuessOptionValue <= 0) {\r
+    doIt=0;\r
+  } else {\r
+    doIt=1;\r
+  };\r
+\r
+  if (doIt) {\r
+    /* MR23 */ printMessage(stderr,"guess done - returning to rule %s {\"%s\"} at depth %d",\r
+        state->traceCurrentRuleName,\r
+        LT(1)->getType() == eofToken ? "@" : LT(1)->getText(),\r
+        state->traceDepth);\r
+    if (state->guessing != 0) {\r
+      /* MR23 */ printMessage(stderr," (guess mode continues - an enclosing guess is still active)");\r
+    } else {\r
+      /* MR23 */ printMessage(stderr," (guess mode ends)");\r
+    };\r
+    /* MR23 */ printMessage(stderr,"\n");\r
+  };\r
+}\r
+\r
+void ANTLRParser::traceGuessFail() {\r
+\r
+  int   doIt=0;\r
+\r
+  if (traceCurrentRuleName == NULL) return;     /* MR21 */\r
+\r
+  if (traceOptionValue <= 0) {\r
+    doIt=0;\r
+  } else if (guessing && traceGuessOptionValue <= 0) {\r
+    doIt=0;\r
+  } else {\r
+    doIt=1;\r
+  };\r
+\r
+  if (doIt) {\r
+    /* MR23 */ printMessage(stderr,"guess failed in %s\n",traceCurrentRuleName);\r
+  };\r
+}\r
+\r
+/* traceOption:\r
+     zero value turns off trace\r
+*/\r
+\r
+void ANTLRParser::tracein(const ANTLRChar * rule) {\r
+\r
+  int       doIt=0;\r
+\r
+  traceDepth++;\r
+  traceCurrentRuleName=rule;\r
+\r
+  if (traceOptionValue <= 0) {\r
+    doIt=0;\r
+  } else if (guessing && traceGuessOptionValue <= 0) {\r
+    doIt=0;\r
+  } else {\r
+    doIt=1;\r
+  };\r
+\r
+  if (doIt) {\r
+    /* MR23 */ printMessage(stderr,"enter rule %s {\"%s\"} depth %d",\r
+            rule,\r
+            LT(1)->getType() == eofToken ? "@" : LT(1)->getText(),\r
+            traceDepth);\r
+    if (guessing) /* MR23 */ printMessage(stderr," guessing");\r
+    /* MR23 */ printMessage(stderr,"\n");\r
+  };\r
+  return;\r
+}\r
+\r
+void ANTLRParser::traceout(const ANTLRChar * rule) {\r
+\r
+  int       doIt=0;\r
+\r
+  traceDepth--;\r
+\r
+  if (traceOptionValue <= 0) {\r
+    doIt=0;\r
+  } else if (guessing && traceGuessOptionValue <= 0) {\r
+    doIt=0;\r
+  } else {\r
+    doIt=1;\r
+  };\r
+\r
+  if (doIt) {\r
+    /* MR23 */ printMessage(stderr,"exit rule %s {\"%s\"} depth %d",\r
+            rule,\r
+            LT(1)->getType() == eofToken ? "@" : LT(1)->getText(),\r
+            traceDepth+1);\r
+    if (guessing) /* MR23 */ printMessage(stderr," guessing");\r
+    /* MR23 */ printMessage(stderr,"\n");\r
+  };\r
+}\r
+\r
+int ANTLRParser::traceOption(int delta) {\r
+\r
+    int     prevValue=traceOptionValue;\r
+\r
+    traceOptionValue=traceOptionValue+delta;\r
+\r
+    if (traceCurrentRuleName != NULL) {\r
+      if (prevValue <= 0 && traceOptionValue > 0) {\r
+        /* MR23 */ printMessage(stderr,"trace enabled in rule %s depth %d\n",traceCurrentRuleName,traceDepth);\r
+      };\r
+      if (prevValue > 0 && traceOptionValue <= 0) {\r
+        /* MR23 */ printMessage(stderr,"trace disabled in rule %s depth %d\n",traceCurrentRuleName,traceDepth);\r
+      };\r
+    };\r
+\r
+    return  prevValue;\r
+}\r
+\r
+int ANTLRParser::traceGuessOption(int delta) {\r
+\r
+    int     prevValue=traceGuessOptionValue;\r
+\r
+    traceGuessOptionValue=traceGuessOptionValue+delta;\r
+\r
+    if (traceCurrentRuleName != NULL) {\r
+      if (prevValue <= 0 && traceGuessOptionValue > 0) {\r
+        /* MR23 */ printMessage(stderr,"guess trace enabled in rule %s depth %d\n",traceCurrentRuleName,traceDepth);\r
+      };\r
+      if (prevValue > 0 && traceGuessOptionValue <= 0) {\r
+        /* MR23 */ printMessage(stderr,"guess trace disabled in rule %s depth %d\n",traceCurrentRuleName,traceDepth);\r
+      };\r
+    };\r
+    return prevValue;\r
+}\r
+\r
+// MR19 V.H. Simonis Defer Fetch feature\r
+\r
+void ANTLRParser::undeferFetch()\r
+{\r
+\r
+#ifdef ZZDEFER_FETCH\r
+    if (stillToFetch) {\r
+        for (int stillToFetch_x = 0; stillToFetch_x < stillToFetch; ++stillToFetch_x) {\r
+               NLA = inputTokens->getToken()->getType();\r
+               dirty--;\r
+               lap = (lap+1)&(LLk-1);\r
+        }\r
+        stillToFetch = 0;\r
+    }\r
+#else\r
+    return;\r
+#endif\r
+\r
+}\r
+\r
+int ANTLRParser::isDeferFetchEnabled()\r
+{\r
+#ifdef ZZDEFER_FETCH\r
+    return 1;\r
+#else\r
+    return 0;\r
+#endif\r
+}\r
+\r
+//MR23\r
+int ANTLRParser::printMessage(FILE* pFile, const char* pFormat, ...)\r
+{\r
+       va_list marker;\r
+       va_start( marker, pFormat );\r
+       int iRet = printMessageV(pFile, pFormat, marker);\r
+       va_end( marker );\r
+       return iRet;\r
+}\r
+\r
+int ANTLRParser::printMessageV(FILE* pFile, const char* pFormat, va_list arglist) // MR23\r
+{\r
+       return vfprintf(pFile, pFormat, arglist);\r
+}\r
+\r
+// MR23 Move semantic predicate error handling from macro to virtual function\r
+//\r
+// Called by the zzfailed_pred\r
+\r
+void ANTLRParser::failedSemanticPredicate(const char* predicate)\r
+{\r
+    printMessage(stdout,"line %d: semantic error; failed predicate: '%s'\n",\r
+       LT(1)->getLine(), predicate);\r
+}\r
diff --git a/Tools/CodeTools/Source/Pccts/h/AParser.h b/Tools/CodeTools/Source/Pccts/h/AParser.h
new file mode 100644 (file)
index 0000000..fe405f4
--- /dev/null
@@ -0,0 +1,376 @@
+/* ANTLRParser.h\r
+ *\r
+ * Define the generic ANTLRParser superclass, which is subclassed to\r
+ * define an actual parser.\r
+ *\r
+ * Before entry into this file: ANTLRTokenType must be set.\r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
+ * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
+ * company may do whatever they wish with source code distributed with\r
+ * PCCTS or the code generated by PCCTS, including the incorporation of\r
+ * PCCTS, or its output, into commerical software.\r
+ *\r
+ * We encourage users to develop software with PCCTS.  However, we do ask\r
+ * that credit is given to us for developing PCCTS.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like PCCTS and have developed a nice tool with the\r
+ * output, please mention that you developed it using PCCTS.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * ANTLR 1.33\r
+ * Terence Parr\r
+ * Parr Research Corporation\r
+ * with Purdue University and AHPCRC, University of Minnesota\r
+ * 1989-2000\r
+ */\r
+\r
+#ifndef APARSER_H_GATE\r
+#define APARSER_H_GATE\r
+\r
+#include "pcctscfg.h"\r
+\r
+#include "pccts_stdio.h"\r
+#include "pccts_setjmp.h"\r
+\r
+PCCTS_NAMESPACE_STD\r
+\r
+#include ATOKEN_H\r
+#include ATOKENBUFFER_H\r
+\r
+#ifdef ZZCAN_GUESS\r
+#ifndef ZZINF_LOOK\r
+#define ZZINF_LOOK\r
+#endif\r
+#endif\r
+\r
+\r
+#define NLA                    (token_type[lap&(LLk-1)])/* --> next LA */\r
+\r
+typedef unsigned char SetWordType;\r
+\r
+/* Define external bit set stuff (for SetWordType) */\r
+#define EXT_WORDSIZE   (sizeof(char)*8)\r
+#define EXT_LOGWORDSIZE        3\r
+\r
+           /* s y n t a c t i c  p r e d i c a t e  s t u f f */\r
+\r
+#ifndef zzUSER_GUESS_HOOK\r
+#define zzUSER_GUESS_HOOK(seqFrozen,zzrv)\r
+#endif\r
+\r
+#ifndef zzUSER_GUESS_DONE_HOOK\r
+#define zzUSER_GUESS_DONE_HOOK(seqFrozen)\r
+#endif\r
+\r
+/* MR14 Add zzUSER_GUESS_FAIL_HOOK and related code */\r
+\r
+#define zzUSER_GUESS_FAIL_HOOK_INTERNAL zzUSER_GUESS_FAIL_HOOK(SeqFrozen)\r
+#ifndef zzUSER_GUESS_FAIL_HOOK\r
+#define zzUSER_GUESS_FAIL_HOOK(zzGuessSeq)\r
+#endif\r
+\r
+\r
+typedef struct _zzjmp_buf {\r
+                       jmp_buf state;\r
+               } zzjmp_buf;\r
+\r
+/* these need to be macros not member functions */\r
+#define zzGUESS_BLOCK          ANTLRParserState zzst; int zzrv; int _marker; int zzGuessSeqFrozen;\r
+#define zzNON_GUESS_MODE       if ( !guessing )\r
+#define zzGUESS_FAIL           guess_fail();\r
+\r
+/*  Note:  zzGUESS_DONE does not execute longjmp() */\r
+\r
+#define zzGUESS_DONE           {zzrv=1; inputTokens->rewind(_marker); guess_done(&zzst);zzUSER_GUESS_DONE_HOOK(zzGuessSeqFrozen) }\r
+#define zzGUESS                                saveState(&zzst); \\r
+                                                       guessing = 1; \\r
+                            zzGuessSeqFrozen = ++zzGuessSeq; \\r
+                                                       _marker = inputTokens->mark(); \\r
+                                                       zzrv = setjmp(guess_start.state); \\r
+                            zzUSER_GUESS_HOOK(zzGuessSeqFrozen,zzrv) \\r
+                                                   if ( zzrv ) zzGUESS_DONE\r
+\r
+#define zzTRACEdata     const ANTLRChar *zzTracePrevRuleName = NULL;\r
+\r
+#ifndef zzTRACEIN\r
+#define zzTRACEIN(r)   zzTracePrevRuleName=traceCurrentRuleName;tracein(r);\r
+#endif\r
+#ifndef zzTRACEOUT\r
+#define zzTRACEOUT(r)  traceout(r);traceCurrentRuleName=zzTracePrevRuleName;\r
+#endif\r
+\r
+                  /* a n t l r  p a r s e r  d e f */\r
+\r
+struct ANTLRParserState {\r
+       /* class variables */\r
+       zzjmp_buf guess_start;\r
+       int guessing;\r
+\r
+       int inf_labase;\r
+       int inf_last;\r
+\r
+       int dirty;\r
+\r
+    int             traceOptionValue;       // MR10\r
+    int             traceGuessOptionValue;  // MR10\r
+    const ANTLRChar *traceCurrentRuleName;  // MR10\r
+    int             traceDepth;             // MR10\r
+\r
+};\r
+\r
+/* notes:\r
+ *\r
+ * multiple inheritance is a cool way to include what stuff is needed\r
+ * in this structure (like guess stuff).  however, i'm not convinced that\r
+ * multiple inheritance works correctly on all platforms.  not that\r
+ * much space is used--just include all possibly useful members.\r
+ *\r
+ * the class should also be a template with arguments for the lookahead\r
+ * depth and so on.  that way, more than one parser can be defined (as\r
+ * each will probably have different lookahead requirements).  however,\r
+ * am i sure that templates work?  no, i'm not sure.\r
+ *\r
+ * no attributes are maintained and, hence, the 'asp' variable is not\r
+ * needed.  $i can still be referenced, but it refers to the token\r
+ * associated with that rule element.  question: where are the token's\r
+ * stored if not on the software stack?  in local variables created\r
+ * and assigned to by antlr.\r
+ */\r
+class ANTLRParser {\r
+protected:\r
+       /* class variables */\r
+       static SetWordType bitmask[sizeof(SetWordType)*8];\r
+       static char eMsgBuffer[500];\r
+\r
+protected:\r
+       int LLk;                                        // number of lookahead symbols (old LL_K)\r
+       int demand_look;\r
+       ANTLRTokenType eofToken;                        // when do I stop during resynch()s\r
+       int bsetsize;                                   // size of bitsets created by ANTLR in\r
+                                                                       // units of SetWordType\r
+\r
+       ANTLRTokenBuffer *inputTokens;  //place to get input tokens\r
+\r
+       zzjmp_buf guess_start;          // where to jump back to upon failure\r
+       int guessing;                           // if guessing (using (...)? predicate)\r
+\r
+       // infinite lookahead stuff\r
+       int can_use_inf_look;           // set by subclass (generated by ANTLR)\r
+       int inf_lap;\r
+       int inf_labase;\r
+       int inf_last;\r
+       int *_inf_line;\r
+\r
+       const ANTLRChar **token_tbl; // pointer to table of token type strings MR20 const\r
+\r
+       int dirty;                                      // used during demand lookahead\r
+\r
+       ANTLRTokenType *token_type;             // fast reference cache of token.getType()\r
+//     ANTLRLightweightToken **token;  // the token with all its attributes\r
+       int lap;\r
+       int labase;\r
+#ifdef ZZDEFER_FETCH\r
+       int stillToFetch;                               // MR19 V.H. Simonis\r
+#endif\r
+\r
+private:\r
+       void fill_inf_look();\r
+\r
+protected:\r
+       virtual void guess_fail() {                         // MR9 27-Sep-97 make virtual\r
+        traceGuessFail();                               // MR10\r
+        longjmp(guess_start.state, 1); }                // MR9\r
+       virtual void guess_done(ANTLRParserState *st) {     // MR9 27-Sep-97 make virtual\r
+         restoreState(st); }                            // MR9\r
+       virtual int guess(ANTLRParserState *);              // MR9 27-Sep-97 make virtual\r
+       void look(int);\r
+    int _match(ANTLRTokenType, ANTLRChar **, ANTLRTokenType *,\r
+                          _ANTLRTokenPtr *, SetWordType **);\r
+    int _setmatch(SetWordType *, ANTLRChar **, ANTLRTokenType *,\r
+                          _ANTLRTokenPtr *, SetWordType **,\r
+                          SetWordType * tokclassErrset /* MR23 */);\r
+    int _match_wsig(ANTLRTokenType);\r
+    int _setmatch_wsig(SetWordType *);\r
+    virtual void consume();\r
+    virtual void resynch(SetWordType *wd,SetWordType mask); // MR21\r
+       void prime_lookahead();\r
+       virtual void tracein(const ANTLRChar *r);              // MR10\r
+       virtual void traceout(const ANTLRChar *r);             // MR10\r
+       static unsigned MODWORD(unsigned x) {return x & (EXT_WORDSIZE-1);}      // x % EXT_WORDSIZE // MR9\r
+       static unsigned DIVWORD(unsigned x) {return x >> EXT_LOGWORDSIZE;}      // x / EXT_WORDSIZE // MR9\r
+       int set_deg(SetWordType *);\r
+       int set_el(ANTLRTokenType, SetWordType *);\r
+       virtual void edecode(SetWordType *);                            // MR1\r
+       virtual void FAIL(int k, ...);                                      // MR1\r
+    int                 traceOptionValue;                           // MR10\r
+    int                 traceGuessOptionValue;                      // MR10\r
+    const ANTLRChar     *traceCurrentRuleName;                      // MR10\r
+    int                 traceDepth;                                 // MR10\r
+    void                traceReset();                               // MR10\r
+    virtual void        traceGuessFail();                           // MR10\r
+    virtual void        traceGuessDone(const ANTLRParserState *);   // MR10\r
+    int                 zzGuessSeq;                                 // MR10\r
+\r
+public:\r
+       ANTLRParser(ANTLRTokenBuffer *,\r
+                               int k=1,\r
+                               int use_inf_look=0,\r
+                               int demand_look=0,\r
+                               int bsetsize=1);\r
+       virtual ~ANTLRParser();\r
+\r
+       virtual void init();\r
+       \r
+       ANTLRTokenType LA(int i)\r
+       {\r
+//\r
+//  MR14 demand look will always be 0 for C++ mode\r
+//\r
+////   return demand_look ? token_type[(labase+(i)-1)&(LLk-1)] :\r
+////                                           token_type[(lap+(i)-1)&(LLk-1)];\r
+\r
+// MR19 V.H. Simonis Defer fetch feature\r
+\r
+#ifdef ZZDEFER_FETCH\r
+      undeferFetch();\r
+#endif\r
+         return token_type[(lap+(i)-1)&(LLk-1)];\r
+       }\r
+       _ANTLRTokenPtr LT(int i);\r
+\r
+       void setEofToken(ANTLRTokenType t)      { eofToken = t; }\r
+       ANTLRTokenType getEofToken() const  { return eofToken; }    // MR14\r
+\r
+       void noGarbageCollectTokens()   { inputTokens->noGarbageCollectTokens(); }\r
+       void garbageCollectTokens()             { inputTokens->garbageCollectTokens(); }\r
+\r
+    virtual void syn(_ANTLRTokenPtr tok, ANTLRChar *egroup,\r
+                                        SetWordType *eset, ANTLRTokenType etok, int k);\r
+       virtual void saveState(ANTLRParserState *);     // MR9 27-Sep-97 make virtual\r
+       virtual void restoreState(ANTLRParserState *);  // MR9 27-Sep-97 make virtual\r
+\r
+       virtual void panic(const char *msg); // MR20 const\r
+\r
+       static char *eMsgd(char *,int);\r
+       static char *eMsg(char *,char *);\r
+       static char *eMsg2(char *,char *,char *);\r
+\r
+       virtual int printMessage(FILE* pFile, const char* pFormat, ...); // MR23\r
+       virtual int printMessageV(FILE* pFile, const char* pFormat, va_list arglist); // MR23\r
+\r
+       void consumeUntil(SetWordType *st);\r
+       void consumeUntilToken(int t);\r
+\r
+       virtual int _setmatch_wdfltsig(SetWordType *tokensWanted,\r
+                                        ANTLRTokenType tokenTypeOfSet,\r
+                                        SetWordType *whatFollows);\r
+       virtual int _match_wdfltsig(ANTLRTokenType tokenWanted,\r
+                                        SetWordType *whatFollows);\r
+       \r
+       const ANTLRChar * parserTokenName(int tok);                     // MR1\r
+\r
+    int                 traceOptionValueDefault;        // MR11\r
+    int                 traceOption(int delta);         // MR11\r
+    int                 traceGuessOption(int delta);    // MR11\r
+\r
+//  MR8  5-Aug-97   S.Bochnak@microtool.com.pl\r
+//  MR8             Move resynch static local variable\r
+//  MR8               to class instance\r
+\r
+    int                 syntaxErrCount;                      // MR12\r
+    ANTLRTokenStream   *getLexer() const {                   // MR12\r
+      return inputTokens ? inputTokens->getLexer() : 0; }    // MR12\r
+protected:                                              // MR8\r
+    int     resynchConsumed;                            // MR8\r
+    char    *zzFAILtext; // workarea required by zzFAIL // MR9\r
+    void    undeferFetch();                             // MR19 V.H. Simonis\r
+    int     isDeferFetchEnabled();                      // MR19 V.H. Simonis\r
+    virtual void failedSemanticPredicate(const char* predicate); /* MR23 */\r
+};\r
+\r
+#define zzmatch(_t)                                                    \\r
+       if ( !_match((ANTLRTokenType)_t, &zzMissText, &zzMissTok, \\r
+                                (_ANTLRTokenPtr *) &zzBadTok, &zzMissSet) ) goto fail;\r
+\r
+#define zzmatch_wsig(_t,handler)                                               \\r
+       if ( !_match_wsig((ANTLRTokenType)_t) ) if ( guessing ) zzGUESS_FAIL else {_signal=MismatchedToken; goto handler;}\r
+\r
+#define zzsetmatch(_ts,_tokclassErrset)                                                        \\r
+       if ( !_setmatch(_ts, &zzMissText, &zzMissTok, \\r
+                                (_ANTLRTokenPtr *) &zzBadTok, &zzMissSet, _tokclassErrset) ) goto fail;\r
+\r
+#define zzsetmatch_wsig(_ts, handler)                          \\r
+       if ( !_setmatch_wsig(_ts) ) if ( guessing ) zzGUESS_FAIL else {_signal=MismatchedToken; goto handler;}\r
+\r
+/* For the dflt signal matchers, a FALSE indicates that an error occurred\r
+ * just like the other matchers, but in this case, the routine has already\r
+ * recovered--we do NOT want to consume another token.  However, when\r
+ * the match was successful, we do want to consume hence _signal=0 so that\r
+ * a token is consumed by the "if (!_signal) consume(); _signal=NoSignal;"\r
+ * preamble.\r
+ */\r
+#define zzsetmatch_wdfltsig(tokensWanted, tokenTypeOfSet, whatFollows) \\r
+       if ( !_setmatch_wdfltsig(tokensWanted, tokenTypeOfSet, whatFollows) ) \\r
+               _signal = MismatchedToken;\r
+\r
+#define zzmatch_wdfltsig(tokenWanted, whatFollows) \\r
+       if ( !_match_wdfltsig(tokenWanted, whatFollows) ) _signal = MismatchedToken;\r
+\r
+\r
+//  MR1  10-Apr-97     zzfailed_pred() macro does not backtrack in guess mode.\r
+//  MR1                            Identification and correction due to J. Lilley\r
+//\r
+//  MR23            Call virtual method to report error.\r
+//  MR23            Provide more control over failed predicate action\r
+//                  without any need for user to worry about guessing internals.\r
+\r
+#ifndef zzfailed_pred\r
+#define zzfailed_pred(_p,_hasuseraction,_useraction) \\r
+  if (guessing) { \\r
+    zzGUESS_FAIL; \\r
+  } else { \\r
+    zzfailed_pred_action(_p,_hasuseraction,_useraction) \\r
+  }\r
+#endif\r
+\r
+//  MR23            Provide more control over failed predicate action\r
+//                  without any need for user to worry about guessing internals.\r
+//                  _hasuseraction == 0 => no user specified error action\r
+//                  _hasuseraction == 1 => user specified error action\r
+\r
+#ifndef zzfailed_pred_action\r
+#define zzfailed_pred_action(_p,_hasuseraction,_useraction) \\r
+    if (_hasuseraction) { _useraction } else { failedSemanticPredicate(_p); }\r
+#endif\r
+\r
+#define zzRULE \\r
+               SetWordType *zzMissSet=NULL; ANTLRTokenType zzMissTok=(ANTLRTokenType)0;        \\r
+               _ANTLRTokenPtr zzBadTok=NULL; ANTLRChar *zzBadText=(ANTLRChar *)"";     \\r
+               int zzErrk=1,zzpf=0; \\r
+        zzTRACEdata \\r
+               ANTLRChar *zzMissText=(ANTLRChar *)"";\r
+\r
+#endif\r
+\r
+        /* S t a n d a r d  E x c e p t i o n  S i g n a l s */\r
+\r
+#define NoSignal                       0\r
+#define MismatchedToken                1\r
+#define NoViableAlt                    2\r
+#define NoSemViableAlt         3\r
+\r
+/* MR7  Allow more control over signalling                                  */\r
+/*        by adding "Unwind" and "SetSignal"                                */\r
+\r
+#define Unwind              4\r
+#define setSignal(newValue) *_retsignal=_signal=(newValue)\r
+#define suppressSignal       *_retsignal=_signal=0\r
+#define exportSignal        *_retsignal=_signal\r
diff --git a/Tools/CodeTools/Source/Pccts/h/ASTBase.cpp b/Tools/CodeTools/Source/Pccts/h/ASTBase.cpp
new file mode 100644 (file)
index 0000000..a94f080
--- /dev/null
@@ -0,0 +1,256 @@
+/* Abstract syntax tree manipulation functions\r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
+ * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
+ * company may do whatever they wish with source code distributed with\r
+ * PCCTS or the code generated by PCCTS, including the incorporation of\r
+ * PCCTS, or its output, into commerical software.\r
+ *\r
+ * We encourage users to develop software with PCCTS.  However, we do ask\r
+ * that credit is given to us for developing PCCTS.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like PCCTS and have developed a nice tool with the\r
+ * output, please mention that you developed it using PCCTS.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * ANTLR 1.33\r
+ * Terence Parr\r
+ * Parr Research Corporation\r
+ * with Purdue University and AHPCRC, University of Minnesota\r
+ * 1989-2000\r
+ */\r
+\r
+#include "pcctscfg.h"\r
+\r
+#include "pccts_stdio.h"\r
+#include "pccts_stdarg.h"\r
+\r
+PCCTS_NAMESPACE_STD\r
+\r
+#define ANTLR_SUPPORT_CODE\r
+\r
+#include "ASTBase.h"\r
+\r
+/* ensure that tree manipulation variables are current after a rule\r
+ * reference\r
+ */\r
+void\r
+ASTBase::link(ASTBase **_root, ASTBase **_sibling, ASTBase **_tail)\r
+{\r
+       if ( *_sibling == NULL ) return;\r
+       if ( *_root == NULL ) *_root = *_sibling;\r
+       else if ( *_root != *_sibling ) (*_root)->_down = *_sibling;\r
+       if ( *_tail==NULL ) *_tail = *_sibling;\r
+       while ( (*_tail)->_right != NULL ) *_tail = (*_tail)->_right;\r
+}\r
+\r
+/* add a child node to the current sibling list */\r
+void\r
+ASTBase::subchild(ASTBase **_root, ASTBase **_sibling, ASTBase **_tail)\r
+{\r
+       if ( *_tail != NULL ) (*_tail)->_right = this;\r
+       else {\r
+               *_sibling = this;\r
+               if ( *_root != NULL ) (*_root)->_down = *_sibling;\r
+       }\r
+       *_tail = this;\r
+       if ( *_root == NULL ) *_root = *_sibling;\r
+}\r
+\r
+/* make a new AST node.  Make the newly-created\r
+ * node the root for the current sibling list.  If a root node already\r
+ * exists, make the newly-created node the root of the current root.\r
+ */\r
+void\r
+ASTBase::subroot(ASTBase **_root, ASTBase **_sibling, ASTBase **_tail)\r
+{\r
+       if ( *_root != NULL )\r
+               if ( (*_root)->_down == *_sibling ) *_sibling = *_tail = *_root;\r
+       *_root = this;\r
+       (*_root)->_down = *_sibling;\r
+}\r
+\r
+/* Apply preorder_action(), etc.. to root then each sibling */\r
+//\r
+//  7-Apr-97 133MR1\r
+//     Fix suggested by Ron House (house@helios.usq.edu.au)\r
+//\r
+void\r
+ASTBase::preorder(void* pData /*= NULL*/ /* MR23 */)\r
+{\r
+       ASTBase *tree = this;\r
+\r
+       while ( tree!= NULL )\r
+       {\r
+               if ( tree->_down != NULL ) {\r
+                       tree->preorder_before_action(pData);            // MR1  \r
+               };\r
+               tree->preorder_action(pData);\r
+               if ( tree->_down!=NULL )\r
+               {\r
+                       tree->_down->preorder(pData);\r
+                       tree->preorder_after_action(pData);                     // MR1\r
+               }\r
+               tree = tree->_right;\r
+       }\r
+}\r
+\r
+/* free all AST nodes in tree; apply func to each before freeing */\r
+void\r
+ASTBase::destroy()\r
+{\r
+   ASTBase* tree = this;\r
+   while (tree) {\r
+      if (tree->_down) tree->_down->destroy();\r
+\r
+      ASTBase* cur = tree;\r
+      tree = tree->_right;\r
+      delete cur;\r
+   }\r
+}\r
+\r
+/* build a tree (root child1 child2 ... NULL)\r
+ * If root is NULL, simply make the children siblings and return ptr\r
+ * to 1st sibling (child1).  If root is not single node, return NULL.\r
+ *\r
+ * Siblings that are actually siblins lists themselves are handled\r
+ * correctly.  For example #( NULL, #( NULL, A, B, C), D) results\r
+ * in the tree ( NULL A B C D ).\r
+ *\r
+ * Requires at least two parameters with the last one being NULL.  If\r
+ * both are NULL, return NULL.\r
+ */\r
+ASTBase *\r
+ASTBase::tmake(ASTBase *root, ...)\r
+{\r
+       va_list ap;\r
+       register ASTBase *child, *sibling=NULL, *tail=NULL /*MR23*/, *w;\r
+\r
+       va_start(ap, root);\r
+\r
+       if ( root != NULL )\r
+               if ( root->_down != NULL ) {  \r
+            root->reportOverwriteOfDownPointer();  /* MR21 Report problem which almost always an error */\r
+            return NULL;\r
+        }\r
+       child = va_arg(ap, ASTBase *);\r
+       while ( child != NULL )\r
+       {\r
+               for (w=child; w->_right!=NULL; w=w->_right) {;} /* find end of child */\r
+               if ( sibling == NULL ) {sibling = child; tail = w;}\r
+               else {tail->_right = child; tail = w;}\r
+               child = va_arg(ap, ASTBase *);\r
+       }\r
+       if ( root==NULL ) root = sibling;\r
+       else root->_down = sibling;\r
+       va_end(ap);\r
+       return root;\r
+}\r
+\r
+#ifndef PCCTS_NOT_USING_SOR\r
+\r
+/* tree duplicate */\r
+// forgot to check for NULL this (TJP July 23,1995)\r
+ASTBase *\r
+ASTBase::dup()\r
+{\r
+       ASTBase *u, *t=this;\r
+       \r
+       if ( t == NULL ) return NULL;\r
+/*\r
+       u = new ASTBase;\r
+       *u = *t;\r
+*/\r
+       u = (ASTBase *)this->shallowCopy();\r
+       if ( t->_right!=NULL ) u->_right = t->_right->dup();\r
+       else u->_right = NULL;\r
+       if ( t->_down!=NULL ) u->_down = t->_down->dup();\r
+       else u->_down = NULL;\r
+       return u;\r
+}\r
+#endif\r
+\r
+//\r
+//  7-Apr-97 133MR1\r
+//          Fix suggested by Asgeir Olafsson (olafsson@cstar.ac.com)\r
+//\r
+/* tree duplicate */\r
+\r
+#ifndef PCCTS_NOT_USING_SOR\r
+\r
+ASTBase *\r
+ASTDoublyLinkedBase::dup()\r
+{\r
+       ASTDoublyLinkedBase *u, *t=this;\r
+       \r
+       if ( t == NULL ) return NULL;\r
+       u = (ASTDoublyLinkedBase *)this->shallowCopy();\r
+       u->_up = NULL;          /* set by calling invocation */\r
+       u->_left = NULL;\r
+       if (t->_right!=NULL) {                                          // MR1\r
+          u->_right=t->_right->dup();                                  // MR1\r
+         ((ASTDoublyLinkedBase *)u->_right)->_left = u;                // MR1\r
+        } else {                                                       // MR1\r
+         u->_right = NULL;                                             // MR1\r
+        };                                                             // MR1\r
+       if (t->_down!=NULL) {                                           // MR1\r
+         u->_down = t->_down->dup();                                   // MR1\r
+          ((ASTDoublyLinkedBase *)u->_down)->_up = u;                  // MR1\r
+        } else {                                                       // MR1\r
+         u->_down = NULL;                                              // MR1\r
+        };                                                             // MR1\r
+       return u;\r
+}\r
+\r
+#endif\r
+\r
+/*\r
+ * Set the 'up', and 'left' pointers of all nodes in 't'.\r
+ * Initial call is double_link(your_tree, NULL, NULL).\r
+ */\r
+void\r
+ASTDoublyLinkedBase::double_link(ASTBase *left, ASTBase *up)\r
+{\r
+    ASTDoublyLinkedBase *t = this;\r
+\r
+    t->_left = (ASTDoublyLinkedBase *) left;\r
+    t->_up = (ASTDoublyLinkedBase *) up;\r
+    if (t->_down != NULL)\r
+               ((ASTDoublyLinkedBase *)t->_down)->double_link(NULL, t);\r
+    if (t->_right != NULL)\r
+               ((ASTDoublyLinkedBase *)t->_right)->double_link(t, up);\r
+}\r
+\r
+// MR21 ASTBase::reportOverwriteOfDownPointer\r
+\r
+void ASTBase::reportOverwriteOfDownPointer()\r
+{\r
+    panic("Attempt to overwrite down pointer in ASTBase::tmake");\r
+}\r
+\r
+// MR21 ASTBase::panic\r
+\r
+void ASTBase::panic(const char *msg)\r
+{\r
+       /* MR23 */ printMessage(stderr,"ASTBase panic: %s\n", msg);\r
+       exit(PCCTS_EXIT_FAILURE);\r
+}\r
+\r
+#ifdef PCCTS_NOT_USING_SOR\r
+//MR23\r
+int ASTBase::printMessage(FILE* pFile, const char* pFormat, ...)\r
+{\r
+       va_list marker;\r
+       va_start( marker, pFormat );\r
+       int iRet = vfprintf(pFile, pFormat, marker);\r
+       va_end( marker );\r
+       return iRet;\r
+}\r
+#endif\r
diff --git a/Tools/CodeTools/Source/Pccts/h/ASTBase.h b/Tools/CodeTools/Source/Pccts/h/ASTBase.h
new file mode 100644 (file)
index 0000000..912f4b8
--- /dev/null
@@ -0,0 +1,122 @@
+/* Abstract syntax tree\r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
+ * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
+ * company may do whatever they wish with source code distributed with\r
+ * PCCTS or the code generated by PCCTS, including the incorporation of\r
+ * PCCTS, or its output, into commerical software.\r
+ *\r
+ * We encourage users to develop software with PCCTS.  However, we do ask\r
+ * that credit is given to us for developing PCCTS.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like PCCTS and have developed a nice tool with the\r
+ * output, please mention that you developed it using PCCTS.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * ANTLR 1.33\r
+ * Terence Parr\r
+ * Parr Research Corporation\r
+ * with Purdue University and AHPCRC, University of Minnesota\r
+ * 1989-2000\r
+ */\r
+\r
+#ifndef ASTBase_H\r
+#define ASTBase_H\r
+\r
+#include "pcctscfg.h"\r
+\r
+#include "pccts_stdio.h"\r
+#include "pccts_stdlib.h"\r
+\r
+PCCTS_NAMESPACE_STD\r
+\r
+#ifndef PCCTS_NOT_USING_SOR\r
+#include "PCCTSAST.h"\r
+#endif\r
+\r
+/*\r
+ * Notes:\r
+ *\r
+ * To specify a copy constructor, subclass one of these classes and\r
+ * give the copy constructor.  To use dup(), you must define shallowCopy().\r
+ * shallowCopy() can use either a copy constructor or just copy the node\r
+ * itself.\r
+ */\r
+\r
+#ifdef PCCTS_NOT_USING_SOR\r
+class DllExportPCCTS ASTBase {\r
+#else\r
+class DllExportPCCTS ASTBase : public PCCTS_AST {\r
+#endif\r
+\r
+protected:\r
+       ASTBase *_right, *_down;\r
+\r
+public:\r
+\r
+#ifdef PCCTS_NOT_USING_SOR\r
+       ASTBase *right()        { return _right; }\r
+       ASTBase *down()     { return _down; }\r
+       void setRight(ASTBase *t)       { _right = (ASTBase *)t; }\r
+       void setDown(ASTBase *t)        { _down = (ASTBase *)t; }\r
+#else\r
+       PCCTS_AST *right()      { return _right; }      // define the SORCERER interface\r
+       PCCTS_AST *down()       { return _down; }\r
+       void setRight(PCCTS_AST *t)     { _right = (ASTBase *)t; }\r
+       void setDown(PCCTS_AST *t)      { _down = (ASTBase *)t; }\r
+#endif\r
+       ASTBase() { _right = _down = NULL; }\r
+       virtual ~ASTBase() { ; }\r
+#ifndef PCCTS_NOT_USING_SOR\r
+       virtual ASTBase *dup();\r
+#endif\r
+       void destroy();\r
+       void preorder(void* pData = NULL /* MR23 */);\r
+       static ASTBase *tmake(ASTBase *, ...);\r
+       static void link(ASTBase **, ASTBase **, ASTBase **);\r
+       void subchild(ASTBase **, ASTBase **, ASTBase **);\r
+       void subroot(ASTBase **, ASTBase **, ASTBase **);\r
+       virtual void preorder_action(void* /*pData*/ = NULL /* MR23 */) { ; }\r
+       virtual void preorder_before_action(void* /*pData*/ = NULL /* MR23 */) { /* MR23 */ printMessage(stdout, " ("); }\r
+       virtual void preorder_after_action(void* /*pData*/ = NULL /* MR23 */) { /* MR23 */ printMessage(stdout, " )"); }\r
+    virtual void panic(const char *msg);         /* MR21 */\r
+    virtual void reportOverwriteOfDownPointer(); /* MR21 */\r
+#ifdef PCCTS_NOT_USING_SOR\r
+       virtual int printMessage(FILE* pFile, const char* pFormat, ...); // MR23\r
+#endif\r
+};\r
+\r
+class DllExportPCCTS ASTDoublyLinkedBase : public ASTBase {\r
+protected:\r
+    ASTDoublyLinkedBase *_left, *_up;\r
+\r
+public:\r
+  void double_link(ASTBase *left, ASTBase *up);\r
+\r
+#ifndef PCCTS_NOT_USING_SOR\r
+  virtual ASTBase *dup();\r
+#endif\r
+\r
+#ifdef PCCTS_NOT_USING_SOR\r
+  ASTBase *left() { return _left; }\r
+  ASTBase *up() { return _up; }\r
+  void setLeft(ASTBase *t) { _left = (ASTDoublyLinkedBase *)t; }    // MR6\r
+  void setUp(ASTBase *t)   { _up = (ASTDoublyLinkedBase *)t; }     // MR6\r
+#else\r
+  PCCTS_AST *left() { return _left; }\r
+  PCCTS_AST *up() { return _up; }\r
+  void setLeft(PCCTS_AST *t) { _left = (ASTDoublyLinkedBase *)t; }  // MR6\r
+  void setUp(PCCTS_AST *t)   { _up = (ASTDoublyLinkedBase *)t; }       // MR6\r
+#endif\r
+\r
+};\r
+\r
+class AST;     // announce that this class will be coming along shortly\r
+#endif\r
diff --git a/Tools/CodeTools/Source/Pccts/h/ATokPtr.h b/Tools/CodeTools/Source/Pccts/h/ATokPtr.h
new file mode 100644 (file)
index 0000000..75b4c86
--- /dev/null
@@ -0,0 +1,88 @@
+/* ATokPtr.h\r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
+ * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
+ * company may do whatever they wish with source code distributed with\r
+ * PCCTS or the code generated by PCCTS, including the incorporation of\r
+ * PCCTS, or its output, into commerical software.\r
+ *\r
+ * We encourage users to develop software with PCCTS.  However, we do ask\r
+ * that credit is given to us for developing PCCTS.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like PCCTS and have developed a nice tool with the\r
+ * output, please mention that you developed it using PCCTS.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * ANTLR 1.33\r
+ * Written by Russell Quong June 30, 1995\r
+ * Adapted by Terence Parr to ANTLR stuff\r
+ * Parr Research Corporation\r
+ * with Purdue University and AHPCRC, University of Minnesota\r
+ * 1989-2000\r
+ */\r
+\r
+#ifndef ATokPtr_h\r
+#define ATokPtr_h\r
+\r
+#include "pcctscfg.h"\r
+\r
+#include "pccts_stdio.h"\r
+\r
+PCCTS_NAMESPACE_STD\r
+\r
+// pointer to a reference counted object\r
+// robust in that an unused ANTLRTokenPtr can point to NULL.\r
+\r
+class ANTLRAbstractToken;\r
+\r
+class DllExportPCCTS ANTLRTokenPtr {\r
+public:\r
+    ANTLRTokenPtr(ANTLRAbstractToken *addr=NULL){ptr_ = addr; ref();}\r
+    ANTLRTokenPtr(const ANTLRTokenPtr &lhs)    {ptr_ = lhs.ptr_; lhs.ref();}\r
+    ~ANTLRTokenPtr();\r
+\r
+    // use ANTLRTokenPtr as a pointer to ANTLRToken\r
+//\r
+//  8-Apr-97   MR1     Make operator -> a const member function\r
+//                       as well as some other member functions\r
+//\r
+    ANTLRAbstractToken *operator-> () const { return ptr_; }           // MR1\r
+//\r
+//  7-Apr-97 133MR1\r
+//          Fix suggested by Andreas Magnusson\r
+//                     (Andreas.Magnusson@mailbox.swipnet.se)\r
+    void operator = (const ANTLRTokenPtr & lhs);                       // MR1\r
+    void operator = (ANTLRAbstractToken *addr);\r
+    int operator != (const ANTLRTokenPtr &q) const                     // MR1 // MR11 unsigned -> int\r
+       { return this->ptr_ != q.ptr_; }\r
+    int operator == (const ANTLRTokenPtr &q) const                     // MR1 // MR11 unsigned -> int\r
+       { return this->ptr_ == q.ptr_; }\r
+    int operator == (const ANTLRAbstractToken *addr) const      // MR11\r
+    { return this->ptr_ == addr; }\r
+    int operator != (const ANTLRAbstractToken *addr) const      // MR11\r
+    { return this->ptr_ != addr; }\r
+\r
+    void ref() const;\r
+    void deref();\r
+\r
+protected:\r
+    ANTLRAbstractToken *ptr_;\r
+};\r
+\r
+//typedef ANTLRTokenPtr _ANTLRTokenPtr;\r
+\r
+/*\r
+ * Since you cannot redefine operator->() to return one of the user's\r
+ * token object types, we must down cast.  This is a drag.  Here's\r
+ * a macro that helps.  template: "mytoken(a-smart-ptr)->myfield".\r
+ */\r
+#define mytoken(tk) ((ANTLRToken *)(tk.operator->()))\r
+\r
+#endif\r
diff --git a/Tools/CodeTools/Source/Pccts/h/ATokPtrImpl.h b/Tools/CodeTools/Source/Pccts/h/ATokPtrImpl.h
new file mode 100644 (file)
index 0000000..9c07cf5
--- /dev/null
@@ -0,0 +1,88 @@
+/*\r
+ * ATokPtrImpl.h (formerly ATokPtr.cpp)\r
+ *\r
+ * This is #included in ATokBuffer.cpp for historical reasons.\r
+ * It has been renamed because of problems with the .cpp extension\r
+ * when used with IDE.\r
+ *\r
+ *\r
+ * ANTLRToken MUST be defined before entry to this file.\r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
+ * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
+ * company may do whatever they wish with source code distributed with\r
+ * PCCTS or the code generated by PCCTS, including the incorporation of\r
+ * PCCTS, or its output, into commerical software.\r
+ *\r
+ * We encourage users to develop software with PCCTS.  However, we do ask\r
+ * that credit is given to us for developing PCCTS.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like PCCTS and have developed a nice tool with the\r
+ * output, please mention that you developed it using PCCTS.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * ANTLR 1.33\r
+ * Written by Russell Quong June 30, 1995\r
+ * Adapted by Terence Parr to ANTLR stuff\r
+ * Parr Research Corporation\r
+ * with Purdue University and AHPCRC, University of Minnesota\r
+ * 1989-2000\r
+ */\r
+\r
+#include "pcctscfg.h"\r
+\r
+PCCTS_NAMESPACE_STD\r
+\r
+#include "ATokPtr.h"\r
+\r
+void ANTLRTokenPtr::ref() const\r
+{\r
+    if (ptr_ != NULL) {\r
+               ptr_->ref();\r
+       }\r
+}\r
+\r
+void ANTLRTokenPtr::deref()\r
+{\r
+    if (ptr_ != NULL)\r
+    {\r
+               ptr_->deref();\r
+               if ( ptr_->nref()==0 )\r
+               {\r
+                   delete ptr_;\r
+                       ptr_ = NULL;\r
+               }\r
+    }\r
+}\r
+\r
+ANTLRTokenPtr::~ANTLRTokenPtr()\r
+{\r
+    deref();\r
+}\r
+\r
+//\r
+//  8-Apr-97   MR1     Make operator -> a const member function\r
+//                       as weall as some other member functions\r
+//\r
+void ANTLRTokenPtr::operator = (const ANTLRTokenPtr & lhs)     // MR1\r
+{\r
+    lhs.ref(); // protect against "xp = xp"; ie same underlying object\r
+    deref();\r
+    ptr_ = lhs.ptr_;\r
+}\r
+\r
+void ANTLRTokenPtr::operator = (ANTLRAbstractToken *addr)\r
+{\r
+    if (addr != NULL) {\r
+       addr->ref();\r
+    }\r
+    deref();\r
+    ptr_ = addr;\r
+}\r
diff --git a/Tools/CodeTools/Source/Pccts/h/AToken.h b/Tools/CodeTools/Source/Pccts/h/AToken.h
new file mode 100644 (file)
index 0000000..6167c21
--- /dev/null
@@ -0,0 +1,325 @@
+/* ANTLRToken.h\r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
+ * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
+ * company may do whatever they wish with source code distributed with\r
+ * PCCTS or the code generated by PCCTS, including the incorporation of\r
+ * PCCTS, or its output, into commerical software.\r
+ *\r
+ * We encourage users to develop software with PCCTS.  However, we do ask\r
+ * that credit is given to us for developing PCCTS.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like PCCTS and have developed a nice tool with the\r
+ * output, please mention that you developed it using PCCTS.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * ANTLR 1.33\r
+ * Terence Parr\r
+ * Parr Research Corporation\r
+ * with Purdue University and AHPCRC, University of Minnesota\r
+ * 1989-2000\r
+ */\r
+\r
+#ifndef ATOKEN_H_GATE\r
+#define ATOKEN_H_GATE\r
+\r
+#include "pcctscfg.h"\r
+\r
+#include "pccts_string.h"\r
+#include "pccts_stdio.h"\r
+#include "pccts_stdlib.h"\r
+#include "pccts_stdarg.h" // MR23\r
+\r
+PCCTS_NAMESPACE_STD\r
+\r
+// MR9      RJV (JVincent@novell.com) Not needed for variable length strings\r
+\r
+//// MR9 #ifndef ANTLRCommonTokenTEXTSIZE\r
+//// MR9 #define ANTLRCommonTokenTEXTSIZE              100\r
+//// MR9 #endif\r
+\r
+\r
+/* must define what a char looks like; can make this a class too */\r
+typedef char ANTLRChar;\r
+\r
+/* D E F I N E  S M A R T  P O I N T E R S */\r
+\r
+//#include ATOKPTR_H   not tested yet, leave out\r
+class ANTLRAbstractToken;\r
+typedef ANTLRAbstractToken *_ANTLRTokenPtr;\r
+\r
+class ANTLRAbstractToken {\r
+public:\r
+    virtual ~ANTLRAbstractToken() {;}\r
+    virtual ANTLRTokenType getType() const = 0;\r
+    virtual void setType(ANTLRTokenType t) = 0;\r
+    virtual int getLine() const = 0;\r
+    virtual void setLine(int line) = 0;\r
+    virtual ANTLRChar *getText() const = 0;\r
+    virtual void setText(const ANTLRChar *) = 0;\r
+\r
+    /* This function will disappear when I can use templates */\r
+       virtual ANTLRAbstractToken *makeToken(ANTLRTokenType tt,\r
+                                                                                 ANTLRChar *text,\r
+                                                                                 int line) = 0;\r
+\r
+       /* define to satisfy ANTLRTokenBuffer's need to determine whether or\r
+          not a token object can be destroyed.  If nref()==0, no one has\r
+          a reference, and the object may be destroyed.  This function defaults\r
+          to 1, hence, if you use deleteTokens() message with a token object\r
+          not derived from ANTLRCommonRefCountToken, the parser will compile\r
+          but will not delete objects after they leave the token buffer.\r
+    */\r
+\r
+       virtual unsigned nref() const { return 1; }     // MR11\r
+       virtual void ref() {;}\r
+       virtual void deref() {;}\r
+\r
+       virtual void panic(const char *msg)             // MR20 const\r
+               {\r
+                       /* MR23 */ printMessage(stderr, "ANTLRAbstractToken panic: %s\n", msg);\r
+                       exit(PCCTS_EXIT_FAILURE);\r
+               }\r
+\r
+       virtual int printMessage(FILE* pFile, const char* pFormat, ...) // MR23\r
+               {\r
+                       va_list marker;\r
+                       va_start( marker, pFormat );\r
+                       int iRet = vfprintf(pFile, pFormat, marker);\r
+                       va_end( marker );\r
+                       return iRet;\r
+               }\r
+};\r
+\r
+/* This class should be subclassed.  It cannot store token type or text */\r
+\r
+class ANTLRRefCountToken : public ANTLRAbstractToken {\r
+public:\r
+#ifdef DBG_REFCOUNTTOKEN\r
+       static int ctor;\r
+       static int dtor;\r
+#endif\r
+protected:\r
+    unsigned refcnt_;\r
+#ifdef DBG_REFCOUNTTOKEN\r
+       char object[200];\r
+#endif\r
+\r
+public:\r
+\r
+       // MR23 - No matter what you do, you're hammered.\r
+       //        Don't give names to formals something breaks.\r
+       //                Give names to formals and don't use them it breaks.\r
+\r
+#ifndef DBG_REFCOUNTTOKEN\r
+       ANTLRRefCountToken(ANTLRTokenType /* t MR23 */, const ANTLRChar * /* s MR23 */)\r
+#else\r
+       ANTLRRefCountToken(ANTLRTokenType t, const ANTLRChar * s)\r
+#endif\r
+\r
+#ifndef DBG_REFCOUNTTOKEN\r
+               {\r
+                       refcnt_ = 0;\r
+               }\r
+#else\r
+       {\r
+               ctor++;\r
+               refcnt_ = 0;\r
+               if ( t==1 ) sprintf(object,"tok_EOF");\r
+               else sprintf(object,"tok_%s",s);\r
+               /* MR23 */ printMessage(stderr, "ctor %s #%d\n",object,ctor);\r
+       }\r
+#endif\r
+       ANTLRRefCountToken()\r
+#ifndef DBG_REFCOUNTTOKEN\r
+               { refcnt_ = 0; }\r
+#else\r
+               {\r
+                       ctor++;\r
+                       refcnt_ = 0;\r
+                       sprintf(object,"tok_blank");\r
+                       /* MR23 */ printMessage(stderr, "ctor %s #%d\n",object,ctor);\r
+               }\r
+       virtual ~ANTLRRefCountToken()\r
+               {\r
+                       dtor++;\r
+                       if ( dtor>ctor ) /* MR23 */ printMessage(stderr, "WARNING: dtor>ctor\n");\r
+                       /* MR23 */ printMessage(stderr, "dtor %s #%d\n", object, dtor);\r
+                       object[0]='\0';\r
+               }\r
+#endif\r
+\r
+       // reference counting stuff needed by ANTLRTokenPtr.\r
+       // User should not access these; for C++ language reasons, we had\r
+       // to make these public.  Yuck.\r
+\r
+       void ref()                    { refcnt_++; }\r
+       void deref()          { refcnt_--; }\r
+       unsigned nref() const { return refcnt_; }   // MR11\r
+\r
+       virtual ANTLRAbstractToken *makeToken(ANTLRTokenType /*tt MR23*/,\r
+                                                                                 ANTLRChar * /*txt MR23*/,\r
+                                                                                 int /*line MR23*/)\r
+       {\r
+               panic("call to ANTLRRefCountToken::makeToken()\n");\r
+               return NULL;\r
+       }\r
+};\r
+\r
+class ANTLRCommonNoRefCountToken : public ANTLRAbstractToken {\r
+protected:\r
+       ANTLRTokenType _type;\r
+       int _line;\r
+       ANTLRChar *_text;               // MR9 RJV\r
+\r
+public:\r
+       ANTLRCommonNoRefCountToken(ANTLRTokenType t, const ANTLRChar *s)\r
+       { setType(t); _line = 0; _text = NULL; setText(s); }\r
+       ANTLRCommonNoRefCountToken()\r
+       { setType((ANTLRTokenType)0); _line = 0; _text = NULL; setText(""); }\r
+\r
+       ~ANTLRCommonNoRefCountToken() { if (_text) delete [] _text; }  // MR9 RJV: Added Destructor to remove string\r
+\r
+       ANTLRTokenType getType() const  { return _type; }\r
+       void setType(ANTLRTokenType t)  { _type = t; }\r
+       virtual int getLine() const             { return _line; }\r
+       void setLine(int line)          { _line = line; }\r
+       ANTLRChar *getText() const      { return _text; }\r
+    int getLength() const           { return strlen(getText()); }       // MR11\r
+\r
+// MR9 RJV: Added code for variable length strings to setText()\r
+\r
+       void setText(const ANTLRChar *s)\r
+       {       if (s != _text) {\r
+          if (_text) delete [] _text;\r
+          if (s != NULL) {\r
+               _text = new ANTLRChar[strlen(s)+1];\r
+            if (_text == NULL) panic("ANTLRCommonNoRefCountToken::setText new failed");\r
+            strcpy(_text,s);\r
+         } else {\r
+            _text = new ANTLRChar[1];\r
+            if (_text == NULL) panic("ANTLRCommonNoRefCountToken::setText new failed");\r
+            strcpy(_text,"");\r
+          };\r
+        };\r
+       }\r
+\r
+       virtual ANTLRAbstractToken *makeToken(ANTLRTokenType tt,\r
+                                                                                 ANTLRChar *txt,\r
+                                                                                 int line)\r
+               {\r
+                       ANTLRAbstractToken *t = new ANTLRCommonNoRefCountToken;\r
+                       t->setType(tt); t->setText(txt); t->setLine(line);\r
+                       return t;\r
+               }\r
+\r
+// MR9 THM Copy constructor required when heap allocated string is used with copy semantics\r
+\r
+   ANTLRCommonNoRefCountToken (const ANTLRCommonNoRefCountToken& from) :\r
+         ANTLRAbstractToken(from) {\r
+        setType(from._type);\r
+        setLine(from._line);\r
+     _text=NULL;\r
+     setText(from._text);\r
+  };\r
+\r
+// MR9 THM operator =() required when heap allocated string is used with copy semantics\r
+\r
+   virtual ANTLRCommonNoRefCountToken& operator =(const ANTLRCommonNoRefCountToken& rhs) {\r
+\r
+//////  MR15 WatCom can't hack use of operator =()\r
+//////  Use this:  *( (ANTRLAbstractToken *) this)=rhs;\r
+\r
+     *( (ANTLRAbstractToken *) this ) = rhs;\r
+\r
+        setType(rhs._type);\r
+        setLine(rhs._line);\r
+     setText(rhs._text);\r
+     return *this;\r
+   };\r
+};\r
+\r
+class ANTLRCommonToken : public ANTLRRefCountToken {\r
+protected:\r
+       ANTLRTokenType       _type;\r
+       int                  _line;\r
+       ANTLRChar           *_text;               // MR9 RJV:Added\r
+\r
+public:\r
+       ANTLRCommonToken(ANTLRTokenType t, const ANTLRChar *s) : ANTLRRefCountToken(t,s)\r
+               { setType(t); _line = 0; _text = NULL; setText(s); }                    // MR9\r
+       ANTLRCommonToken()\r
+               { setType((ANTLRTokenType)0); _line = 0; _text = NULL; setText(""); }   // MR9\r
+\r
+       virtual ~ANTLRCommonToken() { if (_text) delete [] _text; } // MR9 RJV: Added Destructor to remove string\r
+\r
+       ANTLRTokenType getType() const  { return _type; }\r
+       void setType(ANTLRTokenType t)  { _type = t; }\r
+       virtual int getLine() const             { return _line; }\r
+       void setLine(int line)          { _line = line; }\r
+       ANTLRChar *getText() const              { return _text; }\r
+    int getLength() const           { return strlen(getText()); }       // MR11\r
+\r
+// MR9 RJV: Added code for variable length strings to setText()\r
+\r
+       void setText(const ANTLRChar *s)\r
+       {       if (s != _text) {\r
+          if (_text) delete [] _text;\r
+          if (s != NULL) {\r
+               _text = new ANTLRChar[strlen(s)+1];\r
+            if (_text == NULL) panic("ANTLRCommonToken::setText new failed");\r
+            strcpy(_text,s);\r
+         } else {\r
+            _text = new ANTLRChar[1];\r
+            if (_text == NULL) panic("ANTLRCommonToken::setText new failed");\r
+            strcpy(_text,"");\r
+          };\r
+        };\r
+       }\r
+\r
+       virtual ANTLRAbstractToken *makeToken(ANTLRTokenType tt,\r
+                                                                                 ANTLRChar *txt,\r
+                                                                                 int line)\r
+       {\r
+               ANTLRAbstractToken *t = new ANTLRCommonToken(tt,txt);\r
+               t->setLine(line);\r
+               return t;\r
+       }\r
+\r
+// MR9 THM Copy constructor required when heap allocated string is used with copy semantics\r
+\r
+   ANTLRCommonToken (const ANTLRCommonToken& from) :\r
+         ANTLRRefCountToken(from) {\r
+        setType(from._type);\r
+        setLine(from._line);\r
+     _text=NULL;\r
+     setText(from._text);\r
+  };\r
+\r
+// MR9 THM operator =() required when heap allocated string is used with copy semantics\r
+\r
+   virtual ANTLRCommonToken& operator =(const ANTLRCommonToken& rhs) {\r
+\r
+//////  MR15 WatCom can't hack use of operator =()\r
+//////  Use this instead:   *( (ANTRLRRefCountToken *) this)=rhs;\r
+\r
+     *( (ANTLRRefCountToken *) this) = rhs;\r
+\r
+        setType(rhs._type);\r
+        setLine(rhs._line);\r
+     setText(rhs._text);\r
+     return *this;\r
+   };\r
+};\r
+\r
+// used for backward compatibility\r
+typedef ANTLRCommonToken ANTLRCommonBacktrackingToken;\r
+\r
+#endif\r
diff --git a/Tools/CodeTools/Source/Pccts/h/ATokenBuffer.cpp b/Tools/CodeTools/Source/Pccts/h/ATokenBuffer.cpp
new file mode 100644 (file)
index 0000000..9a2f2fc
--- /dev/null
@@ -0,0 +1,374 @@
+/* ANTLRTokenBuffer.cpp\r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
+ * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
+ * company may do whatever they wish with source code distributed with\r
+ * PCCTS or the code generated by PCCTS, including the incorporation of\r
+ * PCCTS, or its output, into commerical software.\r
+ *\r
+ * We encourage users to develop software with PCCTS.  However, we do ask\r
+ * that credit is given to us for developing PCCTS.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like PCCTS and have developed a nice tool with the\r
+ * output, please mention that you developed it using PCCTS.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * ANTLR 1.33\r
+ * Terence Parr\r
+ * Parr Research Corporation\r
+ * with Purdue University and AHPCRC, University of Minnesota\r
+ * 1989-2000\r
+ */\r
+\r
+typedef int ANTLRTokenType;    // fool AToken.h into compiling\r
+\r
+class ANTLRParser;                                     /* MR1 */\r
+\r
+#define ANTLR_SUPPORT_CODE\r
+\r
+#include "pcctscfg.h"\r
+\r
+#include ATOKENBUFFER_H\r
+#include APARSER_H             // MR23\r
+\r
+typedef ANTLRAbstractToken *_ANTLRTokenPtr;\r
+\r
+#if defined(DBG_TBUF)||defined(DBG_TBUF_MARK_REW)\r
+static unsigned char test[1000];\r
+#endif\r
+\r
+#ifdef DBG_REFCOUNTTOKEN\r
+int ANTLRRefCountToken::ctor = 0; /* MR23 */\r
+int ANTLRRefCountToken::dtor = 0; /* MR23 */\r
+#endif\r
+\r
+ANTLRTokenBuffer::\r
+ANTLRTokenBuffer(ANTLRTokenStream *_input, int _k, int _chunk_size_formal) /* MR14 */\r
+{\r
+       this->input = _input;\r
+       this->k = _k;\r
+       buffer_size = chunk_size = _chunk_size_formal;\r
+       buffer = (_ANTLRTokenPtr *)\r
+                        calloc(chunk_size+1,sizeof(_ANTLRTokenPtr ));\r
+       if ( buffer == NULL ) {\r
+               panic("cannot alloc token buffer");\r
+       }\r
+       buffer++;                               // leave the first elem empty so tp-1 is valid ptr\r
+\r
+       tp = &buffer[0];\r
+       last = tp-1;\r
+       next = &buffer[0];\r
+       num_markers = 0;\r
+       end_of_buffer = &buffer[buffer_size-1];\r
+       threshold = &buffer[(int)(buffer_size/2)];      // MR23 - Used to be 1.0/2.0 !\r
+       _deleteTokens = 1;      // assume we delete tokens\r
+       parser=NULL;                            // MR5 - uninitialized reference\r
+}\r
+\r
+static void f() {;}\r
+ANTLRTokenBuffer::\r
+~ANTLRTokenBuffer()\r
+{\r
+       f();\r
+       // Delete all remaining tokens (from 0..last inclusive)\r
+       if ( _deleteTokens )\r
+       {\r
+               _ANTLRTokenPtr *z;\r
+               for (z=buffer; z<=last; z++)\r
+               {\r
+                       (*z)->deref();\r
+//                     z->deref();\r
+#ifdef DBG_REFCOUNTTOKEN\r
+                                       /* MR23 */ printMessage(stderr, "##########dtor: deleting token '%s' (ref %d)\n",\r
+                                                       ((ANTLRCommonToken *)*z)->getText(), (*z)->nref());\r
+#endif\r
+                       if ( (*z)->nref()==0 )\r
+                       {\r
+                               delete (*z);\r
+                       }\r
+               }\r
+       }\r
+\r
+       if ( buffer!=NULL ) free((char *)(buffer-1));\r
+}\r
+\r
+#if defined(DBG_TBUF)||defined(DBG_TBUF_MARK_REW)\r
+#include "pccts_stdio.h"\r
+PCCTS_NAMESPACE_STD\r
+#endif\r
+\r
+_ANTLRTokenPtr ANTLRTokenBuffer::\r
+getToken()\r
+{\r
+       if ( tp <= last )       // is there any buffered lookahead still to be read?\r
+       {\r
+               return *tp++;   // read buffered lookahead\r
+       }\r
+       // out of buffered lookahead, get some more "real"\r
+       // input from getANTLRToken()\r
+       if ( num_markers==0 )\r
+       {\r
+               if( next > threshold )\r
+               {\r
+#ifdef DBG_TBUF\r
+/* MR23 */ printMessage(stderr,"getToken: next > threshold (high water is %d)\n", threshold-buffer);\r
+#endif\r
+                       makeRoom();\r
+               }\r
+       }\r
+       else {\r
+               if ( next > end_of_buffer )\r
+               {\r
+#ifdef DBG_TBUF\r
+/* MR23 */ printMessage(stderr,"getToken: next > end_of_buffer (size is %d)\n", buffer_size);\r
+#endif\r
+                       extendBuffer();\r
+               }\r
+       }\r
+       *next = getANTLRToken();\r
+       (*next)->ref();                         // say we have a copy of this pointer in buffer\r
+       last = next;\r
+       next++;\r
+       tp = last;\r
+       return *tp++;\r
+}\r
+\r
+void ANTLRTokenBuffer::\r
+rewind(int pos)\r
+{\r
+#if defined(DBG_TBUF)||defined(DBG_TBUF_MARK_REW)\r
+       /* MR23 */ printMessage(stderr, "rewind(%d)[nm=%d,from=%d,%d.n=%d]\n", pos, num_markers, tp-buffer,pos,test[pos]);\r
+       test[pos]--;\r
+#endif\r
+       tp = &buffer[pos];\r
+       num_markers--;\r
+}\r
+\r
+/*\r
+ * This function is used to specify that the token pointers read\r
+ * by the ANTLRTokenBuffer should be buffered up (to be reused later).\r
+ */\r
+int ANTLRTokenBuffer::\r
+mark()\r
+{\r
+#if defined(DBG_TBUF)||defined(DBG_TBUF_MARK_REW)\r
+       test[tp-buffer]++;\r
+       /* MR23 */ printMessage(stderr,"mark(%d)[nm=%d,%d.n=%d]\n",tp-buffer,num_markers+1,tp-buffer,test[tp-buffer]);\r
+#endif\r
+       num_markers++;\r
+       return tp - buffer;\r
+}\r
+\r
+/*\r
+ * returns the token pointer n positions ahead.\r
+ * This implies that bufferedToken(1) gets the NEXT symbol of lookahead.\r
+ * This is used in conjunction with the ANTLRParser lookahead buffer.\r
+ *\r
+ * No markers are set or anything.  A bunch of input is buffered--that's all.\r
+ * The tp pointer is left alone as the lookahead has not been advanced\r
+ * with getToken().  The next call to getToken() will find a token\r
+ * in the buffer and won't have to call getANTLRToken().\r
+ *\r
+ * If this is called before a consume() is done, how_many_more_i_need is\r
+ * set to 'n'.\r
+ */\r
+_ANTLRTokenPtr ANTLRTokenBuffer::\r
+bufferedToken(int n)\r
+{\r
+//     int how_many_more_i_need = (last-tp < 0) ? n : n-(last-tp)-1;\r
+       int how_many_more_i_need = (tp > last) ? n : n-(last-tp)-1;\r
+       // Make sure that at least n tokens are available in the buffer\r
+#ifdef DBG_TBUF\r
+       /* MR23 */ printMessage(stderr, "bufferedToken(%d)\n", n);\r
+#endif\r
+       for (int i=1; i<=how_many_more_i_need; i++)\r
+       {\r
+               if ( next > end_of_buffer )     // buffer overflow?\r
+               {\r
+                       extendBuffer();\r
+               }\r
+               *next = getANTLRToken();\r
+               (*next)->ref();         // say we have a copy of this pointer in buffer\r
+               last = next;\r
+               next++;\r
+       }\r
+       return tp[n - 1];\r
+}\r
+\r
+/* If no markers are set, the none of the input needs to be saved (except\r
+ * for the lookahead Token pointers).  We save only k-1 token pointers as\r
+ * we are guaranteed to do a getANTLRToken() right after this because otherwise\r
+ * we wouldn't have needed to extend the buffer.\r
+ *\r
+ * If there are markers in the buffer, we need to save things and so\r
+ * extendBuffer() is called.\r
+ */\r
+void ANTLRTokenBuffer::\r
+makeRoom()\r
+{\r
+#ifdef DBG_TBUF\r
+       /* MR23 */ printMessage(stderr, "in makeRoom.................\n");\r
+       /* MR23 */ printMessage(stderr, "num_markers==%d\n", num_markers);\r
+#endif\r
+/*\r
+       if ( num_markers == 0 )\r
+       {\r
+*/\r
+#ifdef DBG_TBUF\r
+               /* MR23 */ printMessage(stderr, "moving lookahead and resetting next\n");\r
+\r
+               _ANTLRTokenPtr *r;\r
+               /* MR23 */ printMessage(stderr, "tbuf = [");\r
+               for (r=buffer; r<=last; r++)\r
+               {\r
+                       if ( *r==NULL ) /* MR23 */ printMessage(stderr, " xxx");\r
+                       else /* MR23 */ printMessage(stderr, " '%s'", ((ANTLRCommonToken *)*r)->getText());\r
+               }\r
+               /* MR23 */ printMessage(stderr, " ]\n");\r
+\r
+               /* MR23 */ printMessage(stderr,\r
+               "before: tp=%d, last=%d, next=%d, threshold=%d\n",tp-buffer,last-buffer,next-buffer,threshold-buffer);\r
+#endif\r
+\r
+               // Delete all tokens from 0..last-(k-1) inclusive\r
+               if ( _deleteTokens )\r
+               {\r
+                       _ANTLRTokenPtr *z;\r
+                       for (z=buffer; z<=last-(k-1); z++)\r
+                       {\r
+                               (*z)->deref();\r
+//                             z->deref();\r
+#ifdef DBG_REFCOUNTTOKEN\r
+                                       /* MR23 */ printMessage(stderr, "##########makeRoom: deleting token '%s' (ref %d)\n",\r
+                                                       ((ANTLRCommonToken *)*z)->getText(), (*z)->nref());\r
+#endif\r
+                               if ( (*z)->nref()==0 )\r
+                               {\r
+                                       delete (*z);\r
+                               }\r
+                       }\r
+               }\r
+\r
+               // reset the buffer to initial conditions, but move k-1 symbols\r
+               // to the beginning of buffer and put new input symbol at k\r
+               _ANTLRTokenPtr *p = buffer, *q = last-(k-1)+1;\r
+//             ANTLRAbstractToken **p = buffer, **q = end_of_buffer-(k-1)+1;\r
+#ifdef DBG_TBUF\r
+               /* MR23 */ printMessage(stderr, "lookahead buffer = [");\r
+#endif\r
+               for (int i=1; i<=(k-1); i++)\r
+               {\r
+                       *p++ = *q++;\r
+#ifdef DBG_TBUF\r
+                       /* MR23 */ printMessage(stderr,\r
+                       " '%s'", ((ANTLRCommonToken *)buffer[i-1])->getText());\r
+#endif\r
+               }\r
+#ifdef DBG_TBUF\r
+               /* MR23 */ printMessage(stderr, " ]\n");\r
+#endif\r
+               next = &buffer[k-1];\r
+               tp = &buffer[k-1];      // tp points to what will be filled in next\r
+               last = tp-1;\r
+#ifdef DBG_TBUF\r
+               /* MR23 */ printMessage(stderr,\r
+               "after: tp=%d, last=%d, next=%d\n",\r
+               tp-buffer, last-buffer, next-buffer);\r
+#endif\r
+/*\r
+       }\r
+       else {\r
+               extendBuffer();\r
+       }\r
+*/\r
+}\r
+\r
+/* This function extends 'buffer' by chunk_size and returns with all\r
+ * pointers at the same relative positions in the buffer (the buffer base\r
+ * address could have changed in realloc()) except that 'next' comes\r
+ * back set to where the next token should be stored.  All other pointers\r
+ * are untouched.\r
+ */\r
+void\r
+ANTLRTokenBuffer::\r
+extendBuffer()\r
+{\r
+       int save_last = last-buffer, save_tp = tp-buffer, save_next = next-buffer;\r
+#ifdef DBG_TBUF\r
+       /* MR23 */ printMessage(stderr, "extending physical buffer\n");\r
+#endif\r
+       buffer_size += chunk_size;\r
+       buffer = (_ANTLRTokenPtr *)\r
+               realloc((char *)(buffer-1),\r
+                               (buffer_size+1)*sizeof(_ANTLRTokenPtr ));\r
+       if ( buffer == NULL ) {\r
+               panic("cannot alloc token buffer");\r
+       }\r
+       buffer++;                               // leave the first elem empty so tp-1 is valid ptr\r
+\r
+       tp = buffer + save_tp;  // put the pointers back to same relative position\r
+       last = buffer + save_last;\r
+       next = buffer + save_next;\r
+       end_of_buffer = &buffer[buffer_size-1];\r
+       threshold = &buffer[(int)(buffer_size*(1.0/2.0))];\r
+\r
+/*\r
+       // zero out new token ptrs so we'll know if something to delete in buffer\r
+       ANTLRAbstractToken **p = end_of_buffer-chunk_size+1;\r
+       for (; p<=end_of_buffer; p++) *p = NULL;\r
+*/\r
+}\r
+\r
+ANTLRParser * ANTLRTokenBuffer::                               // MR1\r
+setParser(ANTLRParser *p) {                                    // MR1\r
+  ANTLRParser  *old=parser;                                    // MR1\r
+  parser=p;                                                    // MR1\r
+  input->setParser(p);                                         // MR1\r
+  return old;                                                  // MR1\r
+}                                                              // MR1\r
+                                                               // MR1\r
+ANTLRParser * ANTLRTokenBuffer::                               // MR1\r
+getParser() {                                                  // MR1\r
+  return parser;                                               // MR1\r
+}                                                              // MR1\r
+\r
+void ANTLRTokenBuffer::panic(const char *msg) // MR23\r
+{ \r
+       if (parser)                             //MR23\r
+               parser->panic(msg);     //MR23\r
+       else                                    //MR23\r
+               exit(PCCTS_EXIT_FAILURE); \r
+} \r
+\r
+//MR23\r
+int ANTLRTokenBuffer::printMessage(FILE* pFile, const char* pFormat, ...)\r
+{\r
+       va_list marker;\r
+       va_start( marker, pFormat );\r
+\r
+       int iRet = 0;\r
+       if (parser)\r
+               parser->printMessageV(pFile, pFormat, marker);\r
+       else\r
+               iRet = vfprintf(pFile, pFormat, marker);\r
+\r
+       va_end( marker );\r
+       return iRet;\r
+}\r
+\r
+/* to avoid having to link in another file just for the smart token ptr\r
+ * stuff, we include it here.  Ugh.\r
+ *\r
+ * MR23 This causes nothing but problems for IDEs.\r
+ *      Change from .cpp to .h\r
+ *\r
+ */\r
+\r
+#include ATOKPTR_IMPL_H\r
diff --git a/Tools/CodeTools/Source/Pccts/h/ATokenBuffer.h b/Tools/CodeTools/Source/Pccts/h/ATokenBuffer.h
new file mode 100644 (file)
index 0000000..1c008fd
--- /dev/null
@@ -0,0 +1,109 @@
+/* ANTLRTokenBuffer.h\r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
+ * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
+ * company may do whatever they wish with source code distributed with\r
+ * PCCTS or the code generated by PCCTS, including the incorporation of\r
+ * PCCTS, or its output, into commerical software.\r
+ *\r
+ * We encourage users to develop software with PCCTS.  However, we do ask\r
+ * that credit is given to us for developing PCCTS.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like PCCTS and have developed a nice tool with the\r
+ * output, please mention that you developed it using PCCTS.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * ANTLR 1.33\r
+ * Terence Parr\r
+ * Parr Research Corporation\r
+ * with Purdue University and AHPCRC, University of Minnesota\r
+ * 1989-2000\r
+ */\r
+\r
+#ifndef ATOKENBUFFER_H_GATE\r
+#define ATOKENBUFFER_H_GATE\r
+\r
+#include "pcctscfg.h"\r
+\r
+#include "pccts_stdlib.h"\r
+\r
+PCCTS_NAMESPACE_STD\r
+\r
+#include ATOKEN_H\r
+#include ATOKENSTREAM_H\r
+\r
+/*\r
+ * The parser is "attached" to an ANTLRTokenBuffer via interface\r
+ * functions: getToken() and bufferedToken().  The object that actually\r
+ * consumes characters and constructs tokens is connected to the\r
+ * ANTLRTokenBuffer via interface function ANTLRTokenStream::getToken();\r
+ * where ANTLRTokenStream is really just a behavior (class with no data).\r
+ * C++ does not have this abstraction and hence we simply have come up\r
+ * with a fancy name for "void *".  See the note in ANTLRTokenStream.h on\r
+ * the "behavior" of ANTLRTokenStream.\r
+ */\r
+\r
+class ANTLRParser;                                     // MR1\r
+\r
+class DllExportPCCTS ANTLRTokenBuffer {\r
+protected:\r
+       ANTLRTokenStream *input;        // where do I get tokens\r
+       int buffer_size;\r
+       int chunk_size;\r
+       int num_markers;\r
+       int k;                          // Need at least this many tokens in buffer\r
+       _ANTLRTokenPtr *buffer; // buffer used for arbitrary lookahead\r
+       _ANTLRTokenPtr *tp;        // pts into buffer; current token ptr\r
+       _ANTLRTokenPtr *last;      // pts to last valid token in buffer\r
+       _ANTLRTokenPtr *next;      // place to put token from getANTLRToken()\r
+       _ANTLRTokenPtr *end_of_buffer;\r
+       /* when you try to write a token past this and there are no markers\r
+          set, then move k-1 tokens back to the beginning of the buffer.\r
+          We want to stay away from the end of the buffer because we have\r
+          to extend it if a marker is set and we reach the end (we cannot\r
+          move tokens to the beginning of the buffer in this case).\r
+        */\r
+       _ANTLRTokenPtr *threshold;\r
+       unsigned char _deleteTokens;\r
+\r
+       // This function is filled in by the subclass; it initiates fetch of input\r
+       virtual _ANTLRTokenPtr getANTLRToken() { return input->getToken(); }\r
+       void makeRoom();\r
+       void extendBuffer();\r
+\r
+public:\r
+       ANTLRTokenBuffer(ANTLRTokenStream *in, int k=1, int chksz=50);\r
+       virtual ~ANTLRTokenBuffer();\r
+       virtual _ANTLRTokenPtr getToken();\r
+       virtual void rewind(int pos);\r
+       virtual int mark();\r
+       virtual _ANTLRTokenPtr bufferedToken(int i);\r
+\r
+       void noGarbageCollectTokens()   { _deleteTokens=0; }\r
+       void garbageCollectTokens()             { _deleteTokens=1; }\r
+\r
+       virtual int bufferSize() { return buffer_size; }\r
+       virtual int minTokens() { return k; }\r
+       virtual void setMinTokens(int k_new) { k = k_new; }\r
+\r
+       virtual void panic(const char *msg); /* MR20 const */\r
+\r
+       virtual int printMessage(FILE* pFile, const char* pFormat, ...); // MR23\r
+\r
+protected:                                             // MR1\r
+       ANTLRParser     *parser;                        // MR1\r
+public:                                                        // MR1\r
+       ANTLRParser     *setParser(ANTLRParser *p);     // MR1\r
+       ANTLRParser     *getParser();                       // MR1\r
+    ANTLRTokenStream *getLexer() const {    // MR12\r
+      return input;}                        // MR12\r
+};\r
+\r
+#endif\r
diff --git a/Tools/CodeTools/Source/Pccts/h/ATokenStream.h b/Tools/CodeTools/Source/Pccts/h/ATokenStream.h
new file mode 100644 (file)
index 0000000..3dfea6e
--- /dev/null
@@ -0,0 +1,51 @@
+/* ANTLRTokenStream.h\r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
+ * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
+ * company may do whatever they wish with source code distributed with\r
+ * PCCTS or the code generated by PCCTS, including the incorporation of\r
+ * PCCTS, or its output, into commerical software.\r
+ *\r
+ * We encourage users to develop software with PCCTS.  However, we do ask\r
+ * that credit is given to us for developing PCCTS.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like PCCTS and have developed a nice tool with the\r
+ * output, please mention that you developed it using PCCTS.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * ANTLR 1.33\r
+ * Terence Parr\r
+ * Parr Research Corporation\r
+ * with Purdue University and AHPCRC, University of Minnesota\r
+ * 1989-2000\r
+ */\r
+\r
+#ifndef ATOKENSTREAM_H_GATE\r
+#define ATOKENSTREAM_H_GATE\r
+\r
+#include "pcctscfg.h"\r
+\r
+/* This is really a behavior or protocol; it merely indicates the behavior\r
+ * required of the input and output of an ANTLRTokenBuffer.  You could\r
+ * subclass it, but you can also just pass any old pointer to ANTLRTokenBuffer\r
+ * with a type cast (in which case, your getANTLRToken() would have to\r
+ * explicitly cast the input pointer to your REAL type (typically your lexer)).\r
+ */\r
+\r
+class ANTLRParser;                                                     // MR1\r
+\r
+class DllExportPCCTS ANTLRTokenStream {\r
+public:\r
+    virtual _ANTLRTokenPtr getToken() = 0;\r
+       virtual ANTLRParser * setParser(ANTLRParser * /*p MR23*/) {return 0; };   // MR12\r
+       virtual ANTLRParser * getParser() { return 0; };                        // MR12\r
+};\r
+\r
+#endif\r
diff --git a/Tools/CodeTools/Source/Pccts/h/BufFileInput.cpp b/Tools/CodeTools/Source/Pccts/h/BufFileInput.cpp
new file mode 100644 (file)
index 0000000..99d08a4
--- /dev/null
@@ -0,0 +1,100 @@
+// FILE:        BufFileInput.cpp\r
+// AUTHOR:      Alexey Demakov (AVD) demakov@kazbek.ispras.ru\r
+// CREATION:    26-JAN-1998\r
+// DESCRIPTION: File Input Stream with lookahead for Scanner.\r
+//   See file BufFileInput.h for details\r
+\r
+// Change History:\r
+//\r
+//   22-Jun-1998    assert.h -> PCCTS_ASSERT_H\r
+//                  string.h -> PCCTS_STRING_H\r
+//\r
+//   28-May-1998    Add virtual destructor to release buffer.\r
+//\r
+//                  Add dummy definition for ANTLRTokenType\r
+//                  to allow compilation without knowing\r
+//                  token type codes.\r
+//\r
+//                  Manfred Kogler (km@cast.uni-linz.ac.at)\r
+//                  (1.33MR14)\r
+//\r
+//   20-Jul-1998    MR14a - Reorder initialization list for ctor.\r
+//\r
+\r
+enum ANTLRTokenType {TER_HATES_CPP=0, SO_DO_OTHERS=9999 };\r
+\r
+#include "pcctscfg.h"\r
+#include "pccts_assert.h"\r
+#include "pccts_string.h"\r
+\r
+PCCTS_NAMESPACE_STD\r
+\r
+#include "BufFileInput.h"\r
+\r
+BufFileInput::BufFileInput( FILE *f, int buf_size )\r
+: input( f ),\r
+  buf( new int[buf_size] ),\r
+  size( buf_size ),\r
+  start( 0 ),\r
+  len( 0 )\r
+{\r
+}\r
+\r
+BufFileInput::~BufFileInput()\r
+{\r
+  delete [] buf;\r
+}\r
+\r
+int BufFileInput::nextChar( void )\r
+{\r
+    if( len > 0 )\r
+    {\r
+        // get char from buffer\r
+        int c = buf[start];\r
+\r
+        if( c != EOF )\r
+        {\r
+            start++; start %= size;\r
+            len--;\r
+        }\r
+        return c;\r
+    } else {\r
+        // get char from file\r
+        int c = getc( input );\r
+\r
+        if( c == EOF )\r
+        {\r
+            // if EOF - put it in the buffer as indicator\r
+            buf[start] = EOF;\r
+            len++;\r
+        }\r
+        return c;\r
+    }\r
+}\r
+\r
+int BufFileInput::lookahead( char* s )\r
+{\r
+    int l = strlen( s );\r
+\r
+    assert( 0 < l && l <= size );\r
+\r
+    while( len < l )\r
+    {\r
+        int c = getc( input );\r
+\r
+        buf[ (start+len) % size ] = c;\r
+\r
+        len++;\r
+\r
+        if( c == EOF ) return 0;\r
+    }\r
+\r
+    for( int i = 0; i < l; i++ )\r
+    {\r
+        if( s[i] != buf[ (start+i) % size ] ) return 0;\r
+    }\r
+    return 1;\r
+}\r
+\r
+// End of file BufFileInput.cpp\r
+\r
diff --git a/Tools/CodeTools/Source/Pccts/h/BufFileInput.h b/Tools/CodeTools/Source/Pccts/h/BufFileInput.h
new file mode 100644 (file)
index 0000000..ea54c0e
--- /dev/null
@@ -0,0 +1,53 @@
+// FILE:        BufFileInput.h\r
+// AUTHOR:      Alexey Demakov (AVD) demakov@kazbek.ispras.ru\r
+// CREATION:    26-JAN-1998\r
+// DESCRIPTION: File Input Stream with lookahead for Scanner\r
+// Tested under Win32 with ANTLR 1.33 MR10 and MSVC 5.0\r
+\r
+// Change History:\r
+//\r
+//   28-May-1998    Add virtual destructor to release buffer\r
+//                  Manfred Kogler (km@cast.uni-linz.ac.at)\r
+//                  (1.33MR14)\r
+\r
+#ifndef BufFileInput_h\r
+#define BufFileInput_h\r
+\r
+#include "pcctscfg.h"\r
+\r
+#include "pccts_stdio.h"\r
+\r
+PCCTS_NAMESPACE_STD\r
+\r
+#include "DLexerBase.h"\r
+\r
+class DllExportPCCTS BufFileInput : public DLGInputStream\r
+{\r
+public:\r
+    // constructor\r
+    // f - input stream\r
+    // buf_size - size of buffer (maximal length for string in is_in)\r
+\r
+    BufFileInput(FILE *f, int buf_size = 8 );\r
+\r
+    virtual ~BufFileInput();\r
+\r
+    // gets next char from stream\r
+\r
+    virtual int nextChar( void );\r
+\r
+    // looks in stream and compares next l characters with s\r
+    // returns the result of comparision\r
+\r
+    int lookahead( char* s );\r
+\r
+private:\r
+    FILE *input; // input stream;\r
+    int* buf;    // buffer\r
+    int  size;   // size of buffer\r
+    int  start;  // position of the first symbol in buffer\r
+    int  len;    // count of characters in buffers\r
+};\r
+\r
+#endif\r
+// end of file BufFileInput.h\r
diff --git a/Tools/CodeTools/Source/Pccts/h/DLG_stream_input.h b/Tools/CodeTools/Source/Pccts/h/DLG_stream_input.h
new file mode 100644 (file)
index 0000000..d2147f5
--- /dev/null
@@ -0,0 +1,98 @@
+\r
+/************************************************************/\r
+/*                                                                                                                     */\r
+/*             Predefined char stream: Input from (c++) stream.        */\r
+/*                                                                                                                     */\r
+/* By Hubert Holin (Hubert.Holin@Bigfoot.com), 1998.           */\r
+/*                                                                                                                     */\r
+/* This is completely free stuff, do whatever you want with    */\r
+/* it (but then, I will take no responsability for whatever    */\r
+/* may happen if you do either... caveat emptor!).                     */\r
+/*                                                                                                                     */\r
+/************************************************************/\r
+\r
+#ifndef _DLG_STREAM_INPUT_H\r
+#define _DLG_STREAM_INPUT_H\r
+\r
+#include "pccts_istream.h"\r
+\r
+PCCTS_NAMESPACE_STD\r
+\r
+#ifndef DLGX_H\r
+#include "DLexerBase.h"\r
+#endif\r
+\r
+\r
+// NOTES:      The semantics of the copy constructor\r
+//                     and the affectation operator may be unwaranted...\r
+//                     and the stream may not be reset.\r
+//\r
+//                     It would have been so much nicer for nextChar()\r
+//                     to throw (of for the DLGInputStream to change status)\r
+//                     upon hiting EOF than to return an "int"...\r
+\r
+template       <\r
+                               class E,\r
+                               class T = ::std::char_traits<E>\r
+                       >\r
+class DLG_stream_input : public DLGInputStream\r
+{\r
+public:\r
+       \r
+                                               DLG_stream_input(::std::basic_istream<E,T> * p_input_stream)\r
+       :       input(p_input_stream)\r
+       {\r
+               // nothing to do!\r
+       };\r
+       \r
+                                               DLG_stream_input(const DLG_stream_input & a_recopier)\r
+       :       input(a_recopier.input)\r
+       {\r
+               // nothing to do!\r
+       };\r
+       \r
+       virtual                         ~DLG_stream_input()\r
+       {\r
+               this->purge();  // bloody templarized lookup...\r
+       };\r
+       \r
+       DLG_stream_input        operator = (const DLG_stream_input & a_affecter)\r
+       {\r
+               if (this != &a_affecter)\r
+               {\r
+                       input = a_affecter.input;\r
+               }\r
+\r
+               return(*this);\r
+       };\r
+       \r
+       virtual int                     nextChar()\r
+       {\r
+               E       extracted_stuff;\r
+               \r
+               input->get(extracted_stuff);\r
+               \r
+               if      (*input)\r
+               {\r
+                       return(int(extracted_stuff));\r
+               }\r
+               else\r
+               {\r
+                       return(EOF);\r
+               }\r
+       };\r
+       \r
+protected:\r
+       \r
+       ::std::basic_istream<E,T> *     input;\r
+       \r
+private:\r
+       \r
+       void    purge()\r
+       {\r
+               // nothing to do!\r
+       };\r
+};\r
+\r
+#endif /* _DLG_STREAM_INPUT_H */\r
+\r
diff --git a/Tools/CodeTools/Source/Pccts/h/DLexer.h b/Tools/CodeTools/Source/Pccts/h/DLexer.h
new file mode 100644 (file)
index 0000000..37cac24
--- /dev/null
@@ -0,0 +1,191 @@
+/* DLexer.h (formerly DLexer.cpp)\r
+ *\r
+ * This was renamed because the use of the .cpp extension caused problems\r
+ * with IDEs.\r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
+ * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
+ * company may do whatever they wish with source code distributed with\r
+ * PCCTS or the code generated by PCCTS, including the incorporation of\r
+ * PCCTS, or its output, into commerical software.\r
+ *\r
+ * We encourage users to develop software with PCCTS.  However, we do ask\r
+ * that credit is given to us for developing PCCTS.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like PCCTS and have developed a nice tool with the\r
+ * output, please mention that you developed it using PCCTS.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * ANTLR 1.33\r
+ * Terence Parr\r
+ * Parr Research Corporation\r
+ * with Purdue University and AHPCRC, University of Minnesota\r
+ * 1989-2000\r
+ */\r
+\r
+#define ZZINC {if ( track_columns ) (++_endcol);}\r
+\r
+#define ZZGETC {ch = input->nextChar(); cl = ZZSHIFT(ch);}\r
+\r
+#define ZZNEWSTATE     (newstate = dfa[state][cl])\r
+\r
+#ifndef ZZCOPY\r
+#define ZZCOPY \\r
+       /* Truncate matching buffer to size (not an error) */   \\r
+       if (nextpos < lastpos){                         \\r
+               *(nextpos++) = ch;                      \\r
+       }else{                                                  \\r
+               bufovf = 1;                                     \\r
+       }\r
+#endif\r
+\r
+void DLGLexer::\r
+mode( int m )\r
+{\r
+       /* points to base of dfa table */\r
+       if (m<MAX_MODE){\r
+               automaton = m;\r
+               /* have to redo class since using different compression */\r
+               cl = ZZSHIFT(ch);\r
+       }else{\r
+               sprintf((char *)ebuf,"Invalid automaton mode = %d ",m);\r
+               errstd(ebuf);\r
+       }\r
+}\r
+\r
+ANTLRTokenType DLGLexer::\r
+nextTokenType(void)\r
+{\r
+       register int state, newstate;\r
+       /* last space reserved for the null char */\r
+       register DLGChar *lastpos;\r
+       ANTLRTokenType tk;\r
+\r
+skip:\r
+       bufovf = 0;\r
+       lastpos = &_lextext[_bufsize-1];\r
+       nextpos = _lextext;\r
+       _begcol = _endcol+1;\r
+more:\r
+       _begexpr = nextpos;\r
+       if ( interactive ) {\r
+               /* interactive version of automaton */\r
+               /* if there is something in ch, process it */\r
+               state = newstate = dfa_base[automaton];\r
+               if (charfull){\r
+                       ZZINC;\r
+                       ZZCOPY;\r
+                       ZZNEWSTATE;\r
+               }\r
+               while (alternatives[newstate]){\r
+                       state = newstate;\r
+                       ZZGETC;\r
+                       ZZINC;\r
+                       ZZCOPY;\r
+                       ZZNEWSTATE;\r
+               }\r
+               /* figure out if last character really part of token */\r
+               if ((state != dfa_base[automaton]) && (newstate == DfaStates)){\r
+                       charfull = 1;\r
+                       --nextpos;\r
+               }else{\r
+                       charfull = 0;\r
+                       state = newstate;\r
+               }\r
+               *(nextpos) = '\0';\r
+               /* Able to transition out of start state to some non err state?*/\r
+               if ( state == dfa_base[automaton] ){\r
+                       /* make sure doesn't get stuck */\r
+                       advance();\r
+               }\r
+       }\r
+       else { /* non-interactive version of automaton */\r
+               if (!charfull)\r
+                       advance();\r
+               else\r
+                       ZZINC;\r
+               state = dfa_base[automaton];\r
+               while (ZZNEWSTATE != DfaStates) {\r
+                       state = newstate;\r
+                       ZZCOPY;\r
+                       ZZGETC;\r
+                       ZZINC;\r
+               }\r
+               charfull = 1;\r
+               if ( state == dfa_base[automaton] ){\r
+                       if (nextpos < lastpos){\r
+                               *(nextpos++) = ch;\r
+                       }else{\r
+                               bufovf = 1;\r
+                       }\r
+                       *nextpos = '\0';\r
+                       /* make sure doesn't get stuck */\r
+                       advance();\r
+               }else{\r
+                       *nextpos = '\0';\r
+               }\r
+       }\r
+       if ( track_columns ) _endcol -= charfull;\r
+       _endexpr = nextpos -1;\r
+       add_erase = 0;\r
+#ifdef OLD\r
+       tk = (ANTLRTokenType)\r
+                (*actions[accepts[state]])(this);      // must pass this manually\r
+                                                                                       // actions is not a [] of pointers\r
+                                                                                       // to member functions.\r
+#endif\r
+       tk = (this->*actions[accepts[state]])();\r
+\r
+// MR1\r
+// MR1 11-Apr-97  Help for tracking DLG results\r
+// MR1\r
+\r
+#ifdef DEBUG_LEXER\r
+\r
+/* MR1 */        if (debugLexerFlag) {\r
+/* MR1 */         if (parser != NULL) {\r
+/* MR1 */           /* MR23 */ printMessage(stdout, "\ntoken name=%s",parser->parserTokenName(tk));\r
+/* MR1 */         } else {\r
+/* MR1 */           /* MR23 */ printMessage(stdout, "\ntoken nnumber=%d",tk);\r
+/* MR1 */         };\r
+/* MR1 */         /* MR23 */ printMessage(stdout, " lextext=(%s) mode=%d",\r
+/* MR1 */               (_lextext[0]=='\n' && _lextext[1]==0) ?\r
+/* MR1 */                      "newline" : _lextext,\r
+/* MR1 */                              automaton);\r
+/* MR1 */          if (interactive && !charfull) {\r
+/* MR1 */           /* MR23 */ printMessage(stdout, " char=empty");\r
+/* MR1 */          } else {\r
+/* MR1 */           if (ch=='\n') {\r
+/* MR1 */             /* MR23 */ printMessage(stdout, " char=newline");\r
+/* MR1 */           } else {\r
+/* MR1 */             /* MR23 */ printMessage(stdout, " char=(%c)",ch);\r
+/* MR1 */           };\r
+/* MR1 */         };\r
+/* MR1 */         /* MR23 */ printMessage(stdout, " %s\n",\r
+/* MR1 */               (add_erase==1 ? "skip()" :\r
+/* MR1 */                add_erase==2 ? "more()" :\r
+/* MR1 */                ""));\r
+/* MR1 */        };\r
+\r
+#endif\r
+\r
+       switch (add_erase) {\r
+               case 1: goto skip;\r
+               case 2: goto more;\r
+       }\r
+       return tk;\r
+}\r
+\r
+void DLGLexer::\r
+advance()\r
+{\r
+       if ( input==NULL ) err_in();\r
+       ZZGETC; charfull = 1; ZZINC;\r
+}\r
diff --git a/Tools/CodeTools/Source/Pccts/h/DLexerBase.cpp b/Tools/CodeTools/Source/Pccts/h/DLexerBase.cpp
new file mode 100644 (file)
index 0000000..b218afc
--- /dev/null
@@ -0,0 +1,302 @@
+/* DLGLexerBase.c\r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
+ * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
+ * company may do whatever they wish with source code distributed with\r
+ * PCCTS or the code generated by PCCTS, including the incorporation of\r
+ * PCCTS, or its output, into commerical software.\r
+ *\r
+ * We encourage users to develop software with PCCTS.  However, we do ask\r
+ * that credit is given to us for developing PCCTS.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like PCCTS and have developed a nice tool with the\r
+ * output, please mention that you developed it using PCCTS.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * ANTLR 1.33\r
+ * Terence Parr\r
+ * Parr Research Corporation\r
+ * with Purdue University and AHPCRC, University of Minnesota\r
+ * 1989-2000\r
+ */\r
+\r
+#include "pcctscfg.h"\r
+\r
+#include "pccts_stdio.h"\r
+#include "pccts_stdlib.h"\r
+\r
+PCCTS_NAMESPACE_STD\r
+\r
+/* I have to put this here due to C++ limitation\r
+ * that you can't have a 'forward' decl for enums.\r
+ * I hate C++!!!!!!!!!!!!!!!\r
+ */\r
+\r
+// MR1\r
+// MR1  10-Apr-97  133MR1  Prevent use of varying sizes for the\r
+// MR1                         ANTLRTokenType enum\r
+// MR1\r
+\r
+enum ANTLRTokenType { TER_HATES_CPP=0, ITS_UTTER_GARBAGE,              // MR1\r
+                                        WITH_SOME_GOOD_IDEAS=9999};    // MR1\r
+\r
+#define ANTLR_SUPPORT_CODE\r
+\r
+#include "pcctscfg.h"\r
+#include DLEXERBASE_H\r
+#include APARSER_H             // MR23\r
+\r
+DLGLexerBase::\r
+DLGLexerBase(DLGInputStream *in,\r
+            unsigned bufsize,\r
+            int _interactive,\r
+            int _track_columns)\r
+{\r
+       this->_bufsize = bufsize;\r
+       this->_lextext = new DLGChar[_bufsize];\r
+       if ( this->_lextext==NULL ) {\r
+           panic("text buffer is NULL");\r
+       }\r
+       this->_begexpr = this->_endexpr = NULL;\r
+       this->ch = this->bufovf = 0;\r
+       this->nextpos = NULL;\r
+       this->cl = 0;\r
+       this->add_erase = 0;\r
+       this->input = in;\r
+       this->_begcol = 0;\r
+       this->_endcol = 0;\r
+       this->_line = 1;\r
+       this->charfull = 0;\r
+       this->automaton = 0;\r
+       this->token_to_fill = NULL;\r
+       this->interactive = _interactive;\r
+       this->track_columns = _track_columns;\r
+       this->debugLexerFlag = 0;                                       // MR1\r
+       this->parser = NULL;                                            // MR1\r
+    this->lexErrCount=0;                        // MR11\r
+}\r
+\r
+// MR19  THM \r
+\r
+void DLGLexerBase::reset()\r
+{\r
+       this->charfull = 0;\r
+       this->_begcol = 0;\r
+       this->_endcol = 0;\r
+       this->automaton = 0;\r
+       this->_line=1;\r
+       this->lexErrCount=0;\r
+}\r
+\r
+void DLGLexerBase::\r
+setInputStream( DLGInputStream *in )\r
+{\r
+       this->input = in;\r
+       _line = 1;\r
+       charfull = 0;\r
+}\r
+\r
+/* saves dlg state, but not what feeds dlg (such as file position) */\r
+void DLGLexerBase::\r
+saveState(DLGState *state)\r
+{\r
+       state->input = input;\r
+       state->interactive = interactive;\r
+       state->track_columns = track_columns;\r
+       state->auto_num = automaton;\r
+       state->add_erase = add_erase;\r
+       state->lookc = ch;\r
+       state->char_full = charfull;\r
+       state->begcol = _begcol;\r
+       state->endcol = _endcol;\r
+       state->line = _line;\r
+       state->lextext = _lextext;\r
+       state->begexpr = _begexpr;\r
+       state->endexpr = _endexpr;\r
+       state->bufsize = _bufsize;\r
+       state->bufovf = bufovf;\r
+       state->nextpos = nextpos;\r
+       state->class_num = cl;\r
+       state->debugLexerFlag = debugLexerFlag;                         // MR1\r
+       state->parser = parser;                                         // MR1\r
+}\r
+\r
+void DLGLexerBase::\r
+restoreState(DLGState *state)\r
+{\r
+       input = state->input;\r
+       interactive = state->interactive;\r
+       track_columns = state->track_columns;\r
+       automaton = state->auto_num;\r
+       add_erase = state->add_erase;\r
+       ch = state->lookc;\r
+       charfull = state->char_full;\r
+       _begcol = state->begcol;\r
+       _endcol = state->endcol;\r
+       _line = state->line;\r
+       _lextext = state->lextext;\r
+       _begexpr = state->begexpr;\r
+       _endexpr = state->endexpr;\r
+       _bufsize = state->bufsize;\r
+       bufovf = state->bufovf;\r
+       nextpos = state->nextpos;\r
+       cl = state->class_num;\r
+       debugLexerFlag = state->debugLexerFlag;                         // MR1\r
+       parser = state->parser;                                         // MR1\r
+}\r
+\r
+/* erase what is currently in the buffer, and get a new reg. expr */\r
+void DLGLexerBase::\r
+skip()\r
+{\r
+       add_erase = 1;\r
+}\r
+\r
+/* don't erase what is in the lextext buffer, add on to it */\r
+void DLGLexerBase::\r
+more()\r
+{\r
+       add_erase = 2;\r
+}\r
+\r
+/* substitute c for the reg. expr last matched and is in the buffer */\r
+void DLGLexerBase::\r
+replchar(DLGChar c)\r
+{\r
+       /* can't allow overwriting null at end of string */\r
+       if (_begexpr < &_lextext[_bufsize-1]){\r
+               *_begexpr = c;\r
+               *(_begexpr+1) = '\0';\r
+       }\r
+       _endexpr = _begexpr;\r
+       if (c != '\0') {\r
+               nextpos = _begexpr + 1;\r
+       }\r
+       else {\r
+               nextpos = _begexpr;     /* MR30 Zero terminates string. */\r
+       }\r
+}\r
+\r
+/* replace the string s for the reg. expr last matched and in the buffer */\r
+\r
+#ifdef _MSC_VER  // MR23\r
+//Turn off "assignment within conditional expression" warning\r
+#pragma warning(disable : 4706)\r
+#endif\r
+void DLGLexerBase::\r
+replstr(const DLGChar *s) /* MR20 const */\r
+{\r
+       register DLGChar *l= &_lextext[_bufsize -1];\r
+\r
+       nextpos = _begexpr;\r
+       if (s){\r
+               while ((nextpos <= l) && (*(nextpos++) = *(s++))){\r
+                       /* empty */\r
+               }\r
+               /* correct for NULL at end of string */\r
+               nextpos--;\r
+       }\r
+       if ((nextpos <= l) && (*(--s) == 0)){\r
+               bufovf = 0;\r
+       }else{\r
+               bufovf = 1;\r
+       }\r
+       *(nextpos) = '\0';\r
+       _endexpr = nextpos - 1;\r
+}\r
+#ifdef _MSC_VER  // MR23\r
+#pragma warning(default: 4706)\r
+#endif\r
+\r
+void DLGLexerBase::\r
+errstd(const char *s)                               /* MR20 const */\r
+{\r
+        lexErrCount++;                              /* MR11 */\r
+        /* MR23 */ printMessage(stderr,\r
+                "%s near line %d (text was '%s')\n",\r
+                ((s == NULL) ? "Lexical error" : s),\r
+                _line,_lextext);\r
+}\r
+\r
+int DLGLexerBase::\r
+err_in()\r
+{\r
+       /* MR23 */ printMessage(stderr,"No input stream, function, or string\n");\r
+       /* return eof to get out gracefully */\r
+       return EOF;\r
+}\r
+\r
+ANTLRTokenType DLGLexerBase::\r
+erraction()\r
+{\r
+       errstd("invalid token");\r
+       advance();\r
+       skip();\r
+       return (ANTLRTokenType) 0;      // bogus, but satisfies compiler\r
+}\r
+\r
+_ANTLRTokenPtr DLGLexerBase::\r
+getToken()\r
+{\r
+       if ( token_to_fill==NULL ) panic("NULL token_to_fill");\r
+       ANTLRTokenType tt = nextTokenType();\r
+       _ANTLRTokenPtr tk = token_to_fill->makeToken(tt, _lextext,_line);\r
+       return tk;\r
+}\r
+\r
+void DLGLexerBase::\r
+panic(const char *msg)      /* MR20 const */\r
+{\r
+       if (parser)                             //MR23\r
+               parser->panic(msg);     //MR23\r
+       else                                    //MR23\r
+       {\r
+               /* MR23 */ printMessage(stderr, "DLG panic: %s\n", msg);\r
+       //\r
+       //  7-Apr-97 133MR1\r
+       //\r
+               exit(PCCTS_EXIT_FAILURE);                                       // MR1\r
+       }\r
+}\r
+\r
+ANTLRParser * DLGLexerBase::                                           // MR1\r
+setParser(ANTLRParser *p) {                                            // MR1\r
+  ANTLRParser  *oldValue=parser;                                       // MR1\r
+  parser=p;                                                            // MR1\r
+  return oldValue;                                                     // MR1\r
+}                                                                      // MR1\r
+                                                                       // MR1\r
+ANTLRParser * DLGLexerBase::                                           // MR1\r
+getParser() {                                                          // MR1\r
+  return parser;                                                       // MR1\r
+}                                                                      // MR1\r
+                                                                       // MR1\r
+int DLGLexerBase::                                                     // MR1\r
+debugLexer(int newValue) {                                             // MR1\r
+  int  oldValue=debugLexerFlag;                                        // MR1\r
+  debugLexerFlag=newValue;                                             // MR1\r
+  return oldValue;                                                     // MR1\r
+}                                                                      // MR1\r
+\r
+//MR23\r
+int DLGLexerBase::printMessage(FILE* pFile, const char* pFormat, ...)\r
+{\r
+       va_list marker;\r
+       va_start( marker, pFormat );\r
+\r
+       int iRet = 0;\r
+       if (parser)\r
+               parser->printMessageV(pFile, pFormat, marker);\r
+       else\r
+               iRet = vfprintf(pFile, pFormat, marker);\r
+\r
+       va_end( marker );\r
+       return iRet;\r
+}\r
diff --git a/Tools/CodeTools/Source/Pccts/h/DLexerBase.h b/Tools/CodeTools/Source/Pccts/h/DLexerBase.h
new file mode 100644 (file)
index 0000000..db6cc18
--- /dev/null
@@ -0,0 +1,198 @@
+/* DLGLexerBase.h\r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
+ * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
+ * company may do whatever they wish with source code distributed with\r
+ * PCCTS or the code generated by PCCTS, including the incorporation of\r
+ * PCCTS, or its output, into commerical software.\r
+ *\r
+ * We encourage users to develop software with PCCTS.  However, we do ask\r
+ * that credit is given to us for developing PCCTS.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like PCCTS and have developed a nice tool with the\r
+ * output, please mention that you developed it using PCCTS.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * ANTLR 1.33\r
+ * Terence Parr\r
+ * Parr Research Corporation\r
+ * with Purdue University and AHPCRC, University of Minnesota\r
+ * 1989-2000\r
+ */\r
+\r
+#ifndef DLGX_H\r
+#define DLGX_H\r
+\r
+#include "pcctscfg.h"\r
+#include "pccts_stdio.h"\r
+\r
+PCCTS_NAMESPACE_STD\r
+\r
+#include ATOKEN_H\r
+#include ATOKENSTREAM_H\r
+\r
+class ANTLRParser;                                                     // MR1\r
+\r
+/* must define what a char looks like; can make this a class too */\r
+typedef char DLGChar;\r
+\r
+/*  Can have it as a class too: (ack this looks weird; is it right?)\r
+class DllExportPCCTS DLGChar {\r
+private:\r
+       int c;\r
+public:\r
+       DLGChar(int ch) { c = ch; }\r
+       int atom() { return c; }\r
+};\r
+*/\r
+\r
+/* user must subclass this */\r
+class DllExportPCCTS DLGInputStream {\r
+public:\r
+       virtual int nextChar() = 0;\r
+};\r
+\r
+/* Predefined char stream: Input from FILE */\r
+class DllExportPCCTS DLGFileInput : public DLGInputStream {\r
+private:\r
+       int found_eof;\r
+       FILE *input;\r
+public:\r
+       DLGFileInput(FILE *f) { input = f; found_eof = 0; }\r
+       int nextChar() {\r
+                       int c;\r
+                       if ( found_eof ) return EOF;\r
+                       else {\r
+                               c=getc(input);\r
+                               if ( c==EOF ) found_eof = 1;\r
+                               return c;\r
+                       }\r
+       }\r
+    void DLGFileReset(FILE *f) {input=f; found_eof = 0; };              // MR11\r
+};\r
+\r
+// MR9  Suggested by Bruce Guenter (bruceg@qcc.sk.ca)\r
+// MR9  Make DLGStringInput const correct\r
+\r
+/* Predefined char stream: Input from string */\r
+class DllExportPCCTS DLGStringInput : public DLGInputStream {\r
+private:\r
+       const DLGChar *input;                                           // MR9\r
+       const DLGChar *p;                                               // MR9\r
+public:\r
+       DLGStringInput(const DLGChar *s) { input = s; p = &input[0];}   // MR9\r
+       int nextChar()\r
+               {\r
+                       if (*p) return (int) (unsigned char) *p++;              // MR14\r
+                       else return EOF;\r
+               }\r
+\r
+    void DLGStringReset(const DLGChar *s) {input=s; p= &input[0]; }; // MR11 // MR16\r
+};\r
+\r
+class DllExportPCCTS DLGState {\r
+public:\r
+       DLGInputStream *input;\r
+       int interactive;\r
+       int track_columns;\r
+       int auto_num;\r
+       int add_erase;\r
+       int lookc;\r
+       int char_full;\r
+       int begcol, endcol;\r
+       int line;\r
+       DLGChar *lextext, *begexpr, *endexpr;\r
+       int bufsize;\r
+       int bufovf;\r
+       DLGChar *nextpos;\r
+       int     class_num;\r
+       int     debugLexerFlag;                                         // MR1\r
+       ANTLRParser *parser;                                            // MR1\r
+};\r
+\r
+/* user must subclass this */\r
+class DllExportPCCTS DLGLexerBase : public ANTLRTokenStream {\r
+public:\r
+       virtual ANTLRTokenType erraction();\r
+\r
+protected:\r
+       DLGInputStream *input;\r
+       int interactive;\r
+       int track_columns;\r
+       DLGChar *_lextext;      /* text of most recently matched token */\r
+       DLGChar *_begexpr;      /* beginning of last reg expr recogn. */\r
+       DLGChar *_endexpr;      /* beginning of last reg expr recogn. */\r
+       int     _bufsize;               /* number of characters in lextext */\r
+       int     _begcol;                /* column that first character of token is in*/\r
+       int     _endcol;                /* column that last character of token is in */\r
+       int     _line;                  /* line current token is on */\r
+       int     ch;                             /* character to determine next state */\r
+       int     bufovf;                 /* indicates that buffer too small for text */\r
+       int     charfull;\r
+       DLGChar *nextpos;       /* points to next available position in lextext*/\r
+       int     cl;\r
+       int automaton;\r
+       int     add_erase;\r
+       DLGChar ebuf[70];\r
+       _ANTLRTokenPtr token_to_fill;\r
+\r
+       int     debugLexerFlag;                                         // MR1\r
+       ANTLRParser     *parser;                                        // MR1\r
+public:\r
+       virtual _ANTLRTokenPtr getToken();      // MR12 public\r
+       virtual void advance(void) = 0;\r
+       void    skip(void);             /* erase lextext, look for antoher token */\r
+       void    more(void);             /* keep lextext, look for another token */\r
+       void    mode(int k);    /* switch to automaton 'k' */\r
+       void    saveState(DLGState *);\r
+       void    restoreState(DLGState *);\r
+       virtual ANTLRTokenType nextTokenType(void)=0;/* get next token */\r
+       void    replchar(DLGChar c);    /* replace last recognized reg. expr. with\r
+                                                                        a character */\r
+       void    replstr(const DLGChar *s);      /* replace last recognized reg. expr. with\r
+                                                                        a string */ /* MR20 const */\r
+        virtual int err_in();                                          // MR1\r
+       virtual void errstd(const char *);                              // MR1  MR20 const\r
+       int             line()          { return _line; }\r
+       void    set_line(int newValue)  { _line=newValue; };            // MR1\r
+       virtual void newline()  { _line++; }\r
+       DLGChar *lextext()      { return _lextext; }\r
+\r
+       int             begcol()        { return _begcol; }\r
+       int             endcol()        { return _endcol; }\r
+       void    set_begcol(int a)       { _begcol=a; }\r
+       void    set_endcol(int a)       { _endcol=a; }\r
+       DLGChar *begexpr()      { return _begexpr; }\r
+       DLGChar *endexpr()      { return _endexpr; }\r
+       int             bufsize()       { return _bufsize; }\r
+\r
+       void    setToken(ANTLRAbstractToken *t) { token_to_fill = t; }\r
+\r
+       void    setInputStream(DLGInputStream *);\r
+       DLGLexerBase(DLGInputStream *in,\r
+                                unsigned bufsize=2000,\r
+                                int interactive=0,\r
+                                int track_columns=0);\r
+       void reset();                                                                   // MR19\r
+       virtual ~DLGLexerBase() { delete [] _lextext; }\r
+       virtual void panic(const char *msg);                    // MR1  MR20 const\r
+       void    trackColumns() {\r
+                               track_columns = 1;\r
+                               this->_begcol = 0;\r
+                               this->_endcol = 0;\r
+                       };\r
+       virtual ANTLRParser *setParser(ANTLRParser *p);                 // MR1\r
+       virtual ANTLRParser *getParser();                               // MR1\r
+       virtual int debugLexer(int value);                              // MR1\r
+    int     lexErrCount;                            // MR12\r
+       virtual int printMessage(FILE* pFile, const char* pFormat, ...); // MR23\r
+};\r
+\r
+#endif\r
diff --git a/Tools/CodeTools/Source/Pccts/h/PBlackBox.h b/Tools/CodeTools/Source/Pccts/h/PBlackBox.h
new file mode 100644 (file)
index 0000000..d25b8d6
--- /dev/null
@@ -0,0 +1,134 @@
+#ifndef PBLACKBOX_H\r
+#define PBLACKBOX_H\r
+\r
+/*\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
+ * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
+ * company may do whatever they wish with source code distributed with\r
+ * PCCTS or the code generated by PCCTS, including the incorporation of\r
+ * PCCTS, or its output, into commerical software.\r
+ *\r
+ * We encourage users to develop software with PCCTS.  However, we do ask\r
+ * that credit is given to us for developing PCCTS.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like PCCTS and have developed a nice tool with the\r
+ * output, please mention that you developed it using PCCTS.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * ANTLR 1.33\r
+ * Terence Parr\r
+ * Parr Research Corporation\r
+ * with Purdue University and AHPCRC, University of Minnesota\r
+ * 1989-2000\r
+ */\r
+\r
+/* Completely rewritten by Chris Uzdavinis (chris@atdesk.com) for MR23 */\r
+\r
+#include "pcctscfg.h"\r
+\r
+#include "pccts_iostream.h"\r
+\r
+PCCTS_NAMESPACE_STD\r
+\r
+//  MR20 Added #include for "DLexerBase.h"\r
+\r
+#include "DLexerBase.h"\r
+\r
+//\r
+//  The default buffer size of the lexer is given by the\r
+//   second argument of the lexer's ctor.  It is optional\r
+//   and defaults to 2000\r
+//\r
+\r
+template<class Lexer, class Parser, class Token>\r
+class DllExportPCCTS ParserBlackBox {\r
+private:\r
+  // no copy construction allowed\r
+  ParserBlackBox(ParserBlackBox const &);\r
+\r
+  // no copy assignment allowed\r
+  ParserBlackBox & operator=(ParserBlackBox const &);\r
+  \r
+protected:\r
+  DLGFileInput *in;\r
+  Lexer *scan;\r
+  _ANTLRTokenPtr tok;\r
+  ANTLRTokenBuffer *pipe;\r
+  Parser *_parser;\r
+  FILE *file;\r
+  int openByBlackBox;    /* MR21 Don't close what we haven't opened */\r
+public:\r
+       \r
+  ParserBlackBox(FILE *f)\r
+    : in(0)\r
+    , scan(0)\r
+    , tok(0)\r
+    , pipe(0)\r
+    , _parser(0)\r
+    , file(0)\r
+    , openByBlackBox(0)\r
+  {\r
+    if (f == NULL)\r
+    {\r
+      cerr << "invalid file pointer\n"; \r
+    }\r
+    else\r
+    {\r
+      openByBlackBox = 0;     /* MR21a */\r
+      file = f;\r
+      in = new DLGFileInput(f);\r
+      scan = new Lexer(in);\r
+      pipe = new ANTLRTokenBuffer(scan);\r
+      tok = new Token;\r
+      scan->setToken(tok);\r
+      _parser = new Parser(pipe);\r
+      _parser->init();\r
+    }\r
+  }\r
+  ParserBlackBox(char *fname)\r
+    : in(0)\r
+    , scan(0)\r
+    , tok(0)\r
+    , pipe(0)\r
+    , _parser(0)\r
+    , file(0)\r
+    , openByBlackBox(0)\r
+  {\r
+    FILE *f = fopen(fname, "r");\r
+    if ( f==NULL ) {\r
+      openByBlackBox = 0;\r
+      cerr << "cannot open " << fname << "\n"; return;\r
+    }\r
+    else {\r
+      openByBlackBox = 1;\r
+      file = f;\r
+      in = new DLGFileInput(f);\r
+      scan = new Lexer(in);\r
+      pipe = new ANTLRTokenBuffer(scan);\r
+      tok = new Token;\r
+      scan->setToken(tok);\r
+      _parser = new Parser(pipe);\r
+      _parser->init();\r
+    }\r
+  }\r
+       \r
+  ~ParserBlackBox()\r
+  {\r
+    delete in; delete scan; delete pipe; delete _parser; delete tok;\r
+    if (1 == openByBlackBox) {\r
+      fclose(file);\r
+    }\r
+  }\r
+\r
+  Parser *parser()        { return _parser; }\r
+  Lexer  *getLexer()     { return scan; }\r
+};\r
+\r
+#endif\r
diff --git a/Tools/CodeTools/Source/Pccts/h/PCCTSAST.cpp b/Tools/CodeTools/Source/Pccts/h/PCCTSAST.cpp
new file mode 100644 (file)
index 0000000..a8249cd
--- /dev/null
@@ -0,0 +1,684 @@
+/*\r
+ * PCCTSAST.C\r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to SORCERER -- SORCERER is in the public\r
+ * domain.  An individual or company may do whatever they wish with\r
+ * source code distributed with SORCERER or the code generated by\r
+ * SORCERER, including the incorporation of SORCERER, or its output, into\r
+ * commerical software.\r
+ *\r
+ * We encourage users to develop software with SORCERER.  However, we do\r
+ * ask that credit is given to us for developing SORCERER.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like SORCERER and have developed a nice tool with the\r
+ * output, please mention that you developed it using SORCERER.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * SORCERER 1.00B14 and ANTLR 1.33\r
+ * Terence Parr\r
+ * Parr Research Corporation\r
+ * AHPCRC, University of Minnesota\r
+ * 1992-2000\r
+ */\r
+\r
+#define ANTLR_SUPPORT_CODE\r
+\r
+#include "pcctscfg.h"\r
+\r
+#include "PCCTSAST.h"\r
+#include "pccts_stdarg.h"\r
+\r
+PCCTS_NAMESPACE_STD\r
+\r
+#include <ctype.h>\r
+\r
+//#include "SList.h"\r
+\r
+               /* String Scanning/Parsing Stuff */\r
+\r
+const char *PCCTS_AST::scan_token_tbl[] = {     /* MR20 const */\r
+       "invalid",      /*      0 */\r
+       "LPAREN",       /*      1 */\r
+       "RPAREN",       /*      2 */\r
+       "PERCENT",      /*      3 */\r
+       "INT",          /*      4 */\r
+       "COLON",        /*      5 */\r
+       "POUND",        /*      6 */\r
+       "PERIOD",       /*      7 */\r
+};\r
+\r
+void PCCTS_AST::\r
+addChild(PCCTS_AST *t)\r
+{\r
+       if ( t==NULL ) return;\r
+       PCCTS_AST *s = down();\r
+       if ( s!=NULL )\r
+       {\r
+               while ( s->right()!=NULL ) s = s->right();\r
+               s->setRight(t);\r
+       }\r
+       else\r
+               this->setDown(t);\r
+}\r
+\r
+void PCCTS_AST::\r
+lisp(FILE *f)\r
+{\r
+       if ( down() != NULL ) /* MR23 */ printMessage(f," (");\r
+       lisp_action(f);\r
+       if ( down()!=NULL ) down()->lisp(f);\r
+       if ( down() != NULL ) /* MR23 */ printMessage(f," )");\r
+       if ( right()!=NULL ) right()->lisp(f);\r
+}\r
+\r
+/* build a tree (root child1 child2 ... NULL)\r
+ * If root is NULL, simply make the children siblings and return ptr\r
+ * to 1st sibling (child1).  If root is not single node, return NULL.\r
+ *\r
+ * Siblings that are actually sibling lists themselves are handled\r
+ * correctly.  For example #( NULL, #( NULL, A, B, C), D) results\r
+ * in the tree ( NULL A B C D ).\r
+ *\r
+ * Requires at least two parameters with the last one being NULL.  If\r
+ * both are NULL, return NULL.\r
+ *\r
+ * The down() and right() down/right pointers are used to make the tree.\r
+ */\r
+PCCTS_AST *PCCTS_AST::\r
+make(PCCTS_AST *rt, ...)\r
+{\r
+       va_list ap;\r
+       register PCCTS_AST *child, *sibling=NULL, *tail=NULL /*MR23*/, *w;\r
+       PCCTS_AST *root;\r
+\r
+       va_start(ap, rt);\r
+       root = rt;\r
+\r
+       if ( root != NULL )\r
+               if ( root->down() != NULL ) return NULL;\r
+       child = va_arg(ap, PCCTS_AST *);\r
+       while ( child != NULL )\r
+       {\r
+               /* find end of child */\r
+               for (w=child; w->right()!=NULL; w=w->right()) {;}\r
+               if ( sibling == NULL ) {sibling = child; tail = w;}\r
+               else {tail->setRight(child); tail = w;}\r
+               child = va_arg(ap, PCCTS_AST *);\r
+       }\r
+       if ( root==NULL ) root = sibling;\r
+       else root->setDown(sibling);\r
+       va_end(ap);\r
+       return root;\r
+}\r
+\r
+/* The following push and pop routines are only used by ast_find_all() */\r
+\r
+void PCCTS_AST::\r
+_push(PCCTS_AST **st, int *sp, PCCTS_AST *e)\r
+{\r
+       (*sp)--;\r
+       require((*sp)>=0, "stack overflow");\r
+       st[(*sp)] = e;\r
+}\r
+\r
+PCCTS_AST *PCCTS_AST::\r
+_pop(PCCTS_AST **st, int *sp)\r
+{\r
+       PCCTS_AST *e = st[*sp];\r
+       (*sp)++;\r
+       require((*sp)<=MaxTreeStackDepth, "stack underflow");\r
+       return e;\r
+}\r
+\r
+/* Find all occurrences of u in t.\r
+ * 'cursor' must be initialized to 't'.  It eventually\r
+ * returns NULL when no more occurrences of 'u' are found.\r
+ */\r
+PCCTS_AST *PCCTS_AST::\r
+ast_find_all(PCCTS_AST *u, PCCTS_AST **cursor)\r
+{\r
+       PCCTS_AST *sib;\r
+       /*** static ***/ PCCTS_AST *template_stack[MaxTreeStackDepth];  /* MR23 Remove "static" */\r
+       /*** static ***/ int tsp = MaxTreeStackDepth;                   /* MR23 Remove "static" */\r
+\r
+////static int nesting = 0;                                         /* MR23 Not referenced */\r
+\r
+       if ( *cursor == NULL ) return NULL;\r
+       if ( *cursor!=this ) sib = *cursor;\r
+       else {\r
+               /* else, first time--start at top of template 't' */\r
+               tsp = MaxTreeStackDepth;\r
+               sib = this;\r
+               /* bottom of stack is always a NULL--"cookie" indicates "done" */\r
+               _push(template_stack, &tsp, NULL);\r
+       }\r
+\r
+keep_looking:\r
+       if ( sib==NULL )        /* hit end of sibling list */\r
+       {\r
+               sib = _pop(template_stack, &tsp);\r
+               if ( sib == NULL ) { *cursor = NULL; return NULL; }\r
+       }\r
+\r
+       if ( sib->type() != u->type() )\r
+       {\r
+               /* look for another match */\r
+               if ( sib->down()!=NULL )\r
+               {\r
+                       if ( sib->right()!=NULL ) _push(template_stack, &tsp, sib->right());\r
+                       sib=sib->down();\r
+                       goto keep_looking;\r
+               }\r
+               /* nothing below to try, try next sibling */\r
+               sib=sib->right();\r
+               goto keep_looking;\r
+       }\r
+\r
+       /* found a matching root node, try to match what's below */\r
+       if ( match_partial(sib, u) )\r
+       {\r
+               /* record sibling cursor so we can pick up next from there */\r
+               if ( sib->down()!=NULL )\r
+               {\r
+                       if ( sib->right()!=NULL ) _push(template_stack, &tsp, sib->right());\r
+                       *cursor = sib->down();\r
+               }\r
+               else if ( sib->right()!=NULL ) *cursor = sib->right();\r
+               else *cursor = _pop(template_stack, &tsp);\r
+               return sib;\r
+       }\r
+\r
+       /* no match, keep searching */\r
+       if ( sib->down()!=NULL )\r
+       {\r
+               if ( sib->right()!=NULL ) _push(template_stack, &tsp, sib->right());\r
+               sib=sib->down();\r
+       }\r
+       else sib = sib->right();        /* else, try to right if zip below */\r
+       goto keep_looking;\r
+}\r
+\r
+/* are two trees exactly alike? */\r
+int PCCTS_AST::\r
+match(PCCTS_AST *u)\r
+{\r
+       PCCTS_AST *t = this;\r
+       PCCTS_AST *sib;\r
+\r
+       if ( u==NULL ) return 0;\r
+\r
+       for (sib=t; sib!=NULL&&u!=NULL; sib=sib->right(), u=u->right())\r
+       {\r
+               if ( sib->type() != u->type() ) return 0;\r
+               if ( sib->down()!=NULL )\r
+                       if ( !sib->down()->match(u->down()) ) return 0;\r
+       }\r
+       return 1;\r
+}\r
+\r
+/* Is 'u' a subtree of 't' beginning at the root? */\r
+int PCCTS_AST::\r
+match_partial(PCCTS_AST *t, PCCTS_AST *u)\r
+{\r
+       PCCTS_AST *sib;\r
+\r
+       if ( u==NULL ) return 1;\r
+       if ( t==NULL ) return 0; /* MR23 removed unreachable code */\r
+\r
+       for (sib=t; sib!=NULL&&u!=NULL; sib=sib->right(), u=u->right())\r
+       {\r
+               if ( sib->type() != u->type() ) return 0;\r
+               if ( sib->down()!=NULL )\r
+                       if ( !match_partial(sib->down(), u->down()) ) return 0;\r
+       }\r
+       return 1;\r
+}\r
+\r
+#ifdef _MSC_VER  // MR23\r
+//Turn off "unreachable code" warning\r
+#pragma warning(disable : 4702)\r
+#endif\r
+/* Walk the template tree 't' (matching against 'this'), filling in the\r
+ * 'labels' array, and setting 'n' according to how many labels were matched.\r
+ */\r
+int PCCTS_AST::\r
+scanmatch(ScanAST *t, PCCTS_AST **labels[], int *n)\r
+{\r
+       ScanAST *sib;\r
+       PCCTS_AST *u = this;\r
+\r
+       if ( u==NULL ) return 0;\r
+\r
+       for (sib=t; sib!=NULL&&u!=NULL; sib=sib->right(), u=u->right())\r
+       {\r
+               /* make sure tokens match; token of '0' means wildcard match */\r
+               if ( sib->type() != u->type() && sib->type()!=0 ) return 0;\r
+               /* we have a matched token here; set label pointers if exists */\r
+               if ( sib->label_num>0 )\r
+               {\r
+                       require(labels!=NULL, "label found in template, but no array of labels");\r
+                       (*n)++;\r
+                       *(labels[sib->label_num-1]) = u;\r
+               }\r
+               /* match what's below if something there and current node is not wildcard */\r
+               if ( sib->down()!=NULL && sib->type()!=0 )\r
+               {\r
+                       if ( sib->down()==NULL ) \r
+                       {\r
+                               if ( u->down()!=NULL ) \r
+                                       return 0; \r
+                               else \r
+                                       return 1;\r
+                       }\r
+                       if ( !u->down()->scanmatch(sib->down(), labels, n) ) return 0;\r
+               }\r
+       }\r
+       return 1;\r
+}\r
+#ifdef _MSC_VER  // MR23\r
+#pragma warning(default : 4702)\r
+#endif\r
+\r
+void PCCTS_AST::\r
+insert_after(PCCTS_AST *b)\r
+{\r
+       PCCTS_AST *end;\r
+       if ( b==NULL ) return;\r
+       /* find end of b's child list */\r
+       for (end=b; end->right()!=NULL; end=end->right()) {;}\r
+       end->setRight(this->right());\r
+       this->setRight(b);\r
+}\r
+\r
+void PCCTS_AST::\r
+append(PCCTS_AST *b)\r
+{\r
+       PCCTS_AST *end;\r
+       require(b!=NULL, "append: NULL input tree");\r
+       /* find end of child list */\r
+       for (end=this; end->right()!=NULL; end=end->right()) {;}\r
+       end->setRight(b);\r
+}\r
+\r
+PCCTS_AST *PCCTS_AST::\r
+tail()\r
+{\r
+       PCCTS_AST *end;\r
+       /* find end of child list */\r
+       for (end=this; end->right()!=NULL; end=end->right()) {;}\r
+       return end;\r
+}\r
+\r
+PCCTS_AST *PCCTS_AST::\r
+bottom()\r
+{\r
+       PCCTS_AST *end;\r
+       /* find end of child list */\r
+       for (end=this; end->down()!=NULL; end=end->down()) {;}\r
+       return end;\r
+}\r
+\r
+PCCTS_AST *PCCTS_AST::\r
+cut_between(PCCTS_AST *a, PCCTS_AST *b)\r
+{\r
+       PCCTS_AST *end, *ret;\r
+       if (a==NULL||b==NULL) return NULL;\r
+       /* find node pointing to b */\r
+       for (end=a; end->right()!=NULL&&end->right()!=b; end=end->right())\r
+               {;}\r
+       if (end->right()==NULL) return NULL; //ast_cut_between: a,b not connected\r
+       end->setRight(NULL);    /* don't want it point to 'b' anymore */\r
+       ret = a->right();\r
+       a->setRight(b);\r
+       return ret;\r
+}\r
+\r
+#ifdef NOT_YET\r
+SList *PCCTS_AST::\r
+to_slist()\r
+{\r
+       SList *list = new SList;\r
+       PCCTS_AST *p;\r
+\r
+       for (p=this; p!=NULL; p=p->right())\r
+       {\r
+               list->add(p);\r
+       }\r
+       return list;\r
+}\r
+#endif\r
+\r
+void PCCTS_AST::\r
+tfree()\r
+{\r
+       PCCTS_AST *t = this;\r
+    if ( t->down()!=NULL ) t->down()->tfree();\r
+    if ( t->right()!=NULL ) t->right()->tfree();\r
+    delete t;\r
+}\r
+\r
+int PCCTS_AST::\r
+nsiblings()\r
+{\r
+       PCCTS_AST *t = this;\r
+       int n=0;\r
+\r
+       while ( t!=NULL )\r
+       {\r
+               n++;\r
+               t = t->right();\r
+       }\r
+       return n;\r
+}\r
+\r
+PCCTS_AST *PCCTS_AST::\r
+sibling_index(int i)\r
+{\r
+       PCCTS_AST *t = this;\r
+       int j=1;\r
+       require(i>0, "sibling_index: i<=0");\r
+\r
+       while ( t!=NULL )\r
+       {\r
+               if ( j==i ) return t;\r
+               j++;\r
+               t = t->right();\r
+       }\r
+       return NULL;\r
+}\r
+\r
+/* Assume this is a root node of a tree--\r
+ * duplicate that node and what's below; ignore siblings of root node.\r
+ */\r
+\r
+// MR9 23-Sep-97 RJV\r
+// MR9\r
+// MR9 RJV: Original version only duplicated the node and down elements.\r
+// MR9      Made copies of the pointers to sibling.\r
+// MR9      Changed call "down()->deepCopy()" to "down()->deepCopyBushy()"\r
+// MR9\r
+\r
+PCCTS_AST *PCCTS_AST::\r
+deepCopy()\r
+{\r
+       PCCTS_AST *u = this->shallowCopy();\r
+       if ( down()!=NULL ) u->setDown(down()->deepCopyBushy());\r
+    u->setRight(NULL);\r
+       return u;\r
+}\r
+\r
+/* Copy all nodes including siblings of root. */\r
+PCCTS_AST *PCCTS_AST::\r
+deepCopyBushy()\r
+{\r
+       PCCTS_AST *u = this->shallowCopy();\r
+       /* copy the rest of the tree */\r
+       if ( down()!=NULL ) u->setDown(down()->deepCopyBushy());\r
+       if ( right()!=NULL ) u->setRight(right()->deepCopyBushy());\r
+       return u;\r
+}\r
+\r
+void PCCTS_AST::\r
+scanast_free(ScanAST *t)\r
+{\r
+    if ( t == NULL ) return;\r
+    scanast_free( t->down() );\r
+    scanast_free( t->right() );\r
+    free( (char *) t );                                                        // MR1\r
+}\r
+\r
+/*\r
+ * scan\r
+ *\r
+ * This function is like scanf(): it attempts to match a template\r
+ * against an input tree.  A variable number of tree pointers\r
+ * may be set according to the '%i' labels in the template string.\r
+ * For example:\r
+ *\r
+ *   t->ast_scan("#( 6 #(5 %1:4 %2:3) #(1 %3:3 %4:3) )",\r
+ *            &w, &x, &y, &z);\r
+ *\r
+ * Naturally, you'd want this converted from\r
+ *\r
+ *      t->ast_scan("#( RangeOp #(Minus %1:IConst %2:Var) #(Plus %3:Var %4Var) )",\r
+ *                       &w, &x, &y, &z);\r
+ *\r
+ * by SORCERER.\r
+ *\r
+ * This function call must be done withing a SORCERER file because SORCERER\r
+ * must convert the token references to the associated token number.\r
+ *\r
+ * This functions parses the template and creates trees which are then\r
+ * matched against the input tree.  The labels are set as they are\r
+ * encountered; hence, partial matches may leave some pointers set\r
+ * and some NULL.  This routines initializes all argument pointers to NULL\r
+ * at the beginning.\r
+ *\r
+ * This function returns the number of labels matched.\r
+ */\r
+int PCCTS_AST::\r
+ast_scan(char *templ, ...)\r
+{\r
+       va_list ap;\r
+       ScanAST *tmpl;\r
+       int n, i, found=0;\r
+       PCCTS_AST ***label_ptrs=NULL;\r
+\r
+       va_start(ap, templ);\r
+\r
+       /* make a ScanAST tree out of the template */\r
+       tmpl = stringparser_parse_scanast(templ, &n);\r
+\r
+       /* make an array out of the labels */\r
+       if ( n>0 )\r
+       {\r
+               label_ptrs = (PCCTS_AST ***) calloc(n, sizeof(PCCTS_AST **));\r
+               require(label_ptrs!=NULL, "scan: out of memory");\r
+               for (i=1; i<=n; i++)\r
+               {\r
+                       label_ptrs[i-1] = va_arg(ap, PCCTS_AST **);\r
+                       *(label_ptrs[i-1]) = NULL;\r
+               }\r
+       }\r
+\r
+       /* match the input tree against the template */\r
+       scanmatch(tmpl, label_ptrs, &found);\r
+\r
+       scanast_free(tmpl);\r
+       free( (char *) label_ptrs);                                     // MR1\r
+\r
+       return found;\r
+}\r
+\r
+ScanAST *PCCTS_AST::\r
+new_scanast(int tok)\r
+{\r
+    ScanAST *p = (ScanAST *) calloc(1, sizeof(ScanAST));\r
+//\r
+//  7-Apr-97 133MR1\r
+//\r
+    if ( p == NULL )\r
+        panic("out of memory\n");                      // MR23\r
+       p->_token = tok;\r
+       return p;\r
+}\r
+\r
+ScanAST *PCCTS_AST::\r
+stringparser_parse_scanast(char *templ, int *num_labels)\r
+{\r
+       StringLexer lex;\r
+       StringParser parser;\r
+       ScanAST *t;\r
+\r
+       stringlexer_init(&lex, templ);\r
+       stringparser_init(&parser, &lex);\r
+       t = stringparser_parse_tree(&parser);\r
+       *num_labels = parser.num_labels;\r
+       return t;\r
+}\r
+\r
+void PCCTS_AST::\r
+stringparser_match(StringParser *parser, int token)\r
+{\r
+       if ( parser->token != token ) panic("bad tree in scan()");\r
+}\r
+\r
+/*\r
+ * Match a tree of the form:\r
+ *             (root child1 child2 ... childn)\r
+ * or,\r
+ *             node\r
+ *\r
+ * where the elements are integers or labeled integers.\r
+ */\r
+ScanAST *PCCTS_AST::\r
+stringparser_parse_tree(StringParser *parser)\r
+{\r
+       ScanAST *t=NULL, *root, *child, *last=NULL /*MR23*/;\r
+\r
+       if ( parser->token != __POUND )\r
+       {\r
+               return stringparser_parse_element(parser);\r
+       }\r
+       stringparser_match(parser,__POUND);\r
+       parser->token = stringscan_gettok(parser->lexer);\r
+       stringparser_match(parser,__LPAREN);\r
+       parser->token = stringscan_gettok(parser->lexer);\r
+       root = stringparser_parse_element(parser);\r
+       while ( parser->token != __RPAREN )\r
+       {\r
+               child = stringparser_parse_element(parser);\r
+               if ( t==NULL ) { t = child; last = t; }\r
+               else { last->_right = child; last = child; }\r
+       }\r
+       stringparser_match(parser,__RPAREN);\r
+       parser->token = stringscan_gettok(parser->lexer);\r
+       root->_down = t;\r
+       return root;\r
+}\r
+\r
+ScanAST *PCCTS_AST::\r
+stringparser_parse_element(StringParser *parser)\r
+{\r
+       char ebuf[100];\r
+       int label = 0;\r
+\r
+       if ( parser->token == __POUND )\r
+       {\r
+               return stringparser_parse_tree(parser);\r
+       }\r
+       if ( parser->token == __PERCENT )\r
+       {\r
+               parser->token = stringscan_gettok(parser->lexer);\r
+               stringparser_match(parser,__INT);\r
+               label = atoi(parser->lexer->text);\r
+               parser->num_labels++;\r
+               if ( label==0 ) panic("%%0 is an invalid label");\r
+               parser->token = stringscan_gettok(parser->lexer);\r
+               stringparser_match(parser,__COLON);\r
+               parser->token = stringscan_gettok(parser->lexer);\r
+               /* can label tokens and wildcards */\r
+               if ( parser->token != __INT && parser->token != __PERIOD )\r
+                       panic("can only label tokens");\r
+       }\r
+       if ( parser->token == __INT )\r
+       {\r
+               ScanAST *p = new_scanast(atoi(parser->lexer->text));\r
+               parser->token = stringscan_gettok(parser->lexer);\r
+               p->label_num = label;\r
+               return p;\r
+       }\r
+       if ( parser->token == __PERIOD )\r
+       {\r
+               ScanAST *p = new_scanast(0);    /* token of 0 is wildcard */\r
+               parser->token = stringscan_gettok(parser->lexer);\r
+               p->label_num = label;\r
+               return p;\r
+       }\r
+       sprintf(ebuf, "mismatch token in scan(): %s", scan_token_str(parser->token));\r
+       panic(ebuf);\r
+       return NULL;\r
+}\r
+\r
+void PCCTS_AST::\r
+stringparser_init(StringParser *parser, StringLexer *input)\r
+{\r
+       parser->lexer = input;\r
+       parser->token = stringscan_gettok(parser->lexer);\r
+       parser->num_labels = 0;\r
+}\r
+\r
+void PCCTS_AST::\r
+stringlexer_init(StringLexer *scanner, char *input)\r
+{\r
+       scanner->text[0]='\0';\r
+       scanner->input = input;\r
+       scanner->p = input;\r
+       stringscan_advance(scanner);\r
+}\r
+\r
+void PCCTS_AST::\r
+stringscan_advance(StringLexer *scanner)\r
+{\r
+       if ( *(scanner->p) == '\0' ) scanner->c = __StringScanEOF;\r
+       scanner->c = *(scanner->p)++;\r
+}\r
+\r
+int PCCTS_AST::\r
+stringscan_gettok(StringLexer *scanner)\r
+{\r
+       char *index = &scanner->text[0];\r
+       char ebuf[100]; /* MR23 Remove static */\r
+\r
+       while ( isspace(scanner->c) ) { stringscan_advance(scanner); }\r
+       if ( isdigit(scanner->c) )\r
+       {\r
+               int tok = __INT;\r
+               while ( isdigit(scanner->c) ) {\r
+                       *index++ = (char) /* static_cast<char> */ (scanner->c);     // MR23\r
+                       stringscan_advance(scanner);\r
+               }\r
+               *index = '\0';\r
+               return tok;\r
+       }\r
+       switch ( scanner->c )\r
+       {\r
+               case '#' : stringscan_advance(scanner); return __POUND;\r
+               case '(' : stringscan_advance(scanner); return __LPAREN;\r
+               case ')' : stringscan_advance(scanner); return __RPAREN;\r
+               case '%' : stringscan_advance(scanner); return __PERCENT;\r
+               case ':' : stringscan_advance(scanner); return __COLON;\r
+               case '.' : stringscan_advance(scanner); return __PERIOD;\r
+               case '\0' : return __StringScanEOF;\r
+               case __StringScanEOF : return __StringScanEOF;\r
+               default  :\r
+                       sprintf(ebuf, "invalid char in scan: '%c'", scanner->c);\r
+                       panic(ebuf);\r
+       }\r
+       return __StringScanEOF; // never reached\r
+}\r
+\r
+const char *PCCTS_AST:: /* MR20 const */\r
+scan_token_str(int t)\r
+{\r
+       if ( VALID_SCAN_TOKEN(t) ) return scan_token_tbl[t];\r
+       else if ( t==__StringScanEOF ) return "<end-of-string>";\r
+       else return "<invalid-token>";\r
+}\r
+\r
+//MR23\r
+int PCCTS_AST::printMessage(FILE* pFile, const char* pFormat, ...)\r
+{\r
+       va_list marker;\r
+       va_start( marker, pFormat );\r
+       int iRet = vfprintf(pFile, pFormat, marker);\r
+       va_end( marker );\r
+       return iRet;\r
+}\r
diff --git a/Tools/CodeTools/Source/Pccts/h/PCCTSAST.h b/Tools/CodeTools/Source/Pccts/h/PCCTSAST.h
new file mode 100644 (file)
index 0000000..3485da7
--- /dev/null
@@ -0,0 +1,143 @@
+/* Abstract syntax tree\r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
+ * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
+ * company may do whatever they wish with source code distributed with\r
+ * PCCTS or the code generated by PCCTS, including the incorporation of\r
+ * PCCTS, or its output, into commerical software.\r
+ *\r
+ * We encourage users to develop software with PCCTS.  However, we do ask\r
+ * that credit is given to us for developing PCCTS.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like PCCTS and have developed a nice tool with the\r
+ * output, please mention that you developed it using PCCTS.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * ANTLR 1.33\r
+ * Terence Parr\r
+ * Parr Research Corporation\r
+ * with Purdue University and AHPCRC, University of Minnesota\r
+ * 1989-2000\r
+ */\r
+\r
+#ifndef PCCTSAST_H\r
+#define PCCTSAST_H\r
+\r
+#include "pcctscfg.h"\r
+\r
+#include "pccts_stdio.h"\r
+#include "pccts_stdlib.h"\r
+\r
+PCCTS_NAMESPACE_STD\r
+\r
+//class SList;\r
+\r
+#define StringScanMaxText      50\r
+#define MaxTreeStackDepth      400\r
+\r
+//\r
+//  7-Apr-97 133MR1    signed int not accepted by AT&T cfront\r
+//\r
+typedef struct stringlexer {\r
+                       int c;                                          // MR1\r
+                       char *input;\r
+                       char *p;\r
+                       char text[StringScanMaxText];\r
+               } StringLexer;\r
+\r
+/* Define the structures needed for ast_scan() */\r
+typedef struct stringparser {\r
+                       int token;\r
+                       StringLexer *lexer;\r
+                       int num_labels;\r
+               } StringParser;\r
+\r
+typedef struct _scanast {\r
+            struct _scanast *_right, *_down;\r
+            int _token;\r
+                       int label_num;\r
+                       int type() { return _token; }\r
+                       struct _scanast *right() { return _right; }\r
+                       struct _scanast *down() { return _down; }\r
+        } ScanAST;\r
+\r
+#define VALID_SCAN_TOKEN(t)            (t>=__LPAREN && t<=__PERIOD)\r
+\r
+class DllExportPCCTS PCCTS_AST {\r
+protected:\r
+       static const char *scan_token_tbl[];    /* MR20 const */\r
+       enum {\r
+       __LPAREN=1,\r
+       __RPAREN=2,\r
+       __PERCENT=3,\r
+       __INT=4,\r
+       __COLON=5,\r
+       __POUND=6,\r
+       __PERIOD=7,\r
+       __StringScanEOF=-1};\r
+\r
+protected:\r
+       const char *scan_token_str(int t);  /* MR20 const */\r
+       void stringlexer_init(StringLexer *scanner, char *input);\r
+       void stringparser_init(StringParser *, StringLexer *);\r
+       ScanAST *stringparser_parse_scanast(char *templ, int *n);\r
+       ScanAST *stringparser_parse_tree(StringParser *parser);\r
+       ScanAST *stringparser_parse_element(StringParser *parser);\r
+       void stringscan_advance(StringLexer *scanner);\r
+       int stringscan_gettok(StringLexer *scanner);\r
+       void _push(PCCTS_AST **st, int *sp, PCCTS_AST *e);\r
+       PCCTS_AST *_pop(PCCTS_AST **st, int *sp);\r
+       int match_partial(PCCTS_AST *t, PCCTS_AST *u);\r
+       int scanmatch(ScanAST *t, PCCTS_AST **labels[], int *n);\r
+       void scanast_free(ScanAST *t);\r
+       ScanAST *new_scanast(int tok);\r
+       void stringparser_match(StringParser *parser, int type);\r
+       virtual PCCTS_AST *deepCopyBushy();\r
+\r
+public:\r
+       PCCTS_AST()     {;}\r
+       virtual ~PCCTS_AST() {;}\r
+\r
+       /* This group must be defined for SORCERER to work correctly */\r
+       virtual PCCTS_AST *right() = 0;\r
+       virtual PCCTS_AST *down() = 0;\r
+       virtual void setRight(PCCTS_AST *t) = 0;\r
+       virtual void setDown(PCCTS_AST *t) = 0;\r
+// we define these so ANTLR doesn't have to\r
+       virtual int type() { return 0; }\r
+       virtual void setType(int /*t MR23 */) {;}\r
+       virtual PCCTS_AST *shallowCopy() {panic("no shallowCopy() defined"); return NULL;}\r
+\r
+       /* These are not needed by ANTLR, but are support functions */\r
+       virtual PCCTS_AST *deepCopy();  // used by SORCERER in transform mode\r
+       virtual void addChild(PCCTS_AST *t);\r
+       virtual void lisp_action(FILE * /*f MR23 */) {;}\r
+       virtual void lisp(FILE *f);\r
+       static PCCTS_AST *make(PCCTS_AST *rt, ...);\r
+       virtual PCCTS_AST *ast_find_all(PCCTS_AST *u, PCCTS_AST **cursor);\r
+       virtual int match(PCCTS_AST *u);\r
+       virtual void insert_after(PCCTS_AST *b);\r
+       virtual void append(PCCTS_AST *b);\r
+       virtual PCCTS_AST *tail();\r
+       virtual PCCTS_AST *bottom();\r
+       static  PCCTS_AST *cut_between(PCCTS_AST *a, PCCTS_AST *b);\r
+//     virtual SList *to_slist();\r
+       virtual void tfree();\r
+       int ast_scan(char *templ, ...);\r
+       virtual int nsiblings();\r
+       virtual PCCTS_AST *sibling_index(int i);\r
+\r
+       void require(int e,const char *err){ if ( !e ) panic(err); } /* MR20 const */\r
+       virtual void panic(const char *err)     // MR20 const\r
+               { /* MR23 */ printMessage(stderr, "PCCTS_AST: %s\n", err); exit(PCCTS_EXIT_FAILURE); }\r
+       virtual int printMessage(FILE* pFile, const char* pFormat, ...); // MR23\r
+};\r
+\r
+#endif /* PCCTSAST_H */\r
diff --git a/Tools/CodeTools/Source/Pccts/h/SList.h b/Tools/CodeTools/Source/Pccts/h/SList.h
new file mode 100644 (file)
index 0000000..5b8bf97
--- /dev/null
@@ -0,0 +1,72 @@
+#ifndef SList_h\r
+#define SList_h\r
+\r
+/*\r
+ * SList.h\r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to SORCERER -- SORCERER is in the public\r
+ * domain.  An individual or company may do whatever they wish with\r
+ * source code distributed with SORCERER or the code generated by\r
+ * SORCERER, including the incorporation of SORCERER, or its output, into\r
+ * commerical software.\r
+ *\r
+ * We encourage users to develop software with SORCERER.  However, we do\r
+ * ask that credit is given to us for developing SORCERER.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like SORCERER and have developed a nice tool with the\r
+ * output, please mention that you developed it using SORCERER.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * PCCTS 1.33\r
+ * Terence Parr\r
+ * Parr Research Corporation\r
+ * with Purdue University and AHPCRC, University of Minnesota\r
+ * 1992-2000\r
+ */\r
+\r
+#include "pcctscfg.h"\r
+\r
+#include "pccts_stdio.h"\r
+#include "pccts_stdlib.h"\r
+\r
+PCCTS_NAMESPACE_STD\r
+\r
+#include "PCCTSAST.h"\r
+\r
+class PCCTS_AST;\r
+\r
+class SListNode {\r
+protected:\r
+       void *_elem;                    /* pointer to any kind of element */\r
+       SListNode *_next;\r
+public:\r
+       SListNode()                             {_elem=_next=NULL;}\r
+       virtual ~SListNode()    {_elem=_next=NULL;}\r
+       void *elem()                    { return _elem; }\r
+       void setElem(void *e)   { _elem = e; }\r
+       void setNext(SListNode *t)      { _next = t; }\r
+       SListNode *next()               { return _next; }\r
+};\r
+\r
+class SList {\r
+       SListNode *head, *tail;\r
+public:\r
+       SList() {head=tail=NULL;}\r
+       virtual ~SList() {head=tail=NULL;}\r
+       virtual void *iterate(SListNode **);\r
+       virtual void add(void *e);\r
+       virtual void lfree();\r
+       virtual PCCTS_AST *to_ast(SList list);\r
+       virtual void require(int e,char *err){ if ( !e ) panic(err); }\r
+       virtual void panic(char *err){ /* MR23 */ printMessage(stderr, "SList panic: %s\n", err); exit(PCCTS_EXIT_FAILURE); }\r
+       virtual int printMessage(FILE* pFile, const char* pFormat, ...); // MR23\r
+};\r
+\r
+#endif\r
diff --git a/Tools/CodeTools/Source/Pccts/h/antlr.h b/Tools/CodeTools/Source/Pccts/h/antlr.h
new file mode 100644 (file)
index 0000000..8066453
--- /dev/null
@@ -0,0 +1,807 @@
+/* antlr.h \r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
+ * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
+ * company may do whatever they wish with source code distributed with\r
+ * PCCTS or the code generated by PCCTS, including the incorporation of\r
+ * PCCTS, or its output, into commerical software.\r
+ *\r
+ * We encourage users to develop software with PCCTS.  However, we do ask\r
+ * that credit is given to us for developing PCCTS.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like PCCTS and have developed a nice tool with the\r
+ * output, please mention that you developed it using PCCTS.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * ANTLR 1.33\r
+ * Terence Parr\r
+ * Parr Research Corporation\r
+ * with Purdue University and AHPCRC, University of Minnesota\r
+ * 1989-2000\r
+ */\r
+\r
+#ifndef ANTLR_H\r
+#define ANTLR_H\r
+\r
+#include "pcctscfg.h"\r
+\r
+#include "pccts_stdio.h"\r
+\r
+/* turn off warnings for unreferenced labels */\r
+\r
+#ifdef _MSC_VER\r
+#pragma warning(disable:4102)\r
+#endif\r
+\r
+/*\r
+ * Define all of the stack setup and manipulation of $i, #i variables.\r
+ *\r
+ *     Notes:\r
+ *             The type 'Attrib' must be defined before entry into this .h file.\r
+ */\r
+\r
+\r
+#ifdef __USE_PROTOS\r
+#include "pccts_stdlib.h"\r
+#else\r
+#ifdef VAXC\r
+#include <stdlib.h>\r
+#else\r
+#include <malloc.h>\r
+#endif\r
+#endif\r
+#include "pccts_string.h"\r
+\r
+#if 0\r
+#include "set.h"\r
+#endif\r
+\r
+\r
+typedef int ANTLRTokenType;\r
+typedef unsigned char SetWordType;\r
+\r
+typedef char ANTLRChar;\r
+\r
+                                               /* G u e s s  S t u f f */\r
+\r
+#ifdef ZZCAN_GUESS\r
+#ifndef ZZINF_LOOK\r
+#define ZZINF_LOOK\r
+#endif\r
+#endif\r
+\r
+#ifdef ZZCAN_GUESS\r
+typedef struct _zzjmp_buf {\r
+                       jmp_buf state;\r
+               } zzjmp_buf;\r
+#endif\r
+\r
+\r
+/* can make this a power of 2 for more efficient lookup */\r
+\r
+#ifndef ZZLEXBUFSIZE\r
+#define ZZLEXBUFSIZE   8000 /* MR22 raise from 2k to 8k */\r
+#endif\r
+\r
+#define zzOvfChk                                                                                                               \\r
+            if ( zzasp <= 0 )                                           \\r
+            {                                                           \\r
+                fprintf(stderr, zzStackOvfMsg, __FILE__, __LINE__);            \\r
+                exit(PCCTS_EXIT_FAILURE);                                               \\r
+            }\r
+\r
+#ifndef ZZA_STACKSIZE\r
+#define ZZA_STACKSIZE  400\r
+#endif\r
+#ifndef ZZAST_STACKSIZE\r
+#define ZZAST_STACKSIZE        400\r
+#endif\r
+\r
+#ifndef zzfailed_pred\r
+#ifdef ZZCAN_GUESS\r
+#define zzfailed_pred(_p,_hasuseraction,_useraction) \\r
+  if (zzguessing) { \\r
+    zzGUESS_FAIL; \\r
+  } else { \\r
+    zzfailed_pred_action(_p,_hasuseraction,_useraction); \\r
+  }\r
+#else\r
+#define zzfailed_pred(_p,_hasuseraction,_useraction) \\r
+    zzfailed_pred_action(_p,_hasuseraction,_useraction);\r
+#endif\r
+#endif\r
+\r
+/*  MR23            Provide more control over failed predicate action\r
+                    without any need for user to worry about guessing internals.\r
+                    _hasuseraction == 0 => no user specified error action\r
+                    _hasuseraction == 1 => user specified error action\r
+*/\r
+\r
+#ifndef zzfailed_pred_action\r
+#define zzfailed_pred_action(_p,_hasuseraction,_useraction) \\r
+    if (_hasuseraction) { _useraction } \\r
+    else { fprintf(stderr, "semantic error; failed predicate: '%s'\n",_p); }\r
+#endif\r
+\r
+/* MR19 zzchar_t additions */\r
+\r
+#ifdef LL_K\r
+#define LOOKAHEAD \\r
+       int zztokenLA[LL_K]; \\r
+       zzchar_t zztextLA[LL_K][ZZLEXBUFSIZE]; \\r
+       int zzlap = 0, zzlabase=0; /* labase only used for DEMAND_LOOK */\r
+#else\r
+#define LOOKAHEAD                                                                                              \\r
+       int zztoken;\r
+#endif\r
+\r
+#ifndef zzcr_ast\r
+#define zzcr_ast(ast,attr,tok,text)\r
+#endif\r
+\r
+#ifdef DEMAND_LOOK\r
+#define DemandLookData  int zzdirty=1;\r
+#else\r
+#define DemandLookData\r
+#endif\r
+\r
+#ifndef zzUSER_GUESS_HOOK\r
+#define zzUSER_GUESS_HOOK(seqFrozen,zzrv)\r
+#endif\r
+\r
+#ifndef zzUSER_GUESS_DONE_HOOK\r
+#define zzUSER_GUESS_DONE_HOOK(seqFrozen)\r
+#endif\r
+\r
+                                               /* S t a t e  S t u f f */\r
+\r
+#ifdef ZZCAN_GUESS\r
+#define zzGUESS_BLOCK          zzantlr_state zzst; int zzrv; int zzGuessSeqFrozen;\r
+\r
+/* MR10 change zzGUESS: do zzGUESS_DONE when zzrv==1 after longjmp as in C++ mode */\r
+\r
+#define zzGUESS                                zzsave_antlr_state(&zzst); \\r
+                                                       zzguessing = 1; \\r
+                            zzGuessSeqFrozen=++zzGuessSeq; \\r
+                                                       zzrv = setjmp(zzguess_start.state); \\r
+                            zzUSER_GUESS_HOOK(zzGuessSeqFrozen,zzrv) \\r
+                            if (zzrv) zzGUESS_DONE;\r
+#ifdef zzTRACE_RULES\r
+#define zzGUESS_FAIL           { zzTraceGuessFail(); longjmp(zzguess_start.state, 1); }\r
+#else\r
+#define zzGUESS_FAIL           longjmp(zzguess_start.state, 1)\r
+#endif\r
+\r
+/* MR10 change zzGUESS_DONE: zzrv=1 to simulate longjmp() return value as in C++ mode */\r
+\r
+#define zzGUESS_DONE           { zzrestore_antlr_state(&zzst); zzrv=1; zzUSER_GUESS_DONE_HOOK(zzGuessSeqFrozen) }\r
+#define zzNON_GUESS_MODE       if ( !zzguessing )\r
+#define zzGuessData                                     \\r
+            zzjmp_buf zzguess_start;                    \\r
+            int zzguessing;\r
+#else\r
+#define zzGUESS_BLOCK\r
+#define zzGUESS\r
+#define zzGUESS_FAIL\r
+#define zzGUESS_DONE\r
+#define zzNON_GUESS_MODE\r
+#define zzGuessData\r
+#endif\r
+\r
+typedef struct _zzantlr_state {\r
+#ifdef ZZCAN_GUESS\r
+                       zzjmp_buf guess_start;\r
+                       int guessing;\r
+#endif\r
+                       int asp;\r
+                       int ast_sp;\r
+#ifdef ZZINF_LOOK\r
+                       int inf_lap;    /* not sure we need to save this one */\r
+                       int inf_labase;\r
+                       int inf_last;\r
+\r
+/* MR6         Gunnar Rxnning (gunnar@candleweb.no)                                */\r
+/* MR6   Additional state needs to be saved/restored                       */\r
+/* MR6    Matching changes in err.h                                         */\r
+\r
+                       int *inf_tokens;                                             /* MR6 */\r
+                       char **inf_text;                                             /* MR6 */\r
+                       char *inf_text_buffer;                                       /* MR6 */\r
+                       int *inf_line;                                               /* MR6 */\r
+#endif\r
+#ifdef DEMAND_LOOK\r
+                       int dirty;\r
+#endif\r
+\r
+#ifdef LL_K\r
+                       int tokenLA[LL_K];\r
+                       char textLA[LL_K][ZZLEXBUFSIZE];\r
+                       int lap;\r
+                       int labase;\r
+#else\r
+                       int token;\r
+                       char text[ZZLEXBUFSIZE];\r
+#endif\r
+#ifdef zzTRACE_RULES\r
+            int     traceOptionValue;       /* MR10 */\r
+            int     traceGuessOptionValue;  /* MR10 */\r
+            char    *traceCurrentRuleName;  /* MR10 */\r
+            int     traceDepth;             /* MR10 */\r
+#endif\r
+\r
+               } zzantlr_state;\r
+\r
+#ifdef zzTRACE_RULES\r
+extern int  zzTraceOptionValueDefault;\r
+extern int  zzTraceOptionValue;\r
+extern int  zzTraceGuessOptionValue;\r
+extern char *zzTraceCurrentRuleName;\r
+extern int  zzTraceDepth;\r
+#endif\r
+\r
+extern int zzGuessSeq;                      /* MR10 */\r
+extern int zzSyntaxErrCount;                /* MR11 */\r
+extern int zzLexErrCount;                   /* MR11 */\r
+\r
+                 /* I n f i n i t e  L o o k a h e a d */\r
+\r
+\r
+#ifdef ZZINF_LOOK\r
+#define InfLookData    \\r
+       int *zzinf_tokens;      \\r
+       char **zzinf_text;      \\r
+       char *zzinf_text_buffer;        \\r
+       int *zzinf_line;        \\r
+       int zzinf_labase;       \\r
+       int zzinf_last;\r
+#else\r
+#define InfLookData\r
+#endif\r
+\r
+#ifdef ZZINF_LOOK\r
+\r
+#ifndef ZZINF_DEF_TEXT_BUFFER_SIZE\r
+#define ZZINF_DEF_TEXT_BUFFER_SIZE         20000\r
+#endif\r
+#ifndef ZZINF_DEF_TOKEN_BUFFER_SIZE\r
+#define ZZINF_DEF_TOKEN_BUFFER_SIZE        2000\r
+#endif\r
+/* WARNING!!!!!!\r
+ * ZZINF_BUFFER_TEXT_CHUNK_SIZE must be > sizeof(text) largest possible token.\r
+ */\r
+#ifndef ZZINF_BUFFER_TEXT_CHUNK_SIZE\r
+#define ZZINF_BUFFER_TEXT_CHUNK_SIZE   5000\r
+#endif\r
+#ifndef ZZINF_BUFFER_TOKEN_CHUNK_SIZE\r
+#define ZZINF_BUFFER_TOKEN_CHUNK_SIZE  1000\r
+#endif\r
+\r
+#if ZZLEXBUFSIZE > ZZINF_BUFFER_TEXT_CHUNK_SIZE\r
+#define ZZINF_BUFFER_TEXT_CHUNK_SIZE   ZZLEXBUFSIZE+5\r
+#endif\r
+\r
+/* make inf_look user-access macros */\r
+#ifdef LL_K\r
+#define ZZINF_LA_VALID(i)      (((zzinf_labase+i-1)-LL_K+1) <= zzinf_last)\r
+#define ZZINF_LA(i)                    zzinf_tokens[(zzinf_labase+i-1)-LL_K+1]\r
+#define ZZINF_LATEXT(i)                zzinf_text[(zzinf_labase+i-1)-LL_K+1]\r
+/* MR6 In 1.33 vanilla the #define ZZINF_LINE(i) is was commented out  */\r
+#define ZZINF_LINE(i)       zzinf_line[(zzinf_labase+i-1)-LL_K+1]\r
+#else\r
+#define ZZINF_LA_VALID(i)      (((zzinf_labase+i-1)) <= zzinf_last)\r
+#define ZZINF_LA(i)                    zzinf_tokens[(zzinf_labase+i-1)]\r
+#define ZZINF_LATEXT(i)                zzinf_text[(zzinf_labase+i-1)]\r
+#endif\r
+\r
+#define inf_zzgettok _inf_zzgettok()\r
+extern void _inf_zzgettok();\r
+\r
+#endif /* ZZINF_LOOK */\r
+\r
+\r
+#ifdef LL_K\r
+\r
+#ifdef __USE_PROTOS\r
+#define ANTLR_INFO     \\r
+       Attrib zzempty_attr(void) {static Attrib a; return a;} \\r
+       Attrib zzconstr_attr(int _tok, char *_text) \\r
+               {Attrib a; zzcr_attr((&a),_tok,_text); return a;} \\r
+       int zzasp=ZZA_STACKSIZE; \\r
+       char zzStackOvfMsg[]="fatal: attrib/AST stack overflow %s(%d)!\n"; \\r
+       Attrib zzaStack[ZZA_STACKSIZE]; DemandLookData \\r
+       InfLookData \\r
+    zzGuessData\r
+#else\r
+#define ANTLR_INFO                                                                                             \\r
+       Attrib zzempty_attr() {static Attrib a; return a;}                  \\r
+       Attrib zzconstr_attr(_tok, _text) int _tok; char *_text;    \\r
+               {Attrib a; zzcr_attr((&a),_tok,_text); return a;}           \\r
+       int zzasp=ZZA_STACKSIZE;                                            \\r
+       char zzStackOvfMsg[]="fatal: attrib/AST stack overflow %s(%d)!\n";  \\r
+       Attrib zzaStack[ZZA_STACKSIZE]; DemandLookData                      \\r
+       InfLookData                                                 \\r
+    zzGuessData\r
+#endif\r
+\r
+#else\r
+\r
+#ifdef __USE_PROTOS\r
+#define ANTLR_INFO                                                                                             \\r
+       Attrib zzempty_attr(void) {static Attrib a; return a;}                  \\r
+       Attrib zzconstr_attr(int _tok, char *_text)                             \\r
+               {Attrib a; zzcr_attr((&a),_tok,_text); return a;}               \\r
+       int zzasp=ZZA_STACKSIZE;                                                \\r
+       char zzStackOvfMsg[]="fatal: attrib/AST stack overflow %s(%d)!\n";      \\r
+       Attrib zzaStack[ZZA_STACKSIZE]; DemandLookData                          \\r
+       InfLookData                                                             \\r
+    zzGuessData\r
+#else\r
+#define ANTLR_INFO                                                                                             \\r
+       Attrib zzempty_attr() {static Attrib a; return a;}                      \\r
+       Attrib zzconstr_attr(_tok, _text) int _tok; char *_text;                \\r
+               {Attrib a; zzcr_attr((&a),_tok,_text); return a;}               \\r
+       int zzasp=ZZA_STACKSIZE;                                                \\r
+       char zzStackOvfMsg[]="fatal: attrib/AST stack overflow %s(%d)!\n";      \\r
+       Attrib zzaStack[ZZA_STACKSIZE]; DemandLookData                          \\r
+       InfLookData                                                             \\r
+    zzGuessData\r
+#endif\r
+       \r
+#endif /* LL_k */\r
+\r
+\r
+#ifdef ZZINF_LOOK\r
+\r
+#ifdef LL_K\r
+#ifdef DEMAND_LOOK\r
+#define zzPrimeLookAhead  {zzdirty=LL_K; zzlap = zzlabase = 0;}\r
+#else\r
+#define zzPrimeLookAhead  {zzlap = zzlabase = 0; zzfill_inf_look();\\r
+                                                 {int _i;  for(_i=1;_i<=LL_K; _i++)            \\r
+                                                                               {zzCONSUME;} zzlap = zzlabase = 0;}}\r
+#endif\r
+\r
+#else /* LL_K */\r
+\r
+#ifdef DEMAND_LOOK\r
+#define zzPrimeLookAhead  zzfill_inf_look(); zzdirty=1\r
+#else\r
+#define zzPrimeLookAhead  zzfill_inf_look(); inf_zzgettok\r
+\r
+#endif\r
+#endif /* LL_K */\r
+\r
+#else  /* ZZINF_LOOK */\r
+\r
+#ifdef LL_K\r
+#ifdef DEMAND_LOOK\r
+#define zzPrimeLookAhead  {zzdirty=LL_K; zzlap = zzlabase = 0;}\r
+#else\r
+#define zzPrimeLookAhead  {int _i; zzlap = 0; for(_i=1;_i<=LL_K; _i++)         \\r
+                                                                               {zzCONSUME;} zzlap = 0;}\r
+#endif\r
+\r
+#else\r
+\r
+#ifdef DEMAND_LOOK\r
+#define zzPrimeLookAhead  zzdirty=1\r
+#else\r
+#define zzPrimeLookAhead  zzgettok()\r
+#endif\r
+#endif /* LL_K */\r
+\r
+#endif /* ZZINF_LOOK */\r
+\r
+\r
+#ifdef LL_K\r
+#define zzenterANTLRs(s)                            \\r
+        zzlextext = &(zztextLA[0][0]); zzrdstr( s ); zzPrimeLookAhead;\r
+#define zzenterANTLRf(f)                                                       \\r
+               zzlextext = &(zztextLA[0][0]); zzrdfunc( f ); zzPrimeLookAhead;\r
+#define zzenterANTLR(f)                                                        \\r
+               zzlextext = &(zztextLA[0][0]); zzrdstream( f ); zzPrimeLookAhead;\r
+#ifdef ZZINF_LOOK\r
+#define zzleaveANTLR(f)                        free(zzinf_text_buffer); free(zzinf_text); free(zzinf_tokens); free(zzinf_line);\r
+#define zzleaveANTLRf(f)               free(zzinf_text_buffer); free(zzinf_text); free(zzinf_tokens); free(zzinf_line);\r
+#define zzleaveANTLRs(f)               free(zzinf_text_buffer); free(zzinf_text); free(zzinf_tokens); free(zzinf_line);\r
+#else\r
+#define zzleaveANTLR(f)\r
+#define zzleaveANTLRf(f)\r
+#define zzleaveANTLRs(f)\r
+#endif\r
+\r
+#else\r
+\r
+#define zzenterANTLRs(s)                            \\r
+        {static char zztoktext[ZZLEXBUFSIZE];   \\r
+        zzlextext = zztoktext; zzrdstr( s ); zzPrimeLookAhead;}\r
+#define zzenterANTLRf(f)                                                       \\r
+               {static char zztoktext[ZZLEXBUFSIZE];   \\r
+               zzlextext = zztoktext; zzrdfunc( f ); zzPrimeLookAhead;}\r
+#define zzenterANTLR(f)                                                        \\r
+               {static char zztoktext[ZZLEXBUFSIZE];   \\r
+               zzlextext = zztoktext; zzrdstream( f ); zzPrimeLookAhead;}\r
+#ifdef ZZINF_LOOK\r
+#define zzleaveANTLR(f)                        free(zzinf_text_buffer); free(zzinf_text); free(zzinf_tokens); free(zzinf_line);\r
+#define zzleaveANTLRf(f)               free(zzinf_text_buffer); free(zzinf_text); free(zzinf_tokens); free(zzinf_line);\r
+#define zzleaveANTLRs(f)               free(zzinf_text_buffer); free(zzinf_text); free(zzinf_tokens); free(zzinf_line);\r
+#else\r
+#define zzleaveANTLR(f)\r
+#define zzleaveANTLRf(f)\r
+#define zzleaveANTLRs(f)\r
+#endif\r
+\r
+#endif\r
+\r
+/* MR19 Paul D. Smith (psmith@baynetworks.com)\r
+   Need to adjust AST stack pointer at exit.\r
+   Referenced in ANTLRx macros.\r
+*/\r
+\r
+#ifdef GENAST\r
+#define ZZAST_ADJUST ++zzast_sp;\r
+#else\r
+#define ZZAST_ADJUST\r
+#endif\r
+\r
+#define ANTLR(st, f)   zzbufsize = ZZLEXBUFSIZE;       \\r
+                                               zzenterANTLR(f);                        \\r
+            {                                            \\r
+              zzBLOCK(zztasp1);                          \\r
+                                                 st; /* ++zzasp; Removed MR20 G. Hobbelt */     \\r
+                                                     /* ZZAST_ADJUST Removed MR20 G. Hobbelt */ \\r
+              /* MR20 G. Hobbelt. Kill the top' attribute (+AST stack corr.) */  \\r
+              zzEXIT_ANTLR(zztasp1 + 1);                 \\r
+            }                                            \\r
+                                               zzleaveANTLR(f);\r
+                                               \r
+#define ANTLRm(st, f, _m)      zzbufsize = ZZLEXBUFSIZE;       \\r
+                                               zzmode(_m);                             \\r
+                                               zzenterANTLR(f);                        \\r
+            {                                            \\r
+              zzBLOCK(zztasp1);                          \\r
+                                                 st; /* ++zzasp; Removed MR20 G. Hobbelt */     \\r
+                                                     /* ZZAST_ADJUST Removed MR20 G. Hobbelt */ \\r
+              /* MR20 G. Hobbelt. Kill the top' attribute (+AST stack corr.) */  \\r
+              zzEXIT_ANTLR(zztasp1 + 1);                 \\r
+            }                                            \\r
+                                               zzleaveANTLR(f);\r
+                                               \r
+#define ANTLRf(st, f)  zzbufsize = ZZLEXBUFSIZE;       \\r
+                                               zzenterANTLRf(f);                       \\r
+            {                                            \\r
+              zzBLOCK(zztasp1);                          \\r
+                                                 st; /* ++zzasp; Removed MR20 G. Hobbelt */     \\r
+                                                     /* ZZAST_ADJUST Removed MR20 G. Hobbelt */ \\r
+              /* MR20 G. Hobbelt. Kill the top' attribute (+AST stack corr.) */  \\r
+              zzEXIT_ANTLR(zztasp1 + 1);                 \\r
+            }                                            \\r
+                                               zzleaveANTLRf(f);\r
+\r
+#define ANTLRs(st, s)   zzbufsize = ZZLEXBUFSIZE;      \\r
+                        zzenterANTLRs(s);           \\r
+            {                                            \\r
+              zzBLOCK(zztasp1);                          \\r
+                                                 st; /* ++zzasp; Removed MR20 G. Hobbelt */     \\r
+                                                     /* ZZAST_ADJUST Removed MR20 G. Hobbelt */ \\r
+              /* MR20 G. Hobbelt. Kill the top' attribute (+AST stack corr.) */  \\r
+              zzEXIT_ANTLR(zztasp1 + 1);                 \\r
+            }                                            \\r
+                        zzleaveANTLRs(s);\r
+\r
+#ifdef LL_K\r
+#define zztext         (&(zztextLA[zzlap][0]))\r
+#else\r
+#define zztext         zzlextext\r
+#endif\r
+\r
+\r
+                                       /* A r g u m e n t  A c c e s s */\r
+\r
+#define zzaCur                 (zzaStack[zzasp])\r
+#define zzaRet                 (*zzaRetPtr)\r
+#define zzaArg(v,n)            zzaStack[v-n]\r
+#define zzMakeAttr             { zzNON_GUESS_MODE {zzOvfChk; --zzasp; zzcr_attr(&(zzaStack[zzasp]),LA(1),LATEXT(1));}}\r
+#ifdef zzdef0\r
+#define zzMake0                        { zzOvfChk; --zzasp; zzdef0(&(zzaStack[zzasp]));}\r
+#else\r
+#define zzMake0                        { zzOvfChk; --zzasp;}\r
+#endif\r
+#define zzaPush(_v)            { zzOvfChk; zzaStack[--zzasp] = _v;}\r
+#ifndef zzd_attr\r
+#define zzREL(t)               zzasp=(t);              /* Restore state of stack */\r
+#else\r
+#define zzREL(t)               for (; zzasp<(t); zzasp++)                              \\r
+                                               { zzd_attr(&(zzaStack[zzasp])); }\r
+#endif\r
+\r
+\r
+#define zzsetmatch(_es,_tokclassErrset)                                                \\r
+       if ( !_zzsetmatch(_es, &zzBadText, &zzMissText, &zzMissTok, &zzBadTok, &zzMissSet, _tokclassErrset) ) goto fail; /* MR23 */\r
+\r
+#ifdef ZZCAN_GUESS\r
+#define zzsetmatch_wsig(_es, handler)          \\r
+       if ( !_zzsetmatch_wsig(_es) ) if (zzguessing) { zzGUESS_FAIL; } else {_signal=MismatchedToken; goto handler;}\r
+#else\r
+#define zzsetmatch_wsig(_es, handler)          \\r
+       if ( !_zzsetmatch_wsig(_es) ) {_signal=MismatchedToken; goto handler;}\r
+#endif\r
+\r
+#ifdef __USE_PROTOS\r
+extern int _zzsetmatch(SetWordType *, char **, char **, int *, int *, SetWordType **, SetWordType * /* MR23 */); \r
+extern int _zzsetmatch_wsig(SetWordType *);\r
+#else\r
+extern int _zzsetmatch();\r
+extern int _zzsetmatch_wsig();\r
+#endif\r
+\r
+#define zzmatch(_t)                                                    \\r
+       if ( !_zzmatch(_t, &zzBadText, &zzMissText, &zzMissTok, &zzBadTok, &zzMissSet) ) goto fail;\r
+\r
+#ifdef ZZCAN_GUESS\r
+#define zzmatch_wsig(_t,handler)                       \\r
+       if ( !_zzmatch_wsig(_t) ) if (zzguessing) { zzGUESS_FAIL; } else {_signal=MismatchedToken; goto handler;}\r
+#else\r
+#define zzmatch_wsig(_t,handler)                       \\r
+       if ( !_zzmatch_wsig(_t) ) {_signal=MismatchedToken; goto handler;}\r
+#endif\r
+\r
+#ifdef __USE_PROTOS\r
+extern int _zzmatch(int, char **, char **, int *, int *, SetWordType **);\r
+extern int _zzmatch_wsig(int);\r
+#else\r
+extern int _zzmatch();\r
+extern int _zzmatch_wsig();\r
+#endif\r
+\r
+#define zzmatch_wdfltsig(_t,_f)                        \\r
+       if ( !_zzmatch_wdfltsig(_t,_f) ) _signal=MismatchedToken;\r
+#define zzsetmatch_wdfltsig(tw,tt,wf)          \\r
+       if ( !_zzsetmatch_wdfltsig(tw,tt,wf) ) _signal=MismatchedToken;\r
+\r
+#ifdef __USE_PROTOS\r
+extern int _zzmatch_wdfltsig(int, SetWordType *);\r
+extern int _zzsetmatch_wdfltsig(SetWordType *tokensWanted,\r
+                                                               int tokenTypeOfSet,\r
+                                                               SetWordType *whatFollows);\r
+#else\r
+extern int _zzmatch_wdfltsig();\r
+extern int _zzsetmatch_wdfltsig();\r
+#endif\r
+\r
+#ifdef GENAST\r
+#define zzRULE         Attrib *zzaRetPtr = &(zzaStack[zzasp-1]);       \\r
+                                       SetWordType *zzMissSet=NULL; int zzMissTok=0;           \\r
+                                       int zzBadTok=0; char *zzBadText="";             \\r
+                                       int zzErrk=1,zzpf=0;                                    \\r
+                    zzTRACEdata \\r
+                                       char *zzMissText=""; zzASTVars\r
+#else\r
+#define zzRULE         Attrib *zzaRetPtr = &(zzaStack[zzasp-1]);       \\r
+                                       int zzBadTok=0; char *zzBadText="";             \\r
+                                       int zzErrk=1,zzpf=0;                                                            \\r
+                    zzTRACEdata \\r
+                                       SetWordType *zzMissSet=NULL; int zzMissTok=0; char *zzMissText=""\r
+#endif\r
+\r
+#ifdef GENAST\r
+#define zzBLOCK(i)     int i = zzasp - 1; int zztsp = zzast_sp\r
+#define zzEXIT(i)      zzREL(i); zzastREL; zzNON_GUESS_MODE { zzastPush(*_root); }\r
+#define zzEXIT_ANTLR(i)        zzREL(i); zzastREL /* [i_a] added as we want this for the ANTLRx() macros */\r
+#define zzLOOP(i)      zzREL(i); zzastREL\r
+#else\r
+#define zzBLOCK(i)     int i = zzasp - 1\r
+#define zzEXIT(i)      zzREL(i)\r
+#define zzEXIT_ANTLR(i)        zzREL(i)           /* [i_a] added as we want this for the ANTLRx() macros */\r
+#define zzLOOP(i)      zzREL(i)\r
+#endif\r
+\r
+#ifdef LL_K\r
+\r
+#ifdef DEMAND_LOOK\r
+#define LOOK(_k)       {int i,stop=_k-(LL_K-zzdirty); for (i=1; i<=stop; i++)  \\r
+                                       zzCONSUME;}\r
+#define zzCONSUME      {zzgettok(); zzdirty--;                                                 \\r
+                                       zzlap = (zzlap+1)&(LL_K-1);                                             \\r
+                                       zzlextext = &(zztextLA[zzlap][0]);}\r
+#else\r
+#ifdef ZZINF_LOOK\r
+#define zzCONSUME      {inf_zzgettok;                                                                  \\r
+                                       zzlap = (zzlap+1)&(LL_K-1);                                             \\r
+                                       zzlextext = &(zztextLA[zzlap][0]);                              \\r
+                                       }\r
+#else\r
+#define zzCONSUME      {zzgettok();                                                                    \\r
+                                       zzlap = (zzlap+1)&(LL_K-1);                                             \\r
+                                       zzlextext = &(zztextLA[zzlap][0]);}\r
+#endif /* ZZINF_LOOK */\r
+#endif /* DEMAND_LOOK */\r
+\r
+#else /* LL_K */\r
+\r
+#ifdef DEMAND_LOOK\r
+#define LOOK(_k)       if ( zzdirty) zzCONSUME;\r
+#ifdef ZZINF_LOOK\r
+#define zzCONSUME      inf_zzgettok; zzdirty=0;\r
+#else\r
+#define zzCONSUME      zzgettok(); zzdirty=0;\r
+#endif /* ZZINF_LOOK */\r
+\r
+#else  /* DEMAND_LOOK */\r
+\r
+#ifdef ZZINF_LOOK\r
+#define zzCONSUME      inf_zzgettok\r
+#else\r
+#define zzCONSUME      zzgettok();\r
+#endif\r
+\r
+#endif /* DEMAND_LOOK */\r
+\r
+#endif /* LL_K */\r
+\r
+#ifdef LL_K\r
+#define NLA                    zztokenLA[zzlap&(LL_K-1)]       /* --> next LA */\r
+#define NLATEXT                zztextLA[zzlap&(LL_K-1)]        /* --> next text of LA */\r
+#ifdef DEMAND_LOOK\r
+#define LA(i)       zztokenLA[(zzlabase+(i)-1)&(LL_K-1)]\r
+#define LATEXT(i)   (&(zztextLA[(zzlabase+(i)-1)&(LL_K-1)][0]))\r
+#else\r
+#define LA(i)       zztokenLA[(zzlap+(i)-1)&(LL_K-1)]\r
+#define LATEXT(i)   (&(zztextLA[(zzlap+(i)-1)&(LL_K-1)][0]))\r
+#endif\r
+#else\r
+#define NLA                    zztoken\r
+#define NLATEXT                zztext\r
+#define LA(i)       zztoken\r
+#define LATEXT(i)   zztext\r
+#endif\r
+\r
+\r
+           /* S t a n d a r d  S i g n a l s */\r
+\r
+#define NoSignal                       0\r
+#define MismatchedToken                1\r
+#define NoViableAlt                    2\r
+#define NoSemViableAlt         3\r
+\r
+/* MR7  Allow more control over signalling                                  */\r
+/*        by adding "Unwind" and "zzsetSignal"                              */\r
+\r
+#define Unwind              4\r
+#define zzsetSignal(newValue) *_retsignal=_signal=(newValue)\r
+#define zzsuppressSignal *_retsignal=_signal=0\r
+#define zzexportSignal    *_retsignal=_signal\r
+\r
+           /* F u n c t i o n  T r a c i n g */\r
+\r
+#ifndef zzTRACE_RULES\r
+#define zzTRACEdata\r
+#else\r
+#ifndef zzTRACEdata\r
+#define zzTRACEdata     ANTLRChar *zzTracePrevRuleName = NULL;\r
+#endif\r
+#endif\r
+\r
+#ifndef zzTRACEIN\r
+#define zzTRACEIN(r)   zzTracePrevRuleName=zzTraceCurrentRuleName;zzTraceIn(r);\r
+#endif\r
+#ifndef zzTRACEOUT\r
+#define zzTRACEOUT(r)  zzTraceOut(r);zzTraceCurrentRuleName=zzTracePrevRuleName;\r
+#endif\r
+\r
+/* MR19 zzchar_t additions */\r
+\r
+#ifndef zzchar_t\r
+#ifdef ZZWCHAR_T\r
+#define zzchar_t wchar_t\r
+#else\r
+#define zzchar_t char\r
+#endif\r
+#endif\r
+\r
+\r
+/* MR26 */\r
+\r
+#ifdef PCCTS_USE_STDARG\r
+extern void zzFAIL(int k, ...);\r
+#else\r
+extern void zzFAIL();\r
+#endif\r
+                               /* E x t e r n  D e f s */\r
+\r
+#ifdef __USE_PROTOS\r
+extern Attrib zzempty_attr(void);\r
+extern Attrib zzconstr_attr(int, char *);\r
+extern void zzsyn(char *, int, char *, SetWordType *, int, int, char *);\r
+extern int zzset_el(unsigned, SetWordType *);\r
+extern int zzset_deg(SetWordType *);\r
+extern void zzedecode(SetWordType *);\r
+\r
+extern void zzresynch(SetWordType *, SetWordType);\r
+extern void zzsave_antlr_state(zzantlr_state *);\r
+extern void zzrestore_antlr_state(zzantlr_state *);\r
+extern void zzfill_inf_look(void);\r
+extern void zzconsumeUntil(SetWordType *st);                         /* MR7 */\r
+extern void zzconsumeUntilToken(int t);                              /* MR7 */\r
+extern void zzTraceIn(char * ruleName);                              /* MR10 */\r
+extern void zzTraceOut(char * ruleName);                             /* MR10 */\r
+extern int  zzTraceOption(int delta);                                /* MR10 */\r
+extern int  zzTraceGuessOption(int delta);                           /* MR10 */\r
+extern void zzTraceReset(void);                                      /* MR10 */\r
+extern void zzTraceGuessFail(void);                                  /* MR10 */\r
+#ifdef EXCEPTION_HANDLING\r
+extern void zzdflthandlers(int, int *);\r
+#endif\r
+#else\r
+extern Attrib zzempty_attr();\r
+extern Attrib zzconstr_attr();\r
+extern void zzsyn();\r
+extern int zzset_el();\r
+extern int zzset_deg();\r
+extern void zzedecode();\r
+extern void zzresynch();\r
+extern void zzsave_antlr_state();\r
+extern void zzrestore_antlr_state();\r
+extern void zzfill_inf_look();\r
+extern void zzconsumeUntil();                                        /* MR7 */\r
+extern void zzconsumeUntilToken();                                   /* MR7 */\r
+extern void zzTraceIn();                                             /* MR10 */\r
+extern void zzTraceOut();                                            /* MR10 */\r
+extern int  zzTraceOption();                                         /* MR10 */\r
+extern int  zzTraceGuessOption();                                    /* MR10 */\r
+extern void zzTraceReset();                                          /* MR10 */\r
+extern void zzTraceGuessFail();                                      /* MR10 */\r
+#ifdef EXCEPTION_HANDLING\r
+extern void zzdflthandlers();\r
+#endif\r
+#endif\r
+\r
+                               /* G l o b a l  V a r i a b l e s */\r
+\r
+/* Define a parser; user should do a "#parser myname" in their grammar file */\r
+/*extern struct pccts_parser zzparser;*/\r
+\r
+extern char *zztokens[];\r
+#ifdef LL_K\r
+extern int zztokenLA[];\r
+extern zzchar_t zztextLA[][ZZLEXBUFSIZE];\r
+extern int zzlap;\r
+extern int zzlabase;\r
+#else\r
+extern int zztoken;\r
+#endif\r
+\r
+extern char zzStackOvfMsg[];\r
+extern int zzasp;\r
+extern Attrib zzaStack[];\r
+#ifdef ZZINF_LOOK\r
+extern int *zzinf_tokens;\r
+extern char **zzinf_text;\r
+extern char *zzinf_text_buffer;\r
+extern int *zzinf_line;\r
+extern int zzinf_labase;\r
+extern int zzinf_last;\r
+#endif\r
+#ifdef DEMAND_LOOK\r
+extern int zzdirty;\r
+#endif\r
+#ifdef ZZCAN_GUESS\r
+extern int zzguessing;\r
+extern zzjmp_buf zzguess_start;\r
+#endif\r
+\r
+/* Define global veriables that refer to values exported by the scanner.\r
+ * These declarations duplicate those in dlgdef.h, but are needed\r
+ * if ANTLR is not to generate a .dlg file (-gx); PS, this is a hack.\r
+ */\r
+extern zzchar_t *zzlextext;     /* text of most recently matched token */\r
+extern int      zzbufsize;      /* how long zzlextext is */\r
+\r
+#endif\r
diff --git a/Tools/CodeTools/Source/Pccts/h/ast.c b/Tools/CodeTools/Source/Pccts/h/ast.c
new file mode 100644 (file)
index 0000000..9326ae1
--- /dev/null
@@ -0,0 +1,345 @@
+/* Abstract syntax tree manipulation functions\r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
+ * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
+ * company may do whatever they wish with source code distributed with\r
+ * PCCTS or the code generated by PCCTS, including the incorporation of\r
+ * PCCTS, or its output, into commerical software.\r
+ *\r
+ * We encourage users to develop software with PCCTS.  However, we do ask\r
+ * that credit is given to us for developing PCCTS.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like PCCTS and have developed a nice tool with the\r
+ * output, please mention that you developed it using PCCTS.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed. \r
+ *\r
+ * ANTLR 1.33\r
+ * Terence Parr\r
+ * Parr Research Corporation\r
+ * with Purdue University and AHPCRC, University of Minnesota\r
+ * 1989-2000\r
+ */\r
+\r
+#include "pcctscfg.h"\r
+\r
+#ifdef PCCTS_USE_STDARG\r
+#include "pccts_stdarg.h"\r
+#else\r
+#include <varargs.h>\r
+#endif\r
+\r
+/* ensure that tree manipulation variables are current after a rule\r
+ * reference\r
+ */\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+zzlink(AST **_root, AST **_sibling, AST **_tail)\r
+#else\r
+zzlink(_root, _sibling, _tail)\r
+AST **_root, **_sibling, **_tail;\r
+#endif\r
+{\r
+       if ( *_sibling == NULL ) return;\r
+       if ( *_root == NULL ) *_root = *_sibling;\r
+       else if ( *_root != *_sibling ) (*_root)->down = *_sibling;\r
+       if ( *_tail==NULL ) *_tail = *_sibling;\r
+       while ( (*_tail)->right != NULL ) *_tail = (*_tail)->right;\r
+}\r
+\r
+AST *\r
+#ifdef __USE_PROTOS\r
+zzastnew(void)\r
+#else\r
+zzastnew()\r
+#endif\r
+{\r
+       AST *p = (AST *) calloc(1, sizeof(AST));\r
+       if ( p == NULL ) fprintf(stderr,"%s(%d): cannot allocate AST node\n",__FILE__,__LINE__);\r
+       return p;\r
+}\r
+\r
+/* add a child node to the current sibling list */\r
+void\r
+#ifdef __USE_PROTOS\r
+zzsubchild(AST **_root, AST **_sibling, AST **_tail)\r
+#else\r
+zzsubchild(_root, _sibling, _tail)\r
+AST **_root, **_sibling, **_tail;\r
+#endif\r
+{\r
+       AST *n;\r
+       zzNON_GUESS_MODE {\r
+       n = zzastnew();\r
+#ifdef DEMAND_LOOK\r
+       zzcr_ast(n, &(zzaCur), LA(0), LATEXT(0));\r
+#else\r
+       zzcr_ast(n, &(zzaCur), LA(1), LATEXT(1));\r
+#endif\r
+       zzastPush( n );\r
+       if ( *_tail != NULL ) (*_tail)->right = n;\r
+       else {\r
+               *_sibling = n;\r
+               if ( *_root != NULL ) (*_root)->down = *_sibling;\r
+       }\r
+       *_tail = n;\r
+       if ( *_root == NULL ) *_root = *_sibling;\r
+       }\r
+}\r
+\r
+/* make a new AST node.  Make the newly-created\r
+ * node the root for the current sibling list.  If a root node already\r
+ * exists, make the newly-created node the root of the current root.\r
+ */\r
+void\r
+#ifdef __USE_PROTOS\r
+zzsubroot(AST **_root, AST **_sibling, AST **_tail)\r
+#else\r
+zzsubroot(_root, _sibling, _tail)\r
+AST **_root, **_sibling, **_tail;\r
+#endif\r
+{\r
+       AST *n;\r
+       zzNON_GUESS_MODE {\r
+       n = zzastnew();\r
+#ifdef DEMAND_LOOK\r
+       zzcr_ast(n, &(zzaCur), LA(0), LATEXT(0));\r
+#else\r
+       zzcr_ast(n, &(zzaCur), LA(1), LATEXT(1));\r
+#endif\r
+       zzastPush( n );\r
+       if ( *_root != NULL )\r
+               if ( (*_root)->down == *_sibling ) *_sibling = *_tail = *_root;\r
+       *_root = n;\r
+       (*_root)->down = *_sibling;\r
+       }\r
+}\r
+\r
+/* Apply function to root then each sibling\r
+ * example: print tree in child-sibling LISP-format (AST has token field)\r
+ *\r
+ *     void show(tree)\r
+ *     AST *tree;\r
+ *     {\r
+ *             if ( tree == NULL ) return;\r
+ *             printf(" %s", zztokens[tree->token]);\r
+ *     }\r
+ *\r
+ *     void before() { printf(" ("); }\r
+ *     void after()  { printf(" )"); }\r
+ *\r
+ *     LISPdump() { zzpre_ast(tree, show, before, after); }\r
+ *\r
+ */\r
+void\r
+#ifdef __USE_PROTOS\r
+zzpre_ast(\r
+         AST *tree,\r
+         void (*func)(AST *),   /* apply this to each tree node */\r
+         void (*before)(AST *), /* apply this to root of subtree before preordering it */\r
+         void (*after)(AST *))  /* apply this to root of subtree after preordering it */\r
+#else\r
+zzpre_ast(tree, func, before, after)\r
+AST *tree;\r
+void (*func)(),   /* apply this to each tree node */\r
+        (*before)(), /* apply this to root of subtree before preordering it */\r
+        (*after)();  /* apply this to root of subtree after preordering it */\r
+#endif\r
+{\r
+       while ( tree!= NULL )\r
+       {\r
+               if ( tree->down != NULL ) (*before)(tree);\r
+               (*func)(tree);\r
+               zzpre_ast(tree->down, func, before, after);\r
+               if ( tree->down != NULL ) (*after)(tree);\r
+               tree = tree->right;\r
+       }\r
+}\r
+\r
+/* free all AST nodes in tree; apply func to each before freeing */\r
+\r
+#if 0\r
+////void\r
+////#ifdef __USE_PROTOS\r
+////zzfree_ast(AST *tree)\r
+////#else\r
+////zzfree_ast(tree)\r
+////AST *tree;\r
+////#endif\r
+////{\r
+////   if ( tree == NULL ) return;\r
+////   zzfree_ast( tree->down );\r
+////   zzfree_ast( tree->right );\r
+////   zztfree( tree );\r
+////}\r
+#endif\r
+\r
+/*\r
+   MR19 Optimize freeing of the following structure to limit recursion\r
+   SAKAI Kiyotaka (ksakai@isr.co.jp)\r
+*/\r
+\r
+/*\r
+         NULL o\r
+             / \\r
+           NULL o\r
+               / \\r
+            NULL NULL\r
+*/\r
+\r
+/*\r
+   MR21 Another refinement to replace recursion with iteration\r
+   NAKAJIMA Mutsuki (muc@isr.co.jp).\r
+*/\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+zzfree_ast(AST *tree)\r
+#else\r
+zzfree_ast(tree)\r
+AST *tree;\r
+#endif\r
+{\r
+\r
+    AST *otree;\r
+\r
+    if (tree == NULL) return;\r
+\r
+    while (tree->down == NULL || tree->right == NULL) {\r
+\r
+        if (tree->down == NULL && tree->right == NULL) {\r
+            zztfree(tree);\r
+            return;\r
+        }\r
+\r
+        otree = tree;\r
+        if (tree->down == NULL) {\r
+            tree = tree->right;\r
+        } else {\r
+            tree = tree->down;\r
+        }\r
+        zztfree( otree );\r
+    }\r
+\r
+    while (tree != NULL) {\r
+        zzfree_ast(tree->down);\r
+        otree = tree;\r
+        tree = otree->right;\r
+        zztfree(otree);\r
+    }\r
+}\r
+\r
+/* build a tree (root child1 child2 ... NULL)\r
+ * If root is NULL, simply make the children siblings and return ptr\r
+ * to 1st sibling (child1).  If root is not single node, return NULL.\r
+ *\r
+ * Siblings that are actually siblins lists themselves are handled\r
+ * correctly.  For example #( NULL, #( NULL, A, B, C), D) results\r
+ * in the tree ( NULL A B C D ).\r
+ *\r
+ * Requires at least two parameters with the last one being NULL.  If\r
+ * both are NULL, return NULL.\r
+ */\r
+#ifdef PCCTS_USE_STDARG\r
+AST *zztmake(AST *rt, ...)\r
+#else\r
+AST *zztmake(va_alist)\r
+va_dcl\r
+#endif\r
+{\r
+       va_list ap;\r
+       register AST *child, *sibling=NULL, *tail=NULL /* MR20 */, *w;\r
+       AST *root;\r
+\r
+#ifdef PCCTS_USE_STDARG\r
+       va_start(ap, rt);\r
+       root = rt;\r
+#else\r
+       va_start(ap);\r
+       root = va_arg(ap, AST *);\r
+#endif\r
+\r
+       if ( root != NULL )\r
+               if ( root->down != NULL ) return NULL;\r
+       child = va_arg(ap, AST *);\r
+       while ( child != NULL )\r
+       {\r
+               for (w=child; w->right!=NULL; w=w->right) {;} /* find end of child */\r
+               if ( sibling == NULL ) {sibling = child; tail = w;}\r
+               else {tail->right = child; tail = w;}\r
+               child = va_arg(ap, AST *);\r
+       }\r
+       if ( root==NULL ) root = sibling;\r
+       else root->down = sibling;\r
+       va_end(ap);\r
+       return root;\r
+}\r
+\r
+/* tree duplicate */\r
+AST *\r
+#ifdef __USE_PROTOS\r
+zzdup_ast(AST *t)\r
+#else\r
+zzdup_ast(t)\r
+AST *t;\r
+#endif\r
+{\r
+       AST *u;\r
+       \r
+       if ( t == NULL ) return NULL;\r
+       u = zzastnew();\r
+       *u = *t;\r
+#ifdef zzAST_DOUBLE\r
+       u->up = NULL;           /* set by calling invocation */\r
+       u->left = NULL;\r
+#endif\r
+       u->right = zzdup_ast(t->right);\r
+       u->down = zzdup_ast(t->down);\r
+#ifdef zzAST_DOUBLE\r
+       if ( u->right!=NULL ) u->right->left = u;\r
+       if ( u->down!=NULL ) u->down->up = u;\r
+#endif\r
+       return u;\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+zztfree(AST *t)\r
+#else\r
+zztfree(t)\r
+AST *t;\r
+#endif\r
+{\r
+#ifdef zzd_ast\r
+       zzd_ast( t );\r
+#endif\r
+       free( t );\r
+}\r
+\r
+#ifdef zzAST_DOUBLE\r
+/*\r
+ * Set the 'up', and 'left' pointers of all nodes in 't'.\r
+ * Initial call is double_link(your_tree, NULL, NULL).\r
+ */\r
+void\r
+#ifdef __USE_PROTOS\r
+zzdouble_link(AST *t, AST *left, AST *up)\r
+#else\r
+zzdouble_link(t, left, up)\r
+AST *t, *left, *up;\r
+#endif\r
+{\r
+       if ( t==NULL ) return;\r
+       t->left = left;\r
+       t->up = up;\r
+       zzdouble_link(t->down, NULL, t);\r
+       zzdouble_link(t->right, t, up);\r
+}\r
+#endif\r
diff --git a/Tools/CodeTools/Source/Pccts/h/ast.h b/Tools/CodeTools/Source/Pccts/h/ast.h
new file mode 100644 (file)
index 0000000..5ff84bd
--- /dev/null
@@ -0,0 +1,121 @@
+/* Abstract syntax tree\r
+ *\r
+ * Macros, definitions\r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
+ * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
+ * company may do whatever they wish with source code distributed with\r
+ * PCCTS or the code generated by PCCTS, including the incorporation of\r
+ * PCCTS, or its output, into commerical software.\r
+ *\r
+ * We encourage users to develop software with PCCTS.  However, we do ask\r
+ * that credit is given to us for developing PCCTS.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like PCCTS and have developed a nice tool with the\r
+ * output, please mention that you developed it using PCCTS.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * ANTLR 1.33\r
+ * Terence Parr\r
+ * Parr Research Corporation\r
+ * with Purdue University and AHPCRC, University of Minnesota\r
+ * 1989-2000\r
+ */\r
+\r
+#ifndef ZZAST_H\r
+#define ZZAST_H\r
+\r
+#define zzastOvfChk                                                                                                            \\r
+                       if ( zzast_sp <= 0 )                                        \\r
+            {                                                           \\r
+                fprintf(stderr, zzStackOvfMsg, __FILE__, __LINE__);            \\r
+                exit(PCCTS_EXIT_FAILURE);                                               \\r
+            }\r
+\r
+#ifndef USER_DEFINED_AST\r
+#ifndef AST_FIELDS\r
+#define AST_FIELDS\r
+#endif\r
+\r
+typedef struct _ast {\r
+            struct _ast *right, *down;\r
+#ifdef zzAST_DOUBLE\r
+            struct _ast *left, *up;\r
+#endif\r
+            AST_FIELDS\r
+} AST;\r
+\r
+#else\r
+\r
+#ifdef zzAST_DOUBLE\r
+#define AST_REQUIRED_FIELDS   struct _ast *right, *down, *left, *up;\r
+#else\r
+#define AST_REQUIRED_FIELDS   struct _ast *right, *down;\r
+#endif\r
+\r
+#endif\r
+\r
+\r
+/* N o d e  a c c e s s  m a c r o s */\r
+#define zzchild(t)             (((t)==NULL)? (AST *) NULL:(t->down))   /* MR19 */\r
+#define zzsibling(t)   (((t)==NULL)? (AST *) NULL:(t->right))  /* MR19 */\r
+\r
+\r
+/* define global variables needed by #i stack */\r
+#define zzASTgvars                                                                                             \\r
+       AST *zzastStack[ZZAST_STACKSIZE];                                                       \\r
+       int zzast_sp = ZZAST_STACKSIZE;\r
+\r
+#define zzASTVars      AST *_ast = NULL, *_sibling = NULL, *_tail = NULL\r
+#define zzSTR          ( (_tail==NULL)?(&_sibling):(&(_tail->right)) )\r
+#define zzastCur       (zzastStack[zzast_sp])\r
+#define zzastArg(i)    (zzastStack[zztsp-i])\r
+#define zzastPush(p) zzastOvfChk; zzastStack[--zzast_sp] = p;\r
+#define zzastDPush     --zzast_sp\r
+#define zzastMARK      zztsp=zzast_sp;         /* Save state of stack */\r
+#define zzastREL       zzast_sp=zztsp;         /* Return state of stack */\r
+#define zzrm_ast       {zzfree_ast(*_root); _tail = _sibling = (*_root)=NULL;}\r
+\r
+extern int zzast_sp;\r
+extern AST *zzastStack[];\r
+\r
+/* MR26 */\r
+\r
+#ifdef PCCTS_USE_STDARG\r
+AST *zztmake(AST *, ...);\r
+#else\r
+AST *zztmake();\r
+#endif\r
+\r
+#ifdef __USE_PROTOS\r
+void zzlink(AST **, AST **, AST **);\r
+void zzsubchild(AST **, AST **, AST **);\r
+void zzsubroot(AST **, AST **, AST **);\r
+void zzpre_ast(AST *, void (*)(AST *), void (*)(AST *), void (*)(AST *));\r
+void zzfree_ast(AST *);\r
+AST *zzdup_ast(AST *);\r
+void zztfree(AST *);\r
+void zzdouble_link(AST *, AST *, AST *);\r
+AST *zzastnew(void);\r
+\r
+#else\r
+\r
+void zzlink();\r
+AST *zzastnew();\r
+void zzsubchild();\r
+void zzsubroot();\r
+void zzpre_ast();\r
+void zzfree_ast();\r
+AST *zzdup_ast();\r
+void zztfree();\r
+void zzdouble_link();\r
+#endif\r
+\r
+#endif\r
diff --git a/Tools/CodeTools/Source/Pccts/h/charbuf.h b/Tools/CodeTools/Source/Pccts/h/charbuf.h
new file mode 100644 (file)
index 0000000..5f01c8b
--- /dev/null
@@ -0,0 +1,46 @@
+/* ANTLR attribute definition -- constant width text\r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
+ * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
+ * company may do whatever they wish with source code distributed with\r
+ * PCCTS or the code generated by PCCTS, including the incorporation of\r
+ * PCCTS, or its output, into commerical software.\r
+ *\r
+ * We encourage users to develop software with PCCTS.  However, we do ask\r
+ * that credit is given to us for developing PCCTS.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like PCCTS and have developed a nice tool with the\r
+ * output, please mention that you developed it using PCCTS.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * ANTLR 1.33\r
+ * Terence Parr\r
+ * Parr Research Corporation\r
+ * with Purdue University and AHPCRC, University of Minnesota\r
+ * 1989-2000\r
+ */\r
+\r
+#ifndef ZZCHARBUF_H\r
+#define ZZCHARBUF_H\r
+\r
+#include "pcctscfg.h"\r
+\r
+#include "pccts_string.h"\r
+\r
+#ifndef D_TextSize\r
+#define D_TextSize     30\r
+#endif\r
+\r
+typedef struct { char text[D_TextSize]; } Attrib;\r
+\r
+#define zzcr_attr(a,tok,t)     strncpy((a)->text, t, D_TextSize-1); \\r
+                                                       (a)->text[D_TextSize-1] = '\0';\r
+\r
+#endif\r
diff --git a/Tools/CodeTools/Source/Pccts/h/charptr.c b/Tools/CodeTools/Source/Pccts/h/charptr.c
new file mode 100644 (file)
index 0000000..d3f80e6
--- /dev/null
@@ -0,0 +1,58 @@
+/*\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
+ * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
+ * company may do whatever they wish with source code distributed with\r
+ * PCCTS or the code generated by PCCTS, including the incorporation of\r
+ * PCCTS, or its output, into commerical software.\r
+ *\r
+ * We encourage users to develop software with PCCTS.  However, we do ask\r
+ * that credit is given to us for developing PCCTS.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like PCCTS and have developed a nice tool with the\r
+ * output, please mention that you developed it using PCCTS.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * ANTLR 1.33\r
+ * Terence Parr\r
+ * Parr Research Corporation\r
+ * with Purdue University and AHPCRC, University of Minnesota\r
+ * 1989-2000\r
+ */\r
+\r
+#include "pcctscfg.h"\r
+\r
+#ifdef __STDC__\r
+#include "pccts_stdlib.h"\r
+#else\r
+#include <malloc.h>\r
+#endif\r
+#include "pccts_string.h"\r
+\r
+/* 133MR1 include stdio.h for fprintf in charptr.c */\r
+\r
+#include "pccts_stdio.h"\r
+\r
+/* 133MR1 include charptr.h for Attrib in charptr.c */\r
+\r
+#include "charptr.h"\r
+\r
+#ifdef __USE_PROTOS\r
+zzcr_attr(Attrib *a,int token,char *text)\r
+#else\r
+zzcr_attr(a,token,text)\r
+Attrib *a;\r
+int token;\r
+char *text;\r
+#endif\r
+{\r
+       *a = (char *) malloc(strlen(text)+1);                   /* MR6 */\r
+       if ( *a == NULL ) {fprintf(stderr, "zzcr_attr: out of memory!\n"); exit(-1);}\r
+       strcpy(*a, text);\r
+}\r
diff --git a/Tools/CodeTools/Source/Pccts/h/charptr.h b/Tools/CodeTools/Source/Pccts/h/charptr.h
new file mode 100644 (file)
index 0000000..e73da68
--- /dev/null
@@ -0,0 +1,48 @@
+/*\r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
+ * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
+ * company may do whatever they wish with source code distributed with\r
+ * PCCTS or the code generated by PCCTS, including the incorporation of\r
+ * PCCTS, or its output, into commerical software.\r
+ *\r
+ * We encourage users to develop software with PCCTS.  However, we do ask\r
+ * that credit is given to us for developing PCCTS.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like PCCTS and have developed a nice tool with the\r
+ * output, please mention that you developed it using PCCTS.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * ANTLR 1.33\r
+ * Terence Parr\r
+ * Parr Research Corporation\r
+ * with Purdue University and AHPCRC, University of Minnesota\r
+ * 1989-2000\r
+ */\r
+\r
+/*\r
+ * WARNING!!!!: charptr.h does NOT make copies and the\r
+ * memory is freed after the attribute scope exits.\r
+ */\r
+\r
+#ifndef ZZCHARPTR_H\r
+#define ZZCHARPTR_H\r
+\r
+typedef char *Attrib;\r
+#define zzdef0(a)              {*(a)=NULL;}\r
+/* MR8  Jens Tingleff (jensting@imaginet.fr)                                */\r
+/*          Set memory pointer to null after free()                         */\r
+#define zzd_attr(a)            {if ( *(a)!=NULL ) {free(*(a)); *(a)=NULL; }; }\r
+\r
+#ifdef __STDC__\r
+extern zzcr_attr(Attrib *,int,char *);\r
+#endif\r
+\r
+#endif\r
diff --git a/Tools/CodeTools/Source/Pccts/h/config.h b/Tools/CodeTools/Source/Pccts/h/config.h
new file mode 100644 (file)
index 0000000..8aa50ad
--- /dev/null
@@ -0,0 +1 @@
+#include "pcctscfg.h"\r
diff --git a/Tools/CodeTools/Source/Pccts/h/dlgauto.h b/Tools/CodeTools/Source/Pccts/h/dlgauto.h
new file mode 100644 (file)
index 0000000..db94cef
--- /dev/null
@@ -0,0 +1,504 @@
+/* dlgauto.h automaton\r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
+ * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
+ * company may do whatever they wish with source code distributed with\r
+ * PCCTS or the code generated by PCCTS, including the incorporation of\r
+ * PCCTS, or its output, into commerical software.\r
+ *\r
+ * We encourage users to develop software with PCCTS.  However, we do ask\r
+ * that credit is given to us for developing PCCTS.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like PCCTS and have developed a nice tool with the\r
+ * output, please mention that you developed it using PCCTS.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * ANTLR 1.33\r
+ * Will Cohen and Terence Parr\r
+ * Parr Research Corporation\r
+ * with Purdue University and AHPCRC, University of Minnesota\r
+ * 1989-2000\r
+ */\r
+\r
+#ifndef ZZDEFAUTO_H\r
+#define ZZDEFAUTO_H\r
+\r
+/*  10-Apr-97 133MR1   Uses __USE_PROTOS show should #include pcctscfg.h */\r
+\r
+#include "pcctscfg.h"\r
+\r
+zzchar_t       *zzlextext;     /* text of most recently matched token */\r
+zzchar_t       *zzbegexpr;     /* beginning of last reg expr recogn. */\r
+zzchar_t       *zzendexpr;     /* beginning of last reg expr recogn. */\r
+int    zzbufsize = 0;  /* number of characters in zzlextext */          /* MR7 */\r
+int    zzbegcol = 0;   /* column that first character of token is in*/\r
+int    zzendcol = 0;   /* column that last character of token is in */\r
+int    zzline = 1;     /* line current token is on */\r
+int    zzreal_line=1;  /* line of 1st portion of token that is not skipped */\r
+int    zzchar;         /* character to determine next state */\r
+int    zzbufovf;       /* indicates that buffer too small for text */\r
+int    zzcharfull = 0;\r
+static zzchar_t        *zznextpos;/* points to next available position in zzlextext*/\r
+static int     zzclass;\r
+\r
+#ifdef __USE_PROTOS\r
+void   zzerrstd(const char *);\r
+void   (*zzerr)(const char *)=zzerrstd;/* pointer to error reporting function */\r
+extern int     zzerr_in(void);\r
+static int     (*zzfunc_in)(void) = zzerr_in;  /* MR20 */\r
+#else\r
+void   zzerrstd();\r
+void   (*zzerr)()=zzerrstd;    /* pointer to error reporting function */\r
+extern int     zzerr_in();\r
+static int     (*zzfunc_in)() = zzerr_in;      /* MR20 */\r
+#endif\r
+\r
+static FILE    *zzstream_in=0;\r
+static zzchar_t        *zzstr_in=0;\r
+\r
+#ifdef USER_ZZMODE_STACK\r
+int              zzauto = 0;\r
+#else\r
+static int     zzauto = 0;\r
+#endif\r
+static int     zzadd_erase;\r
+static char    zzebuf[70];\r
+\r
+#ifdef ZZCOL\r
+#define ZZINC (++zzendcol)\r
+#else\r
+#define ZZINC\r
+#endif\r
+\r
+\r
+#define ZZGETC_STREAM {zzchar = getc(zzstream_in); zzclass = ZZSHIFT(zzchar);}\r
+#define ZZGETC_FUNC {zzchar = (*zzfunc_in)(); zzclass = ZZSHIFT(zzchar);}\r
+#define ZZGETC_STR {                   \\r
+       if (*zzstr_in){                         \\r
+               zzchar = *zzstr_in;             \\r
+               ++zzstr_in;                             \\r
+       }else{                                          \\r
+               zzchar = EOF;                   \\r
+       }                                                       \\r
+       zzclass = ZZSHIFT(zzchar);      \\r
+}\r
+\r
+#define ZZNEWSTATE     (newstate = dfa[state][zzclass])\r
+\r
+#ifndef ZZCOPY\r
+#define ZZCOPY \\r
+       /* Truncate matching buffer to size (not an error) */   \\r
+       if (zznextpos < lastpos){                               \\r
+               *(zznextpos++) = zzchar;                        \\r
+       }else{                                                  \\r
+               zzbufovf = 1;                                   \\r
+       }\r
+#endif\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+zzrdstream( FILE *f )\r
+#else\r
+zzrdstream( f )\r
+FILE *f;\r
+#endif\r
+{\r
+       /* make sure that it is really set to something, otherwise just\r
+          leave it be.\r
+       */\r
+       if (f){\r
+               /* make sure that there is always someplace to get input\r
+                  before closing zzstream_in\r
+               */\r
+#if 0\r
+               if (zzstream_in && zzstream_in!=stdin) fclose( zzstream_in );\r
+#endif\r
+               zzline = 1;\r
+               zzstream_in = f;\r
+               zzfunc_in = NULL;\r
+               zzstr_in = 0;\r
+               zzcharfull = 0;\r
+       }\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+zzrdfunc( int (*f)(void) )\r
+#else\r
+zzrdfunc( f )\r
+int (*f)();\r
+#endif\r
+{\r
+       /* make sure that it is really set to something, otherwise just\r
+          leave it be.\r
+       */\r
+       if (f){\r
+               /* make sure that there is always someplace to get input\r
+                  before closing zzstream_in\r
+               */\r
+#if 0\r
+               if (zzstream_in && zzstream_in!=stdin) fclose( zzstream_in );\r
+#endif\r
+               zzline = 1;\r
+               zzstream_in = NULL;\r
+               zzfunc_in = f;\r
+               zzstr_in = 0;\r
+               zzcharfull = 0;\r
+       }\r
+}\r
+\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+zzrdstr( zzchar_t *s )\r
+#else\r
+zzrdstr( s )\r
+zzchar_t *s;\r
+#endif\r
+{\r
+       /* make sure that it is really set to something, otherwise just\r
+          leave it be.\r
+       */\r
+       if (s){\r
+               /* make sure that there is always someplace to get input\r
+                  before closing zzstream_in\r
+               */\r
+#if 0\r
+               if (zzstream_in && zzstream_in!=stdin) fclose( zzstream_in );\r
+#endif\r
+               zzline = 1;\r
+               zzstream_in = NULL;\r
+               zzfunc_in = 0;\r
+               zzstr_in = s;\r
+               zzcharfull = 0;\r
+       }\r
+}\r
+\r
+\r
+#ifdef __USE_PROTOS\r
+void zzclose_stream(void)\r
+#else\r
+void zzclose_stream()\r
+#endif\r
+{\r
+#if 0\r
+       fclose( zzstream_in );\r
+       zzstream_in = NULL;\r
+       zzfunc_in = NULL;\r
+#endif\r
+}\r
+\r
+/* saves dlg state, but not what feeds dlg (such as file position) */\r
+void\r
+#ifdef __USE_PROTOS\r
+zzsave_dlg_state(struct zzdlg_state *state)\r
+#else\r
+zzsave_dlg_state(state)\r
+struct zzdlg_state *state;\r
+#endif\r
+{\r
+       state->stream = zzstream_in;\r
+       state->func_ptr = zzfunc_in;\r
+       state->str = zzstr_in;\r
+       state->auto_num = zzauto;\r
+       state->add_erase = zzadd_erase;\r
+       state->lookc = zzchar;\r
+       state->char_full = zzcharfull;\r
+       state->begcol = zzbegcol;\r
+       state->endcol = zzendcol;\r
+       state->line = zzline;\r
+       state->lextext = zzlextext;\r
+       state->begexpr = zzbegexpr;\r
+       state->endexpr = zzendexpr;\r
+       state->bufsize = zzbufsize;\r
+       state->bufovf = zzbufovf;\r
+       state->nextpos = zznextpos;\r
+       state->class_num = zzclass;\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+zzrestore_dlg_state(struct zzdlg_state *state)\r
+#else\r
+zzrestore_dlg_state(state)\r
+struct zzdlg_state *state;\r
+#endif\r
+{\r
+       zzstream_in = state->stream;\r
+       zzfunc_in = state->func_ptr;\r
+       zzstr_in = state->str;\r
+       zzauto = state->auto_num;\r
+       zzadd_erase = state->add_erase;\r
+       zzchar = state->lookc;\r
+       zzcharfull = state->char_full;\r
+       zzbegcol = state->begcol;\r
+       zzendcol = state->endcol;\r
+       zzline = state->line;\r
+       zzlextext = state->lextext;\r
+       zzbegexpr = state->begexpr;\r
+       zzendexpr = state->endexpr;\r
+       zzbufsize = state->bufsize;\r
+       zzbufovf = state->bufovf;\r
+       zznextpos = state->nextpos;\r
+       zzclass = state->class_num;\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+zzmode( int m )\r
+#else\r
+zzmode( m )\r
+int m;\r
+#endif\r
+{\r
+       /* points to base of dfa table */\r
+       if (m<MAX_MODE){\r
+               zzauto = m;\r
+               /* have to redo class since using different compression */\r
+               zzclass = ZZSHIFT(zzchar);\r
+       }else{\r
+               sprintf(zzebuf,"Invalid automaton mode = %d ",m);\r
+               zzerr(zzebuf);\r
+       }\r
+}\r
+\r
+/* erase what is currently in the buffer, and get a new reg. expr */\r
+\r
+#ifdef __USE_PROTOS\r
+void zzskip(void)\r
+#else\r
+void zzskip()\r
+#endif\r
+{\r
+       zzadd_erase = 1;\r
+}\r
+\r
+/* don't erase what is in the zzlextext buffer, add on to it */\r
+#ifdef __USE_PROTOS\r
+void zzmore()\r
+#else\r
+void zzmore()\r
+#endif\r
+{\r
+       zzadd_erase = 2;\r
+}\r
+\r
+/* substitute c for the reg. expr last matched and is in the buffer */\r
+#ifdef __USE_PROTOS\r
+void\r
+zzreplchar(zzchar_t c)\r
+#else\r
+void\r
+zzreplchar(c)\r
+zzchar_t c;\r
+#endif\r
+{\r
+       /* can't allow overwriting null at end of string */\r
+       if (zzbegexpr < &zzlextext[zzbufsize-1]){\r
+               *zzbegexpr = c;\r
+               *(zzbegexpr+1) = '\0';\r
+       }\r
+       zzendexpr = zzbegexpr;\r
+       if (c != '\0') {\r
+               zznextpos = zzbegexpr + 1;\r
+       }\r
+       else {\r
+               zznextpos = zzbegexpr;  /* MR30 Zero terminates string. */\r
+       }\r
+}\r
+\r
+/* replace the string s for the reg. expr last matched and in the buffer */\r
+void\r
+#ifdef __USE_PROTOS\r
+zzreplstr(register zzchar_t *s)\r
+#else\r
+zzreplstr(s)\r
+register zzchar_t *s;\r
+#endif\r
+{\r
+       register zzchar_t *l= &zzlextext[zzbufsize -1];\r
+\r
+       zznextpos = zzbegexpr;\r
+       if (s){\r
+               while ((zznextpos <= l) && (*(zznextpos++) = *(s++))!=0){\r
+                       /* empty */\r
+               }\r
+               /* correct for NULL at end of string */\r
+               zznextpos--;\r
+       }\r
+       if ((zznextpos <= l) && (*(--s) == 0)){\r
+               zzbufovf = 0;\r
+       }else{\r
+               zzbufovf = 1;\r
+       }\r
+       *(zznextpos) = '\0';\r
+       zzendexpr = zznextpos - 1;\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+void zzgettok(void)\r
+#else\r
+void zzgettok()\r
+#endif\r
+{\r
+       register int state, newstate;\r
+       /* last space reserved for the null char */\r
+       zzchar_t *lastpos;  /* MR27 Remove register since address operator used. */\r
+\r
+skip:\r
+       zzreal_line = zzline;\r
+       zzbufovf = 0;\r
+       lastpos = &zzlextext[zzbufsize-1];\r
+       zznextpos = zzlextext;\r
+       zzbegcol = zzendcol+1;\r
+more:\r
+       zzbegexpr = zznextpos;\r
+#ifdef ZZINTERACTIVE\r
+       /* interactive version of automaton */\r
+       /* if there is something in zzchar, process it */\r
+       state = newstate = dfa_base[zzauto];\r
+       if (zzcharfull){\r
+               ZZINC;\r
+               ZZCOPY;\r
+               ZZNEWSTATE;\r
+       }\r
+       if (zzstr_in)\r
+               while (zzalternatives[newstate]){\r
+                       state = newstate;\r
+                       ZZGETC_STR;\r
+                       ZZINC;\r
+                       ZZCOPY;\r
+                       ZZNEWSTATE;\r
+               }\r
+       else if (zzstream_in)\r
+               while (zzalternatives[newstate]){\r
+                       state = newstate;\r
+                       ZZGETC_STREAM;\r
+                       ZZINC;\r
+                       ZZCOPY;\r
+                       ZZNEWSTATE;\r
+               }\r
+       else if (zzfunc_in)\r
+               while (zzalternatives[newstate]){\r
+                       state = newstate;\r
+                       ZZGETC_FUNC;\r
+                       ZZINC;\r
+                       ZZCOPY;\r
+                       ZZNEWSTATE;\r
+               }\r
+       /* figure out if last character really part of token */\r
+       if ((state != dfa_base[zzauto]) && (newstate == DfaStates)){\r
+               zzcharfull = 1;\r
+               --zznextpos;\r
+       }else{\r
+               zzcharfull = 0;\r
+               state = newstate;\r
+       }\r
+       *(zznextpos) = '\0';\r
+       /* Able to transition out of start state to some non err state?*/\r
+       if ( state == dfa_base[zzauto] ){\r
+               /* make sure doesn't get stuck */\r
+               zzadvance();\r
+       }\r
+#else\r
+       /* non-interactive version of automaton */\r
+       if (!zzcharfull)\r
+               zzadvance();\r
+       else\r
+               ZZINC;\r
+       state = dfa_base[zzauto];\r
+       if (zzstr_in)\r
+               while (ZZNEWSTATE != DfaStates){\r
+                       state = newstate;\r
+                       ZZCOPY;\r
+                       ZZGETC_STR;\r
+                       ZZINC;\r
+               }\r
+       else if (zzstream_in)\r
+               while (ZZNEWSTATE != DfaStates){\r
+                       state = newstate;\r
+                       ZZCOPY;\r
+                       ZZGETC_STREAM;\r
+                       ZZINC;\r
+               }\r
+       else if (zzfunc_in)\r
+               while (ZZNEWSTATE != DfaStates){\r
+                       state = newstate;\r
+                       ZZCOPY;\r
+                       ZZGETC_FUNC;\r
+                       ZZINC;\r
+               }\r
+       zzcharfull = 1;\r
+       if ( state == dfa_base[zzauto] ){\r
+               if (zznextpos < lastpos){\r
+                       *(zznextpos++) = zzchar;\r
+               }else{\r
+                       zzbufovf = 1;\r
+               }\r
+               *zznextpos = '\0';\r
+               /* make sure doesn't get stuck */\r
+               zzadvance();\r
+       }else{\r
+               *zznextpos = '\0';\r
+       }\r
+#endif\r
+#ifdef ZZCOL\r
+       zzendcol -= zzcharfull;\r
+#endif\r
+       zzendexpr = zznextpos -1;\r
+       zzadd_erase = 0;\r
+       (*actions[accepts[state]])();\r
+       switch (zzadd_erase) {\r
+               case 1: goto skip;\r
+               case 2: goto more;\r
+       }\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+void zzadvance(void)\r
+#else\r
+void zzadvance()\r
+#endif\r
+{\r
+       if (zzstream_in) { ZZGETC_STREAM; zzcharfull = 1; ZZINC;}\r
+       if (zzfunc_in) { ZZGETC_FUNC; zzcharfull = 1; ZZINC;}\r
+       if (zzstr_in) { ZZGETC_STR; zzcharfull = 1; ZZINC;}\r
+       if (!(zzstream_in || zzfunc_in || zzstr_in)){\r
+               zzerr_in();\r
+       }\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+zzerrstd(const char *s)\r
+#else\r
+zzerrstd(s)\r
+char *s;\r
+#endif\r
+{\r
+        zzLexErrCount++;                /* MR11 */\r
+        fprintf(stderr,\r
+                "%s near line %d (text was '%s')\n",\r
+                ((s == NULL) ? "Lexical error" : s),\r
+                zzline,zzlextext);\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+int zzerr_in(void)\r
+#else\r
+int zzerr_in()\r
+#endif\r
+{\r
+       fprintf(stderr,"No input stream, function, or string\n");\r
+       /* return eof to get out gracefully */\r
+       return EOF;\r
+}\r
+\r
+#endif\r
diff --git a/Tools/CodeTools/Source/Pccts/h/dlgdef.h b/Tools/CodeTools/Source/Pccts/h/dlgdef.h
new file mode 100644 (file)
index 0000000..733d256
--- /dev/null
@@ -0,0 +1,128 @@
+/* dlgdef.h\r
+ * Things in scanner produced by dlg that should be visible to the outside\r
+ * world\r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
+ * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
+ * company may do whatever they wish with source code distributed with\r
+ * PCCTS or the code generated by PCCTS, including the incorporation of\r
+ * PCCTS, or its output, into commerical software.\r
+ *\r
+ * We encourage users to develop software with PCCTS.  However, we do ask\r
+ * that credit is given to us for developing PCCTS.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like PCCTS and have developed a nice tool with the\r
+ * output, please mention that you developed it using PCCTS.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * ANTLR 1.33\r
+ * Terence Parr\r
+ * Parr Research Corporation\r
+ * with Purdue University and AHPCRC, University of Minnesota\r
+ * 1989-2000\r
+ */\r
+\r
+#ifndef ZZDLGDEF_H\r
+#define ZZDLGDEF_H\r
+\r
+#include "pcctscfg.h"\r
+\r
+#ifndef zzchar_t\r
+#ifdef ZZWCHAR_T\r
+#define zzchar_t wchar_t\r
+#else\r
+#define zzchar_t char\r
+#endif\r
+#endif\r
+\r
+struct zzdlg_state {\r
+       FILE *stream;\r
+#ifdef __USE_PROTOS\r
+       int (*func_ptr)(void);\r
+#else\r
+       int (*func_ptr)();\r
+#endif\r
+       zzchar_t *str;\r
+       int auto_num;\r
+       int add_erase;\r
+       int lookc;\r
+       int char_full;\r
+       int begcol, endcol;\r
+       int line;\r
+       zzchar_t *lextext, *begexpr, *endexpr;\r
+       int bufsize;\r
+       int bufovf;\r
+       zzchar_t *nextpos;\r
+       int     class_num;\r
+};\r
+\r
+extern zzchar_t        *zzlextext;     /* text of most recently matched token */\r
+extern zzchar_t        *zzbegexpr;     /* beginning of last reg expr recogn. */\r
+extern zzchar_t        *zzendexpr;     /* beginning of last reg expr recogn. */\r
+extern int     zzbufsize;      /* how long zzlextext is */\r
+extern int     zzbegcol;       /* column that first character of token is in*/\r
+extern int     zzendcol;       /* column that last character of token is in */\r
+extern int     zzline;         /* line current token is on */\r
+extern int     zzreal_line;            /* line of 1st portion of token that is not skipped */\r
+extern int     zzchar;         /* character to determine next state */\r
+extern int     zzbufovf;       /* indicates that buffer too small for text */\r
+#ifdef __USE_PROTOS\r
+extern void    (*zzerr)(const char *);/* pointer to error reporting function */\r
+#else\r
+extern void    (*zzerr)();\r
+#endif\r
+\r
+#ifdef USER_ZZMODE_STACK\r
+extern int     zzauto;\r
+#endif\r
+\r
+#ifdef __USE_PROTOS\r
+extern void    zzadvance(void);\r
+extern void    zzskip(void);   /* erase zzlextext, look for antoher token */\r
+extern void    zzmore(void);   /* keep zzlextext, look for another token */\r
+extern void    zzmode(int k);  /* switch to automaton 'k' */\r
+extern void    zzrdstream(FILE *);/* what stream to read from */\r
+extern void    zzclose_stream(void);/* close the current input stream */\r
+extern void    zzrdfunc(int (*)(void));/* what function to get char from */\r
+extern void zzrdstr( zzchar_t * );\r
+extern void    zzgettok(void); /* get next token */\r
+extern void    zzreplchar(zzchar_t c);/* replace last recognized reg. expr. with\r
+                                       a character */\r
+extern void    zzreplstr(zzchar_t *s);/* replace last recognized reg. expr. with\r
+                                       a string */\r
+extern void zzsave_dlg_state(struct zzdlg_state *);\r
+extern void zzrestore_dlg_state(struct zzdlg_state *);\r
+extern int zzerr_in(void);\r
+extern void    zzerrstd(const char *);\r
+extern void zzerraction(void);\r
+\r
+#else\r
+\r
+extern void    zzadvance();\r
+extern void    zzskip();       /* erase zzlextext, look for antoher token */\r
+extern void    zzmore();       /* keep zzlextext, look for another token */\r
+extern void    zzmode(/*k*/);  /* switch to automaton 'k' */\r
+extern void    zzrdstream();   /* what stream to read from */\r
+extern void    zzclose_stream();/* close the current input stream */\r
+extern void    zzrdfunc();     /* what function to get char from */\r
+extern void zzrdstr();\r
+extern void    zzgettok();     /* get next token */\r
+extern void    zzreplchar();   /* replace last recognized reg. expr. with\r
+                                       a character */\r
+extern void    zzreplstr();    /* replace last recognized reg. expr. with\r
+                                       a string */\r
+extern void zzsave_dlg_state();\r
+extern void zzrestore_dlg_state();\r
+extern int zzerr_in();\r
+extern void    zzerrstd();\r
+extern void zzerraction();\r
+#endif\r
+\r
+#endif\r
diff --git a/Tools/CodeTools/Source/Pccts/h/err.h b/Tools/CodeTools/Source/Pccts/h/err.h
new file mode 100644 (file)
index 0000000..b2b196b
--- /dev/null
@@ -0,0 +1,1170 @@
+/*\r
+ * err.h\r
+ *\r
+ * Standard error handling mechanism\r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
+ * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
+ * company may do whatever they wish with source code distributed with\r
+ * PCCTS or the code generated by PCCTS, including the incorporation of\r
+ * PCCTS, or its output, into commerical software.\r
+ *\r
+ * We encourage users to develop software with PCCTS.  However, we do ask\r
+ * that credit is given to us for developing PCCTS.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like PCCTS and have developed a nice tool with the\r
+ * output, please mention that you developed it using PCCTS.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * Has grown to hold all kinds of stuff (err.h is increasingly misnamed)\r
+ *\r
+ * ANTLR 1.33\r
+ * Terence Parr\r
+ * Parr Research Corporation\r
+ * with Purdue University and AHPCRC, University of Minnesota\r
+ * 1989-2000\r
+ */\r
+\r
+#ifndef ERR_H\r
+#define ERR_H\r
+\r
+#include "pcctscfg.h"\r
+#include <stdlib.h>\r
+#include <assert.h>\r
+\r
+/*                                                                           */\r
+/*  7-Apr-97  133MR1                                                         */\r
+/*             Proper choice of STDC and cplusplus pre-processor symbols (?) */\r
+/*                                                                           */\r
+#include "pccts_string.h"\r
+\r
+#ifdef PCCTS_USE_STDARG\r
+#include "pccts_stdarg.h"\r
+#else\r
+#include <varargs.h>\r
+#endif\r
+\r
+#ifdef DUM\r
+/* Define usable bits per unsigned int word (used for set stuff) */\r
+#ifdef PC\r
+#define BSETWORDSIZE 16\r
+#define BSETLOGWORDSIZE        4\r
+#else\r
+#define        BSETWORDSIZE 32\r
+#define BSETLOGWORDSIZE 5\r
+#endif\r
+#endif\r
+\r
+#define        BSETWORDSIZE 8\r
+#define BSETLOGWORDSIZE 3              /* SetWordType is 8bits */\r
+\r
+#define        BSETMODWORD(x) ((x) & (BSETWORDSIZE-1))         /* x % BSETWORDSIZE */\r
+#define        BSETDIVWORD(x) ((x) >> BSETLOGWORDSIZE)         /* x / BSETWORDSIZE */\r
+\r
+/* This is not put into the global pccts_parser structure because it is\r
+ * hidden and does not need to be saved during a "save state" operation\r
+ */\r
+/* maximum of 32 bits/unsigned int and must be 8 bits/byte */\r
+static SetWordType bitmask[] = {\r
+       0x00000001, 0x00000002, 0x00000004, 0x00000008,\r
+       0x00000010, 0x00000020, 0x00000040, 0x00000080\r
+};\r
+\r
+#ifdef zzTRACE_RULES\r
+int  zzTraceOptionValueDefault=1;\r
+int  zzTraceOptionValue=1;\r
+int  zzTraceGuessOptionValue=1;\r
+char *zzTraceCurrentRuleName=NULL;\r
+int  zzTraceDepth=0;\r
+#endif\r
+\r
+int  zzGuessSeq=0;          /* MR10 */\r
+int  zzSyntaxErrCount=0;    /* MR11 */\r
+int  zzLexErrCount=0;       /* MR11 */\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+zzresynch(SetWordType *wd,SetWordType mask)\r
+#else\r
+zzresynch(wd,mask)\r
+SetWordType *wd, mask;\r
+#endif\r
+{\r
+       static int consumed = 1;\r
+\r
+       /* if you enter here without having consumed a token from last resynch\r
+        * force a token consumption.\r
+        */\r
+       if ( !consumed ) {zzCONSUME; consumed=1; return;}   /* MR10 */\r
+\r
+       /* if current token is in resynch set, we've got what we wanted */\r
+       if ( wd[LA(1)]&mask || LA(1) == zzEOF_TOKEN ) {consumed=0; return;}\r
+       \r
+       /* scan until we find something in the resynch set */\r
+       while ( !(wd[LA(1)]&mask) && LA(1) != zzEOF_TOKEN ) {zzCONSUME;}\r
+       consumed=1;\r
+}\r
+\r
+/*                                                                          */\r
+/*  7-Apr-97 133MR1 for C++ and MR7 for C                                   */\r
+/*          Change suggested by Eli Sternheim (eli@interhdl.com)           */\r
+/*                                                                          */\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+zzconsumeUntil(SetWordType *st)\r
+#else\r
+zzconsumeUntil(st)\r
+SetWordType *st;\r
+#endif\r
+{\r
+    int     tmp;                                                     /* MR7 */\r
+       while ( !zzset_el( (tmp=LA(1)), st) && tmp!=1 /* Eof */) {       /* MR7 */\r
+                                                      zzCONSUME; }   /* MR7 */\r
+}\r
+\r
+/*                                                                          */\r
+/*  7-Apr-97 133MR1 for C++ and MR7 for C                                   */\r
+/*          Change suggested by Eli Sternheim (eli@interhdl.com)           */\r
+/*                                                                          */\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+zzconsumeUntilToken(int t)\r
+#else\r
+zzconsumeUntilToken(t)\r
+int t;\r
+#endif\r
+{\r
+    int     tmp;                                                     /* MR7 */\r
+       while ( (tmp=LA(1)) !=t && tmp!=1 /* Eof */) { zzCONSUME; }      /* MR7 */\r
+}\r
+\r
+/* input looks like:\r
+ *             zzFAIL(k, e1, e2, ...,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText)\r
+ * where the zzMiss stuff is set here to the token that did not match\r
+ * (and which set wasn't it a member of).\r
+ */\r
+\r
+#ifdef PCCTS_USE_STDARG\r
+void zzFAIL(int k, ...)\r
+#else\r
+void zzFAIL(va_alist)\r
+va_dcl\r
+#endif\r
+{\r
+#ifdef LL_K\r
+       static char text[LL_K*ZZLEXBUFSIZE+1];\r
+       SetWordType *f[LL_K];\r
+#else\r
+       static char text[ZZLEXBUFSIZE+1];\r
+       SetWordType *f[1];\r
+#endif\r
+       SetWordType **miss_set;\r
+       char **miss_text;\r
+       int *bad_tok;\r
+       char **bad_text;\r
+       int *err_k;\r
+       int i;\r
+       va_list ap;\r
+#ifndef PCCTS_USE_STDARG                       /* MR20 */\r
+       int k;\r
+#endif\r
+#ifdef PCCTS_USE_STDARG         /* MR20 */\r
+       va_start(ap, k);\r
+#else\r
+       va_start(ap);\r
+       k = va_arg(ap, int);    /* how many lookahead sets? */\r
+#endif\r
+    assert(k <= sizeof(f)/sizeof(f[0]));    /* MR20 G. Hobbelt */\r
+       text[0] = '\0';\r
+       for (i=1; i<=k; i++)    /* collect all lookahead sets */\r
+       {\r
+               f[i-1] = va_arg(ap, SetWordType *);\r
+       }\r
+       for (i=1; i<=k; i++)    /* look for offending token */\r
+       {\r
+               if ( i>1 ) strcat(text, " ");\r
+               strcat(text, LATEXT(i));\r
+               if ( !zzset_el((unsigned)LA(i), f[i-1]) ) break;\r
+       }\r
+       miss_set = va_arg(ap, SetWordType **);\r
+       miss_text = va_arg(ap, char **);\r
+       bad_tok = va_arg(ap, int *);\r
+       bad_text = va_arg(ap, char **);\r
+       err_k = va_arg(ap, int *);\r
+       if ( i>k )\r
+       {\r
+               /* bad; lookahead is permutation that cannot be matched,\r
+                * but, the ith token of lookahead is valid at the ith position\r
+                * (The old LL sub 1 (k) versus LL(k) parsing technique)\r
+                */\r
+               *miss_set = NULL;\r
+               *miss_text = zzlextext;\r
+               *bad_tok = LA(1);\r
+               *bad_text = LATEXT(1);\r
+               *err_k = k;\r
+               return;\r
+       }\r
+/*     fprintf(stderr, "%s not in %dth set\n", zztokens[LA(i)], i);*/\r
+       *miss_set = f[i-1];\r
+       *miss_text = text;\r
+       *bad_tok = LA(i);\r
+       *bad_text = LATEXT(i);\r
+       if ( i==1 ) *err_k = 1;\r
+       else *err_k = k;\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+void zzTraceGuessDone(zzantlr_state *state)\r
+#else\r
+void zzTraceGuessDone(state)\r
+  zzantlr_state     *state;\r
+#endif\r
+{\r
+#ifdef zzTRACE_RULES\r
+#ifdef ZZCAN_GUESS\r
+\r
+  int   doIt=0;\r
+\r
+  if (zzTraceCurrentRuleName == NULL) return;\r
+\r
+  if (zzTraceOptionValue <= 0) {\r
+    doIt=0;\r
+  } else if (zzTraceGuessOptionValue <= 0) {\r
+    doIt=0;\r
+  } else {\r
+    doIt=1;\r
+  };\r
+\r
+  if (doIt) {\r
+    fprintf(stderr,"guess done - returning to rule %s {\"%s\"} at depth %d",\r
+        state->traceCurrentRuleName,\r
+        LATEXT(1),\r
+        state->traceDepth);\r
+    if (state->guessing != 0) {\r
+      fprintf(stderr," (guess mode continues - an enclosing guess is still active)");\r
+    } else {\r
+      fprintf(stderr," (guess mode ends)");\r
+    };\r
+    fprintf(stderr,"\n");\r
+  };\r
+#endif\r
+#endif\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+zzsave_antlr_state(zzantlr_state *buf)\r
+#else\r
+zzsave_antlr_state(buf)\r
+zzantlr_state *buf;\r
+#endif\r
+{\r
+#ifdef LL_K\r
+       int     i;\r
+#endif\r
+\r
+#ifdef ZZCAN_GUESS\r
+       buf->guess_start = zzguess_start;\r
+       buf->guessing = zzguessing;\r
+#endif\r
+       buf->asp = zzasp;\r
+#ifdef GENAST\r
+       buf->ast_sp = zzast_sp;\r
+#endif\r
+#ifdef ZZINF_LOOK\r
+       buf->inf_labase = zzinf_labase;\r
+       buf->inf_last = zzinf_last;\r
+\r
+/* MR6         Gunnar Rxnning (gunnar@candleweb.no)                                */\r
+/* MR6   Additional state needs to be saved/restored                       */\r
+\r
+       buf->inf_tokens = zzinf_tokens;                                  /* MR6 */\r
+       buf->inf_text = zzinf_text;                                      /* MR6 */\r
+       buf->inf_text_buffer = zzinf_text_buffer;                        /* MR6 */\r
+       buf->inf_line = zzinf_line;                                                  /* MR6 */\r
+\r
+#endif\r
+#ifdef DEMAND_LOOK\r
+       buf->dirty = zzdirty;\r
+#endif\r
+#ifdef LL_K\r
+       for (i=0; i<LL_K; i++) buf->tokenLA[i] = zztokenLA[i];\r
+       for (i=0; i<LL_K; i++) strcpy(buf->textLA[i], zztextLA[i]);\r
+       buf->lap = zzlap;\r
+       buf->labase = zzlabase;\r
+#else\r
+       buf->token = zztoken;\r
+       strcpy(buf->text, zzlextext);\r
+#endif\r
+#ifdef zzTRACE_RULES\r
+\r
+    /* MR10 */\r
+\r
+    buf->traceOptionValue=zzTraceOptionValue;\r
+    buf->traceGuessOptionValue=zzTraceGuessOptionValue;\r
+    buf->traceCurrentRuleName=zzTraceCurrentRuleName;\r
+    buf->traceDepth=zzTraceDepth;\r
+#endif\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+zzrestore_antlr_state(zzantlr_state *buf)\r
+#else\r
+zzrestore_antlr_state(buf)\r
+zzantlr_state *buf;\r
+#endif\r
+{\r
+\r
+#ifdef zzTRACE_RULES\r
+    int     prevTraceOptionValue;\r
+#endif\r
+\r
+#ifdef LL_K\r
+       int     i;\r
+#endif\r
+\r
+#ifdef ZZCAN_GUESS\r
+       zzguess_start = buf->guess_start;\r
+       zzguessing = buf->guessing;\r
+#endif\r
+       zzasp = buf->asp;\r
+#ifdef GENAST\r
+       zzast_sp = buf->ast_sp;\r
+#endif\r
+#ifdef ZZINF_LOOK\r
+       zzinf_labase = buf->inf_labase;\r
+       zzinf_last = buf->inf_last;\r
+\r
+/* MR6         Gunnar Rxnning (gunnar@candleweb.no)                                */\r
+/* MR6   Additional state needs to be saved/restored                       */\r
+\r
+       zzinf_tokens = buf->inf_tokens;                                  /* MR6 */\r
+       zzinf_text = buf->inf_text;                                      /* MR6 */\r
+       zzinf_text_buffer = buf->inf_text_buffer;                        /* MR6 */\r
+       zzinf_line = buf->inf_line;                                                  /* MR6 */\r
+#endif\r
+#ifdef DEMAND_LOOK\r
+       zzdirty = buf->dirty;\r
+#endif\r
+#ifdef LL_K\r
+       for (i=0; i<LL_K; i++) zztokenLA[i] = buf->tokenLA[i];\r
+       for (i=0; i<LL_K; i++) strcpy(zztextLA[i], buf->textLA[i]);\r
+       zzlap = buf->lap;\r
+       zzlabase = buf->labase;\r
+#else\r
+       zztoken = buf->token;\r
+       strcpy(zzlextext, buf->text);\r
+#endif\r
+#ifdef zzTRACE_RULES\r
+\r
+    prevTraceOptionValue=zzTraceOptionValue;\r
+    zzTraceOptionValue=buf->traceOptionValue;\r
+    if ( (prevTraceOptionValue > 0) !=\r
+             (zzTraceOptionValue > 0)) {\r
+      if (zzTraceOptionValue > 0) {\r
+        fprintf(stderr,"trace enable restored in rule %s depth %d\n",\r
+                        zzTraceCurrentRuleName,zzTraceDepth);\r
+      };\r
+      if (zzTraceOptionValue <= 0) {\r
+        fprintf(stderr,"trace disable restored in rule %s depth %d\n",\r
+                        zzTraceCurrentRuleName,zzTraceDepth);\r
+      };\r
+    };\r
+\r
+    zzTraceOptionValue=buf->traceOptionValue;            /* MR10 */\r
+    zzTraceGuessOptionValue=buf->traceGuessOptionValue;  /* MR10 */\r
+    zzTraceCurrentRuleName=buf->traceCurrentRuleName;    /* MR10 */\r
+    zzTraceDepth=buf->traceDepth;                        /* MR10 */\r
+    zzTraceGuessDone(buf);                               /* MR10 */\r
+#endif\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+zzedecode(SetWordType *a)\r
+#else\r
+zzedecode(a)\r
+SetWordType *a;\r
+#endif\r
+{\r
+       register SetWordType *p = a;\r
+       register SetWordType *endp = &(p[zzSET_SIZE]);\r
+       register unsigned e = 0;\r
+\r
+       if ( zzset_deg(a)>1 ) fprintf(stderr, " {");\r
+       do {\r
+               register SetWordType t = *p;\r
+               register SetWordType *b = &(bitmask[0]);\r
+               do {\r
+                       if ( t & *b ) fprintf(stderr, " %s", zztokens[e]);\r
+                       e++;\r
+               } while (++b < &(bitmask[sizeof(SetWordType)*8]));\r
+       } while (++p < endp);\r
+       if ( zzset_deg(a)>1 ) fprintf(stderr, " }");\r
+}\r
+\r
+#ifndef USER_ZZSYN\r
+/* standard error reporting function */\r
+void\r
+#ifdef __USE_PROTOS\r
+zzsyn(char *text, int tok, char *egroup, SetWordType *eset, int etok, int k, char *bad_text)\r
+#else\r
+zzsyn(text, tok, egroup, eset, etok, k, bad_text)\r
+char *text, *egroup, *bad_text;\r
+int tok;\r
+int etok;\r
+int k;\r
+SetWordType *eset;\r
+#endif\r
+{\r
+       \r
+    zzSyntaxErrCount++;                             /* MR11 */\r
+       fprintf(stderr, "line %d: syntax error at \"%s\"", zzline, (tok==zzEOF_TOKEN)?"EOF":bad_text);\r
+       if ( !etok && !eset ) {fprintf(stderr, "\n"); return;}\r
+       if ( k==1 ) fprintf(stderr, " missing");\r
+       else\r
+       {\r
+               fprintf(stderr, "; \"%s\" not", bad_text);\r
+               if ( zzset_deg(eset)>1 ) fprintf(stderr, " in");\r
+       }\r
+       if ( zzset_deg(eset)>0 ) zzedecode(eset);\r
+       else fprintf(stderr, " %s", zztokens[etok]);\r
+       if ( strlen(egroup) > 0 ) fprintf(stderr, " in %s", egroup);\r
+       fprintf(stderr, "\n");\r
+}\r
+#endif\r
+\r
+/* is b an element of set p? */\r
+int\r
+#ifdef __USE_PROTOS\r
+zzset_el(unsigned b, SetWordType *p)\r
+#else\r
+zzset_el(b,p)\r
+unsigned b;\r
+SetWordType *p;\r
+#endif\r
+{\r
+       return( p[BSETDIVWORD(b)] & bitmask[BSETMODWORD(b)] );\r
+}\r
+\r
+int\r
+#ifdef __USE_PROTOS\r
+zzset_deg(SetWordType *a)\r
+#else\r
+zzset_deg(a)\r
+SetWordType *a;\r
+#endif\r
+{\r
+       /* Fast compute degree of a set... the number\r
+          of elements present in the set.  Assumes\r
+          that all word bits are used in the set\r
+       */\r
+       register SetWordType *p = a;\r
+       register SetWordType *endp = &(a[zzSET_SIZE]);\r
+       register int degree = 0;\r
+\r
+       if ( a == NULL ) return 0;\r
+       while ( p < endp )\r
+       {\r
+               register SetWordType t = *p;\r
+               register SetWordType *b = &(bitmask[0]);\r
+               do {\r
+                       if (t & *b) ++degree;\r
+               } while (++b < &(bitmask[sizeof(SetWordType)*8]));\r
+               p++;\r
+       }\r
+\r
+       return(degree);\r
+}\r
+\r
+#ifdef DEMAND_LOOK\r
+\r
+#ifdef LL_K\r
+int\r
+#ifdef __USE_PROTOS\r
+_zzmatch(int _t, char **zzBadText, char **zzMissText,\r
+               int *zzMissTok, int *zzBadTok,\r
+               SetWordType **zzMissSet)\r
+#else\r
+_zzmatch(_t, zzBadText, zzMissText, zzMissTok, zzBadTok, zzMissSet)\r
+int _t;\r
+char **zzBadText;\r
+char **zzMissText;\r
+int *zzMissTok, *zzBadTok;\r
+SetWordType **zzMissSet;\r
+#endif\r
+{\r
+       if ( zzdirty==LL_K ) {\r
+               zzCONSUME;\r
+       }\r
+       if ( LA(1)!=_t ) {\r
+               *zzBadText = *zzMissText=LATEXT(1);     \r
+               *zzMissTok= _t; *zzBadTok=LA(1);\r
+               *zzMissSet=NULL;                                \r
+               return 0;\r
+       }\r
+       zzMakeAttr                                              \r
+       zzdirty++;                                              \r
+       zzlabase++;                                             \r
+       return 1;\r
+}\r
+\r
+int\r
+#ifdef __USE_PROTOS\r
+_zzmatch_wsig(int _t)\r
+#else\r
+_zzmatch_wsig(_t)\r
+int _t;\r
+#endif\r
+{\r
+       if ( zzdirty==LL_K ) {\r
+               zzCONSUME;\r
+       }\r
+       if ( LA(1)!=_t ) {\r
+               return 0;\r
+       }\r
+       zzMakeAttr                                              \r
+       zzdirty++;                                              \r
+       zzlabase++;                                             \r
+       return 1;\r
+}\r
+\r
+#else\r
+\r
+int\r
+#ifdef __USE_PROTOS\r
+_zzmatch(int _t, char **zzBadText, char **zzMissText,\r
+                int *zzMissTok, int *zzBadTok, SetWordType **zzMissSet)\r
+#else\r
+_zzmatch(_t, zzBadText, zzMissText, zzMissTok, zzBadTok, zzMissSet)\r
+int _t;\r
+char **zzBadText;\r
+char **zzMissText;\r
+int *zzMissTok, *zzBadTok;\r
+SetWordType **zzMissSet;\r
+#endif\r
+{                                                              \r
+       if ( zzdirty ) {zzCONSUME;}             \r
+       if ( LA(1)!=_t ) {\r
+               *zzBadText = *zzMissText=LATEXT(1);     \r
+               *zzMissTok= _t; *zzBadTok=LA(1);\r
+               *zzMissSet=NULL;                                \r
+               return 0;\r
+       }                                                               \r
+       zzdirty = 1;                                    \r
+       zzMakeAttr                                              \r
+       return 1;\r
+}\r
+\r
+int\r
+#ifdef __USE_PROTOS\r
+_zzmatch_wsig(int _t)\r
+#else\r
+_zzmatch_wsig(_t)\r
+int _t;\r
+#endif\r
+{\r
+       if ( zzdirty ) {zzCONSUME;}             \r
+       if ( LA(1)!=_t ) {\r
+               return 0;\r
+       }\r
+       zzdirty = 1;                                    \r
+       zzMakeAttr                                              \r
+       return 1;\r
+}\r
+\r
+#endif /*LL_K*/\r
+\r
+#else\r
+\r
+int\r
+#ifdef __USE_PROTOS\r
+_zzmatch(int _t, char **zzBadText, char **zzMissText,\r
+               int *zzMissTok, int *zzBadTok,\r
+               SetWordType **zzMissSet)\r
+#else\r
+_zzmatch(_t, zzBadText, zzMissText, zzMissTok, zzBadTok, zzMissSet)\r
+int _t;\r
+char **zzBadText;\r
+char **zzMissText;\r
+int *zzMissTok, *zzBadTok;\r
+SetWordType **zzMissSet;\r
+#endif\r
+{\r
+       if ( LA(1)!=_t ) {                              \r
+               *zzBadText = *zzMissText=LATEXT(1);     \r
+               *zzMissTok= _t; *zzBadTok=LA(1);\r
+               *zzMissSet=NULL;                                \r
+               return 0;\r
+       }\r
+       zzMakeAttr\r
+       return 1;\r
+}\r
+\r
+int\r
+#ifdef __USE_PROTOS\r
+_zzmatch_wsig(int _t)\r
+#else\r
+_zzmatch_wsig(_t)\r
+int _t;\r
+#endif\r
+{\r
+       if ( LA(1)!=_t ) return 0;\r
+       zzMakeAttr                                              \r
+       return 1;\r
+}\r
+\r
+#endif /*DEMAND_LOOK*/\r
+\r
+#ifdef ZZINF_LOOK\r
+void\r
+#ifdef __USE_PROTOS\r
+_inf_zzgettok(void)\r
+#else\r
+_inf_zzgettok()\r
+#endif\r
+{\r
+       if ( zzinf_labase >= zzinf_last )                                       \r
+               {NLA = zzEOF_TOKEN; strcpy(NLATEXT, "");}       \r
+       else {                                                                                  \r
+               NLA = zzinf_tokens[zzinf_labase];\r
+               zzline = zzinf_line[zzinf_labase];      /* wrong in 1.21 */\r
+               strcpy(NLATEXT, zzinf_text[zzinf_labase]);              \r
+               zzinf_labase++;                                                                 \r
+       }                                                                                               \r
+}\r
+#endif\r
+\r
+#ifdef ZZINF_LOOK\r
+/* allocate default size text,token and line arrays;\r
+ * then, read all of the input reallocing the arrays as needed.\r
+ * Once the number of total tokens is known, the LATEXT(i) array (zzinf_text)\r
+ * is allocated and it's pointers are set to the tokens in zzinf_text_buffer.\r
+ */\r
+void\r
+#ifdef __USE_PROTOS\r
+zzfill_inf_look(void)\r
+#else\r
+zzfill_inf_look()\r
+#endif\r
+{\r
+       int tok, line;\r
+       int zzinf_token_buffer_size = ZZINF_DEF_TOKEN_BUFFER_SIZE;\r
+       int zzinf_text_buffer_size = ZZINF_DEF_TEXT_BUFFER_SIZE;\r
+       int zzinf_text_buffer_index = 0;\r
+       int zzinf_lap = 0;\r
+\r
+       /* allocate text/token buffers */\r
+       zzinf_text_buffer = (char *) malloc(zzinf_text_buffer_size);\r
+       if ( zzinf_text_buffer == NULL )\r
+       {\r
+               fprintf(stderr, "cannot allocate lookahead text buffer (%d bytes)\n",\r
+               zzinf_text_buffer_size);\r
+               exit(PCCTS_EXIT_FAILURE);                                                                       \r
+       }\r
+       zzinf_tokens = (int *) calloc(zzinf_token_buffer_size,sizeof(int));\r
+       if ( zzinf_tokens == NULL )\r
+       {\r
+               fprintf(stderr, "cannot allocate token buffer (%d tokens)\n",\r
+                               zzinf_token_buffer_size);\r
+               exit(PCCTS_EXIT_FAILURE);                                                                       \r
+       }\r
+    zzinf_line = (int *) calloc(zzinf_token_buffer_size,sizeof(int));\r
+    if ( zzinf_line == NULL )\r
+    {\r
+        fprintf(stderr, "cannot allocate line buffer (%d ints)\n",\r
+                zzinf_token_buffer_size);\r
+        exit(PCCTS_EXIT_FAILURE);\r
+       }\r
+\r
+       /* get tokens, copying text to text buffer */\r
+       zzinf_text_buffer_index = 0;\r
+       do {\r
+               zzgettok();\r
+               line = zzreal_line;\r
+               while ( zzinf_lap>=zzinf_token_buffer_size )\r
+               {\r
+                       zzinf_token_buffer_size += ZZINF_BUFFER_TOKEN_CHUNK_SIZE;\r
+                       zzinf_tokens = (int *) realloc(zzinf_tokens,\r
+                                                                                                zzinf_token_buffer_size*sizeof(int));\r
+                       if ( zzinf_tokens == NULL )\r
+                       {\r
+                               fprintf(stderr, "cannot allocate lookahead token buffer (%d tokens)\n",\r
+                                               zzinf_token_buffer_size);\r
+                               exit(PCCTS_EXIT_FAILURE);\r
+                       }\r
+            zzinf_line = (int *) realloc(zzinf_line,\r
+                                         zzinf_token_buffer_size*sizeof(int));\r
+            if ( zzinf_line == NULL )\r
+            {\r
+                fprintf(stderr, "cannot allocate lookahead line buffer (%d ints)\n",\r
+                        zzinf_token_buffer_size);\r
+                exit(PCCTS_EXIT_FAILURE);\r
+                       }\r
+\r
+               }\r
+               while ( (zzinf_text_buffer_index+strlen(NLATEXT)+1) >= zzinf_text_buffer_size )\r
+               {\r
+                       zzinf_text_buffer_size += ZZINF_BUFFER_TEXT_CHUNK_SIZE;\r
+                       zzinf_text_buffer = (char *) realloc(zzinf_text_buffer,\r
+                                                                                                zzinf_text_buffer_size);\r
+                       if ( zzinf_text_buffer == NULL )\r
+                       {\r
+                               fprintf(stderr, "cannot allocate lookahead text buffer (%d bytes)\n",\r
+                                               zzinf_text_buffer_size);\r
+                               exit(PCCTS_EXIT_FAILURE);\r
+                       }\r
+               }\r
+               /* record token and text and line of input symbol */\r
+               tok = zzinf_tokens[zzinf_lap] = NLA;\r
+               strcpy(&zzinf_text_buffer[zzinf_text_buffer_index], NLATEXT);\r
+               zzinf_text_buffer_index += strlen(NLATEXT)+1;\r
+        zzinf_line[zzinf_lap] = line;\r
+               zzinf_lap++;\r
+       } while (tok!=zzEOF_TOKEN);\r
+       zzinf_labase = 0;\r
+       zzinf_last = zzinf_lap-1;\r
+\r
+       /* allocate ptrs to text of ith token */\r
+       zzinf_text = (char **) calloc(zzinf_last+1,sizeof(char *));\r
+       if ( zzinf_text == NULL )\r
+       {\r
+               fprintf(stderr, "cannot allocate lookahead text buffer (%d)\n",\r
+                               zzinf_text_buffer_size);\r
+               exit(PCCTS_EXIT_FAILURE);                                                                               \r
+       }                                                                                                       \r
+       zzinf_text_buffer_index = 0;\r
+       zzinf_lap = 0;\r
+       /* set ptrs so that zzinf_text[i] is the text of the ith token found on input */\r
+       while (zzinf_lap<=zzinf_last)\r
+       {\r
+           zzinf_text[zzinf_lap++] = &zzinf_text_buffer[zzinf_text_buffer_index];\r
+               zzinf_text_buffer_index += strlen(&zzinf_text_buffer[zzinf_text_buffer_index])+1;\r
+       }\r
+}\r
+#endif\r
+\r
+int\r
+#ifdef __USE_PROTOS\r
+_zzsetmatch(SetWordType *e, char **zzBadText, char **zzMissText,\r
+                       int *zzMissTok, int *zzBadTok,\r
+                       SetWordType **zzMissSet,\r
+                       SetWordType *zzTokclassErrset /* MR23 */)\r
+#else\r
+_zzsetmatch(e, zzBadText, zzMissText, zzMissTok, zzBadTok, zzMissSet, zzTokclassErrset /* MR23 */)\r
+SetWordType *e;\r
+char **zzBadText;\r
+char **zzMissText;\r
+int *zzMissTok, *zzBadTok;\r
+SetWordType **zzMissSet;\r
+SetWordType *zzTokclassErrset;\r
+#endif\r
+{\r
+#ifdef DEMAND_LOOK\r
+#ifdef LL_K\r
+       if ( zzdirty==LL_K ) {zzCONSUME;}\r
+#else\r
+       if ( zzdirty ) {zzCONSUME;}\r
+#endif\r
+#endif\r
+       if ( !zzset_el((unsigned)LA(1), e) ) {\r
+               *zzBadText = LATEXT(1); *zzMissText=NULL;\r
+               *zzMissTok= 0; *zzBadTok=LA(1);\r
+               *zzMissSet=zzTokclassErrset; /* MR23 */\r
+               return 0;\r
+       }\r
+       zzMakeAttr           /* MR14 Ger Hobbelt (hobbelt@axa.nl) */\r
+#ifdef DEMAND_LOOK\r
+#ifdef LL_K\r
+       zzdirty++;\r
+    zzlabase++;          /* MR14 Ger Hobbelt (hobbelt@axa.nl) */\r
+#else\r
+       zzdirty = 1;\r
+#endif\r
+#endif\r
+       return 1;\r
+}\r
+\r
+int\r
+#ifdef __USE_PROTOS\r
+_zzmatch_wdfltsig(int tokenWanted, SetWordType *whatFollows)\r
+#else\r
+_zzmatch_wdfltsig(tokenWanted, whatFollows)\r
+int tokenWanted;\r
+SetWordType *whatFollows;\r
+#endif\r
+{\r
+#ifdef DEMAND_LOOK\r
+#ifdef LL_K\r
+       if ( zzdirty==LL_K ) {\r
+                       zzCONSUME;\r
+       }\r
+#else\r
+       if ( zzdirty ) {zzCONSUME;}\r
+#endif\r
+#endif\r
+\r
+       if ( LA(1)!=tokenWanted )\r
+       {\r
+        zzSyntaxErrCount++;     /* MR11 */\r
+               fprintf(stderr,\r
+                               "line %d: syntax error at \"%s\" missing %s\n",\r
+                               zzline,\r
+                               (LA(1)==zzEOF_TOKEN)?"<eof>":(char *)LATEXT(1),\r
+                               zztokens[tokenWanted]);\r
+               zzconsumeUntil( whatFollows );\r
+               return 0;\r
+       }\r
+       else {\r
+               zzMakeAttr                                              \r
+#ifdef DEMAND_LOOK\r
+#ifdef LL_K\r
+               zzdirty++;\r
+               zzlabase++;\r
+#else\r
+               zzdirty = 1;\r
+#endif\r
+#else\r
+/*             zzCONSUME;               consume if not demand lookahead */\r
+#endif\r
+               return 1;\r
+       }\r
+}\r
+\r
+int\r
+#ifdef __USE_PROTOS\r
+_zzsetmatch_wdfltsig(SetWordType *tokensWanted,\r
+                                        int tokenTypeOfSet,\r
+                                        SetWordType *whatFollows)\r
+#else\r
+_zzsetmatch_wdfltsig(tokensWanted, tokenTypeOfSet, whatFollows)\r
+SetWordType *tokensWanted;\r
+int tokenTypeOfSet;\r
+SetWordType *whatFollows;\r
+#endif\r
+{\r
+#ifdef DEMAND_LOOK\r
+#ifdef LL_K\r
+       if ( zzdirty==LL_K ) {zzCONSUME;}\r
+#else\r
+       if ( zzdirty ) {zzCONSUME;}\r
+#endif\r
+#endif\r
+       if ( !zzset_el((unsigned)LA(1), tokensWanted) )\r
+       {\r
+        zzSyntaxErrCount++;     /* MR11 */\r
+               fprintf(stderr,\r
+                               "line %d: syntax error at \"%s\" missing %s\n",\r
+                               zzline,\r
+                               (LA(1)==zzEOF_TOKEN)?"<eof>":(char *)LATEXT(1),\r
+                               zztokens[tokenTypeOfSet]);\r
+               zzconsumeUntil( whatFollows );\r
+               return 0;\r
+       }\r
+       else {\r
+               zzMakeAttr\r
+#ifdef DEMAND_LOOK\r
+#ifdef LL_K\r
+               zzdirty++;\r
+               zzlabase++;\r
+#else\r
+               zzdirty = 1;\r
+#endif\r
+#else\r
+/*             zzCONSUME;              consume if not demand lookahead */\r
+#endif\r
+               return 1;\r
+       }\r
+}\r
+\r
+int\r
+#ifdef __USE_PROTOS\r
+_zzsetmatch_wsig(SetWordType *e)\r
+#else\r
+_zzsetmatch_wsig(e)\r
+SetWordType *e;\r
+#endif\r
+{\r
+#ifdef DEMAND_LOOK\r
+#ifdef LL_K\r
+       if ( zzdirty==LL_K ) {zzCONSUME;}\r
+#else\r
+       if ( zzdirty ) {zzCONSUME;}\r
+#endif\r
+#endif\r
+       if ( !zzset_el((unsigned)LA(1), e) ) return 0;\r
+       zzMakeAttr           /* MR14 Ger Hobbelt (hobbelt@axa.nl) */\r
+#ifdef DEMAND_LOOK\r
+#ifdef LL_K\r
+       zzdirty++;\r
+    zzlabase++;          /* MR14 Ger Hobbelt (hobbelt@axa.nl) */\r
+#else\r
+       zzdirty = 1;\r
+#endif\r
+#endif\r
+       return 1;\r
+}\r
+\r
+#ifdef USER_ZZMODE_STACK\r
+static int  zzmstk[ZZMAXSTK] = { -1 };\r
+static int  zzmdep = 0;\r
+static char zzmbuf[70];\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+zzmpush( int m )\r
+#else\r
+zzmpush( m )\r
+int m;\r
+#endif\r
+{\r
+   if(zzmdep == ZZMAXSTK - 1) {\r
+     sprintf(zzmbuf, "Mode stack overflow ");\r
+     zzerr(zzmbuf);\r
+   } else {\r
+     zzmstk[zzmdep++] = zzauto;\r
+     zzmode(m);\r
+   }\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+zzmpop( void )\r
+#else\r
+zzmpop( )\r
+#endif\r
+{\r
+   if(zzmdep == 0)\r
+   {  sprintf(zzmbuf, "Mode stack underflow ");\r
+      zzerr(zzmbuf);\r
+   }\r
+   else\r
+   {  zzmdep--;\r
+      zzmode(zzmstk[zzmdep]);\r
+   }\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+zzsave_mode_stack( int modeStack[], int *modeLevel )\r
+#else\r
+zzsave_mode_stack( modeStack, modeLevel )\r
+int modeStack[];\r
+int *modeLevel;\r
+#endif\r
+{\r
+  int i;\r
+  memcpy(modeStack, zzmstk, sizeof(zzmstk));\r
+  *modeLevel = zzmdep;\r
+  zzmdep = 0;\r
+\r
+  return;\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+zzrestore_mode_stack( int modeStack[], int *modeLevel )\r
+#else\r
+zzrestore_mode_stack( modeStack, modeLevel )\r
+int modeStack[];\r
+int *modeLevel;\r
+#endif\r
+{\r
+  int i;\r
+\r
+  memcpy(zzmstk, modeStack, sizeof(zzmstk));\r
+  zzmdep = *modeLevel;\r
+\r
+  return;\r
+}\r
+#endif /* USER_ZZMODE_STACK */\r
+\r
+#ifdef __USE_PROTOS\r
+void zzTraceReset(void)\r
+#else\r
+void zzTraceReset()\r
+#endif\r
+{\r
+#ifdef zzTRACE_RULES\r
+  zzTraceOptionValue=zzTraceOptionValueDefault;\r
+  zzTraceGuessOptionValue=1;\r
+  zzTraceCurrentRuleName=NULL;\r
+  zzTraceDepth=0;\r
+#endif\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+void zzTraceGuessFail(void)\r
+#else\r
+void zzTraceGuessFail()\r
+#endif\r
+{\r
+\r
+#ifdef zzTRACE_RULES\r
+#ifdef ZZCAN_GUESS\r
+\r
+  int   doIt=0;\r
+\r
+  if (zzTraceOptionValue <= 0) {\r
+    doIt=0;\r
+  } else if (zzguessing && zzTraceGuessOptionValue <= 0) {\r
+    doIt=0;\r
+  } else {\r
+    doIt=1;\r
+  };\r
+\r
+  if (doIt) {\r
+    fprintf(stderr,"guess failed\n");\r
+  };\r
+#endif\r
+#endif\r
+}\r
+\r
+/* zzTraceOption:\r
+     zero value turns off trace\r
+*/\r
+\r
+#ifdef __USE_PROTOS\r
+void zzTraceIn(char * rule)\r
+#else\r
+void zzTraceIn(rule)\r
+  char  *rule;\r
+#endif\r
+{\r
+#ifdef zzTRACE_RULES\r
+\r
+  int           doIt=0;\r
+\r
+  zzTraceDepth++;\r
+  zzTraceCurrentRuleName=rule;\r
+\r
+  if (zzTraceOptionValue <= 0) {\r
+    doIt=0;\r
+#ifdef ZZCAN_GUESS\r
+  } else if (zzguessing && zzTraceGuessOptionValue <= 0) {\r
+    doIt=0;\r
+#endif\r
+  } else {\r
+    doIt=1;\r
+  };\r
+\r
+  if (doIt) {\r
+    fprintf(stderr,"enter rule %s {\"%s\"} depth %d",\r
+            rule,\r
+            LA(1)==1 ? "@" : (char *) LATEXT(1),    /* MR19 */\r
+            zzTraceDepth);\r
+#ifdef ZZCAN_GUESS\r
+    if (zzguessing) fprintf(stderr," guessing");\r
+#endif\r
+    fprintf(stderr,"\n");\r
+  };\r
+#endif\r
+  return;\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+void zzTraceOut(char * rule)\r
+#else\r
+void zzTraceOut(rule)\r
+  char  *rule;\r
+#endif\r
+{\r
+#ifdef zzTRACE_RULES\r
+  int       doIt=0;\r
+\r
+  zzTraceDepth--;\r
+\r
+  if (zzTraceOptionValue <= 0) {\r
+    doIt=0;\r
+#ifdef ZZCAN_GUESS\r
+  } else if (zzguessing && zzTraceGuessOptionValue <= 0) {\r
+    doIt=0;\r
+#endif\r
+  } else {\r
+    doIt=1;\r
+  };\r
+\r
+  if (doIt) {\r
+    fprintf(stderr,"exit rule %s {\"%s\"} depth %d",\r
+            rule,\r
+            LA(1)==1 ? "@" : (char *) LATEXT(1), /* MR19 */\r
+            zzTraceDepth+1);\r
+#ifdef ZZCAN_GUESS\r
+    if (zzguessing) fprintf(stderr," guessing");\r
+#endif\r
+    fprintf(stderr,"\n");\r
+  };\r
+#endif\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+int zzTraceOption(int delta)\r
+#else\r
+int zzTraceOption(delta)\r
+  int   delta;\r
+#endif\r
+{\r
+#ifdef zzTRACE_RULES\r
+    int     prevValue=zzTraceOptionValue;\r
+\r
+    zzTraceOptionValue=zzTraceOptionValue+delta;\r
+\r
+    if (zzTraceCurrentRuleName != NULL) {\r
+      if (prevValue <= 0 && zzTraceOptionValue > 0) {\r
+        fprintf(stderr,"trace enabled in rule %s depth %d\n",\r
+                                            zzTraceCurrentRuleName,zzTraceDepth);\r
+      };\r
+      if (prevValue > 0 && zzTraceOptionValue <= 0) {\r
+        fprintf(stderr,"trace disabled in rule %s depth %d\n",\r
+                                            zzTraceCurrentRuleName,zzTraceDepth);\r
+      };\r
+    };\r
+    return  prevValue;\r
+#else\r
+    return 0;\r
+#endif\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+int zzTraceGuessOption(int delta)\r
+#else\r
+int zzTraceGuessOption(delta)\r
+  int   delta;\r
+#endif\r
+{\r
+#ifdef zzTRACE_RULES\r
+#ifdef ZZCAN_GUESS\r
+    int     prevValue=zzTraceGuessOptionValue;\r
+\r
+    zzTraceGuessOptionValue=zzTraceGuessOptionValue+delta;\r
+\r
+    if (zzTraceCurrentRuleName != NULL) {\r
+      if (prevValue <= 0 && zzTraceGuessOptionValue > 0) {\r
+        fprintf(stderr,"guess trace enabled in rule %s depth %d\n",\r
+                                                zzTraceCurrentRuleName,zzTraceDepth);\r
+      };\r
+      if (prevValue > 0 && zzTraceGuessOptionValue <= 0) {\r
+        fprintf(stderr,"guess trace disabled in rule %s depth %d\n",\r
+                                                zzTraceCurrentRuleName,zzTraceDepth);\r
+      };\r
+    };\r
+    return prevValue;\r
+#else\r
+    return 0;\r
+#endif\r
+#else\r
+    return 0;\r
+#endif\r
+}\r
+\r
+#endif /* ERR_H */\r
diff --git a/Tools/CodeTools/Source/Pccts/h/int.h b/Tools/CodeTools/Source/Pccts/h/int.h
new file mode 100644 (file)
index 0000000..cdcaa92
--- /dev/null
@@ -0,0 +1,37 @@
+/* ANTLR attribute definition -- long integers\r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
+ * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
+ * company may do whatever they wish with source code distributed with\r
+ * PCCTS or the code generated by PCCTS, including the incorporation of\r
+ * PCCTS, or its output, into commerical software.\r
+ *\r
+ * We encourage users to develop software with PCCTS.  However, we do ask\r
+ * that credit is given to us for developing PCCTS.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like PCCTS and have developed a nice tool with the\r
+ * output, please mention that you developed it using PCCTS.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * ANTLR 1.33\r
+ * Terence Parr\r
+ * Parr Research Corporation\r
+ * with Purdue University and AHPCRC, University of Minnesota\r
+ * 1989-2000\r
+ */\r
+\r
+#ifndef ZZINT_H\r
+#define ZZINT_H\r
+\r
+typedef long Attrib;\r
+\r
+#define zzcr_attr(a,tok,t)     *(a) = atol(t);\r
+\r
+#endif\r
diff --git a/Tools/CodeTools/Source/Pccts/h/pccts_assert.h b/Tools/CodeTools/Source/Pccts/h/pccts_assert.h
new file mode 100644 (file)
index 0000000..ff0dfb5
--- /dev/null
@@ -0,0 +1,10 @@
+#ifndef __PCCTS_ASSERT_H__\r
+#define __PCCTS_ASSERT_H__\r
+\r
+#ifdef PCCTS_USE_NAMESPACE_STD\r
+#include <cassert>\r
+#else\r
+#include <assert.h>\r
+#endif\r
+\r
+#endif\r
diff --git a/Tools/CodeTools/Source/Pccts/h/pccts_iostream.h b/Tools/CodeTools/Source/Pccts/h/pccts_iostream.h
new file mode 100644 (file)
index 0000000..972b32c
--- /dev/null
@@ -0,0 +1,10 @@
+#ifndef __PCCTS_IOSTREAM_H__\r
+#define __PCCTS_IOSTREAM_H__\r
+\r
+#ifdef PCCTS_USE_NAMESPACE_STD\r
+#include <iostream>\r
+#else\r
+#include <iostream.h>\r
+#endif\r
+\r
+#endif\r
diff --git a/Tools/CodeTools/Source/Pccts/h/pccts_istream.h b/Tools/CodeTools/Source/Pccts/h/pccts_istream.h
new file mode 100644 (file)
index 0000000..e25cb8c
--- /dev/null
@@ -0,0 +1,10 @@
+#ifndef __PCCTS_ISTREAM_H__\r
+#define __PCCTS_ISTREAM_H__\r
+\r
+#ifdef PCCTS_USE_NAMESPACE_STD\r
+#include <istream>\r
+#else\r
+#include <istream.h>\r
+#endif\r
+\r
+#endif\r
diff --git a/Tools/CodeTools/Source/Pccts/h/pccts_setjmp.h b/Tools/CodeTools/Source/Pccts/h/pccts_setjmp.h
new file mode 100644 (file)
index 0000000..9ea185c
--- /dev/null
@@ -0,0 +1,10 @@
+#ifndef __PCCTS_SETJMP_H__\r
+#define __PCCTS_SETJMP_H__\r
+\r
+#ifdef PCCTS_USE_NAMESPACE_STD\r
+#include <csetjmp>\r
+#else\r
+#include <setjmp.h>\r
+#endif\r
+\r
+#endif\r
diff --git a/Tools/CodeTools/Source/Pccts/h/pccts_stdarg.h b/Tools/CodeTools/Source/Pccts/h/pccts_stdarg.h
new file mode 100644 (file)
index 0000000..e957430
--- /dev/null
@@ -0,0 +1,10 @@
+#ifndef __PCCTS_STDARG_H__\r
+#define __PCCTS_STDARG_H__\r
+\r
+#ifdef PCCTS_USE_NAMESPACE_STD\r
+#include <cstdarg>\r
+#else\r
+#include <stdarg.h>\r
+#endif\r
+\r
+#endif\r
diff --git a/Tools/CodeTools/Source/Pccts/h/pccts_stdio.h b/Tools/CodeTools/Source/Pccts/h/pccts_stdio.h
new file mode 100644 (file)
index 0000000..ac34d10
--- /dev/null
@@ -0,0 +1,10 @@
+#ifndef __PCCTS_STDIO_H__\r
+#define __PCCTS_STDIO_H__\r
+\r
+#ifdef PCCTS_USE_NAMESPACE_STD\r
+#include <cstdio>\r
+#else\r
+#include <stdio.h>\r
+#endif\r
+\r
+#endif\r
diff --git a/Tools/CodeTools/Source/Pccts/h/pccts_stdlib.h b/Tools/CodeTools/Source/Pccts/h/pccts_stdlib.h
new file mode 100644 (file)
index 0000000..f0b344e
--- /dev/null
@@ -0,0 +1,10 @@
+#ifndef __PCCTS_STDLIB_H__\r
+#define __PCCTS_STDLIB_H__\r
+\r
+#ifdef PCCTS_USE_NAMESPACE_STD\r
+#include <cstdlib>\r
+#else\r
+#include <stdlib.h>\r
+#endif\r
+\r
+#endif\r
diff --git a/Tools/CodeTools/Source/Pccts/h/pccts_string.h b/Tools/CodeTools/Source/Pccts/h/pccts_string.h
new file mode 100644 (file)
index 0000000..458a08a
--- /dev/null
@@ -0,0 +1,10 @@
+#ifndef __PCCTS_STRING_H__\r
+#define __PCCTS_STRING_H__\r
+\r
+#ifdef PCCTS_USE_NAMESPACE_STD\r
+#include <cstring>\r
+#else\r
+#include <string.h>\r
+#endif\r
+\r
+#endif\r
diff --git a/Tools/CodeTools/Source/Pccts/h/pcctscfg.h b/Tools/CodeTools/Source/Pccts/h/pcctscfg.h
new file mode 100644 (file)
index 0000000..0c3c5ba
--- /dev/null
@@ -0,0 +1,359 @@
+#ifndef PCCTS_CONFIG_H\r
+#define PCCTS_CONFIG_H\r
+/*\r
+ * pcctscfg.h (formerly config.h) (for ANTLR, DLG, and SORCERER)\r
+ *\r
+ * This is a simple configuration file that doesn't have config stuff\r
+ * in it, but it's a start.\r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
+ * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
+ * company may do whatever they wish with source code distributed with\r
+ * PCCTS or the code generated by PCCTS, including the incorporation of\r
+ * PCCTS, or its output, into commerical software.\r
+ *\r
+ * We encourage users to develop software with PCCTS.  However, we do ask\r
+ * that credit is given to us for developing PCCTS.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like PCCTS and have developed a nice tool with the\r
+ * output, please mention that you developed it using PCCTS.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * Used by PCCTS 1.33 (SORCERER 1.00B11 and up)\r
+ * Terence Parr\r
+ * Parr Research Corporation\r
+ * with Purdue University and AHPCRC, University of Minnesota\r
+ * 1989-2000\r
+ */\r
+\r
+/* This file knows about the following ``environments''\r
+       UNIX    (default)\r
+       DOS     (use #define PC)\r
+       MAC     (use #define MPW; has a few things for THINK C, Metrowerks)\r
+    MS/C++  (MR14 Microsoft Visual C++ environment uses symbol _MSC_VER)\r
+\r
+ */\r
+\r
+/* should test __STDC__ for 1, but some compilers don't set value, just def */\r
+\r
+#ifndef __USE_PROTOS\r
+#ifdef __STDC__\r
+#define __USE_PROTOS\r
+#endif\r
+#ifdef __cplusplus\r
+#define __USE_PROTOS\r
+#endif\r
+#endif\r
+\r
+#ifdef PCCTS_USE_NAMESPACE_STD\r
+#define PCCTS_NAMESPACE_STD     namespace std {}; using namespace std;\r
+#else\r
+#define PCCTS_NAMESPACE_STD\r
+#endif\r
+\r
+#include "pccts_stdio.h"\r
+#include "pccts_stdlib.h"\r
+\r
+/* largest file name size */\r
+\r
+#ifdef _MAX_PATH\r
+#define MaxFileName            _MAX_PATH /* MR9 RJV: MAX_PATH defined in stdlib.h (MSVC++ 5.0) */\r
+#else\r
+#define MaxFileName            300\r
+#endif\r
+\r
+/*\r
+*  Define PC32 if in a 32-bit PC environment (e.g. extended DOS or Win32).\r
+*  The macros tested here are defined by Watcom, Microsoft, Borland,\r
+*  and djgpp, respectively, when they are used as 32-bit compilers.\r
+*  Users of these compilers *must* be sure to define PC in their\r
+*  makefiles for this to work correctly.\r
+*/\r
+#ifdef PC\r
+# if (defined(__WATCOMC__) || defined(_WIN32) || defined(__WIN32__) || \\r
+   defined(__GNUC__) || defined(__GNUG__))\r
+#     ifndef PC32\r
+#        define PC32\r
+#     endif\r
+#  endif\r
+#endif\r
+\r
+/* MR1  10-Apr-97  Default for PC is short file names                              */\r
+/* MR1            Default for non-PC is long file names                                */\r
+/* MR1            Can override via command line option LONGFILENAMES           */\r
+\r
+#ifndef LONGFILENAMES\r
+#ifndef PC\r
+#define LONGFILENAMES\r
+#endif\r
+#endif\r
+\r
+#ifndef LONGFILENAMES\r
+#define ATOKEN_H                       "AToken.h"\r
+#define ATOKPTR_H                      "ATokPtr.h"\r
+#define ATOKPTR_IMPL_H         "ATokPtrIm.h"\r
+#define ATOKENBUFFER_H         "ATokBuf.h"\r
+#define ATOKENBUFFER_C      "ATokBuf.cpp"\r
+#define ATOKENSTREAM_H         "ATokStr.h"\r
+#define APARSER_H                      "AParser.h"\r
+#define APARSER_C           "AParser.cpp"\r
+#define ASTBASE_H                      "ASTBase.h"\r
+#define ASTBASE_C           "ASTBase.cpp"\r
+#define PCCTSAST_C          "PCCTSAST.cpp"\r
+#define LIST_C              "List.cpp"\r
+#define DLEXERBASE_H           "DLexBase.h"\r
+#define DLEXERBASE_C        "DLexBase.cpp"\r
+#define DLEXER_H            "DLexer.h"\r
+#define STREESUPPORT_C         "STreeSup.C"\r
+#else\r
+#define ATOKEN_H                       "AToken.h"\r
+#define ATOKPTR_H                      "ATokPtr.h"\r
+#define ATOKPTR_IMPL_H         "ATokPtrImpl.h"\r
+#define ATOKENBUFFER_H         "ATokenBuffer.h"\r
+#define ATOKENBUFFER_C         "ATokenBuffer.cpp"\r
+#define ATOKENSTREAM_H         "ATokenStream.h"\r
+#define APARSER_H                      "AParser.h"\r
+#define APARSER_C                      "AParser.cpp"\r
+#define ASTBASE_H                      "ASTBase.h"\r
+#define ASTBASE_C                  "ASTBase.cpp"\r
+#define PCCTSAST_C                     "PCCTSAST.cpp"\r
+#define LIST_C                         "List.cpp"\r
+#define DLEXERBASE_H           "DLexerBase.h"\r
+#define DLEXERBASE_C           "DLexerBase.cpp"\r
+#define DLEXER_H                       "DLexer.h"\r
+#define STREESUPPORT_C         "STreeSupport.cpp"\r
+#endif\r
+\r
+/* SORCERER Stuff */\r
+\r
+/* MR8 6-Aug-97     Change from ifdef PC to ifndef LONGFILENAMES            */\r
+\r
+#ifndef LONGFILENAMES\r
+#define STPARSER_H                     "STreePar.h"\r
+#define STPARSER_C                     "STreePar.C"\r
+#else\r
+#define STPARSER_H                     "STreeParser.h"\r
+#define STPARSER_C                     "STreeParser.cpp"\r
+#endif\r
+\r
+#ifdef MPW\r
+#define CPP_FILE_SUFFIX                ".cp"\r
+#define CPP_FILE_SUFFIX_NO_DOT "cp"\r
+#define OBJ_FILE_SUFFIX                ".o"\r
+#else\r
+#ifdef PC\r
+#define CPP_FILE_SUFFIX                ".cpp"\r
+#define CPP_FILE_SUFFIX_NO_DOT "cpp"\r
+#define OBJ_FILE_SUFFIX                ".obj"\r
+#else\r
+#ifdef __VMS\r
+#define CPP_FILE_SUFFIX                ".cpp"\r
+#define CPP_FILE_SUFFIX_NO_DOT "cpp"\r
+#define OBJ_FILE_SUFFIX                ".obj"\r
+#else\r
+#define CPP_FILE_SUFFIX                ".cpp"\r
+#define CPP_FILE_SUFFIX_NO_DOT "cpp"\r
+#define OBJ_FILE_SUFFIX                ".o"\r
+#endif\r
+#endif\r
+#endif\r
+\r
+/* User may redefine how line information looks */     /* make it #line MR7 */\r
+/* MR21 Use #ifndef */\r
+\r
+#ifndef LineInfoFormatStr\r
+#define LineInfoFormatStr "#line %d \"%s\"\n"\r
+#endif\r
+\r
+#ifdef MPW                         /* Macintosh Programmer's Workshop */\r
+#define ErrHdr "File \"%s\"; Line %d #"\r
+#else\r
+#ifdef _MSC_VER                 /* MR14 Microsoft Visual C++ environment */\r
+#define ErrHdr "%s(%d) :"\r
+#else\r
+#define ErrHdr "%s, line %d:"   /* default */\r
+#endif\r
+#endif\r
+\r
+/* must assume old K&R cpp here, can't use #if defined(..)... */\r
+\r
+#ifdef MPW\r
+#define TopDirectory   ":"\r
+#define DirectorySymbol        ":"\r
+#define OutputDirectoryOption "Directory where all output files should go (default=\":\")"\r
+#else\r
+#ifdef PC\r
+#define TopDirectory   "."\r
+#define DirectorySymbol        "\\"\r
+#define OutputDirectoryOption "Directory where all output files should go (default=\".\")"\r
+#else\r
+#ifdef __VMS\r
+#define TopDirectory  "[000000]"\r
+#define DirectorySymbol       "]"\r
+#define OutputDirectoryOption "Directory where all output files should go (default=\"[]\")"\r
+#else\r
+#define TopDirectory   "."\r
+#define DirectorySymbol        "/"\r
+#define OutputDirectoryOption "Directory where all output files should go (default=\".\")"\r
+#endif\r
+#endif\r
+#endif\r
+\r
+#ifdef MPW\r
+\r
+/* Make sure we have prototypes for all functions under MPW */\r
+\r
+#include "pccts_string.h"\r
+#include "pccts_stdlib.h"\r
+\r
+/* MR6 2-Jun-97        Fixes false dependency caused by VC++ #include scanner  */\r
+/* MR6            Reported by Brad Schick (schick@interaccess.com)     */\r
+#define        MPW_CursorCtl_Header <CursorCtl.h>\r
+#include MPW_CursorCtl_Header\r
+#ifdef __cplusplus\r
+extern "C" {\r
+#endif\r
+extern void fsetfileinfo (const char *filename, unsigned long newcreator, unsigned long newtype);\r
+#ifdef __cplusplus\r
+}\r
+#endif\r
+\r
+/* File creators for various popular development environments */\r
+\r
+#define MAC_FILE_CREATOR 'MPS '   /* MPW Text files */\r
+#if 0\r
+#define MAC_FILE_CREATOR 'KAHL'   /* THINK C/Symantec C++ Text files */\r
+#endif\r
+#if 0\r
+#define MAC_FILE_CREATOR 'CWIE'   /* Metrowerks C/C++ Text files */\r
+#endif\r
+\r
+#endif\r
+\r
+#ifdef MPW\r
+#define DAWDLE SpinCursor(1)\r
+#else\r
+#define DAWDLE\r
+#endif\r
+\r
+#ifdef MPW\r
+#define SPECIAL_INITS\r
+#define SPECIAL_FOPEN\r
+#endif\r
+\r
+#ifdef MPW\r
+#ifdef __cplusplus\r
+inline\r
+#else\r
+static\r
+#endif\r
+void special_inits()\r
+{\r
+  InitCursorCtl((acurHandle) 0);\r
+}\r
+#endif\r
+\r
+#ifdef MPW\r
+#ifdef __cplusplus\r
+inline\r
+#else\r
+static\r
+#endif\r
+void special_fopen_actions(char * s)\r
+{\r
+  fsetfileinfo (s, MAC_FILE_CREATOR, 'TEXT');\r
+}\r
+#endif\r
+\r
+/* Define usable bits for set.c stuff */\r
+#define BytesPerWord   sizeof(unsigned)\r
+#define        WORDSIZE                (sizeof(unsigned)*8)\r
+#define LogWordSize     (WORDSIZE==16?4:5)\r
+\r
+#ifndef TRUE\r
+#define TRUE 1\r
+#endif\r
+#ifndef FALSE\r
+#define FALSE 0\r
+#endif\r
+\r
+#if defined(VAXC) || defined(__VMS)\r
+#include <ssdef.h>\r
+#define PCCTS_EXIT_SUCCESS 1\r
+#define PCCTS_EXIT_FAILURE SS$_ABORT\r
+#define zzDIE          return SS$_ABORT;\r
+#define zzDONE return 1;\r
+\r
+#else /* !VAXC and !__VMS */\r
+\r
+#define PCCTS_EXIT_SUCCESS 0\r
+#define PCCTS_EXIT_FAILURE 1\r
+#define zzDIE          return 1;\r
+#define zzDONE return 0;\r
+\r
+#endif\r
+\r
+#ifdef USER_ZZMODE_STACK\r
+# ifndef ZZSTACK_MAX_MODE\r
+#  define  ZZSTACK_MAX_MODE 32\r
+# endif\r
+# define  ZZMAXSTK (ZZSTACK_MAX_MODE * 2)\r
+#endif\r
+\r
+#ifndef DllExportPCCTS\r
+#define DllExportPCCTS\r
+#endif\r
+\r
+#ifdef PC\r
+#ifndef PCCTS_CASE_INSENSITIVE_FILE_NAME\r
+#define PCCTS_CASE_INSENSITIVE_FILE_NAME\r
+#endif\r
+#endif\r
+\r
+#ifdef PC32\r
+#ifndef PCCTS_CASE_INSENSITIVE_FILE_NAME\r
+#define PCCTS_CASE_INSENSITIVE_FILE_NAME\r
+#endif\r
+#endif\r
+\r
+#ifdef __VMS\r
+#ifndef PCCTS_CASE_INSENSITIVE_FILE_NAME\r
+#define PCCTS_CASE_INSENSITIVE_FILE_NAME\r
+#endif\r
+#endif\r
+\r
+#ifdef __USE_PROTOS\r
+#ifndef PCCTS_USE_STDARG\r
+#define PCCTS_USE_STDARG\r
+#endif\r
+#endif\r
+\r
+#ifdef __STDC__\r
+#ifndef PCCTS_USE_STDARG\r
+#define PCCTS_USE_STDARG\r
+#endif\r
+#endif\r
+\r
+#ifdef __cplusplus\r
+#ifndef PCCTS_USE_STDARG\r
+#define PCCTS_USE_STDARG\r
+#endif\r
+#endif\r
+\r
+#ifdef _MSC_VER\r
+/*Turn off the warnings for:\r
+  unreferenced inline/local function has been removed\r
+*/\r
+#pragma warning(disable : 4514)\r
+/* function not expanded */\r
+#pragma warning(disable : 4710)\r
+#endif\r
+\r
+#endif\r
diff --git a/Tools/CodeTools/Source/Pccts/h/pcnames.bat b/Tools/CodeTools/Source/Pccts/h/pcnames.bat
new file mode 100644 (file)
index 0000000..8784aee
--- /dev/null
@@ -0,0 +1,11 @@
+ren aparser.c aparser.cpp\r
+ren astbase.c astbase.cpp\r
+ren atokenbu.c atokbuf.cpp\r
+ren atokenbu.h atokbuf.h\r
+ren atokenst.h atokstr.h\r
+ren dlexerba.c dlexbase.cpp\r
+ren dlexerba.h dlexbase.h\r
+ren dlexer.c dlexer.cpp\r
+ren list.c list.cpp\r
+ren pblackbo.h pblckbox.h\r
+ren pcctsast.c pcctsast.cpp\r
diff --git a/Tools/CodeTools/Source/Pccts/h/slist.cpp b/Tools/CodeTools/Source/Pccts/h/slist.cpp
new file mode 100644 (file)
index 0000000..faf2fe4
--- /dev/null
@@ -0,0 +1,116 @@
+/*\r
+ * SList.C\r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to SORCERER -- SORCERER is in the public\r
+ * domain.  An individual or company may do whatever they wish with\r
+ * source code distributed with SORCERER or the code generated by\r
+ * SORCERER, including the incorporation of SORCERER, or its output, into\r
+ * commerical software.\r
+ *\r
+ * We encourage users to develop software with SORCERER.  However, we do\r
+ * ask that credit is given to us for developing SORCERER.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like SORCERER and have developed a nice tool with the\r
+ * output, please mention that you developed it using SORCERER.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * PCCTS 1.33\r
+ * Terence Parr\r
+ * Parr Research Corporation\r
+ * with Purdue University and AHPCRC, University of Minnesota\r
+ * 1992-2000\r
+ */\r
+\r
+#define ANTLR_SUPPORT_CODE\r
+\r
+#include "SList.h"\r
+#include "pccts_stdarg.h" // MR23\r
+\r
+/* Iterate over a list of elements; returns ptr to a new element\r
+ * in list upon every call and NULL when no more are left.\r
+ * Very useful like this:\r
+ *\r
+ *             cursor = mylist;\r
+ *             while ( (p=mylist->iterate(&cursor)) ) {\r
+ *                     // place with element p\r
+ *             }\r
+ *\r
+ * The cursor must be initialized to point to the list to iterate over.\r
+ */\r
+void *SList::\r
+iterate(SListNode **cursor)\r
+{\r
+       void *e;\r
+\r
+       if ( cursor == NULL || *cursor==NULL ) return NULL;\r
+       if ( head == *cursor ) { *cursor = (*cursor)->next(); }\r
+       e = (*cursor)->elem();\r
+       (*cursor) = (*cursor)->next();\r
+       return e;\r
+}\r
+\r
+/* add an element to end of list. */\r
+void SList::\r
+add(void *e)\r
+{\r
+       SListNode *p, *tail=NULL;\r
+       require(e!=NULL, "slist_add: attempting to add NULL list element");\r
+\r
+       p = new SListNode;\r
+       require(p!=NULL, "add: cannot alloc new list node");\r
+       p->setElem(e);\r
+       if ( head == NULL )\r
+       {\r
+               head = tail = p;\r
+       }\r
+       else                                                            /* find end of list */\r
+       {\r
+               tail->setNext(p);\r
+               tail = p;\r
+       }\r
+}\r
+\r
+void SList::\r
+lfree()\r
+{\r
+       SListNode *p,*q;\r
+\r
+       if ( head==NULL ) return;       /* empty list */\r
+       for (p = head; p!=NULL; p=q)\r
+       {\r
+               q = p->next();\r
+               free(p);\r
+       }\r
+}\r
+\r
+PCCTS_AST *SList::\r
+to_ast(SList list)\r
+{\r
+       PCCTS_AST *t=NULL, *last=NULL;\r
+       SListNode *p;\r
+\r
+       for (p = head; p!=NULL; p=p->next())\r
+       {\r
+               PCCTS_AST *u = (PCCTS_AST *)p->elem();\r
+               if ( last==NULL ) last = t = u;\r
+               else { last->setRight(u); last = u; }\r
+       }\r
+       return t;\r
+}\r
+\r
+// MR23\r
+int SList::printMessage(FILE* pFile, const char* pFormat, ...)\r
+{\r
+       va_list marker;\r
+       va_start( marker, pFormat );\r
+       int iRet = vfprintf(pFile, pFormat, marker);\r
+       va_end( marker );\r
+       return iRet;\r
+}\r
diff --git a/Tools/CodeTools/Source/Pccts/history.ps b/Tools/CodeTools/Source/Pccts/history.ps
new file mode 100644 (file)
index 0000000..e2600d5
--- /dev/null
@@ -0,0 +1,473 @@
+%!PS-Adobe-3.0
+%%Creator: groff version 1.06
+%%DocumentNeededResources: font Times-Roman
+%%+ font Times-Italic
+%%+ font Courier
+%%DocumentSuppliedResources: procset grops 1.06 0
+%%Pages: 3
+%%PageOrder: Ascend
+%%Orientation: Portrait
+%%EndComments
+%%BeginProlog
+%%BeginResource: procset grops 1.06 0
+
+/setpacking where {
+       pop
+       currentpacking
+       true setpacking
+} if
+
+/grops 120 dict dup begin 
+
+% The ASCII code of the space character.
+/SC 32 def
+
+/A /show load def
+/B { 0 SC 3 -1 roll widthshow } bind def
+/C { 0 exch ashow } bind def
+/D { 0 exch 0 SC 5 2 roll awidthshow } bind def
+/E { 0 rmoveto show } bind def
+/F { 0 rmoveto 0 SC 3 -1 roll widthshow } bind def
+/G { 0 rmoveto 0 exch ashow } bind def
+/H { 0 rmoveto 0 exch 0 SC 5 2 roll awidthshow } bind def
+/I { 0 exch rmoveto show } bind def
+/J { 0 exch rmoveto 0 SC 3 -1 roll widthshow } bind def
+/K { 0 exch rmoveto 0 exch ashow } bind def
+/L { 0 exch rmoveto 0 exch 0 SC 5 2 roll awidthshow } bind def
+/M { rmoveto show } bind def
+/N { rmoveto 0 SC 3 -1 roll widthshow } bind def
+/O { rmoveto 0 exch ashow } bind def
+/P { rmoveto 0 exch 0 SC 5 2 roll awidthshow } bind def
+/Q { moveto show } bind def 
+/R { moveto 0 SC 3 -1 roll widthshow } bind def
+/S { moveto 0 exch ashow } bind def
+/T { moveto 0 exch 0 SC 5 2 roll awidthshow } bind def
+
+% name size font SF -
+
+/SF {
+       findfont exch
+       [ exch dup 0 exch 0 exch neg 0 0 ] makefont
+       dup setfont
+       [ exch /setfont cvx ] cvx bind def
+} bind def
+
+% name a c d font MF -
+
+/MF {
+       findfont
+       [ 5 2 roll
+       0 3 1 roll % b
+       neg 0 0 ] makefont
+       dup setfont
+       [ exch /setfont cvx ] cvx bind def
+} bind def
+
+/level0 0 def
+/RES 0 def
+/PL 0 def
+/LS 0 def
+
+% Guess the page length.
+% This assumes that the imageable area is vertically centered on the page.
+% PLG - length
+
+/PLG {
+       gsave newpath clippath pathbbox grestore
+       exch pop add exch pop
+} bind def
+
+% BP -
+
+/BP {
+       /level0 save def
+       1 setlinecap
+       1 setlinejoin
+       72 RES div dup scale
+       LS {
+               90 rotate
+       } {
+               0 PL translate
+       } ifelse
+       1 -1 scale
+} bind def
+
+/EP {
+       level0 restore
+       showpage
+} bind def
+
+
+% centerx centery radius startangle endangle DA -
+
+/DA {
+       newpath arcn stroke
+} bind def
+
+% x y SN - x' y'
+% round a position to nearest (pixel + (.25,.25))
+
+/SN {
+       transform 
+       .25 sub exch .25 sub exch
+       round .25 add exch round .25 add exch
+       itransform
+} bind def
+       
+% endx endy startx starty DL -
+% we round the endpoints of the line, so that parallel horizontal
+% and vertical lines will appear even
+
+/DL {
+       SN
+       moveto
+       SN
+       lineto stroke
+} bind def
+
+% centerx centery radius DC -
+
+/DC {
+       newpath 0 360 arc closepath
+} bind def
+
+
+/TM matrix def
+
+%  width height centerx centery DE -
+
+/DE {
+       TM currentmatrix pop
+       translate scale newpath 0 0 .5 0 360 arc closepath
+       TM setmatrix
+} bind def
+
+% these are for splines
+
+/RC /rcurveto load def
+/RL /rlineto load def
+/ST /stroke load def
+/MT /moveto load def
+/CL /closepath load def
+
+% fill the last path
+
+% amount FL -
+
+/FL {
+       currentgray exch setgray fill setgray
+} bind def
+
+% fill with the ``current color''
+
+/BL /fill load def
+
+/LW /setlinewidth load def
+% new_font_name encoding_vector old_font_name RE -
+
+/RE {
+       findfont
+       dup maxlength dict begin
+       {
+               1 index /FID ne { def } { pop pop } ifelse
+       } forall
+       /Encoding exch def
+       dup /FontName exch def
+       currentdict end definefont pop
+} bind def
+
+/DEFS 0 def
+
+% hpos vpos EBEGIN -
+
+/EBEGIN {
+       moveto
+       DEFS begin
+} bind def
+
+/EEND /end load def
+
+/CNT 0 def
+/level1 0 def
+
+% llx lly newwid wid newht ht newllx newlly PBEGIN -
+
+/PBEGIN {
+       /level1 save def
+       translate
+       div 3 1 roll div exch scale
+       neg exch neg exch translate
+       % set the graphics state to default values
+       0 setgray
+       0 setlinecap
+       1 setlinewidth
+       0 setlinejoin
+       10 setmiterlimit
+       [] 0 setdash
+       /setstrokeadjust where {
+               pop
+               false setstrokeadjust
+       } if
+       /setoverprint where {
+               pop
+               false setoverprint
+       } if
+       newpath
+       /CNT countdictstack def
+       userdict begin
+       /showpage {} def
+} bind def
+
+/PEND {
+       clear
+       countdictstack CNT sub { end } repeat
+       level1 restore
+} bind def
+
+end def
+
+/setpacking where {
+       pop
+       setpacking
+} if
+%%EndResource
+%%IncludeResource: font Times-Roman
+%%IncludeResource: font Times-Italic
+%%IncludeResource: font Courier
+grops begin/DEFS 1 dict def DEFS begin/u{.001 mul}bind def end/RES 72 def/PL
+792 def/LS false def/ENC0[/asciicircum/asciitilde/Scaron/Zcaron/scaron/zcaron
+/Ydieresis/trademark/quotesingle/.notdef/.notdef/.notdef/.notdef/.notdef
+/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
+/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/space
+/exclam/quotedbl/numbersign/dollar/percent/ampersand/quoteright/parenleft
+/parenright/asterisk/plus/comma/hyphen/period/slash/zero/one/two/three/four
+/five/six/seven/eight/nine/colon/semicolon/less/equal/greater/question/at/A/B/C
+/D/E/F/G/H/I/J/K/L/M/N/O/P/Q/R/S/T/U/V/W/X/Y/Z/bracketleft/backslash
+/bracketright/circumflex/underscore/quoteleft/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q
+/r/s/t/u/v/w/x/y/z/braceleft/bar/braceright/tilde/.notdef/quotesinglbase
+/guillemotleft/guillemotright/bullet/florin/fraction/perthousand/dagger
+/daggerdbl/endash/emdash/ff/fi/fl/ffi/ffl/dotlessi/dotlessj/grave/hungarumlaut
+/dotaccent/breve/caron/ring/ogonek/quotedblleft/quotedblright/oe/lslash
+/quotedblbase/OE/Lslash/.notdef/exclamdown/cent/sterling/currency/yen/brokenbar
+/section/dieresis/copyright/ordfeminine/guilsinglleft/logicalnot/minus
+/registered/macron/degree/plusminus/twosuperior/threesuperior/acute/mu
+/paragraph/periodcentered/cedilla/onesuperior/ordmasculine/guilsinglright
+/onequarter/onehalf/threequarters/questiondown/Agrave/Aacute/Acircumflex/Atilde
+/Adieresis/Aring/AE/Ccedilla/Egrave/Eacute/Ecircumflex/Edieresis/Igrave/Iacute
+/Icircumflex/Idieresis/Eth/Ntilde/Ograve/Oacute/Ocircumflex/Otilde/Odieresis
+/multiply/Oslash/Ugrave/Uacute/Ucircumflex/Udieresis/Yacute/Thorn/germandbls
+/agrave/aacute/acircumflex/atilde/adieresis/aring/ae/ccedilla/egrave/eacute
+/ecircumflex/edieresis/igrave/iacute/icircumflex/idieresis/eth/ntilde/ograve
+/oacute/ocircumflex/otilde/odieresis/divide/oslash/ugrave/uacute/ucircumflex
+/udieresis/yacute/thorn/ydieresis]def/Courier@0 ENC0/Courier RE/Times-Italic@0
+ENC0/Times-Italic RE/Times-Roman@0 ENC0/Times-Roman RE
+%%EndProlog
+%%Page: 1 1
+%%BeginPageSetup
+BP
+%%EndPageSetup
+/F0 13/Times-Roman@0 SF(The History of PCCTS)228.232 84 Q/F1 11/Times-Roman@0
+SF(The Purdue Compiler)190.468 108 Q(-Construction T)-.22 E(ool Set)-.88 E/F2
+10/Times-Italic@0 SF -.92(Te)262.245 144 S -.37(re).92 G(nce P).37 E(arr)-.8 E
+/F3 10/Times-Roman@0 SF -.15(Pa)234.755 156 S(rr Research Corporation).15 E
+(Minneapolis, Minnesota)239.39 168 Q(and)280.78 180 Q(Uni)239.315 192 Q -.15
+(ve)-.25 G(rsity of Minnesota).15 E
+(Army High Performance Computing Research Center)180.38 204 Q F2
+([Updated 8-7-94])252.31 228 Q F1 .084(The PCCTS project be)97 259.6 R -.055
+(ga)-.165 G 2.834(na).055 G 2.833(sap)220.547 259.6 S(arser)240.876 259.6 Q
+.083(-generator project for a graduate course at Purdue Uni-)-.22 F -.165(ve)72
+275.6 S 1.085(rsity in the F).165 F 1.086
+(all of 1988 taught by Hank Dietz\212 translator)-.165 F 1.086
+(-writing systems.)-.22 F 1.086(Under the guid-)6.586 F .627
+(ance of Professor Dietz, the parser generator)72 291.6 R 3.377(,A)-.44 G .626
+(NTLR \(originally called YUCC\), continued after)285.18 291.6 R .253
+(the termination of the course and e)72 307.6 R -.165(ve)-.275 G .254
+(ntually became the subject of T).165 F .254(erence P)-.77 F(arr')-.165 E 3.004
+(sM)-.605 G(aster')445.083 307.6 Q 3.004(st)-.605 G(hesis.)479.25 307.6 Q
+(Originally)72 323.6 Q 4.092(,l)-.715 G -.165(ex)126.406 323.6 S 1.342
+(ical analysis w).165 F 1.342(as performed via ALX which w)-.11 F 1.342
+(as soon replaced by W)-.11 F 1.341(ill Cohen')-.44 F(s)-.605 E .594
+(DLG in the F)72 339.6 R .594(all of 1989 \(DF)-.165 F .595(A-based le)-.814 F
+.595(xical-analyzer generator)-.165 F 3.345(,a)-.44 G .595(lso an of)367.188
+339.6 R .595(fshoot of the graduate)-.275 F(translation course\).)72 355.6 Q
+.877(The alpha v)97 375.2 R .877(ersion of ANTLR w)-.165 F .877(as totally re)
+-.11 F .876(written resulting in 1.00B.)-.275 F -1.221(Ve)6.376 G .876
+(rsion 1.00B w)1.221 F(as)-.11 E 1.577(released via an internet ne)72 391.2 R
+1.577(wsgroup \(comp.compilers\) posting in February of 1990 and quickly)-.275
+F -.055(ga)72 407.2 S .356(thered a lar).055 F .356(ge follo)-.198 F 3.106
+(wing. 1.00B)-.275 F .356(generated only LL\(1\) parsers, b)3.106 F .356
+(ut allo)-.22 F .356(wed the mer)-.275 F .356(ged descrip-)-.198 F 1.859
+(tion of le)72 423.2 R 1.859(xical and syntactic analysis.)-.165 F 1.86
+(It had rudimentary attrib)7.359 F 1.86(ute handling similar to that of)-.22 F
+-.55 -1.32(YA C)72 439.2 T 3.549(Ca)1.32 G .799
+(nd did not incorporate rule parameters or return v)109.231 439.2 R .798
+(alues; do)-.275 F(wnw)-.275 E .798(ard inheritance w)-.11 F .798(as v)-.11 F
+(ery)-.165 E -.165(aw)72 455.2 S(kw).165 E 6.433(ard. 1.00B-generated)-.11 F
+3.684(parsers terminated upon the \214rst syntax error)6.433 F 9.184(.L)-.605 G
+-.165(ex)440.916 455.2 S 3.684(ical classes).165 F(\(modes\) were not allo)72
+471.2 Q(wed and DLG did not ha)-.275 E .33 -.165(ve a)-.22 H 2.75(ni).165 G
+(nteracti)305.959 471.2 Q .33 -.165(ve m)-.275 H(ode.).165 E .831
+(Upon starting his Ph.D. at Purdue in the F)97 490.8 R .83(all of 1990, T)-.165
+F .83(erence P)-.77 F .83(arr be)-.165 F -.055(ga)-.165 G 3.58(nt).055 G .83
+(he second total)436.351 490.8 R(re)72 506.8 Q 1.646(write of ANTLR.)-.275 F
+1.646(The method by which grammars may be practically analyzed to generate)
+7.146 F/F4 11/Times-Italic@0 SF(LL)72.638 522.8 Q F1(\().583 E F4(k).396 E F1
+3.849(\)l).737 G 1.099(ookahead information w)105.703 522.8 R 1.099(as disco)
+-.11 F -.165(ve)-.165 G 1.099(red in August of 1990 just before his return.)
+.165 F -1.221(Ve)6.598 G(rsion)1.221 E .626
+(1.00 incorporated this algorithm and included the AST mechanism, le)72 538.8 R
+.626(xical classes, error classes,)-.165 F .354(and automatic error reco)72
+554.8 R -.165(ve)-.165 G .353(ry; code quality and portability were higher).165
+F 5.853(.I)-.605 G 3.103(nF)395.965 554.8 S .353(ebruary of 1992 1.00)410.684
+554.8 R -.11(wa)72 570.8 S 2.76(sr).11 G .01
+(eleased via an article in SIGPLAN Notices.)95.418 570.8 R .01
+(Peter Dahl, Ph.D. candidate, and Professor Matt)5.51 F(O'K)72 586.8 Q 2.074
+(eefe \(both at the Uni)-.275 F -.165(ve)-.275 G 2.073
+(rsity of Minnesota\) tested this v).165 F 2.073(ersion e)-.165 F(xtensi)-.165
+E -.165(ve)-.275 G(ly).165 E 7.573(.D)-.715 G 2.073(ana Hogg)448.522 586.8 R
+(att)-.055 E .078(\(Micro Data Base Systems, Inc.\) came up with the idea of e\
+rror grouping \(strings attached to non-)72 602.8 R
+(terminals\) and tested 1.00 hea)72 618.8 Q(vily)-.22 E(.)-.715 E -1.221(Ve)97
+638.4 S .878(rsion 1.06 w)1.221 F .877
+(as released in December 1992 and represented a lar)-.11 F .877
+(ge feature enhancement)-.198 F -.165(ove)72 654.4 S 3.648(r1).165 G 3.648
+(.00. F)100.365 654.4 R .898(or e)-.165 F .899
+(xample, rudimentary semantic predicates were introduced, error messages were)
+-.165 F 2.281(signi\214cantly impro)72 670.4 R -.165(ve)-.165 G 5.031(df).165 G
+(or)181.953 670.4 Q F4(k)5.427 E F1 2.281
+(>1 lookahead and ANTLR parsers could indicate that lookahead).737 F 1.381
+(fetches were to occur only when necessary for the parse \(normally)72 686.4 R
+4.131(,t)-.715 G 1.381(he lookahead `)387.051 686.4 R(`pipe')-.814 E 4.132('w)
+-.814 G(as)494.837 686.4 Q 1.182(constantly full\).)72 702.4 R 1.182
+(Russell Quong joined the project in the Spring of 1992 to aid in the semantic)
+6.682 F .681(predicate design.)72 718.4 R(Be)6.181 E .681(ginning and adv)-.165
+F .682(anced tutorials were created and released as well.)-.275 F 3.432(Am)
+6.182 G(ak)485.179 718.4 Q(e-)-.11 E .993(\214le generator w)72 734.4 R .993
+(as included that sets up dependencies and such correctly for ANTLR and DLG.)
+-.11 F EP
+%%Page: 2 2
+%%BeginPageSetup
+BP
+%%EndPageSetup
+/F0 11/Times-Roman@0 SF 2.75(-2-)278.837 52 S -1.221(Ve)72 88 S 1.414(ry fe)
+1.221 F 4.164(w1)-.275 G 1.414(.00 incompatibilities were introduced \(1.00 w)
+122.81 88 R 1.415(as quite dif)-.11 F 1.415(ferent from 1.00B in some)-.275 F
+(areas\).)72 104 Q 1.089(1.10 w)97 123.6 R 1.088
+(as released on August 31, 1993 and incorporated b)-.11 F 1.088(ug \214x)-.22 F
+1.088(es, a fe)-.165 F 3.838(wf)-.275 G 1.088(eature enhance-)433.59 123.6 R
+3.112(ments and a major ne)72 139.6 R 5.863(wc)-.275 G(apability \212)196.957
+139.6 Q 3.113(an arbitrary lookahead operator \(syntactic predicate\),)5.863 F
+/F1 11/Courier@0 SF(\(alpha\)?beta)72 155.6 Q F0 6.754(.T)C 1.254
+(his feature w)167.425 155.6 R 1.254
+(as co-designed with Professor Russell Quong also at Purdue.)-.11 F 3.297 -.88
+(To s)72 171.6 T 1.537
+(upport in\214nite lookahead, a preprocessor \215ag, ZZINF_LOOK, w).88 F 1.537
+(as created that forced the)-.11 F .21(ANTLR\(\) macro to tok)72 187.6 R .21
+(enize all input prior to parsing.)-.11 F .209(Hence, at an)5.709 F 2.959(ym)
+-.165 G .209(oment, an action or predi-)389.215 187.6 R .936
+(cate can see the entire input sentence.)72 203.6 R .936
+(The predicate mechanism of 1.06 w)6.436 F .937(as e)-.11 F .937
+(xtended to allo)-.165 F(w)-.275 E .55
+(multiple predicates to be hoisted; the syntactic conte)72 219.6 R .55
+(xt of a predicate w)-.165 F .55(as also mo)-.11 F -.165(ve)-.165 G 3.299(da)
+.165 G .549(long with)461.585 219.6 R(the predicate.)72 235.6 Q .754
+(In February of 1994, SORCERER \(a simple tree-parser generator\) w)97 255.2 R
+.755(as released.)-.11 F .755(This tool)6.255 F(allo)72 271.2 Q .6(ws the user\
+ to parse child-sibling trees by specifying a grammar rather than b)-.275 F
+.599(uilding a recur)-.22 F(-)-.22 E(si)72 287.2 Q -.165(ve)-.275 G 1.39
+(-descent tree w).165 F(alk)-.11 E 1.391(er by hand.)-.11 F -.88(Wo)6.891 G
+1.391(rk to).88 F -.11(wa)-.275 G 1.391
+(rds a library of tree transformations is underw).11 F(ay)-.11 E(.)-.715 E .581
+(Aaron Sa)72 303.2 R(wde)-.165 E 3.331(ya)-.165 G 3.331(tT)145.531 303.2 S .581
+(he Uni)158.641 303.2 R -.165(ve)-.275 G .58
+(rsity of Minnesota became a second author of SORCERER after the).165 F
+(initial release.)72 319.2 Q .627(On April 1, 1994, PCCTS 1.20 w)97 338.8 R
+.627(as released.)-.11 F .627(This w)6.127 F .627(as the \214rst v)-.11 F .627
+(ersion to acti)-.165 F -.165(ve)-.275 G .627(ly support).165 F 1.664
+(C++ output.)72 354.8 R 1.664(It also included important \214x)7.164 F 1.663
+(es re)-.165 F -.055(ga)-.165 G 1.663
+(rding semantic predicates and \(..\)+ subrules.).055 F(This v)72 370.8 Q
+(ersion also introduced tok)-.165 E(en classes, the `)-.11 E(`)-.814 E/F2 11
+/Times-Italic@0 SF(not)A F0 1.628 -.814('' o)D(perator).814 E 2.75(,a)-.44 G
+(nd tok)355.294 370.8 Q(en ranges.)-.11 E .764
+(On June 19, 1994, SORCERER 1.00B9 w)97 390.4 R .765(as released.)-.11 F .765
+(Gary Funck of Intrepid T)6.265 F(echnology)-.77 E .807
+(joined the SORCERER team and pro)72 406.4 R .807(vided v)-.165 F .807(ery v)
+-.165 F .807(aluable suggestions re)-.275 F -.055(ga)-.165 G .806(rding the `)
+.055 F(`transform')-.814 E(')-.814 E(mode of SORCERER.)72 422.4 Q 1.137
+(On August 8, 1994, PCCTS 1.21 w)97 442 R 1.137(as released.)-.11 F 1.138
+(It mainly cleaned up the C++ output and)6.637 F(included a number of b)72 458
+Q(ug \214x)-.22 E(es.)-.165 E .316(From the 1.21 release forw)97 477.6 R .316
+(ard, the maintenance and support of all PCCTS tools will be pri-)-.11 F 1.557
+(marily pro)72 493.6 R 1.557(vided by P)-.165 F 1.557
+(arr Research Corporation, Minneapolis MN---an or)-.165 F -.055(ga)-.198 G
+1.558(nization founded on).055 F 1.616(the principles of e)72 509.6 R 1.616
+(xcellence in research and inte)-.165 F 1.616(grity in b)-.165 F 1.616
+(usiness; we are de)-.22 F -.22(vo)-.275 G 1.616(ted to pro).22 F(viding)-.165
+E 1.202(really cool softw)72 525.6 R 1.202(are tools.)-.11 F 1.202
+(Please see \214le PCCTS.FUTURE for more information.)6.702 F 1.203(All PCCTS)
+6.703 F(tools currently in the public domain will continue to be in the public\
+ domain.)72 541.6 Q 1.198(Looking to)97 561.2 R -.11(wa)-.275 G 1.198
+(rds the future, a graphical user).11 F(-interf)-.22 E 1.197
+(ace is in the design phase.)-.11 F 1.197(This w)6.697 F(ould)-.11 E(allo)72
+577.2 Q 2.753(wu)-.275 G .003(sers to vie)104.42 577.2 R 2.753(wt)-.275 G .004
+(he syntax diagram representation of their grammars and w)162.509 577.2 R .004
+(ould highlight non-)-.11 F 1.181(deterministic productions.)72 593.2 R -.165
+(Pa)6.681 G 1.18(rsing can be traced graphically as well.).165 F 1.18
+(This system will be b)6.68 F(uilt)-.22 E .167(using a multiplatform windo)72
+609.2 R 2.917(wl)-.275 G(ibrary)211.73 609.2 Q 5.667(.W)-.715 G 2.917(ea)
+255.204 609.2 S .168(lso anticipate the introduction of a sophisticated error)
+267.889 609.2 R(handling mechanism called `)72 625.2 Q(`parser e)-.814 E
+(xception handling')-.165 E 2.75('i)-.814 G 2.75(nan)327.431 625.2 S
+(ear future release.)348.815 625.2 Q(Currently)97 644.8 Q 3.019(,P)-.715 G .269
+(CCTS is used at o)150.333 644.8 R -.165(ve)-.165 G 3.019(r1).165 G .269
+(000 kno)253.098 644.8 R .268(wn academic, go)-.275 F -.165(ve)-.165 G .268
+(rnment, and commercial sites).165 F .859(in 37 countries.)72 660.8 R .859
+(Of course, the true number of users is unkno)6.359 F .859(wn due to the lar)
+-.275 F .859(ge number of ftp)-.198 F(sites.)72 676.8 Q EP
+%%Page: 3 3
+%%BeginPageSetup
+BP
+%%EndPageSetup
+/F0 11/Times-Roman@0 SF 2.75(-3-)278.837 52 S(Credits)272.11 88 Q .44 LW
+472.162 103.75 103.838 103.75 DL(Idea/T)134.236 117 Q 52.987(ool Coder)-.88 F
+(Co-designer\(s\))345.436 117 Q 281.334 103.75 281.334 124.75 DL 209.273 103.75
+209.273 124.75 DL 209.273 124.75 103.838 124.75 DL 103.838 126.75 209.273
+126.75 DL 281.334 124.75 209.273 124.75 DL 209.273 126.75 281.334 126.75 DL
+472.162 124.75 281.334 124.75 DL 281.334 126.75 472.162 126.75 DL(ANTLR 1.00A)
+109.338 140 Q -.77(Te)217.523 140 S(rence P).77 E 13.75(arr Hank)-.165 F(Dietz)
+2.75 E 82.83(ALX T)109.338 156 R(erence P)-.77 E 13.75(arr Hank)-.165 F(Dietz)
+2.75 E(ANTLR 1.00B)109.338 172 Q -.77(Te)217.523 172 S(rence P).77 E 13.75
+(arr Hank)-.165 F(Dietz, W)2.75 E(ill Cohen)-.44 E(DLG 1.00B)109.338 188 Q -.44
+(Wi)217.523 188 S(ll Cohen).44 E -.77(Te)289.584 188 S(rence P).77 E(arr)-.165
+E 2.75(,H)-.44 G(ank Dietz)358.147 188 Q(NF)109.338 204 Q 2.75(AR)-.814 G
+30.778(elabelling W)140.611 204 R(ill Cohen)-.44 E/F1 11/Times-Italic@0 SF(LL)
+109.976 220 Q F0(\().583 E F1(k).396 E F0 2.75(\)a).737 G 40.447(nalysis T)
+143.768 220 R(erence P)-.77 E 13.75(arr Hank)-.165 F(Dietz)2.75 E(ANTLR 1.00)
+109.338 236 Q -.77(Te)217.523 236 S(rence P).77 E 13.75(arr Hank)-.165 F
+(Dietz, W)2.75 E(ill Cohen)-.44 E(DLG 1.00)109.338 252 Q -.44(Wi)217.523 252 S
+(ll Cohen).44 E -.77(Te)289.584 252 S(rence P).77 E(arr)-.165 E 2.75(,H)-.44 G
+(ank Dietz)358.147 252 Q(ANTLR 1.06)109.338 268 Q -.77(Te)217.523 268 S
+(rence P).77 E 13.75(arr W)-.165 F(ill Cohen, Russell Quong, Hank Dietz)-.44 E
+(DLG 1.06)109.338 284 Q -.44(Wi)217.523 284 S(ll Cohen).44 E -.77(Te)289.584
+284 S(rence P).77 E(arr)-.165 E 2.75(,H)-.44 G(ank Dietz)358.147 284 Q
+(ANTLR 1.10)109.338 300 Q -.77(Te)217.523 300 S(rence P).77 E 13.75(arr W)-.165
+F(ill Cohen, Russell Quong)-.44 E(ANTLR 1.20)109.338 316 Q -.77(Te)217.523 316
+S(rence P).77 E 13.75(arr W)-.165 F(ill Cohen, Russell Quong)-.44 E(ANTLR 1.21)
+109.338 332 Q -.77(Te)217.523 332 S(rence P).77 E 13.75(arr Russell)-.165 F
+(Quong)2.75 E(DLG 1.10)109.338 348 Q -.44(Wi)217.523 348 S(ll Cohen).44 E -.77
+(Te)289.584 348 S(rence P).77 E(arr)-.165 E(DLG 1.20)109.338 364 Q -.44(Wi)
+217.523 364 S(ll Cohen).44 E -.77(Te)289.584 364 S(rence P).77 E(arr)-.165 E
+(DLG 1.21)109.338 380 Q -.77(Te)217.523 380 S(rence P).77 E(arr)-.165 E
+(Semantic predicates)109.338 396 Q -.77(Te)217.523 396 S(rence P).77 E 13.75
+(arr Russell)-.165 F(Quonq)2.75 E(Syntactic predicates)109.338 412 Q -.77(Te)
+217.523 412 S(rence P).77 E 13.75(arr Russell)-.165 F(Quonq)2.75 E
+(SORCERER 1.00A)109.338 428 Q -.77(Te)217.523 428 S(rence P).77 E(arr)-.165 E
+(SORCERER 1.00B)109.338 444 Q -.77(Te)217.523 444 S(rence P).77 E 13.75
+(arr Aaron)-.165 F(Sa)2.75 E(wde)-.165 E(y)-.165 E(SORCERER 1.00B9)109.338 460
+Q -.77(Te)217.523 460 S(rence P).77 E 13.75(arr Aaron)-.165 F(Sa)2.75 E(wde)
+-.165 E 1.43 -.715(y, G)-.165 H(ary Funck).715 E 472.162 467.75 103.838 467.75
+DL 472.162 103.75 472.162 467.75 DL 103.838 103.75 103.838 467.75 DL EP
+%%Trailer
+end
+%%EOF
diff --git a/Tools/CodeTools/Source/Pccts/history.txt b/Tools/CodeTools/Source/Pccts/history.txt
new file mode 100644 (file)
index 0000000..89ad840
--- /dev/null
@@ -0,0 +1,186 @@
+\r
+\r
+\r
+                    The History of PCCTS\r
+\r
+         The Purdue Compiler-Construction Tool Set\r
+\r
+\r
+                        Terence Parr\r
+                 Parr Research Corporation\r
+                   Minneapolis, Minnesota\r
+                            and\r
+                  University of Minnesota\r
+      Army High Performance Computing Research Center\r
+\r
+                      [Updated 8-7-94]\r
+\r
+\r
+     The PCCTS project began as a parser-generator project for a  gra-\r
+duate  course  at Purdue University in the Fall of 1988 taught by Hank\r
+Dietz- translator-writing systems.  Under the  guidance  of  Professor\r
+Dietz, the parser generator, ANTLR (originally called YUCC), continued\r
+after the termination of the course and eventually became the  subject\r
+of  Terence  Parr's Master's thesis.  Originally, lexical analysis was\r
+performed via ALX which was soon replaced by Will Cohen's DLG  in  the\r
+Fall  of  1989 (DFA-based lexical-analyzer generator, also an offshoot\r
+of the graduate translation course).\r
+\r
+     The alpha version of ANTLR was  totally  rewritten  resulting  in\r
+1.00B.    Version   1.00B  was  released  via  an  internet  newsgroup\r
+(comp.compilers) posting in February of 1990 and  quickly  gathered  a\r
+large  following.  1.00B generated only LL(1) parsers, but allowed the\r
+merged description of lexical and syntactic analysis.  It had rudimen-\r
+tary  attribute  handling  similar  to that of YACC and did not incor-\r
+porate rule parameters or return values; downward inheritance was very\r
+awkward.   1.00B-generated  parsers  terminated  upon the first syntax\r
+error.  Lexical classes (modes) were not allowed and DLG did not  have\r
+an interactive mode.\r
+\r
+     Upon starting his Ph.D. at Purdue in the Fall  of  1990,  Terence\r
+Parr  began  the  second  total rewrite of ANTLR.  The method by which\r
+grammars may be  practically  analyzed  to  generate  LL(k)  lookahead\r
+information  was  discovered in August of 1990 just before his return.\r
+Version 1.00 incorporated this algorithm and included the AST  mechan-\r
+ism,  lexical  classes,  error  classes, and automatic error recovery;\r
+code quality and portability were higher.  In February  of  1992  1.00\r
+was  released  via  an  article in SIGPLAN Notices.  Peter Dahl, Ph.D.\r
+candidate, and Professor Matt O'Keefe (both at the University of  Min-\r
+nesota)  tested  this  version  extensively.  Dana Hoggatt (Micro Data\r
+Base Systems, Inc.) came up with the idea of error  grouping  (strings\r
+attached to non-terminals) and tested 1.00 heavily.\r
+\r
+     Version 1.06 was released in  December  1992  and  represented  a\r
+large  feature enhancement over 1.00.  For example, rudimentary seman-\r
+tic predicates were  introduced,  error  messages  were  significantly\r
+improved  for k>1 lookahead and ANTLR parsers could indicate that loo-\r
+kahead fetches were  to  occur  only  when  necessary  for  the  parse\r
+\r
+\r
+\r
+                                                                Page 1\r
+\f\r
+                                                                 PCCTS\r
+\r
+\r
+(normally,  the  lookahead "pipe" was constantly full).  Russell Quong\r
+joined the project in the Spring of 1992 to aid in the semantic predi-\r
+cate  design.   Beginning  and  advanced  tutorials  were  created and\r
+released as well.  A makefile generator  was  included  that  sets  up\r
+dependencies  and  such  correctly  for  ANTLR and DLG.  Very few 1.00\r
+incompatibilities were introduced (1.00 was quite different from 1.00B\r
+in some areas).\r
+\r
+     1.10 was released on August 31, 1993 and incorporated bug  fixes,\r
+a  few  feature enhancements and a major new capability - an arbitrary\r
+lookahead operator (syntactic predicate), (alpha)?beta.  This  feature\r
+was  co-designed with Professor Russell Quong also at Purdue.  To sup-\r
+port infinite lookahead, a preprocessor flag, ZZINF_LOOK, was  created\r
+that  forced the ANTLR() macro to tokenize all input prior to parsing.\r
+Hence, at any moment, an action or predicate can see the entire  input\r
+sentence.   The predicate mechanism of 1.06 was extended to allow mul-\r
+tiple predicates to be hoisted; the syntactic context of  a  predicate\r
+was also moved along with the predicate.\r
+\r
+     In February of 1994, SORCERER (a  simple  tree-parser  generator)\r
+was  released.  This tool allows the user to parse child-sibling trees\r
+by specifying a grammar rather than building a recursive-descent  tree\r
+walker  by  hand.   Work  towards a library of tree transformations is\r
+underway.  Aaron Sawdey at The University of Minnesota became a second\r
+author of SORCERER after the initial release.\r
+\r
+     On April 1, 1994, PCCTS 1.20 was released.  This  was  the  first\r
+version  to  actively  support C++ output.  It also included important\r
+fixes regarding semantic predicates and (..)+ subrules.  This  version\r
+also introduced token classes, the "not" operator, and token ranges.\r
+\r
+     On June 19, 1994, SORCERER 1.00B9 was released.   Gary  Funck  of\r
+Intrepid  Technology  joined the SORCERER team and provided very valu-\r
+able suggestions regarding the "transform" mode of SORCERER.\r
+\r
+     On August 8, 1994, PCCTS 1.21 was released.  It mainly cleaned up\r
+the C++ output and included a number of bug fixes.\r
+\r
+     From the 1.21 release forward, the maintenance and support of all\r
+PCCTS  tools  will be primarily provided by Parr Research Corporation,\r
+Minneapolis MN---an organization founded on the principles  of  excel-\r
+lence in research and integrity in business; we are devoted to provid-\r
+ing really cool software tools.  Please see file PCCTS.FUTURE for more\r
+information.  All PCCTS tools currently in the public domain will con-\r
+tinue to be in the public domain.\r
+\r
+     Looking towards the future, a graphical user-interface is in  the\r
+design  phase.   This  would  allow  users  to view the syntax diagram\r
+representation of their grammars and would highlight  nondeterministic\r
+productions.   Parsing can be traced graphically as well.  This system\r
+will be built using a multiplatform window library.  We  also  antici-\r
+pate  the  introduction  of  a  sophisticated error handling mechanism\r
+called "parser exception handling" in a near future release.\r
+\r
+\r
+\r
+\r
+                                                                Page 2\r
+\f\r
+                                                                 PCCTS\r
+\r
+\r
+     Currently, PCCTS is used at over 1000 known academic, government,\r
+and  commercial  sites in 37 countries.  Of course, the true number of\r
+users is unknown due to the large number of ftp sites.\r
+                               Credits\r
+\r
+_____________________________________________________________________________\r
+_____________________________________________________________________________\r
+|ANTLR 1.00A            Terence Parr   Hank Dietz                           |\r
+|ALX                    Terence Parr   Hank Dietz                           |\r
+|ANTLR 1.00B            Terence Parr   Hank Dietz, Will Cohen               |\r
+|DLG 1.00B              Will Cohen     Terence Parr, Hank Dietz             |\r
+|NFA Relabelling        Will Cohen                                          |\r
+|LL(k) analysis         Terence Parr   Hank Dietz                           |\r
+|ANTLR 1.00             Terence Parr   Hank Dietz, Will Cohen               |\r
+|DLG 1.00               Will Cohen     Terence Parr, Hank Dietz             |\r
+|ANTLR 1.06             Terence Parr   Will Cohen, Russell Quong, Hank Dietz|\r
+|DLG 1.06               Will Cohen     Terence Parr, Hank Dietz             |\r
+|ANTLR 1.10             Terence Parr   Will Cohen, Russell Quong            |\r
+|ANTLR 1.20             Terence Parr   Will Cohen, Russell Quong            |\r
+|ANTLR 1.21             Terence Parr   Russell Quong                        |\r
+|DLG 1.10               Will Cohen     Terence Parr                         |\r
+|DLG 1.20               Will Cohen     Terence Parr                         |\r
+|DLG 1.21               Terence Parr                                        |\r
+|Semantic predicates    Terence Parr   Russell Quonq                        |\r
+|Syntactic predicates   Terence Parr   Russell Quonq                        |\r
+|SORCERER 1.00A         Terence Parr                                        |\r
+|SORCERER 1.00B         Terence Parr   Aaron Sawdey                         |\r
+|SORCERER 1.00B9        Terence Parr   Aaron Sawdey, Gary Funck             |\r
+|___________________________________________________________________________|\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+                                                                Page 3\r
+\f\r
diff --git a/Tools/CodeTools/Source/Pccts/makefile b/Tools/CodeTools/Source/Pccts/makefile
new file mode 100644 (file)
index 0000000..f9b2dd2
--- /dev/null
@@ -0,0 +1,66 @@
+#\r
+# Main makefile for PCCTS 1.33MR33     /* MRXXX */\r
+#\r
+# Terence Parr\r
+# Parr Research Corporation\r
+#\r
+# verbosity versus silence...\r
+PSss=\r
+#\r
+# this can be set to /user/local/bin etc...\r
+BINDIR=bin\r
+# This part added by Thomas Herter, M"unchen, Germany. See also manpages\r
+# target.\r
+MANDIR=$(HOME)/man\r
+MANEXT=1\r
+MANFILES=dlg/dlg.1 antlr/antlr.1\r
+\r
+#CC=cc\r
+#CC=gcc\r
+#COPT=-O2\r
+\r
+pccts:\r
+       @echo " "\r
+       @echo "             Welcome to PCCTS 1.33MR33 installation"\r
+       @echo " "\r
+       @echo "             (Version 1.33 Maintenance Release #33)" # mrxxx\r
+       @echo " "\r
+       @echo "                  Released 19 April 2002"\r
+       @echo " "\r
+       @echo "                        Featuring"\r
+       @echo "         ANTLR     -- ANother Tool for Language Recognition"\r
+       @echo "         DLG       -- DFA-based Lexical Analyzer Generator"\r
+       @echo "         SORCERER  -- Source-to-source translator (tree walker)" \r
+       @echo " "\r
+       @echo "                  http://www.antlr.org"  \r
+       @echo " "\r
+       @echo "             Trouble reports to tmoog@polhode.com"\r
+       @echo "             Additional PCCTS 1.33 information at"\r
+       @echo "                  http://www.polhode.com"\r
+       @echo\r
+       @echo\r
+       @echo "To substitute gcc for CC to invoke compiler: make CC=gcc"\r
+       @echo "If there are problems with cr and lf try: unzip -a ..."\r
+       @echo\r
+#\r
+       @if [ ! -d $(BINDIR) ] ; then mkdir $(BINDIR) ; fi\r
+       @echo Making executables...\r
+       (cd ./antlr; $(MAKE) CC="$(CC)" COPT="$(COPT)")\r
+       @echo antlr executable now in $(BINDIR)\r
+       (cd ./dlg; $(MAKE) CC="$(CC)" COPT="$(COPT)")\r
+       @echo dlg executable now in $(BINDIR)\r
+       @echo\r
+       @echo "       PCCTS 1.33MR33 installation complete"  # MRXXX\r
+\r
+clean:\r
+       (cd ./antlr; $(MAKE) -s clean)\r
+       (cd ./dlg; $(MAKE) -s clean)\r
+\r
+\r
+manpages:\r
+       # mkdir -p $(MANDIR)/man$(MANEXT)\r
+       if [ ! -d $(MANDIR) ] ; then \\r
+         mkdir $(MANDIR) ; fi\r
+       if [ ! -d $(MANDIR)/man$(MANEXT) ] ; then \\r
+         mkdir $(MANDIR)/man$(MANEXT); fi\r
+       cp -p $(MANFILES) $(MANDIR)/man$(MANEXT)\r
diff --git a/Tools/CodeTools/Source/Pccts/support/genmk/genmk.c b/Tools/CodeTools/Source/Pccts/support/genmk/genmk.c
new file mode 100644 (file)
index 0000000..4952a30
--- /dev/null
@@ -0,0 +1,1063 @@
+/*\r
+ * genmk -- a program to make makefiles for PCCTS\r
+ *\r
+ * ANTLR 1.33MR23\r
+ * Terence John Parr 1989 - 2000\r
+ * Purdue University\r
+ * U of MN\r
+ */\r
+\r
+#include <stdio.h>\r
+#include <string.h>\r
+#include "pcctscfg.h" /* be sensitive to what ANTLR/DLG call the files */\r
+\r
+#ifdef VAXC\r
+#define DIE            return 0;\r
+#define DONE   return 1;\r
+#else\r
+#define DIE            return 1;\r
+#define DONE   return 0;\r
+#endif\r
+\r
+#ifndef require\r
+#define require(expr, err) {if ( !(expr) ) fatal(err);}\r
+#endif\r
+\r
+#define MAX_FILES      50\r
+#define MAX_CFILES     1600\r
+#define MAX_SFILES     50\r
+#define MAX_SORS       50\r
+#define MAX_CLASSES    50\r
+\r
+char *RENAME_OBJ_FLAG="-o",\r
+     *RENAME_EXE_FLAG="-o";\r
+\r
+char *dlg = "parser.dlg";\r
+char *err = "err.c";\r
+char *hdr = "stdpccts.h";\r
+char *tok = "tokens.h";\r
+char *mode = "mode.h";\r
+char *scan = "scan";\r
+\r
+char ATOKENBUFFER_O[100];\r
+char APARSER_O[100];\r
+char ASTBASE_O[100];\r
+char PCCTSAST_O[100];\r
+char LIST_O[100];\r
+char DLEXERBASE_O[100];\r
+\r
+/* Option flags */\r
+static char *project="t", *files[MAX_FILES], *classes[MAX_CLASSES];\r
+static char *cfiles[MAX_CFILES];\r
+static char *sfiles[MAX_SORS][MAX_SFILES],*sclasses[MAX_SORS];\r
+static int  num_sfiles[MAX_SORS]; /*sorcerer files in group */\r
+static int  num_sors = 0; /*sorcerer groups */\r
+static int  num_files = 0; /* grammar files */\r
+static int  num_cfiles = 0; /* additional C/C++ files */\r
+static int  num_classes = 0; /* ANTLR classes */\r
+static int  user_lexer = 0;\r
+static char *user_token_types = NULL;\r
+static int  gen_CPP = 0;\r
+static char *outdir=".";\r
+static char *dlg_class = "DLGLexer";\r
+static int  gen_trees = 0;\r
+static int  gen_hoist = 0;\r
+static int  nondef_comp = 0; /* 1=compiler is non default */\r
+static char *compilerCCC="CC";\r
+static char *compilerCC="cc";\r
+static char *pccts_path="/usr/local/pccts";\r
+\r
+#ifdef __STDC__\r
+void help(void);\r
+void mk(char *project, char **files, int n, int argc, char **argv);\r
+void pfiles(char **files, int n, char *suffix);\r
+void fatal(char *msg);\r
+void warn(char *msg);\r
+#else\r
+void help();\r
+void mk();\r
+void pfiles();\r
+void fatal();\r
+void warn();\r
+#endif\r
+\r
+typedef struct _Opt {\r
+                       char *option;\r
+                       int arg;\r
+#ifdef __cplusplus\r
+                       void (*process)(...);\r
+#else\r
+                       void (*process)();\r
+#endif\r
+                       char *descr;\r
+               } Opt;\r
+\r
+#ifdef __STDC__\r
+static void ProcessArgs(int, char **, Opt *);\r
+#else\r
+static void ProcessArgs();\r
+#endif\r
+\r
+static void\r
+#ifdef __STDC__\r
+pProj(char *s, char *t )\r
+#else\r
+pProj( s, t )\r
+char *s;\r
+char *t;\r
+#endif\r
+{\r
+       project = t;\r
+}\r
+\r
+static void\r
+#ifdef __STDC__\r
+pUL( char *s )\r
+#else\r
+pUL( s )\r
+char *s;\r
+#endif\r
+{\r
+       user_lexer = 1;\r
+}\r
+\r
+static void\r
+#ifdef __STDC__\r
+pCPP( char *s )\r
+#else\r
+pCPP( s )\r
+char *s;\r
+#endif\r
+{\r
+       gen_CPP = 1;\r
+}\r
+\r
+static void\r
+#ifdef __STDC__\r
+pUT( char *s, char *t )\r
+#else\r
+pUT( s, t )\r
+char *s;\r
+char *t;\r
+#endif\r
+{\r
+       user_token_types = t;\r
+}\r
+\r
+static void\r
+#ifdef __STDC__\r
+pTrees( char *s )\r
+#else\r
+pTrees( s )\r
+char *s;\r
+#endif\r
+{\r
+       gen_trees = 1;\r
+}\r
+\r
+static void\r
+#ifdef __STDC__\r
+pHoist( char *s )\r
+#else\r
+pHoist( s )\r
+char *s;\r
+#endif\r
+{\r
+       gen_hoist = 1;\r
+}\r
+\r
+static void\r
+#ifdef __STDC__\r
+pSor( char *s )\r
+#else\r
+pSor( s )\r
+char *s;\r
+#endif\r
+{\r
+       require(num_sors<MAX_SORS, "exceeded max # of sorcerer groups");\r
+       num_sors++;\r
+       pTrees(NULL); /* silently turn on tree generation */\r
+}\r
+\r
+static void\r
+#ifdef __STDC__\r
+pSFiles( char *s, char *t )\r
+#else\r
+pSFiles( s, t )\r
+char *s;\r
+char *t;\r
+#endif\r
+{\r
+       if (num_sors==0)\r
+       {\r
+               pSor(NULL);\r
+               warn("sorcerer input file before any '-sor' option");\r
+       }\r
+               \r
+       require(num_sfiles[num_sors-1]<MAX_SFILES,\r
+                "exceeded max # of sorcerer input files");\r
+       sfiles[num_sors-1][num_sfiles[num_sors-1]++] = t;\r
+}\r
+\r
+static void\r
+#ifdef __STDC__\r
+pCFiles( char *s, char *t )\r
+#else\r
+pCFiles( s, t )\r
+char *s;\r
+char *t;\r
+#endif\r
+{\r
+       require(num_cfiles<MAX_CFILES, "exceeded max # of C/C++ input files");\r
+       cfiles[num_cfiles++] = t;\r
+}\r
+\r
+int\r
+#ifdef __STDC__\r
+isKnownSuffix( char *s )\r
+#else\r
+isKnownSuffix( s )\r
+       char *s;\r
+#endif\r
+{\r
+       if(s==NULL) return 0;\r
+       if (strcasecmp(s,".c")==0) return 1;\r
+       if (strcasecmp(s,".cc")==0) return 1;\r
+       if (strcasecmp(s,".cpp")==0) return 1;\r
+       if (strcasecmp(s,".cxx")==0) return 1;\r
+       if (strcasecmp(s,CPP_FILE_SUFFIX)==0) return 1;\r
+       if (strcasecmp(s,".sor")==0) return 2;\r
+       return 0;\r
+}\r
+\r
+static void\r
+#ifdef __STDC__\r
+pFile( char *s )\r
+#else\r
+pFile( s )\r
+char *s;\r
+#endif\r
+{\r
+       if ( *s=='-' )\r
+       {\r
+               fprintf(stderr, "invalid option: '%s'; ignored...",s);\r
+               return;\r
+       }\r
+       switch(isKnownSuffix(strrchr(s,'.')))\r
+       {\r
+        case 1: /* c/c++ */\r
+               pCFiles("-cfiles",s);\r
+               return;\r
+        case 2: /* sorcerer */\r
+               pSFiles("",s);\r
+               return;\r
+        default: /* grammar (ANTLR) */\r
+               break;\r
+       }\r
+       require(num_files<MAX_FILES, "exceeded max # of input files");\r
+       files[num_files++] = s;\r
+}\r
+\r
+static void\r
+#ifdef __STDC__\r
+pClass( char *s, char *t )\r
+#else\r
+pClass( s, t )\r
+char *s;\r
+char *t;\r
+#endif\r
+{\r
+       if (num_sors==0)\r
+       {\r
+               require(num_classes<MAX_CLASSES, "exceeded max # of grammar classes");\r
+               classes[num_classes++] = t;\r
+       } else\r
+       {\r
+               sclasses[num_sors-1] = t; /* one class per sorcerer group (last valid) */\r
+       }\r
+}\r
+\r
+static void\r
+#ifdef __STDC__\r
+pDLGClass( char *s, char *t )\r
+#else\r
+pDLGClass( s, t )\r
+char *s;\r
+char *t;\r
+#endif\r
+{\r
+       if ( !gen_CPP ) {\r
+               fprintf(stderr, "-dlg-class makes no sense without C++ mode; ignored...");\r
+       }\r
+       else dlg_class = t;\r
+}\r
+\r
+static void\r
+#ifdef __STDC__\r
+pOdir( char *s, char *t )\r
+#else\r
+pOdir( s, t )\r
+char *s;\r
+char *t;\r
+#endif\r
+{\r
+       outdir = t;\r
+}\r
+\r
+static void\r
+#ifdef __STDC__\r
+pHdr( char *s, char *t )\r
+#else\r
+pHdr( s, t )\r
+char *s;\r
+char *t;\r
+#endif\r
+{\r
+       hdr = t;\r
+}\r
+\r
+static void\r
+#ifdef __STDC__\r
+pCompiler( char *s, char *t )\r
+#else\r
+pCompiler( s, t )\r
+char *s;\r
+char *t;\r
+#endif\r
+{\r
+       compilerCCC = t;\r
+       compilerCC = t;\r
+       nondef_comp = 1;\r
+}\r
+\r
+static void\r
+#ifdef __STDC__\r
+ppccts_path( char *s, char *t )\r
+#else\r
+ppccts_path( s, t )\r
+char *s;\r
+char *t;\r
+#endif\r
+{\r
+       pccts_path = t;\r
+}\r
+\r
+Opt options[] = {\r
+       { "-CC", 0,     pCPP,                   "Generate C++ output"},\r
+       { "-class", 1,  pClass,         "Name of a grammar class defined in grammar (if C++)"},\r
+       { "-dlg-class", 1,pDLGClass,"Name of DLG lexer class (default=DLGLexer) (if C++)"},\r
+       { "-header", 1,pHdr,            "Name of ANTLR standard header info (default=no file)"},\r
+       { "-o", 1,      pOdir,                  "Directory where output files should go (default=\".\")"},\r
+       { "-project", 1,        pProj,  "Name of executable to create (default=t)"},\r
+       { "-token-types", 1, pUT,       "Token types are in this file (don't use tokens.h)"},\r
+       { "-trees", 0, pTrees,          "Generate ASTs"},\r
+       { "-user-lexer", 0,     pUL,    "Do not create a DLG-based scanner"},\r
+       { "-mrhoist",0,pHoist,      "Maintenance release style hoisting"},\r
+       { "-cfiles",1,pCFiles,      "Additional files in C or C++ to compile"},\r
+       { "-sor",0,pSor,           "Start of sorcerer group"},\r
+       { "-pccts_path",1,ppccts_path,\r
+                       "Path for $PCCTS directory (default is /usr/local/pccts)"},\r
+       { "-compiler",1,pCompiler,\r
+                       "Default compiler (default is CC/cc)"},\r
+       { "*", 0,pFile,                 "" },   /* anything else is a file */\r
+       { NULL, 0, NULL, NULL }\r
+};\r
+\r
+#ifdef __STDC__\r
+extern char *DIR(void);\r
+#else\r
+extern char *DIR();\r
+#endif\r
+\r
+#ifdef __STDC__\r
+int main(int argc, char **argv)\r
+#else\r
+int main(argc, argv)\r
+int argc;\r
+char **argv;\r
+#endif\r
+{\r
+       int i;\r
+       \r
+       if ( argc == 1 ) { help(); DIE; }\r
+       for(i=0;i<MAX_SORS;i++) num_sfiles[i]=0;\r
+       \r
+       ProcessArgs(argc-1, &(argv[1]), options);\r
+\r
+       strcpy(ATOKENBUFFER_O, ATOKENBUFFER_C);\r
+       ATOKENBUFFER_O[strlen(ATOKENBUFFER_C)-strlen(CPP_FILE_SUFFIX)] = '\0';\r
+       strcat(ATOKENBUFFER_O, OBJ_FILE_SUFFIX);\r
+       strcpy(APARSER_O, APARSER_C);\r
+       APARSER_O[strlen(APARSER_O)-strlen(CPP_FILE_SUFFIX)] = '\0';\r
+       strcat(APARSER_O, OBJ_FILE_SUFFIX);\r
+\r
+       strcpy(ASTBASE_O, ASTBASE_C);\r
+       ASTBASE_O[strlen(ASTBASE_C)-strlen(CPP_FILE_SUFFIX)] = '\0';\r
+       strcat(ASTBASE_O, OBJ_FILE_SUFFIX);\r
+\r
+       strcpy(PCCTSAST_O, PCCTSAST_C);\r
+       PCCTSAST_O[strlen(PCCTSAST_C)-strlen(CPP_FILE_SUFFIX)] = '\0';\r
+       strcat(PCCTSAST_O, OBJ_FILE_SUFFIX);\r
+\r
+       strcpy(LIST_O, LIST_C);\r
+       LIST_O[strlen(LIST_C)-strlen(CPP_FILE_SUFFIX)] = '\0';\r
+       strcat(LIST_O, OBJ_FILE_SUFFIX);\r
+\r
+       strcpy(DLEXERBASE_O, DLEXERBASE_C);\r
+       DLEXERBASE_O[strlen(DLEXERBASE_C)-strlen(CPP_FILE_SUFFIX)] = '\0';\r
+       strcat(DLEXERBASE_O, OBJ_FILE_SUFFIX);\r
+\r
+       if ( num_files == 0 ) fatal("no grammar files specified; exiting...");\r
+       if ( !gen_CPP && num_classes>0 ) {\r
+               warn("can't define classes w/o C++ mode; turning on C++ mode...\n");\r
+               gen_CPP=1;\r
+       }\r
+       if (!gen_CPP && num_sors) {\r
+               warn("can't define sorcerer group in C mode (yet); turning on C++ mode...\n");\r
+               gen_CPP=1;\r
+       }\r
+       if ( gen_CPP && num_classes==0 ) {\r
+               fatal("must define classes >0 grammar classes in C++ mode\n");\r
+       }\r
+\r
+       mk(project, files, num_files, argc, argv);\r
+       DONE;\r
+}\r
+\r
+#ifdef __STDC__\r
+void help(void)\r
+#else\r
+void help()\r
+#endif\r
+{\r
+       Opt *p = options;\r
+       static char buf[1000+1];\r
+\r
+       fprintf(stderr, "genmk [options] f1.g ... fn.g\n");\r
+       while ( p->option!=NULL && *(p->option) != '*' )\r
+       {\r
+               buf[0]='\0';\r
+               if ( p->arg ) sprintf(buf, "%s ___", p->option);\r
+               else strcpy(buf, p->option);\r
+               fprintf(stderr, "\t%-16s   %s\n", buf, p->descr);\r
+               p++;\r
+       }\r
+}\r
+\r
+#ifdef __STDC__\r
+void mk(char *project, char **files, int n, int argc, char **argv)\r
+#else\r
+void mk(project, files, n, argc, argv)\r
+char *project;\r
+char **files;\r
+int n;\r
+int argc;\r
+char **argv;\r
+#endif\r
+{\r
+       int i,j;\r
+\r
+       printf("#\n");\r
+       printf("# PCCTS makefile for: ");\r
+       pfiles(files, n, NULL);\r
+       printf("\n");\r
+       printf("#\n");\r
+       printf("# Created from:");\r
+       for (i=0; i<argc; i++) printf(" %s", argv[i]);\r
+       printf("\n");\r
+       printf("#\n");\r
+       printf("# PCCTS release 1.33MR23\n");\r
+       printf("# Project: %s\n", project);\r
+       if ( gen_CPP ) printf("# C++ output\n");\r
+       else printf("# C output\n");\r
+       if ( user_lexer ) printf("# User-defined scanner\n");\r
+       else printf("# DLG scanner\n");\r
+       if ( user_token_types!=NULL ) printf("# User-defined token types in '%s'\n", user_token_types);\r
+       else printf("# ANTLR-defined token types\n");\r
+       printf("#\n");\r
+/***********\r
+       printf(".SUFFIXES:\n.SUFFIXES:\t.o .cpp .c .h .g .i .dlg .sor\n"); \r
+ ***********/\r
+       if ( user_token_types!=NULL ) {\r
+               printf("# Make sure #tokdefs directive in ANTLR grammar lists this file:\n");\r
+               printf("TOKENS = %s", user_token_types);\r
+       }\r
+       else printf("TOKENS = %stokens.h", DIR());\r
+       printf("\n");\r
+       printf("#\n");\r
+       printf("# The following filenames must be consistent with ANTLR/DLG flags\n");\r
+       printf("DLG_FILE = %s%s\n", DIR(), dlg);\r
+       printf("ERR = %serr\n", DIR());\r
+       if ( strcmp(hdr,"stdpccts.h")!=0 ) printf("HDR_FILE = %s%s\n", DIR(), hdr);\r
+       else printf("HDR_FILE =\n");\r
+       if ( !gen_CPP ) printf("MOD_FILE = %s%s\n", DIR(), mode);\r
+       if ( !gen_CPP ) printf("SCAN = %s\n", scan);\r
+       else printf("SCAN = %s%s\n", DIR(), dlg_class);\r
+\r
+       printf("PCCTS = %s\n",pccts_path);\r
+       printf("ANTLR_H = $(PCCTS)%sh\n", DirectorySymbol);\r
+       if (num_sors>0) {\r
+               printf("SOR_H = $(PCCTS)%ssorcerer%sh\n", DirectorySymbol, DirectorySymbol);\r
+               printf("SOR_LIB = $(PCCTS)%ssorcerer%slib\n",\r
+                               DirectorySymbol, DirectorySymbol);\r
+       }\r
+       printf("BIN = $(PCCTS)%sbin\n", DirectorySymbol);\r
+       printf("ANTLR = $(BIN)%santlr\n", DirectorySymbol);\r
+       printf("DLG = $(BIN)%sdlg\n", DirectorySymbol);\r
+       if (num_sors>0) printf("SOR = $(BIN)%ssor\n", DirectorySymbol);\r
+       printf("CFLAGS = -I. -I$(ANTLR_H)");\r
+       if (num_sors>0) printf(" -I$(SOR_H)");\r
+       if ( strcmp(outdir, ".")!=0 ) printf(" -I%s", outdir);\r
+       printf(" $(COTHER)");\r
+       printf("\n");\r
+       printf("AFLAGS =");\r
+       if ( strcmp(outdir,".")!=0 ) printf(" -o %s", outdir);\r
+       if ( user_lexer ) printf(" -gx");\r
+       if ( gen_CPP ) printf(" -CC");\r
+       if ( strcmp(hdr,"stdpccts.h")!=0 ) printf(" -gh %s", hdr);\r
+       if ( gen_trees ) printf(" -gt");\r
+       if ( gen_hoist ) {\r
+               printf(" -mrhoist on") ;\r
+       } else {\r
+               printf(" -mrhoist off");\r
+       };\r
+       printf(" $(AOTHER)");\r
+       printf("\n");\r
+       printf("DFLAGS = -C2 -i");\r
+       if ( gen_CPP ) printf(" -CC");\r
+       if ( strcmp(dlg_class,"DLGLexer")!=0 ) printf(" -cl %s", dlg_class);\r
+       if ( strcmp(outdir,".")!=0 ) printf(" -o %s", outdir);\r
+       printf(" $(DOTHER)");\r
+       printf("\n");\r
+       if (num_sors>0)\r
+       {\r
+               printf("SFLAGS = -CPP");\r
+               if ( strcmp(outdir,".")!=0 ) printf(" -out-dir %s", outdir);\r
+               printf(" $(SOTHER)\n");\r
+       }\r
+       printf("GRM = ");\r
+       pfiles(files, n, NULL);\r
+       printf("\n");\r
+       printf("SRC = ");\r
+       if ( gen_CPP ) pfiles(files, n, CPP_FILE_SUFFIX_NO_DOT);\r
+       else pfiles(files, n, "c");\r
+       if ( gen_CPP ) {\r
+               printf(" \\\n\t");\r
+               pclasses(classes, num_classes, CPP_FILE_SUFFIX_NO_DOT);\r
+               printf(" \\\n\t");\r
+               printf("$(ANTLR_H)%s%s", DirectorySymbol, APARSER_C);\r
+               if ( !user_lexer ) printf(" $(ANTLR_H)%s%s", DirectorySymbol, DLEXERBASE_C);\r
+               if ( gen_trees ) {\r
+                       printf(" \\\n\t");\r
+                       printf("$(ANTLR_H)%s%s", DirectorySymbol, ASTBASE_C);\r
+                       printf(" $(ANTLR_H)%s%s", DirectorySymbol, PCCTSAST_C);\r
+/*                     printf(" $(ANTLR_H)%s%s", DirectorySymbol, LIST_C); */\r
+                       printf(" \\\n\t");\r
+               }\r
+               printf(" $(ANTLR_H)%s%s", DirectorySymbol, ATOKENBUFFER_C);\r
+       }\r
+       if ( !user_lexer ) {\r
+               if ( gen_CPP ) printf(" $(SCAN)%s", CPP_FILE_SUFFIX);\r
+               else printf(" %s$(SCAN).c", DIR());\r
+       }\r
+       if ( !gen_CPP ) printf(" $(ERR).c");\r
+       for (i=0;i<num_sors;i++)\r
+       {\r
+               printf(" \\\n\t");\r
+               pclasses(&sclasses[i],1,CPP_FILE_SUFFIX_NO_DOT);\r
+               printf(" ");\r
+               pfiles(&sfiles[i][0],num_sfiles[i],CPP_FILE_SUFFIX_NO_DOT);\r
+       }\r
+       if(num_sors>0)\r
+               printf(" \\\n\t$(SOR_LIB)%sSTreeParser.cpp", DirectorySymbol);\r
+       if (num_cfiles>0)\r
+       {\r
+               printf(" \\\n\t");\r
+               pfiles(cfiles,num_cfiles,NULL);\r
+       }\r
+       printf("\n\n");\r
+       printf("OBJ = ");\r
+       pfiles(files, n, "o");\r
+       if ( gen_CPP ) {\r
+               printf(" \\\n\t");\r
+               pclasses(classes, num_classes, "o");\r
+               printf(" \\\n\t");\r
+               printf("%s%s", DIR(), APARSER_O);\r
+               if ( !user_lexer ) {\r
+                       printf(" %s%s", DIR(), DLEXERBASE_O);\r
+               }\r
+               if ( gen_trees ) {\r
+                       printf(" \\\n\t");\r
+                       printf("%s%s", DIR(), ASTBASE_O);\r
+                       printf(" %s%s", DIR(), PCCTSAST_O);\r
+/*                     printf(" %s%s", DIR(), LIST_O); */\r
+                       printf(" \\\n\t");\r
+               }\r
+               printf(" %s%s", DIR(), ATOKENBUFFER_O);\r
+       }\r
+       if ( !user_lexer ) {\r
+               if ( gen_CPP ) printf(" $(SCAN)%s", OBJ_FILE_SUFFIX);\r
+               else printf(" %s$(SCAN)%s", DIR(), OBJ_FILE_SUFFIX);\r
+       }\r
+       if ( !gen_CPP ) printf(" $(ERR)%s", OBJ_FILE_SUFFIX);\r
+       for (i=0;i<num_sors;i++)\r
+       {\r
+               printf(" \\\n\t");\r
+               pclasses(&sclasses[i],1,"o");\r
+               printf(" ");\r
+               pfiles(&sfiles[i][0],num_sfiles[i],"o");\r
+       }\r
+       if(num_sors>0) printf(" \\\n\tSTreeParser.o");\r
+       if (num_cfiles>0)\r
+       {\r
+               printf(" \\\n\t");\r
+               pfiles(cfiles,num_cfiles,"o");\r
+       }\r
+       printf("\n\n");\r
+\r
+       printf("ANTLR_SPAWN = ");\r
+       if ( gen_CPP ) pfiles(files, n, CPP_FILE_SUFFIX_NO_DOT);\r
+       else pfiles(files, n, "c");\r
+       if ( gen_CPP ) {\r
+               printf(" ");\r
+               pclasses(classes, num_classes, CPP_FILE_SUFFIX_NO_DOT);\r
+               printf(" \\\n\t\t");\r
+               pclasses(classes, num_classes, "h");\r
+               if ( strcmp(hdr,"stdpccts.h")!=0 ) {\r
+                       printf(" \\\n\t\t");\r
+                       printf("$(HDR_FILE) stdpccts.h");\r
+               }\r
+       }\r
+       if ( user_lexer ) {\r
+               if ( !user_token_types ) printf(" $(TOKENS)");\r
+       }\r
+       else {\r
+               printf(" $(DLG_FILE)");\r
+               if ( !user_token_types ) printf(" $(TOKENS)");\r
+       }\r
+       if ( !gen_CPP ) printf(" $(ERR).c");\r
+       printf("\n");\r
+\r
+       if ( !user_lexer ) {\r
+               if ( gen_CPP ) printf("DLG_SPAWN = $(SCAN)%s", CPP_FILE_SUFFIX);\r
+               else printf("DLG_SPAWN = %s$(SCAN).c", DIR());\r
+               if ( gen_CPP ) printf(" $(SCAN).h");\r
+               if ( !gen_CPP ) printf(" $(MOD_FILE)");\r
+               printf("\n");\r
+       }\r
+\r
+       if ( gen_CPP ) {\r
+               if ( !nondef_comp )\r
+                       printf("ifdef CXX\nCCC = $(CXX)\nendif\n\nifndef CCC\n");\r
+               printf("CCC = %s\n",compilerCCC);\r
+               if ( !nondef_comp ) printf("endif\n\n");\r
+       }\r
+       else\r
+       {\r
+               if ( !nondef_comp ) printf("ifndef CC\n");\r
+               printf("CC = %s\n",compilerCC);\r
+               if ( !nondef_comp ) printf("endif\n\n");\r
+       }\r
+\r
+       /* set up dependencies */\r
+       printf("\n%s : $(SRC) $(OBJ)\n", project);\r
+       printf("\t%s %s %s $(CFLAGS) $(OBJ)\n",\r
+               gen_CPP?"$(CCC)":"$(CC)",\r
+               RENAME_EXE_FLAG,\r
+               project);\r
+       printf("\n");\r
+\r
+       /* implicit rules */\r
+\r
+/*     if(gen_CPP)\r
+               printf("%%.o : %%.cpp\n\t$(CCC) -c $(CFLAGS) $<\n\n");\r
+\r
+       printf("%%.o : %%.c\n\t%s -c $(CFLAGS) $<\n\n",\r
+                       gen_CPP?"$(CCC)":"$(CC)");\r
+*/\r
+       /* how to compile parser files */\r
+\r
+       for (i=0; i<num_files; i++)\r
+       {\r
+               pfiles(&files[i], 1, "o");\r
+               if ( user_lexer ) {\r
+                       printf(" : $(TOKENS)");\r
+               }\r
+               else {\r
+                       if ( gen_CPP ) printf(" : $(TOKENS) $(SCAN).h");\r
+                       else printf(" : $(MOD_FILE) $(TOKENS)");\r
+               }\r
+               printf(" ");\r
+               if ( gen_CPP ) pfiles(&files[i], 1, CPP_FILE_SUFFIX_NO_DOT);\r
+               else pfiles(&files[i], 1, "c");\r
+               if ( gen_CPP && strcmp(hdr,"stdpccts.h")!=0 ) printf(" $(HDR_FILE)");\r
+               printf("\n");\r
+               printf("\t%s -c $(CFLAGS) %s ",\r
+                       gen_CPP?"$(CCC)":"$(CC)",RENAME_OBJ_FLAG);\r
+               pfiles(&files[i], 1, "o");\r
+               printf(" ");\r
+               if ( gen_CPP ) pfiles(&files[i], 1, CPP_FILE_SUFFIX_NO_DOT);\r
+               else pfiles(&files[i], 1, "c");\r
+               printf("\n\n");\r
+       }\r
+\r
+       for (i=0; i<num_cfiles; i++)\r
+       {\r
+               pfiles(&cfiles[i], 1, "o");\r
+               printf(" : ");\r
+               pfiles(&cfiles[i], 1, NULL);\r
+               if ( gen_CPP && strcmp(hdr,"stdpccts.h")!=0 ) printf(" $(HDR_FILE)");\r
+/***   printf(" "); ***/\r
+/***   pfiles(&cfiles[i], 1, "h"); ***/\r
+               printf("\n");\r
+               printf("\t%s -c $(CFLAGS) %s ",\r
+                       gen_CPP?"$(CCC)":"$(CC)",RENAME_OBJ_FLAG);\r
+               pfiles(&cfiles[i], 1, "o");\r
+               printf(" ");\r
+               pfiles(&cfiles[i], 1, NULL);\r
+               printf("\n\n");\r
+\r
+/*\r
+ *             pfiles(&cfiles[i], 1, "h");\r
+ *             printf(" :\ntouch ");\r
+ *             pfiles(&cfiles[i], 1, "h");\r
+ *             printf("\n\n");\r
+ */\r
+       }\r
+\r
+       /* how to compile err.c */\r
+       if ( !gen_CPP ) {\r
+               printf("$(ERR)%s : $(ERR).c", OBJ_FILE_SUFFIX);\r
+               if ( !user_lexer ) printf(" $(TOKENS)");\r
+               printf("\n");\r
+               printf("\t%s -c $(CFLAGS) %s $(ERR)%s $(ERR).c",\r
+                       gen_CPP?"$(CCC)":"$(CC)",\r
+                       RENAME_OBJ_FLAG,\r
+                       OBJ_FILE_SUFFIX);\r
+               printf("\n\n");\r
+       }\r
+\r
+       /* how to compile Class.c */\r
+       for (i=0; i<num_classes; i++)\r
+       {\r
+               pclasses(&classes[i], 1, "o");\r
+               if ( user_lexer ) {\r
+                       printf(" : $(TOKENS)");\r
+               }\r
+               else {\r
+                       printf(" : $(TOKENS) $(SCAN).h");\r
+               }\r
+               printf(" ");\r
+               pclasses(&classes[i], 1, CPP_FILE_SUFFIX_NO_DOT);\r
+               printf(" ");\r
+               pclasses(&classes[i], 1, "h");\r
+               if ( gen_CPP && strcmp(hdr,"stdpccts.h")!=0 ) printf(" $(HDR_FILE)");\r
+               printf("\n");\r
+               printf("\t%s -c $(CFLAGS) %s ",\r
+                       gen_CPP?"$(CCC)":"$(CC)",\r
+                       RENAME_OBJ_FLAG);\r
+               pclasses(&classes[i], 1, "o");\r
+               printf(" ");\r
+               pclasses(&classes[i], 1, CPP_FILE_SUFFIX_NO_DOT);\r
+               printf("\n\n");\r
+       }\r
+\r
+       /* how to compile scan.c */\r
+       if ( !user_lexer ) {\r
+               if ( gen_CPP ) printf("$(SCAN)%s : $(SCAN)%s", OBJ_FILE_SUFFIX, CPP_FILE_SUFFIX);\r
+               else printf("%s$(SCAN)%s : %s$(SCAN).c", DIR(), OBJ_FILE_SUFFIX, DIR());\r
+               if ( !user_lexer ) printf(" $(TOKENS)");\r
+               printf("\n");\r
+               if ( gen_CPP ) printf("\t$(CCC) -c $(CFLAGS) %s $(SCAN)%s $(SCAN)%s",\r
+                                                       RENAME_OBJ_FLAG,\r
+                                                       OBJ_FILE_SUFFIX,\r
+                                                       CPP_FILE_SUFFIX);\r
+               else printf("\t$(CC) -c $(CFLAGS) %s %s$(SCAN)%s %s$(SCAN).c",\r
+                                       RENAME_OBJ_FLAG,\r
+                                       DIR(),\r
+                                       OBJ_FILE_SUFFIX,\r
+                                       DIR());\r
+               printf("\n\n");\r
+       }\r
+/* how to compile sorcerer classes */\r
+       for (i=0;i<num_sors;i++)\r
+       {\r
+               pclasses(&sclasses[i], 1, "o");\r
+               printf(" : ");\r
+               pclasses(&sclasses[i], 1, CPP_FILE_SUFFIX_NO_DOT);\r
+               printf(" ");\r
+               pclasses(&sclasses[i], 1, "h");\r
+               if ( gen_CPP && strcmp(hdr,"stdpccts.h")!=0 ) printf(" $(HDR_FILE)");\r
+               printf("\n");\r
+               printf("\t%s -c $(CFLAGS) %s ",\r
+                               gen_CPP?"$(CCC)":"$(CC)",\r
+                               RENAME_OBJ_FLAG);\r
+               pclasses(&sclasses[i], 1, "o");\r
+               printf(" ");\r
+               pclasses(&sclasses[i], 1, CPP_FILE_SUFFIX_NO_DOT);\r
+               printf("\n\n");\r
+/* how to compile i-th sorcerer's files*/\r
+               for (j=0; j<num_sfiles[i]; j++)\r
+               {\r
+                       pfiles(&sfiles[i][j], 1, "o");\r
+                       printf(" : ");\r
+                       if ( gen_CPP ) pfiles(&sfiles[i][j], 1, CPP_FILE_SUFFIX_NO_DOT);\r
+                       else pfiles(&sfiles[i][j], 1, "c");\r
+                       if ( gen_CPP && strcmp(hdr,"stdpccts.h")!=0 ) printf(" $(HDR_FILE)");\r
+                       printf("\n");\r
+                       printf("\t%s -c $(CFLAGS) %s ",\r
+                                       gen_CPP?"$(CCC)":"$(CC)",RENAME_OBJ_FLAG);\r
+                       pfiles(&sfiles[i][j], 1, "o");\r
+                       printf(" ");\r
+                       if ( gen_CPP ) pfiles(&sfiles[i][j], 1, CPP_FILE_SUFFIX_NO_DOT);\r
+                       else pfiles(&sfiles[i][j], 1, "c");\r
+                       printf("\n\n");\r
+               }\r
+               if ( gen_CPP ) pfiles(&sfiles[i][0], num_sfiles[i], CPP_FILE_SUFFIX_NO_DOT);\r
+               else pfiles(&sfiles[i][0], num_sfiles[i], "c");\r
+               if ( gen_CPP )\r
+               {\r
+                       printf(" ");\r
+                       pclasses(&sclasses[i], 1, CPP_FILE_SUFFIX_NO_DOT);\r
+                       printf(" ");\r
+                       pclasses(&sclasses[i], 1, "h");\r
+                       if ( strcmp(hdr,"stdpccts.h")!=0 ) \r
+                       {\r
+                               printf(" ");\r
+                               printf("$(HDR_FILE) stdpccts.h");\r
+                       }\r
+               }\r
+               printf(" : ");\r
+               pfiles(&sfiles[i][0],num_sfiles[i],NULL);\r
+               printf("\n\t$(SOR) $(SFLAGS) ");\r
+               pfiles(&sfiles[i][0],num_sfiles[i],NULL);\r
+               printf("\n\n");\r
+       }\r
+       if(num_sors>0)\r
+       {\r
+               printf("STreeParser%s : $(SOR_LIB)%sSTreeParser.cpp\n",\r
+                               OBJ_FILE_SUFFIX,DirectorySymbol);\r
+               printf("\t%s -c $(CFLAGS) %s ",\r
+                               gen_CPP?"$(CCC)":"$(CC)",RENAME_OBJ_FLAG);\r
+               printf("STreeParser%s ",OBJ_FILE_SUFFIX);\r
+               printf("$(SOR_LIB)%sSTreeParser.cpp\n\n",DirectorySymbol);\r
+       }\r
+       \r
+       printf("$(ANTLR_SPAWN) : $(GRM)\n");\r
+       printf("\t$(ANTLR) $(AFLAGS) $(GRM)\n");\r
+\r
+       if ( !user_lexer )\r
+       {\r
+               printf("\n");\r
+               printf("$(DLG_SPAWN) : $(DLG_FILE)\n");\r
+               if ( gen_CPP ) printf("\t$(DLG) $(DFLAGS) $(DLG_FILE)\n");\r
+               else printf("\t$(DLG) $(DFLAGS) $(DLG_FILE) $(SCAN).c\n");\r
+       }\r
+\r
+       /* do the makes for ANTLR/DLG support */\r
+       if ( gen_CPP ) {\r
+               printf("\n");\r
+               printf("%s%s : $(ANTLR_H)%s%s\n", DIR(), APARSER_O, DirectorySymbol, APARSER_C);\r
+               printf("\t%s -c $(CFLAGS) %s ",\r
+                               gen_CPP?"$(CCC)":"$(CC)",\r
+                               RENAME_OBJ_FLAG);\r
+               printf("%s%s $(ANTLR_H)%s%s\n", DIR(), APARSER_O, DirectorySymbol, APARSER_C);\r
+               printf("\n");\r
+               printf("%s%s : $(ANTLR_H)%s%s\n", DIR(), ATOKENBUFFER_O, DirectorySymbol, ATOKENBUFFER_C);\r
+               printf("\t%s -c $(CFLAGS) %s ",\r
+                               gen_CPP?"$(CCC)":"$(CC)",\r
+                               RENAME_OBJ_FLAG);\r
+               printf("%s%s $(ANTLR_H)%s%s\n", DIR(), ATOKENBUFFER_O, DirectorySymbol, ATOKENBUFFER_C);\r
+               if ( !user_lexer ) {\r
+                       printf("\n");\r
+                       printf("%s%s : $(ANTLR_H)%s%s\n", DIR(), DLEXERBASE_O, DirectorySymbol, DLEXERBASE_C);\r
+                       printf("\t%s -c $(CFLAGS) %s ",\r
+                                       gen_CPP?"$(CCC)":"$(CC)",\r
+                                       RENAME_OBJ_FLAG);\r
+                       printf("%s%s $(ANTLR_H)%s%s\n", DIR(), DLEXERBASE_O, DirectorySymbol, DLEXERBASE_C);\r
+               }\r
+               if ( gen_trees ) {\r
+                       printf("\n");\r
+                       printf("%s%s : $(ANTLR_H)%s%s\n", DIR(), ASTBASE_O, DirectorySymbol, ASTBASE_C);\r
+                       printf("\t%s -c $(CFLAGS) %s ",\r
+                                       gen_CPP?"$(CCC)":"$(CC)",\r
+                                       RENAME_OBJ_FLAG);\r
+                       printf("%s%s $(ANTLR_H)%s%s\n", DIR(), ASTBASE_O, DirectorySymbol, ASTBASE_C);\r
+                       printf("\n");\r
+                       printf("%s%s : $(ANTLR_H)%s%s\n", DIR(), PCCTSAST_O, DirectorySymbol, PCCTSAST_C);\r
+                       printf("\t%s -c $(CFLAGS) %s ",\r
+                                       gen_CPP?"$(CCC)":"$(CC)",\r
+                                       RENAME_OBJ_FLAG);\r
+                       printf("%s%s $(ANTLR_H)%s%s\n", DIR(), PCCTSAST_O, DirectorySymbol, PCCTSAST_C);\r
+                       printf("\n");\r
+/*\r
+                       printf("%s%s : $(ANTLR_H)%s%s\n", DIR(), LIST_O, DirectorySymbol, LIST_C);\r
+                       printf("\t%s -c $(CFLAGS) %s ",\r
+                                       gen_CPP?"$(CCC)":"$(CC)",RENAME_OBJ_FLAG);\r
+                       printf("%s%s $(ANTLR_H)%s%s\n", DIR(), LIST_O, DirectorySymbol, LIST_C);\r
+*/\r
+               }\r
+       }\r
+\r
+       /* clean and scrub targets */\r
+\r
+       printf("\nclean:\n");\r
+       printf("\trm -f *%s core %s", OBJ_FILE_SUFFIX, project);\r
+       if ( strcmp(outdir, ".")!=0 ) printf(" %s*%s", DIR(), OBJ_FILE_SUFFIX);\r
+       printf("\n");\r
+\r
+       printf("\nscrub: clean\n");\r
+/*     printf("\trm -f *%s core %s", OBJ_FILE_SUFFIX, project); */\r
+/*     if ( strcmp(outdir, ".")!=0 ) printf(" %s*%s", DIR(), OBJ_FILE_SUFFIX); */\r
+       printf("\trm -f $(ANTLR_SPAWN)");\r
+       if ( !user_lexer ) printf(" $(DLG_SPAWN)");\r
+       for (i=0;i<num_sors;i++)\r
+       {\r
+               printf(" ");\r
+               if ( gen_CPP ) pfiles(&sfiles[i][0], num_sfiles[i], CPP_FILE_SUFFIX_NO_DOT);\r
+               else pfiles(&sfiles[i][0], num_sfiles[i], "c");\r
+               if ( gen_CPP )\r
+               {\r
+                       printf(" ");\r
+                       pclasses(&sclasses[i], 1, CPP_FILE_SUFFIX_NO_DOT);\r
+                       printf(" ");\r
+                       pclasses(&sclasses[i], 1, "h");\r
+               }\r
+       }\r
+       printf("\n\n");\r
+}\r
+\r
+#ifdef __STDC__\r
+void pfiles(char **files, int n, char *suffix)\r
+#else\r
+void pfiles(files, n, suffix)\r
+char **files;\r
+int n;\r
+char *suffix;\r
+#endif\r
+{\r
+       int first=1;\r
+\r
+       while ( n>0 )\r
+       {\r
+               char *p = &(*files)[strlen(*files)-1];\r
+               if ( !first ) putchar(' ');\r
+               first=0;\r
+               while ( p > *files && *p != '.' ) --p;\r
+               if ( p == *files )\r
+               {\r
+                       fprintf(stderr,\r
+                                       "genmk: filenames must be file.suffix format: %s\n",\r
+                                       *files);\r
+                       exit(-1);\r
+               }\r
+               if ( suffix == NULL ) printf("%s", *files);\r
+               else\r
+               {\r
+                       *p = '\0';\r
+                       printf("%s", DIR());\r
+                       if ( strcmp(suffix, "o")==0 ) printf("%s%s", *files, OBJ_FILE_SUFFIX);\r
+                       else printf("%s.%s", *files, suffix);\r
+                       *p = '.';\r
+               }\r
+               files++;\r
+               --n;\r
+       }\r
+}\r
+\r
+#ifdef __STDC__\r
+pclasses(char **classes, int n, char *suffix)\r
+#else\r
+pclasses(classes, n, suffix)\r
+char **classes;\r
+int n;\r
+char *suffix;\r
+#endif\r
+{\r
+       int first=1;\r
+\r
+       while ( n>0 )\r
+       {\r
+               if ( !first ) putchar(' ');\r
+               first=0;\r
+               if ( suffix == NULL ) printf("%s", *classes);\r
+               else {\r
+                       printf("%s", DIR());\r
+                       if ( strcmp(suffix, "o")==0 ) printf("%s%s", *classes, OBJ_FILE_SUFFIX);\r
+                       else printf("%s.%s", *classes, suffix);\r
+               }\r
+               classes++;\r
+               --n;\r
+       }\r
+}\r
+\r
+static void\r
+#ifdef __STDC__\r
+ProcessArgs( int argc, char **argv, Opt *options )\r
+#else\r
+ProcessArgs( argc, argv, options )\r
+int argc;\r
+char **argv;\r
+Opt *options;\r
+#endif\r
+{\r
+       Opt *p;\r
+       require(argv!=NULL, "ProcessArgs: command line NULL");\r
+\r
+       while ( argc-- > 0 )\r
+       {\r
+               p = options;\r
+               while ( p->option != NULL )\r
+               {\r
+                       if ( strcmp(p->option, "*") == 0 ||\r
+                                strcmp(p->option, *argv) == 0 )\r
+                       {\r
+                               if ( p->arg )\r
+                               {\r
+                                       (*p->process)( *argv, *(argv+1) );\r
+                                       argv++;\r
+                                       argc--;\r
+                               }\r
+                               else\r
+                                       (*p->process)( *argv );\r
+                               break;\r
+                       }\r
+                       p++;\r
+               }\r
+               argv++;\r
+       }\r
+}\r
+\r
+#ifdef __STDC__\r
+void fatal( char *err_)\r
+#else\r
+void fatal( err_)\r
+char *err_;\r
+#endif\r
+{\r
+       fprintf(stderr, "genmk: %s\n", err_);\r
+       exit(1);\r
+}\r
+\r
+#ifdef __STDC__\r
+void warn( char *err_)\r
+#else\r
+void warn( err_)\r
+char *err_;\r
+#endif\r
+{\r
+       fprintf(stderr, "genmk: %s\n", err_);\r
+}\r
+\r
+#ifdef __STDC__\r
+char *DIR(void)\r
+#else\r
+char *DIR()\r
+#endif\r
+{\r
+       static char buf[200+1];\r
+       \r
+       if ( strcmp(outdir,TopDirectory)==0 ) return "";\r
+       sprintf(buf, "%s%s", outdir, DirectorySymbol);\r
+       return buf;\r
+}\r
diff --git a/Tools/CodeTools/Source/Pccts/support/genmk/genmk_old.c b/Tools/CodeTools/Source/Pccts/support/genmk/genmk_old.c
new file mode 100644 (file)
index 0000000..2cf9fad
--- /dev/null
@@ -0,0 +1,762 @@
+/*\r
+ * genmk -- a program to make makefiles for PCCTS\r
+ *\r
+ * ANTLR 1.33MR10\r
+ * Terence John Parr 1989 - 1998\r
+ * Purdue University\r
+ * U of MN\r
+ */\r
+\r
+#include <stdio.h>\r
+#include "pcctscfg.h" /* be sensitive to what ANTLR/DLG call the files */\r
+\r
+#ifdef VAXC\r
+#define DIE            return 0;\r
+#define DONE   return 1;\r
+#else\r
+#define DIE            return 1;\r
+#define DONE   return 0;\r
+#endif\r
+\r
+#ifndef require\r
+#define require(expr, err) {if ( !(expr) ) fatal(err);}\r
+#endif\r
+\r
+#define MAX_FILES      50\r
+#define MAX_CLASSES    50\r
+\r
+char *RENAME_OBJ_FLAG="-o",\r
+     *RENAME_EXE_FLAG="-o";\r
+\r
+char *dlg = "parser.dlg";\r
+char *err = "err.c";\r
+char *hdr = "stdpccts.h";\r
+char *tok = "tokens.h";\r
+char *mode = "mode.h";\r
+char *scan = "scan";\r
+\r
+char ATOKENBUFFER_O[100];\r
+char APARSER_O[100];\r
+char ASTBASE_O[100];\r
+char PCCTSAST_O[100];\r
+char LIST_O[100];\r
+char DLEXERBASE_O[100];\r
+\r
+/* Option flags */\r
+static char *project="t", *files[MAX_FILES], *classes[MAX_CLASSES];\r
+static int     num_files = 0;\r
+static int     num_classes = 0;\r
+static int     user_lexer = 0;\r
+static char    *user_token_types = NULL;\r
+static int     gen_CPP = 0;\r
+static char *outdir=".";\r
+static char *dlg_class = "DLGLexer";\r
+static int     gen_trees = 0;\r
+static int  gen_hoist = 0;\r
+static char cfiles[1600]="";\r
+static char *compilerCCC="CC";\r
+static char *compilerCC="cc";\r
+static char *pccts_path="/usr/local/pccts";\r
+\r
+void help();\r
+void mk();\r
+void pfiles();\r
+void pclasses();\r
+void fatal();\r
+void warn();\r
+\r
+typedef struct _Opt {\r
+                       char *option;\r
+                       int  arg;\r
+#ifdef __cplusplus\r
+                       void (*process)(...);\r
+#else\r
+                       void (*process)();\r
+#endif\r
+                       char *descr;\r
+               } Opt;\r
+\r
+#ifdef __STDC__\r
+static void ProcessArgs(int, char **, Opt *);\r
+#else\r
+static void ProcessArgs();\r
+#endif\r
+\r
+static void\r
+pProj( s, t )\r
+char *s;\r
+char *t;\r
+{\r
+       project = t;\r
+}\r
+\r
+static void\r
+pUL( s )\r
+char *s;\r
+{\r
+       user_lexer = 1;\r
+}\r
+\r
+static void\r
+pCPP( s )\r
+char *s;\r
+{\r
+       gen_CPP = 1;\r
+}\r
+\r
+static void\r
+pUT( s, t )\r
+char *s;\r
+char *t;\r
+{\r
+       user_token_types = t;\r
+}\r
+\r
+static void\r
+pTrees( s )\r
+char *s;\r
+{\r
+       gen_trees = 1;\r
+}\r
+\r
+static void\r
+pHoist( s )\r
+char *s;\r
+{\r
+       gen_hoist = 1;\r
+}\r
+\r
+static void\r
+#ifdef __STDC__\r
+pFile( char *s )\r
+#else\r
+pFile( s )\r
+char *s;\r
+#endif\r
+{\r
+       if ( *s=='-' )\r
+       {\r
+               fprintf(stderr, "invalid option: '%s'; ignored...",s);\r
+               return;\r
+       }\r
+\r
+       require(num_files<MAX_FILES, "exceeded max # of input files");\r
+       files[num_files++] = s;\r
+}\r
+\r
+static void\r
+#ifdef __STDC__\r
+pClass( char *s, char *t )\r
+#else\r
+pClass( s, t )\r
+char *s;\r
+char *t;\r
+#endif\r
+{\r
+       require(num_classes<MAX_CLASSES, "exceeded max # of grammar classes");\r
+       classes[num_classes++] = t;\r
+}\r
+\r
+static void\r
+#ifdef __STDC__\r
+pDLGClass( char *s, char *t )\r
+#else\r
+pDLGClass( s, t )\r
+char *s;\r
+char *t;\r
+#endif\r
+{\r
+       if ( !gen_CPP ) {\r
+               fprintf(stderr, "-dlg-class makes no sense without C++ mode; ignored...");\r
+       }\r
+       else dlg_class = t;\r
+}\r
+\r
+static void\r
+#ifdef __STDC__\r
+pOdir( char *s, char *t )\r
+#else\r
+pOdir( s, t )\r
+char *s;\r
+char *t;\r
+#endif\r
+{\r
+       outdir = t;\r
+}\r
+\r
+static void\r
+#ifdef __STDC__\r
+pHdr( char *s, char *t )\r
+#else\r
+pHdr( s, t )\r
+char *s;\r
+char *t;\r
+#endif\r
+{\r
+       hdr = t;\r
+}\r
+\r
+static void\r
+#ifdef __STDC__\r
+pCFiles( char *s, char *t )\r
+#else\r
+pCFiles( s, t )\r
+char *s;\r
+char *t;\r
+#endif\r
+{\r
+       strcat(strcat(cfiles," "), t);\r
+}\r
+\r
+static void\r
+#ifdef __STDC__\r
+pCompiler( char *s, char *t )\r
+#else\r
+pCompiler( s, t )\r
+char *s;\r
+char *t;\r
+#endif\r
+{\r
+        compilerCCC = t;\r
+       compilerCC = t;\r
+}\r
+\r
+static void\r
+#ifdef __STDC__\r
+ppccts_path( char *s, char *t )\r
+#else\r
+ppccts_path( s, t )\r
+char *s;\r
+char *t;\r
+#endif\r
+{\r
+        pccts_path = t;\r
+}\r
+\r
+Opt options[] = {\r
+    { "-CC", 0,        pCPP,                   "Generate C++ output"},\r
+    { "-class", 1,     pClass,         "Name of a grammar class defined in grammar (if C++)"},\r
+    { "-dlg-class", 1,pDLGClass,"Name of DLG lexer class (default=DLGLexer) (if C++)"},\r
+    { "-header", 1,pHdr,               "Name of ANTLR standard header info (default=no file)"},\r
+    { "-o", 1, pOdir,                  "Directory where output files should go (default=\".\")"},\r
+    { "-project", 1,   pProj,  "Name of executable to create (default=t)"},\r
+    { "-token-types", 1, pUT,  "Token types are in this file (don't use tokens.h)"},\r
+    { "-trees", 0, pTrees,             "Generate ASTs"},\r
+    { "-user-lexer", 0,        pUL,    "Do not create a DLG-based scanner"},\r
+    { "-mrhoist",0,pHoist,      "Maintenance release style hoisting"},\r
+    { "-cfiles",1,pCFiles,      "Additional files in C or C++ to compile"},\r
+    { "-pccts_path",1,ppccts_path,\r
+              "Path for $PCCTS directory (default is /usr/local/pccts)"},\r
+    { "-compiler",1,pCompiler,\r
+              "Default compiler (default is CC/cc)"},\r
+    { "*", 0,pFile,            "" },   /* anything else is a file */\r
+       { NULL, 0, NULL, NULL }\r
+};\r
+\r
+extern char *DIR();\r
+\r
+int main(argc, argv)\r
+int argc;\r
+char **argv;\r
+{\r
+       if ( argc == 1 ) { help(); DIE; }\r
+       ProcessArgs(argc-1, &(argv[1]), options);\r
+\r
+       strcpy(ATOKENBUFFER_O, ATOKENBUFFER_C);\r
+       ATOKENBUFFER_O[strlen(ATOKENBUFFER_C)-strlen(CPP_FILE_SUFFIX)] = '\0';\r
+       strcat(ATOKENBUFFER_O, OBJ_FILE_SUFFIX);\r
+       strcpy(APARSER_O, APARSER_C);\r
+       APARSER_O[strlen(APARSER_O)-strlen(CPP_FILE_SUFFIX)] = '\0';\r
+       strcat(APARSER_O, OBJ_FILE_SUFFIX);\r
+\r
+       strcpy(ASTBASE_O, ASTBASE_C);\r
+       ASTBASE_O[strlen(ASTBASE_C)-strlen(CPP_FILE_SUFFIX)] = '\0';\r
+       strcat(ASTBASE_O, OBJ_FILE_SUFFIX);\r
+\r
+       strcpy(PCCTSAST_O, PCCTSAST_C);\r
+       PCCTSAST_O[strlen(PCCTSAST_C)-strlen(CPP_FILE_SUFFIX)] = '\0';\r
+       strcat(PCCTSAST_O, OBJ_FILE_SUFFIX);\r
+\r
+       strcpy(LIST_O, LIST_C);\r
+       LIST_O[strlen(LIST_C)-strlen(CPP_FILE_SUFFIX)] = '\0';\r
+       strcat(LIST_O, OBJ_FILE_SUFFIX);\r
+\r
+       strcpy(DLEXERBASE_O, DLEXERBASE_C);\r
+       DLEXERBASE_O[strlen(DLEXERBASE_C)-strlen(CPP_FILE_SUFFIX)] = '\0';\r
+       strcat(DLEXERBASE_O, OBJ_FILE_SUFFIX);\r
+\r
+       if ( num_files == 0 ) fatal("no grammar files specified; exiting...");\r
+       if ( !gen_CPP && num_classes>0 ) {\r
+               warn("can't define classes w/o C++ mode; turning on C++ mode...\n");\r
+               gen_CPP=1;\r
+       }\r
+       if ( gen_CPP && num_classes==0 ) {\r
+               fatal("must define classes >0 grammar classes in C++ mode\n");\r
+       }\r
+\r
+       mk(project, files, num_files, argc, argv);\r
+       DONE;\r
+}\r
+\r
+void help()\r
+{\r
+       Opt *p = options;\r
+       static char buf[1000+1];\r
+\r
+       fprintf(stderr, "genmk [options] f1.g ... fn.g\n");\r
+       while ( p->option!=NULL && *(p->option) != '*' )\r
+       {\r
+               buf[0]='\0';\r
+               if ( p->arg ) sprintf(buf, "%s ___", p->option);\r
+               else strcpy(buf, p->option);\r
+               fprintf(stderr, "\t%-16s   %s\n", buf, p->descr);\r
+               p++;\r
+       }\r
+}\r
+\r
+void mk(project, files, n, argc, argv)\r
+char *project;\r
+char **files;\r
+int n;\r
+int argc;\r
+char **argv;\r
+{\r
+       int i;\r
+\r
+       printf("#\n");\r
+       printf("# PCCTS makefile for: ");\r
+       pfiles(files, n, NULL);\r
+       printf("\n");\r
+       printf("#\n");\r
+       printf("# Created from:");\r
+       for (i=0; i<argc; i++) printf(" %s", argv[i]);\r
+       printf("\n");\r
+       printf("#\n");\r
+       printf("# PCCTS release 1.33MR21\n");\r
+       printf("# Project: %s\n", project);\r
+       if ( gen_CPP ) printf("# C++ output\n");\r
+       else printf("# C output\n");\r
+       if ( user_lexer ) printf("# User-defined scanner\n");\r
+       else printf("# DLG scanner\n");\r
+       if ( user_token_types!=NULL ) printf("# User-defined token types in '%s'\n", user_token_types);\r
+       else printf("# ANTLR-defined token types\n");\r
+       printf("#\n");\r
+       printf(".SUFFIXES:\n.SUFFIXES:      .o .cpp .c .h .g .i .dlg\n"); \r
+       if ( user_token_types!=NULL ) {\r
+               printf("# Make sure #tokdefs directive in ANTLR grammar lists this file:\n");\r
+               printf("TOKENS = %s", user_token_types);\r
+       }\r
+       else printf("TOKENS = %stokens.h", DIR());\r
+       printf("\n");\r
+       printf("#\n");\r
+       printf("# The following filenames must be consistent with ANTLR/DLG flags\n");\r
+       printf("DLG_FILE = %s%s\n", DIR(), dlg);\r
+       printf("ERR = %serr\n", DIR());\r
+       if ( strcmp(hdr,"stdpccts.h")!=0 ) printf("HDR_FILE = %s%s\n", DIR(), hdr);\r
+       else printf("HDR_FILE =\n");\r
+       if ( !gen_CPP ) printf("MOD_FILE = %s%s\n", DIR(), mode);\r
+       if ( !gen_CPP ) printf("SCAN = %s\n", scan);\r
+       else printf("SCAN = %s%s\n", DIR(), dlg_class);\r
+\r
+       printf("PCCTS = %s\n",pccts_path);\r
+       printf("ANTLR_H = $(PCCTS)%sh\n", DirectorySymbol);\r
+       printf("BIN = $(PCCTS)%sbin\n", DirectorySymbol);\r
+       printf("ANTLR = $(BIN)%santlr\n", DirectorySymbol);\r
+       printf("DLG = $(BIN)%sdlg\n", DirectorySymbol);\r
+       printf("CFLAGS = -I. -I$(ANTLR_H)");\r
+       if ( strcmp(outdir, ".")!=0 ) printf(" -I%s", outdir);\r
+    printf(" $(COTHER)");\r
+       printf("\n");\r
+       printf("AFLAGS =");\r
+       if ( strcmp(outdir,".")!=0 ) printf(" -o %s", outdir);\r
+       if ( user_lexer ) printf(" -gx");\r
+       if ( gen_CPP ) printf(" -CC");\r
+       if ( strcmp(hdr,"stdpccts.h")!=0 ) printf(" -gh %s", hdr);\r
+       if ( gen_trees ) printf(" -gt");\r
+    if ( gen_hoist ) {\r
+      printf(" -mrhoist on") ;\r
+    } else {\r
+      printf(" -mrhoist off");\r
+    };\r
+    printf(" $(AOTHER)");\r
+       printf("\n");\r
+       printf("DFLAGS = -C2 -i");\r
+       if ( gen_CPP ) printf(" -CC");\r
+       if ( strcmp(dlg_class,"DLGLexer")!=0 ) printf(" -cl %s", dlg_class);\r
+       if ( strcmp(outdir,".")!=0 ) printf(" -o %s", outdir);\r
+    printf(" $(DOTHER)");\r
+       printf("\n");\r
+       printf("GRM = ");\r
+       pfiles(files, n, NULL);\r
+       printf("\n");\r
+       printf("MYFILES = %s\n",cfiles);\r
+       printf("SRC = ");\r
+       if ( gen_CPP ) pfiles(files, n, CPP_FILE_SUFFIX_NO_DOT);\r
+       else pfiles(files, n, "c");\r
+       if ( gen_CPP ) {\r
+               printf(" \\\n     ");\r
+               printf(" ");\r
+               pclasses(classes, num_classes, CPP_FILE_SUFFIX_NO_DOT);\r
+               printf(" \\\n      ");\r
+               printf("$(ANTLR_H)%s%s", DirectorySymbol, APARSER_C);\r
+               if ( !user_lexer ) printf(" $(ANTLR_H)%s%s", DirectorySymbol, DLEXERBASE_C);\r
+               if ( gen_trees ) {\r
+                       printf(" \\\n      ");\r
+                       printf("$(ANTLR_H)%s%s", DirectorySymbol, ASTBASE_C);\r
+                       printf(" $(ANTLR_H)%s%s", DirectorySymbol, PCCTSAST_C);\r
+/*                     printf(" $(ANTLR_H)%s%s", DirectorySymbol, LIST_C); */\r
+                       printf(" \\\n      ");\r
+               }\r
+               printf(" $(ANTLR_H)%s%s", DirectorySymbol, ATOKENBUFFER_C);\r
+       }\r
+       if ( !user_lexer ) {\r
+               if ( gen_CPP ) printf(" $(SCAN)%s", CPP_FILE_SUFFIX);\r
+               else printf(" %s$(SCAN).c", DIR());\r
+       }\r
+       if ( !gen_CPP ) printf(" $(ERR).c");\r
+       printf("\\\n    $(MYFILES)\n");\r
+       printf("OBJ = ");\r
+       pfiles(files, n, "o");\r
+       if ( gen_CPP ) {\r
+               printf(" \\\n     ");\r
+               printf(" ");\r
+               pclasses(classes, num_classes, "o");\r
+               printf(" \\\n      ");\r
+               printf(" %s%s", DIR(), APARSER_O);\r
+               if ( !user_lexer ) {\r
+                       printf(" %s%s", DIR(), DLEXERBASE_O);\r
+               }\r
+               if ( gen_trees ) {\r
+                       printf(" \\\n      ");\r
+                       printf("%s%s", DIR(), ASTBASE_O);\r
+                       printf(" %s%s", DIR(), PCCTSAST_O);\r
+/*                     printf(" %s%s", DIR(), LIST_O); */\r
+                       printf(" \\\n      ");\r
+               }\r
+               printf(" %s%s", DIR(), ATOKENBUFFER_O);\r
+       }\r
+       if ( !user_lexer ) {\r
+               if ( gen_CPP ) printf(" $(SCAN)%s", OBJ_FILE_SUFFIX);\r
+               else printf(" %s$(SCAN)%s", DIR(), OBJ_FILE_SUFFIX);\r
+       }\r
+       if ( !gen_CPP ) printf(" $(ERR)%s", OBJ_FILE_SUFFIX);\r
+       printf("\\\n    $(MYFILES:.cpp=.o)\n");\r
+\r
+       printf("ANTLR_SPAWN = ");\r
+       if ( gen_CPP ) pfiles(files, n, CPP_FILE_SUFFIX_NO_DOT);\r
+       else pfiles(files, n, "c");\r
+       if ( gen_CPP ) {\r
+               printf(" ");\r
+               pclasses(classes, num_classes, CPP_FILE_SUFFIX_NO_DOT);\r
+               printf(" \\\n              ");\r
+               pclasses(classes, num_classes, "h");\r
+               if ( strcmp(hdr,"stdpccts.h")!=0 ) {\r
+                       printf(" \\\n              ");\r
+                       printf("$(HDR_FILE) stdpccts.h");\r
+               }\r
+       }\r
+       if ( user_lexer ) {\r
+               if ( !user_token_types ) printf(" $(TOKENS)");\r
+       }\r
+       else {\r
+               printf(" $(DLG_FILE)");\r
+               if ( !user_token_types ) printf(" $(TOKENS)");\r
+       }\r
+       if ( !gen_CPP ) printf(" $(ERR).c");\r
+       printf("\n");\r
+\r
+       if ( !user_lexer ) {\r
+               if ( gen_CPP ) printf("DLG_SPAWN = $(SCAN)%s", CPP_FILE_SUFFIX);\r
+               else printf("DLG_SPAWN = %s$(SCAN).c", DIR());\r
+               if ( gen_CPP ) printf(" $(SCAN).h");\r
+               if ( !gen_CPP ) printf(" $(MOD_FILE)");\r
+               printf("\n");\r
+       }\r
+\r
+       if ( gen_CPP ) {\r
+               printf("CCC = %s\n",compilerCCC);\r
+       }\r
+       else printf("CC = %s\n",compilerCC);\r
+\r
+       /* set up dependencies */\r
+       printf("\n%s : $(OBJ) $(SRC)\n", project);\r
+       printf("        %s %s %s $(CFLAGS) $(OBJ)\n",\r
+                  gen_CPP?"$(CCC)":"$(CC)",\r
+                  RENAME_EXE_FLAG,\r
+                  project);\r
+       printf("\n");\r
+\r
+       /* implicit rules */\r
+\r
+       if(gen_CPP)\r
+               printf("%%.o : %%.cpp\n\t$(CCC) -c $(CFLAGS) $<\n\n");\r
+\r
+       printf("%%.o : %%.c\n\t%s -c $(CFLAGS) $<\n\n",\r
+                       gen_CPP?"$(CCC)":"$(CC)");\r
+\r
+       /* how to compile parser files */\r
+\r
+       for (i=0; i<num_files; i++)\r
+       {\r
+               pfiles(&files[i], 1, "o");\r
+               if ( user_lexer ) {\r
+                       printf(" : $(TOKENS)");\r
+               }\r
+               else {\r
+                       if ( gen_CPP ) printf(" : $(TOKENS) $(SCAN).h");\r
+                       else printf(" : $(MOD_FILE) $(TOKENS)");\r
+               }\r
+               printf(" ");\r
+               if ( gen_CPP ) pfiles(&files[i], 1, CPP_FILE_SUFFIX_NO_DOT);\r
+               else pfiles(&files[i], 1, "c");\r
+               if ( gen_CPP && strcmp(hdr,"stdpccts.h")!=0 ) printf(" $(HDR_FILE)");\r
+               printf("\n");\r
+               printf("        %s -c $(CFLAGS) %s ",\r
+                      gen_CPP?"$(CCC)":"$(CC)",RENAME_OBJ_FLAG);\r
+               pfiles(&files[i], 1, "o");\r
+               printf(" ");\r
+               if ( gen_CPP ) pfiles(&files[i], 1, CPP_FILE_SUFFIX_NO_DOT);\r
+               else pfiles(&files[i], 1, "c");\r
+               printf("\n\n");\r
+       }\r
+\r
+       /* how to compile err.c */\r
+       if ( !gen_CPP ) {\r
+               printf("$(ERR)%s : $(ERR).c", OBJ_FILE_SUFFIX);\r
+               if ( !user_lexer ) printf(" $(TOKENS)");\r
+               printf("\n");\r
+               printf("        %s -c $(CFLAGS) %s $(ERR)%s $(ERR).c",\r
+                          gen_CPP?"$(CCC)":"$(CC)",\r
+                          RENAME_OBJ_FLAG,\r
+                          OBJ_FILE_SUFFIX);\r
+               printf("\n\n");\r
+       }\r
+\r
+       /* how to compile Class.c */\r
+       for (i=0; i<num_classes; i++)\r
+       {\r
+               pclasses(&classes[i], 1, "o");\r
+               if ( user_lexer ) {\r
+                       printf(" : $(TOKENS)");\r
+               }\r
+               else {\r
+                       printf(" : $(TOKENS) $(SCAN).h");\r
+               }\r
+               printf(" ");\r
+               pclasses(&classes[i], 1, CPP_FILE_SUFFIX_NO_DOT);\r
+               printf(" ");\r
+               pclasses(&classes[i], 1, "h");\r
+               if ( gen_CPP && strcmp(hdr,"stdpccts.h")!=0 ) printf(" $(HDR_FILE)");\r
+               printf("\n");\r
+               printf("        %s -c $(CFLAGS) %s ",\r
+                          gen_CPP?"$(CCC)":"$(CC)",\r
+                          RENAME_OBJ_FLAG);\r
+               pclasses(&classes[i], 1, "o");\r
+               printf(" ");\r
+               pclasses(&classes[i], 1, CPP_FILE_SUFFIX_NO_DOT);\r
+               printf("\n\n");\r
+       }\r
+\r
+       /* how to compile scan.c */\r
+       if ( !user_lexer ) {\r
+               if ( gen_CPP ) printf("$(SCAN)%s : $(SCAN)%s", OBJ_FILE_SUFFIX, CPP_FILE_SUFFIX);\r
+               else printf("%s$(SCAN)%s : %s$(SCAN).c", DIR(), OBJ_FILE_SUFFIX, DIR());\r
+               if ( !user_lexer ) printf(" $(TOKENS)");\r
+               printf("\n");\r
+               if ( gen_CPP ) printf(" $(CCC) -c $(CFLAGS) %s $(SCAN)%s $(SCAN)%s",\r
+                                                         RENAME_OBJ_FLAG,\r
+                                                         OBJ_FILE_SUFFIX,\r
+                                                         CPP_FILE_SUFFIX);\r
+               else printf("   $(CC) -c $(CFLAGS) %s %s$(SCAN)%s %s$(SCAN).c",\r
+                                       RENAME_OBJ_FLAG,\r
+                                       DIR(),\r
+                                       OBJ_FILE_SUFFIX,\r
+                                       DIR());\r
+               printf("\n\n");\r
+       }\r
+\r
+       printf("$(ANTLR_SPAWN) : $(GRM)\n");\r
+       printf("        $(ANTLR) $(AFLAGS) $(GRM)\n");\r
+\r
+       if ( !user_lexer )\r
+       {\r
+               printf("\n");\r
+               printf("$(DLG_SPAWN) : $(DLG_FILE)\n");\r
+               if ( gen_CPP ) printf(" $(DLG) $(DFLAGS) $(DLG_FILE)\n");\r
+               else printf("   $(DLG) $(DFLAGS) $(DLG_FILE) $(SCAN).c\n");\r
+       }\r
+\r
+       /* do the makes for ANTLR/DLG support */\r
+       if ( gen_CPP ) {\r
+               printf("\n");\r
+               printf("%s%s : $(ANTLR_H)%s%s\n", DIR(), APARSER_O, DirectorySymbol, APARSER_C);\r
+               printf("        %s -c $(CFLAGS) %s ",\r
+                          gen_CPP?"$(CCC)":"$(CC)",\r
+                          RENAME_OBJ_FLAG);\r
+               printf("%s%s $(ANTLR_H)%s%s\n", DIR(), APARSER_O, DirectorySymbol, APARSER_C);\r
+               printf("\n");\r
+               printf("%s%s : $(ANTLR_H)%s%s\n", DIR(), ATOKENBUFFER_O, DirectorySymbol, ATOKENBUFFER_C);\r
+               printf("        %s -c $(CFLAGS) %s ",\r
+                          gen_CPP?"$(CCC)":"$(CC)",\r
+                          RENAME_OBJ_FLAG);\r
+               printf("%s%s $(ANTLR_H)%s%s\n", DIR(), ATOKENBUFFER_O, DirectorySymbol, ATOKENBUFFER_C);\r
+               if ( !user_lexer ) {\r
+                       printf("\n");\r
+                       printf("%s%s : $(ANTLR_H)%s%s\n", DIR(), DLEXERBASE_O, DirectorySymbol, DLEXERBASE_C);\r
+                       printf("        %s -c $(CFLAGS) %s ",\r
+                                  gen_CPP?"$(CCC)":"$(CC)",\r
+                                  RENAME_OBJ_FLAG);\r
+                       printf("%s%s $(ANTLR_H)%s%s\n", DIR(), DLEXERBASE_O, DirectorySymbol, DLEXERBASE_C);\r
+               }\r
+               if ( gen_trees ) {\r
+                       printf("\n");\r
+                       printf("%s%s : $(ANTLR_H)%s%s\n", DIR(), ASTBASE_O, DirectorySymbol, ASTBASE_C);\r
+                       printf("        %s -c $(CFLAGS) %s ",\r
+                                  gen_CPP?"$(CCC)":"$(CC)",\r
+                                  RENAME_OBJ_FLAG);\r
+                       printf("%s%s $(ANTLR_H)%s%s\n", DIR(), ASTBASE_O, DirectorySymbol, ASTBASE_C);\r
+                       printf("\n");\r
+                       printf("%s%s : $(ANTLR_H)%s%s\n", DIR(), PCCTSAST_O, DirectorySymbol, PCCTSAST_C);\r
+                       printf("        %s -c $(CFLAGS) %s ",\r
+                                  gen_CPP?"$(CCC)":"$(CC)",\r
+                                  RENAME_OBJ_FLAG);\r
+                       printf("%s%s $(ANTLR_H)%s%s\n", DIR(), PCCTSAST_O, DirectorySymbol, PCCTSAST_C);\r
+                       printf("\n");\r
+/*\r
+                       printf("%s%s : $(ANTLR_H)%s%s\n", DIR(), LIST_O, DirectorySymbol, LIST_C);\r
+                       printf("        %s -c $(CFLAGS) %s ",\r
+                              gen_CPP?"$(CCC)":"$(CC)",RENAME_OBJ_FLAG);\r
+                       printf("%s%s $(ANTLR_H)%s%s\n", DIR(), LIST_O, DirectorySymbol, LIST_C);\r
+*/\r
+               }\r
+       }\r
+\r
+       /* clean and scrub targets */\r
+\r
+       printf("\nclean:\n");\r
+       printf("        rm -f *%s core %s", OBJ_FILE_SUFFIX, project);\r
+       if ( strcmp(outdir, ".")!=0 ) printf(" %s*%s", DIR(), OBJ_FILE_SUFFIX);\r
+       printf("\n");\r
+\r
+       printf("\nscrub:\n");\r
+       printf("        rm -f *%s core %s", OBJ_FILE_SUFFIX, project);\r
+       if ( strcmp(outdir, ".")!=0 ) printf(" %s*%s", DIR(), OBJ_FILE_SUFFIX);\r
+       printf(" $(ANTLR_SPAWN)");\r
+       if ( !user_lexer ) printf(" $(DLG_SPAWN)");\r
+       printf("\n");\r
+}\r
+\r
+void pfiles(files, n, suffix)\r
+char **files;\r
+int n;\r
+char *suffix;\r
+{\r
+       int first=1;\r
+\r
+       while ( n>0 )\r
+       {\r
+               char *p = &(*files)[strlen(*files)-1];\r
+               if ( !first ) putchar(' ');\r
+               first=0;\r
+               while ( p > *files && *p != '.' ) --p;\r
+               if ( p == *files )\r
+               {\r
+                       fprintf(stderr,\r
+                                       "genmk: filenames must be file.suffix format: %s\n",\r
+                                       *files);\r
+                       exit(-1);\r
+               }\r
+               if ( suffix == NULL ) printf("%s", *files);\r
+               else\r
+               {\r
+                       *p = '\0';\r
+                       printf("%s", DIR());\r
+                       if ( strcmp(suffix, "o")==0 ) printf("%s%s", *files, OBJ_FILE_SUFFIX);\r
+                       else printf("%s.%s", *files, suffix);\r
+                       *p = '.';\r
+               }\r
+               files++;\r
+               --n;\r
+       }\r
+}\r
+\r
+void pclasses(classes, n, suffix)\r
+char **classes;\r
+int n;\r
+char *suffix;\r
+{\r
+       int first=1;\r
+\r
+       while ( n>0 )\r
+       {\r
+               if ( !first ) putchar(' ');\r
+               first=0;\r
+               if ( suffix == NULL ) printf("%s", *classes);\r
+               else {\r
+                       printf("%s", DIR());\r
+                       if ( strcmp(suffix, "o")==0 ) printf("%s%s", *classes, OBJ_FILE_SUFFIX);\r
+                       else printf("%s.%s", *classes, suffix);\r
+               }\r
+               classes++;\r
+               --n;\r
+       }\r
+}\r
+\r
+static void\r
+#ifdef __STDC__\r
+ProcessArgs( int argc, char **argv, Opt *options )\r
+#else\r
+ProcessArgs( argc, argv, options )\r
+int argc;\r
+char **argv;\r
+Opt *options;\r
+#endif\r
+{\r
+       Opt *p;\r
+       require(argv!=NULL, "ProcessArgs: command line NULL");\r
+\r
+       while ( argc-- > 0 )\r
+       {\r
+               p = options;\r
+               while ( p->option != NULL )\r
+               {\r
+                       if ( strcmp(p->option, "*") == 0 ||\r
+                                strcmp(p->option, *argv) == 0 )\r
+                       {\r
+                               if ( p->arg )\r
+                               {\r
+                                       (*p->process)( *argv, *(argv+1) );\r
+                                       argv++;\r
+                                       argc--;\r
+                               }\r
+                               else\r
+                                       (*p->process)( *argv );\r
+                               break;\r
+                       }\r
+                       p++;\r
+               }\r
+               argv++;\r
+       }\r
+}\r
+\r
+void fatal( err_)\r
+char *err_;\r
+{\r
+    fprintf(stderr, "genmk: %s\n", err_);\r
+    exit(1);\r
+}\r
+\r
+void warn( err_)\r
+char *err_;\r
+{\r
+    fprintf(stderr, "genmk: %s\n", err_);\r
+}\r
+\r
+char *DIR()\r
+{\r
+       static char buf[200+1];\r
+       \r
+       if ( strcmp(outdir,TopDirectory)==0 ) return "";\r
+       sprintf(buf, "%s%s", outdir, DirectorySymbol);\r
+       return buf;\r
+}\r
diff --git a/Tools/CodeTools/Source/Pccts/support/genmk/makefile b/Tools/CodeTools/Source/Pccts/support/genmk/makefile
new file mode 100644 (file)
index 0000000..a003c2f
--- /dev/null
@@ -0,0 +1,29 @@
+##\r
+##  7-Apr-97\r
+##  added support/genmk/makefile to pccts 1.33MR1 distribution kit\r
+##             (support/genmk/makefile" omitted from 1.33 distribution kit)\r
+##\r
+SRC=genmk.c\r
+OBJ=genmk.o\r
+# Define PC if you use a PC OS (changes directory symbol and object file extension)\r
+# see pccts/h/pcctscfg.h\r
+CC=cc\r
+COPT=-O\r
+#CFLAGS=-I../../h -DPC\r
+CFLAGS=$(COPT) -I../../h\r
+BAG=../../bin/bag\r
+\r
+genmk: $(OBJ) $(SRC) ../../h/pcctscfg.h\r
+       $(CC) -o genmk $(OBJ)\r
+\r
+clean:\r
+       rm -rf core *.o\r
+\r
+scrub:\r
+       rm -rf genmk core *.o\r
+\r
+shar:\r
+       shar genmk.c makefile > genmk.shar\r
+\r
+archive:\r
+       $(BAG) genmk.c makefile > genmk.bag\r
diff --git a/Tools/CodeTools/Source/Pccts/support/rexpr/makefile b/Tools/CodeTools/Source/Pccts/support/rexpr/makefile
new file mode 100644 (file)
index 0000000..44caef1
--- /dev/null
@@ -0,0 +1,19 @@
+BAG=../../bin/bag\r
+SRC=test.c rexpr.c\r
+OBJ=test.o rexpr.o\r
+CFLAGS = -g\r
+\r
+test: $(OBJ) $(SRC)\r
+       cc -g -o texpr $(OBJ)\r
+\r
+shar:\r
+       shar makefile test.c rexpr.c rexpr.h > rexpr.shar\r
+\r
+archive:\r
+       $(BAG) makefile test.c rexpr.c rexpr.h > rexpr.bag\r
+\r
+clean:\r
+       rm -rf *.o core texpr\r
+\r
+scrub:\r
+       rm -rf *.o core texpr\r
diff --git a/Tools/CodeTools/Source/Pccts/support/rexpr/rexpr.c b/Tools/CodeTools/Source/Pccts/support/rexpr/rexpr.c
new file mode 100644 (file)
index 0000000..805bf65
--- /dev/null
@@ -0,0 +1,586 @@
+/*\r
+ * This file contains code for\r
+ *\r
+ *      int rexpr(char *expr, char *s);\r
+ *\r
+ * which answers\r
+ *\r
+ *      1 if 's' is in the language described by the regular expression 'expr'\r
+ *      0 if it is not\r
+ *     -1 if the regular expression is invalid\r
+ *\r
+ * Language membership is determined by constructing a non-deterministic\r
+ * finite automata (NFA) from the regular expression.  A depth-\r
+ * first-search is performed on the NFA (graph) to check for a match of 's'.\r
+ * Each non-epsilon arc consumes one character from 's'.  Backtracking is\r
+ * performed to check all possible paths through the NFA.\r
+ *\r
+ * Regular expressions follow the meta-language:\r
+ *\r
+ * <regExpr>        ::= <andExpr> ( '|' <andExpr> )*\r
+ *\r
+ * <andExpr>        ::= <expr> ( <expr> )*\r
+ *\r
+ * <expr>           ::= {'~'} '[' <atomList> ']' <repeatSymbol>\r
+ *                      | '(' <regExpr> ')' <repeatSymbol>\r
+ *                      | '{' <regExpr> '}' <repeatSymbol>\r
+ *                      | <atom> <repeatSymbol>\r
+ *\r
+ * <repeatSymbol>   ::= { '*' | '+' }\r
+ *\r
+ * <atomList>       ::= <atom> ( <atom> )*\r
+ *                      | { <atomList> } <atom> '-' <atom> { <atomList> }\r
+ *\r
+ * <atom>           ::= Token[Atom]\r
+ *\r
+ * Notes:\r
+ *             ~       means complement the set in [..]. i.e. all characters not listed\r
+ *             *       means match 0 or more times (can be on expression or atom)\r
+ *             +       means match 1 or more times (can be on expression or atom)\r
+ *             {}      optional\r
+ *             ()      grouping\r
+ *             []      set of atoms\r
+ *             x-y     all characters from x to y (found only in [..])\r
+ *             \xx the character with value xx\r
+ *\r
+ * Examples:\r
+ *             [a-z]+\r
+ *                     match 1 or more lower-case letters (e.g. variable)\r
+ *\r
+ *             0x[0-9A-Fa-f]+\r
+ *                     match a hex number with 0x on front (e.g. 0xA1FF)\r
+ *\r
+ *             [0-9]+.[0-9]+{e[0-9]+}\r
+ *                     match a floating point number (e.g. 3.14e21)\r
+ *\r
+ * Code example:\r
+ *             if ( rexpr("[a-zA-Z][a-zA-Z0-9]+", str) ) then str is keyword\r
+ *\r
+ * Terence Parr\r
+ * Purdue University\r
+ * April 1991\r
+ */\r
+\r
+#include <stdio.h>\r
+#include <ctype.h>\r
+#ifdef __STDC__\r
+#include <stdlib.h>\r
+#else\r
+#include <malloc.h>\r
+#endif\r
+#include "rexpr.h"\r
+\r
+#ifdef __USE_PROTOS\r
+static int regExpr( GraphPtr g );\r
+static int andExpr( GraphPtr g );\r
+static int expr( GraphPtr g );\r
+static int repeatSymbol( GraphPtr g );\r
+static int atomList( char *p, int complement );\r
+static void next( void );\r
+static ArcPtr newGraphArc( void );\r
+static NodePtr newNode( void );\r
+static int ArcBetweenGraphNode( NodePtr i, NodePtr j, int label );\r
+static Graph BuildNFA_atom( int label );\r
+static Graph BuildNFA_AB( Graph A, Graph B );\r
+static Graph BuildNFA_AorB( Graph A, Graph B );\r
+static Graph BuildNFA_set( char *s );\r
+static Graph BuildNFA_Astar( Graph A );\r
+static Graph BuildNFA_Aplus( Graph A );\r
+static Graph BuildNFA_Aoptional( Graph A );\r
+#else\r
+static int regExpr();\r
+static int andExpr();\r
+static int expr();\r
+static int repeatSymbol();\r
+static int atomList();\r
+static void next();\r
+static ArcPtr newGraphArc();\r
+static NodePtr newNode();\r
+static int ArcBetweenGraphNode();\r
+static Graph BuildNFA_atom();\r
+static Graph BuildNFA_AB();\r
+static Graph BuildNFA_AorB();\r
+static Graph BuildNFA_set();\r
+static Graph BuildNFA_Astar();\r
+static Graph BuildNFA_Aplus();\r
+static Graph BuildNFA_Aoptional();\r
+#endif\r
+\r
+static char *_c;\r
+static int token, tokchar;\r
+static NodePtr accept;\r
+static NodePtr freelist = NULL;\r
+\r
+/*\r
+ * return 1 if s in language described by expr\r
+ *        0 if s is not\r
+ *       -1 if expr is an invalid regular expression\r
+ */\r
+#ifdef __USE_PROTOS\r
+static int rexpr(char *expr,char *s)\r
+#else\r
+static int rexpr(expr, s)\r
+char *expr, *s;\r
+#endif\r
+{\r
+       NodePtr p,q;\r
+       Graph nfa;\r
+       int result;\r
+\r
+       fprintf(stderr, "rexpr(%s,%s);\n", expr,s);\r
+       freelist = NULL;\r
+       _c = expr;\r
+       next();\r
+       if ( regExpr(&nfa) == -1 ) return -1;\r
+       accept = nfa.right;\r
+       result = match(nfa.left, s);\r
+       /* free all your memory */\r
+       p = q = freelist;\r
+       while ( p!=NULL ) { q = p->track; free(p); p = q; }\r
+       return result;\r
+}\r
+\r
+/*\r
+ * do a depth-first-search on the NFA looking for a path from start to\r
+ * accept state labelled with the characters of 's'.\r
+ */\r
+\r
+#ifdef __USE_PROTOS\r
+static int match(NodePtr automaton,char *s)\r
+#else\r
+static int match(automaton, s)\r
+NodePtr automaton;\r
+char *s;\r
+#endif\r
+{\r
+       ArcPtr p;\r
+       \r
+       if ( automaton == accept && *s == '\0' ) return 1;      /* match */\r
+\r
+       for (p=automaton->arcs; p!=NULL; p=p->next)                     /* try all arcs */\r
+       {\r
+               if ( p->label == Epsilon )\r
+               {\r
+                       if ( match(p->target, s) ) return 1;\r
+               }\r
+               else if ( p->label == *s )\r
+                               if ( match(p->target, s+1) ) return 1;\r
+       }\r
+       return 0;\r
+}\r
+\r
+/*\r
+ * <regExpr>        ::= <andExpr> ( '|' {<andExpr>} )*\r
+ *\r
+ * Return -1 if syntax error\r
+ * Return  0 if none found\r
+ * Return  1 if a regExrp was found\r
+ */\r
+\r
+#ifdef __USE_PROTOS\r
+static int regExpr(GraphPtr g)\r
+#else\r
+static int regExpr(g)\r
+GraphPtr g;\r
+#endif\r
+{\r
+       Graph g1, g2;\r
+       \r
+       if ( andExpr(&g1) == -1 )\r
+       {\r
+               return -1;\r
+       }\r
+       \r
+       while ( token == '|' )\r
+       {\r
+               int a;\r
+               next();\r
+               a = andExpr(&g2);\r
+               if ( a == -1 ) return -1;       /* syntax error below */\r
+               else if ( !a ) return 1;        /* empty alternative */\r
+               g1 = BuildNFA_AorB(g1, g2);\r
+       }\r
+       \r
+       if ( token!='\0' ) return -1;\r
+\r
+       *g = g1;\r
+       return 1;\r
+}\r
+\r
+/*\r
+ * <andExpr>        ::= <expr> ( <expr> )*\r
+ */\r
+\r
+#ifdef __USE_PROTOS\r
+static int andExpr(GraphPtr g)\r
+#else\r
+static int andExpr(g)\r
+GraphPtr g;\r
+#endif\r
+{\r
+       Graph g1, g2;\r
+       \r
+       if ( expr(&g1) == -1 )\r
+       {\r
+               return -1;\r
+       }\r
+       \r
+       while ( token==Atom || token=='{' || token=='(' || token=='~' || token=='[' )\r
+       {\r
+               if (expr(&g2) == -1) return -1;\r
+               g1 = BuildNFA_AB(g1, g2);\r
+       }\r
+       \r
+       *g = g1;\r
+       return 1;\r
+}\r
+\r
+/*\r
+ * <expr>           ::=    {'~'} '[' <atomList> ']' <repeatSymbol>\r
+ *                      | '(' <regExpr> ')' <repeatSymbol>\r
+ *                      | '{' <regExpr> '}' <repeatSymbol>\r
+ *                      | <atom> <repeatSymbol>\r
+ */\r
+\r
+#ifdef __USE_PROTOS\r
+static int expr(GraphPtr g)\r
+#else\r
+static int expr(g)\r
+GraphPtr g;\r
+#endif\r
+{\r
+       int complement = 0;\r
+       char s[257];    /* alloc space for string of char in [] */\r
+       \r
+       if ( token == '~' || token == '[' )\r
+       {\r
+               if ( token == '~' ) {complement = 1; next();}\r
+               if ( token != '[' ) return -1;\r
+               next();\r
+               if ( atomList( s, complement ) == -1 ) return -1;\r
+               *g = BuildNFA_set( s );\r
+               if ( token != ']' ) return -1;\r
+               next();\r
+               repeatSymbol( g );\r
+               return 1;\r
+       }\r
+       if ( token == '(' )\r
+       {\r
+               next();\r
+               if ( regExpr( g ) == -1 ) return -1;\r
+               if ( token != ')' ) return -1;\r
+               next();\r
+               repeatSymbol( g );\r
+               return 1;\r
+       }\r
+       if ( token == '{' )\r
+       {\r
+               next();\r
+               if ( regExpr( g ) == -1 ) return -1;\r
+               if ( token != '}' ) return -1;\r
+               next();\r
+               /* S p e c i a l  C a s e   O p t i o n a l  {  } */\r
+               if ( token != '*' && token != '+' )\r
+               {\r
+                       *g = BuildNFA_Aoptional( *g );\r
+               }\r
+               repeatSymbol( g );\r
+               return 1;\r
+       }\r
+       if ( token == Atom )\r
+       {\r
+               *g = BuildNFA_atom( tokchar );\r
+               next();\r
+               repeatSymbol( g );\r
+               return 1;\r
+       }\r
+       \r
+       return -1;\r
+}\r
+\r
+/*\r
+ * <repeatSymbol>   ::= { '*' | '+' }\r
+ */\r
+#ifdef __USE_PROTOS\r
+static int repeatSymbol(GraphPtr g)\r
+#else\r
+static int repeatSymbol(g)\r
+GraphPtr g;\r
+#endif\r
+{\r
+       switch ( token )\r
+       {\r
+               case '*' : *g = BuildNFA_Astar( *g ); next(); break;\r
+               case '+' : *g = BuildNFA_Aplus( *g ); next(); break;\r
+       }\r
+       return 1;\r
+}\r
+\r
+/*\r
+ * <atomList>       ::= <atom> { <atom> }*\r
+ *                      { <atomList> } <atom> '-' <atom> { <atomList> }\r
+ *\r
+ * a-b is same as ab\r
+ * q-a is same as q\r
+ */\r
+\r
+#ifdef __USE_PROTOS\r
+static int atomList(char *p, int complement)\r
+#else\r
+static int atomList(p, complement)\r
+char *p;\r
+int complement;\r
+#endif\r
+{\r
+       static unsigned char set[256];          /* no duplicates */\r
+       int first, last, i;\r
+       char *s = p;\r
+       \r
+       if ( token != Atom ) return -1;\r
+       \r
+       for (i=0; i<256; i++) set[i] = 0;\r
+       while ( token == Atom )\r
+       {\r
+               if ( !set[tokchar] ) *s++ = tokchar;\r
+               set[tokchar] = 1;                       /* Add atom to set */\r
+               next();\r
+               if ( token == '-' )             /* have we found '-' */\r
+               {\r
+                       first = *(s-1);             /* Get last char */\r
+                       next();\r
+                       if ( token != Atom ) return -1;\r
+                       else\r
+                       {\r
+                               last = tokchar;\r
+                       }\r
+                       for (i = first+1; i <= last; i++)\r
+                       {\r
+                               if ( !set[tokchar] ) *s++ = i;\r
+                               set[i] = 1;                     /* Add atom to set */\r
+                       }\r
+                       next();\r
+               }\r
+       }\r
+       *s = '\0';\r
+       if ( complement )\r
+       {\r
+               for (i=0; i<256; i++) set[i] = !set[i];\r
+               for (i=1,s=p; i<256; i++) if ( set[i] ) *s++ = i;\r
+               *s = '\0';\r
+       }\r
+       return 1;\r
+}\r
+\r
+/* a somewhat stupid lexical analyzer */\r
+\r
+#ifdef __USE_PROTOS\r
+static void next(void)\r
+#else\r
+static void next()\r
+#endif\r
+{\r
+       while ( *_c==' ' || *_c=='\t' || *_c=='\n' ) _c++;\r
+       if ( *_c=='\\' )\r
+       {\r
+               _c++;\r
+               if ( isdigit(*_c) )\r
+               {\r
+                       int n=0;\r
+                       while ( isdigit(*_c) )\r
+                       {\r
+                               n = n*10 + (*_c++ - '0');\r
+                       }\r
+                       if ( n>255 ) n=255;\r
+                       tokchar = n;\r
+               }\r
+               else\r
+               {\r
+                       switch (*_c)\r
+                       {\r
+                               case 'n' : tokchar = '\n'; break;\r
+                               case 't' : tokchar = '\t'; break;\r
+                               case 'r' : tokchar = '\r'; break;\r
+                               default  : tokchar = *_c;\r
+                       }\r
+                       _c++;\r
+               }\r
+               token = Atom;\r
+       }\r
+       else if ( isgraph(*_c) && *_c!='[' && *_c!='(' && *_c!='{' &&\r
+                         *_c!='-' && *_c!='}' && *_c!=')' && *_c!=']' &&\r
+                         *_c!='+' && *_c!='*' && *_c!='~' && *_c!='|' )\r
+       {\r
+               token = Atom;\r
+               tokchar = *_c++;\r
+       }\r
+       else\r
+       {\r
+               token = tokchar = *_c++;\r
+       }\r
+}\r
+\r
+/* N F A  B u i l d i n g  R o u t i n e s */\r
+\r
+#ifdef __USE_PROTOS\r
+static ArcPtr newGraphArc(void)\r
+#else\r
+static ArcPtr newGraphArc()\r
+#endif\r
+{\r
+       ArcPtr p;\r
+       p = (ArcPtr) calloc(1, sizeof(Arc));\r
+       if ( p==NULL ) {fprintf(stderr,"rexpr: out of memory\n"); exit(-1);}\r
+       if ( freelist != NULL ) p->track = (ArcPtr) freelist;\r
+       freelist = (NodePtr) p;\r
+       return p;\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+static NodePtr newNode(void)\r
+#else\r
+static NodePtr newNode()\r
+#endif\r
+{\r
+       NodePtr p;\r
+       p = (NodePtr) calloc(1, sizeof(Node));\r
+       if ( p==NULL ) {fprintf(stderr,"rexpr: out of memory\n"); exit(-1);}\r
+       if ( freelist != NULL ) p->track = freelist;\r
+       freelist = p;\r
+       return p;\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+static void ArcBetweenGraphNodes(NodePtr i,NodePtr j,int label)\r
+#else\r
+static void ArcBetweenGraphNodes(i, j, label)\r
+NodePtr i, j;\r
+int label;\r
+#endif\r
+{\r
+       ArcPtr a;\r
+       \r
+       a = newGraphArc();\r
+       if ( i->arcs == NULL ) i->arctail = i->arcs = a;\r
+       else {(i->arctail)->next = a; i->arctail = a;}\r
+       a->label = label;\r
+       a->target = j;\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+static Graph BuildNFA_atom(int label)\r
+#else\r
+static Graph BuildNFA_atom(label)\r
+int label;\r
+#endif\r
+{\r
+       Graph g;\r
+       \r
+       g.left = newNode();\r
+       g.right = newNode();\r
+       ArcBetweenGraphNodes(g.left, g.right, label);\r
+       return( g );\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+static Graph BuildNFA_AB(Graph A,Graph B)\r
+#else\r
+static Graph BuildNFA_AB(A, B)\r
+Graph A, B;\r
+#endif\r
+{\r
+       Graph g;\r
+       \r
+       ArcBetweenGraphNodes(A.right, B.left, Epsilon);\r
+       g.left = A.left;\r
+       g.right = B.right;\r
+       return( g );\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+static Graph BuildNFA_AorB(Graph A,Graph B)\r
+#else\r
+static Graph BuildNFA_AorB(A, B)\r
+Graph A, B;\r
+#endif\r
+{\r
+       Graph g;\r
+       \r
+       g.left = newNode();\r
+       ArcBetweenGraphNodes(g.left, A.left, Epsilon);\r
+       ArcBetweenGraphNodes(g.left, B.left, Epsilon);\r
+       g.right = newNode();\r
+       ArcBetweenGraphNodes(A.right, g.right, Epsilon);\r
+       ArcBetweenGraphNodes(B.right, g.right, Epsilon);\r
+       return( g );\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+static Graph BuildNFA_set(char *s)\r
+#else\r
+static Graph BuildNFA_set( s )\r
+char *s;\r
+#endif\r
+{\r
+       Graph g;\r
+       \r
+       if ( s == NULL ) return g;\r
+       \r
+       g.left = newNode();\r
+       g.right = newNode();\r
+       while ( *s != '\0' )\r
+       {\r
+               ArcBetweenGraphNodes(g.left, g.right, *s++);\r
+       }\r
+       return g;\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+static Graph BuildNFA_Astar(Graph A)\r
+#else\r
+static Graph BuildNFA_Astar( A )\r
+Graph A;\r
+#endif\r
+{\r
+       Graph g;\r
+\r
+       g.left = newNode();\r
+       g.right = newNode();\r
+       \r
+       ArcBetweenGraphNodes(g.left, A.left, Epsilon);\r
+       ArcBetweenGraphNodes(g.left, g.right, Epsilon);\r
+       ArcBetweenGraphNodes(A.right, g.right, Epsilon);\r
+       ArcBetweenGraphNodes(A.right, A.left, Epsilon);\r
+       \r
+       return( g );\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+static Graph BuildNFA_Aplus(Graph A)\r
+#else\r
+static Graph BuildNFA_Aplus( A )\r
+Graph A;\r
+#endif\r
+{\r
+       ArcBetweenGraphNodes(A.right, A.left, Epsilon);\r
+       \r
+       return( A );\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+static Graph BuildNFA_Aoptional(Graph A)\r
+#else\r
+static Graph BuildNFA_Aoptional( A )\r
+Graph A;\r
+#endif\r
+{\r
+       Graph g;\r
+       \r
+       g.left = newNode();\r
+       g.right = newNode();\r
+       \r
+       ArcBetweenGraphNodes(g.left, A.left, Epsilon);\r
+       ArcBetweenGraphNodes(g.left, g.right, Epsilon);\r
+       ArcBetweenGraphNodes(A.right, g.right, Epsilon);\r
+       \r
+       return( g );\r
+}\r
diff --git a/Tools/CodeTools/Source/Pccts/support/rexpr/rexpr.h b/Tools/CodeTools/Source/Pccts/support/rexpr/rexpr.h
new file mode 100644 (file)
index 0000000..e67a965
--- /dev/null
@@ -0,0 +1,30 @@
+#define Atom   256             /* token Atom (an impossible char value) */\r
+#define Epsilon        257             /* epsilon arc (an impossible char value) */\r
+\r
+/* track field must be same for all node types */\r
+typedef struct _a {\r
+                                       struct _a *track;       /* track mem allocation */\r
+                                       int label;\r
+                                       struct _a *next;\r
+                                       struct _n *target;\r
+                               } Arc, *ArcPtr;\r
+\r
+typedef struct _n {\r
+                                       struct _n *track;\r
+                                       ArcPtr arcs, arctail;\r
+                               } Node, *NodePtr;\r
+\r
+typedef struct {\r
+                                       NodePtr left,\r
+                                                       right;\r
+                               } Graph, *GraphPtr;\r
+\r
+#ifdef __USE_PROTOS\r
+int rexpr( char *expr, char *s );\r
+int match( NodePtr automaton, char *s );\r
+#else\r
+int rexpr();\r
+int match();\r
+#endif\r
+\r
+\r
diff --git a/Tools/CodeTools/Source/Pccts/support/rexpr/test.c b/Tools/CodeTools/Source/Pccts/support/rexpr/test.c
new file mode 100644 (file)
index 0000000..2619539
--- /dev/null
@@ -0,0 +1,19 @@
+#include <stdio.h>\r
+#include "rexpr.h"\r
+\r
+/*\r
+ * test for rexpr().\r
+ * To make this test:\r
+ *     cc -o rexpr test.c rexpr.c\r
+ * Then from command line type:\r
+ *     rexpr r string\r
+ * where r is the regular expression that decribes a language\r
+ * and string is the string to verify.\r
+ */\r
+main(argc,argv)\r
+int argc;\r
+char *argv[];\r
+{\r
+       if ( argc!=3 ) fprintf(stderr,"rexpr: expr s\n");\r
+       else printf("%d\n", rexpr(argv[1], argv[2]));\r
+}\r
diff --git a/Tools/CodeTools/Source/Pccts/support/set/set.c b/Tools/CodeTools/Source/Pccts/support/set/set.c
new file mode 100644 (file)
index 0000000..eb6fba7
--- /dev/null
@@ -0,0 +1,816 @@
+/*     set.c\r
+\r
+       The following is a general-purpose set library originally developed\r
+       by Hank Dietz and enhanced by Terence Parr to allow dynamic sets.\r
+       \r
+       Sets are now structs containing the #words in the set and\r
+       a pointer to the actual set words.\r
+       \r
+       Generally, sets need not be explicitly allocated.  They are\r
+       created/extended/shrunk when appropriate (e.g. in set_of()).\r
+       HOWEVER, sets need to be destroyed (free()ed) when they go out of scope\r
+       or are otherwise no longer needed.  A routine is provided to\r
+       free a set.\r
+       \r
+       Sets can be explicitly created with set_new(s, max_elem).\r
+       \r
+       Sets can be declared to have minimum size to reduce realloc traffic.\r
+       Default minimum size = 1.\r
+       \r
+       Sets can be explicitly initialized to have no elements (set.n == 0)\r
+       by using the 'empty' initializer:\r
+       \r
+       Examples:\r
+               set a = empty;  -- set_deg(a) == 0\r
+               \r
+               return( empty );\r
+       \r
+       Example set creation and destruction:\r
+       \r
+       set\r
+       set_of2(e,g)\r
+       unsigned e,g;\r
+       {\r
+               set a,b,c;\r
+               \r
+               b = set_of(e);          -- Creates space for b and sticks in e\r
+               set_new(c, g);          -- set_new(); set_orel() ==> set_of()\r
+               set_orel(g, &c);\r
+               a = set_or(b, c);\r
+               .\r
+               .\r
+               .\r
+               set_free(b);\r
+               set_free(c);\r
+               return( a );\r
+       }\r
+\r
+       1987 by Hank Dietz\r
+       \r
+       Modified by:\r
+               Terence Parr\r
+               Purdue University\r
+               October 1989\r
+\r
+       Made it smell less bad to C++ 7/31/93 -- TJP\r
+*/\r
+\r
+#include <stdio.h>\r
+#include "pcctscfg.h"\r
+#ifdef __STDC__\r
+#include <stdlib.h>\r
+#else\r
+#include <malloc.h>\r
+#endif\r
+#include <string.h>\r
+\r
+#include "set.h"\r
+\r
+#define MIN(i,j) ( (i) > (j) ? (j) : (i))\r
+#define MAX(i,j) ( (i) < (j) ? (j) : (i))\r
+\r
+/* elems can be a maximum of 32 bits */\r
+static unsigned bitmask[] = {\r
+       0x00000001, 0x00000002, 0x00000004, 0x00000008,\r
+       0x00000010, 0x00000020, 0x00000040, 0x00000080,\r
+       0x00000100, 0x00000200, 0x00000400, 0x00000800,\r
+       0x00001000, 0x00002000, 0x00004000, 0x00008000,\r
+#if !defined(PC) || defined(PC32)\r
+       0x00010000, 0x00020000, 0x00040000, 0x00080000,\r
+       0x00100000, 0x00200000, 0x00400000, 0x00800000,\r
+       0x01000000, 0x02000000, 0x04000000, 0x08000000,\r
+       0x10000000, 0x20000000, 0x40000000, 0x80000000\r
+#endif\r
+};\r
+\r
+set empty = set_init;\r
+static unsigned min=1;\r
+\r
+#define StrSize                200\r
+\r
+#ifdef MEMCHK\r
+#define CHK(a)                                 \\r
+       if ( a.setword != NULL )        \\r
+         if ( !valid(a.setword) )      \\r
+               {fprintf(stderr, "%s(%d): invalid set\n",__FILE__,__LINE__); exit(-1);}\r
+#else\r
+#define CHK(a)\r
+#endif\r
+\r
+/*\r
+ * Set the minimum size (in words) of a set to reduce realloc calls\r
+ */\r
+void\r
+#ifdef __USE_PROTOS\r
+set_size( unsigned n )\r
+#else\r
+set_size( n )\r
+unsigned n;\r
+#endif\r
+{\r
+       min = n;\r
+}\r
+\r
+unsigned int\r
+#ifdef __USE_PROTOS\r
+set_deg( set a )\r
+#else\r
+set_deg( a )\r
+set a;\r
+#endif\r
+{\r
+       /* Fast compute degree of a set... the number\r
+          of elements present in the set.  Assumes\r
+          that all word bits are used in the set\r
+          and that SETSIZE(a) is a multiple of WORDSIZE.\r
+       */\r
+       register unsigned *p = &(a.setword[0]);\r
+       register unsigned *endp = NULL; /* MR27 Avoid false memory check report */\r
+       register unsigned degree = 0;\r
+\r
+       CHK(a);\r
+       if ( a.n == 0 ) return(0);\r
+       endp = &(a.setword[a.n]);\r
+       while ( p < endp )\r
+       {\r
+               register unsigned t = *p;\r
+               register unsigned *b = &(bitmask[0]);\r
+               do {\r
+                       if (t & *b) ++degree;\r
+               } while (++b < &(bitmask[WORDSIZE]));\r
+               p++;\r
+       }\r
+\r
+       return(degree);\r
+}\r
+\r
+set\r
+#ifdef __USE_PROTOS\r
+set_or( set b, set c )\r
+#else\r
+set_or( b, c )\r
+set b;\r
+set c;\r
+#endif\r
+{\r
+       /* Fast set union operation */\r
+       /* resultant set size is max(b, c); */\r
+       set *big;\r
+       set t;\r
+       unsigned int m,n;\r
+       register unsigned *r, *p, *q, *endp;\r
+\r
+       CHK(b); CHK(c);\r
+       t = empty;\r
+       if (b.n > c.n) {big= &b; m=b.n; n=c.n;} else {big= &c; m=c.n; n=b.n;}\r
+       set_ext(&t, m);\r
+       r = t.setword;\r
+\r
+       /* Or b,c until max of smaller set */\r
+       q = c.setword;\r
+       p = b.setword;\r
+       endp = &(b.setword[n]);\r
+       while ( p < endp ) *r++ = *p++ | *q++;  \r
+\r
+       /* Copy rest of bigger set into result */\r
+       p = &(big->setword[n]);\r
+       endp = &(big->setword[m]);\r
+       while ( p < endp ) *r++ = *p++;\r
+\r
+       return(t);\r
+}\r
+\r
+set\r
+#ifdef __USE_PROTOS\r
+set_and( set b, set c )\r
+#else\r
+set_and( b, c )\r
+set b;\r
+set c;\r
+#endif\r
+{\r
+       /* Fast set intersection operation */\r
+       /* resultant set size is min(b, c); */\r
+       set t;\r
+       unsigned int n;\r
+       register unsigned *r, *p, *q, *endp;\r
+\r
+       CHK(b); CHK(c);\r
+       t = empty;\r
+       n = (b.n > c.n) ? c.n : b.n;\r
+       if ( n == 0 ) return t;         /* TJP 4-27-92 fixed for empty set */\r
+       set_ext(&t, n);\r
+       r = t.setword;\r
+\r
+       /* & b,c until max of smaller set */\r
+       q = c.setword;\r
+       p = b.setword;\r
+       endp = &(b.setword[n]);\r
+       while ( p < endp ) *r++ = *p++ & *q++;  \r
+\r
+       return(t);\r
+}\r
+\r
+set\r
+#ifdef __USE_PROTOS\r
+set_dif( set b, set c )\r
+#else\r
+set_dif( b, c )\r
+set b;\r
+set c;\r
+#endif\r
+{\r
+       /* Fast set difference operation b - c */\r
+       /* resultant set size is size(b) */\r
+       set t;\r
+       unsigned int n;\r
+       register unsigned *r, *p, *q, *endp;\r
+\r
+       CHK(b); CHK(c);\r
+       t = empty;\r
+       n = (b.n <= c.n) ? b.n : c.n ;\r
+       if ( b.n == 0 ) return t;               /* TJP 4-27-92 fixed for empty set */\r
+                                                                       /* WEC 12-1-92 fixed for c.n = 0 */\r
+       set_ext(&t, b.n);\r
+       r = t.setword;\r
+\r
+       /* Dif b,c until smaller set size */\r
+       q = c.setword;\r
+       p = b.setword;\r
+       endp = &(b.setword[n]);\r
+       while ( p < endp ) *r++ = *p++ & (~ *q++);      \r
+\r
+       /* Copy rest of b into result if size(b) > c */\r
+       if ( b.n > n )\r
+       {\r
+               p = &(b.setword[n]);\r
+               endp = &(b.setword[b.n]);\r
+               while ( p < endp ) *r++ = *p++;\r
+       }\r
+\r
+       return(t);\r
+}\r
+\r
+set\r
+#ifdef __USE_PROTOS\r
+set_of( unsigned b )\r
+#else\r
+set_of( b )\r
+unsigned b;\r
+#endif\r
+{\r
+       /* Fast singleton set constructor operation */\r
+       static set a;\r
+\r
+       if ( b == nil ) return( empty );\r
+       set_new(a, b);\r
+       a.setword[DIVWORD(b)] = bitmask[MODWORD(b)];\r
+\r
+       return(a);\r
+}\r
+\r
+/*\r
+ * Extend (or shrink) the set passed in to have n words.\r
+ *\r
+ * if n is smaller than the minimum, boost n to have the minimum.\r
+ * if the new set size is the same as the old one, do nothing.\r
+ *\r
+ * TJP 4-27-92 Fixed so won't try to alloc 0 bytes\r
+ */\r
+void\r
+#ifdef __USE_PROTOS\r
+set_ext( set *a, unsigned int n )\r
+#else\r
+set_ext( a, n )\r
+set *a;\r
+unsigned int n;\r
+#endif\r
+{\r
+       register unsigned *p;\r
+       register unsigned *endp;\r
+       unsigned int size;\r
+       \r
+       CHK((*a));\r
+    if ( a->n == 0 )\r
+    {\r
+               if ( n == 0 ) return;\r
+               if (a->setword != NULL) {\r
+                       free (a->setword);      /* MR20 */\r
+               }\r
+        a->setword = (unsigned *) calloc(n, BytesPerWord);\r
+        if ( a->setword == NULL )\r
+        {\r
+            fprintf(stderr, "set_ext(%d words): cannot allocate set\n", n);\r
+            exit(-1);\r
+        }\r
+        a->n = n;\r
+        return;\r
+    }\r
+       if ( n < min ) n = min;\r
+       if ( a->n == n || n == 0 ) return;\r
+       size = a->n;\r
+       a->n = n;\r
+       a->setword = (unsigned *) realloc( (char *)a->setword, (n*BytesPerWord) );\r
+       if ( a->setword == NULL )\r
+       {\r
+               fprintf(stderr, "set_ext(%d words): cannot allocate set\n", n);\r
+               exit(-1);\r
+       }\r
+\r
+       p    = &(a->setword[size]);             /* clear from old size to new size */\r
+       endp = &(a->setword[a->n]);\r
+       do {\r
+               *p++ = 0;\r
+       } while ( p < endp );\r
+}\r
+\r
+set\r
+#ifdef __USE_PROTOS\r
+set_not( set a )\r
+#else\r
+set_not( a )\r
+set a;\r
+#endif\r
+{\r
+       /* Fast not of set a (assumes all bits used) */\r
+       /* size of resultant set is size(a) */\r
+       /* ~empty = empty cause we don't know how bit to make set */\r
+       set t;\r
+       register unsigned *r;\r
+       register unsigned *p = a.setword;\r
+       register unsigned *endp = &(a.setword[a.n]);\r
+\r
+       CHK(a);\r
+       t = empty;\r
+       if ( a.n == 0 ) return( empty );\r
+       set_ext(&t, a.n);\r
+       r = t.setword;\r
+       \r
+       do {\r
+               *r++ = (~ *p++);\r
+       } while ( p < endp );\r
+\r
+       return(t);\r
+}\r
+\r
+int\r
+#ifdef __USE_PROTOS\r
+set_equ( set a, set b )\r
+#else\r
+set_equ( a, b )\r
+set a;\r
+set b;\r
+#endif\r
+{\r
+/* 8-Nov-97     Make it work with sets of different sizes       */\r
+/*              Easy to understand, too.  Probably faster.      */\r
+/*              Check for a equal to b                          */\r
+\r
+    unsigned int    count;      /* MR11 */\r
+    unsigned int    i;          /* MR11 */\r
+\r
+       CHK(a); CHK(b);\r
+\r
+    count=MIN(a.n,b.n);\r
+    if (count == 0) return 1;\r
+    for (i=0; i < count; i++) {\r
+      if (a.setword[i] != b.setword[i]) return 0;\r
+    };\r
+    if (a.n < b.n) {\r
+      for (i=count; i < b.n; i++) {\r
+        if (b.setword[i] != 0) return 0;\r
+      }\r
+      return 1;\r
+    } else if (a.n > b.n) {\r
+      for (i=count; i < a.n; i++) {\r
+        if (a.setword[i] != 0) return 0;\r
+      }\r
+      return 1;\r
+    } else {\r
+      return 1;\r
+    };\r
+}\r
+\r
+int\r
+#ifdef __USE_PROTOS\r
+set_sub( set a, set b )\r
+#else\r
+set_sub( a, b )\r
+set a;\r
+set b;\r
+#endif\r
+{\r
+\r
+/* 8-Nov-97     Make it work with sets of different sizes       */\r
+/*              Easy to understand, too.  Probably faster.      */\r
+/*              Check for a is a PROPER subset of b             */\r
+\r
+    unsigned int    count;\r
+    unsigned int    i;\r
+\r
+       CHK(a); CHK(b);\r
+\r
+    if (a.n == 0) return 1;\r
+    count=MIN(a.n,b.n);\r
+    for (i=0; i < count; i++) {\r
+      if (a.setword[i] & ~b.setword[i]) return 0;\r
+    };\r
+    if (a.n <= b.n) {\r
+      return 1;\r
+    } else {\r
+      for (i=count; i<a.n ; i++) {\r
+        if (a.setword[i]) return 0;\r
+      };\r
+    };\r
+    return 1;\r
+}\r
+\r
+unsigned\r
+#ifdef __USE_PROTOS\r
+set_int( set b )\r
+#else\r
+set_int( b )\r
+set b;\r
+#endif\r
+{\r
+       /* Fast pick any element of the set b */\r
+       register unsigned *p = b.setword;\r
+       register unsigned *endp = &(b.setword[b.n]);\r
+\r
+       CHK(b);\r
+       if ( b.n == 0 ) return( nil );\r
+\r
+       do {\r
+               if (*p) {\r
+                       /* Found a non-empty word of the set */\r
+                       register unsigned i = ((p - b.setword) << LogWordSize);\r
+                       register unsigned t = *p;\r
+                       p = &(bitmask[0]);\r
+                       while (!(*p & t)) {\r
+                               ++i; ++p;\r
+                       }\r
+                       return(i);\r
+               }\r
+       } while (++p < endp);\r
+\r
+       /* Empty -- only element it contains is nil */\r
+       return(nil);\r
+}\r
+\r
+int\r
+#ifdef __USE_PROTOS\r
+set_el( unsigned b, set a )\r
+#else\r
+set_el( b, a )\r
+unsigned b;\r
+set a;\r
+#endif\r
+{\r
+       CHK(a);\r
+       /* nil is an element of every set */\r
+       if (b == nil) return(1);\r
+       if ( a.n == 0 || NumWords(b) > a.n ) return(0);\r
+       \r
+       /* Otherwise, we have to check */\r
+       return( a.setword[DIVWORD(b)] & bitmask[MODWORD(b)] );\r
+}\r
+\r
+int\r
+#ifdef __USE_PROTOS\r
+set_nil( set a )\r
+#else\r
+set_nil( a )\r
+set a;\r
+#endif\r
+{\r
+       /* Fast check for nil set */\r
+       register unsigned *p = a.setword;\r
+       register unsigned *endp;\r
+\r
+       CHK(a);\r
+       if ( a.n == 0 ) return(1);\r
+       endp = &(a.setword[a.n]);\r
+       \r
+       /* The set is not empty if any word used to store\r
+          the set is non-zero.  This means one must be a\r
+          bit careful about doing things like negation.\r
+       */\r
+       do {\r
+               if (*p) return(0);\r
+       } while (++p < endp);\r
+       \r
+       return(1);\r
+}\r
+\r
+char *\r
+#ifdef __USE_PROTOS\r
+set_str( set a )\r
+#else\r
+set_str( a )\r
+set a;\r
+#endif\r
+{\r
+       /* Fast convert set a into ASCII char string...\r
+          assumes that all word bits are used in the set\r
+          and that SETSIZE is a multiple of WORDSIZE.\r
+          Trailing 0 bits are removed from the string.\r
+          if no bits are on or set is empty, "" is returned.\r
+       */\r
+       register unsigned *p = a.setword;\r
+       register unsigned *endp = &(a.setword[a.n]);\r
+       static char str_tmp[StrSize+1];\r
+       register char *q = &(str_tmp[0]);\r
+\r
+       CHK(a);\r
+       if ( a.n==0 ) {*q=0; return( &(str_tmp[0]) );}\r
+       do {\r
+               register unsigned t = *p;\r
+               register unsigned *b = &(bitmask[0]);\r
+               do {\r
+                       *(q++) = (char) ((t & *b) ? '1' : '0');\r
+               } while (++b < &(bitmask[WORDSIZE]));\r
+       } while (++p < endp);\r
+\r
+       /* Trim trailing 0s & NULL terminate the string */\r
+       while ((q > &(str_tmp[0])) && (*(q-1) != '1')) --q;\r
+       *q = 0;\r
+\r
+       return(&(str_tmp[0]));\r
+}\r
+\r
+set\r
+#ifdef __USE_PROTOS\r
+set_val( register char *s )\r
+#else\r
+set_val( s )\r
+register char *s;\r
+#endif\r
+{\r
+       /* Fast convert set ASCII char string into a set.\r
+          If the string ends early, the remaining set bits\r
+          are all made zero.\r
+          The resulting set size is just big enough to hold all elements.\r
+       */\r
+       static set a;\r
+       register unsigned *p, *endp;\r
+\r
+       set_new(a, strlen(s));\r
+       p = a.setword;\r
+       endp = &(a.setword[a.n]);\r
+       do {\r
+               register unsigned *b = &(bitmask[0]);\r
+               /* Start with a word with no bits on */\r
+               *p = 0;\r
+               do {\r
+                       if (*s) {\r
+                               if (*s == '1') {\r
+                                       /* Turn-on this bit */\r
+                                       *p |= *b;\r
+                               }\r
+                               ++s;\r
+                       }\r
+               } while (++b < &(bitmask[WORDSIZE]));\r
+       } while (++p < endp);\r
+\r
+       return(a);\r
+}\r
+\r
+/*\r
+ * Or element e into set a.  a can be empty.\r
+ */\r
+void\r
+#ifdef __USE_PROTOS\r
+set_orel( unsigned e, set *a )\r
+#else\r
+set_orel( e, a )\r
+unsigned e;\r
+set *a;\r
+#endif\r
+{\r
+       CHK((*a));\r
+       if ( e == nil ) return;\r
+       if ( NumWords(e) > a->n ) set_ext(a, NumWords(e));\r
+       a->setword[DIVWORD(e)] |= bitmask[MODWORD(e)];\r
+}\r
+\r
+/*\r
+ * Or set b into set a.  a can be empty. does nothing if b empty.\r
+ */\r
+void\r
+#ifdef __USE_PROTOS\r
+set_orin( set *a, set b )\r
+#else\r
+set_orin( a, b )\r
+set *a;\r
+set b;\r
+#endif\r
+{\r
+       /* Fast set union operation */\r
+       /* size(a) is max(a, b); */\r
+       unsigned int m;\r
+       register unsigned *p,\r
+                                         *q    = b.setword,\r
+                                         *endq; /* MR20 */\r
+\r
+       CHK((*a)); CHK(b);\r
+       if ( b.n == 0 ) return;\r
+       endq = &(b.setword[b.n]); /* MR20 */\r
+       m = (a->n > b.n) ? a->n : b.n;\r
+       set_ext(a, m);\r
+       p = a->setword;\r
+       do {\r
+               *p++ |= *q++;\r
+       } while ( q < endq );\r
+}\r
+\r
+/*\r
+ * And set b into set a.  a can be empty. does nothing if b empty.\r
+ */\r
+void\r
+#ifdef __USE_PROTOS\r
+set_andin( set *a, set b )\r
+#else\r
+set_andin( a, b )\r
+set *a;\r
+set b;\r
+#endif\r
+{\r
+       /* Fast set intersection operation */\r
+       /* size(a) is max(a, b); */\r
+       unsigned int m;\r
+       register unsigned *p,\r
+                                         *q    = b.setword,\r
+                                         *endq = &(b.setword[b.n]);\r
+\r
+       CHK((*a)); CHK(b);\r
+       if ( b.n == 0 ) return;\r
+       m = (a->n > b.n) ? a->n : b.n;\r
+       set_ext(a, m);\r
+       p = a->setword;\r
+       do {\r
+               *p++ &= *q++;\r
+       } while ( q < endq );\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+set_rm( unsigned e, set a )\r
+#else\r
+set_rm( e, a )\r
+unsigned e;\r
+set a;\r
+#endif\r
+{\r
+       /* Does not effect size of set */\r
+       CHK(a);\r
+       if ( (e == nil) || (NumWords(e) > a.n) ) return;\r
+       a.setword[DIVWORD(e)] ^= (a.setword[DIVWORD(e)]&bitmask[MODWORD(e)]);\r
+}\r
+\r
+void\r
+#ifdef __USE_PROTOS\r
+set_clr( set a )\r
+#else\r
+set_clr( a )\r
+set a;\r
+#endif\r
+{\r
+       /* Does not effect size of set */\r
+       register unsigned *p = a.setword;\r
+       register unsigned *endp;\r
+       \r
+       CHK(a);\r
+       if ( a.n == 0 ) return;\r
+       endp = &(a.setword[a.n]);\r
+       do {\r
+               *p++ = 0;\r
+       } while ( p < endp );\r
+}\r
+\r
+set\r
+#ifdef __USE_PROTOS\r
+set_dup( set a )\r
+#else\r
+set_dup( a )\r
+set a;\r
+#endif\r
+{\r
+       set b;\r
+       register unsigned *p,\r
+                                         *q    = a.setword,\r
+                                         *endq; /* MR20 */\r
+       \r
+       CHK(a);\r
+       b = empty;\r
+       if ( a.n == 0 ) return( empty );\r
+       endq = &(a.setword[a.n]);       /* MR20 */\r
+       set_ext(&b, a.n);\r
+       p = b.setword;\r
+       do {\r
+               *p++ = *q++;\r
+       } while ( q < endq );\r
+       \r
+       return(b);\r
+}\r
+\r
+/*\r
+ * Return a nil terminated list of unsigned ints that represents all\r
+ * "on" bits in the bit set.\r
+ *\r
+ * e.g. {011011} --> {1, 2, 4, 5, nil}\r
+ *\r
+ * _set_pdq and set_pdq are useful when an operation is required on each element\r
+ * of a set.  Normally, the sequence is:\r
+ *\r
+ *             while ( set_deg(a) > 0 ) {\r
+ *                     e = set_int(a);\r
+ *                     set_rm(e, a);\r
+ *                     ...process e...\r
+ *             }\r
+ * Now,\r
+ *\r
+ *             t = e = set_pdq(a);\r
+ *             while ( *e != nil ) {\r
+ *                     ...process *e...\r
+ *                     e++;\r
+ *             }\r
+ *             free( t );\r
+ *\r
+ * We have saved many set calls and have not destroyed set a.\r
+ */\r
+void\r
+#ifdef __USE_PROTOS\r
+_set_pdq( set a, register unsigned *q )\r
+#else\r
+_set_pdq( a, q )\r
+set a;\r
+register unsigned *q;\r
+#endif\r
+{\r
+       register unsigned *p = a.setword,\r
+                                         *endp = &(a.setword[a.n]);\r
+       register unsigned e=0;\r
+\r
+       CHK(a);\r
+       /* are there any space (possibility of elements)? */\r
+       if ( a.n == 0 ) return;\r
+       do {\r
+               register unsigned t = *p;\r
+               register unsigned *b = &(bitmask[0]);\r
+               do {\r
+                       if ( t & *b ) *q++ = e;\r
+                       ++e;\r
+               } while (++b < &(bitmask[WORDSIZE]));\r
+       } while (++p < endp);\r
+       *q = nil;\r
+}\r
+\r
+/*\r
+ * Same as _set_pdq except allocate memory.  set_pdq is the natural function\r
+ * to use.\r
+ */\r
+unsigned *\r
+#ifdef __USE_PROTOS\r
+set_pdq( set a )\r
+#else\r
+set_pdq( a )\r
+set a;\r
+#endif\r
+{\r
+       unsigned *q;\r
+       int max_deg;\r
+       \r
+       CHK(a);\r
+       max_deg = WORDSIZE*a.n;\r
+       /* assume a.n!=0 & no elements is rare, but still ok */\r
+       if ( a.n == 0 ) return(NULL);\r
+       q = (unsigned *) malloc((max_deg+1)*BytesPerWord);\r
+       if ( q == NULL ) return( NULL );\r
+       _set_pdq(a, q);\r
+       return( q );\r
+}\r
+\r
+/* a function that produces a hash number for the set\r
+ */\r
+unsigned int\r
+#ifdef __USE_PROTOS\r
+set_hash( set a, register unsigned int mod )\r
+#else\r
+set_hash( a, mod )\r
+set a;\r
+register unsigned int mod;\r
+#endif\r
+{\r
+       /* Fast hash of set a (assumes all bits used) */\r
+       register unsigned *p = &(a.setword[0]);\r
+       register unsigned *endp = &(a.setword[a.n]);\r
+       register unsigned i = 0;\r
+\r
+       CHK(a);\r
+       while (p<endp){\r
+               i += (*p);\r
+               ++p;\r
+       }\r
+\r
+       return(i % mod);\r
+}\r
diff --git a/Tools/CodeTools/Source/Pccts/support/set/set.h b/Tools/CodeTools/Source/Pccts/support/set/set.h
new file mode 100644 (file)
index 0000000..5d68152
--- /dev/null
@@ -0,0 +1,121 @@
+#ifndef __GATE_SET_H\r
+#define __GATE_SET_H\r
+\r
+/*     set.h\r
+\r
+       The following is a general-purpose set library originally developed\r
+       by Hank Dietz and enhanced by Terence Parr to allow dynamic sets.\r
+       \r
+       Sets are now structs containing the #words in the set and\r
+       a pointer to the actual set words.\r
+\r
+       1987 by Hank Dietz\r
+       \r
+       Modified by:\r
+               Terence Parr\r
+               Purdue University\r
+               October 1989\r
+\r
+               Added ANSI prototyping Dec. 1992 -- TJP\r
+*/\r
+\r
+#include "pcctscfg.h"\r
+\r
+#ifdef NOT_USED /* SEE config.h */\r
+/* Define usable bits per unsigned int word */\r
+#ifdef PC\r
+#define WORDSIZE 16\r
+#define LogWordSize    4\r
+#else\r
+#define        WORDSIZE 32\r
+#define LogWordSize 5\r
+#endif\r
+#define BytesPerWord   sizeof(unsigned)\r
+#endif\r
+\r
+#define        SETSIZE(a) ((a).n<<LogWordSize)         /* Maximum items per set */\r
+#define        MODWORD(x) ((x) & (WORDSIZE-1))         /* x % WORDSIZE */\r
+#define        DIVWORD(x) ((x) >> LogWordSize)         /* x / WORDSIZE */\r
+#define        nil     (~((unsigned) 0))       /* An impossible set member all bits on (big!) */\r
+\r
+typedef struct _set {\r
+                       unsigned int n;         /* Number of words in set */\r
+                       unsigned *setword;\r
+               } set;\r
+\r
+#define set_init       {0, NULL}\r
+#define set_null(a)    ((a).setword==NULL)\r
+\r
+#define        NumBytes(x)             (((x)>>3)+1)                                            /* Num bytes to hold x */\r
+#define        NumWords(x)             ((((unsigned)(x))>>LogWordSize)+1)      /* Num words to hold x */\r
+\r
+\r
+/* M a c r o s */\r
+\r
+/* make arg1 a set big enough to hold max elem # of arg2 */\r
+#define set_new(a,_max) \\r
+if (((a).setword=(unsigned *)calloc(NumWords(_max),BytesPerWord))==NULL) \\r
+        fprintf(stderr, "set_new: Cannot allocate set with max of %d\n", _max); \\r
+        (a).n = NumWords(_max);\r
+\r
+#define set_free(a)                                                                    \\r
+       {if ( (a).setword != NULL ) free((char *)((a).setword));        \\r
+       (a) = empty;}\r
+\r
+#ifdef __USE_PROTOS\r
+extern void set_size( unsigned );\r
+extern unsigned int set_deg( set );\r
+extern set set_or( set, set );\r
+extern set set_and( set, set );\r
+extern set set_dif( set, set );\r
+extern set set_of( unsigned );\r
+extern void set_ext( set *, unsigned int );\r
+extern set set_not( set );\r
+extern int set_equ( set, set );\r
+extern int set_sub( set, set );\r
+extern unsigned set_int( set );\r
+extern int set_el( unsigned, set );\r
+extern int set_nil( set );\r
+extern char * set_str( set );\r
+extern set set_val( register char * );\r
+extern void set_orel( unsigned, set * );\r
+extern void set_orin( set *, set );\r
+extern void set_andin( set *, set );\r
+extern void set_rm( unsigned, set );\r
+extern void set_clr( set );\r
+extern set set_dup( set );\r
+extern void set_PDQ( set, register unsigned * );\r
+extern unsigned *set_pdq( set );\r
+extern void _set_pdq( set a, register unsigned *q );\r
+extern unsigned int set_hash( set, register unsigned int );\r
+#else\r
+extern void set_size();\r
+extern unsigned int set_deg();\r
+extern set set_or();\r
+extern set set_and();\r
+extern set set_dif();\r
+extern set set_of();\r
+extern void set_ext();\r
+extern set set_not();\r
+extern int set_equ();\r
+extern int set_sub();\r
+extern unsigned set_int();\r
+extern int set_el();\r
+extern int set_nil();\r
+extern char * set_str();\r
+extern set set_val();\r
+extern void set_orel();\r
+extern void set_orin();\r
+extern void set_andin();\r
+extern void set_rm();\r
+extern void set_clr();\r
+extern set set_dup();\r
+extern void set_PDQ();\r
+extern unsigned *set_pdq();\r
+extern void _set_pdq();\r
+extern unsigned int set_hash();\r
+#endif\r
+\r
+extern set empty;\r
+\r
+#endif\r
diff --git a/Tools/CodeTools/Source/Pccts/support/sym/sym.c b/Tools/CodeTools/Source/Pccts/support/sym/sym.c
new file mode 100644 (file)
index 0000000..eccce05
--- /dev/null
@@ -0,0 +1,402 @@
+/*\r
+ * Simple symbol table manager using coalesced chaining to resolve collisions\r
+ *\r
+ * Doubly-linked lists are used for fast removal of entries.\r
+ *\r
+ * 'sym.h' must have a definition for typedef "Sym".  Sym must include at\r
+ * minimum the following fields:\r
+ *\r
+ *             ...\r
+ *             char *symbol;\r
+ *             struct ... *next, *prev, **head, *scope;\r
+ *             unsigned int hash;\r
+ *             ...\r
+ *\r
+ * 'template.h' can be used as a template to create a 'sym.h'.\r
+ *\r
+ * 'head' is &(table[hash(itself)]).\r
+ * The hash table is not resizable at run-time.\r
+ * The scope field is used to link all symbols of a current scope together.\r
+ * Scope() sets the current scope (linked list) to add symbols to.\r
+ * Any number of scopes can be handled.  The user passes the address of\r
+ * a pointer to a symbol table\r
+ * entry (INITIALIZED TO NULL first time).\r
+ *\r
+ * Available Functions:\r
+ *\r
+ *     zzs_init(s1,s2) --      Create hash table with size s1, string table size s2.\r
+ *     zzs_done()              --      Free hash and string table created with zzs_init().\r
+ *     zzs_add(key,rec)--      Add 'rec' with key 'key' to the symbol table.\r
+ *     zzs_newadd(key) --      create entry; add using 'key' to the symbol table.\r
+ *     zzs_get(key)    --      Return pointer to last record entered under 'key'\r
+ *                                             Else return NULL\r
+ *     zzs_del(p)              --      Unlink the entry associated with p.  This does\r
+ *                                             NOT free 'p' and DOES NOT remove it from a scope\r
+ *                                             list.  If it was a part of your intermediate code\r
+ *                                             tree or another structure.  It will still be there.\r
+ *                                             It is only removed from further consideration\r
+ *                                             by the symbol table.\r
+ *     zzs_keydel(s)   --      Unlink the entry associated with key s.\r
+ *                                             Calls zzs_del(p) to unlink.\r
+ *     zzs_scope(sc)   --      Specifies that everything added to the symbol\r
+ *                                             table with zzs_add() is added to the list (scope)\r
+ *                                             'sc'.  'sc' is of 'Sym **sc' type and must be\r
+ *                                             initialized to NULL before trying to add anything\r
+ *                                             to it (passing it to zzs_scope()).  Scopes can be\r
+ *                                         switched at any time and merely links a set of\r
+ *                                             symbol table entries.  If a NULL pointer is\r
+ *                                             passed, the current scope is returned.\r
+ *     zzs_rmscope(sc) --      Remove (zzs_del()) all elements of scope 'sc'\r
+ *                                             from the symbol table.  The entries are NOT\r
+ *                                             free()'d.  A pointer to the first\r
+ *                                             element in the "scope" is returned.  The user\r
+ *                                             can then manipulate the list as he/she chooses\r
+ *                                             (such as freeing them all). NOTE that this\r
+ *                                             function sets your scope pointer to NULL,\r
+ *                                             but returns a pointer to the list for you to use.\r
+ *     zzs_stat()              --      Print out the symbol table and some relevant stats.\r
+ *     zzs_new(key)    --      Create a new record with calloc() of type Sym.\r
+ *                                             Add 'key' to the string table and make the new\r
+ *                                             records 'symbol' pointer point to it.\r
+ *     zzs_strdup(s)   --      Add s to the string table and return a pointer\r
+ *                                             to it.  Very fast allocation routine\r
+ *                                             and does not require strlen() nor calloc().\r
+ *\r
+ * Example:\r
+ *\r
+ *     #include <stdio.h>\r
+ *     #include "sym.h"\r
+ *\r
+ *     main()\r
+ *     {\r
+ *         Sym *scope1=NULL, *scope2=NULL, *a, *p;\r
+ *     \r
+ *         zzs_init(101, 100);\r
+ *     \r
+ *         a = zzs_new("Apple");       zzs_add(a->symbol, a);  -- No scope\r
+ *         zzs_scope( &scope1 );       -- enter scope 1\r
+ *         a = zzs_new("Plum");        zzs_add(a->symbol, a);\r
+ *         zzs_scope( &scope2 );       -- enter scope 2\r
+ *         a = zzs_new("Truck");       zzs_add(a->symbol, a);\r
+ *     \r
+ *     p = zzs_get("Plum");\r
+ *     if ( p == NULL ) fprintf(stderr, "Hmmm...Can't find 'Plum'\n");\r
+ *     \r
+ *     p = zzs_rmscope(&scope1)\r
+ *     for (; p!=NULL; p=p->scope) {printf("Scope1:  %s\n", p->symbol);}\r
+ *     p = zzs_rmscope(&scope2)\r
+ *     for (; p!=NULL; p=p->scope) {printf("Scope2:  %s\n", p->symbol);}\r
+ * }\r
+ *\r
+ * Terence Parr\r
+ * Purdue University\r
+ * February 1990\r
+ *\r
+ * CHANGES\r
+ *\r
+ *     Terence Parr\r
+ *     May 1991\r
+ *             Renamed functions to be consistent with ANTLR\r
+ *             Made HASH macro\r
+ *             Added zzs_keydel()\r
+ *             Added zzs_newadd()\r
+ *             Fixed up zzs_stat()\r
+ *\r
+ *     July 1991\r
+ *             Made symbol table entry save its hash code for fast comparison\r
+ *                     during searching etc...\r
+ */\r
+\r
+#include <stdio.h>\r
+#if defined(__STDC__) || defined(__USE_PROTOS)\r
+#include <string.h>\r
+#include <stdlib.h>\r
+#else\r
+#include <malloc.h>\r
+#endif\r
+#include "sym.h"\r
+\r
+#define StrSame                0\r
+\r
+static Sym **CurScope = NULL;\r
+static unsigned size = 0;\r
+static Sym **table=NULL;\r
+static char *strings;\r
+static char *strp;\r
+static int strsize = 0;\r
+\r
+#ifdef __USE_PROTOS\r
+void zzs_init(int sz,int strs)\r
+#else\r
+void zzs_init(sz, strs)\r
+int sz, strs;\r
+#endif\r
+{\r
+       if ( sz <= 0 || strs <= 0 ) return;\r
+       table = (Sym **) calloc(sz, sizeof(Sym *));\r
+       if ( table == NULL )\r
+       {\r
+               fprintf(stderr, "Cannot allocate table of size %d\n", sz);\r
+               exit(1);\r
+       }\r
+       strings = (char *) calloc(strs, sizeof(char));\r
+       if ( strings == NULL )\r
+       {\r
+               fprintf(stderr, "Cannot allocate string table of size %d\n", strs);\r
+               exit(1);\r
+       }\r
+       size = sz;\r
+       strsize = strs;\r
+       strp = strings;\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+void zzs_done(void)\r
+#else\r
+void zzs_done()\r
+#endif\r
+{\r
+       if ( table != NULL ) free( table );\r
+       if ( strings != NULL ) free( strings );\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+void zzs_add(char *key,Sym rec)\r
+#else\r
+void zzs_add(key, rec)\r
+char *key;\r
+register Sym *rec;\r
+#endif\r
+{\r
+       register unsigned int h=0;\r
+       register char *p=key;\r
+       \r
+       HASH(p, h);\r
+       rec->hash = h;                                  /* save hash code for fast comp later */\r
+       h %= size;\r
+       \r
+       if ( CurScope != NULL ) {rec->scope = *CurScope; *CurScope = rec;}\r
+       rec->next = table[h];                   /* Add to doubly-linked list */\r
+       rec->prev = NULL;\r
+       if ( rec->next != NULL ) (rec->next)->prev = rec;\r
+       table[h] = rec;\r
+       rec->head = &(table[h]);\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+Sym * zzs_get(char *key)\r
+#else\r
+Sym * zzs_get(key)\r
+char *key;\r
+#endif\r
+{\r
+       register unsigned int h=0;\r
+       register char *p=key;\r
+       register Sym *q;\r
+       \r
+       HASH(p, h);\r
+       \r
+       for (q = table[h%size]; q != NULL; q = q->next)\r
+       {\r
+               if ( q->hash == h )             /* do we even have a chance of matching? */\r
+                       if ( strcmp(key, q->symbol) == StrSame ) return( q );\r
+       }\r
+       return( NULL );\r
+}\r
+\r
+/*\r
+ * Unlink p from the symbol table.  Hopefully, it's actually in the\r
+ * symbol table.\r
+ *\r
+ * If p is not part of a bucket chain of the symbol table, bad things\r
+ * will happen.\r
+ *\r
+ * Will do nothing if all list pointers are NULL\r
+ */\r
+#ifdef __USE_PROTOS\r
+void zzs_del(Sym *p)\r
+#else\r
+void zzs_del(p)\r
+register Sym *p;\r
+#endif\r
+{\r
+       if ( p == NULL ) {fprintf(stderr, "zzs_del(NULL)\n"); exit(1);}\r
+       if ( p->prev == NULL )  /* Head of list */\r
+       {\r
+               register Sym **t = p->head;\r
+               \r
+               if ( t == NULL ) return;        /* not part of symbol table */\r
+               (*t) = p->next;\r
+               if ( (*t) != NULL ) (*t)->prev = NULL;\r
+       }\r
+       else\r
+       {\r
+               (p->prev)->next = p->next;\r
+               if ( p->next != NULL ) (p->next)->prev = p->prev;\r
+       }\r
+       p->next = p->prev = NULL;       /* not part of symbol table anymore */\r
+       p->head = NULL;\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+void zzs_keydel(char *key)\r
+#else\r
+void zzs_keydel(key)\r
+char *key;\r
+#endif\r
+{\r
+       Sym *p = zzs_get(key);\r
+\r
+       if ( p != NULL ) zzs_del( p );\r
+}\r
+\r
+/* S c o p e  S t u f f */\r
+\r
+/* Set current scope to 'scope'; return current scope if 'scope' == NULL */\r
+\r
+#ifdef __USE_PROTOS\r
+Sym ** zzs_scope(Sym **scope)\r
+#else\r
+Sym ** zzs_scope(scope)\r
+Sym **scope;\r
+#endif\r
+{\r
+       if ( scope == NULL ) return( CurScope );\r
+       CurScope = scope;\r
+       return( scope );\r
+}\r
+\r
+/* Remove a scope described by 'scope'.  Return pointer to 1st element in scope */\r
+\r
+#ifdef __USE_PROTOS\r
+Sym * zzs_rmscope(Sym **scope)\r
+#else\r
+Sym * zzs_rmscope(scope)\r
+register Sym **scope;\r
+#endif\r
+{\r
+       register Sym *p;\r
+       Sym *start;\r
+\r
+       if ( scope == NULL ) return(NULL);\r
+       start = p = *scope;\r
+       for (; p != NULL; p=p->scope) { zzs_del( p ); }\r
+       *scope = NULL;\r
+       return( start );\r
+}\r
+\r
+#ifdef __USE_PROTOS\r
+void zzs_stat(void)\r
+#else\r
+void zzs_stat()\r
+#endif\r
+{\r
+       static unsigned short count[20];\r
+       unsigned int i,n=0,low=0, hi=0;\r
+       register Sym **p;\r
+       float avg=0.0;\r
+       \r
+       for (i=0; i<20; i++) count[i] = 0;\r
+       for (p=table; p<&(table[size]); p++)\r
+       {\r
+               register Sym *q = *p;\r
+               unsigned int len;\r
+               \r
+               if ( q != NULL && low==0 ) low = p-table;\r
+               len = 0;\r
+               if ( q != NULL ) printf("[%d]", p-table);\r
+               while ( q != NULL )\r
+               {\r
+                       len++;\r
+                       n++;\r
+                       printf(" %s", q->symbol);\r
+                       q = q->next;\r
+                       if ( q == NULL ) printf("\n");\r
+               }\r
+               if ( len>=20 ) printf("zzs_stat: count table too small\n");\r
+               else count[len]++;\r
+               if ( *p != NULL ) hi = p-table;\r
+       }\r
+\r
+       printf("Storing %d recs used %d hash positions out of %d\n",\r
+                       n, size-count[0], size);\r
+       printf("%f %% utilization\n",\r
+                       ((float)(size-count[0]))/((float)size));\r
+       for (i=0; i<20; i++)\r
+       {\r
+               if ( count[i] != 0 )\r
+               {\r
+                       avg += (((float)(i*count[i]))/((float)n)) * i;\r
+                       printf("Buckets of len %d == %d (%f %% of recs)\n",\r
+                                       i, count[i], 100.0*((float)(i*count[i]))/((float)n));\r
+               }\r
+       }\r
+       printf("Avg bucket length %f\n", avg);\r
+       printf("Range of hash function: %d..%d\n", low, hi);\r
+}\r
+\r
+/*\r
+ * Given a string, this function allocates and returns a pointer to a\r
+ * symbol table record whose "symbol" pointer is reset to a position\r
+ * in the string table.\r
+ */\r
+\r
+#ifdef __USE_PROTOS\r
+Sym * zzs_new(char *text)\r
+#else\r
+Sym * zzs_new(text)\r
+char *text;\r
+#endif\r
+{\r
+       Sym *p;\r
+       \r
+       if ( (p = (Sym *) calloc(1,sizeof(Sym))) == 0 )\r
+       {\r
+               fprintf(stderr,"Out of memory\n");\r
+               exit(1);\r
+       }\r
+       p->symbol = zzs_strdup(text);\r
+       \r
+       return p;\r
+}\r
+\r
+/* create a new symbol table entry and add it to the symbol table */\r
+\r
+#ifdef __USE_PROTOS\r
+Sym * zzs_newadd(char *text)\r
+#else\r
+Sym * zzs_newadd(text)\r
+char *text;\r
+#endif\r
+{\r
+       Sym *p = zzs_new(text);\r
+       if ( p != NULL ) zzs_add(text, p);\r
+       return p;\r
+}\r
+\r
+/* Add a string to the string table and return a pointer to it.\r
+ * Bump the pointer into the string table to next avail position.\r
+ */\r
+\r
+#ifdef __USE_PROTOS\r
+char * zzs_strdup(char *s)\r
+#else\r
+char * zzs_strdup(s)\r
+register char *s;\r
+#endif\r
+{\r
+       register char *start=strp;\r
+\r
+       while ( *s != '\0' )\r
+       {\r
+               if ( strp >= &(strings[strsize-2]) )\r
+               {\r
+                       fprintf(stderr, "sym: string table overflow (%d chars)\n", strsize);\r
+                       exit(-1);\r
+               }\r
+               *strp++ = *s++;\r
+       }\r
+       *strp++ = '\0';\r
+\r
+       return( start );\r
+}\r
diff --git a/Tools/CodeTools/Source/Pccts/support/sym/template.h b/Tools/CodeTools/Source/Pccts/support/sym/template.h
new file mode 100644 (file)
index 0000000..ee6e665
--- /dev/null
@@ -0,0 +1,41 @@
+/* T e m p l a t e  F o r  S y m b o l  T a b l e  M a n a g e r */\r
+\r
+/* define some hash function */\r
+#ifndef HASH\r
+#define HASH(p, h) while ( *p != '\0' ) h = (h<<1) + *p++;\r
+#endif\r
+\r
+/* minimum symbol table record */\r
+typedef struct _sym {\r
+                       char *symbol;\r
+                       struct _sym *next, *prev, **head, *scope;\r
+                       unsigned int hash;\r
+               } Sym, *SymPtr;\r
+\r
+#ifdef __USE_PROTOS\r
+void zzs_init(int, int);\r
+void zzs_done(void);\r
+void zzs_add(char *, Sym *);\r
+Sym *zzs_get(char *);\r
+void zzs_del(Sym *);\r
+void zzs_keydel(char *);\r
+Sym **zzs_scope(Sym **);\r
+Sym *zzs_rmscope(Sym **);\r
+void zzs_stat(void);\r
+Sym *zzs_new(char *);\r
+Sym *zzs_newadd(char *);\r
+char *zzs_strdup(char *);\r
+#else\r
+void zzs_init();\r
+void zzs_done();\r
+void zzs_add();\r
+Sym *zzs_get();\r
+void zzs_del();\r
+void zzs_keydel();\r
+Sym **zzs_scope();\r
+Sym *zzs_rmscope();\r
+void zzs_stat();\r
+Sym *zzs_new();\r
+Sym *zzs_newadd();\r
+char *zzs_strdup();\r
+#endif\r
diff --git a/Tools/CodeTools/Source/PeCoffLoader/BasePeCoff.c b/Tools/CodeTools/Source/PeCoffLoader/BasePeCoff.c
new file mode 100644 (file)
index 0000000..9c25e1f
--- /dev/null
@@ -0,0 +1,1060 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2005, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  PeCoffLoader.c\r
+\r
+Abstract:\r
+\r
+  Tiano PE/COFF loader \r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+\r
+#include <Common/UefiBaseTypes.h>\r
+#include <Common/EfiImage.h>\r
+#include <Library/PeCoffLib.h>\r
+\r
+STATIC\r
+RETURN_STATUS\r
+PeCoffLoaderGetPeHeader (\r
+  IN OUT PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext,\r
+  OUT    EFI_IMAGE_NT_HEADERS          *PeHdr,\r
+  OUT    EFI_TE_IMAGE_HEADER           *TeHdr\r
+  );\r
+\r
+STATIC\r
+RETURN_STATUS\r
+PeCoffLoaderCheckImageType (\r
+  IN OUT PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext,\r
+  IN     EFI_IMAGE_NT_HEADERS          *PeHdr,\r
+  IN     EFI_TE_IMAGE_HEADER           *TeHdr\r
+  );\r
+\r
+STATIC\r
+VOID                            *\r
+PeCoffLoaderImageAddress (\r
+  IN OUT PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext,\r
+  IN     UINTN                         Address\r
+  );\r
+\r
+\r
+STATIC\r
+RETURN_STATUS\r
+PeCoffLoaderGetPeHeader (\r
+  IN OUT PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext,\r
+  OUT    EFI_IMAGE_NT_HEADERS          *PeHdr,\r
+  OUT    EFI_TE_IMAGE_HEADER           *TeHdr\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Retrieves the PE or TE Header from a PE/COFF or TE image\r
+\r
+Arguments:\r
+\r
+  ImageContext  - The context of the image being loaded\r
+\r
+  PeHdr         - The buffer in which to return the PE header\r
+  \r
+  TeHdr         - The buffer in which to return the TE header\r
+\r
+Returns:\r
+\r
+  RETURN_SUCCESS if the PE or TE Header is read, \r
+  Otherwise, the error status from reading the PE/COFF or TE image using the ImageRead function.\r
+\r
+--*/\r
+{\r
+  RETURN_STATUS            Status;\r
+  EFI_IMAGE_DOS_HEADER  DosHdr;\r
+  UINTN                 Size;\r
+\r
+  ImageContext->IsTeImage = FALSE;\r
+  //\r
+  // Read the DOS image headers\r
+  //\r
+  Size = sizeof (EFI_IMAGE_DOS_HEADER);\r
+  Status = ImageContext->ImageRead (\r
+                          ImageContext->Handle,\r
+                          0,\r
+                          &Size,\r
+                          &DosHdr\r
+                          );\r
+  if (RETURN_ERROR (Status)) {\r
+    ImageContext->ImageError = IMAGE_ERROR_IMAGE_READ;\r
+    return Status;\r
+  }\r
+\r
+  ImageContext->PeCoffHeaderOffset = 0;\r
+  if (DosHdr.e_magic == EFI_IMAGE_DOS_SIGNATURE) {\r
+    //\r
+    // DOS image header is present, so read the PE header after the DOS image header\r
+    //\r
+    ImageContext->PeCoffHeaderOffset = DosHdr.e_lfanew;\r
+  }\r
+  //\r
+  // Read the PE/COFF Header\r
+  //\r
+  Size = sizeof (EFI_IMAGE_NT_HEADERS);\r
+  Status = ImageContext->ImageRead (\r
+                          ImageContext->Handle,\r
+                          ImageContext->PeCoffHeaderOffset,\r
+                          &Size,\r
+                          PeHdr\r
+                          );\r
+  if (RETURN_ERROR (Status)) {\r
+    ImageContext->ImageError = IMAGE_ERROR_IMAGE_READ;\r
+    return Status;\r
+  }\r
+  //\r
+  // Check the PE/COFF Header Signature. If not, then try to read a TE header\r
+  //\r
+  if (PeHdr->Signature != EFI_IMAGE_NT_SIGNATURE) {\r
+    Size = sizeof (EFI_TE_IMAGE_HEADER);\r
+    Status = ImageContext->ImageRead (\r
+                            ImageContext->Handle,\r
+                            0,\r
+                            &Size,\r
+                            TeHdr\r
+                            );\r
+    if (TeHdr->Signature != EFI_TE_IMAGE_HEADER_SIGNATURE) {\r
+      return RETURN_UNSUPPORTED;\r
+    }\r
+\r
+    ImageContext->IsTeImage = TRUE;\r
+  }\r
+\r
+  return RETURN_SUCCESS;\r
+}\r
+\r
+STATIC\r
+RETURN_STATUS\r
+PeCoffLoaderCheckImageType (\r
+  IN OUT PE_COFF_LOADER_IMAGE_CONTEXT          *ImageContext,\r
+  IN     EFI_IMAGE_NT_HEADERS                  *PeHdr,\r
+  IN     EFI_TE_IMAGE_HEADER                   *TeHdr\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Checks the PE or TE header of a PE/COFF or TE image to determine if it supported\r
+\r
+Arguments:\r
+\r
+  ImageContext  - The context of the image being loaded\r
+\r
+  PeHdr         - The buffer in which to return the PE header\r
+  \r
+  TeHdr         - The buffer in which to return the TE header\r
+\r
+Returns:\r
+\r
+  RETURN_SUCCESS if the PE/COFF or TE image is supported\r
+  RETURN_UNSUPPORTED of the PE/COFF or TE image is not supported.\r
+\r
+--*/\r
+{\r
+  //\r
+  // See if the machine type is supported.  We support a native machine type (IA-32/Itanium-based)\r
+  // and the machine type for the Virtual Machine.\r
+  //\r
+  if (ImageContext->IsTeImage == FALSE) {\r
+    ImageContext->Machine = PeHdr->FileHeader.Machine;\r
+  } else {\r
+    ImageContext->Machine = TeHdr->Machine;\r
+  }\r
+\r
+  if (!(EFI_IMAGE_MACHINE_TYPE_SUPPORTED (ImageContext->Machine))) {\r
+    ImageContext->ImageError = IMAGE_ERROR_INVALID_MACHINE_TYPE;\r
+    return RETURN_UNSUPPORTED;\r
+  }\r
+\r
+  //\r
+  // See if the image type is supported.  We support EFI Applications,\r
+  // EFI Boot Service Drivers, and EFI Runtime Drivers.\r
+  //\r
+  if (ImageContext->IsTeImage == FALSE) {\r
+    ImageContext->ImageType = PeHdr->OptionalHeader.Subsystem;\r
+  } else {\r
+    ImageContext->ImageType = (UINT16) (TeHdr->Subsystem);\r
+  }\r
+\r
+\r
+  return RETURN_SUCCESS;\r
+}\r
+\r
+RETURN_STATUS\r
+EFIAPI\r
+PeCoffLoaderGetImageInfo (\r
+  IN OUT PE_COFF_LOADER_IMAGE_CONTEXT           *ImageContext\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Retrieves information on a PE/COFF image\r
+\r
+Arguments:\r
+\r
+  This         - Calling context\r
+  ImageContext - The context of the image being loaded\r
+\r
+Returns:\r
+\r
+  RETURN_SUCCESS           - The information on the PE/COFF image was collected.\r
+  RETURN_INVALID_PARAMETER - ImageContext is NULL.\r
+  RETURN_UNSUPPORTED       - The PE/COFF image is not supported.\r
+  Otherwise             - The error status from reading the PE/COFF image using the\r
+                          ImageContext->ImageRead() function\r
+\r
+--*/\r
+{\r
+  RETURN_STATUS                      Status;\r
+  EFI_IMAGE_NT_HEADERS            PeHdr;\r
+  EFI_TE_IMAGE_HEADER             TeHdr;\r
+  EFI_IMAGE_DATA_DIRECTORY        *DebugDirectoryEntry;\r
+  UINTN                           Size;\r
+  UINTN                           Index;\r
+  UINTN                           DebugDirectoryEntryRva;\r
+  UINTN                           DebugDirectoryEntryFileOffset;\r
+  UINTN                           SectionHeaderOffset;\r
+  EFI_IMAGE_SECTION_HEADER        SectionHeader;\r
+  EFI_IMAGE_DEBUG_DIRECTORY_ENTRY DebugEntry;\r
+\r
+  if (NULL == ImageContext) {\r
+    return RETURN_INVALID_PARAMETER;\r
+  }\r
+  //\r
+  // Assume success\r
+  //\r
+  ImageContext->ImageError  = IMAGE_ERROR_SUCCESS;\r
+\r
+  Status                    = PeCoffLoaderGetPeHeader (ImageContext, &PeHdr, &TeHdr);\r
+  if (RETURN_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+  //\r
+  // Verify machine type\r
+  //\r
+  Status = PeCoffLoaderCheckImageType (ImageContext, &PeHdr, &TeHdr);\r
+  if (RETURN_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+  //\r
+  // Retrieve the base address of the image\r
+  //\r
+  if (!(ImageContext->IsTeImage)) {\r
+    ImageContext->ImageAddress = PeHdr.OptionalHeader.ImageBase;\r
+  } else {\r
+    ImageContext->ImageAddress = (PHYSICAL_ADDRESS) (TeHdr.ImageBase);\r
+  }\r
+  //\r
+  // Initialize the alternate destination address to 0 indicating that it\r
+  // should not be used.\r
+  //\r
+  ImageContext->DestinationAddress = 0;\r
+\r
+  //\r
+  // Initialize the codeview pointer.\r
+  //\r
+  ImageContext->CodeView    = NULL;\r
+  ImageContext->PdbPointer  = NULL;\r
+\r
+  //\r
+  // Three cases with regards to relocations:\r
+  // - Image has base relocs, RELOCS_STRIPPED==0    => image is relocatable\r
+  // - Image has no base relocs, RELOCS_STRIPPED==1 => Image is not relocatable\r
+  // - Image has no base relocs, RELOCS_STRIPPED==0 => Image is relocatable but\r
+  //   has no base relocs to apply\r
+  // Obviously having base relocations with RELOCS_STRIPPED==1 is invalid.\r
+  //\r
+  // Look at the file header to determine if relocations have been stripped, and\r
+  // save this info in the image context for later use.\r
+  //\r
+  if ((!(ImageContext->IsTeImage)) && ((PeHdr.FileHeader.Characteristics & EFI_IMAGE_FILE_RELOCS_STRIPPED) != 0)) {\r
+    ImageContext->RelocationsStripped = TRUE;\r
+  } else {\r
+    ImageContext->RelocationsStripped = FALSE;\r
+  }\r
+\r
+  if (!(ImageContext->IsTeImage)) {\r
+    ImageContext->ImageSize         = (UINT64) PeHdr.OptionalHeader.SizeOfImage;\r
+    ImageContext->SectionAlignment  = PeHdr.OptionalHeader.SectionAlignment;\r
+    ImageContext->SizeOfHeaders     = PeHdr.OptionalHeader.SizeOfHeaders;\r
+\r
+    //\r
+    // Modify ImageSize to contain .PDB file name if required and initialize\r
+    // PdbRVA field...\r
+    //\r
+    if (PeHdr.OptionalHeader.NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_DEBUG) {\r
+      DebugDirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *) &(PeHdr.OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG]);\r
+\r
+      DebugDirectoryEntryRva = DebugDirectoryEntry->VirtualAddress;\r
+\r
+      //\r
+      // Determine the file offset of the debug directory...  This means we walk\r
+      // the sections to find which section contains the RVA of the debug\r
+      // directory\r
+      //\r
+      DebugDirectoryEntryFileOffset = 0;\r
+\r
+      SectionHeaderOffset = (UINTN)(\r
+                               ImageContext->PeCoffHeaderOffset +\r
+                               sizeof (UINT32) + \r
+                               sizeof (EFI_IMAGE_FILE_HEADER) + \r
+                               PeHdr.FileHeader.SizeOfOptionalHeader\r
+                               );\r
+\r
+      for (Index = 0; Index < PeHdr.FileHeader.NumberOfSections; Index++) {\r
+        //\r
+        // Read section header from file\r
+        //\r
+        Size = sizeof (EFI_IMAGE_SECTION_HEADER);\r
+        Status = ImageContext->ImageRead (\r
+                                 ImageContext->Handle,\r
+                                 SectionHeaderOffset,\r
+                                 &Size,\r
+                                 &SectionHeader\r
+                                 );\r
+        if (RETURN_ERROR (Status)) {\r
+          ImageContext->ImageError = IMAGE_ERROR_IMAGE_READ;\r
+          return Status;\r
+        }\r
+\r
+        if (DebugDirectoryEntryRva >= SectionHeader.VirtualAddress &&\r
+            DebugDirectoryEntryRva < SectionHeader.VirtualAddress + SectionHeader.Misc.VirtualSize) {\r
+            DebugDirectoryEntryFileOffset =\r
+            DebugDirectoryEntryRva - SectionHeader.VirtualAddress + SectionHeader.PointerToRawData;\r
+          break;\r
+        }\r
+\r
+        SectionHeaderOffset += sizeof (EFI_IMAGE_SECTION_HEADER);\r
+      }\r
+\r
+      if (DebugDirectoryEntryFileOffset != 0) {\r
+        for (Index = 0; Index < DebugDirectoryEntry->Size; Index++) {\r
+          //\r
+          // Read next debug directory entry\r
+          //\r
+          Size = sizeof (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY);\r
+          Status = ImageContext->ImageRead (\r
+                                   ImageContext->Handle,\r
+                                   DebugDirectoryEntryFileOffset,\r
+                                   &Size,\r
+                                   &DebugEntry\r
+                                   );\r
+          if (RETURN_ERROR (Status)) {\r
+            ImageContext->ImageError = IMAGE_ERROR_IMAGE_READ;\r
+            return Status;\r
+          }\r
+\r
+          if (DebugEntry.Type == EFI_IMAGE_DEBUG_TYPE_CODEVIEW) {\r
+            ImageContext->DebugDirectoryEntryRva = (UINT32) (DebugDirectoryEntryRva + Index * sizeof (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY));\r
+            if (DebugEntry.RVA == 0 && DebugEntry.FileOffset != 0) {\r
+              ImageContext->ImageSize += DebugEntry.SizeOfData;\r
+            }\r
+\r
+            return RETURN_SUCCESS;\r
+          }\r
+        }\r
+      }\r
+    }\r
+  } else {\r
+    ImageContext->ImageSize         = 0;\r
+    ImageContext->SectionAlignment  = 4096;\r
+    ImageContext->SizeOfHeaders     = sizeof (EFI_TE_IMAGE_HEADER) + (UINTN) TeHdr.BaseOfCode - (UINTN) TeHdr.StrippedSize;\r
+\r
+    DebugDirectoryEntry             = &TeHdr.DataDirectory[1];\r
+    DebugDirectoryEntryRva          = DebugDirectoryEntry->VirtualAddress;\r
+    SectionHeaderOffset             = (UINTN) (sizeof (EFI_TE_IMAGE_HEADER));\r
+\r
+    DebugDirectoryEntryFileOffset   = 0;\r
+\r
+    for (Index = 0; Index < TeHdr.NumberOfSections;) {\r
+      //\r
+      // Read section header from file\r
+      //\r
+      Size = sizeof (EFI_IMAGE_SECTION_HEADER);\r
+      Status = ImageContext->ImageRead (\r
+                               ImageContext->Handle,\r
+                               SectionHeaderOffset,\r
+                               &Size,\r
+                               &SectionHeader\r
+                               );\r
+      if (RETURN_ERROR (Status)) {\r
+        ImageContext->ImageError = IMAGE_ERROR_IMAGE_READ;\r
+        return Status;\r
+      }\r
+\r
+      if (DebugDirectoryEntryRva >= SectionHeader.VirtualAddress &&\r
+          DebugDirectoryEntryRva < SectionHeader.VirtualAddress + SectionHeader.Misc.VirtualSize) {\r
+        DebugDirectoryEntryFileOffset = DebugDirectoryEntryRva -\r
+          SectionHeader.VirtualAddress +\r
+          SectionHeader.PointerToRawData +\r
+          sizeof (EFI_TE_IMAGE_HEADER) -\r
+          TeHdr.StrippedSize;\r
+\r
+        //\r
+        // File offset of the debug directory was found, if this is not the last\r
+        // section, then skip to the last section for calculating the image size.\r
+        //\r
+        if (Index < (UINTN) TeHdr.NumberOfSections - 1) {\r
+          SectionHeaderOffset += (TeHdr.NumberOfSections - 1 - Index) * sizeof (EFI_IMAGE_SECTION_HEADER);\r
+          Index = TeHdr.NumberOfSections - 1;\r
+          continue;\r
+        }\r
+      }\r
+\r
+      //\r
+      // In Te image header there is not a field to describe the ImageSize.\r
+      // Actually, the ImageSize equals the RVA plus the VirtualSize of \r
+      // the last section mapped into memory (Must be rounded up to \r
+      // a mulitple of Section Alignment). Per the PE/COFF specification, the\r
+      // section headers in the Section Table must appear in order of the RVA\r
+      // values for the corresponding sections. So the ImageSize can be determined\r
+      // by the RVA and the VirtualSize of the last section header in the\r
+      // Section Table.\r
+      //\r
+      if ((++Index) == (UINTN) TeHdr.NumberOfSections) {\r
+        ImageContext->ImageSize = (SectionHeader.VirtualAddress + SectionHeader.Misc.VirtualSize +\r
+                                   ImageContext->SectionAlignment - 1) & ~(ImageContext->SectionAlignment - 1);\r
+      }\r
+\r
+      SectionHeaderOffset += sizeof (EFI_IMAGE_SECTION_HEADER);\r
+    }\r
+\r
+    if (DebugDirectoryEntryFileOffset != 0) {\r
+      for (Index = 0; Index < DebugDirectoryEntry->Size; Index++) {\r
+        //\r
+        // Read next debug directory entry\r
+        //\r
+        Size = sizeof (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY);\r
+        Status = ImageContext->ImageRead (\r
+                                 ImageContext->Handle,\r
+                                 DebugDirectoryEntryFileOffset,\r
+                                 &Size,\r
+                                 &DebugEntry\r
+                                 );\r
+        if (RETURN_ERROR (Status)) {\r
+          ImageContext->ImageError = IMAGE_ERROR_IMAGE_READ;\r
+          return Status;\r
+        }\r
+\r
+        if (DebugEntry.Type == EFI_IMAGE_DEBUG_TYPE_CODEVIEW) {\r
+          ImageContext->DebugDirectoryEntryRva = (UINT32) (DebugDirectoryEntryRva + Index * sizeof (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY));\r
+          return RETURN_SUCCESS;\r
+        }\r
+      }\r
+    }\r
+  }\r
+\r
+  return RETURN_SUCCESS;\r
+}\r
+\r
+STATIC\r
+VOID *\r
+PeCoffLoaderImageAddress (\r
+  IN OUT PE_COFF_LOADER_IMAGE_CONTEXT          *ImageContext,\r
+  IN     UINTN                                 Address\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Converts an image address to the loaded address\r
+\r
+Arguments:\r
+\r
+  ImageContext  - The context of the image being loaded\r
+\r
+  Address       - The address to be converted to the loaded address\r
+\r
+Returns:\r
+\r
+  NULL if the address can not be converted, otherwise, the converted address\r
+\r
+--*/\r
+{\r
+  if (Address >= ImageContext->ImageSize) {\r
+    ImageContext->ImageError = IMAGE_ERROR_INVALID_IMAGE_ADDRESS;\r
+    return NULL;\r
+  }\r
+\r
+  return (CHAR8 *) ((UINTN) ImageContext->ImageAddress + Address);\r
+}\r
+\r
+RETURN_STATUS\r
+EFIAPI\r
+PeCoffLoaderRelocateImage (\r
+  IN OUT PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Relocates a PE/COFF image in memory\r
+\r
+Arguments:\r
+\r
+  This         - Calling context\r
+\r
+  ImageContext - Contains information on the loaded image to relocate\r
+\r
+Returns:\r
+\r
+  RETURN_SUCCESS      if the PE/COFF image was relocated\r
+  RETURN_LOAD_ERROR   if the image is not a valid PE/COFF image\r
+  RETURN_UNSUPPORTED  not support\r
+\r
+--*/\r
+{\r
+  RETURN_STATUS                Status;\r
+  EFI_IMAGE_NT_HEADERS      *PeHdr;\r
+  EFI_TE_IMAGE_HEADER       *TeHdr;\r
+  EFI_IMAGE_DATA_DIRECTORY  *RelocDir;\r
+  UINT64                    Adjust;\r
+  EFI_IMAGE_BASE_RELOCATION *RelocBase;\r
+  EFI_IMAGE_BASE_RELOCATION *RelocBaseEnd;\r
+  UINT16                    *Reloc;\r
+  UINT16                    *RelocEnd;\r
+  CHAR8                     *Fixup;\r
+  CHAR8                     *FixupBase;\r
+  UINT16                    *F16;\r
+  UINT32                    *F32;\r
+  CHAR8                     *FixupData;\r
+  PHYSICAL_ADDRESS      BaseAddress;\r
+\r
+  PeHdr = NULL;\r
+  TeHdr = NULL;\r
+  //\r
+  // Assume success\r
+  //\r
+  ImageContext->ImageError = IMAGE_ERROR_SUCCESS;\r
+\r
+  //\r
+  // If there are no relocation entries, then we are done\r
+  //\r
+  if (ImageContext->RelocationsStripped) {\r
+    return RETURN_SUCCESS;\r
+  }\r
+\r
+  //\r
+  // If the destination address is not 0, use that rather than the\r
+  // image address as the relocation target.\r
+  //\r
+  if (ImageContext->DestinationAddress) {\r
+    BaseAddress = ImageContext->DestinationAddress;\r
+  } else {\r
+    BaseAddress = ImageContext->ImageAddress;\r
+  }\r
+\r
+  if (!(ImageContext->IsTeImage)) {\r
+    PeHdr = (EFI_IMAGE_NT_HEADERS *)((UINTN)ImageContext->ImageAddress + \r
+                                            ImageContext->PeCoffHeaderOffset);\r
+    Adjust = (UINT64) BaseAddress - PeHdr->OptionalHeader.ImageBase;\r
+    PeHdr->OptionalHeader.ImageBase = (UINTN) BaseAddress;\r
+\r
+    //\r
+    // Find the relocation block\r
+    //\r
+    // Per the PE/COFF spec, you can't assume that a given data directory\r
+    // is present in the image. You have to check the NumberOfRvaAndSizes in\r
+    // the optional header to verify a desired directory entry is there.\r
+    //\r
+    if (PeHdr->OptionalHeader.NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC) {\r
+      RelocDir  = &PeHdr->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC];\r
+      RelocBase = PeCoffLoaderImageAddress (ImageContext, RelocDir->VirtualAddress);\r
+      RelocBaseEnd = PeCoffLoaderImageAddress (\r
+                      ImageContext,\r
+                      RelocDir->VirtualAddress + RelocDir->Size - 1\r
+                      );\r
+    } else {\r
+      //\r
+      // Set base and end to bypass processing below.\r
+      //\r
+      RelocBase = RelocBaseEnd = 0;\r
+    }\r
+  } else {\r
+    TeHdr             = (EFI_TE_IMAGE_HEADER *) (UINTN) (ImageContext->ImageAddress);\r
+    Adjust            = (UINT64) (BaseAddress - TeHdr->ImageBase);\r
+    TeHdr->ImageBase  = (UINT64) (BaseAddress);\r
+\r
+    //\r
+    // Find the relocation block\r
+    //\r
+    RelocDir = &TeHdr->DataDirectory[0];\r
+    RelocBase = (EFI_IMAGE_BASE_RELOCATION *)(UINTN)(\r
+                                    ImageContext->ImageAddress + \r
+                                    RelocDir->VirtualAddress +\r
+                                    sizeof(EFI_TE_IMAGE_HEADER) - \r
+                                    TeHdr->StrippedSize\r
+                                    );\r
+    RelocBaseEnd = (EFI_IMAGE_BASE_RELOCATION *) ((UINTN) RelocBase + (UINTN) RelocDir->Size - 1);\r
+  }\r
+  \r
+  //\r
+  // Run the relocation information and apply the fixups\r
+  //\r
+  FixupData = ImageContext->FixupData;\r
+  while (RelocBase < RelocBaseEnd) {\r
+\r
+    Reloc     = (UINT16 *) ((CHAR8 *) RelocBase + sizeof (EFI_IMAGE_BASE_RELOCATION));\r
+    RelocEnd  = (UINT16 *) ((CHAR8 *) RelocBase + RelocBase->SizeOfBlock);\r
+    if (!(ImageContext->IsTeImage)) {\r
+      FixupBase = PeCoffLoaderImageAddress (ImageContext, RelocBase->VirtualAddress);\r
+    } else {\r
+      FixupBase = (CHAR8 *)(UINTN)(ImageContext->ImageAddress +\r
+                    RelocBase->VirtualAddress +\r
+                    sizeof(EFI_TE_IMAGE_HEADER) - \r
+                    TeHdr->StrippedSize\r
+                    );\r
+    }\r
+\r
+    if ((CHAR8 *) RelocEnd < (CHAR8 *) ((UINTN) ImageContext->ImageAddress) ||\r
+        (CHAR8 *) RelocEnd > (CHAR8 *)((UINTN)ImageContext->ImageAddress + \r
+          (UINTN)ImageContext->ImageSize)) {\r
+      ImageContext->ImageError = IMAGE_ERROR_FAILED_RELOCATION;\r
+      return RETURN_LOAD_ERROR;\r
+    }\r
+\r
+    //\r
+    // Run this relocation record\r
+    //\r
+    while (Reloc < RelocEnd) {\r
+\r
+      Fixup = FixupBase + (*Reloc & 0xFFF);\r
+      switch ((*Reloc) >> 12) {\r
+      case EFI_IMAGE_REL_BASED_ABSOLUTE:\r
+        break;\r
+\r
+      case EFI_IMAGE_REL_BASED_HIGH:\r
+        F16   = (UINT16 *) Fixup;\r
+        *F16 = (UINT16) (*F16 + ((UINT16) ((UINT32) Adjust >> 16)));\r
+        if (FixupData != NULL) {\r
+          *(UINT16 *) FixupData = *F16;\r
+          FixupData             = FixupData + sizeof (UINT16);\r
+        }\r
+        break;\r
+\r
+      case EFI_IMAGE_REL_BASED_LOW:\r
+        F16   = (UINT16 *) Fixup;\r
+        *F16  = (UINT16) (*F16 + (UINT16) Adjust);\r
+        if (FixupData != NULL) {\r
+          *(UINT16 *) FixupData = *F16;\r
+          FixupData             = FixupData + sizeof (UINT16);\r
+        }\r
+        break;\r
+\r
+      case EFI_IMAGE_REL_BASED_HIGHLOW:\r
+        F32   = (UINT32 *) Fixup;\r
+        *F32  = *F32 + (UINT32) Adjust;\r
+        if (FixupData != NULL) {\r
+          FixupData             = ALIGN_POINTER (FixupData, sizeof (UINT32));\r
+          *(UINT32 *) FixupData = *F32;\r
+          FixupData             = FixupData + sizeof (UINT32);\r
+        }\r
+        break;\r
+\r
+      case EFI_IMAGE_REL_BASED_HIGHADJ:\r
+        //\r
+        // Return the same EFI_UNSUPPORTED return code as\r
+        // PeCoffLoaderRelocateImageEx() returns if it does not recognize\r
+        // the relocation type.\r
+        //\r
+        ImageContext->ImageError = IMAGE_ERROR_FAILED_RELOCATION;\r
+        return RETURN_UNSUPPORTED;\r
+\r
+      default:\r
+        Status = PeCoffLoaderRelocateImageEx (Reloc, Fixup, &FixupData, Adjust);\r
+        if (RETURN_ERROR (Status)) {\r
+          ImageContext->ImageError = IMAGE_ERROR_FAILED_RELOCATION;\r
+          return Status;\r
+        }\r
+      }\r
+\r
+      //\r
+      // Next relocation record\r
+      //\r
+      Reloc += 1;\r
+    }\r
+\r
+    //\r
+    // Next reloc block\r
+    //\r
+    RelocBase = (EFI_IMAGE_BASE_RELOCATION *) RelocEnd;\r
+  }\r
+\r
+  return RETURN_SUCCESS;\r
+}\r
+\r
+RETURN_STATUS\r
+EFIAPI\r
+PeCoffLoaderLoadImage (\r
+  IN OUT PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Loads a PE/COFF image into memory\r
+\r
+Arguments:\r
+\r
+  This         - Calling context\r
+\r
+  ImageContext - Contains information on image to load into memory\r
+\r
+Returns:\r
+\r
+  RETURN_SUCCESS            if the PE/COFF image was loaded\r
+  RETURN_BUFFER_TOO_SMALL   if the caller did not provide a large enough buffer\r
+  RETURN_LOAD_ERROR         if the image is a runtime driver with no relocations\r
+  RETURN_INVALID_PARAMETER  if the image address is invalid\r
+\r
+--*/\r
+{\r
+  RETURN_STATUS                            Status;\r
+  EFI_IMAGE_NT_HEADERS                  *PeHdr;\r
+  EFI_TE_IMAGE_HEADER                   *TeHdr;\r
+  PE_COFF_LOADER_IMAGE_CONTEXT  CheckContext;\r
+  EFI_IMAGE_SECTION_HEADER              *FirstSection;\r
+  EFI_IMAGE_SECTION_HEADER              *Section;\r
+  UINTN                                 NumberOfSections;\r
+  UINTN                                 Index;\r
+  CHAR8                                 *Base;\r
+  CHAR8                                 *End;\r
+  CHAR8                                 *MaxEnd;\r
+  EFI_IMAGE_DATA_DIRECTORY              *DirectoryEntry;\r
+  EFI_IMAGE_DEBUG_DIRECTORY_ENTRY       *DebugEntry;\r
+  UINTN                                 Size;\r
+  UINT32                                TempDebugEntryRva;\r
+\r
+  PeHdr = NULL;\r
+  TeHdr = NULL;\r
+  //\r
+  // Assume success\r
+  //\r
+  ImageContext->ImageError = IMAGE_ERROR_SUCCESS;\r
+\r
+  //\r
+  // Copy the provided context info into our local version, get what we\r
+  // can from the original image, and then use that to make sure everything\r
+  // is legit.\r
+  //\r
+  CopyMem (&CheckContext, ImageContext, sizeof (PE_COFF_LOADER_IMAGE_CONTEXT));\r
+\r
+  Status = PeCoffLoaderGetImageInfo (&CheckContext);\r
+  if (RETURN_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  //\r
+  // Make sure there is enough allocated space for the image being loaded\r
+  //\r
+  if (ImageContext->ImageSize < CheckContext.ImageSize) {\r
+    ImageContext->ImageError = IMAGE_ERROR_INVALID_IMAGE_SIZE;\r
+    return RETURN_BUFFER_TOO_SMALL;\r
+  }\r
+\r
+  //\r
+  // If there's no relocations, then make sure it's not a runtime driver,\r
+  // and that it's being loaded at the linked address.\r
+  //\r
+  if (CheckContext.RelocationsStripped) {\r
+    //\r
+    // If the image does not contain relocations and it is a runtime driver\r
+    // then return an error.\r
+    //\r
+    if (CheckContext.ImageType == EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER) {\r
+      ImageContext->ImageError = IMAGE_ERROR_INVALID_SUBSYSTEM;\r
+      return RETURN_LOAD_ERROR;\r
+    }\r
+    //\r
+    // If the image does not contain relocations, and the requested load address\r
+    // is not the linked address, then return an error.\r
+    //\r
+    if (CheckContext.ImageAddress != ImageContext->ImageAddress) {\r
+      ImageContext->ImageError = IMAGE_ERROR_INVALID_IMAGE_ADDRESS;\r
+      return RETURN_INVALID_PARAMETER;\r
+    }\r
+  }\r
+  //\r
+  // Make sure the allocated space has the proper section alignment\r
+  //\r
+  if (!(ImageContext->IsTeImage)) {\r
+    if ((ImageContext->ImageAddress & (CheckContext.SectionAlignment - 1)) != 0) {\r
+      ImageContext->ImageError = IMAGE_ERROR_INVALID_SECTION_ALIGNMENT;\r
+      return RETURN_INVALID_PARAMETER;\r
+    }\r
+  }\r
+  //\r
+  // Read the entire PE/COFF or TE header into memory\r
+  //\r
+  if (!(ImageContext->IsTeImage)) {\r
+    Status = ImageContext->ImageRead (\r
+                            ImageContext->Handle,\r
+                            0,\r
+                            &ImageContext->SizeOfHeaders,\r
+                            (VOID *) (UINTN) ImageContext->ImageAddress\r
+                            );\r
+\r
+    PeHdr = (EFI_IMAGE_NT_HEADERS *)\r
+      ((UINTN)ImageContext->ImageAddress + ImageContext->PeCoffHeaderOffset);\r
+\r
+    FirstSection = (EFI_IMAGE_SECTION_HEADER *) (\r
+                      (UINTN)ImageContext->ImageAddress +\r
+                      ImageContext->PeCoffHeaderOffset +\r
+                      sizeof(UINT32) + \r
+                      sizeof(EFI_IMAGE_FILE_HEADER) + \r
+                      PeHdr->FileHeader.SizeOfOptionalHeader\r
+      );\r
+    NumberOfSections = (UINTN) (PeHdr->FileHeader.NumberOfSections);\r
+  } else {\r
+    Status = ImageContext->ImageRead (\r
+                            ImageContext->Handle,\r
+                            0,\r
+                            &ImageContext->SizeOfHeaders,\r
+                            (void *) (UINTN) ImageContext->ImageAddress\r
+                            );\r
+\r
+    TeHdr             = (EFI_TE_IMAGE_HEADER *) (UINTN) (ImageContext->ImageAddress);\r
+\r
+    FirstSection = (EFI_IMAGE_SECTION_HEADER *) (\r
+          (UINTN)ImageContext->ImageAddress +\r
+          sizeof(EFI_TE_IMAGE_HEADER)\r
+          );\r
+    NumberOfSections  = (UINTN) (TeHdr->NumberOfSections);\r
+\r
+  }\r
+\r
+  if (RETURN_ERROR (Status)) {\r
+    ImageContext->ImageError = IMAGE_ERROR_IMAGE_READ;\r
+    return RETURN_LOAD_ERROR;\r
+  }\r
+\r
+  //\r
+  // Load each section of the image\r
+  //\r
+  Section = FirstSection;\r
+  for (Index = 0, MaxEnd = NULL; Index < NumberOfSections; Index++) {\r
+\r
+    //\r
+    // Compute sections address\r
+    //\r
+    Base = PeCoffLoaderImageAddress (ImageContext, Section->VirtualAddress);\r
+    End = PeCoffLoaderImageAddress (\r
+            ImageContext,\r
+            Section->VirtualAddress + Section->Misc.VirtualSize - 1\r
+            );\r
+    if (ImageContext->IsTeImage) {\r
+      Base  = (CHAR8 *) ((UINTN) Base + sizeof (EFI_TE_IMAGE_HEADER) - (UINTN) TeHdr->StrippedSize);\r
+      End   = (CHAR8 *) ((UINTN) End + sizeof (EFI_TE_IMAGE_HEADER) - (UINTN) TeHdr->StrippedSize);\r
+    }\r
+\r
+    if (End > MaxEnd) {\r
+      MaxEnd = End;\r
+    }\r
+    //\r
+    // If the base start or end address resolved to 0, then fail.\r
+    //\r
+    if ((Base == NULL) || (End == NULL)) {\r
+      ImageContext->ImageError = IMAGE_ERROR_SECTION_NOT_LOADED;\r
+      return RETURN_LOAD_ERROR;\r
+    }\r
+\r
+    //\r
+    // Read the section\r
+    //\r
+    Size = (UINTN) Section->Misc.VirtualSize;\r
+    if ((Size == 0) || (Size > Section->SizeOfRawData)) {\r
+      Size = (UINTN) Section->SizeOfRawData;\r
+    }\r
+\r
+    if (Section->SizeOfRawData) {\r
+      if (!(ImageContext->IsTeImage)) {\r
+        Status = ImageContext->ImageRead (\r
+                                ImageContext->Handle,\r
+                                Section->PointerToRawData,\r
+                                &Size,\r
+                                Base\r
+                                );\r
+      } else {\r
+        Status = ImageContext->ImageRead (\r
+                                ImageContext->Handle,\r
+                                Section->PointerToRawData + sizeof (EFI_TE_IMAGE_HEADER) - (UINTN) TeHdr->StrippedSize,\r
+                                &Size,\r
+                                Base\r
+                                );\r
+      }\r
+\r
+      if (RETURN_ERROR (Status)) {\r
+        ImageContext->ImageError = IMAGE_ERROR_IMAGE_READ;\r
+        return Status;\r
+      }\r
+    }\r
+\r
+    //\r
+    // If raw size is less then virt size, zero fill the remaining\r
+    //\r
+\r
+    if (Size < Section->Misc.VirtualSize) {\r
+      ZeroMem (Base + Size, Section->Misc.VirtualSize - Size);\r
+    }\r
+\r
+    //\r
+    // Next Section\r
+    //\r
+    Section += 1;\r
+  }\r
+\r
+  //\r
+  // Get image's entry point\r
+  //\r
+  if (!(ImageContext->IsTeImage)) {\r
+    ImageContext->EntryPoint = (PHYSICAL_ADDRESS) (UINTN) PeCoffLoaderImageAddress (\r
+                                                                ImageContext,\r
+                                                                PeHdr->OptionalHeader.AddressOfEntryPoint\r
+                                                                );\r
+  } else {\r
+    ImageContext->EntryPoint =  (PHYSICAL_ADDRESS) (\r
+                       (UINTN)ImageContext->ImageAddress +\r
+                       (UINTN)TeHdr->AddressOfEntryPoint +\r
+                       (UINTN)sizeof(EFI_TE_IMAGE_HEADER) -\r
+          (UINTN) TeHdr->StrippedSize\r
+      );\r
+  }\r
+\r
+  //\r
+  // Determine the size of the fixup data\r
+  //\r
+  // Per the PE/COFF spec, you can't assume that a given data directory\r
+  // is present in the image. You have to check the NumberOfRvaAndSizes in\r
+  // the optional header to verify a desired directory entry is there.\r
+  //\r
+  if (!(ImageContext->IsTeImage)) {\r
+    if (PeHdr->OptionalHeader.NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC) {\r
+      DirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *)\r
+        &PeHdr->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC];\r
+      ImageContext->FixupDataSize = DirectoryEntry->Size / sizeof (UINT16) * sizeof (UINTN);\r
+    } else {\r
+      ImageContext->FixupDataSize = 0;\r
+    }\r
+  } else {\r
+    DirectoryEntry              = &TeHdr->DataDirectory[0];\r
+    ImageContext->FixupDataSize = DirectoryEntry->Size / sizeof (UINT16) * sizeof (UINTN);\r
+  }\r
+  //\r
+  // Consumer must allocate a buffer for the relocation fixup log.\r
+  // Only used for runtime drivers.\r
+  //\r
+  ImageContext->FixupData = NULL;\r
+\r
+  //\r
+  // Load the Codeview info if present\r
+  //\r
+  if (ImageContext->DebugDirectoryEntryRva != 0) {\r
+    if (!(ImageContext->IsTeImage)) {\r
+      DebugEntry = PeCoffLoaderImageAddress (\r
+                    ImageContext,\r
+                    ImageContext->DebugDirectoryEntryRva\r
+                    );\r
+    } else {\r
+      DebugEntry = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *)(UINTN)(\r
+                                               ImageContext->ImageAddress +\r
+                                               ImageContext->DebugDirectoryEntryRva +\r
+                                               sizeof(EFI_TE_IMAGE_HEADER) -\r
+                                               TeHdr->StrippedSize\r
+                                               );\r
+    }\r
+\r
+    if (DebugEntry != NULL) {\r
+      TempDebugEntryRva = DebugEntry->RVA;\r
+      if (DebugEntry->RVA == 0 && DebugEntry->FileOffset != 0) {\r
+        Section--;\r
+        if ((UINTN) Section->SizeOfRawData < Section->Misc.VirtualSize) {\r
+          TempDebugEntryRva = Section->VirtualAddress + Section->Misc.VirtualSize;\r
+        } else {\r
+          TempDebugEntryRva = Section->VirtualAddress + Section->SizeOfRawData;\r
+        }\r
+      }\r
+\r
+      if (TempDebugEntryRva != 0) {\r
+        if (!(ImageContext->IsTeImage)) {\r
+          ImageContext->CodeView = PeCoffLoaderImageAddress (ImageContext, TempDebugEntryRva);\r
+        } else {\r
+          ImageContext->CodeView = (VOID *)(\r
+                      (UINTN)ImageContext->ImageAddress +\r
+                      (UINTN)TempDebugEntryRva +\r
+                      (UINTN)sizeof(EFI_TE_IMAGE_HEADER) -\r
+                (UINTN) TeHdr->StrippedSize\r
+            );\r
+        }\r
+\r
+        if (ImageContext->CodeView == NULL) {\r
+          ImageContext->ImageError = IMAGE_ERROR_IMAGE_READ;\r
+          return RETURN_LOAD_ERROR;\r
+        }\r
+\r
+        if (DebugEntry->RVA == 0) {\r
+          Size = DebugEntry->SizeOfData;\r
+          if (!(ImageContext->IsTeImage)) {\r
+            Status = ImageContext->ImageRead (\r
+                                    ImageContext->Handle,\r
+                                    DebugEntry->FileOffset,\r
+                                    &Size,\r
+                                    ImageContext->CodeView\r
+                                    );\r
+          } else {\r
+            Status = ImageContext->ImageRead (\r
+                                    ImageContext->Handle,\r
+                                    DebugEntry->FileOffset + sizeof (EFI_TE_IMAGE_HEADER) - TeHdr->StrippedSize,\r
+                                    &Size,\r
+                                    ImageContext->CodeView\r
+                                    );\r
+            //\r
+            // Should we apply fix up to this field according to the size difference between PE and TE?\r
+            // Because now we maintain TE header fields unfixed, this field will also remain as they are\r
+            // in original PE image.\r
+            //\r
+          }\r
+\r
+          if (RETURN_ERROR (Status)) {\r
+            ImageContext->ImageError = IMAGE_ERROR_IMAGE_READ;\r
+            return RETURN_LOAD_ERROR;\r
+          }\r
+\r
+          DebugEntry->RVA = TempDebugEntryRva;\r
+        }\r
+\r
+        switch (*(UINT32 *) ImageContext->CodeView) {\r
+        case CODEVIEW_SIGNATURE_NB10:\r
+          ImageContext->PdbPointer = (CHAR8 *) ImageContext->CodeView + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY);\r
+          break;\r
+\r
+        case CODEVIEW_SIGNATURE_RSDS:\r
+          ImageContext->PdbPointer = (CHAR8 *) ImageContext->CodeView + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_RSDS_ENTRY);\r
+          break;\r
+\r
+        default:\r
+          break;\r
+        }\r
+      }\r
+    }\r
+  }\r
+\r
+  return Status;\r
+}\r
diff --git a/Tools/CodeTools/Source/PeCoffLoader/Common/EfiImage.h b/Tools/CodeTools/Source/PeCoffLoader/Common/EfiImage.h
new file mode 100644 (file)
index 0000000..9528e6b
--- /dev/null
@@ -0,0 +1,701 @@
+/** @file\r
+  EFI image format for PE32+. Please note some data structures are different\r
+  for IA-32 and Itanium-based images, look for UINTN and the #ifdef EFI_IA64\r
+\r
+  @bug Fix text - doc as defined in MSFT EFI specification.\r
+\r
+  Copyright (c) 2006, Intel Corporation                                                         \r
+  All rights reserved. This program and the accompanying materials                          \r
+  are licensed and made available under the terms and conditions of the BSD License         \r
+  which accompanies this distribution.  The full text of the license may be found at        \r
+  http://opensource.org/licenses/bsd-license.php                                            \r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+  Module Name:  EfiImage.h\r
+\r
+**/\r
+\r
+#ifndef __EFI_IMAGE_H__\r
+#define __EFI_IMAGE_H__\r
+\r
+//\r
+// PE32+ Subsystem type for EFI images\r
+//\r
+#define EFI_IMAGE_SUBSYSTEM_EFI_APPLICATION         10\r
+#define EFI_IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER 11\r
+#define EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER      12\r
+#define EFI_IMAGE_SUBSYSTEM_SAL_RUNTIME_DRIVER      13\r
+\r
+//\r
+// BugBug: Need to get a real answer for this problem. This is not in the\r
+//         PE specification.\r
+//\r
+//         A SAL runtime driver does not get fixed up when a transition to\r
+//         virtual mode is made. In all other cases it should be treated\r
+//         like a EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER image\r
+//\r
+#define EFI_IMAGE_SUBSYSTEM_SAL_RUNTIME_DRIVER  13\r
+\r
+//\r
+// PE32+ Machine type for EFI images\r
+//\r
+#define IMAGE_FILE_MACHINE_I386     0x014c\r
+#define IMAGE_FILE_MACHINE_IA64     0x0200\r
+#define IMAGE_FILE_MACHINE_EBC      0x0EBC\r
+#define IMAGE_FILE_MACHINE_X64      0x8664\r
+//\r
+// Support old names for backward compatible\r
+//\r
+#define EFI_IMAGE_MACHINE_IA32      IMAGE_FILE_MACHINE_I386 \r
+#define EFI_IMAGE_MACHINE_IA64      IMAGE_FILE_MACHINE_IA64  \r
+#define EFI_IMAGE_MACHINE_IPF       IMAGE_FILE_MACHINE_IA64  \r
+#define EFI_IMAGE_MACHINE_EBC       IMAGE_FILE_MACHINE_EBC  \r
+#define EFI_IMAGE_MACHINE_X64       IMAGE_FILE_MACHINE_X64\r
+\r
+#define EFI_IMAGE_DOS_SIGNATURE     0x5A4D      // MZ\r
+#define EFI_IMAGE_OS2_SIGNATURE     0x454E      // NE\r
+#define EFI_IMAGE_OS2_SIGNATURE_LE  0x454C      // LE\r
+#define EFI_IMAGE_NT_SIGNATURE      0x00004550  // PE00\r
+#define EFI_IMAGE_EDOS_SIGNATURE    0x44454550  // PEED\r
+\r
+///\r
+/// PE images can start with an optional DOS header, so if an image is run\r
+///  under DOS it can print an error message.\r
+///\r
+typedef struct {\r
+  UINT16  e_magic;    // Magic number\r
+  UINT16  e_cblp;     // Bytes on last page of file\r
+  UINT16  e_cp;       // Pages in file\r
+  UINT16  e_crlc;     // Relocations\r
+  UINT16  e_cparhdr;  // Size of header in paragraphs\r
+  UINT16  e_minalloc; // Minimum extra paragraphs needed\r
+  UINT16  e_maxalloc; // Maximum extra paragraphs needed\r
+  UINT16  e_ss;       // Initial (relative) SS value\r
+  UINT16  e_sp;       // Initial SP value\r
+  UINT16  e_csum;     // Checksum\r
+  UINT16  e_ip;       // Initial IP value\r
+  UINT16  e_cs;       // Initial (relative) CS value\r
+  UINT16  e_lfarlc;   // File address of relocation table\r
+  UINT16  e_ovno;     // Overlay number\r
+  UINT16  e_res[4];   // Reserved words\r
+  UINT16  e_oemid;    // OEM identifier (for e_oeminfo)\r
+  UINT16  e_oeminfo;  // OEM information; e_oemid specific\r
+  UINT16  e_res2[10]; // Reserved words\r
+  UINT32  e_lfanew;   // File address of new exe header\r
+} EFI_IMAGE_DOS_HEADER;\r
+\r
+///\r
+/// File header format.\r
+///\r
+typedef struct {\r
+  UINT16  Machine;\r
+  UINT16  NumberOfSections;\r
+  UINT32  TimeDateStamp;\r
+  UINT32  PointerToSymbolTable;\r
+  UINT32  NumberOfSymbols;\r
+  UINT16  SizeOfOptionalHeader;\r
+  UINT16  Characteristics;\r
+} EFI_IMAGE_FILE_HEADER;\r
+\r
+#define EFI_IMAGE_SIZEOF_FILE_HEADER        20\r
+\r
+#define EFI_IMAGE_FILE_RELOCS_STRIPPED      0x0001  // Relocation info stripped from file.\r
+#define EFI_IMAGE_FILE_EXECUTABLE_IMAGE     0x0002  // File is executable  (i.e. no unresolved externel references).\r
+#define EFI_IMAGE_FILE_LINE_NUMS_STRIPPED   0x0004  // Line nunbers stripped from file.\r
+#define EFI_IMAGE_FILE_LOCAL_SYMS_STRIPPED  0x0008  // Local symbols stripped from file.\r
+#define EFI_IMAGE_FILE_BYTES_REVERSED_LO    0x0080  // Bytes of machine word are reversed.\r
+#define EFI_IMAGE_FILE_32BIT_MACHINE        0x0100  // 32 bit word machine.\r
+#define EFI_IMAGE_FILE_DEBUG_STRIPPED       0x0200  // Debugging info stripped from file in .DBG file\r
+#define EFI_IMAGE_FILE_SYSTEM               0x1000  // System File.\r
+#define EFI_IMAGE_FILE_DLL                  0x2000  // File is a DLL.\r
+#define EFI_IMAGE_FILE_BYTES_REVERSED_HI    0x8000  // Bytes of machine word are reversed.\r
+#define EFI_IMAGE_FILE_MACHINE_UNKNOWN      0\r
+#define EFI_IMAGE_FILE_MACHINE_I386         0x14c   // Intel 386.\r
+#define EFI_IMAGE_FILE_MACHINE_R3000        0x162   // MIPS* little-endian, 0540 big-endian\r
+#define EFI_IMAGE_FILE_MACHINE_R4000        0x166   // MIPS* little-endian\r
+#define EFI_IMAGE_FILE_MACHINE_ALPHA        0x184   // Alpha_AXP*\r
+#define EFI_IMAGE_FILE_MACHINE_POWERPC      0x1F0   // IBM* PowerPC Little-Endian\r
+#define EFI_IMAGE_FILE_MACHINE_TAHOE        0x7cc   // Intel EM machine\r
+//\r
+// * Other names and brands may be claimed as the property of others.\r
+//\r
+\r
+///\r
+/// Directory format.\r
+///\r
+typedef struct {\r
+  UINT32  VirtualAddress;\r
+  UINT32  Size;\r
+} EFI_IMAGE_DATA_DIRECTORY;\r
+\r
+#define EFI_IMAGE_NUMBER_OF_DIRECTORY_ENTRIES 16\r
+\r
+typedef struct {\r
+  UINT16  Magic;\r
+  UINT8   MajorLinkerVersion;\r
+  UINT8   MinorLinkerVersion;\r
+  UINT32  SizeOfCode;\r
+  UINT32  SizeOfInitializedData;\r
+  UINT32  SizeOfUninitializedData;\r
+  UINT32  AddressOfEntryPoint;\r
+  UINT32  BaseOfCode;\r
+  UINT32  BaseOfData;\r
+  UINT32  BaseOfBss;\r
+  UINT32  GprMask;\r
+  UINT32  CprMask[4];\r
+  UINT32  GpValue;\r
+} EFI_IMAGE_ROM_OPTIONAL_HEADER;\r
+\r
+#define EFI_IMAGE_ROM_OPTIONAL_HDR_MAGIC      0x107\r
+#define EFI_IMAGE_SIZEOF_ROM_OPTIONAL_HEADER  sizeof (EFI_IMAGE_ROM_OPTIONAL_HEADER)\r
+\r
+typedef struct {\r
+  EFI_IMAGE_FILE_HEADER         FileHeader;\r
+  EFI_IMAGE_ROM_OPTIONAL_HEADER OptionalHeader;\r
+} EFI_IMAGE_ROM_HEADERS;\r
+\r
+///\r
+/// @attention\r
+/// EFI_IMAGE_OPTIONAL_HEADER32 and EFI_IMAGE_OPTIONAL_HEADER64\r
+/// are for use ONLY by tools.  All proper EFI code MUST use\r
+/// EFI_IMAGE_OPTIONAL_HEADER ONLY!!!\r
+///\r
+#define EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC 0x10b\r
+\r
+typedef struct {\r
+  //\r
+  // Standard fields.\r
+  //\r
+  UINT16                    Magic;\r
+  UINT8                     MajorLinkerVersion;\r
+  UINT8                     MinorLinkerVersion;\r
+  UINT32                    SizeOfCode;\r
+  UINT32                    SizeOfInitializedData;\r
+  UINT32                    SizeOfUninitializedData;\r
+  UINT32                    AddressOfEntryPoint;\r
+  UINT32                    BaseOfCode;\r
+  UINT32                    BaseOfData;\r
+  //\r
+  // NT additional fields.\r
+  //\r
+  UINT32                    ImageBase;\r
+  UINT32                    SectionAlignment;\r
+  UINT32                    FileAlignment;\r
+  UINT16                    MajorOperatingSystemVersion;\r
+  UINT16                    MinorOperatingSystemVersion;\r
+  UINT16                    MajorImageVersion;\r
+  UINT16                    MinorImageVersion;\r
+  UINT16                    MajorSubsystemVersion;\r
+  UINT16                    MinorSubsystemVersion;\r
+  UINT32                    Win32VersionValue;\r
+  UINT32                    SizeOfImage;\r
+  UINT32                    SizeOfHeaders;\r
+  UINT32                    CheckSum;\r
+  UINT16                    Subsystem;\r
+  UINT16                    DllCharacteristics;\r
+  UINT32                    SizeOfStackReserve;\r
+  UINT32                    SizeOfStackCommit;\r
+  UINT32                    SizeOfHeapReserve;\r
+  UINT32                    SizeOfHeapCommit;\r
+  UINT32                    LoaderFlags;\r
+  UINT32                    NumberOfRvaAndSizes;\r
+  EFI_IMAGE_DATA_DIRECTORY  DataDirectory[EFI_IMAGE_NUMBER_OF_DIRECTORY_ENTRIES];\r
+} EFI_IMAGE_OPTIONAL_HEADER32;\r
+\r
+///\r
+/// @attention\r
+/// EFI_IMAGE_OPTIONAL_HEADER32 and EFI_IMAGE_OPTIONAL_HEADER64\r
+/// are for use ONLY by tools.  All proper EFI code MUST use\r
+/// EFI_IMAGE_OPTIONAL_HEADER ONLY!!!\r
+///\r
+#define EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC 0x20b\r
+\r
+typedef struct {\r
+  //\r
+  // Standard fields.\r
+  //\r
+  UINT16                    Magic;\r
+  UINT8                     MajorLinkerVersion;\r
+  UINT8                     MinorLinkerVersion;\r
+  UINT32                    SizeOfCode;\r
+  UINT32                    SizeOfInitializedData;\r
+  UINT32                    SizeOfUninitializedData;\r
+  UINT32                    AddressOfEntryPoint;\r
+  UINT32                    BaseOfCode;\r
+  //\r
+  // NT additional fields.\r
+  //\r
+  UINT64                    ImageBase;\r
+  UINT32                    SectionAlignment;\r
+  UINT32                    FileAlignment;\r
+  UINT16                    MajorOperatingSystemVersion;\r
+  UINT16                    MinorOperatingSystemVersion;\r
+  UINT16                    MajorImageVersion;\r
+  UINT16                    MinorImageVersion;\r
+  UINT16                    MajorSubsystemVersion;\r
+  UINT16                    MinorSubsystemVersion;\r
+  UINT32                    Win32VersionValue;\r
+  UINT32                    SizeOfImage;\r
+  UINT32                    SizeOfHeaders;\r
+  UINT32                    CheckSum;\r
+  UINT16                    Subsystem;\r
+  UINT16                    DllCharacteristics;\r
+  UINT64                    SizeOfStackReserve;\r
+  UINT64                    SizeOfStackCommit;\r
+  UINT64                    SizeOfHeapReserve;\r
+  UINT64                    SizeOfHeapCommit;\r
+  UINT32                    LoaderFlags;\r
+  UINT32                    NumberOfRvaAndSizes;\r
+  EFI_IMAGE_DATA_DIRECTORY  DataDirectory[EFI_IMAGE_NUMBER_OF_DIRECTORY_ENTRIES];\r
+} EFI_IMAGE_OPTIONAL_HEADER64;\r
+\r
+///\r
+/// @attention\r
+/// EFI_IMAGE_NT_HEADERS32 and EFI_IMAGE_HEADERS64 are for use ONLY\r
+/// by tools.  All proper EFI code MUST use EFI_IMAGE_NT_HEADERS ONLY!!!\r
+///\r
+typedef struct {\r
+  UINT32                      Signature;\r
+  EFI_IMAGE_FILE_HEADER       FileHeader;\r
+  EFI_IMAGE_OPTIONAL_HEADER32 OptionalHeader;\r
+} EFI_IMAGE_NT_HEADERS32;\r
+\r
+#define EFI_IMAGE_SIZEOF_NT_OPTIONAL32_HEADER sizeof (EFI_IMAGE_NT_HEADERS32)\r
+\r
+typedef struct {\r
+  UINT32                      Signature;\r
+  EFI_IMAGE_FILE_HEADER       FileHeader;\r
+  EFI_IMAGE_OPTIONAL_HEADER64 OptionalHeader;\r
+} EFI_IMAGE_NT_HEADERS64;\r
+\r
+#define EFI_IMAGE_SIZEOF_NT_OPTIONAL64_HEADER sizeof (EFI_IMAGE_NT_HEADERS64)\r
+\r
+//\r
+// Processor specific definition of EFI_IMAGE_OPTIONAL_HEADER so the\r
+// type name EFI_IMAGE_OPTIONAL_HEADER is appropriate to the build.  Same for\r
+// EFI_IMAGE_NT_HEADERS.  These definitions MUST be used by ALL EFI code.\r
+//\r
+#if   defined (MDE_CPU_IA32) && !defined (BUILDING_TOOLS) || \\r
+      defined (BUILDING_TOOLS) && defined (TOOL_BUILD_IA32_TARGET)\r
+\r
+// typedef EFI_IMAGE_OPTIONAL_HEADER32     EFI_IMAGE_OPTIONAL_HEADER;\r
+typedef EFI_IMAGE_NT_HEADERS32          EFI_IMAGE_NT_HEADERS;\r
+\r
+#define EFI_IMAGE_NT_OPTIONAL_HDR_MAGIC EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC\r
+#define EFI_IMAGE_MACHINE_TYPE_SUPPORTED(Machine) \\r
+  (((Machine) == EFI_IMAGE_MACHINE_IA32) || ((Machine) == EFI_IMAGE_MACHINE_EBC))\r
+\r
+#elif defined (MDE_CPU_IPF) && !defined (BUILDING_TOOLS) || \\r
+      defined (BUILDING_TOOLS) && defined (TOOL_BUILD_IPF_TARGET)\r
+\r
+typedef EFI_IMAGE_OPTIONAL_HEADER64     EFI_IMAGE_OPTIONAL_HEADER;\r
+typedef EFI_IMAGE_NT_HEADERS64          EFI_IMAGE_NT_HEADERS;\r
+\r
+#define EFI_IMAGE_NT_OPTIONAL_HDR_MAGIC EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC\r
+#define EFI_IMAGE_MACHINE_TYPE_SUPPORTED(Machine) \\r
+  (((Machine) == EFI_IMAGE_MACHINE_IPF) || ((Machine) == EFI_IMAGE_MACHINE_EBC))\r
+\r
+#elif defined (MDE_CPU_X64) && !defined (BUILDING_TOOLS) || \\r
+      defined (BUILDING_TOOLS) && defined (TOOL_BUILD_X64_TARGET)\r
+\r
+typedef EFI_IMAGE_OPTIONAL_HEADER64     EFI_IMAGE_OPTIONAL_HEADER;\r
+typedef EFI_IMAGE_NT_HEADERS64          EFI_IMAGE_NT_HEADERS;\r
+\r
+#define EFI_IMAGE_NT_OPTIONAL_HDR_MAGIC EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC\r
+#define EFI_IMAGE_MACHINE_TYPE_SUPPORTED(Machine) \\r
+  (((Machine) == EFI_IMAGE_MACHINE_X64) || ((Machine) == EFI_IMAGE_MACHINE_EBC))\r
+\r
+#elif defined (MDE_CPU_EBC)\r
+\r
+//\r
+// This is just to make sure you can cross compile with the EBC compiiler.\r
+// It does not make sense to have a PE loader coded in EBC. You need to \r
+// understand the basic \r
+//\r
+typedef EFI_IMAGE_OPTIONAL_HEADER64     EFI_IMAGE_OPTIONAL_HEADER;\r
+typedef EFI_IMAGE_NT_HEADERS64          EFI_IMAGE_NT_HEADERS;\r
+\r
+#define EFI_IMAGE_NT_OPTIONAL_HDR_MAGIC EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC\r
+#define EFI_IMAGE_MACHINE_TYPE_SUPPORTED(Machine) ((Machine) == EFI_IMAGE_MACHINE_EBC)\r
+\r
+#else\r
+#error Unknown Processor Type\r
+#endif\r
+\r
+\r
+#define EFI_IMAGE_FIRST_SECTION(ntheader) \\r
+    ( \\r
+      (EFI_IMAGE_SECTION_HEADER *) \\r
+        ( \\r
+          (UINT32) ntheader + \\r
+          FIELD_OFFSET (EFI_IMAGE_NT_HEADERS, OptionalHeader) + \\r
+          ((EFI_IMAGE_NT_HEADERS *) (ntheader))->FileHeader.SizeOfOptionalHeader \\r
+        ) \\r
+    )\r
+\r
+//\r
+// Subsystem Values\r
+//\r
+#define EFI_IMAGE_SUBSYSTEM_UNKNOWN     0\r
+#define EFI_IMAGE_SUBSYSTEM_NATIVE      1\r
+#define EFI_IMAGE_SUBSYSTEM_WINDOWS_GUI 2\r
+#define EFI_IMAGE_SUBSYSTEM_WINDOWS_CUI 3.\r
+#define EFI_IMAGE_SUBSYSTEM_OS2_CUI     5\r
+#define EFI_IMAGE_SUBSYSTEM_POSIX_CUI   7\r
+\r
+//\r
+// Directory Entries\r
+//\r
+#define EFI_IMAGE_DIRECTORY_ENTRY_EXPORT      0\r
+#define EFI_IMAGE_DIRECTORY_ENTRY_IMPORT      1\r
+#define EFI_IMAGE_DIRECTORY_ENTRY_RESOURCE    2\r
+#define EFI_IMAGE_DIRECTORY_ENTRY_EXCEPTION   3\r
+#define EFI_IMAGE_DIRECTORY_ENTRY_SECURITY    4\r
+#define EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC   5\r
+#define EFI_IMAGE_DIRECTORY_ENTRY_DEBUG       6\r
+#define EFI_IMAGE_DIRECTORY_ENTRY_COPYRIGHT   7\r
+#define EFI_IMAGE_DIRECTORY_ENTRY_GLOBALPTR   8\r
+#define EFI_IMAGE_DIRECTORY_ENTRY_TLS         9\r
+#define EFI_IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG 10\r
+\r
+//\r
+// Section header format.\r
+//\r
+#define EFI_IMAGE_SIZEOF_SHORT_NAME 8\r
+\r
+typedef struct {\r
+  UINT8 Name[EFI_IMAGE_SIZEOF_SHORT_NAME];\r
+  union {\r
+    UINT32  PhysicalAddress;\r
+    UINT32  VirtualSize;\r
+  } Misc;\r
+  UINT32  VirtualAddress;\r
+  UINT32  SizeOfRawData;\r
+  UINT32  PointerToRawData;\r
+  UINT32  PointerToRelocations;\r
+  UINT32  PointerToLinenumbers;\r
+  UINT16  NumberOfRelocations;\r
+  UINT16  NumberOfLinenumbers;\r
+  UINT32  Characteristics;\r
+} EFI_IMAGE_SECTION_HEADER;\r
+\r
+#define EFI_IMAGE_SIZEOF_SECTION_HEADER       40\r
+\r
+#define EFI_IMAGE_SCN_TYPE_NO_PAD             0x00000008  // Reserved.\r
+#define EFI_IMAGE_SCN_CNT_CODE                0x00000020\r
+#define EFI_IMAGE_SCN_CNT_INITIALIZED_DATA    0x00000040\r
+#define EFI_IMAGE_SCN_CNT_UNINITIALIZED_DATA  0x00000080\r
+\r
+#define EFI_IMAGE_SCN_LNK_OTHER               0x00000100  // Reserved.\r
+#define EFI_IMAGE_SCN_LNK_INFO                0x00000200  // Section contains comments or some other type of information.\r
+#define EFI_IMAGE_SCN_LNK_REMOVE              0x00000800  // Section contents will not become part of image.\r
+#define EFI_IMAGE_SCN_LNK_COMDAT              0x00001000\r
+\r
+#define EFI_IMAGE_SCN_ALIGN_1BYTES            0x00100000\r
+#define EFI_IMAGE_SCN_ALIGN_2BYTES            0x00200000\r
+#define EFI_IMAGE_SCN_ALIGN_4BYTES            0x00300000\r
+#define EFI_IMAGE_SCN_ALIGN_8BYTES            0x00400000\r
+#define EFI_IMAGE_SCN_ALIGN_16BYTES           0x00500000\r
+#define EFI_IMAGE_SCN_ALIGN_32BYTES           0x00600000\r
+#define EFI_IMAGE_SCN_ALIGN_64BYTES           0x00700000\r
+\r
+#define EFI_IMAGE_SCN_MEM_DISCARDABLE         0x02000000\r
+#define EFI_IMAGE_SCN_MEM_NOT_CACHED          0x04000000\r
+#define EFI_IMAGE_SCN_MEM_NOT_PAGED           0x08000000\r
+#define EFI_IMAGE_SCN_MEM_SHARED              0x10000000\r
+#define EFI_IMAGE_SCN_MEM_EXECUTE             0x20000000\r
+#define EFI_IMAGE_SCN_MEM_READ                0x40000000\r
+#define EFI_IMAGE_SCN_MEM_WRITE               0x80000000\r
+\r
+///\r
+/// Symbol format.\r
+///\r
+#define EFI_IMAGE_SIZEOF_SYMBOL 18\r
+\r
+//\r
+// Section values.\r
+//\r
+// Symbols have a section number of the section in which they are\r
+// defined. Otherwise, section numbers have the following meanings:\r
+//\r
+#define EFI_IMAGE_SYM_UNDEFINED (UINT16) 0  // Symbol is undefined or is common.\r
+#define EFI_IMAGE_SYM_ABSOLUTE  (UINT16) -1 // Symbol is an absolute value.\r
+#define EFI_IMAGE_SYM_DEBUG     (UINT16) -2 // Symbol is a special debug item.\r
+//\r
+// Type (fundamental) values.\r
+//\r
+#define EFI_IMAGE_SYM_TYPE_NULL   0   // no type.\r
+#define EFI_IMAGE_SYM_TYPE_VOID   1   //\r
+#define EFI_IMAGE_SYM_TYPE_CHAR   2   // type character.\r
+#define EFI_IMAGE_SYM_TYPE_SHORT  3   // type short integer.\r
+#define EFI_IMAGE_SYM_TYPE_INT    4\r
+#define EFI_IMAGE_SYM_TYPE_LONG   5\r
+#define EFI_IMAGE_SYM_TYPE_FLOAT  6\r
+#define EFI_IMAGE_SYM_TYPE_DOUBLE 7\r
+#define EFI_IMAGE_SYM_TYPE_STRUCT 8\r
+#define EFI_IMAGE_SYM_TYPE_UNION  9\r
+#define EFI_IMAGE_SYM_TYPE_ENUM   10  // enumeration.\r
+#define EFI_IMAGE_SYM_TYPE_MOE    11  // member of enumeration.\r
+#define EFI_IMAGE_SYM_TYPE_BYTE   12\r
+#define EFI_IMAGE_SYM_TYPE_WORD   13\r
+#define EFI_IMAGE_SYM_TYPE_UINT   14\r
+#define EFI_IMAGE_SYM_TYPE_DWORD  15\r
+\r
+//\r
+// Type (derived) values.\r
+//\r
+#define EFI_IMAGE_SYM_DTYPE_NULL      0 // no derived type.\r
+#define EFI_IMAGE_SYM_DTYPE_POINTER   1\r
+#define EFI_IMAGE_SYM_DTYPE_FUNCTION  2\r
+#define EFI_IMAGE_SYM_DTYPE_ARRAY     3\r
+\r
+//\r
+// Storage classes.\r
+//\r
+#define EFI_IMAGE_SYM_CLASS_END_OF_FUNCTION   (UINT8) -1\r
+#define EFI_IMAGE_SYM_CLASS_NULL              0\r
+#define EFI_IMAGE_SYM_CLASS_AUTOMATIC         1\r
+#define EFI_IMAGE_SYM_CLASS_EXTERNAL          2\r
+#define EFI_IMAGE_SYM_CLASS_STATIC            3\r
+#define EFI_IMAGE_SYM_CLASS_REGISTER          4\r
+#define EFI_IMAGE_SYM_CLASS_EXTERNAL_DEF      5\r
+#define EFI_IMAGE_SYM_CLASS_LABEL             6\r
+#define EFI_IMAGE_SYM_CLASS_UNDEFINED_LABEL   7\r
+#define EFI_IMAGE_SYM_CLASS_MEMBER_OF_STRUCT  8\r
+#define EFI_IMAGE_SYM_CLASS_ARGUMENT          9\r
+#define EFI_IMAGE_SYM_CLASS_STRUCT_TAG        10\r
+#define EFI_IMAGE_SYM_CLASS_MEMBER_OF_UNION   11\r
+#define EFI_IMAGE_SYM_CLASS_UNION_TAG         12\r
+#define EFI_IMAGE_SYM_CLASS_TYPE_DEFINITION   13\r
+#define EFI_IMAGE_SYM_CLASS_UNDEFINED_STATIC  14\r
+#define EFI_IMAGE_SYM_CLASS_ENUM_TAG          15\r
+#define EFI_IMAGE_SYM_CLASS_MEMBER_OF_ENUM    16\r
+#define EFI_IMAGE_SYM_CLASS_REGISTER_PARAM    17\r
+#define EFI_IMAGE_SYM_CLASS_BIT_FIELD         18\r
+#define EFI_IMAGE_SYM_CLASS_BLOCK             100\r
+#define EFI_IMAGE_SYM_CLASS_FUNCTION          101\r
+#define EFI_IMAGE_SYM_CLASS_END_OF_STRUCT     102\r
+#define EFI_IMAGE_SYM_CLASS_FILE              103\r
+#define EFI_IMAGE_SYM_CLASS_SECTION           104\r
+#define EFI_IMAGE_SYM_CLASS_WEAK_EXTERNAL     105\r
+\r
+//\r
+// type packing constants\r
+//\r
+#define EFI_IMAGE_N_BTMASK  017\r
+#define EFI_IMAGE_N_TMASK   060\r
+#define EFI_IMAGE_N_TMASK1  0300\r
+#define EFI_IMAGE_N_TMASK2  0360\r
+#define EFI_IMAGE_N_BTSHFT  4\r
+#define EFI_IMAGE_N_TSHIFT  2\r
+\r
+//\r
+// Communal selection types.\r
+//\r
+#define EFI_IMAGE_COMDAT_SELECT_NODUPLICATES    1\r
+#define EFI_IMAGE_COMDAT_SELECT_ANY             2\r
+#define EFI_IMAGE_COMDAT_SELECT_SAME_SIZE       3\r
+#define EFI_IMAGE_COMDAT_SELECT_EXACT_MATCH     4\r
+#define EFI_IMAGE_COMDAT_SELECT_ASSOCIATIVE     5\r
+\r
+#define EFI_IMAGE_WEAK_EXTERN_SEARCH_NOLIBRARY  1\r
+#define EFI_IMAGE_WEAK_EXTERN_SEARCH_LIBRARY    2\r
+#define EFI_IMAGE_WEAK_EXTERN_SEARCH_ALIAS      3\r
+\r
+///\r
+/// Relocation format.\r
+///\r
+typedef struct {\r
+  UINT32  VirtualAddress;\r
+  UINT32  SymbolTableIndex;\r
+  UINT16  Type;\r
+} EFI_IMAGE_RELOCATION;\r
+\r
+#define EFI_IMAGE_SIZEOF_RELOCATION 10\r
+\r
+//\r
+// I386 relocation types.\r
+//\r
+#define EFI_IMAGE_REL_I386_ABSOLUTE 0   // Reference is absolute, no relocation is necessary\r
+#define EFI_IMAGE_REL_I386_DIR16    01  // Direct 16-bit reference to the symbols virtual address\r
+#define EFI_IMAGE_REL_I386_REL16    02  // PC-relative 16-bit reference to the symbols virtual address\r
+#define EFI_IMAGE_REL_I386_DIR32    06  // Direct 32-bit reference to the symbols virtual address\r
+#define EFI_IMAGE_REL_I386_DIR32NB  07  // Direct 32-bit reference to the symbols virtual address, base not included\r
+#define EFI_IMAGE_REL_I386_SEG12    011 // Direct 16-bit reference to the segment-selector bits of a 32-bit virtual address\r
+#define EFI_IMAGE_REL_I386_SECTION  012\r
+#define EFI_IMAGE_REL_I386_SECREL   013\r
+#define EFI_IMAGE_REL_I386_REL32    024 // PC-relative 32-bit reference to the symbols virtual address\r
+\r
+///\r
+/// Based relocation format.\r
+///\r
+typedef struct {\r
+  UINT32  VirtualAddress;\r
+  UINT32  SizeOfBlock;\r
+} EFI_IMAGE_BASE_RELOCATION;\r
+\r
+#define EFI_IMAGE_SIZEOF_BASE_RELOCATION  8\r
+\r
+//\r
+// Based relocation types.\r
+//\r
+#define EFI_IMAGE_REL_BASED_ABSOLUTE      0\r
+#define EFI_IMAGE_REL_BASED_HIGH          1\r
+#define EFI_IMAGE_REL_BASED_LOW           2\r
+#define EFI_IMAGE_REL_BASED_HIGHLOW       3\r
+#define EFI_IMAGE_REL_BASED_HIGHADJ       4\r
+#define EFI_IMAGE_REL_BASED_MIPS_JMPADDR  5\r
+#define EFI_IMAGE_REL_BASED_IA64_IMM64    9\r
+#define EFI_IMAGE_REL_BASED_DIR64         10\r
+\r
+///\r
+/// Line number format.\r
+///\r
+typedef struct {\r
+  union {\r
+    UINT32  SymbolTableIndex; // Symbol table index of function name if Linenumber is 0.\r
+    UINT32  VirtualAddress;   // Virtual address of line number.\r
+  } Type;\r
+  UINT16  Linenumber;         // Line number.\r
+} EFI_IMAGE_LINENUMBER;\r
+\r
+#define EFI_IMAGE_SIZEOF_LINENUMBER 6\r
+\r
+//\r
+// Archive format.\r
+//\r
+#define EFI_IMAGE_ARCHIVE_START_SIZE        8\r
+#define EFI_IMAGE_ARCHIVE_START             "!<arch>\n"\r
+#define EFI_IMAGE_ARCHIVE_END               "`\n"\r
+#define EFI_IMAGE_ARCHIVE_PAD               "\n"\r
+#define EFI_IMAGE_ARCHIVE_LINKER_MEMBER     "/               "\r
+#define EFI_IMAGE_ARCHIVE_LONGNAMES_MEMBER  "//              "\r
+\r
+typedef struct {\r
+  UINT8 Name[16];     // File member name - `/' terminated.\r
+  UINT8 Date[12];     // File member date - decimal.\r
+  UINT8 UserID[6];    // File member user id - decimal.\r
+  UINT8 GroupID[6];   // File member group id - decimal.\r
+  UINT8 Mode[8];      // File member mode - octal.\r
+  UINT8 Size[10];     // File member size - decimal.\r
+  UINT8 EndHeader[2]; // String to end header.\r
+} EFI_IMAGE_ARCHIVE_MEMBER_HEADER;\r
+\r
+#define EFI_IMAGE_SIZEOF_ARCHIVE_MEMBER_HDR 60\r
+\r
+//\r
+// DLL support.\r
+//\r
+\r
+///\r
+/// DLL Export Format\r
+///\r
+typedef struct {\r
+  UINT32  Characteristics;\r
+  UINT32  TimeDateStamp;\r
+  UINT16  MajorVersion;\r
+  UINT16  MinorVersion;\r
+  UINT32  Name;\r
+  UINT32  Base;\r
+  UINT32  NumberOfFunctions;\r
+  UINT32  NumberOfNames;\r
+  UINT32  AddressOfFunctions;\r
+  UINT32  AddressOfNames;\r
+  UINT32  AddressOfNameOrdinals;\r
+} EFI_IMAGE_EXPORT_DIRECTORY;\r
+\r
+///\r
+/// DLL support.\r
+/// Import Format\r
+///\r
+typedef struct {\r
+  UINT16  Hint;\r
+  UINT8   Name[1];\r
+} EFI_IMAGE_IMPORT_BY_NAME;\r
+\r
+typedef struct {\r
+  union {\r
+    UINT32                    Function;\r
+    UINT32                    Ordinal;\r
+    EFI_IMAGE_IMPORT_BY_NAME  *AddressOfData;\r
+  } u1;\r
+} EFI_IMAGE_THUNK_DATA;\r
+\r
+#define EFI_IMAGE_ORDINAL_FLAG              0x80000000\r
+#define EFI_IMAGE_SNAP_BY_ORDINAL(Ordinal)  ((Ordinal & EFI_IMAGE_ORDINAL_FLAG) != 0)\r
+#define EFI_IMAGE_ORDINAL(Ordinal)          (Ordinal & 0xffff)\r
+\r
+typedef struct {\r
+  UINT32                Characteristics;\r
+  UINT32                TimeDateStamp;\r
+  UINT32                ForwarderChain;\r
+  UINT32                Name;\r
+  EFI_IMAGE_THUNK_DATA  *FirstThunk;\r
+} EFI_IMAGE_IMPORT_DESCRIPTOR;\r
+\r
+///\r
+/// Debug Format\r
+///\r
+#define EFI_IMAGE_DEBUG_TYPE_CODEVIEW 2\r
+\r
+typedef struct {\r
+  UINT32  Characteristics;\r
+  UINT32  TimeDateStamp;\r
+  UINT16  MajorVersion;\r
+  UINT16  MinorVersion;\r
+  UINT32  Type;\r
+  UINT32  SizeOfData;\r
+  UINT32  RVA;\r
+  UINT32  FileOffset;\r
+} EFI_IMAGE_DEBUG_DIRECTORY_ENTRY;\r
+\r
+#define CODEVIEW_SIGNATURE_NB10 0x3031424E  // "NB10"\r
+typedef struct {\r
+  UINT32  Signature;                        // "NB10"\r
+  UINT32  Unknown;\r
+  UINT32  Unknown2;\r
+  UINT32  Unknown3;\r
+  //\r
+  // Filename of .PDB goes here\r
+  //\r
+} EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY;\r
+\r
+#define CODEVIEW_SIGNATURE_RSDS 0x53445352  // "RSDS"\r
+typedef struct {\r
+  UINT32  Signature;                        // "RSDS"\r
+  UINT32  Unknown;\r
+  UINT32  Unknown2;\r
+  UINT32  Unknown3;\r
+  UINT32  Unknown4;\r
+  UINT32  Unknown5;\r
+  //\r
+  // Filename of .PDB goes here\r
+  //\r
+} EFI_IMAGE_DEBUG_CODEVIEW_RSDS_ENTRY;\r
+\r
+///\r
+/// Header format for TE images\r
+///\r
+typedef struct {\r
+  UINT16                    Signature;            // signature for TE format = "VZ"\r
+  UINT16                    Machine;              // from the original file header\r
+  UINT8                     NumberOfSections;     // from the original file header\r
+  UINT8                     Subsystem;            // from original optional header\r
+  UINT16                    StrippedSize;         // how many bytes we removed from the header\r
+  UINT32                    AddressOfEntryPoint;  // offset to entry point -- from original optional header\r
+  UINT32                    BaseOfCode;           // from original image -- required for ITP debug\r
+  UINT64                    ImageBase;            // from original file header\r
+  EFI_IMAGE_DATA_DIRECTORY  DataDirectory[2];     // only base relocation and debug directory\r
+} EFI_TE_IMAGE_HEADER;\r
+\r
+#define EFI_TE_IMAGE_HEADER_SIGNATURE 0x5A56      // "VZ"\r
+\r
+//\r
+// Data directory indexes in our TE image header\r
+//\r
+#define EFI_TE_IMAGE_DIRECTORY_ENTRY_BASERELOC  0\r
+#define EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG      1\r
+\r
+#endif\r
diff --git a/Tools/CodeTools/Source/PeCoffLoader/Ia32/PeCoffLoaderEx.c b/Tools/CodeTools/Source/PeCoffLoader/Ia32/PeCoffLoaderEx.c
new file mode 100644 (file)
index 0000000..f58e8d0
--- /dev/null
@@ -0,0 +1,56 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+    PeCoffLoaderEx.c\r
+\r
+Abstract:\r
+\r
+    IA-32 Specific relocation fixups\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#include <Common/UefiBaseTypes.h>\r
+\r
+RETURN_STATUS\r
+PeCoffLoaderRelocateImageEx (\r
+  IN UINT16      *Reloc,\r
+  IN OUT CHAR8   *Fixup,\r
+  IN OUT CHAR8   **FixupData,\r
+  IN UINT64      Adjust\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Performs an IA-32 specific relocation fixup\r
+\r
+Arguments:\r
+\r
+  Reloc      - Pointer to the relocation record\r
+\r
+  Fixup      - Pointer to the address to fix up\r
+\r
+  FixupData  - Pointer to a buffer to log the fixups\r
+\r
+  Adjust     - The offset to adjust the fixup\r
+\r
+Returns:\r
+\r
+  EFI_UNSUPPORTED   - Unsupported now\r
+\r
+--*/\r
+{\r
+  return RETURN_UNSUPPORTED;\r
+}\r
diff --git a/Tools/CodeTools/Source/PeCoffLoader/Ipf/PeCoffLoaderEx.c b/Tools/CodeTools/Source/PeCoffLoader/Ipf/PeCoffLoaderEx.c
new file mode 100644 (file)
index 0000000..3f39899
--- /dev/null
@@ -0,0 +1,249 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+    PeCoffLoaderEx.c\r
+\r
+Abstract:\r
+\r
+    Fixes Intel Itanium(TM) specific relocation types\r
+\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#include <Common/UefiBaseTypes.h>\r
+#include <Common/EfiImage.h>\r
+#include <Library/PeCoffLib.h>\r
+\r
+\r
+\r
+\r
+\r
+#define EXT_IMM64(Value, Address, Size, InstPos, ValPos)  \\r
+    Value |= (((UINT64)((*(Address) >> InstPos) & (((UINT64)1 << Size) - 1))) << ValPos)\r
+\r
+#define INS_IMM64(Value, Address, Size, InstPos, ValPos)  \\r
+    *(UINT32*)Address = (*(UINT32*)Address & ~(((1 << Size) - 1) << InstPos)) | \\r
+          ((UINT32)((((UINT64)Value >> ValPos) & (((UINT64)1 << Size) - 1))) << InstPos)\r
+\r
+#define IMM64_IMM7B_INST_WORD_X         3  \r
+#define IMM64_IMM7B_SIZE_X              7  \r
+#define IMM64_IMM7B_INST_WORD_POS_X     4  \r
+#define IMM64_IMM7B_VAL_POS_X           0  \r
+\r
+#define IMM64_IMM9D_INST_WORD_X         3  \r
+#define IMM64_IMM9D_SIZE_X              9  \r
+#define IMM64_IMM9D_INST_WORD_POS_X     18  \r
+#define IMM64_IMM9D_VAL_POS_X           7  \r
+\r
+#define IMM64_IMM5C_INST_WORD_X         3  \r
+#define IMM64_IMM5C_SIZE_X              5  \r
+#define IMM64_IMM5C_INST_WORD_POS_X     13  \r
+#define IMM64_IMM5C_VAL_POS_X           16  \r
+\r
+#define IMM64_IC_INST_WORD_X            3  \r
+#define IMM64_IC_SIZE_X                 1  \r
+#define IMM64_IC_INST_WORD_POS_X        12  \r
+#define IMM64_IC_VAL_POS_X              21  \r
+\r
+#define IMM64_IMM41a_INST_WORD_X        1  \r
+#define IMM64_IMM41a_SIZE_X             10  \r
+#define IMM64_IMM41a_INST_WORD_POS_X    14  \r
+#define IMM64_IMM41a_VAL_POS_X          22  \r
+\r
+#define IMM64_IMM41b_INST_WORD_X        1  \r
+#define IMM64_IMM41b_SIZE_X             8  \r
+#define IMM64_IMM41b_INST_WORD_POS_X    24  \r
+#define IMM64_IMM41b_VAL_POS_X          32  \r
+\r
+#define IMM64_IMM41c_INST_WORD_X        2  \r
+#define IMM64_IMM41c_SIZE_X             23  \r
+#define IMM64_IMM41c_INST_WORD_POS_X    0  \r
+#define IMM64_IMM41c_VAL_POS_X          40  \r
+\r
+#define IMM64_SIGN_INST_WORD_X          3  \r
+#define IMM64_SIGN_SIZE_X               1  \r
+#define IMM64_SIGN_INST_WORD_POS_X      27  \r
+#define IMM64_SIGN_VAL_POS_X            63  \r
+\r
+RETURN_STATUS\r
+PeCoffLoaderRelocateImageEx (\r
+  IN UINT16      *Reloc,\r
+  IN OUT CHAR8   *Fixup, \r
+  IN OUT CHAR8   **FixupData,\r
+  IN UINT64      Adjust\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Performs an Itanium-based specific relocation fixup\r
+\r
+Arguments:\r
+\r
+  Reloc      - Pointer to the relocation record\r
+\r
+  Fixup      - Pointer to the address to fix up\r
+\r
+  FixupData  - Pointer to a buffer to log the fixups\r
+\r
+  Adjust     - The offset to adjust the fixup\r
+\r
+Returns:\r
+\r
+  Status code\r
+\r
+--*/\r
+{\r
+  UINT64      *F64;\r
+  UINT64      FixupVal;\r
+\r
+  switch ((*Reloc) >> 12) {\r
+\r
+    case EFI_IMAGE_REL_BASED_DIR64:\r
+      F64 = (UINT64 *) Fixup;\r
+      *F64 = *F64 + (UINT64) Adjust;\r
+      if (*FixupData != NULL) {\r
+        *FixupData = ALIGN_POINTER(*FixupData, sizeof(UINT64));\r
+        *(UINT64 *)(*FixupData) = *F64;\r
+        *FixupData = *FixupData + sizeof(UINT64);\r
+      }\r
+      break;\r
+\r
+    case EFI_IMAGE_REL_BASED_IA64_IMM64:\r
+\r
+      //\r
+      // Align it to bundle address before fixing up the\r
+      // 64-bit immediate value of the movl instruction.\r
+      //\r
+\r
+      Fixup = (CHAR8 *)((UINTN) Fixup & (UINTN) ~(15));\r
+      FixupVal = (UINT64)0;\r
+                       \r
+      // \r
+      // Extract the lower 32 bits of IMM64 from bundle\r
+      //\r
+      EXT_IMM64(FixupVal,\r
+                (UINT32 *)Fixup + IMM64_IMM7B_INST_WORD_X,\r
+                IMM64_IMM7B_SIZE_X,\r
+                IMM64_IMM7B_INST_WORD_POS_X,\r
+                IMM64_IMM7B_VAL_POS_X\r
+                );\r
+\r
+      EXT_IMM64(FixupVal,\r
+                (UINT32 *)Fixup + IMM64_IMM9D_INST_WORD_X,\r
+                IMM64_IMM9D_SIZE_X,\r
+                IMM64_IMM9D_INST_WORD_POS_X,\r
+                IMM64_IMM9D_VAL_POS_X\r
+                );\r
+\r
+      EXT_IMM64(FixupVal,\r
+                (UINT32 *)Fixup + IMM64_IMM5C_INST_WORD_X,\r
+                IMM64_IMM5C_SIZE_X,\r
+                IMM64_IMM5C_INST_WORD_POS_X,\r
+                IMM64_IMM5C_VAL_POS_X\r
+                );\r
+\r
+      EXT_IMM64(FixupVal,\r
+                (UINT32 *)Fixup + IMM64_IC_INST_WORD_X,\r
+                IMM64_IC_SIZE_X,\r
+                IMM64_IC_INST_WORD_POS_X,\r
+                IMM64_IC_VAL_POS_X\r
+                );\r
+\r
+      EXT_IMM64(FixupVal,\r
+                (UINT32 *)Fixup + IMM64_IMM41a_INST_WORD_X,\r
+                IMM64_IMM41a_SIZE_X,\r
+                IMM64_IMM41a_INST_WORD_POS_X,\r
+                IMM64_IMM41a_VAL_POS_X\r
+                );\r
+                       \r
+      // \r
+      // Update 64-bit address\r
+      //\r
+      FixupVal += Adjust;\r
+\r
+      // \r
+      // Insert IMM64 into bundle\r
+      //\r
+      INS_IMM64(FixupVal,\r
+                ((UINT32 *)Fixup + IMM64_IMM7B_INST_WORD_X),\r
+                IMM64_IMM7B_SIZE_X,\r
+                IMM64_IMM7B_INST_WORD_POS_X,\r
+                IMM64_IMM7B_VAL_POS_X\r
+                );\r
+\r
+      INS_IMM64(FixupVal,\r
+                ((UINT32 *)Fixup + IMM64_IMM9D_INST_WORD_X),\r
+                IMM64_IMM9D_SIZE_X,\r
+                IMM64_IMM9D_INST_WORD_POS_X,\r
+                IMM64_IMM9D_VAL_POS_X\r
+                );\r
+\r
+      INS_IMM64(FixupVal,\r
+                ((UINT32 *)Fixup + IMM64_IMM5C_INST_WORD_X),\r
+                IMM64_IMM5C_SIZE_X,\r
+                IMM64_IMM5C_INST_WORD_POS_X,\r
+                IMM64_IMM5C_VAL_POS_X\r
+                );\r
+\r
+      INS_IMM64(FixupVal,\r
+                ((UINT32 *)Fixup + IMM64_IC_INST_WORD_X),\r
+                IMM64_IC_SIZE_X,\r
+                IMM64_IC_INST_WORD_POS_X,\r
+                IMM64_IC_VAL_POS_X\r
+                );\r
+\r
+      INS_IMM64(FixupVal,\r
+                ((UINT32 *)Fixup + IMM64_IMM41a_INST_WORD_X),\r
+                IMM64_IMM41a_SIZE_X,\r
+                IMM64_IMM41a_INST_WORD_POS_X,\r
+                IMM64_IMM41a_VAL_POS_X\r
+                );\r
+\r
+      INS_IMM64(FixupVal,\r
+                ((UINT32 *)Fixup + IMM64_IMM41b_INST_WORD_X),\r
+                IMM64_IMM41b_SIZE_X,\r
+                IMM64_IMM41b_INST_WORD_POS_X,\r
+                IMM64_IMM41b_VAL_POS_X\r
+                );\r
+\r
+      INS_IMM64(FixupVal,\r
+                ((UINT32 *)Fixup + IMM64_IMM41c_INST_WORD_X),\r
+                IMM64_IMM41c_SIZE_X,\r
+                IMM64_IMM41c_INST_WORD_POS_X,\r
+                IMM64_IMM41c_VAL_POS_X\r
+                );\r
+\r
+      INS_IMM64(FixupVal,\r
+                ((UINT32 *)Fixup + IMM64_SIGN_INST_WORD_X),\r
+                IMM64_SIGN_SIZE_X,\r
+                IMM64_SIGN_INST_WORD_POS_X,\r
+                IMM64_SIGN_VAL_POS_X\r
+                );\r
+\r
+      F64 = (UINT64 *) Fixup;\r
+      if (*FixupData != NULL) {\r
+        *FixupData = ALIGN_POINTER(*FixupData, sizeof(UINT64));\r
+        *(UINT64 *)(*FixupData) = *F64;\r
+        *FixupData = *FixupData + sizeof(UINT64);\r
+      }\r
+      break;\r
+\r
+    default:\r
+      return RETURN_UNSUPPORTED;\r
+  }\r
+\r
+  return RETURN_SUCCESS;\r
+}\r
diff --git a/Tools/CodeTools/Source/PeCoffLoader/X64/PeCoffLoaderEx.c b/Tools/CodeTools/Source/PeCoffLoader/X64/PeCoffLoaderEx.c
new file mode 100644 (file)
index 0000000..1e6cc34
--- /dev/null
@@ -0,0 +1,74 @@
+/*++\r
+\r
+Copyright 2005, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+\r
+Module Name:\r
+\r
+  PeCoffLoaderEx.c\r
+\r
+Abstract:\r
+\r
+  x64 Specific relocation fixups\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#include <Common/UefiBaseTypes.h>\r
+#include <Common/EfiImage.h>\r
+#include <Library/PeCoffLib.h>\r
+\r
+\r
+\r
+\r
+RETURN_STATUS\r
+PeCoffLoaderRelocateImageEx (\r
+  IN UINT16      *Reloc,\r
+  IN OUT CHAR8   *Fixup, \r
+  IN OUT CHAR8   **FixupData,\r
+  IN UINT64      Adjust\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Performs an x64 specific relocation fixup\r
+\r
+Arguments:\r
+  Reloc      - Pointer to the relocation record\r
+  Fixup      - Pointer to the address to fix up\r
+  FixupData  - Pointer to a buffer to log the fixups\r
+  Adjust     - The offset to adjust the fixup\r
+\r
+Returns:\r
+  None\r
+\r
+--*/\r
+{\r
+  UINT64      *F64;\r
+\r
+  switch ((*Reloc) >> 12) {\r
+\r
+    case EFI_IMAGE_REL_BASED_DIR64:\r
+      F64 = (UINT64 *) Fixup;\r
+      *F64 = *F64 + (UINT64) Adjust;\r
+      if (*FixupData != NULL) {\r
+        *FixupData = ALIGN_POINTER(*FixupData, sizeof(UINT64));\r
+        *(UINT64 *)(*FixupData) = *F64;\r
+        *FixupData = *FixupData + sizeof(UINT64);\r
+      }\r
+      break;\r
+\r
+    default:\r
+      return RETURN_UNSUPPORTED;\r
+  }\r
+\r
+  return RETURN_SUCCESS;\r
+}\r
diff --git a/Tools/CodeTools/Source/PeCoffLoader/build.xml b/Tools/CodeTools/Source/PeCoffLoader/build.xml
new file mode 100644 (file)
index 0000000..db37829
--- /dev/null
@@ -0,0 +1,153 @@
+<?xml version="1.0" ?>\r
+<!--\r
+Copyright (c) 2006, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+-->\r
+<project default="GenTool" basedir=".">\r
+<!--\r
+    EDK PeCoffLoader\r
+  Copyright (c) 2006, Intel Corporation\r
+-->\r
+  <taskdef resource="cpptasks.tasks"/>\r
+  <typedef resource="cpptasks.types"/>\r
+  <taskdef resource="net/sf/antcontrib/antlib.xml"/>\r
+\r
+  <property name="LibName" value="PeCoffLoader"/>\r
+  <property name="LINK_OUTPUT_TYPE" value="static"/>\r
+  <property name="BUILD_DIR_IA32" value="${PACKAGE_DIR}/${LibName}/tmp/Ia32"/>\r
+  <property name="BUILD_DIR_X64" value="${PACKAGE_DIR}/${LibName}/tmp/X64"/>\r
+  <property name="BUILD_DIR_IPF" value="${PACKAGE_DIR}/${LibName}/tmp/Ipf"/>\r
+\r
+  <target name="GenTool" depends="init, PeCoffLoaderLib">\r
+    <echo message="The EDK Library: ${LibName} build has completed!"/>\r
+  </target>\r
+\r
+  <target name="init">\r
+    <echo message="Building the EDK Library: ${LibName}"/>\r
+    <mkdir dir="${BUILD_DIR_IA32}"/>\r
+    <mkdir dir="${BUILD_DIR_X64}"/>\r
+    <mkdir dir="${BUILD_DIR_IPF}"/>\r
+\r
+    <condition property="syslibdirs" value="">\r
+      <os family="mac"/>\r
+    </condition>\r
+    \r
+    <condition property="syslibs" value="">\r
+      <os family="mac"/>\r
+    </condition>\r
+    \r
+    <condition property="syslibdirs" value="${env.CYGWIN_HOME}/lib/e2fsprogs">\r
+      <os family="windows"/>\r
+    </condition>\r
+    \r
+    <condition property="syslibs" value="uuid">\r
+      <os family="windows"/>\r
+    </condition>\r
+    \r
+    <condition property="syslibdirs" value="/usr/lib">\r
+      <os name="Linux"/>\r
+    </condition>\r
+    \r
+    <condition property="syslibs" value="uuid">\r
+      <os name="Linux"/>\r
+    </condition>\r
+    \r
+  </target>\r
+\r
+  <target name="PeCoffLoaderLib" depends="init, PeCoffLoader_Ia32, PeCoffLoader_Ipf, PeCoffLoader_X64"/>\r
+\r
+  <target name="PeCoffLoader_Ia32" >\r
+    <cc name="${ToolChain}" objdir="${BUILD_DIR_IA32}" \r
+        outfile="${LIB_DIR}/${LibName}_Ia32"\r
+        outtype="static"\r
+        debug="true"\r
+        optimize="speed">\r
+\r
+      <defineset>\r
+        <define name="BUILDING_TOOLS"/>\r
+        <define name="TOOL_BUILD_IA32_TARGET"/>\r
+      </defineset>\r
+    \r
+      <fileset dir="${basedir}/${LibName}" \r
+        includes="BasePeCoff.c Ia32/PeCoffLoaderEx.c" />\r
+\r
+      <includepath path="${PACKAGE_DIR}/${LibName}"/>\r
+      <includepath path="${PACKAGE_DIR}/Include"/>\r
+      <includepath path="${PACKAGE_DIR}/Include/Ia32"/>\r
+      <includepath path="${PACKAGE_DIR}/Common"/>\r
+    </cc>\r
+  </target>\r
+\r
+  <target name="PeCoffLoader_Ipf" >\r
+    <cc name="${ToolChain}" objdir="${BUILD_DIR_IPF}" \r
+        outfile="${LIB_DIR}/${LibName}_Ipf"\r
+        outtype="static"\r
+        debug="true"\r
+        optimize="speed">\r
+\r
+      <defineset>\r
+        <define name="BUILDING_TOOLS"/>\r
+        <define name="TOOL_BUILD_IPF_TARGET"/>\r
+      </defineset>\r
+    \r
+      <fileset dir="${basedir}/${LibName}" \r
+        includes="BasePeCoff.c Ipf/PeCoffLoaderEx.c" />\r
+\r
+      <includepath path="${PACKAGE_DIR}/${LibName}"/>\r
+      <includepath path="${PACKAGE_DIR}/Include"/>\r
+      <includepath path="${PACKAGE_DIR}/Include/Ia32"/>\r
+      <includepath path="${PACKAGE_DIR}/Common"/>\r
+    </cc>\r
+  </target>\r
+\r
+  <target name="PeCoffLoader_X64" >\r
+    <cc name="${ToolChain}" objdir="${BUILD_DIR_X64}" \r
+        outfile="${LIB_DIR}/${LibName}_X64"\r
+        outtype="static"\r
+        debug="true"\r
+        optimize="speed">\r
+\r
+      <defineset>\r
+        <define name="BUILDING_TOOLS"/>\r
+        <define name="TOOL_BUILD_X64_TARGET"/>\r
+      </defineset>\r
+    \r
+      <fileset dir="${basedir}/${LibName}" \r
+        includes="BasePeCoff.c X64/PeCoffLoaderEx.c" />\r
+\r
+      <includepath path="${PACKAGE_DIR}/${LibName}"/>\r
+      <includepath path="${PACKAGE_DIR}/Include"/>\r
+      <includepath path="${PACKAGE_DIR}/Include/Ia32"/>\r
+      <includepath path="${PACKAGE_DIR}/Common"/>\r
+    </cc>\r
+  </target>\r
+\r
+\r
+  <target name="clean">\r
+    <echo message="Removing Intermediate Files Only"/>  \r
+    <delete>\r
+      <fileset dir="${BUILD_DIR_IA32}" includes="*.obj"/>\r
+      <fileset dir="${BUILD_DIR_X64}" includes="*.obj"/>\r
+      <fileset dir="${BUILD_DIR_IPF}" includes="*.obj"/>\r
+    </delete>\r
+  </target>\r
+\r
+  <target name="cleanall">\r
+    <echo message="Removing Object Files and the Executable: ${LibName}${ext_exe}"/>  \r
+    <delete dir="${PACKAGE_DIR}/${LibName}/tmp">\r
+    </delete>\r
+    <delete failonerror="false" quiet="true" includeEmptyDirs="true">\r
+      <fileset dir="${BUILD_DIR}"/>\r
+      <fileset file="${LIB_DIR}/${LibName}_Ia32${ext_static}"/>\r
+      <fileset file="${BIN_DIR}/${LibName}_X64${ext_static}"/>\r
+      <fileset file="${BIN_DIR}/${LibName}_IPF${ext_static}"/>\r
+    </delete>\r
+  </target>\r
+\r
+</project>\r
diff --git a/Tools/CodeTools/Source/PeiRebase/PeiRebaseExe.c b/Tools/CodeTools/Source/PeiRebase/PeiRebaseExe.c
new file mode 100644 (file)
index 0000000..27c646e
--- /dev/null
@@ -0,0 +1,1059 @@
+/*++\r
+\r
+Copyright (c)  1999-2006 Intel Corporation. All rights reserved\r
+This program and the accompanying materials are licensed and made available \r
+under the terms and conditions of the BSD License which accompanies this \r
+distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+\r
+Module Name:\r
+\r
+  PeiRebaseExe.c\r
+\r
+Abstract:\r
+\r
+  This contains all code necessary to build the PeiRebase.exe utility.\r
+  This utility relies heavily on the PeiRebase DLL.  Definitions for both\r
+  can be found in the PEI Rebase Utility Specification, review draft.\r
+\r
+--*/\r
+\r
+#include <stdlib.h>\r
+#include <stdio.h>\r
+#include <string.h>\r
+\r
+#include <Common/UefiBaseTypes.h>\r
+#include <Common/FirmwareVolumeImageFormat.h>\r
+#include <Common/FirmwareFileSystem.h>\r
+#include <Library/PeCoffLib.h>\r
+\r
+#include "CommonLib.h"\r
+#include "ParseInf.h"\r
+#include "FvLib.h"\r
+#include "EfiUtilityMsgs.h"\r
+#include "PeiRebaseExe.h"\r
+\r
+EFI_STATUS\r
+ReadHeader (\r
+  IN FILE       *InputFile,\r
+  OUT UINT32    *FvSize,\r
+  OUT BOOLEAN   *ErasePolarity\r
+  );\r
+\r
+int\r
+main (\r
+  int  argc,\r
+  char **argv\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This utility relocates PEI XIP PE32s in a FV.\r
+\r
+Arguments:\r
+\r
+  argc          - Number of command line arguments\r
+  argv[]:\r
+  BaseAddress     The base address to use for rebasing the FV.  The correct \r
+                  format is a hex number preceded by 0x.\r
+  InputFileName   The name of the input FV file.\r
+  OutputFileName  The name of the output FV file.\r
+  MapFileName     The name of the map file of relocation info.\r
+\r
+  Arguments come in pair in any order.\r
+    -I InputFileName \r
+    -O OutputFileName\r
+    -B BaseAddress \r
+    -M MapFileName \r
+\r
+Returns:\r
+\r
+  0   No error conditions detected.\r
+  1   One or more of the input parameters is invalid.\r
+  2   A resource required by the utility was unavailable.  \r
+      Most commonly this will be memory allocation or file creation.\r
+  3   PeiRebase.dll could not be loaded.\r
+  4   Error executing the PEI rebase.\r
+\r
+--*/\r
+{\r
+  UINT8                       Index;\r
+  CHAR8                       InputFileName[_MAX_PATH];\r
+  CHAR8                       OutputFileName[_MAX_PATH];\r
+  CHAR8                       MapFileName[_MAX_PATH];\r
+  EFI_PHYSICAL_ADDRESS        BaseAddress;\r
+  BOOLEAN                     BaseAddressSet;\r
+  EFI_STATUS                  Status;\r
+  FILE                        *InputFile;\r
+  FILE                        *OutputFile;\r
+  FILE                        *MapFile;\r
+  UINT64                      FvOffset;\r
+  UINT32                      FileCount;\r
+  int                         BytesRead;\r
+  EFI_FIRMWARE_VOLUME_HEADER  *FvImage;\r
+  UINT32                      FvSize;\r
+  EFI_FFS_FILE_HEADER         *CurrentFile;\r
+  BOOLEAN                     ErasePolarity;\r
+  EFI_PHYSICAL_ADDRESS        CurrentFileBaseAddress;\r
+\r
+  ErasePolarity = FALSE;\r
+  //\r
+  // Set utility name for error/warning reporting purposes.\r
+  //\r
+  SetUtilityName (UTILITY_NAME);\r
+  //\r
+  // Verify the correct number of arguments\r
+  //\r
+  if (argc != MAX_ARGS) {\r
+    PrintUsage ();\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  //\r
+  // Initialize variables\r
+  //\r
+  InputFileName[0]  = 0;\r
+  OutputFileName[0] = 0;\r
+  MapFileName[0]    = 0;\r
+  BaseAddress       = 0;\r
+  BaseAddressSet    = FALSE;\r
+  FvOffset          = 0;\r
+  FileCount         = 0;\r
+  ErasePolarity     = FALSE;\r
+  InputFile         = NULL;\r
+  OutputFile        = NULL;\r
+  MapFile           = NULL;\r
+  FvImage           = NULL;\r
+\r
+  //\r
+  // Parse the command line arguments\r
+  //\r
+  for (Index = 1; Index < MAX_ARGS; Index += 2) {\r
+    //\r
+    // Make sure argument pair begin with - or /\r
+    //\r
+    if (argv[Index][0] != '-' && argv[Index][0] != '/') {\r
+      PrintUsage ();\r
+      Error (NULL, 0, 0, argv[Index], "unrecognized option");\r
+      return STATUS_ERROR;\r
+    }\r
+    //\r
+    // Make sure argument specifier is only one letter\r
+    //\r
+    if (argv[Index][2] != 0) {\r
+      PrintUsage ();\r
+      Error (NULL, 0, 0, argv[Index], "unrecognized option");\r
+      return STATUS_ERROR;\r
+    }    \r
+    //\r
+    // Determine argument to read\r
+    //\r
+    switch (argv[Index][1]) {\r
+    case 'I':\r
+    case 'i':\r
+      if (strlen (InputFileName) == 0) {\r
+        strcpy (InputFileName, argv[Index + 1]);\r
+      } else {\r
+        PrintUsage ();\r
+        Error (NULL, 0, 0, argv[Index + 1], "only one -i InputFileName may be specified");\r
+        return STATUS_ERROR;\r
+      }\r
+      break;\r
+\r
+    case 'O':\r
+    case 'o':\r
+      if (strlen (OutputFileName) == 0) {\r
+        strcpy (OutputFileName, argv[Index + 1]);\r
+      } else {\r
+        PrintUsage ();\r
+        Error (NULL, 0, 0, argv[Index + 1], "only one -o OutputFileName may be specified");\r
+        return STATUS_ERROR;\r
+      }\r
+      break;\r
+\r
+    case 'B':\r
+    case 'b':\r
+      if (!BaseAddressSet) {\r
+        Status = AsciiStringToUint64 (argv[Index + 1], FALSE, &BaseAddress);\r
+        if (EFI_ERROR (Status)) {\r
+          PrintUsage ();\r
+          Error (NULL, 0, 0, argv[Index + 1], "invalid hex digit given for the base address");\r
+          return STATUS_ERROR;\r
+        }\r
+\r
+        BaseAddressSet = TRUE;\r
+      } else {\r
+        PrintUsage ();\r
+        Error (NULL, 0, 0, argv[Index + 1], "-b BaseAddress may only be specified once");\r
+        return STATUS_ERROR;\r
+      }\r
+      break;\r
+\r
+    case 'M':\r
+    case 'm':\r
+      if (strlen (MapFileName) == 0) {\r
+        strcpy (MapFileName, argv[Index + 1]);\r
+      } else {\r
+        PrintUsage ();\r
+        Error (NULL, 0, 0, argv[Index + 1], "only one -m MapFileName may be specified");\r
+        return STATUS_ERROR;\r
+      }\r
+      break;\r
+\r
+    default:\r
+      PrintUsage ();\r
+      Error (NULL, 0, 0, argv[Index], "unrecognized argument");\r
+      return STATUS_ERROR;\r
+      break;\r
+    }\r
+  }\r
+\r
+  //\r
+  // Create the Map file if we need it\r
+  //\r
+  if (strlen (MapFileName) != 0) {\r
+    MapFile = fopen (MapFileName, "w");\r
+    if (MapFile == NULL) {\r
+      Error (NULL, 0, 0, MapFileName, "failed to open map file");\r
+      goto Finish;\r
+    }\r
+  } \r
+\r
+  //\r
+  // Open the file containing the FV\r
+  //\r
+  InputFile = fopen (InputFileName, "rb");\r
+  if (InputFile == NULL) {\r
+    Error (NULL, 0, 0, InputFileName, "could not open input file for reading");\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Determine size of FV\r
+  //\r
+  Status = ReadHeader (InputFile, &FvSize, &ErasePolarity);\r
+  if (EFI_ERROR (Status)) {\r
+    Error (NULL, 0, 0, "could not parse the FV header", NULL);\r
+    goto Finish;\r
+  }\r
+  //\r
+  // Allocate a buffer for the FV image\r
+  //\r
+  FvImage = malloc (FvSize);\r
+  if (FvImage == NULL) {\r
+    Error (NULL, 0, 0, "application error", "memory allocation failed");\r
+    goto Finish;\r
+  }\r
+  //\r
+  // Read the entire FV to the buffer\r
+  //\r
+  BytesRead = fread (FvImage, 1, FvSize, InputFile);\r
+  fclose (InputFile);\r
+  InputFile = NULL;\r
+  if ((unsigned int) BytesRead != FvSize) {\r
+    Error (NULL, 0, 0, InputFileName, "failed to read from file");\r
+    goto Finish;\r
+  }\r
+  //\r
+  // Prepare to walk the FV image\r
+  //\r
+  InitializeFvLib (FvImage, FvSize);\r
+  //\r
+  // Get the first file\r
+  //\r
+  Status = GetNextFile (NULL, &CurrentFile);\r
+  if (EFI_ERROR (Status)) {\r
+    Error (NULL, 0, 0, "cannot find the first file in the FV image", NULL);\r
+    goto Finish;\r
+  }\r
+  //\r
+  // Check if each file should be rebased\r
+  //\r
+  while (CurrentFile != NULL) {\r
+    //\r
+    // Rebase this file\r
+    //\r
+    CurrentFileBaseAddress  = BaseAddress + ((UINTN) CurrentFile - (UINTN) FvImage);\r
+    Status                  = FfsRebase (CurrentFile, CurrentFileBaseAddress, MapFile);\r
+\r
+    if (EFI_ERROR (Status)) {\r
+      switch (Status) {\r
+\r
+      case EFI_INVALID_PARAMETER:\r
+        Error (NULL, 0, 0, "invalid parameter passed to FfsRebase", NULL);\r
+        break;\r
+\r
+      case EFI_ABORTED:\r
+        Error (NULL, 0, 0, "error detected while rebasing -- aborted", NULL);\r
+        break;\r
+\r
+      case EFI_OUT_OF_RESOURCES:\r
+        Error (NULL, 0, 0, "FfsRebase could not allocate required resources", NULL);\r
+        break;\r
+\r
+      case EFI_NOT_FOUND:\r
+        Error (NULL, 0, 0, "FfsRebase could not locate a PE32 section", NULL);\r
+        break;\r
+\r
+      default:\r
+        Error (NULL, 0, 0, "FfsRebase returned unknown status", "status=0x%08X", Status);\r
+        break;\r
+      }\r
+\r
+      goto Finish;\r
+    }\r
+\r
+    //\r
+    // Get the next file\r
+    //\r
+    Status = GetNextFile (CurrentFile, &CurrentFile);\r
+    if (EFI_ERROR (Status)) {\r
+      Error (NULL, 0, 0, "cannot find the next file in the FV image", NULL);\r
+      goto Finish;\r
+    }\r
+  }\r
+  //\r
+  // Open the output file\r
+  //\r
+  OutputFile = fopen (OutputFileName, "wb");\r
+  if (OutputFile == NULL) {\r
+    Error (NULL, 0, 0, OutputFileName, "failed to open output file");\r
+    goto Finish;\r
+  }\r
+\r
+  if (fwrite (FvImage, 1, FvSize, OutputFile) != FvSize) {\r
+    Error (NULL, 0, 0, "failed to write to output file", 0);\r
+    goto Finish;\r
+  }\r
+\r
+Finish:\r
+  if (InputFile != NULL) {\r
+    fclose (InputFile);\r
+  }\r
+  //\r
+  // If we created an output file, and there was an error, remove it so\r
+  // subsequent builds will rebuild it.\r
+  //\r
+  if (OutputFile != NULL) {\r
+    if (GetUtilityStatus () == STATUS_ERROR) {\r
+      remove (OutputFileName);\r
+    }\r
+\r
+    fclose (OutputFile);\r
+  }\r
+\r
+  if (MapFile != NULL) {\r
+    fclose (MapFile);\r
+  }\r
+\r
+  if (FvImage != NULL) {\r
+    free (FvImage);\r
+  }\r
+\r
+  return GetUtilityStatus ();\r
+}\r
+\r
+EFI_STATUS\r
+ReadHeader (\r
+  IN FILE       *InputFile,\r
+  OUT UINT32    *FvSize,\r
+  OUT BOOLEAN   *ErasePolarity\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function determines the size of the FV and the erase polarity.  The \r
+  erase polarity is the FALSE value for file state.\r
+\r
+Arguments:\r
+\r
+  InputFile       The file that contains the FV image.\r
+  FvSize          The size of the FV.\r
+  ErasePolarity   The FV erase polarity.\r
+    \r
+Returns:\r
\r
+  EFI_SUCCESS             Function completed successfully.\r
+  EFI_INVALID_PARAMETER   A required parameter was NULL or is out of range.\r
+  EFI_ABORTED             The function encountered an error.\r
+\r
+--*/\r
+{\r
+  EFI_FIRMWARE_VOLUME_HEADER  VolumeHeader;\r
+  EFI_FV_BLOCK_MAP_ENTRY      BlockMap;\r
+  UINTN                       Signature[2];\r
+  UINTN                       BytesRead;\r
+  UINT32                      Size;\r
+\r
+  BytesRead = 0;\r
+  Size      = 0;\r
+  //\r
+  // Check input parameters\r
+  //\r
+  if ((InputFile == NULL) || (FvSize == NULL) || (ErasePolarity == NULL)) {\r
+    Error (NULL, 0, 0, "ReadHeader()", "invalid input parameter");\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+  //\r
+  // Read the header\r
+  //\r
+  fread (&VolumeHeader, sizeof (EFI_FIRMWARE_VOLUME_HEADER) - sizeof (EFI_FV_BLOCK_MAP_ENTRY), 1, InputFile);\r
+  BytesRead     = sizeof (EFI_FIRMWARE_VOLUME_HEADER) - sizeof (EFI_FV_BLOCK_MAP_ENTRY);\r
+  Signature[0]  = VolumeHeader.Signature;\r
+  Signature[1]  = 0;\r
+\r
+  //\r
+  // Get erase polarity\r
+  //\r
+  if (VolumeHeader.Attributes & EFI_FVB_ERASE_POLARITY) {\r
+    *ErasePolarity = TRUE;\r
+  }\r
+\r
+  do {\r
+    fread (&BlockMap, sizeof (EFI_FV_BLOCK_MAP_ENTRY), 1, InputFile);\r
+    BytesRead += sizeof (EFI_FV_BLOCK_MAP_ENTRY);\r
+\r
+    if (BlockMap.NumBlocks != 0) {\r
+      Size += BlockMap.NumBlocks * BlockMap.BlockLength;\r
+    }\r
+\r
+  } while (!(BlockMap.NumBlocks == 0 && BlockMap.BlockLength == 0));\r
+\r
+  if (VolumeHeader.FvLength != Size) {\r
+    Error (NULL, 0, 0, "volume size not consistant with block maps", NULL);\r
+    return EFI_ABORTED;\r
+  }\r
+\r
+  *FvSize = Size;\r
+\r
+  rewind (InputFile);\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+VOID\r
+PrintUtilityInfo (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Displays the standard utility information to SDTOUT\r
+\r
+Arguments:\r
+\r
+  None\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+{\r
+  printf (\r
+    "%s, PEI Rebase Utility. Version %i.%i, %s.\n\n",\r
+    UTILITY_NAME,\r
+    UTILITY_MAJOR_VERSION,\r
+    UTILITY_MINOR_VERSION,\r
+    UTILITY_DATE\r
+    );\r
+}\r
+\r
+VOID\r
+PrintUsage (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Displays the utility usage syntax to STDOUT\r
+\r
+Arguments:\r
+\r
+  None\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+{\r
+  printf (\r
+    "Usage: %s -I InputFileName -O OutputFileName -B BaseAddress [-M MapFile]\n",\r
+    UTILITY_NAME\r
+    );\r
+  printf ("  Where:\n");\r
+  printf ("    InputFileName is the name of the EFI FV file to rebase.\n");\r
+  printf ("    OutputFileName is the desired output file name.\n");\r
+  printf ("    BaseAddress is the FV base address to rebase agains.\n");\r
+  printf ("    MapFileName is an optional map file of the relocations\n");\r
+  printf ("  Argument pair may be in any order.\n\n");\r
+}\r
+\r
+EFI_STATUS\r
+FfsRebase (\r
+  IN OUT EFI_FFS_FILE_HEADER    *FfsFile,\r
+  IN EFI_PHYSICAL_ADDRESS       BaseAddress,\r
+  IN FILE                       *MapFile      OPTIONAL\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function determines if a file is XIP and should be rebased.  It will \r
+  rebase any PE32 sections found in the file using the base address.\r
+  \r
+Arguments:\r
+\r
+  FfsFile           A pointer to Ffs file image.\r
+  BaseAddress       The base address to use for rebasing the file image.\r
+  MapFile           Optional file to dump relocation information into\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS             The image was properly rebased.\r
+  EFI_INVALID_PARAMETER   An input parameter is invalid.\r
+  EFI_ABORTED             An error occurred while rebasing the input file image.\r
+  EFI_OUT_OF_RESOURCES    Could not allocate a required resource.\r
+  EFI_NOT_FOUND           No compressed sections could be found.\r
+\r
+--*/\r
+{\r
+  EFI_STATUS                            Status;\r
+  PE_COFF_LOADER_IMAGE_CONTEXT          ImageContext;\r
+  UINTN                                 MemoryImagePointer;\r
+  UINTN                                 MemoryImagePointerAligned;\r
+  EFI_PHYSICAL_ADDRESS                  ImageAddress;\r
+  UINT64                                ImageSize;\r
+  EFI_PHYSICAL_ADDRESS                  EntryPoint;\r
+  UINT32                                Pe32ImageSize;\r
+  UINT32                                NewPe32BaseAddress;\r
+  UINTN                                 Index;\r
+  EFI_FILE_SECTION_POINTER              CurrentPe32Section;\r
+  EFI_FFS_FILE_STATE                    SavedState;\r
+  EFI_IMAGE_NT_HEADERS                  *PeHdr;\r
+  UINT32                                *PeHdrSizeOfImage;\r
+  UINT32                                *PeHdrChecksum;\r
+  UINT32                                FoundCount;\r
+  EFI_TE_IMAGE_HEADER                   *TEImageHeader;\r
+  UINT8                                 *TEBuffer;\r
+  EFI_IMAGE_DOS_HEADER                  *DosHeader;\r
+  UINT8                                 FileGuidString[80];\r
+  UINT32                                TailSize;\r
+  EFI_FFS_FILE_TAIL                     TailValue;\r
+\r
+  //\r
+  // Verify input parameters\r
+  //\r
+  if (FfsFile == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+  \r
+  //\r
+  // Convert the GUID to a string so we can at least report which file\r
+  // if we find an error.\r
+  //\r
+  PrintGuidToBuffer (&FfsFile->Name, FileGuidString, sizeof (FileGuidString), TRUE);\r
+  if (FfsFile->Attributes & FFS_ATTRIB_TAIL_PRESENT) {\r
+    TailSize = sizeof (EFI_FFS_FILE_TAIL);\r
+  } else {\r
+    TailSize = 0;\r
+  }\r
+  \r
+  //\r
+  // Do some cursory checks on the FFS file contents\r
+  //\r
+  Status = VerifyFfsFile (FfsFile);\r
+  if (EFI_ERROR (Status)) {\r
+    Error (NULL, 0, 0, "file does not appear to be a valid FFS file, cannot be rebased", FileGuidString);\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  memset (&ImageContext, 0, sizeof (ImageContext));\r
+\r
+  //\r
+  // Check if XIP file type. If not XIP, don't rebase.\r
+  //\r
+  if (FfsFile->Type != EFI_FV_FILETYPE_PEI_CORE &&\r
+      FfsFile->Type != EFI_FV_FILETYPE_PEIM &&\r
+      FfsFile->Type != EFI_FV_FILETYPE_SECURITY_CORE &&\r
+      FfsFile->Type != EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER\r
+      ) {\r
+    return EFI_SUCCESS;\r
+  }\r
+\r
+  //\r
+  // Rebase each PE32 section\r
+  //\r
+  Status      = EFI_SUCCESS;\r
+  FoundCount  = 0;\r
+  for (Index = 1;; Index++) {\r
+    Status = GetSectionByType (FfsFile, EFI_SECTION_PE32, Index, &CurrentPe32Section);\r
+    if (EFI_ERROR (Status)) {\r
+      break;\r
+    }\r
+\r
+    FoundCount++;\r
+\r
+    //\r
+    // Calculate the PE32 base address, the FFS file base plus the offset of the PE32 section\r
+    //\r
+    NewPe32BaseAddress = ((UINT32) BaseAddress) + ((UINTN) CurrentPe32Section.Pe32Section + sizeof (EFI_COMMON_SECTION_HEADER) - (UINTN) FfsFile);\r
+\r
+    //\r
+    // Initialize context\r
+    //\r
+    memset (&ImageContext, 0, sizeof (ImageContext));\r
+    ImageContext.Handle     = (VOID *) ((UINTN) CurrentPe32Section.Pe32Section + sizeof (EFI_PE32_SECTION));\r
+    ImageContext.ImageRead  = (PE_COFF_LOADER_READ_FILE) FfsRebaseImageRead;\r
+\r
+    Status                  = PeCoffLoaderGetImageInfo (&ImageContext);\r
+\r
+    if (EFI_ERROR (Status)) {\r
+      Error (NULL, 0, 0, "GetImageInfo() call failed on rebase", FileGuidString);\r
+      return Status;\r
+    }\r
+    //\r
+    // Allocate a buffer for the image to be loaded into.\r
+    //\r
+    Pe32ImageSize       = GetLength (CurrentPe32Section.Pe32Section->CommonHeader.Size) - sizeof (EFI_PE32_SECTION);\r
+    MemoryImagePointer  = (UINTN) (malloc (Pe32ImageSize + 0x1000));\r
+    if (MemoryImagePointer == 0) {\r
+      Error (NULL, 0, 0, "memory allocation failure", NULL);\r
+      return EFI_OUT_OF_RESOURCES;\r
+    }\r
+    memset ((void *) MemoryImagePointer, 0, Pe32ImageSize + 0x1000);\r
+    MemoryImagePointerAligned = (MemoryImagePointer + 0x0FFF) & (-1 << 12);\r
+    \r
+\r
+    ImageContext.ImageAddress = MemoryImagePointerAligned;\r
+\r
+    Status                    = PeCoffLoaderLoadImage (&ImageContext);\r
+    if (EFI_ERROR (Status)) {\r
+      Error (NULL, 0, 0, "LoadImage() call failed on rebase", FileGuidString);\r
+      free ((VOID *) MemoryImagePointer);\r
+      return Status;\r
+    }\r
+\r
+    ImageContext.DestinationAddress = NewPe32BaseAddress;\r
+    Status                          = PeCoffLoaderRelocateImage (&ImageContext);\r
+    if (EFI_ERROR (Status)) {\r
+      Error (NULL, 0, 0, "RelocateImage() call failed on rebase", FileGuidString);\r
+      free ((VOID *) MemoryImagePointer);\r
+      return Status;\r
+    }\r
+\r
+    ImageAddress  = ImageContext.ImageAddress;\r
+    ImageSize     = ImageContext.ImageSize;\r
+    EntryPoint    = ImageContext.EntryPoint;\r
+\r
+    if (ImageSize > Pe32ImageSize) {\r
+      Error (\r
+        NULL,\r
+        0,\r
+        0,\r
+        "rebased image is larger than original PE32 image",\r
+        "0x%X > 0x%X, file %s",\r
+        ImageSize,\r
+        Pe32ImageSize,\r
+        FileGuidString\r
+        );\r
+      free ((VOID *) MemoryImagePointer);\r
+      return EFI_ABORTED;\r
+    }\r
+    //\r
+    // Since we may have updated the Codeview RVA, we need to insure the PE\r
+    // header indicates the image is large enough to contain the Codeview data\r
+    // so it will be loaded properly later if the PEIM is reloaded into memory...\r
+    //\r
+    PeHdr = (VOID *) ((UINTN) ImageAddress + ImageContext.PeCoffHeaderOffset);\r
+    if (PeHdr->FileHeader.Machine == EFI_IMAGE_MACHINE_IA32) {\r
+      PeHdrSizeOfImage     = (UINT32 *) (&(*(EFI_IMAGE_OPTIONAL_HEADER32 *) &PeHdr->OptionalHeader).SizeOfImage);\r
+      PeHdrChecksum        = (UINT32 *) (&(*(EFI_IMAGE_OPTIONAL_HEADER32 *) &PeHdr->OptionalHeader).CheckSum);\r
+    } else if (PeHdr->FileHeader.Machine == EFI_IMAGE_MACHINE_IA64) {\r
+      PeHdrSizeOfImage     = (UINT32 *) (&(*(EFI_IMAGE_OPTIONAL_HEADER64 *) &PeHdr->OptionalHeader).SizeOfImage);\r
+      PeHdrChecksum        = (UINT32 *) (&(*(EFI_IMAGE_OPTIONAL_HEADER64 *) &PeHdr->OptionalHeader).CheckSum);\r
+    } else if (PeHdr->FileHeader.Machine == EFI_IMAGE_MACHINE_X64) {\r
+      PeHdrSizeOfImage     = (UINT32 *) (&(*(EFI_IMAGE_OPTIONAL_HEADER64 *) &PeHdr->OptionalHeader).SizeOfImage);\r
+      PeHdrChecksum        = (UINT32 *) (&(*(EFI_IMAGE_OPTIONAL_HEADER64 *) &PeHdr->OptionalHeader).CheckSum);\r
+    } else {\r
+      Error (\r
+        NULL,\r
+        0,\r
+        0,\r
+        "unknown machine type in PE32 image",\r
+        "machine type=0x%X, file=%s",\r
+        (UINT32) PeHdr->FileHeader.Machine,\r
+        FileGuidString\r
+        );\r
+      free ((VOID *) MemoryImagePointer);\r
+      return EFI_ABORTED;\r
+    }\r
+\r
+    if (*PeHdrSizeOfImage != ImageContext.ImageSize) {\r
+      *PeHdrSizeOfImage = (UINT32) ImageContext.ImageSize;\r
+      if (*PeHdrChecksum) {\r
+        *PeHdrChecksum = 0;\r
+      }\r
+    }\r
+\r
+    memcpy (CurrentPe32Section.Pe32Section + 1, (VOID *) MemoryImagePointerAligned, (UINT32) ImageSize);\r
+    \r
+    //\r
+    // Get EntryPoint in Flash Region.\r
+    //\r
+    EntryPoint = NewPe32BaseAddress + EntryPoint - ImageAddress;\r
+\r
+    //\r
+    // If a map file was selected output mapping information for any file that\r
+    // was rebased.\r
+    //\r
+    if (MapFile != NULL) {\r
+      fprintf (MapFile, "PE32 File: %s Base:%08lx", FileGuidString, BaseAddress);\r
+      fprintf (MapFile, " EntryPoint:%08lx", EntryPoint);\r
+      if (ImageContext.PdbPointer != NULL) {\r
+        fprintf (MapFile, " FileName: %s", ImageContext.PdbPointer);\r
+      }\r
+      fprintf (MapFile, "\n");\r
+    }\r
+\r
+    free ((VOID *) MemoryImagePointer);\r
+\r
+    //\r
+    // Now update file checksum\r
+    //\r
+    if (FfsFile->Attributes & FFS_ATTRIB_TAIL_PRESENT) {\r
+      TailSize = sizeof (EFI_FFS_FILE_TAIL);\r
+    } else {\r
+      TailSize = 0;\r
+    }\r
+\r
+    if (FfsFile->Attributes & FFS_ATTRIB_CHECKSUM) {\r
+      SavedState  = FfsFile->State;\r
+      FfsFile->IntegrityCheck.Checksum.File = 0;\r
+      FfsFile->State                        = 0;\r
+      if (FfsFile->Attributes & FFS_ATTRIB_CHECKSUM) {\r
+        FfsFile->IntegrityCheck.Checksum.File = CalculateChecksum8 (\r
+                                                  (UINT8 *) FfsFile,\r
+                                                  GetLength (FfsFile->Size) - TailSize\r
+                                                  );\r
+      } else {\r
+        FfsFile->IntegrityCheck.Checksum.File = FFS_FIXED_CHECKSUM;\r
+      }\r
+\r
+      FfsFile->State = SavedState;\r
+    }\r
+    //\r
+    // Update tail if present\r
+    //\r
+    if (FfsFile->Attributes & FFS_ATTRIB_TAIL_PRESENT) {\r
+      TailValue = (EFI_FFS_FILE_TAIL) (~(FfsFile->IntegrityCheck.TailReference));\r
+      *(EFI_FFS_FILE_TAIL *) (((UINTN) FfsFile + GetLength (FfsFile->Size) - sizeof (EFI_FFS_FILE_TAIL))) = TailValue;\r
+    }\r
+  }\r
+  //\r
+  // Now process TE sections\r
+  //\r
+  for (Index = 1;; Index++) {\r
+    Status = GetSectionByType (FfsFile, EFI_SECTION_TE, Index, &CurrentPe32Section);\r
+    if (EFI_ERROR (Status)) {\r
+      break;\r
+    }\r
+\r
+    FoundCount++;\r
+\r
+    //\r
+    // Calculate the TE base address, the FFS file base plus the offset of the TE section less the size stripped off\r
+    // by GenTEImage\r
+    //\r
+    TEImageHeader = (EFI_TE_IMAGE_HEADER *) ((UINT8 *) CurrentPe32Section.Pe32Section + sizeof (EFI_COMMON_SECTION_HEADER));\r
+\r
+    NewPe32BaseAddress = ((UINT32) BaseAddress) +\r
+      (\r
+        (UINTN) CurrentPe32Section.Pe32Section +\r
+        sizeof (EFI_COMMON_SECTION_HEADER) +\r
+        sizeof (EFI_TE_IMAGE_HEADER) -\r
+        TEImageHeader->StrippedSize -\r
+        (UINTN) FfsFile\r
+      );\r
+\r
+    //\r
+    // Allocate a buffer to unshrink the image into.\r
+    //\r
+    Pe32ImageSize = GetLength (CurrentPe32Section.Pe32Section->CommonHeader.Size) - sizeof (EFI_PE32_SECTION) -\r
+    sizeof (EFI_TE_IMAGE_HEADER);\r
+    Pe32ImageSize += TEImageHeader->StrippedSize;\r
+    TEBuffer = (UINT8 *) malloc (Pe32ImageSize);\r
+    if (TEBuffer == NULL) {\r
+      Error (NULL, 0, 0, "failed to allocate memory", NULL);\r
+      return EFI_OUT_OF_RESOURCES;\r
+    }\r
+    //\r
+    // Expand the image into our buffer and fill in critical fields in the DOS header\r
+    // Fill in fields required by the loader.\r
+    // At offset 0x3C is the offset to the PE signature. We'll put it immediately following the offset value\r
+    // itself.\r
+    //\r
+    memset (TEBuffer, 0, Pe32ImageSize);\r
+    DosHeader = (EFI_IMAGE_DOS_HEADER *) TEBuffer;\r
+    DosHeader->e_magic = EFI_IMAGE_DOS_SIGNATURE;\r
+    *(UINT32 *) (TEBuffer + 0x3C) = 0x40;\r
+    PeHdr = (EFI_IMAGE_NT_HEADERS *) (TEBuffer + 0x40);\r
+    PeHdr->Signature = EFI_IMAGE_NT_SIGNATURE;\r
+    PeHdr->FileHeader.Machine = TEImageHeader->Machine;\r
+    PeHdr->FileHeader.NumberOfSections = TEImageHeader->NumberOfSections;\r
+\r
+    //\r
+    // Say the size of the optional header is the total we stripped off less the size of a PE file header and PE signature and\r
+    // the 0x40 bytes for our DOS header.\r
+    //\r
+    PeHdr->FileHeader.SizeOfOptionalHeader = (UINT16) (TEImageHeader->StrippedSize - 0x40 - sizeof (UINT32) - sizeof (EFI_IMAGE_FILE_HEADER));\r
+    PeHdr->OptionalHeader.ImageBase = (UINTN) (TEImageHeader->ImageBase - TEImageHeader->StrippedSize + sizeof (EFI_TE_IMAGE_HEADER));\r
+    PeHdr->OptionalHeader.AddressOfEntryPoint = TEImageHeader->AddressOfEntryPoint;\r
+    PeHdr->OptionalHeader.BaseOfCode  = TEImageHeader->BaseOfCode;\r
+    PeHdr->OptionalHeader.SizeOfImage = Pe32ImageSize;\r
+    PeHdr->OptionalHeader.Subsystem   = TEImageHeader->Subsystem;\r
+    PeHdr->OptionalHeader.SizeOfImage = Pe32ImageSize;\r
+    PeHdr->OptionalHeader.SizeOfHeaders = TEImageHeader->StrippedSize + TEImageHeader->NumberOfSections *\r
+    sizeof (EFI_IMAGE_SECTION_HEADER) - 12;\r
+\r
+    //\r
+    // Set NumberOfRvaAndSizes in the optional header to what we had available in the original image\r
+    //\r
+    if ((TEImageHeader->DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_BASERELOC].VirtualAddress != 0) ||\r
+        (TEImageHeader->DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_BASERELOC].Size != 0)\r
+        ) {\r
+      PeHdr->OptionalHeader.NumberOfRvaAndSizes = EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC + 1;\r
+      PeHdr->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC].VirtualAddress = TEImageHeader->DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_BASERELOC].VirtualAddress;\r
+      PeHdr->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC].Size = TEImageHeader->DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_BASERELOC].Size;\r
+    }\r
+\r
+    if ((TEImageHeader->DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG].VirtualAddress != 0) ||\r
+        (TEImageHeader->DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG].Size != 0)\r
+        ) {\r
+      PeHdr->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG].VirtualAddress = TEImageHeader->DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG].VirtualAddress;\r
+      PeHdr->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG].Size = TEImageHeader->DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG].Size;\r
+      if (PeHdr->OptionalHeader.NumberOfRvaAndSizes < EFI_IMAGE_DIRECTORY_ENTRY_DEBUG + 1) {\r
+        PeHdr->OptionalHeader.NumberOfRvaAndSizes = EFI_IMAGE_DIRECTORY_ENTRY_DEBUG + 1;\r
+      }\r
+    }\r
+    //\r
+    // NOTE: These values are defaults, and should be verified to be correct in the GenTE utility\r
+    //\r
+    PeHdr->OptionalHeader.SectionAlignment = 0x10;\r
+\r
+    //\r
+    // Copy the rest of the image to its original offset\r
+    //\r
+    memcpy (\r
+      TEBuffer + TEImageHeader->StrippedSize,\r
+      (UINT8 *) CurrentPe32Section.Pe32Section + sizeof (EFI_PE32_SECTION) + sizeof (EFI_TE_IMAGE_HEADER),\r
+      GetLength (CurrentPe32Section.Pe32Section->CommonHeader.Size) - sizeof (EFI_PE32_SECTION) -\r
+      sizeof (EFI_TE_IMAGE_HEADER)\r
+      );\r
+\r
+    //\r
+    // Initialize context\r
+    //\r
+    memset (&ImageContext, 0, sizeof (ImageContext));\r
+    ImageContext.Handle     = (VOID *) TEBuffer;\r
+    ImageContext.ImageRead  = (PE_COFF_LOADER_READ_FILE) FfsRebaseImageRead;\r
+\r
+    Status                  = PeCoffLoaderGetImageInfo (&ImageContext);\r
+\r
+    if (EFI_ERROR (Status)) {\r
+      Error (NULL, 0, 0, "GetImageInfo() call failed on rebase of TE image", FileGuidString);\r
+      free (TEBuffer);\r
+      return Status;\r
+    }\r
+    //\r
+    // Allocate a buffer for the image to be loaded into.\r
+    //\r
+    MemoryImagePointer = (UINTN) (malloc (Pe32ImageSize + 0x1000));\r
+    if (MemoryImagePointer == 0) {\r
+      Error (NULL, 0, 0, "memory allocation error on rebase of TE image", FileGuidString);\r
+      free (TEBuffer);\r
+      return EFI_OUT_OF_RESOURCES;\r
+    }\r
+    memset ((void *) MemoryImagePointer, 0, Pe32ImageSize + 0x1000);\r
+    MemoryImagePointerAligned = (MemoryImagePointer + 0x0FFF) & (-1 << 12);\r
+    \r
+\r
+    ImageContext.ImageAddress = MemoryImagePointerAligned;\r
+    Status                    = PeCoffLoaderLoadImage (&ImageContext);\r
+    if (EFI_ERROR (Status)) {\r
+      Error (NULL, 0, 0, "LoadImage() call failed on rebase of TE image", FileGuidString);\r
+      free (TEBuffer);\r
+      free ((VOID *) MemoryImagePointer);\r
+      return Status;\r
+    }\r
+\r
+    ImageContext.DestinationAddress = NewPe32BaseAddress;\r
+    Status                          = PeCoffLoaderRelocateImage (&ImageContext);\r
+    if (EFI_ERROR (Status)) {\r
+      Error (NULL, 0, 0, "RelocateImage() call failed on rebase of TE image", FileGuidString);\r
+      free ((VOID *) MemoryImagePointer);\r
+      free (TEBuffer);\r
+      return Status;\r
+    }\r
+\r
+    ImageAddress  = ImageContext.ImageAddress;\r
+    ImageSize     = ImageContext.ImageSize;\r
+    EntryPoint    = ImageContext.EntryPoint;\r
+\r
+    //\r
+    // Since we may have updated the Codeview RVA, we need to insure the PE\r
+    // header indicates the image is large enough to contain the Codeview data\r
+    // so it will be loaded properly later if the PEIM is reloaded into memory...\r
+    //\r
+    PeHdr = (VOID *) ((UINTN) ImageAddress + ImageContext.PeCoffHeaderOffset);\r
+    if (PeHdr->FileHeader.Machine == EFI_IMAGE_MACHINE_IA32) {\r
+      PeHdrSizeOfImage     = (UINT32 *) (&(*(EFI_IMAGE_OPTIONAL_HEADER32 *) &PeHdr->OptionalHeader).SizeOfImage);\r
+      PeHdrChecksum        = (UINT32 *) (&(*(EFI_IMAGE_OPTIONAL_HEADER32 *) &PeHdr->OptionalHeader).CheckSum);\r
+    } else if (PeHdr->FileHeader.Machine == EFI_IMAGE_MACHINE_IA64) {\r
+      PeHdrSizeOfImage     = (UINT32 *) (&(*(EFI_IMAGE_OPTIONAL_HEADER64 *) &PeHdr->OptionalHeader).SizeOfImage);\r
+      PeHdrChecksum        = (UINT32 *) (&(*(EFI_IMAGE_OPTIONAL_HEADER64 *) &PeHdr->OptionalHeader).CheckSum);\r
+    } else {\r
+      Error (\r
+        NULL,\r
+        0,\r
+        0,\r
+        "unknown machine type in TE image",\r
+        "machine type=0x%X, file=%s",\r
+        (UINT32) PeHdr->FileHeader.Machine,\r
+        FileGuidString\r
+        );\r
+      free ((VOID *) MemoryImagePointer);\r
+      free (TEBuffer);\r
+      return EFI_ABORTED;\r
+    }\r
+\r
+    if (*PeHdrSizeOfImage != ImageContext.ImageSize) {\r
+      *PeHdrSizeOfImage = (UINT32) ImageContext.ImageSize;\r
+      if (*PeHdrChecksum) {\r
+        *PeHdrChecksum = 0;\r
+      }\r
+    }\r
+\r
+    TEImageHeader->ImageBase = (UINT64) (NewPe32BaseAddress + TEImageHeader->StrippedSize - sizeof (EFI_TE_IMAGE_HEADER));\r
+    memcpy (\r
+      (UINT8 *) (CurrentPe32Section.Pe32Section + 1) + sizeof (EFI_TE_IMAGE_HEADER),\r
+      (VOID *) ((UINT8 *) MemoryImagePointerAligned + TEImageHeader->StrippedSize),\r
+      GetLength (CurrentPe32Section.Pe32Section->CommonHeader.Size) - sizeof (EFI_PE32_SECTION) -\r
+      sizeof (EFI_TE_IMAGE_HEADER)\r
+      );\r
+    \r
+    //\r
+    // Get EntryPoint in Flash Region.\r
+    //\r
+    EntryPoint = NewPe32BaseAddress + EntryPoint - ImageAddress;\r
+\r
+    //\r
+    // If a map file was selected output mapping information for any file that\r
+    // was rebased.\r
+    //\r
+    if (MapFile != NULL) {\r
+      fprintf (MapFile, "TE   File: %s Base:%08lx", FileGuidString, BaseAddress);\r
+      fprintf (MapFile, " EntryPoint:%08lx", EntryPoint);\r
+      if (ImageContext.PdbPointer != NULL) {\r
+        fprintf (MapFile, " FileName: %s", ImageContext.PdbPointer);\r
+      }\r
+      fprintf (MapFile, "\n");\r
+    }\r
+\r
+    free ((VOID *) MemoryImagePointer);\r
+    free (TEBuffer);\r
+    if (FfsFile->Attributes & FFS_ATTRIB_TAIL_PRESENT) {\r
+      TailSize = sizeof (EFI_FFS_FILE_TAIL);\r
+    } else {\r
+      TailSize = 0;\r
+    }\r
+    //\r
+    // Now update file checksum\r
+    //\r
+    if (FfsFile->Attributes & FFS_ATTRIB_CHECKSUM) {\r
+      SavedState  = FfsFile->State;\r
+      FfsFile->IntegrityCheck.Checksum.File = 0;\r
+      FfsFile->State                        = 0;\r
+      if (FfsFile->Attributes & FFS_ATTRIB_CHECKSUM) {\r
+        FfsFile->IntegrityCheck.Checksum.File = CalculateChecksum8 (\r
+                                                  (UINT8 *) FfsFile,\r
+                                                  GetLength (FfsFile->Size) - TailSize\r
+                                                  );\r
+      } else {\r
+        FfsFile->IntegrityCheck.Checksum.File = FFS_FIXED_CHECKSUM;\r
+      }\r
+\r
+      FfsFile->State = SavedState;\r
+    }\r
+    //\r
+    // Update tail if present\r
+    //\r
+    if (FfsFile->Attributes & FFS_ATTRIB_TAIL_PRESENT) {\r
+      TailValue = (EFI_FFS_FILE_TAIL) (~(FfsFile->IntegrityCheck.TailReference));\r
+      *(EFI_FFS_FILE_TAIL *) (((UINTN) FfsFile + GetLength (FfsFile->Size) - sizeof (EFI_FFS_FILE_TAIL))) = TailValue;\r
+    }\r
+  }\r
+  //\r
+  // If we found no files, then emit an error if no compressed sections either\r
+  //\r
+  if (FoundCount == 0) {\r
+    Status = GetSectionByType (FfsFile, EFI_SECTION_COMPRESSION, Index, &CurrentPe32Section);\r
+    if (EFI_ERROR (Status)) {\r
+      Error (NULL, 0, 0, "no PE32, TE, nor compressed section found in FV file", FileGuidString);\r
+      return EFI_NOT_FOUND;\r
+    }\r
+  }\r
+  \r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+FfsRebaseImageRead (\r
+  IN     VOID    *FileHandle,\r
+  IN     UINTN   FileOffset,\r
+  IN OUT UINT32  *ReadSize,\r
+  OUT    VOID    *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Support routine for the PE/COFF Loader that reads a buffer from a PE/COFF file\r
+\r
+Arguments:\r
+\r
+  FileHandle - The handle to the PE/COFF file\r
+\r
+  FileOffset - The offset, in bytes, into the file to read\r
+\r
+  ReadSize   - The number of bytes to read from the file starting at FileOffset\r
+\r
+  Buffer     - A pointer to the buffer to read the data into.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS - ReadSize bytes of data were read into Buffer from the PE/COFF file starting at FileOffset\r
+\r
+--*/\r
+{\r
+  CHAR8   *Destination8;\r
+  CHAR8   *Source8;\r
+  UINT32  Length;\r
+\r
+  Destination8  = Buffer;\r
+  Source8       = (CHAR8 *) ((UINTN) FileHandle + FileOffset);\r
+  Length        = *ReadSize;\r
+  while (Length--) {\r
+    *(Destination8++) = *(Source8++);\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
diff --git a/Tools/CodeTools/Source/PeiRebase/PeiRebaseExe.h b/Tools/CodeTools/Source/PeiRebase/PeiRebaseExe.h
new file mode 100644 (file)
index 0000000..b05baef
--- /dev/null
@@ -0,0 +1,155 @@
+/*++\r
+\r
+Copyright (c)  1999-2006 Intel Corporation. All rights reserved\r
+This program and the accompanying materials are licensed and made available \r
+under the terms and conditions of the BSD License which accompanies this \r
+distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+\r
+Module Name:\r
+  \r
+  PeiRebaseExe.h\r
+\r
+Abstract:\r
+\r
+  Definitions for the PeiRebase exe utility.\r
+\r
+--*/\r
+\r
+#ifndef _EFI_PEIM_FIXUP_EXE_H\r
+#define _EFI_PEIM_FIXUP_EXE_H\r
+\r
+#include <Common/FirmwareVolumeImageFormat.h>\r
+#include <Common/FirmwareFileSystem.h>\r
+#include <Common/FirmwareVolumeHeader.h>\r
+#include <Common/MultiPhase.h>\r
+\r
+//\r
+// Utility Name\r
+//\r
+#define UTILITY_NAME  "PeiRebase"\r
+\r
+//\r
+// Utility version information\r
+//\r
+#define UTILITY_MAJOR_VERSION 0\r
+#define UTILITY_MINOR_VERSION 1\r
+#define UTILITY_DATE          __DATE__\r
+\r
+//\r
+// The maximum number of arguments accepted from the command line.\r
+//\r
+#define MAX_ARGS  9\r
+\r
+//\r
+// The file copy buffer size\r
+//\r
+#define FILE_COPY_BUFFER_SIZE 512\r
+\r
+//\r
+// The function that displays general utility information\r
+//\r
+VOID\r
+PrintUtilityInfo (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  None\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+//\r
+// The function that displays the utility usage message.\r
+//\r
+VOID\r
+PrintUsage (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  None\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+//\r
+// Internal function declarations\r
+//\r
+EFI_STATUS\r
+FfsRebaseImageRead (\r
+  IN     VOID    *FileHandle,\r
+  IN     UINTN   FileOffset,\r
+  IN OUT UINT32  *ReadSize,\r
+  OUT    VOID    *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  FileHandle  - GC_TODO: add argument description\r
+  FileOffset  - GC_TODO: add argument description\r
+  ReadSize    - GC_TODO: add argument description\r
+  Buffer      - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+FfsRebase (\r
+  IN OUT EFI_FFS_FILE_HEADER    *FfsFile,\r
+  IN EFI_PHYSICAL_ADDRESS       BaseAddress,\r
+  IN FILE                       *MapFile      OPTIONAL\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  FfsFile     - GC_TODO: add argument description\r
+  BaseAddress - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+#endif\r
diff --git a/Tools/CodeTools/Source/PeiRebase/build.xml b/Tools/CodeTools/Source/PeiRebase/build.xml
new file mode 100644 (file)
index 0000000..7174441
--- /dev/null
@@ -0,0 +1,107 @@
+<?xml version="1.0" ?>\r
+<!--\r
+Copyright (c) 2006, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+-->\r
+<project default="GenTool" basedir=".">\r
+<!--\r
+    EDK PeiRebase Tool\r
+  Copyright (c) 2006, Intel Corporation\r
+-->\r
+  <property name="ToolName" value="PeiRebase"/>\r
+  <property name="FileSet" value="*.c"/>\r
+\r
+  <taskdef resource="cpptasks.tasks"/>\r
+  <typedef resource="cpptasks.types"/>\r
+  <taskdef resource="net/sf/antcontrib/antlib.xml"/>\r
+\r
+  <property name="LINK_OUTPUT_TYPE" value="static"/>\r
+  <property name="BUILD_DIR" value="${PACKAGE_DIR}/${ToolName}/tmp"/>\r
+\r
+  <target name="GenTool" depends="init, Tool">\r
+    <echo message="The EDK Tool: ${ToolName} build has completed"/>\r
+  </target>\r
+\r
+  <target name="Tool" depends="init, PeiRebase_Ia32, PeiRebase_Ipf, PeiRebase_X64"/>\r
+\r
+  <target name="init">\r
+    <echo message="Building the EDK Tool: ${ToolName}"/>\r
+    <mkdir dir="${BUILD_DIR}"/>\r
+  </target>\r
+\r
+  <target name="PeiRebase_Ia32" depends="init">\r
+    <cc name="${ToolChain}" objdir="${BUILD_DIR}" \r
+        outfile="${BIN_DIR}/${ToolName}_Ia32"\r
+        outtype="executable"\r
+        debug="true"\r
+        optimize="speed">\r
+      <compilerarg value="${ExtraArgus}" if="ExtraArgus" />\r
+\r
+      <fileset dir="${basedir}/${ToolName}" \r
+        includes="${FileSet}"/>\r
+\r
+      <includepath path="${PACKAGE_DIR}/Include"/>\r
+      <includepath path="${PACKAGE_DIR}/Include/Ia32"/>\r
+      <includepath path="${PACKAGE_DIR}/Common"/>\r
+      <libset dir="${LIB_DIR}" libs="CommonTools PeCoffLoader_Ia32"/>\r
+    </cc>\r
+  </target>\r
+\r
+  <target name="PeiRebase_Ipf" depends="init">\r
+    <cc name="${ToolChain}" objdir="${BUILD_DIR}" \r
+        outfile="${BIN_DIR}/${ToolName}_Ipf"\r
+        outtype="executable"\r
+        debug="true"\r
+        optimize="speed">\r
+      <compilerarg value="${ExtraArgus}" if="ExtraArgus" />\r
+      <fileset dir="${basedir}/${ToolName}" \r
+        includes="${FileSet}"/>\r
+\r
+      <includepath path="${PACKAGE_DIR}/Include"/>\r
+      <includepath path="${PACKAGE_DIR}/Include/Ia32"/>\r
+      <includepath path="${PACKAGE_DIR}/Common"/>\r
+      <libset dir="${LIB_DIR}" libs="CommonTools PeCoffLoader_Ipf"/>\r
+    </cc>\r
+  </target>\r
+\r
+  <target name="PeiRebase_X64" depends="init">\r
+    <cc name="${ToolChain}" objdir="${BUILD_DIR}" \r
+        outfile="${BIN_DIR}/${ToolName}_X64"\r
+        outtype="executable"\r
+        debug="true"\r
+        optimize="speed">\r
+      <compilerarg value="${ExtraArgus}" if="ExtraArgus" />\r
+      <fileset dir="${basedir}/${ToolName}" \r
+        includes="${FileSet}" />\r
+\r
+      <includepath path="${PACKAGE_DIR}/Include"/>\r
+      <includepath path="${PACKAGE_DIR}/Include/Ia32"/>\r
+      <includepath path="${PACKAGE_DIR}/Common"/>\r
+      <libset dir="${LIB_DIR}" libs="CommonTools PeCoffLoader_X64"/>\r
+    </cc>\r
+  </target>\r
+\r
+  <target name="clean">\r
+    <echo message="Removing Intermediate Files Only"/>  \r
+    <delete>\r
+      <fileset dir="${BUILD_DIR}" includes="*.obj"/>\r
+    </delete>\r
+  </target>\r
+\r
+  <target name="cleanall">\r
+    <echo message="Removing Object Files and the Executable: ${ToolName}_*${ext_exe}"/>  \r
+    <delete failonerror="false" quiet="true" includeEmptyDirs="true">\r
+      <fileset dir="${BUILD_DIR}"/>\r
+      <fileset file="${BIN_DIR}/${ToolName}_Ia32${ext_exe}"/>\r
+      <fileset file="${BIN_DIR}/${ToolName}_Ipf${ext_exe}"/>\r
+      <fileset file="${BIN_DIR}/${ToolName}_X64${ext_exe}"/>\r
+    </delete>\r
+  </target>\r
+\r
+</project>\r
diff --git a/Tools/CodeTools/Source/SecApResetVectorFixup/SecApResetVectorFixup.c b/Tools/CodeTools/Source/SecApResetVectorFixup/SecApResetVectorFixup.c
new file mode 100644 (file)
index 0000000..4426457
--- /dev/null
@@ -0,0 +1,363 @@
+/*++\r
+\r
+Copyright (c)  2004-2006 Intel Corporation. All rights reserved\r
+This program and the accompanying materials are licensed and made available \r
+under the terms and conditions of the BSD License which accompanies this \r
+distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+\r
+Module Name:\r
+\r
+    SecApResetVectorFixup.c\r
+\r
+Abstract:\r
+\r
+    This utility is part of build process for IA32 Fvrecovery.fv whose total size\r
+    is larger than 128kB so that we cannot use GenFvImage utility to put Ap reset \r
+    vector at the zero vector of Fv header.\r
+    \r
+      PEI FV after using the tool\r
+    \r
+    -------------------------\r
+    |zzz                    |\r
+    |                       |\r
+    |                       |\r
+    |      FFS              |\r
+    |                       |\r
+    |                       |\r
+    |                       |\r
+    |---------------------- |\r
+    |       PAD             |\r
+    |                       |\r
+    |.......................|  --- \r
+    |                       |   |\r
+    |xxx                    |   | 128K    \r
+    |---------------------- |   | \r
+    |       VTF (SEC)       |   |\r
+    -------------------------  ---\r
+    \r
+    1. zzz --> Zero vector, which is beyond the 128K limited address space\r
+    2. xxx --> AP reset vector at 4K alignment below 128K and it is in the PAD\r
+       file area.\r
+    3. After the build process ,the PAD guid is changed to a new GUID to avoid \r
+       the PAD definition confusing. If there is some problem, try to disable\r
+       UpdatePadFileGuid\r
+    \r
+     \r
+    \r
+--*/\r
+\r
+#include "SecApResetVectorFixup.h"\r
+\r
+\r
+EFI_GUID  DefaultFvPadFileNameGuid = { 0x78f54d4, 0xcc22, 0x4048, 0x9e, 0x94, 0x87, 0x9c, 0x21, 0x4d, 0x56, 0x2f };\r
+EFI_GUID  NewFvPadFileNameGuid     = { 0x145372bc, 0x66b9, 0x476d, 0x81, 0xbc, 0x21, 0x27, 0xc3, 0x76, 0xbb, 0x66 };\r
+\r
+//\r
+// jmp 0xf000:0xffd0 (0xFFFFFFD0)\r
+//\r
+UINT8 ApResetVector[5] = {0xEA, 0xD0, 0xFF, 0x00, 0xF0};\r
+\r
+VOID\r
+PrintUtilityInfo (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Displays the standard utility information to SDTOUT\r
+\r
+Arguments:\r
+\r
+  None\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+{\r
+  printf (\r
+    "%s - Tiano IA32 SEC Ap Reset Vector Fixup Utility."" Version %i.%i\n\n",\r
+    UTILITY_NAME,\r
+    UTILITY_MAJOR_VERSION,\r
+    UTILITY_MINOR_VERSION\r
+    );\r
+}\r
+\r
+VOID\r
+PrintUsage (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Displays the utility usage syntax to STDOUT\r
+\r
+Arguments:\r
+\r
+  None\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+{\r
+  printf ("Usage: %s InputFvrecoveryFile OutputFvrecoveryFile\n", UTILITY_NAME);\r
+  printf ("  Where:\n");\r
+  printf ("\tInputFvrecoveryFile   - Name of the IA32 input Fvrecovery.fv file.\n");\r
+  printf ("\tOutputFvrecoveryFile  - Name of the IA32 output Fvrecovery.fv file.\n");\r
+}\r
+\r
+\r
+VOID \r
+UpdatePadFileGuid (\r
+  IN     EFI_FIRMWARE_VOLUME_HEADER  *FvHeader,\r
+  IN     EFI_FFS_FILE_HEADER         *FileHeader,\r
+  IN     UINT32                      FileLength,\r
+  IN OUT EFI_GUID                    *Guid\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Update the Pad File Guid to change it to other guid and update\r
+  the checksum\r
+\r
+Arguments:\r
+  FvHeader   - EFI_FIRMWARE_VOLUME_HEADER \r
+  FileHeader - The FFS PAD file header.\r
+  FileLength - The FFS PAD file length.\r
+  Guid       - The Guid to compare and if it is PAD Guid, update it to new Guid\r
+Returns:\r
+  VOID\r
+--*/\r
+\r
+{\r
+  if ((CompareGuid (Guid, (EFI_GUID *)&DefaultFvPadFileNameGuid)) == 0) {\r
+    //\r
+    // Set new Pad file guid\r
+    // \r
+    memcpy (Guid, &NewFvPadFileNameGuid, sizeof (EFI_GUID));\r
+\r
+\r
+\r
+    FileHeader->Type       = EFI_FV_FILETYPE_FFS_PAD;\r
+    FileHeader->Attributes = 0;\r
+    //\r
+    // Fill in checksums and state, must be zero during checksum calculation.\r
+    //\r
+    FileHeader->IntegrityCheck.Checksum.Header = 0;\r
+    FileHeader->IntegrityCheck.Checksum.File   = 0;\r
+    FileHeader->State                          = 0;\r
+    FileHeader->IntegrityCheck.Checksum.Header = CalculateChecksum8 ((UINT8 *) FileHeader, sizeof (EFI_FFS_FILE_HEADER));\r
+    if (FileHeader->Attributes & FFS_ATTRIB_CHECKSUM) {\r
+      FileHeader->IntegrityCheck.Checksum.File = CalculateChecksum8 ((UINT8 *) FileHeader, FileLength);\r
+    } else {\r
+      FileHeader->IntegrityCheck.Checksum.File = FFS_FIXED_CHECKSUM;\r
+    }\r
+\r
+    FileHeader->State = EFI_FILE_HEADER_CONSTRUCTION | EFI_FILE_HEADER_VALID | EFI_FILE_DATA_VALID;\r
+\r
+    if (FvHeader->Attributes & EFI_FVB_ERASE_POLARITY) {\r
+      FileHeader->State = (UINT8)~(FileHeader->State);\r
+    }    \r
+  }\r
+  \r
+}\r
+\r
+\r
+STATUS\r
+main (\r
+  IN INTN   argc,\r
+  IN CHAR8  **argv\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Main function.\r
+\r
+Arguments:\r
+\r
+  argc - Number of command line parameters.\r
+  argv - Array of pointers to parameter strings.\r
+\r
+Returns:\r
+  STATUS_SUCCESS - Utility exits successfully.\r
+  STATUS_ERROR   - Some error occurred during execution.\r
+\r
+--*/\r
+{\r
+  FILE                        *FpIn;\r
+  FILE                        *FpOut;\r
+  UINT32                      FvrecoveryFileSize;\r
+  UINT8                       *FileBuffer;\r
+  UINT8                       *FileBufferRaw;\r
+  UINT64                      FvLength;\r
+  UINT32                      Offset;\r
+  UINT32                      FileLength;\r
+  UINT32                      FileOccupiedSize;\r
+  EFI_FIRMWARE_VOLUME_HEADER  *FvHeader;\r
+  EFI_FFS_FILE_HEADER         *FileHeader;\r
+  EFI_GUID                    *TempGuid;\r
+  UINT8                       *FixPoint;\r
+  UINT32                      TempResult;\r
+  UINT32                      Index;\r
+  UINT32                      IpiVector;\r
+\r
+  TempGuid = NULL;\r
+  SetUtilityName (UTILITY_NAME);\r
+\r
+  //\r
+  // Display utility information\r
+  //\r
+  PrintUtilityInfo ();\r
+\r
+  //\r
+  // Verify the correct number of arguments\r
+  //\r
+  if (argc != MAX_ARGS) {\r
+    Error (NULL, 0, 0, "invalid number of input parameters specified", NULL);\r
+    PrintUsage ();\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Open the Input Fvrecovery.fv file\r
+  //\r
+  if ((FpIn = fopen (argv[1], "rb")) == NULL) {\r
+    Error (NULL, 0, 0, "Unable to open file", argv[1]);\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Get the Input Fvrecovery.fv file size\r
+  //\r
+  fseek (FpIn, 0, SEEK_END);\r
+  FvrecoveryFileSize = ftell (FpIn);\r
+  //\r
+  // Read the contents of input file to memory buffer\r
+  //\r
+  FileBuffer    = NULL;\r
+  FileBufferRaw = NULL;\r
+  FileBufferRaw = (UINT8 *) malloc (FvrecoveryFileSize + 0x10000);\r
+  if (NULL == FileBufferRaw) {\r
+    Error (NULL, 0, 0, "No sufficient memory to allocate!", NULL);\r
+    fclose (FpIn);\r
+    return STATUS_ERROR;\r
+  }\r
+  TempResult = 0x10000 - ((UINT32)FileBufferRaw & 0x0FFFF);\r
+  FileBuffer = (UINT8 *)((UINT32)FileBufferRaw + TempResult);\r
+  fseek (FpIn, 0, SEEK_SET);\r
+  TempResult = fread (FileBuffer, 1, FvrecoveryFileSize, FpIn);\r
+  if (TempResult != FvrecoveryFileSize) {\r
+    Error (NULL, 0, 0, "Read input file error!", NULL);\r
+    free ((VOID *)FileBufferRaw);\r
+    fclose (FpIn);\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Close the input Fvrecovery.fv file\r
+  //\r
+  fclose (FpIn);\r
+  //\r
+  // Find the pad FFS file\r
+  //\r
+  FvHeader         = (EFI_FIRMWARE_VOLUME_HEADER *)FileBuffer;\r
+  FvLength         = FvHeader->FvLength;\r
+  FileHeader       = (EFI_FFS_FILE_HEADER *)(FileBuffer + FvHeader->HeaderLength);\r
+  FileLength       = (*(UINT32 *)(FileHeader->Size)) & 0x00FFFFFF;\r
+  FileOccupiedSize = GETOCCUPIEDSIZE(FileLength, 8);\r
+  Offset           = (UINT32)FileHeader - (UINT32)FileBuffer;\r
+  \r
+  while (Offset < FvLength) {\r
+    TempGuid = (EFI_GUID *)&(FileHeader->Name);\r
+    FileLength = (*(UINT32 *)(FileHeader->Size)) & 0x00FFFFFF;\r
+    FileOccupiedSize = GETOCCUPIEDSIZE(FileLength, 8);\r
+    if ((CompareGuid (TempGuid, (EFI_GUID *)&DefaultFvPadFileNameGuid)) == 0) {\r
+      break;\r
+    }\r
+    FileHeader = (EFI_FFS_FILE_HEADER *)((UINT32)FileHeader + FileOccupiedSize);\r
+    Offset = (UINT32)FileHeader - (UINT32)FileBuffer;\r
+  }\r
+\r
+  if (Offset >= FvLength) {\r
+    Error (NULL, 0, 0, "No pad file found!", NULL);\r
+    free ((VOID *)FileBufferRaw);\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Find the position to place Ap reset vector, the offset\r
+  // between the position and the end of Fvrecovery.fv file\r
+  // should not exceed 128kB to prevent Ap reset vector from\r
+  // outside legacy E and F segment\r
+  //\r
+  FixPoint = (UINT8 *)(FileHeader + sizeof(EFI_FFS_FILE_HEADER));\r
+  TempResult = 0x1000 - ((UINT32)FixPoint & 0x0FFF);\r
+  FixPoint +=TempResult;\r
+  if (((UINT32)FixPoint - (UINT32)FileHeader + 5) > FileOccupiedSize) {\r
+    Error (NULL, 0, 0, "No appropriate space in pad file to add Ap reset vector!", NULL);\r
+    free ((VOID *)FileBufferRaw);\r
+    return STATUS_ERROR;  \r
+  }\r
+  while (((UINT32)FixPoint - (UINT32)FileHeader + 5) <= FileOccupiedSize) {\r
+    FixPoint += 0x1000;\r
+  }\r
+  FixPoint -= 0x1000;\r
+  if ((UINT32)FvHeader + FvLength - (UINT32)FixPoint > 0x20000) {\r
+    Error (NULL, 0, 0, "The position to place Ap reset vector is not in E and F segment!", NULL);\r
+    free ((VOID *)FileBufferRaw);\r
+    return STATUS_ERROR; \r
+  }    \r
+  //\r
+  // Fix up Ap reset vector and calculate the IPI vector\r
+  //\r
+  for (Index = 0; Index < 5; Index++) {\r
+    FixPoint[Index] = ApResetVector[Index];\r
+  } \r
+  TempResult = 0x0FFFFFFFF - ((UINT32)FvHeader + (UINT32)FvLength - 1 - (UINT32)FixPoint);\r
+  TempResult >>= 12;\r
+  IpiVector = TempResult & 0x0FF;\r
+  \r
+  \r
+  UpdatePadFileGuid (FvHeader, FileHeader, FileLength, TempGuid);\r
+\r
+  //\r
+  // Open the output Fvrecovery.fv file\r
+  //\r
+  if ((FpOut = fopen (argv[2], "w+b")) == NULL) {\r
+    Error (NULL, 0, 0, "Unable to open file", argv[2]);\r
+    free ((VOID *)FileBufferRaw);\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Write the output Fvrecovery.fv file\r
+  //\r
+  if ((fwrite (FileBuffer, 1, FvrecoveryFileSize, FpOut)) != FvrecoveryFileSize) {\r
+    Error (NULL, 0, 0, "Write output file error!", NULL);\r
+    free ((VOID *)FileBufferRaw);\r
+    return STATUS_ERROR;   \r
+  }\r
+  //\r
+  //\r
+  //\r
+  fseek (FpOut, -8, SEEK_END);\r
+  if ((fwrite (&IpiVector, 1, sizeof(UINT32), FpOut)) != sizeof(UINT32)) {\r
+    Error (NULL, 0, 0, "Write output file error!", NULL);\r
+    free ((VOID *)FileBufferRaw);\r
+    return STATUS_ERROR;\r
+  }  \r
+  //\r
+  // Close the output Fvrecovery.fv file\r
+  //\r
+  fclose (FpOut);\r
+  free ((VOID *)FileBufferRaw);\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
diff --git a/Tools/CodeTools/Source/SecApResetVectorFixup/SecApResetVectorFixup.h b/Tools/CodeTools/Source/SecApResetVectorFixup/SecApResetVectorFixup.h
new file mode 100644 (file)
index 0000000..6d234e3
--- /dev/null
@@ -0,0 +1,104 @@
+/*++\r
+\r
+Copyright (c)  1999-2006 Intel Corporation. All rights reserved\r
+This program and the accompanying materials are licensed and made available\r
+under the terms and conditions of the BSD License which accompanies this\r
+distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+\r
+Module Name:\r
+\r
+  SecApResetVectorFixup.h\r
+\r
+Abstract:\r
+\r
+  Definitions for the SecApResetVectorFixup utility.\r
+\r
+--*/\r
+\r
+#ifndef _SEC_AP_RESET_VECTOR_FIXUP_H\r
+#define _SEC_AP_RESET_VECTOR_FIXUP_H\r
+\r
+#include <stdio.h>\r
+#include <stdlib.h>\r
+\r
+#include <Common/UefiBaseTypes.h>\r
+#include <Common/EfiImage.h>\r
+#include <Common/FirmwareVolumeImageFormat.h>\r
+#include <Common/FirmwareFileSystem.h>\r
+#include <Common/FirmwareVolumeHeader.h>\r
+\r
+#include "EfiUtilityMsgs.c"\r
+#include "CommonLib.h"\r
+\r
+\r
+//\r
+// Utility Name\r
+//\r
+#define UTILITY_NAME  "SecApResetVectorFixup"\r
+\r
+//\r
+// Utility version information\r
+//\r
+#define UTILITY_MAJOR_VERSION 0\r
+#define UTILITY_MINOR_VERSION 1\r
+#define UTILITY_DATE          __DATE__\r
+\r
+//\r
+// The maximum number of arguments accepted from the command line.\r
+//\r
+#define MAX_ARGS        3\r
+#define BUF_SIZE        (8 * 1024)\r
+\r
+#define GETOCCUPIEDSIZE(ActualSize, Alignment) \\r
+  (ActualSize) + (((Alignment) - ((ActualSize) & ((Alignment) - 1))) & ((Alignment) - 1))\r
+\r
+\r
+VOID\r
+PrintUtilityInfo (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Displays the standard utility information to SDTOUT\r
+\r
+Arguments:\r
+\r
+  None\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+;\r
+\r
+VOID\r
+PrintUsage (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Displays the utility usage syntax to STDOUT\r
+\r
+Arguments:\r
+\r
+  None\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+;\r
+\r
+\r
+#endif\r
diff --git a/Tools/CodeTools/Source/SecApResetVectorFixup/build.xml b/Tools/CodeTools/Source/SecApResetVectorFixup/build.xml
new file mode 100644 (file)
index 0000000..f615b2a
--- /dev/null
@@ -0,0 +1,70 @@
+<?xml version="1.0" ?>\r
+<!--\r
+Copyright (c) 2006, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+-->\r
+<project default="GenTool" basedir=".">\r
+<!--\r
+    EDK SecApResetVectorFixup Tool\r
+  Copyright (c) 2006, Intel Corporation\r
+-->\r
+  <property name="ToolName" value="SecApResetVectorFixup"/>\r
+  <property name="FileSet" value="*.c"/>\r
+\r
+  <taskdef resource="cpptasks.tasks"/>\r
+  <typedef resource="cpptasks.types"/>\r
+  <taskdef resource="net/sf/antcontrib/antlib.xml"/>\r
+\r
+  <property name="LINK_OUTPUT_TYPE" value="static"/>\r
+  <property name="BUILD_DIR" value="${PACKAGE_DIR}/${ToolName}/tmp"/>\r
+\r
+  <target name="GenTool" depends="init, Tool">\r
+    <echo message="The EDK Tool: ${ToolName} build has completed"/>\r
+  </target>\r
+\r
+  <target name="init">\r
+    <echo message="Building the EDK Tool: ${ToolName}"/>\r
+    <mkdir dir="${BUILD_DIR}"/>\r
+  </target>\r
+\r
+  <target name="Tool" depends="init">\r
+    <cc name="${ToolChain}" objdir="${BUILD_DIR}" \r
+        outfile="${BIN_DIR}/${ToolName}"\r
+        outtype="executable"\r
+        optimize="speed" \r
+        debug="true">\r
+\r
+      <fileset dir="${basedir}/${ToolName}" \r
+        includes="${FileSet}" \r
+        defaultexcludes="TRUE" \r
+        excludes="*.xml *.inf"/>\r
+\r
+      <includepath path="${PACKAGE_DIR}/Include"/>\r
+      <includepath path="${PACKAGE_DIR}/Include/${HostArch}"/>\r
+      <includepath path="${PACKAGE_DIR}/Common"/>\r
+      <libset dir="${LIB_DIR}" libs="CommonTools"/>\r
+    </cc>\r
+  </target>\r
+\r
+  <target name="clean">\r
+    <echo message="Removing Intermediate Files Only"/>  \r
+    <delete>\r
+      <fileset dir="${BUILD_DIR}" includes="*.obj"/>\r
+    </delete>\r
+  </target>\r
+\r
+  <target name="cleanall">\r
+    <echo message="Removing Object Files and the Executable: ${ToolName}${ext_exe}"/>  \r
+    <delete failonerror="false" quiet="true" includeEmptyDirs="true">\r
+      <fileset dir="${BUILD_DIR}"/>\r
+      <fileset file="${BIN_DIR}/${ToolName}${ext_exe}"/>\r
+    </delete>\r
+  </target>\r
+\r
+</project>\r
diff --git a/Tools/CodeTools/Source/SecFixup/SecFixup.c b/Tools/CodeTools/Source/SecFixup/SecFixup.c
new file mode 100644 (file)
index 0000000..c2d46a1
--- /dev/null
@@ -0,0 +1,362 @@
+/*++\r
+\r
+Copyright (c)  1999-2006 Intel Corporation. All rights reserved\r
+This program and the accompanying materials are licensed and made available \r
+under the terms and conditions of the BSD License which accompanies this \r
+distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+\r
+Module Name:\r
+\r
+    SecFixup.c\r
+\r
+Abstract:\r
+\r
+    This utility is part of build process for IA32 SEC FFS file.\r
+    \r
+    It fixup the reset vector data. The reset vector data binary file\r
+    will be wrapped as a RAW section and be located immediately after\r
+    the PE/TE section.\r
+\r
+    The SEC EXE file can be either PE or TE file.\r
+    \r
+--*/\r
+\r
+#include <stdio.h>\r
+\r
+#include <Common/UefiBaseTypes.h>\r
+#include <Common/EfiImage.h>\r
+#include <Common/FirmwareVolumeImageFormat.h>\r
+\r
+#include "EfiUtilityMsgs.c"\r
+#include "SecFixup.h"\r
+\r
+VOID\r
+PrintUtilityInfo (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Displays the standard utility information to SDTOUT\r
+\r
+Arguments:\r
+\r
+  None\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+{\r
+  printf (\r
+    "%s - Tiano IA32 SEC Fixup Utility."" Version %i.%i\n\n",\r
+    UTILITY_NAME,\r
+    UTILITY_MAJOR_VERSION,\r
+    UTILITY_MINOR_VERSION\r
+    );\r
+}\r
+\r
+VOID\r
+PrintUsage (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Displays the utility usage syntax to STDOUT\r
+\r
+Arguments:\r
+\r
+  None\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+{\r
+  printf ("Usage: %s SecExeFile ResetVectorDataFile OutputFile\n", UTILITY_NAME);\r
+  printf ("  Where:\n");\r
+  printf ("\tSecExeFile           - Name of the IA32 SEC EXE file.\n");\r
+  printf ("\tResetVectorDataFile  - Name of the reset vector data binary file.\n");\r
+  printf ("\tOutputFileName       - Name of the output file.\n\n");\r
+}\r
+\r
+STATUS\r
+main (\r
+  IN INTN   argc,\r
+  IN CHAR8  **argv\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Main function.\r
+\r
+Arguments:\r
+\r
+  argc - Number of command line parameters.\r
+  argv - Array of pointers to parameter strings.\r
+\r
+Returns:\r
+  STATUS_SUCCESS - Utility exits successfully.\r
+  STATUS_ERROR   - Some error occurred during execution.\r
+\r
+--*/\r
+{\r
+  FILE    *FpIn;\r
+\r
+  FILE    *FpOut;\r
+  UINT32  AddressOfEntryPoint;\r
+  INT32   DestRel;\r
+  STATUS  Status;\r
+  UINT32  SecFileSize;\r
+\r
+  SetUtilityName (UTILITY_NAME);\r
+\r
+  //\r
+  // Display utility information\r
+  //\r
+  PrintUtilityInfo ();\r
+\r
+  //\r
+  // Verify the correct number of arguments\r
+  //\r
+  if (argc != MAX_ARGS) {\r
+    Error (NULL, 0, 0, "invalid number of input parameters specified", NULL);\r
+    PrintUsage ();\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Open the SEC exe file\r
+  //\r
+  if ((FpIn = fopen (argv[1], "rb")) == NULL) {\r
+    Error (NULL, 0, 0, "Unable to open file", argv[1]);\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Get the entry point of the EXE file\r
+  //\r
+  Status = GetEntryPoint (FpIn, &AddressOfEntryPoint);\r
+  if (Status != STATUS_SUCCESS) {\r
+    fclose (FpIn);\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Get the SEC file size\r
+  //\r
+  fseek (FpIn, 0, SEEK_END);\r
+  SecFileSize = ftell (FpIn);\r
+\r
+  //\r
+  // Close the SEC file\r
+  //\r
+  fclose (FpIn);\r
+\r
+  //\r
+  // Open the reset vector data file\r
+  //\r
+  if ((FpIn = fopen (argv[2], "rb")) == NULL) {\r
+    Error (NULL, 0, 0, "Unable to open file", argv[2]);\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Open the output file\r
+  //\r
+  if ((FpOut = fopen (argv[3], "w+b")) == NULL) {\r
+    Error (NULL, 0, 0, "Unable to open file", argv[3]);\r
+    fclose (FpIn);\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Copy the input file to the output file\r
+  //\r
+  if (CopyFile (FpIn, FpOut) != STATUS_SUCCESS) {\r
+    fclose (FpIn);\r
+    fclose (FpOut);\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Close the reset vector data file\r
+  //\r
+  fclose (FpIn);\r
+\r
+  //\r
+  // Fix the destination relative in the jmp instruction\r
+  // in the reset vector data structure\r
+  //\r
+  fseek (FpOut, -DEST_REL_OFFSET, SEEK_END);\r
+  DestRel = AddressOfEntryPoint - (SecFileSize + sizeof (EFI_COMMON_SECTION_HEADER) + (UINT32) (ftell (FpOut)) + 2);\r
+  if (DestRel <= -65536) {\r
+    Error (NULL, 0, 0, "The SEC EXE file size is too big", NULL);\r
+    fclose (FpOut);\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  if (fwrite (&DestRel, sizeof (UINT16), 1, FpOut) != 1) {\r
+    Error (NULL, 0, 0, "Failed to write to the output file", NULL);\r
+    fclose (FpOut);\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Close the output file\r
+  //\r
+  fclose (FpOut);\r
+\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+STATUS\r
+GetEntryPoint (\r
+  IN  FILE   *ExeFile,\r
+  OUT UINT32 *EntryPoint\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Get the address of the entry point of a PE/TE file.\r
+\r
+Arguments:\r
+\r
+  PeFile     - File pointer to the specified PE/TE file.\r
+  EntryPoint - Buffer for the address of the entry point to be returned.\r
+\r
+Returns:\r
+  STATUS_SUCCESS - Function completed successfully.\r
+  STATUS_ERROR   - Error occured.\r
+\r
+--*/\r
+// GC_TODO:    ExeFile - add argument and description to function comment\r
+{\r
+  EFI_IMAGE_DOS_HEADER    DosHeader;\r
+  EFI_IMAGE_NT_HEADERS32  NtHeader;\r
+  EFI_TE_IMAGE_HEADER     TeHeader;\r
+\r
+  //\r
+  // Check if it is a TE file\r
+  //\r
+  fseek (ExeFile, 0, SEEK_SET);\r
+  //\r
+  // Attempt to read the TE header\r
+  //\r
+  if (fread (&TeHeader, sizeof (TeHeader), 1, ExeFile) == 1) {\r
+    if (TeHeader.Signature == EFI_TE_IMAGE_HEADER_SIGNATURE) {\r
+      if (TeHeader.Machine != EFI_IMAGE_MACHINE_IA32) {\r
+        Error (NULL, 0, 0, "The SEC file is PE but is not PE32 for IA32", NULL);\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      *EntryPoint = TeHeader.AddressOfEntryPoint + sizeof (EFI_TE_IMAGE_HEADER) - TeHeader.StrippedSize;\r
+      return STATUS_SUCCESS;\r
+    }\r
+  }\r
+  //\r
+  // Check if it is a PE file\r
+  //\r
+  fseek (ExeFile, 0, SEEK_SET);\r
+  //\r
+  // Attempt to read the DOS header\r
+  //\r
+  if (fread (&DosHeader, sizeof (DosHeader), 1, ExeFile) != 1) {\r
+    goto InvalidFile;\r
+  }\r
+  //\r
+  // Check the magic number\r
+  //\r
+  if (DosHeader.e_magic != EFI_IMAGE_DOS_SIGNATURE) {\r
+    goto InvalidFile;\r
+  }\r
+  //\r
+  // Position into the file and read the NT PE header\r
+  //\r
+  fseek (ExeFile, (long) DosHeader.e_lfanew, SEEK_SET);\r
+  if (fread (&NtHeader, sizeof (NtHeader), 1, ExeFile) != 1) {\r
+    goto InvalidFile;\r
+  }\r
+  //\r
+  // Check the PE signature in the header\r
+  //\r
+  if (NtHeader.Signature != EFI_IMAGE_NT_SIGNATURE) {\r
+    goto InvalidFile;\r
+  }\r
+  //\r
+  // Make sure the PE file is PE32 for IA32\r
+  //\r
+  if (NtHeader.FileHeader.Machine != EFI_IMAGE_MACHINE_IA32 ||\r
+      NtHeader.OptionalHeader.Magic != EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC\r
+      ) {\r
+    Error (NULL, 0, 0, "The SEC file is PE but is not PE32 for IA32", NULL);\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Get the entry point from the optional header\r
+  //\r
+  *EntryPoint = NtHeader.OptionalHeader.AddressOfEntryPoint;\r
+  return STATUS_SUCCESS;\r
+\r
+InvalidFile:\r
+  Error (NULL, 0, 0, "The SEC file is neither PE nor TE file", NULL);\r
+  return STATUS_ERROR;\r
+}\r
+\r
+STATUS\r
+CopyFile (\r
+  FILE    *FpIn,\r
+  FILE    *FpOut\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Copy file.\r
+\r
+Arguments:\r
+\r
+  FpIn  - File pointer to the source file.\r
+  FpOut - File pointer to the destination file.\r
+\r
+Returns:\r
+  STATUS_SUCCESS - Function completed successfully.\r
+  STATUS_ERROR   - Error occured.\r
+\r
+--*/\r
+{\r
+  INTN  FileSize;\r
+\r
+  INTN  Offset;\r
+\r
+  INTN  Length;\r
+  UINT8 Buffer[BUF_SIZE];\r
+\r
+  fseek (FpIn, 0, SEEK_END);\r
+  FileSize = ftell (FpIn);\r
+\r
+  fseek (FpIn, 0, SEEK_SET);\r
+  fseek (FpOut, 0, SEEK_SET);\r
+\r
+  Offset = 0;\r
+  while (Offset < FileSize) {\r
+    Length = sizeof (Buffer);\r
+    if (FileSize - Offset < Length) {\r
+      Length = FileSize - Offset;\r
+    }\r
+\r
+    if (fread (Buffer, Length, 1, FpIn) != 1 || fwrite (Buffer, Length, 1, FpOut) != 1) {\r
+      Error (NULL, 0, 0, "Copy file error", NULL);\r
+      return STATUS_ERROR;\r
+    }\r
+\r
+    Offset += Length;\r
+  }\r
+\r
+  return STATUS_SUCCESS;\r
+}\r
diff --git a/Tools/CodeTools/Source/SecFixup/SecFixup.h b/Tools/CodeTools/Source/SecFixup/SecFixup.h
new file mode 100644 (file)
index 0000000..3694b15
--- /dev/null
@@ -0,0 +1,146 @@
+/*++\r
+\r
+Copyright (c)  1999-2006 Intel Corporation. All rights reserved\r
+This program and the accompanying materials are licensed and made available \r
+under the terms and conditions of the BSD License which accompanies this \r
+distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+\r
+Module Name:\r
+  \r
+  SecFixup.h\r
+\r
+Abstract:\r
+\r
+  Definitions for the SecFixup utility.\r
+\r
+--*/\r
+\r
+#ifndef _SEC_FIXUP_H\r
+#define _SEC_FIXUP_H\r
+\r
+//\r
+// Utility Name\r
+//\r
+#define UTILITY_NAME  "SecFixup"\r
+\r
+//\r
+// Utility version information\r
+//\r
+#define UTILITY_MAJOR_VERSION 0\r
+#define UTILITY_MINOR_VERSION 1\r
+#define UTILITY_DATE          __DATE__\r
+\r
+//\r
+// The maximum number of arguments accepted from the command line.\r
+//\r
+#define MAX_ARGS        4\r
+\r
+#define DEST_REL_OFFSET 13\r
+#define BUF_SIZE        (8 * 1024)\r
+\r
+//\r
+// The function that displays general utility information\r
+//\r
+VOID\r
+PrintUtilityInfo (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  None\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+//\r
+// The function that displays the utility usage message.\r
+//\r
+VOID\r
+PrintUsage (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  None\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+//\r
+// The function that gets the entry point of a PE/TE file.\r
+//\r
+STATUS\r
+GetEntryPoint (\r
+  IN  FILE   *ExeFile,\r
+  OUT UINT32 *EntryPoint\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  ExeFile     - GC_TODO: add argument description\r
+  EntryPoint  - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+//\r
+// The function that copies a file.\r
+//\r
+STATUS\r
+CopyFile (\r
+  FILE    *FpIn,\r
+  FILE    *FpOut\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  FpIn  - GC_TODO: add argument description\r
+  FpOut - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+#endif\r
diff --git a/Tools/CodeTools/Source/SecFixup/build.xml b/Tools/CodeTools/Source/SecFixup/build.xml
new file mode 100644 (file)
index 0000000..ebc408b
--- /dev/null
@@ -0,0 +1,70 @@
+<?xml version="1.0" ?>\r
+<!--\r
+Copyright (c) 2006, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+-->\r
+<project default="GenTool" basedir=".">\r
+<!--\r
+    EDK SecFixup Tool\r
+  Copyright (c) 2006, Intel Corporation\r
+-->\r
+  <property name="ToolName" value="SecFixup"/>\r
+  <property name="FileSet" value="*.c"/>\r
+\r
+  <taskdef resource="cpptasks.tasks"/>\r
+  <typedef resource="cpptasks.types"/>\r
+  <taskdef resource="net/sf/antcontrib/antlib.xml"/>\r
+\r
+  <property name="LINK_OUTPUT_TYPE" value="static"/>\r
+  <property name="BUILD_DIR" value="${PACKAGE_DIR}/${ToolName}/tmp"/>\r
+\r
+  <target name="GenTool" depends="init, Tool">\r
+    <echo message="The EDK Tool: ${ToolName} build has completed!"/>\r
+  </target>\r
+\r
+  <target name="init">\r
+    <echo message="Building the EDK Tool: ${ToolName}"/>\r
+    <mkdir dir="${BUILD_DIR}"/>\r
+  </target>\r
+\r
+  <target name="Tool" depends="init">\r
+    <cc name="${ToolChain}" objdir="${BUILD_DIR}" \r
+        outfile="${BIN_DIR}/${ToolName}"\r
+        outtype="executable"\r
+        optimize="speed" \r
+        debug="true">\r
+\r
+      <fileset dir="${basedir}/${ToolName}" \r
+        includes="${FileSet}" \r
+        defaultexcludes="TRUE" \r
+        excludes="*.xml *.inf"/>\r
+\r
+      <includepath path="${PACKAGE_DIR}/Include"/>\r
+      <includepath path="${PACKAGE_DIR}/Include/${HostArch}"/>\r
+      <includepath path="${PACKAGE_DIR}/Common"/>\r
+      <libset dir="${LIB_DIR}" libs="CommonTools"/>\r
+    </cc>\r
+  </target>\r
+\r
+  <target name="clean">\r
+    <echo message="Removing Intermediate Files Only"/>  \r
+    <delete>\r
+      <fileset dir="${BUILD_DIR}" includes="*.obj"/>\r
+    </delete>\r
+  </target>\r
+\r
+  <target name="cleanall">\r
+    <echo message="Removing Object Files and the Executable: ${ToolName}${ext_exe}"/>  \r
+    <delete failonerror="false" quiet="true" includeEmptyDirs="true">\r
+      <fileset dir="${BUILD_DIR}"/>\r
+      <fileset file="${BIN_DIR}/${ToolName}${ext_exe}"/>\r
+    </delete>\r
+  </target>\r
+\r
+</project>\r
diff --git a/Tools/CodeTools/Source/SetStamp/SetStamp.c b/Tools/CodeTools/Source/SetStamp/SetStamp.c
new file mode 100644 (file)
index 0000000..539aced
--- /dev/null
@@ -0,0 +1,475 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  SetStamp.c\r
+\r
+Abstract:\r
+  Set Date/Time Stamp of Portable Executable (PE) format file\r
+\r
+--*/\r
+\r
+#include <stdio.h>\r
+#include <string.h>\r
+#include <time.h>\r
+\r
+#define LINE_MAXLEN 80\r
+\r
+void\r
+PrintUsage (\r
+  void\r
+  )\r
+/*++\r
+Routine Description:\r
+  print usage of setstamp command\r
+\r
+Arguments:\r
+  void\r
+\r
+Returns:\r
+  None\r
+--*/\r
+{\r
+  //\r
+  // print usage of command\r
+  //\r
+  printf ("Usage: SetStamp <PE-File> <TIME-File>\n");\r
+}\r
+\r
+int\r
+GetDateTime (\r
+  FILE      *fp,\r
+  time_t    *ltime\r
+  )\r
+/*++\r
+Routine Description:\r
+  Read the date and time from TIME file. If the date/time string is\r
+"NOW NOW", write the current date and time to TIME file and set it to\r
+ltime. Else, set the date and time of TIME file to ltime.\r
+\r
+Arguments:\r
+  fp              - The pointer of TIME file\r
+  ltime           - Date and time\r
+\r
+Returns:\r
+  =  0            - Success\r
+  = -1            - Failed\r
+--*/\r
+{\r
+  char      buffer[LINE_MAXLEN];\r
+  struct tm stime;\r
+  struct tm *now;\r
+\r
+  if (fgets (buffer, LINE_MAXLEN, fp) == NULL) {\r
+    printf ("Error: Cannot read TIME file.\n");\r
+    return -1;\r
+  }\r
+  //\r
+  // compare the value with "NOW NOW", write TIME file if equal\r
+  //\r
+  if (strncmp (buffer, "NOW NOW", 7) == 0) {\r
+    //\r
+    // get system current time and date\r
+    //\r
+    time (ltime);\r
+\r
+    now = localtime (ltime);\r
+    if (now == NULL) {\r
+      printf ("Error: Cannot get local time.\n");\r
+      return -1;\r
+    }\r
+\r
+    if (strftime (buffer, LINE_MAXLEN, "%Y-%m-%d %H:%M:%S", now) == 0) {\r
+      printf ("Error: Cannot format time string.\n");\r
+      return -1;\r
+    }\r
+    //\r
+    // write TIME file\r
+    //\r
+    if (fseek (fp, 0, SEEK_SET) != 0) {\r
+      printf ("Error: Cannot move location of TIME file.\n");\r
+      return -1;\r
+    }\r
+\r
+    if (fputs (buffer, fp) == EOF) {\r
+      printf ("Error: Cannot write time string to TIME file.\n");\r
+      return -1;\r
+    }\r
+    //\r
+    // ltime has been set as current time and date, return\r
+    //\r
+    return 0;\r
+  }\r
+  //\r
+  // get the date and time from buffer\r
+  //\r
+  if (6 != sscanf (\r
+            buffer,\r
+            "%d-%d-%d %d:%d:%d",\r
+            &stime.tm_year,\r
+            &stime.tm_mon,\r
+            &stime.tm_mday,\r
+            &stime.tm_hour,\r
+            &stime.tm_min,\r
+            &stime.tm_sec\r
+            )) {\r
+    printf ("Error: Invaild date or time!\n");\r
+    return -1;\r
+  }\r
+  //\r
+  // in struct, Month (0 - 11; Jan = 0). So decrease 1 from it\r
+  //\r
+  stime.tm_mon -= 1;\r
+\r
+  //\r
+  // in struct, Year (current year minus 1900)\r
+  // and only the dates can be handled from Jan 1, 1970 to Jan 18, 2038\r
+  //\r
+  //\r
+  // convert 0 -> 100 (2000), 1 -> 101 (2001), ..., 38 -> 138 (2038)\r
+  //\r
+  if (stime.tm_year <= 38) {\r
+    stime.tm_year += 100;\r
+  }\r
+  //\r
+  // convert 1970 -> 70, 2000 -> 100, ...\r
+  //\r
+  else if (stime.tm_year >= 1970) {\r
+    stime.tm_year -= 1900;\r
+  }\r
+  //\r
+  // convert the date and time to time_t format\r
+  //\r
+  *ltime = mktime (&stime);\r
+  if (*ltime == (time_t) - 1) {\r
+    printf ("Error: Invalid date or time!\n");\r
+    return -1;\r
+  }\r
+\r
+  return 0;\r
+}\r
+\r
+int\r
+ReadFromFile (\r
+  FILE      *fp,\r
+  long      offset,\r
+  void      *buffer,\r
+  int       size\r
+  )\r
+/*++\r
+Routine Description:\r
+  read data from a specified location of file\r
+\r
+Arguments:\r
+  fp              - file pointer\r
+  offset          - number of bytes from beginning of file\r
+  buffer          - buffer used to store data\r
+  size            - size of buffer\r
+\r
+Returns:\r
+  =  0            - Success\r
+  = -1            - Failed\r
+--*/\r
+{\r
+  //\r
+  // set file pointer to the specified location of file\r
+  //\r
+  if (fseek (fp, offset, SEEK_SET) != 0) {\r
+    printf ("Error: Cannot move the current location of the file.\n");\r
+    return -1;\r
+  }\r
+  //\r
+  // read data from the file\r
+  //\r
+  if (fread (buffer, size, 1, fp) != 1) {\r
+    printf ("Error: Cannot read data from the file.\n");\r
+    return -1;\r
+  }\r
+\r
+  return 0;\r
+}\r
+\r
+int\r
+WriteToFile (\r
+  FILE      *fp,\r
+  long      offset,\r
+  void      *buffer,\r
+  int       size\r
+  )\r
+/*++\r
+Routine Description:\r
+  write data to a specified location of file\r
+\r
+Arguments:\r
+  fp              - file pointer\r
+  offset          - number of bytes from beginning of file\r
+  buffer          - buffer used to store data\r
+  size            - size of buffer\r
+\r
+Returns:\r
+  =  0            - Success\r
+  = -1            - Failed\r
+--*/\r
+{\r
+  //\r
+  // set file pointer to the specified location of file\r
+  //\r
+  if (fseek (fp, offset, SEEK_SET) != 0) {\r
+    printf ("Error: Cannot move the current location of the file.\n");\r
+    return -1;\r
+  }\r
+  //\r
+  // write data to the file\r
+  //\r
+  if (fwrite (buffer, size, 1, fp) != 1) {\r
+    perror ("Error: Cannot write data to the file.\n");\r
+    return -1;\r
+  }\r
+\r
+  return 0;\r
+}\r
+\r
+int\r
+SetStamp (\r
+  FILE      *fp,\r
+  time_t    ltime\r
+  )\r
+/*++\r
+Routine Description:\r
+  set Date/Time Stamp of the file\r
+\r
+Arguments:\r
+  fp              - file pointer\r
+  ltime           - time and date\r
+\r
+Returns:\r
+  =  0            - Success\r
+  = -1            - Failed\r
+--*/\r
+{\r
+  unsigned char header[4];\r
+  unsigned long offset;\r
+  unsigned long NumberOfRvaAndSizes;\r
+  unsigned int  nvalue;\r
+  unsigned long lvalue;\r
+\r
+  //\r
+  // read the header of file\r
+  //\r
+  if (ReadFromFile (fp, 0, header, 2) != 0) {\r
+    return -1;\r
+  }\r
+  //\r
+  // "MZ" -- the header of image file (PE)\r
+  //\r
+  if (strncmp ((char *) header, "MZ", 2) != 0) {\r
+    printf ("Error: Invalid Image file.\n");\r
+    return -1;\r
+  }\r
+  //\r
+  // At location 0x3C, the stub has the file offset to the\r
+  // PE signature.\r
+  //\r
+  if (ReadFromFile (fp, 0x3C, &offset, 4) != 0) {\r
+    return -1;\r
+  }\r
+  //\r
+  // read the header of optional\r
+  //\r
+  if (ReadFromFile (fp, offset, header, 4) != 0) {\r
+    return -1;\r
+  }\r
+  //\r
+  // "PE\0\0" -- the signature of optional header\r
+  //\r
+  if (strncmp ((char *) header, "PE\0\0", 4) != 0) {\r
+    printf ("Error: Invalid PE format file.\n");\r
+    return -1;\r
+  }\r
+  //\r
+  // Add 8 to skip PE signature (4-byte), Machine (2-byte) and\r
+  // NumberOfSection (2-byte)\r
+  //\r
+  offset += 8;\r
+\r
+  if (WriteToFile (fp, offset, &ltime, 4) != 0) {\r
+    return -1;\r
+  }\r
+  //\r
+  // Add 16 to skip COFF file header, and get to optional header.\r
+  //\r
+  offset += 16;\r
+\r
+  //\r
+  // Check the magic field, 0x10B for PE32 and 0x20B for PE32+\r
+  //\r
+  if (ReadFromFile (fp, offset, &nvalue, 2) != 0) {\r
+    return -1;\r
+  }\r
+  //\r
+  // If this is PE32 image file, offset of NumberOfRvaAndSizes is 92.\r
+  // Else it is 108.\r
+  //\r
+  switch (nvalue & 0xFFFF) {\r
+  case 0x10B:\r
+    offset += 92;\r
+    break;\r
+\r
+  case 0x20B:\r
+    offset += 108;\r
+    break;\r
+\r
+  default:\r
+    printf ("Error: Sorry! The Magic value is unknown.\n");\r
+    return -1;\r
+  }\r
+  //\r
+  // get the value of NumberOfRvaAndSizes\r
+  //\r
+  if (ReadFromFile (fp, offset, &NumberOfRvaAndSizes, 4) != 0) {\r
+    return -1;\r
+  }\r
+  //\r
+  // Date/time stamp exists in Export Table, Import Table, Resource Table,\r
+  // Debug Table and Delay Import Table. And in Import Table and Delay Import\r
+  // Table, it will be set when bound. So here only set the date/time stamp\r
+  // of Export Table, Resource Table and Debug Table.\r
+  //\r
+  //\r
+  // change date/time stamp of Export Table, the offset of Export Table\r
+  // is 4 + 0 * 8 = 4. And the offset of stamp is 4.\r
+  //\r
+  if (NumberOfRvaAndSizes >= 1) {\r
+    if (ReadFromFile (fp, offset + 4, &lvalue, 4) != 0) {\r
+      return -1;\r
+    }\r
+\r
+    if (lvalue != 0) {\r
+      if (WriteToFile (fp, lvalue + 4, &ltime, 4) != 0) {\r
+        return -1;\r
+      }\r
+    }\r
+  }\r
+  //\r
+  // change date/time stamp of Resource Table, the offset of Resource Table\r
+  // is 4 + 2 * 8 = 20. And the offset of stamp is 4.\r
+  //\r
+  if (NumberOfRvaAndSizes >= 3) {\r
+    if (ReadFromFile (fp, offset + 20, &lvalue, 4) != 0) {\r
+      return -1;\r
+    }\r
+\r
+    if (lvalue != 0) {\r
+      if (WriteToFile (fp, lvalue + 4, &ltime, 4) != 0) {\r
+        return -1;\r
+      }\r
+    }\r
+  }\r
+  //\r
+  // change date/time stamp of Debug Table, offset of Debug Table\r
+  // is 4 + 6 * 8 = 52. And the offset of stamp is 4.\r
+  //\r
+  if (NumberOfRvaAndSizes >= 7) {\r
+    if (ReadFromFile (fp, offset + 52, &lvalue, 4) != 0) {\r
+      return -1;\r
+    }\r
+\r
+    if (lvalue != 0) {\r
+      if (WriteToFile (fp, lvalue + 4, &ltime, 4) != 0) {\r
+        return -1;\r
+      }\r
+    }\r
+    //\r
+    // change the date/time stamp of Debug Data\r
+    //\r
+    if (ReadFromFile (fp, lvalue + 24, &lvalue, 4) != 0) {\r
+      return -1;\r
+    }\r
+    //\r
+    // get the signature of debug data\r
+    //\r
+    if (ReadFromFile (fp, lvalue, header, 2) != 0) {\r
+      return -1;\r
+    }\r
+    //\r
+    // "NB" - the signature of Debug Data\r
+    // Need Review: (From Spec. is "NB05", From .dll is "NB10")\r
+    //\r
+    if (strncmp ((char *) header, "NB", 2) == 0) {\r
+      if (WriteToFile (fp, lvalue + 8, &ltime, 4) != 0) {\r
+        return -1;\r
+      }\r
+    }\r
+  }\r
+\r
+  return 0;\r
+}\r
+\r
+int\r
+main (\r
+  int       argc,\r
+  char      *argv[]\r
+  )\r
+{\r
+  FILE    *fp;\r
+  time_t  ltime;\r
+\r
+  //\r
+  // check the number of parameters\r
+  //\r
+  if (argc != 3) {\r
+    PrintUsage ();\r
+    return -1;\r
+  }\r
+  //\r
+  // open the TIME file, if not exists, return\r
+  //\r
+  fp = fopen (argv[2], "r+");\r
+  if (fp == NULL) {\r
+    return 0;\r
+  }\r
+  //\r
+  // get time and date from file\r
+  //\r
+  if (GetDateTime (fp, &ltime) != 0) {\r
+    fclose (fp);\r
+    return -1;\r
+  }\r
+  //\r
+  // close the TIME file\r
+  //\r
+  fclose (fp);\r
+\r
+  //\r
+  // open the PE file\r
+  //\r
+  fp = fopen (argv[1], "r+b");\r
+  if (fp == NULL) {\r
+    printf ("Error: Cannot open the PE file!\n");\r
+    return -1;\r
+  }\r
+  //\r
+  // set time and date stamp to the PE file\r
+  //\r
+  if (SetStamp (fp, ltime) != 0) {\r
+    fclose (fp);\r
+    return -1;\r
+  }\r
+\r
+  printf ("Set Date/Time Stamp to %s", ctime (&ltime));\r
+\r
+  //\r
+  // close the PE file\r
+  //\r
+  fclose (fp);\r
+\r
+  return 0;\r
+}\r
diff --git a/Tools/CodeTools/Source/SetStamp/build.xml b/Tools/CodeTools/Source/SetStamp/build.xml
new file mode 100644 (file)
index 0000000..9425797
--- /dev/null
@@ -0,0 +1,70 @@
+<?xml version="1.0" ?>\r
+<!--\r
+Copyright (c) 2006, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+-->\r
+<project default="GenTool" basedir=".">\r
+<!--\r
+    EDK SetStamp Tool\r
+  Copyright (c) 2006, Intel Corporation\r
+-->\r
+  <property name="ToolName" value="SetStamp"/>\r
+  <property name="FileSet" value="SetStamp.c"/>\r
+\r
+  <taskdef resource="cpptasks.tasks"/>\r
+  <typedef resource="cpptasks.types"/>\r
+  <taskdef resource="net/sf/antcontrib/antlib.xml"/>\r
+\r
+  <property name="LINK_OUTPUT_TYPE" value="static"/>\r
+  <property name="BUILD_DIR" value="${PACKAGE_DIR}/${ToolName}/tmp"/>\r
+\r
+  <target name="GenTool" depends="init, Tool">\r
+    <echo message="The EDK Tool: ${ToolName} build has completed!"/>\r
+  </target>\r
+\r
+  <target name="init">\r
+    <echo message="Building the EDK Tool: ${ToolName}"/>\r
+    <mkdir dir="${BUILD_DIR}"/>\r
+  </target>\r
+\r
+  <target name="Tool" depends="init">\r
+    <cc name="${ToolChain}" objdir="${BUILD_DIR}" \r
+        outfile="${BIN_DIR}/${ToolName}"\r
+        outtype="executable"\r
+        debug="true"\r
+        optimize="speed">\r
+\r
+      <fileset dir="${basedir}/${ToolName}" \r
+        includes="${FileSet}" \r
+        defaultexcludes="TRUE" \r
+        excludes="*.xml *.inf"/>\r
+\r
+      <includepath path="${PACKAGE_DIR}/Include"/>\r
+      <includepath path="${PACKAGE_DIR}/Include/Ia32"/>\r
+      <includepath path="${PACKAGE_DIR}/Common"/>\r
+\r
+    </cc>\r
+  </target>\r
+\r
+  <target name="clean">\r
+    <echo message="Removing Intermediate Files Only"/>  \r
+    <delete>\r
+      <fileset dir="${BUILD_DIR}" includes="*.obj"/>\r
+    </delete>\r
+  </target>\r
+\r
+  <target name="cleanall">\r
+    <echo message="Removing Object Files and the Executable: ${ToolName}${ext_exe}"/>  \r
+    <delete failonerror="false" quiet="true" includeEmptyDirs="true">\r
+      <fileset dir="${BUILD_DIR}"/>\r
+      <fileset file="${BIN_DIR}/${ToolName}${ext_exe}"/>\r
+    </delete>\r
+  </target>\r
+\r
+</project>\r
diff --git a/Tools/CodeTools/Source/SplitFile/SplitFile.c b/Tools/CodeTools/Source/SplitFile/SplitFile.c
new file mode 100644 (file)
index 0000000..a1bda7d
--- /dev/null
@@ -0,0 +1,131 @@
+/*\r
+\r
+Copyright (c)  1999-2006 Intel Corporation. All rights reserved\r
+This program and the accompanying materials are licensed and made available \r
+under the terms and conditions of the BSD License which accompanies this \r
+distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+*/\r
+\r
+// GC_TODO: fix comment to start with /*++\r
+#include "stdio.h"\r
+#include "string.h"\r
+#include "stdlib.h"\r
+\r
+void\r
+helpmsg (\r
+  void\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+{\r
+  printf (\r
+    "SplitFile Filename Offset\n""   Filename = Input file to split\n""   Offset = offset at which to split file\n"\r
+    "\n\n""SplitFile will break a file in two pieces at the requested offset\n"\r
+    "  outputting Filename1 and Filename2\n"\r
+    );\r
+}\r
+\r
+int\r
+main (\r
+  int argc,\r
+  char*argv[]\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  argc  - GC_TODO: add argument description\r
+  ]     - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+{\r
+  FILE          *In;\r
+\r
+  FILE          *Out1;\r
+\r
+  FILE          *Out2;\r
+  char          OutName1[512];\r
+  char          OutName2[512];\r
+  unsigned long Index;\r
+  unsigned long splitpoint;\r
+  char          CharC;\r
+\r
+  if (argc != 3) {\r
+    helpmsg ();\r
+    return -1;\r
+  }\r
+\r
+  In = fopen (argv[1], "rb");\r
+  if (In == NULL) {\r
+    printf ("Unable to open file \"%s\"\n", argv[1]);\r
+    return -1;\r
+  }\r
+\r
+  strncpy (OutName1, argv[1], 510);\r
+  strncpy (OutName2, argv[1], 510);\r
+  strcat (OutName1, "1");\r
+  strcat (OutName2, "2");\r
+\r
+  Out1 = fopen (OutName1, "wb");\r
+  if (Out1 == NULL) {\r
+    printf ("Unable to open file \"%s\"\n", OutName1);\r
+    return -1;\r
+  }\r
+\r
+  Out2 = fopen (OutName2, "wb");\r
+  if (Out2 == NULL) {\r
+    printf ("Unable to open file \"%s\"\n", OutName2);\r
+    return -1;\r
+  }\r
+\r
+  splitpoint = atoi (argv[2]);\r
+\r
+  for (Index = 0; Index < splitpoint; Index++) {\r
+    CharC = (char) fgetc (In);\r
+    if (feof (In)) {\r
+      break;\r
+    }\r
+\r
+    fputc (CharC, Out1);\r
+  }\r
+\r
+  for (;;) {\r
+    CharC = (char) fgetc (In);\r
+    if (feof (In)) {\r
+      break;\r
+    }\r
+\r
+    fputc (CharC, Out2);\r
+  }\r
+\r
+  fclose (In);\r
+  fclose (Out1);\r
+  fclose (Out2);\r
+\r
+  return 0;\r
+}\r
diff --git a/Tools/CodeTools/Source/SplitFile/build.xml b/Tools/CodeTools/Source/SplitFile/build.xml
new file mode 100644 (file)
index 0000000..6fa9b57
--- /dev/null
@@ -0,0 +1,69 @@
+<?xml version="1.0" ?>\r
+<!--\r
+Copyright (c) 2006, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+-->\r
+<project default="GenTool" basedir=".">\r
+<!--\r
+    EDK SplitFile Tool\r
+  Copyright (c) 2006, Intel Corporation\r
+-->\r
+  <property name="ToolName" value="SplitFile"/>\r
+  <property name="FileSet" value="*.c"/>\r
+\r
+  <taskdef resource="cpptasks.tasks"/>\r
+  <typedef resource="cpptasks.types"/>\r
+  <taskdef resource="net/sf/antcontrib/antlib.xml"/>\r
+\r
+  <property name="LINK_OUTPUT_TYPE" value="static"/>\r
+  <property name="BUILD_DIR" value="${PACKAGE_DIR}/${ToolName}/tmp"/>\r
+\r
+  <target name="GenTool" depends="init, Tool">\r
+    <echo message="The EDK Tool: ${ToolName} build has completed!"/>\r
+  </target>\r
+\r
+  <target name="init">\r
+    <echo message="Building the EDK Tool: ${ToolName}"/>\r
+    <mkdir dir="${BUILD_DIR}"/>\r
+  </target>\r
+\r
+  <target name="Tool" depends="init">\r
+    <cc name="${ToolChain}" objdir="${BUILD_DIR}" \r
+        outfile="${BIN_DIR}/${ToolName}"\r
+        outtype="executable"\r
+        optimize="speed" \r
+        debug="true">\r
+\r
+      <fileset dir="${basedir}/${ToolName}" \r
+        includes="${FileSet}" \r
+        defaultexcludes="TRUE" \r
+        excludes="*.xml *.inf"/>\r
+\r
+      <includepath path="${PACKAGE_DIR}/Include"/>\r
+      <includepath path="${PACKAGE_DIR}/Include/Ia32"/>\r
+      <includepath path="${PACKAGE_DIR}/Common"/>\r
+    </cc>\r
+  </target>\r
+\r
+  <target name="clean">\r
+    <echo message="Removing Intermediate Files Only"/>  \r
+    <delete>\r
+      <fileset dir="${BUILD_DIR}" includes="*.obj"/>\r
+    </delete>\r
+  </target>\r
+\r
+  <target name="cleanall">\r
+    <echo message="Removing Object Files and the Executable: ${ToolName}${ext_exe}"/>  \r
+    <delete failonerror="false" quiet="true" includeEmptyDirs="true">\r
+      <fileset dir="${BUILD_DIR}"/>\r
+      <fileset file="${BIN_DIR}/${ToolName}${ext_exe}"/>\r
+    </delete>\r
+  </target>\r
+\r
+</project>\r
diff --git a/Tools/CodeTools/Source/StrGather/StrGather.c b/Tools/CodeTools/Source/StrGather/StrGather.c
new file mode 100644 (file)
index 0000000..9eb5c5a
--- /dev/null
@@ -0,0 +1,2531 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  StrGather.c  \r
+\r
+Abstract:\r
+\r
+  Parse a strings file and create or add to a string database file.\r
+\r
+--*/\r
+\r
+#include <stdio.h>\r
+#include <string.h>\r
+#include <stdlib.h>\r
+#include <ctype.h>\r
+\r
+#include <Common/UefiBaseTypes.h>\r
+\r
+#include "CommonLib.h"\r
+#include "EfiUtilityMsgs.h"\r
+#include "StrGather.h"\r
+#include "StringDB.h"\r
+\r
+#define TOOL_VERSION  "0.31"\r
+\r
+#ifndef MAX_PATH\r
+#define MAX_PATH                    255\r
+#endif\r
+#define MAX_NEST_DEPTH              20  // just in case we get in an endless loop.\r
+#define MAX_STRING_IDENTIFIER_NAME  100 // number of wchars\r
+#define MAX_LINE_LEN                200\r
+#define STRING_TOKEN                "STRING_TOKEN"\r
+#define DEFAULT_BASE_NAME           "BaseName"\r
+//\r
+// Operational modes for this utility\r
+//\r
+#define MODE_UNKNOWN  0\r
+#define MODE_PARSE    1\r
+#define MODE_SCAN     2\r
+#define MODE_DUMP     3\r
+\r
+//\r
+// We keep a linked list of these for the source files we process\r
+//\r
+typedef struct _SOURCE_FILE {\r
+  FILE                *Fptr;\r
+  WCHAR               *FileBuffer;\r
+  WCHAR               *FileBufferPtr;\r
+  UINT32              FileSize;\r
+  CHAR8               FileName[MAX_PATH];\r
+  UINT32              LineNum;\r
+  BOOLEAN             EndOfFile;\r
+  BOOLEAN             SkipToHash;\r
+  struct _SOURCE_FILE *Previous;\r
+  struct _SOURCE_FILE *Next;\r
+  WCHAR               ControlCharacter;\r
+} SOURCE_FILE;\r
+\r
+#define DEFAULT_CONTROL_CHARACTER UNICODE_SLASH\r
+\r
+//\r
+// Here's all our globals. We need a linked list of include paths, a linked\r
+// list of source files, a linked list of subdirectories (appended to each\r
+// include path when searching), and a couple other fields.\r
+//\r
+static struct {\r
+  SOURCE_FILE                 SourceFiles;\r
+  TEXT_STRING_LIST            *IncludePaths;                    // all include paths to search\r
+  TEXT_STRING_LIST            *LastIncludePath;\r
+  TEXT_STRING_LIST            *ScanFileName;\r
+  TEXT_STRING_LIST            *LastScanFileName;\r
+  TEXT_STRING_LIST            *SkipExt;                         // if -skipext .uni\r
+  TEXT_STRING_LIST            *LastSkipExt;\r
+  TEXT_STRING_LIST            *IndirectionFileName;\r
+  TEXT_STRING_LIST            *LastIndirectionFileName;\r
+  TEXT_STRING_LIST            *DatabaseFileName;\r
+  TEXT_STRING_LIST            *LastDatabaseFileName;\r
+  WCHAR_STRING_LIST           *Language;\r
+  WCHAR_STRING_LIST           *LastLanguage;\r
+  WCHAR_MATCHING_STRING_LIST  *IndirectionList;                 // from indirection file(s)\r
+  WCHAR_MATCHING_STRING_LIST  *LastIndirectionList;\r
+  BOOLEAN                     Verbose;                          // for more detailed output\r
+  BOOLEAN                     VerboseDatabaseWrite;             // for more detailed output when writing database\r
+  BOOLEAN                     VerboseDatabaseRead;              // for more detailed output when reading database\r
+  BOOLEAN                     NewDatabase;                      // to start from scratch\r
+  BOOLEAN                     IgnoreNotFound;                   // when scanning\r
+  BOOLEAN                     VerboseScan;\r
+  BOOLEAN                     UnquotedStrings;                  // -uqs option\r
+  CHAR8                       OutputDatabaseFileName[MAX_PATH];\r
+  CHAR8                       StringHFileName[MAX_PATH];\r
+  CHAR8                       StringCFileName[MAX_PATH];        // output .C filename\r
+  CHAR8                       DumpUFileName[MAX_PATH];          // output unicode dump file name\r
+  CHAR8                       HiiExportPackFileName[MAX_PATH];  // HII export pack file name\r
+  CHAR8                       BaseName[MAX_PATH];               // base filename of the strings file\r
+  UINT32                      Mode;\r
+} mGlobals;\r
+\r
+static\r
+BOOLEAN\r
+IsValidIdentifierChar (\r
+  CHAR8     Char,\r
+  BOOLEAN   FirstChar\r
+  );\r
+\r
+static\r
+void\r
+RewindFile (\r
+  SOURCE_FILE *SourceFile\r
+  );\r
+\r
+static\r
+BOOLEAN\r
+SkipTo (\r
+  SOURCE_FILE *SourceFile,\r
+  WCHAR       WChar,\r
+  BOOLEAN     StopAfterNewline\r
+  );\r
+\r
+static\r
+UINT32\r
+SkipWhiteSpace (\r
+  SOURCE_FILE *SourceFile\r
+  );\r
+\r
+static\r
+BOOLEAN\r
+IsWhiteSpace (\r
+  SOURCE_FILE *SourceFile\r
+  );\r
+\r
+static\r
+BOOLEAN\r
+EndOfFile (\r
+  SOURCE_FILE *SourceFile\r
+  );\r
+\r
+static\r
+void\r
+PreprocessFile (\r
+  SOURCE_FILE *SourceFile\r
+  );\r
+\r
+static\r
+UINT32\r
+GetStringIdentifierName (\r
+  IN SOURCE_FILE  *SourceFile,\r
+  IN OUT WCHAR    *StringIdentifierName,\r
+  IN UINT32       StringIdentifierNameLen\r
+  );\r
+\r
+static\r
+UINT32\r
+GetLanguageIdentifierName (\r
+  IN SOURCE_FILE  *SourceFile,\r
+  IN OUT WCHAR    *LanguageIdentifierName,\r
+  IN UINT32       LanguageIdentifierNameLen,\r
+  IN BOOLEAN      Optional\r
+  );\r
+\r
+static\r
+WCHAR *\r
+GetPrintableLanguageName (\r
+  IN SOURCE_FILE  *SourceFile\r
+  );\r
+\r
+static\r
+STATUS\r
+AddCommandLineLanguage (\r
+  IN CHAR8         *Language\r
+  );\r
+\r
+static\r
+WCHAR *\r
+GetQuotedString (\r
+  SOURCE_FILE *SourceFile,\r
+  BOOLEAN     Optional\r
+  );\r
+\r
+static\r
+STATUS\r
+ProcessIncludeFile (\r
+  SOURCE_FILE *SourceFile,\r
+  SOURCE_FILE *ParentSourceFile\r
+  );\r
+\r
+static\r
+STATUS\r
+ParseFile (\r
+  SOURCE_FILE *SourceFile\r
+  );\r
+\r
+static\r
+FILE  *\r
+FindFile (\r
+  IN CHAR8    *FileName,\r
+  OUT CHAR8   *FoundFileName,\r
+  IN UINT32   FoundFileNameLen\r
+  );\r
+\r
+static\r
+STATUS\r
+ProcessArgs (\r
+  int   Argc,\r
+  char  *Argv[]\r
+  );\r
+\r
+static\r
+STATUS\r
+ProcessFile (\r
+  SOURCE_FILE *SourceFile\r
+  );\r
+\r
+static\r
+UINT32\r
+wstrcmp (\r
+  WCHAR *Buffer,\r
+  WCHAR *Str\r
+  );\r
+\r
+static\r
+void\r
+Usage (\r
+  VOID\r
+  );\r
+\r
+static\r
+void\r
+FreeLists (\r
+  VOID\r
+  );\r
+\r
+static\r
+void\r
+ProcessTokenString (\r
+  SOURCE_FILE *SourceFile\r
+  );\r
+\r
+static\r
+void\r
+ProcessTokenInclude (\r
+  SOURCE_FILE *SourceFile\r
+  );\r
+\r
+static\r
+void\r
+ProcessTokenScope (\r
+  SOURCE_FILE *SourceFile\r
+  );\r
+\r
+static\r
+void\r
+ProcessTokenLanguage (\r
+  SOURCE_FILE *SourceFile\r
+  );\r
+\r
+static\r
+void\r
+ProcessTokenLangDef (\r
+  SOURCE_FILE *SourceFile\r
+  );\r
+\r
+static\r
+STATUS\r
+ScanFiles (\r
+  TEXT_STRING_LIST *ScanFiles\r
+  );\r
+\r
+static\r
+STATUS\r
+ParseIndirectionFiles (\r
+  TEXT_STRING_LIST    *Files\r
+  );\r
+\r
+STATUS\r
+StringDBCreateHiiExportPack (\r
+  CHAR8               *OutputFileName\r
+  );\r
+\r
+int\r
+main (\r
+  int   Argc,\r
+  char  *Argv[]\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Call the routine to parse the command-line options, then process the file.\r
+  \r
+Arguments:\r
+\r
+  Argc - Standard C main() argc and argv.\r
+  Argv - Standard C main() argc and argv.\r
+\r
+Returns:\r
+\r
+  0       if successful\r
+  nonzero otherwise\r
+  \r
+--*/\r
+{\r
+  STATUS  Status;\r
+\r
+  SetUtilityName (PROGRAM_NAME);\r
+  //\r
+  // Process the command-line arguments\r
+  //\r
+  Status = ProcessArgs (Argc, Argv);\r
+  if (Status != STATUS_SUCCESS) {\r
+    return Status;\r
+  }\r
+  //\r
+  // Initialize the database manager\r
+  //\r
+  StringDBConstructor ();\r
+  //\r
+  // We always try to read in an existing database file. It may not\r
+  // exist, which is ok usually.\r
+  //\r
+  if (mGlobals.NewDatabase == 0) {\r
+    //\r
+    // Read all databases specified.\r
+    //\r
+    for (mGlobals.LastDatabaseFileName = mGlobals.DatabaseFileName;\r
+         mGlobals.LastDatabaseFileName != NULL;\r
+         mGlobals.LastDatabaseFileName = mGlobals.LastDatabaseFileName->Next\r
+        ) {\r
+      Status = StringDBReadDatabase (mGlobals.LastDatabaseFileName->Str, TRUE, mGlobals.VerboseDatabaseRead);\r
+      if (Status != STATUS_SUCCESS) {\r
+        return Status;\r
+      }\r
+    }\r
+  }\r
+  //\r
+  // Read indirection file(s) if specified\r
+  //\r
+  if (ParseIndirectionFiles (mGlobals.IndirectionFileName) != STATUS_SUCCESS) {\r
+    goto Finish;\r
+  }\r
+  //\r
+  // If scanning source files, do that now\r
+  //\r
+  if (mGlobals.Mode == MODE_SCAN) {\r
+    ScanFiles (mGlobals.ScanFileName);\r
+  } else if (mGlobals.Mode == MODE_PARSE) {\r
+    //\r
+    // Parsing a unicode strings file\r
+    //\r
+    mGlobals.SourceFiles.ControlCharacter = DEFAULT_CONTROL_CHARACTER;\r
+    Status = ProcessIncludeFile (&mGlobals.SourceFiles, NULL);\r
+    if (Status != STATUS_SUCCESS) {\r
+      goto Finish;\r
+    }\r
+  }\r
+  //\r
+  // Create the string defines header file if there have been no errors.\r
+  //\r
+  ParserSetPosition (NULL, 0);\r
+  if ((mGlobals.StringHFileName[0] != 0) && (GetUtilityStatus () < STATUS_ERROR)) {\r
+    Status = StringDBDumpStringDefines (mGlobals.StringHFileName, mGlobals.BaseName);\r
+    if (Status != EFI_SUCCESS) {\r
+      goto Finish;\r
+    }\r
+  }\r
+  //\r
+  // Dump the strings to a .c file if there have still been no errors.\r
+  //\r
+  if ((mGlobals.StringCFileName[0] != 0) && (GetUtilityStatus () < STATUS_ERROR)) {\r
+    Status = StringDBDumpCStrings (\r
+              mGlobals.StringCFileName,\r
+              mGlobals.BaseName,\r
+              mGlobals.Language,\r
+              mGlobals.IndirectionList\r
+              );\r
+    if (Status != EFI_SUCCESS) {\r
+      goto Finish;\r
+    }\r
+  }\r
+  //\r
+  // Dump the database if requested\r
+  //\r
+  if ((mGlobals.DumpUFileName[0] != 0) && (GetUtilityStatus () < STATUS_ERROR)) {\r
+    StringDBDumpDatabase (NULL, mGlobals.DumpUFileName, FALSE);\r
+  }\r
+  //\r
+  // Dump the string data as HII binary string pack if requested\r
+  //\r
+  if ((mGlobals.HiiExportPackFileName[0] != 0) && (GetUtilityStatus () < STATUS_ERROR)) {\r
+    StringDBCreateHiiExportPack (mGlobals.HiiExportPackFileName);\r
+  }\r
+  //\r
+  // Always update the database if no errors and not in dump mode. If they specified -od\r
+  // for an output database file name, then use that name. Otherwise use the name of\r
+  // the first database file specified with -db\r
+  //\r
+  if ((mGlobals.Mode != MODE_DUMP) && (GetUtilityStatus () < STATUS_ERROR)) {\r
+    if (mGlobals.OutputDatabaseFileName[0]) {\r
+      Status = StringDBWriteDatabase (mGlobals.OutputDatabaseFileName, mGlobals.VerboseDatabaseWrite);\r
+    } else {\r
+      Status = StringDBWriteDatabase (mGlobals.DatabaseFileName->Str, mGlobals.VerboseDatabaseWrite);\r
+    }\r
+\r
+    if (Status != EFI_SUCCESS) {\r
+      goto Finish;\r
+    }\r
+  }\r
+\r
+Finish:\r
+  //\r
+  // Free up memory\r
+  //\r
+  FreeLists ();\r
+  StringDBDestructor ();\r
+  return GetUtilityStatus ();\r
+}\r
+\r
+static\r
+STATUS\r
+ProcessIncludeFile (\r
+  SOURCE_FILE *SourceFile,\r
+  SOURCE_FILE *ParentSourceFile\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Given a source file, open the file and parse it\r
+  \r
+Arguments:\r
+\r
+  SourceFile        - name of file to parse\r
+  ParentSourceFile  - for error reporting purposes, the file that #included SourceFile.\r
+\r
+Returns:\r
+\r
+  Standard status.\r
+  \r
+--*/\r
+{\r
+  static UINT32 NestDepth = 0;\r
+  CHAR8         FoundFileName[MAX_PATH];\r
+  STATUS        Status;\r
+\r
+  Status = STATUS_SUCCESS;\r
+  NestDepth++;\r
+  //\r
+  // Print the file being processed. Indent so you can tell the include nesting\r
+  // depth.\r
+  //\r
+  if (mGlobals.Verbose) {\r
+    fprintf (stdout, "%*cProcessing file '%s'\n", NestDepth * 2, ' ', SourceFile->FileName);\r
+  }\r
+\r
+  //\r
+  // Make sure we didn't exceed our maximum nesting depth\r
+  //\r
+  if (NestDepth > MAX_NEST_DEPTH) {\r
+    Error (NULL, 0, 0, SourceFile->FileName, "max nesting depth (%d) exceeded", NestDepth);\r
+    Status = STATUS_ERROR;\r
+    goto Finish;\r
+  }\r
+  //\r
+  // Try to open the file locally, and if that fails try along our include paths.\r
+  //\r
+  strcpy (FoundFileName, SourceFile->FileName);\r
+  if ((SourceFile->Fptr = fopen (FoundFileName, "rb")) == NULL) {\r
+    //\r
+    // Try to find it among the paths if it has a parent (that is, it is included\r
+    // by someone else).\r
+    //\r
+    if (ParentSourceFile == NULL) {\r
+      Error (NULL, 0, 0, SourceFile->FileName, "file not found");\r
+      return STATUS_ERROR;\r
+    }\r
+\r
+    SourceFile->Fptr = FindFile (SourceFile->FileName, FoundFileName, sizeof (FoundFileName));\r
+    if (SourceFile->Fptr == NULL) {\r
+      Error (ParentSourceFile->FileName, ParentSourceFile->LineNum, 0, SourceFile->FileName, "include file not found");\r
+      return STATUS_ERROR;\r
+    }\r
+  }\r
+  //\r
+  // Process the file found\r
+  //\r
+  ProcessFile (SourceFile);\r
+Finish:\r
+  //\r
+  // Close open files and return status\r
+  //\r
+  if (SourceFile->Fptr != NULL) {\r
+    fclose (SourceFile->Fptr);\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
+static\r
+STATUS\r
+ProcessFile (\r
+  SOURCE_FILE *SourceFile\r
+  )\r
+{\r
+  //\r
+  // Get the file size, and then read the entire thing into memory.\r
+  // Allocate space for a terminator character.\r
+  //\r
+  fseek (SourceFile->Fptr, 0, SEEK_END);\r
+  SourceFile->FileSize = ftell (SourceFile->Fptr);\r
+  fseek (SourceFile->Fptr, 0, SEEK_SET);\r
+  SourceFile->FileBuffer = (WCHAR *) malloc (SourceFile->FileSize + sizeof (WCHAR));\r
+  if (SourceFile->FileBuffer == NULL) {\r
+    Error (NULL, 0, 0, "memory allocation failure", NULL);\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  fread ((VOID *) SourceFile->FileBuffer, SourceFile->FileSize, 1, SourceFile->Fptr);\r
+  SourceFile->FileBuffer[(SourceFile->FileSize / sizeof (WCHAR))] = UNICODE_NULL;\r
+  //\r
+  // Pre-process the file to replace comments with spaces\r
+  //\r
+  PreprocessFile (SourceFile);\r
+  //\r
+  // Parse the file\r
+  //\r
+  ParseFile (SourceFile);\r
+  free (SourceFile->FileBuffer);\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+STATUS\r
+ParseFile (\r
+  SOURCE_FILE *SourceFile\r
+  )\r
+{\r
+  BOOLEAN InComment;\r
+  UINT32  Len;\r
+\r
+  //\r
+  // First character of a unicode file is special. Make sure\r
+  //\r
+  if (SourceFile->FileBufferPtr[0] != UNICODE_FILE_START) {\r
+    Error (SourceFile->FileName, 1, 0, SourceFile->FileName, "file does not appear to be a unicode file");\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  SourceFile->FileBufferPtr++;\r
+  InComment = FALSE;\r
+  //\r
+  // Print the first line if in verbose mode\r
+  //\r
+  if (mGlobals.Verbose) {\r
+    printf ("%d: %S\n", SourceFile->LineNum, SourceFile->FileBufferPtr);\r
+  }\r
+  //\r
+  // Since the syntax is relatively straightforward, just switch on the next char\r
+  //\r
+  while (!EndOfFile (SourceFile)) {\r
+    //\r
+    // Check for whitespace\r
+    //\r
+    if (SourceFile->FileBufferPtr[0] == UNICODE_SPACE) {\r
+      SourceFile->FileBufferPtr++;\r
+    } else if (SourceFile->FileBufferPtr[0] == UNICODE_TAB) {\r
+      SourceFile->FileBufferPtr++;\r
+    } else if (SourceFile->FileBufferPtr[0] == UNICODE_CR) {\r
+      SourceFile->FileBufferPtr++;\r
+    } else if (SourceFile->FileBufferPtr[0] == UNICODE_LF) {\r
+      SourceFile->FileBufferPtr++;\r
+      SourceFile->LineNum++;\r
+      if (mGlobals.Verbose) {\r
+        printf ("%d: %S\n", SourceFile->LineNum, SourceFile->FileBufferPtr);\r
+      }\r
+\r
+      InComment = FALSE;\r
+    } else if (SourceFile->FileBufferPtr[0] == 0) {\r
+      SourceFile->FileBufferPtr++;\r
+    } else if (InComment) {\r
+      SourceFile->FileBufferPtr++;\r
+    } else if ((SourceFile->FileBufferPtr[0] == UNICODE_SLASH) && (SourceFile->FileBufferPtr[1] == UNICODE_SLASH)) {\r
+      SourceFile->FileBufferPtr += 2;\r
+      InComment = TRUE;\r
+    } else if (SourceFile->SkipToHash && (SourceFile->FileBufferPtr[0] != SourceFile->ControlCharacter)) {\r
+      SourceFile->FileBufferPtr++;\r
+    } else {\r
+      SourceFile->SkipToHash = FALSE;\r
+      if ((SourceFile->FileBufferPtr[0] == SourceFile->ControlCharacter) &&\r
+          ((Len = wstrcmp (SourceFile->FileBufferPtr + 1, L"include")) > 0)\r
+          ) {\r
+        SourceFile->FileBufferPtr += Len + 1;\r
+        ProcessTokenInclude (SourceFile);\r
+      } else if ((SourceFile->FileBufferPtr[0] == SourceFile->ControlCharacter) &&\r
+               (Len = wstrcmp (SourceFile->FileBufferPtr + 1, L"scope")) > 0\r
+              ) {\r
+        SourceFile->FileBufferPtr += Len + 1;\r
+        ProcessTokenScope (SourceFile);\r
+      } else if ((SourceFile->FileBufferPtr[0] == SourceFile->ControlCharacter) &&\r
+               (Len = wstrcmp (SourceFile->FileBufferPtr + 1, L"language")) > 0\r
+              ) {\r
+        SourceFile->FileBufferPtr += Len + 1;\r
+        ProcessTokenLanguage (SourceFile);\r
+      } else if ((SourceFile->FileBufferPtr[0] == SourceFile->ControlCharacter) &&\r
+               (Len = wstrcmp (SourceFile->FileBufferPtr + 1, L"langdef")) > 0\r
+              ) {\r
+        SourceFile->FileBufferPtr += Len + 1;\r
+        ProcessTokenLangDef (SourceFile);\r
+      } else if ((SourceFile->FileBufferPtr[0] == SourceFile->ControlCharacter) &&\r
+               (Len = wstrcmp (SourceFile->FileBufferPtr + 1, L"string")) > 0\r
+              ) {\r
+        SourceFile->FileBufferPtr += Len + 1;\r
+        ProcessTokenString (SourceFile);\r
+      } else if ((SourceFile->FileBufferPtr[0] == SourceFile->ControlCharacter) &&\r
+               (Len = wstrcmp (SourceFile->FileBufferPtr + 1, L"EFI_BREAKPOINT()")) > 0\r
+              ) {\r
+        SourceFile->FileBufferPtr += Len;\r
+        //\r
+        // BUGBUG: Caling EFI_BREAKOINT() is breaking the link.  What is the proper action for this tool\r
+        // in this condition?\r
+        //\r
+//        EFI_BREAKPOINT ();\r
+      } else if ((SourceFile->FileBufferPtr[0] == SourceFile->ControlCharacter) &&\r
+               (SourceFile->FileBufferPtr[1] == UNICODE_EQUAL_SIGN)\r
+              ) {\r
+        SourceFile->ControlCharacter = SourceFile->FileBufferPtr[2];\r
+        SourceFile->FileBufferPtr += 3;\r
+      } else {\r
+        Error (SourceFile->FileName, SourceFile->LineNum, 0, "unrecognized token", "%S", SourceFile->FileBufferPtr);\r
+        //\r
+        // Treat rest of line as a comment.\r
+        //\r
+        InComment = TRUE;\r
+      }\r
+    }\r
+  }\r
+\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+void\r
+PreprocessFile (\r
+  SOURCE_FILE *SourceFile\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Preprocess a file to replace all carriage returns with NULLs so\r
+  we can print lines from the file to the screen.\r
+  \r
+Arguments:\r
+  SourceFile - structure that we use to keep track of an input file.\r
+\r
+Returns:\r
+  Nothing.\r
+  \r
+--*/\r
+{\r
+  BOOLEAN InComment;\r
+\r
+  RewindFile (SourceFile);\r
+  InComment = FALSE;\r
+  while (!EndOfFile (SourceFile)) {\r
+    //\r
+    // If a line-feed, then no longer in a comment\r
+    //\r
+    if (SourceFile->FileBufferPtr[0] == UNICODE_LF) {\r
+      SourceFile->FileBufferPtr++;\r
+      SourceFile->LineNum++;\r
+      InComment = 0;\r
+    } else if (SourceFile->FileBufferPtr[0] == UNICODE_CR) {\r
+      //\r
+      // Replace all carriage returns with a NULL so we can print stuff\r
+      //\r
+      SourceFile->FileBufferPtr[0] = 0;\r
+      SourceFile->FileBufferPtr++;\r
+    } else if (InComment) {\r
+      SourceFile->FileBufferPtr[0] = UNICODE_SPACE;\r
+      SourceFile->FileBufferPtr++;\r
+    } else if ((SourceFile->FileBufferPtr[0] == UNICODE_SLASH) && (SourceFile->FileBufferPtr[1] == UNICODE_SLASH)) {\r
+      SourceFile->FileBufferPtr += 2;\r
+      InComment = TRUE;\r
+    } else {\r
+      SourceFile->FileBufferPtr++;\r
+    }\r
+  }\r
+  //\r
+  // Could check for end-of-file and still in a comment, but\r
+  // should not be necessary. So just restore the file pointers.\r
+  //\r
+  RewindFile (SourceFile);\r
+}\r
+\r
+static\r
+WCHAR *\r
+GetPrintableLanguageName (\r
+  IN SOURCE_FILE  *SourceFile\r
+  )\r
+{\r
+  WCHAR   *String;\r
+  WCHAR   *Start;\r
+  WCHAR   *Ptr;\r
+  UINT32  Len;\r
+\r
+  SkipWhiteSpace (SourceFile);\r
+  if (SourceFile->FileBufferPtr[0] != UNICODE_DOUBLE_QUOTE) {\r
+    Error (\r
+      SourceFile->FileName,\r
+      SourceFile->LineNum,\r
+      0,\r
+      "expected quoted printable language name",\r
+      "%S",\r
+      SourceFile->FileBufferPtr\r
+      );\r
+    SourceFile->SkipToHash = TRUE;\r
+    return NULL;\r
+  }\r
+\r
+  Len = 0;\r
+  SourceFile->FileBufferPtr++;\r
+  Start = Ptr = SourceFile->FileBufferPtr;\r
+  while (!EndOfFile (SourceFile)) {\r
+    if (SourceFile->FileBufferPtr[0] == UNICODE_CR) {\r
+      Warning (SourceFile->FileName, SourceFile->LineNum, 0, "carriage return found in quoted string", "%S", Start);\r
+      break;\r
+    } else if (SourceFile->FileBufferPtr[0] == UNICODE_DOUBLE_QUOTE) {\r
+      break;\r
+    }\r
+\r
+    SourceFile->FileBufferPtr++;\r
+    Len++;\r
+  }\r
+\r
+  if (SourceFile->FileBufferPtr[0] != UNICODE_DOUBLE_QUOTE) {\r
+    Warning (\r
+      SourceFile->FileName,\r
+      SourceFile->LineNum,\r
+      0,\r
+      "missing closing quote on printable language name string",\r
+      "%S",\r
+      Start\r
+      );\r
+  } else {\r
+    SourceFile->FileBufferPtr++;\r
+  }\r
+  //\r
+  // Now allocate memory for the string and save it off\r
+  //\r
+  String = (WCHAR *) malloc ((Len + 1) * sizeof (WCHAR));\r
+  if (String == NULL) {\r
+    Error (NULL, 0, 0, "memory allocation failed", NULL);\r
+    return NULL;\r
+  }\r
+  //\r
+  // Copy the string from the file buffer to the local copy.\r
+  // We do no reformatting of it whatsoever at this point.\r
+  //\r
+  Ptr = String;\r
+  while (Len > 0) {\r
+    *Ptr = *Start;\r
+    Start++;\r
+    Ptr++;\r
+    Len--;\r
+  }\r
+\r
+  *Ptr = 0;\r
+  //\r
+  // Now format the string to convert \wide and \narrow controls\r
+  //\r
+  StringDBFormatString (String);\r
+  return String;\r
+}\r
+\r
+static\r
+WCHAR *\r
+GetQuotedString (\r
+  SOURCE_FILE *SourceFile,\r
+  BOOLEAN     Optional\r
+  )\r
+{\r
+  WCHAR   *String;\r
+  WCHAR   *Start;\r
+  WCHAR   *Ptr;\r
+  UINT32  Len;\r
+  BOOLEAN PreviousBackslash;\r
+\r
+  if (SourceFile->FileBufferPtr[0] != UNICODE_DOUBLE_QUOTE) {\r
+    if (!Optional) {\r
+      Error (SourceFile->FileName, SourceFile->LineNum, 0, "expected quoted string", "%S", SourceFile->FileBufferPtr);\r
+    }\r
+\r
+    return NULL;\r
+  }\r
+\r
+  Len = 0;\r
+  SourceFile->FileBufferPtr++;\r
+  Start             = Ptr = SourceFile->FileBufferPtr;\r
+  PreviousBackslash = FALSE;\r
+  while (!EndOfFile (SourceFile)) {\r
+    if ((SourceFile->FileBufferPtr[0] == UNICODE_DOUBLE_QUOTE) && (!PreviousBackslash)) {\r
+      break;\r
+    } else if (SourceFile->FileBufferPtr[0] == UNICODE_CR) {\r
+      Warning (SourceFile->FileName, SourceFile->LineNum, 0, "carriage return found in quoted string", "%S", Start);\r
+      PreviousBackslash = FALSE;\r
+    } else if (SourceFile->FileBufferPtr[0] == UNICODE_BACKSLASH) {\r
+      PreviousBackslash = TRUE;\r
+    } else {\r
+      PreviousBackslash = FALSE;\r
+    }\r
+\r
+    SourceFile->FileBufferPtr++;\r
+    Len++;\r
+  }\r
+\r
+  if (SourceFile->FileBufferPtr[0] != UNICODE_DOUBLE_QUOTE) {\r
+    Warning (SourceFile->FileName, SourceFile->LineNum, 0, "missing closing quote on string", "%S", Start);\r
+  } else {\r
+    SourceFile->FileBufferPtr++;\r
+  }\r
+  //\r
+  // Now allocate memory for the string and save it off\r
+  //\r
+  String = (WCHAR *) malloc ((Len + 1) * sizeof (WCHAR));\r
+  if (String == NULL) {\r
+    Error (NULL, 0, 0, "memory allocation failed", NULL);\r
+    return NULL;\r
+  }\r
+  //\r
+  // Copy the string from the file buffer to the local copy.\r
+  // We do no reformatting of it whatsoever at this point.\r
+  //\r
+  Ptr = String;\r
+  while (Len > 0) {\r
+    *Ptr = *Start;\r
+    Start++;\r
+    Ptr++;\r
+    Len--;\r
+  }\r
+\r
+  *Ptr = 0;\r
+  return String;\r
+}\r
+//\r
+// Parse:\r
+//    #string STR_ID_NAME\r
+//\r
+// All we can do is call the string database to add the string identifier. Unfortunately\r
+// he'll have to keep track of the last identifier we added.\r
+//\r
+static\r
+void\r
+ProcessTokenString (\r
+  SOURCE_FILE *SourceFile\r
+  )\r
+{\r
+  WCHAR   StringIdentifier[MAX_STRING_IDENTIFIER_NAME];\r
+  UINT16  StringId;\r
+  //\r
+  // Extract the string identifier name and add it to the database.\r
+  //\r
+  if (GetStringIdentifierName (SourceFile, StringIdentifier, sizeof (StringIdentifier)) > 0) {\r
+    StringId = STRING_ID_INVALID;\r
+    StringDBAddStringIdentifier (StringIdentifier, &StringId, 0);\r
+  } else {\r
+    //\r
+    // Error recovery -- skip to the next #\r
+    //\r
+    SourceFile->SkipToHash = TRUE;\r
+  }\r
+}\r
+\r
+static\r
+BOOLEAN\r
+EndOfFile (\r
+  SOURCE_FILE *SourceFile\r
+  )\r
+{\r
+  //\r
+  // The file buffer pointer will typically get updated before the End-of-file flag in the\r
+  // source file structure, so check it first.\r
+  //\r
+  if (SourceFile->FileBufferPtr >= SourceFile->FileBuffer + SourceFile->FileSize / sizeof (WCHAR)) {\r
+    SourceFile->EndOfFile = TRUE;\r
+    return TRUE;\r
+  }\r
+\r
+  if (SourceFile->EndOfFile) {\r
+    return TRUE;\r
+  }\r
+\r
+  return FALSE;\r
+}\r
+\r
+static\r
+UINT32\r
+GetStringIdentifierName (\r
+  IN SOURCE_FILE  *SourceFile,\r
+  IN OUT WCHAR    *StringIdentifierName,\r
+  IN UINT32       StringIdentifierNameLen\r
+  )\r
+{\r
+  UINT32  Len;\r
+  WCHAR   *From;\r
+  WCHAR   *Start;\r
+\r
+  //\r
+  // Skip whitespace\r
+  //\r
+  SkipWhiteSpace (SourceFile);\r
+  if (SourceFile->EndOfFile) {\r
+    Error (SourceFile->FileName, SourceFile->LineNum, 0, "end-of-file encountered", "expected string identifier");\r
+    return 0;\r
+  }\r
+  //\r
+  // Verify first character of name is [A-Za-z]\r
+  //\r
+  Len = 0;\r
+  StringIdentifierNameLen /= 2;\r
+  From  = SourceFile->FileBufferPtr;\r
+  Start = SourceFile->FileBufferPtr;\r
+  if (((SourceFile->FileBufferPtr[0] >= UNICODE_A) && (SourceFile->FileBufferPtr[0] <= UNICODE_Z)) ||\r
+      ((SourceFile->FileBufferPtr[0] >= UNICODE_z) && (SourceFile->FileBufferPtr[0] <= UNICODE_z))\r
+      ) {\r
+    //\r
+    // Do nothing\r
+    //\r
+  } else {\r
+    Error (SourceFile->FileName, SourceFile->LineNum, 0, "invalid character in string identifier name", "%S", Start);\r
+    return 0;\r
+  }\r
+\r
+  while (!EndOfFile (SourceFile)) {\r
+    if (((SourceFile->FileBufferPtr[0] >= UNICODE_A) && (SourceFile->FileBufferPtr[0] <= UNICODE_Z)) ||\r
+        ((SourceFile->FileBufferPtr[0] >= UNICODE_z) && (SourceFile->FileBufferPtr[0] <= UNICODE_z)) ||\r
+        ((SourceFile->FileBufferPtr[0] >= UNICODE_0) && (SourceFile->FileBufferPtr[0] <= UNICODE_9)) ||\r
+        (SourceFile->FileBufferPtr[0] == UNICODE_UNDERSCORE)\r
+        ) {\r
+      Len++;\r
+      if (Len >= StringIdentifierNameLen) {\r
+        Error (SourceFile->FileName, SourceFile->LineNum, 0, "string identifier name too long", "%S", Start);\r
+        return 0;\r
+      }\r
+\r
+      *StringIdentifierName = SourceFile->FileBufferPtr[0];\r
+      StringIdentifierName++;\r
+      SourceFile->FileBufferPtr++;\r
+    } else if (SkipWhiteSpace (SourceFile) == 0) {\r
+      Error (SourceFile->FileName, SourceFile->LineNum, 0, "invalid string identifier name", "%S", Start);\r
+      return 0;\r
+    } else {\r
+      break;\r
+    }\r
+  }\r
+  //\r
+  // Terminate the copy of the string.\r
+  //\r
+  *StringIdentifierName = 0;\r
+  return Len;\r
+}\r
+\r
+static\r
+UINT32\r
+GetLanguageIdentifierName (\r
+  IN SOURCE_FILE  *SourceFile,\r
+  IN OUT WCHAR    *LanguageIdentifierName,\r
+  IN UINT32       LanguageIdentifierNameLen,\r
+  IN BOOLEAN      Optional\r
+  )\r
+{\r
+  UINT32  Len;\r
+  WCHAR   *From;\r
+  WCHAR   *Start;\r
+  //\r
+  // Skip whitespace\r
+  //\r
+  SkipWhiteSpace (SourceFile);\r
+  if (SourceFile->EndOfFile) {\r
+    if (!Optional) {\r
+      Error (\r
+        SourceFile->FileName,\r
+        SourceFile->LineNum,\r
+        0,\r
+        "end-of-file encountered",\r
+        "expected language identifier"\r
+        );\r
+    }\r
+\r
+    return 0;\r
+  }\r
+  //\r
+  // This function is called to optionally get a language identifier name in:\r
+  //   #string STR_ID eng "the string"\r
+  // If it's optional, and we find a double-quote, then return now.\r
+  //\r
+  if (Optional) {\r
+    if (*SourceFile->FileBufferPtr == UNICODE_DOUBLE_QUOTE) {\r
+      return 0;\r
+    }\r
+  }\r
+\r
+  Len = 0;\r
+  LanguageIdentifierNameLen /= 2;\r
+  //\r
+  // Internal error if we weren't given at least 4 WCHAR's to work with.\r
+  //\r
+  if (LanguageIdentifierNameLen < LANGUAGE_IDENTIFIER_NAME_LEN + 1) {\r
+    Error (\r
+      SourceFile->FileName,\r
+      SourceFile->LineNum,\r
+      0,\r
+      "app error -- language identifier name length is invalid",\r
+      NULL\r
+      );\r
+  }\r
+\r
+  From  = SourceFile->FileBufferPtr;\r
+  Start = SourceFile->FileBufferPtr;\r
+  while (!EndOfFile (SourceFile)) {\r
+    if (((SourceFile->FileBufferPtr[0] >= UNICODE_a) && (SourceFile->FileBufferPtr[0] <= UNICODE_z))) {\r
+      Len++;\r
+      if (Len > LANGUAGE_IDENTIFIER_NAME_LEN) {\r
+        Error (SourceFile->FileName, SourceFile->LineNum, 0, "language identifier name too long", "%S", Start);\r
+        return 0;\r
+      }\r
+\r
+      *LanguageIdentifierName = SourceFile->FileBufferPtr[0];\r
+      SourceFile->FileBufferPtr++;\r
+      LanguageIdentifierName++;\r
+    } else if (!IsWhiteSpace (SourceFile)) {\r
+      Error (SourceFile->FileName, SourceFile->LineNum, 0, "invalid language identifier name", "%S", Start);\r
+      return 0;\r
+    } else {\r
+      break;\r
+    }\r
+  }\r
+  //\r
+  // Terminate the copy of the string.\r
+  //\r
+  *LanguageIdentifierName = 0;\r
+  return Len;\r
+}\r
+\r
+static\r
+void\r
+ProcessTokenInclude (\r
+  SOURCE_FILE *SourceFile\r
+  )\r
+{\r
+  CHAR8       IncludeFileName[MAX_PATH];\r
+  CHAR8       *To;\r
+  UINT32      Len;\r
+  BOOLEAN     ReportedError;\r
+  SOURCE_FILE IncludedSourceFile;\r
+\r
+  ReportedError = FALSE;\r
+  if (SkipWhiteSpace (SourceFile) == 0) {\r
+    Warning (SourceFile->FileName, SourceFile->LineNum, 0, "expected whitespace following #include keyword", NULL);\r
+  }\r
+  //\r
+  // Should be quoted file name\r
+  //\r
+  if (SourceFile->FileBufferPtr[0] != UNICODE_DOUBLE_QUOTE) {\r
+    Error (SourceFile->FileName, SourceFile->LineNum, 0, "expected quoted include file name", NULL);\r
+    goto FailDone;\r
+  }\r
+\r
+  SourceFile->FileBufferPtr++;\r
+  //\r
+  // Copy the filename as ascii to our local string\r
+  //\r
+  To  = IncludeFileName;\r
+  Len = 0;\r
+  while (!EndOfFile (SourceFile)) {\r
+    if ((SourceFile->FileBufferPtr[0] == UNICODE_CR) || (SourceFile->FileBufferPtr[0] == UNICODE_LF)) {\r
+      Error (SourceFile->FileName, SourceFile->LineNum, 0, "end-of-line found in quoted include file name", NULL);\r
+      goto FailDone;\r
+    }\r
+\r
+    if (SourceFile->FileBufferPtr[0] == UNICODE_DOUBLE_QUOTE) {\r
+      SourceFile->FileBufferPtr++;\r
+      break;\r
+    }\r
+    //\r
+    // If too long, then report the error once and process until the closing quote\r
+    //\r
+    Len++;\r
+    if (!ReportedError && (Len >= sizeof (IncludeFileName))) {\r
+      Error (SourceFile->FileName, SourceFile->LineNum, 0, "length of include file name exceeds limit", NULL);\r
+      ReportedError = TRUE;\r
+    }\r
+\r
+    if (!ReportedError) {\r
+      *To = UNICODE_TO_ASCII (SourceFile->FileBufferPtr[0]);\r
+      To++;\r
+    }\r
+\r
+    SourceFile->FileBufferPtr++;\r
+  }\r
+\r
+  if (!ReportedError) {\r
+    *To = 0;\r
+    memset ((char *) &IncludedSourceFile, 0, sizeof (SOURCE_FILE));\r
+    strcpy (IncludedSourceFile.FileName, IncludeFileName);\r
+    IncludedSourceFile.ControlCharacter = DEFAULT_CONTROL_CHARACTER;\r
+    ProcessIncludeFile (&IncludedSourceFile, SourceFile);\r
+    //\r
+    // printf ("including file '%s'\n", IncludeFileName);\r
+    //\r
+  }\r
+\r
+  return ;\r
+FailDone:\r
+  //\r
+  // Error recovery -- skip to next #\r
+  //\r
+  SourceFile->SkipToHash = TRUE;\r
+}\r
+\r
+static\r
+void\r
+ProcessTokenScope (\r
+  SOURCE_FILE *SourceFile\r
+  )\r
+{\r
+  WCHAR StringIdentifier[MAX_STRING_IDENTIFIER_NAME];\r
+  //\r
+  // Extract the scope name\r
+  //\r
+  if (GetStringIdentifierName (SourceFile, StringIdentifier, sizeof (StringIdentifier)) > 0) {\r
+    StringDBSetScope (StringIdentifier);\r
+  }\r
+}\r
+//\r
+// Parse:  #langdef eng "English"\r
+//         #langdef chn "\wideChinese"\r
+//\r
+static\r
+void\r
+ProcessTokenLangDef (\r
+  SOURCE_FILE *SourceFile\r
+  )\r
+{\r
+  WCHAR   LanguageIdentifier[MAX_STRING_IDENTIFIER_NAME];\r
+  UINT32  Len;\r
+  WCHAR   *PrintableName;\r
+  //\r
+  // Extract the 3-character language identifier\r
+  //\r
+  Len = GetLanguageIdentifierName (SourceFile, LanguageIdentifier, sizeof (LanguageIdentifier), FALSE);\r
+  if (Len != LANGUAGE_IDENTIFIER_NAME_LEN) {\r
+    Error (SourceFile->FileName, SourceFile->LineNum, 0, "invalid or missing language identifier", NULL);\r
+  } else {\r
+    //\r
+    // Extract the printable name\r
+    //\r
+    PrintableName = GetPrintableLanguageName (SourceFile);\r
+    if (PrintableName != NULL) {\r
+      ParserSetPosition (SourceFile->FileName, SourceFile->LineNum);\r
+      StringDBAddLanguage (LanguageIdentifier, PrintableName);\r
+      free (PrintableName);\r
+      return ;\r
+    }\r
+  }\r
+  //\r
+  // Error recovery -- skip to next #\r
+  //\r
+  SourceFile->SkipToHash = TRUE;\r
+}\r
+\r
+static\r
+BOOLEAN\r
+ApparentQuotedString (\r
+  SOURCE_FILE *SourceFile\r
+  )\r
+{\r
+  WCHAR *Ptr;\r
+  //\r
+  // See if the first and last nonblank characters on the line are double quotes\r
+  //\r
+  for (Ptr = SourceFile->FileBufferPtr; *Ptr && (*Ptr == UNICODE_SPACE); Ptr++)\r
+    ;\r
+  if (*Ptr != UNICODE_DOUBLE_QUOTE) {\r
+    return FALSE;\r
+  }\r
+\r
+  while (*Ptr) {\r
+    Ptr++;\r
+  }\r
+\r
+  Ptr--;\r
+  for (; *Ptr && (*Ptr == UNICODE_SPACE); Ptr--)\r
+    ;\r
+  if (*Ptr != UNICODE_DOUBLE_QUOTE) {\r
+    return FALSE;\r
+  }\r
+\r
+  return TRUE;\r
+}\r
+//\r
+// Parse:\r
+//   #language eng "some string " "more string"\r
+//\r
+static\r
+void\r
+ProcessTokenLanguage (\r
+  SOURCE_FILE *SourceFile\r
+  )\r
+{\r
+  WCHAR   *String;\r
+  WCHAR   *SecondString;\r
+  WCHAR   *TempString;\r
+  WCHAR   *From;\r
+  WCHAR   *To;\r
+  WCHAR   Language[LANGUAGE_IDENTIFIER_NAME_LEN + 1];\r
+  UINT32  Len;\r
+  BOOLEAN PreviousNewline;\r
+  //\r
+  // Get the language identifier\r
+  //\r
+  Language[0] = 0;\r
+  Len         = GetLanguageIdentifierName (SourceFile, Language, sizeof (Language), TRUE);\r
+  if (Len != LANGUAGE_IDENTIFIER_NAME_LEN) {\r
+    Error (SourceFile->FileName, SourceFile->LineNum, 0, "invalid or missing language identifier", "%S", Language);\r
+    SourceFile->SkipToHash = TRUE;\r
+    return ;\r
+  }\r
+  //\r
+  // Extract the string value. It's either a quoted string that starts on the current line, or\r
+  // an unquoted string that starts on the following line and continues until the next control\r
+  // character in column 1.\r
+  // Look ahead to find a quote or a newline\r
+  //\r
+  if (SkipTo (SourceFile, UNICODE_DOUBLE_QUOTE, TRUE)) {\r
+    String = GetQuotedString (SourceFile, FALSE);\r
+    if (String != NULL) {\r
+      //\r
+      // Set the position in the file of where we are parsing for error\r
+      // reporting purposes. Then start looking ahead for additional\r
+      // quoted strings, and concatenate them until we get a failure\r
+      // back from the string parser.\r
+      //\r
+      Len = StrLen (String) + 1;\r
+      ParserSetPosition (SourceFile->FileName, SourceFile->LineNum);\r
+      do {\r
+        SkipWhiteSpace (SourceFile);\r
+        SecondString = GetQuotedString (SourceFile, TRUE);\r
+        if (SecondString != NULL) {\r
+          Len += StrLen (SecondString);\r
+          TempString = (WCHAR *) malloc (Len * sizeof (WCHAR));\r
+          if (TempString == NULL) {\r
+            Error (NULL, 0, 0, "application error", "failed to allocate memory");\r
+            return ;\r
+          }\r
+\r
+          StrCpy (TempString, String);\r
+          StrCat (TempString, SecondString);\r
+          free (String);\r
+          free (SecondString);\r
+          String = TempString;\r
+        }\r
+      } while (SecondString != NULL);\r
+      StringDBAddString (Language, NULL, NULL, String, TRUE, 0);\r
+      free (String);\r
+    } else {\r
+      //\r
+      // Error was reported at lower level. Error recovery mode.\r
+      //\r
+      SourceFile->SkipToHash = TRUE;\r
+    }\r
+  } else {\r
+    if (!mGlobals.UnquotedStrings) {\r
+      //\r
+      // They're using unquoted strings. If the next non-blank character is a double quote, and the\r
+      // last non-blank character on the line is a double quote, then more than likely they're using\r
+      // quotes, so they need to put the quoted string on the end of the previous line\r
+      //\r
+      if (ApparentQuotedString (SourceFile)) {\r
+        Warning (\r
+          SourceFile->FileName,\r
+          SourceFile->LineNum,\r
+          0,\r
+          "unexpected quoted string on line",\r
+          "specify -uqs option if necessary"\r
+          );\r
+      }\r
+    }\r
+    //\r
+    // Found end-of-line (hopefully). Skip over it and start taking in characters\r
+    // until we find a control character at the start of a line.\r
+    //\r
+    Len             = 0;\r
+    From            = SourceFile->FileBufferPtr;\r
+    PreviousNewline = FALSE;\r
+    while (!EndOfFile (SourceFile)) {\r
+      if (SourceFile->FileBufferPtr[0] == UNICODE_LF) {\r
+        PreviousNewline = TRUE;\r
+        SourceFile->LineNum++;\r
+      } else {\r
+        Len++;\r
+        if (PreviousNewline && (SourceFile->FileBufferPtr[0] == SourceFile->ControlCharacter)) {\r
+          break;\r
+        }\r
+\r
+        PreviousNewline = FALSE;\r
+      }\r
+\r
+      SourceFile->FileBufferPtr++;\r
+    }\r
+\r
+    if ((Len == 0) && EndOfFile (SourceFile)) {\r
+      Error (SourceFile->FileName, SourceFile->LineNum, 0, "unexpected end of file", NULL);\r
+      SourceFile->SkipToHash = TRUE;\r
+      return ;\r
+    }\r
+    //\r
+    // Now allocate a buffer, copy the characters, and add the string.\r
+    //\r
+    String = (WCHAR *) malloc ((Len + 1) * sizeof (WCHAR));\r
+    if (String == NULL) {\r
+      Error (NULL, 0, 0, "application error", "failed to allocate memory");\r
+      return ;\r
+    }\r
+\r
+    To = String;\r
+    while (From < SourceFile->FileBufferPtr) {\r
+      switch (*From) {\r
+      case UNICODE_LF:\r
+      case 0:\r
+        break;\r
+\r
+      default:\r
+        *To = *From;\r
+        To++;\r
+        break;\r
+      }\r
+\r
+      From++;\r
+    }\r
+\r
+    //\r
+    // String[Len] = 0;\r
+    //\r
+    *To = 0;\r
+    StringDBAddString (Language, NULL, NULL, String, TRUE, 0);\r
+  }\r
+}\r
+\r
+static\r
+BOOLEAN\r
+IsWhiteSpace (\r
+  SOURCE_FILE *SourceFile\r
+  )\r
+{\r
+  switch (SourceFile->FileBufferPtr[0]) {\r
+  case UNICODE_NULL:\r
+  case UNICODE_CR:\r
+  case UNICODE_SPACE:\r
+  case UNICODE_TAB:\r
+  case UNICODE_LF:\r
+    return TRUE;\r
+\r
+  default:\r
+    return FALSE;\r
+  }\r
+}\r
+\r
+static\r
+UINT32\r
+SkipWhiteSpace (\r
+  SOURCE_FILE *SourceFile\r
+  )\r
+{\r
+  UINT32  Count;\r
+\r
+  Count = 0;\r
+  while (!EndOfFile (SourceFile)) {\r
+    Count++;\r
+    switch (*SourceFile->FileBufferPtr) {\r
+    case UNICODE_NULL:\r
+    case UNICODE_CR:\r
+    case UNICODE_SPACE:\r
+    case UNICODE_TAB:\r
+      SourceFile->FileBufferPtr++;\r
+      break;\r
+\r
+    case UNICODE_LF:\r
+      SourceFile->FileBufferPtr++;\r
+      SourceFile->LineNum++;\r
+      if (mGlobals.Verbose) {\r
+        printf ("%d: %S\n", SourceFile->LineNum, SourceFile->FileBufferPtr);\r
+      }\r
+      break;\r
+\r
+    default:\r
+      return Count - 1;\r
+    }\r
+  }\r
+  //\r
+  // Some tokens require trailing whitespace. If we're at the end of the\r
+  // file, then we count that as well.\r
+  //\r
+  if ((Count == 0) && (EndOfFile (SourceFile))) {\r
+    Count++;\r
+  }\r
+\r
+  return Count;\r
+}\r
+\r
+static\r
+UINT32\r
+wstrcmp (\r
+  WCHAR *Buffer,\r
+  WCHAR *Str\r
+  )\r
+{\r
+  UINT32  Len;\r
+\r
+  Len = 0;\r
+  while (*Str == *Buffer) {\r
+    Buffer++;\r
+    Str++;\r
+    Len++;\r
+  }\r
+\r
+  if (*Str) {\r
+    return 0;\r
+  }\r
+\r
+  return Len;\r
+}\r
+//\r
+// Given a filename, try to find it along the include paths.\r
+//\r
+static\r
+FILE *\r
+FindFile (\r
+  IN CHAR8   *FileName,\r
+  OUT CHAR8  *FoundFileName,\r
+  IN UINT32  FoundFileNameLen\r
+  )\r
+{\r
+  FILE              *Fptr;\r
+  TEXT_STRING_LIST  *List;\r
+\r
+  //\r
+  // Traverse the list of paths and try to find the file\r
+  //\r
+  List = mGlobals.IncludePaths;\r
+  while (List != NULL) {\r
+    //\r
+    // Put the path and filename together\r
+    //\r
+    if (strlen (List->Str) + strlen (FileName) + 1 > FoundFileNameLen) {\r
+      Error (PROGRAM_NAME, 0, 0, NULL, "internal error - cannot concatenate path+filename");\r
+      return NULL;\r
+    }\r
+    //\r
+    // Append the filename to this include path and try to open the file.\r
+    //\r
+    strcpy (FoundFileName, List->Str);\r
+    strcat (FoundFileName, FileName);\r
+    if ((Fptr = fopen (FoundFileName, "rb")) != NULL) {\r
+      //\r
+      // Return the file pointer\r
+      //\r
+      return Fptr;\r
+    }\r
+\r
+    List = List->Next;\r
+  }\r
+  //\r
+  // Not found\r
+  //\r
+  FoundFileName[0] = 0;\r
+  return NULL;\r
+}\r
+//\r
+// Process the command-line arguments\r
+//\r
+static\r
+STATUS\r
+ProcessArgs (\r
+  int   Argc,\r
+  char  *Argv[]\r
+  )\r
+{\r
+  TEXT_STRING_LIST  *NewList;\r
+  //\r
+  // Clear our globals\r
+  //\r
+  memset ((char *) &mGlobals, 0, sizeof (mGlobals));\r
+  strcpy (mGlobals.BaseName, DEFAULT_BASE_NAME);\r
+  //\r
+  // Skip program name\r
+  //\r
+  Argc--;\r
+  Argv++;\r
+\r
+  if (Argc == 0) {\r
+    Usage ();\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  mGlobals.Mode = MODE_UNKNOWN;\r
+  //\r
+  // Process until no more -args.\r
+  //\r
+  while ((Argc > 0) && (Argv[0][0] == '-')) {\r
+    //\r
+    // -parse option\r
+    //\r
+    if (stricmp (Argv[0], "-parse") == 0) {\r
+      if (mGlobals.Mode != MODE_UNKNOWN) {\r
+        Error (NULL, 0, 0, "only one of -parse/-scan/-dump allowed", NULL);\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      mGlobals.Mode = MODE_PARSE;\r
+      //\r
+      // -scan option\r
+      //\r
+    } else if (stricmp (Argv[0], "-scan") == 0) {\r
+      if (mGlobals.Mode != MODE_UNKNOWN) {\r
+        Error (NULL, 0, 0, "only one of -parse/-scan/-dump allowed", NULL);\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      mGlobals.Mode = MODE_SCAN;\r
+      //\r
+      // -vscan verbose scanning option\r
+      //\r
+    } else if (stricmp (Argv[0], "-vscan") == 0) {\r
+      mGlobals.VerboseScan = TRUE;\r
+      //\r
+      // -dump option\r
+      //\r
+    } else if (stricmp (Argv[0], "-dump") == 0) {\r
+      if (mGlobals.Mode != MODE_UNKNOWN) {\r
+        Error (NULL, 0, 0, "only one of -parse/-scan/-dump allowed", NULL);\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      mGlobals.Mode = MODE_DUMP;\r
+    } else if (stricmp (Argv[0], "-uqs") == 0) {\r
+      mGlobals.UnquotedStrings = TRUE;\r
+      //\r
+      // -i path    add include search path when parsing\r
+      //\r
+    } else if (stricmp (Argv[0], "-i") == 0) {\r
+      //\r
+      // check for one more arg\r
+      //\r
+      if ((Argc <= 1) || (Argv[1][0] == '-')) {\r
+        Error (PROGRAM_NAME, 0, 0, Argv[0], "missing include path");\r
+        return STATUS_ERROR;\r
+      }\r
+      //\r
+      // Allocate memory for a new list element, fill it in, and\r
+      // add it to our list of include paths. Always make sure it\r
+      // has a "\" on the end of it.\r
+      //\r
+      NewList = malloc (sizeof (TEXT_STRING_LIST));\r
+      if (NewList == NULL) {\r
+        Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      memset ((char *) NewList, 0, sizeof (TEXT_STRING_LIST));\r
+      NewList->Str = malloc (strlen (Argv[1]) + 2);\r
+      if (NewList->Str == NULL) {\r
+        free (NewList);\r
+        Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      strcpy (NewList->Str, Argv[1]);\r
+      if (NewList->Str[strlen (NewList->Str) - 1] != '\\') {\r
+        strcat (NewList->Str, "\\");\r
+      }\r
+      //\r
+      // Add it to our linked list\r
+      //\r
+      if (mGlobals.IncludePaths == NULL) {\r
+        mGlobals.IncludePaths = NewList;\r
+      } else {\r
+        mGlobals.LastIncludePath->Next = NewList;\r
+      }\r
+\r
+      mGlobals.LastIncludePath = NewList;\r
+      Argc--;\r
+      Argv++;\r
+    } else if (stricmp (Argv[0], "-if") == 0) {\r
+      //\r
+      // Indirection file -- check for one more arg\r
+      //\r
+      if ((Argc <= 1) || (Argv[1][0] == '-')) {\r
+        Error (PROGRAM_NAME, 0, 0, Argv[0], "missing indirection file name");\r
+        return STATUS_ERROR;\r
+      }\r
+      //\r
+      // Allocate memory for a new list element, fill it in, and\r
+      // add it to our list of include paths. Always make sure it\r
+      // has a "\" on the end of it.\r
+      //\r
+      NewList = malloc (sizeof (TEXT_STRING_LIST));\r
+      if (NewList == NULL) {\r
+        Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      memset ((char *) NewList, 0, sizeof (TEXT_STRING_LIST));\r
+      NewList->Str = malloc (strlen (Argv[1]) + 1);\r
+      if (NewList->Str == NULL) {\r
+        free (NewList);\r
+        Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      strcpy (NewList->Str, Argv[1]);\r
+      //\r
+      // Add it to our linked list\r
+      //\r
+      if (mGlobals.IndirectionFileName == NULL) {\r
+        mGlobals.IndirectionFileName = NewList;\r
+      } else {\r
+        mGlobals.LastIndirectionFileName->Next = NewList;\r
+      }\r
+\r
+      mGlobals.LastIndirectionFileName = NewList;\r
+      Argc--;\r
+      Argv++;\r
+    } else if (stricmp (Argv[0], "-db") == 0) {\r
+      //\r
+      // -db option to specify a database file.\r
+      // Check for one more arg (the database file name)\r
+      //\r
+      if ((Argc <= 1) || (Argv[1][0] == '-')) {\r
+        Error (PROGRAM_NAME, 0, 0, Argv[0], "missing database file name");\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      NewList = malloc (sizeof (TEXT_STRING_LIST));\r
+      if (NewList == NULL) {\r
+        Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      memset ((char *) NewList, 0, sizeof (TEXT_STRING_LIST));\r
+      NewList->Str = malloc (strlen (Argv[1]) + 1);\r
+      if (NewList->Str == NULL) {\r
+        free (NewList);\r
+        Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      strcpy (NewList->Str, Argv[1]);\r
+      //\r
+      // Add it to our linked list\r
+      //\r
+      if (mGlobals.DatabaseFileName == NULL) {\r
+        mGlobals.DatabaseFileName = NewList;\r
+      } else {\r
+        mGlobals.LastDatabaseFileName->Next = NewList;\r
+      }\r
+\r
+      mGlobals.LastDatabaseFileName = NewList;\r
+      Argc--;\r
+      Argv++;\r
+    } else if (stricmp (Argv[0], "-ou") == 0) {\r
+      //\r
+      // -ou option to specify an output unicode file to\r
+      // which we can dump our database.\r
+      //\r
+      if ((Argc <= 1) || (Argv[1][0] == '-')) {\r
+        Error (PROGRAM_NAME, 0, 0, Argv[0], "missing database dump output file name");\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      if (mGlobals.DumpUFileName[0] == 0) {\r
+        strcpy (mGlobals.DumpUFileName, Argv[1]);\r
+      } else {\r
+        Error (PROGRAM_NAME, 0, 0, Argv[1], "-ou option already specified with '%s'", mGlobals.DumpUFileName);\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      Argc--;\r
+      Argv++;\r
+    } else if (stricmp (Argv[0], "-hpk") == 0) {\r
+      //\r
+      // -hpk option to create an HII export pack of the input database file\r
+      //\r
+      if ((Argc <= 1) || (Argv[1][0] == '-')) {\r
+        Error (PROGRAM_NAME, 0, 0, Argv[0], "missing raw string data dump output file name");\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      if (mGlobals.HiiExportPackFileName[0] == 0) {\r
+        strcpy (mGlobals.HiiExportPackFileName, Argv[1]);\r
+      } else {\r
+        Error (PROGRAM_NAME, 0, 0, Argv[1], "-or option already specified with '%s'", mGlobals.HiiExportPackFileName);\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      Argc--;\r
+      Argv++;\r
+    } else if ((stricmp (Argv[0], "-?") == 0) || (stricmp (Argv[0], "-h") == 0)) {\r
+      Usage ();\r
+      return STATUS_ERROR;\r
+    } else if (stricmp (Argv[0], "-v") == 0) {\r
+      mGlobals.Verbose = 1;\r
+    } else if (stricmp (Argv[0], "-vdbw") == 0) {\r
+      mGlobals.VerboseDatabaseWrite = 1;\r
+    } else if (stricmp (Argv[0], "-vdbr") == 0) {\r
+      mGlobals.VerboseDatabaseRead = 1;\r
+    } else if (stricmp (Argv[0], "-newdb") == 0) {\r
+      mGlobals.NewDatabase = 1;\r
+    } else if (stricmp (Argv[0], "-ignorenotfound") == 0) {\r
+      mGlobals.IgnoreNotFound = 1;\r
+    } else if (stricmp (Argv[0], "-oc") == 0) {\r
+      //\r
+      // check for one more arg\r
+      //\r
+      if ((Argc <= 1) || (Argv[1][0] == '-')) {\r
+        Error (PROGRAM_NAME, 0, 0, Argv[0], "missing output C filename");\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      strcpy (mGlobals.StringCFileName, Argv[1]);\r
+      Argc--;\r
+      Argv++;\r
+    } else if (stricmp (Argv[0], "-bn") == 0) {\r
+      //\r
+      // check for one more arg\r
+      //\r
+      if ((Argc <= 1) || (Argv[1][0] == '-')) {\r
+        Error (PROGRAM_NAME, 0, 0, Argv[0], "missing base name");\r
+        Usage ();\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      strcpy (mGlobals.BaseName, Argv[1]);\r
+      Argc--;\r
+      Argv++;\r
+    } else if (stricmp (Argv[0], "-oh") == 0) {\r
+      //\r
+      // -oh to specify output .h defines file name\r
+      //\r
+      if ((Argc <= 1) || (Argv[1][0] == '-')) {\r
+        Error (PROGRAM_NAME, 0, 0, Argv[0], "missing output .h filename");\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      strcpy (mGlobals.StringHFileName, Argv[1]);\r
+      Argc--;\r
+      Argv++;\r
+    } else if (stricmp (Argv[0], "-skipext") == 0) {\r
+      //\r
+      // -skipext to skip scanning of files with certain filename extensions\r
+      //\r
+      if ((Argc <= 1) || (Argv[1][0] == '-')) {\r
+        Error (PROGRAM_NAME, 0, 0, Argv[0], "missing filename extension");\r
+        return STATUS_ERROR;\r
+      }\r
+      //\r
+      // Allocate memory for a new list element, fill it in, and\r
+      // add it to our list of excluded extensions. Always make sure it\r
+      // has a "." as the first character.\r
+      //\r
+      NewList = malloc (sizeof (TEXT_STRING_LIST));\r
+      if (NewList == NULL) {\r
+        Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      memset ((char *) NewList, 0, sizeof (TEXT_STRING_LIST));\r
+      NewList->Str = malloc (strlen (Argv[1]) + 2);\r
+      if (NewList->Str == NULL) {\r
+        free (NewList);\r
+        Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      if (Argv[1][0] == '.') {\r
+        strcpy (NewList->Str, Argv[1]);\r
+      } else {\r
+        NewList->Str[0] = '.';\r
+        strcpy (NewList->Str + 1, Argv[1]);\r
+      }\r
+      //\r
+      // Add it to our linked list\r
+      //\r
+      if (mGlobals.SkipExt == NULL) {\r
+        mGlobals.SkipExt = NewList;\r
+      } else {\r
+        mGlobals.LastSkipExt->Next = NewList;\r
+      }\r
+\r
+      mGlobals.LastSkipExt = NewList;\r
+      Argc--;\r
+      Argv++;\r
+    } else if (stricmp (Argv[0], "-lang") == 0) {\r
+      //\r
+      // "-lang eng" or "-lang spa+cat" to only output certain languages\r
+      //\r
+      if ((Argc <= 1) || (Argv[1][0] == '-')) {\r
+        Error (PROGRAM_NAME, 0, 0, Argv[0], "missing language name");\r
+        Usage ();\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      if (AddCommandLineLanguage (Argv[1]) != STATUS_SUCCESS) {\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      Argc--;\r
+      Argv++;\r
+    } else if (stricmp (Argv[0], "-od") == 0) {\r
+      //\r
+      // Output database file name -- check for another arg\r
+      //\r
+      if ((Argc <= 1) || (Argv[1][0] == '-')) {\r
+        Error (PROGRAM_NAME, 0, 0, Argv[0], "missing output database file name");\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      strcpy (mGlobals.OutputDatabaseFileName, Argv[1]);\r
+      Argv++;\r
+      Argc--;\r
+    } else {\r
+      //\r
+      // Unrecognized arg\r
+      //\r
+      Error (PROGRAM_NAME, 0, 0, Argv[0], "unrecognized option");\r
+      Usage ();\r
+      return STATUS_ERROR;\r
+    }\r
+\r
+    Argv++;\r
+    Argc--;\r
+  }\r
+  //\r
+  // Make sure they specified the mode parse/scan/dump\r
+  //\r
+  if (mGlobals.Mode == MODE_UNKNOWN) {\r
+    Error (NULL, 0, 0, "must specify one of -parse/-scan/-dump", NULL);\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // All modes require a database filename\r
+  //\r
+  if (mGlobals.DatabaseFileName == 0) {\r
+    Error (NULL, 0, 0, "must specify a database filename using -db DbFileName", NULL);\r
+    Usage ();\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // If dumping the database file, then return immediately if all\r
+  // parameters check out.\r
+  //\r
+  if (mGlobals.Mode == MODE_DUMP) {\r
+    //\r
+    // Not much use if they didn't specify -oh or -oc or -ou or -hpk\r
+    //\r
+    if ((mGlobals.DumpUFileName[0] == 0) &&\r
+        (mGlobals.StringHFileName[0] == 0) &&\r
+        (mGlobals.StringCFileName[0] == 0) &&\r
+        (mGlobals.HiiExportPackFileName[0] == 0)\r
+        ) {\r
+      Error (NULL, 0, 0, "-dump without -oc/-oh/-ou/-hpk is a NOP", NULL);\r
+      return STATUS_ERROR;\r
+    }\r
+\r
+    return STATUS_SUCCESS;\r
+  }\r
+  //\r
+  // Had to specify source string file and output string defines header filename.\r
+  //\r
+  if (mGlobals.Mode == MODE_SCAN) {\r
+    if (Argc < 1) {\r
+      Error (PROGRAM_NAME, 0, 0, NULL, "must specify at least one source file to scan with -scan");\r
+      Usage ();\r
+      return STATUS_ERROR;\r
+    }\r
+    //\r
+    // Get the list of filenames\r
+    //\r
+    while (Argc > 0) {\r
+      NewList = malloc (sizeof (TEXT_STRING_LIST));\r
+      if (NewList == NULL) {\r
+        Error (PROGRAM_NAME, 0, 0, "memory allocation failure", NULL);\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      memset (NewList, 0, sizeof (TEXT_STRING_LIST));\r
+      NewList->Str = (CHAR8 *) malloc (strlen (Argv[0]) + 1);\r
+      if (NewList->Str == NULL) {\r
+        Error (PROGRAM_NAME, 0, 0, "memory allocation failure", NULL);\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      strcpy (NewList->Str, Argv[0]);\r
+      if (mGlobals.ScanFileName == NULL) {\r
+        mGlobals.ScanFileName = NewList;\r
+      } else {\r
+        mGlobals.LastScanFileName->Next = NewList;\r
+      }\r
+\r
+      mGlobals.LastScanFileName = NewList;\r
+      Argc--;\r
+      Argv++;\r
+    }\r
+  } else {\r
+    //\r
+    // Parse mode -- must specify an input unicode file name\r
+    //\r
+    if (Argc < 1) {\r
+      Error (PROGRAM_NAME, 0, 0, NULL, "must specify input unicode string file name with -parse");\r
+      Usage ();\r
+      return STATUS_ERROR;\r
+    }\r
+\r
+    strcpy (mGlobals.SourceFiles.FileName, Argv[0]);\r
+  }\r
+\r
+  return STATUS_SUCCESS;\r
+}\r
+//\r
+// Found "-lang eng,spa+cat" on the command line. Parse the\r
+// language list and save the setting for later processing.\r
+//\r
+static\r
+STATUS\r
+AddCommandLineLanguage (\r
+  IN CHAR8         *Language\r
+  )\r
+{\r
+  WCHAR_STRING_LIST *WNewList;\r
+  WCHAR             *From;\r
+  WCHAR             *To;\r
+  //\r
+  // Keep processing the input string until we find the end.\r
+  //\r
+  while (*Language) {\r
+    //\r
+    // Allocate memory for a new list element, fill it in, and\r
+    // add it to our list.\r
+    //\r
+    WNewList = MALLOC (sizeof (WCHAR_STRING_LIST));\r
+    if (WNewList == NULL) {\r
+      Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");\r
+      return STATUS_ERROR;\r
+    }\r
+\r
+    memset ((char *) WNewList, 0, sizeof (WCHAR_STRING_LIST));\r
+    WNewList->Str = malloc ((strlen (Language) + 1) * sizeof (WCHAR));\r
+    if (WNewList->Str == NULL) {\r
+      free (WNewList);\r
+      Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");\r
+      return STATUS_ERROR;\r
+    }\r
+    //\r
+    // Copy it as unicode to our new structure. Then remove the\r
+    // plus signs in it, and verify each language name is 3 characters\r
+    // long. If we find a comma, then we're done with this group, so\r
+    // break out.\r
+    //\r
+    UnicodeSPrint (WNewList->Str, (strlen (Language) + 1) * sizeof (WCHAR), L"%a", Language);\r
+    From = To = WNewList->Str;\r
+    while (*From) {\r
+      if (*From == L',') {\r
+        break;\r
+      }\r
+\r
+      if ((StrLen (From) < LANGUAGE_IDENTIFIER_NAME_LEN) ||\r
+            (\r
+              (From[LANGUAGE_IDENTIFIER_NAME_LEN] != 0) &&\r
+              (From[LANGUAGE_IDENTIFIER_NAME_LEN] != UNICODE_PLUS_SIGN) &&\r
+              (From[LANGUAGE_IDENTIFIER_NAME_LEN] != L',')\r
+            )\r
+          ) {\r
+        Error (PROGRAM_NAME, 0, 0, Language, "invalid format for language name on command line");\r
+        FREE (WNewList->Str);\r
+        FREE (WNewList);\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      StrnCpy (To, From, LANGUAGE_IDENTIFIER_NAME_LEN);\r
+      To += LANGUAGE_IDENTIFIER_NAME_LEN;\r
+      From += LANGUAGE_IDENTIFIER_NAME_LEN;\r
+      if (*From == L'+') {\r
+        From++;\r
+      }\r
+    }\r
+\r
+    *To = 0;\r
+    //\r
+    // Add it to our linked list\r
+    //\r
+    if (mGlobals.Language == NULL) {\r
+      mGlobals.Language = WNewList;\r
+    } else {\r
+      mGlobals.LastLanguage->Next = WNewList;\r
+    }\r
+\r
+    mGlobals.LastLanguage = WNewList;\r
+    //\r
+    // Skip to next entry (comma-separated list)\r
+    //\r
+    while (*Language) {\r
+      if (*Language == L',') {\r
+        Language++;\r
+        break;\r
+      }\r
+\r
+      Language++;\r
+    }\r
+  }\r
+\r
+  return STATUS_SUCCESS;\r
+}\r
+//\r
+// The contents of the text file are expected to be (one per line)\r
+//   STRING_IDENTIFIER_NAME   ScopeName\r
+// For example:\r
+//   STR_ID_MY_FAVORITE_STRING   IBM\r
+//\r
+static\r
+STATUS\r
+ParseIndirectionFiles (\r
+  TEXT_STRING_LIST    *Files\r
+  )\r
+{\r
+  FILE                        *Fptr;\r
+  CHAR8                       Line[200];\r
+  CHAR8                       *StringName;\r
+  CHAR8                       *ScopeName;\r
+  CHAR8                       *End;\r
+  UINT32                      LineCount;\r
+  WCHAR_MATCHING_STRING_LIST  *NewList;\r
+\r
+  Line[sizeof (Line) - 1] = 0;\r
+  Fptr                    = NULL;\r
+  while (Files != NULL) {\r
+    Fptr      = fopen (Files->Str, "r");\r
+    LineCount = 0;\r
+    if (Fptr == NULL) {\r
+      Error (NULL, 0, 0, Files->Str, "failed to open input indirection file for reading");\r
+      return STATUS_ERROR;\r
+    }\r
+\r
+    while (fgets (Line, sizeof (Line), Fptr) != NULL) {\r
+      //\r
+      // remove terminating newline for error printing purposes.\r
+      //\r
+      if (Line[strlen (Line) - 1] == '\n') {\r
+        Line[strlen (Line) - 1] = 0;\r
+      }\r
+\r
+      LineCount++;\r
+      if (Line[sizeof (Line) - 1] != 0) {\r
+        Error (Files->Str, LineCount, 0, "line length exceeds maximum supported", NULL);\r
+        goto Done;\r
+      }\r
+\r
+      StringName = Line;\r
+      while (*StringName && (isspace (*StringName))) {\r
+        StringName++;\r
+      }\r
+\r
+      if (*StringName) {\r
+        if ((*StringName == '_') || isalpha (*StringName)) {\r
+          End = StringName;\r
+          while ((*End) && (*End == '_') || (isalnum (*End))) {\r
+            End++;\r
+          }\r
+\r
+          if (isspace (*End)) {\r
+            *End = 0;\r
+            End++;\r
+            while (isspace (*End)) {\r
+              End++;\r
+            }\r
+\r
+            if (*End) {\r
+              ScopeName = End;\r
+              while (*End && !isspace (*End)) {\r
+                End++;\r
+              }\r
+\r
+              *End = 0;\r
+              //\r
+              // Add the string name/scope pair\r
+              //\r
+              NewList = malloc (sizeof (WCHAR_MATCHING_STRING_LIST));\r
+              if (NewList == NULL) {\r
+                Error (NULL, 0, 0, "memory allocation error", NULL);\r
+                goto Done;\r
+              }\r
+\r
+              memset (NewList, 0, sizeof (WCHAR_MATCHING_STRING_LIST));\r
+              NewList->Str1 = (WCHAR *) malloc ((strlen (StringName) + 1) * sizeof (WCHAR));\r
+              NewList->Str2 = (WCHAR *) malloc ((strlen (ScopeName) + 1) * sizeof (WCHAR));\r
+              if ((NewList->Str1 == NULL) || (NewList->Str2 == NULL)) {\r
+                Error (NULL, 0, 0, "memory allocation error", NULL);\r
+                goto Done;\r
+              }\r
+\r
+              UnicodeSPrint (NewList->Str1, strlen (StringName) + 1, L"%a", StringName);\r
+              UnicodeSPrint (NewList->Str2, strlen (ScopeName) + 1, L"%a", ScopeName);\r
+              if (mGlobals.IndirectionList == NULL) {\r
+                mGlobals.IndirectionList = NewList;\r
+              } else {\r
+                mGlobals.LastIndirectionList->Next = NewList;\r
+              }\r
+\r
+              mGlobals.LastIndirectionList = NewList;\r
+            } else {\r
+              Error (Files->Str, LineCount, 0, StringName, "invalid line : expected 'StringIdentifier Scope'");\r
+              goto Done;\r
+            }\r
+          } else {\r
+            Error (Files->Str, LineCount, 0, StringName, "invalid line : expected 'StringIdentifier Scope'");\r
+            goto Done;\r
+          }\r
+        } else {\r
+          Error (Files->Str, LineCount, 0, StringName, "invalid string identifier");\r
+          goto Done;\r
+        }\r
+      }\r
+    }\r
+\r
+    fclose (Fptr);\r
+    Fptr  = NULL;\r
+    Files = Files->Next;\r
+  }\r
+\r
+Done:\r
+  if (Fptr != NULL) {\r
+    fclose (Fptr);\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+STATUS\r
+ScanFiles (\r
+  TEXT_STRING_LIST *ScanFiles\r
+  )\r
+{\r
+  char              Line[MAX_LINE_LEN];\r
+  FILE              *Fptr;\r
+  UINT32            LineNum;\r
+  char              *Cptr;\r
+  char              *SavePtr;\r
+  char              *TermPtr;\r
+  char              *StringTokenPos;\r
+  TEXT_STRING_LIST  *SList;\r
+  BOOLEAN           SkipIt;\r
+\r
+  //\r
+  // Put a null-terminator at the end of the line. If we read in\r
+  // a line longer than we support, then we can catch it.\r
+  //\r
+  Line[MAX_LINE_LEN - 1] = 0;\r
+  //\r
+  // Process each file. If they gave us a skip extension list, then\r
+  // skip it if the extension matches.\r
+  //\r
+  while (ScanFiles != NULL) {\r
+    SkipIt = FALSE;\r
+    for (SList = mGlobals.SkipExt; SList != NULL; SList = SList->Next) {\r
+      if ((strlen (ScanFiles->Str) > strlen (SList->Str)) &&\r
+          (strcmp (ScanFiles->Str + strlen (ScanFiles->Str) - strlen (SList->Str), SList->Str) == 0)\r
+          ) {\r
+        SkipIt = TRUE;\r
+        //\r
+        // printf ("Match: %s : %s\n", ScanFiles->Str, SList->Str);\r
+        //\r
+        break;\r
+      }\r
+    }\r
+\r
+    if (!SkipIt) {\r
+      if (mGlobals.VerboseScan) {\r
+        printf ("Scanning %s\n", ScanFiles->Str);\r
+      }\r
+\r
+      Fptr = fopen (ScanFiles->Str, "r");\r
+      if (Fptr == NULL) {\r
+        Error (NULL, 0, 0, ScanFiles->Str, "failed to open input file for scanning");\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      LineNum = 0;\r
+      while (fgets (Line, sizeof (Line), Fptr) != NULL) {\r
+        LineNum++;\r
+        if (Line[MAX_LINE_LEN - 1] != 0) {\r
+          Error (ScanFiles->Str, LineNum, 0, "line length exceeds maximum supported by tool", NULL);\r
+          fclose (Fptr);\r
+          return STATUS_ERROR;\r
+        }\r
+        //\r
+        // Remove the newline from the input line so we can print a warning message\r
+        //\r
+        if (Line[strlen (Line) - 1] == '\n') {\r
+          Line[strlen (Line) - 1] = 0;\r
+        }\r
+        //\r
+        // Terminate the line at // comments\r
+        //\r
+        Cptr = strstr (Line, "//");\r
+        if (Cptr != NULL) {\r
+          *Cptr = 0;\r
+        }\r
+\r
+        Cptr = Line;\r
+        while ((Cptr = strstr (Cptr, STRING_TOKEN)) != NULL) {\r
+          //\r
+          // Found "STRING_TOKEN". Make sure we don't have NUM_STRING_TOKENS or\r
+          // something like that. Then make sure it's followed by\r
+          // an open parenthesis, a string identifier, and then a closing\r
+          // parenthesis.\r
+          //\r
+          if (mGlobals.VerboseScan) {\r
+            printf (" %d: %s", LineNum, Cptr);\r
+          }\r
+\r
+          if (((Cptr == Line) || (!IsValidIdentifierChar (*(Cptr - 1), FALSE))) &&\r
+              (!IsValidIdentifierChar (*(Cptr + sizeof (STRING_TOKEN) - 1), FALSE))\r
+              ) {\r
+            StringTokenPos  = Cptr;\r
+            SavePtr         = Cptr;\r
+            Cptr += strlen (STRING_TOKEN);\r
+            while (*Cptr && isspace (*Cptr) && (*Cptr != '(')) {\r
+              Cptr++;\r
+            }\r
+\r
+            if (*Cptr != '(') {\r
+              Warning (ScanFiles->Str, LineNum, 0, StringTokenPos, "expected "STRING_TOKEN "(identifier)");\r
+            } else {\r
+              //\r
+              // Skip over the open-parenthesis and find the next non-blank character\r
+              //\r
+              Cptr++;\r
+              while (isspace (*Cptr)) {\r
+                Cptr++;\r
+              }\r
+\r
+              SavePtr = Cptr;\r
+              if ((*Cptr == '_') || isalpha (*Cptr)) {\r
+                while ((*Cptr == '_') || (isalnum (*Cptr))) {\r
+                  Cptr++;\r
+                }\r
+\r
+                TermPtr = Cptr;\r
+                while (*Cptr && isspace (*Cptr)) {\r
+                  Cptr++;\r
+                }\r
+\r
+                if (*Cptr != ')') {\r
+                  Warning (ScanFiles->Str, LineNum, 0, StringTokenPos, "expected "STRING_TOKEN "(identifier)");\r
+                }\r
+\r
+                if (*TermPtr) {\r
+                  *TermPtr  = 0;\r
+                  Cptr      = TermPtr + 1;\r
+                } else {\r
+                  Cptr = TermPtr;\r
+                }\r
+                //\r
+                // Add the string identifier to the list of used strings\r
+                //\r
+                ParserSetPosition (ScanFiles->Str, LineNum);\r
+                StringDBSetStringReferenced (SavePtr, mGlobals.IgnoreNotFound);\r
+                if (mGlobals.VerboseScan) {\r
+                  printf ("...referenced %s", SavePtr);\r
+                }\r
+              } else {\r
+                Warning (ScanFiles->Str, LineNum, 0, StringTokenPos, "expected valid string identifier name");\r
+              }\r
+            }\r
+          } else {\r
+            //\r
+            // Found it, but it's a substring of something else. Advance our pointer.\r
+            //\r
+            Cptr++;\r
+          }\r
+\r
+          if (mGlobals.VerboseScan) {\r
+            printf ("\n");\r
+          }\r
+        }\r
+      }\r
+\r
+      fclose (Fptr);\r
+    } else {\r
+      //\r
+      // Skipping this file type\r
+      //\r
+      if (mGlobals.VerboseScan) {\r
+        printf ("Skip scanning of %s\n", ScanFiles->Str);\r
+      }\r
+    }\r
+\r
+    ScanFiles = ScanFiles->Next;\r
+  }\r
+\r
+  return STATUS_SUCCESS;\r
+}\r
+//\r
+// Free the global string lists we allocated memory for\r
+//\r
+static\r
+void\r
+FreeLists (\r
+  VOID\r
+  )\r
+{\r
+  TEXT_STRING_LIST  *Temp;\r
+  WCHAR_STRING_LIST *WTemp;\r
+\r
+  //\r
+  // Traverse the include paths, freeing each\r
+  //\r
+  while (mGlobals.IncludePaths != NULL) {\r
+    Temp = mGlobals.IncludePaths->Next;\r
+    free (mGlobals.IncludePaths->Str);\r
+    free (mGlobals.IncludePaths);\r
+    mGlobals.IncludePaths = Temp;\r
+  }\r
+  //\r
+  // If we did a scan, then free up our\r
+  // list of files to scan.\r
+  //\r
+  while (mGlobals.ScanFileName != NULL) {\r
+    Temp = mGlobals.ScanFileName->Next;\r
+    free (mGlobals.ScanFileName->Str);\r
+    free (mGlobals.ScanFileName);\r
+    mGlobals.ScanFileName = Temp;\r
+  }\r
+  //\r
+  // If they gave us a list of filename extensions to\r
+  // skip on scan, then free them up.\r
+  //\r
+  while (mGlobals.SkipExt != NULL) {\r
+    Temp = mGlobals.SkipExt->Next;\r
+    free (mGlobals.SkipExt->Str);\r
+    free (mGlobals.SkipExt);\r
+    mGlobals.SkipExt = Temp;\r
+  }\r
+  //\r
+  // Free up any languages specified\r
+  //\r
+  while (mGlobals.Language != NULL) {\r
+    WTemp = mGlobals.Language->Next;\r
+    free (mGlobals.Language->Str);\r
+    free (mGlobals.Language);\r
+    mGlobals.Language = WTemp;\r
+  }\r
+  //\r
+  // Free up our indirection list\r
+  //\r
+  while (mGlobals.IndirectionList != NULL) {\r
+    mGlobals.LastIndirectionList = mGlobals.IndirectionList->Next;\r
+    free (mGlobals.IndirectionList->Str1);\r
+    free (mGlobals.IndirectionList->Str2);\r
+    free (mGlobals.IndirectionList);\r
+    mGlobals.IndirectionList = mGlobals.LastIndirectionList;\r
+  }\r
+\r
+  while (mGlobals.IndirectionFileName != NULL) {\r
+    mGlobals.LastIndirectionFileName = mGlobals.IndirectionFileName->Next;\r
+    free (mGlobals.IndirectionFileName->Str);\r
+    free (mGlobals.IndirectionFileName);\r
+    mGlobals.IndirectionFileName = mGlobals.LastIndirectionFileName;\r
+  }\r
+}\r
+\r
+static\r
+BOOLEAN\r
+IsValidIdentifierChar (\r
+  CHAR8     Char,\r
+  BOOLEAN   FirstChar\r
+  )\r
+{\r
+  //\r
+  // If it's the first character of an identifier, then\r
+  // it must be one of [A-Za-z_].\r
+  //\r
+  if (FirstChar) {\r
+    if (isalpha (Char) || (Char == '_')) {\r
+      return TRUE;\r
+    }\r
+  } else {\r
+    //\r
+    // If it's not the first character, then it can\r
+    // be one of [A-Za-z_0-9]\r
+    //\r
+    if (isalnum (Char) || (Char == '_')) {\r
+      return TRUE;\r
+    }\r
+  }\r
+\r
+  return FALSE;\r
+}\r
+\r
+static\r
+void\r
+RewindFile (\r
+  SOURCE_FILE *SourceFile\r
+  )\r
+{\r
+  SourceFile->LineNum       = 1;\r
+  SourceFile->FileBufferPtr = SourceFile->FileBuffer;\r
+  SourceFile->EndOfFile     = 0;\r
+}\r
+\r
+static\r
+BOOLEAN\r
+SkipTo (\r
+  SOURCE_FILE *SourceFile,\r
+  WCHAR       WChar,\r
+  BOOLEAN     StopAfterNewline\r
+  )\r
+{\r
+  while (!EndOfFile (SourceFile)) {\r
+    //\r
+    // Check for the character of interest\r
+    //\r
+    if (SourceFile->FileBufferPtr[0] == WChar) {\r
+      return TRUE;\r
+    } else {\r
+      if (SourceFile->FileBufferPtr[0] == UNICODE_LF) {\r
+        SourceFile->LineNum++;\r
+        if (StopAfterNewline) {\r
+          SourceFile->FileBufferPtr++;\r
+          if (SourceFile->FileBufferPtr[0] == 0) {\r
+            SourceFile->FileBufferPtr++;\r
+          }\r
+\r
+          return FALSE;\r
+        }\r
+      }\r
+\r
+      SourceFile->FileBufferPtr++;\r
+    }\r
+  }\r
+\r
+  return FALSE;\r
+}\r
+\r
+static\r
+void\r
+Usage (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Print usage information for this utility.\r
+  \r
+Arguments:\r
+\r
+  None.\r
+\r
+Returns:\r
+\r
+  Nothing.\r
+  \r
+--*/\r
+{\r
+  int               Index;\r
+  static const char *Str[] = {\r
+    "",\r
+    PROGRAM_NAME " version "TOOL_VERSION " -- process unicode strings file",\r
+    "  Usage: "PROGRAM_NAME " -parse {parse options} [FileNames]",\r
+    "         "PROGRAM_NAME " -scan {scan options} [FileName]",\r
+    "         "PROGRAM_NAME " -dump {dump options}",\r
+    "    Common options include:",\r
+    "      -h or -?         for this help information",\r
+    "      -db Database     required name of output/input database file",\r
+    "      -bn BaseName     for use in the .h and .c output files",\r
+    "                       Default = "DEFAULT_BASE_NAME,\r
+    "      -v               for verbose output",\r
+    "      -vdbw            for verbose output when writing database",\r
+    "      -vdbr            for verbose output when reading database",\r
+    "      -od FileName     to specify an output database file name",\r
+    "    Parse options include:",\r
+    "      -i IncludePath   add IncludePath to list of search paths",\r
+    "      -newdb           to not read in existing database file",\r
+    "      -uqs             to indicate that unquoted strings are used",\r
+    "      FileNames        name of one or more unicode files to parse",\r
+    "    Scan options include:",\r
+    "      -scan            scan text file(s) for STRING_TOKEN() usage",\r
+    "      -skipext .ext    to skip scan of files with .ext filename extension",\r
+    "      -ignorenotfound  ignore if a given STRING_TOKEN(STR) is not ",\r
+    "                       found in the database",\r
+    "      FileNames        one or more files to scan",\r
+    "    Dump options include:",\r
+    "      -oc FileName     write string data to FileName",\r
+    "      -oh FileName     write string defines to FileName",\r
+    "      -ou FileName     dump database to unicode file FileName",\r
+    "      -lang Lang       only dump for the language 'Lang'",\r
+    "      -if FileName     to specify an indirection file",\r
+    "      -hpk FileName    to create an HII export pack of the strings",\r
+    "",\r
+    "  The expected process is to parse a unicode string file to create an initial",\r
+    "  database of string identifier names and string definitions. Then text files",\r
+    "  should be scanned for STRING_TOKEN() usages, and the referenced",\r
+    "  strings will be tagged as used in the database. After all files have been",\r
+    "  scanned, then the database should be dumped to create the necessary output",\r
+    "  files.",\r
+    "",\r
+    NULL\r
+  };\r
+  for (Index = 0; Str[Index] != NULL; Index++) {\r
+    fprintf (stdout, "%s\n", Str[Index]);\r
+  }\r
+}\r
diff --git a/Tools/CodeTools/Source/StrGather/StrGather.h b/Tools/CodeTools/Source/StrGather/StrGather.h
new file mode 100644 (file)
index 0000000..65dc15c
--- /dev/null
@@ -0,0 +1,84 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  StrGather.h\r
+\r
+Abstract:\r
+\r
+  Common defines and prototypes for StrGather.\r
+  \r
+--*/\r
+\r
+#ifndef _STR_GATHER_H_\r
+#define _STR_GATHER_H_\r
+\r
+#define MALLOC(size)  malloc (size)\r
+#define FREE(ptr)     free (ptr)\r
+\r
+#define PROGRAM_NAME  "StrGather"\r
+\r
+typedef CHAR16  WCHAR;\r
+\r
+#define UNICODE_TO_ASCII(w)   (INT8) ((w) & 0xFF)\r
+#define ASCII_TO_UNICODE(a)   (WCHAR) ((UINT8) (a))\r
+\r
+#define UNICODE_HASH          L'#'\r
+#define UNICODE_BACKSLASH     L'\\'\r
+#define UNICODE_SLASH         L'/'\r
+#define UNICODE_EQUAL_SIGN    L'='\r
+#define UNICODE_PLUS_SIGN     L'+'\r
+\r
+#define UNICODE_FILE_START    0xFEFF\r
+#define UNICODE_CR            0x000D\r
+#define UNICODE_LF            0x000A\r
+#define UNICODE_NULL          0x0000\r
+#define UNICODE_SPACE         L' '\r
+#define UNICODE_SLASH         L'/'\r
+#define UNICODE_DOUBLE_QUOTE  L'"'\r
+#define UNICODE_Z             L'Z'\r
+#define UNICODE_z             L'z'\r
+#define UNICODE_A             L'A'\r
+#define UNICODE_a             L'a'\r
+#define UNICODE_F             L'F'\r
+#define UNICODE_f             L'f'\r
+#define UNICODE_UNDERSCORE    L'_'\r
+#define UNICODE_0             L'0'\r
+#define UNICODE_9             L'9'\r
+#define UNICODE_TAB           L'\t'\r
+#define UNICODE_NBR_STRING    L"\\nbr"\r
+#define UNICODE_BR_STRING     L"\\br"\r
+#define UNICODE_WIDE_STRING   L"\\wide"\r
+#define UNICODE_NARROW_STRING L"\\narrow"\r
+\r
+//\r
+// This is the length of a valid string identifier\r
+//\r
+#define LANGUAGE_IDENTIFIER_NAME_LEN  3\r
+\r
+typedef struct _TEXT_STRING_LIST {\r
+  struct _TEXT_STRING_LIST  *Next;\r
+  CHAR8                     *Str;\r
+} TEXT_STRING_LIST;\r
+\r
+typedef struct _WCHAR_STRING_LIST {\r
+  struct _WCHAR_STRING_LIST *Next;\r
+  WCHAR                     *Str;\r
+} WCHAR_STRING_LIST;\r
+\r
+typedef struct _WCHAR_MATCHING_STRING_LIST {\r
+  struct _WCHAR_MATCHING_STRING_LIST  *Next;\r
+  WCHAR                               *Str1;\r
+  WCHAR                               *Str2;\r
+} WCHAR_MATCHING_STRING_LIST;\r
+\r
+#endif // #ifndef _STR_GATHER_H_\r
diff --git a/Tools/CodeTools/Source/StrGather/StringDB.c b/Tools/CodeTools/Source/StrGather/StringDB.c
new file mode 100644 (file)
index 0000000..16ef052
--- /dev/null
@@ -0,0 +1,2759 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  StringDB.c\r
+\r
+Abstract:\r
+\r
+  String database implementation\r
+  \r
+--*/\r
+\r
+#include <stdio.h>\r
+#include <stdlib.h>\r
+#include <string.h>\r
+#include <ctype.h>  // for tolower()\r
+\r
+#include <Common/UefiBaseTypes.h>\r
+#include <Common/MultiPhase.h>\r
+#include <Common/InternalFormRepresentation.h>\r
+#include <Protocol/UgaDraw.h>  // for EFI_UGA_PIXEL definition\r
+#include <Protocol/Hii.h>\r
+\r
+#include "EfiUtilityMsgs.h"\r
+#include "StrGather.h"\r
+#include "StringDB.h"\r
+\r
+\r
+#define STRING_OFFSET RELOFST\r
+\r
+#define STRING_DB_KEY (('S' << 24) | ('D' << 16) | ('B' << 8) | 'K')\r
+//\r
+// Version supported by this tool\r
+//\r
+#define STRING_DB_VERSION             0x00010000\r
+\r
+#define STRING_DB_MAJOR_VERSION_MASK  0xFFFF0000\r
+#define STRING_DB_MINOR_VERSION_MASK  0x0000FFFF\r
+\r
+#define DEFINE_STR                    L"// #define"\r
+\r
+#define LANGUAGE_CODE_WIDTH           4\r
+//\r
+// This is the header that gets written to the top of the\r
+// output binary database file.\r
+//\r
+typedef struct {\r
+  UINT32  Key;\r
+  UINT32  HeaderSize;\r
+  UINT32  Version;\r
+  UINT32  NumStringIdenfiers;\r
+  UINT32  StringIdentifiersSize;\r
+  UINT32  NumLanguages;\r
+} STRING_DB_HEADER;\r
+\r
+//\r
+// When we write out data to the database, we have a UINT16 identifier, which\r
+// indicates what follows, followed by the data. Here's the structure.\r
+//\r
+typedef struct {\r
+  UINT16  DataType;\r
+  UINT16  Reserved;\r
+} DB_DATA_ITEM_HEADER;\r
+\r
+#define DB_DATA_TYPE_INVALID              0x0000\r
+#define DB_DATA_TYPE_STRING_IDENTIFIER    0x0001\r
+#define DB_DATA_TYPE_LANGUAGE_DEFINITION  0x0002\r
+#define DB_DATA_TYPE_STRING_DEFINITION    0x0003\r
+#define DB_DATA_TYPE_LAST                 DB_DATA_TYPE_STRING_DEFINITION\r
+\r
+//\r
+// We have to keep track of a list of languages, each of which has its own\r
+// list of strings. Define a structure to keep track of all languages and\r
+// their list of strings.\r
+//\r
+typedef struct _STRING_LIST {\r
+  struct _STRING_LIST *Next;\r
+  UINT32              Size;         // number of bytes in string, including null terminator\r
+  WCHAR               *LanguageName;\r
+  WCHAR               *StringName;  // for example STR_ID_TEXT1\r
+  WCHAR               *Scope;       //\r
+  WCHAR               *Str;         // the actual string\r
+  UINT16              Flags;        // properties of this string (used, undefined)\r
+} STRING_LIST;\r
+\r
+typedef struct _LANGUAGE_LIST {\r
+  struct _LANGUAGE_LIST *Next;\r
+  WCHAR                 LanguageName[4];\r
+  WCHAR                 *PrintableLanguageName;\r
+  STRING_LIST           *String;\r
+  STRING_LIST           *LastString;\r
+} LANGUAGE_LIST;\r
+\r
+//\r
+// We also keep track of all the string identifier names, which we assign unique\r
+// values to. Create a structure to keep track of them all.\r
+//\r
+typedef struct _STRING_IDENTIFIER {\r
+  struct _STRING_IDENTIFIER *Next;\r
+  UINT32                    Index;  // only need 16 bits, but makes it easier with UINT32\r
+  WCHAR                     *StringName;\r
+  UINT16                    Flags;  // if someone referenced it via STRING_TOKEN()\r
+} STRING_IDENTIFIER;\r
+//\r
+// Keep our globals in this structure to be as modular as possible.\r
+//\r
+typedef struct {\r
+  FILE              *StringDBFptr;\r
+  LANGUAGE_LIST     *LanguageList;\r
+  LANGUAGE_LIST     *LastLanguageList;\r
+  LANGUAGE_LIST     *CurrentLanguage;         // keep track of the last language they used\r
+  STRING_IDENTIFIER *StringIdentifier;\r
+  STRING_IDENTIFIER *LastStringIdentifier;\r
+  UINT8             *StringDBFileName;\r
+  UINT32            NumStringIdentifiers;\r
+  UINT32            NumStringIdentifiersReferenced;\r
+  STRING_IDENTIFIER *CurrentStringIdentifier; // keep track of the last string identifier they added\r
+  WCHAR             *CurrentScope;\r
+} STRING_DB_DATA;\r
+\r
+static STRING_DB_DATA mDBData;\r
+\r
+static const char     *mSourceFileHeader[] = {\r
+  "//",\r
+  "//  DO NOT EDIT -- auto-generated file",\r
+  "//",\r
+  "//  This file is generated by the string gather utility",\r
+  "//",\r
+  NULL\r
+};\r
+\r
+static\r
+STRING_LIST           *\r
+StringDBFindString (\r
+  WCHAR                       *LanguageName,\r
+  WCHAR                       *StringName,\r
+  WCHAR                       *Scope,\r
+  WCHAR_STRING_LIST           *LanguagesOfInterest,\r
+  WCHAR_MATCHING_STRING_LIST  *IndirectionList\r
+  );\r
+\r
+static\r
+STRING_IDENTIFIER     *\r
+StringDBFindStringIdentifierByName (\r
+  WCHAR *Name\r
+  );\r
+\r
+static\r
+STRING_IDENTIFIER     *\r
+StringDBFindStringIdentifierByIndex (\r
+  UINT32    Index\r
+  );\r
+\r
+static\r
+LANGUAGE_LIST         *\r
+StringDBFindLanguageList (\r
+  WCHAR *LanguageName\r
+  );\r
+\r
+static\r
+void\r
+StringDBWriteStandardFileHeader (\r
+  FILE *OutFptr\r
+  );\r
+\r
+static\r
+WCHAR                 *\r
+AsciiToWchar (\r
+  CHAR8 *Str\r
+  );\r
+\r
+static\r
+WCHAR                 *\r
+DuplicateString (\r
+  WCHAR   *Str\r
+  );\r
+\r
+static\r
+STATUS\r
+StringDBWriteStringIdentifier (\r
+  FILE                *DBFptr,\r
+  UINT16              StringId,\r
+  UINT16              Flags,\r
+  WCHAR               *IdentifierName\r
+  );\r
+\r
+static\r
+STATUS\r
+StringDBReadStringIdentifier (\r
+  FILE                *DBFptr\r
+  );\r
+\r
+static\r
+STATUS\r
+StringDBWriteLanguageDefinition (\r
+  FILE            *DBFptr,\r
+  WCHAR           *LanguageName,\r
+  WCHAR           *PrintableLanguageName\r
+  );\r
+\r
+static\r
+STATUS\r
+StringDBReadLanguageDefinition (\r
+  FILE            *DBFptr\r
+  );\r
+\r
+static\r
+STATUS\r
+StringDBWriteString (\r
+  FILE            *DBFptr,\r
+  UINT16          Flags,\r
+  WCHAR           *Language,\r
+  WCHAR           *StringName,\r
+  WCHAR           *Scope,\r
+  WCHAR           *Str\r
+  );\r
+\r
+static\r
+STATUS\r
+StringDBReadString (\r
+  FILE            *DBFptr\r
+  );\r
+\r
+static\r
+STATUS\r
+StringDBReadGenericString (\r
+  FILE      *DBFptr,\r
+  UINT16    *Size,\r
+  WCHAR     **Str\r
+  );\r
+\r
+static\r
+STATUS\r
+StringDBWriteGenericString (\r
+  FILE      *DBFptr,\r
+  WCHAR     *Str\r
+  );\r
+\r
+static\r
+void\r
+StringDBAssignStringIndexes (\r
+  VOID\r
+  );\r
+\r
+/*****************************************************************************/\r
+\r
+/*++\r
+\r
+Routine Description:\r
+  Constructor function for the string database handler.\r
+\r
+Arguments:\r
+  None.\r
+\r
+Returns:\r
+  None.\r
+\r
+--*/\r
+void\r
+StringDBConstructor (\r
+  VOID\r
+  )\r
+{\r
+  memset ((char *) &mDBData, 0, sizeof (STRING_DB_DATA));\r
+  mDBData.CurrentScope = DuplicateString (L"NULL");\r
+}\r
+\r
+/*****************************************************************************/\r
+\r
+/*++\r
+\r
+Routine Description:\r
+  Destructor function for the string database handler.\r
+\r
+Arguments:\r
+  None.\r
+\r
+Returns:\r
+  None.\r
+\r
+--*/\r
+void\r
+StringDBDestructor (\r
+  VOID\r
+  )\r
+{\r
+  LANGUAGE_LIST     *NextLang;\r
+  STRING_LIST       *NextStr;\r
+  STRING_IDENTIFIER *NextIdentifier;\r
+  //\r
+  // Close the database file if it's open\r
+  //\r
+  if (mDBData.StringDBFptr != NULL) {\r
+    fclose (mDBData.StringDBFptr);\r
+    mDBData.StringDBFptr = NULL;\r
+  }\r
+  //\r
+  // If we've allocated any strings/languages, free them up\r
+  //\r
+  while (mDBData.LanguageList != NULL) {\r
+    NextLang = mDBData.LanguageList->Next;\r
+    //\r
+    // Free up all strings for this language\r
+    //\r
+    while (mDBData.LanguageList->String != NULL) {\r
+      NextStr = mDBData.LanguageList->String->Next;\r
+      FREE (mDBData.LanguageList->String->Str);\r
+      FREE (mDBData.LanguageList->String);\r
+      mDBData.LanguageList->String = NextStr;\r
+    }\r
+\r
+    FREE (mDBData.LanguageList->PrintableLanguageName);\r
+    FREE (mDBData.LanguageList);\r
+    mDBData.LanguageList = NextLang;\r
+  }\r
+  //\r
+  // Free up string identifiers\r
+  //\r
+  while (mDBData.StringIdentifier != NULL) {\r
+    NextIdentifier = mDBData.StringIdentifier->Next;\r
+    FREE (mDBData.StringIdentifier->StringName);\r
+    FREE (mDBData.StringIdentifier);\r
+    mDBData.StringIdentifier = NextIdentifier;\r
+  }\r
+  //\r
+  // Free the filename\r
+  //\r
+  if (mDBData.StringDBFileName != NULL) {\r
+    FREE (mDBData.StringDBFileName);\r
+    mDBData.StringDBFileName = NULL;\r
+  }\r
+  //\r
+  // We save a copy of the scope, so free it up if we\r
+  // have one.\r
+  //\r
+  if (mDBData.CurrentScope != NULL) {\r
+    FREE (mDBData.CurrentScope);\r
+    mDBData.CurrentScope = NULL;\r
+  }\r
+}\r
+\r
+/*****************************************************************************/\r
+\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Dump the contents of a database to an output C file.\r
+\r
+Arguments:\r
+\r
+  FileName        - name of the output file to write \r
+  BaseName        - used for the name of the C array defined\r
+  Languages       - list of languages of interest\r
+\r
+Returns:\r
+\r
+  STATUS\r
+\r
+Notes:\r
+\r
+  Languages is a pointer to a linked list of languages specified on\r
+  the command line. Format is "eng" and "spa+cat". For this, print\r
+  the strings for eng. Print the strings for spa too, but if one is\r
+  missing look for a cat string and print if it it exists.\r
+\r
+--*/\r
+STATUS\r
+StringDBDumpCStrings (\r
+  CHAR8                       *FileName,\r
+  CHAR8                       *BaseName,\r
+  WCHAR_STRING_LIST           *LanguagesOfInterest,\r
+  WCHAR_MATCHING_STRING_LIST  *IndirectionList\r
+  )\r
+{\r
+  FILE                        *Fptr;\r
+  LANGUAGE_LIST               *Lang;\r
+  STRING_LIST                 *CurrString;\r
+  STRING_LIST                 EmptyString;\r
+  UINT32                      Offset;\r
+  UINT32                      StringIndex;\r
+  UINT32                      TempIndex;\r
+  UINT32                      BytesThisLine;\r
+  EFI_HII_STRING_PACK         StringPack;\r
+  UINT8                       *Ptr;\r
+  UINT32                      Len;\r
+  WCHAR                       ZeroString[1];\r
+  WCHAR_STRING_LIST           *LOIPtr;\r
+  BOOLEAN                     LanguageOk;\r
+  WCHAR                       *TempStringPtr;\r
+  WCHAR                       *LangName;\r
+  STRING_IDENTIFIER           *StringIdentifier;\r
+  WCHAR                       Line[200];\r
+\r
+  if ((Fptr = fopen (FileName, "w")) == NULL) {\r
+    Error (NULL, 0, 0, FileName, "failed to open output C string file");\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Assign index values to the string identifiers\r
+  //\r
+  StringDBAssignStringIndexes ();\r
+  //\r
+  // Write the standard header to the output file, then the structure\r
+  // definition header.\r
+  //\r
+  StringDBWriteStandardFileHeader (Fptr);\r
+  fprintf (Fptr, "\nunsigned char %s[] = {\n", BaseName);\r
+  //\r
+  // If a given string is not defined, then we'll use this one.\r
+  //\r
+  memset (&EmptyString, 0, sizeof (EmptyString));\r
+  EmptyString.Size  = sizeof (ZeroString);\r
+  EmptyString.Str   = ZeroString;\r
+  //\r
+  // Process each language, then each string for each langage\r
+  //\r
+  ZeroString[0] = 0;\r
+  for (Lang = mDBData.LanguageList; Lang != NULL; Lang = Lang->Next) {\r
+    //\r
+    // If we have a language list, then make sure this language is in that\r
+    // list.\r
+    //\r
+    LanguageOk  = TRUE;\r
+    LangName    = Lang->LanguageName;\r
+    if (LanguagesOfInterest != NULL) {\r
+      LanguageOk = FALSE;\r
+      for (LOIPtr = LanguagesOfInterest; LOIPtr != NULL; LOIPtr = LOIPtr->Next) {\r
+        if (StrnCmp (LOIPtr->Str, Lang->LanguageName, LANGUAGE_IDENTIFIER_NAME_LEN) == 0) {\r
+          LangName    = LOIPtr->Str;\r
+          LanguageOk  = TRUE;\r
+          break;\r
+        }\r
+      }\r
+    }\r
+\r
+    if (!LanguageOk) {\r
+      continue;\r
+    }\r
+    //\r
+    // Process each string for this language. We have to make 3 passes on the strings:\r
+    //   Pass1: computes sizes and fill in the string pack header\r
+    //   Pass2: write the array of offsets\r
+    //   Pass3: write the strings\r
+    //\r
+    //\r
+    // PASS 1: Fill in and print the HII string pack header\r
+    //\r
+    // Compute the size for this language package and write\r
+    // the header out. Each string package contains:\r
+    //   Header\r
+    //   Offset[]  -- an array of offsets to strings, of type RELOFST each\r
+    //   String[]  -- the actual strings themselves\r
+    //\r
+    AsciiSPrint ( Line, sizeof(Line),\r
+      "\n//******************************************************************************"\r
+      "\n// Start of string definitions for %s/%s",\r
+      Lang->LanguageName,\r
+      Lang->PrintableLanguageName\r
+      );\r
+    fprintf (Fptr, "%s", Line);\r
+    memset ((char *) &StringPack, 0, sizeof (EFI_HII_STRING_PACK));\r
+    StringPack.Header.Type        = EFI_HII_STRING;\r
+    StringPack.NumStringPointers  = (UINT16) mDBData.NumStringIdentifiersReferenced;\r
+    //\r
+    // First string is the language name. If we're printing all languages, then\r
+    // it's just the "spa". If we were given a list of languages to print, then it's\r
+    // the "spacat" string. Compute its offset and fill in\r
+    // the info in the header. Since we know the language name string's length,\r
+    // and the printable language name follows it, use that info to fill in the\r
+    // entry for the printable language name as well.\r
+    //\r
+    StringPack.LanguageNameString = (STRING_OFFSET) (sizeof (EFI_HII_STRING_PACK) + (mDBData.NumStringIdentifiersReferenced * sizeof (STRING_OFFSET)));\r
+    StringPack.PrintableLanguageName = (STRING_OFFSET) (StringPack.LanguageNameString + (StrLen (LangName) + 1) * sizeof (WCHAR));\r
+    //\r
+    // Add up the size of all strings so we can fill in our header.\r
+    //\r
+    Len = 0;\r
+    for (StringIndex = 0; StringIndex < mDBData.NumStringIdentifiersReferenced; StringIndex++) {\r
+      //\r
+      // For the first string (language name), we print out the "spacat" if they\r
+      // requested it. We set LangName to point to the proper language name string above.\r
+      //\r
+      if (StringIndex == STRING_ID_LANGUAGE_NAME) {\r
+        Len += (StrLen (LangName) + 1) * sizeof (WCHAR);\r
+      } else {\r
+        //\r
+        // Find a string with this language.stringname\r
+        //\r
+        StringIdentifier = StringDBFindStringIdentifierByIndex (StringIndex);\r
+        if (StringIdentifier == NULL) {\r
+          Error (NULL, 0, 0, "internal error", "invalid string index 0x%X", StringIndex);\r
+          return STATUS_ERROR;\r
+        }\r
+        //\r
+        // Find a matching string if this string identifier was referenced\r
+        //\r
+        EmptyString.Flags = STRING_FLAGS_UNDEFINED;\r
+        CurrString        = NULL;\r
+        if (StringIdentifier->Flags & STRING_FLAGS_REFERENCED) {\r
+          CurrString = StringDBFindString (\r
+                        Lang->LanguageName,\r
+                        StringIdentifier->StringName,\r
+                        NULL,\r
+                        LanguagesOfInterest,\r
+                        IndirectionList\r
+                        );\r
+          if (NULL == CurrString) {\r
+            //\r
+            // If string for Lang->LanguageName is not found, try to get an English version\r
+            //\r
+            CurrString = StringDBFindString (\r
+                          L"eng",\r
+                          StringIdentifier->StringName,\r
+                          NULL,\r
+                          LanguagesOfInterest,\r
+                          IndirectionList\r
+                          );\r
+          }\r
+        }\r
+\r
+        if (CurrString == NULL) {\r
+          CurrString = &EmptyString;\r
+          EmptyString.Flags |= StringIdentifier->Flags;\r
+        }\r
+\r
+        Len += CurrString->Size;\r
+      }\r
+    }\r
+    StringPack.Header.Length =    sizeof (EFI_HII_STRING_PACK) \r
+                                + mDBData.NumStringIdentifiersReferenced * sizeof (STRING_OFFSET) \r
+                                + Len;\r
+    //\r
+    // Write out the header one byte at a time\r
+    //\r
+    Ptr = (UINT8 *) &StringPack;\r
+    for (TempIndex = 0; TempIndex < sizeof (EFI_HII_STRING_PACK); TempIndex++, Ptr++) {\r
+      if ((TempIndex & 0x07) == 0) {\r
+        fprintf (Fptr, "\n  ");\r
+      }\r
+\r
+      fprintf (Fptr, "0x%02X, ", (UINT32) *Ptr);\r
+    }\r
+\r
+    fprintf (Fptr, "\n  // offset 0x%X\n", sizeof (StringPack));\r
+    //\r
+    // PASS2 : write the offsets\r
+    //\r
+    // Traverse the list of strings again and write the array of offsets. The\r
+    // offset to the first string is the size of the string pack header\r
+    // plus the size of the offsets array. The other strings follow it.\r
+    //\r
+    StringIndex = 0;\r
+    Offset      = sizeof (StringPack) + mDBData.NumStringIdentifiersReferenced * sizeof (STRING_OFFSET);\r
+    for (StringIndex = 0; StringIndex < mDBData.NumStringIdentifiersReferenced; StringIndex++) {\r
+      //\r
+      // Write the offset, followed by a useful comment\r
+      //\r
+      fprintf (Fptr, "  ");\r
+      Ptr = (UINT8 *) &Offset;\r
+      for (TempIndex = 0; TempIndex < sizeof (STRING_OFFSET); TempIndex++) {\r
+        fprintf (Fptr, "0x%02X, ", (UINT32) Ptr[TempIndex]);\r
+      }\r
+      //\r
+      // Find the string name\r
+      //\r
+      StringIdentifier = StringDBFindStringIdentifierByIndex (StringIndex);\r
+      if (StringIdentifier == NULL) {\r
+        Error (NULL, 0, 0, "internal error", "invalid string index 0x%X", StringIndex);\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      AsciiSPrint (Line, sizeof(Line) , " // offset to string %s (0x%04X)", StringIdentifier->StringName, StringIndex);\r
+      fprintf (Fptr, "%s", Line);\r
+      //\r
+      // For the first string (language name), we print out the "spacat" if they\r
+      // requested it. We set LangName to point to the proper language name string above.\r
+      //\r
+      if (StringIndex == STRING_ID_LANGUAGE_NAME) {\r
+        Offset += (StrLen (LangName) + 1) * sizeof (WCHAR);\r
+        CurrString = StringDBFindString (\r
+                      Lang->LanguageName,\r
+                      StringIdentifier->StringName,\r
+                      NULL, // scope\r
+                      NULL,\r
+                      NULL\r
+                      );\r
+      } else {\r
+        //\r
+        // Find a matching string\r
+        //\r
+        CurrString = StringDBFindString (\r
+                      Lang->LanguageName,\r
+                      StringIdentifier->StringName,\r
+                      NULL,   // scope\r
+                      LanguagesOfInterest,\r
+                      IndirectionList\r
+                      );\r
+\r
+        if (NULL == CurrString) {\r
+          CurrString = StringDBFindString (\r
+                        L"eng",\r
+                        StringIdentifier->StringName,\r
+                        NULL, // scope\r
+                        LanguagesOfInterest,\r
+                        IndirectionList\r
+                        );\r
+        }\r
+\r
+        EmptyString.LanguageName = Lang->LanguageName;\r
+        if (CurrString == NULL) {\r
+          CurrString        = &EmptyString;\r
+          EmptyString.Flags = STRING_FLAGS_UNDEFINED;\r
+        } else if ((StringIdentifier->Flags & STRING_FLAGS_REFERENCED) == 0) {\r
+          CurrString        = &EmptyString;\r
+          EmptyString.Flags = 0;\r
+        }\r
+\r
+        Offset += CurrString->Size;\r
+      }\r
+      //\r
+      // Print useful info about this string\r
+      //\r
+      if ((StringIdentifier->Flags & STRING_FLAGS_REFERENCED) == 0) {\r
+        fprintf (Fptr, " - not referenced");\r
+      }\r
+\r
+      if (CurrString->Flags & STRING_FLAGS_UNDEFINED) {\r
+        fprintf (Fptr, " - not defined for this language");\r
+      } else if (StrCmp (CurrString->LanguageName, Lang->LanguageName) != 0) {\r
+        AsciiSPrint (\r
+          Line, sizeof(Line),\r
+          " - not defined for this language -- using secondary language %s definition",\r
+          CurrString->LanguageName\r
+          );\r
+        fprintf ( Fptr, "%s", Line);\r
+      }\r
+\r
+      fprintf (Fptr, "\n");\r
+    }\r
+    //\r
+    // For unreferenced string identifiers, print a message that they are not referenced anywhere\r
+    //\r
+    while (StringIndex < mDBData.NumStringIdentifiers) {\r
+      StringIdentifier = StringDBFindStringIdentifierByIndex (StringIndex);\r
+      if (StringIdentifier != NULL) {\r
+        AsciiSPrint (Line, sizeof(Line), "  // %s not referenced\n", StringIdentifier->StringName);\r
+        fprintf (Fptr, "%s", Line);\r
+      }\r
+\r
+      StringIndex++;\r
+    }\r
+\r
+    //\r
+    // PASS 3: write the strings themselves.\r
+    // Keep track of how many bytes we write per line because some editors\r
+    // (Visual Studio for instance) can't handle too long of lines.\r
+    //\r
+    Offset = sizeof (StringPack) + mDBData.NumStringIdentifiersReferenced * sizeof (STRING_OFFSET);\r
+    for (StringIndex = 0; StringIndex < mDBData.NumStringIdentifiersReferenced; StringIndex++) {\r
+      StringIdentifier = StringDBFindStringIdentifierByIndex (StringIndex);\r
+      if (StringIdentifier == NULL) {\r
+        Error (NULL, 0, 0, "internal error", "invalid string index 0x%X", StringIndex);\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      AsciiSPrint (Line, sizeof(Line), "  // string %s offset 0x%08X\n  ", StringIdentifier->StringName, Offset);\r
+      fprintf (Fptr, "%s", Line);\r
+      //\r
+      // For the first string (language name), we print out the "spacat" if they\r
+      // requested it. We set LangName to point to the proper language name string above.\r
+      //\r
+      if (StringIndex == STRING_ID_LANGUAGE_NAME) {\r
+        TempStringPtr = LangName;\r
+      } else {\r
+        //\r
+        // Find a matching string if this string identifier was referenced\r
+        //\r
+        CurrString = NULL;\r
+        if (StringIdentifier->Flags & STRING_FLAGS_REFERENCED) {\r
+          CurrString = StringDBFindString (\r
+                        Lang->LanguageName,\r
+                        StringIdentifier->StringName,\r
+                        NULL,   // scope\r
+                        LanguagesOfInterest,\r
+                        IndirectionList\r
+                        );\r
+          if (NULL == CurrString) {\r
+            CurrString = StringDBFindString (\r
+                          L"eng",\r
+                          StringIdentifier->StringName,\r
+                          NULL, // scope\r
+                          LanguagesOfInterest,\r
+                          IndirectionList\r
+                          );\r
+          }\r
+        }\r
+\r
+        if (CurrString == NULL) {\r
+          CurrString = &EmptyString;\r
+        }\r
+\r
+        TempStringPtr = CurrString->Str;\r
+      }\r
+\r
+      BytesThisLine = 0;\r
+      for (TempIndex = 0; TempStringPtr[TempIndex] != 0; TempIndex++) {\r
+        fprintf (\r
+          Fptr,\r
+          "0x%02X, 0x%02X, ",\r
+          (UINT32) TempStringPtr[TempIndex] & 0xFF,\r
+          (UINT32) ((TempStringPtr[TempIndex] >> 8) & 0xFF)\r
+          );\r
+        BytesThisLine += 2;\r
+        Offset += 2;\r
+        //\r
+        // Let's say we only allow 14 per line\r
+        //\r
+        if (BytesThisLine > 14) {\r
+          fprintf (Fptr, "\n  ");\r
+          BytesThisLine = 0;\r
+        }\r
+      }\r
+      //\r
+      // Print NULL WCHAR at the end of this string.\r
+      //\r
+      fprintf (Fptr, "0x00, 0x00,\n");\r
+      Offset += 2;\r
+    }\r
+    //\r
+    // Sanity check the offset. Make sure our running offset is what we put in the\r
+    // string pack header.\r
+    //\r
+    if (StringPack.Header.Length != Offset) {\r
+      Error (\r
+        __FILE__,\r
+        __LINE__,\r
+        0,\r
+        "application error",\r
+        "stringpack size 0x%X does not match final size 0x%X",\r
+        StringPack.Header.Length,\r
+        Offset\r
+        );\r
+    }\r
+  }\r
+  //\r
+  // Print terminator string pack, closing brace and close the file.\r
+  // The size of 0 triggers to the consumer that this is the end.\r
+  //\r
+  memset ((char *) &StringPack, 0, sizeof (EFI_HII_STRING_PACK));\r
+  StringPack.Header.Type  = EFI_HII_STRING;\r
+  Ptr                     = (UINT8 *) &StringPack;\r
+  fprintf (Fptr, "\n  // strings terminator pack");\r
+  for (TempIndex = 0; TempIndex < sizeof (StringPack); TempIndex++, Ptr++) {\r
+    if ((TempIndex & 0x0F) == 0) {\r
+      fprintf (Fptr, "\n  ");\r
+    }\r
+\r
+    fprintf (Fptr, "0x%02X, ", (UINT32) *Ptr);\r
+  }\r
+\r
+  fprintf (Fptr, "\n};\n");\r
+  fclose (Fptr);\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+/*****************************************************************************/\r
+\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Dump the #define string names\r
+\r
+Arguments:\r
+\r
+  FileName        - name of the output file to write \r
+  BaseName        - used for the protection #ifndef/#endif \r
+\r
+Returns:\r
+\r
+  STATUS\r
+\r
+--*/\r
+STATUS\r
+StringDBDumpStringDefines (\r
+  CHAR8 *FileName,\r
+  CHAR8 *BaseName\r
+  )\r
+{\r
+  FILE              *Fptr;\r
+  STRING_IDENTIFIER *Identifier;\r
+  CHAR8             CopyBaseName[100];\r
+  WCHAR             Line[200];\r
+  UINT32            Index;\r
+  const CHAR8       *StrDefHeader[] = {\r
+    "#ifndef _%s_STRINGS_DEFINE_H_\n",\r
+    "#define _%s_STRINGS_DEFINE_H_\n\n",\r
+    NULL\r
+  };\r
+\r
+  if ((Fptr = fopen (FileName, "w")) == NULL) {\r
+    Error (NULL, 0, 0, FileName, "failed to open output string defines file");\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Get the base source filename and convert to uppercase.\r
+  //\r
+  if (sizeof (CopyBaseName) <= strlen (BaseName) + 1) {\r
+    Error (NULL, 0, 0, "application error", "StringDBDumpStringDefines() string length insufficient");\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  strcpy (CopyBaseName, BaseName);\r
+  for (Index = 0; CopyBaseName[Index] != 0; Index++) {\r
+    if (islower (CopyBaseName[Index])) {\r
+      CopyBaseName[Index] = (INT8) toupper (CopyBaseName[Index]);\r
+    }\r
+  }\r
+  //\r
+  // Assign index values to the string identifiers\r
+  //\r
+  StringDBAssignStringIndexes ();\r
+  //\r
+  // Write the standard header to the output file, and then the\r
+  // protective #ifndef.\r
+  //\r
+  StringDBWriteStandardFileHeader (Fptr);\r
+  for (Index = 0; StrDefHeader[Index] != NULL; Index++) {\r
+    fprintf (Fptr, StrDefHeader[Index], CopyBaseName);\r
+  }\r
+  //\r
+  // Print all the #defines for the string identifiers. Print identifiers\r
+  // whose names start with '$' as comments. Add comments for string\r
+  // identifiers not used as well.\r
+  //\r
+  Identifier = mDBData.StringIdentifier;\r
+  while (Identifier != NULL) {\r
+    if (Identifier->StringName[0] == L'$') {\r
+      fprintf (Fptr, "// ");\r
+    }\r
+\r
+    if (Identifier->Flags & STRING_FLAGS_REFERENCED) {\r
+      AsciiSPrint (Line, sizeof(Line), "#define %-40s 0x%04X\n", Identifier->StringName, Identifier->Index);\r
+      fprintf (Fptr, "%s", Line);\r
+    } else {\r
+      AsciiSPrint (Line, sizeof(Line), "//#define %-40s 0x%04X // not referenced\n", Identifier->StringName, Identifier->Index);\r
+      fprintf (Fptr, "%s", Line);\r
+    }\r
+\r
+    Identifier = Identifier->Next;\r
+  }\r
+\r
+  fprintf (Fptr, "\n#endif\n");\r
+  fclose (Fptr);\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+/*****************************************************************************/\r
+\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Add a string identifier to the database.\r
+\r
+Arguments:\r
+\r
+  StringName      - name of the string identifier. For example "STR_MY_STRING"\r
+  NewId           - if an ID has been assigned\r
+  Flags           - characteristics for the identifier\r
+\r
+Returns:\r
+\r
+  STATUS\r
+\r
+--*/\r
+STATUS\r
+StringDBAddStringIdentifier (\r
+  WCHAR     *StringName,\r
+  UINT16    *NewId,\r
+  UINT16    Flags\r
+  )\r
+{\r
+  STRING_IDENTIFIER *StringIdentifier;\r
+  STATUS            Status;\r
+  //\r
+  // If it was already used for some other language, then we don't\r
+  // need to add it. But set it to the current string identifier.\r
+  // The referenced bit is sticky.\r
+  //\r
+  Status            = STATUS_SUCCESS;\r
+  StringIdentifier  = StringDBFindStringIdentifierByName (StringName);\r
+  if (StringIdentifier != NULL) {\r
+    if (Flags & STRING_FLAGS_REFERENCED) {\r
+      StringIdentifier->Flags |= STRING_FLAGS_REFERENCED;\r
+    }\r
+\r
+    mDBData.CurrentStringIdentifier = StringIdentifier;\r
+    *NewId                          = (UINT16) StringIdentifier->Index;\r
+    return Status;\r
+  }\r
+\r
+  StringIdentifier = (STRING_IDENTIFIER *) MALLOC (sizeof (STRING_IDENTIFIER));\r
+  if (StringIdentifier == NULL) {\r
+    Error (NULL, 0, 0, NULL, "memory allocation error");\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  memset ((char *) StringIdentifier, 0, sizeof (STRING_IDENTIFIER));\r
+  StringIdentifier->StringName = (WCHAR *) malloc ((StrLen (StringName) + 1) * sizeof (WCHAR));\r
+  if (StringIdentifier->StringName == NULL) {\r
+    Error (NULL, 0, 0, NULL, "memory allocation error");\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  StrCpy (StringIdentifier->StringName, StringName);\r
+  if (*NewId != STRING_ID_INVALID) {\r
+    StringIdentifier->Index = *NewId;\r
+    StringIdentifier->Flags |= STRING_FLAGS_INDEX_ASSIGNED;\r
+    if (mDBData.NumStringIdentifiers <= StringIdentifier->Index) {\r
+      mDBData.NumStringIdentifiers = StringIdentifier->Index + 1;\r
+    }\r
+  } else {\r
+    StringIdentifier->Index = mDBData.NumStringIdentifiers++;\r
+  }\r
+\r
+  StringIdentifier->Flags |= Flags;\r
+  //\r
+  // Add it to our list of string identifiers\r
+  //\r
+  if (mDBData.StringIdentifier == NULL) {\r
+    mDBData.StringIdentifier = StringIdentifier;\r
+  } else {\r
+    mDBData.LastStringIdentifier->Next = StringIdentifier;\r
+  }\r
+\r
+  mDBData.LastStringIdentifier    = StringIdentifier;\r
+  mDBData.CurrentStringIdentifier = StringIdentifier;\r
+  *NewId                          = (UINT16) StringIdentifier->Index;\r
+  return Status;\r
+}\r
+\r
+/*****************************************************************************/\r
+\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Add a new string to the database.\r
+\r
+Arguments:\r
+\r
+  LanguageName    - "eng" or "spa" language name\r
+  StringName      - "STR_MY_TEXT" string name\r
+  Scope           - from the #scope statements in the string file\r
+  Format          - if we should format the string\r
+  Flags           - characteristic flags for the string\r
+\r
+Returns:\r
+\r
+  STATUS\r
+\r
+Notes:\r
+\r
+  Several of the fields can be "inherited" from the previous calls to\r
+  our database functions. For example, if scope is NULL here, then\r
+  we'll use the previous setting.\r
+\r
+--*/\r
+STATUS\r
+StringDBAddString (\r
+  WCHAR   *LanguageName,\r
+  WCHAR   *StringName,\r
+  WCHAR   *Scope,\r
+  WCHAR   *String,\r
+  BOOLEAN Format,\r
+  UINT16  Flags\r
+  )\r
+{\r
+  LANGUAGE_LIST     *Lang;\r
+  UINT32            Size;\r
+  STRING_LIST       *Str;\r
+  UINT16            StringIndex;\r
+  WCHAR             TempLangName[4];\r
+  STRING_IDENTIFIER *StringIdentifier;\r
+\r
+  //\r
+  // Check that language name is exactly 3 characters, or emit an error.\r
+  // Truncate at 3 if it's longer, or make it 3 if it's shorter.\r
+  //\r
+  if (LanguageName != NULL) {\r
+    Size = StrLen (LanguageName);\r
+    if (Size != 3) {\r
+      ParserError (0, "invalid length for language name", "%S", LanguageName);\r
+      if (Size > 3) {\r
+        LanguageName[3] = 0;\r
+      } else {\r
+        //\r
+        // Make a local copy of the language name string, and extend to\r
+        // 3 characters since we make assumptions elsewhere in this program\r
+        // on the length.\r
+        //\r
+        StrCpy (TempLangName, LanguageName);\r
+        for (; Size < 3; Size++) {\r
+          TempLangName[Size] = L'?';\r
+        }\r
+\r
+        TempLangName[4] = 0;\r
+        LanguageName    = TempLangName;\r
+      }\r
+    }\r
+  }\r
+  //\r
+  // If they specified a language, make sure they've defined it already\r
+  // via a #langdef statement. Otherwise use the current default language.\r
+  //\r
+  if (LanguageName != NULL) {\r
+    Lang = StringDBFindLanguageList (LanguageName);\r
+    if (Lang == NULL) {\r
+      ParserError (0, "language not defined", "%S", LanguageName);\r
+      return STATUS_ERROR;\r
+    } else {\r
+      StringDBSetCurrentLanguage (LanguageName);\r
+    }\r
+  } else {\r
+    Lang = mDBData.CurrentLanguage;\r
+    if (Lang == NULL) {\r
+      //\r
+      // Have to call SetLanguage() first\r
+      //\r
+      ParserError (0, "no language defined", "%S", StringName);\r
+      return STATUS_ERROR;\r
+    }\r
+  }\r
+  //\r
+  // If they didn't define a string identifier, use the last string identifier\r
+  // added.\r
+  //\r
+  if (StringName == NULL) {\r
+    StringName = mDBData.CurrentStringIdentifier->StringName;\r
+    if (StringName == NULL) {\r
+      ParserError (0, "no string identifier previously specified", NULL);\r
+      return STATUS_ERROR;\r
+    }\r
+  }\r
+  //\r
+  // If scope was not specified, use the default setting\r
+  //\r
+  if (Scope != NULL) {\r
+    Scope = DuplicateString (Scope);\r
+  } else {\r
+    Scope = DuplicateString (mDBData.CurrentScope);\r
+  }\r
+  //\r
+  // printf ("Adding string: %S.%S.%S\n", Lang->LanguageName, StringName, Scope);\r
+  //\r
+  // Check for duplicates for this Language.StringName.Scope. Allow multiple\r
+  // definitions of the language name and printable language name, since the\r
+  // user does not specifically define them.\r
+  //\r
+  if (StringDBFindString (Lang->LanguageName, StringName, Scope, NULL, NULL) != NULL) {\r
+    if ((StrCmp (StringName, LANGUAGE_NAME_STRING_NAME) == 0) &&\r
+        (StrCmp (StringName, PRINTABLE_LANGUAGE_NAME_STRING_NAME) == 0)\r
+        ) {\r
+      ParserError (\r
+        0,\r
+        "string multiply defined",\r
+        "Language.Name.Scope = %S.%S.%S",\r
+        Lang->LanguageName,\r
+        StringName,\r
+        Scope\r
+        );\r
+      return STATUS_ERROR;\r
+    }\r
+  }\r
+\r
+  StringIndex = STRING_ID_INVALID;\r
+  if (StringDBAddStringIdentifier (StringName, &StringIndex, Flags) != STATUS_SUCCESS) {\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  StringIdentifier = StringDBFindStringIdentifierByName (StringName);\r
+  //\r
+  // Add this string to the end of the strings for this language.\r
+  //\r
+  Str = (STRING_LIST *) malloc (sizeof (STRING_LIST));\r
+  if (Str == NULL) {\r
+    Error (NULL, 0, 0, NULL, "memory allocation error");\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  memset ((char *) Str, 0, sizeof (STRING_LIST));\r
+  Size              = (StrLen (String) + 1) * sizeof (WCHAR);\r
+  Str->Flags        = Flags;\r
+  Str->Scope        = Scope;\r
+  Str->StringName   = StringIdentifier->StringName;\r
+  Str->LanguageName = DuplicateString (LanguageName);\r
+  Str->Str          = (WCHAR *) MALLOC (Size);\r
+  if (Str->Str == NULL) {\r
+    Error (NULL, 0, 0, NULL, "memory allocation error");\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // If not formatting, just copy the string.\r
+  //\r
+  StrCpy (Str->Str, String);\r
+  if (Format) {\r
+    StringDBFormatString (Str->Str);\r
+  }\r
+  //\r
+  // Size may change after formatting. We set the size to\r
+  // the actual size of the string, including the null for\r
+  // easier processing later.\r
+  //\r
+  Str->Size = (StrLen (Str->Str) + 1) * sizeof (WCHAR);\r
+  if (Lang->String == NULL) {\r
+    Lang->String = Str;\r
+  } else {\r
+    Lang->LastString->Next = Str;\r
+  }\r
+\r
+  Lang->LastString = Str;\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+/*****************************************************************************/\r
+\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Given a language name, see if a language list for it has been defined\r
+\r
+Arguments:\r
+\r
+  LanguageName    - like "eng"\r
+\r
+Returns:\r
+\r
+  A pointer to the language list\r
+\r
+--*/\r
+static\r
+LANGUAGE_LIST *\r
+StringDBFindLanguageList (\r
+  WCHAR *LanguageName\r
+  )\r
+{\r
+  LANGUAGE_LIST *Lang;\r
+\r
+  Lang = mDBData.LanguageList;\r
+  while (Lang != NULL) {\r
+    if (StrCmp (LanguageName, Lang->LanguageName) == 0) {\r
+      break;\r
+    }\r
+\r
+    Lang = Lang->Next;\r
+  }\r
+\r
+  return Lang;\r
+}\r
+\r
+/*****************************************************************************/\r
+STATUS\r
+StringDBSetCurrentLanguage (\r
+  WCHAR *LanguageName\r
+  )\r
+{\r
+  LANGUAGE_LIST *Lang;\r
+\r
+  Lang = StringDBFindLanguageList (LanguageName);\r
+  if (Lang == NULL) {\r
+    ParserError (0, "language not previously defined", "%S", LanguageName);\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  mDBData.CurrentLanguage = Lang;\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+/*****************************************************************************/\r
+STATUS\r
+StringDBAddLanguage (\r
+  WCHAR *LanguageName,\r
+  WCHAR *PrintableLanguageName\r
+  )\r
+{\r
+  LANGUAGE_LIST *Lang;\r
+  //\r
+  // Check for redefinitions\r
+  //\r
+  Lang = StringDBFindLanguageList (LanguageName);\r
+  if (Lang != NULL) {\r
+    //\r
+    // Better be the same printable name\r
+    //\r
+    if (StrCmp (PrintableLanguageName, Lang->PrintableLanguageName) != 0) {\r
+      ParserError (\r
+        0,\r
+        "language redefinition",\r
+        "%S:%S != %S:%S",\r
+        Lang->LanguageName,\r
+        Lang->PrintableLanguageName,\r
+        LanguageName,\r
+        PrintableLanguageName\r
+        );\r
+      return STATUS_ERROR;\r
+      //\r
+      //    } else {\r
+      //      ParserWarning (0, "benign language redefinition", "%S", PrintableLanguageName);\r
+      //      return STATUS_WARNING;\r
+      //\r
+    }\r
+  } else {\r
+    //\r
+    // Allocate memory to keep track of this new language\r
+    //\r
+    Lang = (LANGUAGE_LIST *) malloc (sizeof (LANGUAGE_LIST));\r
+    if (Lang == NULL) {\r
+      Error (NULL, 0, 0, NULL, "memory allocation error");\r
+      return STATUS_ERROR;\r
+    }\r
+\r
+    memset ((char *) Lang, 0, sizeof (LANGUAGE_LIST));\r
+    //\r
+    // Save the language name, then allocate memory to save the\r
+    // printable language name\r
+    //\r
+    StrCpy (Lang->LanguageName, LanguageName);\r
+    Lang->PrintableLanguageName = (WCHAR *) malloc ((StrLen (PrintableLanguageName) + 1) * sizeof (WCHAR));\r
+    if (Lang->PrintableLanguageName == NULL) {\r
+      Error (NULL, 0, 0, NULL, "memory allocation error");\r
+      return STATUS_ERROR;\r
+    }\r
+\r
+    StrCpy (Lang->PrintableLanguageName, PrintableLanguageName);\r
+\r
+    if (mDBData.LanguageList == NULL) {\r
+      mDBData.LanguageList = Lang;\r
+    } else {\r
+      mDBData.LastLanguageList->Next = Lang;\r
+    }\r
+\r
+    mDBData.LastLanguageList = Lang;\r
+  }\r
+  //\r
+  // Default is to make our active language this new one\r
+  //\r
+  StringDBSetCurrentLanguage (LanguageName);\r
+  //\r
+  // The first two strings for any language are the language name,\r
+  // followed by the printable language name. Add them and set them\r
+  // to referenced so they never get stripped out.\r
+  //\r
+  StringDBAddString (\r
+    LanguageName,\r
+    LANGUAGE_NAME_STRING_NAME,\r
+    NULL,\r
+    LanguageName,\r
+    FALSE,\r
+    STRING_FLAGS_REFERENCED\r
+    );\r
+  StringDBAddString (\r
+    LanguageName,\r
+    PRINTABLE_LANGUAGE_NAME_STRING_NAME,\r
+    NULL,\r
+    PrintableLanguageName,\r
+    FALSE,\r
+    STRING_FLAGS_REFERENCED\r
+    );\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+/*****************************************************************************/\r
+static\r
+STRING_IDENTIFIER *\r
+StringDBFindStringIdentifierByName (\r
+  WCHAR *StringName\r
+  )\r
+{\r
+  STRING_IDENTIFIER *Identifier;\r
+\r
+  Identifier = mDBData.StringIdentifier;\r
+  while (Identifier != NULL) {\r
+    if (StrCmp (StringName, Identifier->StringName) == 0) {\r
+      return Identifier;\r
+    }\r
+\r
+    Identifier = Identifier->Next;\r
+  }\r
+\r
+  return NULL;\r
+}\r
+\r
+static\r
+STRING_IDENTIFIER *\r
+StringDBFindStringIdentifierByIndex (\r
+  UINT32    StringIndex\r
+  )\r
+{\r
+  STRING_IDENTIFIER *Identifier;\r
+\r
+  Identifier = mDBData.StringIdentifier;\r
+  while (Identifier != NULL) {\r
+    if (Identifier->Index == StringIndex) {\r
+      return Identifier;\r
+    }\r
+\r
+    Identifier = Identifier->Next;\r
+  }\r
+\r
+  return NULL;\r
+}\r
+\r
+/*****************************************************************************/\r
+static\r
+void\r
+StringDBWriteStandardFileHeader (\r
+  FILE *OutFptr\r
+  )\r
+{\r
+  UINT32  TempIndex;\r
+  for (TempIndex = 0; mSourceFileHeader[TempIndex] != NULL; TempIndex++) {\r
+    fprintf (OutFptr, "%s\n", mSourceFileHeader[TempIndex]);\r
+  }\r
+}\r
+\r
+/*****************************************************************************/\r
+\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  Given a Unicode string from an input file, reformat the string to replace\r
+  backslash control sequences with the appropriate encoding.\r
+\r
+Arguments:\r
+\r
+  String        - pointer to string to reformat\r
+\r
+Returns:\r
+\r
+  Nothing\r
+\r
+--*/\r
+void\r
+StringDBFormatString (\r
+  WCHAR   *String\r
+  )\r
+{\r
+  WCHAR *From;\r
+  WCHAR *To;\r
+  int   HexNibbles;\r
+  WCHAR HexValue;\r
+  //\r
+  // Go through the string and process any formatting characters\r
+  //\r
+  From  = String;\r
+  To    = String;\r
+  while (*From) {\r
+    if (*From == UNICODE_BACKSLASH) {\r
+      //\r
+      // First look for \wide and replace with the appropriate control character. Note that\r
+      // when you have "define STR L"ABC"", then sizeof(ABC) is 8 because the null char is\r
+      // counted. Make adjustments for this. We advance From below, so subtract 2 each time.\r
+      //\r
+      if (StrnCmp (From, UNICODE_WIDE_STRING, sizeof (UNICODE_WIDE_STRING) / sizeof (WCHAR) - 1) == 0) {\r
+        *To = WIDE_CHAR;\r
+        From += sizeof (UNICODE_WIDE_STRING) / sizeof (WCHAR) - 2;\r
+      } else if (StrnCmp (From, UNICODE_NARROW_STRING, sizeof (UNICODE_NARROW_STRING) / sizeof (WCHAR) - 1) == 0) {\r
+        //\r
+        // Found: \narrow\r
+        //\r
+        *To = NARROW_CHAR;\r
+        From += sizeof (UNICODE_NARROW_STRING) / sizeof (WCHAR) - 2;\r
+      } else if (StrnCmp (From, UNICODE_NBR_STRING, sizeof (UNICODE_NBR_STRING) / sizeof (WCHAR) - 1) == 0) {\r
+        //\r
+        // Found: \nbr\r
+        //\r
+        *To = NON_BREAKING_CHAR;\r
+        From += sizeof (UNICODE_NBR_STRING) / sizeof (WCHAR) - 2;\r
+      } else if (StrnCmp (From, UNICODE_BR_STRING, sizeof (UNICODE_BR_STRING) / sizeof (WCHAR) - 1) == 0) {\r
+        //\r
+        // Found: \br -- pass through untouched\r
+        //\r
+        *To = *From;\r
+      } else {\r
+        //\r
+        // Standard one-character control sequences such as \n, \r, \\, or \x\r
+        //\r
+        From++;\r
+        switch (*From) {\r
+        case ASCII_TO_UNICODE ('n'):\r
+          *To = UNICODE_CR;\r
+          To++;\r
+          *To = UNICODE_LF;\r
+          break;\r
+\r
+        //\r
+        // carriage return\r
+        //\r
+        case ASCII_TO_UNICODE ('r'):\r
+          *To = UNICODE_CR;\r
+          break;\r
+\r
+        //\r
+        // backslash\r
+        //\r
+        case UNICODE_BACKSLASH:\r
+          *To = UNICODE_BACKSLASH;\r
+          break;\r
+\r
+        //\r
+        // Tab\r
+        //\r
+        case ASCII_TO_UNICODE ('t'):\r
+          *To = UNICODE_TAB;\r
+          break;\r
+\r
+        //\r
+        // embedded double-quote\r
+        //\r
+        case UNICODE_DOUBLE_QUOTE:\r
+          *To = UNICODE_DOUBLE_QUOTE;\r
+          break;\r
+\r
+        //\r
+        // Hex Unicode character \x1234. We'll process up to 4 hex characters\r
+        //\r
+        case ASCII_TO_UNICODE ('x'):\r
+          HexValue = 0;\r
+          for (HexNibbles = 0; HexNibbles < 4; HexNibbles++) {\r
+            if ((From[1] >= UNICODE_0) && (From[1] <= UNICODE_9)) {\r
+              HexValue = (HexValue << 4) | (From[1] - UNICODE_0);\r
+            } else if ((From[1] >= UNICODE_a) && (From[1] <= UNICODE_f)) {\r
+              HexValue = (HexValue << 4) | (10 + From[1] - UNICODE_a);\r
+            } else if ((From[1] >= UNICODE_A) && (From[1] <= UNICODE_F)) {\r
+              HexValue = (HexValue << 4) | (10 + From[1] - UNICODE_A);\r
+            } else {\r
+              break;\r
+            }\r
+\r
+            From++;\r
+          }\r
+\r
+          if (HexNibbles == 0) {\r
+            ParserWarning (\r
+              0,\r
+              "expected at least one valid hex digit with \\x escaped character in string",\r
+              "\\%C",\r
+              *From\r
+              );\r
+          } else {\r
+            *To = HexValue;\r
+          }\r
+          break;\r
+\r
+        default:\r
+          *To = UNICODE_SPACE;\r
+          ParserWarning (0, "invalid escaped character in string", "\\%C", *From);\r
+          break;\r
+        }\r
+      }\r
+    } else {\r
+      *To = *From;\r
+    }\r
+\r
+    From++;\r
+    To++;\r
+  }\r
+\r
+  *To = 0;\r
+}\r
+\r
+/*****************************************************************************/\r
+STATUS\r
+StringDBReadDatabase (\r
+  CHAR8   *DBFileName,\r
+  BOOLEAN IgnoreIfNotExist,\r
+  BOOLEAN Verbose\r
+  )\r
+{\r
+  STRING_DB_HEADER    DbHeader;\r
+  STATUS              Status;\r
+  FILE                *DBFptr;\r
+  DB_DATA_ITEM_HEADER DataItemHeader;\r
+\r
+  Status  = STATUS_SUCCESS;\r
+  DBFptr  = NULL;\r
+  //\r
+  //  if (Verbose) {\r
+  //    fprintf (stdout, "Reading database file %s\n", DBFileName);\r
+  //  }\r
+  //\r
+  // Try to open the input file\r
+  //\r
+  if ((DBFptr = fopen (DBFileName, "rb")) == NULL) {\r
+    if (IgnoreIfNotExist) {\r
+      return STATUS_SUCCESS;\r
+    }\r
+\r
+    Error (NULL, 0, 0, DBFileName, "failed to open input database file for reading");\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Read and verify the database header\r
+  //\r
+  if (fread ((void *) &DbHeader, sizeof (STRING_DB_HEADER), 1, DBFptr) != 1) {\r
+    Error (NULL, 0, 0, DBFileName, "failed to read header from database file");\r
+    Status = STATUS_ERROR;\r
+    goto Finish;\r
+  }\r
+\r
+  if (DbHeader.Key != STRING_DB_KEY) {\r
+    Error (NULL, 0, 0, DBFileName, "invalid header in database file");\r
+    Status = STATUS_ERROR;\r
+    goto Finish;\r
+  }\r
+\r
+  if ((DbHeader.Version & STRING_DB_MAJOR_VERSION_MASK) != (STRING_DB_VERSION & STRING_DB_MAJOR_VERSION_MASK)) {\r
+    Error (NULL, 0, 0, DBFileName, "incompatible database file version -- rebuild clean");\r
+    Status = STATUS_ERROR;\r
+    goto Finish;\r
+  }\r
+  //\r
+  // Read remaining items\r
+  //\r
+  while (fread (&DataItemHeader, sizeof (DataItemHeader), 1, DBFptr) == 1) {\r
+    switch (DataItemHeader.DataType) {\r
+    case DB_DATA_TYPE_STRING_IDENTIFIER:\r
+      StringDBReadStringIdentifier (DBFptr);\r
+      break;\r
+\r
+    case DB_DATA_TYPE_LANGUAGE_DEFINITION:\r
+      StringDBReadLanguageDefinition (DBFptr);\r
+      break;\r
+\r
+    case DB_DATA_TYPE_STRING_DEFINITION:\r
+      StringDBReadString (DBFptr);\r
+      break;\r
+\r
+    default:\r
+      Error (\r
+        NULL,\r
+        0,\r
+        0,\r
+        "database corrupted",\r
+        "invalid data item type 0x%X at offset 0x%X",\r
+        (UINT32) DataItemHeader.DataType,\r
+        ftell (DBFptr) - sizeof (DataItemHeader)\r
+        );\r
+      Status = STATUS_ERROR;\r
+      goto Finish;\r
+    }\r
+  }\r
+\r
+Finish:\r
+  if (DBFptr != NULL) {\r
+    fclose (DBFptr);\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
+/*****************************************************************************/\r
+\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  Write everything we know to the output database file. Write:\r
+\r
+  Database header\r
+  String identifiers[]\r
+  StringPacks[]\r
+\r
+Arguments:\r
+\r
+  DBFileName    - name of the file to write to\r
+  Verbose       - for debug purposes, print info messages along the way.\r
+\r
+Returns:\r
+\r
+  STATUS\r
+\r
+--*/\r
+STATUS\r
+StringDBWriteDatabase (\r
+  CHAR8   *DBFileName,\r
+  BOOLEAN Verbose\r
+  )\r
+{\r
+  STRING_DB_HEADER  DbHeader;\r
+  UINT32            Counter;\r
+  UINT32            StrLength;\r
+  LANGUAGE_LIST     *Lang;\r
+  STRING_IDENTIFIER *StringIdentifier;\r
+  STRING_LIST       *StrList;\r
+  FILE              *DBFptr;\r
+\r
+  if (Verbose) {\r
+    fprintf (stdout, "Writing database %s\n", DBFileName);\r
+  }\r
+\r
+  if ((DBFptr = fopen (DBFileName, "wb")) == NULL) {\r
+    Error (NULL, 0, 0, DBFileName, "failed to open output database file for writing");\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Fill in and write the database header\r
+  //\r
+  memset (&DbHeader, 0, sizeof (STRING_DB_HEADER));\r
+  DbHeader.HeaderSize = sizeof (STRING_DB_HEADER);\r
+  DbHeader.Key        = STRING_DB_KEY;\r
+  DbHeader.Version    = STRING_DB_VERSION;\r
+  //\r
+  // Count the number of languages we have\r
+  //\r
+  for (Lang = mDBData.LanguageList; Lang != NULL; Lang = Lang->Next) {\r
+    DbHeader.NumLanguages++;\r
+  }\r
+  //\r
+  // Count up how many string identifiers we have, and total up the\r
+  // size of the names plus the size of the flags field we will\r
+  // write out too.\r
+  //\r
+  DbHeader.NumStringIdenfiers = mDBData.NumStringIdentifiers;\r
+  StringIdentifier            = mDBData.StringIdentifier;\r
+  for (Counter = 0; Counter < mDBData.NumStringIdentifiers; Counter++) {\r
+    StrLength = StrLen (StringIdentifier->StringName) + 1;\r
+    DbHeader.StringIdentifiersSize += StrLength * sizeof (WCHAR) + sizeof (StringIdentifier->Flags);\r
+    StringIdentifier = StringIdentifier->Next;\r
+  }\r
+\r
+  //\r
+  // Write the header\r
+  //\r
+  fwrite (&DbHeader, sizeof (STRING_DB_HEADER), 1, DBFptr);\r
+  if (Verbose) {\r
+    fprintf (stdout, "  Number of string identifiers  0x%04X\n", DbHeader.NumStringIdenfiers);\r
+    fprintf (stdout, "  Number of languages           %d\n", DbHeader.NumLanguages);\r
+  }\r
+  //\r
+  // Write the string identifiers\r
+  //\r
+  for (StringIdentifier = mDBData.StringIdentifier; StringIdentifier != NULL; StringIdentifier = StringIdentifier->Next) {\r
+    StringDBWriteStringIdentifier (\r
+      DBFptr,\r
+      (UINT16) StringIdentifier->Index,\r
+      StringIdentifier->Flags,\r
+      StringIdentifier->StringName\r
+      );\r
+  }\r
+  //\r
+  // Now write all the strings for each language\r
+  //\r
+  for (Lang = mDBData.LanguageList; Lang != NULL; Lang = Lang->Next) {\r
+    StringDBWriteLanguageDefinition (DBFptr, Lang->LanguageName, Lang->PrintableLanguageName);\r
+    for (StrList = Lang->String; StrList != NULL; StrList = StrList->Next) {\r
+      StringDBWriteString (\r
+        DBFptr,\r
+        StrList->Flags,\r
+        Lang->LanguageName,\r
+        StrList->StringName,\r
+        StrList->Scope,\r
+        StrList->Str\r
+        );\r
+    }\r
+  }\r
+\r
+  fclose (DBFptr);\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+STATUS\r
+StringDBSetStringReferenced (\r
+  CHAR8     *StringIdentifierName,\r
+  BOOLEAN   IgnoreNotFound\r
+  )\r
+{\r
+  STRING_IDENTIFIER *Id;\r
+  WCHAR             *WName;\r
+  STATUS            Status;\r
+  //\r
+  // See if it's already been defined.\r
+  //\r
+  Status  = STATUS_SUCCESS;\r
+  WName   = (WCHAR *) malloc ((strlen (StringIdentifierName) + 1) * sizeof (WCHAR));\r
+  UnicodeSPrint (WName, (strlen (StringIdentifierName) + 1) * sizeof (WCHAR), L"%a", StringIdentifierName);\r
+  Id = StringDBFindStringIdentifierByName (WName);\r
+  if (Id != NULL) {\r
+    Id->Flags |= STRING_FLAGS_REFERENCED;\r
+  } else {\r
+    if (IgnoreNotFound == 0) {\r
+      ParserWarning (0, StringIdentifierName, "string identifier not found in database");\r
+      Status = STATUS_WARNING;\r
+    }\r
+  }\r
+\r
+  free (WName);\r
+  return Status;\r
+}\r
+\r
+/*****************************************************************************/\r
+\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Dump the contents of a database to an output unicode file.\r
+\r
+Arguments:\r
+\r
+  DBFileName        - name of the pre-existing database file to read\r
+  OutputFileName    - name of the file to dump the database contents to\r
+  Verbose           - for printing of additional info useful for debugging\r
+\r
+Returns:\r
+\r
+  STATUS\r
+\r
+Notes:\r
+\r
+  There's some issue with the unicode printing routines. Therefore to \r
+  write to the output file properly, open it as binary and use fwrite.\r
+  Ideally we could open it with just L"w" and use fwprintf().\r
+\r
+--*/\r
+STATUS\r
+StringDBDumpDatabase (\r
+  CHAR8               *DBFileName,\r
+  CHAR8               *OutputFileName,\r
+  BOOLEAN             Verbose\r
+  )\r
+{\r
+  LANGUAGE_LIST     *Lang;\r
+  STRING_IDENTIFIER *StringIdentifier;\r
+  STRING_LIST       *StrList;\r
+  FILE              *OutFptr;\r
+  WCHAR             WChar;\r
+  WCHAR             CrLf[2];\r
+  WCHAR             Line[200];\r
+  WCHAR             *Scope;\r
+  //\r
+  // This function assumes the database has already been read, and\r
+  // we're just dumping our internal data structures to a unicode file.\r
+  //\r
+  if (Verbose) {\r
+    fprintf (stdout, "Dumping database file %s\n", DBFileName);\r
+  }\r
+\r
+  OutFptr         = fopen (OutputFileName, "wb");\r
+  if (OutFptr == NULL) {\r
+    Error (NULL, 0, 0, OutputFileName, "failed to open output file for writing");\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  WChar = UNICODE_FILE_START;\r
+  fwrite (&WChar, sizeof (WCHAR), 1, OutFptr);\r
+  CrLf[1] = UNICODE_LF;\r
+  CrLf[0] = UNICODE_CR;\r
+  //\r
+  // The default control character is '/'. Make it '#' by writing\r
+  // "/=#" to the output file.\r
+  //\r
+  UnicodeSPrint (Line, sizeof(Line), L"/=#");\r
+  fwrite (Line, StrLen (Line) * sizeof (WCHAR), 1, OutFptr);\r
+  fwrite (&CrLf, sizeof (CrLf), 1, OutFptr);\r
+  fwrite (&CrLf, sizeof (CrLf), 1, OutFptr);\r
+  //\r
+  // Dump all the string identifiers and their values\r
+  //\r
+  StringDBAssignStringIndexes ();\r
+  for (StringIdentifier = mDBData.StringIdentifier; StringIdentifier != NULL; StringIdentifier = StringIdentifier->Next) {\r
+    //\r
+    // Write the "#define " string\r
+    //\r
+    if (StringIdentifier->Flags & STRING_FLAGS_REFERENCED) {\r
+      UnicodeSPrint (\r
+        Line,\r
+        sizeof(Line), L"%s %-60.60s 0x%04X",\r
+        DEFINE_STR,\r
+        StringIdentifier->StringName,\r
+        StringIdentifier->Index\r
+        );\r
+    } else {\r
+      UnicodeSPrint (\r
+        Line,\r
+        sizeof(Line), L"%s %-60.60s 0x%04X  // NOT REFERENCED",\r
+        DEFINE_STR,\r
+        StringIdentifier->StringName,\r
+        StringIdentifier->Index\r
+        );\r
+    }\r
+\r
+    fwrite (Line, StrLen (Line) * sizeof (WCHAR), 1, OutFptr);\r
+    fwrite (&CrLf, sizeof (CrLf), 1, OutFptr);\r
+  }\r
+\r
+  fwrite (&CrLf, sizeof (CrLf), 1, OutFptr);\r
+  //\r
+  // Now write all the strings for each language.\r
+  //\r
+  WChar = UNICODE_DOUBLE_QUOTE;\r
+  Scope = NULL;\r
+  for (Lang = mDBData.LanguageList; Lang != NULL; Lang = Lang->Next) {\r
+    fwrite (&CrLf, sizeof (CrLf), 1, OutFptr);\r
+    UnicodeSPrint (Line, sizeof(Line), L"#langdef %s \"%s\"", Lang->LanguageName, Lang->PrintableLanguageName);\r
+    fwrite (Line, StrLen (Line) * sizeof (WCHAR), 1, OutFptr);\r
+    fwrite (&CrLf, sizeof (CrLf), 1, OutFptr);\r
+    fwrite (&CrLf, sizeof (CrLf), 1, OutFptr);\r
+    //\r
+    // Now the strings (in double-quotes) for this language. Write\r
+    // #string STR_NAME  #language eng "string"\r
+    //\r
+    for (StrList = Lang->String; StrList != NULL; StrList = StrList->Next) {\r
+      //\r
+      // Print the internal flags for debug\r
+      //\r
+      UnicodeSPrint (Line, sizeof(Line), L"// flags=0x%02X", (UINT32) StrList->Flags);\r
+      fwrite (Line, StrLen (Line) * sizeof (WCHAR), 1, OutFptr);\r
+      fwrite (&CrLf, sizeof (CrLf), 1, OutFptr);\r
+      //\r
+      // Print the scope if changed\r
+      //\r
+      if ((Scope == NULL) || (StrCmp (Scope, StrList->Scope) != 0)) {\r
+        UnicodeSPrint (Line, sizeof(Line), L"#scope %s", StrList->Scope);\r
+        fwrite (Line, StrLen (Line) * sizeof (WCHAR), 1, OutFptr);\r
+        fwrite (&CrLf, sizeof (CrLf), 1, OutFptr);\r
+        Scope = StrList->Scope;\r
+      }\r
+\r
+      UnicodeSPrint (\r
+        Line,\r
+        sizeof(Line), L"#string %-50.50s #language %s \"",\r
+        StrList->StringName,\r
+        Lang->LanguageName\r
+        );\r
+      fwrite (Line, StrLen (Line) * sizeof (WCHAR), 1, OutFptr);\r
+      fwrite (StrList->Str, StrList->Size - sizeof (WCHAR), 1, OutFptr);\r
+      UnicodeSPrint (Line, sizeof(Line), L"\"");\r
+      fwrite (Line, StrLen (Line) * sizeof (WCHAR), 1, OutFptr);\r
+      fwrite (&CrLf, sizeof (CrLf), 1, OutFptr);\r
+    }\r
+  }\r
+\r
+  fclose (OutFptr);\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+/*****************************************************************************/\r
+\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Given a primary language, a string identifier number, and a list of\r
+  languages, find a secondary string.\r
+\r
+Arguments:\r
+\r
+  LanguageName      - primary language, like "spa"\r
+  StringId          - string index value\r
+  LanguageList      - linked list of "eng", "spa+cat",...\r
+\r
+Returns:\r
+\r
+  Pointer to a secondary string if found. NULL otherwise.\r
+\r
+Notes:\r
\r
+  Given: LanguageName "spa"   and  LanguageList "spa+cat", match the\r
+  "spa" and extract the "cat" and see if there is a string defined\r
+  for "cat".StringId.\r
+\r
+--*/\r
+static\r
+STATUS\r
+StringDBWriteStringIdentifier (\r
+  FILE                *DBFptr,\r
+  UINT16              StringId,\r
+  UINT16              Flags,\r
+  WCHAR               *IdentifierName\r
+  )\r
+{\r
+  DB_DATA_ITEM_HEADER Hdr;\r
+  memset (&Hdr, 0, sizeof (DB_DATA_ITEM_HEADER));\r
+  Hdr.DataType = DB_DATA_TYPE_STRING_IDENTIFIER;\r
+  if (fwrite (&Hdr, sizeof (DB_DATA_ITEM_HEADER), 1, DBFptr) != 1) {\r
+    Error (NULL, 0, 0, "failed to write string to output database file", NULL);\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  if (fwrite (&StringId, sizeof (StringId), 1, DBFptr) != 1) {\r
+    Error (NULL, 0, 0, "failed to write StringId to output database", NULL);\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  if (fwrite (&Flags, sizeof (Flags), 1, DBFptr) != 1) {\r
+    Error (NULL, 0, 0, "failed to write StringId flags to output database", NULL);\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  if (StringDBWriteGenericString (DBFptr, IdentifierName) != STATUS_SUCCESS) {\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+STATUS\r
+StringDBReadStringIdentifier (\r
+  FILE                *DBFptr\r
+  )\r
+{\r
+  WCHAR   *IdentifierName;\r
+  UINT16  Flags;\r
+  UINT16  StringId;\r
+  UINT16  Size;\r
+\r
+  if (fread (&StringId, sizeof (StringId), 1, DBFptr) != 1) {\r
+    Error (NULL, 0, 0, "failed to read StringId from database", NULL);\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  if (fread (&Flags, sizeof (Flags), 1, DBFptr) != 1) {\r
+    Error (NULL, 0, 0, "failed to read StringId flags from database", NULL);\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  if (StringDBReadGenericString (DBFptr, &Size, &IdentifierName) != STATUS_SUCCESS) {\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  StringDBAddStringIdentifier (IdentifierName, &StringId, Flags);\r
+  //\r
+  // printf ("STRID:  0x%04X %S\n", (UINT32)StringId, IdentifierName);\r
+  //\r
+  FREE (IdentifierName);\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+STATUS\r
+StringDBWriteString (\r
+  FILE            *DBFptr,\r
+  UINT16          Flags,\r
+  WCHAR           *Language,\r
+  WCHAR           *StringName,\r
+  WCHAR           *Scope,\r
+  WCHAR           *Str\r
+  )\r
+{\r
+  DB_DATA_ITEM_HEADER Hdr;\r
+  memset (&Hdr, 0, sizeof (DB_DATA_ITEM_HEADER));\r
+  Hdr.DataType = DB_DATA_TYPE_STRING_DEFINITION;\r
+  if (fwrite (&Hdr, sizeof (DB_DATA_ITEM_HEADER), 1, DBFptr) != 1) {\r
+    Error (NULL, 0, 0, "failed to write string header to output database file", NULL);\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  if (fwrite (&Flags, sizeof (Flags), 1, DBFptr) != 1) {\r
+    Error (NULL, 0, 0, "failed to write string flags to output database", NULL);\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  if (StringDBWriteGenericString (DBFptr, Language) != STATUS_SUCCESS) {\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  if (StringDBWriteGenericString (DBFptr, StringName) != STATUS_SUCCESS) {\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  if (StringDBWriteGenericString (DBFptr, Scope) != STATUS_SUCCESS) {\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  if (StringDBWriteGenericString (DBFptr, Str) != STATUS_SUCCESS) {\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // printf ("DBWriteString: %S.%S.%S\n", Language, StringName, Scope);\r
+  //\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+STATUS\r
+StringDBReadString (\r
+  FILE            *DBFptr\r
+  )\r
+{\r
+  UINT16  Flags;\r
+  UINT16  Size;\r
+  WCHAR   *Language;\r
+  WCHAR   *StringName;\r
+  WCHAR   *Scope;\r
+  WCHAR   *Str;\r
+\r
+  if (fread (&Flags, sizeof (Flags), 1, DBFptr) != 1) {\r
+    Error (NULL, 0, 0, "failed to read string flags from database", NULL);\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  if (StringDBReadGenericString (DBFptr, &Size, &Language) != STATUS_SUCCESS) {\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  if (StringDBReadGenericString (DBFptr, &Size, &StringName) != STATUS_SUCCESS) {\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  if (StringDBReadGenericString (DBFptr, &Size, &Scope) != STATUS_SUCCESS) {\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  if (StringDBReadGenericString (DBFptr, &Size, &Str) != STATUS_SUCCESS) {\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // If the first or second string (language name and printable language name),\r
+  // then skip them. They're added via language definitions data items in\r
+  // the database.\r
+  //\r
+  if (StringName[0] != L'$') {\r
+    StringDBAddString (Language, StringName, Scope, Str, FALSE, Flags);\r
+  }\r
+  //\r
+  // printf ("DBReadString: %S.%S.%S\n", Language, StringName, Scope);\r
+  //\r
+  FREE (Language);\r
+  FREE (StringName);\r
+  if (Str != NULL) {\r
+    FREE (Str);\r
+  }\r
+\r
+  if (Scope != NULL) {\r
+    FREE (Scope);\r
+  }\r
+\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+STATUS\r
+StringDBWriteLanguageDefinition (\r
+  FILE            *DBFptr,\r
+  WCHAR           *LanguageName,\r
+  WCHAR           *PrintableLanguageName\r
+  )\r
+{\r
+  DB_DATA_ITEM_HEADER Hdr;\r
+  memset (&Hdr, 0, sizeof (DB_DATA_ITEM_HEADER));\r
+  Hdr.DataType = DB_DATA_TYPE_LANGUAGE_DEFINITION;\r
+  if (fwrite (&Hdr, sizeof (DB_DATA_ITEM_HEADER), 1, DBFptr) != 1) {\r
+    Error (NULL, 0, 0, "failed to write string to output database file", NULL);\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  if (StringDBWriteGenericString (DBFptr, LanguageName) != STATUS_SUCCESS) {\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  if (StringDBWriteGenericString (DBFptr, PrintableLanguageName) != STATUS_SUCCESS) {\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+STATUS\r
+StringDBReadLanguageDefinition (\r
+  FILE            *DBFptr\r
+  )\r
+{\r
+  WCHAR   *LanguageName;\r
+  WCHAR   *PrintableLanguageName;\r
+  UINT16  Size;\r
+  STATUS  Status;\r
+\r
+  if (StringDBReadGenericString (DBFptr, &Size, &LanguageName) != STATUS_SUCCESS) {\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  if (StringDBReadGenericString (DBFptr, &Size, &PrintableLanguageName) != STATUS_SUCCESS) {\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // printf("LANG: %S %S\n", LanguageName, PrintableLanguageName);\r
+  //\r
+  Status = StringDBAddLanguage (LanguageName, PrintableLanguageName);\r
+  FREE (LanguageName);\r
+  FREE (PrintableLanguageName);\r
+  return Status;\r
+}\r
+//\r
+// All unicode strings in the database consist of a UINT16 length\r
+// field, followed by the string itself. This routine reads one\r
+// of those and returns the info.\r
+//\r
+static\r
+STATUS\r
+StringDBReadGenericString (\r
+  FILE      *DBFptr,\r
+  UINT16    *Size,\r
+  WCHAR     **Str\r
+  )\r
+{\r
+  UINT16  LSize;\r
+  UINT16  Flags;\r
+  WCHAR   *LStr;\r
+\r
+  if (fread (&LSize, sizeof (UINT16), 1, DBFptr) != 1) {\r
+    Error (NULL, 0, 0, "failed to read a string length field from the database", NULL);\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  if (fread (&Flags, sizeof (UINT16), 1, DBFptr) != 1) {\r
+    Error (NULL, 0, 0, "failed to read a string flags field from the database", NULL);\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  LStr = MALLOC (LSize);\r
+  if (LStr == NULL) {\r
+    Error (__FILE__, __LINE__, 0, "memory allocation failed reading the database", NULL);\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  if (fread (LStr, sizeof (WCHAR), (UINT32) LSize / sizeof (WCHAR), DBFptr) != (UINT32) LSize / sizeof (WCHAR)) {\r
+    Error (NULL, 0, 0, "failed to read string from database", NULL);\r
+    Error (NULL, 0, 0, "database read failure", "offset 0x%X", ftell (DBFptr));\r
+    free (LStr);\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // printf ("DBR: %S\n", LStr);\r
+  //\r
+  // If the flags field indicated we were asked to write a NULL string, then\r
+  // return them a NULL pointer.\r
+  //\r
+  if (Flags & STRING_FLAGS_UNDEFINED) {\r
+    *Size = 0;\r
+    *Str  = NULL;\r
+  } else {\r
+    *Size = LSize;\r
+    *Str  = LStr;\r
+  }\r
+\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+STATUS\r
+StringDBWriteGenericString (\r
+  FILE      *DBFptr,\r
+  WCHAR     *Str\r
+  )\r
+{\r
+  UINT16  Size;\r
+  UINT16  Flags;\r
+  WCHAR   ZeroString[1];\r
+  //\r
+  // Strings in the database consist of a size UINT16 followed\r
+  // by the string itself.\r
+  //\r
+  if (Str == NULL) {\r
+    ZeroString[0] = 0;\r
+    Str           = ZeroString;\r
+    Size          = sizeof (ZeroString);\r
+    Flags         = STRING_FLAGS_UNDEFINED;\r
+  } else {\r
+    Flags = 0;\r
+    Size  = (UINT16) ((StrLen (Str) + 1) * sizeof (WCHAR));\r
+  }\r
+\r
+  if (fwrite (&Size, sizeof (UINT16), 1, DBFptr) != 1) {\r
+    Error (NULL, 0, 0, "failed to write string size to database", NULL);\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  if (fwrite (&Flags, sizeof (UINT16), 1, DBFptr) != 1) {\r
+    Error (NULL, 0, 0, "failed to write string flags to database", NULL);\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  if (fwrite (Str, sizeof (WCHAR), Size / sizeof (WCHAR), DBFptr) != Size / sizeof (WCHAR)) {\r
+    Error (NULL, 0, 0, "failed to write string to database", NULL);\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+STRING_LIST *\r
+StringDBFindString (\r
+  WCHAR                       *LanguageName,\r
+  WCHAR                       *StringName,\r
+  WCHAR                       *Scope,\r
+  WCHAR_STRING_LIST           *LanguagesOfInterest,\r
+  WCHAR_MATCHING_STRING_LIST  *IndirectionList\r
+  )\r
+{\r
+  LANGUAGE_LIST               *Lang;\r
+  STRING_LIST                 *CurrString;\r
+  WCHAR_MATCHING_STRING_LIST  *IndListPtr;\r
+  WCHAR                       TempLangName[LANGUAGE_IDENTIFIER_NAME_LEN + 1];\r
+  WCHAR                       *WCharPtr;\r
+\r
+  //\r
+  // If we were given an indirection list, then see if one was specified for this\r
+  // string identifier. That is to say, if the indirection says "STR_ID_MY_FAVORITE MyScope",\r
+  // then if this string name matches one in the list, then do a lookup with the\r
+  // specified scope and return that value.\r
+  //\r
+  if (IndirectionList != NULL) {\r
+    for (IndListPtr = IndirectionList; IndListPtr != NULL; IndListPtr = IndListPtr->Next) {\r
+      if (StrCmp (StringName, IndListPtr->Str1) == 0) {\r
+        CurrString = StringDBFindString (LanguageName, StringName, IndListPtr->Str2, LanguagesOfInterest, NULL);\r
+        if (CurrString != NULL) {\r
+          return CurrString;\r
+        }\r
+      }\r
+    }\r
+  }\r
+  //\r
+  // First look for exact match language.stringname\r
+  //\r
+  for (Lang = mDBData.LanguageList; Lang != NULL; Lang = Lang->Next) {\r
+    if (StrCmp (LanguageName, Lang->LanguageName) == 0) {\r
+      //\r
+      // Found language match. Try to find string name match\r
+      //\r
+      for (CurrString = Lang->String; CurrString != NULL; CurrString = CurrString->Next) {\r
+        if (StrCmp (StringName, CurrString->StringName) == 0) {\r
+          //\r
+          // Found a string name match. See if we're supposed to find\r
+          // a scope match.\r
+          //\r
+          if (Scope != NULL) {\r
+            if (StrCmp (CurrString->Scope, Scope) == 0) {\r
+              return CurrString;\r
+            }\r
+          } else {\r
+            return CurrString;\r
+          }\r
+        }\r
+      }\r
+    }\r
+  }\r
+  //\r
+  // If we got here, then we didn't find a match. Look for secondary string\r
+  // matches. That is to say, if we're processing "spa", and they requested\r
+  // "spa+cat", then recursively call with "cat"\r
+  //\r
+  while (LanguagesOfInterest != NULL) {\r
+    //\r
+    // If this is the language we're looking for, then process the\r
+    // languages of interest list for it.\r
+    //\r
+    if (StrnCmp (LanguageName, LanguagesOfInterest->Str, LANGUAGE_IDENTIFIER_NAME_LEN) == 0) {\r
+      WCharPtr = LanguagesOfInterest->Str + LANGUAGE_IDENTIFIER_NAME_LEN;\r
+      while (*WCharPtr) {\r
+        //\r
+        // Double-check the length, though it should have been checked on the\r
+        // command line.\r
+        //\r
+        if (StrLen (WCharPtr) < LANGUAGE_IDENTIFIER_NAME_LEN) {\r
+          Error (NULL, 0, 0, "malformed alternate language list", "%S", LanguagesOfInterest->Str);\r
+          return NULL;\r
+        }\r
+\r
+        StrnCpy (TempLangName, WCharPtr, LANGUAGE_IDENTIFIER_NAME_LEN);\r
+        TempLangName[LANGUAGE_IDENTIFIER_NAME_LEN]  = 0;\r
+        CurrString = StringDBFindString (TempLangName, StringName, NULL, NULL, IndirectionList);\r
+        if (CurrString != NULL) {\r
+          return CurrString;\r
+        }\r
+\r
+        WCharPtr += LANGUAGE_IDENTIFIER_NAME_LEN;\r
+      }\r
+    }\r
+\r
+    LanguagesOfInterest = LanguagesOfInterest->Next;\r
+  }\r
+\r
+  return NULL;\r
+}\r
+\r
+STATUS\r
+StringDBSetScope (\r
+  WCHAR   *Scope\r
+  )\r
+{\r
+  //\r
+  // Free up existing scope memory.\r
+  //\r
+  if (mDBData.CurrentScope != NULL) {\r
+    FREE (mDBData.CurrentScope);\r
+  }\r
+\r
+  mDBData.CurrentScope = DuplicateString (Scope);\r
+  return STATUS_SUCCESS;\r
+}\r
+//\r
+// We typically don't assign index values to string identifiers\r
+// until we're ready to write out files. To reduce the size of\r
+// the output file, re-order the string identifiers to move any\r
+// unreferenced ones to the end. Then we'll walk the list\r
+// again to assign string indexes, keeping track of the last\r
+// one referenced.\r
+//\r
+static\r
+void\r
+StringDBAssignStringIndexes (\r
+  VOID\r
+  )\r
+{\r
+  STRING_IDENTIFIER *StrId;\r
+  STRING_IDENTIFIER *FirstUsed;\r
+  STRING_IDENTIFIER *LastUsed;\r
+  STRING_IDENTIFIER *FirstUnused;\r
+  STRING_IDENTIFIER *LastUnused;\r
+  UINT32            Index;\r
+  UINT32            MaxReferenced;\r
+\r
+  //\r
+  // Create two lists -- used and unused. Then put them together with\r
+  // the unused ones on the end.\r
+  //\r
+  FirstUsed   = NULL;\r
+  LastUsed    = NULL;\r
+  FirstUnused = NULL;\r
+  LastUnused  = NULL;\r
+  StrId       = mDBData.StringIdentifier;\r
+  while (StrId != NULL) {\r
+    if ((StrId->Flags & STRING_FLAGS_REFERENCED) == 0) {\r
+      //\r
+      // Put it on the unused list\r
+      //\r
+      if (FirstUnused == NULL) {\r
+        FirstUnused = StrId;\r
+      } else {\r
+        LastUnused->Next = StrId;\r
+      }\r
+\r
+      LastUnused        = StrId;\r
+      StrId             = StrId->Next;\r
+      LastUnused->Next  = NULL;\r
+    } else {\r
+      //\r
+      // Put it on the used list\r
+      //\r
+      if (FirstUsed == NULL) {\r
+        FirstUsed = StrId;\r
+      } else {\r
+        LastUsed->Next = StrId;\r
+      }\r
+\r
+      LastUsed        = StrId;\r
+      StrId           = StrId->Next;\r
+      LastUsed->Next  = NULL;\r
+    }\r
+  }\r
+  //\r
+  // Join the lists\r
+  //\r
+  if (FirstUsed != NULL) {\r
+    mDBData.StringIdentifier  = FirstUsed;\r
+    LastUsed->Next            = FirstUnused;\r
+  } else {\r
+    mDBData.StringIdentifier = FirstUnused;\r
+  }\r
+\r
+  MaxReferenced = 0;\r
+  Index         = 0;\r
+  for (StrId = mDBData.StringIdentifier; StrId != NULL; StrId = StrId->Next) {\r
+    StrId->Index = Index;\r
+    Index++;\r
+    if (StrId->Flags & STRING_FLAGS_REFERENCED) {\r
+      mDBData.NumStringIdentifiersReferenced = Index;\r
+    }\r
+  }\r
+\r
+  mDBData.NumStringIdentifiers = Index;\r
+}\r
+\r
+static\r
+WCHAR *\r
+DuplicateString (\r
+  WCHAR   *Str\r
+  )\r
+{\r
+  WCHAR *NewStr;\r
+  if (Str == NULL) {\r
+    return NULL;\r
+  }\r
+\r
+  NewStr = MALLOC ((StrLen (Str) + 1) * sizeof (WCHAR));\r
+  if (NewStr == NULL) {\r
+    Error (NULL, 0, 0, "memory allocation failure", NULL);\r
+    return NULL;\r
+  }\r
+\r
+  StrCpy (NewStr, Str);\r
+  return NewStr;\r
+}\r
+\r
+static\r
+WCHAR *\r
+AsciiToWchar (\r
+  CHAR8 *Str\r
+  )\r
+{\r
+  UINT32  Len;\r
+  WCHAR   *NewStr;\r
+  WCHAR   *Ptr;\r
+\r
+  Len     = strlen (Str) + 1;\r
+  NewStr  = (WCHAR *) malloc (Len * sizeof (WCHAR));\r
+  for (Ptr = NewStr; *Str != 0; Str++, Ptr++) {\r
+    *Ptr = (UINT16) (UINT8) *Str;\r
+  }\r
+\r
+  *Ptr = 0;\r
+  return NewStr;\r
+}\r
+\r
+/*****************************************************************************/\r
+\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Create an HII export string pack for the strings in our database.\r
+\r
+Arguments:\r
+\r
+  FileName        - name of the output file to write \r
+\r
+Returns:\r
+\r
+  STATUS\r
+\r
+\r
+--*/\r
+STATUS\r
+StringDBCreateHiiExportPack (\r
+  CHAR8                       *FileName\r
+  )\r
+{\r
+  FILE                        *Fptr;\r
+  LANGUAGE_LIST               *Lang;\r
+  STRING_LIST                 *CurrString;\r
+  STRING_LIST                 EmptyString;\r
+  UINT32                      Offset;\r
+  UINT32                      StringIndex;\r
+  UINT32                      TempIndex;\r
+  EFI_HII_STRING_PACK         StringPack;\r
+  UINT32                      Len;\r
+  WCHAR                       ZeroString[1];\r
+  WCHAR                       *TempStringPtr;\r
+  WCHAR                       *LangName;\r
+  STRING_IDENTIFIER           *StringIdentifier;\r
+\r
+  if ((Fptr = fopen (FileName, "wb")) == NULL) {\r
+    Error (NULL, 0, 0, FileName, "failed to open output HII export file");\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Assign index values to the string identifiers\r
+  //\r
+  StringDBAssignStringIndexes ();\r
+  //\r
+  // If a given string is not defined, then we'll use this one.\r
+  //\r
+  memset (&EmptyString, 0, sizeof (EmptyString));\r
+  EmptyString.Size  = sizeof (ZeroString);\r
+  EmptyString.Str   = ZeroString;\r
+  //\r
+  // Process each language, then each string for each langage\r
+  //\r
+  ZeroString[0] = 0;\r
+  for (Lang = mDBData.LanguageList; Lang != NULL; Lang = Lang->Next) {\r
+    //\r
+    // Process each string for this language. We have to make 3 passes on the strings:\r
+    //   Pass1: computes sizes and fill in the string pack header\r
+    //   Pass2: write the array of offsets\r
+    //   Pass3: write the strings\r
+    //\r
+    //\r
+    // PASS 1: Fill in and print the HII string pack header\r
+    //\r
+    // Compute the size for this language package and write\r
+    // the header out. Each string package contains:\r
+    //   Header\r
+    //   Offset[]  -- an array of offsets to strings, of type RELOFST each\r
+    //   String[]  -- the actual strings themselves\r
+    //\r
+    memset ((char *) &StringPack, 0, sizeof (EFI_HII_STRING_PACK));\r
+    StringPack.Header.Type        = EFI_HII_STRING;\r
+    StringPack.NumStringPointers  = (UINT16) mDBData.NumStringIdentifiersReferenced;\r
+    LangName                      = Lang->LanguageName;\r
+    //\r
+    // First string is the language name. If we're printing all languages, then\r
+    // it's just the "spa". If we were given a list of languages to print, then it's\r
+    // the "spacat" string. Compute its offset and fill in\r
+    // the info in the header. Since we know the language name string's length,\r
+    // and the printable language name follows it, use that info to fill in the\r
+    // entry for the printable language name as well.\r
+    //\r
+    StringPack.LanguageNameString = (STRING_OFFSET) (sizeof (EFI_HII_STRING_PACK) + (mDBData.NumStringIdentifiersReferenced * sizeof (STRING_OFFSET)));\r
+    StringPack.PrintableLanguageName = (STRING_OFFSET) (StringPack.LanguageNameString + (StrLen (LangName) + 1) * sizeof (WCHAR));\r
+    //\r
+    // Add up the size of all strings so we can fill in our header.\r
+    //\r
+    Len = 0;\r
+    for (StringIndex = 0; StringIndex < mDBData.NumStringIdentifiersReferenced; StringIndex++) {\r
+      //\r
+      // For the first string (language name), we print out the "spacat" if they\r
+      // requested it. We set LangName to point to the proper language name string above.\r
+      //\r
+      if (StringIndex == STRING_ID_LANGUAGE_NAME) {\r
+        Len += (StrLen (LangName) + 1) * sizeof (WCHAR);\r
+      } else {\r
+        //\r
+        // Find a string with this language.stringname\r
+        //\r
+        StringIdentifier = StringDBFindStringIdentifierByIndex (StringIndex);\r
+        if (StringIdentifier == NULL) {\r
+          Error (NULL, 0, 0, "internal error", "invalid string index 0x%X", StringIndex);\r
+          return STATUS_ERROR;\r
+        }\r
+        //\r
+        // Find a matching string if this string identifier was referenced\r
+        //\r
+        EmptyString.Flags = STRING_FLAGS_UNDEFINED;\r
+        CurrString        = NULL;\r
+        if (StringIdentifier->Flags & STRING_FLAGS_REFERENCED) {\r
+          CurrString = StringDBFindString (\r
+                        Lang->LanguageName,\r
+                        StringIdentifier->StringName,\r
+                        NULL,\r
+                        NULL, // LanguagesOfInterest,\r
+                        NULL\r
+                        );\r
+          //\r
+          // IndirectionList);\r
+          //\r
+          if (NULL == CurrString) {\r
+            //\r
+            // If string for Lang->LanguageName is not found, try to get an English version\r
+            //\r
+            CurrString = StringDBFindString (\r
+                          L"eng",\r
+                          StringIdentifier->StringName,\r
+                          NULL,\r
+                          NULL, // LanguagesOfInterest,\r
+                          NULL\r
+                          );\r
+            //\r
+            // IndirectionList);\r
+            //\r
+          }\r
+        }\r
+\r
+        if (CurrString == NULL) {\r
+          CurrString = &EmptyString;\r
+          EmptyString.Flags |= StringIdentifier->Flags;\r
+        }\r
+\r
+        Len += CurrString->Size;\r
+      }\r
+    }\r
+    StringPack.Header.Length =    sizeof (EFI_HII_STRING_PACK) \r
+                                + mDBData.NumStringIdentifiersReferenced * sizeof (STRING_OFFSET) \r
+                                + Len;\r
+    //\r
+    // Write out the string pack header\r
+    //\r
+    fwrite ((void *) &StringPack, sizeof (StringPack), 1, Fptr);\r
+    //\r
+    // PASS2 : write the offsets\r
+    //\r
+    // Traverse the list of strings again and write the array of offsets. The\r
+    // offset to the first string is the size of the string pack header\r
+    // plus the size of the offsets array. The other strings follow it.\r
+    //\r
+    StringIndex = 0;\r
+    Offset      = sizeof (StringPack) + mDBData.NumStringIdentifiersReferenced * sizeof (STRING_OFFSET);\r
+    for (StringIndex = 0; StringIndex < mDBData.NumStringIdentifiersReferenced; StringIndex++) {\r
+      //\r
+      // Write the offset\r
+      //\r
+      fwrite (&Offset, sizeof (STRING_OFFSET), 1, Fptr);\r
+      //\r
+      // Find the string name\r
+      //\r
+      StringIdentifier = StringDBFindStringIdentifierByIndex (StringIndex);\r
+      if (StringIdentifier == NULL) {\r
+        Error (NULL, 0, 0, "internal error", "invalid string index 0x%X", StringIndex);\r
+        return STATUS_ERROR;\r
+      }\r
+      //\r
+      // For the first string (language name), we print out the "spacat" if they\r
+      // requested it. We set LangName to point to the proper language name string above.\r
+      //\r
+      if (StringIndex == STRING_ID_LANGUAGE_NAME) {\r
+        Offset += (StrLen (LangName) + 1) * sizeof (WCHAR);\r
+        CurrString = StringDBFindString (\r
+                      Lang->LanguageName,\r
+                      StringIdentifier->StringName,\r
+                      NULL, // scope\r
+                      NULL,\r
+                      NULL\r
+                      );\r
+      } else {\r
+        //\r
+        // Find a matching string\r
+        //\r
+        CurrString = StringDBFindString (\r
+                      Lang->LanguageName,\r
+                      StringIdentifier->StringName,\r
+                      NULL, // scope\r
+                      NULL, // LanguagesOfInterest,\r
+                      NULL\r
+                      );\r
+        //\r
+        // IndirectionList);\r
+        //\r
+        if (NULL == CurrString) {\r
+          CurrString = StringDBFindString (\r
+                        L"eng",\r
+                        StringIdentifier->StringName,\r
+                        NULL, // scope\r
+                        NULL, // LanguagesOfInterest,\r
+                        NULL\r
+                        );\r
+          //\r
+          // IndirectionList);\r
+          //\r
+        }\r
+\r
+        EmptyString.LanguageName = Lang->LanguageName;\r
+        if (CurrString == NULL) {\r
+          CurrString        = &EmptyString;\r
+          EmptyString.Flags = STRING_FLAGS_UNDEFINED;\r
+        } else if ((StringIdentifier->Flags & STRING_FLAGS_REFERENCED) == 0) {\r
+          CurrString        = &EmptyString;\r
+          EmptyString.Flags = 0;\r
+        }\r
+\r
+        Offset += CurrString->Size;\r
+      }\r
+    }\r
+\r
+    //\r
+    // PASS 3: write the strings themselves.\r
+    //\r
+    Offset = sizeof (StringPack) + mDBData.NumStringIdentifiersReferenced * sizeof (STRING_OFFSET);\r
+    for (StringIndex = 0; StringIndex < mDBData.NumStringIdentifiersReferenced; StringIndex++) {\r
+      StringIdentifier = StringDBFindStringIdentifierByIndex (StringIndex);\r
+      if (StringIdentifier == NULL) {\r
+        Error (NULL, 0, 0, "internal error", "invalid string index 0x%X", StringIndex);\r
+        return STATUS_ERROR;\r
+      }\r
+      //\r
+      // For the first string (language name), we print out the "spacat" if they\r
+      // requested it. We set LangName to point to the proper language name string above.\r
+      //\r
+      if (StringIndex == STRING_ID_LANGUAGE_NAME) {\r
+        TempStringPtr = LangName;\r
+      } else {\r
+        //\r
+        // Find a matching string if this string identifier was referenced\r
+        //\r
+        CurrString = NULL;\r
+        if (StringIdentifier->Flags & STRING_FLAGS_REFERENCED) {\r
+          CurrString = StringDBFindString (\r
+                        Lang->LanguageName,\r
+                        StringIdentifier->StringName,\r
+                        NULL, // scope\r
+                        NULL, // LanguagesOfInterest,\r
+                        NULL\r
+                        );\r
+          //\r
+          // IndirectionList);\r
+          //\r
+          if (NULL == CurrString) {\r
+            CurrString = StringDBFindString (\r
+                          L"eng",\r
+                          StringIdentifier->StringName,\r
+                          NULL, // scope\r
+                          NULL, // LanguagesOfInterest,\r
+                          NULL\r
+                          );\r
+            //\r
+            // IndirectionList);\r
+            //\r
+          }\r
+        }\r
+\r
+        if (CurrString == NULL) {\r
+          CurrString = &EmptyString;\r
+        }\r
+\r
+        TempStringPtr = CurrString->Str;\r
+      }\r
+\r
+      for (TempIndex = 0; TempStringPtr[TempIndex] != 0; TempIndex++) {\r
+        fwrite (&TempStringPtr[TempIndex], sizeof (CHAR16), 1, Fptr);\r
+        Offset += 2;\r
+      }\r
+      //\r
+      // Print NULL WCHAR at the end of this string.\r
+      //\r
+      TempIndex = 0;\r
+      fwrite (&TempIndex, sizeof (CHAR16), 1, Fptr);\r
+      Offset += 2;\r
+    }\r
+    //\r
+    // Sanity check the offset. Make sure our running offset is what we put in the\r
+    // string pack header.\r
+    //\r
+    if (StringPack.Header.Length != Offset) {\r
+      Error (\r
+        __FILE__,\r
+        __LINE__,\r
+        0,\r
+        "application error",\r
+        "stringpack size 0x%X does not match final size 0x%X",\r
+        StringPack.Header.Length,\r
+        Offset\r
+        );\r
+    }\r
+  }\r
+  //\r
+  // Print terminator string pack, closing brace and close the file.\r
+  // The size of 0 triggers to the consumer that this is the end.\r
+  //\r
+  memset ((char *) &StringPack, 0, sizeof (EFI_HII_STRING_PACK));\r
+  StringPack.Header.Type = EFI_HII_STRING;\r
+  fwrite ((void *) &StringPack, sizeof (StringPack), 1, Fptr);\r
+  fclose (Fptr);\r
+  return STATUS_SUCCESS;\r
+}\r
diff --git a/Tools/CodeTools/Source/StrGather/StringDB.h b/Tools/CodeTools/Source/StrGather/StringDB.h
new file mode 100644 (file)
index 0000000..c525731
--- /dev/null
@@ -0,0 +1,136 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  StringDB.h\r
+\r
+Abstract:\r
+\r
+  Common defines and prototypes for string database management\r
+  \r
+--*/\r
+\r
+#ifndef _STRING_DB_H_\r
+#define _STRING_DB_H_\r
+\r
+#define LANGUAGE_NAME_STRING_NAME           L"$LANGUAGE_NAME"\r
+#define PRINTABLE_LANGUAGE_NAME_STRING_NAME L"$PRINTABLE_LANGUAGE_NAME"\r
+\r
+void\r
+StringDBConstructor (\r
+  void\r
+  )\r
+;\r
+void\r
+StringDBDestructor (\r
+  void\r
+  )\r
+;\r
+\r
+STATUS\r
+StringDBAddString (\r
+  WCHAR   *LanguageName,\r
+  WCHAR   *StringIdentifier,\r
+  WCHAR   *Scope,\r
+  WCHAR   *String,\r
+  BOOLEAN Format,\r
+  UINT16  Flags\r
+  )\r
+;\r
+\r
+STATUS\r
+StringDBSetScope (\r
+  WCHAR   *Scope\r
+  )\r
+;\r
+\r
+#define STRING_FLAGS_REFERENCED           0x0001  // if referenced somewhere\r
+#define STRING_FLAGS_UNDEFINED            0x0002  // if we added it for padding purposes\r
+#define STRING_FLAGS_INDEX_ASSIGNED       0x0004  // so don't change the index value\r
+#define STRING_ID_INVALID                 0xFFFF\r
+#define STRING_ID_LANGUAGE_NAME           0x0000\r
+#define STRING_ID_PRINTABLE_LANGUAGE_NAME 0x0001\r
+\r
+STATUS\r
+StringDBAddStringIdentifier (\r
+  WCHAR     *StringIdentifier,\r
+  UINT16    *NewId,\r
+  UINT16    Flags\r
+  )\r
+;\r
+\r
+STATUS\r
+StringDBReadDatabase (\r
+  CHAR8   *DBFileName,\r
+  BOOLEAN IgnoreIfNotExist,\r
+  BOOLEAN Verbose\r
+  )\r
+;\r
+\r
+STATUS\r
+StringDBWriteDatabase (\r
+  CHAR8   *DBFileName,\r
+  BOOLEAN Verbose\r
+  )\r
+;\r
+\r
+STATUS\r
+StringDBDumpDatabase (\r
+  CHAR8               *DBFileName,\r
+  CHAR8               *OutputFileName,\r
+  BOOLEAN             Verbose\r
+  )\r
+;\r
+\r
+STATUS\r
+StringDBAddLanguage (\r
+  WCHAR *LanguageName,\r
+  WCHAR *PrintableLanguageName\r
+  )\r
+;\r
+\r
+STATUS\r
+StringDBDumpCStrings (\r
+  CHAR8                       *FileName,\r
+  CHAR8                       *BaseName,\r
+  WCHAR_STRING_LIST           *LanguagesOfInterest,\r
+  WCHAR_MATCHING_STRING_LIST  *IndirectionList\r
+  )\r
+;\r
+\r
+STATUS\r
+StringDBDumpStringDefines (\r
+  CHAR8               *FileName,\r
+  CHAR8               *BaseName\r
+  )\r
+;\r
+\r
+STATUS\r
+StringDBSetCurrentLanguage (\r
+  WCHAR *LanguageName\r
+  )\r
+;\r
+\r
+STATUS\r
+StringDBSetStringReferenced (\r
+  CHAR8     *StringIdentifierName,\r
+  BOOLEAN   IgnoreNotFound\r
+  )\r
+;\r
+\r
+void\r
+StringDBFormatString (\r
+  WCHAR   *String\r
+  )\r
+;\r
+\r
+#endif // #ifndef _STRING_DB_H_\r
diff --git a/Tools/CodeTools/Source/StrGather/build.xml b/Tools/CodeTools/Source/StrGather/build.xml
new file mode 100644 (file)
index 0000000..f011177
--- /dev/null
@@ -0,0 +1,72 @@
+<?xml version="1.0" ?>\r
+<!--\r
+Copyright (c) 2006, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+-->\r
+<project default="GenTool" basedir=".">\r
+<!--\r
+    EDK StrGather Tool\r
+  Copyright (c) 2006, Intel Corporation\r
+-->\r
+  <property name="ToolName" value="StrGather"/>\r
+  <property name="FileSet" value="*.c *.h"/>\r
+\r
+  <taskdef resource="cpptasks.tasks"/>\r
+  <typedef resource="cpptasks.types"/>\r
+  <taskdef resource="net/sf/antcontrib/antlib.xml"/>\r
+\r
+  <property name="LINK_OUTPUT_TYPE" value="static"/>\r
+  <property name="BUILD_DIR" value="${PACKAGE_DIR}/${ToolName}/tmp"/>\r
+\r
+  <target name="GenTool" depends="init, Tool">\r
+    <echo message="The EDK Tool: ${ToolName} build has completed!"/>\r
+  </target>\r
+\r
+  <target name="init">\r
+    <echo message="Building the EDK Tool: ${ToolName}"/>\r
+    <mkdir dir="${BUILD_DIR}"/>\r
+  </target>\r
+\r
+  <target name="Tool" depends="init">\r
+    <cc name="${ToolChain}" objdir="${BUILD_DIR}" \r
+        outfile="${BIN_DIR}/${ToolName}"\r
+        outtype="executable"\r
+        optimize="speed" \r
+        debug="true">\r
+\r
+      <compilerarg value="-fshort-wchar" if="gcc"/>\r
+\r
+      <fileset dir="${basedir}/${ToolName}" \r
+        includes="${FileSet}" \r
+        defaultexcludes="TRUE" \r
+        excludes="*.xml *.inf"/>\r
+\r
+      <includepath path="${PACKAGE_DIR}/Include"/>\r
+      <includepath path="${PACKAGE_DIR}/Include/${HostArch}"/>\r
+      <includepath path="${PACKAGE_DIR}/Common"/>\r
+      <libset dir="${LIB_DIR}" libs="CommonTools String"/>\r
+    </cc>\r
+  </target>\r
+\r
+  <target name="clean">\r
+    <echo message="Removing Intermediate Files Only"/>  \r
+    <delete>\r
+      <fileset dir="${BUILD_DIR}" includes="*.obj"/>\r
+    </delete>\r
+  </target>\r
+\r
+  <target name="cleanall">\r
+    <echo message="Removing Object Files and the Executable: ${ToolName}${ext_exe}"/>  \r
+    <delete failonerror="false" quiet="true" includeEmptyDirs="true">\r
+      <fileset dir="${BUILD_DIR}"/>\r
+      <fileset file="${BIN_DIR}/${ToolName}${ext_exe}"/>\r
+    </delete>\r
+  </target>\r
+\r
+</project>\r
diff --git a/Tools/CodeTools/Source/String/PrintLib.c b/Tools/CodeTools/Source/String/PrintLib.c
new file mode 100644 (file)
index 0000000..eef3f4d
--- /dev/null
@@ -0,0 +1,674 @@
+/*++\r
+\r
+Copyright (c)  2004-2006 Intel Corporation. All rights reserved\r
+This program and the accompanying materials are licensed and made available\r
+under the terms and conditions of the BSD License which accompanies this\r
+distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+\r
+Module Name:\r
+\r
+  PrintLib.c\r
+\r
+Abstract:\r
+\r
+  Print Library.\r
+\r
+--*/\r
+\r
+#include <Common/UefiBaseTypes.h>\r
+#include <Library/PrintLib.h>\r
+\r
+#include "CommonLib.h"\r
+#include "PrintLibInternal.h"\r
+\r
+typedef struct {\r
+  RETURN_STATUS  Status;\r
+  CHAR8          *String;\r
+} STATUS_LOOKUP_TABLE_ENTRY;\r
+\r
+static CONST STATUS_LOOKUP_TABLE_ENTRY  StatusString[] = {\r
+  { RETURN_SUCCESS,               "Success" },\r
+  { RETURN_LOAD_ERROR,            "Load Error" },\r
+  { RETURN_INVALID_PARAMETER,     "Invalid Parameter" },\r
+  { RETURN_UNSUPPORTED,           "Unsupported" },\r
+  { RETURN_BAD_BUFFER_SIZE,       "Bad Buffer Size" },\r
+  { RETURN_BUFFER_TOO_SMALL,      "Buffer Too Small" },\r
+  { RETURN_NOT_READY,             "Not Ready" },\r
+  { RETURN_DEVICE_ERROR,          "Device Error" },\r
+  { RETURN_WRITE_PROTECTED,       "Write Protected" },\r
+  { RETURN_OUT_OF_RESOURCES,      "Out of Resources" },\r
+  { RETURN_VOLUME_CORRUPTED,      "Volume Corrupt" },\r
+  { RETURN_VOLUME_FULL,           "Volume Full" },\r
+  { RETURN_NO_MEDIA,              "No Media" },\r
+  { RETURN_MEDIA_CHANGED,         "Media changed" },\r
+  { RETURN_NOT_FOUND,             "Not Found" },\r
+  { RETURN_ACCESS_DENIED,         "Access Denied" },\r
+  { RETURN_NO_RESPONSE,           "No Response" },\r
+  { RETURN_NO_MAPPING,            "No mapping" },\r
+  { RETURN_TIMEOUT,               "Time out" },\r
+  { RETURN_NOT_STARTED,           "Not started" },\r
+  { RETURN_ALREADY_STARTED,       "Already started" },\r
+  { RETURN_ABORTED,               "Aborted" },\r
+  { RETURN_ICMP_ERROR,            "ICMP Error" },\r
+  { RETURN_TFTP_ERROR,            "TFTP Error" },\r
+  { RETURN_PROTOCOL_ERROR,        "Protocol Error" },\r
+  { RETURN_WARN_UNKNOWN_GLYPH,    "Warning Unknown Glyph" },\r
+  { RETURN_WARN_DELETE_FAILURE,   "Warning Delete Failure" },\r
+  { RETURN_WARN_WRITE_FAILURE,    "Warning Write Failure" },\r
+  { RETURN_WARN_BUFFER_TOO_SMALL, "Warning Buffer Too Small" },\r
+  { 0,                              NULL                     }\r
+};\r
+\r
+\r
+/**\r
+  VSPrint function to process format and place the results in Buffer. Since a\r
+  VA_LIST is used this rountine allows the nesting of Vararg routines. Thus\r
+  this is the main print working routine\r
+\r
+  @param  StartOfBuffer Unicode buffer to print the results of the parsing of Format into.\r
+\r
+  @param  BufferSize Maximum number of characters to put into buffer. Zero means\r
+  no limit.\r
+\r
+  @param  Flags Intial flags value.  Can only have FORMAT_UNICODE and OUTPUT_UNICODE set\r
+\r
+  @param  FormatString Unicode format string see file header for more details.\r
+\r
+  @param  Marker Vararg list consumed by processing Format.\r
+\r
+  @return Number of characters printed.\r
+\r
+**/\r
+UINTN\r
+BasePrintLibVSPrint (\r
+  OUT CHAR8        *Buffer,\r
+  IN  UINTN        BufferSize,\r
+  IN  UINTN        Flags,\r
+  IN  CONST CHAR8  *Format,\r
+  IN  VA_LIST      Marker\r
+  )\r
+{\r
+  CHAR8           *OriginalBuffer;\r
+  CHAR8           ValueBuffer[MAXIMUM_VALUE_CHARACTERS];\r
+  UINTN           BytesPerOutputCharacter;\r
+  UINTN           BytesPerFormatCharacter;\r
+  UINTN           FormatMask;\r
+  UINTN           FormatCharacter;\r
+  UINTN           Width;\r
+  UINTN           Precision;\r
+  INT64           Value;\r
+  CHAR8           *ArgumentString;\r
+  UINTN           Character;\r
+  GUID            *TmpGuid;\r
+  TIME            *TmpTime;\r
+  UINTN           Count;\r
+  UINTN           ArgumentMask;\r
+  INTN            BytesPerArgumentCharacter;\r
+  UINTN           ArgumentCharacter;\r
+  BOOLEAN         Done;\r
+  UINTN           Index;\r
+  CHAR8           Prefix;\r
+  BOOLEAN         ZeroPad;\r
+  BOOLEAN         Comma;\r
+  UINTN           Digits;\r
+  UINTN           Radix;\r
+  RETURN_STATUS   Status;\r
+\r
+  OriginalBuffer = Buffer;\r
+\r
+  if ((Flags & OUTPUT_UNICODE) != 0) {\r
+    BytesPerOutputCharacter = 2;\r
+  } else {\r
+    BytesPerOutputCharacter = 1;\r
+  }\r
+  if ((Flags & FORMAT_UNICODE) != 0) {\r
+    BytesPerFormatCharacter = 2;\r
+    FormatMask = 0xffff;\r
+  } else {\r
+    BytesPerFormatCharacter = 1;\r
+    FormatMask = 0xff;\r
+  }\r
+\r
+  //\r
+  // Reserve space for the Null terminator.\r
+  // If BufferSize is 0, this will set BufferSize to the max unsigned value\r
+  //\r
+  BufferSize--;\r
+\r
+  //\r
+  // Get the first character from the format string\r
+  //\r
+  FormatCharacter = (*Format | (*(Format + 1) << 8)) & FormatMask;\r
+\r
+  //\r
+  // Loop until the end of the format string is reached or the output buffer is full\r
+  //\r
+  while (FormatCharacter != 0 && BufferSize > 0) {\r
+    //\r
+    // Clear all the flag bits except those that may have been passed in\r
+    //\r
+    Flags &= (OUTPUT_UNICODE | FORMAT_UNICODE);\r
+\r
+    //\r
+    // Set the default width to zero, and the default precision to 1\r
+    //\r
+    Width     = 0;\r
+    Precision = 1;\r
+    Prefix    = 0;\r
+    Comma     = FALSE;\r
+    ZeroPad   = FALSE;\r
+    Count     = 0;\r
+    Digits    = 0;\r
+\r
+    switch (FormatCharacter) {\r
+    case '%':\r
+      //\r
+      // Parse Flags and Width\r
+      //\r
+      for (Done = FALSE; !Done; ) {\r
+        Format += BytesPerFormatCharacter;\r
+        FormatCharacter = (*Format | (*(Format + 1) << 8)) & FormatMask;\r
+        switch (FormatCharacter) {\r
+        case '.':\r
+          Flags |= PRECISION;\r
+          break;\r
+        case '-':\r
+          Flags |= LEFT_JUSTIFY;\r
+          break;\r
+        case '+':\r
+          Flags |= PREFIX_SIGN;\r
+          break;\r
+        case ' ':\r
+          Flags |= PREFIX_BLANK;\r
+          break;\r
+        case ',':\r
+          Flags |= COMMA_TYPE;\r
+          break;\r
+        case 'L':\r
+        case 'l':\r
+          Flags |= LONG_TYPE;\r
+          break;\r
+        case '*':\r
+          if ((Flags & PRECISION) == 0) {\r
+            Flags |= PAD_TO_WIDTH;\r
+            Width = VA_ARG (Marker, UINTN);\r
+          } else {\r
+            Precision = VA_ARG (Marker, UINTN);\r
+          }\r
+          break;\r
+        case '0':\r
+          if ((Flags & PRECISION) == 0) {\r
+            Flags |= PREFIX_ZERO;\r
+          }\r
+        case '1':\r
+        case '2':\r
+        case '3':\r
+        case '4':\r
+        case '5':\r
+        case '6':\r
+        case '7':\r
+        case '8':\r
+        case '9':\r
+          for (Count = 0; ((FormatCharacter >= '0') &&  (FormatCharacter <= '9')); ){\r
+            Count = (Count * 10) + FormatCharacter - '0';\r
+            Format += BytesPerFormatCharacter;\r
+            FormatCharacter = (*Format | (*(Format + 1) << 8)) & FormatMask;\r
+          }\r
+          Format -= BytesPerFormatCharacter;\r
+          if ((Flags & PRECISION) == 0) {\r
+            Flags |= PAD_TO_WIDTH;\r
+            Width = Count;\r
+          } else {\r
+            Precision = Count;\r
+          }\r
+          break;\r
+        default:\r
+          Done = TRUE;\r
+          break;\r
+        }\r
+      }\r
+\r
+      //\r
+      // Limit the maximum field width to the remaining characters in the output buffer\r
+      //\r
+      if (Width > BufferSize) {\r
+        Width = BufferSize;\r
+      }\r
+\r
+      //\r
+      // Handle each argument type\r
+      //\r
+      switch (FormatCharacter) {\r
+      case 'X':\r
+        Flags |= PREFIX_ZERO;\r
+        //\r
+        // break skiped on purpose\r
+        //\r
+      case 'x':\r
+        Flags |= RADIX_HEX;\r
+        //\r
+        // break skiped on purpose\r
+        //\r
+      case 'd':\r
+        if ((Flags & LONG_TYPE) == 0) {\r
+          Value = (VA_ARG (Marker, INTN));\r
+        } else {\r
+          Value = VA_ARG (Marker, INT64);\r
+        }\r
+        if ((Flags & PREFIX_BLANK) != 0) {\r
+          Prefix = ' ';\r
+        }\r
+        if ((Flags & PREFIX_SIGN) != 0) {\r
+          Prefix = '+';\r
+        }\r
+        if ((Flags & COMMA_TYPE) != 0) {\r
+          Comma = TRUE;\r
+        }\r
+        if ((Flags & RADIX_HEX) == 0) {\r
+          Radix = 10;\r
+          if (Comma) {\r
+            Flags &= (~PREFIX_ZERO);\r
+            Precision = 1;\r
+          }\r
+          if (Value < 0) {\r
+            Flags |= PREFIX_SIGN;\r
+            Prefix = '-';\r
+            Value = -Value;\r
+          }\r
+        } else {\r
+          Radix = 16;\r
+          Comma = FALSE;\r
+          if ((Flags & LONG_TYPE) == 0 && Value < 0) {\r
+            Value = (UINTN)Value;\r
+          }\r
+        }\r
+        //\r
+        // Convert Value to a reversed string\r
+        //\r
+        Count = BasePrintLibValueToString (ValueBuffer, Value, Radix);\r
+        if (Value == 0 && Precision == 0) {\r
+          Count = 0;\r
+        }\r
+        ArgumentString = (CHAR8 *)ValueBuffer + Count;\r
+        Digits = 3 - (Count % 3);\r
+        if (Comma && Count != 0) {\r
+          Count += ((Count - 1) / 3);\r
+        }\r
+        if (Prefix != 0) {\r
+          Count++;\r
+        }\r
+        Flags |= ARGUMENT_REVERSED;\r
+        ZeroPad = TRUE;\r
+        if ((Flags & PREFIX_ZERO) != 0) {\r
+          if ((Flags & PAD_TO_WIDTH) != 0) {\r
+            if ((Flags & PRECISION) == 0) {\r
+              Precision = Width;\r
+            }\r
+          }\r
+        }\r
+        break;\r
+\r
+      case 's':\r
+      case 'S':\r
+        Flags |= ARGUMENT_UNICODE;\r
+        //\r
+        // break skipped on purpose\r
+        //\r
+      case 'a':\r
+        ArgumentString = (CHAR8 *)VA_ARG (Marker, CHAR8 *);\r
+        if (ArgumentString == NULL) {\r
+          Flags &= (~ARGUMENT_UNICODE);\r
+          ArgumentString = "<null string>";\r
+        }\r
+        break;\r
+\r
+      case 'c':\r
+        Character = VA_ARG (Marker, UINTN) & 0xffff;\r
+        ArgumentString = (CHAR8 *)&Character;\r
+        Flags |= ARGUMENT_UNICODE;\r
+        break;\r
+\r
+      case 'g':\r
+        TmpGuid = VA_ARG (Marker, GUID *);\r
+        if (TmpGuid == NULL) {\r
+          ArgumentString = "<null guid>";\r
+        } else {\r
+          BasePrintLibSPrint (\r
+            ValueBuffer,\r
+            0,\r
+            0,\r
+            "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",\r
+            TmpGuid->Data1,\r
+            TmpGuid->Data2,\r
+            TmpGuid->Data3,\r
+            TmpGuid->Data4[0],\r
+            TmpGuid->Data4[1],\r
+            TmpGuid->Data4[2],\r
+            TmpGuid->Data4[3],\r
+            TmpGuid->Data4[4],\r
+            TmpGuid->Data4[5],\r
+            TmpGuid->Data4[6],\r
+            TmpGuid->Data4[7]\r
+            );\r
+          ArgumentString = ValueBuffer;\r
+        }\r
+        break;\r
+\r
+      case 't':\r
+        TmpTime = VA_ARG (Marker, TIME *);\r
+        if (TmpTime == NULL) {\r
+          ArgumentString = "<null time>";\r
+        } else {\r
+          BasePrintLibSPrint (\r
+            ValueBuffer,\r
+            0,\r
+            0,\r
+            "%02d/%02d/%04d  %02d:%02d",\r
+            TmpTime->Month,\r
+            TmpTime->Day,\r
+            TmpTime->Year,\r
+            TmpTime->Hour,\r
+            TmpTime->Minute\r
+            );\r
+          ArgumentString = ValueBuffer;\r
+        }\r
+        break;\r
+\r
+      case 'r':\r
+        Status = VA_ARG (Marker, RETURN_STATUS);\r
+        ArgumentString = ValueBuffer;\r
+        for (Index = 0; StatusString[Index].String != NULL; Index++) {\r
+          if (Status == StatusString[Index].Status) {\r
+            ArgumentString = StatusString[Index].String;\r
+          }\r
+        }\r
+        if (ArgumentString == ValueBuffer) {\r
+          BasePrintLibSPrint ((CHAR8 *) ValueBuffer, 0, 0, "%08X", Status);\r
+        }\r
+        break;\r
+\r
+      case '%':\r
+      default:\r
+        //\r
+        // if the type is '%' or unknown, then print it to the screen\r
+        //\r
+        ArgumentString = (CHAR8 *)&FormatCharacter;\r
+        Flags |= ARGUMENT_UNICODE;\r
+        break;\r
+      }\r
+      break;\r
+    case '\n':\r
+      ArgumentString = "\n";\r
+         \r
+      break;\r
+    default:\r
+      ArgumentString = (CHAR8 *)&FormatCharacter;\r
+      Flags |= ARGUMENT_UNICODE;\r
+      break;\r
+    }\r
+\r
+    //\r
+    // Retrieve the ArgumentString attriubutes\r
+    //\r
+    if ((Flags & ARGUMENT_UNICODE) != 0) {\r
+      ArgumentMask = 0xffff;\r
+      BytesPerArgumentCharacter = 2;\r
+    } else {\r
+      ArgumentMask = 0xff;\r
+      BytesPerArgumentCharacter = 1;\r
+    }\r
+    if ((Flags & ARGUMENT_REVERSED) != 0) {\r
+      BytesPerArgumentCharacter = -BytesPerArgumentCharacter;\r
+    } else {\r
+      //\r
+      // Compute the number of characters in ArgumentString and store it in Count\r
+      // ArgumentString is either null-terminated, or it contains Precision characters\r
+      //\r
+      for (Count = 0; Count < Precision || ((Flags & PRECISION) == 0); Count++) {\r
+        ArgumentCharacter = ((ArgumentString[Count * BytesPerArgumentCharacter] & 0xff) | ((ArgumentString[Count * BytesPerArgumentCharacter + 1]) << 8)) & ArgumentMask;\r
+        if (ArgumentCharacter == 0) {\r
+          break;\r
+        }\r
+      }\r
+    }\r
+\r
+    //\r
+    // Limit the length of the string to append to the remaining characters in the output buffer\r
+    //\r
+    if (Count > BufferSize) {\r
+      Count = BufferSize;\r
+    }\r
+    if (Precision < Count) {\r
+      Precision = Count;\r
+    }\r
+\r
+    //\r
+    // Pad before the string\r
+    //\r
+    if ((Flags & (PAD_TO_WIDTH | LEFT_JUSTIFY)) == (PAD_TO_WIDTH)) {\r
+      Buffer = BasePrintLibFillBuffer (Buffer, Width - Precision, ' ', BytesPerOutputCharacter);\r
+    }\r
+\r
+    if (ZeroPad) {\r
+      if (Prefix != 0) {\r
+        Buffer = BasePrintLibFillBuffer (Buffer, 1, Prefix, BytesPerOutputCharacter);\r
+      }\r
+      Buffer = BasePrintLibFillBuffer (Buffer, Precision - Count, '0', BytesPerOutputCharacter);\r
+    } else {\r
+      Buffer = BasePrintLibFillBuffer (Buffer, Precision - Count, ' ', BytesPerOutputCharacter);\r
+      if (Prefix != 0) {\r
+        Buffer = BasePrintLibFillBuffer (Buffer, 1, Prefix, BytesPerOutputCharacter);\r
+      }\r
+    }\r
+\r
+    //\r
+    // Output the Prefix character if it is present\r
+    //\r
+    Index = 0;\r
+    if (Prefix) {\r
+      Index++;\r
+    }\r
+\r
+    //\r
+    // Copy the string into the output buffer performing the required type conversions\r
+    //\r
+    while (Index < Count) {\r
+      ArgumentCharacter = ((*ArgumentString & 0xff) | (*(ArgumentString + 1) << 8)) & ArgumentMask;\r
+\r
+      Buffer = BasePrintLibFillBuffer (Buffer, 1, ArgumentCharacter, BytesPerOutputCharacter);\r
+      ArgumentString    += BytesPerArgumentCharacter;\r
+      Index++;\r
+      if (Comma) {\r
+        Digits++;\r
+        if (Digits == 3) {\r
+          Digits = 0;\r
+          Index++;\r
+          if (Index < Count) {\r
+            Buffer = BasePrintLibFillBuffer (Buffer, 1, ',', BytesPerOutputCharacter);\r
+          }\r
+        }\r
+      }\r
+    }\r
+\r
+    //\r
+    // Pad after the string\r
+    //\r
+    if ((Flags & (PAD_TO_WIDTH | LEFT_JUSTIFY)) == (PAD_TO_WIDTH | LEFT_JUSTIFY)) {\r
+      Buffer = BasePrintLibFillBuffer (Buffer, Width - Precision, ' ', BytesPerOutputCharacter);\r
+    }\r
+\r
+    //\r
+    // Reduce the number of characters\r
+    //\r
+    BufferSize -= Count;\r
+\r
+    //\r
+    // Get the next character from the format string\r
+    //\r
+    Format += BytesPerFormatCharacter;\r
+\r
+    //\r
+    // Get the next character from the format string\r
+    //\r
+    FormatCharacter = (*Format | (*(Format + 1) << 8)) & FormatMask;\r
+  }\r
+\r
+  //\r
+  // Null terminate the Unicode or ASCII string\r
+  //\r
+  Buffer = BasePrintLibFillBuffer (Buffer, 1, 0, BytesPerOutputCharacter);\r
+\r
+  return ((Buffer - OriginalBuffer) / BytesPerOutputCharacter);\r
+}\r
+\r
+UINTN\r
+BasePrintLibSPrint (\r
+  OUT CHAR8        *StartOfBuffer,\r
+  IN  UINTN        BufferSize,\r
+  IN  UINTN        Flags,\r
+  IN  CONST CHAR8  *FormatString,\r
+  ...\r
+  )\r
+{\r
+  VA_LIST  Marker;\r
+\r
+  VA_START (Marker, FormatString);\r
+  return BasePrintLibVSPrint (StartOfBuffer, BufferSize, Flags, FormatString, Marker);\r
+}\r
+\r
+UINTN\r
+EFIAPI\r
+UnicodeVSPrint (\r
+  OUT CHAR16        *StartOfBuffer,\r
+  IN  UINTN         BufferSize,\r
+  IN  CONST CHAR16  *FormatString,\r
+  IN  VA_LIST       Marker\r
+  )\r
+{\r
+  return BasePrintLibVSPrint ((CHAR8 *)StartOfBuffer, BufferSize >> 1, FORMAT_UNICODE | OUTPUT_UNICODE, (CHAR8 *)FormatString, Marker);\r
+}\r
+\r
+UINTN\r
+EFIAPI\r
+UnicodeSPrint (\r
+  OUT CHAR16        *StartOfBuffer,\r
+  IN  UINTN         BufferSize,\r
+  IN  CONST CHAR16  *FormatString,\r
+  ...\r
+  )\r
+{\r
+  VA_LIST Marker;\r
+\r
+  VA_START (Marker, FormatString);\r
+  return UnicodeVSPrint (StartOfBuffer, BufferSize, FormatString, Marker);\r
+}\r
+\r
+UINTN\r
+EFIAPI\r
+UnicodeVSPrintAsciiFormat (\r
+  OUT CHAR16       *StartOfBuffer,\r
+  IN  UINTN        BufferSize,\r
+  IN  CONST CHAR8  *FormatString,\r
+  IN  VA_LIST      Marker\r
+  )\r
+{\r
+  return BasePrintLibVSPrint ((CHAR8 *)StartOfBuffer, BufferSize >> 1, OUTPUT_UNICODE,FormatString, Marker);\r
+}\r
+\r
+UINTN\r
+EFIAPI\r
+UnicodeSPrintAsciiFormat (\r
+  OUT CHAR16       *StartOfBuffer,\r
+  IN  UINTN        BufferSize,\r
+  IN  CONST CHAR8  *FormatString,\r
+  ...\r
+  )\r
+{\r
+  VA_LIST Marker;\r
+\r
+  VA_START (Marker, FormatString);\r
+  return UnicodeVSPrintAsciiFormat (StartOfBuffer, BufferSize >> 1, FormatString, Marker);\r
+}\r
+\r
+UINTN\r
+EFIAPI\r
+AsciiVSPrint (\r
+  OUT CHAR8         *StartOfBuffer,\r
+  IN  UINTN         BufferSize,\r
+  IN  CONST CHAR8   *FormatString,\r
+  IN  VA_LIST       Marker\r
+  )\r
+{\r
+  return BasePrintLibVSPrint (StartOfBuffer, BufferSize, 0, FormatString, Marker);\r
+}\r
+\r
+UINTN\r
+EFIAPI\r
+AsciiSPrint (\r
+  OUT CHAR8        *StartOfBuffer,\r
+  IN  UINTN        BufferSize,\r
+  IN  CONST CHAR8  *FormatString,\r
+  ...\r
+  )\r
+{\r
+  VA_LIST Marker;\r
+\r
+  VA_START (Marker, FormatString);\r
+  return AsciiVSPrint (StartOfBuffer, BufferSize, FormatString, Marker);\r
+}\r
+\r
+UINTN\r
+EFIAPI\r
+AsciiVSPrintUnicodeFormat (\r
+  OUT CHAR8         *StartOfBuffer,\r
+  IN  UINTN         BufferSize,\r
+  IN  CONST CHAR16  *FormatString,\r
+  IN  VA_LIST       Marker\r
+  )\r
+{\r
+  return BasePrintLibVSPrint (StartOfBuffer, BufferSize, FORMAT_UNICODE, (CHAR8 *)FormatString, Marker);\r
+}\r
+\r
+UINTN\r
+EFIAPI\r
+AsciiSPrintUnicodeFormat (\r
+  OUT CHAR8         *StartOfBuffer,\r
+  IN  UINTN         BufferSize,\r
+  IN  CONST CHAR16  *FormatString,\r
+  ...\r
+  )\r
+{\r
+  VA_LIST Marker;\r
+\r
+  VA_START (Marker, FormatString);\r
+  return AsciiVSPrintUnicodeFormat (StartOfBuffer, BufferSize, FormatString, Marker);\r
+}\r
+\r
+UINTN\r
+EFIAPI\r
+UnicodeValueToString (\r
+  IN OUT CHAR16  *Buffer,\r
+  IN UINTN       Flags,\r
+  IN INT64       Value,\r
+  IN UINTN       Width\r
+  )\r
+{\r
+  return BasePrintLibConvertValueToString ((CHAR8 *)Buffer, Flags, Value, Width, 2);\r
+}\r
+\r
+UINTN\r
+EFIAPI\r
+AsciiValueToString (\r
+  IN OUT CHAR8  *Buffer,\r
+  IN UINTN      Flags,\r
+  IN INT64      Value,\r
+  IN UINTN      Width\r
+  )\r
+{\r
+  return BasePrintLibConvertValueToString ((CHAR8 *)Buffer, Flags, Value, Width, 1);\r
+}\r
diff --git a/Tools/CodeTools/Source/String/PrintLibInternal.c b/Tools/CodeTools/Source/String/PrintLibInternal.c
new file mode 100644 (file)
index 0000000..63d0c71
--- /dev/null
@@ -0,0 +1,142 @@
+/*++\r
+\r
+Copyright (c)  2004-2006 Intel Corporation. All rights reserved\r
+This program and the accompanying materials are licensed and made available\r
+under the terms and conditions of the BSD License which accompanies this\r
+distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+\r
+Module Name:\r
+\r
+  PrintLibInternal.c\r
+\r
+Abstract:\r
+\r
+  Print Library worker functions.\r
+\r
+--*/\r
+\r
+#include <Common/UefiBaseTypes.h>\r
+#include <Library/PrintLib.h>\r
+\r
+#include "CommonLib.h"\r
+#include "PrintLibInternal.h"\r
+\r
+static CONST CHAR8 mHexStr[] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};\r
+\r
+CHAR8 *\r
+BasePrintLibFillBuffer (\r
+  CHAR8   *Buffer,\r
+  INTN    Length,\r
+  UINTN   Character,\r
+  INTN    Increment\r
+  )\r
+{\r
+  INTN  Index;\r
+\r
+  for (Index = 0; Index < Length; Index++) {\r
+    *Buffer       =  (CHAR8) Character;\r
+    *(Buffer + 1) =  (CHAR8) (Character >> 8);\r
+    Buffer        += Increment;\r
+  }\r
+  return Buffer;\r
+}\r
+\r
+/**\r
+  Print worker function that prints a Value as a decimal number in Buffer.\r
+\r
+  @param  Buffer Location to place the Unicode or ASCII string of Value.\r
+\r
+  @param  Value Value to convert to a Decimal or Hexidecimal string in Buffer.\r
+\r
+  @param  Flags Flags to use in printing string, see file header for details.\r
+\r
+  @param  Precision Minimum number of digits to return in the ASCII string\r
+\r
+  @return Number of characters printed.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+BasePrintLibValueToString (\r
+  IN OUT CHAR8  *Buffer,\r
+  IN INT64      Value,\r
+  IN UINTN      Radix\r
+  )\r
+{\r
+  UINTN   Digits;\r
+  UINT32  Remainder;\r
+\r
+  //\r
+  // Loop to convert one digit at a time in reverse order\r
+  //\r
+  *(Buffer++) = 0;\r
+  Digits = 0;\r
+  do {\r
+    // Value = (INT64)DivU64x32Remainder ((UINT64)Value, (UINT32)Radix, &Remainder);\r
+    Remainder = (UINT64)Value % (UINT32)Radix;\r
+    Value = (UINT64)Value / (UINT32)Radix;\r
+    *(Buffer++) = mHexStr[Remainder];\r
+    Digits++;\r
+  } while (Value != 0);\r
+  return Digits;\r
+}\r
+\r
+UINTN\r
+BasePrintLibConvertValueToString (\r
+  IN OUT CHAR8   *Buffer,\r
+  IN UINTN       Flags,\r
+  IN INT64       Value,\r
+  IN UINTN       Width,\r
+  IN UINTN       Increment\r
+  )\r
+{\r
+  CHAR8  *OriginalBuffer;\r
+  CHAR8  ValueBuffer[MAXIMUM_VALUE_CHARACTERS];\r
+  UINTN  Count;\r
+  UINTN  Digits;\r
+  UINTN  Index;\r
+\r
+  OriginalBuffer = Buffer;\r
+\r
+  if (Width == 0 || (Flags & COMMA_TYPE) != 0) {\r
+    Flags &= (~PREFIX_ZERO);\r
+  }\r
+\r
+  if (Width == 0 || Width > (MAXIMUM_VALUE_CHARACTERS - 1)) {\r
+    Width = MAXIMUM_VALUE_CHARACTERS - 1;\r
+  }\r
+\r
+  if (Value < 0) {\r
+    Value = -Value;\r
+    Buffer = BasePrintLibFillBuffer (Buffer, 1, '-', Increment);\r
+  }\r
+\r
+  Count = BasePrintLibValueToString (ValueBuffer, Value, 10);\r
+\r
+  if ((Flags & PREFIX_ZERO) != 0) {\r
+    Buffer = BasePrintLibFillBuffer (Buffer, Width - Count, '0', Increment);\r
+  }\r
+\r
+  Digits = 3 - (Count % 3);\r
+  for (Index = 0; Index < Count; Index++) {\r
+    Buffer = BasePrintLibFillBuffer (Buffer, 1, ValueBuffer[Count - Index], Increment);\r
+    if ((Flags & COMMA_TYPE) != 0) {\r
+      Digits++;\r
+      if (Digits == 3) {\r
+        Digits = 0;\r
+        if ((Index + 1) < Count) {\r
+          Buffer = BasePrintLibFillBuffer (Buffer, 1, ',', Increment);\r
+        }\r
+      }\r
+    }\r
+  }\r
+\r
+  Buffer = BasePrintLibFillBuffer (Buffer, 1, 0, Increment);\r
+\r
+  return ((Buffer - OriginalBuffer) / Increment);\r
+}\r
diff --git a/Tools/CodeTools/Source/String/PrintLibInternal.h b/Tools/CodeTools/Source/String/PrintLibInternal.h
new file mode 100644 (file)
index 0000000..87f0955
--- /dev/null
@@ -0,0 +1,101 @@
+/*++\r
+\r
+Copyright (c)  2004-2006 Intel Corporation. All rights reserved\r
+This program and the accompanying materials are licensed and made available\r
+under the terms and conditions of the BSD License which accompanies this\r
+distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+\r
+Module Name:\r
+\r
+  PrintLibInternal.h\r
+\r
+Abstract:\r
+\r
+  Print Library.\r
+\r
+--*/\r
+\r
+\r
+\r
+//\r
+// Print primitives\r
+//\r
+//#define LEFT_JUSTIFY      0x01\r
+#define PREFIX_SIGN       0x02\r
+#define PREFIX_BLANK      0x04\r
+//#define COMMA_TYPE        0x08\r
+#define LONG_TYPE         0x10\r
+//#define PREFIX_ZERO       0x20\r
+#define OUTPUT_UNICODE    0x40\r
+#define RADIX_HEX         0x80\r
+#define FORMAT_UNICODE    0x100\r
+#define PAD_TO_WIDTH      0x200\r
+#define ARGUMENT_UNICODE  0x400\r
+#define PRECISION         0x800\r
+#define ARGUMENT_REVERSED 0x1000\r
+\r
+///\r
+/// Define the maximum number of characters that are required to encode\r
+/// a decimal, hexidecimal, GUID, or TIME value with a Nll terminator.\r
+///   Maximum Length Decimal String     = 28    "-9,223,372,036,854,775,808"\r
+///   Maximum Length Hexidecimal String = 17    "FFFFFFFFFFFFFFFF"\r
+///   Maximum Length GUID               = 37    "00000000-0000-0000-0000-000000000000"\r
+///   Maximum Length TIME               = 18    "12/12/2006  12:12"\r
+///\r
+#define MAXIMUM_VALUE_CHARACTERS  38\r
+\r
+//\r
+//\r
+//\r
+typedef struct {\r
+  UINT16  Year;\r
+  UINT8   Month;\r
+  UINT8   Day;\r
+  UINT8   Hour;\r
+  UINT8   Minute;\r
+  UINT8   Second;\r
+  UINT8   Pad1;\r
+  UINT32  Nanosecond;\r
+  INT16   TimeZone;\r
+  UINT8   Daylight;\r
+  UINT8   Pad2;\r
+} TIME;\r
+\r
+UINTN\r
+BasePrintLibSPrint (\r
+  OUT CHAR8        *Buffer,\r
+  IN  UINTN        BufferSize,\r
+  IN  UINTN        Flags,\r
+  IN  CONST CHAR8  *FormatString,\r
+  ...\r
+  );\r
+\r
+CHAR8 *\r
+BasePrintLibFillBuffer (\r
+  CHAR8   *Buffer,\r
+  INTN    Length,\r
+  UINTN   Character,\r
+  INTN    Increment\r
+  );\r
+\r
+UINTN\r
+EFIAPI\r
+BasePrintLibValueToString (\r
+  IN OUT CHAR8  *Buffer,\r
+  IN INT64      Value,\r
+  IN UINTN      Radix\r
+  );\r
+\r
+UINTN\r
+BasePrintLibConvertValueToString (\r
+  IN OUT CHAR8   *Buffer,\r
+  IN UINTN       Flags,\r
+  IN INT64       Value,\r
+  IN UINTN       Width,\r
+  IN UINTN       Increment\r
+  );\r
diff --git a/Tools/CodeTools/Source/String/String.c b/Tools/CodeTools/Source/String/String.c
new file mode 100644 (file)
index 0000000..78d0a59
--- /dev/null
@@ -0,0 +1,732 @@
+/*++\r
+\r
+Copyright (c)  2004-2006 Intel Corporation. All rights reserved\r
+This program and the accompanying materials are licensed and made available\r
+under the terms and conditions of the BSD License which accompanies this\r
+distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+\r
+Module Name:\r
+\r
+  String.c\r
+\r
+Abstract:\r
+\r
+  Unicode and ASCII string primatives.\r
+\r
+--*/\r
+\r
+#include <assert.h>\r
+\r
+#include <Common/UefiBaseTypes.h>\r
+\r
+#include <string.h>\r
+\r
+#include "CommonLib.h"\r
+\r
+/**\r
+  Returns the length of a Null-terminated Unicode string.\r
+\r
+  This function returns the number of Unicode characters in the Null-terminated\r
+  Unicode string specified by String.\r
+\r
+  If String is NULL, then ASSERT().\r
+\r
+  @param  String  Pointer to a Null-terminated Unicode string.\r
+\r
+  @return The length of String.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+StrLen (\r
+  IN      CONST CHAR16              *String\r
+  )\r
+{\r
+  UINTN                             Length;\r
+\r
+  ASSERT (String != NULL);\r
+\r
+  for (Length = 0; *String != L'\0'; String++, Length++) {\r
+    ;\r
+  }\r
+  return Length;\r
+}\r
+\r
+/**\r
+  Returns the length of a Null-terminated ASCII string.\r
+\r
+  This function returns the number of ASCII characters in the Null-terminated\r
+  ASCII string specified by String.\r
+\r
+  If String is NULL, then ASSERT().\r
+\r
+  @param  String  Pointer to a Null-terminated ASCII string.\r
+\r
+  @return The length of String.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+AsciiStrLen (\r
+  IN      CONST CHAR8               *String\r
+  )\r
+{\r
+  UINTN                             Length;\r
+\r
+  ASSERT (String != NULL);\r
+\r
+  for (Length = 0; *String != '\0'; String++, Length++) {\r
+    ;\r
+  }\r
+  return Length;\r
+}\r
+\r
+/**\r
+  Copies one Null-terminated Unicode string to another Null-terminated Unicode\r
+  string and returns the new Unicode string.\r
+\r
+  This function copies the contents of the Unicode string Source to the Unicode\r
+  string Destination, and returns Destination. If Source and Destination\r
+  overlap, then the results are undefined.\r
+\r
+  If Destination is NULL, then ASSERT().\r
+  If Source is NULL, then ASSERT().\r
+  If Source and Destination overlap, then ASSERT().\r
+\r
+  @param  Destination Pointer to a Null-terminated Unicode string.\r
+  @param  Source      Pointer to a Null-terminated Unicode string.\r
+\r
+  @return Destiantion\r
+\r
+**/\r
+CHAR16 *\r
+EFIAPI\r
+StrCpy (\r
+  OUT     CHAR16                    *Destination,\r
+  IN      CONST CHAR16              *Source\r
+  )\r
+{\r
+  CHAR16                            *ReturnValue;\r
+\r
+  //\r
+  // Destination cannot be NULL\r
+  //\r
+  ASSERT (Destination != NULL);\r
+\r
+  //\r
+  // Destination and source cannot overlap\r
+  //\r
+  ASSERT ((UINTN)(Destination - Source) > StrLen (Source));\r
+  ASSERT ((UINTN)(Source - Destination) > StrLen (Source));\r
+\r
+  ReturnValue = Destination;\r
+  while (*Source) {\r
+    *(Destination++) = *(Source++);\r
+  }\r
+  *Destination = 0;\r
+  return ReturnValue;\r
+}\r
+\r
+/**\r
+  Copies one Null-terminated Unicode string with a maximum length to another\r
+  Null-terminated Unicode string with a maximum length and returns the new\r
+  Unicode string.\r
+\r
+  This function copies the contents of the Unicode string Source to the Unicode\r
+  string Destination, and returns Destination. At most, Length Unicode\r
+  characters are copied from Source to Destination. If Length is 0, then\r
+  Destination is returned unmodified. If Length is greater that the number of\r
+  Unicode characters in Source, then Destination is padded with Null Unicode\r
+  characters. If Source and Destination overlap, then the results are\r
+  undefined.\r
+\r
+  If Destination is NULL, then ASSERT().\r
+  If Source is NULL, then ASSERT().\r
+  If Source and Destination overlap, then ASSERT().\r
+\r
+  @param  Destination Pointer to a Null-terminated Unicode string.\r
+  @param  Source      Pointer to a Null-terminated Unicode string.\r
+  @param  Length      Maximum number of Unicode characters to copy.\r
+\r
+  @return Destination\r
+\r
+**/\r
+CHAR16 *\r
+EFIAPI\r
+StrnCpy (\r
+  OUT     CHAR16                    *Destination,\r
+  IN      CONST CHAR16              *Source,\r
+  IN      UINTN                     Length\r
+  )\r
+{\r
+  CHAR16                            *ReturnValue;\r
+\r
+  if (Length == 0) {\r
+    return Destination;\r
+  }\r
+\r
+  //\r
+  // Destination cannot be NULL if Length is not zero\r
+  //\r
+  ASSERT (Destination != NULL);\r
+\r
+  //\r
+  // Destination and source cannot overlap\r
+  // Q: Does Source have to be NULL-terminated?\r
+  //\r
+  ASSERT ((UINTN)(Destination - Source) > StrLen (Source));\r
+  ASSERT ((UINTN)(Source - Destination) >= Length);\r
+\r
+  ReturnValue = Destination;\r
+\r
+  while ((*Source != L'\0') && (Length > 0)) {\r
+    *(Destination++) = *(Source++);\r
+    Length--;\r
+  }\r
+\r
+  memset (Destination, 0, Length * sizeof (*Destination));\r
+  return ReturnValue;\r
+}\r
+\r
+/**\r
+  Returns the size of a Null-terminated Unicode string in bytes, including the\r
+  Null terminator.\r
+\r
+  This function returns the size, in bytes, of the Null-terminated Unicode\r
+  string specified by String.\r
+\r
+  If String is NULL, then ASSERT().\r
+\r
+  @param  String  Pointer to a Null-terminated Unicode string.\r
+\r
+  @return The size of String.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+StrSize (\r
+  IN      CONST CHAR16              *String\r
+  )\r
+{\r
+  return (StrLen (String) + 1) * sizeof (*String);\r
+}\r
+\r
+/**\r
+  Compares two Null-terminated Unicode strings, and returns the difference\r
+  between the first mismatched Unicode characters.\r
+\r
+  This function compares the Null-terminated Unicode string FirstString to the\r
+  Null-terminated Unicode string SecondString. If FirstString is identical to\r
+  SecondString, then 0 is returned. Otherwise, the value returned is the first\r
+  mismatched Unicode character in SecondString subtracted from the first\r
+  mismatched Unicode character in FirstString.\r
+\r
+  If FirstString is NULL, then ASSERT().\r
+  If SecondString is NULL, then ASSERT().\r
+\r
+  @param  FirstString   Pointer to a Null-terminated Unicode string.\r
+  @param  SecondString  Pointer to a Null-terminated Unicode string.\r
+\r
+  @retval 0   FirstString is identical to SecondString.\r
+  @retval !=0 FirstString is not identical to SecondString.\r
+\r
+**/\r
+INTN\r
+EFIAPI\r
+StrCmp (\r
+  IN      CONST CHAR16              *FirstString,\r
+  IN      CONST CHAR16              *SecondString\r
+  )\r
+{\r
+  //\r
+  // ASSERT both strings should never be zero\r
+  //\r
+  ASSERT (StrSize (FirstString) != 0);\r
+  ASSERT (StrSize (SecondString) != 0);\r
+\r
+  while ((*FirstString != L'\0') && (*FirstString == *SecondString)) {\r
+    FirstString++;\r
+    SecondString++;\r
+  }\r
+  return *FirstString - *SecondString;\r
+}\r
+\r
+/**\r
+  Compares two Null-terminated Unicode strings with maximum lengths, and\r
+  returns the difference between the first mismatched Unicode characters.\r
+\r
+  This function compares the Null-terminated Unicode string FirstString to the\r
+  Null-terminated Unicode string SecondString. At most, Length Unicode\r
+  characters will be compared. If Length is 0, then 0 is returned. If\r
+  FirstString is identical to SecondString, then 0 is returned. Otherwise, the\r
+  value returned is the first mismatched Unicode character in SecondString\r
+  subtracted from the first mismatched Unicode character in FirstString.\r
+\r
+  If FirstString is NULL, then ASSERT().\r
+  If SecondString is NULL, then ASSERT().\r
+\r
+  @param  FirstString   Pointer to a Null-terminated Unicode string.\r
+  @param  SecondString  Pointer to a Null-terminated Unicode string.\r
+  @param  Length        Maximum number of Unicode characters to compare.\r
+\r
+  @retval 0   FirstString is identical to SecondString.\r
+  @retval !=0 FirstString is not identical to SecondString.\r
+\r
+**/\r
+INTN\r
+EFIAPI\r
+StrnCmp (\r
+  IN      CONST CHAR16              *FirstString,\r
+  IN      CONST CHAR16              *SecondString,\r
+  IN      UINTN                     Length\r
+  )\r
+{\r
+  if (Length == 0) {\r
+    return 0;\r
+  }\r
+\r
+  //\r
+  // ASSERT both strings should never be zero\r
+  //\r
+  ASSERT (StrSize (FirstString) != 0);\r
+  ASSERT (StrSize (SecondString) != 0);\r
+\r
+  while ((*FirstString != L'\0') &&\r
+         (*FirstString == *SecondString) &&\r
+         (Length > 1)) {\r
+    FirstString++;\r
+    SecondString++;\r
+    Length--;\r
+  }\r
+\r
+  return *FirstString - *SecondString;\r
+}\r
+\r
+/**\r
+  Concatenates one Null-terminated Unicode string to another Null-terminated\r
+  Unicode string, and returns the concatenated Unicode string.\r
+\r
+  This function concatenates two Null-terminated Unicode strings. The contents\r
+  of Null-terminated Unicode string Source are concatenated to the end of\r
+  Null-terminated Unicode string Destination. The Null-terminated concatenated\r
+  Unicode String is returned. If Source and Destination overlap, then the\r
+  results are undefined.\r
+\r
+  If Destination is NULL, then ASSERT().\r
+  If Source is NULL, then ASSERT().\r
+  If Source and Destination overlap, then ASSERT().\r
+\r
+  @param  Destination Pointer to a Null-terminated Unicode string.\r
+  @param  Source      Pointer to a Null-terminated Unicode string.\r
+\r
+  @return Destination\r
+\r
+**/\r
+CHAR16 *\r
+EFIAPI\r
+StrCat (\r
+  IN OUT  CHAR16                    *Destination,\r
+  IN      CONST CHAR16              *Source\r
+  )\r
+{\r
+  StrCpy (Destination + StrLen (Destination), Source);\r
+\r
+  //\r
+  // Size of the resulting string should never be zero.\r
+  //\r
+  ASSERT (StrSize (Destination) != 0);\r
+  return Destination;\r
+}\r
+\r
+/**\r
+  Concatenates one Null-terminated Unicode string with a maximum length to the\r
+  end of another Null-terminated Unicode string, and returns the concatenated\r
+  Unicode string.\r
+\r
+  This function concatenates two Null-terminated Unicode strings. The contents\r
+  of Null-terminated Unicode string Source are concatenated to the end of\r
+  Null-terminated Unicode string Destination, and Destination is returned. At\r
+  most, Length Unicode characters are concatenated from Source to the end of\r
+  Destination, and Destination is always Null-terminated. If Length is 0, then\r
+  Destination is returned unmodified. If Source and Destination overlap, then\r
+  the results are undefined.\r
+\r
+  If Destination is NULL, then ASSERT().\r
+  If Source is NULL, then ASSERT().\r
+  If Source and Destination overlap, then ASSERT().\r
+\r
+  @param  Destination Pointer to a Null-terminated Unicode string.\r
+  @param  Source      Pointer to a Null-terminated Unicode string.\r
+  @param  Length      Maximum number of Unicode characters to concatenate from\r
+                      Source.\r
+\r
+  @return Destination\r
+\r
+**/\r
+CHAR16 *\r
+EFIAPI\r
+StrnCat (\r
+  IN OUT  CHAR16                    *Destination,\r
+  IN      CONST CHAR16              *Source,\r
+  IN      UINTN                     Length\r
+  )\r
+{\r
+  StrnCpy (Destination + StrLen (Destination), Source, Length);\r
+\r
+  //\r
+  // Size of the resulting string should never be zero.\r
+  //\r
+  ASSERT (StrSize (Destination) != 0);\r
+  return Destination;\r
+}\r
+\r
+/**\r
+  Copies one Null-terminated ASCII string to another Null-terminated ASCII\r
+  string and returns the new ASCII string.\r
+\r
+  This function copies the contents of the ASCII string Source to the ASCII\r
+  string Destination, and returns Destination. If Source and Destination\r
+  overlap, then the results are undefined.\r
+\r
+  If Destination is NULL, then ASSERT().\r
+  If Source is NULL, then ASSERT().\r
+  If Source and Destination overlap, then ASSERT().\r
+\r
+  @param  Destination Pointer to a Null-terminated ASCII string.\r
+  @param  Source      Pointer to a Null-terminated ASCII string.\r
+\r
+  @return Destination\r
+\r
+**/\r
+CHAR8 *\r
+EFIAPI\r
+AsciiStrCpy (\r
+  OUT     CHAR8                     *Destination,\r
+  IN      CONST CHAR8               *Source\r
+  )\r
+{\r
+  CHAR8                             *ReturnValue;\r
+\r
+  //\r
+  // Destination cannot be NULL\r
+  //\r
+  ASSERT (Destination != NULL);\r
+\r
+  //\r
+  // Destination and source cannot overlap\r
+  //\r
+  ASSERT ((UINTN)(Destination - Source) > AsciiStrLen (Source));\r
+  ASSERT ((UINTN)(Source - Destination) > AsciiStrLen (Source));\r
+\r
+  ReturnValue = Destination;\r
+  while (*Source) {\r
+    *(Destination++) = *(Source++);\r
+  }\r
+  *Destination = 0;\r
+  return ReturnValue;\r
+}\r
+\r
+/**\r
+  Copies one Null-terminated ASCII string with a maximum length to another\r
+  Null-terminated ASCII string with a maximum length and returns the new ASCII\r
+  string.\r
+\r
+  This function copies the contents of the ASCII string Source to the ASCII\r
+  string Destination, and returns Destination. At most, Length ASCII characters\r
+  are copied from Source to Destination. If Length is 0, then Destination is\r
+  returned unmodified. If Length is greater that the number of ASCII characters\r
+  in Source, then Destination is padded with Null ASCII characters. If Source\r
+  and Destination overlap, then the results are undefined.\r
+\r
+  If Destination is NULL, then ASSERT().\r
+  If Source is NULL, then ASSERT().\r
+  If Source and Destination overlap, then ASSERT().\r
+\r
+  @param  Destination Pointer to a Null-terminated ASCII string.\r
+  @param  Source      Pointer to a Null-terminated ASCII string.\r
+  @param  Length      Maximum number of ASCII characters to copy.\r
+\r
+  @return Destination\r
+\r
+**/\r
+CHAR8 *\r
+EFIAPI\r
+AsciiStrnCpy (\r
+  OUT     CHAR8                     *Destination,\r
+  IN      CONST CHAR8               *Source,\r
+  IN      UINTN                     Length\r
+  )\r
+{\r
+  CHAR8                             *ReturnValue;\r
+\r
+  if (Length == 0) {\r
+    return Destination;\r
+  }\r
+\r
+  //\r
+  // Destination cannot be NULL\r
+  //\r
+  ASSERT (Destination != NULL);\r
+\r
+  //\r
+  // Destination and source cannot overlap\r
+  //\r
+  ASSERT ((UINTN)(Destination - Source) > AsciiStrLen (Source));\r
+  ASSERT ((UINTN)(Source - Destination) >= Length);\r
+\r
+  ReturnValue = Destination;\r
+\r
+  while (*Source && Length > 0) {\r
+    *(Destination++) = *(Source++);\r
+    Length--;\r
+  }\r
+\r
+  // ZeroMem (Destination, Length * sizeof (*Destination));\r
+  memset (Destination, 0, Length * sizeof (*Destination));\r
+  return ReturnValue;\r
+}\r
+\r
+/**\r
+  Returns the size of a Null-terminated ASCII string in bytes, including the\r
+  Null terminator.\r
+\r
+  This function returns the size, in bytes, of the Null-terminated ASCII string\r
+  specified by String.\r
+\r
+  If String is NULL, then ASSERT().\r
+\r
+  @param  String  Pointer to a Null-terminated ASCII string.\r
+\r
+  @return The size of String.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+AsciiStrSize (\r
+  IN      CONST CHAR8               *String\r
+  )\r
+{\r
+  return (AsciiStrLen (String) + 1) * sizeof (*String);\r
+}\r
+\r
+/**\r
+  Compares two Null-terminated ASCII strings, and returns the difference\r
+  between the first mismatched ASCII characters.\r
+\r
+  This function compares the Null-terminated ASCII string FirstString to the\r
+  Null-terminated ASCII string SecondString. If FirstString is identical to\r
+  SecondString, then 0 is returned. Otherwise, the value returned is the first\r
+  mismatched ASCII character in SecondString subtracted from the first\r
+  mismatched ASCII character in FirstString.\r
+\r
+  If FirstString is NULL, then ASSERT().\r
+  If SecondString is NULL, then ASSERT().\r
+\r
+  @param  FirstString   Pointer to a Null-terminated ASCII string.\r
+  @param  SecondString  Pointer to a Null-terminated ASCII string.\r
+\r
+  @retval 0   FirstString is identical to SecondString.\r
+  @retval !=0 FirstString is not identical to SecondString.\r
+\r
+**/\r
+INTN\r
+EFIAPI\r
+AsciiStrCmp (\r
+  IN      CONST CHAR8               *FirstString,\r
+  IN      CONST CHAR8               *SecondString\r
+  )\r
+{\r
+  //\r
+  // ASSERT both strings should never be zero\r
+  //\r
+  ASSERT (AsciiStrSize (FirstString));\r
+  ASSERT (AsciiStrSize (SecondString));\r
+\r
+  while ((*FirstString != '\0') && (*FirstString == *SecondString)) {\r
+    FirstString++;\r
+    SecondString++;\r
+  }\r
+\r
+  return *FirstString - *SecondString;\r
+}\r
+\r
+STATIC\r
+CHAR8\r
+EFIAPI\r
+AsciiToUpper (\r
+  IN      CHAR8                     Chr\r
+  )\r
+{\r
+  return (Chr >= 'a' && Chr <= 'z') ? Chr - ('a' - 'A') : Chr;\r
+}\r
+\r
+/**\r
+  Performs a case insensitive comparison of two Null-terminated ASCII strings,\r
+  and returns the difference between the first mismatched ASCII characters.\r
+\r
+  This function performs a case insensitive comparison of the Null-terminated\r
+  ASCII string FirstString to the Null-terminated ASCII string SecondString. If\r
+  FirstString is identical to SecondString, then 0 is returned. Otherwise, the\r
+  value returned is the first mismatched lower case ASCII character in\r
+  SecondString subtracted from the first mismatched lower case ASCII character\r
+  in FirstString.\r
+\r
+  If FirstString is NULL, then ASSERT().\r
+  If SecondString is NULL, then ASSERT().\r
+\r
+  @param  FirstString   Pointer to a Null-terminated ASCII string.\r
+  @param  SecondString  Pointer to a Null-terminated ASCII string.\r
+\r
+  @retval 0   FirstString is identical to SecondString using case insensitive\r
+              comparisons.\r
+  @retval !=0 FirstString is not identical to SecondString using case\r
+              insensitive comparisons.\r
+\r
+**/\r
+INTN\r
+EFIAPI\r
+AsciiStriCmp (\r
+  IN      CONST CHAR8               *FirstString,\r
+  IN      CONST CHAR8               *SecondString\r
+  )\r
+{\r
+  //\r
+  // ASSERT both strings should never be zero\r
+  //\r
+  ASSERT (AsciiStrSize (FirstString));\r
+  ASSERT (AsciiStrSize (SecondString));\r
+\r
+  while ((*FirstString != '\0') &&\r
+         (AsciiToUpper (*FirstString) == AsciiToUpper (*SecondString))) {\r
+    FirstString++;\r
+    SecondString++;\r
+  }\r
+\r
+  return AsciiToUpper (*FirstString) - AsciiToUpper (*SecondString);\r
+}\r
+\r
+/**\r
+  Compares two Null-terminated ASCII strings with maximum lengths, and returns\r
+  the difference between the first mismatched ASCII characters.\r
+\r
+  This function compares the Null-terminated ASCII string FirstString to the\r
+  Null-terminated ASCII  string SecondString. At most, Length ASCII characters\r
+  will be compared. If Length is 0, then 0 is returned. If FirstString is\r
+  identical to SecondString, then 0 is returned. Otherwise, the value returned\r
+  is the first mismatched ASCII character in SecondString subtracted from the\r
+  first mismatched ASCII character in FirstString.\r
+\r
+  If FirstString is NULL, then ASSERT().\r
+  If SecondString is NULL, then ASSERT().\r
+\r
+  @param  FirstString   Pointer to a Null-terminated ASCII string.\r
+  @param  SecondString  Pointer to a Null-terminated ASCII string.\r
+\r
+  @retval 0   FirstString is identical to SecondString.\r
+  @retval !=0 FirstString is not identical to SecondString.\r
+\r
+**/\r
+INTN\r
+EFIAPI\r
+AsciiStrnCmp (\r
+  IN      CONST CHAR8               *FirstString,\r
+  IN      CONST CHAR8               *SecondString,\r
+  IN      UINTN                     Length\r
+  )\r
+{\r
+  //\r
+  // ASSERT both strings should never be zero\r
+  //\r
+  ASSERT (AsciiStrSize (FirstString));\r
+  ASSERT (AsciiStrSize (SecondString));\r
+\r
+  while ((*FirstString != '\0') &&\r
+         (*FirstString == *SecondString) &&\r
+         (Length > 1)) {\r
+    FirstString++;\r
+    SecondString++;\r
+    Length--;\r
+  }\r
+  return *FirstString - *SecondString;\r
+}\r
+\r
+/**\r
+  Concatenates one Null-terminated ASCII string to another Null-terminated\r
+  ASCII string, and returns the concatenated ASCII string.\r
+\r
+  This function concatenates two Null-terminated ASCII strings. The contents of\r
+  Null-terminated ASCII string Source are concatenated to the end of Null-\r
+  terminated ASCII string Destination. The Null-terminated concatenated ASCII\r
+  String is returned.\r
+\r
+  If Destination is NULL, then ASSERT().\r
+  If Source is NULL, then ASSERT().\r
+\r
+  @param  Destination Pointer to a Null-terminated ASCII string.\r
+  @param  Source      Pointer to a Null-terminated ASCII string.\r
+\r
+  @return Destination\r
+\r
+**/\r
+CHAR8 *\r
+EFIAPI\r
+AsciiStrCat (\r
+  IN OUT CHAR8    *Destination,\r
+  IN CONST CHAR8  *Source\r
+  )\r
+{\r
+  AsciiStrCpy (Destination + AsciiStrLen (Destination), Source);\r
+\r
+  //\r
+  // Size of the resulting string should never be zero.\r
+  //\r
+  ASSERT (AsciiStrSize (Destination) != 0);\r
+  return Destination;\r
+}\r
+\r
+/**\r
+  Concatenates one Null-terminated ASCII string with a maximum length to the\r
+  end of another Null-terminated ASCII string, and returns the concatenated\r
+  ASCII string.\r
+\r
+  This function concatenates two Null-terminated ASCII strings. The contents\r
+  of Null-terminated ASCII string Source are concatenated to the end of Null-\r
+  terminated ASCII string Destination, and Destination is returned. At most,\r
+  Length ASCII characters are concatenated from Source to the end of\r
+  Destination, and Destination is always Null-terminated. If Length is 0, then\r
+  Destination is returned unmodified. If Source and Destination overlap, then\r
+  the results are undefined.\r
+\r
+  If Destination is NULL, then ASSERT().\r
+  If Source is NULL, then ASSERT().\r
+  If Source and Destination overlap, then ASSERT().\r
+\r
+  @param  Destination Pointer to a Null-terminated ASCII string.\r
+  @param  Source      Pointer to a Null-terminated ASCII string.\r
+  @param  Length      Maximum number of ASCII characters to concatenate from\r
+                      Source.\r
+\r
+  @return Destination\r
+\r
+**/\r
+CHAR8 *\r
+EFIAPI\r
+AsciiStrnCat (\r
+  IN OUT  CHAR8                     *Destination,\r
+  IN      CONST CHAR8               *Source,\r
+  IN      UINTN                     Length\r
+  )\r
+{\r
+  AsciiStrnCpy (Destination + AsciiStrLen (Destination), Source, Length);\r
+\r
+  //\r
+  // Size of the resulting string should never be zero.\r
+  //\r
+  ASSERT (AsciiStrSize (Destination) != 0);\r
+  return Destination;\r
+}\r
diff --git a/Tools/CodeTools/Source/String/build.xml b/Tools/CodeTools/Source/String/build.xml
new file mode 100644 (file)
index 0000000..933cb5c
--- /dev/null
@@ -0,0 +1,96 @@
+<?xml version="1.0" ?>\r
+<!--\r
+Copyright (c) 2006, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+-->\r
+<project default="GenTool" basedir=".">\r
+<!--\r
+    EDK String\r
+  Copyright (c) 2006, Intel Corporation\r
+-->\r
+  <taskdef resource="cpptasks.tasks"/>\r
+  <typedef resource="cpptasks.types"/>\r
+  <taskdef resource="net/sf/antcontrib/antlib.xml"/>\r
+\r
+  <property name="LibName" value="String"/>\r
+  <property name="LINK_OUTPUT_TYPE" value="static"/>\r
+  <property name="BUILD_DIR" value="${PACKAGE_DIR}/${LibName}/tmp"/>\r
+\r
+  <target name="GenTool" depends="init, String">\r
+    <echo message="The EDK Library: ${LibName} build has completed!"/>\r
+  </target>\r
+\r
+  <target name="init">\r
+    <echo message="Building the EDK Library: ${LibName}"/>\r
+    <mkdir dir="${BUILD_DIR}"/>\r
+\r
+    <condition property="syslibdirs" value="">\r
+      <os family="mac"/>\r
+    </condition>\r
+    \r
+    <condition property="syslibs" value="">\r
+      <os family="mac"/>\r
+    </condition>\r
+    \r
+    <condition property="syslibdirs" value="${env.CYGWIN_HOME}/lib/e2fsprogs">\r
+      <os family="windows"/>\r
+    </condition>\r
+    \r
+    <condition property="syslibs" value="uuid">\r
+      <os family="windows"/>\r
+    </condition>\r
+    \r
+    <condition property="syslibdirs" value="/usr/lib">\r
+      <os name="Linux"/>\r
+    </condition>\r
+    \r
+    <condition property="syslibs" value="uuid">\r
+      <os name="Linux"/>\r
+    </condition>\r
+    \r
+  </target>\r
+\r
+  <target name="String" depends="init">\r
+    <cc name="${ToolChain}" objdir="${BUILD_DIR}" \r
+        outfile="${LIB_DIR}/${LibName}"\r
+        outtype="static"\r
+        debug="true"\r
+        optimize="speed">\r
+      <compilerarg value="${ExtraArgus}" if="ExtraArgus" />\r
+      <compilerarg value="-fshort-wchar" if="gcc"/>\r
+\r
+      <fileset dir="${basedir}/${LibName}" \r
+        includes="*.c" />\r
+\r
+      <includepath path="${PACKAGE_DIR}/${LibName}"/>\r
+      <includepath path="${PACKAGE_DIR}/Include"/>\r
+      <includepath path="${PACKAGE_DIR}/Include/${HostArch}"/>\r
+      <includepath path="${PACKAGE_DIR}/Common"/>\r
+    </cc>\r
+  </target>\r
+\r
+\r
+  <target name="clean">\r
+    <echo message="Removing Intermediate Files Only"/>  \r
+    <delete>\r
+      <fileset dir="${BUILD_DIR}" includes="*.obj"/>\r
+    </delete>\r
+  </target>\r
+\r
+  <target name="cleanall">\r
+    <echo message="Removing Object Files and the Library: ${LibName}${ext_static}"/>  \r
+    <delete dir="${PACKAGE_DIR}/${LibName}/tmp">\r
+    </delete>\r
+    <delete failonerror="false" quiet="true" includeEmptyDirs="true">\r
+      <fileset dir="${BUILD_DIR}"/>\r
+      <fileset file="${LIB_DIR}/${LibName}${ext_static}"/>\r
+    </delete>\r
+  </target>\r
+\r
+</project>\r
diff --git a/Tools/CodeTools/Source/Strip/Strip.c b/Tools/CodeTools/Source/Strip/Strip.c
new file mode 100644 (file)
index 0000000..bccdffb
--- /dev/null
@@ -0,0 +1,105 @@
+/*++\r
+\r
+Copyright (c)  2004-2006 Intel Corporation. All rights reserved\r
+This program and the accompanying materials are licensed and made available\r
+under the terms and conditions of the BSD License which accompanies this\r
+distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+\r
+Module Name:\r
+\r
+  Strip.c\r
+\r
+Abstract:\r
+\r
+  Quick Exe2Bin equivalent.\r
+\r
+--*/\r
+\r
+#include <stdio.h>\r
+#include <memory.h>\r
+#include <string.h>\r
+#include <stdlib.h>\r
+\r
+int\r
+main (\r
+  int  argc,\r
+  char *argv[]\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Converts executable files to binary files.\r
+\r
+Arguments:\r
+\r
+  argc   - Number of command line arguments\r
+  argv[] - Array of pointers to the command line arguments\r
+\r
+Returns:\r
+\r
+  Zero     - Function completed successfully.\r
+  Non-zero - Function exited with errors.\r
+\r
+--*/\r
+{\r
+  FILE  *InFile;\r
+  FILE  *OutFile;\r
+  int   Index;\r
+  int   FileSize;\r
+  char  *Buffer;\r
+  char  *Ptrx;\r
+\r
+  if (argc < 3) {\r
+    printf ("Need more args, such as file name to convert and output name\n");\r
+    return -1;\r
+  }\r
+\r
+  InFile  = fopen (argv[1], "rb");\r
+  OutFile = fopen (argv[2], "wb");\r
+\r
+  if (!InFile) {\r
+    printf ("no file, exit\n");\r
+    return -1;\r
+  }\r
+\r
+  if (OutFile == NULL) {\r
+    printf ("Unable to open output file.\n");\r
+    return -1;\r
+  }\r
+\r
+  fseek (InFile, 0, SEEK_END);\r
+  FileSize = ftell (InFile);\r
+\r
+  if (FileSize < 0x200) {\r
+    printf ("%d is not a legal size, exit\n", FileSize);\r
+    return -1;\r
+  }\r
+\r
+  fseek (InFile, 0, SEEK_SET);\r
+\r
+  Buffer = (char *) malloc (FileSize);\r
+  if (Buffer == NULL) {\r
+    printf ("Error: Out of resources.\n");\r
+    return -1;\r
+  }\r
+\r
+  fread (Buffer, 1, FileSize, InFile);\r
+\r
+  Ptrx  = Buffer + 0x200;\r
+\r
+  Index = FileSize - 0x200;\r
+\r
+  fwrite (Ptrx, Index, 1, OutFile);\r
+\r
+  fclose (InFile);\r
+  fclose (OutFile);\r
+  free (Buffer);\r
+\r
+  return 0;\r
+}\r
diff --git a/Tools/CodeTools/Source/Strip/build.xml b/Tools/CodeTools/Source/Strip/build.xml
new file mode 100644 (file)
index 0000000..9ead28d
--- /dev/null
@@ -0,0 +1,69 @@
+<?xml version="1.0" ?>\r
+<!--\r
+Copyright (c) 2006, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+-->\r
+<project default="GenTool" basedir=".">\r
+<!--\r
+    EDK Strip Tool\r
+  Copyright (c) 2006, Intel Corporation\r
+-->\r
+  <property name="ToolName" value="Strip"/>\r
+  <property name="FileSet" value="*.c"/>\r
+\r
+  <taskdef resource="cpptasks.tasks"/>\r
+  <typedef resource="cpptasks.types"/>\r
+  <taskdef resource="net/sf/antcontrib/antlib.xml"/>\r
+\r
+  <property name="LINK_OUTPUT_TYPE" value="static"/>\r
+  <property name="BUILD_DIR" value="${PACKAGE_DIR}/${ToolName}/tmp"/>\r
+\r
+  <target name="GenTool" depends="init, Tool">\r
+    <echo message="The EDK Tool: ${ToolName} build has completed!"/>\r
+  </target>\r
+\r
+  <target name="init">\r
+    <echo message="Building the EDK Tool: ${ToolName}"/>\r
+    <mkdir dir="${BUILD_DIR}"/>\r
+  </target>\r
+\r
+  <target name="Tool" depends="init">\r
+    <cc name="${ToolChain}" objdir="${BUILD_DIR}" \r
+        outfile="${BIN_DIR}/${ToolName}"\r
+        outtype="executable"\r
+        optimize="speed" \r
+        debug="true">\r
+\r
+      <fileset dir="${basedir}/${ToolName}" \r
+        includes="${FileSet}" \r
+        defaultexcludes="TRUE" \r
+        excludes="*.xml *.inf"/>\r
+\r
+      <includepath path="${PACKAGE_DIR}/Include"/>\r
+      <includepath path="${PACKAGE_DIR}/Include/Ia32"/>\r
+      <includepath path="${PACKAGE_DIR}/Common"/>\r
+    </cc>\r
+  </target>\r
+\r
+  <target name="clean">\r
+    <echo message="Removing Intermediate Files Only"/>  \r
+    <delete>\r
+      <fileset dir="${BUILD_DIR}" includes="*.obj"/>\r
+    </delete>\r
+  </target>\r
+\r
+  <target name="cleanall">\r
+    <echo message="Removing Object Files and the Executable: ${ToolName}${ext_exe}"/>  \r
+    <delete failonerror="false" quiet="true" includeEmptyDirs="true">\r
+      <fileset dir="${BUILD_DIR}"/>\r
+      <fileset file="${BIN_DIR}/${ToolName}${ext_exe}"/>\r
+    </delete>\r
+  </target>\r
+\r
+</project>\r
diff --git a/Tools/CodeTools/Source/TianoTools.msa b/Tools/CodeTools/Source/TianoTools.msa
new file mode 100644 (file)
index 0000000..2e4b27c
--- /dev/null
@@ -0,0 +1,316 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">\r
+  <MsaHeader>\r
+    <ModuleName>Tiano C Tools</ModuleName>\r
+    <ModuleType>TOOL</ModuleType>\r
+    <GuidValue>A169C678-3F55-4b6a-80BF-FD8B8DCAB883</GuidValue>\r
+    <Version>2.0</Version>\r
+    <Abstract>This is the TianoTools Module</Abstract>\r
+    <Description>This Module provides the EFI/Tiano Tools that are used to create EFI/Tiano
+      Modules and Platform Binary Files (PBF)
+      These tools require compilation only once if the Developer Workstation and
+      the Developer's choice of HOST tool chain are stable.  If the developer
+      updates either the OS or the HOST tool chain, these tools should be rebuilt.</Description>\r
+    <Copyright>Copyright 2006, Intel Corporation</Copyright>\r
+    <License URL="http://opensource.org/licenses/bsd-license.php">All rights reserved.  This program and the accompanying materials
+are licensed and made available under the terms and conditions of the 
+BSD License which accompanies this distribution.  The full text of the 
+license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.</License>\r
+    <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION   0x00000052</Specification>\r
+  </MsaHeader>\r
+  <ModuleDefinitions>\r
+    <SupportedArchitectures>EBC IA32 X64 IPF</SupportedArchitectures>\r
+    <BinaryModule>false</BinaryModule>\r
+    <OutputFileBasename>NULL</OutputFileBasename>\r
+  </ModuleDefinitions>\r
+  <SourceFiles>\r
+    <Filename>build.xml</Filename>\r
+    <Filename>Common/build.xml</Filename>\r
+    <Filename>Common/CommonLib.c</Filename>\r
+    <Filename>Common/CommonLib.h</Filename>\r
+    <Filename>Common/Crc32.c</Filename>\r
+    <Filename>Common/Crc32.h</Filename>\r
+    <Filename>Common/EfiCompress.c</Filename>\r
+    <Filename>Common/EfiCompress.h</Filename>\r
+    <Filename>Common/EfiCustomizedCompress.h</Filename>\r
+    <Filename>Common/EfiDecompress.c</Filename>\r
+    <Filename>Common/EfiDecompress.h</Filename>\r
+    <Filename>Common/EfiUtilityMsgs.c</Filename>\r
+    <Filename>Common/EfiUtilityMsgs.h</Filename>\r
+    <Filename>Common/FvLib.c</Filename>\r
+    <Filename>Common/FvLib.h</Filename>\r
+    <Filename>Common/MyAlloc.c</Filename>\r
+    <Filename>Common/MyAlloc.h</Filename>\r
+    <Filename>Common/ParseInf.c</Filename>\r
+    <Filename>Common/ParseInf.h</Filename>\r
+    <Filename>Common/SimpleFileParsing.c</Filename>\r
+    <Filename>Common/SimpleFileParsing.h</Filename>\r
+    <Filename>Common/WinNtInclude.h</Filename>\r
+    <Filename>CompressDll/build.xml</Filename>\r
+    <Filename>CompressDll/CompressDll.c</Filename>\r
+    <Filename>CompressDll/CompressDll.h</Filename>\r
+    <Filename>CreateMtFile/build.xml</Filename>\r
+    <Filename>CreateMtFile/CreateMtFile.c</Filename>\r
+    <Filename>CustomizedCompress/build.xml</Filename>\r
+    <Filename>CustomizedCompress/CustomizedCompress.c</Filename>\r
+    <Filename>EfiCompress/build.xml</Filename>\r
+    <Filename>EfiCompress/EfiCompressMain.c</Filename>\r
+    <Filename>EfiCompress/makefile</Filename>\r
+    <Filename>EfiRom/build.xml</Filename>\r
+    <Filename>EfiRom/EfiRom.c</Filename>\r
+    <Filename>FlashMap/build.xml</Filename>\r
+    <Filename>FlashMap/FlashDefFile.c</Filename>\r
+    <Filename>FlashMap/FlashDefFile.h</Filename>\r
+    <Filename>FlashMap/FlashMap.c</Filename>\r
+    <Filename>FlashMap/Microcode.c</Filename>\r
+    <Filename>FlashMap/Microcode.h</Filename>\r
+    <Filename>FlashMap/Symbols.c</Filename>\r
+    <Filename>FlashMap/Symbols.h</Filename>\r
+    <Filename>FwImage/build.xml</Filename>\r
+    <Filename>FwImage/fwimage.c</Filename>\r
+    <Filename>GenAcpiTable/build.xml</Filename>\r
+    <Filename>GenAcpiTable/GenAcpiTable.c</Filename>\r
+    <Filename>GenCapsuleHdr/build.xml</Filename>\r
+    <Filename>GenCapsuleHdr/CreateGuid.c</Filename>\r
+    <Filename>GenCapsuleHdr/GenCapsuleHdr.c</Filename>\r
+    <Filename>GenCRC32Section/build.xml</Filename>\r
+    <Filename>GenCRC32Section/GenCRC32Section.c</Filename>\r
+    <Filename>GenCRC32Section/GenCRC32Section.h</Filename>\r
+    <Filename>GenDepex/build.xml</Filename>\r
+    <Filename>GenDepex/DepexParser.c</Filename>\r
+    <Filename>GenDepex/DepexParser.h</Filename>\r
+    <Filename>GenDepex/GenDepex.c</Filename>\r
+    <Filename>GenDepex/GenDepex.h</Filename>\r
+    <Filename>GenFfsFile/build.xml</Filename>\r
+    <Filename>GenFfsFile/GenFfsFile.c</Filename>\r
+    <Filename>GenFfsFile/GenFfsFile.h</Filename>\r
+    <Filename>GenFfsFile/SimpleFileParsing.c</Filename>\r
+    <Filename>GenFvImage/build.xml</Filename>\r
+    <Filename>GenFvImage/Ebc/PeCoffLoaderEx.c</Filename>\r
+    <Filename>GenFvImage/GenFvImageExe.c</Filename>\r
+    <Filename>GenFvImage/GenFvImageExe.h</Filename>\r
+    <Filename>GenFvImage/GenFvImageLib.c</Filename>\r
+    <Filename>GenFvImage/GenFvImageLib.h</Filename>\r
+    <Filename>GenFvImage/GenFvImageLibInternal.h</Filename>\r
+    <Filename>GenSection/build.xml</Filename>\r
+    <Filename>GenSection/GenSection.c</Filename>\r
+    <Filename>GenSection/GenSection.h</Filename>\r
+    <Filename>GenTEImage/build.xml</Filename>\r
+    <Filename>GenTEImage/GenTEImage.c</Filename>\r
+    <Filename>GuidChk/build.xml</Filename>\r
+    <Filename>GuidChk/CommonUtils.h</Filename>\r
+    <Filename>GuidChk/FileSearch.c</Filename>\r
+    <Filename>GuidChk/FileSearch.h</Filename>\r
+    <Filename>GuidChk/GuidChk.c</Filename>\r
+    <Filename>GuidChk/GuidList.c</Filename>\r
+    <Filename>GuidChk/UtilsMsgs.c</Filename>\r
+    <Filename>GuidChk/UtilsMsgs.h</Filename>\r
+    <Filename>Include/Common/BaseTypes.h</Filename>\r
+    <Filename>Include/Common/Capsule.h</Filename>\r
+    <Filename>Include/Common/Dependency.h</Filename>\r
+    <Filename>Include/Common/EfiImage.h</Filename>\r
+    <Filename>Include/Common/FirmwareFileSystem.h</Filename>\r
+    <Filename>Include/Common/FirmwareVolumeHeader.h</Filename>\r
+    <Filename>Include/Common/FirmwareVolumeImageFormat.h</Filename>\r
+    <Filename>Include/Common/InternalFormRepresentation.h</Filename>\r
+    <Filename>Include/Common/MultiPhase.h</Filename>\r
+    <Filename>Include/Common/UefiBaseTypes.h</Filename>\r
+    <Filename>Include/Common/Variable.h</Filename>\r
+    <Filename>Include/Common/WorkingBlockHeader.h</Filename>\r
+    <Filename>Include/Guid/AcpiTableStorage.h</Filename>\r
+    <Filename>Include/Guid/Apriori.h</Filename>\r
+    <Filename>Include/Guid/Capsule.h</Filename>\r
+    <Filename>Include/Guid/FirmwareFileSystem.h</Filename>\r
+    <Filename>Include/Ia32/ProcessorBind.h</Filename>\r
+    <Filename>Include/IndustryStandard/pci22.h</Filename>\r
+    <Filename>Include/Library/PeCoffLib.h</Filename>\r
+    <Filename>Include/Library/PrintLib.h</Filename>\r
+    <Filename>Include/Protocol/DevicePath.h</Filename>\r
+    <Filename>Include/Protocol/GuidedSectionExtraction.h</Filename>\r
+    <Filename>Include/Protocol/Hii.h</Filename>\r
+    <Filename>Include/Protocol/UgaDraw.h</Filename>\r
+    <Filename>MakeDeps/build.xml</Filename>\r
+    <Filename>MakeDeps/MakeDeps.c</Filename>\r
+    <Filename>ModifyInf/build.xml</Filename>\r
+    <Filename>ModifyInf/ModifyInf.c</Filename>\r
+    <Filename>Pccts/antlr/antlr.1</Filename>\r
+    <Filename>Pccts/antlr/antlr.c</Filename>\r
+    <Filename>Pccts/antlr/antlr.g</Filename>\r
+    <Filename>Pccts/antlr/antlr.ilk</Filename>\r
+    <Filename>Pccts/antlr/antlr.pdb</Filename>\r
+    <Filename>Pccts/antlr/antlr.r</Filename>\r
+    <Filename>Pccts/antlr/antlr1.txt</Filename>\r
+    <Filename>Pccts/antlr/AntlrMS.mak</Filename>\r
+    <Filename>Pccts/antlr/AntlrPPC.mak</Filename>\r
+    <Filename>Pccts/antlr/bits.c</Filename>\r
+    <Filename>Pccts/antlr/build.c</Filename>\r
+    <Filename>Pccts/antlr/build.xml</Filename>\r
+    <Filename>Pccts/antlr/dumpcycles.c</Filename>\r
+    <Filename>Pccts/antlr/dumpnode.c</Filename>\r
+    <Filename>Pccts/antlr/egman.c</Filename>\r
+    <Filename>Pccts/antlr/err.c</Filename>\r
+    <Filename>Pccts/antlr/fcache.c</Filename>\r
+    <Filename>Pccts/antlr/fset.c</Filename>\r
+    <Filename>Pccts/antlr/fset2.c</Filename>\r
+    <Filename>Pccts/antlr/gen.c</Filename>\r
+    <Filename>Pccts/antlr/generic.h</Filename>\r
+    <Filename>Pccts/antlr/globals.c</Filename>\r
+    <Filename>Pccts/antlr/hash.c</Filename>\r
+    <Filename>Pccts/antlr/hash.h</Filename>\r
+    <Filename>Pccts/antlr/lex.c</Filename>\r
+    <Filename>Pccts/antlr/main.c</Filename>\r
+    <Filename>Pccts/antlr/makefile</Filename>\r
+    <Filename>Pccts/antlr/makefile1</Filename>\r
+    <Filename>Pccts/antlr/misc.c</Filename>\r
+    <Filename>Pccts/antlr/mode.h</Filename>\r
+    <Filename>Pccts/antlr/mrhoist.c</Filename>\r
+    <Filename>Pccts/antlr/parser.dlg</Filename>\r
+    <Filename>Pccts/antlr/pred.c</Filename>\r
+    <Filename>Pccts/antlr/proto.h</Filename>\r
+    <Filename>Pccts/antlr/README</Filename>\r
+    <Filename>Pccts/antlr/scan.c</Filename>\r
+    <Filename>Pccts/antlr/stdpccts.h</Filename>\r
+    <Filename>Pccts/antlr/syn.h</Filename>\r
+    <Filename>Pccts/antlr/tokens.h</Filename>\r
+    <Filename>Pccts/antlr/vc70.pdb</Filename>\r
+    <Filename>Pccts/build.xml</Filename>\r
+    <Filename>Pccts/CHANGES_FROM_131.txt</Filename>\r
+    <Filename>Pccts/CHANGES_FROM_133.txt</Filename>\r
+    <Filename>Pccts/CHANGES_FROM_133_BEFORE_MR13.txt</Filename>\r
+    <Filename>Pccts/CHANGES_SUMMARY.txt</Filename>\r
+    <Filename>Pccts/dlg/automata.c</Filename>\r
+    <Filename>Pccts/dlg/build.xml</Filename>\r
+    <Filename>Pccts/dlg/dlg.1</Filename>\r
+    <Filename>Pccts/dlg/dlg.h</Filename>\r
+    <Filename>Pccts/dlg/dlg.r</Filename>\r
+    <Filename>Pccts/dlg/dlg1.txt</Filename>\r
+    <Filename>Pccts/dlg/dlg_a.c</Filename>\r
+    <Filename>Pccts/dlg/dlg_p.c</Filename>\r
+    <Filename>Pccts/dlg/dlg_p.g</Filename>\r
+    <Filename>Pccts/dlg/DlgMS.mak</Filename>\r
+    <Filename>Pccts/dlg/DlgPPC.mak</Filename>\r
+    <Filename>Pccts/dlg/err.c</Filename>\r
+    <Filename>Pccts/dlg/main.c</Filename>\r
+    <Filename>Pccts/dlg/makefile</Filename>\r
+    <Filename>Pccts/dlg/makefile1</Filename>\r
+    <Filename>Pccts/dlg/mode.h</Filename>\r
+    <Filename>Pccts/dlg/output.c</Filename>\r
+    <Filename>Pccts/dlg/parser.dlg</Filename>\r
+    <Filename>Pccts/dlg/relabel.c</Filename>\r
+    <Filename>Pccts/dlg/stdpccts.h</Filename>\r
+    <Filename>Pccts/dlg/support.c</Filename>\r
+    <Filename>Pccts/dlg/tokens.h</Filename>\r
+    <Filename>Pccts/h/antlr.h</Filename>\r
+    <Filename>Pccts/h/AParser.cpp</Filename>\r
+    <Filename>Pccts/h/AParser.h</Filename>\r
+    <Filename>Pccts/h/ast.c</Filename>\r
+    <Filename>Pccts/h/ast.h</Filename>\r
+    <Filename>Pccts/h/ASTBase.cpp</Filename>\r
+    <Filename>Pccts/h/ASTBase.h</Filename>\r
+    <Filename>Pccts/h/AToken.h</Filename>\r
+    <Filename>Pccts/h/ATokenBuffer.cpp</Filename>\r
+    <Filename>Pccts/h/ATokenBuffer.h</Filename>\r
+    <Filename>Pccts/h/ATokenStream.h</Filename>\r
+    <Filename>Pccts/h/ATokPtr.h</Filename>\r
+    <Filename>Pccts/h/ATokPtrImpl.h</Filename>\r
+    <Filename>Pccts/h/BufFileInput.cpp</Filename>\r
+    <Filename>Pccts/h/BufFileInput.h</Filename>\r
+    <Filename>Pccts/h/charbuf.h</Filename>\r
+    <Filename>Pccts/h/charptr.c</Filename>\r
+    <Filename>Pccts/h/charptr.h</Filename>\r
+    <Filename>Pccts/h/config.h</Filename>\r
+    <Filename>Pccts/h/DLexer.h</Filename>\r
+    <Filename>Pccts/h/DLexerBase.cpp</Filename>\r
+    <Filename>Pccts/h/DLexerBase.h</Filename>\r
+    <Filename>Pccts/h/DLG_stream_input.h</Filename>\r
+    <Filename>Pccts/h/dlgauto.h</Filename>\r
+    <Filename>Pccts/h/dlgdef.h</Filename>\r
+    <Filename>Pccts/h/err.h</Filename>\r
+    <Filename>Pccts/h/int.h</Filename>\r
+    <Filename>Pccts/h/PBlackBox.h</Filename>\r
+    <Filename>Pccts/h/pccts_assert.h</Filename>\r
+    <Filename>Pccts/h/pccts_iostream.h</Filename>\r
+    <Filename>Pccts/h/pccts_istream.h</Filename>\r
+    <Filename>Pccts/h/pccts_setjmp.h</Filename>\r
+    <Filename>Pccts/h/pccts_stdarg.h</Filename>\r
+    <Filename>Pccts/h/pccts_stdio.h</Filename>\r
+    <Filename>Pccts/h/pccts_stdlib.h</Filename>\r
+    <Filename>Pccts/h/pccts_string.h</Filename>\r
+    <Filename>Pccts/h/PCCTSAST.cpp</Filename>\r
+    <Filename>Pccts/h/PCCTSAST.h</Filename>\r
+    <Filename>Pccts/h/pcctscfg.h</Filename>\r
+    <Filename>Pccts/h/pcnames.bat</Filename>\r
+    <Filename>Pccts/h/slist.cpp</Filename>\r
+    <Filename>Pccts/h/SList.h</Filename>\r
+    <Filename>Pccts/history.ps</Filename>\r
+    <Filename>Pccts/history.txt</Filename>\r
+    <Filename>Pccts/KNOWN_PROBLEMS.txt</Filename>\r
+    <Filename>Pccts/makefile</Filename>\r
+    <Filename>Pccts/MPW_Read_Me</Filename>\r
+    <Filename>Pccts/NOTES.bcc</Filename>\r
+    <Filename>Pccts/NOTES.msvc</Filename>\r
+    <Filename>Pccts/README</Filename>\r
+    <Filename>Pccts/RIGHTS</Filename>\r
+    <Filename>Pccts/support/genmk/genmk.c</Filename>\r
+    <Filename>Pccts/support/genmk/genmk_old.c</Filename>\r
+    <Filename>Pccts/support/genmk/makefile</Filename>\r
+    <Filename>Pccts/support/rexpr/makefile</Filename>\r
+    <Filename>Pccts/support/rexpr/rexpr.c</Filename>\r
+    <Filename>Pccts/support/rexpr/rexpr.h</Filename>\r
+    <Filename>Pccts/support/rexpr/test.c</Filename>\r
+    <Filename>Pccts/support/set/set.c</Filename>\r
+    <Filename>Pccts/support/set/set.h</Filename>\r
+    <Filename>Pccts/support/sym/sym.c</Filename>\r
+    <Filename>Pccts/support/sym/template.h</Filename>\r
+    <Filename>PeCoffLoader/BasePeCoff.c</Filename>\r
+    <Filename>PeCoffLoader/build.xml</Filename>\r
+    <Filename>PeCoffLoader/Common/EfiImage.h</Filename>\r
+    <Filename>PeCoffLoader/Ia32/PeCoffLoaderEx.c</Filename>\r
+    <Filename>PeCoffLoader/Ipf/PeCoffLoaderEx.c</Filename>\r
+    <Filename>PeCoffLoader/X64/PeCoffLoaderEx.c</Filename>\r
+    <Filename>PeiRebase/build.xml</Filename>\r
+    <Filename>PeiRebase/makefile</Filename>\r
+    <Filename>PeiRebase/PeiRebaseExe.c</Filename>\r
+    <Filename>PeiRebase/PeiRebaseExe.h</Filename>\r
+    <Filename>SecApResetVectorFixup/build.xml</Filename>\r
+    <Filename>SecApResetVectorFixup/SecApResetVectorFixup.c</Filename>\r
+    <Filename>SecApResetVectorFixup/SecApResetVectorFixup.h</Filename>\r
+    <Filename>SecFixup/build.xml</Filename>\r
+    <Filename>SecFixup/SecFixup.c</Filename>\r
+    <Filename>SecFixup/SecFixup.h</Filename>\r
+    <Filename>SetStamp/build.xml</Filename>\r
+    <Filename>SetStamp/SetStamp.c</Filename>\r
+    <Filename>SplitFile/build.xml</Filename>\r
+    <Filename>SplitFile/SplitFile.c</Filename>\r
+    <Filename>StrGather/build.xml</Filename>\r
+    <Filename>StrGather/StrGather.c</Filename>\r
+    <Filename>StrGather/StrGather.h</Filename>\r
+    <Filename>StrGather/StringDB.c</Filename>\r
+    <Filename>StrGather/StringDB.h</Filename>\r
+    <Filename>String/build.xml</Filename>\r
+    <Filename>String/PrintLib.c</Filename>\r
+    <Filename>String/PrintLibInternal.c</Filename>\r
+    <Filename>String/PrintLibInternal.h</Filename>\r
+    <Filename>String/String.c</Filename>\r
+    <Filename>Strip/build.xml</Filename>\r
+    <Filename>Strip/Strip.c</Filename>\r
+    <Filename>VfrCompile/build.xml</Filename>\r
+    <Filename>VfrCompile/DLGLexer.cpp</Filename>\r
+    <Filename>VfrCompile/DLGLexer.h</Filename>\r
+    <Filename>VfrCompile/EfiVfr.h</Filename>\r
+    <Filename>VfrCompile/EfiVfrParser.cpp</Filename>\r
+    <Filename>VfrCompile/EfiVfrParser.h</Filename>\r
+    <Filename>VfrCompile/parser.dlg</Filename>\r
+    <Filename>VfrCompile/tokens.h</Filename>\r
+    <Filename>VfrCompile/VfrCompile.cpp</Filename>\r
+    <Filename>VfrCompile/VfrCompile.g</Filename>\r
+    <Filename>VfrCompile/VfrServices.cpp</Filename>\r
+    <Filename>VfrCompile/VfrServices.h</Filename>\r
+    <Filename>ZeroDebugData/build.xml</Filename>\r
+    <Filename>ZeroDebugData/ZeroDebugData.c</Filename>\r
+  </SourceFiles>\r
+</ModuleSurfaceArea>
\ No newline at end of file
diff --git a/Tools/CodeTools/Source/VfrCompile/EfiVfr.h b/Tools/CodeTools/Source/VfrCompile/EfiVfr.h
new file mode 100644 (file)
index 0000000..6419ad7
--- /dev/null
@@ -0,0 +1,181 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2005, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  EfiVfr.h\r
+\r
+Abstract:\r
+\r
+  Defines and prototypes for the EFI internal forms representation\r
+  setup protocol and drivers\r
+  \r
+--*/\r
+\r
+#ifndef _EFI_VFR_H_\r
+#define _EFI_VFR_H_\r
+\r
+#include <string.h>\r
+\r
+#include <Common/UefiBaseTypes.h>\r
+#include <Common/InternalFormRepresentation.h>\r
+\r
+//\r
+// This number should be incremented with each change to the VFR compiler.\r
+// We write the version to the output list file for debug purposes.\r
+//\r
+#define VFR_COMPILER_VERSION  "1.88"\r
+\r
+//\r
+// Maximum file path for filenames\r
+//\r
+#ifndef MAX_PATH\r
+#define MAX_PATH        255\r
+#endif\r
+#define MAX_QUEUE_COUNT 255\r
+#define MAX_LINE_LEN    1024\r
+#define PROGRAM_NAME    "VfrCompile"\r
+\r
+//\r
+// We parse C-style structure definitions which can then be referenced\r
+// in VFR statements.\r
+// We need to define an internal structure that can be used to\r
+// track the fields in a structure definition, and another structure\r
+// to keep track of the structure name and subfields.\r
+//\r
+typedef struct _STRUCT_FIELD_DEFINITION {\r
+  struct _STRUCT_FIELD_DEFINITION *Next;\r
+  int                             DataSize;\r
+  int                             Offset;     // from the start of the structure\r
+  int                             ArrayLength;\r
+  char                            IsArray;\r
+  char                            *Name;\r
+} STRUCT_FIELD_DEFINITION;\r
+\r
+typedef struct _STRUCT_DEFINITION {\r
+  struct _STRUCT_DEFINITION *Next;\r
+  int                       Size;\r
+  int                       LineNum;          // line number where the structure was defined\r
+  int                       IsNonNV;          // if this is the non-NV data structure definition\r
+  int                       Referenced;       // if it's referenced anywhere in the VFR\r
+  int                       VarStoreIdValid;  // found a 'varstore' statement for it in the VFR\r
+  unsigned short            VarStoreId;       // key from a varstore IFR statement\r
+  int                       VarStoreLineNum;  // line number where VARSTORE was defined\r
+  char                      *Name;\r
+  STRUCT_FIELD_DEFINITION   *Field;\r
+  STRUCT_FIELD_DEFINITION   *LastField;\r
+} STRUCT_DEFINITION;\r
+\r
+//\r
+// For the IdEqValList variable list of UINT16's, keep track of them using\r
+// a linked list until we know how many there are.\r
+// We also use a linked list of these to keep track of labels used in\r
+// the VFR script so we can catch duplicates.\r
+// We'll also use it to keep track of defined varstore id's so we can\r
+// detect duplicate definitions.\r
+//\r
+typedef struct _UINT16_LIST {\r
+  struct _UINT16_LIST *Next;\r
+  UINT16              Value;\r
+  UINT32              LineNum;\r
+} UINT16_LIST;\r
+\r
+typedef struct _GOTO_REFERENCE {\r
+  struct _GOTO_REFERENCE  *Next;\r
+  UINT32                  RefLineNum; // line number of source file where referenced\r
+  UINT16                  Value;\r
+} GOTO_REFERENCE;\r
+\r
+typedef struct _FORM_ID_VALUE {\r
+  struct _FORM_ID_VALUE *Next;\r
+  UINT32                LineNum;\r
+  UINT16                Value;\r
+} FORM_ID_VALUE;\r
+\r
+//\r
+// We keep track in the parser of all "#line 4 "x.y"" strings so we\r
+// can cross-reference the line numbers in the preprocessor output .i file\r
+// to the original input files.\r
+//\r
+typedef struct _PARSER_LINE_DEFINITION {\r
+  struct _PARSER_LINE_DEFINITION  *Next;\r
+  UINT32                          HashLineNum;  // from the #line stmt\r
+  UINT32                          TokenLineNum; // line number in the .i file\r
+  CHAR8                           *FileName;    // from the #line stmt\r
+} PARSER_LINE_DEFINITION;\r
+\r
+extern PARSER_LINE_DEFINITION *gLineDefinition;\r
+extern PARSER_LINE_DEFINITION *gLastLineDefinition;\r
+\r
+extern\r
+char                          *\r
+ConvertLineNumber (\r
+  UINT32 *LineNum\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Given the line number in the preprocessor-output file, use the line number\r
+  information we've saved to determine the source file name and line number\r
+  where the code originally came from. This is required for error reporting.\r
+\r
+Arguments:\r
+  LineNum - the line number in the preprocessor-output file.\r
+\r
+Returns:\r
+  Returns a pointer to the source file name. Also returns the line number \r
+  in the provided LineNum argument\r
+\r
+--*/\r
+;\r
+\r
+typedef struct _IFR_BYTE {\r
+  struct _IFR_BYTE  *Next;\r
+  UINT32            LineNum;\r
+  UINT8             OpcodeByte;\r
+  UINT8             KeyByte;\r
+} IFR_BYTE;\r
+\r
+typedef struct {\r
+  CHAR8 VfrFileName[MAX_PATH];\r
+  CHAR8 VfrListFileName[MAX_PATH];\r
+  INT8  CreateListFile;\r
+  INT8  CreateIfrBinFile;\r
+  CHAR8 IfrOutputFileName[MAX_PATH];\r
+  CHAR8 OutputDirectory[MAX_PATH];\r
+  CHAR8 PreprocessorOutputFileName[MAX_PATH];\r
+  CHAR8 VfrBaseFileName[MAX_PATH];  // name of input VFR file with no path or extension\r
+  CHAR8 *IncludePaths;\r
+  CHAR8 *CPreprocessorOptions;\r
+} OPTIONS;\r
+\r
+extern OPTIONS  gOptions;\r
+\r
+VOID\r
+WriteStandardFileHeader (\r
+  FILE *OutFptr\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  This function is invoked to emit a standard header to an\r
+  output text file.\r
+  \r
+Arguments:\r
+  OutFptr - file to write the header to\r
+\r
+Returns:\r
+  None\r
+\r
+--*/\r
+;\r
+\r
+#endif // #ifndef _EFI_VFR_H_\r
diff --git a/Tools/CodeTools/Source/VfrCompile/VfrCompile.g b/Tools/CodeTools/Source/VfrCompile/VfrCompile.g
new file mode 100644 (file)
index 0000000..44820bc
--- /dev/null
@@ -0,0 +1,3529 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2005, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  VfrCompile.g\r
+\r
+Abstract:\r
+\r
+  PCCTS parser and lexer definitions for the EFI VFR forms compiler\r
+  \r
+--*/  \r
+\r
+#header<<\r
+\r
+#include <Common/UefiBaseTypes.h>\r
+#include <Common/MultiPhase.h>\r
+#include <Common/InternalFormRepresentation.h>\r
+#include <Protocol/UgaDraw.h>\r
+#include <Protocol/Hii.h>\r
+\r
+#include "CommonLib.h"\r
+#include "EfiUtilityMsgs.h"\r
+#include "EfiVfr.h"\r
+#include "VfrServices.h"\r
+\r
+#include <ctype.h>\r
+#ifndef __GNUC__\r
+#include <direct.h>\r
+#include <process.h> // for spawn functions\r
+#else\r
+#include <unistd.h>\r
+#endif\r
+\r
+>>\r
+\r
+<<\r
+\r
+//\r
+// Base info for DLG-generated scanner\r
+//\r
+#include "DLexerBase.h"    \r
+\r
+//\r
+// Include the scanner file generated by DLG\r
+//\r
+#include "DLGLexer.h"    \r
+\r
+class DLGLexerVfr : public DLGLexer\r
+{\r
+public:\r
+  DLGLexerVfr (DLGFileInput *F) : DLGLexer (F) {};\r
+  INT32 errstd (char *Text) \r
+  { \r
+    printf ("unrecognized input '%s'\n", Text); \r
+  }\r
+\r
+};\r
+\r
+//\r
+// Base token definitions for ANTLR\r
+//\r
+#include "AToken.h"\r
+\r
+//\r
+// This is how we invoke the C preprocessor on the VFR source file\r
+// to resolve #defines, #includes, etc. To make C source files\r
+// shareable between VFR and drivers, define VFRCOMPILE so that\r
+// #ifdefs can be used in shared .h files.\r
+//\r
+#ifdef __GNUC__\r
+#define PREPROCESSOR_COMMAND        "gcc "\r
+#define PREPROCESSOR_OPTIONS        "-x c -E -P -DVFRCOMPILE "\r
+#define FILE_SEP_CHAR '/'\r
+#define FILE_SEP_STRING "/"\r
+#else\r
+#define PREPROCESSOR_COMMAND        "cl.exe "\r
+#define PREPROCESSOR_OPTIONS        "/nologo /P /TC /DVFRCOMPILE "\r
+#define FILE_SEP_CHAR '/'\r
+#define FILE_SEP_STRING "/"\r
+#endif\r
+\r
+typedef ANTLRCommonToken ANTLRToken;\r
+\r
+//\r
+// Specify the filename extensions for the files we generate.\r
+//\r
+#define VFR_BINARY_FILENAME_EXTENSION       ".c"\r
+#define VFR_LIST_FILENAME_EXTENSION         ".lst"\r
+\r
+static \r
+VOID \r
+Usage ();\r
+\r
+static \r
+STATUS \r
+ProcessArgs (\r
+  int         Argc, \r
+  char        *Argv[]\r
+  );\r
+\r
+static \r
+VOID \r
+Cleanup ();\r
+\r
+//\r
+// Globals\r
+//\r
+OPTIONS gOptions;\r
+\r
+int \r
+main (\r
+  int   argc, \r
+  char  **argv\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Application entry point function. Parse command-line arguments, \r
+  invoke the parser, clean up, and return.\r
+\r
+Arguments:\r
+  argc - standard argc passed to main() per C conventions\r
+  argv - standard argv passed to main() per C conventions\r
+\r
+Returns:\r
+  STATUS_SUCCESS - program executed with no errors or warnings\r
+  STATUS_WARNING - program executed with warnings\r
+  STATUS_ERROR   - non-recoverable errors encountered while processing\r
+\r
+--*/\r
+{\r
+  FILE      *VfrFptr;\r
+  char      *Cmd;\r
+  char      *Cptr;\r
+  int       Len;\r
+  STATUS    Status;\r
+    \r
+  //\r
+  // Set our program name for the error printing routines.\r
+  // Then set printing limits.\r
+  //\r
+  SetUtilityName (PROGRAM_NAME);\r
+  SetPrintLimits (20, 20, 30);\r
+  //\r
+  // Process the command-line arguments\r
+  //\r
+  if (ProcessArgs (argc, argv) != STATUS_SUCCESS) {\r
+    Usage ();\r
+    Cleanup();\r
+    return STATUS_ERROR;\r
+  }\r
+  VfrFptr = NULL;\r
+  //\r
+  // Verify the VFR script file exists\r
+  //\r
+  if ((VfrFptr = fopen (gOptions.VfrFileName, "r")) == NULL) {\r
+    Error (PROGRAM_NAME, 0, 0, gOptions.VfrFileName, "could not open input VFR file");\r
+    Cleanup();\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Now close the file and make a system call to run the preprocessor\r
+  // on it.\r
+  //\r
+  fclose (VfrFptr);\r
+  Len = strlen (PREPROCESSOR_OPTIONS) + strlen (gOptions.VfrFileName) + 10;\r
+  if (gOptions.CPreprocessorOptions != NULL) {\r
+    Len += strlen (gOptions.CPreprocessorOptions) + 1;\r
+  }\r
+  if (gOptions.IncludePaths != NULL) {\r
+    Len += strlen (gOptions.IncludePaths) + 1;\r
+  }\r
+  Cmd = (char *)malloc (Len);\r
+  if (Cmd == NULL) {\r
+    Error (PROGRAM_NAME, 0, 0, NULL, "could not allocate memory");\r
+    Cleanup();\r
+    return STATUS_ERROR;\r
+  }  \r
+  strcpy (Cmd, PREPROCESSOR_OPTIONS);\r
+  if (gOptions.IncludePaths != NULL) {\r
+    strcat (Cmd, gOptions.IncludePaths);\r
+    strcat (Cmd, " ");\r
+  }\r
+  if (gOptions.CPreprocessorOptions != NULL) {\r
+    strcat (Cmd, gOptions.CPreprocessorOptions);\r
+    strcat (Cmd, " ");\r
+  }\r
+  strcat (Cmd, gOptions.VfrFileName);\r
+#ifndef __GNUC__\r
+  Status = _spawnlp (_P_WAIT, PREPROCESSOR_COMMAND, Cmd, NULL);\r
+#else\r
+  {\r
+    char CommandLine[1000];\r
+    char *p;\r
+\r
+    //\r
+    // Lean the slashes forward.\r
+    //\r
+    for (p = gOptions.PreprocessorOutputFileName; *p; p++) {\r
+      if (*p=='\\') {\r
+        *p=FILE_SEP_CHAR;\r
+      }\r
+    }\r
\r
+    //\r
+    // Lean the slashes forward.\r
+    //\r
+    for (p = Cmd; *p; p++) {\r
+      if (*p=='\\') {\r
+        *p=FILE_SEP_CHAR;\r
+      }\r
+    }\r
\r
+    sprintf(CommandLine, "%s %s > %s", PREPROCESSOR_COMMAND, Cmd, gOptions.PreprocessorOutputFileName);\r
+    Status = system (CommandLine);\r
+  }\r
+#endif\r
+  if (Status != 0) {\r
+    Error (PROGRAM_NAME, 0, 0, gOptions.VfrFileName, "failed to spawn C preprocessor on VFR file");\r
+    printf ("Command: '%s %s'\n", PREPROCESSOR_COMMAND, Cmd);\r
+    Cleanup();\r
+    return STATUS_ERROR;\r
+  }\r
+  free (Cmd);\r
+  //\r
+  // Open the preprocessor output file\r
+  //\r
+  if ((VfrFptr = fopen (gOptions.PreprocessorOutputFileName, "r")) == NULL) {\r
+    Error (PROGRAM_NAME, 0, 0, "failed to open input VFR preprocessor output file", \r
+      gOptions.PreprocessorOutputFileName);\r
+    Cleanup();\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // Define input VFR file\r
+  //\r
+  DLGFileInput InputFile (VfrFptr);\r
+  //\r
+  // Define an instance of the scanner    \r
+  //\r
+  DLGLexerVfr Scanner (&InputFile);\r
+  //\r
+  // Define token buffer between scanner and parser\r
+  //\r
+  ANTLRTokenBuffer Pipe (&Scanner);    \r
+  //\r
+  // Create a token to use as a model\r
+  //\r
+  ANTLRToken Tok;     \r
+  //\r
+  // Tell the scanner what type the token is\r
+  //\r
+  Scanner.setToken (&Tok);    \r
+  //\r
+  // Create an instance of our parser\r
+  //\r
+  EfiVfrParser Parser (&Pipe);    \r
+  //\r
+  // Initialize the parser    \r
+  //\r
+  Parser.init ();\r
+  Status = GetUtilityStatus ();\r
+  if (Status != STATUS_SUCCESS) {\r
+    Cleanup();\r
+    return Status;\r
+  }  \r
+  //\r
+  // Start the first rule    \r
+  //\r
+  Parser.program ();\r
+  //\r
+  // Close the input script file\r
+  //\r
+  fclose (VfrFptr);\r
+  Parser.WriteIfrBytes ();\r
+  //\r
+  // Call cleanup, which does some extra checking of the script\r
+  //\r
+  Parser.Cleanup ();\r
+  Cleanup();\r
+  //\r
+  // If we had an error somewhere, delete our output files so that\r
+  // a subsequent build will rebuild them.\r
+  //\r
+  Status = GetUtilityStatus ();\r
+  if (Status == STATUS_ERROR) {\r
+    remove (gOptions.IfrOutputFileName);\r
+  }\r
+  return Status;\r
+}\r
+static\r
+VOID\r
+Cleanup ()\r
+/*++\r
+\r
+Routine Description:\r
+  Free up memory allocated during parsing.\r
+\r
+Arguments:\r
+  None\r
+\r
+Returns:\r
+  None\r
+\r
+--*/\r
+{\r
+  //\r
+  // Free up our string we allocated to track the include paths\r
+  //\r
+  if (gOptions.IncludePaths != NULL) {\r
+    free (gOptions.IncludePaths);\r
+    gOptions.IncludePaths = NULL;\r
+  }\r
+  //\r
+  // Free up our string we allocated to track preprocessor options\r
+  //\r
+  if (gOptions.CPreprocessorOptions != NULL) {\r
+    free (gOptions.CPreprocessorOptions);\r
+    gOptions.CPreprocessorOptions = NULL;\r
+  }\r
+}  \r
+\r
+static\r
+STATUS\r
+ProcessArgs (\r
+  int         Argc, \r
+  char        *Argv[]\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Process the command-line arguments.\r
+\r
+Arguments:\r
+  Argc - standard argc passed to main()\r
+  Argv - standard argv passed to main()\r
+\r
+Returns:\r
+  STATUS_SUCCESS - program should continue (all args ok)\r
+\r
+--*/\r
+{\r
+  char    *IncludePaths;\r
+  char    *CPreprocessorOptions;\r
+  int     Len;  \r
+  char    CopyStr[MAX_PATH];\r
+  char    *Cptr;\r
+\r
+  //\r
+  // Put options in known state.\r
+  //\r
+  memset ((char *)&gOptions, 0, sizeof (OPTIONS));\r
+  //\r
+  // Go through all the arguments that start with '-'\r
+  //\r
+  Argc--;\r
+  Argv++;\r
+  while ((Argc > 0) && (Argv[0][0] == '-')) {\r
+    //\r
+    // -? or -h help option -- return an error for printing usage\r
+    //\r
+    if ((stricmp (Argv[0], "-?") == 0) || (stricmp (Argv[0], "-h") == 0)) {\r
+      return STATUS_ERROR;\r
+      break;\r
+    //\r
+    // -l to create a listing output file\r
+    //\r
+    } else if (stricmp (Argv[0], "-l") == 0) {\r
+      gOptions.CreateListFile = 1;\r
+    //\r
+    // -I include_path option for finding include files. We'll pass this\r
+    // to the preprocessor. Turn them all into a single include string.\r
+    //\r
+    } else if (stricmp (Argv[0], "-i") == 0) {\r
+      if ((Argc < 2) || (Argv[1][0] == '-')) {\r
+        Error (PROGRAM_NAME, 0, 0, Argv[0], "missing path argument");\r
+        return STATUS_ERROR;\r
+      }\r
+      Argc--;\r
+      Argv++;\r
+      Len = strlen (" -I ");\r
+      Len += strlen (Argv[0]) + 2;\r
+      if (gOptions.IncludePaths != NULL) {\r
+        Len += strlen (gOptions.IncludePaths);\r
+      }\r
+      IncludePaths = (CHAR8 *)malloc (Len);\r
+      if (IncludePaths == NULL) {\r
+        Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");\r
+        return STATUS_ERROR;\r
+      }\r
+      IncludePaths[0] = 0;\r
+      if (gOptions.IncludePaths != NULL) {\r
+        strcpy (IncludePaths, gOptions.IncludePaths);\r
+        free (gOptions.IncludePaths);\r
+      }\r
+      strcat (IncludePaths, " -I ");\r
+      strcat (IncludePaths, Argv[0]);\r
+      gOptions.IncludePaths = IncludePaths;\r
+    //\r
+    // -od OutputDirectory to define a common directory for output files\r
+    //\r
+    } else if (stricmp (Argv[0], "-od") == 0) {\r
+      if ((Argc < 2) || (Argv[1][0] == '-')) {\r
+        Error (PROGRAM_NAME, 0, 0, Argv[0], "missing output directory name");\r
+        return STATUS_ERROR;\r
+      }\r
+      Argc--;\r
+      Argv++;\r
+      strcpy (gOptions.OutputDirectory, Argv[0]);\r
+    } else if (stricmp (Argv[0], "-ibin") == 0) {\r
+      gOptions.CreateIfrBinFile = 1;\r
+    } else if (stricmp (Argv[0], "-nostrings") == 0) {\r
+      // deprecated option\r
+    //\r
+    // -ppflag C-preprocessor-flag option for passing options to the C preprocessor.\r
+    // Turn them all into a single string.\r
+    //\r
+    } else if (stricmp (Argv[0], "-ppflag") == 0) {\r
+      if (Argc < 2) {\r
+        Error (PROGRAM_NAME, 0, 0, Argv[0], "missing C-preprocessor argument");\r
+        return STATUS_ERROR;\r
+      }\r
+      Argc--;\r
+      Argv++;\r
+      Len = strlen (Argv[0]) + 2;\r
+      if (gOptions.CPreprocessorOptions != NULL) {\r
+        Len += strlen (gOptions.CPreprocessorOptions);\r
+      }\r
+      CPreprocessorOptions = (CHAR8 *)malloc (Len);\r
+      if (CPreprocessorOptions == NULL) {\r
+        Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");\r
+        return STATUS_ERROR;\r
+      }\r
+      CPreprocessorOptions[0] = 0;\r
+      if (gOptions.CPreprocessorOptions != NULL) {\r
+        strcpy (CPreprocessorOptions, gOptions.CPreprocessorOptions);\r
+        free (gOptions.CPreprocessorOptions);\r
+      }\r
+      strcat (CPreprocessorOptions, " ");\r
+      strcat (CPreprocessorOptions, Argv[0]);\r
+      gOptions.CPreprocessorOptions = CPreprocessorOptions;\r
+    } else {\r
+      Error (PROGRAM_NAME, 0, 0, Argv[0], "unrecognized option");\r
+      return STATUS_ERROR;\r
+    }\r
+    Argc--;\r
+    Argv++;\r
+  }\r
+  //\r
+  // Must specify at least the vfr file name\r
+  //\r
+  if (Argc > 1) {\r
+    Error (PROGRAM_NAME, 0, 0, Argv[1], "unrecognized argument after VFR file name");\r
+    return STATUS_ERROR;\r
+  } else if (Argc < 1) {\r
+    Error (PROGRAM_NAME, 0, 0, NULL, "must specify VFR file name");\r
+    return STATUS_ERROR;\r
+  }\r
+  strcpy (gOptions.VfrFileName, Argv[0]);\r
+  //\r
+  // We run the preprocessor on the VFR file to manage #include statements.\r
+  // Unfortunately the preprocessor does not allow you to specify the\r
+  // output name or path of the resultant .i file, so we have to do\r
+  // some work. Here we'll extract the basename of the VFR file, then\r
+  // append .i on the end. \r
+  //\r
+  strcpy (CopyStr, gOptions.VfrFileName);\r
+  Cptr = CopyStr + strlen (CopyStr) - 1;\r
+  for (;(Cptr > CopyStr) && (*Cptr != '\\') && (*Cptr != ':') && (*Cptr != '/'); Cptr--);\r
+  if (Cptr == CopyStr) {\r
+    strcpy (gOptions.PreprocessorOutputFileName, Cptr);\r
+    strcpy (gOptions.VfrBaseFileName, Cptr);\r
+  } else {\r
+    strcpy (gOptions.PreprocessorOutputFileName, Cptr+1);\r
+    strcpy (gOptions.VfrBaseFileName, Cptr+1);\r
+  }\r
+  for (Cptr = gOptions.PreprocessorOutputFileName; *Cptr && (*Cptr != '.'); Cptr++);\r
+  strcpy (Cptr, ".i");\r
+  //\r
+  // Terminate the vfr file basename at the extension\r
+  //\r
+  for (Cptr = gOptions.VfrBaseFileName; *Cptr && (*Cptr != '.'); Cptr++) {\r
+  }\r
+  *Cptr = 0; \r
+  //\r
+  // If they defined an output directory, prepend all output files\r
+  // with the working directory. Output files of interest:\r
+  //    VfrListFileName             -- list file\r
+  //    IfrOutputFileName           -- IFR bytes \r
+  //    StringOutputFileName        -- string bytes\r
+  //    StringListFileName          -- not used\r
+  //    StringDefineFileName        -- #defines of string identifiers\r
+  //\r
+  // We have two cases:\r
+  //   1. Output directory (-od) not specified, in which case output files\r
+  //      go to the current working directory.\r
+  //   2. Output directory specified, in which case the output files\r
+  //      go directly to the specified directory.\r
+  //\r
+  if (gOptions.OutputDirectory[0] == 0) {\r
+    CopyStr[0] = 0;\r
+#ifndef __GNUC__\r
+    _getcwd (CopyStr, sizeof (CopyStr));\r
+#else\r
+    getcwd (CopyStr, sizeof (CopyStr));\r
+#endif\r
+    strcpy (gOptions.OutputDirectory, CopyStr);\r
+  }\r
+  //\r
+  // Make sure output directory has a trailing backslash\r
+  //\r
+  if (gOptions.OutputDirectory[strlen (gOptions.OutputDirectory) - 1] != '\\' ||\r
+      gOptions.OutputDirectory[strlen (gOptions.OutputDirectory) - 1] != '/') {\r
+    strcat (gOptions.OutputDirectory, FILE_SEP_STRING);\r
+  }\r
+  //\r
+  // Create the base output file name as: path\base, copy it to all the output\r
+  // filenames, and then add the appropriate extension to each.\r
+  //\r
+  strcpy (gOptions.VfrListFileName, gOptions.OutputDirectory);\r
+  strcat (gOptions.VfrListFileName, gOptions.VfrBaseFileName);\r
+  strcpy (gOptions.IfrOutputFileName, gOptions.VfrListFileName);\r
+  strcat (gOptions.VfrListFileName, VFR_LIST_FILENAME_EXTENSION);\r
+  strcat (gOptions.IfrOutputFileName, VFR_BINARY_FILENAME_EXTENSION);\r
+  //\r
+  // We set a default list file name, so if they do not\r
+  // want a list file, null out the name now.\r
+  //\r
+  if (gOptions.CreateListFile == 0) {\r
+    gOptions.VfrListFileName[0] = 0;\r
+  }\r
+  return STATUS_SUCCESS;\r
+}\r
+static \r
+VOID \r
+Usage ()\r
+/*++\r
+\r
+Routine Description:\r
+  Print utility usage instructions\r
+\r
+Arguments:\r
+  None\r
+\r
+Returns:\r
+  None\r
+\r
+--*/\r
+{\r
+  int Index;\r
+  const char *Help[] = {\r
+    " ", \r
+    "VfrCompile version " VFR_COMPILER_VERSION,\r
+    " ",\r
+    "  Usage: VfrCompile {options} [VfrFile]",\r
+    " ",\r
+    "    where options include:",\r
+    "      -? or -h       prints this help",\r
+    "      -l             create an output IFR listing file",\r
+    "      -i IncPath     add IncPath to the search path for VFR included files",\r
+    "      -od OutputDir  deposit all output files to directory OutputDir (default=cwd)",\r
+    "      -ibin          create an IFR HII pack file",\r
+    "    where parameters include:",\r
+    "      VfrFile        name of the input VFR script file",\r
+    " ",\r
+    NULL\r
+    };\r
+  for (Index = 0; Help[Index] != NULL; Index++) {\r
+    fprintf (stdout, "%s\n", Help[Index]);\r
+  }\r
+}\r
+    \r
+>>\r
+\r
+\r
+#lexaction\r
+<<\r
+\r
+#include "EfiVfr.h"\r
+\r
+PARSER_LINE_DEFINITION  *gLineDefinition = NULL;\r
+PARSER_LINE_DEFINITION  *gLastLineDefinition = NULL;\r
+\r
+VOID\r
+AddFileLine (\r
+  char      *TokenString,\r
+  UINT32    TokenLine\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  During the lexer phase, if we encounter a #line statement output by\r
+  the preprocessor, this function gets called. We'll save off the info \r
+  for error reporting purposes. The preprocessor line information has the\r
+  form:\r
+    \r
+    #line 3 "FileName.c"  \r
+\r
+Arguments:\r
+  TokenString - the parsed string as shown above\r
+  TokenLine   - the line number in the preprocessed output file \r
+  \r
+Returns:\r
+  NA\r
+\r
+--*/\r
+{\r
+  PARSER_LINE_DEFINITION  *LineDef;\r
+  CHAR8                   *Cptr;\r
+  \r
+  //\r
+  // Allocate a structure in which we can keep track of this line information.\r
+  //\r
+  LineDef = (PARSER_LINE_DEFINITION *)malloc (sizeof (PARSER_LINE_DEFINITION));\r
+  memset ((char *)LineDef, 0, sizeof (PARSER_LINE_DEFINITION));\r
+  LineDef->TokenLineNum = TokenLine;\r
+  LineDef->HashLineNum = atoi (TokenString + 6);\r
+  //\r
+  // Find the quotes in the filename, then allocate space in the line\r
+  // def structure for a copy of the filename. Finally, copy it without\r
+  // quotes to the line def.\r
+  //\r
+  for (Cptr = TokenString + 7; *Cptr && (*Cptr != '"'); Cptr++);\r
+  if (*Cptr == '"') {\r
+    LineDef->FileName = (CHAR8 *)malloc (strlen (Cptr));\r
+    Cptr++;\r
+    strcpy (LineDef->FileName, Cptr);\r
+    for (Cptr = LineDef->FileName; *Cptr && (*Cptr != '"'); Cptr++);\r
+    *Cptr = 0;   \r
+    //\r
+    // Now add this new one to the list\r
+    //\r
+    if (gLineDefinition == NULL) {\r
+      gLineDefinition = LineDef;\r
+    } else {\r
+      gLastLineDefinition->Next = LineDef;\r
+    }\r
+    gLastLineDefinition = LineDef;\r
+  } else {\r
+    Error (PROGRAM_NAME, 0, 0, "invalid line definition in preprocessor output file", TokenString);\r
+    free (LineDef);\r
+    return;\r
+  }\r
+}\r
+char *\r
+ConvertLineNumber (\r
+  UINT32 *LineNum\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Given the line number in the preprocessor-output file, use the line number\r
+  information we've saved to determine the source file name and line number\r
+  where the code originally came from. This is required for error reporting.\r
+\r
+Arguments:\r
+  LineNum - the line number in the preprocessor-output file.\r
+\r
+Returns:\r
+  Returns a pointer to the source file name. Also returns the line number \r
+  in the provided LineNum argument\r
+\r
+--*/\r
+{\r
+  PARSER_LINE_DEFINITION  *LineDef;\r
+  //\r
+  // Step through our linked list of #line information we saved off. \r
+  // For each one, look at its line number, and the line number of the\r
+  // next record, and see if the passed-in line number is in the range.\r
+  // If it is, then convert the line number to the appropriate line number\r
+  // of the original source file.\r
+  //\r
+  for (LineDef = gLineDefinition; LineDef != NULL; LineDef = LineDef->Next) {\r
+    //\r
+    // The given LineNum is the line number from the .i file.\r
+    // Find a line definition whose range includes this line number,\r
+    // convert the line number, and return the filename.\r
+    //\r
+    if (LineDef->TokenLineNum <= *LineNum) {\r
+      if (LineDef->Next != NULL) {\r
+        if (LineDef->Next->TokenLineNum > *LineNum) {\r
+          *LineNum = *LineNum - LineDef->TokenLineNum + LineDef->HashLineNum;\r
+          return LineDef->FileName;\r
+        }\r
+      } else {\r
+        //\r
+        // Last one in the list of line definitions, so has to be right\r
+        //\r
+        *LineNum = *LineNum - LineDef->TokenLineNum + LineDef->HashLineNum;\r
+        return LineDef->FileName;\r
+      }\r
+    }\r
+  }\r
+  return NULL;\r
+}\r
+\r
+>>\r
+\r
+//\r
+// Define a lexical class for parsing quoted strings. Basically\r
+// starts with a double quote, and ends with a double quote that\r
+// is not preceeded with a backslash.\r
+//\r
+#lexclass QUOTED_STRING\r
+#token TheString            "~[\"]*\"" << mode (START); >>     \r
+\r
+//\r
+// Define a lexical class for parsing "#pragma pack" statements. \r
+// We do this just for convenience (since we skip them here) so\r
+// that users can include some minimal .h files.\r
+//\r
+#lexclass PRAGMA_PACK\r
+#token "pack"     << skip (); >>\r
+#token "[\ \t]"   << skip (); >> \r
+#token "\("       << skip (); >>\r
+#token "[0-9]*"   << skip (); >>\r
+#token "\)"       << skip (); mode (START); >>\r
+\r
+//\r
+// Define a lexclass for skipping over C++ style comments\r
+//\r
+#lexclass CPP_COMMENT\r
+#token "~[\n]*"       << skip (); >>\r
+#token "\n"           << skip (); mode (START); newline (); >>\r
+\r
+//\r
+// Standard lexclass is START\r
+//\r
+#lexclass START\r
+\r
+//\r
+// Find start of C++ style comments\r
+//\r
+#token "//"     << skip (); mode (CPP_COMMENT); >>\r
+\r
+//\r
+// Skip whitespace\r
+//\r
+#token "[\ \t]"   << skip (); >> \r
+\r
+//\r
+// Skip over newlines, but count them\r
+//\r
+#token "\n"       << skip (); newline (); >>\r
+\r
+//\r
+// Skip pragma pack statements\r
+//\r
+#token "\#pragma" << skip (); mode(PRAGMA_PACK); >>\r
+\r
+//\r
+// Skip over 'extern' in any included .H file\r
+//\r
+#token "extern"   << skip (); >>\r
+\r
+//\r
+// Tokens for the different keywords. Syntax is:\r
+// TokenName("ErrorMessageText")    "TokenString"\r
+//   where:\r
+//     TokenName is the token name (must be capitalized) that is used in the rules\r
+//     ErrorMessageText is the string the compiler emits when it detects a syntax error\r
+//     TokenString is the actual matching string used in the user script\r
+//\r
+#token LineDefinition                           "#line\ [0-9]+\ \"~[\"]+\"[\ \t]*\n" << AddFileLine (begexpr (), line ()); skip (); >>\r
+#token FormSet("formset")                       "formset"\r
+#token EndFormSet("endformset")                 "endformset"\r
+#token Title("title")                           "title"\r
+#token FormId("formid")                         "formid"\r
+#token OneOf("oneof")                           "oneof"\r
+#token Prompt("prompt")                         "prompt"\r
+#token OrderedList("orderedlist")               "orderedlist"\r
+#token EndList("endlist")                       "endlist"\r
+#token EndForm("endform")                       "endform"\r
+#token EndOneOf("endoneof")                     "endoneof"\r
+#token Form("form")                             "form"\r
+#token Subtitle("subtitle")                     "subtitle"\r
+#token Help("help")                             "help"\r
+#token VarId("varid")                           "varid"\r
+#token Text("text")                             "text"\r
+#token Option("option")                         "option"\r
+#token Value("value")                           "value"\r
+#token Flags("flags")                           "flags"\r
+#token Date("date")                             "date"\r
+#token EndDate("enddate")                       "enddate"\r
+#token Year("year")                             "year"\r
+#token Month("month")                           "month"\r
+#token Day("day")                               "day"\r
+#token Time("time")                             "time"\r
+#token EndTime("endtime")                       "endtime"\r
+#token Hour("hour")                             "hour"\r
+#token Minute("minute")                         "minute"\r
+#token Second("second")                         "second"\r
+#token AND("AND")                               "AND"\r
+#token OR("OR")                                 "OR"\r
+#token GrayOutIf("grayoutif")                   "grayoutif"\r
+#token NOT("NOT")                               "NOT"\r
+#token Label("label")                           "label"\r
+#token Timeout("timeout")                       "timeout"\r
+#token Inventory("inventory")                   "inventory"\r
+#token StringToken("STRING_TOKEN")              "STRING_TOKEN"\r
+#token NonNvDataMap("_NON_NV_DATA_MAP")         "_NON_NV_DATA_MAP"\r
+#token Struct("struct")                         "struct"\r
+#token Uint64("UINT64")                         "UINT64"\r
+#token Uint32("UINT32")                         "UINT32"\r
+#token Uint16("UINT16")                         "UINT16"\r
+#token Char16("CHAR16")                         "CHAR16"\r
+#token Uint8("UINT8")                           "UINT8"\r
+#token Guid("guid")                             "guid"\r
+#token CheckBox("checkbox")                     "checkbox"\r
+#token EndCheckBox("endcheckbox")               "endcheckbox"\r
+#token Numeric("numeric")                       "numeric"\r
+#token EndNumeric("endnumeric")                 "endnumeric"            \r
+#token Minimum("minimum")                       "minimum"         \r
+#token Maximum("maximum")                       "maximum"         \r
+#token Step("step")                             "step"      \r
+#token Default("default")                       "default"         \r
+#token Password("password")                     "password"          \r
+#token EndPassword("endpassword")               "endpassword"             \r
+#token String("string")                         "string"        \r
+#token EndString("endstring")                   "endstring"           \r
+#token MinSize("minsize")                       "minsize"         \r
+#token MaxSize("maxsize")                       "maxsize"         \r
+#token Encoding("encoding")                     "encoding"\r
+#token SuppressIf("suppressif")                 "suppressif"\r
+#token Hidden("hidden")                         "hidden"\r
+#token Goto("goto")                             "goto"\r
+#token InconsistentIf                           "inconsistentif"\r
+#token EndIf("endif")                           "endif"\r
+#token IdEqId("ideqid")                         "ideqid"\r
+#token IdEqVal("ideqval")                       "ideqval"\r
+#token VarEqVal("vareqval")                     "vareqval"\r
+#token Var("var")                               "var"\r
+#token IdEqValList("ideqvallist")               "ideqvallist"\r
+#token Length("length")                         "length"\r
+#token Values("values")                         "values"\r
+#token Key("key")                               "key"\r
+#token DefaultFlag("DEFAULT")                   "DEFAULT"\r
+#token ManufacturingFlag("MANUFACTURING")       "MANUFACTURING"\r
+#token InteractiveFlag("INTERACTIVE")           "INTERACTIVE"\r
+#token NVAccessFlag("NV_ACCESS")                "NV_ACCESS"\r
+#token ResetRequiredFlag("RESET_REQUIRED")      "RESET_REQUIRED"\r
+#token LateCheckFlag("LATE_CHECK")              "LATE_CHECK"\r
+#token Class("class")                           "class"\r
+#token Subclass("subclass")                     "subclass"\r
+#token TypeDef("typedef")                       "typedef"\r
+#token Restore("restore")                       "restore"\r
+#token Save("save")                             "save"\r
+#token Defaults("defaults")                     "defaults"\r
+#token Banner("banner")                         "banner"\r
+#token Align("align")                           "align"\r
+#token Left("left")                             "left"\r
+#token Right("right")                           "right"\r
+#token Center("center")                         "center"\r
+#token Line("line")                             "line"\r
+#token VarStore("varstore")                     "varstore"\r
+#token Name("name")                             "name"\r
+#token Oem("oem")                               "oem"\r
+#token True("TRUE")                             "TRUE"\r
+#token False("FALSE")                           "FALSE"\r
+#token GreaterThan(">")                         ">"\r
+#token GreaterEqual(">=")                       ">="\r
+#token LessThan("<")                          "<"\r
+#token LessEqual("<=")                        "<="\r
+\r
+//\r
+// Define the class and subclass tokens\r
+//\r
+#token ClassNonDevice("NONDEVICE")                        "NON_DEVICE"\r
+#token ClassDiskDevice("DISK_DEVICE")                     "DISK_DEVICE"\r
+#token ClassVideoDevice("VIDEO_DEVICE")                   "VIDEO_DEVICE"\r
+#token ClassNetworkDevice("NETWORK_DEVICE")               "NETWORK_DEVICE"\r
+#token ClassInputDevice("INPUT_DEVICE")                   "INPUT_DEVICE"\r
+#token ClassOnBoardDevice("ONBOARD_DEVICE")               "ONBOARD_DEVICE"\r
+#token ClassOtherDevice("OTHER_DEVICE")                   "OTHER_DEVICE"\r
+\r
+#token SubclassSetupApplication("SETUP_APPLICATION")      "SETUP_APPLICATION"\r
+#token SubclassGeneralApplication("GENERAL_APPLICATION")  "GENERAL_APPLICATION"\r
+#token SubclassFrontPage("FRONT_PAGE")                    "FRONT_PAGE"\r
+#token SubclassSingleUse("SINGLE_USE")                    "SINGLE_USE"\r
+\r
+#token LanguageIdentifier("language identifier") "[a-z][a-z][a-z]"   // 3 lowercase characters\r
+#token StringIdentifier("string identifier")    "[A-Za-z_][A-Za-z_0-9]*"\r
+#token Number("numeric value")                  "(0x[0-9A-Fa-f]+) | [0-9]+"\r
+#token OpenBrace("{")                           "\{"\r
+#token CloseBrace("}")                          "\}"\r
+#token OpenParen("(")                           "\("\r
+#token CloseParen(")")                          "\)"\r
+#token OpenBracket("[")                         "\["\r
+#token CloseBracket("]")                        "\]"\r
+\r
+//\r
+// Define all other invalid characters so that they get through the lexical phase\r
+// and we can catch them during the parse phase. We get much better error\r
+// messages then. \r
+//\r
+#token InvalidCharacters("invalid characters")  "~[;:=,\.\|]"  \r
+\r
+//\r
+// This is the overall definition of a VFR form definition script.\r
+//\r
+program :\r
+  ( dataStructDefinition )*\r
+  formSetStatement   \r
+  ( vfrStatementVarStore )*\r
+  ( formDefinition )*\r
+  EFS:EndFormSet  ";"                   << WriteOpByte (EFS->getLine(), EFI_IFR_END_FORM_SET_OP); >>\r
+  "@" // end of file\r
+  ;\r
+    \r
+formSetStatement :\r
+  FS:FormSet                            << WriteOpByte (FS->getLine(), EFI_IFR_FORM_SET_OP); >>\r
+  Guid "=" \r
+  OpenBrace \r
+  G1:Number ","\r
+  G2:Number ","\r
+  G3:Number ","\r
+  OpenBrace\r
+  G4:Number ","\r
+  G5:Number ","\r
+  G6:Number ","\r
+  G7:Number ","\r
+  G8:Number ","\r
+  G9:Number ","\r
+  G10:Number ","\r
+  G11:Number \r
+  CloseBrace\r
+  CloseBrace                            << WriteGuidValue (G1->getLine (), G1->getText (), G2->getText (), G3->getText (),\r
+                                                           G4->getText (), G5->getText (), G6->getText (), G7->getText (),\r
+                                                           G8->getText (), G9->getText (), G10->getText (), G11->getText ()\r
+                                                          );\r
+                                         >>\r
+  ","\r
+  Title "=" getStringId ","\r
+  Help  "=" getStringId ","\r
+  //\r
+  // insert padding for an EFI_PHYSICAL_ADDRESS (UINT64)\r
+  //\r
+                                            << WriteDWord (0, 0); WriteDWord (0, 0); >>\r
+  Class "=" CVAL:classDefinition ","        << WriteClass (); >>\r
+  Subclass "=" SVAL:subclassDefinition ","  << WriteSubclass (); >>\r
+                                            << WriteWord (mNvDataStructSize); >>\r
+  ;  \r
+\r
+//\r
+// A form can be of multiple classes, thus allow CLASS_A | CLASS_B | CLASS_C\r
+//\r
+classDefinition :\r
+  validClassNames ( "\|" validClassNames )*\r
+  ;\r
+  \r
+validClassNames :\r
+    CND:ClassNonDevice          << SetClass (CND->getLine(), EFI_NON_DEVICE_CLASS); >>\r
+  | CDD:ClassDiskDevice         << SetClass (CDD->getLine(), EFI_DISK_DEVICE_CLASS); >>\r
+  | CVD:ClassVideoDevice        << SetClass (CVD->getLine(), EFI_VIDEO_DEVICE_CLASS); >>\r
+  | CNW:ClassNetworkDevice      << SetClass (CNW->getLine(), EFI_NETWORK_DEVICE_CLASS); >>\r
+  | CID:ClassInputDevice        << SetClass (CID->getLine(), EFI_INPUT_DEVICE_CLASS); >>\r
+  | COB:ClassOnBoardDevice      << SetClass (COB->getLine(), EFI_ON_BOARD_DEVICE_CLASS); >>\r
+  | COD:ClassOtherDevice        << SetClass (COD->getLine(), EFI_OTHER_DEVICE_CLASS); >>\r
+  | CNUM:Number                 << SetClass (CNUM->getLine(), GetNumber (CNUM->getText(), CNUM->getLine(), 4)); >>\r
+  ; << PrintErrorMessage (LT(1)->getLine(), LT(1)->getText(), "invalid class"); >>\r
+\r
+//\r
+// A form can only be of one subclass type.\r
+//\r
+subclassDefinition :\r
+    SSA:SubclassSetupApplication    << SetSubclass (SSA->getLine(), EFI_SETUP_APPLICATION_SUBCLASS); >>\r
+  | SGA:SubclassGeneralApplication  << SetSubclass (SGA->getLine(), EFI_GENERAL_APPLICATION_SUBCLASS); >>\r
+  | SFP:SubclassFrontPage           << SetSubclass (SFP->getLine(), EFI_FRONT_PAGE_SUBCLASS); >>\r
+  | SSU:SubclassSingleUse           << SetSubclass (SSU->getLine(), EFI_SINGLE_USE_SUBCLASS); >>\r
+  | SNUM:Number                     << SetSubclass (SNUM->getLine(), GetNumber (SNUM->getText(), SNUM->getLine(), 4)); >>\r
+  ; << PrintErrorMessage (LT(1)->getLine(), LT(1)->getText(), "invalid subclass"); >>\r
+\r
+//\r
+// Parse a C type data structure for storing VFR setup data. Allow:\r
+//  typedef struct _XXX_ {\r
+//     (fields)\r
+//  } MY_NV_DATA;\r
+//\r
+dataStructDefinition :\r
+  << int IsNonNV = 0; >>\r
+  { TypeDef } \r
+  S:Struct                          \r
+  (\r
+    NonNvDataMap                    << IsNonNV = 1; >>\r
+  |\r
+    { StringIdentifier }\r
+  )                                 << StartStructDefinition (IsNonNV, S->getLine()); >>\r
+  OpenBrace \r
+  dataStructFields \r
+  CloseBrace NAME:StringIdentifier  << EndStructDefinition (NAME->getText(), NAME->getLine()); >>\r
+  ";"\r
+  ;\r
+\r
+//\r
+// Parse a C type data structure for defining data that is not stored in NV.\r
+//  typedef struct _NON_NV_DATA_MAP {\r
+//     (fields)\r
+//  } NON_NV_DATA_MAP;\r
+//\r
+nonNvDataStructDefinition :\r
+  { TypeDef } \r
+  Struct NonNvDataMap\r
+  { StringIdentifier }\r
+  OpenBrace \r
+  dataStructFields \r
+  CloseBrace NAME:StringIdentifier        << AddStructField (NAME->getText(), NAME->getLine(), 0, 0, 0); >>\r
+  ";"                                             \r
+  ;\r
+\r
+dataStructFields :\r
+  ( dataStructField64 | dataStructField32 | dataStructField16 | dataStructField8 ) *\r
+  ;\r
+\r
+//*****************************************************************************\r
+//\r
+// PARSE:\r
+//   UINT64 Name[4];\r
+//   UINT64 Name;\r
+//\r
+// Used while parsing the NV data map structures.\r
+//\r
+dataStructField64 :\r
+  << int ArrayLength = 1; char IsArray = 0; >>\r
+  "UINT64" \r
+  NAME:StringIdentifier \r
+  ( ";" | OpenBracket IVal:Number CloseBracket ";"  << ArrayLength = GetNumber (IVal->getText(), IVal->getLine(), 4); IsArray = 1; >> ) \r
+                                                    << AddStructField (NAME->getText(), NAME->getLine(), 8, ArrayLength, IsArray); >>\r
+  ;\r
+\r
+//*****************************************************************************\r
+//\r
+// PARSE:\r
+//   UINT32 Name[4];\r
+//   UINT32 Name;\r
+//\r
+// Used while parsing the NV data map structures.\r
+//\r
+dataStructField32 :\r
+  << int ArrayLength = 1; char IsArray = 0; >>\r
+  "UINT32" \r
+  NAME:StringIdentifier \r
+  ( ";" | OpenBracket IVal:Number CloseBracket ";"  << ArrayLength = GetNumber (IVal->getText(), IVal->getLine(), 4); IsArray = 1; >> )  \r
+                                                    << AddStructField (NAME->getText(), NAME->getLine(), 4, ArrayLength, IsArray); >>\r
+  ;\r
+\r
+//*****************************************************************************\r
+//\r
+// PARSE:\r
+//   UINT16 Name[4];\r
+//   UINT16 Name;\r
+//\r
+// Used while parsing the NV data map structures.\r
+//\r
+dataStructField16 :\r
+  << int ArrayLength = 1; char IsArray = 0; >>\r
+  ( "UINT16" | "CHAR16" )\r
+  NAME:StringIdentifier \r
+  ( ";" | OpenBracket IVal:Number CloseBracket ";"  << ArrayLength = GetNumber (IVal->getText(), IVal->getLine(), 4); IsArray = 1; >> ) \r
+                                                    << AddStructField (NAME->getText(), NAME->getLine(), 2, ArrayLength, IsArray); >>\r
+  ;\r
+\r
+//*****************************************************************************\r
+//\r
+// PARSE:\r
+//   UINT8 Name[4];\r
+//   UINT8 Name;\r
+//\r
+// Used while parsing the NV data map structures.\r
+//\r
+dataStructField8 :\r
+  << int ArrayLength = 1; char IsArray = 0; >>\r
+  "UINT8" \r
+  NAME:StringIdentifier \r
+  ( ";" | OpenBracket IVal:Number CloseBracket ";"  << ArrayLength = GetNumber (IVal->getText(), IVal->getLine(), 4); IsArray = 1; >> ) \r
+                                                    << AddStructField (NAME->getText(), NAME->getLine(), 1, ArrayLength, IsArray); >>\r
+  ;\r
+\r
+//*****************************************************************************\r
+//\r
+// PARSE:\r
+//    form formid = 1,\r
+//      title  = STRING_TOKEN(STR_FORM_TITLE);\r
+//      -- form statements --\r
+//    endform;\r
+//\r
+//  The Form ID cannot be 0\r
+//\r
+formDefinition :\r
+  FRM:Form FormId                << WriteOpByte (FRM->getLine(), EFI_IFR_FORM_OP); >> \r
+  "=" \r
+  VAL:Number                     << WriteWord (GetNumber (VAL->getText(), VAL->getLine(), 2)); AddFormId (GetNumber (VAL->getText(), VAL->getLine(), 2), VAL->getLine()); >>\r
+  ","\r
+  Title "=" getStringId ";"      // writes string identifier\r
+  ( vfrStatements )*\r
+  ENDF:EndForm  ";"              << WriteOpByte (ENDF->getLine(), EFI_IFR_END_FORM_OP); >>\r
+  ;\r
+\r
+//\r
+// VFR statements in a formset\r
+//\r
+vfrStatements :\r
+  vfrStatementSubTitle        | \r
+  vfrStatementOneOf           |\r
+  vfrStatementTextText        |\r
+  vfrStatementCheckBox        |\r
+  vfrStatementNumeric         |\r
+  vfrStatementDate            |\r
+  vfrStatementTime            |\r
+  vfrStatementPassword        |\r
+  vfrStatementString          |\r
+  vfrStatementSuppressIf      |\r
+  vfrStatementHidden          |\r
+  vfrStatementGoto            | \r
+  vfrStatementGrayOutIf       |\r
+  vfrStatementInconsistentIf  |\r
+  vfrStatementLabel           |\r
+  vfrStatementBanner          |\r
+  vfrStatementInventory       |\r
+  vfrStatementOrderedList     |\r
+  vfrStatementOem             |\r
+  vfrStatementSaveRestoreDefaults\r
+  ;\r
+\r
+//*****************************************************************************\r
+//\r
+// PARSE:\r
+//   label 100;\r
+//\r
+vfrStatementLabel :\r
+  OPID:Label                              << WriteOpByte (OPID->getLine(), EFI_IFR_LABEL_OP); >>\r
+  VAL:Number                              << \r
+                                              WriteWord (GetNumber (VAL->getText(), VAL->getLine(), 2)); \r
+                                              AddLabel (GetNumber (VAL->getText(), VAL->getLine(), 2), VAL->getLine());\r
+                                          >>\r
+  ";"\r
+  ;\r
+\r
+//*****************************************************************************\r
+//\r
+// PARSE:\r
+//   oem 0x12, 0x34, 0x56;\r
+//\r
+vfrStatementOem :\r
+  OPID:Oem                              << WriteOpByte (OPID->getLine(), EFI_IFR_OEM_DEFINED_OP); >>\r
+  ( VAL1:Number << WriteByte (GetNumber (VAL1->getText(), VAL1->getLine(), 1), 0); >> )\r
+  ( "," VAL2:Number << WriteByte (GetNumber (VAL2->getText(), VAL2->getLine(), 1), 0); >> )*\r
+  ";"\r
+  ;\r
+  \r
+//*****************************************************************************\r
+//\r
+// PARSE:\r
+//   inconsistentif NOT .... AND NOT .... OR ... endif;\r
+//\r
+vfrStatementInconsistentIf : \r
+  << ResetFlags (); >>\r
+  IIFOP:InconsistentIf                  << WriteOpByte (IIFOP->getLine(), EFI_IFR_INCONSISTENT_IF_OP); >>\r
+  Prompt "=" getStringId ","\r
+  { \r
+    FF:Flags  "=" flagsField ( "\|" flagsField )* "," \r
+  }\r
+  << WriteFlags (); >> //  write the flags field\r
+  vfrBooleanExpression\r
+  EOP:EndIf ";"                         << WriteOpByte (EOP->getLine(), EFI_IFR_END_IF_OP); >>\r
+  ;\r
+\r
+//*****************************************************************************\r
+// \r
+// PARSE:\r
+//   TRUE AND (ideqval SomeStruct.SomeMember >= 0x10 OR \r
+//               ideqid SomeStruct.SomeMember < SomeStruct.SomeOtherMember) AND\r
+//            (ideqlist SomeStruct.SomeOtherMember == 0x10, 0x20, 0x30 OR\r
+//               vareqval var(VAR_EQ_TEST_NAME) == 0x1)\r
+//\r
+// For supporting complex express, divide the vfrBooleanExpression to two parts\r
+// so that pred-LL(k) parser can parse incrementally.\r
+//\r
+vfrBooleanExpression :\r
+  leftPartVfrBooleanExp { rightPartVfrBooleanExp }\r
+  ;\r
+  \r
+leftPartVfrBooleanExp :\r
+  OpenParen vfrBooleanExpression CloseParen                                                        |\r
+  (ideqval | ideqid | ideqvallist | vareqval | truefalse)                                          |\r
+  NOPID:NOT leftPartVfrBooleanExp           << WriteOpByte (NOPID->getLine(), EFI_IFR_NOT_OP); >>\r
+  ;\r
+\r
+rightPartVfrBooleanExp :\r
+  AOPID:AND vfrBooleanExpression            << WriteOpByte (AOPID->getLine(), EFI_IFR_AND_OP); >>  |\r
+  OOPID:OR vfrBooleanExpression             << WriteOpByte (OOPID->getLine(), EFI_IFR_OR_OP); >>\r
+  ;\r
+\r
+//*****************************************************************************\r
+//\r
+// PARSE:\r
+//   TRUE\r
+//\r
+truefalse :\r
+  TOPID:True                                << WriteOpByte (TOPID->getLine(), EFI_IFR_TRUE_OP); >> |\r
+  FOPID:False                               << WriteOpByte (FOPID->getLine(), EFI_IFR_FALSE_OP); >>\r
+  ;\r
+\r
+//*****************************************************************************\r
+//\r
+// PARSE:\r
+//   varstore MY_STRUCT_NAME, key = 0x1234, name = "MyVariableName", guid = {...};\r
+//\r
+vfrStatementVarStore : \r
+  OP:VarStore                           << WriteOpByte (OP->getLine(), EFI_IFR_VARSTORE_OP); >>\r
+  STRUCT_NAME:StringIdentifier ","\r
+  Key   "=" KNUM:Number ","\r
+  Name  "=" VAR_NAME:StringIdentifier ","  \r
+  Guid "=" \r
+  OpenBrace \r
+  G1:Number ","\r
+  G2:Number ","\r
+  G3:Number ","\r
+  OpenBrace\r
+  G4:Number ","\r
+  G5:Number ","\r
+  G6:Number ","\r
+  G7:Number ","\r
+  G8:Number ","\r
+  G9:Number ","\r
+  G10:Number ","\r
+  G11:Number \r
+  CloseBrace\r
+  CloseBrace                            << WriteGuidValue (G1->getLine (), G1->getText (), G2->getText (), G3->getText (),\r
+                                                           G4->getText (), G5->getText (), G6->getText (), G7->getText (),\r
+                                                           G8->getText (), G9->getText (), G10->getText (), G11->getText ()\r
+                                                          );\r
+                                           WriteWord (GetNumber (KNUM->getText(), KNUM->getLine(), 2)); \r
+                                           AddVarStore (STRUCT_NAME->getText(), VAR_NAME->getText(), GetNumber (KNUM->getText(), KNUM->getLine(), 2), STRUCT_NAME->getLine());\r
+                                         >>\r
+  \r
+  ";"\r
+  ;\r
+\r
+//*****************************************************************************\r
+//\r
+// PARSE:  \r
+//   vareqval var(0x100) == 0x20\r
+//\r
+vareqval : \r
+  OPID:VarEqVal                           << WriteOpByte (OPID->getLine(), EFI_IFR_EQ_VAR_VAL_OP); >>\r
+  Var OpenParen \r
+  VAR:Number                              << WriteWord (GetNumber (VAR->getText(), VAR->getLine(), 2)); >>\r
+  CloseParen\r
+  compareNumber\r
+  ;\r
+\r
+ideqval : \r
+  OPID:IdEqVal                            << WriteOpByte (OPID->getLine(), EFI_IFR_EQ_ID_VAL_OP); >>\r
+  vfrStructFieldName[0]\r
+  compareNumber\r
+  ;\r
+\r
+//*****************************************************************************\r
+//\r
+// PARSE:\r
+//   ideqid MyNVData3.Field16A == MyNVData3.Field16B\r
+//\r
+// NOTE: Before processing the second variable store in the ideqid statement, set a global flag\r
+//       so that when we parse the second variable we set the secondary variable store id.\r
+//\r
+ideqid : \r
+  OPID:IdEqId                             << WriteOpByte (OPID->getLine(), EFI_IFR_EQ_ID_ID_OP);  >>\r
+  vfrStructFieldName[0]\r
+  compareVfrStructFieldNameNL0\r
+  ;\r
+\r
+//*****************************************************************************\r
+//\r
+// compareNumber is the combination of compare operation and Number\r
+//\r
+compareNumber :\r
+  (\r
+  "=="\r
+  VAL1:Number                             << WriteWord (GetNumber (VAL1->getText(), VAL1->getLine(), 2)); >>\r
+  ) |\r
+  (\r
+  GTOPID:GreaterThan\r
+  VAL2:Number                             << WriteWord (GetNumber (VAL2->getText(), VAL2->getLine(), 2));\r
+                                             WriteOpByte (GTOPID->getLine(), EFI_IFR_GT_OP); >>\r
+  ) |\r
+  (\r
+  GEOPID:GreaterEqual\r
+  VAL3:Number                             << WriteWord (GetNumber (VAL3->getText(), VAL3->getLine(), 2));\r
+                                             WriteOpByte (GEOPID->getLine(), EFI_IFR_GE_OP); >>\r
+  ) |\r
+  (\r
+  LTOPID:LessThan\r
+  VAL4:Number                             << WriteWord (GetNumber (VAL4->getText(), VAL4->getLine(), 2));\r
+                                             WriteOpByte (LTOPID->getLine(), EFI_IFR_GE_OP);\r
+                                             WriteOpByte (LTOPID->getLine(), EFI_IFR_NOT_OP); >>\r
+  ) |\r
+  (\r
+  LEOPID:LessEqual\r
+  VAL5:Number                             << WriteWord (GetNumber (VAL5->getText(), VAL5->getLine(), 2));\r
+                                             WriteOpByte (LEOPID->getLine(), EFI_IFR_GT_OP);\r
+                                             WriteOpByte (LEOPID->getLine(), EFI_IFR_NOT_OP); >>\r
+  )\r
+  ;\r
+\r
+//*****************************************************************************\r
+//\r
+// compareVfrStructFieldNameNL0 is the combination of compare operation and  vfrStructFieldNameNL[0]\r
+//\r
+compareVfrStructFieldNameNL0 :\r
+  (\r
+  "=="                                    << mIdEqIdStmt = 1; >>\r
+  vfrStructFieldNameNL[0]                 << mIdEqIdStmt = 0; >>\r
+  ) |\r
+  (\r
+  GTOPID:GreaterThan                      << mIdEqIdStmt = 1; >>\r
+  vfrStructFieldNameNL[0]                 << mIdEqIdStmt = 0;\r
+                                             WriteOpByte (GTOPID->getLine(), EFI_IFR_GT_OP); >>\r
+  ) |\r
+  (\r
+  GEOPID:GreaterEqual                     << mIdEqIdStmt = 1; >>\r
+  vfrStructFieldNameNL[0]                 << mIdEqIdStmt = 0;\r
+                                             WriteOpByte (GEOPID->getLine(), EFI_IFR_GE_OP); >>\r
+  ) |\r
+  (\r
+  LTOPID:LessThan                       << mIdEqIdStmt = 1; >>\r
+  vfrStructFieldNameNL[0]                 << mIdEqIdStmt = 0;\r
+                                             WriteOpByte (LTOPID->getLine(), EFI_IFR_GE_OP);\r
+                                             WriteOpByte (LTOPID->getLine(), EFI_IFR_NOT_OP); >>\r
+  ) |\r
+  (\r
+  LEOPID:LessEqual                      << mIdEqIdStmt = 1; >>\r
+  vfrStructFieldNameNL[0]                 << mIdEqIdStmt = 0;\r
+                                             WriteOpByte (LEOPID->getLine(), EFI_IFR_GT_OP);\r
+                                             WriteOpByte (LEOPID->getLine(), EFI_IFR_NOT_OP); >>\r
+  )\r
+  ;\r
+  \r
+\r
+ideqvallist : \r
+  OPID:IdEqValList                        << WriteOpByte (OPID->getLine(), EFI_IFR_EQ_ID_LIST_OP); >>\r
+  vfrStructFieldName[0] \r
+  "=="\r
+  ( VAL:Number                            << QueueIdEqValList (GetNumber (VAL->getText(), VAL->getLine(), 2)); >> ) +\r
+                                          << FlushQueueIdEqValList(); >>\r
+  ;\r
+    \r
+vfrStatementGoto : \r
+  << UINT32 LineNum, KeyValue = 0; ResetFlags (); >>\r
+  IDG:Goto                          << WriteOpByte (IDG->getLine(), EFI_IFR_REF_OP); >>\r
+  VAL:Number  ","                   << WriteWord (GetNumber (VAL->getText(), VAL->getLine(), 2)); \r
+                                       AddGotoReference (GetNumber (VAL->getText(), VAL->getLine(), 2), VAL->getLine());\r
+                                    >>\r
+  KP:Prompt   "=" getStringId ","   << LineNum = KP->getLine();  >>\r
+  Help        "=" getStringId\r
+  { \r
+    "," \r
+    FF:Flags  "=" flagsField ( "\|" flagsField )*  << LineNum = FF->getLine(); >>\r
+  }\r
+  {\r
+    "," Key   "=" KNUM:Number       << LineNum = KNUM->getLine(); KeyValue = GetNumber(KNUM->getText(), LineNum, 2); >>\r
+  }\r
+                                    << WriteFlagsKey (KeyValue, LineNum); >>\r
+  ";"\r
+  ;\r
+    \r
+vfrStatementHidden : \r
+  IDH:Hidden                  << WriteOpByte (IDH->getLine(), EFI_IFR_HIDDEN_OP); >>\r
+  Value "="\r
+  VAL:Number ","              << WriteWord (GetNumber (VAL->getText(), VAL->getLine(), 2)); >>\r
+  Key "="\r
+  KVAL:Number                 << WriteWord (GetNumber (KVAL->getText(), KVAL->getLine(), 2)); >>\r
+  ";"\r
+  ;    \r
+\r
+//*****************************************************************************\r
+//\r
+// PARSE:\r
+//   suppressif <boolean_expression> { grayoutif } <statements>+ endif;\r
+// Note:\r
+//   You can have: suppressif:grayoutif:statements:endif\r
+//                 suppressif:grayoutif:endif                  -- serves no purpose\r
+//                 suppressif:statements:endif\r
+//                 suppressif:endif                            -- serves no purpose\r
+//\r
+vfrStatementSuppressIf : \r
+  << ResetFlags (); >>\r
+  OPID:SuppressIf                     << WriteOpByte (OPID->getLine(), EFI_IFR_SUPPRESS_IF_OP); SetIfStart (OPID->getLine()); >>\r
+  { \r
+    FF:Flags  "=" flagsField ( "\|" flagsField )* ","\r
+  }\r
+  << WriteFlags (); >> //  write the flags field \r
+  vfrBooleanExpression\r
+  ";"\r
+  { suppressIfGrayOutIf } ( suppressIfAndGrayoutIfSubstatements )+\r
+  ENDOP:EndIf ";"                     << WriteOpByte (ENDOP->getLine(), EFI_IFR_END_IF_OP); SetIfStart (0); >>\r
+  ;\r
+\r
+//\r
+// This is the form for a grayoutif nested in a suppressif statement\r
+//\r
+suppressIfGrayOutIf :\r
+  << ResetFlags (); >>\r
+  OPID:GrayOutIf                      << WriteOpByte (OPID->getLine(), EFI_IFR_GRAYOUT_IF_OP); >>\r
+  { \r
+    FF:Flags  "=" flagsField ( "\|" flagsField )* "," \r
+  }\r
+  << WriteFlags (); >> //  write the flags field\r
+  vfrBooleanExpression\r
+  ";"\r
+  ; \r
+\r
+//*****************************************************************************\r
+//\r
+// PARSE:\r
+//   grayoutif { flags = n, } <boolean_expression> endif;\r
+// Note:\r
+//   You can have: grayoutif:suppressif:statements:endif\r
+//                 grayoutif:statements:endif\r
+//\r
+//\r
+vfrStatementGrayOutIf :\r
+  << ResetFlags (); >>\r
+  OPID:GrayOutIf                      << WriteOpByte (OPID->getLine(), EFI_IFR_GRAYOUT_IF_OP); SetIfStart (OPID->getLine()); >>\r
+  { \r
+    FF:Flags  "=" flagsField ( "\|" flagsField )* "," \r
+  }\r
+  << WriteFlags (); >> //  write the flags field\r
+  vfrBooleanExpression\r
+  ";"\r
+  { grayoutIfSuppressIf } ( suppressIfAndGrayoutIfSubstatements )+ \r
+  ENDOP:EndIf ";"                     << WriteOpByte (ENDOP->getLine(), EFI_IFR_END_IF_OP); SetIfStart (0); >>\r
+  ;\r
+\r
+//\r
+// This is the format for a suppressif nested in a grayoutif\r
+//\r
+grayoutIfSuppressIf : \r
+  << ResetFlags (); >>\r
+  OPID:SuppressIf                     << WriteOpByte (OPID->getLine(), EFI_IFR_SUPPRESS_IF_OP); >>\r
+  { \r
+    FF:Flags  "=" flagsField ( "\|" flagsField )* ","\r
+  }\r
+  << WriteFlags (); >> //  write the flags field\r
+  vfrBooleanExpression\r
+  ";"\r
+  ;\r
+\r
+//\r
+// These are the VFR statements that are valid inside a suppressif or grayoutif statement.\r
+//\r
+suppressIfAndGrayoutIfSubstatements :\r
+  vfrStatementOneOf           |\r
+  vfrStatementTextText        |\r
+  vfrStatementCheckBox        |\r
+  vfrStatementNumeric         |\r
+  vfrStatementDate            |\r
+  vfrStatementTime            |\r
+  vfrStatementPassword        |\r
+  vfrStatementString          |\r
+  vfrStatementHidden          |\r
+  vfrStatementGoto            | \r
+  vfrStatementLabel           |\r
+  vfrStatementInventory       |\r
+  vfrStatementOrderedList     |\r
+  vfrStatementSaveRestoreDefaults\r
+  ; \r
+\r
+//*****************************************************************************\r
+//\r
+// PARSE:\r
+//\r
+//    password  varid    = MyNvData.Password,\r
+//              prompt   = STRING_TOKEN(STR_PASSWORD_PROMPT),\r
+//              help     = STRING_TOKEN(STR_PASSWORD_HELP),\r
+//              minsize  = 6,\r
+//              maxsize  = 20,\r
+//              encoding = 1,\r
+//    endpassword; \r
+  \r
+vfrStatementPassword : \r
+  << UINT32 KeyValue = 0; UINT32 LineNum; ResetFlags (); >>\r
+  IDPW:Password                       << WriteOpByte (IDPW->getLine(), EFI_IFR_PASSWORD_OP); >>\r
+  VarId       "=" vfrStructFieldNameArray[0] ","\r
+  Prompt      "=" getStringId ","\r
+  KH:Help     "=" getStringId ","    << LineNum = KH->getLine(); >>\r
+  { \r
+    FF:Flags  "=" flagsField ( "\|" flagsField )* ","  << LineNum = FF->getLine(); >>\r
+  }\r
+  {\r
+    Key "=" KNUM:Number ","           << LineNum = KNUM->getLine(); KeyValue = GetNumber(KNUM->getText(), LineNum, 2); >>\r
+  }\r
+                                      << WriteFlagsKey (KeyValue, LineNum); >>\r
+  MinSize   "=" MIN:Number ","        << WriteByte (GetNumber (MIN->getText(), MIN->getLine(), 1), 0); >>\r
+  MaxSize   "=" MAX:Number ","        << WriteByte (GetNumber (MAX->getText(), MAX->getLine(), 1), 0); >>\r
+  Encoding  "=" ENC:Number ","        << WriteWord (GetNumber (ENC->getText(), ENC->getLine(), 2)); >>\r
+  EndPassword  ";"              \r
+  ;\r
+\r
+//*****************************************************************************\r
+//\r
+//  PARSE:\r
+//\r
+//    string    varid    = MyNv.String,\r
+//              prompt   = STRING_TOKEN(STR_STRING_PROMPT),\r
+//              help     = STRING_TOKEN(STR_STRING_HELP),\r
+//              flags    = INTERACTIVE,\r
+//              key      = 0x1234,\r
+//              minsize  = 6,\r
+//              maxsize  = 0x14,\r
+//    endstring; \r
+//\r
+// Since flags and key are optional, we can't use Flags->getLine(). Therefore for error\r
+// reporting we save the line number of the "help" keyword.\r
+//\r
+vfrStatementString : \r
+  << unsigned int KeyValue = 0; UINT32 LineNum; ResetFlags (); >>\r
+  IDS:String                                << WriteOpByte (IDS->getLine(), EFI_IFR_STRING_OP); >>\r
+  VarId     "=" vfrStructFieldNameArray[0] ","\r
+  Prompt    "=" getStringId ","\r
+  KH:Help   "=" getStringId ","             << LineNum = KH->getLine(); >>\r
+  { \r
+    FF:Flags "=" \r
+    flagsField ( "\|" flagsField )*         << LineNum = FF->getLine(); >>\r
+    "," \r
+  }\r
+  {\r
+    Key "=" KNUM:Number ","                 << LineNum = KNUM->getLine(); KeyValue = GetNumber(KNUM->getText(), LineNum, 2); >>\r
+  }\r
+                                            << WriteFlagsKey (KeyValue, LineNum); >>\r
+  MinSize   "=" MIN:Number ","              << WriteByte (GetNumber (MIN->getText(), MIN->getLine(), 1), 0);  >>\r
+  MaxSize   "=" MAX:Number ","              << WriteByte (GetNumber (MAX->getText(), MAX->getLine(), 1), 0); >>\r
+  EndString  ";"\r
+  ;\r
+\r
+//*****************************************************************************\r
+//\r
+// PARSE:\r
+//    numeric varid   = MyIfrNVData.HowOldAreYouInYears, \r
+//            prompt  = STRING_TOKEN(STR_NUMERIC_PROMPT),\r
+//            help    = STRING_TOKEN(STR_NUMERIC_HELP),\r
+//            flags   = INTERACTIVE,  // flags is optional\r
+//            key     = 0x1234,       // key is optional if (flags & INTERACTIVE = 0)\r
+//            minimum = 0x0,\r
+//            maximum = 0xf0,\r
+//            step    = 1,            // step is option, and step=1 if not specified\r
+//            default = 0;            // default is optional, and default=minimum if not specified\r
+//    endnumeric;\r
+//\r
+// Make flags and key optional. However if flags includes INTERACTIVE, then a key is required.\r
+// That check is done in WriteFlagsKey() function.\r
+//\r
+vfrStatementNumeric :  \r
+  << UINT32 LineNum, KeyValue = 0; ResetFlags (); >>\r
+  IDN:Numeric                         << WriteOpByte (IDN->getLine(), EFI_IFR_NUMERIC_OP); >>\r
+  VarId     "=" vfrStructFieldName[2] ","\r
+  Prompt    "=" getStringId ","\r
+  KH:Help   "=" getStringId ","       << LineNum = KH->getLine(); >>\r
+  { \r
+    FF:Flags "=" flagsField ( "\|" flagsField )* ","     << LineNum = FF->getLine (); >>\r
+  }\r
+  {\r
+    Key "=" KNUM:Number  ","          << LineNum = KNUM->getLine(); KeyValue = GetNumber(KNUM->getText(), LineNum, 2); >>\r
+  }\r
+                                      << WriteFlagsKey (KeyValue, LineNum); >>\r
+  minMaxStepDefault                   \r
+  EndNumeric ";"                      << WriteMinMaxStepDefault (); >>\r
+  ;\r
+\r
+//\r
+// Parse minimum/maximum/step/default statements. Special cases:\r
+//   - if step not specified, then the value is 1\r
+//   - if default not specified, then the value is the min value specified\r
+//   - if max < min, print a warning and swap the values (changes default too)\r
+//\r
+minMaxStepDefault :\r
+  << InitMinMaxStepDefault (); >>\r
+  Minimum   "=" MIN:Number ","        << SetMinMaxStepDefault (GetNumber (MIN->getText(),  MIN->getLine(), 2), 0, MIN->getLine()); >>\r
+  Maximum   "=" MAX:Number ","        << SetMinMaxStepDefault (GetNumber (MAX->getText(),  MAX->getLine(), 2), 1, MAX->getLine()); >>\r
+  { Step    "=" STEP:Number ","       << SetMinMaxStepDefault (GetNumber (STEP->getText(), STEP->getLine(), 2), 2, STEP->getLine()); >> }\r
+  { Default "=" DEF:Number ","        << SetMinMaxStepDefault (GetNumber (DEF->getText(),  DEF->getLine(), 2), 3, DEF->getLine()); >> }\r
+  ;\r
+\r
+\r
+//*****************************************************************************\r
+//\r
+// PARSE:\r
+//\r
+//    date    year varid  = Date.Year,                        // "Date.Year" is a special case we recognize\r
+//            prompt      = STRING_TOKEN(STR_DATE_PROMPT),\r
+//            help        = STRING_TOKEN(STR_DATE_YEAR_HELP),\r
+//            minimum     = 1939,\r
+//            maximum     = 2101,\r
+//            step        = 1,\r
+//            default     = 1964,\r
+//\r
+//            month varid = Date.Month,    \r
+//            prompt      = STRING_TOKEN(STR_DATE_PROMPT),\r
+//            help        = STRING_TOKEN(STR_DATE_MONTH_HELP),\r
+//            minimum     = 1,\r
+//            maximum     = 12,\r
+//            step        = 1,\r
+//            default     = 1,\r
+//\r
+//            day varid   = Date.Day,\r
+//            prompt      = STRING_TOKEN(STR_DATE_PROMPT),\r
+//            help        = STRING_TOKEN(STR_DATE_DAY_HELP),\r
+//            minimum     = 1,\r
+//            maximum     = 31,\r
+//            step        = 0x1,\r
+//            default     = 1,\r
+//\r
+//    enddate;\r
+//  \r
+vfrStatementDate :  \r
+  Date                            \r
+  IDY:Year VarId "="                  << WriteOpByte (IDY->getLine(), EFI_IFR_DATE_OP); >>\r
+  vfrStructFieldName[2] "," \r
+  dateTimeSubStatement                    \r
+  IDM:Month VarId "="                 << WriteOpByte (IDM->getLine(), EFI_IFR_DATE_OP); >>\r
+  vfrStructFieldName[2] "," \r
+  dateTimeSubStatement                    \r
+  IDD:Day VarId "="                   << WriteOpByte (IDD->getLine(), EFI_IFR_DATE_OP); >> \r
+  vfrStructFieldName[2] ","  \r
+  dateTimeSubStatement    \r
+  EndDate ";"\r
+  ;\r
+  \r
+vfrStatementTime :  \r
+  Time                            \r
+  IDH:Hour VarId "="                  << WriteOpByte (IDH->getLine(), EFI_IFR_TIME_OP); >>\r
+  vfrStructFieldName[2] ","  \r
+  dateTimeSubStatement                    \r
+  IDM:Minute VarId "="                << WriteOpByte (IDM->getLine(), EFI_IFR_TIME_OP); >>\r
+  vfrStructFieldName[2] "," \r
+  dateTimeSubStatement                    \r
+  IDS:Second VarId "="                << WriteOpByte (IDS->getLine(), EFI_IFR_TIME_OP); >>\r
+  vfrStructFieldName[2] "," \r
+  dateTimeSubStatement\r
+  EndTime ";"\r
+  ;\r
+\r
+//*****************************************************************************\r
+//\r
+// PARSE:\r
+//\r
+//   text  text = STRING_ID;\r
+//   text  text = STRING_ID, text = STRING_ID;\r
+//   text  text = STRING_ID, text = STRING_ID, flags = x, key = y;\r
+//\r
+vfrStatementTextText :\r
+  << ResetFlags (); >>\r
+  IDT:Text                            << WriteOpByte (IDT->getLine(), EFI_IFR_TEXT_OP); >>\r
+  Help "=" getStringId ","\r
+  Text "=" \r
+  getStringId                         // writes string identifier\r
+  { "," Text "=" getStringId\r
+    "," Flags "=" flagsField ( "\|" flagsField )*  << WriteFlags (); >>\r
+    "," \r
+    Key "=" KNUM:Number               << WriteWord (GetNumber(KNUM->getText(), KNUM->getLine(), 2)); >>\r
+  }\r
+  ";" \r
+  ;\r
+\r
+//*****************************************************************************\r
+//\r
+// PARSE:\r
+//\r
+//   inventory help = ID, text = ID;\r
+//   inventory help = ID, text = id, text = ID;\r
+//\r
+vfrStatementInventory :\r
+  IDI:Inventory                        << WriteOpByte (IDI->getLine(), EFI_IFR_INVENTORY_OP); >>\r
+  Help        "=" getStringId ","\r
+  Text        "=" getStringId                 // writes string identifier\r
+  { "," Text  "=" getStringId\r
+  }\r
+  ";" \r
+  ;\r
+\r
+//*****************************************************************************\r
+//\r
+// PARSE:\r
+//\r
+//    restore defaults,\r
+//      formid  = 4,\r
+//      prompt  = STRING_TOKEN(STR_RESTORE_DEFAULTS_PROMPT),\r
+//      help    = STRING_TOKEN(STR_RESTORE_DEFAULTS_HELP),\r
+//      flags   = 0,\r
+//      key     = 0;\r
+//\r
+//    save defaults,\r
+//      formid  = 4,\r
+//      prompt  = STRING_TOKEN(STR_SAVE_DEFAULTS_PROMPT),\r
+//      help    = STRING_TOKEN(STR_SAVE_DEFAULTS_HELP),\r
+//      flags   = 0,\r
+//      key     = 0;\r
+//\r
+vfrStatementSaveRestoreDefaults : \r
+  << unsigned int KeyValue = 0; UINT32 LineNum; ResetFlags (); >>\r
+  ( IDS:Save                            << WriteOpByte (IDS->getLine(), EFI_IFR_SAVE_DEFAULTS_OP); >>\r
+  | IDR:Restore                         << WriteOpByte (IDR->getLine(), EFI_IFR_RESTORE_DEFAULTS_OP); >>\r
+  )\r
+  Defaults ","\r
+  FormId    "=" FRMID:Number  ","       << WriteWord (GetNumber (FRMID->getText(), FRMID->getLine(), 2)); \r
+                                           AddGotoReference (GetNumber (FRMID->getText(), FRMID->getLine(), 2), FRMID->getLine());\r
+                                        >>\r
+  Prompt    "=" getStringId ","\r
+  KH:Help   "=" getStringId             << LineNum = KH->getLine(); >>\r
+  { \r
+    "," FF:Flags "=" flagsField ( "\|" flagsField )*  << LineNum = FF->getLine(); >>\r
+  }\r
+  {\r
+    "," Key "=" KNUM:Number             << LineNum = KNUM->getLine(); KeyValue = GetNumber(KNUM->getText(), LineNum, 2); >>\r
+  }\r
+                                        << WriteFlagsKey (KeyValue, LineNum); >>\r
+  ";"\r
+  ;\r
+\r
+//*****************************************************************************\r
+//\r
+// PARSE:\r
+//\r
+//   flags = 0x10 | DEFAULT | MANUFACTURING | INTERACTIVE | NV_ACCESS | RESET_REQUIRED | LATE_CHECK\r
+//\r
+// \r
+flagsField :\r
+  VAL:Number                          << SetFlags (GetNumber(VAL->getText(), VAL->getLine(), 4), VAL->getLine()); >>\r
+  | IF:InteractiveFlag                << SetFlags (EFI_IFR_FLAG_INTERACTIVE, IF->getLine());    >>\r
+  | MF:ManufacturingFlag              << SetFlags (EFI_IFR_FLAG_MANUFACTURING, MF->getLine());  >>\r
+  | DF:DefaultFlag                    << SetFlags (EFI_IFR_FLAG_DEFAULT, DF->getLine());        >>\r
+  | NV:NVAccessFlag                   << SetFlags (EFI_IFR_FLAG_NV_ACCESS, NV->getLine());      >>\r
+  | RR:ResetRequiredFlag              << SetFlags (EFI_IFR_FLAG_RESET_REQUIRED, RR->getLine()); >>\r
+  | LC:LateCheckFlag                  << SetFlags (EFI_IFR_FLAG_LATE_CHECK, LC->getLine());     >>\r
+  ;\r
+\r
+dateTimeSubStatement :\r
+  Prompt  "=" getStringId ","\r
+  Help    "=" getStringId ","\r
+                                      << WriteByte (0, 0); WriteWord (0); >> // bogus flags and key\r
+  minMaxStepDefault                   << WriteMinMaxStepDefault (); >>\r
+  ;\r
+  \r
+vfrStatementCheckBox :  \r
+  << UINT32 LineNum, KeyValue = 0; ResetFlags (); >>\r
+  IDCB:CheckBox                       << WriteOpByte (IDCB->getLine(), EFI_IFR_CHECKBOX_OP); >>\r
+  VarId     "=" vfrStructFieldName[1] ","\r
+  Prompt    "=" getStringId ","\r
+  Help      "=" getStringId ","\r
+  FF:Flags  "=" flagsField ( "\|" flagsField )*  "," << LineNum = FF->getLine(); >>\r
+  { \r
+    Key "=" KV:Number  ","           << LineNum = KV->getLine(); KeyValue = GetNumber(KV->getText(), LineNum, 2); >>\r
+  }\r
+                                     << WriteFlagsKey (KeyValue, LineNum); >>\r
+  EndCheckBox ";"\r
+  ;\r
+     \r
+vfrStatementSubTitle :\r
+  IDS:Subtitle Text "="               << WriteOpByte (IDS->getLine(), EFI_IFR_SUBTITLE_OP); >>\r
+  getStringId                         // writes string indentifier\r
+  ";"\r
+  ;\r
+\r
+//*****************************************************************************\r
+//\r
+// PARSE:\r
+//    banner \r
+//      title = STRING_TOKEN(STR_BANNER_TITLE),\r
+//      line  1,\r
+//      align center;     // or left or right\r
+//\r
+//    banner, \r
+//      title = STRING_TOKEN(STR_BANNER_TITLE), timeout = 100;\r
+//\r
+vfrStatementBanner :\r
+  IDB:Banner { "," }                    << WriteOpByte (IDB->getLine(), EFI_IFR_BANNER_OP); >>\r
+  Title "=" getStringId ","\r
+  ( \r
+    Line VAL:Number ","                 << WriteWord (GetNumber(VAL->getText(), VAL->getLine(), 2)); >>\r
+    Align \r
+    ( Left                              << WriteByte (EFI_IFR_BANNER_ALIGN_LEFT, 0); >>\r
+    | Center                            << WriteByte (EFI_IFR_BANNER_ALIGN_CENTER, 0); >>\r
+    | Right                             << WriteByte (EFI_IFR_BANNER_ALIGN_RIGHT, 0); >>\r
+    ) ";"\r
+  |\r
+    Timeout "=" TO:Number ";"           << WriteWord (GetNumber(TO->getText(), TO->getLine(), 2)); >>\r
+                                        << WriteByte (EFI_IFR_BANNER_TIMEOUT, 0); >>\r
+  )\r
+  ;\r
+\r
+//*****************************************************************************\r
+//\r
+// PARSE:\r
+//   oneof  varid       = MyNv.OneOfData,\r
+//          prompt      = STRING_TOKEN(STR_ONE_OF_PROMPT),\r
+//          help        = STRING_TOKEN(STR_ONE_OF_HELP),\r
+//          option text = STRING_TOKEN(STR_ONE_OF_TEXT), \r
+//          value       = 0, \r
+//          flags       = DEFAULT | INTERACTIVE;\r
+//\r
+// supressif/grayoutif are supported inside oneof stmt.\r
+// We do not restrict the number of oneOfOptionText to >=2, but >=1.\r
+// The situation that all oneOfOptionText are suppressed is also possiable.\r
+//\r
+vfrStatementOneOf :\r
+  << ResetFlags (); >>\r
+  IDOO:OneOf                              << WriteOpByte (IDOO->getLine(), EFI_IFR_ONE_OF_OP); >>\r
+  VarId   "=" vfrStructFieldName[2] ","       \r
+  Prompt  "=" getStringId  ","           // writes string identifier\r
+  Help    "=" getStringId  ","           // writes string identifier\r
+  ( oneOfOptionText )+                   // there must be at least 1 option to be choosed, not 2.\r
+  IDEOO:EndOneOf   ";"                    << TestOneOfFlags (IDEOO->getLine()); WriteOpByte (IDEOO->getLine(), EFI_IFR_END_ONE_OF_OP); >>\r
+  ;\r
+\r
+//*****************************************************************************\r
+//\r
+// PARSE:\r
+//  \r
+//   orderedlist  varid       = MyNv.OrderedListData,\r
+//                prompt      = STRING_TOKEN(STR_ORDERED_LIST_PROMPT),\r
+//                help        = STRING_TOKEN(STR_ORDERED_LIST_HELP),  \r
+//                option text = STRING_TOKEN(STR_ORDERED_LIST_TEXT), value = 0, flags = INTERACTIVE;\r
+//                -- additional option text -- \r
+//   endlist;\r
+//\r
+vfrStatementOrderedList :\r
+  << ResetFlags (); InitOrderedList(); >>\r
+  IDOL:OrderedList                       << WriteOpByte (IDOL->getLine(), EFI_IFR_ORDERED_LIST_OP); >>\r
+  VarId   "=" vfrStructFieldNameArray[1] ","       \r
+  Prompt  "=" getStringId  ","           // writes string identifier\r
+  Help    "=" getStringId  ","           // writes string identifier\r
+  orderedListOptionText ( orderedListOptionText )+\r
+  IDEOL:EndList   ";"                    << WriteOpByte (IDEOL->getLine(), EFI_IFR_END_OP); EndOrderedList(IDEOL->getLine()); >>\r
+  ;\r
+\r
+//*****************************************************************************\r
+//\r
+// PARSE:\r
+//\r
+//   option text = STRING_TOKEN(STRING_ID), value = 0 flags = 99;\r
+//\r
+// Differs from the oneOfOptionText in that we don't allow the DEFAULT flag to\r
+// be set, and value cannot be 0.\r
+//\r
+orderedListOptionText :\r
+  << UINT32 KeyValue = 0; >>\r
+  IDO:Option                          << WriteOpByte (IDO->getLine(), EFI_IFR_ONE_OF_OPTION_OP); >>\r
+  Text      "=" getStringId ","       // writes string identifier\r
+  Value     "=" WVAL:Number ","       << \r
+                                          if (GetNumber(WVAL->getText(), WVAL->getLine(), 2) == 0) {\r
+                                            PrintErrorMessage (WVAL->getLine(), "value=0 is invalid for ordered lists", NULL); \r
+                                          } else {\r
+                                            WriteWord (GetNumber(WVAL->getText(), WVAL->getLine(), 2)); \r
+                                          }\r
+                                      >>\r
+  FF:Flags  "=" orderedListFlagsField  \r
+                ("\|" orderedListFlagsField )*                   \r
+  { \r
+    "," Key "=" KV:Number             << KeyValue = GetNumber (KV->getText(), KV->getLine(), 2); >> \r
+  }\r
+                                      << WriteFlagsKey (KeyValue, FF->getLine()); >>\r
+  ";"                                 << mOptionCount++; >>\r
+  ;\r
+\r
+//*****************************************************************************\r
+//\r
+// PARSE:\r
+//\r
+//   flags = 0x10 | DEFAULT | MANUFACTURING | INTERACTIVE | NV_ACCESS | RESET_REQUIRED | LATE_CHECK\r
+//\r
+// The ordered list flags field cannot have a default.\r
+//\r
+orderedListFlagsField :\r
+  VAL:Number                          << SetFlags (GetNumber(VAL->getText(), VAL->getLine(), 4), VAL->getLine()); >>\r
+  | IF:InteractiveFlag                << SetFlags (EFI_IFR_FLAG_INTERACTIVE, IF->getLine());    >>\r
+  | MF:ManufacturingFlag              << SetFlags (EFI_IFR_FLAG_MANUFACTURING, MF->getLine());  >>\r
+  | NV:NVAccessFlag                   << SetFlags (EFI_IFR_FLAG_NV_ACCESS, NV->getLine());      >>\r
+  | RR:ResetRequiredFlag              << SetFlags (EFI_IFR_FLAG_RESET_REQUIRED, RR->getLine()); >>\r
+  | LC:LateCheckFlag                  << SetFlags (EFI_IFR_FLAG_LATE_CHECK, LC->getLine());     >>\r
+  | DF:DefaultFlag                    << PrintWarningMessage (DF->getLine(), "DEFAULT flag not valid for ordered lists", NULL); >>\r
+  ;\r
+\r
+//\r
+// Parse references to VFR structure field names of form "MyNvStructure.Field". \r
+// This implementation is specific to strings, passwords, and references in an \r
+// ordered list statement because we want to specify the size of the entire \r
+// field, rather than just one element. Then call a function to write out its \r
+// offset and length.\r
+//\r
+vfrStructFieldNameArray[int FieldWidth] :\r
+  << int ArrayIndex = 1; char IsArrayIndex = 0; >>\r
+  SName:StringIdentifier \r
+  "." \r
+  SFieldName:StringIdentifier \r
+  { OpenBracket AIndex:Number CloseBracket << ArrayIndex = GetNumber(AIndex->getText(), AIndex->getLine(), 4); IsArrayIndex = 1; >> }\r
+            << \r
+                WriteFieldOffset (1, \r
+                                  SName->getText(), \r
+                                  SName->getLine(), \r
+                                  SFieldName->getText(), \r
+                                  SFieldName->getLine(),\r
+                                  ArrayIndex, \r
+                                  IsArrayIndex,\r
+                                  FieldWidth,\r
+                                  1\r
+                                  ); \r
+            >>\r
+  ;\r
+\r
+//\r
+// Parse references to VFR structure field names of form "MyNvStructure.Field",\r
+// then call a function to write out its offset and length.\r
+//\r
+vfrStructFieldName[int FieldWidth] :\r
+  << int ArrayIndex = 1; char IsArrayIndex = 0; >>\r
+  SName:StringIdentifier \r
+  "." \r
+  SFieldName:StringIdentifier \r
+  { OpenBracket AIndex:Number CloseBracket << ArrayIndex = GetNumber(AIndex->getText(), AIndex->getLine(), 4); IsArrayIndex = 1; >> }\r
+            << \r
+                WriteFieldOffset (1, \r
+                                  SName->getText(), \r
+                                  SName->getLine(), \r
+                                  SFieldName->getText(), \r
+                                  SFieldName->getLine(),\r
+                                  ArrayIndex, \r
+                                  IsArrayIndex,\r
+                                  FieldWidth,\r
+                                  0\r
+                                  ); \r
+            >>\r
+  ;\r
+\r
+//*****************************************************************************\r
+//\r
+// PARSE:\r
+//\r
+//   MyNvStructure.FieldName[4]\r
+//\r
+// Parse references to VFR structure field names of form "MyNvStructure.Field",\r
+// then call a function to write out the offset with no length.\r
+//\r
+vfrStructFieldNameNL[int FieldWidth] :\r
+  << int ArrayIndex = 1; char IsArrayIndex = 0; >>\r
+  SName:StringIdentifier \r
+  "." \r
+  SFieldName:StringIdentifier \r
+  { OpenBracket AIndex:Number CloseBracket   << ArrayIndex = GetNumber(AIndex->getText(), AIndex->getLine(), 4); IsArrayIndex = 1; >> }\r
+            << \r
+                WriteFieldOffset (0, \r
+                                  SName->getText(), \r
+                                  SName->getLine(), \r
+                                  SFieldName->getText(), \r
+                                  SFieldName->getLine(),\r
+                                  ArrayIndex, \r
+                                  IsArrayIndex,\r
+                                  FieldWidth,\r
+                                  0\r
+                                  ); \r
+            >>\r
+  ;\r
+\r
+//*****************************************************************************\r
+//\r
+// PARSE:\r
+//   suppressif TRUE OR FALSE;\r
+//   grayoutif FALSE OR TRUE;\r
+//     option text = STRING_TOKEN(STRING_ID), value = 0 flags = 99;\r
+//     option text = STRING_TOKEN(STRING_ID2), value = 1 flags = 98;\r
+//   endif;\r
+//\r
+oneOfOptionText :\r
+  suppressIfOptionText    |\r
+  grayOutIfOptionText     |\r
+  commonOptionText\r
+  ;\r
+\r
+suppressIfOptionText : \r
+  << ResetFlags (); >>\r
+  OPID:SuppressIf                     << WriteOpByte (OPID->getLine(), EFI_IFR_SUPPRESS_IF_OP); SetIfStart (OPID->getLine()); >>\r
+  { \r
+    FF:Flags  "=" flagsField ( "\|" flagsField )* ","\r
+  }\r
+  << WriteFlags (); >> //  write the flags field \r
+  vfrBooleanExpression\r
+  ";"\r
+  { suppressIfGrayOutIf } ( commonOptionText )+\r
+  ENDOP:EndIf ";"                     << WriteOpByte (ENDOP->getLine(), EFI_IFR_END_IF_OP); SetIfStart (0); >>\r
+  ;\r
+\r
+grayOutIfOptionText :\r
+  << ResetFlags (); >>\r
+  OPID:GrayOutIf                      << WriteOpByte (OPID->getLine(), EFI_IFR_GRAYOUT_IF_OP); SetIfStart (OPID->getLine()); >>\r
+  { \r
+    FF:Flags  "=" flagsField ( "\|" flagsField )* "," \r
+  }\r
+  << WriteFlags (); >> //  write the flags field\r
+  vfrBooleanExpression\r
+  ";"\r
+  { grayoutIfSuppressIf } ( commonOptionText )+ \r
+  ENDOP:EndIf ";"                     << WriteOpByte (ENDOP->getLine(), EFI_IFR_END_IF_OP); SetIfStart (0); >>\r
+  ;\r
+\r
+commonOptionText : \r
+  << UINT32 KeyValue = 0; >>\r
+  IDO:Option                      << WriteOpByte (IDO->getLine(), EFI_IFR_ONE_OF_OPTION_OP); >>\r
+  Text      "=" getStringId ","   // writes string identifier\r
+  Value     "=" WVal:Number ","   << WriteWord (GetNumber(WVal->getText(), WVal->getLine(), 2)); >>\r
+  FF:Flags  "=" flagsField  ("\|" flagsField )*                   \r
+  { \r
+    "," Key "=" KV:Number         << KeyValue = GetNumber (KV->getText(), KV->getLine(), 2); >> \r
+  }\r
+                                  << WriteFlagsKey (KeyValue, FF->getLine()); >>\r
+  ";"                             << mOptionCount++; >>\r
+  ;\r
+\r
+//\r
+// Gets a string identifier. It must be a numeric value of form:\r
+// \r
+//   STRING_TOKEN(100)\r
+//\r
+getStringId :\r
+  << unsigned short StrId; >>\r
+  StringToken OpenParen\r
+  IdVal:Number             << StrId = GetNumber (IdVal->getText(), IdVal->getLine(), 2); WriteStringIdWord (StrId); >> \r
+  CloseParen\r
+  ;\r
+\r
+//******************************************************************************\r
+//\r
+// Parser class definition. \r
+//  \r
+class EfiVfrParser {\r
+<<\r
+//\r
+// Parser definitions go here    \r
+//\r
+private:\r
+  STRUCT_DEFINITION   *mFirstStructDefinition;\r
+  STRUCT_DEFINITION   *mLastStructDefinition;\r
+  INT32               mNvDataStructSize;                    \r
+  INT32               mNonNvDataStructSize;\r
+  //\r
+  // Flag to indicate that we're processing a ideqid VFR statement so that\r
+  // we can do late checks on the statement.\r
+  //\r
+  INT32               mIdEqIdStmt;\r
+  INT32               mLastNVVariableDataSize;\r
+  GOTO_REFERENCE      *mGotoReferences;\r
+  FORM_ID_VALUE       *mFormIdValues;\r
+  VfrOpcodeHandler    mOpcodeHandler;\r
+  UINT16_LIST         *mUint16List;\r
+  UINT16_LIST         *mLastUint16;\r
+  UINT16_LIST         *mDefinedLabels;\r
+  UINT16_LIST         *mDefinedVarStoreId;\r
+  UINT16_LIST         *mLastDefinedVarStoreId;\r
+  UINT32              mMinimumValue, mMaximumValue, mStepValue, mDefaultValue;\r
+  UINT32              mStmtFlags;\r
+  UINT32              mSubStmtFlags;\r
+  UINT32              mSubStmtFlagsLineNum;\r
+  EFI_GUID            mFormSetGuid;\r
+  UINT8               mNvDataStructDefined;\r
+  UINT16              mClass, mSubclass;\r
+  UINT32              mIfStart;\r
+  UINT32              mOptionCount;  // how many "option" fields in a given statement\r
+  UINT32              mLastVarIdSize;\r
+  UINT8               mOutput;\r
+public:        \r
+\r
+VOID \r
+EfiVfrParser::SetIfStart (\r
+  UINT32 LineNum\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Invoked during VFR parsing when an "if" is encountered. Save the\r
+  source line number so we can point to it if we don't find a \r
+  corresponding endif later.\r
+\r
+Arguments:\r
+  LineNum - source line number where the "if" was parsed.\r
+\r
+Returns:\r
+  None\r
+\r
+--*/\r
+{\r
+  mIfStart = LineNum;\r
+}\r
+VOID \r
+EfiVfrParser::SetClass (\r
+  UINT32 LineNum, \r
+  UINT32 Value\r
+  ) \r
+/*++\r
+\r
+Routine Description:\r
+  Invoked during VFR parsing when a "class" statement is found. Check the\r
+  range on the class value and save it for later.\r
+\r
+Arguments:\r
+  LineNum - source line number where the class statement was parsed.\r
+  Value   - the class value\r
+\r
+Returns:\r
+  None\r
+\r
+--*/\r
+{\r
+  if (Value & 0xFFFF0000) {\r
+    PrintWarningMessage (LineNum, NULL, "class value exceeds maximum allowed");\r
+  }\r
+  mClass |= (UINT16)Value;\r
+}\r
+VOID \r
+EfiVfrParser::SetSubclass (\r
+  UINT32 LineNum, \r
+  UINT32 Value\r
+  ) \r
+/*++\r
+\r
+Routine Description:\r
+  Invoked during VFR parsing when a subclass statement is found. Check the\r
+  range on the value and save it for later.\r
+\r
+Arguments:\r
+  LineNum - source line number where the class statement was parsed.\r
+  Value   - the subclass value from the VFR statement\r
+\r
+Returns:\r
+  None\r
+\r
+--*/\r
+{\r
+  if (Value & 0xFFFF0000) {\r
+    PrintWarningMessage (LineNum, NULL, "subclass value exceeds maximum allowed");\r
+  }\r
+  mSubclass |= (UINT16)Value;\r
+}\r
+VOID EfiVfrParser::WriteClass ()\r
+{\r
+  WriteWord (mClass);\r
+  mClass = 0;\r
+}\r
+VOID EfiVfrParser::WriteSubclass ()\r
+{\r
+  WriteWord (mSubclass);\r
+  mSubclass = 0;\r
+}\r
+VOID EfiVfrParser::WriteIfrBytes ()\r
+{\r
+  mOpcodeHandler.WriteIfrBytes ();\r
+}\r
+VOID \r
+EfiVfrParser::WriteFlagsKey (\r
+  UINT32 KeyValue, \r
+  UINT32 LineNum\r
+  ) \r
+/*++\r
+\r
+Routine Description:\r
+  Write out the flags and key values from the previous VFR statement.\r
+  Many statements take a flags/key pair. If not specified, then 0\r
+  values are written out. However do not allow an interactive flags field\r
+  to be specified if no key value is specified. Also, if NV_ACCESS flag\r
+  is set but INTERACTIVE is not, then set interactive and issue a warning.\r
+\r
+Arguments:\r
+  KeyValue  - the key value from the VFR statement\r
+  LineNum   - source line number where the statement was parsed\r
+\r
+Returns:\r
+  None\r
+\r
+--*/\r
+{\r
+  if ((mSubStmtFlags & EFI_IFR_FLAG_INTERACTIVE) && (KeyValue == 0)) {\r
+    PrintErrorMessage (LineNum, NULL, "invalid or missing key value - required with INTERACTIVE");\r
+  }\r
+  if ((mSubStmtFlags & EFI_IFR_FLAG_NV_ACCESS) && !(mSubStmtFlags & EFI_IFR_FLAG_INTERACTIVE)) {\r
+    PrintWarningMessage (LineNum, NULL, "NV_ACCESS without INTERACTIVE has no effect -- setting INTERACTIVE");\r
+    mSubStmtFlags |= EFI_IFR_FLAG_INTERACTIVE;\r
+  }\r
+  WriteFlags ();\r
+  WriteWord (KeyValue);\r
+}\r
+VOID \r
+EfiVfrParser::InitOrderedList ()\r
+{\r
+  mOptionCount = 0;\r
+}  \r
+VOID \r
+EfiVfrParser::EndOrderedList (\r
+  UINT32 LineNum\r
+  )\r
+{\r
+  if (mLastVarIdSize < mOptionCount) {\r
+    PrintErrorMessage (LineNum, NULL, "number of options exceeds the variable store size");\r
+  }\r
+}\r
+VOID \r
+EfiVfrParser::ResetFlags ()\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Flags are set for each substatement in a given one-of statement.\r
+  To make sure there are no conflicts, for example setting DEFAULT on\r
+  more than one substatement, we keep track of the flags at a statement\r
+  level and a substatement level. This function resets the flags so \r
+  we get a fresh start.\r
+\r
+Arguments:\r
+  None\r
+\r
+Returns:\r
+  None\r
+\r
+--*/\r
+{\r
+  mStmtFlags = 0;\r
+  mSubStmtFlagsLineNum = 0;\r
+  mSubStmtFlags = 0;\r
+}\r
+//\r
+// Test validity of flags value for a one-of statement.\r
+//\r
+VOID \r
+EfiVfrParser::TestOneOfFlags (\r
+  UINT32 LineNum\r
+  ) \r
+{\r
+  //\r
+  // One of the fields must have had the default bit set\r
+  //\r
+  if ((mStmtFlags & EFI_IFR_FLAG_DEFAULT) == 0) {\r
+    PrintWarningMessage (LineNum, "default value must be specified", NULL);\r
+  }\r
+}\r
+VOID \r
+EfiVfrParser::SetFlags (\r
+  UINT32 Flags, \r
+  UINT32 LineNum\r
+  ) \r
+{\r
+  //\r
+  // Check for redefinitions and invalid combinations\r
+  //\r
+  if (mStmtFlags & Flags & EFI_IFR_FLAG_MANUFACTURING) {\r
+    PrintErrorMessage (LineNum, "MANUFACTURING", "a field with this flag already defined");\r
+  }\r
+  if (mStmtFlags & Flags & EFI_IFR_FLAG_DEFAULT) {\r
+    PrintErrorMessage (LineNum, "DEFAULT", "a field with this flag already defined");\r
+  }\r
+  mSubStmtFlags |= Flags;\r
+  mSubStmtFlagsLineNum = LineNum;\r
+}\r
+VOID \r
+EfiVfrParser::WriteFlags ()\r
+{\r
+  //\r
+  // Check value for validity\r
+  //\r
+  if (mSubStmtFlags & ~(EFI_IFR_FLAG_DEFAULT | \r
+                        EFI_IFR_FLAG_MANUFACTURING | \r
+                        EFI_IFR_FLAG_INTERACTIVE | \r
+                        EFI_IFR_FLAG_NV_ACCESS | \r
+                        EFI_IFR_FLAG_RESET_REQUIRED | \r
+                        EFI_IFR_FLAG_LATE_CHECK )) {\r
+    PrintWarningMessage (mSubStmtFlagsLineNum, "invalid bits defined in flag", NULL);\r
+  }\r
+  WriteByte ((UINT8)mSubStmtFlags, 'F');\r
+  //\r
+  // We can now clear the substatement flags\r
+  //\r
+  mStmtFlags |= mSubStmtFlags;\r
+  mSubStmtFlags = 0;\r
+}\r
+//\r
+// When we parse a min/max/step/default sequence, save off the values for\r
+// later use. Call this first to init the values.\r
+//\r
+VOID \r
+EfiVfrParser::InitMinMaxStepDefault ()\r
+{\r
+  mMinimumValue         = 0;\r
+  mMaximumValue         = 0;\r
+  mStepValue            = 1;\r
+  mDefaultValue         = 0;\r
+}  \r
+VOID \r
+EfiVfrParser::WriteMinMaxStepDefault ()\r
+{\r
+  WriteWord (mMinimumValue);\r
+  WriteWord (mMaximumValue);\r
+  WriteWord (mStepValue);\r
+  WriteWord (mDefaultValue);\r
+}  \r
+VOID \r
+EfiVfrParser::SetMinMaxStepDefault (\r
+  UINT16  Value, \r
+  INT32   MMSD, \r
+  INT32   LineNum\r
+  ) \r
+{\r
+  UINT16 TempValue;\r
+  //\r
+  // Min specified\r
+  //\r
+  if (MMSD == 0) {\r
+    mMinimumValue = Value;\r
+    mDefaultValue = Value;\r
+  //\r
+  // Max specified\r
+  //\r
+  } else if (MMSD == 1) {\r
+    mMaximumValue = Value;\r
+    //\r
+    // If min > max, then swap the values. That includes resetting the default\r
+    // value as well.\r
+    //\r
+    if (mMinimumValue > mMaximumValue) {\r
+      PrintWarningMessage (LineNum, NULL, "maximum < minimum");      \r
+      TempValue = Value;\r
+      mMaximumValue = mMinimumValue;\r
+      mMinimumValue = TempValue;\r
+      mDefaultValue = mMinimumValue;\r
+    }\r
+  //\r
+  // Step specified\r
+  //\r
+  } else if (MMSD == 2) { \r
+    mStepValue = Value;\r
+  //\r
+  // Default specified. Make sure min <= default <= max.\r
+  //\r
+  } else if (MMSD == 3) {\r
+    mDefaultValue = Value;\r
+    if (mMinimumValue > Value) {\r
+      PrintErrorMessage (LineNum, NULL, "default value < minimum value");\r
+    } else if (Value > mMaximumValue) {\r
+      PrintErrorMessage (LineNum, NULL, "default value > maximum value");\r
+    }\r
+  } else {\r
+    PrintErrorMessage (LineNum, "application error", "internal MMSD error");    \r
+  }\r
+}\r
+VOID \r
+EfiVfrParser::AddLabel (\r
+  UINT32 LabelNumber, \r
+  UINT32 LineNum\r
+  ) \r
+{\r
+  UINT16_LIST *Label;\r
+\r
+  //\r
+  // Added a label from the user VFR script. Make sure they haven't already \r
+  // defined the same label elsewhere\r
+  //\r
+  for (Label = mDefinedLabels; Label != NULL; Label = Label->Next) {\r
+    if (Label->Value == LabelNumber) {\r
+      PrintErrorMessage (LineNum, NULL, "label already defined");\r
+      PrintErrorMessage (Label->LineNum, NULL, "previous definition of redefined label");\r
+      break;\r
+    }\r
+  }\r
+  Label = (UINT16_LIST *)malloc (sizeof (UINT16_LIST));\r
+  if (Label == NULL) {\r
+    PrintErrorMessage (0, NULL, "memory allocation error");\r
+    return;\r
+  }\r
+  memset ((char *)Label, 0, sizeof (UINT16_LIST));\r
+  Label->Value = LabelNumber;\r
+  Label->LineNum = LineNum;\r
+  Label->Next = mDefinedLabels;\r
+  mDefinedLabels = Label;\r
+}\r
+VOID \r
+EfiVfrParser::QueueIdEqValList (\r
+  UINT16 Value\r
+  )\r
+{\r
+  UINT16_LIST   *U16;\r
+  \r
+  U16 = (UINT16_LIST *)malloc (sizeof (UINT16_LIST));\r
+  if (U16 == NULL) {\r
+    Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failed");\r
+  } else {\r
+    memset ((char *)U16, 0, sizeof (UINT16_LIST));\r
+    U16->Value = Value;\r
+    if (mUint16List == NULL) {\r
+      mUint16List = U16;\r
+    } else {\r
+      mLastUint16->Next = U16;\r
+    } \r
+    mLastUint16 = U16;\r
+  }\r
+}    \r
+VOID \r
+EfiVfrParser::FlushQueueIdEqValList ()\r
+{\r
+  UINT32 Count;\r
+  \r
+  //\r
+  // We queued up a list of IdEqValList items. The IFR requires a count\r
+  // followed by the actual values. Do it.\r
+  //\r
+  Count = 0;\r
+  mLastUint16 = mUint16List;\r
+  while (mLastUint16 != NULL) {\r
+    Count++;\r
+    mLastUint16 = mLastUint16->Next;\r
+  }\r
+  // BUGBUG -- check for more than 16K items?\r
+  WriteWord (Count);\r
+  //\r
+  // Now write the values.\r
+  //\r
+  mLastUint16 = mUint16List;\r
+  while (mLastUint16 != NULL) {\r
+    WriteWord ((UINT32)mLastUint16->Value);\r
+    mLastUint16 = mLastUint16->Next;\r
+  }\r
+  //\r
+  // Free up the list\r
+  //  \r
+  mLastUint16 = mUint16List;\r
+  while (mUint16List != NULL) {\r
+    mLastUint16 = mUint16List->Next;\r
+    free (mUint16List);\r
+    mUint16List = mLastUint16;\r
+  }\r
+}\r
+VOID \r
+EfiVfrParser::PrintErrorMessage (\r
+  UINT32              LineNum,\r
+  CHAR8               *Msg1,\r
+  CHAR8               *Msg2\r
+  )\r
+{\r
+  char *FileName;\r
+  \r
+  if (LineNum != 0) {\r
+    FileName = ConvertLineNumber ((UINT32 *)&LineNum);\r
+    Error (FileName, LineNum, 0, Msg1, Msg2);\r
+  } else {\r
+    Error (PROGRAM_NAME, 0, 0, Msg1, Msg2);\r
+  }\r
+}\r
+VOID \r
+EfiVfrParser::PrintWarningMessage (\r
+  UINT32              LineNum,\r
+  CHAR8               *Msg1,\r
+  CHAR8               *Msg2\r
+  )\r
+{\r
+  char *FileName;\r
+  \r
+  if (LineNum != 0) {\r
+    FileName = ConvertLineNumber ((UINT32 *)&LineNum);\r
+    Warning (FileName, LineNum, 0, Msg1, Msg2);\r
+  } else {\r
+    Warning (PROGRAM_NAME, 0, 0, Msg1, Msg2);\r
+  }\r
+}\r
+VOID \r
+EfiVfrParser::syn (\r
+  ANTLRAbstractToken  *Tok, \r
+  ANTLRChar           *Egroup, \r
+  SetWordType         *Eset, \r
+  ANTLRTokenType      ETok, \r
+  INT32               Huh\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Called by the parser base class as a result of parse syntax errors.\r
+\r
+Arguments:\r
+  Tok     - token that caused the error\r
+  Egroup  - not sure\r
+  Eset    - index in token table of the expected token\r
+  Huh     - not sure\r
+\r
+Returns:\r
+  NA\r
+\r
+--*/\r
+{\r
+  char    *FileName;\r
+  UINT32  LineNum;\r
+  \r
+  LineNum = Tok->getLine ();\r
+  FileName = ConvertLineNumber ((UINT32 *)&LineNum);\r
+  //\r
+  // Sometimes the token number is 0, in which case I don't know what to\r
+  // print.\r
+  //\r
+  if (ETok == 0) {\r
+    Error (FileName, LineNum, 0, Tok->getText (), "unexpected token");\r
+  } else {\r
+    //\r
+    // If we were expecting an endif, then report the line where the corresponding\r
+    // IF began.\r
+    //\r
+    if ((strcmp (_token_tbl[ETok], "endif") == 0) && (mIfStart != 0)) {\r
+      LineNum = mIfStart;\r
+      FileName = ConvertLineNumber (&LineNum);\r
+      Error (FileName, LineNum, 0, "statement missing corresponding endif", NULL);\r
+    } else {\r
+      Error (FileName, LineNum, 0, Tok->getText (), "expected %s", _token_tbl[ETok]);\r
+    }\r
+  }\r
+}\r
+\r
+VOID \r
+EfiVfrParser::init()        \r
+/*++\r
+\r
+Routine Description:\r
+  Initializations function for our parser.\r
+\r
+Arguments:\r
+  None.\r
+\r
+Returns:\r
+  None.\r
+\r
+--*/\r
+{\r
+  ANTLRParser::init();\r
+\r
+  //\r
+  // Used for queuing a variable list of UINT16's\r
+  //\r
+  mUint16List               = NULL;\r
+  mLastUint16               = NULL;\r
+  mFirstStructDefinition    = NULL;\r
+  mLastStructDefinition     = NULL;\r
+  mNvDataStructSize         = 0;\r
+  mNonNvDataStructSize      = 0;\r
+  mNvDataStructDefined      = 0;\r
+  mGotoReferences           = NULL;\r
+  mFormIdValues             = NULL;\r
+  mDefinedLabels            = NULL;\r
+  mClass                    = 0;\r
+  mSubclass                 = 0;\r
+  mIfStart                  = 0;\r
+  mDefinedVarStoreId        = NULL;\r
+  mLastDefinedVarStoreId    = NULL;\r
+  mIdEqIdStmt               = 0;\r
+  mLastNVVariableDataSize   = 0;\r
+    \r
+  memset ((char *)&mFormSetGuid, 0, sizeof (EFI_GUID));\r
+}\r
+//\r
+// Destructor for the parser.\r
+//\r
+EfiVfrParser::~EfiVfrParser(VOID)\r
+{\r
+  Cleanup();\r
+}\r
+VOID\r
+EfiVfrParser::Cleanup (VOID)\r
+/*++\r
+\r
+Routine Description:\r
+  Free memory allocated during parsing\r
+\r
+Arguments:\r
+  None.\r
+\r
+Returns:\r
+  None.\r
+\r
+--*/\r
+{\r
+  STRUCT_DEFINITION         *NextStruct;\r
+  STRUCT_FIELD_DEFINITION   *NextField;\r
+  UINT8                     Buff[6];\r
+  UINT16_LIST               *NextU16List;\r
+  \r
+  //\r
+  // Free up the structure definitions if any\r
+  //\r
+  while (mFirstStructDefinition != NULL) {\r
+    //\r
+    // Free up all the fields for this struct\r
+    //\r
+    while (mFirstStructDefinition->Field != NULL) {\r
+      NextField = mFirstStructDefinition->Field->Next;\r
+      free (mFirstStructDefinition->Field->Name);\r
+      free (mFirstStructDefinition->Field);\r
+      mFirstStructDefinition->Field = NextField;\r
+    }\r
+    NextStruct = mFirstStructDefinition->Next;\r
+    free (mFirstStructDefinition->Name);\r
+    free (mFirstStructDefinition);\r
+    mFirstStructDefinition = NextStruct;\r
+  }\r
+  //\r
+  // Free up the goto references and form id defines\r
+  //\r
+  FreeGotoReferences ();\r
+  //\r
+  // Free up label list\r
+  //\r
+  while (mDefinedLabels != NULL) {\r
+    NextU16List = mDefinedLabels->Next;\r
+    delete (mDefinedLabels);\r
+    mDefinedLabels = NextU16List;\r
+  }\r
+  //\r
+  // Free up the list of defined variable storage IDs\r
+  //\r
+  while (mDefinedVarStoreId != NULL) {\r
+    NextU16List = mDefinedVarStoreId->Next;\r
+    delete (mDefinedVarStoreId);\r
+    mDefinedVarStoreId = NextU16List;\r
+  }\r
+}\r
+\r
+INT32 \r
+EfiVfrParser::AtoX (\r
+  CHAR8   *HexString, \r
+  INT32   NumBytes, \r
+  UINT32  *HexValue\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Given a pointer to a ascii hex string, convert to a number with the given\r
+  number of bytes.\r
+\r
+Arguments:\r
+  HexString   - pointer to a string of format 30BCA\r
+  Size        - number of bytes to convert\r
+  HexValue    - return result\r
+\r
+Returns:\r
+  The number of bytes converted.\r
+\r
+--*/\r
+{\r
+  INT32 Count;\r
+  INT32 Value;\r
+\r
+  *HexValue = 0;\r
+  Count = 0;\r
+  while (Count < NumBytes) {\r
+    if ((*HexString >= '0') && (*HexString <= '9')) {\r
+      Value = *HexString - '0';\r
+    } else if ((*HexString >= 'a') && (*HexString <= 'f')) {\r
+      Value = *HexString - 'a' + 10;\r
+    } else if ((*HexString >= 'A') && (*HexString <= 'F')) {\r
+      Value = *HexString - 'A' + 10;\r
+    } else {\r
+      return Count;\r
+    }\r
+    HexString++;\r
+    *HexValue = (*HexValue << 4) | Value;\r
+    if ((*HexString >= '0') && (*HexString <= '9')) {\r
+      Value = *HexString - '0';\r
+    } else if ((*HexString >= 'a') && (*HexString <= 'f')) {\r
+      Value = *HexString - 'a' + 10;\r
+    } else if ((*HexString >= 'A') && (*HexString <= 'F')) {\r
+      Value = *HexString - 'A' + 10;\r
+    } else {\r
+      return Count;\r
+    }\r
+    *HexValue = (*HexValue << 4) | Value;\r
+    HexString++;\r
+    Count++;\r
+  }\r
+  return Count;\r
+}\r
+VOID \r
+EfiVfrParser::WriteGuidValue (\r
+  UINT32       TokenLineNum,\r
+  CHAR8        *G1, \r
+  CHAR8        *G2,\r
+  CHAR8        *G3,\r
+  CHAR8        *G4,\r
+  CHAR8        *G5,\r
+  CHAR8        *G6,\r
+  CHAR8        *G7,\r
+  CHAR8        *G8,\r
+  CHAR8        *G9,\r
+  CHAR8        *G10,\r
+  CHAR8        *G11\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  A Guid was parsed, likely of format:\r
+  #define MY_GUID { 0x12345678, 0xAABB, 0xCCDD, 0xEE, 0xFF, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66 }\r
+\r
+  Write out the value.\r
+\r
+Arguments:\r
+  TokenLineNum   - line number where the guid was used\r
+  G1-G11         - the 11 fields of the guid value\r
+\r
+Returns:\r
+  None.\r
+\r
+--*/\r
+{\r
+  UINT32        Value;\r
+  INT32         Loop;\r
+\r
+  mFormSetGuid.Data1 = GetNumber (G1, TokenLineNum, 4);\r
+  mFormSetGuid.Data2 = (UINT16)GetNumber (G2, TokenLineNum, 2);\r
+  mFormSetGuid.Data3 = (UINT16)GetNumber (G3, TokenLineNum, 2);\r
+  mFormSetGuid.Data4[0] = (UINT8)GetNumber (G4, TokenLineNum, 1);\r
+  mFormSetGuid.Data4[1] = (UINT8)GetNumber (G5, TokenLineNum, 1);\r
+  mFormSetGuid.Data4[2] = (UINT8)GetNumber (G6, TokenLineNum, 1);\r
+  mFormSetGuid.Data4[3] = (UINT8)GetNumber (G7, TokenLineNum, 1);\r
+  mFormSetGuid.Data4[4] = (UINT8)GetNumber (G8, TokenLineNum, 1);\r
+  mFormSetGuid.Data4[5] = (UINT8)GetNumber (G9, TokenLineNum, 1);\r
+  mFormSetGuid.Data4[6] = (UINT8)GetNumber (G10, TokenLineNum, 1);\r
+  mFormSetGuid.Data4[7] = (UINT8)GetNumber (G11, TokenLineNum, 1);\r
+  \r
+  WriteDWord (mFormSetGuid.Data1, 'G');\r
+  WriteWord (mFormSetGuid.Data2);\r
+  WriteWord (mFormSetGuid.Data3);\r
+  WriteByte (mFormSetGuid.Data4[0], 0);\r
+  WriteByte (mFormSetGuid.Data4[1], 0);\r
+  WriteByte (mFormSetGuid.Data4[2], 0);\r
+  WriteByte (mFormSetGuid.Data4[3], 0);\r
+  WriteByte (mFormSetGuid.Data4[4], 0);\r
+  WriteByte (mFormSetGuid.Data4[5], 0);\r
+  WriteByte (mFormSetGuid.Data4[6], 0);\r
+  WriteByte (mFormSetGuid.Data4[7], 0);\r
+}\r
+VOID \r
+EfiVfrParser::WriteFieldOffset (\r
+  INT8    WriteLength,\r
+  CHAR8   *StructName, \r
+  INT32   LineNum1, \r
+  CHAR8   *FieldName, \r
+  INT32   LineNum2,\r
+  INT32   ArrayIndex,\r
+  INT8    IsArrayIndex,\r
+  INT32   FieldWidth,\r
+  INT8    WriteArraySize\r
+  ) \r
+/*++\r
+\r
+Routine Description:\r
+  A VFR script referenced the NV store structure. Given the structure's name\r
+  and the field's name, write the offset of the field to the output file.\r
+\r
+Arguments:\r
+  WriteLength     - write the field length byte out\r
+  StructName      - name of the NV store structure\r
+  LineNum1        - line number in the VFR where we are (for error printing)\r
+  FieldName       - the name of the field within the NV store structure\r
+  LineNum2        - line number in the VFR where FieldName is referenced \r
+  ArrayIndex      - the index specified, for example NV_DATA.Field[ArrayIndex]\r
+  IsArrayIndex    - non-zero if an array index was specified\r
+  FieldWidth      - expected size for the Field (1 byte? 2 bytes?)\r
+  WriteArraySize  - write the size of the entire field, not the size of a single element\r
+\r
+Returns:\r
+  None.\r
+\r
+--*/\r
+{\r
+  STRUCT_DEFINITION         *StructDef;\r
+  STRUCT_FIELD_DEFINITION   *FieldDef;\r
+  UINT32                    Offset;\r
+  UINT32                    VarSize;\r
+  CHAR8                     Msg[100];\r
+  //\r
+  // If we're writing an array size, then they better have referenced the field without an\r
+  // index. \r
+  //\r
+  if (WriteArraySize && IsArrayIndex) {\r
+    sprintf (Msg, "array index specified where an array is required");\r
+    PrintErrorMessage (LineNum2, FieldName, Msg);\r
+    return;\r
+  }\r
+  //\r
+  // Look through our list of known structures for a match\r
+  //\r
+  for (StructDef = mFirstStructDefinition; StructDef != NULL; StructDef = StructDef->Next) {\r
+    //\r
+    // Check for matching structure name\r
+    //\r
+    if (strcmp (StructDef->Name, StructName) == 0) {\r
+      //\r
+      // Mark it as referenced (for debug purposes only). Check the\r
+      // flag that indicates that we have already found a varstore VFR\r
+      // statement for it.\r
+      //\r
+      StructDef->Referenced++;\r
+      if (StructDef->VarStoreIdValid == 0) {\r
+        //\r
+        // Set it valid so we don't flag it multiple times, then emit the error\r
+        //\r
+        StructDef->VarStoreIdValid = 1;\r
+        PrintErrorMessage (LineNum1, StructName, "varstore statement missing for this variable store");\r
+      }\r
+      //\r
+      // Let the opcode-handler know which variable storage we're now using\r
+      //\r
+      if (mIdEqIdStmt) {\r
+        mOpcodeHandler.SetSecondaryVarStoreId (StructDef->VarStoreId);\r
+      } else {\r
+        mOpcodeHandler.SetVarStoreId (StructDef->VarStoreId);\r
+      }\r
+      //\r
+      // Found matching structure name. Now find the matching field name\r
+      //\r
+      for (FieldDef = StructDef->Field; FieldDef != NULL; FieldDef = FieldDef->Next) {\r
+        if (strcmp (FieldDef->Name, FieldName) == 0) {\r
+          //\r
+          // Make sure the variable size is valid\r
+          //\r
+          if ((FieldWidth != 0) && (FieldDef->DataSize > FieldWidth)) {\r
+            sprintf (Msg, "field width exceeds %d byte%c", FieldWidth, FieldWidth == 1 ? ' ' : 's');\r
+            PrintErrorMessage (LineNum2, FieldName, Msg);\r
+          }\r
+          //\r
+          // If they specified an index (MyVfrData.FieldX[10]), then make sure that the\r
+          // data structure was declared as an array, and that the index is in bounds.\r
+          // If they did not specify an index, then we'll assume 0. This is required for\r
+          // strings.\r
+          //\r
+          if (IsArrayIndex) {\r
+            VarSize = FieldDef->DataSize;\r
+            if (FieldDef->IsArray == 0) {\r
+              PrintErrorMessage (LineNum2, FieldName, "field is not declared as an array");\r
+              return;\r
+            }\r
+            if (FieldDef->ArrayLength < ArrayIndex) {\r
+              PrintErrorMessage (LineNum2, FieldName, "array index exceeds declared size of field");\r
+              return;\r
+            }\r
+          } else {\r
+            if (FieldDef->IsArray) {\r
+              VarSize = FieldDef->DataSize * FieldDef->ArrayLength;\r
+            } else {\r
+              VarSize = FieldDef->DataSize;\r
+            }\r
+          }\r
+          //\r
+          // If we're in the middle of a ideqid VFR statement, then this is the second\r
+          // variable ID that we're now processing. Make sure that its size is the same\r
+          // as the first variable.\r
+          // \r
+          if (mIdEqIdStmt) {\r
+            if (mLastVarIdSize != VarSize) {\r
+              PrintErrorMessage (LineNum2, FieldName, "variables must have the same size");\r
+              return;\r
+            }\r
+          }\r
+          mLastVarIdSize = VarSize;\r
+          //\r
+          // If we're supposed to write an array size, then require it to be an array\r
+          //\r
+          if (WriteArraySize && !FieldDef->IsArray) {\r
+            PrintErrorMessage (LineNum2, FieldName, "array required");\r
+            return;\r
+          }\r
+          //\r
+          // Write the variable offset and size. If we're in the non-NV structure, then\r
+          // set the offset beyond the NV data structure size.\r
+          //\r
+          Offset = FieldDef->Offset + FieldDef->DataSize * (ArrayIndex - 1);\r
+          if (StructDef->IsNonNV) Offset += mNvDataStructSize; \r
+          WriteWord (Offset);\r
+          if (WriteLength) {\r
+            if (WriteArraySize) {\r
+              if (FieldDef->DataSize * FieldDef->ArrayLength > 255) {\r
+                PrintErrorMessage (LineNum2, FieldName, "array size exceeds 255 maximum encoding limit");\r
+                return;\r
+              }\r
+              WriteByte (FieldDef->DataSize * FieldDef->ArrayLength, 0);\r
+            } else {\r
+              WriteByte (FieldDef->DataSize, 0);\r
+            }\r
+          }\r
+          return;\r
+        }\r
+      }\r
+      sprintf (Msg, "structure %s does not have a field named '%s'", StructName, FieldName);\r
+      PrintErrorMessage (LineNum2, Msg, NULL);\r
+      PrintErrorMessage (StructDef->LineNum, "see structure definition", NULL);\r
+      return;\r
+    }\r
+  }\r
+  //\r
+  // The structure was not found in the defined list. See if it's the "Date" structure\r
+  //\r
+  if (strcmp (StructName, "Date") == 0) {\r
+    //\r
+    // BUGBUG -- remove support for Date and Time as valid structure \r
+    // names. They should use the NON_NV_DATA_MAP structure for this.\r
+    //\r
+    // Someone specified Date.Years|Months|Days\r
+    // BUGBUG -- define some constants for the IDs used here\r
+    // Length == 0 implies that this is not user NV data storage.\r
+    //\r
+    if (strcmp (FieldName, "Year") == 0) {\r
+      //\r
+      // Write ID (offset), ID, and size\r
+      //\r
+      WriteWord (mNvDataStructSize + mNonNvDataStructSize + 0);\r
+      if (WriteLength) {\r
+        WriteByte (0, 0);\r
+      }\r
+    } else if (strcmp (FieldName, "Month") == 0) {\r
+      //\r
+      // Write ID (offset), ID, and size\r
+      //\r
+      WriteWord (mNvDataStructSize + mNonNvDataStructSize + 2);\r
+      if (WriteLength) {\r
+        WriteByte (0, 0);\r
+      }\r
+    } else if (strcmp (FieldName, "Day") == 0) {\r
+      //\r
+      // Write ID (offset), ID, and size\r
+      //\r
+      WriteWord (mNvDataStructSize + mNonNvDataStructSize + 4);\r
+      if (WriteLength) {\r
+        WriteByte (0, 0);\r
+      }\r
+    } else {\r
+      PrintErrorMessage (LineNum1, FieldName, "expected valid field name TheYear/TheMonth/TheDay");\r
+    }\r
+    return;\r
+  } else if (strcmp (StructName, "Time") == 0) {\r
+    //\r
+    // Someone specified Time.Hours|Minutes|Seconds\r
+    // BUGBUG -- define some constants for the IDs used here\r
+    //\r
+    if (strcmp (FieldName, "Hours") == 0) {\r
+      //\r
+      // Write ID (offset), ID, and size\r
+      //\r
+      WriteWord (mNvDataStructSize + mNonNvDataStructSize + 6);\r
+      if (WriteLength) {\r
+        WriteByte (0, 0);\r
+      }\r
+    } else if (strcmp (FieldName, "Minutes") == 0) {\r
+      //\r
+      // Write ID (offset), ID, and size\r
+      //\r
+      WriteWord (mNvDataStructSize + mNonNvDataStructSize + 8);\r
+      if (WriteLength) {\r
+        WriteByte (0, 0);\r
+      }\r
+    } else if (strcmp (FieldName, "Seconds") == 0) {\r
+      //\r
+      // Write ID (offset), ID, and size\r
+      //\r
+      WriteWord (mNvDataStructSize + mNonNvDataStructSize + 10);\r
+      if (WriteLength) {\r
+        WriteByte (0, 0);\r
+      }\r
+    } else {\r
+      PrintErrorMessage (LineNum1, FieldName, "expected valid field name Hours/Minutes/Seconds");\r
+    }\r
+    return;\r
+  } else {\r
+    PrintErrorMessage (LineNum1, StructName, "undefined structure");\r
+    return;\r
+  }\r
+}\r
+VOID\r
+EfiVfrParser::StartStructDefinition (\r
+  INT32  IsNonNV,\r
+  INT32  LineNum\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Called when we encounter a new "struct _MY_STRUCT..." statement while parsing. \r
+  Initialize internal data and structures for parsing the fields of the structure.\r
+\r
+Arguments:\r
+  LineNum  - line number in the source file (for error reporting purposes)\r
+  IsNonNv  - flag indicating (if nonzero) that the variable referred to is not in\r
+             the standard NV store.\r
+Returns:\r
+  None\r
+\r
+--*/\r
+{\r
+  STRUCT_DEFINITION *StructDef;\r
+  //\r
+  // Allocate memory for the structure record\r
+  //\r
+  StructDef = (STRUCT_DEFINITION *)malloc (sizeof (STRUCT_DEFINITION));\r
+  memset (StructDef, 0, sizeof (STRUCT_DEFINITION));\r
+  StructDef->LineNum = LineNum;\r
+  //\r
+  // Set flag indicating non-NV data structure or not\r
+  //\r
+  StructDef->IsNonNV = IsNonNV;\r
+  //\r
+  // Add it to the end of our linked list. If it's the first one\r
+  // defined, then it's the default varstore ID, so set it valid.\r
+  //\r
+  if (mFirstStructDefinition == NULL) {\r
+    mFirstStructDefinition = StructDef;\r
+    StructDef->VarStoreIdValid = 1;\r
+  } else {\r
+    mLastStructDefinition->Next = StructDef;\r
+  }\r
+  mLastStructDefinition = StructDef;\r
+}\r
+VOID\r
+EfiVfrParser::EndStructDefinition (\r
+  CHAR8  *StructName,\r
+  INT32  LineNum\r
+  )\r
+{\r
+  STRUCT_DEFINITION         *StructDef;\r
+  STRUCT_FIELD_DEFINITION   *FieldDef;\r
+  UINT32                    Offset;\r
+  //\r
+  // Make sure they have not already defined a structure with this name\r
+  //\r
+  for (StructDef = mFirstStructDefinition; StructDef != NULL; StructDef = StructDef->Next) {\r
+    if ((StructDef->Name != NULL) && (strcmp (StructDef->Name, StructName) == 0)) {\r
+      PrintErrorMessage (LineNum, StructName, "structure with this name already defined");\r
+      //\r
+      // Fall through and fill in the rest of the structure information. We do\r
+      // this because the structure has already been added to our global list,\r
+      // so will be used elsewhere, so we want it to contain valid fields.\r
+      //\r
+    }\r
+  }    \r
+  //\r
+  // Allocate memory for the structure name \r
+  //\r
+  mLastStructDefinition->Name = (char *)malloc (strlen (StructName) + 1);\r
+  strcpy (mLastStructDefinition->Name, StructName);\r
+  //\r
+  // Compute the structure size, and the offsets to each field\r
+  //\r
+  Offset = 0;\r
+  for (FieldDef = mLastStructDefinition->Field; FieldDef != NULL; FieldDef = FieldDef->Next) {\r
+    FieldDef->Offset = Offset;\r
+    Offset += FieldDef->ArrayLength * FieldDef->DataSize;\r
+  }\r
+  mLastStructDefinition->Size = Offset;\r
+  //\r
+  // Go through all the structure we have so far and figure out (if we can)\r
+  // the size of the non-NV storage. We also assume that the first structure\r
+  // definition is the primary/default storage for the VFR form.\r
+  //\r
+  if (mNonNvDataStructSize == 0) {\r
+    for (StructDef = mFirstStructDefinition; StructDef != NULL; StructDef = StructDef->Next) {\r
+      if (StructDef->IsNonNV) {\r
+        mNonNvDataStructSize = StructDef->Size;\r
+        break;\r
+      }\r
+    }\r
+  }\r
+  if (mNvDataStructSize == 0) {\r
+    for (StructDef = mFirstStructDefinition; StructDef != NULL; StructDef = StructDef->Next) {\r
+      if (StructDef->IsNonNV == 0) {\r
+        mNvDataStructSize = StructDef->Size;\r
+        break;\r
+      }\r
+    }\r
+  }\r
+}\r
+VOID \r
+EfiVfrParser::AddStructField (\r
+  CHAR8   *FieldName, \r
+  INT32   LineNum, \r
+  INT32   DataSize,\r
+  INT32   ArrayLength,\r
+  INT8    IsArray\r
+  ) \r
+/*++\r
+\r
+Routine Description:\r
+  We're parsing the VFR structure definition. Add another defined field to \r
+  our definition.\r
+\r
+Arguments:\r
+  FieldName   - name of the field in the structure.\r
+  LineNum     - the line number from the input (preprocessor output) file\r
+  DataSize    - the size of the field (1, 2, or 4 bytes)\r
+  ArrayLength - the number of elements (for array)\r
+  IsArray     - non-zero if the field is an array\r
+\r
+Returns:\r
+  None.\r
+\r
+--*/\r
+{\r
+  STRUCT_FIELD_DEFINITION *FieldDef;\r
+  STRUCT_FIELD_DEFINITION *Temp;\r
+  //\r
+  // Make sure we don't already have a field of this name in our structure\r
+  //\r
+  for (FieldDef = mLastStructDefinition->Field; FieldDef != NULL; FieldDef = FieldDef->Next) {\r
+    if (strcmp (FieldDef->Name, FieldName) == 0) {\r
+      PrintErrorMessage (LineNum, FieldName, "field with this name already defined");\r
+      return;\r
+    }\r
+  } \r
+  //\r
+  // If it's an array, then they better not have a size of 0. For example:\r
+  //   UINT8 MyBytes[0];\r
+  //\r
+  if (IsArray && (ArrayLength <= 0)) {\r
+    PrintErrorMessage (LineNum, FieldName, "invalid array size");\r
+    return;\r
+  }    \r
+  //\r
+  // Allocate memory for a new structure field definition\r
+  //    \r
+  FieldDef = (STRUCT_FIELD_DEFINITION *)malloc (sizeof (STRUCT_FIELD_DEFINITION));\r
+  memset ((char *)FieldDef, 0, sizeof (STRUCT_FIELD_DEFINITION));\r
+  FieldDef->ArrayLength  = ArrayLength;\r
+  FieldDef->DataSize     = DataSize;\r
+  FieldDef->IsArray      = IsArray;\r
+  FieldDef->Name = (char *)malloc (strlen (FieldName) + 1);\r
+  strcpy (FieldDef->Name, FieldName);\r
+  //\r
+  // Add it to the end of the field list for the currently active structure\r
+  //\r
+  if (mLastStructDefinition->Field == NULL) {\r
+    mLastStructDefinition->Field = FieldDef;\r
+  } else {\r
+    mLastStructDefinition->LastField->Next = FieldDef;\r
+  }\r
+  mLastStructDefinition->LastField = FieldDef;\r
+}\r
+VOID\r
+EfiVfrParser::AddVarStore (\r
+  CHAR8  *StructName,       // actual name of the structure\r
+  CHAR8  *VarName,          // actual NV variable name\r
+  UINT16 VarStoreId,        // key value\r
+  INT32  LineNum            // parse line number (for error reporting)\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Called while parsing a varstore statement. Add the variable store \r
+  to our linked list.\r
+\r
+Arguments:\r
+  StructName    - the name of the typedef'ed structure to use\r
+  VarName       - the NV variable name as specified in the varstore statement\r
+  VarStoreId    - the variable store ID as specified in the varstore statememt\r
+  LineNum       - the line number from the input (preprocessor output) file\r
+\r
+Returns:\r
+  None.\r
+\r
+--*/\r
+{\r
+  STRUCT_DEFINITION *StructDef;\r
+  UINT16_LIST       *L16Ptr;\r
+  //\r
+  // Go through our list of previously-defined variable store IDs and\r
+  // make sure this one is not a duplicate in name or key value.\r
+  //\r
+  for (L16Ptr = mDefinedVarStoreId; L16Ptr != NULL; L16Ptr = L16Ptr->Next) {\r
+    if (L16Ptr->Value == VarStoreId) {\r
+      PrintErrorMessage (LineNum, "variable storage key already used", NULL);\r
+      PrintErrorMessage (L16Ptr->LineNum, "previous usage of storage key", NULL);\r
+    }\r
+  }\r
+  // \r
+  // Key value of 0 is invalid since that's assigned by default to the default\r
+  // variable store (the first structure parsed).\r
+  //\r
+  if (VarStoreId == 0) {\r
+    PrintErrorMessage (LineNum, "variable storage key of 0 is invalid", NULL);\r
+  }\r
+  //\r
+  // Create a new element to add to the list\r
+  //\r
+  L16Ptr = (UINT16_LIST *)malloc(sizeof (UINT16_LIST));\r
+  memset (L16Ptr, 0, sizeof (UINT16_LIST));\r
+  L16Ptr->LineNum = LineNum;\r
+  L16Ptr->Value = VarStoreId;\r
+  if (mDefinedVarStoreId == NULL) {\r
+    mDefinedVarStoreId = L16Ptr;\r
+  } else {\r
+    mLastDefinedVarStoreId->Next = L16Ptr;\r
+  }\r
+  mLastDefinedVarStoreId = L16Ptr;\r
+  //\r
+  // Find the structure definition with this name\r
+  //\r
+  for (StructDef = mFirstStructDefinition; StructDef != NULL; StructDef = StructDef->Next) {\r
+    if (strcmp (StructDef->Name, StructName) == 0) {\r
+      //\r
+      // Make sure they did not already define a variable storage ID \r
+      // for this structure.\r
+      //\r
+      if (StructDef->VarStoreId != 0) {\r
+        PrintErrorMessage (LineNum, StructName, "variable storage already defined for this structure");\r
+        PrintErrorMessage (StructDef->VarStoreLineNum, StructName, "previous definition for variable storage");\r
+      }\r
+      StructDef->VarStoreId       = VarStoreId;\r
+      StructDef->VarStoreIdValid  = 1;\r
+      StructDef->VarStoreLineNum  = LineNum;\r
+      WriteWord (StructDef->Size);\r
+      while (*VarName) {\r
+        WriteByte(*VarName, 0);\r
+        VarName++;\r
+      }\r
+      WriteByte(0,0);\r
+      return;\r
+    }\r
+  }    \r
+  PrintErrorMessage (LineNum, StructName, "structure with this name not defined");\r
+}\r
+VOID \r
+EfiVfrParser::WriteDWord (\r
+  UINT32    Value, \r
+  UINT8     KeyByte\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  During parsing, we came upon some code that requires a 32-bit value be\r
+  written to the VFR binary file. Queue up the 4 bytes.\r
+\r
+Arguments:\r
+  Value   - the 32-bit value to write\r
+  KeyByte - a single character which gets written out beside the first byte.\r
+            This is used to tag the data in the output file so that during \r
+            debug you have an idea what the value is.\r
+\r
+Returns:\r
+  None.\r
+\r
+--*/\r
+{\r
+  //\r
+  // Write 4 bytes, little endian. Specify a key byte only on the first one\r
+  //\r
+  mOpcodeHandler.AddByte ((UINT8)Value, KeyByte);\r
+  Value \>>= 8;\r
+  mOpcodeHandler.AddByte ((UINT8)Value, 0);\r
+  Value \>>= 8;\r
+  mOpcodeHandler.AddByte ((UINT8)Value, 0);\r
+  Value \>>= 8;\r
+  mOpcodeHandler.AddByte ((UINT8)Value, 0);\r
+}\r
+VOID \r
+EfiVfrParser::WriteOpByte (\r
+  UINT32    LineNum,\r
+  UINT8     ByteValue\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  During parsing, we came upon a new VFR opcode. At this point we flush\r
+  the output queue and then queue up this byte (with 'O' for opcode tag).\r
+\r
+Arguments:\r
+\r
+  ByteValue   - opcode value\r
+\r
+Returns:\r
+\r
+  None.\r
+\r
+--*/\r
+{\r
+  mOpcodeHandler.AddOpcodeByte (ByteValue, LineNum);\r
+}\r
+VOID \r
+EfiVfrParser::WriteByte (\r
+  UINT8   ByteValue, \r
+  UINT8   Key\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  During parsing of the VFR we spoonfeed this function with bytes to write to\r
+  the output VFR binary file. This function simply queues up the bytes, and\r
+  the queue gets flushed each time a new VFR opcode is encountered.\r
+\r
+Arguments:\r
+\r
+  ByteValue   - raw byte to write\r
+  Key         - character to tag the byte with when we write ByteValue to the\r
+                output file.\r
+\r
+Returns:\r
+\r
+  None.\r
+\r
+--*/\r
+{\r
+  mOpcodeHandler.AddByte (ByteValue, Key);\r
+}\r
+VOID \r
+EfiVfrParser::WriteWord (\r
+  UINT32  Value\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  During VFR parsing we came upon a case where we need to write out a \r
+  16-bit value. Queue it up.\r
+\r
+Arguments:\r
+  Value - value to write.\r
+\r
+Returns:\r
+  None.\r
+\r
+--*/\r
+{\r
+  mOpcodeHandler.AddByte ((UINT8)Value, 0);\r
+  mOpcodeHandler.AddByte ((UINT8)((Value \>> 8) & 0xFF), 0);\r
+}\r
+VOID \r
+EfiVfrParser::WriteStringIdWord (\r
+  UINT16 WordValue\r
+  )\r
+{\r
+  mOpcodeHandler.AddByte ((UINT8)WordValue, 'S');\r
+  mOpcodeHandler.AddByte ((UINT8)((WordValue \>> 8) & 0xFF), 0);\r
+}\r
+VOID\r
+EfiVfrParser::FreeGotoReferences ()\r
+/*++\r
+\r
+Routine Description:\r
+  Called during cleanup to free up the memory we allocated when\r
+  keeping track of VFR goto statements.\r
+\r
+Arguments:\r
+  None\r
+\r
+Returns:\r
+  None\r
+\r
+--*/\r
+{\r
+  GOTO_REFERENCE  *CurrRef;\r
+  GOTO_REFERENCE  *NextRef;\r
+  FORM_ID_VALUE   *CurrFormId;\r
+  FORM_ID_VALUE   *NextFormId;\r
+  UINT8           Found;\r
+  CHAR8           Name[20];\r
+\r
+  //\r
+  // Go through all the "goto" references and make sure there was a \r
+  // form ID of that value defined.\r
+  //\r
+  for (CurrRef = mGotoReferences; CurrRef != NULL; CurrRef = CurrRef->Next) {\r
+    Found = 0;\r
+    for (CurrFormId = mFormIdValues; CurrFormId != NULL; CurrFormId = CurrFormId->Next) {\r
+      if (CurrRef->Value == CurrFormId->Value) {\r
+        Found = 1;\r
+        break;\r
+      }\r
+    }\r
+    if (!Found) {\r
+      sprintf (Name, "%d", (UINT32)CurrRef->Value);\r
+      PrintErrorMessage (CurrRef->RefLineNum, Name, "undefined form ID");\r
+    }  \r
+  }  \r
+  //\r
+  // Now free up the form id and goto references\r
+  //\r
+  CurrFormId = mFormIdValues;\r
+  while (CurrFormId != NULL) {\r
+    NextFormId = CurrFormId->Next;\r
+    free (CurrFormId);\r
+    CurrFormId = NextFormId;\r
+  }\r
+  mFormIdValues = NULL;\r
+  CurrRef = mGotoReferences;\r
+  while (CurrRef != NULL) {\r
+    NextRef = CurrRef->Next;\r
+    free (CurrRef);\r
+    CurrRef = NextRef;\r
+  }  \r
+  mGotoReferences = NULL;\r
+}\r
+VOID\r
+EfiVfrParser::AddGotoReference (\r
+  UINT32  GotoNumber,\r
+  UINT32  LineNum\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  During VFR parsing we came upon a goto statement. Since we support\r
+  forward references, save the referenced label and at the end of parsing\r
+  we'll check that the label was actually defined somewhere.\r
+\r
+Arguments:\r
+  GotoNumber  - the label number referenced\r
+  LineNum     - the line number where the reference was made (used for\r
+                error reporting)\r
+\r
+Returns:\r
+  None\r
+\r
+--*/\r
+{\r
+  GOTO_REFERENCE *NewRef;\r
+  \r
+  NewRef = (GOTO_REFERENCE *)malloc (sizeof (GOTO_REFERENCE));\r
+  if (NewRef == NULL) {\r
+    Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");\r
+    return;\r
+  }\r
+  memset ((char *)NewRef, 0, sizeof (GOTO_REFERENCE));\r
+  NewRef->Value = (UINT16)GotoNumber;\r
+  NewRef->RefLineNum = LineNum;\r
+  NewRef->Next = mGotoReferences;\r
+  mGotoReferences = NewRef;\r
+}\r
+VOID\r
+EfiVfrParser::AddFormId (\r
+  INT32   FormIdValue,\r
+  UINT32  LineNum\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  This function is called when we parse "form formid = 3" statements.\r
+  We save the form ID valud so we can verify that duplicates are not\r
+  defined. Also, these are the targets of goto statements, so when we're\r
+  done parsing the script we also go through all the goto statements to\r
+  check that there was a target FormId defined as referenced by each\r
+  goto statement.\r
+  \r
+  Note that formid = 0 is invalid.\r
+\r
+Arguments:\r
+  FormIdValue  - the parsed value for the Form ID\r
+  LineNum      - line number of the source file we're parsing\r
+\r
+Returns:\r
+  NA\r
+\r
+--*/\r
+{\r
+  FORM_ID_VALUE *NewFormId;\r
+  char          *FileName;\r
+  char          *FileName2;\r
+  UINT32        LineNum2;  \r
+  //\r
+  // Verify that FormId != 0\r
+  //\r
+  if (FormIdValue == 0) {\r
+    FileName = ConvertLineNumber (&LineNum);\r
+    Error (FileName, LineNum, 0, "form ID cannot be 0", NULL);\r
+    return;\r
+  }\r
+  //\r
+  // First go through all previously defined form IDs and make sure they have not defined\r
+  // duplicates.\r
+  //\r
+  for (NewFormId = mFormIdValues; NewFormId != NULL; NewFormId = NewFormId->Next) {\r
+    if ((UINT16)FormIdValue == NewFormId->Value) {\r
+      FileName = ConvertLineNumber (&LineNum);\r
+      LineNum2 = NewFormId->LineNum;\r
+      FileName2 = ConvertLineNumber (&LineNum2);\r
+      Error (FileName, LineNum, 0, NULL, "form ID %d already defined", FormIdValue);\r
+      Error (FileName2, LineNum2, 0, NULL, "form ID %d previous definition", FormIdValue);\r
+      return;\r
+    }\r
+  }\r
+  //\r
+  // Allocate memory for a new one \r
+  //\r
+  NewFormId = (FORM_ID_VALUE *)malloc (sizeof (FORM_ID_VALUE));\r
+  if (NewFormId == NULL) {\r
+    Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");\r
+    return;\r
+  }\r
+  memset ((char *)NewFormId, 0, sizeof (FORM_ID_VALUE));\r
+  NewFormId->LineNum = LineNum;\r
+  NewFormId->Next = mFormIdValues;\r
+  NewFormId->Value = (UINT16)FormIdValue;\r
+  mFormIdValues = NewFormId;\r
+}\r
+UINT32\r
+EfiVfrParser::GetNumber (\r
+  CHAR8   *NumStr,\r
+  UINT32  LineNum,\r
+  UINT32  NumBytes\r
+  )\r
+{\r
+  UINT32 Value;\r
+  \r
+  if ((NumStr[0] == '0') && (NumStr[1] == 'x')) {\r
+    AtoX (NumStr + 2, 4, &Value);\r
+  } else {\r
+    Value = (UINT32)atoi (NumStr);\r
+  }\r
+  //\r
+  // Check range\r
+  //\r
+  if ((NumBytes < 4) && (Value & ((UINT32)0xFFFFFFFF << (NumBytes * 8)))) {\r
+    PrintErrorMessage (LineNum, NumStr, "value out of range");\r
+    return 0;\r
+  }\r
+  return Value;\r
+}\r
+\r
+>>\r
+\r
+} // end grammar class\r
+\r
diff --git a/Tools/CodeTools/Source/VfrCompile/VfrServices.cpp b/Tools/CodeTools/Source/VfrCompile/VfrServices.cpp
new file mode 100644 (file)
index 0000000..359256a
--- /dev/null
@@ -0,0 +1,758 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2005, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  VfrServices.cpp\r
+\r
+Abstract:\r
+\r
+  Support routines for the VFR compiler\r
+  \r
+--*/  \r
+\r
+#include <stdio.h>    // for FILE routines\r
+#include <stdlib.h>   // for malloc() and free()\r
+\r
+#include <Common/UefiBaseTypes.h>\r
+#include <Common/MultiPhase.h>\r
+#include <Common/InternalFormRepresentation.h>\r
+#include <Protocol/UgaDraw.h>  // for EFI_UGA_PIXEL definition\r
+#include <Protocol/Hii.h>\r
+\r
+#include "EfiUtilityMsgs.h"\r
+#include "EfiVfr.h"\r
+#include "VfrServices.h"\r
+\r
+\r
+static const char *mSourceFileHeader[] = {\r
+  "//",\r
+  "//  DO NOT EDIT -- auto-generated file",\r
+  "//",\r
+  "//  This file is generated by the VFR compiler.",\r
+  "//",\r
+  NULL\r
+};\r
+\r
+typedef struct {\r
+   CHAR8    *Name;\r
+   INT32    Size;\r
+} IFR_OPCODE_SIZES;\r
+\r
+//\r
+// Create a table that can be used to do internal checking on the IFR\r
+// bytes we emit.\r
+//\r
+static const IFR_OPCODE_SIZES mOpcodeSizes[] = {\r
+  { 0, 0 },     // invalid\r
+  { "EFI_IFR_FORM",                       sizeof (EFI_IFR_FORM) },\r
+  { "EFI_IFR_SUBTITLE",                   sizeof (EFI_IFR_SUBTITLE) }, \r
+  { "EFI_IFR_TEXT",                       -6 }, //sizeof (EFI_IFR_TEXT) }, \r
+  { "unused 0x04 opcode",                 0 }, // EFI_IFR_GRAPHIC_OP\r
+  { "EFI_IFR_ONE_OF",                     sizeof (EFI_IFR_ONE_OF) }, \r
+  { "EFI_IFR_CHECKBOX",                   sizeof (EFI_IFR_CHECKBOX) }, \r
+  { "EFI_IFR_NUMERIC",                    sizeof (EFI_IFR_NUMERIC) }, \r
+  { "EFI_IFR_PASSWORD",                   sizeof (EFI_IFR_PASSWORD) }, \r
+  { "EFI_IFR_ONE_OF_OPTION",              sizeof (EFI_IFR_ONE_OF_OPTION) }, \r
+  { "EFI_IFR_SUPPRESS",                   sizeof (EFI_IFR_SUPPRESS) }, \r
+  { "EFI_IFR_END_FORM",                   sizeof (EFI_IFR_END_FORM) }, \r
+  { "EFI_IFR_HIDDEN",                     sizeof (EFI_IFR_HIDDEN) }, \r
+  { "EFI_IFR_END_FORM_SET",               sizeof (EFI_IFR_END_FORM_SET) }, \r
+  { "EFI_IFR_FORM_SET",                   sizeof (EFI_IFR_FORM_SET) }, \r
+  { "EFI_IFR_REF",                        sizeof (EFI_IFR_REF) }, \r
+  { "EFI_IFR_END_ONE_OF",                 sizeof (EFI_IFR_END_ONE_OF) }, \r
+  { "EFI_IFR_INCONSISTENT",               sizeof (EFI_IFR_INCONSISTENT) }, \r
+  { "EFI_IFR_EQ_ID_VAL",                  sizeof (EFI_IFR_EQ_ID_VAL) }, \r
+  { "EFI_IFR_EQ_ID_ID",                   sizeof (EFI_IFR_EQ_ID_ID) }, \r
+  { "EFI_IFR_EQ_ID_LIST",                 -sizeof (EFI_IFR_EQ_ID_LIST) }, \r
+  { "EFI_IFR_AND",                        sizeof (EFI_IFR_AND) }, \r
+  { "EFI_IFR_OR",                         sizeof (EFI_IFR_OR) }, \r
+  { "EFI_IFR_NOT",                        sizeof (EFI_IFR_NOT) }, \r
+  { "EFI_IFR_END_EXPR",                   sizeof (EFI_IFR_END_EXPR) }, \r
+  { "EFI_IFR_GRAY_OUT",                   sizeof (EFI_IFR_GRAY_OUT) }, \r
+  { "EFI_IFR_DATE",                       sizeof (EFI_IFR_DATE) / 3 }, \r
+  { "EFI_IFR_TIME",                       sizeof (EFI_IFR_TIME) / 3 }, \r
+  { "EFI_IFR_STRING",                     sizeof (EFI_IFR_STRING) }, \r
+  { "EFI_IFR_LABEL",                      sizeof (EFI_IFR_LABEL) }, \r
+  { "EFI_IFR_SAVE_DEFAULTS",              sizeof (EFI_IFR_SAVE_DEFAULTS) }, \r
+  { "EFI_IFR_RESTORE_DEFAULTS",           sizeof (EFI_IFR_RESTORE_DEFAULTS) }, \r
+  { "EFI_IFR_BANNER",                     sizeof (EFI_IFR_BANNER) },\r
+  { "EFI_IFR_INVENTORY",                  sizeof (EFI_IFR_INVENTORY) },\r
+  { "EFI_IFR_EQ_VAR_VAL_OP",              sizeof (EFI_IFR_EQ_VAR_VAL) },\r
+  { "EFI_IFR_ORDERED_LIST_OP",            sizeof (EFI_IFR_ORDERED_LIST) },\r
+  { "EFI_IFR_VARSTORE_OP",                -sizeof (EFI_IFR_VARSTORE) },\r
+  { "EFI_IFR_VARSTORE_SELECT_OP",         sizeof (EFI_IFR_VARSTORE_SELECT) },\r
+  { "EFI_IFR_VARSTORE_SELECT_PAIR_OP",    sizeof (EFI_IFR_VARSTORE_SELECT_PAIR) },\r
+  { "EFI_IFR_TRUE",                       sizeof (EFI_IFR_TRUE)},\r
+  { "EFI_IFR_FALSE",                      sizeof (EFI_IFR_FALSE)},\r
+  { "EFI_IFR_GT",                         sizeof (EFI_IFR_GT)},\r
+  { "EFI_IFR_GE",                         sizeof (EFI_IFR_GE)},\r
+  { "EFI_IFR_OEM_DEFINED_OP",             -2 },\r
+};\r
+\r
+\r
+VfrOpcodeHandler::VfrOpcodeHandler (\r
+  ) \r
+/*++\r
+\r
+Routine Description:\r
+  Constructor for the VFR opcode handling class.\r
+  \r
+Arguments:\r
+  None\r
+\r
+Returns:\r
+  None\r
+\r
+--*/\r
+{ \r
+  mIfrBytes                       = NULL; \r
+  mLastIfrByte                    = NULL;\r
+  mBytesWritten                   = 0;\r
+  mQueuedByteCount                = 0;\r
+  mQueuedOpcodeByteValid          = 0;\r
+  mPrimaryVarStoreId              = 0;\r
+  mSecondaryVarStoreId            = 0;\r
+  mSecondaryVarStoreIdSet         = 0;\r
+  mPrimaryVarStoreIdSet           = 0;\r
+  mDefaultVarStoreId              = 0;\r
+}\r
+\r
+VOID \r
+VfrOpcodeHandler::SetVarStoreId (\r
+  UINT16 VarStoreId\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  This function is invoked by the parser when a variable is referenced in the \r
+  VFR. Save the variable store (and set a flag) so that we can later determine \r
+  if we need to emit a varstore-select or varstore-select-pair opcode.\r
+  \r
+Arguments:\r
+  VarStoreId - ID of the variable store referenced in the VFR\r
+\r
+Returns:\r
+  None\r
+\r
+--*/\r
+{\r
+  mPrimaryVarStoreId    = VarStoreId;\r
+  mPrimaryVarStoreIdSet = 1;\r
+}\r
+\r
+VOID \r
+VfrOpcodeHandler::SetSecondaryVarStoreId (\r
+  UINT16 VarStoreId\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  This function is invoked by the parser when a secondary variable is \r
+  referenced in the VFR. Save the variable store (and set a flag) so \r
+  that we can later determine if we need to emit a varstore-select or \r
+  varstore-pair opcode.\r
+  \r
+Arguments:\r
+  VarStoreId - ID of the variable store referenced in the VFR\r
+\r
+Returns:\r
+  None\r
+\r
+--*/\r
+{\r
+  mSecondaryVarStoreId    = VarStoreId;\r
+  mSecondaryVarStoreIdSet = 1;\r
+}\r
+\r
+VOID \r
+VfrOpcodeHandler::WriteIfrBytes (\r
+  ) \r
+/*++\r
+\r
+Routine Description:\r
+  This function is invoked at the end of parsing. Its purpose\r
+  is to write out all the IFR bytes that were queued up while\r
+  parsing.\r
+  \r
+Arguments:\r
+  None\r
+\r
+Returns:\r
+  None\r
+\r
+--*/\r
+{ \r
+  IFR_BYTE                  *Curr;\r
+  IFR_BYTE                  *Next;\r
+  UINT32                    Count;\r
+  UINT32                    LineCount;\r
+  UINT32                    PoundLines;\r
+  UINT32                    ByteCount;\r
+  CHAR8                     Line[MAX_LINE_LEN];\r
+  CHAR8                     *Cptr;\r
+  FILE                      *InFptr;\r
+  FILE                      *OutFptr;\r
+  UINT32                    ListFile;\r
+  EFI_HII_IFR_PACK_HEADER   IfrHeader;\r
+  UINT8                     *Ptr;\r
+  FILE                      *IfrBinFptr;\r
+  UINT32                    BytesLeftThisOpcode;\r
+  //\r
+  // If someone added a new opcode and didn't update our opcode sizes structure, error out.\r
+  //\r
+  if (sizeof(mOpcodeSizes) / sizeof (mOpcodeSizes[0]) != EFI_IFR_LAST_OPCODE + 1) {\r
+    Error (__FILE__, __LINE__, 0, "application error", "internal IFR binary table size is incorrect");\r
+    return;\r
+  }\r
+  //\r
+  // Flush the queue\r
+  //\r
+  FlushQueue ();    \r
+  //\r
+  // If there have been any errors to this point, then skip dumping the IFR\r
+  // binary data. This way doing an nmake again will try to build it again, and\r
+  // the build will fail if they did not fix the problem.\r
+  //\r
+  if (GetUtilityStatus () != STATUS_ERROR) {\r
+    if ((IfrBinFptr = fopen (gOptions.IfrOutputFileName, "w")) == NULL) {\r
+      Error (PROGRAM_NAME, 0, 0, gOptions.IfrOutputFileName, "could not open file for writing");\r
+      return;\r
+    }\r
+    //\r
+    // Write the standard file header to the output file\r
+    //\r
+    WriteStandardFileHeader (IfrBinFptr);\r
+    //\r
+    // Write the structure header\r
+    //\r
+    fprintf (IfrBinFptr, "\nunsigned char %sBin[] = {", gOptions.VfrBaseFileName);\r
+    //\r
+    // Write the header\r
+    //\r
+    memset ((char *)&IfrHeader, 0, sizeof (IfrHeader));\r
+    IfrHeader.Header.Type = EFI_HII_IFR;\r
+    IfrHeader.Header.Length = mBytesWritten + sizeof (IfrHeader);    \r
+    Ptr = (UINT8 *)&IfrHeader;\r
+    for (Count = 0; Count < sizeof (IfrHeader); Count++, Ptr++) {\r
+      if ((Count & 0x03) == 0) {\r
+        fprintf (IfrBinFptr, "\n  ");\r
+      }\r
+      fprintf (IfrBinFptr, "0x%02X, ", *Ptr);      \r
+    }\r
+    //\r
+    //\r
+    // Write all the IFR bytes\r
+    //\r
+    fprintf (IfrBinFptr, "\n  // start of IFR data");\r
+    Curr = mIfrBytes;\r
+    Count = 0;\r
+    while (Curr != NULL) {\r
+      if ((Count & 0x0F) == 0) {\r
+        fprintf (IfrBinFptr, "\n  ");\r
+      }\r
+      if (Curr->KeyByte != 0) {\r
+        fprintf (IfrBinFptr, "/*%c*/ ", Curr->KeyByte);\r
+      }\r
+      fprintf (IfrBinFptr, "0x%02X, ", Curr->OpcodeByte);\r
+      Count++;\r
+      Curr = Curr->Next;\r
+    }\r
+    fprintf (IfrBinFptr, "\n};\n\n");\r
+    //\r
+    //\r
+    // Close the file\r
+    //\r
+    fclose (IfrBinFptr); \r
+    IfrBinFptr = NULL;\r
+  }\r
+  //\r
+  // Write the bytes as binary data if the user specified to do so\r
+  //\r
+  if ((GetUtilityStatus () != STATUS_ERROR) &&  (gOptions.CreateIfrBinFile != 0)) {\r
+    //\r
+    // Use the Ifr output file name with a ".hpk" extension.\r
+    //\r
+    for (Cptr = gOptions.IfrOutputFileName + strlen (gOptions.IfrOutputFileName) - 1;\r
+         (*Cptr != '.') && (Cptr > gOptions.IfrOutputFileName) && (*Cptr != '\\');\r
+         Cptr--) {\r
+      //\r
+      // do nothing\r
+      //\r
+    }\r
+    if (*Cptr == '.') {\r
+      strcpy (Cptr, ".hpk");\r
+    } else {\r
+      strcat (gOptions.IfrOutputFileName, ".hpk");\r
+    }\r
+    if ((IfrBinFptr = fopen (gOptions.IfrOutputFileName, "wb")) == NULL) {\r
+      Error (PROGRAM_NAME, 0, 0, gOptions.IfrOutputFileName, "could not open file for writing");\r
+      return;\r
+    }\r
+    //\r
+    // Write the structure header\r
+    //\r
+    memset ((char *)&IfrHeader, 0, sizeof (IfrHeader));\r
+    IfrHeader.Header.Type = EFI_HII_IFR;\r
+    IfrHeader.Header.Length = mBytesWritten + sizeof (IfrHeader);    \r
+    Ptr = (UINT8 *)&IfrHeader;\r
+    for (Count = 0; Count < sizeof (IfrHeader); Count++, Ptr++) {\r
+      fwrite (Ptr, 1, 1, IfrBinFptr);\r
+    }\r
+    //\r
+    //\r
+    // Write all the IFR bytes\r
+    //\r
+    Curr = mIfrBytes;\r
+    Count = 0;\r
+    while (Curr != NULL) {\r
+      fwrite (&Curr->OpcodeByte, 1, 1, IfrBinFptr);\r
+      Curr = Curr->Next;\r
+    }\r
+    //\r
+    //\r
+    // Close the file\r
+    //\r
+    fclose (IfrBinFptr); \r
+    IfrBinFptr = NULL;\r
+  }\r
+  //\r
+  // If creating a listing file, then open the input and output files\r
+  //\r
+  ListFile = 0;\r
+  if (gOptions.CreateListFile) {\r
+    //\r
+    // Open the input VFR file and the output list file\r
+    //\r
+    if ((InFptr = fopen (gOptions.PreprocessorOutputFileName, "r")) == NULL) {\r
+      Warning (PROGRAM_NAME, 0, 0, gOptions.PreprocessorOutputFileName, "could not open file for creating a list file");\r
+    } else {\r
+      if ((OutFptr = fopen (gOptions.VfrListFileName, "w")) == NULL) {\r
+        Warning (PROGRAM_NAME, 0, 0, gOptions.VfrListFileName, "could not open output list file for writing");\r
+        fclose (InFptr);\r
+        InFptr = NULL;\r
+      } else {\r
+        LineCount   = 0;\r
+        ListFile    = 1;\r
+        PoundLines  = 0;\r
+        ByteCount   = 0;\r
+      }\r
+    }\r
+  }\r
+  //\r
+  // Write the list file\r
+  //\r
+  if (ListFile) {\r
+    //\r
+    // Write out the VFR compiler version\r
+    //\r
+    fprintf (OutFptr, "//\n//  VFR compiler version " VFR_COMPILER_VERSION "\n//\n");\r
+    Curr = mIfrBytes;\r
+    while (Curr != NULL) {\r
+      //\r
+      // Print lines until we reach the line of the current opcode\r
+      //\r
+      while (LineCount < PoundLines + Curr->LineNum) {\r
+        if (fgets (Line, sizeof (Line), InFptr) != NULL) {\r
+          //\r
+          // We should check for line length exceeded on the fgets(). Otherwise it\r
+          // throws the listing file output off. Future enhancement perhaps.\r
+          //\r
+          fprintf (OutFptr, "%s", Line);\r
+          if (strncmp (Line, "#line", 5) == 0) {\r
+            PoundLines++;\r
+          }\r
+        }\r
+        LineCount++;\r
+      }\r
+      //\r
+      // Print all opcodes with line numbers less than where we are now\r
+      //\r
+      BytesLeftThisOpcode = 0;\r
+      while ((Curr != NULL) && ((Curr->LineNum == 0) || (LineCount >= PoundLines + Curr->LineNum))) {\r
+        if (BytesLeftThisOpcode == 0) {\r
+          fprintf (OutFptr, ">%08X: ", ByteCount);\r
+          if (Curr->Next != NULL) {\r
+            BytesLeftThisOpcode = (UINT32)Curr->Next->OpcodeByte;\r
+          }\r
+        }\r
+        fprintf (OutFptr, "%02X ", (UINT32)Curr->OpcodeByte);\r
+        ByteCount++;\r
+        BytesLeftThisOpcode--;\r
+        if (BytesLeftThisOpcode == 0) {\r
+          fprintf (OutFptr, "\n");\r
+        }\r
+        Curr = Curr->Next;\r
+      }\r
+    }\r
+    //\r
+    // Dump any remaining lines from the input file\r
+    //\r
+    while (fgets (Line, sizeof (Line), InFptr) != NULL) {\r
+      fprintf (OutFptr, "%s", Line);\r
+    }\r
+    fclose (InFptr);\r
+    fclose (OutFptr);\r
+  }\r
+  //\r
+  // Debug code to make sure that each opcode we write out has as many\r
+  // bytes as the IFR structure requires. If there were errors, then\r
+  // don't do this step.\r
+  //\r
+  if (GetUtilityStatus () != STATUS_ERROR) {\r
+    Curr = mIfrBytes;\r
+    ByteCount = 0;\r
+    while (Curr != NULL) {\r
+      //\r
+      // First byte is the opcode, second byte is the length\r
+      //\r
+      if (Curr->Next == NULL) {\r
+        Error (__FILE__, __LINE__, 0, "application error", "last opcode written does not contain a length byte");\r
+        break;\r
+      }\r
+      Count = (UINT32)Curr->Next->OpcodeByte;\r
+      if (Count == 0) {\r
+        Error (\r
+          __FILE__, \r
+          __LINE__, \r
+          0, \r
+          "application error", \r
+          "opcode with 0 length specified in output at offset 0x%X", \r
+          ByteCount\r
+          );\r
+        break;\r
+      }\r
+      //\r
+      // Check the length\r
+      //\r
+      if ((Curr->OpcodeByte > EFI_IFR_LAST_OPCODE) || (Curr->OpcodeByte == 0)) {\r
+        Error (\r
+          __FILE__, \r
+          __LINE__, \r
+          0, \r
+          "application error", \r
+          "invalid opcode 0x%X in output at offset 0x%X", \r
+          (UINT32) Curr->OpcodeByte, ByteCount\r
+          );\r
+      } else if (mOpcodeSizes[Curr->OpcodeByte].Size < 0) {\r
+        //\r
+        // For those cases where the length is variable, the size is negative, and indicates\r
+        // the miniumum size.\r
+        //\r
+        if ((mOpcodeSizes[Curr->OpcodeByte].Size * -1) > Count) {\r
+          Error (\r
+            __FILE__, \r
+            __LINE__, \r
+            0, \r
+            "application error", \r
+            "insufficient number of bytes written for %s at offset 0x%X",\r
+            mOpcodeSizes[Curr->OpcodeByte].Name, \r
+            ByteCount\r
+            );\r
+        }\r
+      } else {\r
+        //\r
+        // Check for gaps\r
+        //\r
+        if (mOpcodeSizes[Curr->OpcodeByte].Size == 0) {\r
+          Error (\r
+            __FILE__, \r
+            __LINE__, \r
+            0, \r
+            "application error", \r
+            "invalid opcode 0x%X in output at offset 0x%X", \r
+            (UINT32)Curr->OpcodeByte, \r
+            ByteCount\r
+            );\r
+        } else {\r
+          //\r
+          // Check size\r
+          //\r
+          if (mOpcodeSizes[Curr->OpcodeByte].Size != Count) {\r
+            Error (\r
+              __FILE__, \r
+              __LINE__, \r
+              0, \r
+              "application error", \r
+              "invalid number of bytes (%d written s/b %d) written for %s at offset 0x%X",\r
+              Count, \r
+              mOpcodeSizes[Curr->OpcodeByte].Size, \r
+              mOpcodeSizes[Curr->OpcodeByte].Name, \r
+              ByteCount\r
+              );\r
+          }\r
+        }\r
+      }\r
+      //\r
+      // Skip to next opcode\r
+      //\r
+      while (Count > 0) {\r
+        ByteCount++;\r
+        if (Curr == NULL) {\r
+          Error (__FILE__, __LINE__, 0, "application error", "last opcode written has invalid length");\r
+          break;\r
+        }\r
+        Curr = Curr->Next;\r
+        Count--;\r
+      }\r
+    }\r
+  }\r
+}\r
+\r
+VfrOpcodeHandler::~VfrOpcodeHandler(\r
+  ) \r
+/*++\r
+\r
+Routine Description:\r
+  Destructor for the VFR opcode handler. Free up memory allocated\r
+  while parsing the VFR script.\r
+  \r
+Arguments:\r
+  None\r
+\r
+Returns:\r
+  None\r
+\r
+--*/\r
+{\r
+  IFR_BYTE    *Curr;\r
+  IFR_BYTE    *Next;\r
+  //\r
+  // Free up the IFR bytes\r
+  //\r
+  Curr = mIfrBytes;\r
+  while (Curr != NULL) {\r
+    Next = Curr->Next;\r
+    free (Curr);\r
+    Curr = Next;\r
+  }\r
+}\r
+\r
+int \r
+VfrOpcodeHandler::AddOpcodeByte (\r
+  UINT8 OpcodeByte, \r
+  UINT32 LineNum\r
+  ) \r
+/*++\r
+\r
+Routine Description:\r
+  This function is invoked by the parser when a new IFR\r
+  opcode should be emitted.\r
+  \r
+Arguments:\r
+  OpcodeByte  - the IFR opcode\r
+  LineNum     - the line number from the source file that resulted\r
+                in the opcode being emitted.\r
+\r
+Returns:\r
+  0 always\r
+\r
+--*/\r
+{\r
+  UINT32 Count;\r
+\r
+  FlushQueue();\r
+  //\r
+  // Now add this new byte\r
+  //\r
+  mQueuedOpcodeByte       = OpcodeByte;\r
+  mQueuedLineNum          = LineNum;\r
+  mQueuedOpcodeByteValid  = 1;\r
+  return 0;\r
+}\r
+\r
+VOID \r
+VfrOpcodeHandler::AddByte (\r
+  UINT8 ByteVal, \r
+  UINT8 KeyByte\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  This function is invoked by the parser when it determines\r
+  that more raw IFR bytes should be emitted to the output stream.\r
+  Here we just queue them up into an output buffer.\r
+  \r
+Arguments:\r
+  ByteVal   - the raw byte to emit to the output IFR stream\r
+  KeyByte   - a value that can be used for debug. \r
+\r
+Returns:\r
+  None\r
+\r
+--*/\r
+{\r
+  //\r
+  // Check for buffer overflow\r
+  //\r
+  if (mQueuedByteCount > MAX_QUEUE_COUNT) {\r
+    Error (PROGRAM_NAME, 0, 0, NULL, "opcode queue overflow");\r
+  } else {\r
+    mQueuedBytes[mQueuedByteCount]    = ByteVal;\r
+    mQueuedKeyBytes[mQueuedByteCount] = KeyByte;\r
+    mQueuedByteCount++;\r
+  }\r
+}\r
+\r
+int \r
+VfrOpcodeHandler::FlushQueue (\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  This function is invoked to flush the internal IFR buffer.\r
+  \r
+Arguments:\r
+  None\r
+\r
+Returns:\r
+  0 always\r
+\r
+--*/\r
+{\r
+  UINT32 Count;\r
+  UINT32 EmitNoneOnePair;\r
+\r
+  EmitNoneOnePair = 0;\r
+  //\r
+  // If the secondary varstore was specified, then we have to emit\r
+  // a varstore-select-pair opcode, which only applies to the following\r
+  // statement. \r
+  //\r
+  if (mSecondaryVarStoreIdSet) {\r
+    mSecondaryVarStoreIdSet = 0;\r
+    //\r
+    // If primary and secondary are the same as the current default\r
+    // varstore, then we don't have to do anything.\r
+    // Note that the varstore-select-pair only applies to the following\r
+    // opcode.\r
+    //\r
+    if ((mPrimaryVarStoreId != mSecondaryVarStoreId) || (mPrimaryVarStoreId != mDefaultVarStoreId)) {\r
+      IAddByte (EFI_IFR_VARSTORE_SELECT_PAIR_OP, 'O', mQueuedLineNum);\r
+      IAddByte ((UINT8)sizeof (EFI_IFR_VARSTORE_SELECT_PAIR), 'L', 0);\r
+      IAddByte ((UINT8)mPrimaryVarStoreId, 0, 0);\r
+      IAddByte ((UINT8)(mPrimaryVarStoreId >> 8), 0, 0);\r
+      IAddByte ((UINT8)mSecondaryVarStoreId, 0, 0);\r
+      IAddByte ((UINT8)(mSecondaryVarStoreId >> 8), 0, 0);\r
+    }\r
+  } else if (mPrimaryVarStoreIdSet != 0) {\r
+    mPrimaryVarStoreIdSet = 0;\r
+    if (mDefaultVarStoreId != mPrimaryVarStoreId) {\r
+      //\r
+      // The VFR statement referenced a different variable store \r
+      // than the last one we reported. Insert a new varstore select \r
+      // statement. \r
+      //\r
+      IAddByte (EFI_IFR_VARSTORE_SELECT_OP, 'O', mQueuedLineNum);\r
+      IAddByte ((UINT8)sizeof (EFI_IFR_VARSTORE_SELECT), 'L', 0);\r
+      IAddByte ((UINT8)mPrimaryVarStoreId, 0, 0);\r
+      IAddByte ((UINT8)(mPrimaryVarStoreId >> 8), 0, 0);\r
+      mDefaultVarStoreId = mPrimaryVarStoreId;\r
+    }\r
+  }\r
+  //\r
+  // Likely a new opcode is being added. Since each opcode item in the IFR has \r
+  // a header that specifies the size of the opcode item (which we don't\r
+  // know until we find the next opcode in the VFR), we queue up bytes\r
+  // until we know the size. Then we write them out. So flush the queue\r
+  // now.\r
+  //\r
+  if (mQueuedOpcodeByteValid != 0) {\r
+    // \r
+    // Add the previous opcode byte, the length byte, and the binary\r
+    // data.\r
+    //\r
+    IAddByte (mQueuedOpcodeByte, 'O', mQueuedLineNum);\r
+    IAddByte ((UINT8)(mQueuedByteCount + 2), 'L', 0);\r
+    for (Count = 0; Count < mQueuedByteCount; Count++) {\r
+      IAddByte (mQueuedBytes[Count], mQueuedKeyBytes[Count], 0);          \r
+    }\r
+    mQueuedByteCount = 0;\r
+    mQueuedOpcodeByteValid = 0;\r
+  }    \r
+  return 0;\r
+}\r
+\r
+int \r
+VfrOpcodeHandler::IAddByte (\r
+  UINT8   ByteVal, \r
+  UINT8   KeyByte, \r
+  UINT32  LineNum\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  This internal function is used to add actual IFR bytes to\r
+  the output stream. Most other functions queue up the bytes\r
+  in an internal buffer. Once they come here, there's no\r
+  going back.\r
+\r
+  \r
+Arguments:\r
+  ByteVal   - value to write to output \r
+  KeyByte   - key value tied to the byte -- useful for debug\r
+  LineNum   - line number from source file the byte resulted from\r
+\r
+Returns:\r
+  0 - if successful\r
+  1 - failed due to memory allocation failure\r
+\r
+--*/\r
+{\r
+  IFR_BYTE    *NewByte;\r
+  NewByte = (IFR_BYTE *)malloc (sizeof (IFR_BYTE));\r
+  if (NewByte == NULL) {\r
+    return 1;\r
+  }\r
+  memset ((char *)NewByte, 0, sizeof (IFR_BYTE));\r
+  NewByte->OpcodeByte = ByteVal;\r
+  NewByte->KeyByte = KeyByte;\r
+  NewByte->LineNum = LineNum;\r
+  //\r
+  // Add to the list\r
+  //\r
+  if (mIfrBytes == NULL) {\r
+    mIfrBytes = NewByte;\r
+  } else {\r
+    mLastIfrByte->Next = NewByte;\r
+  } \r
+  mLastIfrByte = NewByte;\r
+  mBytesWritten++;\r
+  return 0;\r
+}\r
+\r
+VOID \r
+WriteStandardFileHeader (\r
+  FILE *OutFptr\r
+  ) \r
+/*++\r
+\r
+Routine Description:\r
+  This function is invoked to emit a standard header to an\r
+  output text file.\r
+  \r
+Arguments:\r
+  OutFptr - file to write the header to\r
+\r
+Returns:\r
+  None\r
+\r
+--*/\r
+{\r
+  UINT32 TempIndex;\r
+  for (TempIndex = 0; mSourceFileHeader[TempIndex] != NULL; TempIndex++) {\r
+    fprintf (OutFptr, "%s\n", mSourceFileHeader[TempIndex]);\r
+  }\r
+  //\r
+  // Write out the VFR compiler version\r
+  //\r
+  fprintf (OutFptr, "//  VFR compiler version " VFR_COMPILER_VERSION "\n//\n");\r
+}\r
diff --git a/Tools/CodeTools/Source/VfrCompile/VfrServices.h b/Tools/CodeTools/Source/VfrCompile/VfrServices.h
new file mode 100644 (file)
index 0000000..6b8c560
--- /dev/null
@@ -0,0 +1,227 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  VfrServices.h\r
+\r
+Abstract:\r
+\r
+  Prototypes and defines for routines and classes used by the\r
+  EFI VFR compiler.\r
+  \r
+--*/\r
+\r
+#ifndef _VFR_SERVICES_H_\r
+#define _VFR_SERVICES_H_\r
+\r
+class VfrOpcodeHandler\r
+{\r
+public:\r
+  VfrOpcodeHandler (\r
+    VOID\r
+    )\r
+  /*++\r
+\r
+Routine Description:\r
+  Constructor for the VFR opcode handling class.\r
+  \r
+Arguments:\r
+  None\r
+\r
+Returns:\r
+  None\r
+\r
+--*/\r
+  ;\r
+  ~VfrOpcodeHandler (\r
+    VOID\r
+    )\r
+  /*++\r
+\r
+Routine Description:\r
+  Destructor for the VFR opcode handler. Free up memory allocated\r
+  while parsing the VFR script.\r
+  \r
+Arguments:\r
+  None\r
+\r
+Returns:\r
+  None\r
+\r
+--*/\r
+  ;\r
+  void\r
+  WriteIfrBytes (\r
+    VOID\r
+    )\r
+  /*++\r
+\r
+Routine Description:\r
+  This function is invoked at the end of parsing. Its purpose\r
+  is to write out all the IFR bytes that were queued up while\r
+  parsing.\r
+  \r
+Arguments:\r
+  None\r
+\r
+Returns:\r
+  None\r
+\r
+--*/\r
+  ;\r
+  int\r
+  AddOpcodeByte (\r
+    UINT8  OpcodeByte,\r
+    UINT32 LineNum\r
+    )\r
+  /*++\r
+\r
+Routine Description:\r
+  This function is invoked by the parser when a new IFR\r
+  opcode should be emitted.\r
+  \r
+Arguments:\r
+  OpcodeByte  - the IFR opcode\r
+  LineNum     - the line number from the source file that resulted\r
+                in the opcode being emitted.\r
+\r
+Returns:\r
+  0 always\r
+\r
+--*/\r
+  ;\r
+  void\r
+  AddByte (\r
+    UINT8 ByteVal,\r
+    UINT8 KeyByte\r
+    )\r
+  /*++\r
+\r
+Routine Description:\r
+  This function is invoked by the parser when it determines\r
+  that more raw IFR bytes should be emitted to the output stream.\r
+  Here we just queue them up into an output buffer.\r
+  \r
+Arguments:\r
+  ByteVal   - the raw byte to emit to the output IFR stream\r
+  KeyByte   - a value that can be used for debug. \r
+\r
+Returns:\r
+  None\r
+\r
+--*/\r
+  ;\r
+  void\r
+  SetVarStoreId (\r
+    UINT16 VarStoreId\r
+    )\r
+  /*++\r
+\r
+Routine Description:\r
+  This function is invoked by the parser when a variable is referenced in the \r
+  VFR. Save the variable store (and set a flag) so that we can later determine \r
+  if we need to emit a varstore-select or varstore-select-pair opcode.\r
+  \r
+Arguments:\r
+  VarStoreId - ID of the variable store referenced in the VFR\r
+\r
+Returns:\r
+  None\r
+\r
+--*/\r
+  ;\r
+  void\r
+  SetSecondaryVarStoreId (\r
+    UINT16 VarStoreId\r
+    )\r
+  /*++\r
+\r
+Routine Description:\r
+  This function is invoked by the parser when a secondary variable is \r
+  referenced in the VFR. Save the variable store (and set a flag) so \r
+  that we can later determine if we need to emit a varstore-select or \r
+  varstore-pair opcode.\r
+  \r
+Arguments:\r
+  VarStoreId - ID of the variable store referenced in the VFR\r
+\r
+Returns:\r
+  None\r
+\r
+--*/\r
+  ;\r
+\r
+/* */\r
+private:\r
+  int\r
+  FlushQueue (\r
+    VOID\r
+    )\r
+  /*++\r
+\r
+Routine Description:\r
+  This function is invoked to flush the internal IFR buffer.\r
+  \r
+Arguments:\r
+  None\r
+\r
+Returns:\r
+  0 always\r
+\r
+--*/\r
+  ;\r
+  int\r
+  IAddByte (\r
+    UINT8  ByteVal,\r
+    UINT8  KeyByte,\r
+    UINT32 LineNum\r
+    )\r
+  /*++\r
+\r
+Routine Description:\r
+  This internal function is used to add actual IFR bytes to\r
+  the output stream. Most other functions queue up the bytes\r
+  in an internal buffer. Once they come here, there's no\r
+  going back.\r
+\r
+  \r
+Arguments:\r
+  ByteVal   - value to write to output \r
+  KeyByte   - key value tied to the byte -- useful for debug\r
+  LineNum   - line number from source file the byte resulted from\r
+\r
+Returns:\r
+  0 - if successful\r
+  1 - failed due to memory allocation failure\r
+\r
+--*/\r
+  ;\r
+\r
+/* */\r
+private:\r
+  IFR_BYTE  *mIfrBytes;\r
+  IFR_BYTE  *mLastIfrByte;\r
+  UINT32    mQueuedByteCount;\r
+  UINT32    mBytesWritten;\r
+  UINT32    mQueuedLineNum;\r
+  UINT8     mQueuedBytes[MAX_QUEUE_COUNT];\r
+  UINT8     mQueuedKeyBytes[MAX_QUEUE_COUNT];\r
+  UINT8     mQueuedOpcodeByte;\r
+  UINT32    mQueuedOpcodeByteValid;\r
+  UINT16    mPrimaryVarStoreId;\r
+  UINT8     mPrimaryVarStoreIdSet;\r
+  UINT16    mSecondaryVarStoreId;\r
+  UINT8     mSecondaryVarStoreIdSet;\r
+  UINT16    mDefaultVarStoreId;\r
+};\r
+\r
+#endif // #ifndef _VFR_SERVICES_H_\r
diff --git a/Tools/CodeTools/Source/VfrCompile/build.xml b/Tools/CodeTools/Source/VfrCompile/build.xml
new file mode 100644 (file)
index 0000000..247f0d2
--- /dev/null
@@ -0,0 +1,123 @@
+<?xml version="1.0" ?>\r
+<!--\r
+Copyright (c) 2006, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+-->\r
+<project default="GenTool" basedir="." name="VfrCompile">\r
+<!--\r
+    EDK VfrCompile Tool\r
+  Copyright (c) 2006, Intel Corporation\r
+-->\r
+  <property name="ToolName" value="VfrCompile"/>\r
+  <property name="FileSet" value="*.cpp"/>\r
+  <property name="FileSetPccts" value="ATokenBuffer.cpp DLexerBase.cpp AParser.cpp"/>\r
+  <taskdef resource="cpptasks.tasks"/>\r
+  <typedef resource="cpptasks.types"/>\r
+  <taskdef resource="net/sf/antcontrib/antlib.xml"/>\r
+\r
+  <property name="LINK_OUTPUT_TYPE" value="static"/>\r
+  <property name="BUILD_DIR" value="${PACKAGE_DIR}/${ToolName}/tmp"/>\r
+\r
+  <target name="GenTool" depends="init, Antlr, Dlg, Tool">\r
+    <echo message="The EDK Tool: ${ToolName} build has completed"/>\r
+  </target>\r
+\r
+  <target name="init">\r
+\r
+    <echo message="Building the EDK Tool: ${ToolName}"/>\r
+    <mkdir dir="${BUILD_DIR}"/>\r
+\r
+    <condition property="AntlrDepends">\r
+      <uptodate targetfile="${PACKAGE_DIR}/VfrCompile/parser.dlg" srcfile="${PACKAGE_DIR}/VfrCompile/VfrCompile.g" value="true"/>\r
+    </condition>\r
+\r
+    <condition property="DlgDepends">\r
+      <uptodate targetfile="${PACKAGE_DIR}/VfrCompile/DLGLexer.cpp" srcfile="${PACKAGE_DIR}/VfrCompile/parser.dlg" value="true"/>\r
+    </condition>\r
+\r
+    <condition property="CheckDepends">\r
+      <or>\r
+        <isset property="AntlrDepends"/>\r
+        <isset property="DlgDepends"/>\r
+      </or>\r
+    </condition>\r
+\r
+    <condition property="gxx_extra_libs" value="stdc++ System gcc_s.10.4 gcc">\r
+      <os family="mac"/>\r
+    </condition>\r
+    \r
+    <condition property="gxx_extra_libs" value="stdc++">\r
+      <os name="linux"/>\r
+    </condition>\r
+    \r
+    <condition property="gxx_extra_libs" value="stdc++">\r
+      <os family="windows"/>\r
+    </condition>\r
+    \r
+  </target>\r
+\r
+  <target name="Antlr" depends="init" unless="AntlrDepends">\r
+    <echo message="Executing ANTLR"/>\r
+    <exec dir="${basedir}/${ToolName}" executable="${env.FRAMEWORK_TOOLS_PATH}/antlr" failonerror="TRUE">\r
+      <arg line="-CC -e3 -ck 3 -o . VfrCompile.g"/>\r
+    </exec>\r
+  </target>\r
+\r
+  <target name="Dlg" depends="Antlr" unless="DlgDepends">\r
+    <echo message="Executing DLG"/>\r
+    <exec dir="${basedir}/${ToolName}" executable="${env.FRAMEWORK_TOOLS_PATH}/dlg" failonerror="TRUE">\r
+      <arg line="-C2 -i -CC -o . parser.dlg"/>\r
+    </exec>\r
+  </target>\r
+\r
+  <target name="Tool" depends="init">\r
+    <cc name="${ToolChain}" objdir="${BUILD_DIR}" \r
+        outfile="${BIN_DIR}/${ToolName}"\r
+        outtype="executable"\r
+        debug="true"\r
+        optimize="speed">\r
+\r
+      <fileset dir="${basedir}/${ToolName}" \r
+        includes="${FileSet}" />\r
+\r
+      <fileset dir="${basedir}/Pccts/h" \r
+        includes="${FileSetPccts}" />\r
+\r
+      <includepath path="${PACKAGE_DIR}/Pccts/h"/>\r
+      <includepath path="${PACKAGE_DIR}/Include"/>\r
+      <includepath path="${PACKAGE_DIR}/Include/${HostArch}"/>\r
+      <includepath path="${PACKAGE_DIR}/Common"/>\r
+      <libset dir="${LIB_DIR}" libs="CommonTools"/>\r
+      <syslibset libs="${gxx_extra_libs}" if="gcc"/>\r
+    </cc>\r
+  </target>\r
+\r
+  <target name="clean">\r
+    <echo message="Removing Intermediate Files Only"/>\r
+    <delete>\r
+      <fileset dir="${BUILD_DIR}" includes="*.obj"/>\r
+    </delete>\r
+  </target>\r
+\r
+  <target name="cleanall">\r
+    <echo message="Removing Object Files and the Executable: ${ToolName}${ext_exe}"/>\r
+    <delete failonerror="false" quiet="true" includeEmptyDirs="true">\r
+      <fileset dir="${BUILD_DIR}"/>\r
+      <fileset file="${basedir}/${ToolName}/DLGLexer.cpp"/>\r
+      <fileset file="${basedir}/${ToolName}/DLGLexer.h"/>\r
+      <fileset file="${basedir}/${ToolName}/EfiVfrParser.cpp"/>\r
+      <fileset file="${basedir}/${ToolName}/EfiVfrParser.h"/>\r
+      <fileset file="${basedir}/${ToolName}/parser.dlg"/>\r
+      <fileset file="${basedir}/${ToolName}/tokens.h"/>\r
+      <fileset file="${basedir}/${ToolName}/VfrCompile.cpp"/>\r
+      <fileset file="${BIN_DIR}/${ToolName}${ext_exe}"/>\r
+    </delete>\r
+  </target>\r
+\r
+</project>\r
diff --git a/Tools/CodeTools/Source/ZeroDebugData/ZeroDebugData.c b/Tools/CodeTools/Source/ZeroDebugData/ZeroDebugData.c
new file mode 100644 (file)
index 0000000..caf129b
--- /dev/null
@@ -0,0 +1,391 @@
+/*++\r
+\r
+Copyright (c)  2004-2006 Intel Corporation. All rights reserved\r
+This program and the accompanying materials are licensed and made available\r
+under the terms and conditions of the BSD License which accompanies this\r
+distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+\r
+Module Name:\r
+\r
+  ZeroDebugData.c\r
+\r
+Abstract:\r
+\r
+  Zero the Debug Data Fields of Portable Executable (PE) format file.\r
+\r
+--*/\r
+\r
+#include <stdio.h>\r
+#include <string.h>\r
+#include <stdlib.h>\r
+\r
+void\r
+PrintUsage (\r
+  void\r
+  )\r
+/*++\r
+Routine Description:\r
+  print usage of ZeroDebugData command\r
+\r
+Arguments:\r
+  None\r
+\r
+Returns:\r
+  None\r
+--*/\r
+// GC_TODO:    void - add argument and description to function comment\r
+{\r
+  //\r
+  // print usage of command\r
+  //\r
+  printf ("\nUsage: ZeroDebugData <PE-File> [DebugData-File]\n");\r
+}\r
+\r
+int\r
+ReadFromFile (\r
+  FILE      *fp,\r
+  long      offset,\r
+  void      *buffer,\r
+  int       size\r
+  )\r
+/*++\r
+Routine Description:\r
+  read data from a specified location of file\r
+\r
+Arguments:\r
+  fp              - file pointer\r
+  offset          - number of bytes from beginning of file\r
+  buffer          - buffer used to store data\r
+  size            - size of buffer\r
+\r
+Returns:\r
+  =  0            - Success\r
+  = -1            - Failed\r
+--*/\r
+{\r
+  //\r
+  // set file pointer to the specified location of file\r
+  //\r
+  if (fseek (fp, offset, SEEK_SET) != 0) {\r
+    printf ("Error: Cannot move the current location of the file.\n");\r
+    return -1;\r
+  }\r
+  //\r
+  // read data from the file\r
+  //\r
+  if (fread (buffer, size, 1, fp) != 1) {\r
+    printf ("Error: Cannot read data from the file.\n");\r
+    return -1;\r
+  }\r
+\r
+  return 0;\r
+}\r
+\r
+int\r
+ZeroDebugData (\r
+  FILE      *fp,\r
+  FILE      *fpData\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Zero the debug data fields of the file\r
+\r
+Arguments:\r
+\r
+  fp              - file pointer\r
+  fpData          - pointer to output file that ZeroDebugData progress is written to\r
+\r
+Returns:\r
+\r
+  =  0            - Success\r
+  = -1            - Failed\r
+\r
+--*/\r
+{\r
+  unsigned char header[4];\r
+  unsigned long offset;\r
+  unsigned long NumberOfRvaAndSizes;\r
+  unsigned int  nvalue;\r
+  unsigned long lvalue;\r
+  unsigned long Size;\r
+  unsigned long Pointer;\r
+  unsigned char *Buffer;\r
+  unsigned long Index;\r
+\r
+  //\r
+  // read the header of file\r
+  //\r
+  if (ReadFromFile (fp, 0, header, 2) != 0) {\r
+    printf ("Error: open image file\n");\r
+    return -1;\r
+  }\r
+  //\r
+  // "MZ" -- the header of image file (PE)\r
+  //\r
+  if (strncmp ((char *) header, "MZ", 2) != 0) {\r
+    printf ("Error: Invalid Image file.\n");\r
+    return -1;\r
+  }\r
+  //\r
+  // At location 0x3C, the stub has the file offset to the\r
+  // PE signature.\r
+  //\r
+  if (ReadFromFile (fp, 0x3C, &offset, 4) != 0) {\r
+    return -1;\r
+  }\r
+  //\r
+  // read the header of optional\r
+  //\r
+  if (ReadFromFile (fp, offset, header, 4) != 0) {\r
+    return -1;\r
+  }\r
+  //\r
+  // "PE\0\0" -- the signature of optional header\r
+  //\r
+  if (strncmp ((char *) header, "PE\0\0", 4) != 0) {\r
+    printf ("Error: Invalid PE format file.\n");\r
+    return -1;\r
+  }\r
+  //\r
+  // Add 16 to skip COFF file header, and get to optional header.\r
+  //\r
+  offset += 24;\r
+\r
+  //\r
+  // Check the magic field, 0x10B for PE32 and 0x20B for PE32+\r
+  //\r
+  if (ReadFromFile (fp, offset, &nvalue, 2) != 0) {\r
+    return -1;\r
+  }\r
+  //\r
+  // If this is PE32 image file, offset of NumberOfRvaAndSizes is 92.\r
+  // Else it is 108.\r
+  //\r
+  switch (nvalue & 0xFFFF) {\r
+  case 0x10B:\r
+    offset += 92;\r
+    printf ("Info: Image is PE32. ");\r
+    break;\r
+\r
+  case 0x20B:\r
+    offset += 108;\r
+    printf ("Info: Image is PE32+. ");\r
+    break;\r
+\r
+  default:\r
+    printf ("Error: Magic value is unknown.\n");\r
+    return -1;\r
+  }\r
+  //\r
+  // get the value of NumberOfRvaAndSizes\r
+  //\r
+  if (ReadFromFile (fp, offset, &NumberOfRvaAndSizes, 4) != 0) {\r
+    printf ("Error: read NumberOfRvaAndSizes error.\n");\r
+    return -1;\r
+  }\r
+  //\r
+  // printf ("Info: NumberOfRvaAndSizes = %d\n", NumberOfRvaAndSizes);\r
+  //\r
+  //\r
+  // Finding Debug Table, offset of Debug Table\r
+  // is 4 + 6 * 8 = 52.\r
+  //\r
+  if (NumberOfRvaAndSizes >= 7) {\r
+    if (ReadFromFile (fp, offset + 52, &lvalue, 4) != 0) {\r
+      return -1;\r
+    }\r
+    //\r
+    // Read the SizeOfData(16) and PointerToRawData(24)\r
+    //\r
+    if (ReadFromFile (fp, lvalue + 16, &Size, 4) != 0) {\r
+      printf ("error: Size = %d\n", Size);\r
+      return -1;\r
+    }\r
+\r
+    printf ("Debug data: size = %xh, ", Size);\r
+    fprintf (fpData, "Debug data: size = %xh, ", Size);\r
+\r
+    if (ReadFromFile (fp, lvalue + 20, &Pointer, 4) != 0) {\r
+      printf ("error: LoadOffset = %xh\n", Pointer);\r
+      return -1;\r
+    }\r
+    //\r
+    // printf ("LoadOffset = %xh, ", Pointer);\r
+    //\r
+    fprintf (fpData, "LoadOffset = %xh, ", Pointer);\r
+\r
+    if (ReadFromFile (fp, lvalue + 24, &Pointer, 4) != 0) {\r
+      printf ("error: FileOffset = %xh\n", Pointer);\r
+      return -1;\r
+    }\r
+\r
+    printf ("FileOffset = %xh, ", Pointer);\r
+    fprintf (fpData, "FileOffset = %xh, \n", Pointer);\r
+\r
+    if ((lvalue != 0) && (Pointer != 0)) {\r
+      //\r
+      // prepare buffer\r
+      //\r
+      Buffer = malloc (Size + 1);\r
+      if (Buffer == NULL) {\r
+        printf ("Error: Cannot allocate memory.\n");\r
+        return -1;\r
+      }\r
+      //\r
+      // set file pointer to the specified location of file\r
+      //\r
+      if (fseek (fp, Pointer, SEEK_SET) != 0) {\r
+        printf ("Error: Cannot move the current location of the file.\n");\r
+        free (Buffer);\r
+        return -1;\r
+      }\r
+      //\r
+      // read data from PE file\r
+      //\r
+      if (fread (Buffer, Size, 1, fp) != 1) {\r
+        printf ("Error: Cannot read data from the file.\n");\r
+        free (Buffer);\r
+        return -1;\r
+      }\r
+      //\r
+      // write to data file\r
+      //\r
+      for (Index = 0; Index < Size;) {\r
+        fprintf (fpData, "%02x ", Buffer[Index]);\r
+\r
+        Index++;\r
+        if (Index % 8 == 0) {\r
+          fprintf (fpData, "\n");\r
+        }\r
+      }\r
+\r
+      fprintf (fpData, "\n");\r
+\r
+      //\r
+      // zero buffer and write back to PE file\r
+      //\r
+      if (fseek (fp, Pointer, SEEK_SET) != 0) {\r
+        printf ("Error: Cannot move the current location of the file.\n");\r
+        free (Buffer);\r
+        return -1;\r
+      }\r
+\r
+      memset (Buffer, 0, Size);\r
+      if (fwrite (Buffer, Size, 1, fp) != 1) {\r
+        perror ("Error: Cannot write zero to the file.\n");\r
+        free (Buffer);\r
+        return -1;\r
+      }\r
+      //\r
+      // set file pointer to the specified location of file\r
+      //\r
+      if (fseek (fp, lvalue + 4, SEEK_SET) != 0) {\r
+        printf ("Error: Cannot move the current location of the file.\n");\r
+        free (Buffer);\r
+        return -1;\r
+      }\r
+\r
+      if (fwrite (Buffer, 4, 1, fp) != 1) {\r
+        perror ("Error: Cannot write zero to the file.\n");\r
+        free (Buffer);\r
+        return -1;\r
+      }\r
+\r
+      free (Buffer);\r
+    }\r
+  }\r
+\r
+  return 0;\r
+}\r
+\r
+int\r
+main (\r
+  int       argc,\r
+  char      *argv[]\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Prints the zero debug data of the PE file to the DebugData file.\r
+  Executes the ZeroDebugData function.\r
+\r
+Arguments:\r
+\r
+  argc   - Standard C argument, number of command line arguments.\r
+  argv[] - Standard C argument, array of pointers to the input files,\r
+           such as the PE and DebugData files.\r
+\r
+Returns:\r
+\r
+  zero    - success\r
+  nonzero - failure\r
+\r
+--*/\r
+{\r
+  FILE  *fp;\r
+  FILE  *fpData;\r
+  char  DataFile[1024] = "";\r
+\r
+  //\r
+  // check the number of parameters\r
+  //\r
+  if (argc < 2) {\r
+    printf ("\nUsage: ZeroDebugData <PE-File> [DebugData-File]\n");\r
+    return -1;\r
+  }\r
+  //\r
+  // open the DebugData file, if not exists, return\r
+  //\r
+  if (argc >= 3) {\r
+    strcpy (DataFile, argv[2]);\r
+  } else {\r
+    strcpy (DataFile, "DebugData.dat");\r
+  }\r
+\r
+  fpData = fopen (DataFile, "a+");\r
+  if (fpData == NULL) {\r
+    fpData = fopen (DataFile, "w");\r
+    if (fpData == NULL) {\r
+      printf ("Error: Cannot open the data file!\n");\r
+      return -1;\r
+    }\r
+  }\r
+  //\r
+  // open the PE file\r
+  //\r
+  fp = fopen (argv[1], "r+b");\r
+  if (fp == NULL) {\r
+    printf ("Error: Cannot open the PE file!\n");\r
+    return -1;\r
+  }\r
+  //\r
+  // Zero the Debug Data to the PE file\r
+  //\r
+  printf ("Zero Debug Data to file %s:\n", argv[1]);\r
+  fprintf (fpData, "\nZero Debug Data to file %s:\n", argv[1]);\r
+  if ((int *) ZeroDebugData (fp, fpData) != 0) {\r
+    printf ("Error: Zero Debug Data PE file\n");\r
+    fclose (fp);\r
+    return -1;\r
+  }\r
+\r
+  printf (" success\n");\r
+\r
+  //\r
+  // close the PE file\r
+  //\r
+  fflush (fpData);\r
+  fflush (fp);\r
+  fclose (fpData);\r
+  fclose (fp);\r
+\r
+  return 0;\r
+}\r
diff --git a/Tools/CodeTools/Source/ZeroDebugData/build.xml b/Tools/CodeTools/Source/ZeroDebugData/build.xml
new file mode 100644 (file)
index 0000000..2a85fc1
--- /dev/null
@@ -0,0 +1,69 @@
+<?xml version="1.0" ?>\r
+<!--\r
+Copyright (c) 2006, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+-->\r
+<project default="GenTool" basedir=".">\r
+<!--\r
+    EDK ZeroDebugData Tool\r
+  Copyright (c) 2006, Intel Corporation\r
+-->\r
+  <property name="ToolName" value="ZeroDebugData"/>\r
+  <property name="FileSet" value="*.c"/>\r
+\r
+  <taskdef resource="cpptasks.tasks"/>\r
+  <typedef resource="cpptasks.types"/>\r
+  <taskdef resource="net/sf/antcontrib/antlib.xml"/>\r
+\r
+  <property name="LINK_OUTPUT_TYPE" value="static"/>\r
+  <property name="BUILD_DIR" value="${PACKAGE_DIR}/${ToolName}/tmp"/>\r
+\r
+  <target name="GenTool" depends="init, Tool">\r
+    <echo message="The EDK Tool: ${ToolName} build  has completed"/>\r
+  </target>\r
+\r
+  <target name="init">\r
+    <echo message="Building the EDK Tool: ${ToolName}"/>\r
+    <mkdir dir="${BUILD_DIR}"/>\r
+  </target>\r
+\r
+  <target name="Tool" depends="init">\r
+    <cc name="${ToolChain}" objdir="${BUILD_DIR}" \r
+        outfile="${BIN_DIR}/${ToolName}"\r
+        outtype="executable"\r
+        optimize="speed" \r
+        debug="true">\r
+\r
+      <fileset dir="${basedir}/${ToolName}" \r
+        includes="${FileSet}" \r
+        defaultexcludes="TRUE" \r
+        excludes="*.xml *.inf"/>\r
+\r
+      <includepath path="${PACKAGE_DIR}/Include"/>\r
+      <includepath path="${PACKAGE_DIR}/Include/${HostArch}"/>\r
+      <includepath path="${PACKAGE_DIR}/Common"/>\r
+    </cc>\r
+  </target>\r
+\r
+  <target name="clean">\r
+    <echo message="Removing Intermediate Files Only"/>  \r
+    <delete failonerror="false" quiet="true" includeEmptyDirs="true">\r
+      <fileset dir="${BUILD_DIR}"/>\r
+    </delete>\r
+  </target>\r
+\r
+  <target name="cleanall">\r
+    <echo message="Removing Object Files and the Executable: ${ToolName}${ext_exe}"/>  \r
+    <delete failonerror="false" quiet="true" includeEmptyDirs="true">\r
+      <fileset dir="${BUILD_DIR}"/>\r
+      <fileset file="${BIN_DIR}/${ToolName}${ext_exe}"/>\r
+    </delete>\r
+  </target>\r
+\r
+</project>\r
diff --git a/Tools/CodeTools/Source/build.xml b/Tools/CodeTools/Source/build.xml
new file mode 100644 (file)
index 0000000..3d59c9c
--- /dev/null
@@ -0,0 +1,269 @@
+<?xml version="1.0" encoding="utf-8" ?> \r
+<!--\r
+Copyright (c) 2006, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+-->\r
+<project default="all" basedir="." name="C_Code">\r
+<!-- Copyright (c) 2006, Intel Corporation -->\r
+<!-- Filename: Tools/Source/build.xml -->\r
+\r
+  <taskdef resource="net/sf/antcontrib/antlib.xml"/>\r
+\r
+  <property name="ReallyVerbose" value="false"/>\r
+  <property environment="env" />\r
+\r
+  <property name="WORKSPACE" value="${env.WORKSPACE}" />\r
+  <property name="WORKSPACE_DIR" value="${WORKSPACE}" />\r
+  <property name="PACKAGE" value="Tools" />\r
+  <property name="PACKAGE_DIR" value="${WORKSPACE}/Tools/Source/TianoTools" />\r
+  <property name="LIB_DIR" value="${PACKAGE_DIR}/Library" />\r
+  <property name="BIN_DIR" value="${WORKSPACE}/Tools/bin" />\r
+  <property name="BUILD_MODE" value="PACKAGE" />\r
+  <property name="Libs" \r
+    value="Common/build.xml CustomizedCompress/build.xml PeCoffLoader/build.xml String/build.xml"/>\r
+\r
+  <import file="${WORKSPACE_DIR}/Tools/Conf/BuildMacro.xml" />\r
+\r
+  <path id="classpath">\r
+    <fileset dir="${WORKSPACE}/Tools/Jars" includes="*.jar"/>\r
+    <fileset dir="${env.XMLBEANS_HOME}/lib" includes="*.jar"/>\r
+  </path>\r
+\r
+  <taskdef classpathref="classpath" resource="GenBuild.tasks" />\r
+  <taskdef classpathref="classpath" resource="net/sf/antcontrib/antlib.xml" />\r
+\r
+  <taskdef classpathref="classpath" resource="cpptasks.tasks"/>\r
+  <typedef classpathref="classpath" resource="cpptasks.types"/>\r
+\r
+  <target name="all" depends="init, Tools">\r
+    <echo message="The EDK II C Tools build complete!"/>\r
+  </target>\r
+  \r
+  <target name="init">\r
+    <echo message="EDK C Code Tools, build initialization"/>\r
+    <mkdir dir="${BIN_DIR}" />\r
+    <mkdir dir="${LIB_DIR}" />\r
+\r
+    <condition property="HostArch" value="X64">\r
+      <os arch="amd64"/>\r
+    </condition>\r
+    <condition property="HostArch" value="Ia32">\r
+      <or>\r
+        <os arch="x86"/>\r
+        <os arch="i386"/>\r
+      </or>\r
+    </condition>\r
+    <condition property="HostArch" value="Ia32">\r
+      <os arch="i386"/>\r
+    </condition> \r
+\r
+    <if>\r
+      <os family="unix" />\r
+      <then>\r
+        <echo message="OS Family UNIX, ${HostArch}" />\r
+      </then>\r
+      <elseif>\r
+        <os family="dos" />\r
+        <then>\r
+          <echo message="OS Family DOS, ${HostArch}" />\r
+        </then>\r
+      </elseif>\r
+      <elseif>\r
+        <os family="mac" />\r
+        <then>\r
+          <echo message="OS Family OS X, ${HostArch}" />\r
+        </then>\r
+      </elseif>\r
+      <else>\r
+        <fail message="OS Family Unsupported, ${HostArch}" />\r
+      </else>\r
+    </if>\r
+\r
+    <if>\r
+      <not>\r
+        <isset property="ToolChain" />\r
+      </not>\r
+      <then>\r
+        <if>\r
+          <isset property="env.TOOL_CHAIN" />\r
+          <then>\r
+            <property name="ToolChain" value="${env.TOOL_CHAIN}"/>\r
+          </then>\r
+          <else>\r
+            <!-- Default Tool Chain is Microsoft Visual Studio -->\r
+            <property name="ToolChain" value="msvc"/>\r
+          </else>\r
+        </if>\r
+      </then>\r
+    </if>\r
+    \r
+    <if>\r
+      <equals arg1="${ToolChain}" arg2="gcc" />\r
+      <then>\r
+        <exec executable="gcc" outputproperty="host.gcc.ver">\r
+          <arg line="-E" />\r
+          <arg line="-P" />\r
+          <arg line="-x c" />\r
+          <arg line="gcc.ver" />\r
+        </exec>\r
+        <if>\r
+          <contains string="${host.gcc.ver}" substring="4" />\r
+          <then>\r
+            <property name="ExtraArgus" value="-Wno-pointer-sign" />\r
+          </then>\r
+        </if>\r
+      </then>\r
+    </if>\r
+\r
+    <condition property="linux" value="true">\r
+      <os name="Linux"/>\r
+    </condition>\r
+    \r
+    <condition property="intel_win">\r
+      <and>\r
+        <os family="dos"/>\r
+        <equals arg1="${ToolChain}" arg2="intel"/>\r
+      </and>\r
+    </condition>\r
+    \r
+    <condition property="intel_linux">\r
+      <and>\r
+        <os name="Linux"/>\r
+        <equals arg1="${ToolChain}" arg2="intel"/>\r
+      </and>\r
+    </condition>\r
+    \r
+    <condition property="intel_mac">\r
+      <and>\r
+        <os family="mac"/>\r
+        <equals arg1="${ToolChain}" arg2="intel"/>\r
+      </and>\r
+    </condition>\r
+    \r
+    <condition property="gcc">\r
+      <and>\r
+        <equals arg1="${ToolChain}" arg2="gcc"/>\r
+      </and>\r
+    </condition>\r
+\r
+    <condition property="cygwin">\r
+      <and>\r
+        <os family="dos"/>\r
+        <equals arg1="${ToolChain}" arg2="gcc"/>\r
+      </and>\r
+    </condition>\r
+    \r
+    <condition property="x86_64_linux">\r
+      <and>\r
+        <os name="Linux"/>\r
+        <equals arg1="${HostArch}" arg2="X64"/>\r
+      </and>\r
+    </condition>\r
+    \r
+    <condition property="windows" value="true">\r
+      <os family="Windows"/>\r
+    </condition>\r
+    \r
+    <condition property="OSX" value="true">\r
+      <os family="Mac"/>\r
+    </condition>\r
+\r
+    <condition property="cyglinux">\r
+      <or>\r
+        <istrue value="${linux}"/>\r
+        <istrue value="${cygwin}"/>\r
+      </or>\r
+    </condition>\r
+\r
+    <!-- msft is a family, used by both Microsoft and Intel Windows compiler tool chains -->\r
+    <condition property="msft">\r
+      <isfalse value="${gcc}"/>\r
+    </condition>\r
+\r
+    <if>\r
+      <istrue value="${ReallyVerbose}"/>\r
+      <then>\r
+        <echo message="Test property msvc:         ${msvc}"/> \r
+        <echo message="Test property gcc:          ${gcc}"/> \r
+        <echo message="Test property intel_win:    ${intel_win}"/> \r
+        <echo message="Test property intel_linux:  ${intel_linux}"/> \r
+        <echo message="Test property intel_mac:    ${intel_mac}"/> \r
+        <echo message="Test property msft:         ${msft}"/> \r
+        <echo message="Test property cygwin:       ${cygwin}"/> \r
+        <echo message="Test property cyglinux:     ${cyglinux}"/> \r
+        <echo message="Test property windows:      ${windows}"/> \r
+        <echo message="Test property linux:        ${linux}"/> \r
+        <echo message="Test property OSX:          ${OSX}"/> \r
+        <echo message="Test property x86_64_linux: ${x86_64_linux}"/> \r
+       </then>\r
+    </if>\r
+\r
+    <property name="haveLibtool" value="false"/>\r
+    <if>\r
+      <and>\r
+        <not>\r
+          <isset property="env.CYGWIN_HOME"/>\r
+        </not>\r
+          <isset property="cygwin"/>\r
+      </and>\r
+      <then>\r
+        <fail message="You must set the environment variable: CYGWIN_HOME"/>\r
+      </then>\r
+    </if>\r
+\r
+    <if>\r
+        <istrue value="${gcc}"/>\r
+      <then>\r
+        <property name="ext_static" value=".a"/>\r
+        <property name="ext_dynamic" value=".so"/>\r
+        <if>\r
+          <istrue value="${cygwin}"/>\r
+          <then>\r
+            <property name="ext_exe" value=".exe"/>\r
+          </then>\r
+          <else>\r
+            <property name="ext_exe" value=""/>\r
+          </else>\r
+        </if>\r
+      </then>\r
+      <else>\r
+        <property name="ext_static" value=".lib"/>\r
+        <property name="ext_dynamic" value=".dll"/>\r
+        <property name="ext_exe" value=".exe"/>\r
+      </else>\r
+    </if>\r
+  </target>\r
+\r
+  <target name="Libraries" depends="init">\r
+    <subant target="" inheritall="true">\r
+      <fileset dir="${PACKAGE_DIR}" \r
+        includes="${Libs}"/>\r
+    </subant>\r
+  </target>\r
+\r
+  <target name="Tools" depends="Libraries">\r
+    <subant target="" inheritall="true">\r
+      <fileset dir="${PACKAGE_DIR}" includes="*/build.xml"\r
+        excludes="${Libs}"/>\r
+    </subant>\r
+  </target>\r
+\r
+  <target name="clean" depends="init">\r
+    <subant target="clean" inheritall="true">\r
+      <fileset dir="${PACKAGE_DIR}" includes="*/build.xml"/>\r
+    </subant>\r
+  </target>\r
+\r
+  <target name="cleanall" depends="init">\r
+    <subant target="cleanall" inheritall="true">\r
+      <fileset dir="${PACKAGE_DIR}" includes="*/build.xml"/>\r
+    </subant>\r
+    <delete dir="${LIB_DIR}"/>\r
+  </target>\r
+</project>\r
diff --git a/Tools/CodeTools/TianoTools/Common/CommonLib.c b/Tools/CodeTools/TianoTools/Common/CommonLib.c
deleted file mode 100644 (file)
index 4d1663a..0000000
+++ /dev/null
@@ -1,508 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2004, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-Module Name:\r
-\r
-  CommonLib.c\r
-\r
-Abstract:\r
-\r
-  Common Library Functions\r
\r
---*/\r
-\r
-#include <stdio.h>\r
-#include <string.h>\r
-#include <stdlib.h>\r
-#include "CommonLib.h"\r
-\r
-VOID\r
-PeiZeroMem (\r
-  IN VOID   *Buffer,\r
-  IN UINTN  Size\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Set Buffer to zero for Size bytes.\r
-\r
-Arguments:\r
-\r
-  Buffer  - Memory to set.\r
-\r
-  Size    - Number of bytes to set\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-{\r
-  INT8  *Ptr;\r
-\r
-  Ptr = Buffer;\r
-  while (Size--) {\r
-    *(Ptr++) = 0;\r
-  }\r
-}\r
-\r
-VOID\r
-PeiCopyMem (\r
-  IN VOID   *Destination,\r
-  IN VOID   *Source,\r
-  IN UINTN  Length\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Copy Length bytes from Source to Destination.\r
-\r
-Arguments:\r
-\r
-  Destination - Target of copy\r
-\r
-  Source      - Place to copy from\r
-\r
-  Length      - Number of bytes to copy\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-{\r
-  CHAR8 *Destination8;\r
-  CHAR8 *Source8;\r
-\r
-  Destination8  = Destination;\r
-  Source8       = Source;\r
-  while (Length--) {\r
-    *(Destination8++) = *(Source8++);\r
-  }\r
-}\r
-\r
-VOID\r
-ZeroMem (\r
-  IN VOID   *Buffer,\r
-  IN UINTN  Size\r
-  )\r
-{\r
-  PeiZeroMem (Buffer, Size);\r
-}\r
-\r
-VOID\r
-CopyMem (\r
-  IN VOID   *Destination,\r
-  IN VOID   *Source,\r
-  IN UINTN  Length\r
-  )\r
-{\r
-  PeiCopyMem (Destination, Source, Length);\r
-}\r
-\r
-INTN\r
-CompareGuid (\r
-  IN EFI_GUID     *Guid1,\r
-  IN EFI_GUID     *Guid2\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Compares to GUIDs\r
-\r
-Arguments:\r
-\r
-  Guid1 - guid to compare\r
-  Guid2 - guid to compare\r
-\r
-Returns:\r
-  =  0  if Guid1 == Guid2\r
-  != 0  if Guid1 != Guid2 \r
-\r
---*/\r
-{\r
-  INT32 *g1;\r
-  INT32 *g2;\r
-  INT32 r;\r
-\r
-  //\r
-  // Compare 32 bits at a time\r
-  //\r
-  g1  = (INT32 *) Guid1;\r
-  g2  = (INT32 *) Guid2;\r
-\r
-  r   = g1[0] - g2[0];\r
-  r |= g1[1] - g2[1];\r
-  r |= g1[2] - g2[2];\r
-  r |= g1[3] - g2[3];\r
-\r
-  return r;\r
-}\r
-\r
-EFI_STATUS\r
-GetFileImage (\r
-  IN CHAR8    *InputFileName,\r
-  OUT CHAR8   **InputFileImage,\r
-  OUT UINT32  *BytesRead\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  This function opens a file and reads it into a memory buffer.  The function \r
-  will allocate the memory buffer and returns the size of the buffer.\r
-\r
-Arguments:\r
-\r
-  InputFileName     The name of the file to read.\r
-  InputFileImage    A pointer to the memory buffer.\r
-  BytesRead         The size of the memory buffer.\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS              The function completed successfully.\r
-  EFI_INVALID_PARAMETER    One of the input parameters was invalid.\r
-  EFI_ABORTED              An error occurred.\r
-  EFI_OUT_OF_RESOURCES     No resource to complete operations.\r
-\r
---*/\r
-{\r
-  FILE    *InputFile;\r
-  UINT32  FileSize;\r
-\r
-  //\r
-  // Verify input parameters.\r
-  //\r
-  if (InputFileName == NULL || strlen (InputFileName) == 0 || InputFileImage == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-  //\r
-  // Open the file and copy contents into a memory buffer.\r
-  //\r
-  //\r
-  // Open the file\r
-  //\r
-  InputFile = fopen (InputFileName, "rb");\r
-  if (InputFile == NULL) {\r
-    printf ("ERROR: Could not open input file \"%s\".\n", InputFileName);\r
-    return EFI_ABORTED;\r
-  }\r
-  //\r
-  // Go to the end so that we can determine the file size\r
-  //\r
-  if (fseek (InputFile, 0, SEEK_END)) {\r
-    printf ("ERROR: System error reading input file \"%s\".\n", InputFileName);\r
-    fclose (InputFile);\r
-    return EFI_ABORTED;\r
-  }\r
-  //\r
-  // Get the file size\r
-  //\r
-  FileSize = ftell (InputFile);\r
-  if (FileSize == -1) {\r
-    printf ("ERROR: System error parsing input file \"%s\".\n", InputFileName);\r
-    fclose (InputFile);\r
-    return EFI_ABORTED;\r
-  }\r
-  //\r
-  // Allocate a buffer\r
-  //\r
-  *InputFileImage = malloc (FileSize);\r
-  if (*InputFileImage == NULL) {\r
-    fclose (InputFile);\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-  //\r
-  // Reset to the beginning of the file\r
-  //\r
-  if (fseek (InputFile, 0, SEEK_SET)) {\r
-    printf ("ERROR: System error reading input file \"%s\".\n", InputFileName);\r
-    fclose (InputFile);\r
-    free (*InputFileImage);\r
-    *InputFileImage = NULL;\r
-    return EFI_ABORTED;\r
-  }\r
-  //\r
-  // Read all of the file contents.\r
-  //\r
-  *BytesRead = fread (*InputFileImage, sizeof (UINT8), FileSize, InputFile);\r
-  if (*BytesRead != sizeof (UINT8) * FileSize) {\r
-    printf ("ERROR: Reading file \"%s\"%i.\n", InputFileName);\r
-    fclose (InputFile);\r
-    free (*InputFileImage);\r
-    *InputFileImage = NULL;\r
-    return EFI_ABORTED;\r
-  }\r
-  //\r
-  // Close the file\r
-  //\r
-  fclose (InputFile);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-UINT8\r
-CalculateChecksum8 (\r
-  IN UINT8        *Buffer,\r
-  IN UINTN        Size\r
-  )\r
-/*++\r
-  \r
-Routine Description:\r
-\r
-  This function calculates the value needed for a valid UINT8 checksum\r
-\r
-Arguments:\r
-\r
-  Buffer      Pointer to buffer containing byte data of component.\r
-  Size        Size of the buffer\r
-\r
-Returns:\r
-\r
-  The 8 bit checksum value needed.\r
-\r
---*/\r
-{\r
-  return (UINT8) (0x100 - CalculateSum8 (Buffer, Size));\r
-}\r
-\r
-UINT8\r
-CalculateSum8 (\r
-  IN UINT8  *Buffer,\r
-  IN UINTN  Size\r
-  )\r
-/*++\r
-  \r
-Routine Description::\r
-\r
-  This function calculates the UINT8 sum for the requested region.\r
-\r
-Arguments:\r
-\r
-  Buffer      Pointer to buffer containing byte data of component.\r
-  Size        Size of the buffer\r
-\r
-Returns:\r
-\r
-  The 8 bit checksum value needed.\r
-\r
---*/\r
-{\r
-  UINTN Index;\r
-  UINT8 Sum;\r
-\r
-  Sum = 0;\r
-\r
-  //\r
-  // Perform the byte sum for buffer\r
-  //\r
-  for (Index = 0; Index < Size; Index++) {\r
-    Sum = (UINT8) (Sum + Buffer[Index]);\r
-  }\r
-\r
-  return Sum;\r
-}\r
-\r
-UINT16\r
-CalculateChecksum16 (\r
-  IN UINT16       *Buffer,\r
-  IN UINTN        Size\r
-  )\r
-/*++\r
-  \r
-Routine Description::\r
-\r
-  This function calculates the value needed for a valid UINT16 checksum\r
-\r
-Arguments:\r
-\r
-  Buffer      Pointer to buffer containing byte data of component.\r
-  Size        Size of the buffer\r
-\r
-Returns:\r
-\r
-  The 16 bit checksum value needed.\r
-\r
---*/\r
-{\r
-  return (UINT16) (0x10000 - CalculateSum16 (Buffer, Size));\r
-}\r
-\r
-UINT16\r
-CalculateSum16 (\r
-  IN UINT16       *Buffer,\r
-  IN UINTN        Size\r
-  )\r
-/*++\r
-  \r
-Routine Description:\r
-\r
-  This function calculates the UINT16 sum for the requested region.\r
-\r
-Arguments:\r
-\r
-  Buffer      Pointer to buffer containing byte data of component.\r
-  Size        Size of the buffer\r
-\r
-Returns:\r
-\r
-  The 16 bit checksum\r
-\r
---*/\r
-{\r
-  UINTN   Index;\r
-  UINT16  Sum;\r
-\r
-  Sum = 0;\r
-\r
-  //\r
-  // Perform the word sum for buffer\r
-  //\r
-  for (Index = 0; Index < Size; Index++) {\r
-    Sum = (UINT16) (Sum + Buffer[Index]);\r
-  }\r
-\r
-  return (UINT16) Sum;\r
-}\r
-\r
-EFI_STATUS\r
-PrintGuid (\r
-  IN EFI_GUID *Guid\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  This function prints a GUID to STDOUT.\r
-\r
-Arguments:\r
-\r
-  Guid    Pointer to a GUID to print.\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS             The GUID was printed.\r
-  EFI_INVALID_PARAMETER   The input was NULL.\r
-\r
---*/\r
-{\r
-  if (Guid == NULL) {\r
-    printf ("ERROR: PrintGuid called with a NULL value.\n");\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  printf (\r
-    "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x\n",\r
-    Guid->Data1,\r
-    Guid->Data2,\r
-    Guid->Data3,\r
-    Guid->Data4[0],\r
-    Guid->Data4[1],\r
-    Guid->Data4[2],\r
-    Guid->Data4[3],\r
-    Guid->Data4[4],\r
-    Guid->Data4[5],\r
-    Guid->Data4[6],\r
-    Guid->Data4[7]\r
-    );\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-PrintGuidToBuffer (\r
-  IN EFI_GUID     *Guid,\r
-  IN OUT UINT8    *Buffer,\r
-  IN UINT32       BufferLen,\r
-  IN BOOLEAN      Uppercase\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  This function prints a GUID to a buffer\r
-\r
-Arguments:\r
-\r
-  Guid      - Pointer to a GUID to print.\r
-  Buffer    - Pointer to a user-provided buffer to print to\r
-  BufferLen - Size of the Buffer\r
-  Uppercase - If use upper case.\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS             The GUID was printed.\r
-  EFI_INVALID_PARAMETER   The input was NULL.\r
-  EFI_BUFFER_TOO_SMALL    The input buffer was not big enough\r
-  \r
---*/\r
-{\r
-  if (Guid == NULL) {\r
-    printf ("ERROR: PrintGuidToBuffer() called with a NULL value\n");\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if (BufferLen < PRINTED_GUID_BUFFER_SIZE) {\r
-    printf ("ERORR: PrintGuidToBuffer() called with invalid buffer size\n");\r
-    return EFI_BUFFER_TOO_SMALL;\r
-  }\r
-\r
-  if (Uppercase) {\r
-    sprintf (\r
-      Buffer,\r
-      "%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X",\r
-      Guid->Data1,\r
-      Guid->Data2,\r
-      Guid->Data3,\r
-      Guid->Data4[0],\r
-      Guid->Data4[1],\r
-      Guid->Data4[2],\r
-      Guid->Data4[3],\r
-      Guid->Data4[4],\r
-      Guid->Data4[5],\r
-      Guid->Data4[6],\r
-      Guid->Data4[7]\r
-      );\r
-  } else {\r
-    sprintf (\r
-      Buffer,\r
-      "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",\r
-      Guid->Data1,\r
-      Guid->Data2,\r
-      Guid->Data3,\r
-      Guid->Data4[0],\r
-      Guid->Data4[1],\r
-      Guid->Data4[2],\r
-      Guid->Data4[3],\r
-      Guid->Data4[4],\r
-      Guid->Data4[5],\r
-      Guid->Data4[6],\r
-      Guid->Data4[7]\r
-      );\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-#ifdef __GNUC__\r
-#ifndef __CYGWIN__\r
-char *strlwr(char *s)\r
-{\r
-  char *p = s;\r
-  for(;*s;s++) {\r
-    *s = tolower(*s);\r
-  }\r
-  return p;\r
-}\r
-#endif\r
-#endif\r
diff --git a/Tools/CodeTools/TianoTools/Common/CommonLib.h b/Tools/CodeTools/TianoTools/Common/CommonLib.h
deleted file mode 100644 (file)
index 46f0cba..0000000
+++ /dev/null
@@ -1,135 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2004, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-Module Name:\r
-\r
-  CommonLib.h\r
-\r
-Abstract:\r
-\r
-  Common library assistance routines.\r
-\r
---*/\r
-\r
-#ifndef _EFI_COMMON_LIB_H\r
-#define _EFI_COMMON_LIB_H\r
-\r
-#include <Common/UefiBaseTypes.h>\r
-\r
-#ifndef _MAX_PATH\r
-#define _MAX_PATH 500\r
-#endif\r
-\r
-#define PRINTED_GUID_BUFFER_SIZE  37  // including null-termination\r
-//\r
-// Function declarations\r
-//\r
-VOID\r
-PeiZeroMem (\r
-  IN VOID   *Buffer,\r
-  IN UINTN  Size\r
-  )\r
-;\r
-\r
-VOID\r
-PeiCopyMem (\r
-  IN VOID   *Destination,\r
-  IN VOID   *Source,\r
-  IN UINTN  Length\r
-  )\r
-;\r
-\r
-VOID\r
-ZeroMem (\r
-  IN VOID   *Buffer,\r
-  IN UINTN  Size\r
-  )\r
-;\r
-\r
-VOID\r
-CopyMem (\r
-  IN VOID   *Destination,\r
-  IN VOID   *Source,\r
-  IN UINTN  Length\r
-  )\r
-;\r
-\r
-INTN\r
-CompareGuid (\r
-  IN EFI_GUID     *Guid1,\r
-  IN EFI_GUID     *Guid2\r
-  )\r
-;\r
-\r
-EFI_STATUS\r
-GetFileImage (\r
-  IN CHAR8    *InputFileName,\r
-  OUT CHAR8   **InputFileImage,\r
-  OUT UINT32  *BytesRead\r
-  )\r
-;\r
-\r
-UINT8\r
-CalculateChecksum8 (\r
-  IN UINT8        *Buffer,\r
-  IN UINTN        Size\r
-  )\r
-;\r
-\r
-UINT8\r
-CalculateSum8 (\r
-  IN UINT8        *Buffer,\r
-  IN UINTN        Size\r
-  )\r
-;\r
-\r
-UINT16\r
-CalculateChecksum16 (\r
-  IN UINT16       *Buffer,\r
-  IN UINTN        Size\r
-  )\r
-;\r
-\r
-UINT16\r
-CalculateSum16 (\r
-  IN UINT16       *Buffer,\r
-  IN UINTN        Size\r
-  )\r
-;\r
-\r
-EFI_STATUS\r
-PrintGuid (\r
-  IN EFI_GUID                     *Guid\r
-  )\r
-;\r
-\r
-#define PRINTED_GUID_BUFFER_SIZE  37  // including null-termination\r
-EFI_STATUS\r
-PrintGuidToBuffer (\r
-  IN EFI_GUID     *Guid,\r
-  IN OUT UINT8    *Buffer,\r
-  IN UINT32       BufferLen,\r
-  IN BOOLEAN      Uppercase\r
-  )\r
-;\r
-\r
-#define ASSERT(x) assert(x)\r
-\r
-#ifdef __GNUC__\r
-#define stricmp strcasecmp\r
-#define strnicmp strncasecmp\r
-#define strcmpi strcasecmp\r
-#ifndef __CYGWIN__\r
-char *strlwr(char *s);\r
-#endif\r
-#endif\r
-\r
-#endif\r
diff --git a/Tools/CodeTools/TianoTools/Common/Crc32.c b/Tools/CodeTools/TianoTools/Common/Crc32.c
deleted file mode 100644 (file)
index 4ae5eb4..0000000
+++ /dev/null
@@ -1,326 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2004, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-Module Name:\r
-\r
-  crc32.c\r
-\r
-Abstract:\r
-\r
-  CalcuateCrc32 routine.\r
-  \r
---*/\r
-\r
-#include <stdlib.h>\r
-#include "Crc32.h"\r
-\r
-UINT32  mCrcTable[256] = {\r
-  0x00000000,\r
-  0x77073096,\r
-  0xEE0E612C,\r
-  0x990951BA,\r
-  0x076DC419,\r
-  0x706AF48F,\r
-  0xE963A535,\r
-  0x9E6495A3,\r
-  0x0EDB8832,\r
-  0x79DCB8A4,\r
-  0xE0D5E91E,\r
-  0x97D2D988,\r
-  0x09B64C2B,\r
-  0x7EB17CBD,\r
-  0xE7B82D07,\r
-  0x90BF1D91,\r
-  0x1DB71064,\r
-  0x6AB020F2,\r
-  0xF3B97148,\r
-  0x84BE41DE,\r
-  0x1ADAD47D,\r
-  0x6DDDE4EB,\r
-  0xF4D4B551,\r
-  0x83D385C7,\r
-  0x136C9856,\r
-  0x646BA8C0,\r
-  0xFD62F97A,\r
-  0x8A65C9EC,\r
-  0x14015C4F,\r
-  0x63066CD9,\r
-  0xFA0F3D63,\r
-  0x8D080DF5,\r
-  0x3B6E20C8,\r
-  0x4C69105E,\r
-  0xD56041E4,\r
-  0xA2677172,\r
-  0x3C03E4D1,\r
-  0x4B04D447,\r
-  0xD20D85FD,\r
-  0xA50AB56B,\r
-  0x35B5A8FA,\r
-  0x42B2986C,\r
-  0xDBBBC9D6,\r
-  0xACBCF940,\r
-  0x32D86CE3,\r
-  0x45DF5C75,\r
-  0xDCD60DCF,\r
-  0xABD13D59,\r
-  0x26D930AC,\r
-  0x51DE003A,\r
-  0xC8D75180,\r
-  0xBFD06116,\r
-  0x21B4F4B5,\r
-  0x56B3C423,\r
-  0xCFBA9599,\r
-  0xB8BDA50F,\r
-  0x2802B89E,\r
-  0x5F058808,\r
-  0xC60CD9B2,\r
-  0xB10BE924,\r
-  0x2F6F7C87,\r
-  0x58684C11,\r
-  0xC1611DAB,\r
-  0xB6662D3D,\r
-  0x76DC4190,\r
-  0x01DB7106,\r
-  0x98D220BC,\r
-  0xEFD5102A,\r
-  0x71B18589,\r
-  0x06B6B51F,\r
-  0x9FBFE4A5,\r
-  0xE8B8D433,\r
-  0x7807C9A2,\r
-  0x0F00F934,\r
-  0x9609A88E,\r
-  0xE10E9818,\r
-  0x7F6A0DBB,\r
-  0x086D3D2D,\r
-  0x91646C97,\r
-  0xE6635C01,\r
-  0x6B6B51F4,\r
-  0x1C6C6162,\r
-  0x856530D8,\r
-  0xF262004E,\r
-  0x6C0695ED,\r
-  0x1B01A57B,\r
-  0x8208F4C1,\r
-  0xF50FC457,\r
-  0x65B0D9C6,\r
-  0x12B7E950,\r
-  0x8BBEB8EA,\r
-  0xFCB9887C,\r
-  0x62DD1DDF,\r
-  0x15DA2D49,\r
-  0x8CD37CF3,\r
-  0xFBD44C65,\r
-  0x4DB26158,\r
-  0x3AB551CE,\r
-  0xA3BC0074,\r
-  0xD4BB30E2,\r
-  0x4ADFA541,\r
-  0x3DD895D7,\r
-  0xA4D1C46D,\r
-  0xD3D6F4FB,\r
-  0x4369E96A,\r
-  0x346ED9FC,\r
-  0xAD678846,\r
-  0xDA60B8D0,\r
-  0x44042D73,\r
-  0x33031DE5,\r
-  0xAA0A4C5F,\r
-  0xDD0D7CC9,\r
-  0x5005713C,\r
-  0x270241AA,\r
-  0xBE0B1010,\r
-  0xC90C2086,\r
-  0x5768B525,\r
-  0x206F85B3,\r
-  0xB966D409,\r
-  0xCE61E49F,\r
-  0x5EDEF90E,\r
-  0x29D9C998,\r
-  0xB0D09822,\r
-  0xC7D7A8B4,\r
-  0x59B33D17,\r
-  0x2EB40D81,\r
-  0xB7BD5C3B,\r
-  0xC0BA6CAD,\r
-  0xEDB88320,\r
-  0x9ABFB3B6,\r
-  0x03B6E20C,\r
-  0x74B1D29A,\r
-  0xEAD54739,\r
-  0x9DD277AF,\r
-  0x04DB2615,\r
-  0x73DC1683,\r
-  0xE3630B12,\r
-  0x94643B84,\r
-  0x0D6D6A3E,\r
-  0x7A6A5AA8,\r
-  0xE40ECF0B,\r
-  0x9309FF9D,\r
-  0x0A00AE27,\r
-  0x7D079EB1,\r
-  0xF00F9344,\r
-  0x8708A3D2,\r
-  0x1E01F268,\r
-  0x6906C2FE,\r
-  0xF762575D,\r
-  0x806567CB,\r
-  0x196C3671,\r
-  0x6E6B06E7,\r
-  0xFED41B76,\r
-  0x89D32BE0,\r
-  0x10DA7A5A,\r
-  0x67DD4ACC,\r
-  0xF9B9DF6F,\r
-  0x8EBEEFF9,\r
-  0x17B7BE43,\r
-  0x60B08ED5,\r
-  0xD6D6A3E8,\r
-  0xA1D1937E,\r
-  0x38D8C2C4,\r
-  0x4FDFF252,\r
-  0xD1BB67F1,\r
-  0xA6BC5767,\r
-  0x3FB506DD,\r
-  0x48B2364B,\r
-  0xD80D2BDA,\r
-  0xAF0A1B4C,\r
-  0x36034AF6,\r
-  0x41047A60,\r
-  0xDF60EFC3,\r
-  0xA867DF55,\r
-  0x316E8EEF,\r
-  0x4669BE79,\r
-  0xCB61B38C,\r
-  0xBC66831A,\r
-  0x256FD2A0,\r
-  0x5268E236,\r
-  0xCC0C7795,\r
-  0xBB0B4703,\r
-  0x220216B9,\r
-  0x5505262F,\r
-  0xC5BA3BBE,\r
-  0xB2BD0B28,\r
-  0x2BB45A92,\r
-  0x5CB36A04,\r
-  0xC2D7FFA7,\r
-  0xB5D0CF31,\r
-  0x2CD99E8B,\r
-  0x5BDEAE1D,\r
-  0x9B64C2B0,\r
-  0xEC63F226,\r
-  0x756AA39C,\r
-  0x026D930A,\r
-  0x9C0906A9,\r
-  0xEB0E363F,\r
-  0x72076785,\r
-  0x05005713,\r
-  0x95BF4A82,\r
-  0xE2B87A14,\r
-  0x7BB12BAE,\r
-  0x0CB61B38,\r
-  0x92D28E9B,\r
-  0xE5D5BE0D,\r
-  0x7CDCEFB7,\r
-  0x0BDBDF21,\r
-  0x86D3D2D4,\r
-  0xF1D4E242,\r
-  0x68DDB3F8,\r
-  0x1FDA836E,\r
-  0x81BE16CD,\r
-  0xF6B9265B,\r
-  0x6FB077E1,\r
-  0x18B74777,\r
-  0x88085AE6,\r
-  0xFF0F6A70,\r
-  0x66063BCA,\r
-  0x11010B5C,\r
-  0x8F659EFF,\r
-  0xF862AE69,\r
-  0x616BFFD3,\r
-  0x166CCF45,\r
-  0xA00AE278,\r
-  0xD70DD2EE,\r
-  0x4E048354,\r
-  0x3903B3C2,\r
-  0xA7672661,\r
-  0xD06016F7,\r
-  0x4969474D,\r
-  0x3E6E77DB,\r
-  0xAED16A4A,\r
-  0xD9D65ADC,\r
-  0x40DF0B66,\r
-  0x37D83BF0,\r
-  0xA9BCAE53,\r
-  0xDEBB9EC5,\r
-  0x47B2CF7F,\r
-  0x30B5FFE9,\r
-  0xBDBDF21C,\r
-  0xCABAC28A,\r
-  0x53B39330,\r
-  0x24B4A3A6,\r
-  0xBAD03605,\r
-  0xCDD70693,\r
-  0x54DE5729,\r
-  0x23D967BF,\r
-  0xB3667A2E,\r
-  0xC4614AB8,\r
-  0x5D681B02,\r
-  0x2A6F2B94,\r
-  0xB40BBE37,\r
-  0xC30C8EA1,\r
-  0x5A05DF1B,\r
-  0x2D02EF8D\r
-};\r
-\r
-EFI_STATUS\r
-CalculateCrc32 (\r
-  IN  UINT8                             *Data,\r
-  IN  UINTN                             DataSize,\r
-  IN OUT UINT32                         *CrcOut\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  The CalculateCrc32 routine.\r
-\r
-Arguments:\r
-\r
-  Data        - The buffer contaning the data to be processed\r
-  DataSize    - The size of data to be processed\r
-  CrcOut      - A pointer to the caller allocated UINT32 that on\r
-                contains the CRC32 checksum of Data\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS               - Calculation is successful.\r
-  EFI_INVALID_PARAMETER     - Data / CrcOut = NULL, or DataSize = 0\r
-\r
---*/\r
-{\r
-  UINT32  Crc;\r
-  UINTN   Index;\r
-  UINT8   *Ptr;\r
-\r
-  if ((DataSize == 0) || (Data == NULL) || (CrcOut == NULL)) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  Crc = 0xffffffff;\r
-  for (Index = 0, Ptr = Data; Index < DataSize; Index++, Ptr++) {\r
-    Crc = (Crc >> 8) ^ mCrcTable[(UINT8) Crc ^ *Ptr];\r
-  }\r
-\r
-  *CrcOut = Crc ^ 0xffffffff;\r
-\r
-  return EFI_SUCCESS;\r
-}\r
diff --git a/Tools/CodeTools/TianoTools/Common/Crc32.h b/Tools/CodeTools/TianoTools/Common/Crc32.h
deleted file mode 100644 (file)
index ec48cdd..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2004, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-Module Name:\r
-\r
-  Crc32.h\r
-\r
-Abstract:\r
-\r
-  Header file for CalcuateCrc32 routine\r
-  \r
---*/\r
-\r
-#ifndef _CRC32_H\r
-#define _CRC32_H\r
-\r
-#include <Common/UefiBaseTypes.h>\r
-\r
-EFI_STATUS\r
-CalculateCrc32 (\r
-  IN  UINT8                             *Data,\r
-  IN  UINTN                             DataSize,\r
-  IN OUT UINT32                         *CrcOut\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  The CalculateCrc32 routine.\r
-\r
-Arguments:\r
-\r
-  Data        - The buffer contaning the data to be processed\r
-  DataSize    - The size of data to be processed\r
-  CrcOut      - A pointer to the caller allocated UINT32 that on\r
-                contains the CRC32 checksum of Data\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS               - Calculation is successful.\r
-  EFI_INVALID_PARAMETER     - Data / CrcOut = NULL, or DataSize = 0\r
-\r
---*/\r
-;\r
-\r
-#endif\r
diff --git a/Tools/CodeTools/TianoTools/Common/EfiCompress.c b/Tools/CodeTools/TianoTools/Common/EfiCompress.c
deleted file mode 100644 (file)
index 5b91b1d..0000000
+++ /dev/null
@@ -1,1742 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2004, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-Module Name:\r
-\r
-  EfiCompress.c\r
-\r
-Abstract:\r
-\r
-  Compression routine. The compression algorithm is a mixture of\r
-  LZ77 and Huffman coding. LZ77 transforms the source data into a\r
-  sequence of Original Characters and Pointers to repeated strings.\r
-  This sequence is further divided into Blocks and Huffman codings\r
-  are applied to each Block.\r
-\r
---*/\r
-\r
-#include "EfiCompress.h"\r
-\r
-//\r
-// Macro Definitions\r
-//\r
-typedef INT32 NODE;\r
-#define UINT8_BIT     8\r
-#define THRESHOLD     3\r
-#define INIT_CRC      0\r
-#define WNDBIT        19\r
-#define WNDSIZ        (1U << WNDBIT)\r
-#define MAXMATCH      256\r
-#define BLKSIZ        (1U << 14)  // 16 * 1024U\r
-#define PERC_FLAG     0x80000000U\r
-#define CODE_BIT      16\r
-#define NIL           0\r
-#define MAX_HASH_VAL  (3 * WNDSIZ + (WNDSIZ / 512 + 1) * UINT8_MAX)\r
-#define HASH(p, c)    ((p) + ((c) << (WNDBIT - 9)) + WNDSIZ * 2)\r
-#define CRCPOLY       0xA001\r
-#define UPDATE_CRC(c) mCrc = mCrcTable[(mCrc ^ (c)) & 0xFF] ^ (mCrc >> UINT8_BIT)\r
-\r
-//\r
-// C: the Char&Len Set; P: the Position Set; T: the exTra Set\r
-//\r
-#define NC    (UINT8_MAX + MAXMATCH + 2 - THRESHOLD)\r
-#define CBIT  9\r
-#define NP    (WNDBIT + 1)\r
-#define PBIT  5\r
-#define NT    (CODE_BIT + 3)\r
-#define TBIT  5\r
-#if NT > NP\r
-#define NPT NT\r
-#else\r
-#define NPT NP\r
-#endif\r
-//\r
-// Function Prototypes\r
-//\r
-STATIC VOID PutDword(IN UINT32 Data);\r
-\r
-STATIC\r
-EFI_STATUS\r
-AllocateMemory (\r
-  VOID\r
-  );\r
-\r
-STATIC\r
-VOID\r
-FreeMemory (\r
-  VOID\r
-  );\r
-\r
-STATIC\r
-VOID\r
-InitSlide (\r
-  VOID\r
-  );\r
-\r
-STATIC\r
-NODE\r
-Child (\r
-  IN NODE   NodeQ,\r
-  IN UINT8  CharC\r
-  );\r
-\r
-STATIC\r
-VOID\r
-MakeChild (\r
-  IN NODE  NodeQ,\r
-  IN UINT8 CharC,\r
-  IN NODE  NodeR\r
-  );\r
-\r
-STATIC\r
-VOID\r
-Split (\r
-  IN NODE Old\r
-  );\r
-\r
-STATIC\r
-VOID\r
-InsertNode (\r
-  VOID\r
-  );\r
-\r
-STATIC\r
-VOID\r
-DeleteNode (\r
-  VOID\r
-  );\r
-\r
-STATIC\r
-VOID\r
-GetNextMatch (\r
-  VOID\r
-  );\r
-\r
-STATIC\r
-EFI_STATUS\r
-Encode (\r
-  VOID\r
-  );\r
-\r
-STATIC\r
-VOID\r
-CountTFreq (\r
-  VOID\r
-  );\r
-\r
-STATIC\r
-VOID\r
-WritePTLen (\r
-  IN INT32 Number,\r
-  IN INT32 nbit,\r
-  IN INT32 Special\r
-  );\r
-\r
-STATIC\r
-VOID\r
-WriteCLen (\r
-  VOID\r
-  );\r
-\r
-STATIC\r
-VOID\r
-EncodeC (\r
-  IN INT32 Value\r
-  );\r
-\r
-STATIC\r
-VOID\r
-EncodeP (\r
-  IN UINT32 Value\r
-  );\r
-\r
-STATIC\r
-VOID\r
-SendBlock (\r
-  VOID\r
-  );\r
-\r
-STATIC\r
-VOID\r
-Output (\r
-  IN UINT32 c,\r
-  IN UINT32 p\r
-  );\r
-\r
-STATIC\r
-VOID\r
-HufEncodeStart (\r
-  VOID\r
-  );\r
-\r
-STATIC\r
-VOID\r
-HufEncodeEnd (\r
-  VOID\r
-  );\r
-\r
-STATIC\r
-VOID\r
-MakeCrcTable (\r
-  VOID\r
-  );\r
-\r
-STATIC\r
-VOID\r
-PutBits (\r
-  IN INT32  Number,\r
-  IN UINT32 Value\r
-  );\r
-\r
-STATIC\r
-INT32\r
-FreadCrc (\r
-  OUT UINT8 *Pointer,\r
-  IN  INT32 Number\r
-  );\r
-\r
-STATIC\r
-VOID\r
-InitPutBits (\r
-  VOID\r
-  );\r
-\r
-STATIC\r
-VOID\r
-CountLen (\r
-  IN INT32 Index\r
-  );\r
-\r
-STATIC\r
-VOID\r
-MakeLen (\r
-  IN INT32 Root\r
-  );\r
-\r
-STATIC\r
-VOID\r
-DownHeap (\r
-  IN INT32 Index\r
-  );\r
-\r
-STATIC\r
-VOID\r
-MakeCode (\r
-  IN  INT32       Number,\r
-  IN  UINT8 Len[  ],\r
-  OUT UINT16 Code[]\r
-  );\r
-\r
-STATIC\r
-INT32\r
-MakeTree (\r
-  IN  INT32            NParm,\r
-  IN  UINT16  FreqParm[],\r
-  OUT UINT8   LenParm[ ],\r
-  OUT UINT16  CodeParm[]\r
-  );\r
-\r
-//\r
-//  Global Variables\r
-//\r
-static UINT8  *mSrc, *mDst, *mSrcUpperLimit, *mDstUpperLimit;\r
-\r
-static UINT8  *mLevel, *mText, *mChildCount, *mBuf, mCLen[NC], mPTLen[NPT], *mLen;\r
-static INT16  mHeap[NC + 1];\r
-static INT32  mRemainder, mMatchLen, mBitCount, mHeapSize, mN;\r
-static UINT32 mBufSiz = 0, mOutputPos, mOutputMask, mSubBitBuf, mCrc;\r
-static UINT32 mCompSize, mOrigSize;\r
-\r
-static UINT16 *mFreq, *mSortPtr, mLenCnt[17], mLeft[2 * NC - 1], mRight[2 * NC - 1], mCrcTable[UINT8_MAX + 1],\r
-  mCFreq[2 * NC - 1], mCTable[4096], mCCode[NC], mPFreq[2 * NP - 1], mPTCode[NPT], mTFreq[2 * NT - 1];\r
-\r
-static NODE   mPos, mMatchPos, mAvail, *mPosition, *mParent, *mPrev, *mNext = NULL;\r
-\r
-//\r
-// functions\r
-//\r
-EFI_STATUS\r
-Compress (\r
-  IN      UINT8   *SrcBuffer,\r
-  IN      UINT32  SrcSize,\r
-  IN      UINT8   *DstBuffer,\r
-  IN OUT  UINT32  *DstSize\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  The main compression routine.\r
-\r
-Arguments:\r
-\r
-  SrcBuffer   - The buffer storing the source data\r
-  SrcSize     - The size of source data\r
-  DstBuffer   - The buffer to store the compressed data\r
-  DstSize     - On input, the size of DstBuffer; On output,\r
-                the size of the actual compressed data.\r
-\r
-Returns:\r
-\r
-  EFI_BUFFER_TOO_SMALL  - The DstBuffer is too small. In this case,\r
-                DstSize contains the size needed.\r
-  EFI_SUCCESS           - Compression is successful.\r
-  EFI_OUT_OF_RESOURCES  - No resource to complete function.\r
-\r
---*/\r
-{\r
-  EFI_STATUS  Status;\r
-\r
-  //\r
-  // Initializations\r
-  //\r
-  mBufSiz         = 0;\r
-  mBuf            = NULL;\r
-  mText           = NULL;\r
-  mLevel          = NULL;\r
-  mChildCount     = NULL;\r
-  mPosition       = NULL;\r
-  mParent         = NULL;\r
-  mPrev           = NULL;\r
-  mNext           = NULL;\r
-\r
-  mSrc            = SrcBuffer;\r
-  mSrcUpperLimit  = mSrc + SrcSize;\r
-  mDst            = DstBuffer;\r
-  mDstUpperLimit  = mDst +*DstSize;\r
-\r
-  PutDword (0L);\r
-  PutDword (0L);\r
-\r
-  MakeCrcTable ();\r
-\r
-  mOrigSize             = mCompSize = 0;\r
-  mCrc                  = INIT_CRC;\r
-\r
-  //\r
-  // Compress it\r
-  //\r
-  Status = Encode ();\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-  //\r
-  // Null terminate the compressed data\r
-  //\r
-  if (mDst < mDstUpperLimit) {\r
-    *mDst++ = 0;\r
-  }\r
-  //\r
-  // Fill in compressed size and original size\r
-  //\r
-  mDst = DstBuffer;\r
-  PutDword (mCompSize + 1);\r
-  PutDword (mOrigSize);\r
-\r
-  //\r
-  // Return\r
-  //\r
-  if (mCompSize + 1 + 8 > *DstSize) {\r
-    *DstSize = mCompSize + 1 + 8;\r
-    return EFI_BUFFER_TOO_SMALL;\r
-  } else {\r
-    *DstSize = mCompSize + 1 + 8;\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-}\r
-\r
-STATIC\r
-VOID\r
-PutDword (\r
-  IN UINT32 Data\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Put a dword to output stream\r
-  \r
-Arguments:\r
-\r
-  Data    - the dword to put\r
-  \r
-Returns: (VOID)\r
-  \r
---*/\r
-{\r
-  if (mDst < mDstUpperLimit) {\r
-    *mDst++ = (UINT8) (((UINT8) (Data)) & 0xff);\r
-  }\r
-\r
-  if (mDst < mDstUpperLimit) {\r
-    *mDst++ = (UINT8) (((UINT8) (Data >> 0x08)) & 0xff);\r
-  }\r
-\r
-  if (mDst < mDstUpperLimit) {\r
-    *mDst++ = (UINT8) (((UINT8) (Data >> 0x10)) & 0xff);\r
-  }\r
-\r
-  if (mDst < mDstUpperLimit) {\r
-    *mDst++ = (UINT8) (((UINT8) (Data >> 0x18)) & 0xff);\r
-  }\r
-}\r
-\r
-STATIC\r
-EFI_STATUS\r
-AllocateMemory (\r
-  VOID\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Allocate memory spaces for data structures used in compression process\r
-  \r
-Argements: \r
-  VOID\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS           - Memory is allocated successfully\r
-  EFI_OUT_OF_RESOURCES  - Allocation fails\r
-\r
---*/\r
-{\r
-  UINT32  Index;\r
-\r
-  mText = malloc (WNDSIZ * 2 + MAXMATCH);\r
-  for (Index = 0; Index < WNDSIZ * 2 + MAXMATCH; Index++) {\r
-    mText[Index] = 0;\r
-  }\r
-\r
-  mLevel      = malloc ((WNDSIZ + UINT8_MAX + 1) * sizeof (*mLevel));\r
-  mChildCount = malloc ((WNDSIZ + UINT8_MAX + 1) * sizeof (*mChildCount));\r
-  mPosition   = malloc ((WNDSIZ + UINT8_MAX + 1) * sizeof (*mPosition));\r
-  mParent     = malloc (WNDSIZ * 2 * sizeof (*mParent));\r
-  mPrev       = malloc (WNDSIZ * 2 * sizeof (*mPrev));\r
-  mNext       = malloc ((MAX_HASH_VAL + 1) * sizeof (*mNext));\r
-\r
-  mBufSiz     = BLKSIZ;\r
-  mBuf        = malloc (mBufSiz);\r
-  while (mBuf == NULL) {\r
-    mBufSiz = (mBufSiz / 10U) * 9U;\r
-    if (mBufSiz < 4 * 1024U) {\r
-      return EFI_OUT_OF_RESOURCES;\r
-    }\r
-\r
-    mBuf = malloc (mBufSiz);\r
-  }\r
-\r
-  mBuf[0] = 0;\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-VOID\r
-FreeMemory (\r
-  VOID\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Called when compression is completed to free memory previously allocated.\r
-  \r
-Arguments: (VOID)\r
-\r
-Returns: (VOID)\r
-\r
---*/\r
-{\r
-  if (mText != NULL) {\r
-    free (mText);\r
-  }\r
-\r
-  if (mLevel != NULL) {\r
-    free (mLevel);\r
-  }\r
-\r
-  if (mChildCount != NULL) {\r
-    free (mChildCount);\r
-  }\r
-\r
-  if (mPosition != NULL) {\r
-    free (mPosition);\r
-  }\r
-\r
-  if (mParent != NULL) {\r
-    free (mParent);\r
-  }\r
-\r
-  if (mPrev != NULL) {\r
-    free (mPrev);\r
-  }\r
-\r
-  if (mNext != NULL) {\r
-    free (mNext);\r
-  }\r
-\r
-  if (mBuf != NULL) {\r
-    free (mBuf);\r
-  }\r
-\r
-  return ;\r
-}\r
-\r
-STATIC\r
-VOID\r
-InitSlide (\r
-  VOID\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Initialize String Info Log data structures\r
-  \r
-Arguments: (VOID)\r
-\r
-Returns: (VOID)\r
-\r
---*/\r
-{\r
-  NODE  Index;\r
-\r
-  for (Index = WNDSIZ; Index <= WNDSIZ + UINT8_MAX; Index++) {\r
-    mLevel[Index]     = 1;\r
-    mPosition[Index]  = NIL;  /* sentinel */\r
-  }\r
-\r
-  for (Index = WNDSIZ; Index < WNDSIZ * 2; Index++) {\r
-    mParent[Index] = NIL;\r
-  }\r
-\r
-  mAvail = 1;\r
-  for (Index = 1; Index < WNDSIZ - 1; Index++) {\r
-    mNext[Index] = (NODE) (Index + 1);\r
-  }\r
-\r
-  mNext[WNDSIZ - 1] = NIL;\r
-  for (Index = WNDSIZ * 2; Index <= MAX_HASH_VAL; Index++) {\r
-    mNext[Index] = NIL;\r
-  }\r
-}\r
-\r
-STATIC\r
-NODE\r
-Child (\r
-  IN NODE  NodeQ,\r
-  IN UINT8 CharC\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Find child node given the parent node and the edge character\r
-  \r
-Arguments:\r
-\r
-  NodeQ       - the parent node\r
-  CharC       - the edge character\r
-  \r
-Returns:\r
-\r
-  The child node (NIL if not found)  \r
-  \r
---*/\r
-{\r
-  NODE  NodeR;\r
-\r
-  NodeR = mNext[HASH (NodeQ, CharC)];\r
-  //\r
-  // sentinel\r
-  //\r
-  mParent[NIL] = NodeQ;\r
-  while (mParent[NodeR] != NodeQ) {\r
-    NodeR = mNext[NodeR];\r
-  }\r
-\r
-  return NodeR;\r
-}\r
-\r
-STATIC\r
-VOID\r
-MakeChild (\r
-  IN NODE  Parent,\r
-  IN UINT8 CharC,\r
-  IN NODE  Child\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Create a new child for a given parent node.\r
-  \r
-Arguments:\r
-\r
-  Parent       - the parent node\r
-  CharC   - the edge character\r
-  Child       - the child node\r
-  \r
-Returns: (VOID)\r
-\r
---*/\r
-{\r
-  NODE  Node1;\r
-  NODE  Node2;\r
-\r
-  Node1           = (NODE) HASH (Parent, CharC);\r
-  Node2           = mNext[Node1];\r
-  mNext[Node1]    = Child;\r
-  mNext[Child]    = Node2;\r
-  mPrev[Node2]    = Child;\r
-  mPrev[Child]    = Node1;\r
-  mParent[Child]  = Parent;\r
-  mChildCount[Parent]++;\r
-}\r
-\r
-STATIC\r
-VOID\r
-Split (\r
-  NODE Old\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Split a node.\r
-  \r
-Arguments:\r
-\r
-  Old     - the node to split\r
-  \r
-Returns: (VOID)\r
-\r
---*/\r
-{\r
-  NODE  New;\r
-  NODE  TempNode;\r
-\r
-  New               = mAvail;\r
-  mAvail            = mNext[New];\r
-  mChildCount[New]  = 0;\r
-  TempNode          = mPrev[Old];\r
-  mPrev[New]        = TempNode;\r
-  mNext[TempNode]   = New;\r
-  TempNode          = mNext[Old];\r
-  mNext[New]        = TempNode;\r
-  mPrev[TempNode]   = New;\r
-  mParent[New]      = mParent[Old];\r
-  mLevel[New]       = (UINT8) mMatchLen;\r
-  mPosition[New]    = mPos;\r
-  MakeChild (New, mText[mMatchPos + mMatchLen], Old);\r
-  MakeChild (New, mText[mPos + mMatchLen], mPos);\r
-}\r
-\r
-STATIC\r
-VOID\r
-InsertNode (\r
-  VOID\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Insert string info for current position into the String Info Log\r
-  \r
-Arguments: (VOID)\r
-\r
-Returns: (VOID)\r
-\r
---*/\r
-{\r
-  NODE  NodeQ;\r
-  NODE  NodeR;\r
-  NODE  Index2;\r
-  NODE  NodeT;\r
-  UINT8 CharC;\r
-  UINT8 *t1;\r
-  UINT8 *t2;\r
-\r
-  if (mMatchLen >= 4) {\r
-    //\r
-    // We have just got a long match, the target tree\r
-    // can be located by MatchPos + 1. Travese the tree\r
-    // from bottom up to get to a proper starting point.\r
-    // The usage of PERC_FLAG ensures proper node deletion\r
-    // in DeleteNode() later.\r
-    //\r
-    mMatchLen--;\r
-    NodeR = (NODE) ((mMatchPos + 1) | WNDSIZ);\r
-    NodeQ = mParent[NodeR];\r
-    while (NodeQ == NIL) {\r
-      NodeR = mNext[NodeR];\r
-      NodeQ = mParent[NodeR];\r
-    }\r
-\r
-    while (mLevel[NodeQ] >= mMatchLen) {\r
-      NodeR = NodeQ;\r
-      NodeQ = mParent[NodeQ];\r
-    }\r
-\r
-    NodeT = NodeQ;\r
-    while (mPosition[NodeT] < 0) {\r
-      mPosition[NodeT]  = mPos;\r
-      NodeT             = mParent[NodeT];\r
-    }\r
-\r
-    if (NodeT < WNDSIZ) {\r
-      mPosition[NodeT] = (NODE) (mPos | (UINT32) PERC_FLAG);\r
-    }\r
-  } else {\r
-    //\r
-    // Locate the target tree\r
-    //\r
-    NodeQ = (NODE) (mText[mPos] + WNDSIZ);\r
-    CharC = mText[mPos + 1];\r
-    NodeR = Child (NodeQ, CharC);\r
-    if (NodeR == NIL) {\r
-      MakeChild (NodeQ, CharC, mPos);\r
-      mMatchLen = 1;\r
-      return ;\r
-    }\r
-\r
-    mMatchLen = 2;\r
-  }\r
-  //\r
-  // Traverse down the tree to find a match.\r
-  // Update Position value along the route.\r
-  // Node split or creation is involved.\r
-  //\r
-  for (;;) {\r
-    if (NodeR >= WNDSIZ) {\r
-      Index2    = MAXMATCH;\r
-      mMatchPos = NodeR;\r
-    } else {\r
-      Index2    = mLevel[NodeR];\r
-      mMatchPos = (NODE) (mPosition[NodeR] & (UINT32)~PERC_FLAG);\r
-    }\r
-\r
-    if (mMatchPos >= mPos) {\r
-      mMatchPos -= WNDSIZ;\r
-    }\r
-\r
-    t1  = &mText[mPos + mMatchLen];\r
-    t2  = &mText[mMatchPos + mMatchLen];\r
-    while (mMatchLen < Index2) {\r
-      if (*t1 != *t2) {\r
-        Split (NodeR);\r
-        return ;\r
-      }\r
-\r
-      mMatchLen++;\r
-      t1++;\r
-      t2++;\r
-    }\r
-\r
-    if (mMatchLen >= MAXMATCH) {\r
-      break;\r
-    }\r
-\r
-    mPosition[NodeR]  = mPos;\r
-    NodeQ             = NodeR;\r
-    NodeR             = Child (NodeQ, *t1);\r
-    if (NodeR == NIL) {\r
-      MakeChild (NodeQ, *t1, mPos);\r
-      return ;\r
-    }\r
-\r
-    mMatchLen++;\r
-  }\r
-\r
-  NodeT           = mPrev[NodeR];\r
-  mPrev[mPos]     = NodeT;\r
-  mNext[NodeT]    = mPos;\r
-  NodeT           = mNext[NodeR];\r
-  mNext[mPos]     = NodeT;\r
-  mPrev[NodeT]    = mPos;\r
-  mParent[mPos]   = NodeQ;\r
-  mParent[NodeR]  = NIL;\r
-\r
-  //\r
-  // Special usage of 'next'\r
-  //\r
-  mNext[NodeR] = mPos;\r
-\r
-}\r
-\r
-STATIC\r
-VOID\r
-DeleteNode (\r
-  VOID\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Delete outdated string info. (The Usage of PERC_FLAG\r
-  ensures a clean deletion)\r
-  \r
-Arguments: (VOID)\r
-\r
-Returns: (VOID)\r
-\r
---*/\r
-{\r
-  NODE  NodeQ;\r
-  NODE  NodeR;\r
-  NODE  NodeS;\r
-  NODE  NodeT;\r
-  NODE  NodeU;\r
-\r
-  if (mParent[mPos] == NIL) {\r
-    return ;\r
-  }\r
-\r
-  NodeR         = mPrev[mPos];\r
-  NodeS         = mNext[mPos];\r
-  mNext[NodeR]  = NodeS;\r
-  mPrev[NodeS]  = NodeR;\r
-  NodeR         = mParent[mPos];\r
-  mParent[mPos] = NIL;\r
-  if (NodeR >= WNDSIZ) {\r
-    return ;\r
-  }\r
-\r
-  mChildCount[NodeR]--;\r
-  if (mChildCount[NodeR] > 1) {\r
-    return ;\r
-  }\r
-\r
-  NodeT = (NODE) (mPosition[NodeR] & (UINT32)~PERC_FLAG);\r
-  if (NodeT >= mPos) {\r
-    NodeT -= WNDSIZ;\r
-  }\r
-\r
-  NodeS = NodeT;\r
-  NodeQ = mParent[NodeR];\r
-  NodeU = mPosition[NodeQ];\r
-  while (NodeU & (UINT32) PERC_FLAG) {\r
-    NodeU &= (UINT32)~PERC_FLAG;\r
-    if (NodeU >= mPos) {\r
-      NodeU -= WNDSIZ;\r
-    }\r
-\r
-    if (NodeU > NodeS) {\r
-      NodeS = NodeU;\r
-    }\r
-\r
-    mPosition[NodeQ]  = (NODE) (NodeS | WNDSIZ);\r
-    NodeQ             = mParent[NodeQ];\r
-    NodeU             = mPosition[NodeQ];\r
-  }\r
-\r
-  if (NodeQ < WNDSIZ) {\r
-    if (NodeU >= mPos) {\r
-      NodeU -= WNDSIZ;\r
-    }\r
-\r
-    if (NodeU > NodeS) {\r
-      NodeS = NodeU;\r
-    }\r
-\r
-    mPosition[NodeQ] = (NODE) (NodeS | WNDSIZ | (UINT32) PERC_FLAG);\r
-  }\r
-\r
-  NodeS           = Child (NodeR, mText[NodeT + mLevel[NodeR]]);\r
-  NodeT           = mPrev[NodeS];\r
-  NodeU           = mNext[NodeS];\r
-  mNext[NodeT]    = NodeU;\r
-  mPrev[NodeU]    = NodeT;\r
-  NodeT           = mPrev[NodeR];\r
-  mNext[NodeT]    = NodeS;\r
-  mPrev[NodeS]    = NodeT;\r
-  NodeT           = mNext[NodeR];\r
-  mPrev[NodeT]    = NodeS;\r
-  mNext[NodeS]    = NodeT;\r
-  mParent[NodeS]  = mParent[NodeR];\r
-  mParent[NodeR]  = NIL;\r
-  mNext[NodeR]    = mAvail;\r
-  mAvail          = NodeR;\r
-}\r
-\r
-STATIC\r
-VOID\r
-GetNextMatch (\r
-  VOID\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Advance the current position (read in new data if needed).\r
-  Delete outdated string info. Find a match string for current position.\r
-\r
-Arguments: (VOID)\r
-\r
-Returns: (VOID)\r
-\r
---*/\r
-{\r
-  INT32 Number;\r
-\r
-  mRemainder--;\r
-  mPos++;\r
-  if (mPos == WNDSIZ * 2) {\r
-    memmove (&mText[0], &mText[WNDSIZ], WNDSIZ + MAXMATCH);\r
-    Number = FreadCrc (&mText[WNDSIZ + MAXMATCH], WNDSIZ);\r
-    mRemainder += Number;\r
-    mPos = WNDSIZ;\r
-  }\r
-\r
-  DeleteNode ();\r
-  InsertNode ();\r
-}\r
-\r
-STATIC\r
-EFI_STATUS\r
-Encode (\r
-  VOID\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  The main controlling routine for compression process.\r
-\r
-Arguments: (VOID)\r
-\r
-Returns:\r
-  \r
-  EFI_SUCCESS           - The compression is successful\r
-  EFI_OUT_0F_RESOURCES  - Not enough memory for compression process\r
-\r
---*/\r
-{\r
-  EFI_STATUS  Status;\r
-  INT32       LastMatchLen;\r
-  NODE        LastMatchPos;\r
-\r
-  Status = AllocateMemory ();\r
-  if (EFI_ERROR (Status)) {\r
-    FreeMemory ();\r
-    return Status;\r
-  }\r
-\r
-  InitSlide ();\r
-\r
-  HufEncodeStart ();\r
-\r
-  mRemainder  = FreadCrc (&mText[WNDSIZ], WNDSIZ + MAXMATCH);\r
-\r
-  mMatchLen   = 0;\r
-  mPos        = WNDSIZ;\r
-  InsertNode ();\r
-  if (mMatchLen > mRemainder) {\r
-    mMatchLen = mRemainder;\r
-  }\r
-\r
-  while (mRemainder > 0) {\r
-    LastMatchLen  = mMatchLen;\r
-    LastMatchPos  = mMatchPos;\r
-    GetNextMatch ();\r
-    if (mMatchLen > mRemainder) {\r
-      mMatchLen = mRemainder;\r
-    }\r
-\r
-    if (mMatchLen > LastMatchLen || LastMatchLen < THRESHOLD) {\r
-      //\r
-      // Not enough benefits are gained by outputting a pointer,\r
-      // so just output the original character\r
-      //\r
-      Output (mText[mPos - 1], 0);\r
-\r
-    } else {\r
-\r
-      if (LastMatchLen == THRESHOLD) {\r
-        if (((mPos - LastMatchPos - 2) & (WNDSIZ - 1)) > (1U << 11)) {\r
-          Output (mText[mPos - 1], 0);\r
-          continue;\r
-        }\r
-      }\r
-      //\r
-      // Outputting a pointer is beneficial enough, do it.\r
-      //\r
-      Output (\r
-        LastMatchLen + (UINT8_MAX + 1 - THRESHOLD),\r
-        (mPos - LastMatchPos - 2) & (WNDSIZ - 1)\r
-        );\r
-      LastMatchLen--;\r
-      while (LastMatchLen > 0) {\r
-        GetNextMatch ();\r
-        LastMatchLen--;\r
-      }\r
-\r
-      if (mMatchLen > mRemainder) {\r
-        mMatchLen = mRemainder;\r
-      }\r
-    }\r
-  }\r
-\r
-  HufEncodeEnd ();\r
-  FreeMemory ();\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-STATIC\r
-VOID\r
-CountTFreq (\r
-  VOID\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Count the frequencies for the Extra Set\r
-  \r
-Arguments: (VOID)\r
-\r
-Returns: (VOID)\r
-\r
---*/\r
-{\r
-  INT32 Index;\r
-  INT32 Index3;\r
-  INT32 Number;\r
-  INT32 Count;\r
-\r
-  for (Index = 0; Index < NT; Index++) {\r
-    mTFreq[Index] = 0;\r
-  }\r
-\r
-  Number = NC;\r
-  while (Number > 0 && mCLen[Number - 1] == 0) {\r
-    Number--;\r
-  }\r
-\r
-  Index = 0;\r
-  while (Index < Number) {\r
-    Index3 = mCLen[Index++];\r
-    if (Index3 == 0) {\r
-      Count = 1;\r
-      while (Index < Number && mCLen[Index] == 0) {\r
-        Index++;\r
-        Count++;\r
-      }\r
-\r
-      if (Count <= 2) {\r
-        mTFreq[0] = (UINT16) (mTFreq[0] + Count);\r
-      } else if (Count <= 18) {\r
-        mTFreq[1]++;\r
-      } else if (Count == 19) {\r
-        mTFreq[0]++;\r
-        mTFreq[1]++;\r
-      } else {\r
-        mTFreq[2]++;\r
-      }\r
-    } else {\r
-      mTFreq[Index3 + 2]++;\r
-    }\r
-  }\r
-}\r
-\r
-STATIC\r
-VOID\r
-WritePTLen (\r
-  IN INT32 Number,\r
-  IN INT32 nbit,\r
-  IN INT32 Special\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Outputs the code length array for the Extra Set or the Position Set.\r
-  \r
-Arguments:\r
-\r
-  Number       - the number of symbols\r
-  nbit    - the number of bits needed to represent 'n'\r
-  Special - the special symbol that needs to be take care of\r
-  \r
-Returns: (VOID)\r
-\r
---*/\r
-{\r
-  INT32 Index;\r
-  INT32 Index3;\r
-\r
-  while (Number > 0 && mPTLen[Number - 1] == 0) {\r
-    Number--;\r
-  }\r
-\r
-  PutBits (nbit, Number);\r
-  Index = 0;\r
-  while (Index < Number) {\r
-    Index3 = mPTLen[Index++];\r
-    if (Index3 <= 6) {\r
-      PutBits (3, Index3);\r
-    } else {\r
-      PutBits (Index3 - 3, (1U << (Index3 - 3)) - 2);\r
-    }\r
-\r
-    if (Index == Special) {\r
-      while (Index < 6 && mPTLen[Index] == 0) {\r
-        Index++;\r
-      }\r
-\r
-      PutBits (2, (Index - 3) & 3);\r
-    }\r
-  }\r
-}\r
-\r
-STATIC\r
-VOID\r
-WriteCLen (\r
-  VOID\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Outputs the code length array for Char&Length Set\r
-  \r
-Arguments: (VOID)\r
-\r
-Returns: (VOID)\r
-\r
---*/\r
-{\r
-  INT32 Index;\r
-  INT32 Index3;\r
-  INT32 Number;\r
-  INT32 Count;\r
-\r
-  Number = NC;\r
-  while (Number > 0 && mCLen[Number - 1] == 0) {\r
-    Number--;\r
-  }\r
-\r
-  PutBits (CBIT, Number);\r
-  Index = 0;\r
-  while (Index < Number) {\r
-    Index3 = mCLen[Index++];\r
-    if (Index3 == 0) {\r
-      Count = 1;\r
-      while (Index < Number && mCLen[Index] == 0) {\r
-        Index++;\r
-        Count++;\r
-      }\r
-\r
-      if (Count <= 2) {\r
-        for (Index3 = 0; Index3 < Count; Index3++) {\r
-          PutBits (mPTLen[0], mPTCode[0]);\r
-        }\r
-      } else if (Count <= 18) {\r
-        PutBits (mPTLen[1], mPTCode[1]);\r
-        PutBits (4, Count - 3);\r
-      } else if (Count == 19) {\r
-        PutBits (mPTLen[0], mPTCode[0]);\r
-        PutBits (mPTLen[1], mPTCode[1]);\r
-        PutBits (4, 15);\r
-      } else {\r
-        PutBits (mPTLen[2], mPTCode[2]);\r
-        PutBits (CBIT, Count - 20);\r
-      }\r
-    } else {\r
-      PutBits (mPTLen[Index3 + 2], mPTCode[Index3 + 2]);\r
-    }\r
-  }\r
-}\r
-\r
-STATIC\r
-VOID\r
-EncodeC (\r
-  IN INT32 Value\r
-  )\r
-{\r
-  PutBits (mCLen[Value], mCCode[Value]);\r
-}\r
-\r
-STATIC\r
-VOID\r
-EncodeP (\r
-  IN UINT32 Value\r
-  )\r
-{\r
-  UINT32  Index;\r
-  UINT32  NodeQ;\r
-\r
-  Index = 0;\r
-  NodeQ = Value;\r
-  while (NodeQ) {\r
-    NodeQ >>= 1;\r
-    Index++;\r
-  }\r
-\r
-  PutBits (mPTLen[Index], mPTCode[Index]);\r
-  if (Index > 1) {\r
-    PutBits (Index - 1, Value & (0xFFFFFFFFU >> (32 - Index + 1)));\r
-  }\r
-}\r
-\r
-STATIC\r
-VOID\r
-SendBlock (\r
-  VOID\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Huffman code the block and output it.\r
-  \r
-Arguments: \r
-  (VOID)\r
-\r
-Returns: \r
-  (VOID)\r
-\r
---*/\r
-{\r
-  UINT32  Index;\r
-  UINT32  Index2;\r
-  UINT32  Index3;\r
-  UINT32  Flags;\r
-  UINT32  Root;\r
-  UINT32  Pos;\r
-  UINT32  Size;\r
-  Flags = 0;\r
-\r
-  Root  = MakeTree (NC, mCFreq, mCLen, mCCode);\r
-  Size  = mCFreq[Root];\r
-  PutBits (16, Size);\r
-  if (Root >= NC) {\r
-    CountTFreq ();\r
-    Root = MakeTree (NT, mTFreq, mPTLen, mPTCode);\r
-    if (Root >= NT) {\r
-      WritePTLen (NT, TBIT, 3);\r
-    } else {\r
-      PutBits (TBIT, 0);\r
-      PutBits (TBIT, Root);\r
-    }\r
-\r
-    WriteCLen ();\r
-  } else {\r
-    PutBits (TBIT, 0);\r
-    PutBits (TBIT, 0);\r
-    PutBits (CBIT, 0);\r
-    PutBits (CBIT, Root);\r
-  }\r
-\r
-  Root = MakeTree (NP, mPFreq, mPTLen, mPTCode);\r
-  if (Root >= NP) {\r
-    WritePTLen (NP, PBIT, -1);\r
-  } else {\r
-    PutBits (PBIT, 0);\r
-    PutBits (PBIT, Root);\r
-  }\r
-\r
-  Pos = 0;\r
-  for (Index = 0; Index < Size; Index++) {\r
-    if (Index % UINT8_BIT == 0) {\r
-      Flags = mBuf[Pos++];\r
-    } else {\r
-      Flags <<= 1;\r
-    }\r
-\r
-    if (Flags & (1U << (UINT8_BIT - 1))) {\r
-      EncodeC (mBuf[Pos++] + (1U << UINT8_BIT));\r
-      Index3 = mBuf[Pos++];\r
-      for (Index2 = 0; Index2 < 3; Index2++) {\r
-        Index3 <<= UINT8_BIT;\r
-        Index3 += mBuf[Pos++];\r
-      }\r
-\r
-      EncodeP (Index3);\r
-    } else {\r
-      EncodeC (mBuf[Pos++]);\r
-    }\r
-  }\r
-\r
-  for (Index = 0; Index < NC; Index++) {\r
-    mCFreq[Index] = 0;\r
-  }\r
-\r
-  for (Index = 0; Index < NP; Index++) {\r
-    mPFreq[Index] = 0;\r
-  }\r
-}\r
-\r
-STATIC\r
-VOID\r
-Output (\r
-  IN UINT32 CharC,\r
-  IN UINT32 Pos\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Outputs an Original Character or a Pointer\r
-\r
-Arguments:\r
-\r
-  CharC     - The original character or the 'String Length' element of a Pointer\r
-  Pos     - The 'Position' field of a Pointer\r
-\r
-Returns: (VOID)\r
-\r
---*/\r
-{\r
-  static UINT32 CPos;\r
-\r
-  if ((mOutputMask >>= 1) == 0) {\r
-    mOutputMask = 1U << (UINT8_BIT - 1);\r
-    //\r
-    // Check the buffer overflow per outputing UINT8_BIT symbols\r
-    // which is an Original Character or a Pointer. The biggest\r
-    // symbol is a Pointer which occupies 5 bytes.\r
-    //\r
-    if (mOutputPos >= mBufSiz - 5 * UINT8_BIT) {\r
-      SendBlock ();\r
-      mOutputPos = 0;\r
-    }\r
-\r
-    CPos        = mOutputPos++;\r
-    mBuf[CPos]  = 0;\r
-  }\r
-\r
-  mBuf[mOutputPos++] = (UINT8) CharC;\r
-  mCFreq[CharC]++;\r
-  if (CharC >= (1U << UINT8_BIT)) {\r
-    mBuf[CPos] |= mOutputMask;\r
-    mBuf[mOutputPos++]  = (UINT8) (Pos >> 24);\r
-    mBuf[mOutputPos++]  = (UINT8) (Pos >> 16);\r
-    mBuf[mOutputPos++]  = (UINT8) (Pos >> (UINT8_BIT));\r
-    mBuf[mOutputPos++]  = (UINT8) Pos;\r
-    CharC               = 0;\r
-    while (Pos) {\r
-      Pos >>= 1;\r
-      CharC++;\r
-    }\r
-\r
-    mPFreq[CharC]++;\r
-  }\r
-}\r
-\r
-STATIC\r
-VOID\r
-HufEncodeStart (\r
-  VOID\r
-  )\r
-{\r
-  INT32 Index;\r
-\r
-  for (Index = 0; Index < NC; Index++) {\r
-    mCFreq[Index] = 0;\r
-  }\r
-\r
-  for (Index = 0; Index < NP; Index++) {\r
-    mPFreq[Index] = 0;\r
-  }\r
-\r
-  mOutputPos = mOutputMask = 0;\r
-  InitPutBits ();\r
-  return ;\r
-}\r
-\r
-STATIC\r
-VOID\r
-HufEncodeEnd (\r
-  VOID\r
-  )\r
-{\r
-  SendBlock ();\r
-\r
-  //\r
-  // Flush remaining bits\r
-  //\r
-  PutBits (UINT8_BIT - 1, 0);\r
-\r
-  return ;\r
-}\r
-\r
-STATIC\r
-VOID\r
-MakeCrcTable (\r
-  VOID\r
-  )\r
-{\r
-  UINT32  Index;\r
-  UINT32  Index2;\r
-  UINT32  Temp;\r
-\r
-  for (Index = 0; Index <= UINT8_MAX; Index++) {\r
-    Temp = Index;\r
-    for (Index2 = 0; Index2 < UINT8_BIT; Index2++) {\r
-      if (Temp & 1) {\r
-        Temp = (Temp >> 1) ^ CRCPOLY;\r
-      } else {\r
-        Temp >>= 1;\r
-      }\r
-    }\r
-\r
-    mCrcTable[Index] = (UINT16) Temp;\r
-  }\r
-}\r
-\r
-STATIC\r
-VOID\r
-PutBits (\r
-  IN INT32  Number,\r
-  IN UINT32 Value\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Outputs rightmost n bits of x\r
-\r
-Arguments:\r
-\r
-  Number   - the rightmost n bits of the data is used\r
-  x   - the data \r
-\r
-Returns: (VOID)\r
-\r
---*/\r
-{\r
-  UINT8 Temp;\r
-\r
-  while (Number >= mBitCount) {\r
-    //\r
-    // Number -= mBitCount should never equal to 32\r
-    //\r
-    Temp = (UINT8) (mSubBitBuf | (Value >> (Number -= mBitCount)));\r
-    if (mDst < mDstUpperLimit) {\r
-      *mDst++ = Temp;\r
-    }\r
-\r
-    mCompSize++;\r
-    mSubBitBuf  = 0;\r
-    mBitCount   = UINT8_BIT;\r
-  }\r
-\r
-  mSubBitBuf |= Value << (mBitCount -= Number);\r
-}\r
-\r
-STATIC\r
-INT32\r
-FreadCrc (\r
-  OUT UINT8 *Pointer,\r
-  IN  INT32 Number\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Read in source data\r
-  \r
-Arguments:\r
-\r
-  Pointer   - the buffer to hold the data\r
-  Number   - number of bytes to read\r
-\r
-Returns:\r
-\r
-  number of bytes actually read\r
-  \r
---*/\r
-{\r
-  INT32 Index;\r
-\r
-  for (Index = 0; mSrc < mSrcUpperLimit && Index < Number; Index++) {\r
-    *Pointer++ = *mSrc++;\r
-  }\r
-\r
-  Number = Index;\r
-\r
-  Pointer -= Number;\r
-  mOrigSize += Number;\r
-  Index--;\r
-  while (Index >= 0) {\r
-    UPDATE_CRC (*Pointer++);\r
-    Index--;\r
-  }\r
-\r
-  return Number;\r
-}\r
-\r
-STATIC\r
-VOID\r
-InitPutBits (\r
-  VOID\r
-  )\r
-{\r
-  mBitCount   = UINT8_BIT;\r
-  mSubBitBuf  = 0;\r
-}\r
-\r
-STATIC\r
-VOID\r
-CountLen (\r
-  IN INT32 Index\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Count the number of each code length for a Huffman tree.\r
-  \r
-Arguments:\r
-\r
-  Index   - the top node\r
-  \r
-Returns: (VOID)\r
-\r
---*/\r
-{\r
-  static INT32  Depth = 0;\r
-\r
-  if (Index < mN) {\r
-    mLenCnt[(Depth < 16) ? Depth : 16]++;\r
-  } else {\r
-    Depth++;\r
-    CountLen (mLeft[Index]);\r
-    CountLen (mRight[Index]);\r
-    Depth--;\r
-  }\r
-}\r
-\r
-STATIC\r
-VOID\r
-MakeLen (\r
-  IN INT32 Root\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Create code length array for a Huffman tree\r
-  \r
-Arguments:\r
-\r
-  Root   - the root of the tree\r
-  \r
-Returns:\r
-\r
-  VOID\r
-\r
---*/\r
-{\r
-  INT32   Index;\r
-  INT32   Index3;\r
-  UINT32  Cum;\r
-\r
-  for (Index = 0; Index <= 16; Index++) {\r
-    mLenCnt[Index] = 0;\r
-  }\r
-\r
-  CountLen (Root);\r
-\r
-  //\r
-  // Adjust the length count array so that\r
-  // no code will be generated longer than its designated length\r
-  //\r
-  Cum = 0;\r
-  for (Index = 16; Index > 0; Index--) {\r
-    Cum += mLenCnt[Index] << (16 - Index);\r
-  }\r
-\r
-  while (Cum != (1U << 16)) {\r
-    mLenCnt[16]--;\r
-    for (Index = 15; Index > 0; Index--) {\r
-      if (mLenCnt[Index] != 0) {\r
-        mLenCnt[Index]--;\r
-        mLenCnt[Index + 1] += 2;\r
-        break;\r
-      }\r
-    }\r
-\r
-    Cum--;\r
-  }\r
-\r
-  for (Index = 16; Index > 0; Index--) {\r
-    Index3 = mLenCnt[Index];\r
-    Index3--;\r
-    while (Index3 >= 0) {\r
-      mLen[*mSortPtr++] = (UINT8) Index;\r
-      Index3--;\r
-    }\r
-  }\r
-}\r
-\r
-STATIC\r
-VOID\r
-DownHeap (\r
-  IN INT32 Index\r
-  )\r
-{\r
-  INT32 Index2;\r
-  INT32 Index3;\r
-\r
-  //\r
-  // priority queue: send Index-th entry down heap\r
-  //\r
-  Index3  = mHeap[Index];\r
-  Index2  = 2 * Index;\r
-  while (Index2 <= mHeapSize) {\r
-    if (Index2 < mHeapSize && mFreq[mHeap[Index2]] > mFreq[mHeap[Index2 + 1]]) {\r
-      Index2++;\r
-    }\r
-\r
-    if (mFreq[Index3] <= mFreq[mHeap[Index2]]) {\r
-      break;\r
-    }\r
-\r
-    mHeap[Index]  = mHeap[Index2];\r
-    Index         = Index2;\r
-    Index2        = 2 * Index;\r
-  }\r
-\r
-  mHeap[Index] = (INT16) Index3;\r
-}\r
-\r
-STATIC\r
-VOID\r
-MakeCode (\r
-  IN  INT32       Number,\r
-  IN  UINT8 Len[  ],\r
-  OUT UINT16 Code[]\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Assign code to each symbol based on the code length array\r
-  \r
-Arguments:\r
-\r
-  Number     - number of symbols\r
-  Len   - the code length array\r
-  Code  - stores codes for each symbol\r
-\r
-Returns: (VOID)\r
-\r
---*/\r
-{\r
-  INT32   Index;\r
-  UINT16  Start[18];\r
-\r
-  Start[1] = 0;\r
-  for (Index = 1; Index <= 16; Index++) {\r
-    Start[Index + 1] = (UINT16) ((Start[Index] + mLenCnt[Index]) << 1);\r
-  }\r
-\r
-  for (Index = 0; Index < Number; Index++) {\r
-    Code[Index] = Start[Len[Index]]++;\r
-  }\r
-}\r
-\r
-STATIC\r
-INT32\r
-MakeTree (\r
-  IN  INT32            NParm,\r
-  IN  UINT16  FreqParm[],\r
-  OUT UINT8   LenParm[ ],\r
-  OUT UINT16  CodeParm[]\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Generates Huffman codes given a frequency distribution of symbols\r
-  \r
-Arguments:\r
-\r
-  NParm    - number of symbols\r
-  FreqParm - frequency of each symbol\r
-  LenParm  - code length for each symbol\r
-  CodeParm - code for each symbol\r
-  \r
-Returns:\r
-\r
-  Root of the Huffman tree.\r
-  \r
---*/\r
-{\r
-  INT32 Index;\r
-  INT32 Index2;\r
-  INT32 Index3;\r
-  INT32 Avail;\r
-\r
-  //\r
-  // make tree, calculate len[], return root\r
-  //\r
-  mN        = NParm;\r
-  mFreq     = FreqParm;\r
-  mLen      = LenParm;\r
-  Avail     = mN;\r
-  mHeapSize = 0;\r
-  mHeap[1]  = 0;\r
-  for (Index = 0; Index < mN; Index++) {\r
-    mLen[Index] = 0;\r
-    if (mFreq[Index]) {\r
-      mHeapSize++;\r
-      mHeap[mHeapSize] = (INT16) Index;\r
-    }\r
-  }\r
-\r
-  if (mHeapSize < 2) {\r
-    CodeParm[mHeap[1]] = 0;\r
-    return mHeap[1];\r
-  }\r
-\r
-  for (Index = mHeapSize / 2; Index >= 1; Index--) {\r
-    //\r
-    // make priority queue\r
-    //\r
-    DownHeap (Index);\r
-  }\r
-\r
-  mSortPtr = CodeParm;\r
-  do {\r
-    Index = mHeap[1];\r
-    if (Index < mN) {\r
-      *mSortPtr++ = (UINT16) Index;\r
-    }\r
-\r
-    mHeap[1] = mHeap[mHeapSize--];\r
-    DownHeap (1);\r
-    Index2 = mHeap[1];\r
-    if (Index2 < mN) {\r
-      *mSortPtr++ = (UINT16) Index2;\r
-    }\r
-\r
-    Index3        = Avail++;\r
-    mFreq[Index3] = (UINT16) (mFreq[Index] + mFreq[Index2]);\r
-    mHeap[1]      = (INT16) Index3;\r
-    DownHeap (1);\r
-    mLeft[Index3]   = (UINT16) Index;\r
-    mRight[Index3]  = (UINT16) Index2;\r
-  } while (mHeapSize > 1);\r
-\r
-  mSortPtr = CodeParm;\r
-  MakeLen (Index3);\r
-  MakeCode (NParm, LenParm, CodeParm);\r
-\r
-  //\r
-  // return root\r
-  //\r
-  return Index3;\r
-}\r
diff --git a/Tools/CodeTools/TianoTools/Common/EfiCompress.h b/Tools/CodeTools/TianoTools/Common/EfiCompress.h
deleted file mode 100644 (file)
index 6ad80e4..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2004, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-Module Name:\r
-\r
-  EfiCompress.h\r
-\r
-Abstract:\r
-\r
-  Header file for compression routine\r
-  \r
---*/\r
-\r
-#ifndef _EFICOMPRESS_H\r
-#define _EFICOMPRESS_H\r
-\r
-#include <string.h>\r
-#include <stdlib.h>\r
-\r
-#include <Common/UefiBaseTypes.h>\r
-\r
-EFI_STATUS\r
-Compress (\r
-  IN      UINT8   *SrcBuffer,\r
-  IN      UINT32  SrcSize,\r
-  IN      UINT8   *DstBuffer,\r
-  IN OUT  UINT32  *DstSize\r
-  )\r
-;\r
-\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  The compression routine.\r
-\r
-Arguments:\r
-\r
-  SrcBuffer   - The buffer storing the source data\r
-  SrcSize     - The size of source data\r
-  DstBuffer   - The buffer to store the compressed data\r
-  DstSize     - On input, the size of DstBuffer; On output,\r
-                the size of the actual compressed data.\r
-\r
-Returns:\r
-\r
-  EFI_BUFFER_TOO_SMALL  - The DstBuffer is too small. In this case,\r
-                DstSize contains the size needed.\r
-  EFI_SUCCESS           - Compression is successful.\r
-\r
---*/\r
-typedef\r
-EFI_STATUS\r
-(*COMPRESS_FUNCTION) (\r
-  IN      UINT8   *SrcBuffer,\r
-  IN      UINT32  SrcSize,\r
-  IN      UINT8   *DstBuffer,\r
-  IN OUT  UINT32  *DstSize\r
-  );\r
-\r
-#endif\r
diff --git a/Tools/CodeTools/TianoTools/Common/EfiCustomizedCompress.h b/Tools/CodeTools/TianoTools/Common/EfiCustomizedCompress.h
deleted file mode 100644 (file)
index af26b6f..0000000
+++ /dev/null
@@ -1,141 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2004, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-Module Name:\r
-  \r
-  EfiCustomizedCompress.h\r
-\r
-Abstract:\r
-\r
-  Header file for Customized compression routine\r
-  \r
---*/\r
-\r
-#ifndef _EFICUSTOMIZEDCOMPRESS_H\r
-#define _EFICUSTOMIZEDCOMPRESS_H\r
-\r
-#include <Common/UefiBaseTypes.h>\r
-\r
-EFI_STATUS\r
-SetCustomizedCompressionType (\r
-  IN  CHAR8   *Type\r
-  )\r
-;\r
-\r
-/*++\r
-\r
-Routine Description:\r
-\r
-The implementation of Customized SetCompressionType().\r
-\r
-Arguments:\r
-  Type        - The type if compression.\r
-    \r
-Returns:\r
-    \r
-  EFI_SUCCESS           - The type has been set.\r
-  EFI_UNSUPPORTED       - This type is unsupported.\r
-\r
-    \r
---*/\r
-EFI_STATUS\r
-CustomizedGetInfo (\r
-  IN      VOID    *Source,\r
-  IN      UINT32  SrcSize,\r
-  OUT     UINT32  *DstSize,\r
-  OUT     UINT32  *ScratchSize\r
-  )\r
-;\r
-\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  The implementation of Customized GetInfo().\r
-\r
-Arguments:\r
-\r
-  Source      - The source buffer containing the compressed data.\r
-  SrcSize     - The size of source buffer\r
-  DstSize     - The size of destination buffer.\r
-  ScratchSize - The size of scratch buffer.\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS           - The size of destination buffer and the size of scratch buffer are successull retrieved.\r
-  EFI_INVALID_PARAMETER - The source data is corrupted\r
-\r
---*/\r
-EFI_STATUS\r
-CustomizedDecompress (\r
-  IN      VOID    *Source,\r
-  IN      UINT32  SrcSize,\r
-  IN OUT  VOID    *Destination,\r
-  IN      UINT32  DstSize,\r
-  IN OUT  VOID    *Scratch,\r
-  IN      UINT32  ScratchSize\r
-  )\r
-;\r
-\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  The implementation of Customized Decompress().\r
-\r
-Arguments:\r
-\r
-  This        - The protocol instance pointer\r
-  Source      - The source buffer containing the compressed data.\r
-  SrcSize     - The size of source buffer\r
-  Destination - The destination buffer to store the decompressed data\r
-  DstSize     - The size of destination buffer.\r
-  Scratch     - The buffer used internally by the decompress routine. This  buffer is needed to store intermediate data.\r
-  ScratchSize - The size of scratch buffer.\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS           - Decompression is successfull\r
-  EFI_INVALID_PARAMETER - The source data is corrupted\r
-\r
---*/\r
-EFI_STATUS\r
-CustomizedCompress (\r
-  IN      UINT8   *SrcBuffer,\r
-  IN      UINT32  SrcSize,\r
-  IN      UINT8   *DstBuffer,\r
-  IN OUT  UINT32  *DstSize\r
-  )\r
-;\r
-\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  The Customized compression routine.\r
-\r
-Arguments:\r
-\r
-  SrcBuffer   - The buffer storing the source data\r
-  SrcSize     - The size of source data\r
-  DstBuffer   - The buffer to store the compressed data\r
-  DstSize     - On input, the size of DstBuffer; On output,\r
-                the size of the actual compressed data.\r
-\r
-Returns:\r
-\r
-  EFI_BUFFER_TOO_SMALL  - The DstBuffer is too small. In this case,\r
-                          DstSize contains the size needed.\r
-  EFI_SUCCESS           - Compression is successful.\r
-\r
---*/\r
-\r
-#endif\r
diff --git a/Tools/CodeTools/TianoTools/Common/EfiDecompress.c b/Tools/CodeTools/TianoTools/Common/EfiDecompress.c
deleted file mode 100644 (file)
index 288c425..0000000
+++ /dev/null
@@ -1,790 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2004, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-Module Name:\r
-  \r
-  EfiDecompress.c\r
-\r
-Abstract:\r
-\r
-  Decompressor. Algorithm Ported from OPSD code (Decomp.asm)\r
-  \r
---*/\r
-\r
-#include "EfiDecompress.h"\r
-\r
-//\r
-// Decompression algorithm begins here\r
-//\r
-#define BITBUFSIZ 32\r
-#define MAXMATCH  256\r
-#define THRESHOLD 3\r
-#define CODE_BIT  16\r
-#define BAD_TABLE - 1\r
-\r
-//\r
-// C: Char&Len Set; P: Position Set; T: exTra Set\r
-//\r
-#define NC    (0xff + MAXMATCH + 2 - THRESHOLD)\r
-#define CBIT  9\r
-#define PBIT  5\r
-#define TBIT  5\r
-#define MAXNP ((1U << PBIT) - 1)\r
-#define NT    (CODE_BIT + 3)\r
-#if NT > MAXNP\r
-#define NPT NT\r
-#else\r
-#define NPT MAXNP\r
-#endif\r
-\r
-typedef struct {\r
-  UINT8   *mSrcBase;  // Starting address of compressed data\r
-  UINT8   *mDstBase;  // Starting address of decompressed data\r
-  UINT32  mOutBuf;\r
-  UINT32  mInBuf;\r
-\r
-  UINT16  mBitCount;\r
-  UINT32  mBitBuf;\r
-  UINT32  mSubBitBuf;\r
-  UINT16  mBlockSize;\r
-  UINT32  mCompSize;\r
-  UINT32  mOrigSize;\r
-\r
-  UINT16  mBadTableFlag;\r
-\r
-  UINT16  mLeft[2 * NC - 1];\r
-  UINT16  mRight[2 * NC - 1];\r
-  UINT8   mCLen[NC];\r
-  UINT8   mPTLen[NPT];\r
-  UINT16  mCTable[4096];\r
-  UINT16  mPTTable[256];\r
-} SCRATCH_DATA;\r
-\r
-STATIC\r
-VOID\r
-FillBuf (\r
-  IN  SCRATCH_DATA  *Sd,\r
-  IN  UINT16        NumOfBits\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Shift mBitBuf NumOfBits left. Read in NumOfBits of bits from source.\r
-\r
-Arguments:\r
-\r
-  Sd        - The global scratch data\r
-  NumOfBit  - The number of bits to shift and read.\r
-\r
-Returns: (VOID)\r
-\r
---*/\r
-{\r
-  Sd->mBitBuf = (UINT32) (Sd->mBitBuf << NumOfBits);\r
-\r
-  while (NumOfBits > Sd->mBitCount) {\r
-\r
-    Sd->mBitBuf |= (UINT32) (Sd->mSubBitBuf << (NumOfBits = (UINT16) (NumOfBits - Sd->mBitCount)));\r
-\r
-    if (Sd->mCompSize > 0) {\r
-      //\r
-      // Get 1 byte into SubBitBuf\r
-      //\r
-      Sd->mCompSize--;\r
-      Sd->mSubBitBuf  = 0;\r
-      Sd->mSubBitBuf  = Sd->mSrcBase[Sd->mInBuf++];\r
-      Sd->mBitCount   = 8;\r
-\r
-    } else {\r
-      //\r
-      // No more bits from the source, just pad zero bit.\r
-      //\r
-      Sd->mSubBitBuf  = 0;\r
-      Sd->mBitCount   = 8;\r
-\r
-    }\r
-  }\r
-\r
-  Sd->mBitCount = (UINT16) (Sd->mBitCount - NumOfBits);\r
-  Sd->mBitBuf |= Sd->mSubBitBuf >> Sd->mBitCount;\r
-}\r
-\r
-STATIC\r
-UINT32\r
-GetBits (\r
-  IN  SCRATCH_DATA  *Sd,\r
-  IN  UINT16        NumOfBits\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Get NumOfBits of bits out from mBitBuf. Fill mBitBuf with subsequent \r
-  NumOfBits of bits from source. Returns NumOfBits of bits that are \r
-  popped out.\r
-\r
-Arguments:\r
-\r
-  Sd            - The global scratch data.\r
-  NumOfBits     - The number of bits to pop and read.\r
-\r
-Returns:\r
-\r
-  The bits that are popped out.\r
-\r
---*/\r
-{\r
-  UINT32  OutBits;\r
-\r
-  OutBits = (UINT32) (Sd->mBitBuf >> (BITBUFSIZ - NumOfBits));\r
-\r
-  FillBuf (Sd, NumOfBits);\r
-\r
-  return OutBits;\r
-}\r
-\r
-STATIC\r
-UINT16\r
-MakeTable (\r
-  IN  SCRATCH_DATA  *Sd,\r
-  IN  UINT16        NumOfChar,\r
-  IN  UINT8         *BitLen,\r
-  IN  UINT16        TableBits,\r
-  OUT UINT16        *Table\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Creates Huffman Code mapping table according to code length array.\r
-\r
-Arguments:\r
-\r
-  Sd        - The global scratch data\r
-  NumOfChar - Number of symbols in the symbol set\r
-  BitLen    - Code length array\r
-  TableBits - The width of the mapping table\r
-  Table     - The table\r
-  \r
-Returns:\r
-  \r
-  0         - OK.\r
-  BAD_TABLE - The table is corrupted.\r
-\r
---*/\r
-{\r
-  UINT16  Count[17];\r
-  UINT16  Weight[17];\r
-  UINT16  Start[18];\r
-  UINT16  *Pointer;\r
-  UINT16  Index3;\r
-  UINT16  Index;\r
-  UINT16  Len;\r
-  UINT16  Char;\r
-  UINT16  JuBits;\r
-  UINT16  Avail;\r
-  UINT16  NextCode;\r
-  UINT16  Mask;\r
-\r
-  for (Index = 1; Index <= 16; Index++) {\r
-    Count[Index] = 0;\r
-  }\r
-\r
-  for (Index = 0; Index < NumOfChar; Index++) {\r
-    Count[BitLen[Index]]++;\r
-  }\r
-\r
-  Start[1] = 0;\r
-\r
-  for (Index = 1; Index <= 16; Index++) {\r
-    Start[Index + 1] = (UINT16) (Start[Index] + (Count[Index] << (16 - Index)));\r
-  }\r
-\r
-  if (Start[17] != 0) {\r
-    /*(1U << 16)*/\r
-    return (UINT16) BAD_TABLE;\r
-  }\r
-\r
-  JuBits = (UINT16) (16 - TableBits);\r
-\r
-  for (Index = 1; Index <= TableBits; Index++) {\r
-    Start[Index] >>= JuBits;\r
-    Weight[Index] = (UINT16) (1U << (TableBits - Index));\r
-  }\r
-\r
-  while (Index <= 16) {\r
-    Weight[Index++] = (UINT16) (1U << (16 - Index));\r
-  }\r
-\r
-  Index = (UINT16) (Start[TableBits + 1] >> JuBits);\r
-\r
-  if (Index != 0) {\r
-    Index3 = (UINT16) (1U << TableBits);\r
-    while (Index != Index3) {\r
-      Table[Index++] = 0;\r
-    }\r
-  }\r
-\r
-  Avail = NumOfChar;\r
-  Mask  = (UINT16) (1U << (15 - TableBits));\r
-\r
-  for (Char = 0; Char < NumOfChar; Char++) {\r
-\r
-    Len = BitLen[Char];\r
-    if (Len == 0) {\r
-      continue;\r
-    }\r
-\r
-    NextCode = (UINT16) (Start[Len] + Weight[Len]);\r
-\r
-    if (Len <= TableBits) {\r
-\r
-      for (Index = Start[Len]; Index < NextCode; Index++) {\r
-        Table[Index] = Char;\r
-      }\r
-\r
-    } else {\r
-\r
-      Index3  = Start[Len];\r
-      Pointer = &Table[Index3 >> JuBits];\r
-      Index   = (UINT16) (Len - TableBits);\r
-\r
-      while (Index != 0) {\r
-        if (*Pointer == 0) {\r
-          Sd->mRight[Avail]                     = Sd->mLeft[Avail] = 0;\r
-          *Pointer = Avail++;\r
-        }\r
-\r
-        if (Index3 & Mask) {\r
-          Pointer = &Sd->mRight[*Pointer];\r
-        } else {\r
-          Pointer = &Sd->mLeft[*Pointer];\r
-        }\r
-\r
-        Index3 <<= 1;\r
-        Index--;\r
-      }\r
-\r
-      *Pointer = Char;\r
-\r
-    }\r
-\r
-    Start[Len] = NextCode;\r
-  }\r
-  //\r
-  // Succeeds\r
-  //\r
-  return 0;\r
-}\r
-\r
-STATIC\r
-UINT32\r
-DecodeP (\r
-  IN  SCRATCH_DATA  *Sd\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Decodes a position value.\r
-\r
-Arguments:\r
-\r
-  Sd      - the global scratch data\r
-\r
-Returns:\r
-\r
-  The position value decoded.\r
-\r
---*/\r
-{\r
-  UINT16  Val;\r
-  UINT32  Mask;\r
-  UINT32  Pos;\r
-\r
-  Val = Sd->mPTTable[Sd->mBitBuf >> (BITBUFSIZ - 8)];\r
-\r
-  if (Val >= MAXNP) {\r
-    Mask = 1U << (BITBUFSIZ - 1 - 8);\r
-\r
-    do {\r
-\r
-      if (Sd->mBitBuf & Mask) {\r
-        Val = Sd->mRight[Val];\r
-      } else {\r
-        Val = Sd->mLeft[Val];\r
-      }\r
-\r
-      Mask >>= 1;\r
-    } while (Val >= MAXNP);\r
-  }\r
-  //\r
-  // Advance what we have read\r
-  //\r
-  FillBuf (Sd, Sd->mPTLen[Val]);\r
-\r
-  Pos = Val;\r
-  if (Val > 1) {\r
-    Pos = (UINT32) ((1U << (Val - 1)) + GetBits (Sd, (UINT16) (Val - 1)));\r
-  }\r
-\r
-  return Pos;\r
-}\r
-\r
-STATIC\r
-UINT16\r
-ReadPTLen (\r
-  IN  SCRATCH_DATA  *Sd,\r
-  IN  UINT16        nn,\r
-  IN  UINT16        nbit,\r
-  IN  UINT16        Special\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Reads code lengths for the Extra Set or the Position Set\r
-\r
-Arguments:\r
-\r
-  Sd        - The global scratch data\r
-  nn        - Number of symbols\r
-  nbit      - Number of bits needed to represent nn\r
-  Special   - The special symbol that needs to be taken care of \r
-\r
-Returns:\r
-\r
-  0         - OK.\r
-  BAD_TABLE - Table is corrupted.\r
-\r
---*/\r
-{\r
-  UINT16  Number;\r
-  UINT16  CharC;\r
-  UINT16  Index;\r
-  UINT32  Mask;\r
-\r
-  Number = (UINT16) GetBits (Sd, nbit);\r
-\r
-  if (Number == 0) {\r
-    CharC = (UINT16) GetBits (Sd, nbit);\r
-\r
-    for (Index = 0; Index < 256; Index++) {\r
-      Sd->mPTTable[Index] = CharC;\r
-    }\r
-\r
-    for (Index = 0; Index < nn; Index++) {\r
-      Sd->mPTLen[Index] = 0;\r
-    }\r
-\r
-    return 0;\r
-  }\r
-\r
-  Index = 0;\r
-\r
-  while (Index < Number) {\r
-\r
-    CharC = (UINT16) (Sd->mBitBuf >> (BITBUFSIZ - 3));\r
-\r
-    if (CharC == 7) {\r
-      Mask = 1U << (BITBUFSIZ - 1 - 3);\r
-      while (Mask & Sd->mBitBuf) {\r
-        Mask >>= 1;\r
-        CharC += 1;\r
-      }\r
-    }\r
-\r
-    FillBuf (Sd, (UINT16) ((CharC < 7) ? 3 : CharC - 3));\r
-\r
-    Sd->mPTLen[Index++] = (UINT8) CharC;\r
-\r
-    if (Index == Special) {\r
-      CharC = (UINT16) GetBits (Sd, 2);\r
-      CharC--;\r
-      while ((INT16) (CharC) >= 0) {\r
-        Sd->mPTLen[Index++] = 0;\r
-        CharC--;\r
-      }\r
-    }\r
-  }\r
-\r
-  while (Index < nn) {\r
-    Sd->mPTLen[Index++] = 0;\r
-  }\r
-\r
-  return MakeTable (Sd, nn, Sd->mPTLen, 8, Sd->mPTTable);\r
-}\r
-\r
-STATIC\r
-VOID\r
-ReadCLen (\r
-  SCRATCH_DATA  *Sd\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Reads code lengths for Char&Len Set.\r
-\r
-Arguments:\r
-\r
-  Sd    - the global scratch data\r
-\r
-Returns: (VOID)\r
-\r
---*/\r
-{\r
-  UINT16  Number;\r
-  UINT16  CharC;\r
-  UINT16  Index;\r
-  UINT32  Mask;\r
-\r
-  Number = (UINT16) GetBits (Sd, CBIT);\r
-\r
-  if (Number == 0) {\r
-    CharC = (UINT16) GetBits (Sd, CBIT);\r
-\r
-    for (Index = 0; Index < NC; Index++) {\r
-      Sd->mCLen[Index] = 0;\r
-    }\r
-\r
-    for (Index = 0; Index < 4096; Index++) {\r
-      Sd->mCTable[Index] = CharC;\r
-    }\r
-\r
-    return ;\r
-  }\r
-\r
-  Index = 0;\r
-  while (Index < Number) {\r
-\r
-    CharC = Sd->mPTTable[Sd->mBitBuf >> (BITBUFSIZ - 8)];\r
-    if (CharC >= NT) {\r
-      Mask = 1U << (BITBUFSIZ - 1 - 8);\r
-\r
-      do {\r
-\r
-        if (Mask & Sd->mBitBuf) {\r
-          CharC = Sd->mRight[CharC];\r
-        } else {\r
-          CharC = Sd->mLeft[CharC];\r
-        }\r
-\r
-        Mask >>= 1;\r
-\r
-      } while (CharC >= NT);\r
-    }\r
-    //\r
-    // Advance what we have read\r
-    //\r
-    FillBuf (Sd, Sd->mPTLen[CharC]);\r
-\r
-    if (CharC <= 2) {\r
-\r
-      if (CharC == 0) {\r
-        CharC = 1;\r
-      } else if (CharC == 1) {\r
-        CharC = (UINT16) (GetBits (Sd, 4) + 3);\r
-      } else if (CharC == 2) {\r
-        CharC = (UINT16) (GetBits (Sd, CBIT) + 20);\r
-      }\r
-\r
-      CharC--;\r
-      while ((INT16) (CharC) >= 0) {\r
-        Sd->mCLen[Index++] = 0;\r
-        CharC--;\r
-      }\r
-\r
-    } else {\r
-\r
-      Sd->mCLen[Index++] = (UINT8) (CharC - 2);\r
-\r
-    }\r
-  }\r
-\r
-  while (Index < NC) {\r
-    Sd->mCLen[Index++] = 0;\r
-  }\r
-\r
-  MakeTable (Sd, NC, Sd->mCLen, 12, Sd->mCTable);\r
-\r
-  return ;\r
-}\r
-\r
-STATIC\r
-UINT16\r
-DecodeC (\r
-  SCRATCH_DATA  *Sd\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Decode a character/length value.\r
-\r
-Arguments:\r
-\r
-  Sd    - The global scratch data.\r
-\r
-Returns:\r
-\r
-  The value decoded.\r
-\r
---*/\r
-{\r
-  UINT16  Index2;\r
-  UINT32  Mask;\r
-\r
-  if (Sd->mBlockSize == 0) {\r
-    //\r
-    // Starting a new block\r
-    //\r
-    Sd->mBlockSize    = (UINT16) GetBits (Sd, 16);\r
-    Sd->mBadTableFlag = ReadPTLen (Sd, NT, TBIT, 3);\r
-    if (Sd->mBadTableFlag != 0) {\r
-      return 0;\r
-    }\r
-\r
-    ReadCLen (Sd);\r
-\r
-    Sd->mBadTableFlag = ReadPTLen (Sd, MAXNP, PBIT, (UINT16) (-1));\r
-    if (Sd->mBadTableFlag != 0) {\r
-      return 0;\r
-    }\r
-  }\r
-\r
-  Sd->mBlockSize--;\r
-  Index2 = Sd->mCTable[Sd->mBitBuf >> (BITBUFSIZ - 12)];\r
-\r
-  if (Index2 >= NC) {\r
-    Mask = 1U << (BITBUFSIZ - 1 - 12);\r
-\r
-    do {\r
-      if (Sd->mBitBuf & Mask) {\r
-        Index2 = Sd->mRight[Index2];\r
-      } else {\r
-        Index2 = Sd->mLeft[Index2];\r
-      }\r
-\r
-      Mask >>= 1;\r
-    } while (Index2 >= NC);\r
-  }\r
-  //\r
-  // Advance what we have read\r
-  //\r
-  FillBuf (Sd, Sd->mCLen[Index2]);\r
-\r
-  return Index2;\r
-}\r
-\r
-STATIC\r
-VOID\r
-Decode (\r
-  SCRATCH_DATA  *Sd\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Decode the source data and put the resulting data into the destination buffer.\r
-\r
-Arguments:\r
-\r
-  Sd            - The global scratch data\r
-\r
-Returns: (VOID)\r
-\r
- --*/\r
-{\r
-  UINT16  BytesRemain;\r
-  UINT32  DataIdx;\r
-  UINT16  CharC;\r
-\r
-  BytesRemain = (UINT16) (-1);\r
-\r
-  DataIdx     = 0;\r
-\r
-  for (;;) {\r
-    CharC = DecodeC (Sd);\r
-    if (Sd->mBadTableFlag != 0) {\r
-      return ;\r
-    }\r
-\r
-    if (CharC < 256) {\r
-      //\r
-      // Process an Original character\r
-      //\r
-      Sd->mDstBase[Sd->mOutBuf++] = (UINT8) CharC;\r
-      if (Sd->mOutBuf >= Sd->mOrigSize) {\r
-        return ;\r
-      }\r
-\r
-    } else {\r
-      //\r
-      // Process a Pointer\r
-      //\r
-      CharC       = (UINT16) (CharC - (UINT8_MAX + 1 - THRESHOLD));\r
-\r
-      BytesRemain = CharC;\r
-\r
-      DataIdx     = Sd->mOutBuf - DecodeP (Sd) - 1;\r
-\r
-      BytesRemain--;\r
-      while ((INT16) (BytesRemain) >= 0) {\r
-        Sd->mDstBase[Sd->mOutBuf++] = Sd->mDstBase[DataIdx++];\r
-        if (Sd->mOutBuf >= Sd->mOrigSize) {\r
-          return ;\r
-        }\r
-\r
-        BytesRemain--;\r
-      }\r
-    }\r
-  }\r
-\r
-  return ;\r
-}\r
-\r
-EFI_STATUS\r
-GetInfo (\r
-  IN      VOID    *Source,\r
-  IN      UINT32  SrcSize,\r
-  OUT     UINT32  *DstSize,\r
-  OUT     UINT32  *ScratchSize\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  The implementation of EFI_DECOMPRESS_PROTOCOL.GetInfo().\r
-\r
-Arguments:\r
-\r
-  Source      - The source buffer containing the compressed data.\r
-  SrcSize     - The size of source buffer\r
-  DstSize     - The size of destination buffer.\r
-  ScratchSize - The size of scratch buffer.\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS           - The size of destination buffer and the size of scratch buffer are successull retrieved.\r
-  EFI_INVALID_PARAMETER - The source data is corrupted\r
-\r
---*/\r
-{\r
-  UINT8 *Src;\r
-\r
-  *ScratchSize  = sizeof (SCRATCH_DATA);\r
-\r
-  Src           = Source;\r
-  if (SrcSize < 8) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  *DstSize = Src[4] + (Src[5] << 8) + (Src[6] << 16) + (Src[7] << 24);\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-Decompress (\r
-  IN      VOID    *Source,\r
-  IN      UINT32  SrcSize,\r
-  IN OUT  VOID    *Destination,\r
-  IN      UINT32  DstSize,\r
-  IN OUT  VOID    *Scratch,\r
-  IN      UINT32  ScratchSize\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  The implementation of EFI_DECOMPRESS_PROTOCOL.Decompress().\r
-\r
-Arguments:\r
-\r
-  This        - The protocol instance pointer\r
-  Source      - The source buffer containing the compressed data.\r
-  SrcSize     - The size of source buffer\r
-  Destination - The destination buffer to store the decompressed data\r
-  DstSize     - The size of destination buffer.\r
-  Scratch     - The buffer used internally by the decompress routine. This  buffer is needed to store intermediate data.\r
-  ScratchSize - The size of scratch buffer.\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS           - Decompression is successfull\r
-  EFI_INVALID_PARAMETER - The source data is corrupted\r
-\r
---*/\r
-{\r
-  UINT32        Index;\r
-  UINT32        CompSize;\r
-  UINT32        OrigSize;\r
-  EFI_STATUS    Status;\r
-  SCRATCH_DATA  *Sd;\r
-  UINT8         *Src;\r
-  UINT8         *Dst;\r
-\r
-  Status  = EFI_SUCCESS;\r
-  Src     = Source;\r
-  Dst     = Destination;\r
-\r
-  if (ScratchSize < sizeof (SCRATCH_DATA)) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  Sd = (SCRATCH_DATA *) Scratch;\r
-\r
-  if (SrcSize < 8) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  CompSize  = Src[0] + (Src[1] << 8) + (Src[2] << 16) + (Src[3] << 24);\r
-  OrigSize  = Src[4] + (Src[5] << 8) + (Src[6] << 16) + (Src[7] << 24);\r
-\r
-  if (SrcSize < CompSize + 8) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if (DstSize != OrigSize) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  Src = Src + 8;\r
-\r
-  for (Index = 0; Index < sizeof (SCRATCH_DATA); Index++) {\r
-    ((UINT8 *) Sd)[Index] = 0;\r
-  }\r
-\r
-  Sd->mSrcBase  = Src;\r
-  Sd->mDstBase  = Dst;\r
-  Sd->mCompSize = CompSize;\r
-  Sd->mOrigSize = OrigSize;\r
-\r
-  //\r
-  // Fill the first BITBUFSIZ bits\r
-  //\r
-  FillBuf (Sd, BITBUFSIZ);\r
-\r
-  //\r
-  // Decompress it\r
-  //\r
-  Decode (Sd);\r
-\r
-  if (Sd->mBadTableFlag != 0) {\r
-    //\r
-    // Something wrong with the source\r
-    //\r
-    Status = EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  return Status;\r
-}\r
diff --git a/Tools/CodeTools/TianoTools/Common/EfiDecompress.h b/Tools/CodeTools/TianoTools/Common/EfiDecompress.h
deleted file mode 100644 (file)
index 3f82ac6..0000000
+++ /dev/null
@@ -1,106 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2004, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-Module Name:\r
-  \r
-  EfiDecompress.h\r
-\r
-Abstract:\r
-\r
-  Header file for compression routine\r
-  \r
---*/\r
-\r
-#ifndef _EFI_DECOMPRESS_H\r
-#define _EFI_DECOMPRESS_H\r
-\r
-#include <Common/UefiBaseTypes.h>\r
-\r
-EFI_STATUS\r
-GetInfo (\r
-  IN      VOID    *Source,\r
-  IN      UINT32  SrcSize,\r
-  OUT     UINT32  *DstSize,\r
-  OUT     UINT32  *ScratchSize\r
-  );\r
-\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  The implementation of EFI_DECOMPRESS_PROTOCOL.GetInfo().\r
-\r
-Arguments:\r
-\r
-  Source      - The source buffer containing the compressed data.\r
-  SrcSize     - The size of source buffer\r
-  DstSize     - The size of destination buffer.\r
-  ScratchSize - The size of scratch buffer.\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS           - The size of destination buffer and the size of scratch buffer are successull retrieved.\r
-  EFI_INVALID_PARAMETER - The source data is corrupted\r
-\r
---*/\r
-EFI_STATUS\r
-Decompress (\r
-  IN      VOID    *Source,\r
-  IN      UINT32  SrcSize,\r
-  IN OUT  VOID    *Destination,\r
-  IN      UINT32  DstSize,\r
-  IN OUT  VOID    *Scratch,\r
-  IN      UINT32  ScratchSize\r
-  )\r
-;\r
-\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  The implementation of EFI_DECOMPRESS_PROTOCOL.Decompress().\r
-\r
-Arguments:\r
-\r
-  This        - The protocol instance pointer\r
-  Source      - The source buffer containing the compressed data.\r
-  SrcSize     - The size of source buffer\r
-  Destination - The destination buffer to store the decompressed data\r
-  DstSize     - The size of destination buffer.\r
-  Scratch     - The buffer used internally by the decompress routine. This  buffer is needed to store intermediate data.\r
-  ScratchSize - The size of scratch buffer.\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS           - Decompression is successfull\r
-  EFI_INVALID_PARAMETER - The source data is corrupted\r
-\r
---*/\r
-typedef\r
-EFI_STATUS\r
-(*GETINFO_FUNCTION) (\r
-  IN      VOID    *Source,\r
-  IN      UINT32  SrcSize,\r
-  OUT     UINT32  *DstSize,\r
-  OUT     UINT32  *ScratchSize\r
-  );\r
-\r
-typedef\r
-EFI_STATUS\r
-(*DECOMPRESS_FUNCTION) (\r
-  IN      VOID    *Source,\r
-  IN      UINT32  SrcSize,\r
-  IN OUT  VOID    *Destination,\r
-  IN      UINT32  DstSize,\r
-  IN OUT  VOID    *Scratch,\r
-  IN      UINT32  ScratchSize\r
-  );\r
-#endif\r
diff --git a/Tools/CodeTools/TianoTools/Common/EfiUtilityMsgs.c b/Tools/CodeTools/TianoTools/Common/EfiUtilityMsgs.c
deleted file mode 100644 (file)
index 566d214..0000000
+++ /dev/null
@@ -1,755 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2004, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-Module Name:  \r
-\r
-  EfiUtilityMsgs.c\r
-  \r
-Abstract:\r
-\r
-  EFI tools utility functions to display warning, error, and informational\r
-  messages.\r
-  \r
---*/\r
-\r
-#include <stdio.h>\r
-#include <string.h>\r
-#include <ctype.h>\r
-#include <stdarg.h>\r
-\r
-#include "EfiUtilityMsgs.h"\r
-\r
-#define MAX_LINE_LEN  200\r
-\r
-//\r
-// Declare module globals for keeping track of the the utility's\r
-// name and other settings.\r
-//\r
-static STATUS mStatus                 = STATUS_SUCCESS;\r
-static CHAR8  mUtilityName[50]        = { 0 };\r
-static UINT32 mDebugMsgMask           = 0;\r
-static CHAR8  *mSourceFileName        = NULL;\r
-static UINT32 mSourceFileLineNum      = 0;\r
-static UINT32 mErrorCount             = 0;\r
-static UINT32 mWarningCount           = 0;\r
-static UINT32 mMaxErrors              = 0;\r
-static UINT32 mMaxWarnings            = 0;\r
-static UINT32 mMaxWarningsPlusErrors  = 0;\r
-static INT8   mPrintLimitsSet         = 0;\r
-\r
-static\r
-void\r
-PrintMessage (\r
-  CHAR8   *Type,\r
-  CHAR8   *FileName,\r
-  UINT32  LineNumber,\r
-  UINT32  MessageCode,\r
-  CHAR8   *Text,\r
-  CHAR8   *MsgFmt,\r
-  va_list List\r
-  );\r
-\r
-static\r
-void\r
-PrintLimitExceeded (\r
-  VOID\r
-  );\r
-\r
-void\r
-Error (\r
-  CHAR8   *FileName,\r
-  UINT32  LineNumber,\r
-  UINT32  MessageCode,\r
-  CHAR8   *Text,\r
-  CHAR8   *MsgFmt,\r
-  ...\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Prints an error message.\r
-  \r
-Arguments:\r
-  All arguments are optional, though the printed message may be useless if\r
-  at least something valid is not specified.\r
-  \r
-  FileName - name of the file or application. If not specified, then the\r
-             utilty name (as set by the utility calling SetUtilityName()\r
-             earlier) is used. Otherwise "Unknown utility" is used.\r
-  \r
-  LineNumber - the line number of error, typically used by parsers. If the\r
-               utility is not a parser, then 0 should be specified. Otherwise\r
-               the FileName and LineNumber info can be used to cause\r
-               MS Visual Studio to jump to the error.\r
-               \r
-  MessageCode - an application-specific error code that can be referenced in\r
-              other documentation. \r
-\r
-  Text        - the text in question, typically used by parsers.\r
-  \r
-  MsgFmt - the format string for the error message. Can contain formatting\r
-           controls for use with the varargs.\r
-           \r
-Returns:\r
-  None.\r
-  \r
-Notes:\r
-  We print the following (similar to the Warn() and Debug() \r
-  W\r
-  Typical error/warning message format:\r
-\r
-  bin\VfrCompile.cpp(330) : error C2660: 'AddVfrDataStructField' : function does not take 2 parameters\r
-\r
-  BUGBUG -- these three utility functions are almost identical, and\r
-  should be modified to share code.\r
-\r
-  Visual Studio does not find error messages with:\r
-  \r
-     " error :"\r
-     " error 1:"\r
-     " error c1:"\r
-     " error 1000:"\r
-     " error c100:"\r
-\r
-  It does find:\r
-     " error c1000:"     \r
---*/\r
-{\r
-  va_list List;\r
-  //\r
-  // If limits have been set, then check that we have not exceeded them\r
-  //\r
-  if (mPrintLimitsSet) {\r
-    //\r
-    // See if we've exceeded our total count\r
-    //\r
-    if (mMaxWarningsPlusErrors != 0) {\r
-      if (mErrorCount + mWarningCount > mMaxWarningsPlusErrors) {\r
-        PrintLimitExceeded ();\r
-        return ;\r
-      }\r
-    }\r
-    //\r
-    // See if we've exceeded our error count\r
-    //\r
-    if (mMaxErrors != 0) {\r
-      if (mErrorCount > mMaxErrors) {\r
-        PrintLimitExceeded ();\r
-        return ;\r
-      }\r
-    }\r
-  }\r
-\r
-  mErrorCount++;\r
-  va_start (List, MsgFmt);\r
-  PrintMessage ("error", FileName, LineNumber, MessageCode, Text, MsgFmt, List);\r
-  va_end (List);\r
-  //\r
-  // Set status accordingly\r
-  //\r
-  if (mStatus < STATUS_ERROR) {\r
-    mStatus = STATUS_ERROR;\r
-  }\r
-}\r
-\r
-void\r
-ParserError (\r
-  UINT32  MessageCode,\r
-  CHAR8   *Text,\r
-  CHAR8   *MsgFmt,\r
-  ...\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Print a parser error, using the source file name and line number\r
-  set by a previous call to SetParserPosition().\r
-\r
-Arguments:\r
-  MessageCode   - application-specific error code\r
-  Text          - text to print in the error message\r
-  MsgFmt        - format string to print at the end of the error message\r
-\r
-Returns:\r
-  NA\r
-\r
---*/\r
-{\r
-  va_list List;\r
-  //\r
-  // If limits have been set, then check them\r
-  //\r
-  if (mPrintLimitsSet) {\r
-    //\r
-    // See if we've exceeded our total count\r
-    //\r
-    if (mMaxWarningsPlusErrors != 0) {\r
-      if (mErrorCount + mWarningCount > mMaxWarningsPlusErrors) {\r
-        PrintLimitExceeded ();\r
-        return ;\r
-      }\r
-    }\r
-    //\r
-    // See if we've exceeded our error count\r
-    //\r
-    if (mMaxErrors != 0) {\r
-      if (mErrorCount > mMaxErrors) {\r
-        PrintLimitExceeded ();\r
-        return ;\r
-      }\r
-    }\r
-  }\r
-\r
-  mErrorCount++;\r
-  va_start (List, MsgFmt);\r
-  PrintMessage ("error", mSourceFileName, mSourceFileLineNum, MessageCode, Text, MsgFmt, List);\r
-  va_end (List);\r
-  //\r
-  // Set status accordingly\r
-  //\r
-  if (mStatus < STATUS_ERROR) {\r
-    mStatus = STATUS_ERROR;\r
-  }\r
-}\r
-\r
-void\r
-ParserWarning (\r
-  UINT32  ErrorCode,\r
-  CHAR8   *OffendingText,\r
-  CHAR8   *MsgFmt,\r
-  ...\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Print a parser warning, using the source file name and line number\r
-  set by a previous call to SetParserPosition().\r
-\r
-Arguments:\r
-  ErrorCode     - application-specific error code\r
-  OffendingText - text to print in the warning message\r
-  MsgFmt        - format string to print at the end of the warning message\r
-\r
-Returns:\r
-  NA\r
-\r
---*/\r
-{\r
-  va_list List;\r
-  //\r
-  // If limits have been set, then check them\r
-  //\r
-  if (mPrintLimitsSet) {\r
-    //\r
-    // See if we've exceeded our total count\r
-    //\r
-    if (mMaxWarningsPlusErrors != 0) {\r
-      if (mErrorCount + mWarningCount > mMaxWarningsPlusErrors) {\r
-        PrintLimitExceeded ();\r
-        return ;\r
-      }\r
-    }\r
-    //\r
-    // See if we've exceeded our warning count\r
-    //\r
-    if (mMaxWarnings != 0) {\r
-      if (mWarningCount > mMaxWarnings) {\r
-        PrintLimitExceeded ();\r
-        return ;\r
-      }\r
-    }\r
-  }\r
-\r
-  mWarningCount++;\r
-  va_start (List, MsgFmt);\r
-  PrintMessage ("warning", mSourceFileName, mSourceFileLineNum, ErrorCode, OffendingText, MsgFmt, List);\r
-  va_end (List);\r
-  //\r
-  // Set status accordingly\r
-  //\r
-  if (mStatus < STATUS_WARNING) {\r
-    mStatus = STATUS_WARNING;\r
-  }\r
-}\r
-\r
-void\r
-Warning (\r
-  CHAR8   *FileName,\r
-  UINT32  LineNumber,\r
-  UINT32  MessageCode,\r
-  CHAR8   *Text,\r
-  CHAR8   *MsgFmt,\r
-  ...\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Print a warning message.\r
-\r
-Arguments:\r
-  FileName    - name of the file where the warning was detected, or the name\r
-                of the application that detected the warning\r
-  \r
-  LineNumber  - the line number where the warning was detected (parsers).\r
-                0 should be specified if the utility is not a parser.\r
-               \r
-  MessageCode - an application-specific warning code that can be referenced in\r
-                other documentation. \r
-\r
-  Text        - the text in question (parsers)\r
-  \r
-  MsgFmt      - the format string for the warning message. Can contain formatting\r
-                controls for use with varargs.\r
-           \r
-Returns:\r
-  None.\r
-\r
---*/\r
-{\r
-  va_list List;\r
-  //\r
-  // If limits have been set, then check them\r
-  //\r
-  if (mPrintLimitsSet) {\r
-    //\r
-    // See if we've exceeded our total count\r
-    //\r
-    if (mMaxWarningsPlusErrors != 0) {\r
-      if (mErrorCount + mWarningCount > mMaxWarningsPlusErrors) {\r
-        PrintLimitExceeded ();\r
-        return ;\r
-      }\r
-    }\r
-    //\r
-    // See if we've exceeded our warning count\r
-    //\r
-    if (mMaxWarnings != 0) {\r
-      if (mWarningCount > mMaxWarnings) {\r
-        PrintLimitExceeded ();\r
-        return ;\r
-      }\r
-    }\r
-  }\r
-\r
-  mWarningCount++;\r
-  va_start (List, MsgFmt);\r
-  PrintMessage ("warning", FileName, LineNumber, MessageCode, Text, MsgFmt, List);\r
-  va_end (List);\r
-  //\r
-  // Set status accordingly\r
-  //\r
-  if (mStatus < STATUS_WARNING) {\r
-    mStatus = STATUS_WARNING;\r
-  }\r
-}\r
-\r
-void\r
-DebugMsg (\r
-  CHAR8   *FileName,\r
-  UINT32  LineNumber,\r
-  UINT32  MsgMask,\r
-  CHAR8   *Text,\r
-  CHAR8   *MsgFmt,\r
-  ...\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Print a warning message.\r
-\r
-Arguments:\r
-  FileName    - typically the name of the utility printing the debug message, but\r
-                can be the name of a file being parsed.\r
-  \r
-  LineNumber  - the line number in FileName (parsers) \r
-               \r
-  MsgMask     - an application-specific bitmask that, in combination with mDebugMsgMask,\r
-                determines if the debug message gets printed.\r
-\r
-  Text        - the text in question (parsers)\r
-  \r
-  MsgFmt      - the format string for the debug message. Can contain formatting\r
-                controls for use with varargs.\r
-           \r
-Returns:\r
-  None.\r
-\r
---*/\r
-{\r
-  va_list List;\r
-  //\r
-  // If the debug mask is not applicable, then do nothing.\r
-  //\r
-  if ((MsgMask != 0) && ((mDebugMsgMask & MsgMask) == 0)) {\r
-    return ;\r
-  }\r
-\r
-  va_start (List, MsgFmt);\r
-  PrintMessage ("debug", FileName, LineNumber, 0, Text, MsgFmt, List);\r
-  va_end (List);\r
-}\r
-\r
-static\r
-void\r
-PrintMessage (\r
-  CHAR8   *Type,\r
-  CHAR8   *FileName,\r
-  UINT32  LineNumber,\r
-  UINT32  MessageCode,\r
-  CHAR8   *Text,\r
-  CHAR8   *MsgFmt,\r
-  va_list List\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Worker routine for all the utility printing services. Prints the message in\r
-  a format that Visual Studio will find when scanning build outputs for\r
-  errors or warnings.\r
-\r
-Arguments:\r
-  Type        - "warning" or "error" string to insert into the message to be\r
-                printed. The first character of this string (converted to uppercase)\r
-                is used to preceed the MessageCode value in the output string.\r
-\r
-  FileName    - name of the file where the warning was detected, or the name\r
-                of the application that detected the warning\r
-  \r
-  LineNumber  - the line number where the warning was detected (parsers).\r
-                0 should be specified if the utility is not a parser.\r
-               \r
-  MessageCode - an application-specific warning code that can be referenced in\r
-                other documentation. \r
-\r
-  Text        - part of the message to print\r
-  \r
-  MsgFmt      - the format string for the message. Can contain formatting\r
-                controls for use with varargs.\r
-  List        - the variable list.\r
-           \r
-Returns:\r
-  None.\r
-\r
-Notes:\r
-  If FileName == NULL then this utility will use the string passed into SetUtilityName(). \r
-  \r
-  LineNumber is only used if the caller is a parser, in which case FileName refers to the\r
-  file being parsed.\r
-\r
-  Text and MsgFmt are both optional, though it would be of little use calling this function with\r
-  them both NULL.\r
-\r
-  Output will typically be of the form:\r
-    <FileName>(<LineNumber>) : <Type> <Type[0]><MessageCode>: <Text> : <MsgFmt>\r
-\r
-    Parser (LineNumber != 0)\r
-      VfrCompile.cpp(330) : error E2660: AddVfrDataStructField : function does not take 2 parameters\r
-    Generic utility (LineNumber == 0) \r
-      UtilityName : error E1234 : Text string : MsgFmt string and args\r
-\r
---*/\r
-{\r
-  CHAR8 Line[MAX_LINE_LEN];\r
-  CHAR8 Line2[MAX_LINE_LEN];\r
-  CHAR8 *Cptr;\r
-  //\r
-  // If given a filename, then add it (and the line number) to the string.\r
-  // If there's no filename, then use the program name if provided.\r
-  //\r
-  if (FileName != NULL) {\r
-    Cptr = FileName;\r
-  } else if (mUtilityName[0] != 0) {\r
-    Cptr = mUtilityName;\r
-  } else {\r
-    Cptr = "Unknown utility";\r
-  }\r
-\r
-  strcpy (Line, Cptr);\r
-  if (LineNumber != 0) {\r
-    sprintf (Line2, "(%d)", LineNumber);\r
-    strcat (Line, Line2);\r
-  }\r
-  //\r
-  // Have to print an error code or Visual Studio won't find the\r
-  // message for you. It has to be decimal digits too.\r
-  //\r
-  sprintf (Line2, " : %s %c%04d", Type, toupper (Type[0]), MessageCode);\r
-  strcat (Line, Line2);\r
-  fprintf (stdout, "%s", Line);\r
-  //\r
-  // If offending text was provided, then print it\r
-  //\r
-  if (Text != NULL) {\r
-    fprintf (stdout, ": %s ", Text);\r
-  }\r
-  //\r
-  // Print formatted message if provided\r
-  //\r
-  if (MsgFmt != NULL) {\r
-    vsprintf (Line2, MsgFmt, List);\r
-    fprintf (stdout, ": %s", Line2);\r
-  }\r
-\r
-  fprintf (stdout, "\n");\r
-}\r
-\r
-void\r
-ParserSetPosition (\r
-  CHAR8   *SourceFileName,\r
-  UINT32  LineNum\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Set the position in a file being parsed. This can be used to \r
-  print error messages deeper down in a parser.\r
-\r
-Arguments:\r
-  SourceFileName - name of the source file being parsed\r
-  LineNum        - line number of the source file being parsed\r
-\r
-Returns:\r
-  NA\r
-\r
---*/\r
-{\r
-  mSourceFileName     = SourceFileName;\r
-  mSourceFileLineNum  = LineNum;\r
-}\r
-\r
-void\r
-SetUtilityName (\r
-  CHAR8   *UtilityName\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  All printed error/warning/debug messages follow the same format, and\r
-  typically will print a filename or utility name followed by the error\r
-  text. However if a filename is not passed to the print routines, then\r
-  they'll print the utility name if you call this function early in your\r
-  app to set the utility name.\r
-  \r
-Arguments:\r
-  UtilityName  -  name of the utility, which will be printed with all\r
-                  error/warning/debug messags.\r
-\r
-Returns:\r
-  NA\r
-  \r
---*/\r
-{\r
-  //\r
-  // Save the name of the utility in our local variable. Make sure its\r
-  // length does not exceed our buffer.\r
-  //\r
-  if (UtilityName != NULL) {\r
-    if (strlen (UtilityName) >= sizeof (mUtilityName)) {\r
-      Error (UtilityName, 0, 0, "application error", "utility name length exceeds internal buffer size");\r
-      strncpy (mUtilityName, UtilityName, sizeof (mUtilityName) - 1);\r
-      mUtilityName[sizeof (mUtilityName) - 1] = 0;\r
-      return ;\r
-    } else {\r
-      strcpy (mUtilityName, UtilityName);\r
-    }\r
-  } else {\r
-    Error (NULL, 0, 0, "application error", "SetUtilityName() called with NULL utility name");\r
-  }\r
-}\r
-\r
-STATUS\r
-GetUtilityStatus (\r
-  VOID\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  When you call Error() or Warning(), this module keeps track of it and\r
-  sets a local mStatus to STATUS_ERROR or STATUS_WARNING. When the utility\r
-  exits, it can call this function to get the status and use it as a return\r
-  value.\r
-  \r
-Arguments:\r
-  None.\r
-\r
-Returns:\r
-  Worst-case status reported, as defined by which print function was called.\r
-  \r
---*/\r
-{\r
-  return mStatus;\r
-}\r
-\r
-void\r
-SetDebugMsgMask (\r
-  UINT32  DebugMask\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Set the debug printing mask. This is used by the DebugMsg() function\r
-  to determine when/if a debug message should be printed.\r
-\r
-Arguments:\r
-  DebugMask  - bitmask, specific to the calling application\r
-\r
-Returns:\r
-  NA\r
-\r
---*/\r
-{\r
-  mDebugMsgMask = DebugMask;\r
-}\r
-\r
-void\r
-SetPrintLimits (\r
-  UINT32  MaxErrors,\r
-  UINT32  MaxWarnings,\r
-  UINT32  MaxWarningsPlusErrors\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Set the limits of how many errors, warnings, and errors+warnings\r
-  we will print.\r
-\r
-Arguments:\r
-  MaxErrors       - maximum number of error messages to print\r
-  MaxWarnings     - maximum number of warning messages to print\r
-  MaxWarningsPlusErrors \r
-                  - maximum number of errors+warnings to print\r
-\r
-Returns:\r
-  NA\r
-\r
---*/\r
-{\r
-  mMaxErrors              = MaxErrors;\r
-  mMaxWarnings            = MaxWarnings;\r
-  mMaxWarningsPlusErrors  = MaxWarningsPlusErrors;\r
-  mPrintLimitsSet         = 1;\r
-}\r
-\r
-static\r
-void\r
-PrintLimitExceeded (\r
-  VOID\r
-  )\r
-{\r
-  static INT8 mPrintLimitExceeded = 0;\r
-  //\r
-  // If we've already printed the message, do nothing. Otherwise\r
-  // temporarily increase our print limits so we can pass one\r
-  // more message through.\r
-  //\r
-  if (mPrintLimitExceeded == 0) {\r
-    mPrintLimitExceeded++;\r
-    mMaxErrors++;\r
-    mMaxWarnings++;\r
-    mMaxWarningsPlusErrors++;\r
-    Error (NULL, 0, 0, "error/warning print limit exceeded", NULL);\r
-    mMaxErrors--;\r
-    mMaxWarnings--;\r
-    mMaxWarningsPlusErrors--;\r
-  }\r
-}\r
-\r
-#if 0\r
-void\r
-TestUtilityMessages (\r
-  VOID\r
-  )\r
-{\r
-  char *ArgStr = "ArgString";\r
-  int  ArgInt;\r
-\r
-  ArgInt  = 0x12345678;\r
-  //\r
-  // Test without setting utility name\r
-  //\r
-  fprintf (stdout, "* Testing without setting utility name\n");\r
-  fprintf (stdout, "** Test debug message not printed\n");\r
-  DebugMsg (NULL, 0, 0x00000001, NULL, NULL);\r
-  fprintf (stdout, "** Test warning with two strings and two args\n");\r
-  Warning (NULL, 0, 1234, "Text1", "Text2 %s 0x%X", ArgStr, ArgInt);\r
-  fprintf (stdout, "** Test error with two strings and two args\n");\r
-  Warning (NULL, 0, 1234, "Text1", "Text2 %s 0x%X", ArgStr, ArgInt);\r
-  fprintf (stdout, "** Test parser warning with nothing\n");\r
-  ParserWarning (0, NULL, NULL);\r
-  fprintf (stdout, "** Test parser error with nothing\n");\r
-  ParserError (0, NULL, NULL);\r
-  //\r
-  // Test with utility name set now\r
-  //\r
-  fprintf (stdout, "** Testingin with utility name set\n");\r
-  SetUtilityName ("MyUtilityName");\r
-  //\r
-  // Test debug prints\r
-  //\r
-  SetDebugMsgMask (2);\r
-  fprintf (stdout, "** Test debug message with one string\n");\r
-  DebugMsg (NULL, 0, 0x00000002, "Text1", NULL);\r
-  fprintf (stdout, "** Test debug message with one string\n");\r
-  DebugMsg (NULL, 0, 0x00000002, NULL, "Text2");\r
-  fprintf (stdout, "** Test debug message with two strings\n");\r
-  DebugMsg (NULL, 0, 0x00000002, "Text1", "Text2");\r
-  fprintf (stdout, "** Test debug message with two strings and two args\n");\r
-  DebugMsg (NULL, 0, 0x00000002, "Text1", "Text2 %s 0x%X", ArgStr, ArgInt);\r
-  //\r
-  // Test warning prints\r
-  //\r
-  fprintf (stdout, "** Test warning with no strings\n");\r
-  Warning (NULL, 0, 1234, NULL, NULL);\r
-  fprintf (stdout, "** Test warning with one string\n");\r
-  Warning (NULL, 0, 1234, "Text1", NULL);\r
-  fprintf (stdout, "** Test warning with one string\n");\r
-  Warning (NULL, 0, 1234, NULL, "Text2");\r
-  fprintf (stdout, "** Test warning with two strings and two args\n");\r
-  Warning (NULL, 0, 1234, "Text1", "Text2 %s 0x%X", ArgStr, ArgInt);\r
-  //\r
-  // Test error prints\r
-  //\r
-  fprintf (stdout, "** Test error with no strings\n");\r
-  Error (NULL, 0, 1234, NULL, NULL);\r
-  fprintf (stdout, "** Test error with one string\n");\r
-  Error (NULL, 0, 1234, "Text1", NULL);\r
-  fprintf (stdout, "** Test error with one string\n");\r
-  Error (NULL, 0, 1234, NULL, "Text2");\r
-  fprintf (stdout, "** Test error with two strings and two args\n");\r
-  Error (NULL, 0, 1234, "Text1", "Text2 %s 0x%X", ArgStr, ArgInt);\r
-  //\r
-  // Test parser prints\r
-  //\r
-  fprintf (stdout, "** Test parser errors\n");\r
-  ParserSetPosition (__FILE__, __LINE__ + 1);\r
-  ParserError (1234, NULL, NULL);\r
-  ParserSetPosition (__FILE__, __LINE__ + 1);\r
-  ParserError (1234, "Text1", NULL);\r
-  ParserSetPosition (__FILE__, __LINE__ + 1);\r
-  ParserError (1234, NULL, "Text2");\r
-  ParserSetPosition (__FILE__, __LINE__ + 1);\r
-  ParserError (1234, "Text1", "Text2");\r
-  ParserSetPosition (__FILE__, __LINE__ + 1);\r
-  ParserError (1234, "Text1", "Text2 %s 0x%X", ArgStr, ArgInt);\r
-\r
-  fprintf (stdout, "** Test parser warnings\n");\r
-  ParserSetPosition (__FILE__, __LINE__ + 1);\r
-  ParserWarning (4321, NULL, NULL);\r
-  ParserSetPosition (__FILE__, __LINE__ + 1);\r
-  ParserWarning (4321, "Text1", NULL);\r
-  ParserSetPosition (__FILE__, __LINE__ + 1);\r
-  ParserWarning (4321, NULL, "Text2");\r
-  ParserSetPosition (__FILE__, __LINE__ + 1);\r
-  ParserWarning (4321, "Text1", "Text2");\r
-  ParserSetPosition (__FILE__, __LINE__ + 1);\r
-  ParserWarning (4321, "Text1", "Text2 %s 0x%X", ArgStr, ArgInt);\r
-}\r
-#endif\r
diff --git a/Tools/CodeTools/TianoTools/Common/EfiUtilityMsgs.h b/Tools/CodeTools/TianoTools/Common/EfiUtilityMsgs.h
deleted file mode 100644 (file)
index a76b822..0000000
+++ /dev/null
@@ -1,137 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2004, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-Module Name:\r
-\r
-  EfiUtilityMsgs.h\r
-\r
-Abstract:\r
-\r
-  Defines and prototypes for common EFI utility error and debug messages.\r
-  \r
---*/\r
-\r
-#ifndef _EFI_UTILITY_MSGS_H_\r
-#define _EFI_UTILITY_MSGS_H_\r
-\r
-#include <Common/UefiBaseTypes.h>\r
-\r
-//\r
-// Status codes returned by EFI utility programs and functions\r
-//\r
-#define STATUS_SUCCESS  0\r
-#define STATUS_WARNING  1\r
-#define STATUS_ERROR    2\r
-#define VOID void \r
-\r
-typedef int STATUS;\r
-\r
-#ifdef __cplusplus\r
-extern "C" {\r
-#endif\r
-//\r
-// When we call Error() or Warning(), the module keeps track of the worst\r
-// case reported. GetUtilityStatus() will get the worst-case results, which\r
-// can be used as the return value from the app.\r
-//\r
-STATUS\r
-GetUtilityStatus (\r
-  void\r
-  );\r
-\r
-//\r
-// If someone prints an error message and didn't specify a source file name,\r
-// then we print the utility name instead. However they must tell us the\r
-// utility name early on via this function.\r
-//\r
-void\r
-SetUtilityName (\r
-  CHAR8 *ProgramName\r
-  )\r
-;\r
-\r
-void\r
-Error (\r
-  CHAR8   *FileName,\r
-  UINT32  LineNumber,\r
-  UINT32  ErrorCode,\r
-  CHAR8   *OffendingText,\r
-  CHAR8   *MsgFmt,\r
-  ...\r
-  )\r
-;\r
-\r
-void\r
-Warning (\r
-  CHAR8   *FileName,\r
-  UINT32  LineNumber,\r
-  UINT32  ErrorCode,\r
-  CHAR8   *OffendingText,\r
-  CHAR8   *MsgFmt,\r
-  ...\r
-  )\r
-;\r
-\r
-void\r
-DebugMsg (\r
-  CHAR8   *FileName,\r
-  UINT32  LineNumber,\r
-  UINT32  MsgLevel,\r
-  CHAR8   *OffendingText,\r
-  CHAR8   *MsgFmt,\r
-  ...\r
-  )\r
-;\r
-\r
-void\r
-SetDebugMsgMask (\r
-  UINT32    MsgMask\r
-  )\r
-;\r
-\r
-void\r
-ParserSetPosition (\r
-  CHAR8   *SourceFileName,\r
-  UINT32  LineNum\r
-  )\r
-;\r
-\r
-void\r
-ParserError (\r
-  UINT32  ErrorCode,\r
-  CHAR8   *OffendingText,\r
-  CHAR8   *MsgFmt,\r
-  ...\r
-  )\r
-;\r
-\r
-void\r
-ParserWarning (\r
-  UINT32  ErrorCode,\r
-  CHAR8   *OffendingText,\r
-  CHAR8   *MsgFmt,\r
-  ...\r
-  )\r
-;\r
-\r
-void\r
-SetPrintLimits (\r
-  UINT32  NumErrors,\r
-  UINT32  NumWarnings,\r
-  UINT32  NumWarningsPlusErrors\r
-  )\r
-;\r
-\r
-#ifdef __cplusplus\r
-}\r
-#endif\r
-\r
-#endif // #ifndef _EFI_UTILITY_MSGS_H_\r
diff --git a/Tools/CodeTools/TianoTools/Common/FvLib.c b/Tools/CodeTools/TianoTools/Common/FvLib.c
deleted file mode 100644 (file)
index e8d6279..0000000
+++ /dev/null
@@ -1,780 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2004, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-Module Name:\r
-\r
-  FvLib.c\r
-\r
-Abstract:\r
-\r
-  These functions assist in parsing and manipulating a Firmware Volume.\r
-\r
---*/\r
-\r
-//\r
-// Include files\r
-//\r
-#include "FvLib.h"\r
-#include "CommonLib.h"\r
-#include "EfiUtilityMsgs.h"\r
-\r
-//\r
-// Module global variables\r
-//\r
-EFI_FIRMWARE_VOLUME_HEADER  *mFvHeader  = NULL;\r
-UINT32                      mFvLength   = 0;\r
-\r
-//\r
-// External function implementations\r
-//\r
-EFI_STATUS\r
-InitializeFvLib (\r
-  IN VOID                         *Fv,\r
-  IN UINT32                       FvLength\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  This initializes the FV lib with a pointer to the FV and length.  It does not\r
-  verify the FV in any way.\r
-\r
-Arguments:\r
-\r
-  Fv            Buffer containing the FV.\r
-  FvLength      Length of the FV\r
-    \r
-Returns:\r
\r
-  EFI_SUCCESS             Function Completed successfully.\r
-  EFI_INVALID_PARAMETER   A required parameter was NULL.\r
-\r
---*/\r
-{\r
-  //\r
-  // Verify input arguments\r
-  //\r
-  if (Fv == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  mFvHeader = (EFI_FIRMWARE_VOLUME_HEADER *) Fv;\r
-  mFvLength = FvLength;\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-GetFvHeader (\r
-  OUT EFI_FIRMWARE_VOLUME_HEADER  **FvHeader,\r
-  OUT UINT32                      *FvLength\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  This function returns a pointer to the current FV and the size.\r
-\r
-Arguments:\r
-\r
-  FvHeader      Pointer to the FV buffer.\r
-  FvLength      Length of the FV\r
-    \r
-Returns:\r
\r
-  EFI_SUCCESS             Function Completed successfully.\r
-  EFI_INVALID_PARAMETER   A required parameter was NULL.\r
-  EFI_ABORTED             The library needs to be initialized.\r
-\r
---*/\r
-{\r
-  //\r
-  // Verify library has been initialized.\r
-  //\r
-  if (mFvHeader == NULL || mFvLength == 0) {\r
-    return EFI_ABORTED;\r
-  }\r
-  //\r
-  // Verify input arguments\r
-  //\r
-  if (FvHeader == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  *FvHeader = mFvHeader;\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-GetNextFile (\r
-  IN EFI_FFS_FILE_HEADER          *CurrentFile,\r
-  OUT EFI_FFS_FILE_HEADER         **NextFile\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  This function returns the next file.  If the current file is NULL, it returns\r
-  the first file in the FV.  If the function returns EFI_SUCCESS and the file \r
-  pointer is NULL, then there are no more files in the FV.\r
-\r
-Arguments:\r
-\r
-  CurrentFile   Pointer to the current file, must be within the current FV.\r
-  NextFile      Pointer to the next file in the FV.\r
-    \r
-Returns:\r
\r
-  EFI_SUCCESS             Function completed successfully.\r
-  EFI_INVALID_PARAMETER   A required parameter was NULL or is out of range.\r
-  EFI_ABORTED             The library needs to be initialized.\r
-\r
---*/\r
-{\r
-  EFI_STATUS  Status;\r
-\r
-  //\r
-  // Verify library has been initialized.\r
-  //\r
-  if (mFvHeader == NULL || mFvLength == 0) {\r
-    return EFI_ABORTED;\r
-  }\r
-  //\r
-  // Verify input arguments\r
-  //\r
-  if (NextFile == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-  //\r
-  // Verify FV header\r
-  //\r
-  Status = VerifyFv (mFvHeader);\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_ABORTED;\r
-  }\r
-  //\r
-  // Get first file\r
-  //\r
-  if (CurrentFile == NULL) {\r
-    CurrentFile = (EFI_FFS_FILE_HEADER *) ((UINTN) mFvHeader + mFvHeader->HeaderLength);\r
-\r
-    //\r
-    // Verify file is valid\r
-    //\r
-    Status = VerifyFfsFile (CurrentFile);\r
-    if (EFI_ERROR (Status)) {\r
-      //\r
-      // no files in this FV\r
-      //\r
-      *NextFile = NULL;\r
-      return EFI_SUCCESS;\r
-    } else {\r
-      //\r
-      // Verify file is in this FV.\r
-      //\r
-      if ((UINTN) CurrentFile >= (UINTN) mFvHeader + mFvLength - sizeof (EFI_FFS_FILE_HEADER)) {\r
-        *NextFile = NULL;\r
-        return EFI_SUCCESS;\r
-      }\r
-\r
-      *NextFile = CurrentFile;\r
-      return EFI_SUCCESS;\r
-    }\r
-  }\r
-  //\r
-  // Verify current file is in range\r
-  //\r
-  if (((UINTN) CurrentFile < (UINTN) mFvHeader + sizeof (EFI_FIRMWARE_VOLUME_HEADER)) ||\r
-      ((UINTN) CurrentFile >= (UINTN) mFvHeader + mFvLength - sizeof (EFI_FIRMWARE_VOLUME_HEADER))\r
-      ) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-  //\r
-  // Get next file, compensate for 8 byte alignment if necessary.\r
-  //\r
-  *NextFile = (EFI_FFS_FILE_HEADER *) (((UINTN) CurrentFile + GetLength (CurrentFile->Size) + 0x07) & (-1 << 3));\r
-\r
-  //\r
-  // Verify file is in this FV.\r
-  //\r
-  if ((UINTN) *NextFile >= (UINTN) mFvHeader + mFvLength - sizeof (EFI_FFS_FILE_HEADER)) {\r
-    *NextFile = NULL;\r
-    return EFI_SUCCESS;\r
-  }\r
-  //\r
-  // Verify file is valid\r
-  //\r
-  Status = VerifyFfsFile (*NextFile);\r
-  if (EFI_ERROR (Status)) {\r
-    //\r
-    // no more files in this FV\r
-    //\r
-    *NextFile = NULL;\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-GetFileByName (\r
-  IN EFI_GUID                     *FileName,\r
-  OUT EFI_FFS_FILE_HEADER         **File\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Find a file by name.  The function will return NULL if the file is not found.\r
-\r
-Arguments:\r
-\r
-  FileName    The GUID file name of the file to search for.\r
-  File        Return pointer.  In the case of an error, contents are undefined.\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS             The function completed successfully.\r
-  EFI_ABORTED             An error was encountered.\r
-  EFI_INVALID_PARAMETER   One of the parameters was NULL.\r
-\r
---*/\r
-{\r
-  EFI_FFS_FILE_HEADER *CurrentFile;\r
-  EFI_STATUS          Status;\r
-\r
-  //\r
-  // Verify library has been initialized.\r
-  //\r
-  if (mFvHeader == NULL || mFvLength == 0) {\r
-    return EFI_ABORTED;\r
-  }\r
-  //\r
-  // Verify input parameters\r
-  //\r
-  if (FileName == NULL || File == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-  //\r
-  // Verify FV header\r
-  //\r
-  Status = VerifyFv (mFvHeader);\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_ABORTED;\r
-  }\r
-  //\r
-  // Get the first file\r
-  //\r
-  Status = GetNextFile (NULL, &CurrentFile);\r
-  if (EFI_ERROR (Status)) {\r
-    Error (NULL, 0, 0, "error parsing the FV", NULL);\r
-    return EFI_ABORTED;\r
-  }\r
-  //\r
-  // Loop as long as we have a valid file\r
-  //\r
-  while (CurrentFile) {\r
-    if (!CompareGuid (&CurrentFile->Name, FileName)) {\r
-      *File = CurrentFile;\r
-      return EFI_SUCCESS;\r
-    }\r
-\r
-    Status = GetNextFile (CurrentFile, &CurrentFile);\r
-    if (EFI_ERROR (Status)) {\r
-      Error (NULL, 0, 0, "error parsing the FV", NULL);\r
-      return EFI_ABORTED;\r
-    }\r
-  }\r
-  //\r
-  // File not found in this FV.\r
-  //\r
-  *File = NULL;\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-GetFileByType (\r
-  IN EFI_FV_FILETYPE              FileType,\r
-  IN UINTN                        Instance,\r
-  OUT EFI_FFS_FILE_HEADER         **File\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Find a file by type and instance.  An instance of 1 is the first instance.\r
-  The function will return NULL if a matching file cannot be found.\r
-  File type EFI_FV_FILETYPE_ALL means any file type is valid.\r
-\r
-Arguments:\r
-\r
-  FileType    Type of file to search for.\r
-  Instance    Instace of the file type to return.\r
-  File        Return pointer.  In the case of an error, contents are undefined.\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS             The function completed successfully.\r
-  EFI_ABORTED             An error was encountered.\r
-  EFI_INVALID_PARAMETER   One of the parameters was NULL.\r
-\r
---*/\r
-{\r
-  EFI_FFS_FILE_HEADER *CurrentFile;\r
-  EFI_STATUS          Status;\r
-  UINTN               FileCount;\r
-\r
-  //\r
-  // Verify library has been initialized.\r
-  //\r
-  if (mFvHeader == NULL || mFvLength == 0) {\r
-    return EFI_ABORTED;\r
-  }\r
-  //\r
-  // Verify input parameters\r
-  //\r
-  if (File == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-  //\r
-  // Verify FV header\r
-  //\r
-  Status = VerifyFv (mFvHeader);\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_ABORTED;\r
-  }\r
-  //\r
-  // Initialize the number of matching files found.\r
-  //\r
-  FileCount = 0;\r
-\r
-  //\r
-  // Get the first file\r
-  //\r
-  Status = GetNextFile (NULL, &CurrentFile);\r
-  if (EFI_ERROR (Status)) {\r
-    Error (NULL, 0, 0, "error parsing FV", NULL);\r
-    return EFI_ABORTED;\r
-  }\r
-  //\r
-  // Loop as long as we have a valid file\r
-  //\r
-  while (CurrentFile) {\r
-    if (FileType == EFI_FV_FILETYPE_ALL || CurrentFile->Type == FileType) {\r
-      FileCount++;\r
-    }\r
-\r
-    if (FileCount == Instance) {\r
-      *File = CurrentFile;\r
-      return EFI_SUCCESS;\r
-    }\r
-\r
-    Status = GetNextFile (CurrentFile, &CurrentFile);\r
-    if (EFI_ERROR (Status)) {\r
-      Error (NULL, 0, 0, "error parsing the FV", NULL);\r
-      return EFI_ABORTED;\r
-    }\r
-  }\r
-\r
-  *File = NULL;\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-GetSectionByType (\r
-  IN EFI_FFS_FILE_HEADER          *File,\r
-  IN EFI_SECTION_TYPE             SectionType,\r
-  IN UINTN                        Instance,\r
-  OUT EFI_FILE_SECTION_POINTER    *Section\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Find a section in a file by type and instance.  An instance of 1 is the first \r
-  instance.  The function will return NULL if a matching section cannot be found.\r
-  The function will not handle encapsulating sections.\r
-\r
-Arguments:\r
-\r
-  File        The file to search.\r
-  SectionType Type of file to search for.\r
-  Instance    Instace of the section to return.\r
-  Section     Return pointer.  In the case of an error, contents are undefined.\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS             The function completed successfully.\r
-  EFI_ABORTED             An error was encountered.\r
-  EFI_INVALID_PARAMETER   One of the parameters was NULL.\r
-  EFI_NOT_FOUND           No found.\r
---*/\r
-{\r
-  EFI_FILE_SECTION_POINTER  CurrentSection;\r
-  EFI_STATUS                Status;\r
-  UINTN                     SectionCount;\r
-\r
-  //\r
-  // Verify input parameters\r
-  //\r
-  if (File == NULL || Instance == 0) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-  //\r
-  // Verify FFS header\r
-  //\r
-  Status = VerifyFfsFile (File);\r
-  if (EFI_ERROR (Status)) {\r
-    Error (NULL, 0, 0, "invalid FFS file", NULL);\r
-    return EFI_ABORTED;\r
-  }\r
-  //\r
-  // Initialize the number of matching sections found.\r
-  //\r
-  SectionCount = 0;\r
-\r
-  //\r
-  // Get the first section\r
-  //\r
-  CurrentSection.CommonHeader = (EFI_COMMON_SECTION_HEADER *) ((UINTN) File + sizeof (EFI_FFS_FILE_HEADER));\r
-\r
-  //\r
-  // Loop as long as we have a valid file\r
-  //\r
-  while ((UINTN) CurrentSection.CommonHeader < (UINTN) File + GetLength (File->Size)) {\r
-    if (CurrentSection.CommonHeader->Type == SectionType) {\r
-      SectionCount++;\r
-    }\r
-\r
-    if (SectionCount == Instance) {\r
-      *Section = CurrentSection;\r
-      return EFI_SUCCESS;\r
-    }\r
-    //\r
-    // Find next section (including compensating for alignment issues.\r
-    //\r
-    CurrentSection.CommonHeader = (EFI_COMMON_SECTION_HEADER *) ((((UINTN) CurrentSection.CommonHeader) + GetLength (CurrentSection.CommonHeader->Size) + 0x03) & (-1 << 2));\r
-  }\r
-  //\r
-  // Section not found\r
-  //\r
-  (*Section).Code16Section = NULL;\r
-  return EFI_NOT_FOUND;\r
-}\r
-//\r
-// will not parse compressed sections\r
-//\r
-EFI_STATUS\r
-VerifyFv (\r
-  IN EFI_FIRMWARE_VOLUME_HEADER   *FvHeader\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Verify the current pointer points to a valid FV header.\r
-\r
-Arguments:\r
-\r
-  FvHeader     Pointer to an alleged FV file.\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS             The FV header is valid.\r
-  EFI_VOLUME_CORRUPTED    The FV header is not valid.\r
-  EFI_INVALID_PARAMETER   A required parameter was NULL.\r
-  EFI_ABORTED             Operation aborted.\r
-\r
---*/\r
-{\r
-  UINT16  Checksum;\r
-\r
-  //\r
-  // Verify input parameters\r
-  //\r
-  if (FvHeader == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if (FvHeader->Signature != EFI_FVH_SIGNATURE) {\r
-    Error (NULL, 0, 0, "invalid FV header signature", NULL);\r
-    return EFI_VOLUME_CORRUPTED;\r
-  }\r
-  //\r
-  // Verify header checksum\r
-  //\r
-  Checksum = CalculateSum16 ((UINT16 *) FvHeader, FvHeader->HeaderLength / sizeof (UINT16));\r
-\r
-  if (Checksum != 0) {\r
-    Error (NULL, 0, 0, "invalid FV header checksum", NULL);\r
-    return EFI_ABORTED;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-VerifyFfsFile (\r
-  IN EFI_FFS_FILE_HEADER  *FfsHeader\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Verify the current pointer points to a FFS file header.\r
-\r
-Arguments:\r
-\r
-  FfsHeader     Pointer to an alleged FFS file.\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS           The Ffs header is valid.\r
-  EFI_NOT_FOUND         This "file" is the beginning of free space.\r
-  EFI_VOLUME_CORRUPTED  The Ffs header is not valid.\r
-  EFI_ABORTED           The erase polarity is not known.\r
-\r
---*/\r
-{\r
-  BOOLEAN             ErasePolarity;\r
-  EFI_STATUS          Status;\r
-  EFI_FFS_FILE_HEADER BlankHeader;\r
-  UINT8               Checksum;\r
-  UINT32              FileLength;\r
-  UINT32              OccupiedFileLength;\r
-  EFI_FFS_FILE_TAIL   *Tail;\r
-  UINT8               SavedChecksum;\r
-  UINT8               SavedState;\r
-  UINT8               FileGuidString[80];\r
-  UINT32              TailSize;\r
-  //\r
-  // Verify library has been initialized.\r
-  //\r
-  if (mFvHeader == NULL || mFvLength == 0) {\r
-    return EFI_ABORTED;\r
-  }\r
-  //\r
-  // Verify FV header\r
-  //\r
-  Status = VerifyFv (mFvHeader);\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_ABORTED;\r
-  }\r
-  //\r
-  // Get the erase polarity.\r
-  //\r
-  Status = GetErasePolarity (&ErasePolarity);\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_ABORTED;\r
-  }\r
-  //\r
-  // Check if we have free space\r
-  //\r
-  if (ErasePolarity) {\r
-    memset (&BlankHeader, -1, sizeof (EFI_FFS_FILE_HEADER));\r
-  } else {\r
-    memset (&BlankHeader, 0, sizeof (EFI_FFS_FILE_HEADER));\r
-  }\r
-\r
-  if (memcmp (&BlankHeader, FfsHeader, sizeof (EFI_FFS_FILE_HEADER)) == 0) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-  //\r
-  // Convert the GUID to a string so we can at least report which file\r
-  // if we find an error.\r
-  //\r
-  PrintGuidToBuffer (&FfsHeader->Name, FileGuidString, sizeof (FileGuidString), TRUE);\r
-  if (FfsHeader->Attributes & FFS_ATTRIB_TAIL_PRESENT) {\r
-    TailSize = sizeof (EFI_FFS_FILE_TAIL);\r
-  } else {\r
-    TailSize = 0;\r
-  }\r
-  //\r
-  // Verify file header checksum\r
-  //\r
-  SavedState = FfsHeader->State;\r
-  FfsHeader->State = 0;\r
-  SavedChecksum = FfsHeader->IntegrityCheck.Checksum.File;\r
-  FfsHeader->IntegrityCheck.Checksum.File = 0;\r
-  Checksum = CalculateSum8 ((UINT8 *) FfsHeader, sizeof (EFI_FFS_FILE_HEADER));\r
-  FfsHeader->State = SavedState;\r
-  FfsHeader->IntegrityCheck.Checksum.File = SavedChecksum;\r
-  if (Checksum != 0) {\r
-    Error (NULL, 0, 0, FileGuidString, "invalid FFS file header checksum");\r
-    return EFI_ABORTED;\r
-  }\r
-  //\r
-  // Verify file checksum\r
-  //\r
-  if (FfsHeader->Attributes & FFS_ATTRIB_CHECKSUM) {\r
-    //\r
-    // Verify file data checksum\r
-    //\r
-    FileLength          = GetLength (FfsHeader->Size);\r
-    OccupiedFileLength  = (FileLength + 0x07) & (-1 << 3);\r
-    Checksum            = CalculateSum8 ((UINT8 *) FfsHeader, FileLength - TailSize);\r
-    Checksum            = (UINT8) (Checksum - FfsHeader->State);\r
-    if (Checksum != 0) {\r
-      Error (NULL, 0, 0, FileGuidString, "invalid FFS file checksum");\r
-      return EFI_ABORTED;\r
-    }\r
-  } else {\r
-    //\r
-    // File does not have a checksum\r
-    // Verify contents are 0x5A as spec'd\r
-    //\r
-    if (FfsHeader->IntegrityCheck.Checksum.File != FFS_FIXED_CHECKSUM) {\r
-      Error (NULL, 0, 0, FileGuidString, "invalid fixed FFS file header checksum");\r
-      return EFI_ABORTED;\r
-    }\r
-  }\r
-  //\r
-  // Check if the tail is present and verify it if it is.\r
-  //\r
-  if (FfsHeader->Attributes & FFS_ATTRIB_TAIL_PRESENT) {\r
-    //\r
-    // Verify tail is complement of integrity check field in the header.\r
-    //\r
-    Tail = (EFI_FFS_FILE_TAIL *) ((UINTN) FfsHeader + GetLength (FfsHeader->Size) - sizeof (EFI_FFS_FILE_TAIL));\r
-    if (FfsHeader->IntegrityCheck.TailReference != (EFI_FFS_FILE_TAIL)~(*Tail)) {\r
-      Error (NULL, 0, 0, FileGuidString, "invalid FFS file tail");\r
-      return EFI_ABORTED;\r
-    }\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-UINT32\r
-GetLength (\r
-  UINT8     *ThreeByteLength\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Converts a three byte length value into a UINT32.\r
-\r
-Arguments:\r
-\r
-  ThreeByteLength   Pointer to the first of the 3 byte length.\r
-\r
-Returns:\r
-\r
-  UINT32      Size of the section\r
-\r
---*/\r
-{\r
-  UINT32  Length;\r
-\r
-  if (ThreeByteLength == NULL) {\r
-    return 0;\r
-  }\r
-\r
-  Length  = *((UINT32 *) ThreeByteLength);\r
-  Length  = Length & 0x00FFFFFF;\r
-\r
-  return Length;\r
-}\r
-\r
-EFI_STATUS\r
-GetErasePolarity (\r
-  OUT BOOLEAN   *ErasePolarity\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  This function returns with the FV erase polarity.  If the erase polarity\r
-  for a bit is 1, the function return TRUE.\r
-\r
-Arguments:\r
-\r
-  ErasePolarity   A pointer to the erase polarity.\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS              The function completed successfully.\r
-  EFI_INVALID_PARAMETER    One of the input parameters was invalid.\r
-  EFI_ABORTED              Operation aborted.\r
-  \r
---*/\r
-{\r
-  EFI_STATUS  Status;\r
-\r
-  //\r
-  // Verify library has been initialized.\r
-  //\r
-  if (mFvHeader == NULL || mFvLength == 0) {\r
-    return EFI_ABORTED;\r
-  }\r
-  //\r
-  // Verify FV header\r
-  //\r
-  Status = VerifyFv (mFvHeader);\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_ABORTED;\r
-  }\r
-  //\r
-  // Verify input parameters.\r
-  //\r
-  if (ErasePolarity == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if (mFvHeader->Attributes & EFI_FVB_ERASE_POLARITY) {\r
-    *ErasePolarity = TRUE;\r
-  } else {\r
-    *ErasePolarity = FALSE;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-UINT8\r
-GetFileState (\r
-  IN BOOLEAN              ErasePolarity,\r
-  IN EFI_FFS_FILE_HEADER  *FfsHeader\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  This function returns a the highest state bit in the FFS that is set.\r
-  It in no way validate the FFS file.\r
-\r
-Arguments:\r
-  \r
-  ErasePolarity The erase polarity for the file state bits.\r
-  FfsHeader     Pointer to a FFS file.\r
-\r
-Returns:\r
-\r
-  UINT8   The hightest set state of the file.\r
-\r
---*/\r
-{\r
-  UINT8 FileState;\r
-  UINT8 HighestBit;\r
-\r
-  FileState = FfsHeader->State;\r
-\r
-  if (ErasePolarity) {\r
-    FileState = (UINT8)~FileState;\r
-  }\r
-\r
-  HighestBit = 0x80;\r
-  while (HighestBit != 0 && (HighestBit & FileState) == 0) {\r
-    HighestBit >>= 1;\r
-  }\r
-\r
-  return HighestBit;\r
-}\r
diff --git a/Tools/CodeTools/TianoTools/Common/FvLib.h b/Tools/CodeTools/TianoTools/Common/FvLib.h
deleted file mode 100644 (file)
index 1ad1e81..0000000
+++ /dev/null
@@ -1,181 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2004, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-Module Name:\r
-\r
-  FvLib.h\r
-\r
-Abstract:\r
-\r
-  These functions assist in parsing and manipulating a Firmware Volume.\r
-\r
---*/\r
-\r
-#ifndef _EFI_FV_LIB_H\r
-#define _EFI_FV_LIB_H\r
-\r
-//\r
-// Include files\r
-//\r
-#include <string.h>\r
-\r
-#include <Common/UefiBaseTypes.h>\r
-#include <Common/EfiImage.h>\r
-#include <Common/FirmwareVolumeImageFormat.h>\r
-#include <Common/FirmwareFileSystem.h>\r
-#include <Common/FirmwareVolumeHeader.h>\r
-#include <Common/MultiPhase.h>\r
-\r
-EFI_STATUS\r
-InitializeFvLib (\r
-  IN VOID                         *Fv,\r
-  IN UINT32                       FvLength\r
-  )\r
-;\r
-\r
-EFI_STATUS\r
-GetFvHeader (\r
-  OUT EFI_FIRMWARE_VOLUME_HEADER  **FvHeader,\r
-  OUT UINT32                      *FvLength\r
-  )\r
-;\r
-\r
-EFI_STATUS\r
-GetNextFile (\r
-  IN EFI_FFS_FILE_HEADER          *CurrentFile,\r
-  OUT EFI_FFS_FILE_HEADER         **NextFile\r
-  )\r
-;\r
-\r
-EFI_STATUS\r
-GetFileByName (\r
-  IN EFI_GUID                     *FileName,\r
-  OUT EFI_FFS_FILE_HEADER         **File\r
-  )\r
-;\r
-\r
-EFI_STATUS\r
-GetFileByType (\r
-  IN EFI_FV_FILETYPE              FileType,\r
-  IN UINTN                        Instance,\r
-  OUT EFI_FFS_FILE_HEADER         **File\r
-  )\r
-;\r
-\r
-EFI_STATUS\r
-GetSectionByType (\r
-  IN EFI_FFS_FILE_HEADER          *File,\r
-  IN EFI_SECTION_TYPE             SectionType,\r
-  IN UINTN                        Instance,\r
-  OUT EFI_FILE_SECTION_POINTER    *Section\r
-  )\r
-;\r
-//\r
-// will not parse compressed sections\r
-//\r
-EFI_STATUS\r
-VerifyFv (\r
-  IN EFI_FIRMWARE_VOLUME_HEADER   *FvHeader\r
-  )\r
-;\r
-\r
-EFI_STATUS\r
-VerifyFfsFile (\r
-  IN EFI_FFS_FILE_HEADER          *FfsHeader\r
-  )\r
-;\r
-\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Verify the current pointer points to a FFS file header.\r
-\r
-Arguments:\r
-\r
-  FfsHeader     Pointer to an alleged FFS file.\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS           The Ffs header is valid.\r
-  EFI_NOT_FOUND         This "file" is the beginning of free space.\r
-  EFI_VOLUME_CORRUPTED  The Ffs header is not valid.\r
-\r
---*/\r
-UINT32\r
-GetLength (\r
-  UINT8                           *ThreeByteLength\r
-  )\r
-;\r
-\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Converts a three byte length value into a UINT32.\r
-\r
-Arguments:\r
-\r
-  ThreeByteLength   Pointer to the first of the 3 byte length.\r
-\r
-Returns:\r
-\r
-  UINT32      Size of the section\r
-\r
---*/\r
-EFI_STATUS\r
-GetErasePolarity (\r
-  OUT BOOLEAN   *ErasePolarity\r
-  )\r
-;\r
-\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  This function returns with the FV erase polarity.  If the erase polarity\r
-  for a bit is 1, the function return TRUE.\r
-\r
-Arguments:\r
-\r
-  ErasePolarity   A pointer to the erase polarity.\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS              The function completed successfully.\r
-  EFI_INVALID_PARAMETER    One of the input parameters was invalid.\r
-\r
---*/\r
-UINT8\r
-GetFileState (\r
-  IN BOOLEAN              ErasePolarity,\r
-  IN EFI_FFS_FILE_HEADER  *FfsHeader\r
-  )\r
-;\r
-\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  This function returns a the highest state bit in the FFS that is set.\r
-  It in no way validate the FFS file.\r
-\r
-Arguments:\r
-  \r
-  ErasePolarity The erase polarity for the file state bits.\r
-  FfsHeader     Pointer to a FFS file.\r
-\r
-Returns:\r
-\r
-  UINT8   The hightest set state of the file.\r
-\r
---*/\r
-#endif\r
diff --git a/Tools/CodeTools/TianoTools/Common/MyAlloc.c b/Tools/CodeTools/TianoTools/Common/MyAlloc.c
deleted file mode 100644 (file)
index 39fddf7..0000000
+++ /dev/null
@@ -1,516 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2004, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-Module Name:\r
-\r
-  MyAlloc.c\r
-\r
-Abstract:\r
-\r
-  File for memory allocation tracking functions.\r
-\r
---*/\r
-\r
-#include "MyAlloc.h"\r
-\r
-#if USE_MYALLOC\r
-//\r
-// Get back to original alloc/free calls.\r
-//\r
-#undef malloc\r
-#undef calloc\r
-#undef realloc\r
-#undef free\r
-//\r
-// Start of allocation list.\r
-//\r
-static MY_ALLOC_STRUCT  *MyAllocData = NULL;\r
-\r
-//\r
-//\r
-//\r
-static UINT32           MyAllocHeadMagik  = MYALLOC_HEAD_MAGIK;\r
-static UINT32           MyAllocTailMagik  = MYALLOC_TAIL_MAGIK;\r
-\r
-//\r
-// ////////////////////////////////////////////////////////////////////////////\r
-//\r
-//\r
-VOID\r
-MyCheck (\r
-  BOOLEAN      Final,\r
-  UINT8        File[],\r
-  UINTN        Line\r
-  )\r
-// *++\r
-// Description:\r
-//\r
-//  Check for corruptions in the allocated memory chain.  If a corruption\r
-//  is detection program operation stops w/ an exit(1) call.\r
-//\r
-// Parameters:\r
-//\r
-//  Final := When FALSE, MyCheck() returns if the allocated memory chain\r
-//           has not been corrupted.  When TRUE, MyCheck() returns if there\r
-//           are no un-freed allocations.  If there are un-freed allocations,\r
-//           they are displayed and exit(1) is called.\r
-//\r
-//\r
-//  File := Set to __FILE__ by macro expansion.\r
-//\r
-//  Line := Set to __LINE__ by macro expansion.\r
-//\r
-// Returns:\r
-//\r
-//  n/a\r
-//\r
-// --*/\r
-//\r
-{\r
-  MY_ALLOC_STRUCT *Tmp;\r
-\r
-  //\r
-  // Check parameters.\r
-  //\r
-  if (File == NULL || Line == 0) {\r
-    printf (\r
-      "\nMyCheck(Final=%u, File=%xh, Line=%u)"\r
-      "Invalid parameter(s).\n",\r
-      Final,\r
-      File,\r
-      Line\r
-      );\r
-\r
-    exit (1);\r
-  }\r
-\r
-  if (strlen (File) == 0) {\r
-    printf (\r
-      "\nMyCheck(Final=%u, File=%s, Line=%u)"\r
-      "Invalid parameter.\n",\r
-      Final,\r
-      File,\r
-      Line\r
-      );\r
-\r
-    exit (1);\r
-  }\r
-  //\r
-  // Check structure contents.\r
-  //\r
-  for (Tmp = MyAllocData; Tmp != NULL; Tmp = Tmp->Next) {\r
-    if (memcmp(Tmp->Buffer, &MyAllocHeadMagik, sizeof MyAllocHeadMagik) ||\r
-        memcmp(&Tmp->Buffer[Tmp->Size + sizeof(UINT32)], &MyAllocTailMagik, sizeof MyAllocTailMagik)) {\r
-      break;\r
-    }\r
-  }\r
-  //\r
-  // If Tmp is not NULL, the structure is corrupt.\r
-  //\r
-  if (Tmp != NULL) {\r
-    printf (\r
-      "\nMyCheck(Final=%u, File=%s, Line=%u)""\nStructure corrupted!"\r
-      "\nFile=%s, Line=%u, nSize=%u, Head=%xh, Tail=%xh\n",\r
-      Final,\r
-      File,\r
-      Line,\r
-      Tmp->File,\r
-      Tmp->Line,\r
-      Tmp->Size,\r
-      *(UINT32 *) (Tmp->Buffer),\r
-      *(UINT32 *) (&Tmp->Buffer[Tmp->Size + sizeof (UINT32)])\r
-      );\r
-\r
-    exit (1);\r
-  }\r
-  //\r
-  // If Final is TRUE, display the state of the structure chain.\r
-  //\r
-  if (Final) {\r
-    if (MyAllocData != NULL) {\r
-      printf (\r
-        "\nMyCheck(Final=%u, File=%s, Line=%u)"\r
-        "\nSome allocated items have not been freed.\n",\r
-        Final,\r
-        File,\r
-        Line\r
-        );\r
-\r
-      for (Tmp = MyAllocData; Tmp != NULL; Tmp = Tmp->Next) {\r
-        printf (\r
-          "File=%s, Line=%u, nSize=%u, Head=%xh, Tail=%xh\n",\r
-          Tmp->File,\r
-          Tmp->Line,\r
-          Tmp->Size,\r
-          *(UINT32 *) (Tmp->Buffer),\r
-          *(UINT32 *) (&Tmp->Buffer[Tmp->Size + sizeof (UINT32)])\r
-          );\r
-      }\r
-    }\r
-  }\r
-}\r
-//\r
-// ////////////////////////////////////////////////////////////////////////////\r
-//\r
-//\r
-VOID *\r
-MyAlloc (\r
-  UINTN      Size,\r
-  UINT8 File[],\r
-  UINTN      Line\r
-  )\r
-// *++\r
-// Description:\r
-//\r
-//  Allocate a new link in the allocation chain along with enough storage\r
-//  for the File[] string, requested Size and alignment overhead.  If\r
-//  memory cannot be allocated or the allocation chain has been corrupted,\r
-//  exit(1) will be called.\r
-//\r
-// Parameters:\r
-//\r
-//  Size := Number of bytes (UINT8) requested by the called.\r
-//          Size cannot be zero.\r
-//\r
-//  File := Set to __FILE__ by macro expansion.\r
-//\r
-//  Line := Set to __LINE__ by macro expansion.\r
-//\r
-// Returns:\r
-//\r
-//  Pointer to the caller's buffer.\r
-//\r
-// --*/\r
-//\r
-{\r
-  MY_ALLOC_STRUCT *Tmp;\r
-  UINTN           Len;\r
-\r
-  //\r
-  // Check for invalid parameters.\r
-  //\r
-  if (Size == 0 || File == NULL || Line == 0) {\r
-    printf (\r
-      "\nMyAlloc(Size=%u, File=%xh, Line=%u)"\r
-      "\nInvalid parameter(s).\n",\r
-      Size,\r
-      File,\r
-      Line\r
-      );\r
-\r
-    exit (1);\r
-  }\r
-\r
-  Len = strlen (File);\r
-  if (Len == 0) {\r
-    printf (\r
-      "\nMyAlloc(Size=%u, File=%s, Line=%u)"\r
-      "\nInvalid parameter.\n",\r
-      Size,\r
-      File,\r
-      Line\r
-      );\r
-\r
-    exit (1);\r
-  }\r
-  //\r
-  // Check the allocation list for corruption.\r
-  //\r
-  MyCheck (0, __FILE__, __LINE__);\r
-\r
-  //\r
-  // Allocate a new entry.\r
-  //\r
-  Tmp = calloc (\r
-          1,\r
-          sizeof (MY_ALLOC_STRUCT) + Len + 1 + sizeof (UINT64) + Size + (sizeof MyAllocHeadMagik) + (sizeof MyAllocTailMagik)\r
-          );\r
-\r
-  if (Tmp == NULL) {\r
-    printf (\r
-      "\nMyAlloc(Size=%u, File=%s, Line=%u)"\r
-      "\nOut of memory.\n",\r
-      Size,\r
-      File,\r
-      Line\r
-      );\r
-\r
-    exit (1);\r
-  }\r
-  //\r
-  // Fill in the new entry.\r
-  //\r
-  Tmp->File = ((UINT8 *) Tmp) + sizeof (MY_ALLOC_STRUCT);\r
-  strcpy (Tmp->File, File);\r
-  Tmp->Line   = Line;\r
-  Tmp->Size   = Size;\r
-  Tmp->Buffer = (UINT8 *) (((UINTN) Tmp + Len + 9) &~7);\r
-\r
-  memcpy (Tmp->Buffer, &MyAllocHeadMagik, sizeof MyAllocHeadMagik);\r
-\r
-  memcpy (\r
-    &Tmp->Buffer[Size + sizeof (UINT32)],\r
-    &MyAllocTailMagik,\r
-    sizeof MyAllocTailMagik\r
-    );\r
-\r
-  Tmp->Next   = MyAllocData;\r
-  Tmp->Cksum  = (UINTN) Tmp + (UINTN) (Tmp->Next) + Tmp->Line + Tmp->Size + (UINTN) (Tmp->File) + (UINTN) (Tmp->Buffer);\r
-\r
-  MyAllocData = Tmp;\r
-\r
-  return Tmp->Buffer + sizeof (UINT32);\r
-}\r
-//\r
-// ////////////////////////////////////////////////////////////////////////////\r
-//\r
-//\r
-VOID *\r
-MyRealloc (\r
-  VOID       *Ptr,\r
-  UINTN      Size,\r
-  UINT8 File[],\r
-  UINTN      Line\r
-  )\r
-// *++\r
-// Description:\r
-//\r
-//  This does a MyAlloc(), memcpy() and MyFree().  There is no optimization\r
-//  for shrinking or expanding buffers.  An invalid parameter will cause\r
-//  MyRealloc() to fail with a call to exit(1).\r
-//\r
-// Parameters:\r
-//\r
-//  Ptr := Pointer to the caller's buffer to be re-allocated.\r
-//\r
-//  Size := Size of new buffer.  Size cannot be zero.\r
-//\r
-//  File := Set to __FILE__ by macro expansion.\r
-//\r
-//  Line := Set to __LINE__ by macro expansion.\r
-//\r
-// Returns:\r
-//\r
-//  Pointer to new caller's buffer.\r
-//\r
-// --*/\r
-//\r
-{\r
-  MY_ALLOC_STRUCT *Tmp;\r
-  VOID            *Buffer;\r
-\r
-  //\r
-  // Check for invalid parameter(s).\r
-  //\r
-  if (Size == 0 || File == NULL || Line == 0) {\r
-    printf (\r
-      "\nMyRealloc(Ptr=%xh, Size=%u, File=%xh, Line=%u)"\r
-      "\nInvalid parameter(s).\n",\r
-      Ptr,\r
-      Size,\r
-      File,\r
-      Line\r
-      );\r
-\r
-    exit (1);\r
-  }\r
-\r
-  if (strlen (File) == 0) {\r
-    printf (\r
-      "\nMyRealloc(Ptr=%xh, Size=%u, File=%s, Line=%u)"\r
-      "\nInvalid parameter.\n",\r
-      Ptr,\r
-      Size,\r
-      File,\r
-      Line\r
-      );\r
-\r
-    exit (1);\r
-  }\r
-  //\r
-  // Find existing buffer in allocation list.\r
-  //\r
-  if (Ptr == NULL) {\r
-    Tmp = NULL;\r
-  } else if (&MyAllocData->Buffer[sizeof (UINT32)] == Ptr) {\r
-    Tmp = MyAllocData;\r
-  } else {\r
-    for (Tmp = MyAllocData;; Tmp = Tmp->Next) {\r
-      if (Tmp->Next == NULL) {\r
-        printf (\r
-          "\nMyRealloc(Ptr=%xh, Size=%u, File=%s, Line=%u)"\r
-          "\nCould not find buffer.\n",\r
-          Ptr,\r
-          Size,\r
-          File,\r
-          Line\r
-          );\r
-\r
-        exit (1);\r
-      }\r
-\r
-      Tmp = Tmp->Next;\r
-    }\r
-  }\r
-  //\r
-  // Allocate new buffer, copy old data, free old buffer.\r
-  //\r
-  Buffer = MyAlloc (Size, File, Line);\r
-\r
-  if (Buffer != NULL && Tmp != NULL) {\r
-    memcpy (\r
-      Buffer,\r
-      &Tmp->Buffer[sizeof (UINT32)],\r
-      ((Size <= Tmp->Size) ? Size : Tmp->Size)\r
-      );\r
-\r
-    MyFree (Ptr, __FILE__, __LINE__);\r
-  }\r
-\r
-  return Buffer;\r
-}\r
-//\r
-// ////////////////////////////////////////////////////////////////////////////\r
-//\r
-//\r
-VOID\r
-MyFree (\r
-  VOID       *Ptr,\r
-  UINT8 File[],\r
-  UINTN      Line\r
-  )\r
-// *++\r
-// Description:\r
-//\r
-//  Release a previously allocated buffer.  Invalid parameters will cause\r
-//  MyFree() to fail with an exit(1) call.\r
-//\r
-// Parameters:\r
-//\r
-//  Ptr := Pointer to the caller's buffer to be freed.\r
-//         A NULL pointer will be ignored.\r
-//\r
-//  File := Set to __FILE__ by macro expansion.\r
-//\r
-//  Line := Set to __LINE__ by macro expansion.\r
-//\r
-// Returns:\r
-//\r
-//  n/a\r
-//\r
-// --*/\r
-//\r
-{\r
-  MY_ALLOC_STRUCT *Tmp;\r
-  MY_ALLOC_STRUCT *Tmp2;\r
-\r
-  //\r
-  // Check for invalid parameter(s).\r
-  //\r
-  if (File == NULL || Line == 0) {\r
-    printf (\r
-      "\nMyFree(Ptr=%xh, File=%xh, Line=%u)"\r
-      "\nInvalid parameter(s).\n",\r
-      Ptr,\r
-      File,\r
-      Line\r
-      );\r
-\r
-    exit (1);\r
-  }\r
-\r
-  if (strlen (File) == 0) {\r
-    printf (\r
-      "\nMyFree(Ptr=%xh, File=%s, Line=%u)"\r
-      "\nInvalid parameter.\n",\r
-      Ptr,\r
-      File,\r
-      Line\r
-      );\r
-\r
-    exit (1);\r
-  }\r
-  //\r
-  // Freeing NULL is always valid.\r
-  //\r
-  if (Ptr == NULL) {\r
-    return ;\r
-  }\r
-  //\r
-  // Fail if nothing is allocated.\r
-  //\r
-  if (MyAllocData == NULL) {\r
-    printf (\r
-      "\nMyFree(Ptr=%xh, File=%s, Line=%u)"\r
-      "\nCalled before memory allocated.\n",\r
-      Ptr,\r
-      File,\r
-      Line\r
-      );\r
-\r
-    exit (1);\r
-  }\r
-  //\r
-  // Check for corrupted allocation list.\r
-  //\r
-  MyCheck (0, __FILE__, __LINE__);\r
-\r
-  //\r
-  // Need special check for first item in list.\r
-  //\r
-  if (&MyAllocData->Buffer[sizeof (UINT32)] == Ptr) {\r
-    //\r
-    // Unlink first item in list.\r
-    //\r
-    Tmp         = MyAllocData;\r
-    MyAllocData = MyAllocData->Next;\r
-  } else {\r
-    //\r
-    // Walk list looking for matching item.\r
-    //\r
-    for (Tmp = MyAllocData;; Tmp = Tmp->Next) {\r
-      //\r
-      // Fail if end of list is reached.\r
-      //\r
-      if (Tmp->Next == NULL) {\r
-        printf (\r
-          "\nMyFree(Ptr=%xh, File=%s, Line=%u)\n"\r
-          "\nNot found.\n",\r
-          Ptr,\r
-          File,\r
-          Line\r
-          );\r
-\r
-        exit (1);\r
-      }\r
-      //\r
-      // Leave loop when match is found.\r
-      //\r
-      if (&Tmp->Next->Buffer[sizeof (UINT32)] == Ptr) {\r
-        break;\r
-      }\r
-    }\r
-    //\r
-    // Unlink item from list.\r
-    //\r
-    Tmp2      = Tmp->Next;\r
-    Tmp->Next = Tmp->Next->Next;\r
-    Tmp       = Tmp2;\r
-  }\r
-  //\r
-  // Release item.\r
-  //\r
-  free (Tmp);\r
-}\r
-\r
-#endif /* USE_MYALLOC */\r
-\r
-/* eof - MyAlloc.c */\r
diff --git a/Tools/CodeTools/TianoTools/Common/MyAlloc.h b/Tools/CodeTools/TianoTools/Common/MyAlloc.h
deleted file mode 100644 (file)
index 9697012..0000000
+++ /dev/null
@@ -1,222 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2004, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-Module Name:\r
-\r
-  MyAlloc.h\r
-\r
-Abstract:\r
-\r
-  Header file for memory allocation tracking functions.\r
-\r
---*/\r
-\r
-#ifndef _MYALLOC_H_\r
-#define _MYALLOC_H_\r
-\r
-#include <stdio.h>\r
-#include <stdlib.h>\r
-#include <string.h>\r
-\r
-#include <Common/BaseTypes.h>\r
-\r
-//\r
-// Default operation is to use the memory allocation tracking functions.\r
-// To over-ride add "#define USE_MYALLOC 0" to your program header and/or\r
-// source files as needed.  Or, just do not include this header file in\r
-// your project.\r
-//\r
-#ifndef USE_MYALLOC\r
-#define USE_MYALLOC 1\r
-#endif\r
-\r
-#if USE_MYALLOC\r
-//\r
-// Replace C library allocation routines with MyAlloc routines.\r
-//\r
-#define malloc(size)        MyAlloc ((size), __FILE__, __LINE__)\r
-#define calloc(count, size) MyAlloc ((count) * (size), __FILE__, __LINE__)\r
-#define realloc(ptr, size)  MyRealloc ((ptr), (size), __FILE__, __LINE__)\r
-#define free(ptr)           MyFree ((ptr), __FILE__, __LINE__)\r
-#define alloc_check(final)  MyCheck ((final), __FILE__, __LINE__)\r
-\r
-//\r
-// Structure for checking/tracking memory allocations.\r
-//\r
-typedef struct MyAllocStruct {\r
-  UINTN                 Cksum;\r
-  struct MyAllocStruct  *Next;\r
-  UINTN                 Line;\r
-  UINTN                 Size;\r
-  UINT8                 *File;\r
-  UINT8                 *Buffer;\r
-} MY_ALLOC_STRUCT;\r
-//\r
-// Cksum := (UINTN)This + (UINTN)Next + Line + Size + (UINTN)File +\r
-//          (UINTN)Buffer;\r
-//\r
-// Next := Pointer to next allocation structure in the list.\r
-//\r
-// Line := __LINE__\r
-//\r
-// Size := Size of allocation request.\r
-//\r
-// File := Pointer to __FILE__ string stored immediately following\r
-//         MY_ALLOC_STRUCT in memory.\r
-//\r
-// Buffer := Pointer to UINT32 aligned storage immediately following\r
-//           the NULL terminated __FILE__ string.  This is UINT32\r
-//           aligned because the underflow signature is 32-bits and\r
-//           this will place the first caller address on a 64-bit\r
-//           boundary.\r
-//\r
-//\r
-// Signatures used to check for buffer overflow/underflow conditions.\r
-//\r
-#define MYALLOC_HEAD_MAGIK  0xBADFACED\r
-#define MYALLOC_TAIL_MAGIK  0xDEADBEEF\r
-\r
-VOID\r
-MyCheck (\r
-  BOOLEAN      Final,\r
-  UINT8        File[],\r
-  UINTN        Line\r
-  )\r
-;\r
-//\r
-// *++\r
-// Description:\r
-//\r
-//  Check for corruptions in the allocated memory chain.  If a corruption\r
-//  is detection program operation stops w/ an exit(1) call.\r
-//\r
-// Parameters:\r
-//\r
-//  Final := When FALSE, MyCheck() returns if the allocated memory chain\r
-//           has not been corrupted.  When TRUE, MyCheck() returns if there\r
-//           are no un-freed allocations.  If there are un-freed allocations,\r
-//           they are displayed and exit(1) is called.\r
-//\r
-//\r
-//  File := Set to __FILE__ by macro expansion.\r
-//\r
-//  Line := Set to __LINE__ by macro expansion.\r
-//\r
-// Returns:\r
-//\r
-//  n/a\r
-//\r
-// --*/\r
-//\r
-VOID  *\r
-MyAlloc (\r
-  UINTN      Size,\r
-  UINT8      File[],\r
-  UINTN      Line\r
-  )\r
-;\r
-//\r
-// *++\r
-// Description:\r
-//\r
-//  Allocate a new link in the allocation chain along with enough storage\r
-//  for the File[] string, requested Size and alignment overhead.  If\r
-//  memory cannot be allocated or the allocation chain has been corrupted,\r
-//  exit(1) will be called.\r
-//\r
-// Parameters:\r
-//\r
-//  Size := Number of bytes (UINT8) requested by the called.\r
-//          Size cannot be zero.\r
-//\r
-//  File := Set to __FILE__ by macro expansion.\r
-//\r
-//  Line := Set to __LINE__ by macro expansion.\r
-//\r
-// Returns:\r
-//\r
-//  Pointer to the caller's buffer.\r
-//\r
-// --*/\r
-//\r
-VOID  *\r
-MyRealloc (\r
-  VOID       *Ptr,\r
-  UINTN      Size,\r
-  UINT8      File[],\r
-  UINTN      Line\r
-  )\r
-;\r
-//\r
-// *++\r
-// Description:\r
-//\r
-//  This does a MyAlloc(), memcpy() and MyFree().  There is no optimization\r
-//  for shrinking or expanding buffers.  An invalid parameter will cause\r
-//  MyRealloc() to fail with a call to exit(1).\r
-//\r
-// Parameters:\r
-//\r
-//  Ptr := Pointer to the caller's buffer to be re-allocated.\r
-//         Ptr cannot be NULL.\r
-//\r
-//  Size := Size of new buffer.  Size cannot be zero.\r
-//\r
-//  File := Set to __FILE__ by macro expansion.\r
-//\r
-//  Line := Set to __LINE__ by macro expansion.\r
-//\r
-// Returns:\r
-//\r
-//  Pointer to new caller's buffer.\r
-//\r
-// --*/\r
-//\r
-VOID\r
-MyFree (\r
-  VOID       *Ptr,\r
-  UINT8      File[],\r
-  UINTN      Line\r
-  )\r
-;\r
-//\r
-// *++\r
-// Description:\r
-//\r
-//  Release a previously allocated buffer.  Invalid parameters will cause\r
-//  MyFree() to fail with an exit(1) call.\r
-//\r
-// Parameters:\r
-//\r
-//  Ptr := Pointer to the caller's buffer to be freed.\r
-//         A NULL pointer will be ignored.\r
-//\r
-//  File := Set to __FILE__ by macro expansion.\r
-//\r
-//  Line := Set to __LINE__ by macro expansion.\r
-//\r
-// Returns:\r
-//\r
-//  n/a\r
-//\r
-// --*/\r
-//\r
-#else /* USE_MYALLOC */\r
-\r
-//\r
-// Nothing to do when USE_MYALLOC is zero.\r
-//\r
-#define alloc_check(final)\r
-\r
-#endif /* USE_MYALLOC */\r
-#endif /* _MYALLOC_H_ */\r
-\r
-/* eof - MyAlloc.h */\r
diff --git a/Tools/CodeTools/TianoTools/Common/ParseInf.c b/Tools/CodeTools/TianoTools/Common/ParseInf.c
deleted file mode 100644 (file)
index de0ffd8..0000000
+++ /dev/null
@@ -1,630 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2004, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-Module Name:\r
-\r
-  ParseInf.c\r
-\r
-Abstract:\r
-\r
-  This contains some useful functions for parsing INF files.\r
-\r
---*/\r
-\r
-#include <assert.h>\r
-#include <string.h>\r
-#include <ctype.h>\r
-#include <stdlib.h>\r
-#include "ParseInf.h"\r
-\r
-#ifndef _MAX_PATH\r
-#define _MAX_PATH 500\r
-#endif\r
-\r
-CHAR8 *\r
-ReadLine (\r
-  IN MEMORY_FILE    *InputFile,\r
-  IN OUT CHAR8      *InputBuffer,\r
-  IN UINTN          MaxLength\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  This function reads a line, stripping any comments.\r
-  The function reads a string from the input stream argument and stores it in \r
-  the input string. ReadLine reads characters from the current file position \r
-  to and including the first newline character, to the end of the stream, or \r
-  until the number of characters read is equal to MaxLength - 1, whichever \r
-  comes first.  The newline character, if read, is replaced with a \0. \r
-\r
-Arguments:\r
-\r
-  InputFile     Memory file image.\r
-  InputBuffer   Buffer to read into, must be _MAX_PATH size.\r
-  MaxLength     The maximum size of the input buffer.\r
-\r
-Returns:\r
-\r
-  NULL if error or EOF\r
-  InputBuffer otherwise\r
-\r
---*/\r
-{\r
-  CHAR8 *CharPtr;\r
-  CHAR8 *EndOfLine;\r
-  UINTN CharsToCopy;\r
-\r
-  //\r
-  // Verify input parameters are not null\r
-  //\r
-  assert (InputBuffer);\r
-  assert (InputFile->FileImage);\r
-  assert (InputFile->Eof);\r
-  assert (InputFile->CurrentFilePointer);\r
-\r
-  //\r
-  // Check for end of file condition\r
-  //\r
-  if (InputFile->CurrentFilePointer >= InputFile->Eof) {\r
-    return NULL;\r
-  }\r
-  //\r
-  // Find the next newline char\r
-  //\r
-  EndOfLine = strchr (InputFile->CurrentFilePointer, '\n');\r
-\r
-  //\r
-  // Determine the number of characters to copy.\r
-  //\r
-  if (EndOfLine == 0) {\r
-    //\r
-    // If no newline found, copy to the end of the file.\r
-    //\r
-    CharsToCopy = InputFile->Eof - InputFile->CurrentFilePointer;\r
-  } else if (EndOfLine >= InputFile->Eof) {\r
-    //\r
-    // If the newline found was beyond the end of file, copy to the eof.\r
-    //\r
-    CharsToCopy = InputFile->Eof - InputFile->CurrentFilePointer;\r
-  } else {\r
-    //\r
-    // Newline found in the file.\r
-    //\r
-    CharsToCopy = EndOfLine - InputFile->CurrentFilePointer;\r
-  }\r
-  //\r
-  // If the end of line is too big for the current buffer, set it to the max\r
-  // size of the buffer (leaving room for the \0.\r
-  //\r
-  if (CharsToCopy > MaxLength - 1) {\r
-    CharsToCopy = MaxLength - 1;\r
-  }\r
-  //\r
-  // Copy the line.\r
-  //\r
-  memcpy (InputBuffer, InputFile->CurrentFilePointer, CharsToCopy);\r
-\r
-  //\r
-  // Add the null termination over the 0x0D\r
-  //\r
-  InputBuffer[CharsToCopy - 1] = '\0';\r
-\r
-  //\r
-  // Increment the current file pointer (include the 0x0A)\r
-  //\r
-  InputFile->CurrentFilePointer += CharsToCopy + 1;\r
-\r
-  //\r
-  // Strip any comments\r
-  //\r
-  CharPtr = strstr (InputBuffer, "//");\r
-  if (CharPtr != 0) {\r
-    CharPtr[0] = 0;\r
-  }\r
-  //\r
-  // Return the string\r
-  //\r
-  return InputBuffer;\r
-}\r
-\r
-BOOLEAN\r
-FindSection (\r
-  IN MEMORY_FILE    *InputFile,\r
-  IN CHAR8          *Section\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  This function parses a file from the beginning to find a section.\r
-  The section string may be anywhere within a line.\r
-\r
-Arguments:\r
-\r
-  InputFile     Memory file image.\r
-  Section       Section to search for\r
-\r
-Returns:\r
-\r
-  FALSE if error or EOF\r
-  TRUE if section found\r
-\r
---*/\r
-{\r
-  CHAR8 InputBuffer[_MAX_PATH];\r
-  CHAR8 *CurrentToken;\r
-\r
-  //\r
-  // Verify input is not NULL\r
-  //\r
-  assert (InputFile->FileImage);\r
-  assert (InputFile->Eof);\r
-  assert (InputFile->CurrentFilePointer);\r
-  assert (Section);\r
-\r
-  //\r
-  // Rewind to beginning of file\r
-  //\r
-  InputFile->CurrentFilePointer = InputFile->FileImage;\r
-\r
-  //\r
-  // Read lines until the section is found\r
-  //\r
-  while (InputFile->CurrentFilePointer < InputFile->Eof) {\r
-    //\r
-    // Read a line\r
-    //\r
-    ReadLine (InputFile, InputBuffer, _MAX_PATH);\r
-\r
-    //\r
-    // Check if the section is found\r
-    //\r
-    CurrentToken = strstr (InputBuffer, Section);\r
-    if (CurrentToken != NULL) {\r
-      return TRUE;\r
-    }\r
-  }\r
-\r
-  return FALSE;\r
-}\r
-\r
-EFI_STATUS\r
-FindToken (\r
-  IN MEMORY_FILE    *InputFile,\r
-  IN CHAR8          *Section,\r
-  IN CHAR8          *Token,\r
-  IN UINTN          Instance,\r
-  OUT CHAR8         *Value\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Finds a token value given the section and token to search for.\r
-\r
-Arguments:\r
-\r
-  InputFile Memory file image.\r
-  Section   The section to search for, a string within [].\r
-  Token     The token to search for, e.g. EFI_PEIM_RECOVERY, followed by an = in the INF file.\r
-  Instance  The instance of the token to search for.  Zero is the first instance.\r
-  Value     The string that holds the value following the =.  Must be _MAX_PATH in size.\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS             Value found.\r
-  EFI_ABORTED             Format error detected in INF file.\r
-  EFI_INVALID_PARAMETER   Input argument was null.\r
-  EFI_LOAD_ERROR          Error reading from the file.\r
-  EFI_NOT_FOUND           Section/Token/Value not found.\r
-\r
---*/\r
-{\r
-  CHAR8   InputBuffer[_MAX_PATH];\r
-  CHAR8   *CurrentToken;\r
-  BOOLEAN ParseError;\r
-  BOOLEAN ReadError;\r
-  UINTN   Occurrance;\r
-\r
-  //\r
-  // Check input parameters\r
-  //\r
-  if (InputFile->FileImage == NULL ||\r
-      InputFile->Eof == NULL ||\r
-      InputFile->CurrentFilePointer == NULL ||\r
-      Section == NULL ||\r
-      strlen (Section) == 0 ||\r
-      Token == NULL ||\r
-      strlen (Token) == 0 ||\r
-      Value == NULL\r
-      ) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-  //\r
-  // Initialize error codes\r
-  //\r
-  ParseError  = FALSE;\r
-  ReadError   = FALSE;\r
-\r
-  //\r
-  // Initialize our instance counter for the search token\r
-  //\r
-  Occurrance = 0;\r
-\r
-  if (FindSection (InputFile, Section)) {\r
-    //\r
-    // Found the desired section, find and read the desired token\r
-    //\r
-    do {\r
-      //\r
-      // Read a line from the file\r
-      //\r
-      if (ReadLine (InputFile, InputBuffer, _MAX_PATH) == NULL) {\r
-        //\r
-        // Error reading from input file\r
-        //\r
-        ReadError = TRUE;\r
-        break;\r
-      }\r
-      //\r
-      // Get the first non-whitespace string\r
-      //\r
-      CurrentToken = strtok (InputBuffer, " \t\n");\r
-      if (CurrentToken == NULL) {\r
-        //\r
-        // Whitespace line found (or comment) so continue\r
-        //\r
-        CurrentToken = InputBuffer;\r
-        continue;\r
-      }\r
-      //\r
-      // Make sure we have not reached the end of the current section\r
-      //\r
-      if (CurrentToken[0] == '[') {\r
-        break;\r
-      }\r
-      //\r
-      // Compare the current token with the desired token\r
-      //\r
-      if (strcmp (CurrentToken, Token) == 0) {\r
-        //\r
-        // Found it\r
-        //\r
-        //\r
-        // Check if it is the correct instance\r
-        //\r
-        if (Instance == Occurrance) {\r
-          //\r
-          // Copy the contents following the =\r
-          //\r
-          CurrentToken = strtok (NULL, "= \t\n");\r
-          if (CurrentToken == NULL) {\r
-            //\r
-            // Nothing found, parsing error\r
-            //\r
-            ParseError = TRUE;\r
-          } else {\r
-            //\r
-            // Copy the current token to the output value\r
-            //\r
-            strcpy (Value, CurrentToken);\r
-            return EFI_SUCCESS;\r
-          }\r
-        } else {\r
-          //\r
-          // Increment the occurrance found\r
-          //\r
-          Occurrance++;\r
-        }\r
-      }\r
-    } while (\r
-      !ParseError &&\r
-      !ReadError &&\r
-      InputFile->CurrentFilePointer < InputFile->Eof &&\r
-      CurrentToken[0] != '[' &&\r
-      Occurrance <= Instance\r
-    );\r
-  }\r
-  //\r
-  // Distinguish between read errors and INF file format errors.\r
-  //\r
-  if (ReadError) {\r
-    return EFI_LOAD_ERROR;\r
-  }\r
-\r
-  if (ParseError) {\r
-    return EFI_ABORTED;\r
-  }\r
-\r
-  return EFI_NOT_FOUND;\r
-}\r
-\r
-EFI_STATUS\r
-StringToGuid (\r
-  IN CHAR8      *AsciiGuidBuffer,\r
-  OUT EFI_GUID  *GuidBuffer\r
-  )\r
-/*++\r
-\r
-Routine Description: \r
-\r
-  Converts a string to an EFI_GUID.  The string must be in the \r
-  xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx format.\r
-\r
-Arguments:  \r
-\r
-  AsciiGuidBuffer - pointer to ascii string\r
-  GuidBuffer      - pointer to destination Guid\r
-\r
-Returns:  \r
-\r
-  EFI_ABORTED             Could not convert the string\r
-  EFI_SUCCESS             The string was successfully converted\r
-  EFI_INVALID_PARAMETER   Input parameter is invalid.\r
-\r
---*/\r
-{\r
-  INT32 Index;\r
-  UINTN Data1;\r
-  UINTN Data2;\r
-  UINTN Data3;\r
-  UINTN Data4[8];\r
-\r
-  if (AsciiGuidBuffer == NULL || GuidBuffer == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-  //\r
-  // Scan the guid string into the buffer\r
-  //\r
-  Index = sscanf (\r
-            AsciiGuidBuffer,\r
-            "%08x-%04x-%04x-%02x%02x-%02hx%02hx%02hx%02hx%02hx%02hx",\r
-            &Data1,\r
-            &Data2,\r
-            &Data3,\r
-            &Data4[0],\r
-            &Data4[1],\r
-            &Data4[2],\r
-            &Data4[3],\r
-            &Data4[4],\r
-            &Data4[5],\r
-            &Data4[6],\r
-            &Data4[7]\r
-            );\r
-\r
-  //\r
-  // Verify the correct number of items were scanned.\r
-  //\r
-  if (Index != 11) {\r
-    printf ("ERROR: Malformed GUID \"%s\".\n\n", AsciiGuidBuffer);\r
-    return EFI_ABORTED;\r
-  }\r
-  //\r
-  // Copy the data into our GUID.\r
-  //\r
-  GuidBuffer->Data1     = (UINT32) Data1;\r
-  GuidBuffer->Data2     = (UINT16) Data2;\r
-  GuidBuffer->Data3     = (UINT16) Data3;\r
-  GuidBuffer->Data4[0]  = (UINT8) Data4[0];\r
-  GuidBuffer->Data4[1]  = (UINT8) Data4[1];\r
-  GuidBuffer->Data4[2]  = (UINT8) Data4[2];\r
-  GuidBuffer->Data4[3]  = (UINT8) Data4[3];\r
-  GuidBuffer->Data4[4]  = (UINT8) Data4[4];\r
-  GuidBuffer->Data4[5]  = (UINT8) Data4[5];\r
-  GuidBuffer->Data4[6]  = (UINT8) Data4[6];\r
-  GuidBuffer->Data4[7]  = (UINT8) Data4[7];\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-AsciiStringToUint64 (\r
-  IN CONST CHAR8  *AsciiString,\r
-  IN BOOLEAN      IsHex,\r
-  OUT UINT64      *ReturnValue\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Converts a null terminated ascii string that represents a number into a \r
-  UINT64 value.  A hex number may be preceeded by a 0x, but may not be \r
-  succeeded by an h.  A number without 0x or 0X is considered to be base 10 \r
-  unless the IsHex input is true.\r
-\r
-Arguments:\r
-\r
-  AsciiString   The string to convert.\r
-  IsHex         Force the string to be treated as a hex number.\r
-  ReturnValue   The return value.\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS   Number successfully converted.\r
-  EFI_ABORTED   Invalid character encountered.\r
-\r
---*/\r
-{\r
-  UINT8   Index;\r
-  UINT64  HexNumber;\r
-  CHAR8   CurrentChar;\r
-\r
-  //\r
-  // Initialize the result\r
-  //\r
-  HexNumber = 0;\r
-\r
-  //\r
-  // Add each character to the result\r
-  //\r
-  if (IsHex || (AsciiString[0] == '0' && (AsciiString[1] == 'x' || AsciiString[1] == 'X'))) {\r
-    //\r
-    // Verify string is a hex number\r
-    //\r
-    for (Index = 2; Index < strlen (AsciiString); Index++) {\r
-      if (isxdigit (AsciiString[Index]) == 0) {\r
-        return EFI_ABORTED;\r
-      }\r
-    }\r
-    //\r
-    // Convert the hex string.\r
-    //\r
-    for (Index = 2; AsciiString[Index] != '\0'; Index++) {\r
-      CurrentChar = AsciiString[Index];\r
-      HexNumber *= 16;\r
-      if (CurrentChar >= '0' && CurrentChar <= '9') {\r
-        HexNumber += CurrentChar - '0';\r
-      } else if (CurrentChar >= 'a' && CurrentChar <= 'f') {\r
-        HexNumber += CurrentChar - 'a' + 10;\r
-      } else if (CurrentChar >= 'A' && CurrentChar <= 'F') {\r
-        HexNumber += CurrentChar - 'A' + 10;\r
-      } else {\r
-        //\r
-        // Unrecognized character\r
-        //\r
-        return EFI_ABORTED;\r
-      }\r
-    }\r
-\r
-    *ReturnValue = HexNumber;\r
-  } else {\r
-    //\r
-    // Verify string is a number\r
-    //\r
-    for (Index = 0; Index < strlen (AsciiString); Index++) {\r
-      if (isdigit (AsciiString[Index]) == 0) {\r
-        return EFI_ABORTED;\r
-      }\r
-    }\r
-\r
-    *ReturnValue = atol (AsciiString);\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-};\r
-\r
-CHAR8 *\r
-ReadLineInStream (\r
-  IN FILE       *InputFile,\r
-  IN OUT CHAR8  *InputBuffer\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  This function reads a line, stripping any comments.\r
-  // BUGBUG:  This is obsolete once genmake goes away...\r
-\r
-Arguments:\r
-\r
-  InputFile     Stream pointer.\r
-  InputBuffer   Buffer to read into, must be _MAX_PATH size.\r
-\r
-Returns:\r
-\r
-  NULL if error or EOF\r
-  InputBuffer otherwise\r
-\r
---*/\r
-{\r
-  CHAR8 *CharPtr;\r
-\r
-  //\r
-  // Verify input parameters are not null\r
-  //\r
-  assert (InputFile);\r
-  assert (InputBuffer);\r
-\r
-  //\r
-  // Read a line\r
-  //\r
-  if (fgets (InputBuffer, _MAX_PATH, InputFile) == NULL) {\r
-    return NULL;\r
-  }\r
-  //\r
-  // Strip any comments\r
-  //\r
-  CharPtr = strstr (InputBuffer, "//");\r
-  if (CharPtr != 0) {\r
-    CharPtr[0] = 0;\r
-  }\r
-\r
-  CharPtr = strstr (InputBuffer, "#");\r
-  if (CharPtr != 0) {\r
-    CharPtr[0] = 0;\r
-  }\r
-  //\r
-  // Return the string\r
-  //\r
-  return InputBuffer;\r
-}\r
-\r
-BOOLEAN\r
-FindSectionInStream (\r
-  IN FILE       *InputFile,\r
-  IN CHAR8      *Section\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  This function parses a stream file from the beginning to find a section.\r
-  The section string may be anywhere within a line.\r
-  // BUGBUG:  This is obsolete once genmake goes away...\r
-\r
-Arguments:\r
-\r
-  InputFile     Stream pointer.\r
-  Section       Section to search for\r
-\r
-Returns:\r
-\r
-  FALSE if error or EOF\r
-  TRUE if section found\r
-\r
---*/\r
-{\r
-  CHAR8 InputBuffer[_MAX_PATH];\r
-  CHAR8 *CurrentToken;\r
-\r
-  //\r
-  // Verify input is not NULL\r
-  //\r
-  assert (InputFile);\r
-  assert (Section);\r
-\r
-  //\r
-  // Rewind to beginning of file\r
-  //\r
-  if (fseek (InputFile, 0, SEEK_SET) != 0) {\r
-    return FALSE;\r
-  }\r
-  //\r
-  // Read lines until the section is found\r
-  //\r
-  while (feof (InputFile) == 0) {\r
-    //\r
-    // Read a line\r
-    //\r
-    ReadLineInStream (InputFile, InputBuffer);\r
-\r
-    //\r
-    // Check if the section is found\r
-    //\r
-    CurrentToken = strstr (InputBuffer, Section);\r
-    if (CurrentToken != NULL) {\r
-      return TRUE;\r
-    }\r
-  }\r
-\r
-  return FALSE;\r
-}\r
diff --git a/Tools/CodeTools/TianoTools/Common/ParseInf.h b/Tools/CodeTools/TianoTools/Common/ParseInf.h
deleted file mode 100644 (file)
index ff98635..0000000
+++ /dev/null
@@ -1,234 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2004, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-Module Name:\r
-\r
-  ParseInf.h\r
-\r
-Abstract:\r
-\r
-  Header file for helper functions useful for parsing INF files.\r
-\r
---*/\r
-\r
-#ifndef _EFI_PARSE_INF_H\r
-#define _EFI_PARSE_INF_H\r
-\r
-#include <stdio.h>\r
-#include <stdlib.h>\r
-\r
-#include <Common/UefiBaseTypes.h>\r
-\r
-//\r
-// Common data structures\r
-//\r
-typedef struct {\r
-  CHAR8 *FileImage;\r
-  CHAR8 *Eof;\r
-  CHAR8 *CurrentFilePointer;\r
-} MEMORY_FILE;\r
-\r
-//\r
-// Functions declarations\r
-//\r
-CHAR8 *\r
-ReadLine (\r
-  IN MEMORY_FILE    *InputFile,\r
-  IN OUT CHAR8      *InputBuffer,\r
-  IN UINTN          MaxLength\r
-  )\r
-;\r
-\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  This function reads a line, stripping any comments.\r
-  The function reads a string from the input stream argument and stores it in \r
-  the input string. ReadLine reads characters from the current file position \r
-  to and including the first newline character, to the end of the stream, or \r
-  until the number of characters read is equal to MaxLength - 1, whichever \r
-  comes first.  The newline character, if read, is replaced with a \0. \r
-\r
-Arguments:\r
-\r
-  InputFile     Memory file image.\r
-  InputBuffer   Buffer to read into, must be _MAX_PATH size.\r
-  MaxLength     The maximum size of the input buffer.\r
-\r
-Returns:\r
-\r
-  NULL if error or EOF\r
-  InputBuffer otherwise\r
-\r
---*/\r
-BOOLEAN\r
-FindSection (\r
-  IN MEMORY_FILE    *InputFile,\r
-  IN CHAR8          *Section\r
-  )\r
-;\r
-\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  This function parses a file from the beginning to find a section.\r
-  The section string may be anywhere within a line.\r
-\r
-Arguments:\r
-\r
-  InputFile     Memory file image.\r
-  Section       Section to search for\r
-\r
-Returns:\r
-\r
-  FALSE if error or EOF\r
-  TRUE if section found\r
-\r
---*/\r
-EFI_STATUS\r
-FindToken (\r
-  IN MEMORY_FILE    *InputFile,\r
-  IN CHAR8          *Section,\r
-  IN CHAR8          *Token,\r
-  IN UINTN          Instance,\r
-  OUT CHAR8         *Value\r
-  )\r
-;\r
-\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Finds a token value given the section and token to search for.\r
-\r
-Arguments:\r
-\r
-  InputFile Memory file image.\r
-  Section   The section to search for, a string within [].\r
-  Token     The token to search for, e.g. EFI_PEIM_RECOVERY, followed by an = in the INF file.\r
-  Instance  The instance of the token to search for.  Zero is the first instance.\r
-  Value     The string that holds the value following the =.  Must be _MAX_PATH in size.\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS             Value found.\r
-  EFI_ABORTED             Format error detected in INF file.\r
-  EFI_INVALID_PARAMETER   Input argument was null.\r
-  EFI_LOAD_ERROR          Error reading from the file.\r
-  EFI_NOT_FOUND           Section/Token/Value not found.\r
-\r
---*/\r
-EFI_STATUS\r
-StringToGuid (\r
-  IN CHAR8        *AsciiGuidBuffer,\r
-  OUT EFI_GUID    *GuidBuffer\r
-  )\r
-;\r
-\r
-/*++\r
-\r
-Routine Description: \r
-\r
-  Converts a string to an EFI_GUID.  The string must be in the \r
-  xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx format.\r
-\r
-Arguments:  \r
-\r
-  GuidBuffer      - pointer to destination Guid\r
-  AsciiGuidBuffer - pointer to ascii string\r
-\r
-Returns:  \r
-\r
-  EFI_ABORTED    Could not convert the string\r
-  EFI_SUCCESS    The string was successfully converted\r
-\r
---*/\r
-EFI_STATUS\r
-AsciiStringToUint64 (\r
-  IN CONST CHAR8  *AsciiString,\r
-  IN BOOLEAN      IsHex,\r
-  OUT UINT64      *ReturnValue\r
-  )\r
-;\r
-\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Converts a null terminated ascii string that represents a number into a \r
-  UINT64 value.  A hex number may be preceeded by a 0x, but may not be \r
-  succeeded by an h.  A number without 0x or 0X is considered to be base 10 \r
-  unless the IsHex input is true.\r
-\r
-Arguments:\r
-\r
-  AsciiString   The string to convert.\r
-  IsHex         Force the string to be treated as a hex number.\r
-  ReturnValue   The return value.\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS   Number successfully converted.\r
-  EFI_ABORTED   Invalid character encountered.\r
-\r
---*/\r
-CHAR8 *\r
-ReadLineInStream (\r
-  IN FILE       *InputFile,\r
-  IN OUT CHAR8  *InputBuffer\r
-  )\r
-;\r
-\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  This function reads a line, stripping any comments.\r
-\r
-Arguments:\r
-\r
-  InputFile     Stream pointer.\r
-  InputBuffer   Buffer to read into, must be _MAX_PATH size.\r
-\r
-Returns:\r
-\r
-  NULL if error or EOF\r
-  InputBuffer otherwise\r
-\r
---*/\r
-BOOLEAN\r
-FindSectionInStream (\r
-  IN FILE       *InputFile,\r
-  IN CHAR8      *Section\r
-  )\r
-;\r
-\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  This function parses a stream file from the beginning to find a section.\r
-  The section string may be anywhere within a line.\r
-\r
-Arguments:\r
-\r
-  InputFile     Stream pointer.\r
-  Section       Section to search for\r
-\r
-Returns:\r
-\r
-  FALSE if error or EOF\r
-  TRUE if section found\r
-\r
---*/\r
-#endif\r
diff --git a/Tools/CodeTools/TianoTools/Common/SimpleFileParsing.c b/Tools/CodeTools/TianoTools/Common/SimpleFileParsing.c
deleted file mode 100644 (file)
index 73b74cd..0000000
+++ /dev/null
@@ -1,1457 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2004, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-Module Name:\r
-\r
-  SimpleFileParsing.c  \r
-\r
-Abstract:\r
-\r
-  Generic but simple file parsing routines.\r
-\r
---*/\r
-\r
-#include <stdio.h>\r
-#include <string.h>\r
-#include <stdlib.h>\r
-#include <ctype.h>\r
-\r
-#include "EfiUtilityMsgs.h"\r
-#include "SimpleFileParsing.h"\r
-\r
-#ifndef MAX_PATH\r
-#define MAX_PATH  255\r
-#endif\r
-//\r
-// just in case we get in an endless loop.\r
-//\r
-#define MAX_NEST_DEPTH  20\r
-//\r
-// number of wchars\r
-//\r
-#define MAX_STRING_IDENTIFIER_NAME  100\r
-\r
-#define MAX_LINE_LEN                400\r
-\r
-#define T_CHAR_SPACE                ' '\r
-#define T_CHAR_NULL                 0\r
-#define T_CHAR_CR                   '\r'\r
-#define T_CHAR_TAB                  '\t'\r
-#define T_CHAR_LF                   '\n'\r
-#define T_CHAR_SLASH                '/'\r
-#define T_CHAR_BACKSLASH            '\\'\r
-#define T_CHAR_DOUBLE_QUOTE         '"'\r
-#define T_CHAR_LC_X                 'x'\r
-#define T_CHAR_0                    '0'\r
-#define T_CHAR_STAR                 '*'\r
-\r
-//\r
-// We keep a linked list of these for the source files we process\r
-//\r
-typedef struct _SOURCE_FILE {\r
-  FILE                *Fptr;\r
-  T_CHAR              *FileBuffer;\r
-  T_CHAR              *FileBufferPtr;\r
-  unsigned int        FileSize;\r
-  char                FileName[MAX_PATH];\r
-  unsigned int        LineNum;\r
-  BOOLEAN             EndOfFile;\r
-  BOOLEAN             SkipToHash;\r
-  struct _SOURCE_FILE *Previous;\r
-  struct _SOURCE_FILE *Next;\r
-  T_CHAR              ControlCharacter;\r
-} SOURCE_FILE;\r
-\r
-typedef struct {\r
-  T_CHAR  *FileBufferPtr;\r
-} FILE_POSITION;\r
-\r
-//\r
-// Keep all our module globals in this structure\r
-//\r
-static struct {\r
-  SOURCE_FILE SourceFile;\r
-  BOOLEAN     VerboseFile;\r
-  BOOLEAN     VerboseToken;\r
-} mGlobals;\r
-\r
-static\r
-unsigned int\r
-t_strcmp (\r
-  T_CHAR *Buffer,\r
-  T_CHAR *Str\r
-  );\r
-\r
-static\r
-unsigned int\r
-t_strncmp (\r
-  T_CHAR *Str1,\r
-  T_CHAR *Str2,\r
-  int    Len\r
-  );\r
-\r
-static\r
-unsigned int\r
-t_strlen (\r
-  T_CHAR *Str\r
-  );\r
-\r
-static\r
-void\r
-RewindFile (\r
-  SOURCE_FILE *SourceFile\r
-  );\r
-\r
-static\r
-BOOLEAN\r
-IsWhiteSpace (\r
-  SOURCE_FILE *SourceFile\r
-  );\r
-\r
-static\r
-unsigned int\r
-SkipWhiteSpace (\r
-  SOURCE_FILE *SourceFile\r
-  );\r
-\r
-static\r
-BOOLEAN\r
-EndOfFile (\r
-  SOURCE_FILE *SourceFile\r
-  );\r
-\r
-static\r
-void\r
-PreprocessFile (\r
-  SOURCE_FILE *SourceFile\r
-  );\r
-\r
-static\r
-T_CHAR  *\r
-t_strcpy (\r
-  T_CHAR *Dest,\r
-  T_CHAR *Src\r
-  );\r
-\r
-static\r
-STATUS\r
-ProcessIncludeFile (\r
-  SOURCE_FILE *SourceFile,\r
-  SOURCE_FILE *ParentSourceFile\r
-  );\r
-\r
-static\r
-STATUS\r
-ParseFile (\r
-  SOURCE_FILE *SourceFile\r
-  );\r
-\r
-static\r
-FILE    *\r
-FindFile (\r
-  char          *FileName,\r
-  char          *FoundFileName,\r
-  unsigned int  FoundFileNameLen\r
-  );\r
-\r
-static\r
-STATUS\r
-ProcessFile (\r
-  SOURCE_FILE *SourceFile\r
-  );\r
-\r
-static\r
-STATUS\r
-GetFilePosition (\r
-  FILE_POSITION *Fpos\r
-  );\r
-\r
-static\r
-STATUS\r
-SetFilePosition (\r
-  FILE_POSITION *Fpos\r
-  );\r
-\r
-STATUS\r
-SFPInit (\r
-  VOID\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-Arguments:\r
-  None.\r
-\r
-Returns:\r
-  STATUS_SUCCESS always\r
-\r
---*/\r
-{\r
-  memset ((void *) &mGlobals, 0, sizeof (mGlobals));\r
-  return STATUS_SUCCESS;\r
-}\r
-\r
-unsigned\r
-int\r
-SFPGetLineNumber (\r
-  VOID\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Return the line number of the file we're parsing. Used\r
-  for error reporting purposes.\r
-\r
-Arguments:\r
-  None.\r
-\r
-Returns:\r
-  The line number, or 0 if no file is being processed\r
-\r
---*/\r
-{\r
-  return mGlobals.SourceFile.LineNum;\r
-}\r
-\r
-T_CHAR *\r
-SFPGetFileName (\r
-  VOID\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Return the name of the file we're parsing. Used\r
-  for error reporting purposes.\r
-\r
-Arguments:\r
-  None.\r
-\r
-Returns:\r
-  A pointer to the file name. Null if no file is being\r
-  processed.\r
-\r
---*/\r
-{\r
-  if (mGlobals.SourceFile.FileName[0]) {\r
-    return mGlobals.SourceFile.FileName;\r
-  }\r
-\r
-  return NULL;\r
-}\r
-\r
-STATUS\r
-SFPOpenFile (\r
-  char      *FileName\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Open a file for parsing.\r
-\r
-Arguments:\r
-  FileName  - name of the file to parse\r
-\r
-Returns:\r
-  \r
-\r
---*/\r
-{\r
-  STATUS  Status;\r
-  t_strcpy (mGlobals.SourceFile.FileName, FileName);\r
-  Status = ProcessIncludeFile (&mGlobals.SourceFile, NULL);\r
-  return Status;\r
-}\r
-\r
-BOOLEAN\r
-SFPIsToken (\r
-  T_CHAR *Str\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Check to see if the specified token is found at\r
-  the current position in the input file.\r
-\r
-Arguments:\r
-  Str - the token to look for\r
-\r
-Returns:\r
-  TRUE - the token is next\r
-  FALSE - the token is not next\r
-\r
-Notes:\r
-  We do a simple string comparison on this function. It is\r
-  the responsibility of the caller to ensure that the token\r
-  is not a subset of some other token.\r
-\r
-  The file pointer is advanced past the token in the input file.\r
-\r
---*/\r
-{\r
-  unsigned int  Len;\r
-  SkipWhiteSpace (&mGlobals.SourceFile);\r
-  if (EndOfFile (&mGlobals.SourceFile)) {\r
-    return FALSE;\r
-  }\r
-\r
-  if ((Len = t_strcmp (mGlobals.SourceFile.FileBufferPtr, Str)) > 0) {\r
-    mGlobals.SourceFile.FileBufferPtr += Len;\r
-    if (mGlobals.VerboseToken) {\r
-      printf ("Token: '%s'\n", Str);\r
-    }\r
-\r
-    return TRUE;\r
-  }\r
-\r
-  return FALSE;\r
-}\r
-\r
-BOOLEAN\r
-SFPIsKeyword (\r
-  T_CHAR *Str\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Check to see if the specified keyword is found at\r
-  the current position in the input file.\r
-\r
-Arguments:\r
-  Str - keyword to look for\r
-\r
-Returns:\r
-  TRUE - the keyword is next\r
-  FALSE - the keyword is not next\r
-\r
-Notes:\r
-  A keyword is defined as a "special" string that has a non-alphanumeric\r
-  character following it.\r
-\r
---*/\r
-{\r
-  unsigned int  Len;\r
-  SkipWhiteSpace (&mGlobals.SourceFile);\r
-  if (EndOfFile (&mGlobals.SourceFile)) {\r
-    return FALSE;\r
-  }\r
-\r
-  if ((Len = t_strcmp (mGlobals.SourceFile.FileBufferPtr, Str)) > 0) {\r
-    if (isalnum (mGlobals.SourceFile.FileBufferPtr[Len])) {\r
-      return FALSE;\r
-    }\r
-\r
-    mGlobals.SourceFile.FileBufferPtr += Len;\r
-    if (mGlobals.VerboseToken) {\r
-      printf ("Token: '%s'\n", Str);\r
-    }\r
-\r
-    return TRUE;\r
-  }\r
-\r
-  return FALSE;\r
-}\r
-\r
-BOOLEAN\r
-SFPGetNextToken (\r
-  T_CHAR        *Str,\r
-  unsigned int  Len\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Get the next token from the input stream. \r
-\r
-Arguments:\r
-  Str - pointer to a copy of the next token\r
-  Len - size of buffer pointed to by Str\r
-\r
-Returns:\r
-  TRUE  - next token successfully returned\r
-  FALSE - otherwise\r
-\r
-Notes:\r
-  Preceeding white space is ignored. \r
-  The parser's buffer pointer is advanced past the end of the\r
-  token.\r
-\r
---*/\r
-{\r
-  unsigned int  Index;\r
-  T_CHAR        TempChar;\r
-\r
-  SkipWhiteSpace (&mGlobals.SourceFile);\r
-  if (EndOfFile (&mGlobals.SourceFile)) {\r
-    return FALSE;\r
-  }\r
-  //\r
-  // Have to have enough string for at least one char and a null-terminator\r
-  //\r
-  if (Len < 2) {\r
-    return FALSE;\r
-  }\r
-  //\r
-  // Look at the first character. If it's an identifier, then treat it\r
-  // as such\r
-  //\r
-  TempChar = mGlobals.SourceFile.FileBufferPtr[0];\r
-  if (((TempChar >= 'a') && (TempChar <= 'z')) || ((TempChar >= 'A') && (TempChar <= 'Z')) || (TempChar == '_')) {\r
-    Str[0] = TempChar;\r
-    mGlobals.SourceFile.FileBufferPtr++;\r
-    Index = 1;\r
-    while (!EndOfFile (&mGlobals.SourceFile) && (Index < Len)) {\r
-      TempChar = mGlobals.SourceFile.FileBufferPtr[0];\r
-      if (((TempChar >= 'a') && (TempChar <= 'z')) ||\r
-          ((TempChar >= 'A') && (TempChar <= 'Z')) ||\r
-          ((TempChar >= '0') && (TempChar <= '9')) ||\r
-          (TempChar == '_')\r
-          ) {\r
-        Str[Index] = mGlobals.SourceFile.FileBufferPtr[0];\r
-        mGlobals.SourceFile.FileBufferPtr++;\r
-        Index++;\r
-      } else {\r
-        //\r
-        // Invalid character for symbol name, so break out\r
-        //\r
-        break;\r
-      }\r
-    }\r
-    //\r
-    // Null terminate and return success\r
-    //\r
-    Str[Index] = 0;\r
-    return TRUE;\r
-  } else if ((TempChar == ')') || (TempChar == '(') || (TempChar == '*')) {\r
-    Str[0] = mGlobals.SourceFile.FileBufferPtr[0];\r
-    mGlobals.SourceFile.FileBufferPtr++;\r
-    Str[1] = 0;\r
-    return TRUE;\r
-  } else {\r
-    //\r
-    // Everything else is white-space (or EOF) separated\r
-    //\r
-    Index = 0;\r
-    while (!EndOfFile (&mGlobals.SourceFile) && (Index < Len)) {\r
-      if (IsWhiteSpace (&mGlobals.SourceFile)) {\r
-        if (Index > 0) {\r
-          Str[Index] = 0;\r
-          return TRUE;\r
-        }\r
-\r
-        return FALSE;\r
-      } else {\r
-        Str[Index] = mGlobals.SourceFile.FileBufferPtr[0];\r
-        mGlobals.SourceFile.FileBufferPtr++;\r
-        Index++;\r
-      }\r
-    }\r
-    //\r
-    // See if we just ran out of file contents, but did find a token\r
-    //\r
-    if ((Index > 0) && EndOfFile (&mGlobals.SourceFile)) {\r
-      Str[Index] = 0;\r
-      return TRUE;\r
-    }\r
-  }\r
-\r
-  return FALSE;\r
-}\r
-\r
-BOOLEAN\r
-SFPGetGuidToken (\r
-  T_CHAR *Str,\r
-  UINT32 Len\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Parse a GUID from the input stream. Stop when you discover white space.\r
-\r
-Arguments:\r
-  Str - pointer to a copy of the next token\r
-  Len - size of buffer pointed to by Str\r
-\r
-Returns:\r
-  TRUE  - GUID string returned successfully\r
-  FALSE - otherwise\r
-\r
---*/\r
-{\r
-  UINT32  Index;\r
-  SkipWhiteSpace (&mGlobals.SourceFile);\r
-  if (EndOfFile (&mGlobals.SourceFile)) {\r
-    return FALSE;\r
-  }\r
-\r
-  Index = 0;\r
-  while (!EndOfFile (&mGlobals.SourceFile) && (Index < Len)) {\r
-    if (IsWhiteSpace (&mGlobals.SourceFile)) {\r
-      if (Index > 0) {\r
-        Str[Index] = 0;\r
-        return TRUE;\r
-      }\r
-\r
-      return FALSE;\r
-    } else {\r
-      Str[Index] = mGlobals.SourceFile.FileBufferPtr[0];\r
-      mGlobals.SourceFile.FileBufferPtr++;\r
-      Index++;\r
-    }\r
-  }\r
-\r
-  return FALSE;\r
-}\r
-\r
-BOOLEAN\r
-SFPSkipToToken (\r
-  T_CHAR *Str\r
-  )\r
-{\r
-  unsigned int  Len;\r
-  T_CHAR        *SavePos;\r
-  Len     = t_strlen (Str);\r
-  SavePos = mGlobals.SourceFile.FileBufferPtr;\r
-  SkipWhiteSpace (&mGlobals.SourceFile);\r
-  while (!EndOfFile (&mGlobals.SourceFile)) {\r
-    if (t_strncmp (Str, mGlobals.SourceFile.FileBufferPtr, Len) == 0) {\r
-      mGlobals.SourceFile.FileBufferPtr += Len;\r
-      return TRUE;\r
-    }\r
-\r
-    mGlobals.SourceFile.FileBufferPtr++;\r
-    SkipWhiteSpace (&mGlobals.SourceFile);\r
-  }\r
-\r
-  mGlobals.SourceFile.FileBufferPtr = SavePos;\r
-  return FALSE;\r
-}\r
-\r
-BOOLEAN\r
-SFPGetNumber (\r
-  unsigned int *Value\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Check the token at the current file position for a numeric value.\r
-  May be either decimal or hex.\r
-\r
-Arguments:\r
-  Value  - pointer where to store the value\r
-\r
-Returns:\r
-  FALSE    - current token is not a number\r
-  TRUE     - current token is a number\r
-\r
---*/\r
-{\r
-  SkipWhiteSpace (&mGlobals.SourceFile);\r
-  if (EndOfFile (&mGlobals.SourceFile)) {\r
-    return FALSE;\r
-  }\r
-\r
-  if (isdigit (mGlobals.SourceFile.FileBufferPtr[0])) {\r
-    //\r
-    // Check for hex value\r
-    //\r
-    if ((mGlobals.SourceFile.FileBufferPtr[0] == T_CHAR_0) && (mGlobals.SourceFile.FileBufferPtr[1] == T_CHAR_LC_X)) {\r
-      if (!isxdigit (mGlobals.SourceFile.FileBufferPtr[2])) {\r
-        return FALSE;\r
-      }\r
-\r
-      mGlobals.SourceFile.FileBufferPtr += 2;\r
-      sscanf (mGlobals.SourceFile.FileBufferPtr, "%x", Value);\r
-      while (isxdigit (mGlobals.SourceFile.FileBufferPtr[0])) {\r
-        mGlobals.SourceFile.FileBufferPtr++;\r
-      }\r
-\r
-      return TRUE;\r
-    } else {\r
-      *Value = atoi (mGlobals.SourceFile.FileBufferPtr);\r
-      while (isdigit (mGlobals.SourceFile.FileBufferPtr[0])) {\r
-        mGlobals.SourceFile.FileBufferPtr++;\r
-      }\r
-\r
-      return TRUE;\r
-    }\r
-  } else {\r
-    return FALSE;\r
-  }\r
-}\r
-\r
-STATUS\r
-SFPCloseFile (\r
-  VOID\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Close the file being parsed.\r
-\r
-Arguments:\r
-  None.\r
-\r
-Returns:\r
-  STATUS_SUCCESS - the file was closed \r
-  STATUS_ERROR   - no file is currently open\r
-\r
---*/\r
-{\r
-  if (mGlobals.SourceFile.FileBuffer != NULL) {\r
-    free (mGlobals.SourceFile.FileBuffer);\r
-    memset (&mGlobals.SourceFile, 0, sizeof (mGlobals.SourceFile));\r
-    return STATUS_SUCCESS;\r
-  }\r
-\r
-  return STATUS_ERROR;\r
-}\r
-\r
-static\r
-STATUS\r
-ProcessIncludeFile (\r
-  SOURCE_FILE *SourceFile,\r
-  SOURCE_FILE *ParentSourceFile\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Given a source file, open the file and parse it\r
-  \r
-Arguments:\r
-\r
-  SourceFile        - name of file to parse\r
-  ParentSourceFile  - for error reporting purposes, the file that #included SourceFile.\r
-\r
-Returns:\r
-\r
-  Standard status.\r
-  \r
---*/\r
-{\r
-  static unsigned int NestDepth = 0;\r
-  char                FoundFileName[MAX_PATH];\r
-  STATUS              Status;\r
-\r
-  Status = STATUS_SUCCESS;\r
-  NestDepth++;\r
-  //\r
-  // Print the file being processed. Indent so you can tell the include nesting\r
-  // depth.\r
-  //\r
-  if (mGlobals.VerboseFile) {\r
-    fprintf (stdout, "%*cProcessing file '%s'\n", NestDepth * 2, ' ', SourceFile->FileName);\r
-    fprintf (stdout, "Parent source file = '%s'\n", ParentSourceFile);\r
-  }\r
-\r
-  //\r
-  // Make sure we didn't exceed our maximum nesting depth\r
-  //\r
-  if (NestDepth > MAX_NEST_DEPTH) {\r
-    Error (NULL, 0, 0, SourceFile->FileName, "max nesting depth (%d) exceeded", NestDepth);\r
-    Status = STATUS_ERROR;\r
-    goto Finish;\r
-  }\r
-  //\r
-  // Try to open the file locally, and if that fails try along our include paths.\r
-  //\r
-  strcpy (FoundFileName, SourceFile->FileName);\r
-  if ((SourceFile->Fptr = fopen (FoundFileName, "rb")) == NULL) {\r
-    return STATUS_ERROR;\r
-  }\r
-  //\r
-  // Process the file found\r
-  //\r
-  ProcessFile (SourceFile);\r
-Finish:\r
-  //\r
-  // Close open files and return status\r
-  //\r
-  if (SourceFile->Fptr != NULL) {\r
-    fclose (SourceFile->Fptr);\r
-    SourceFile->Fptr = NULL;\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-static\r
-STATUS\r
-ProcessFile (\r
-  SOURCE_FILE *SourceFile\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Given a source file that's been opened, read the contents into an internal\r
-  buffer and pre-process it to remove comments.\r
-  \r
-Arguments:\r
-\r
-  SourceFile        - structure containing info on the file to process\r
-\r
-Returns:\r
-\r
-  Standard status.\r
-  \r
---*/\r
-{\r
-  //\r
-  // Get the file size, and then read the entire thing into memory.\r
-  // Allocate extra space for a terminator character.\r
-  //\r
-  fseek (SourceFile->Fptr, 0, SEEK_END);\r
-  SourceFile->FileSize = ftell (SourceFile->Fptr);\r
-  if (mGlobals.VerboseFile) {\r
-    printf ("FileSize = %d (0x%X)\n", SourceFile->FileSize, SourceFile->FileSize);\r
-  }\r
-\r
-  fseek (SourceFile->Fptr, 0, SEEK_SET);\r
-  SourceFile->FileBuffer = (T_CHAR *) malloc (SourceFile->FileSize + sizeof (T_CHAR));\r
-  if (SourceFile->FileBuffer == NULL) {\r
-    Error (NULL, 0, 0, "memory allocation failure", NULL);\r
-    return STATUS_ERROR;\r
-  }\r
-\r
-  fread ((void *) SourceFile->FileBuffer, SourceFile->FileSize, 1, SourceFile->Fptr);\r
-  SourceFile->FileBuffer[(SourceFile->FileSize / sizeof (T_CHAR))] = T_CHAR_NULL;\r
-  //\r
-  // Pre-process the file to replace comments with spaces\r
-  //\r
-  PreprocessFile (SourceFile);\r
-  SourceFile->LineNum = 1;\r
-  return STATUS_SUCCESS;\r
-}\r
-\r
-static\r
-void\r
-PreprocessFile (\r
-  SOURCE_FILE *SourceFile\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Preprocess a file to replace all carriage returns with NULLs so\r
-  we can print lines (as part of error messages) from the file to the screen.\r
-  \r
-Arguments:\r
-  SourceFile - structure that we use to keep track of an input file.\r
-\r
-Returns:\r
-  Nothing.\r
-  \r
---*/\r
-{\r
-  BOOLEAN InComment;\r
-  BOOLEAN SlashSlashComment;\r
-  int     LineNum;\r
-\r
-  RewindFile (SourceFile);\r
-  InComment         = FALSE;\r
-  SlashSlashComment = FALSE;\r
-  while (!EndOfFile (SourceFile)) {\r
-    //\r
-    // If a line-feed, then no longer in a comment if we're in a // comment\r
-    //\r
-    if (SourceFile->FileBufferPtr[0] == T_CHAR_LF) {\r
-      SourceFile->FileBufferPtr++;\r
-      SourceFile->LineNum++;\r
-      if (InComment && SlashSlashComment) {\r
-        InComment         = FALSE;\r
-        SlashSlashComment = FALSE;\r
-      }\r
-    } else if (SourceFile->FileBufferPtr[0] == T_CHAR_CR) {\r
-      //\r
-      // Replace all carriage returns with a NULL so we can print stuff\r
-      //\r
-      SourceFile->FileBufferPtr[0] = 0;\r
-      SourceFile->FileBufferPtr++;\r
-      //\r
-      // Check for */ comment end\r
-      //\r
-    } else if (InComment &&\r
-             !SlashSlashComment &&\r
-             (SourceFile->FileBufferPtr[0] == T_CHAR_STAR) &&\r
-             (SourceFile->FileBufferPtr[1] == T_CHAR_SLASH)\r
-            ) {\r
-      SourceFile->FileBufferPtr[0] = T_CHAR_SPACE;\r
-      SourceFile->FileBufferPtr++;\r
-      SourceFile->FileBufferPtr[0] = T_CHAR_SPACE;\r
-      SourceFile->FileBufferPtr++;\r
-      InComment = FALSE;\r
-    } else if (InComment) {\r
-      SourceFile->FileBufferPtr[0] = T_CHAR_SPACE;\r
-      SourceFile->FileBufferPtr++;\r
-      //\r
-      // Check for // comments\r
-      //\r
-    } else if ((SourceFile->FileBufferPtr[0] == T_CHAR_SLASH) && (SourceFile->FileBufferPtr[1] == T_CHAR_SLASH)) {\r
-      InComment         = TRUE;\r
-      SlashSlashComment = TRUE;\r
-      //\r
-      // Check for /* comment start\r
-      //\r
-    } else if ((SourceFile->FileBufferPtr[0] == T_CHAR_SLASH) && (SourceFile->FileBufferPtr[1] == T_CHAR_STAR)) {\r
-      SourceFile->FileBufferPtr[0] = T_CHAR_SPACE;\r
-      SourceFile->FileBufferPtr++;\r
-      SourceFile->FileBufferPtr[0] = T_CHAR_SPACE;\r
-      SourceFile->FileBufferPtr++;\r
-      SlashSlashComment = FALSE;\r
-      InComment         = TRUE;\r
-    } else {\r
-      SourceFile->FileBufferPtr++;\r
-    }\r
-  }\r
-  //\r
-  // Could check for end-of-file and still in a comment, but\r
-  // should not be necessary. So just restore the file pointers.\r
-  //\r
-  RewindFile (SourceFile);\r
-  //\r
-  // Dump the reformatted file if verbose mode\r
-  //\r
-  if (mGlobals.VerboseFile) {\r
-    LineNum = 1;\r
-    printf ("%04d: ", LineNum);\r
-    while (!EndOfFile (SourceFile)) {\r
-      if (SourceFile->FileBufferPtr[0] == T_CHAR_LF) {\r
-        printf ("'\n%04d: '", ++LineNum);\r
-      } else {\r
-        printf ("%c", SourceFile->FileBufferPtr[0]);\r
-      }\r
-\r
-      SourceFile->FileBufferPtr++;\r
-    }\r
-\r
-    printf ("'\n");\r
-    printf ("FileSize = %d (0x%X)\n", SourceFile->FileSize, SourceFile->FileSize);\r
-    RewindFile (SourceFile);\r
-  }\r
-}\r
-\r
-BOOLEAN\r
-SFPGetQuotedString (\r
-  T_CHAR      *Str,\r
-  int         Length\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Retrieve a quoted-string from the input file. \r
-  \r
-Arguments:\r
-  Str    - pointer to a copy of the quoted string parsed\r
-  Length - size of buffer pointed to by Str\r
-\r
-Returns:\r
-  TRUE    - next token in input stream was a quoted string, and\r
-            the string value was returned in Str\r
-  FALSE   - otherwise\r
-  \r
---*/\r
-{\r
-  SkipWhiteSpace (&mGlobals.SourceFile);\r
-  if (EndOfFile (&mGlobals.SourceFile)) {\r
-    return FALSE;\r
-  }\r
-\r
-  if (mGlobals.SourceFile.FileBufferPtr[0] == T_CHAR_DOUBLE_QUOTE) {\r
-    mGlobals.SourceFile.FileBufferPtr++;\r
-    while (Length > 0) {\r
-      if (EndOfFile (&mGlobals.SourceFile)) {\r
-        return FALSE;\r
-      }\r
-      //\r
-      // Check for closing quote\r
-      //\r
-      if (mGlobals.SourceFile.FileBufferPtr[0] == T_CHAR_DOUBLE_QUOTE) {\r
-        mGlobals.SourceFile.FileBufferPtr++;\r
-        *Str = 0;\r
-        return TRUE;\r
-      }\r
-\r
-      *Str = mGlobals.SourceFile.FileBufferPtr[0];\r
-      Str++;\r
-      Length--;\r
-      mGlobals.SourceFile.FileBufferPtr++;\r
-    }\r
-  }\r
-  //\r
-  // First character was not a quote, or the input string length was\r
-  // insufficient to contain the quoted string, so return failure code.\r
-  //\r
-  return FALSE;\r
-}\r
-\r
-BOOLEAN\r
-SFPIsEOF (\r
-  VOID\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Return TRUE of FALSE to indicate whether or not we've reached the end of the\r
-  file we're parsing.\r
-  \r
-Arguments:\r
-  NA\r
-\r
-Returns:\r
-  TRUE    - EOF reached\r
-  FALSE   - otherwise\r
-  \r
---*/\r
-{\r
-  SkipWhiteSpace (&mGlobals.SourceFile);\r
-  return EndOfFile (&mGlobals.SourceFile);\r
-}\r
-\r
-#if 0\r
-static\r
-T_CHAR *\r
-GetQuotedString (\r
-  SOURCE_FILE *SourceFile,\r
-  BOOLEAN     Optional\r
-  )\r
-{\r
-  T_CHAR        *String;\r
-  T_CHAR        *Start;\r
-  T_CHAR        *Ptr;\r
-  unsigned int  Len;\r
-  BOOLEAN       PreviousBackslash;\r
-\r
-  if (SourceFile->FileBufferPtr[0] != T_CHAR_DOUBLE_QUOTE) {\r
-    if (Optional == FALSE) {\r
-      Error (SourceFile->FileName, SourceFile->LineNum, 0, "expected quoted string", "%S", SourceFile->FileBufferPtr);\r
-    }\r
-\r
-    return NULL;\r
-  }\r
-\r
-  Len = 0;\r
-  SourceFile->FileBufferPtr++;\r
-  Start             = Ptr = SourceFile->FileBufferPtr;\r
-  PreviousBackslash = FALSE;\r
-  while (!EndOfFile (SourceFile)) {\r
-    if ((SourceFile->FileBufferPtr[0] == T_CHAR_DOUBLE_QUOTE) && (PreviousBackslash == FALSE)) {\r
-      break;\r
-    } else if (SourceFile->FileBufferPtr[0] == T_CHAR_CR) {\r
-      Warning (SourceFile->FileName, SourceFile->LineNum, 0, "carriage return found in quoted string", "%S", Start);\r
-      PreviousBackslash = FALSE;\r
-    } else if (SourceFile->FileBufferPtr[0] == T_CHAR_BACKSLASH) {\r
-      PreviousBackslash = TRUE;\r
-    } else {\r
-      PreviousBackslash = FALSE;\r
-    }\r
-\r
-    SourceFile->FileBufferPtr++;\r
-    Len++;\r
-  }\r
-\r
-  if (SourceFile->FileBufferPtr[0] != T_CHAR_DOUBLE_QUOTE) {\r
-    Warning (SourceFile->FileName, SourceFile->LineNum, 0, "missing closing quote on string", "%S", Start);\r
-  } else {\r
-    SourceFile->FileBufferPtr++;\r
-  }\r
-  //\r
-  // Now allocate memory for the string and save it off\r
-  //\r
-  String = (T_CHAR *) malloc ((Len + 1) * sizeof (T_CHAR));\r
-  if (String == NULL) {\r
-    Error (NULL, 0, 0, "memory allocation failed", NULL);\r
-    return NULL;\r
-  }\r
-  //\r
-  // Copy the string from the file buffer to the local copy.\r
-  // We do no reformatting of it whatsoever at this point.\r
-  //\r
-  Ptr = String;\r
-  while (Len > 0) {\r
-    *Ptr = *Start;\r
-    Start++;\r
-    Ptr++;\r
-    Len--;\r
-  }\r
-\r
-  *Ptr = 0;\r
-  return String;\r
-}\r
-#endif\r
-static\r
-BOOLEAN\r
-EndOfFile (\r
-  SOURCE_FILE *SourceFile\r
-  )\r
-{\r
-  //\r
-  // The file buffer pointer will typically get updated before the End-of-file flag in the\r
-  // source file structure, so check it first.\r
-  //\r
-  if (SourceFile->FileBufferPtr >= SourceFile->FileBuffer + SourceFile->FileSize / sizeof (T_CHAR)) {\r
-    SourceFile->EndOfFile = TRUE;\r
-    return TRUE;\r
-  }\r
-\r
-  if (SourceFile->EndOfFile) {\r
-    return TRUE;\r
-  }\r
-\r
-  return FALSE;\r
-}\r
-\r
-#if 0\r
-static\r
-void\r
-ProcessTokenInclude (\r
-  SOURCE_FILE *SourceFile\r
-  )\r
-{\r
-  char          IncludeFileName[MAX_PATH];\r
-  char          *To;\r
-  unsigned int  Len;\r
-  BOOLEAN       ReportedError;\r
-  SOURCE_FILE   IncludedSourceFile;\r
-\r
-  ReportedError = FALSE;\r
-  if (SkipWhiteSpace (SourceFile) == 0) {\r
-    Warning (SourceFile->FileName, SourceFile->LineNum, 0, "expected whitespace following #include keyword", NULL);\r
-  }\r
-  //\r
-  // Should be quoted file name\r
-  //\r
-  if (SourceFile->FileBufferPtr[0] != T_CHAR_DOUBLE_QUOTE) {\r
-    Error (SourceFile->FileName, SourceFile->LineNum, 0, "expected quoted include file name", NULL);\r
-    goto FailDone;\r
-  }\r
-\r
-  SourceFile->FileBufferPtr++;\r
-  //\r
-  // Copy the filename as ascii to our local string\r
-  //\r
-  To  = IncludeFileName;\r
-  Len = 0;\r
-  while (!EndOfFile (SourceFile)) {\r
-    if ((SourceFile->FileBufferPtr[0] == T_CHAR_CR) || (SourceFile->FileBufferPtr[0] == T_CHAR_LF)) {\r
-      Error (SourceFile->FileName, SourceFile->LineNum, 0, "end-of-line found in quoted include file name", NULL);\r
-      goto FailDone;\r
-    }\r
-\r
-    if (SourceFile->FileBufferPtr[0] == T_CHAR_DOUBLE_QUOTE) {\r
-      SourceFile->FileBufferPtr++;\r
-      break;\r
-    }\r
-    //\r
-    // If too long, then report the error once and process until the closing quote\r
-    //\r
-    Len++;\r
-    if (!ReportedError && (Len >= sizeof (IncludeFileName))) {\r
-      Error (SourceFile->FileName, SourceFile->LineNum, 0, "length of include file name exceeds limit", NULL);\r
-      ReportedError = TRUE;\r
-    }\r
-\r
-    if (!ReportedError) {\r
-      *To = (T_CHAR) SourceFile->FileBufferPtr[0];\r
-      To++;\r
-    }\r
-\r
-    SourceFile->FileBufferPtr++;\r
-  }\r
-\r
-  if (!ReportedError) {\r
-    *To = 0;\r
-    memset ((char *) &IncludedSourceFile, 0, sizeof (SOURCE_FILE));\r
-    strcpy (IncludedSourceFile.FileName, IncludeFileName);\r
-    ProcessIncludeFile (&IncludedSourceFile, SourceFile);\r
-  }\r
-\r
-  return ;\r
-FailDone:\r
-  //\r
-  // Error recovery -- skip to next #\r
-  //\r
-  SourceFile->SkipToHash = TRUE;\r
-}\r
-#endif\r
-static\r
-BOOLEAN\r
-IsWhiteSpace (\r
-  SOURCE_FILE *SourceFile\r
-  )\r
-{\r
-  switch (*SourceFile->FileBufferPtr) {\r
-  case T_CHAR_NULL:\r
-  case T_CHAR_CR:\r
-  case T_CHAR_SPACE:\r
-  case T_CHAR_TAB:\r
-  case T_CHAR_LF:\r
-    return TRUE;\r
-\r
-  default:\r
-    return FALSE;\r
-  }\r
-}\r
-\r
-unsigned int\r
-SkipWhiteSpace (\r
-  SOURCE_FILE *SourceFile\r
-  )\r
-{\r
-  unsigned int  Count;\r
-\r
-  Count = 0;\r
-  while (!EndOfFile (SourceFile)) {\r
-    Count++;\r
-    switch (*SourceFile->FileBufferPtr) {\r
-    case T_CHAR_NULL:\r
-    case T_CHAR_CR:\r
-    case T_CHAR_SPACE:\r
-    case T_CHAR_TAB:\r
-      SourceFile->FileBufferPtr++;\r
-      break;\r
-\r
-    case T_CHAR_LF:\r
-      SourceFile->FileBufferPtr++;\r
-      SourceFile->LineNum++;\r
-      break;\r
-\r
-    default:\r
-      return Count - 1;\r
-    }\r
-  }\r
-  //\r
-  // Some tokens require trailing whitespace. If we're at the end of the\r
-  // file, then we count that as well.\r
-  //\r
-  if ((Count == 0) && (EndOfFile (SourceFile))) {\r
-    Count++;\r
-  }\r
-\r
-  return Count;\r
-}\r
-\r
-static\r
-unsigned int\r
-t_strcmp (\r
-  T_CHAR *Buffer,\r
-  T_CHAR *Str\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Compare two strings for equality. The string pointed to by 'Buffer' may or may not be null-terminated,\r
-  so only compare up to the length of Str.\r
-\r
-Arguments:\r
-  Buffer  - pointer to first (possibly not null-terminated) string\r
-  Str     - pointer to null-terminated string to compare to Buffer\r
-\r
-Returns:\r
-  Number of bytes matched if exact match\r
-  0 if Buffer does not start with Str\r
-\r
---*/\r
-{\r
-  unsigned int  Len;\r
-\r
-  Len = 0;\r
-  while (*Str && (*Str == *Buffer)) {\r
-    Buffer++;\r
-    Str++;\r
-    Len++;\r
-  }\r
-\r
-  if (*Str) {\r
-    return 0;\r
-  }\r
-\r
-  return Len;\r
-}\r
-\r
-static\r
-unsigned int\r
-t_strlen (\r
-  T_CHAR *Str\r
-  )\r
-{\r
-  unsigned int  Len;\r
-  Len = 0;\r
-  while (*Str) {\r
-    Len++;\r
-    Str++;\r
-  }\r
-\r
-  return Len;\r
-}\r
-\r
-static\r
-unsigned int\r
-t_strncmp (\r
-  T_CHAR *Str1,\r
-  T_CHAR *Str2,\r
-  int    Len\r
-  )\r
-{\r
-  while (Len > 0) {\r
-    if (*Str1 != *Str2) {\r
-      return Len;\r
-    }\r
-\r
-    Len--;\r
-    Str1++;\r
-    Str2++;\r
-  }\r
-\r
-  return 0;\r
-}\r
-\r
-static\r
-T_CHAR *\r
-t_strcpy (\r
-  T_CHAR *Dest,\r
-  T_CHAR *Src\r
-  )\r
-{\r
-  T_CHAR  *SaveDest;\r
-  SaveDest = Dest;\r
-  while (*Src) {\r
-    *Dest = *Src;\r
-    Dest++;\r
-    Src++;\r
-  }\r
-\r
-  *Dest = 0;\r
-  return SaveDest;\r
-}\r
-\r
-static\r
-void\r
-RewindFile (\r
-  SOURCE_FILE *SourceFile\r
-  )\r
-{\r
-  SourceFile->LineNum       = 1;\r
-  SourceFile->FileBufferPtr = SourceFile->FileBuffer;\r
-  SourceFile->EndOfFile     = 0;\r
-}\r
-\r
-static\r
-UINT32\r
-GetHexChars (\r
-  T_CHAR      *Buffer,\r
-  UINT32      BufferLen\r
-  )\r
-{\r
-  UINT32  Len;\r
-  Len = 0;\r
-  while (!EndOfFile (&mGlobals.SourceFile) && (BufferLen > 0)) {\r
-    if (isxdigit (mGlobals.SourceFile.FileBufferPtr[0])) {\r
-      *Buffer = mGlobals.SourceFile.FileBufferPtr[0];\r
-      Buffer++;\r
-      Len++;\r
-      BufferLen--;\r
-      mGlobals.SourceFile.FileBufferPtr++;\r
-    } else {\r
-      break;\r
-    }\r
-  }\r
-  //\r
-  // Null terminate if we can\r
-  //\r
-  if ((Len > 0) && (BufferLen > 0)) {\r
-    *Buffer = 0;\r
-  }\r
-\r
-  return Len;\r
-}\r
-\r
-BOOLEAN\r
-SFPGetGuid (\r
-  int         GuidStyle,\r
-  EFI_GUID    *Value\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Parse a GUID from the input stream. Stop when you discover white space.\r
-\r
-Arguments:\r
-  GuidStyle - Style of the following GUID token\r
-  Value     - pointer to EFI_GUID struct for output\r
-\r
-Returns:\r
-  TRUE  - GUID string parsed successfully\r
-  FALSE - otherwise\r
-\r
-  GUID styles\r
-    Style[0] 12345678-1234-5678-AAAA-BBBBCCCCDDDD\r
-\r
---*/\r
-{\r
-  UINT32        Value32;\r
-  UINT32        Index;\r
-  FILE_POSITION FPos;\r
-  T_CHAR        TempString[20];\r
-  T_CHAR        TempString2[3];\r
-  T_CHAR        *From;\r
-  T_CHAR        *To;\r
-  UINT32        Len;\r
-  BOOLEAN       Status;\r
-\r
-  Status = FALSE;\r
-  //\r
-  // Skip white space, then start parsing\r
-  //\r
-  SkipWhiteSpace (&mGlobals.SourceFile);\r
-  GetFilePosition (&FPos);\r
-  if (EndOfFile (&mGlobals.SourceFile)) {\r
-    return FALSE;\r
-  }\r
-\r
-  if (GuidStyle == PARSE_GUID_STYLE_5_FIELDS) {\r
-    //\r
-    // Style[0] 12345678-1234-5678-AAAA-BBBBCCCCDDDD\r
-    //\r
-    Len = GetHexChars (TempString, sizeof (TempString));\r
-    if ((Len == 0) || (Len > 8)) {\r
-      goto Done;\r
-    }\r
-\r
-    sscanf (TempString, "%x", &Value32);\r
-    Value->Data1 = Value32;\r
-    //\r
-    // Next two UINT16 fields\r
-    //\r
-    if (mGlobals.SourceFile.FileBufferPtr[0] != '-') {\r
-      goto Done;\r
-    }\r
-\r
-    mGlobals.SourceFile.FileBufferPtr++;\r
-    Len = GetHexChars (TempString, sizeof (TempString));\r
-    if ((Len == 0) || (Len > 4)) {\r
-      goto Done;\r
-    }\r
-\r
-    sscanf (TempString, "%x", &Value32);\r
-    Value->Data2 = (UINT16) Value32;\r
-\r
-    if (mGlobals.SourceFile.FileBufferPtr[0] != '-') {\r
-      goto Done;\r
-    }\r
-\r
-    mGlobals.SourceFile.FileBufferPtr++;\r
-    Len = GetHexChars (TempString, sizeof (TempString));\r
-    if ((Len == 0) || (Len > 4)) {\r
-      goto Done;\r
-    }\r
-\r
-    sscanf (TempString, "%x", &Value32);\r
-    Value->Data3 = (UINT16) Value32;\r
-    //\r
-    // Parse the "AAAA" as two bytes\r
-    //\r
-    if (mGlobals.SourceFile.FileBufferPtr[0] != '-') {\r
-      goto Done;\r
-    }\r
-\r
-    mGlobals.SourceFile.FileBufferPtr++;\r
-    Len = GetHexChars (TempString, sizeof (TempString));\r
-    if ((Len == 0) || (Len > 4)) {\r
-      goto Done;\r
-    }\r
-\r
-    sscanf (TempString, "%x", &Value32);\r
-    Value->Data4[0] = (UINT8) (Value32 >> 8);\r
-    Value->Data4[1] = (UINT8) Value32;\r
-    if (mGlobals.SourceFile.FileBufferPtr[0] != '-') {\r
-      goto Done;\r
-    }\r
-\r
-    mGlobals.SourceFile.FileBufferPtr++;\r
-    //\r
-    // Read the last 6 bytes of the GUID\r
-    //\r
-    //\r
-    Len = GetHexChars (TempString, sizeof (TempString));\r
-    if ((Len == 0) || (Len > 12)) {\r
-      goto Done;\r
-    }\r
-    //\r
-    // Insert leading 0's to make life easier\r
-    //\r
-    if (Len != 12) {\r
-      From            = TempString + Len - 1;\r
-      To              = TempString + 11;\r
-      TempString[12]  = 0;\r
-      while (From >= TempString) {\r
-        *To = *From;\r
-        To--;\r
-        From--;\r
-      }\r
-\r
-      while (To >= TempString) {\r
-        *To = '0';\r
-        To--;\r
-      }\r
-    }\r
-    //\r
-    // Now parse each byte\r
-    //\r
-    TempString2[2] = 0;\r
-    for (Index = 0; Index < 6; Index++) {\r
-      //\r
-      // Copy the two characters from the input string to something\r
-      // we can parse.\r
-      //\r
-      TempString2[0]  = TempString[Index * 2];\r
-      TempString2[1]  = TempString[Index * 2 + 1];\r
-      sscanf (TempString2, "%x", &Value32);\r
-      Value->Data4[Index + 2] = (UINT8) Value32;\r
-    }\r
-\r
-    Status = TRUE;\r
-  } else {\r
-    //\r
-    // Unsupported GUID style\r
-    //\r
-    return FALSE;\r
-  }\r
-\r
-Done:\r
-  if (Status == FALSE) {\r
-    SetFilePosition (&FPos);\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-static\r
-STATUS\r
-GetFilePosition (\r
-  FILE_POSITION *Fpos\r
-  )\r
-{\r
-  Fpos->FileBufferPtr = mGlobals.SourceFile.FileBufferPtr;\r
-  return STATUS_SUCCESS;\r
-}\r
-\r
-static\r
-STATUS\r
-SetFilePosition (\r
-  FILE_POSITION *Fpos\r
-  )\r
-{\r
-  //\r
-  // Should check range of pointer\r
-  //\r
-  mGlobals.SourceFile.FileBufferPtr = Fpos->FileBufferPtr;\r
-  return STATUS_SUCCESS;\r
-}\r
diff --git a/Tools/CodeTools/TianoTools/Common/SimpleFileParsing.h b/Tools/CodeTools/TianoTools/Common/SimpleFileParsing.h
deleted file mode 100644 (file)
index 7cf25a6..0000000
+++ /dev/null
@@ -1,120 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2004, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-Module Name:\r
-\r
-  SimpleFileParsing.h\r
-\r
-Abstract:\r
-\r
-  Function prototypes and defines for the simple file parsing routines.\r
-\r
---*/\r
-\r
-#ifndef _SIMPLE_FILE_PARSING_H_\r
-#define _SIMPLE_FILE_PARSING_H_\r
-\r
-#include <Common/UefiBaseTypes.h>\r
-\r
-#define T_CHAR  char\r
-\r
-STATUS\r
-SFPInit (\r
-  VOID\r
-  )\r
-;\r
-\r
-STATUS\r
-SFPOpenFile (\r
-  char    *FileName\r
-  )\r
-;\r
-\r
-BOOLEAN\r
-SFPIsKeyword (\r
-  T_CHAR *Str\r
-  )\r
-;\r
-\r
-BOOLEAN\r
-SFPIsToken (\r
-  T_CHAR *Str\r
-  )\r
-;\r
-\r
-BOOLEAN\r
-SFPGetNextToken (\r
-  T_CHAR        *Str,\r
-  unsigned int  Len\r
-  )\r
-;\r
-\r
-BOOLEAN\r
-SFPGetGuidToken (\r
-  T_CHAR *Str,\r
-  UINT32 Len\r
-  )\r
-;\r
-\r
-#define PARSE_GUID_STYLE_5_FIELDS 0\r
-\r
-BOOLEAN\r
-SFPGetGuid (\r
-  int         GuidStyle,\r
-  EFI_GUID    *Value\r
-  )\r
-;\r
-\r
-BOOLEAN\r
-SFPSkipToToken (\r
-  T_CHAR *Str\r
-  )\r
-;\r
-\r
-BOOLEAN\r
-SFPGetNumber (\r
-  unsigned int   *Value\r
-  )\r
-;\r
-\r
-BOOLEAN\r
-SFPGetQuotedString (\r
-  T_CHAR      *Str,\r
-  int         Length\r
-  )\r
-;\r
-\r
-BOOLEAN\r
-SFPIsEOF (\r
-  VOID\r
-  )\r
-;\r
-\r
-STATUS\r
-SFPCloseFile (\r
-  VOID\r
-  )\r
-;\r
-\r
-unsigned\r
-int\r
-SFPGetLineNumber (\r
-  VOID\r
-  )\r
-;\r
-\r
-T_CHAR  *\r
-SFPGetFileName (\r
-  VOID\r
-  )\r
-;\r
-\r
-#endif // #ifndef _SIMPLE_FILE_PARSING_H_\r
diff --git a/Tools/CodeTools/TianoTools/Common/WinNtInclude.h b/Tools/CodeTools/TianoTools/Common/WinNtInclude.h
deleted file mode 100644 (file)
index 80e45b4..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-/*--\r
-\r
-Copyright (c) 2006, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-Module Name:\r
-  WinNtInclude.h\r
-\r
-Abstract:\r
-  Include file for the WinNt Library\r
-\r
---*/\r
-\r
-#ifndef __WIN_NT_INCLUDE_H__\r
-#define __WIN_NT_INCLUDE_H__\r
-\r
-//\r
-// Win32 include files do not compile clean with /W4, so we use the warning\r
-// pragma to suppress the warnings for Win32 only. This way our code can stil\r
-// compile at /W4 (highest warning level) with /WX (warnings cause build\r
-// errors).\r
-//\r
-#pragma warning(disable : 4115)\r
-#pragma warning(disable : 4201)\r
-#pragma warning(disable : 4214)\r
-#pragma warning(disable : 4028)\r
-#pragma warning(disable : 4133)\r
-\r
-#define GUID  _WINNT_DUP_GUID_____\r
-#define _LIST_ENTRY  _WINNT_DUP_LIST_ENTRY_FORWARD\r
-#define LIST_ENTRY   _WINNT_DUP_LIST_ENTRY\r
-#define InterlockedIncrement _WINNT_DUP_InterlockedIncrement\r
-#define InterlockedDecrement _WINNT_DUP_InterlockedDecrement\r
-#define InterlockedCompareExchange64 _WINNT_DUP_InterlockedCompareExchange64\r
-#undef UNALIGNED\r
-#undef CONST\r
-#undef VOID\r
-\r
-#ifndef __GNUC__\r
-#include "windows.h"\r
-#endif\r
-\r
-#undef GUID\r
-#undef _LIST_ENTRY\r
-#undef LIST_ENTRY\r
-#undef InterlockedIncrement\r
-#undef InterlockedDecrement\r
-#undef InterlockedCompareExchange64\r
-#undef InterlockedCompareExchangePointer\r
-\r
-#define VOID void\r
-\r
-//\r
-// Prevent collisions with Windows API name macros that deal with Unicode/Not issues\r
-//\r
-#undef LoadImage\r
-#undef CreateEvent\r
-\r
-//\r
-// Set the warnings back on as the EFI code must be /W4.\r
-//\r
-#pragma warning(default : 4115)\r
-#pragma warning(default : 4201)\r
-#pragma warning(default : 4214)\r
-\r
-\r
-#endif\r
diff --git a/Tools/CodeTools/TianoTools/Common/build.xml b/Tools/CodeTools/TianoTools/Common/build.xml
deleted file mode 100644 (file)
index 902f677..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-<?xml version="1.0" ?>\r
-<!--\r
-Copyright (c) 2006, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
--->\r
-<project default="CommonTools.lib" basedir=".">\r
-<!--\r
-    EDK Common Tools Library\r
-  Copyright (c) 2006, Intel Corporation\r
--->\r
-\r
-  <taskdef resource="cpptasks.tasks"/>\r
-  <typedef resource="cpptasks.types"/>\r
-  <taskdef resource="net/sf/antcontrib/antlib.xml"/>\r
-\r
-  <property name="tmp" value="tmp"/>\r
-  <property name="LibName" value="CommonTool"/>\r
-\r
-  <property name="LINK_OUTPUT_TYPE" value="static"/>\r
-  <property name="BUILD_DIR" value="${PACKAGE_DIR}/Common/tmp"/>\r
-\r
-  <target name="CommonTools.lib" depends="init, ToolsLibrary">\r
-    <echo message="The EDK Tool Library: ${LibName} build has completed."/>\r
-  </target>\r
-\r
-  <target name="init">\r
-    <echo message="Building the EDK Tool Library: ${LibName}"/>\r
-    <mkdir dir="${BUILD_DIR}"/>\r
-  </target>\r
-\r
-  <target name="ToolsLibrary" depends="init">\r
-    <cc name="${ToolChain}" objdir="${BUILD_DIR}" \r
-        outfile="${LIB_DIR}/CommonTools"\r
-        outtype="static"\r
-        debug="true"\r
-        optimize="speed">\r
-      <compilerarg value="${ExtraArgus}" if="ExtraArgus" />\r
-      <compilerarg value="-fPIC" if="x86_64_linux"/>\r
-\r
-      <includepath path="${PACKAGE_DIR}/Include"/>\r
-      <includepath path="${PACKAGE_DIR}/Include/${HostArch}"/>\r
-\r
-      <fileset dir="${basedir}/Common" \r
-        includes="*.c" />\r
-    </cc>\r
-  </target>\r
-\r
-  <target name="clean">\r
-    <echo message="Removing Intermediate Files Only from ${BUILD_DIR}"/>  \r
-    <delete dir="${BUILD_DIR}"/>\r
-  </target>\r
-\r
-  <target name="cleanall">\r
-    <echo message="Removing Object Files and the Library: ${LibName}${ext_static}"/>  \r
-    <delete failonerror="false" quiet="true" includeEmptyDirs="true">\r
-      <fileset dir="${BUILD_DIR}"/>\r
-      <fileset file="${LIB_DIR}/${LibName}${ext_static}"/>\r
-    </delete>\r
-  </target>\r
-\r
-</project>\r
diff --git a/Tools/CodeTools/TianoTools/CompressDll/CompressDll.c b/Tools/CodeTools/TianoTools/CompressDll/CompressDll.c
deleted file mode 100644 (file)
index cc06f26..0000000
+++ /dev/null
@@ -1,105 +0,0 @@
-/** @file\r
-  Compression DLL used by PCD Tools\r
-\r
-  Copyright (c) 2006, Intel Corporation   All rights reserved.\r
-  This program and the accompanying materials are licensed and made available \r
-  under the terms and conditions of the BSD License which accompanies this \r
-  distribution.  The full text of the license may be found at\r
-  http://opensource.org/licenses/bsd-license.php \r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-#if defined(__GNUC__)\r
-typedef long long __int64;/*For cygwin build*/\r
-#endif\r
-#include "CompressDll.h"\r
-#include "EfiCompress.h"\r
-\r
-extern\r
-EFI_STATUS\r
-Compress (\r
-  IN      UINT8   *SrcBuffer,\r
-  IN      UINT32  SrcSize,\r
-  IN      UINT8   *DstBuffer,\r
-  IN OUT  UINT32  *DstSize\r
-  );\r
-  \r
-JNIEXPORT jbyteArray JNICALL  Java_org_tianocore_framework_tasks_Compress_CallCompress \r
-(JNIEnv *env, jobject obj, jbyteArray SourceBuffer, jint SourceSize, jstring path)\r
-{\r
-  char*          DestBuffer;\r
-  int            DestSize;   \r
-  int            Result;\r
-  char           *InputBuffer;\r
-  jbyteArray     OutputBuffer;\r
-  jbyte          *TempByte;\r
-  \r
-  DestSize   = 0;\r
-  DestBuffer = NULL;\r
-  \r
-  TempByte = (*env)->GetByteArrayElements(env, SourceBuffer, 0);\r
-  InputBuffer = (char*) TempByte;\r
-\r
-  \r
-   //\r
-   //  First call compress function and get need buffer size\r
-   //\r
-\r
-   Result = Compress (\r
-        (char*) InputBuffer, \r
-        SourceSize,  \r
-        DestBuffer,\r
-        &DestSize\r
-        );\r
-\r
-   if (Result = EFI_BUFFER_TOO_SMALL) {\r
-     DestBuffer = malloc (DestSize);\r
-   }\r
-\r
-   //\r
-   //  Second call compress and get the DestBuffer value\r
-   //\r
-   Result = Compress(\r
-              (char*) InputBuffer, \r
-        SourceSize,  \r
-        DestBuffer,\r
-        &DestSize  \r
-     );\r
-\r
-   //\r
-   // new a MV array to store the return compressed buffer\r
-   //\r
-   OutputBuffer = (*env)->NewByteArray(env, DestSize);\r
-   (*env)->SetByteArrayRegion(env, OutputBuffer,0, DestSize, (jbyte*) DestBuffer);\r
-\r
-   //\r
-   // Free Ouputbuffer.\r
-   //\r
-   free (DestBuffer);\r
-  \r
-\r
-  if (Result != 0) {\r
-    return NULL;\r
-  } else {\r
-    return OutputBuffer;\r
-  }\r
-}\r
-\r
-#ifdef _MSC_VER\r
-BOOLEAN \r
-__stdcall \r
-DllMainCRTStartup(\r
-    unsigned int hDllHandle, \r
-    unsigned int nReason,    \r
-    void*   Reserved    \r
-)\r
-{\r
-  return TRUE;\r
-}\r
-#else\r
-#ifdef __GNUC__\r
-#endif\r
-#endif\r
-\r
diff --git a/Tools/CodeTools/TianoTools/CompressDll/CompressDll.h b/Tools/CodeTools/TianoTools/CompressDll/CompressDll.h
deleted file mode 100644 (file)
index fa3b83c..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/* DO NOT EDIT THIS FILE - it is machine generated */\r
-\r
-#include <jni.h>\r
-/* Header for class org_tianocore_frameworktasks_Compress */\r
-\r
-#ifndef _Included_org_tianocore_framework_tasks_Compress\r
-#define _Included_org_tianocore_framework_tasks_Compress\r
-#ifdef __cplusplus\r
-extern "C" {\r
-#endif\r
-/*\r
- * Class:     org_tianocore_frameworktasks_Compress\r
- * Method:    CallCompress\r
- * Signature: ([BILjava/lang/String;)[B\r
- */\r
-JNIEXPORT jbyteArray JNICALL Java_org_tianocore_framework_tasks_Compress_CallCompress\r
-  (JNIEnv *, jobject, jbyteArray, jint, jstring);\r
-\r
-#ifdef __cplusplus\r
-}\r
-#endif\r
-#endif\r
diff --git a/Tools/CodeTools/TianoTools/CompressDll/build.xml b/Tools/CodeTools/TianoTools/CompressDll/build.xml
deleted file mode 100644 (file)
index 5043d12..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>\r
-<!--\r
-Copyright (c) 2006, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
--->\r
-<project default="GenTool" basedir=".">\r
-<!--\r
-    EDK CompressDll Tool Library\r
-  Copyright (c) 2006, Intel Corporation\r
--->\r
-\r
-  <property name="WORKSPACE" value="${env.WORKSPACE}"/>\r
-  <property name="LibName" value="CompressDll"/>\r
-  <property name="FileSet" value="CompressDll.c CompressDll.h"/>\r
-  <property name="LibFileSet" value="CompressDll.c DepexParser.h"/>\r
-\r
-  <taskdef resource="cpptasks.tasks"/>\r
-  <typedef resource="cpptasks.types"/>\r
-  <taskdef resource="net/sf/antcontrib/antlib.xml"/>\r
-\r
-  <property name="LINK_OUTPUT_TYPE" value="static"/>\r
-  <property name="BUILD_DIR" value="${WORKSPACE}/Tools/Source/TianoTools/${LibName}/tmp"/>\r
-\r
-  <target name="GenTool" depends="init,Lib" >\r
-    <echo message="The EDK Tool Library: ${LibName} build has completed!"/>\r
-  </target>\r
-\r
-  <target name="init">\r
-    <echo message="Building the EDK Tool Library: ${LibName}"/>\r
-    <mkdir dir="${BUILD_DIR}"/>\r
-  </target>\r
-  \r
-  <target name="Lib" depends="init">\r
-    <cc name="${ToolChain}" \r
-      objdir="${BUILD_DIR}" \r
-      outtype="shared" \r
-      debug="true"\r
-      optimize="speed" \r
-      outfile="${BIN_DIR}/${LibName}"\r
-      outputfileproperty="result"\r
-      >\r
-      <compilerarg value="${ExtraArgus}" if="ExtraArgus" />\r
-      <fileset dir="${LibName}" includes="${LibFileSet}" defaultexcludes="TRUE" excludes="*.xml *.inf"/>\r
-      <includepath path="${PACKAGE_DIR}/Include"/>\r
-      <includepath path="${PACKAGE_DIR}/Include/${HostArch}"/>\r
-      <includepath path="${PACKAGE_DIR}/Common"/>\r
-      <includepath path="${env.JAVA_HOME}/include"/>\r
-      <includepath path="${env.JAVA_HOME}/include/linux" if="gcc"/>\r
-      <includepath path="${env.JAVA_HOME}/include/win32" if="cygwin"/>\r
-      <includepath path="${env.JAVA_HOME}/include/win32" if="msft"/>\r
-      <libset dir="${LIB_DIR}" libs="CommonTools"/>\r
-      <syslibset libs="kernel32" if="msft"/>\r
-      <linkerarg value="-mno-cygwin" if="cygwin"/>\r
-      <linkerarg value="--add-stdcall-alias" if="cygwin"/>\r
-    </cc>\r
-    <copy file="${result}" tofile="${BIN_DIR}/CompressDll.dll"/>\r
-    <chmod file="${BIN_DIR}/CompressDll.dll" perm="ugo+x"/>\r
-  </target>\r
-\r
-  <target name="clean">\r
-    <echo message="Removing Intermediate Files Only"/>\r
-    <delete>\r
-      <fileset dir="${BUILD_DIR}" includes="*.obj"/>\r
-    </delete>\r
-  </target>\r
-\r
-  <target name="cleanall">\r
-    <echo message="Removing Object Files and the Executable: ${LibName}${ext_shared}"/>\r
-    <delete failonerror="false" quiet="true" includeEmptyDirs="true">\r
-      <fileset dir="${BUILD_DIR}"/>\r
-      <fileset file="${BIN_DIR}/${LibName}.*"/>\r
-    </delete>\r
-  </target>\r
-</project>\r
diff --git a/Tools/CodeTools/TianoTools/CreateMtFile/CreateMtFile.c b/Tools/CodeTools/TianoTools/CreateMtFile/CreateMtFile.c
deleted file mode 100644 (file)
index 1c17b3d..0000000
+++ /dev/null
@@ -1,247 +0,0 @@
-/*++\r
-\r
-Copyright (c)  1999-2006 Intel Corporation. All rights reserved\r
-This program and the accompanying materials are licensed and made available \r
-under the terms and conditions of the BSD License which accompanies this \r
-distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-\r
-Module Name:\r
-\r
-  CreateMtFile.c\r
-\r
-Abstract:\r
-\r
-  Simple utility to create a pad file containing fixed data.\r
-  \r
---*/\r
-\r
-#include <stdio.h>\r
-#include <string.h>\r
-#include <stdlib.h>\r
-\r
-#include <Common/UefiBaseTypes.h>\r
-\r
-#define PROGRAM_NAME  "CreateMtFile"\r
-\r
-typedef struct {\r
-  INT8    *OutFileName;\r
-  INT8    ByteValue;\r
-  UINT32  FileSize;\r
-} OPTIONS;\r
-\r
-static\r
-EFI_STATUS\r
-ProcessArgs (\r
-  IN INT32          Argc,\r
-  IN INT8           *Argv[],\r
-  IN OUT OPTIONS    *Options\r
-  );\r
-\r
-static\r
-void\r
-Usage (\r
-  VOID\r
-  );\r
-\r
-int\r
-main (\r
-  IN INT32  Argc,\r
-  IN INT8   *Argv[]\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  \r
-  Main entry point for this utility.\r
-\r
-Arguments:\r
-\r
-  Standard C entry point args Argc and Argv\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS if good to go\r
-\r
---*/\r
-// GC_TODO:    ] - add argument and description to function comment\r
-// GC_TODO:    EFI_INVALID_PARAMETER - add return value to function comment\r
-// GC_TODO:    EFI_DEVICE_ERROR - add return value to function comment\r
-// GC_TODO:    EFI_DEVICE_ERROR - add return value to function comment\r
-{\r
-  FILE    *OutFptr;\r
-  OPTIONS Options;\r
-\r
-  //\r
-  // Process the command-line arguments.\r
-  //\r
-  if (ProcessArgs (Argc, Argv, &Options) != EFI_SUCCESS) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-  //\r
-  // Open the output file\r
-  //\r
-  if ((OutFptr = fopen (Options.OutFileName, "wb")) == NULL) {\r
-    fprintf (\r
-      stdout,\r
-      PROGRAM_NAME " ERROR: Could not open output file '%s' for writing\n",\r
-      Options.OutFileName\r
-      );\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-  //\r
-  // Write the pad bytes. Do it the slow way (one at a time) for now.\r
-  //\r
-  while (Options.FileSize > 0) {\r
-    if (fwrite (&Options.ByteValue, 1, 1, OutFptr) != 1) {\r
-      fclose (OutFptr);\r
-      fprintf (stdout, PROGRAM_NAME " ERROR: Failed to write to output file\n");\r
-      return EFI_DEVICE_ERROR;\r
-    }\r
-\r
-    Options.FileSize--;\r
-  }\r
-  //\r
-  // Close the file\r
-  //\r
-  fclose (OutFptr);\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-static\r
-EFI_STATUS\r
-ProcessArgs (\r
-  IN INT32          Argc,\r
-  IN INT8           *Argv[],\r
-  IN OUT OPTIONS    *Options\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  \r
-  Process the command line arguments.\r
-\r
-Arguments:\r
-\r
-  Argc    - argument count as passed in to the entry point function\r
-  Argv    - array of arguments as passed in to the entry point function\r
-  Options - stucture of where to put the values of the parsed arguments\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS if everything looks good\r
-  EFI_INVALID_PARAMETER otherwise\r
-\r
---*/\r
-// GC_TODO:    ] - add argument and description to function comment\r
-{\r
-  UINT32  Multiplier;\r
-\r
-  //\r
-  // Clear the options\r
-  //\r
-  memset ((char *) Options, 0, sizeof (OPTIONS));\r
-\r
-  //\r
-  // Skip program name\r
-  //\r
-  Argv++;\r
-  Argc--;\r
-  if (Argc < 2) {\r
-    Usage ();\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-  //\r
-  // If first arg is dash-option, then print usage.\r
-  //\r
-  if (Argv[0][0] == '-') {\r
-    Usage ();\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-  //\r
-  // First arg is file name\r
-  //\r
-  Options->OutFileName = Argv[0];\r
-  Argc--;\r
-  Argv++;\r
-\r
-  //\r
-  // Second arg is file size. Allow 0x1000, 0x100K, 1024, 1K\r
-  //\r
-  Multiplier = 1;\r
-  if ((Argv[0][strlen (Argv[0]) - 1] == 'k') || (Argv[0][strlen (Argv[0]) - 1] == 'K')) {\r
-    Multiplier = 1024;\r
-  }\r
-  //\r
-  // Look for 0x prefix on file size\r
-  //\r
-  if ((Argv[0][0] == '0') && ((Argv[0][1] == 'x') || (Argv[0][1] == 'X'))) {\r
-    if (sscanf (Argv[0], "%x", &Options->FileSize) != 1) {\r
-      fprintf (stdout, PROGRAM_NAME " ERROR: Invalid file size '%s'\n", Argv[0]);\r
-      Usage ();\r
-      return EFI_INVALID_PARAMETER;\r
-    }\r
-    //\r
-    // Otherwise must be a decimal number\r
-    //\r
-  } else {\r
-    if (sscanf (Argv[0], "%d", &Options->FileSize) != 1) {\r
-      fprintf (stdout, PROGRAM_NAME " ERROR: Invalid file size '%s'\n", Argv[0]);\r
-      Usage ();\r
-      return EFI_INVALID_PARAMETER;\r
-    }\r
-  }\r
-\r
-  Options->FileSize *= Multiplier;\r
-  //\r
-  // Assume byte value of 0xff\r
-  //\r
-  Options->ByteValue = (INT8) (UINT8) 0xFF;\r
-  return EFI_SUCCESS;\r
-}\r
-//\r
-// Print utility usage info\r
-//\r
-static\r
-void\r
-Usage (\r
-  VOID\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  None\r
-\r
-Returns:\r
-\r
-  GC_TODO: add return values\r
-\r
---*/\r
-{\r
-  UINT32            Index;\r
-  static const INT8 *Text[] = {\r
-    " ",\r
-    "Usage:  "PROGRAM_NAME " OutFileName FileSize",\r
-    "  where:",\r
-    "    OutFileName is the name of the output file to generate",\r
-    "    FileSize is the size of the file to create",\r
-    "  Examples:",\r
-    "    "PROGRAM_NAME " OutFile.bin 32K",\r
-    "    "PROGRAM_NAME " OutFile.bin 0x1000",\r
-    " ",\r
-    NULL\r
-  };\r
-\r
-  for (Index = 0; Text[Index] != NULL; Index++) {\r
-    fprintf (stdout, "%s\n", Text[Index]);\r
-  }\r
-}\r
diff --git a/Tools/CodeTools/TianoTools/CreateMtFile/build.xml b/Tools/CodeTools/TianoTools/CreateMtFile/build.xml
deleted file mode 100644 (file)
index b227224..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-<?xml version="1.0" ?>\r
-<!--\r
-Copyright (c) 2006, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
--->\r
-<project default="GenTool" basedir=".">\r
-<!--\r
-    EDK CreateMtFile Tool\r
-  Copyright (c) 2006, Intel Corporation\r
--->\r
-  <property name="ToolName" value="CreateMtFile"/>\r
-  <property name="FileSet" value="*.c"/>\r
-\r
-  <taskdef resource="cpptasks.tasks"/>\r
-  <typedef resource="cpptasks.types"/>\r
-  <taskdef resource="net/sf/antcontrib/antlib.xml"/>\r
-\r
-  <property name="LINK_OUTPUT_TYPE" value="static"/>\r
-  <property name="BUILD_DIR" value="${PACKAGE_DIR}/${ToolName}/tmp"/>\r
-\r
-  <target name="GenTool" depends="init, Tool">\r
-    <echo message="The EDK Tool: ${ToolName} build has completed!"/>\r
-  </target>\r
-\r
-  <target name="init">\r
-    <echo message="Building the EDK Tool: ${ToolName}"/>\r
-    <mkdir dir="${BUILD_DIR}"/>\r
-  </target>\r
-\r
-  <target name="Tool" depends="init">\r
-    <cc name="${ToolChain}" objdir="${BUILD_DIR}" \r
-        outfile="${BIN_DIR}/${ToolName}"\r
-        outtype="executable"\r
-        optimize="speed" \r
-        debug="true">\r
-      <compilerarg value="${ExtraArgus}" if="ExtraArgus" />\r
-\r
-      <fileset dir="${basedir}/${ToolName}" \r
-        includes="${FileSet}" \r
-        defaultexcludes="TRUE" \r
-        excludes="*.xml *.inf"/>\r
-\r
-      <includepath path="${PACKAGE_DIR}/Include"/>\r
-      <includepath path="${PACKAGE_DIR}/Include/Ia32"/>\r
-      <includepath path="${PACKAGE_DIR}/Common"/>\r
-    </cc>\r
-  </target>\r
-\r
-  <target name="clean">\r
-    <echo message="Removing Intermediate Files Only"/>  \r
-    <delete>\r
-      <fileset dir="${BUILD_DIR}" includes="*.obj"/>\r
-    </delete>\r
-  </target>\r
-\r
-  <target name="cleanall">\r
-    <echo message="Removing Object Files and the Executable: ${ToolName}${ext_exe}"/>  \r
-    <delete failonerror="false" quiet="true" includeEmptyDirs="true">\r
-      <fileset dir="${BUILD_DIR}"/>\r
-      <fileset file="${BIN_DIR}/${ToolName}${ext_exe}"/>\r
-    </delete>\r
-  </target>\r
-\r
-</project>\r
diff --git a/Tools/CodeTools/TianoTools/CustomizedCompress/CustomizedCompress.c b/Tools/CodeTools/TianoTools/CustomizedCompress/CustomizedCompress.c
deleted file mode 100644 (file)
index 0dc6612..0000000
+++ /dev/null
@@ -1,146 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2004, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-Module Name:\r
-  \r
-  CustomizedCompress.c\r
-\r
-Abstract:\r
-\r
-  Header file for Customized compression routine\r
-  \r
---*/\r
-\r
-#include <Common/UefiBaseTypes.h>\r
-\r
-EFI_STATUS\r
-SetCustomizedCompressionType (\r
-  IN  CHAR8   *Type\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-The implementation of Customized SetCompressionType().\r
-\r
-Arguments:\r
-  Type        - The type if compression.\r
-    \r
-Returns:\r
-    \r
-  EFI_SUCCESS           - The type has been set.\r
-  EFI_UNSUPPORTED       - This type is unsupported.\r
-\r
-    \r
---*/\r
-{\r
-  return EFI_UNSUPPORTED;\r
-}\r
-\r
-EFI_STATUS\r
-CustomizedGetInfo (\r
-  IN      VOID    *Source,\r
-  IN      UINT32  SrcSize,\r
-  OUT     UINT32  *DstSize,\r
-  OUT     UINT32  *ScratchSize\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-The implementation of Customized GetInfo().\r
-\r
-Arguments:\r
-  Source      - The source buffer containing the compressed data.\r
-  SrcSize     - The size of source buffer\r
-  DstSize     - The size of destination buffer.\r
-  ScratchSize - The size of scratch buffer.\r
-    \r
-Returns:\r
-    \r
-  EFI_SUCCESS           - The size of destination buffer and the size of scratch buffer are successull retrieved.\r
-  EFI_INVALID_PARAMETER - The source data is corrupted\r
-  EFI_UNSUPPORTED       - The operation is unsupported.\r
-\r
-    \r
---*/\r
-{\r
-  return EFI_UNSUPPORTED;\r
-}\r
-\r
-EFI_STATUS\r
-CustomizedDecompress (\r
-  IN      VOID    *Source,\r
-  IN      UINT32  SrcSize,\r
-  IN OUT  VOID    *Destination,\r
-  IN      UINT32  DstSize,\r
-  IN OUT  VOID    *Scratch,\r
-  IN      UINT32  ScratchSize\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  The implementation of Customized Decompress().\r
-\r
-Arguments:\r
-\r
-  This        - The protocol instance pointer\r
-  Source      - The source buffer containing the compressed data.\r
-  SrcSize     - The size of source buffer\r
-  Destination - The destination buffer to store the decompressed data\r
-  DstSize     - The size of destination buffer.\r
-  Scratch     - The buffer used internally by the decompress routine. This  buffer is needed to store intermediate data.\r
-  ScratchSize - The size of scratch buffer.\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS           - Decompression is successfull\r
-  EFI_INVALID_PARAMETER - The source data is corrupted\r
-  EFI_UNSUPPORTED       - The operation is unsupported.\r
-\r
---*/\r
-{\r
-  return EFI_UNSUPPORTED;\r
-}\r
-\r
-EFI_STATUS\r
-CustomizedCompress (\r
-  IN      UINT8   *SrcBuffer,\r
-  IN      UINT32  SrcSize,\r
-  IN      UINT8   *DstBuffer,\r
-  IN OUT  UINT32  *DstSize\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  The Customized compression routine.\r
-\r
-Arguments:\r
-\r
-  SrcBuffer   - The buffer storing the source data\r
-  SrcSize     - The size of source data\r
-  DstBuffer   - The buffer to store the compressed data\r
-  DstSize     - On input, the size of DstBuffer; On output,\r
-                the size of the actual compressed data.\r
-\r
-Returns:\r
-\r
-  EFI_BUFFER_TOO_SMALL  - The DstBuffer is too small. In this case,\r
-                DstSize contains the size needed.\r
-  EFI_SUCCESS           - Compression is successful.\r
-\r
-  EFI_UNSUPPORTED       - The operation is unsupported.\r
---*/\r
-{\r
-  return EFI_UNSUPPORTED;\r
-}\r
diff --git a/Tools/CodeTools/TianoTools/CustomizedCompress/build.xml b/Tools/CodeTools/TianoTools/CustomizedCompress/build.xml
deleted file mode 100644 (file)
index 4664a95..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-<?xml version="1.0" ?>\r
-<!--\r
-Copyright (c) 2006, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
--->\r
-<project default="GenLib" basedir="." name="CustomizedCompressLibrary">\r
-<!--\r
-    EDK Customized Compress Library\r
-  Copyright (c) 2006, Intel Corporation\r
--->\r
-\r
-  <taskdef resource="cpptasks.tasks"/>\r
-  <typedef resource="cpptasks.types"/>\r
-  <taskdef resource="net/sf/antcontrib/antlib.xml"/>\r
-\r
-  <property name="LibName" value="CustomizedCompress"/>\r
-  <property name="LINK_OUTPUT_TYPE" value="static"/>\r
-  <property name="BUILD_DIR" value="${PACKAGE_DIR}/CustomizedCompress/tmp"/>\r
-\r
-  <target name="GenLib" depends="init, CustomizedCompress">\r
-    <echo message="The EDK Tool Library ${LibName} build has completed!"/>\r
-  </target>\r
-\r
-  <target name="init">\r
-    <echo message="Building the EDK Tool Library: ${LibName}"/>\r
-    <mkdir dir="${BUILD_DIR}"/>\r
-  </target>\r
-\r
-  <target name="CustomizedCompress" depends="init">\r
-    <cc name="${ToolChain}" objdir="${BUILD_DIR}" \r
-        outfile="${LIB_DIR}/${LibName}"\r
-        outtype="static"\r
-        debug="true"\r
-        optimize="speed">\r
-\r
-      <fileset dir="${basedir}/CustomizedCompress" \r
-        includes="*.c" \r
-        defaultexcludes="TRUE" \r
-        excludes="*.xml *.inf"/>\r
-\r
-      <includepath path="${PACKAGE_DIR}/Include"/>\r
-      <includepath path="${PACKAGE_DIR}/Include/Ia32"/>\r
-    </cc>\r
-    <if>\r
-      <istrue value="msft"/>\r
-      <then>\r
-        <exec dir="${BUILD_DIR}" executable="lib" failonerror="false">\r
-          <arg line="/NOLOGO *.lib /OUT:${LIB_DIR}/CustomizedCompress${ext_static}"/>\r
-        </exec>\r
-      </then>\r
-    </if>\r
-  </target>\r
-\r
-  <target name="clean">\r
-    <echo message="Removing Intermediate Files Only"/>  \r
-    <delete>\r
-      <fileset dir="${BUILD_DIR}" includes="*.obj"/>\r
-    </delete>\r
-  </target>\r
-\r
-  <target name="cleanall">\r
-    <echo message="Removing Object Files and the Library: ${LibName}${ext_static}"/>  \r
-    <delete failonerror="false" quiet="true" includeEmptyDirs="true">\r
-      <fileset dir="${BUILD_DIR}"/>\r
-      <fileset file="${LIB_DIR}/${LibName}${ext_static}"/>\r
-    </delete>\r
-  </target>\r
-\r
-</project>\r
diff --git a/Tools/CodeTools/TianoTools/EfiCompress/EfiCompressMain.c b/Tools/CodeTools/TianoTools/EfiCompress/EfiCompressMain.c
deleted file mode 100644 (file)
index 492210f..0000000
+++ /dev/null
@@ -1,165 +0,0 @@
-/*++\r
-\r
-Copyright (c)  1999-2006 Intel Corporation. All rights reserved\r
-This program and the accompanying materials are licensed and made available \r
-under the terms and conditions of the BSD License which accompanies this \r
-distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-\r
-Module Name:\r
-  \r
-  EfiCompressMain.c\r
-\r
-Abstract:\r
-\r
-  The main function for the compression utility.\r
-  \r
---*/\r
-\r
-#include <stdlib.h>\r
-#include <string.h>\r
-#include <ctype.h>\r
-#include <stdarg.h>\r
-#include <stdio.h>\r
-\r
-#include <Common/UefiBaseTypes.h>\r
-\r
-#include "EfiCompress.h"\r
-\r
-int\r
-main (\r
-  INT32 argc,\r
-  CHAR8 *argv[]\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Compresses the input files\r
-\r
-Arguments:\r
-\r
-  argc   - number of arguments passed into the command line.\r
-  argv[] - files to compress and files to output compressed data to.\r
-\r
-Returns:\r
-\r
-  int: 0 for successful execution of the function.\r
-\r
---*/\r
-{\r
-  EFI_STATUS  Status;\r
-  FILE        *infile;\r
-  FILE        *outfile;\r
-  UINT32      SrcSize;\r
-  UINT32      DstSize;\r
-  UINT8       *SrcBuffer;\r
-  UINT8       *DstBuffer;\r
-  UINT8       Buffer[8];\r
-\r
-  //\r
-  //  Added for makefile debug - KCE\r
-  //\r
-  INT32       arg_counter;\r
-  printf ("\n\n");\r
-  for (arg_counter = 0; arg_counter < argc; arg_counter++) {\r
-    printf ("%s ", argv[arg_counter]);\r
-  }\r
-\r
-  printf ("\n\n");\r
-\r
-  SrcBuffer             = DstBuffer = NULL;\r
-\r
-  infile                = outfile = NULL;\r
-\r
-  if (argc != 3) {\r
-    printf ("Usage: EFICOMPRESS <infile> <outfile>\n");\r
-    goto Done;\r
-  }\r
-\r
-  if ((outfile = fopen (argv[2], "wb")) == NULL) {\r
-    printf ("Can't open output file\n");\r
-    goto Done;\r
-  }\r
-\r
-  if ((infile = fopen (argv[1], "rb")) == NULL) {\r
-    printf ("Can't open input file\n");\r
-    goto Done;\r
-  }\r
-  //\r
-  // Get the size of source file\r
-  //\r
-  SrcSize = 0;\r
-  while (fread (Buffer, 1, 1, infile)) {\r
-    SrcSize++;\r
-\r
-  }\r
-  //\r
-  // Read in the source data\r
-  //\r
-  if ((SrcBuffer = malloc (SrcSize)) == NULL) {\r
-    printf ("Can't allocate memory\n");\r
-    goto Done;\r
-  }\r
-\r
-  rewind (infile);\r
-  if (fread (SrcBuffer, 1, SrcSize, infile) != SrcSize) {\r
-    printf ("Can't read from source\n");\r
-    goto Done;\r
-  }\r
-  //\r
-  // Get destination data size and do the compression\r
-  //\r
-  DstSize = 0;\r
-  Status  = Compress (SrcBuffer, SrcSize, DstBuffer, &DstSize);\r
-  if (Status == EFI_BUFFER_TOO_SMALL) {\r
-    if ((DstBuffer = malloc (DstSize)) == NULL) {\r
-      printf ("Can't allocate memory\n");\r
-      goto Done;\r
-    }\r
-\r
-    Status = Compress (SrcBuffer, SrcSize, DstBuffer, &DstSize);\r
-  }\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    printf ("Compress Error\n");\r
-    goto Done;\r
-  }\r
-\r
-  printf ("\nOrig Size = %ld\n", SrcSize);\r
-  printf ("Comp Size = %ld\n", DstSize);\r
-\r
-  if (DstBuffer == NULL) {\r
-    printf ("No destination to write to.\n");\r
-    goto Done;\r
-  }\r
-  //\r
-  // Write out the result\r
-  //\r
-  if (fwrite (DstBuffer, 1, DstSize, outfile) != DstSize) {\r
-    printf ("Can't write to destination file\n");\r
-  }\r
-\r
-Done:\r
-  if (SrcBuffer) {\r
-    free (SrcBuffer);\r
-  }\r
-\r
-  if (DstBuffer) {\r
-    free (DstBuffer);\r
-  }\r
-\r
-  if (infile) {\r
-    fclose (infile);\r
-  }\r
-\r
-  if (outfile) {\r
-    fclose (outfile);\r
-  }\r
-\r
-  return 0;\r
-}\r
diff --git a/Tools/CodeTools/TianoTools/EfiCompress/build.xml b/Tools/CodeTools/TianoTools/EfiCompress/build.xml
deleted file mode 100644 (file)
index 94f6055..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-<?xml version="1.0" ?>\r
-<!--\r
-Copyright (c) 2006, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
--->\r
-<project default="GenTool" basedir=".">\r
-<!--\r
-    EDK EfiCompress Tool\r
-  Copyright (c) 2006, Intel Corporation\r
--->\r
-  <property name="ToolName" value="EfiCompress"/>\r
-  <property name="FileSet" value="*.c"/>\r
-\r
-  <taskdef resource="cpptasks.tasks"/>\r
-  <typedef resource="cpptasks.types"/>\r
-  <taskdef resource="net/sf/antcontrib/antlib.xml"/>\r
-\r
-  <property name="LINK_OUTPUT_TYPE" value="static"/>\r
-  <property name="BUILD_DIR" value="${PACKAGE_DIR}/${ToolName}/tmp"/>\r
-\r
-  <target name="GenTool" depends="init, Tool">\r
-    <echo message="The EDK Tool: ${ToolName} build has completed!"/>\r
-  </target>\r
-\r
-  <target name="init">\r
-    <echo message="Building the EDK Tool: ${ToolName}"/>\r
-    <mkdir dir="${BUILD_DIR}"/>\r
-  </target>\r
-\r
-  <target name="Tool" depends="init">\r
-    <cc name="${ToolChain}" objdir="${BUILD_DIR}" \r
-        outfile="${BIN_DIR}/${ToolName}"\r
-        outtype="executable"\r
-        optimize="speed" \r
-        debug="true">\r
-\r
-      <fileset dir="${basedir}/${ToolName}" \r
-        includes="${FileSet}" \r
-        defaultexcludes="TRUE" \r
-        excludes="*.xml *.inf"/>\r
-\r
-      <includepath path="${PACKAGE_DIR}/Include"/>\r
-      <includepath path="${PACKAGE_DIR}/Include/${HostArch}"/>\r
-      <includepath path="${PACKAGE_DIR}/Common"/>\r
-      <libset dir="${LIB_DIR}" libs="CommonTools"/>\r
-    </cc>\r
-  </target>\r
-\r
-  <target name="clean">\r
-    <echo message="Removing Intermediate Files Only"/>  \r
-    <delete>\r
-      <fileset dir="${BUILD_DIR}" includes="*.obj"/>\r
-    </delete>\r
-  </target>\r
-\r
-  <target name="cleanall">\r
-    <echo message="Removing Object Files and the Executable: ${ToolName}${ext_exe}"/>  \r
-    <delete failonerror="false" quiet="true" includeEmptyDirs="true">\r
-      <fileset dir="${BUILD_DIR}"/>\r
-      <fileset file="${BIN_DIR}/${ToolName}${ext_exe}"/>\r
-    </delete>\r
-  </target>\r
-\r
-</project>\r
diff --git a/Tools/CodeTools/TianoTools/EfiRom/EfiRom.c b/Tools/CodeTools/TianoTools/EfiRom/EfiRom.c
deleted file mode 100644 (file)
index 2cc478b..0000000
+++ /dev/null
@@ -1,1536 +0,0 @@
-/*++\r
-\r
-Copyright (c)  1999-2006 Intel Corporation. All rights reserved\r
-This program and the accompanying materials are licensed and made available \r
-under the terms and conditions of the BSD License which accompanies this \r
-distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-Module Name:\r
-\r
-  EfiRom.c\r
-  \r
-Abstract:\r
-\r
-  Utility program to create an EFI option ROM image from binary and \r
-  EFI PE32 files.\r
-\r
-\r
---*/\r
-\r
-#include <stdio.h>\r
-#include <string.h>\r
-#include <stdlib.h>\r
-\r
-#include <Common/UefiBaseTypes.h>\r
-#include <Common/EfiImage.h>  // for PE32 structure definitions\r
-#include <Common/MultiPhase.h>\r
-\r
-#include <IndustryStandard/pci22.h>  // for option ROM header structures\r
-\r
-#include "EfiCompress.h"\r
-#include "CommonLib.h"\r
-\r
-//\r
-// Version of this utility\r
-//\r
-#define UTILITY_VERSION "v2.5"\r
-\r
-//\r
-// Define some status return values\r
-//\r
-#define STATUS_SUCCESS  0\r
-#define STATUS_WARNING  1\r
-#define STATUS_ERROR    2\r
-\r
-//\r
-// Define the max length of a filename\r
-//\r
-#define MAX_PATH                  200\r
-\r
-#define DEFAULT_OUTPUT_EXTENSION  ".rom"\r
-\r
-//\r
-// Max size for an option ROM image\r
-//\r
-#define MAX_OPTION_ROM_SIZE (1024 * 1024 * 16)  // 16MB\r
-//\r
-// Values for the indicator field in the PCI data structure\r
-//\r
-#define INDICATOR_LAST  0x80  // last file in series of files\r
-//\r
-// Masks for the FILE_LIST.FileFlags field\r
-//\r
-#define FILE_FLAG_BINARY    0x01\r
-#define FILE_FLAG_EFI       0x02\r
-#define FILE_FLAG_COMPRESS  0x04\r
-\r
-//\r
-// Use this linked list structure to keep track of all the filenames\r
-// specified on the command line.\r
-//\r
-typedef struct _FILE_LIST {\r
-  struct _FILE_LIST *Next;\r
-  INT8              *FileName;\r
-  UINT32            FileFlags;\r
-  UINT32            ClassCode;\r
-  UINT16            CodeRevision;\r
-} FILE_LIST;\r
-\r
-//\r
-// Use this to track our command-line options\r
-//\r
-typedef struct {\r
-  INT8      OutFileName[MAX_PATH];\r
-  INT8      NoLast;\r
-  INT8      Verbose;\r
-  INT8      DumpOption;\r
-  UINT8     DevIdValid;\r
-  UINT8     VendIdValid;\r
-  UINT16    VendId;\r
-  UINT16    DevId;\r
-  FILE_LIST *FileList;\r
-} OPTIONS;\r
-\r
-//\r
-// Make a global structure to keep track of command-line options\r
-//\r
-static OPTIONS  mOptions;\r
-\r
-//\r
-// Use these to convert from machine type value to a named type\r
-//\r
-typedef struct {\r
-  UINT16  Value;\r
-  char    *Name;\r
-} STRING_LOOKUP;\r
-\r
-static STRING_LOOKUP  mMachineTypes[] = {\r
-  EFI_IMAGE_MACHINE_IA32,\r
-  "IA32",\r
-  EFI_IMAGE_MACHINE_IA64,\r
-  "IA64",\r
-  EFI_IMAGE_MACHINE_EBC,\r
-  "EBC",\r
-  0,\r
-  NULL\r
-};\r
-\r
-static STRING_LOOKUP  mSubsystemTypes[] = {\r
-  EFI_IMAGE_SUBSYSTEM_EFI_APPLICATION,\r
-  "EFI application",\r
-  EFI_IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER,\r
-  "EFI boot service driver",\r
-  EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER,\r
-  "EFI runtime driver",\r
-  0,\r
-  NULL\r
-};\r
-//\r
-//  Function prototypes\r
-//\r
-static\r
-void\r
-Usage (\r
-  VOID\r
-  );\r
-\r
-static\r
-int\r
-ParseCommandLine (\r
-  int       Argc,\r
-  char      *Argv[],\r
-  OPTIONS   *Options\r
-  );\r
-\r
-static\r
-int\r
-CheckPE32File (\r
-  FILE      *Fptr,\r
-  UINT16    *MachineType,\r
-  UINT16    *SubSystem\r
-  );\r
-\r
-static\r
-int\r
-ProcessEfiFile (\r
-  FILE      *OutFptr,\r
-  FILE_LIST *InFile,\r
-  UINT16    VendId,\r
-  UINT16    DevId,\r
-  UINT32    *Size\r
-  );\r
-\r
-static\r
-int\r
-ProcessBinFile (\r
-  FILE      *OutFptr,\r
-  FILE_LIST *InFile,\r
-  UINT32    *Size\r
-  );\r
-\r
-static\r
-void\r
-DumpImage (\r
-  FILE_LIST *InFile\r
-  );\r
-\r
-char                  *\r
-GetMachineTypeStr (\r
-  UINT16    MachineType\r
-  );\r
-\r
-static\r
-char                  *\r
-GetSubsystemTypeStr (\r
-  UINT16  SubsystemType\r
-  );\r
-\r
-main (\r
-  int   Argc,\r
-  char  *Argv[]\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  \r
-  Given an EFI image filename, create a ROM-able image by creating an option \r
-  ROM header and PCI data structure, filling them in, and then writing the\r
-  option ROM header + PCI data structure + EFI image out to the output file.\r
-\r
-Arguments:\r
-\r
-  Argc            - standard C main() argument count\r
-\r
-  Argv            - standard C main() argument list\r
-\r
-Returns:\r
-\r
-  0             success\r
-  non-zero      otherwise\r
-\r
---*/\r
-// GC_TODO:    ] - add argument and description to function comment\r
-{\r
-  INT8      *Ext;\r
-  FILE      *FptrOut;\r
-  UINT32    Status;\r
-  FILE_LIST *FList;\r
-  UINT32    TotalSize;\r
-  UINT32    Size;\r
-\r
-  Status  = STATUS_SUCCESS;\r
-  FptrOut = NULL;\r
-\r
-  //\r
-  // Parse the command line arguments\r
-  //\r
-  if (ParseCommandLine (Argc, Argv, &mOptions)) {\r
-    return STATUS_ERROR;\r
-  }\r
-  //\r
-  // If dumping an image, then do that and quit\r
-  //\r
-  if (mOptions.DumpOption) {\r
-    DumpImage (mOptions.FileList);\r
-    goto BailOut;\r
-  }\r
-  //\r
-  // Determine the output filename. Either what they specified on\r
-  // the command line, or the first input filename with a different extension.\r
-  //\r
-  if (!mOptions.OutFileName[0]) {\r
-    strcpy (mOptions.OutFileName, mOptions.FileList->FileName);\r
-    //\r
-    // Find the last . on the line and replace the filename extension with\r
-    // the default\r
-    //\r
-    for (Ext = mOptions.OutFileName + strlen (mOptions.OutFileName) - 1;\r
-         (Ext >= mOptions.OutFileName) && (*Ext != '.') && (*Ext != '\\');\r
-         Ext--\r
-        )\r
-      ;\r
-    //\r
-    // If dot here, then insert extension here, otherwise append\r
-    //\r
-    if (*Ext != '.') {\r
-      Ext = mOptions.OutFileName + strlen (mOptions.OutFileName);\r
-    }\r
-\r
-    strcpy (Ext, DEFAULT_OUTPUT_EXTENSION);\r
-  }\r
-  //\r
-  // Make sure we don't have the same filename for input and output files\r
-  //\r
-  for (FList = mOptions.FileList; FList != NULL; FList = FList->Next) {\r
-    if (stricmp (mOptions.OutFileName, FList->FileName) == 0) {\r
-      Status = STATUS_ERROR;\r
-      fprintf (\r
-        stdout,\r
-        "ERROR: Input and output file names must be different - %s = %s\n",\r
-        FList->FileName,\r
-        mOptions.OutFileName\r
-        );\r
-      goto BailOut;\r
-    }\r
-  }\r
-  //\r
-  // Now open our output file\r
-  //\r
-  if ((FptrOut = fopen (mOptions.OutFileName, "w+b")) == NULL) {\r
-    fprintf (stdout, "ERROR: Failed to open output file %s\n", mOptions.OutFileName);\r
-    goto BailOut;\r
-  }\r
-  //\r
-  // Process all our files\r
-  //\r
-  TotalSize = 0;\r
-  for (FList = mOptions.FileList; FList != NULL; FList = FList->Next) {\r
-    Size = 0;\r
-    if (FList->FileFlags & FILE_FLAG_EFI) {\r
-      if (mOptions.Verbose) {\r
-        fprintf (stdout, "Processing EFI file    %s\n", FList->FileName);\r
-      }\r
-\r
-      Status = ProcessEfiFile (FptrOut, FList, mOptions.VendId, mOptions.DevId, &Size);\r
-    } else if (FList->FileFlags & FILE_FLAG_BINARY) {\r
-      if (mOptions.Verbose) {\r
-        fprintf (stdout, "Processing binary file %s\n", FList->FileName);\r
-      }\r
-\r
-      Status = ProcessBinFile (FptrOut, FList, &Size);\r
-    } else {\r
-      fprintf (stdout, "ERROR: File not specified as EFI or binary: %s\n", FList->FileName);\r
-      Status = STATUS_ERROR;\r
-    }\r
-\r
-    if (mOptions.Verbose) {\r
-      fprintf (stdout, "  Output size = 0x%X\n", Size);\r
-    }\r
-\r
-    if (Status != STATUS_SUCCESS) {\r
-      break;\r
-    }\r
-\r
-    TotalSize += Size;\r
-  }\r
-  //\r
-  // Check total size\r
-  //\r
-  if (TotalSize > MAX_OPTION_ROM_SIZE) {\r
-    fprintf (\r
-      stdout,\r
-      "ERROR: Option ROM image size exceeds limit 0x%X bytes\n",\r
-      MAX_OPTION_ROM_SIZE\r
-      );\r
-    Status = STATUS_ERROR;\r
-  }\r
-\r
-BailOut:\r
-  if (FptrOut != NULL) {\r
-    fclose (FptrOut);\r
-  }\r
-  //\r
-  // Clean up our file list\r
-  //\r
-  while (mOptions.FileList != NULL) {\r
-    FList = mOptions.FileList->Next;\r
-    free (mOptions.FileList);\r
-    mOptions.FileList = FList;\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-static\r
-int\r
-ProcessBinFile (\r
-  FILE      *OutFptr,\r
-  FILE_LIST *InFile,\r
-  UINT32    *Size\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  \r
-  Process a binary input file.\r
-\r
-Arguments:\r
-\r
-  OutFptr     - file pointer to output binary ROM image file we're creating\r
-  InFile      - structure contains information on the binary file to process\r
-  Size        - pointer to where to return the size added to the output file\r
-\r
-Returns:\r
-\r
-  0 - successful\r
-\r
---*/\r
-{\r
-  FILE                      *InFptr;\r
-  UINT32                    TotalSize;\r
-  UINT32                    FileSize;\r
-  UINT8                     *Buffer;\r
-  UINT32                    Status;\r
-  PCI_EXPANSION_ROM_HEADER  *RomHdr;\r
-  PCI_DATA_STRUCTURE        *PciDs;\r
-  UINT32                    Index;\r
-  UINT8                     ByteCheckSum;\r
-\r
-  Status = STATUS_SUCCESS;\r
-\r
-  //\r
-  // Try to open the input file\r
-  //\r
-  if ((InFptr = fopen (InFile->FileName, "rb")) == NULL) {\r
-    fprintf (stdout, "ERROR: Failed to open input file %s\n", InFile->FileName);\r
-    return STATUS_ERROR;\r
-  }\r
-  //\r
-  // Seek to the end of the input file and get the file size. Then allocate\r
-  // a buffer to read it in to.\r
-  //\r
-  fseek (InFptr, 0, SEEK_END);\r
-  FileSize = ftell (InFptr);\r
-  if (mOptions.Verbose) {\r
-    fprintf (stdout, "  File size   = 0x%X\n", FileSize);\r
-  }\r
-\r
-  fseek (InFptr, 0, SEEK_SET);\r
-  Buffer = (INT8 *) malloc (FileSize);\r
-  if (Buffer == NULL) {\r
-    fprintf (stdout, "ERROR: Memory allocation failed\n");\r
-    Status = STATUS_ERROR;\r
-    goto BailOut;\r
-  }\r
-\r
-  if (fread (Buffer, FileSize, 1, InFptr) != 1) {\r
-    fprintf (stdout, "ERROR: Failed to read all bytes from input file\n");\r
-    Status = STATUS_ERROR;\r
-    goto BailOut;\r
-  }\r
-  //\r
-  // Total size must be an even multiple of 512 bytes, and can't exceed\r
-  // the option ROM image size.\r
-  //\r
-  TotalSize = FileSize;\r
-  if (TotalSize & 0x1FF) {\r
-    TotalSize = (TotalSize + 0x200) &~0x1ff;\r
-  }\r
-\r
-  if (TotalSize > MAX_OPTION_ROM_SIZE) {\r
-    fprintf (\r
-      stdout,\r
-      "ERROR: Option ROM image %s size exceeds limit 0x%X bytes\n",\r
-      InFile->FileName,\r
-      MAX_OPTION_ROM_SIZE\r
-      );\r
-    Status = STATUS_ERROR;\r
-    goto BailOut;\r
-  }\r
-  //\r
-  // Return the size to the caller so they can keep track of the running total.\r
-  //\r
-  *Size = TotalSize;\r
-\r
-  //\r
-  // Crude check to make sure it's a legitimate ROM image\r
-  //\r
-  RomHdr = (PCI_EXPANSION_ROM_HEADER *) Buffer;\r
-  if (RomHdr->Signature != PCI_EXPANSION_ROM_HEADER_SIGNATURE) {\r
-    fprintf (stdout, "ERROR: ROM image file has invalid ROM signature\n");\r
-    Status = STATUS_ERROR;\r
-    goto BailOut;\r
-  }\r
-  //\r
-  // Make sure the pointer to the PCI data structure is within the size of the image.\r
-  // Then check it for valid signature.\r
-  //\r
-  if ((RomHdr->PcirOffset > FileSize) || (RomHdr->PcirOffset == 0)) {\r
-    fprintf (stdout, "ERROR: Invalid PCI data structure offset\n");\r
-    Status = STATUS_ERROR;\r
-    goto BailOut;\r
-  }\r
-\r
-  PciDs = (PCI_DATA_STRUCTURE *) (Buffer + RomHdr->PcirOffset);\r
-  if (PciDs->Signature != PCI_DATA_STRUCTURE_SIGNATURE) {\r
-    fprintf (stdout, "ERROR: PCI data structure has invalid signature\n");\r
-    Status = STATUS_ERROR;\r
-    goto BailOut;\r
-  }\r
-  //\r
-  // If this is the last image, then set the LAST bit unless requested not\r
-  // to via the command-line -l argument. Otherwise, make sure you clear it.\r
-  //\r
-  if ((InFile->Next == NULL) && (mOptions.NoLast == 0)) {\r
-    PciDs->Indicator = INDICATOR_LAST;\r
-  } else {\r
-    PciDs->Indicator = 0;\r
-  }\r
-\r
-  ByteCheckSum = 0;\r
-  for (Index = 0; Index < FileSize - 1; Index++) {\r
-    ByteCheckSum = (UINT8) (ByteCheckSum + Buffer[Index]);\r
-  }\r
-\r
-  Buffer[FileSize - 1] = (UINT8) ((~ByteCheckSum) + 1);\r
-  fprintf (stdout, "CheckSUm = %02x\n", (UINT32) Buffer[FileSize - 1]);\r
-\r
-  //\r
-  // Now copy the input file contents out to the output file\r
-  //\r
-  if (fwrite (Buffer, FileSize, 1, OutFptr) != 1) {\r
-    fprintf (stdout, "ERROR: Failed to write all file bytes to output file\n");\r
-    Status = STATUS_ERROR;\r
-    goto BailOut;\r
-  }\r
-\r
-  TotalSize -= FileSize;\r
-  //\r
-  // Pad the rest of the image to make it a multiple of 512 bytes\r
-  //\r
-  while (TotalSize > 0) {\r
-    putc (~0, OutFptr);\r
-    TotalSize--;\r
-  }\r
-\r
-BailOut:\r
-  if (InFptr != NULL) {\r
-    fclose (InFptr);\r
-  }\r
-\r
-  if (Buffer != NULL) {\r
-    free (Buffer);\r
-  }\r
-  //\r
-  // Print the file name if errors occurred\r
-  //\r
-  if (Status != STATUS_SUCCESS) {\r
-    fprintf (stdout, "Error processing binary file %s\n", InFile->FileName);\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-static\r
-int\r
-ProcessEfiFile (\r
-  FILE      *OutFptr,\r
-  FILE_LIST *InFile,\r
-  UINT16    VendId,\r
-  UINT16    DevId,\r
-  UINT32    *Size\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  \r
-  Process a PE32 EFI file.\r
-\r
-Arguments:\r
-\r
-  OutFptr     - file pointer to output binary ROM image file we're creating\r
-  InFile      - structure contains information on the PE32 file to process\r
-  VendId      - vendor ID as required in the option ROM header\r
-  DevId       - device ID as required in the option ROM header\r
-  Size        - pointer to where to return the size added to the output file\r
-\r
-Returns:\r
-\r
-  0 - successful\r
-\r
---*/\r
-{\r
-  UINT32                        Status;\r
-  FILE                          *InFptr;\r
-  EFI_PCI_EXPANSION_ROM_HEADER  RomHdr;\r
-  PCI_DATA_STRUCTURE            PciDs;\r
-  UINT32                        FileSize;\r
-  UINT32                        CompressedFileSize;\r
-  UINT8                         *Buffer;\r
-  UINT8                         *CompressedBuffer;\r
-  UINT8                         *TempBufferPtr;\r
-  UINT32                        TotalSize;\r
-  UINT32                        HeaderSize;\r
-  UINT16                        MachineType;\r
-  UINT16                        SubSystem;\r
-  UINT32                        HeaderPadBytes;\r
-\r
-  //\r
-  // Try to open the input file\r
-  //\r
-  if ((InFptr = fopen (InFile->FileName, "rb")) == NULL) {\r
-    fprintf (stdout, "ERROR: Failed to open input file %s\n", InFile->FileName);\r
-    return STATUS_ERROR;\r
-  }\r
-  //\r
-  // Initialize our buffer pointers to null.\r
-  //\r
-  Buffer            = NULL;\r
-  CompressedBuffer  = NULL;\r
-\r
-  //\r
-  // Double-check the file to make sure it's what we expect it to be\r
-  //\r
-  Status = CheckPE32File (InFptr, &MachineType, &SubSystem);\r
-  if (Status != STATUS_SUCCESS) {\r
-    goto BailOut;\r
-  }\r
-  //\r
-  // Seek to the end of the input file and get the file size\r
-  //\r
-  fseek (InFptr, 0, SEEK_END);\r
-  FileSize = ftell (InFptr);\r
-\r
-  //\r
-  // Get the size of the headers we're going to put in front of the image. The\r
-  // EFI header must be aligned on a 4-byte boundary, so pad accordingly.\r
-  //\r
-  if (sizeof (RomHdr) & 0x03) {\r
-    HeaderPadBytes = 4 - (sizeof (RomHdr) & 0x03);\r
-  } else {\r
-    HeaderPadBytes = 0;\r
-  }\r
-\r
-  HeaderSize = sizeof (PCI_DATA_STRUCTURE) + HeaderPadBytes + sizeof (EFI_PCI_EXPANSION_ROM_HEADER);\r
-  if (mOptions.Verbose) {\r
-    fprintf (stdout, "  File size   = 0x%X\n", FileSize);\r
-  }\r
-  //\r
-  // Allocate memory for the entire file (in case we have to compress), then\r
-  // seek back to the beginning of the file and read it into our buffer.\r
-  //\r
-  Buffer = (INT8 *) malloc (FileSize);\r
-  if (Buffer == NULL) {\r
-    fprintf (stdout, "ERROR: Memory allocation failed\n");\r
-    Status = STATUS_ERROR;\r
-    goto BailOut;\r
-  }\r
-\r
-  fseek (InFptr, 0, SEEK_SET);\r
-  if (fread (Buffer, FileSize, 1, InFptr) != 1) {\r
-    fprintf (stdout, "ERROR: Failed to read all bytes from input file\n");\r
-    Status = STATUS_ERROR;\r
-    goto BailOut;\r
-  }\r
-  //\r
-  // Now determine the size of the final output file. It's either the header size\r
-  // plus the file's size, or the header size plus the compressed file size.\r
-  //\r
-  if (InFile->FileFlags & FILE_FLAG_COMPRESS) {\r
-    //\r
-    // Allocate a buffer into which we can compress the image, compress it,\r
-    // and use that size as the new size.\r
-    //\r
-    CompressedBuffer = (INT8 *) malloc (FileSize);\r
-    if (CompressedBuffer == NULL) {\r
-      fprintf (stdout, "ERROR: Memory allocation failed\n");\r
-      Status = STATUS_ERROR;\r
-      goto BailOut;\r
-    }\r
-\r
-    CompressedFileSize  = FileSize;\r
-    Status              = Compress (Buffer, FileSize, CompressedBuffer, &CompressedFileSize);\r
-    if (Status != STATUS_SUCCESS) {\r
-      fprintf (stdout, "ERROR: Compression failed\n");\r
-      goto BailOut;\r
-    }\r
-    //\r
-    // Now compute the size, then swap buffer pointers.\r
-    //\r
-    if (mOptions.Verbose) {\r
-      fprintf (stdout, "  Comp size   = 0x%X\n", CompressedFileSize);\r
-    }\r
-\r
-    TotalSize         = CompressedFileSize + HeaderSize;\r
-    FileSize          = CompressedFileSize;\r
-    TempBufferPtr     = Buffer;\r
-    Buffer            = CompressedBuffer;\r
-    CompressedBuffer  = TempBufferPtr;\r
-  } else {\r
-    TotalSize = FileSize + HeaderSize;\r
-  }\r
-  //\r
-  // Total size must be an even multiple of 512 bytes\r
-  //\r
-  if (TotalSize & 0x1FF) {\r
-    TotalSize = (TotalSize + 0x200) &~0x1ff;\r
-  }\r
-  //\r
-  // Check size\r
-  //\r
-  if (TotalSize > MAX_OPTION_ROM_SIZE) {\r
-    fprintf (\r
-      stdout,\r
-      "ERROR: Option ROM image %s size exceeds limit 0x%X bytes\n",\r
-      InFile->FileName,\r
-      MAX_OPTION_ROM_SIZE\r
-      );\r
-    Status = STATUS_ERROR;\r
-    goto BailOut;\r
-  }\r
-  //\r
-  // Return the size to the caller so they can keep track of the running total.\r
-  //\r
-  *Size = TotalSize;\r
-\r
-  //\r
-  // Now fill in the ROM header. These values come from chapter 18 of the\r
-  // EFI 1.02 specification.\r
-  //\r
-  memset (&RomHdr, 0, sizeof (RomHdr));\r
-  RomHdr.Signature            = PCI_EXPANSION_ROM_HEADER_SIGNATURE;\r
-  RomHdr.InitializationSize   = (UINT16) (TotalSize / 512);\r
-  RomHdr.EfiSignature         = EFI_PCI_EXPANSION_ROM_HEADER_EFISIGNATURE;\r
-  RomHdr.EfiSubsystem         = SubSystem;\r
-  RomHdr.EfiMachineType       = MachineType;\r
-  RomHdr.EfiImageHeaderOffset = (UINT16) HeaderSize;\r
-  RomHdr.PcirOffset           = (UINT16) (sizeof (RomHdr) + HeaderPadBytes);\r
-  //\r
-  // Set image as compressed or not\r
-  //\r
-  if (InFile->FileFlags & FILE_FLAG_COMPRESS) {\r
-    RomHdr.CompressionType = EFI_PCI_EXPANSION_ROM_HEADER_COMPRESSED;\r
-  }\r
-  //\r
-  // Fill in the PCI data structure\r
-  //\r
-  memset (&PciDs, 0, sizeof (PCI_DATA_STRUCTURE));\r
-\r
-  PciDs.Signature = PCI_DATA_STRUCTURE_SIGNATURE;\r
-  PciDs.VendorId  = VendId;\r
-  PciDs.DeviceId  = DevId;\r
-  PciDs.Length    = (UINT16) sizeof (PCI_DATA_STRUCTURE);\r
-  PciDs.Revision  = 0;\r
-  //\r
-  // Class code and code revision from the command line (optional)\r
-  //\r
-  PciDs.ClassCode[0]  = (UINT8) InFile->ClassCode;\r
-  PciDs.ClassCode[1]  = (UINT8) (InFile->ClassCode >> 8);\r
-  PciDs.ClassCode[2]  = (UINT8) (InFile->ClassCode >> 16);\r
-  PciDs.ImageLength   = RomHdr.InitializationSize;\r
-  PciDs.CodeRevision  = InFile->CodeRevision;\r
-  PciDs.CodeType      = PCI_CODE_TYPE_EFI_IMAGE;\r
-\r
-  //\r
-  // If this is the last image, then set the LAST bit unless requested not\r
-  // to via the command-line -l argument.\r
-  //\r
-  if ((InFile->Next == NULL) && (mOptions.NoLast == 0)) {\r
-    PciDs.Indicator = INDICATOR_LAST;\r
-  }\r
-  //\r
-  // Write the ROM header to the output file\r
-  //\r
-  if (fwrite (&RomHdr, sizeof (RomHdr), 1, OutFptr) != 1) {\r
-    fprintf (stdout, "ERROR: Failed to write ROM header to output file\n");\r
-    Status = STATUS_ERROR;\r
-    goto BailOut;\r
-  }\r
-\r
-  //\r
-  // Write pad bytes to align the PciDs\r
-  //\r
-  while (HeaderPadBytes > 0) {\r
-    if (putc (0, OutFptr) == EOF) {\r
-      fprintf (stdout, "ERROR: Failed to write ROM header pad bytes to output file\n");\r
-      Status = STATUS_ERROR;\r
-      goto BailOut;\r
-    }\r
-\r
-    HeaderPadBytes--;\r
-  }\r
-  //\r
-  // Write the PCI data structure header to the output file\r
-  //\r
-  if (fwrite (&PciDs, sizeof (PciDs), 1, OutFptr) != 1) {\r
-    fprintf (stdout, "ERROR: Failed to write PCI ROM header to output file\n");\r
-    Status = STATUS_ERROR;\r
-    goto BailOut;\r
-  }\r
-  //\r
-  // Keep track of how many bytes left to write\r
-  //\r
-  TotalSize -= HeaderSize;\r
-\r
-  //\r
-  // Now dump the input file's contents to the output file\r
-  //\r
-  if (fwrite (Buffer, FileSize, 1, OutFptr) != 1) {\r
-    fprintf (stdout, "ERROR: Failed to write all file bytes to output file\n");\r
-    Status = STATUS_ERROR;\r
-    goto BailOut;\r
-  }\r
-\r
-  TotalSize -= FileSize;\r
-  //\r
-  // Pad the rest of the image to make it a multiple of 512 bytes\r
-  //\r
-  while (TotalSize > 0) {\r
-    if (putc (~0, OutFptr) == EOF) {\r
-      fprintf (stdout, "ERROR: Failed to write trailing pad bytes output file\n");\r
-      Status = STATUS_ERROR;\r
-      goto BailOut;\r
-    }\r
-\r
-    TotalSize--;\r
-  }\r
-\r
-BailOut:\r
-  if (InFptr != NULL) {\r
-    fclose (InFptr);\r
-  }\r
-\r
-  //\r
-  // Free up our buffers\r
-  //\r
-  if (Buffer != NULL) {\r
-    free (Buffer);\r
-  }\r
-\r
-  if (CompressedBuffer != NULL) {\r
-    free (CompressedBuffer);\r
-  }\r
-  //\r
-  // Print the file name if errors occurred\r
-  //\r
-  if (Status != STATUS_SUCCESS) {\r
-    fprintf (stdout, "Error processing EFI file %s\n", InFile->FileName);\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-static\r
-int\r
-CheckPE32File (\r
-  FILE      *Fptr,\r
-  UINT16    *MachineType,\r
-  UINT16    *SubSystem\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  Fptr        - GC_TODO: add argument description\r
-  MachineType - GC_TODO: add argument description\r
-  SubSystem   - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
-  GC_TODO: add return values\r
-\r
---*/\r
-{\r
-  /*++\r
-\r
-Routine Description:\r
-  \r
-  Given a file pointer to a supposed PE32 image file, verify that it is indeed a\r
-  PE32 image file, and then return the machine type in the supplied pointer.\r
-\r
-Arguments:\r
-\r
-  Fptr          File pointer to the already-opened PE32 file\r
-  MachineType   Location to stuff the machine type of the PE32 file. This is needed\r
-                because the image may be Itanium-based, IA32, or EBC.\r
-\r
-Returns:\r
-\r
-  0             success\r
-  non-zero      otherwise\r
-\r
---*/\r
-  EFI_IMAGE_DOS_HEADER      DosHeader;\r
-  EFI_IMAGE_FILE_HEADER     FileHdr;\r
-  EFI_IMAGE_OPTIONAL_HEADER OptionalHdr;\r
-  UINT32                    PESig;\r
-\r
-  //\r
-  // Position to the start of the file\r
-  //\r
-  fseek (Fptr, 0, SEEK_SET);\r
-\r
-  //\r
-  // Read the DOS header\r
-  //\r
-  if (fread (&DosHeader, sizeof (DosHeader), 1, Fptr) != 1) {\r
-    fprintf (stdout, "ERROR: Failed to read the DOS stub from the input file\n");\r
-    return STATUS_ERROR;\r
-  }\r
-  //\r
-  // Check the magic number (0x5A4D)\r
-  //\r
-  if (DosHeader.e_magic != EFI_IMAGE_DOS_SIGNATURE) {\r
-    fprintf (stdout, "ERROR: Input file does not appear to be a PE32 image (magic number)\n");\r
-    return STATUS_ERROR;\r
-  }\r
-  //\r
-  // Position into the file and check the PE signature\r
-  //\r
-  fseek (Fptr, (long) DosHeader.e_lfanew, SEEK_SET);\r
-  if (fread (&PESig, sizeof (PESig), 1, Fptr) != 1) {\r
-    fprintf (stdout, "ERROR: Failed to read PE signature bytes from input file\n");\r
-    return STATUS_ERROR;\r
-  }\r
-  //\r
-  // Check the PE signature in the header "PE\0\0"\r
-  //\r
-  if (PESig != EFI_IMAGE_NT_SIGNATURE) {\r
-    fprintf (stdout, "ERROR: Input file does not appear to be a PE32 image (signature)\n");\r
-    return STATUS_ERROR;\r
-  }\r
-  //\r
-  // Read the file header and stuff their MachineType\r
-  //\r
-  if (fread (&FileHdr, sizeof (FileHdr), 1, Fptr) != 1) {\r
-    fprintf (stdout, "ERROR: Failed to read PE file header from input file\n");\r
-    return STATUS_ERROR;\r
-  }\r
-\r
-  memcpy ((char *) MachineType, &FileHdr.Machine, 2);\r
-\r
-  //\r
-  // Read the optional header so we can get the subsystem\r
-  //\r
-  if (fread (&OptionalHdr, sizeof (OptionalHdr), 1, Fptr) != 1) {\r
-    fprintf (stdout, "ERROR: Failed to read COFF optional header from input file\n");\r
-    return STATUS_ERROR;\r
-  }\r
-\r
-  *SubSystem = OptionalHdr.Subsystem;\r
-  if (mOptions.Verbose) {\r
-    fprintf (stdout, "  Got subsystem = 0x%X from image\n", (int) *SubSystem);\r
-  }\r
-  //\r
-  // Good to go\r
-  //\r
-  return STATUS_SUCCESS;\r
-}\r
-\r
-static\r
-int\r
-ParseCommandLine (\r
-  int         Argc,\r
-  char        *Argv[],\r
-  OPTIONS     *Options\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  \r
-  Given the Argc/Argv program arguments, and a pointer to an options structure,\r
-  parse the command-line options and check their validity.\r
-\r
-\r
-Arguments:\r
-\r
-  Argc            - standard C main() argument count\r
-  Argv[]          - standard C main() argument list\r
-  Options         - pointer to a structure to store the options in\r
-\r
-Returns:\r
-\r
-  STATUS_SUCCESS    success\r
-  non-zero          otherwise\r
-\r
---*/\r
-//\r
-{\r
-  FILE_LIST *FileList;\r
-\r
-  FILE_LIST *PrevFileList;\r
-  UINT32    FileFlags;\r
-  UINT32    ClassCode;\r
-  UINT32    CodeRevision;\r
-\r
-  FileFlags = 0;\r
-\r
-  //\r
-  // Clear out the options\r
-  //\r
-  memset ((char *) Options, 0, sizeof (OPTIONS));\r
-\r
-  //\r
-  // To avoid compile warnings\r
-  //\r
-  FileList                = PrevFileList = NULL;\r
-\r
-  ClassCode               = 0;\r
-  CodeRevision            = 0;\r
-  //\r
-  // Skip over the program name\r
-  //\r
-  Argc--;\r
-  Argv++;\r
-\r
-  //\r
-  // If no arguments, assume they want usage info\r
-  //\r
-  if (Argc == 0) {\r
-    Usage ();\r
-    return STATUS_ERROR;\r
-  }\r
-  //\r
-  // Process until no more arguments\r
-  //\r
-  while (Argc > 0) {\r
-    if ((Argv[0][0] == '-') || (Argv[0][0] == '/')) {\r
-      //\r
-      // To simplify string comparisons, replace slashes with dashes\r
-      //\r
-      Argv[0][0] = '-';\r
-\r
-      //\r
-      // Vendor ID specified with -v\r
-      //\r
-      if (stricmp (Argv[0], "-v") == 0) {\r
-        //\r
-        // Make sure there's another parameter\r
-        //\r
-        if (Argc > 1) {\r
-          Options->VendId       = (UINT16) strtol (Argv[1], NULL, 16);\r
-          Options->VendIdValid  = 1;\r
-        } else {\r
-          fprintf (\r
-            stdout,\r
-            "ERROR: Missing Vendor ID with %s\n\n",\r
-            Argv[0]\r
-            );\r
-          Usage ();\r
-          return STATUS_ERROR;\r
-        }\r
-\r
-        Argv++;\r
-        Argc--;\r
-      } else if (stricmp (Argv[0], "-d") == 0) {\r
-        //\r
-        // Device ID specified with -d\r
-        // Make sure there's another parameter\r
-        //\r
-        if (Argc > 1) {\r
-          Options->DevId      = (UINT16) strtol (Argv[1], NULL, 16);\r
-          Options->DevIdValid = 1;\r
-        } else {\r
-          fprintf (\r
-            stdout,\r
-            "ERROR: Missing Device ID with %s\n\n",\r
-            Argv[0]\r
-            );\r
-          Usage ();\r
-          return STATUS_ERROR;\r
-        }\r
-\r
-        Argv++;\r
-        Argc--;\r
-      } else if (stricmp (Argv[0], "-o") == 0) {\r
-        //\r
-        // Output filename specified with -o\r
-        // Make sure there's another parameter\r
-        //\r
-        if (Argc > 1) {\r
-          strcpy (Options->OutFileName, Argv[1]);\r
-        } else {\r
-          fprintf (\r
-            stdout,\r
-            "ERROR: Missing output file name with %s\n\n",\r
-            Argv[0]\r
-            );\r
-          Usage ();\r
-          return STATUS_ERROR;\r
-        }\r
-\r
-        Argv++;\r
-        Argc--;\r
-      } else if ((stricmp (Argv[0], "-h") == 0) || (strcmp (Argv[0], "-?") == 0)) {\r
-        //\r
-        // Help option\r
-        //\r
-        Usage ();\r
-        return STATUS_ERROR;\r
-      } else if (stricmp (Argv[0], "-b") == 0) {\r
-        //\r
-        // Specify binary files with -b\r
-        //\r
-        FileFlags = (FileFlags &~FILE_FLAG_EFI) | FILE_FLAG_BINARY;\r
-      } else if ((stricmp (Argv[0], "-e") == 0) || (stricmp (Argv[0], "-ec") == 0)) {\r
-        //\r
-        // Specify EFI files with -e. Specify EFI-compressed with -ec.\r
-        //\r
-        FileFlags = (FileFlags &~FILE_FLAG_BINARY) | FILE_FLAG_EFI;\r
-        if ((Argv[0][2] == 'c') || (Argv[0][2] == 'C')) {\r
-          FileFlags |= FILE_FLAG_COMPRESS;\r
-        }\r
-        //\r
-        // Specify not to set the LAST bit in the last file with -l\r
-        //\r
-      } else if (stricmp (Argv[0], "-l") == 0) {\r
-        Options->NoLast = 1;\r
-      } else if (stricmp (Argv[0], "-p") == 0) {\r
-        //\r
-        // -v for verbose would have been nicer, but it's already used. Let's use\r
-        // -p for prolix (wordy) output\r
-        //\r
-        Options->Verbose = 1;\r
-      } else if (stricmp (Argv[0], "-dump") == 0) {\r
-        //\r
-        // -dump for dumping a ROM image. In this case, say that the device id\r
-        // and vendor id are valid so we don't have to specify bogus ones on the\r
-        // command line.\r
-        //\r
-        Options->DumpOption   = 1;\r
-\r
-        Options->VendIdValid  = 1;\r
-        Options->DevIdValid   = 1;\r
-        FileFlags             = FILE_FLAG_BINARY;\r
-      } else if (stricmp (Argv[0], "-cc") == 0) {\r
-        //\r
-        // Class code value for the next file in the list.\r
-        // Make sure there's another parameter\r
-        //\r
-        if (Argc > 1) {\r
-          //\r
-          // No error checking on the return value. Could check for LONG_MAX,\r
-          // LONG_MIN, or 0 class code value if desired. Check range (3 bytes)\r
-          // at least.\r
-          //\r
-          ClassCode = (UINT32) strtol (Argv[1], NULL, 16);\r
-          if (ClassCode & 0xFF000000) {\r
-            fprintf (stdout, "ERROR: Class code %s out of range\n", Argv[1]);\r
-            return STATUS_ERROR;\r
-          }\r
-        } else {\r
-          fprintf (\r
-            stdout,\r
-            "ERROR: Missing class code value with %s\n\n",\r
-            Argv[0]\r
-            );\r
-          Usage ();\r
-          return STATUS_ERROR;\r
-        }\r
-\r
-        Argv++;\r
-        Argc--;\r
-      } else if (stricmp (Argv[0], "-rev") == 0) {\r
-        //\r
-        // Code revision in the PCI data structure. The value is for the next\r
-        // file in the list.\r
-        // Make sure there's another parameter\r
-        //\r
-        if (Argc > 1) {\r
-          //\r
-          // No error checking on the return value. Could check for LONG_MAX,\r
-          // LONG_MIN, or 0 value if desired. Check range (2 bytes)\r
-          // at least.\r
-          //\r
-          CodeRevision = (UINT32) strtol (Argv[1], NULL, 16);\r
-          if (CodeRevision & 0xFFFF0000) {\r
-            fprintf (stdout, "ERROR: Code revision %s out of range\n", Argv[1]);\r
-            return STATUS_ERROR;\r
-          }\r
-        } else {\r
-          fprintf (\r
-            stdout,\r
-            "ERROR: Missing code revision value with %s\n\n",\r
-            Argv[0]\r
-            );\r
-          Usage ();\r
-          return STATUS_ERROR;\r
-        }\r
-\r
-        Argv++;\r
-        Argc--;\r
-      } else {\r
-        fprintf (stdout, "ERROR: Invalid option specified: %s\n\n", Argv[0]);\r
-        Usage ();\r
-        return STATUS_ERROR;\r
-      }\r
-    } else {\r
-      //\r
-      // Not a slash-option argument. Must be a file name. Make sure they've specified\r
-      // -e or -b already.\r
-      //\r
-      if ((FileFlags & (FILE_FLAG_BINARY | FILE_FLAG_EFI)) == 0) {\r
-        fprintf (stdout, "ERROR: Missing -e or -b with input file %s\n", Argv[0]);\r
-        return STATUS_ERROR;\r
-      }\r
-      //\r
-      // Create a new file structure\r
-      //\r
-      FileList = (FILE_LIST *) malloc (sizeof (FILE_LIST));\r
-      if (FileList == NULL) {\r
-        fprintf (stdout, "ERROR: Memory allocation failure\n");\r
-        return STATUS_ERROR;\r
-      }\r
-\r
-      memset ((char *) FileList, 0, sizeof (FILE_LIST));\r
-      FileList->FileName  = Argv[0];\r
-      FileList->FileFlags = FileFlags;\r
-      if (Options->FileList == NULL) {\r
-        Options->FileList = FileList;\r
-      } else {\r
-        if (PrevFileList == NULL) {\r
-          PrevFileList = FileList;\r
-        } else {          \r
-          PrevFileList->Next = FileList;\r
-        }\r
-      }\r
-\r
-      PrevFileList = FileList;\r
-      //\r
-      // Set the class code and code revision for this file, then reset the values.\r
-      //\r
-      FileList->ClassCode     = ClassCode;\r
-      FileList->CodeRevision  = (UINT16) CodeRevision;\r
-      ClassCode               = 0;\r
-      CodeRevision            = 0;\r
-    }\r
-    //\r
-    // Next argument\r
-    //\r
-    Argv++;\r
-    Argc--;\r
-  }\r
-  //\r
-  // Make sure they specified a device ID and vendor ID\r
-  //\r
-  if (!Options->VendIdValid) {\r
-    fprintf (stdout, "ERROR: Missing Vendor ID on command line\n\n");\r
-    Usage ();\r
-    return STATUS_ERROR;\r
-  }\r
-\r
-  if (!Options->DevIdValid) {\r
-    fprintf (stdout, "ERROR: Missing Device ID on command line\n\n");\r
-    Usage ();\r
-    return STATUS_ERROR;\r
-  }\r
-  //\r
-  // Must have specified some files\r
-  //\r
-  if (Options->FileList == NULL) {\r
-    fprintf (stdout, "ERROR: Missing input file name\n");\r
-    Usage ();\r
-    return STATUS_ERROR;\r
-  }\r
-\r
-  return 0;\r
-}\r
-\r
-static\r
-void\r
-Usage (\r
-  VOID\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  \r
-  Print usage information for this utility.\r
-\r
-Arguments:\r
-\r
-  None.\r
-\r
-Returns:\r
-\r
-  Nothing.\r
-\r
---*/\r
-{\r
-  int               Index;\r
-  static const char *Msg[] = {\r
-    "EfiRom "UTILITY_VERSION " - Intel EFI Make Option ROM utility",\r
-    "  Copyright (C), 1999-2002 Intel Coproration\n",\r
-    "  Create an option ROM image from a list of input files",\r
-    "  Usage: efirom {-p} [-v VendorId] [-d DeviceId] {-o OutFileName} ",\r
-    "                [-e|-b] [FileName(s)]",\r
-    "    where:",\r
-    "      VendorId       - required hex PCI Vendor ID for the device",\r
-    "      DeviceId       - required hex PCI Device ID for the device",\r
-    "      OutFileName    - optional output file name. Default is the first input",\r
-    "                       file name with a "DEFAULT_OUTPUT_EXTENSION " file extension",\r
-    "      FileNames      - input PE32 or binary file name(s)",\r
-    "      BinFileName    - input binary file name(s)",\r
-    "      -p             - for verbose output",\r
-    "      -l             - to not automatically set the LAST bit on the last file",\r
-    "      -b             - following FileNames are binary files",\r
-    "      -e             - following FileNames are EFI PE32 image files",\r
-    "      -ec            - following FileNames are EFI PE32 image files, and should",\r
-    "                       be compressed by this utility",\r
-    "      -cc ClassCode  - to use hex ClassCode in the PCI data structure header for",\r
-    "                       the following FileName",\r
-    "      -rev Revision  - to use hex Revision in the PCI data structure header for",\r
-    "                       the following FileName",\r
-    "      -dump          - to dump the headers of an existing option ROM image",\r
-    "",\r
-    "Example usage: EfiRom -v 0xABCD -d 0x1234 -b File1.bin File2.bin -e File1.efi File2.efi ",\r
-    "",\r
-    NULL\r
-  };\r
-\r
-  for (Index = 0; Msg[Index] != NULL; Index++) {\r
-    fprintf (stdout, "%s\n", Msg[Index]);\r
-  }\r
-}\r
-\r
-static\r
-void\r
-DumpImage (\r
-  FILE_LIST *InFile\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  InFile  - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
-  GC_TODO: add return values\r
-\r
---*/\r
-{\r
-  PCI_EXPANSION_ROM_HEADER      PciRomHdr;\r
-  FILE                          *InFptr;\r
-  UINT32                        ImageStart;\r
-  UINT32                        ImageCount;\r
-  EFI_PCI_EXPANSION_ROM_HEADER  EfiRomHdr;\r
-  PCI_DATA_STRUCTURE            PciDs;\r
-\r
-  //\r
-  // Open the input file\r
-  //\r
-  if ((InFptr = fopen (InFile->FileName, "rb")) == NULL) {\r
-    fprintf (\r
-      stdout,\r
-      "ERROR: Could not open input file %s\n",\r
-      InFile->FileName\r
-      );\r
-    return ;\r
-  }\r
-  //\r
-  // Go through the image and dump the header stuff for each\r
-  //\r
-  ImageCount = 0;\r
-  for (;;) {\r
-    //\r
-    // Save our postition in the file, since offsets in the headers\r
-    // are relative to the particular image.\r
-    //\r
-    ImageStart = ftell (InFptr);\r
-    ImageCount++;\r
-\r
-    //\r
-    // Read the option ROM header. Have to assume a raw binary image for now.\r
-    //\r
-    if (fread (&PciRomHdr, sizeof (PciRomHdr), 1, InFptr) != 1) {\r
-      fprintf (stdout, "ERROR: Failed to read PCI ROM header from file\n");\r
-      goto BailOut;\r
-    }\r
-\r
-    //\r
-    // Dump the contents of the header\r
-    //\r
-    fprintf (stdout, "Image %d -- Offset 0x%X\n", ImageCount, ImageStart);\r
-    fprintf (stdout, "  ROM header contents\n");\r
-    fprintf (stdout, "    Signature              0x%04X\n", (UINT32) PciRomHdr.Signature);\r
-    fprintf (stdout, "    PCIR offset            0x%04X\n", (UINT32) PciRomHdr.PcirOffset);\r
-    //\r
-    // Find PCI data structure\r
-    //\r
-    if (fseek (InFptr, ImageStart + PciRomHdr.PcirOffset, SEEK_SET)) {\r
-      fprintf (stdout, "ERROR: Failed to seek to PCI data structure\n");\r
-      goto BailOut;\r
-    }\r
-    //\r
-    // Read and dump the PCI data structure\r
-    //\r
-    if (fread (&PciDs, sizeof (PciDs), 1, InFptr) != 1) {\r
-      fprintf (stdout, "ERROR: Failed to read PCI data structure from file\n");\r
-      goto BailOut;\r
-    }\r
-\r
-    fprintf (stdout, "  PCI Data Structure\n");\r
-    fprintf (\r
-      stdout,\r
-      "    Signature              %c%c%c%c\n",\r
-      (char) PciDs.Signature,\r
-      (char) (PciDs.Signature >> 8),\r
-      (char) (PciDs.Signature >> 16),\r
-      (char) (PciDs.Signature >> 24)\r
-      );\r
-    fprintf (stdout, "    Vendor ID              0x%04X\n", PciDs.VendorId);\r
-    fprintf (stdout, "    Device ID              0x%04X\n", PciDs.DeviceId);\r
-    fprintf (\r
-      stdout,\r
-      "    Class Code             0x%06X\n",\r
-      (UINT32) (PciDs.ClassCode[0] | (PciDs.ClassCode[1] << 8) | (PciDs.ClassCode[2] << 16))\r
-      );\r
-    fprintf (stdout, "    Image size             0x%X\n", PciDs.ImageLength * 512);\r
-    fprintf (stdout, "    Code revision:         0x%04X\n", PciDs.CodeRevision);\r
-    fprintf (stdout, "    Indicator              0x%02X", (UINT32) PciDs.Indicator);\r
-    //\r
-    // Print the indicator, used to flag the last image\r
-    //\r
-    if (PciDs.Indicator == INDICATOR_LAST) {\r
-      fprintf (stdout, "   (last image)\n");\r
-    } else {\r
-      fprintf (stdout, "\n");\r
-    }\r
-    //\r
-    // Print the code type. If EFI code, then we can provide more info.\r
-    //\r
-    fprintf (stdout, "    Code type              0x%02X", (UINT32) PciDs.CodeType);\r
-    if (PciDs.CodeType == PCI_CODE_TYPE_EFI_IMAGE) {\r
-      fprintf (stdout, "   (EFI image)\n");\r
-      //\r
-      // Re-read the header as an EFI ROM header, then dump more info\r
-      //\r
-      fprintf (stdout, "  EFI ROM header contents\n");\r
-      if (fseek (InFptr, ImageStart, SEEK_SET)) {\r
-        fprintf (stdout, "ERROR: Failed to re-seek to ROM header structure\n");\r
-        goto BailOut;\r
-      }\r
-\r
-      if (fread (&EfiRomHdr, sizeof (EfiRomHdr), 1, InFptr) != 1) {\r
-        fprintf (stdout, "ERROR: Failed to read EFI PCI ROM header from file\n");\r
-        goto BailOut;\r
-      }\r
-      //\r
-      // Now dump more info\r
-      //\r
-      fprintf (stdout, "    EFI Signature          0x%04X\n", EfiRomHdr.EfiSignature);\r
-      fprintf (\r
-        stdout,\r
-        "    Compression Type       0x%04X ",\r
-        (UINT32) EfiRomHdr.CompressionType\r
-        );\r
-      if (EfiRomHdr.CompressionType == EFI_PCI_EXPANSION_ROM_HEADER_COMPRESSED) {\r
-        fprintf (stdout, "(compressed)\n");\r
-      } else {\r
-        fprintf (stdout, "(not compressed)\n");\r
-      }\r
-\r
-      fprintf (\r
-        stdout,\r
-        "    Machine type           0x%04X (%s)\n",\r
-        EfiRomHdr.EfiMachineType,\r
-        GetMachineTypeStr (EfiRomHdr.EfiMachineType)\r
-        );\r
-      fprintf (\r
-        stdout,\r
-        "    Subsystem              0x%04X (%s)\n",\r
-        EfiRomHdr.EfiSubsystem,\r
-        GetSubsystemTypeStr (EfiRomHdr.EfiSubsystem)\r
-        );\r
-      fprintf (\r
-        stdout,\r
-        "    EFI image offset       0x%04X (@0x%X)\n",\r
-        (UINT32) EfiRomHdr.EfiImageHeaderOffset,\r
-        (UINT32) (EfiRomHdr.EfiImageHeaderOffset + ImageStart)\r
-        );\r
-\r
-    } else {\r
-      //\r
-      // Not an EFI image\r
-      //\r
-      fprintf (stdout, "\n");\r
-    }\r
-    //\r
-    // If code type is EFI image, then dump it as well?\r
-    //\r
-    // if (PciDs.CodeType == PCI_CODE_TYPE_EFI_IMAGE) {\r
-    // }\r
-    //\r
-    // If last image, then we're done\r
-    //\r
-    if (PciDs.Indicator == INDICATOR_LAST) {\r
-      goto BailOut;\r
-    }\r
-    //\r
-    // Seek to the start of the next image\r
-    //\r
-    if (fseek (InFptr, ImageStart + (PciDs.ImageLength * 512), SEEK_SET)) {\r
-      fprintf (stdout, "ERROR: Failed to seek to next image\n");\r
-      goto BailOut;\r
-    }\r
-  }\r
-\r
-BailOut:\r
-  fclose (InFptr);\r
-}\r
-\r
-char *\r
-GetMachineTypeStr (\r
-  UINT16    MachineType\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  MachineType - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
-  GC_TODO: add return values\r
-\r
---*/\r
-{\r
-  int Index;\r
-\r
-  for (Index = 0; mMachineTypes[Index].Name != NULL; Index++) {\r
-    if (mMachineTypes[Index].Value == MachineType) {\r
-      return mMachineTypes[Index].Name;\r
-    }\r
-  }\r
-\r
-  return "unknown";\r
-}\r
-\r
-static\r
-char *\r
-GetSubsystemTypeStr (\r
-  UINT16  SubsystemType\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  SubsystemType - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
-  GC_TODO: add return values\r
-\r
---*/\r
-{\r
-  int Index;\r
-\r
-  for (Index = 0; mSubsystemTypes[Index].Name != NULL; Index++) {\r
-    if (mSubsystemTypes[Index].Value == SubsystemType) {\r
-      return mSubsystemTypes[Index].Name;\r
-    }\r
-  }\r
-\r
-  return "unknown";\r
-}\r
diff --git a/Tools/CodeTools/TianoTools/EfiRom/build.xml b/Tools/CodeTools/TianoTools/EfiRom/build.xml
deleted file mode 100644 (file)
index acb94a4..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-<?xml version="1.0" ?>\r
-<!--\r
-Copyright (c) 2006, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
--->\r
-<project default="GenTool" basedir=".">\r
-<!--\r
-    EDK EfiRom Tool\r
-  Copyright (c) 2006, Intel Corporation\r
--->\r
-  <property name="ToolName" value="EfiRom"/>\r
-  <property name="FileSet" value="*.c"/>\r
-\r
-  <taskdef resource="cpptasks.tasks"/>\r
-  <typedef resource="cpptasks.types"/>\r
-  <taskdef resource="net/sf/antcontrib/antlib.xml"/>\r
-\r
-  <property name="LINK_OUTPUT_TYPE" value="static"/>\r
-  <property name="BUILD_DIR" value="${PACKAGE_DIR}/${ToolName}/tmp"/>\r
-\r
-  <target name="GenTool" depends="init, Tool">\r
-    <echo message="The EDK Tool: ${ToolName} build has completed!"/>\r
-  </target>\r
-\r
-  <target name="init">\r
-    <echo message="Building the EDK Tool: ${ToolName}"/>\r
-    <mkdir dir="${BUILD_DIR}"/>\r
-  </target>\r
-\r
-  <target name="Tool" depends="init">\r
-    <cc name="${ToolChain}" objdir="${BUILD_DIR}" \r
-        outfile="${BIN_DIR}/${ToolName}"\r
-        outtype="executable"\r
-        optimize="speed" \r
-        debug="true">\r
-      <compilerarg value="${ExtraArgus}" if="ExtraArgus" />\r
-      <fileset dir="${basedir}/${ToolName}" \r
-        includes="${FileSet}" \r
-        defaultexcludes="TRUE" \r
-        excludes="*.xml *.inf"/>\r
-\r
-      <includepath path="${PACKAGE_DIR}/Include"/>\r
-      <includepath path="${PACKAGE_DIR}/Include/${HostArch}"/>\r
-      <includepath path="${PACKAGE_DIR}/Common"/>\r
-      <libset dir="${LIB_DIR}" libs="CommonTools"/>\r
-    </cc>\r
-  </target>\r
-\r
-  <target name="clean">\r
-    <echo message="Removing Intermediate Files Only"/>  \r
-    <delete>\r
-      <fileset dir="${BUILD_DIR}" includes="*.obj"/>\r
-    </delete>\r
-  </target>\r
-\r
-  <target name="cleanall">\r
-    <echo message="Removing Object Files and the Executable: ${ToolName}${ext_exe}"/>  \r
-    <delete failonerror="false" quiet="true" includeEmptyDirs="true">\r
-      <fileset dir="${BUILD_DIR}"/>\r
-      <fileset file="${BIN_DIR}/${ToolName}${ext_exe}"/>\r
-    </delete>\r
-  </target>\r
-\r
-</project>\r
diff --git a/Tools/CodeTools/TianoTools/FlashMap/FlashDefFile.c b/Tools/CodeTools/TianoTools/FlashMap/FlashDefFile.c
deleted file mode 100644 (file)
index cdbf788..0000000
+++ /dev/null
@@ -1,2788 +0,0 @@
-/*++\r
-\r
-Copyright (c)  2004-2006 Intel Corporation. All rights reserved\r
-This program and the accompanying materials are licensed and made available \r
-under the terms and conditions of the BSD License which accompanies this \r
-distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-Module Name:\r
-\r
-  FlashDefFile.c\r
-\r
-Abstract:\r
-\r
-  Utility for flash management in the Intel Platform Innovation Framework\r
-  for EFI build environment.\r
-\r
---*/\r
-\r
-#include <stdio.h>\r
-#include <string.h>\r
-#include <stdlib.h>\r
-\r
-#include <Common/UefiBaseTypes.h>\r
-#include <Common/FirmwareVolumeHeader.h>\r
-#include <Common/MultiPhase.h>\r
-\r
-#include "EfiUtilityMsgs.h"\r
-#include "FlashDefFile.h"\r
-#include "SimpleFileParsing.h"\r
-#include "Symbols.h"\r
-\r
-//\r
-// #include "TrackMallocFree.h"\r
-//\r
-#define WCHAR_T           char\r
-#define MAX_STRING_LEN    256\r
-#define MAX_NAME_LEN      128\r
-#define BUFFER_SIZE       1024\r
-#define MAX_ATTR_LEN      128\r
-#define MAX_AREATYPE_LEN  128\r
-#define COLUMN2_START     60\r
-#define COLUMN3_START     70\r
-//\r
-// Information for each subregions defined in the fdf file will be saved in these\r
-//\r
-typedef struct _FLASH_SUBREGION_DESCRIPTION {\r
-  struct _FLASH_SUBREGION_DESCRIPTION *Next;\r
-  int                                 CreateHob;                  // to add to the auto-created HOB array\r
-  WCHAR_T                             Name[MAX_NAME_LEN];         // each subregion within a region must have a unique name\r
-  unsigned int                        Size;                       // size, in bytes, of this subregion\r
-  unsigned int                        SizeLeft;                   // used when creating the image\r
-  WCHAR_T                             Attributes[MAX_ATTR_LEN];   // subregion attributes used in the output HOB\r
-  WCHAR_T                             AreaType[MAX_AREATYPE_LEN]; // subregion area type used in the output HOB\r
-  EFI_GUID                            NameGuid;                   // used in the output HOB\r
-  WCHAR_T                             NameGuidString[MAX_NAME_LEN];\r
-  EFI_GUID                            AreaTypeGuid;               // used in the output HOB\r
-  WCHAR_T                             AreaTypeGuidString[MAX_NAME_LEN];\r
-  EFI_GUID                            FileSystemGuid;             // used in the output HOB\r
-  WCHAR_T                             FileSystemGuidString[MAX_NAME_LEN];\r
-} FLASH_SUBREGION_DESCRIPTION;\r
-\r
-//\r
-// Information for each block in a flash device will be saved in one of these.\r
-// We'll also use it for region definitions.\r
-//\r
-typedef struct _FLASH_BLOCK_DESCRIPTION {\r
-  struct _FLASH_BLOCK_DESCRIPTION *Next;                      // next block in the linked list\r
-  WCHAR_T                         Name[MAX_NAME_LEN];         // each block must have a unique name\r
-  unsigned int                    Size;                       // size, in bytes, of this block\r
-  unsigned int                    SizeLeft;                   // for use when creating image\r
-  unsigned int                    Flags;                      // user-defined flags for the block\r
-  unsigned int                    Alignment;                  // power of 2 alignment\r
-  WCHAR_T                         Attributes[MAX_ATTR_LEN];   // only used for Region definitions\r
-  WCHAR_T                         AreaType[MAX_AREATYPE_LEN]; // only used for Region definitions\r
-  FLASH_SUBREGION_DESCRIPTION     *Subregions;\r
-  FLASH_SUBREGION_DESCRIPTION     *LastSubregion;\r
-} FLASH_BLOCK_DESCRIPTION;\r
-\r
-//\r
-// Information for each flash device will be saved in one of these\r
-//\r
-typedef struct _FLASH_DEVICE_DESCRIPTION {\r
-  struct _FLASH_DEVICE_DESCRIPTION  *Next;              // next flash device in our linked list\r
-  int                               ErasePolarity;      // erase polarity of the flash device\r
-  unsigned int                      BaseAddress;        // base address of the flash device\r
-  unsigned int                      Size;               // total size, in bytes, of the flash device\r
-  WCHAR_T                           Name[MAX_NAME_LEN]; // name of the flash device\r
-  FLASH_BLOCK_DESCRIPTION           *PBlocks;           // linked list of physical block descriptors\r
-  FLASH_BLOCK_DESCRIPTION           *LastPBlock;        // last block in the linked list\r
-  FLASH_BLOCK_DESCRIPTION           *Regions;           // linked list of flash region descriptors\r
-  FLASH_BLOCK_DESCRIPTION           *LastRegion;        // last region in the linked list\r
-} FLASH_DEVICE_DESCRIPTION;\r
-\r
-//\r
-// For image definitions, they can specify a file name or raw data bytes. Keep a linked list.\r
-//\r
-typedef struct _IMAGE_DEFINITION_ENTRY {\r
-  struct _IMAGE_DEFINITION_ENTRY  *Next;\r
-  WCHAR_T                         RegionName[MAX_NAME_LEN];\r
-  WCHAR_T                         SubregionName[MAX_NAME_LEN];\r
-  WCHAR_T                         Name[MAX_NAME_LEN]; // file or data name\r
-  int                             IsRawData;          // non-zero if raw data bytes\r
-  unsigned int                    RawDataSize;\r
-  char                            *RawData;\r
-  int                             Optional;           // optional file (don't include if it doesn't exist)\r
-} IMAGE_DEFINITION_ENTRY;\r
-\r
-//\r
-// When we parse an image definition, save all the data for each in one of these\r
-//\r
-typedef struct _IMAGE_DEFINITION {\r
-  struct _IMAGE_DEFINITION  *Next;\r
-  WCHAR_T                   Name[MAX_NAME_LEN];\r
-  IMAGE_DEFINITION_ENTRY    *Entries;\r
-  IMAGE_DEFINITION_ENTRY    *LastEntry;\r
-} IMAGE_DEFINITION;\r
-\r
-typedef struct {\r
-  char  *BufferStart;\r
-  char  *BufferEnd;\r
-  char  *BufferPos;\r
-} BUFFER_DATA;\r
-\r
-static const char               *CIncludeHeader = "/*++\n\n"\r
-"  DO NOT EDIT -- file auto-generated by FlashMap utility\n\n""--*/\n""\n""#ifndef _FLASH_MAP_H_\n"\r
-"#define _FLASH_MAP_H_\n\n";\r
-//\r
-//  "#include \"EfiFlashMap.h\"\n\n";\r
-//\r
-static const char               *CIncludeFooter = "#endif // #ifndef _FLASH_MAP_H_\n\n";\r
-\r
-static const char               *CFlashMapDataFileHeader = "/*++\n\n"\r
-"  DO NOT EDIT -- file auto-generated by FlashMap utility\n\n""--*/\n""\n";\r
-\r
-static FLASH_DEVICE_DESCRIPTION *mFlashDevices      = NULL;\r
-static IMAGE_DEFINITION         *mImageDefinitions  = NULL;\r
-\r
-//\r
-// Local function prototypes\r
-//\r
-static\r
-BUFFER_DATA                     *\r
-CreateBufferData (\r
-  VOID\r
-  );\r
-\r
-static\r
-BOOLEAN\r
-AddBufferDataByte (\r
-  BUFFER_DATA *Buffer,\r
-  char        Data\r
-  );\r
-\r
-static\r
-void\r
-FreeBufferData (\r
-  BUFFER_DATA *Buffer,\r
-  BOOLEAN     FreeData\r
-  );\r
-\r
-static\r
-char                            *\r
-GetBufferData (\r
-  BUFFER_DATA *Buffer,\r
-  int         *BufferSize\r
-  );\r
-\r
-static\r
-FLASH_SUBREGION_DESCRIPTION     *\r
-ParseSubregionDefinition (\r
-  unsigned int  SizeLeft\r
-  );\r
-\r
-void\r
-FDFConstructor (\r
-  VOID\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Initialization routine for the services that operate on a flash\r
-  definition file.\r
-\r
-Arguments:\r
-  None.\r
-\r
-Returns:\r
-  NA\r
-\r
---*/\r
-{\r
-  mFlashDevices     = NULL;\r
-  mImageDefinitions = NULL;\r
-}\r
-\r
-void\r
-FDFDestructor (\r
-  VOID\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Finalization/cleanup routine for the services that operate on a flash\r
-  definition file.\r
-\r
-Arguments:\r
-  None.\r
-\r
-Returns:\r
-  NA\r
-\r
---*/\r
-{\r
-  FLASH_BLOCK_DESCRIPTION     *FBNext;\r
-  FLASH_DEVICE_DESCRIPTION    *FDNext;\r
-  IMAGE_DEFINITION            *IDNext;\r
-  IMAGE_DEFINITION_ENTRY      *IDENext;\r
-  FLASH_SUBREGION_DESCRIPTION *SubNext;\r
-  //\r
-  // Go through all our flash devices and free the memory\r
-  //\r
-  while (mFlashDevices != NULL) {\r
-    //\r
-    // Free the physical block definitions\r
-    //\r
-    while (mFlashDevices->PBlocks != NULL) {\r
-      FBNext = mFlashDevices->PBlocks->Next;\r
-      _free (mFlashDevices->PBlocks);\r
-      mFlashDevices->PBlocks = FBNext;\r
-    }\r
-    //\r
-    // Free the region definitions\r
-    //\r
-    while (mFlashDevices->Regions != NULL) {\r
-      FBNext = mFlashDevices->Regions->Next;\r
-      //\r
-      // First free the subregion definitions\r
-      //\r
-      while (mFlashDevices->Regions->Subregions != NULL) {\r
-        SubNext = mFlashDevices->Regions->Subregions->Next;\r
-        _free (mFlashDevices->Regions->Subregions);\r
-        mFlashDevices->Regions->Subregions = SubNext;\r
-      }\r
-\r
-      _free (mFlashDevices->Regions);\r
-      mFlashDevices->Regions = FBNext;\r
-    }\r
-\r
-    FDNext = mFlashDevices->Next;\r
-    _free (mFlashDevices);\r
-    mFlashDevices = FDNext;\r
-  }\r
-  //\r
-  // Free up the image definitions, and the data\r
-  //\r
-  while (mImageDefinitions != NULL) {\r
-    //\r
-    // Free the entries\r
-    //\r
-    while (mImageDefinitions->Entries != NULL) {\r
-      IDENext = mImageDefinitions->Entries->Next;\r
-      if (mImageDefinitions->Entries->RawData != NULL) {\r
-        _free (mImageDefinitions->Entries->RawData);\r
-      }\r
-\r
-      _free (mImageDefinitions->Entries);\r
-      mImageDefinitions->Entries = IDENext;\r
-    }\r
-\r
-    IDNext = mImageDefinitions->Next;\r
-    _free (mImageDefinitions);\r
-    mImageDefinitions = IDNext;\r
-  }\r
-}\r
-\r
-STATUS\r
-FDFParseFile (\r
-  char    *FileName\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Parse the specified flash definition file, saving the definitions in\r
-  file-static variables for use by other functions.\r
-  \r
-Arguments:\r
-  FileName    - name of the input flash definition text file.\r
-\r
-Returns:\r
-  STATUS_SUCCESS    - file parsed with no errors or warnings\r
-  STATUS_WARNING    - warnings, but no errors, were encountered while parsing\r
-  STATUS_ERROR      - errors were encountered while parsing\r
-  \r
---*/\r
-{\r
-  FILE                        *Fptr;\r
-  STATUS                      Status;\r
-  unsigned int                Num;\r
-  FLASH_DEVICE_DESCRIPTION    *FDDesc;\r
-  FLASH_BLOCK_DESCRIPTION     *FBlockDesc;\r
-  FLASH_BLOCK_DESCRIPTION     *TempBlockDesc;\r
-  FLASH_SUBREGION_DESCRIPTION *Subregion;\r
-  FLASH_SUBREGION_DESCRIPTION *TempSubregion;\r
-  unsigned int                BlockSizeLeft;\r
-  unsigned int                RegionSizeLeft;\r
-  unsigned int                SubregionSizeLeft;\r
-  int                         ErrorCount;\r
-  int                         WarningCount;\r
-  IMAGE_DEFINITION            *ImageDef;\r
-  IMAGE_DEFINITION_ENTRY      *ImageDefEntry;\r
-  IMAGE_DEFINITION_ENTRY      *TempImageDefEntry;\r
-  BUFFER_DATA                 *BufferData;\r
-  char                        Str[100];\r
-  BOOLEAN                     PreviousComma;\r
-\r
-  if ((Fptr = fopen (FileName, "r")) == NULL) {\r
-    Error (NULL, 0, 0, FileName, "failed to open input flash definition file for reading");\r
-    return STATUS_ERROR;\r
-  }\r
-\r
-  fclose (Fptr);\r
-  Status        = STATUS_SUCCESS;\r
-  ErrorCount    = 0;\r
-  WarningCount  = 0;\r
-  //\r
-  // Initialize the simple-file-parsing routines\r
-  //\r
-  SFPInit ();\r
-  //\r
-  // Open the file\r
-  //\r
-  if ((Status = SFPOpenFile (FileName)) != STATUS_SUCCESS) {\r
-    return Status;\r
-  }\r
-  //\r
-  // Parse the file. Should start with a series of these:\r
-  // FlashDevice {\r
-  //   Name = "FLASH_1234", Size = 0x2004, BaseAddress = 0xFFF0000, ErasePolarity = 1,\r
-  //   Block { Name = "BLOCK1",  Size = 0x1000, Flags = 0x0001 }\r
-  //   Block { Name = "BLOCK2",  Size = 0x1004, Flags = 0x0002 }\r
-  //   Region  { Name = "REGION_NAME", Size = 0x2004, Align= 4 }\r
-  // }\r
-  //\r
-  while (SFPIsKeyword ("FlashDevice")) {\r
-    //\r
-    // Allocate memory for new flash device description block\r
-    //\r
-    FDDesc = (FLASH_DEVICE_DESCRIPTION *) _malloc (sizeof (FLASH_DEVICE_DESCRIPTION));\r
-    if (FDDesc == NULL) {\r
-      Error (__FILE__, __LINE__, 0, "memory allocation failure", NULL);\r
-      ErrorCount++;\r
-      goto Done;\r
-    }\r
-\r
-    memset (FDDesc, 0, sizeof (FLASH_DEVICE_DESCRIPTION));\r
-    //\r
-    // Open brace -- warning if not there\r
-    //\r
-    if (!SFPIsToken ("{")) {\r
-      Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected {", NULL);\r
-      WarningCount++;\r
-    }\r
-    //\r
-    // Parse:  Name = "DeviceName",\r
-    //\r
-    if (!SFPIsKeyword ("Name")) {\r
-      Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected 'Name'", NULL);\r
-      ErrorCount++;\r
-      goto Done;\r
-    }\r
-\r
-    if (!SFPIsToken ("=")) {\r
-      Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected '='", NULL);\r
-      WarningCount++;\r
-    }\r
-\r
-    if (!SFPGetQuotedString (FDDesc->Name, sizeof (FDDesc->Name))) {\r
-      Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected quoted name of flash device", NULL);\r
-      ErrorCount++;\r
-      goto Done;\r
-    }\r
-\r
-    if (!SFPIsToken (",")) {\r
-      Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected comma following flash device name", NULL);\r
-      WarningCount++;\r
-    }\r
-    //\r
-    // Parse: Size = 0x20000,\r
-    //\r
-    if (!SFPIsKeyword ("Size")) {\r
-      Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected 'Size'", NULL);\r
-      ErrorCount++;\r
-      goto Done;\r
-    }\r
-\r
-    if (!SFPIsToken ("=")) {\r
-      Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected '='", NULL);\r
-      WarningCount++;\r
-    }\r
-\r
-    if (!SFPGetNumber (&FDDesc->Size)) {\r
-      Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected numeric Size value", NULL);\r
-      ErrorCount++;\r
-      goto Done;\r
-    }\r
-    //\r
-    // Check for 0 size\r
-    //\r
-    if (FDDesc->Size == 0) {\r
-      Error (SFPGetFileName (), SFPGetLineNumber (), 0, FDDesc->Name, "Size field cannot be 0", NULL);\r
-      ErrorCount++;\r
-      goto Done;\r
-    }\r
-\r
-    SFPIsToken (",");\r
-    //\r
-    // Parse: BaseAddress = 0xFFF0000,\r
-    //\r
-    if (!SFPIsKeyword ("BaseAddress")) {\r
-      Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected 'BaseAddress'", NULL);\r
-      ErrorCount++;\r
-      goto Done;\r
-    }\r
-\r
-    if (!SFPIsToken ("=")) {\r
-      Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected '='", NULL);\r
-      WarningCount++;\r
-    }\r
-\r
-    if (!SFPGetNumber (&FDDesc->BaseAddress)) {\r
-      Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected numeric value for BaseAddress", NULL);\r
-      ErrorCount++;\r
-      goto Done;\r
-    }\r
-\r
-    if (!SFPIsToken (",")) {\r
-      Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected comma following BaseAddress value", NULL);\r
-      WarningCount++;\r
-    }\r
-    //\r
-    // Parse: ErasePolarity = 1,\r
-    //\r
-    if (!SFPIsKeyword ("ErasePolarity")) {\r
-      Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected 'ErasePolarity'", NULL);\r
-      ErrorCount++;\r
-      goto Done;\r
-    }\r
-\r
-    if (!SFPIsToken ("=")) {\r
-      Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected '='", NULL);\r
-      WarningCount++;\r
-    }\r
-\r
-    if (!SFPGetNumber (&Num) || ((Num != 0) && (Num != 1))) {\r
-      Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected numeric erase polarity value 1 or 0", NULL);\r
-      ErrorCount++;\r
-      goto Done;\r
-    }\r
-\r
-    FDDesc->ErasePolarity = Num;\r
-    if (!SFPIsToken (",")) {\r
-      Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected comma following erase polarity value", NULL);\r
-      WarningCount++;\r
-    }\r
-    //\r
-    // Parse array of:\r
-    //   Block {  Name = "BLOCK1", Size = 0x1000, Flags = 0x0001 }\r
-    //\r
-    // Keep track of size to make sure the sum of the physical blocks and region sizes do not\r
-    // exceed the size of the flash device.\r
-    //\r
-    BlockSizeLeft   = FDDesc->Size;\r
-    RegionSizeLeft  = FDDesc->Size;\r
-    while (SFPIsKeyword ("Block")) {\r
-      //\r
-      // Allocate memory for a new physical block descriptor\r
-      //\r
-      FBlockDesc = (FLASH_BLOCK_DESCRIPTION *) _malloc (sizeof (FLASH_BLOCK_DESCRIPTION));\r
-      if (FBlockDesc == NULL) {\r
-        Error (__FILE__, __LINE__, 0, "memory allocation failure", NULL);\r
-        ErrorCount++;\r
-        goto Done;\r
-      }\r
-\r
-      memset (FBlockDesc, 0, sizeof (FLASH_BLOCK_DESCRIPTION));\r
-      //\r
-      // Open brace -- warning if not there\r
-      //\r
-      if (!SFPIsToken ("{")) {\r
-        Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected {", NULL);\r
-        WarningCount++;\r
-      }\r
-      //\r
-      // Parse:  Name = "BlockName",\r
-      //\r
-      if (!SFPIsKeyword ("Name")) {\r
-        Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected 'Name'", NULL);\r
-        ErrorCount++;\r
-        goto Done;\r
-      }\r
-\r
-      if (!SFPIsToken ("=")) {\r
-        Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected '='", NULL);\r
-        WarningCount++;\r
-      }\r
-\r
-      if (!SFPGetQuotedString (FBlockDesc->Name, sizeof (FBlockDesc->Name))) {\r
-        Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected quoted name of physical block", NULL);\r
-        ErrorCount++;\r
-        goto Done;\r
-      }\r
-      //\r
-      // Make sure there are no other physical block names with this same name\r
-      //\r
-      for (TempBlockDesc = FDDesc->PBlocks; TempBlockDesc != NULL; TempBlockDesc = TempBlockDesc->Next) {\r
-        if (strcmp (TempBlockDesc->Name, FBlockDesc->Name) == 0) {\r
-          Error (\r
-            SFPGetFileName (),\r
-            SFPGetLineNumber (),\r
-            0,\r
-            TempBlockDesc->Name,\r
-            "physical block with this name already defined"\r
-            );\r
-          ErrorCount++;\r
-        }\r
-      }\r
-\r
-      if (!SFPIsToken (",")) {\r
-        Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected comma following physical block name", NULL);\r
-        WarningCount++;\r
-      }\r
-      //\r
-      // Parse: Size = 0x2000,\r
-      //\r
-      if (!SFPIsKeyword ("Size")) {\r
-        Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected 'Size'", NULL);\r
-        ErrorCount++;\r
-        goto Done;\r
-      }\r
-\r
-      if (!SFPIsToken ("=")) {\r
-        Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected '='", NULL);\r
-        WarningCount++;\r
-      }\r
-\r
-      if (!SFPGetNumber (&FBlockDesc->Size)) {\r
-        Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected numeric Size value", NULL);\r
-        ErrorCount++;\r
-        goto Done;\r
-      }\r
-      //\r
-      // Make sure the sum of physical blocks so far does not exceed flash device size\r
-      //\r
-      if (BlockSizeLeft < FBlockDesc->Size) {\r
-        Error (\r
-          SFPGetFileName (),\r
-          SFPGetLineNumber (),\r
-          0,\r
-          "sum of physical block sizes exceeds flash device size",\r
-          NULL\r
-          );\r
-        ErrorCount++;\r
-      }\r
-\r
-      BlockSizeLeft -= FBlockDesc->Size;\r
-      SFPIsToken (",");\r
-      //\r
-      // Optional parse: Flags = 0xFFF0000,\r
-      //\r
-      if (SFPIsKeyword ("Flags")) {\r
-        if (!SFPIsToken ("=")) {\r
-          Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected '='", NULL);\r
-          WarningCount++;\r
-        }\r
-\r
-        if (!SFPGetNumber (&FBlockDesc->Flags)) {\r
-          Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected numeric value for Flags", NULL);\r
-          ErrorCount++;\r
-          goto Done;\r
-        }\r
-      }\r
-\r
-      if (!SFPIsToken ("}")) {\r
-        Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected PhysicalBlock closing brace '}'", NULL);\r
-        WarningCount++;\r
-      }\r
-      //\r
-      // Add the physical block descriptor to the end of the linked list\r
-      //\r
-      if (FDDesc->LastPBlock != NULL) {\r
-        FDDesc->LastPBlock->Next = FBlockDesc;\r
-      } else {\r
-        FDDesc->PBlocks = FBlockDesc;\r
-      }\r
-\r
-      FDDesc->LastPBlock = FBlockDesc;\r
-    }\r
-    //\r
-    // Make sure sum of sizes of physical blocks added up to size of flash device\r
-    //\r
-    if (BlockSizeLeft != 0) {\r
-      Error (\r
-        SFPGetFileName (),\r
-        SFPGetLineNumber (),\r
-        0,\r
-        NULL,\r
-        "sum of sizes of physical blocks (0x%08X) != flash device size (0x%08X) : delta = 0x%08X",\r
-        FDDesc->Size - BlockSizeLeft,\r
-        FDDesc->Size,\r
-        BlockSizeLeft\r
-        );\r
-      ErrorCount++;\r
-    }\r
-    //\r
-    // Parse array of:\r
-    //   Region { Name = "REGION_1", Size = 0x2000, Flags = 0x1234, Alignment = 4, Attributes = "str", AreaType = "str" }\r
-    //\r
-    while (SFPIsKeyword ("Region")) {\r
-      //\r
-      // Allocate memory for a new physical block descriptor\r
-      //\r
-      FBlockDesc = (FLASH_BLOCK_DESCRIPTION *) _malloc (sizeof (FLASH_BLOCK_DESCRIPTION));\r
-      if (FBlockDesc == NULL) {\r
-        Error (__FILE__, __LINE__, 0, "memory allocation failure", NULL);\r
-        ErrorCount++;\r
-        goto Done;\r
-      }\r
-\r
-      memset (FBlockDesc, 0, sizeof (FLASH_BLOCK_DESCRIPTION));\r
-      //\r
-      // Open brace -- warning if not there\r
-      //\r
-      if (!SFPIsToken ("{")) {\r
-        Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected {", NULL);\r
-        WarningCount++;\r
-      }\r
-      //\r
-      // Parse:  Name = "BlockName",\r
-      //\r
-      if (!SFPIsKeyword ("Name")) {\r
-        Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected 'Name'", NULL);\r
-        ErrorCount++;\r
-        goto Done;\r
-      }\r
-\r
-      if (!SFPIsToken ("=")) {\r
-        Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected '='", NULL);\r
-        WarningCount++;\r
-      }\r
-\r
-      if (!SFPGetQuotedString (FBlockDesc->Name, sizeof (FBlockDesc->Name))) {\r
-        Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected quoted Region name", NULL);\r
-        ErrorCount++;\r
-        goto Done;\r
-      }\r
-      //\r
-      // Make sure there are no other region names with this same name\r
-      //\r
-      for (TempBlockDesc = FDDesc->Regions; TempBlockDesc != NULL; TempBlockDesc = TempBlockDesc->Next) {\r
-        if (strcmp (TempBlockDesc->Name, FBlockDesc->Name) == 0) {\r
-          Error (\r
-            SFPGetFileName (),\r
-            SFPGetLineNumber (),\r
-            0,\r
-            TempBlockDesc->Name,\r
-            "Region with this name already defined"\r
-            );\r
-          ErrorCount++;\r
-        }\r
-      }\r
-\r
-      if (!SFPIsToken (",")) {\r
-        Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected comma following Region name", NULL);\r
-        WarningCount++;\r
-      }\r
-      //\r
-      // Parse: Size = 0x2000,\r
-      //\r
-      if (!SFPIsKeyword ("Size")) {\r
-        Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected 'Size'", NULL);\r
-        ErrorCount++;\r
-        goto Done;\r
-      }\r
-\r
-      if (!SFPIsToken ("=")) {\r
-        Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected '='", NULL);\r
-        WarningCount++;\r
-      }\r
-\r
-      if (!SFPGetNumber (&FBlockDesc->Size)) {\r
-        Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected numeric Size value", NULL);\r
-        ErrorCount++;\r
-        goto Done;\r
-      }\r
-\r
-      if (!SFPIsToken (",")) {\r
-        Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected ','", NULL);\r
-      }\r
-      //\r
-      // Make sure the sum of regions so far does not exceed flash device size\r
-      //\r
-      if (RegionSizeLeft < FBlockDesc->Size) {\r
-        Error (SFPGetFileName (), SFPGetLineNumber (), 0, "sum of Region sizes exceeds flash device size", NULL);\r
-        ErrorCount++;\r
-      }\r
-\r
-      RegionSizeLeft -= FBlockDesc->Size;\r
-      //\r
-      // Optional parse: Flags = 0xFFF0000,\r
-      //\r
-      if (SFPIsKeyword ("Flags")) {\r
-        if (!SFPIsToken ("=")) {\r
-          Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected '='", NULL);\r
-          WarningCount++;\r
-        }\r
-\r
-        if (!SFPGetNumber (&FBlockDesc->Flags)) {\r
-          Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected numeric value for Flags", NULL);\r
-          ErrorCount++;\r
-          goto Done;\r
-        }\r
-        //\r
-        // comma\r
-        //\r
-        if (!SFPIsToken (",")) {\r
-          Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected ','", NULL);\r
-        }\r
-      }\r
-      //\r
-      // Optional parse: Alignment = 4\r
-      //\r
-      if (SFPIsKeyword ("Alignment")) {\r
-        if (!SFPIsToken ("=")) {\r
-          Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected '='", NULL);\r
-          WarningCount++;\r
-        }\r
-\r
-        if (!SFPGetNumber (&FBlockDesc->Alignment)) {\r
-          Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected numeric Alignment value", NULL);\r
-          ErrorCount++;\r
-          goto Done;\r
-        }\r
-        //\r
-        // comma\r
-        //\r
-        if (!SFPIsToken (",")) {\r
-          Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected ','", NULL);\r
-        }\r
-      }\r
-      //\r
-      // Parse:  Attributes = "String",\r
-      //\r
-      if (!SFPIsKeyword ("Attributes")) {\r
-        Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected 'Attributes'", NULL);\r
-        ErrorCount++;\r
-        goto Done;\r
-      }\r
-\r
-      if (!SFPIsToken ("=")) {\r
-        Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected '='", NULL);\r
-        WarningCount++;\r
-      }\r
-\r
-      if (!SFPGetQuotedString (FBlockDesc->Attributes, sizeof (FBlockDesc->Attributes))) {\r
-        Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected quoted Attributes string", NULL);\r
-        ErrorCount++;\r
-        goto Done;\r
-      }\r
-\r
-      if (!SFPIsToken (",")) {\r
-        Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected ','", NULL);\r
-      }\r
-      //\r
-      // Parse:  AreaType = "String",\r
-      //\r
-      if (!SFPIsKeyword ("AreaType")) {\r
-        Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected 'AreaType'", NULL);\r
-        ErrorCount++;\r
-        goto Done;\r
-      }\r
-\r
-      if (!SFPIsToken ("=")) {\r
-        Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected '='", NULL);\r
-        WarningCount++;\r
-      }\r
-\r
-      if (!SFPGetQuotedString (FBlockDesc->AreaType, sizeof (FBlockDesc->AreaType))) {\r
-        Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected quoted AreaType string", NULL);\r
-        ErrorCount++;\r
-        goto Done;\r
-      }\r
-\r
-      PreviousComma = SFPIsToken (",");\r
-      //\r
-      // Parse optional Subregion definitions\r
-      //\r
-      SubregionSizeLeft = FBlockDesc->Size;\r
-      while (SFPIsToken ("Subregion")) {\r
-        if (!PreviousComma) {\r
-          Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected ',' before 'Subregion'", NULL);\r
-          WarningCount++;\r
-          PreviousComma = TRUE;\r
-        }\r
-\r
-        Subregion = ParseSubregionDefinition (SubregionSizeLeft);\r
-        if (Subregion == NULL) {\r
-          ErrorCount++;\r
-          goto Done;\r
-        }\r
-\r
-        SubregionSizeLeft -= Subregion->Size;\r
-        //\r
-        // Add it to the end of our list\r
-        //\r
-        if (FBlockDesc->Subregions == NULL) {\r
-          FBlockDesc->Subregions = Subregion;\r
-        } else {\r
-          FBlockDesc->LastSubregion->Next = Subregion;\r
-        }\r
-\r
-        FBlockDesc->LastSubregion = Subregion;\r
-        //\r
-        // Make sure all subregion names are unique. We do this each time\r
-        // through so that we catch the error immediately after it happens, in\r
-        // which case the reported line number is at least close to where the\r
-        // problem lies. We don't exit on the error because we can continue parsing\r
-        // the script to perhaps catch other errors or warnings.\r
-        //\r
-        for (Subregion = FBlockDesc->Subregions; Subregion != NULL; Subregion = Subregion->Next) {\r
-          for (TempSubregion = Subregion->Next; TempSubregion != NULL; TempSubregion = TempSubregion->Next) {\r
-            if (strcmp (Subregion->Name, TempSubregion->Name) == 0) {\r
-              Error (SFPGetFileName (), SFPGetLineNumber (), 0, Subregion->Name, "duplicate Subregion name");\r
-              ErrorCount++;\r
-            }\r
-          }\r
-        }\r
-      }\r
-\r
-      if (!SFPIsToken ("}")) {\r
-        Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected Region closing brace '}'", NULL);\r
-        WarningCount++;\r
-      }\r
-      //\r
-      // Add the region descriptor to the end of the linked list\r
-      //\r
-      if (FDDesc->LastRegion != NULL) {\r
-        FDDesc->LastRegion->Next = FBlockDesc;\r
-      } else {\r
-        FDDesc->Regions = FBlockDesc;\r
-      }\r
-\r
-      FDDesc->LastRegion = FBlockDesc;\r
-    }\r
-    //\r
-    // Make sure sum of sizes of regions adds up to size of flash device\r
-    //\r
-    if (RegionSizeLeft != 0) {\r
-      Error (\r
-        SFPGetFileName (),\r
-        SFPGetLineNumber (),\r
-        0,\r
-        NULL,\r
-        "sum of sizes of Regions (0x%08X) != flash device size (0x%08X) : delta = 0x%08X",\r
-        FDDesc->Size - RegionSizeLeft,\r
-        FDDesc->Size,\r
-        RegionSizeLeft\r
-        );\r
-      ErrorCount++;\r
-    }\r
-    //\r
-    // Look for closing brace\r
-    //\r
-    if (!SFPIsToken ("}")) {\r
-      Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected FlashDevice closing brace '}'", NULL);\r
-      WarningCount++;\r
-    }\r
-    //\r
-    // Add this flash description to the list\r
-    //\r
-    FDDesc->Next  = mFlashDevices;\r
-    mFlashDevices = FDDesc;\r
-  }\r
-\r
-  while (SFPIsKeyword ("FlashDeviceImage")) {\r
-    //\r
-    // Allocate memory for a new FD image definition\r
-    //\r
-    ImageDef = (IMAGE_DEFINITION *) _malloc (sizeof (IMAGE_DEFINITION));\r
-    if (ImageDef == NULL) {\r
-      Error (__FILE__, __LINE__, 0, "memory allocation failure", NULL);\r
-      ErrorCount++;\r
-      goto Done;\r
-    }\r
-\r
-    memset (ImageDef, 0, sizeof (IMAGE_DEFINITION));\r
-    //\r
-    // Open brace -- warning if not there\r
-    //\r
-    if (!SFPIsToken ("{")) {\r
-      Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected {", NULL);\r
-      WarningCount++;\r
-    }\r
-    //\r
-    // Parse:  Name = "ImageName",\r
-    //\r
-    if (!SFPIsKeyword ("Name")) {\r
-      Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected 'Name'", NULL);\r
-      ErrorCount++;\r
-      goto Done;\r
-    }\r
-\r
-    if (!SFPIsToken ("=")) {\r
-      Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected '='", NULL);\r
-      WarningCount++;\r
-    }\r
-\r
-    if (!SFPGetQuotedString (ImageDef->Name, sizeof (ImageDef->Name))) {\r
-      Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected quoted name of image", NULL);\r
-      ErrorCount++;\r
-      goto Done;\r
-    }\r
-\r
-    if (!SFPIsToken (",")) {\r
-      Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected comma following image name", NULL);\r
-      WarningCount++;\r
-    }\r
-\r
-    while (1) {\r
-      //\r
-      // Parse: File { Name = "FV\FvOem.fv", Region = "REGION_OEM", Optional = TRUE }\r
-      //\r
-      if (SFPIsKeyword ("File")) {\r
-        ImageDefEntry = (IMAGE_DEFINITION_ENTRY *) _malloc (sizeof (IMAGE_DEFINITION_ENTRY));\r
-        if (ImageDefEntry == NULL) {\r
-          Error (__FILE__, __LINE__, 0, "memory allocation failure", NULL);\r
-          ErrorCount++;\r
-          goto Done;\r
-        }\r
-\r
-        memset (ImageDefEntry, 0, sizeof (IMAGE_DEFINITION_ENTRY));\r
-        //\r
-        // Open brace -- warning if not there\r
-        //\r
-        if (!SFPIsToken ("{")) {\r
-          Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected {", NULL);\r
-          WarningCount++;\r
-        }\r
-        //\r
-        // Parse: Name = "FileName.txt"\r
-        //\r
-        if (!SFPIsKeyword ("Name")) {\r
-          Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected 'Name'", NULL);\r
-          ErrorCount++;\r
-          goto Done;\r
-        }\r
-\r
-        if (!SFPIsToken ("=")) {\r
-          Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected '='", NULL);\r
-          WarningCount++;\r
-        }\r
-\r
-        if (!SFPGetQuotedString (ImageDefEntry->Name, sizeof (ImageDefEntry->Name))) {\r
-          Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected quoted name of file", NULL);\r
-          ErrorCount++;\r
-          goto Done;\r
-        }\r
-\r
-        if (!SFPIsToken (",")) {\r
-          Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected comma following file name", NULL);\r
-          WarningCount++;\r
-        }\r
-        //\r
-        // Parse: Region = "REGION_NAME"\r
-        //\r
-        if (!SFPIsKeyword ("Region")) {\r
-          Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected 'Region'", NULL);\r
-          ErrorCount++;\r
-          goto Done;\r
-        }\r
-\r
-        if (!SFPIsToken ("=")) {\r
-          Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected '='", NULL);\r
-          WarningCount++;\r
-        }\r
-\r
-        if (!SFPGetQuotedString (ImageDefEntry->RegionName, sizeof (ImageDefEntry->RegionName))) {\r
-          Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected quoted Region name", NULL);\r
-          ErrorCount++;\r
-          goto Done;\r
-        }\r
-\r
-        if (!SFPIsToken (",")) {\r
-          Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected comma following Region name", NULL);\r
-          WarningCount++;\r
-        }\r
-        //\r
-        // Parse optional: Subregion = "SUBREGION_NAME"\r
-        //\r
-        if (SFPIsKeyword ("Subregion")) {\r
-          if (!SFPIsToken ("=")) {\r
-            Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected '='", NULL);\r
-            WarningCount++;\r
-          }\r
-\r
-          if (!SFPGetQuotedString (ImageDefEntry->SubregionName, sizeof (ImageDefEntry->SubregionName))) {\r
-            Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected quoted Subegion name", NULL);\r
-            ErrorCount++;\r
-            goto Done;\r
-          }\r
-\r
-          if (!SFPIsToken (",")) {\r
-            Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected comma following Subregion name", NULL);\r
-            WarningCount++;\r
-          }\r
-          //\r
-          // For a given region, you can only place data using the region name, or the subregion names.\r
-          // In other words, you can't say File1->Region1 and File2->Region1.Subregion1. Enforce that\r
-          // here by checking that any previous entries with the same Region name had a Subregion specified\r
-          // as well.\r
-          //\r
-          for (TempImageDefEntry = ImageDef->Entries;\r
-               TempImageDefEntry != NULL;\r
-               TempImageDefEntry = TempImageDefEntry->Next\r
-              ) {\r
-            if (strcmp (TempImageDefEntry->Name, ImageDefEntry->Name) == 0) {\r
-              if (TempImageDefEntry->SubregionName[0] == 0) {\r
-                Error (\r
-                  SFPGetFileName (),\r
-                  SFPGetLineNumber (),\r
-                  0,\r
-                  TempImageDefEntry->RegionName,\r
-                  "data already placed on a region-basis in the region, can't place data using subregions"\r
-                  );\r
-                ErrorCount++;\r
-              }\r
-            }\r
-          }\r
-        }\r
-        //\r
-        // Optional parse: Optional = TRUE | FALSE\r
-        //\r
-        if (SFPIsKeyword ("Optional")) {\r
-          if (!SFPIsToken ("=")) {\r
-            Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected '='", NULL);\r
-            WarningCount++;\r
-          }\r
-\r
-          if (!SFPIsKeyword ("TRUE")) {\r
-            ImageDefEntry->Optional = 1;\r
-          } else if (SFPIsKeyword ("FALSE")) {\r
-            //\r
-            // Already set to 0\r
-            //\r
-          } else {\r
-            Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected 'TRUE' or 'FALSE'", NULL);\r
-            ErrorCount++;\r
-            goto Done;\r
-          }\r
-\r
-          SFPIsToken (",");\r
-        }\r
-        //\r
-        // Closing brace\r
-        //\r
-        if (!SFPIsToken ("}")) {\r
-          Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected '}' closing brace to File entry", NULL);\r
-          ErrorCount++;\r
-          goto Done;\r
-        }\r
-        //\r
-        // Add the entry to the end of the list\r
-        //\r
-        if (ImageDef->LastEntry != NULL) {\r
-          ImageDef->LastEntry->Next = ImageDefEntry;\r
-        } else {\r
-          ImageDef->Entries = ImageDefEntry;\r
-        }\r
-\r
-        ImageDef->LastEntry = ImageDefEntry;\r
-      } else if (SFPIsKeyword ("RawData")) {\r
-        //\r
-        // Parse: RawData { Name = "PadBytes", Region = "REGION_1", Data = { 0x78, 0x56, 0x34, 0x12 }}\r
-        //\r
-        ImageDefEntry = (IMAGE_DEFINITION_ENTRY *) _malloc (sizeof (IMAGE_DEFINITION_ENTRY));\r
-        if (ImageDefEntry == NULL) {\r
-          Error (__FILE__, __LINE__, 0, "memory allocation failure", NULL);\r
-          ErrorCount++;\r
-          goto Done;\r
-        }\r
-\r
-        memset (ImageDefEntry, 0, sizeof (IMAGE_DEFINITION_ENTRY));\r
-        ImageDefEntry->IsRawData = 1;\r
-        //\r
-        // Open brace -- warning if not there\r
-        //\r
-        if (!SFPIsToken ("{")) {\r
-          Warning (\r
-            SFPGetFileName (),\r
-            SFPGetLineNumber (),\r
-            0,\r
-            "expected '{' opening brace for RawData definition",\r
-            NULL\r
-            );\r
-          WarningCount++;\r
-        }\r
-        //\r
-        // Parse: Name = "PadBytes"\r
-        //\r
-        if (!SFPIsKeyword ("Name")) {\r
-          Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected 'Name'", NULL);\r
-          ErrorCount++;\r
-          goto Done;\r
-        }\r
-\r
-        if (!SFPIsToken ("=")) {\r
-          Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected '='", NULL);\r
-          WarningCount++;\r
-        }\r
-\r
-        if (!SFPGetQuotedString (ImageDefEntry->Name, sizeof (ImageDefEntry->Name))) {\r
-          Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected quoted name of raw data", NULL);\r
-          ErrorCount++;\r
-          goto Done;\r
-        }\r
-\r
-        if (!SFPIsToken (",")) {\r
-          Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected comma following raw data name", NULL);\r
-          WarningCount++;\r
-        }\r
-        //\r
-        // Parse: Region = "REGION_NAME"\r
-        //\r
-        if (!SFPIsKeyword ("Region")) {\r
-          Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected 'Region'", NULL);\r
-          ErrorCount++;\r
-          goto Done;\r
-        }\r
-\r
-        if (!SFPIsToken ("=")) {\r
-          Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected '='", NULL);\r
-          WarningCount++;\r
-        }\r
-\r
-        if (!SFPGetQuotedString (ImageDefEntry->RegionName, sizeof (ImageDefEntry->RegionName))) {\r
-          Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected quoted Region name", NULL);\r
-          ErrorCount++;\r
-          goto Done;\r
-        }\r
-\r
-        if (!SFPIsToken (",")) {\r
-          Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected comma following Region name", NULL);\r
-          WarningCount++;\r
-        }\r
-        //\r
-        // Parse optional: Subregion = "SUBREGION_NAME"\r
-        //\r
-        if (SFPIsKeyword ("Subregion")) {\r
-          if (!SFPIsToken ("=")) {\r
-            Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected '='", NULL);\r
-            WarningCount++;\r
-          }\r
-\r
-          if (!SFPGetQuotedString (ImageDefEntry->SubregionName, sizeof (ImageDefEntry->SubregionName))) {\r
-            Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected quoted Subegion name", NULL);\r
-            ErrorCount++;\r
-            goto Done;\r
-          }\r
-\r
-          if (!SFPIsToken (",")) {\r
-            Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected comma following Subregion name", NULL);\r
-            WarningCount++;\r
-          }\r
-          //\r
-          // For a given region, you can only place data using the region name, or the subregion names.\r
-          // In other words, you can't say File1->Region1 and File2->Region1.Subregion1. Enforce that\r
-          // here by checking that any previous entries with the same Region name had a Subregion specified\r
-          // as well.\r
-          //\r
-          for (TempImageDefEntry = ImageDef->Entries;\r
-               TempImageDefEntry != NULL;\r
-               TempImageDefEntry = TempImageDefEntry->Next\r
-              ) {\r
-            if (strcmp (TempImageDefEntry->Name, ImageDefEntry->Name) == 0) {\r
-              if (TempImageDefEntry->SubregionName[0] == 0) {\r
-                Error (\r
-                  SFPGetFileName (),\r
-                  SFPGetLineNumber (),\r
-                  0,\r
-                  TempImageDefEntry->RegionName,\r
-                  "data already placed on a region-basis in the region, can't place data using subregions"\r
-                  );\r
-                ErrorCount++;\r
-              }\r
-            }\r
-          }\r
-        }\r
-        //\r
-        // Parse: Data = { 0x78, 0x56, 0x34, 0x12 }\r
-        //\r
-        if (!SFPIsKeyword ("Data")) {\r
-          Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected 'Data'", NULL);\r
-          ErrorCount++;\r
-          goto Done;\r
-        }\r
-\r
-        if (!SFPIsToken ("=")) {\r
-          Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected '='", NULL);\r
-          WarningCount++;\r
-        }\r
-\r
-        if (!SFPIsToken ("{")) {\r
-          Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected '{' preceeding data list", NULL);\r
-          WarningCount++;\r
-        }\r
-\r
-        if ((BufferData = CreateBufferData ()) == NULL) {\r
-          ErrorCount++;\r
-          goto Done;\r
-        }\r
-        //\r
-        // Read bytes from input file until closing brace\r
-        //\r
-        while (!SFPIsToken ("}")) {\r
-          if (!SFPGetNumber (&Num)) {\r
-            SFPGetNextToken (Str, sizeof (Str));\r
-            Error (SFPGetFileName (), SFPGetLineNumber (), 0, Str, "expected data value", Str);\r
-            ErrorCount++;\r
-            FreeBufferData (BufferData, TRUE);\r
-            goto Done;\r
-          } else {\r
-            //\r
-            // Only allow bytes\r
-            //\r
-            if (Num > 0xFF) {\r
-              Error (SFPGetFileName (), SFPGetLineNumber (), 0, "only values 0-255 (0x00-0xFF) allowed", NULL);\r
-              ErrorCount++;\r
-              FreeBufferData (BufferData, TRUE);\r
-              goto Done;\r
-            }\r
-\r
-            AddBufferDataByte (BufferData, (char) Num);\r
-            SFPIsToken (",");\r
-          }\r
-        }\r
-        //\r
-        // Now get the data and save it in our image entry\r
-        //\r
-        ImageDefEntry->RawData = GetBufferData (BufferData, &ImageDefEntry->RawDataSize);\r
-        FreeBufferData (BufferData, 0);\r
-        //\r
-        // Closing brace for RawData {}\r
-        //\r
-        if (!SFPIsToken ("}")) {\r
-          Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected '}' closing brace for RawData", NULL);\r
-          ErrorCount++;\r
-          goto Done;\r
-        }\r
-        //\r
-        // Add the entry to the end of the list\r
-        //\r
-        if (ImageDef->LastEntry != NULL) {\r
-          ImageDef->LastEntry->Next = ImageDefEntry;\r
-        } else {\r
-          ImageDef->Entries = ImageDefEntry;\r
-        }\r
-\r
-        ImageDef->LastEntry = ImageDefEntry;\r
-      } else if (SFPIsToken ("}")) {\r
-        //\r
-        // Closing brace for FDImage {}\r
-        //\r
-        break;\r
-      } else {\r
-        SFPGetNextToken (Str, sizeof (Str));\r
-        Error (SFPGetFileName (), SFPGetLineNumber (), 0, Str, "unrecognized token", Str);\r
-        ErrorCount++;\r
-        goto Done;\r
-      }\r
-    }\r
-    //\r
-    // Add this image definition to our global list\r
-    //\r
-    ImageDef->Next    = mImageDefinitions;\r
-    mImageDefinitions = ImageDef;\r
-  }\r
-  //\r
-  // Check for end-of-file\r
-  //\r
-  if (!SFPIsEOF ()) {\r
-    SFPGetNextToken (Str, sizeof (Str));\r
-    Error (SFPGetFileName (), SFPGetLineNumber (), 0, Str, "expected end-of-file", Str);\r
-    ErrorCount++;\r
-  }\r
-\r
-Done:\r
-  SFPCloseFile ();\r
-  if (ErrorCount != 0) {\r
-    return STATUS_ERROR;\r
-  } else if (WarningCount != 0) {\r
-    return STATUS_WARNING;\r
-  }\r
-\r
-  return STATUS_SUCCESS;\r
-}\r
-\r
-static\r
-FLASH_SUBREGION_DESCRIPTION *\r
-ParseSubregionDefinition (\r
-  unsigned int  SizeLeft\r
-  )\r
-/*++\r
-  \r
-Routine Description:\r
-\r
-  Parse Subregion definitions from the input flash definition file. Format:\r
-\r
-    Subregion {\r
-      CreateHob       = TRUE,\r
-      Name            = "FOO",\r
-      Size            = 0xA000,\r
-      Attributes      = "EFI_FLASH_AREA_SUBFV | EFI_FLASH_AREA_MEMMAPPED_FV",\r
-      AreaType        = "EFI_FLASH_AREA_EFI_VARIABLES",\r
-      NameGuid        = 12345678-1234-5678-AAAA-BBBBCCCCDDDD (or "EFI_SOME_GUID"),\r
-      AreaTypeGuid    = 11111111-2222-3333-4444-1, (or "EFI_SOME_GUID") (optional)\r
-      FileSystemGuid  = 11111111-2222-3333-4444-1, (or "EFI_SOME_GUID") (optional)\r
-    }\r
-\r
-    NOTE: The caller has already parsed the "Subregion" token, so start with the opening brace.\r
-\r
-Arguments:\r
-   \r
-   SizeLeft   - in the flash definition file, a Region can be broken up into\r
-                one or more subregions. As we parse the subregion definitions,\r
-                the caller keeps track of how much space is left in the region\r
-                that we're parsing subregions for. SizeLeft is that size, and\r
-                so the size of the subregion we're now parsing better not\r
-                exceed the size left.\r
-  Returns:\r
-\r
-    NULL    - unrecoverable errors detected while parsing the subregion definition\r
-\r
-    pointer to a subregion definition created from the parsed subregion\r
-\r
---*/\r
-{\r
-  FLASH_SUBREGION_DESCRIPTION *Subregion;\r
-  int                         ErrorCount;\r
-  int                         WarningCount;\r
-  unsigned int                Number;\r
-  BOOLEAN                     PreviousComma;\r
-  //\r
-  // Allocate memory for the new subregion descriptor\r
-  //\r
-  ErrorCount    = 0;\r
-  WarningCount  = 0;\r
-  Subregion     = (FLASH_SUBREGION_DESCRIPTION *) _malloc (sizeof (FLASH_SUBREGION_DESCRIPTION));\r
-  if (Subregion == NULL) {\r
-    Error (__FILE__, __LINE__, 0, "memory allocation failure", NULL);\r
-    ErrorCount++;\r
-    goto Done;\r
-  }\r
-\r
-  memset (Subregion, 0, sizeof (FLASH_SUBREGION_DESCRIPTION));\r
-  //\r
-  // Open brace -- warning if not there\r
-  //\r
-  if (!SFPIsToken ("{")) {\r
-    Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected {", NULL);\r
-    WarningCount++;\r
-  }\r
-  //\r
-  // Parse:  CreateHob = TRUE | FALSE,\r
-  //\r
-  if (!SFPIsKeyword ("CreateHob")) {\r
-    Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected 'CreateHob'", NULL);\r
-    ErrorCount++;\r
-    goto Done;\r
-  }\r
-\r
-  if (!SFPIsToken ("=")) {\r
-    Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected '='", NULL);\r
-    WarningCount++;\r
-  }\r
-\r
-  if (SFPIsToken ("TRUE")) {\r
-    Subregion->CreateHob = 1;\r
-  } else if (SFPIsToken ("FALSE")) {\r
-    //\r
-    // Subregion->CreateHob = 0; -- not required since we did a memset earlier\r
-    //\r
-  } else {\r
-    Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected 'TRUE' or 'FALSE'", NULL);\r
-    ErrorCount++;\r
-    goto Done;\r
-  }\r
-\r
-  if (!SFPIsToken (",")) {\r
-    Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected ',' following CreateHob value", NULL);\r
-    WarningCount++;\r
-  }\r
-  //\r
-  // Parse:  Name = "Name",\r
-  //\r
-  if (!SFPIsKeyword ("Name")) {\r
-    Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected 'Name'", NULL);\r
-    ErrorCount++;\r
-    goto Done;\r
-  }\r
-\r
-  if (!SFPIsToken ("=")) {\r
-    Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected '='", NULL);\r
-    WarningCount++;\r
-  }\r
-\r
-  if (!SFPGetQuotedString (Subregion->Name, sizeof (Subregion->Name))) {\r
-    Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected Subregion name", NULL);\r
-    ErrorCount++;\r
-    goto Done;\r
-  }\r
-\r
-  if (!SFPIsToken (",")) {\r
-    Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected comma following Region name", NULL);\r
-    WarningCount++;\r
-  }\r
-  //\r
-  // Parse: Size = 0x2000,\r
-  //\r
-  if (!SFPIsKeyword ("Size")) {\r
-    Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected 'Size'", NULL);\r
-    ErrorCount++;\r
-    goto Done;\r
-  }\r
-\r
-  if (!SFPIsToken ("=")) {\r
-    Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected '='", NULL);\r
-    WarningCount++;\r
-  }\r
-\r
-  if (!SFPGetNumber (&Subregion->Size)) {\r
-    Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected numeric Size value", NULL);\r
-    ErrorCount++;\r
-    goto Done;\r
-  }\r
-\r
-  //\r
-  // Check that the size does not exceed the size left passed in\r
-  //\r
-  if (Subregion->Size > SizeLeft) {\r
-    Error (SFPGetFileName (), SFPGetLineNumber (), 0, "sum of Subregion sizes exceeds Region size", NULL);\r
-    ErrorCount++;\r
-    goto Done;\r
-  }\r
-\r
-  if (!SFPIsToken (",")) {\r
-    Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected ',' following Size value", NULL);\r
-  }\r
-  //\r
-  // Parse:  Attributes = Number | "String",\r
-  //\r
-  if (!SFPIsKeyword ("Attributes")) {\r
-    Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected 'Attributes'", NULL);\r
-    ErrorCount++;\r
-    goto Done;\r
-  }\r
-\r
-  if (!SFPIsToken ("=")) {\r
-    Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected '='", NULL);\r
-    WarningCount++;\r
-  }\r
-\r
-  if (SFPGetNumber (&Number)) {\r
-    sprintf (Subregion->Attributes, "0x%X", Number);\r
-  } else if (!SFPGetQuotedString (Subregion->Attributes, sizeof (Subregion->Attributes))) {\r
-    Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected quoted Attributes string", NULL);\r
-    ErrorCount++;\r
-    goto Done;\r
-  }\r
-\r
-  if (!SFPIsToken (",")) {\r
-    Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected ','", NULL);\r
-  }\r
-  //\r
-  // Parse:  AreaType = Number | "String",\r
-  // AreaType is a UINT8, so error if it exceeds the size\r
-  //\r
-  if (!SFPIsKeyword ("AreaType")) {\r
-    Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected 'AreaType'", NULL);\r
-    ErrorCount++;\r
-    goto Done;\r
-  }\r
-\r
-  if (!SFPIsToken ("=")) {\r
-    Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected '='", NULL);\r
-    WarningCount++;\r
-  }\r
-\r
-  if (SFPGetNumber (&Number)) {\r
-    if (Number > 0xFF) {\r
-      Error (SFPGetFileName (), SFPGetLineNumber (), 0, "AreaType value exceeds 255", NULL);\r
-      ErrorCount++;\r
-    }\r
-\r
-    sprintf (Subregion->AreaType, "0x%X", Number & 0x00FF);\r
-  } else if (!SFPGetQuotedString (Subregion->AreaType, sizeof (Subregion->AreaType))) {\r
-    Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected quoted AreaType string", NULL);\r
-    ErrorCount++;\r
-    goto Done;\r
-  }\r
-\r
-  if (!SFPIsToken (",")) {\r
-    Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected ',' following AreaType value", NULL);\r
-  }\r
-  //\r
-  // Parse the three GUIDs (last two are optional)\r
-  //\r
-  //    NameGuid        = 12345678-1234-5678-AAAA-BBBBCCCCDDDD, (or "EFI_SOME_GUID")\r
-  //    AreaTypeGuid    = 11111111-2222-3333-4444-1, (or "EFI_SOME_GUID")\r
-  //    FileSysteGuid   = 11111111-2222-3333-4444-1, (or "EFI_SOME_GUID")\r
-  //\r
-  if (!SFPIsKeyword ("NameGuid")) {\r
-    Error (SFPGetFileName (), SFPGetLineNumber (), 0, "expected 'NameGuid'", NULL);\r
-    ErrorCount++;\r
-    goto Done;\r
-  }\r
-\r
-  if (!SFPIsToken ("=")) {\r
-    Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected '='", NULL);\r
-    WarningCount++;\r
-  }\r
-  //\r
-  // Allow a GUID or a quoted string identifier, which we'll just copy as a string\r
-  //\r
-  if (SFPGetQuotedString (Subregion->NameGuidString, sizeof (Subregion->NameGuidString))) {\r
-    //\r
-    // Nothing else to do\r
-    //\r
-  } else if (!SFPGetGuid (PARSE_GUID_STYLE_5_FIELDS, &Subregion->NameGuid)) {\r
-    Error (\r
-      SFPGetFileName (),\r
-      SFPGetLineNumber (),\r
-      0,\r
-      "expected NameGuid quoted string or GUID of form 12345678-1234-1234-1234-123456789ABC",\r
-      NULL\r
-      );\r
-    ErrorCount++;\r
-    goto Done;\r
-  }\r
-  //\r
-  // Comma following NameGuid is optional if they don't specify AreaTypeGuid or FileSystemGuid\r
-  //\r
-  PreviousComma = SFPIsToken (",");\r
-  if (SFPIsKeyword ("AreaTypeGuid")) {\r
-    //\r
-    // Check for preceeding comma now\r
-    //\r
-    if (!PreviousComma) {\r
-      Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected ',' before 'AreaTypeGuid'", NULL);\r
-      WarningCount++;\r
-    }\r
-\r
-    if (!SFPIsToken ("=")) {\r
-      Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected '='", NULL);\r
-      WarningCount++;\r
-    }\r
-\r
-    if (SFPGetQuotedString (Subregion->AreaTypeGuidString, sizeof (Subregion->AreaTypeGuidString))) {\r
-      //\r
-      // Nothing else to do\r
-      //\r
-    } else if (!SFPGetGuid (PARSE_GUID_STYLE_5_FIELDS, &Subregion->AreaTypeGuid)) {\r
-      Error (\r
-        SFPGetFileName (),\r
-        SFPGetLineNumber (),\r
-        0,\r
-        "expected AreaTypeGuid quoted string or GUID of form 12345678-1234-1234-1234-123456789ABC",\r
-        NULL\r
-        );\r
-      ErrorCount++;\r
-      goto Done;\r
-    }\r
-\r
-    PreviousComma = SFPIsToken (",");\r
-  }\r
-\r
-  if (SFPIsKeyword ("FileSystemGuid")) {\r
-    //\r
-    // Check for preceeding comma now\r
-    //\r
-    if (!PreviousComma) {\r
-      Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected ',' before 'FileSystemGuid'", NULL);\r
-      WarningCount++;\r
-    }\r
-\r
-    if (!SFPIsToken ("=")) {\r
-      Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected '='", NULL);\r
-      WarningCount++;\r
-    }\r
-    //\r
-    // Allow a GUID or a quoted string identifier, which we'll just copy as a string\r
-    //\r
-    if (SFPGetQuotedString (Subregion->FileSystemGuidString, sizeof (Subregion->FileSystemGuidString))) {\r
-      //\r
-      // Nothing else to do\r
-      //\r
-    } else if (!SFPGetGuid (PARSE_GUID_STYLE_5_FIELDS, &Subregion->FileSystemGuid)) {\r
-      Error (\r
-        SFPGetFileName (),\r
-        SFPGetLineNumber (),\r
-        0,\r
-        "expected FileSystemGuid quoted string or GUID of form 12345678-1234-1234-1234-123456789ABC",\r
-        NULL\r
-        );\r
-      ErrorCount++;\r
-      goto Done;\r
-    }\r
-\r
-    SFPIsToken (",");\r
-  }\r
-  //\r
-  // Look for subregion closing brace\r
-  //\r
-  if (!SFPIsToken ("}")) {\r
-    Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected Subregion closing brace '}'", NULL);\r
-    WarningCount++;\r
-  }\r
-\r
-Done:\r
-  //\r
-  // If any errors were encountered, then delete the subregion definition\r
-  //\r
-  if (ErrorCount != 0) {\r
-    _free (Subregion);\r
-    Subregion = NULL;\r
-  }\r
-\r
-  return Subregion;\r
-}\r
-\r
-STATUS\r
-FDFCreateCIncludeFile (\r
-  char      *FlashDeviceName,\r
-  char      *FileName\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Create a header file with #define definitions per an already-parsed\r
-  flash definition file.\r
-\r
-Arguments:\r
-  FlashDeviceName - name of flash device (from the flash definition file)\r
-                    to use\r
-  FileName        - name of output file to create\r
-\r
-Returns:\r
-  STATUS_SUCCESS    - no errors or warnings\r
-  STATUS_WARNING    - warnings, but no errors, were encountered\r
-  STATUS_ERROR      - errors were encountered\r
-\r
---*/\r
-{\r
-  FILE                        *OutFptr;\r
-  FLASH_BLOCK_DESCRIPTION     *FBlock;\r
-  FLASH_DEVICE_DESCRIPTION    *FDev;\r
-  FLASH_SUBREGION_DESCRIPTION *Subregion;\r
-  unsigned int                Offset;\r
-  unsigned int                SubregionOffset;\r
-  int                         CreateHobs;\r
-  //\r
-  // Find the definition we're supposed to use\r
-  //\r
-  for (FDev = mFlashDevices; FDev != NULL; FDev = FDev->Next) {\r
-    if (strcmp (FDev->Name, FlashDeviceName) == 0) {\r
-      break;\r
-    }\r
-  }\r
-\r
-  if (FDev == NULL) {\r
-    Error (NULL, 0, 0, NULL, FlashDeviceName, "flash device not found in flash definitions");\r
-    return STATUS_ERROR;\r
-  }\r
-\r
-  if ((OutFptr = fopen (FileName, "w")) == NULL) {\r
-    Error (NULL, 0, 0, FileName, "failed to open output file for writing");\r
-    return STATUS_ERROR;\r
-  }\r
-  //\r
-  // Write a header\r
-  //\r
-  fprintf (OutFptr, CIncludeHeader);\r
-  //\r
-  // Write flash block base and size defines\r
-  //\r
-  fprintf (OutFptr, "#define FLASH_BASE                                          0x%08X\n", FDev->BaseAddress);\r
-  fprintf (OutFptr, "#define FLASH_SIZE                                          0x%08X\n\n", FDev->Size);\r
-  //\r
-  // Write flash regions base, size and offset defines\r
-  //\r
-  Offset      = 0;\r
-  CreateHobs  = 0;\r
-  for (FBlock = FDev->Regions; FBlock != NULL; FBlock = FBlock->Next) {\r
-    fprintf (\r
-      OutFptr,\r
-      "#define FLASH_REGION_%s_BASE              %*c0x%08X\n",\r
-      FBlock->Name,\r
-      COLUMN2_START - 40 - strlen (FBlock->Name),\r
-      ' ',\r
-      Offset + FDev->BaseAddress\r
-      );\r
-    fprintf (\r
-      OutFptr,\r
-      "#define FLASH_REGION_%s_SIZE              %*c0x%08X\n",\r
-      FBlock->Name,\r
-      COLUMN2_START - 40 - strlen (FBlock->Name),\r
-      ' ',\r
-      FBlock->Size\r
-      );\r
-    fprintf (\r
-      OutFptr,\r
-      "#define FLASH_REGION_%s_OFFSET            %*c0x%08X\n",\r
-      FBlock->Name,\r
-      COLUMN2_START - 40 - strlen (FBlock->Name),\r
-      ' ',\r
-      Offset\r
-      );\r
-    //\r
-    // Create defines for any subregions\r
-    //\r
-    SubregionOffset = 0;\r
-    for (Subregion = FBlock->Subregions; Subregion != NULL; Subregion = Subregion->Next) {\r
-      fprintf (\r
-        OutFptr,\r
-        "#define FLASH_REGION_%s_SUBREGION_%s_BASE     %*c0x%08X\n",\r
-        FBlock->Name,\r
-        Subregion->Name,\r
-        COLUMN3_START - 43 - strlen (FBlock->Name) - strlen (Subregion->Name),\r
-        ' ',\r
-        FDev->BaseAddress + Offset + SubregionOffset\r
-        );\r
-      fprintf (\r
-        OutFptr,\r
-        "#define FLASH_REGION_%s_SUBREGION_%s_SIZE     %*c0x%08X\n",\r
-        FBlock->Name,\r
-        Subregion->Name,\r
-        COLUMN3_START - 43 - strlen (FBlock->Name) - strlen (Subregion->Name),\r
-        ' ',\r
-        Subregion->Size\r
-        );\r
-      fprintf (\r
-        OutFptr,\r
-        "#define FLASH_REGION_%s_SUBREGION_%s_OFFSET   %*c0x%08X\n",\r
-        FBlock->Name,\r
-        Subregion->Name,\r
-        COLUMN3_START - 43 - strlen (FBlock->Name) - strlen (Subregion->Name),\r
-        ' ',\r
-        Offset + SubregionOffset\r
-        );\r
-      SubregionOffset += Subregion->Size;\r
-      if (Subregion->CreateHob != 0) {\r
-        CreateHobs = 1;\r
-      }\r
-    }\r
-\r
-    Offset += FBlock->Size;\r
-  }\r
-  //\r
-  // Now create a #define for the flash map data definition\r
-  //\r
-  fprintf (OutFptr, "\n\n#define EFI_FLASH_AREA_DATA_DEFINITION \\\n");\r
-  //\r
-  // Emit entry for each region\r
-  //\r
-  Offset = 0;\r
-  for (FBlock = FDev->Regions; FBlock != NULL; FBlock = FBlock->Next) {\r
-    fprintf (OutFptr, "  /* %s region */\\\n", FBlock->Name);\r
-    fprintf (OutFptr, "  {\\\n");\r
-    fprintf (OutFptr, "    FLASH_REGION_%s_BASE,\\\n", FBlock->Name);\r
-    fprintf (OutFptr, "    FLASH_REGION_%s_SIZE,\\\n", FBlock->Name);\r
-    fprintf (OutFptr, "    %s,\\\n", FBlock->Attributes);\r
-    fprintf (OutFptr, "    %s,\\\n  },\\\n", FBlock->AreaType);\r
-  }\r
-\r
-  fprintf (OutFptr, "\n\n");\r
-  //\r
-  // Now walk the list again to create the EFI_HOB_FLASH_MAP_ENTRY_TYPE definition\r
-  //\r
-  if (CreateHobs != 0) {\r
-    fprintf (OutFptr, "//\n// EFI_HOB_FLASH_MAP_ENTRY_TYPE definition\n//\n");\r
-    fprintf (OutFptr, "#define EFI_HOB_FLASH_MAP_ENTRY_TYPE_DATA_DEFINITION");\r
-    for (FBlock = FDev->Regions; FBlock != NULL; FBlock = FBlock->Next) {\r
-      //\r
-      // See if the block has subregions, and that the CreateHobs flag is set\r
-      // for any of them.\r
-      //\r
-      CreateHobs = 0;\r
-      for (Subregion = FBlock->Subregions; Subregion != NULL; Subregion = Subregion->Next) {\r
-        if (Subregion->CreateHob != 0) {\r
-          CreateHobs = 1;\r
-          break;\r
-        }\r
-      }\r
-      //\r
-      // If any of the subregions had the CreateHobs flag set, then create the entries in the\r
-      // output file\r
-      //\r
-      if (CreateHobs != 0) {\r
-        for (Subregion = FBlock->Subregions; Subregion != NULL; Subregion = Subregion->Next) {\r
-          if (Subregion->CreateHob != 0) {\r
-            fprintf (OutFptr, " \\\n");\r
-            fprintf (OutFptr, "  /* %s.%s Subregion */\\\n", FBlock->Name, Subregion->Name);\r
-            fprintf (OutFptr, "  {\\\n");\r
-            fprintf (OutFptr, "    EFI_HOB_TYPE_GUID_EXTENSION,\\\n");\r
-            fprintf (OutFptr, "    sizeof (EFI_HOB_FLASH_MAP_ENTRY_TYPE ),\\\n");\r
-            fprintf (OutFptr, "    0,\\\n");\r
-            //\r
-            // The NameGuid may have been specified in the input flash definition file as a GUID, or\r
-            // as a quoted string. Do the right one.\r
-            //\r
-            if (Subregion->NameGuidString[0] != 0) {\r
-              fprintf (OutFptr, "    %s, \\\n", Subregion->NameGuidString);\r
-            } else {\r
-              fprintf (\r
-                OutFptr,\r
-                "    { 0x%08X, 0x%04X, 0x%04X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X },\\\n",\r
-                Subregion->NameGuid.Data1,\r
-                (unsigned int) Subregion->NameGuid.Data2,\r
-                (unsigned int) Subregion->NameGuid.Data3,\r
-                (unsigned int) Subregion->NameGuid.Data4[0],\r
-                (unsigned int) Subregion->NameGuid.Data4[1],\r
-                (unsigned int) Subregion->NameGuid.Data4[2],\r
-                (unsigned int) Subregion->NameGuid.Data4[3],\r
-                (unsigned int) Subregion->NameGuid.Data4[4],\r
-                (unsigned int) Subregion->NameGuid.Data4[5],\r
-                (unsigned int) Subregion->NameGuid.Data4[6],\r
-                (unsigned int) Subregion->NameGuid.Data4[7]\r
-                );\r
-            }\r
-\r
-            fprintf (OutFptr, "    0, 0, 0,\\\n");\r
-            fprintf (OutFptr, "    %s,\\\n", Subregion->AreaType);\r
-            //\r
-            // The AreaTypeGuid may have been specified in the input flash definition file as a GUID, or\r
-            // as a quoted string. Do the right one.\r
-            //\r
-            if (Subregion->AreaTypeGuidString[0] != 0) {\r
-              fprintf (OutFptr, "    %s, \\\n", Subregion->AreaTypeGuidString);\r
-            } else {\r
-              fprintf (\r
-                OutFptr,\r
-                "    { 0x%08X, 0x%04X, 0x%04X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X },\\\n",\r
-                Subregion->AreaTypeGuid.Data1,\r
-                (unsigned int) Subregion->AreaTypeGuid.Data2,\r
-                (unsigned int) Subregion->AreaTypeGuid.Data3,\r
-                (unsigned int) Subregion->AreaTypeGuid.Data4[0],\r
-                (unsigned int) Subregion->AreaTypeGuid.Data4[1],\r
-                (unsigned int) Subregion->AreaTypeGuid.Data4[2],\r
-                (unsigned int) Subregion->AreaTypeGuid.Data4[3],\r
-                (unsigned int) Subregion->AreaTypeGuid.Data4[4],\r
-                (unsigned int) Subregion->AreaTypeGuid.Data4[5],\r
-                (unsigned int) Subregion->AreaTypeGuid.Data4[6],\r
-                (unsigned int) Subregion->AreaTypeGuid.Data4[7]\r
-                );\r
-            }\r
-\r
-            fprintf (OutFptr, "    1,\\\n");\r
-            fprintf (OutFptr, "    {\\\n");\r
-            fprintf (OutFptr, "      %s,\\\n", Subregion->Attributes);\r
-            fprintf (OutFptr, "      0,\\\n");\r
-            fprintf (OutFptr, "      FLASH_REGION_%s_SUBREGION_%s_BASE,\\\n", FBlock->Name, Subregion->Name);\r
-            fprintf (OutFptr, "      FLASH_REGION_%s_SUBREGION_%s_SIZE,\\\n", FBlock->Name, Subregion->Name);\r
-            //\r
-            // The FileSystemGuid may have been specified in the input flash definition file as a GUID, or\r
-            // as a quoted string. Do the right one.\r
-            //\r
-            if (Subregion->FileSystemGuidString[0] != 0) {\r
-              fprintf (OutFptr, "      %s, \\\n", Subregion->FileSystemGuidString);\r
-            } else {\r
-              fprintf (\r
-                OutFptr,\r
-                "      { 0x%08X, 0x%04X, 0x%04X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X },\\\n",\r
-                Subregion->FileSystemGuid.Data1,\r
-                (unsigned int) Subregion->FileSystemGuid.Data2,\r
-                (unsigned int) Subregion->FileSystemGuid.Data3,\r
-                (unsigned int) Subregion->FileSystemGuid.Data4[0],\r
-                (unsigned int) Subregion->FileSystemGuid.Data4[1],\r
-                (unsigned int) Subregion->FileSystemGuid.Data4[2],\r
-                (unsigned int) Subregion->FileSystemGuid.Data4[3],\r
-                (unsigned int) Subregion->FileSystemGuid.Data4[4],\r
-                (unsigned int) Subregion->FileSystemGuid.Data4[5],\r
-                (unsigned int) Subregion->FileSystemGuid.Data4[6],\r
-                (unsigned int) Subregion->FileSystemGuid.Data4[7]\r
-                );\r
-            }\r
-\r
-            fprintf (OutFptr, "    },\\\n");\r
-            fprintf (OutFptr, "  },");\r
-          }\r
-        }\r
-      }\r
-    }\r
-\r
-    fprintf (OutFptr, "\n\n");\r
-  }\r
-\r
-  //\r
-  // Write the file's closing #endif\r
-  //\r
-  fprintf (OutFptr, CIncludeFooter);\r
-  fclose (OutFptr);\r
-  return STATUS_SUCCESS;\r
-}\r
-\r
-STATUS\r
-FDFCreateAsmIncludeFile (\r
-  char      *FlashDeviceName,\r
-  char      *FileName\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Create an assembly header file with equate definitions per an already-parsed\r
-  flash definition file.\r
-\r
-Arguments:\r
-  FlashDeviceName - name of flash device (from the flash definition file)\r
-                    to use\r
-  FileName        - name of output file to create\r
-\r
-Returns:\r
-  STATUS_SUCCESS    - no errors or warnings\r
-  STATUS_WARNING    - warnings, but no errors, were encountered\r
-  STATUS_ERROR      - errors were encountered\r
-\r
---*/\r
-{\r
-  FILE                        *OutFptr;\r
-  FLASH_BLOCK_DESCRIPTION     *FBlock;\r
-  FLASH_DEVICE_DESCRIPTION    *FDev;\r
-  unsigned int                Offset;\r
-  FLASH_SUBREGION_DESCRIPTION *Subregion;\r
-  unsigned int                SubregionOffset;\r
-  //\r
-  // Find the definition we're supposed to use\r
-  //\r
-  for (FDev = mFlashDevices; FDev != NULL; FDev = FDev->Next) {\r
-    if (strcmp (FDev->Name, FlashDeviceName) == 0) {\r
-      break;\r
-    }\r
-  }\r
-\r
-  if (FDev == NULL) {\r
-    Error (NULL, 0, 0, NULL, FlashDeviceName, "flash device not found in flash definitions");\r
-    return STATUS_ERROR;\r
-  }\r
-\r
-  if ((OutFptr = fopen (FileName, "w")) == NULL) {\r
-    Error (NULL, 0, 0, FileName, "failed to open output file for writing");\r
-    return STATUS_ERROR;\r
-  }\r
-  //\r
-  // Write a header\r
-  //\r
-  fprintf (OutFptr, "\n\n");\r
-  //\r
-  // Write flash block size and offset defines\r
-  //\r
-  fprintf (\r
-    OutFptr,\r
-    "FLASH_BASE                               %*cequ 0%08Xh\n",\r
-    COLUMN2_START - 40,\r
-    ' ',\r
-    FDev->BaseAddress\r
-    );\r
-  fprintf (OutFptr, "FLASH_SIZE                               %*cequ 0%08Xh\n", COLUMN2_START - 40, ' ', FDev->Size);\r
-  //\r
-  // Write flash region size and offset defines\r
-  //\r
-  fprintf (OutFptr, "\n");\r
-  Offset = 0;\r
-  for (FBlock = FDev->Regions; FBlock != NULL; FBlock = FBlock->Next) {\r
-    fprintf (\r
-      OutFptr,\r
-      "FLASH_REGION_%s_BASE   %*cequ 0%08Xh\n",\r
-      FBlock->Name,\r
-      COLUMN2_START - 20 - strlen (FBlock->Name),\r
-      ' ',\r
-      FDev->BaseAddress + Offset\r
-      );\r
-    fprintf (\r
-      OutFptr,\r
-      "FLASH_REGION_%s_SIZE   %*cequ 0%08Xh\n",\r
-      FBlock->Name,\r
-      COLUMN2_START - 20 - strlen (FBlock->Name),\r
-      ' ',\r
-      FBlock->Size\r
-      );\r
-    fprintf (\r
-      OutFptr,\r
-      "FLASH_REGION_%s_OFFSET %*cequ 0%08Xh\n",\r
-      FBlock->Name,\r
-      COLUMN2_START - 20 - strlen (FBlock->Name),\r
-      ' ',\r
-      Offset\r
-      );\r
-    //\r
-    // Create defines for any subregions\r
-    //\r
-    SubregionOffset = 0;\r
-    for (Subregion = FBlock->Subregions; Subregion != NULL; Subregion = Subregion->Next) {\r
-      fprintf (\r
-        OutFptr,\r
-        "FLASH_REGION_%s_SUBREGION_%s_BASE     %*cequ 0%08Xh\n",\r
-        FBlock->Name,\r
-        Subregion->Name,\r
-        COLUMN3_START - 39 - strlen (FBlock->Name) - strlen (Subregion->Name),\r
-        ' ',\r
-        FDev->BaseAddress + Offset + SubregionOffset\r
-        );\r
-      fprintf (\r
-        OutFptr,\r
-        "FLASH_REGION_%s_SUBREGION_%s_SIZE     %*cequ 0%08Xh\n",\r
-        FBlock->Name,\r
-        Subregion->Name,\r
-        COLUMN3_START - 39 - strlen (FBlock->Name) - strlen (Subregion->Name),\r
-        ' ',\r
-        Subregion->Size\r
-        );\r
-      fprintf (\r
-        OutFptr,\r
-        "FLASH_REGION_%s_SUBREGION_%s_OFFSET   %*cequ 0%08Xh\n",\r
-        FBlock->Name,\r
-        Subregion->Name,\r
-        COLUMN3_START - 39 - strlen (FBlock->Name) - strlen (Subregion->Name),\r
-        ' ',\r
-        Offset + SubregionOffset\r
-        );\r
-      SubregionOffset += Subregion->Size;\r
-    }\r
-\r
-    Offset += FBlock->Size;\r
-  }\r
-\r
-  //\r
-  // Write closing \n\r
-  //\r
-  fprintf (OutFptr, "\n\n");\r
-  fclose (OutFptr);\r
-  return STATUS_SUCCESS;\r
-}\r
-\r
-STATUS\r
-FDFCreateSymbols (\r
-  char      *FlashDeviceName\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Using the given flash device name, add symbols to the global symbol table. This\r
-  allows other functions to use the symbol definitions for other purposes.\r
-\r
-Arguments:\r
-  FlashDeviceName - name of flash device (from the flash definition file)\r
-                    to use\r
-\r
-Returns:\r
-  STATUS_SUCCESS    - no errors or warnings\r
-  STATUS_WARNING    - warnings, but no errors, were encountered\r
-  STATUS_ERROR      - errors were encountered\r
-\r
---*/\r
-{\r
-  FLASH_BLOCK_DESCRIPTION     *FBlock;\r
-  FLASH_DEVICE_DESCRIPTION    *FDev;\r
-  unsigned int                Offset;\r
-  char                        SymName[120];\r
-  char                        SymValue[120];\r
-  FLASH_SUBREGION_DESCRIPTION *Subregion;\r
-  unsigned int                SubregionOffset;\r
-  //\r
-  // Find the definition we're supposed to use\r
-  //\r
-  for (FDev = mFlashDevices; FDev != NULL; FDev = FDev->Next) {\r
-    if (strcmp (FDev->Name, FlashDeviceName) == 0) {\r
-      break;\r
-    }\r
-  }\r
-\r
-  if (FDev == NULL) {\r
-    Error (NULL, 0, 0, NULL, FlashDeviceName, "flash device not found in flash definitions");\r
-    return STATUS_ERROR;\r
-  }\r
-\r
-  sprintf (SymValue, "0x%08X", FDev->BaseAddress);\r
-  SymbolAdd ("FLASH_BASE", SymValue, 0);\r
-  sprintf (SymValue, "0x%08X", FDev->Size);\r
-  SymbolAdd ("FLASH_SIZE", SymValue, 0);\r
-  //\r
-  // Add flash block size and offset defines\r
-  //\r
-  // Offset = 0;\r
-  // for (FBlock = FDev->PBlocks; FBlock != NULL; FBlock = FBlock->Next) {\r
-  //  sprintf (SymName, "FLASH_BLOCK_%s_BASE", FBlock->Name);\r
-  //  sprintf (SymValue, "0x%08X", FDev->BaseAddress + Offset);\r
-  //  SymbolAdd (SymName, SymValue, 0);\r
-  //  sprintf (SymName, "FLASH_BLOCK_%s_SIZE", FBlock->Name);\r
-  //  sprintf (SymValue, "0x%08X", FBlock->Size);\r
-  //  SymbolAdd (SymName, SymValue, 0);\r
-  //  sprintf (SymName, "FLASH_BLOCK_%s_OFFSET", FBlock->Name);\r
-  //  sprintf (SymValue, "0x%08X", Offset);\r
-  //  SymbolAdd (SymName, SymValue, 0);\r
-  //  Offset += FBlock->Size;\r
-  // }\r
-  //\r
-  // Add flash region block base, size, and offset defines\r
-  //\r
-  Offset = 0;\r
-  for (FBlock = FDev->Regions; FBlock != NULL; FBlock = FBlock->Next) {\r
-    sprintf (SymName, "FLASH_REGION_%s_BASE", FBlock->Name);\r
-    sprintf (SymValue, "0x%08X", FDev->BaseAddress + Offset);\r
-    SymbolAdd (SymName, SymValue, 0);\r
-    sprintf (SymName, "FLASH_REGION_%s_SIZE", FBlock->Name);\r
-    sprintf (SymValue, "0x%08X", FBlock->Size);\r
-    SymbolAdd (SymName, SymValue, 0);\r
-    sprintf (SymName, "FLASH_REGION_%s_OFFSET", FBlock->Name);\r
-    sprintf (SymValue, "0x%08X", Offset);\r
-    SymbolAdd (SymName, SymValue, 0);\r
-    //\r
-    // Add subregion symbols\r
-    //\r
-    if (FBlock->Subregions != NULL) {\r
-      SubregionOffset = 0;\r
-      for (Subregion = FBlock->Subregions; Subregion != NULL; Subregion = Subregion->Next) {\r
-        sprintf (SymName, "FLASH_REGION_%s_SUBREGION_%s_BASE", FBlock->Name, Subregion->Name);\r
-        sprintf (SymValue, "0x%08X", FDev->BaseAddress + Offset + SubregionOffset);\r
-        SymbolAdd (SymName, SymValue, 0);\r
-        sprintf (SymName, "FLASH_REGION_%s_SUBREGION_%s_SIZE", FBlock->Name, Subregion->Name);\r
-        sprintf (SymValue, "0x%08X", Subregion->Size);\r
-        SymbolAdd (SymName, SymValue, 0);\r
-        sprintf (SymName, "FLASH_REGION_%s_SUBREGION_%s_OFFSET", FBlock->Name, Subregion->Name);\r
-        sprintf (SymValue, "0x%08X", Offset + SubregionOffset);\r
-        SymbolAdd (SymName, SymValue, 0);\r
-        SubregionOffset += Subregion->Size;\r
-      }\r
-    }\r
-\r
-    Offset += FBlock->Size;\r
-  }\r
-\r
-  return STATUS_SUCCESS;\r
-}\r
-\r
-STATUS\r
-FDFCreateImage (\r
-  char      *FlashDeviceName,\r
-  char      *ImageName,\r
-  char      *FileName\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Create a flash image using the given device and image names.\r
-\r
-Arguments:\r
-  FlashDeviceName - name of flash device (from the flash definition file)\r
-                    to use\r
-  ImageName       - name of image (from the flash definition file) to create\r
-  FileName        - name of output file to create\r
-\r
-Returns:\r
-  STATUS_SUCCESS    - no errors or warnings\r
-  STATUS_WARNING    - warnings, but no errors, were encountered\r
-  STATUS_ERROR      - errors were encountered\r
-\r
---*/\r
-{\r
-  STATUS                      Status;\r
-  FILE                        *OutFptr;\r
-  FLASH_BLOCK_DESCRIPTION     *RegionDef;\r
-  FLASH_DEVICE_DESCRIPTION    *FDev;\r
-  IMAGE_DEFINITION            *ImageDef;\r
-  unsigned int                Offset;\r
-  char                        *Buffer;\r
-  FILE                        *InFptr;\r
-  long                        FileSize;\r
-  IMAGE_DEFINITION_ENTRY      *IDefEntry;\r
-  FLASH_SUBREGION_DESCRIPTION *SubregionDef;\r
-  //\r
-  // Find the flash definition we're supposed to use\r
-  //\r
-  InFptr  = NULL;\r
-  Status  = STATUS_ERROR;\r
-  for (FDev = mFlashDevices; FDev != NULL; FDev = FDev->Next) {\r
-    if (strcmp (FDev->Name, FlashDeviceName) == 0) {\r
-      break;\r
-    }\r
-  }\r
-\r
-  if (FDev == NULL) {\r
-    Error (NULL, 0, 0, FlashDeviceName, "flash device not found in flash definitions");\r
-    return STATUS_ERROR;\r
-  }\r
-  //\r
-  // Find the image name we're supposed to create\r
-  //\r
-  for (ImageDef = mImageDefinitions; ImageDef != NULL; ImageDef = ImageDef->Next) {\r
-    if (strcmp (ImageDef->Name, ImageName) == 0) {\r
-      break;\r
-    }\r
-  }\r
-\r
-  if (ImageDef == NULL) {\r
-    Error (NULL, 0, 0, ImageName, "image definition not found in image definitions");\r
-    return STATUS_ERROR;\r
-  }\r
-  //\r
-  // Open the output file\r
-  //\r
-  if ((OutFptr = fopen (FileName, "wb")) == NULL) {\r
-    Error (NULL, 0, 0, FileName, "failed to open output file for writing");\r
-    return STATUS_ERROR;\r
-  }\r
-  //\r
-  // Allocate a buffer to copy the input data to\r
-  //\r
-  Buffer = (char *) _malloc (FDev->Size);\r
-  if (Buffer == NULL) {\r
-    Error (NULL, 0, 0, (INT8 *) "failed to allocate memory", NULL);\r
-    goto Done;\r
-  }\r
-  //\r
-  // Set contents of buffer to the erased value\r
-  //\r
-  if (FDev->ErasePolarity) {\r
-    memset (Buffer, 0xFF, FDev->Size);\r
-  } else {\r
-    memset (Buffer, 0, FDev->Size);\r
-  }\r
-  //\r
-  // Set all region and subregion size-left fields to the size of the region/subregion\r
-  //\r
-  for (RegionDef = FDev->Regions; RegionDef != NULL; RegionDef = RegionDef->Next) {\r
-    RegionDef->SizeLeft = RegionDef->Size;\r
-    for (SubregionDef = RegionDef->Subregions; SubregionDef != NULL; SubregionDef = SubregionDef->Next) {\r
-      SubregionDef->SizeLeft = SubregionDef->Size;\r
-    }\r
-  }\r
-  //\r
-  // Now go through the image list, read files into the buffer.\r
-  //\r
-  for (IDefEntry = ImageDef->Entries; IDefEntry != NULL; IDefEntry = IDefEntry->Next) {\r
-    //\r
-    // If it's a file name, open the file, get the size, find the corresponding\r
-    // flash region it's in, and copy the data.\r
-    //\r
-    if (IDefEntry->IsRawData == 0) {\r
-      if ((InFptr = fopen (IDefEntry->Name, "rb")) == NULL) {\r
-        Error (NULL, 0, 0, IDefEntry->Name, "failed to open input file for reading");\r
-        goto Done;\r
-      }\r
-\r
-      fseek (InFptr, 0, SEEK_END);\r
-      FileSize = ftell (InFptr);\r
-      fseek (InFptr, 0, SEEK_SET);\r
-    } else {\r
-      FileSize = IDefEntry->RawDataSize;\r
-    }\r
-    //\r
-    // Find the region/subregion it's in, see if we have space left\r
-    //\r
-    Offset = 0;\r
-    for (RegionDef = FDev->Regions; RegionDef != NULL; RegionDef = RegionDef->Next) {\r
-      if (strcmp (RegionDef->Name, IDefEntry->RegionName) == 0) {\r
-        break;\r
-      }\r
-\r
-      Offset += RegionDef->Size;\r
-    }\r
-\r
-    if (RegionDef == NULL) {\r
-      Error (NULL, 0, 0, IDefEntry->RegionName, "Region name not found in FlashDevice %s definition", FDev->Name);\r
-      goto Done;\r
-    }\r
-\r
-    //\r
-    // Check for subregion\r
-    //\r
-    if (IDefEntry->SubregionName[0] != 0) {\r
-      for (SubregionDef = RegionDef->Subregions; SubregionDef != NULL; SubregionDef = SubregionDef->Next) {\r
-        if (strcmp (SubregionDef->Name, IDefEntry->SubregionName) == 0) {\r
-          break;\r
-        }\r
-\r
-        Offset += SubregionDef->Size;\r
-      }\r
-\r
-      if (SubregionDef == NULL) {\r
-        Error (\r
-          NULL,\r
-          0,\r
-          0,\r
-          IDefEntry->SubregionName,\r
-          "Subregion name not found in FlashDevice %s.%s Region definition",\r
-          FDev->Name,\r
-          RegionDef->Name\r
-          );\r
-        goto Done;\r
-      }\r
-      //\r
-      // Enough space in the subregion?\r
-      //\r
-      if (SubregionDef->SizeLeft < (unsigned int) FileSize) {\r
-        Error (\r
-          NULL,\r
-          0,\r
-          0,\r
-          IDefEntry->Name,\r
-          "insufficient space in Subregion (at least 0x%X additional bytes required)",\r
-          FileSize - SubregionDef->SizeLeft\r
-          );\r
-        goto Done;\r
-      }\r
-\r
-      //\r
-      // Read the file into the buffer if it's a file. Otherwise copy the raw data\r
-      //\r
-      if (IDefEntry->IsRawData == 0) {\r
-        if (fread (Buffer + Offset + (SubregionDef->Size - SubregionDef->SizeLeft), FileSize, 1, InFptr) != 1) {\r
-          Error (NULL, 0, 0, IDefEntry->Name, "failed to read file contents");\r
-          goto Done;\r
-        }\r
-\r
-        fclose (InFptr);\r
-        InFptr = NULL;\r
-      } else {\r
-        memcpy (\r
-          Buffer + Offset + (SubregionDef->Size - SubregionDef->SizeLeft),\r
-          IDefEntry->RawData,\r
-          IDefEntry->RawDataSize\r
-          );\r
-      }\r
-\r
-      SubregionDef->SizeLeft -= FileSize;\r
-      //\r
-      // Align based on the Region alignment requirements.\r
-      //\r
-      if (RegionDef->Alignment != 0) {\r
-        while (((unsigned int) (SubregionDef->Size - SubregionDef->SizeLeft) &~RegionDef->Alignment) != 0) {\r
-          if (SubregionDef->SizeLeft == 0) {\r
-            break;\r
-          }\r
-\r
-          SubregionDef->SizeLeft--;\r
-        }\r
-      }\r
-    } else {\r
-      //\r
-      // Placing data in a region. Check for enough space in the region left.\r
-      //\r
-      if (RegionDef->SizeLeft < (unsigned int) FileSize) {\r
-        Error (\r
-          NULL,\r
-          0,\r
-          0,\r
-          IDefEntry->Name,\r
-          "insufficient space in Region (at least 0x%X additional bytes required)",\r
-          FileSize - RegionDef->SizeLeft\r
-          );\r
-        goto Done;\r
-      }\r
-\r
-      //\r
-      // Read the file into the buffer if it's a file. Otherwise copy the raw data\r
-      //\r
-      if (IDefEntry->IsRawData == 0) {\r
-        if (fread (Buffer + Offset + (RegionDef->Size - RegionDef->SizeLeft), FileSize, 1, InFptr) != 1) {\r
-          Error (NULL, 0, 0, IDefEntry->Name, "failed to read file contents");\r
-          goto Done;\r
-        }\r
-\r
-        fclose (InFptr);\r
-        InFptr = NULL;\r
-      } else {\r
-        memcpy (Buffer + Offset + (RegionDef->Size - RegionDef->SizeLeft), IDefEntry->RawData, IDefEntry->RawDataSize);\r
-      }\r
-\r
-      RegionDef->SizeLeft -= FileSize;\r
-      //\r
-      // Align\r
-      //\r
-      if (RegionDef->Alignment != 0) {\r
-        while (((unsigned int) (RegionDef->Size - RegionDef->SizeLeft) &~RegionDef->Alignment) != 0) {\r
-          if (RegionDef->SizeLeft == 0) {\r
-            break;\r
-          }\r
-\r
-          RegionDef->SizeLeft--;\r
-        }\r
-      }\r
-    }\r
-  }\r
-\r
-  if (fwrite (Buffer, FDev->Size, 1, OutFptr) != 1) {\r
-    Error (NULL, 0, 0, "failed to write buffer contents to output file", NULL);\r
-    goto Done;\r
-  }\r
-\r
-  Status = STATUS_SUCCESS;\r
-Done:\r
-  if (InFptr != NULL) {\r
-    fclose (InFptr);\r
-  }\r
-\r
-  if (Buffer != NULL) {\r
-    _free (Buffer);\r
-  }\r
-\r
-  if (OutFptr != NULL) {\r
-    fclose (OutFptr);\r
-    if (Status == STATUS_ERROR) {\r
-      remove (FileName);\r
-    }\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-STATUS\r
-FDFCreateDscFile (\r
-  char      *FlashDeviceName,\r
-  char      *FileName\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Create a DSC-style output file with equates for flash management.\r
-\r
-Arguments:\r
-  FlashDeviceName - name of flash device (from the flash definition file)\r
-                    to use\r
-  FileName        - name of output file to create\r
-\r
-Returns:\r
-  STATUS_SUCCESS    - no errors or warnings\r
-  STATUS_WARNING    - warnings, but no errors, were encountered\r
-  STATUS_ERROR      - errors were encountered\r
-\r
---*/\r
-{\r
-  FILE                        *OutFptr;\r
-  FLASH_BLOCK_DESCRIPTION     *FBlock;\r
-  FLASH_DEVICE_DESCRIPTION    *FDev;\r
-  unsigned int                Offset;\r
-  FLASH_SUBREGION_DESCRIPTION *Subregion;\r
-  unsigned int                SubregionOffset;\r
-  //\r
-  // Find the definition we're supposed to use\r
-  //\r
-  for (FDev = mFlashDevices; FDev != NULL; FDev = FDev->Next) {\r
-    if (strcmp (FDev->Name, FlashDeviceName) == 0) {\r
-      break;\r
-    }\r
-  }\r
-\r
-  if (FDev == NULL) {\r
-    Error (NULL, 0, 0, FlashDeviceName, "flash device not found in flash definitions");\r
-    return STATUS_ERROR;\r
-  }\r
-\r
-  if ((OutFptr = fopen (FileName, "w")) == NULL) {\r
-    Error (NULL, 0, 0, FileName, "failed to open output file for writing");\r
-    return STATUS_ERROR;\r
-  }\r
-  //\r
-  // Write the flash base address and size\r
-  //\r
-  fprintf (OutFptr, "\n");\r
-  fprintf (OutFptr, "FLASH_BASE                                      = 0x%08X\n", FDev->BaseAddress);\r
-  fprintf (OutFptr, "FLASH_SIZE                                      = 0x%08X\n\n", FDev->Size);\r
-  //\r
-  // Write flash block size and offset defines\r
-  //\r
-  Offset = 0;\r
-  for (FBlock = FDev->Regions; FBlock != NULL; FBlock = FBlock->Next) {\r
-    fprintf (\r
-      OutFptr,\r
-      "FLASH_REGION_%s_BASE          %*c= 0x%08X\n",\r
-      FBlock->Name,\r
-      COLUMN2_START - 40 - strlen (FBlock->Name),\r
-      ' ',\r
-      Offset + FDev->BaseAddress\r
-      );\r
-    fprintf (\r
-      OutFptr,\r
-      "FLASH_REGION_%s_SIZE          %*c= 0x%08X\n",\r
-      FBlock->Name,\r
-      COLUMN2_START - 40 - strlen (FBlock->Name),\r
-      ' ',\r
-      FBlock->Size\r
-      );\r
-    fprintf (\r
-      OutFptr,\r
-      "FLASH_REGION_%s_SIZE_BLOCKS   %*c= 0x%x\n",\r
-      FBlock->Name,\r
-      COLUMN2_START - 40 - strlen (FBlock->Name),\r
-      ' ',\r
-      (FBlock->Size)/(FDev->PBlocks->Size)\r
-      );      \r
-    //\r
-    // Create defines for any subregions\r
-    //\r
-    SubregionOffset = 0;\r
-    for (Subregion = FBlock->Subregions; Subregion != NULL; Subregion = Subregion->Next) {\r
-      fprintf (\r
-        OutFptr,\r
-        "FLASH_REGION_%s_SUBREGION_%s_BASE     %*c= 0x%08X\n",\r
-        FBlock->Name,\r
-        Subregion->Name,\r
-        COLUMN3_START - 48 - strlen (FBlock->Name) - strlen (Subregion->Name),\r
-        ' ',\r
-        FDev->BaseAddress + Offset + SubregionOffset\r
-        );\r
-      fprintf (\r
-        OutFptr,\r
-        "FLASH_REGION_%s_SUBREGION_%s_SIZE     %*c= 0x%08X\n",\r
-        FBlock->Name,\r
-        Subregion->Name,\r
-        COLUMN3_START - 48 - strlen (FBlock->Name) - strlen (Subregion->Name),\r
-        ' ',\r
-        Subregion->Size\r
-        );\r
-      fprintf (\r
-        OutFptr,\r
-        "FLASH_REGION_%s_SUBREGION_%s_OFFSET   %*c= 0x%08X\n",\r
-        FBlock->Name,\r
-        Subregion->Name,\r
-        COLUMN3_START - 48 - strlen (FBlock->Name) - strlen (Subregion->Name),\r
-        ' ',\r
-        Offset + SubregionOffset\r
-        );\r
-\r
-      SubregionOffset += Subregion->Size;\r
-    }\r
-\r
-    Offset += FBlock->Size;\r
-  }\r
-  //\r
-  // Close file\r
-  //\r
-  fprintf (OutFptr, "\n");\r
-  fclose (OutFptr);\r
-  return STATUS_SUCCESS;\r
-}\r
-\r
-\r
-/*++\r
-\r
-Routine Description:\r
-  The following buffer management routines are used to encapsulate functionality\r
-  for managing a growable data buffer.\r
-\r
-Arguments:\r
-  BUFFER_DATA     - structure that is used to maintain a data buffer\r
-\r
-Returns:\r
-  NA\r
-\r
---*/\r
-static\r
-BUFFER_DATA *\r
-CreateBufferData (\r
-  VOID\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Create a growable data buffer with default buffer length.\r
-\r
-Arguments:\r
-\r
-  None\r
-\r
-Returns:\r
-\r
-  NULL          - error occured during data buffer creation\r
-  Not NULL      - the pointer to the newly created data buffer\r
-\r
---*/\r
-{\r
-  BUFFER_DATA *BD;\r
-  BD = (BUFFER_DATA *) _malloc (sizeof (BUFFER_DATA));\r
-  if (BD == NULL) {\r
-    Error (__FILE__, __LINE__, 0, "memory allocation failure", NULL);\r
-    return NULL;\r
-  }\r
-\r
-  memset (BD, 0, sizeof (BUFFER_DATA));\r
-  BD->BufferStart = (char *) _malloc (BUFFER_SIZE);\r
-  if (BD->BufferStart == NULL) {\r
-    _free (BD);\r
-    Error (__FILE__, __LINE__, 0, "memory allocation failure", NULL);\r
-    return NULL;\r
-  }\r
-\r
-  BD->BufferEnd = BD->BufferStart + BUFFER_SIZE;\r
-  BD->BufferPos = BD->BufferStart;\r
-  return BD;\r
-}\r
-\r
-static\r
-BOOLEAN\r
-AddBufferDataByte (\r
-  BUFFER_DATA *Buffer,\r
-  char        Data\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Add a single byte to a growable data buffer, growing the buffer if required.\r
-\r
-Arguments:\r
-\r
-  Buffer  - pointer to the growable data buffer to add a single byte to\r
-  Data    - value of the single byte data to be added\r
-\r
-Returns:\r
-\r
-  TRUE    - the single byte data was successfully added\r
-  FALSE   - error occurred, the single byte data was not added\r
-\r
---*/\r
-{\r
-  int   Size;\r
-  char  *NewBuffer;\r
-  //\r
-  // See if we have to grow the buffer\r
-  //\r
-  if (Buffer->BufferPos >= Buffer->BufferEnd) {\r
-    Size      = (int) Buffer->BufferEnd - (int) Buffer->BufferStart;\r
-    NewBuffer = (char *) _malloc (Size + BUFFER_SIZE);\r
-    if (NewBuffer == NULL) {\r
-      Error (__FILE__, __LINE__, 0, "memory allocation failure", NULL);\r
-      return FALSE;\r
-    }\r
-\r
-    memcpy (NewBuffer, Buffer->BufferStart, Size);\r
-    _free (Buffer->BufferStart);\r
-    Buffer->BufferStart = NewBuffer;\r
-    Buffer->BufferPos   = Buffer->BufferStart + Size;\r
-    Buffer->BufferEnd   = Buffer->BufferStart + Size + BUFFER_SIZE;\r
-  }\r
-\r
-  *Buffer->BufferPos = Data;\r
-  Buffer->BufferPos++;\r
-  return TRUE;\r
-}\r
-\r
-static\r
-void\r
-FreeBufferData (\r
-  BUFFER_DATA *Buffer,\r
-  BOOLEAN     FreeData\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Free memory used to manage a growable data buffer.\r
-\r
-Arguments:\r
-\r
-  Buffer    - pointer to the growable data buffer to be destructed\r
-  FreeData  - TRUE, free memory containing the buffered data\r
-              FALSE, do not free the buffered data memory\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-{\r
-  if (Buffer != NULL) {\r
-    if (FreeData && (Buffer->BufferStart != NULL)) {\r
-      _free (Buffer->BufferStart);\r
-    }\r
-\r
-    _free (Buffer);\r
-  }\r
-}\r
-\r
-static\r
-char *\r
-GetBufferData (\r
-  BUFFER_DATA *Buffer,\r
-  int         *BufferSize\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Return a pointer and size of the data in a growable data buffer.\r
-\r
-Arguments:\r
-\r
-  Buffer      - pointer to the growable data buffer\r
-  BufferSize  - size of the data in the growable data buffer\r
-\r
-Returns:\r
-\r
-  pointer of the data in the growable data buffer\r
-\r
---*/\r
-{\r
-  *BufferSize = (int) Buffer->BufferPos - (int) Buffer->BufferStart;\r
-  return Buffer->BufferStart;\r
-}\r
-\r
-STATUS\r
-FDDiscover (\r
-  char          *FDFileName,\r
-  unsigned int  BaseAddr\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Walk a binary image and see if you find anything that looks like a\r
-  firmware volume.\r
-\r
-Arguments:\r
-  FDFileName        - name of input FD image to parse\r
-  BaseAddr          - base address of input FD image\r
-\r
-Returns:\r
-  STATUS_SUCCESS    - no errors or warnings\r
-  STATUS_WARNING    - warnings, but no errors, were encountered\r
-  STATUS_ERROR      - errors were encountered\r
-\r
-NOTE:\r
-  This routine is used for debug purposes only.\r
-\r
---*/\r
-{\r
-  FILE                        *InFptr;\r
-  long                        FileSize;\r
-  long                        Offset;\r
-  EFI_FIRMWARE_VOLUME_HEADER  FVHeader;\r
-  EFI_GUID\r
-    FileSystemGuid = { 0x7A9354D9, 0x0468, 0x444a, 0x81, 0xCE, 0x0B, 0xF6, 0x17, 0xD8, 0x90, 0xDF };\r
-\r
-  if ((InFptr = fopen (FDFileName, "rb")) == NULL) {\r
-    Error (NULL, 0, 0, FDFileName, "failed to open file for reading");\r
-    return STATUS_ERROR;\r
-  }\r
-\r
-  fseek (InFptr, 0, SEEK_END);\r
-  FileSize = ftell (InFptr);\r
-  fseek (InFptr, 0, SEEK_SET);\r
-  Offset = 0;\r
-  while (Offset < FileSize) {\r
-    fseek (InFptr, Offset, SEEK_SET);\r
-    //\r
-    // Read the contents of the file, see if it's an FV header\r
-    //\r
-    if (fread (&FVHeader, sizeof (EFI_FIRMWARE_VOLUME_HEADER), 1, InFptr) == 1) {\r
-      //\r
-      // Check version and GUID\r
-      //\r
-      if ((FVHeader.Revision == EFI_FVH_REVISION) && (FVHeader.Signature == EFI_FVH_SIGNATURE)) {\r
-        fprintf (stdout, "FV header at 0x%08X FVSize=0x%08X ", Offset + BaseAddr, (UINT32) FVHeader.FvLength);\r
-        if (memcmp (&FVHeader.FileSystemGuid, &FileSystemGuid, sizeof (EFI_GUID)) == 0) {\r
-          fprintf (stdout, "standard FFS file system\n");\r
-        } else {\r
-          fprintf (stdout, "non-standard FFS file system\n");\r
-        }\r
-      }\r
-    }\r
-\r
-    Offset += 16 * 1024;\r
-  }\r
-\r
-  fclose (InFptr);\r
-  return STATUS_SUCCESS;\r
-}\r
diff --git a/Tools/CodeTools/TianoTools/FlashMap/FlashDefFile.h b/Tools/CodeTools/TianoTools/FlashMap/FlashDefFile.h
deleted file mode 100644 (file)
index 0e2ea2c..0000000
+++ /dev/null
@@ -1,281 +0,0 @@
-/*++\r
-\r
-Copyright (c)  2004-2006 Intel Corporation. All rights reserved\r
-This program and the accompanying materials are licensed and made available \r
-under the terms and conditions of the BSD License which accompanies this \r
-distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-\r
-Module Name:\r
-\r
-  FlashDefFile.h\r
-\r
-Abstract:\r
-\r
-  Header file for flash management utility in the Intel Platform \r
-  Innovation Framework for EFI build environment.\r
-\r
---*/\r
-\r
-#ifndef _FLASH_DEF_FILE_H_\r
-#define _FLASH_DEF_FILE_H_\r
-\r
-#ifdef __cplusplus\r
-extern "C"\r
-{\r
-#endif\r
-\r
-void\r
-FDFConstructor (\r
-  VOID\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  None\r
-\r
-Returns:\r
-\r
-  GC_TODO: add return values\r
-\r
---*/\r
-;\r
-\r
-void\r
-FDFDestructor (\r
-  VOID\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  None\r
-\r
-Returns:\r
-\r
-  GC_TODO: add return values\r
-\r
---*/\r
-;\r
-\r
-STATUS\r
-FDFParseFile (\r
-  char    *FileName\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  FileName  - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
-  GC_TODO: add return values\r
-\r
---*/\r
-;\r
-\r
-STATUS\r
-FDFCreateCIncludeFile (\r
-  char      *FlashDeviceName,\r
-  char      *FileName\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  FlashDeviceName - GC_TODO: add argument description\r
-  FileName        - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
-  GC_TODO: add return values\r
-\r
---*/\r
-;\r
-\r
-STATUS\r
-FDFCreateCFlashMapDataFile (\r
-  char      *FlashDeviceName,\r
-  char      *FileName\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  FlashDeviceName - GC_TODO: add argument description\r
-  FileName        - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
-  GC_TODO: add return values\r
-\r
---*/\r
-;\r
-\r
-STATUS\r
-FDFCreateAsmIncludeFile (\r
-  char      *FlashDeviceName,\r
-  char      *FileName\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  FlashDeviceName - GC_TODO: add argument description\r
-  FileName        - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
-  GC_TODO: add return values\r
-\r
---*/\r
-;\r
-\r
-STATUS\r
-FDFParseFile (\r
-  char      *FileName\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  FileName  - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
-  GC_TODO: add return values\r
-\r
---*/\r
-;\r
-\r
-STATUS\r
-FDFCreateImage (\r
-  char      *FlashDeviceName,\r
-  char      *ImageName,\r
-  char      *FileName\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  FlashDeviceName - GC_TODO: add argument description\r
-  ImageName       - GC_TODO: add argument description\r
-  FileName        - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
-  GC_TODO: add return values\r
-\r
---*/\r
-;\r
-\r
-STATUS\r
-FDFCreateDscFile (\r
-  char      *FlashDeviceName,\r
-  char      *FileName\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  FlashDeviceName - GC_TODO: add argument description\r
-  FileName        - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
-  GC_TODO: add return values\r
-\r
---*/\r
-;\r
-\r
-STATUS\r
-FDFCreateSymbols (\r
-  char      *FlashDeviceName\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  FlashDeviceName - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
-  GC_TODO: add return values\r
-\r
---*/\r
-;\r
-\r
-STATUS\r
-FDDiscover (\r
-  char          *FDFileName,\r
-  unsigned int  BaseAddr\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  FDFileName  - GC_TODO: add argument description\r
-  BaseAddr    - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
-  GC_TODO: add return values\r
-\r
---*/\r
-;\r
-\r
-#ifdef __cplusplus\r
-}\r
-#endif\r
-\r
-#endif // #ifndef _FLASH_DEF_FILE_H_\r
diff --git a/Tools/CodeTools/TianoTools/FlashMap/FlashMap.c b/Tools/CodeTools/TianoTools/FlashMap/FlashMap.c
deleted file mode 100644 (file)
index 88f5003..0000000
+++ /dev/null
@@ -1,769 +0,0 @@
-/*++\r
-\r
-Copyright (c)  2004-2006 Intel Corporation. All rights reserved\r
-This program and the accompanying materials are licensed and made available \r
-under the terms and conditions of the BSD License which accompanies this \r
-distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-Module Name:\r
-\r
-  FlashMap.c\r
-\r
-Abstract:\r
-\r
-  Utility for flash management in the Intel Platform Innovation Framework\r
-  for EFI build environment.\r
-\r
---*/\r
-\r
-#include <stdio.h>\r
-#include <string.h>\r
-#include <stdlib.h>\r
-#include <ctype.h>\r
-\r
-#include <Common/UefiBaseTypes.h>\r
-\r
-#include "EfiUtilityMsgs.h"\r
-#include "Microcode.h"\r
-#include "FlashDefFile.h"\r
-#include "Symbols.h"\r
-\r
-#define UTILITY_NAME  "FlashMap"\r
-\r
-typedef struct _STRING_LIST {\r
-  struct _STRING_LIST *Next;\r
-  char                *Str;\r
-} STRING_LIST;\r
-\r
-//\r
-// Keep our globals in one of these structures\r
-//\r
-static struct {\r
-  char          *CIncludeFileName;\r
-  char          *FlashDevice;\r
-  char          *FlashDeviceImage;\r
-  char          *MCIFileName;\r
-  char          *MCOFileName;\r
-  char          *ImageOutFileName;\r
-  char          *DscFileName;\r
-  char          *AsmIncludeFileName;\r
-  char          *FlashDefinitionFileName;\r
-  char          *StringReplaceInFileName;\r
-  char          *StringReplaceOutFileName;\r
-  char          *DiscoverFDImageName;\r
-  char          MicrocodePadByteValue;\r
-  unsigned int  MicrocodeAlignment;\r
-  STRING_LIST   *MCIFileNames;\r
-  STRING_LIST   *LastMCIFileNames;\r
-  unsigned int  BaseAddress;\r
-} mGlobals;\r
-\r
-#define DEFAULT_MC_PAD_BYTE_VALUE 0xFF\r
-#define DEFAULT_MC_ALIGNMENT      16\r
-\r
-static\r
-STATUS\r
-ProcessCommandLine (\r
-  int     argc,\r
-  char    *argv[]\r
-  );\r
-\r
-static\r
-STATUS\r
-MergeMicrocodeFiles (\r
-  char            *OutFileName,\r
-  STRING_LIST     *FileNames,\r
-  unsigned int    Alignment,\r
-  char            PadByteValue\r
-  );\r
-\r
-static\r
-void\r
-Usage (\r
-  VOID\r
-  );\r
-\r
-char* \r
-NormalizePath (\r
-  char* OldPathName\r
-  );\r
-\r
-int\r
-main (\r
-  int   argc,\r
-  char  *argv[]\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Parse the command line arguments and then call worker functions to do the work\r
-  \r
-Arguments:\r
-  argc      - number of elements in argv\r
-  argv      - array of command-line arguments\r
-\r
-Returns:\r
-  STATUS_SUCCESS    - no problems encountered while processing\r
-  STATUS_WARNING    - warnings, but no errors, were encountered while processing\r
-  STATUS_ERROR      - errors were encountered while processing\r
-  \r
---*/\r
-{\r
-  STATUS  Status;\r
-\r
-  SetUtilityName (UTILITY_NAME);\r
-  Status = ProcessCommandLine (argc, argv);\r
-  if (Status != STATUS_SUCCESS) {\r
-    return Status;\r
-  }\r
-  //\r
-  // Check for discovery of an FD (command line option)\r
-  //\r
-  if (mGlobals.DiscoverFDImageName != NULL) {\r
-    Status = FDDiscover (mGlobals.DiscoverFDImageName, mGlobals.BaseAddress);\r
-    goto Done;\r
-  }\r
-  //\r
-  // If they're doing microcode file parsing, then do that\r
-  //\r
-  if (mGlobals.MCIFileName != NULL) {\r
-    MicrocodeConstructor ();\r
-    MicrocodeParseFile (mGlobals.MCIFileName, mGlobals.MCOFileName);\r
-    MicrocodeDestructor ();\r
-  }\r
-  //\r
-  // If they're doing microcode file merging, then do that now\r
-  //\r
-  if (mGlobals.MCIFileNames != NULL) {\r
-    MergeMicrocodeFiles (\r
-      mGlobals.MCOFileName,\r
-      mGlobals.MCIFileNames,\r
-      mGlobals.MicrocodeAlignment,\r
-      mGlobals.MicrocodePadByteValue\r
-      );\r
-  }\r
-  //\r
-  // If using a flash definition file, then process that and return\r
-  //\r
-  if (mGlobals.FlashDefinitionFileName != NULL) {\r
-    FDFConstructor ();\r
-    SymbolsConstructor ();\r
-    Status = FDFParseFile (mGlobals.FlashDefinitionFileName);\r
-    if (GetUtilityStatus () != STATUS_ERROR) {\r
-      //\r
-      // If they want us to do a string-replace on a file, then add the symbol definitions to\r
-      // the symbol table, and then do the string replace.\r
-      //\r
-      if (mGlobals.StringReplaceInFileName != NULL) {\r
-        Status  = FDFCreateSymbols (mGlobals.FlashDevice);\r
-        Status  = SymbolsFileStringsReplace (mGlobals.StringReplaceInFileName, mGlobals.StringReplaceOutFileName);\r
-      }\r
-      //\r
-      // If they want us to create a .h defines file or .c flashmap data file, then do so now\r
-      //\r
-      if (mGlobals.CIncludeFileName != NULL) {\r
-        Status = FDFCreateCIncludeFile (mGlobals.FlashDevice, mGlobals.CIncludeFileName);\r
-      }\r
-      if (mGlobals.AsmIncludeFileName != NULL) {\r
-        Status = FDFCreateAsmIncludeFile (mGlobals.FlashDevice, mGlobals.AsmIncludeFileName);\r
-      }\r
-      //\r
-      // If they want us to create an image, do that now\r
-      //\r
-      if (mGlobals.ImageOutFileName != NULL) {\r
-        Status = FDFCreateImage (mGlobals.FlashDevice, mGlobals.FlashDeviceImage, mGlobals.ImageOutFileName);\r
-      }\r
-      //\r
-      // If they want to create an output DSC file, do that now\r
-      //\r
-      if (mGlobals.DscFileName != NULL) {\r
-        Status = FDFCreateDscFile (mGlobals.FlashDevice, mGlobals.DscFileName);\r
-      }\r
-    }\r
-    SymbolsDestructor ();\r
-    FDFDestructor ();\r
-  }\r
-Done:\r
-  //\r
-  // Free up memory\r
-  //\r
-  while (mGlobals.MCIFileNames != NULL) {\r
-    mGlobals.LastMCIFileNames = mGlobals.MCIFileNames->Next;\r
-    _free (mGlobals.MCIFileNames);\r
-    mGlobals.MCIFileNames = mGlobals.LastMCIFileNames;\r
-  }\r
-  return GetUtilityStatus ();\r
-}\r
-\r
-static\r
-STATUS\r
-MergeMicrocodeFiles (\r
-  char            *OutFileName,\r
-  STRING_LIST     *FileNames,\r
-  unsigned int    Alignment,\r
-  char            PadByteValue\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Merge binary microcode files into a single file, taking into consideration\r
-  the alignment and pad value.\r
-\r
-Arguments:\r
-\r
-  OutFileName     - name of the output file to create\r
-  FileNames       - linked list of input microcode files to merge\r
-  Alignment       - alignment for each microcode file in the output image\r
-  PadByteValue    - value to use when padding to meet alignment requirements\r
-\r
-Returns:\r
-\r
-  STATUS_SUCCESS  - merge completed successfully or with acceptable warnings\r
-  STATUS_ERROR    - merge failed, output file not created\r
-\r
---*/\r
-{\r
-  long    FileSize;\r
-  long    TotalFileSize;\r
-  FILE    *InFptr;\r
-  FILE    *OutFptr;\r
-  char    *Buffer;\r
-  STATUS  Status;\r
-\r
-  //\r
-  // Open the output file\r
-  //\r
-  if ((OutFptr = fopen (OutFileName, "wb")) == NULL) {\r
-    Error (NULL, 0, 0, OutFileName, "failed to open output file for writing");\r
-    return STATUS_ERROR;\r
-  }\r
-  //\r
-  // Walk the list of files\r
-  //\r
-  Status        = STATUS_ERROR;\r
-  Buffer        = NULL;\r
-  InFptr        = NULL;\r
-  TotalFileSize = 0;\r
-  while (FileNames != NULL) {\r
-    //\r
-    // Open the file, determine the size, then read it in and write\r
-    // it back out.\r
-    //\r
-    if ((InFptr = fopen (NormalizePath(FileNames->Str), "rb")) == NULL) {\r
-      Error (NULL, 0, 0, NormalizePath(FileNames->Str), "failed to open input file for reading");\r
-      goto Done;\r
-    }\r
-    fseek (InFptr, 0, SEEK_END);\r
-    FileSize = ftell (InFptr);\r
-    fseek (InFptr, 0, SEEK_SET);\r
-    if (FileSize != 0) {\r
-      Buffer = (char *) _malloc (FileSize);\r
-      if (Buffer == NULL) {\r
-        Error (NULL, 0, 0, "memory allocation failure", NULL);\r
-        goto Done;\r
-      }\r
-      if (fread (Buffer, FileSize, 1, InFptr) != 1) {\r
-        Error (NULL, 0, 0, FileNames->Str, "failed to read file contents");\r
-        goto Done;\r
-      }\r
-      //\r
-      // Align\r
-      //\r
-      if (Alignment != 0) {\r
-        while ((TotalFileSize % Alignment) != 0) {\r
-          if (fwrite (&PadByteValue, 1, 1, OutFptr) != 1) {\r
-            Error (NULL, 0, 0, OutFileName, "failed to write pad bytes to output file");\r
-            goto Done;\r
-          }\r
-          TotalFileSize++;\r
-        }\r
-      }\r
-      TotalFileSize += FileSize;\r
-      if (fwrite (Buffer, FileSize, 1, OutFptr) != 1) {\r
-        Error (NULL, 0, 0, OutFileName, "failed to write to output file");\r
-        goto Done;\r
-      }\r
-      _free (Buffer);\r
-      Buffer = NULL;\r
-    } else {\r
-      Warning (NULL, 0, 0, FileNames->Str, "0-size file encountered");\r
-    }\r
-    fclose (InFptr);\r
-    InFptr    = NULL;\r
-    FileNames = FileNames->Next;\r
-  }\r
-  Status = STATUS_SUCCESS;\r
-Done:\r
-  fclose (OutFptr);\r
-  if (InFptr != NULL) {\r
-    fclose (InFptr);\r
-  }\r
-  if (Buffer != NULL) {\r
-    _free (Buffer);\r
-  }\r
-  if (Status == STATUS_ERROR) {\r
-    remove (OutFileName);\r
-  }\r
-  return Status;\r
-}\r
-\r
-static\r
-STATUS\r
-ProcessCommandLine (\r
-  int   argc,\r
-  char  *argv[]\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Process the command line arguments\r
-  \r
-Arguments:\r
-  argc   - Standard C entry point arguments\r
-  argv[] - Standard C entry point arguments\r
-\r
-Returns:\r
-  STATUS_SUCCESS    - no problems encountered while processing\r
-  STATUS_WARNING    - warnings, but no errors, were encountered while processing\r
-  STATUS_ERROR      - errors were encountered while processing\r
-  \r
---*/\r
-{\r
-  int           ThingsToDo;\r
-  unsigned int  Temp;\r
-  STRING_LIST   *Str;\r
-  //\r
-  // Skip program name arg, process others\r
-  //\r
-  argc--;\r
-  argv++;\r
-  if (argc == 0) {\r
-    Usage ();\r
-    return STATUS_ERROR;\r
-  }\r
-  //\r
-  // Clear out our globals, then start walking the arguments\r
-  //\r
-  memset ((void *) &mGlobals, 0, sizeof (mGlobals));\r
-  mGlobals.MicrocodePadByteValue  = DEFAULT_MC_PAD_BYTE_VALUE;\r
-  mGlobals.MicrocodeAlignment     = DEFAULT_MC_ALIGNMENT;\r
-  ThingsToDo                      = 0;\r
-  while (argc > 0) {\r
-    if (strcmp (argv[0], "-?") == 0) {\r
-      Usage ();\r
-      return STATUS_ERROR;\r
-    } else if (strcmp (argv[0], "-hfile") == 0) {\r
-      //\r
-      // -hfile FileName\r
-      //\r
-      // Used to specify an output C #include file to create that contains\r
-      // #define statements for all the flashmap region offsets and sizes.\r
-      // Check for additional argument.\r
-      //\r
-      if (argc < 2) {\r
-        Error (NULL, 0, 0, argv[0], "option requires an output file name");\r
-        return STATUS_ERROR;\r
-      }\r
-      argc--;\r
-      argv++;\r
-      mGlobals.CIncludeFileName = argv[0];\r
-      ThingsToDo++;\r
-    } else if (strcmp (argv[0], "-flashdevice") == 0) {\r
-      //\r
-      // -flashdevice FLASH_DEVICE_NAME\r
-      //\r
-      // Used to select which flash device definition to operate on.\r
-      // Check for additional argument\r
-      //\r
-      if (argc < 2) {\r
-        Error (NULL, 0, 0, argv[0], "option requires a flash device name to use");\r
-        return STATUS_ERROR;\r
-      }\r
-      argc--;\r
-      argv++;\r
-      mGlobals.FlashDevice = argv[0];\r
-    } else if (strcmp (argv[0], "-mco") == 0) {\r
-      //\r
-      // -mco OutFileName\r
-      //\r
-      // Used to specify a microcode output binary file to create.\r
-      // Check for additional argument.\r
-      //\r
-      if (argc < 2) {\r
-        Error (NULL, 0, 0, (INT8 *) argv[0], (INT8 *) "option requires an output microcode file name to create");\r
-        return STATUS_ERROR;\r
-      }\r
-      argc--;\r
-      argv++;\r
-      mGlobals.MCOFileName = argv[0];\r
-      ThingsToDo++;\r
-    } else if (strcmp (argv[0], "-asmincfile") == 0) {\r
-      //\r
-      // -asmincfile FileName\r
-      //\r
-      // Used to specify the name of the output assembly include file that contains\r
-      // equates for the flash region addresses and sizes.\r
-      // Check for additional argument.\r
-      //\r
-      if (argc < 2) {\r
-        Error (NULL, 0, 0, argv[0], "option requires an output ASM include file name to create");\r
-        return STATUS_ERROR;\r
-      }\r
-      argc--;\r
-      argv++;\r
-      mGlobals.AsmIncludeFileName = argv[0];\r
-      ThingsToDo++;\r
-    } else if (strcmp (argv[0], "-mci") == 0) {\r
-      //\r
-      // -mci FileName\r
-      //\r
-      // Used to specify an input microcode text file to parse.\r
-      // Check for additional argument\r
-      //\r
-      if (argc < 2) {\r
-        Error (NULL, 0, 0, (INT8 *) argv[0], (INT8 *) "option requires an input microcode text file name to parse");\r
-        return STATUS_ERROR;\r
-      }\r
-      argc--;\r
-      argv++;\r
-      mGlobals.MCIFileName = argv[0];\r
-    } else if (strcmp (argv[0], "-flashdeviceimage") == 0) {\r
-      //\r
-      // -flashdeviceimage FlashDeviceImage\r
-      //\r
-      // Used to specify which flash device image definition from the input flash definition file\r
-      // to create.\r
-      // Check for additional argument.\r
-      //\r
-      if (argc < 2) {\r
-        Error (NULL, 0, 0, argv[0], "option requires the name of a flash definition image to use");\r
-        return STATUS_ERROR;\r
-      }\r
-      argc--;\r
-      argv++;\r
-      mGlobals.FlashDeviceImage = argv[0];\r
-    } else if (strcmp (argv[0], "-imageout") == 0) {\r
-      //\r
-      // -imageout FileName\r
-      //\r
-      // Used to specify the name of the output FD image file to create.\r
-      // Check for additional argument.\r
-      //\r
-      if (argc < 2) {\r
-        Error (NULL, 0, 0, argv[0], "option requires an output image filename to create");\r
-        return STATUS_ERROR;\r
-      }\r
-      argc--;\r
-      argv++;\r
-      mGlobals.ImageOutFileName = argv[0];\r
-      ThingsToDo++;\r
-    } else if (strcmp (argv[0], "-dsc") == 0) {\r
-      //\r
-      // -dsc FileName\r
-      //\r
-      // Used to specify the name of the output DSC file to create.\r
-      // Check for additional argument.\r
-      //\r
-      if (argc < 2) {\r
-        Error (NULL, 0, 0, argv[0], "option requires an output DSC filename to create");\r
-        return STATUS_ERROR;\r
-      }\r
-      argc--;\r
-      argv++;\r
-      mGlobals.DscFileName = argv[0];\r
-      ThingsToDo++;\r
-    } else if (strcmp (argv[0], "-fdf") == 0) {\r
-      //\r
-      // -fdf FileName\r
-      //\r
-      // Used to specify the name of the input flash definition file.\r
-      // Check for additional argument.\r
-      //\r
-      if (argc < 2) {\r
-        Error (NULL, 0, 0, argv[0], "option requires an input flash definition file name");\r
-        return STATUS_ERROR;\r
-      }\r
-      argc--;\r
-      argv++;\r
-      mGlobals.FlashDefinitionFileName = argv[0];\r
-    } else if (strcmp (argv[0], "-discover") == 0) {\r
-      //\r
-      // -discover FDFileName\r
-      //\r
-      // Debug functionality used to scan an existing FD image, trying to find\r
-      // firmware volumes at 64K boundaries.\r
-      // Check for additional argument.\r
-      //\r
-      if (argc < 2) {\r
-        Error (NULL, 0, 0, argv[0], "option requires an input FD image file name");\r
-        return STATUS_ERROR;\r
-      }\r
-      argc--;\r
-      argv++;\r
-      mGlobals.DiscoverFDImageName = argv[0];\r
-      ThingsToDo++;\r
-    } else if (strcmp (argv[0], "-baseaddr") == 0) {\r
-      //\r
-      // -baseaddr Addr\r
-      //\r
-      // Used to specify a base address when doing a discover of an FD image.\r
-      // Check for additional argument.\r
-      //\r
-      if (argc < 2) {\r
-        Error (NULL, 0, 0, argv[0], "option requires a base address");\r
-        return STATUS_ERROR;\r
-      }\r
-      argc--;\r
-      argv++;\r
-      if (tolower (argv[0][1]) == 'x') {\r
-        sscanf (argv[0] + 2, "%x", &mGlobals.BaseAddress);\r
-      } else {\r
-        sscanf (argv[0], "%d", &mGlobals.BaseAddress);\r
-      }\r
-    } else if (strcmp (argv[0], "-padvalue") == 0) {\r
-      //\r
-      // -padvalue Value\r
-      //\r
-      // Used to specify the value to pad with when aligning data while\r
-      // creating an FD image. Check for additional argument.\r
-      //\r
-      if (argc < 2) {\r
-        Error (NULL, 0, 0, argv[0], "option requires a byte value");\r
-        return STATUS_ERROR;\r
-      }\r
-      argc--;\r
-      argv++;\r
-      if (tolower (argv[0][1]) == 'x') {\r
-        sscanf (argv[0] + 2, "%x", &Temp);\r
-        mGlobals.MicrocodePadByteValue = (char) Temp;\r
-      } else {\r
-        sscanf (argv[0], "%d", &Temp);\r
-        mGlobals.MicrocodePadByteValue = (char) Temp;\r
-      }\r
-    } else if (strcmp (argv[0], "-align") == 0) {\r
-      //\r
-      // -align Alignment\r
-      //\r
-      // Used to specify how each data file is aligned in the region\r
-      // when creating an FD image. Check for additional argument.\r
-      //\r
-      if (argc < 2) {\r
-        Error (NULL, 0, 0, argv[0], "option requires an alignment");\r
-        return STATUS_ERROR;\r
-      }\r
-      argc--;\r
-      argv++;\r
-      if (tolower (argv[0][1]) == 'x') {\r
-        sscanf (argv[0] + 2, "%x", &mGlobals.MicrocodeAlignment);\r
-      } else {\r
-        sscanf (argv[0], "%d", &mGlobals.MicrocodeAlignment);\r
-      }\r
-    } else if (strcmp (argv[0], "-mcmerge") == 0) {\r
-      //\r
-      // -mcmerge FileName(s)\r
-      //\r
-      // Used to concatenate multiple microde binary files. Can specify\r
-      // multiple file names with the one -mcmerge flag. Check for additional argument.\r
-      //\r
-      if ((argc < 2) || (argv[1][0] == '-')) {\r
-        Error (NULL, 0, 0, argv[0], "option requires one or more input file names");\r
-        return STATUS_ERROR;\r
-      }\r
-      //\r
-      // Take input files until another option or end of list\r
-      //\r
-      ThingsToDo++;\r
-      while ((argc > 1) && (argv[1][0] != '-')) {\r
-        Str = (STRING_LIST *) _malloc (sizeof (STRING_LIST));\r
-        if (Str == NULL) {\r
-          Error (NULL, 0, 0, "memory allocation failure", NULL);\r
-          return STATUS_ERROR;\r
-        }\r
-        memset (Str, 0, sizeof (STRING_LIST));\r
-        Str->Str = argv[1];\r
-        if (mGlobals.MCIFileNames == NULL) {\r
-          mGlobals.MCIFileNames = Str;\r
-        } else {\r
-          mGlobals.LastMCIFileNames->Next = Str;\r
-        }\r
-        mGlobals.LastMCIFileNames = Str;\r
-        argc--;\r
-        argv++;\r
-      }\r
-    } else if (strcmp (argv[0], "-strsub") == 0) {\r
-      //\r
-      // -strsub SrcFile DestFile\r
-      //\r
-      // Used to perform string substitutions on a file, writing the result to a new\r
-      // file. Check for two additional arguments.\r
-      //\r
-      if (argc < 3) {\r
-        Error (NULL, 0, 0, argv[0], "option requires input and output file names for string substitution");\r
-        return STATUS_ERROR;\r
-      }\r
-      argc--;\r
-      argv++;\r
-      mGlobals.StringReplaceInFileName = argv[0];\r
-      argc--;\r
-      argv++;\r
-      mGlobals.StringReplaceOutFileName = argv[0];\r
-      ThingsToDo++;\r
-    } else {\r
-      Error (NULL, 0, 0, argv[0], "invalid option");\r
-      return STATUS_ERROR;\r
-    }\r
-    argc--;\r
-    argv++;\r
-  }\r
-  //\r
-  // If no outputs requested, then report an error\r
-  //\r
-  if (ThingsToDo == 0) {\r
-    Error (NULL, 0, 0, "nothing to do", NULL);\r
-    return STATUS_ERROR;\r
-  }\r
-  //\r
-  // If they want an asm file, #include file, or C file to be created, then they have to specify a\r
-  // flash device name and flash definition file name.\r
-  //\r
-  if ((mGlobals.CIncludeFileName != NULL) &&\r
-      ((mGlobals.FlashDevice == NULL) || (mGlobals.FlashDefinitionFileName == NULL))) {\r
-    Error (NULL, 0, 0, "must specify -flashdevice and -fdf with -hfile", NULL);\r
-    return STATUS_ERROR;\r
-  }\r
-  if ((mGlobals.AsmIncludeFileName != NULL) &&\r
-      ((mGlobals.FlashDevice == NULL) || (mGlobals.FlashDefinitionFileName == NULL))) {\r
-    Error (NULL, 0, 0, "must specify -flashdevice and -fdf with -asmincfile", NULL);\r
-    return STATUS_ERROR;\r
-  }\r
-  //\r
-  // If they want a dsc file to be created, then they have to specify a\r
-  // flash device name and a flash definition file name\r
-  //\r
-  if (mGlobals.DscFileName != NULL) {\r
-    if (mGlobals.FlashDevice == NULL) {\r
-      Error (NULL, 0, 0, "must specify -flashdevice with -dsc", NULL);\r
-      return STATUS_ERROR;\r
-    }\r
-    if (mGlobals.FlashDefinitionFileName == NULL) {\r
-      Error (NULL, 0, 0, "must specify -fdf with -dsc", NULL);\r
-      return STATUS_ERROR;\r
-    }\r
-  }\r
-  //\r
-  // If they specified an output microcode file name, then they have to specify an input\r
-  // file name, and vice versa.\r
-  //\r
-  if ((mGlobals.MCIFileName != NULL) && (mGlobals.MCOFileName == NULL)) {\r
-    Error (NULL, 0, 0, "must specify output microcode file name", NULL);\r
-    return STATUS_ERROR;\r
-  }\r
-  if ((mGlobals.MCOFileName != NULL) && (mGlobals.MCIFileName == NULL) && (mGlobals.MCIFileNames == NULL)) {\r
-    Error (NULL, 0, 0, "must specify input microcode file name", NULL);\r
-    return STATUS_ERROR;\r
-  }\r
-  //\r
-  // If doing merge, then have to specify output file name\r
-  //\r
-  if ((mGlobals.MCIFileNames != NULL) && (mGlobals.MCOFileName == NULL)) {\r
-    Error (NULL, 0, 0, "must specify output microcode file name", NULL);\r
-    return STATUS_ERROR;\r
-  }\r
-  //\r
-  // If they want an output image to be created, then they have to specify\r
-  // the flash device and the flash device image to use.\r
-  //\r
-  if (mGlobals.ImageOutFileName != NULL) {\r
-    if (mGlobals.FlashDevice == NULL) {\r
-      Error (NULL, 0, 0, "must specify -flashdevice with -imageout", NULL);\r
-      return STATUS_ERROR;\r
-    }\r
-    if (mGlobals.FlashDeviceImage == NULL) {\r
-      Error (NULL, 0, 0, "must specify -flashdeviceimage with -imageout", NULL);\r
-      return STATUS_ERROR;\r
-    }\r
-    if (mGlobals.FlashDefinitionFileName == NULL) {\r
-      Error (NULL, 0, 0, "must specify -c or -fdf with -imageout", NULL);\r
-      return STATUS_ERROR;\r
-    }\r
-  }\r
-  return STATUS_SUCCESS;\r
-}\r
-\r
-static\r
-void\r
-Usage (\r
-  VOID\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Print utility command line help\r
-  \r
-Arguments:\r
-  None\r
-\r
-Returns:\r
-  NA\r
-\r
---*/\r
-{\r
-  int   i;\r
-  char  *Msg[] = {\r
-    "Usage: FlashTool -fdf FlashDefFile -flashdevice FlashDevice",\r
-    "                 -flashdeviceimage FlashDeviceImage -mci MCIFile -mco MCOFile",\r
-    "                 -discover FDImage -dsc DscFile -asmincfile AsmIncFile",\r
-    "                 -imageOut ImageOutFile -hfile HFile -strsub InStrFile OutStrFile",\r
-    "                 -baseaddr BaseAddr -align Alignment -padvalue PadValue",\r
-    "                 -mcmerge MCIFile(s)",\r
-    "  where",\r
-    "    FlashDefFile     - input Flash Definition File",\r
-    "    FlashDevice      - flash device to use (from flash definition file)",\r
-    "    FlashDeviceImage - flash device image to use (from flash definition file)",\r
-    "    MCIFile          - input microcode file to parse",\r
-    "    MCOFile          - output binary microcode image to create from MCIFile",\r
-    "    HFile            - output #include file to create",\r
-    "    FDImage          - name of input FDImage file to scan",\r
-    "    ImageOutFile     - output image file to create",\r
-    "    DscFile          - output DSC file to create",\r
-    "    AsmIncFile       - output ASM include file to create",\r
-    "    InStrFile        - input file to replace symbol names, writing result to OutStrFile",\r
-    "    BaseAddr         - base address of FDImage (used with -discover)",\r
-    "    Alignment        - alignment to use when merging microcode binaries",\r
-    "    PadValue         - byte value to use as pad value when aligning microcode binaries",\r
-    "    MCIFile(s)       - one or more microcode binary files to merge/concatenate",\r
-    "",\r
-    NULL\r
-  };\r
-  for (i = 0; Msg[i] != NULL; i++) {\r
-    fprintf (stdout, "%s\n", Msg[i]);\r
-  }\r
-}\r
-\r
-char* \r
-NormalizePath (\r
-  char* OldPathName\r
-  )\r
-{\r
-  char* Visitor;\r
-  \r
-  if (OldPathName == NULL) {\r
-    return NULL;\r
-  }\r
-  \r
-  Visitor = OldPathName;\r
-  while (*Visitor != '\0') {\r
-    if (*Visitor == '\\') {\r
-      *Visitor = '/';\r
-    }\r
-    Visitor++;\r
-  }\r
-  \r
-  return OldPathName;\r
-}\r
-\r
diff --git a/Tools/CodeTools/TianoTools/FlashMap/Microcode.c b/Tools/CodeTools/TianoTools/FlashMap/Microcode.c
deleted file mode 100644 (file)
index 2335325..0000000
+++ /dev/null
@@ -1,304 +0,0 @@
-/*++\r
-\r
-Copyright (c)  2004-2006 Intel Corporation. All rights reserved\r
-This program and the accompanying materials are licensed and made available \r
-under the terms and conditions of the BSD License which accompanies this \r
-distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-Module Name:\r
-\r
-  Microcode.c\r
-\r
-Abstract:\r
-\r
-  Utility for working with microcode patch files in the Intel \r
-  Platform Innovation Framework for EFI build environment.\r
-\r
---*/\r
-\r
-#include <stdio.h>\r
-#include <string.h> // for memset()\r
-#include <ctype.h>\r
-#include <stdlib.h> // for malloc()\r
-\r
-#include "EfiUtilityMsgs.h"\r
-#include "Microcode.h"\r
-\r
-#define MAX_LINE_LEN  256\r
-\r
-//\r
-// Structure definition for a microcode header\r
-//\r
-typedef struct {\r
-  unsigned int  HeaderVersion;\r
-  unsigned int  PatchId;\r
-  unsigned int  Date;\r
-  unsigned int  CpuId;\r
-  unsigned int  Checksum;\r
-  unsigned int  LoaderVersion;\r
-  unsigned int  PlatformId;\r
-  unsigned int  DataSize;   // if 0, then TotalSize = 2048, and TotalSize field is invalid\r
-  unsigned int  TotalSize;  // number of bytes\r
-  unsigned int  Reserved[3];\r
-} MICROCODE_IMAGE_HEADER;\r
-\r
-static\r
-STATUS\r
-MicrocodeReadData (\r
-  FILE          *InFptr,\r
-  unsigned int  *Data\r
-  );\r
-\r
-void\r
-MicrocodeConstructor (\r
-  void\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Constructor of module Microcode\r
-\r
-Arguments:\r
-\r
-  None\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-{\r
-}\r
-\r
-void\r
-MicrocodeDestructor (\r
-  void\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Destructor of module Microcode\r
-\r
-Arguments:\r
-\r
-  None\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-{\r
-}\r
-\r
-static\r
-STATUS\r
-MicrocodeReadData (\r
-  FILE          *InFptr,\r
-  unsigned int  *Data\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Read a 32-bit microcode data value from a text file and convert to raw binary form.\r
-\r
-Arguments:\r
-  InFptr    - file pointer to input text file\r
-  Data      - pointer to where to return the data parsed\r
-\r
-Returns:\r
-  STATUS_SUCCESS    - no errors or warnings, Data contains valid information\r
-  STATUS_ERROR      - errors were encountered\r
-\r
---*/\r
-{\r
-  char  Line[MAX_LINE_LEN];\r
-  char  *cptr;\r
-\r
-  Line[MAX_LINE_LEN - 1]  = 0;\r
-  *Data                   = 0;\r
-  if (fgets (Line, MAX_LINE_LEN, InFptr) == NULL) {\r
-    return STATUS_ERROR;\r
-  }\r
-  //\r
-  // If it was a binary file, then it may have overwritten our null terminator\r
-  //\r
-  if (Line[MAX_LINE_LEN - 1] != 0) {\r
-    return STATUS_ERROR;\r
-  }\r
-  //\r
-  // Look for\r
-  // dd 000000001h ; comment\r
-  // dd XXXXXXXX\r
-  // DD  XXXXXXXXX\r
-  //  DD XXXXXXXXX\r
-  //\r
-  for (cptr = Line; *cptr && isspace(*cptr); cptr++) {\r
-  }\r
-  if ((tolower(cptr[0]) == 'd') && (tolower(cptr[1]) == 'd') && isspace (cptr[2])) {\r
-    //\r
-    // Skip blanks and look for a hex digit\r
-    //\r
-    cptr += 3;\r
-    for (; *cptr && isspace(*cptr); cptr++) {\r
-    }\r
-    if (isxdigit (*cptr)) {\r
-      if (sscanf (cptr, "%X", Data) != 1) {\r
-        return STATUS_ERROR;\r
-      }\r
-    }\r
-    return STATUS_SUCCESS;\r
-  }\r
-  return STATUS_ERROR;\r
-}\r
-\r
-STATUS\r
-MicrocodeParseFile (\r
-  char  *InFileName,\r
-  char  *OutFileName\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Parse a microcode text file, and write the binary results to an output file.\r
-\r
-Arguments:\r
-  InFileName  - input text file to parse\r
-  OutFileName - output file to write raw binary data from parsed input file\r
-\r
-Returns:\r
-  STATUS_SUCCESS    - no errors or warnings\r
-  STATUS_ERROR      - errors were encountered\r
-\r
---*/\r
-{\r
-  FILE                    *InFptr;\r
-  FILE                    *OutFptr;\r
-  STATUS                  Status;\r
-  MICROCODE_IMAGE_HEADER  *Header;\r
-  unsigned int            Size;\r
-  unsigned int            Size2;\r
-  unsigned int            Data;\r
-  unsigned int            Checksum;\r
-  char                    *Buffer;\r
-  char                    *Ptr;\r
-  unsigned int            TotalSize;\r
-\r
-  Status  = STATUS_ERROR;\r
-  InFptr  = NULL;\r
-  OutFptr = NULL;\r
-  Buffer  = NULL;\r
-  //\r
-  // Open the input text file\r
-  //\r
-  if ((InFptr = fopen (InFileName, "r")) == NULL) {\r
-    Error (NULL, 0, 0, InFileName, "failed to open input microcode file for reading");\r
-    return STATUS_ERROR;\r
-  }\r
-  //\r
-  // Make two passes on the input file. The first pass is to determine how\r
-  // much data is in the file so we can allocate a working buffer. Then\r
-  // we'll allocate a buffer and re-read the file into the buffer for processing.\r
-  //\r
-  Size = 0;\r
-  do {\r
-    Status = MicrocodeReadData (InFptr, &Data);\r
-    if (Status == STATUS_SUCCESS) {\r
-      Size += sizeof (Data);\r
-    }\r
-  } while (Status == STATUS_SUCCESS);\r
-  //\r
-  // Error if no data.\r
-  //\r
-  if (Size == 0) {\r
-    Error (NULL, 0, 0, InFileName, "no parse-able data found in file");\r
-    goto Done;\r
-  }\r
-  if (Size < sizeof (MICROCODE_IMAGE_HEADER)) {\r
-    Error (NULL, 0, 0, InFileName, "amount of parse-able data is insufficient to contain a microcode header");\r
-    goto Done;\r
-  }\r
-  //\r
-  // Allocate a buffer for the data\r
-  //\r
-  Buffer = (char *) _malloc (Size);\r
-  if (Buffer == NULL) {\r
-    Error (NULL, 0, 0, "memory allocation failure", NULL);\r
-    goto Done;\r
-  }\r
-  //\r
-  // Re-read the file, storing the data into our buffer\r
-  //\r
-  fseek (InFptr, 0, SEEK_SET);\r
-  Ptr = Buffer;\r
-  do {\r
-    Status = MicrocodeReadData (InFptr, &Data);\r
-    if (Status == STATUS_SUCCESS) {\r
-      *(unsigned int *) Ptr = Data;\r
-      Ptr += sizeof (Data);\r
-    }\r
-  } while (Status == STATUS_SUCCESS);\r
-  //\r
-  // Can't do much checking on the header because, per the spec, the\r
-  // DataSize field may be 0, which means DataSize = 2000 and TotalSize = 2K,\r
-  // and the TotalSize field is invalid (actually missing). Thus we can't\r
-  // even verify the Reserved fields are 0.\r
-  //\r
-  Header = (MICROCODE_IMAGE_HEADER *) Buffer;\r
-  if (Header->DataSize == 0) {\r
-    TotalSize = 2048;\r
-  } else {\r
-    TotalSize = Header->TotalSize;\r
-  }\r
-  if (TotalSize != Size) {\r
-    Error (NULL, 0, 0, InFileName, "file contents do not contain expected TotalSize 0x%04X", TotalSize);\r
-    goto Done;\r
-  }\r
-  //\r
-  // Checksum the contents\r
-  //\r
-  Ptr       = Buffer;\r
-  Checksum  = 0;\r
-  Size2     = 0;\r
-  while (Size2 < Size) {\r
-    Checksum += *(unsigned int *) Ptr;\r
-    Ptr += 4;\r
-    Size2 += 4;\r
-  }\r
-  if (Checksum != 0) {\r
-    Error (NULL, 0, 0, InFileName, "checksum failed on file contents");\r
-    goto Done;\r
-  }\r
-  //\r
-  // Open the output file and write the buffer contents\r
-  //\r
-  if ((OutFptr = fopen (OutFileName, "wb")) == NULL) {\r
-    Error (NULL, 0, 0, OutFileName, "failed to open output microcode file for writing");\r
-    goto Done;\r
-  }\r
-  if (fwrite (Buffer, Size, 1, OutFptr) != 1) {\r
-    Error (NULL, 0, 0, OutFileName, "failed to write microcode data to output file");\r
-    goto Done;\r
-  }\r
-  Status = STATUS_SUCCESS;\r
-Done:\r
-  if (Buffer != NULL) {\r
-    free (Buffer);\r
-  }\r
-  if (InFptr != NULL) {\r
-    fclose (InFptr);\r
-  }\r
-  if (OutFptr != NULL) {\r
-    fclose (OutFptr);\r
-    if (Status == STATUS_ERROR) {\r
-      remove (OutFileName);\r
-    }\r
-  }\r
-  return Status;\r
-}\r
diff --git a/Tools/CodeTools/TianoTools/FlashMap/Microcode.h b/Tools/CodeTools/TianoTools/FlashMap/Microcode.h
deleted file mode 100644 (file)
index f85313e..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-/*++\r
-\r
-Copyright (c)  2004-2006 Intel Corporation. All rights reserved\r
-This program and the accompanying materials are licensed and made available \r
-under the terms and conditions of the BSD License which accompanies this \r
-distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-Module Name:\r
-\r
-  Microcode.h\r
-\r
-Abstract:\r
-\r
-  Header file for flash management utility in the Intel Platform \r
-  Innovation Framework for EFI build environment.\r
-\r
---*/\r
-\r
-#ifndef _MICROCODE_H_\r
-#define _MICROCODE_H_\r
-\r
-void\r
-MicrocodeConstructor (\r
-  void\r
-  );\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Constructor of module Microcode\r
-\r
-Arguments:\r
-\r
-  None\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-\r
-void\r
-MicrocodeDestructor (\r
-  void\r
-  );\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Destructor of module Microcode\r
-\r
-Arguments:\r
-\r
-  None\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-\r
-STATUS\r
-MicrocodeParseFile (\r
-  char  *InFileName,\r
-  char  *OutFileName\r
-  );\r
-/*++\r
-\r
-Routine Description:\r
-  Parse a microcode text file, and write the binary results to an output file.\r
-\r
-Arguments:\r
-  InFileName  - input text file to parse\r
-  OutFileName - output file to write raw binary data from parsed input file\r
-\r
-Returns:\r
-  STATUS_SUCCESS    - no errors or warnings\r
-  STATUS_ERROR      - errors were encountered\r
-\r
---*/\r
-\r
-\r
-#endif // #ifndef _MICROCODE_H_\r
diff --git a/Tools/CodeTools/TianoTools/FlashMap/Symbols.c b/Tools/CodeTools/TianoTools/FlashMap/Symbols.c
deleted file mode 100644 (file)
index 8e40814..0000000
+++ /dev/null
@@ -1,648 +0,0 @@
-/*++\r
-\r
-Copyright (c)  2004-2006 Intel Corporation. All rights reserved\r
-This program and the accompanying materials are licensed and made available \r
-under the terms and conditions of the BSD License which accompanies this \r
-distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-Module Name:\r
-\r
-  Symbol.c\r
-\r
-Abstract:\r
-\r
-  Class-like implementation for a symbol table.\r
-\r
---*/\r
-\r
-// GC_TODO: fix comment to set correct module name: Symbols.c\r
-#include <stdio.h>\r
-#include <string.h>\r
-#include <stdlib.h>\r
-//\r
-// for isspace()\r
-//\r
-#include <ctype.h>\r
-\r
-#include <Common/UefiBaseTypes.h>\r
-\r
-#include "CommonLib.h"\r
-#include "EfiUtilityMsgs.h"\r
-#include "Symbols.h"\r
-\r
-#define MAX_LINE_LEN  512\r
-\r
-//\r
-// Linked list to keep track of all symbols\r
-//\r
-typedef struct _SYMBOL {\r
-  struct _SYMBOL  *Next;\r
-  int             Type;\r
-  char            *Name;\r
-  char            *Value;\r
-} SYMBOL;\r
-\r
-static\r
-SYMBOL        *\r
-FreeSymbols (\r
-  SYMBOL *Syms\r
-  );\r
-\r
-static\r
-int\r
-ExpandMacros (\r
-  char  *SourceLine,\r
-  char  *DestLine,\r
-  int   LineLen\r
-  );\r
-\r
-static SYMBOL *mSymbolTable = NULL;\r
-\r
-void\r
-SymbolsConstructor (\r
-  VOID\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  None\r
-\r
-Returns:\r
-\r
-  GC_TODO: add return values\r
-\r
---*/\r
-{\r
-  SymbolsDestructor ();\r
-}\r
-\r
-void\r
-SymbolsDestructor (\r
-  VOID\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  None\r
-\r
-Returns:\r
-\r
-  GC_TODO: add return values\r
-\r
---*/\r
-{\r
-  mSymbolTable = FreeSymbols (mSymbolTable);\r
-}\r
-\r
-char *\r
-GetSymbolValue (\r
-  char *SymbolName\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  \r
-  Look up a symbol in our symbol table.\r
-\r
-Arguments:\r
-\r
-  SymbolName\r
-\r
-Returns:\r
-\r
-  Pointer to the value of the symbol if found\r
-  NULL if the symbol is not found\r
-\r
---*/\r
-// GC_TODO:    SymbolName - add argument and description to function comment\r
-{\r
-  SYMBOL  *Symbol;\r
-  //\r
-  // Walk the symbol table\r
-  //\r
-  Symbol = mSymbolTable;\r
-  while (Symbol) {\r
-    if (stricmp (SymbolName, Symbol->Name) == 0) {\r
-      return Symbol->Value;\r
-    }\r
-\r
-    Symbol = Symbol->Next;\r
-  }\r
-\r
-  return NULL;\r
-}\r
-\r
-int\r
-SymbolAdd (\r
-  char    *Name,\r
-  char    *Value,\r
-  int     Mode\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  \r
-  Add a symbol name/value to the symbol table\r
-\r
-Arguments:\r
-\r
-  Name  - name of symbol to add\r
-  Value - value of symbol to add\r
-  Mode  - currrently unused\r
-\r
-Returns:\r
-\r
-  Length of symbol added.\r
-\r
-Notes:\r
-  If Value == NULL, then this routine will assume that the Name field\r
-  looks something like "MySymName = MySymValue", and will try to parse\r
-  it that way and add the symbol name/pair from the string.\r
-\r
---*/\r
-{\r
-  SYMBOL  *Symbol;\r
-\r
-  SYMBOL  *NewSymbol;\r
-  int     Len;\r
-  char    *Start;\r
-  char    *Cptr;\r
-  char    CSave;\r
-  char    *SaveCptr;\r
-\r
-  Len       = 0;\r
-  SaveCptr  = NULL;\r
-  CSave     = 0;\r
-  //\r
-  // If value pointer is null, then they passed us a line something like:\r
-  //    varname = value, or simply var =\r
-  //\r
-  if (Value == NULL) {\r
-    Start = Name;\r
-    while (*Name && isspace (*Name)) {\r
-      Name++;\r
-    }\r
-\r
-    if (Name == NULL) {\r
-      return -1;\r
-    }\r
-    //\r
-    // Find the end of the name. Either space or a '='.\r
-    //\r
-    for (Value = Name; *Value && !isspace (*Value) && (*Value != '='); Value++)\r
-      ;\r
-    if (Value == NULL) {\r
-      return -1;\r
-    }\r
-    //\r
-    // Look for the '='\r
-    //\r
-    Cptr = Value;\r
-    while (*Value && (*Value != '=')) {\r
-      Value++;\r
-    }\r
-\r
-    if (Value == NULL) {\r
-      return -1;\r
-    }\r
-    //\r
-    // Now truncate the name\r
-    //\r
-    *Cptr = 0;\r
-    //\r
-    // Skip over the = and then any spaces\r
-    //\r
-    Value++;\r
-    while (*Value && isspace (*Value)) {\r
-      Value++;\r
-\r
-    }\r
-    //\r
-    // Find end of string, checking for quoted string\r
-    //\r
-    if (*Value == '\"') {\r
-      Value++;\r
-      for (Cptr = Value; *Cptr && *Cptr != '\"'; Cptr++)\r
-        ;\r
-    } else {\r
-      for (Cptr = Value; *Cptr && !isspace (*Cptr); Cptr++)\r
-        ;\r
-    }\r
-    //\r
-    // Null terminate the value string\r
-    //\r
-    CSave     = *Cptr;\r
-    SaveCptr  = Cptr;\r
-    *Cptr     = 0;\r
-    Len       = (int) (Cptr - Start);\r
-  }\r
-  //\r
-  // We now have a symbol name and a value. Look for an existing variable\r
-  // and overwrite it.\r
-  //\r
-  Symbol = mSymbolTable;\r
-  while (Symbol) {\r
-    //\r
-    // Check for symbol name match\r
-    //\r
-    if (stricmp (Name, Symbol->Name) == 0) {\r
-      _free (Symbol->Value);\r
-      Symbol->Value = (char *) _malloc (strlen (Value) + 1);\r
-      if (Symbol->Value == NULL) {\r
-        Error (NULL, 0, 0, NULL, "failed to allocate memory");\r
-        return -1;\r
-      }\r
-\r
-      strcpy (Symbol->Value, Value);\r
-      //\r
-      // If value == "NULL", then make it a 0-length string\r
-      //\r
-      if (stricmp (Symbol->Value, "NULL") == 0) {\r
-        Symbol->Value[0] = 0;\r
-      }\r
-\r
-      return Len;\r
-    }\r
-\r
-    Symbol = Symbol->Next;\r
-  }\r
-  //\r
-  // Does not exist, create a new one\r
-  //\r
-  NewSymbol = (SYMBOL *) _malloc (sizeof (SYMBOL));\r
-  if (NewSymbol == NULL) {\r
-    Error (NULL, 0, 0, NULL, "memory allocation failure");\r
-    return -1;\r
-  }\r
-\r
-  memset ((char *) NewSymbol, 0, sizeof (SYMBOL));\r
-  NewSymbol->Name = (char *) _malloc (strlen (Name) + 1);\r
-  if (NewSymbol->Name == NULL) {\r
-    Error (NULL, 0, 0, NULL, "memory allocation failure");\r
-    _free (NewSymbol);\r
-    return -1;\r
-  }\r
-\r
-  NewSymbol->Value = (char *) _malloc (strlen (Value) + 1);\r
-  if (NewSymbol->Value == NULL) {\r
-    Error (NULL, 0, 0, NULL, "memory allocation failure");\r
-    _free (NewSymbol->Name);\r
-    _free (NewSymbol);\r
-    return -1;\r
-  }\r
-\r
-  strcpy (NewSymbol->Name, Name);\r
-  strcpy (NewSymbol->Value, Value);\r
-  //\r
-  // Remove trailing spaces\r
-  //\r
-  Cptr = NewSymbol->Value + strlen (NewSymbol->Value) - 1;\r
-  while (Cptr > NewSymbol->Value) {\r
-    if (isspace (*Cptr)) {\r
-      *Cptr = 0;\r
-      Cptr--;\r
-    } else {\r
-      break;\r
-    }\r
-  }\r
-  //\r
-  // Add it to the head of the list.\r
-  //\r
-  NewSymbol->Next = mSymbolTable;\r
-  mSymbolTable    = NewSymbol;\r
-  //\r
-  // If value == "NULL", then make it a 0-length string\r
-  //\r
-  if (stricmp (NewSymbol->Value, "NULL") == 0) {\r
-    NewSymbol->Value[0] = 0;\r
-  }\r
-  //\r
-  // Restore the terminator we inserted if they passed in var=value\r
-  //\r
-  if (SaveCptr != NULL) {\r
-    *SaveCptr = CSave;\r
-  }\r
-  _free (NewSymbol->Value);\r
-  _free (NewSymbol->Name);\r
-  _free (NewSymbol);\r
-  return Len;\r
-}\r
-\r
-static\r
-STATUS\r
-RemoveSymbol (\r
-  char *Name,\r
-  char SymbolType\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  \r
-  Remove a symbol name/value from the symbol table\r
-\r
-Arguments:\r
-\r
-  Name  - name of symbol to remove\r
-  SymbolType - type of symbol to remove\r
-\r
-Returns:\r
-\r
-  STATUS_SUCCESS - matching symbol found and removed\r
-  STATUS_ERROR   - matching symbol not found in symbol table\r
-\r
---*/\r
-{\r
-  SYMBOL  *Symbol;\r
-\r
-  SYMBOL  *PrevSymbol;\r
-\r
-  PrevSymbol  = NULL;\r
-  Symbol      = mSymbolTable;\r
-  //\r
-  // Walk the linked list of symbols in the symbol table looking\r
-  // for a match of both symbol name and type.\r
-  //\r
-  while (Symbol) {\r
-    if ((stricmp (Name, Symbol->Name) == 0) && (Symbol->Type & SymbolType)) {\r
-      //\r
-      // If the symbol has a value associated with it, free the memory\r
-      // allocated for the value.\r
-      // Then free the memory allocated for the symbols string name.\r
-      //\r
-      if (Symbol->Value) {\r
-        _free (Symbol->Value);\r
-      }\r
-\r
-      _free (Symbol->Name);\r
-      //\r
-      // Link the previous symbol to the next symbol to effectively\r
-      // remove this symbol from the linked list.\r
-      //\r
-      if (PrevSymbol) {\r
-        PrevSymbol->Next = Symbol->Next;\r
-      } else {\r
-        mSymbolTable = Symbol->Next;\r
-      }\r
-\r
-      _free (Symbol);\r
-      return STATUS_SUCCESS;\r
-    }\r
-\r
-    PrevSymbol  = Symbol;\r
-    Symbol      = Symbol->Next;\r
-  }\r
-\r
-  return STATUS_WARNING;\r
-}\r
-\r
-static\r
-SYMBOL *\r
-FreeSymbols (\r
-  SYMBOL *Syms\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  Syms  - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
-  GC_TODO: add return values\r
-\r
---*/\r
-{\r
-  SYMBOL  *Next;\r
-  while (Syms) {\r
-    if (Syms->Name != NULL) {\r
-      _free (Syms->Name);\r
-    }\r
-\r
-    if (Syms->Value != NULL) {\r
-      _free (Syms->Value);\r
-    }\r
-\r
-    Next = Syms->Next;\r
-    _free (Syms);\r
-    Syms = Next;\r
-  }\r
-\r
-  return Syms;\r
-}\r
-\r
-static\r
-int\r
-ExpandMacros (\r
-  char  *SourceLine,\r
-  char  *DestLine,\r
-  int   LineLen\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  \r
-  Given a line of text, replace all variables of format $(NAME) with values\r
-  from our symbol table.\r
-\r
-Arguments:\r
-\r
-  SourceLine    - input line of text to do symbol replacements on\r
-  DestLine      - on output, SourceLine with symbols replaced\r
-  LineLen       - length of DestLine, so we don't exceed its allocated length\r
-\r
-Returns:\r
-\r
-  STATUS_SUCCESS - no problems encountered\r
-  STATUS_WARNING - missing closing parenthesis on a symbol reference in SourceLine\r
-  STATUS_ERROR   - memory allocation failure\r
-\r
---*/\r
-{\r
-  static int  NestDepth = 0;\r
-  char        *FromPtr;\r
-  char        *ToPtr;\r
-  char        *SaveStart;\r
-  char        *Cptr;\r
-  char        *value;\r
-  int         Expanded;\r
-  int         ExpandedCount;\r
-  INT8        *LocalDestLine;\r
-  STATUS      Status;\r
-  int         LocalLineLen;\r
-\r
-  NestDepth++;\r
-  Status        = STATUS_SUCCESS;\r
-  LocalDestLine = (char *) _malloc (LineLen);\r
-  if (LocalDestLine == NULL) {\r
-    Error (__FILE__, __LINE__, 0, "memory allocation failed", NULL);\r
-    return STATUS_ERROR;\r
-  }\r
-\r
-  FromPtr = SourceLine;\r
-  ToPtr   = LocalDestLine;\r
-  //\r
-  // Walk the entire line, replacing $(MACRO_NAME).\r
-  //\r
-  LocalLineLen  = LineLen;\r
-  ExpandedCount = 0;\r
-  while (*FromPtr && (LocalLineLen > 0)) {\r
-    if ((*FromPtr == '$') && (*(FromPtr + 1) == '(')) {\r
-      //\r
-      // Save the start in case it's undefined, in which case we copy it as-is.\r
-      //\r
-      SaveStart = FromPtr;\r
-      Expanded  = 0;\r
-      //\r
-      // Macro expansion time. Find the end (no spaces allowed)\r
-      //\r
-      FromPtr += 2;\r
-      for (Cptr = FromPtr; *Cptr && (*Cptr != ')'); Cptr++)\r
-        ;\r
-      if (*Cptr) {\r
-        //\r
-        // Truncate the string at the closing parenthesis for ease-of-use.\r
-        // Then copy the string directly to the destination line in case we don't find\r
-        // a definition for it.\r
-        //\r
-        *Cptr = 0;\r
-        strcpy (ToPtr, SaveStart);\r
-        if ((value = GetSymbolValue (FromPtr)) != NULL) {\r
-          strcpy (ToPtr, value);\r
-          LocalLineLen -= strlen (value);\r
-          ToPtr += strlen (value);\r
-          Expanded = 1;\r
-          ExpandedCount++;\r
-        }\r
-\r
-        if (!Expanded) {\r
-          //\r
-          // Restore closing parenthesis, and advance to next character\r
-          //\r
-          *Cptr   = ')';\r
-          FromPtr = SaveStart + 1;\r
-          ToPtr++;\r
-        } else {\r
-          FromPtr = Cptr + 1;\r
-        }\r
-      } else {\r
-        Error (NULL, 0, 0, SourceLine, "missing closing parenthesis on macro");\r
-        strcpy (ToPtr, FromPtr);\r
-        Status = STATUS_WARNING;\r
-        goto Done;\r
-      }\r
-    } else {\r
-      *ToPtr = *FromPtr;\r
-      FromPtr++;\r
-      ToPtr++;\r
-      LocalLineLen--;\r
-    }\r
-  }\r
-\r
-  if (*FromPtr == 0) {\r
-    *ToPtr = 0;\r
-  }\r
-\r
-  //\r
-  // If we expanded at least one string successfully, then make a recursive call to try again.\r
-  //\r
-  if ((ExpandedCount != 0) && (Status == STATUS_SUCCESS) && (NestDepth < 10)) {\r
-    Status = ExpandMacros (LocalDestLine, DestLine, LineLen);\r
-    _free (LocalDestLine);\r
-    NestDepth = 0;\r
-    return Status;\r
-  }\r
-\r
-Done:\r
-  if (Status != STATUS_ERROR) {\r
-    strcpy (DestLine, LocalDestLine);\r
-  }\r
-\r
-  NestDepth = 0;\r
-  _free (LocalDestLine);\r
-  return Status;\r
-}\r
-\r
-STATUS\r
-SymbolsFileStringsReplace (\r
-  char    *InFileName,\r
-  char    *OutFileName\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  \r
-  Given input and output file names, read in the input file, replace variable\r
-  references of format $(NAME) with appropriate values from our symbol table,\r
-  and write the result out to the output file.\r
-\r
-Arguments:\r
-\r
-  InFileName  - name of input text file to replace variable references\r
-  OutFileName - name of output text file to write results to\r
-\r
-Returns:\r
-\r
-  STATUS_SUCCESS - no problems encountered\r
-  STATUS_ERROR   - failed to open input or output file\r
-\r
---*/\r
-{\r
-  STATUS  Status;\r
-  FILE    *InFptr;\r
-  FILE    *OutFptr;\r
-  char    Line[MAX_LINE_LEN];\r
-  char    OutLine[MAX_LINE_LEN];\r
-\r
-  Status = STATUS_ERROR;\r
-  //\r
-  // Open input and output files\r
-  //\r
-  InFptr  = NULL;\r
-  OutFptr = NULL;\r
-  if ((InFptr = fopen (InFileName, "r")) == NULL) {\r
-    Error (NULL, 0, 0, InFileName, "failed to open input file for reading");\r
-    goto Done;\r
-  }\r
-\r
-  if ((OutFptr = fopen (OutFileName, "w")) == NULL) {\r
-    Error (NULL, 0, 0, OutFileName, "failed to open output file for writing");\r
-    goto Done;\r
-  }\r
-  //\r
-  // Read lines from input file until done\r
-  //\r
-  while (fgets (Line, sizeof (Line), InFptr) != NULL) {\r
-    ExpandMacros (Line, OutLine, sizeof (OutLine));\r
-    fprintf (OutFptr, OutLine);\r
-  }\r
-\r
-  Status = STATUS_SUCCESS;\r
-Done:\r
-  if (InFptr != NULL) {\r
-    fclose (InFptr);\r
-  }\r
-\r
-  if (OutFptr != NULL) {\r
-    fclose (OutFptr);\r
-  }\r
-\r
-  return Status;\r
-}\r
diff --git a/Tools/CodeTools/TianoTools/FlashMap/Symbols.h b/Tools/CodeTools/TianoTools/FlashMap/Symbols.h
deleted file mode 100644 (file)
index a3cadff..0000000
+++ /dev/null
@@ -1,124 +0,0 @@
-/*++\r
-\r
-Copyright (c)  2004-2006 Intel Corporation. All rights reserved\r
-This program and the accompanying materials are licensed and made available \r
-under the terms and conditions of the BSD License which accompanies this \r
-distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-Module Name:\r
-\r
-  Symbols.h\r
-\r
-Abstract:\r
-\r
-  Defines and prototypes for a class-like symbol table service.\r
-\r
---*/\r
-\r
-#ifndef _SYMBOLS_H_\r
-#define _SYMBOLS_H_\r
-\r
-#ifdef __cplusplus\r
-extern "C"\r
-{\r
-#endif\r
-\r
-int\r
-SymbolAdd (\r
-  char    *Name,\r
-  char    *Value,\r
-  int     Mode\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  Name  - GC_TODO: add argument description\r
-  Value - GC_TODO: add argument description\r
-  Mode  - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
-  GC_TODO: add return values\r
-\r
---*/\r
-;\r
-\r
-STATUS\r
-SymbolsFileStringsReplace (\r
-  char    *InFileName,\r
-  char    *OutFileName\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  InFileName  - GC_TODO: add argument description\r
-  OutFileName - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
-  GC_TODO: add return values\r
-\r
---*/\r
-;\r
-\r
-void\r
-SymbolsConstructor (\r
-  VOID\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  None\r
-\r
-Returns:\r
-\r
-  GC_TODO: add return values\r
-\r
---*/\r
-;\r
-\r
-void\r
-SymbolsDestructor (\r
-  VOID\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  None\r
-\r
-Returns:\r
-\r
-  GC_TODO: add return values\r
-\r
---*/\r
-;\r
-\r
-#ifdef __cplusplus\r
-}\r
-#endif\r
-\r
-#endif // #ifndef _SYMBOLS_H_\r
diff --git a/Tools/CodeTools/TianoTools/FlashMap/build.xml b/Tools/CodeTools/TianoTools/FlashMap/build.xml
deleted file mode 100644 (file)
index 680c182..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-<?xml version="1.0" ?>\r
-<!--\r
-Copyright (c) 2006, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
--->\r
-<project default="GenTool" basedir=".">\r
-<!--\r
-    EDK FlashMap Tool\r
-  Copyright (c) 2006, Intel Corporation\r
--->\r
-  <property name="ToolName" value="FlashMap"/>\r
-  <property name="FileSet" value="*.c"/>\r
-\r
-  <taskdef resource="cpptasks.tasks"/>\r
-  <typedef resource="cpptasks.types"/>\r
-  <taskdef resource="net/sf/antcontrib/antlib.xml"/>\r
-\r
-  <property name="LINK_OUTPUT_TYPE" value="static"/>\r
-  <property name="BUILD_DIR" value="${PACKAGE_DIR}/${ToolName}/tmp"/>\r
-\r
-  <target name="GenTool" depends="init, Tool">\r
-    <echo message="The EDK Tool: ${ToolName} build has completed!"/>\r
-  </target>\r
-\r
-  <target name="init">\r
-    <echo message="Building the EDK Tool: ${ToolName}"/>\r
-    <mkdir dir="${BUILD_DIR}"/>\r
-  </target>\r
-\r
-  <target name="Tool" depends="init">\r
-    <cc name="${ToolChain}" objdir="${BUILD_DIR}" \r
-        outfile="${BIN_DIR}/${ToolName}"\r
-        outtype="executable"\r
-        optimize="speed" \r
-        debug="true">\r
-      <compilerarg value="${ExtraArgus}" if="ExtraArgus" />\r
-\r
-      <defineset>\r
-        <define name="_malloc" value="malloc"/>\r
-        <define name="_free" value="free"/>\r
-      </defineset>\r
-\r
-      <fileset dir="${basedir}/${ToolName}" \r
-        includes="${FileSet}" \r
-        defaultexcludes="TRUE" \r
-        excludes="*.xml *.inf"/>\r
-\r
-      <includepath path="${PACKAGE_DIR}/Include"/>\r
-      <includepath path="${PACKAGE_DIR}/Include/${HostArch}"/>\r
-      <includepath path="${PACKAGE_DIR}/Common"/>\r
-      <libset dir="${LIB_DIR}" libs="CommonTools"/>\r
-    </cc>\r
-  </target>\r
-\r
-  <target name="clean">\r
-    <echo message="Removing Intermediate Files Only"/>  \r
-    <delete>\r
-      <fileset dir="${BUILD_DIR}" includes="*.obj"/>\r
-    </delete>\r
-  </target>\r
-\r
-  <target name="cleanall">\r
-    <echo message="Removing Object Files and the Executable: ${ToolName}${ext_exe}"/>  \r
-    <delete failonerror="false" quiet="true" includeEmptyDirs="true">\r
-      <fileset dir="${BUILD_DIR}"/>\r
-      <fileset file="${BIN_DIR}/${ToolName}${ext_exe}"/>\r
-    </delete>\r
-  </target>\r
-\r
-</project>\r
diff --git a/Tools/CodeTools/TianoTools/FwImage/build.xml b/Tools/CodeTools/TianoTools/FwImage/build.xml
deleted file mode 100644 (file)
index b52c576..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-<?xml version="1.0" ?>\r
-<!--\r
-Copyright (c) 2006, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
--->\r
-<project default="GenTool" basedir=".">\r
-<!--\r
-    EDK FwImage Tool\r
-  Copyright (c) 2006, Intel Corporation\r
--->\r
-  <property name="ToolName" value="FwImage"/>\r
-  <property name="FileSet" value="fwimage.c"/>\r
-\r
-  <taskdef resource="cpptasks.tasks"/>\r
-  <typedef resource="cpptasks.types"/>\r
-  <taskdef resource="net/sf/antcontrib/antlib.xml"/>\r
-\r
-  <property name="LINK_OUTPUT_TYPE" value="static"/>\r
-  <property name="BUILD_DIR" value="${PACKAGE_DIR}/${ToolName}/tmp"/>\r
-\r
-  <target name="GenTool" depends="init, Tool">\r
-    <echo message="The EDK Tool: ${ToolName} build has completed!"/>\r
-  </target>\r
-\r
-  <target name="init">\r
-    <echo message="Building the EDK Tool: ${ToolName}"/>\r
-    <mkdir dir="${BUILD_DIR}"/>\r
-  </target>\r
-\r
-  <target name="Tool" depends="init">\r
-    <cc name="${ToolChain}" objdir="${BUILD_DIR}" \r
-        outfile="${BIN_DIR}/${ToolName}"\r
-        outtype="executable"\r
-        debug="true"\r
-        optimize="speed">\r
-      <compilerarg value="${ExtraArgus}" if="ExtraArgus" />\r
-\r
-      <fileset dir="${basedir}/${ToolName}" \r
-        includes="${FileSet}" \r
-        defaultexcludes="TRUE" \r
-        excludes="*.xml *.inf"/>\r
-\r
-      <includepath path="${PACKAGE_DIR}/Include"/>\r
-      <includepath path="${PACKAGE_DIR}/Include/${HostArch}"/>\r
-      <includepath path="${PACKAGE_DIR}/Common"/>\r
-      <libset dir="${LIB_DIR}" libs="CommonTools"/>\r
-    </cc>\r
-  </target>\r
-\r
-  <target name="clean">\r
-    <echo message="Removing Intermediate Files Only"/>  \r
-    <delete>\r
-      <fileset dir="${BUILD_DIR}" includes="*.obj"/>\r
-    </delete>\r
-  </target>\r
-\r
-  <target name="cleanall">\r
-    <echo message="Removing Object Files and the Executable: ${ToolName}${ext_exe}"/>  \r
-    <delete failonerror="false" quiet="true" includeEmptyDirs="true">\r
-      <fileset dir="${BUILD_DIR}"/>\r
-      <fileset file="${BIN_DIR}/${ToolName}${ext_exe}"/>\r
-    </delete>\r
-  </target>\r
-\r
-</project>\r
diff --git a/Tools/CodeTools/TianoTools/FwImage/fwimage.c b/Tools/CodeTools/TianoTools/FwImage/fwimage.c
deleted file mode 100644 (file)
index 5dd1634..0000000
+++ /dev/null
@@ -1,510 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2004, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-Module Name:\r
-\r
-    fwimage.c\r
-\r
-Abstract:\r
-\r
-    Converts a pe32+ image to an FW image type\r
-\r
---*/\r
-\r
-#include "WinNtInclude.h"\r
-\r
-#ifndef __GNUC__\r
-#include <windows.h>\r
-#endif\r
-#include <stdio.h>\r
-#include <stdlib.h>\r
-#include <string.h>\r
-#include <time.h>\r
-\r
-#include <Common/UefiBaseTypes.h>\r
-#include <Common/EfiImage.h>\r
-\r
-#include "CommonLib.h"\r
-#include "EfiUtilityMsgs.c"\r
-\r
-#define UTILITY_NAME  "FwImage"\r
-\r
-#ifdef __GNUC__\r
-typedef unsigned long ULONG;\r
-typedef unsigned char UCHAR;\r
-typedef unsigned char *PUCHAR;\r
-typedef unsigned short USHORT;\r
-#endif\r
-\r
-VOID\r
-Usage (\r
-  VOID\r
-  )\r
-{\r
-  printf ("Usage: " UTILITY_NAME "  {-t time-date} [BASE|SEC|PEI_CORE|PEIM|DXE_CORE|DXE_DRIVER|DXE_RUNTIME_DRIVER|DXE_SAL_DRIVER|DXE_SMM_DRIVER|TOOL|UEFI_DRIVER|UEFI_APPLICATION|USER_DEFINED] peimage [outimage]");\r
-}\r
-\r
-static\r
-STATUS\r
-FCopyFile (\r
-  FILE    *in,\r
-  FILE    *out\r
-  )\r
-{\r
-  ULONG filesize;\r
-  ULONG offset;\r
-  ULONG length;\r
-  UCHAR Buffer[8 * 1024];\r
-\r
-  fseek (in, 0, SEEK_END);\r
-  filesize = ftell (in);\r
-\r
-  fseek (in, 0, SEEK_SET);\r
-  fseek (out, 0, SEEK_SET);\r
-\r
-  offset = 0;\r
-  while (offset < filesize) {\r
-    length = sizeof (Buffer);\r
-    if (filesize - offset < length) {\r
-      length = filesize - offset;\r
-    }\r
-\r
-    fread (Buffer, length, 1, in);\r
-    fwrite (Buffer, length, 1, out);\r
-    offset += length;\r
-  }\r
-\r
-  if ((ULONG) ftell (out) != filesize) {\r
-    Error (NULL, 0, 0, "write error", NULL);\r
-    return STATUS_ERROR;\r
-  }\r
-\r
-  return STATUS_SUCCESS;\r
-}\r
-\r
-static\r
-STATUS\r
-FReadFile (\r
-  FILE    *in,\r
-  VOID    **Buffer,\r
-  UINTN   *Length\r
-  )\r
-{\r
-  fseek (in, 0, SEEK_END);\r
-  *Length = ftell (in);\r
-  *Buffer = malloc (*Length);\r
-  fseek (in, 0, SEEK_SET);\r
-  fread (*Buffer, *Length, 1, in);\r
-  return STATUS_SUCCESS;\r
-}\r
-\r
-static\r
-STATUS\r
-FWriteFile (\r
-  FILE    *out,\r
-  VOID    *Buffer,\r
-  UINTN   Length\r
-  )\r
-{\r
-  fseek (out, 0, SEEK_SET);\r
-  fwrite (Buffer, Length, 1, out);\r
-  if ((ULONG) ftell (out) != Length) {\r
-    Error (NULL, 0, 0, "write error", NULL);\r
-    return STATUS_ERROR;\r
-  }\r
-  free (Buffer);\r
-  return STATUS_SUCCESS;\r
-}\r
-\r
-int\r
-main (\r
-  int  argc,\r
-  char *argv[]\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Main function.\r
-\r
-Arguments:\r
-\r
-  argc - Number of command line parameters.\r
-  argv - Array of pointers to command line parameter strings.\r
-\r
-Returns:\r
-  STATUS_SUCCESS - Utility exits successfully.\r
-  STATUS_ERROR   - Some error occurred during execution.\r
-\r
---*/\r
-{\r
-  ULONG             Type;\r
-  PUCHAR            Ext;\r
-  PUCHAR            p;\r
-  PUCHAR            pe;\r
-  PUCHAR            OutImageName;\r
-  UCHAR             outname[500];\r
-  FILE              *fpIn;\r
-  FILE              *fpOut;\r
-  VOID              *ZeroBuffer;\r
-  EFI_IMAGE_DOS_HEADER  *DosHdr;\r
-  EFI_IMAGE_NT_HEADERS  *PeHdr;\r
-  EFI_IMAGE_OPTIONAL_HEADER32  *Optional32;\r
-  EFI_IMAGE_OPTIONAL_HEADER64  *Optional64;\r
-  time_t            TimeStamp;\r
-  struct tm         TimeStruct;\r
-  EFI_IMAGE_DOS_HEADER  BackupDosHdr;\r
-  ULONG             Index;\r
-  ULONG             Index1;\r
-  ULONG             Index2;\r
-  ULONG             Index3;\r
-  BOOLEAN           TimeStampPresent;\r
-  UINTN                                 AllignedRelocSize;\r
-  UINTN                                 Delta;\r
-  EFI_IMAGE_SECTION_HEADER              *SectionHeader;\r
-  UINT8      *FileBuffer;\r
-  UINTN      FileLength;\r
-  RUNTIME_FUNCTION  *RuntimeFunction;\r
-  UNWIND_INFO       *UnwindInfo;\r
-\r
-  SetUtilityName (UTILITY_NAME);\r
-  //\r
-  // Assign to fix compile warning\r
-  //\r
-  OutImageName      = NULL;\r
-  Type              = 0;\r
-  Ext               = 0;\r
-  TimeStamp         = 0;\r
-  TimeStampPresent  = FALSE;\r
-\r
-  //\r
-  // Look for -t time-date option first. If the time is "0", then\r
-  // skip it.\r
-  //\r
-  if ((argc > 2) && !strcmp (argv[1], "-t")) {\r
-    TimeStampPresent = TRUE;\r
-    if (strcmp (argv[2], "0") != 0) {\r
-      //\r
-      // Convert the string to a value\r
-      //\r
-      memset ((char *) &TimeStruct, 0, sizeof (TimeStruct));\r
-      if (sscanf(\r
-          argv[2], "%d/%d/%d,%d:%d:%d",\r
-          &TimeStruct.tm_mon,   /* months since January - [0,11] */\r
-          &TimeStruct.tm_mday,  /* day of the month - [1,31] */\r
-          &TimeStruct.tm_year,  /* years since 1900 */\r
-          &TimeStruct.tm_hour,  /* hours since midnight - [0,23] */\r
-          &TimeStruct.tm_min,   /* minutes after the hour - [0,59] */\r
-          &TimeStruct.tm_sec    /* seconds after the minute - [0,59] */\r
-            ) != 6) {\r
-        Error (NULL, 0, 0, argv[2], "failed to convert to mm/dd/yyyy,hh:mm:ss format");\r
-        return STATUS_ERROR;\r
-      }\r
-      //\r
-      // Now fixup some of the fields\r
-      //\r
-      TimeStruct.tm_mon--;\r
-      TimeStruct.tm_year -= 1900;\r
-      //\r
-      // Sanity-check values?\r
-      // Convert\r
-      //\r
-      TimeStamp = mktime (&TimeStruct);\r
-      if (TimeStamp == (time_t) - 1) {\r
-        Error (NULL, 0, 0, argv[2], "failed to convert time");\r
-        return STATUS_ERROR;\r
-      }\r
-    }\r
-    //\r
-    // Skip over the args\r
-    //\r
-    argc -= 2;\r
-    argv += 2;\r
-  }\r
-  //\r
-  // Check for enough args\r
-  //\r
-  if (argc < 3) {\r
-    Usage ();\r
-    return STATUS_ERROR;\r
-  }\r
-\r
-  if (argc == 4) {\r
-    OutImageName = argv[3];\r
-  }\r
-  //\r
-  // Get new image type\r
-  //\r
-  p = argv[1];\r
-  if (*p == '/' || *p == '\\') {\r
-    p += 1;\r
-  }\r
-\r
-  if (stricmp (p, "app") == 0 || stricmp (p, "UEFI_APPLICATION") == 0) {\r
-    Type  = EFI_IMAGE_SUBSYSTEM_EFI_APPLICATION;\r
-    Ext   = ".efi";\r
-\r
-  } else if (stricmp (p, "bsdrv") == 0 || stricmp (p, "DXE_DRIVER") == 0) {\r
-    Type  = EFI_IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER;\r
-    Ext   = ".efi";\r
-\r
-  } else if (stricmp (p, "rtdrv") == 0 || stricmp (p, "DXE_RUNTIME_DRIVER") == 0) {\r
-    Type  = EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER;\r
-    Ext   = ".efi";\r
-\r
-  } else if (stricmp (p, "rtdrv") == 0 || stricmp (p, "DXE_SAL_DRIVER") == 0) {\r
-    Type  = EFI_IMAGE_SUBSYSTEM_SAL_RUNTIME_DRIVER;\r
-    Ext   = ".efi";\r
-  } else if (stricmp (p, "SEC") == 0) {\r
-    Type  = EFI_IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER;\r
-    Ext   = ".sec";\r
-  } else if (stricmp (p, "peim") == 0 ||\r
-           stricmp (p, "BASE") == 0 ||\r
-           stricmp (p, "PEI_CORE") == 0 ||\r
-           stricmp (p, "PEIM") == 0 ||\r
-           stricmp (p, "DXE_SMM_DRIVER") == 0 ||\r
-           stricmp (p, "TOOL") == 0 ||\r
-           stricmp (p, "UEFI_APPLICATION") == 0 ||\r
-           stricmp (p, "USER_DEFINED") == 0 ||\r
-           stricmp (p, "UEFI_DRIVER") == 0 ||\r
-           stricmp (p, "DXE_CORE") == 0\r
-          ) {\r
-    Type  = EFI_IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER;\r
-    Ext   = ".pei";\r
-  } else {\r
-       printf ("%s", p);\r
-    Usage ();\r
-    return STATUS_ERROR;\r
-  }\r
-  //\r
-  // open source file\r
-  //\r
-  fpIn = fopen (argv[2], "rb");\r
-  if (!fpIn) {\r
-    Error (NULL, 0, 0, argv[2], "failed to open input file for reading");\r
-    return STATUS_ERROR;\r
-  }\r
-\r
-  FReadFile (fpIn, (VOID **)&FileBuffer, &FileLength);\r
-\r
-  //\r
-  // Read the dos & pe hdrs of the image\r
-  //\r
-  DosHdr = (EFI_IMAGE_DOS_HEADER *)FileBuffer;\r
-  if (DosHdr->e_magic != EFI_IMAGE_DOS_SIGNATURE) {\r
-    Error (NULL, 0, 0, argv[2], "DOS header signature not found in source image");\r
-    fclose (fpIn);\r
-    return STATUS_ERROR;\r
-  }\r
-\r
-  PeHdr = (EFI_IMAGE_NT_HEADERS *)(FileBuffer + DosHdr->e_lfanew);\r
-  if (PeHdr->Signature != EFI_IMAGE_NT_SIGNATURE) {\r
-    Error (NULL, 0, 0, argv[2], "PE header signature not found in source image");\r
-    fclose (fpIn);\r
-    return STATUS_ERROR;\r
-  }\r
-\r
-  //\r
-  // open output file\r
-  //\r
-  strcpy (outname, argv[2]);\r
-  pe = NULL;\r
-  for (p = outname; *p; p++) {\r
-    if (*p == '.') {\r
-      pe = p;\r
-    }\r
-  }\r
-\r
-  if (!pe) {\r
-    pe = p;\r
-  }\r
-\r
-  strcpy (pe, Ext);\r
-\r
-  if (!OutImageName) {\r
-    OutImageName = outname;\r
-  }\r
-\r
-  fpOut = fopen (OutImageName, "w+b");\r
-  if (!fpOut) {\r
-    Error (NULL, 0, 0, OutImageName, "could not open output file for writing");\r
-    fclose (fpIn);\r
-    return STATUS_ERROR;\r
-  }\r
-\r
-  //\r
-  // Zero all unused fields of the DOS header\r
-  //\r
-  memcpy (&BackupDosHdr, DosHdr, sizeof (EFI_IMAGE_DOS_HEADER));\r
-  memset (DosHdr, 0, sizeof (EFI_IMAGE_DOS_HEADER));\r
-  DosHdr->e_magic  = BackupDosHdr.e_magic;\r
-  DosHdr->e_lfanew = BackupDosHdr.e_lfanew;\r
-\r
-  for (Index = sizeof (EFI_IMAGE_DOS_HEADER); Index < (ULONG) DosHdr->e_lfanew; Index++) {\r
-    FileBuffer[Index] = DosHdr->e_cp;\r
-  }\r
-\r
-  //\r
-  // Path the PE header\r
-  //\r
-  PeHdr->OptionalHeader.Subsystem = (USHORT) Type;\r
-  if (TimeStampPresent) {\r
-    PeHdr->FileHeader.TimeDateStamp = (UINT32) TimeStamp;\r
-  }\r
-\r
-  if (PeHdr->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {\r
-    Optional32 = (EFI_IMAGE_OPTIONAL_HEADER32 *)&PeHdr->OptionalHeader;\r
-    Optional32->MajorLinkerVersion          = 0;\r
-    Optional32->MinorLinkerVersion          = 0;\r
-    Optional32->MajorOperatingSystemVersion = 0;\r
-    Optional32->MinorOperatingSystemVersion = 0;\r
-    Optional32->MajorImageVersion           = 0;\r
-    Optional32->MinorImageVersion           = 0;\r
-    Optional32->MajorSubsystemVersion       = 0;\r
-    Optional32->MinorSubsystemVersion       = 0;\r
-    Optional32->Win32VersionValue           = 0;\r
-    Optional32->CheckSum                    = 0;\r
-    Optional32->SizeOfStackReserve = 0;\r
-    Optional32->SizeOfStackCommit  = 0;\r
-    Optional32->SizeOfHeapReserve  = 0;\r
-    Optional32->SizeOfHeapCommit   = 0;\r
-\r
-    //\r
-    // Strip zero padding at the end of the .reloc section \r
-    //\r
-    if (Optional32->NumberOfRvaAndSizes >= 6) {\r
-      if (Optional32->DataDirectory[5].Size != 0) {\r
-        SectionHeader = (EFI_IMAGE_SECTION_HEADER *)(FileBuffer + DosHdr->e_lfanew + sizeof(UINT32) + sizeof (EFI_IMAGE_FILE_HEADER) + PeHdr->FileHeader.SizeOfOptionalHeader);\r
-        for (Index = 0; Index < PeHdr->FileHeader.NumberOfSections; Index++, SectionHeader++) {\r
-          //\r
-          // Look for the Section Header that starts as the same virtual address as the Base Relocation Data Directory\r
-          //\r
-          if (SectionHeader->VirtualAddress == Optional32->DataDirectory[5].VirtualAddress) {\r
-            SectionHeader->Misc.VirtualSize = Optional32->DataDirectory[5].Size;\r
-            AllignedRelocSize = (Optional32->DataDirectory[5].Size + Optional32->FileAlignment - 1) & (~(Optional32->FileAlignment - 1));\r
-            //\r
-            // Check to see if there is zero padding at the end of the base relocations\r
-            //\r
-            if (AllignedRelocSize < SectionHeader->SizeOfRawData) {\r
-              //\r
-              // Check to see if the base relocations are at the end of the file\r
-              //\r
-              if (SectionHeader->PointerToRawData + SectionHeader->SizeOfRawData == Optional32->SizeOfImage) {\r
-                //\r
-                // All the required conditions are met to strip the zero padding of the end of the base relocations section\r
-                //\r
-                Optional32->SizeOfImage -= (SectionHeader->SizeOfRawData - AllignedRelocSize);\r
-                Optional32->SizeOfInitializedData -= (SectionHeader->SizeOfRawData - AllignedRelocSize);\r
-                SectionHeader->SizeOfRawData = AllignedRelocSize;\r
-                FileLength = Optional32->SizeOfImage;\r
-              }\r
-            }\r
-          }\r
-        }\r
-      }\r
-    }\r
-  } \r
-  if (PeHdr->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC) {\r
-    Optional64 = (EFI_IMAGE_OPTIONAL_HEADER64 *)&PeHdr->OptionalHeader;\r
-    Optional64->MajorLinkerVersion          = 0;\r
-    Optional64->MinorLinkerVersion          = 0;\r
-    Optional64->MajorOperatingSystemVersion = 0;\r
-    Optional64->MinorOperatingSystemVersion = 0;\r
-    Optional64->MajorImageVersion           = 0;\r
-    Optional64->MinorImageVersion           = 0;\r
-    Optional64->MajorSubsystemVersion       = 0;\r
-    Optional64->MinorSubsystemVersion       = 0;\r
-    Optional64->Win32VersionValue           = 0;\r
-    Optional64->CheckSum                    = 0;\r
-    Optional64->SizeOfStackReserve = 0;\r
-    Optional64->SizeOfStackCommit  = 0;\r
-    Optional64->SizeOfHeapReserve  = 0;\r
-    Optional64->SizeOfHeapCommit   = 0;\r
-\r
-    //\r
-    // Zero the .pdata section if the machine type is X64 and the Debug Directory is empty\r
-    //\r
-    if (PeHdr->FileHeader.Machine == 0x8664) { // X64\r
-      if (Optional64->NumberOfRvaAndSizes >= 4) {\r
-        if (Optional64->NumberOfRvaAndSizes < 7 || (Optional64->NumberOfRvaAndSizes >= 7 && Optional64->DataDirectory[6].Size == 0)) {\r
-          SectionHeader = (EFI_IMAGE_SECTION_HEADER *)(FileBuffer + DosHdr->e_lfanew + sizeof(UINT32) + sizeof (EFI_IMAGE_FILE_HEADER) + PeHdr->FileHeader.SizeOfOptionalHeader);\r
-          for (Index = 0; Index < PeHdr->FileHeader.NumberOfSections; Index++, SectionHeader++) {\r
-            if (SectionHeader->VirtualAddress == Optional64->DataDirectory[3].VirtualAddress) {\r
-              RuntimeFunction = (RUNTIME_FUNCTION *)(FileBuffer + SectionHeader->PointerToRawData);\r
-              for (Index1 = 0; Index1 < Optional64->DataDirectory[3].Size / sizeof (RUNTIME_FUNCTION); Index1++, RuntimeFunction++) {\r
-                SectionHeader = (EFI_IMAGE_SECTION_HEADER *)(FileBuffer + DosHdr->e_lfanew + sizeof(UINT32) + sizeof (EFI_IMAGE_FILE_HEADER) + PeHdr->FileHeader.SizeOfOptionalHeader);\r
-                for (Index2 = 0; Index2 < PeHdr->FileHeader.NumberOfSections; Index2++, SectionHeader++) {\r
-                  if (RuntimeFunction->UnwindInfoAddress > SectionHeader->VirtualAddress && RuntimeFunction->UnwindInfoAddress < (SectionHeader->VirtualAddress + SectionHeader->SizeOfRawData)) {\r
-                    UnwindInfo = (UNWIND_INFO *)(FileBuffer + SectionHeader->PointerToRawData + (RuntimeFunction->UnwindInfoAddress - SectionHeader->VirtualAddress));\r
-                    if (UnwindInfo->Version == 1) {\r
-                      memset (UnwindInfo + 1, 0, UnwindInfo->CountOfUnwindCodes * sizeof (UINT16));\r
-                      memset (UnwindInfo, 0, sizeof (UNWIND_INFO));\r
-                    }\r
-                  }\r
-                }\r
-                memset (RuntimeFunction, 0, sizeof (RUNTIME_FUNCTION));\r
-              }\r
-            }\r
-          }\r
-          Optional64->DataDirectory[3].Size = 0;\r
-          Optional64->DataDirectory[3].VirtualAddress = 0;\r
-        }\r
-      }\r
-    }\r
-\r
-    //\r
-    // Strip zero padding at the end of the .reloc section \r
-    //\r
-    if (Optional64->NumberOfRvaAndSizes >= 6) {\r
-      if (Optional64->DataDirectory[5].Size != 0) {\r
-        SectionHeader = (EFI_IMAGE_SECTION_HEADER *)(FileBuffer + DosHdr->e_lfanew + sizeof(UINT32) + sizeof (EFI_IMAGE_FILE_HEADER) + PeHdr->FileHeader.SizeOfOptionalHeader);\r
-        for (Index = 0; Index < PeHdr->FileHeader.NumberOfSections; Index++, SectionHeader++) {\r
-          //\r
-          // Look for the Section Header that starts as the same virtual address as the Base Relocation Data Directory\r
-          //\r
-          if (SectionHeader->VirtualAddress == Optional64->DataDirectory[5].VirtualAddress) {\r
-            SectionHeader->Misc.VirtualSize = Optional64->DataDirectory[5].Size;\r
-            AllignedRelocSize = (Optional64->DataDirectory[5].Size + Optional64->FileAlignment - 1) & (~(Optional64->FileAlignment - 1));\r
-            //\r
-            // Check to see if there is zero padding at the end of the base relocations\r
-            //\r
-            if (AllignedRelocSize < SectionHeader->SizeOfRawData) {\r
-              //\r
-              // Check to see if the base relocations are at the end of the file\r
-              //\r
-              if (SectionHeader->PointerToRawData + SectionHeader->SizeOfRawData == Optional64->SizeOfImage) {\r
-                //\r
-                // All the required conditions are met to strip the zero padding of the end of the base relocations section\r
-                //\r
-                Optional64->SizeOfImage -= (SectionHeader->SizeOfRawData - AllignedRelocSize);\r
-                Optional64->SizeOfInitializedData -= (SectionHeader->SizeOfRawData - AllignedRelocSize);\r
-                SectionHeader->SizeOfRawData = AllignedRelocSize;\r
-                FileLength = Optional64->SizeOfImage;\r
-              }\r
-            }\r
-          }\r
-        }\r
-      }\r
-    }\r
-  }\r
-\r
-  FWriteFile (fpOut, FileBuffer, FileLength);\r
-\r
-  //\r
-  // Done\r
-  //\r
-  fclose (fpIn);\r
-  fclose (fpOut);\r
-  //\r
-  // printf ("Created %s\n", OutImageName);\r
-  //\r
-  return STATUS_SUCCESS;\r
-}\r
diff --git a/Tools/CodeTools/TianoTools/GenAcpiTable/GenAcpiTable.c b/Tools/CodeTools/TianoTools/GenAcpiTable/GenAcpiTable.c
deleted file mode 100644 (file)
index 7a413ea..0000000
+++ /dev/null
@@ -1,544 +0,0 @@
-/*++\r
-\r
-Copyright (c)  2004-2006 Intel Corporation. All rights reserved\r
-This program and the accompanying materials are licensed and made available \r
-under the terms and conditions of the BSD License which accompanies this \r
-distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-Module Name:\r
-\r
-  GenAcpiTable.c\r
-  \r
-Abstract:\r
-\r
-  A utility that extracts the .DATA section from a PE/COFF image.\r
-\r
---*/\r
-\r
-#include <stdio.h>\r
-#include <string.h>\r
-#include <stdlib.h>\r
-\r
-#include <Common/UefiBaseTypes.h>\r
-#include <Common/EfiImage.h> // for PE32 structure definitions\r
-\r
-#include "CommonLib.h"\r
-#include "EfiUtilityMsgs.h"\r
-\r
-//\r
-// Version of this utility\r
-//\r
-#define UTILITY_NAME    "GenAcpiTable"\r
-#define UTILITY_VERSION "v0.11"\r
-\r
-//\r
-// Define the max length of a filename\r
-//\r
-#define MAX_PATH                  256\r
-#define DEFAULT_OUTPUT_EXTENSION  ".acpi"\r
-\r
-//\r
-// Use this to track our command-line options and globals\r
-//\r
-struct {\r
-  INT8  OutFileName[MAX_PATH];\r
-  INT8  InFileName[MAX_PATH];\r
-} mOptions;\r
-\r
-//\r
-// Use these to convert from machine type value to a named type\r
-//\r
-typedef struct {\r
-  UINT16  Value;\r
-  INT8    *Name;\r
-} STRING_LOOKUP;\r
-\r
-static STRING_LOOKUP  mMachineTypes[] = {\r
-  EFI_IMAGE_MACHINE_IA32,\r
-  "IA32",\r
-  EFI_IMAGE_MACHINE_IA64,\r
-  "IA64",\r
-  EFI_IMAGE_MACHINE_EBC,\r
-  "EBC",\r
-  0,\r
-  NULL\r
-};\r
-\r
-static STRING_LOOKUP  mSubsystemTypes[] = {\r
-  EFI_IMAGE_SUBSYSTEM_EFI_APPLICATION,\r
-  "EFI application",\r
-  EFI_IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER,\r
-  "EFI boot service driver",\r
-  EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER,\r
-  "EFI runtime driver",\r
-  0,\r
-  NULL\r
-};\r
-//\r
-//  Function prototypes\r
-//\r
-static\r
-void\r
-Usage (\r
-  VOID\r
-  );\r
-\r
-static\r
-STATUS\r
-ParseCommandLine (\r
-  int       Argc,\r
-  char      *Argv[]\r
-  );\r
-\r
-static\r
-STATUS\r
-CheckPE32File (\r
-  INT8      *FileName,\r
-  FILE      *Fptr,\r
-  UINT16    *MachineType,\r
-  UINT16    *SubSystem\r
-  );\r
-\r
-static\r
-STATUS\r
-ProcessFile (\r
-  INT8      *InFileName,\r
-  INT8      *OutFileName\r
-  );\r
-\r
-static\r
-void\r
-DumpImage (\r
-  INT8      *FileName\r
-  );\r
-\r
-main (\r
-  int   Argc,\r
-  char  *Argv[]\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  \r
-\r
-Arguments:\r
-\r
-  Argc            - standard C main() argument count\r
-\r
-  Argv            - standard C main() argument list\r
-\r
-Returns:\r
-\r
-  0             success\r
-  non-zero      otherwise\r
-\r
---*/\r
-// GC_TODO:    ] - add argument and description to function comment\r
-{\r
-  UINT32  Status;\r
-\r
-  SetUtilityName (UTILITY_NAME);\r
-  //\r
-  // Parse the command line arguments\r
-  //\r
-  if (ParseCommandLine (Argc, Argv)) {\r
-    return STATUS_ERROR;\r
-  }\r
-  //\r
-  // Make sure we don't have the same filename for input and output files\r
-  //\r
-  if (stricmp (mOptions.OutFileName, mOptions.InFileName) == 0) {\r
-    Error (NULL, 0, 0, mOptions.OutFileName, "input and output file names must be different");\r
-    goto Finish;\r
-  }\r
-  //\r
-  // Process the file\r
-  //\r
-  ProcessFile (mOptions.InFileName, mOptions.OutFileName);\r
-Finish:\r
-  Status = GetUtilityStatus ();\r
-  return Status;\r
-}\r
-\r
-static\r
-STATUS\r
-ProcessFile (\r
-  INT8      *InFileName,\r
-  INT8      *OutFileName\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  \r
-  Process a PE32 EFI file.\r
-\r
-Arguments:\r
-\r
-  InFileName - Name of the PE32 EFI file to process.\r
-  OutFileName - Name of the output file for the processed data.\r
-\r
-Returns:\r
-\r
-  0 - successful\r
-\r
---*/\r
-{\r
-  STATUS                      Status;\r
-  UINTN                       Index;\r
-  FILE                        *InFptr;\r
-  FILE                        *OutFptr;\r
-  UINT16                      MachineType;\r
-  UINT16                      SubSystem;\r
-  UINT32                      PESigOffset;\r
-  EFI_IMAGE_FILE_HEADER       FileHeader;\r
-  EFI_IMAGE_OPTIONAL_HEADER32 OptionalHeader32;\r
-  EFI_IMAGE_OPTIONAL_HEADER64 OptionalHeader64;\r
-  EFI_IMAGE_SECTION_HEADER    SectionHeader;\r
-  UINT8                       *Buffer;\r
-  long                        SaveFilePosition;\r
-\r
-  InFptr  = NULL;\r
-  OutFptr = NULL;\r
-  Buffer  = NULL;\r
-  Status  = STATUS_ERROR;\r
-  //\r
-  // Try to open the input file\r
-  //\r
-  if ((InFptr = fopen (InFileName, "rb")) == NULL) {\r
-    Error (NULL, 0, 0, InFileName, "failed to open input file for reading");\r
-    return STATUS_ERROR;\r
-  }\r
-  //\r
-  // Double-check the file to make sure it's what we expect it to be\r
-  //\r
-  if (CheckPE32File (InFileName, InFptr, &MachineType, &SubSystem) != STATUS_SUCCESS) {\r
-    goto Finish;\r
-  }\r
-  //\r
-  // Per the PE/COFF specification, at offset 0x3C in the file is a 32-bit\r
-  // offset (from the start of the file) to the PE signature, which always\r
-  // follows the MSDOS stub. The PE signature is immediately followed by the\r
-  // COFF file header.\r
-  //\r
-  //\r
-  if (fseek (InFptr, 0x3C, SEEK_SET) != 0) {\r
-    Error (NULL, 0, 0, InFileName, "failed to seek to PE signature in file", NULL);\r
-    goto Finish;\r
-  }\r
-\r
-  if (fread (&PESigOffset, sizeof (PESigOffset), 1, InFptr) != 1) {\r
-    Error (NULL, 0, 0, InFileName, "failed to read PE signature offset from file");\r
-    goto Finish;\r
-  }\r
-\r
-  if (fseek (InFptr, PESigOffset + 4, SEEK_SET) != 0) {\r
-    Error (NULL, 0, 0, InFileName, "failed to seek to PE signature");\r
-    goto Finish;\r
-  }\r
-  //\r
-  // We should now be at the COFF file header. Read it in and verify it's\r
-  // of an image type we support.\r
-  //\r
-  if (fread (&FileHeader, sizeof (EFI_IMAGE_FILE_HEADER), 1, InFptr) != 1) {\r
-    Error (NULL, 0, 0, InFileName, "failed to read file header from image");\r
-    goto Finish;\r
-  }\r
-\r
-  if ((FileHeader.Machine != EFI_IMAGE_MACHINE_IA32) && (FileHeader.Machine != EFI_IMAGE_MACHINE_IA64) && (FileHeader.Machine != EFI_IMAGE_MACHINE_X64)) {\r
-    Error (NULL, 0, 0, InFileName, "image is of an unsupported machine type 0x%X", (UINT32) FileHeader.Machine);\r
-    goto Finish;\r
-  }\r
-  //\r
-  // Read in the optional header. Assume PE32, and if not, then re-read as PE32+\r
-  //\r
-  SaveFilePosition = ftell (InFptr);\r
-  if (fread (&OptionalHeader32, sizeof (EFI_IMAGE_OPTIONAL_HEADER32), 1, InFptr) != 1) {\r
-    Error (NULL, 0, 0, InFileName, "failed to read optional header from input file");\r
-    goto Finish;\r
-  }\r
-\r
-  if (OptionalHeader32.Magic == EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC) {\r
-    if (fseek (InFptr, SaveFilePosition, SEEK_SET) != 0) {\r
-      Error (NULL, 0, 0, InFileName, "failed to seek to .data section");\r
-      goto Finish;\r
-    }\r
-\r
-    if (fread (&OptionalHeader64, sizeof (EFI_IMAGE_OPTIONAL_HEADER64), 1, InFptr) != 1) {\r
-      Error (NULL, 0, 0, InFileName, "failed to read optional header from input file");\r
-      goto Finish;\r
-    }\r
-  }\r
-  //\r
-  // Search for the ".data" section\r
-  //\r
-  for (Index = 0; Index < FileHeader.NumberOfSections; Index++) {\r
-    if (fread (&SectionHeader, sizeof (EFI_IMAGE_SECTION_HEADER), 1, InFptr) != 1) {\r
-      Error (NULL, 0, 0, InFileName, "failed to read optional header from input file");\r
-      goto Finish;\r
-    }\r
-\r
-    if (strcmp (SectionHeader.Name, ".data") == 0) {\r
-      if (fseek (InFptr, SectionHeader.PointerToRawData, SEEK_SET) != 0) {\r
-        Error (NULL, 0, 0, InFileName, "failed to seek to .data section");\r
-        goto Finish;\r
-      }\r
-\r
-      Buffer = (UINT8 *) malloc (SectionHeader.Misc.VirtualSize);\r
-      if (Buffer == NULL) {\r
-        Status = EFI_OUT_OF_RESOURCES;\r
-        goto Finish;\r
-      }\r
-      if (fread (Buffer, SectionHeader.Misc.VirtualSize, 1, InFptr) != 1) {\r
-        Error (NULL, 0, 0, InFileName, "failed to .data section");\r
-        goto Finish;\r
-      }\r
-      //\r
-      // Now open our output file\r
-      //\r
-      if ((OutFptr = fopen (OutFileName, "wb")) == NULL) {\r
-        Error (NULL, 0, 0, OutFileName, "failed to open output file for writing");\r
-        goto Finish;\r
-      }\r
-\r
-      if (fwrite (Buffer, SectionHeader.Misc.VirtualSize, 1, OutFptr) != 1) {\r
-        Error (NULL, 0, 0, OutFileName, "failed to write .data section");\r
-        goto Finish;\r
-      }\r
-\r
-      Status = STATUS_SUCCESS;\r
-      goto Finish;\r
-    }\r
-  }\r
-\r
-  Status = STATUS_ERROR;\r
-\r
-Finish:\r
-  if (InFptr != NULL) {\r
-    fclose (InFptr);\r
-  }\r
-  //\r
-  // Close the output file. If there was an error, delete the output file so\r
-  // that a subsequent build will rebuild it.\r
-  //\r
-  if (OutFptr != NULL) {\r
-    fclose (OutFptr);\r
-    if (GetUtilityStatus () == STATUS_ERROR) {\r
-      remove (OutFileName);\r
-    }\r
-  }\r
-\r
-  //\r
-  // Free up our buffer\r
-  //\r
-  if (Buffer != NULL) {\r
-    free (Buffer);\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-static\r
-STATUS\r
-CheckPE32File (\r
-  INT8      *FileName,\r
-  FILE      *Fptr,\r
-  UINT16    *MachineType,\r
-  UINT16    *SubSystem\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  FileName    - GC_TODO: add argument description\r
-  Fptr        - GC_TODO: add argument description\r
-  MachineType - GC_TODO: add argument description\r
-  SubSystem   - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
-  GC_TODO: add return values\r
-\r
---*/\r
-{\r
-  /*++\r
-\r
-Routine Description:\r
-  \r
-  Given a file pointer to a supposed PE32 image file, verify that it is indeed a\r
-  PE32 image file, and then return the machine type in the supplied pointer.\r
-\r
-Arguments:\r
-\r
-  Fptr          File pointer to the already-opened PE32 file\r
-  MachineType   Location to stuff the machine type of the PE32 file. This is needed\r
-                because the image may be Itanium-based, IA32, or EBC.\r
-\r
-Returns:\r
-\r
-  0             success\r
-  non-zero      otherwise\r
-\r
---*/\r
-  EFI_IMAGE_DOS_HEADER      DosHeader;\r
-  EFI_IMAGE_FILE_HEADER     FileHdr;\r
-  EFI_IMAGE_OPTIONAL_HEADER OptionalHdr;\r
-  UINT32                    PESig;\r
-  STATUS                    Status;\r
-\r
-  Status = STATUS_ERROR;\r
-  //\r
-  // Position to the start of the file\r
-  //\r
-  fseek (Fptr, 0, SEEK_SET);\r
-  //\r
-  // Read the DOS header\r
-  //\r
-  if (fread (&DosHeader, sizeof (DosHeader), 1, Fptr) != 1) {\r
-    Error (NULL, 0, 0, FileName, "failed to read the DOS stub from the input file");\r
-    goto Finish;\r
-  }\r
-  //\r
-  // Check the magic number (0x5A4D)\r
-  //\r
-  if (DosHeader.e_magic != EFI_IMAGE_DOS_SIGNATURE) {\r
-    Error (NULL, 0, 0, FileName, "input file does not appear to be a PE32 image (magic number)");\r
-    goto Finish;\r
-  }\r
-  //\r
-  // Position into the file and check the PE signature\r
-  //\r
-  fseek (Fptr, (long) DosHeader.e_lfanew, SEEK_SET);\r
-  if (fread (&PESig, sizeof (PESig), 1, Fptr) != 1) {\r
-    Error (NULL, 0, 0, FileName, "failed to read PE signature bytes");\r
-    goto Finish;\r
-  }\r
-  //\r
-  // Check the PE signature in the header "PE\0\0"\r
-  //\r
-  if (PESig != EFI_IMAGE_NT_SIGNATURE) {\r
-    Error (NULL, 0, 0, FileName, "file does not appear to be a PE32 image (signature)");\r
-    goto Finish;\r
-  }\r
-  //\r
-  // Read the file header\r
-  //\r
-  if (fread (&FileHdr, sizeof (FileHdr), 1, Fptr) != 1) {\r
-    Error (NULL, 0, 0, FileName, "failed to read PE file header from input file");\r
-    goto Finish;\r
-  }\r
-  //\r
-  // Read the optional header so we can get the subsystem\r
-  //\r
-  if (fread (&OptionalHdr, sizeof (OptionalHdr), 1, Fptr) != 1) {\r
-    Error (NULL, 0, 0, FileName, "failed to read COFF optional header from input file");\r
-    goto Finish;\r
-  }\r
-\r
-  *SubSystem = OptionalHdr.Subsystem;\r
-  //\r
-  // Good to go\r
-  //\r
-  Status = STATUS_SUCCESS;\r
-Finish:\r
-  fseek (Fptr, 0, SEEK_SET);\r
-  return Status;\r
-}\r
-\r
-static\r
-int\r
-ParseCommandLine (\r
-  int         Argc,\r
-  char        *Argv[]\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  \r
-  Given the Argc/Argv program arguments, and a pointer to an options structure,\r
-  parse the command-line options and check their validity.\r
-\r
-\r
-Arguments:\r
-\r
-  Argc            - standard C main() argument count\r
-  Argv            - standard C main() argument list\r
-\r
-Returns:\r
-\r
-  STATUS_SUCCESS    success\r
-  non-zero          otherwise\r
-\r
---*/\r
-// GC_TODO:    ] - add argument and description to function comment\r
-{\r
-  //\r
-  // Clear out the options\r
-  //\r
-  memset ((char *) &mOptions, 0, sizeof (mOptions));\r
-  //\r
-  // Skip over the program name\r
-  //\r
-  Argc--;\r
-  Argv++;\r
-\r
-  if (Argc != 2) {\r
-    Usage ();\r
-    return STATUS_ERROR;\r
-  }\r
-\r
-  strcpy (mOptions.InFileName, Argv[0]);\r
-  //\r
-  // Next argument\r
-  //\r
-  Argv++;\r
-  Argc--;\r
-\r
-  strcpy (mOptions.OutFileName, Argv[0]);\r
-\r
-  return STATUS_SUCCESS;\r
-}\r
-\r
-static\r
-void\r
-Usage (\r
-  VOID\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  \r
-  Print usage information for this utility.\r
-\r
-Arguments:\r
-\r
-  None.\r
-\r
-Returns:\r
-\r
-  Nothing.\r
-\r
---*/\r
-{\r
-  int               Index;\r
-  static const char *Msg[] = {\r
-    UTILITY_NAME " version "UTILITY_VERSION " - Generate ACPI Table image utility",\r
-    "  Generate an ACPI Table image from an EFI PE32 image",\r
-    "  Usage: "UTILITY_NAME " InFileName OutFileName",\r
-    "    where:",\r
-    "      InFileName     - name of the input PE32 file",\r
-    "      OutFileName    - to write output to OutFileName rather than InFileName"DEFAULT_OUTPUT_EXTENSION,\r
-    "",\r
-    NULL\r
-  };\r
-  for (Index = 0; Msg[Index] != NULL; Index++) {\r
-    fprintf (stdout, "%s\n", Msg[Index]);\r
-  }\r
-}\r
diff --git a/Tools/CodeTools/TianoTools/GenAcpiTable/build.xml b/Tools/CodeTools/TianoTools/GenAcpiTable/build.xml
deleted file mode 100644 (file)
index 8c8c5eb..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-<?xml version="1.0" ?>\r
-<!--\r
-Copyright (c) 2006, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
--->\r
-<project default="GenTool" basedir=".">\r
-<!--\r
-    EDK GenAcpiTable Tool\r
-  Copyright (c) 2006, Intel Corporation\r
--->\r
-  <property name="ToolName" value="GenAcpiTable"/>\r
-  <property name="FileSet" value="*.c"/>\r
-\r
-  <taskdef resource="cpptasks.tasks"/>\r
-  <typedef resource="cpptasks.types"/>\r
-  <taskdef resource="net/sf/antcontrib/antlib.xml"/>\r
-\r
-  <property name="LINK_OUTPUT_TYPE" value="static"/>\r
-  <property name="BUILD_DIR" value="${PACKAGE_DIR}/${ToolName}/tmp"/>\r
-\r
-  <target name="GenTool" depends="init, Tool">\r
-    <echo message="The EDK Tool: ${ToolName} build has completed!"/>\r
-  </target>\r
-\r
-  <target name="init">\r
-    <echo message="Building the EDK Tool: ${ToolName}"/>\r
-    <mkdir dir="${BUILD_DIR}"/>\r
-  </target>\r
-\r
-  <target name="Tool" depends="init">\r
-    <cc name="${ToolChain}" objdir="${BUILD_DIR}" \r
-        outfile="${BIN_DIR}/${ToolName}"\r
-        outtype="executable"\r
-        optimize="speed" \r
-        debug="true">\r
-      <compilerarg value="${ExtraArgus}" if="ExtraArgus" />\r
-\r
-      <fileset dir="${basedir}/${ToolName}" \r
-        includes="${FileSet}" \r
-        defaultexcludes="TRUE" \r
-        excludes="*.xml *.inf"/>\r
-\r
-      <includepath path="${PACKAGE_DIR}/Include"/>\r
-      <includepath path="${PACKAGE_DIR}/Include/Ia32"/>\r
-      <includepath path="${PACKAGE_DIR}/Common"/>\r
-      <libset dir="${LIB_DIR}" libs="CommonTools"/>\r
-    </cc>\r
-  </target>\r
-\r
-  <target name="clean">\r
-    <echo message="Removing Intermediate Files Only"/>  \r
-    <delete>\r
-      <fileset dir="${BUILD_DIR}" includes="*.obj"/>\r
-    </delete>\r
-  </target>\r
-\r
-  <target name="cleanall">\r
-    <echo message="Removing Object Files and the Executable: ${ToolName}${ext_exe}"/>  \r
-    <delete failonerror="false" quiet="true" includeEmptyDirs="true">\r
-      <fileset dir="${BUILD_DIR}"/>\r
-      <fileset file="${BIN_DIR}/${ToolName}${ext_exe}"/>\r
-    </delete>\r
-  </target>\r
-\r
-</project>\r
diff --git a/Tools/CodeTools/TianoTools/GenCRC32Section/GenCRC32Section.c b/Tools/CodeTools/TianoTools/GenCRC32Section/GenCRC32Section.c
deleted file mode 100644 (file)
index b99cf2f..0000000
+++ /dev/null
@@ -1,286 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2004, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-Module Name:\r
-  \r
-    GenCRC32Section.c\r
-\r
-Abstract:\r
-\r
-  This file contains functions required to generate a Firmware File System \r
-  file. The code is compliant with the Tiano C Coding standards.\r
-\r
---*/\r
-\r
-#include "GenCRC32Section.h"\r
-\r
-#define TOOLVERSION   "0.2"\r
-\r
-#define UTILITY_NAME  "GenCrc32Section"\r
-\r
-EFI_GUID  gEfiCrc32SectionGuid = EFI_CRC32_GUIDED_SECTION_EXTRACTION_PROTOCOL_GUID;\r
-\r
-EFI_STATUS\r
-SignSectionWithCrc32 (\r
-  IN OUT UINT8  *FileBuffer,\r
-  IN OUT UINT32 *BufferSize,\r
-  IN UINT32     DataSize\r
-  )\r
-/*++\r
-        \r
-Routine Description:\r
-           \r
-  Signs the section with CRC32 and add GUIDed section header for the \r
-  signed data. data stays in same location (overwrites source data).\r
-            \r
-Arguments:\r
-               \r
-  FileBuffer  - Buffer containing data to sign\r
-                \r
-  BufferSize  - On input, the size of FileBuffer. On output, the size of \r
-                actual section data (including added section header).              \r
-\r
-  DataSize    - Length of data to Sign\r
-\r
-  Key         - Key to use when signing. Currently only CRC32 is supported.\r
-                                       \r
-Returns:\r
-                       \r
-  EFI_SUCCESS           - Successful\r
-  EFI_OUT_OF_RESOURCES  - Not enough resource to complete the operation.\r
-                        \r
---*/\r
-{\r
-\r
-  UINT32                Crc32Checksum;\r
-  EFI_STATUS            Status;\r
-  UINT32                TotalSize;\r
-  CRC32_SECTION_HEADER  Crc32Header;\r
-  UINT8                 *SwapBuffer;\r
-\r
-  Crc32Checksum = 0;\r
-  SwapBuffer    = NULL;\r
-\r
-  if (DataSize == 0) {\r
-    *BufferSize = 0;\r
-\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  Status = CalculateCrc32 (FileBuffer, DataSize, &Crc32Checksum);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  TotalSize = DataSize + CRC32_SECTION_HEADER_SIZE;\r
-  Crc32Header.GuidSectionHeader.CommonHeader.Type     = EFI_SECTION_GUID_DEFINED;\r
-  Crc32Header.GuidSectionHeader.CommonHeader.Size[0]  = (UINT8) (TotalSize & 0xff);\r
-  Crc32Header.GuidSectionHeader.CommonHeader.Size[1]  = (UINT8) ((TotalSize & 0xff00) >> 8);\r
-  Crc32Header.GuidSectionHeader.CommonHeader.Size[2]  = (UINT8) ((TotalSize & 0xff0000) >> 16);\r
-  memcpy (&(Crc32Header.GuidSectionHeader.SectionDefinitionGuid), &gEfiCrc32SectionGuid, sizeof (EFI_GUID));\r
-  Crc32Header.GuidSectionHeader.Attributes  = EFI_GUIDED_SECTION_AUTH_STATUS_VALID;\r
-  Crc32Header.GuidSectionHeader.DataOffset  = CRC32_SECTION_HEADER_SIZE;\r
-  Crc32Header.CRC32Checksum                 = Crc32Checksum;\r
-\r
-  SwapBuffer = (UINT8 *) malloc (DataSize);\r
-  if (SwapBuffer == NULL) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-\r
-  memcpy (SwapBuffer, FileBuffer, DataSize);\r
-  memcpy (FileBuffer, &Crc32Header, CRC32_SECTION_HEADER_SIZE);\r
-  memcpy (FileBuffer + CRC32_SECTION_HEADER_SIZE, SwapBuffer, DataSize);\r
-\r
-  //\r
-  // Make sure section ends on a DWORD boundary\r
-  //\r
-  while ((TotalSize & 0x03) != 0) {\r
-    FileBuffer[TotalSize] = 0;\r
-    TotalSize++;\r
-  }\r
-\r
-  *BufferSize = TotalSize;\r
-\r
-  if (SwapBuffer != NULL) {\r
-    free (SwapBuffer);\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-VOID\r
-PrintUsage (\r
-  VOID\r
-  )\r
-{\r
-  printf ("Usage:\n");\r
-  printf (UTILITY_NAME " -i \"inputfile1\" \"inputfile2\" -o \"outputfile\" \n");\r
-  printf ("   -i \"inputfile\":\n ");\r
-  printf ("       specifies the input files that would be signed to CRC32 Guided section.\n");\r
-  printf ("   -o \"outputfile\":\n");\r
-  printf ("       specifies the output file that is a CRC32 Guided section.\n");\r
-}\r
-\r
-INT32\r
-ReadFilesContentsIntoBuffer (\r
-  IN      CHAR8   *argv[],\r
-  IN      INT32   Start,\r
-  IN OUT  UINT8   **FileBuffer,\r
-  IN OUT  UINT32  *BufferSize,\r
-  OUT     UINT32  *ContentSize,\r
-  IN      INT32   MaximumArguments\r
-  )\r
-{\r
-  INT32   Index;\r
-  CHAR8   *FileName;\r
-  FILE    *InputFile;\r
-  UINT8   Temp;\r
-  UINT32  Size;\r
-\r
-  FileName  = NULL;\r
-  InputFile = NULL;\r
-  Size      = 0;\r
-  Index     = 0;\r
-\r
-  //\r
-  // read all input files into one file buffer\r
-  //\r
-  while (argv[Start + Index][0] != '-') {\r
-\r
-    FileName  = argv[Start + Index];\r
-    InputFile = fopen (FileName, "rb");\r
-    if (InputFile == NULL) {\r
-      Error (NULL, 0, 0, FileName, "failed to open input binary file");\r
-      return -1;\r
-    }\r
-\r
-    fread (&Temp, sizeof (UINT8), 1, InputFile);\r
-    while (!feof (InputFile)) {\r
-      (*FileBuffer)[Size++] = Temp;\r
-      fread (&Temp, sizeof (UINT8), 1, InputFile);\r
-    }\r
-\r
-    fclose (InputFile);\r
-    InputFile = NULL;\r
-\r
-    //\r
-    // Make sure section ends on a DWORD boundary\r
-    //\r
-    while ((Size & 0x03) != 0) {\r
-      (*FileBuffer)[Size] = 0;\r
-      Size++;\r
-    }\r
-\r
-    Index++;\r
-    if (Index == MaximumArguments) {\r
-      break;\r
-    }\r
-  }\r
-\r
-  *ContentSize = Size;\r
-  return Index;\r
-}\r
-\r
-int\r
-main (\r
-  INT32 argc,\r
-  CHAR8 *argv[]\r
-  )\r
-{\r
-  FILE        *OutputFile;\r
-  UINT8       *FileBuffer;\r
-  UINT32      BufferSize;\r
-  EFI_STATUS  Status;\r
-  UINT32      ContentSize;\r
-  CHAR8       *OutputFileName;\r
-  INT32       ReturnValue;\r
-  INT32       Index;\r
-\r
-  OutputFile      = NULL;\r
-  FileBuffer      = NULL;\r
-  ContentSize     = 0;\r
-  OutputFileName  = NULL;\r
-\r
-  SetUtilityName (UTILITY_NAME);\r
-\r
-  if (argc == 1) {\r
-    PrintUsage ();\r
-    return -1;\r
-  }\r
-\r
-  BufferSize  = 1024 * 1024 * 16;\r
-  FileBuffer  = (UINT8 *) malloc (BufferSize * sizeof (UINT8));\r
-  if (FileBuffer == NULL) {\r
-    Error (NULL, 0, 0, "memory allocation failed", NULL);\r
-    return -1;\r
-  }\r
-\r
-  ZeroMem (FileBuffer, BufferSize);\r
-\r
-  for (Index = 0; Index < argc; Index++) {\r
-    if (strcmpi (argv[Index], "-i") == 0) {\r
-      ReturnValue = ReadFilesContentsIntoBuffer (\r
-                      argv,\r
-                      (Index + 1),\r
-                      &FileBuffer,\r
-                      &BufferSize,\r
-                      &ContentSize,\r
-                      (argc - (Index + 1))\r
-                      );\r
-      if (ReturnValue == -1) {\r
-        Error (NULL, 0, 0, "failed to read file contents", NULL);\r
-        return -1;\r
-      }\r
-\r
-      Index += ReturnValue;\r
-    }\r
-\r
-    if (strcmpi (argv[Index], "-o") == 0) {\r
-      OutputFileName = argv[Index + 1];\r
-    }\r
-  }\r
-\r
-  OutputFile = fopen (OutputFileName, "wb");\r
-  if (OutputFile == NULL) {\r
-    Error (NULL, 0, 0, OutputFileName, "failed to open output binary file");\r
-    free (FileBuffer);\r
-    return -1;\r
-  }\r
-\r
-  /*  \r
-  //\r
-  // make sure section ends on a DWORD boundary ??\r
-  //\r
-  while ( (Size & 0x03) != 0 ) {\r
-    FileBuffer[Size] = 0;\r
-    Size ++;\r
-  }\r
-*/\r
-  Status = SignSectionWithCrc32 (FileBuffer, &BufferSize, ContentSize);\r
-  if (EFI_ERROR (Status)) {\r
-    Error (NULL, 0, 0, "failed to sign section", NULL);\r
-    free (FileBuffer);\r
-    fclose (OutputFile);\r
-    return -1;\r
-  }\r
-\r
-  ContentSize = fwrite (FileBuffer, sizeof (UINT8), BufferSize, OutputFile);\r
-  if (ContentSize != BufferSize) {\r
-    Error (NULL, 0, 0, "failed to write output buffer", NULL);\r
-    ReturnValue = -1;\r
-  } else {\r
-    ReturnValue = 0;\r
-  }\r
-\r
-  free (FileBuffer);\r
-  fclose (OutputFile);\r
-  return ReturnValue;\r
-}\r
diff --git a/Tools/CodeTools/TianoTools/GenCRC32Section/GenCRC32Section.h b/Tools/CodeTools/TianoTools/GenCRC32Section/GenCRC32Section.h
deleted file mode 100644 (file)
index 1cf976b..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2004, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-Module Name:\r
-\r
-  GenCRC32Section.h \r
-\r
-Abstract:\r
-\r
-  Header file for GenFfsFile. Mainly defines the header of section\r
-  header for CRC32 GUID defined sections. Share with GenSection.c\r
-\r
---*/\r
-\r
-//\r
-// External Files Referenced\r
-//\r
-\r
-/* Standard Headers */\r
-#include <stdio.h>\r
-#include <stdlib.h>\r
-#include <string.h>\r
-#include <assert.h>\r
-\r
-/* MDE Headers */\r
-#include <Common/UefiBaseTypes.h>\r
-#include <Common/EfiImage.h>\r
-#include <Common/FirmwareVolumeImageFormat.h>\r
-#include <Common/FirmwareFileSystem.h>\r
-#include <Common/FirmwareVolumeHeader.h>\r
-#include <Protocol/GuidedSectionExtraction.h>\r
-\r
-/* Tool Headers */\r
-#include "CommonLib.h"\r
-#include "Crc32.h"\r
-#include "EfiCompress.h"\r
-#include "EfiUtilityMsgs.h"\r
-#include "ParseInf.h"\r
-\r
-//\r
-// Module Coded to Tiano Coding Conventions\r
-//\r
-#ifndef _EFI_GEN_CRC32_SECTION_H\r
-#define _EFI_GEN_CRC32_SECTION_H\r
-\r
-\r
-typedef struct {\r
-  EFI_GUID_DEFINED_SECTION  GuidSectionHeader;\r
-  UINT32                    CRC32Checksum;\r
-} CRC32_SECTION_HEADER;\r
-\r
-#define EFI_SECTION_CRC32_GUID_DEFINED  0\r
-#define CRC32_SECTION_HEADER_SIZE       (sizeof (CRC32_SECTION_HEADER))\r
-\r
-#endif\r
diff --git a/Tools/CodeTools/TianoTools/GenCRC32Section/build.xml b/Tools/CodeTools/TianoTools/GenCRC32Section/build.xml
deleted file mode 100644 (file)
index bbb0f71..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-<?xml version="1.0" ?>\r
-<!--\r
-Copyright (c) 2006, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
--->\r
-<project default="GenTool" basedir=".">\r
-<!--\r
-    EDK GenCRC32Section Tool\r
-  Copyright (c) 2006, Intel Corporation\r
--->\r
-  <property name="ToolName" value="GenCRC32Section"/>\r
-  <property name="FileSet" value="GenCRC32Section.c GenCRC32Section.h"/>\r
-\r
-  <taskdef resource="cpptasks.tasks"/>\r
-  <typedef resource="cpptasks.types"/>\r
-  <taskdef resource="net/sf/antcontrib/antlib.xml"/>\r
-\r
-  <property name="LINK_OUTPUT_TYPE" value="static"/>\r
-  <property name="BUILD_DIR" value="${PACKAGE_DIR}/${ToolName}/tmp"/>\r
-\r
-  <target name="GenTool" depends="init, Tool">\r
-    <echo message="The EDK Tool: ${ToolName} build has completed!"/>\r
-  </target>\r
-\r
-  <target name="init">\r
-    <echo message="Building the EDK Tool: ${ToolName}"/>\r
-    <mkdir dir="${BUILD_DIR}"/>\r
-  </target>\r
-\r
-  <target name="Tool" depends="init">\r
-    <cc name="${ToolChain}" objdir="${BUILD_DIR}" \r
-        outfile="${BIN_DIR}/${ToolName}"\r
-        outtype="executable"\r
-        debug="true"\r
-        optimize="speed">\r
-\r
-      <fileset dir="${basedir}/${ToolName}" \r
-        includes="${FileSet}"/>\r
-\r
-      <includepath path="${PACKAGE_DIR}/Include"/>\r
-      <includepath path="${PACKAGE_DIR}/Include/${HostArch}"/>\r
-      <includepath path="${PACKAGE_DIR}/Common"/>\r
-      <libset dir="${LIB_DIR}" libs="CommonTools"/>\r
-\r
-    </cc>\r
-  </target>\r
-\r
-  <target name="clean">\r
-    <echo message="Removing Intermediate Files Only"/>  \r
-    <delete>\r
-      <fileset dir="${BUILD_DIR}" includes="*.obj"/>\r
-    </delete>\r
-  </target>\r
-\r
-  <target name="cleanall">\r
-    <echo message="Removing Object Files and the Executable: ${ToolName}${ext_exe}"/>  \r
-    <delete failonerror="false" quiet="true" includeEmptyDirs="true">\r
-      <fileset dir="${BUILD_DIR}"/>\r
-      <fileset file="${BIN_DIR}/${ToolName}${ext_exe}"/>\r
-    </delete>\r
-  </target>\r
-\r
-</project>\r
diff --git a/Tools/CodeTools/TianoTools/GenCapsuleHdr/CreateGuid.c b/Tools/CodeTools/TianoTools/GenCapsuleHdr/CreateGuid.c
deleted file mode 100644 (file)
index 2a984fa..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-/*++\r
-\r
-Copyright (c)  2004-2006 Intel Corporation. All rights reserved\r
-This program and the accompanying materials are licensed and made available \r
-under the terms and conditions of the BSD License which accompanies this \r
-distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-\r
-Module Name:\r
-\r
-  CreateGuid.c  \r
-\r
-Abstract:\r
-\r
-  Library routine to create a GUID\r
-\r
---*/\r
-\r
-#include <windows.h>\r
-#include <stdio.h>\r
-#include <string.h>\r
-#include <stdlib.h>\r
-#include <ctype.h>\r
-\r
-void\r
-CreateGuid (\r
-  GUID *Guid\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  Guid  - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
-  GC_TODO: add return values\r
-\r
---*/\r
-{\r
-  CoCreateGuid (Guid);\r
-}\r
diff --git a/Tools/CodeTools/TianoTools/GenCapsuleHdr/GenCapsuleHdr.c b/Tools/CodeTools/TianoTools/GenCapsuleHdr/GenCapsuleHdr.c
deleted file mode 100644 (file)
index d1f55b9..0000000
+++ /dev/null
@@ -1,2674 +0,0 @@
-/*++\r
-\r
-Copyright (c)  2002-2006 Intel Corporation. All rights reserved\r
-This program and the accompanying materials are licensed and made available \r
-under the terms and conditions of the BSD License which accompanies this \r
-distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-\r
-Module Name:\r
-\r
-  GenCapsuleHdr.c  \r
-\r
-Abstract:\r
-\r
-  Generate a capsule header for a file, and optionally prepend the\r
-  header to a file or list of files.\r
-\r
---*/\r
-\r
-#define _UNICODE\r
-\r
-#include <stdio.h>\r
-#include <string.h>\r
-#include <stdlib.h>\r
-#include <ctype.h>\r
-\r
-#include <Common/UefiBaseTypes.h>\r
-#include <Common/MultiPhase.h>\r
-#include <Common/Capsule.h>\r
-#include <Common/FirmwareVolumeImageFormat.h>\r
-#include <Common/FirmwareVolumeHeader.h>\r
-#include <Common/FirmwareFileSystem.h>  // for FV header GUID\r
-#include <Guid/Capsule.h>\r
-#include <Guid/FirmwareFileSystem.h>  // for FV header GUID\r
-\r
-#include "CommonLib.h"\r
-#include "EfiUtilityMsgs.h"\r
-\r
-#define MAX_PATH                  256\r
-#define PROGRAM_NAME              "GenCapsuleHdr"\r
-\r
-#define UNICODE_BACKSLASH         L'\\'\r
-#define UNICODE_FILE_START        0xFEFF\r
-#define UNICODE_CR                0x000D\r
-#define UNICODE_LF                0x000A\r
-#define UNICODE_NULL              0x0000\r
-#define UNICODE_SPACE             L' '\r
-#define UNICODE_SLASH             L'/'\r
-#define UNICODE_DOUBLE_QUOTE      L'"'\r
-#define UNICODE_A                 L'A'\r
-#define UNICODE_F                 L'F'\r
-#define UNICODE_Z                 L'Z'\r
-#define UNICODE_a                 L'a'\r
-#define UNICODE_f                 L'f'\r
-#define UNICODE_z                 L'z'\r
-#define UNICODE_0                 L'0'\r
-#define UNICODE_9                 L'9'\r
-#define UNICODE_TAB               L'\t'\r
-\r
-#define OEM_HEADER_STRING         L"OemHeader"\r
-#define AUTHOR_INFO_STRING        L"AuthorInfo"\r
-#define REVISION_INFO_STRING      L"RevisionInfo"\r
-#define SHORT_DESCRIPTION_STRING  L"ShortDescription"\r
-#define LONG_DESCRIPTION_STRING   L"LongDescription"\r
-#define EQUAL_STRING              L"="\r
-#define OPEN_BRACE_STRING         L"{"\r
-#define CLOSE_BRACE_STRING        L"}"\r
-#define GUID_STRING               L"GUID"\r
-#define DATA_STRING               L"DATA"\r
-\r
-#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
-#define UEFI_CAPSULE_HEADER_NO_FALAGS      0\r
-#define UEFI_CAPSULE_HEADER_RESET_FALAGS   CAPSULE_FLAGS_PERSIST_ACROSS_RESET\r
-#define UEFI_CAPSULE_HEADER_ALL_FALAGS     (CAPSULE_FLAGS_PERSIST_ACROSS_RESET | CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE)\r
-#endif\r
-\r
-typedef wchar_t WCHAR;\r
-\r
-typedef struct _FILE_LIST {\r
-  struct _FILE_LIST *Next;\r
-  INT8              FileName[MAX_PATH];\r
-} FILE_LIST;\r
-\r
-typedef struct _SIZE_LIST {\r
-  struct _SIZE_LIST *Next;\r
-  UINT32            Size;\r
-} SIZE_LIST;\r
-\r
-typedef struct {\r
-  INT8    FileName[MAX_PATH];\r
-  WCHAR   *FileBuffer;\r
-  WCHAR   *FileBufferPtr;\r
-  UINT32  FileSize;\r
-  FILE    *FilePtr;\r
-  BOOLEAN EndOfFile;\r
-  UINT32  LineNum;\r
-} SOURCE_FILE;\r
-\r
-//\r
-// Here's all our globals.\r
-//\r
-static struct {\r
-  BOOLEAN   Dump;\r
-  BOOLEAN   Verbose;\r
-  BOOLEAN   JoinMode;\r
-  INT8      ScriptFileName[MAX_PATH];\r
-  INT8      OutputFileName[MAX_PATH];\r
-  FILE_LIST *FileList;\r
-  FILE      *OutFptr;\r
-  SIZE_LIST *SizeList;\r
-  SIZE_LIST *LastSize;\r
-  SIZE_LIST *CurrentSize;\r
-} mOptions;\r
-\r
-static EFI_GUID mEfiCapsuleHeaderGuid = EFI_CAPSULE_GUID;\r
-\r
-void\r
-CreateGuid (\r
-  EFI_GUID *Guid\r
-  );\r
-\r
-static\r
-STATUS\r
-ProcessArgs (\r
-  int   Argc,\r
-  char  *Argv[]\r
-  );\r
-\r
-static\r
-void\r
-SkipWhiteSpace (\r
-  SOURCE_FILE *SourceFile\r
-  );\r
-\r
-static\r
-STATUS\r
-GetHexValue (\r
-  SOURCE_FILE  *SourceFile,\r
-  UINT32       *Value,\r
-  UINT32       NumDigits\r
-  );\r
-\r
-static\r
-BOOLEAN\r
-GetSplitFileName (\r
-  INT8    *BaseFileName,\r
-  INT8    *NewFileName,\r
-  UINT32  SequenceNumber\r
-  );\r
-\r
-static\r
-STATUS\r
-SplitCapsule (\r
-  INT8 *CapsuleFileName\r
-  );\r
-\r
-static\r
-void\r
-Usage (\r
-  VOID\r
-  );\r
-\r
-static\r
-void\r
-DumpCapsule (\r
-  VOID\r
-  );\r
-\r
-static\r
-STATUS\r
-JoinCapsule (\r
-  VOID\r
-  );\r
-\r
-static\r
-STATUS\r
-DumpCapsuleHeaderStrings (\r
-  UINT8   *SectionName,\r
-  WCHAR   *Buffer\r
-  );\r
-\r
-static\r
-STATUS\r
-CheckFirmwareVolumeHeader (\r
-  INT8    *FileName,\r
-  INT8    *Buffer,\r
-  UINT32  BufferSize\r
-  );\r
-\r
-static\r
-BOOLEAN\r
-IsToken (\r
-  SOURCE_FILE *File,\r
-  WCHAR       *Token\r
-  );\r
-\r
-static\r
-BOOLEAN\r
-GetNumber (\r
-  INT8    *Str,\r
-  UINT32  *Value\r
-  );\r
-\r
-static\r
-STATUS\r
-ProcessScriptFile (\r
-  INT8                *ScriptFileName,\r
-  FILE                *OutFptr,\r
-  EFI_CAPSULE_HEADER  *CapsuleHeader\r
-  );\r
-\r
-static\r
-STATUS\r
-ParseCapsuleInfo (\r
-  SOURCE_FILE       *SourceFile,\r
-  FILE              *OutFptr,\r
-  WCHAR             *SectionName\r
-  );\r
-\r
-static\r
-STATUS\r
-CreateCapsule (\r
-  VOID\r
-  );\r
-\r
-static\r
-STATUS\r
-ParseOemInfo (\r
-  SOURCE_FILE       *SourceFile,\r
-  FILE              *OutFptr\r
-  );\r
-\r
-static\r
-BOOLEAN\r
-IsWhiteSpace (\r
-  WCHAR Char\r
-  );\r
-\r
-static\r
-BOOLEAN\r
-EndOfFile (\r
-  SOURCE_FILE *File\r
-  );\r
-\r
-int\r
-main (\r
-  int   Argc,\r
-  char  *Argv[]\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Call the routine to process the command-line arguments, then\r
-  dispatch to the appropriate function.\r
-  \r
-Arguments:\r
-  Standard C main() argc and argv.\r
-\r
-Returns:\r
-  0      if successful\r
-  nonzero otherwise\r
-  \r
---*/\r
-// GC_TODO:    Argc - add argument and description to function comment\r
-// GC_TODO:    ] - add argument and description to function comment\r
-{\r
-  STATUS    Status;\r
-  FILE_LIST *NextFile;\r
-  //\r
-  // Specify our program name to the error printing routines.\r
-  //\r
-  SetUtilityName (PROGRAM_NAME);\r
-  //\r
-  // Process the command-line arguments\r
-  //\r
-  Status = ProcessArgs (Argc, Argv);\r
-  if (Status == STATUS_SUCCESS) {\r
-    if (mOptions.Dump) {\r
-      DumpCapsule ();\r
-    } else if (mOptions.JoinMode) {\r
-      JoinCapsule ();\r
-    } else {\r
-      CreateCapsule ();\r
-    }\r
-  }\r
-  //\r
-  // Cleanup\r
-  //\r
-  while (mOptions.FileList != NULL) {\r
-    NextFile = mOptions.FileList->Next;\r
-    free (mOptions.FileList);\r
-    mOptions.FileList = NextFile;\r
-  }\r
-\r
-  while (mOptions.SizeList != NULL) {\r
-    mOptions.CurrentSize = mOptions.SizeList->Next;\r
-    free (mOptions.SizeList);\r
-    mOptions.SizeList = mOptions.CurrentSize;\r
-  }\r
-\r
-  return GetUtilityStatus ();\r
-}\r
-\r
-static\r
-STATUS\r
-CreateCapsule (\r
-  VOID\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  None\r
-\r
-Returns:\r
-\r
-  GC_TODO: add return values\r
-\r
---*/\r
-{\r
-  FILE                        *InFptr;\r
-  FILE_LIST                   *FileList;\r
-  INT8                        *Buffer;\r
-  UINT32                      Size;\r
-  EFI_CAPSULE_HEADER          CapsuleHeader;\r
-  UINT8                       Zero;\r
-  UINT8                       FirstFile;\r
-  UINT32                      CapsuleHeaderSize;\r
-  long                        InsertedBlockMapEntryOffset;\r
-  EFI_FV_BLOCK_MAP_ENTRY      InsertedBlockMapEntry;\r
-  UINT64                      FirmwareVolumeSize;\r
-  long                        FileSize;\r
-  EFI_FIRMWARE_VOLUME_HEADER  FVHeader;\r
-\r
-  Buffer                      = NULL;\r
-  InFptr                      = NULL;\r
-  FirmwareVolumeSize          = 0;\r
-  CapsuleHeaderSize           = 0;\r
-  InsertedBlockMapEntryOffset = 0;\r
-  memset (&InsertedBlockMapEntry, 0, sizeof (EFI_FV_BLOCK_MAP_ENTRY));\r
-  memset (&FVHeader, 0, sizeof (EFI_FIRMWARE_VOLUME_HEADER));\r
-\r
-  if ((mOptions.OutFptr = fopen (mOptions.OutputFileName, "wb")) == NULL) {\r
-    Error (NULL, 0, 0, mOptions.OutputFileName, "failed to open output file for writing");\r
-    return STATUS_ERROR;\r
-  }\r
-\r
-  memset ((char *) &CapsuleHeader, 0, sizeof (CapsuleHeader));\r
-  memcpy ((void *) &CapsuleHeader.CapsuleGuid, (void *) &mEfiCapsuleHeaderGuid, sizeof (EFI_GUID));\r
-  CapsuleHeader.HeaderSize        = sizeof (EFI_CAPSULE_HEADER);\r
-  CapsuleHeader.CapsuleImageSize  = sizeof (EFI_CAPSULE_HEADER);\r
-  if (mOptions.ScriptFileName[0] != 0) {\r
-    if (ProcessScriptFile (mOptions.ScriptFileName, mOptions.OutFptr, &CapsuleHeader) != STATUS_SUCCESS) {\r
-      goto Done;\r
-    }\r
-  } else {\r
-    //\r
-    // Insert a default capsule header\r
-#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
-    CapsuleHeader.HeaderSize = sizeof (EFI_CAPSULE_HEADER);\r
-    CapsuleHeader.Flags   = UEFI_CAPSULE_HEADER_ALL_FALAGS;\r
-#endif\r
-    CapsuleHeader.OffsetToCapsuleBody = sizeof (EFI_CAPSULE_HEADER);\r
-\r
-   if (fwrite ((void *) &CapsuleHeader, sizeof (CapsuleHeader), 1, mOptions.OutFptr) != 1) {\r
-     Error (NULL, 0, 0, mOptions.OutputFileName, "failed to write to file");\r
-     goto Done;\r
-   }\r
- }\r
-\r
-  CapsuleHeaderSize = CapsuleHeader.OffsetToCapsuleBody;\r
-  //\r
-  // Now copy the contents of any other files specified on the command\r
-  // line to the output file. Files must be FFS files, which are aligned\r
-  // on 8-byte boundaries. Don't align the first file, since it's the start\r
-  // of the image once the capsule header has been removed.\r
-  //\r
-  FileList  = mOptions.FileList;\r
-  FirstFile = 1;\r
-  Zero      = 0;\r
-  while (FileList != NULL) {\r
-    if ((InFptr = fopen (FileList->FileName, "rb")) == NULL) {\r
-      Error (NULL, 0, 0, FileList->FileName, "failed to open file for reading");\r
-      goto Done;\r
-    }\r
-    //\r
-    // Allocate a buffer into which we can read the file.\r
-    //\r
-    fseek (InFptr, 0, SEEK_END);\r
-    Size = ftell (InFptr);\r
-    rewind (InFptr);\r
-    Buffer = (char *) malloc (Size);\r
-    if (Buffer == NULL) {\r
-      Error (__FILE__, __LINE__, 0, FileList->FileName, "failed to allocate buffer to read file into");\r
-      goto Done;\r
-    }\r
-\r
-    if (fread ((void *) Buffer, Size, 1, InFptr) != 1) {\r
-      Error (NULL, 0, 0, FileList->FileName, "failed to read file contents");\r
-      goto Done;\r
-    }\r
-\r
-    if (Size > 0) {\r
-      //\r
-      // Align the write of the first bytes from the file if not the first file\r
-      //\r
-      if (FirstFile) {\r
-        //\r
-        // First file must be a firmware volume. Double-check, and then insert\r
-        // an additional block map entry so we can add more files from the command line\r
-        //\r
-        if (CheckFirmwareVolumeHeader (FileList->FileName, Buffer, Size) != STATUS_SUCCESS) {\r
-          goto Done;\r
-        }\r
-        //\r
-        // Save a copy of the firmware volume header for later\r
-        //\r
-        memcpy (&FVHeader, Buffer, sizeof (EFI_FIRMWARE_VOLUME_HEADER));\r
-        FirmwareVolumeSize = FVHeader.FvLength;\r
-        if (FileList->Next != NULL) {\r
-          //\r
-          // Copy the firmware volume header\r
-          //\r
-          InsertedBlockMapEntryOffset = CapsuleHeaderSize + FVHeader.HeaderLength;\r
-          if (fwrite (Buffer, FVHeader.HeaderLength, 1, mOptions.OutFptr) != 1) {\r
-            Error (NULL, 0, 0, mOptions.OutputFileName, "failed to write to file");\r
-            goto Done;\r
-          }\r
-\r
-          if (fwrite (&InsertedBlockMapEntry, sizeof (EFI_FV_BLOCK_MAP_ENTRY), 1, mOptions.OutFptr) != 1) {\r
-            Error (NULL, 0, 0, mOptions.OutputFileName, "failed to write to file");\r
-            goto Done;\r
-          }\r
-\r
-          if (fwrite (\r
-                Buffer + FVHeader.HeaderLength,\r
-                Size - FVHeader.HeaderLength,\r
-                1,\r
-                mOptions.OutFptr\r
-                ) != 1) {\r
-            Error (NULL, 0, 0, mOptions.OutputFileName, "failed to write to file");\r
-            goto Done;\r
-          }\r
-        } else {\r
-          //\r
-          // Copy the file contents as-is\r
-          //\r
-          if (fwrite ((void *) Buffer, Size, 1, mOptions.OutFptr) != 1) {\r
-            Error (NULL, 0, 0, mOptions.OutputFileName, "failed to write to file");\r
-            goto Done;\r
-          }\r
-        }\r
-      } else {\r
-        while ((ftell (mOptions.OutFptr) - CapsuleHeaderSize) & 0x07) {\r
-          if (fwrite ((void *) &Zero, 1, 1, mOptions.OutFptr) != 1) {\r
-            Error (NULL, 0, 0, mOptions.OutputFileName, "failed to write to file");\r
-            goto Done;\r
-          }\r
-        }\r
-\r
-        if (fwrite ((void *) Buffer, Size, 1, mOptions.OutFptr) != 1) {\r
-          Error (NULL, 0, 0, mOptions.OutputFileName, "failed to write to file");\r
-          goto Done;\r
-        }\r
-      }\r
-\r
-      FirstFile = 0;\r
-    }\r
-\r
-    free (Buffer);\r
-    Buffer = NULL;\r
-    fclose (InFptr);\r
-    InFptr    = NULL;\r
-    FileList  = FileList->Next;\r
-  }\r
-\r
-Done:\r
-  if (Buffer != NULL) {\r
-    free (Buffer);\r
-  }\r
-\r
-  if (InFptr != NULL) {\r
-    fclose (InFptr);\r
-  }\r
-  //\r
-  // If we inserted an additional block map entry, then fix it up. Fix up the\r
-  // FV header as well to reflect our new size.\r
-  //\r
-  if (InsertedBlockMapEntryOffset != 0) {\r
-    FileSize                        = ftell (mOptions.OutFptr);\r
-    InsertedBlockMapEntry.NumBlocks = 1;\r
-    InsertedBlockMapEntry.BlockLength = (UINT32) ((UINT64) FileSize - (UINT64) CapsuleHeaderSize - FirmwareVolumeSize - sizeof (EFI_FV_BLOCK_MAP_ENTRY));\r
-    fseek (mOptions.OutFptr, InsertedBlockMapEntryOffset, SEEK_SET);\r
-    fwrite (&InsertedBlockMapEntry, sizeof (EFI_FV_BLOCK_MAP_ENTRY), 1, mOptions.OutFptr);\r
-    //\r
-    // Fix up the firmware volume header and write it out\r
-    //\r
-    fseek (mOptions.OutFptr, CapsuleHeaderSize, SEEK_SET);\r
-    FVHeader.FvLength = FileSize - CapsuleHeaderSize;\r
-    FVHeader.HeaderLength += sizeof (EFI_FV_BLOCK_MAP_ENTRY);\r
-    fwrite (&FVHeader, sizeof (EFI_FIRMWARE_VOLUME_HEADER) - sizeof (EFI_FV_BLOCK_MAP_ENTRY), 1, mOptions.OutFptr);\r
-    //\r
-    // Reposition to the end of the file\r
-    //\r
-  }\r
-  //\r
-  // Close files and free the global string lists we allocated memory for\r
-  //\r
-  if (mOptions.OutFptr != NULL) {\r
-    //\r
-    // We should now know the full capsule image size. Update the header and write it again.\r
-    //\r
-    fseek (mOptions.OutFptr, 0, SEEK_END);\r
-    Size  = ftell (mOptions.OutFptr);\r
-    CapsuleHeader.CapsuleImageSize = Size;\r
-    fseek (mOptions.OutFptr, 0, SEEK_SET);\r
-    if (fwrite ((void *) &CapsuleHeader, sizeof (CapsuleHeader), 1, mOptions.OutFptr) != 1) {\r
-      Error (NULL, 0, 0, mOptions.OutputFileName, "failed to write to file");\r
-    }\r
-\r
-    fseek (mOptions.OutFptr, 0, SEEK_END);\r
-    fclose (mOptions.OutFptr);\r
-    mOptions.OutFptr = NULL;\r
-  }\r
-  //\r
-  // If they are doing split capsule output, then split it up now.\r
-  //\r
-  if ((mOptions.Dump == 0) && (GetUtilityStatus () == STATUS_SUCCESS) && (mOptions.SizeList != NULL)) {\r
-    SplitCapsule (mOptions.OutputFileName);\r
-  }\r
-\r
-  return STATUS_SUCCESS;\r
-}\r
-\r
-static\r
-STATUS\r
-ProcessScriptFile (\r
-  INT8                *ScriptFileName,\r
-  FILE                *OutFptr,\r
-  EFI_CAPSULE_HEADER  *CapsuleHeader\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Parse a capsule header script file.\r
-\r
-Arguments:\r
-  ScriptFileName    - name of script file to parse\r
-  OutFptr           - output to dump binary data\r
-  CapsuleHeader     - capsule header to update with size info\r
-                      of parsed fields in the script file\r
-\r
-Returns:\r
-  STATUS_SUCCESS - if all went well\r
-\r
---*/\r
-{\r
-#if 0\r
-  STATUS      Status;\r
-  SOURCE_FILE SourceFile;\r
-  WCHAR       *WScriptFileName;\r
-  BOOLEAN     InComment;\r
-\r
-  if (fwrite (CapsuleHeader, sizeof (EFI_CAPSULE_HEADER), 1, OutFptr) != 1) {\r
-    Error (NULL, 0, 0, "failed to write capsule header to output file", NULL);\r
-    return STATUS_ERROR;\r
-  }\r
-\r
-  memset (&SourceFile, 0, sizeof (SOURCE_FILE));\r
-  strcpy (SourceFile.FileName, ScriptFileName);\r
-\r
-  Status = STATUS_ERROR;\r
-  //\r
-  // Open the input unicode script file and read it into a buffer\r
-  //\r
-  WScriptFileName = (WCHAR *) malloc ((strlen (ScriptFileName) + 1) * sizeof (WCHAR));\r
-  if (WScriptFileName == NULL) {\r
-    Error (__FILE__, __LINE__, 0, "failed to allocate memory", NULL);\r
-    return STATUS_ERROR;\r
-  }\r
-\r
-  swprintf (WScriptFileName, L"%S", ScriptFileName);\r
-  if ((SourceFile.FilePtr = _wfopen (WScriptFileName, L"r")) == NULL) {\r
-    free (WScriptFileName);\r
-    Error (NULL, 0, 0, ScriptFileName, "failed to open script file for reading");\r
-    goto Done;\r
-  }\r
-\r
-  free (WScriptFileName);\r
-  fseek (SourceFile.FilePtr, 0, SEEK_END);\r
-  SourceFile.FileSize = ftell (SourceFile.FilePtr);\r
-  rewind (SourceFile.FilePtr);\r
-  SourceFile.FileBuffer = (WCHAR *) malloc (SourceFile.FileSize + sizeof (WCHAR));\r
-  if (SourceFile.FileBuffer == NULL) {\r
-    Error (__FILE__, __LINE__, 0, ScriptFileName, "failed to allocate memory to read in file contents");\r
-    goto Done;\r
-  }\r
-\r
-  if (fread (SourceFile.FileBuffer, SourceFile.FileSize, 1, SourceFile.FilePtr) != 1) {\r
-    Error (NULL, 0, 0, ScriptFileName, "failed to read file contents");\r
-    goto Done;\r
-  }\r
-\r
-  SourceFile.FileBufferPtr  = SourceFile.FileBuffer;\r
-  SourceFile.LineNum        = 1;\r
-  if (SourceFile.FileBuffer[0] != UNICODE_FILE_START) {\r
-    Error (ScriptFileName, 1, 0, "file does not appear to be a unicode file", NULL);\r
-    goto Done;\r
-  }\r
-\r
-  SourceFile.FileBufferPtr++;\r
-  SourceFile.FileBuffer[SourceFile.FileSize / sizeof (WCHAR)] = 0;\r
-  //\r
-  // Walk the source file buffer and replace all carriage returns with 0 so\r
-  // we can print from the file contents on parse errors.\r
-  //\r
-  InComment = 0;\r
-  while (!EndOfFile (&SourceFile)) {\r
-    if (SourceFile.FileBufferPtr[0] == UNICODE_CR) {\r
-      SourceFile.FileBufferPtr[0] = 0;\r
-      InComment                   = 0;\r
-    } else if (SourceFile.FileBufferPtr[0] == UNICODE_LF) {\r
-      InComment = 0;\r
-    } else if (InComment) {\r
-      SourceFile.FileBufferPtr[0] = UNICODE_SPACE;\r
-    } else if ((SourceFile.FileBufferPtr[0] == UNICODE_SLASH) && (SourceFile.FileBufferPtr[1] == UNICODE_SLASH)) {\r
-      InComment                   = 1;\r
-      SourceFile.FileBufferPtr[0] = UNICODE_SPACE;\r
-    }\r
-\r
-    SourceFile.FileBufferPtr++;\r
-  }\r
-  //\r
-  // Reposition to the start of the file, but skip over the unicode file start\r
-  //\r
-  SourceFile.FileBufferPtr = SourceFile.FileBuffer;\r
-  SourceFile.FileBufferPtr++;\r
-  SourceFile.EndOfFile                    = 0;\r
-  CapsuleHeader->OffsetToOemDefinedHeader = ftell (OutFptr);\r
-  //\r
-  // Parse the OEM bytes\r
-  //\r
-  if (ParseOemInfo (&SourceFile, OutFptr) != STATUS_SUCCESS) {\r
-    goto Done;\r
-  }\r
-  //\r
-  // Parse the author information\r
-  //\r
-  CapsuleHeader->OffsetToAuthorInformation = ftell (OutFptr);\r
-  if (ParseCapsuleInfo (&SourceFile, OutFptr, AUTHOR_INFO_STRING) != STATUS_SUCCESS) {\r
-    goto Done;\r
-  }\r
-  //\r
-  // Parse the revision information\r
-  //\r
-  CapsuleHeader->OffsetToRevisionInformation = ftell (OutFptr);\r
-  if (ParseCapsuleInfo (&SourceFile, OutFptr, REVISION_INFO_STRING) != STATUS_SUCCESS) {\r
-    goto Done;\r
-  }\r
-  //\r
-  // Parse the short description\r
-  //\r
-  CapsuleHeader->OffsetToShortDescription = ftell (OutFptr);\r
-  if (ParseCapsuleInfo (&SourceFile, OutFptr, SHORT_DESCRIPTION_STRING) != STATUS_SUCCESS) {\r
-    goto Done;\r
-  }\r
-  //\r
-  // Parse the long description\r
-  //\r
-  CapsuleHeader->OffsetToLongDescription = ftell (OutFptr);\r
-  if (ParseCapsuleInfo (&SourceFile, OutFptr, LONG_DESCRIPTION_STRING) != STATUS_SUCCESS) {\r
-    goto Done;\r
-  }\r
-  //\r
-  // Better be end of contents\r
-  //\r
-  SkipWhiteSpace (&SourceFile);\r
-  if (!EndOfFile (&SourceFile)) {\r
-    Error (ScriptFileName, SourceFile.LineNum, 0, NULL, "expected end-of-file, not %.20S", SourceFile.FileBufferPtr);\r
-    goto Done;\r
-  }\r
-\r
-  CapsuleHeader->OffsetToCapsuleBody = ftell (OutFptr);\r
-  rewind (OutFptr);\r
-  fwrite (CapsuleHeader, sizeof (EFI_CAPSULE_HEADER), 1, OutFptr);\r
-  fseek (OutFptr, 0, SEEK_END);\r
-  Status = STATUS_SUCCESS;\r
-Done:\r
-  if (SourceFile.FilePtr != NULL) {\r
-    fclose (SourceFile.FilePtr);\r
-  }\r
-\r
-  if (SourceFile.FileBuffer != NULL) {\r
-    free (SourceFile.FileBuffer);\r
-  }\r
-\r
-  return Status;\r
-\r
-#endif\r
-  return STATUS_SUCCESS;\r
-}\r
-//\r
-// Parse the OEM data of format:\r
-//      OemInfo {\r
-//            GUID = 12345676-1234-1234-123456789ABC\r
-//            DATA = 0x01, 0x02, 0x03...\r
-//      }\r
-//\r
-static\r
-STATUS\r
-ParseOemInfo (\r
-  SOURCE_FILE       *SourceFile,\r
-  FILE              *OutFptr\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  SourceFile  - GC_TODO: add argument description\r
-  OutFptr     - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
-  GC_TODO: add return values\r
-\r
---*/\r
-{\r
-  long                    OemHeaderOffset;\r
-  UINT32                  Data;\r
-  EFI_CAPSULE_OEM_HEADER  OemHeader;\r
-  STATUS                  Status;\r
-  UINT32                  DigitCount;\r
-  WCHAR                   *SaveFilePos;\r
-  UINT8                   ByteData;\r
-\r
-  Status = STATUS_ERROR;\r
-  memset (&OemHeader, 0, sizeof (EFI_CAPSULE_OEM_HEADER));\r
-  OemHeaderOffset       = ftell (OutFptr);\r
-  OemHeader.HeaderSize  = sizeof (EFI_CAPSULE_OEM_HEADER);\r
-  if (fwrite (&OemHeader, sizeof (EFI_CAPSULE_OEM_HEADER), 1, OutFptr) != 1) {\r
-    Error (NULL, 0, 0, "failed to write OEM header to output file", NULL);\r
-    goto Done;\r
-  }\r
-\r
-  if (!IsToken (SourceFile, OEM_HEADER_STRING)) {\r
-    Error (\r
-      SourceFile->FileName,\r
-      SourceFile->LineNum,\r
-      0,\r
-      NULL,\r
-      "expected %S, not %.20S",\r
-      OEM_HEADER_STRING,\r
-      SourceFile->FileBufferPtr\r
-      );\r
-    goto Done;\r
-  }\r
-\r
-  if (!IsToken (SourceFile, EQUAL_STRING)) {\r
-    Error (\r
-      SourceFile->FileName,\r
-      SourceFile->LineNum,\r
-      0,\r
-      NULL,\r
-      "expected %S, not %.20S",\r
-      EQUAL_STRING,\r
-      SourceFile->FileBufferPtr\r
-      );\r
-    goto Done;\r
-  }\r
-\r
-  if (!IsToken (SourceFile, OPEN_BRACE_STRING)) {\r
-    Error (\r
-      SourceFile->FileName,\r
-      SourceFile->LineNum,\r
-      0,\r
-      NULL,\r
-      "expected %S, not %.20S",\r
-      OPEN_BRACE_STRING,\r
-      SourceFile->FileBufferPtr\r
-      );\r
-    goto Done;\r
-  }\r
-  //\r
-  // Look for:  GUID = xxxxxxx-xxxx-xxxx-xxxxxxxxxxxxx\r
-  //\r
-  if (!IsToken (SourceFile, GUID_STRING)) {\r
-    Error (\r
-      SourceFile->FileName,\r
-      SourceFile->LineNum,\r
-      0,\r
-      NULL,\r
-      "expected %S, not %.20S",\r
-      GUID_STRING,\r
-      SourceFile->FileBufferPtr\r
-      );\r
-    goto Done;\r
-  }\r
-\r
-  if (!IsToken (SourceFile, EQUAL_STRING)) {\r
-    Error (\r
-      SourceFile->FileName,\r
-      SourceFile->LineNum,\r
-      0,\r
-      NULL,\r
-      "expected %S, not %.20S",\r
-      EQUAL_STRING,\r
-      SourceFile->FileBufferPtr\r
-      );\r
-    goto Done;\r
-  }\r
-  //\r
-  // Parse the xxxxxxxx-xxxx-xxxx-xxxx portion of the GUID\r
-  //\r
-  SkipWhiteSpace (SourceFile);\r
-  if (GetHexValue (SourceFile, &Data, 8) != STATUS_SUCCESS) {\r
-    Error (SourceFile->FileName, SourceFile->LineNum, 0, "invalid GUID", NULL);\r
-    goto Done;\r
-  }\r
-\r
-  OemHeader.OemGuid.Data1 = Data;\r
-  if (!IsToken (SourceFile, L"-")) {\r
-    Error (\r
-      SourceFile->FileName,\r
-      SourceFile->LineNum,\r
-      0,\r
-      NULL,\r
-      "expected dash in GUID, not %S",\r
-      SourceFile->FileBufferPtr\r
-      );\r
-    goto Done;\r
-  }\r
-  //\r
-  // Get 3 word values\r
-  //\r
-  for (DigitCount = 0; DigitCount < 3; DigitCount++) {\r
-    if (GetHexValue (SourceFile, &Data, 4) != STATUS_SUCCESS) {\r
-      Error (SourceFile->FileName, SourceFile->LineNum, 0, "invalid GUID", NULL);\r
-      goto Done;\r
-    }\r
-\r
-    switch (DigitCount) {\r
-    case 0:\r
-      OemHeader.OemGuid.Data2 = (UINT16) Data;\r
-      break;\r
-\r
-    case 1:\r
-      OemHeader.OemGuid.Data3 = (UINT16) Data;\r
-      break;\r
-\r
-    case 2:\r
-      OemHeader.OemGuid.Data4[1]  = (UINT8) Data;\r
-      OemHeader.OemGuid.Data4[0]  = (UINT8) (Data >> 8);\r
-      break;\r
-    }\r
-\r
-    if (!IsToken (SourceFile, L"-")) {\r
-      Error (\r
-        SourceFile->FileName,\r
-        SourceFile->LineNum,\r
-        0,\r
-        NULL,\r
-        "expected dash in GUID, not %S",\r
-        SourceFile->FileBufferPtr\r
-        );\r
-      goto Done;\r
-    }\r
-  }\r
-  //\r
-  // Pick up the last 6 bytes of the GUID\r
-  //\r
-  SaveFilePos = SourceFile->FileBufferPtr;\r
-  for (DigitCount = 0; DigitCount < 6; DigitCount++) {\r
-    if (GetHexValue (SourceFile, &Data, 2) != STATUS_SUCCESS) {\r
-      Error (SourceFile->FileName, SourceFile->LineNum, 0, "invalid GUID", NULL);\r
-      goto Done;\r
-    }\r
-\r
-    OemHeader.OemGuid.Data4[DigitCount + 2] = (UINT8) Data;\r
-  }\r
-  //\r
-  // Now read raw OEM data bytes. May or may not be present.\r
-  //    DATA = 0x01, 0x02, 0x02...\r
-  //\r
-  if (IsToken (SourceFile, CLOSE_BRACE_STRING)) {\r
-    Status = STATUS_SUCCESS;\r
-    goto Done;\r
-  }\r
-\r
-  if (!IsToken (SourceFile, DATA_STRING)) {\r
-    Error (\r
-      SourceFile->FileName,\r
-      SourceFile->LineNum,\r
-      0,\r
-      NULL,\r
-      "expected %S, not %.20S",\r
-      DATA_STRING,\r
-      SourceFile->FileBufferPtr\r
-      );\r
-    goto Done;\r
-  }\r
-\r
-  if (!IsToken (SourceFile, EQUAL_STRING)) {\r
-    Error (\r
-      SourceFile->FileName,\r
-      SourceFile->LineNum,\r
-      0,\r
-      NULL,\r
-      "expected %S, not %.20S",\r
-      EQUAL_STRING,\r
-      SourceFile->FileBufferPtr\r
-      );\r
-    goto Done;\r
-  }\r
-\r
-  while (!EndOfFile (SourceFile)) {\r
-    if (IsToken (SourceFile, CLOSE_BRACE_STRING)) {\r
-      Status = STATUS_SUCCESS;\r
-      goto Done;\r
-    }\r
-\r
-    if (IsToken (SourceFile, L"0x")) {\r
-      if (swscanf (SourceFile->FileBufferPtr, L"%x", &Data) != 1) {\r
-        Error (\r
-          SourceFile->FileName,\r
-          SourceFile->LineNum,\r
-          0,\r
-          NULL,\r
-          "expected hex byte value, not %.20S",\r
-          SourceFile->FileBufferPtr\r
-          );\r
-        goto Done;\r
-      }\r
-\r
-      if (Data &~0xFF) {\r
-        Error (\r
-          SourceFile->FileName,\r
-          SourceFile->LineNum,\r
-          0,\r
-          NULL,\r
-          "expected byte hex byte value at %.20S",\r
-          SourceFile->FileBufferPtr\r
-          );\r
-        goto Done;\r
-      }\r
-      //\r
-      // Skip over the hex digits, then write the data\r
-      //\r
-      while (iswxdigit (SourceFile->FileBufferPtr[0])) {\r
-        SourceFile->FileBufferPtr++;\r
-      }\r
-\r
-      ByteData = (UINT8) Data;\r
-      if (fwrite (&ByteData, 1, 1, OutFptr) != 1) {\r
-        Error (NULL, 0, 0, "failed to write OEM data to output file", NULL);\r
-        goto Done;\r
-      }\r
-\r
-      OemHeader.HeaderSize++;\r
-      //\r
-      // Optional comma\r
-      //\r
-      IsToken (SourceFile, L",");\r
-    } else {\r
-      Error (\r
-        SourceFile->FileName,\r
-        SourceFile->LineNum,\r
-        0,\r
-        NULL,\r
-        "expected hex OEM data, not %.20S",\r
-        SourceFile->FileBufferPtr\r
-        );\r
-      goto Done;\r
-    }\r
-  }\r
-\r
-  if (EndOfFile (SourceFile)) {\r
-    Error (\r
-      SourceFile->FileName,\r
-      SourceFile->LineNum,\r
-      0,\r
-      NULL,\r
-      "expected %S close to OEM header data",\r
-      CLOSE_BRACE_STRING\r
-      );\r
-    goto Done;\r
-  }\r
-\r
-  Status = STATUS_SUCCESS;\r
-Done:\r
-  //\r
-  // re-write the oem header if no errors\r
-  //\r
-  if (Status == STATUS_SUCCESS) {\r
-    fseek (OutFptr, OemHeaderOffset, SEEK_SET);\r
-    if (fwrite (&OemHeader, sizeof (EFI_CAPSULE_OEM_HEADER), 1, OutFptr) != 1) {\r
-      Error (NULL, 0, 0, "failed to write OEM header to output file", NULL);\r
-      goto Done;\r
-    }\r
-\r
-    fseek (OutFptr, 0, SEEK_END);\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-static\r
-STATUS\r
-ParseCapsuleInfo (\r
-  SOURCE_FILE       *SourceFile,\r
-  FILE              *OutFptr,\r
-  WCHAR             *SectionName\r
-  )\r
-// GC_TODO: function comment should start with '/*++'\r
-//\r
-// GC_TODO: function comment is missing 'Routine Description:'\r
-// GC_TODO: function comment is missing 'Arguments:'\r
-// GC_TODO: function comment is missing 'Returns:'\r
-// GC_TODO:    SourceFile - add argument and description to function comment\r
-// GC_TODO:    OutFptr - add argument and description to function comment\r
-// GC_TODO:    SectionName - add argument and description to function comment\r
-// Parse:  eng "string " "parts"\r
-//          spa "string " "parts"\r
-// Write out: "eng string parts\0spa string parts\0\0\r
-//\r
-{\r
-  STATUS  Status;\r
-  int     StringCount;\r
-  WCHAR   Zero;\r
-  WCHAR   Spacebar;\r
-\r
-  Status    = STATUS_ERROR;\r
-  Zero      = 0;\r
-  Spacebar  = UNICODE_SPACE;\r
-\r
-  if (!IsToken (SourceFile, SectionName)) {\r
-    Error (\r
-      SourceFile->FileName,\r
-      SourceFile->LineNum,\r
-      0,\r
-      NULL,\r
-      "expected %S, not %.20S",\r
-      SectionName,\r
-      SourceFile->FileBufferPtr\r
-      );\r
-    goto Done;\r
-  }\r
-\r
-  if (!IsToken (SourceFile, EQUAL_STRING)) {\r
-    Error (\r
-      SourceFile->FileName,\r
-      SourceFile->LineNum,\r
-      0,\r
-      NULL,\r
-      "expected %S, not %.20S",\r
-      EQUAL_STRING,\r
-      SourceFile->FileBufferPtr\r
-      );\r
-    goto Done;\r
-  }\r
-\r
-  if (!IsToken (SourceFile, OPEN_BRACE_STRING)) {\r
-    Error (\r
-      SourceFile->FileName,\r
-      SourceFile->LineNum,\r
-      0,\r
-      NULL,\r
-      "expected %S, not %.20S",\r
-      OPEN_BRACE_STRING,\r
-      SourceFile->FileBufferPtr\r
-      );\r
-    goto Done;\r
-  }\r
-\r
-  while (!EndOfFile (SourceFile)) {\r
-    if (IsToken (SourceFile, CLOSE_BRACE_STRING)) {\r
-      break;\r
-    }\r
-    //\r
-    // Look for language identifier (3 lowercase chars)\r
-    //\r
-    if ((SourceFile->FileBufferPtr[0] >= UNICODE_a) &&\r
-        (SourceFile->FileBufferPtr[0] <= UNICODE_z) &&\r
-        (SourceFile->FileBufferPtr[1] >= UNICODE_a) &&\r
-        (SourceFile->FileBufferPtr[1] <= UNICODE_z) &&\r
-        (SourceFile->FileBufferPtr[2] >= UNICODE_a) &&\r
-        (SourceFile->FileBufferPtr[2] <= UNICODE_z) &&\r
-        IsWhiteSpace (SourceFile->FileBufferPtr[3])\r
-          ) {\r
-      //\r
-      // Write the 3 chars followed by a spacebar, and then look for opening quote\r
-      //\r
-      fwrite (SourceFile->FileBufferPtr, sizeof (WCHAR), 1, OutFptr);\r
-      SourceFile->FileBufferPtr++;\r
-      fwrite (SourceFile->FileBufferPtr, sizeof (WCHAR), 1, OutFptr);\r
-      SourceFile->FileBufferPtr++;\r
-      fwrite (SourceFile->FileBufferPtr, sizeof (WCHAR), 1, OutFptr);\r
-      SourceFile->FileBufferPtr++;\r
-      fwrite (&Spacebar, sizeof (WCHAR), 1, OutFptr);\r
-      StringCount = 0;\r
-      while (IsToken (SourceFile, L"\"")) {\r
-        StringCount++;\r
-        while (!EndOfFile (SourceFile)) {\r
-          if (SourceFile->FileBufferPtr[0] == UNICODE_DOUBLE_QUOTE) {\r
-            SourceFile->FileBufferPtr++;\r
-            break;\r
-          } else if ((SourceFile->FileBufferPtr[0] == UNICODE_LF) || (SourceFile->FileBufferPtr[0] == 0)) {\r
-            Error (SourceFile->FileName, SourceFile->LineNum, 0, "missing closing quote on string", NULL);\r
-            goto Done;\r
-          } else {\r
-            fwrite (SourceFile->FileBufferPtr, sizeof (WCHAR), 1, OutFptr);\r
-            SourceFile->FileBufferPtr++;\r
-          }\r
-        }\r
-      }\r
-\r
-      if (StringCount == 0) {\r
-        Error (\r
-          SourceFile->FileName,\r
-          SourceFile->LineNum,\r
-          0,\r
-          NULL,\r
-          "expected quoted string, not %.20S",\r
-          SourceFile->FileBufferPtr\r
-          );\r
-        goto Done;\r
-      }\r
-      //\r
-      // This string's null terminator\r
-      //\r
-      fwrite (&Zero, sizeof (WCHAR), 1, OutFptr);\r
-    } else {\r
-      Error (\r
-        SourceFile->FileName,\r
-        SourceFile->LineNum,\r
-        0,\r
-        NULL,\r
-        "expected valid language identifer, not %.20S",\r
-        SourceFile->FileBufferPtr\r
-        );\r
-      goto Done;\r
-    }\r
-  }\r
-  //\r
-  // Double null terminator\r
-  //\r
-  fwrite (&Zero, sizeof (WCHAR), 1, OutFptr);\r
-  Status = STATUS_SUCCESS;\r
-Done:\r
-  return Status;\r
-}\r
-\r
-static\r
-STATUS\r
-SplitCapsule (\r
-  INT8    *CapsuleFileName\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  We've created an entire capsule image. Now split it up into the \r
-  size pieces they requested.\r
-\r
-Arguments:\r
-  CapsuleFileName  - name of an existing capsule file on disk\r
-\r
-Returns:\r
-  STATUS_SUCCESS - if no problems\r
-\r
-Notes:\r
-  This implementation reads in the entire capsule image from\r
-  disk, then overwrites the original file with the first\r
-  in the series.\r
-\r
---*/\r
-{\r
-#if 0\r
-  EFI_CAPSULE_HEADER  *CapHdr;\r
-\r
-  EFI_CAPSULE_HEADER  Hdr;\r
-  FILE                *CapFptr;\r
-  FILE                *OutFptr;\r
-  UINT32              SizeLeft;\r
-  UINT32              CurrentSize;\r
-  UINT32              DataSize;\r
-  UINT32              SequenceNumber;\r
-  INT8                *Buffer;\r
-  INT8                FileName[MAX_PATH];\r
-  STATUS              Status;\r
-  UINT32              FileSize;\r
-  //\r
-  // Figure out the total size, then rewind the input file and\r
-  // read the entire thing in\r
-  //\r
-  if ((CapFptr = fopen (CapsuleFileName, "rb")) == NULL) {\r
-    Error (NULL, 0, 0, CapsuleFileName, "failed to open capsule image for reading");\r
-    return STATUS_ERROR;\r
-  }\r
-\r
-  OutFptr = NULL;\r
-  Status  = STATUS_SUCCESS;\r
-  fseek (CapFptr, 0, SEEK_END);\r
-  SizeLeft = ftell (CapFptr);\r
-  fseek (CapFptr, 0, SEEK_SET);\r
-  CapHdr = (EFI_CAPSULE_HEADER *) malloc (SizeLeft);\r
-  if (CapHdr == NULL) {\r
-    Error (NULL, 0, 0, "memory allocation failure", NULL);\r
-    goto FailDone;\r
-  }\r
-\r
-  if (fread (CapHdr, SizeLeft, 1, CapFptr) != 1) {\r
-    Error (NULL, 0, 0, "failed to read capsule contents", "split failed");\r
-    goto FailDone;\r
-  }\r
-\r
-  fclose (CapFptr);\r
-  CapFptr = NULL;\r
-  //\r
-  // Get a GUID to fill in the InstanceId GUID in the header\r
-  //\r
-  CreateGuid (&CapHdr->InstanceId);\r
-  SequenceNumber = 0;\r
-  //\r
-  // If the split size is larger than the original capsule image, then\r
-  // we're done.\r
-  //\r
-  if (mOptions.SizeList->Size >= SizeLeft) {\r
-    mOptions.SizeList->Size = SizeLeft;\r
-    goto Done;\r
-  }\r
-  //\r
-  // First size has to be big enough for the original header\r
-  //\r
-  if (mOptions.SizeList->Size < CapHdr->OffsetToCapsuleBody) {\r
-    Error (NULL, 0, 0, "first split size is insufficient for the original capsule header", NULL);\r
-    goto FailDone;\r
-  }\r
-  //\r
-  // Initialize the header we'll use on all but the first part\r
-  //\r
-  memset (&Hdr, 0, sizeof (Hdr));\r
-  Hdr.CapsuleGuid         = CapHdr->CapsuleGuid;\r
-  Hdr.HeaderSize          = sizeof (Hdr);\r
-  Hdr.Flags               = CapHdr->Flags;\r
-  Hdr.InstanceId          = CapHdr->InstanceId;\r
-  Hdr.CapsuleImageSize    = CapHdr->CapsuleImageSize;\r
-  Hdr.OffsetToCapsuleBody = Hdr.HeaderSize;\r
-  Hdr.SequenceNumber      = 1;\r
-  //\r
-  // printf ("Created %s - 0x%X bytes\n", CapsuleFileName, mOptions.SizeList->Size);\r
-  //\r
-  Buffer = (UINT8 *) CapHdr;\r
-  //\r
-  // Walk the list of sizes and write out a capsule header, and\r
-  // then the raw capsule data.\r
-  //\r
-  //  SizeLeft -= mOptions.SizeList->Size;\r
-  //\r
-  mOptions.CurrentSize = mOptions.SizeList;\r
-  while (SizeLeft) {\r
-    CurrentSize = mOptions.CurrentSize->Size;\r
-    GetSplitFileName (mOptions.OutputFileName, FileName, SequenceNumber);\r
-    if ((OutFptr = fopen (FileName, "wb")) == NULL) {\r
-      Error (NULL, 0, 0, FileName, "failed to open split file for writing");\r
-      goto FailDone;\r
-    }\r
-\r
-    if (Buffer == (UINT8 *) CapHdr) {\r
-      //\r
-      // First part -- write out original header and data\r
-      //\r
-      if (fwrite (Buffer, CurrentSize, 1, OutFptr) != 1) {\r
-        Error (NULL, 0, 0, FileName, "failed to write to split image file");\r
-        goto FailDone;\r
-      }\r
-\r
-      SizeLeft -= CurrentSize;\r
-      Buffer += CurrentSize;\r
-      DataSize  = CurrentSize;\r
-      FileSize  = CurrentSize;\r
-    } else {\r
-      //\r
-      // Not the first part. Write the default header, and then the raw bytes from the\r
-      // original image.\r
-      //\r
-      if (CurrentSize <= sizeof (Hdr)) {\r
-        Error (NULL, 0, 0, "split size too small for capsule header + data", "0x%X", CurrentSize);\r
-        goto FailDone;\r
-      }\r
-\r
-      DataSize = CurrentSize - sizeof (Hdr);\r
-      if (DataSize > SizeLeft) {\r
-        DataSize = SizeLeft;\r
-      }\r
-\r
-      if (fwrite (&Hdr, sizeof (Hdr), 1, OutFptr) != 1) {\r
-        Error (NULL, 0, 0, FileName, "failed to write capsule header to output file");\r
-        fclose (OutFptr);\r
-        goto FailDone;\r
-      }\r
-\r
-      if (fwrite (Buffer, DataSize, 1, OutFptr) != 1) {\r
-        Error (NULL, 0, 0, FileName, "failed to write capsule data to output file");\r
-        fclose (OutFptr);\r
-        goto FailDone;\r
-      }\r
-\r
-      Hdr.SequenceNumber++;\r
-      Buffer += DataSize;\r
-      SizeLeft -= DataSize;\r
-      FileSize = DataSize + sizeof (Hdr);\r
-    }\r
-    //\r
-    // Next size in list if there is one\r
-    //\r
-    if (mOptions.CurrentSize->Next != NULL) {\r
-      mOptions.CurrentSize = mOptions.CurrentSize->Next;\r
-    }\r
-\r
-    SequenceNumber++;\r
-    fclose (OutFptr);\r
-    OutFptr = NULL;\r
-    printf ("Created %s - 0x%X bytes (0x%X bytes of data)\n", FileName, FileSize, DataSize);\r
-  }\r
-\r
-  goto Done;\r
-FailDone:\r
-  Status = STATUS_ERROR;\r
-Done:\r
-  if (CapHdr != NULL) {\r
-    free (CapHdr);\r
-  }\r
-\r
-  if (CapFptr != NULL) {\r
-    fclose (CapFptr);\r
-  }\r
-\r
-  if (OutFptr != NULL) {\r
-    fclose (OutFptr);\r
-  }\r
-\r
-  return Status;\r
-\r
-#endif\r
-   return STATUS_SUCCESS;\r
-}\r
-\r
-static\r
-BOOLEAN\r
-GetSplitFileName (\r
-  INT8    *BaseFileName,\r
-  INT8    *NewFileName,\r
-  UINT32  SequenceNumber\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  BaseFileName    - GC_TODO: add argument description\r
-  NewFileName     - GC_TODO: add argument description\r
-  SequenceNumber  - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
-  GC_TODO: add return values\r
-\r
---*/\r
-{\r
-  /*++\r
-\r
-Routine Description:\r
-  Given an initial split capsule file name and a sequence number,\r
-  create an appropriate file name for this split of a capsule image.\r
-\r
-Arguments:\r
-  BaseFileName   - name of of the first split file in the series\r
-  NewFileName    - output name of the split file\r
-  SequenceNumber - 0-based sequence number of split images\r
-\r
-Returns:\r
-  TRUE   - name created successfully\r
-  FALSE  - otherwise\r
-\r
---*/\r
-  INT8    *Ptr;\r
-  INT8    *Part2Start;\r
-  UINT32  Digits;\r
-  UINT32  Len;\r
-  UINT32  BaseOffset;\r
-  //\r
-  // Work back from the end of the file name and see if there is a number somewhere\r
-  //\r
-  for (Ptr = BaseFileName + strlen (BaseFileName) - 1; (Ptr > BaseFileName) && !isdigit (*Ptr); Ptr--)\r
-    ;\r
-  if ((Ptr == BaseFileName) && (!isdigit (*Ptr))) {\r
-    //\r
-    // Found no number, so just add it to the end\r
-    //\r
-    sprintf (NewFileName, "%s%d", BaseFileName, SequenceNumber);\r
-    return TRUE;\r
-  } else {\r
-    //\r
-    // Found a number. Look back to find the first digit.\r
-    //\r
-    Part2Start = Ptr + 1;\r
-    for (Digits = 1; isdigit (*Ptr) && (Ptr > BaseFileName); Ptr--, Digits++)\r
-      ;\r
-    if (!isdigit (*Ptr)) {\r
-      Ptr++;\r
-      Digits--;\r
-    }\r
-\r
-    BaseOffset      = atoi (Ptr);\r
-    SequenceNumber  = SequenceNumber + BaseOffset;\r
-    if (Digits > 1) {\r
-      //\r
-      // Copy the first part of the original file name to the new filename\r
-      // This is the path for filenames with format path\name001.cap\r
-      //\r
-      Len = (UINT32) Ptr - (UINT32) BaseFileName;\r
-      strncpy (NewFileName, BaseFileName, Len);\r
-      sprintf (NewFileName + Len, "%0*d", Digits, SequenceNumber);\r
-      strcat (NewFileName, Part2Start);\r
-      return TRUE;\r
-    } else {\r
-      //\r
-      // Only one digit found. This is the path for filenames with\r
-      // format path\name1.cap\r
-      //\r
-      Len = (UINT32) Ptr - (UINT32) BaseFileName + 1;\r
-      strncpy (NewFileName, BaseFileName, Len);\r
-      sprintf (NewFileName + Len - 1, "%d", SequenceNumber);\r
-      strcat (NewFileName, Part2Start);\r
-      return TRUE;\r
-    }\r
-  }\r
-}\r
-\r
-static\r
-BOOLEAN\r
-IsWhiteSpace (\r
-  WCHAR  Char\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  Char  - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
-  GC_TODO: add return values\r
-\r
---*/\r
-{\r
-  switch (Char) {\r
-  case UNICODE_SPACE:\r
-  case UNICODE_TAB:\r
-  case UNICODE_NULL:\r
-  case UNICODE_CR:\r
-  case UNICODE_LF:\r
-    return TRUE;\r
-\r
-  default:\r
-    return FALSE;\r
-  }\r
-}\r
-\r
-static\r
-BOOLEAN\r
-IsToken (\r
-  SOURCE_FILE *File,\r
-  WCHAR       *Token\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  File  - GC_TODO: add argument description\r
-  Token - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
-  GC_TODO: add return values\r
-\r
---*/\r
-{\r
-  SkipWhiteSpace (File);\r
-  if (EndOfFile (File)) {\r
-    return FALSE;\r
-  }\r
-\r
-  if (wcsncmp (Token, File->FileBufferPtr, wcslen (Token)) == 0) {\r
-    File->FileBufferPtr += wcslen (Token);\r
-    return TRUE;\r
-  }\r
-\r
-  return FALSE;\r
-}\r
-\r
-static\r
-STATUS\r
-CheckFirmwareVolumeHeader (\r
-  INT8    *FileName,\r
-  INT8    *Buffer,\r
-  UINT32  BufferSize\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  FileName    - GC_TODO: add argument description\r
-  Buffer      - GC_TODO: add argument description\r
-  BufferSize  - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
-  GC_TODO: add return values\r
-\r
---*/\r
-{\r
-  EFI_FIRMWARE_VOLUME_HEADER  *Hdr;\r
-  EFI_GUID                    FVHeaderGuid = EFI_FIRMWARE_FILE_SYSTEM_GUID;\r
-\r
-  Hdr           = (EFI_FIRMWARE_VOLUME_HEADER *) Buffer;\r
-  if (Hdr->Signature != EFI_FVH_SIGNATURE) {\r
-    Error (NULL, 0, 0, FileName, "file does not appear to be a firmware volume (bad signature)");\r
-    return STATUS_ERROR;\r
-  }\r
-\r
-  if (Hdr->Revision != EFI_FVH_REVISION) {\r
-    Error (NULL, 0, 0, FileName, "unsupported firmware volume header version");\r
-    return STATUS_ERROR;\r
-  }\r
-\r
-  if (Hdr->FvLength > BufferSize) {\r
-    Error (NULL, 0, 0, FileName, "malformed firmware volume -- FvLength > file size");\r
-    return STATUS_ERROR;\r
-  }\r
-\r
-  if (memcmp (&Hdr->FileSystemGuid, &FVHeaderGuid, sizeof (EFI_GUID)) != 0) {\r
-    Error (NULL, 0, 0, FileName, "invalid FFS GUID in firmware volume header");\r
-    return STATUS_ERROR;\r
-  }\r
-\r
-  return STATUS_SUCCESS;\r
-}\r
-\r
-static\r
-void\r
-DumpCapsule (\r
-  VOID\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  None\r
-\r
-Returns:\r
-\r
-  GC_TODO: add return values\r
-\r
---*/\r
-{\r
-#if 0\r
-  FILE                        *InFptr;\r
-  FILE_LIST                   *FileList;\r
-  EFI_CAPSULE_HEADER          CapsuleHeader;\r
-  EFI_FIRMWARE_VOLUME_HEADER  FVHeader;\r
-  EFI_CAPSULE_OEM_HEADER      *OemHeader;\r
-  UINT8                       *BPtr;\r
-  UINT32                      FileSize;\r
-  UINT32                      CapsuleHeaderDataSize;\r
-  UINT8                       ByteCount;\r
-  UINT8                       *CapsuleHeaderData;\r
-  BOOLEAN                     SplitImage;\r
-\r
-  InFptr            = NULL;\r
-  CapsuleHeaderData = NULL;\r
-  FileList          = mOptions.FileList;\r
-  while (FileList != NULL) {\r
-    if ((InFptr = fopen (FileList->FileName, "rb")) == NULL) {\r
-      Error (NULL, 0, 0, FileList->FileName, "failed to open file for reading");\r
-      goto Done;\r
-    }\r
-\r
-    if (fread (&CapsuleHeader, sizeof (EFI_CAPSULE_HEADER), 1, InFptr) != 1) {\r
-      Error (NULL, 0, 0, FileList->FileName, "failed to read capsule header");\r
-      goto Done;\r
-    }\r
-\r
-    fseek (InFptr, 0, SEEK_END);\r
-    FileSize = ftell (InFptr);\r
-    if (CapsuleHeader.CapsuleImageSize > FileSize) {\r
-      SplitImage = TRUE;\r
-    } else {\r
-      SplitImage = FALSE;\r
-    }\r
-\r
-    printf (\r
-      "Capsule %s Size=0x%X CargoSize=0x%X\n",\r
-      FileList->FileName,\r
-      FileSize,\r
-      FileSize - CapsuleHeader.OffsetToCapsuleBody\r
-      );\r
-    printf (\r
-      "  GUID                  %08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X",\r
-      CapsuleHeader.CapsuleGuid.Data1,\r
-      (UINT32) CapsuleHeader.CapsuleGuid.Data2,\r
-      (UINT32) CapsuleHeader.CapsuleGuid.Data3,\r
-      (UINT32) CapsuleHeader.CapsuleGuid.Data4[0],\r
-      (UINT32) CapsuleHeader.CapsuleGuid.Data4[1],\r
-      (UINT32) CapsuleHeader.CapsuleGuid.Data4[2],\r
-      (UINT32) CapsuleHeader.CapsuleGuid.Data4[3],\r
-      (UINT32) CapsuleHeader.CapsuleGuid.Data4[4],\r
-      (UINT32) CapsuleHeader.CapsuleGuid.Data4[5],\r
-      (UINT32) CapsuleHeader.CapsuleGuid.Data4[6],\r
-      (UINT32) CapsuleHeader.CapsuleGuid.Data4[7]\r
-      );\r
-    if (memcmp (&CapsuleHeader.CapsuleGuid, &mEfiCapsuleHeaderGuid, sizeof (EFI_GUID)) != 0) {\r
-      printf ("  INVALID GUID");\r
-    }\r
-\r
-    printf ("\n");\r
-    printf ("  Header size           0x%08X\n", CapsuleHeader.HeaderSize);\r
-    printf ("  Flags                 0x%08X\n", CapsuleHeader.Flags);\r
-    if (!SplitImage) {\r
-      printf ("  Capsule image size    0x%08X\n", CapsuleHeader.CapsuleImageSize);\r
-    } else {\r
-      printf ("  Capsule image size    0x%08X (split)\n", CapsuleHeader.CapsuleImageSize);\r
-    }\r
-\r
-    printf ("  Sequence number       %d\n", CapsuleHeader.SequenceNumber);\r
-    printf (\r
-      "  InstanceId            %08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X\n",\r
-      CapsuleHeader.InstanceId.Data1,\r
-      (UINT32) CapsuleHeader.InstanceId.Data2,\r
-      (UINT32) CapsuleHeader.InstanceId.Data3,\r
-      (UINT32) CapsuleHeader.InstanceId.Data4[0],\r
-      (UINT32) CapsuleHeader.InstanceId.Data4[1],\r
-      (UINT32) CapsuleHeader.InstanceId.Data4[2],\r
-      (UINT32) CapsuleHeader.InstanceId.Data4[3],\r
-      (UINT32) CapsuleHeader.InstanceId.Data4[4],\r
-      (UINT32) CapsuleHeader.InstanceId.Data4[5],\r
-      (UINT32) CapsuleHeader.InstanceId.Data4[6],\r
-      (UINT32) CapsuleHeader.InstanceId.Data4[7]\r
-      );\r
-    printf ("  Offset to capsule     0x%X\n", CapsuleHeader.OffsetToCapsuleBody);\r
-    //\r
-    // Dump header data if there\r
-    //\r
-    CapsuleHeaderDataSize = CapsuleHeader.OffsetToCapsuleBody - CapsuleHeader.HeaderSize;\r
-    if (CapsuleHeaderDataSize != 0) {\r
-      CapsuleHeaderData = (UINT8 *) malloc (CapsuleHeaderDataSize);\r
-      if (CapsuleHeaderData == NULL) {\r
-        Error (\r
-          NULL,\r
-          0,\r
-          0,\r
-          "failed to allocate memory to read in capsule header data",\r
-          "0x%X bytes",\r
-          CapsuleHeaderDataSize\r
-          );\r
-        goto Done;\r
-      }\r
-\r
-      fseek (InFptr, CapsuleHeader.HeaderSize, SEEK_SET);\r
-      if (fread (CapsuleHeaderData, CapsuleHeaderDataSize, 1, InFptr) != 1) {\r
-        Error (\r
-          NULL,\r
-          0,\r
-          0,\r
-          "failed to read capsule header data contents from file",\r
-          "0x%X bytes",\r
-          CapsuleHeaderDataSize\r
-          );\r
-        goto Done;\r
-      }\r
-      //\r
-      // ************************************************************************\r
-      //\r
-      // OEM HEADER\r
-      //\r
-      // ************************************************************************\r
-      //\r
-      if (CapsuleHeader.OffsetToOemDefinedHeader != 0) {\r
-        OemHeader = (EFI_CAPSULE_OEM_HEADER *) (CapsuleHeaderData + CapsuleHeader.OffsetToOemDefinedHeader - CapsuleHeader.HeaderSize);\r
-        printf ("  OEM Header\n");\r
-        printf (\r
-          "    GUID                %08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X\n",\r
-          OemHeader->OemGuid.Data1,\r
-          (UINT32) OemHeader->OemGuid.Data2,\r
-          (UINT32) OemHeader->OemGuid.Data3,\r
-          (UINT32) OemHeader->OemGuid.Data4[0],\r
-          (UINT32) OemHeader->OemGuid.Data4[1],\r
-          (UINT32) OemHeader->OemGuid.Data4[2],\r
-          (UINT32) OemHeader->OemGuid.Data4[3],\r
-          (UINT32) OemHeader->OemGuid.Data4[4],\r
-          (UINT32) OemHeader->OemGuid.Data4[5],\r
-          (UINT32) OemHeader->OemGuid.Data4[6],\r
-          (UINT32) OemHeader->OemGuid.Data4[7]\r
-          );\r
-        printf ("    Header size:        0x%X\n", OemHeader->HeaderSize);\r
-        printf ("    OEM data");\r
-        BPtr = (UINT8 *) (OemHeader + 1);\r
-        for (ByteCount = 0; ByteCount < OemHeader->HeaderSize - sizeof (EFI_CAPSULE_OEM_HEADER); ByteCount++) {\r
-          if ((ByteCount & 0x7) == 0) {\r
-            printf ("\n      ");\r
-          }\r
-\r
-          printf ("%02X ", (UINT32) *BPtr);\r
-          BPtr++;\r
-        }\r
-\r
-        printf ("\n");\r
-      }\r
-      //\r
-      // ************************************************************************\r
-      //\r
-      // Author, revision, short description, and long description information\r
-      //\r
-      // ************************************************************************\r
-      //\r
-      if (CapsuleHeader.OffsetToAuthorInformation != 0) {\r
-        if (DumpCapsuleHeaderStrings (\r
-              "Author information",\r
-              (WCHAR *) (CapsuleHeaderData + CapsuleHeader.OffsetToAuthorInformation - CapsuleHeader.HeaderSize)\r
-              ) != STATUS_SUCCESS) {\r
-          goto Done;\r
-        }\r
-      }\r
-\r
-      if (CapsuleHeader.OffsetToRevisionInformation != 0) {\r
-        if (DumpCapsuleHeaderStrings (\r
-              "Revision information",\r
-              (WCHAR *) (CapsuleHeaderData + CapsuleHeader.OffsetToRevisionInformation - CapsuleHeader.HeaderSize)\r
-              ) != STATUS_SUCCESS) {\r
-          goto Done;\r
-        }\r
-      }\r
-\r
-      if (CapsuleHeader.OffsetToShortDescription != 0) {\r
-        if (DumpCapsuleHeaderStrings (\r
-              "Short description",\r
-              (WCHAR *) (CapsuleHeaderData + CapsuleHeader.OffsetToShortDescription - CapsuleHeader.HeaderSize)\r
-              ) != STATUS_SUCCESS) {\r
-          goto Done;\r
-        }\r
-      }\r
-\r
-      if (CapsuleHeader.OffsetToLongDescription != 0) {\r
-        if (DumpCapsuleHeaderStrings (\r
-              "Long description",\r
-              (WCHAR *) (CapsuleHeaderData + CapsuleHeader.OffsetToLongDescription - CapsuleHeader.HeaderSize)\r
-              ) != STATUS_SUCCESS) {\r
-          goto Done;\r
-        }\r
-      }\r
-    }\r
-    //\r
-    // If it's not a split image, or it is a split image and this is the first in the series, then\r
-    // dump the cargo volume.\r
-    //\r
-    if ((!SplitImage) || (CapsuleHeader.SequenceNumber == 0)) {\r
-      printf ("  Cargo FV dump\n");\r
-      fseek (InFptr, CapsuleHeader.OffsetToCapsuleBody, SEEK_SET);\r
-      if (fread (&FVHeader, sizeof (EFI_FIRMWARE_VOLUME_HEADER), 1, InFptr) != 1) {\r
-        Error (NULL, 0, 0, FileList->FileName, "failed to read cargo FV header");\r
-        goto Done;\r
-      }\r
-\r
-      printf ("    FV length           0x%X", FVHeader.FvLength);\r
-      if (FileSize - CapsuleHeader.OffsetToCapsuleBody != FVHeader.FvLength) {\r
-        if (!SplitImage) {\r
-          printf (" ERROR: expected 0x%X to jive with file size on disk", FileSize - CapsuleHeader.OffsetToCapsuleBody);\r
-        }\r
-      }\r
-\r
-      printf ("\n");\r
-      printf ("    Signature           0x%X ", FVHeader.Signature);\r
-      if (FVHeader.Signature == EFI_FVH_SIGNATURE) {\r
-        printf ("_FVH\n");\r
-      } else {\r
-        printf ("INVALID\n");\r
-      }\r
-\r
-      printf ("    FV header length    0x%X\n", (UINT32) FVHeader.HeaderLength);\r
-      printf ("    Revision            0x%X\n", (UINT32) FVHeader.Revision);\r
-      printf ("\n");\r
-    }\r
-\r
-    FileList = FileList->Next;\r
-  }\r
-\r
-Done:\r
-  if (InFptr != NULL) {\r
-    fclose (InFptr);\r
-  }\r
-\r
-  if (CapsuleHeaderData != NULL) {\r
-    free (CapsuleHeaderData);\r
-  }\r
-#endif\r
-}\r
-\r
-static\r
-STATUS\r
-JoinCapsule (\r
-  VOID\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Join split capsule images into a single image. This is the\r
-  support function for the -j command-line option.\r
-\r
-Arguments:\r
-  None.\r
-\r
-Returns:\r
-  STATUS_SUCCESS - no problems encountered\r
-\r
---*/\r
-{\r
-#if 0\r
-  UINT32              Size;\r
-  FILE                *InFptr;\r
-  FILE                *OutFptr;\r
-  INT8                *Buffer;\r
-  FILE_LIST           *FileList;\r
-  STATUS              Status;\r
-  EFI_CAPSULE_HEADER  CapHdr;\r
-  EFI_CAPSULE_HEADER  *CapHdrPtr;\r
-  UINT32              SizeLeft;\r
-  UINT32              SequenceNumber;\r
-  //\r
-  // Must have at least two files for join mode\r
-  //\r
-  if ((mOptions.FileList == NULL) || (mOptions.FileList->Next == NULL)) {\r
-    Error (NULL, 0, 0, "must specify at least two file names to join", NULL);\r
-    return STATUS_ERROR;\r
-  }\r
-  //\r
-  // Open the output file\r
-  //\r
-  if ((OutFptr = fopen (mOptions.OutputFileName, "wb")) == NULL) {\r
-    Error (NULL, 0, 0, mOptions.OutputFileName, "failed to open output file for writing");\r
-    return STATUS_ERROR;\r
-  }\r
-\r
-  FileList        = mOptions.FileList;\r
-  Buffer          = NULL;\r
-  SequenceNumber  = 0;\r
-  InFptr          = NULL;\r
-  SizeLeft        = 0;\r
-  while (FileList != NULL) {\r
-    if ((InFptr = fopen (FileList->FileName, "rb")) == NULL) {\r
-      Error (NULL, 0, 0, FileList->FileName, "failed to open file for reading");\r
-      goto FailDone;\r
-    }\r
-    //\r
-    // Allocate a buffer into which we can read the file.\r
-    //\r
-    fseek (InFptr, 0, SEEK_END);\r
-    Size = ftell (InFptr);\r
-    rewind (InFptr);\r
-    Buffer = (char *) malloc (Size);\r
-    if (Buffer == NULL) {\r
-      Error (__FILE__, __LINE__, 0, FileList->FileName, "failed to allocate buffer to read file into");\r
-      goto FailDone;\r
-    }\r
-\r
-    CapHdrPtr = (EFI_CAPSULE_HEADER *) Buffer;\r
-    if (fread ((void *) Buffer, Size, 1, InFptr) != 1) {\r
-      Error (NULL, 0, 0, FileList->FileName, "failed to read file contents");\r
-      goto FailDone;\r
-    }\r
-    //\r
-    // Check the header for validity. Check size first.\r
-    //\r
-    if (Size < sizeof (EFI_CAPSULE_HEADER)) {\r
-      Error (NULL, 0, 0, FileList->FileName, "file size is insufficient for a capsule header");\r
-      goto FailDone;\r
-    }\r
-    //\r
-    // Check GUID\r
-    //\r
-    if (memcmp (&CapHdrPtr->CapsuleGuid, &mEfiCapsuleHeaderGuid, sizeof (EFI_GUID)) != 0) {\r
-      Error (NULL, 0, 0, FileList->FileName, "invalid capsule GUID");\r
-      goto FailDone;\r
-    }\r
-    //\r
-    // Check sequence number\r
-    //\r
-    if (CapHdrPtr->SequenceNumber != SequenceNumber) {\r
-      Error (\r
-        NULL,\r
-        0,\r
-        0,\r
-        FileList->FileName,\r
-        "invalid sequence number %d (expected %d)",\r
-        CapHdrPtr->SequenceNumber,\r
-        SequenceNumber\r
-        );\r
-      goto FailDone;\r
-    }\r
-    //\r
-    // If the first file, read save the capsule header\r
-    //\r
-    if (SequenceNumber == 0) {\r
-      memcpy (&CapHdr, CapHdrPtr, sizeof (EFI_CAPSULE_HEADER));\r
-      //\r
-      // Erase the InstanceId GUID\r
-      //\r
-      memset (&CapHdrPtr->InstanceId, 0, sizeof (EFI_GUID));\r
-      if (fwrite (Buffer, Size, 1, OutFptr) != 1) {\r
-        Error (NULL, 0, 0, FileList->FileName, "failed to write contents to output file");\r
-        goto FailDone;\r
-      }\r
-\r
-      if (CapHdr.CapsuleImageSize < Size) {\r
-        Error (NULL, 0, 0, FileList->FileName, "capsule image size in capsule header < image size");\r
-        goto FailDone;\r
-      }\r
-\r
-      SizeLeft = CapHdr.CapsuleImageSize - Size;\r
-    } else {\r
-      //\r
-      // Check the GUID against the first file's GUID\r
-      //\r
-      if (memcmp (&CapHdr.CapsuleGuid, &CapHdrPtr->CapsuleGuid, sizeof (EFI_GUID)) != 0) {\r
-        Error (NULL, 0, 0, FileList->FileName, "GUID does not match first file's GUID");\r
-        goto FailDone;\r
-      }\r
-      //\r
-      // Make sure we're not throwing out any header info\r
-      //\r
-      if (CapHdrPtr->OffsetToCapsuleBody > sizeof (EFI_CAPSULE_HEADER)) {\r
-        //\r
-        // Could be the split information, so just emit a warning\r
-        //\r
-        Warning (\r
-          NULL,\r
-          0,\r
-          0,\r
-          FileList->FileName,\r
-          "image appears to have additional capsule header information -- ignoring"\r
-          );\r
-      } else if (CapHdrPtr->OffsetToCapsuleBody < sizeof (EFI_CAPSULE_HEADER)) {\r
-        Error (NULL, 0, 0, FileList->FileName, "offset to capsule body in capsule header is insufficient");\r
-        goto FailDone;\r
-      }\r
-\r
-      if (fwrite (Buffer + CapHdrPtr->OffsetToCapsuleBody, Size - CapHdrPtr->OffsetToCapsuleBody, 1, OutFptr) != 1) {\r
-        Error (NULL, 0, 0, mOptions.OutputFileName, "failed to write to file");\r
-        goto FailDone;\r
-      }\r
-\r
-      if (SizeLeft < (Size - CapHdrPtr->OffsetToCapsuleBody)) {\r
-        Error (NULL, 0, 0, "sum of image sizes exceeds size specified in initial capsule header", NULL);\r
-        goto FailDone;\r
-      }\r
-      //\r
-      // printf ("FILE: %s OffsetToCapsuleBody=0x%X\n", FileList->FileName, CapHdrPtr->OffsetToCapsuleBody);\r
-      //\r
-      SizeLeft = SizeLeft - (Size - CapHdrPtr->OffsetToCapsuleBody);\r
-    }\r
-    //\r
-    // printf ("FILE: %s sizeleft=0x%X\n", FileList->FileName, SizeLeft);\r
-    //\r
-    fclose (InFptr);\r
-    InFptr = NULL;\r
-    free (Buffer);\r
-    Buffer    = NULL;\r
-    FileList  = FileList->Next;\r
-    SequenceNumber++;\r
-  }\r
-\r
-  if (SizeLeft) {\r
-    Error (NULL, 0, 0, "sum of capsule images is insufficient", "0x%X bytes missing", SizeLeft);\r
-    goto FailDone;\r
-  }\r
-\r
-  Status = STATUS_SUCCESS;\r
-  goto Done;\r
-FailDone:\r
-  Status = STATUS_ERROR;\r
-Done:\r
-  if (InFptr != NULL) {\r
-    fclose (InFptr);\r
-  }\r
-\r
-  if (OutFptr != NULL) {\r
-    fclose (OutFptr);\r
-  }\r
-\r
-  if (Buffer != NULL) {\r
-    free (Buffer);\r
-  }\r
-\r
-  return Status;\r
-\r
-#endif\r
-return STATUS_SUCCESS;\r
-}\r
-\r
-static\r
-STATUS\r
-DumpCapsuleHeaderStrings (\r
-  UINT8   *SectionName,\r
-  WCHAR   *Buffer\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Given a pointer to string data from a capsule header, dump\r
-  the strings.\r
-\r
-Arguments:\r
-  SectionName  - name of the capsule header section to which\r
-                 the string data pertains\r
-  Buffer       - pointer to string data from a capsule header\r
-\r
-Returns:\r
-  STATUS_SUCCESS - all went well\r
-\r
---*/\r
-{\r
-  printf ("  %s\n", SectionName);\r
-  while (*Buffer) {\r
-    printf ("    Language: %S\n", Buffer);\r
-    while (*Buffer) {\r
-      Buffer++;\r
-    }\r
-\r
-    Buffer++;\r
-    while (*Buffer) {\r
-      if (wcslen (Buffer) > 60) {\r
-        printf ("      %.60S\n", Buffer);\r
-        Buffer += 60;\r
-      } else {\r
-        printf ("      %S\n", Buffer);\r
-        Buffer += wcslen (Buffer);\r
-      }\r
-    }\r
-\r
-    Buffer++;\r
-  }\r
-\r
-  return STATUS_SUCCESS;\r
-}\r
-\r
-static\r
-STATUS\r
-GetHexValue (\r
-  SOURCE_FILE  *SourceFile,\r
-  UINT32       *Value,\r
-  UINT32       NumDigits\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Scan a hex value from the input stream.\r
-  \r
-Arguments:\r
-  SourceFile   - input file contents\r
-  Value        - returned value\r
-  NumDigits    - number of digits to read\r
-\r
-Returns:\r
-  STATUS_SUCCESS - if NumDigits were read from the file\r
-  STATUS_ERROR   - otherwise\r
-\r
-  \r
---*/\r
-{\r
-  WCHAR   *SaveFilePos;\r
-  UINT32  Digits;\r
-  WCHAR   Nibble;\r
-\r
-  SaveFilePos = SourceFile->FileBufferPtr;\r
-  *Value      = 0;\r
-  Digits      = NumDigits;\r
-  while (Digits > 0) {\r
-    Nibble = SourceFile->FileBufferPtr[0];\r
-    if ((Nibble >= UNICODE_0) && (Nibble <= UNICODE_9)) {\r
-      *Value = (*Value << 4) | (Nibble - UNICODE_0);\r
-    } else if ((Nibble >= UNICODE_A) && (Nibble <= UNICODE_F)) {\r
-      *Value = (*Value << 4) | (Nibble - UNICODE_A + 0x10);\r
-    } else if ((Nibble >= UNICODE_a) && (Nibble <= UNICODE_f)) {\r
-      *Value = (*Value << 4) | (Nibble - UNICODE_a + 0x10);\r
-    } else {\r
-      Error (\r
-        SourceFile->FileName,\r
-        SourceFile->LineNum,\r
-        0,\r
-        NULL,\r
-        "expected %d valid hex nibbles at %.20S",\r
-        NumDigits,\r
-        SaveFilePos\r
-        );\r
-      return STATUS_ERROR;\r
-    }\r
-\r
-    SourceFile->FileBufferPtr++;\r
-    Digits--;\r
-  }\r
-\r
-  return STATUS_SUCCESS;\r
-}\r
-\r
-static\r
-BOOLEAN\r
-EndOfFile (\r
-  SOURCE_FILE *File\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  File  - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
-  GC_TODO: add return values\r
-\r
---*/\r
-{\r
-  if ((UINT32) File->FileBufferPtr - (UINT32) File->FileBuffer >= File->FileSize) {\r
-    File->EndOfFile = TRUE;\r
-  }\r
-  //\r
-  // Reposition to the end of the file if we went beyond\r
-  //\r
-  if (File->EndOfFile) {\r
-    File->FileBufferPtr = File->FileBuffer + File->FileSize / sizeof (WCHAR);\r
-  }\r
-\r
-  return File->EndOfFile;\r
-}\r
-\r
-static\r
-void\r
-SkipWhiteSpace (\r
-  SOURCE_FILE *SourceFile\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  SourceFile  - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
-  GC_TODO: add return values\r
-\r
---*/\r
-{\r
-  while (!EndOfFile (SourceFile)) {\r
-    switch (*SourceFile->FileBufferPtr) {\r
-    case UNICODE_NULL:\r
-    case UNICODE_CR:\r
-    case UNICODE_SPACE:\r
-    case UNICODE_TAB:\r
-      SourceFile->FileBufferPtr++;\r
-      break;\r
-\r
-    case UNICODE_LF:\r
-      SourceFile->FileBufferPtr++;\r
-      SourceFile->LineNum++;\r
-      break;\r
-\r
-    default:\r
-      return ;\r
-    }\r
-  }\r
-}\r
-//\r
-// Parse a number. Possible format:\r
-//   1234\r
-//   1234k\r
-//   1234K\r
-//   1M\r
-//   1m\r
-//   0x100\r
-//\r
-static\r
-BOOLEAN\r
-GetNumber (\r
-  INT8    *Str,\r
-  UINT32  *Value\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  Str   - GC_TODO: add argument description\r
-  Value - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
-  GC_TODO: add return values\r
-\r
---*/\r
-{\r
-  UINT32  LValue;\r
-\r
-  *Value  = 0;\r
-  LValue  = 0;\r
-  if (!isdigit (Str[0])) {\r
-    return FALSE;\r
-  }\r
-  //\r
-  // Look for hex number\r
-  //\r
-  if ((Str[0] == '0') && (tolower (Str[1]) == 'x')) {\r
-    Str += 2;\r
-    if (Str[0] == 0) {\r
-      return FALSE;\r
-    }\r
-\r
-    while (Str[0]) {\r
-      if ((Str[0] >= '0') && (Str[0] <= '9')) {\r
-        LValue = (LValue << 4) | (Str[0] - '0');\r
-      } else if ((Str[0] >= 'A') && (Str[0] <= 'F')) {\r
-        LValue = (LValue << 4) | (Str[0] - 'A' + 0x10);\r
-      } else if ((Str[0] >= 'a') && (Str[0] <= 'f')) {\r
-        LValue = (LValue << 4) | (Str[0] - 'a' + 0x10);\r
-      } else {\r
-        break;\r
-      }\r
-\r
-      Str++;\r
-    }\r
-  } else {\r
-    LValue = atoi (Str);\r
-    while (isdigit (*Str)) {\r
-      Str++;\r
-    }\r
-  }\r
-  //\r
-  // If string left over, better be one character we recognize\r
-  //\r
-  if (Str[0]) {\r
-    if (Str[1]) {\r
-      return FALSE;\r
-    }\r
-\r
-    switch (Str[0]) {\r
-    case 'k':\r
-    case 'K':\r
-      LValue *= 1024;\r
-      break;\r
-\r
-    case 'm':\r
-    case 'M':\r
-      LValue *= 1024 * 1024;\r
-      break;\r
-\r
-    default:\r
-      return FALSE;\r
-    }\r
-  }\r
-\r
-  *Value = LValue;\r
-  return TRUE;\r
-}\r
-//\r
-// Process the command-line arguments\r
-//\r
-static\r
-STATUS\r
-ProcessArgs (\r
-  int   Argc,\r
-  char  *Argv[]\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Processes command line arguments.\r
-\r
-Arguments:\r
-\r
-  Argc   - Number of command line arguments\r
-  Argv[] - Array of files input on command line  \r
-\r
-Returns:\r
-\r
-  STATUS_ERROR    - Function exited with an error\r
-  STATUS_SUCCESS  - Function executed successfully\r
-\r
---*/\r
-{\r
-  FILE_LIST *NewFile;\r
-\r
-  FILE_LIST *LastFile;\r
-  SIZE_LIST *NewSize;\r
-  \r
-  NewFile = NULL;\r
-  NewSize = NULL;\r
-  \r
-  //\r
-  // Clear our globals\r
-  //\r
-  memset ((char *) &mOptions, 0, sizeof (mOptions));\r
-\r
-  //\r
-  // Skip program name\r
-  //\r
-  Argc--;\r
-  Argv++;\r
-\r
-  if (Argc == 0) {\r
-    Usage ();\r
-    return STATUS_ERROR;\r
-  }\r
-  //\r
-  // Process until no more options\r
-  //\r
-  while ((Argc > 0) && (Argv[0][0] == '-')) {\r
-    if (stricmp (Argv[0], "-script") == 0) {\r
-      //\r
-      // Check for one more arg\r
-      //\r
-      if (Argc > 1) {\r
-        //\r
-        // Save the file name\r
-        //\r
-        if (strlen (Argv[1]) >= sizeof (mOptions.ScriptFileName)) {\r
-          Error (NULL, 0, 0, NULL, "input script file name length exceeds internal buffer size");\r
-          \r
-          if (NewFile != NULL) {\r
-            free (NewFile);\r
-          }\r
-          if (NewSize != NULL) {\r
-            free (NewSize);\r
-          }\r
-          \r
-          return STATUS_ERROR;\r
-        }\r
-\r
-        strcpy (mOptions.ScriptFileName, Argv[1]);\r
-      } else {\r
-        Error (NULL, 0, 0, Argv[0], "missing script file name with option");\r
-        Usage ();\r
-        \r
-        if (NewFile != NULL) {\r
-          free (NewFile);\r
-        }\r
-        if (NewSize != NULL) {\r
-          free (NewSize);\r
-        }       \r
-\r
-        return STATUS_ERROR;\r
-      }\r
-\r
-      Argc--;\r
-      Argv++;\r
-      //\r
-      // -o outfilename -- specify output file name (required)\r
-      //\r
-    } else if (stricmp (Argv[0], "-o") == 0) {\r
-      //\r
-      // check for one more arg\r
-      //\r
-      if (Argc > 1) {\r
-        //\r
-        // Try to open the file\r
-        //\r
-        // if ((mOptions.OutFptr = fopen (Argv[1], "wb")) == NULL) {\r
-        //  Error (NULL, 0, 0, Argv[1], "failed to open output file for writing");\r
-        //  return STATUS_ERROR;\r
-        // }\r
-        //\r
-        strcpy (mOptions.OutputFileName, Argv[1]);\r
-      } else {\r
-        Error (NULL, 0, 0, Argv[0], "missing output filename with option");\r
-        Usage ();\r
-        \r
-        if (NewFile != NULL) {\r
-          free (NewFile);\r
-        }\r
-        if (NewSize != NULL) {\r
-          free (NewSize);\r
-        }\r
-                \r
-        return STATUS_ERROR;\r
-      }\r
-\r
-      Argc--;\r
-      Argv++;\r
-    } else if (stricmp (Argv[0], "-j") == 0) {\r
-      mOptions.JoinMode = TRUE;\r
-      //\r
-      // -split <size> option (multiple allowed)\r
-      //\r
-    } else if (stricmp (Argv[0], "-split") == 0) {\r
-      if (Argc > 1) {\r
-        NewSize = (SIZE_LIST *) malloc (sizeof (SIZE_LIST));\r
-        if (NewSize == NULL) {\r
-          Error (NULL, 0, 0, "memory allocation failure", NULL);\r
-\r
-          if (NewFile != NULL) {\r
-            free (NewFile);\r
-          }\r
-          if (NewSize != NULL) {\r
-            free (NewSize);\r
-          }\r
-          \r
-          return STATUS_ERROR;\r
-        }\r
-\r
-        memset (NewSize, 0, sizeof (SIZE_LIST));\r
-        //\r
-        // Get the size from the next arg, and then add this size\r
-        // to our size list\r
-        //\r
-        if (!GetNumber (Argv[1], &NewSize->Size)) {\r
-          Error (NULL, 0, 0, Argv[1], "invalid split size argument");\r
-\r
-          if (NewFile != NULL) {\r
-            free (NewFile);\r
-          }\r
-          if (NewSize != NULL) {\r
-            free (NewSize);\r
-          }       \r
-          \r
-          return STATUS_ERROR;\r
-        }\r
-\r
-        if (mOptions.SizeList == NULL) {\r
-          mOptions.SizeList     = NewSize;\r
-          mOptions.CurrentSize  = NewSize;\r
-        } else {\r
-          mOptions.LastSize->Next = NewSize;\r
-        }\r
-\r
-        mOptions.LastSize = NewSize;\r
-        free (NewSize);\r
-      } else {\r
-        Error (NULL, 0, 0, Argv[0], "missing size parameter with option");\r
-        Usage ();\r
-\r
-        if (NewFile != NULL) {\r
-          free (NewFile);\r
-        }\r
-        if (NewSize != NULL) {\r
-          free (NewSize);\r
-        }\r
-        \r
-        return STATUS_ERROR;\r
-      }\r
-\r
-      Argc--;\r
-      Argv++;      \r
-    } else if ((stricmp (Argv[0], "-h") == 0) || (strcmp (Argv[0], "-?") == 0)) {\r
-      Usage ();\r
-      \r
-      if (NewFile != NULL) {\r
-        free (NewFile);\r
-      }\r
-      if (NewSize != NULL) {\r
-        free (NewSize);\r
-      }\r
-      \r
-      return STATUS_ERROR;\r
-      //\r
-      // Default minimum header\r
-      //\r
-    } else if (stricmp (Argv[0], "-dump") == 0) {\r
-      mOptions.Dump = TRUE;\r
-    } else if (stricmp (Argv[0], "-v") == 0) {\r
-      mOptions.Verbose = TRUE;\r
-    } else {\r
-      Error (NULL, 0, 0, Argv[0], "unrecognized option");\r
-      Usage ();\r
-      \r
-      if (NewFile != NULL) {\r
-        free (NewFile);\r
-      }\r
-      if (NewSize != NULL) {\r
-        free (NewSize);\r
-      }\r
-      \r
-      return STATUS_ERROR;\r
-    }\r
-\r
-    Argc--;\r
-    Argv++;\r
-  }\r
-  //\r
-  // Can't -j join files and -s split output capsule\r
-  //\r
-  if ((mOptions.SizeList != NULL) && (mOptions.JoinMode)) {\r
-    Error (NULL, 0, 0, "cannot specify both -j and -size", NULL);\r
-    \r
-    if (NewFile != NULL) {\r
-      free (NewFile);\r
-    }\r
-    if (NewSize != NULL) {\r
-      free (NewSize);\r
-    }\r
-    \r
-    return STATUS_ERROR;\r
-  }\r
-  //\r
-  // Must have specified an output file name if not -dump\r
-  //\r
-  if ((mOptions.Dump == 0) && (mOptions.OutputFileName[0] == 0)) {\r
-    Error (NULL, 0, 0, NULL, "-o OutputFileName must be specified");\r
-    Usage ();\r
-    \r
-    if (NewFile != NULL) {\r
-      free (NewFile);\r
-    }\r
-    if (NewSize != NULL) {\r
-      free (NewSize);\r
-    }\r
-    \r
-    return STATUS_ERROR;\r
-  }\r
-  //\r
-  // Rest of arguments are input files. The first one is a firmware\r
-  // volume image, and the rest are FFS files that are to be inserted\r
-  // into the firmware volume.\r
-  //\r
-  LastFile = NULL;\r
-  while (Argc > 0) {\r
-    NewFile = (FILE_LIST *) malloc (sizeof (FILE_LIST));\r
-    if (NewFile == NULL) {\r
-      Error (NULL, 0, 0, "memory allocation failure", NULL);\r
-\r
-      if (NewFile != NULL) {\r
-        free (NewFile);\r
-      }\r
-      if (NewSize != NULL) {\r
-        free (NewSize);\r
-      }\r
-    \r
-      return STATUS_ERROR;\r
-    }\r
-\r
-    memset ((char *) NewFile, 0, sizeof (FILE_LIST));\r
-    strcpy (NewFile->FileName, Argv[0]);\r
-    if (mOptions.FileList == NULL) {\r
-      mOptions.FileList = NewFile;\r
-    } else {\r
-      if (LastFile == NULL) {\r
-        LastFile = NewFile;\r
-      } else {\r
-        LastFile->Next = NewFile;\r
-      }      \r
-    }\r
-\r
-    LastFile = NewFile;\r
-    Argc--;\r
-    Argv++;\r
-  }\r
-\r
-  //\r
-  // Must have provided at least one file name\r
-  //\r
-  if (mOptions.FileList == NULL) {\r
-    Error (NULL, 0, 0, "must specify at least one file name", NULL);\r
-    Usage ();\r
-    \r
-    if (NewFile != NULL) {\r
-      free (NewFile);\r
-    }\r
-    if (NewSize != NULL) {\r
-      free (NewSize);\r
-    }\r
-    \r
-    return STATUS_ERROR;\r
-  }\r
-\r
-  return STATUS_SUCCESS;\r
-}\r
-\r
-static\r
-void\r
-Usage (\r
-  VOID\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Print usage information for this utility.\r
-  \r
-Arguments:\r
-\r
-  None.\r
-\r
-Returns:\r
-\r
-  Nothing.\r
-  \r
---*/\r
-{\r
-  int               Index;\r
-  static const char *Str[] = {\r
-    PROGRAM_NAME " -- create a capsule header",\r
-    "  Usage: "PROGRAM_NAME " {options} [CapsuleFV]",\r
-    //\r
-    // {FfsFileNames}",\r
-    //\r
-    "    Options include:",\r
-    "      -h or -?         for this help information",\r
-    "      -script fname    to take capsule header info from unicode script",\r
-    "                       file fname",\r
-    "      -o fname         write output to file fname (required)",\r
-    "      -split size      split capsule image into multiple output files",\r
-    "      -dump            to dump a capsule header",\r
-    "      -v               for verbose output\n",\r
-    "      -j               to join split capsule images into a single image",\r
-    "",\r
-    "    CapsuleFV is the name of an existing well-formed Tiano firmware",\r
-    "    volume file.",\r
-    //\r
-    // FfsFileNames are the names of one or more Tiano FFS files to",\r
-    // "    insert into the output capsule image.",\r
-    //\r
-    NULL\r
-  };\r
-  for (Index = 0; Str[Index] != NULL; Index++) {\r
-    fprintf (stdout, "%s\n", Str[Index]);\r
-  }\r
-}\r
diff --git a/Tools/CodeTools/TianoTools/GenCapsuleHdr/build.xml b/Tools/CodeTools/TianoTools/GenCapsuleHdr/build.xml
deleted file mode 100644 (file)
index 7c43d0a..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-<?xml version="1.0" ?>\r
-<!--\r
-Copyright (c) 2006, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
--->\r
-<project default="GenTool" basedir=".">\r
-<!--\r
-    EDK GenCapsuleHdr Tool\r
-  Copyright (c) 2006, Intel Corporation\r
--->\r
-  <property name="ToolName" value="GenCapsuleHdr"/>\r
-  <property name="FileSet" value="GenCapsuleHdr.c"/>\r
-\r
-  <taskdef resource="cpptasks.tasks"/>\r
-  <typedef resource="cpptasks.types"/>\r
-  <taskdef resource="net/sf/antcontrib/antlib.xml"/>\r
-\r
-  <property name="LINK_OUTPUT_TYPE" value="static"/>\r
-  <property name="BUILD_DIR" value="${PACKAGE_DIR}/${ToolName}/tmp"/>\r
-\r
-  <target name="GenTool" depends="init, Tool">\r
-    <echo message="The EDK Tool: ${ToolName} build has completed!"/>\r
-  </target>\r
-\r
-  <target name="init">\r
-    <echo message="Building the EDK Tool: ${ToolName}"/>\r
-    <mkdir dir="${BUILD_DIR}"/>\r
-  </target>\r
-\r
-  <target name="Tool" depends="init">\r
-    <cc name="${ToolChain}" objdir="${BUILD_DIR}" \r
-        outfile="${BIN_DIR}/${ToolName}"\r
-        outtype="executable"\r
-        optimize="speed" \r
-        debug="true">\r
-      <compilerarg value="${ExtraArgus}" if="ExtraArgus" />\r
-\r
-      <fileset dir="${basedir}/${ToolName}" \r
-        includes="${FileSet}" \r
-        defaultexcludes="TRUE" \r
-        excludes="*.xml *.inf"/>\r
-\r
-      <includepath path="${PACKAGE_DIR}/Include"/>\r
-      <includepath path="${PACKAGE_DIR}/Include/${HostArch}"/>\r
-      <includepath path="${PACKAGE_DIR}/Common"/>\r
-      <libset dir="${LIB_DIR}" libs="CommonTools"/>\r
-      <syslibset dir="${env.CYGWIN_HOME}/lib/mingw" libs="msvcr71" if="cygwin"/>\r
-    </cc>\r
-  </target>\r
-\r
-  <target name="clean">\r
-    <echo message="Removing Intermediate Files Only"/>  \r
-    <delete>\r
-      <fileset dir="${BUILD_DIR}" includes="*.obj"/>\r
-    </delete>\r
-  </target>\r
-\r
-  <target name="cleanall">\r
-    <echo message="Removing Object Files and the Executable: ${ToolName}${ext_exe}"/>  \r
-    <delete failonerror="false" quiet="true" includeEmptyDirs="true">\r
-      <fileset dir="${BUILD_DIR}"/>\r
-      <fileset file="${BIN_DIR}/${ToolName}${ext_exe}"/>\r
-    </delete>\r
-  </target>\r
-\r
-</project>\r
diff --git a/Tools/CodeTools/TianoTools/GenDepex/DepexParser.c b/Tools/CodeTools/TianoTools/GenDepex/DepexParser.c
deleted file mode 100644 (file)
index 9f0a0cb..0000000
+++ /dev/null
@@ -1,903 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2004, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-Module Name:\r
-\r
-  DepexParser.c\r
-\r
-Abstract:\r
-\r
-  Validate Dependency Expression syntax\r
-  recursive descent Algorithm\r
-\r
-  The original BNF grammar(taken from "Pre EFI Initialization Core Interface Specification \r
-  draft review 0.9") is thus:\r
-       <depex>    ::= BEFORE <guid> END\r
-                    | AFTER <guid> END\r
-                    | SOR <bool> END\r
-                    | <bool> END    \r
-       <bool>     ::= <bool> AND <term> \r
-                    | <bool> OR <term>  \r
-                    | <term>            \r
-       <term>     ::= NOT <factor>      \r
-                    | <factor>          \r
-       <factor>   ::= <bool>            \r
-                    | TRUE \r
-                    | FALSE \r
-                    | GUID\r
-\r
-       <guid>     ::= '{' <hex32> ',' <hex16> ',' <hex16> ','\r
-                      <hex8> ',' <hex8> ',' <hex8> ',' <hex8> ',' \r
-                      <hex8> ',' <hex8> ',' <hex8> ',' <hex8> '}'\r
-       <hex32>    ::= <hexprefix> <hexvalue>\r
-       <hex16>    ::= <hexprefix> <hexvalue>\r
-       <hex8>     ::= <hexprefix> <hexvalue>\r
-       <hexprefix>::= '0' 'x'\r
-                    | '0' 'X'\r
-       <hexvalue> ::= <hexdigit> <hexvalue>\r
-                    | <hexdigit>\r
-       <hexdigit> ::= [0-9]\r
-                    | [a-f]\r
-                    | [A-F]\r
-\r
-  After cleaning left recursive and parentheses supported, the BNF grammar used in this module is thus:\r
-       <depex>    ::= BEFORE <guid>\r
-                    | AFTER <guid>\r
-                    | SOR <bool>\r
-                    | <bool>\r
-       <bool>     ::= <term><rightbool>\r
-       <rightbool>::= AND <term><rightbool>\r
-                    | OR <term><rightbool>\r
-                    | ''\r
-       <term>     ::= NOT <factor>\r
-                    | <factor>\r
-       <factor>   ::= '('<bool>')'<rightfactor>\r
-                    | NOT <factor> <rightbool> <rightfactor>\r
-                    | TRUE <rightfactor>\r
-                    | FALSE <rightfactor>\r
-                    | END <rightfactor>\r
-                    | <guid> <rightfactor>                    \r
-       <rightfactor> ::=AND <term><rightbool> <rightfactor>   \r
-                    | OR <term><rightbool> <rightfactor>                 \r
-                    | ''\r
-       <guid>     ::= '{' <hex32> ',' <hex16> ',' <hex16> ','\r
-                      <hex8> ',' <hex8> ',' <hex8> ',' <hex8> ',' \r
-                      <hex8> ',' <hex8> ',' <hex8> ',' <hex8> '}'\r
-       <hex32>    ::= <hexprefix> <hexvalue>\r
-       <hex16>    ::= <hexprefix> <hexvalue>\r
-       <hex8>     ::= <hexprefix> <hexvalue>\r
-       <hexprefix>::= '0' 'x'\r
-                    | '0' 'X'\r
-       <hexvalue> ::= <hexdigit> <hexvalue>\r
-                    | <hexdigit>\r
-       <hexdigit> ::= [0-9]\r
-                    | [a-f]\r
-                    | [A-F]\r
\r
-  Note: 1. There's no precedence in operators except parentheses;\r
-        2. For hex32, less and equal than 8 bits is valid, more than 8 bits is invalid.\r
-           Same constraint for hex16 is 4, hex8 is 2. All hex should contains at least 1 bit.\r
-        3. "<factor>   ::= '('<bool>')'<rightfactor>" is added to support parentheses;\r
-        4. "<factor>   ::= GUID" is changed to "<factor>   ::= <guid>";\r
-        5. "DEPENDENCY_END" is the terminal of the expression. But it has been filtered by caller. \r
-           During parsing, "DEPENDENCY_END" will be treated as illegal factor;\r
-    \r
-  This code should build in any environment that supports a standard C-library w/ string\r
-  operations and File I/O services.\r
-\r
-  As an example of usage, consider the following:\r
-\r
-  The input string could be something like: \r
-    \r
-      NOT ({ 0xce345171, 0xba0b, 0x11d2, 0x8e, 0x4f, 0x0, 0xa0, 0xc9, 0x69, 0x72,\r
-        0x3b } AND { 0x964e5b22, 0x6459, 0x11d2, 0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69,\r
-        0x72, 0x3b }) OR { 0x03c4e603, 0xac28, 0x11d3, 0x9a, 0x2d, 0x00, 0x90, 0x27,\r
-        0x3f, 0xc1, 0x4d } AND\r
-\r
-  It's invalid for an extra "AND" in the end.\r
-\r
-  Complies with Tiano C Coding Standards Document, version 0.33, 16 Aug 2001.\r
-\r
---*/\r
-\r
-#include "DepexParser.h"\r
-\r
-BOOLEAN\r
-ParseBool (\r
-  IN      INT8      *Pbegin,\r
-  IN      UINT32    length,\r
-  IN OUT  INT8      **Pindex\r
-  );\r
-\r
-BOOLEAN\r
-ParseTerm (\r
-  IN      INT8      *Pbegin,\r
-  IN      UINT32    length,\r
-  IN OUT  INT8      **Pindex\r
-  );\r
-\r
-BOOLEAN\r
-ParseRightBool (\r
-  IN      INT8      *Pbegin,\r
-  IN      UINT32    length,\r
-  IN OUT  INT8      **Pindex\r
-  );\r
-\r
-BOOLEAN\r
-ParseFactor (\r
-  IN      INT8      *Pbegin,\r
-  IN      UINT32    length,\r
-  IN OUT  INT8      **Pindex\r
-  );\r
-\r
-VOID\r
-LeftTrim (\r
-  IN      INT8      *Pbegin,\r
-  IN      UINT32    length,\r
-  IN OUT  INT8      **Pindex\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Left trim the space, '\n' and '\r' character in string.\r
-  The space at the end does not need trim.\r
-\r
-\r
-Arguments:\r
-\r
-  Pbegin    The pointer to the string  \r
-  length    length of the string\r
-  Pindex    The pointer of pointer to the next parse character in the string\r
-\r
-Returns:\r
-\r
-  None\r
-\r
-\r
---*/\r
-{\r
-  while\r
-  (\r
-    ((*Pindex) < (Pbegin + length)) &&\r
-    ((strncmp (*Pindex, " ", 1) == 0) || (strncmp (*Pindex, "\n", 1) == 0) || (strncmp (*Pindex, "\r", 1) == 0))\r
-  ) {\r
-    (*Pindex)++;\r
-  }\r
-}\r
-\r
-BOOLEAN\r
-ParseHexdigit (\r
-  IN      INT8      *Pbegin,\r
-  IN      UINT32    length,\r
-  IN OUT  INT8      **Pindex\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Parse Hex bit in dependency expression.  \r
-\r
-Arguments:\r
-\r
-  Pbegin    The pointer to the string  \r
-  length    Length of the string\r
-  Pindex    The pointer of pointer to the next parse character in the string\r
-\r
-Returns:\r
-\r
-  BOOLEAN   If parses a valid hex bit, return TRUE, otherwise FALSE\r
-\r
-\r
---*/\r
-{\r
-  //\r
-  // <hexdigit> ::= [0-9] | [a-f] | [A-F]\r
-  //\r
-  if (((**Pindex) >= '0' && (**Pindex) <= '9') ||\r
-      ((**Pindex) >= 'a' && (**Pindex) <= 'f') ||\r
-      ((**Pindex) >= 'A' && (**Pindex) <= 'F')\r
-      ) {\r
-    (*Pindex)++;\r
-    return TRUE;\r
-  } else {\r
-    return FALSE;\r
-  }\r
-}\r
-\r
-BOOLEAN\r
-ParseHex32 (\r
-  IN      INT8      *Pbegin,\r
-  IN      UINT32    length,\r
-  IN OUT  INT8      **Pindex\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Parse Hex32 in dependency expression.  \r
-\r
-Arguments:\r
-\r
-  Pbegin    The pointer to the string  \r
-  length    Length of the string\r
-  Pindex    The pointer of point to the next parse character in the string\r
-\r
-Returns:\r
-\r
-  BOOLEAN   If parses a valid hex32, return TRUE, otherwise FALSE\r
-\r
-\r
---*/\r
-{\r
-  INT32 Index;\r
-  INT8  *Pin;\r
-\r
-  Index = 0;\r
-  Pin   = *Pindex;\r
-  LeftTrim (Pbegin, length, Pindex);\r
-\r
-  if ((strncmp (*Pindex, "0x", 2) != 0) && (strncmp (*Pindex, "0X", 2) != 0)) {\r
-    return FALSE;\r
-  }\r
-  (*Pindex) += 2;\r
-\r
-  while (ParseHexdigit (Pbegin, length, Pindex)) {\r
-    Index++;\r
-  }\r
-\r
-  if (Index > 0 && Index <= 8) {\r
-    return TRUE;\r
-  } else {\r
-    *Pindex = Pin;\r
-    return FALSE;\r
-  }\r
-}\r
-\r
-BOOLEAN\r
-ParseHex16 (\r
-  IN      INT8      *Pbegin,\r
-  IN      UINT32    length,\r
-  IN OUT  INT8      **Pindex\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Parse Hex16 in dependency expression.  \r
-\r
-Arguments:\r
-\r
-  Pbegin    The pointer to the string  \r
-  length    Length of the string\r
-  Pindex    The pointer of pointer to the next parse character in the string\r
-\r
-Returns:\r
-\r
-  BOOLEAN   If parses a valid hex16, return TRUE, otherwise FALSE\r
-\r
-\r
---*/\r
-{\r
-  int   Index;\r
-  INT8  *Pin;\r
-\r
-  Index = 0;\r
-  Pin   = *Pindex;\r
-  LeftTrim (Pbegin, length, Pindex);\r
-\r
-  if ((strncmp (*Pindex, "0x", 2) != 0) && (strncmp (*Pindex, "0X", 2) != 0)) {\r
-    return FALSE;\r
-  }\r
-  (*Pindex) += 2;\r
-\r
-  while (ParseHexdigit (Pbegin, length, Pindex)) {\r
-    Index++;\r
-  }\r
-\r
-  if (Index > 0 && Index <= 4) {\r
-    return TRUE;\r
-  } else {\r
-    *Pindex = Pin;\r
-    return FALSE;\r
-  }\r
-}\r
-\r
-BOOLEAN\r
-ParseHex8 (\r
-  IN      INT8      *Pbegin,\r
-  IN      UINT32    length,\r
-  IN OUT  INT8      **Pindex\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Parse Hex8 in dependency expression.  \r
-\r
-Arguments:\r
-\r
-  Pbegin    The pointer to the string  \r
-  length    Length of the string\r
-  Pindex    The pointer of pointer to the next parse character in the string\r
-\r
-Returns:\r
-\r
-  BOOLEAN   If parses a valid hex8, return TRUE, otherwise FALSE\r
-\r
-\r
---*/\r
-{\r
-  int   Index;\r
-  INT8  *Pin;\r
-\r
-  Index = 0;\r
-  Pin   = *Pindex;\r
-  LeftTrim (Pbegin, length, Pindex);\r
-\r
-  if ((strncmp (*Pindex, "0x", 2) != 0) && (strncmp (*Pindex, "0X", 2) != 0)) {\r
-    return FALSE;\r
-  }\r
-  (*Pindex) += 2;\r
-\r
-  while (ParseHexdigit (Pbegin, length, Pindex)) {\r
-    Index++;\r
-  }\r
-\r
-  if (Index > 0 && Index <= 2) {\r
-    return TRUE;\r
-  } else {\r
-    *Pindex = Pin;\r
-    return FALSE;\r
-  }\r
-}\r
-\r
-BOOLEAN\r
-ParseGuid (\r
-  IN      INT8      *Pbegin,\r
-  IN      UINT32    length,\r
-  IN OUT  INT8      **Pindex\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Parse guid in dependency expression.\r
-  There can be any number of spaces between '{' and hexword, ',' and hexword, \r
-  hexword and ',', hexword and '}'. The hexword include hex32, hex16 and hex8.\r
-\r
-Arguments:\r
-\r
-  Pbegin    The pointer to the string  \r
-  length    length of the string\r
-  Pindex    The pointer of pointer to the next parse character in the string\r
-\r
-Returns:\r
-\r
-  BOOLEAN   If parses a valid guid, return TRUE, otherwise FALSE\r
-\r
-\r
---*/\r
-{\r
-  INT32 Index;\r
-  INT8  *Pin;\r
-  Pin = *Pindex;\r
-  LeftTrim (Pbegin, length, Pindex);\r
-  if (strncmp (*Pindex, "{", 1) != 0) {\r
-    return FALSE;\r
-  }\r
-  (*Pindex)++;\r
-\r
-  LeftTrim (Pbegin, length, Pindex);\r
-  if (!ParseHex32 (Pbegin, length, Pindex)) {\r
-    *Pindex = Pin;\r
-    return FALSE;\r
-  }\r
-\r
-  LeftTrim (Pbegin, length, Pindex);\r
-  if (strncmp (*Pindex, ",", 1) != 0) {\r
-    return FALSE;\r
-  } else {\r
-    (*Pindex)++;\r
-  }\r
-\r
-  for (Index = 0; Index < 2; Index++) {\r
-    LeftTrim (Pbegin, length, Pindex);\r
-    if (!ParseHex16 (Pbegin, length, Pindex)) {\r
-      *Pindex = Pin;\r
-      return FALSE;\r
-    }\r
-\r
-    LeftTrim (Pbegin, length, Pindex);\r
-    if (strncmp (*Pindex, ",", 1) != 0) {\r
-      return FALSE;\r
-    } else {\r
-      (*Pindex)++;\r
-    }\r
-  }\r
-\r
-  LeftTrim (Pbegin, length, Pindex);\r
-  if (strncmp (*Pindex, "{", 1) != 0) {\r
-    return FALSE;\r
-  }\r
-  (*Pindex)++;\r
-\r
-  for (Index = 0; Index < 7; Index++) {\r
-    LeftTrim (Pbegin, length, Pindex);\r
-    if (!ParseHex8 (Pbegin, length, Pindex)) {\r
-      *Pindex = Pin;\r
-      return FALSE;\r
-    }\r
-\r
-    LeftTrim (Pbegin, length, Pindex);\r
-    if (strncmp (*Pindex, ",", 1) != 0) {\r
-      return FALSE;\r
-    } else {\r
-      (*Pindex)++;\r
-    }\r
-  }\r
-\r
-  LeftTrim (Pbegin, length, Pindex);\r
-  if (!ParseHex8 (Pbegin, length, Pindex)) {\r
-    *Pindex = Pin;\r
-    return FALSE;\r
-  }\r
-\r
-  LeftTrim (Pbegin, length, Pindex);\r
-  if (strncmp (*Pindex, "}", 1) != 0) {\r
-    return FALSE;\r
-  } else {\r
-    (*Pindex)++;\r
-  }\r
-\r
-  LeftTrim (Pbegin, length, Pindex);\r
-  if (strncmp (*Pindex, "}", 1) != 0) {\r
-    return FALSE;\r
-  } else {\r
-    (*Pindex)++;\r
-  }\r
-\r
-  return TRUE;\r
-}\r
-\r
-BOOLEAN\r
-ParseRightFactor (\r
-  IN      INT8      *Pbegin,\r
-  IN      UINT32    length,\r
-  IN OUT  INT8      **Pindex\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Parse rightfactor in bool expression.\r
-\r
-Arguments:\r
-\r
-  Pbegin    The pointer to the string  \r
-  length    length of the string\r
-  Pindex    The pointer of pointer to the next parse character in the string\r
-\r
-Returns:\r
-\r
-  BOOLEAN   If string is a valid rightfactor expression, return TRUE, otherwise FALSE\r
-\r
-\r
---*/\r
-{\r
-  INT8  *Pin;\r
-\r
-  Pin = *Pindex;\r
-  LeftTrim (Pbegin, length, Pindex);\r
-\r
-  //\r
-  // <rightfactor> ::=AND <term> <rightbool> <rightfactor>\r
-  //\r
-  if (strncmp (*Pindex, OPERATOR_AND, strlen (OPERATOR_AND)) == 0) {\r
-    *Pindex += strlen (OPERATOR_AND);\r
-    LeftTrim (Pbegin, length, Pindex);\r
-\r
-    if (ParseTerm (Pbegin, length, Pindex)) {\r
-      LeftTrim (Pbegin, length, Pindex);\r
-\r
-      if (ParseRightBool (Pbegin, length, Pindex)) {\r
-        LeftTrim (Pbegin, length, Pindex);\r
-        if (ParseRightFactor (Pbegin, length, Pindex)) {\r
-          return TRUE;\r
-        } else {\r
-          *Pindex = Pin;\r
-        }\r
-      } else {\r
-        *Pindex = Pin;\r
-      }\r
-    } else {\r
-      *Pindex = Pin;\r
-    }\r
-  }\r
-  //\r
-  // <rightfactor> ::=OR <term> <rightbool> <rightfactor>\r
-  //\r
-  if (strncmp (*Pindex, OPERATOR_OR, strlen (OPERATOR_OR)) == 0) {\r
-    *Pindex += strlen (OPERATOR_OR);\r
-    LeftTrim (Pbegin, length, Pindex);\r
-\r
-    if (ParseTerm (Pbegin, length, Pindex)) {\r
-      LeftTrim (Pbegin, length, Pindex);\r
-\r
-      if (ParseRightBool (Pbegin, length, Pindex)) {\r
-        LeftTrim (Pbegin, length, Pindex);\r
-        if (ParseRightFactor (Pbegin, length, Pindex)) {\r
-          return TRUE;\r
-        } else {\r
-          *Pindex = Pin;\r
-        }\r
-      } else {\r
-        *Pindex = Pin;\r
-      }\r
-    } else {\r
-      *Pindex = Pin;\r
-    }\r
-  }\r
-  //\r
-  // <rightfactor> ::= ''\r
-  //\r
-  *Pindex = Pin;\r
-  return TRUE;\r
-}\r
-\r
-BOOLEAN\r
-ParseRightBool (\r
-  IN      INT8      *Pbegin,\r
-  IN      UINT32    length,\r
-  IN OUT  INT8      **Pindex\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Parse rightbool in bool expression.\r
-\r
-Arguments:\r
-\r
-  Pbegin    The pointer to the string  \r
-  length    length of the string\r
-  Pindex    The pointer of pointer to the next parse character in the string\r
-\r
-Returns:\r
-\r
-  BOOLEAN   If string is a valid rightbool expression, return TRUE, otherwise FALSE\r
-\r
-\r
---*/\r
-{\r
-  INT8  *Pin;\r
-\r
-  Pin = *Pindex;\r
-  LeftTrim (Pbegin, length, Pindex);\r
-\r
-  //\r
-  // <rightbool>::= AND <term><rightbool>\r
-  //\r
-  if (strncmp (*Pindex, OPERATOR_AND, strlen (OPERATOR_AND)) == 0) {\r
-    *Pindex += strlen (OPERATOR_AND);\r
-    LeftTrim (Pbegin, length, Pindex);\r
-\r
-    if (ParseTerm (Pbegin, length, Pindex)) {\r
-      LeftTrim (Pbegin, length, Pindex);\r
-\r
-      if (ParseRightBool (Pbegin, length, Pindex)) {\r
-        return TRUE;\r
-      } else {\r
-        *Pindex = Pin;\r
-      }\r
-    } else {\r
-      *Pindex = Pin;\r
-    }\r
-  }\r
-  //\r
-  // <rightbool>::=  OR <term><rightbool>\r
-  //\r
-  if (strncmp (*Pindex, OPERATOR_OR, strlen (OPERATOR_OR)) == 0) {\r
-    *Pindex += strlen (OPERATOR_OR);\r
-    LeftTrim (Pbegin, length, Pindex);\r
-\r
-    if (ParseTerm (Pbegin, length, Pindex)) {\r
-      LeftTrim (Pbegin, length, Pindex);\r
-\r
-      if (ParseRightBool (Pbegin, length, Pindex)) {\r
-        return TRUE;\r
-      } else {\r
-        *Pindex = Pin;\r
-      }\r
-    } else {\r
-      *Pindex = Pin;\r
-    }\r
-  }\r
-  //\r
-  // <rightbool>::= ''\r
-  //\r
-  *Pindex = Pin;\r
-  return TRUE;\r
-}\r
-\r
-BOOLEAN\r
-ParseFactor (\r
-  IN      INT8      *Pbegin,\r
-  IN      UINT32    length,\r
-  IN OUT  INT8      **Pindex\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Parse factor in bool expression.\r
-\r
-Arguments:\r
-\r
-  Pbegin    The pointer to the string  \r
-  length    length of the string\r
-  Pindex    The pointer of pointer to the next parse character in the string\r
-\r
-Returns:\r
-\r
-  BOOLEAN   If string is a valid factor, return TRUE, otherwise FALSE\r
-\r
-\r
---*/\r
-{\r
-  INT8  *Pin;\r
-\r
-  Pin = *Pindex;\r
-  LeftTrim (Pbegin, length, Pindex);\r
-\r
-  //\r
-  // <factor>   ::= '('<bool>')'<rightfactor>\r
-  //\r
-  if (strncmp (*Pindex, OPERATOR_LEFT_PARENTHESIS, strlen (OPERATOR_LEFT_PARENTHESIS)) == 0) {\r
-    *Pindex += strlen (OPERATOR_LEFT_PARENTHESIS);\r
-    LeftTrim (Pbegin, length, Pindex);\r
-\r
-    if (!ParseBool (Pbegin, length, Pindex)) {\r
-      *Pindex = Pin;\r
-    } else {\r
-      LeftTrim (Pbegin, length, Pindex);\r
-\r
-      if (strncmp (*Pindex, OPERATOR_RIGHT_PARENTHESIS, strlen (OPERATOR_RIGHT_PARENTHESIS)) == 0) {\r
-        *Pindex += strlen (OPERATOR_RIGHT_PARENTHESIS);\r
-        LeftTrim (Pbegin, length, Pindex);\r
-\r
-        if (ParseRightFactor (Pbegin, length, Pindex)) {\r
-          return TRUE;\r
-        } else {\r
-          *Pindex = Pin;\r
-        }\r
-      }\r
-    }\r
-  }\r
-  //\r
-  // <factor>   ::= NOT <factor> <rightbool> <rightfactor>\r
-  //\r
-  if (strncmp (*Pindex, OPERATOR_NOT, strlen (OPERATOR_NOT)) == 0) {\r
-    *Pindex += strlen (OPERATOR_NOT);\r
-    LeftTrim (Pbegin, length, Pindex);\r
-\r
-    if (ParseFactor (Pbegin, length, Pindex)) {\r
-      LeftTrim (Pbegin, length, Pindex);\r
-\r
-      if (ParseRightBool (Pbegin, length, Pindex)) {\r
-        LeftTrim (Pbegin, length, Pindex);\r
-\r
-        if (ParseRightFactor (Pbegin, length, Pindex)) {\r
-          return TRUE;\r
-        } else {\r
-          *Pindex = Pin;\r
-        }\r
-      } else {\r
-        *Pindex = Pin;\r
-      }\r
-    } else {\r
-      *Pindex = Pin;\r
-    }\r
-  }\r
-  //\r
-  // <factor>   ::= TRUE <rightfactor>\r
-  //\r
-  if (strncmp (*Pindex, OPERATOR_TRUE, strlen (OPERATOR_TRUE)) == 0) {\r
-    *Pindex += strlen (OPERATOR_TRUE);\r
-    LeftTrim (Pbegin, length, Pindex);\r
-\r
-    if (ParseRightFactor (Pbegin, length, Pindex)) {\r
-      return TRUE;\r
-    } else {\r
-      *Pindex = Pin;\r
-    }\r
-  }\r
-  //\r
-  // <factor>   ::= FALSE <rightfactor>\r
-  //\r
-  if (strncmp (*Pindex, OPERATOR_FALSE, strlen (OPERATOR_FALSE)) == 0) {\r
-    *Pindex += strlen (OPERATOR_FALSE);\r
-    LeftTrim (Pbegin, length, Pindex);\r
-\r
-    if (ParseRightFactor (Pbegin, length, Pindex)) {\r
-      return TRUE;\r
-    } else {\r
-      *Pindex = Pin;\r
-    }\r
-  }\r
-  //\r
-  // <factor>   ::= <guid> <rightfactor>\r
-  //\r
-  if (ParseGuid (Pbegin, length, Pindex)) {\r
-    LeftTrim (Pbegin, length, Pindex);\r
-\r
-    if (ParseRightFactor (Pbegin, length, Pindex)) {\r
-      return TRUE;\r
-    } else {\r
-      *Pindex = Pin;\r
-      return FALSE;\r
-    }\r
-  } else {\r
-    *Pindex = Pin;\r
-    return FALSE;\r
-  }\r
-}\r
-\r
-BOOLEAN\r
-ParseTerm (\r
-  IN      INT8      *Pbegin,\r
-  IN      UINT32    length,\r
-  IN OUT  INT8      **Pindex\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Parse term in bool expression.\r
-\r
-Arguments:\r
-\r
-  Pbegin    The pointer to the string  \r
-  length    length of the string\r
-  Pindex    The pointer of pointer to the next parse character in the string\r
-\r
-Returns:\r
-\r
-  BOOLEAN   If string is a valid term, return TRUE, otherwise FALSE\r
-\r
-\r
---*/\r
-{\r
-  INT8  *Pin;\r
-\r
-  Pin = *Pindex;\r
-  LeftTrim (Pbegin, length, Pindex);\r
-\r
-  //\r
-  // <term>     ::= NOT <factor>\r
-  //\r
-  if (strncmp (*Pindex, OPERATOR_NOT, strlen (OPERATOR_NOT)) == 0) {\r
-    *Pindex += strlen (OPERATOR_NOT);\r
-    LeftTrim (Pbegin, length, Pindex);\r
-\r
-    if (!ParseFactor (Pbegin, length, Pindex)) {\r
-      *Pindex = Pin;\r
-    } else {\r
-      return TRUE;\r
-    }\r
-  }\r
-  //\r
-  // <term>     ::=<factor>\r
-  //\r
-  if (ParseFactor (Pbegin, length, Pindex)) {\r
-    return TRUE;\r
-  } else {\r
-    *Pindex = Pin;\r
-    return FALSE;\r
-  }\r
-}\r
-\r
-BOOLEAN\r
-ParseBool (\r
-  IN      INT8      *Pbegin,\r
-  IN      UINT32    length,\r
-  IN OUT  INT8      **Pindex\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Parse bool expression.\r
-\r
-Arguments:\r
-\r
-  Pbegin    The pointer to the string  \r
-  length    length of the string\r
-  Pindex    The pointer of pointer to the next parse character in the string\r
-\r
-Returns:\r
-\r
-  BOOLEAN   If string is a valid bool expression, return TRUE, otherwise FALSE\r
-\r
-\r
---*/\r
-{\r
-  INT8  *Pin;\r
-  Pin = *Pindex;\r
-  LeftTrim (Pbegin, length, Pindex);\r
-\r
-  if (ParseTerm (Pbegin, length, Pindex)) {\r
-    LeftTrim (Pbegin, length, Pindex);\r
-\r
-    if (!ParseRightBool (Pbegin, length, Pindex)) {\r
-      *Pindex = Pin;\r
-      return FALSE;\r
-    } else {\r
-      return TRUE;\r
-    }\r
-  } else {\r
-    *Pindex = Pin;\r
-    return FALSE;\r
-  }\r
-}\r
-\r
-BOOLEAN\r
-ParseDepex (\r
-  IN      INT8      *Pbegin,\r
-  IN      UINT32    length\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Parse whole dependency expression.\r
-\r
-Arguments:\r
-\r
-  Pbegin    The pointer to the string  \r
-  length    length of the string\r
-\r
-Returns:\r
-\r
-  BOOLEAN   If string is a valid dependency expression, return TRUE, otherwise FALSE\r
-\r
-\r
---*/\r
-{\r
-  BOOLEAN Result;\r
-  INT8    **Pindex;\r
-  INT8    *temp;\r
-\r
-  Result  = FALSE;\r
-  temp    = Pbegin;\r
-  Pindex  = &temp;\r
-\r
-  LeftTrim (Pbegin, length, Pindex);\r
-  if (strncmp (*Pindex, OPERATOR_BEFORE, strlen (OPERATOR_BEFORE)) == 0) {\r
-    (*Pindex) += strlen (OPERATOR_BEFORE);\r
-    Result = ParseGuid (Pbegin, length, Pindex);\r
-\r
-  } else if (strncmp (*Pindex, OPERATOR_AFTER, strlen (OPERATOR_AFTER)) == 0) {\r
-    (*Pindex) += strlen (OPERATOR_AFTER);\r
-    Result = ParseGuid (Pbegin, length, Pindex);\r
-\r
-  } else if (strncmp (*Pindex, OPERATOR_SOR, strlen (OPERATOR_SOR)) == 0) {\r
-    (*Pindex) += strlen (OPERATOR_SOR);\r
-    Result = ParseBool (Pbegin, length, Pindex);\r
-\r
-  } else {\r
-    Result = ParseBool (Pbegin, length, Pindex);\r
-\r
-  }\r
-\r
-  LeftTrim (Pbegin, length, Pindex);\r
-  return (BOOLEAN) (Result && (*Pindex) >= (Pbegin + length));\r
-}\r
diff --git a/Tools/CodeTools/TianoTools/GenDepex/DepexParser.h b/Tools/CodeTools/TianoTools/GenDepex/DepexParser.h
deleted file mode 100644 (file)
index 29e0884..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-/*++\r
-Copyright (c) 2004, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-  Module Name:  \r
-          GenDepex.h\r
-\r
-  Abstract:\r
-          This file contains the relevant declarations required\r
-          to generate a binary Dependency File\r
-\r
-  Complies with Tiano C Coding Standards Document, version 0.31, 12 Dec 2000.\r
-\r
---*/\r
-\r
-// TODO: fix comment to set correct module name: DepexParser.h\r
-#ifndef _EFI_DEPEX_PARSER_H_\r
-#define _EFI_DEPEX_PARSER_H_\r
-#include "GenDepex.h"\r
-#endif\r
diff --git a/Tools/CodeTools/TianoTools/GenDepex/GenDepex.c b/Tools/CodeTools/TianoTools/GenDepex/GenDepex.c
deleted file mode 100644 (file)
index 3818649..0000000
+++ /dev/null
@@ -1,919 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2004, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-Module Name:\r
-\r
-  GenDepex.c\r
-\r
-Abstract:\r
-\r
-  Generate Dependency Expression ("GenDepex")\r
-\r
-  Infix to Postfix Algorithm\r
-\r
-  This code has been scrubbed to be free of having any EFI core tree dependencies.\r
-  It should build in any environment that supports a standard C-library w/ string\r
-  operations and File I/O services.\r
-\r
-  As an example of usage, consider the following:\r
-\r
-  The input user file could be something like "Sample.DXS" whose contents are\r
-\r
-    #include "Tiano.h"\r
-\r
-    DEPENDENCY_START\r
-      NOT (DISK_IO_PROTOCOL AND SIMPLE_FILE_SYSTEM_PROTOCOL) \r
-        OR EFI_PXE_BASE_CODE_PROTOCOL\r
-    DEPENDENCY_END\r
-\r
-  This file is then washed through the C-preprocessor, viz.,\r
-\r
-    cl /EP Sample.DXS > Sample.TMP1\r
-\r
-  This yields the following file "Sample.TMP1" whose contents are\r
-\r
-    DEPENDENCY_START\r
-      NOT ({ 0xce345171, 0xba0b, 0x11d2, 0x8e, 0x4f, 0x0, 0xa0, 0xc9, 0x69, 0x72,\r
-        0x3b } AND { 0x964e5b22, 0x6459, 0x11d2, 0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69,\r
-        0x72, 0x3b }) OR { 0x03c4e603, 0xac28, 0x11d3, 0x9a, 0x2d, 0x00, 0x90, 0x27,\r
-        0x3f, 0xc1, 0x4d }\r
-    DEPENDENCY_END\r
-\r
-  This file, in turn, will be fed into the utility, viz.,\r
-\r
-    GenDepex Sample.TMP1 Sample.TMP2\r
-\r
-  With a file that is 55 bytes long:\r
-\r
-     55 bytes for the grammar binary\r
-        PUSH opcode         - 1  byte\r
-        GUID Instance       - 16 bytes\r
-        PUSH opcode         - 1  byte\r
-        GUID Instance       - 16 bytes\r
-        AND opcode          - 1  byte\r
-        NOT opcode          - 1  byte\r
-        PUSH opcode         - 1  byte\r
-        GUID Instance       - 16 bytes\r
-        OR opcode           - 1  byte\r
-        END opcode          - 1  byte\r
-\r
-  The file "Sample.TMP2" could be fed via a Section-builder utility \r
-  (GenSection) that would be used for the creation of a dependency\r
-  section file (.DPX) which in turn would be used by a generate FFS\r
-  utility (GenFfsFile) to produce a DXE driver/core (.DXE) or \r
-  a DXE application (.APP) file.\r
-\r
-  Complies with Tiano C Coding Standards Document, version 0.31, 12 Dec 2000.\r
-\r
---*/\r
-\r
-#include "GenDepex.h"\r
-\r
-#define TOOL_NAME "GenDepex"\r
-\r
-extern\r
-ParseDepex (\r
-  IN      INT8      *Pbegin,\r
-  IN      UINT32    length\r
-  );\r
-\r
-VOID\r
-PrintGenDepexUtilityInfo (\r
-  VOID\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Displays the standard utility information to SDTOUT.\r
-\r
-Arguments:\r
-\r
-  None\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-{\r
-  printf (\r
-    "%s, Tiano Dependency Expression Generation Utility. Version %d.%d.\n",\r
-    UTILITY_NAME,\r
-    UTILITY_MAJOR_VERSION,\r
-    UTILITY_MINOR_VERSION\r
-    );\r
-  printf ("Copyright (C) 1996-2002 Intel Corporation.  All rights reserved.\n\n");\r
-}\r
-\r
-VOID\r
-PrintGenDepexUsageInfo (\r
-  VOID\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Displays the utility usage syntax to STDOUT.\r
-\r
-Arguments:\r
-\r
-  None\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-{\r
-  printf (\r
-    "Usage: %s -I <INFILE> -O <OUTFILE> [-P <Optional Boundary for padding up>] \n",\r
-    UTILITY_NAME\r
-    );\r
-  printf (" Where:\n");\r
-  printf ("  <INFILE> is the input pre-processed dependency text files name.\n");\r
-  printf ("  <OUTFILE> is the output binary dependency files name.\n");\r
-  printf ("  <Optional Boundary for padding up> is the padding integer value.\n");\r
-  printf ("    This is the boundary to align the output file size to.\n");\r
-}\r
-\r
-DEPENDENCY_OPCODE\r
-PopOpCode (\r
-  IN OUT VOID **Stack\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Pop an element from the Opcode stack.\r
-\r
-Arguments:\r
-\r
-  Stack               Current top of the OpCode stack location\r
-\r
-Returns:\r
-\r
-  DEPENDENCY_OPCODE   OpCode at the top of the OpCode stack.\r
-  Stack               New top of the OpCode stack location\r
-\r
-\r
---*/\r
-{\r
-  DEPENDENCY_OPCODE *OpCodePtr;\r
-\r
-  OpCodePtr = *Stack;\r
-  OpCodePtr--;\r
-  *Stack = OpCodePtr;\r
-  return *OpCodePtr;\r
-}\r
-\r
-VOID\r
-PushOpCode (\r
-  IN OUT  VOID                **Stack,\r
-  IN      DEPENDENCY_OPCODE   OpCode\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Push an element onto the Opcode Stack\r
-\r
-Arguments:\r
-\r
-  Stack     Current top of the OpCode stack location\r
-  OpCode    OpCode to push onto the stack\r
-\r
-Returns:\r
-\r
-  Stack     New top of the OpCode stack location\r
-\r
---*/\r
-{\r
-  DEPENDENCY_OPCODE *OpCodePtr;\r
-\r
-  OpCodePtr   = *Stack;\r
-  *OpCodePtr  = OpCode;\r
-  OpCodePtr++;\r
-  *Stack = OpCodePtr;\r
-}\r
-\r
-EFI_STATUS\r
-GenerateDependencyExpression (\r
-  IN     FILE           *InFile,\r
-  IN OUT FILE           *OutFile,\r
-  IN     INT8           Padding  OPTIONAL\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  This takes the pre-compiled dependency text file and \r
-  converts it into a binary dependency file.\r
-\r
-  The BNF for the dependency expression is as follows \r
-  (from the DXE 1.0 Draft specification).\r
-\r
-  The inputted BNF grammar is thus:\r
-    <depex> ::= sor <dep> | \r
-                before GUID <dep> | \r
-                after GUID <dep> | \r
-                <bool>\r
-\r
-    <dep> ::=   <bool> |\r
-\r
-    <bool> ::=  <bool> and <term> | \r
-                <bool> or <term> | \r
-                <term>\r
-\r
-    <term> ::=  not <factor> | \r
-                <factor>\r
-\r
-    <factor> ::= ( <bool> ) | \r
-                 <term> <term> | \r
-                 GUID | \r
-                 <boolval>\r
-\r
-    <boolval> ::= true | \r
-                  false\r
-\r
-  The outputed binary grammer is thus:\r
-    <depex> ::= sor <dep> | \r
-                before <depinst> <dep> | \r
-                after <depinst> <dep> | \r
-                <bool>\r
-\r
-    <dep> ::=   <bool> |\r
-\r
-    <bool> ::=  <bool> and <term> | \r
-                <bool> or <term> | <term>\r
-\r
-    <term> ::=  not <factor> | \r
-                <factor>\r
-\r
-    <factor> ::= ( <bool> ) | \r
-                 <term> <term> | \r
-                 <boolval> | \r
-                 <depinst> | \r
-                 <termval>\r
-\r
-    <boolval> ::= true | \r
-                  false\r
-\r
-    <depinst> ::= push GUID\r
-\r
-    <termval> ::= end\r
-\r
-  BugBug: A correct grammer is parsed correctly. A file that violates the\r
-          grammer may parse when it should generate an error. There is some\r
-          error checking and it covers most of the case when it's an include\r
-          of definition issue. An ill formed expresion may not be detected.\r
-\r
-Arguments:\r
-\r
-  InFile -  Input pre-compiled text file of the dependency expression.\r
-            This needs to be in ASCII.\r
-            The file pointer can not be NULL.\r
-\r
-  OutFile - Binary dependency file.\r
-            The file pointer can not be NULL.\r
-\r
-  Padding - OPTIONAL integer value to pad the output file to.\r
-\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS             The function completed successfully.\r
-  EFI_INVALID_PARAMETER   One of the parameters in the text file was invalid.\r
-  EFI_OUT_OF_RESOURCES    Unable to allocate memory.\r
-  EFI_ABORTED             An misc error occurred.\r
-\r
---*/\r
-{\r
-  INT8              *Ptrx;\r
-  INT8              *Pend;\r
-  INT8              *EvaluationStack;\r
-  INT8              *StackPtr;\r
-  INT8              *Buffer;\r
-  INT8              Line[LINESIZE];\r
-  UINTN             Index;\r
-  UINTN             OutFileSize;\r
-  UINTN             FileSize;\r
-  UINTN             Results;\r
-  BOOLEAN           NotDone;\r
-  BOOLEAN           Before_Flag;\r
-  BOOLEAN           After_Flag;\r
-  BOOLEAN           Dep_Flag;\r
-  BOOLEAN           SOR_Flag;\r
-  EFI_GUID          Guid;\r
-  UINTN             ArgCountParsed;\r
-  DEPENDENCY_OPCODE Opcode;\r
-\r
-  Before_Flag = FALSE;\r
-  After_Flag  = FALSE;\r
-  Dep_Flag    = FALSE;\r
-  SOR_Flag    = FALSE;\r
-\r
-  memset (Line, 0, LINESIZE);\r
-\r
-  OutFileSize     = 0;\r
-\r
-  EvaluationStack = (INT8 *) malloc (EVAL_STACK_SIZE);\r
-\r
-  if (EvaluationStack != NULL) {\r
-    StackPtr = EvaluationStack;\r
-  } else {\r
-    printf ("Unable to allocate memory to EvaluationStack - Out of resources\n");\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-\r
-  Results = (UINTN) fseek (InFile, 0, SEEK_END);\r
-\r
-  if (Results != 0) {\r
-    printf ("FSEEK failed - Aborted\n");\r
-    return EFI_ABORTED;\r
-  }\r
-\r
-  FileSize = ftell (InFile);\r
-\r
-  if (FileSize == -1L) {\r
-    printf ("FTELL failed - Aborted\n");\r
-    return EFI_ABORTED;\r
-  }\r
-\r
-  Buffer = (INT8 *) malloc (FileSize + BUFFER_SIZE);\r
-\r
-  if (Buffer == NULL) {\r
-    printf ("Unable to allocate memory to Buffer - Out of resources\n");\r
-    free (EvaluationStack);\r
-\r
-    Results = (UINTN) fclose (InFile);\r
-    if (Results != 0) {\r
-      printf ("FCLOSE failed\n");\r
-    }\r
-\r
-    Results = (UINTN) fclose (OutFile);\r
-    if (Results != 0) {\r
-      printf ("FCLOSE failed\n");\r
-    }\r
-\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-\r
-  Results = (UINTN) fseek (InFile, 0, SEEK_SET);\r
-\r
-  if (Results != 0) {\r
-    printf ("FSEEK failed - Aborted\n");\r
-    return EFI_ABORTED;\r
-  }\r
-\r
-  memset (Buffer, 0, FileSize + BUFFER_SIZE);\r
-  fread (Buffer, FileSize, 1, InFile);\r
-\r
-  Ptrx    = Buffer;\r
-  Pend    = Ptrx + FileSize - strlen (DEPENDENCY_END);\r
-  Index   = FileSize;\r
-\r
-  NotDone = TRUE;\r
-  while ((Index--) && NotDone) {\r
-\r
-    if (strncmp (Pend, DEPENDENCY_END, strlen (DEPENDENCY_END)) == 0) {\r
-      NotDone = FALSE;\r
-    } else {\r
-      Pend--;\r
-    }\r
-  }\r
-\r
-  if (NotDone) {\r
-    printf ("Couldn't find end string %s\n", DEPENDENCY_END);\r
-\r
-    Results = (UINTN) fclose (InFile);\r
-    if (Results != 0) {\r
-      printf ("FCLOSE failed\n");\r
-    }\r
-\r
-    Results = (UINTN) fclose (OutFile);\r
-    if (Results != 0) {\r
-      printf ("FCLOSE failed\n");\r
-    }\r
-\r
-    free (Buffer);\r
-    free (EvaluationStack);\r
-\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  Index   = FileSize;\r
-\r
-  NotDone = TRUE;\r
-  while ((Index--) && NotDone) {\r
-\r
-    if (strncmp (Ptrx, DEPENDENCY_START, strlen (DEPENDENCY_START)) == 0) {\r
-      Ptrx += sizeof (DEPENDENCY_START);\r
-      NotDone = FALSE;\r
-      //\r
-      // BUGBUG -- should Index be decremented by sizeof(DEPENDENCY_START)?\r
-      //\r
-    } else {\r
-      Ptrx++;\r
-    }\r
-  }\r
-\r
-  if (NotDone) {\r
-    printf ("Couldn't find start string %s\n", DEPENDENCY_START);\r
-\r
-    Results = (UINTN) fclose (InFile);\r
-    if (Results != 0) {\r
-      printf ("FCLOSE failed\n");\r
-    }\r
-\r
-    Results = (UINTN) fclose (OutFile);\r
-    if (Results != 0) {\r
-      printf ("FCLOSE failed\n");\r
-    }\r
-\r
-    free (Buffer);\r
-    free (EvaluationStack);\r
-\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-  //\r
-  //  validate the syntax of expression\r
-  //\r
-  if (!ParseDepex (Ptrx, Pend - Ptrx - 1)) {\r
-    printf ("The syntax of expression is wrong\n");\r
-\r
-    Results = (UINTN) fclose (InFile);\r
-    if (Results != 0) {\r
-      printf ("FCLOSE failed\n");\r
-    }\r
-\r
-    Results = (UINTN) fclose (OutFile);\r
-    if (Results != 0) {\r
-      printf ("FCLOSE failed\n");\r
-    }\r
-\r
-    free (Buffer);\r
-    free (EvaluationStack);\r
-\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  NotDone = TRUE;\r
-\r
-  while ((Index--) && NotDone) {\r
-\r
-    if (*Ptrx == ' ') {\r
-      Ptrx++;\r
-    } else if (*Ptrx == '\n' || *Ptrx == '\r') {\r
-      Ptrx++;\r
-    } else if (strncmp (Ptrx, OPERATOR_SOR, strlen (OPERATOR_SOR)) == 0) {\r
-      //\r
-      //  Checks for some invalid dependencies\r
-      //\r
-      if (Before_Flag) {\r
-\r
-        printf ("A BEFORE operator was detected.\n");\r
-        printf ("There can only be one SOR or one AFTER or one BEFORE operator\n");\r
-        return EFI_INVALID_PARAMETER;\r
-\r
-      } else if (After_Flag) {\r
-\r
-        printf ("An AFTER operator was detected.\n");\r
-        printf ("There can only be one SOR or one AFTER or one BEFORE operator\n");\r
-        return EFI_INVALID_PARAMETER;\r
-\r
-      } else if (SOR_Flag) {\r
-\r
-        printf ("Another SOR operator was detected.\n");\r
-        printf ("There can only be one SOR or one AFTER or one BEFORE operator\n");\r
-        return EFI_INVALID_PARAMETER;\r
-\r
-      } else if (Dep_Flag) {\r
-\r
-        printf ("The Schedule On Request - SOR operator must be the first operator following DEPENDENCY_START\n");\r
-        return EFI_INVALID_PARAMETER;\r
-\r
-      } else {\r
-        //\r
-        //  BUGBUG - This was not in the spec but is in the CORE code\r
-        //  An OPERATOR_SOR has to be first - following the DEPENDENCY_START\r
-        //\r
-        fputc (EFI_DEP_SOR, OutFile);\r
-        OutFileSize++;\r
-        Ptrx += sizeof (OPERATOR_SOR);\r
-        SOR_Flag = TRUE;\r
-\r
-      }\r
-    } else if (strncmp (Ptrx, OPERATOR_BEFORE, strlen (OPERATOR_BEFORE)) == 0) {\r
-      //\r
-      //  Checks for some invalid dependencies\r
-      //\r
-      if (Before_Flag) {\r
-\r
-        printf ("Another BEFORE operator was detected.\n");\r
-        printf ("There can only be one SOR or one AFTER or one BEFORE operator\n");\r
-        return EFI_INVALID_PARAMETER;\r
-\r
-      } else if (After_Flag) {\r
-\r
-        printf ("An AFTER operator was detected.\n");\r
-        printf ("There can only be one SOR or one AFTER or one BEFORE operator\n");\r
-        return EFI_INVALID_PARAMETER;\r
-\r
-      } else if (SOR_Flag) {\r
-\r
-        printf ("A SOR operator was detected.\n");\r
-        printf ("There can only be one SOR or one AFTER or one BEFORE operator\n");\r
-        return EFI_INVALID_PARAMETER;\r
-\r
-      } else if (Dep_Flag) {\r
-\r
-        printf ("The BEFORE operator must be the first operator following DEPENDENCY_START\n");\r
-        return EFI_INVALID_PARAMETER;\r
-\r
-      } else {\r
-        fputc (EFI_DEP_BEFORE, OutFile);\r
-        OutFileSize++;\r
-        Ptrx += sizeof (OPERATOR_BEFORE);\r
-        Before_Flag = TRUE;\r
-      }\r
-    } else if (strncmp (Ptrx, OPERATOR_AFTER, strlen (OPERATOR_AFTER)) == 0) {\r
-      //\r
-      //  Checks for some invalid dependencies\r
-      //\r
-      if (Before_Flag) {\r
-\r
-        printf ("A BEFORE operator was detected.\n");\r
-        printf ("There can only be one SOR or one AFTER or one BEFORE operator\n");\r
-        return EFI_INVALID_PARAMETER;\r
-\r
-      } else if (After_Flag) {\r
-\r
-        printf ("Another AFTER operator was detected.\n");\r
-        printf ("There can only be one SOR or one AFTER or one BEFORE operator\n");\r
-        return EFI_INVALID_PARAMETER;\r
-\r
-      } else if (SOR_Flag) {\r
-\r
-        printf ("A SOR operator was detected.\n");\r
-        printf ("There can only be one SOR or one AFTER or one BEFORE operator\n");\r
-        return EFI_INVALID_PARAMETER;\r
-\r
-      } else if (Dep_Flag) {\r
-\r
-        printf ("The AFTER operator must be the first operator following DEPENDENCY_START\n");\r
-        return EFI_INVALID_PARAMETER;\r
-\r
-      } else {\r
-        fputc (EFI_DEP_AFTER, OutFile);\r
-        OutFileSize++;\r
-        Ptrx += sizeof (OPERATOR_AFTER);\r
-        Dep_Flag    = TRUE;\r
-        After_Flag  = TRUE;\r
-      }\r
-    } else if (strncmp (Ptrx, OPERATOR_AND, strlen (OPERATOR_AND)) == 0) {\r
-      while (StackPtr != EvaluationStack) {\r
-        Opcode = PopOpCode ((VOID **) &StackPtr);\r
-        if (Opcode != DXE_DEP_LEFT_PARENTHESIS) {\r
-          fputc (Opcode, OutFile);\r
-          OutFileSize++;\r
-        } else {\r
-          PushOpCode ((VOID **) &StackPtr, DXE_DEP_LEFT_PARENTHESIS);\r
-          break;\r
-        }\r
-      }\r
-\r
-      PushOpCode ((VOID **) &StackPtr, EFI_DEP_AND);\r
-      Ptrx += sizeof (OPERATOR_AND);\r
-      Dep_Flag = TRUE;\r
-\r
-    } else if (strncmp (Ptrx, OPERATOR_OR, strlen (OPERATOR_OR)) == 0) {\r
-      while (StackPtr != EvaluationStack) {\r
-        Opcode = PopOpCode ((VOID **) &StackPtr);\r
-        if (Opcode != DXE_DEP_LEFT_PARENTHESIS) {\r
-          fputc (Opcode, OutFile);\r
-          OutFileSize++;\r
-        } else {\r
-          PushOpCode ((VOID **) &StackPtr, DXE_DEP_LEFT_PARENTHESIS);\r
-          break;\r
-        }\r
-      }\r
-\r
-      PushOpCode ((VOID **) &StackPtr, EFI_DEP_OR);\r
-      Ptrx += sizeof (OPERATOR_OR);\r
-      Dep_Flag = TRUE;\r
-\r
-    } else if (strncmp (Ptrx, OPERATOR_NOT, strlen (OPERATOR_NOT)) == 0) {\r
-      while (StackPtr != EvaluationStack) {\r
-        Opcode = PopOpCode ((VOID **) &StackPtr);\r
-        if (Opcode != DXE_DEP_LEFT_PARENTHESIS) {\r
-          fputc (Opcode, OutFile);\r
-          OutFileSize++;\r
-        } else {\r
-          PushOpCode ((VOID **) &StackPtr, DXE_DEP_LEFT_PARENTHESIS);\r
-          break;\r
-        }\r
-      }\r
-\r
-      PushOpCode ((VOID **) &StackPtr, EFI_DEP_NOT);\r
-      Ptrx += sizeof (OPERATOR_NOT);\r
-      Dep_Flag = TRUE;\r
-\r
-    } else if (*Ptrx == '\t') {\r
-\r
-      printf ("File contains tabs. This violates the coding standard\n");\r
-      return EFI_INVALID_PARAMETER;\r
-\r
-    } else if (*Ptrx == '\n') {\r
-      //\r
-      // Skip the newline character in the file\r
-      //\r
-      Ptrx++;\r
-\r
-    } else if (strncmp (Ptrx, OPERATOR_LEFT_PARENTHESIS, strlen (OPERATOR_LEFT_PARENTHESIS)) == 0) {\r
-      PushOpCode ((VOID **) &StackPtr, DXE_DEP_LEFT_PARENTHESIS);\r
-\r
-      Ptrx += strlen (OPERATOR_LEFT_PARENTHESIS);\r
-      Dep_Flag = TRUE;\r
-\r
-    } else if (strncmp (Ptrx, OPERATOR_RIGHT_PARENTHESIS, strlen (OPERATOR_RIGHT_PARENTHESIS)) == 0) {\r
-      while (StackPtr != EvaluationStack) {\r
-        Opcode = PopOpCode ((VOID **) &StackPtr);\r
-        if (Opcode != DXE_DEP_LEFT_PARENTHESIS) {\r
-          fputc (Opcode, OutFile);\r
-          OutFileSize++;\r
-        } else {\r
-          break;\r
-        }\r
-      }\r
-\r
-      Ptrx += strlen (OPERATOR_RIGHT_PARENTHESIS);\r
-      Dep_Flag = TRUE;\r
-\r
-    } else if (strncmp (Ptrx, OPERATOR_TRUE, strlen (OPERATOR_TRUE)) == 0) {\r
-\r
-      fputc (EFI_DEP_TRUE, OutFile);\r
-\r
-      OutFileSize++;\r
-\r
-      //\r
-      // OutFileSize += sizeof (EFI_DEP_TRUE);\r
-      //\r
-      Dep_Flag = TRUE;\r
-\r
-      Ptrx += strlen (OPERATOR_TRUE);\r
-\r
-    } else if (strncmp (Ptrx, OPERATOR_FALSE, strlen (OPERATOR_FALSE)) == 0) {\r
-\r
-      fputc (EFI_DEP_FALSE, OutFile);\r
-\r
-      OutFileSize++;\r
-\r
-      //\r
-      // OutFileSize += sizeof (EFI_DEP_FALSE);\r
-      //\r
-      Dep_Flag = TRUE;\r
-\r
-      Ptrx += strlen (OPERATOR_FALSE);\r
-\r
-    } else if (*Ptrx == '{') {\r
-      Ptrx++;\r
-\r
-      if (*Ptrx == ' ') {\r
-        Ptrx++;\r
-      }\r
-\r
-      {\r
-        int byte_index;\r
-        // This is an array of UINT32s. sscanf will trash memory\r
-        // if you try to read into a UINT8 with a %x formatter.\r
-        UINT32 Guid_Data4[8];\r
-\r
-        ArgCountParsed = sscanf (\r
-                         Ptrx,\r
-            "%x, %x, %x, { %x, %x, %x, %x, %x, %x, %x, %x }",\r
-                         &Guid.Data1,\r
-                         &Guid.Data2,\r
-                         &Guid.Data3,\r
-                         &Guid_Data4[0],\r
-                         &Guid_Data4[1],\r
-                         &Guid_Data4[2],\r
-                         &Guid_Data4[3],\r
-                         &Guid_Data4[4],\r
-                         &Guid_Data4[5],\r
-                         &Guid_Data4[6],\r
-                         &Guid_Data4[7]\r
-                         );\r
-        \r
-        // Now we can copy the 32 bit ints into the GUID.\r
-        for (byte_index=0; byte_index<8; byte_index++) {\r
-          Guid.Data4[byte_index] = (UINT8) Guid_Data4[byte_index];\r
-        }\r
-      }\r
-\r
-      if (ArgCountParsed != 11) {\r
-        printf ("We have found an illegal GUID\n");\r
-        printf ("Fix your depex\n");\r
-        exit (-1);\r
-      }\r
-\r
-      while (*Ptrx != '}') {\r
-        Ptrx++;\r
-      }\r
-\r
-    Ptrx++;\r
-      while (*Ptrx != '}') {\r
-        Ptrx++;\r
-      }\r
-    //\r
-      // Absorb the closing }\r
-      //\r
-      Ptrx++;\r
-\r
-      //\r
-      // Don't provide a PUSH Opcode for the Before and After case\r
-      //\r
-      if ((!Before_Flag) && (!After_Flag)) {\r
-        fputc (EFI_DEP_PUSH, OutFile);\r
-        OutFileSize++;\r
-      }\r
-\r
-      fwrite (&Guid, sizeof (EFI_GUID), 1, OutFile);\r
-\r
-      OutFileSize += sizeof (EFI_GUID);\r
-      Dep_Flag = TRUE;\r
-\r
-    } else if (strncmp (Ptrx, DEPENDENCY_END, strlen (DEPENDENCY_END)) == 0) {\r
-      NotDone = FALSE;\r
-    } else {\r
-      //\r
-      // Not a valid construct. Null terminate somewhere out there and\r
-      // print an error message.\r
-      //\r
-      *(Ptrx + 20) = 0;\r
-      printf (TOOL_NAME " ERROR: Unrecognized input at: \"%s\"...\n", Ptrx);\r
-      return EFI_INVALID_PARAMETER;\r
-    }\r
-  }\r
-  //\r
-  //  DRAIN();\r
-  //\r
-  while (StackPtr != EvaluationStack) {\r
-    fputc (PopOpCode ((VOID **) &StackPtr), OutFile);\r
-    OutFileSize++;\r
-  }\r
-\r
-  if (OutFileSize == 0) {\r
-    printf ("Grammer contains no operators or constants\n");\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  fputc (EFI_DEP_END, OutFile);\r
-\r
-  OutFileSize++;\r
-\r
-  //\r
-  //  Checks for invalid padding values\r
-  //\r
-  if (Padding < 0) {\r
-\r
-    printf ("The inputted padding value was %d\n", Padding);\r
-    printf ("The optional padding value can not be less than ZERO\n");\r
-    return EFI_INVALID_PARAMETER;\r
-\r
-  } else if (Padding > 0) {\r
-\r
-    while ((OutFileSize % Padding) != 0) {\r
-\r
-      fputc (' ', OutFile);\r
-      OutFileSize++;\r
-    }\r
-  }\r
-\r
-  Results = (UINTN) fclose (InFile);\r
-  if (Results != 0) {\r
-    printf ("FCLOSE failed\n");\r
-  }\r
-\r
-  Results = (UINTN) fclose (OutFile);\r
-  if (Results != 0) {\r
-    printf ("FCLOSE failed\n");\r
-  }\r
-\r
-  free (Buffer);\r
-  free (EvaluationStack);\r
-\r
-  return EFI_SUCCESS;\r
-} // End GenerateDependencyExpression function\r
-\r
-int\r
-main (\r
-  IN UINTN argc,\r
-  IN CHAR8 *argv[]\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Parse user entries.  Print some rudimentary help\r
-\r
-Arguments:\r
-\r
-  argc    The count of input arguments\r
-  argv    The input arguments string array\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS             The function completed successfully.\r
-  EFI_INVALID_PARAMETER   One of the input parameters was invalid or one of the parameters in the text file was invalid.\r
-  EFI_OUT_OF_RESOURCES    Unable to allocate memory.\r
-  EFI_ABORTED             Unable to open/create a file or a misc error.\r
-\r
---*/\r
-// TODO:    ] - add argument and description to function comment\r
-{\r
-  FILE    *OutFile;\r
-  FILE    *InFile;\r
-  UINT8   Padding;\r
-  UINTN   Index;\r
-  BOOLEAN Input_Flag;\r
-  BOOLEAN Output_Flag;\r
-  BOOLEAN Pad_Flag;\r
-\r
-  InFile      = NULL;\r
-  OutFile     = NULL;\r
-  Padding     = 0;\r
-  Input_Flag  = FALSE;\r
-  Output_Flag = FALSE;\r
-  Pad_Flag    = FALSE;\r
-\r
-  if (argc < 5) {\r
-    printf ("Not enough arguments\n");\r
-    PrintGenDepexUsageInfo ();\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  for (Index = 1; Index < argc - 1; Index++) {\r
-\r
-    if ((strcmp (argv[Index], "-I") == 0) || (strcmp (argv[Index], "-i") == 0)) {\r
-\r
-      if (!Input_Flag) {\r
-\r
-        InFile      = fopen (argv[Index + 1], "rb");\r
-        Input_Flag  = TRUE;\r
-\r
-      } else {\r
-        printf ("GenDepex only allows one INPUT (-I) argument\n");\r
-        return EFI_INVALID_PARAMETER;\r
-      }\r
-\r
-    } else if ((strcmp (argv[Index], "-O") == 0) || (strcmp (argv[Index], "-o") == 0)) {\r
-\r
-      if (!Output_Flag) {\r
-\r
-        OutFile     = fopen (argv[Index + 1], "wb");\r
-        Output_Flag = TRUE;\r
-\r
-      } else {\r
-        printf ("GenDepex only allows one OUTPUT (-O) argument\n");\r
-        return EFI_INVALID_PARAMETER;\r
-      }\r
-\r
-    } else if ((strcmp (argv[Index], "-P") == 0) || (strcmp (argv[Index], "-p") == 0)) {\r
-\r
-      if (!Pad_Flag) {\r
-\r
-        Padding   = (UINT8) atoi (argv[Index + 1]);\r
-        Pad_Flag  = TRUE;\r
-\r
-      } else {\r
-        printf ("GenDepex only allows one PADDING (-P) argument\n");\r
-        return EFI_INVALID_PARAMETER;\r
-      }\r
-    }\r
-  }\r
-\r
-  PrintGenDepexUtilityInfo ();\r
-\r
-  if (InFile == NULL) {\r
-    printf ("Can not open <INFILE> for reading.\n");\r
-    PrintGenDepexUsageInfo ();\r
-    return EFI_ABORTED;\r
-  }\r
-\r
-  if (OutFile == NULL) {\r
-    printf ("Can not open <OUTFILE> for writting.\n");\r
-    PrintGenDepexUsageInfo ();\r
-    return EFI_ABORTED;\r
-  }\r
-\r
-  return GenerateDependencyExpression (InFile, OutFile, Padding);\r
-}\r
diff --git a/Tools/CodeTools/TianoTools/GenDepex/GenDepex.h b/Tools/CodeTools/TianoTools/GenDepex/GenDepex.h
deleted file mode 100644 (file)
index b198156..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-/*++\r
-Copyright (c) 2004, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-  Module Name:  \r
-          GenDepex.h\r
-\r
-  Abstract:\r
-          This file contains the relevant declarations required\r
-          to generate a binary Dependency File\r
-\r
-  Complies with Tiano C Coding Standards Document, version 0.31, 12 Dec 2000.\r
-\r
---*/\r
-\r
-#ifndef _EFI_GEN_DEPEX_H\r
-#define _EFI_GEN_DEPEX_H\r
-\r
-\r
-#include <stdio.h>\r
-#include <stdlib.h>\r
-#include <memory.h>\r
-#include <string.h>\r
-#ifndef __GNUC__\r
-#include <malloc.h>\r
-#endif\r
-\r
-#include <Common/UefiBaseTypes.h>\r
-#include <Common/Dependency.h>\r
-\r
-#define DEPENDENCY_START            "DEPENDENCY_START"\r
-#define OPERATOR_BEFORE             "BEFORE"\r
-#define OPERATOR_AFTER              "AFTER"\r
-#define OPERATOR_AND                "AND"\r
-#define OPERATOR_OR                 "OR"\r
-#define OPERATOR_NOT                "NOT"\r
-#define OPERATOR_TRUE               "TRUE"\r
-#define OPERATOR_FALSE              "FALSE"\r
-#define OPERATOR_SOR                "SOR"\r
-#define OPERATOR_END                "END"\r
-#define OPERATOR_LEFT_PARENTHESIS   "("\r
-#define OPERATOR_RIGHT_PARENTHESIS  ")"\r
-#define DEPENDENCY_END              "DEPENDENCY_END"\r
-\r
-#define DXE_DEP_LEFT_PARENTHESIS    0x0a\r
-#define DXE_DEP_RIGHT_PARENTHESIS   0x0b\r
-\r
-#define LINESIZE                    320\r
-#define SIZE_A_SYMBOL               60\r
-#define DEPENDENCY_OPCODE           UINT8\r
-#define EVAL_STACK_SIZE             0x1024\r
-#define BUFFER_SIZE                 0x100\r
-\r
-//\r
-// Utility Name\r
-//\r
-#define UTILITY_NAME  "GenDepex"\r
-\r
-//\r
-// Utility version information\r
-//\r
-#define UTILITY_MAJOR_VERSION 0\r
-#define UTILITY_MINOR_VERSION 5\r
-\r
-#endif\r
diff --git a/Tools/CodeTools/TianoTools/GenDepex/build.xml b/Tools/CodeTools/TianoTools/GenDepex/build.xml
deleted file mode 100644 (file)
index 568177a..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-<?xml version="1.0" ?>\r
-<!--\r
-Copyright (c) 2006, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
--->\r
-<project default="GenTool" basedir=".">\r
-<!--\r
-    EDK GenDepex Tool\r
-  Copyright (c) 2006, Intel Corporation\r
--->\r
-  <property name="ToolName" value="GenDepex"/>\r
-  <property name="FileSet" value="DepexParser.c GenDepex.c GenDepex.h"/>\r
-\r
-  <taskdef resource="cpptasks.tasks"/>\r
-  <typedef resource="cpptasks.types"/>\r
-  <taskdef resource="net/sf/antcontrib/antlib.xml"/>\r
-\r
-  <property name="LINK_OUTPUT_TYPE" value="static"/>\r
-  <property name="BUILD_DIR" value="${PACKAGE_DIR}/${ToolName}/tmp"/>\r
-\r
-  <target name="GenTool" depends="init, Tool">\r
-    <echo message="The EDK Tool: ${ToolName} build has completed!"/>\r
-  </target>\r
-\r
-  <target name="init">\r
-    <echo message="Building the EDK Tool: ${ToolName}"/>\r
-    <mkdir dir="${BUILD_DIR}"/>\r
-  </target>\r
-\r
-  <target name="Tool" depends="init">\r
-    <cc name="${ToolChain}" objdir="${BUILD_DIR}" \r
-        outfile="${BIN_DIR}/${ToolName}"\r
-        outtype="executable"\r
-        debug="true"\r
-        optimize="speed">\r
-      <compilerarg value="${ExtraArgus}" if="ExtraArgus" />\r
-\r
-      <fileset dir="${basedir}/${ToolName}" \r
-        includes="${FileSet}" />\r
-\r
-      <includepath path="${PACKAGE_DIR}/Include"/>\r
-      <includepath path="${PACKAGE_DIR}/Include/Ia32"/>\r
-      <includepath path="${PACKAGE_DIR}/Common"/>\r
-    </cc>\r
-  </target>\r
-\r
-  <target name="clean">\r
-    <echo message="Removing Intermediate Files Only"/>  \r
-    <delete>\r
-      <fileset dir="${BUILD_DIR}" includes="*.obj"/>\r
-    </delete>\r
-  </target>\r
-\r
-  <target name="cleanall">\r
-    <echo message="Removing Object Files and the Executable: ${ToolName}${ext_exe}"/>  \r
-    <delete failonerror="false" quiet="true" includeEmptyDirs="true">\r
-      <fileset dir="${BUILD_DIR}"/>\r
-      <fileset file="${BIN_DIR}/${ToolName}${ext_exe}"/>\r
-    </delete>\r
-  </target>\r
-\r
-</project>\r
diff --git a/Tools/CodeTools/TianoTools/GenFfsFile/GenFfsFile.c b/Tools/CodeTools/TianoTools/GenFfsFile/GenFfsFile.c
deleted file mode 100644 (file)
index 1eea09f..0000000
+++ /dev/null
@@ -1,2646 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2004, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-Module Name:\r
-\r
-  GenFfsFile.c\r
-\r
-Abstract:\r
-\r
-  This file contains functions required to generate a Firmware File System\r
-  file.\r
-\r
---*/\r
-\r
-#include <stdio.h>\r
-#include <ctype.h>  // for isalpha()\r
-//\r
-// include file for _spawnv\r
-//\r
-#ifndef __GNUC__\r
-#include <process.h>\r
-#endif\r
-#include <stdlib.h>\r
-#include <string.h>\r
-\r
-#include <Common/UefiBaseTypes.h>\r
-#include <Common/FirmwareVolumeImageFormat.h>\r
-#include <Common/FirmwareFileSystem.h>\r
-#include <Common/FirmwareVolumeHeader.h>\r
-#include <Common/FirmwareVolumeImageFormat.h>\r
-\r
-#include "ParseInf.h"\r
-#include "EfiCompress.h"\r
-#include "EfiCustomizedCompress.h"\r
-#include "Crc32.h"\r
-#include "GenFfsFile.h"\r
-#include "CommonLib.h"\r
-#include "EfiUtilityMsgs.h"\r
-#include "SimpleFileParsing.h"\r
-\r
-#define UTILITY_NAME    "GenFfsFile"\r
-#define TOOLVERSION     "0.32"\r
-#define MAX_ARRAY_SIZE  100\r
-\r
-static\r
-INT32\r
-GetNextLine (\r
-  OUT CHAR8       *Destination,\r
-  IN FILE         *Package,\r
-  IN OUT UINT32   *LineNumber\r
-  );\r
-\r
-static\r
-void\r
-CheckSlash (\r
-  IN OUT CHAR8  *String,\r
-  IN FILE       *In,\r
-  IN OUT UINT32 *LineNumber\r
-  );\r
-\r
-static\r
-INT32\r
-FindSectionInPackage (\r
-  IN CHAR8        *BuildDirectory,\r
-  IN FILE         *OverridePackage,\r
-  IN OUT UINT32   *LineNumber\r
-  );\r
-\r
-static\r
-STATUS\r
-ProcessCommandLineArgs (\r
-  int     Argc,\r
-  char    *Argv[]\r
-  );\r
-\r
-static\r
-void\r
-PrintUsage (\r
-  void\r
-  );\r
-\r
-//\r
-// Keep globals in this structure\r
-//\r
-static struct {\r
-  UINT8   BuildDirectory[_MAX_PATH];\r
-  UINT8   PrimaryPackagePath[_MAX_PATH];\r
-  UINT8   OverridePackagePath[_MAX_PATH];\r
-  BOOLEAN Verbose;\r
-} mGlobals;\r
-\r
-static EFI_GUID mZeroGuid = { 0 };\r
-\r
-static\r
-void\r
-StripQuotes (\r
-  IN OUT CHAR8 *String\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Removes quotes and/or whitespace from around a string\r
-\r
-Arguments:\r
-\r
- String    - String to remove quotes from\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-{\r
-  UINTN Index;\r
-  UINTN Index2;\r
-  UINTN StrLen;\r
-\r
-  Index2  = strspn (String, "\" \t\n");\r
-  StrLen  = strlen (String);\r
-\r
-  for (Index = Index2; String[Index] != '\"', Index < StrLen; Index++) {\r
-    String[Index - Index2] = String[Index];\r
-  }\r
-\r
-  String[Index - Index2] = 0;\r
-}\r
-\r
-static\r
-void\r
-PrintUsage (\r
-  void\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Print Error / Help message.\r
-\r
-Arguments:\r
-\r
-  void\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-{\r
-  printf ("Usage:\n");\r
-  printf (UTILITY_NAME " -b \"build directory\" -p1 \"package1.inf\" -p2 \"package2.inf\" -v\n");\r
-  printf ("   -b \"build directory\":\n ");\r
-  printf ("       specifies the full path to the component build directory.\n");\r
-  printf ("   -p1 \"P1_path\":\n");\r
-  printf ("       specifies fully qualified file name to the primary package file.\n");\r
-  printf ("       This file will normally exist in the same directory as the makefile\n");\r
-  printf ("       for the component. Required.\n");\r
-  printf ("   -p2 \"P2_path\":\n");\r
-  printf ("       specifies fully qualified file name to the override package file.\n");\r
-  printf ("       This file will normally exist in the build tip. Optional.\n");\r
-}\r
-\r
-static\r
-INT32\r
-TestComment (\r
-  IN CHAR8  *String,\r
-  IN FILE   *In\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Tests input string to see if it is a comment, and if so goes to the next line in the file that is not a comment\r
-\r
-Arguments:\r
-\r
-  String      - String to test\r
-\r
-  In          - Open file to move pointer within\r
-\r
-Returns:\r
-\r
-  -1          - End of file reached\r
-   0          - Not a comment\r
-   1          - Comment bypassed\r
-\r
---*/\r
-{\r
-  CHAR8 CharBuffer;\r
-\r
-  CharBuffer = 0;\r
-  if ((String[0] == '/') && (String[1] == '/')) {\r
-    while (CharBuffer != '\n') {\r
-      fscanf (In, "%c", &CharBuffer);\r
-      if (feof (In)) {\r
-        return -1;\r
-      }\r
-    }\r
-  } else {\r
-    return 0;\r
-  }\r
-\r
-  return 1;\r
-}\r
-\r
-static\r
-void\r
-BreakString (\r
-  IN CONST CHAR8 *Source,\r
-  OUT CHAR8      *Destination,\r
-  IN INTN        Direction\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Takes an input string and returns either the part before the =, or the part after the =, depending on direction\r
-\r
-Arguments:\r
-\r
-  Source      - String to break\r
-\r
-  Destination - Buffer to place new string in\r
-\r
-  Direction   - 0 to return all of source string before =\r
-                1 to return all of source string after =\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-{\r
-  UINTN Index;\r
-  UINTN Index2;\r
-\r
-  Index   = 0;\r
-  Index2  = 0;\r
-\r
-  if (strchr (Source, '=') == NULL) {\r
-    strcpy (Destination, Source);\r
-\r
-    return ;\r
-  }\r
-\r
-  if (Direction == 0) {\r
-    //\r
-    // return part of string before =\r
-    //\r
-    while (Source[Index] != '=') {\r
-      Destination[Index] = Source[Index++];\r
-    }\r
-\r
-    Destination[Index] = 0;\r
-  } else {\r
-    //\r
-    // return part of string after =\r
-    //\r
-    strcpy (Destination, strchr (Source, '=') + 1);\r
-  }\r
-}\r
-\r
-static\r
-INT32\r
-GetNextLine (\r
-  OUT CHAR8       *Destination,\r
-  IN FILE         *Package,\r
-  IN OUT UINT32   *LineNumber\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Gets the next non-commented line from the file\r
-\r
-Arguments:\r
-\r
-  Destination - Where to put string\r
-\r
-  Package     - Package to get string from\r
-  \r
-  LineNumber  - The actual line number.\r
-\r
-Returns:\r
-\r
-  -1          - End of file reached\r
-   0          - Success\r
-\r
---*/\r
-{\r
-  CHAR8 String[_MAX_PATH];\r
-  fscanf (Package, "%s", &String);\r
-  if (feof (Package)) {\r
-    return -1;\r
-  }\r
-\r
-  while (TestComment (String, Package) == 1) {\r
-    fscanf (Package, "%s", &String);\r
-    if (feof (Package)) {\r
-      return -1;\r
-    }\r
-  }\r
-\r
-  strcpy (Destination, String);\r
-  return 0;\r
-}\r
-\r
-static\r
-VOID\r
-CheckSlash (\r
-  IN OUT CHAR8  *String,\r
-  IN FILE       *In,\r
-  IN OUT UINT32 *LineNumber\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Checks to see if string is line continuation character, if so goes to next valid line\r
-\r
-Arguments:\r
-\r
-  String      - String to test\r
-\r
-  In          - Open file to move pointer within\r
-  \r
-  LineNumber  - The line number.\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-{\r
-  CHAR8 ByteBuffer;\r
-  ByteBuffer = 0;\r
-\r
-  switch (String[0]) {\r
-\r
-  case '\\':\r
-    while (String[0] == '\\') {\r
-      while (ByteBuffer != '\n') {\r
-        fscanf (In, "%c", &ByteBuffer);\r
-      }\r
-      (*LineNumber)++;\r
-      if (GetNextLine (String, In, LineNumber) == -1) {\r
-        return ;\r
-      }\r
-    }\r
-    break;\r
-\r
-  case '\n':\r
-    (*LineNumber)++;\r
-    while (String[0] == '\n') {\r
-      if (GetNextLine (String, In, LineNumber) == -1) {\r
-        return ;\r
-      }\r
-    }\r
-    break;\r
-\r
-  default:\r
-    break;\r
-\r
-  }\r
-\r
-}\r
-\r
-static\r
-INT32\r
-FindSectionInPackage (\r
-  IN CHAR8        *BuildDirectory,\r
-  IN FILE         *OverridePackage,\r
-  IN OUT UINT32   *LineNumber\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Finds the matching section within the package\r
-\r
-Arguments:\r
-\r
-  BuildDirectory  - name of section to find\r
-\r
-  OverridePackage - Package file to search within\r
-  \r
-  LineNumber      - The line number.\r
-\r
-Returns:\r
-\r
-  -1          - End of file reached\r
-   0          - Success\r
-\r
---*/\r
-{\r
-  CHAR8 String[_MAX_PATH];\r
-  CHAR8 NewString[_MAX_PATH];\r
-  String[0] = 0;\r
-\r
-  while (strcmp (BuildDirectory, String) != 0) {\r
-    if (GetNextLine (NewString, OverridePackage, LineNumber) != 0) {\r
-      return -1;\r
-    }\r
-\r
-    if (NewString[0] == '[') {\r
-      if (NewString[strlen (NewString) - 1] != ']') {\r
-        //\r
-        // have to construct string.\r
-        //\r
-        strcpy (String, NewString + 1);\r
-\r
-        while (1) {\r
-          fscanf (OverridePackage, "%s", &NewString);\r
-          if (feof (OverridePackage)) {\r
-            return -1;\r
-          }\r
-\r
-          if (NewString[0] != ']') {\r
-            if (strlen (String) != 0) {\r
-              strcat (String, " ");\r
-            }\r
-\r
-            strcat (String, NewString);\r
-            if (String[strlen (String) - 1] == ']') {\r
-              String[strlen (String) - 1] = 0;\r
-              break;\r
-            }\r
-          } else {\r
-            break;\r
-          }\r
-        }\r
-      } else {\r
-        NewString[strlen (NewString) - 1] = 0;\r
-        strcpy (String, NewString + 1);\r
-      }\r
-    }\r
-  }\r
-\r
-  return 0;\r
-}\r
-\r
-static\r
-EFI_STATUS\r
-GenSimpleGuidSection (\r
-  IN OUT UINT8  *FileBuffer,\r
-  IN OUT UINT32 *BufferSize,\r
-  IN UINT32     DataSize,\r
-  IN EFI_GUID   SignGuid,\r
-  IN UINT16     GuidedSectionAttributes\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  add GUIDed section header for the data buffer.\r
-  data stays in same location (overwrites source data).\r
-\r
-Arguments:\r
-\r
-  FileBuffer  - Buffer containing data to sign\r
-\r
-  BufferSize  - On input, the size of FileBuffer. On output, the size of\r
-                actual section data (including added section header).\r
-\r
-  DataSize    - Length of data to Sign\r
-\r
-  SignGuid    - Guid to be add.\r
-  \r
-  GuidedSectionAttributes - The section attribute.\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS           - Successful\r
-  EFI_OUT_OF_RESOURCES  - Not enough resource.\r
-\r
---*/\r
-{\r
-  UINT32                    TotalSize;\r
-\r
-  EFI_GUID_DEFINED_SECTION  GuidSectionHeader;\r
-  UINT8                     *SwapBuffer;\r
-\r
-  SwapBuffer = NULL;\r
-\r
-  if (DataSize == 0) {\r
-    *BufferSize = 0;\r
-\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  TotalSize = DataSize + sizeof (EFI_GUID_DEFINED_SECTION);\r
-  GuidSectionHeader.CommonHeader.Type     = EFI_SECTION_GUID_DEFINED;\r
-  GuidSectionHeader.CommonHeader.Size[0]  = (UINT8) (TotalSize & 0xff);\r
-  GuidSectionHeader.CommonHeader.Size[1]  = (UINT8) ((TotalSize & 0xff00) >> 8);\r
-  GuidSectionHeader.CommonHeader.Size[2]  = (UINT8) ((TotalSize & 0xff0000) >> 16);\r
-  memcpy (&(GuidSectionHeader.SectionDefinitionGuid), &SignGuid, sizeof (EFI_GUID));\r
-  GuidSectionHeader.Attributes  = GuidedSectionAttributes;\r
-  GuidSectionHeader.DataOffset  = sizeof (EFI_GUID_DEFINED_SECTION);\r
-\r
-  SwapBuffer                    = (UINT8 *) malloc (DataSize);\r
-  if (SwapBuffer == NULL) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-\r
-  memcpy (SwapBuffer, FileBuffer, DataSize);\r
-  memcpy (FileBuffer, &GuidSectionHeader, sizeof (EFI_GUID_DEFINED_SECTION));\r
-  memcpy (FileBuffer + sizeof (EFI_GUID_DEFINED_SECTION), SwapBuffer, DataSize);\r
-\r
-  //\r
-  // Make sure section ends on a DWORD boundary\r
-  //\r
-  while ((TotalSize & 0x03) != 0) {\r
-    FileBuffer[TotalSize] = 0;\r
-    TotalSize++;\r
-  }\r
-\r
-  *BufferSize = TotalSize;\r
-\r
-  if (SwapBuffer != NULL) {\r
-    free (SwapBuffer);\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-static\r
-EFI_STATUS\r
-CompressSection (\r
-  UINT8  *FileBuffer,\r
-  UINT32 *BufferSize,\r
-  UINT32 DataSize,\r
-  CHAR8  *Type\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Compress the data and add section header for the compressed data.\r
-  Compressed data (with section header) stays in same location as the source\r
-  (overwrites source data).\r
-\r
-Arguments:\r
-\r
-  FileBuffer  - Buffer containing data to Compress\r
-\r
-  BufferSize  - On input, the size of FileBuffer. On output, the size of\r
-                actual compressed data (including added section header).\r
-                When buffer is too small, this value indicates the size needed.\r
-\r
-  DataSize    - The size of data to compress\r
-\r
-  Type        - The compression type (not used currently).\r
-                Assume EFI_HEAVY_COMPRESSION.\r
-\r
-Returns:\r
-\r
-  EFI_BUFFER_TOO_SMALL - Buffer size is too small.\r
-  EFI_UNSUPPORTED      - Compress type can not be supported.\r
-  EFI_SUCCESS          - Successful\r
-  EFI_OUT_OF_RESOURCES - Not enough resource.\r
-\r
---*/\r
-{\r
-  EFI_STATUS              Status;\r
-  UINT8                   *CompData;\r
-  UINT32                  CompSize;\r
-  UINT32                  TotalSize;\r
-  EFI_COMPRESSION_SECTION CompressionSet;\r
-  UINT8                   CompressionType;\r
-  COMPRESS_FUNCTION       CompressFunction;\r
-\r
-  Status            = EFI_SUCCESS;\r
-  CompData          = NULL;\r
-  CompSize          = 0;\r
-  TotalSize         = 0;\r
-  CompressFunction  = NULL;\r
-\r
-  //\r
-  // Get the compress type\r
-  //\r
-  if (strcmpi (Type, "Dummy") == 0) {\r
-    //\r
-    // Added "Dummy" to keep backward compatibility.\r
-    //\r
-    CompressionType   = EFI_STANDARD_COMPRESSION;\r
-    CompressFunction  = (COMPRESS_FUNCTION) Compress;\r
-\r
-  } else if (strcmpi (Type, "LZH") == 0) {\r
-    //\r
-    // EFI stardard compression (LZH)\r
-    //\r
-    CompressionType   = EFI_STANDARD_COMPRESSION;\r
-    CompressFunction  = (COMPRESS_FUNCTION) Compress;\r
-\r
-  } else {\r
-    //\r
-    // Customized compression\r
-    //\r
-    Status = SetCustomizedCompressionType (Type);\r
-    if (EFI_ERROR (Status)) {\r
-      return Status;\r
-    }\r
-\r
-    CompressionType   = EFI_CUSTOMIZED_COMPRESSION;\r
-    CompressFunction  = (COMPRESS_FUNCTION) CustomizedCompress;\r
-  }\r
-  //\r
-  // Compress the raw data\r
-  //\r
-  Status = CompressFunction (FileBuffer, DataSize, CompData, &CompSize);\r
-  if (Status == EFI_BUFFER_TOO_SMALL) {\r
-    CompData = malloc (CompSize);\r
-    if (!CompData) {\r
-      return EFI_OUT_OF_RESOURCES;\r
-    }\r
-\r
-    Status = CompressFunction (FileBuffer, DataSize, CompData, &CompSize);\r
-  }\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    if (CompData != NULL) {\r
-      free (CompData);\r
-    }\r
-\r
-    return Status;\r
-  }\r
-\r
-  TotalSize = CompSize + sizeof (EFI_COMPRESSION_SECTION);\r
-\r
-  //\r
-  // Buffer too small?\r
-  //\r
-  if (TotalSize > *BufferSize) {\r
-    *BufferSize = TotalSize;\r
-    if (CompData != NULL) {\r
-      free (CompData);\r
-    }\r
-\r
-    return EFI_BUFFER_TOO_SMALL;\r
-  }\r
-  //\r
-  // Add the section header for the compressed data\r
-  //\r
-  CompressionSet.CommonHeader.Type    = EFI_SECTION_COMPRESSION;\r
-  CompressionSet.CommonHeader.Size[0] = (UINT8) (TotalSize & 0xff);\r
-  CompressionSet.CommonHeader.Size[1] = (UINT8) ((TotalSize & 0xff00) >> 8);\r
-  CompressionSet.CommonHeader.Size[2] = (UINT8) ((TotalSize & 0xff0000) >> 16);\r
-  CompressionSet.CompressionType      = CompressionType;\r
-  CompressionSet.UncompressedLength   = DataSize;\r
-\r
-  //\r
-  // Copy header and data to the buffer\r
-  //\r
-  memcpy (FileBuffer, &CompressionSet, sizeof (EFI_COMPRESSION_SECTION));\r
-  memcpy (FileBuffer + sizeof (CompressionSet), CompData, CompSize);\r
-\r
-  //\r
-  // Make sure section ends on a DWORD boundary\r
-  //\r
-  while ((TotalSize & 0x03) != 0) {\r
-    FileBuffer[TotalSize] = 0;\r
-    TotalSize++;\r
-  }\r
-\r
-  *BufferSize = TotalSize;\r
-\r
-  if (CompData != NULL) {\r
-    free (CompData);\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-static\r
-void\r
-StripParens (\r
-  IN OUT CHAR8 *String\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Removes Parenthesis from around a string\r
-\r
-Arguments:\r
-\r
- String    - String to remove parens from\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-{\r
-  INT32 Index;\r
-\r
-  if (String[0] != '(') {\r
-    return ;\r
-  }\r
-\r
-  for (Index = 1; String[Index] != ')'; Index++) {\r
-    String[Index - 1] = String[Index];\r
-    if (String[Index] == 0) {\r
-      return ;\r
-    }\r
-  }\r
-\r
-  String[Index - 1] = 0;\r
-\r
-  return ;\r
-}\r
-\r
-static\r
-void\r
-StripEqualMark (\r
-  IN OUT CHAR8 *String\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Removes Equal Mark from around a string\r
-\r
-Arguments:\r
-\r
- String    - String to remove equal mark from\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-{\r
-  INT32 Index;\r
-\r
-  if (String[0] != '=' && String[strlen (String) - 1] != '=') {\r
-    return ;\r
-  }\r
-\r
-  if (String[0] == '=') {\r
-\r
-    for (Index = 1; String[Index] != 0; Index++) {\r
-      String[Index - 1] = String[Index];\r
-    }\r
-\r
-    String[Index - 1] = 0;\r
-  }\r
-\r
-  if (String[strlen (String) - 1] == '=') {\r
-    String[strlen (String) - 1] = 0;\r
-  }\r
-\r
-  return ;\r
-}\r
-\r
-static\r
-INT32\r
-ProcessEnvironmentVariable (\r
-  IN CHAR8  *Buffer,\r
-  OUT CHAR8 *NewBuffer\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Converts environment variables to values\r
-\r
-Arguments:\r
-\r
-  Buffer      - Buffer containing Environment Variable String\r
-\r
-  NewBuffer   - Buffer containing value of environment variable\r
-\r
-\r
-Returns:\r
-\r
-  Number of characters from Buffer used\r
-\r
---*/\r
-{\r
-  INT32 Index;\r
-  INT32 Index2;\r
-  CHAR8 VariableBuffer[_MAX_PATH];\r
-\r
-  Index   = 2;\r
-  Index2  = 0;\r
-\r
-  while (Buffer[Index] != ')') {\r
-    VariableBuffer[Index - 2] = Buffer[Index++];\r
-  }\r
-\r
-  VariableBuffer[Index - 2] = 0;\r
-  Index++;\r
-\r
-  if (getenv (VariableBuffer) != NULL) {\r
-    strcpy (NewBuffer, getenv (VariableBuffer));\r
-  } else {\r
-    printf ("Environment variable %s not found!\n", VariableBuffer);\r
-  }\r
-\r
-  return Index;\r
-}\r
-\r
-static\r
-void\r
-SplitAttributesField (\r
-  IN CHAR8       *Buffer,\r
-  IN CHAR8       *AttributesArray[],\r
-  IN OUT UINT32  *NumberOfAttributes\r
-  )\r
-/*\r
-  NumberOfAttributes: on input, it specifies the current number of attributes\r
-                      stored in AttributeArray.\r
-                      on output, it is updated to the latest number of attributes\r
-                      stored in AttributesArray.\r
-*/\r
-{\r
-  UINT32  Index;\r
-  UINT32  Index2;\r
-  UINT32  z;\r
-  CHAR8   *CharBuffer;\r
-\r
-  CharBuffer  = NULL;\r
-  CharBuffer  = (CHAR8 *) malloc (_MAX_PATH);\r
-  ZeroMem (CharBuffer, _MAX_PATH);\r
-\r
-  for (Index = 0, z = 0, Index2 = 0; Index < strlen (Buffer); Index++) {\r
-\r
-    if (Buffer[Index] != '|') {\r
-      CharBuffer[z] = Buffer[Index];\r
-      z++;\r
-    } else {\r
-\r
-      CharBuffer[z] = 0;\r
-      AttributesArray[*NumberOfAttributes + Index2] = CharBuffer;\r
-      Index2++;\r
-\r
-      //\r
-      // allocate new char buffer for the next attributes string\r
-      //\r
-      CharBuffer = (CHAR8 *) malloc (_MAX_PATH);\r
-      ZeroMem (CharBuffer, _MAX_PATH);\r
-      z = 0;\r
-    }\r
-  }\r
-\r
-  CharBuffer[z] = 0;\r
-  //\r
-  // record the last attributes string in the Buffer\r
-  //\r
-  AttributesArray[*NumberOfAttributes + Index2] = CharBuffer;\r
-  Index2++;\r
-\r
-  *NumberOfAttributes += Index2;\r
-\r
-  return ;\r
-}\r
-\r
-static\r
-INT32\r
-GetToolArguments (\r
-  CHAR8       *ToolArgumentsArray[],\r
-  FILE        *Package,\r
-  CHAR8       **PtrInputFileName,\r
-  CHAR8       **PtrOutputFileName,\r
-  EFI_GUID    *Guid,\r
-  UINT16      *GuidedSectionAttributes\r
-  )\r
-{\r
-  CHAR8       Buffer[_MAX_PATH];\r
-  BOOLEAN     ArgumentsFlag;\r
-  BOOLEAN     InputFlag;\r
-  BOOLEAN     OutputFlag;\r
-  BOOLEAN     GuidFlag;\r
-  BOOLEAN     AttributesFlag;\r
-  UINT32      argc;\r
-  UINT32      Index2;\r
-  UINT32      z;\r
-  CHAR8       *CharBuffer;\r
-  INT32       Index;\r
-  INT32       ReturnValue;\r
-  EFI_STATUS  Status;\r
-\r
-  CHAR8       *AttributesArray[MAX_ARRAY_SIZE];\r
-  UINT32      NumberOfAttributes;\r
-  CHAR8       *InputFileName;\r
-  CHAR8       *OutputFileName;\r
-  UINT32      LineNumber;\r
-  Buffer[_MAX_PATH];\r
-\r
-  ArgumentsFlag   = FALSE;\r
-  InputFlag       = FALSE;\r
-  OutputFlag      = FALSE;\r
-  GuidFlag        = FALSE;\r
-  AttributesFlag  = FALSE;\r
-  //\r
-  // Start at 1, since ToolArgumentsArray[0]\r
-  // is the program name.\r
-  //\r
-  argc            = 1;\r
-  Index2              = 0;\r
-\r
-  z                   = 0;\r
-  ReturnValue         = 0;\r
-  NumberOfAttributes  = 0;\r
-  InputFileName       = NULL;\r
-  OutputFileName      = NULL;\r
-\r
-  ZeroMem (Buffer, _MAX_PATH);\r
-  ZeroMem (AttributesArray, sizeof (CHAR8 *) * MAX_ARRAY_SIZE);\r
-  LineNumber = 0;\r
-  while (Buffer[0] != ')') {\r
-\r
-    if (GetNextLine (Buffer, Package, &LineNumber) != -1) {\r
-      CheckSlash (Buffer, Package, &LineNumber);\r
-      StripEqualMark (Buffer);\r
-    } else {\r
-      Error (NULL, 0, 0, "failed to get next line from package file", NULL);\r
-      return -1;\r
-    }\r
-\r
-    if (Buffer[0] == ')') {\r
-      break;\r
-    } else if (strcmpi (Buffer, "ARGS") == 0) {\r
-\r
-      ArgumentsFlag   = TRUE;\r
-      AttributesFlag  = FALSE;\r
-      continue;\r
-\r
-    } else if (strcmpi (Buffer, "INPUT") == 0) {\r
-\r
-      InputFlag       = TRUE;\r
-      ArgumentsFlag   = FALSE;\r
-      AttributesFlag  = FALSE;\r
-      continue;\r
-\r
-    } else if (strcmpi (Buffer, "OUTPUT") == 0) {\r
-\r
-      OutputFlag      = TRUE;\r
-      ArgumentsFlag   = FALSE;\r
-      AttributesFlag  = FALSE;\r
-      continue;\r
-\r
-    } else if (strcmpi (Buffer, "GUID") == 0) {\r
-\r
-      GuidFlag        = TRUE;\r
-      ArgumentsFlag   = FALSE;\r
-      AttributesFlag  = FALSE;\r
-      //\r
-      // fetch the GUID for the section\r
-      //\r
-      continue;\r
-\r
-    } else if (strcmpi (Buffer, "ATTRIBUTES") == 0) {\r
-\r
-      AttributesFlag  = TRUE;\r
-      ArgumentsFlag   = FALSE;\r
-      //\r
-      // fetch the GUIDed Section's Attributes\r
-      //\r
-      continue;\r
-\r
-    } else if (strcmpi (Buffer, "") == 0) {\r
-      continue;\r
-    }\r
-    //\r
-    // get all command arguments into ToolArgumentsArray\r
-    //\r
-    if (ArgumentsFlag) {\r
-\r
-      StripEqualMark (Buffer);\r
-\r
-      CharBuffer = (CHAR8 *) malloc (_MAX_PATH);\r
-      if (CharBuffer == NULL) {\r
-        goto ErrorExit;\r
-      }\r
-\r
-      ZeroMem (CharBuffer, sizeof (_MAX_PATH));\r
-\r
-      ToolArgumentsArray[argc] = CharBuffer;\r
-\r
-      if (Buffer[0] == '$') {\r
-        Index = ProcessEnvironmentVariable (&Buffer[0], ToolArgumentsArray[argc]);\r
-        //\r
-        // if there is string after the environment variable, cat it.\r
-        //\r
-        if ((UINT32) Index < strlen (Buffer)) {\r
-          strcat (ToolArgumentsArray[argc], &Buffer[Index]);\r
-        }\r
-      } else {\r
-        strcpy (ToolArgumentsArray[argc], Buffer);\r
-      }\r
-\r
-      argc += 1;\r
-      ToolArgumentsArray[argc] = NULL;\r
-      continue;\r
-    }\r
-\r
-    if (InputFlag) {\r
-\r
-      StripEqualMark (Buffer);\r
-\r
-      InputFileName = (CHAR8 *) malloc (_MAX_PATH);\r
-      if (InputFileName == NULL) {\r
-        goto ErrorExit;\r
-      }\r
-\r
-      ZeroMem (InputFileName, sizeof (_MAX_PATH));\r
-\r
-      if (Buffer[0] == '$') {\r
-        Index = ProcessEnvironmentVariable (&Buffer[0], InputFileName);\r
-        //\r
-        // if there is string after the environment variable, cat it.\r
-        //\r
-        if ((UINT32) Index < strlen (Buffer)) {\r
-          strcat (InputFileName, &Buffer[Index]);\r
-        }\r
-      } else {\r
-        strcpy (InputFileName, Buffer);\r
-      }\r
-\r
-      InputFlag = FALSE;\r
-      continue;\r
-    }\r
-\r
-    if (OutputFlag) {\r
-\r
-      StripEqualMark (Buffer);\r
-\r
-      OutputFileName = (CHAR8 *) malloc (_MAX_PATH);\r
-      if (OutputFileName == NULL) {\r
-        goto ErrorExit;\r
-      }\r
-\r
-      ZeroMem (OutputFileName, sizeof (_MAX_PATH));\r
-\r
-      if (Buffer[0] == '$') {\r
-        Index = ProcessEnvironmentVariable (&Buffer[0], OutputFileName);\r
-        //\r
-        // if there is string after the environment variable, cat it.\r
-        //\r
-        if ((UINT32) Index < strlen (Buffer)) {\r
-          strcat (OutputFileName, &Buffer[Index]);\r
-        }\r
-      } else {\r
-        strcpy (OutputFileName, Buffer);\r
-      }\r
-\r
-      OutputFlag = FALSE;\r
-      continue;\r
-    }\r
-\r
-    if (GuidFlag) {\r
-\r
-      StripEqualMark (Buffer);\r
-\r
-      Status = StringToGuid (Buffer, Guid);\r
-      if (EFI_ERROR (Status)) {\r
-        ReturnValue = -1;\r
-        goto ErrorExit;\r
-      }\r
-\r
-      GuidFlag = FALSE;\r
-    }\r
-\r
-    if (AttributesFlag) {\r
-\r
-      StripEqualMark (Buffer);\r
-\r
-      //\r
-      // there might be no space between each attribute in the statement,\r
-      // split them aside and return each attribute string\r
-      // in the AttributesArray\r
-      //\r
-      SplitAttributesField (Buffer, AttributesArray, &NumberOfAttributes);\r
-    }\r
-  }\r
-  //\r
-  // ReplaceVariableInBuffer (ToolArgumentsArray,&i,"INPUT",InputVariable,j);\r
-  // ReplaceVariableInBuffer (ToolArgumentsArray,&i,"OUTPUT",&TargetFileName,1);\r
-  //\r
-  for (z = 0; z < NumberOfAttributes; z++) {\r
-    if (strcmpi (AttributesArray[z], "PROCESSING_REQUIRED") == 0) {\r
-      *GuidedSectionAttributes |= EFI_GUIDED_SECTION_PROCESSING_REQUIRED;\r
-    } else if (strcmpi (AttributesArray[z], "AUTH_STATUS_VALID") == 0) {\r
-      *GuidedSectionAttributes |= EFI_GUIDED_SECTION_AUTH_STATUS_VALID;\r
-    }\r
-  }\r
-\r
-ErrorExit:\r
-\r
-  for (Index2 = 0; Index2 < MAX_ARRAY_SIZE; Index2++) {\r
-    if (AttributesArray[Index2] == NULL) {\r
-      break;\r
-    }\r
-\r
-    free (AttributesArray[Index2]);\r
-  }\r
-\r
-  *PtrInputFileName   = InputFileName;\r
-  *PtrOutputFileName  = OutputFileName;\r
-\r
-  return ReturnValue;\r
-}\r
-\r
-static\r
-INT32\r
-ProcessScript (\r
-  IN OUT UINT8   *FileBuffer,\r
-  IN FILE        *Package,\r
-  IN CHAR8       *BuildDirectory,\r
-  IN BOOLEAN     ForceUncompress\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Signs the section, data stays in same location\r
-\r
-Arguments:\r
-\r
-  FileBuffer  - Data Buffer\r
-\r
-  Package     - Points to curly brace in Image Script\r
-\r
-  BuildDirectory     - Name of the source directory parameter\r
-  \r
-  ForceUncompress   - Whether to force uncompress.\r
-\r
-Returns:\r
-\r
-  Number of bytes added to file buffer\r
-  -1 on error\r
-\r
---*/\r
-{\r
-  EFI_STATUS  Status;\r
-  UINT32      Size;\r
-  CHAR8       Buffer[_MAX_PATH];\r
-  CHAR8       Type[_MAX_PATH];\r
-  CHAR8       FileName[_MAX_PATH];\r
-  CHAR8       NewBuffer[_MAX_PATH];\r
-  INT32       Index3;\r
-  INT32       Index2;\r
-  UINT32      ReturnValue;\r
-  UINT8       ByteBuffer;\r
-  FILE        *InFile;\r
-  UINT32      SourceDataSize;\r
-  CHAR8       *ToolArgumentsArray[MAX_ARRAY_SIZE];\r
-  CHAR8       *OutputFileName;\r
-  CHAR8       *InputFileName;\r
-  CHAR8       ToolName[_MAX_PATH];\r
-  FILE        *OutputFile;\r
-  FILE        *InputFile;\r
-  UINT8       Temp;\r
-  int         returnint;\r
-  INT32       Index;\r
-  UINT32      LineNumber;\r
-  BOOLEAN     IsError;\r
-  EFI_GUID    SignGuid;\r
-  UINT16      GuidedSectionAttributes;\r
-  UINT8       *TargetFileBuffer;\r
-\r
-  OutputFileName          = NULL;\r
-  InputFileName           = NULL;\r
-  OutputFile              = NULL;\r
-  InputFile               = NULL;\r
-  IsError                 = FALSE;\r
-  GuidedSectionAttributes = 0;\r
-  TargetFileBuffer        = NULL;\r
-\r
-  Size                    = 0;\r
-  LineNumber              = 0;\r
-  Buffer[0]               = 0;\r
-  for (Index3 = 0; Index3 < MAX_ARRAY_SIZE; ++Index3) {\r
-    ToolArgumentsArray[Index3] = NULL;\r
-  }\r
-\r
-  while (Buffer[0] != '}') {\r
-    if (GetNextLine (Buffer, Package, &LineNumber) != -1) {\r
-      CheckSlash (Buffer, Package, &LineNumber);\r
-    } else {\r
-      printf ("ERROR in IMAGE SCRIPT!\n");\r
-      IsError = TRUE;\r
-      goto Done;\r
-    }\r
-\r
-    if (strcmpi (Buffer, "Compress") == 0) {\r
-      //\r
-      // Handle compress\r
-      //\r
-      //\r
-      // read compression type\r
-      //\r
-      if (GetNextLine (Buffer, Package, &LineNumber) != -1) {\r
-        CheckSlash (Buffer, Package, &LineNumber);\r
-      }\r
-\r
-      StripParens (Buffer);\r
-      if (Buffer[0] == '$') {\r
-        ProcessEnvironmentVariable (&Buffer[0], Type);\r
-      } else {\r
-        strcpy (Type, Buffer);\r
-      }\r
-      //\r
-      // build buffer\r
-      //\r
-      while (Buffer[0] != '{') {\r
-        if (GetNextLine (Buffer, Package, &LineNumber) != -1) {\r
-          CheckSlash (Buffer, Package, &LineNumber);\r
-        }\r
-      }\r
-\r
-      ReturnValue = ProcessScript (&FileBuffer[Size], Package, BuildDirectory, ForceUncompress);\r
-      if (ReturnValue == -1) {\r
-        IsError = TRUE;\r
-        goto Done;\r
-      }\r
-      //\r
-      // Call compress routine on buffer.\r
-      // Occasionally, compressed data + section header would\r
-      // be largere than the source and EFI_BUFFER_TOO_SMALL is\r
-      // returned from CompressSection()\r
-      //\r
-      SourceDataSize = ReturnValue;\r
-\r
-      if (!ForceUncompress) {\r
-\r
-        Status = CompressSection (\r
-                  &FileBuffer[Size],\r
-                  &ReturnValue,\r
-                  SourceDataSize,\r
-                  Type\r
-                  );\r
-\r
-        if (Status == EFI_BUFFER_TOO_SMALL) {\r
-          Status = CompressSection (\r
-                    &FileBuffer[Size],\r
-                    &ReturnValue,\r
-                    SourceDataSize,\r
-                    Type\r
-                    );\r
-        }\r
-\r
-        if (EFI_ERROR (Status)) {\r
-          IsError = TRUE;\r
-          goto Done;\r
-        }\r
-      }\r
-\r
-      Size += ReturnValue;\r
-\r
-    } else if (strcmpi (Buffer, "Tool") == 0) {\r
-\r
-      ZeroMem (ToolName, _MAX_PATH);\r
-      ZeroMem (ToolArgumentsArray, sizeof (CHAR8 *) * MAX_ARRAY_SIZE);\r
-      ZeroMem (&SignGuid, sizeof (EFI_GUID));\r
-\r
-      //\r
-      // handle signing Tool\r
-      //\r
-      while (Buffer[0] != '(') {\r
-        if (GetNextLine (Buffer, Package, &LineNumber) != -1) {\r
-          CheckSlash (Buffer, Package, &LineNumber);\r
-        }\r
-      }\r
-\r
-      if (strcmpi (Buffer, "(") == 0) {\r
-        if (GetNextLine (Buffer, Package, &LineNumber) != -1) {\r
-          CheckSlash (Buffer, Package, &LineNumber);\r
-        }\r
-      }\r
-\r
-      StripParens (Buffer);\r
-\r
-      if (Buffer[0] == '$') {\r
-        Index = ProcessEnvironmentVariable (&Buffer[0], ToolName);\r
-        //\r
-        // if there is string after the environment variable, cat it.\r
-        //\r
-        if ((UINT32) Index < strlen (Buffer)) {\r
-          strcat (ToolName, &Buffer[Index]);\r
-        }\r
-      } else {\r
-        strcpy (ToolName, Buffer);\r
-      }\r
-\r
-      ToolArgumentsArray[0] = ToolName;\r
-\r
-      //\r
-      // read ARGS\r
-      //\r
-      if (GetToolArguments (\r
-            ToolArgumentsArray,\r
-            Package,\r
-            &InputFileName,\r
-            &OutputFileName,\r
-            &SignGuid,\r
-            &GuidedSectionAttributes\r
-            ) == -1) {\r
-        IsError = TRUE;\r
-        goto Done;\r
-      }\r
-      //\r
-      // if the tool need input file,\r
-      // dump the file buffer to the specified input file.\r
-      //\r
-      if (InputFileName != NULL) {\r
-        InputFile = fopen (InputFileName, "wb");\r
-        if (InputFile == NULL) {\r
-          Error (NULL, 0, 0, InputFileName, "failed to open output file for writing");\r
-          IsError = TRUE;\r
-          goto Done;\r
-        }\r
-\r
-        fwrite (FileBuffer, sizeof (UINT8), Size, InputFile);\r
-        fclose (InputFile);\r
-        InputFile = NULL;\r
-        free (InputFileName);\r
-        InputFileName = NULL;\r
-      }\r
-      //\r
-      // dispatch signing tool\r
-      //\r
-#ifdef __GNUC__\r
-      {\r
-        char CommandLine[1000];\r
-        sprintf(CommandLine, "%s %s", ToolName, ToolArgumentsArray);\r
-        returnint = system(CommandLine);\r
-      }\r
-#else\r
-      returnint = _spawnv (_P_WAIT, ToolName, ToolArgumentsArray);\r
-#endif\r
-      if (returnint != 0) {\r
-        Error (NULL, 0, 0, ToolName, "external tool failed");\r
-        IsError = TRUE;\r
-        goto Done;\r
-      }\r
-      //\r
-      // if the tool has output file,\r
-      // dump the output file to the file buffer\r
-      //\r
-      if (OutputFileName != NULL) {\r
-\r
-        OutputFile = fopen (OutputFileName, "rb");\r
-        if (OutputFile == NULL) {\r
-          Error (NULL, 0, 0, OutputFileName, "failed to open output file for writing");\r
-          IsError = TRUE;\r
-          goto Done;\r
-        }\r
-\r
-        TargetFileBuffer  = &FileBuffer[Size];\r
-        SourceDataSize    = Size;\r
-\r
-        fread (&Temp, sizeof (UINT8), 1, OutputFile);\r
-        while (!feof (OutputFile)) {\r
-          FileBuffer[Size++] = Temp;\r
-          fread (&Temp, sizeof (UINT8), 1, OutputFile);\r
-        }\r
-\r
-        while ((Size & 0x03) != 0) {\r
-          FileBuffer[Size] = 0;\r
-          Size++;\r
-        }\r
-\r
-        SourceDataSize = Size - SourceDataSize;\r
-\r
-        fclose (OutputFile);\r
-        OutputFile = NULL;\r
-        free (OutputFileName);\r
-        OutputFileName = NULL;\r
-\r
-        if (CompareGuid (&SignGuid, &mZeroGuid) != 0) {\r
-          ReturnValue = SourceDataSize;\r
-          Status = GenSimpleGuidSection (\r
-                    TargetFileBuffer,\r
-                    &ReturnValue,\r
-                    SourceDataSize,\r
-                    SignGuid,\r
-                    GuidedSectionAttributes\r
-                    );\r
-          if (EFI_ERROR (Status)) {\r
-            IsError = TRUE;\r
-            goto Done;\r
-          }\r
-\r
-          Size = ReturnValue;\r
-        }\r
-      }\r
-\r
-    } else if (Buffer[0] != '}') {\r
-      //\r
-      // if we are here, we should see either a file name,\r
-      // or a }.\r
-      //\r
-      Index3      = 0;\r
-      FileName[0] = 0;\r
-      //\r
-      // Prepend the build directory to the file name if the\r
-      // file name does not already contain a full path.\r
-      //\r
-      if (!isalpha (Buffer[0]) || (Buffer[1] != ':')) {\r
-        sprintf (FileName, "%s\\", BuildDirectory);\r
-      }\r
-\r
-      while (Buffer[Index3] != '\n') {\r
-        if (Buffer[Index3] == '$') {\r
-          Index3 += ProcessEnvironmentVariable (&Buffer[Index3], NewBuffer);\r
-          strcat (FileName, NewBuffer);\r
-        }\r
-\r
-        if (Buffer[Index3] == 0) {\r
-          break;\r
-        } else {\r
-          Index2              = strlen (FileName);\r
-          FileName[Index2++]  = Buffer[Index3++];\r
-          FileName[Index2]    = 0;\r
-        }\r
-      }\r
-\r
-      InFile = fopen (FileName, "rb");\r
-      if (InFile == NULL) {\r
-        Error (NULL, 0, 0, FileName, "failed to open file for reading");\r
-        IsError = TRUE;\r
-        goto Done;\r
-      }\r
-\r
-      fread (&ByteBuffer, sizeof (UINT8), 1, InFile);\r
-      while (!feof (InFile)) {\r
-        FileBuffer[Size++] = ByteBuffer;\r
-        fread (&ByteBuffer, sizeof (UINT8), 1, InFile);\r
-      }\r
-\r
-      fclose (InFile);\r
-      InFile = NULL;\r
-\r
-      //\r
-      // Make sure section ends on a DWORD boundary\r
-      //\r
-      while ((Size & 0x03) != 0) {\r
-        FileBuffer[Size] = 0;\r
-        Size++;\r
-      }\r
-\r
-    }\r
-  }\r
-\r
-Done:\r
-  for (Index3 = 1; Index3 < MAX_ARRAY_SIZE; Index3++) {\r
-    if (ToolArgumentsArray[Index3] == NULL) {\r
-      break;\r
-    }\r
-\r
-    free (ToolArgumentsArray[Index3]);\r
-  }\r
-\r
-  if (IsError) {\r
-    return -1;\r
-  }\r
-\r
-  return Size;\r
-\r
-}\r
-\r
-static\r
-UINT8\r
-StringToType (\r
-  IN CHAR8 *String\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Converts File Type String to value.  EFI_FV_FILETYPE_ALL indicates that an\r
-  unrecognized file type was specified.\r
-\r
-Arguments:\r
-\r
-  String    - File type string\r
-\r
-Returns:\r
-\r
-  File Type Value\r
-\r
---*/\r
-{\r
-  if (strcmpi (String, "EFI_FV_FILETYPE_RAW") == 0) {\r
-    return EFI_FV_FILETYPE_RAW;\r
-  }\r
-\r
-  if (strcmpi (String, "EFI_FV_FILETYPE_FREEFORM") == 0) {\r
-    return EFI_FV_FILETYPE_FREEFORM;\r
-  }\r
-\r
-  if (strcmpi (String, "EFI_FV_FILETYPE_SECURITY_CORE") == 0) {\r
-    return EFI_FV_FILETYPE_SECURITY_CORE;\r
-  }\r
-\r
-  if (strcmpi (String, "EFI_FV_FILETYPE_PEI_CORE") == 0) {\r
-    return EFI_FV_FILETYPE_PEI_CORE;\r
-  }\r
-\r
-  if (strcmpi (String, "EFI_FV_FILETYPE_DXE_CORE") == 0) {\r
-    return EFI_FV_FILETYPE_DXE_CORE;\r
-  }\r
-\r
-  if (strcmpi (String, "EFI_FV_FILETYPE_PEIM") == 0) {\r
-    return EFI_FV_FILETYPE_PEIM;\r
-  }\r
-\r
-  if (strcmpi (String, "EFI_FV_FILETYPE_DRIVER") == 0) {\r
-    return EFI_FV_FILETYPE_DRIVER;\r
-  }\r
-\r
-  if (strcmpi (String, "EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER") == 0) {\r
-    return EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER;\r
-  }\r
-\r
-  if (strcmpi (String, "EFI_FV_FILETYPE_APPLICATION") == 0) {\r
-    return EFI_FV_FILETYPE_APPLICATION;\r
-  }\r
-\r
-  if (strcmpi (String, "EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE") == 0) {\r
-    return EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE;\r
-  }\r
-\r
-  return EFI_FV_FILETYPE_ALL;\r
-}\r
-\r
-static\r
-UINT32\r
-AdjustFileSize (\r
-  IN UINT8  *FileBuffer,\r
-  IN UINT32 FileSize\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Adjusts file size to insure sectioned file is exactly the right length such\r
-  that it ends on exactly the last byte of the last section.  ProcessScript()\r
-  may have padded beyond the end of the last section out to a 4 byte boundary.\r
-  This padding is stripped.\r
-\r
-Arguments:\r
-  FileBuffer  - Data Buffer - contains a section stream\r
-  FileSize    - Size of FileBuffer as returned from ProcessScript()\r
-\r
-Returns:\r
-  Corrected size of file.\r
-\r
---*/\r
-{\r
-  UINT32                    TotalLength;\r
-  UINT32                    CurrentLength;\r
-  UINT32                    SectionLength;\r
-  UINT32                    SectionStreamLength;\r
-  EFI_COMMON_SECTION_HEADER *SectionHeader;\r
-  EFI_COMMON_SECTION_HEADER *NextSectionHeader;\r
-\r
-  TotalLength         = 0;\r
-  CurrentLength       = 0;\r
-  SectionStreamLength = FileSize;\r
-\r
-  SectionHeader       = (EFI_COMMON_SECTION_HEADER *) FileBuffer;\r
-\r
-  while (TotalLength < SectionStreamLength) {\r
-    SectionLength = *((UINT32 *) SectionHeader->Size) & 0x00ffffff;\r
-    TotalLength += SectionLength;\r
-\r
-    if (TotalLength == SectionStreamLength) {\r
-      return TotalLength;\r
-    }\r
-    //\r
-    // Move to the next byte following the section...\r
-    //\r
-    SectionHeader = (EFI_COMMON_SECTION_HEADER *) ((UINT8 *) SectionHeader + SectionLength);\r
-    CurrentLength = (UINTN) SectionHeader - (UINTN) FileBuffer;\r
-\r
-    //\r
-    // Figure out where the next section begins\r
-    //\r
-    NextSectionHeader = (EFI_COMMON_SECTION_HEADER *) ((UINT8 *) SectionHeader + 3);\r
-    NextSectionHeader = (EFI_COMMON_SECTION_HEADER *) ((UINTN) NextSectionHeader &~ (UINTN) 3);\r
-    TotalLength += (UINTN) NextSectionHeader - (UINTN) SectionHeader;\r
-    SectionHeader = NextSectionHeader;\r
-  }\r
-\r
-  return CurrentLength;\r
-}\r
-\r
-static\r
-INT32\r
-MainEntry (\r
-  INT32     argc,\r
-  CHAR8     *argv[],\r
-  BOOLEAN   ForceUncompress\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  MainEntry function.\r
-\r
-Arguments:\r
-\r
-  argc            - Number of command line parameters.\r
-  argv            - Array of pointers to command line parameter strings.\r
-  ForceUncompress - If TRUE, force to do not compress the sections even if compression\r
-                    is specified in the script. Otherwise, FALSE.\r
-\r
-Returns:\r
-  STATUS_SUCCESS  - Function exits successfully.\r
-  STATUS_ERROR    - Some error occurred during execution.\r
-\r
---*/\r
-{\r
-  FILE                    *PrimaryPackage;\r
-  FILE                    *OverridePackage;\r
-  FILE                    *Out;\r
-  CHAR8                   BaseName[_MAX_PATH];\r
-  EFI_GUID                FfsGuid;\r
-  CHAR8                   GuidString[_MAX_PATH];\r
-  EFI_FFS_FILE_HEADER     FileHeader;\r
-  CHAR8                   FileType[_MAX_PATH];\r
-  EFI_FFS_FILE_ATTRIBUTES FfsAttrib;\r
-  EFI_FFS_FILE_ATTRIBUTES FfsAttribDefined;\r
-  UINT64                  FfsAlignment;\r
-  UINT32                  FfsAlignment32;\r
-  CHAR8                   InputString[_MAX_PATH];\r
-  BOOLEAN                 ImageScriptInOveride;\r
-  UINT32                  FileSize;\r
-  UINT8                   *FileBuffer;\r
-  EFI_STATUS              Status;\r
-  UINT32                  LineNumber;\r
-  EFI_FFS_FILE_TAIL       TailValue;\r
-\r
-  BaseName[0]       = 0;\r
-  FileType[0]       = 0;\r
-  FfsAttrib         = 0;\r
-  FfsAttribDefined  = 0;\r
-  FfsAlignment      = 0;\r
-  FfsAlignment32    = 0;\r
-  PrimaryPackage    = NULL;\r
-  Out               = NULL;\r
-  OverridePackage   = NULL;\r
-  FileBuffer        = NULL;\r
-\r
-  strcpy (GuidString, "00000000-0000-0000-0000-000000000000");\r
-  Status = StringToGuid (GuidString, &FfsGuid);\r
-  if (Status != 0) {\r
-    Error (NULL, 0, 0, GuidString, "error parsing GUID string");\r
-    return STATUS_ERROR;\r
-  }\r
-\r
-  GuidString[0]         = 0;\r
-  ImageScriptInOveride  = FALSE;\r
-  //\r
-  // Initialize the simple file parsing routines. Then open\r
-  // the primary package file for parsing.\r
-  //\r
-  SFPInit ();\r
-  if (SFPOpenFile (mGlobals.PrimaryPackagePath) != STATUS_SUCCESS) {\r
-    Error (NULL, 0, 0, mGlobals.PrimaryPackagePath, "unable to open primary package file");\r
-    goto Done;\r
-  }\r
-  //\r
-  // First token in the file must be "PACKAGE.INF"\r
-  //\r
-  if (!SFPIsToken ("PACKAGE.INF")) {\r
-    Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "expected 'PACKAGE.INF'", NULL);\r
-    goto Done;\r
-  }\r
-  //\r
-  // Find the [.] section\r
-  //\r
-  if (!SFPSkipToToken ("[.]")) {\r
-    Error (mGlobals.PrimaryPackagePath, 1, 0, "could not locate [.] section in package file", NULL);\r
-    goto Done;\r
-  }\r
-  //\r
-  // Start parsing the data. The algorithm is essentially the same for each keyword:\r
-  //   1. Identify the keyword\r
-  //   2. Verify that the keyword/value pair has not already been defined\r
-  //   3. Set some flag indicating that the keyword/value pair has been defined\r
-  //   4. Skip over the "="\r
-  //   5. Get the value, which may be a number, TRUE, FALSE, or a string.\r
-  //\r
-  while (1) {\r
-    if (SFPIsToken ("BASE_NAME")) {\r
-      //\r
-      // Found BASE_NAME, format:\r
-      //   BASE_NAME = MyBaseName\r
-      //\r
-      if (BaseName[0] != 0) {\r
-        Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "BASE_NAME already defined", NULL);\r
-        goto Done;\r
-      }\r
-\r
-      if (!SFPIsToken ("=")) {\r
-        Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "expected '='", NULL);\r
-        goto Done;\r
-      }\r
-\r
-      if (!SFPGetNextToken (BaseName, sizeof (BaseName))) {\r
-        Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "expected valid base name", NULL);\r
-        goto Done;\r
-      }\r
-    } else if (SFPIsToken ("IMAGE_SCRIPT")) {\r
-      //\r
-      // Found IMAGE_SCRIPT. Break out and process below.\r
-      //\r
-      break;\r
-    } else if (SFPIsToken ("FFS_FILEGUID")) {\r
-      //\r
-      // found FILEGUID, format:\r
-      //   FFS_FILEGUID = F7845C4F-EDF5-42C5-BD8F-A02AF63DD93A\r
-      //\r
-      if (GuidString[0] != 0) {\r
-        Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "FFS_FILEGUID already defined", NULL);\r
-        goto Done;\r
-      }\r
-\r
-      if (!SFPIsToken ("=")) {\r
-        Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "expected '='", NULL);\r
-        goto Done;\r
-      }\r
-\r
-      if (SFPGetGuidToken (GuidString, sizeof (GuidString)) != TRUE) {\r
-        Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "expected file GUID", NULL);\r
-        goto Done;\r
-      }\r
-\r
-      Status = StringToGuid (GuidString, &FfsGuid);\r
-      if (Status != 0) {\r
-        Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "expected valid file GUID", NULL);\r
-        goto Done;\r
-      }\r
-    } else if (SFPIsToken ("FFS_FILETYPE")) {\r
-      //\r
-      // ***********************************************************************\r
-      //\r
-      // Found FFS_FILETYPE, format:\r
-      //  FFS_FILETYPE = EFI_FV_FILETYPE_APPLICATION\r
-      //\r
-      if (FileType[0] != 0) {\r
-        Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "FFS_FILETYPE previously defined", NULL);\r
-        goto Done;\r
-      }\r
-\r
-      if (!SFPIsToken ("=")) {\r
-        Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "expected '='", NULL);\r
-        goto Done;\r
-      }\r
-\r
-      if (!SFPGetNextToken (FileType, sizeof (FileType))) {\r
-        Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "expected valid FFS_FILETYPE", NULL);\r
-        goto Done;\r
-      }\r
-    } else if (SFPIsToken ("FFS_ATTRIB_HEADER_EXTENSION")) {\r
-      //\r
-      // ***********************************************************************\r
-      //\r
-      // Found: FFS_ATTRIB_HEADER_EXTENSION = FALSE\r
-      // Spec says the bit is for future expansion, and must be false.\r
-      //\r
-      if (FfsAttribDefined & FFS_ATTRIB_HEADER_EXTENSION) {\r
-        Error (\r
-          mGlobals.PrimaryPackagePath,\r
-          SFPGetLineNumber (),\r
-          0,\r
-          "FFS_ATTRIB_HEADER_EXTENSION previously defined",\r
-          NULL\r
-          );\r
-        goto Done;\r
-      }\r
-\r
-      FfsAttribDefined |= FFS_ATTRIB_HEADER_EXTENSION;\r
-      if (!SFPIsToken ("=")) {\r
-        Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "expected '='", NULL);\r
-        goto Done;\r
-      }\r
-\r
-      if (SFPIsToken ("TRUE")) {\r
-        Error (\r
-          mGlobals.PrimaryPackagePath,\r
-          SFPGetLineNumber (),\r
-          0,\r
-          "only FFS_ATTRIB_HEADER_EXTENSION = FALSE is supported",\r
-          NULL\r
-          );\r
-        goto Done;\r
-      } else if (SFPIsToken ("FALSE")) {\r
-        //\r
-        // Default is FALSE\r
-        //\r
-      } else {\r
-        Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "expected 'FALSE'", NULL);\r
-        goto Done;\r
-      }\r
-    } else if (SFPIsToken ("FFS_ATTRIB_TAIL_PRESENT")) {\r
-      //\r
-      // ***********************************************************************\r
-      //\r
-      // Found: FFS_ATTRIB_TAIL_PRESENT = TRUE | FALSE\r
-      //\r
-      if (FfsAttribDefined & FFS_ATTRIB_TAIL_PRESENT) {\r
-        Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "FFS_ATTRIB_TAIL_PRESENT previously defined", NULL);\r
-        goto Done;\r
-      }\r
-\r
-      FfsAttribDefined |= FFS_ATTRIB_TAIL_PRESENT;\r
-      if (!SFPIsToken ("=")) {\r
-        Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "expected '='", NULL);\r
-        goto Done;\r
-      }\r
-\r
-      if (SFPIsToken ("TRUE")) {\r
-        FfsAttrib |= FFS_ATTRIB_TAIL_PRESENT;\r
-      } else if (SFPIsToken ("FALSE")) {\r
-        //\r
-        // Default is FALSE\r
-        //\r
-      } else {\r
-        Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "expected 'TRUE' or 'FALSE'", NULL);\r
-        goto Done;\r
-      }\r
-    } else if (SFPIsToken ("FFS_ATTRIB_RECOVERY")) {\r
-      //\r
-      // ***********************************************************************\r
-      //\r
-      // Found: FFS_ATTRIB_RECOVERY = TRUE | FALSE\r
-      //\r
-      if (FfsAttribDefined & FFS_ATTRIB_RECOVERY) {\r
-        Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "FFS_ATTRIB_RECOVERY previously defined", NULL);\r
-        goto Done;\r
-      }\r
-\r
-      FfsAttribDefined |= FFS_ATTRIB_RECOVERY;\r
-      if (!SFPIsToken ("=")) {\r
-        Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "expected '='", NULL);\r
-        goto Done;\r
-      }\r
-\r
-      if (SFPIsToken ("TRUE")) {\r
-        FfsAttrib |= FFS_ATTRIB_RECOVERY;\r
-      } else if (SFPIsToken ("FALSE")) {\r
-        //\r
-        // Default is FALSE\r
-        //\r
-      } else {\r
-        Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "expected 'TRUE' or 'FALSE'", NULL);\r
-        goto Done;\r
-      }\r
-    } else if (SFPIsToken ("FFS_ATTRIB_CHECKSUM")) {\r
-      //\r
-      // ***********************************************************************\r
-      //\r
-      // Found: FFS_ATTRIB_CHECKSUM = TRUE | FALSE\r
-      //\r
-      if (FfsAttribDefined & FFS_ATTRIB_CHECKSUM) {\r
-        Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "FFS_ATTRIB_CHECKSUM previously defined", NULL);\r
-        goto Done;\r
-      }\r
-\r
-      FfsAttribDefined |= FFS_ATTRIB_CHECKSUM;\r
-      if (!SFPIsToken ("=")) {\r
-        Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "expected '='", NULL);\r
-        goto Done;\r
-      }\r
-\r
-      if (SFPIsToken ("TRUE")) {\r
-        FfsAttrib |= FFS_ATTRIB_CHECKSUM;\r
-      } else if (SFPIsToken ("FALSE")) {\r
-        //\r
-        // Default is FALSE\r
-        //\r
-      } else {\r
-        Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "expected 'TRUE' or 'FALSE'", NULL);\r
-        goto Done;\r
-      }\r
-    } else if (SFPIsToken ("FFS_ALIGNMENT") || SFPIsToken ("FFS_ATTRIB_DATA_ALIGNMENT")) {\r
-      //\r
-      // ***********************************************************************\r
-      //\r
-      // Found FFS_ALIGNMENT, formats:\r
-      //   FFS_ALIGNMENT = 0-7\r
-      //   FFS_ATTRIB_DATA_ALIGNMENT = 0-7\r
-      //\r
-      if (FfsAttribDefined & FFS_ATTRIB_DATA_ALIGNMENT) {\r
-        Error (\r
-          mGlobals.PrimaryPackagePath,\r
-          SFPGetLineNumber (),\r
-          0,\r
-          "FFS_ALIGNMENT/FFS_ATTRIB_DATA_ALIGNMENT previously defined",\r
-          NULL\r
-          );\r
-        goto Done;\r
-      }\r
-\r
-      FfsAttribDefined |= FFS_ATTRIB_DATA_ALIGNMENT;\r
-      if (!SFPIsToken ("=")) {\r
-        Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "expected '='", NULL);\r
-        goto Done;\r
-      }\r
-\r
-      if (!SFPGetNumber (&FfsAlignment32)) {\r
-        Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "expected numeric value for alignment", NULL);\r
-        goto Done;\r
-      }\r
-\r
-      if (FfsAlignment32 > 7) {\r
-        Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, "expected 0 <= alignment <= 7", NULL);\r
-        goto Done;\r
-      }\r
-\r
-      FfsAttrib |= (((EFI_FFS_FILE_ATTRIBUTES) FfsAlignment32) << 3);\r
-    } else {\r
-      SFPGetNextToken (InputString, sizeof (InputString));\r
-      Error (mGlobals.PrimaryPackagePath, SFPGetLineNumber (), 0, InputString, "unrecognized/unexpected token");\r
-      goto Done;\r
-    }\r
-  }\r
-  //\r
-  // Close the primary package file\r
-  //\r
-  SFPCloseFile ();\r
-  //\r
-  // TODO: replace code below with basically a copy of the code above. Don't\r
-  // forget to reset the FfsAttribDefined variable first. Also, you'll need\r
-  // to somehow keep track of whether or not the basename is defined multiple\r
-  // times in the override package. Ditto on the file GUID.\r
-  //\r
-  if (mGlobals.OverridePackagePath[0] != 0) {\r
-    OverridePackage = fopen (mGlobals.OverridePackagePath, "r");\r
-    //\r
-    // NOTE: For package override to work correctly, the code below must be modified to\r
-    //       SET or CLEAR bits properly. For example, if the primary package set\r
-    //       FFS_ATTRIB_CHECKSUM = TRUE, and the override set FFS_ATTRIB_CHECKSUM = FALSE, then\r
-    //       we'd need to clear the bit below. Since this is not happening, I'm guessing that\r
-    //       the override functionality is not being used, so should be made obsolete. If I'm\r
-    //       wrong, and it is being used, then it needs to be fixed. Thus emit an error if it is\r
-    //       used, and we'll address it then.  4/10/2003\r
-    //\r
-    Error (__FILE__, __LINE__, 0, "package override functionality is not implemented correctly", NULL);\r
-    goto Done;\r
-  } else {\r
-    OverridePackage = NULL;\r
-  }\r
-\r
-#ifdef OVERRIDE_SUPPORTED\r
-  if (OverridePackage != NULL) {\r
-    //\r
-    // Parse override package file\r
-    //\r
-    fscanf (OverridePackage, "%s", &InputString);\r
-    if (strcmpi (InputString, "PACKAGE.INF") != 0) {\r
-      Error (mGlobals.OverridePackagePath, 1, 0, "invalid package file", "expected 'PACKAGE.INF'");\r
-      goto Done;\r
-    }\r
-    //\r
-    // Match [dir] to Build Directory\r
-    //\r
-    if (FindSectionInPackage (mGlobals.BuildDirectory, OverridePackage, &LineNumber) != 0) {\r
-      Error (mGlobals.OverridePackagePath, 1, 0, mGlobals.BuildDirectory, "section not found in package file");\r
-      goto Done;\r
-    }\r
-\r
-    InputString[0] = 0;\r
-    while ((InputString[0] != '[') && (!feof (OverridePackage))) {\r
-      if (GetNextLine (InputString, OverridePackage, &LineNumber) != -1) {\r
-        if (InputString[0] != '[') {\r
-here:\r
-          if (strcmpi (InputString, "BASE_NAME") == 0) {\r
-            //\r
-            // found BASE_NAME, next is = and string.\r
-            //\r
-            fscanf (OverridePackage, "%s", &InputString);\r
-            CheckSlash (InputString, OverridePackage, &LineNumber);\r
-            if (strlen (InputString) == 1) {\r
-              //\r
-              // string is just =\r
-              //\r
-              fscanf (OverridePackage, "%s", &InputString);\r
-              CheckSlash (InputString, OverridePackage, &LineNumber);\r
-              strcpy (BaseName, InputString);\r
-            } else {\r
-              BreakString (InputString, InputString, 1);\r
-              strcpy (BaseName, InputString);\r
-            }\r
-          } else if (strcmpi (InputString, "IMAGE_SCRIPT") == 0) {\r
-            //\r
-            // found IMAGE_SCRIPT, come back later to process it\r
-            //\r
-            ImageScriptInOveride = TRUE;\r
-            fscanf (OverridePackage, "%s", &InputString);\r
-          } else if (strcmpi (InputString, "FFS_FILEGUID") == 0) {\r
-            //\r
-            // found FILEGUID, next is = and string.\r
-            //\r
-            fscanf (OverridePackage, "%s", &InputString);\r
-            CheckSlash (InputString, OverridePackage, &LineNumber);\r
-            if (strlen (InputString) == 1) {\r
-              //\r
-              // string is just =\r
-              //\r
-              fscanf (OverridePackage, "%s", &InputString);\r
-              CheckSlash (InputString, OverridePackage, &LineNumber);\r
-              Status = StringToGuid (InputString, &FfsGuid);\r
-              if (Status != 0) {\r
-                Error (mGlobals.OverridePackagePath, 1, 0, InputString, "bad FFS_FILEGUID format");\r
-                goto Done;\r
-              }\r
-            } else {\r
-              BreakString (InputString, InputString, 1);\r
-              Status = StringToGuid (InputString, &FfsGuid);\r
-              if (Status != 0) {\r
-                Error (mGlobals.OverridePackagePath, 1, 0, InputString, "bad FFS_FILEGUID format");\r
-                goto Done;\r
-              }\r
-            }\r
-          } else if (strcmpi (InputString, "FFS_FILETYPE") == 0) {\r
-            //\r
-            // found FILETYPE, next is = and string.\r
-            //\r
-            fscanf (OverridePackage, "%s", &InputString);\r
-            CheckSlash (InputString, OverridePackage, &LineNumber);\r
-            if (strlen (InputString) == 1) {\r
-              //\r
-              // string is just =\r
-              //\r
-              fscanf (OverridePackage, "%s", &InputString);\r
-              CheckSlash (InputString, OverridePackage, &LineNumber);\r
-              strcpy (FileType, InputString);\r
-            } else {\r
-              BreakString (InputString, InputString, 1);\r
-              strcpy (FileType, InputString);\r
-            }\r
-\r
-          } else if (strcmpi (InputString, "FFS_ATTRIB_RECOVERY") == 0) {\r
-            //\r
-            // found FFS_ATTRIB_RECOVERY, next is = and string.\r
-            //\r
-            fscanf (OverridePackage, "%s", &InputString);\r
-            CheckSlash (InputString, OverridePackage, &LineNumber);\r
-            if (strlen (InputString) == 1) {\r
-              //\r
-              // string is just =\r
-              //\r
-              fscanf (OverridePackage, "%s", &InputString);\r
-              CheckSlash (InputString, OverridePackage, &LineNumber);\r
-              if (strcmpi (InputString, "TRUE") == 0) {\r
-                FfsAttrib |= FFS_ATTRIB_RECOVERY;\r
-              }\r
-            } else {\r
-              BreakString (InputString, InputString, 1);\r
-              if (strcmpi (InputString, "TRUE") == 0) {\r
-                FfsAttrib |= FFS_ATTRIB_RECOVERY;\r
-              }\r
-            }\r
-          } else if (strcmpi (InputString, "FFS_ATTRIB_CHECKSUM") == 0) {\r
-            //\r
-            // found FFS_ATTRIB_CHECKSUM, next is = and string.\r
-            //\r
-            fscanf (OverridePackage, "%s", &InputString);\r
-            CheckSlash (InputString, OverridePackage, &LineNumber);\r
-            if (strlen (InputString) == 1) {\r
-              //\r
-              // string is just =\r
-              //\r
-              fscanf (OverridePackage, "%s", &InputString);\r
-              CheckSlash (InputString, OverridePackage, &LineNumber);\r
-              if (strcmpi (InputString, "TRUE") == 0) {\r
-                FfsAttrib |= FFS_ATTRIB_CHECKSUM;\r
-              }\r
-            } else {\r
-              BreakString (InputString, InputString, 1);\r
-              if (strcmpi (InputString, "TRUE") == 0) {\r
-                FfsAttrib |= FFS_ATTRIB_CHECKSUM;\r
-              }\r
-            }\r
-          } else if (strcmpi (InputString, "FFS_ALIGNMENT") == 0) {\r
-            //\r
-            // found FFS_ALIGNMENT, next is = and string.\r
-            //\r
-            fscanf (OverridePackage, "%s", &InputString);\r
-            CheckSlash (InputString, OverridePackage, &LineNumber);\r
-            if (strlen (InputString) == 1) {\r
-              //\r
-              // string is just =\r
-              //\r
-              fscanf (OverridePackage, "%s", &InputString);\r
-              CheckSlash (InputString, OverridePackage, &LineNumber);\r
-            } else {\r
-              BreakString (InputString, InputString, 1);\r
-            }\r
-\r
-            AsciiStringToUint64 (InputString, FALSE, &FfsAlignment);\r
-            if (FfsAlignment > 7) {\r
-              Error (mGlobals.OverridePackagePath, 1, 0, InputString, "invalid FFS_ALIGNMENT value");\r
-              goto Done;\r
-            }\r
-\r
-            FfsAttrib |= (((EFI_FFS_FILE_ATTRIBUTES) FfsAlignment) << 3);\r
-          } else if (strchr (InputString, '=') != NULL) {\r
-            BreakString (InputString, String, 1);\r
-            fseek (OverridePackage, (-1 * (strlen (String) + 1)), SEEK_CUR);\r
-            BreakString (InputString, InputString, 0);\r
-            goto here;\r
-          }\r
-        }\r
-      }\r
-    }\r
-  }\r
-#endif // #ifdef OVERRIDE_SUPPORTED\r
-  //\r
-  // Require that they specified a file GUID at least, since that's how we're\r
-  // naming the file.\r
-  //\r
-  if (GuidString[0] == 0) {\r
-    Error (mGlobals.PrimaryPackagePath, 1, 0, "FFS_FILEGUID must be specified", NULL);\r
-    return STATUS_ERROR;\r
-  }\r
-  //\r
-  // Build Header and process image script\r
-  //\r
-  FileBuffer = (UINT8 *) malloc ((1024 * 1024 * 16) * sizeof (UINT8));\r
-  if (FileBuffer == NULL) {\r
-    Error (__FILE__, __LINE__, 0, "memory allocation failed", NULL);\r
-    goto Done;\r
-  }\r
-\r
-  FileSize = 0;\r
-  if (ImageScriptInOveride) {\r
-#ifdef OVERRIDE_SUPORTED\r
-    rewind (OverridePackage);\r
-    LineNumber = 0;\r
-    FindSectionInPackage (mGlobals.BuildDirectory, OverridePackage, &LineNumber);\r
-    while (strcmpi (InputString, "IMAGE_SCRIPT") != 0) {\r
-      GetNextLine (InputString, OverridePackage, &LineNumber);\r
-      CheckSlash (InputString, OverridePackage, &LineNumber);\r
-      if (strchr (InputString, '=') != NULL) {\r
-        BreakString (InputString, InputString, 0);\r
-      }\r
-    }\r
-\r
-    while (InputString[0] != '{') {\r
-      GetNextLine (InputString, OverridePackage, &LineNumber);\r
-      CheckSlash (InputString, OverridePackage, &LineNumber);\r
-    }\r
-    //\r
-    // Found start of image script, process it\r
-    //\r
-    FileSize += ProcessScript (FileBuffer, OverridePackage, mGlobals.BuildDirectory, ForceUncompress);\r
-    if (FileSize == -1) {\r
-      return -1;\r
-    }\r
-\r
-    if (StringToType (FileType) != EFI_FV_FILETYPE_RAW) {\r
-      FileSize = AdjustFileSize (FileBuffer, FileSize);\r
-    }\r
-\r
-    if (BaseName[0] == '\"') {\r
-      StripQuotes (BaseName);\r
-    }\r
-\r
-    if (BaseName[0] != 0) {\r
-      sprintf (InputString, "%s-%s", GuidString, BaseName);\r
-    } else {\r
-      strcpy (InputString, GuidString);\r
-    }\r
-\r
-    switch (StringToType (FileType)) {\r
-\r
-    case EFI_FV_FILETYPE_SECURITY_CORE:\r
-      strcat (InputString, ".SEC");\r
-      break;\r
-\r
-    case EFI_FV_FILETYPE_PEIM:\r
-    case EFI_FV_FILETYPE_PEI_CORE:\r
-    case EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER:\r
-      strcat (InputString, ".PEI");\r
-      break;\r
-\r
-    case EFI_FV_FILETYPE_DRIVER:\r
-    case EFI_FV_FILETYPE_DXE_CORE:\r
-      strcat (InputString, ".DXE");\r
-      break;\r
-\r
-    case EFI_FV_FILETYPE_APPLICATION:\r
-      strcat (InputString, ".APP");\r
-      break;\r
-\r
-    case EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE:\r
-      strcat (InputString, ".FVI");\r
-      break;\r
-\r
-    case EFI_FV_FILETYPE_ALL:\r
-      Error (mGlobals.OverridePackagePath, 1, 0, "invalid FFS file type for this utility", NULL);\r
-      goto Done;\r
-\r
-    default:\r
-      strcat (InputString, ".FFS");\r
-      break;\r
-    }\r
-\r
-    if (ForceUncompress) {\r
-      strcat (InputString, ".ORG");\r
-    }\r
-\r
-    Out = fopen (InputString, "wb");\r
-    if (Out == NULL) {\r
-      Error (NULL, 0, 0, InputString, "could not open output file for writing");\r
-      goto Done;\r
-    }\r
-    //\r
-    // create ffs header\r
-    //\r
-    memset (&FileHeader, 0, sizeof (EFI_FFS_FILE_HEADER));\r
-    memcpy (&FileHeader.Name, &FfsGuid, sizeof (EFI_GUID));\r
-    FileHeader.Type       = StringToType (FileType);\r
-    FileHeader.Attributes = FfsAttrib;\r
-    //\r
-    // Now FileSize includes the EFI_FFS_FILE_HEADER\r
-    //\r
-    FileSize += sizeof (EFI_FFS_FILE_HEADER);\r
-    FileHeader.Size[0]  = (UINT8) (FileSize & 0xFF);\r
-    FileHeader.Size[1]  = (UINT8) ((FileSize & 0xFF00) >> 8);\r
-    FileHeader.Size[2]  = (UINT8) ((FileSize & 0xFF0000) >> 16);\r
-    //\r
-    // Fill in checksums and state, these must be zero for checksumming\r
-    //\r
-    // FileHeader.IntegrityCheck.Checksum.Header = 0;\r
-    // FileHeader.IntegrityCheck.Checksum.File = 0;\r
-    // FileHeader.State = 0;\r
-    //\r
-    FileHeader.IntegrityCheck.Checksum.Header = CalculateChecksum8 (\r
-                                                  (UINT8 *) &FileHeader,\r
-                                                  sizeof (EFI_FFS_FILE_HEADER)\r
-                                                  );\r
-    if (FileHeader.Attributes & FFS_ATTRIB_CHECKSUM) {\r
-      FileHeader.IntegrityCheck.Checksum.File = CalculateChecksum8 ((UINT8 *) &FileHeader, FileSize);\r
-    } else {\r
-      FileHeader.IntegrityCheck.Checksum.File = FFS_FIXED_CHECKSUM;\r
-    }\r
-\r
-    FileHeader.State = EFI_FILE_HEADER_CONSTRUCTION | EFI_FILE_HEADER_VALID | EFI_FILE_DATA_VALID;\r
-    //\r
-    // write header\r
-    //\r
-    if (fwrite (&FileHeader, sizeof (FileHeader), 1, Out) != 1) {\r
-      Error (NULL, 0, 0, "failed to write file header to output file", NULL);\r
-      goto Done;\r
-    }\r
-    //\r
-    // write data\r
-    //\r
-    if (fwrite (FileBuffer, FileSize - sizeof (EFI_FFS_FILE_HEADER), 1, Out) != 1) {\r
-      Error (NULL, 0, 0, "failed to write all bytes to output file", NULL);\r
-      goto Done;\r
-    }\r
-\r
-    fclose (Out);\r
-    Out = NULL;\r
-#endif // #ifdef OVERRIDE_SUPPORTED\r
-  } else {\r
-    //\r
-    // Open primary package file and process the IMAGE_SCRIPT section\r
-    //\r
-    PrimaryPackage = fopen (mGlobals.PrimaryPackagePath, "r");\r
-    if (PrimaryPackage == NULL) {\r
-      Error (NULL, 0, 0, mGlobals.PrimaryPackagePath, "unable to open primary package file");\r
-      goto Done;\r
-    }\r
-\r
-    LineNumber = 1;\r
-    FindSectionInPackage (".", PrimaryPackage, &LineNumber);\r
-    while (strcmpi (InputString, "IMAGE_SCRIPT") != 0) {\r
-      GetNextLine (InputString, PrimaryPackage, &LineNumber);\r
-      CheckSlash (InputString, PrimaryPackage, &LineNumber);\r
-      if (strchr (InputString, '=') != NULL) {\r
-        BreakString (InputString, InputString, 0);\r
-      }\r
-    }\r
-\r
-    while (InputString[0] != '{') {\r
-      GetNextLine (InputString, PrimaryPackage, &LineNumber);\r
-      CheckSlash (InputString, PrimaryPackage, &LineNumber);\r
-    }\r
-    //\r
-    // Found start of image script, process it\r
-    //\r
-    FileSize += ProcessScript (FileBuffer, PrimaryPackage, mGlobals.BuildDirectory, ForceUncompress);\r
-    if (FileSize == -1) {\r
-      goto Done;\r
-    }\r
-\r
-    if (StringToType (FileType) != EFI_FV_FILETYPE_RAW) {\r
-      FileSize = AdjustFileSize (FileBuffer, FileSize);\r
-    }\r
-\r
-    if (BaseName[0] == '\"') {\r
-      StripQuotes (BaseName);\r
-    }\r
-\r
-    if (BaseName[0] != 0) {\r
-      sprintf (InputString, "%s-%s", GuidString, BaseName);\r
-    } else {\r
-      strcpy (InputString, GuidString);\r
-    }\r
-\r
-    switch (StringToType (FileType)) {\r
-\r
-    case EFI_FV_FILETYPE_SECURITY_CORE:\r
-      strcat (InputString, ".SEC");\r
-      break;\r
-\r
-    case EFI_FV_FILETYPE_PEIM:\r
-    case EFI_FV_FILETYPE_PEI_CORE:\r
-    case EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER:\r
-      strcat (InputString, ".PEI");\r
-      break;\r
-\r
-    case EFI_FV_FILETYPE_DRIVER:\r
-    case EFI_FV_FILETYPE_DXE_CORE:\r
-      strcat (InputString, ".DXE");\r
-      break;\r
-\r
-    case EFI_FV_FILETYPE_APPLICATION:\r
-      strcat (InputString, ".APP");\r
-      break;\r
-\r
-    case EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE:\r
-      strcat (InputString, ".FVI");\r
-      break;\r
-\r
-    case EFI_FV_FILETYPE_ALL:\r
-      Error (mGlobals.PrimaryPackagePath, 1, 0, "invalid FFS file type for this utility", NULL);\r
-      goto Done;\r
-\r
-    default:\r
-      strcat (InputString, ".FFS");\r
-      break;\r
-    }\r
-\r
-    if (ForceUncompress) {\r
-      strcat (InputString, ".ORG");\r
-    }\r
-\r
-    Out = fopen (InputString, "wb");\r
-    if (Out == NULL) {\r
-      Error (NULL, 0, 0, InputString, "failed to open output file for writing");\r
-      goto Done;\r
-    }\r
-    //\r
-    // Initialize the FFS file header\r
-    //\r
-    memset (&FileHeader, 0, sizeof (EFI_FFS_FILE_HEADER));\r
-    memcpy (&FileHeader.Name, &FfsGuid, sizeof (EFI_GUID));\r
-    FileHeader.Type       = StringToType (FileType);\r
-    FileHeader.Attributes = FfsAttrib;\r
-    //\r
-    // From this point on FileSize includes the size of the EFI_FFS_FILE_HEADER\r
-    //\r
-    FileSize += sizeof (EFI_FFS_FILE_HEADER);\r
-    //\r
-    // If using a tail, then it adds two bytes\r
-    //\r
-    if (FileHeader.Attributes & FFS_ATTRIB_TAIL_PRESENT) {\r
-      //\r
-      // Tail is not allowed for pad and 0-length files\r
-      //\r
-      if ((FileHeader.Type == EFI_FV_FILETYPE_FFS_PAD) || (FileSize == sizeof (EFI_FFS_FILE_HEADER))) {\r
-        Error (\r
-          mGlobals.PrimaryPackagePath,\r
-          1,\r
-          0,\r
-          "FFS_ATTRIB_TAIL_PRESENT=TRUE is invalid for PAD or 0-length files",\r
-          NULL\r
-          );\r
-        goto Done;\r
-      }\r
-\r
-      FileSize += sizeof (EFI_FFS_FILE_TAIL);\r
-    }\r
-\r
-    FileHeader.Size[0]  = (UINT8) (FileSize & 0xFF);\r
-    FileHeader.Size[1]  = (UINT8) ((FileSize & 0xFF00) >> 8);\r
-    FileHeader.Size[2]  = (UINT8) ((FileSize & 0xFF0000) >> 16);\r
-    //\r
-    // Fill in checksums and state, they must be 0 for checksumming.\r
-    //\r
-    // FileHeader.IntegrityCheck.Checksum.Header = 0;\r
-    // FileHeader.IntegrityCheck.Checksum.File = 0;\r
-    // FileHeader.State = 0;\r
-    //\r
-    FileHeader.IntegrityCheck.Checksum.Header = CalculateChecksum8 (\r
-                                                  (UINT8 *) &FileHeader,\r
-                                                  sizeof (EFI_FFS_FILE_HEADER)\r
-                                                  );\r
-    if (FileHeader.Attributes & FFS_ATTRIB_CHECKSUM) {\r
-      //\r
-      // Cheating here.  Since the header checksums, just calculate the checksum of the body.\r
-      // Checksum does not include the tail\r
-      //\r
-      if (FileHeader.Attributes & FFS_ATTRIB_TAIL_PRESENT) {\r
-        FileHeader.IntegrityCheck.Checksum.File = CalculateChecksum8 (\r
-                                                    FileBuffer,\r
-                                                    FileSize - sizeof (EFI_FFS_FILE_HEADER) - sizeof (EFI_FFS_FILE_TAIL)\r
-                                                    );\r
-      } else {\r
-        FileHeader.IntegrityCheck.Checksum.File = CalculateChecksum8 (\r
-                                                    FileBuffer,\r
-                                                    FileSize - sizeof (EFI_FFS_FILE_HEADER)\r
-                                                    );\r
-      }\r
-    } else {\r
-      FileHeader.IntegrityCheck.Checksum.File = FFS_FIXED_CHECKSUM;\r
-    }\r
-    //\r
-    // Set the state now. Spec says the checksum assumes the state is 0\r
-    //\r
-    FileHeader.State = EFI_FILE_HEADER_CONSTRUCTION | EFI_FILE_HEADER_VALID | EFI_FILE_DATA_VALID;\r
-    //\r
-    // If there is a tail, then set it\r
-    //\r
-    if (FileHeader.Attributes & FFS_ATTRIB_TAIL_PRESENT) {\r
-      TailValue = FileHeader.IntegrityCheck.TailReference;\r
-      TailValue = (UINT16) (~TailValue);\r
-      memcpy (\r
-        (UINT8 *) FileBuffer + FileSize - sizeof (EFI_FFS_FILE_HEADER) - sizeof (EFI_FFS_FILE_TAIL),\r
-        &TailValue,\r
-        sizeof (TailValue)\r
-        );\r
-    }\r
-    //\r
-    // Write the FFS file header\r
-    //\r
-    if (fwrite (&FileHeader, sizeof (FileHeader), 1, Out) != 1) {\r
-      Error (NULL, 0, 0, "failed to write file header contents", NULL);\r
-      goto Done;\r
-    }\r
-    //\r
-    // Write data\r
-    //\r
-    if (fwrite (FileBuffer, FileSize - sizeof (EFI_FFS_FILE_HEADER), 1, Out) != 1) {\r
-      Error (NULL, 0, 0, "failed to write file contents", NULL);\r
-      goto Done;\r
-    }\r
-  }\r
-\r
-Done:\r
-  SFPCloseFile ();\r
-  if (Out != NULL) {\r
-    fclose (Out);\r
-  }\r
-\r
-  if (PrimaryPackage != NULL) {\r
-    fclose (PrimaryPackage);\r
-  }\r
-\r
-  if (FileBuffer != NULL) {\r
-    free (FileBuffer);\r
-  }\r
-\r
-  if (OverridePackage != NULL) {\r
-    fclose (OverridePackage);\r
-  }\r
-\r
-  return GetUtilityStatus ();\r
-}\r
-\r
-int\r
-main (\r
-  INT32 argc,\r
-  CHAR8 *argv[]\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Main function.\r
-\r
-Arguments:\r
-\r
-  argc - Number of command line parameters.\r
-  argv - Array of pointers to parameter strings.\r
-\r
-Returns:\r
-  STATUS_SUCCESS - Utility exits successfully.\r
-  STATUS_ERROR   - Some error occurred during execution.\r
-\r
---*/\r
-{\r
-  STATUS  Status;\r
-  //\r
-  // Set the name of our utility for error reporting purposes.\r
-  //\r
-  SetUtilityName (UTILITY_NAME);\r
-  Status = ProcessCommandLineArgs (argc, argv);\r
-  if (Status != STATUS_SUCCESS) {\r
-    return Status;\r
-  }\r
-\r
-  Status = MainEntry (argc, argv, TRUE);\r
-  if (Status == STATUS_SUCCESS) {\r
-    MainEntry (argc, argv, FALSE);\r
-  }\r
-  //\r
-  // If any errors were reported via the standard error reporting\r
-  // routines, then the status has been saved. Get the value and\r
-  // return it to the caller.\r
-  //\r
-  return GetUtilityStatus ();\r
-}\r
-\r
-static\r
-STATUS\r
-ProcessCommandLineArgs (\r
-  int     Argc,\r
-  char    *Argv[]\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Process the command line arguments.\r
-\r
-Arguments:\r
-  Argc - as passed in to main()\r
-  Argv - as passed in to main()\r
-\r
-Returns:\r
-  STATUS_SUCCESS    - arguments all ok\r
-  STATUS_ERROR      - problem with args, so caller should exit\r
-\r
---*/\r
-{\r
-  //\r
-  // If no args, then print usage instructions and return an error\r
-  //\r
-  if (Argc == 1) {\r
-    PrintUsage ();\r
-    return STATUS_ERROR;\r
-  }\r
-\r
-  memset (&mGlobals, 0, sizeof (mGlobals));\r
-  Argc--;\r
-  Argv++;\r
-  while (Argc > 0) {\r
-    if (strcmpi (Argv[0], "-b") == 0) {\r
-      //\r
-      // OPTION: -b BuildDirectory\r
-      // Make sure there is another argument, then save it to our globals.\r
-      //\r
-      if (Argc < 2) {\r
-        Error (NULL, 0, 0, "-b option requires the build directory name", NULL);\r
-        return STATUS_ERROR;\r
-      }\r
-\r
-      if (mGlobals.BuildDirectory[0]) {\r
-        Error (NULL, 0, 0, Argv[0], "option can only be specified once");\r
-        return STATUS_ERROR;\r
-      }\r
-\r
-      strcpy (mGlobals.BuildDirectory, Argv[1]);\r
-      Argc--;\r
-      Argv++;\r
-    } else if (strcmpi (Argv[0], "-p1") == 0) {\r
-      //\r
-      // OPTION: -p1 PrimaryPackageFile\r
-      // Make sure there is another argument, then save it to our globals.\r
-      //\r
-      if (Argc < 2) {\r
-        Error (NULL, 0, 0, Argv[0], "option requires the primary package file name");\r
-        return STATUS_ERROR;\r
-      }\r
-\r
-      if (mGlobals.PrimaryPackagePath[0]) {\r
-        Error (NULL, 0, 0, Argv[0], "option can only be specified once");\r
-        return STATUS_ERROR;\r
-      }\r
-\r
-      strcpy (mGlobals.PrimaryPackagePath, Argv[1]);\r
-      Argc--;\r
-      Argv++;\r
-    } else if (strcmpi (Argv[0], "-p2") == 0) {\r
-      //\r
-      // OPTION: -p2 OverridePackageFile\r
-      // Make sure there is another argument, then save it to our globals.\r
-      //\r
-      if (Argc < 2) {\r
-        Error (NULL, 0, 0, Argv[0], "option requires the override package file name");\r
-        return STATUS_ERROR;\r
-      }\r
-\r
-      if (mGlobals.OverridePackagePath[0]) {\r
-        Error (NULL, 0, 0, Argv[0], "option can only be specified once");\r
-        return STATUS_ERROR;\r
-      }\r
-\r
-      strcpy (mGlobals.OverridePackagePath, Argv[1]);\r
-      Argc--;\r
-      Argv++;\r
-    } else if (strcmpi (Argv[0], "-v") == 0) {\r
-      //\r
-      // OPTION: -v       verbose\r
-      //\r
-      mGlobals.Verbose = TRUE;\r
-    } else if (strcmpi (Argv[0], "-h") == 0) {\r
-      //\r
-      // OPTION: -h      help\r
-      //\r
-      PrintUsage ();\r
-      return STATUS_ERROR;\r
-    } else if (strcmpi (Argv[0], "-?") == 0) {\r
-      //\r
-      // OPTION:  -?      help\r
-      //\r
-      PrintUsage ();\r
-      return STATUS_ERROR;\r
-    } else {\r
-      Error (NULL, 0, 0, Argv[0], "unrecognized option");\r
-      PrintUsage ();\r
-      return STATUS_ERROR;\r
-    }\r
-\r
-    Argv++;\r
-    Argc--;\r
-  }\r
-  //\r
-  // Must have at least specified the package file name\r
-  //\r
-  if (mGlobals.PrimaryPackagePath[0] == 0) {\r
-    Error (NULL, 0, 0, "must specify primary package file", NULL);\r
-    return STATUS_ERROR;\r
-  }\r
-\r
-  return STATUS_SUCCESS;\r
-}\r
diff --git a/Tools/CodeTools/TianoTools/GenFfsFile/GenFfsFile.h b/Tools/CodeTools/TianoTools/GenFfsFile/GenFfsFile.h
deleted file mode 100644 (file)
index f5bc718..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2004, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-Module Name:\r
-\r
-  GenFfsFile.h \r
-\r
-Abstract:\r
-\r
-  Header file for GenFfsFile.\r
-\r
---*/\r
-\r
-//\r
-// Module Coded to Tiano Coding Conventions\r
-//\r
-#ifndef _EFI_GEN_FFSFILE_H\r
-#define _EFI_GEN_FFSFILE_H\r
-\r
-//\r
-// External Files Referenced\r
-//\r
-#include <Common/UefiBaseTypes.h>\r
-#include <Common/FirmwareVolumeImageFormat.h>\r
-\r
-#include "MyAlloc.h"\r
-\r
-#endif\r
diff --git a/Tools/CodeTools/TianoTools/GenFfsFile/SimpleFileParsing.c b/Tools/CodeTools/TianoTools/GenFfsFile/SimpleFileParsing.c
deleted file mode 100644 (file)
index 5fa5a22..0000000
+++ /dev/null
@@ -1,969 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2004, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-Module Name:\r
-\r
-  SimpleFileParsing.c  \r
-\r
-Abstract:\r
-\r
-  Generic but simple file parsing routines.\r
-\r
---*/\r
-\r
-#include <stdio.h>\r
-#include <string.h>\r
-#include <stdlib.h>\r
-#include <ctype.h>\r
-\r
-#include <Common/UefiBaseTypes.h>\r
-\r
-#include "EfiUtilityMsgs.h"\r
-#include "SimpleFileParsing.h"\r
-\r
-#define MAX_PATH                    255\r
-#define MAX_NEST_DEPTH              20  // just in case we get in an endless loop.\r
-#define MAX_STRING_IDENTIFIER_NAME  100 // number of wchars\r
-#define MAX_LINE_LEN                400\r
-\r
-#define T_CHAR_SPACE                ' '\r
-#define T_CHAR_NULL                 0\r
-#define T_CHAR_CR                   '\r'\r
-#define T_CHAR_TAB                  '\t'\r
-#define T_CHAR_LF                   '\n'\r
-#define T_CHAR_SLASH                '/'\r
-#define T_CHAR_BACKSLASH            '\\'\r
-#define T_CHAR_DOUBLE_QUOTE         '"'\r
-#define T_CHAR_LC_X                 'x'\r
-#define T_CHAR_0                    '0'\r
-\r
-//\r
-// We keep a linked list of these for the source files we process\r
-//\r
-typedef struct _SOURCE_FILE {\r
-  FILE                *Fptr;\r
-  T_CHAR              *FileBuffer;\r
-  T_CHAR              *FileBufferPtr;\r
-  UINT32              FileSize;\r
-  INT8                FileName[MAX_PATH];\r
-  UINT32              LineNum;\r
-  BOOLEAN             EndOfFile;\r
-  BOOLEAN             SkipToHash;\r
-  struct _SOURCE_FILE *Previous;\r
-  struct _SOURCE_FILE *Next;\r
-  T_CHAR              ControlCharacter;\r
-} SOURCE_FILE;\r
-\r
-//\r
-// Here's all our module globals.\r
-//\r
-static struct {\r
-  SOURCE_FILE SourceFile;\r
-  BOOLEAN     Verbose;\r
-} mGlobals;\r
-\r
-static\r
-UINT32\r
-t_strcmp (\r
-  T_CHAR *Buffer,\r
-  T_CHAR *Str\r
-  );\r
-\r
-static\r
-UINT32\r
-t_strncmp (\r
-  T_CHAR *Str1,\r
-  T_CHAR *Str2,\r
-  UINT32 Len\r
-  );\r
-\r
-static\r
-UINT32\r
-t_strlen (\r
-  T_CHAR *Str\r
-  );\r
-\r
-static\r
-void\r
-RewindFile (\r
-  SOURCE_FILE *SourceFile\r
-  );\r
-\r
-static\r
-BOOLEAN\r
-SkipTo (\r
-  SOURCE_FILE *SourceFile,\r
-  T_CHAR      TChar,\r
-  BOOLEAN     StopAfterNewline\r
-  );\r
-\r
-static\r
-BOOLEAN\r
-IsWhiteSpace (\r
-  SOURCE_FILE *SourceFile\r
-  );\r
-\r
-static\r
-UINT32\r
-SkipWhiteSpace (\r
-  SOURCE_FILE *SourceFile\r
-  );\r
-\r
-static\r
-BOOLEAN\r
-EndOfFile (\r
-  SOURCE_FILE *SourceFile\r
-  );\r
-\r
-static\r
-void\r
-PreprocessFile (\r
-  SOURCE_FILE *SourceFile\r
-  );\r
-\r
-//\r
-// static\r
-// T_CHAR *\r
-// GetQuotedString (\r
-//  SOURCE_FILE *SourceFile,\r
-//  BOOLEAN     Optional\r
-//  );\r
-//\r
-static\r
-T_CHAR  *\r
-t_strcpy (\r
-  T_CHAR *Dest,\r
-  T_CHAR *Src\r
-  );\r
-\r
-static\r
-STATUS\r
-ProcessIncludeFile (\r
-  SOURCE_FILE *SourceFile,\r
-  SOURCE_FILE *ParentSourceFile\r
-  );\r
-\r
-static\r
-STATUS\r
-ParseFile (\r
-  SOURCE_FILE *SourceFile\r
-  );\r
-\r
-static\r
-FILE    *\r
-FindFile (\r
-  IN INT8     *FileName,\r
-  OUT INT8    *FoundFileName,\r
-  IN UINT32   FoundFileNameLen\r
-  );\r
-\r
-static\r
-STATUS\r
-ProcessFile (\r
-  SOURCE_FILE *SourceFile\r
-  );\r
-\r
-STATUS\r
-SFPInit (\r
-  VOID\r
-  )\r
-{\r
-  memset ((void *) &mGlobals, 0, sizeof (mGlobals));\r
-  return STATUS_SUCCESS;\r
-}\r
-\r
-UINT32\r
-SFPGetLineNumber (\r
-  VOID\r
-  )\r
-{\r
-  return mGlobals.SourceFile.LineNum;\r
-}\r
-\r
-/*++\r
-\r
-Routine Description:\r
-  Return the line number of the file we're parsing. Used\r
-  for error reporting purposes.\r
-\r
-Arguments:\r
-  None.\r
-\r
-Returns:\r
-  The line number, or 0 if no file is being processed\r
-\r
---*/\r
-T_CHAR *\r
-SFPGetFileName (\r
-  VOID\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Return the name of the file we're parsing. Used\r
-  for error reporting purposes.\r
-\r
-Arguments:\r
-  None.\r
-\r
-Returns:\r
-  A pointer to the file name. Null if no file is being\r
-  processed.\r
-\r
---*/\r
-{\r
-  if (mGlobals.SourceFile.FileName[0]) {\r
-    return mGlobals.SourceFile.FileName;\r
-  }\r
-\r
-  return NULL;\r
-}\r
-\r
-STATUS\r
-SFPOpenFile (\r
-  IN INT8   *FileName\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Open a file for parsing.\r
-\r
-Arguments:\r
-  FileName  - name of the file to parse\r
-\r
-Returns:\r
-  \r
-\r
---*/\r
-{\r
-  STATUS  Status;\r
-  t_strcpy (mGlobals.SourceFile.FileName, FileName);\r
-  Status = ProcessIncludeFile (&mGlobals.SourceFile, NULL);\r
-  return Status;\r
-}\r
-\r
-BOOLEAN\r
-SFPIsToken (\r
-  T_CHAR *Str\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Check to see if the specified token is found at\r
-  the current position in the input file.\r
-\r
-Arguments:\r
-  Str - the token to look for\r
-\r
-Returns:\r
-  TRUE - the token is next\r
-  FALSE - the token is not next\r
-\r
-Notes:\r
-  We do a simple string comparison on this function. It is\r
-  the responsibility of the caller to ensure that the token\r
-  is not a subset of some other token.\r
-\r
-  The file pointer is advanced past the token in the input file.\r
-\r
---*/\r
-{\r
-  UINT32  Len;\r
-  SkipWhiteSpace (&mGlobals.SourceFile);\r
-\r
-  if ((Len = t_strcmp (mGlobals.SourceFile.FileBufferPtr, Str)) > 0) {\r
-    mGlobals.SourceFile.FileBufferPtr += Len;\r
-    return TRUE;\r
-  }\r
-\r
-  return FALSE;\r
-\r
-}\r
-\r
-BOOLEAN\r
-SFPGetNextToken (\r
-  T_CHAR *Str,\r
-  UINT32 Len\r
-  )\r
-{\r
-  UINT32  Index;\r
-  SkipWhiteSpace (&mGlobals.SourceFile);\r
-  Index = 0;\r
-  while (!EndOfFile (&mGlobals.SourceFile) && (Index < Len)) {\r
-    if (IsWhiteSpace (&mGlobals.SourceFile)) {\r
-      if (Index > 0) {\r
-        Str[Index] = 0;\r
-        return TRUE;\r
-      }\r
-\r
-      return FALSE;\r
-    } else {\r
-      Str[Index] = mGlobals.SourceFile.FileBufferPtr[0];\r
-      mGlobals.SourceFile.FileBufferPtr++;\r
-      Index++;\r
-    }\r
-  }\r
-\r
-  return FALSE;\r
-}\r
-\r
-BOOLEAN\r
-SFPSkipToToken (\r
-  T_CHAR *Str\r
-  )\r
-{\r
-  UINT32  Len;\r
-  T_CHAR  *SavePos;\r
-  Len     = t_strlen (Str);\r
-  SavePos = mGlobals.SourceFile.FileBufferPtr;\r
-  SkipWhiteSpace (&mGlobals.SourceFile);\r
-  while (!EndOfFile (&mGlobals.SourceFile)) {\r
-    if (t_strncmp (Str, mGlobals.SourceFile.FileBufferPtr, Len) == 0) {\r
-      mGlobals.SourceFile.FileBufferPtr += Len;\r
-      return TRUE;\r
-    }\r
-\r
-    mGlobals.SourceFile.FileBufferPtr++;\r
-    SkipWhiteSpace (&mGlobals.SourceFile);\r
-  }\r
-\r
-  mGlobals.SourceFile.FileBufferPtr = SavePos;\r
-  return FALSE;\r
-}\r
-\r
-BOOLEAN\r
-SFPGetNumber (\r
-  UINT32   *Value\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Check the token at the current file position for a numeric value.\r
-  May be either decimal or hex.\r
-\r
-Arguments:\r
-  Value  - pointer where to store the value\r
-\r
-Returns:\r
-  FALSE    - current token is not a number\r
-  TRUE     - current token is a number\r
-\r
---*/\r
-{\r
-  //\r
-  //  UINT32 Len;\r
-  //\r
-  SkipWhiteSpace (&mGlobals.SourceFile);\r
-  if (EndOfFile (&mGlobals.SourceFile)) {\r
-    return FALSE;\r
-  }\r
-\r
-  if (isdigit (mGlobals.SourceFile.FileBufferPtr[0])) {\r
-    //\r
-    // Check for hex value\r
-    //\r
-    if ((mGlobals.SourceFile.FileBufferPtr[0] == T_CHAR_0) && (mGlobals.SourceFile.FileBufferPtr[1] == T_CHAR_LC_X)) {\r
-      if (!isxdigit (mGlobals.SourceFile.FileBufferPtr[2])) {\r
-        return FALSE;\r
-      }\r
-\r
-      mGlobals.SourceFile.FileBufferPtr += 2;\r
-      sscanf (mGlobals.SourceFile.FileBufferPtr, "%x", Value);\r
-      while (isxdigit (mGlobals.SourceFile.FileBufferPtr[0])) {\r
-        mGlobals.SourceFile.FileBufferPtr++;\r
-      }\r
-\r
-      return TRUE;\r
-    } else {\r
-      *Value = atoi (mGlobals.SourceFile.FileBufferPtr);\r
-      while (isdigit (mGlobals.SourceFile.FileBufferPtr[0])) {\r
-        mGlobals.SourceFile.FileBufferPtr++;\r
-      }\r
-\r
-      return TRUE;\r
-    }\r
-  } else {\r
-    return FALSE;\r
-  }\r
-}\r
-\r
-STATUS\r
-SFPCloseFile (\r
-  VOID\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Close the file being parsed.\r
-\r
-Arguments:\r
-  None.\r
-\r
-Returns:\r
-  STATUS_SUCCESS - the file was closed \r
-  STATUS_ERROR   - no file is currently open\r
-\r
---*/\r
-{\r
-  if (mGlobals.SourceFile.FileBuffer != NULL) {\r
-    free (mGlobals.SourceFile.FileBuffer);\r
-    memset (&mGlobals.SourceFile, 0, sizeof (mGlobals.SourceFile));\r
-    return STATUS_SUCCESS;\r
-  }\r
-\r
-  return STATUS_ERROR;\r
-}\r
-\r
-static\r
-STATUS\r
-ProcessIncludeFile (\r
-  SOURCE_FILE *SourceFile,\r
-  SOURCE_FILE *ParentSourceFile\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Given a source file, open the file and parse it\r
-  \r
-Arguments:\r
-\r
-  SourceFile        - name of file to parse\r
-  ParentSourceFile  - for error reporting purposes, the file that #included SourceFile.\r
-\r
-Returns:\r
-\r
-  Standard status.\r
-  \r
---*/\r
-{\r
-  static UINT32 NestDepth = 0;\r
-  INT8          FoundFileName[MAX_PATH];\r
-  STATUS        Status;\r
-\r
-  Status = STATUS_SUCCESS;\r
-  NestDepth++;\r
-  //\r
-  // Print the file being processed. Indent so you can tell the include nesting\r
-  // depth.\r
-  //\r
-  if (mGlobals.Verbose) {\r
-    fprintf (stdout, "%*cProcessing file '%s'\n", NestDepth * 2, ' ', SourceFile->FileName);\r
-  }\r
-\r
-  //\r
-  // Make sure we didn't exceed our maximum nesting depth\r
-  //\r
-  if (NestDepth > MAX_NEST_DEPTH) {\r
-    Error (NULL, 0, 0, SourceFile->FileName, "max nesting depth (%d) exceeded", NestDepth);\r
-    Status = STATUS_ERROR;\r
-    goto Finish;\r
-  }\r
-  //\r
-  // Try to open the file locally, and if that fails try along our include paths.\r
-  //\r
-  strcpy (FoundFileName, SourceFile->FileName);\r
-  if ((SourceFile->Fptr = fopen (FoundFileName, "r")) == NULL) {\r
-    //\r
-    // Try to find it among the paths if it has a parent (that is, it is included\r
-    // by someone else).\r
-    //\r
-    Error (NULL, 0, 0, SourceFile->FileName, "file not found");\r
-    return STATUS_ERROR;\r
-  }\r
-  //\r
-  // Process the file found\r
-  //\r
-  ProcessFile (SourceFile);\r
-Finish:\r
-  //\r
-  // Close open files and return status\r
-  //\r
-  if (SourceFile->Fptr != NULL) {\r
-    fclose (SourceFile->Fptr);\r
-    SourceFile->Fptr = NULL;\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-static\r
-STATUS\r
-ProcessFile (\r
-  SOURCE_FILE *SourceFile\r
-  )\r
-{\r
-  //\r
-  // Get the file size, and then read the entire thing into memory.\r
-  // Allocate space for a terminator character.\r
-  //\r
-  fseek (SourceFile->Fptr, 0, SEEK_END);\r
-  SourceFile->FileSize = ftell (SourceFile->Fptr);\r
-  fseek (SourceFile->Fptr, 0, SEEK_SET);\r
-  SourceFile->FileBuffer = (T_CHAR *) malloc (SourceFile->FileSize + sizeof (T_CHAR));\r
-  if (SourceFile->FileBuffer == NULL) {\r
-    Error (NULL, 0, 0, "memory allocation failure", NULL);\r
-    return STATUS_ERROR;\r
-  }\r
-\r
-  fread ((VOID *) SourceFile->FileBuffer, SourceFile->FileSize, 1, SourceFile->Fptr);\r
-  SourceFile->FileBuffer[(SourceFile->FileSize / sizeof (T_CHAR))] = T_CHAR_NULL;\r
-  //\r
-  // Pre-process the file to replace comments with spaces\r
-  //\r
-  PreprocessFile (SourceFile);\r
-  SourceFile->LineNum = 1;\r
-  return STATUS_SUCCESS;\r
-}\r
-\r
-static\r
-void\r
-PreprocessFile (\r
-  SOURCE_FILE *SourceFile\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Preprocess a file to replace all carriage returns with NULLs so\r
-  we can print lines from the file to the screen.\r
-  \r
-Arguments:\r
-  SourceFile - structure that we use to keep track of an input file.\r
-\r
-Returns:\r
-  Nothing.\r
-  \r
---*/\r
-{\r
-  BOOLEAN InComment;\r
-\r
-  RewindFile (SourceFile);\r
-  InComment = FALSE;\r
-  while (!EndOfFile (SourceFile)) {\r
-    //\r
-    // If a line-feed, then no longer in a comment\r
-    //\r
-    if (SourceFile->FileBufferPtr[0] == T_CHAR_LF) {\r
-      SourceFile->FileBufferPtr++;\r
-      SourceFile->LineNum++;\r
-      InComment = 0;\r
-    } else if (SourceFile->FileBufferPtr[0] == T_CHAR_CR) {\r
-      //\r
-      // Replace all carriage returns with a NULL so we can print stuff\r
-      //\r
-      SourceFile->FileBufferPtr[0] = 0;\r
-      SourceFile->FileBufferPtr++;\r
-    } else if (InComment) {\r
-      SourceFile->FileBufferPtr[0] = T_CHAR_SPACE;\r
-      SourceFile->FileBufferPtr++;\r
-    } else if ((SourceFile->FileBufferPtr[0] == T_CHAR_SLASH) && (SourceFile->FileBufferPtr[1] == T_CHAR_SLASH)) {\r
-      SourceFile->FileBufferPtr += 2;\r
-      InComment = TRUE;\r
-    } else {\r
-      SourceFile->FileBufferPtr++;\r
-    }\r
-  }\r
-  //\r
-  // Could check for end-of-file and still in a comment, but\r
-  // should not be necessary. So just restore the file pointers.\r
-  //\r
-  RewindFile (SourceFile);\r
-}\r
-\r
-#if 0\r
-static\r
-T_CHAR *\r
-GetQuotedString (\r
-  SOURCE_FILE *SourceFile,\r
-  BOOLEAN     Optional\r
-  )\r
-{\r
-  T_CHAR  *String;\r
-  T_CHAR  *Start;\r
-  T_CHAR  *Ptr;\r
-  UINT32  Len;\r
-  BOOLEAN PreviousBackslash;\r
-\r
-  if (SourceFile->FileBufferPtr[0] != T_CHAR_DOUBLE_QUOTE) {\r
-    if (!Optional) {\r
-      Error (SourceFile->FileName, SourceFile->LineNum, 0, "expected quoted string", "%S", SourceFile->FileBufferPtr);\r
-    }\r
-\r
-    return NULL;\r
-  }\r
-\r
-  Len = 0;\r
-  SourceFile->FileBufferPtr++;\r
-  Start             = Ptr = SourceFile->FileBufferPtr;\r
-  PreviousBackslash = FALSE;\r
-  while (!EndOfFile (SourceFile)) {\r
-    if ((SourceFile->FileBufferPtr[0] == T_CHAR_DOUBLE_QUOTE) && (!PreviousBackslash)) {\r
-      break;\r
-    } else if (SourceFile->FileBufferPtr[0] == T_CHAR_CR) {\r
-      Warning (SourceFile->FileName, SourceFile->LineNum, 0, "carriage return found in quoted string", "%S", Start);\r
-      PreviousBackslash = FALSE;\r
-    } else if (SourceFile->FileBufferPtr[0] == T_CHAR_BACKSLASH) {\r
-      PreviousBackslash = TRUE;\r
-    } else {\r
-      PreviousBackslash = FALSE;\r
-    }\r
-\r
-    SourceFile->FileBufferPtr++;\r
-    Len++;\r
-  }\r
-\r
-  if (SourceFile->FileBufferPtr[0] != T_CHAR_DOUBLE_QUOTE) {\r
-    Warning (SourceFile->FileName, SourceFile->LineNum, 0, "missing closing quote on string", "%S", Start);\r
-  } else {\r
-    SourceFile->FileBufferPtr++;\r
-  }\r
-  //\r
-  // Now allocate memory for the string and save it off\r
-  //\r
-  String = (T_CHAR *) malloc ((Len + 1) * sizeof (T_CHAR));\r
-  if (String == NULL) {\r
-    Error (NULL, 0, 0, "memory allocation failed", NULL);\r
-    return NULL;\r
-  }\r
-  //\r
-  // Copy the string from the file buffer to the local copy.\r
-  // We do no reformatting of it whatsoever at this point.\r
-  //\r
-  Ptr = String;\r
-  while (Len > 0) {\r
-    *Ptr = *Start;\r
-    Start++;\r
-    Ptr++;\r
-    Len--;\r
-  }\r
-\r
-  *Ptr = 0;\r
-  return String;\r
-}\r
-#endif\r
-static\r
-BOOLEAN\r
-EndOfFile (\r
-  SOURCE_FILE *SourceFile\r
-  )\r
-{\r
-  //\r
-  // The file buffer pointer will typically get updated before the End-of-file flag in the\r
-  // source file structure, so check it first.\r
-  //\r
-  if (SourceFile->FileBufferPtr >= SourceFile->FileBuffer + SourceFile->FileSize / sizeof (T_CHAR)) {\r
-    SourceFile->EndOfFile = TRUE;\r
-    return TRUE;\r
-  }\r
-\r
-  if (SourceFile->EndOfFile) {\r
-    return TRUE;\r
-  }\r
-\r
-  return FALSE;\r
-}\r
-\r
-#if 0\r
-static\r
-void\r
-ProcessTokenInclude (\r
-  SOURCE_FILE *SourceFile\r
-  )\r
-{\r
-  INT8        IncludeFileName[MAX_PATH];\r
-  INT8        *To;\r
-  UINT32      Len;\r
-  BOOLEAN     ReportedError;\r
-  SOURCE_FILE IncludedSourceFile;\r
-\r
-  ReportedError = FALSE;\r
-  if (SkipWhiteSpace (SourceFile) == 0) {\r
-    Warning (SourceFile->FileName, SourceFile->LineNum, 0, "expected whitespace following #include keyword", NULL);\r
-  }\r
-  //\r
-  // Should be quoted file name\r
-  //\r
-  if (SourceFile->FileBufferPtr[0] != T_CHAR_DOUBLE_QUOTE) {\r
-    Error (SourceFile->FileName, SourceFile->LineNum, 0, "expected quoted include file name", NULL);\r
-    goto FailDone;\r
-  }\r
-\r
-  SourceFile->FileBufferPtr++;\r
-  //\r
-  // Copy the filename as ascii to our local string\r
-  //\r
-  To  = IncludeFileName;\r
-  Len = 0;\r
-  while (!EndOfFile (SourceFile)) {\r
-    if ((SourceFile->FileBufferPtr[0] == T_CHAR_CR) || (SourceFile->FileBufferPtr[0] == T_CHAR_LF)) {\r
-      Error (SourceFile->FileName, SourceFile->LineNum, 0, "end-of-line found in quoted include file name", NULL);\r
-      goto FailDone;\r
-    }\r
-\r
-    if (SourceFile->FileBufferPtr[0] == T_CHAR_DOUBLE_QUOTE) {\r
-      SourceFile->FileBufferPtr++;\r
-      break;\r
-    }\r
-    //\r
-    // If too long, then report the error once and process until the closing quote\r
-    //\r
-    Len++;\r
-    if (!ReportedError && (Len >= sizeof (IncludeFileName))) {\r
-      Error (SourceFile->FileName, SourceFile->LineNum, 0, "length of include file name exceeds limit", NULL);\r
-      ReportedError = TRUE;\r
-    }\r
-\r
-    if (!ReportedError) {\r
-      //\r
-      // *To = UNICODE_TO_ASCII(SourceFile->FileBufferPtr[0]);\r
-      //\r
-      *To = (T_CHAR) SourceFile->FileBufferPtr[0];\r
-      To++;\r
-    }\r
-\r
-    SourceFile->FileBufferPtr++;\r
-  }\r
-\r
-  if (!ReportedError) {\r
-    *To = 0;\r
-    memset ((char *) &IncludedSourceFile, 0, sizeof (SOURCE_FILE));\r
-    strcpy (IncludedSourceFile.FileName, IncludeFileName);\r
-    //\r
-    // IncludedSourceFile.ControlCharacter = DEFAULT_CONTROL_CHARACTER;\r
-    //\r
-    ProcessIncludeFile (&IncludedSourceFile, SourceFile);\r
-    //\r
-    // printf ("including file '%s'\n", IncludeFileName);\r
-    //\r
-  }\r
-\r
-  return ;\r
-FailDone:\r
-  //\r
-  // Error recovery -- skip to next #\r
-  //\r
-  SourceFile->SkipToHash = TRUE;\r
-}\r
-#endif\r
-static\r
-BOOLEAN\r
-IsWhiteSpace (\r
-  SOURCE_FILE *SourceFile\r
-  )\r
-{\r
-  switch (*SourceFile->FileBufferPtr) {\r
-  case T_CHAR_NULL:\r
-  case T_CHAR_CR:\r
-  case T_CHAR_SPACE:\r
-  case T_CHAR_TAB:\r
-  case T_CHAR_LF:\r
-    return TRUE;\r
-\r
-  default:\r
-    return FALSE;\r
-  }\r
-}\r
-\r
-UINT32\r
-SkipWhiteSpace (\r
-  SOURCE_FILE *SourceFile\r
-  )\r
-{\r
-  UINT32  Count;\r
-\r
-  Count = 0;\r
-  while (!EndOfFile (SourceFile)) {\r
-    Count++;\r
-    switch (*SourceFile->FileBufferPtr) {\r
-    case T_CHAR_NULL:\r
-    case T_CHAR_CR:\r
-    case T_CHAR_SPACE:\r
-    case T_CHAR_TAB:\r
-      SourceFile->FileBufferPtr++;\r
-      break;\r
-\r
-    case T_CHAR_LF:\r
-      SourceFile->FileBufferPtr++;\r
-      SourceFile->LineNum++;\r
-      if (mGlobals.Verbose) {\r
-        printf ("%d: %S\n", SourceFile->LineNum, SourceFile->FileBufferPtr);\r
-      }\r
-      break;\r
-\r
-    default:\r
-      return Count - 1;\r
-    }\r
-  }\r
-  //\r
-  // Some tokens require trailing whitespace. If we're at the end of the\r
-  // file, then we count that as well.\r
-  //\r
-  if ((Count == 0) && (EndOfFile (SourceFile))) {\r
-    Count++;\r
-  }\r
-\r
-  return Count;\r
-}\r
-\r
-static\r
-UINT32\r
-t_strcmp (\r
-  T_CHAR *Buffer,\r
-  T_CHAR *Str\r
-  )\r
-{\r
-  UINT32  Len;\r
-\r
-  Len = 0;\r
-  while (*Str == *Buffer) {\r
-    Buffer++;\r
-    Str++;\r
-    Len++;\r
-  }\r
-\r
-  if (*Str) {\r
-    return 0;\r
-  }\r
-\r
-  return Len;\r
-}\r
-\r
-static\r
-UINT32\r
-t_strlen (\r
-  T_CHAR *Str\r
-  )\r
-{\r
-  UINT32  Len;\r
-  Len = 0;\r
-  while (*Str) {\r
-    Len++;\r
-    Str++;\r
-  }\r
-\r
-  return Len;\r
-}\r
-\r
-static\r
-UINT32\r
-t_strncmp (\r
-  T_CHAR *Str1,\r
-  T_CHAR *Str2,\r
-  UINT32 Len\r
-  )\r
-{\r
-  while (Len > 0) {\r
-    if (*Str1 != *Str2) {\r
-      return Len;\r
-    }\r
-\r
-    Len--;\r
-    Str1++;\r
-    Str2++;\r
-  }\r
-\r
-  return 0;\r
-}\r
-\r
-static\r
-T_CHAR *\r
-t_strcpy (\r
-  T_CHAR *Dest,\r
-  T_CHAR *Src\r
-  )\r
-{\r
-  T_CHAR  *SaveDest;\r
-  SaveDest = Dest;\r
-  while (*Src) {\r
-    *Dest = *Src;\r
-    Dest++;\r
-    Src++;\r
-  }\r
-\r
-  *Dest = 0;\r
-  return SaveDest;\r
-}\r
-\r
-#if 0\r
-static\r
-BOOLEAN\r
-IsValidIdentifierChar (\r
-  INT8      Char,\r
-  BOOLEAN   FirstChar\r
-  )\r
-{\r
-  //\r
-  // If it's the first character of an identifier, then\r
-  // it must be one of [A-Za-z_].\r
-  //\r
-  if (FirstChar) {\r
-    if (isalpha (Char) || (Char == '_')) {\r
-      return TRUE;\r
-    }\r
-  } else {\r
-    //\r
-    // If it's not the first character, then it can\r
-    // be one of [A-Za-z_0-9]\r
-    //\r
-    if (isalnum (Char) || (Char == '_')) {\r
-      return TRUE;\r
-    }\r
-  }\r
-\r
-  return FALSE;\r
-}\r
-#endif\r
-static\r
-void\r
-RewindFile (\r
-  SOURCE_FILE *SourceFile\r
-  )\r
-{\r
-  SourceFile->LineNum       = 1;\r
-  SourceFile->FileBufferPtr = SourceFile->FileBuffer;\r
-  SourceFile->EndOfFile     = 0;\r
-}\r
-\r
-#if 0\r
-static\r
-BOOLEAN\r
-SkipTo (\r
-  SOURCE_FILE  *SourceFile,\r
-  T_CHAR       TChar,\r
-  BOOLEAN      StopAfterNewline\r
-  )\r
-{\r
-  while (!EndOfFile (SourceFile)) {\r
-    //\r
-    // Check for the character of interest\r
-    //\r
-    if (SourceFile->FileBufferPtr[0] == TChar) {\r
-      return TRUE;\r
-    } else {\r
-      if (SourceFile->FileBufferPtr[0] == T_CHAR_LF) {\r
-        SourceFile->LineNum++;\r
-        if (StopAfterNewline) {\r
-          SourceFile->FileBufferPtr++;\r
-          if (SourceFile->FileBufferPtr[0] == 0) {\r
-            SourceFile->FileBufferPtr++;\r
-          }\r
-\r
-          return FALSE;\r
-        }\r
-      }\r
-\r
-      SourceFile->FileBufferPtr++;\r
-    }\r
-  }\r
-\r
-  return FALSE;\r
-}\r
-#endif\r
diff --git a/Tools/CodeTools/TianoTools/GenFfsFile/build.xml b/Tools/CodeTools/TianoTools/GenFfsFile/build.xml
deleted file mode 100644 (file)
index b7f8681..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-<?xml version="1.0" ?>\r
-<!--\r
-Copyright (c) 2006, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
--->\r
-<project default="GenTool" basedir=".">\r
-<!--\r
-    EDK GenFfsFile Tool\r
-  Copyright (c) 2006, Intel Corporation\r
--->\r
-  <property name="ToolName" value="GenFfsFile"/>\r
-  <property name="FileSet" value="GenFfsFile.c"/>\r
-\r
-  <taskdef resource="cpptasks.tasks"/>\r
-  <typedef resource="cpptasks.types"/>\r
-  <taskdef resource="net/sf/antcontrib/antlib.xml"/>\r
-\r
-  <property name="LINK_OUTPUT_TYPE" value="static"/>\r
-  <property name="BUILD_DIR" value="${PACKAGE_DIR}/${ToolName}/tmp"/>\r
-\r
-  <target name="GenTool" depends="init, Tool">\r
-    <echo message="The EDK Tool: ${ToolName} build has completed!"/>\r
-  </target>\r
-\r
-  <target name="init">\r
-    <echo message="Building the EDK Tool: ${ToolName}"/>\r
-    <mkdir dir="${BUILD_DIR}"/>\r
-  </target>\r
-\r
-  <target name="Tool" depends="init">\r
-    <cc name="${ToolChain}" objdir="${BUILD_DIR}" \r
-        outfile="${BIN_DIR}/${ToolName}"\r
-        outtype="executable"\r
-        debug="true"\r
-        optimize="speed">\r
-      <compilerarg value="${ExtraArgus}" if="ExtraArgus" />\r
-\r
-      <fileset dir="${basedir}/${ToolName}" \r
-        includes="${FileSet}" \r
-        defaultexcludes="TRUE" \r
-        excludes="*.xml *.inf"/>\r
-\r
-      <includepath path="${PACKAGE_DIR}/Include"/>\r
-      <includepath path="${PACKAGE_DIR}/Include/${HostArch}"/>\r
-      <includepath path="${PACKAGE_DIR}/Common"/>\r
-      <libset dir="${LIB_DIR}" libs="CommonTools CustomizedCompress"/>\r
-    </cc>\r
-  </target>\r
-\r
-  <target name="clean">\r
-    <echo message="Removing Intermediate Files Only"/>  \r
-    <delete>\r
-      <fileset dir="${BUILD_DIR}" includes="*.obj"/>\r
-    </delete>\r
-  </target>\r
-\r
-  <target name="cleanall">\r
-    <echo message="Removing Object Files and the Executable: ${ToolName}${ext_exe}"/>  \r
-    <delete failonerror="false" quiet="true" includeEmptyDirs="true">\r
-      <fileset dir="${BUILD_DIR}"/>\r
-      <fileset file="${BIN_DIR}/${ToolName}${ext_exe}"/>\r
-    </delete>\r
-  </target>\r
-\r
-</project>\r
diff --git a/Tools/CodeTools/TianoTools/GenFvImage/Ebc/PeCoffLoaderEx.c b/Tools/CodeTools/TianoTools/GenFvImage/Ebc/PeCoffLoaderEx.c
deleted file mode 100644 (file)
index e8cf8b6..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2004, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-Module Name:\r
-\r
-    PeCoffLoaderEx.c\r
-\r
-Abstract:\r
-\r
-    EBC Specific relocation fixups\r
-\r
-Revision History\r
-\r
---*/\r
-\r
-\r
-\r
-\r
-RETURN_STATUS\r
-PeCoffLoaderRelocateImageEx (\r
-  IN UINT16      *Reloc,\r
-  IN OUT CHAR8   *Fixup,\r
-  IN OUT CHAR8   **FixupData,\r
-  IN UINT64      Adjust\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Performs an IA-32 specific relocation fixup\r
-\r
-Arguments:\r
-\r
-  Reloc      - Pointer to the relocation record\r
-\r
-  Fixup      - Pointer to the address to fix up\r
-\r
-  FixupData  - Pointer to a buffer to log the fixups\r
-\r
-  Adjust     - The offset to adjust the fixup\r
-\r
-Returns:\r
-\r
-  EFI_UNSUPPORTED   - Unsupported now\r
-\r
---*/\r
-{\r
-  return RETURN_UNSUPPORTED;\r
-}\r
diff --git a/Tools/CodeTools/TianoTools/GenFvImage/GenFvImageExe.c b/Tools/CodeTools/TianoTools/GenFvImage/GenFvImageExe.c
deleted file mode 100644 (file)
index d0117b8..0000000
+++ /dev/null
@@ -1,299 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2004, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-Module Name:\r
-\r
-  GenFvImageExe.c\r
-\r
-Abstract:\r
-\r
-  This contains all code necessary to build the GenFvImage.exe utility.       \r
-  This utility relies heavily on the GenFvImage Lib.  Definitions for both\r
-  can be found in the Tiano Firmware Volume Generation Utility \r
-  Specification, review draft.\r
-\r
---*/\r
-\r
-//\r
-// File included in build\r
-//\r
-#include "GenFvImageExe.h"\r
-#include "CommonLib.h"\r
-#include "EfiUtilityMsgs.h"\r
-\r
-VOID\r
-PrintUtilityInfo (\r
-  VOID\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Displays the standard utility information to SDTOUT\r
-\r
-Arguments:\r
-\r
-  None\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-{\r
-  printf (\r
-    "%s - Tiano Firmware Volume Generation Utility."" Version %i.%i\n\n",\r
-    UTILITY_NAME,\r
-    UTILITY_MAJOR_VERSION,\r
-    UTILITY_MINOR_VERSION\r
-    );\r
-}\r
-\r
-VOID\r
-PrintUsage (\r
-  VOID\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Displays the utility usage syntax to STDOUT\r
-\r
-Arguments:\r
-\r
-  None\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-{\r
-  printf ("Usage: %s -I FvInfFileName\n", UTILITY_NAME);\r
-  printf ("  Where:\n");\r
-  printf ("\tFvInfFileName is the name of the image description file.\n\n");\r
-}\r
-\r
-int\r
-main (\r
-  IN INTN   argc,\r
-  IN CHAR8  **argv\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  This utility uses GenFvImage.Lib to build a firmware volume image.\r
-\r
-Arguments:\r
-\r
-  FvInfFileName      The name of an FV image description file.\r
-\r
-  Arguments come in pair in any order.\r
-    -I FvInfFileName \r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS            No error conditions detected.\r
-  EFI_INVALID_PARAMETER  One or more of the input parameters is invalid.\r
-  EFI_OUT_OF_RESOURCES   A resource required by the utility was unavailable.  \r
-                         Most commonly this will be memory allocation \r
-                         or file creation.\r
-  EFI_LOAD_ERROR         GenFvImage.lib could not be loaded.\r
-  EFI_ABORTED            Error executing the GenFvImage lib.\r
-\r
---*/\r
-{\r
-  EFI_STATUS  Status;\r
-  CHAR8       InfFileName[_MAX_PATH];\r
-  CHAR8       *InfFileImage;\r
-  UINTN       InfFileSize;\r
-  UINT8       *FvImage;\r
-  UINTN       FvImageSize;\r
-  UINT8       Index;\r
-  CHAR8       FvFileNameBuffer[_MAX_PATH];\r
-  CHAR8       *FvFileName;\r
-  FILE        *FvFile;\r
-  FILE        *SymFile;\r
-  CHAR8       SymFileNameBuffer[_MAX_PATH];\r
-  CHAR8       *SymFileName;\r
-  UINT8       *SymImage;\r
-  UINTN       SymImageSize;\r
-  CHAR8       *CurrentSymString;\r
-\r
-  FvFileName  = FvFileNameBuffer;\r
-  SymFileName = SymFileNameBuffer;\r
-\r
-  SetUtilityName (UTILITY_NAME);\r
-  //\r
-  // Display utility information\r
-  //\r
-  PrintUtilityInfo ();\r
-\r
-  //\r
-  // Verify the correct number of arguments\r
-  //\r
-  if (argc != MAX_ARGS) {\r
-    Error (NULL, 0, 0, "invalid number of input parameters specified", NULL);\r
-    PrintUsage ();\r
-    return GetUtilityStatus ();\r
-  }\r
-  //\r
-  // Initialize variables\r
-  //\r
-  strcpy (InfFileName, "");\r
-\r
-  //\r
-  // Parse the command line arguments\r
-  //\r
-  for (Index = 1; Index < MAX_ARGS; Index += 2) {\r
-    //\r
-    // Make sure argument pair begin with - or /\r
-    //\r
-    if (argv[Index][0] != '-' && argv[Index][0] != '/') {\r
-      Error (NULL, 0, 0, argv[Index], "argument pair must begin with \"-\" or \"/\"");\r
-      PrintUsage ();\r
-      return GetUtilityStatus ();\r
-    }\r
-    //\r
-    // Make sure argument specifier is only one letter\r
-    //\r
-    if (argv[Index][2] != 0) {\r
-      Error (NULL, 0, 0, argv[Index], "unrecognized argument");\r
-      PrintUsage ();\r
-      return GetUtilityStatus ();\r
-    }\r
-    //\r
-    // Determine argument to read\r
-    //\r
-    switch (argv[Index][1]) {\r
-\r
-    case 'I':\r
-    case 'i':\r
-      if (strlen (InfFileName) == 0) {\r
-        strcpy (InfFileName, argv[Index + 1]);\r
-      } else {\r
-        Error (NULL, 0, 0, argv[Index + 1], "FvInfFileName may only be specified once");\r
-        PrintUsage ();\r
-        return GetUtilityStatus ();\r
-      }\r
-      break;\r
-\r
-    default:\r
-      Error (NULL, 0, 0, argv[Index], "unrecognized argument");\r
-      PrintUsage ();\r
-      return GetUtilityStatus ();\r
-      break;\r
-    }\r
-  }\r
-  //\r
-  // Read the INF file image\r
-  //\r
-  Status = GetFileImage (InfFileName, &InfFileImage, &InfFileSize);\r
-  if (EFI_ERROR (Status)) {\r
-    return STATUS_ERROR;\r
-  }\r
-  //\r
-  // Call the GenFvImage lib\r
-  //\r
-  Status = GenerateFvImage (\r
-            InfFileImage,\r
-            InfFileSize,\r
-            &FvImage,\r
-            &FvImageSize,\r
-            &FvFileName,\r
-            &SymImage,\r
-            &SymImageSize,\r
-            &SymFileName\r
-            );\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    switch (Status) {\r
-\r
-    case EFI_INVALID_PARAMETER:\r
-      Error (NULL, 0, 0, "invalid parameter passed to GenFvImage Lib", NULL);\r
-      return GetUtilityStatus ();\r
-      break;\r
-\r
-    case EFI_ABORTED:\r
-      Error (NULL, 0, 0, "error detected while creating the file image", NULL);\r
-      return GetUtilityStatus ();\r
-      break;\r
-\r
-    case EFI_OUT_OF_RESOURCES:\r
-      Error (NULL, 0, 0, "GenFvImage Lib could not allocate required resources", NULL);\r
-      return GetUtilityStatus ();\r
-      break;\r
-\r
-    case EFI_VOLUME_CORRUPTED:\r
-      Error (NULL, 0, 0, "no base address was specified, but the FV.INF included a PEI or BSF file", NULL);\r
-      return GetUtilityStatus ();\r
-      break;\r
-\r
-    case EFI_LOAD_ERROR:\r
-      Error (NULL, 0, 0, "could not load FV image generation library", NULL);\r
-      return GetUtilityStatus ();\r
-      break;\r
-\r
-    default:\r
-      Error (NULL, 0, 0, "GenFvImage Lib returned unknown status", "status returned = 0x%X", Status);\r
-      return GetUtilityStatus ();\r
-      break;\r
-    }\r
-  }\r
-  //\r
-  // Write file\r
-  //\r
-  FvFile = fopen (FvFileName, "wb");\r
-  if (FvFile == NULL) {\r
-    Error (NULL, 0, 0, FvFileName, "could not open output file");\r
-    free (FvImage);\r
-    free (SymImage);\r
-    return GetUtilityStatus ();\r
-  }\r
-\r
-  if (fwrite (FvImage, 1, FvImageSize, FvFile) != FvImageSize) {\r
-    Error (NULL, 0, 0, FvFileName, "failed to write to output file");\r
-    free (FvImage);\r
-    free (SymImage);\r
-    fclose (FvFile);\r
-    return GetUtilityStatus ();\r
-  }\r
-\r
-  fclose (FvFile);\r
-  free (FvImage);\r
-\r
-  //\r
-  // Write symbol file\r
-  //\r
-  if (strcmp (SymFileName, "")) {\r
-    SymFile = fopen (SymFileName, "wt");\r
-    if (SymFile == NULL) {\r
-      Error (NULL, 0, 0, SymFileName, "could not open output symbol file");\r
-      free (SymImage);\r
-      return GetUtilityStatus ();\r
-    }\r
-\r
-    fprintf (SymFile, "TEXTSYM format | V1.0\n");\r
-\r
-    CurrentSymString = SymImage;\r
-    while (((UINTN) CurrentSymString - (UINTN) SymImage) < SymImageSize) {\r
-      fprintf (SymFile, "%s", CurrentSymString);\r
-      CurrentSymString = (CHAR8 *) (((UINTN) CurrentSymString) + strlen (CurrentSymString) + 1);\r
-    }\r
-\r
-    fclose (SymFile);\r
-  }\r
-\r
-  free (SymImage);\r
-\r
-  return GetUtilityStatus ();\r
-}\r
diff --git a/Tools/CodeTools/TianoTools/GenFvImage/GenFvImageExe.h b/Tools/CodeTools/TianoTools/GenFvImage/GenFvImageExe.h
deleted file mode 100644 (file)
index 9b97935..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2004, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-Module Name:\r
-  \r
-  GenFvImageExe.h\r
-\r
-Abstract:\r
-\r
-  Definitions for the PeimFixup exe utility.\r
-\r
---*/\r
-\r
-//\r
-// Coded to Tiano Coding Standards\r
-//\r
-#ifndef _EFI_GEN_FV_IMAGE_EXE_H\r
-#define _EFI_GEN_FV_IMAGE_EXE_H\r
-\r
-#include <stdio.h>\r
-#include <string.h>\r
-#include <stdlib.h>\r
-#include "GenFvImageLib.h"\r
-\r
-//\r
-// Utility Name\r
-//\r
-#define UTILITY_NAME  "GenFvImage"\r
-\r
-//\r
-// Utility version information\r
-//\r
-#define UTILITY_MAJOR_VERSION 0\r
-#define UTILITY_MINOR_VERSION 1\r
-#define UTILITY_DATE          __DATE__\r
-\r
-//\r
-// The maximum number of arguments accepted from the command line.\r
-//\r
-#define MAX_ARGS  3\r
-\r
-//\r
-// The function that displays general utility information\r
-//\r
-VOID\r
-PrintUtilityInfo (\r
-  VOID\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  None\r
-\r
-Returns:\r
-\r
-  TODO: add return values\r
-\r
---*/\r
-;\r
-\r
-//\r
-// The function that displays the utility usage message.\r
-//\r
-VOID\r
-PrintUsage (\r
-  VOID\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  None\r
-\r
-Returns:\r
-\r
-  TODO: add return values\r
-\r
---*/\r
-;\r
-\r
-#endif\r
diff --git a/Tools/CodeTools/TianoTools/GenFvImage/GenFvImageLib.c b/Tools/CodeTools/TianoTools/GenFvImage/GenFvImageLib.c
deleted file mode 100644 (file)
index 888656a..0000000
+++ /dev/null
@@ -1,2727 +0,0 @@
-/*++\r
-i\r
-\r
-Copyright (c) 2004, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-Module Name:\r
-\r
-  GenFvImageLib.c\r
-\r
-Abstract:\r
-\r
-  This file contains functions required to generate a Firmware Volume.\r
-\r
---*/\r
-\r
-//\r
-// Include files\r
-//\r
-#ifdef __GNUC__\r
-#include <uuid/uuid.h>\r
-#include <sys/stat.h>\r
-#endif\r
-#include <string.h>\r
-#ifndef __GNUC__\r
-#include <io.h>\r
-#endif\r
-#include <assert.h>\r
-\r
-#include <Common/UefiBaseTypes.h>\r
-#include <Common/FirmwareVolumeImageFormat.h>\r
-#include <Common/Variable.h>\r
-#include <Common/WorkingBlockHeader.h>\r
-#include <Guid/FirmwareFileSystem.h>\r
-\r
-#include "GenFvImageLib.h"\r
-#include "GenFvImageLibInternal.h"\r
-#include "CommonLib.h"\r
-#include "Crc32.h"\r
-#include "EfiUtilityMsgs.h"\r
-#include "FvLib.h"\r
-#include "EfiCompress.h"\r
-#include "WinNtInclude.h"\r
-\r
-\r
-//\r
-// Local function prototypes\r
-//\r
-EFI_STATUS\r
-GetPe32Info (\r
-  IN UINT8                  *Pe32,\r
-  OUT UINT32                *EntryPoint,\r
-  OUT UINT32                *BaseOfCode,\r
-  OUT UINT16                *MachineType\r
-  );\r
-\r
-//\r
-// Local function implementations.\r
-//\r
-EFI_GUID  FfsGuid = EFI_FIRMWARE_FILE_SYSTEM_GUID;\r
-EFI_GUID  DefaultFvPadFileNameGuid = { 0x78f54d4, 0xcc22, 0x4048, 0x9e, 0x94, 0x87, 0x9c, 0x21, 0x4d, 0x56, 0x2f };\r
-\r
-//\r
-// This data array will be located at the base of the Firmware Volume Header (FVH)\r
-// in the boot block.  It must not exceed 14 bytes of code.  The last 2 bytes\r
-// will be used to keep the FVH checksum consistent.\r
-// This code will be run in response to a starutp IPI for HT-enabled systems.\r
-//\r
-#define SIZEOF_STARTUP_DATA_ARRAY 0x10\r
-\r
-UINT8                                   m128kRecoveryStartupApDataArray[SIZEOF_STARTUP_DATA_ARRAY] = {\r
-  //\r
-  // EA D0 FF 00 F0               ; far jmp F000:FFD0\r
-  // 0, 0, 0, 0, 0, 0, 0, 0, 0,   ; Reserved bytes\r
-  // 0, 0                         ; Checksum Padding\r
-  //\r
-  0xEA,\r
-  0xD0,\r
-  0xFF,\r
-  0x0,\r
-  0xF0,\r
-  0x00,\r
-  0x00,\r
-  0x00,\r
-  0x00,\r
-  0x00,\r
-  0x00,\r
-  0x00,\r
-  0x00,\r
-  0x00,\r
-  0x00,\r
-  0x00\r
-};\r
-\r
-UINT8                                   m64kRecoveryStartupApDataArray[SIZEOF_STARTUP_DATA_ARRAY] = {\r
-  //\r
-  // EB CE                               ; jmp short ($-0x30)\r
-  // ; (from offset 0x0 to offset 0xFFD0)\r
-  // 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ; Reserved bytes\r
-  // 0, 0                                ; Checksum Padding\r
-  //\r
-  0xEB,\r
-  0xCE,\r
-  0x00,\r
-  0x00,\r
-  0x00,\r
-  0x00,\r
-  0x00,\r
-  0x00,\r
-  0x00,\r
-  0x00,\r
-  0x00,\r
-  0x00,\r
-  0x00,\r
-  0x00,\r
-  0x00,\r
-  0x00\r
-};\r
-\r
-EFI_STATUS\r
-ParseFvInf (\r
-  IN MEMORY_FILE  *InfFile,\r
-  IN FV_INFO      *FvInfo\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  This function parses a FV.INF file and copies info into a FV_INFO structure.\r
-\r
-Arguments:\r
-\r
-  InfFile         Memory file image.\r
-  FvInfo          Information read from INF file.\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS       INF file information successfully retrieved.\r
-  EFI_ABORTED       INF file has an invalid format.\r
-  EFI_NOT_FOUND     A required string was not found in the INF file.\r
---*/\r
-{\r
-  CHAR8       Value[_MAX_PATH];\r
-  UINT64      Value64;\r
-  UINTN       Index;\r
-  EFI_STATUS  Status;\r
-\r
-  //\r
-  // Initialize FV info\r
-  //\r
-  memset (FvInfo, 0, sizeof (FV_INFO));\r
-\r
-  //\r
-  // Read the FV base address\r
-  //\r
-  Status = FindToken (InfFile, OPTIONS_SECTION_STRING, EFI_FV_BASE_ADDRESS_STRING, 0, Value);\r
-\r
-  if (Status == EFI_SUCCESS) {\r
-    //\r
-    // Get the base address\r
-    //\r
-    Status = AsciiStringToUint64 (Value, FALSE, &Value64);\r
-    if (EFI_ERROR (Status)) {\r
-      Error (NULL, 0, 0, EFI_FV_BASE_ADDRESS_STRING, "invalid value");\r
-      return EFI_ABORTED;\r
-    }\r
-\r
-    FvInfo->BaseAddress = Value64;\r
-  } else {\r
-    Error (NULL, 0, 0, EFI_FV_BASE_ADDRESS_STRING, "could not find value");\r
-    return EFI_ABORTED;\r
-  }\r
-  //\r
-  // Read the FV Guid\r
-  //\r
-  Status = FindToken (InfFile, OPTIONS_SECTION_STRING, EFI_FV_GUID_STRING, 0, Value);\r
-\r
-  if (Status == EFI_SUCCESS) {\r
-    //\r
-    // Get the guid value\r
-    //\r
-    Status = StringToGuid (Value, &FvInfo->FvGuid);\r
-    if (EFI_ERROR (Status)) {\r
-      memcpy (&FvInfo->FvGuid, &FfsGuid, sizeof (EFI_GUID));\r
-    }\r
-  } else {\r
-    memcpy (&FvInfo->FvGuid, &FfsGuid, sizeof (EFI_GUID));\r
-  }\r
-  //\r
-  // Read the FV file name\r
-  //\r
-  Status = FindToken (InfFile, OPTIONS_SECTION_STRING, EFI_FV_FILE_NAME_STRING, 0, Value);\r
-\r
-  if (Status == EFI_SUCCESS) {\r
-    //\r
-    // copy the file name\r
-    //\r
-    strcpy (FvInfo->FvName, Value);\r
-  } else {\r
-    Error (NULL, 0, 0, EFI_FV_FILE_NAME_STRING, "value not specified");\r
-    return EFI_ABORTED;\r
-  }\r
-  //\r
-  // Read the Sym file name\r
-  //\r
-  Status = FindToken (InfFile, OPTIONS_SECTION_STRING, EFI_SYM_FILE_NAME_STRING, 0, Value);\r
-\r
-  if (Status == EFI_SUCCESS) {\r
-    //\r
-    // copy the file name\r
-    //\r
-    strcpy (FvInfo->SymName, Value);\r
-  } else {\r
-    //\r
-    // Symbols not required, so init to NULL.\r
-    //\r
-    strcpy (FvInfo->SymName, "");\r
-  }\r
-  //\r
-  // Read the read disabled capability attribute\r
-  //\r
-  Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_READ_DISABLED_CAP_STRING, 0, Value);\r
-\r
-  if (Status == EFI_SUCCESS) {\r
-    //\r
-    // Update the read disabled flag\r
-    //\r
-    if (strcmp (Value, TRUE_STRING) == 0) {\r
-      FvInfo->FvAttributes |= EFI_FVB_READ_DISABLED_CAP;\r
-    } else if (strcmp (Value, FALSE_STRING) != 0) {\r
-      Error (NULL, 0, 0, EFI_FVB_READ_DISABLED_CAP_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING);\r
-      return EFI_ABORTED;\r
-    }\r
-  } else {\r
-    Error (NULL, 0, 0, EFI_FVB_READ_DISABLED_CAP_STRING, "value not specified");\r
-    return Status;\r
-  }\r
-  //\r
-  // Read the read enabled capability attribute\r
-  //\r
-  Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_READ_ENABLED_CAP_STRING, 0, Value);\r
-\r
-  if (Status == EFI_SUCCESS) {\r
-    //\r
-    // Update the read disabled flag\r
-    //\r
-    if (strcmp (Value, TRUE_STRING) == 0) {\r
-      FvInfo->FvAttributes |= EFI_FVB_READ_ENABLED_CAP;\r
-    } else if (strcmp (Value, FALSE_STRING) != 0) {\r
-      Error (NULL, 0, 0, EFI_FVB_READ_ENABLED_CAP_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING);\r
-      return EFI_ABORTED;\r
-    }\r
-  } else {\r
-    Error (NULL, 0, 0, EFI_FVB_READ_ENABLED_CAP_STRING, "value not specified");\r
-    return Status;\r
-  }\r
-  //\r
-  // Read the read status attribute\r
-  //\r
-  Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_READ_STATUS_STRING, 0, Value);\r
-\r
-  if (Status == EFI_SUCCESS) {\r
-    //\r
-    // Update the read disabled flag\r
-    //\r
-    if (strcmp (Value, TRUE_STRING) == 0) {\r
-      FvInfo->FvAttributes |= EFI_FVB_READ_STATUS;\r
-    } else if (strcmp (Value, FALSE_STRING) != 0) {\r
-      Error (NULL, 0, 0, EFI_FVB_READ_STATUS_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING);\r
-      return EFI_ABORTED;\r
-    }\r
-  } else {\r
-    Error (NULL, 0, 0, EFI_FVB_READ_STATUS_STRING, "value not specified");\r
-    return Status;\r
-  }\r
-  //\r
-  // Read the write disabled capability attribute\r
-  //\r
-  Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_WRITE_DISABLED_CAP_STRING, 0, Value);\r
-\r
-  if (Status == EFI_SUCCESS) {\r
-    //\r
-    // Update the write disabled flag\r
-    //\r
-    if (strcmp (Value, TRUE_STRING) == 0) {\r
-      FvInfo->FvAttributes |= EFI_FVB_WRITE_DISABLED_CAP;\r
-    } else if (strcmp (Value, FALSE_STRING) != 0) {\r
-      Error (NULL, 0, 0, EFI_FVB_WRITE_DISABLED_CAP_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING);\r
-      return EFI_ABORTED;\r
-    }\r
-  } else {\r
-    Error (NULL, 0, 0, EFI_FVB_WRITE_DISABLED_CAP_STRING, "value not specified");\r
-    return Status;\r
-  }\r
-  //\r
-  // Read the write enabled capability attribute\r
-  //\r
-  Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_WRITE_ENABLED_CAP_STRING, 0, Value);\r
-\r
-  if (Status == EFI_SUCCESS) {\r
-    //\r
-    // Update the write disabled flag\r
-    //\r
-    if (strcmp (Value, TRUE_STRING) == 0) {\r
-      FvInfo->FvAttributes |= EFI_FVB_WRITE_ENABLED_CAP;\r
-    } else if (strcmp (Value, FALSE_STRING) != 0) {\r
-      Error (NULL, 0, 0, EFI_FVB_WRITE_ENABLED_CAP_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING);\r
-      return EFI_ABORTED;\r
-    }\r
-  } else {\r
-    Error (NULL, 0, 0, EFI_FVB_WRITE_ENABLED_CAP_STRING, "value not specified");\r
-    return Status;\r
-  }\r
-  //\r
-  // Read the write status attribute\r
-  //\r
-  Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_WRITE_STATUS_STRING, 0, Value);\r
-\r
-  if (Status == EFI_SUCCESS) {\r
-    //\r
-    // Update the write disabled flag\r
-    //\r
-    if (strcmp (Value, TRUE_STRING) == 0) {\r
-      FvInfo->FvAttributes |= EFI_FVB_WRITE_STATUS;\r
-    } else if (strcmp (Value, FALSE_STRING) != 0) {\r
-      Error (NULL, 0, 0, EFI_FVB_WRITE_STATUS_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING);\r
-      return EFI_ABORTED;\r
-    }\r
-  } else {\r
-    Error (NULL, 0, 0, EFI_FVB_WRITE_STATUS_STRING, "value not specified");\r
-    return Status;\r
-  }\r
-  //\r
-  // Read the lock capability attribute\r
-  //\r
-  Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_LOCK_CAP_STRING, 0, Value);\r
-\r
-  if (Status == EFI_SUCCESS) {\r
-    //\r
-    // Update the attribute flag\r
-    //\r
-    if (strcmp (Value, TRUE_STRING) == 0) {\r
-      FvInfo->FvAttributes |= EFI_FVB_LOCK_CAP;\r
-    } else if (strcmp (Value, FALSE_STRING) != 0) {\r
-      Error (NULL, 0, 0, EFI_FVB_LOCK_CAP_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING);\r
-      return EFI_ABORTED;\r
-    }\r
-  } else {\r
-    Error (NULL, 0, 0, EFI_FVB_LOCK_CAP_STRING, "value not specified");\r
-    return Status;\r
-  }\r
-  //\r
-  // Read the lock status attribute\r
-  //\r
-  Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_LOCK_STATUS_STRING, 0, Value);\r
-\r
-  if (Status == EFI_SUCCESS) {\r
-    //\r
-    // Update the attribute flag\r
-    //\r
-    if (strcmp (Value, TRUE_STRING) == 0) {\r
-      FvInfo->FvAttributes |= EFI_FVB_LOCK_STATUS;\r
-    } else if (strcmp (Value, FALSE_STRING) != 0) {\r
-      Error (NULL, 0, 0, EFI_FVB_LOCK_STATUS_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING);\r
-      return EFI_ABORTED;\r
-    }\r
-  } else {\r
-    Error (NULL, 0, 0, EFI_FVB_LOCK_STATUS_STRING, "value not specified");\r
-    return Status;\r
-  }\r
-  //\r
-  // Read the sticky write attribute\r
-  //\r
-  Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_STICKY_WRITE_STRING, 0, Value);\r
-\r
-  if (Status == EFI_SUCCESS) {\r
-    //\r
-    // Update the attribute flag\r
-    //\r
-    if (strcmp (Value, TRUE_STRING) == 0) {\r
-      FvInfo->FvAttributes |= EFI_FVB_STICKY_WRITE;\r
-    } else if (strcmp (Value, FALSE_STRING) != 0) {\r
-      Error (NULL, 0, 0, EFI_FVB_STICKY_WRITE_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING);\r
-      return EFI_ABORTED;\r
-    }\r
-  } else {\r
-    Error (NULL, 0, 0, EFI_FVB_STICKY_WRITE_STRING, "value not specified");\r
-    return Status;\r
-  }\r
-  //\r
-  // Read the memory mapped attribute\r
-  //\r
-  Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_MEMORY_MAPPED_STRING, 0, Value);\r
-\r
-  if (Status == EFI_SUCCESS) {\r
-    //\r
-    // Update the attribute flag\r
-    //\r
-    if (strcmp (Value, TRUE_STRING) == 0) {\r
-      FvInfo->FvAttributes |= EFI_FVB_MEMORY_MAPPED;\r
-    } else if (strcmp (Value, FALSE_STRING) != 0) {\r
-      Error (NULL, 0, 0, EFI_FVB_MEMORY_MAPPED_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING);\r
-      return EFI_ABORTED;\r
-    }\r
-  } else {\r
-    Error (NULL, 0, 0, EFI_FVB_MEMORY_MAPPED_STRING, "value not specified");\r
-    return Status;\r
-  }\r
-  //\r
-  // Read the erase polarity attribute\r
-  //\r
-  Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_ERASE_POLARITY_STRING, 0, Value);\r
-\r
-  if (Status == EFI_SUCCESS) {\r
-    //\r
-    // Update the attribute flag\r
-    //\r
-    if (strcmp (Value, ONE_STRING) == 0) {\r
-      FvInfo->FvAttributes |= EFI_FVB_ERASE_POLARITY;\r
-    } else if (strcmp (Value, ZERO_STRING) != 0) {\r
-      Error (NULL, 0, 0, EFI_FVB_ERASE_POLARITY_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING);\r
-      return EFI_ABORTED;\r
-    }\r
-  } else {\r
-    Error (NULL, 0, 0, EFI_FVB_ERASE_POLARITY_STRING, "value not specified");\r
-    return Status;\r
-  }\r
-  //\r
-  // Read the alignment capabilities attribute\r
-  //\r
-  Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_ALIGNMENT_CAP_STRING, 0, Value);\r
-\r
-  if (Status == EFI_SUCCESS) {\r
-    //\r
-    // Update attribute\r
-    //\r
-    if (strcmp (Value, TRUE_STRING) == 0) {\r
-      FvInfo->FvAttributes |= EFI_FVB_ALIGNMENT_CAP;\r
-    } else if (strcmp (Value, FALSE_STRING) != 0) {\r
-      Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_CAP_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING);\r
-      return EFI_ABORTED;\r
-    }\r
-  } else {\r
-    Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_CAP_STRING, "value not specified");\r
-    return Status;\r
-  }\r
-  //\r
-  // Read the word alignment capability attribute\r
-  //\r
-  Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_ALIGNMENT_2_STRING, 0, Value);\r
-\r
-  if (Status == EFI_SUCCESS) {\r
-    //\r
-    // Update attribute\r
-    //\r
-    if (strcmp (Value, TRUE_STRING) == 0) {\r
-      FvInfo->FvAttributes |= EFI_FVB_ALIGNMENT_2;\r
-    } else if (strcmp (Value, FALSE_STRING) != 0) {\r
-      Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_2_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING);\r
-      return EFI_ABORTED;\r
-    }\r
-  } else {\r
-    Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_2_STRING, "value not specified");\r
-    return Status;\r
-  }\r
-  //\r
-  // Read the dword alignment capability attribute\r
-  //\r
-  Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_ALIGNMENT_4_STRING, 0, Value);\r
-\r
-  if (Status == EFI_SUCCESS) {\r
-    //\r
-    // Update attribute\r
-    //\r
-    if (strcmp (Value, TRUE_STRING) == 0) {\r
-      FvInfo->FvAttributes |= EFI_FVB_ALIGNMENT_4;\r
-    } else if (strcmp (Value, FALSE_STRING) != 0) {\r
-      Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_4_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING);\r
-      return EFI_ABORTED;\r
-    }\r
-  } else {\r
-    Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_4_STRING, "value not specified");\r
-    return Status;\r
-  }\r
-  //\r
-  // Read the word alignment capability attribute\r
-  //\r
-  Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_ALIGNMENT_8_STRING, 0, Value);\r
-\r
-  if (Status == EFI_SUCCESS) {\r
-    //\r
-    // Update attribute\r
-    //\r
-    if (strcmp (Value, TRUE_STRING) == 0) {\r
-      FvInfo->FvAttributes |= EFI_FVB_ALIGNMENT_8;\r
-    } else if (strcmp (Value, FALSE_STRING) != 0) {\r
-      Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_8_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING);\r
-      return EFI_ABORTED;\r
-    }\r
-  } else {\r
-    Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_8_STRING, "value not specified");\r
-    return Status;\r
-  }\r
-  //\r
-  // Read the qword alignment capability attribute\r
-  //\r
-  Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_ALIGNMENT_16_STRING, 0, Value);\r
-\r
-  if (Status == EFI_SUCCESS) {\r
-    //\r
-    // Update attribute\r
-    //\r
-    if (strcmp (Value, TRUE_STRING) == 0) {\r
-      FvInfo->FvAttributes |= EFI_FVB_ALIGNMENT_16;\r
-    } else if (strcmp (Value, FALSE_STRING) != 0) {\r
-      Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_16_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING);\r
-      return EFI_ABORTED;\r
-    }\r
-  } else {\r
-    Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_16_STRING, "value not specified");\r
-    return Status;\r
-  }\r
-  //\r
-  // Read the 32 byte alignment capability attribute\r
-  //\r
-  Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_ALIGNMENT_32_STRING, 0, Value);\r
-\r
-  if (Status == EFI_SUCCESS) {\r
-    //\r
-    // Update attribute\r
-    //\r
-    if (strcmp (Value, TRUE_STRING) == 0) {\r
-      FvInfo->FvAttributes |= EFI_FVB_ALIGNMENT_32;\r
-    } else if (strcmp (Value, FALSE_STRING) != 0) {\r
-      Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_32_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING);\r
-      return EFI_ABORTED;\r
-    }\r
-  } else {\r
-    Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_32_STRING, "value not specified");\r
-    return Status;\r
-  }\r
-  //\r
-  // Read the 64 byte alignment capability attribute\r
-  //\r
-  Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_ALIGNMENT_64_STRING, 0, Value);\r
-\r
-  if (Status == EFI_SUCCESS) {\r
-    //\r
-    // Update attribute\r
-    //\r
-    if (strcmp (Value, TRUE_STRING) == 0) {\r
-      FvInfo->FvAttributes |= EFI_FVB_ALIGNMENT_64;\r
-    } else if (strcmp (Value, FALSE_STRING) != 0) {\r
-      Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_64_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING);\r
-      return EFI_ABORTED;\r
-    }\r
-  } else {\r
-    Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_64_STRING, "value not specified");\r
-    return Status;\r
-  }\r
-  //\r
-  // Read the 128 byte alignment capability attribute\r
-  //\r
-  Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_ALIGNMENT_128_STRING, 0, Value);\r
-\r
-  if (Status == EFI_SUCCESS) {\r
-    //\r
-    // Update attribute\r
-    //\r
-    if (strcmp (Value, TRUE_STRING) == 0) {\r
-      FvInfo->FvAttributes |= EFI_FVB_ALIGNMENT_128;\r
-    } else if (strcmp (Value, FALSE_STRING) != 0) {\r
-      Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_128_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING);\r
-      return EFI_ABORTED;\r
-    }\r
-  } else {\r
-    Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_128_STRING, "value not specified");\r
-    return Status;\r
-  }\r
-  //\r
-  // Read the 256 byte alignment capability attribute\r
-  //\r
-  Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_ALIGNMENT_256_STRING, 0, Value);\r
-\r
-  if (Status == EFI_SUCCESS) {\r
-    //\r
-    // Update attribute\r
-    //\r
-    if (strcmp (Value, TRUE_STRING) == 0) {\r
-      FvInfo->FvAttributes |= EFI_FVB_ALIGNMENT_256;\r
-    } else if (strcmp (Value, FALSE_STRING) != 0) {\r
-      Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_256_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING);\r
-      return EFI_ABORTED;\r
-    }\r
-  } else {\r
-    Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_256_STRING, "value not specified");\r
-    return Status;\r
-  }\r
-  //\r
-  // Read the 512 byte alignment capability attribute\r
-  //\r
-  Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_ALIGNMENT_512_STRING, 0, Value);\r
-\r
-  if (Status == EFI_SUCCESS) {\r
-    //\r
-    // Update attribute\r
-    //\r
-    if (strcmp (Value, TRUE_STRING) == 0) {\r
-      FvInfo->FvAttributes |= EFI_FVB_ALIGNMENT_512;\r
-    } else if (strcmp (Value, FALSE_STRING) != 0) {\r
-      Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_512_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING);\r
-      return EFI_ABORTED;\r
-    }\r
-  } else {\r
-    Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_512_STRING, "value not specified");\r
-    return Status;\r
-  }\r
-  //\r
-  // Read the 1K byte alignment capability attribute\r
-  //\r
-  Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_ALIGNMENT_1K_STRING, 0, Value);\r
-\r
-  if (Status == EFI_SUCCESS) {\r
-    //\r
-    // Update attribute\r
-    //\r
-    if (strcmp (Value, TRUE_STRING) == 0) {\r
-      FvInfo->FvAttributes |= EFI_FVB_ALIGNMENT_1K;\r
-    } else if (strcmp (Value, FALSE_STRING) != 0) {\r
-      Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_1K_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING);\r
-      return EFI_ABORTED;\r
-    }\r
-  } else {\r
-    Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_1K_STRING, "value not specified");\r
-    return Status;\r
-  }\r
-  //\r
-  // Read the 2K byte alignment capability attribute\r
-  //\r
-  Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_ALIGNMENT_2K_STRING, 0, Value);\r
-\r
-  if (Status == EFI_SUCCESS) {\r
-    //\r
-    // Update attribute\r
-    //\r
-    if (strcmp (Value, TRUE_STRING) == 0) {\r
-      FvInfo->FvAttributes |= EFI_FVB_ALIGNMENT_2K;\r
-    } else if (strcmp (Value, FALSE_STRING) != 0) {\r
-      Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_2K_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING);\r
-      return EFI_ABORTED;\r
-    }\r
-  } else {\r
-    Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_2K_STRING, "value not specified");\r
-    return Status;\r
-  }\r
-  //\r
-  // Read the 4K byte alignment capability attribute\r
-  //\r
-  Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_ALIGNMENT_4K_STRING, 0, Value);\r
-\r
-  if (Status == EFI_SUCCESS) {\r
-    //\r
-    // Update attribute\r
-    //\r
-    if (strcmp (Value, TRUE_STRING) == 0) {\r
-      FvInfo->FvAttributes |= EFI_FVB_ALIGNMENT_4K;\r
-    } else if (strcmp (Value, FALSE_STRING) != 0) {\r
-      Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_4K_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING);\r
-      return EFI_ABORTED;\r
-    }\r
-  } else {\r
-    Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_4K_STRING, "value not specified");\r
-    return Status;\r
-  }\r
-  //\r
-  // Read the 8K byte alignment capability attribute\r
-  //\r
-  Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_ALIGNMENT_8K_STRING, 0, Value);\r
-\r
-  if (Status == EFI_SUCCESS) {\r
-    //\r
-    // Update attribute\r
-    //\r
-    if (strcmp (Value, TRUE_STRING) == 0) {\r
-      FvInfo->FvAttributes |= EFI_FVB_ALIGNMENT_8K;\r
-    } else if (strcmp (Value, FALSE_STRING) != 0) {\r
-      Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_8K_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING);\r
-      return EFI_ABORTED;\r
-    }\r
-  } else {\r
-    Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_8K_STRING, "value not specified");\r
-    return Status;\r
-  }\r
-  //\r
-  // Read the 16K byte alignment capability attribute\r
-  //\r
-  Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_ALIGNMENT_16K_STRING, 0, Value);\r
-\r
-  if (Status == EFI_SUCCESS) {\r
-    //\r
-    // Update attribute\r
-    //\r
-    if (strcmp (Value, TRUE_STRING) == 0) {\r
-      FvInfo->FvAttributes |= EFI_FVB_ALIGNMENT_16K;\r
-    } else if (strcmp (Value, FALSE_STRING) != 0) {\r
-      Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_16K_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING);\r
-      return EFI_ABORTED;\r
-    }\r
-  } else {\r
-    Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_16K_STRING, "value not specified");\r
-    return Status;\r
-  }\r
-  //\r
-  // Read the 32K byte alignment capability attribute\r
-  //\r
-  Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_ALIGNMENT_32K_STRING, 0, Value);\r
-\r
-  if (Status == EFI_SUCCESS) {\r
-    //\r
-    // Update attribute\r
-    //\r
-    if (strcmp (Value, TRUE_STRING) == 0) {\r
-      FvInfo->FvAttributes |= EFI_FVB_ALIGNMENT_32K;\r
-    } else if (strcmp (Value, FALSE_STRING) != 0) {\r
-      Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_32K_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING);\r
-      return EFI_ABORTED;\r
-    }\r
-  } else {\r
-    Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_32K_STRING, "value not specified");\r
-    return Status;\r
-  }\r
-  //\r
-  // Read the 64K byte alignment capability attribute\r
-  //\r
-  Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FVB_ALIGNMENT_64K_STRING, 0, Value);\r
-\r
-  if (Status == EFI_SUCCESS) {\r
-    //\r
-    // Update attribute\r
-    //\r
-    if (strcmp (Value, TRUE_STRING) == 0) {\r
-      FvInfo->FvAttributes |= EFI_FVB_ALIGNMENT_64K;\r
-    } else if (strcmp (Value, FALSE_STRING) != 0) {\r
-      Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_64K_STRING, "expected %s | %s", TRUE_STRING, FALSE_STRING);\r
-      return EFI_ABORTED;\r
-    }\r
-  } else {\r
-    Error (NULL, 0, 0, EFI_FVB_ALIGNMENT_64K_STRING, "value not specified");\r
-    return Status;\r
-  }\r
-\r
-  if (!(FvInfo->FvAttributes & EFI_FVB_ALIGNMENT_CAP) &&\r
-      (\r
-        (FvInfo->FvAttributes & EFI_FVB_ALIGNMENT_2) ||\r
-        (FvInfo->FvAttributes & EFI_FVB_ALIGNMENT_4) ||\r
-        (FvInfo->FvAttributes & EFI_FVB_ALIGNMENT_8) ||\r
-        (FvInfo->FvAttributes & EFI_FVB_ALIGNMENT_16) ||\r
-        (FvInfo->FvAttributes & EFI_FVB_ALIGNMENT_32) ||\r
-        (FvInfo->FvAttributes & EFI_FVB_ALIGNMENT_64) ||\r
-        (FvInfo->FvAttributes & EFI_FVB_ALIGNMENT_128) ||\r
-        (FvInfo->FvAttributes & EFI_FVB_ALIGNMENT_256) ||\r
-        (FvInfo->FvAttributes & EFI_FVB_ALIGNMENT_512) ||\r
-        (FvInfo->FvAttributes & EFI_FVB_ALIGNMENT_1K) ||\r
-        (FvInfo->FvAttributes & EFI_FVB_ALIGNMENT_2K) ||\r
-        (FvInfo->FvAttributes & EFI_FVB_ALIGNMENT_4K) ||\r
-        (FvInfo->FvAttributes & EFI_FVB_ALIGNMENT_8K) ||\r
-        (FvInfo->FvAttributes & EFI_FVB_ALIGNMENT_16K) ||\r
-        (FvInfo->FvAttributes & EFI_FVB_ALIGNMENT_32K) ||\r
-        (FvInfo->FvAttributes & EFI_FVB_ALIGNMENT_64K)\r
-      )\r
-     ) {\r
-    Error (\r
-      NULL,\r
-      0,\r
-      0,\r
-      "illegal combination of alignment attributes",\r
-      "if %s is not %s, no individual alignments can be %s",\r
-      EFI_FVB_ALIGNMENT_CAP_STRING,\r
-      TRUE_STRING,\r
-      TRUE_STRING\r
-      );\r
-    return EFI_ABORTED;\r
-  }\r
-  //\r
-  // Read block maps\r
-  //\r
-  for (Index = 0; Index < MAX_NUMBER_OF_FV_BLOCKS; Index++) {\r
-    //\r
-    // Read the number of blocks\r
-    //\r
-    Status = FindToken (InfFile, OPTIONS_SECTION_STRING, EFI_NUM_BLOCKS_STRING, Index, Value);\r
-\r
-    if (Status == EFI_SUCCESS) {\r
-      //\r
-      // Update the number of blocks\r
-      //\r
-      Status = AsciiStringToUint64 (Value, FALSE, &Value64);\r
-      if (EFI_ERROR (Status)) {\r
-        Error (NULL, 0, 0, Value, "invalid value for %s", EFI_NUM_BLOCKS_STRING);\r
-        return EFI_ABORTED;\r
-      }\r
-\r
-      FvInfo->FvBlocks[Index].NumBlocks = (UINT32) Value64;\r
-    } else {\r
-      //\r
-      // If there is no number of blocks, but there is a size, then we have a mismatched pair\r
-      // and should return an error.\r
-      //\r
-      Status = FindToken (InfFile, OPTIONS_SECTION_STRING, EFI_BLOCK_SIZE_STRING, Index, Value);\r
-      if (!EFI_ERROR (Status)) {\r
-        Error (NULL, 0, 0, "must specify both", "%s and %s", EFI_NUM_BLOCKS_STRING, EFI_BLOCK_SIZE_STRING);\r
-        return EFI_ABORTED;\r
-      } else {\r
-        //\r
-        // We are done\r
-        //\r
-        break;\r
-      }\r
-    }\r
-    //\r
-    // Read the size of blocks\r
-    //\r
-    Status = FindToken (InfFile, OPTIONS_SECTION_STRING, EFI_BLOCK_SIZE_STRING, Index, Value);\r
-\r
-    if (Status == EFI_SUCCESS) {\r
-      //\r
-      // Update the number of blocks\r
-      //\r
-      Status = AsciiStringToUint64 (Value, FALSE, &Value64);\r
-      if (EFI_ERROR (Status)) {\r
-        Error (NULL, 0, 0, Value, "invalid value specified for %s", EFI_BLOCK_SIZE_STRING);\r
-        return EFI_ABORTED;\r
-      }\r
-\r
-      FvInfo->FvBlocks[Index].BlockLength = (UINT32) Value64;\r
-    } else {\r
-      //\r
-      // There is a number of blocks, but there is no size, so we have a mismatched pair\r
-      // and should return an error.\r
-      //\r
-      Error (NULL, 0, 0, "must specify both", "%s and %s", EFI_NUM_BLOCKS_STRING, EFI_BLOCK_SIZE_STRING);\r
-      return EFI_ABORTED;\r
-    }\r
-  }\r
-  //\r
-  // Read files\r
-  //\r
-  for (Index = 0; Index < MAX_NUMBER_OF_FILES_IN_FV; Index++) {\r
-    //\r
-    // Read the number of blocks\r
-    //\r
-    Status = FindToken (InfFile, FILES_SECTION_STRING, EFI_FILE_NAME_STRING, Index, Value);\r
-\r
-    if (Status == EFI_SUCCESS) {\r
-      //\r
-      // Add the file\r
-      //\r
-      strcpy (FvInfo->FvFiles[Index], Value);\r
-    } else {\r
-      break;\r
-    }\r
-  }\r
-\r
-  if (FindSection (InfFile, COMPONENT_SECTION_STRING)) {\r
-    Index = 0;\r
-    //\r
-    // Read component FV_VARIABLE\r
-    //\r
-    Status = FindToken (InfFile, COMPONENT_SECTION_STRING, EFI_NV_VARIABLE_STRING, 0, Value);\r
-\r
-    if (Status == EFI_SUCCESS) {\r
-      //\r
-      // Add the component\r
-      //\r
-      strcpy (FvInfo->FvComponents[Index].ComponentName, EFI_NV_VARIABLE_STRING);\r
-      Status = AsciiStringToUint64 (Value, FALSE, &Value64);\r
-      if (EFI_ERROR (Status)) {\r
-        printf ("ERROR: %s is not a valid integer.\n", EFI_NV_VARIABLE_STRING);\r
-        return EFI_ABORTED;\r
-      }\r
-\r
-      FvInfo->FvComponents[Index].Size = (UINTN) Value64;\r
-    } else {\r
-      printf ("WARNING: Could not read %s.\n", EFI_NV_VARIABLE_STRING);\r
-    }\r
-\r
-    Index++;\r
-    //\r
-    // Read component FV_EVENT_LOG\r
-    //\r
-    Status = FindToken (InfFile, COMPONENT_SECTION_STRING, EFI_NV_EVENT_LOG_STRING, 0, Value);\r
-\r
-    if (Status == EFI_SUCCESS) {\r
-      //\r
-      // Add the component\r
-      //\r
-      strcpy (FvInfo->FvComponents[Index].ComponentName, EFI_NV_EVENT_LOG_STRING);\r
-      Status = AsciiStringToUint64 (Value, FALSE, &Value64);\r
-      if (EFI_ERROR (Status)) {\r
-        printf ("ERROR: %s is not a valid integer.\n", EFI_NV_EVENT_LOG_STRING);\r
-        return EFI_ABORTED;\r
-      }\r
-\r
-      FvInfo->FvComponents[Index].Size = (UINTN) Value64;\r
-    } else {\r
-      printf ("WARNING: Could not read %s.\n", EFI_NV_EVENT_LOG_STRING);\r
-    }\r
-\r
-    Index++;\r
-    //\r
-    // Read component FV_FTW_WORKING\r
-    //\r
-    Status = FindToken (InfFile, COMPONENT_SECTION_STRING, EFI_NV_FTW_WORKING_STRING, 0, Value);\r
-\r
-    if (Status == EFI_SUCCESS) {\r
-      //\r
-      // Add the component\r
-      //\r
-      strcpy (FvInfo->FvComponents[Index].ComponentName, EFI_NV_FTW_WORKING_STRING);\r
-      Status = AsciiStringToUint64 (Value, FALSE, &Value64);\r
-      if (EFI_ERROR (Status)) {\r
-        printf ("ERROR: %s is not a valid integer.\n", EFI_NV_FTW_WORKING_STRING);\r
-        return EFI_ABORTED;\r
-      }\r
-\r
-      FvInfo->FvComponents[Index].Size = (UINTN) Value64;\r
-    } else {\r
-      printf ("WARNING: Could not read %s.\n", EFI_NV_FTW_WORKING_STRING);\r
-    }\r
-\r
-    Index++;\r
-    //\r
-    // Read component FV_FTW_SPARE\r
-    //\r
-    Status = FindToken (InfFile, COMPONENT_SECTION_STRING, EFI_NV_FTW_SPARE_STRING, 0, Value);\r
-\r
-    if (Status == EFI_SUCCESS) {\r
-      //\r
-      // Add the component\r
-      //\r
-      strcpy (FvInfo->FvComponents[Index].ComponentName, EFI_NV_FTW_SPARE_STRING);\r
-      Status = AsciiStringToUint64 (Value, FALSE, &Value64);\r
-      if (EFI_ERROR (Status)) {\r
-        printf ("ERROR: %s is not a valid integer.\n", EFI_NV_FTW_SPARE_STRING);\r
-        return EFI_ABORTED;\r
-      }\r
-\r
-      FvInfo->FvComponents[Index].Size = (UINTN) Value64;\r
-    } else {\r
-      printf ("WARNING: Could not read %s.\n", EFI_NV_FTW_SPARE_STRING);\r
-    }\r
-  }\r
-  //\r
-  // Compute size for easy access later\r
-  //\r
-  FvInfo->Size = 0;\r
-  for (Index = 0; FvInfo->FvBlocks[Index].NumBlocks; Index++) {\r
-    FvInfo->Size += FvInfo->FvBlocks[Index].NumBlocks * FvInfo->FvBlocks[Index].BlockLength;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-VOID\r
-UpdateFfsFileState (\r
-  IN EFI_FFS_FILE_HEADER          *FfsFile,\r
-  IN EFI_FIRMWARE_VOLUME_HEADER   *FvHeader\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  This function changes the FFS file attributes based on the erase polarity\r
-  of the FV.\r
-\r
-Arguments:\r
-\r
-  FfsFile   File header.\r
-  FvHeader  FV header.\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-{\r
-  if (FvHeader->Attributes & EFI_FVB_ERASE_POLARITY) {\r
-    FfsFile->State = (UINT8)~(FfsFile->State);\r
-  }\r
-}\r
-\r
-EFI_STATUS\r
-ReadFfsAlignment (\r
-  IN EFI_FFS_FILE_HEADER    *FfsFile,\r
-  IN OUT UINT32             *Alignment\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  This function determines the alignment of the FFS input file from the file\r
-  attributes.\r
-\r
-Arguments:\r
-\r
-  FfsFile       FFS file to parse\r
-  Alignment     The minimum required alignment of the FFS file, in bytes\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS              The function completed successfully.\r
-  EFI_INVALID_PARAMETER    One of the input parameters was invalid.\r
-  EFI_ABORTED              An error occurred.\r
-\r
---*/\r
-{\r
-  //\r
-  // Verify input parameters.\r
-  //\r
-  if (FfsFile == NULL || Alignment == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  switch ((FfsFile->Attributes >> 3) & 0x07) {\r
-\r
-  case 0:\r
-    //\r
-    // 1 byte alignment\r
-    //\r
-    *Alignment = (1 << 0);\r
-    break;\r
-\r
-  case 1:\r
-    //\r
-    // 16 byte alignment\r
-    //\r
-    *Alignment = (1 << 4);\r
-    break;\r
-\r
-  case 2:\r
-    //\r
-    // 128 byte alignment\r
-    //\r
-    *Alignment = (1 << 7);\r
-    break;\r
-\r
-  case 3:\r
-    //\r
-    // 512 byte alignment\r
-    //\r
-    *Alignment = (1 << 9);\r
-    break;\r
-\r
-  case 4:\r
-    //\r
-    // 1K byte alignment\r
-    //\r
-    *Alignment = (1 << 10);\r
-    break;\r
-\r
-  case 5:\r
-    //\r
-    // 4K byte alignment\r
-    //\r
-    *Alignment = (1 << 12);\r
-    break;\r
-\r
-  case 6:\r
-    //\r
-    // 32K byte alignment\r
-    //\r
-    *Alignment = (1 << 15);\r
-    break;\r
-\r
-  case 7:\r
-    //\r
-    // 64K byte alignment\r
-    //\r
-    *Alignment = (1 << 16);\r
-    break;\r
-\r
-  default:\r
-    Error (NULL, 0, 0, "nvalid file attribute calculated, this is most likely a utility error", NULL);\r
-    return EFI_ABORTED;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-AddPadFile (\r
-  IN OUT MEMORY_FILE  *FvImage,\r
-  IN UINT32           DataAlignment\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  This function adds a pad file to the FV image if it required to align the\r
-  data of the next file.\r
-\r
-Arguments:\r
-\r
-  FvImage         The memory image of the FV to add it to.  The current offset\r
-                  must be valid.\r
-  DataAlignment   The data alignment of the next FFS file.\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS              The function completed successfully.\r
-  EFI_INVALID_PARAMETER    One of the input parameters was invalid.\r
-  EFI_OUT_OF_RESOURCES     Insufficient resources exist in the FV to complete\r
-                           the pad file add.\r
-\r
---*/\r
-{\r
-  EFI_FFS_FILE_HEADER *PadFile;\r
-  EFI_GUID            PadFileGuid;\r
-  UINTN               PadFileSize;\r
-\r
-  //\r
-  // Verify input parameters.\r
-  //\r
-  if (FvImage == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-  //\r
-  // Basic assumption is we start from an 8 byte aligned address\r
-  // and our file header is a multiple of 8 bytes\r
-  //\r
-  assert ((UINTN) FvImage->CurrentFilePointer % 8 == 0);\r
-  assert (sizeof (EFI_FFS_FILE_HEADER) % 8 == 0);\r
-\r
-  //\r
-  // Check if a pad file is necessary\r
-  //\r
-  if (((UINTN) FvImage->CurrentFilePointer - (UINTN) FvImage->FileImage + sizeof (EFI_FFS_FILE_HEADER)) % DataAlignment == 0) {\r
-    return EFI_SUCCESS;\r
-  }\r
-  //\r
-  // Write pad file header\r
-  //\r
-  PadFile = (EFI_FFS_FILE_HEADER *) FvImage->CurrentFilePointer;\r
-\r
-  //\r
-  // Verify that we have enough space for the file header\r
-  //\r
-  if ((UINTN) (PadFile + sizeof (EFI_FFS_FILE_HEADER)) >= (UINTN) FvImage->Eof) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-\r
-#ifdef __GNUC__\r
-  {\r
-    uuid_t tmp_id;\r
-    uuid_generate (tmp_id);\r
-    memcpy (&PadFileGuid, tmp_id, sizeof (EFI_GUID));\r
-  }\r
-#else\r
-  UuidCreate (&PadFileGuid);\r
-#endif\r
-  memset (PadFile, 0, sizeof (EFI_FFS_FILE_HEADER));\r
-  memcpy (&PadFile->Name, &PadFileGuid, sizeof (EFI_GUID));\r
-  PadFile->Type       = EFI_FV_FILETYPE_FFS_PAD;\r
-  PadFile->Attributes = 0;\r
-\r
-  //\r
-  // Calculate the pad file size\r
-  //\r
-  //\r
-  // This is the earliest possible valid offset (current plus pad file header\r
-  // plus the next file header)\r
-  //\r
-  PadFileSize = (UINTN) FvImage->CurrentFilePointer - (UINTN) FvImage->FileImage + (sizeof (EFI_FFS_FILE_HEADER) * 2);\r
-\r
-  //\r
-  // Add whatever it takes to get to the next aligned address\r
-  //\r
-  while ((PadFileSize % DataAlignment) != 0) {\r
-    PadFileSize++;\r
-  }\r
-  //\r
-  // Subtract the next file header size\r
-  //\r
-  PadFileSize -= sizeof (EFI_FFS_FILE_HEADER);\r
-\r
-  //\r
-  // Subtract the starting offset to get size\r
-  //\r
-  PadFileSize -= (UINTN) FvImage->CurrentFilePointer - (UINTN) FvImage->FileImage;\r
-\r
-  //\r
-  // Write pad file size (calculated size minus next file header size)\r
-  //\r
-  PadFile->Size[0]  = (UINT8) (PadFileSize & 0xFF);\r
-  PadFile->Size[1]  = (UINT8) ((PadFileSize >> 8) & 0xFF);\r
-  PadFile->Size[2]  = (UINT8) ((PadFileSize >> 16) & 0xFF);\r
-\r
-  //\r
-  // Fill in checksums and state, they must be 0 for checksumming.\r
-  //\r
-  PadFile->IntegrityCheck.Checksum.Header = 0;\r
-  PadFile->IntegrityCheck.Checksum.File   = 0;\r
-  PadFile->State                          = 0;\r
-  PadFile->IntegrityCheck.Checksum.Header = CalculateChecksum8 ((UINT8 *) PadFile, sizeof (EFI_FFS_FILE_HEADER));\r
-  if (PadFile->Attributes & FFS_ATTRIB_CHECKSUM) {\r
-    PadFile->IntegrityCheck.Checksum.File = CalculateChecksum8 ((UINT8 *) PadFile, PadFileSize);\r
-  } else {\r
-    PadFile->IntegrityCheck.Checksum.File = FFS_FIXED_CHECKSUM;\r
-  }\r
-\r
-  PadFile->State = EFI_FILE_HEADER_CONSTRUCTION | EFI_FILE_HEADER_VALID | EFI_FILE_DATA_VALID;\r
-  UpdateFfsFileState (\r
-    (EFI_FFS_FILE_HEADER *) PadFile,\r
-    (EFI_FIRMWARE_VOLUME_HEADER *) FvImage->FileImage\r
-    );\r
-\r
-  //\r
-  // Verify that we have enough space (including the padding\r
-  //\r
-  if ((UINTN) (PadFile + sizeof (EFI_FFS_FILE_HEADER)) >= (UINTN) FvImage->Eof) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-  //\r
-  // Update the current FV pointer\r
-  //\r
-  FvImage->CurrentFilePointer += PadFileSize;\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-BOOLEAN\r
-IsVtfFile (\r
-  IN EFI_FFS_FILE_HEADER    *FileBuffer\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  This function checks the header to validate if it is a VTF file\r
-\r
-Arguments:\r
-\r
-  FileBuffer     Buffer in which content of a file has been read.\r
-\r
-Returns:\r
-\r
-  TRUE    If this is a VTF file\r
-  FALSE   If this is not a VTF file\r
-\r
---*/\r
-{\r
-  EFI_GUID  VtfGuid = EFI_FFS_VOLUME_TOP_FILE_GUID;\r
-  if (!memcmp (&FileBuffer->Name, &VtfGuid, sizeof (EFI_GUID))) {\r
-    return TRUE;\r
-  } else {\r
-    return FALSE;\r
-  }\r
-}\r
-\r
-EFI_STATUS\r
-FfsRebaseImageRead (\r
-  IN     VOID    *FileHandle,\r
-  IN     UINTN   FileOffset,\r
-  IN OUT UINT32  *ReadSize,\r
-  OUT    VOID    *Buffer\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Support routine for the PE/COFF Loader that reads a buffer from a PE/COFF file\r
-\r
-Arguments:\r
-\r
-  FileHandle - The handle to the PE/COFF file\r
-\r
-  FileOffset - The offset, in bytes, into the file to read\r
-\r
-  ReadSize   - The number of bytes to read from the file starting at FileOffset\r
-\r
-  Buffer     - A pointer to the buffer to read the data into.\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS - ReadSize bytes of data were read into Buffer from the PE/COFF file starting at FileOffset\r
-\r
---*/\r
-{\r
-  CHAR8   *Destination8;\r
-  CHAR8   *Source8;\r
-  UINT32  Length;\r
-\r
-  Destination8  = Buffer;\r
-  Source8       = (CHAR8 *) ((UINTN) FileHandle + FileOffset);\r
-  Length        = *ReadSize;\r
-  while (Length--) {\r
-    *(Destination8++) = *(Source8++);\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r
-EFI_STATUS\r
-AddSymFile (\r
-  IN UINT64               BaseAddress,\r
-  IN EFI_FFS_FILE_HEADER  *FfsFile,\r
-  IN OUT MEMORY_FILE      *SymImage,\r
-  IN CHAR8                *SourceFileName\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  This function adds the SYM tokens in the source file to the destination file.\r
-  The SYM tokens are updated to reflect the base address.\r
-\r
-Arguments:\r
-\r
-  BaseAddress     The base address for the new SYM tokens.\r
-  FfsFile         Pointer to the beginning of the FFS file in question.\r
-  SymImage        The memory file to update with symbol information.\r
-  SourceFileName  The source file.\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS              The function completed successfully.\r
-  EFI_INVALID_PARAMETER    One of the input parameters was invalid.\r
-  EFI_ABORTED              An error occurred.\r
-\r
---*/\r
-{\r
-  FILE                      *SourceFile;\r
-\r
-  CHAR8                     Buffer[_MAX_PATH];\r
-  CHAR8                     Type[_MAX_PATH];\r
-  CHAR8                     Address[_MAX_PATH];\r
-  CHAR8                     Section[_MAX_PATH];\r
-  CHAR8                     Token[_MAX_PATH];\r
-  CHAR8                     SymFileName[_MAX_PATH];\r
-  CHAR8                     CodeModuleName[_MAX_PATH];\r
-  CHAR8                     *Ptr;\r
-\r
-  UINT64                    TokenAddress;\r
-\r
-  EFI_STATUS                Status;\r
-  EFI_FILE_SECTION_POINTER  Pe32Section;\r
-  UINT32                    EntryPoint;\r
-  UINT32                    BaseOfCode;\r
-  UINT16                    MachineType;\r
-\r
-  //\r
-  // Verify input parameters.\r
-  //\r
-  if (BaseAddress == 0 || FfsFile == NULL || SymImage == NULL || SourceFileName == NULL) {\r
-    Error (NULL, 0, 0, "invalid parameter passed to AddSymFile()", NULL);\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-  //\r
-  // Check if we want to add this file\r
-  //\r
-  //\r
-  // Get the file name\r
-  //\r
-  strcpy (Buffer, SourceFileName);\r
-\r
-  //\r
-  // Copy the file name for the path of the sym file and truncate the name portion.\r
-  //\r
-  strcpy (SymFileName, Buffer);\r
-  Ptr = strrchr (SymFileName, '\\');\r
-  assert (Ptr);\r
-  Ptr[0] = 0;\r
-\r
-  //\r
-  // Find the file extension and make it lower case\r
-  //\r
-  Ptr = strrchr (SymFileName, '.');\r
-  if (Ptr != NULL) {\r
-    strlwr (Ptr);\r
-  }\r
-  //\r
-  // Check if it is PEI file\r
-  //\r
-  if (strstr (Buffer, ".pei") != NULL) {\r
-    //\r
-    // Find the human readable portion\r
-    //\r
-    if (!strtok (Buffer, "-") ||\r
-        !strtok (NULL, "-") ||\r
-        !strtok (NULL, "-") ||\r
-        !strtok (NULL, "-") ||\r
-        !strtok (NULL, "-") ||\r
-        !strcpy (Buffer, strtok (NULL, "."))\r
-          ) {\r
-      Error (NULL, 0, 0, "failed to find human readable portion of the file name in AddSymFile()", NULL);\r
-      return EFI_ABORTED;\r
-    }\r
-    //\r
-    // Save code module name\r
-    //\r
-    strcpy (CodeModuleName, Buffer);\r
-\r
-    //\r
-    // Add the symbol file name and extension to the file path.\r
-    //\r
-    strcat (Buffer, ".sym");\r
-    strcat (SymFileName, "\\");\r
-    strcat (SymFileName, Buffer);\r
-  } else {\r
-    //\r
-    // Only handle PEIM files.\r
-    //\r
-    return EFI_SUCCESS;\r
-  }\r
-  //\r
-  // Find PE32 section\r
-  //\r
-  Status = GetSectionByType (FfsFile, EFI_SECTION_PE32, 1, &Pe32Section);\r
-\r
-  //\r
-  // BUGBUG: Assume if no PE32 section it is PIC and hardcode base address\r
-  //\r
-  if (Status == EFI_NOT_FOUND) {\r
-    Status = GetSectionByType (FfsFile, EFI_SECTION_TE, 1, &Pe32Section);\r
-  }\r
-\r
-  if (Status == EFI_SUCCESS) {\r
-    Status = GetPe32Info (\r
-              (VOID *) ((UINTN) Pe32Section.Pe32Section + sizeof (EFI_SECTION_PE32)),\r
-              &EntryPoint,\r
-              &BaseOfCode,\r
-              &MachineType\r
-              );\r
-  } else if (Status == EFI_NOT_FOUND) {\r
-    //\r
-    // For PIC, hardcode.\r
-    //\r
-    BaseOfCode = 0x60;\r
-    Status = EFI_SUCCESS;\r
-  } else {\r
-    Error (NULL, 0, 0, "could not parse a PE32 section from the PEI file", NULL);\r
-    return Status;\r
-  }\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    Error (NULL, 0, 0, "GetPe32Info() could not get PE32 entry point for PEI file", NULL);\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Open the source file\r
-  //\r
-  SourceFile = fopen (SymFileName, "r");\r
-  if (SourceFile == NULL) {\r
-    //\r
-    // SYM files are not required.\r
-    //\r
-    return EFI_SUCCESS;\r
-  }\r
-  //\r
-  // Read the first line\r
-  //\r
-  if (fgets (Buffer, _MAX_PATH, SourceFile) == NULL) {\r
-    Buffer[0] = 0;\r
-  }\r
-  //\r
-  // Make sure it matches the expected sym format\r
-  //\r
-  if (strcmp (Buffer, "TEXTSYM format | V1.0\n")) {\r
-    fclose (SourceFile);\r
-    Error (NULL, 0, 0, "AddSymFile() found unexpected sym format in input file", NULL);\r
-    return EFI_ABORTED;\r
-  }\r
-  //\r
-  // Read in the file\r
-  //\r
-  while (feof (SourceFile) == 0) {\r
-    //\r
-    // Read a line\r
-    //\r
-    if (fscanf (\r
-          SourceFile,\r
-          "%s | %s | %s | %s\n",\r
-          Type,\r
-          Address,\r
-          Section,\r
-          Token\r
-          ) == 4) {\r
-      //\r
-      // If the token starts with "??" ignore it\r
-      //\r
-      if (Token[0] == '?' && Token[1] == '?') {\r
-        continue;\r
-      }\r
-      //\r
-      // Get the token address\r
-      //\r
-      AsciiStringToUint64 (Address, TRUE, &TokenAddress);\r
-\r
-      //\r
-      // Add the base address\r
-      //\r
-      TokenAddress += BaseAddress;\r
-\r
-      //\r
-      // If PE32 or TE section then find the start of code.  For PIC it is hardcoded.\r
-      //\r
-      if (Pe32Section.Pe32Section) {\r
-        //\r
-        // Add the offset of the PE32 section\r
-        //\r
-        TokenAddress += (UINTN) Pe32Section.Pe32Section - (UINTN) FfsFile;\r
-\r
-        //\r
-        // Add the size of the PE32 section header\r
-        //\r
-        TokenAddress += sizeof (EFI_PE32_SECTION);\r
-      } else {\r
-        //\r
-        // For PIC hardcoded.\r
-        //\r
-        TokenAddress += 0x28;\r
-      }\r
-\r
-      //\r
-      // Add the beginning of the code\r
-      //\r
-      TokenAddress += BaseOfCode;\r
-\r
-      sprintf (\r
-        Buffer,\r
-        "%s | %016I64X | %s | _%s%s\n",\r
-        Type,\r
-        TokenAddress,\r
-        Section,\r
-        CodeModuleName,\r
-        Token\r
-        );\r
-      memcpy (SymImage->CurrentFilePointer, Buffer, strlen (Buffer) + 1);\r
-      SymImage->CurrentFilePointer = (UINT8 *) (((UINTN) SymImage->CurrentFilePointer) + strlen (Buffer) + 1);\r
-    }\r
-  }\r
-\r
-  fclose (SourceFile);\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-AddFile (\r
-  IN OUT MEMORY_FILE          *FvImage,\r
-  IN FV_INFO                  *FvInfo,\r
-  IN UINTN                    Index,\r
-  IN OUT EFI_FFS_FILE_HEADER  **VtfFileImage,\r
-  IN OUT MEMORY_FILE          *SymImage\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  This function adds a file to the FV image.  The file will pad to the\r
-  appropriate alignment if required.\r
-\r
-Arguments:\r
-\r
-  FvImage       The memory image of the FV to add it to.  The current offset\r
-                must be valid.\r
-  FvInfo        Pointer to information about the FV.\r
-  Index         The file in the FvInfo file list to add.\r
-  VtfFileImage  A pointer to the VTF file within the FvImage.  If this is equal\r
-                to the end of the FvImage then no VTF previously found.\r
-  SymImage      The memory image of the Sym file to update if symbols are present.\r
-                The current offset must be valid.\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS              The function completed successfully.\r
-  EFI_INVALID_PARAMETER    One of the input parameters was invalid.\r
-  EFI_ABORTED              An error occurred.\r
-  EFI_OUT_OF_RESOURCES     Insufficient resources exist to complete the add.\r
-\r
---*/\r
-{\r
-  FILE                  *NewFile;\r
-  UINTN                 FileSize;\r
-  UINT8                 *FileBuffer;\r
-  UINTN                 NumBytesRead;\r
-  UINT32                CurrentFileAlignment;\r
-  EFI_STATUS            Status;\r
-  EFI_PHYSICAL_ADDRESS  CurrentFileBaseAddress;\r
-  UINT8                 VtfHeaderChecksum;\r
-  UINT8                 VtfFileChecksum;\r
-  UINT8                 FileState;\r
-  EFI_FFS_FILE_TAIL     TailValue;\r
-  UINT32                TailSize;\r
-  //\r
-  // Verify input parameters.\r
-  //\r
-  if (FvImage == NULL || FvInfo == NULL || FvInfo->FvFiles[Index][0] == 0 || VtfFileImage == NULL || SymImage == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-  //\r
-  // Read the file to add\r
-  //\r
-  NewFile = fopen (FvInfo->FvFiles[Index], "rb");\r
-\r
-  if (NewFile == NULL) {\r
-    Error (NULL, 0, 0, FvInfo->FvFiles[Index], "failed to open file for reading");\r
-    return EFI_ABORTED;\r
-  }\r
-  //\r
-  // Get the file size\r
-  //\r
-#ifdef __GNUC__\r
-  {\r
-    struct stat stat_buf;\r
-    fstat(fileno(NewFile), &stat_buf);\r
-    FileSize = stat_buf.st_size;\r
-  }\r
-#else\r
-  FileSize = _filelength (fileno (NewFile));\r
-#endif\r
-\r
-  //\r
-  // Read the file into a buffer\r
-  //\r
-  FileBuffer = malloc (FileSize);\r
-  if (FileBuffer == NULL) {\r
-    Error (NULL, 0, 0, "memory allocation failure", NULL);\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-\r
-  NumBytesRead = fread (FileBuffer, sizeof (UINT8), FileSize, NewFile);\r
-\r
-  //\r
-  // Done with the file, from this point on we will just use the buffer read.\r
-  //\r
-  fclose (NewFile);\r
-\r
-  //\r
-  // Verify read successful\r
-  //\r
-  if (NumBytesRead != sizeof (UINT8) * FileSize) {\r
-    free (FileBuffer);\r
-    Error (NULL, 0, 0, FvInfo->FvFiles[Index], "failed to read input file contents");\r
-    return EFI_ABORTED;\r
-  }\r
-  //\r
-  // Verify space exists to add the file\r
-  //\r
-  if (FileSize > (UINTN) ((UINTN) *VtfFileImage - (UINTN) FvImage->CurrentFilePointer)) {\r
-    Error (NULL, 0, 0, FvInfo->FvFiles[Index], "insufficient space remains to add the file");\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-  //\r
-  // Update the file state based on polarity of the FV.\r
-  //\r
-  UpdateFfsFileState (\r
-    (EFI_FFS_FILE_HEADER *) FileBuffer,\r
-    (EFI_FIRMWARE_VOLUME_HEADER *) FvImage->FileImage\r
-    );\r
-\r
-  //\r
-  // If we have a VTF file, add it at the top.\r
-  //\r
-  if (IsVtfFile ((EFI_FFS_FILE_HEADER *) FileBuffer)) {\r
-    if ((UINTN) *VtfFileImage == (UINTN) FvImage->Eof) {\r
-      //\r
-      // No previous VTF, add this one.\r
-      //\r
-      *VtfFileImage = (EFI_FFS_FILE_HEADER *) (UINTN) ((UINTN) FvImage->FileImage + FvInfo->Size - FileSize);\r
-      //\r
-      // Sanity check. The file MUST align appropriately\r
-      //\r
-      if ((((UINTN) *VtfFileImage) & 0x07) != 0) {\r
-        Error (NULL, 0, 0, "VTF file does not align on 8-byte boundary", NULL);\r
-      }\r
-      //\r
-      // copy VTF File Header\r
-      //\r
-      memcpy (*VtfFileImage, FileBuffer, sizeof (EFI_FFS_FILE_HEADER));\r
-\r
-      //\r
-      // Copy VTF body\r
-      //\r
-      memcpy (\r
-        (UINT8 *) *VtfFileImage + sizeof (EFI_FFS_FILE_HEADER),\r
-        FileBuffer + sizeof (EFI_FFS_FILE_HEADER),\r
-        FileSize - sizeof (EFI_FFS_FILE_HEADER)\r
-        );\r
-\r
-      //\r
-      // re-calculate the VTF File Header\r
-      //\r
-      FileState = (*VtfFileImage)->State;\r
-      (*VtfFileImage)->State = 0;\r
-      *(UINT32 *) ((*VtfFileImage)->Size) = FileSize;\r
-      (*VtfFileImage)->IntegrityCheck.Checksum.Header = 0;\r
-      (*VtfFileImage)->IntegrityCheck.Checksum.File = 0;\r
-\r
-      VtfHeaderChecksum = CalculateChecksum8 ((UINT8 *) *VtfFileImage, sizeof (EFI_FFS_FILE_HEADER));\r
-      (*VtfFileImage)->IntegrityCheck.Checksum.Header = VtfHeaderChecksum;\r
-      //\r
-      // Determine if it has a tail\r
-      //\r
-      if ((*VtfFileImage)->Attributes & FFS_ATTRIB_TAIL_PRESENT) {\r
-        TailSize = sizeof (EFI_FFS_FILE_TAIL);\r
-      } else {\r
-        TailSize = 0;\r
-      }\r
-\r
-      if ((*VtfFileImage)->Attributes & FFS_ATTRIB_CHECKSUM) {\r
-        VtfFileChecksum = CalculateChecksum8 ((UINT8 *) *VtfFileImage, FileSize - TailSize);\r
-        (*VtfFileImage)->IntegrityCheck.Checksum.File = VtfFileChecksum;\r
-      } else {\r
-        (*VtfFileImage)->IntegrityCheck.Checksum.File = FFS_FIXED_CHECKSUM;\r
-      }\r
-      //\r
-      // If it has a file tail, update it\r
-      //\r
-      if ((*VtfFileImage)->Attributes & FFS_ATTRIB_TAIL_PRESENT) {\r
-        TailValue = (EFI_FFS_FILE_TAIL) (~((*VtfFileImage)->IntegrityCheck.TailReference));\r
-        *(EFI_FFS_FILE_TAIL *) (((UINTN) (*VtfFileImage) + GetLength ((*VtfFileImage)->Size) - sizeof (EFI_FFS_FILE_TAIL))) = TailValue;\r
-      }\r
-      (*VtfFileImage)->State = FileState;\r
-      free (FileBuffer);\r
-      return EFI_SUCCESS;\r
-    } else {\r
-      //\r
-      // Already found a VTF file.\r
-      //\r
-      Error (NULL, 0, 0, "multiple VTF files are illegal in a single FV", NULL);\r
-      free (FileBuffer);\r
-      return EFI_ABORTED;\r
-    }\r
-  }\r
-  //\r
-  // Check if alignment is required\r
-  //\r
-  Status = ReadFfsAlignment ((EFI_FFS_FILE_HEADER *) FileBuffer, &CurrentFileAlignment);\r
-  if (EFI_ERROR (Status)) {\r
-    printf ("ERROR: Could not determine alignment of file %s.\n", FvInfo->FvFiles[Index]);\r
-    free (FileBuffer);\r
-    return EFI_ABORTED;\r
-  }\r
-  //\r
-  // Add pad file if necessary\r
-  //\r
-  Status = AddPadFile (FvImage, CurrentFileAlignment);\r
-  if (EFI_ERROR (Status)) {\r
-    printf ("ERROR: Could not align the file data properly.\n");\r
-    free (FileBuffer);\r
-    return EFI_ABORTED;\r
-  }\r
-  //\r
-  // Add file\r
-  //\r
-  if ((FvImage->CurrentFilePointer + FileSize) < FvImage->Eof) {\r
-    //\r
-    // Copy the file\r
-    //\r
-    memcpy (FvImage->CurrentFilePointer, FileBuffer, FileSize);\r
-\r
-    //\r
-    // If the file is XIP, rebase\r
-    //\r
-    CurrentFileBaseAddress = FvInfo->BaseAddress + ((UINTN) FvImage->CurrentFilePointer - (UINTN) FvImage->FileImage);\r
-    //\r
-    //    Status = RebaseFfsFile ((EFI_FFS_FILE_HEADER*) FvImage->CurrentFilePointer, CurrentFileBaseAddress);\r
-    //    if (EFI_ERROR(Status)) {\r
-    //      printf ("ERROR: Could not rebase the file %s.\n", FvInfo->FvFiles[Index]);\r
-    //      return EFI_ABORTED;\r
-    //    }\r
-    //\r
-    // Update Symbol file\r
-    //\r
-    Status = AddSymFile (\r
-              CurrentFileBaseAddress,\r
-              (EFI_FFS_FILE_HEADER *) FvImage->CurrentFilePointer,\r
-              SymImage,\r
-              FvInfo->FvFiles[Index]\r
-              );\r
-    assert (!EFI_ERROR (Status));\r
-\r
-    //\r
-    // Update the current pointer in the FV image\r
-    //\r
-    FvImage->CurrentFilePointer += FileSize;\r
-  } else {\r
-    printf ("ERROR: The firmware volume is out of space, could not add file %s.\n", FvInfo->FvFiles[Index]);\r
-    return EFI_ABORTED;\r
-  }\r
-  //\r
-  // Make next file start at QWord Boundry\r
-  //\r
-  while (((UINTN) FvImage->CurrentFilePointer & 0x07) != 0) {\r
-    FvImage->CurrentFilePointer++;\r
-  }\r
-  //\r
-  // Free allocated memory.\r
-  //\r
-  free (FileBuffer);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-AddVariableBlock (\r
-  IN UINT8                    *FvImage,\r
-  IN UINTN                    Size,\r
-  IN FV_INFO                  *FvInfo\r
-  )\r
-{\r
-  EFI_FIRMWARE_VOLUME_HEADER  *FvHeader;\r
-  VARIABLE_STORE_HEADER       *VarStoreHeader;\r
-  //\r
-  // Variable block should exclude FvHeader. Since the length of\r
-  // FvHeader depends on the block map, which is variable length,\r
-  // we could only decide the actual variable block length here.\r
-  //\r
-  FvHeader                  = (EFI_FIRMWARE_VOLUME_HEADER *) FvImage;\r
-  FvImage                   = FvImage + FvHeader->HeaderLength;\r
-\r
-  VarStoreHeader            = (VARIABLE_STORE_HEADER *) FvImage;\r
-\r
-  VarStoreHeader->Signature = VARIABLE_STORE_SIGNATURE;\r
-  VarStoreHeader->Size      = Size - FvHeader->HeaderLength;\r
-  VarStoreHeader->Format    = VARIABLE_STORE_FORMATTED;\r
-  VarStoreHeader->State     = VARIABLE_STORE_HEALTHY;\r
-  VarStoreHeader->Reserved  = 0;\r
-  VarStoreHeader->Reserved1 = 0;\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-AddEventLogBlock (\r
-  IN UINT8                    *FvImage,\r
-  IN UINTN                    Size,\r
-  IN FV_INFO                  *FvInfo\r
-  )\r
-{\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-AddFTWWorkingBlock (\r
-  IN UINT8                    *FvImage,\r
-  IN UINTN                    Size,\r
-  IN FV_INFO                  *FvInfo\r
-  )\r
-{\r
-  EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER *FTWHeader;\r
-  UINT32                                  Crc32;\r
-\r
-  Crc32     = 0;\r
-  FTWHeader = (EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER *) FvImage;\r
-  memcpy (&FTWHeader->Signature, &(FvInfo->FvGuid), sizeof (EFI_GUID));\r
-  FTWHeader->WriteQueueSize = Size - sizeof (EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER);\r
-  CalculateCrc32 (FvImage, sizeof (EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER), &Crc32);\r
-  FTWHeader->Crc = Crc32;\r
-  if (FvInfo->FvAttributes & EFI_FVB_ERASE_POLARITY) {\r
-    FTWHeader->WorkingBlockValid    = 0;\r
-    FTWHeader->WorkingBlockInvalid  = 1;\r
-  } else {\r
-    FTWHeader->WorkingBlockValid    = 1;\r
-    FTWHeader->WorkingBlockInvalid  = 0;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-AddFTWSpareBlock (\r
-  IN UINT8                    *FvImage,\r
-  IN UINTN                    Size,\r
-  IN FV_INFO                  *FvInfo\r
-  )\r
-{\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-GenNonFFSFv (\r
-  IN UINT8                    *FvImage,\r
-  IN FV_INFO                  *FvInfo\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  This function generate the non FFS FV image, such as the working block\r
-  and spare block. How each component of the FV is built is component\r
-  specific.\r
-\r
-Arguments:\r
-\r
-  FvImage       The memory image of the FV to add it to.  The current offset\r
-                must be valid.\r
-  FvInfo        Pointer to information about the FV.\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS              The function completed successfully.\r
-  EFI_INVALID_PARAMETER    One of the input parameters was invalid.\r
-  EFI_ABORTED              An error occurred.\r
-  EFI_OUT_OF_RESOURCES     Insufficient resources exist to complete the add.\r
-\r
---*/\r
-{\r
-  UINTN                       Index;\r
-  EFI_FIRMWARE_VOLUME_HEADER  *FvHeader;\r
-  UINT64                      TotalSize;\r
-\r
-  FvHeader  = (EFI_FIRMWARE_VOLUME_HEADER *) FvImage;\r
-  TotalSize = 0;\r
-\r
-  for (Index = 0; FvInfo->FvComponents[Index].Size != 0; Index++) {\r
-    if (stricmp (FvInfo->FvComponents[Index].ComponentName, EFI_NV_VARIABLE_STRING) == 0) {\r
-      AddVariableBlock (FvImage, FvInfo->FvComponents[Index].Size, FvInfo);\r
-    } else if (stricmp (FvInfo->FvComponents[Index].ComponentName, EFI_NV_EVENT_LOG_STRING) == 0) {\r
-      AddEventLogBlock (FvImage, FvInfo->FvComponents[Index].Size, FvInfo);\r
-    } else if (stricmp (FvInfo->FvComponents[Index].ComponentName, EFI_NV_FTW_WORKING_STRING) == 0) {\r
-      AddFTWWorkingBlock (FvImage, FvInfo->FvComponents[Index].Size, FvInfo);\r
-    } else if (stricmp (FvInfo->FvComponents[Index].ComponentName, EFI_NV_FTW_SPARE_STRING) == 0) {\r
-      AddFTWSpareBlock (FvImage, FvInfo->FvComponents[Index].Size, FvInfo);\r
-    } else {\r
-      printf ("Error. Unknown Non-FFS block %s \n", FvInfo->FvComponents[Index].ComponentName);\r
-      return EFI_ABORTED;\r
-    }\r
-\r
-    FvImage   = FvImage + FvInfo->FvComponents[Index].Size;\r
-    TotalSize = TotalSize + FvInfo->FvComponents[Index].Size;\r
-  }\r
-  //\r
-  // Index and TotalSize is zero mean there's no component, so this is an empty fv\r
-  //\r
-  if ((Index != 0 || TotalSize != 0) && TotalSize != FvInfo->Size) {\r
-    printf ("Error. Component size does not sum up to FV size.\n");\r
-    return EFI_ABORTED;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-PadFvImage (\r
-  IN MEMORY_FILE          *FvImage,\r
-  IN EFI_FFS_FILE_HEADER  *VtfFileImage\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  This function places a pad file between the last file in the FV and the VTF\r
-  file if the VTF file exists.\r
-\r
-Arguments:\r
-\r
-  FvImage       Memory file for the FV memory image\r
-  VtfFileImage  The address of the VTF file.  If this is the end of the FV\r
-                image, no VTF exists and no pad file is needed.\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS             Completed successfully.\r
-  EFI_INVALID_PARAMETER   One of the input parameters was NULL.\r
-\r
---*/\r
-{\r
-  EFI_FFS_FILE_HEADER *PadFile;\r
-  UINTN               FileSize;\r
-\r
-  //\r
-  // If there is no VTF or the VTF naturally follows the previous file without a\r
-  // pad file, then there's nothing to do\r
-  //\r
-  if ((UINTN) VtfFileImage == (UINTN) FvImage->Eof || (void *) FvImage->CurrentFilePointer == (void *) VtfFileImage) {\r
-    return EFI_SUCCESS;\r
-  }\r
-  //\r
-  // Pad file starts at beginning of free space\r
-  //\r
-  PadFile = (EFI_FFS_FILE_HEADER *) FvImage->CurrentFilePointer;\r
-\r
-  //\r
-  // write header\r
-  //\r
-  memset (PadFile, 0, sizeof (EFI_FFS_FILE_HEADER));\r
-  memcpy (&PadFile->Name, &DefaultFvPadFileNameGuid, sizeof (EFI_GUID));\r
-  PadFile->Type       = EFI_FV_FILETYPE_FFS_PAD;\r
-  PadFile->Attributes = 0;\r
-\r
-  //\r
-  // FileSize includes the EFI_FFS_FILE_HEADER\r
-  //\r
-  FileSize          = (UINTN) VtfFileImage - (UINTN) FvImage->CurrentFilePointer;\r
-  PadFile->Size[0]  = (UINT8) (FileSize & 0x000000FF);\r
-  PadFile->Size[1]  = (UINT8) ((FileSize & 0x0000FF00) >> 8);\r
-  PadFile->Size[2]  = (UINT8) ((FileSize & 0x00FF0000) >> 16);\r
-\r
-  //\r
-  // Fill in checksums and state, must be zero during checksum calculation.\r
-  //\r
-  PadFile->IntegrityCheck.Checksum.Header = 0;\r
-  PadFile->IntegrityCheck.Checksum.File   = 0;\r
-  PadFile->State                          = 0;\r
-  PadFile->IntegrityCheck.Checksum.Header = CalculateChecksum8 ((UINT8 *) PadFile, sizeof (EFI_FFS_FILE_HEADER));\r
-  if (PadFile->Attributes & FFS_ATTRIB_CHECKSUM) {\r
-    PadFile->IntegrityCheck.Checksum.File = CalculateChecksum8 ((UINT8 *) PadFile, FileSize);\r
-  } else {\r
-    PadFile->IntegrityCheck.Checksum.File = FFS_FIXED_CHECKSUM;\r
-  }\r
-\r
-  PadFile->State = EFI_FILE_HEADER_CONSTRUCTION | EFI_FILE_HEADER_VALID | EFI_FILE_DATA_VALID;\r
-\r
-  UpdateFfsFileState (\r
-    (EFI_FFS_FILE_HEADER *) PadFile,\r
-    (EFI_FIRMWARE_VOLUME_HEADER *) FvImage->FileImage\r
-    );\r
-  //\r
-  // Update the current FV pointer\r
-  //\r
-  FvImage->CurrentFilePointer = FvImage->Eof;\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-UpdateResetVector (\r
-  IN MEMORY_FILE            *FvImage,\r
-  IN FV_INFO                *FvInfo,\r
-  IN EFI_FFS_FILE_HEADER    *VtfFile\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  This parses the FV looking for the PEI core and then plugs the address into\r
-  the SALE_ENTRY point of the BSF/VTF for IPF and does BUGBUG TBD action to\r
-  complete an IA32 Bootstrap FV.\r
-\r
-Arguments:\r
-\r
-  FvImage       Memory file for the FV memory image\r
-  FvInfo        Information read from INF file.\r
-  VtfFile       Pointer to the VTF file in the FV image.\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS             Function Completed successfully.\r
-  EFI_ABORTED             Error encountered.\r
-  EFI_INVALID_PARAMETER   A required parameter was NULL.\r
-  EFI_NOT_FOUND           PEI Core file not found.\r
-\r
---*/\r
-{\r
-  EFI_FFS_FILE_HEADER       *PeiCoreFile;\r
-  EFI_FFS_FILE_HEADER       *SecCoreFile;\r
-  EFI_STATUS                Status;\r
-  EFI_FILE_SECTION_POINTER  Pe32Section;\r
-  UINT32                    EntryPoint;\r
-  UINT32                    BaseOfCode;\r
-  UINT16                    MachineType;\r
-  EFI_PHYSICAL_ADDRESS      PeiCorePhysicalAddress;\r
-  EFI_PHYSICAL_ADDRESS      SecCorePhysicalAddress;\r
-  EFI_PHYSICAL_ADDRESS      *SecCoreEntryAddressPtr;\r
-  UINT32                    *Ia32ResetAddressPtr;\r
-  UINT8                     *BytePointer;\r
-  UINT8                     *BytePointer2;\r
-  UINT16                    *WordPointer;\r
-  UINT16                    CheckSum;\r
-  UINTN                     Index;\r
-  EFI_FFS_FILE_STATE        SavedState;\r
-  EFI_FFS_FILE_TAIL         TailValue;\r
-  UINT32                    TailSize;\r
-  UINT64                    FitAddress;\r
-  FIT_TABLE                 *FitTablePtr;\r
-\r
-  //\r
-  // Verify input parameters\r
-  //\r
-  if (FvImage == NULL || FvInfo == NULL || VtfFile == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-  //\r
-  // Initialize FV library\r
-  //\r
-  InitializeFvLib (FvImage->FileImage, (UINTN) FvImage->Eof - (UINTN) FvImage->FileImage);\r
-\r
-  //\r
-  // Verify VTF file\r
-  //\r
-  Status = VerifyFfsFile (VtfFile);\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-  //\r
-  // Find the PEI Core\r
-  //\r
-  Status = GetFileByType (EFI_FV_FILETYPE_PEI_CORE, 1, &PeiCoreFile);\r
-  if (EFI_ERROR (Status) || PeiCoreFile == NULL) {\r
-    Error (NULL, 0, 0, "could not find the PEI core in the FV", NULL);\r
-    return EFI_ABORTED;\r
-  }\r
-\r
-  //\r
-  // PEI Core found, now find PE32 or TE section\r
-  //\r
-  Status = GetSectionByType (PeiCoreFile, EFI_SECTION_PE32, 1, &Pe32Section);\r
-  if (Status == EFI_NOT_FOUND) {\r
-    Status = GetSectionByType (PeiCoreFile, EFI_SECTION_TE, 1, &Pe32Section);\r
-  }\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    Error (NULL, 0, 0, "could not find PE32 or TE section in PEI core file", NULL);\r
-    return EFI_ABORTED;\r
-  }\r
-\r
-  Status = GetPe32Info (\r
-            (VOID *) ((UINTN) Pe32Section.Pe32Section + sizeof (EFI_SECTION_PE32)),\r
-            &EntryPoint,\r
-            &BaseOfCode,\r
-            &MachineType\r
-            );\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    Error (NULL, 0, 0, "could not get PE32 entry point for PEI core", NULL);\r
-    return EFI_ABORTED;\r
-  }\r
-  //\r
-  // Physical address is FV base + offset of PE32 + offset of the entry point\r
-  //\r
-  PeiCorePhysicalAddress = FvInfo->BaseAddress;\r
-  PeiCorePhysicalAddress += (UINTN) Pe32Section.Pe32Section + sizeof (EFI_SECTION_PE32) - (UINTN) FvImage->FileImage;\r
-  PeiCorePhysicalAddress += EntryPoint;\r
-\r
-  if (MachineType == EFI_IMAGE_MACHINE_IA64) {\r
-    //\r
-    // Update PEI_CORE address\r
-    //\r
-    //\r
-    // Set the uncached attribute bit in the physical address\r
-    //\r
-    PeiCorePhysicalAddress |= 0x8000000000000000ULL;\r
-\r
-    //\r
-    // Check if address is aligned on a 16 byte boundary\r
-    //\r
-    if (PeiCorePhysicalAddress & 0xF) {\r
-      printf (\r
-        "ERROR: PEI_CORE entry point is not aligned on a 16 byte boundary, address specified is %Xh.\n",\r
-        PeiCorePhysicalAddress\r
-        );\r
-      return EFI_ABORTED;\r
-    }\r
-    //\r
-    // First Get the FIT table address\r
-    //\r
-    FitAddress  = (*(UINT64 *) (FvImage->Eof - IPF_FIT_ADDRESS_OFFSET)) & 0xFFFFFFFF;\r
-\r
-    FitTablePtr = (FIT_TABLE *) (FvImage->FileImage + (FitAddress - FvInfo->BaseAddress));\r
-\r
-    Status      = UpdatePeiCoreEntryInFit (FitTablePtr, PeiCorePhysicalAddress);\r
-\r
-    if (!EFI_ERROR (Status)) {\r
-      UpdateFitCheckSum (FitTablePtr);\r
-    }\r
-    //\r
-    // Find the Sec Core\r
-    //\r
-    Status = GetFileByType (EFI_FV_FILETYPE_SECURITY_CORE, 1, &SecCoreFile);\r
-    if (EFI_ERROR (Status) || SecCoreFile == NULL) {\r
-      Error (NULL, 0, 0, "could not find the Sec core in the FV", NULL);\r
-      return EFI_ABORTED;\r
-    }\r
-    //\r
-    // Sec Core found, now find PE32 section\r
-    //\r
-    Status = GetSectionByType (SecCoreFile, EFI_SECTION_PE32, 1, &Pe32Section);\r
-    if (EFI_ERROR (Status)) {\r
-      Error (NULL, 0, 0, "could not find PE32 section in SEC core file", NULL);\r
-      return EFI_ABORTED;\r
-    }\r
-\r
-    Status = GetPe32Info (\r
-              (VOID *) ((UINTN) Pe32Section.Pe32Section + sizeof (EFI_SECTION_PE32)),\r
-              &EntryPoint,\r
-              &BaseOfCode,\r
-              &MachineType\r
-              );\r
-    if (EFI_ERROR (Status)) {\r
-      Error (NULL, 0, 0, "could not get PE32 entry point for SEC core", NULL);\r
-      return EFI_ABORTED;\r
-    }\r
-    //\r
-    // Physical address is FV base + offset of PE32 + offset of the entry point\r
-    //\r
-    SecCorePhysicalAddress = FvInfo->BaseAddress;\r
-    SecCorePhysicalAddress += (UINTN) Pe32Section.Pe32Section + sizeof (EFI_SECTION_PE32) - (UINTN) FvImage->FileImage;\r
-    SecCorePhysicalAddress += EntryPoint;\r
-\r
-    //\r
-    // Update SEC_CORE address\r
-    //\r
-    //\r
-    // Set the uncached attribute bit in the physical address\r
-    //\r
-    SecCorePhysicalAddress |= 0x8000000000000000ULL;\r
-\r
-    //\r
-    // Update the address\r
-    //\r
-    SecCoreEntryAddressPtr  = (EFI_PHYSICAL_ADDRESS *) ((UINTN) FvImage->Eof - IPF_SALE_ENTRY_ADDRESS_OFFSET);\r
-    *SecCoreEntryAddressPtr = SecCorePhysicalAddress;\r
-\r
-    //\r
-    // Check if address is aligned on a 16 byte boundary\r
-    //\r
-    if (SecCorePhysicalAddress & 0xF) {\r
-      printf (\r
-        "ERROR: SALE_ENTRY entry point is not aligned on a 16 byte boundary, address specified is %Xh.\n",\r
-        SecCorePhysicalAddress\r
-        );\r
-      return EFI_ABORTED;\r
-    }\r
-  } else if (MachineType == EFI_IMAGE_MACHINE_IA32) {\r
-    //\r
-    // Get the location to update\r
-    //\r
-    Ia32ResetAddressPtr = (UINT32 *) ((UINTN) FvImage->Eof - IA32_PEI_CORE_ENTRY_OFFSET);\r
-\r
-    //\r
-    // Write lower 32 bits of physical address\r
-    //\r
-    *Ia32ResetAddressPtr = (UINT32) PeiCorePhysicalAddress;\r
-\r
-    //\r
-    // Update the BFV base address\r
-    //\r
-    Ia32ResetAddressPtr   = (UINT32 *) ((UINTN) FvImage->Eof - 4);\r
-    *Ia32ResetAddressPtr  = (UINT32) (FvInfo->BaseAddress);\r
-\r
-    CheckSum              = 0x0000;\r
-\r
-    //\r
-    // Update the Startup AP in the FVH header block ZeroVector region.\r
-    //\r
-    BytePointer   = (UINT8 *) ((UINTN) FvImage->FileImage);\r
-    BytePointer2  = (FvInfo->Size == 0x10000) ? m64kRecoveryStartupApDataArray : m128kRecoveryStartupApDataArray;\r
-    for (Index = 0; Index < SIZEOF_STARTUP_DATA_ARRAY; Index++) {\r
-      *BytePointer++ = *BytePointer2++;\r
-    }\r
-    //\r
-    // Calculate the checksum\r
-    //\r
-    WordPointer = (UINT16 *) ((UINTN) FvImage->FileImage);\r
-    for (Index = 0; Index < SIZEOF_STARTUP_DATA_ARRAY / 2; Index++) {\r
-      CheckSum = (UINT16) (CheckSum + ((UINT16) *WordPointer));\r
-      WordPointer++;\r
-    }\r
-    //\r
-    // Update the checksum field\r
-    //\r
-    BytePointer = (UINT8 *) ((UINTN) FvImage->FileImage);\r
-    BytePointer += (SIZEOF_STARTUP_DATA_ARRAY - 2);\r
-    WordPointer   = (UINT16 *) BytePointer;\r
-    *WordPointer  = (UINT16) (0x10000 - (UINT32) CheckSum);\r
-  } else {\r
-    Error (NULL, 0, 0, "invalid machine type in PEI core", "machine type=0x%X", (UINT32) MachineType);\r
-    return EFI_ABORTED;\r
-  }\r
-  //\r
-  // Determine if it has an FFS file tail.\r
-  //\r
-  if (VtfFile->Attributes & FFS_ATTRIB_TAIL_PRESENT) {\r
-    TailSize = sizeof (EFI_FFS_FILE_TAIL);\r
-  } else {\r
-    TailSize = 0;\r
-  }\r
-  //\r
-  // Now update file checksum\r
-  //\r
-  SavedState  = VtfFile->State;\r
-  VtfFile->IntegrityCheck.Checksum.File = 0;\r
-  VtfFile->State                        = 0;\r
-  if (VtfFile->Attributes & FFS_ATTRIB_CHECKSUM) {\r
-    VtfFile->IntegrityCheck.Checksum.File = CalculateChecksum8 (\r
-                                              (UINT8 *) VtfFile,\r
-                                              GetLength (VtfFile->Size) - TailSize\r
-                                              );\r
-  } else {\r
-    VtfFile->IntegrityCheck.Checksum.File = FFS_FIXED_CHECKSUM;\r
-  }\r
-\r
-  VtfFile->State = SavedState;\r
-\r
-  //\r
-  // Update tail if present\r
-  //\r
-  if (VtfFile->Attributes & FFS_ATTRIB_TAIL_PRESENT) {\r
-    TailValue = (EFI_FFS_FILE_TAIL) (~(VtfFile->IntegrityCheck.TailReference));\r
-    *(EFI_FFS_FILE_TAIL *) (((UINTN) (VtfFile) + GetLength (VtfFile->Size) - sizeof (EFI_FFS_FILE_TAIL))) = TailValue;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-GetPe32Info (\r
-  IN UINT8                  *Pe32,\r
-  OUT UINT32                *EntryPoint,\r
-  OUT UINT32                *BaseOfCode,\r
-  OUT UINT16                *MachineType\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Retrieves the PE32 entry point offset and machine type from PE image or TeImage.  \r
-  See EfiImage.h for machine types.  The entry point offset is from the beginning \r
-  of the PE32 buffer passed in.\r
-\r
-Arguments:\r
-\r
-  Pe32          Beginning of the PE32.\r
-  EntryPoint    Offset from the beginning of the PE32 to the image entry point.\r
-  BaseOfCode    Base address of code.\r
-  MachineType   Magic number for the machine type.\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS             Function completed successfully.\r
-  EFI_ABORTED             Error encountered.\r
-  EFI_INVALID_PARAMETER   A required parameter was NULL.\r
-  EFI_UNSUPPORTED         The operation is unsupported.\r
-\r
---*/\r
-{\r
-  EFI_IMAGE_DOS_HEADER  *DosHeader;\r
-  EFI_IMAGE_NT_HEADERS  *NtHeader;\r
-  EFI_TE_IMAGE_HEADER   *TeHeader;\r
-\r
-  //\r
-  // Verify input parameters\r
-  //\r
-  if (Pe32 == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  //\r
-  // First check whether it is one TE Image.\r
-  //\r
-  TeHeader = (EFI_TE_IMAGE_HEADER *) Pe32;\r
-  if (TeHeader->Signature == EFI_TE_IMAGE_HEADER_SIGNATURE) {\r
-    //\r
-    // By TeImage Header to get output\r
-    //\r
-    *EntryPoint   = TeHeader->AddressOfEntryPoint + sizeof (EFI_TE_IMAGE_HEADER) - TeHeader->StrippedSize;\r
-    *BaseOfCode   = TeHeader->BaseOfCode + sizeof (EFI_TE_IMAGE_HEADER) - TeHeader->StrippedSize;\r
-    *MachineType  = TeHeader->Machine;\r
-  } else {\r
-  \r
-    //\r
-    // Then check whether \r
-    // First is the DOS header\r
-    //\r
-    DosHeader = (EFI_IMAGE_DOS_HEADER *) Pe32;\r
-  \r
-    //\r
-    // Verify DOS header is expected\r
-    //\r
-    if (DosHeader->e_magic != EFI_IMAGE_DOS_SIGNATURE) {\r
-      printf ("ERROR: Unknown magic number in the DOS header, 0x%04X.\n", DosHeader->e_magic);\r
-      return EFI_UNSUPPORTED;\r
-    }\r
-    //\r
-    // Immediately following is the NT header.\r
-    //\r
-    NtHeader = (EFI_IMAGE_NT_HEADERS *) ((UINTN) Pe32 + DosHeader->e_lfanew);\r
-  \r
-    //\r
-    // Verify NT header is expected\r
-    //\r
-    if (NtHeader->Signature != EFI_IMAGE_NT_SIGNATURE) {\r
-      printf ("ERROR: Unrecognized image signature 0x%08X.\n", NtHeader->Signature);\r
-      return EFI_UNSUPPORTED;\r
-    }\r
-    //\r
-    // Get output\r
-    //\r
-    *EntryPoint   = NtHeader->OptionalHeader.AddressOfEntryPoint;\r
-    *BaseOfCode   = NtHeader->OptionalHeader.BaseOfCode;\r
-    *MachineType  = NtHeader->FileHeader.Machine;\r
-  }\r
-\r
-  //\r
-  // Verify machine type is supported\r
-  //\r
-  if (*MachineType != EFI_IMAGE_MACHINE_IA32 && *MachineType != EFI_IMAGE_MACHINE_IA64 && *MachineType != EFI_IMAGE_MACHINE_X64 && *MachineType != EFI_IMAGE_MACHINE_EBC) {\r
-    printf ("ERROR: Unrecognized machine type in the PE32 file.\n");\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-//\r
-// Exposed function implementations (prototypes are defined in GenFvImageLib.h)\r
-//\r
-EFI_STATUS\r
-GenerateFvImage (\r
-  IN CHAR8    *InfFileImage,\r
-  IN UINTN    InfFileSize,\r
-  OUT UINT8   **FvImage,\r
-  OUT UINTN   *FvImageSize,\r
-  OUT CHAR8   **FvFileName,\r
-  OUT UINT8   **SymImage,\r
-  OUT UINTN   *SymImageSize,\r
-  OUT CHAR8   **SymFileName\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  This is the main function which will be called from application.\r
-\r
-Arguments:\r
-\r
-  InfFileImage  Buffer containing the INF file contents.\r
-  InfFileSize   Size of the contents of the InfFileImage buffer.\r
-  FvImage       Pointer to the FV image created.\r
-  FvImageSize   Size of the FV image created and pointed to by FvImage.\r
-  FvFileName    Requested name for the FV file.\r
-  SymImage      Pointer to the Sym image created.\r
-  SymImageSize  Size of the Sym image created and pointed to by SymImage.\r
-  SymFileName   Requested name for the Sym file.\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS             Function completed successfully.\r
-  EFI_OUT_OF_RESOURCES    Could not allocate required resources.\r
-  EFI_ABORTED             Error encountered.\r
-  EFI_INVALID_PARAMETER   A required parameter was NULL.\r
-\r
---*/\r
-{\r
-  EFI_STATUS                  Status;\r
-  MEMORY_FILE                 InfMemoryFile;\r
-  MEMORY_FILE                 FvImageMemoryFile;\r
-  MEMORY_FILE                 SymImageMemoryFile;\r
-  FV_INFO                     FvInfo;\r
-  UINTN                       Index;\r
-  EFI_FIRMWARE_VOLUME_HEADER  *FvHeader;\r
-  EFI_FFS_FILE_HEADER         *VtfFileImage;\r
-\r
-  //\r
-  // Check for invalid parameter\r
-  //\r
-  if (InfFileImage == NULL || FvImage == NULL || FvImageSize == NULL || FvFileName == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-  //\r
-  // Initialize file structures\r
-  //\r
-  InfMemoryFile.FileImage           = InfFileImage;\r
-  InfMemoryFile.CurrentFilePointer  = InfFileImage;\r
-  InfMemoryFile.Eof                 = InfFileImage + InfFileSize;\r
-\r
-  //\r
-  // Parse the FV inf file for header information\r
-  //\r
-  Status = ParseFvInf (&InfMemoryFile, &FvInfo);\r
-  if (EFI_ERROR (Status)) {\r
-    printf ("ERROR: Could not parse the input INF file.\n");\r
-    return EFI_ABORTED;\r
-  }\r
-  //\r
-  // Update the file name return values\r
-  //\r
-  strcpy (*FvFileName, FvInfo.FvName);\r
-  strcpy (*SymFileName, FvInfo.SymName);\r
-\r
-  //\r
-  // Calculate the FV size\r
-  //\r
-  *FvImageSize = FvInfo.Size;\r
-\r
-  //\r
-  // Allocate the FV\r
-  //\r
-  *FvImage = malloc (*FvImageSize);\r
-  if (*FvImage == NULL) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-  //\r
-  // Allocate space for symbol file storage\r
-  //\r
-  *SymImage = malloc (SYMBOL_FILE_SIZE);\r
-  if (*SymImage == NULL) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-  //\r
-  // Initialize the FV to the erase polarity\r
-  //\r
-  if (FvInfo.FvAttributes & EFI_FVB_ERASE_POLARITY) {\r
-    memset (*FvImage, -1, *FvImageSize);\r
-  } else {\r
-    memset (*FvImage, 0, *FvImageSize);\r
-  }\r
-  //\r
-  // Initialize FV header\r
-  //\r
-  FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *) *FvImage;\r
-\r
-  //\r
-  // Initialize the zero vector to all zeros.\r
-  //\r
-  memset (FvHeader->ZeroVector, 0, 16);\r
-\r
-  //\r
-  // Copy the FFS GUID\r
-  //\r
-  memcpy (&FvHeader->FileSystemGuid, &FvInfo.FvGuid, sizeof (EFI_GUID));\r
-\r
-  FvHeader->FvLength    = *FvImageSize;\r
-  FvHeader->Signature   = EFI_FVH_SIGNATURE;\r
-  FvHeader->Attributes  = FvInfo.FvAttributes;\r
-  FvHeader->Revision    = EFI_FVH_REVISION;\r
-  FvHeader->Reserved[0] = 0;\r
-  FvHeader->Reserved[1] = 0;\r
-  FvHeader->Reserved[2] = 0;\r
-\r
-  //\r
-  // Copy firmware block map\r
-  //\r
-  for (Index = 0; FvInfo.FvBlocks[Index].NumBlocks != 0; Index++) {\r
-    FvHeader->FvBlockMap[Index].NumBlocks   = FvInfo.FvBlocks[Index].NumBlocks;\r
-    FvHeader->FvBlockMap[Index].BlockLength = FvInfo.FvBlocks[Index].BlockLength;\r
-  }\r
-  //\r
-  // Add block map terminator\r
-  //\r
-  FvHeader->FvBlockMap[Index].NumBlocks   = 0;\r
-  FvHeader->FvBlockMap[Index].BlockLength = 0;\r
-\r
-  //\r
-  // Complete the header\r
-  //\r
-  FvHeader->HeaderLength  = (UINT16) (((UINTN) &(FvHeader->FvBlockMap[Index + 1])) - (UINTN) *FvImage);\r
-  FvHeader->Checksum      = 0;\r
-  FvHeader->Checksum      = CalculateChecksum16 ((UINT16 *) FvHeader, FvHeader->HeaderLength / sizeof (UINT16));\r
-\r
-  //\r
-  // If there is no FFS file, find and generate each components of the FV\r
-  //\r
-  if (FvInfo.FvFiles[0][0] == 0) {\r
-    Status = GenNonFFSFv (*FvImage, &FvInfo);\r
-    if (EFI_ERROR (Status)) {\r
-      printf ("ERROR: Could not generate NonFFS FV.\n");\r
-      free (*FvImage);\r
-      return EFI_ABORTED;\r
-    }\r
-\r
-    return EFI_SUCCESS;\r
-  }\r
-  //\r
-  // Initialize our "file" view of the buffer\r
-  //\r
-  FvImageMemoryFile.FileImage           = *FvImage;\r
-  FvImageMemoryFile.CurrentFilePointer  = *FvImage + FvHeader->HeaderLength;\r
-  FvImageMemoryFile.Eof                 = *FvImage +*FvImageSize;\r
-\r
-  //\r
-  // Initialize our "file" view of the symbol file.\r
-  //\r
-  SymImageMemoryFile.FileImage          = *SymImage;\r
-  SymImageMemoryFile.CurrentFilePointer = *SymImage;\r
-  SymImageMemoryFile.Eof                = *FvImage + SYMBOL_FILE_SIZE;\r
-\r
-  //\r
-  // Initialize the FV library.\r
-  //\r
-  InitializeFvLib (FvImageMemoryFile.FileImage, FvInfo.Size);\r
-\r
-  //\r
-  // Files start on 8 byte alignments, so move to the next 8 byte aligned\r
-  // address.  For now, just assert if it isn't.  Currently FV header is\r
-  // always a multiple of 8 bytes.\r
-  // BUGBUG: Handle this better\r
-  //\r
-  assert ((((UINTN) FvImageMemoryFile.CurrentFilePointer) % 8) == 0);\r
-\r
-  //\r
-  // Initialize the VTF file address.\r
-  //\r
-  VtfFileImage = (EFI_FFS_FILE_HEADER *) FvImageMemoryFile.Eof;\r
-\r
-  //\r
-  // Add files to FV\r
-  //\r
-  for (Index = 0; FvInfo.FvFiles[Index][0] != 0; Index++) {\r
-    //\r
-    // Add the file\r
-    //\r
-    Status = AddFile (&FvImageMemoryFile, &FvInfo, Index, &VtfFileImage, &SymImageMemoryFile);\r
-\r
-    //\r
-    // Exit if error detected while adding the file\r
-    //\r
-    if (EFI_ERROR (Status)) {\r
-      printf ("ERROR: Could not add file %s.\n", FvInfo.FvFiles[Index]);\r
-      free (*FvImage);\r
-      return EFI_ABORTED;\r
-    }\r
-  }\r
-  //\r
-  // If there is a VTF file, some special actions need to occur.\r
-  //\r
-  if ((UINTN) VtfFileImage != (UINTN) FvImageMemoryFile.Eof) {\r
-    //\r
-    // Pad from the end of the last file to the beginning of the VTF file.\r
-    //\r
-    Status = PadFvImage (&FvImageMemoryFile, VtfFileImage);\r
-    if (EFI_ERROR (Status)) {\r
-      printf ("ERROR: Could not create the pad file between the last file and the VTF file.\n");\r
-      free (*FvImage);\r
-      return EFI_ABORTED;\r
-    }\r
-    //\r
-    // Update reset vector (SALE_ENTRY for IPF)\r
-    // Now for IA32 and IA64 platform, the fv which has bsf file must have the \r
-    // EndAddress of 0xFFFFFFFF. Thus, only this type fv needs to update the   \r
-    // reset vector. If the PEI Core is found, the VTF file will probably get  \r
-    // corrupted by updating the entry point.                                  \r
-    //\r
-    if ((FvInfo.BaseAddress + FvInfo.Size) == FV_IMAGES_TOP_ADDRESS) {       \r
-      Status = UpdateResetVector (&FvImageMemoryFile, &FvInfo, VtfFileImage);\r
-      if (EFI_ERROR(Status)) {                                               \r
-        printf ("ERROR: Could not update the reset vector.\n");              \r
-        free (*FvImage);                                                     \r
-        return EFI_ABORTED;                                                  \r
-      }                                                                      \r
-    }\r
-  } \r
-  //\r
-  // Determine final Sym file size\r
-  //\r
-  *SymImageSize = SymImageMemoryFile.CurrentFilePointer - SymImageMemoryFile.FileImage;\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-UpdatePeiCoreEntryInFit (\r
-  IN FIT_TABLE     *FitTablePtr,\r
-  IN UINT64        PeiCorePhysicalAddress\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  This function is used to update the Pei Core address in FIT, this can be used by Sec core to pass control from\r
-  Sec to Pei Core\r
-\r
-Arguments:\r
-\r
-  FitTablePtr             - The pointer of FIT_TABLE.\r
-  PeiCorePhysicalAddress  - The address of Pei Core entry.\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS             - The PEI_CORE FIT entry was updated successfully.\r
-  EFI_NOT_FOUND           - Not found the PEI_CORE FIT entry.\r
-\r
---*/\r
-{\r
-  FIT_TABLE *TmpFitPtr;\r
-  UINTN     Index;\r
-  UINTN     NumFitComponents;\r
-\r
-  TmpFitPtr         = FitTablePtr;\r
-  NumFitComponents  = TmpFitPtr->CompSize;\r
-\r
-  for (Index = 0; Index < NumFitComponents; Index++) {\r
-    if ((TmpFitPtr->CvAndType & FIT_TYPE_MASK) == COMP_TYPE_FIT_PEICORE) {\r
-      TmpFitPtr->CompAddress = PeiCorePhysicalAddress;\r
-      return EFI_SUCCESS;\r
-    }\r
-\r
-    TmpFitPtr++;\r
-  }\r
-\r
-  return EFI_NOT_FOUND;\r
-}\r
-\r
-VOID\r
-UpdateFitCheckSum (\r
-  IN FIT_TABLE   *FitTablePtr\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  This function is used to update the checksum for FIT.\r
-\r
-\r
-Arguments:\r
-\r
-  FitTablePtr             - The pointer of FIT_TABLE.\r
-\r
-Returns:\r
-\r
-  None.\r
-\r
---*/\r
-{\r
-  if ((FitTablePtr->CvAndType & CHECKSUM_BIT_MASK) >> 7) {\r
-    FitTablePtr->CheckSum = 0;\r
-    FitTablePtr->CheckSum = CalculateChecksum8 ((UINT8 *) FitTablePtr, FitTablePtr->CompSize * 16);\r
-  }\r
-}\r
diff --git a/Tools/CodeTools/TianoTools/GenFvImage/GenFvImageLib.h b/Tools/CodeTools/TianoTools/GenFvImage/GenFvImageLib.h
deleted file mode 100644 (file)
index 47a5a3b..0000000
+++ /dev/null
@@ -1,142 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2004, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-Module Name:\r
-  \r
-  GenFvImageLib.h\r
-\r
-Abstract:\r
-\r
-  This file contains describes the public interfaces to the GenFvImage Library.\r
-  The basic purpose of the library is to create Firmware Volume images.\r
-\r
---*/\r
-\r
-#ifndef _EFI_GEN_FV_IMAGE_LIB_H\r
-#define _EFI_GEN_FV_IMAGE_LIB_H\r
-\r
-//\r
-// Include files\r
-//\r
-#include <Common/UefiBaseTypes.h>\r
-#include <Common/MultiPhase.h>\r
-\r
-#include "ParseInf.h"\r
-\r
-//\r
-// Following definition is used for FIT in IPF\r
-//\r
-#define COMP_TYPE_FIT_PEICORE 0x10\r
-#define COMP_TYPE_FIT_UNUSED  0x7F\r
-\r
-#define FIT_TYPE_MASK         0x7F\r
-#define CHECKSUM_BIT_MASK     0x80\r
-\r
-#pragma pack(1)\r
-\r
-typedef struct {\r
-  UINT64  CompAddress;\r
-  UINT32  CompSize;\r
-  UINT16  CompVersion;\r
-  UINT8   CvAndType;\r
-  UINT8   CheckSum;\r
-} FIT_TABLE;\r
-\r
-#pragma pack()\r
-//\r
-// Exported function prototypes\r
-//\r
-EFI_STATUS\r
-GenerateFvImage (\r
-  IN CHAR8    *InfFileImage,\r
-  IN UINTN    InfFileSize,\r
-  OUT UINT8   **FvImage,\r
-  OUT UINTN   *FvImageSize,\r
-  OUT CHAR8   **FvFileName,\r
-  OUT UINT8   **SymImage,\r
-  OUT UINTN   *SymImageSize,\r
-  OUT CHAR8   **SymFileName\r
-  )\r
-;\r
-\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  This is the main function which will be called from application.\r
-\r
-Arguments:\r
-\r
-  InfFileImage  Buffer containing the INF file contents.\r
-  InfFileSize   Size of the contents of the InfFileImage buffer.\r
-  FvImage       Pointer to the FV image created.\r
-  FvImageSize   Size of the FV image created and pointed to by FvImage.\r
-  FvFileName    Requested name for the FV file.\r
-  SymImage      Pointer to the Sym image created.\r
-  SymImageSize  Size of the Sym image created and pointed to by SymImage.\r
-  SymFileName   Requested name for the Sym file.\r
-    \r
-Returns:\r
\r
-  EFI_SUCCESS             Function completed successfully.\r
-  EFI_OUT_OF_RESOURCES    Could not allocate required resources.\r
-  EFI_ABORTED             Error encountered.\r
-  EFI_INVALID_PARAMETER   A required parameter was NULL.\r
-\r
---*/\r
-EFI_STATUS\r
-UpdatePeiCoreEntryInFit (\r
-  IN FIT_TABLE     *FitTablePtr,\r
-  IN UINT64        PeiCorePhysicalAddress\r
-  )\r
-;\r
-\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  This function is used to update the Pei Core address in FIT, this can be used by Sec core to pass control from\r
-  Sec to Pei Core\r
-\r
-Arguments:\r
-\r
-  FitTablePtr             - The pointer of FIT_TABLE.\r
-  PeiCorePhysicalAddress  - The address of Pei Core entry.\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS             - The PEI_CORE FIT entry was updated successfully.\r
-  EFI_NOT_FOUND           - Not found the PEI_CORE FIT entry.\r
-\r
---*/\r
-VOID\r
-UpdateFitCheckSum (\r
-  IN FIT_TABLE   *FitTablePtr\r
-  )\r
-;\r
-\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  This function is used to update the checksum for FIT.\r
-\r
-\r
-Arguments:\r
-\r
-  FitTablePtr             - The pointer of FIT_TABLE.\r
-\r
-Returns:\r
-\r
-  None.\r
-\r
---*/\r
-#endif\r
diff --git a/Tools/CodeTools/TianoTools/GenFvImage/GenFvImageLibInternal.h b/Tools/CodeTools/TianoTools/GenFvImage/GenFvImageLibInternal.h
deleted file mode 100644 (file)
index cff3b1a..0000000
+++ /dev/null
@@ -1,172 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2004, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-Module Name:\r
-  \r
-  GenFvImageLibInternal.h\r
-\r
-Abstract:\r
-\r
-  This file contains describes the private declarations for the GenFvImage Library.\r
-  The basic purpose of the library is to create Firmware Volume images.\r
-\r
---*/\r
-\r
-#ifndef _EFI_GEN_FV_IMAGE_LIB_INTERNAL_H\r
-#define _EFI_GEN_FV_IMAGE_LIB_INTERNAL_H\r
-\r
-//\r
-// Include files\r
-//\r
-#include <stdlib.h>\r
-\r
-#include <Common/FirmwareVolumeHeader.h>\r
-\r
-#include "CommonLib.h"\r
-#include "GenFvImageLib.h"\r
-\r
-//\r
-// Private data declarations\r
-//\r
-//\r
-// The maximum number of block map entries supported by the library\r
-//\r
-#define MAX_NUMBER_OF_FV_BLOCKS 100\r
-\r
-//\r
-// The maximum number of files in the FV supported by the library\r
-//\r
-#define MAX_NUMBER_OF_FILES_IN_FV       1000\r
-#define MAX_NUMBER_OF_COMPONENTS_IN_FV  10\r
-\r
-//\r
-// INF file strings\r
-//\r
-#define OPTIONS_SECTION_STRING            "[options]"\r
-#define ATTRIBUTES_SECTION_STRING         "[attributes]"\r
-#define FILES_SECTION_STRING              "[files]"\r
-#define COMPONENT_SECTION_STRING          "[components]"\r
-\r
-#define EFI_FV_BASE_ADDRESS_STRING        "EFI_BASE_ADDRESS"\r
-#define EFI_FV_FILE_NAME_STRING           "EFI_FILE_NAME"\r
-#define EFI_SYM_FILE_NAME_STRING          "EFI_SYM_FILE_NAME"\r
-#define EFI_NUM_BLOCKS_STRING             "EFI_NUM_BLOCKS"\r
-#define EFI_BLOCK_SIZE_STRING             "EFI_BLOCK_SIZE"\r
-#define EFI_FV_GUID_STRING                "EFI_FV_GUID"\r
-\r
-#define EFI_FVB_READ_DISABLED_CAP_STRING  "EFI_READ_DISABLED_CAP"\r
-#define EFI_FVB_READ_ENABLED_CAP_STRING   "EFI_READ_ENABLED_CAP"\r
-#define EFI_FVB_READ_STATUS_STRING        "EFI_READ_STATUS"\r
-\r
-#define EFI_FVB_WRITE_DISABLED_CAP_STRING "EFI_WRITE_DISABLED_CAP"\r
-#define EFI_FVB_WRITE_ENABLED_CAP_STRING  "EFI_WRITE_ENABLED_CAP"\r
-#define EFI_FVB_WRITE_STATUS_STRING       "EFI_WRITE_STATUS"\r
-\r
-#define EFI_FVB_LOCK_CAP_STRING           "EFI_LOCK_CAP"\r
-#define EFI_FVB_LOCK_STATUS_STRING        "EFI_LOCK_STATUS"\r
-\r
-#define EFI_FVB_STICKY_WRITE_STRING       "EFI_STICKY_WRITE"\r
-#define EFI_FVB_MEMORY_MAPPED_STRING      "EFI_MEMORY_MAPPED"\r
-#define EFI_FVB_ERASE_POLARITY_STRING     "EFI_ERASE_POLARITY"\r
-\r
-#define EFI_FVB_ALIGNMENT_CAP_STRING      "EFI_ALIGNMENT_CAP"\r
-#define EFI_FVB_ALIGNMENT_2_STRING        "EFI_ALIGNMENT_2"\r
-#define EFI_FVB_ALIGNMENT_4_STRING        "EFI_ALIGNMENT_4"\r
-#define EFI_FVB_ALIGNMENT_8_STRING        "EFI_ALIGNMENT_8"\r
-#define EFI_FVB_ALIGNMENT_16_STRING       "EFI_ALIGNMENT_16"\r
-#define EFI_FVB_ALIGNMENT_32_STRING       "EFI_ALIGNMENT_32"\r
-#define EFI_FVB_ALIGNMENT_64_STRING       "EFI_ALIGNMENT_64"\r
-#define EFI_FVB_ALIGNMENT_128_STRING      "EFI_ALIGNMENT_128"\r
-#define EFI_FVB_ALIGNMENT_256_STRING      "EFI_ALIGNMENT_256"\r
-#define EFI_FVB_ALIGNMENT_512_STRING      "EFI_ALIGNMENT_512"\r
-#define EFI_FVB_ALIGNMENT_1K_STRING       "EFI_ALIGNMENT_1K"\r
-#define EFI_FVB_ALIGNMENT_2K_STRING       "EFI_ALIGNMENT_2K"\r
-#define EFI_FVB_ALIGNMENT_4K_STRING       "EFI_ALIGNMENT_4K"\r
-#define EFI_FVB_ALIGNMENT_8K_STRING       "EFI_ALIGNMENT_8K"\r
-#define EFI_FVB_ALIGNMENT_16K_STRING      "EFI_ALIGNMENT_16K"\r
-#define EFI_FVB_ALIGNMENT_32K_STRING      "EFI_ALIGNMENT_32K"\r
-#define EFI_FVB_ALIGNMENT_64K_STRING      "EFI_ALIGNMENT_64K"\r
-\r
-//\r
-// Component sections\r
-//\r
-#define EFI_NV_VARIABLE_STRING    "EFI_NV_VARIABLE"\r
-#define EFI_NV_EVENT_LOG_STRING   "EFI_NV_EVENT_LOG"\r
-#define EFI_NV_FTW_WORKING_STRING "EFI_NV_FTW_WORKING"\r
-#define EFI_NV_FTW_SPARE_STRING   "EFI_NV_FTW_SPARE"\r
-\r
-#define EFI_FILE_NAME_STRING      "EFI_FILE_NAME"\r
-\r
-#define ONE_STRING                "1"\r
-#define ZERO_STRING               "0"\r
-#define TRUE_STRING               "TRUE"\r
-#define FALSE_STRING              "FALSE"\r
-#define NULL_STRING               "NULL"\r
-\r
-//\r
-// Defines to calculate the offset for PEI CORE entry points\r
-//\r
-#define IA32_PEI_CORE_ENTRY_OFFSET  0x20\r
-\r
-//\r
-// Defines to calculate the FIT table\r
-//\r
-#define IPF_FIT_ADDRESS_OFFSET  0x20\r
-\r
-//\r
-// Defines to calculate the offset for SALE_ENTRY\r
-//\r
-#define IPF_SALE_ENTRY_ADDRESS_OFFSET 0x18\r
-\r
-//\r
-// Symbol file definitions, current max size if 512K\r
-//\r
-#define SYMBOL_FILE_SIZE  0x80000\r
-\r
-#define FV_IMAGES_TOP_ADDRESS             0x100000000ULL\r
-\r
-//\r
-// Private data types\r
-//\r
-//\r
-// Component information\r
-//\r
-typedef struct {\r
-  UINTN Size;\r
-  CHAR8 ComponentName[_MAX_PATH];\r
-} COMPONENT_INFO;\r
-\r
-//\r
-// FV information holder\r
-//\r
-typedef struct {\r
-  EFI_PHYSICAL_ADDRESS    BaseAddress;\r
-  EFI_GUID                FvGuid;\r
-  UINTN                   Size;\r
-  CHAR8                   FvName[_MAX_PATH];\r
-  CHAR8                   SymName[_MAX_PATH];\r
-  EFI_FV_BLOCK_MAP_ENTRY  FvBlocks[MAX_NUMBER_OF_FV_BLOCKS];\r
-  EFI_FVB_ATTRIBUTES      FvAttributes;\r
-  CHAR8                   FvFiles[MAX_NUMBER_OF_FILES_IN_FV][_MAX_PATH];\r
-  COMPONENT_INFO          FvComponents[MAX_NUMBER_OF_COMPONENTS_IN_FV];\r
-} FV_INFO;\r
-\r
-//\r
-// Private function prototypes\r
-//\r
-EFI_STATUS\r
-ParseFvInf (\r
-  IN MEMORY_FILE  *InfFile,\r
-  IN FV_INFO      *FvInfo\r
-  )\r
-;\r
-\r
-#endif\r
diff --git a/Tools/CodeTools/TianoTools/GenFvImage/build.xml b/Tools/CodeTools/TianoTools/GenFvImage/build.xml
deleted file mode 100644 (file)
index ae930b0..0000000
+++ /dev/null
@@ -1,124 +0,0 @@
-<?xml version="1.0" ?>\r
-<!--\r
-Copyright (c) 2006, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
--->\r
-<project default="GenTool" basedir=".">\r
-<!--\r
-    EDK GenFvImage Tool\r
-  Copyright (c) 2006, Intel Corporation\r
--->\r
-  <property name="ToolName" value="GenFvImage"/>\r
-  <property name="FileSet" value="GenFvImageLib.c GenFvImageExe.c"/>\r
-\r
-  <taskdef resource="cpptasks.tasks"/>\r
-  <typedef resource="cpptasks.types"/>\r
-  <taskdef resource="net/sf/antcontrib/antlib.xml"/>\r
-\r
-  <property name="LINK_OUTPUT_TYPE" value="static"/>\r
-  <property name="BUILD_DIR" value="${PACKAGE_DIR}/${ToolName}/tmp"/>\r
-\r
-  <target name="GenTool" depends="init, Tool">\r
-    <echo message="The EDK Tool: ${ToolName} build has completed"/>\r
-  </target>\r
-\r
-  <target name="init">\r
-    <echo message="Building the EDK Tool: ${ToolName}"/>\r
-    <mkdir dir="${BUILD_DIR}"/>\r
-    <if>\r
-      <istrue value="${OSX}"/>\r
-      <then>\r
-        <property name="syslibdirs" value=""/>\r
-        <property name="syslibs" value=""/>\r
-      </then>\r
-    </if>\r
-\r
-    <if>\r
-      <istrue value="${cygwin}"/>\r
-      <then>\r
-        <property name="syslibdirs" value="${env.CYGWIN_HOME}/lib/e2fsprogs"/>\r
-        <property name="syslibs" value="uuid"/>\r
-      </then>\r
-    </if>\r
-    \r
-    <if>\r
-      <istrue value="${msft}"/>\r
-      <then>\r
-        <property name="syslibdirs" value=""/>\r
-        <property name="syslibs" value="uuid"/>\r
-      </then>\r
-    </if>\r
-    \r
-    <if>\r
-      <istrue value="${linux}"/>\r
-      <then>\r
-        <if>\r
-          <istrue value="${x86_64_linux}"/>\r
-          <then>\r
-            <property name="syslibdirs" value="/lib64"/>\r
-          </then>\r
-          <else>\r
-            <property name="syslibdirs" value="/usr/lib"/>\r
-          </else>\r
-        </if>\r
-        <property name="syslibs" value="uuid"/>\r
-      </then>\r
-    </if>\r
-    <echo message="syslibdirs set to: ${syslibdirs}"/>\r
-  </target>\r
-\r
-  <target name="Tool" depends="init, GenFvImage"/>\r
-\r
-  <target name="GenFvImage" >\r
-    <cc name="${ToolChain}" objdir="${BUILD_DIR}" \r
-        outfile="${BIN_DIR}/${ToolName}"\r
-        outtype="executable"\r
-        debug="true"\r
-        optimize="speed">\r
-      <compilerarg value="${ExtraArgus}" if="ExtraArgus" />\r
-\r
-      <defineset>\r
-        <define name="BUILDING_TOOLS"/>\r
-        <define name="TOOL_BUILD_IA32_TARGET"/>\r
-      </defineset>\r
-    \r
-      <fileset dir="${basedir}/${ToolName}" \r
-        includes="${FileSet}"/>\r
-\r
-      <includepath path="${PACKAGE_DIR}/${ToolName}"/>\r
-      <includepath path="${PACKAGE_DIR}/Include"/>\r
-      <includepath path="${PACKAGE_DIR}/Include/${HostArch}"/>\r
-      <includepath path="${PACKAGE_DIR}/Common"/>\r
-      <libset dir="${LIB_DIR}" libs="CommonTools"/>\r
-\r
-      <linkerarg value="/nodefaultlib:libc.lib" if="msft"/>\r
-      <syslibset dir="${syslibdirs}" libs="${syslibs}" if="cyglinux"/>\r
-      <syslibset libs="RpcRT4" if="msft"/>\r
-    </cc>\r
-  </target>\r
-\r
-  <target name="clean">\r
-    <echo message="Removing Intermediate Files Only"/>  \r
-    <delete>\r
-      <fileset dir="${BUILD_DIR}" includes="*.obj"/>\r
-    </delete>\r
-  </target>\r
-\r
-  <target name="cleanall">\r
-    <echo message="Removing Object Files and the Executable: ${ToolName}${ext_exe}"/>  \r
-    <delete failonerror="false" quiet="true" includeEmptyDirs="true">\r
-      <fileset dir="${BUILD_DIR}"/>\r
-      <fileset file="${BIN_DIR}/${ToolName}_Ia32${ext_exe}"/>\r
-      <fileset file="${BIN_DIR}/${ToolName}_X64${ext_exe}"/>\r
-      <fileset file="${BIN_DIR}/${ToolName}${ext_exe}"/>\r
-      <fileset file="${BIN_DIR}/${ToolName}_Ipf${ext_exe}"/>\r
-    </delete>\r
-  </target>\r
-\r
-</project>\r
diff --git a/Tools/CodeTools/TianoTools/GenSection/GenSection.c b/Tools/CodeTools/TianoTools/GenSection/GenSection.c
deleted file mode 100644 (file)
index 353b1a3..0000000
+++ /dev/null
@@ -1,938 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2004, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-Module Name:\r
-\r
-  GenSection.c\r
-\r
-Abstract:\r
-\r
-  Creates output file that is a properly formed section per the FV spec.\r
-\r
---*/\r
-\r
-#include <stdio.h>\r
-#include <stdlib.h>\r
-#include <string.h>\r
-\r
-#include <Common/UefiBaseTypes.h>\r
-#include <Common/FirmwareVolumeImageFormat.h>\r
-#include <Protocol/GuidedSectionExtraction.h>\r
-\r
-#include "CommonLib.h"\r
-#include "EfiCompress.h"\r
-#include "EfiCustomizedCompress.h"\r
-#include "Crc32.h"\r
-#include "EfiUtilityMsgs.h"\r
-#include "GenSection.h"\r
-\r
-\r
-#define UTILITY_NAME            "GenSection"\r
-\r
-#define PARAMETER_NOT_SPECIFIED "Parameter not specified"\r
-#define MAXIMUM_INPUT_FILE_NUM  10\r
-\r
-char      *SectionTypeName[] = {\r
-  NULL,                                 // 0x00 - reserved\r
-  "EFI_SECTION_COMPRESSION",            // 0x01\r
-  "EFI_SECTION_GUID_DEFINED",           // 0x02\r
-  NULL,                                 // 0x03 - reserved\r
-  NULL,                                 // 0x04 - reserved\r
-  NULL,                                 // 0x05 - reserved\r
-  NULL,                                 // 0x06 - reserved\r
-  NULL,                                 // 0x07 - reserved\r
-  NULL,                                 // 0x08 - reserved\r
-  NULL,                                 // 0x09 - reserved\r
-  NULL,                                 // 0x0A - reserved\r
-  NULL,                                 // 0x0B - reserved\r
-  NULL,                                 // 0x0C - reserved\r
-  NULL,                                 // 0x0D - reserved\r
-  NULL,                                 // 0x0E - reserved\r
-  NULL,                                 // 0x0F - reserved\r
-  "EFI_SECTION_PE32",                   // 0x10\r
-  "EFI_SECTION_PIC",                    // 0x11\r
-  "EFI_SECTION_TE",                     // 0x12\r
-  "EFI_SECTION_DXE_DEPEX",              // 0x13\r
-  "EFI_SECTION_VERSION",                // 0x14\r
-  "EFI_SECTION_USER_INTERFACE",         // 0x15\r
-  "EFI_SECTION_COMPATIBILITY16",        // 0x16\r
-  "EFI_SECTION_FIRMWARE_VOLUME_IMAGE",  // 0x17\r
-  "EFI_SECTION_FREEFORM_SUBTYPE_GUID",  // 0x18\r
-  "EFI_SECTION_RAW",                    // 0x19\r
-  NULL,                                 // 0x1A\r
-  "EFI_SECTION_PEI_DEPEX"               // 0x1B\r
-};\r
-\r
-char      *CompressionTypeName[]    = { "NONE", "STANDARD" };\r
-char      *GUIDedSectionTypeName[]  = { "CRC32" };\r
-EFI_GUID  gEfiCrc32SectionGuid      = EFI_CRC32_GUIDED_SECTION_EXTRACTION_PROTOCOL_GUID;\r
-\r
-static\r
-VOID\r
-PrintUsageMessage (\r
-  VOID\r
-  )\r
-{\r
-  UINTN SectionType;\r
-  UINTN DisplayCount;\r
-\r
-  printf ("Usage: "UTILITY_NAME "  -i InputFile -o OutputFile -s SectionType [SectionType params]\n\n");\r
-  printf ("    Where SectionType is one of the following section types:\n\n");\r
-\r
-  DisplayCount = 0;\r
-  for (SectionType = 0; SectionType <= EFI_SECTION_LAST_SECTION_TYPE; SectionType++) {\r
-    if (SectionTypeName[SectionType] != NULL) {\r
-      printf ("       %s\n", SectionTypeName[SectionType]);\r
-    }\r
-  }\r
-\r
-  printf ("\n    and SectionType dependent parameters are as follows:\n\n");\r
-  printf (\r
-    "       %s:       -t < %s | %s >\n",\r
-    SectionTypeName[EFI_SECTION_COMPRESSION],\r
-    CompressionTypeName[EFI_NOT_COMPRESSED],\r
-    CompressionTypeName[EFI_STANDARD_COMPRESSION]\r
-    );\r
-  printf (\r
-    "       %s:      -t < %s >\n""                          // Currently only CRC32 is supported\n\n",\r
-    SectionTypeName[EFI_SECTION_GUID_DEFINED],\r
-    GUIDedSectionTypeName[EFI_SECTION_CRC32_GUID_DEFINED]\r
-    );\r
-  printf (\r
-    "       %s:           -v VersionNumber\n""                          [-a \"Version string\"]\n\n",\r
-    SectionTypeName[EFI_SECTION_VERSION]\r
-    );\r
-  printf (\r
-    "       %s:    -a \"Human readable name\"\n\n",\r
-    SectionTypeName[EFI_SECTION_USER_INTERFACE]\r
-    );\r
-}\r
-\r
-VOID\r
-Ascii2UnicodeWriteString (\r
-  char    *String,\r
-  FILE    *OutFile,\r
-  BOOLEAN WriteLangCode\r
-  )\r
-{\r
-  UINTN Index;\r
-  UINT8 AsciiNull;\r
-  //\r
-  // BUGBUG need to get correct language code...\r
-  //\r
-  char  *EnglishLangCode = "eng";\r
-  AsciiNull = 0;\r
-  //\r
-  // first write the language code (english only)\r
-  //\r
-  if (WriteLangCode) {\r
-    fwrite (EnglishLangCode, 1, 4, OutFile);\r
-  }\r
-  //\r
-  // Next, write out the string... Convert ASCII to Unicode in the process.\r
-  //\r
-  Index = 0;\r
-  do {\r
-    fwrite (&String[Index], 1, 1, OutFile);\r
-    fwrite (&AsciiNull, 1, 1, OutFile);\r
-  } while (String[Index++] != 0);\r
-}\r
-\r
-STATUS\r
-GenSectionCommonLeafSection (\r
-  char    **InputFileName,\r
-  int     InputFileNum,\r
-  UINTN   SectionType,\r
-  FILE    *OutFile\r
-  )\r
-/*++\r
-        \r
-Routine Description:\r
-           \r
-  Generate a leaf section of type other than EFI_SECTION_VERSION\r
-  and EFI_SECTION_USER_INTERFACE. Input file must be well formed.\r
-  The function won't validate the input file's contents. For\r
-  common leaf sections, the input file may be a binary file.\r
-  The utility will add section header to the file.\r
-            \r
-Arguments:\r
-               \r
-  InputFileName  - Name of the input file.\r
-                \r
-  InputFileNum   - Number of input files. Should be 1 for leaf section.\r
-\r
-  SectionType    - A valid section type string\r
-\r
-  OutFile        - Output file handle\r
-\r
-Returns:\r
-                       \r
-  STATUS_ERROR            - can't continue\r
-  STATUS_SUCCESS          - successful return\r
-\r
---*/\r
-{\r
-  UINT64                    InputFileLength;\r
-  FILE                      *InFile;\r
-  UINT8                     *Buffer;\r
-  INTN                      TotalLength;\r
-  EFI_COMMON_SECTION_HEADER CommonSect;\r
-  STATUS                    Status;\r
-\r
-  if (InputFileNum > 1) {\r
-    Error (NULL, 0, 0, "invalid parameter", "more than one input file specified");\r
-    return STATUS_ERROR;\r
-  } else if (InputFileNum < 1) {\r
-    Error (NULL, 0, 0, "no input file specified", NULL);\r
-    return STATUS_ERROR;\r
-  }\r
-  //\r
-  // Open the input file\r
-  //\r
-  InFile = fopen (InputFileName[0], "rb");\r
-  if (InFile == NULL) {\r
-    Error (NULL, 0, 0, InputFileName[0], "failed to open input file");\r
-    return STATUS_ERROR;\r
-  }\r
-\r
-  Status  = STATUS_ERROR;\r
-  Buffer  = NULL;\r
-  //\r
-  // Seek to the end of the input file so we can determine its size\r
-  //\r
-  fseek (InFile, 0, SEEK_END);\r
-  fgetpos (InFile, &InputFileLength);\r
-  fseek (InFile, 0, SEEK_SET);\r
-  //\r
-  // Fill in the fields in the local section header structure\r
-  //\r
-  CommonSect.Type = (EFI_SECTION_TYPE) SectionType;\r
-  TotalLength     = sizeof (CommonSect) + (INTN) InputFileLength;\r
-  //\r
-  // Size must fit in 3 bytes\r
-  //\r
-  if (TotalLength >= 0x1000000) {\r
-    Error (NULL, 0, 0, InputFileName[0], "file size (0x%X) exceeds section size limit", TotalLength);\r
-    goto Done;\r
-  }\r
-  //\r
-  // Now copy the size into the section header and write out the section header\r
-  //\r
-  memcpy (&CommonSect.Size, &TotalLength, 3);\r
-  fwrite (&CommonSect, sizeof (CommonSect), 1, OutFile);\r
-  //\r
-  // Allocate a buffer to read in the contents of the input file. Then\r
-  // read it in as one block and write it to the output file.\r
-  //\r
-  if (InputFileLength != 0) {\r
-    Buffer = (UINT8 *) malloc ((size_t) InputFileLength);\r
-    if (Buffer == NULL) {\r
-      Error (__FILE__, __LINE__, 0, "memory allocation failure", NULL);\r
-      goto Done;\r
-    }\r
-\r
-    if (fread (Buffer, (size_t) InputFileLength, 1, InFile) != 1) {\r
-      Error (NULL, 0, 0, InputFileName[0], "failed to read contents of file");\r
-      goto Done;\r
-    }\r
-\r
-    if (fwrite (Buffer, (size_t) InputFileLength, 1, OutFile) != 1) {\r
-      Error (NULL, 0, 0, "failed to write to output file", NULL);\r
-      goto Done;\r
-    }\r
-  }\r
-\r
-  Status = STATUS_SUCCESS;\r
-Done:\r
-  fclose (InFile);\r
-  if (Buffer != NULL) {\r
-    free (Buffer);\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-EFI_STATUS\r
-GetSectionContents (\r
-  char    **InputFileName,\r
-  int     InputFileNum,\r
-  UINT8   *FileBuffer,\r
-  UINTN   *BufferLength\r
-  )\r
-/*++\r
-        \r
-Routine Description:\r
-           \r
-  Get the contents of all section files specified in InputFileName\r
-  into FileBuffer.\r
-            \r
-Arguments:\r
-               \r
-  InputFileName  - Name of the input file.\r
-                \r
-  InputFileNum   - Number of input files. Should be at least 1.\r
-\r
-  FileBuffer     - Output buffer to contain data\r
-\r
-  BufferLength   - Actual length of the data \r
-\r
-Returns:\r
-                       \r
-  EFI_SUCCESS on successful return\r
-  EFI_INVALID_PARAMETER if InputFileNum is less than 1\r
-  EFI_ABORTED if unable to open input file.\r
-\r
---*/\r
-{\r
-  UINTN   Size;\r
-  UINTN   FileSize;\r
-  INTN    Index;\r
-  FILE    *InFile;\r
-\r
-  if (InputFileNum < 1) {\r
-    Error (NULL, 0, 0, "must specify at least one input file", NULL);\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  Size = 0;\r
-  //\r
-  // Go through our array of file names and copy their contents\r
-  // to the output buffer.\r
-  //\r
-  for (Index = 0; Index < InputFileNum; Index++) {\r
-    InFile = fopen (InputFileName[Index], "rb");\r
-    if (InFile == NULL) {\r
-      Error (NULL, 0, 0, InputFileName[Index], "failed to open input file");\r
-      return EFI_ABORTED;\r
-    }\r
-\r
-    fseek (InFile, 0, SEEK_END);\r
-    FileSize = ftell (InFile);\r
-    fseek (InFile, 0, SEEK_SET);\r
-    //\r
-    // Now read the contents of the file into the buffer\r
-    //\r
-    if (FileSize > 0) {\r
-      if (fread (FileBuffer + Size, (size_t) FileSize, 1, InFile) != 1) {\r
-        Error (NULL, 0, 0, InputFileName[Index], "failed to read contents of input file");\r
-        fclose (InFile);\r
-        return EFI_ABORTED;\r
-      }\r
-    }\r
-\r
-    fclose (InFile);\r
-    Size += (UINTN) FileSize;\r
-    //\r
-    // make sure section ends on a DWORD boundary\r
-    //\r
-    while ((Size & 0x03) != 0) {\r
-      FileBuffer[Size] = 0;\r
-      Size++;\r
-    }\r
-  }\r
-\r
-  *BufferLength = Size;\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-GenSectionCompressionSection (\r
-  char    **InputFileName,\r
-  int     InputFileNum,\r
-  UINTN   SectionType,\r
-  UINTN   SectionSubType,\r
-  FILE    *OutFile\r
-  )\r
-/*++\r
-        \r
-Routine Description:\r
-           \r
-  Generate an encapsulating section of type EFI_SECTION_COMPRESSION\r
-  Input file must be already sectioned. The function won't validate\r
-  the input files' contents. Caller should hand in files already \r
-  with section header.\r
-            \r
-Arguments:\r
-               \r
-  InputFileName  - Name of the input file.\r
-                \r
-  InputFileNum   - Number of input files. Should be at least 1.\r
-\r
-  SectionType    - Section type to generate. Should be \r
-                   EFI_SECTION_COMPRESSION\r
-\r
-  SectionSubType - Specify the compression algorithm requested. \r
-  \r
-  OutFile        - Output file handle\r
-\r
-Returns:\r
-                       \r
-  EFI_SUCCESS           on successful return\r
-  EFI_INVALID_PARAMETER if InputFileNum is less than 1\r
-  EFI_ABORTED           if unable to open input file.\r
-  EFI_OUT_OF_RESOURCES  No resource to complete the operation.\r
---*/\r
-{\r
-  UINTN                   TotalLength;\r
-  UINTN                   InputLength;\r
-  UINTN                   CompressedLength;\r
-  UINT8                   *FileBuffer;\r
-  UINT8                   *OutputBuffer;\r
-  EFI_STATUS              Status;\r
-  EFI_COMPRESSION_SECTION CompressionSect;\r
-  COMPRESS_FUNCTION       CompressFunction;\r
-\r
-  if (SectionType != EFI_SECTION_COMPRESSION) {\r
-    Error (NULL, 0, 0, "parameter must be EFI_SECTION_COMPRESSION", NULL);\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  InputLength       = 0;\r
-  FileBuffer        = NULL;\r
-  OutputBuffer      = NULL;\r
-  CompressedLength  = 0;\r
-  FileBuffer        = (UINT8 *) malloc ((1024 * 1024 * 4) * sizeof (UINT8));\r
-  if (FileBuffer == NULL) {\r
-    Error (__FILE__, __LINE__, 0, "application error", "failed to allocate memory");\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-  //\r
-  // read all input file contents into a buffer\r
-  //\r
-  Status = GetSectionContents (\r
-            InputFileName,\r
-            InputFileNum,\r
-            FileBuffer,\r
-            &InputLength\r
-            );\r
-  if (EFI_ERROR (Status)) {\r
-    free (FileBuffer);\r
-    return Status;\r
-  }\r
-\r
-  CompressFunction = NULL;\r
-\r
-  //\r
-  // Now data is in FileBuffer, compress the data\r
-  //\r
-  switch (SectionSubType) {\r
-  case EFI_NOT_COMPRESSED:\r
-    CompressedLength = InputLength;\r
-    break;\r
-\r
-  case EFI_STANDARD_COMPRESSION:\r
-    CompressFunction = (COMPRESS_FUNCTION) Compress;\r
-    break;\r
-\r
-  case EFI_CUSTOMIZED_COMPRESSION:\r
-    CompressFunction = (COMPRESS_FUNCTION) CustomizedCompress;\r
-    break;\r
-\r
-  default:\r
-    Error (NULL, 0, 0, "unknown compression type", NULL);\r
-    free (FileBuffer);\r
-    return EFI_ABORTED;\r
-  }\r
-\r
-  if (CompressFunction != NULL) {\r
-\r
-    Status = CompressFunction (FileBuffer, InputLength, OutputBuffer, &CompressedLength);\r
-    if (Status == EFI_BUFFER_TOO_SMALL) {\r
-      OutputBuffer = malloc (CompressedLength);\r
-      if (!OutputBuffer) {\r
-        free (FileBuffer);\r
-        return EFI_OUT_OF_RESOURCES;\r
-      }\r
-\r
-      Status = CompressFunction (FileBuffer, InputLength, OutputBuffer, &CompressedLength);\r
-    }\r
-\r
-    free (FileBuffer);\r
-    FileBuffer = OutputBuffer;\r
-\r
-    if (EFI_ERROR (Status)) {\r
-      if (FileBuffer != NULL) {\r
-        free (FileBuffer);\r
-      }\r
-\r
-      return Status;\r
-    }\r
-  }\r
-\r
-  TotalLength = CompressedLength + sizeof (EFI_COMPRESSION_SECTION);\r
-  //\r
-  // Add the section header for the compressed data\r
-  //\r
-  CompressionSect.CommonHeader.Type     = (EFI_SECTION_TYPE) SectionType;\r
-  CompressionSect.CommonHeader.Size[0]  = (UINT8) (TotalLength & 0xff);\r
-  CompressionSect.CommonHeader.Size[1]  = (UINT8) ((TotalLength & 0xff00) >> 8);\r
-  CompressionSect.CommonHeader.Size[2]  = (UINT8) ((TotalLength & 0xff0000) >> 16);\r
-  CompressionSect.CompressionType       = (UINT8) SectionSubType;\r
-  CompressionSect.UncompressedLength    = InputLength;\r
-\r
-  fwrite (&CompressionSect, sizeof (CompressionSect), 1, OutFile);\r
-  fwrite (FileBuffer, CompressedLength, 1, OutFile);\r
-  free (FileBuffer);\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-GenSectionGuidDefinedSection (\r
-  char    **InputFileName,\r
-  int     InputFileNum,\r
-  UINTN   SectionType,\r
-  UINTN   SectionSubType,\r
-  FILE    *OutFile\r
-  )\r
-/*++\r
-        \r
-Routine Description:\r
-           \r
-  Generate an encapsulating section of type EFI_SECTION_GUID_DEFINED\r
-  Input file must be already sectioned. The function won't validate\r
-  the input files' contents. Caller should hand in files already \r
-  with section header.\r
-            \r
-Arguments:\r
-               \r
-  InputFileName  - Name of the input file.\r
-                \r
-  InputFileNum   - Number of input files. Should be at least 1.\r
-\r
-  SectionType    - Section type to generate. Should be \r
-                   EFI_SECTION_GUID_DEFINED\r
-\r
-  SectionSubType - Specify the authentication algorithm requested. \r
-  \r
-  OutFile        - Output file handle\r
-\r
-Returns:\r
-                       \r
-  EFI_SUCCESS on successful return\r
-  EFI_INVALID_PARAMETER if InputFileNum is less than 1\r
-  EFI_ABORTED if unable to open input file.\r
-  EFI_OUT_OF_RESOURCES  No resource to complete the operation.\r
-\r
---*/\r
-{\r
-  INTN                  TotalLength;\r
-  INTN                  InputLength;\r
-  UINT8                 *FileBuffer;\r
-  UINT32                Crc32Checksum;\r
-  EFI_STATUS            Status;\r
-  CRC32_SECTION_HEADER  Crc32GuidSect;\r
-\r
-  if (SectionType != EFI_SECTION_GUID_DEFINED) {\r
-    Error (NULL, 0, 0, "parameter must be EFI_SECTION_GUID_DEFINED", NULL);\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  InputLength = 0;\r
-  FileBuffer  = NULL;\r
-  FileBuffer  = (UINT8 *) malloc ((1024 * 1024 * 4) * sizeof (UINT8));\r
-  if (FileBuffer == NULL) {\r
-    Error (__FILE__, __LINE__, 0, "application error", "failed to allocate memory");\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-  //\r
-  // read all input file contents into a buffer\r
-  //\r
-  Status = GetSectionContents (\r
-            InputFileName,\r
-            InputFileNum,\r
-            FileBuffer,\r
-            &InputLength\r
-            );\r
-  if (EFI_ERROR (Status)) {\r
-    free (FileBuffer);\r
-    return Status;\r
-  }\r
-  //\r
-  // Now data is in FileBuffer, compress the data\r
-  //\r
-  switch (SectionSubType) {\r
-  case EFI_SECTION_CRC32_GUID_DEFINED:\r
-    Crc32Checksum = 0;\r
-    CalculateCrc32 (FileBuffer, InputLength, &Crc32Checksum);\r
-    if (EFI_ERROR (Status)) {\r
-      free (FileBuffer);\r
-      return Status;\r
-    }\r
-\r
-    TotalLength = InputLength + CRC32_SECTION_HEADER_SIZE;\r
-    Crc32GuidSect.GuidSectionHeader.CommonHeader.Type     = (EFI_SECTION_TYPE) SectionType;\r
-    Crc32GuidSect.GuidSectionHeader.CommonHeader.Size[0]  = (UINT8) (TotalLength & 0xff);\r
-    Crc32GuidSect.GuidSectionHeader.CommonHeader.Size[1]  = (UINT8) ((TotalLength & 0xff00) >> 8);\r
-    Crc32GuidSect.GuidSectionHeader.CommonHeader.Size[2]  = (UINT8) ((TotalLength & 0xff0000) >> 16);\r
-    memcpy (&(Crc32GuidSect.GuidSectionHeader.SectionDefinitionGuid), &gEfiCrc32SectionGuid, sizeof (EFI_GUID));\r
-    Crc32GuidSect.GuidSectionHeader.Attributes  = EFI_GUIDED_SECTION_AUTH_STATUS_VALID;\r
-    Crc32GuidSect.GuidSectionHeader.DataOffset  = CRC32_SECTION_HEADER_SIZE;\r
-    Crc32GuidSect.CRC32Checksum                 = Crc32Checksum;\r
-\r
-    break;\r
-\r
-  default:\r
-    Error (NULL, 0, 0, "invalid parameter", "unknown GUID defined type");\r
-    free (FileBuffer);\r
-    return EFI_ABORTED;\r
-  }\r
-\r
-  fwrite (&Crc32GuidSect, sizeof (Crc32GuidSect), 1, OutFile);\r
-  fwrite (FileBuffer, InputLength, 1, OutFile);\r
-\r
-  free (FileBuffer);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-int\r
-main (\r
-  int  argc,\r
-  char *argv[]\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Main\r
-\r
-Arguments:\r
-\r
-  command line parameters\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS    Section header successfully generated and section concatenated.\r
-  EFI_ABORTED    Could not generate the section\r
-  EFI_OUT_OF_RESOURCES  No resource to complete the operation.\r
-\r
---*/\r
-{\r
-  INTN                      Index;\r
-  INTN                      VersionNumber;\r
-  UINTN                     SectionType;\r
-  UINTN                     SectionSubType;\r
-  BOOLEAN                   InputFileRequired;\r
-  BOOLEAN                   SubTypeRequired;\r
-  FILE                      *InFile;\r
-  FILE                      *OutFile;\r
-  INTN                      InputFileNum;\r
-\r
-  char                      **InputFileName;\r
-  char                      *OutputFileName;\r
-  char                      AuxString[500] = { 0 };\r
-\r
-  char                      *ParamSectionType;\r
-  char                      *ParamSectionSubType;\r
-  char                      *ParamLength;\r
-  char                      *ParamVersion;\r
-  char                      *ParamDigitalSignature;\r
-\r
-  EFI_STATUS                Status;\r
-  EFI_COMMON_SECTION_HEADER CommonSect;\r
-\r
-  InputFileName         = NULL;\r
-  OutputFileName        = PARAMETER_NOT_SPECIFIED;\r
-  ParamSectionType      = PARAMETER_NOT_SPECIFIED;\r
-  ParamSectionSubType   = PARAMETER_NOT_SPECIFIED;\r
-  ParamLength           = PARAMETER_NOT_SPECIFIED;\r
-  ParamVersion          = PARAMETER_NOT_SPECIFIED;\r
-  ParamDigitalSignature = PARAMETER_NOT_SPECIFIED;\r
-  Status                = EFI_SUCCESS;\r
-\r
-  VersionNumber         = 0;\r
-  SectionType           = 0;\r
-  SectionSubType        = 0;\r
-  InputFileRequired     = TRUE;\r
-  SubTypeRequired       = FALSE;\r
-  InFile                = NULL;\r
-  OutFile               = NULL;\r
-  InputFileNum          = 0;\r
-  Status                = EFI_SUCCESS;\r
-\r
-  SetUtilityName (UTILITY_NAME);\r
-  if (argc == 1) {\r
-    PrintUsageMessage ();\r
-    return STATUS_ERROR;\r
-  }\r
-  //\r
-  // Parse command line\r
-  //\r
-  Index = 1;\r
-  while (Index < argc) {\r
-    if (strcmpi (argv[Index], "-i") == 0) {\r
-      //\r
-      // Input File found\r
-      //\r
-      Index++;\r
-      InputFileName = (char **) malloc (MAXIMUM_INPUT_FILE_NUM * sizeof (char *));\r
-      if (InputFileName == NULL) {\r
-        Error (__FILE__, __LINE__, 0, "application error", "failed to allocate memory");\r
-        return EFI_OUT_OF_RESOURCES;\r
-      }\r
-\r
-      memset (InputFileName, 0, (MAXIMUM_INPUT_FILE_NUM * sizeof (char *)));\r
-      InputFileName[InputFileNum] = argv[Index];\r
-      InputFileNum++;\r
-      Index++;\r
-      //\r
-      // Parse subsequent parameters until another switch is encountered\r
-      //\r
-      while ((Index < argc) && (argv[Index][0] != '-')) {\r
-        if ((InputFileNum % MAXIMUM_INPUT_FILE_NUM) == 0) {\r
-          //\r
-          // InputFileName buffer too small, need to realloc\r
-          //\r
-          InputFileName = (char **) realloc (\r
-                                      InputFileName,\r
-                                      (InputFileNum + MAXIMUM_INPUT_FILE_NUM) * sizeof (char *)\r
-                                      );\r
-          if (InputFileName == NULL) {\r
-            Error (__FILE__, __LINE__, 0, "application error", "failed to allocate memory");\r
-            return EFI_OUT_OF_RESOURCES;\r
-          }\r
-\r
-          memset (&(InputFileName[InputFileNum]), 0, (MAXIMUM_INPUT_FILE_NUM * sizeof (char *)));\r
-        }\r
-\r
-        InputFileName[InputFileNum] = argv[Index];\r
-        InputFileNum++;\r
-        Index++;\r
-      }\r
-\r
-    }\r
-\r
-    if (strcmpi (argv[Index], "-o") == 0) {\r
-      //\r
-      // Output file found\r
-      //\r
-      Index++;\r
-      OutputFileName = argv[Index];\r
-    } else if (strcmpi (argv[Index], "-s") == 0) {\r
-      //\r
-      // Section Type found\r
-      //\r
-      Index++;\r
-      ParamSectionType = argv[Index];\r
-    } else if (strcmpi (argv[Index], "-t") == 0) {\r
-      //\r
-      // Compression or Authentication type\r
-      //\r
-      Index++;\r
-      ParamSectionSubType = argv[Index];\r
-    } else if (strcmpi (argv[Index], "-l") == 0) {\r
-      //\r
-      // Length\r
-      //\r
-      Index++;\r
-      ParamLength = argv[Index];\r
-    } else if (strcmpi (argv[Index], "-v") == 0) {\r
-      //\r
-      // VersionNumber\r
-      //\r
-      Index++;\r
-      ParamVersion = argv[Index];\r
-    } else if (strcmpi (argv[Index], "-a") == 0) {\r
-      //\r
-      // Aux string\r
-      //\r
-      Index++;\r
-      //\r
-      // Note, the MSVC C-Start parses out and consolidates quoted strings from the command\r
-      // line.  Quote characters are stripped.  If this tool is ported to other environments\r
-      // this will need to be taken into account\r
-      //\r
-      strncpy (AuxString, argv[Index], 499);\r
-    } else if (strcmpi (argv[Index], "-d") == 0) {\r
-      //\r
-      // Digital signature for EFI_TEST_AUTHENTICAION (must be 0 or 1)\r
-      //\r
-      Index++;\r
-      ParamDigitalSignature = argv[Index];\r
-    } else if (strcmpi (argv[Index], "-?") == 0) {\r
-      PrintUsageMessage ();\r
-      return STATUS_ERROR;\r
-    } else {\r
-      Error (NULL, 0, 0, argv[Index], "unknown option");\r
-      return GetUtilityStatus ();\r
-    }\r
-\r
-    Index++;\r
-  }\r
-  //\r
-  // At this point, all command line parameters are verified as not being totally\r
-  // bogus.  Next verify the command line parameters are complete and make\r
-  // sense...\r
-  //\r
-  if (stricmp (ParamSectionType, SectionTypeName[EFI_SECTION_COMPRESSION]) == 0) {\r
-    SectionType     = EFI_SECTION_COMPRESSION;\r
-    SubTypeRequired = TRUE;\r
-    if (stricmp (ParamSectionSubType, CompressionTypeName[EFI_NOT_COMPRESSED]) == 0) {\r
-      SectionSubType = EFI_NOT_COMPRESSED;\r
-    } else if (stricmp (ParamSectionSubType, CompressionTypeName[EFI_STANDARD_COMPRESSION]) == 0) {\r
-      SectionSubType = EFI_STANDARD_COMPRESSION;\r
-    } else {\r
-      Error (NULL, 0, 0, ParamSectionSubType, "unknown compression type");\r
-      PrintUsageMessage ();\r
-      return GetUtilityStatus ();\r
-    }\r
-  } else if (stricmp (ParamSectionType, SectionTypeName[EFI_SECTION_GUID_DEFINED]) == 0) {\r
-    SectionType     = EFI_SECTION_GUID_DEFINED;\r
-    SubTypeRequired = TRUE;\r
-    if (stricmp (ParamSectionSubType, GUIDedSectionTypeName[EFI_SECTION_CRC32_GUID_DEFINED]) == 0) {\r
-      SectionSubType = EFI_SECTION_CRC32_GUID_DEFINED;\r
-    } else {\r
-      Error (NULL, 0, 0, ParamSectionSubType, "unknown GUID defined section type", ParamSectionSubType);\r
-      PrintUsageMessage ();\r
-      return GetUtilityStatus ();\r
-    }\r
-  } else if (stricmp (ParamSectionType, SectionTypeName[EFI_SECTION_PE32]) == 0) {\r
-    SectionType = EFI_SECTION_PE32;\r
-  } else if (stricmp (ParamSectionType, SectionTypeName[EFI_SECTION_PIC]) == 0) {\r
-    SectionType = EFI_SECTION_PIC;\r
-  } else if (stricmp (ParamSectionType, SectionTypeName[EFI_SECTION_TE]) == 0) {\r
-    SectionType = EFI_SECTION_TE;\r
-  } else if (stricmp (ParamSectionType, SectionTypeName[EFI_SECTION_DXE_DEPEX]) == 0) {\r
-    SectionType = EFI_SECTION_DXE_DEPEX;\r
-  } else if (stricmp (ParamSectionType, SectionTypeName[EFI_SECTION_VERSION]) == 0) {\r
-    SectionType       = EFI_SECTION_VERSION;\r
-    InputFileRequired = FALSE;\r
-    Index             = sscanf (ParamVersion, "%d", &VersionNumber);\r
-    if (Index != 1 || VersionNumber < 0 || VersionNumber > 65565) {\r
-      Error (NULL, 0, 0, ParamVersion, "illegal version number");\r
-      PrintUsageMessage ();\r
-      return GetUtilityStatus ();\r
-    }\r
-\r
-    if (strcmp (AuxString, PARAMETER_NOT_SPECIFIED) == 0) {\r
-      AuxString[0] = 0;\r
-    }\r
-  } else if (stricmp (ParamSectionType, SectionTypeName[EFI_SECTION_USER_INTERFACE]) == 0) {\r
-    SectionType       = EFI_SECTION_USER_INTERFACE;\r
-    InputFileRequired = FALSE;\r
-    if (strcmp (AuxString, PARAMETER_NOT_SPECIFIED) == 0) {\r
-      Error (NULL, 0, 0, "user interface string not specified", NULL);\r
-      PrintUsageMessage ();\r
-      return GetUtilityStatus ();\r
-    }\r
-  } else if (stricmp (ParamSectionType, SectionTypeName[EFI_SECTION_COMPATIBILITY16]) == 0) {\r
-    SectionType = EFI_SECTION_COMPATIBILITY16;\r
-  } else if (stricmp (ParamSectionType, SectionTypeName[EFI_SECTION_FIRMWARE_VOLUME_IMAGE]) == 0) {\r
-    SectionType = EFI_SECTION_FIRMWARE_VOLUME_IMAGE;\r
-  } else if (stricmp (ParamSectionType, SectionTypeName[EFI_SECTION_FREEFORM_SUBTYPE_GUID]) == 0) {\r
-    SectionType = EFI_SECTION_FREEFORM_SUBTYPE_GUID;\r
-  } else if (stricmp (ParamSectionType, SectionTypeName[EFI_SECTION_RAW]) == 0) {\r
-    SectionType = EFI_SECTION_RAW;\r
-  } else if (stricmp (ParamSectionType, SectionTypeName[EFI_SECTION_PEI_DEPEX]) == 0) {\r
-    SectionType = EFI_SECTION_PEI_DEPEX;\r
-  } else {\r
-    Error (NULL, 0, 0, ParamSectionType, "unknown section type");\r
-    PrintUsageMessage ();\r
-    return GetUtilityStatus ();\r
-  }\r
-  //\r
-  // Open output file\r
-  //\r
-  OutFile = fopen (OutputFileName, "wb");\r
-  if (OutFile == NULL) {\r
-    Error (NULL, 0, 0, OutputFileName, "failed to open output file for writing");\r
-    if (InFile != NULL) {\r
-      fclose (InFile);\r
-    }\r
-\r
-    return GetUtilityStatus ();\r
-  }\r
-  //\r
-  // At this point, we've fully validated the command line, and opened appropriate\r
-  // files, so let's go and do what we've been asked to do...\r
-  //\r
-  //\r
-  // Within this switch, build and write out the section header including any\r
-  // section type specific pieces.  If there's an input file, it's tacked on later\r
-  //\r
-  switch (SectionType) {\r
-  case EFI_SECTION_COMPRESSION:\r
-    Status = GenSectionCompressionSection (\r
-              InputFileName,\r
-              InputFileNum,\r
-              SectionType,\r
-              SectionSubType,\r
-              OutFile\r
-              );\r
-    break;\r
-\r
-  case EFI_SECTION_GUID_DEFINED:\r
-    Status = GenSectionGuidDefinedSection (\r
-              InputFileName,\r
-              InputFileNum,\r
-              SectionType,\r
-              SectionSubType,\r
-              OutFile\r
-              );\r
-    break;\r
-\r
-  case EFI_SECTION_VERSION:\r
-    CommonSect.Type = (EFI_SECTION_TYPE) SectionType;\r
-\r
-    Index           = sizeof (CommonSect);\r
-    //\r
-    // 2 characters for the build number\r
-    //\r
-    Index += 2;\r
-    //\r
-    // Aux string is ascii.. unicode is 2X + 2 bytes for terminating unicode null.\r
-    //\r
-    Index += (strlen (AuxString) * 2) + 2;\r
-    memcpy (&CommonSect.Size, &Index, 3);\r
-    fwrite (&CommonSect, sizeof (CommonSect), 1, OutFile);\r
-    fwrite (&VersionNumber, 2, 1, OutFile);\r
-    Ascii2UnicodeWriteString (AuxString, OutFile, FALSE);\r
-    break;\r
-\r
-  case EFI_SECTION_USER_INTERFACE:\r
-    CommonSect.Type = (EFI_SECTION_TYPE) SectionType;\r
-    Index           = sizeof (CommonSect);\r
-    //\r
-    // Aux string is ascii.. unicode is 2X + 2 bytes for terminating unicode null.\r
-    //\r
-    Index += (strlen (AuxString) * 2) + 2;\r
-    memcpy (&CommonSect.Size, &Index, 3);\r
-    fwrite (&CommonSect, sizeof (CommonSect), 1, OutFile);\r
-    Ascii2UnicodeWriteString (AuxString, OutFile, FALSE);\r
-    break;\r
-\r
-  default:\r
-    //\r
-    // All other section types are caught by default (they're all the same)\r
-    //\r
-    Status = GenSectionCommonLeafSection (\r
-              InputFileName,\r
-              InputFileNum,\r
-              SectionType,\r
-              OutFile\r
-              );\r
-    break;\r
-  }\r
-\r
-  if (InputFileName != NULL) {\r
-    free (InputFileName);\r
-  }\r
-\r
-  fclose (OutFile);\r
-  //\r
-  // If we had errors, then delete the output file\r
-  //\r
-  if (GetUtilityStatus () == STATUS_ERROR) {\r
-    remove (OutputFileName);\r
-  }\r
-\r
-  return GetUtilityStatus ();\r
-}\r
diff --git a/Tools/CodeTools/TianoTools/GenSection/GenSection.h b/Tools/CodeTools/TianoTools/GenSection/GenSection.h
deleted file mode 100644 (file)
index 3606463..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2004, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-Module Name:\r
-\r
-  GenSection.h \r
-\r
-Abstract:\r
-\r
-  Header file for GenSection.\r
-\r
---*/\r
-\r
-//\r
-// Module Coded to Tiano Coding Conventions\r
-//\r
-#ifndef _EFI_GEN_SECTION_H\r
-#define _EFI_GEN_SECTION_H\r
-\r
-//\r
-// External Files Referenced\r
-//\r
-#include <Common/UefiBaseTypes.h>\r
-#include <Common/FirmwareVolumeImageFormat.h>\r
-\r
-typedef struct {\r
-  EFI_GUID_DEFINED_SECTION  GuidSectionHeader;\r
-  UINT32                    CRC32Checksum;\r
-} CRC32_SECTION_HEADER;\r
-\r
-#define EFI_SECTION_CRC32_GUID_DEFINED  0\r
-#define CRC32_SECTION_HEADER_SIZE       (sizeof (CRC32_SECTION_HEADER))\r
-\r
-#endif\r
diff --git a/Tools/CodeTools/TianoTools/GenSection/build.xml b/Tools/CodeTools/TianoTools/GenSection/build.xml
deleted file mode 100644 (file)
index 63ffccd..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-<?xml version="1.0" ?>\r
-<!--\r
-Copyright (c) 2006, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
--->\r
-<project default="GenTool" basedir=".">\r
-<!--\r
-    EDK GenSection Tool\r
-  Copyright (c) 2006, Intel Corporation\r
--->\r
-  <property name="ToolName" value="GenSection"/>\r
-  <property name="FileSet" value="GenSection.c"/>\r
-\r
-  <taskdef resource="cpptasks.tasks"/>\r
-  <typedef resource="cpptasks.types"/>\r
-  <taskdef resource="net/sf/antcontrib/antlib.xml"/>\r
-\r
-  <property name="LINK_OUTPUT_TYPE" value="static"/>\r
-  <property name="BUILD_DIR" value="${PACKAGE_DIR}/${ToolName}/tmp"/>\r
-\r
-  <target name="GenTool" depends="init, Tool">\r
-    <echo message="The EDK Tool: ${ToolName} build has completed!"/>\r
-  </target>\r
-\r
-  <target name="init">\r
-    <echo message="Building the EDK Tool: ${ToolName}"/>\r
-    <mkdir dir="${BUILD_DIR}"/>\r
-  </target>\r
-\r
-  <target name="Tool" depends="init">\r
-    <cc name="${ToolChain}" objdir="${BUILD_DIR}" \r
-        outfile="${BIN_DIR}/${ToolName}"\r
-        outtype="executable"\r
-        debug="true"\r
-        optimize="speed">\r
-      <compilerarg value="${ExtraArgus}" if="ExtraArgus" />\r
-\r
-      <fileset dir="${basedir}/${ToolName}" \r
-        includes="${FileSet}" \r
-        defaultexcludes="TRUE" \r
-        excludes="*.xml *.inf"/>\r
-\r
-      <includepath path="${PACKAGE_DIR}/Include"/>\r
-      <includepath path="${PACKAGE_DIR}/Include/${HostArch}"/>\r
-      <includepath path="${PACKAGE_DIR}/Common"/>\r
-      <libset dir="${LIB_DIR}" libs="CommonTools CustomizedCompress"/>\r
-    </cc>\r
-  </target>\r
-\r
-  <target name="clean">\r
-    <echo message="Removing Intermediate Files Only"/>  \r
-    <delete>\r
-      <fileset dir="${BUILD_DIR}" includes="*.obj"/>\r
-    </delete>\r
-  </target>\r
-\r
-  <target name="cleanall">\r
-    <echo message="Removing Object Files and the Executable: ${ToolName}${ext_exe}"/>  \r
-    <delete failonerror="false" quiet="true" includeEmptyDirs="true">\r
-      <fileset dir="${BUILD_DIR}"/>\r
-      <fileset file="${BIN_DIR}/${ToolName}${ext_exe}"/>\r
-    </delete>\r
-  </target>\r
-\r
-</project>\r
diff --git a/Tools/CodeTools/TianoTools/GenTEImage/GenTEImage.c b/Tools/CodeTools/TianoTools/GenTEImage/GenTEImage.c
deleted file mode 100644 (file)
index 90f3b39..0000000
+++ /dev/null
@@ -1,916 +0,0 @@
-/*++\r
-\r
-Copyright (c)  1999-2006 Intel Corporation. All rights reserved\r
-This program and the accompanying materials are licensed and made available \r
-under the terms and conditions of the BSD License which accompanies this \r
-distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-Module Name:\r
-\r
-  GenTEImage.c\r
-  \r
-Abstract:\r
-\r
-  Utility program to shrink a PE32 image down by replacing\r
-  the DOS, PE, and optional headers with a minimal header.\r
-\r
---*/\r
-\r
-#include <stdio.h>\r
-#include <string.h>\r
-#include <stdlib.h>\r
-\r
-#include <Common/UefiBaseTypes.h>\r
-#include <Common/EfiImage.h> // for PE32 structure definitions\r
-\r
-#include "CommonLib.h"\r
-#include "EfiUtilityMsgs.h"\r
-\r
-//\r
-// Version of this utility\r
-//\r
-#define UTILITY_NAME    "GenTEImage"\r
-#define UTILITY_VERSION "v0.11"\r
-\r
-//\r
-// Define the max length of a filename\r
-//\r
-#define MAX_PATH                  256\r
-#define DEFAULT_OUTPUT_EXTENSION  ".te"\r
-\r
-//\r
-// Use this to track our command-line options and globals\r
-//\r
-struct {\r
-  INT8  OutFileName[MAX_PATH];\r
-  INT8  InFileName[MAX_PATH];\r
-  INT8  Verbose;\r
-  INT8  Dump;\r
-} mOptions;\r
-\r
-//\r
-// Use these to convert from machine type value to a named type\r
-//\r
-typedef struct {\r
-  UINT16  Value;\r
-  INT8    *Name;\r
-} STRING_LOOKUP;\r
-\r
-static STRING_LOOKUP  mMachineTypes[] = {\r
-  EFI_IMAGE_MACHINE_IA32,\r
-  "IA32",\r
-  EFI_IMAGE_MACHINE_IA64,\r
-  "IA64",\r
-  EFI_IMAGE_MACHINE_EBC,\r
-  "EBC",\r
-  0,\r
-  NULL\r
-};\r
-\r
-static STRING_LOOKUP  mSubsystemTypes[] = {\r
-  EFI_IMAGE_SUBSYSTEM_EFI_APPLICATION,\r
-  "EFI application",\r
-  EFI_IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER,\r
-  "EFI boot service driver",\r
-  EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER,\r
-  "EFI runtime driver",\r
-  0,\r
-  NULL\r
-};\r
-//\r
-//  Function prototypes\r
-//\r
-static\r
-void\r
-Usage (\r
-  VOID\r
-  );\r
-\r
-static\r
-STATUS\r
-ParseCommandLine (\r
-  int       Argc,\r
-  char      *Argv[]\r
-  );\r
-\r
-static\r
-STATUS\r
-CheckPE32File (\r
-  INT8      *FileName,\r
-  FILE      *Fptr,\r
-  UINT16    *MachineType,\r
-  UINT16    *SubSystem\r
-  );\r
-\r
-static\r
-STATUS\r
-ProcessFile (\r
-  INT8      *InFileName,\r
-  INT8      *OutFileName\r
-  );\r
-\r
-static\r
-void\r
-DumpImage (\r
-  INT8      *FileName\r
-  );\r
-\r
-static\r
-INT8                  *\r
-GetMachineTypeStr (\r
-  UINT16    MachineType\r
-  );\r
-\r
-static\r
-INT8                  *\r
-GetSubsystemTypeStr (\r
-  UINT16  SubsystemType\r
-  );\r
-\r
-main (\r
-  int   Argc,\r
-  char  *Argv[]\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  \r
-\r
-Arguments:\r
-\r
-  Argc            - standard C main() argument count\r
-\r
-  Argv            - standard C main() argument list\r
-\r
-Returns:\r
-\r
-  0             success\r
-  non-zero      otherwise\r
-\r
---*/\r
-// GC_TODO:    ] - add argument and description to function comment\r
-{\r
-  INT8    *Ext;\r
-  UINT32  Status;\r
-\r
-  SetUtilityName (UTILITY_NAME);\r
-  //\r
-  // Parse the command line arguments\r
-  //\r
-  if (ParseCommandLine (Argc, Argv)) {\r
-    return STATUS_ERROR;\r
-  }\r
-  //\r
-  // If dumping an image, then do that and quit\r
-  //\r
-  if (mOptions.Dump) {\r
-    DumpImage (mOptions.InFileName);\r
-    goto Finish;\r
-  }\r
-  //\r
-  // Determine the output filename. Either what they specified on\r
-  // the command line, or the first input filename with a different extension.\r
-  //\r
-  if (!mOptions.OutFileName[0]) {\r
-    strcpy (mOptions.OutFileName, mOptions.InFileName);\r
-    //\r
-    // Find the last . on the line and replace the filename extension with\r
-    // the default\r
-    //\r
-    for (Ext = mOptions.OutFileName + strlen (mOptions.OutFileName) - 1;\r
-         (Ext >= mOptions.OutFileName) && (*Ext != '.') && (*Ext != '\\');\r
-         Ext--\r
-        )\r
-      ;\r
-    //\r
-    // If dot here, then insert extension here, otherwise append\r
-    //\r
-    if (*Ext != '.') {\r
-      Ext = mOptions.OutFileName + strlen (mOptions.OutFileName);\r
-    }\r
-\r
-    strcpy (Ext, DEFAULT_OUTPUT_EXTENSION);\r
-  }\r
-  //\r
-  // Make sure we don't have the same filename for input and output files\r
-  //\r
-  if (stricmp (mOptions.OutFileName, mOptions.InFileName) == 0) {\r
-    Error (NULL, 0, 0, mOptions.OutFileName, "input and output file names must be different");\r
-    goto Finish;\r
-  }\r
-  //\r
-  // Process the file\r
-  //\r
-  ProcessFile (mOptions.InFileName, mOptions.OutFileName);\r
-Finish:\r
-  Status = GetUtilityStatus ();\r
-  return Status;\r
-}\r
-\r
-static\r
-STATUS\r
-ProcessFile (\r
-  INT8      *InFileName,\r
-  INT8      *OutFileName\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  \r
-  Process a PE32 EFI file.\r
-\r
-Arguments:\r
-  \r
-  InFileName      - the file name pointer to the input file\r
-  OutFileName     - the file name pointer to the output file\r
-\r
-Returns:\r
-\r
-  STATUS_SUCCESS  - the process has been finished successfully\r
-  STATUS_ERROR    - error occured during the processing\r
-\r
---*/\r
-{\r
-  STATUS                      Status;\r
-  FILE                        *InFptr;\r
-  FILE                        *OutFptr;\r
-  UINT16                      MachineType;\r
-  UINT16                      SubSystem;\r
-  EFI_TE_IMAGE_HEADER         TEImageHeader;\r
-  UINT32                      PESigOffset;\r
-  EFI_IMAGE_FILE_HEADER       FileHeader;\r
-  EFI_IMAGE_OPTIONAL_HEADER32 OptionalHeader32;\r
-  EFI_IMAGE_OPTIONAL_HEADER64 OptionalHeader64;\r
-  UINT32                      BytesStripped;\r
-  UINT32                      FileSize;\r
-  UINT8                       *Buffer;\r
-  long                        SaveFilePosition;\r
-\r
-  InFptr  = NULL;\r
-  OutFptr = NULL;\r
-  Buffer  = NULL;\r
-  Status  = STATUS_ERROR;\r
-\r
-  //\r
-  // Try to open the input file\r
-  //\r
-  if ((InFptr = fopen (InFileName, "rb")) == NULL) {\r
-    Error (NULL, 0, 0, InFileName, "failed to open input file for reading");\r
-    return STATUS_ERROR;\r
-  }\r
-  //\r
-  // Double-check the file to make sure it's what we expect it to be\r
-  //\r
-  if (CheckPE32File (InFileName, InFptr, &MachineType, &SubSystem) != STATUS_SUCCESS) {\r
-    goto Finish;\r
-  }\r
-  //\r
-  // Initialize our new header\r
-  //\r
-  memset (&TEImageHeader, 0, sizeof (EFI_TE_IMAGE_HEADER));\r
-\r
-  //\r
-  // Seek to the end to get the file size\r
-  //\r
-  fseek (InFptr, 0, SEEK_END);\r
-  FileSize = ftell (InFptr);\r
-  fseek (InFptr, 0, SEEK_SET);\r
-\r
-  //\r
-  // Per the PE/COFF specification, at offset 0x3C in the file is a 32-bit\r
-  // offset (from the start of the file) to the PE signature, which always\r
-  // follows the MSDOS stub. The PE signature is immediately followed by the\r
-  // COFF file header.\r
-  //\r
-  //\r
-  if (fseek (InFptr, 0x3C, SEEK_SET) != 0) {\r
-    Error (NULL, 0, 0, InFileName, "failed to seek to PE signature in file", NULL);\r
-    goto Finish;\r
-  }\r
-\r
-  if (fread (&PESigOffset, sizeof (PESigOffset), 1, InFptr) != 1) {\r
-    Error (NULL, 0, 0, InFileName, "failed to read PE signature offset from file");\r
-    goto Finish;\r
-  }\r
-\r
-  if (fseek (InFptr, PESigOffset + 4, SEEK_SET) != 0) {\r
-    Error (NULL, 0, 0, InFileName, "failed to seek to PE signature");\r
-    goto Finish;\r
-  }\r
-  //\r
-  // We should now be at the COFF file header. Read it in and verify it's\r
-  // of an image type we support.\r
-  //\r
-  if (fread (&FileHeader, sizeof (EFI_IMAGE_FILE_HEADER), 1, InFptr) != 1) {\r
-    Error (NULL, 0, 0, InFileName, "failed to read file header from image");\r
-    goto Finish;\r
-  }\r
-\r
-  if ((FileHeader.Machine != EFI_IMAGE_MACHINE_IA32) && (FileHeader.Machine != EFI_IMAGE_MACHINE_IA64)) {\r
-    Error (NULL, 0, 0, InFileName, "image is of an unsupported machine type 0x%X", (UINT32) FileHeader.Machine);\r
-    goto Finish;\r
-  }\r
-  //\r
-  // Calculate the total number of bytes we're going to strip off. The '4' is for the\r
-  // PE signature PE\0\0. Then sanity check the size.\r
-  //\r
-  BytesStripped = PESigOffset + 4 + sizeof (EFI_IMAGE_FILE_HEADER) + FileHeader.SizeOfOptionalHeader;\r
-  if (BytesStripped >= FileSize) {\r
-    Error (NULL, 0, 0, InFileName, "attempt to strip more bytes than the total file size");\r
-    goto Finish;\r
-  }\r
-\r
-  if (BytesStripped &~0xFFFF) {\r
-    Error (NULL, 0, 0, InFileName, "attempt to strip more than 64K bytes", NULL);\r
-    goto Finish;\r
-  }\r
-\r
-  TEImageHeader.StrippedSize = (UINT16) BytesStripped;\r
-\r
-  //\r
-  // Read in the optional header. Assume PE32, and if not, then re-read as PE32+\r
-  //\r
-  SaveFilePosition = ftell (InFptr);\r
-  if (fread (&OptionalHeader32, sizeof (EFI_IMAGE_OPTIONAL_HEADER32), 1, InFptr) != 1) {\r
-    Error (NULL, 0, 0, InFileName, "failed to read optional header from input file");\r
-    goto Finish;\r
-  }\r
-\r
-  if (OptionalHeader32.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {\r
-    //\r
-    // Fill in our new header with required data directory entries\r
-    //\r
-    TEImageHeader.AddressOfEntryPoint = OptionalHeader32.AddressOfEntryPoint;\r
-    //\r
-    // - BytesStripped + sizeof (EFI_TE_IMAGE_HEADER);\r
-    //\r
-    // We're going to pack the subsystem into 1 byte. Make sure it fits\r
-    //\r
-    if (OptionalHeader32.Subsystem &~0xFF) {\r
-      Error (\r
-        NULL,\r
-        0,\r
-        0,\r
-        InFileName,\r
-        NULL,\r
-        "image subsystem 0x%X cannot be packed into 1 byte",\r
-        (UINT32) OptionalHeader32.Subsystem\r
-        );\r
-      goto Finish;\r
-    }\r
-\r
-    TEImageHeader.Subsystem   = (UINT8) OptionalHeader32.Subsystem;\r
-    TEImageHeader.BaseOfCode  = OptionalHeader32.BaseOfCode;\r
-    TEImageHeader.ImageBase = (UINT64) (OptionalHeader32.ImageBase + TEImageHeader.StrippedSize - sizeof (EFI_TE_IMAGE_HEADER));\r
-    if (OptionalHeader32.NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC) {\r
-      TEImageHeader.DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_BASERELOC].VirtualAddress = OptionalHeader32.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC].VirtualAddress;\r
-      TEImageHeader.DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_BASERELOC].Size = OptionalHeader32.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC].Size;\r
-    }\r
-\r
-    if (OptionalHeader32.NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_DEBUG) {\r
-      TEImageHeader.DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG].VirtualAddress = OptionalHeader32.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG].VirtualAddress;\r
-      TEImageHeader.DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG].Size = OptionalHeader32.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG].Size;\r
-    }\r
-  } else if (OptionalHeader32.Magic == EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC) {\r
-    //\r
-    // Rewind and re-read the optional header\r
-    //\r
-    fseek (InFptr, SaveFilePosition, SEEK_SET);\r
-    if (fread (&OptionalHeader64, sizeof (EFI_IMAGE_OPTIONAL_HEADER64), 1, InFptr) != 1) {\r
-      Error (NULL, 0, 0, InFileName, "failed to re-read optional header from input file");\r
-      goto Finish;\r
-    }\r
-\r
-    TEImageHeader.AddressOfEntryPoint = OptionalHeader64.AddressOfEntryPoint;\r
-    //\r
-    // - BytesStripped + sizeof (EFI_TE_IMAGE_HEADER);\r
-    //\r
-    // We're going to pack the subsystem into 1 byte. Make sure it fits\r
-    //\r
-    if (OptionalHeader64.Subsystem &~0xFF) {\r
-      Error (\r
-        NULL,\r
-        0,\r
-        0,\r
-        InFileName,\r
-        NULL,\r
-        "image subsystem 0x%X cannot be packed into 1 byte",\r
-        (UINT32) OptionalHeader64.Subsystem\r
-        );\r
-      goto Finish;\r
-    }\r
-\r
-    TEImageHeader.Subsystem   = (UINT8) OptionalHeader64.Subsystem;\r
-    TEImageHeader.BaseOfCode  = OptionalHeader32.BaseOfCode;\r
-    TEImageHeader.ImageBase = (UINT64) (OptionalHeader64.ImageBase + TEImageHeader.StrippedSize - sizeof (EFI_TE_IMAGE_HEADER));\r
-    if (OptionalHeader64.NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC) {\r
-      TEImageHeader.DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_BASERELOC].VirtualAddress = OptionalHeader64.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC].VirtualAddress;\r
-      TEImageHeader.DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_BASERELOC].Size = OptionalHeader64.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC].Size;\r
-    }\r
-\r
-    if (OptionalHeader64.NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_DEBUG) {\r
-      TEImageHeader.DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG].VirtualAddress = OptionalHeader64.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG].VirtualAddress;\r
-      TEImageHeader.DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG].Size = OptionalHeader64.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG].Size;\r
-    }\r
-  } else {\r
-    Error (\r
-      NULL,\r
-      0,\r
-      0,\r
-      InFileName,\r
-      "unsupported magic number 0x%X found in optional header",\r
-      (UINT32) OptionalHeader32.Magic\r
-      );\r
-    goto Finish;\r
-  }\r
-  //\r
-  // Fill in the remainder of our new image header\r
-  //\r
-  TEImageHeader.Signature = EFI_TE_IMAGE_HEADER_SIGNATURE;\r
-  TEImageHeader.Machine   = FileHeader.Machine;\r
-  //\r
-  // We're going to pack the number of sections into a single byte. Make sure it fits.\r
-  //\r
-  if (FileHeader.NumberOfSections &~0xFF) {\r
-    Error (\r
-      NULL,\r
-      0,\r
-      0,\r
-      InFileName,\r
-      NULL,\r
-      "image's number of sections 0x%X cannot be packed into 1 byte",\r
-      (UINT32) FileHeader.NumberOfSections\r
-      );\r
-    goto Finish;\r
-  }\r
-\r
-  TEImageHeader.NumberOfSections = (UINT8) FileHeader.NumberOfSections;\r
-\r
-  //\r
-  // Now open our output file\r
-  //\r
-  if ((OutFptr = fopen (OutFileName, "wb")) == NULL) {\r
-    Error (NULL, 0, 0, OutFileName, "failed to open output file for writing");\r
-    goto Finish;\r
-  }\r
-  //\r
-  // Write the TE header\r
-  //\r
-  if (fwrite (&TEImageHeader, sizeof (EFI_TE_IMAGE_HEADER), 1, OutFptr) != 1) {\r
-    Error (NULL, 0, 0, "failed to write image header to output file", NULL);\r
-    goto Finish;\r
-  }\r
-  //\r
-  // Position into the input file, read the part we're not stripping, and\r
-  // write it out.\r
-  //\r
-  fseek (InFptr, BytesStripped, SEEK_SET);\r
-  Buffer = (UINT8 *) malloc (FileSize - BytesStripped);\r
-  if (Buffer == NULL) {\r
-    Error (NULL, 0, 0, "application error", "failed to allocate memory");\r
-    goto Finish;\r
-  }\r
-\r
-  if (fread (Buffer, FileSize - BytesStripped, 1, InFptr) != 1) {\r
-    Error (NULL, 0, 0, InFileName, "failed to read remaining contents of input file");\r
-    goto Finish;\r
-  }\r
-\r
-  if (fwrite (Buffer, FileSize - BytesStripped, 1, OutFptr) != 1) {\r
-    Error (NULL, 0, 0, OutFileName, "failed to write all bytes to output file");\r
-    goto Finish;\r
-  }\r
-\r
-  Status = STATUS_SUCCESS;\r
-\r
-Finish:\r
-  if (InFptr != NULL) {\r
-    fclose (InFptr);\r
-  }\r
-  //\r
-  // Close the output file. If there was an error, delete the output file so\r
-  // that a subsequent build will rebuild it.\r
-  //\r
-  if (OutFptr != NULL) {\r
-    fclose (OutFptr);\r
-    if (GetUtilityStatus () == STATUS_ERROR) {\r
-      remove (OutFileName);\r
-    }\r
-  }\r
-\r
-  //\r
-  // Free up our buffer\r
-  //\r
-  if (Buffer != NULL) {\r
-    free (Buffer);\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-static\r
-STATUS\r
-CheckPE32File (\r
-  INT8      *FileName,\r
-  FILE      *Fptr,\r
-  UINT16    *MachineType,\r
-  UINT16    *SubSystem\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  FileName    - GC_TODO: add argument description\r
-  Fptr        - GC_TODO: add argument description\r
-  MachineType - GC_TODO: add argument description\r
-  SubSystem   - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
-  GC_TODO: add return values\r
-\r
---*/\r
-{\r
-  /*++\r
-\r
-Routine Description:\r
-  \r
-  Given a file pointer to a supposed PE32 image file, verify that it is indeed a\r
-  PE32 image file, and then return the machine type in the supplied pointer.\r
-\r
-Arguments:\r
-\r
-  Fptr          File pointer to the already-opened PE32 file\r
-  MachineType   Location to stuff the machine type of the PE32 file. This is needed\r
-                because the image may be Itanium-based, IA32, or EBC.\r
-\r
-Returns:\r
-\r
-  0             success\r
-  non-zero      otherwise\r
-\r
---*/\r
-  EFI_IMAGE_DOS_HEADER      DosHeader;\r
-  EFI_IMAGE_FILE_HEADER     FileHdr;\r
-  EFI_IMAGE_OPTIONAL_HEADER OptionalHdr;\r
-  UINT32                    PESig;\r
-  STATUS                    Status;\r
-\r
-  Status = STATUS_ERROR;\r
-  //\r
-  // Position to the start of the file\r
-  //\r
-  fseek (Fptr, 0, SEEK_SET);\r
-  //\r
-  // Read the DOS header\r
-  //\r
-  if (fread (&DosHeader, sizeof (DosHeader), 1, Fptr) != 1) {\r
-    Error (NULL, 0, 0, FileName, "failed to read the DOS stub from the input file");\r
-    goto Finish;\r
-  }\r
-  //\r
-  // Check the magic number (0x5A4D)\r
-  //\r
-  if (DosHeader.e_magic != EFI_IMAGE_DOS_SIGNATURE) {\r
-    Error (NULL, 0, 0, FileName, "input file does not appear to be a PE32 image (magic number)");\r
-    goto Finish;\r
-  }\r
-  //\r
-  // Position into the file and check the PE signature\r
-  //\r
-  fseek (Fptr, (long) DosHeader.e_lfanew, SEEK_SET);\r
-  if (fread (&PESig, sizeof (PESig), 1, Fptr) != 1) {\r
-    Error (NULL, 0, 0, FileName, "failed to read PE signature bytes");\r
-    goto Finish;\r
-  }\r
-  //\r
-  // Check the PE signature in the header "PE\0\0"\r
-  //\r
-  if (PESig != EFI_IMAGE_NT_SIGNATURE) {\r
-    Error (NULL, 0, 0, FileName, "file does not appear to be a PE32 image (signature)");\r
-    goto Finish;\r
-  }\r
-  //\r
-  // Read the file header\r
-  //\r
-  if (fread (&FileHdr, sizeof (FileHdr), 1, Fptr) != 1) {\r
-    Error (NULL, 0, 0, FileName, "failed to read PE file header from input file");\r
-    goto Finish;\r
-  }\r
-  //\r
-  // Read the optional header so we can get the subsystem\r
-  //\r
-  if (fread (&OptionalHdr, sizeof (OptionalHdr), 1, Fptr) != 1) {\r
-    Error (NULL, 0, 0, FileName, "failed to read COFF optional header from input file");\r
-    goto Finish;\r
-  }\r
-\r
-  *SubSystem = OptionalHdr.Subsystem;\r
-  if (mOptions.Verbose) {\r
-    fprintf (stdout, "  Got subsystem = 0x%X from image\n", (int) *SubSystem);\r
-  }\r
-  //\r
-  // Good to go\r
-  //\r
-  Status = STATUS_SUCCESS;\r
-Finish:\r
-  fseek (Fptr, 0, SEEK_SET);\r
-  return Status;\r
-}\r
-\r
-static\r
-int\r
-ParseCommandLine (\r
-  int         Argc,\r
-  char        *Argv[]\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  \r
-  Given the Argc/Argv program arguments, and a pointer to an options structure,\r
-  parse the command-line options and check their validity.\r
-\r
-\r
-Arguments:\r
-\r
-  Argc            - standard C main() argument count\r
-  Argv            - standard C main() argument list\r
-\r
-Returns:\r
-\r
-  STATUS_SUCCESS    success\r
-  non-zero          otherwise\r
-\r
---*/\r
-// GC_TODO:    ] - add argument and description to function comment\r
-{\r
-  //\r
-  // Clear out the options\r
-  //\r
-  memset ((char *) &mOptions, 0, sizeof (mOptions));\r
-  //\r
-  // Skip over the program name\r
-  //\r
-  Argc--;\r
-  Argv++;\r
-  //\r
-  // If no arguments, assume they want usage info\r
-  //\r
-  if (Argc == 0) {\r
-    Usage ();\r
-    return STATUS_ERROR;\r
-  }\r
-  //\r
-  // Process until no more arguments\r
-  //\r
-  while ((Argc > 0) && (Argv[0][0] == '-')) {\r
-    if (stricmp (Argv[0], "-o") == 0) {\r
-      //\r
-      // Output filename specified with -o\r
-      // Make sure there's another parameter\r
-      //\r
-      if (Argc > 1) {\r
-        strcpy (mOptions.OutFileName, Argv[1]);\r
-      } else {\r
-        Error (NULL, 0, 0, Argv[0], "missing output file name with option");\r
-        Usage ();\r
-        return STATUS_ERROR;\r
-      }\r
-\r
-      Argv++;\r
-      Argc--;\r
-    } else if ((stricmp (Argv[0], "-h") == 0) || (strcmp (Argv[0], "-?") == 0)) {\r
-      //\r
-      // Help option\r
-      //\r
-      Usage ();\r
-      return STATUS_ERROR;\r
-    } else if (stricmp (Argv[0], "-v") == 0) {\r
-      //\r
-      // -v for verbose\r
-      //\r
-      mOptions.Verbose = 1;\r
-    } else if (stricmp (Argv[0], "-dump") == 0) {\r
-      //\r
-      // -dump for dumping an image\r
-      //\r
-      mOptions.Dump = 1;\r
-    } else {\r
-      Error (NULL, 0, 0, Argv[0], "unrecognized option");\r
-      Usage ();\r
-      return STATUS_ERROR;\r
-    }\r
-    //\r
-    // Next argument\r
-    //\r
-    Argv++;\r
-    Argc--;\r
-  }\r
-  //\r
-  // Better be one more arg for input file name\r
-  //\r
-  if (Argc == 0) {\r
-    Error (NULL, 0, 0, "input file name required", NULL);\r
-    Usage ();\r
-    return STATUS_ERROR;\r
-  }\r
-\r
-  if (Argc != 1) {\r
-    Error (NULL, 0, 0, Argv[1], "extra arguments on command line");\r
-    return STATUS_ERROR;\r
-  }\r
-\r
-  strcpy (mOptions.InFileName, Argv[0]);\r
-  return STATUS_SUCCESS;\r
-}\r
-\r
-static\r
-void\r
-Usage (\r
-  VOID\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  \r
-  Print usage information for this utility.\r
-\r
-Arguments:\r
-\r
-  None.\r
-\r
-Returns:\r
-\r
-  Nothing.\r
-\r
---*/\r
-{\r
-  int               Index;\r
-  static const char *Msg[] = {\r
-    UTILITY_NAME " version "UTILITY_VERSION " - TE image utility",\r
-    "  Generate a TE image from an EFI PE32 image",\r
-    "  Usage: "UTILITY_NAME " {-v} {-dump} {-h|-?} {-o OutFileName} InFileName",\r
-    "                [-e|-b] [FileName(s)]",\r
-    "    where:",\r
-    "      -v             - for verbose output",\r
-    "      -dump          - to dump the input file to a text file",\r
-    "      -h -?          - for this help information",\r
-    "      -o OutFileName - to write output to OutFileName rather than InFileName"DEFAULT_OUTPUT_EXTENSION,\r
-    "      InFileName     - name of the input PE32 file",\r
-    "",\r
-    NULL\r
-  };\r
-  for (Index = 0; Msg[Index] != NULL; Index++) {\r
-    fprintf (stdout, "%s\n", Msg[Index]);\r
-  }\r
-}\r
-\r
-static\r
-VOID\r
-DumpImage (\r
-  INT8    *FileName\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  \r
-  Dump a specified image information\r
-\r
-Arguments:\r
-  \r
-  FileName - File name pointer to the image to dump\r
-\r
-Returns:\r
-\r
-  Nothing.\r
-\r
---*/\r
-{\r
-  FILE                *InFptr;\r
-  EFI_TE_IMAGE_HEADER TEImageHeader;\r
-  INT8                *NamePtr;\r
-\r
-  //\r
-  // Open the input file\r
-  //\r
-  InFptr  = NULL;\r
-\r
-  if ((InFptr = fopen (FileName, "rb")) == NULL) {\r
-    Error (NULL, 0, 0, FileName, "failed to open input file for reading");\r
-    return ;\r
-  }\r
-\r
-  if (fread (&TEImageHeader, sizeof (EFI_TE_IMAGE_HEADER), 1, InFptr) != 1) {\r
-    Error (NULL, 0, 0, FileName, "failed to read image header from input file");\r
-    goto Finish;\r
-  }\r
-\r
-  if (TEImageHeader.Signature != EFI_TE_IMAGE_HEADER_SIGNATURE) {\r
-    Error (NULL, 0, 0, FileName, "Image does not appear to be a TE image (bad signature)");\r
-    goto Finish;\r
-  }\r
-  //\r
-  // Dump the header\r
-  //\r
-  fprintf (stdout, "Header (%d bytes):\n", sizeof (EFI_TE_IMAGE_HEADER));\r
-  fprintf (stdout, "  Signature:          0x%04X (TE)\n", (UINT32) TEImageHeader.Signature);\r
-  NamePtr = GetMachineTypeStr (TEImageHeader.Machine);\r
-  fprintf (stdout, "  Machine:            0x%04X (%s)\n", (UINT32) TEImageHeader.Machine, NamePtr);\r
-  NamePtr = GetSubsystemTypeStr (TEImageHeader.Subsystem);\r
-  fprintf (stdout, "  Subsystem:          0x%02X (%s)\n", (UINT32) TEImageHeader.Subsystem, NamePtr);\r
-  fprintf (stdout, "  Number of sections  0x%02X\n", (UINT32) TEImageHeader.NumberOfSections);\r
-  fprintf (stdout, "  Stripped size:      0x%04X\n", (UINT32) TEImageHeader.StrippedSize);\r
-  fprintf (stdout, "  Entry point:        0x%08X\n", TEImageHeader.AddressOfEntryPoint);\r
-  fprintf (stdout, "  Base of code:       0x%08X\n", TEImageHeader.BaseOfCode);\r
-  fprintf (stdout, "  Data directories:\n");\r
-  fprintf (\r
-    stdout,\r
-    "    %8X [%8X] RVA [size] of Base Relocation Directory\n",\r
-    TEImageHeader.DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_BASERELOC].VirtualAddress,\r
-    TEImageHeader.DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_BASERELOC].Size\r
-    );\r
-  fprintf (\r
-    stdout,\r
-    "    %8X [%8X] RVA [size] of Debug Directory\n",\r
-    TEImageHeader.DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG].VirtualAddress,\r
-    TEImageHeader.DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG].Size\r
-    );\r
-\r
-Finish:\r
-  if (InFptr != NULL) {\r
-    fclose (InFptr);\r
-  }\r
-}\r
-\r
-static\r
-INT8 *\r
-GetMachineTypeStr (\r
-  UINT16    MachineType\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  MachineType - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
-  GC_TODO: add return values\r
-\r
---*/\r
-{\r
-  int Index;\r
-\r
-  for (Index = 0; mMachineTypes[Index].Name != NULL; Index++) {\r
-    if (mMachineTypes[Index].Value == MachineType) {\r
-      return mMachineTypes[Index].Name;\r
-    }\r
-  }\r
-\r
-  return "unknown";\r
-}\r
-\r
-static\r
-INT8 *\r
-GetSubsystemTypeStr (\r
-  UINT16  SubsystemType\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  SubsystemType - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
-  GC_TODO: add return values\r
-\r
---*/\r
-{\r
-  int Index;\r
-\r
-  for (Index = 0; mSubsystemTypes[Index].Name != NULL; Index++) {\r
-    if (mSubsystemTypes[Index].Value == SubsystemType) {\r
-      return mSubsystemTypes[Index].Name;\r
-    }\r
-  }\r
-\r
-  return "unknown";\r
-}\r
diff --git a/Tools/CodeTools/TianoTools/GenTEImage/build.xml b/Tools/CodeTools/TianoTools/GenTEImage/build.xml
deleted file mode 100644 (file)
index e79f957..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-<?xml version="1.0" ?>\r
-<!--\r
-Copyright (c) 2006, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
--->\r
-<project default="GenTool" basedir=".">\r
-<!--\r
-    EDK GenTEImage Tool\r
-  Copyright (c) 2006, Intel Corporation\r
--->\r
-  <property name="ToolName" value="GenTEImage"/>\r
-  <property name="FileSet" value="*.c"/>\r
-\r
-  <taskdef resource="cpptasks.tasks"/>\r
-  <typedef resource="cpptasks.types"/>\r
-  <taskdef resource="net/sf/antcontrib/antlib.xml"/>\r
-\r
-\r
-  <property name="LINK_OUTPUT_TYPE" value="static"/>\r
-  <property name="BUILD_DIR" value="${PACKAGE_DIR}/${ToolName}/tmp"/>\r
-\r
-  <target name="GenTool" depends="init, Tool">\r
-    <echo message="The EDK Tool: ${ToolName} build has completed!"/>\r
-  </target>\r
-\r
-  <target name="init">\r
-    <echo message="Building the EDK Tool: ${ToolName}"/>\r
-    <mkdir dir="${BUILD_DIR}"/>\r
-  </target>\r
-\r
-  <target name="Tool" depends="init">\r
-    <cc name="${ToolChain}" objdir="${BUILD_DIR}" \r
-        outfile="${BIN_DIR}/${ToolName}"\r
-        outtype="executable"\r
-        debug="true"\r
-        optimize="speed">\r
-      <compilerarg value="${ExtraArgus}" if="ExtraArgus" />\r
-\r
-      <fileset dir="${basedir}/${ToolName}" \r
-        includes="${FileSet}" \r
-        defaultexcludes="TRUE" \r
-        excludes="*.xml *.inf"/>\r
-\r
-      <includepath path="${PACKAGE_DIR}/Include"/>\r
-      <includepath path="${PACKAGE_DIR}/Include/${HostArch}"/>\r
-      <includepath path="${PACKAGE_DIR}/Common"/>\r
-      <libset dir="${LIB_DIR}" libs="CommonTools"/>\r
-    </cc>\r
-  </target>\r
-\r
-  <target name="clean">\r
-    <echo message="Removing Intermediate Files Only"/>  \r
-    <delete>\r
-      <fileset dir="${BUILD_DIR}" includes="*.obj"/>\r
-    </delete>\r
-  </target>\r
-\r
-  <target name="cleanall">\r
-    <echo message="Removing Object Files and the Executable: ${ToolName}${ext_exe}"/>  \r
-    <delete failonerror="false" quiet="true" includeEmptyDirs="true">\r
-      <fileset dir="${BUILD_DIR}"/>\r
-      <fileset file="${BIN_DIR}/${ToolName}${ext_exe}"/>\r
-    </delete>\r
-  </target>\r
-\r
-</project>\r
diff --git a/Tools/CodeTools/TianoTools/GuidChk/CommonUtils.h b/Tools/CodeTools/TianoTools/GuidChk/CommonUtils.h
deleted file mode 100644 (file)
index f7a331e..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2004, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-Module Name:  \r
-\r
-  CommonUtils.h\r
-  \r
-Abstract:\r
-\r
-  Common utility defines and structure definitions.\r
-  \r
---*/\r
-\r
-#ifndef _COMMON_UTILS_H_\r
-#define _COMMON_UTILS_H_\r
-\r
-//\r
-// Basic types\r
-//\r
-typedef unsigned char UINT8;\r
-typedef char INT8;\r
-typedef unsigned short UINT16;\r
-typedef unsigned int UINT32;\r
-\r
-typedef UINT8 BOOLEAN;\r
-typedef UINT32 STATUS;\r
-\r
-#define TRUE            1\r
-#define FALSE           0\r
-\r
-#define STATUS_SUCCESS  0\r
-#define STATUS_WARNING  1\r
-#define STATUS_ERROR    2\r
-\r
-//\r
-// Linked list of strings\r
-//\r
-typedef struct _STRING_LIST {\r
-  struct _STRING_LIST *Next;\r
-  char                *Str;\r
-} STRING_LIST;\r
-\r
-int\r
-CreateGuidList (\r
-  INT8    *OutFileName\r
-  )\r
-;\r
-\r
-#endif // #ifndef _COMMON_UTILS_H_\r
diff --git a/Tools/CodeTools/TianoTools/GuidChk/FileSearch.c b/Tools/CodeTools/TianoTools/GuidChk/FileSearch.c
deleted file mode 100644 (file)
index 8b5b58f..0000000
+++ /dev/null
@@ -1,285 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2004, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-Module Name:  \r
-\r
-  FileSearch.c\r
-  \r
-Abstract:\r
-\r
-  Module used to support file searches on the system.\r
-  \r
---*/\r
-\r
-#include <stdio.h>\r
-\r
-#include "CommonUtils.h"\r
-#include "FileSearch.h"\r
-#include "UtilsMsgs.h"\r
-\r
-//\r
-// Internal file search flag for sanity checks\r
-//\r
-#define FILE_SEARCH_STARTED 0x8000\r
-#define FILE_SEARCH_INITED  0x4000\r
-\r
-static\r
-BOOLEAN\r
-FileSearchMeetsCriteria (\r
-  FILE_SEARCH_DATA    *FSData\r
-  );\r
-\r
-/*****************************************************************************/\r
-STATUS\r
-FileSearchInit (\r
-  FILE_SEARCH_DATA    *FSData\r
-  )\r
-{\r
-  memset ((char *) FSData, 0, sizeof (FILE_SEARCH_DATA));\r
-  FSData->Handle          = INVALID_HANDLE_VALUE;\r
-  FSData->FileSearchFlags = FILE_SEARCH_INITED;\r
-  FSData->FileName[0]     = 0;\r
-  return STATUS_SUCCESS;\r
-}\r
-\r
-STATUS\r
-FileSearchStart (\r
-  FILE_SEARCH_DATA    *FSData,\r
-  char                *FileMask,\r
-  UINT32              SearchFlags\r
-  )\r
-{\r
-  BOOLEAN Done;\r
-\r
-  //\r
-  // Save their flags, and set a flag to indicate that they called this\r
-  // start function so we can perform extended checking in the other\r
-  // routines we have in this module.\r
-  //\r
-  FSData->FileSearchFlags |= (SearchFlags | FILE_SEARCH_STARTED);\r
-  FSData->FileName[0] = 0;\r
-\r
-  //\r
-  // Begin the search\r
-  //\r
-  FSData->Handle = FindFirstFile (FileMask, &(FSData->FindData));\r
-  if (FSData->Handle == INVALID_HANDLE_VALUE) {\r
-    return STATUS_ERROR;\r
-  }\r
-  //\r
-  // Keep looping through until we find a file meeting the caller's\r
-  // criteria per the search flags\r
-  //\r
-  Done = FALSE;\r
-  while (!Done) {\r
-    //\r
-    // If we're done (we found a match) copy the file name found and return\r
-    //\r
-    Done = FileSearchMeetsCriteria (FSData);\r
-    if (Done) {\r
-      return STATUS_SUCCESS;\r
-    }\r
-    //\r
-    // Go on to next file\r
-    //\r
-    if (!FindNextFile (FSData->Handle, &(FSData->FindData))) {\r
-      return STATUS_NOT_FOUND;\r
-    }\r
-  }\r
-  //\r
-  // Not reached\r
-  //\r
-  return STATUS_NOT_FOUND;\r
-}\r
-\r
-//\r
-// Find the next file meeting their criteria and return it.\r
-//\r
-STATUS\r
-FileSearchFindNext (\r
-  FILE_SEARCH_DATA    *FSData\r
-  )\r
-{\r
-  BOOLEAN Done;\r
-\r
-  Done = FALSE;\r
-  while (!Done) {\r
-    if (!FindNextFile (FSData->Handle, &(FSData->FindData))) {\r
-      return STATUS_NOT_FOUND;\r
-    }\r
-    //\r
-    // See if it matches their criteria\r
-    //\r
-    Done = FileSearchMeetsCriteria (FSData);\r
-    if (Done) {\r
-      return STATUS_SUCCESS;\r
-    }\r
-  }\r
-  //\r
-  // Not reached\r
-  //\r
-  return STATUS_NOT_FOUND;\r
-}\r
-//\r
-// Perform any cleanup necessary to close down a search\r
-//\r
-STATUS\r
-FileSearchDestroy (\r
-  FILE_SEARCH_DATA    *FSData\r
-  )\r
-{\r
-  if (FSData->Handle != INVALID_HANDLE_VALUE) {\r
-    FindClose (FSData->Handle);\r
-    FSData->Handle = INVALID_HANDLE_VALUE;\r
-  }\r
-\r
-  FSData->FileName[0]     = 0;\r
-  FSData->FileSearchFlags = 0;\r
-  return STATUS_SUCCESS;\r
-}\r
-\r
-static\r
-BOOLEAN\r
-FileSearchMeetsCriteria (\r
-  FILE_SEARCH_DATA    *FSData\r
-  )\r
-{\r
-  BOOLEAN     Status;\r
-  STRING_LIST *StrList;\r
-  UINT32      ExtLen;\r
-  UINT32      FileNameLen;\r
-\r
-  Status = FALSE;\r
-\r
-  //\r
-  // First clear the flag indicating this is neither a file or a\r
-  // directory.\r
-  //\r
-  FSData->FileFlags &= ~(FILE_SEARCH_DIR | FILE_SEARCH_FILE);\r
-\r
-  //\r
-  // We found a file. See if it matches the user's search criteria. First\r
-  // check for this being a directory, and they want directories, and\r
-  // it's not "." and it's not ".."\r
-  //\r
-  if ((FSData->FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) &&\r
-      (FSData->FileSearchFlags & FILE_SEARCH_DIR) &&\r
-      (strcmp (FSData->FindData.cFileName, ".")) &&\r
-      (strcmp (FSData->FindData.cFileName, ".."))\r
-      ) {\r
-    //\r
-    // Assume we'll make it past this check\r
-    //\r
-    Status = TRUE;\r
-    //\r
-    // If they have a list of exclude directories, then check for those\r
-    //\r
-    StrList = FSData->ExcludeDirs;\r
-    while (StrList != NULL) {\r
-      if (stricmp (FSData->FindData.cFileName, StrList->Str) == 0) {\r
-        Status = FALSE;\r
-        break;\r
-      }\r
-\r
-      StrList = StrList->Next;\r
-    }\r
-    //\r
-    // If we didn't fail due to excluded directories, then set the dir flag\r
-    //\r
-    if (Status) {\r
-      FSData->FileFlags |= FILE_SEARCH_DIR;\r
-    }\r
-    //\r
-    // Else check for a file, and they want files....\r
-    //\r
-  } else if (((FSData->FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0) &&\r
-           (FSData->FileSearchFlags & FILE_SEARCH_FILE)\r
-          ) {\r
-    //\r
-    // See if it's in our list of excluded files\r
-    //\r
-    Status  = TRUE;\r
-    StrList = FSData->ExcludeFiles;\r
-    while (StrList != NULL) {\r
-      if (stricmp (FSData->FindData.cFileName, StrList->Str) == 0) {\r
-        Status = FALSE;\r
-        break;\r
-      }\r
-\r
-      StrList = StrList->Next;\r
-    }\r
-\r
-    if (Status) {\r
-      //\r
-      // See if it's in our list of excluded file extensions\r
-      //\r
-      FileNameLen = strlen (FSData->FindData.cFileName);\r
-      StrList     = FSData->ExcludeExtensions;\r
-      while (StrList != NULL) {\r
-        ExtLen = strlen (StrList->Str);\r
-        if (stricmp (\r
-              FSData->FindData.cFileName + FileNameLen - ExtLen,\r
-              StrList->Str\r
-              ) == 0) {\r
-          Status = FALSE;\r
-          break;\r
-        }\r
-\r
-        StrList = StrList->Next;\r
-      }\r
-    }\r
-\r
-    if (Status) {\r
-      FSData->FileFlags |= FILE_SEARCH_FILE;\r
-    }\r
-  }\r
-  //\r
-  // If it's a match, copy the filename into another field of the structure\r
-  // for portability.\r
-  //\r
-  if (Status) {\r
-    strcpy (FSData->FileName, FSData->FindData.cFileName);\r
-  }\r
-\r
-  return Status;\r
-}\r
-//\r
-// Exclude a list of subdirectories.\r
-//\r
-STATUS\r
-FileSearchExcludeDirs (\r
-  FILE_SEARCH_DATA    *FSData,\r
-  STRING_LIST         *StrList\r
-  )\r
-{\r
-  FSData->ExcludeDirs = StrList;\r
-  return STATUS_SUCCESS;\r
-}\r
-\r
-STATUS\r
-FileSearchExcludeFiles (\r
-  FILE_SEARCH_DATA    *FSData,\r
-  STRING_LIST         *StrList\r
-  )\r
-{\r
-  FSData->ExcludeFiles = StrList;\r
-  return STATUS_SUCCESS;\r
-}\r
-\r
-STATUS\r
-FileSearchExcludeExtensions (\r
-  FILE_SEARCH_DATA    *FSData,\r
-  STRING_LIST         *StrList\r
-  )\r
-{\r
-  FSData->ExcludeExtensions = StrList;\r
-  return STATUS_SUCCESS;\r
-}\r
diff --git a/Tools/CodeTools/TianoTools/GuidChk/FileSearch.h b/Tools/CodeTools/TianoTools/GuidChk/FileSearch.h
deleted file mode 100644 (file)
index bc40265..0000000
+++ /dev/null
@@ -1,108 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2004, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-Module Name:  \r
-\r
-  FileSearch.h\r
-  \r
-Abstract:\r
-\r
-  Header file to support file searching.\r
-  \r
---*/\r
-\r
-#ifndef _FILE_SEARCH_H_\r
-#define _FILE_SEARCH_H_\r
-\r
-//\r
-// Since the file searching routines are OS dependent, put the\r
-// necessary include paths in this header file so that the non-OS-dependent\r
-// files don't need to include these windows-specific header files.\r
-//\r
-#include <stdio.h>\r
-#include <string.h>\r
-#include <ctype.h>\r
-#include <direct.h>\r
-#include <windows.h>\r
-\r
-//\r
-// Return codes of some of the file search routines\r
-//\r
-#define STATUS_NOT_FOUND  0x1000\r
-\r
-//\r
-// Flags for what to search for. Also used in the FileFlags return field.\r
-//\r
-#define FILE_SEARCH_DIR   0x0001\r
-#define FILE_SEARCH_FILE  0x0002\r
-\r
-//\r
-// Here's our class definition\r
-//\r
-typedef struct {\r
-  HANDLE          Handle;\r
-  WIN32_FIND_DATA FindData;\r
-  UINT32          FileSearchFlags;    // DIRS, FILES, etc\r
-  UINT32          FileFlags;\r
-  INT8            FileName[MAX_PATH]; // for portability\r
-  STRING_LIST     *ExcludeDirs;\r
-  STRING_LIST     *ExcludeFiles;\r
-  STRING_LIST     *ExcludeExtensions;\r
-} FILE_SEARCH_DATA;\r
-\r
-//\r
-// Here's our member functions\r
-//\r
-STATUS\r
-FileSearchInit (\r
-  FILE_SEARCH_DATA    *FSData\r
-  )\r
-;\r
-\r
-STATUS\r
-FileSearchDestroy (\r
-  FILE_SEARCH_DATA    *FSData\r
-  )\r
-;\r
-\r
-STATUS\r
-FileSearchStart (\r
-  FILE_SEARCH_DATA    *FSData,\r
-  char                *FileMask,\r
-  UINT32              SearchFlags\r
-  )\r
-;\r
-\r
-STATUS\r
-FileSearchFindNext (\r
-  FILE_SEARCH_DATA    *FSData\r
-  )\r
-;\r
-\r
-STATUS\r
-FileSearchExcludeDirs (\r
-  FILE_SEARCH_DATA    *FSData,\r
-  STRING_LIST         *StrList\r
-  )\r
-;\r
-STATUS\r
-FileSearchExcludeExtensions (\r
-  FILE_SEARCH_DATA    *FSData,\r
-  STRING_LIST         *StrList\r
-  )\r
-;\r
-STATUS\r
-FileSearchExcludeFiles (\r
-  FILE_SEARCH_DATA    *FSData,\r
-  STRING_LIST         *StrList\r
-  )\r
-;\r
-#endif\r
diff --git a/Tools/CodeTools/TianoTools/GuidChk/GuidChk.c b/Tools/CodeTools/TianoTools/GuidChk/GuidChk.c
deleted file mode 100644 (file)
index de88405..0000000
+++ /dev/null
@@ -1,2348 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2004, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-Module Name:  \r
-\r
-  GuidChk.c \r
-  \r
-Abstract:\r
-\r
-  Parse files in a directory and subdirectories to find all guid definitions.\r
-  Then check them against each other to make sure there are no duplicates.\r
-  \r
---*/\r
-\r
-#include <stdio.h>\r
-#include <string.h>\r
-#include <stdlib.h>\r
-#include <ctype.h>\r
-\r
-#include "CommonUtils.h"\r
-#include "FileSearch.h"\r
-#include "UtilsMsgs.h"\r
-\r
-#define MAX_LINE_LEN  180 // we concatenate two lines sometimes\r
-// Define a structure that correlates filename extensions to an enumerated\r
-// type.\r
-//\r
-typedef struct {\r
-  INT8  *Extension;\r
-  INT8  ExtensionCode;\r
-} FILE_TYPE_TABLE_ENTRY;\r
-\r
-#define FILE_EXTENSION_UNKNOWN  0\r
-#define FILE_EXTENSION_C        1\r
-#define FILE_EXTENSION_H        2\r
-#define FILE_EXTENSION_IA32_ASM 3\r
-#define FILE_EXTENSION_IA32_INC 4\r
-#define FILE_EXTENSION_IA64_ASM 5\r
-#define FILE_EXTENSION_IA64_INC 6\r
-#define FILE_EXTENSION_PKG      7\r
-#define FILE_EXTENSION_INF      8\r
-\r
-FILE_TYPE_TABLE_ENTRY FileTypeTable[] = {\r
-  ".c",\r
-  FILE_EXTENSION_C,\r
-  ".h",\r
-  FILE_EXTENSION_H,\r
-  ".inc",\r
-  FILE_EXTENSION_IA32_INC,\r
-  ".asm",\r
-  FILE_EXTENSION_IA32_ASM,\r
-  ".s",\r
-  FILE_EXTENSION_IA64_ASM,\r
-  ".pkg",\r
-  FILE_EXTENSION_PKG,\r
-  ".inf",\r
-  FILE_EXTENSION_INF,\r
-  ".i",\r
-  FILE_EXTENSION_IA64_INC,\r
-  NULL,\r
-  0\r
-};\r
-\r
-typedef struct EFI_GUID {\r
-  UINT32  Data1;\r
-  UINT16  Data2;\r
-  UINT16  Data3;\r
-  UINT8   Data4[8];\r
-} EFI_GUID;\r
-\r
-typedef struct {\r
-  INT8  Data[4];\r
-  INT8  DataLen;\r
-} EFI_SIGNATURE;\r
-\r
-typedef struct _GUID_RECORD {\r
-  struct _GUID_RECORD *Next;\r
-  BOOLEAN             Reported;\r
-  INT8                *FileName;\r
-  INT8                *SymName;\r
-  EFI_GUID            Guid;\r
-} GUID_RECORD;\r
-\r
-typedef struct _SIGNATURE_RECORD {\r
-  struct _SIGNATURE_RECORD  *Next;\r
-  BOOLEAN                   Reported;\r
-  INT8                      *FileName;\r
-  EFI_SIGNATURE             Signature;\r
-} SIGNATURE_RECORD;\r
-\r
-//\r
-// Utility options\r
-//\r
-typedef struct {\r
-  INT8        DatabaseOutputFileName[MAX_PATH]; // with -b option\r
-  STRING_LIST *ExcludeDirs;                     // list of directory names not to process\r
-  STRING_LIST *ExcludeSubDirs;                  // list of directory names to not process subdirectories (build)\r
-  STRING_LIST *ExcludeFiles;                    // list of files to exclude (make.inf)\r
-  STRING_LIST *ExcludeExtensions;               // list of filename extensions to exclude (.inf, .pkg)\r
-  BOOLEAN     Verbose;\r
-  BOOLEAN     PrintFound;\r
-  BOOLEAN     CheckGuids;\r
-  BOOLEAN     CheckSignatures;\r
-  BOOLEAN     GuidXReference;\r
-} OPTIONS;\r
-\r
-static\r
-STATUS\r
-ProcessArgs (\r
-  int     Argc,\r
-  char    *Argv[]\r
-  );\r
-\r
-static\r
-VOID\r
-Usage (\r
-  VOID\r
-  );\r
-\r
-static\r
-STATUS\r
-ProcessDirectory (\r
-  INT8        *Path,\r
-  INT8        *DirectoryName\r
-  );\r
-\r
-static\r
-STATUS\r
-ProcessFile (\r
-  INT8                *DirectoryName,\r
-  INT8                *FileName\r
-  );\r
-\r
-static\r
-UINT32\r
-GetFileExtension (\r
-  INT8        *FileName\r
-  );\r
-\r
-static\r
-UINT32\r
-SkipWhiteSpace (\r
-  INT8    *Str\r
-  );\r
-\r
-static\r
-UINT32\r
-ValidSymbolName (\r
-  INT8    *Name\r
-  );\r
-\r
-static\r
-STATUS\r
-ProcessCFileGuids (\r
-  INT8    *FileName\r
-  );\r
-\r
-static\r
-STATUS\r
-AddSignature (\r
-  INT8      *FileName,\r
-  INT8      *StrDef,\r
-  UINT32    SigSize\r
-  );\r
-\r
-static\r
-STATUS\r
-ProcessCFileSigs (\r
-  INT8    *FileName\r
-  );\r
-\r
-static\r
-STATUS\r
-ProcessINFFileGuids (\r
-  INT8    *FileName\r
-  );\r
-\r
-static\r
-STATUS\r
-ProcessPkgFileGuids (\r
-  INT8    *FileName\r
-  );\r
-\r
-static\r
-STATUS\r
-ProcessIA32FileGuids (\r
-  INT8    *FileName\r
-  );\r
-\r
-static\r
-STATUS\r
-ProcessIA64FileGuids (\r
-  INT8    *FileName\r
-  );\r
-\r
-static\r
-BOOLEAN\r
-IsIA64GuidLine (\r
-  INT8      *Line,\r
-  UINT32    *GuidHigh,\r
-  UINT32    *GuidLow,\r
-  BOOLEAN   *Low,\r
-  INT8      *SymName\r
-  );\r
-\r
-static\r
-STATUS\r
-AddGuid11 (\r
-  INT8      *FileName,\r
-  UINT32    *Data,\r
-  INT8      *SymName\r
-  );\r
-\r
-static\r
-STATUS\r
-AddPkgGuid (\r
-  INT8      *FileName,\r
-  UINT32    *Data,\r
-  UINT64    *Data64\r
-  );\r
-\r
-static\r
-STATUS\r
-AddGuid16 (\r
-  INT8      *FileName,\r
-  UINT32    *Data\r
-  );\r
-\r
-static\r
-STATUS\r
-AddGuid64x2 (\r
-  INT8      *FileName,\r
-  UINT32    DataHH,                             // Upper 32-bits of upper 64 bits of guid\r
-  UINT32    DataHL,                             // Lower 32-bits of upper 64 bits\r
-  UINT32    DataLH,\r
-  UINT32    DataLL\r
-  );\r
-\r
-static\r
-VOID\r
-FreeGuids (\r
-  VOID\r
-  );\r
-\r
-static\r
-VOID\r
-FreeSigs (\r
-  VOID\r
-  );\r
-\r
-static\r
-STATUS\r
-CheckDuplicates (\r
-  VOID\r
-  );\r
-\r
-//\r
-// static\r
-// VOID\r
-// ReportGuid (\r
-//  INT8        *FileName,\r
-//  GUID_RECORD *FileRecord\r
-//  );\r
-//\r
-static\r
-VOID\r
-FreeOptions (\r
-  VOID\r
-  );\r
-\r
-static\r
-BOOLEAN\r
-CheckGuidData (\r
-  UINT32    *GuidData,\r
-  UINT32    DataCount\r
-  );\r
-\r
-/**************************** GLOBALS ****************************************/\r
-static GUID_RECORD      *gGuidList      = NULL;\r
-static SIGNATURE_RECORD *gSignatureList = NULL;\r
-static OPTIONS          gOptions;\r
-\r
-/*****************************************************************************/\r
-int\r
-main (\r
-  int     Argc,\r
-  char    *Argv[]\r
-  )\r
-{\r
-  INT8    *Cwd;\r
-  STATUS  Status;\r
-\r
-  SetUtilityName ("GuidChk");\r
-  //\r
-  // Get the current working directory and then process the command line\r
-  // arguments.\r
-  //\r
-  Cwd     = _getcwd (NULL, 0);\r
-  Status  = ProcessArgs (Argc, Argv);\r
-  if (Status != STATUS_SUCCESS) {\r
-    return Status;\r
-  }\r
-\r
-  if (gOptions.CheckGuids || gOptions.CheckSignatures) {\r
-    Status = ProcessDirectory (Cwd, NULL);\r
-    if (Status == STATUS_SUCCESS) {\r
-      //\r
-      // Check for duplicates\r
-      //\r
-      Status = CheckDuplicates ();\r
-    }\r
-  }\r
-\r
-  if (gOptions.DatabaseOutputFileName[0] != 0) {\r
-    CreateGuidList (gOptions.DatabaseOutputFileName);\r
-  }\r
-  //\r
-  // Free up the memory\r
-  //\r
-  free (Cwd);\r
-  FreeGuids ();\r
-  FreeSigs ();\r
-  FreeOptions ();\r
-  return GetUtilityStatus ();\r
-}\r
-\r
-static\r
-STATUS\r
-ProcessArgs (\r
-  int     Argc,\r
-  char    *Argv[]\r
-  )\r
-{\r
-  STRING_LIST *StrList;\r
-\r
-  memset ((char *) &gOptions, 0, sizeof (gOptions));\r
-  //\r
-  // skip over program name\r
-  //\r
-  Argc--;\r
-  Argv++;\r
-\r
-  if (Argc == 0) {\r
-    Usage ();\r
-    return STATUS_ERROR;\r
-  }\r
-\r
-  while (Argc > 0) {\r
-    //\r
-    // Look for options\r
-    //\r
-    if ((Argv[0][0] == '-') || (Argv[0][0] == '/')) {\r
-      switch (Argv[0][1]) {\r
-      //\r
-      // Help option\r
-      //\r
-      case 'h':\r
-      case 'H':\r
-      case '?':\r
-        Usage ();\r
-        return STATUS_ERROR;\r
-        break;\r
-\r
-      //\r
-      // Check guids option\r
-      //\r
-      case 'g':\r
-      case 'G':\r
-        gOptions.CheckGuids = TRUE;\r
-        break;\r
-\r
-      //\r
-      // Check signatures option\r
-      //\r
-      case 's':\r
-      case 'S':\r
-        gOptions.CheckSignatures = TRUE;\r
-        break;\r
-\r
-      //\r
-      // Print guids found option\r
-      //\r
-      case 'p':\r
-      case 'P':\r
-        gOptions.PrintFound = TRUE;\r
-        break;\r
-\r
-      //\r
-      // Exclude files option\r
-      //\r
-      case 'f':\r
-      case 'F':\r
-        //\r
-        // Check for another arg\r
-        //\r
-        if (Argc < 2) {\r
-          Error (NULL, 0, 0, Argv[0], "missing argument with option");\r
-          Usage ();\r
-          return STATUS_ERROR;\r
-        }\r
-\r
-        StrList = malloc (sizeof (STRING_LIST));\r
-        if (StrList == NULL) {\r
-          Error (NULL, 0, 0, "memory allocation failure", NULL);\r
-          return STATUS_ERROR;\r
-        }\r
-\r
-        memset ((char *) StrList, 0, sizeof (STRING_LIST));\r
-        StrList->Str          = Argv[1];\r
-        StrList->Next         = gOptions.ExcludeFiles;\r
-        gOptions.ExcludeFiles = StrList;\r
-        Argc--;\r
-        Argv++;\r
-        break;\r
-\r
-      //\r
-      // Exclude directories option\r
-      //\r
-      case 'd':\r
-      case 'D':\r
-        //\r
-        // Check for another arg\r
-        //\r
-        if (Argc < 2) {\r
-          Error (NULL, 0, 0, Argv[0], "missing argument with option");\r
-          Usage ();\r
-          return STATUS_ERROR;\r
-        }\r
-\r
-        StrList = malloc (sizeof (STRING_LIST));\r
-        if (StrList == NULL) {\r
-          Error (NULL, 0, 0, "memory allocation failure", NULL);\r
-          return STATUS_ERROR;\r
-        }\r
-\r
-        memset ((char *) StrList, 0, sizeof (STRING_LIST));\r
-        StrList->Str          = Argv[1];\r
-        StrList->Next         = gOptions.ExcludeDirs;\r
-        gOptions.ExcludeDirs  = StrList;\r
-        Argc--;\r
-        Argv++;\r
-        break;\r
-\r
-      //\r
-      // -u  exclude all subdirectories of a given directory option\r
-      //\r
-      case 'u':\r
-      case 'U':\r
-        //\r
-        // Check for another arg\r
-        //\r
-        if (Argc < 2) {\r
-          Error (NULL, 0, 0, Argv[0], "missing argument with option");\r
-          Usage ();\r
-          return STATUS_ERROR;\r
-        }\r
-\r
-        StrList = malloc (sizeof (STRING_LIST));\r
-        if (StrList == NULL) {\r
-          Error (NULL, 0, 0, "memory allocation failure", NULL);\r
-          return STATUS_ERROR;\r
-        }\r
-\r
-        memset ((char *) StrList, 0, sizeof (STRING_LIST));\r
-        StrList->Str            = Argv[1];\r
-        StrList->Next           = gOptions.ExcludeSubDirs;\r
-        gOptions.ExcludeSubDirs = StrList;\r
-        Argc--;\r
-        Argv++;\r
-        break;\r
-\r
-      //\r
-      // -e  exclude by filename extension option\r
-      //\r
-      case 'e':\r
-      case 'E':\r
-        //\r
-        // Check for another arg\r
-        //\r
-        if (Argc < 2) {\r
-          Error (NULL, 0, 0, Argv[0], "missing argument with option");\r
-          Usage ();\r
-          return STATUS_ERROR;\r
-        }\r
-\r
-        StrList = malloc (sizeof (STRING_LIST));\r
-        if (StrList == NULL) {\r
-          Error (NULL, 0, 0, "memory allocation failure", NULL);\r
-          return STATUS_ERROR;\r
-        }\r
-\r
-        memset ((char *) StrList, 0, sizeof (STRING_LIST));\r
-        //\r
-        // Let them put a * in front of the filename extension\r
-        //\r
-        StrList->Str = Argv[1];\r
-        if (StrList->Str[0] == '*') {\r
-          StrList->Str++;\r
-        }\r
-\r
-        StrList->Next               = gOptions.ExcludeExtensions;\r
-        gOptions.ExcludeExtensions  = StrList;\r
-        Argc--;\r
-        Argv++;\r
-        break;\r
-\r
-      //\r
-      // Print guid with matching symbol name for guid definitions found\r
-      //\r
-      case 'x':\r
-      case 'X':\r
-        gOptions.GuidXReference = 1;\r
-        break;\r
-\r
-      //\r
-      // -b   Print the internal database list to a file\r
-      //\r
-      case 'b':\r
-      case 'B':\r
-        //\r
-        // Check for one more arg\r
-        //\r
-        if (Argc < 2) {\r
-          Error (NULL, 0, 0, Argv[0], "must specify file name with option");\r
-          Usage ();\r
-          return STATUS_ERROR;\r
-        }\r
-\r
-        strcpy (gOptions.DatabaseOutputFileName, Argv[1]);\r
-        Argc--;\r
-        Argv++;\r
-        break;\r
-\r
-      default:\r
-        Error (NULL, 0, 0, Argv[0], "invalid option");\r
-        Usage ();\r
-        return STATUS_ERROR;\r
-      }\r
-    } else {\r
-      break;\r
-    }\r
-    //\r
-    // Next arg\r
-    //\r
-    Argc--;\r
-    Argv++;\r
-  }\r
-\r
-  if (Argc > 0) {\r
-    Error (NULL, 0, 0, Argv[0], "invalid argument");\r
-    Usage ();\r
-    return STATUS_ERROR;\r
-  }\r
-  //\r
-  // Have to check signatures, GUIDs, or dump the GUID database.\r
-  //\r
-  if ((!gOptions.CheckGuids) && (!gOptions.CheckSignatures) && (gOptions.DatabaseOutputFileName[0] == 0)) {\r
-    Error (NULL, 0, 0, "nothing to do", "must specify -g, -s, and/or -b");\r
-    Usage ();\r
-    return STATUS_ERROR;\r
-  }\r
-\r
-  return STATUS_SUCCESS;\r
-}\r
-//\r
-// Print usage instructions\r
-//\r
-static\r
-VOID\r
-Usage (\r
-  VOID\r
-  )\r
-{\r
-  int   Index;\r
-  char  *Str[] = {\r
-    "GuidChk - scan files for duplicate GUID or signature definitions",\r
-    "",\r
-    "Usage:  GuidChk {options}\n",\r
-    "  Options: ",\r
-    "    -d dirname     exclude searching of a directory",\r
-    "    -f filename    exclude searching of a file",\r
-    "    -e extension   exclude searching of files by extension",\r
-    "    -p             print all GUIDS found",\r
-    "    -g             check for duplicate guids",\r
-    "    -s             check for duplicate signatures",\r
-    "    -x             print guid+defined symbol name",\r
-    "    -b outfile     write internal GUID+basename list to outfile",\r
-    "    -u dirname     exclude searching all subdirectories of a directory",\r
-    "    -h -?          print this help text",\r
-    " ",\r
-    "   Example: GuidChk -g -u build -d fv -f make.inf -e .pkg",\r
-    "",\r
-    NULL\r
-  };\r
-  for (Index = 0; Str[Index] != NULL; Index++) {\r
-    fprintf (stdout, "%s\n", Str[Index]);\r
-  }\r
-}\r
-//\r
-// Process an entire directory by name\r
-//\r
-static\r
-STATUS\r
-ProcessDirectory (\r
-  INT8          *Path,\r
-  INT8          *DirectoryName\r
-  )\r
-{\r
-  FILE_SEARCH_DATA  FSData;\r
-  char              *FileMask;\r
-  BOOLEAN           Done;\r
-  UINT32            Len;\r
-  BOOLEAN           NoSubdirs;\r
-  STRING_LIST       *SLPtr;\r
-\r
-  //\r
-  // Root directory may be null\r
-  //\r
-  if (DirectoryName != NULL) {\r
-    //\r
-    // printf ("Processing directory: %s\n", DirectoryName);\r
-    //\r
-  }\r
-  //\r
-  // Initialize our file searching\r
-  //\r
-  FileSearchInit (&FSData);\r
-\r
-  //\r
-  // Exclude some directories, files, and extensions\r
-  //\r
-  FileSearchExcludeDirs (&FSData, gOptions.ExcludeDirs);\r
-  FileSearchExcludeExtensions (&FSData, gOptions.ExcludeExtensions);\r
-  FileSearchExcludeFiles (&FSData, gOptions.ExcludeFiles);\r
-  //\r
-  // See if this directory is in the list of directories that they\r
-  // don't want to process subdirectories of\r
-  //\r
-  NoSubdirs = FALSE;\r
-  if (DirectoryName != NULL) {\r
-    for (SLPtr = gOptions.ExcludeSubDirs; SLPtr != NULL; SLPtr = SLPtr->Next) {\r
-      if (stricmp (SLPtr->Str, DirectoryName) == 0) {\r
-        //\r
-        // printf ("not processing subdirectories of %s\n", DirectoryName);\r
-        //\r
-        NoSubdirs = TRUE;\r
-        break;\r
-      }\r
-    }\r
-  }\r
-  //\r
-  // Create a filemask of files to search for. We'll append "\*.*" on the\r
-  // end, so allocate some extra bytes.\r
-  //\r
-  Len = strlen (Path) + 10;\r
-  if (DirectoryName != NULL) {\r
-    Len += strlen (DirectoryName);\r
-  }\r
-\r
-  FileMask = malloc (Len);\r
-  if (FileMask == NULL) {\r
-    Error (NULL, 0, 0, "memory allocation failure", NULL);\r
-    return STATUS_ERROR;\r
-  }\r
-  //\r
-  // Now put it all together\r
-  //\r
-  strcpy (FileMask, Path);\r
-  if ((DirectoryName != NULL) && (strlen (DirectoryName) > 0)) {\r
-    strcat (FileMask, "\\");\r
-    strcat (FileMask, DirectoryName);\r
-  }\r
-\r
-  strcat (FileMask, "\\*.*");\r
-\r
-  //\r
-  // Start file searching for files and directories\r
-  //\r
-  FileSearchStart (&FSData, FileMask, FILE_SEARCH_FILE | FILE_SEARCH_DIR);\r
-\r
-  //\r
-  // Now hack the "\*.*" off the end of the filemask so we can use it to pass\r
-  // the full directory path on recursive calls to process directories.\r
-  //\r
-  FileMask[strlen (FileMask) - 4] = 0;\r
-\r
-  //\r
-  // Loop until no more files\r
-  //\r
-  Done = FALSE;\r
-  while (!Done) {\r
-    //\r
-    // printf ("Found %s...", FSData.FileName);\r
-    //\r
-    if (FSData.FileFlags & FILE_SEARCH_DIR) {\r
-      //\r
-      // printf ("directory\n");\r
-      //\r
-      if (!NoSubdirs) {\r
-        ProcessDirectory (FileMask, FSData.FileName);\r
-      }\r
-    } else if (FSData.FileFlags & FILE_SEARCH_FILE) {\r
-      //\r
-      // printf ("file\n");\r
-      //\r
-      ProcessFile (FileMask, FSData.FileName);\r
-    } else {\r
-      //\r
-      // printf ("unknown\n");\r
-      //\r
-    }\r
-\r
-    if (FileSearchFindNext (&FSData) != STATUS_SUCCESS) {\r
-      Done = TRUE;\r
-    }\r
-  }\r
-  //\r
-  // Free up allocated memory\r
-  //\r
-  free (FileMask);\r
-\r
-  //\r
-  // Free up our file searching\r
-  //\r
-  FileSearchDestroy (&FSData);\r
-\r
-  return STATUS_SUCCESS;\r
-}\r
-//\r
-// Process a single file.\r
-//\r
-static\r
-STATUS\r
-ProcessFile (\r
-  INT8                *DirectoryName,\r
-  INT8                *FileName\r
-  )\r
-{\r
-  STATUS  Status;\r
-  UINT32  FileExtension;\r
-  INT8    FullFileName[MAX_PATH];\r
-\r
-  Status = STATUS_SUCCESS;\r
-\r
-  sprintf (FullFileName, "%s\\%s", DirectoryName, FileName);\r
-  //\r
-  // printf ("Found file: %s\n", FullFileName);\r
-  //\r
-  FileExtension = GetFileExtension (FileName);\r
-\r
-  //\r
-  // Process these for GUID checks\r
-  //\r
-  if (gOptions.CheckGuids) {\r
-    switch (FileExtension) {\r
-    case FILE_EXTENSION_C:\r
-    case FILE_EXTENSION_H:\r
-      Status = ProcessCFileGuids (FullFileName);\r
-      break;\r
-\r
-    case FILE_EXTENSION_PKG:\r
-      Status = ProcessPkgFileGuids (FullFileName);\r
-      break;\r
-\r
-    case FILE_EXTENSION_IA32_INC:\r
-    case FILE_EXTENSION_IA32_ASM:\r
-      Status = ProcessIA32FileGuids (FullFileName);\r
-      break;\r
-\r
-    case FILE_EXTENSION_INF:\r
-      Status = ProcessINFFileGuids (FullFileName);\r
-      break;\r
-\r
-    case FILE_EXTENSION_IA64_INC:\r
-    case FILE_EXTENSION_IA64_ASM:\r
-      Status = ProcessIA64FileGuids (FullFileName);\r
-      break;\r
-\r
-    default:\r
-      //\r
-      // No errors anyway\r
-      //\r
-      Status = STATUS_SUCCESS;\r
-      break;\r
-    }\r
-  }\r
-\r
-  if (gOptions.CheckSignatures) {\r
-    switch (FileExtension) {\r
-    case FILE_EXTENSION_C:\r
-    case FILE_EXTENSION_H:\r
-      Status = ProcessCFileSigs (FullFileName);\r
-      break;\r
-\r
-    default:\r
-      //\r
-      // No errors anyway\r
-      //\r
-      Status = STATUS_SUCCESS;\r
-      break;\r
-    }\r
-  }\r
-\r
-  return Status;\r
-}\r
-//\r
-// Return a code indicating the file name extension.\r
-//\r
-static\r
-UINT32\r
-GetFileExtension (\r
-  INT8        *FileName\r
-  )\r
-{\r
-  INT8  *Extension;\r
-  int   Index;\r
-\r
-  //\r
-  // Look back for a filename extension\r
-  //\r
-  for (Extension = FileName + strlen (FileName) - 1; Extension >= FileName; Extension--) {\r
-    if (*Extension == '.') {\r
-      for (Index = 0; FileTypeTable[Index].Extension != NULL; Index++) {\r
-        if (stricmp (FileTypeTable[Index].Extension, Extension) == 0) {\r
-          return FileTypeTable[Index].ExtensionCode;\r
-        }\r
-      }\r
-    }\r
-  }\r
-\r
-  return FILE_TYPE_UNKNOWN;\r
-}\r
-//\r
-// Process a .pkg file.\r
-//\r
-// Look for FFS_FILEGUID=35b898ca-b6a9-49ce-8c72-904735cc49b7\r
-//\r
-static\r
-STATUS\r
-ProcessPkgFileGuids (\r
-  INT8    *FileName\r
-  )\r
-{\r
-  FILE    *Fptr;\r
-  INT8    Line[MAX_LINE_LEN * 2];\r
-  INT8    *Cptr;\r
-  INT8    *Cptr2;\r
-  UINT32  GuidScan[11];\r
-  UINT64  Guid64;\r
-\r
-  if ((Fptr = fopen (FileName, "r")) == NULL) {\r
-    Error (NULL, 0, 0, FileName, "could not open input file for reading");\r
-    return STATUS_ERROR;\r
-  }\r
-  //\r
-  // Read lines from the file until done\r
-  //\r
-  while (fgets (Line, sizeof (Line), Fptr) != NULL) {\r
-    Cptr = Line;\r
-    Cptr += SkipWhiteSpace (Line);\r
-    if (strncmp (Cptr, "FFS_FILEGUID", 12) == 0) {\r
-      Cptr += 12;\r
-      Cptr += SkipWhiteSpace (Cptr);\r
-      if (*Cptr == '=') {\r
-        Cptr++;\r
-        Cptr += SkipWhiteSpace (Cptr + 1);\r
-        //\r
-        // Blank out dashes on the line.\r
-        //\r
-        for (Cptr2 = Cptr; *Cptr2; Cptr2++) {\r
-          if (*Cptr2 == '-') {\r
-            *Cptr2 = ' ';\r
-          }\r
-        }\r
-\r
-        if (sscanf (\r
-              Cptr,\r
-              "%X %X %X %X %I64X",\r
-              &GuidScan[0],\r
-              &GuidScan[1],\r
-              &GuidScan[2],\r
-              &GuidScan[3],\r
-              &Guid64\r
-              ) == 5) {\r
-          AddPkgGuid (FileName, GuidScan, &Guid64);\r
-        } else {\r
-          DebugMsg (NULL, 0, 0, FileName, "GUID scan failed");\r
-        }\r
-      }\r
-    }\r
-  }\r
-\r
-  fclose (Fptr);\r
-  return STATUS_SUCCESS;\r
-}\r
-//\r
-// Process an IA32 assembly file.\r
-//\r
-// Look for:\r
-// FIND_FD_GUID_VAL equ  01h, 01h, 01h, 01h, 01h, 01h, 01h, 01h, 01h, 01h, 01h, 01h, 01h, 01h, 01h, 01h\r
-// PEI_GUID_FileNameGuid_Gmch815  equ  081818181h, 08181h, 08181h, 081h, 081h, 081h, 081h, 081h, 081h, 081h, 081h\r
-//\r
-static\r
-STATUS\r
-ProcessIA32FileGuids (\r
-  INT8    *FileName\r
-  )\r
-{\r
-  FILE    *Fptr;\r
-  INT8    Line[MAX_LINE_LEN];\r
-  INT8    *Cptr;\r
-  INT8    CSave;\r
-  INT8    *CSavePtr;\r
-  UINT32  Len;\r
-  UINT32  GuidData[16];\r
-  UINT32  Index;\r
-\r
-  if ((Fptr = fopen (FileName, "r")) == NULL) {\r
-    Error (NULL, 0, 0, FileName, "could not open input file for reading");\r
-    return STATUS_ERROR;\r
-  }\r
-  //\r
-  // Read lines from the file until done\r
-  //\r
-  while (fgets (Line, sizeof (Line), Fptr) != NULL) {\r
-    Cptr = Line;\r
-    Cptr += SkipWhiteSpace (Line);\r
-    //\r
-    // Look for xxxGUIDyyy equ 01h, 02h, 03h, ...\r
-    //\r
-    Len = ValidSymbolName (Cptr);\r
-    if (Len) {\r
-      //\r
-      // Terminate the line after the symbol name, then look for "guid" in\r
-      // the name.\r
-      //\r
-      CSavePtr  = Cptr + Len;\r
-      CSave     = *CSavePtr;\r
-      *CSavePtr = 0;\r
-      while (*Cptr) {\r
-        if (strnicmp (Cptr, "guid", 4) == 0) {\r
-          break;\r
-        }\r
-\r
-        Cptr++;\r
-      }\r
-      //\r
-      // If we found the string "guid", continue\r
-      //\r
-      if (*Cptr) {\r
-        //\r
-        // Restore the character on the line where we null-terminated the symbol\r
-        //\r
-        *CSavePtr = CSave;\r
-        Cptr      = CSavePtr;\r
-        Len       = SkipWhiteSpace (Cptr);\r
-        //\r
-        // Had to be some white space\r
-        //\r
-        if (Len) {\r
-          Cptr += Len;\r
-          //\r
-          // now look for "equ"\r
-          //\r
-          if (strnicmp (Cptr, "equ", 3) == 0) {\r
-            Cptr += 3;\r
-            Cptr += SkipWhiteSpace (Cptr);\r
-            //\r
-            // Now scan all the data\r
-            //\r
-            for (Index = 0; Index < 16; Index++) {\r
-              if (sscanf (Cptr, "%X", &GuidData[Index]) != 1) {\r
-                break;\r
-              }\r
-              //\r
-              // Skip to next\r
-              //\r
-              while (isxdigit (*Cptr)) {\r
-                Cptr++;\r
-              }\r
-\r
-              if ((*Cptr != 'h') && (*Cptr != 'H')) {\r
-                break;\r
-              } else {\r
-                Cptr++;\r
-                while (*Cptr && (isspace (*Cptr) || (*Cptr == ','))) {\r
-                  Cptr++;\r
-                }\r
-              }\r
-            }\r
-            //\r
-            // Now see which form we had\r
-            //\r
-            if (Index == 16) {\r
-              AddGuid16 (FileName, GuidData);\r
-            } else if (Index == 11) {\r
-              AddGuid11 (FileName, GuidData, NULL);\r
-            }\r
-          }\r
-        }\r
-      }\r
-    }\r
-  }\r
-\r
-  fclose (Fptr);\r
-  return STATUS_SUCCESS;\r
-}\r
-//\r
-// Found and parsed an IA32 assembly code guid. Save the 16 bytes off in the list\r
-// of guids.\r
-//\r
-static\r
-STATUS\r
-AddGuid16 (\r
-  INT8      *FileName,\r
-  UINT32    *Data\r
-  )\r
-{\r
-  GUID_RECORD *NewRec;\r
-  int         Index;\r
-\r
-  //\r
-  // Sanity check the data\r
-  //\r
-  if (!CheckGuidData (Data, 16)) {\r
-    return STATUS_ERROR;\r
-  }\r
-  //\r
-  // Allocate memory for a new guid structure\r
-  //\r
-  NewRec = malloc (sizeof (GUID_RECORD));\r
-  if (NewRec == NULL) {\r
-    Error (NULL, 0, 0, "memory allocation failure", NULL);\r
-    return STATUS_ERROR;\r
-  }\r
-\r
-  memset ((char *) NewRec, 0, sizeof (GUID_RECORD));\r
-  NewRec->FileName = malloc (strlen (FileName) + 1);\r
-  if (NewRec->FileName == NULL) {\r
-    free (NewRec);\r
-    Error (NULL, 0, 0, "memory allocation failure", NULL);\r
-    return STATUS_ERROR;\r
-  }\r
-\r
-  strcpy (NewRec->FileName, FileName);\r
-  NewRec->Guid.Data1  = (UINT32) (Data[0] | (Data[1] << 8) | (Data[2] << 16) | (Data[3] << 24));\r
-  NewRec->Guid.Data2  = (UINT16) (Data[4] | (Data[5] << 8));\r
-  NewRec->Guid.Data3  = (UINT16) (Data[6] | (Data[7] << 8));\r
-  for (Index = 0; Index < 8; Index++) {\r
-    NewRec->Guid.Data4[Index] = (UINT8) Data[Index + 8];\r
-  }\r
-  //\r
-  // Add it to the list\r
-  //\r
-  NewRec->Next  = gGuidList;\r
-  gGuidList     = NewRec;\r
-\r
-  //\r
-  // Report it\r
-  // ReportGuid (FileName, NewRec);\r
-  //\r
-  return STATUS_SUCCESS;\r
-}\r
-//\r
-// Add a GUID defined as GuidLow: 0x1122334455667788\r
-//                       GuidHi:  0x99AABBCCDDEEFF00\r
-//\r
-// These are equivalent:\r
-// { 0x11223344, 0x5566, 0x7788, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF, 0x00 }\r
-//    and:\r
-// Low: 00FFEEDDCCBBAA99\r
-// Hi:  7788556611223344\r
-//\r
-static\r
-STATUS\r
-AddGuid64x2 (\r
-  INT8      *FileName,\r
-  UINT32    DataHH, // Upper 32-bits of upper 64 bits of guid\r
-  UINT32    DataHL, // Lower 32-bits of upper 64 bits\r
-  UINT32    DataLH,\r
-  UINT32    DataLL\r
-  )\r
-{\r
-  GUID_RECORD *NewRec;\r
-  int         Index;\r
-\r
-  //\r
-  // Allocate memory for a new guid structure\r
-  //\r
-  NewRec = malloc (sizeof (GUID_RECORD));\r
-  if (NewRec == NULL) {\r
-    Error (NULL, 0, 0, "memory allocation failure", NULL);\r
-    return STATUS_ERROR;\r
-  }\r
-\r
-  memset ((char *) NewRec, 0, sizeof (GUID_RECORD));\r
-  NewRec->FileName = malloc (strlen (FileName) + 1);\r
-  if (NewRec->FileName == NULL) {\r
-    free (NewRec);\r
-    Error (NULL, 0, 0, "memory allocation failure", NULL);\r
-    return STATUS_ERROR;\r
-  }\r
-\r
-  strcpy (NewRec->FileName, FileName);\r
-  NewRec->Guid.Data1  = DataHL;\r
-  NewRec->Guid.Data2  = (UINT16) DataHH;\r
-  NewRec->Guid.Data3  = (UINT16) (DataHH >> 16);\r
-  for (Index = 0; Index < 4; Index++) {\r
-    NewRec->Guid.Data4[Index] = (UINT8) DataLL;\r
-    DataLL >>= 8;\r
-  }\r
-\r
-  for (Index = 0; Index < 4; Index++) {\r
-    NewRec->Guid.Data4[Index + 4] = (UINT8) DataLH;\r
-    DataLH >>= 8;\r
-  }\r
-  //\r
-  // Add it to the list\r
-  //\r
-  NewRec->Next  = gGuidList;\r
-  gGuidList     = NewRec;\r
-\r
-  //\r
-  // Report it\r
-  // ReportGuid (FileName, NewRec);\r
-  //\r
-  return STATUS_SUCCESS;\r
-}\r
-//\r
-// Process INF files. Look for:\r
-// FILE_GUID            = 240612B6-A063-11d4-9A3A-0090273FC14D\r
-//\r
-static\r
-STATUS\r
-ProcessINFFileGuids (\r
-  INT8    *FileName\r
-  )\r
-{\r
-  FILE    *Fptr;\r
-  INT8    Line[MAX_LINE_LEN * 2];\r
-  INT8    *Cptr;\r
-  INT8    *Cptr2;\r
-  UINT32  GuidScan[11];\r
-  UINT64  Guid64;\r
-\r
-  if ((Fptr = fopen (FileName, "r")) == NULL) {\r
-    Error (NULL, 0, 0, FileName, "could not open input file for reading");\r
-    return STATUS_ERROR;\r
-  }\r
-  //\r
-  // Read lines from the file until done\r
-  //\r
-  while (fgets (Line, sizeof (Line), Fptr) != NULL) {\r
-    Cptr = Line;\r
-    Cptr += SkipWhiteSpace (Line);\r
-    if (strncmp (Cptr, "FILE_GUID", 9) == 0) {\r
-      Cptr += 9;\r
-      Cptr += SkipWhiteSpace (Cptr);\r
-      if (*Cptr == '=') {\r
-        Cptr++;\r
-        Cptr += SkipWhiteSpace (Cptr + 1);\r
-        //\r
-        // Blank out dashes on the line.\r
-        //\r
-        for (Cptr2 = Cptr; *Cptr2; Cptr2++) {\r
-          if (*Cptr2 == '-') {\r
-            *Cptr2 = ' ';\r
-          }\r
-        }\r
-\r
-        if (sscanf (\r
-              Cptr,\r
-              "%X %X %X %X %I64X",\r
-              &GuidScan[0],\r
-              &GuidScan[1],\r
-              &GuidScan[2],\r
-              &GuidScan[3],\r
-              &Guid64\r
-              ) == 5) {\r
-          AddPkgGuid (FileName, GuidScan, &Guid64);\r
-        } else {\r
-          DebugMsg (NULL, 0, 0, FileName, "GUID scan failed");\r
-        }\r
-      }\r
-    }\r
-  }\r
-\r
-  fclose (Fptr);\r
-  return STATUS_SUCCESS;\r
-}\r
-//\r
-// Parse ('g','m','a','p','a','b','c','d')\r
-//\r
-static\r
-STATUS\r
-AddSignature (\r
-  INT8      *FileName,\r
-  INT8      *StrDef,\r
-  UINT32    SigSize\r
-  )\r
-{\r
-  SIGNATURE_RECORD  *NewRec;\r
-  INT8              *Cptr;\r
-  UINT32            Index;\r
-  BOOLEAN           Fail;\r
-\r
-  //\r
-  // Allocate memory for the new record\r
-  //\r
-  Fail    = FALSE;\r
-  NewRec  = malloc (sizeof (SIGNATURE_RECORD));\r
-  if (NewRec == NULL) {\r
-    Error (NULL, 0, 0, "memory allocation failure", NULL);\r
-    return STATUS_ERROR;\r
-  }\r
-  //\r
-  // Allocate memory to save the file name\r
-  //\r
-  NewRec->FileName = malloc (strlen (FileName) + 1);\r
-  if (NewRec->FileName == NULL) {\r
-    Error (NULL, 0, 0, "memory allocation failure", NULL);\r
-    free (NewRec);\r
-    return STATUS_ERROR;\r
-  }\r
-  //\r
-  // Fill in the fields\r
-  //\r
-  strcpy (NewRec->FileName, FileName);\r
-  NewRec->Signature.DataLen = (UINT8) SigSize;\r
-  //\r
-  // Skip to open parenthesis\r
-  //\r
-  Cptr = StrDef;\r
-  Cptr += SkipWhiteSpace (Cptr);\r
-  if (*Cptr != '(') {\r
-    Fail = TRUE;\r
-    goto Done;\r
-  }\r
-\r
-  Cptr++;\r
-  //\r
-  // Skip to first ' and start processing\r
-  //\r
-  while (*Cptr && (*Cptr != '\'')) {\r
-    Cptr++;\r
-  }\r
-\r
-  for (Index = 0; Index < SigSize; Index++) {\r
-    if (*Cptr == '\'') {\r
-      Cptr++;\r
-      NewRec->Signature.Data[Index] = (INT8) *Cptr;\r
-      //\r
-      // Skip to closing quote\r
-      //\r
-      Cptr++;\r
-      if (*Cptr != '\'') {\r
-        Fail = TRUE;\r
-        break;\r
-      }\r
-      //\r
-      // Skip over closing quote, go to next one\r
-      //\r
-      Cptr++;\r
-      while (*Cptr && (*Cptr != '\'')) {\r
-        Cptr++;\r
-      }\r
-    } else {\r
-      Fail = TRUE;\r
-      DebugMsg (NULL, 0, 0, StrDef, "failed to parse signature");\r
-      break;\r
-    }\r
-  }\r
-\r
-Done:\r
-  if (Fail) {\r
-    free (NewRec->FileName);\r
-    free (NewRec);\r
-    return STATUS_ERROR;\r
-  }\r
-\r
-  NewRec->Next    = gSignatureList;\r
-  gSignatureList  = NewRec;\r
-  return STATUS_SUCCESS;\r
-}\r
-//\r
-// Look for:\r
-// #define POOL_HEAD_SIGNATURE         EFI_SIGNATURE_16('p','h')\r
-// #define GCD_MEMORY_MAP_SIGNATURE    EFI_SIGNATURE_32('g','m','a','p')\r
-// #define GCD_MEMORY_MAP_SIGNATURE    EFI_SIGNATURE_64('g','m','a','p','a','b','c','d')\r
-//\r
-static\r
-STATUS\r
-ProcessCFileSigs (\r
-  INT8    *FileName\r
-  )\r
-{\r
-  FILE    *Fptr;\r
-  INT8    Line[MAX_LINE_LEN * 2];\r
-  INT8    *Cptr;\r
-  UINT32  Len;\r
-  UINT32  LineLen;\r
-\r
-  if ((Fptr = fopen (FileName, "r")) == NULL) {\r
-    Error (NULL, 0, 0, FileName, "could not open input file for reading");\r
-    return STATUS_ERROR;\r
-  }\r
-  //\r
-  // Read lines from the file until done\r
-  //\r
-  while (fgets (Line, sizeof (Line), Fptr) != NULL) {\r
-    Cptr = Line;\r
-    Cptr += SkipWhiteSpace (Line);\r
-    //\r
-    // look for #define xxxGUIDxxx value\r
-    //\r
-    if (*Cptr == '#') {\r
-      Cptr++;\r
-      Cptr += SkipWhiteSpace (Cptr);\r
-      //\r
-      // Look for "define"\r
-      //\r
-      if (!strncmp (Cptr, "define", 6)) {\r
-        Cptr += 6;\r
-        //\r
-        // Better be whitespace\r
-        //\r
-        Len = SkipWhiteSpace (Cptr);\r
-        if (Len) {\r
-          Cptr += Len;\r
-          //\r
-          // See if it's a valid symbol name\r
-          //\r
-          Len = ValidSymbolName (Cptr);\r
-          if (Len) {\r
-            //\r
-            // It is a valid symbol name. See if there's a line continuation,\r
-            // and if so, read one more line.\r
-            // Skip over the symbol name and look for the string "EFI_SIGNATURE_xx"\r
-            //\r
-            LineLen = strlen (Line);\r
-            if ((Line[LineLen - 1] == '\n') && (Line[LineLen - 2] == '\\')) {\r
-              fgets (Line + LineLen - 2, sizeof (Line) - LineLen, Fptr);\r
-            } else if (Line[LineLen - 1] == '\\') {\r
-              fgets (Line + LineLen - 1, sizeof (Line) - LineLen, Fptr);\r
-            }\r
-\r
-            Cptr += Len;\r
-            Cptr += SkipWhiteSpace (Cptr);\r
-            if (strncmp (Cptr, "EFI_SIGNATURE_16", 16) == 0) {\r
-              AddSignature (FileName, Cptr + 16, 2);\r
-            } else if (strncmp (Cptr, "EFI_SIGNATURE_32", 16) == 0) {\r
-              AddSignature (FileName, Cptr + 16, 4);\r
-            } else if (strncmp (Cptr, "EFI_SIGNATURE_64", 16) == 0) {\r
-              AddSignature (FileName, Cptr + 16, 8);\r
-            }\r
-          }\r
-        }\r
-      }\r
-    }\r
-  }\r
-\r
-  fclose (Fptr);\r
-  return STATUS_SUCCESS;\r
-}\r
-//\r
-// look for #define xxxGUIDyyy { 0x...}\r
-// xxx EFI_GUID  GuidName = { 0x... };\r
-//\r
-static\r
-STATUS\r
-ProcessCFileGuids (\r
-  INT8    *FileName\r
-  )\r
-{\r
-  FILE    *Fptr;\r
-  INT8    Line[MAX_LINE_LEN * 2];\r
-  INT8    *Cptr;\r
-  INT8    CSave;\r
-  INT8    *CSavePtr;\r
-  INT8    *TempCptr;\r
-  INT8    *SymName;\r
-  UINT32  Len;\r
-  UINT32  LineLen;\r
-  UINT32  GuidScan[11];\r
-\r
-  if ((Fptr = fopen (FileName, "r")) == NULL) {\r
-    Error (NULL, 0, 0, FileName, "could not open input file for reading");\r
-    return STATUS_ERROR;\r
-  }\r
-  //\r
-  // Read lines from the file until done\r
-  //\r
-  while (fgets (Line, sizeof (Line), Fptr) != NULL) {\r
-    Cptr = Line;\r
-    Cptr += SkipWhiteSpace (Line);\r
-    //\r
-    // look for #define xxxGUIDxxx value\r
-    //\r
-    if (*Cptr == '#') {\r
-      Cptr++;\r
-      Cptr += SkipWhiteSpace (Cptr);\r
-      //\r
-      // Look for "define"\r
-      //\r
-      if (!strncmp (Cptr, "define", 6)) {\r
-        Cptr += 6;\r
-        //\r
-        // Better be whitespace\r
-        //\r
-        Len = SkipWhiteSpace (Cptr);\r
-        if (Len) {\r
-          Cptr += Len;\r
-          //\r
-          // See if it's a valid symbol name\r
-          //\r
-          Len = ValidSymbolName (Cptr);\r
-          if (Len) {\r
-            //\r
-            // It is a valid symbol name. See if there's a line continuation,\r
-            // and if so, read one more line.\r
-            // Then truncate after the symbol name, look for the string "GUID",\r
-            // and continue.\r
-            //\r
-            SymName = Cptr;\r
-            LineLen = strlen (Line);\r
-            if ((Line[LineLen - 1] == '\n') && (Line[LineLen - 2] == '\\')) {\r
-              fgets (Line + LineLen - 2, sizeof (Line) - LineLen, Fptr);\r
-            } else if (Line[LineLen - 1] == '\\') {\r
-              fgets (Line + LineLen - 1, sizeof (Line) - LineLen, Fptr);\r
-            }\r
-\r
-            CSavePtr  = Cptr + Len;\r
-            CSave     = *CSavePtr;\r
-            *CSavePtr = 0;\r
-            while (*Cptr) {\r
-              if (strncmp (Cptr, "GUID", 4) == 0) {\r
-                break;\r
-              }\r
-\r
-              Cptr++;\r
-            }\r
-            //\r
-            // If we didn't run out of string, then we found the GUID string.\r
-            // Now look for { 0x....... }\r
-            //\r
-            if (*Cptr) {\r
-              Cptr      = CSavePtr;\r
-              *CSavePtr = CSave;\r
-              Cptr += SkipWhiteSpace (Cptr);\r
-              if (*Cptr == '{') {\r
-                *Cptr = 0;\r
-                Cptr++;\r
-                //\r
-                // 0x665E3FF6, 0x46CC, 0x11d4, 0x9A, 0x38, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0x4D }\r
-                // If you have one suffixed with "L", then it doesn't work. So hack off 'L' characters\r
-                // in the string.\r
-                //\r
-                for (TempCptr = Cptr; *TempCptr; TempCptr++) {\r
-                  if (*TempCptr == 'L') {\r
-                    if (*(TempCptr + 1) == ',') {\r
-                      *TempCptr       = ',';\r
-                      *(TempCptr + 1) = ' ';\r
-                    }\r
-                  }\r
-                }\r
-\r
-                if (sscanf (\r
-                      Cptr,\r
-                      "%X, %X, %X, %X, %X, %X, %X, %X, %X, %X, %X",\r
-                      &GuidScan[0],\r
-                      &GuidScan[1],\r
-                      &GuidScan[2],\r
-                      &GuidScan[3],\r
-                      &GuidScan[4],\r
-                      &GuidScan[5],\r
-                      &GuidScan[6],\r
-                      &GuidScan[7],\r
-                      &GuidScan[8],\r
-                      &GuidScan[9],\r
-                      &GuidScan[10]\r
-                      ) == 11) {\r
-                  AddGuid11 (FileName, GuidScan, SymName);\r
-                }\r
-              }\r
-            }\r
-          }\r
-        }\r
-      }\r
-      //\r
-      // Else look for "static EFI_GUID xxxGUIDxxx = { 0x.... };\r
-      //\r
-    } else if ((CSavePtr = strstr (Line, "EFI_GUID")) != NULL) {\r
-      //\r
-      // Read the next line if line continuation\r
-      //\r
-      LineLen = strlen (Line);\r
-      if ((Line[LineLen - 1] == '\n') && (Line[LineLen - 2] == '\\')) {\r
-        fgets (Line + LineLen - 2, sizeof (Line) - LineLen, Fptr);\r
-      } else if (Line[LineLen - 1] == '\\') {\r
-        fgets (Line + LineLen - 1, sizeof (Line) - LineLen, Fptr);\r
-      }\r
-\r
-      Cptr = CSavePtr + 8;\r
-      Cptr += SkipWhiteSpace (Cptr);\r
-      //\r
-      // Should be variable name next\r
-      //\r
-      Len     = ValidSymbolName (Cptr);\r
-      SymName = Cptr;\r
-      Cptr += Len;\r
-      Cptr += SkipWhiteSpace (Cptr);\r
-      if (*Cptr == '=') {\r
-        Cptr++;\r
-        Cptr += SkipWhiteSpace (Cptr);\r
-        //\r
-        // Should be open-brace next to define guid\r
-        //\r
-        if (*Cptr == '{') {\r
-          Cptr++;\r
-          //\r
-          // 0x665E3FF6, 0x46CC, 0x11d4, 0x9A, 0x38, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0x4D }\r
-          //\r
-          if (sscanf (\r
-                Cptr,\r
-                "%X, %X, %X, %X, %X, %X, %X, %X, %X, %X, %X",\r
-                &GuidScan[0],\r
-                &GuidScan[1],\r
-                &GuidScan[2],\r
-                &GuidScan[3],\r
-                &GuidScan[4],\r
-                &GuidScan[5],\r
-                &GuidScan[6],\r
-                &GuidScan[7],\r
-                &GuidScan[8],\r
-                &GuidScan[9],\r
-                &GuidScan[10]\r
-                ) == 11) {\r
-            AddGuid11 (FileName, GuidScan, Cptr);\r
-            //\r
-            // printf ("Found guid: %s", Cptr);\r
-            //\r
-          }\r
-        }\r
-      }\r
-    }\r
-  }\r
-\r
-  fclose (Fptr);\r
-  return STATUS_SUCCESS;\r
-}\r
-//\r
-// Process Intel Itanium(TM) GUID definitions. Look for:\r
-// #define Cs870MemoryTestPEIMGuidL 0x9C2403386E1C8FAA\r
-// #define Cs870MemoryTestPEIMGuidH 0xE89E95C6180342f0\r
-// in either order.\r
-// This function assumes no blank lines between definitions.\r
-//\r
-static\r
-STATUS\r
-ProcessIA64FileGuids (\r
-  INT8    *FileName\r
-  )\r
-{\r
-  FILE    *Fptr;\r
-  INT8    Line[MAX_LINE_LEN];\r
-  UINT32  Guid1H;\r
-  UINT32  Guid1L;\r
-  UINT32  Guid2H;\r
-  UINT32  Guid2L;\r
-  INT8    SymName1[MAX_LINE_LEN];\r
-  INT8    SymName2[MAX_LINE_LEN];\r
-  BOOLEAN Done;\r
-  BOOLEAN LowFirst;\r
-  BOOLEAN FoundLow;\r
-\r
-  if ((Fptr = fopen (FileName, "r")) == NULL) {\r
-    Error (NULL, 0, 0, FileName, "could not open input file for reading");\r
-    return STATUS_ERROR;\r
-  }\r
-\r
-  Done = FALSE;\r
-  if (fgets (Line, sizeof (Line), Fptr) == NULL) {\r
-    Done = 1;\r
-  }\r
-  //\r
-  // Read lines from the file until done. Since the guid definition takes\r
-  // two lines, we read lines in different places to recover gracefully\r
-  // from mismatches. For example, if you thought you found the first half,\r
-  // but the next line had a symbol mismatch, then you have to process the\r
-  // line again in case it's the start of a new definition.\r
-  //\r
-  while (!Done) {\r
-    //\r
-    // Check current line for GUID definition. Assume low define first.\r
-    //\r
-    if (IsIA64GuidLine (Line, &Guid1H, &Guid1L, &FoundLow, SymName1)) {\r
-      //\r
-      // Might have to swap guids later. Save off if we found the LOW first\r
-      //\r
-      if (FoundLow) {\r
-        LowFirst = TRUE;\r
-      } else {\r
-        LowFirst = FALSE;\r
-      }\r
-      //\r
-      // Read the next line and try for the rest of the guid definition\r
-      //\r
-      if (fgets (Line, sizeof (Line), Fptr) == NULL) {\r
-        Done = 1;\r
-      } else {\r
-        if (IsIA64GuidLine (Line, &Guid2H, &Guid2L, &FoundLow, SymName2)) {\r
-          //\r
-          // Found another. If the symbol names match, then save it off.\r
-          //\r
-          if (strcmp (SymName1, SymName2) == 0) {\r
-            //\r
-            // Yea, found one. Save it off.\r
-            //\r
-            if (LowFirst) {\r
-              AddGuid64x2 (FileName, Guid2H, Guid2L, Guid1H, Guid1L);\r
-            } else {\r
-              AddGuid64x2 (FileName, Guid1H, Guid1L, Guid2H, Guid2L);\r
-            }\r
-            //\r
-            // Read the next line for processing\r
-            //\r
-            if (fgets (Line, sizeof (Line), Fptr) == NULL) {\r
-              Done = 1;\r
-            }\r
-          } else {\r
-            //\r
-            // Don't get another line so that we reprocess this line in case it\r
-            // contains the start of a new definition.\r
-            // fprintf (stdout, "Symbol name mismatch: %s: %s != %s\n",\r
-            //    FileName, SymName1, SymName2);\r
-            //\r
-          }\r
-        } else {\r
-          //\r
-          // Second line was not a guid definition. Get the next line from the\r
-          // file.\r
-          //\r
-          if (fgets (Line, sizeof (Line), Fptr) == NULL) {\r
-            Done = 1;\r
-          }\r
-        }\r
-      }\r
-    } else {\r
-      //\r
-      // Not a guid define line. Next.\r
-      //\r
-      if (fgets (Line, sizeof (Line), Fptr) == NULL) {\r
-        Done = 1;\r
-      }\r
-    }\r
-  }\r
-\r
-  fclose (Fptr);\r
-  return STATUS_SUCCESS;\r
-}\r
-//\r
-// Given a line from an Itanium-based assembly file, check the line for a guid\r
-// defininition. One of either:\r
-// #define Cs870MemoryTestPEIMGuidL 0x9C2403386E1C8FAA\r
-// #define Cs870MemoryTestPEIMGuidH 0xE89E95C6180342f0\r
-// Return the defined value as two 32-bit values, and whether it's a high\r
-// or low guid.\r
-//\r
-static\r
-BOOLEAN\r
-IsIA64GuidLine (\r
-  INT8      *Line,\r
-  UINT32    *GuidHigh,\r
-  UINT32    *GuidLow,\r
-  BOOLEAN   *FoundLow,\r
-  INT8      *SymName\r
-  )\r
-{\r
-  INT8    *Cptr;\r
-  INT8    CSave;\r
-  INT8    *CSavePtr;\r
-  INT8    *SymStart;\r
-  UINT32  Len;\r
-\r
-  Cptr = Line;\r
-  Cptr += SkipWhiteSpace (Cptr);\r
-  //\r
-  // look for #define xxxGUID[L|H] 0xHexValue\r
-  //\r
-  if (*Cptr == '#') {\r
-    Cptr++;\r
-    Cptr += SkipWhiteSpace (Cptr);\r
-    //\r
-    // Look for "define"\r
-    //\r
-    if (!strncmp (Cptr, "define", 6)) {\r
-      Cptr += 6;\r
-      //\r
-      // Better be whitespace\r
-      //\r
-      Len = SkipWhiteSpace (Cptr);\r
-      if (Len) {\r
-        Cptr += Len;\r
-        //\r
-        // See if it's a valid symbol name\r
-        //\r
-        Len = ValidSymbolName (Cptr);\r
-        if (Len) {\r
-          //\r
-          // Save the start so we can copy it to their string if later checks are ok\r
-          //\r
-          SymStart = Cptr;\r
-          //\r
-          // It is a valid symbol name, look for the string GuidL or GuidH\r
-          //\r
-          CSavePtr  = Cptr + Len;\r
-          CSave     = *CSavePtr;\r
-          *CSavePtr = 0;\r
-          while (*Cptr) {\r
-            if (strncmp (Cptr, "GuidL", 5) == 0) {\r
-              *FoundLow = 1;\r
-              break;\r
-            } else if (strncmp (Cptr, "GuidH", 5) == 0) {\r
-              *FoundLow = 0;\r
-              break;\r
-            }\r
-\r
-            Cptr++;\r
-          }\r
-          //\r
-          // If we didn't run out of string, then we found the GUID string.\r
-          // Restore the null character we inserted above and continue.\r
-          // Now look for  0x.......\r
-          //\r
-          if (*Cptr) {\r
-            //\r
-            // Return symbol name less the "L" or "H"\r
-            //\r
-            strcpy (SymName, SymStart);\r
-            SymName[strlen (SymName) - 1] = 0;\r
-            Cptr                          = CSavePtr;\r
-            *CSavePtr                     = CSave;\r
-            Cptr += SkipWhiteSpace (Cptr);\r
-            if ((*Cptr == '0') && (*(Cptr + 1) == 'x')) {\r
-              //\r
-              // skip over "0x"\r
-              //\r
-              Cptr += 2;\r
-              //\r
-              // 0x0123456789ABCDEF -- null terminate after 8 characters,\r
-              // scan, replace the character and scan at that point.\r
-              //\r
-              CSave       = *(Cptr + 8);\r
-              *(Cptr + 8) = 0;\r
-              if (sscanf (Cptr, "%X", GuidHigh) == 1) {\r
-                *(Cptr + 8) = CSave;\r
-                if (sscanf (Cptr + 8, "%X", GuidLow) == 1) {\r
-                  return TRUE;\r
-                }\r
-              }\r
-            }\r
-          }\r
-        }\r
-      }\r
-    }\r
-  }\r
-\r
-  return FALSE;\r
-}\r
-//\r
-// Look at the characters in the string and determine if it's a valid\r
-// symbol name. Basically [a-zA-Z_][a-zA-Z_0-9]*\r
-//\r
-static\r
-UINT32\r
-ValidSymbolName (\r
-  INT8    *Name\r
-  )\r
-{\r
-  int Len;\r
-\r
-  Len = 0;\r
-\r
-  //\r
-  // Test first character\r
-  //\r
-  if (((*Name >= 'a') && (*Name <= 'z')) || ((*Name >= 'A') && (*Name <= 'Z')) || (*Name == '_')) {\r
-    Name++;\r
-    Len = 1;\r
-    while (*Name) {\r
-      if (((*Name >= 'a') && (*Name <= 'z')) ||\r
-          ((*Name >= 'A') && (*Name <= 'Z')) ||\r
-          ((*Name >= '0') && (*Name <= '9')) ||\r
-          (*Name == '_')\r
-          ) {\r
-        Name++;\r
-        Len++;\r
-      } else {\r
-        break;\r
-      }\r
-    }\r
-  }\r
-\r
-  return Len;\r
-}\r
-\r
-static\r
-UINT32\r
-SkipWhiteSpace (\r
-  INT8    *Str\r
-  )\r
-{\r
-  UINT32  Len;\r
-  Len = 0;\r
-  while (isspace (*Str) && *Str) {\r
-    Len++;\r
-    Str++;\r
-  }\r
-\r
-  return Len;\r
-}\r
-//\r
-// found FFS_FILEGUID=35b898ca-b6a9-49ce-8c72-904735cc49b7\r
-//\r
-static\r
-STATUS\r
-AddPkgGuid (\r
-  INT8      *FileName,\r
-  UINT32    *Data,\r
-  UINT64    *Data64\r
-  )\r
-{\r
-  GUID_RECORD *NewRec;\r
-  int         Index;\r
-\r
-  //\r
-  // Sanity check the data\r
-  //\r
-  if ((Data[1] | Data[2] | Data[3]) & 0xFFFF0000) {\r
-    Error (NULL, 0, 0, "out of range value for GUID data word(s) [1] - [3]", NULL);\r
-    return STATUS_ERROR;\r
-  }\r
-  //\r
-  // More checks for Data64?\r
-  // Allocate memory for a new one guid structure\r
-  //\r
-  NewRec = malloc (sizeof (GUID_RECORD));\r
-  if (NewRec == NULL) {\r
-    Error (NULL, 0, 0, "memory allocation failure", NULL);\r
-    return STATUS_ERROR;\r
-  }\r
-\r
-  memset ((char *) NewRec, 0, sizeof (GUID_RECORD));\r
-  NewRec->FileName = malloc (strlen (FileName) + 1);\r
-  if (NewRec->FileName == NULL) {\r
-    free (NewRec);\r
-    Error (NULL, 0, 0, "memory allocation failure", NULL);\r
-    return STATUS_ERROR;\r
-  }\r
-\r
-  strcpy (NewRec->FileName, FileName);\r
-  NewRec->Guid.Data1    = Data[0];\r
-  NewRec->Guid.Data2    = (UINT16) Data[1];\r
-  NewRec->Guid.Data3    = (UINT16) Data[2];\r
-  NewRec->Guid.Data4[0] = (UINT8) Data[3];\r
-  NewRec->Guid.Data4[1] = (UINT8) (Data[3] >> 8);\r
-  for (Index = 2; Index < 8; Index++) {\r
-    NewRec->Guid.Data4[Index] = (UINT8) *Data64;\r
-    *Data64 >>= 8;\r
-  }\r
-  //\r
-  // Add it to the list\r
-  //\r
-  NewRec->Next  = gGuidList;\r
-  gGuidList     = NewRec;\r
-\r
-  //\r
-  // Report it\r
-  // ReportGuid (FileName, NewRec);\r
-  //\r
-  return STATUS_SUCCESS;\r
-}\r
-//\r
-// Add a guid consisting of 11 fields to our list of guids\r
-//\r
-static\r
-STATUS\r
-AddGuid11 (\r
-  INT8      *FileName,\r
-  UINT32    *Data,\r
-  INT8      *SymName\r
-  )\r
-{\r
-  GUID_RECORD *NewRec;\r
-  int         Index;\r
-\r
-  //\r
-  // Sanity check the data\r
-  //\r
-  if (!CheckGuidData (Data, 11)) {\r
-    return STATUS_ERROR;\r
-  }\r
-  //\r
-  // Allocate memory for a new one guid structure\r
-  //\r
-  NewRec = malloc (sizeof (GUID_RECORD));\r
-  if (NewRec == NULL) {\r
-    Error (NULL, 0, 0, "memory allocation failure", NULL);\r
-    return STATUS_ERROR;\r
-  }\r
-\r
-  memset ((char *) NewRec, 0, sizeof (GUID_RECORD));\r
-  NewRec->FileName = malloc (strlen (FileName) + 1);\r
-  if (NewRec->FileName == NULL) {\r
-    free (NewRec);\r
-    Error (NULL, 0, 0, "memory allocation failure", NULL);\r
-    return STATUS_ERROR;\r
-  }\r
-\r
-  strcpy (NewRec->FileName, FileName);\r
-  if (SymName != NULL) {\r
-    NewRec->SymName = malloc (strlen (SymName) + 1);\r
-    if (NewRec->SymName == NULL) {\r
-      free (NewRec);\r
-      Error (NULL, 0, 0, "memory allocation failure", NULL);\r
-      return STATUS_ERROR;\r
-    }\r
-  }\r
-\r
-  strcpy (NewRec->SymName, SymName);\r
-\r
-  NewRec->Guid.Data1  = Data[0];\r
-  NewRec->Guid.Data2  = (UINT16) Data[1];\r
-  NewRec->Guid.Data3  = (UINT16) Data[2];\r
-  for (Index = 0; Index < 8; Index++) {\r
-    NewRec->Guid.Data4[Index] = (UINT8) Data[3 + Index];\r
-  }\r
-  //\r
-  // Add it to the list\r
-  //\r
-  NewRec->Next  = gGuidList;\r
-  gGuidList     = NewRec;\r
-\r
-  //\r
-  // Report it\r
-  // ReportGuid (FileName, NewRec);\r
-  //\r
-  return STATUS_SUCCESS;\r
-}\r
-//\r
-// For debug purposes, print each guid found\r
-//\r
-// static\r
-// VOID\r
-// ReportGuid (\r
-//  INT8        *FileName,\r
-// GUID_RECORD *NewGuid\r
-//  )\r
-// {\r
-//  //fprintf (stdout, "%s: 0x%08X\n", FileName, NewGuid->Guid.Data1);\r
-// }\r
-//\r
-// Free up memory we allocated to keep track of guids defined.\r
-//\r
-static\r
-VOID\r
-FreeGuids (\r
-  VOID\r
-  )\r
-{\r
-  GUID_RECORD *NextRec;\r
-  while (gGuidList != NULL) {\r
-    NextRec = gGuidList->Next;\r
-    if (gGuidList->FileName != NULL) {\r
-      free (gGuidList->FileName);\r
-    }\r
-\r
-    if (gGuidList->SymName != NULL) {\r
-      free (gGuidList->SymName);\r
-    }\r
-\r
-    free (gGuidList);\r
-    gGuidList = NextRec;\r
-  }\r
-}\r
-\r
-static\r
-VOID\r
-FreeSigs (\r
-  VOID\r
-  )\r
-{\r
-  SIGNATURE_RECORD  *NextRec;\r
-  while (gSignatureList != NULL) {\r
-    NextRec = gSignatureList->Next;\r
-    if (gSignatureList->FileName != NULL) {\r
-      free (gSignatureList->FileName);\r
-    }\r
-\r
-    free (gSignatureList);\r
-    gSignatureList = NextRec;\r
-  }\r
-}\r
-//\r
-// Scan through all guids defined and compare each for duplicates.\r
-//\r
-static\r
-STATUS\r
-CheckDuplicates (\r
-  VOID\r
-  )\r
-{\r
-  GUID_RECORD       *CurrentFile;\r
-\r
-  GUID_RECORD       *TempFile;\r
-  SIGNATURE_RECORD  *CurrentSig;\r
-  SIGNATURE_RECORD  *TempSig;\r
-  STATUS            Status;\r
-  int               Index;\r
-  int               DupCount;\r
-  int               Len;\r
-  BOOLEAN           Same;\r
-  UINT32            GuidSum;\r
-  INT8              *SymName;\r
-\r
-  Status = STATUS_SUCCESS;\r
-\r
-  //\r
-  // If we're checking guids.....\r
-  //\r
-  if (gOptions.CheckGuids) {\r
-    //\r
-    // If -p option, print all guids found\r
-    //\r
-    if (gOptions.PrintFound) {\r
-      CurrentFile = gGuidList;\r
-      while (CurrentFile != NULL) {\r
-        fprintf (\r
-          stdout,\r
-          "GUID:  0x%08X 0x%04X 0x%04X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X %s\n",\r
-          (UINT32) CurrentFile->Guid.Data1,\r
-          (UINT32) CurrentFile->Guid.Data2,\r
-          (UINT32) CurrentFile->Guid.Data3,\r
-          (UINT32) CurrentFile->Guid.Data4[0],\r
-          (UINT32) CurrentFile->Guid.Data4[1],\r
-          (UINT32) CurrentFile->Guid.Data4[2],\r
-          (UINT32) CurrentFile->Guid.Data4[3],\r
-          (UINT32) CurrentFile->Guid.Data4[4],\r
-          (UINT32) CurrentFile->Guid.Data4[5],\r
-          (UINT32) CurrentFile->Guid.Data4[6],\r
-          (UINT32) CurrentFile->Guid.Data4[7],\r
-          CurrentFile->FileName\r
-          );\r
-        CurrentFile = CurrentFile->Next;\r
-      }\r
-    }\r
-\r
-    if (gOptions.GuidXReference) {\r
-      CurrentFile = gGuidList;\r
-      while (CurrentFile != NULL) {\r
-        //\r
-        // If no symbol name, print "unknown"\r
-        //\r
-        SymName = CurrentFile->SymName;\r
-        if (SymName == NULL) {\r
-          SymName = "unknown";\r
-        }\r
-\r
-        fprintf (\r
-          stdout,\r
-          "%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X %s\n",\r
-          (UINT32) CurrentFile->Guid.Data1,\r
-          (UINT32) CurrentFile->Guid.Data2,\r
-          (UINT32) CurrentFile->Guid.Data3,\r
-          (UINT32) CurrentFile->Guid.Data4[0],\r
-          (UINT32) CurrentFile->Guid.Data4[1],\r
-          (UINT32) CurrentFile->Guid.Data4[2],\r
-          (UINT32) CurrentFile->Guid.Data4[3],\r
-          (UINT32) CurrentFile->Guid.Data4[4],\r
-          (UINT32) CurrentFile->Guid.Data4[5],\r
-          (UINT32) CurrentFile->Guid.Data4[6],\r
-          (UINT32) CurrentFile->Guid.Data4[7],\r
-          SymName\r
-          );\r
-        CurrentFile = CurrentFile->Next;\r
-      }\r
-    }\r
-    //\r
-    // Now go through all guids and report duplicates.\r
-    //\r
-    CurrentFile = gGuidList;\r
-    while (CurrentFile != NULL) {\r
-      DupCount  = 0;\r
-      TempFile  = CurrentFile->Next;\r
-      while (TempFile) {\r
-        //\r
-        // Compare the guids\r
-        //\r
-        if ((CurrentFile->Guid.Data1 == TempFile->Guid.Data1) &&\r
-            (CurrentFile->Guid.Data2 == TempFile->Guid.Data2) &&\r
-            (CurrentFile->Guid.Data3 == TempFile->Guid.Data3)\r
-            ) {\r
-          //\r
-          // OR in all the guid bytes so we can ignore NULL-guid definitions.\r
-          //\r
-          GuidSum = CurrentFile->Guid.Data1 | CurrentFile->Guid.Data2 | CurrentFile->Guid.Data3;\r
-          Same    = TRUE;\r
-          for (Index = 0; Index < 8; Index++) {\r
-            GuidSum |= CurrentFile->Guid.Data4[Index];\r
-            if (CurrentFile->Guid.Data4[Index] != TempFile->Guid.Data4[Index]) {\r
-              Same = FALSE;\r
-              break;\r
-            }\r
-          }\r
-          //\r
-          // If they're the same, and the guid was non-zero, print a message.\r
-          //\r
-          if (Same && GuidSum) {\r
-            if (DupCount == 0) {\r
-              Error (NULL, 0, 0, "duplicate GUIDS found", NULL);\r
-              fprintf (stdout, "   FILE1: %s\n", CurrentFile->FileName);\r
-            }\r
-\r
-            DupCount++;\r
-            fprintf (stdout, "   FILE%d: %s\n", DupCount + 1, TempFile->FileName);\r
-            //\r
-            // Flag it as reported so we don't report it again if there's three or more\r
-            //\r
-            TempFile->Reported = TRUE;\r
-          }\r
-        }\r
-        //\r
-        // Next one\r
-        //\r
-        TempFile = TempFile->Next;\r
-      }\r
-      //\r
-      // Print the guid if we found duplicates\r
-      //\r
-      if (DupCount) {\r
-        fprintf (\r
-          stdout,\r
-          "   GUID:  0x%08X 0x%04X 0x%04X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X\n",\r
-          (UINT32) CurrentFile->Guid.Data1,\r
-          (UINT32) CurrentFile->Guid.Data2,\r
-          (UINT32) CurrentFile->Guid.Data3,\r
-          (UINT32) CurrentFile->Guid.Data4[0],\r
-          (UINT32) CurrentFile->Guid.Data4[1],\r
-          (UINT32) CurrentFile->Guid.Data4[2],\r
-          (UINT32) CurrentFile->Guid.Data4[3],\r
-          (UINT32) CurrentFile->Guid.Data4[4],\r
-          (UINT32) CurrentFile->Guid.Data4[5],\r
-          (UINT32) CurrentFile->Guid.Data4[6],\r
-          (UINT32) CurrentFile->Guid.Data4[7]\r
-          );\r
-        //\r
-        // return STATUS_ERROR;\r
-        //\r
-      }\r
-      //\r
-      // Find the next one that hasn't been reported\r
-      //\r
-      do {\r
-        CurrentFile = CurrentFile->Next;\r
-      } while ((CurrentFile != NULL) && (CurrentFile->Reported));\r
-    }\r
-  }\r
-\r
-  if (gOptions.CheckSignatures) {\r
-    //\r
-    // Print ones found if specified\r
-    //\r
-    if (gOptions.PrintFound) {\r
-      CurrentSig = gSignatureList;\r
-      while (CurrentSig != NULL) {\r
-        Len = CurrentSig->Signature.DataLen;\r
-        for (Index = 0; Index < Len; Index++) {\r
-          fprintf (stdout, "%c", CurrentSig->Signature.Data[Index]);\r
-        }\r
-\r
-        fprintf (stdout, "  %s\n", CurrentSig->FileName);\r
-        CurrentSig = CurrentSig->Next;\r
-      }\r
-    }\r
-\r
-    CurrentSig = gSignatureList;\r
-    while (CurrentSig != NULL) {\r
-      DupCount  = 0;\r
-      TempSig   = CurrentSig->Next;\r
-      Len       = CurrentSig->Signature.DataLen;\r
-      while (TempSig) {\r
-        //\r
-        // Check for same length, then do string compare\r
-        //\r
-        if (Len == TempSig->Signature.DataLen) {\r
-          if (strncmp (CurrentSig->Signature.Data, TempSig->Signature.Data, Len) == 0) {\r
-            //\r
-            // Print header message if first failure for this sig\r
-            //\r
-            if (DupCount == 0) {\r
-              Error (NULL, 0, 0, "duplicate signatures found", NULL);\r
-              fprintf (stdout, "   FILE1: %s\n", CurrentSig->FileName);\r
-            }\r
-\r
-            DupCount++;\r
-            fprintf (stdout, "   FILE%d: %s\n", DupCount + 1, TempSig->FileName);\r
-            TempSig->Reported = TRUE;\r
-          }\r
-        }\r
-\r
-        TempSig = TempSig->Next;\r
-      }\r
-\r
-      if (DupCount) {\r
-        fprintf (stdout, "   SIG:   ");\r
-        for (Index = 0; Index < Len; Index++) {\r
-          fprintf (stdout, "%c", CurrentSig->Signature.Data[Index]);\r
-        }\r
-\r
-        fprintf (stdout, "\n");\r
-      }\r
-      //\r
-      // On to the next one that hasn't been reported\r
-      //\r
-      do {\r
-        CurrentSig = CurrentSig->Next;\r
-      } while ((CurrentSig != NULL) && (CurrentSig->Reported));\r
-    }\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-static\r
-VOID\r
-FreeOptions (\r
-  VOID\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Free up any memory we allocated when processing command-line options.\r
-\r
-Arguments:\r
-  None.\r
-\r
-Returns:\r
-  NA\r
-\r
-Notes:\r
-  We don't free up the ->Str fields because we did not allocate them.\r
-  Instead, we just set the pointer to point to the actual parameter\r
-  from the command line.\r
-\r
---*/\r
-{\r
-  STRING_LIST *Ptr;\r
-  while (gOptions.ExcludeDirs != NULL) {\r
-    Ptr = gOptions.ExcludeDirs->Next;\r
-    //\r
-    // free (gOptions.ExcludeDirs->Str);\r
-    //\r
-    free (gOptions.ExcludeDirs);\r
-    gOptions.ExcludeDirs = Ptr;\r
-  }\r
-\r
-  while (gOptions.ExcludeSubDirs != NULL) {\r
-    Ptr = gOptions.ExcludeSubDirs->Next;\r
-    //\r
-    // free (gOptions.ExcludeSubDirs->Str);\r
-    //\r
-    free (gOptions.ExcludeSubDirs);\r
-    gOptions.ExcludeSubDirs = Ptr;\r
-  }\r
-\r
-  while (gOptions.ExcludeExtensions != NULL) {\r
-    Ptr = gOptions.ExcludeExtensions->Next;\r
-    //\r
-    // free (gOptions.ExcludeExtensions->Str);\r
-    //\r
-    free (gOptions.ExcludeExtensions);\r
-    gOptions.ExcludeExtensions = Ptr;\r
-  }\r
-\r
-  while (gOptions.ExcludeFiles != NULL) {\r
-    Ptr = gOptions.ExcludeFiles->Next;\r
-    //\r
-    // free (gOptions.ExcludeFiles->Str);\r
-    //\r
-    free (gOptions.ExcludeFiles);\r
-    gOptions.ExcludeFiles = Ptr;\r
-  }\r
-}\r
-//\r
-// Given an array of 32-bit data, validate the data for the given number of\r
-// guid data. For example, it might have been scanned as 16 bytes of data, or\r
-// 11 fields of data.\r
-//\r
-static\r
-BOOLEAN\r
-CheckGuidData (\r
-  UINT32    *Data,\r
-  UINT32    DataCount\r
-  )\r
-{\r
-  UINT32  Index;\r
-\r
-  if (DataCount == 16) {\r
-    for (Index = 0; Index < 16; Index++) {\r
-      if (Data[Index] &~0xFF) {\r
-        return FALSE;\r
-      }\r
-    }\r
-\r
-    return TRUE;\r
-  } else if (DataCount == 11) {\r
-    //\r
-    // Data[0] never out of range (32-bit)\r
-    //\r
-    if ((Data[1] | Data[2]) &~0xFFFF) {\r
-      //\r
-      // Error ("Out of range value for GUID data word(s) [1] and/or [2]");\r
-      //\r
-      return FALSE;\r
-    }\r
-\r
-    for (Index = 0; Index < 8; Index++) {\r
-      if (Data[Index + 3] &~0xFF) {\r
-        //\r
-        // Error ("Out of range value for GUID data byte(s) [4] - [11]");\r
-        //\r
-        return FALSE;\r
-      }\r
-    }\r
-\r
-    return TRUE;\r
-  }\r
-\r
-  return FALSE;\r
-}\r
diff --git a/Tools/CodeTools/TianoTools/GuidChk/GuidList.c b/Tools/CodeTools/TianoTools/GuidChk/GuidList.c
deleted file mode 100644 (file)
index bb6a44d..0000000
+++ /dev/null
@@ -1,186 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2004, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-Module Name:\r
-\r
-  GuidList.c  \r
-\r
-Abstract:\r
-\r
-  Utility to create a GUID-to-name listing file that can\r
-  be used by other utilities. Basic operation is to take the\r
-  table of name+GUIDs that we have compiled into this utility,\r
-  and create a text file that can be parsed by other utilities\r
-  to do replacement of "name" with "GUID".\r
-\r
-Notes:\r
-  To add a new GUID to this database:\r
-    1. Add a "#include EFI_GUID_DEFINITION(name)" statement below\r
-    2. Modify the mGuidList[] array below to add the new GUID name\r
-\r
-  The only issue that may come up is that, if the source GUID file\r
-  is not in the standard GUID directory, then this utility won't\r
-  compile because the #include fails. In this case you'd need\r
-  to define a new macro (if it's in a standard place) or modify\r
-  this utility's makefile to add the path to your new .h file.\r
-\r
---*/\r
-\r
-#include <stdio.h>\r
-#include <string.h>\r
-#include <stdlib.h>\r
-#include <ctype.h>\r
-\r
-#include <Common/UefiBaseTypes.h>\r
-#include <Guid/Apriori.h>\r
-#include <Guid/AcpiTableStorage.h>\r
-\r
-#include "EfiUtilityMsgs.h"\r
-\r
-\r
-#define GUID_XREF(varname, guid) { \\r
-    #varname, #guid, guid \\r
-  }\r
-\r
-#define NULL_GUID \\r
-  { \\r
-    0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 \\r
-  }\r
-\r
-typedef struct {\r
-  INT8      *VariableName;\r
-  INT8      *DefineName;\r
-  EFI_GUID  Guid;\r
-} GUID_LIST;\r
-\r
-//\r
-// This is our table of all GUIDs we want to print out to create\r
-// a GUID-to-name cross reference.\r
-// Use the #defined name from the GUID definition's source .h file.\r
-//\r
-static GUID_LIST  mGuidList[] = {\r
-  GUID_XREF(gAprioriGuid, EFI_APRIORI_GUID),\r
-  GUID_XREF(gEfiAcpiTableStorageGuid, EFI_ACPI_TABLE_STORAGE_GUID),\r
-  // FIXME The next line was removed in the port to R9.\r
-  // GUID_XREF(gEfiDefaultBmpLogoGuid, EFI_DEFAULT_BMP_LOGO_GUID),\r
-  GUID_XREF(gEfiAcpiTableStorageGuid, EFI_ACPI_TABLE_STORAGE_GUID),\r
-  //\r
-  // Terminator\r
-  //\r
-  {\r
-    NULL,\r
-    NULL,\r
-    NULL_GUID\r
-  }\r
-};\r
-\r
-void\r
-PrintGuidText (\r
-  FILE      *OutFptr,\r
-  INT8      *VariableName,\r
-  INT8      *DefineName,\r
-  EFI_GUID  *Guid\r
-  );\r
-\r
-int\r
-CreateGuidList (\r
-  INT8    *OutFileName\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Print our GUID/name list to the specified output file.\r
-  \r
-Arguments:\r
-  OutFileName  - name of the output file to write our results to.\r
-\r
-Returns:\r
-  0       if successful\r
-  nonzero otherwise\r
-  \r
---*/\r
-{\r
-  FILE  *OutFptr;\r
-  int   Index;\r
-\r
-  //\r
-  // Open output file for writing. If the name is NULL, then write to stdout\r
-  //\r
-  if (OutFileName != NULL) {\r
-    OutFptr = fopen (OutFileName, "w");\r
-    if (OutFptr == NULL) {\r
-      Error (NULL, 0, 0, OutFileName, "failed to open output file for writing");\r
-      return STATUS_ERROR;\r
-    }\r
-  } else {\r
-    OutFptr = stdout;\r
-  }\r
-\r
-  for (Index = 0; mGuidList[Index].VariableName != NULL; Index++) {\r
-    PrintGuidText (OutFptr, mGuidList[Index].VariableName, mGuidList[Index].DefineName, &mGuidList[Index].Guid);\r
-  }\r
-  //\r
-  // Close the output file if they specified one.\r
-  //\r
-  if (OutFileName != NULL) {\r
-    fclose (OutFptr);\r
-  }\r
-\r
-  return STATUS_SUCCESS;\r
-}\r
-\r
-void\r
-PrintGuidText (\r
-  FILE      *OutFptr,\r
-  INT8      *VariableName,\r
-  INT8      *DefineName,\r
-  EFI_GUID  *Guid\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Print a GUID/name combo in INF-style format\r
-\r
-  guid-guid-guid-guid DEFINE_NAME gName\r
-\r
-Arguments:\r
-  OutFptr       - file pointer to which to write the output\r
-  VariableName  - the GUID variable's name\r
-  DefineName    - the name used in the #define\r
-  Guid          - pointer to the GUID value\r
-\r
-Returns:\r
-  NA\r
-\r
---*/\r
-{\r
-  if (OutFptr == NULL) {\r
-    OutFptr = stdout;\r
-  }\r
-\r
-  fprintf (\r
-    OutFptr,\r
-    "%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X %s %s\n",\r
-    Guid->Data1,\r
-    Guid->Data2,\r
-    Guid->Data3,\r
-    Guid->Data4[0],\r
-    Guid->Data4[1],\r
-    Guid->Data4[2],\r
-    Guid->Data4[3],\r
-    Guid->Data4[4],\r
-    Guid->Data4[5],\r
-    Guid->Data4[6],\r
-    Guid->Data4[7],\r
-    DefineName,\r
-    VariableName\r
-    );\r
-}\r
diff --git a/Tools/CodeTools/TianoTools/GuidChk/UtilsMsgs.c b/Tools/CodeTools/TianoTools/GuidChk/UtilsMsgs.c
deleted file mode 100644 (file)
index 8aa343f..0000000
+++ /dev/null
@@ -1,490 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2004, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-Module Name:  \r
-\r
-  UtilsMsgs.c\r
-  \r
-Abstract:\r
-\r
-  EFI tools utility functions to display warning, error, and informational\r
-  messages.\r
-  \r
---*/\r
-\r
-#include <stdio.h>\r
-#include <string.h>\r
-#include <ctype.h>\r
-#include <stdarg.h>\r
-\r
-#include <Common/UefiBaseTypes.h>\r
-\r
-#include "EfiUtilityMsgs.h"\r
-\r
-#define MAX_LINE_LEN  200\r
-\r
-//\r
-// Declare module globals for keeping track of the the utility's\r
-// name and other settings.\r
-//\r
-static STATUS mStatus             = STATUS_SUCCESS;\r
-static INT8   mUtilityName[50]    = { 0 };\r
-static INT8   *mSourceFileName    = NULL;\r
-static UINT32 mSourceFileLineNum  = 0;\r
-static UINT32 mErrorCount         = 0;\r
-static UINT32 mWarningCount       = 0;\r
-static UINT32 mDebugMsgMask       = 0;\r
-\r
-static\r
-void\r
-PrintMessage (\r
-  INT8    *Type,\r
-  INT8    *FileName,\r
-  UINT32  LineNumber,\r
-  UINT32  MessageCode,\r
-  INT8    *Text,\r
-  INT8    *MsgFmt,\r
-  va_list List\r
-  );\r
-\r
-void\r
-Error (\r
-  INT8    *FileName,\r
-  UINT32  LineNumber,\r
-  UINT32  MessageCode,\r
-  INT8    *Text,\r
-  INT8    *MsgFmt,\r
-  ...\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Prints an error message.\r
-  \r
-Arguments:\r
-  All arguments are optional, though the printed message may be useless if\r
-  at least something valid is not specified.\r
-  \r
-  FileName - name of the file or application. If not specified, then the\r
-             utilty name (as set by the utility calling SetUtilityName()\r
-             earlier) is used. Otherwise "Unknown utility" is used.\r
-  \r
-  LineNumber - the line number of error, typically used by parsers. If the\r
-               utility is not a parser, then 0 should be specified. Otherwise\r
-               the FileName and LineNumber info can be used to cause\r
-               MS Visual Studio to jump to the error.\r
-               \r
-  MessageCode - an application-specific error code that can be referenced in\r
-              other documentation. \r
-\r
-  Text        - the text in question, typically used by parsers.\r
-  \r
-  MsgFmt - the format string for the error message. Can contain formatting\r
-           controls for use with the varargs.\r
-           \r
-Returns:\r
-  None.\r
-  \r
-Notes:\r
-  We print the following (similar to the Warn() and Debug() \r
-  W\r
-  Typical error/warning message format:\r
-\r
-  bin\VfrCompile.cpp(330) : error C2660: 'AddVfrDataStructField' : function does not take 2 parameters\r
-\r
-  BUGBUG -- these three utility functions are almost identical, and\r
-  should be modified to share code.\r
-\r
-  Visual Studio does not find error messages with:\r
-  \r
-     " error :"\r
-     " error 1:"\r
-     " error c1:"\r
-     " error 1000:"\r
-     " error c100:"\r
-\r
-  It does find:\r
-     " error c1000:"     \r
---*/\r
-{\r
-  va_list List;\r
-  mErrorCount++;\r
-  va_start (List, MsgFmt);\r
-  PrintMessage ("error", FileName, LineNumber, MessageCode, Text, MsgFmt, List);\r
-  va_end (List);\r
-  //\r
-  // Set status accordingly\r
-  //\r
-  if (mStatus < STATUS_ERROR) {\r
-    mStatus = STATUS_ERROR;\r
-  }\r
-}\r
-\r
-void\r
-ParserError (\r
-  UINT32  MessageCode,\r
-  INT8    *Text,\r
-  INT8    *MsgFmt,\r
-  ...\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Print a parser error, using the source file name and line number\r
-  set by a previous call to SetParserPosition().\r
-\r
-Arguments:\r
-  MessageCode   - application-specific error code\r
-  Text          - text to print in the error message\r
-  MsgFmt        - format string to print at the end of the error message\r
-  ...\r
-\r
-Returns:\r
-  NA\r
-\r
---*/\r
-{\r
-  va_list List;\r
-  mErrorCount++;\r
-  va_start (List, MsgFmt);\r
-  PrintMessage ("error", mSourceFileName, mSourceFileLineNum, MessageCode, Text, MsgFmt, List);\r
-  va_end (List);\r
-  //\r
-  // Set status accordingly\r
-  //\r
-  if (mStatus < STATUS_ERROR) {\r
-    mStatus = STATUS_ERROR;\r
-  }\r
-}\r
-\r
-void\r
-ParserWarning (\r
-  UINT32  ErrorCode,\r
-  INT8    *OffendingText,\r
-  INT8    *MsgFmt,\r
-  ...\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Print a parser warning, using the source file name and line number\r
-  set by a previous call to SetParserPosition().\r
-\r
-Arguments:\r
-  ErrorCode     - application-specific error code\r
-  OffendingText - text to print in the warning message\r
-  MsgFmt        - format string to print at the end of the warning message\r
-  ...\r
-\r
-Returns:\r
-  NA\r
-\r
---*/\r
-{\r
-  va_list List;\r
-  mWarningCount++;\r
-  va_start (List, MsgFmt);\r
-  PrintMessage ("warning", mSourceFileName, mSourceFileLineNum, ErrorCode, OffendingText, MsgFmt, List);\r
-  va_end (List);\r
-  //\r
-  // Set status accordingly\r
-  //\r
-  if (mStatus < STATUS_WARNING) {\r
-    mStatus = STATUS_WARNING;\r
-  }\r
-}\r
-\r
-void\r
-Warning (\r
-  INT8    *FileName,\r
-  UINT32  LineNumber,\r
-  UINT32  MessageCode,\r
-  INT8    *Text,\r
-  INT8    *MsgFmt,\r
-  ...\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Print a warning message.\r
-\r
-Arguments:\r
-  FileName    - name of the file where the warning was detected, or the name\r
-                of the application that detected the warning\r
-  \r
-  LineNumber  - the line number where the warning was detected (parsers).\r
-                0 should be specified if the utility is not a parser.\r
-               \r
-  MessageCode - an application-specific warning code that can be referenced in\r
-                other documentation. \r
-\r
-  Text        - the text in question (parsers)\r
-  \r
-  MsgFmt      - the format string for the warning message. Can contain formatting\r
-                controls for use with varargs.\r
-                \r
-  ...\r
-           \r
-Returns:\r
-  None.\r
-\r
---*/\r
-{\r
-  va_list List;\r
-  mWarningCount++;\r
-  va_start (List, MsgFmt);\r
-  PrintMessage ("warning", FileName, LineNumber, MessageCode, Text, MsgFmt, List);\r
-  va_end (List);\r
-  //\r
-  // Set status accordingly\r
-  //\r
-  if (mStatus < STATUS_WARNING) {\r
-    mStatus = STATUS_WARNING;\r
-  }\r
-}\r
-\r
-void\r
-DebugMsg (\r
-  INT8    *FileName,\r
-  UINT32  LineNumber,\r
-  UINT32  MsgMask,\r
-  INT8    *Text,\r
-  INT8    *MsgFmt,\r
-  ...\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Print a warning message.\r
-\r
-Arguments:\r
-  FileName    - typically the name of the utility printing the debug message, but\r
-                can be the name of a file being parsed.\r
-  \r
-  LineNumber  - the line number in FileName (parsers) \r
-               \r
-  MsgMask     - an application-specific bitmask that, in combination with mDebugMsgMask,\r
-                determines if the debug message gets printed.\r
-\r
-  Text        - the text in question (parsers)\r
-  \r
-  MsgFmt      - the format string for the debug message. Can contain formatting\r
-                controls for use with varargs.\r
-          \r
-  ... \r
-Returns:\r
-  None.\r
-\r
---*/\r
-{\r
-  va_list List;\r
-  //\r
-  // If the debug mask is not applicable, then do nothing.\r
-  //\r
-  if ((MsgMask != 0) && ((mDebugMsgMask & MsgMask) == 0)) {\r
-    return ;\r
-  }\r
-\r
-  va_start (List, MsgFmt);\r
-  PrintMessage ("debug", FileName, LineNumber, 0, Text, MsgFmt, List);\r
-  va_end (List);\r
-}\r
-\r
-static\r
-void\r
-PrintMessage (\r
-  INT8    *Type,\r
-  INT8    *FileName,\r
-  UINT32  LineNumber,\r
-  UINT32  MessageCode,\r
-  INT8    *Text,\r
-  INT8    *MsgFmt,\r
-  va_list List\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Worker routine for all the utility printing services. Prints the message in\r
-  a format that Visual Studio will find when scanning build outputs for\r
-  errors or warnings.\r
-\r
-Arguments:\r
-  Type        - "warning" or "error" string to insert into the message to be\r
-                printed. The first character of this string (converted to uppercase)\r
-                is used to preceed the MessageCode value in the output string.\r
-\r
-  FileName    - name of the file where the warning was detected, or the name\r
-                of the application that detected the warning\r
-  \r
-  LineNumber  - the line number where the warning was detected (parsers).\r
-                0 should be specified if the utility is not a parser.\r
-               \r
-  MessageCode - an application-specific warning code that can be referenced in\r
-                other documentation. \r
-\r
-  Text        - part of the message to print\r
-  \r
-  MsgFmt      - the format string for the message. Can contain formatting\r
-                controls for use with varargs.\r
-\r
-  List        - Variable function parameter list.           \r
-Returns:\r
-  None.\r
-\r
-Notes:\r
-  If FileName == NULL then this utility will use the string passed into SetUtilityName(). \r
-  \r
-  LineNumber is only used if the caller is a parser, in which case FileName refers to the\r
-  file being parsed.\r
-\r
-  Text and MsgFmt are both optional, though it would be of little use calling this function with\r
-  them both NULL.\r
-\r
-  Output will typically be of the form:\r
-    <FileName>(<LineNumber>) : <Type> <Type[0]><MessageCode>: <Text> : <MsgFmt>\r
-\r
-    Parser (LineNumber != 0)\r
-      VfrCompile.cpp(330) : error E2660: AddVfrDataStructField : function does not take 2 parameters\r
-    Generic utility (LineNumber == 0) \r
-      UtilityName : error E1234 : Text string : MsgFmt string and args\r
-\r
---*/\r
-{\r
-  INT8  Line[MAX_LINE_LEN];\r
-  INT8  Line2[MAX_LINE_LEN];\r
-  INT8  *Cptr;\r
-  //\r
-  // If given a filename, then add it (and the line number) to the string.\r
-  // If there's no filename, then use the program name if provided.\r
-  //\r
-  if (FileName != NULL) {\r
-    Cptr = FileName;\r
-  } else if (mUtilityName[0] != 0) {\r
-    Cptr = mUtilityName;\r
-  } else {\r
-    Cptr = "Unknown utility";\r
-  }\r
-\r
-  strcpy (Line, Cptr);\r
-  if (LineNumber != 0) {\r
-    sprintf (Line2, "(%d)", LineNumber);\r
-    strcat (Line, Line2);\r
-  }\r
-  //\r
-  // Have to print an error code or Visual Studio won't find the\r
-  // message for you. It has to be decimal digits too.\r
-  //\r
-  sprintf (Line2, " : %s %c%04d", Type, toupper (Type[0]), MessageCode);\r
-  strcat (Line, Line2);\r
-  fprintf (stdout, "%s", Line);\r
-  //\r
-  // If offending text was provided, then print it\r
-  //\r
-  if (Text != NULL) {\r
-    fprintf (stdout, ": %s ", Text);\r
-  }\r
-  //\r
-  // Print formatted message if provided\r
-  //\r
-  if (MsgFmt != NULL) {\r
-    vsprintf (Line2, MsgFmt, List);\r
-    fprintf (stdout, ": %s", Line2);\r
-  }\r
-\r
-  fprintf (stdout, "\n");\r
-}\r
-\r
-void\r
-ParserSetPosition (\r
-  INT8    *SourceFileName,\r
-  UINT32  LineNum\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Set the position in a file being parsed. This can be used to \r
-  print error messages deeper down in a parser.\r
-\r
-Arguments:\r
-  SourceFileName - name of the source file being parsed\r
-  LineNum        - line number of the source file being parsed\r
-\r
-Returns:\r
-  NA\r
-\r
---*/\r
-{\r
-  mSourceFileName     = SourceFileName;\r
-  mSourceFileLineNum  = LineNum;\r
-}\r
-\r
-void\r
-SetUtilityName (\r
-  INT8    *UtilityName\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  All printed error/warning/debug messages follow the same format, and\r
-  typically will print a filename or utility name followed by the error\r
-  text. However if a filename is not passed to the print routines, then\r
-  they'll print the utility name if you call this function early in your\r
-  app to set the utility name.\r
-  \r
-Arguments:\r
-  UtilityName  -  name of the utility, which will be printed with all\r
-                  error/warning/debug messags.\r
-\r
-Returns:\r
-  NA\r
-  \r
---*/\r
-{\r
-  //\r
-  // Save the name of the utility in our local variable. Make sure its\r
-  // length does not exceed our buffer.\r
-  //\r
-  if (UtilityName != NULL) {\r
-    if (strlen (UtilityName) >= sizeof (mUtilityName)) {\r
-      Error (UtilityName, 0, 0, "application error", "utility name length exceeds internal buffer size");\r
-      strncpy (mUtilityName, UtilityName, sizeof (mUtilityName) - 1);\r
-      mUtilityName[sizeof (mUtilityName) - 1] = 0;\r
-      return ;\r
-    } else {\r
-      strcpy (mUtilityName, UtilityName);\r
-    }\r
-  } else {\r
-    Error (NULL, 0, 0, "application error", "SetUtilityName() called with NULL utility name");\r
-  }\r
-}\r
-\r
-STATUS\r
-GetUtilityStatus (\r
-  VOID\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  When you call Error() or Warning(), this module keeps track of it and\r
-  sets a local mStatus to STATUS_ERROR or STATUS_WARNING. When the utility\r
-  exits, it can call this function to get the status and use it as a return\r
-  value.\r
-  \r
-Arguments:\r
-  None.\r
-\r
-Returns:\r
-  Worst-case status reported, as defined by which print function was called.\r
-  \r
---*/\r
-{\r
-  return mStatus;\r
-}\r
diff --git a/Tools/CodeTools/TianoTools/GuidChk/UtilsMsgs.h b/Tools/CodeTools/TianoTools/GuidChk/UtilsMsgs.h
deleted file mode 100644 (file)
index 5f6c701..0000000
+++ /dev/null
@@ -1,106 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2004, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-Module Name:  \r
-\r
-  UtilsMsgs.h\r
-  \r
-Abstract:\r
-\r
-  Prototypes for the EFI tools utility functions.\r
-  \r
---*/\r
-\r
-#ifndef _UTILS_MESSAGES_H_\r
-#define _UTILS_MESSAGES_H_\r
-\r
-STATUS\r
-GetUtilityStatus (\r
-  VOID\r
-  )\r
-;\r
-\r
-//\r
-// If someone prints an error message and didn't specify a source file name,\r
-// then we print the utility name instead. However they must tell us the\r
-// utility name early on via this function.\r
-//\r
-VOID\r
-SetUtilityName (\r
-  INT8 *ProgramName\r
-  )\r
-;\r
-\r
-void\r
-Error (\r
-  INT8    *FileName,\r
-  UINT32  LineNumber,\r
-  UINT32  ErrorCode,\r
-  INT8    *OffendingText,\r
-  INT8    *MsgFmt,\r
-  ...\r
-  )\r
-;\r
-\r
-void\r
-Warning (\r
-  INT8    *FileName,\r
-  UINT32  LineNumber,\r
-  UINT32  ErrorCode,\r
-  INT8    *OffendingText,\r
-  INT8    *MsgFmt,\r
-  ...\r
-  )\r
-;\r
-\r
-void\r
-DebugMsg (\r
-  INT8    *FileName,\r
-  UINT32  LineNumber,\r
-  UINT32  MsgLevel,\r
-  INT8    *OffendingText,\r
-  INT8    *MsgFmt,\r
-  ...\r
-  )\r
-;\r
-\r
-void\r
-SetDebugMsgMask (\r
-  UINT32    MsgMask\r
-  )\r
-;\r
-\r
-void\r
-ParserSetPosition (\r
-  INT8    *SourceFileName,\r
-  UINT32  LineNum\r
-  )\r
-;\r
-\r
-void\r
-ParserError (\r
-  UINT32  ErrorCode,\r
-  INT8    *OffendingText,\r
-  INT8    *MsgFmt,\r
-  ...\r
-  )\r
-;\r
-\r
-void\r
-ParserWarning (\r
-  UINT32  ErrorCode,\r
-  INT8    *OffendingText,\r
-  INT8    *MsgFmt,\r
-  ...\r
-  )\r
-;\r
-\r
-#endif\r
diff --git a/Tools/CodeTools/TianoTools/GuidChk/build.xml b/Tools/CodeTools/TianoTools/GuidChk/build.xml
deleted file mode 100644 (file)
index aec3ad1..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-<?xml version="1.0" ?>\r
-<!--\r
-Copyright (c) 2006, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
--->\r
-<project default="GenTool" basedir=".">\r
-<!--\r
-    EDK GuidChk Tool\r
-  Copyright (c) 2006, Intel Corporation\r
--->\r
-  <property name="ToolName" value="GuidChk"/>\r
-  <property name="FileSet" value="*.c *.h"/>\r
-\r
-  <taskdef resource="cpptasks.tasks"/>\r
-  <typedef resource="cpptasks.types"/>\r
-  <taskdef resource="net/sf/antcontrib/antlib.xml"/>\r
-\r
-  <property name="LINK_OUTPUT_TYPE" value="static"/>\r
-  <property name="BUILD_DIR" value="${PACKAGE_DIR}/${ToolName}/tmp"/>\r
-\r
-  <target name="GenTool" depends="init, Tool">\r
-    <if>\r
-      <isfalse value="${gcc}"/>\r
-      <then>\r
-        <echo message="The EDK Tool: ${ToolName} build has completed!"/>\r
-      </then>\r
-    </if>\r
-  </target>\r
-\r
-  <target name="init">\r
-    <if>\r
-      <istrue value="${gcc}"/>\r
-      <then>\r
-        <echo message="The EDK Tool: ${ToolName} is not built for GCC!"/>\r
-      </then>\r
-      <else>\r
-        <echo message="Building the EDK Tool: ${ToolName}"/>\r
-        <mkdir dir="${BUILD_DIR}"/>\r
-      </else>\r
-    </if>\r
-  </target>\r
-\r
-  <target name="Tool" depends="init" unless="gcc">\r
-    <cc name="${ToolChain}" objdir="${BUILD_DIR}" \r
-        outfile="${BIN_DIR}/${ToolName}"\r
-        outtype="executable"\r
-        debug="true"\r
-        optimize="speed">\r
-\r
-      <fileset dir="${basedir}/${ToolName}" \r
-        includes="${FileSet}" \r
-        defaultexcludes="TRUE" \r
-        excludes="*.xml *.inf"/>\r
-\r
-      <includepath path="${PACKAGE_DIR}/Include"/>\r
-      <includepath path="${PACKAGE_DIR}/Include/Ia32"/>\r
-      <includepath path="${PACKAGE_DIR}/Common"/>\r
-      <libset dir="${LIB_DIR}" libs="CommonTools"/>\r
-\r
-    </cc>\r
-  </target>\r
-\r
-  <target name="clean">\r
-    <echo message="Removing Intermediate Files Only"/>  \r
-    <delete failonerror="false" quiet="true" includeEmptyDirs="true">\r
-      <fileset dir="${BUILD_DIR}"/>\r
-    </delete>\r
-  </target>\r
-\r
-  <target name="cleanall">\r
-    <echo message="Removing Object Files and the Executable: ${ToolName}${ext_exe}"/>  \r
-    <delete failonerror="false" quiet="true" includeEmptyDirs="true">\r
-      <fileset dir="${BUILD_DIR}"/>\r
-      <fileset file="${BIN_DIR}/${ToolName}${ext_exe}"/>\r
-    </delete>\r
-  </target>\r
-\r
-</project>\r
diff --git a/Tools/CodeTools/TianoTools/Include/Common/BaseTypes.h b/Tools/CodeTools/TianoTools/Include/Common/BaseTypes.h
deleted file mode 100644 (file)
index b87e714..0000000
+++ /dev/null
@@ -1,212 +0,0 @@
-/** @file\r
-  Processor or Compiler specific defines for all supported processors.\r
-\r
-  This file is stand alone self consistent set of definitions. \r
-\r
-  Copyright (c) 2006, Intel Corporation                                                         \r
-  All rights reserved. This program and the accompanying materials                          \r
-  are licensed and made available under the terms and conditions of the BSD License         \r
-  which accompanies this distribution.  The full text of the license may be found at        \r
-  http://opensource.org/licenses/bsd-license.php                                            \r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-  Module Name:  BaseTypes.h\r
-\r
-**/\r
-\r
-#ifndef __BASE_TYPES_H__\r
-#define __BASE_TYPES_H__\r
-\r
-//\r
-// Include processor specific binding\r
-//\r
-#include <ProcessorBind.h>\r
-#include <stdarg.h>\r
-\r
-#define MEMORY_FENCE()  MemoryFence ()\r
-#define BREAKPOINT()    CpuBreakpoint ()\r
-#define DEADLOOP()      CpuDeadLoop ()\r
-\r
-typedef struct {\r
-  UINT32  Data1;\r
-  UINT16  Data2;\r
-  UINT16  Data3;\r
-  UINT8   Data4[8];\r
-} GUID;\r
-\r
-\r
-//\r
-// Modifiers to absract standard types to aid in debug of problems\r
-//\r
-#define CONST     const\r
-#define STATIC    static\r
-#define VOID      void\r
-\r
-//\r
-// Modifiers for Data Types used to self document code.\r
-// This concept is borrowed for UEFI specification.\r
-//\r
-#ifndef IN\r
-//\r
-// Some other envirnments use this construct, so #ifndef to prevent\r
-// mulitple definition.\r
-//\r
-#define IN\r
-#define OUT\r
-#define OPTIONAL\r
-#endif\r
-\r
-//\r
-// Constants. They may exist in other build structures, so #ifndef them.\r
-//\r
-#ifndef TRUE\r
-//\r
-// BugBug: UEFI specification claims 1 and 0. We are concerned about the \r
-//  complier portability so we did it this way.\r
-//\r
-#define TRUE  ((BOOLEAN)(1==1))\r
-#endif\r
-\r
-#ifndef FALSE\r
-#define FALSE ((BOOLEAN)(0==1))\r
-#endif\r
-\r
-#ifndef NULL\r
-#define NULL  ((VOID *) 0)\r
-#endif\r
-\r
-//\r
-//  Support for variable length argument lists using the ANSI standard.\r
-//  \r
-//  Since we are using the ANSI standard we used the standard nameing and\r
-//  did not folow the coding convention\r
-//\r
-//  VA_LIST  - typedef for argument list.\r
-//  VA_START (VA_LIST Marker, argument before the ...) - Init Marker for use.\r
-//  VA_END (VA_LIST Marker) - Clear Marker\r
-//  VA_ARG (VA_LIST Marker, var arg size) - Use Marker to get an argumnet from\r
-//    the ... list. You must know the size and pass it in this macro.\r
-//\r
-//  example:\r
-//\r
-//  UINTN\r
-//  ExampleVarArg (\r
-//    IN UINTN  NumberOfArgs,\r
-//    ...\r
-//    )\r
-//  {\r
-//    VA_LIST Marker;\r
-//    UINTN   Index;\r
-//    UINTN   Result;\r
-//\r
-//    //\r
-//    // Initialize the Marker\r
-//    //\r
-//    VA_START (Marker, NumberOfArgs);\r
-//    for (Index = 0, Result = 0; Index < NumberOfArgs; Index++) {\r
-//      //\r
-//      // The ... list is a series of UINTN values, so average them up.\r
-//      //\r
-//      Result += VA_ARG (Marker, UINTN);\r
-//    }\r
-//\r
-//    VA_END (Marker);\r
-//    return Result\r
-//  }\r
-//\r
-\r
-#define _INT_SIZE_OF(n) ((sizeof (n) + sizeof (UINTN) - 1) &~(sizeof (UINTN) - 1))\r
-\r
-//\r
-// Also support coding convention rules for var arg macros\r
-//\r
-#ifndef VA_START\r
-\r
-// typedef CHAR8 *VA_LIST;\r
-// #define VA_START(ap, v) (ap = (VA_LIST) & (v) + _INT_SIZE_OF (v))\r
-// #define VA_ARG(ap, t)   (*(t *) ((ap += _INT_SIZE_OF (t)) - _INT_SIZE_OF (t)))\r
-// #define VA_END(ap)      (ap = (VA_LIST) 0)\r
-// Use the native arguments for tools.\r
-#define VA_START va_start\r
-#define VA_ARG   va_arg\r
-#define VA_END   va_end\r
-#define VA_LIST  va_list\r
-\r
-#endif\r
-\r
-///\r
-///  CONTAINING_RECORD - returns a pointer to the structure\r
-///      from one of it's elements.\r
-///\r
-#define _CR(Record, TYPE, Field)  ((TYPE *) ((CHAR8 *) (Record) - (CHAR8 *) &(((TYPE *) 0)->Field)))\r
-\r
-///\r
-///  ALIGN_POINTER - aligns a pointer to the lowest boundry\r
-///\r
-#define ALIGN_POINTER(p, s) ((VOID *) ((p) + (((s) - ((UINTN) (p))) & ((s) - 1))))\r
-\r
-///\r
-///  ALIGN_VARIABLE - aligns a variable up to the next natural boundry for int size of a processor\r
-///\r
-#define ALIGN_VARIABLE(Value, Adjustment) \\r
-  Adjustment = 0U; \\r
-  if ((UINTN) (Value) % sizeof (UINTN)) { \\r
-    (Adjustment) = (UINTN)(sizeof (UINTN) - ((UINTN) (Value) % sizeof (UINTN))); \\r
-  } \\r
-  (Value) = (UINTN)((UINTN) (Value) + (UINTN) (Adjustment))\r
-\r
-//\r
-// EFI Error Codes common to all execution phases\r
-//\r
-\r
-typedef INTN RETURN_STATUS;\r
-\r
-///\r
-/// Set the upper bit to indicate EFI Error.\r
-///\r
-#define ENCODE_ERROR(a)              (MAX_BIT | (a))\r
-\r
-#define ENCODE_WARNING(a)            (a)\r
-#define RETURN_ERROR(a)              ((a) < 0)\r
-\r
-#define RETURN_SUCCESS               0\r
-#define RETURN_LOAD_ERROR            ENCODE_ERROR (1)\r
-#define RETURN_INVALID_PARAMETER     ENCODE_ERROR (2)\r
-#define RETURN_UNSUPPORTED           ENCODE_ERROR (3)\r
-#define RETURN_BAD_BUFFER_SIZE       ENCODE_ERROR (4)\r
-#define RETURN_BUFFER_TOO_SMALL      ENCODE_ERROR (5)\r
-#define RETURN_NOT_READY             ENCODE_ERROR (6)\r
-#define RETURN_DEVICE_ERROR          ENCODE_ERROR (7)\r
-#define RETURN_WRITE_PROTECTED       ENCODE_ERROR (8)\r
-#define RETURN_OUT_OF_RESOURCES      ENCODE_ERROR (9)\r
-#define RETURN_VOLUME_CORRUPTED      ENCODE_ERROR (10)\r
-#define RETURN_VOLUME_FULL           ENCODE_ERROR (11)\r
-#define RETURN_NO_MEDIA              ENCODE_ERROR (12)\r
-#define RETURN_MEDIA_CHANGED         ENCODE_ERROR (13)\r
-#define RETURN_NOT_FOUND             ENCODE_ERROR (14)\r
-#define RETURN_ACCESS_DENIED         ENCODE_ERROR (15)\r
-#define RETURN_NO_RESPONSE           ENCODE_ERROR (16)\r
-#define RETURN_NO_MAPPING            ENCODE_ERROR (17)\r
-#define RETURN_TIMEOUT               ENCODE_ERROR (18)\r
-#define RETURN_NOT_STARTED           ENCODE_ERROR (19)\r
-#define RETURN_ALREADY_STARTED       ENCODE_ERROR (20)\r
-#define RETURN_ABORTED               ENCODE_ERROR (21)\r
-#define RETURN_ICMP_ERROR            ENCODE_ERROR (22)\r
-#define RETURN_TFTP_ERROR            ENCODE_ERROR (23)\r
-#define RETURN_PROTOCOL_ERROR        ENCODE_ERROR (24)\r
-#define RETURN_INCOMPATIBLE_VERSION  ENCODE_ERROR (25)\r
-#define RETURN_SECURITY_VIOLATION    ENCODE_ERROR (26)\r
-#define RETURN_CRC_ERROR             ENCODE_ERROR (27)\r
-#define RETURN_END_OF_MEDIA          ENCODE_ERROR (28)\r
-#define RETURN_END_OF_FILE           ENCODE_ERROR (31)\r
-\r
-#define RETURN_WARN_UNKNOWN_GLYPH    ENCODE_WARNING (1)\r
-#define RETURN_WARN_DELETE_FAILURE   ENCODE_WARNING (2)\r
-#define RETURN_WARN_WRITE_FAILURE    ENCODE_WARNING (3)\r
-#define RETURN_WARN_BUFFER_TOO_SMALL ENCODE_WARNING (4)\r
-\r
-typedef UINT64 PHYSICAL_ADDRESS;\r
-\r
-#endif\r
diff --git a/Tools/CodeTools/TianoTools/Include/Common/Capsule.h b/Tools/CodeTools/TianoTools/Include/Common/Capsule.h
deleted file mode 100644 (file)
index 0434fdf..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-/** @file\r
-  Defines for the EFI Capsule functionality.\r
-\r
-  Copyright (c) 2006, Intel Corporation                                                         \r
-  All rights reserved. This program and the accompanying materials                          \r
-  are licensed and made available under the terms and conditions of the BSD License         \r
-  which accompanies this distribution.  The full text of the license may be found at        \r
-  http://opensource.org/licenses/bsd-license.php                                            \r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-  Module Name:  Capsule.h\r
-\r
-  @par Revision Reference:\r
-  These definitions are from Capsule Spec Version 0.9.\r
-\r
-**/\r
-\r
-#ifndef _EFI_CAPSULE_H_\r
-#define _EFI_CAPSULE_H_\r
-\r
-//\r
-// Bits in the flags field of the capsule header\r
-//\r
-#define EFI_CAPSULE_HEADER_FLAG_SETUP 0x00000001  // supports setup changes\r
-\r
-\r
-#define CAPSULE_BLOCK_DESCRIPTOR_SIGNATURE  EFI_SIGNATURE_32 ('C', 'B', 'D', 'S')\r
-\r
-//\r
-// An array of these describe the blocks that make up a capsule for\r
-// a capsule update.\r
-//\r
-typedef struct {\r
-  UINT64                Length;     // length of the data block\r
-  EFI_PHYSICAL_ADDRESS  Data;       // physical address of the data block\r
-  UINT32                Signature;  // CBDS\r
-  UINT32                CheckSum;   // to sum this structure to 0\r
-} EFI_CAPSULE_BLOCK_DESCRIPTOR;\r
-\r
-typedef struct {\r
-  EFI_GUID  OemGuid;\r
-  UINT32    HeaderSize;\r
-  //\r
-  // UINT8                       OemHdrData[];\r
-  //\r
-} EFI_CAPSULE_OEM_HEADER;\r
-\r
-typedef struct {\r
-  EFI_GUID  CapsuleGuid;\r
-  UINT32    HeaderSize;\r
-  UINT32    Flags;\r
-  UINT32    CapsuleImageSize;\r
-  UINT32    SequenceNumber;\r
-  EFI_GUID  InstanceId;\r
-  UINT32    OffsetToSplitInformation;\r
-  UINT32    OffsetToCapsuleBody;\r
-  UINT32    OffsetToOemDefinedHeader;\r
-  UINT32    OffsetToAuthorInformation;\r
-  UINT32    OffsetToRevisionInformation;\r
-  UINT32    OffsetToShortDescription;\r
-  UINT32    OffsetToLongDescription;\r
-  UINT32    OffsetToApplicableDevices;\r
-} EFI_CAPSULE_HEADER;\r
-\r
-#endif // #ifndef _EFI_CAPSULE_H_\r
diff --git a/Tools/CodeTools/TianoTools/Include/Common/Dependency.h b/Tools/CodeTools/TianoTools/Include/Common/Dependency.h
deleted file mode 100644 (file)
index 744027d..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-/** @file\r
-  This module contains data specific to dependency expressions\r
-  and local function prototypes.\r
-\r
-  Copyright (c) 2006, Intel Corporation                                                         \r
-  All rights reserved. This program and the accompanying materials                          \r
-  are licensed and made available under the terms and conditions of the BSD License         \r
-  which accompanies this distribution.  The full text of the license may be found at        \r
-  http://opensource.org/licenses/bsd-license.php                                            \r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-  Module Name:  Dependency.h\r
-\r
-**/\r
-\r
-#ifndef __DEPENDENCY_H__\r
-#define __DEPENDENCY_H__\r
-\r
-/// EFI_DEP_BEFORE       - If present, this must be the first and only opcode\r
-#define EFI_DEP_BEFORE        0x00\r
-\r
-/// EFI_DEP_AFTER        - If present, this must be the first and only opcode\r
-#define EFI_DEP_AFTER         0x01\r
-\r
-#define EFI_DEP_PUSH          0x02\r
-#define EFI_DEP_AND           0x03\r
-#define EFI_DEP_OR            0x04\r
-#define EFI_DEP_NOT           0x05\r
-#define EFI_DEP_TRUE          0x06\r
-#define EFI_DEP_FALSE         0x07\r
-#define EFI_DEP_END           0x08\r
-\r
-/// EFI_DEP_SOR          - If present, this must be the first opcode\r
-#define EFI_DEP_SOR           0x09\r
-\r
-///\r
-/// EFI_DEP_REPLACE_TRUE - Used to dynamically patch the dependecy expression\r
-///                        to save time.  A EFI_DEP_PUSH is evauated one an\r
-///                        replaced with EFI_DEP_REPLACE_TRUE\r
-///\r
-#define EFI_DEP_REPLACE_TRUE  0xff\r
-\r
-///\r
-/// Define the initial size of the dependency expression evaluation stack\r
-///\r
-#define DEPEX_STACK_SIZE_INCREMENT  0x1000\r
-\r
-#endif\r
diff --git a/Tools/CodeTools/TianoTools/Include/Common/EfiImage.h b/Tools/CodeTools/TianoTools/Include/Common/EfiImage.h
deleted file mode 100644 (file)
index 2f5c580..0000000
+++ /dev/null
@@ -1,716 +0,0 @@
-/** @file\r
-  EFI image format for PE32+. Please note some data structures are different\r
-  for IA-32 and Itanium-based images, look for UINTN and the #ifdef EFI_IA64\r
-\r
-  @bug Fix text - doc as defined in MSFT EFI specification.\r
-\r
-  Copyright (c) 2006, Intel Corporation                                                         \r
-  All rights reserved. This program and the accompanying materials                          \r
-  are licensed and made available under the terms and conditions of the BSD License         \r
-  which accompanies this distribution.  The full text of the license may be found at        \r
-  http://opensource.org/licenses/bsd-license.php                                            \r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-  Module Name:  EfiImage.h\r
-\r
-**/\r
-\r
-#ifndef __EFI_IMAGE_H__\r
-#define __EFI_IMAGE_H__\r
-\r
-//\r
-// PE32+ Subsystem type for EFI images\r
-//\r
-#define EFI_IMAGE_SUBSYSTEM_EFI_APPLICATION         10\r
-#define EFI_IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER 11\r
-#define EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER      12\r
-#define EFI_IMAGE_SUBSYSTEM_SAL_RUNTIME_DRIVER      13\r
-\r
-//\r
-// BugBug: Need to get a real answer for this problem. This is not in the\r
-//         PE specification.\r
-//\r
-//         A SAL runtime driver does not get fixed up when a transition to\r
-//         virtual mode is made. In all other cases it should be treated\r
-//         like a EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER image\r
-//\r
-#define EFI_IMAGE_SUBSYSTEM_SAL_RUNTIME_DRIVER  13\r
-\r
-//\r
-// PE32+ Machine type for EFI images\r
-//\r
-#define IMAGE_FILE_MACHINE_I386     0x014c\r
-#define IMAGE_FILE_MACHINE_IA64     0x0200\r
-#define IMAGE_FILE_MACHINE_EBC      0x0EBC\r
-#define IMAGE_FILE_MACHINE_X64      0x8664\r
-//\r
-// Support old names for backward compatible\r
-//\r
-#define EFI_IMAGE_MACHINE_IA32      IMAGE_FILE_MACHINE_I386 \r
-#define EFI_IMAGE_MACHINE_IA64      IMAGE_FILE_MACHINE_IA64  \r
-#define EFI_IMAGE_MACHINE_IPF       IMAGE_FILE_MACHINE_IA64  \r
-#define EFI_IMAGE_MACHINE_EBC       IMAGE_FILE_MACHINE_EBC  \r
-#define EFI_IMAGE_MACHINE_X64       IMAGE_FILE_MACHINE_X64\r
-\r
-#define EFI_IMAGE_DOS_SIGNATURE     0x5A4D      // MZ\r
-#define EFI_IMAGE_OS2_SIGNATURE     0x454E      // NE\r
-#define EFI_IMAGE_OS2_SIGNATURE_LE  0x454C      // LE\r
-#define EFI_IMAGE_NT_SIGNATURE      0x00004550  // PE00\r
-#define EFI_IMAGE_EDOS_SIGNATURE    0x44454550  // PEED\r
-\r
-///\r
-/// PE images can start with an optional DOS header, so if an image is run\r
-///  under DOS it can print an error message.\r
-///\r
-typedef struct {\r
-  UINT16  e_magic;    // Magic number\r
-  UINT16  e_cblp;     // Bytes on last page of file\r
-  UINT16  e_cp;       // Pages in file\r
-  UINT16  e_crlc;     // Relocations\r
-  UINT16  e_cparhdr;  // Size of header in paragraphs\r
-  UINT16  e_minalloc; // Minimum extra paragraphs needed\r
-  UINT16  e_maxalloc; // Maximum extra paragraphs needed\r
-  UINT16  e_ss;       // Initial (relative) SS value\r
-  UINT16  e_sp;       // Initial SP value\r
-  UINT16  e_csum;     // Checksum\r
-  UINT16  e_ip;       // Initial IP value\r
-  UINT16  e_cs;       // Initial (relative) CS value\r
-  UINT16  e_lfarlc;   // File address of relocation table\r
-  UINT16  e_ovno;     // Overlay number\r
-  UINT16  e_res[4];   // Reserved words\r
-  UINT16  e_oemid;    // OEM identifier (for e_oeminfo)\r
-  UINT16  e_oeminfo;  // OEM information; e_oemid specific\r
-  UINT16  e_res2[10]; // Reserved words\r
-  UINT32  e_lfanew;   // File address of new exe header\r
-} EFI_IMAGE_DOS_HEADER;\r
-\r
-///\r
-/// File header format.\r
-///\r
-typedef struct {\r
-  UINT16  Machine;\r
-  UINT16  NumberOfSections;\r
-  UINT32  TimeDateStamp;\r
-  UINT32  PointerToSymbolTable;\r
-  UINT32  NumberOfSymbols;\r
-  UINT16  SizeOfOptionalHeader;\r
-  UINT16  Characteristics;\r
-} EFI_IMAGE_FILE_HEADER;\r
-\r
-#define EFI_IMAGE_SIZEOF_FILE_HEADER        20\r
-\r
-#define EFI_IMAGE_FILE_RELOCS_STRIPPED      0x0001  // Relocation info stripped from file.\r
-#define EFI_IMAGE_FILE_EXECUTABLE_IMAGE     0x0002  // File is executable  (i.e. no unresolved externel references).\r
-#define EFI_IMAGE_FILE_LINE_NUMS_STRIPPED   0x0004  // Line nunbers stripped from file.\r
-#define EFI_IMAGE_FILE_LOCAL_SYMS_STRIPPED  0x0008  // Local symbols stripped from file.\r
-#define EFI_IMAGE_FILE_BYTES_REVERSED_LO    0x0080  // Bytes of machine word are reversed.\r
-#define EFI_IMAGE_FILE_32BIT_MACHINE        0x0100  // 32 bit word machine.\r
-#define EFI_IMAGE_FILE_DEBUG_STRIPPED       0x0200  // Debugging info stripped from file in .DBG file\r
-#define EFI_IMAGE_FILE_SYSTEM               0x1000  // System File.\r
-#define EFI_IMAGE_FILE_DLL                  0x2000  // File is a DLL.\r
-#define EFI_IMAGE_FILE_BYTES_REVERSED_HI    0x8000  // Bytes of machine word are reversed.\r
-#define EFI_IMAGE_FILE_MACHINE_UNKNOWN      0\r
-#define EFI_IMAGE_FILE_MACHINE_I386         0x14c   // Intel 386.\r
-#define EFI_IMAGE_FILE_MACHINE_R3000        0x162   // MIPS* little-endian, 0540 big-endian\r
-#define EFI_IMAGE_FILE_MACHINE_R4000        0x166   // MIPS* little-endian\r
-#define EFI_IMAGE_FILE_MACHINE_ALPHA        0x184   // Alpha_AXP*\r
-#define EFI_IMAGE_FILE_MACHINE_POWERPC      0x1F0   // IBM* PowerPC Little-Endian\r
-#define EFI_IMAGE_FILE_MACHINE_TAHOE        0x7cc   // Intel EM machine\r
-//\r
-// * Other names and brands may be claimed as the property of others.\r
-//\r
-\r
-///\r
-/// Directory format.\r
-///\r
-typedef struct {\r
-  UINT32  VirtualAddress;\r
-  UINT32  Size;\r
-} EFI_IMAGE_DATA_DIRECTORY;\r
-\r
-#define EFI_IMAGE_NUMBER_OF_DIRECTORY_ENTRIES 16\r
-\r
-typedef struct {\r
-  UINT16  Magic;\r
-  UINT8   MajorLinkerVersion;\r
-  UINT8   MinorLinkerVersion;\r
-  UINT32  SizeOfCode;\r
-  UINT32  SizeOfInitializedData;\r
-  UINT32  SizeOfUninitializedData;\r
-  UINT32  AddressOfEntryPoint;\r
-  UINT32  BaseOfCode;\r
-  UINT32  BaseOfData;\r
-  UINT32  BaseOfBss;\r
-  UINT32  GprMask;\r
-  UINT32  CprMask[4];\r
-  UINT32  GpValue;\r
-} EFI_IMAGE_ROM_OPTIONAL_HEADER;\r
-\r
-#define EFI_IMAGE_ROM_OPTIONAL_HDR_MAGIC      0x107\r
-#define EFI_IMAGE_SIZEOF_ROM_OPTIONAL_HEADER  sizeof (EFI_IMAGE_ROM_OPTIONAL_HEADER)\r
-\r
-typedef struct {\r
-  EFI_IMAGE_FILE_HEADER         FileHeader;\r
-  EFI_IMAGE_ROM_OPTIONAL_HEADER OptionalHeader;\r
-} EFI_IMAGE_ROM_HEADERS;\r
-\r
-///\r
-/// @attention\r
-/// EFI_IMAGE_OPTIONAL_HEADER32 and EFI_IMAGE_OPTIONAL_HEADER64\r
-/// are for use ONLY by tools.  All proper EFI code MUST use\r
-/// EFI_IMAGE_OPTIONAL_HEADER ONLY!!!\r
-///\r
-#define EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC 0x10b\r
-\r
-typedef struct {\r
-  //\r
-  // Standard fields.\r
-  //\r
-  UINT16                    Magic;\r
-  UINT8                     MajorLinkerVersion;\r
-  UINT8                     MinorLinkerVersion;\r
-  UINT32                    SizeOfCode;\r
-  UINT32                    SizeOfInitializedData;\r
-  UINT32                    SizeOfUninitializedData;\r
-  UINT32                    AddressOfEntryPoint;\r
-  UINT32                    BaseOfCode;\r
-  UINT32                    BaseOfData;\r
-  //\r
-  // NT additional fields.\r
-  //\r
-  UINT32                    ImageBase;\r
-  UINT32                    SectionAlignment;\r
-  UINT32                    FileAlignment;\r
-  UINT16                    MajorOperatingSystemVersion;\r
-  UINT16                    MinorOperatingSystemVersion;\r
-  UINT16                    MajorImageVersion;\r
-  UINT16                    MinorImageVersion;\r
-  UINT16                    MajorSubsystemVersion;\r
-  UINT16                    MinorSubsystemVersion;\r
-  UINT32                    Win32VersionValue;\r
-  UINT32                    SizeOfImage;\r
-  UINT32                    SizeOfHeaders;\r
-  UINT32                    CheckSum;\r
-  UINT16                    Subsystem;\r
-  UINT16                    DllCharacteristics;\r
-  UINT32                    SizeOfStackReserve;\r
-  UINT32                    SizeOfStackCommit;\r
-  UINT32                    SizeOfHeapReserve;\r
-  UINT32                    SizeOfHeapCommit;\r
-  UINT32                    LoaderFlags;\r
-  UINT32                    NumberOfRvaAndSizes;\r
-  EFI_IMAGE_DATA_DIRECTORY  DataDirectory[EFI_IMAGE_NUMBER_OF_DIRECTORY_ENTRIES];\r
-} EFI_IMAGE_OPTIONAL_HEADER32;\r
-\r
-///\r
-/// @attention\r
-/// EFI_IMAGE_OPTIONAL_HEADER32 and EFI_IMAGE_OPTIONAL_HEADER64\r
-/// are for use ONLY by tools.  All proper EFI code MUST use\r
-/// EFI_IMAGE_OPTIONAL_HEADER ONLY!!!\r
-///\r
-#define EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC 0x20b\r
-\r
-typedef struct {\r
-  //\r
-  // Standard fields.\r
-  //\r
-  UINT16                    Magic;\r
-  UINT8                     MajorLinkerVersion;\r
-  UINT8                     MinorLinkerVersion;\r
-  UINT32                    SizeOfCode;\r
-  UINT32                    SizeOfInitializedData;\r
-  UINT32                    SizeOfUninitializedData;\r
-  UINT32                    AddressOfEntryPoint;\r
-  UINT32                    BaseOfCode;\r
-  //\r
-  // NT additional fields.\r
-  //\r
-  UINT64                    ImageBase;\r
-  UINT32                    SectionAlignment;\r
-  UINT32                    FileAlignment;\r
-  UINT16                    MajorOperatingSystemVersion;\r
-  UINT16                    MinorOperatingSystemVersion;\r
-  UINT16                    MajorImageVersion;\r
-  UINT16                    MinorImageVersion;\r
-  UINT16                    MajorSubsystemVersion;\r
-  UINT16                    MinorSubsystemVersion;\r
-  UINT32                    Win32VersionValue;\r
-  UINT32                    SizeOfImage;\r
-  UINT32                    SizeOfHeaders;\r
-  UINT32                    CheckSum;\r
-  UINT16                    Subsystem;\r
-  UINT16                    DllCharacteristics;\r
-  UINT64                    SizeOfStackReserve;\r
-  UINT64                    SizeOfStackCommit;\r
-  UINT64                    SizeOfHeapReserve;\r
-  UINT64                    SizeOfHeapCommit;\r
-  UINT32                    LoaderFlags;\r
-  UINT32                    NumberOfRvaAndSizes;\r
-  EFI_IMAGE_DATA_DIRECTORY  DataDirectory[EFI_IMAGE_NUMBER_OF_DIRECTORY_ENTRIES];\r
-} EFI_IMAGE_OPTIONAL_HEADER64;\r
-\r
-///\r
-/// @attention\r
-/// EFI_IMAGE_NT_HEADERS32 and EFI_IMAGE_HEADERS64 are for use ONLY\r
-/// by tools.  All proper EFI code MUST use EFI_IMAGE_NT_HEADERS ONLY!!!\r
-///\r
-typedef struct {\r
-  UINT32                      Signature;\r
-  EFI_IMAGE_FILE_HEADER       FileHeader;\r
-  EFI_IMAGE_OPTIONAL_HEADER32 OptionalHeader;\r
-} EFI_IMAGE_NT_HEADERS32;\r
-\r
-#define EFI_IMAGE_SIZEOF_NT_OPTIONAL32_HEADER sizeof (EFI_IMAGE_NT_HEADERS32)\r
-\r
-typedef struct {\r
-  UINT32                      Signature;\r
-  EFI_IMAGE_FILE_HEADER       FileHeader;\r
-  EFI_IMAGE_OPTIONAL_HEADER64 OptionalHeader;\r
-} EFI_IMAGE_NT_HEADERS64;\r
-\r
-#define EFI_IMAGE_SIZEOF_NT_OPTIONAL64_HEADER sizeof (EFI_IMAGE_NT_HEADERS64)\r
-\r
-//\r
-// Processor specific definition of EFI_IMAGE_OPTIONAL_HEADER so the\r
-// type name EFI_IMAGE_OPTIONAL_HEADER is appropriate to the build.  Same for\r
-// EFI_IMAGE_NT_HEADERS.  These definitions MUST be used by ALL EFI code.\r
-//\r
-#if   defined (MDE_CPU_IA32)\r
-\r
-typedef EFI_IMAGE_OPTIONAL_HEADER32     EFI_IMAGE_OPTIONAL_HEADER;\r
-typedef EFI_IMAGE_NT_HEADERS32          EFI_IMAGE_NT_HEADERS;\r
-\r
-#define EFI_IMAGE_NT_OPTIONAL_HDR_MAGIC EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC\r
-#define EFI_IMAGE_MACHINE_TYPE_SUPPORTED(Machine) \\r
-  (((Machine) == EFI_IMAGE_MACHINE_IA32) || ((Machine) == EFI_IMAGE_MACHINE_EBC))\r
-\r
-#elif defined (MDE_CPU_IPF)\r
-\r
-typedef EFI_IMAGE_OPTIONAL_HEADER64     EFI_IMAGE_OPTIONAL_HEADER;\r
-typedef EFI_IMAGE_NT_HEADERS64          EFI_IMAGE_NT_HEADERS;\r
-\r
-#define EFI_IMAGE_NT_OPTIONAL_HDR_MAGIC EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC\r
-#define EFI_IMAGE_MACHINE_TYPE_SUPPORTED(Machine) \\r
-  (((Machine) == EFI_IMAGE_MACHINE_IPF) || ((Machine) == EFI_IMAGE_MACHINE_EBC))\r
-\r
-#elif defined (MDE_CPU_X64)\r
-\r
-typedef EFI_IMAGE_OPTIONAL_HEADER64     EFI_IMAGE_OPTIONAL_HEADER;\r
-typedef EFI_IMAGE_NT_HEADERS64          EFI_IMAGE_NT_HEADERS;\r
-\r
-#define EFI_IMAGE_NT_OPTIONAL_HDR_MAGIC EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC\r
-#define EFI_IMAGE_MACHINE_TYPE_SUPPORTED(Machine) \\r
-  (((Machine) == EFI_IMAGE_MACHINE_X64) || ((Machine) == EFI_IMAGE_MACHINE_EBC))\r
-\r
-#elif defined (MDE_CPU_EBC)\r
-\r
-//\r
-// This is just to make sure you can cross compile with the EBC compiiler.\r
-// It does not make sense to have a PE loader coded in EBC. You need to \r
-// understand the basic \r
-//\r
-typedef EFI_IMAGE_OPTIONAL_HEADER64     EFI_IMAGE_OPTIONAL_HEADER;\r
-typedef EFI_IMAGE_NT_HEADERS64          EFI_IMAGE_NT_HEADERS;\r
-\r
-#define EFI_IMAGE_NT_OPTIONAL_HDR_MAGIC EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC\r
-#define EFI_IMAGE_MACHINE_TYPE_SUPPORTED(Machine) ((Machine) == EFI_IMAGE_MACHINE_EBC)\r
-\r
-#else\r
-#error Unknown Processor Type\r
-#endif\r
-\r
-\r
-#define EFI_IMAGE_FIRST_SECTION(ntheader) \\r
-    ( \\r
-      (EFI_IMAGE_SECTION_HEADER *) \\r
-        ( \\r
-          (UINT32) ntheader + \\r
-          FIELD_OFFSET (EFI_IMAGE_NT_HEADERS, OptionalHeader) + \\r
-          ((EFI_IMAGE_NT_HEADERS *) (ntheader))->FileHeader.SizeOfOptionalHeader \\r
-        ) \\r
-    )\r
-\r
-//\r
-// Subsystem Values\r
-//\r
-#define EFI_IMAGE_SUBSYSTEM_UNKNOWN     0\r
-#define EFI_IMAGE_SUBSYSTEM_NATIVE      1\r
-#define EFI_IMAGE_SUBSYSTEM_WINDOWS_GUI 2\r
-#define EFI_IMAGE_SUBSYSTEM_WINDOWS_CUI 3.\r
-#define EFI_IMAGE_SUBSYSTEM_OS2_CUI     5\r
-#define EFI_IMAGE_SUBSYSTEM_POSIX_CUI   7\r
-\r
-//\r
-// Directory Entries\r
-//\r
-#define EFI_IMAGE_DIRECTORY_ENTRY_EXPORT      0\r
-#define EFI_IMAGE_DIRECTORY_ENTRY_IMPORT      1\r
-#define EFI_IMAGE_DIRECTORY_ENTRY_RESOURCE    2\r
-#define EFI_IMAGE_DIRECTORY_ENTRY_EXCEPTION   3\r
-#define EFI_IMAGE_DIRECTORY_ENTRY_SECURITY    4\r
-#define EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC   5\r
-#define EFI_IMAGE_DIRECTORY_ENTRY_DEBUG       6\r
-#define EFI_IMAGE_DIRECTORY_ENTRY_COPYRIGHT   7\r
-#define EFI_IMAGE_DIRECTORY_ENTRY_GLOBALPTR   8\r
-#define EFI_IMAGE_DIRECTORY_ENTRY_TLS         9\r
-#define EFI_IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG 10\r
-\r
-//\r
-// Section header format.\r
-//\r
-#define EFI_IMAGE_SIZEOF_SHORT_NAME 8\r
-\r
-typedef struct {\r
-  UINT8 Name[EFI_IMAGE_SIZEOF_SHORT_NAME];\r
-  union {\r
-    UINT32  PhysicalAddress;\r
-    UINT32  VirtualSize;\r
-  } Misc;\r
-  UINT32  VirtualAddress;\r
-  UINT32  SizeOfRawData;\r
-  UINT32  PointerToRawData;\r
-  UINT32  PointerToRelocations;\r
-  UINT32  PointerToLinenumbers;\r
-  UINT16  NumberOfRelocations;\r
-  UINT16  NumberOfLinenumbers;\r
-  UINT32  Characteristics;\r
-} EFI_IMAGE_SECTION_HEADER;\r
-\r
-#define EFI_IMAGE_SIZEOF_SECTION_HEADER       40\r
-\r
-#define EFI_IMAGE_SCN_TYPE_NO_PAD             0x00000008  // Reserved.\r
-#define EFI_IMAGE_SCN_CNT_CODE                0x00000020\r
-#define EFI_IMAGE_SCN_CNT_INITIALIZED_DATA    0x00000040\r
-#define EFI_IMAGE_SCN_CNT_UNINITIALIZED_DATA  0x00000080\r
-\r
-#define EFI_IMAGE_SCN_LNK_OTHER               0x00000100  // Reserved.\r
-#define EFI_IMAGE_SCN_LNK_INFO                0x00000200  // Section contains comments or some other type of information.\r
-#define EFI_IMAGE_SCN_LNK_REMOVE              0x00000800  // Section contents will not become part of image.\r
-#define EFI_IMAGE_SCN_LNK_COMDAT              0x00001000\r
-\r
-#define EFI_IMAGE_SCN_ALIGN_1BYTES            0x00100000\r
-#define EFI_IMAGE_SCN_ALIGN_2BYTES            0x00200000\r
-#define EFI_IMAGE_SCN_ALIGN_4BYTES            0x00300000\r
-#define EFI_IMAGE_SCN_ALIGN_8BYTES            0x00400000\r
-#define EFI_IMAGE_SCN_ALIGN_16BYTES           0x00500000\r
-#define EFI_IMAGE_SCN_ALIGN_32BYTES           0x00600000\r
-#define EFI_IMAGE_SCN_ALIGN_64BYTES           0x00700000\r
-\r
-#define EFI_IMAGE_SCN_MEM_DISCARDABLE         0x02000000\r
-#define EFI_IMAGE_SCN_MEM_NOT_CACHED          0x04000000\r
-#define EFI_IMAGE_SCN_MEM_NOT_PAGED           0x08000000\r
-#define EFI_IMAGE_SCN_MEM_SHARED              0x10000000\r
-#define EFI_IMAGE_SCN_MEM_EXECUTE             0x20000000\r
-#define EFI_IMAGE_SCN_MEM_READ                0x40000000\r
-#define EFI_IMAGE_SCN_MEM_WRITE               0x80000000\r
-\r
-///\r
-/// Symbol format.\r
-///\r
-#define EFI_IMAGE_SIZEOF_SYMBOL 18\r
-\r
-//\r
-// Section values.\r
-//\r
-// Symbols have a section number of the section in which they are\r
-// defined. Otherwise, section numbers have the following meanings:\r
-//\r
-#define EFI_IMAGE_SYM_UNDEFINED (UINT16) 0  // Symbol is undefined or is common.\r
-#define EFI_IMAGE_SYM_ABSOLUTE  (UINT16) -1 // Symbol is an absolute value.\r
-#define EFI_IMAGE_SYM_DEBUG     (UINT16) -2 // Symbol is a special debug item.\r
-//\r
-// Type (fundamental) values.\r
-//\r
-#define EFI_IMAGE_SYM_TYPE_NULL   0   // no type.\r
-#define EFI_IMAGE_SYM_TYPE_VOID   1   //\r
-#define EFI_IMAGE_SYM_TYPE_CHAR   2   // type character.\r
-#define EFI_IMAGE_SYM_TYPE_SHORT  3   // type short integer.\r
-#define EFI_IMAGE_SYM_TYPE_INT    4\r
-#define EFI_IMAGE_SYM_TYPE_LONG   5\r
-#define EFI_IMAGE_SYM_TYPE_FLOAT  6\r
-#define EFI_IMAGE_SYM_TYPE_DOUBLE 7\r
-#define EFI_IMAGE_SYM_TYPE_STRUCT 8\r
-#define EFI_IMAGE_SYM_TYPE_UNION  9\r
-#define EFI_IMAGE_SYM_TYPE_ENUM   10  // enumeration.\r
-#define EFI_IMAGE_SYM_TYPE_MOE    11  // member of enumeration.\r
-#define EFI_IMAGE_SYM_TYPE_BYTE   12\r
-#define EFI_IMAGE_SYM_TYPE_WORD   13\r
-#define EFI_IMAGE_SYM_TYPE_UINT   14\r
-#define EFI_IMAGE_SYM_TYPE_DWORD  15\r
-\r
-//\r
-// Type (derived) values.\r
-//\r
-#define EFI_IMAGE_SYM_DTYPE_NULL      0 // no derived type.\r
-#define EFI_IMAGE_SYM_DTYPE_POINTER   1\r
-#define EFI_IMAGE_SYM_DTYPE_FUNCTION  2\r
-#define EFI_IMAGE_SYM_DTYPE_ARRAY     3\r
-\r
-//\r
-// Storage classes.\r
-//\r
-#define EFI_IMAGE_SYM_CLASS_END_OF_FUNCTION   (UINT8) -1\r
-#define EFI_IMAGE_SYM_CLASS_NULL              0\r
-#define EFI_IMAGE_SYM_CLASS_AUTOMATIC         1\r
-#define EFI_IMAGE_SYM_CLASS_EXTERNAL          2\r
-#define EFI_IMAGE_SYM_CLASS_STATIC            3\r
-#define EFI_IMAGE_SYM_CLASS_REGISTER          4\r
-#define EFI_IMAGE_SYM_CLASS_EXTERNAL_DEF      5\r
-#define EFI_IMAGE_SYM_CLASS_LABEL             6\r
-#define EFI_IMAGE_SYM_CLASS_UNDEFINED_LABEL   7\r
-#define EFI_IMAGE_SYM_CLASS_MEMBER_OF_STRUCT  8\r
-#define EFI_IMAGE_SYM_CLASS_ARGUMENT          9\r
-#define EFI_IMAGE_SYM_CLASS_STRUCT_TAG        10\r
-#define EFI_IMAGE_SYM_CLASS_MEMBER_OF_UNION   11\r
-#define EFI_IMAGE_SYM_CLASS_UNION_TAG         12\r
-#define EFI_IMAGE_SYM_CLASS_TYPE_DEFINITION   13\r
-#define EFI_IMAGE_SYM_CLASS_UNDEFINED_STATIC  14\r
-#define EFI_IMAGE_SYM_CLASS_ENUM_TAG          15\r
-#define EFI_IMAGE_SYM_CLASS_MEMBER_OF_ENUM    16\r
-#define EFI_IMAGE_SYM_CLASS_REGISTER_PARAM    17\r
-#define EFI_IMAGE_SYM_CLASS_BIT_FIELD         18\r
-#define EFI_IMAGE_SYM_CLASS_BLOCK             100\r
-#define EFI_IMAGE_SYM_CLASS_FUNCTION          101\r
-#define EFI_IMAGE_SYM_CLASS_END_OF_STRUCT     102\r
-#define EFI_IMAGE_SYM_CLASS_FILE              103\r
-#define EFI_IMAGE_SYM_CLASS_SECTION           104\r
-#define EFI_IMAGE_SYM_CLASS_WEAK_EXTERNAL     105\r
-\r
-//\r
-// type packing constants\r
-//\r
-#define EFI_IMAGE_N_BTMASK  017\r
-#define EFI_IMAGE_N_TMASK   060\r
-#define EFI_IMAGE_N_TMASK1  0300\r
-#define EFI_IMAGE_N_TMASK2  0360\r
-#define EFI_IMAGE_N_BTSHFT  4\r
-#define EFI_IMAGE_N_TSHIFT  2\r
-\r
-//\r
-// Communal selection types.\r
-//\r
-#define EFI_IMAGE_COMDAT_SELECT_NODUPLICATES    1\r
-#define EFI_IMAGE_COMDAT_SELECT_ANY             2\r
-#define EFI_IMAGE_COMDAT_SELECT_SAME_SIZE       3\r
-#define EFI_IMAGE_COMDAT_SELECT_EXACT_MATCH     4\r
-#define EFI_IMAGE_COMDAT_SELECT_ASSOCIATIVE     5\r
-\r
-#define EFI_IMAGE_WEAK_EXTERN_SEARCH_NOLIBRARY  1\r
-#define EFI_IMAGE_WEAK_EXTERN_SEARCH_LIBRARY    2\r
-#define EFI_IMAGE_WEAK_EXTERN_SEARCH_ALIAS      3\r
-\r
-///\r
-/// Relocation format.\r
-///\r
-typedef struct {\r
-  UINT32  VirtualAddress;\r
-  UINT32  SymbolTableIndex;\r
-  UINT16  Type;\r
-} EFI_IMAGE_RELOCATION;\r
-\r
-#define EFI_IMAGE_SIZEOF_RELOCATION 10\r
-\r
-//\r
-// I386 relocation types.\r
-//\r
-#define EFI_IMAGE_REL_I386_ABSOLUTE 0   // Reference is absolute, no relocation is necessary\r
-#define EFI_IMAGE_REL_I386_DIR16    01  // Direct 16-bit reference to the symbols virtual address\r
-#define EFI_IMAGE_REL_I386_REL16    02  // PC-relative 16-bit reference to the symbols virtual address\r
-#define EFI_IMAGE_REL_I386_DIR32    06  // Direct 32-bit reference to the symbols virtual address\r
-#define EFI_IMAGE_REL_I386_DIR32NB  07  // Direct 32-bit reference to the symbols virtual address, base not included\r
-#define EFI_IMAGE_REL_I386_SEG12    011 // Direct 16-bit reference to the segment-selector bits of a 32-bit virtual address\r
-#define EFI_IMAGE_REL_I386_SECTION  012\r
-#define EFI_IMAGE_REL_I386_SECREL   013\r
-#define EFI_IMAGE_REL_I386_REL32    024 // PC-relative 32-bit reference to the symbols virtual address\r
-\r
-///\r
-/// Based relocation format.\r
-///\r
-typedef struct {\r
-  UINT32  VirtualAddress;\r
-  UINT32  SizeOfBlock;\r
-} EFI_IMAGE_BASE_RELOCATION;\r
-\r
-#define EFI_IMAGE_SIZEOF_BASE_RELOCATION  8\r
-\r
-//\r
-// Based relocation types.\r
-//\r
-#define EFI_IMAGE_REL_BASED_ABSOLUTE      0\r
-#define EFI_IMAGE_REL_BASED_HIGH          1\r
-#define EFI_IMAGE_REL_BASED_LOW           2\r
-#define EFI_IMAGE_REL_BASED_HIGHLOW       3\r
-#define EFI_IMAGE_REL_BASED_HIGHADJ       4\r
-#define EFI_IMAGE_REL_BASED_MIPS_JMPADDR  5\r
-#define EFI_IMAGE_REL_BASED_IA64_IMM64    9\r
-#define EFI_IMAGE_REL_BASED_DIR64         10\r
-\r
-///\r
-/// Line number format.\r
-///\r
-typedef struct {\r
-  union {\r
-    UINT32  SymbolTableIndex; // Symbol table index of function name if Linenumber is 0.\r
-    UINT32  VirtualAddress;   // Virtual address of line number.\r
-  } Type;\r
-  UINT16  Linenumber;         // Line number.\r
-} EFI_IMAGE_LINENUMBER;\r
-\r
-#define EFI_IMAGE_SIZEOF_LINENUMBER 6\r
-\r
-//\r
-// Archive format.\r
-//\r
-#define EFI_IMAGE_ARCHIVE_START_SIZE        8\r
-#define EFI_IMAGE_ARCHIVE_START             "!<arch>\n"\r
-#define EFI_IMAGE_ARCHIVE_END               "`\n"\r
-#define EFI_IMAGE_ARCHIVE_PAD               "\n"\r
-#define EFI_IMAGE_ARCHIVE_LINKER_MEMBER     "/               "\r
-#define EFI_IMAGE_ARCHIVE_LONGNAMES_MEMBER  "//              "\r
-\r
-typedef struct {\r
-  UINT8 Name[16];     // File member name - `/' terminated.\r
-  UINT8 Date[12];     // File member date - decimal.\r
-  UINT8 UserID[6];    // File member user id - decimal.\r
-  UINT8 GroupID[6];   // File member group id - decimal.\r
-  UINT8 Mode[8];      // File member mode - octal.\r
-  UINT8 Size[10];     // File member size - decimal.\r
-  UINT8 EndHeader[2]; // String to end header.\r
-} EFI_IMAGE_ARCHIVE_MEMBER_HEADER;\r
-\r
-#define EFI_IMAGE_SIZEOF_ARCHIVE_MEMBER_HDR 60\r
-\r
-//\r
-// DLL support.\r
-//\r
-\r
-///\r
-/// DLL Export Format\r
-///\r
-typedef struct {\r
-  UINT32  Characteristics;\r
-  UINT32  TimeDateStamp;\r
-  UINT16  MajorVersion;\r
-  UINT16  MinorVersion;\r
-  UINT32  Name;\r
-  UINT32  Base;\r
-  UINT32  NumberOfFunctions;\r
-  UINT32  NumberOfNames;\r
-  UINT32  AddressOfFunctions;\r
-  UINT32  AddressOfNames;\r
-  UINT32  AddressOfNameOrdinals;\r
-} EFI_IMAGE_EXPORT_DIRECTORY;\r
-\r
-///\r
-/// DLL support.\r
-/// Import Format\r
-///\r
-typedef struct {\r
-  UINT16  Hint;\r
-  UINT8   Name[1];\r
-} EFI_IMAGE_IMPORT_BY_NAME;\r
-\r
-typedef struct {\r
-  union {\r
-    UINT32                    Function;\r
-    UINT32                    Ordinal;\r
-    EFI_IMAGE_IMPORT_BY_NAME  *AddressOfData;\r
-  } u1;\r
-} EFI_IMAGE_THUNK_DATA;\r
-\r
-#define EFI_IMAGE_ORDINAL_FLAG              0x80000000\r
-#define EFI_IMAGE_SNAP_BY_ORDINAL(Ordinal)  ((Ordinal & EFI_IMAGE_ORDINAL_FLAG) != 0)\r
-#define EFI_IMAGE_ORDINAL(Ordinal)          (Ordinal & 0xffff)\r
-\r
-typedef struct {\r
-  UINT32                Characteristics;\r
-  UINT32                TimeDateStamp;\r
-  UINT32                ForwarderChain;\r
-  UINT32                Name;\r
-  EFI_IMAGE_THUNK_DATA  *FirstThunk;\r
-} EFI_IMAGE_IMPORT_DESCRIPTOR;\r
-\r
-///\r
-/// Debug Format\r
-///\r
-#define EFI_IMAGE_DEBUG_TYPE_CODEVIEW 2\r
-\r
-typedef struct {\r
-  UINT32  Characteristics;\r
-  UINT32  TimeDateStamp;\r
-  UINT16  MajorVersion;\r
-  UINT16  MinorVersion;\r
-  UINT32  Type;\r
-  UINT32  SizeOfData;\r
-  UINT32  RVA;\r
-  UINT32  FileOffset;\r
-} EFI_IMAGE_DEBUG_DIRECTORY_ENTRY;\r
-\r
-#define CODEVIEW_SIGNATURE_NB10 0x3031424E  // "NB10"\r
-typedef struct {\r
-  UINT32  Signature;                        // "NB10"\r
-  UINT32  Unknown;\r
-  UINT32  Unknown2;\r
-  UINT32  Unknown3;\r
-  //\r
-  // Filename of .PDB goes here\r
-  //\r
-} EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY;\r
-\r
-#define CODEVIEW_SIGNATURE_RSDS 0x53445352  // "RSDS"\r
-typedef struct {\r
-  UINT32  Signature;                        // "RSDS"\r
-  UINT32  Unknown;\r
-  UINT32  Unknown2;\r
-  UINT32  Unknown3;\r
-  UINT32  Unknown4;\r
-  UINT32  Unknown5;\r
-  //\r
-  // Filename of .PDB goes here\r
-  //\r
-} EFI_IMAGE_DEBUG_CODEVIEW_RSDS_ENTRY;\r
-\r
-//\r
-// .pdata entries for X64\r
-//\r
-typedef struct {\r
-  UINT32  FunctionStartAddress;\r
-  UINT32  FunctionEndAddress;\r
-  UINT32  UnwindInfoAddress;\r
-} RUNTIME_FUNCTION;\r
-\r
-typedef struct {\r
-  UINT8  Version:3;\r
-  UINT8  Flags:5;\r
-  UINT8  SizeOfProlog;\r
-  UINT8  CountOfUnwindCodes;\r
-  UINT8  FrameRegister:4;\r
-  UINT8  FrameRegisterOffset:4;\r
-} UNWIND_INFO;\r
-\r
-///\r
-/// Header format for TE images\r
-///\r
-typedef struct {\r
-  UINT16                    Signature;            // signature for TE format = "VZ"\r
-  UINT16                    Machine;              // from the original file header\r
-  UINT8                     NumberOfSections;     // from the original file header\r
-  UINT8                     Subsystem;            // from original optional header\r
-  UINT16                    StrippedSize;         // how many bytes we removed from the header\r
-  UINT32                    AddressOfEntryPoint;  // offset to entry point -- from original optional header\r
-  UINT32                    BaseOfCode;           // from original image -- required for ITP debug\r
-  UINT64                    ImageBase;            // from original file header\r
-  EFI_IMAGE_DATA_DIRECTORY  DataDirectory[2];     // only base relocation and debug directory\r
-} EFI_TE_IMAGE_HEADER;\r
-\r
-#define EFI_TE_IMAGE_HEADER_SIGNATURE 0x5A56      // "VZ"\r
-\r
-//\r
-// Data directory indexes in our TE image header\r
-//\r
-#define EFI_TE_IMAGE_DIRECTORY_ENTRY_BASERELOC  0\r
-#define EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG      1\r
-\r
-#endif\r
diff --git a/Tools/CodeTools/TianoTools/Include/Common/FirmwareFileSystem.h b/Tools/CodeTools/TianoTools/Include/Common/FirmwareFileSystem.h
deleted file mode 100644 (file)
index 5678a95..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-/** @file\r
-  This file defines the data structures that comprise the FFS file system.\r
-\r
-  Copyright (c) 2006, Intel Corporation                                                         \r
-  All rights reserved. This program and the accompanying materials                          \r
-  are licensed and made available under the terms and conditions of the BSD License         \r
-  which accompanies this distribution.  The full text of the license may be found at        \r
-  http://opensource.org/licenses/bsd-license.php                                            \r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-  Module Name:  FirmwareFileSystem.h\r
-\r
-  @par Revision Reference:\r
-  These definitions are from Firmware File System Spec 0.9.\r
-\r
-**/\r
-\r
-#ifndef __EFI_FFS_FILE_SYSTEM_H__\r
-#define __EFI_FFS_FILE_SYSTEM_H__\r
-\r
-///\r
-/// FFS specific file types\r
-///\r
-#define EFI_FV_FILETYPE_FFS_PAD 0xF0\r
-\r
-//\r
-// FFS File Attributes\r
-//\r
-#define FFS_ATTRIB_TAIL_PRESENT     0x01\r
-#define FFS_ATTRIB_RECOVERY         0x02\r
-#define FFS_ATTRIB_HEADER_EXTENSION 0x04\r
-#define FFS_ATTRIB_DATA_ALIGNMENT   0x38\r
-#define FFS_ATTRIB_CHECKSUM         0x40\r
-\r
-///\r
-/// FFS_FIXED_CHECKSUM is the default checksum value used when the\r
-/// FFS_ATTRIB_CHECKSUM attribute bit is clear\r
-/// note this is NOT an architecturally defined value, but is in this file for\r
-/// implementation convenience\r
-///\r
-#define FFS_FIXED_CHECKSUM  0x5A\r
-\r
-//\r
-// File state definitions\r
-//\r
-#define EFI_FILE_HEADER_CONSTRUCTION  0x01\r
-#define EFI_FILE_HEADER_VALID         0x02\r
-#define EFI_FILE_DATA_VALID           0x04\r
-#define EFI_FILE_MARKED_FOR_UPDATE    0x08\r
-#define EFI_FILE_DELETED              0x10\r
-#define EFI_FILE_HEADER_INVALID       0x20\r
-\r
-#define EFI_FILE_ALL_STATE_BITS       (EFI_FILE_HEADER_CONSTRUCTION | \\r
-                                 EFI_FILE_HEADER_VALID | \\r
-                                 EFI_FILE_DATA_VALID | \\r
-                                 EFI_FILE_MARKED_FOR_UPDATE | \\r
-                                 EFI_FILE_DELETED | \\r
-                                 EFI_FILE_HEADER_INVALID \\r
-          )\r
-\r
-#define EFI_TEST_FFS_ATTRIBUTES_BIT(FvbAttributes, TestAttributes, Bit) \\r
-    ( \\r
-      (BOOLEAN) ( \\r
-          (FvbAttributes & EFI_FVB_ERASE_POLARITY) ? (((~TestAttributes) & Bit) == Bit) : ((TestAttributes & Bit) == Bit) \\r
-        ) \\r
-    )\r
-\r
-typedef UINT16  EFI_FFS_FILE_TAIL;\r
-\r
-///\r
-/// FFS file integrity check structure\r
-///\r
-typedef union {\r
-  struct {\r
-    UINT8 Header;\r
-    UINT8 File;\r
-  } Checksum;\r
-  UINT16  TailReference;\r
-} EFI_FFS_INTEGRITY_CHECK;\r
-\r
-//\r
-// FFS file header definition\r
-//\r
-typedef UINT8 EFI_FFS_FILE_ATTRIBUTES;\r
-typedef UINT8 EFI_FFS_FILE_STATE;\r
-\r
-typedef struct {\r
-  EFI_GUID                Name;\r
-  EFI_FFS_INTEGRITY_CHECK IntegrityCheck;\r
-  EFI_FV_FILETYPE         Type;\r
-  EFI_FFS_FILE_ATTRIBUTES Attributes;\r
-  UINT8                   Size[3];\r
-  EFI_FFS_FILE_STATE      State;\r
-} EFI_FFS_FILE_HEADER;\r
-\r
-#endif\r
diff --git a/Tools/CodeTools/TianoTools/Include/Common/FirmwareVolumeHeader.h b/Tools/CodeTools/TianoTools/Include/Common/FirmwareVolumeHeader.h
deleted file mode 100644 (file)
index 038dce6..0000000
+++ /dev/null
@@ -1,109 +0,0 @@
-/** @file\r
-  Defines data structure that is the volume header found at the beginning of\r
-  all firmware volumes that are either memory mapped, or have an\r
-  associated FirmwareVolumeBlock protocol.\r
-\r
-  Copyright (c) 2006, Intel Corporation                                                         \r
-  All rights reserved. This program and the accompanying materials                          \r
-  are licensed and made available under the terms and conditions of the BSD License         \r
-  which accompanies this distribution.  The full text of the license may be found at        \r
-  http://opensource.org/licenses/bsd-license.php                                            \r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-  Module Name:  FirmwareVolumeHeader.h\r
-\r
-  @par Revision Reference:\r
-  These definitions are from Firmware Volume Block Spec 0.9.\r
-\r
-**/\r
-\r
-#ifndef __EFI_FIRMWARE_VOLUME_HEADER_H__\r
-#define __EFI_FIRMWARE_VOLUME_HEADER_H__\r
-\r
-//\r
-// Firmware Volume Block Attributes definition\r
-//\r
-typedef UINT32  EFI_FVB_ATTRIBUTES;\r
-\r
-//\r
-// Firmware Volume Block Attributes bit definitions\r
-//\r
-#define EFI_FVB_READ_DISABLED_CAP   0x00000001\r
-#define EFI_FVB_READ_ENABLED_CAP    0x00000002\r
-#define EFI_FVB_READ_STATUS         0x00000004\r
-\r
-#define EFI_FVB_WRITE_DISABLED_CAP  0x00000008\r
-#define EFI_FVB_WRITE_ENABLED_CAP   0x00000010\r
-#define EFI_FVB_WRITE_STATUS        0x00000020\r
-\r
-#define EFI_FVB_LOCK_CAP            0x00000040\r
-#define EFI_FVB_LOCK_STATUS         0x00000080\r
-\r
-#define EFI_FVB_STICKY_WRITE        0x00000200\r
-#define EFI_FVB_MEMORY_MAPPED       0x00000400\r
-#define EFI_FVB_ERASE_POLARITY      0x00000800\r
-\r
-#define EFI_FVB_ALIGNMENT_CAP       0x00008000\r
-#define EFI_FVB_ALIGNMENT_2         0x00010000\r
-#define EFI_FVB_ALIGNMENT_4         0x00020000\r
-#define EFI_FVB_ALIGNMENT_8         0x00040000\r
-#define EFI_FVB_ALIGNMENT_16        0x00080000\r
-#define EFI_FVB_ALIGNMENT_32        0x00100000\r
-#define EFI_FVB_ALIGNMENT_64        0x00200000\r
-#define EFI_FVB_ALIGNMENT_128       0x00400000\r
-#define EFI_FVB_ALIGNMENT_256       0x00800000\r
-#define EFI_FVB_ALIGNMENT_512       0x01000000\r
-#define EFI_FVB_ALIGNMENT_1K        0x02000000\r
-#define EFI_FVB_ALIGNMENT_2K        0x04000000\r
-#define EFI_FVB_ALIGNMENT_4K        0x08000000\r
-#define EFI_FVB_ALIGNMENT_8K        0x10000000\r
-#define EFI_FVB_ALIGNMENT_16K       0x20000000\r
-#define EFI_FVB_ALIGNMENT_32K       0x40000000\r
-#define EFI_FVB_ALIGNMENT_64K       0x80000000\r
-\r
-#define EFI_FVB_CAPABILITIES  (EFI_FVB_READ_DISABLED_CAP | \\r
-                              EFI_FVB_READ_ENABLED_CAP | \\r
-                              EFI_FVB_WRITE_DISABLED_CAP | \\r
-                              EFI_FVB_WRITE_ENABLED_CAP | \\r
-                              EFI_FVB_LOCK_CAP \\r
-                              )\r
-\r
-#define EFI_FVB_STATUS    (EFI_FVB_READ_STATUS | EFI_FVB_WRITE_STATUS | EFI_FVB_LOCK_STATUS)\r
-\r
-///\r
-/// Firmware Volume Header Revision definition\r
-///\r
-#define EFI_FVH_REVISION  0x01\r
-\r
-///\r
-/// Firmware Volume Header Signature definition\r
-///\r
-#define EFI_FVH_SIGNATURE EFI_SIGNATURE_32 ('_', 'F', 'V', 'H')\r
-\r
-///\r
-/// Firmware Volume Header Block Map Entry definition\r
-///\r
-typedef struct {\r
-  UINT32  NumBlocks;\r
-  UINT32  BlockLength;\r
-} EFI_FV_BLOCK_MAP_ENTRY;\r
-\r
-///\r
-/// Firmware Volume Header definition\r
-///\r
-typedef struct {\r
-  UINT8                   ZeroVector[16];\r
-  EFI_GUID                FileSystemGuid;\r
-  UINT64                  FvLength;\r
-  UINT32                  Signature;\r
-  EFI_FVB_ATTRIBUTES      Attributes;\r
-  UINT16                  HeaderLength;\r
-  UINT16                  Checksum;\r
-  UINT8                   Reserved[3];\r
-  UINT8                   Revision;\r
-  EFI_FV_BLOCK_MAP_ENTRY  FvBlockMap[1];\r
-} EFI_FIRMWARE_VOLUME_HEADER;\r
-\r
-#endif\r
diff --git a/Tools/CodeTools/TianoTools/Include/Common/FirmwareVolumeImageFormat.h b/Tools/CodeTools/TianoTools/Include/Common/FirmwareVolumeImageFormat.h
deleted file mode 100644 (file)
index 14fa41b..0000000
+++ /dev/null
@@ -1,277 +0,0 @@
-/** @file\r
-  This file defines the data structures that are architecturally defined for file\r
-  images loaded via the FirmwareVolume protocol.  The Firmware Volume specification\r
-  is the basis for these definitions.\r
-\r
-  Copyright (c) 2006, Intel Corporation                                                         \r
-  All rights reserved. This program and the accompanying materials                          \r
-  are licensed and made available under the terms and conditions of the BSD License         \r
-  which accompanies this distribution.  The full text of the license may be found at        \r
-  http://opensource.org/licenses/bsd-license.php                                            \r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-  Module Name:  FimrwareVolumeImageFormat.h\r
-\r
-  @par Revision Reference:\r
-  These definitions are from Firmware Volume Spec 0.9.\r
-\r
-**/\r
-\r
-#ifndef __FIRMWARE_VOLUME_IMAGE_FORMAT_H__\r
-#define __FIRMWARE_VOLUME_IMAGE_FORMAT_H__\r
-\r
-//\r
-// pack all data structures since this is actually a binary format and we cannot\r
-// allow internal padding in the data structures because of some compilerism..\r
-//\r
-#pragma pack(1)\r
-//\r
-// ////////////////////////////////////////////////////////////////////////////\r
-//\r
-// Architectural file types\r
-//\r
-typedef UINT8 EFI_FV_FILETYPE;\r
-\r
-#define EFI_FV_FILETYPE_ALL                   0x00\r
-#define EFI_FV_FILETYPE_RAW                   0x01\r
-#define EFI_FV_FILETYPE_FREEFORM              0x02\r
-#define EFI_FV_FILETYPE_SECURITY_CORE         0x03\r
-#define EFI_FV_FILETYPE_PEI_CORE              0x04\r
-#define EFI_FV_FILETYPE_DXE_CORE              0x05\r
-#define EFI_FV_FILETYPE_PEIM                  0x06\r
-#define EFI_FV_FILETYPE_DRIVER                0x07\r
-#define EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER  0x08\r
-#define EFI_FV_FILETYPE_APPLICATION           0x09\r
-//\r
-// File type 0x0A is reserved and should not be used\r
-//\r
-#define EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE 0x0B\r
-\r
-//\r
-// ////////////////////////////////////////////////////////////////////////////\r
-//\r
-// Section types\r
-//\r
-typedef UINT8 EFI_SECTION_TYPE;\r
-\r
-//\r
-// ************************************************************\r
-// The section type EFI_SECTION_ALL is a psuedo type.  It is\r
-// used as a wildcard when retrieving sections.  The section\r
-// type EFI_SECTION_ALL matches all section types.\r
-// ************************************************************\r
-//\r
-#define EFI_SECTION_ALL 0x00\r
-\r
-//\r
-// ************************************************************\r
-// Encapsulation section Type values\r
-// ************************************************************\r
-//\r
-#define EFI_SECTION_COMPRESSION   0x01\r
-#define EFI_SECTION_GUID_DEFINED  0x02\r
-\r
-//\r
-// ************************************************************\r
-// Leaf section Type values\r
-// ************************************************************\r
-//\r
-#define EFI_SECTION_FIRST_LEAF_SECTION_TYPE 0x10\r
-\r
-#define EFI_SECTION_PE32                    0x10\r
-#define EFI_SECTION_PIC                     0x11\r
-#define EFI_SECTION_TE                      0x12\r
-#define EFI_SECTION_DXE_DEPEX               0x13\r
-#define EFI_SECTION_VERSION                 0x14\r
-#define EFI_SECTION_USER_INTERFACE          0x15\r
-#define EFI_SECTION_COMPATIBILITY16         0x16\r
-#define EFI_SECTION_FIRMWARE_VOLUME_IMAGE   0x17\r
-#define EFI_SECTION_FREEFORM_SUBTYPE_GUID   0x18\r
-#define EFI_SECTION_RAW                     0x19\r
-#define EFI_SECTION_PEI_DEPEX               0x1B\r
-\r
-#define EFI_SECTION_LAST_LEAF_SECTION_TYPE  0x1B\r
-#define EFI_SECTION_LAST_SECTION_TYPE       0x1B\r
-\r
-//\r
-// ////////////////////////////////////////////////////////////////////////////\r
-//\r
-// Common section header\r
-//\r
-typedef struct {\r
-  UINT8 Size[3];\r
-  UINT8 Type;\r
-} EFI_COMMON_SECTION_HEADER;\r
-\r
-#define SECTION_SIZE(SectionHeaderPtr) \\r
-    ((UINT32) (*((UINT32 *) ((EFI_COMMON_SECTION_HEADER *) SectionHeaderPtr)->Size) & 0x00ffffff))\r
-\r
-//\r
-// ////////////////////////////////////////////////////////////////////////////\r
-//\r
-// Compression section\r
-//\r
-//\r
-// CompressionType values\r
-//\r
-#define EFI_NOT_COMPRESSED          0x00\r
-#define EFI_STANDARD_COMPRESSION    0x01\r
-#define EFI_CUSTOMIZED_COMPRESSION  0x02\r
-\r
-typedef struct {\r
-  EFI_COMMON_SECTION_HEADER CommonHeader;\r
-  UINT32                    UncompressedLength;\r
-  UINT8                     CompressionType;\r
-} EFI_COMPRESSION_SECTION;\r
-\r
-//\r
-// ////////////////////////////////////////////////////////////////////////////\r
-//\r
-// GUID defined section\r
-//\r
-typedef struct {\r
-  EFI_COMMON_SECTION_HEADER CommonHeader;\r
-  EFI_GUID                  SectionDefinitionGuid;\r
-  UINT16                    DataOffset;\r
-  UINT16                    Attributes;\r
-} EFI_GUID_DEFINED_SECTION;\r
-\r
-//\r
-// Bit values for Attributes\r
-//\r
-#define EFI_GUIDED_SECTION_PROCESSING_REQUIRED  0x01\r
-#define EFI_GUIDED_SECTION_AUTH_STATUS_VALID    0x02\r
-\r
-//\r
-// Bit values for AuthenticationStatus\r
-//\r
-#define EFI_AGGREGATE_AUTH_STATUS_PLATFORM_OVERRIDE 0x000001\r
-#define EFI_AGGREGATE_AUTH_STATUS_IMAGE_SIGNED      0x000002\r
-#define EFI_AGGREGATE_AUTH_STATUS_NOT_TESTED        0x000004\r
-#define EFI_AGGREGATE_AUTH_STATUS_TEST_FAILED       0x000008\r
-#define EFI_AGGREGATE_AUTH_STATUS_ALL               0x00000f\r
-\r
-#define EFI_LOCAL_AUTH_STATUS_PLATFORM_OVERRIDE     0x010000\r
-#define EFI_LOCAL_AUTH_STATUS_IMAGE_SIGNED          0x020000\r
-#define EFI_LOCAL_AUTH_STATUS_NOT_TESTED            0x040000\r
-#define EFI_LOCAL_AUTH_STATUS_TEST_FAILED           0x080000\r
-#define EFI_LOCAL_AUTH_STATUS_ALL                   0x0f0000\r
-\r
-//\r
-// ////////////////////////////////////////////////////////////////////////////\r
-//\r
-// PE32+ section\r
-//\r
-typedef struct {\r
-  EFI_COMMON_SECTION_HEADER CommonHeader;\r
-} EFI_PE32_SECTION;\r
-\r
-//\r
-// ////////////////////////////////////////////////////////////////////////////\r
-//\r
-// PIC section\r
-//\r
-typedef struct {\r
-  EFI_COMMON_SECTION_HEADER CommonHeader;\r
-} EFI_PIC_SECTION;\r
-\r
-//\r
-// ////////////////////////////////////////////////////////////////////////////\r
-//\r
-// PEIM header section\r
-//\r
-typedef struct {\r
-  EFI_COMMON_SECTION_HEADER CommonHeader;\r
-} EFI_PEIM_HEADER_SECTION;\r
-\r
-//\r
-// ////////////////////////////////////////////////////////////////////////////\r
-//\r
-// DEPEX section\r
-//\r
-typedef struct {\r
-  EFI_COMMON_SECTION_HEADER CommonHeader;\r
-} EFI_DEPEX_SECTION;\r
-\r
-//\r
-// ////////////////////////////////////////////////////////////////////////////\r
-//\r
-// Version section\r
-//\r
-typedef struct {\r
-  EFI_COMMON_SECTION_HEADER CommonHeader;\r
-  UINT16                    BuildNumber;\r
-  INT16                     VersionString[1];\r
-} EFI_VERSION_SECTION;\r
-\r
-//\r
-// ////////////////////////////////////////////////////////////////////////////\r
-//\r
-// User interface section\r
-//\r
-typedef struct {\r
-  EFI_COMMON_SECTION_HEADER CommonHeader;\r
-  INT16                     FileNameString[1];\r
-} EFI_USER_INTERFACE_SECTION;\r
-\r
-//\r
-// ////////////////////////////////////////////////////////////////////////////\r
-//\r
-// Code16 section\r
-//\r
-typedef struct {\r
-  EFI_COMMON_SECTION_HEADER CommonHeader;\r
-} EFI_CODE16_SECTION;\r
-\r
-//\r
-// ////////////////////////////////////////////////////////////////////////////\r
-//\r
-// Firmware Volume Image section\r
-//\r
-typedef struct {\r
-  EFI_COMMON_SECTION_HEADER CommonHeader;\r
-} EFI_FIRMWARE_VOLUME_IMAGE_SECTION;\r
-\r
-//\r
-// ////////////////////////////////////////////////////////////////////////////\r
-//\r
-// Freeform subtype GUID section\r
-//\r
-typedef struct {\r
-  EFI_COMMON_SECTION_HEADER CommonHeader;\r
-  EFI_GUID                  SubTypeGuid;\r
-} EFI_FREEFORM_SUBTYPE_GUID_SECTION;\r
-\r
-//\r
-// ////////////////////////////////////////////////////////////////////////////\r
-//\r
-// Raw section\r
-//\r
-typedef struct {\r
-  EFI_COMMON_SECTION_HEADER CommonHeader;\r
-} EFI_RAW_SECTION;\r
-\r
-//\r
-// undo the pragma from the beginning...\r
-//\r
-#pragma pack()\r
-\r
-typedef union {\r
-  EFI_COMMON_SECTION_HEADER         *CommonHeader;\r
-  EFI_COMPRESSION_SECTION           *CompressionSection;\r
-  EFI_GUID_DEFINED_SECTION          *GuidDefinedSection;\r
-  EFI_PE32_SECTION                  *Pe32Section;\r
-  EFI_PIC_SECTION                   *PicSection;\r
-  EFI_PEIM_HEADER_SECTION           *PeimHeaderSection;\r
-  EFI_DEPEX_SECTION                 *DependencySection;\r
-  EFI_VERSION_SECTION               *VersionSection;\r
-  EFI_USER_INTERFACE_SECTION        *UISection;\r
-  EFI_CODE16_SECTION                *Code16Section;\r
-  EFI_FIRMWARE_VOLUME_IMAGE_SECTION *FVImageSection;\r
-  EFI_FREEFORM_SUBTYPE_GUID_SECTION *FreeformSubtypeSection;\r
-  EFI_RAW_SECTION                   *RawSection;\r
-} EFI_FILE_SECTION_POINTER;\r
-\r
-#endif\r
diff --git a/Tools/CodeTools/TianoTools/Include/Common/InternalFormRepresentation.h b/Tools/CodeTools/TianoTools/Include/Common/InternalFormRepresentation.h
deleted file mode 100644 (file)
index bf3d824..0000000
+++ /dev/null
@@ -1,422 +0,0 @@
-/** @file\r
-  This file defines the encoding for the VFR (Visual Form Representation) language.\r
-  IFR is primarily consumed by the EFI presentation engine, and produced by EFI\r
-  internal application and drivers as well as all add-in card option-ROM drivers\r
-\r
-  Copyright (c) 2006, Intel Corporation                                                         \r
-  All rights reserved. This program and the accompanying materials                          \r
-  are licensed and made available under the terms and conditions of the BSD License         \r
-  which accompanies this distribution.  The full text of the license may be found at        \r
-  http://opensource.org/licenses/bsd-license.php                                            \r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-  Module Name:  InternalFormRepresentation.h\r
-\r
-  @par Revision Reference:\r
-  These definitions are from Human Interface Infrastructure Spec Version 0.92.\r
-\r
-**/\r
-\r
-#ifndef __EFI_INTERNAL_FORM_REPRESENTATION_H__\r
-#define __EFI_INTERNAL_FORM_REPRESENTATION_H__\r
-\r
-//\r
-// The following types are currently defined:\r
-//\r
-typedef UINT32  RELOFST;\r
-typedef CHAR16  *EFI_STRING;\r
-\r
-//\r
-// IFR Op codes\r
-//\r
-#define EFI_IFR_FORM_OP                 0x01\r
-#define EFI_IFR_SUBTITLE_OP             0x02\r
-#define EFI_IFR_TEXT_OP                 0x03\r
-#define EFI_IFR_GRAPHIC_OP              0x04\r
-#define EFI_IFR_ONE_OF_OP               0x05\r
-#define EFI_IFR_CHECKBOX_OP             0x06\r
-#define EFI_IFR_NUMERIC_OP              0x07\r
-#define EFI_IFR_PASSWORD_OP             0x08\r
-#define EFI_IFR_ONE_OF_OPTION_OP        0x09  // ONEOF OPTION field\r
-#define EFI_IFR_SUPPRESS_IF_OP          0x0A\r
-#define EFI_IFR_END_FORM_OP             0x0B\r
-#define EFI_IFR_HIDDEN_OP               0x0C\r
-#define EFI_IFR_END_FORM_SET_OP         0x0D\r
-#define EFI_IFR_FORM_SET_OP             0x0E\r
-#define EFI_IFR_REF_OP                  0x0F\r
-#define EFI_IFR_END_ONE_OF_OP           0x10\r
-#define EFI_IFR_END_OP                  EFI_IFR_END_ONE_OF_OP\r
-#define EFI_IFR_INCONSISTENT_IF_OP      0x11\r
-#define EFI_IFR_EQ_ID_VAL_OP            0x12\r
-#define EFI_IFR_EQ_ID_ID_OP             0x13\r
-#define EFI_IFR_EQ_ID_LIST_OP           0x14\r
-#define EFI_IFR_AND_OP                  0x15\r
-#define EFI_IFR_OR_OP                   0x16\r
-#define EFI_IFR_NOT_OP                  0x17\r
-#define EFI_IFR_END_IF_OP               0x18  // for endif of inconsistentif, suppressif, grayoutif\r
-#define EFI_IFR_GRAYOUT_IF_OP           0x19\r
-#define EFI_IFR_DATE_OP                 0x1A\r
-#define EFI_IFR_TIME_OP                 0x1B\r
-#define EFI_IFR_STRING_OP               0x1C\r
-#define EFI_IFR_LABEL_OP                0x1D\r
-#define EFI_IFR_SAVE_DEFAULTS_OP        0x1E\r
-#define EFI_IFR_RESTORE_DEFAULTS_OP     0x1F\r
-#define EFI_IFR_BANNER_OP               0x20\r
-#define EFI_IFR_INVENTORY_OP            0x21\r
-#define EFI_IFR_EQ_VAR_VAL_OP           0x22\r
-#define EFI_IFR_ORDERED_LIST_OP         0x23\r
-#define EFI_IFR_VARSTORE_OP             0x24\r
-#define EFI_IFR_VARSTORE_SELECT_OP      0x25\r
-#define EFI_IFR_VARSTORE_SELECT_PAIR_OP 0x26\r
-#define EFI_IFR_TRUE_OP                 0x27\r
-#define EFI_IFR_FALSE_OP                0x28\r
-#define EFI_IFR_GT_OP                   0x29\r
-#define EFI_IFR_GE_OP                   0x2A\r
-#define EFI_IFR_OEM_DEFINED_OP          0x2B\r
-#define EFI_IFR_LAST_OPCODE             EFI_IFR_OEM_DEFINED_OP\r
-#define EFI_IFR_OEM_OP                  0xFE\r
-#define EFI_IFR_NV_ACCESS_COMMAND       0xFF\r
-\r
-//\r
-// Define values for the flags fields in some VFR opcodes. These are\r
-// bitmasks.\r
-//\r
-#define EFI_IFR_FLAG_DEFAULT              0x01\r
-#define EFI_IFR_FLAG_MANUFACTURING        0x02\r
-#define EFI_IFR_FLAG_INTERACTIVE          0x04\r
-#define EFI_IFR_FLAG_NV_ACCESS            0x08\r
-#define EFI_IFR_FLAG_RESET_REQUIRED       0x10\r
-#define EFI_IFR_FLAG_LATE_CHECK           0x20\r
-\r
-#define EFI_NON_DEVICE_CLASS              0x00  // Useful when you do not want something in the Device Manager\r
-#define EFI_DISK_DEVICE_CLASS             0x01\r
-#define EFI_VIDEO_DEVICE_CLASS            0x02\r
-#define EFI_NETWORK_DEVICE_CLASS          0x04\r
-#define EFI_INPUT_DEVICE_CLASS            0x08\r
-#define EFI_ON_BOARD_DEVICE_CLASS         0x10\r
-#define EFI_OTHER_DEVICE_CLASS            0x20\r
-\r
-#define EFI_SETUP_APPLICATION_SUBCLASS    0x00\r
-#define EFI_GENERAL_APPLICATION_SUBCLASS  0x01\r
-#define EFI_FRONT_PAGE_SUBCLASS           0x02\r
-#define EFI_SINGLE_USE_SUBCLASS           0x03  // Used to display a single entity and then exit\r
-\r
-//\r
-// Used to flag dynamically created op-codes. This is meaningful to the IFR Library set\r
-// and the browser since we need to distinguish between compiled NV map data and created data.\r
-// We do not allow new entries to be created in the NV map dynamically however we still need\r
-// to display this information correctly.  To dynamically create op-codes and assume that their\r
-// data will be saved, ensure that the NV starting location they refer to is pre-defined in the\r
-// NV map.\r
-//\r
-#define EFI_IFR_FLAG_CREATED  128\r
-\r
-#pragma pack(1)\r
-//\r
-// IFR Structure definitions\r
-//\r
-typedef struct {\r
-  UINT8 OpCode;\r
-  UINT8 Length;\r
-} EFI_IFR_OP_HEADER;\r
-\r
-typedef struct {\r
-  EFI_IFR_OP_HEADER     Header;\r
-  EFI_GUID              Guid;\r
-  STRING_REF            FormSetTitle;\r
-  STRING_REF            Help;\r
-  EFI_PHYSICAL_ADDRESS  CallbackHandle;\r
-  UINT16                Class;\r
-  UINT16                SubClass;\r
-  UINT16                NvDataSize; // set once, size of the NV data as defined in the script\r
-} EFI_IFR_FORM_SET;\r
-\r
-typedef struct {\r
-  EFI_IFR_OP_HEADER Header;\r
-  UINT16            FormId;\r
-  STRING_REF        FormTitle;\r
-} EFI_IFR_FORM;\r
-\r
-typedef struct {\r
-  EFI_IFR_OP_HEADER Header;\r
-  UINT16            LabelId;\r
-} EFI_IFR_LABEL;\r
-\r
-typedef struct {\r
-  EFI_IFR_OP_HEADER Header;\r
-  STRING_REF        SubTitle;\r
-} EFI_IFR_SUBTITLE;\r
-\r
-typedef struct {\r
-  EFI_IFR_OP_HEADER Header;\r
-  STRING_REF        Help;\r
-  STRING_REF        Text;\r
-  STRING_REF        TextTwo;\r
-  UINT8             Flags;          // This is included solely for purposes of interactive/dynamic support.\r
-  UINT16            Key;            // Value to be passed to caller to identify this particular op-code\r
-} EFI_IFR_TEXT;\r
-\r
-//\r
-// goto\r
-//\r
-typedef struct {\r
-  EFI_IFR_OP_HEADER Header;\r
-  UINT16            FormId;\r
-  STRING_REF        Prompt;\r
-  STRING_REF        Help;   // The string Token for the context-help\r
-  UINT8             Flags;  // This is included solely for purposes of interactive/dynamic support.\r
-  UINT16            Key;    // Value to be passed to caller to identify this particular op-code\r
-} EFI_IFR_REF;\r
-\r
-typedef struct {\r
-  EFI_IFR_OP_HEADER Header;\r
-} EFI_IFR_END_FORM;\r
-\r
-typedef struct {\r
-  EFI_IFR_OP_HEADER Header;\r
-} EFI_IFR_END_FORM_SET;\r
-\r
-//\r
-// Also notice that the IFR_ONE_OF and IFR_CHECK_BOX are identical in structure......code assumes this to be true, if this ever\r
-// changes we need to revisit the InitializeTagStructures code\r
-//\r
-typedef struct {\r
-  EFI_IFR_OP_HEADER Header;\r
-  UINT16            QuestionId; // The ID designating what the question is about...sucked in from a #define, likely in the form of a variable name\r
-  UINT8             Width;      // The Size of the Data being saved\r
-  STRING_REF        Prompt;     // The String Token for the Prompt\r
-  STRING_REF        Help;       // The string Token for the context-help\r
-} EFI_IFR_ONE_OF;\r
-\r
-typedef struct {\r
-  EFI_IFR_OP_HEADER Header;\r
-  UINT16            QuestionId; // The offset in NV for storage of the data\r
-  UINT8             MaxEntries; // The maximum number of options in the ordered list (=size of NVStore)\r
-  STRING_REF        Prompt;     // The string token for the prompt\r
-  STRING_REF        Help;       // The string token for the context-help\r
-} EFI_IFR_ORDERED_LIST;\r
-\r
-typedef struct {\r
-  EFI_IFR_OP_HEADER Header;\r
-  UINT16            QuestionId; // The ID designating what the question is about...sucked in from a #define, likely in the form of a variable name\r
-  UINT8             Width;      // The Size of the Data being saved\r
-  STRING_REF        Prompt;     // The String Token for the Prompt\r
-  STRING_REF        Help;       // The string Token for the context-help\r
-  UINT8             Flags;      // For now, if non-zero, means that it is the default option, - further definition likely\r
-  UINT16            Key;        // Value to be passed to caller to identify this particular op-code\r
-} EFI_IFR_CHECKBOX, EFI_IFR_CHECK_BOX;\r
-\r
-typedef struct {\r
-  EFI_IFR_OP_HEADER Header;\r
-  STRING_REF        Option;     // The string token describing the option\r
-  UINT16            Value;      // The value associated with this option that is stored in the NVRAM if chosen\r
-  UINT8             Flags;      // For now, if non-zero, means that it is the default option, - further definition likely above\r
-  UINT16            Key;        // Value to be passed to caller to identify this particular op-code\r
-} EFI_IFR_ONE_OF_OPTION;\r
-\r
-typedef struct {\r
-  EFI_IFR_OP_HEADER Header;\r
-  UINT16            QuestionId; // The ID designating what the question is about...sucked in from a #define, likely in the form of a variable name\r
-  UINT8             Width;      // The Size of the Data being saved\r
-  STRING_REF        Prompt;     // The String Token for the Prompt\r
-  STRING_REF        Help;       // The string Token for the context-help\r
-  UINT8             Flags;      // This is included solely for purposes of interactive/dynamic support.\r
-  UINT16            Key;        // Value to be passed to caller to identify this particular op-code\r
-  UINT16            Minimum;\r
-  UINT16            Maximum;\r
-  UINT16            Step;       // If step is 0, then manual input is specified, otherwise, left/right arrow selection is called for\r
-  UINT16            Default;\r
-} EFI_IFR_NUMERIC;\r
-\r
-//\r
-// There is an interesting twist with regards to Time and Date.  This is one of the few items which can accept input from\r
-// a user, however may or may not need to use storage in the NVRAM space.  The decided method for determining if NVRAM space\r
-// will be used (only for a TimeOp or DateOp) is:  If .QuestionId == 0 && .Width == 0 (normally an impossibility) then use system\r
-// resources to store the data away and not NV resources.  In other words, the setup engine will call gRT->SetTime, and gRT->SetDate\r
-// for the saving of data, and the values displayed will be from the gRT->GetXXXX series of calls.\r
-//\r
-typedef struct {\r
-  EFI_IFR_NUMERIC Hour;\r
-  EFI_IFR_NUMERIC Minute;\r
-  EFI_IFR_NUMERIC Second;\r
-} EFI_IFR_TIME;\r
-\r
-typedef struct {\r
-  EFI_IFR_NUMERIC Year;\r
-  EFI_IFR_NUMERIC Month;\r
-  EFI_IFR_NUMERIC Day;\r
-} EFI_IFR_DATE;\r
-\r
-typedef struct {\r
-  EFI_IFR_OP_HEADER Header;\r
-  UINT16            QuestionId;   // The ID designating what the question is about...sucked in from a #define, likely in the form of a variable name\r
-  UINT8             Width;        // The Size of the Data being saved -- BUGBUG -- remove someday\r
-  STRING_REF        Prompt;       // The String Token for the Prompt\r
-  STRING_REF        Help;         // The string Token for the context-help\r
-  UINT8             Flags;        // This is included solely for purposes of interactive/dynamic support.\r
-  UINT16            Key;          // Value to be passed to caller to identify this particular op-code\r
-  UINT8             MinSize;      // Minimum allowable sized password\r
-  UINT8             MaxSize;      // Maximum allowable sized password\r
-  UINT16            Encoding;\r
-} EFI_IFR_PASSWORD;\r
-\r
-typedef struct {\r
-  EFI_IFR_OP_HEADER Header;\r
-  UINT16            QuestionId;   // The ID designating what the question is about...sucked in from a #define, likely in the form of a variable name\r
-  UINT8             Width;        // The Size of the Data being saved -- BUGBUG -- remove someday\r
-  STRING_REF        Prompt;       // The String Token for the Prompt\r
-  STRING_REF        Help;         // The string Token for the context-help\r
-  UINT8             Flags;        // This is included solely for purposes of interactive/dynamic support.\r
-  UINT16            Key;          // Value to be passed to caller to identify this particular op-code\r
-  UINT8             MinSize;      // Minimum allowable sized password\r
-  UINT8             MaxSize;      // Maximum allowable sized password\r
-} EFI_IFR_STRING;\r
-\r
-typedef struct {\r
-  EFI_IFR_OP_HEADER Header;\r
-} EFI_IFR_END_ONE_OF;\r
-\r
-typedef struct {\r
-  EFI_IFR_OP_HEADER Header;\r
-  UINT16            Value;\r
-  UINT16            Key;\r
-} EFI_IFR_HIDDEN;\r
-\r
-typedef struct {\r
-  EFI_IFR_OP_HEADER Header;\r
-  UINT8             Flags;\r
-} EFI_IFR_SUPPRESS;\r
-\r
-typedef struct {\r
-  EFI_IFR_OP_HEADER Header;\r
-  UINT8             Flags;\r
-} EFI_IFR_GRAY_OUT;\r
-\r
-typedef struct {\r
-  EFI_IFR_OP_HEADER Header;\r
-  STRING_REF        Popup;\r
-  UINT8             Flags;\r
-} EFI_IFR_INCONSISTENT;\r
-\r
-typedef struct {\r
-  EFI_IFR_OP_HEADER Header;\r
-  UINT16            QuestionId;   // offset into variable storage\r
-  UINT8             Width;        // size of variable storage\r
-  UINT16            Value;        // value to compare against\r
-} EFI_IFR_EQ_ID_VAL;\r
-\r
-typedef struct {\r
-  EFI_IFR_OP_HEADER Header;\r
-  UINT16            QuestionId;   // offset into variable storage\r
-  UINT8             Width;        // size of variable storage\r
-  UINT16            ListLength;\r
-  UINT16            ValueList[1];\r
-} EFI_IFR_EQ_ID_LIST;\r
-\r
-typedef struct {\r
-  EFI_IFR_OP_HEADER Header;\r
-  UINT16            QuestionId1;  // offset into variable storage for first value to compare\r
-  UINT8             Width;        // size of variable storage (must be same for both)\r
-  UINT16            QuestionId2;  // offset into variable storage for second value to compare\r
-} EFI_IFR_EQ_ID_ID;\r
-\r
-typedef struct {\r
-  EFI_IFR_OP_HEADER Header;\r
-  UINT16            VariableId;   // offset into variable storage\r
-  UINT16            Value;        // value to compare against\r
-} EFI_IFR_EQ_VAR_VAL;\r
-\r
-typedef struct {\r
-  EFI_IFR_OP_HEADER Header;\r
-} EFI_IFR_AND;\r
-\r
-typedef struct {\r
-  EFI_IFR_OP_HEADER Header;\r
-} EFI_IFR_OR;\r
-\r
-typedef struct {\r
-  EFI_IFR_OP_HEADER Header;\r
-} EFI_IFR_NOT;\r
-\r
-typedef struct {\r
-  EFI_IFR_OP_HEADER Header;\r
-} EFI_IFR_END_EXPR, EFI_IFR_END_IF;\r
-\r
-typedef struct {\r
-  EFI_IFR_OP_HEADER Header;\r
-  UINT16            FormId;\r
-  STRING_REF        Prompt;\r
-  STRING_REF        Help;\r
-  UINT8             Flags;\r
-  UINT16            Key;\r
-} EFI_IFR_SAVE_DEFAULTS;\r
-\r
-typedef struct {\r
-  EFI_IFR_OP_HEADER Header;\r
-  STRING_REF        Help;\r
-  STRING_REF        Text;\r
-  STRING_REF        TextTwo;      // optional text\r
-} EFI_IFR_INVENTORY;\r
-\r
-typedef struct {\r
-  EFI_IFR_OP_HEADER Header;\r
-  EFI_GUID          Guid;         // GUID for the variable\r
-  UINT16            VarId;        // variable store ID, as referenced elsewhere in the form\r
-  UINT16            Size;         // size of the variable storage\r
-} EFI_IFR_VARSTORE;\r
-\r
-typedef struct {\r
-  EFI_IFR_OP_HEADER Header;\r
-  UINT16            VarId;        // variable store ID, as referenced elsewhere in the form\r
-} EFI_IFR_VARSTORE_SELECT;\r
-\r
-//\r
-// Used for the ideqid VFR statement where two variable stores may be referenced in the\r
-// same VFR statement.\r
-// A browser should treat this as an EFI_IFR_VARSTORE_SELECT statement and assume that all following\r
-// IFR opcodes use the VarId as defined here.\r
-//\r
-typedef struct {\r
-  EFI_IFR_OP_HEADER Header;\r
-  UINT16            VarId;          // variable store ID, as referenced elsewhere in the form\r
-  UINT16            SecondaryVarId; // variable store ID, as referenced elsewhere in the form\r
-} EFI_IFR_VARSTORE_SELECT_PAIR;\r
-\r
-typedef struct {\r
-  EFI_IFR_OP_HEADER Header;\r
-} EFI_IFR_TRUE;\r
-\r
-typedef struct {\r
-  EFI_IFR_OP_HEADER Header;\r
-} EFI_IFR_FALSE;\r
-\r
-typedef struct {\r
-  EFI_IFR_OP_HEADER Header;\r
-} EFI_IFR_GT;\r
-\r
-typedef struct {\r
-  EFI_IFR_OP_HEADER Header;\r
-} EFI_IFR_GE;\r
-\r
-//\r
-// Save defaults and restore defaults have same structure\r
-//\r
-#define EFI_IFR_RESTORE_DEFAULTS  EFI_IFR_SAVE_DEFAULTS\r
-\r
-typedef struct {\r
-  EFI_IFR_OP_HEADER Header;\r
-  STRING_REF        Title;        // The string token for the banner title\r
-  UINT16            LineNumber;   // 1-based line number\r
-  UINT8             Alignment;    // left, center, or right-aligned\r
-} EFI_IFR_BANNER;\r
-\r
-#define EFI_IFR_BANNER_ALIGN_LEFT   0\r
-#define EFI_IFR_BANNER_ALIGN_CENTER 1\r
-#define EFI_IFR_BANNER_ALIGN_RIGHT  2\r
-#define EFI_IFR_BANNER_TIMEOUT      0xFF\r
-\r
-#pragma pack()\r
-\r
-#endif\r
diff --git a/Tools/CodeTools/TianoTools/Include/Common/MultiPhase.h b/Tools/CodeTools/TianoTools/Include/Common/MultiPhase.h
deleted file mode 100644 (file)
index 93867a5..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-/** @file\r
-  This includes some definitions that will be used in both PEI and DXE phases.\r
-\r
-  Copyright (c) 2006, Intel Corporation                                                         \r
-  All rights reserved. This program and the accompanying materials                          \r
-  are licensed and made available under the terms and conditions of the BSD License         \r
-  which accompanies this distribution.  The full text of the license may be found at        \r
-  http://opensource.org/licenses/bsd-license.php                                            \r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-  Module Name:  MultiPhase.h\r
-\r
-**/\r
-\r
-#ifndef __MULTI_PHASE_H__\r
-#define __MULTI_PHASE_H__\r
-\r
-//\r
-//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\r
-//\r
-// Needed EFI defines for PEI\r
-//\r
-typedef UINT64  EFI_PHYSICAL_ADDRESS;\r
-\r
-typedef enum {\r
-  EfiReservedMemoryType,\r
-  EfiLoaderCode,\r
-  EfiLoaderData,\r
-  EfiBootServicesCode,\r
-  EfiBootServicesData,\r
-  EfiRuntimeServicesCode,\r
-  EfiRuntimeServicesData,\r
-  EfiConventionalMemory,\r
-  EfiUnusableMemory,\r
-  EfiACPIReclaimMemory,\r
-  EfiACPIMemoryNVS,\r
-  EfiMemoryMappedIO,\r
-  EfiMemoryMappedIOPortSpace,\r
-  EfiPalCode,\r
-  EfiMaxMemoryType\r
-} EFI_MEMORY_TYPE;\r
-\r
-typedef UINT32  EFI_STATUS_CODE_TYPE;\r
-typedef UINT32  EFI_STATUS_CODE_VALUE;\r
-\r
-typedef struct {\r
-  UINT16    HeaderSize;\r
-  UINT16    Size;\r
-  EFI_GUID  Type;\r
-} EFI_STATUS_CODE_DATA;\r
-\r
-typedef struct {\r
-  UINT64  Signature;\r
-  UINT32  Revision;\r
-  UINT32  HeaderSize;\r
-  UINT32  CRC32;\r
-  UINT32  Reserved;\r
-} EFI_TABLE_HEADER;\r
-\r
-#define EFI_PAGE_SIZE         4096\r
-\r
-\r
-typedef VOID    *EFI_HANDLE;\r
-typedef UINT16  EFI_HII_HANDLE;\r
-typedef UINT16  STRING_REF;\r
-typedef struct {\r
-  INT16     Value;\r
-  INT16     Exponent;\r
-} EFI_EXP_BASE10_DATA;\r
-\r
-//\r
-// Define macros to build data structure signatures from characters.\r
-//\r
-#define EFI_SIGNATURE_16(A, B)        ((A) | (B << 8))\r
-#define EFI_SIGNATURE_32(A, B, C, D)  (EFI_SIGNATURE_16 (A, B) | (EFI_SIGNATURE_16 (C, D) << 16))\r
-#define EFI_SIGNATURE_64(A, B, C, D, E, F, G, H) \\r
-    (EFI_SIGNATURE_32 (A, B, C, D) | ((UINT64) (EFI_SIGNATURE_32 (E, F, G, H)) << 32))\r
-\r
-\r
-#include <Protocol/DevicePath.h>\r
-\r
-#endif\r
diff --git a/Tools/CodeTools/TianoTools/Include/Common/UefiBaseTypes.h b/Tools/CodeTools/TianoTools/Include/Common/UefiBaseTypes.h
deleted file mode 100644 (file)
index 4954c10..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-/** @file\r
-  This file makes the BaseTypes.h backward compatible with the ones used in the \r
-  past for EFI and Tiano development. It's mostly just prepending an EFI_ on the \r
-  definitions.\r
-\r
-  Copyright (c) 2006, Intel Corporation                                                         \r
-  All rights reserved. This program and the accompanying materials                          \r
-  are licensed and made available under the terms and conditions of the BSD License         \r
-  which accompanies this distribution.  The full text of the license may be found at        \r
-  http://opensource.org/licenses/bsd-license.php                                            \r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-  Module Name:  UefiBaseTypes.h\r
-\r
-**/\r
-\r
-#ifndef __UEFI_BASE_TYPES_H__\r
-#define __UEFI_BASE_TYPES_H__\r
-\r
-#include <Common/BaseTypes.h>\r
-\r
-typedef UINT64    EFI_LBA;\r
-\r
-#define EFIERR(_a)                    ENCODE_ERROR(_a)\r
-\r
-#define EFI_MAX_BIT                   MAX_BIT\r
-#define EFI_MAX_ADDRESS               MAX_ADDRESS\r
-#define EFI_BREAKPOINT()              CpuBreakpoint ()\r
-#define EFI_DEADLOOP()                CpuDeadLoop ()\r
-#define EFI_ERROR(A)                  RETURN_ERROR(A)\r
-\r
-typedef GUID          EFI_GUID;\r
-typedef RETURN_STATUS EFI_STATUS;\r
-\r
-#define EFI_SUCCESS               RETURN_SUCCESS              \r
-#define EFI_LOAD_ERROR            RETURN_LOAD_ERROR           \r
-#define EFI_INVALID_PARAMETER     RETURN_INVALID_PARAMETER    \r
-#define EFI_UNSUPPORTED           RETURN_UNSUPPORTED          \r
-#define EFI_BAD_BUFFER_SIZE       RETURN_BAD_BUFFER_SIZE      \r
-#define EFI_BUFFER_TOO_SMALL      RETURN_BUFFER_TOO_SMALL     \r
-#define EFI_NOT_READY             RETURN_NOT_READY            \r
-#define EFI_DEVICE_ERROR          RETURN_DEVICE_ERROR         \r
-#define EFI_WRITE_PROTECTED       RETURN_WRITE_PROTECTED      \r
-#define EFI_OUT_OF_RESOURCES      RETURN_OUT_OF_RESOURCES     \r
-#define EFI_VOLUME_CORRUPTED      RETURN_VOLUME_CORRUPTED     \r
-#define EFI_VOLUME_FULL           RETURN_VOLUME_FULL          \r
-#define EFI_NO_MEDIA              RETURN_NO_MEDIA             \r
-#define EFI_MEDIA_CHANGED         RETURN_MEDIA_CHANGED        \r
-#define EFI_NOT_FOUND             RETURN_NOT_FOUND            \r
-#define EFI_ACCESS_DENIED         RETURN_ACCESS_DENIED        \r
-#define EFI_NO_RESPONSE           RETURN_NO_RESPONSE          \r
-#define EFI_NO_MAPPING            RETURN_NO_MAPPING           \r
-#define EFI_TIMEOUT               RETURN_TIMEOUT              \r
-#define EFI_NOT_STARTED           RETURN_NOT_STARTED          \r
-#define EFI_ALREADY_STARTED       RETURN_ALREADY_STARTED      \r
-#define EFI_ABORTED               RETURN_ABORTED              \r
-#define EFI_ICMP_ERROR            RETURN_ICMP_ERROR           \r
-#define EFI_TFTP_ERROR            RETURN_TFTP_ERROR           \r
-#define EFI_PROTOCOL_ERROR        RETURN_PROTOCOL_ERROR       \r
-#define EFI_INCOMPATIBLE_VERSION  RETURN_INCOMPATIBLE_VERSION \r
-#define EFI_SECURITY_VIOLATION    RETURN_SECURITY_VIOLATION   \r
-#define EFI_CRC_ERROR             RETURN_CRC_ERROR   \r
-#define EFI_END_OF_MEDIA          RETURN_END_OF_MEDIA\r
-#define EFI_END_OF_FILE           RETURN_END_OF_FILE\r
-\r
-#define EFI_WARN_UNKNOWN_GLYPH    RETURN_WARN_UNKNOWN_GLYPH   \r
-#define EFI_WARN_DELETE_FAILURE   RETURN_WARN_DELETE_FAILURE  \r
-#define EFI_WARN_WRITE_FAILURE    RETURN_WARN_WRITE_FAILURE   \r
-#define EFI_WARN_BUFFER_TOO_SMALL RETURN_WARN_BUFFER_TOO_SMALL\r
-\r
-//\r
-// The EFI memory allocation functions work in units of EFI_PAGEs that are\r
-// 4K. This should in no way be confused with the page size of the processor.\r
-// An EFI_PAGE is just the quanta of memory in EFI.\r
-//\r
-#define EFI_PAGE_MASK         0xFFF\r
-#define EFI_PAGE_SHIFT        12\r
-\r
-#define EFI_SIZE_TO_PAGES(a)  (((a) >> EFI_PAGE_SHIFT) + (((a) & EFI_PAGE_MASK) ? 1 : 0))\r
-\r
-#define EFI_PAGES_TO_SIZE(a)   ( (a) << EFI_PAGE_SHIFT)\r
-\r
-#endif\r
diff --git a/Tools/CodeTools/TianoTools/Include/Common/Variable.h b/Tools/CodeTools/TianoTools/Include/Common/Variable.h
deleted file mode 100644 (file)
index bc0d640..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2006, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-Module Name:\r
-\r
-  EfiVariable.h\r
-  \r
-Abstract:\r
-  \r
-  Header file for EFI Variable Services\r
-\r
---*/\r
-\r
-#ifndef _EFI_VARIABLE_H_\r
-#define _EFI_VARIABLE_H_\r
-\r
-#define VARIABLE_STORE_SIGNATURE  EFI_SIGNATURE_32 ('$', 'V', 'S', 'S')\r
-\r
-#define MAX_VARIABLE_SIZE         1024\r
-\r
-#define VARIABLE_DATA             0x55AA\r
-\r
-//\r
-// Variable Store Header flags\r
-//\r
-#define VARIABLE_STORE_FORMATTED  0x5a\r
-#define VARIABLE_STORE_HEALTHY    0xfe\r
-\r
-//\r
-// Variable Store Status\r
-//\r
-typedef enum {\r
-  EfiRaw,\r
-  EfiValid,\r
-  EfiInvalid,\r
-  EfiUnknown\r
-} VARIABLE_STORE_STATUS;\r
-\r
-//\r
-// Variable State flags\r
-//\r
-#define VAR_IN_DELETED_TRANSITION     0xfe  // Variable is in obsolete transistion\r
-#define VAR_DELETED                   0xfd  // Variable is obsolete\r
-#define VAR_ADDED                     0x7f  // Variable has been completely added\r
-#define IS_VARIABLE_STATE(_c, _Mask)  (BOOLEAN) (((~_c) & (~_Mask)) != 0)\r
-\r
-#pragma pack(1)\r
-\r
-typedef struct {\r
-  UINT32  Signature;\r
-  UINT32  Size;\r
-  UINT8   Format;\r
-  UINT8   State;\r
-  UINT16  Reserved;\r
-  UINT32  Reserved1;\r
-} VARIABLE_STORE_HEADER;\r
-\r
-typedef struct {\r
-  UINT16    StartId;\r
-  UINT8     State;\r
-  UINT8     Reserved;\r
-  UINT32    Attributes;\r
-  UINTN     NameSize;\r
-  UINTN     DataSize;\r
-  EFI_GUID  VendorGuid;\r
-} VARIABLE_HEADER;\r
-\r
-#pragma pack()\r
-\r
-#endif // _EFI_VARIABLE_H_\r
diff --git a/Tools/CodeTools/TianoTools/Include/Common/WorkingBlockHeader.h b/Tools/CodeTools/TianoTools/Include/Common/WorkingBlockHeader.h
deleted file mode 100644 (file)
index 235b740..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2006, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-Module Name:\r
-\r
-  EfiWorkingBlockHeader.h\r
-\r
-Abstract:\r
-\r
-  Defines data structure that is the headers found at the runtime \r
-  updatable firmware volumes, such as the FileSystemGuid of the \r
-  working block, the header structure of the variable block, FTW\r
-  working block, or event log block.\r
-\r
---*/\r
-\r
-#ifndef _EFI_WORKING_BLOCK_HEADER_H_\r
-#define _EFI_WORKING_BLOCK_HEADER_H_\r
-\r
-//\r
-// EFI Fault tolerant working block header\r
-// The header is immediately followed by the write queue.\r
-//\r
-typedef struct {\r
-  EFI_GUID  Signature;\r
-  UINT32    Crc;\r
-  UINT32    WorkingBlockValid : 1;\r
-  UINT32    WorkingBlockInvalid : 1;\r
-#define WORKING_BLOCK_VALID   0x1\r
-#define WORKING_BLOCK_INVALID 0x2\r
-  UINT32    Reserved : 6;\r
-  UINT8     Reserved3[3];\r
-  UINTN     WriteQueueSize;\r
-  //\r
-  // UINT8                WriteQueue[WriteQueueSize];\r
-  //\r
-} EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER;\r
-\r
-#endif\r
diff --git a/Tools/CodeTools/TianoTools/Include/Guid/AcpiTableStorage.h b/Tools/CodeTools/TianoTools/Include/Guid/AcpiTableStorage.h
deleted file mode 100644 (file)
index 80b1154..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-/** @file\r
-  The ACPI table storage file is fully FFS compliant. \r
-  The file is a number of sections of type EFI_SECTION_RAW.\r
-  This GUID is used to identify the file as an ACPI table storage file.\r
-\r
-  Copyright (c) 2006, Intel Corporation                                                         \r
-  All rights reserved. This program and the accompanying materials                          \r
-  are licensed and made available under the terms and conditions of the BSD License         \r
-  which accompanies this distribution.  The full text of the license may be found at        \r
-  http://opensource.org/licenses/bsd-license.php                                            \r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-  Module Name:  AcpiTableStorage.h\r
-\r
-  @par Revision Reference:\r
-  GUID defined in ACPI Table Storage Spec Version 0.9.\r
-\r
-**/\r
-\r
-#ifndef _ACPI_TABLE_STORAGE_H_\r
-#define _ACPI_TABLE_STORAGE_H_\r
-\r
-#define EFI_ACPI_TABLE_STORAGE_GUID \\r
-  { 0x7e374e25, 0x8e01, 0x4fee, {0x87, 0xf2, 0x39, 0xc, 0x23, 0xc6, 0x6, 0xcd } }\r
-\r
-extern EFI_GUID gEfiAcpiTableStorageGuid;\r
-\r
-#endif\r
diff --git a/Tools/CodeTools/TianoTools/Include/Guid/Apriori.h b/Tools/CodeTools/TianoTools/Include/Guid/Apriori.h
deleted file mode 100644 (file)
index ba92560..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-/** @file\r
-  GUID used as an FV filename for A Priori file. The A Priori file contains a\r
-  list of FV filenames that the DXE dispatcher will schedule reguardless of\r
-  the dependency grammer.\r
-\r
-  Copyright (c) 2006, Intel Corporation                                                         \r
-  All rights reserved. This program and the accompanying materials                          \r
-  are licensed and made available under the terms and conditions of the BSD License         \r
-  which accompanies this distribution.  The full text of the license may be found at        \r
-  http://opensource.org/licenses/bsd-license.php                                            \r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-  Module Name:  Apriori.h\r
-\r
-  @par Revision Reference:\r
-  GUID defined in DXE CIS spec version 0.91B\r
-\r
-**/\r
-\r
-#ifndef __APRIORI_GUID_H__\r
-#define __APRIORI_GUID_H__\r
-\r
-#define EFI_APRIORI_GUID \\r
-  { \\r
-    0xfc510ee7, 0xffdc, 0x11d4, {0xbd, 0x41, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 } \\r
-  }\r
-\r
-extern EFI_GUID gAprioriGuid;\r
-\r
-#endif\r
diff --git a/Tools/CodeTools/TianoTools/Include/Guid/Capsule.h b/Tools/CodeTools/TianoTools/Include/Guid/Capsule.h
deleted file mode 100644 (file)
index 7864b92..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-/** @file\r
-  GUIDs used for EFI Capsule\r
-\r
-  Copyright (c) 2006, Intel Corporation                                                         \r
-  All rights reserved. This program and the accompanying materials                          \r
-  are licensed and made available under the terms and conditions of the BSD License         \r
-  which accompanies this distribution.  The full text of the license may be found at        \r
-  http://opensource.org/licenses/bsd-license.php                                            \r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-  Module Name:  Capsule.h\r
-\r
-  @par Revision Reference:\r
-  GUIDs defined in Capsule Spec Version 0.9\r
-\r
-**/\r
-\r
-#ifndef __CAPSULE_GUID_H__\r
-#define __CAPSULE_GUID_H__\r
-\r
-//\r
-// This is the GUID of the capsule header of the image on disk.\r
-//\r
-#define EFI_CAPSULE_GUID \\r
-  { \\r
-    0x3B6686BD, 0x0D76, 0x4030, {0xB7, 0x0E, 0xB5, 0x51, 0x9E, 0x2F, 0xC5, 0xA0 } \\r
-  }\r
-\r
-//\r
-// This is the GUID of the configuration results file created by the capsule\r
-// application.\r
-//\r
-#define EFI_CONFIG_FILE_NAME_GUID \\r
-  { \\r
-    0x98B8D59B, 0xE8BA, 0x48EE, {0x98, 0xDD, 0xC2, 0x95, 0x39, 0x2F, 0x1E, 0xDB } \\r
-  }\r
-\r
-extern EFI_GUID gEfiCapsuleGuid;\r
-extern EFI_GUID gEfiConfigFileNameGuid;\r
-\r
-#endif\r
diff --git a/Tools/CodeTools/TianoTools/Include/Guid/FirmwareFileSystem.h b/Tools/CodeTools/TianoTools/Include/Guid/FirmwareFileSystem.h
deleted file mode 100644 (file)
index 06bfa7d..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-/** @file\r
-  Guid used to define the Firmware File System.  See the Framework Firmware \r
-  File System Specification for more details.\r
-\r
-  Copyright (c) 2006, Intel Corporation                                                         \r
-  All rights reserved. This program and the accompanying materials                          \r
-  are licensed and made available under the terms and conditions of the BSD License         \r
-  which accompanies this distribution.  The full text of the license may be found at        \r
-  http://opensource.org/licenses/bsd-license.php                                            \r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-  Module Name:  FirmwareFileSystem.h\r
-\r
-  @par Revision Reference:\r
-  Guids defined in Firmware File System Spec 0.9\r
-\r
-**/\r
-\r
-#ifndef __FIRMWARE_FILE_SYSTEM_GUID_H__\r
-#define __FIRMWARE_FILE_SYSTEM_GUID_H__\r
-\r
-//\r
-// GUIDs defined by the FFS specification.\r
-//\r
-#define EFI_FIRMWARE_FILE_SYSTEM_GUID \\r
-  { \\r
-    0x7A9354D9, 0x0468, 0x444a, {0x81, 0xCE, 0x0B, 0xF6, 0x17, 0xD8, 0x90, 0xDF } \\r
-  }\r
-\r
-#define EFI_FFS_VOLUME_TOP_FILE_GUID \\r
-  { \\r
-    0x1BA0062E, 0xC779, 0x4582, {0x85, 0x66, 0x33, 0x6A, 0xE8, 0xF7, 0x8F, 0x9 } \\r
-  }\r
-\r
-extern EFI_GUID gEfiFirmwareFileSystemGuid;\r
-extern EFI_GUID gEfiFirmwareVolumeTopFileGuid;\r
-\r
-#endif\r
diff --git a/Tools/CodeTools/TianoTools/Include/Ia32/ProcessorBind.h b/Tools/CodeTools/TianoTools/Include/Ia32/ProcessorBind.h
deleted file mode 100644 (file)
index 587d8a6..0000000
+++ /dev/null
@@ -1,167 +0,0 @@
-/** @file\r
-  Processor or Compiler specific defines and types for x64.\r
-\r
-  Copyright (c) 2006, Intel Corporation                                                         \r
-  All rights reserved. This program and the accompanying materials                          \r
-  are licensed and made available under the terms and conditions of the BSD License         \r
-  which accompanies this distribution.  The full text of the license may be found at        \r
-  http://opensource.org/licenses/bsd-license.php                                            \r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-  Module Name:  ProcessorBind.h\r
-\r
-**/\r
-\r
-#ifndef __PROCESSOR_BIND_H__\r
-#define __PROCESSOR_BIND_H__\r
-\r
-//\r
-// Define the processor type so other code can make processor based choices\r
-//\r
-#define MDE_CPU_IA32\r
-\r
-//\r
-// Make sure we are useing the correct packing rules per EFI specification\r
-//\r
-#ifndef __GNUC__\r
-#pragma pack()\r
-#endif\r
-\r
-#if _MSC_EXTENSIONS\r
-\r
-//\r
-// Disable warning that make it impossible to compile at /W4\r
-// This only works for Microsoft* tools\r
-//\r
-\r
-//\r
-// Disabling bitfield type checking warnings.\r
-//\r
-#pragma warning ( disable : 4214 )\r
-\r
-//\r
-// Disabling the unreferenced formal parameter warnings.\r
-//\r
-#pragma warning ( disable : 4100 )\r
-\r
-//\r
-// Disable slightly different base types warning as CHAR8 * can not be set\r
-// to a constant string.\r
-//\r
-#pragma warning ( disable : 4057 )\r
-\r
-//\r
-// ASSERT(FALSE) or while (TRUE) are legal constructes so supress this warning\r
-//\r
-#pragma warning ( disable : 4127 )\r
-\r
-\r
-#endif\r
-\r
-\r
-#if !defined(__GNUC__) && (__STDC_VERSION__ < 199901L)\r
-  //\r
-  // No ANSI C 2000 stdint.h integer width declarations, so define equivalents\r
-  //\r
\r
-  #if _MSC_EXTENSIONS \r
-    \r
-    //\r
-    // use Microsoft* C complier dependent interger width types \r
-    //\r
-    typedef unsigned __int64    UINT64;\r
-    typedef __int64             INT64;\r
-    typedef unsigned __int32    UINT32;\r
-    typedef __int32             INT32;\r
-    typedef unsigned short      UINT16;\r
-    typedef unsigned short      CHAR16;\r
-    typedef short               INT16;\r
-    typedef unsigned char       BOOLEAN;\r
-    typedef unsigned char       UINT8;\r
-    typedef char                CHAR8;\r
-    typedef char                INT8;\r
-  #else\r
-\r
-    //\r
-    // Assume standard IA-32 alignment. \r
-    // BugBug: Need to check portability of long long\r
-    //\r
-    typedef unsigned long long  UINT64;\r
-    typedef long long           INT64;\r
-    typedef unsigned int        UINT32;\r
-    typedef int                 INT32;\r
-    typedef unsigned short      UINT16;\r
-    typedef unsigned short      CHAR16;\r
-    typedef short               INT16;\r
-    typedef unsigned char       BOOLEAN;\r
-    typedef unsigned char       UINT8;\r
-    typedef char                CHAR8;\r
-    typedef char                INT8;\r
-  #endif\r
-\r
-  #define UINT8_MAX 0xff\r
-\r
-#else\r
-  //\r
-  // Use ANSI C 2000 stdint.h integer width declarations\r
-  //\r
-  #include "stdint.h"\r
-  typedef uint8_t   BOOLEAN;\r
-  typedef int8_t    INT8;\r
-  typedef uint8_t   UINT8;\r
-  typedef int16_t   INT16;\r
-  typedef uint16_t  UINT16;\r
-  typedef int32_t   INT32;\r
-  typedef uint32_t  UINT32;\r
-  typedef int64_t   INT64;\r
-  typedef uint64_t  UINT64;\r
-  typedef char      CHAR8;\r
-  typedef uint16_t  CHAR16;\r
-\r
-#endif\r
-\r
-typedef UINT32  UINTN;\r
-typedef INT32   INTN;\r
-\r
-\r
-//\r
-// Processor specific defines\r
-//\r
-#define MAX_BIT     0x80000000\r
-#define MAX_2_BITS  0xC0000000\r
-\r
-//\r
-// Maximum legal IA-32 address\r
-//\r
-#define MAX_ADDRESS   0xFFFFFFFF\r
-\r
-//\r
-// Modifier to ensure that all protocol member functions and EFI intrinsics\r
-// use the correct C calling convention. All protocol member functions and\r
-// EFI intrinsics are required to modify thier member functions with EFIAPI.\r
-//\r
-#if _MSC_EXTENSIONS\r
-  //\r
-  // Microsoft* compiler requires _EFIAPI useage, __cdecl is Microsoft* specific C.\r
-  // \r
-  #define EFIAPI __cdecl  \r
-#endif\r
-\r
-#if __GNUC__\r
-  #define EFIAPI __attribute__((cdecl))    \r
-#endif\r
-\r
-//\r
-// The Microsoft* C compiler can removed references to unreferenced data items\r
-//  if the /OPT:REF linker option is used. We defined a macro as this is a \r
-//  a non standard extension\r
-//\r
-#if _MSC_EXTENSIONS\r
-  #define GLOBAL_REMOVE_IF_UNREFERENCED __declspec(selectany)\r
-#else\r
-  #define GLOBAL_REMOVE_IF_UNREFERENCED\r
-#endif\r
-\r
-#endif\r
diff --git a/Tools/CodeTools/TianoTools/Include/IndustryStandard/pci22.h b/Tools/CodeTools/TianoTools/Include/IndustryStandard/pci22.h
deleted file mode 100644 (file)
index 7fee279..0000000
+++ /dev/null
@@ -1,481 +0,0 @@
-/** @file\r
-  Support for PCI 2.2 standard.\r
-\r
-  Copyright (c) 2006, Intel Corporation                                                         \r
-  All rights reserved. This program and the accompanying materials                          \r
-  are licensed and made available under the terms and conditions of the BSD License         \r
-  which accompanies this distribution.  The full text of the license may be found at        \r
-  http://opensource.org/licenses/bsd-license.php                                            \r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-  Module Name:  pci22.h\r
-\r
-**/\r
-\r
-#ifndef _PCI22_H\r
-#define _PCI22_H\r
-\r
-#define PCI_MAX_SEGMENT 0\r
-\r
-#define PCI_MAX_BUS     255\r
-\r
-#define PCI_MAX_DEVICE  31\r
-#define PCI_MAX_FUNC    7\r
-\r
-//\r
-// Command\r
-//\r
-#define PCI_VGA_PALETTE_SNOOP_DISABLED  0x20\r
-\r
-#pragma pack(push, 1)\r
-typedef struct {\r
-  UINT16  VendorId;\r
-  UINT16  DeviceId;\r
-  UINT16  Command;\r
-  UINT16  Status;\r
-  UINT8   RevisionID;\r
-  UINT8   ClassCode[3];\r
-  UINT8   CacheLineSize;\r
-  UINT8   LatencyTimer;\r
-  UINT8   HeaderType;\r
-  UINT8   BIST;\r
-} PCI_DEVICE_INDEPENDENT_REGION;\r
-\r
-typedef struct {\r
-  UINT32  Bar[6];\r
-  UINT32  CISPtr;\r
-  UINT16  SubsystemVendorID;\r
-  UINT16  SubsystemID;\r
-  UINT32  ExpansionRomBar;\r
-  UINT8   CapabilityPtr;\r
-  UINT8   Reserved1[3];\r
-  UINT32  Reserved2;\r
-  UINT8   InterruptLine;\r
-  UINT8   InterruptPin;\r
-  UINT8   MinGnt;\r
-  UINT8   MaxLat;\r
-} PCI_DEVICE_HEADER_TYPE_REGION;\r
-\r
-typedef struct {\r
-  PCI_DEVICE_INDEPENDENT_REGION Hdr;\r
-  PCI_DEVICE_HEADER_TYPE_REGION Device;\r
-} PCI_TYPE00;\r
-\r
-typedef struct {\r
-  UINT32  Bar[2];\r
-  UINT8   PrimaryBus;\r
-  UINT8   SecondaryBus;\r
-  UINT8   SubordinateBus;\r
-  UINT8   SecondaryLatencyTimer;\r
-  UINT8   IoBase;\r
-  UINT8   IoLimit;\r
-  UINT16  SecondaryStatus;\r
-  UINT16  MemoryBase;\r
-  UINT16  MemoryLimit;\r
-  UINT16  PrefetchableMemoryBase;\r
-  UINT16  PrefetchableMemoryLimit;\r
-  UINT32  PrefetchableBaseUpper32;\r
-  UINT32  PrefetchableLimitUpper32;\r
-  UINT16  IoBaseUpper16;\r
-  UINT16  IoLimitUpper16;\r
-  UINT8   CapabilityPtr;\r
-  UINT8   Reserved[3];\r
-  UINT32  ExpansionRomBAR;\r
-  UINT8   InterruptLine;\r
-  UINT8   InterruptPin;\r
-  UINT16  BridgeControl;\r
-} PCI_BRIDGE_CONTROL_REGISTER;\r
-\r
-typedef struct {\r
-  PCI_DEVICE_INDEPENDENT_REGION Hdr;\r
-  PCI_BRIDGE_CONTROL_REGISTER   Bridge;\r
-} PCI_TYPE01;\r
-\r
-typedef union {\r
-  PCI_TYPE00  Device;\r
-  PCI_TYPE01  Bridge;\r
-} PCI_TYPE_GENERIC;\r
-\r
-typedef struct {\r
-  UINT32  CardBusSocketReg; // Cardus Socket/ExCA Base\r
-  // Address Register\r
-  //\r
-  UINT16  Reserved;\r
-  UINT16  SecondaryStatus;      // Secondary Status\r
-  UINT8   PciBusNumber;         // PCI Bus Number\r
-  UINT8   CardBusBusNumber;     // CardBus Bus Number\r
-  UINT8   SubordinateBusNumber; // Subordinate Bus Number\r
-  UINT8   CardBusLatencyTimer;  // CardBus Latency Timer\r
-  UINT32  MemoryBase0;          // Memory Base Register 0\r
-  UINT32  MemoryLimit0;         // Memory Limit Register 0\r
-  UINT32  MemoryBase1;\r
-  UINT32  MemoryLimit1;\r
-  UINT32  IoBase0;\r
-  UINT32  IoLimit0;             // I/O Base Register 0\r
-  UINT32  IoBase1;              // I/O Limit Register 0\r
-  UINT32  IoLimit1;\r
-  UINT8   InterruptLine;        // Interrupt Line\r
-  UINT8   InterruptPin;         // Interrupt Pin\r
-  UINT16  BridgeControl;        // Bridge Control\r
-} PCI_CARDBUS_CONTROL_REGISTER;\r
-\r
-//\r
-// Definitions of PCI class bytes and manipulation macros.\r
-//\r
-#define PCI_CLASS_OLD                 0x00\r
-#define PCI_CLASS_OLD_OTHER           0x00\r
-#define PCI_CLASS_OLD_VGA             0x01\r
-\r
-#define PCI_CLASS_MASS_STORAGE        0x01\r
-#define PCI_CLASS_MASS_STORAGE_SCSI   0x00\r
-#define PCI_CLASS_MASS_STORAGE_IDE    0x01  // obsolete\r
-#define PCI_CLASS_IDE                 0x01\r
-#define PCI_CLASS_MASS_STORAGE_FLOPPY 0x02\r
-#define PCI_CLASS_MASS_STORAGE_IPI    0x03\r
-#define PCI_CLASS_MASS_STORAGE_RAID   0x04\r
-#define PCI_CLASS_MASS_STORAGE_OTHER  0x80\r
-\r
-#define PCI_CLASS_NETWORK             0x02\r
-#define PCI_CLASS_NETWORK_ETHERNET    0x00\r
-#define PCI_CLASS_ETHERNET            0x00  // obsolete\r
-#define PCI_CLASS_NETWORK_TOKENRING   0x01\r
-#define PCI_CLASS_NETWORK_FDDI        0x02\r
-#define PCI_CLASS_NETWORK_ATM         0x03\r
-#define PCI_CLASS_NETWORK_ISDN        0x04\r
-#define PCI_CLASS_NETWORK_OTHER       0x80\r
-\r
-#define PCI_CLASS_DISPLAY             0x03\r
-#define PCI_CLASS_DISPLAY_CTRL        0x03  // obsolete\r
-#define PCI_CLASS_DISPLAY_VGA         0x00\r
-#define PCI_CLASS_VGA                 0x00  // obsolete\r
-#define PCI_CLASS_DISPLAY_XGA         0x01\r
-#define PCI_CLASS_DISPLAY_3D          0x02\r
-#define PCI_CLASS_DISPLAY_OTHER       0x80\r
-#define PCI_CLASS_DISPLAY_GFX         0x80\r
-#define PCI_CLASS_GFX                 0x80  // obsolete\r
-#define PCI_CLASS_BRIDGE              0x06\r
-#define PCI_CLASS_BRIDGE_HOST         0x00\r
-#define PCI_CLASS_BRIDGE_ISA          0x01\r
-#define PCI_CLASS_ISA                 0x01  // obsolete\r
-#define PCI_CLASS_BRIDGE_EISA         0x02\r
-#define PCI_CLASS_BRIDGE_MCA          0x03\r
-#define PCI_CLASS_BRIDGE_P2P          0x04\r
-#define PCI_CLASS_BRIDGE_PCMCIA       0x05\r
-#define PCI_CLASS_BRIDGE_NUBUS        0x06\r
-#define PCI_CLASS_BRIDGE_CARDBUS      0x07\r
-#define PCI_CLASS_BRIDGE_RACEWAY      0x08\r
-#define PCI_CLASS_BRIDGE_ISA_PDECODE  0x80\r
-#define PCI_CLASS_ISA_POSITIVE_DECODE 0x80  // obsolete\r
-#define PCI_CLASS_SERIAL              0x0C\r
-#define PCI_CLASS_SERIAL_FIREWIRE     0x00\r
-#define PCI_CLASS_SERIAL_ACCESS_BUS   0x01\r
-#define PCI_CLASS_SERIAL_SSA          0x02\r
-#define PCI_CLASS_SERIAL_USB          0x03\r
-#define PCI_CLASS_SERIAL_FIBRECHANNEL 0x04\r
-#define PCI_CLASS_SERIAL_SMB          0x05\r
-\r
-#define IS_CLASS1(_p, c)              ((_p)->Hdr.ClassCode[2] == (c))\r
-#define IS_CLASS2(_p, c, s)           (IS_CLASS1 (_p, c) && ((_p)->Hdr.ClassCode[1] == (s)))\r
-#define IS_CLASS3(_p, c, s, p)        (IS_CLASS2 (_p, c, s) && ((_p)->Hdr.ClassCode[0] == (p)))\r
-\r
-#define IS_PCI_DISPLAY(_p)            IS_CLASS1 (_p, PCI_CLASS_DISPLAY)\r
-#define IS_PCI_VGA(_p)                IS_CLASS3 (_p, PCI_CLASS_DISPLAY, PCI_CLASS_DISPLAY_VGA, 0)\r
-#define IS_PCI_8514(_p)               IS_CLASS3 (_p, PCI_CLASS_DISPLAY, PCI_CLASS_DISPLAY_VGA, 1)\r
-#define IS_PCI_GFX(_p)                IS_CLASS3 (_p, PCI_CLASS_DISPLAY, PCI_CLASS_DISPLAY_GFX, 0)\r
-#define IS_PCI_OLD(_p)                IS_CLASS1 (_p, PCI_CLASS_OLD)\r
-#define IS_PCI_OLD_VGA(_p)            IS_CLASS2 (_p, PCI_CLASS_OLD, PCI_CLASS_OLD_VGA)\r
-#define IS_PCI_IDE(_p)                IS_CLASS2 (_p, PCI_CLASS_MASS_STORAGE, PCI_CLASS_MASS_STORAGE_IDE)\r
-#define IS_PCI_SCSI(_p)               IS_CLASS3 (_p, PCI_CLASS_MASS_STORAGE, PCI_CLASS_MASS_STORAGE_SCSI, 0)\r
-#define IS_PCI_RAID(_p)               IS_CLASS3 (_p, PCI_CLASS_MASS_STORAGE, PCI_CLASS_MASS_STORAGE_RAID, 0)\r
-#define IS_PCI_LPC(_p)                IS_CLASS3 (_p, PCI_CLASS_BRIDGE, PCI_CLASS_BRIDGE_ISA, 0)\r
-#define IS_PCI_P2P(_p)                IS_CLASS3 (_p, PCI_CLASS_BRIDGE, PCI_CLASS_BRIDGE_P2P, 0)\r
-#define IS_PCI_P2P_SUB(_p)            IS_CLASS3 (_p, PCI_CLASS_BRIDGE, PCI_CLASS_BRIDGE_P2P, 1)\r
-#define IS_PCI_USB(_p)                IS_CLASS2 (_p, PCI_CLASS_SERIAL, PCI_CLASS_SERIAL_USB)\r
-\r
-#define HEADER_TYPE_DEVICE            0x00\r
-#define HEADER_TYPE_PCI_TO_PCI_BRIDGE 0x01\r
-#define HEADER_TYPE_CARDBUS_BRIDGE    0x02\r
-\r
-#define HEADER_TYPE_MULTI_FUNCTION    0x80\r
-#define HEADER_LAYOUT_CODE            0x7f\r
-\r
-#define IS_PCI_BRIDGE(_p)             (((_p)->Hdr.HeaderType & HEADER_LAYOUT_CODE) == (HEADER_TYPE_PCI_TO_PCI_BRIDGE))\r
-#define IS_CARDBUS_BRIDGE(_p)         (((_p)->Hdr.HeaderType & HEADER_LAYOUT_CODE) == (HEADER_TYPE_CARDBUS_BRIDGE))\r
-#define IS_PCI_MULTI_FUNC(_p)         ((_p)->Hdr.HeaderType & HEADER_TYPE_MULTI_FUNCTION)\r
-\r
-#define PCI_DEVICE_ROMBAR             0x30\r
-#define PCI_BRIDGE_ROMBAR             0x38\r
-\r
-#define PCI_MAX_BAR                   6\r
-#define PCI_MAX_CONFIG_OFFSET         0x100\r
-//\r
-// bugbug: this is supported in PCI spec v2.3\r
-//\r
-#define PCI_EXP_MAX_CONFIG_OFFSET                   0x1000\r
-\r
-#define PCI_VENDOR_ID_OFFSET                        0x00\r
-#define PCI_DEVICE_ID_OFFSET                        0x02\r
-#define PCI_COMMAND_OFFSET                          0x04\r
-#define PCI_PRIMARY_STATUS_OFFSET                   0x06\r
-#define PCI_REVISION_ID_OFFSET                      0x08\r
-#define PCI_CLASSCODE_OFFSET                        0x09\r
-#define PCI_CACHELINE_SIZE_OFFSET                   0x0C\r
-#define PCI_LATENCY_TIMER_OFFSET                    0x0D\r
-#define PCI_HEADER_TYPE_OFFSET                      0x0E\r
-#define PCI_BIST_OFFSET                             0x0F\r
-\r
-#define PCI_BRIDGE_CONTROL_REGISTER_OFFSET          0x3E\r
-#define PCI_BRIDGE_STATUS_REGISTER_OFFSET           0x1E\r
-\r
-#define PCI_BRIDGE_PRIMARY_BUS_REGISTER_OFFSET      0x18\r
-#define PCI_BRIDGE_SECONDARY_BUS_REGISTER_OFFSET    0x19\r
-#define PCI_BRIDGE_SUBORDINATE_BUS_REGISTER_OFFSET  0x1a\r
-\r
-typedef struct {\r
-  UINT8 Register;\r
-  UINT8 Function;\r
-  UINT8 Device;\r
-  UINT8 Bus;\r
-  UINT8 Reserved[4];\r
-} DEFIO_PCI_ADDR;\r
-\r
-typedef union {\r
-  struct {\r
-    UINT32  Reg : 8;\r
-    UINT32  Func : 3;\r
-    UINT32  Dev : 5;\r
-    UINT32  Bus : 8;\r
-    UINT32  Reserved : 7;\r
-    UINT32  Enable : 1;\r
-  } Bits;\r
-  UINT32  Uint32;\r
-} PCI_CONFIG_ACCESS_CF8;\r
-\r
-#pragma pack()\r
-\r
-#define EFI_ROOT_BRIDGE_LIST                            'eprb'\r
-#define PCI_EXPANSION_ROM_HEADER_SIGNATURE              0xaa55\r
-#define EFI_PCI_EXPANSION_ROM_HEADER_EFISIGNATURE       0x0EF1\r
-#define PCI_DATA_STRUCTURE_SIGNATURE                    EFI_SIGNATURE_32 ('P', 'C', 'I', 'R')\r
-#define PCI_CODE_TYPE_PCAT_IMAGE                        0x00\r
-#define PCI_CODE_TYPE_EFI_IMAGE                         0x03\r
-#define EFI_PCI_EXPANSION_ROM_HEADER_COMPRESSED         0x0001\r
-\r
-#define EFI_PCI_COMMAND_IO_SPACE                        0x0001\r
-#define EFI_PCI_COMMAND_MEMORY_SPACE                    0x0002\r
-#define EFI_PCI_COMMAND_BUS_MASTER                      0x0004\r
-#define EFI_PCI_COMMAND_SPECIAL_CYCLE                   0x0008\r
-#define EFI_PCI_COMMAND_MEMORY_WRITE_AND_INVALIDATE     0x0010\r
-#define EFI_PCI_COMMAND_VGA_PALETTE_SNOOP               0x0020\r
-#define EFI_PCI_COMMAND_PARITY_ERROR_RESPOND            0x0040\r
-#define EFI_PCI_COMMAND_STEPPING_CONTROL                0x0080\r
-#define EFI_PCI_COMMAND_SERR                            0x0100\r
-#define EFI_PCI_COMMAND_FAST_BACK_TO_BACK               0x0200\r
-\r
-#define EFI_PCI_BRIDGE_CONTROL_PARITY_ERROR_RESPONSE    0x0001\r
-#define EFI_PCI_BRIDGE_CONTROL_SERR                     0x0002\r
-#define EFI_PCI_BRIDGE_CONTROL_ISA                      0x0004\r
-#define EFI_PCI_BRIDGE_CONTROL_VGA                      0x0008\r
-#define EFI_PCI_BRIDGE_CONTROL_VGA_16                   0x0010\r
-#define EFI_PCI_BRIDGE_CONTROL_MASTER_ABORT             0x0020\r
-#define EFI_PCI_BRIDGE_CONTROL_RESET_SECONDARY_BUS      0x0040\r
-#define EFI_PCI_BRIDGE_CONTROL_FAST_BACK_TO_BACK        0x0080\r
-#define EFI_PCI_BRIDGE_CONTROL_PRIMARY_DISCARD_TIMER    0x0100\r
-#define EFI_PCI_BRIDGE_CONTROL_SECONDARY_DISCARD_TIMER  0x0200\r
-#define EFI_PCI_BRIDGE_CONTROL_TIMER_STATUS             0x0400\r
-#define EFI_PCI_BRIDGE_CONTROL_DISCARD_TIMER_SERR       0x0800\r
-\r
-//\r
-// Following are the PCI-CARDBUS bridge control bit\r
-//\r
-#define EFI_PCI_BRIDGE_CONTROL_IREQINT_ENABLE       0x0080\r
-#define EFI_PCI_BRIDGE_CONTROL_RANGE0_MEMORY_TYPE   0x0100\r
-#define EFI_PCI_BRIDGE_CONTROL_RANGE1_MEMORY_TYPE   0x0200\r
-#define EFI_PCI_BRIDGE_CONTROL_WRITE_POSTING_ENABLE 0x0400\r
-\r
-//\r
-// Following are the PCI status control bit\r
-//\r
-#define EFI_PCI_STATUS_CAPABILITY             0x0010\r
-#define EFI_PCI_STATUS_66MZ_CAPABLE           0x0020\r
-#define EFI_PCI_FAST_BACK_TO_BACK_CAPABLE     0x0080\r
-#define EFI_PCI_MASTER_DATA_PARITY_ERROR      0x0100\r
-\r
-#define EFI_PCI_CAPABILITY_PTR                0x34\r
-#define EFI_PCI_CARDBUS_BRIDGE_CAPABILITY_PTR 0x14\r
-\r
-#pragma pack(1)\r
-typedef struct {\r
-  UINT16  Signature;    // 0xaa55\r
-  UINT8   Reserved[0x16];\r
-  UINT16  PcirOffset;\r
-} PCI_EXPANSION_ROM_HEADER;\r
-\r
-typedef struct {\r
-  UINT16  Signature;    // 0xaa55\r
-  UINT16  InitializationSize;\r
-  UINT32  EfiSignature; // 0x0EF1\r
-  UINT16  EfiSubsystem;\r
-  UINT16  EfiMachineType;\r
-  UINT16  CompressionType;\r
-  UINT8   Reserved[8];\r
-  UINT16  EfiImageHeaderOffset;\r
-  UINT16  PcirOffset;\r
-} EFI_PCI_EXPANSION_ROM_HEADER;\r
-\r
-typedef struct {\r
-  UINT16  Signature;    // 0xaa55\r
-  UINT8   Size512;\r
-  UINT8   Reserved[15];\r
-  UINT16  PcirOffset;\r
-} EFI_LEGACY_EXPANSION_ROM_HEADER;\r
-\r
-typedef union {\r
-  UINT8                           *Raw;\r
-  PCI_EXPANSION_ROM_HEADER        *Generic;\r
-  EFI_PCI_EXPANSION_ROM_HEADER    *Efi;\r
-  EFI_LEGACY_EXPANSION_ROM_HEADER *PcAt;\r
-} EFI_PCI_ROM_HEADER;\r
-\r
-typedef struct {\r
-  UINT32  Signature;    // "PCIR"\r
-  UINT16  VendorId;\r
-  UINT16  DeviceId;\r
-  UINT16  Reserved0;\r
-  UINT16  Length;\r
-  UINT8   Revision;\r
-  UINT8   ClassCode[3];\r
-  UINT16  ImageLength;\r
-  UINT16  CodeRevision;\r
-  UINT8   CodeType;\r
-  UINT8   Indicator;\r
-  UINT16  Reserved1;\r
-} PCI_DATA_STRUCTURE;\r
-\r
-//\r
-// PCI Capability List IDs and records\r
-//\r
-#define EFI_PCI_CAPABILITY_ID_PMI     0x01\r
-#define EFI_PCI_CAPABILITY_ID_AGP     0x02\r
-#define EFI_PCI_CAPABILITY_ID_VPD     0x03\r
-#define EFI_PCI_CAPABILITY_ID_SLOTID  0x04\r
-#define EFI_PCI_CAPABILITY_ID_MSI     0x05\r
-#define EFI_PCI_CAPABILITY_ID_HOTPLUG 0x06\r
-#define EFI_PCI_CAPABILITY_ID_PCIX    0x07\r
-//\r
-// bugbug: this ID is defined in PCI spec v2.3\r
-//\r
-#define EFI_PCI_CAPABILITY_ID_PCIEXP  0x10\r
-\r
-typedef struct {\r
-  UINT8 CapabilityID;\r
-  UINT8 NextItemPtr;\r
-} EFI_PCI_CAPABILITY_HDR;\r
-\r
-//\r
-// Capability EFI_PCI_CAPABILITY_ID_PMI\r
-//\r
-typedef struct {\r
-  EFI_PCI_CAPABILITY_HDR  Hdr;\r
-  UINT16                  PMC;\r
-  UINT16                  PMCSR;\r
-  UINT8                   BridgeExtention;\r
-  UINT8                   Data;\r
-} EFI_PCI_CAPABILITY_PMI;\r
-\r
-//\r
-// Capability EFI_PCI_CAPABILITY_ID_AGP\r
-//\r
-typedef struct {\r
-  EFI_PCI_CAPABILITY_HDR  Hdr;\r
-  UINT8                   Rev;\r
-  UINT8                   Reserved;\r
-  UINT32                  Status;\r
-  UINT32                  Command;\r
-} EFI_PCI_CAPABILITY_AGP;\r
-\r
-//\r
-// Capability EFI_PCI_CAPABILITY_ID_VPD\r
-//\r
-typedef struct {\r
-  EFI_PCI_CAPABILITY_HDR  Hdr;\r
-  UINT16                  AddrReg;\r
-  UINT32                  DataReg;\r
-} EFI_PCI_CAPABILITY_VPD;\r
-\r
-//\r
-// Capability EFI_PCI_CAPABILITY_ID_SLOTID\r
-//\r
-typedef struct {\r
-  EFI_PCI_CAPABILITY_HDR  Hdr;\r
-  UINT8                   ExpnsSlotReg;\r
-  UINT8                   ChassisNo;\r
-} EFI_PCI_CAPABILITY_SLOTID;\r
-\r
-//\r
-// Capability EFI_PCI_CAPABILITY_ID_MSI\r
-//\r
-typedef struct {\r
-  EFI_PCI_CAPABILITY_HDR  Hdr;\r
-  UINT16                  MsgCtrlReg;\r
-  UINT32                  MsgAddrReg;\r
-  UINT16                  MsgDataReg;\r
-} EFI_PCI_CAPABILITY_MSI32;\r
-\r
-typedef struct {\r
-  EFI_PCI_CAPABILITY_HDR  Hdr;\r
-  UINT16                  MsgCtrlReg;\r
-  UINT32                  MsgAddrRegLsdw;\r
-  UINT32                  MsgAddrRegMsdw;\r
-  UINT16                  MsgDataReg;\r
-} EFI_PCI_CAPABILITY_MSI64;\r
-\r
-//\r
-// Capability EFI_PCI_CAPABILITY_ID_HOTPLUG\r
-//\r
-typedef struct {\r
-  EFI_PCI_CAPABILITY_HDR  Hdr;\r
-  //\r
-  // not finished - fields need to go here\r
-  //\r
-} EFI_PCI_CAPABILITY_HOTPLUG;\r
-\r
-//\r
-// Capability EFI_PCI_CAPABILITY_ID_PCIX\r
-//\r
-typedef struct {\r
-  EFI_PCI_CAPABILITY_HDR  Hdr;\r
-  UINT16                  CommandReg;\r
-  UINT32                  StatusReg;\r
-} EFI_PCI_CAPABILITY_PCIX;\r
-\r
-typedef struct {\r
-  EFI_PCI_CAPABILITY_HDR  Hdr;\r
-  UINT16                  SecStatusReg;\r
-  UINT32                  StatusReg;\r
-  UINT32                  SplitTransCtrlRegUp;\r
-  UINT32                  SplitTransCtrlRegDn;\r
-} EFI_PCI_CAPABILITY_PCIX_BRDG;\r
-\r
-#define DEVICE_ID_NOCARE    0xFFFF\r
-\r
-#define PCI_ACPI_UNUSED     0\r
-#define PCI_BAR_NOCHANGE    0\r
-#define PCI_BAR_OLD_ALIGN   0xFFFFFFFFFFFFFFFFULL\r
-#define PCI_BAR_EVEN_ALIGN  0xFFFFFFFFFFFFFFFEULL\r
-#define PCI_BAR_SQUAD_ALIGN 0xFFFFFFFFFFFFFFFDULL\r
-#define PCI_BAR_DQUAD_ALIGN 0xFFFFFFFFFFFFFFFCULL\r
-\r
-#define PCI_BAR_IDX0        0x00\r
-#define PCI_BAR_IDX1        0x01\r
-#define PCI_BAR_IDX2        0x02\r
-#define PCI_BAR_IDX3        0x03\r
-#define PCI_BAR_IDX4        0x04\r
-#define PCI_BAR_IDX5        0x05\r
-#define PCI_BAR_ALL         0xFF\r
-\r
-#pragma pack(pop)\r
-\r
-#endif\r
diff --git a/Tools/CodeTools/TianoTools/Include/Library/PeCoffLib.h b/Tools/CodeTools/TianoTools/Include/Library/PeCoffLib.h
deleted file mode 100644 (file)
index 08e8195..0000000
+++ /dev/null
@@ -1,131 +0,0 @@
-/** @file\r
-       Memory Only PE COFF loader\r
-\r
-       Copyright (c) 2006, Intel Corporation                                                         \r
-       All rights reserved. This program and the accompanying materials                          \r
-       are licensed and made available under the terms and conditions of the BSD License         \r
-       which accompanies this distribution.  The full text of the license may be found at        \r
-       http://opensource.org/licenses/bsd-license.php                                            \r
-\r
-       THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-       WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-       Module Name:    PeCoffLib.h\r
-\r
-**/\r
-\r
-#ifndef __BASE_PE_COFF_LIB_H__\r
-#define __BASE_PE_COFF_LIB_H__\r
-\r
-//\r
-// Return status codes from the PE/COFF Loader services\r
-// BUGBUG: Find where used and see if can be replaced by RETURN_STATUS codes\r
-//\r
-#define IMAGE_ERROR_SUCCESS                      0\r
-#define IMAGE_ERROR_IMAGE_READ                   1  \r
-#define IMAGE_ERROR_INVALID_PE_HEADER_SIGNATURE  2\r
-#define IMAGE_ERROR_INVALID_MACHINE_TYPE         3\r
-#define IMAGE_ERROR_INVALID_SUBSYSTEM            4\r
-#define IMAGE_ERROR_INVALID_IMAGE_ADDRESS        5\r
-#define IMAGE_ERROR_INVALID_IMAGE_SIZE           6\r
-#define IMAGE_ERROR_INVALID_SECTION_ALIGNMENT    7\r
-#define IMAGE_ERROR_SECTION_NOT_LOADED           8\r
-#define IMAGE_ERROR_FAILED_RELOCATION            9\r
-#define IMAGE_ERROR_FAILED_ICACHE_FLUSH          10\r
-\r
-\r
-//\r
-// PE/COFF Loader Read Function passed in by caller\r
-//\r
-typedef\r
-RETURN_STATUS\r
-(EFIAPI *PE_COFF_LOADER_READ_FILE) (\r
-  IN     VOID   *FileHandle,\r
-  IN     UINTN  FileOffset,\r
-  IN OUT UINTN  *ReadSize,\r
-  OUT    VOID   *Buffer\r
-  );\r
-\r
-//\r
-// Context structure used while PE/COFF image is being loaded and relocated\r
-//\r
-typedef struct {\r
-  PHYSICAL_ADDRESS                  ImageAddress;\r
-  UINT64                            ImageSize;\r
-  PHYSICAL_ADDRESS                  DestinationAddress;\r
-  PHYSICAL_ADDRESS                  EntryPoint;\r
-  PE_COFF_LOADER_READ_FILE          ImageRead;\r
-  VOID                              *Handle;\r
-  VOID                              *FixupData;\r
-  UINT32                            SectionAlignment;\r
-  UINT32                            PeCoffHeaderOffset;\r
-  UINT32                            DebugDirectoryEntryRva;\r
-  VOID                              *CodeView;\r
-  CHAR8                             *PdbPointer;\r
-  UINTN                             SizeOfHeaders;\r
-  UINT32                            ImageCodeMemoryType;\r
-  UINT32                            ImageDataMemoryType;\r
-  UINT32                            ImageError;\r
-  UINTN                             FixupDataSize;\r
-  UINT16                            Machine;\r
-  UINT16                            ImageType;\r
-  BOOLEAN                           RelocationsStripped;\r
-  BOOLEAN                           IsTeImage;\r
-} PE_COFF_LOADER_IMAGE_CONTEXT;\r
-\r
-\r
-/**\r
-       Retrieves information on a PE/COFF image\r
-\r
-       @param  ImageContext The context of the image being loaded\r
-\r
-       @retval EFI_SUCCESS The information on the PE/COFF image was collected.\r
-       @retval EFI_INVALID_PARAMETER ImageContext is NULL.\r
-       @retval EFI_UNSUPPORTED The PE/COFF image is not supported.\r
-       @retval Otherwise The error status from reading the PE/COFF image using the\r
-       ImageContext->ImageRead() function\r
-\r
-**/\r
-RETURN_STATUS\r
-EFIAPI\r
-PeCoffLoaderGetImageInfo (\r
-  IN OUT PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext\r
-  )\r
-;\r
-\r
-/**\r
-       Relocates a PE/COFF image in memory\r
-\r
-       @param  ImageContext Contains information on the loaded image to relocate\r
-\r
-       @retval EFI_SUCCESS      if the PE/COFF image was relocated\r
-       @retval EFI_LOAD_ERROR   if the image is not a valid PE/COFF image\r
-       @retval EFI_UNSUPPORTED  not support\r
-\r
-**/\r
-RETURN_STATUS\r
-EFIAPI\r
-PeCoffLoaderRelocateImage (\r
-  IN OUT PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext\r
-  )\r
-;\r
-\r
-/**\r
-       Loads a PE/COFF image into memory\r
-\r
-       @param  ImageContext Contains information on image to load into memory\r
-\r
-       @retval EFI_SUCCESS            if the PE/COFF image was loaded\r
-       @retval EFI_BUFFER_TOO_SMALL   if the caller did not provide a large enough buffer\r
-       @retval EFI_LOAD_ERROR         if the image is a runtime driver with no relocations\r
-       @retval EFI_INVALID_PARAMETER  if the image address is invalid\r
-\r
-**/\r
-RETURN_STATUS\r
-EFIAPI\r
-PeCoffLoaderLoadImage (\r
-  IN OUT PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext\r
-  )\r
-;\r
-\r
-#endif\r
diff --git a/Tools/CodeTools/TianoTools/Include/Library/PrintLib.h b/Tools/CodeTools/TianoTools/Include/Library/PrintLib.h
deleted file mode 100644 (file)
index 9c65459..0000000
+++ /dev/null
@@ -1,406 +0,0 @@
-/** @file\r
-       Library that provides print services\r
-\r
-       Copyright (c) 2006, Intel Corporation                                                         \r
-       All rights reserved. This program and the accompanying materials                          \r
-       are licensed and made available under the terms and conditions of the BSD License         \r
-       which accompanies this distribution.  The full text of the license may be found at        \r
-       http://opensource.org/licenses/bsd-license.php                                            \r
-\r
-       THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-       WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-       Module Name:    PrintLib.h\r
-\r
-**/\r
-\r
-#ifndef __PRINT_LIB_H__\r
-#define __PRINT_LIB_H__\r
-\r
-//\r
-// Print primitives\r
-//\r
-#define LEFT_JUSTIFY      0x01\r
-#define COMMA_TYPE        0x08\r
-#define PREFIX_ZERO       0x20\r
-\r
-/**\r
-  Produces a Null-terminated Unicode string in an output buffer based on \r
-  a Null-terminated Unicode format string and a VA_LIST argument list\r
-  \r
-  Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer\r
-  and BufferSize.  \r
-  The Unicode string is produced by parsing the format string specified by FormatString.  \r
-  Arguments are pulled from the variable argument list specified by Marker based on the \r
-  contents of the format string.  \r
-  The length of the produced output buffer is returned.\r
-  If BufferSize is 0, then no output buffer is produced and 0 is returned.\r
-\r
-  If BufferSize is not 0 and StartOfBuffer is NULL, then ASSERT().\r
-  If BufferSize is not 0 and FormatString is NULL, then ASSERT().\r
-  If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than \r
-  PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().\r
-  If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string\r
-  contains more than PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().\r
-\r
-  @param  StartOfBuffer   APointer to the output buffer for the produced Null-terminated \r
-                          Unicode string.\r
-  @param  BufferSize      The size, in bytes, of the output buffer specified by StartOfBuffer.\r
-  @param  FormatString    Null-terminated Unicode format string.\r
-  @param  Marker          VA_LIST marker for the variable argument list.\r
-  \r
-  @return return Length of the produced output buffer.\r
-\r
-**/\r
-UINTN\r
-EFIAPI\r
-UnicodeVSPrint (\r
-  OUT CHAR16        *StartOfBuffer,\r
-  IN  UINTN         BufferSize,\r
-  IN  CONST CHAR16  *FormatString,\r
-  IN  VA_LIST       Marker\r
-  );\r
-\r
-/**\r
-  Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated \r
-  Unicode format string and variable argument list.\r
-  \r
-  Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer\r
-  and BufferSize.\r
-  The Unicode string is produced by parsing the format string specified by FormatString.\r
-  Arguments are pulled from the variable argument list based on the contents of the format string.\r
-  The length of the produced output buffer is returned.  \r
-  If BufferSize is 0, then no output buffer is produced and 0 is returned.\r
-\r
-  If BufferSize is not 0 and StartOfBuffer is NULL, then ASSERT().\r
-  If BufferSize is not 0 and FormatString is NULL, then ASSERT().\r
-  If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than \r
-  PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().\r
-  If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string\r
-  contains more than PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().\r
-\r
-  @param  StartOfBuffer   APointer to the output buffer for the produced Null-terminated \r
-                          Unicode string.\r
-  @param  BufferSize      The size, in bytes, of the output buffer specified by StartOfBuffer.\r
-  @param  FormatString    Null-terminated Unicode format string.\r
-  \r
-  @return Length of the produced output buffer.\r
-\r
-**/\r
-UINTN\r
-EFIAPI\r
-UnicodeSPrint (\r
-  OUT CHAR16        *StartOfBuffer,\r
-  IN  UINTN         BufferSize,\r
-  IN  CONST CHAR16  *FormatString,\r
-  ...\r
-  );\r
-\r
-/**\r
-  Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated\r
-  ASCII format string and a VA_LIST argument list\r
-  \r
-  Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer\r
-  and BufferSize.\r
-  The Unicode string is produced by parsing the format string specified by FormatString.\r
-  Arguments are pulled from the variable argument list specified by Marker based on the \r
-  contents of the format string.\r
-  The length of the produced output buffer is returned.\r
-  If BufferSize is 0, then no output buffer is produced and 0 is returned.\r
-\r
-  If BufferSize is not 0 and StartOfBuffer is NULL, then ASSERT().\r
-  If BufferSize is not 0 and FormatString is NULL, then ASSERT().\r
-  If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than \r
-  PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().\r
-  If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string\r
-  contains more than PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().\r
-\r
-  @param  StartOfBuffer   APointer to the output buffer for the produced Null-terminated \r
-                          Unicode string.\r
-  @param  BufferSize      The size, in bytes, of the output buffer specified by StartOfBuffer.\r
-  @param  FormatString    Null-terminated Unicode format string.\r
-  @param  Marker          VA_LIST marker for the variable argument list.\r
-  \r
-  @return Length of the produced output buffer.\r
-\r
-**/\r
-UINTN\r
-EFIAPI\r
-UnicodeVSPrintAsciiFormat (\r
-  OUT CHAR16       *StartOfBuffer,\r
-  IN  UINTN        BufferSize,\r
-  IN  CONST CHAR8  *FormatString,\r
-  IN  VA_LIST      Marker\r
-  );\r
-\r
-/**\r
-  Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated \r
-  ASCII format string and  variable argument list.\r
-  \r
-  Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer\r
-  and BufferSize.\r
-  The Unicode string is produced by parsing the format string specified by FormatString.\r
-  Arguments are pulled from the variable argument list based on the contents of the \r
-  format string.\r
-  The length of the produced output buffer is returned.\r
-  If BufferSize is 0, then no output buffer is produced and 0 is returned.\r
-\r
-  If BufferSize is not 0 and StartOfBuffer is NULL, then ASSERT().\r
-  If BufferSize is not 0 and FormatString is NULL, then ASSERT().\r
-  If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than \r
-  PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().\r
-  If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string\r
-  contains more than PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().\r
-\r
-  @param  StartOfBuffer   APointer to the output buffer for the produced Null-terminated \r
-                          Unicode string.\r
-  @param  BufferSize      The size, in bytes, of the output buffer specified by StartOfBuffer.\r
-  @param  FormatString    Null-terminated Unicode format string.\r
-  \r
-  @return Length of the produced output buffer.\r
-\r
-**/\r
-UINTN\r
-EFIAPI\r
-UnicodeSPrintAsciiFormat (\r
-  OUT CHAR16       *StartOfBuffer,\r
-  IN  UINTN        BufferSize,\r
-  IN  CONST CHAR8  *FormatString,\r
-  ...\r
-  );\r
-\r
-/**\r
-  Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated\r
-  ASCII format string and a VA_LIST argument list.\r
-  \r
-  Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer\r
-  and BufferSize.\r
-  The ASCII string is produced by parsing the format string specified by FormatString.\r
-  Arguments are pulled from the variable argument list specified by Marker based on \r
-  the contents of the format string.\r
-  The length of the produced output buffer is returned.\r
-  If BufferSize is 0, then no output buffer is produced and 0 is returned.\r
-\r
-  If BufferSize is not 0 and StartOfBuffer is NULL, then ASSERT().\r
-  If BufferSize is not 0 and FormatString is NULL, then ASSERT().\r
-  If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than \r
-  PcdMaximumUnicodeStringLength ASCII characters, then ASSERT().\r
-  If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string\r
-  contains more than PcdMaximumUnicodeStringLength ASCII characters, then ASSERT().\r
-\r
-  @param  StartOfBuffer   APointer to the output buffer for the produced Null-terminated \r
-                          ASCII string.\r
-  @param  BufferSize      The size, in bytes, of the output buffer specified by StartOfBuffer.\r
-  @param  FormatString    Null-terminated Unicode format string.\r
-  @param  Marker          VA_LIST marker for the variable argument list.\r
-  \r
-  @return Length of the produced output buffer.\r
-\r
-**/\r
-UINTN\r
-EFIAPI\r
-AsciiVSPrint (\r
-  OUT CHAR8         *StartOfBuffer,\r
-  IN  UINTN         BufferSize,\r
-  IN  CONST CHAR8   *FormatString,\r
-  IN  VA_LIST       Marker\r
-  );\r
-\r
-/**\r
-  Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated\r
-  ASCII format string and  variable argument list.\r
-  \r
-  Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer\r
-  and BufferSize.\r
-  The ASCII string is produced by parsing the format string specified by FormatString.\r
-  Arguments are pulled from the variable argument list based on the contents of the \r
-  format string.\r
-  The length of the produced output buffer is returned.\r
-  If BufferSize is 0, then no output buffer is produced and 0 is returned.\r
-\r
-  If BufferSize is not 0 and StartOfBuffer is NULL, then ASSERT().\r
-  If BufferSize is not 0 and FormatString is NULL, then ASSERT().\r
-  If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than \r
-  PcdMaximumUnicodeStringLength ASCII characters, then ASSERT().\r
-  If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string\r
-  contains more than PcdMaximumUnicodeStringLength ASCII characters, then ASSERT().\r
-\r
-  @param  StartOfBuffer   APointer to the output buffer for the produced Null-terminated \r
-                          ASCII string.\r
-  @param  BufferSize      The size, in bytes, of the output buffer specified by StartOfBuffer.\r
-  @param  FormatString    Null-terminated Unicode format string.\r
-  \r
-  @return Length of the produced output buffer.\r
-\r
-**/\r
-UINTN\r
-EFIAPI\r
-AsciiSPrint (\r
-  OUT CHAR8        *StartOfBuffer,\r
-  IN  UINTN        BufferSize,\r
-  IN  CONST CHAR8  *FormatString,\r
-  ...\r
-  );\r
-\r
-/**\r
-  Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated\r
-  ASCII format string and a VA_LIST argument list.\r
-  \r
-  Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer\r
-  and BufferSize.\r
-  The ASCII string is produced by parsing the format string specified by FormatString.\r
-  Arguments are pulled from the variable argument list specified by Marker based on \r
-  the contents of the format string.\r
-  The length of the produced output buffer is returned.\r
-  If BufferSize is 0, then no output buffer is produced and 0 is returned.\r
-\r
-  If BufferSize is not 0 and StartOfBuffer is NULL, then ASSERT().\r
-  If BufferSize is not 0 and FormatString is NULL, then ASSERT().\r
-  If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than \r
-  PcdMaximumUnicodeStringLength ASCII characters, then ASSERT().\r
-  If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string\r
-  contains more than PcdMaximumUnicodeStringLength ASCII characters, then ASSERT().\r
-\r
-  @param  StartOfBuffer   APointer to the output buffer for the produced Null-terminated \r
-                          ASCII string.\r
-  @param  BufferSize      The size, in bytes, of the output buffer specified by StartOfBuffer.\r
-  @param  FormatString    Null-terminated Unicode format string.\r
-  @param  Marker          VA_LIST marker for the variable argument list.\r
-  \r
-  @return Length of the produced output buffer.\r
-\r
-**/\r
-UINTN\r
-EFIAPI\r
-AsciiVSPrintUnicodeFormat (\r
-  OUT CHAR8         *StartOfBuffer,\r
-  IN  UINTN         BufferSize,\r
-  IN  CONST CHAR16  *FormatString,\r
-  IN  VA_LIST       Marker\r
-  );\r
-\r
-/**\r
-  Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated\r
-  ASCII format string and  variable argument list.\r
-  \r
-  Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer\r
-  and BufferSize.\r
-  The ASCII string is produced by parsing the format string specified by FormatString.\r
-  Arguments are pulled from the variable argument list based on the contents of the \r
-  format string.\r
-  The length of the produced output buffer is returned.\r
-  If BufferSize is 0, then no output buffer is produced and 0 is returned.\r
-\r
-  If BufferSize is not 0 and StartOfBuffer is NULL, then ASSERT().\r
-  If BufferSize is not 0 and FormatString is NULL, then ASSERT().\r
-  If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than \r
-  PcdMaximumUnicodeStringLength ASCII characters, then ASSERT().\r
-  If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string\r
-  contains more than PcdMaximumUnicodeStringLength ASCII characters, then ASSERT().\r
-\r
-  @param  StartOfBuffer   APointer to the output buffer for the produced Null-terminated \r
-                          ASCII string.\r
-  @param  BufferSize      The size, in bytes, of the output buffer specified by StartOfBuffer.\r
-  @param  FormatString    Null-terminated Unicode format string.\r
-  \r
-  @return Length of the produced output buffer.\r
-\r
-**/\r
-UINTN\r
-EFIAPI\r
-AsciiSPrintUnicodeFormat (\r
-  OUT CHAR8         *StartOfBuffer,\r
-  IN  UINTN         BufferSize,\r
-  IN  CONST CHAR16  *FormatString,\r
-  ...\r
-  );\r
-\r
-/**\r
-  Converts a decimal value to a Null-terminated Unicode string.\r
-  \r
-  Converts the decimal number specified by Value to a Null-terminated Unicode \r
-  string specified by Buffer containing at most Width characters.\r
-  If Width is 0 then a width of  MAXIMUM_VALUE_CHARACTERS is assumed.\r
-  The total number of characters placed in Buffer is returned.\r
-  If the conversion contains more than Width characters, then only the first\r
-  Width characters are returned, and the total number of characters \r
-  required to perform the conversion is returned.\r
-  Additional conversion parameters are specified in Flags.  \r
-  The Flags bit LEFT_JUSTIFY is always ignored.\r
-  All conversions are left justified in Buffer.\r
-  If Width is 0, PREFIX_ZERO is ignored in Flags.\r
-  If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and commas\r
-  are inserted every 3rd digit starting from the right.\r
-  If Value is < 0, then the fist character in Buffer is a '-'.\r
-  If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored, \r
-  then Buffer is padded with '0' characters so the combination of the optional '-' \r
-  sign character, '0' characters, digit characters for Value, and the Null-terminator\r
-  add up to Width characters.\r
-\r
-  If Buffer is NULL, then ASSERT().\r
-  If unsupported bits are set in Flags, then ASSERT().\r
-  If Width >= MAXIMUM_VALUE_CHARACTERS, then ASSERT()\r
-\r
-  @param  Buffer  Pointer to the output buffer for the produced Null-terminated\r
-                  Unicode string.\r
-  @param  Flags   The bitmask of flags that specify left justification, zero pad, and commas.\r
-  @param  Value   The 64-bit signed value to convert to a string.\r
-  @param  Width          The maximum number of Unicode characters to place in Buffer.\r
-  \r
-  @return Total number of characters required to perform the conversion.\r
-\r
-**/\r
-UINTN\r
-EFIAPI\r
-UnicodeValueToString (\r
-  IN OUT CHAR16  *Buffer,\r
-  IN UINTN       Flags,\r
-  IN INT64       Value,\r
-  IN UINTN       Width\r
-  );\r
-\r
-/**\r
-  Converts a decimal value to a Null-terminated ASCII string.\r
-  \r
-  Converts the decimal number specified by Value to a Null-terminated ASCII string \r
-  specified by Buffer containing at most Width characters.\r
-  If Width is 0 then a width of  MAXIMUM_VALUE_CHARACTERS is assumed.\r
-  The total number of characters placed in Buffer is returned.\r
-  If the conversion contains more than Width characters, then only the first Width\r
-  characters are returned, and the total number of characters required to perform\r
-  the conversion is returned.\r
-  Additional conversion parameters are specified in Flags.  \r
-  The Flags bit LEFT_JUSTIFY is always ignored.\r
-  All conversions are left justified in Buffer.\r
-  If Width is 0, PREFIX_ZERO is ignored in Flags.\r
-  If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and commas \r
-  are inserted every 3rd digit starting from the right.\r
-  If Value is < 0, then the fist character in Buffer is a '-'.\r
-  If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored, then Buffer\r
-  is padded with '0' characters so the combination of the optional '-'\r
-  sign character, '0' characters, digit characters for Value, and the \r
-  Null-terminator add up to Width characters.\r
-\r
-  If Buffer is NULL, then ASSERT().\r
-  If unsupported bits are set in Flags, then ASSERT().\r
-  If Width >= MAXIMUM_VALUE_CHARACTERS, then ASSERT()\r
-\r
-  @param  Buffer  Pointer to the output buffer for the produced Null-terminated\r
-                  ASCII string.\r
-  @param  Flags   The bitmask of flags that specify left justification, zero pad, and commas.\r
-  @param  Value   The 64-bit signed value to convert to a string.\r
-  @param  Width          The maximum number of ASCII characters to place in Buffer.\r
-  \r
-  @return Total number of characters required to perform the conversion.\r
-\r
-**/\r
-UINTN\r
-EFIAPI\r
-AsciiValueToString (\r
-  IN OUT CHAR8  *Buffer,\r
-  IN UINTN      Flags,\r
-  IN INT64      Value,\r
-  IN UINTN      Width\r
-  );\r
-\r
-#endif\r
diff --git a/Tools/CodeTools/TianoTools/Include/Protocol/DevicePath.h b/Tools/CodeTools/TianoTools/Include/Protocol/DevicePath.h
deleted file mode 100644 (file)
index d019999..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-/** @file\r
-  The device path protocol as defined in EFI 1.0.\r
-\r
-  The device path represents a programatic path to a device. It's the view\r
-  from a software point of view. It also must persist from boot to boot, so \r
-  it can not contain things like PCI bus numbers that change from boot to boot.\r
-\r
-  Copyright (c) 2006, Intel Corporation                                                         \r
-  All rights reserved. This program and the accompanying materials                          \r
-  are licensed and made available under the terms and conditions of the BSD License         \r
-  which accompanies this distribution.  The full text of the license may be found at        \r
-  http://opensource.org/licenses/bsd-license.php                                            \r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-  Module Name:  DevicePath.h\r
-\r
-**/\r
-\r
-#ifndef __EFI_DEVICE_PATH_PROTOCOL_H__\r
-#define __EFI_DEVICE_PATH_PROTOCOL_H__\r
-\r
-//\r
-// Device Path protocol\r
-//\r
-#define EFI_DEVICE_PATH_PROTOCOL_GUID \\r
-  { \\r
-    0x9576e91, 0x6d3f, 0x11d2, {0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b } \\r
-  }\r
-\r
-#pragma pack(1)\r
-\r
-typedef struct {\r
-  UINT8 Type;\r
-  UINT8 SubType;\r
-  UINT8 Length[2];\r
-} EFI_DEVICE_PATH_PROTOCOL;\r
-\r
-#pragma pack()\r
-                                             \r
-#define EFI_DP_TYPE_MASK                     0x7F\r
-#define EFI_DP_TYPE_UNPACKED                 0x80\r
-#define END_DEVICE_PATH_TYPE                 0x7f\r
-                                             \r
-#define EFI_END_ENTIRE_DEVICE_PATH           0xff\r
-#define EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE   0xff\r
-#define EFI_END_INSTANCE_DEVICE_PATH         0x01\r
-#define END_ENTIRE_DEVICE_PATH_SUBTYPE       EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE\r
-#define END_INSTANCE_DEVICE_PATH_SUBTYPE     EFI_END_INSTANCE_DEVICE_PATH\r
-                                             \r
-#define EFI_END_DEVICE_PATH_LENGTH           (sizeof (EFI_DEVICE_PATH_PROTOCOL))\r
-#define END_DEVICE_PATH_LENGTH               EFI_END_DEVICE_PATH_LENGTH\r
-                                             \r
-#define DP_IS_END_TYPE(a)                    \r
-#define DP_IS_END_SUBTYPE(a)                 (((a)->SubType == END_ENTIRE_DEVICE_PATH_SUBTYPE)\r
-#define DevicePathSubType(a)                 ((a)->SubType)\r
-#define IsDevicePathUnpacked(a)              ((a)->Type & EFI_DP_TYPE_UNPACKED)\r
-                                             \r
-#define EfiDevicePathNodeLength(a)           (((a)->Length[0]) | ((a)->Length[1] << 8))\r
-#define DevicePathNodeLength(a)              (EfiDevicePathNodeLength(a))\r
-#define EfiNextDevicePathNode(a)             ((EFI_DEVICE_PATH_PROTOCOL *) (((UINT8 *) (a)) + EfiDevicePathNodeLength (a)))\r
-#define NextDevicePathNode(a)                (EfiNextDevicePathNode(a)) \r
-                                             \r
-#define EfiDevicePathType(a)                 (((a)->Type) & EFI_DP_TYPE_MASK)\r
-#define DevicePathType(a)                    (EfiDevicePathType(a))\r
-#define EfiIsDevicePathEndType(a)            (EfiDevicePathType (a) == END_DEVICE_PATH_TYPE)\r
-#define IsDevicePathEndType(a)               (EfiIsDevicePathEndType(a)) \r
-                                             \r
-                                             \r
-#define EfiIsDevicePathEndSubType(a)         ((a)->SubType == EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE)\r
-#define IsDevicePathEndSubType(a)            (EfiIsDevicePathEndSubType(a))\r
-#define EfiIsDevicePathEndInstanceSubType(a) ((a)->SubType == EFI_END_INSTANCE_DEVICE_PATH)\r
-                                             \r
-#define EfiIsDevicePathEnd(a)                (EfiIsDevicePathEndType (a) && EfiIsDevicePathEndSubType (a))\r
-#define IsDevicePathEnd(a)                   (EfiIsDevicePathEnd(a))\r
-#define EfiIsDevicePathEndInstance(a)        (EfiIsDevicePathEndType (a) && EfiIsDevicePathEndInstanceSubType (a))\r
-\r
-\r
-#define SetDevicePathNodeLength(a,l) {                           \\r
-          (a)->Length[0] = (UINT8) (l);                          \\r
-          (a)->Length[1] = (UINT8) ((l) >> 8);                   \\r
-          }\r
-\r
-#define SetDevicePathEndNode(a)  {                               \\r
-          (a)->Type = END_DEVICE_PATH_TYPE;                      \\r
-          (a)->SubType = END_ENTIRE_DEVICE_PATH_SUBTYPE;         \\r
-          (a)->Length[0] = sizeof(EFI_DEVICE_PATH_PROTOCOL);     \\r
-          (a)->Length[1] = 0;                                    \\r
-          }\r
-\r
-extern EFI_GUID gEfiDevicePathProtocolGuid;\r
-\r
-#endif\r
diff --git a/Tools/CodeTools/TianoTools/Include/Protocol/GuidedSectionExtraction.h b/Tools/CodeTools/TianoTools/Include/Protocol/GuidedSectionExtraction.h
deleted file mode 100644 (file)
index d98c56a..0000000
+++ /dev/null
@@ -1,102 +0,0 @@
-/** @file\r
-  This file declares GUIDed section extraction protocol.\r
-\r
-  This interface provides a means of decoding a GUID defined encapsulation \r
-  section. There may be multiple different GUIDs associated with the GUIDed\r
-  section extraction protocol. That is, all instances of the GUIDed section\r
-  extraction protocol must have the same interface structure.\r
-\r
-  Copyright (c) 2006, Intel Corporation                                                         \r
-  All rights reserved. This program and the accompanying materials                          \r
-  are licensed and made available under the terms and conditions of the BSD License         \r
-  which accompanies this distribution.  The full text of the license may be found at        \r
-  http://opensource.org/licenses/bsd-license.php                                            \r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-  Module Name:  GuidedSectionExtraction.h\r
-\r
-  @par Revision Reference:\r
-  This protocol is defined in Firmware Volume Specification.\r
-  Version 0.9\r
-\r
-**/\r
-\r
-#ifndef __GUIDED_SECTION_EXTRACTION_PROTOCOL_H__\r
-#define __GUIDED_SECTION_EXTRACTION_PROTOCOL_H__\r
-\r
-\r
-//\r
-// Protocol GUID definition. Each GUIDed section extraction protocol has the\r
-// same interface but with different GUID. All the GUIDs is defined here.\r
-// May add multiple GUIDs here.\r
-//\r
-#define EFI_CRC32_GUIDED_SECTION_EXTRACTION_PROTOCOL_GUID \\r
-  { \\r
-    0xFC1BCDB0, 0x7D31, 0x49aa, {0x93, 0x6A, 0xA4, 0x60, 0x0D, 0x9D, 0xD0, 0x83 } \\r
-  }\r
-\r
-//\r
-// Forward reference for pure ANSI compatability\r
-//\r
-typedef struct _EFI_GUIDED_SECTION_EXTRACTION_PROTOCOL  EFI_GUIDED_SECTION_EXTRACTION_PROTOCOL;\r
-\r
-//\r
-// Protocol member functions\r
-//\r
-/**\r
-  Processes the input section and returns the data contained therein along \r
-  with the authentication status.\r
-\r
-  @param  This                  Indicates the EFI_GUIDED_SECTION_EXTRACTION_PROTOCOL instance.  \r
-  @param  InputSection          Buffer containing the input GUIDed section to be processed.  \r
-  @param  OutputBuffer          *OutputBuffer is allocated from boot services pool memory \r
-                                and contains the new section stream.  \r
-  @param  OutputSize            A pointer to a caller-allocated UINTN in which the size \r
-                                of *OutputBuffer allocation is stored.   \r
-  @param  AuthenticationStatus  A pointer to a caller-allocated UINT32 that \r
-                                indicates the authentication status of the output buffer.\r
-                                \r
-  @retval EFI_SUCCESS           The InputSection was successfully processed and the \r
-                                section contents were returned.\r
-  @retval EFI_OUT_OF_RESOURCES  The system has insufficient resources to \r
-                                process the request.\r
-  @retval EFI_INVALID_PARAMETER The GUID in InputSection does not match \r
-                                this instance of the GUIDed Section Extraction Protocol.\r
-\r
-**/\r
-\r
-typedef\r
-EFI_STATUS\r
-(EFIAPI *EFI_EXTRACT_GUIDED_SECTION) (\r
-  IN  EFI_GUIDED_SECTION_EXTRACTION_PROTOCOL          *This,\r
-  IN  VOID                                            *InputSection,\r
-  OUT VOID                                            **OutputBuffer,\r
-  OUT UINTN                                           *OutputSize,\r
-  OUT UINT32                                          *AuthenticationStatus\r
-  );\r
-\r
-//\r
-// Protocol definition\r
-//\r
-/**\r
-  @par Protocol Description:\r
-  If a GUID-defined section is encountered when doing section extraction, \r
-  the section extraction driver calls the appropriate instance of the GUIDed \r
-  Section Extraction Protocol to extract the section stream contained therein.\r
-\r
-  @param ExtractSection\r
-  Takes the GUIDed section as input and produces the section stream data. \r
-\r
-**/\r
-struct _EFI_GUIDED_SECTION_EXTRACTION_PROTOCOL {\r
-  EFI_EXTRACT_GUIDED_SECTION  ExtractSection;\r
-};\r
-\r
-//\r
-// may add other GUID here\r
-//\r
-extern EFI_GUID gEfiCrc32GuidedSectionExtractionProtocolGuid;\r
-\r
-#endif\r
diff --git a/Tools/CodeTools/TianoTools/Include/Protocol/Hii.h b/Tools/CodeTools/TianoTools/Include/Protocol/Hii.h
deleted file mode 100644 (file)
index ceeba1c..0000000
+++ /dev/null
@@ -1,1024 +0,0 @@
-/** @file\r
-  This file defines the Human Interface Infrastructure protocol which will \r
-  be used by resources which want to publish IFR/Font/String data and have it \r
-  collected by the Configuration engine.\r
-\r
-  Copyright (c) 2006, Intel Corporation                                                         \r
-  All rights reserved. This program and the accompanying materials                          \r
-  are licensed and made available under the terms and conditions of the BSD License         \r
-  which accompanies this distribution.  The full text of the license may be found at        \r
-  http://opensource.org/licenses/bsd-license.php                                            \r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-  Module Name:  Hii.h\r
-\r
-  @par Revision Reference:\r
-  This protocol is defined in HII spec 0.92.\r
-\r
-**/\r
-\r
-#ifndef __HII_H__\r
-#define __HII_H__\r
-\r
-\r
-#define EFI_HII_PROTOCOL_GUID \\r
-  { \\r
-    0xea816d2c, 0xcee5, 0x4f02, {0x99, 0xb5, 0xd3, 0x90, 0x5c, 0xbb, 0xd0, 0x77 } \\r
-  }\r
-\r
-// BugBug:\r
-//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\r
-// If UGA goes away we need to put this some place. I'm not sure where?\r
-//\r
-//typedef struct {\r
-//  UINT8 Blue;\r
-//  UINT8 Green;\r
-//  UINT8 Red;\r
-//  UINT8 Reserved;\r
-//} EFI_UGA_PIXEL;\r
-\r
-//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\r
-//\r
-\r
-typedef struct _EFI_HII_PROTOCOL  EFI_HII_PROTOCOL;\r
-\r
-//\r
-// Global definition\r
-//\r
-#define NARROW_CHAR         0xFFF0\r
-#define WIDE_CHAR           0xFFF1\r
-#define NON_BREAKING_CHAR   0xFFF2\r
-#define GLYPH_WIDTH         8\r
-#define GLYPH_HEIGHT        19\r
-\r
-#define EFI_HII_FONT        1\r
-#define EFI_HII_STRING      2\r
-#define EFI_HII_IFR         3\r
-#define EFI_HII_KEYBOARD    4\r
-#define EFI_HII_HANDLES     5\r
-#define EFI_HII_VARIABLE    6\r
-#define EFI_HII_DEVICE_PATH 7\r
-\r
-\r
-// References to string tokens must use this macro to enable scanning for\r
-// token usages.\r
-//\r
-#define STRING_TOKEN(t) t\r
-\r
-//\r
-// The following types are currently defined:\r
-//\r
-typedef UINT16  EFI_FORM_ID;\r
-typedef UINT16  EFI_FORM_LABEL;\r
-\r
-#pragma pack(1)\r
-\r
-typedef struct {\r
-  UINT32  Length;\r
-  UINT16  Type;\r
-} EFI_HII_PACK_HEADER;\r
-\r
-//\r
-// A form list consists of a large variety of structure\r
-// possibilities so to represent the binary blob of data\r
-// associated with a package of forms, we will assume a\r
-// pointer to a self-describing data buffer.\r
-//\r
-typedef struct {\r
-  EFI_HII_PACK_HEADER Header;\r
-} EFI_HII_IFR_PACK;\r
-\r
-typedef struct {\r
-  EFI_HII_PACK_HEADER Header;           // Must be filled in\r
-  EFI_HANDLE          ImageHandle;      // Must be filled in\r
-  EFI_HANDLE          DeviceHandle;     // Optional\r
-  EFI_HANDLE          ControllerHandle; // Optional\r
-  EFI_HANDLE          CallbackHandle;   // Optional\r
-  EFI_HANDLE          COBExportHandle;  // Optional\r
-} EFI_HII_HANDLE_PACK;\r
-\r
-//\r
-// ********************************************************\r
-// EFI_VARIABLE_CONTENTS\r
-// ********************************************************\r
-//\r
-typedef struct {\r
-  EFI_HII_PACK_HEADER Header;\r
-  EFI_GUID            VariableGuid;\r
-  UINT32              VariableNameLength;\r
-  UINT16              VariableId;\r
-  //\r
-  //  CHAR16                VariableName[]; //Null-terminated\r
-  //\r
-} EFI_HII_VARIABLE_PACK;\r
-\r
-//\r
-// ********************************************************\r
-// EFI_DEVICE_PATH_PACK\r
-// ********************************************************\r
-//\r
-typedef struct {\r
-  EFI_HII_PACK_HEADER Header;\r
-  //\r
-  //  EFI_DEVICE_PATH       DevicePath[];\r
-  //\r
-} EFI_HII_DEVICE_PATH_PACK;\r
-\r
-//\r
-// ********************************************************\r
-// EFI_HII_DATA_TABLE\r
-// ********************************************************\r
-//\r
-typedef struct {\r
-  EFI_HII_HANDLE  HiiHandle;\r
-  EFI_GUID        PackageGuid;\r
-  UINT32          DataTableSize;\r
-  UINT32          IfrDataOffset;\r
-  UINT32          StringDataOffset;\r
-  UINT32          VariableDataOffset;\r
-  UINT32          DevicePathOffset;\r
-  UINT32          NumberOfVariableData;\r
-  UINT32          NumberOfLanguages;\r
-  //\r
-  // EFI_HII_DEVICE_PATH_PACK DevicePath[];\r
-  // EFI_HII_VARIABLE_PACK VariableData[];\r
-  // EFI_HII_IFR_PACK IfrData;\r
-  // EFI_HII_STRING_PACK StringData[];\r
-  //\r
-} EFI_HII_DATA_TABLE;\r
-\r
-//\r
-// ********************************************************\r
-// EFI_HII_EXPORT_TABLE\r
-// ********************************************************\r
-//\r
-typedef struct {\r
-  UINT32    NumberOfHiiDataTables;\r
-  EFI_GUID  Revision;\r
-  //\r
-  // EFI_HII_DATA_TABLE HiiDataTable[];\r
-  //\r
-} EFI_HII_EXPORT_TABLE;\r
-\r
-typedef struct {\r
-  BOOLEAN               FormSetUpdate;      // If TRUE, next variable is significant\r
-  EFI_PHYSICAL_ADDRESS  FormCallbackHandle; // If not 0, will update Formset with this info\r
-  BOOLEAN               FormUpdate;         // If TRUE, next variable is significant\r
-  UINT16                FormValue;          // specify which form is to be updated if FormUpdate value is TRUE.\r
-  STRING_REF            FormTitle;          // If not 0, will update Form with this info\r
-  UINT16                DataCount;          // The number of Data entries in this structure\r
-  UINT8                 *Data;              // An array of 1+ op-codes, specified by DataCount\r
-} EFI_HII_UPDATE_DATA;\r
-\r
-//\r
-// String attributes\r
-//\r
-#define LANG_RIGHT_TO_LEFT  0x00000001\r
-\r
-//\r
-// A string package is used to localize strings to a particular\r
-// language.  The package is associated with a particular driver\r
-// or set of drivers.  Tools are used to associate tokens with\r
-// string references in forms and in programs.  These tokens are\r
-// language agnostic.  When paired with a language pack (directly\r
-// or indirectly), the string token resolves into an actual\r
-// UNICODE string.  The NumStringPointers determines how many\r
-// StringPointers (offset values) there are as well as the total\r
-// number of Strings that are defined.\r
-//\r
-typedef struct {\r
-  EFI_HII_PACK_HEADER Header;\r
-  RELOFST             LanguageNameString;\r
-  RELOFST             PrintableLanguageName;\r
-  UINT32              NumStringPointers;\r
-  UINT32              Attributes;\r
-  //\r
-  //  RELOFST               StringPointers[];\r
-  //  EFI_STRING            Strings[];\r
-  //\r
-} EFI_HII_STRING_PACK;\r
-\r
-//\r
-// Glyph Attributes\r
-//\r
-#define EFI_GLYPH_NON_SPACING   1\r
-#define EFI_GLYPH_WIDE          2\r
-\r
-typedef struct {\r
-  CHAR16  UnicodeWeight;\r
-  UINT8   Attributes;\r
-  UINT8   GlyphCol1[GLYPH_HEIGHT];\r
-} EFI_NARROW_GLYPH;\r
-\r
-typedef struct {\r
-  CHAR16  UnicodeWeight;\r
-  UINT8   Attributes;\r
-  UINT8   GlyphCol1[GLYPH_HEIGHT];\r
-  UINT8   GlyphCol2[GLYPH_HEIGHT];\r
-  UINT8   Pad[3];\r
-} EFI_WIDE_GLYPH;\r
-\r
-//\r
-// A font list consists of a font header followed by a series\r
-// of glyph structures.  Note that fonts are not language specific.\r
-//\r
-typedef struct {\r
-  EFI_HII_PACK_HEADER Header;\r
-  UINT16              NumberOfNarrowGlyphs;\r
-  UINT16              NumberOfWideGlyphs;\r
-} EFI_HII_FONT_PACK;\r
-\r
-//\r
-// The IfrData in the EFI_HII_IFR_PACK structure definition\r
-// is variable length, and not really part of the header. To\r
-// simplify from code the size of the header, define an\r
-// identical structure that does not include the IfrData field.\r
-// Then use sizeof() this new structure to determine the\r
-// actual size of the header.\r
-//\r
-typedef struct {\r
-  EFI_HII_PACK_HEADER Header;\r
-} EFI_HII_IFR_PACK_HEADER;\r
-\r
-//\r
-// pedef EFI_HII_PACK_HEADER EFI_HII_IFR_PACK_HEADER;\r
-//\r
-typedef enum {\r
-  EfiKeyLCtrl,\r
-  EfiKeyA0,\r
-  EfiKeyLAlt,\r
-  EfiKeySpaceBar,\r
-  EfiKeyA2,\r
-  EfiKeyA3,\r
-  EfiKeyA4,\r
-  EfiKeyRCtrl,\r
-  EfiKeyLeftArrow,\r
-  EfiKeyDownArrow,\r
-  EfiKeyRightArrow,\r
-  EfiKeyZero,\r
-  EfiKeyPeriod,\r
-  EfiKeyEnter,\r
-  EfiKeyLShift,\r
-  EfiKeyB0,\r
-  EfiKeyB1,\r
-  EfiKeyB2,\r
-  EfiKeyB3,\r
-  EfiKeyB4,\r
-  EfiKeyB5,\r
-  EfiKeyB6,\r
-  EfiKeyB7,\r
-  EfiKeyB8,\r
-  EfiKeyB9,\r
-  EfiKeyB10,\r
-  EfiKeyRshift,\r
-  EfiKeyUpArrow,\r
-  EfiKeyOne,\r
-  EfiKeyTwo,\r
-  EfiKeyThree,\r
-  EfiKeyCapsLock,\r
-  EfiKeyC1,\r
-  EfiKeyC2,\r
-  EfiKeyC3,\r
-  EfiKeyC4,\r
-  EfiKeyC5,\r
-  EfiKeyC6,\r
-  EfiKeyC7,\r
-  EfiKeyC8,\r
-  EfiKeyC9,\r
-  EfiKeyC10,\r
-  EfiKeyC11,\r
-  EfiKeyC12,\r
-  EfiKeyFour,\r
-  EfiKeyFive,\r
-  EfiKeySix,\r
-  EfiKeyPlus,\r
-  EfiKeyTab,\r
-  EfiKeyD1,\r
-  EfiKeyD2,\r
-  EfiKeyD3,\r
-  EfiKeyD4,\r
-  EfiKeyD5,\r
-  EfiKeyD6,\r
-  EfiKeyD7,\r
-  EfiKeyD8,\r
-  EfiKeyD9,\r
-  EfiKeyD10,\r
-  EfiKeyD11,\r
-  EfiKeyD12,\r
-  EfiKeyD13,\r
-  EfiKeyDel,\r
-  EfiKeyEnd,\r
-  EfiKeyPgDn,\r
-  EfiKeySeven,\r
-  EfiKeyEight,\r
-  EfiKeyNine,\r
-  EfiKeyE0,\r
-  EfiKeyE1,\r
-  EfiKeyE2,\r
-  EfiKeyE3,\r
-  EfiKeyE4,\r
-  EfiKeyE5,\r
-  EfiKeyE6,\r
-  EfiKeyE7,\r
-  EfiKeyE8,\r
-  EfiKeyE9,\r
-  EfiKeyE10,\r
-  EfiKeyE11,\r
-  EfiKeyE12,\r
-  EfiKeyBackSpace,\r
-  EfiKeyIns,\r
-  EfiKeyHome,\r
-  EfiKeyPgUp,\r
-  EfiKeyNLck,\r
-  EfiKeySlash,\r
-  EfiKeyAsterisk,\r
-  EfiKeyMinus,\r
-  EfiKeyEsc,\r
-  EfiKeyF1,\r
-  EfiKeyF2,\r
-  EfiKeyF3,\r
-  EfiKeyF4,\r
-  EfiKeyF5,\r
-  EfiKeyF6,\r
-  EfiKeyF7,\r
-  EfiKeyF8,\r
-  EfiKeyF9,\r
-  EfiKeyF10,\r
-  EfiKeyF11,\r
-  EfiKeyF12,\r
-  EfiKeyPrint,\r
-  EfiKeySLck,\r
-  EfiKeyPause\r
-} EFI_KEY;\r
-\r
-typedef struct {\r
-  EFI_KEY Key;\r
-  CHAR16  Unicode;\r
-  CHAR16  ShiftedUnicode;\r
-  CHAR16  AltGrUnicode;\r
-  CHAR16  ShiftedAltGrUnicode;\r
-  UINT16  Modifier;\r
-} EFI_KEY_DESCRIPTOR;\r
-\r
-//\r
-// This structure allows a sparse set of keys to be redefined\r
-// or a complete redefinition of the keyboard layout.  Most\r
-// keyboards have a lot of commonality in their layouts, therefore\r
-// only defining those keys that need to change from the default\r
-// minimizes the passed in information.\r
-//\r
-// Additionally, when an update occurs, the active keyboard layout\r
-// will be switched to the newly updated keyboard layout.  This\r
-// allows for situations that when a keyboard layout driver is\r
-// loaded as part of system initialization, the system will default\r
-// the keyboard behavior to the new layout.\r
-//\r
-// Each call to update the keyboard mapping should contain the\r
-// complete set of key descriptors to be updated, since every\r
-// call to the HII which contains an EFI_HII_KEYBOARD_PACK will\r
-// wipe the previous set of overrides.  A call to\r
-//\r
-typedef struct {\r
-  EFI_HII_PACK_HEADER Header;\r
-  EFI_KEY_DESCRIPTOR  *Descriptor;\r
-  UINT8               DescriptorCount;\r
-} EFI_HII_KEYBOARD_PACK;\r
-\r
-//\r
-// The EFI_HII_PACKAGES can contain different types of packages just\r
-// after the structure as inline data.\r
-//\r
-typedef struct {\r
-  UINTN     NumberOfPackages;\r
-  EFI_GUID  *GuidId;\r
-  //\r
-  // EFI_HII_HANDLE_PACK    *HandlePack;        // Only one pack.\r
-  // EFI_HII_IFR_PACK       *IfrPack;           // Only one pack.\r
-  // EFI_HII_FONT_PACK      *FontPack[];        // Multiple packs ok\r
-  // EFI_HII_STRING_PACK    *StringPack[];      // Multiple packs ok\r
-  // EFI_HII_KEYBOARD_PACK  *KeyboardPack[];    // Multiple packs ok\r
-  //\r
-} EFI_HII_PACKAGES;\r
-\r
-typedef struct _EFI_HII_VARIABLE_PACK_LIST {\r
-  struct _EFI_HII_VARIABLE_PACK_LIST   *NextVariablePack;\r
-  EFI_HII_VARIABLE_PACK                *VariablePack;\r
-} EFI_HII_VARIABLE_PACK_LIST;\r
-\r
-#pragma pack()\r
-\r
-/**\r
-  Registers the various packs that are passed in via the Packages parameter. \r
-\r
-  @param  This A pointer to the EFI_HII_PROTOCOL instance.\r
-  \r
-  @param  Packages A pointer to an EFI_HII_PACKAGES package instance.\r
-  \r
-  @param  Handle A pointer to the EFI_HII_HANDLE instance.\r
-\r
-  @retval EFI_SUCCESS Data was extracted from Packages, the database \r
-  was updated with the data, and Handle returned successfully.\r
-  \r
-  @retval EFI_INVALID_PARAMETER The content of Packages  was invalid. \r
-\r
-**/\r
-typedef\r
-EFI_STATUS\r
-(EFIAPI *EFI_HII_NEW_PACK) (\r
-  IN  EFI_HII_PROTOCOL    *This,\r
-  IN  EFI_HII_PACKAGES    *Packages,\r
-  OUT EFI_HII_HANDLE      *Handle\r
-  );\r
-\r
-/**\r
-  Removes a package from the HII database. \r
-\r
-  @param  This A pointer to the EFI_HII_PROTOCOL instance.\r
-  \r
-  @param  Handle The handle that was registered to the data that is requested \r
-  for removal. \r
-\r
-  @retval EFI_SUCCESS The data associated with the Handle was removed \r
-  from the HII database.\r
-  \r
-  @retval EFI_INVALID_PARAMETER The Handle was not valid. \r
-\r
-**/\r
-typedef\r
-EFI_STATUS\r
-(EFIAPI *EFI_HII_REMOVE_PACK) (\r
-  IN EFI_HII_PROTOCOL    *This,\r
-  IN EFI_HII_HANDLE      Handle\r
-  );\r
-\r
-/**\r
-  Determines the handles that are currently active in the database.\r
-\r
-  @param  This A pointer to the EFI_HII_PROTOCOL instance.\r
-  \r
-  @param  HandleBufferLength On input, a pointer to the length of the handle \r
-  buffer. On output, the length of the handle buffer that is required \r
-  for the handles found.\r
-  \r
-  @param  Handle An array of EFI_HII_HANDLE instances returned.\r
-\r
-  @retval EFI_SUCCESS Handle was updated successfully.\r
-  \r
-  @retval EFI_BUFFER_TOO_SMALL The HandleBufferLength parameter indicates \r
-  that Handle is too small to support the number of handles.\r
-\r
-**/\r
-typedef\r
-EFI_STATUS\r
-(EFIAPI *EFI_HII_FIND_HANDLES) (\r
-  IN     EFI_HII_PROTOCOL *This,\r
-  IN OUT UINT16           *HandleBufferLength,\r
-  OUT    EFI_HII_HANDLE   *Handle\r
-  );\r
-\r
-/**\r
-  Exports the contents of the database into a buffer.\r
-\r
-  @param  This A pointer to the EFI_HII_PROTOCOL instance.\r
-  \r
-  @param  Handle An EFI_HII_HANDLE that corresponds to the desired \r
-  handle to export. If the value is 0, the entire database will be exported.\r
-  In either case, the data will be exported in a format described by the \r
-  structure definition of EFI_HII_EXPORT_TABLE.\r
-  \r
-  @param  BufferSize\r
-  On input, a pointer to the length of the buffer. On output, the length \r
-  of the buffer that is required for the export data.\r
-  \r
-  @param  Buffer A pointer to a buffer that will contain the results of the export function.\r
-\r
-  @retval EFI_SUCCESS The buffer was successfully filled with BufferSize amount of data.\r
-  \r
-  @retval EFI_BUFFER_TOO_SMALL The value in BufferSize was too small to contain the export data.\r
-\r
-**/\r
-typedef\r
-EFI_STATUS\r
-(EFIAPI *EFI_HII_EXPORT) (\r
-  IN     EFI_HII_PROTOCOL *This,\r
-  IN     EFI_HII_HANDLE   Handle,\r
-  IN OUT UINTN            *BufferSize,\r
-  OUT    VOID             *Buffer\r
-  );\r
-\r
-/**\r
-  Remove any new strings that were added after the initial string export \r
-  for this handle.\r
-\r
-  @param  This A pointer to the EFI_HII_PROTOCOL instance.\r
-  \r
-  @param  Handle The handle on which the string resides.\r
-\r
-  @retval EFI_SUCCESS Remove strings from the handle successfully.\r
-  \r
-  @retval EFI_INVALID_PARAMETER The Handle was unknown.\r
-\r
-**/\r
-typedef\r
-EFI_STATUS\r
-(EFIAPI *EFI_HII_RESET_STRINGS) (\r
-  IN     EFI_HII_PROTOCOL   *This,\r
-  IN     EFI_HII_HANDLE     Handle\r
-  );\r
-\r
-/**\r
-  Tests if all of the characters in a string have corresponding font characters.\r
-\r
-  @param  This A pointer to the EFI_HII_PROTOCOL instance.\r
-  \r
-  @param  StringToTest A pointer to a Unicode string.\r
-  \r
-  @param  FirstMissing A pointer to an index into the string. On input, \r
-  the index of the first character in the StringToTest to examine. On exit, \r
-  the index of the first character encountered for which a glyph is unavailable.\r
-  If all glyphs in the string are available, the index is the index of the \r
-  terminator of the string.\r
-  \r
-  @param  GlyphBufferSize A pointer to a value. On output, if the function \r
-  returns EFI_SUCCESS, it contains the amount of memory that is required to \r
-  store the string¡¯s glyph equivalent.\r
-\r
-  @retval EFI_SUCCESS All glyphs are available. Note that an empty string \r
-  always returns this value.\r
-  \r
-  @retval EFI_NOT_FOUND A glyph was not found for a character.\r
-\r
-**/\r
-typedef\r
-EFI_STATUS\r
-(EFIAPI *EFI_HII_TEST_STRING) (\r
-  IN     EFI_HII_PROTOCOL  *This,\r
-  IN     CHAR16            *StringToTest,\r
-  IN OUT UINT32            *FirstMissing,\r
-  OUT    UINT32            *GlyphBufferSize\r
-  );\r
-\r
-/**\r
-  Translates a Unicode character into the corresponding font glyph.\r
-\r
-  @param  This A pointer to the EFI_HII_PROTOCOL instance.\r
-  \r
-  @param  Source A pointer to a Unicode string.\r
-  \r
-  @param  Index On input, the offset into the string from which to fetch \r
-  the character.On successful completion, the index is updated to the first \r
-  character past the character(s) making up the just extracted glyph. \r
-  \r
-  @param  GlyphBuffer Pointer to an array where the glyphs corresponding \r
-  to the characters in the source may be stored. GlyphBuffer is assumed \r
-  to be wide enough to accept a wide glyph character.\r
-  \r
-  @param  BitWidth If EFI_SUCCESS was returned, the UINT16 pointed to by \r
-  this value is filled with the length of the glyph in pixels. It is unchanged \r
-  if the call was unsuccessful.\r
-  \r
-  @param  InternalStatus The cell pointed to by this parameter must be \r
-  initialized to zero prior to invoking the call the first time for any string.\r
-\r
-  @retval EFI_SUCCESS It worked.\r
-  \r
-  @retval EFI_NOT_FOUND A glyph for a character was not found.\r
-\r
-**/\r
-typedef\r
-EFI_STATUS\r
-(EFIAPI *EFI_HII_GET_GLYPH) (\r
-  IN     EFI_HII_PROTOCOL  *This,\r
-  IN     CHAR16            *Source,\r
-  IN OUT UINT16            *Index,\r
-  OUT    UINT8             **GlyphBuffer,\r
-  OUT    UINT16            *BitWidth,\r
-  IN OUT UINT32            *InternalStatus\r
-  );\r
-\r
-/**\r
-  Translates a glyph into the format required for input to the Universal \r
-  Graphics Adapter (UGA) Block Transfer (BLT) routines.\r
-\r
-  @param  This A pointer to the EFI_HII_PROTOCOL instance.\r
-  \r
-  @param  GlyphBuffer A pointer to the buffer that contains glyph data.\r
-  \r
-  @param  Foreground The foreground setting requested to be used for the \r
-  generated BltBuffer data. \r
-  \r
-  @param  Background The background setting requested to be used for the \r
-  generated BltBuffer data.\r
-  \r
-  @param  Count The entry in the BltBuffer upon which to act.\r
-  \r
-  @param  Width The width in bits of the glyph being converted.\r
-  \r
-  @param  Height The height in bits of the glyph being converted\r
-  \r
-  @param  BltBuffer A pointer to the buffer that contains the data that is \r
-  ready to be used by the UGA BLT routines. \r
-\r
-  @retval EFI_SUCCESS It worked.\r
-  \r
-  @retval EFI_NOT_FOUND A glyph for a character was not found.\r
-\r
-**/\r
-typedef\r
-EFI_STATUS\r
-(EFIAPI *EFI_HII_GLYPH_TO_BLT) (\r
-  IN     EFI_HII_PROTOCOL   *This,\r
-  IN     UINT8              *GlyphBuffer,\r
-  IN     EFI_UGA_PIXEL      Foreground,\r
-  IN     EFI_UGA_PIXEL      Background,\r
-  IN     UINTN              Count,\r
-  IN     UINTN              Width,\r
-  IN     UINTN              Height,\r
-  IN OUT EFI_UGA_PIXEL      *BltBuffer\r
-  );\r
-\r
-/**\r
-  Allows a new string to be added to an already existing string package.\r
-\r
-  @param  This A pointer to the EFI_HII_PROTOCOL instance.\r
-  \r
-  @param  Pointer to a NULL-terminated string containing a single ISO 639-2 \r
-  language identifier, indicating the language in which the string is translated. \r
-  \r
-  @param  Handle The handle of the language pack to which the string is to be added.\r
-  \r
-  @param  Reference The identifier of the string to be added. If the reference \r
-  value is zero, then the string will be assigned a new identifier on that \r
-  handle for the language specified. Otherwise, the string will be updated \r
-  with the NewString Value. \r
-  \r
-  @param  NewString The string to be added.\r
-\r
-  @retval EFI_SUCCESS The string was effectively registered.\r
-  \r
-  @retval EFI_INVALID_PARAMETER The Handle was unknown.\r
-\r
-**/\r
-typedef\r
-EFI_STATUS\r
-(EFIAPI *EFI_HII_NEW_STRING) (\r
-  IN     EFI_HII_PROTOCOL      *This,\r
-  IN     CHAR16                *Language,\r
-  IN     EFI_HII_HANDLE        Handle,\r
-  IN OUT STRING_REF            *Reference,\r
-  IN     CHAR16                *NewString\r
-  );\r
-\r
-/**\r
-  Allows a program to determine the primary languages that are supported \r
-  on a given handle.\r
-\r
-  @param  This A pointer to the EFI_HII_PROTOCOL instance.\r
-  \r
-  @param  Handle The handle on which the strings reside.\r
-  \r
-  @param  LanguageString A string allocated by GetPrimaryLanguages() that \r
-  contains a list of all primary languages registered on the handle. \r
-\r
-  @retval EFI_SUCCESS LanguageString was correctly returned.\r
-  \r
-  @retval EFI_INVALID_PARAMETER The Handle was unknown.\r
-\r
-**/\r
-typedef\r
-EFI_STATUS\r
-(EFIAPI *EFI_HII_GET_PRI_LANGUAGES) (\r
-  IN  EFI_HII_PROTOCOL    *This,\r
-  IN  EFI_HII_HANDLE      Handle,\r
-  OUT EFI_STRING          *LanguageString\r
-  );\r
-\r
-/**\r
-  Allows a program to determine which secondary languages are supported \r
-  on a given handle for a given primary language.\r
-\r
-  @param  This A pointer to the EFI_HII_PROTOCOL instance.\r
-  \r
-  @param  Handle The handle on which the strings reside.\r
-  \r
-  @param  PrimaryLanguage Pointer to a NULL-terminated string containing a single \r
-  ISO 639-2 language identifier, indicating the primary language.\r
-  \r
-  @param  LanguageString A string allocated by GetSecondaryLanguages() \r
-  containing a list of all secondary languages registered on the handle.\r
-\r
-  @retval EFI_SUCCESS LanguageString was correctly returned.\r
-  \r
-  @retval EFI_INVALID_PARAMETER The Handle was unknown.\r
-\r
-**/\r
-typedef\r
-EFI_STATUS\r
-(EFIAPI *EFI_HII_GET_SEC_LANGUAGES) (\r
-  IN  EFI_HII_PROTOCOL    *This,\r
-  IN  EFI_HII_HANDLE      Handle,\r
-  IN  CHAR16              *PrimaryLanguage,\r
-  OUT EFI_STRING          *LanguageString\r
-  );\r
-\r
-/**\r
-  Extracts a string from a package already registered with the EFI HII database.\r
-\r
-  @param  This A pointer to the EFI_HII_PROTOCOL instance.\r
-  \r
-  @param  Handle The handle on which the string resides.\r
-  \r
-  @param  Token The string token assigned to the string.\r
-  \r
-  @param  Raw If TRUE, the string is returned unedited in the internal \r
-  storage format described above. If false, the string returned is edited \r
-  by replacing <cr> with <space> and by removing special characters such \r
-  as the <wide> prefix.\r
-  \r
-  @param  LanguageString Pointer to a NULL-terminated string containing a \r
-  single ISO 639-2 language identifier, indicating the language to print. \r
-  If the LanguageString is empty (starts with a NULL), the default system \r
-  language will be used to determine the language.\r
-  \r
-  @param  BufferLength Length of the StringBuffer.\r
-  \r
-  @param  StringBuffer The buffer designed to receive the characters in the string.\r
-\r
-  @retval EFI_SUCCESS StringBuffer is filled with a NULL-terminated string.\r
-  \r
-  @retval EFI_INVALID_PARAMETER The handle or string token is unknown.\r
-  \r
-  @retval EFI_BUFFER_TOO_SMALL The buffer provided was not large enough to \r
-  allow the entire string to be stored. \r
-\r
-**/\r
-typedef\r
-EFI_STATUS\r
-(EFIAPI *EFI_HII_GET_STRING) (\r
-  IN     EFI_HII_PROTOCOL  *This,\r
-  IN     EFI_HII_HANDLE    Handle,\r
-  IN     STRING_REF        Token,\r
-  IN     BOOLEAN           Raw,\r
-  IN     CHAR16            *LanguageString,\r
-  IN OUT UINTN             *BufferLength,\r
-  OUT    EFI_STRING        StringBuffer\r
-  );\r
-\r
-/**\r
-  Allows a program to extract a part of a string of not more than a given width. \r
-\r
-  @param  This A pointer to the EFI_HII_PROTOCOL instance.\r
-  \r
-  @param  Handle The handle on which the string resides.\r
-  \r
-  @param  Token The string token assigned to the string. \r
-  \r
-  @param  Index On input, the offset into the string where the line is to start.\r
-  On output, the index is updated to point to beyond the last character returned \r
-  in the call.\r
-  \r
-  @param  LineWidth The maximum width of the line in units of narrow glyphs.\r
-  \r
-  @param  LanguageString Pointer to a NULL-terminated string containing a \r
-  single ISO 639-2 language identifier, indicating the language to print.\r
-  \r
-  @param  BufferLength Pointer to the length of the StringBuffer. \r
-  \r
-  @param  StringBuffer The buffer designed to receive the characters in the string. \r
-\r
-  @retval EFI_SUCCESS StringBuffer filled with characters that will fit on the line.\r
-  \r
-  @retval EFI_NOT_FOUND The font glyph for at least one of the characters in \r
-  the string is not in the font database.\r
-  \r
-  @retval EFI_BUFFER_TOO_SMALL The buffer provided was not large enough \r
-  to allow the entire string to be stored.\r
-\r
-**/\r
-typedef\r
-EFI_STATUS\r
-(EFIAPI *EFI_HII_GET_LINE) (\r
-  IN     EFI_HII_PROTOCOL  *This,\r
-  IN     EFI_HII_HANDLE    Handle,\r
-  IN     STRING_REF        Token,\r
-  IN OUT UINT16            *Index,\r
-  IN     UINT16            LineWidth,\r
-  IN     CHAR16            *LanguageString,\r
-  IN OUT UINT16            *BufferLength,\r
-  OUT    EFI_STRING        StringBuffer\r
-  );\r
-\r
-/**\r
-  Allows a program to extract a form or form package that has previously \r
-  been registered with the HII database.\r
-\r
-  @param  This A pointer to the EFI_HII_PROTOCOL instance.\r
-  \r
-  @param  Handle Handle on which the form resides.\r
-  \r
-  @param  FormId The ID of the form to return. If the ID is zero, \r
-  the entire form package is returned. \r
-  \r
-  @param  BufferLength On input, the length of the Buffer. On output, \r
-  the length of the returned buffer, \r
-  \r
-  @param  Buffer The buffer designed to receive the form(s).\r
-\r
-  @retval EFI_SUCCESS Buffer filled with the requested forms. BufferLength \r
-  was updated.\r
-  \r
-  @retval EFI_INVALID_PARAMETER The handle is unknown.\r
-  \r
-  @retval EFI_NOT_FOUND A form on the requested handle cannot be found with \r
-  the requested FormId.\r
-  \r
-  @retval EFI_BUFFER_TOO_SMALL The buffer provided was not large enough \r
-  to allow the form to be stored. \r
-\r
-**/\r
-typedef\r
-EFI_STATUS\r
-(EFIAPI *EFI_HII_GET_FORMS) (\r
-  IN     EFI_HII_PROTOCOL  *This,\r
-  IN     EFI_HII_HANDLE    Handle,\r
-  IN     EFI_FORM_ID       FormId,\r
-  IN OUT UINTN             *BufferLength,\r
-  OUT    UINT8             *Buffer\r
-  );\r
-\r
-/**\r
-  Extracts the defaults that are associated with a given handle in the HII database.\r
-\r
-  @param  This A pointer to the EFI_HII_PROTOCOL instance.\r
-  \r
-  @param  Handle The HII handle from which will have default data retrieved.\r
-  \r
-  @param  DefaultMask The mask used to specify some type of default override when extracting \r
-  the default image data.\r
-  \r
-  @param  VariablePackList A indirect pointer to the first entry of a link list with \r
-  type EFI_HII_VARIABLE_PACK_LIST. \r
-\r
-  @retval EFI_SUCCESS The VariablePackList was populated with the appropriate \r
-  default setting data.\r
-  \r
-  @retval EFI_NOT_FOUND The IFR does not have any explicit or default map(s).\r
-  \r
-  @retval EFI_INVALID_PARAMETER The HII database entry associated with Handle \r
-  contain invalid data.\r
-\r
-**/\r
-typedef\r
-EFI_STATUS\r
-(EFIAPI *EFI_HII_GET_DEFAULT_IMAGE) (\r
-  IN     EFI_HII_PROTOCOL           *This,\r
-  IN     EFI_HII_HANDLE             Handle,\r
-  IN     UINTN                      DefaultMask,\r
-  OUT    EFI_HII_VARIABLE_PACK_LIST **VariablePackList\r
-  );\r
-\r
-/**\r
-  Allows the caller to update a form or form package that has previously been \r
-  registered with the EFI HII database.\r
-\r
-  @param  This A pointer to the EFI_HII_PROTOCOL instance.\r
-  \r
-  @param  Handle Handle of the package where the form to be updated resides.\r
-  \r
-  @param  Label The label inside the form package where the update is to take place.\r
-  \r
-  @param  AddData If TRUE, adding data at a given Label; otherwise, \r
-  if FALSE, removing data at a given Label.\r
-  \r
-  @param  Data The buffer containing the new tags to insert after the Label\r
-\r
-  @retval EFI_SUCCESS The form was updated with the new tags.\r
-  \r
-  @retval EFI_INVALID_PARAMETER The buffer for the buffer length does not \r
-  contain an integral number of tags.\r
-  \r
-  @retval EFI_NOT_FOUND The Handle, Label, or FormId was not found. \r
-\r
-**/\r
-typedef\r
-EFI_STATUS\r
-(EFIAPI *EFI_HII_UPDATE_FORM) (\r
-  IN EFI_HII_PROTOCOL     *This,\r
-  IN EFI_HII_HANDLE       Handle,\r
-  IN EFI_FORM_LABEL       Label,\r
-  IN BOOLEAN              AddData,\r
-  IN EFI_HII_UPDATE_DATA  *Data\r
-  );\r
-\r
-/**\r
-  Retrieves the current keyboard layout. \r
-\r
-  @param  This A pointer to the EFI_HII_PROTOCOL instance.\r
-  \r
-  @param  DescriptorCount A pointer to the number of Descriptor entries being \r
-  described in the keyboard layout being retrieved.\r
-  \r
-  @param  Descriptor A pointer to a buffer containing an array of EFI_KEY_DESCRIPTOR \r
-  entries. Each entry will reflect the definition of a specific physical key.\r
-\r
-  @retval EFI_SUCCESS The keyboard layout was retrieved successfully.\r
-\r
-**/\r
-typedef\r
-EFI_STATUS\r
-(EFIAPI *EFI_HII_GET_KEYBOARD_LAYOUT) (\r
-  IN     EFI_HII_PROTOCOL    *This,\r
-  OUT    UINT16              *DescriptorCount,\r
-  OUT    EFI_KEY_DESCRIPTOR  *Descriptor\r
-  );\r
-\r
-/**\r
-  @par Protocol Description:\r
-  The HII Protocol manages the HII database, which is a repository for data \r
-  having to do with fonts, strings, forms, keyboards, and other future human \r
-  interface items.\r
-\r
-  @param NewPack\r
-  Extracts the various packs from a package list.\r
-\r
-  @param RemovePack\r
-  Removes a package from the HII database.\r
-\r
-  @param FindHandles\r
-  Determines the handles that are currently active in the database.\r
-\r
-  @param ExportDatabase\r
-  Export the entire contents of the database to a buffer.\r
-\r
-  @param TestString\r
-  Tests if all of the characters in a string have corresponding font characters.\r
-\r
-  @param GetGlyph\r
-  Translates a Unicode character into the corresponding font glyph. \r
-\r
-  @param GlyphToBlt\r
-  Converts a glyph value into a format that is ready for a UGA BLT command. \r
-\r
-  @param NewString\r
-  Allows a new string to be added to an already existing string package.\r
-\r
-  @param GetPrimaryLanguages\r
-  Allows a program to determine the primary languages that are supported \r
-  on a given handle. \r
-\r
-  @param GetSecondaryLanguages\r
-  Allows a program to determine which secondary languages are supported \r
-  on a given handle for a given primary language.\r
-\r
-  @param GetString\r
-  Extracts a string from a package that is already registered with the \r
-  EFI HII database. \r
-\r
-  @param ResetString\r
-  Remove any new strings that were added after the initial string export \r
-  for this handle.\r
-\r
-  @param GetLine\r
-  Allows a program to extract a part of a string of not more than a given width.\r
-\r
-  @param GetForms\r
-  Allows a program to extract a form or form package that has been previously registered.\r
-\r
-  @param GetDefaultImage\r
-  Allows a program to extract the nonvolatile image that represents the default storage image. \r
-\r
-  @param UpdateForm\r
-  Allows a program to update a previously registered form. \r
-\r
-  @param GetKeyboardLayout\r
-  Allows a program to extract the current keyboard layout.\r
-\r
-**/\r
-struct _EFI_HII_PROTOCOL {\r
-  EFI_HII_NEW_PACK            NewPack;\r
-  EFI_HII_REMOVE_PACK         RemovePack;\r
-  EFI_HII_FIND_HANDLES        FindHandles;\r
-  EFI_HII_EXPORT              ExportDatabase;\r
-\r
-  EFI_HII_TEST_STRING         TestString;\r
-  EFI_HII_GET_GLYPH           GetGlyph;\r
-  EFI_HII_GLYPH_TO_BLT        GlyphToBlt;\r
-\r
-  EFI_HII_NEW_STRING          NewString;\r
-  EFI_HII_GET_PRI_LANGUAGES   GetPrimaryLanguages;\r
-  EFI_HII_GET_SEC_LANGUAGES   GetSecondaryLanguages;\r
-  EFI_HII_GET_STRING          GetString;\r
-  EFI_HII_RESET_STRINGS       ResetStrings;\r
-  EFI_HII_GET_LINE            GetLine;\r
-  EFI_HII_GET_FORMS           GetForms;\r
-  EFI_HII_GET_DEFAULT_IMAGE   GetDefaultImage;\r
-  EFI_HII_UPDATE_FORM         UpdateForm;\r
-\r
-  EFI_HII_GET_KEYBOARD_LAYOUT GetKeyboardLayout;\r
-};\r
-\r
-extern EFI_GUID gEfiHiiProtocolGuid;\r
-\r
-#endif\r
diff --git a/Tools/CodeTools/TianoTools/Include/Protocol/UgaDraw.h b/Tools/CodeTools/TianoTools/Include/Protocol/UgaDraw.h
deleted file mode 100644 (file)
index 5586bdf..0000000
+++ /dev/null
@@ -1,168 +0,0 @@
-/** @file\r
-  UGA Draw protocol from the EFI 1.1 specification.\r
-\r
-  Abstraction of a very simple graphics device.\r
-\r
-  Copyright (c) 2006, Intel Corporation                                                         \r
-  All rights reserved. This program and the accompanying materials                          \r
-  are licensed and made available under the terms and conditions of the BSD License         \r
-  which accompanies this distribution.  The full text of the license may be found at        \r
-  http://opensource.org/licenses/bsd-license.php                                            \r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-  Module Name:  UgaDraw.h\r
-\r
-**/\r
-\r
-#ifndef __UGA_DRAW_H__\r
-#define __UGA_DRAW_H__\r
-\r
-#define EFI_UGA_DRAW_PROTOCOL_GUID \\r
-  { \\r
-    0x982c298b, 0xf4fa, 0x41cb, {0xb8, 0x38, 0x77, 0xaa, 0x68, 0x8f, 0xb8, 0x39 } \\r
-  }\r
-\r
-typedef struct _EFI_UGA_DRAW_PROTOCOL EFI_UGA_DRAW_PROTOCOL;\r
-\r
-/**\r
-  Return the current video mode information.\r
-\r
-  @param  This                  Protocol instance pointer.\r
-  @param  HorizontalResolution  Current video horizontal resolution in pixels\r
-  @param  VerticalResolution    Current video vertical resolution in pixels\r
-  @param  ColorDepth            Current video color depth in bits per pixel\r
-  @param  RefreshRate           Current video refresh rate in Hz.\r
-\r
-  @retval EFI_SUCCESS           Mode information returned.\r
-  @retval EFI_NOT_STARTED       Video display is not initialized. Call SetMode ()\r
-  @retval EFI_INVALID_PARAMETER One of the input args was NULL.\r
-\r
-**/\r
-typedef\r
-EFI_STATUS\r
-(EFIAPI *EFI_UGA_DRAW_PROTOCOL_GET_MODE) (\r
-  IN  EFI_UGA_DRAW_PROTOCOL *This,\r
-  OUT UINT32                *HorizontalResolution,\r
-  OUT UINT32                *VerticalResolution,\r
-  OUT UINT32                *ColorDepth,\r
-  OUT UINT32                *RefreshRate\r
-  )\r
-;\r
-\r
-/**\r
-  Return the current video mode information.\r
-\r
-  @param  This                 Protocol instance pointer.\r
-  @param  HorizontalResolution Current video horizontal resolution in pixels\r
-  @param  VerticalResolution   Current video vertical resolution in pixels\r
-  @param  ColorDepth           Current video color depth in bits per pixel\r
-  @param  RefreshRate          Current video refresh rate in Hz.\r
-\r
-  @retval EFI_SUCCESS          Mode information returned.\r
-  @retval EFI_NOT_STARTED      Video display is not initialized. Call SetMode ()\r
-\r
-**/\r
-typedef\r
-EFI_STATUS\r
-(EFIAPI *EFI_UGA_DRAW_PROTOCOL_SET_MODE) (\r
-  IN  EFI_UGA_DRAW_PROTOCOL *This,\r
-  IN  UINT32                HorizontalResolution,\r
-  IN  UINT32                VerticalResolution,\r
-  IN  UINT32                ColorDepth,\r
-  IN  UINT32                RefreshRate\r
-  )\r
-;\r
-\r
-typedef struct {\r
-  UINT8 Blue;\r
-  UINT8 Green;\r
-  UINT8 Red;\r
-  UINT8 Reserved;\r
-} EFI_UGA_PIXEL;\r
-\r
-typedef union {\r
-  EFI_UGA_PIXEL Pixel;\r
-  UINT32        Raw;\r
-} EFI_UGA_PIXEL_UNION;\r
-\r
-typedef enum {\r
-  EfiUgaVideoFill,\r
-  EfiUgaVideoToBltBuffer,\r
-  EfiUgaBltBufferToVideo,\r
-  EfiUgaVideoToVideo,\r
-  EfiUgaBltMax\r
-} EFI_UGA_BLT_OPERATION;\r
-\r
-/**\r
-  Type specifying a pointer to a function to perform an UGA Blt operation.\r
-\r
-    The following table defines actions for BltOperations:\r
-\r
-    <B>EfiUgaVideoFill</B> - Write data from the  BltBuffer pixel (SourceX, SourceY) \r
-      directly to every pixel of the video display rectangle \r
-      (DestinationX, DestinationY) (DestinationX + Width, DestinationY + Height). \r
-      Only one pixel will be used from the BltBuffer. Delta is NOT used.\r
-\r
-    <B>EfiUgaVideoToBltBuffer</B> - Read data from the video display rectangle \r
-      (SourceX, SourceY) (SourceX + Width, SourceY + Height) and place it in \r
-      the BltBuffer rectangle (DestinationX, DestinationY ) \r
-      (DestinationX + Width, DestinationY + Height). If DestinationX or \r
-      DestinationY is not zero then Delta must be set to the length in bytes \r
-      of a row in the BltBuffer.\r
-\r
-    <B>EfiUgaBltBufferToVideo</B> - Write data from the  BltBuffer rectangle \r
-      (SourceX, SourceY) (SourceX + Width, SourceY + Height) directly to the \r
-      video display rectangle (DestinationX, DestinationY) \r
-      (DestinationX + Width, DestinationY + Height). If SourceX or SourceY is \r
-      not zero then Delta must be set to the length in bytes of a row in the \r
-      BltBuffer.\r
-\r
-    <B>EfiUgaVideoToVideo</B> - Copy from the video display rectangle (SourceX, SourceY)\r
-     (SourceX + Width, SourceY + Height) .to the video display rectangle \r
-     (DestinationX, DestinationY) (DestinationX + Width, DestinationY + Height). \r
-     The BltBuffer and Delta  are not used in this mode.\r
-\r
-\r
-    @param[in] This          - Protocol instance pointer.\r
-    @param[in] BltBuffer     - Buffer containing data to blit into video buffer. This \r
-                               buffer has a size of Width*Height*sizeof(EFI_UGA_PIXEL)\r
-    @param[in] BltOperation  - Operation to perform on BlitBuffer and video memory\r
-    @param[in] SourceX       - X coordinate of source for the BltBuffer.\r
-    @param[in] SourceY       - Y coordinate of source for the BltBuffer.\r
-    @param[in] DestinationX  - X coordinate of destination for the BltBuffer.\r
-    @param[in] DestinationY  - Y coordinate of destination for the BltBuffer.\r
-    @param[in] Width         - Width of rectangle in BltBuffer in pixels.\r
-    @param[in] Height        - Hight of rectangle in BltBuffer in pixels.\r
-    @param[in] Delta         - OPTIONAL\r
-  \r
-    @retval EFI_SUCCESS           - The Blt operation completed.\r
-    @retval EFI_INVALID_PARAMETER - BltOperation is not valid.\r
-    @retval EFI_DEVICE_ERROR      - A hardware error occured writting to the video buffer.\r
-\r
---*/\r
-typedef\r
-EFI_STATUS\r
-(EFIAPI *EFI_UGA_DRAW_PROTOCOL_BLT) (\r
-  IN  EFI_UGA_DRAW_PROTOCOL                   * This,\r
-  IN  EFI_UGA_PIXEL                           * BltBuffer, OPTIONAL\r
-  IN  EFI_UGA_BLT_OPERATION                   BltOperation,\r
-  IN  UINTN                                   SourceX,\r
-  IN  UINTN                                   SourceY,\r
-  IN  UINTN                                   DestinationX,\r
-  IN  UINTN                                   DestinationY,\r
-  IN  UINTN                                   Width,\r
-  IN  UINTN                                   Height,\r
-  IN  UINTN                                   Delta         OPTIONAL\r
-  );\r
-\r
-struct _EFI_UGA_DRAW_PROTOCOL {\r
-  EFI_UGA_DRAW_PROTOCOL_GET_MODE  GetMode;\r
-  EFI_UGA_DRAW_PROTOCOL_SET_MODE  SetMode;\r
-  EFI_UGA_DRAW_PROTOCOL_BLT       Blt;\r
-};\r
-\r
-extern EFI_GUID gEfiUgaDrawProtocolGuid;\r
-\r
-#endif\r
diff --git a/Tools/CodeTools/TianoTools/Include/X64/ProcessorBind.h b/Tools/CodeTools/TianoTools/Include/X64/ProcessorBind.h
deleted file mode 100644 (file)
index f865ce8..0000000
+++ /dev/null
@@ -1,193 +0,0 @@
-/** @file\r
-  Processor or Compiler specific defines and types x64 (Intel(r) EM64T, AMD64).\r
-\r
-  Copyright (c) 2006, Intel Corporation                                                         \r
-  All rights reserved. This program and the accompanying materials                          \r
-  are licensed and made available under the terms and conditions of the BSD License         \r
-  which accompanies this distribution.  The full text of the license may be found at        \r
-  http://opensource.org/licenses/bsd-license.php                                            \r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-  Module Name:  ProcessorBind.h\r
-\r
-**/\r
-\r
-#ifndef __PROCESSOR_BIND_H__\r
-#define __PROCESSOR_BIND_H__\r
-\r
-//\r
-// Define the processor type so other code can make processor based choices\r
-//\r
-#define MDE_CPU_X64\r
-\r
-\r
-//\r
-// Make sure we are useing the correct packing rules per EFI specification\r
-//\r
-#pragma pack()\r
-\r
-\r
-#if _MSC_EXTENSIONS \r
-    \r
-//\r
-// Disable warning that make it impossible to compile at /W4\r
-// This only works for Microsoft* tools\r
-//\r
-\r
-//\r
-// Disabling bitfield type checking warnings.\r
-//\r
-#pragma warning ( disable : 4214 )\r
-\r
-//\r
-// Disabling the unreferenced formal parameter warnings.\r
-//\r
-#pragma warning ( disable : 4100 )\r
-\r
-//\r
-// Disable slightly different base types warning as CHAR8 * can not be set\r
-// to a constant string.\r
-//\r
-#pragma warning ( disable : 4057 )\r
-\r
-//\r
-// ASSERT(FALSE) or while (TRUE) are legal constructes so supress this warning\r
-//\r
-#pragma warning ( disable : 4127 )\r
-\r
-\r
-#endif\r
-\r
-\r
-#if (__STDC_VERSION__ < 199901L)\r
-  //\r
-  // No ANSI C 2000 stdint.h integer width declarations, so define equivalents\r
-  //\r
\r
-  #if _MSC_EXTENSIONS \r
-    \r
-\r
-    //\r
-    // use Microsoft C complier dependent interger width types \r
-    //\r
-    typedef unsigned __int64    UINT64;\r
-    typedef __int64             INT64;\r
-    typedef unsigned __int32    UINT32;\r
-    typedef __int32             INT32;\r
-    typedef unsigned short      UINT16;\r
-    typedef unsigned short      CHAR16;\r
-    typedef short               INT16;\r
-    typedef unsigned char       BOOLEAN;\r
-    typedef unsigned char       UINT8;\r
-    typedef char                CHAR8;\r
-    typedef char                INT8;\r
-  #else\r
-    #ifdef _EFI_P64 \r
-      //\r
-      // P64 - is Intel Itanium(TM) speak for pointers being 64-bit and longs and ints \r
-      //  are 32-bits\r
-      //\r
-      typedef unsigned long long  UINT64;\r
-      typedef long long           INT64;\r
-      typedef unsigned int        UINT32;\r
-      typedef int                 INT32;\r
-      typedef unsigned short      CHAR16;\r
-      typedef unsigned short      UINT16;\r
-      typedef short               INT16;\r
-      typedef unsigned char       BOOLEAN;\r
-      typedef unsigned char       UINT8;\r
-      typedef char                CHAR8;\r
-      typedef char                INT8;\r
-    #else\r
-      //\r
-      // Assume LP64 - longs and pointers are 64-bit. Ints are 32-bit.\r
-      //\r
-      typedef unsigned long   UINT64;\r
-      typedef long            INT64;\r
-      typedef unsigned int    UINT32;\r
-      typedef int             INT32;\r
-      typedef unsigned short  UINT16;\r
-      typedef unsigned short  CHAR16;\r
-      typedef short           INT16;\r
-      typedef unsigned char   BOOLEAN;\r
-      typedef unsigned char   UINT8;\r
-      typedef char            CHAR8;\r
-      typedef char            INT8;\r
-    #endif\r
-  #endif\r
-\r
-  #define UINT8_MAX 0xff\r
-\r
-#else\r
-  //\r
-  // Use ANSI C 2000 stdint.h integer width declarations\r
-  //\r
-  #include <stdint.h>\r
-  typedef uint8_t   BOOLEAN;\r
-  typedef int8_t    INT8;\r
-  typedef uint8_t   UINT8;\r
-  typedef int16_t   INT16;\r
-  typedef uint16_t  UINT16;\r
-  typedef int32_t   INT32;\r
-  typedef uint32_t  UINT32;\r
-  typedef int64_t   INT64;\r
-  typedef uint64_t  UINT64;\r
-  typedef char      CHAR8;\r
-  typedef uint16_t  CHAR16;\r
-\r
-#endif\r
-\r
-typedef UINT64  UINTN;\r
-typedef INT64   INTN;\r
-\r
-\r
-//\r
-// Processor specific defines\r
-//\r
-#define MAX_BIT     0x8000000000000000\r
-#define MAX_2_BITS  0xC000000000000000\r
-\r
-//\r
-// Maximum legal Itanium-based address\r
-//\r
-#define MAX_ADDRESS   0xFFFFFFFFFFFFFFFF\r
-\r
-//\r
-// Modifier to ensure that all protocol member functions and EFI intrinsics\r
-// use the correct C calling convention. All protocol member functions and\r
-// EFI intrinsics are required to modify thier member functions with EFIAPI.\r
-//\r
-#if _MSC_EXTENSIONS \r
-  ///\r
-  /// Define the standard calling convention reguardless of optimization level.\r
-  /// __cdecl is Microsoft* specific C extension.\r
-  /// \r
-  #define EFIAPI __cdecl  \r
-#elif __GNUC__\r
-  ///\r
-  /// Define the standard calling convention reguardless of optimization level.\r
-  /// efidecl is an extension to GCC that supports the differnece between x64\r
-  /// GCC ABI and x64 Microsoft* ABI. EFI is closer to the Microsoft* ABI and\r
-  /// EFIAPI makes sure the right ABI is used for public interfaces. \r
-  /// eficecl is a work in progress and we do not yet have the compiler\r
-  ///\r
-  #define EFIAPI \r
-#else\r
-  #define EFIAPI       \r
-#endif\r
-\r
-//\r
-// The Microsoft* C compiler can removed references to unreferenced data items\r
-//  if the /OPT:REF linker option is used. We defined a macro as this is a \r
-//  a non standard extension\r
-//\r
-#if _MSC_EXTENSIONS\r
-  #define GLOBAL_REMOVE_IF_UNREFERENCED __declspec(selectany)\r
-#else\r
-  #define GLOBAL_REMOVE_IF_UNREFERENCED\r
-#endif\r
-\r
-#endif\r
-\r
diff --git a/Tools/CodeTools/TianoTools/MakeDeps/MakeDeps.c b/Tools/CodeTools/TianoTools/MakeDeps/MakeDeps.c
deleted file mode 100755 (executable)
index 3943df0..0000000
+++ /dev/null
@@ -1,1284 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2004, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-Module Name:\r
-\r
-  MakeDeps.c  \r
-\r
-Abstract:\r
-\r
-  Recursively scan source files to find include files and emit them to \r
-  create dependency lists.\r
-\r
---*/\r
-\r
-#include <stdio.h>\r
-#include <string.h>\r
-#include <stdlib.h>\r
-#include <ctype.h>\r
-\r
-#include <Common/UefiBaseTypes.h>\r
-\r
-#include "EfiUtilityMsgs.h"\r
-#include "CommonLib.h"\r
-\r
-//\r
-// Structure to maintain a linked list of strings\r
-//\r
-typedef struct _STRING_LIST {\r
-  struct _STRING_LIST *Next;\r
-  char                *Str;\r
-} STRING_LIST;\r
-\r
-#define UTILITY_NAME      "MakeDeps"\r
-\r
-#define MAX_LINE_LEN      2048\r
-#define MAX_PATH          2048\r
-#define START_NEST_DEPTH  1\r
-#define MAX_NEST_DEPTH    1000  // just in case we get in an endless loop.\r
-//\r
-// Define the relative paths used by the special #include macros\r
-//\r
-#define PROTOCOL_DIR_PATH       "Protocol/"\r
-#define GUID_DIR_PATH           "Guid/"\r
-#define ARCH_PROTOCOL_DIR_PATH  "ArchProtocol/"\r
-#define PPI_PROTOCOL_DIR_PATH   "Ppi/"\r
-\r
-//\r
-// Use this structure to keep track of all the special #include forms\r
-//\r
-typedef struct {\r
-  INT8  *IncludeMacroName;\r
-  INT8  *PathName;\r
-} INCLUDE_MACRO_CONVERSION;\r
-\r
-//\r
-// This data is used to convert #include macros like:\r
-//    #include EFI_PROTOCOL_DEFINITION(xxx)\r
-// into\r
-//    #include Protocol/xxx/xxx.h\r
-//\r
-static const INCLUDE_MACRO_CONVERSION mMacroConversion[] = {\r
-  "EFI_PROTOCOL_DEFINITION",\r
-  PROTOCOL_DIR_PATH,\r
-  "EFI_GUID_DEFINITION",\r
-  GUID_DIR_PATH,\r
-  "EFI_ARCH_PROTOCOL_DEFINITION",\r
-  ARCH_PROTOCOL_DIR_PATH,\r
-  "EFI_PROTOCOL_PRODUCER",\r
-  PROTOCOL_DIR_PATH,\r
-  "EFI_PROTOCOL_CONSUMER",\r
-  PROTOCOL_DIR_PATH,\r
-  "EFI_PROTOCOL_DEPENDENCY",\r
-  PROTOCOL_DIR_PATH,\r
-  "EFI_ARCH_PROTOCOL_PRODUCER",\r
-  ARCH_PROTOCOL_DIR_PATH,\r
-  "EFI_ARCH_PROTOCOL_CONSUMER",\r
-  ARCH_PROTOCOL_DIR_PATH,\r
-  "EFI_ARCH_PROTOCOL_DEPENDENCY",\r
-  ARCH_PROTOCOL_DIR_PATH,\r
-  "EFI_PPI_DEFINITION",\r
-  PPI_PROTOCOL_DIR_PATH,\r
-  "EFI_PPI_PRODUCER",\r
-  PPI_PROTOCOL_DIR_PATH,\r
-  "EFI_PPI_CONSUMER",\r
-  PPI_PROTOCOL_DIR_PATH,\r
-  "EFI_PPI_DEPENDENCY",\r
-  PPI_PROTOCOL_DIR_PATH,\r
-  NULL,\r
-  NULL\r
-};\r
-\r
-typedef struct _SYMBOL {\r
-  struct _SYMBOL  *Next;\r
-  INT8            *Name;\r
-  INT8            *Value;\r
-} SYMBOL;\r
-\r
-//\r
-// Here's all our globals. We need a linked list of include paths, a linked\r
-// list of source files, a linked list of subdirectories (appended to each\r
-// include path when searching), and flags to keep track of command-line options.\r
-//\r
-static struct {\r
-  STRING_LIST *IncludePaths;            // all include paths to search\r
-  STRING_LIST *SourceFiles;             // all source files to parse\r
-  STRING_LIST *SubDirs;                 // appended to each include path when searching\r
-  SYMBOL      *SymbolTable;             // for replacement strings\r
-  FILE        *OutFptr;                 // output dependencies to this file\r
-  BOOLEAN     Verbose;                  // for more detailed output\r
-  BOOLEAN     IgnoreNotFound;           // no warnings if files not found\r
-  BOOLEAN     QuietMode;                // -q - don't print missing file warnings\r
-  BOOLEAN     NoSystem;                 // don't process #include <system> files\r
-  BOOLEAN     NeverFail;                // always return success\r
-  BOOLEAN     NoDupes;                  // to not list duplicate dependency files (for timing purposes)\r
-  BOOLEAN     UseSumDeps;               // use summary dependency files if found\r
-  INT8        TargetFileName[MAX_PATH]; // target object filename\r
-  INT8        SumDepsPath[MAX_PATH];    // path to summary files\r
-  INT8        *OutFileName;             // -o option\r
-} mGlobals;\r
-\r
-static\r
-STATUS\r
-ProcessFile (\r
-  INT8            *TargetFileName,\r
-  INT8            *FileName,\r
-  UINT32          NestDepth,\r
-  STRING_LIST     *ProcessedFiles\r
-  );\r
-\r
-static\r
-FILE  *\r
-FindFile (\r
-  INT8    *FileName,\r
-  UINT32  FileNameLen\r
-  );\r
-\r
-static\r
-void\r
-PrintDependency (\r
-  INT8    *Target,\r
-  INT8    *DependentFile\r
-  );\r
-\r
-static\r
-void\r
-ReplaceSymbols (\r
-  INT8    *Str,\r
-  UINT32  StrSize\r
-  );\r
-\r
-static\r
-STATUS\r
-ProcessArgs (\r
-  int   Argc,\r
-  char  *Argv[]\r
-  );\r
-\r
-static\r
-void\r
-Usage (\r
-  VOID\r
-  );\r
-\r
-static\r
-void\r
-FreeLists (\r
-  VOID\r
-  );\r
-\r
-int\r
-main (\r
-  int   Argc,\r
-  char  *Argv[]\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Call the routine to parse the command-line options, then process each file\r
-  to build dependencies.\r
-  \r
-Arguments:\r
-\r
-  Argc - Standard C main() argc.\r
-  Argv - Standard C main() argv.\r
-\r
-Returns:\r
-\r
-  0       if successful\r
-  nonzero otherwise\r
-  \r
---*/\r
-{\r
-  STRING_LIST *File;\r
-  STRING_LIST ProcessedFiles;\r
-  STRING_LIST *TempList;\r
-  STATUS      Status;\r
-  INT8        *Cptr;\r
-  INT8        TargetFileName[MAX_PATH];\r
-\r
-  SetUtilityName (UTILITY_NAME);\r
-  //\r
-  // Process the command-line arguments\r
-  //\r
-  Status = ProcessArgs (Argc, Argv);\r
-  if (Status != STATUS_SUCCESS) {\r
-    return STATUS_ERROR;\r
-  }\r
-  //\r
-  // Go through the list of source files and process each.\r
-  //\r
-  memset (&ProcessedFiles, 0, sizeof (STRING_LIST));\r
-  File = mGlobals.SourceFiles;\r
-  while (File != NULL) {\r
-    //\r
-    // Clear out our list of processed files\r
-    //\r
-    TempList = ProcessedFiles.Next;\r
-    while (ProcessedFiles.Next != NULL) {\r
-      TempList = ProcessedFiles.Next->Next;\r
-      free (ProcessedFiles.Next->Str);\r
-      free (ProcessedFiles.Next);\r
-      ProcessedFiles.Next = TempList;\r
-    }\r
-    //\r
-    // Replace filename extension with ".obj" if they did not\r
-    // specifically specify the target file\r
-    //\r
-    if (mGlobals.TargetFileName[0] == 0) {\r
-      strcpy (TargetFileName, File->Str);\r
-      //\r
-      // Find the .extension\r
-      //\r
-      for (Cptr = TargetFileName + strlen (TargetFileName) - 1;\r
-           (*Cptr != '\\' && *Cptr != '/') && (Cptr > TargetFileName) && (*Cptr != '.');\r
-           Cptr--\r
-          )\r
-        ;\r
-      if (Cptr == TargetFileName) {\r
-        Error (NULL, 0, 0, File->Str, "could not locate extension in filename");\r
-        goto Finish;\r
-      }\r
-      //\r
-      // Tack on the ".obj"\r
-      //\r
-      strcpy (Cptr, ".obj");\r
-    } else {\r
-      //\r
-      // Copy the target filename they specified\r
-      //\r
-      strcpy (TargetFileName, mGlobals.TargetFileName);\r
-    }\r
-\r
-    Status = ProcessFile (TargetFileName, File->Str, START_NEST_DEPTH, &ProcessedFiles);\r
-    if (Status != STATUS_SUCCESS) {\r
-      goto Finish;\r
-    }\r
-\r
-    File = File->Next;\r
-  }\r
-\r
-Finish:\r
-  //\r
-  // Free up memory\r
-  //\r
-  FreeLists ();\r
-  //\r
-  // Free up our processed files list\r
-  //\r
-  TempList = ProcessedFiles.Next;\r
-  while (ProcessedFiles.Next != NULL) {\r
-    TempList = ProcessedFiles.Next->Next;\r
-    free (ProcessedFiles.Next->Str);\r
-    free (ProcessedFiles.Next);\r
-    ProcessedFiles.Next = TempList;\r
-  }\r
-  //\r
-  // Close our output file\r
-  //\r
-  if ((mGlobals.OutFptr != stdout) && (mGlobals.OutFptr != NULL)) {\r
-    fprintf(mGlobals.OutFptr, "\t\n");  // file ending flag\r
-    fclose (mGlobals.OutFptr);\r
-  }\r
-\r
-  if (mGlobals.NeverFail) {\r
-    return STATUS_SUCCESS;\r
-  }\r
-  //\r
-  // If any errors, then delete our output so that it will get created\r
-  // again on a rebuild.\r
-  //\r
-  if ((GetUtilityStatus () == STATUS_ERROR) && (mGlobals.OutFileName != NULL)) {\r
-    remove (mGlobals.OutFileName);\r
-  }\r
-\r
-  return GetUtilityStatus ();\r
-}\r
-\r
-static\r
-STATUS\r
-ProcessFile (\r
-  INT8            *TargetFileName,\r
-  INT8            *FileName,\r
-  UINT32          NestDepth,\r
-  STRING_LIST     *ProcessedFiles\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Given a source file name, open the file and parse all #include lines.\r
-  \r
-Arguments:\r
-\r
-  TargetFileName - name of the usually .obj target\r
-  FileName       - name of the file to process\r
-  NestDepth      - how deep we're nested in includes\r
-  ProcessedFiles - list of processed files.\r
-\r
-Returns:\r
-\r
-  standard status.\r
-  \r
---*/\r
-{\r
-  FILE        *Fptr;\r
-  INT8        Line[MAX_LINE_LEN];\r
-  INT8        *Cptr;\r
-  INT8        *EndPtr;\r
-  INT8        *SaveCptr;\r
-  INT8        EndChar;\r
-  INT8        FileNameCopy[MAX_PATH];\r
-  INT8        MacroIncludeFileName[MAX_LINE_LEN];\r
-  INT8        SumDepsFile[MAX_PATH];\r
-  STATUS      Status;\r
-  UINT32      Index;\r
-  UINT32      LineNum;\r
-  STRING_LIST *ListPtr;\r
-\r
-  Status  = STATUS_SUCCESS;\r
-  Fptr    = NULL;\r
-  //\r
-  // Print the file being processed. Indent so you can tell the include nesting\r
-  // depth.\r
-  //\r
-  if (mGlobals.Verbose) {\r
-    fprintf (stdout, "%*cProcessing file '%s'\n", NestDepth * 2, ' ', FileName);\r
-  }\r
-  //\r
-  // If we're using summary dependency files, and a matching .dep file is\r
-  // found for this file, then just emit the summary dependency file as\r
-  // a dependency and return.\r
-  //\r
-  if (mGlobals.UseSumDeps) {\r
-    strcpy (SumDepsFile, mGlobals.SumDepsPath);\r
-    strcat (SumDepsFile, FileName);\r
-    for (Cptr = SumDepsFile + strlen (SumDepsFile) - 1;\r
-         (*Cptr != '\\' && *Cptr != '/') && (Cptr > SumDepsFile) && (*Cptr != '.');\r
-         Cptr--\r
-        )\r
-      ;\r
-    if (*Cptr == '.') {\r
-      strcpy (Cptr, ".dep");\r
-    } else {\r
-      strcat (SumDepsFile, ".dep");\r
-    }\r
-    //\r
-    // See if the summary dep file exists. Could use _stat() function, but\r
-    // it's less portable.\r
-    //\r
-    if ((Fptr = fopen (SumDepsFile, "r")) != NULL) {\r
-      PrintDependency (TargetFileName, SumDepsFile);\r
-      return STATUS_SUCCESS;\r
-    }\r
-  }\r
-  //\r
-  // If we're not doing duplicates, and we've already seen this filename,\r
-  // then return\r
-  //\r
-  if (mGlobals.NoDupes) {\r
-    for (ListPtr = ProcessedFiles->Next; ListPtr != NULL; ListPtr = ListPtr->Next) {\r
-      if (stricmp (FileName, ListPtr->Str) == 0) {\r
-        break;\r
-      }\r
-    }\r
-    //\r
-    // If we found a match, we're done. If we didn't, create a new element\r
-    // and add it to the list.\r
-    //\r
-    if (ListPtr != NULL) {\r
-      //\r
-      // Print a message if verbose mode\r
-      //\r
-      if (mGlobals.Verbose) {\r
-        DebugMsg (NULL, 0, 0, FileName, "duplicate include -- not processed again");\r
-      }\r
-\r
-      return STATUS_SUCCESS;\r
-    }\r
-\r
-    ListPtr       = malloc (sizeof (STRING_LIST));\r
-    ListPtr->Str  = malloc (strlen (FileName) + 1);\r
-    strcpy (ListPtr->Str, FileName);\r
-    ListPtr->Next         = ProcessedFiles->Next;\r
-    ProcessedFiles->Next  = ListPtr;\r
-  }\r
-\r
-  //\r
-  // Make sure we didn't exceed our maximum nesting depth\r
-  //\r
-  if (NestDepth > MAX_NEST_DEPTH) {\r
-    Error (NULL, 0, 0, FileName, "max nesting depth exceeded on file");\r
-    goto Finish;\r
-  }\r
-  //\r
-  // Make a local copy of the filename. Then we can manipulate it\r
-  // if we have to.\r
-  //\r
-  strcpy (FileNameCopy, FileName);\r
-  //\r
-  // Try to open the file locally\r
-  //\r
-  if ((Fptr = fopen (FileNameCopy, "r")) == NULL) {\r
-    //\r
-    // Try to find it among the paths.\r
-    //\r
-    Fptr = FindFile (FileNameCopy, sizeof (FileNameCopy));\r
-    if (Fptr == NULL) {\r
-      //\r
-      // If this is not the top-level file, and the command-line argument\r
-      // said to ignore missing files, then return ok\r
-      //\r
-      if (NestDepth != START_NEST_DEPTH) {\r
-        if (mGlobals.IgnoreNotFound) {\r
-          if (!mGlobals.QuietMode) {\r
-            DebugMsg (NULL, 0, 0, FileNameCopy, "could not find file");\r
-          }\r
-\r
-          return STATUS_SUCCESS;\r
-        } else {\r
-          Error (NULL, 0, 0, FileNameCopy, "could not find file");\r
-          return STATUS_ERROR;\r
-        }\r
-      } else {\r
-        //\r
-        // Top-level (first) file. Emit an error.\r
-        //\r
-        Error (NULL, 0, 0, FileNameCopy, "could not find file");\r
-        return STATUS_ERROR;\r
-      }\r
-    }\r
-  }\r
-  //\r
-  // Print the dependency, with string substitution\r
-  //\r
-  PrintDependency (TargetFileName, FileNameCopy);\r
-\r
-  //\r
-  // Now read in lines and find all #include lines. Allow them to indent, and\r
-  // to put spaces between the # and include.\r
-  //\r
-  LineNum = 0;\r
-  while ((fgets (Line, sizeof (Line), Fptr) != NULL) && (Status == STATUS_SUCCESS)) {\r
-    LineNum++;\r
-    Cptr = Line;\r
-    //\r
-    // Skip preceeding spaces on the line\r
-    //\r
-    while (*Cptr && (isspace (*Cptr))) {\r
-      Cptr++;\r
-    }\r
-    //\r
-    // Check for # character\r
-    //\r
-    if (*Cptr == '#') {\r
-      Cptr++;\r
-      //\r
-      // Check for "include"\r
-      //\r
-      while (*Cptr && (isspace (*Cptr))) {\r
-        Cptr++;\r
-      }\r
-\r
-      if (strncmp (Cptr, "include", 7) == 0) {\r
-        //\r
-        // Skip over "include" and move on to filename as "file" or <file>\r
-        //\r
-        Cptr += 7;\r
-        while (*Cptr && (isspace (*Cptr))) {\r
-          Cptr++;\r
-        }\r
-\r
-        if (*Cptr == '<') {\r
-          EndChar = '>';\r
-        } else if (*Cptr == '"') {\r
-          EndChar = '"';\r
-        } else {\r
-          //\r
-          // Handle special #include MACRO_NAME(file)\r
-          // Set EndChar to null so we fall through on processing below.\r
-          //\r
-          EndChar = 0;\r
-          //\r
-          // Look for all the special include macros and convert accordingly.\r
-          //\r
-          for (Index = 0; mMacroConversion[Index].IncludeMacroName != NULL; Index++) {\r
-            //\r
-            // Save the start of the string in case some macros are substrings\r
-            // of others.\r
-            //\r
-            SaveCptr = Cptr;\r
-            if (strncmp (\r
-                  Cptr,\r
-                  mMacroConversion[Index].IncludeMacroName,\r
-                  strlen (mMacroConversion[Index].IncludeMacroName)\r
-                  ) == 0) {\r
-              //\r
-              // Skip over the macro name\r
-              //\r
-              Cptr += strlen (mMacroConversion[Index].IncludeMacroName);\r
-              //\r
-              // Skip over open parenthesis, blank spaces, then find closing\r
-              // parenthesis or blank space\r
-              //\r
-              while (*Cptr && (isspace (*Cptr))) {\r
-                Cptr++;\r
-              }\r
-\r
-              if (*Cptr == '(') {\r
-                Cptr++;\r
-                while (*Cptr && (isspace (*Cptr))) {\r
-                  Cptr++;\r
-                }\r
-\r
-                EndPtr = Cptr;\r
-                while (*EndPtr && !isspace (*EndPtr) && (*EndPtr != ')')) {\r
-                  EndPtr++;\r
-                }\r
-\r
-                *EndPtr = 0;\r
-                //\r
-                // Create the path\r
-                //\r
-                strcpy (MacroIncludeFileName, mMacroConversion[Index].PathName);\r
-                strcat (MacroIncludeFileName, Cptr);\r
-                strcat (MacroIncludeFileName, "/");\r
-                strcat (MacroIncludeFileName, Cptr);\r
-                strcat (MacroIncludeFileName, ".h");\r
-                //\r
-                // Process immediately, then break out of the outside FOR loop.\r
-                //\r
-                Status = ProcessFile (TargetFileName, MacroIncludeFileName, NestDepth + 1, ProcessedFiles);\r
-                break;\r
-              }\r
-            }\r
-            //\r
-            // Restore the start\r
-            //\r
-            Cptr = SaveCptr;\r
-          }\r
-          //\r
-          // Don't recognize the include line? Ignore it. We assume that the\r
-          // file compiles anyway.\r
-          //\r
-          if (mMacroConversion[Index].IncludeMacroName == NULL) {\r
-            //\r
-            // Warning (FileNameCopy, LineNum, 0, "could not parse line", NULL);\r
-            // Status = STATUS_WARNING;\r
-            //\r
-          }\r
-        }\r
-        //\r
-        // Process "normal" includes. If the endchar is 0, then the\r
-        // file has already been processed. Otherwise look for the\r
-        // endchar > or ", and process the include file.\r
-        //\r
-        if (EndChar != 0) {\r
-          Cptr++;\r
-          EndPtr = Cptr;\r
-          while (*EndPtr && (*EndPtr != EndChar)) {\r
-            EndPtr++;\r
-          }\r
-\r
-          if (*EndPtr == EndChar) {\r
-            //\r
-            // If we're processing it, do it\r
-            //\r
-            if ((EndChar != '>') || (!mGlobals.NoSystem)) {\r
-              //\r
-              // Null terminate the filename and try to process it.\r
-              //\r
-              *EndPtr = 0;\r
-              Status  = ProcessFile (TargetFileName, Cptr, NestDepth + 1, ProcessedFiles);\r
-            }\r
-          } else {\r
-            Warning (FileNameCopy, LineNum, 0, "malformed include", "missing closing %c", EndChar);\r
-            Status = STATUS_WARNING;\r
-            goto Finish;\r
-          }\r
-        }\r
-      }\r
-    }\r
-  }\r
-\r
-Finish:\r
-  //\r
-  // Close open files and return status\r
-  //\r
-  if (Fptr != NULL) {\r
-    fclose (Fptr);\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-static\r
-void\r
-PrintDependency (\r
-  INT8    *TargetFileName,\r
-  INT8    *DependentFile\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Given a target (.obj) file name, and a dependent file name, do any string\r
-  substitutions (per the command line options) on the file names, then\r
-  print the dependency line of form:\r
-  \r
-  TargetFileName : DependentFile\r
-  \r
-Arguments:\r
-\r
-  TargetFileName - build target file name\r
-  DependentFile  - file on which TargetFileName depends\r
-\r
-Returns:\r
-\r
-  None\r
-  \r
---*/\r
-{\r
-  INT8  Str[MAX_PATH];\r
-\r
-  //\r
-  // Go through the symbols and do replacements\r
-  //\r
-  strcpy (Str, DependentFile);\r
-  ReplaceSymbols (Str, sizeof (Str));\r
-  fprintf (mGlobals.OutFptr, "%s\n", Str);\r
-}\r
-\r
-static\r
-void\r
-ReplaceSymbols (\r
-  INT8    *Str,\r
-  UINT32  StrSize\r
-  )\r
-{\r
-  SYMBOL  *Sym;\r
-  INT8    StrCopy[MAX_LINE_LEN];\r
-  INT8    *From;\r
-  INT8    *To;\r
-  BOOLEAN Replaced;\r
-\r
-  //\r
-  // Go through the entire string to look for replacement strings at\r
-  // every position.\r
-  //\r
-  From  = Str;\r
-  To    = StrCopy;\r
-  while (*From) {\r
-    //\r
-    // Copy the character\r
-    //\r
-    *To       = *From;\r
-    Replaced  = FALSE;\r
-    //\r
-    // Go through each symbol and try to find a string substitution\r
-    //\r
-    Sym = mGlobals.SymbolTable;\r
-    while (Sym != NULL) {\r
-      if (strnicmp (From, Sym->Value, strlen (Sym->Value)) == 0) {\r
-        //\r
-        // Replace the string, then advance the pointers past the\r
-        // replaced strings\r
-        //\r
-        strcpy (To, Sym->Name);\r
-        To += strlen (Sym->Name);\r
-        From += strlen (Sym->Value);\r
-        Replaced = TRUE;\r
-        //\r
-        // Break from the while()\r
-        //\r
-        break;\r
-      } else {\r
-        Sym = Sym->Next;\r
-      }\r
-    }\r
-\r
-    if (!Replaced) {\r
-      From++;\r
-      To++;\r
-    }\r
-  }\r
-  //\r
-  // Null terminate, and return it\r
-  //\r
-  *To = 0;\r
-  if (strlen (StrCopy) < StrSize) {\r
-    strcpy (Str, StrCopy);\r
-  }\r
-}\r
-//\r
-// Given a filename, try to find it along the include paths.\r
-//\r
-static\r
-FILE *\r
-FindFile (\r
-  INT8    *FileName,\r
-  UINT32  FileNameLen\r
-  )\r
-{\r
-  FILE        *Fptr;\r
-  STRING_LIST *List;\r
-  STRING_LIST *SubDir;\r
-  INT8        FullFileName[MAX_PATH * 2];\r
-\r
-  //\r
-  // Traverse the list of paths and try to find the file\r
-  //\r
-  List = mGlobals.IncludePaths;\r
-  while (List != NULL) {\r
-    //\r
-    // Put the path and filename together\r
-    //\r
-    if (strlen (List->Str) + strlen (FileName) + 1 > sizeof (FullFileName)) {\r
-      Error (\r
-        __FILE__,\r
-        __LINE__,\r
-        0,\r
-        "application error",\r
-        "cannot concatenate '%s' + '%s'",\r
-        List->Str,\r
-        FileName\r
-        );\r
-      return NULL;\r
-    }\r
-    //\r
-    // Append the filename to this include path and try to open the file.\r
-    //\r
-    strcpy (FullFileName, List->Str);\r
-    strcat (FullFileName, FileName);\r
-    if ((Fptr = fopen (FullFileName, "r")) != NULL) {\r
-      //\r
-      // Return the file name\r
-      //\r
-      if (FileNameLen <= strlen (FullFileName)) {\r
-        Error (__FILE__, __LINE__, 0, "application error", "internal path name of insufficient length");\r
-        //\r
-        // fprintf (stdout, "File length > %d: %s\n", FileNameLen, FullFileName);\r
-        //\r
-        return NULL;\r
-      }\r
-\r
-      strcpy (FileName, FullFileName);\r
-      return Fptr;\r
-    }\r
-    //\r
-    // Didn't find it there. Now try this directory with every subdirectory\r
-    // the user specified on the command line\r
-    //\r
-    for (SubDir = mGlobals.SubDirs; SubDir != NULL; SubDir = SubDir->Next) {\r
-      strcpy (FullFileName, List->Str);\r
-      strcat (FullFileName, SubDir->Str);\r
-      strcat (FullFileName, FileName);\r
-      if ((Fptr = fopen (FullFileName, "r")) != NULL) {\r
-        //\r
-        // Return the file name\r
-        //\r
-        if (FileNameLen <= strlen (FullFileName)) {\r
-          Error (__FILE__, __LINE__, 0, "application error", "internal path name of insufficient length");\r
-          return NULL;\r
-        }\r
-\r
-        strcpy (FileName, FullFileName);\r
-        return Fptr;\r
-      }\r
-    }\r
-\r
-    List = List->Next;\r
-  }\r
-  //\r
-  // Not found\r
-  //\r
-  return NULL;\r
-}\r
-//\r
-// Process the command-line arguments\r
-//\r
-static\r
-STATUS\r
-ProcessArgs (\r
-  int   Argc,\r
-  char  *Argv[]\r
-  )\r
-{\r
-  STRING_LIST *NewList;\r
-  STRING_LIST *LastIncludePath;\r
-  STRING_LIST *LastSourceFile;\r
-  SYMBOL      *Symbol;\r
-  int         Index;\r
-  //\r
-  // Clear our globals\r
-  //\r
-  memset ((char *) &mGlobals, 0, sizeof (mGlobals));\r
-  mGlobals.NoDupes = TRUE;\r
-  //\r
-  // Skip program name\r
-  //\r
-  Argc--;\r
-  Argv++;\r
-  //\r
-  // Initialize locals\r
-  //\r
-  LastIncludePath = NULL;\r
-  LastSourceFile  = NULL;\r
-  //\r
-  // Process until no more args\r
-  //\r
-  while (Argc) {\r
-    //\r
-    // -i path    add include search path\r
-    //\r
-    if (stricmp (Argv[0], "-i") == 0) {\r
-      //\r
-      // check for one more arg\r
-      //\r
-      if (Argc > 1) {\r
-        //\r
-        // Allocate memory for a new list element, fill it in, and\r
-        // add it to our list of include paths. Always make sure it\r
-        // has a "\" on the end of it.\r
-        //\r
-        NewList = malloc (sizeof (STRING_LIST));\r
-        if (NewList == NULL) {\r
-          Error (__FILE__, __LINE__, 0, "memory allocation failure", NULL);\r
-          return STATUS_ERROR;\r
-        }\r
-\r
-        NewList->Next = NULL;\r
-        NewList->Str  = malloc (strlen (Argv[1]) + 2);\r
-        if (NewList->Str == NULL) {\r
-          free (NewList);\r
-          Error (__FILE__, __LINE__, 0, "memory allocation failure", NULL);\r
-          return STATUS_ERROR;\r
-        }\r
-\r
-        strcpy (NewList->Str, Argv[1]);\r
-        if (NewList->Str[strlen (NewList->Str) - 1] != '\\' && NewList->Str[strlen (NewList->Str) - 1] != '/') {\r
-          strcat (NewList->Str, "/");\r
-        }\r
-        //\r
-        // Add it to the end of the our list of include paths\r
-        //\r
-        if (mGlobals.IncludePaths == NULL) {\r
-          mGlobals.IncludePaths = NewList;\r
-        } else {\r
-          LastIncludePath->Next = NewList;\r
-        }\r
-\r
-        LastIncludePath = NewList;\r
-        //\r
-        // fprintf (stdout, "Added path: %s\n", NewList->Str);\r
-        //\r
-      } else {\r
-        Error (NULL, 0, 0, Argv[0], "option requires an include path");\r
-        Usage ();\r
-        return STATUS_ERROR;\r
-      }\r
-\r
-      Argc--;\r
-      Argv++;\r
-    } else if (stricmp (Argv[0], "-f") == 0) {\r
-      //\r
-      // Check for one more arg\r
-      //\r
-      if (Argc > 1) {\r
-        //\r
-        // Allocate memory for a new list element, fill it in, and\r
-        // add it to our list of source files.\r
-        //\r
-        NewList = malloc (sizeof (STRING_LIST));\r
-        if (NewList == NULL) {\r
-          Error (__FILE__, __LINE__, 0, "memory allocation failure", NULL);\r
-          return STATUS_ERROR;\r
-        }\r
-\r
-        NewList->Next = NULL;\r
-        //\r
-        // Allocate space to replace ".c" with ".obj", plus null termination\r
-        //\r
-        NewList->Str = malloc (strlen (Argv[1]) + 5);\r
-        if (NewList->Str == NULL) {\r
-          free (NewList);\r
-          Error (__FILE__, __LINE__, 0, "memory allocation failure", NULL);\r
-          return STATUS_ERROR;\r
-        }\r
-\r
-        strcpy (NewList->Str, Argv[1]);\r
-        if (mGlobals.SourceFiles == NULL) {\r
-          mGlobals.SourceFiles = NewList;\r
-        } else {\r
-          LastSourceFile->Next = NewList;\r
-        }\r
-\r
-        LastSourceFile = NewList;\r
-      } else {\r
-        Error (NULL, 0, 0, Argv[0], "option requires a file name");\r
-        Usage ();\r
-        return STATUS_ERROR;\r
-      }\r
-      //\r
-      // The C compiler first looks for #include files in the directory where\r
-      // the source file came from. Add the file's source directory to the\r
-      // list of include paths.\r
-      //\r
-      NewList = malloc (sizeof (STRING_LIST));\r
-      if (NewList == NULL) {\r
-        Error (__FILE__, __LINE__, 0, "memory allocation failure", NULL);\r
-        return STATUS_ERROR;\r
-      }\r
-\r
-      NewList->Next = NULL;\r
-      NewList->Str  = malloc (strlen (Argv[1]) + 3);\r
-      if (NewList->Str == NULL) {\r
-        free (NewList);\r
-        Error (__FILE__, __LINE__, 0, "memory allocation failure", NULL);\r
-        return STATUS_ERROR;\r
-      }\r
-\r
-      strcpy (NewList->Str, Argv[1]);\r
-      //\r
-      // Back up in the source file name to the last backslash and terminate after it.\r
-      //\r
-      for (Index = strlen (NewList->Str) - 1; (Index > 0) && (NewList->Str[Index] != '\\' && NewList->Str[Index] != '/'); Index--)\r
-        ;\r
-      if (Index < 0) {\r
-        strcpy (NewList->Str, "./");\r
-      } else {\r
-        NewList->Str[Index + 1] = 0;\r
-      }\r
-      //\r
-      // Add it to the end of the our list of include paths\r
-      //\r
-      if (mGlobals.IncludePaths == NULL) {\r
-        mGlobals.IncludePaths = NewList;\r
-      } else {\r
-        LastIncludePath->Next = NewList;\r
-      }\r
-\r
-      if (mGlobals.Verbose) {\r
-        fprintf (stdout, "Adding include path: %s\n", NewList->Str);\r
-      }\r
-\r
-      LastIncludePath = NewList;\r
-      Argc--;\r
-      Argv++;\r
-    } else if (stricmp (Argv[0], "-s") == 0) {\r
-      //\r
-      // -s subdir    add subdirectory subdir to list of subdirecties to scan.\r
-      // Check for one more arg first.\r
-      //\r
-      if (Argc > 1) {\r
-        //\r
-        // Allocate memory for a new list element, fill it in, and\r
-        // add it to our list of subdirectory include paths. Always\r
-        // make sure it has a "\" on the end of it.\r
-        //\r
-        NewList = malloc (sizeof (STRING_LIST));\r
-        if (NewList == NULL) {\r
-          Error (__FILE__, __LINE__, 0, "memory allocation failure", NULL);\r
-          return STATUS_ERROR;\r
-        }\r
-\r
-        NewList->Str = malloc (strlen (Argv[1]) + 2);\r
-        if (NewList->Str == NULL) {\r
-          free (NewList);\r
-          Error (__FILE__, __LINE__, 0, "memory allocation failure", NULL);\r
-          return STATUS_ERROR;\r
-        }\r
-\r
-        strcpy (NewList->Str, Argv[1]);\r
-        if (NewList->Str[strlen (NewList->Str) - 1] != '\\' && NewList->Str[strlen (NewList->Str) - 1] != '/') {\r
-          strcat (NewList->Str, "/");\r
-        }\r
-\r
-        NewList->Next     = mGlobals.SubDirs;\r
-        mGlobals.SubDirs  = NewList;\r
-      } else {\r
-        Error (NULL, 0, 0, Argv[0], "option requires a subdirectory name");\r
-        Usage ();\r
-        return STATUS_ERROR;\r
-      }\r
-\r
-      Argc--;\r
-      Argv++;\r
-    } else if (stricmp (Argv[0], "-sub") == 0) {\r
-      //\r
-      // -sub symname symvalue  to do string substitution in the output\r
-      //\r
-      if (Argc > 2) {\r
-        //\r
-        // Allocate memory for the symbol object\r
-        //\r
-        Symbol = malloc (sizeof (SYMBOL));\r
-        if (Symbol == NULL) {\r
-          Error (__FILE__, __LINE__, 0, "memory allocation failure", NULL);\r
-          return STATUS_ERROR;\r
-        }\r
-        //\r
-        // Allocate memory for the symbol name and value, then save copies\r
-        //\r
-        Symbol->Name = malloc (strlen (Argv[1]) + 1);\r
-        if (Symbol->Name == NULL) {\r
-          free (Symbol);\r
-          Error (__FILE__, __LINE__, 0, "memory allocation failure", NULL);\r
-          return STATUS_ERROR;\r
-        }\r
-\r
-        strcpy (Symbol->Name, Argv[1]);\r
-        Symbol->Value = malloc (strlen (Argv[2]) + 1);\r
-        if (Symbol->Value == NULL) {\r
-          free (Symbol->Name);\r
-          free (Symbol);\r
-          Error (__FILE__, __LINE__, 0, "memory allocation failure", NULL);\r
-          return STATUS_ERROR;\r
-        }\r
-\r
-        strcpy (Symbol->Value, Argv[2]);\r
-        //\r
-        // Add it to the list\r
-        //\r
-        Symbol->Next          = mGlobals.SymbolTable;\r
-        mGlobals.SymbolTable  = Symbol;\r
-      } else {\r
-        Error (NULL, 0, 0, Argv[0], "option requires a symbol name and value");\r
-        Usage ();\r
-        return STATUS_ERROR;\r
-      }\r
-      //\r
-      // Skip over args\r
-      //\r
-      Argc -= 2;\r
-      Argv += 2;\r
-    } else if (stricmp (Argv[0], "-nosystem") == 0) {\r
-      mGlobals.NoSystem = TRUE;\r
-    } else if (stricmp (Argv[0], "-nodupes") == 0) {\r
-      mGlobals.NoDupes = TRUE;\r
-    } else if (stricmp (Argv[0], "-nodups") == 0) {\r
-      mGlobals.NoDupes = TRUE;\r
-    } else if (stricmp (Argv[0], "-target") == 0) {\r
-      //\r
-      // -target TargetFileName  - Target object file (only one allowed right\r
-      // now) is TargetFileName rather than SourceFile.obj\r
-      //\r
-      if (Argc > 1) {\r
-        strcpy (mGlobals.TargetFileName, Argv[1]);\r
-      } else {\r
-        Error (NULL, 0, 0, Argv[0], "option requires a target file name");\r
-        Usage ();\r
-        return STATUS_ERROR;\r
-      }\r
-\r
-      Argc--;\r
-      Argv++;\r
-    } else if (stricmp (Argv[0], "-usesumdeps") == 0) {\r
-      //\r
-      // -usesumdeps Path - if we find an included file xxx.h, and file\r
-      // Path/xxx.dep exists, list Path/xxx.dep as a dependency rather than\r
-      // xxx.h and don't parse xxx.h. This allows you to create a dependency\r
-      // file for a commonly included file, and have its dependency file updated\r
-      // only if its included files are updated. Then anyone else including this\r
-      // common include file can simply have a dependency on that file's .dep file\r
-      // rather than on all the files included by it. Confusing enough?\r
-      //\r
-      mGlobals.UseSumDeps = 1;\r
-      if (Argc > 1) {\r
-        strcpy (mGlobals.SumDepsPath, Argv[1]);\r
-        //\r
-        // Add slash on end if not there\r
-        //\r
-        if (mGlobals.SumDepsPath[strlen (mGlobals.SumDepsPath) - 1] != '\\' && mGlobals.SumDepsPath[strlen (mGlobals.SumDepsPath) - 1] != '/') {\r
-          strcat (mGlobals.SumDepsPath, "/");\r
-        }\r
-      } else {\r
-        Error (NULL, 0, 0, Argv[0], "option requires path to summary dependency files");\r
-        Usage ();\r
-        return STATUS_ERROR;\r
-      }\r
-\r
-      Argc--;\r
-      Argv++;\r
-\r
-    } else if (stricmp (Argv[0], "-o") == 0) {\r
-      //\r
-      // -o OutputFileName    - specify an output filename for dependency list\r
-      // check for one more arg\r
-      //\r
-      if (Argc > 1) {\r
-        //\r
-        // Try to open the file\r
-        //\r
-        if ((mGlobals.OutFptr = fopen (Argv[1], "w")) == NULL) {\r
-          Error (NULL, 0, 0, Argv[1], "could not open file for writing");\r
-          return STATUS_ERROR;\r
-        }\r
-\r
-        mGlobals.OutFileName = Argv[1];\r
-      } else {\r
-        Error (NULL, 0, 0, Argv[0], "option requires output file name");\r
-        Usage ();\r
-        return STATUS_ERROR;\r
-      }\r
-\r
-      Argc--;\r
-      Argv++;\r
-    } else if (stricmp (Argv[0], "-v") == 0) {\r
-      mGlobals.Verbose = TRUE;\r
-    } else if (stricmp (Argv[0], "-neverfail") == 0) {\r
-      mGlobals.NeverFail = TRUE;\r
-    } else if (stricmp (Argv[0], "-q") == 0) {\r
-      mGlobals.QuietMode = TRUE;\r
-    } else if (stricmp (Argv[0], "-ignorenotfound") == 0) {\r
-      mGlobals.IgnoreNotFound = TRUE;\r
-    } else if ((stricmp (Argv[0], "-h") == 0) || (strcmp (Argv[0], "-?") == 0)) {\r
-      Usage ();\r
-      return STATUS_ERROR;\r
-    } else {\r
-      Error (NULL, 0, 0, Argv[0], "unrecognized option");\r
-      Usage ();\r
-      return STATUS_ERROR;\r
-    }\r
-\r
-    Argc--;\r
-    Argv++;\r
-  }\r
-  //\r
-  // Had to specify at least one source file\r
-  //\r
-  if (mGlobals.SourceFiles == NULL) {\r
-    Error (NULL, 0, 0, "must specify one source file name", NULL);\r
-    Usage ();\r
-    return STATUS_ERROR;\r
-  }\r
-  //\r
-  // Assume output to stdout if not specified\r
-  //\r
-  if (mGlobals.OutFptr == NULL) {\r
-    mGlobals.OutFptr = stdout;\r
-  }\r
-\r
-  return STATUS_SUCCESS;\r
-}\r
-//\r
-// Free the global string lists we allocated memory for\r
-//\r
-static\r
-void\r
-FreeLists (\r
-  VOID\r
-  )\r
-{\r
-  STRING_LIST *Temp;\r
-  SYMBOL      *NextSym;\r
-\r
-  //\r
-  // printf ("Free lists.....");\r
-  //\r
-  // Traverse the include paths, freeing each\r
-  // printf ("freeing include paths\n");\r
-  //\r
-  while (mGlobals.IncludePaths != NULL) {\r
-    Temp = mGlobals.IncludePaths->Next;\r
-    //\r
-    // printf ("Freeing include path string '%s' at 0x%X\n",\r
-    //  mGlobals.IncludePaths->Str, (int)(mGlobals.IncludePaths->Str));\r
-    //\r
-    free (mGlobals.IncludePaths->Str);\r
-    //\r
-    // printf ("Freeing include path object at 0x%X\n", (int)(mGlobals.IncludePaths));\r
-    //\r
-    free (mGlobals.IncludePaths);\r
-    mGlobals.IncludePaths = Temp;\r
-  }\r
-  //\r
-  // Traverse the source files, freeing each\r
-  //\r
-  while (mGlobals.SourceFiles != NULL) {\r
-    Temp = mGlobals.SourceFiles->Next;\r
-    free (mGlobals.SourceFiles->Str);\r
-    free (mGlobals.SourceFiles);\r
-    mGlobals.SourceFiles = Temp;\r
-  }\r
-  //\r
-  // Traverse the subdirectory list, freeing each\r
-  //\r
-  while (mGlobals.SubDirs != NULL) {\r
-    Temp = mGlobals.SubDirs->Next;\r
-    free (mGlobals.SubDirs->Str);\r
-    free (mGlobals.SubDirs);\r
-    mGlobals.SubDirs = Temp;\r
-  }\r
-  //\r
-  // Free the symbol table\r
-  //\r
-  while (mGlobals.SymbolTable != NULL) {\r
-    NextSym = mGlobals.SymbolTable->Next;\r
-    free (mGlobals.SymbolTable->Name);\r
-    free (mGlobals.SymbolTable->Value);\r
-    mGlobals.SymbolTable = NextSym;\r
-  }\r
-  //\r
-  // printf ("done\n");\r
-  //\r
-}\r
-\r
-static\r
-void\r
-Usage (\r
-  VOID\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Print usage information for this utility.\r
-  \r
-Arguments:\r
-\r
-  None.\r
-\r
-Returns:\r
-\r
-  Nothing.\r
-  \r
---*/\r
-{\r
-  int               Index;\r
-  static const char *Str[] = {\r
-    UTILITY_NAME " -- make dependencies",\r
-    "  Usage: MakeDeps [options]",\r
-    "    Options include:",\r
-    "      -h or -?         for this help information",\r
-    "      -f SourceFile    add SourceFile to list of files to scan",\r
-    "      -i IncludePath   add IncludePath to list of search paths",\r
-    "      -o OutputFile    write output dependencies to OutputFile",\r
-    "      -s SubDir        for each IncludePath, also search IncludePath\\SubDir",\r
-    "      -v               for verbose output",\r
-    "      -ignorenotfound  don't warn for files not found",\r
-    "      -target Target   for single SourceFile, target is Target, not SourceFile.obj",\r
-    "      -q               quiet mode to not report files not found if ignored",\r
-    "      -sub sym str     replace all occurrances of 'str' with 'sym' in the output",\r
-    "      -nosystem        not process system <include> files",\r
-    "      -neverfail       always return a success return code",\r
-    //\r
-    //    "      -nodupes         keep track of include files, don't rescan duplicates",\r
-    //\r
-    "      -usesumdeps path use summary dependency files in 'path' directory.",\r
-    "",\r
-    NULL\r
-  };\r
-  for (Index = 0; Str[Index] != NULL; Index++) {\r
-    fprintf (stdout, "%s\n", Str[Index]);\r
-  }\r
-}\r
diff --git a/Tools/CodeTools/TianoTools/MakeDeps/build.xml b/Tools/CodeTools/TianoTools/MakeDeps/build.xml
deleted file mode 100755 (executable)
index 60c34c2..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-<?xml version="1.0" ?>\r
-<!--\r
-Copyright (c) 2006, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
--->\r
-<project default="GenTool" basedir=".">\r
-<!--\r
-    EDK MakeDeps Tool\r
-  Copyright (c) 2006, Intel Corporation\r
--->\r
-  <property name="ToolName" value="MakeDeps"/>\r
-  <property name="FileSet" value="*.c *.h"/>\r
-\r
-  <taskdef resource="cpptasks.tasks"/>\r
-  <typedef resource="cpptasks.types"/>\r
-  <taskdef resource="net/sf/antcontrib/antlib.xml"/>\r
-\r
-  <property name="LINK_OUTPUT_TYPE" value="static"/>\r
-  <property name="BUILD_DIR" value="${PACKAGE_DIR}/${ToolName}/tmp"/>\r
-\r
-  <target name="GenTool" depends="init, Tool">\r
-    <echo message="The EDK Tool: ${ToolName} build has completed!"/>\r
-  </target>\r
-\r
-  <target name="init">\r
-    <echo message="Building the EDK Tool: ${ToolName}"/>\r
-    <mkdir dir="${BUILD_DIR}"/>\r
-  </target>\r
-\r
-  <target name="Tool" depends="init">\r
-    <cc name="${ToolChain}" objdir="${BUILD_DIR}" \r
-        outfile="${BIN_DIR}/${ToolName}"\r
-        outtype="executable"\r
-        debug="true"\r
-        optimize="speed">\r
-      <compilerarg value="${ExtraArgus}" if="ExtraArgus" />   \r
-       \r
-      <fileset dir="${basedir}/${ToolName}" \r
-        includes="${FileSet}" \r
-        defaultexcludes="TRUE" \r
-        excludes="*.xml *.inf"/>\r
-\r
-      <includepath path="${PACKAGE_DIR}/Include"/>\r
-      <includepath path="${PACKAGE_DIR}/Include/${HostArch}"/>\r
-      <includepath path="${PACKAGE_DIR}/Common"/>\r
-      <libset dir="${LIB_DIR}" libs="CommonTools"/>\r
-    </cc>\r
-  </target>\r
-\r
-  <target name="clean">\r
-    <echo message="Removing Intermediate Files Only"/>  \r
-    <delete>\r
-      <fileset dir="${BUILD_DIR}" includes="*.obj"/>\r
-    </delete>\r
-  </target>\r
-\r
-  <target name="cleanall">\r
-    <echo message="Removing Object Files and the Executable: ${ToolName}${ext_exe}"/>  \r
-    <delete failonerror="false" quiet="true" includeEmptyDirs="true">\r
-      <fileset dir="${BUILD_DIR}"/>\r
-      <fileset file="${BIN_DIR}/${ToolName}${ext_exe}"/>\r
-    </delete>\r
-  </target>\r
-\r
-</project>\r
diff --git a/Tools/CodeTools/TianoTools/ModifyInf/ModifyInf.c b/Tools/CodeTools/TianoTools/ModifyInf/ModifyInf.c
deleted file mode 100755 (executable)
index 6008feb..0000000
+++ /dev/null
@@ -1,321 +0,0 @@
-/*++\r
-\r
-Copyright (c)  1999-2006 Intel Corporation. All rights reserved\r
-This program and the accompanying materials are licensed and made available \r
-under the terms and conditions of the BSD License which accompanies this \r
-distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-\r
-Module Name:\r
-\r
-  ModifyInf.c\r
-\r
-Abstract:\r
-\r
-  It is a simple tool to modify some fields in a FV inf file \r
-  and output a new FV inf file.  \r
-\r
---*/\r
-\r
-#include "stdio.h"\r
-#include "string.h"\r
-\r
-//\r
-// Read a line into buffer including '\r\n'\r
-//\r
-int\r
-ReadLine (\r
-  char *LineBuffer,\r
-  FILE *fp\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  LineBuffer  - GC_TODO: add argument description\r
-  fp          - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
-  GC_TODO: add return values\r
-\r
---*/\r
-{\r
-  int   CharC;\r
-  char  *Line;\r
-\r
-  Line = LineBuffer;\r
-\r
-  while ((CharC = fgetc (fp)) != EOF) {\r
-    *Line++ = (char) CharC;\r
-    if (CharC == 0x0a) {\r
-      break;\r
-    }\r
-  }\r
-\r
-  *Line = 0;\r
-\r
-  if (CharC == EOF) {\r
-    return 0;\r
-  } else {\r
-    return 1;\r
-  }\r
-\r
-}\r
-//\r
-// Write a line into output file\r
-//\r
-int\r
-WriteLine (\r
-  char *Line,\r
-  FILE *fp\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  Line  - GC_TODO: add argument description\r
-  fp    - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
-  GC_TODO: add return values\r
-\r
---*/\r
-{\r
-  fwrite (Line, strlen (Line), 1, fp);\r
-  return 0;\r
-}\r
-//\r
-// Apply patterns to a line\r
-// Currently there are 2 patterns to support\r
-// '==' replace a field value with a new value\r
-// '+=' append a string at the end of original line\r
-// '-'  prevent the line from applying any patterns\r
-//      it has the highest priority\r
-//\r
-int\r
-ApplyPattern (\r
-  char *Line,\r
-  char *argv[],\r
-  int  argc\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  Line  - GC_TODO: add argument description\r
-  ]     - GC_TODO: add argument description\r
-  argc  - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
-  GC_TODO: add return values\r
-\r
---*/\r
-{\r
-  static char Section[256];\r
-  char        PatternBuffer[256];\r
-  char        *Pattern;\r
-  char        *Pattern1;\r
-  char        *Pattern2;\r
-  int         PatternNum;\r
-  char        *Ptr;\r
-\r
-  Pattern     = PatternBuffer;\r
-\r
-  PatternNum  = argc;\r
-\r
-  //\r
-  // For section field\r
-  // record current scope section into static buffer\r
-  //\r
-  Ptr = Line;\r
-  if (*Ptr == '[') {\r
-    while (*Ptr != ']') {\r
-      if (!(*Ptr++)) {\r
-        return -1;\r
-      }\r
-    }\r
-\r
-    strcpy (Section, Line);\r
-    Section[Ptr - Line + 1] = 0;\r
-  }\r
-  //\r
-  // Apply each pattern on the line\r
-  //\r
-  while (PatternNum-- > 3) {\r
-\r
-    strcpy (Pattern, argv[PatternNum]);\r
-\r
-    //\r
-    // For pattern '-'\r
-    // keep it unmodified by other patterns\r
-    //\r
-    if (*Pattern == '-') {\r
-      if (strstr (Line, Pattern + 1)) {\r
-        return 0;\r
-      } else {\r
-        continue;\r
-      }\r
-    }\r
-    //\r
-    // For other patterns\r
-    // get its section at first if it has\r
-    //\r
-    if (*Pattern == '[') {\r
-      if (strncmp (Section, Pattern, strlen (Section))) {\r
-        //\r
-        // This pattern can't be appied for current section\r
-        //\r
-        continue;\r
-      }\r
-      //\r
-      // Strip the section field\r
-      //\r
-      while (*Pattern != ']') {\r
-        if (!(*Pattern++)) {\r
-          return -1;\r
-        }\r
-      }\r
-\r
-      Pattern++;\r
-    }\r
-    //\r
-    // Apply patterns\r
-    //\r
-    Pattern1  = strstr (Pattern, "==");\r
-    Pattern2  = strstr (Pattern, "+=");\r
-    if (Pattern1) {\r
-      //\r
-      // For pattern '=='\r
-      // replace the field value with a new string\r
-      //\r
-      if (!strncmp (Line, Pattern, Pattern1 - Pattern)) {\r
-        Pattern1 += 2;\r
-        Ptr = strstr (Line, "=");\r
-        if (!Ptr) {\r
-          return -1;\r
-        }\r
-\r
-        while (*(++Ptr) == ' ')\r
-          ;\r
-        *Ptr = 0;\r
-        strcat (Line, Pattern1);\r
-        strcat (Line, "\r\n");\r
-      }\r
-    } else if (Pattern2) {\r
-      //\r
-      // For pattern '+='\r
-      // append a string at end of the original string\r
-      //\r
-      if (!strncmp (Line, Pattern, Pattern2 - Pattern)) {\r
-        Pattern2 += 2;\r
-        Ptr = Line;\r
-        while (*Ptr != 0x0D && *Ptr != 0x0A) {\r
-          Ptr++;\r
-        }\r
-\r
-        *Ptr = 0;\r
-        strcat (Line, Pattern2);\r
-        strcat (Line, "\r\n");\r
-      }\r
-    }\r
-  }\r
-\r
-  return 0;\r
-}\r
-\r
-void\r
-Usage (\r
-  void\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  None\r
-\r
-Returns:\r
-\r
-  GC_TODO: add return values\r
-\r
---*/\r
-{\r
-  printf ("ModifyInf InputFVInfFileName OutputFVInfFileName [Pattern strings]\r\n");\r
-}\r
-\r
-int\r
-main (\r
-  int argc,\r
-  char*argv[]\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  argc  - GC_TODO: add argument description\r
-  ]     - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
-  GC_TODO: add return values\r
-\r
---*/\r
-{\r
-  char  LineBuffer[256];\r
-  FILE  *fpin;\r
-  FILE  *fpout;\r
-\r
-  if (argc < 3) {\r
-    Usage ();\r
-    return -1;\r
-  }\r
-\r
-  fpin = fopen (argv[1], "rb");\r
-  if (!fpin) {\r
-    printf ("Can't open input file!\r\n");\r
-    return -1;\r
-  }\r
-\r
-  fpout = fopen (argv[2], "wb");\r
-  if (!fpout) {\r
-    fclose (fpin);\r
-    printf ("Can't create output file!\r\n");\r
-    return -1;\r
-  }\r
-\r
-  while (ReadLine (LineBuffer, fpin)) {\r
-    ApplyPattern (LineBuffer, argv, argc);\r
-    WriteLine (LineBuffer, fpout);\r
-  }\r
-\r
-  fclose (fpin);\r
-  fclose (fpout);\r
-\r
-  return 0;\r
-}\r
diff --git a/Tools/CodeTools/TianoTools/ModifyInf/build.xml b/Tools/CodeTools/TianoTools/ModifyInf/build.xml
deleted file mode 100644 (file)
index a695ae0..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-<?xml version="1.0" ?>\r
-<!--\r
-Copyright (c) 2006, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
--->\r
-<project default="GenTool" basedir=".">\r
-<!--\r
-    EDK ModifyInf Tool\r
-  Copyright (c) 2006, Intel Corporation\r
--->\r
-  <property name="ToolName" value="ModifyInf"/>\r
-  <property name="FileSet" value="ModifyInf.c"/>\r
-\r
-  <taskdef resource="cpptasks.tasks"/>\r
-  <typedef resource="cpptasks.types"/>\r
-  <taskdef resource="net/sf/antcontrib/antlib.xml"/>\r
-\r
-  <property name="LINK_OUTPUT_TYPE" value="static"/>\r
-  <property name="BUILD_DIR" value="${PACKAGE_DIR}/${ToolName}/tmp"/>\r
-\r
-  <target name="GenTool" depends="init, Tool">\r
-    <echo message="The EDK Tool: ${ToolName} build has completed!"/>\r
-  </target>\r
-\r
-  <target name="init">\r
-    <echo message="Building the EDK Tool: ${ToolName}"/>\r
-    <mkdir dir="${BUILD_DIR}"/>\r
-  </target>\r
-\r
-  <target name="Tool" depends="init">\r
-    <cc name="${ToolChain}" objdir="${BUILD_DIR}" \r
-        outfile="${BIN_DIR}/${ToolName}"\r
-        outtype="executable"\r
-        debug="true"\r
-        optimize="speed">\r
-\r
-      <fileset dir="${basedir}/${ToolName}" \r
-        includes="${FileSet}" \r
-        defaultexcludes="TRUE" \r
-        excludes="*.xml *.inf"/>\r
-\r
-      <includepath path="${PACKAGE_DIR}/Include"/>\r
-      <includepath path="${PACKAGE_DIR}/Include/${HostArch}"/>\r
-      <includepath path="${PACKAGE_DIR}/Common"/>\r
-\r
-    </cc>\r
-  </target>\r
-\r
-  <target name="clean">\r
-    <echo message="Removing Intermediate Files Only"/>  \r
-    <delete>\r
-      <fileset dir="${BUILD_DIR}" includes="*.obj"/>\r
-    </delete>\r
-  </target>\r
-\r
-  <target name="cleanall">\r
-    <echo message="Removing Object Files and the Executable: ${ToolName}${ext_exe}"/>  \r
-    <delete failonerror="false" quiet="true" includeEmptyDirs="true">\r
-      <fileset dir="${BUILD_DIR}"/>\r
-      <fileset file="${BIN_DIR}/${ToolName}${ext_exe}"/>\r
-    </delete>\r
-  </target>\r
-\r
-</project>\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/CHANGES_FROM_131.txt b/Tools/CodeTools/TianoTools/Pccts/CHANGES_FROM_131.txt
deleted file mode 100644 (file)
index 500d84f..0000000
+++ /dev/null
@@ -1,522 +0,0 @@
-CHANGES FROM 1.31\r
-\r
-This file contains the migration of PCCTS from 1.31 in the order that\r
-changes were made.  1.32b7 is the last beta before full 1.32.\r
-Terence Parr, Parr Research Corporation 1995.\r
-\r
-\r
-======================================================================\r
-1.32b1\r
-Added Russell Quong to banner, changed banner for output slightly\r
-Fixed it so that you have before / after actions for C++ in class def\r
-Fixed bug in optimizer that made it sometimes forget to set internal\r
-        token pointers.  Only showed up when a {...} was in the "wrong spot".\r
-\r
-======================================================================\r
-1.32b2\r
-Added fixes by Dave Seidel for PC compilers in 32 bit mode (config.h\r
-and set.h).\r
-\r
-======================================================================\r
-1.32b3\r
-Fixed hideous bug in code generator for wildcard and for ~token op.\r
-\r
-from Dave Seidel\r
-\r
-   Added pcnames.bat\r
-   1. in antlr/main.c: change strcasecmp() to stricmp()\r
-\r
-   2. in dlg/output.c: use DLEXER_C instead on "DLexer.C"\r
-\r
-   3. in h/PBlackBox.h: use <iostream.h> instead of <stream.h>\r
-\r
-======================================================================\r
-1.32b4\r
-When the -ft option was used, any path prefix screwed up\r
-the gate on the .h files\r
-\r
-Fixed yet another bug due to the optimizer.\r
-\r
-The exception handling thing was a bit wacko:\r
-\r
-a : ( A B )? A B\r
-  | A C\r
-  ;\r
-  exception ...\r
-\r
-caused an exception if "A C" was the input.  In other words,\r
-it found that A C didn't match the (A B)? pred and caused\r
-an exception rather than trying the next alt.  All I did\r
-was to change the zzmatch_wsig() macros.\r
-\r
-Fixed some problems in gen.c relating to the name of token\r
-class bit sets in the output.\r
-\r
-Added the tremendously cool generalized predicate.  For the\r
-moment, I'll give this bried description.\r
-\r
-a : <<predicate>>? blah\r
-  | foo\r
-  ;\r
-\r
-This implies that (assuming blah and foo are syntactically\r
-ambiguous) "predicate" indicates the semantic validity of\r
-applying "blah".  If "predicate" is false, "foo" is attempted.\r
-\r
-Previously, you had to say:\r
-\r
-a : <<LA(1)==ID ? predicate : 1>>? ID\r
-  | ID\r
-  ;\r
-\r
-Now, you can simply use "predicate" without the ?: operator\r
-if you turn on ANTLR command line option: "-prc on".  This\r
-tells ANTLR to compute that all by itself.  It computes n\r
-tokens of lookahead where LT(n) or LATEXT(n) is the farthest\r
-ahead you look.\r
-\r
-If you give a predicate using "-prc on" that is followed\r
-by a construct that can recognize more than one n-sequence,\r
-you will get a warning from ANTLR.  For example,\r
-\r
-a : <<isTypeName(LT(1)->getText())>>? (ID|INT)\r
-  ;\r
-\r
-This is wrong because the predicate will be applied to INTs\r
-as well as ID's.  You should use this syntax to make\r
-the predicate more specific:\r
-\r
-a : (ID)? => <<isTypeName(LT(1)->getText())>>? (ID|INT)\r
-  ;\r
-\r
-which says "don't apply the predicate unless ID is the\r
-current lookahead context".\r
-\r
-You cannot currently have anything in the "(context)? =>"\r
-except sequences such as:\r
-\r
-( LPAREN ID | LPAREN SCOPE )? => <<pred>>?\r
-\r
-I haven't tested this THAT much, but it does work for the\r
-C++ grammar.\r
-\r
-======================================================================\r
-1.32b5\r
-\r
-Added getLine() to the ANTLRTokenBase and DLGBasedToken classes\r
-left line() for backward compatibility.\r
-----\r
-Removed SORCERER_TRANSFORM from the ast.h stuff.\r
--------\r
-Fixed bug in code gen of ANTLR such that nested syn preds work more\r
-efficiently now.  The ANTLRTokenBuffer was getting very large\r
-with nested predicates.\r
-------\r
-Memory leak is now gone from ANTLRTokenBuf; all tokens are deleted.\r
-For backward compatibility reasons, you have to say parser->deleteTokens()\r
-or mytokenbuffer->deleteTokens() but later it will be the default mode.\r
-Say this after the parser is constructed. E.g.,\r
-\r
-    ParserBlackBox<DLGLexer, MyParser, ANTLRToken> p(stdin);\r
-    p.parser()->deleteTokens();\r
-    p.parser()->start_symbol();\r
-\r
-\r
-==============================\r
-1.32b6\r
-\r
-Changed so that deleteTokens() will do a delete ((ANTLRTokenBase *))\r
-on the ptr.  This gets the virtual destructor.\r
-\r
-Fixed some weird things in the C++ header files (a few return types).\r
-\r
-Made the AST routines correspond to the book and SORCERER stuff.\r
-\r
-New token stuff:  See testcpp/14/test.g\r
-\r
-ANTLR accepts a #pragma gc_tokens which says\r
-[1]     Generate label = copy(LT(1)) instead of label=LT(1) for\r
-        all labeled token references.\r
-[2]     User now has to define ANTLRTokenPtr (as a class or a typedef\r
-        to just a pointer) as well as the ANTLRToken class itself.\r
-               See the example.\r
-\r
-To delete tokens in token buffer, use deleteTokens() message on parser.\r
-\r
-        All tokens that fall off the ANTLRTokenBuffer get deleted\r
-        which is what currently happens when deleteTokens() message\r
-        has been sent to token buffer.\r
-\r
-We always generate ANTLRTokenPtr instead of 'ANTLRToken *' now.\r
-Then if no pragma set, ANTLR generates a\r
-\r
-        class ANTLRToken;\r
-        typedef ANTLRToken *ANTLRTokenPtr;\r
-\r
-in each file.\r
-\r
-Made a warning for x:rule_ref <<$x>>; still no warning for $i's, however.\r
-class BB {\r
-\r
-a : x:b y:A <<$x\r
-$y>>\r
-  ;\r
-\r
-b : B;\r
-\r
-}\r
-generates\r
-Antlr parser generator   Version 1.32b6   1989-1995\r
-test.g, line 3: error: There are no token ptrs for rule references: '$x'\r
-\r
-===================\r
-1.32b7:\r
-\r
-[With respect to token object garbage collection (GC), 1.32b7\r
- backtracks from 1.32b6, but results in better and less intrusive GC.\r
- This is the last beta version before full 1.32.]\r
-\r
-BIGGEST CHANGES:\r
-\r
-o      The "#pragma gc_tokens" is no longer used.\r
-\r
-o      .C files are now .cpp files (hence, makefiles will have to\r
-       be changed; or you can rerun genmk).  This is a good move,\r
-       but causes some backward incompatibility problems.  You can\r
-       avoid this by changing CPP_FILE_SUFFIX to ".C" in pccts/h/config.h.\r
-\r
-o      The token object class hierarchy has been flattened to include\r
-       only three classes: ANTLRAbstractToken, ANTLRCommonToken, and\r
-       ANTLRCommonNoRefCountToken.  The common token now does garbage\r
-       collection via ref counting.\r
-\r
-o      "Smart" pointers are now used for garbage collection.  That is,\r
-       ANTLRTokenPtr is used instead of "ANTLRToken *".\r
-\r
-o      The antlr.1 man page has been cleaned up slightly.\r
-\r
-o      The SUN C++ compiler now complains less about C++ support code.\r
-\r
-o      Grammars which subclass ANTLRCommonToken must wrap all token\r
-       pointer references in mytoken(token_ptr).  This is the only\r
-       serious backward incompatibility.  See below.\r
-\r
-\r
-MINOR CHANGES:\r
-\r
---------------------------------------------------------\r
-1      deleteTokens()\r
-\r
-The deleteTokens() message to the parser or token buffer has been changed\r
-to one of:\r
-\r
-    void noGarbageCollectTokens()   { inputTokens->noGarbageCollectTokens(); }\r
-    void garbageCollectTokens()     { inputTokens->garbageCollectTokens(); }\r
-\r
-The token buffer deletes all non-referenced tokens by default now.\r
-\r
---------------------------------------------------------\r
-2      makeToken()\r
-\r
-The makeToken() message returns a new type.  The function should look\r
-like:\r
-\r
-    virtual ANTLRAbstractToken *makeToken(ANTLRTokenType tt,\r
-                                          ANTLRChar *txt,\r
-                                          int line)\r
-    {\r
-        ANTLRAbstractToken *t = new ANTLRCommonToken(tt,txt);\r
-        t->setLine(line);\r
-        return t;\r
-    }\r
-\r
---------------------------------------------------------\r
-3      TokenType\r
-\r
-Changed TokenType-> ANTLRTokenType  (often forces changes in AST defs due\r
-to #[] constructor called to AST(tokentype, string)).\r
-\r
---------------------------------------------------------\r
-4      AST()\r
-\r
-You must define AST(ANTLRTokenPtr t) now in your AST class definition.\r
-You might also have to include ATokPtr.h above the definition; e.g.,\r
-if AST is defined in a separate file, such as AST.h, it's a good idea\r
-to include ATOKPTR_H (ATokPtr.h).  For example,\r
-\r
-       #include ATOKPTR_H\r
-       class AST : public ASTBase {\r
-       protected:\r
-           ANTLRTokenPtr token;\r
-       public:\r
-           AST(ANTLRTokenPtr t) { token = t; }\r
-           void preorder_action() {\r
-               char *s = token->getText();\r
-               printf(" %s", s);\r
-           }\r
-       };\r
-\r
-Note the use of smart pointers rather than "ANTLRToken *".\r
-\r
---------------------------------------------------------\r
-5      SUN C++\r
-\r
-From robertb oakhill.sps.mot.com Bob Bailey. Changed ANTLR C++ output\r
-to avoid an error in Sun C++ 3.0.1.  Made "public" return value\r
-structs created to hold multiple return values public.\r
-\r
---------------------------------------------------------\r
-6      genmk\r
-\r
-Fixed genmk so that target List.* is not included anymore.  It's\r
-called SList.* anyway.\r
-\r
---------------------------------------------------------\r
-7      \r vs \n\r
-\r
-Scott Vorthmann <vorth cmu.edu> fixed antlr.g in ANTLR so that \r\r
-is allowed as the return character as well as \n.\r
-\r
---------------------------------------------------------\r
-8      Exceptions\r
-\r
-Bug in exceptions attached to labeled token/tokclass references.  Didn't gen\r
-code for exceptions.  This didn't work:\r
-\r
-a : "help" x:ID\r
-  ;\r
-        exception[x]\r
-        catch MismatchedToken : <<printf("eh?\n");>>\r
-\r
-Now ANTLR generates (which is kinda big, but necessary):\r
-\r
-        if ( !_match_wsig(ID) ) {\r
-                if ( guessing ) goto fail;\r
-                _signal=MismatchedToken;\r
-                switch ( _signal ) {\r
-                case MismatchedToken :\r
-                        printf("eh?\n");\r
-                        _signal = NoSignal;\r
-                        break;\r
-                default :\r
-                        goto _handler;\r
-                }\r
-        }\r
-\r
-which implies that you can recover and continue parsing after a missing/bad\r
-token reference.\r
-\r
---------------------------------------------------------\r
-9      genmk\r
-\r
-genmk now correctly uses config file for CPP_FILE_SUFFIX stuff.\r
-\r
---------------------------------------------------------\r
-10     general cleanup / PURIFY\r
-\r
-Anthony Green <green vizbiz.com> suggested a bunch of good general\r
-clean up things for the code; he also suggested a few things to\r
-help out the "PURIFY" memory allocation checker.\r
-\r
---------------------------------------------------------\r
-11     $-variable references.\r
-\r
-Manuel ORNATO indicated that a $-variable outside of a rule caused\r
-ANTLR to crash.  I fixed this.\r
-\r
-12     Tom Moog suggestion\r
-\r
-Fail action of semantic predicate needs "{}" envelope.  FIXED.\r
-\r
-13     references to LT(1).\r
-\r
-I have enclosed all assignments such as:\r
-\r
-             _t22 = (ANTLRTokenPtr)LT(1);\r
-\r
-in "if ( !guessing )" so that during backtracking the reference count\r
-for token objects is not increased.\r
-\r
-\r
-TOKEN OBJECT GARBAGE COLLECTION\r
-\r
-1      INTRODUCTION\r
-\r
-The class ANTLRCommonToken is now garbaged collected through a "smart"\r
-pointer called ANTLRTokenPtr using reference counting.  Any token\r
-object not referenced by your grammar actions is destroyed by the\r
-ANTLRTokenBuffer when it must make room for more token objects.\r
-Referenced tokens are then destroyed in your parser when local\r
-ANTLRTokenPtr objects are deleted.  For example,\r
-\r
-a : label:ID ;\r
-\r
-would be converted to something like:\r
-\r
-void yourclass::a(void)\r
-{\r
-       zzRULE;\r
-       ANTLRTokenPtr label=NULL;       // used to be ANTLRToken *label;\r
-        zzmatch(ID);\r
-        label = (ANTLRTokenPtr)LT(1);\r
-       consume();\r
-       ...\r
-}\r
-\r
-When the "label" object is destroyed (it's just a pointer to your\r
-input token object LT(1)), it decrements the reference count on the\r
-object created for the ID.  If the count goes to zero, the object\r
-pointed by label is deleted.\r
-\r
-To correctly manage the garbage collection, you should use\r
-ANTLRTokenPtr instead of "ANTLRToken *".  Most ANTLR support code\r
-(visible to the user) has been modified to use the smart pointers.\r
-\r
-***************************************************************\r
-Remember that any local objects that you create are not deleted when a\r
-lonjmp() is executed.  Unfortunately, the syntactic predicates (...)?\r
-use setjmp()/longjmp().  There are some situations when a few tokens\r
-will "leak".\r
-***************************************************************\r
-\r
-2      DETAILS\r
-\r
-o      The default is to perform token object garbage collection.\r
-       You may use parser->noGarbageCollectTokens() to turn off\r
-       garbage collection.\r
-\r
-\r
-o      The type ANTLRTokenPtr is always defined now (automatically).\r
-       If you do not wish to use smart pointers, you will have to\r
-       redefined ANTLRTokenPtr by subclassing, changing the header\r
-       file or changing ANTLR's code generation (easy enough to\r
-       do in gen.c).\r
-\r
-o      If you don't use ParserBlackBox, the new initialization sequence is:\r
-\r
-           ANTLRTokenPtr aToken = new ANTLRToken;\r
-           scan.setToken(mytoken(aToken));\r
-\r
-       where mytoken(aToken) gets an ANTLRToken * from the smart pointer.\r
-\r
-o      Define C++ preprocessor symbol DBG_REFCOUNTTOKEN to see a bunch of\r
-       debugging stuff for reference counting if you suspect something.\r
-\r
-\r
-3      WHY DO I HAVE TO TYPECAST ALL MY TOKEN POINTERS NOW??????\r
-\r
-If you subclass ANTLRCommonToken and then attempt to refer to one of\r
-your token members via a token pointer in your grammar actions, the\r
-C++ compiler will complain that your token object does not have that\r
-member.  For example, if you used to do this\r
-\r
-<<\r
-class ANTLRToken : public ANTLRCommonToken {\r
-        int muck;\r
-       ...\r
-};\r
->>\r
-\r
-class Foo {\r
-a : t:ID << t->muck = ...; >> ;\r
-}\r
-\r
-Now, you must do change the t->muck reference to:\r
-\r
-a : t:ID << mytoken(t)->muck = ...; >> ;\r
-\r
-in order to downcast 't' to be an "ANTLRToken *" not the\r
-"ANTLRAbstractToken *" resulting from ANTLRTokenPtr::operator->().\r
-The macro is defined as:\r
-\r
-/*\r
- * Since you cannot redefine operator->() to return one of the user's\r
- * token object types, we must down cast.  This is a drag.  Here's\r
- * a macro that helps.  template: "mytoken(a-smart-ptr)->myfield".\r
- */\r
-#define mytoken(tp) ((ANTLRToken *)(tp.operator->()))\r
-\r
-You have to use macro mytoken(grammar-label) now because smart\r
-pointers are not specific to a parser's token objects.  In other\r
-words, the ANTLRTokenPtr class has a pointer to a generic\r
-ANTLRAbstractToken not your ANTLRToken; the ANTLR support code must\r
-use smart pointers too, but be able to work with any kind of\r
-ANTLRToken.  Sorry about this, but it's C++'s fault not mine.  Some\r
-nebulous future version of the C++ compilers should obviate the need\r
-to downcast smart pointers with runtime type checking (and by allowing\r
-different return type of overridden functions).\r
-\r
-A way to have backward compatible code is to shut off the token object\r
-garbage collection; i.e., use parser->noGarbageCollectTokens() and\r
-change the definition of ANTLRTokenPtr (that's why you get source code\r
-<wink>).\r
-\r
-\r
-PARSER EXCEPTION HANDLING\r
-\r
-I've noticed some weird stuff with the exception handling.  I intend\r
-to give this top priority for the "book release" of ANTLR.\r
-\r
-==========\r
-1.32 Full Release\r
-\r
-o      Changed Token class hierarchy to be (Thanks to Tom Moog):\r
-\r
-        ANTLRAbstractToken\r
-          ANTLRRefCountToken\r
-             ANTLRCommonToken\r
-          ANTLRNoRefCountCommonToken\r
-\r
-o      Added virtual panic() to ANTLRAbstractToken.  Made ANTLRParser::panic()\r
-       virtual also.\r
-\r
-o      Cleaned up the dup() stuff in AST hierarchy to use shallowCopy() to\r
-       make node copies.  John Farr at Medtronic suggested this.  I.e.,\r
-       if you want to use dup() with either ANTLR or SORCERER or -transform\r
-       mode with SORCERER, you must defined shallowCopy() as:\r
-\r
-       virtual PCCTS_AST *shallowCopy()\r
-       {\r
-           return new AST;\r
-           p->setDown(NULL);\r
-           p->setRight(NULL);\r
-           return p;\r
-       }\r
-\r
-       or\r
-\r
-       virtual PCCTS_AST *shallowCopy()\r
-       {\r
-           return new AST(*this);\r
-       }\r
-       \r
-       if you have defined a copy constructor such as\r
-\r
-       AST(const AST &t)       // shallow copy constructor\r
-       {\r
-               token = t.token;\r
-               iconst = t.iconst;\r
-               setDown(NULL);\r
-               setRight(NULL);\r
-       }\r
-\r
-o      Added a warning with -CC and -gk are used together.  This is broken,\r
-       hence a warning is appropriate.\r
-\r
-o      Added warning when #-stuff is used w/o -gt option.\r
-\r
-o      Updated MPW installation.\r
-\r
-o      "Miller, Philip W." <MILLERPW f1groups.fsd.jhuapl.edu> suggested\r
-       that genmk be use RENAME_OBJ_FLAG RENAME_EXE_FLAG instead of\r
-       hardcoding "-o" in genmk.c.\r
-\r
-o      made all exit() calls use EXIT_SUCCESS or EXIT_FAILURE.\r
-\r
-===========================================================================\r
-1.33\r
-\r
-EXIT_FAILURE and EXIT_SUCCESS were not always defined.  I had to modify\r
-a bunch of files to use PCCTS_EXIT_XXX, which forces a new version.  Sorry\r
-about that.\r
-\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/CHANGES_FROM_133.txt b/Tools/CodeTools/TianoTools/Pccts/CHANGES_FROM_133.txt
deleted file mode 100644 (file)
index 2128c4f..0000000
+++ /dev/null
@@ -1,2448 +0,0 @@
-=======================================================================\r
-List of Implemented Fixes and Changes for Maintenance Releases of PCCTS\r
-=======================================================================\r
-\r
-                               DISCLAIMER\r
-\r
- The software and these notes are provided "as is".  They may include\r
- typographical or technical errors and their authors disclaims all\r
- liability of any kind or nature for damages due to error, fault,\r
- defect, or deficiency regardless of cause.  All warranties of any\r
- kind, either express or implied, including, but not limited to, the\r
- implied  warranties of merchantability and fitness for a particular\r
- purpose are disclaimed.\r
-\r
-\r
-        -------------------------------------------------------\r
-        Note:  Items #153 to #1 are now in a separate file named\r
-                CHANGES_FROM_133_BEFORE_MR13.txt\r
-        -------------------------------------------------------\r
-        \r
-#312. (Changed in MR33) Bug caused by change #299.\r
-\r
-       In change #299 a warning message was suppressed when there was\r
-       no LT(1) in a semantic predicate and max(k,ck) was 1.  The \r
-       changed caused the code which set a default predicate depth for\r
-       the semantic predicate to be left as 0 rather than set to 1.\r
-       \r
-       This manifested as an error at line #1559 of mrhost.c\r
-       \r
-       Reported by Peter Dulimov.\r
-           \r
-#311. (Changed in MR33) Added sorcer/lib to Makefile.\r
-\r
-    Reported by Dale Martin.\r
-            \r
-#310. (Changed in MR32) In C mode zzastPush was spelled zzastpush in one case.\r
-\r
-    Reported by Jean-Claude Durand\r
-    \r
-#309. (Changed in MR32) Renamed baseName because of VMS name conflict\r
-\r
-    Renamed baseName to pcctsBaseName to avoid library name conflict with\r
-    VMS library routine.  Reported by Jean-François PIÉRONNE.\r
-    \r
-#308. (Changed in MR32) Used "template" as name of formal in C routine\r
-\r
-       In astlib.h routine ast_scan a formal was named "template".  This caused\r
-       problems when the C code was compiled with a C++ compiler.  Reported by\r
-       Sabyasachi Dey.\r
-            \r
-#307. (Changed in MR31) Compiler dependent bug in function prototype generation\r
-    \r
-    The code which generated function prototypes contained a bug which\r
-    was compiler/optimization dependent.  Under some circumstance an\r
-    extra character would be included in portions of a function prototype.\r
-    \r
-    Reported by David Cook.\r
-    \r
-#306. (Changed in MR30) Validating predicate following a token\r
-\r
-    A validating predicate which immediately followed a token match \r
-    consumed the token after the predicate rather than before.  Prior\r
-    to this fix (in the following example) isValidTimeScaleValue() in\r
-    the predicate would test the text for TIMESCALE rather than for\r
-    NUMBER:\r
-     \r
-               time_scale :\r
-               TIMESCALE\r
-               <<isValidTimeScaleValue(LT(1)->getText())>>?\r
-               ts:NUMBER\r
-               ( us:MICROSECOND << tVal = ...>>\r
-               | ns:NANOSECOND << tVal = ...  >>\r
-               )\r
-       \r
-       Reported by Adalbert Perbandt.\r
-       \r
-#305. (Changed in MR30) Alternatives with guess blocks inside (...)* blocks.\r
-\r
-       In MR14 change #175 fixed a bug in the prediction expressions for guess\r
-       blocks which were of the form (alpha)? beta.  Unfortunately, this\r
-       resulted in a new bug as exemplified by the example below, which computed\r
-       the first set for r as {B} rather than {B C}:\r
-       \r
-                                       r : ( (A)? B\r
-                                           | C\r
-                                               )*\r
-  \r
-    This example doesn't make any sense as A is not a prefix of B, but it\r
-    illustrates the problem.  This bug did not appear for:\r
-    \r
-                               r : ( (A)?\r
-                                   | C\r
-                                   )*\r
-\r
-       because it does not use the (alpha)? beta form.\r
-\r
-       Item #175 fixed an asymmetry in ambiguity messages for the following\r
-       constructs which appear to have identical ambiguities (between repeating\r
-       the loop vs. exiting the loop).  MR30 retains this fix, but the implementation\r
-       is slightly different.\r
-       \r
-                 r_star : ( (A B)? )* A ;\r
-                 r_plus : ( (A B)? )+ A ;\r
-\r
-    Reported by Arpad Beszedes (beszedes inf.u-szeged.hu).\r
-    \r
-#304. (Changed in MR30) Crash when mismatch between output value counts.\r
-\r
-       For a rule such as:\r
-       \r
-               r1 : r2>[i,j];\r
-               r2 >[int i, int j] : A;\r
-               \r
-       If there were extra actuals for the reference to rule r2 from rule r1\r
-       there antlr would crash.  This bug was introduced by change #276.\r
-\r
-       Reported by Sinan Karasu.\r
-       \r
-#303. (Changed in MR30) DLGLexerBase::replchar\r
-\r
-       DLGLexerBase::replchar and the C mode routine zzreplchar did not work \r
-       properly when the new character was 0.\r
-      \r
-    Reported with fix by Philippe Laporte\r
-\r
-#302. (Changed in MR28) Fix significant problems in initial release of MR27.\r
-\r
-#301. (Changed in MR27) Default tab stops set to 2 spaces.\r
-\r
-    To have antlr generate true tabs rather than spaces, use "antlr -tab 0".\r
-    To generate 4 spaces per tab stop use "antlr -tab 4"\r
-    \r
-#300. (Changed in MR27)\r
-\r
-       Consider the following methods of constructing an AST from ID:\r
-       \r
-        rule1!\r
-                : id:ID << #0 = #[id]; >> ;\r
-        \r
-        rule2!\r
-                : id:ID << #0 = #id; >> ;\r
-        \r
-        rule3\r
-                : ID ;\r
-        \r
-        rule4\r
-                : id:ID << #0 = #id; >> ;\r
-        \r
-    For rule_2, the AST corresponding to id would always be NULL.  This\r
-    is because the user explicitly suppressed AST construction using the\r
-    "!" operator on the rule.  In MR27 the use of an AST expression\r
-    such as #id overrides the "!" operator and forces construction of\r
-    the AST.\r
-    \r
-    This fix does not apply to C mode ASTs when the ASTs are referenced\r
-    using numbers rather than symbols.\r
-\r
-       For C mode, this requires that the (optional) function/macro zzmk_ast\r
-       be defined.  This functions copies information from an attribute into\r
-       a previously allocated AST.\r
-\r
-    Reported by Jan Langer (jan langernetz.de)\r
-\r
-#299. (Changed in MR27) Don't warn if k=1 and semantic predicate missing LT(i)\r
-\r
-    If a semantic does not have a reference to LT(i) or (C mode LATEXT(i))\r
-    then pccts doesn't know how many lookahead tokens to use for context.\r
-    However, if max(k,ck) is 1 then there is really only one choice and\r
-    the warning is unnecessary.\r
-    \r
-#298. (Changed in MR27) Removed "register" for lastpos in dlgauto.c zzgettok\r
-\r
-#297. (Changed in MR27) Incorrect prototypes when used with classic C\r
-\r
-    There were a number of errors in function headers when antlr was\r
-    built with compilers that do not have __STDC__ or __cplusplus set.\r
-    \r
-    The functions which have variable length argument lists now use\r
-    PCCTS_USE_STDARG rather than __USE_PROTOTYPES__ to determine\r
-    whether to use stdargs or varargs.\r
-\r
-#296. (Changed in MR27) Complex return types in rules.\r
-\r
-    The following return type was not properly handled when \r
-    unpacking a struct with containing multiple return values:\r
-    \r
-      rule > [int i, IIR_Bool (IIR_Decl::*constraint)()] : ...    \r
-\r
-    Instead of using "constraint", the program got lost and used\r
-    an empty string.\r
-    \r
-    Reported by P.A. Wilsey.\r
-\r
-#295. (Changed in MR27) Extra ";" following zzGUESS_DONE sometimes.\r
-\r
-    Certain constructs with guess blocks in MR23 led to extra ";"\r
-    preceding the "else" clause of an "if".\r
-\r
-    Reported by P.A. Wilsey.\r
-    \r
-#294. (Changed in MR27) Infinite loop in antlr for nested blocks\r
-\r
-    An oversight in detecting an empty alternative sometimes led\r
-    to an infinite loop in antlr when it encountered a rule with\r
-    nested blocks and guess blocks.\r
-    \r
-    Reported by P.A. Wilsey.\r
-    \r
-#293. (Changed in MR27) Sorcerer optimization of _t->type()\r
-\r
-    Sorcerer generated code may contain many calls to _t->type() in a\r
-    single statement.  This change introduces a temporary variable\r
-    to eliminate unnnecesary function calls.\r
-\r
-    Change implemented by Tom Molteno (tim videoscript.com).\r
-\r
-#292. (Changed in MR27)\r
-\r
-    WARNING:  Item #267 changes the signature of methods in the AST class.\r
-\r
-    **** Be sure to revise your AST functions of the same name  ***\r
-\r
-#291. (Changed in MR24)\r
-\r
-    Fix to serious code generation error in MR23 for (...)+ block.\r
-\r
-#290. (Changed in MR23) \r
-\r
-    Item #247 describes a change in the way {...} blocks handled\r
-    an error.  Consider:\r
-\r
-            r1 : {A} b ;\r
-            b  : B;\r
-                \r
-                with input "C".\r
-\r
-    Prior to change #247, the error would resemble "expected B -\r
-    found C".  This is correct but incomplete, and therefore\r
-    misleading.  In #247 it was changed to "expected A, B - found\r
-    C".  This was fine, except for users of parser exception\r
-    handling because the exception was generated in the epilogue \r
-    for {...} block rather than in rule b.  This made it difficult\r
-    for users of parser exception handling because B was not\r
-    expected in that context. Those not using parser exception\r
-    handling didn't notice the difference.\r
-\r
-    The current change restores the behavior prior to #247 when\r
-    parser exceptions are present, but retains the revised behavior\r
-    otherwise.  This change should be visible only when exceptions\r
-    are in use and only for {...} blocks and sub-blocks of the form\r
-    (something|something | something | epsilon) where epsilon represents\r
-    an empty production and it is the last alternative of a sub-block.\r
-    In contrast, (something | epsilon | something) should generate the\r
-    same code as before, even when exceptions are used.\r
-    \r
-    Reported by Philippe Laporte (philippe at transvirtual.com).\r
-\r
-#289. (Changed in MR23) Bug in matching complement of a #tokclass\r
-\r
-    Prior to MR23 when a #tokclass was matched in both its complemented form\r
-    and uncomplemented form, the bit set generated for its first use was used\r
-    for both cases.  However, the prediction expression was correctly computed\r
-    in both cases.  This meant that the second case would never be matched\r
-    because, for the second appearance, the prediction expression and the \r
-    set to be matched would be complements of each other.\r
-        \r
-    Consider:\r
-        \r
-                #token A "a"\r
-                #token B "b"\r
-                #token C "c"\r
-                #tokclass AB {A B}\r
-                \r
-                r1 : AB    /* alt 1x */\r
-                   | ~AB   /* alt 1y */\r
-                   ;\r
-        \r
-    Prior to MR23, this resulted in alternative 1y being unreachable.  Had it\r
-    been written:\r
-        \r
-                r2 : ~AB  /* alt 2x */\r
-                   : AB   /* alt 2y */\r
-                   \r
-    then alternative 2y would have become unreachable.        \r
-        \r
-    This bug was only for the case of complemented #tokclass.  For complemented\r
-    #token the proper code was generated.           \r
-        \r
-#288. (Changed in MR23) #errclass not restricted to choice points\r
-\r
-    The #errclass directive is supposed to allow a programmer to define\r
-    print strings which should appear in syntax error messages as a replacement\r
-    for some combinations of tokens. For instance:\r
-    \r
-            #errclass Operator {PLUS MINUS TIMES DIVIDE}\r
-            \r
-    If a syntax message includes all four of these tokens, and there is no\r
-    "better" choice of error class, the word "Operator" will be used rather\r
-    than a list of the four token names.\r
-        \r
-    Prior to MR23 the #errclass definitions were used only at choice points\r
-    (which call the FAIL macro). In other cases where there was no choice\r
-    (e.g. where a single token or token class were matched) the #errclass\r
-    information was not used.\r
-\r
-    With MR23 the #errclass declarations are used for syntax error messages\r
-    when matching a #tokclass, a wildcard (i.e. "*"), or the complement of a\r
-    #token or #tokclass (e.g. ~Operator).\r
-\r
-    Please note that #errclass may now be defined using #tokclass names \r
-    (see Item #284).\r
-\r
-    Reported by Philip A. Wilsey.\r
-\r
-#287. (Changed in MR23) Print name for #tokclass\r
-\r
-    Item #148 describes how to give a print name to a #token so that,for\r
-    example, #token ID could have the expression "identifier" in syntax\r
-    error messages.  This has been extended to #tokclass:\r
-    \r
-            #token ID("identifier")  "[a-zA-Z]+"\r
-            #tokclass Primitive("primitive type") \r
-                                    {INT, FLOAT, CHAR, FLOAT, DOUBLE, BOOL} \r
-\r
-    This is really a cosmetic change, since #tokclass names do not appear\r
-    in any error messages.\r
-        \r
-#286. (Changed in MR23) Makefile change to use of cd\r
-\r
-    In cases where a pccts subdirectory name matched a directory identified\r
-    in a $CDPATH environment variable the build would fail.  All makefile\r
-    cd commands have been changed from "cd xyz" to "cd ./xyz" in order\r
-    to avoid this problem.\r
-        \r
-#285. (Changed in MR23) Check for null pointers in some dlg structures\r
-\r
-    An invalid regular expression can cause dlg to build an invalid\r
-    structure to represent the regular expression even while it issues \r
-    error messages.  Additional pointer checks were added.\r
-\r
-    Reported by Robert Sherry.\r
-\r
-#284. (Changed in MR23) Allow #tokclass in #errclass definitions\r
-\r
-    Previously, a #tokclass reference in the definition of an\r
-    #errclass was not handled properly. Instead of being expanded\r
-    into the set of tokens represented by the #tokclass it was\r
-    treated somewhat like an #errclass.  However, in a later phase\r
-    when all #errclass were expanded into the corresponding tokens\r
-    the #tokclass reference was not expanded (because it wasn't an\r
-    #errclass).  In effect the reference was ignored.\r
-\r
-    This has been fixed.\r
-\r
-    Problem reported by Mike Dimmick (mike dimmick.demon.co.uk).\r
-\r
-#283. (Changed in MR23) Option -tmake invoke's parser's tmake \r
-\r
-    When the string #(...) appears in an action antlr replaces it with\r
-    a call to ASTBase::tmake(...) to construct an AST.  It is sometimes\r
-    useful to change the tmake routine so that it has access to information\r
-    in the parser - something which is not possible with a static method\r
-    in an application where they may be multiple parsers active.\r
-\r
-    The antlr option -tmake replaces the call to ASTBase::tmake with a call\r
-    to a user supplied tmake routine.\r
-   \r
-#282. (Changed in MR23) Initialization error for DBG_REFCOUNTTOKEN\r
-\r
-    When the pre-processor symbol DBG_REFCOUNTTOKEN is defined \r
-    incorrect code is generated to initialize ANTLRRefCountToken::ctor and\r
-    dtor.\r
-\r
-    Fix reported by Sven Kuehn (sven sevenkuehn.de).\r
-   \r
-#281. (Changed in MR23) Addition of -noctor option for Sorcerer\r
-\r
-    Added a -noctor option to suppress generation of the blank ctor\r
-    for users who wish to define their own ctor.\r
-\r
-    Contributed by Jan Langer (jan langernetz.de).\r
-\r
-#280. (Changed in MR23) Syntax error message for EOF token\r
-\r
-    The EOF token now receives special treatment in syntax error messages\r
-    because there is no text matched by the eof token.  The token name\r
-    of the eof token is used unless it is "@" - in which case the string\r
-    "<eof>" is used.\r
-\r
-    Problem reported by Erwin Achermann (erwin.achermann switzerland.org).\r
-\r
-#279. (Changed in MR23) Exception groups\r
-\r
-    There was a bug in the way that exception groups were attached to\r
-    alternatives which caused problems when there was a block contained\r
-    in an alternative.  For instance, in the following rule;\r
-\r
-        statement : IF S { ELSE S } \r
-                        exception ....\r
-        ;\r
-\r
-    the exception would be attached to the {...} block instead of the \r
-    entire alternative because it was attached, in error, to the last\r
-    alternative instead of the last OPEN alternative.\r
-\r
-    Reported by Ty Mordane (tymordane hotmail.com).\r
-    \r
-#278. (Changed in MR23) makefile changes\r
-\r
-    Contributed by Tomasz Babczynski (faster lab05-7.ict.pwr.wroc.pl).\r
-\r
-    The -cfile option is not absolutely needed: when extension of\r
-    source file is one of the well-known C/C++ extensions it is \r
-    treated as C/C++ source\r
-\r
-    The gnu make defines the CXX variable as the default C++ compiler\r
-    name, so I added a line to copy this (if defined) to the CCC var.\r
-\r
-    Added a -sor option: after it any -class command defines the class\r
-    name for sorcerer, not for ANTLR.  A file extended with .sor is \r
-    treated as sorcerer input.  Because sorcerer can be called multiple\r
-    times, -sor option can be repeated.  Any files and classes (one class\r
-    per group) after each -sor makes one tree parser.\r
-\r
-    Not implemented:\r
-\r
-        1. Generate dependences for user c/c++ files.\r
-        2. Support for -sor in c mode not.\r
-\r
-    I have left the old genmk program in the directory as genmk_old.c.\r
-\r
-#277. (Changed in MR23) Change in macro for failed semantic predicates\r
-\r
-    In the past, a semantic predicate that failed generated a call to\r
-    the macro zzfailed_pred:\r
-\r
-        #ifndef zzfailed_pred\r
-        #define zzfailed_pred(_p) \\r
-          if (guessing) { \\r
-            zzGUESS_FAIL; \\r
-          } else { \\r
-            something(_p)\r
-          }\r
-        #endif\r
-\r
-    If a user wished to use the failed action option for semantic predicates:\r
-\r
-        rule : <<my_predicate>>? [my_fail_action] A\r
-             | ...\r
-\r
-           \r
-    the code for my_fail_action would have to contain logic for handling\r
-    the guess part of the zzfailed_pred macro.  The user should not have\r
-    to be aware of the guess logic in writing the fail action.\r
-\r
-    The zzfailed_pred has been rewritten to have three arguments:\r
-\r
-            arg 1: the stringized predicate of the semantic predicate\r
-            arg 2: 0 => there is no user-defined fail action\r
-                   1 => there is a user-defined fail action\r
-            arg 3: the user-defined fail action (if defined)\r
-                   otherwise a no-operation\r
-\r
-    The zzfailed_pred macro is now defined as:\r
-\r
-        #ifndef zzfailed_pred\r
-        #define zzfailed_pred(_p,_hasuseraction,_useraction) \\r
-          if (guessing) { \\r
-            zzGUESS_FAIL; \\r
-          } else { \\r
-            zzfailed_pred_action(_p,_hasuseraction,_useraction) \\r
-          }\r
-        #endif\r
-\r
-\r
-    With zzfailed_pred_action defined as:\r
-\r
-        #ifndef zzfailed_pred_action\r
-        #define zzfailed_pred_action(_p,_hasuseraction,_useraction) \\r
-            if (_hasUserAction) { _useraction } else { failedSemanticPredicate(_p); }\r
-        #endif\r
-\r
-    In C++ mode failedSemanticPredicate() is a virtual function.\r
-    In C mode the default action is a fprintf statement.\r
-\r
-    Suggested by Erwin Achermann (erwin.achermann switzerland.org).\r
-\r
-#276. (Changed in MR23) Addition of return value initialization syntax\r
-\r
-    In an attempt to reduce the problems caused by the PURIFY macro I have\r
-    added new syntax for initializing the return value of rules and the\r
-    antlr option "-nopurify".\r
-\r
-    A rule with a single return argument:\r
-\r
-        r1 > [Foo f = expr] :\r
-\r
-    now generates code that resembles:\r
-\r
-        Foo r1(void) {\r
-          Foo _retv = expr;\r
-          ...\r
-        }\r
-  \r
-    A rule with more than one return argument:\r
-\r
-        r2 > [Foo f = expr1, Bar b = expr2 ] :\r
-\r
-    generates code that resembles:\r
-\r
-        struct _rv1 {\r
-            Foo f;\r
-            Bar b;\r
-        }\r
-\r
-        _rv1 r2(void) {\r
-          struct _rv1 _retv;\r
-          _retv.f = expr1;\r
-          _retv.b = expr2;\r
-          ...\r
-        }\r
-\r
-    C++ style comments appearing in the initialization list may cause problems.\r
-\r
-#275. (Changed in MR23) Addition of -nopurify option to antlr\r
-\r
-    A long time ago the PURIFY macro was introduced to initialize\r
-    return value arguments and get rid of annying messages from program\r
-    that checked for unitialized variables.\r
-\r
-    This has caused significant annoyance for C++ users that had\r
-    classes with virtual functions or non-trivial contructors because\r
-    it would zero the object, including the pointer to the virtual\r
-    function table.  This could be defeated by redefining\r
-    the PURIFY macro to be empty, but it was a constant surprise to\r
-    new C++ users of pccts.\r
-\r
-    I would like to remove it, but I fear that some existing programs\r
-    depend on it and would break.  My temporary solution is to add\r
-    an antlr option -nopurify which disables generation of the PURIFY\r
-    macro call.\r
-\r
-    The PURIFY macro should be avoided in favor of the new syntax\r
-    for initializing return arguments described in item #275.\r
-\r
-    To avoid name clash, the PURIFY macro has been renamed PCCTS_PURIFY.\r
-\r
-#274. (Changed in MR23) DLexer.cpp renamed to DLexer.h\r
-      (Changed in MR23) ATokPtr.cpp renamed to ATokPtrImpl.h\r
-\r
-    These two files had .cpp extensions but acted like .h files because\r
-    there were included in other files. This caused problems for many IDE.\r
-    I have renamed them.  The ATokPtrImpl.h was necessary because there was\r
-    already an ATokPtr.h.\r
-\r
-#273. (Changed in MR23) Default win32 library changed to multi-threaded DLL\r
-\r
-    The model used for building the Win32 debug and release libraries has changed\r
-    to multi-threaded DLL.\r
-\r
-    To make this change in your MSVC 6 project:\r
-\r
-        Project -> Settings\r
-        Select the C++ tab in the right pane of the dialog box\r
-        Select "Category: Code Generation"\r
-        Under "Use run-time library" select one of the following:\r
-\r
-            Multi-threaded DLL\r
-            Debug Multi-threaded DLL\r
-           \r
-    Suggested by Bill Menees (bill.menees gogallagher.com) \r
-    \r
-#272. (Changed in MR23) Failed semantic predicate reported via virtual function\r
-\r
-    In the past, a failed semantic predicated reported the problem via a\r
-    macro which used fprintf().  The macro now expands into a call on \r
-    the virtual function ANTLRParser::failedSemanticPredicate().\r
-\r
-#271. (Changed in MR23) Warning for LT(i), LATEXT(i) in token match actions\r
-\r
-    An bug (or at least an oddity) is that a reference to LT(1), LA(1),\r
-    or LATEXT(1) in an action which immediately follows a token match\r
-    in a rule refers to the token matched, not the token which is in\r
-    the lookahead buffer.  Consider:\r
-\r
-        r : abc <<action alpha>> D <<action beta>> E;\r
-\r
-    In this case LT(1) in action alpha will refer to the next token in\r
-    the lookahead buffer ("D"), but LT(1) in action beta will refer to\r
-    the token matched by D - the preceding token.\r
-\r
-    A warning has been added for users about this when an action\r
-    following a token match contains a reference to LT(1), LA(1), or LATEXT(1).\r
-\r
-    This behavior should be changed, but it appears in too many programs\r
-    now.  Another problem, perhaps more significant, is that the obvious\r
-    fix (moving the consume() call to before the action) could change the \r
-    order in which input is requested and output appears in existing programs.\r
-\r
-    This problem was reported, along with a fix by Benjamin Mandel\r
-    (beny sd.co.il).  However, I felt that changing the behavior was too\r
-    dangerous for existing code.\r
-\r
-#270. (Changed in MR23) Removed static objects from PCCTSAST.cpp\r
-\r
-    There were some statically allocated objects in PCCTSAST.cpp\r
-    These were changed to non-static.\r
-\r
-#269. (Changed in MR23) dlg output for initializing static array\r
-\r
-    The output from dlg contains a construct similar to the\r
-    following:\r
-   \r
-        struct XXX {\r
-          static const int size;\r
-          static int array1[5];\r
-        };\r
-\r
-        const int XXX::size = 4;\r
-        int XXX::array1[size+1];\r
-\r
-    \r
-    The problem is that although the expression "size+1" used in\r
-    the definition of array1 is equal to 5 (the expression used to\r
-    declare array), it is not considered equivalent by some compilers.\r
-\r
-    Reported with fix by Volker H. Simonis (simonis informatik.uni-tuebingen.de)\r
-\r
-#268. (Changed in MR23) syn() routine output when k > 1\r
-\r
-    The syn() routine is supposed to print out the text of the\r
-    token causing the syntax error.  It appears that it always\r
-    used the text from the first lookahead token rather than the\r
-    appropriate one.  The appropriate one is computed by comparing\r
-    the token codes of lookahead token i (for i = 1 to k) with\r
-    the FIRST(i) set.\r
-    \r
-    This has been corrected in ANTLRParser::syn().\r
-\r
-    Reported by Bill Menees (bill.menees gogallagher.com) \r
-\r
-#267. (Changed in MR23) AST traversal functions client data argument\r
-\r
-    The AST traversal functions now take an extra (optional) parameter\r
-    which can point to client data:\r
-\r
-        preorder_action(void* pData = NULL)\r
-        preorder_before_action(void* pData = NULL)\r
-        preorder_after_action(void* pData = NULL)\r
-\r
-    ****       Warning: this changes the AST signature.         ***\r
-    **** Be sure to revise your AST functions of the same name  ***\r
-\r
-    Bill Menees (bill.menees gogallagher.com) \r
-    \r
-#266. (Changed in MR23) virtual function printMessage()\r
-\r
-    Bill Menees (bill.menees gogallagher.com) has completed the\r
-    tedious taks of replacing all calls to fprintf() with calls\r
-    to the virtual function printMessage().  For classes which\r
-    have a pointer to the parser it forwards the printMessage()\r
-    call to the parser's printMessage() routine.\r
-\r
-    This should make it significanly easier to redirect pccts\r
-    error and warning messages.\r
-\r
-#265. (Changed in MR23) Remove "labase++" in C++ mode\r
-\r
-    In C++ mode labase++ is called when a token is matched.\r
-    It appears that labase is not used in C++ mode at all, so\r
-    this code has been commented out.\r
-    \r
-#264. (Changed in MR23) Complete rewrite of ParserBlackBox.h\r
-\r
-    The parser black box (PBlackBox.h) was completely rewritten\r
-    by Chris Uzdavinis (chris atdesk.com) to improve its robustness.\r
-\r
-#263. (Changed in MR23) -preamble and -preamble_first rescinded\r
-\r
-    Changes for item #253 have been rescinded.\r
-\r
-#262. (Changed in MR23) Crash with -alpha option during traceback\r
-\r
-    Under some circumstances a -alpha traceback was started at the\r
-    "wrong" time.  As a result, internal data structures were not\r
-    initialized.\r
-\r
-    Reported by Arpad Beszedes (beszedes inf.u-szeged.hu).\r
-\r
-#261. (Changed in MR23) Defer token fetch for C++ mode\r
-\r
-    Item #216 has been revised to indicate that use of the defer fetch\r
-    option (ZZDEFER_FETCH) requires dlg option -i.\r
-\r
-#260. (MR22) Raise default lex buffer size from 8,000 to 32,000 bytes.\r
-\r
-    ZZLEXBUFSIZE is the size (in bytes) of the buffer used by dlg \r
-    generated lexers.  The default value has been raised to 32,000 and\r
-    the value used by antlr, dlg, and sorcerer has also been raised to\r
-    32,000.\r
-\r
-#259. (MR22) Default function arguments in C++ mode.\r
-\r
-    If a rule is declared:\r
-\r
-            rr [int i = 0] : ....\r
-\r
-    then the declaration generated by pccts resembles:\r
-\r
-            void rr(int i = 0);\r
-\r
-    however, the definition must omit the default argument:\r
-\r
-            void rr(int i) {...}\r
-\r
-    In the past the default value was not omitted.  In MR22\r
-    the generated code resembles:\r
-\r
-            void rr(int i /* = 0 */ ) {...}\r
-\r
-    Implemented by Volker H. Simonis (simonis informatik.uni-tuebingen.de)\r
-\r
-\r
-    Note: In MR23 this was changed so that nested C style comments\r
-    ("/* ... */") would not cause problems.\r
-\r
-#258. (MR22)  Using a base class for your parser\r
-\r
-    In item #102 (MR10) the class statement was extended to allow one\r
-    to specify a base class other than ANTLRParser for the generated\r
-    parser.  It turned out that this was less than useful because\r
-    the constructor still specified ANTLRParser as the base class.\r
-\r
-    The class statement now uses the first identifier appearing after\r
-    the ":" as the name of the base class.  For example:\r
-\r
-        class MyParser : public FooParser {\r
-\r
-    Generates in MyParser.h:\r
-\r
-            class MyParser : public FooParser {\r
-\r
-    Generates in MyParser.cpp something that resembles:\r
-\r
-            MyParser::MyParser(ANTLRTokenBuffer *input) :\r
-                                         FooParser(input,1,0,0,4)\r
-            {\r
-                token_tbl = _token_tbl;\r
-                traceOptionValueDefault=1;    // MR10 turn trace ON\r
-            }\r
-\r
-    The base class constructor must have a signature similar to\r
-    that of ANTLRParser.\r
-\r
-#257. (MR21a) Removed dlg statement that -i has no effect in C++ mode.\r
-\r
-    This was incorrect.\r
-\r
-#256. (MR21a) Malformed syntax graph causes crash after error message.\r
-\r
-    In the past, certain kinds of errors in the very first grammar\r
-    element could cause the construction of a malformed graph \r
-    representing the grammar.  This would eventually result in a\r
-    fatal internal error.  The code has been changed to be more\r
-    resistant to this particular error.\r
-\r
-#255. (MR21a) ParserBlackBox(FILE* f) \r
-\r
-    This constructor set openByBlackBox to the wrong value.\r
-\r
-    Reported by Kees Bakker (kees_bakker tasking.nl).\r
-\r
-#254. (MR21a) Reporting syntax error at end-of-file\r
-\r
-    When there was a syntax error at the end-of-file the syntax\r
-    error routine would substitute "<eof>" for the programmer's\r
-    end-of-file symbol.  This substitution is now done only when\r
-    the programmer does not define his own end-of-file symbol\r
-    or the symbol begins with the character "@".\r
-\r
-    Reported by Kees Bakker (kees_bakker tasking.nl).\r
-\r
-#253. (MR21) Generation of block preamble (-preamble and -preamble_first)\r
-\r
-        *** This change was rescinded by item #263 ***\r
-\r
-    The antlr option -preamble causes antlr to insert the code\r
-    BLOCK_PREAMBLE at the start of each rule and block.  It does\r
-    not insert code before rules references, token references, or\r
-    actions.  By properly defining the macro BLOCK_PREAMBLE the\r
-    user can generate code which is specific to the start of blocks.\r
-\r
-    The antlr option -preamble_first is similar, but inserts the\r
-    code BLOCK_PREAMBLE_FIRST(PreambleFirst_123) where the symbol\r
-    PreambleFirst_123 is equivalent to the first set defined by\r
-    the #FirstSetSymbol described in Item #248.\r
-\r
-    I have not investigated how these options interact with guess\r
-    mode (syntactic predicates).\r
-\r
-#252. (MR21) Check for null pointer in trace routine\r
-\r
-    When some trace options are used when the parser is generated\r
-    without the trace enabled, the current rule name may be a\r
-    NULL pointer.  A guard was added to check for this in\r
-    restoreState.\r
-\r
-    Reported by Douglas E. Forester (dougf projtech.com).\r
-\r
-#251. (MR21) Changes to #define zzTRACE_RULES\r
-\r
-    The macro zzTRACE_RULES was being use to pass information to\r
-    AParser.h.  If this preprocessor symbol was not properly\r
-    set the first time AParser.h was #included, the declaration\r
-    of zzTRACEdata would be omitted (it is used by the -gd option).\r
-    Subsequent #includes of AParser.h would be skipped because of \r
-    the #ifdef guard, so the declaration of zzTracePrevRuleName would\r
-    never be made.  The result was that proper compilation was very \r
-    order dependent.\r
-\r
-    The declaration of zzTRACEdata was made unconditional and the\r
-    problem of removing unused declarations will be left to optimizers.\r
-    \r
-    Diagnosed by Douglas E. Forester (dougf projtech.com).\r
-\r
-#250. (MR21) Option for EXPERIMENTAL change to error sets for blocks\r
-\r
-    The antlr option -mrblkerr turns on an experimental feature\r
-    which is supposed to provide more accurate syntax error messages\r
-    for k=1, ck=1 grammars.  When used with k>1 or ck>1 grammars the\r
-    behavior should be no worse than the current behavior.\r
-\r
-    There is no problem with the matching of elements or the computation\r
-    of prediction expressions in pccts.  The task is only one of listing\r
-    the most appropriate tokens in the error message.  The error sets used\r
-    in pccts error messages are approximations of the exact error set when\r
-    optional elements in (...)* or (...)+ are involved.  While entirely\r
-    correct, the error messages are sometimes not 100% accurate.  \r
-\r
-    There is also a minor philosophical issue.  For example, suppose the\r
-    grammar expects the token to be an optional A followed by Z, and it \r
-    is X.  X, of course, is neither A nor Z, so an error message is appropriate.\r
-    Is it appropriate to say "Expected Z" ?  It is correct, it is accurate,\r
-    but it is not complete.  \r
-\r
-    When k>1 or ck>1 the problem of providing the exactly correct\r
-    list of tokens for the syntax error messages ends up becoming\r
-    equivalent to evaluating the prediction expression for the\r
-    alternatives twice. However, for k=1 ck=1 grammars the prediction\r
-    expression can be computed easily and evaluated cheaply, so I\r
-    decided to try implementing it to satisfy a particular application.\r
-    This application uses the error set in an interactive command language\r
-    to provide prompts which list the alternatives available at that\r
-    point in the parser.  The user can then enter additional tokens to\r
-    complete the command line.  To do this required more accurate error \r
-    sets then previously provided by pccts.\r
-\r
-    In some cases the default pccts behavior may lead to more robust error\r
-    recovery or clearer error messages then having the exact set of tokens.\r
-    This is because (a) features like -ge allow the use of symbolic names for\r
-    certain sets of tokens, so having extra tokens may simply obscure things\r
-    and (b) the error set is use to resynchronize the parser, so a good\r
-    choice is sometimes more important than having the exact set.\r
-\r
-    Consider the following example:\r
-\r
-            Note:  All examples code has been abbreviated\r
-            to the absolute minimum in order to make the\r
-            examples concise.\r
-\r
-        star1 : (A)* Z;\r
-\r
-    The generated code resembles:\r
-\r
-           old                new (with -mrblkerr)\r
-        --//-----------         --------------------\r
-        for (;;) {            for (;;) {\r
-            match(A);           match(A);\r
-        }                     }\r
-        match(Z);             if (! A and ! Z) then\r
-                                FAIL(...{A,Z}...);\r
-                              }\r
-                              match(Z);\r
-\r
-\r
-        With input X\r
-            old message: Found X, expected Z\r
-            new message: Found X, expected A, Z\r
-\r
-    For the example:\r
-\r
-        star2 : (A|B)* Z;\r
-\r
-           old                      new (with -mrblkerr)\r
-        -------------               --------------------\r
-        for (;;) {                  for (;;) {\r
-          if (!A and !B) break;       if (!A and !B) break;\r
-          if (...) {                  if (...) {\r
-            <same ...>                  <same ...>\r
-          }                           }\r
-          else {                      else {\r
-            FAIL(...{A,B,Z}...)         FAIL(...{A,B}...);\r
-          }                           }\r
-        }                           }\r
-        match(B);                   if (! A and ! B and !Z) then\r
-                                        FAIL(...{A,B,Z}...);\r
-                                    }\r
-                                    match(B);\r
-\r
-        With input X\r
-            old message: Found X, expected Z\r
-            new message: Found X, expected A, B, Z\r
-        With input A X\r
-            old message: Found X, expected Z\r
-            new message: Found X, expected A, B, Z\r
-\r
-            This includes the choice of looping back to the\r
-            star block.\r
-\r
-    The code for plus blocks:\r
-\r
-        plus1 : (A)+ Z;\r
-\r
-    The generated code resembles:\r
-\r
-           old                  new (with -mrblkerr)\r
-        -------------           --------------------\r
-        do {                    do {\r
-          match(A);               match(A);\r
-        } while (A)             } while (A)\r
-        match(Z);               if (! A and ! Z) then\r
-                                  FAIL(...{A,Z}...);\r
-                                }\r
-                                match(Z);\r
-\r
-        With input A X\r
-            old message: Found X, expected Z\r
-            new message: Found X, expected A, Z\r
-\r
-            This includes the choice of looping back to the\r
-            plus block.\r
-\r
-    For the example:\r
-\r
-        plus2 : (A|B)+ Z;\r
-\r
-           old                    new (with -mrblkerr)\r
-        -------------             --------------------\r
-        do {                        do {\r
-          if (A) {                    <same>\r
-            match(A);                 <same>\r
-          } else if (B) {             <same>\r
-            match(B);                 <same>\r
-          } else {                    <same>\r
-            if (cnt > 1) break;       <same>\r
-            FAIL(...{A,B,Z}...)         FAIL(...{A,B}...);\r
-          }                           }\r
-          cnt++;                      <same>\r
-        }                           }\r
-\r
-        match(Z);                   if (! A and ! B and !Z) then\r
-                                        FAIL(...{A,B,Z}...);\r
-                                    }\r
-                                    match(B);\r
-\r
-        With input X\r
-            old message: Found X, expected A, B, Z\r
-            new message: Found X, expected A, B\r
-        With input A X\r
-            old message: Found X, expected Z\r
-            new message: Found X, expected A, B, Z\r
-\r
-            This includes the choice of looping back to the\r
-            star block.\r
-    \r
-#249. (MR21) Changes for DEC/VMS systems\r
-\r
-    Jean-François Piéronne (jfp altavista.net) has updated some\r
-    VMS related command files and fixed some minor problems related\r
-    to building pccts under the DEC/VMS operating system.  For DEC/VMS\r
-    users the most important differences are:\r
-\r
-        a.  Revised makefile.vms\r
-        b.  Revised genMMS for genrating VMS style makefiles.\r
-\r
-#248. (MR21) Generate symbol for first set of an alternative\r
-\r
-    pccts can generate a symbol which represents the tokens which may\r
-    appear at the start of a block:\r
-\r
-        rr : #FirstSetSymbol(rr_FirstSet)  ( Foo | Bar ) ;\r
-\r
-    This will generate the symbol rr_FirstSet of type SetWordType with\r
-    elements Foo and Bar set. The bits can be tested using code similar \r
-    to the following:\r
-\r
-        if (set_el(Foo, &rr_FirstSet)) { ...\r
-\r
-    This can be combined with the C array zztokens[] or the C++ routine\r
-    tokenName() to get the print name of the token in the first set.\r
-\r
-    The size of the set is given by the newly added enum SET_SIZE, a \r
-    protected member of the generated parser's class.  The number of\r
-    elements in the generated set will not be exactly equal to the \r
-    value of SET_SIZE because of synthetic tokens created by #tokclass,\r
-    #errclass, the -ge option, and meta-tokens such as epsilon, and\r
-    end-of-file.\r
-\r
-    The #FirstSetSymbol must appear immediately before a block\r
-    such as (...)+, (...)*, and {...}, and (...).  It may not appear\r
-    immediately before a token, a rule reference, or action.  However\r
-    a token or rule reference can be enclosed in a (...) in order to\r
-    make the use of #pragma FirstSetSymbol legal.\r
-\r
-            rr_bad : #FirstSetSymbol(rr_bad_FirstSet) Foo;   //  Illegal\r
-\r
-            rr_ok :  #FirstSetSymbol(rr_ok_FirstSet) (Foo);  //  Legal\r
-    \r
-    Do not confuse FirstSetSymbol sets with the sets used for testing\r
-    lookahead. The sets used for FirstSetSymbol have one element per bit,\r
-    so the number of bytes  is approximately the largest token number\r
-    divided by 8.  The sets used for testing lookahead store 8 lookahead \r
-    sets per byte, so the length of the array is approximately the largest\r
-    token number.\r
-\r
-    If there is demand, a similar routine for follow sets can be added.\r
-\r
-#247. (MR21) Misleading error message on syntax error for optional elements.\r
-\r
-        ===================================================\r
-        The behavior has been revised when parser exception\r
-        handling is used.  See Item #290\r
-        ===================================================\r
-\r
-    Prior to MR21, tokens which were optional did not appear in syntax\r
-    error messages if the block which immediately followed detected a \r
-    syntax error.\r
-\r
-    Consider the following grammar which accepts Number, Word, and Other:\r
-\r
-            rr : {Number} Word;\r
-\r
-    For this rule the code resembles:\r
-\r
-            if (LA(1) == Number) {\r
-                match(Number);\r
-                consume();\r
-            }\r
-            match(Word);\r
-\r
-    Prior to MR21, the error message for input "$ a" would be:\r
-\r
-            line 1: syntax error at "$" missing Word\r
-\r
-    With MR21 the message will be:\r
-\r
-            line 1: syntax error at "$" expecting Word, Number.\r
-\r
-    The generate code resembles:\r
-\r
-            if ( (LA(1)==Number) ) {\r
-                zzmatch(Number);\r
-                consume();\r
-            }\r
-            else {\r
-                if ( (LA(1)==Word) ) {\r
-                    /* nothing */\r
-                }\r
-                else {\r
-                    FAIL(... message for both Number and Word ...);\r
-                }\r
-            }\r
-            match(Word);\r
-        \r
-    The code generated for optional blocks in MR21 is slightly longer\r
-    than the previous versions, but it should give better error messages.\r
-\r
-    The code generated for:\r
-\r
-            { a | b | c }\r
-\r
-    should now be *identical* to:\r
-\r
-            ( a | b | c | )\r
-\r
-    which was not the case prior to MR21.\r
-\r
-    Reported by Sue Marvin (sue siara.com).\r
-\r
-#246. (Changed in MR21) Use of $(MAKE) for calls to make\r
-\r
-    Calls to make from the makefiles were replaced with $(MAKE)\r
-    because of problems when using gmake.\r
-\r
-    Reported with fix by Sunil K.Vallamkonda (sunil siara.com).\r
-\r
-#245. (Changed in MR21) Changes to genmk\r
-\r
-    The following command line options have been added to genmk:\r
-\r
-        -cfiles ... \r
-            \r
-            To add a user's C or C++ files into makefile automatically.\r
-            The list of files must be enclosed in apostrophes.  This\r
-            option may be specified multiple times.\r
-\r
-        -compiler ...\r
-    \r
-            The name of the compiler to use for $(CCC) or $(CC).  The\r
-            default in C++ mode is "CC".  The default in C mode is "cc".\r
-\r
-        -pccts_path ...\r
-\r
-            The value for $(PCCTS), the pccts directory.  The default\r
-            is /usr/local/pccts.\r
-\r
-    Contributed by Tomasz Babczynski (t.babczynski ict.pwr.wroc.pl).\r
-\r
-#244. (Changed in MR21) Rename variable "not" in antlr.g\r
-\r
-    When antlr.g is compiled with a C++ compiler, a variable named\r
-    "not" causes problems.  Reported by Sinan Karasu\r
-    (sinan.karasu boeing.com).\r
-\r
-#243  (Changed in MR21) Replace recursion with iteration in zzfree_ast\r
-\r
-    Another refinement to zzfree_ast in ast.c to limit recursion.\r
-\r
-    NAKAJIMA Mutsuki (muc isr.co.jp).\r
-\r
-\r
-#242.  (Changed in MR21) LineInfoFormatStr\r
-\r
-    Added an #ifndef/#endif around LineInfoFormatStr in pcctscfg.h.\r
-\r
-#241. (Changed in MR21) Changed macro PURIFY to a no-op\r
-\r
-                ***********************\r
-                *** NOT IMPLEMENTED ***\r
-                ***********************\r
-\r
-        The PURIFY macro was changed to a no-op because it was causing \r
-        problems when passing C++ objects.\r
-    \r
-        The old definition:\r
-    \r
-            #define PURIFY(r,s)     memset((char *) &(r),'\\0',(s));\r
-    \r
-        The new definition:\r
-    \r
-            #define PURIFY(r,s)     /* nothing */\r
-#endif\r
-\r
-#240. (Changed in MR21) sorcerer/h/sorcerer.h _MATCH and _MATCHRANGE\r
-\r
-    Added test for NULL token pointer.\r
-\r
-    Suggested by Peter Keller (keller ebi.ac.uk)\r
-\r
-#239. (Changed in MR21) C++ mode AParser::traceGuessFail\r
-\r
-    If tracing is turned on when the code has been generated\r
-    without trace code, a failed guess generates a trace report\r
-    even though there are no other trace reports.  This\r
-    make the behavior consistent with other parts of the\r
-    trace system.\r
-\r
-    Reported by David Wigg (wiggjd sbu.ac.uk).\r
-\r
-#238. (Changed in MR21) Namespace version #include files\r
-\r
-    Changed reference from CStdio to cstdio (and other\r
-    #include file names) in the namespace version of pccts.\r
-    Should have known better.\r
-\r
-#237. (Changed in MR21) ParserBlackBox(FILE*)\r
-    \r
-    In the past, ParserBlackBox would close the FILE in the dtor\r
-    even though it was not opened by ParserBlackBox.  The problem\r
-    is that there were two constructors, one which accepted a file   \r
-    name and did an fopen, the other which accepted a FILE and did\r
-    not do an fopen.  There is now an extra member variable which\r
-    remembers whether ParserBlackBox did the open or not.\r
-\r
-    Suggested by Mike Percy (mpercy scires.com).\r
-\r
-#236. (Changed in MR21) tmake now reports down pointer problem\r
-\r
-    When ASTBase::tmake attempts to update the down pointer of \r
-    an AST it checks to see if the down pointer is NULL.  If it\r
-    is not NULL it does not do the update and returns NULL.\r
-    An attempt to update the down pointer is almost always a\r
-    result of a user error.  This can lead to difficult to find\r
-    problems during tree construction.\r
-\r
-    With this change, the routine calls a virtual function\r
-    reportOverwriteOfDownPointer() which calls panic to\r
-    report the problem.  Users who want the old behavior can\r
-    redefined the virtual function in their AST class.\r
-\r
-    Suggested by Sinan Karasu (sinan.karasu boeing.com)\r
-\r
-#235. (Changed in MR21) Made ANTLRParser::resynch() virtual\r
-\r
-    Suggested by Jerry Evans (jerry swsl.co.uk).\r
-\r
-#234. (Changed in MR21) Implicit int for function return value\r
-\r
-    ATokenBuffer:bufferSize() did not specify a type for the\r
-    return value.\r
-\r
-    Reported by Hai Vo-Ba (hai fc.hp.com).\r
-\r
-#233. (Changed in MR20) Converted to MSVC 6.0\r
-\r
-    Due to external circumstances I have had to convert to MSVC 6.0\r
-    The MSVC 5.0 project files (.dsw and .dsp) have been retained as\r
-    xxx50.dsp and xxx50.dsw.  The MSVC 6.0 files are named xxx60.dsp\r
-    and xxx60.dsw (where xxx is the related to the directory/project).\r
-\r
-#232. (Changed in MR20) Make setwd bit vectors protected in parser.h\r
-\r
-    The access for the setwd array in the parser header was not\r
-    specified.  As a result, it would depend on the code which \r
-    preceded it.  In MR20 it will always have access "protected".\r
-\r
-    Reported by Piotr Eljasiak (eljasiak zt.gdansk.tpsa.pl).\r
-\r
-#231. (Changed in MR20) Error in token buffer debug code.\r
-\r
-    When token buffer debugging is selected via the pre-processor\r
-    symbol DEBUG_TOKENBUFFER there is an erroneous check in\r
-    AParser.cpp:\r
-\r
-        #ifdef DEBUG_TOKENBUFFER\r
-            if (i >= inputTokens->bufferSize() ||\r
-                inputTokens->minTokens() < LLk )     /* MR20 Was "<=" */\r
-        ...\r
-        #endif\r
-\r
-    Reported by David Wigg (wiggjd sbu.ac.uk).\r
-\r
-#230. (Changed in MR20) Fixed problem with #define for -gd option\r
-\r
-    There was an error in setting zzTRACE_RULES for the -gd (trace) option.\r
-\r
-    Reported by Gary Funck (gary intrepid.com).\r
-\r
-#229. (Changed in MR20) Additional "const" for literals\r
-\r
-    "const" was added to the token name literal table.\r
-    "const" was added to some panic() and similar routine\r
-\r
-#228. (Changed in MR20) dlg crashes on "()"\r
-\r
-    The following token defintion will cause DLG to crash.\r
-\r
-        #token "()"\r
-\r
-    When there is a syntax error in a regular expression\r
-    many of the dlg routines return a structure which has\r
-    null pointers.  When this is accessed by callers it\r
-    generates the crash.\r
-\r
-    I have attempted to fix the more common cases.\r
-\r
-    Reported by  Mengue Olivier (dolmen bigfoot.com).\r
-\r
-#227. (Changed in MR20) Array overwrite\r
-\r
-    Steveh Hand (sassth unx.sas.com) reported a problem which\r
-    was traced to a temporary array which was not properly\r
-    resized for deeply nested blocks.  This has been fixed.\r
-\r
-#226. (Changed in MR20) -pedantic conformance\r
-   \r
-    G. Hobbelt (i_a mbh.org) and THM made many, many minor \r
-    changes to create prototypes for all the functions and\r
-    bring antlr, dlg, and sorcerer into conformance with\r
-    the gcc -pedantic option.\r
-\r
-    This may require uses to add pccts/h/pcctscfg.h to some\r
-    files or makefiles in order to have __USE_PROTOS defined.\r
-\r
-#225  (Changed in MR20) AST stack adjustment in C mode\r
-\r
-    The fix in #214 for AST stack adjustment in C mode missed \r
-    some cases.\r
-\r
-    Reported with fix by Ger Hobbelt (i_a mbh.org).\r
-\r
-#224  (Changed in MR20) LL(1) and LL(2) with #pragma approx\r
-\r
-    This may take a record for the oldest, most trival, lexical\r
-    error in pccts.  The regular expressions for LL(1) and LL(2)\r
-    lacked an escape for the left and right parenthesis.\r
-\r
-    Reported by Ger Hobbelt (i_a mbh.org).\r
-\r
-#223  (Changed in MR20) Addition of IBM_VISUAL_AGE directory\r
-\r
-    Build files for antlr, dlg, and sorcerer under IBM Visual Age \r
-    have been contributed by Anton Sergeev (ags mlc.ru).  They have\r
-    been placed in the pccts/IBM_VISUAL_AGE directory.\r
-\r
-#222  (Changed in MR20) Replace __STDC__ with __USE_PROTOS\r
-\r
-    Most occurrences of __STDC__ replaced with __USE_PROTOS due to\r
-    complaints from several users.\r
-\r
-#221  (Changed in MR20) Added #include for DLexerBase.h to PBlackBox.\r
-\r
-    Added #include for DLexerBase.h to PBlackBox.\r
-\r
-#220  (Changed in MR19) strcat arguments reversed in #pred parse\r
-\r
-    The arguments to strcat are reversed when creating a print\r
-    name for a hash table entry for use with #pred feature.\r
-\r
-    Problem diagnosed and fix reported by Scott Harrington \r
-    (seh4 ix.netcom.com).\r
-\r
-#219. (Changed in MR19) C Mode routine zzfree_ast\r
-\r
-    Changes to reduce use of recursion for AST trees with only right\r
-    links or only left links in the C mode routine zzfree_ast.\r
-\r
-    Implemented by SAKAI Kiyotaka (ksakai isr.co.jp).\r
-\r
-#218. (Changed in MR19) Changes to support unsigned char in C mode\r
-\r
-    Changes to antlr.h and err.h to fix omissions in use of zzchar_t\r
-\r
-    Implemented by SAKAI Kiyotaka (ksakai isr.co.jp).\r
-\r
-#217. (Changed in MR19) Error message when dlg -i and -CC options selected\r
-    \r
-    *** This change was rescinded by item #257 ***\r
-\r
-    The parsers generated by pccts in C++ mode are not able to support the\r
-    interactive lexer option (except, perhaps, when using the deferred fetch\r
-    parser option.(Item #216).\r
-\r
-    DLG now warns when both -i and -CC are selected.\r
-\r
-    This warning was suggested by David Venditti (07751870267-0001 t-online.de).\r
-\r
-#216. (Changed in MR19) Defer token fetch for C++ mode\r
-\r
-    Implemented by Volker H. Simonis (simonis informatik.uni-tuebingen.de)\r
-\r
-    Normally, pccts keeps the lookahead token buffer completely filled.\r
-    This requires max(k,ck) tokens of lookahead.  For some applications\r
-    this can cause deadlock problems.  For example, there may be cases\r
-    when the parser can't tell when the input has been completely consumed\r
-    until the parse is complete, but the parse can't be completed because \r
-    the input routines are waiting for additional tokens to fill the\r
-    lookahead buffer.\r
-    \r
-    When the ANTLRParser class is built with the pre-processor option \r
-    ZZDEFER_FETCH defined, the fetch of new tokens by consume() is deferred\r
-    until LA(i) or LT(i) is called. \r
-\r
-    To test whether this option has been built into the ANTLRParser class\r
-    use "isDeferFetchEnabled()".\r
-\r
-    Using the -gd trace option with the default tracein() and traceout()\r
-    routines will defeat the effort to defer the fetch because the\r
-    trace routines print out information about the lookahead token at\r
-    the start of the rule.\r
-    \r
-    Because the tracein and traceout routines are virtual it is \r
-    easy to redefine them in your parser:\r
-\r
-        class MyParser {\r
-        <<\r
-            virtual void tracein(ANTLRChar * ruleName)\r
-                { fprintf(stderr,"Entering: %s\n", ruleName); }\r
-            virtual void traceout(ANTLRChar * ruleName)\r
-                { fprintf(stderr,"Leaving: %s\n", ruleName); }\r
-        >>\r
\r
-    The originals for those routines are pccts/h/AParser.cpp\r
\r
-    This requires use of the dlg option -i (interactive lexer).\r
-\r
-    This is implemented only for C++ mode.\r
-\r
-    This is experimental.  The interaction with guess mode (syntactic\r
-    predicates)is not known.\r
-\r
-#215. (Changed in MR19) Addition of reset() to DLGLexerBase\r
-\r
-    There was no obvious way to reset the lexer for reuse.  The\r
-    reset() method now does this.\r
-\r
-    Suggested by David Venditti (07751870267-0001 t-online.de).\r
-\r
-#214. (Changed in MR19)  C mode: Adjust AST stack pointer at exit\r
-\r
-    In C mode the AST stack pointer needs to be reset if there will\r
-    be multiple calls to the ANTLRx macros.\r
-\r
-    Reported with fix by Paul D. Smith (psmith baynetworks.com).\r
-\r
-#213. (Changed in MR18)  Fatal error with -mrhoistk (k>1 hoisting)\r
-\r
-    When rearranging code I forgot to un-comment a critical line of\r
-    code that handles hoisting of predicates with k>1 lookahead.  This\r
-    is now fixed.\r
-\r
-    Reported by Reinier van den Born (reinier vnet.ibm.com).\r
-\r
-#212. (Changed in MR17)  Mac related changes by Kenji Tanaka\r
-\r
-    Kenji Tanaka (kentar osa.att.ne.jp) has made a number of changes for\r
-    Macintosh users.\r
-\r
-    a.  The following Macintosh MPW files aid in installing pccts on Mac:\r
-\r
-            pccts/MPW_Read_Me\r
-\r
-            pccts/install68K.mpw\r
-            pccts/installPPC.mpw\r
-\r
-            pccts/antlr/antlr.r\r
-            pccts/antlr/antlr68K.make\r
-            pccts/antlr/antlrPPC.make\r
-\r
-            pccts/dlg/dlg.r\r
-            pccts/dlg/dlg68K.make\r
-            pccts/dlg/dlgPPC.make\r
-\r
-            pccts/sorcerer/sor.r\r
-            pccts/sorcerer/sor68K.make\r
-            pccts/sorcerer/sorPPC.make\r
-    \r
-       They completely replace the previous Mac installation files.\r
-            \r
-    b. The most significant is a change in the MAC_FILE_CREATOR symbol\r
-       in pcctscfg.h:\r
-\r
-        old: #define MAC_FILE_CREATOR 'MMCC'   /* Metrowerks C/C++ Text files */\r
-        new: #define MAC_FILE_CREATOR 'CWIE'   /* Metrowerks C/C++ Text files */\r
-\r
-    c.  Added calls to special_fopen_actions() where necessary.\r
-\r
-#211. (Changed in MR16a)  C++ style comment in dlg\r
-\r
-    This has been fixed.\r
-\r
-#210. (Changed in MR16a)  Sor accepts \r\n, \r, or \n for end-of-line\r
-\r
-    A user requested that Sorcerer be changed to accept other forms\r
-    of end-of-line.\r
-\r
-#209. (Changed in MR16) Name of files changed.\r
-\r
-        Old:  CHANGES_FROM_1.33\r
-        New:  CHANGES_FROM_133.txt\r
-\r
-        Old:  KNOWN_PROBLEMS\r
-        New:  KNOWN_PROBLEMS.txt\r
-\r
-#208. (Changed in MR16) Change in use of pccts #include files\r
-\r
-    There were problems with MS DevStudio when mixing Sorcerer and\r
-    PCCTS in the same source file.  The problem is caused by the\r
-    redefinition of setjmp in the MS header file setjmp.h.  In\r
-    setjmp.h the pre-processor symbol setjmp was redefined to be\r
-    _setjmp.  A later effort to execute #include <setjmp.h> resulted \r
-    in an effort to #include <_setjmp.h>.  I'm not sure whether this\r
-    is a bug or a feature.  In any case, I decided to fix it by\r
-    avoiding the use of pre-processor symbols in #include statements\r
-    altogether.  This has the added benefit of making pre-compiled\r
-    headers work again.\r
-\r
-    I've replaced statements:\r
-\r
-        old: #include PCCTS_SETJMP_H\r
-        new: #include "pccts_setjmp.h"\r
-\r
-    Where pccts_setjmp.h contains:\r
-\r
-            #ifndef __PCCTS_SETJMP_H__\r
-            #define __PCCTS_SETJMP_H__\r
-    \r
-            #ifdef PCCTS_USE_NAMESPACE_STD\r
-            #include <Csetjmp>\r
-            #else\r
-            #include <setjmp.h>\r
-            #endif\r
-\r
-            #endif\r
-        \r
-    A similar change has been made for other standard header files\r
-    required by pccts and sorcerer: stdlib.h, stdarg.h, stdio.h, etc.\r
-\r
-    Reported by Jeff Vincent (JVincent novell.com) and Dale Davis\r
-    (DalDavis spectrace.com).\r
-\r
-#207. (Changed in MR16) dlg reports an invalid range for: [\0x00-\0xff]\r
-\r
-     -----------------------------------------------------------------\r
-     Note from MR23:  This fix does not work.  I am investigating why.\r
-     -----------------------------------------------------------------\r
-\r
-    dlg will report that this is an invalid range.\r
-\r
-    Diagnosed by Piotr Eljasiak (eljasiak no-spam.zt.gdansk.tpsa.pl):\r
-\r
-        I think this problem is not specific to unsigned chars\r
-        because dlg reports no error for the range [\0x00-\0xfe].\r
-\r
-        I've found that information on range is kept in field\r
-        letter (unsigned char) of Attrib struct. Unfortunately\r
-        the letter value internally is for some reasons increased\r
-        by 1, so \0xff is represented here as 0.\r
-\r
-        That's why dlg complains about the range [\0x00-\0xff] in\r
-        dlg_p.g:\r
-\r
-        if ($$.letter > $2.letter) {\r
-          error("invalid range  ", zzline);\r
-        } \r
-\r
-    The fix is:\r
-\r
-        if ($$.letter > $2.letter && 255 != $$2.letter) {\r
-          error("invalid range  ", zzline);\r
-        } \r
-\r
-#206. (Changed in MR16) Free zzFAILtext in ANTLRParser destructor\r
-\r
-    The ANTLRParser destructor now frees zzFAILtext.\r
-\r
-    Problem and fix reported by Manfred Kogler (km cast.uni-linz.ac.at).\r
-\r
-#205. (Changed in MR16) DLGStringReset argument now const\r
-\r
-    Changed: void DLGStringReset(DLGChar *s) {...}\r
-    To:      void DLGStringReset(const DLGChar *s) {...}\r
-\r
-    Suggested by Dale Davis (daldavis spectrace.com)\r
-\r
-#204. (Changed in MR15a) Change __WATCOM__ to __WATCOMC__ in pcctscfg.h\r
-    \r
-    Reported by Oleg Dashevskii (olegdash my-dejanews.com).\r
-\r
-#203. (Changed in MR15) Addition of sorcerer to distribution kit\r
-\r
-    I have finally caved in to popular demand.  The pccts 1.33mr15\r
-    kit will include sorcerer.  The separate sorcerer kit will be\r
-    discontinued.\r
-\r
-#202. (Changed) in MR15) Organization of MS Dev Studio Projects in Kit\r
-\r
-    Previously there was one workspace that contained projects for\r
-    all three parts of pccts: antlr, dlg, and sorcerer.  Now each\r
-    part (and directory) has its own workspace/project and there\r
-    is an additional workspace/project to build a library from the\r
-    .cpp files in the pccts/h directory.\r
-\r
-    The library build will create pccts_debug.lib or pccts_release.lib\r
-    according to the configuration selected.  \r
-\r
-    If you don't want to build pccts 1.33MR15 you can download a\r
-    ready-to-run kit for win32 from http://www.polhode.com/win32.zip.\r
-    The ready-to-run for win32 includes executables, a pre-built static\r
-    library for the .cpp files in the pccts/h directory, and a  sample\r
-    application\r
-\r
-    You will need to define the environment variable PCCTS to point to\r
-    the root of the pccts directory hierarchy.\r
-\r
-#201. (Changed in MR15) Several fixes by K.J. Cummings (cummings peritus.com)\r
-\r
-      Generation of SETJMP rather than SETJMP_H in gen.c.\r
-\r
-      (Sor B19) Declaration of ref_vars_inits for ref_var_inits in\r
-      pccts/sorcerer/sorcerer.h.\r
-\r
-#200. (Changed in MR15) Remove operator=() in AToken.h\r
-\r
-      User reported that WatCom couldn't handle use of\r
-      explicit operator =().  Replace with equivalent\r
-      using cast operator.\r
-\r
-#199. (Changed in MR15) Don't allow use of empty #tokclass\r
-\r
-      Change antlr.g to disallow empty #tokclass sets.\r
-\r
-      Reported by Manfred Kogler (km cast.uni-linz.ac.at).\r
-\r
-#198. Revised ANSI C grammar due to efforts by Manuel Kessler\r
-\r
-      Manuel Kessler (mlkessler cip.physik.uni-wuerzburg.de)\r
-\r
-          Allow trailing ... in function parameter lists.\r
-          Add bit fields.\r
-          Allow old-style function declarations.\r
-          Support cv-qualified pointers.\r
-          Better checking of combinations of type specifiers.\r
-          Release of memory for local symbols on scope exit.\r
-          Allow input file name on command line as well as by redirection.\r
-\r
-              and other miscellaneous tweaks.\r
-\r
-      This is not part of the pccts distribution kit. It must be\r
-      downloaded separately from:\r
-\r
-            http://www.polhode.com/ansi_mr15.zip\r
-\r
-#197. (Changed in MR14) Resetting the lookahead buffer of the parser\r
-\r
-      Explanation and fix by Sinan Karasu (sinan.karasu boeing.com)\r
-\r
-      Consider the code used to prime the lookahead buffer LA(i)\r
-      of the parser when init() is called:\r
-\r
-        void\r
-        ANTLRParser::\r
-        prime_lookahead()\r
-        {\r
-            int i;\r
-            for(i=1;i<=LLk; i++) consume();\r
-            dirty=0;\r
-            //lap = 0;      // MR14 - Sinan Karasu (sinan.karusu boeing.com)\r
-            //labase = 0;   // MR14\r
-            labase=lap;     // MR14\r
-        }\r
-\r
-      When the parser is instantiated, lap=0,labase=0 is set.\r
-\r
-      The "for" loop runs LLk times. In consume(), lap = lap +1 (mod LLk) is\r
-      computed.  Therefore, lap(before the loop) == lap (after the loop).\r
-\r
-      Now the only problem comes in when one does an init() of the parser\r
-      after an Eof has been seen. At that time, lap could be non zero.\r
-      Assume it was lap==1. Now we do a prime_lookahead(). If LLk is 2,\r
-      then\r
-\r
-        consume()\r
-        {\r
-            NLA = inputTokens->getToken()->getType();\r
-            dirty--;\r
-            lap = (lap+1)&(LLk-1);\r
-        }\r
-\r
-      or expanding NLA,\r
-\r
-        token_type[lap&(LLk-1)]) = inputTokens->getToken()->getType();\r
-        dirty--;\r
-        lap = (lap+1)&(LLk-1);\r
-\r
-      so now we prime locations 1 and 2.  In prime_lookahead it used to set\r
-      lap=0 and labase=0.  Now, the next token will be read from location 0,\r
-      NOT 1 as it should have been.\r
-\r
-      This was never caught before, because if a parser is just instantiated,\r
-      then lap and labase are 0, the offending assignment lines are\r
-      basically no-ops, since the for loop wraps around back to 0.\r
-\r
-#196. (Changed in MR14) Problems with "(alpha)? beta" guess\r
-\r
-    Consider the following syntactic predicate in a grammar\r
-    with 2 tokens of lookahead (k=2 or ck=2):\r
-\r
-        rule  : ( alpha )? beta ;\r
-        alpha : S t ;\r
-        t     : T U\r
-              | T\r
-              ;\r
-        beta  : S t Z ;\r
-\r
-    When antlr computes the prediction expression with one token\r
-    of lookahead for alts 1 and 2 of rule t it finds an ambiguity.\r
-\r
-    Because the grammar has a lookahead of 2 it tries to compute\r
-    two tokens of lookahead for alts 1 and 2 of t.  Alt 1 clearly\r
-    has a lookahead of (T U).  Alt 2 is one token long so antlr\r
-    tries to compute the follow set of alt 2, which means finding\r
-    the things which can follow rule t in the context of (alpha)?.\r
-    This cannot be computed, because alpha is only part of a rule,\r
-    and antlr can't tell what part of beta is matched by alpha and\r
-    what part remains to be matched.  Thus it impossible for antlr\r
-    to  properly determine the follow set of rule t.\r
-\r
-    Prior to 1.33MR14, the follow of (alpha)? was computed as\r
-    FIRST(beta) as a result of the internal representation of\r
-    guess blocks.\r
-\r
-    With MR14 the follow set will be the empty set for that context.\r
-\r
-    Normally, one expects a rule appearing in a guess block to also\r
-    appear elsewhere.  When the follow context for this other use\r
-    is "ored" with the empty set, the context from the other use\r
-    results, and a reasonable follow context results.  However if\r
-    there is *no* other use of the rule, or it is used in a different\r
-    manner then the follow context will be inaccurate - it was\r
-    inaccurate even before MR14, but it will be inaccurate in a\r
-    different way.\r
-\r
-    For the example given earlier, a reasonable way to rewrite the\r
-    grammar:\r
-\r
-        rule  : ( alpha )? beta\r
-        alpha : S t ;\r
-        t     : T U\r
-              | T\r
-              ;\r
-        beta  : alpha Z ;\r
-\r
-    If there are no other uses of the rule appearing in the guess\r
-    block it will generate a test for EOF - a workaround for\r
-    representing a null set in the lookahead tests.\r
-\r
-    If you encounter such a problem you can use the -alpha option\r
-    to get additional information:\r
-\r
-    line 2: error: not possible to compute follow set for alpha\r
-              in an "(alpha)? beta" block.\r
-\r
-    With the antlr -alpha command line option the following information\r
-    is inserted into the generated file:\r
-\r
-    #if 0\r
-\r
-      Trace of references leading to attempt to compute the follow set of\r
-      alpha in an "(alpha)? beta" block. It is not possible for antlr to\r
-      compute this follow set because it is not known what part of beta has\r
-      already been matched by alpha and what part remains to be matched.\r
-\r
-      Rules which make use of the incorrect follow set will also be incorrect\r
-\r
-         1 #token T              alpha/2   line 7     brief.g\r
-         2 end alpha             alpha/3   line 8     brief.g\r
-         2 end (...)? block at   start/1   line 2     brief.g\r
-\r
-    #endif\r
-\r
-    At the moment, with the -alpha option selected the program marks\r
-    any rules which appear in the trace back chain (above) as rules with\r
-    possible problems computing follow set.\r
-\r
-    Reported by Greg Knapen (gregory.knapen bell.ca).\r
-\r
-#195. (Changed in MR14) #line directive not at column 1\r
-\r
-      Under certain circunstances a predicate test could generate\r
-      a #line directive which was not at column 1.\r
-\r
-      Reported with fix by David KÃ¥gedal  (davidk lysator.liu.se)\r
-      (http://www.lysator.liu.se/~davidk/).\r
-\r
-#194. (Changed in MR14) (C Mode only) Demand lookahead with #tokclass\r
-\r
-      In C mode with the demand lookahead option there is a bug in the\r
-      code which handles matches for #tokclass (zzsetmatch and\r
-      zzsetmatch_wsig).\r
-\r
-      The bug causes the lookahead pointer to get out of synchronization\r
-      with the current token pointer.\r
-\r
-      The problem was reported with a fix by Ger Hobbelt (hobbelt axa.nl).\r
-\r
-#193. (Changed in MR14) Use of PCCTS_USE_NAMESPACE_STD\r
-\r
-      The pcctscfg.h now contains the following definitions:\r
-\r
-        #ifdef PCCTS_USE_NAMESPACE_STD\r
-        #define PCCTS_STDIO_H     <Cstdio>\r
-        #define PCCTS_STDLIB_H    <Cstdlib>\r
-        #define PCCTS_STDARG_H    <Cstdarg>\r
-        #define PCCTS_SETJMP_H    <Csetjmp>\r
-        #define PCCTS_STRING_H    <Cstring>\r
-        #define PCCTS_ASSERT_H    <Cassert>\r
-        #define PCCTS_ISTREAM_H   <istream>\r
-        #define PCCTS_IOSTREAM_H  <iostream>\r
-        #define PCCTS_NAMESPACE_STD     namespace std {}; using namespace std;\r
-        #else\r
-        #define PCCTS_STDIO_H     <stdio.h>\r
-        #define PCCTS_STDLIB_H    <stdlib.h>\r
-        #define PCCTS_STDARG_H    <stdarg.h>\r
-        #define PCCTS_SETJMP_H    <setjmp.h>\r
-        #define PCCTS_STRING_H    <string.h>\r
-        #define PCCTS_ASSERT_H    <assert.h>\r
-        #define PCCTS_ISTREAM_H   <istream.h>\r
-        #define PCCTS_IOSTREAM_H  <iostream.h>\r
-        #define PCCTS_NAMESPACE_STD\r
-        #endif\r
-\r
-      The runtime support in pccts/h uses these pre-processor symbols\r
-      consistently.\r
-\r
-      Also, antlr and dlg have been changed to generate code which uses\r
-      these pre-processor symbols rather than having the names of the\r
-      #include files hard-coded in the generated code.\r
-\r
-      This required the addition of "#include pcctscfg.h" to a number of\r
-      files in pccts/h.\r
-\r
-      It appears that this sometimes causes problems for MSVC 5 in\r
-      combination with the "automatic" option for pre-compiled headers.\r
-      In such cases disable the "automatic" pre-compiled headers option.\r
-\r
-      Suggested by Hubert Holin (Hubert.Holin Bigfoot.com).\r
-\r
-#192. (Changed in MR14) Change setText() to accept "const ANTLRChar *"\r
-\r
-      Changed ANTLRToken::setText(ANTLRChar *) to setText(const ANTLRChar *).\r
-      This allows literal strings to be used to initialize tokens.  Since\r
-      the usual token implementation (ANTLRCommonToken)  makes a copy of the\r
-      input string, this was an unnecessary limitation.\r
-\r
-      Suggested by Bob McWhirter (bob netwrench.com).\r
-\r
-#191. (Changed in MR14) HP/UX aCC compiler compatibility problem\r
-\r
-      Needed to explicitly declare zzINF_DEF_TOKEN_BUFFER_SIZE and\r
-      zzINF_BUFFER_TOKEN_CHUNK_SIZE as ints in pccts/h/AParser.cpp.\r
-\r
-      Reported by David Cook (dcook bmc.com).\r
-\r
-#190. (Changed in MR14) IBM OS/2 CSet compiler compatibility problem\r
-\r
-      Name conflict with "_cs" in pccts/h/ATokenBuffer.cpp\r
-\r
-      Reported by David Cook (dcook bmc.com).\r
-\r
-#189. (Changed in MR14) -gxt switch in C mode\r
-\r
-      The -gxt switch in C mode didn't work because of incorrect\r
-      initialization.\r
-\r
-      Reported by Sinan Karasu (sinan boeing.com).\r
-\r
-#188. (Changed in MR14) Added pccts/h/DLG_stream_input.h\r
-\r
-      This is a DLG stream class based on C++ istreams.\r
-\r
-      Contributed by Hubert Holin (Hubert.Holin Bigfoot.com).\r
-\r
-#187. (Changed in MR14) Rename config.h to pcctscfg.h\r
-\r
-      The PCCTS configuration file has been renamed from config.h to\r
-      pcctscfg.h.  The problem with the original name is that it led\r
-      to name collisions when pccts parsers were combined with other\r
-      software.\r
-\r
-      All of the runtime support routines in pccts/h/* have been\r
-      changed to use the new name.  Existing software can continue\r
-      to use pccts/h/config.h. The contents of pccts/h/config.h is\r
-      now just "#include "pcctscfg.h".\r
-\r
-      I don't have a record of the user who suggested this.\r
-\r
-#186. (Changed in MR14) Pre-processor symbol DllExportPCCTS class modifier\r
-\r
-      Classes in the C++ runtime support routines are now declared:\r
-\r
-        class DllExportPCCTS className ....\r
-\r
-      By default, the pre-processor symbol is defined as the empty\r
-      string.  This if for use by MSVC++ users to create DLL classes.\r
-\r
-      Suggested by Manfred Kogler (km cast.uni-linz.ac.at).\r
-\r
-#185. (Changed in MR14) Option to not use PCCTS_AST base class for ASTBase\r
-\r
-      Normally, the ASTBase class is derived from PCCTS_AST which contains\r
-      functions useful to Sorcerer.  If these are not necessary then the\r
-      user can define the pre-processor symbol "PCCTS_NOT_USING_SOR" which\r
-      will cause the ASTBase class to replace references to PCCTS_AST with\r
-      references to ASTBase where necessary.\r
-\r
-      The class ASTDoublyLinkedBase will contain a pure virtual function\r
-      shallowCopy() that was formerly defined in class PCCTS_AST.\r
-\r
-      Suggested by Bob McWhirter (bob netwrench.com).\r
-\r
-#184. (Changed in MR14) Grammars with no tokens generate invalid tokens.h\r
-\r
-      Reported by Hubert Holin (Hubert.Holin bigfoot.com).\r
-\r
-#183. (Changed in MR14) -f to specify file with names of grammar files\r
-\r
-      In DEC/VMS it is difficult to specify very long command lines.\r
-      The -f option allows one to place the names of the grammar files\r
-      in a data file in order to bypass limitations of the DEC/VMS\r
-      command language interpreter.\r
-\r
-      Addition supplied by Bernard Giroud (b_giroud decus.ch).\r
-\r
-#182. (Changed in MR14) Output directory option for DEC/VMS\r
-\r
-      Fix some problems with the -o option under DEC/VMS.\r
-\r
-      Fix supplied by Bernard Giroud (b_giroud decus.ch).\r
-\r
-#181. (Changed in MR14) Allow chars > 127 in DLGStringInput::nextChar()\r
-\r
-      Changed DLGStringInput to cast the character using (unsigned char)\r
-      so that languages with character codes greater than 127 work\r
-      without changes.\r
-\r
-      Suggested by Manfred Kogler (km cast.uni-linz.ac.at).\r
-\r
-#180. (Added in MR14) ANTLRParser::getEofToken()\r
-\r
-      Added "ANTLRToken ANTLRParser::getEofToken() const" to match the\r
-      setEofToken routine.\r
-\r
-      Requested by Manfred Kogler (km cast.uni-linz.ac.at).\r
-\r
-#179. (Fixed in MR14) Memory leak for BufFileInput subclass of DLGInputStream\r
-\r
-      The BufFileInput class described in Item #142 neglected to release\r
-      the allocated buffer when an instance was destroyed.\r
-\r
-      Reported by Manfred Kogler (km cast.uni-linz.ac.at).\r
-\r
-#178. (Fixed in MR14) Bug in "(alpha)? beta" guess blocks first sets\r
-\r
-      In 1.33 vanilla, and all maintenance releases prior to MR14\r
-      there is a bug in the handling of guess blocks which use the\r
-      "long" form:\r
-\r
-                  (alpha)? beta\r
-\r
-      inside a (...)*, (...)+, or {...} block.\r
-\r
-      This problem does *not* apply to the case where beta is omitted\r
-      or when the syntactic predicate is on the leading edge of an\r
-      alternative.\r
-\r
-      The problem is that both alpha and beta are stored in the\r
-      syntax diagram, and that some analysis routines would fail\r
-      to skip the alpha portion when it was not on the leading edge.\r
-      Consider the following grammar with -ck 2:\r
-\r
-                r : ( (A)? B )* C D\r
-\r
-                  | A B      /* forces -ck 2 computation for old antlr    */\r
-                             /*              reports ambig for alts 1 & 2 */\r
-\r
-                  | B C      /* forces -ck 2 computation for new antlr    */\r
-                             /*              reports ambig for alts 1 & 3 */\r
-                  ;\r
-\r
-      The prediction expression for the first alternative should be\r
-      LA(1)={B C} LA(2)={B C D}, but previous versions of antlr\r
-      would compute the prediction expression as LA(1)={A C} LA(2)={B D}\r
-\r
-      Reported by Arpad Beszedes (beszedes inf.u-szeged.hu) who provided\r
-      a very clear example of the problem and identified the probable cause.\r
-\r
-#177. (Changed in MR14) #tokdefs and #token with regular expression\r
-\r
-      In MR13 the change described by Item #162 caused an existing\r
-      feature of antlr to fail.  Prior to the change it was possible\r
-      to give regular expression definitions and actions to tokens\r
-      which were defined via the #tokdefs directive.\r
-\r
-      This now works again.\r
-\r
-      Reported by Manfred Kogler (km cast.uni-linz.ac.at).\r
-\r
-#176. (Changed in MR14) Support for #line in antlr source code\r
-\r
-      Note: this was implemented by Arpad Beszedes (beszedes inf.u-szeged.hu).\r
-\r
-      In 1.33MR14 it is possible for a pre-processor to generate #line\r
-      directives in the antlr source and have those line numbers and file\r
-      names used in antlr error messages and in the #line directives\r
-      generated by antlr.\r
-\r
-      The #line directive may appear in the following forms:\r
-\r
-            #line ll "sss" xx xx ...\r
-\r
-      where ll represents a line number, "sss" represents the name of a file\r
-      enclosed in quotation marks, and xxx are arbitrary integers.\r
-\r
-      The following form (without "line") is not supported at the moment:\r
-\r
-            # ll "sss" xx xx ...\r
-\r
-      The result:\r
-\r
-        zzline\r
-\r
-            is replaced with ll from the # or #line directive\r
-\r
-        FileStr[CurFile]\r
-\r
-            is updated with the contents of the string (if any)\r
-            following the line number\r
-\r
-      Note\r
-      ----\r
-      The file-name string following the line number can be a complete\r
-      name with a directory-path. Antlr generates the output files from\r
-      the input file name (by replacing the extension from the file-name\r
-      with .c or .cpp).\r
-\r
-      If the input file (or the file-name from the line-info) contains\r
-      a path:\r
-\r
-        "../grammar.g"\r
-\r
-      the generated source code will be placed in "../grammar.cpp" (i.e.\r
-      in the parent directory).  This is inconvenient in some cases\r
-      (even the -o switch can not be used) so the path information is\r
-      removed from the #line directive.  Thus, if the line-info was\r
-\r
-        #line 2 "../grammar.g"\r
-\r
-      then the current file-name will become "grammar.g"\r
-\r
-      In this way, the generated source code according to the grammar file\r
-      will always be in the current directory, except when the -o switch\r
-      is used.\r
-\r
-#175. (Changed in MR14) Bug when guess block appears at start of (...)*\r
-\r
-      In 1.33 vanilla and all maintenance releases prior to 1.33MR14\r
-      there is a bug when a guess block appears at the start of a (...)+.\r
-      Consider the following k=1 (ck=1) grammar:\r
-\r
-            rule :\r
-                  ( (STAR)? ZIP )* ID ;\r
-\r
-      Prior to 1.33MR14, the generated code resembled:\r
-\r
-        ...\r
-        zzGUESS_BLOCK\r
-        while ( 1 ) {\r
-            if ( ! LA(1)==STAR) break;\r
-            zzGUESS\r
-            if ( !zzrv ) {\r
-                zzmatch(STAR);\r
-                zzCONSUME;\r
-                zzGUESS_DONE\r
-                zzmatch(ZIP);\r
-                zzCONSUME;\r
-            ...\r
-\r
-      Note that the routine uses STAR for the prediction expression\r
-      rather than ZIP.  With 1.33MR14 the generated code resembles:\r
-\r
-        ...\r
-        while ( 1 ) {\r
-            if ( ! LA(1)==ZIP) break;\r
-        ...\r
-\r
-      This problem existed only with (...)* blocks and was caused\r
-      by the slightly more complicated graph which represents (...)*\r
-      blocks.  This caused the analysis routine to compute the first\r
-      set for the alpha part of the "(alpha)? beta" rather than the\r
-      beta part.\r
-\r
-      Both (...)+ and {...} blocks handled the guess block correctly.\r
-\r
-      Reported by Arpad Beszedes (beszedes inf.u-szeged.hu) who provided\r
-      a very clear example of the problem and identified the probable cause.\r
-\r
-#174. (Changed in MR14) Bug when action precedes syntactic predicate\r
-\r
-      In 1.33 vanilla, and all maintenance releases prior to MR14,\r
-      there was a bug when a syntactic predicate was immediately\r
-      preceded by an action.  Consider the following -ck 2 grammar:\r
-\r
-            rule :\r
-                   <<int i;>>\r
-                   (alpha)? beta C\r
-                 | A B\r
-                 ;\r
-\r
-            alpha : A ;\r
-            beta  : A B;\r
-\r
-      Prior to MR14, the code generated for the first alternative\r
-      resembled:\r
-\r
-        ...\r
-        zzGUESS\r
-        if ( !zzrv && LA(1)==A && LA(2)==A) {\r
-            alpha();\r
-            zzGUESS_DONE\r
-            beta();\r
-            zzmatch(C);\r
-            zzCONSUME;\r
-        } else {\r
-        ...\r
-\r
-      The prediction expression (i.e. LA(1)==A && LA(2)==A) is clearly\r
-      wrong because LA(2) should be matched to B (first[2] of beta is {B}).\r
-\r
-      With 1.33MR14 the prediction expression is:\r
-\r
-        ...\r
-        if ( !zzrv && LA(1)==A && LA(2)==B) {\r
-            alpha();\r
-            zzGUESS_DONE\r
-            beta();\r
-            zzmatch(C);\r
-            zzCONSUME;\r
-        } else {\r
-        ...\r
-\r
-      This will only affect users in which alpha is shorter than\r
-      than max(k,ck) and there is an action immediately preceding\r
-      the syntactic predicate.\r
-\r
-      This problem was reported by reported by Arpad Beszedes\r
-      (beszedes inf.u-szeged.hu) who provided a very clear example\r
-      of the problem and identified the presence of the init-action\r
-      as the likely culprit.\r
-\r
-#173. (Changed in MR13a) -glms for Microsoft style filenames with -gl\r
-\r
-      With the -gl option antlr generates #line directives using the\r
-      exact name of the input files specified on the command line.\r
-      An oddity of the Microsoft C and C++ compilers is that they\r
-      don't accept file names in #line directives containing "\"\r
-      even though these are names from the native file system.\r
-\r
-      With -glms option, the "\" in file names appearing in #line\r
-      directives is replaced with a "/" in order to conform to\r
-      Microsoft compiler requirements.\r
-\r
-      Reported by Erwin Achermann (erwin.achermann switzerland.org).\r
-\r
-#172. (Changed in MR13) \r\n in antlr source counted as one line\r
-\r
-      Some MS software uses \r\n to indicate a new line.  Antlr\r
-      now recognizes this in counting lines.\r
-\r
-      Reported by Edward L. Hepler (elh ece.vill.edu).\r
-\r
-#171. (Changed in MR13) #tokclass L..U now allowed\r
-\r
-      The following is now allowed:\r
-\r
-            #tokclass ABC { A..B C }\r
-\r
-      Reported by Dave Watola (dwatola amtsun.jpl.nasa.gov)\r
-\r
-#170. (Changed in MR13) Suppression for predicates with lookahead depth >1\r
-\r
-      In MR12 the capability for suppression of predicates with lookahead\r
-      depth=1 was introduced.  With MR13 this had been extended to\r
-      predicates with lookahead depth > 1 and released for use by users\r
-      on an experimental basis.\r
-\r
-      Consider the following grammar with -ck 2 and the predicate in rule\r
-      "a" with depth 2:\r
-\r
-            r1  : (ab)* "@"\r
-                ;\r
-\r
-            ab  : a\r
-                | b\r
-                ;\r
-\r
-            a   : (A B)? => <<p(LATEXT(2))>>? A B C\r
-                ;\r
-\r
-            b   : A B C\r
-                ;\r
-\r
-      Normally, the predicate would be hoisted into rule r1 in order to\r
-      determine whether to call rule "ab".  However it should *not* be\r
-      hoisted because, even if p is false, there is a valid alternative\r
-      in rule b.  With "-mrhoistk on" the predicate will be suppressed.\r
-\r
-      If "-info p" command line option is present the following information\r
-      will appear in the generated code:\r
-\r
-                while ( (LA(1)==A)\r
-        #if 0\r
-\r
-        Part (or all) of predicate with depth > 1 suppressed by alternative\r
-            without predicate\r
-\r
-        pred  <<  p(LATEXT(2))>>?\r
-                  depth=k=2  ("=>" guard)  rule a  line 8  t1.g\r
-          tree context:\r
-            (root = A\r
-               B\r
-            )\r
-\r
-        The token sequence which is suppressed: ( A B )\r
-        The sequence of references which generate that sequence of tokens:\r
-\r
-           1 to ab          r1/1       line 1     t1.g\r
-           2 ab             ab/1       line 4     t1.g\r
-           3 to b           ab/2       line 5     t1.g\r
-           4 b              b/1        line 11    t1.g\r
-           5 #token A       b/1        line 11    t1.g\r
-           6 #token B       b/1        line 11    t1.g\r
-\r
-        #endif\r
-\r
-      A slightly more complicated example:\r
-\r
-            r1  : (ab)* "@"\r
-                ;\r
-\r
-            ab  : a\r
-                | b\r
-                ;\r
-\r
-            a   : (A B)? => <<p(LATEXT(2))>>? (A  B | D E)\r
-                ;\r
-\r
-            b   : <<q(LATEXT(2))>>? D E\r
-                ;\r
-\r
-\r
-      In this case, the sequence (D E) in rule "a" which lies behind\r
-      the guard is used to suppress the predicate with context (D E)\r
-      in rule b.\r
-\r
-                while ( (LA(1)==A || LA(1)==D)\r
-            #if 0\r
-\r
-            Part (or all) of predicate with depth > 1 suppressed by alternative\r
-                without predicate\r
-\r
-            pred  <<  q(LATEXT(2))>>?\r
-                              depth=k=2  rule b  line 11  t2.g\r
-              tree context:\r
-                (root = D\r
-                   E\r
-                )\r
-\r
-            The token sequence which is suppressed: ( D E )\r
-            The sequence of references which generate that sequence of tokens:\r
-\r
-               1 to ab          r1/1       line 1     t2.g\r
-               2 ab             ab/1       line 4     t2.g\r
-               3 to a           ab/1       line 4     t2.g\r
-               4 a              a/1        line 8     t2.g\r
-               5 #token D       a/1        line 8     t2.g\r
-               6 #token E       a/1        line 8     t2.g\r
-\r
-            #endif\r
-            &&\r
-            #if 0\r
-\r
-            pred  <<  p(LATEXT(2))>>?\r
-                              depth=k=2  ("=>" guard)  rule a  line 8  t2.g\r
-              tree context:\r
-                (root = A\r
-                   B\r
-                )\r
-\r
-            #endif\r
-\r
-            (! ( LA(1)==A && LA(2)==B ) || p(LATEXT(2)) )  {\r
-                ab();\r
-                ...\r
-\r
-#169. (Changed in MR13) Predicate test optimization for depth=1 predicates\r
-\r
-      When the MR12 generated a test of a predicate which had depth 1\r
-      it would use the depth >1 routines, resulting in correct but\r
-      inefficient behavior.  In MR13, a bit test is used.\r
-\r
-#168. (Changed in MR13) Token expressions in context guards\r
-\r
-      The token expressions appearing in context guards such as:\r
-\r
-            (A B)? => <<test(LT(1))>>?  someRule\r
-\r
-      are computed during an early phase of antlr processing.  As\r
-      a result, prior to MR13, complex expressions such as:\r
-\r
-            ~B\r
-            L..U\r
-            ~L..U\r
-            TokClassName\r
-            ~TokClassName\r
-\r
-      were not computed properly.  This resulted in incorrect\r
-      context being computed for such expressions.\r
-\r
-      In MR13 these context guards are verified for proper semantics\r
-      in the initial phase and then re-evaluated after complex token\r
-      expressions have been computed in order to produce the correct\r
-      behavior.\r
-\r
-      Reported by Arpad Beszedes (beszedes inf.u-szeged.hu).\r
-\r
-#167. (Changed in MR13) ~L..U\r
-\r
-      Prior to MR13, the complement of a token range was\r
-      not properly computed.\r
-\r
-#166. (Changed in MR13) token expression L..U\r
-\r
-      The token U was represented as an unsigned char, restricting\r
-      the use of L..U to cases where U was assigned a token number\r
-      less than 256.  This is corrected in MR13.\r
-\r
-#165. (Changed in MR13) option -newAST\r
-\r
-      To create ASTs from an ANTLRTokenPtr antlr usually calls\r
-      "new AST(ANTLRTokenPtr)".  This option generates a call\r
-      to "newAST(ANTLRTokenPtr)" instead.  This allows a user\r
-      to define a parser member function to create an AST object.\r
-\r
-      Similar changes for ASTBase::tmake and ASTBase::link were not\r
-      thought necessary since they do not create AST objects, only\r
-      use existing ones.\r
-\r
-#164. (Changed in MR13) Unused variable _astp\r
-\r
-      For many compilations, we have lived with warnings about\r
-      the unused variable _astp.  It turns out that this varible\r
-      can *never* be used because the code which references it was\r
-      commented out.\r
-\r
-      This investigation was sparked by a note from Erwin Achermann\r
-      (erwin.achermann switzerland.org).\r
-\r
-#163. (Changed in MR13) Incorrect makefiles for testcpp examples\r
-\r
-      All the examples in pccts/testcpp/* had incorrect definitions\r
-      in the makefiles for the symbol "CCC".  Instead of CCC=CC they\r
-      had CC=$(CCC).\r
-\r
-      There was an additional problem in testcpp/1/test.g due to the\r
-      change in ANTLRToken::getText() to a const member function\r
-      (Item #137).\r
-\r
-      Reported by Maurice Mass (maas cuci.nl).\r
-\r
-#162. (Changed in MR13) Combining #token with #tokdefs\r
-\r
-      When it became possible to change the print-name of a\r
-      #token (Item #148) it became useful to give a #token\r
-      statement whose only purpose was to giving a print name\r
-      to the #token.  Prior to this change this could not be\r
-      combined with the #tokdefs feature.\r
-\r
-#161. (Changed in MR13) Switch -gxt inhibits generation of tokens.h\r
-\r
-#160. (Changed in MR13) Omissions in list of names for remap.h\r
-\r
-      When a user selects the -gp option antlr creates a list\r
-      of macros in remap.h to rename some of the standard\r
-      antlr routines from zzXXX to userprefixXXX.\r
-\r
-      There were number of omissions from the remap.h name\r
-      list related to the new trace facility.  This was reported,\r
-      along with a fix, by Bernie Solomon (bernard ug.eds.com).\r
-\r
-#159. (Changed in MR13) Violations of classic C rules\r
-\r
-      There were a number of violations of classic C style in\r
-      the distribution kit.  This was reported, along with fixes,\r
-      by Bernie Solomon (bernard ug.eds.com).\r
-\r
-#158. (Changed in MR13) #header causes problem for pre-processors\r
-\r
-      A user who runs the C pre-processor on antlr source suggested\r
-      that another syntax be allowed.  With MR13 such directives\r
-      such as #header, #pragma, etc. may be written as "\#header",\r
-      "\#pragma", etc.  For escaping pre-processor directives inside\r
-      a #header use something like the following:\r
-\r
-            \#header\r
-            <<\r
-                \#include <stdio.h>\r
-            >>\r
-\r
-#157. (Fixed in MR13) empty error sets for rules with infinite recursion\r
-\r
-      When the first set for a rule cannot be computed due to infinite\r
-      left recursion and it is the only alternative for a block then\r
-      the error set for the block would be empty.  This would result\r
-      in a fatal error.\r
-\r
-      Reported by Darin Creason (creason genedax.com)\r
-\r
-#156. (Changed in MR13) DLGLexerBase::getToken() now public\r
-\r
-#155. (Changed in MR13) Context behind predicates can suppress\r
-\r
-      With -mrhoist enabled the context behind a guarded predicate can\r
-      be used to suppress other predicates.  Consider the following grammar:\r
-\r
-        r0 : (r1)+;\r
-\r
-        r1  : rp\r
-            | rq\r
-            ;\r
-        rp  : <<p LATEXT(1)>>? B ;\r
-        rq : (A)? => <<q LATEXT(1)>>? (A|B);\r
-\r
-      In earlier versions both predicates "p" and "q" would be hoisted into\r
-      rule r0. With MR12c predicate p is suppressed because the context which\r
-      follows predicate q includes "B" which can "cover" predicate "p".  In\r
-      other words, in trying to decide in r0 whether to call r1, it doesn't\r
-      really matter whether p is false or true because, either way, there is\r
-      a valid choice within r1.\r
-\r
-#154. (Changed in MR13) Making hoist suppression explicit using <<nohoist>>\r
-\r
-      A common error, even among experienced pccts users, is to code\r
-      an init-action to inhibit hoisting rather than a leading action.\r
-      An init-action does not inhibit hoisting.\r
-\r
-      This was coded:\r
-\r
-        rule1 : <<;>> rule2\r
-\r
-      This is what was meant:\r
-\r
-        rule1 : <<;>> <<;>> rule2\r
-\r
-      With MR13, the user can code:\r
-\r
-        rule1 : <<;>> <<nohoist>> rule2\r
-\r
-      The following will give an error message:\r
-\r
-        rule1 : <<nohoist>> rule2\r
-\r
-      If the <<nohoist>> appears as an init-action rather than a leading\r
-      action an error message is issued.  The meaning of an init-action\r
-      containing "nohoist" is unclear: does it apply to just one\r
-      alternative or to all alternatives ?\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-        -------------------------------------------------------\r
-        Note:  Items #153 to #1 are now in a separate file named\r
-                CHANGES_FROM_133_BEFORE_MR13.txt\r
-        -------------------------------------------------------\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/CHANGES_FROM_133_BEFORE_MR13.txt b/Tools/CodeTools/TianoTools/Pccts/CHANGES_FROM_133_BEFORE_MR13.txt
deleted file mode 100644 (file)
index bba5ecd..0000000
+++ /dev/null
@@ -1,3666 +0,0 @@
-\r
-    ------------------------------------------------------------\r
-           This is the second part of a two part file.\r
-      This is a list of changes to pccts 1.33 prior to MR13\r
-       For more recent information see CHANGES_FROM_133.txt\r
-    ------------------------------------------------------------\r
-\r
-                               DISCLAIMER\r
-\r
- The software and these notes are provided "as is".  They may include\r
- typographical or technical errors and their authors disclaims all\r
- liability of any kind or nature for damages due to error, fault,\r
- defect, or deficiency regardless of cause.  All warranties of any\r
- kind, either express or implied, including, but not limited to, the\r
- implied  warranties of merchantability and fitness for a particular\r
- purpose are disclaimed.\r
-\r
-\r
-#153. (Changed in MR12b) Bug in computation of -mrhoist suppression set\r
-\r
-      Consider the following grammar with k=1 and "-mrhoist on":\r
-\r
-            r1  : (A)? => ((p>>? x      /* l1 */\r
-                | r2                    /* l2 */\r
-                ;\r
-            r2  :  A                    /* l4 */\r
-                | (B)? => <<q>>? y      /* l5 */\r
-                ;\r
-\r
-      In earlier versions the mrhoist routine would see that both l1 and\r
-      l2 contained predicates and would assume that this prevented either\r
-      from acting to suppress the other predicate.  In the example above\r
-      it didn't realize the A at line l4 is capable of suppressing the\r
-      predicate at l1 even though alt l2 contains (indirectly) a predicate.\r
-\r
-      This is fixed  in MR12b.\r
-\r
-      Reported by Reinier van den Born (reinier@vnet.ibm.com)\r
-\r
-#153. (Changed in MR12a) Bug in computation of -mrhoist suppression set\r
-\r
-      An oversight similar to that described in Item #152 appeared in\r
-      the computation of the set that "covered" a predicate.  If a\r
-      predicate expression included a term such as p=AND(q,r) the context\r
-      of p was taken to be context(q) & context(r), when it should have\r
-      been context(q) | context(r).  This is fixed in MR12a.\r
-\r
-#152. (Changed in MR12) Bug in generation of predicate expressions\r
-\r
-      The primary purpose for MR12 is to make quite clear that MR11 is\r
-      obsolete and to fix the bug related to predicate expressions.\r
-\r
-      In MR10 code was added to optimize the code generated for\r
-      predicate expression tests.  Unfortunately, there was a\r
-      significant oversight in the code which resulted in a bug in\r
-      the generation of code for predicate expression tests which\r
-      contained predicates combined using AND:\r
-\r
-            r0 : (r1)* "@" ;\r
-            r1 : (AAA)? => <<p LATEXT(1)>>? r2 ;\r
-            r2 : (BBB)? => <<q LATEXT(1)>>? Q\r
-               | (BBB)? => <<r LATEXT(1)>>? Q\r
-               ;\r
-\r
-      In MR11 (and MR10 when using "-mrhoist on") the code generated\r
-      for r0 to predict r1 would be equivalent to:\r
-\r
-        if ( LA(1)==Q &&\r
-                (LA(1)==AAA && LA(1)==BBB) &&\r
-                    ( p && ( q || r )) ) {\r
-\r
-      This is incorrect because it expresses the idea that LA(1)\r
-      *must* be AAA in order to attempt r1, and *must* be BBB to\r
-      attempt r2.  The result was that r1 became unreachable since\r
-      both condition can not be simultaneously true.\r
-\r
-      The general philosophy of code generation for predicates\r
-      can be summarized as follows:\r
-\r
-            a. If the context is true don't enter an alt\r
-               for which the corresponding predicate is false.\r
-\r
-               If the context is false then it is okay to enter\r
-               the alt without evaluating the predicate at all.\r
-\r
-            b. A predicate created by ORing of predicates has\r
-               context which is the OR of their individual contexts.\r
-\r
-            c. A predicate created by ANDing of predicates has\r
-               (surprise) context which is the OR of their individual\r
-               contexts.\r
-\r
-            d. Apply these rules recursively.\r
-\r
-            e. Remember rule (a)\r
-\r
-      The correct code should express the idea that *if* LA(1) is\r
-      AAA then p must be true to attempt r1, but if LA(1) is *not*\r
-      AAA then it is okay to attempt r1, provided that *if* LA(1) is\r
-      BBB then one of q or r must be true.\r
-\r
-        if ( LA(1)==Q &&\r
-                ( !(LA(1)==AAA || LA(1)==BBB) ||\r
-                    ( ! LA(1) == AAA || p) &&\r
-                    ( ! LA(1) == BBB || q || r ) ) ) {\r
-\r
-      I believe this is fixed in MR12.\r
-\r
-      Reported by Reinier van den Born (reinier@vnet.ibm.com)\r
-\r
-#151a. (Changed in MR12) ANTLRParser::getLexer()\r
-\r
-      As a result of several requests, I have added public methods to\r
-      get a pointer to the lexer belonging to a parser.\r
-\r
-            ANTLRTokenStream *ANTLRParser::getLexer() const\r
-\r
-                Returns a pointer to the lexer being used by the\r
-                parser.  ANTLRTokenStream is the base class of\r
-                DLGLexer\r
-\r
-            ANTLRTokenStream *ANTLRTokenBuffer::getLexer() const\r
-\r
-                Returns a pointer to the lexer being used by the\r
-                ANTLRTokenBuffer.  ANTLRTokenStream is the base\r
-                class of DLGLexer\r
-\r
-      You must manually cast the ANTLRTokenStream to your program's\r
-      lexer class. Because the name of the lexer's class is not fixed.\r
-      Thus it is impossible to incorporate it into the DLGLexerBase\r
-      class.\r
-\r
-#151b.(Changed in MR12) ParserBlackBox member getLexer()\r
-\r
-      The template class ParserBlackBox now has a member getLexer()\r
-      which returns a pointer to the lexer.\r
-\r
-#150. (Changed in MR12) syntaxErrCount and lexErrCount now public\r
-\r
-      See Item #127 for more information.\r
-\r
-#149. (Changed in MR12) antlr option -info o (letter o for orphan)\r
-\r
-      If there is more than one rule which is not referenced by any\r
-      other rule then all such rules are listed.  This is useful for\r
-      alerting one to rules which are not used, but which can still\r
-      contribute to ambiguity.  For example:\r
-\r
-            start : a Z ;\r
-            unused: a A ;\r
-            a     : (A)+ ;\r
-\r
-      will cause an ambiguity report for rule "a" which will be\r
-      difficult to understand if the user forgets about rule "unused"\r
-      simply because it is not used in the grammar.\r
-\r
-#148. (Changed in MR11) #token names appearing in zztokens,token_tbl\r
-\r
-      In a #token statement like the following:\r
-\r
-            #token Plus "\+"\r
-\r
-      the string "Plus" appears in the zztokens array (C mode) and\r
-      token_tbl (C++ mode).  This string is used in most error\r
-      messages.  In MR11 one has the option of using some other string,\r
-      (e.g.  "+") in those tables.\r
-\r
-      In MR11 one can write:\r
-\r
-            #token Plus ("+")             "\+"\r
-            #token RP   ("(")             "\("\r
-            #token COM  ("comment begin") "/\*"\r
-\r
-      A #token statement is allowed to appear in more than one #lexclass\r
-      with different regular expressions.  However, the token name appears\r
-      only once in the zztokens/token_tbl array.  This means that only\r
-      one substitute can be specified for a given #token name.  The second\r
-      attempt to define a substitute name (different from the first) will\r
-      result in an error message.\r
-\r
-#147. (Changed in MR11) Bug in follow set computation\r
-\r
-      There is a bug in 1.33 vanilla and all maintenance releases\r
-      prior to MR11 in the computation of the follow set.  The bug is\r
-      different than that described in Item #82 and probably more\r
-      common.  It was discovered in the ansi.g grammar while testing\r
-      the "ambiguity aid" (Item #119). The search for a bug started\r
-      when the ambiguity aid was unable to discover the actual source\r
-      of an ambiguity reported by antlr.\r
-\r
-      The problem appears when an optimization of the follow set\r
-      computation is used inappropriately.  The result is that the\r
-      follow set used is the "worst case".  In other words, the error\r
-      can lead to false reports of ambiguity.  The good news is that\r
-      if you have a grammar in which you have addressed all reported\r
-      ambiguities you are ok.  The bad news is that you may have spent\r
-      time fixing ambiguities that were not real, or used k=2 when\r
-      ck=2 might have been sufficient, and so on.\r
-\r
-      The following grammar demonstrates the problem:\r
-\r
-        ------------------------------------------------------------\r
-            expr          :   ID ;\r
-\r
-            start         :   stmt SEMI ;\r
-\r
-            stmt          :   CASE expr COLON\r
-                          |   expr SEMI\r
-                          |   plain_stmt\r
-                          ;\r
-\r
-            plain_stmt    :   ID COLON ;\r
-        ------------------------------------------------------------\r
-\r
-      When compiled with k=1 and ck=2 it will report:\r
-\r
-         warning: alts 2 and 3 of the rule itself ambiguous upon\r
-                                             { IDENTIFIER }, { COLON }\r
-\r
-      When antlr analyzes "stmt" it computes the first[1] set of all\r
-      alternatives.  It finds an ambiguity between alts 2 and 3 for ID.\r
-      It then computes the first[2] set for alternatives 2 and 3 to resolve\r
-      the ambiguity.  In computing the first[2] set of "expr" (which is\r
-      only one token long) it needs to determine what could follow "expr".\r
-      Under a certain combination of circumstances antlr forgets that it\r
-      is trying to analyze "stmt" which can only be followed by SEMI and\r
-      adds to the first[2] set of "expr" the "global" follow set (including\r
-      "COLON") which could follow "expr" (under other conditions) in the\r
-      phrase "CASE expr COLON".\r
-\r
-#146. (Changed in MR11) Option -treport for locating "difficult" alts\r
-\r
-      It can be difficult to determine which alternatives are causing\r
-      pccts to work hard to resolve an ambiguity.  In some cases the\r
-      ambiguity is successfully resolved after much CPU time so there\r
-      is no message at all.\r
-\r
-      A rough measure of the amount of work being peformed which is\r
-      independent of the CPU speed and system load is the number of\r
-      tnodes created.  Using "-info t" gives information about the\r
-      total number of tnodes created and the peak number of tnodes.\r
-\r
-        Tree Nodes:  peak 1300k  created 1416k  lost 0\r
-\r
-      It also puts in the generated C or C++ file the number of tnodes\r
-      created for a rule (at the end of the rule).  However this\r
-      information is not sufficient to locate the alternatives within\r
-      a rule which are causing the creation of tnodes.\r
-\r
-      Using:\r
-\r
-             antlr -treport 100000 ....\r
-\r
-      causes antlr to list on stdout any alternatives which require the\r
-      creation of more than 100,000 tnodes, along with the lookahead sets\r
-      for those alternatives.\r
-\r
-      The following is a trivial case from the ansi.g grammar which shows\r
-      the format of the report.  This report might be of more interest\r
-      in cases where 1,000,000 tuples were created to resolve the ambiguity.\r
-\r
-      -------------------------------------------------------------------------\r
-        There were 0 tuples whose ambiguity could not be resolved\r
-             by full lookahead\r
-        There were 157 tnodes created to resolve ambiguity between:\r
-\r
-          Choice 1: statement/2  line 475  file ansi.g\r
-          Choice 2: statement/3  line 476  file ansi.g\r
-\r
-            Intersection of lookahead[1] sets:\r
-\r
-               IDENTIFIER\r
-\r
-            Intersection of lookahead[2] sets:\r
-\r
-               LPARENTHESIS     COLON            AMPERSAND        MINUS\r
-               STAR             PLUSPLUS         MINUSMINUS       ONESCOMPLEMENT\r
-               NOT              SIZEOF           OCTALINT         DECIMALINT\r
-               HEXADECIMALINT   FLOATONE         FLOATTWO         IDENTIFIER\r
-               STRING           CHARACTER\r
-      -------------------------------------------------------------------------\r
-\r
-#145. (Documentation)  Generation of Expression Trees\r
-\r
-      Item #99 was misleading because it implied that the optimization\r
-      for tree expressions was available only for trees created by\r
-      predicate expressions and neglected to mention that it required\r
-      the use of "-mrhoist on".  The optimization applies to tree\r
-      expressions created for grammars with k>1 and for predicates with\r
-      lookahead depth >1.\r
-\r
-      In MR11 the optimized version is always used so the -mrhoist on\r
-      option need not be specified.\r
-\r
-#144. (Changed in MR11) Incorrect test for exception group\r
-\r
-      In testing for a rule's exception group the label a pointer\r
-      is compared against '\0'.  The intention is "*pointer".\r
-\r
-      Reported by Jeffrey C. Fried (Jeff@Fried.net).\r
-\r
-#143. (Changed in MR11) Optional ";" at end of #token statement\r
-\r
-      Fixes problem of:\r
-\r
-            #token X "x"\r
-\r
-            <<\r
-                parser action\r
-            >>\r
-\r
-      Being confused with:\r
-\r
-            #token X "x" <<lexical action>>\r
-\r
-#142. (Changed in MR11) class BufFileInput subclass of DLGInputStream\r
-\r
-      Alexey Demakov (demakov@kazbek.ispras.ru) has supplied class\r
-      BufFileInput derived from DLGInputStream which provides a\r
-      function lookahead(char *string) to test characters in the\r
-      input stream more than one character ahead.\r
-\r
-      The default amount of lookahead is specified by the constructor\r
-      and defaults to 8 characters.  This does *not* include the one\r
-      character of lookahead maintained internally by DLG in member "ch"\r
-      and which is not available for testing via BufFileInput::lookahead().\r
-\r
-      This is a useful class for overcoming the one-character-lookahead\r
-      limitation of DLG without resorting to a lexer capable of\r
-      backtracking (like flex) which is not integrated with antlr as is\r
-      DLG.\r
-\r
-      There are no restrictions on copying or using BufFileInput.* except\r
-      that the authorship and related information must be retained in the\r
-      source code.\r
-\r
-      The class is located in pccts/h/BufFileInput.* of the kit.\r
-\r
-#141. (Changed in MR11) ZZDEBUG_CONSUME for ANTLRParser::consume()\r
-\r
-      A debug aid has been added to file ANTLRParser::consume() in\r
-      file AParser.cpp:\r
-\r
-            #ifdef ZZDEBUG_CONSUME_ACTION\r
-                zzdebug_consume_action();\r
-            #endif\r
-\r
-      Suggested by Sramji Ramanathan (ps@kumaran.com).\r
-\r
-#140. (Changed in MR11) #pred to define predicates\r
-\r
-      +---------------------------------------------------+\r
-      | Note: Assume "-prc on" for this entire discussion |\r
-      +---------------------------------------------------+\r
-\r
-      A problem with predicates is that each one is regarded as\r
-      unique and capable of disambiguating cases where two\r
-      alternatives have identical lookahead.  For example:\r
-\r
-        rule : <<pred(LATEXT(1))>>? A\r
-             | <<pred(LATEXT(1))>>? A\r
-             ;\r
-\r
-      will not cause any error messages or warnings to be issued\r
-      by earlier versions of pccts.  To compare the text of the\r
-      predicates is an incomplete solution.\r
-\r
-      In 1.33MR11 I am introducing the #pred statement in order to\r
-      solve some problems with predicates.  The #pred statement allows\r
-      one to give a symbolic name to a "predicate literal" or a\r
-      "predicate expression" in order to refer to it in other predicate\r
-      expressions or in the rules of the grammar.\r
-\r
-      The predicate literal associated with a predicate symbol is C\r
-      or C++ code which can be used to test the condition.  A\r
-      predicate expression defines a predicate symbol in terms of other\r
-      predicate symbols using "!", "&&", and "||".  A predicate symbol\r
-      can be defined in terms of a predicate literal, a predicate\r
-      expression, or *both*.\r
-\r
-      When a predicate symbol is defined with both a predicate literal\r
-      and a predicate expression, the predicate literal is used to generate\r
-      code, but the predicate expression is used to check for two\r
-      alternatives with identical predicates in both alternatives.\r
-\r
-      Here are some examples of #pred statements:\r
-\r
-        #pred  IsLabel       <<isLabel(LATEXT(1))>>?\r
-        #pred  IsLocalVar    <<isLocalVar(LATEXT(1))>>?\r
-        #pred  IsGlobalVar   <<isGlobalVar(LATEXT(1)>>?\r
-        #pred  IsVar         <<isVar(LATEXT(1))>>?       IsLocalVar || IsGlobalVar\r
-        #pred  IsScoped      <<isScoped(LATEXT(1))>>?    IsLabel || IsLocalVar\r
-\r
-      I hope that the use of EBNF notation to describe the syntax of the\r
-      #pred statement will not cause problems for my readers (joke).\r
-\r
-        predStatement : "#pred"\r
-                            CapitalizedName\r
-                              (\r
-                                  "<<predicate_literal>>?"\r
-                                | "<<predicate_literal>>?"  predOrExpr\r
-                                | predOrExpr\r
-                              )\r
-                      ;\r
-\r
-        predOrExpr    : predAndExpr ( "||" predAndExpr ) * ;\r
-\r
-        predAndExpr   : predPrimary ( "&&" predPrimary ) * ;\r
-\r
-        predPrimary   : CapitalizedName\r
-                      | "!" predPrimary\r
-                      | "(" predOrExpr ")"\r
-                      ;\r
-\r
-      What is the purpose of this nonsense ?\r
-\r
-      To understand how predicate symbols help, you need to realize that\r
-      predicate symbols are used in two different ways with two different\r
-      goals.\r
-\r
-        a. Allow simplification of predicates which have been combined\r
-           during predicate hoisting.\r
-\r
-        b. Allow recognition of identical predicates which can't disambiguate\r
-           alternatives with common lookahead.\r
-\r
-      First we will discuss goal (a).  Consider the following rule:\r
-\r
-            rule0: rule1\r
-                 | ID\r
-                 | ...\r
-                 ;\r
-\r
-            rule1: rule2\r
-                 | rule3\r
-                 ;\r
-\r
-            rule2: <<isX(LATEXT(1))>>? ID ;\r
-            rule3: <<!isX(LATEXT(1)>>? ID ;\r
-\r
-      When the predicates in rule2 and rule3 are combined by hoisting\r
-      to create a prediction expression for rule1 the result is:\r
-\r
-            if ( LA(1)==ID\r
-                && ( isX(LATEXT(1) || !isX(LATEXT(1) ) ) { rule1(); ...\r
-\r
-      This is inefficient, but more importantly, can lead to false\r
-      assumptions that the predicate expression distinguishes the rule1\r
-      alternative with some other alternative with lookahead ID.  In\r
-      MR11 one can write:\r
-\r
-            #pred IsX     <<isX(LATEXT(1))>>?\r
-\r
-            ...\r
-\r
-            rule2: <<IsX>>? ID  ;\r
-            rule3: <<!IsX>>? ID ;\r
-\r
-      During hoisting MR11 recognizes this as a special case and\r
-      eliminates the predicates.  The result is a prediction\r
-      expression like the following:\r
-\r
-            if ( LA(1)==ID ) { rule1(); ...\r
-\r
-      Please note that the following cases which appear to be equivalent\r
-      *cannot* be simplified by MR11 during hoisting because the hoisting\r
-      logic only checks for a "!" in the predicate action, not in the\r
-      predicate expression for a predicate symbol.\r
-\r
-        *Not* equivalent and is not simplified during hoisting:\r
-\r
-            #pred IsX      <<isX(LATEXT(1))>>?\r
-            #pred NotX     <<!isX(LATEXT(1))>>?\r
-            ...\r
-            rule2: <<IsX>>? ID  ;\r
-            rule3: <<NotX>>? ID ;\r
-\r
-        *Not* equivalent and is not simplified during hoisting:\r
-\r
-            #pred IsX      <<isX(LATEXT(1))>>?\r
-            #pred NotX     !IsX\r
-            ...\r
-            rule2: <<IsX>>? ID  ;\r
-            rule3: <<NotX>>? ID ;\r
-\r
-      Now we will discuss goal (b).\r
-\r
-      When antlr discovers that there is a lookahead ambiguity between\r
-      two alternatives it attempts to resolve the ambiguity by searching\r
-      for predicates in both alternatives.  In the past any predicate\r
-      would do, even if the same one appeared in both alternatives:\r
-\r
-            rule: <<p(LATEXT(1))>>? X\r
-                | <<p(LATEXT(1))>>? X\r
-                ;\r
-\r
-      The #pred statement is a start towards solving this problem.\r
-      During ambiguity resolution (*not* predicate hoisting) the\r
-      predicates for the two alternatives are expanded and compared.\r
-      Consider the following example:\r
-\r
-            #pred Upper     <<isUpper(LATEXT(1))>>?\r
-            #pred Lower     <<isLower(LATEXT(1))>>?\r
-            #pred Alpha     <<isAlpha(LATEXT(1))>>?  Upper || Lower\r
-\r
-            rule0: rule1\r
-                 | <<Alpha>>? ID\r
-                 ;\r
-\r
-            rule1:\r
-                 | rule2\r
-                 | rule3\r
-                 ...\r
-                 ;\r
-\r
-            rule2: <<Upper>>? ID;\r
-            rule3: <<Lower>>? ID;\r
-\r
-      The definition of #pred Alpha expresses:\r
-\r
-            a. to test the predicate use the C code "isAlpha(LATEXT(1))"\r
-\r
-            b. to analyze the predicate use the information that\r
-               Alpha is equivalent to the union of Upper and Lower,\r
-\r
-      During ambiguity resolution the definition of Alpha is expanded\r
-      into "Upper || Lower" and compared with the predicate in the other\r
-      alternative, which is also "Upper || Lower".  Because they are\r
-      identical MR11 will report a problem.\r
-\r
-    -------------------------------------------------------------------------\r
-      t10.g, line 5: warning: the predicates used to disambiguate rule rule0\r
-             (file t10.g alt 1 line 5 and alt 2 line 6)\r
-             are identical when compared without context and may have no\r
-             resolving power for some lookahead sequences.\r
-    -------------------------------------------------------------------------\r
-\r
-      If you use the "-info p" option the output file will contain:\r
-\r
-    +----------------------------------------------------------------------+\r
-    |#if 0                                                                 |\r
-    |                                                                      |\r
-    |The following predicates are identical when compared without          |\r
-    |  lookahead context information.  For some ambiguous lookahead        |\r
-    |  sequences they may not have any power to resolve the ambiguity.     |\r
-    |                                                                      |\r
-    |Choice 1: rule0/1  alt 1  line 5  file t10.g                          |\r
-    |                                                                      |\r
-    |  The original predicate for choice 1 with available context          |\r
-    |    information:                                                      |\r
-    |                                                                      |\r
-    |    OR expr                                                           |\r
-    |                                                                      |\r
-    |      pred  <<  Upper>>?                                              |\r
-    |                        depth=k=1  rule rule2  line 14  t10.g         |\r
-    |        set context:                                                  |\r
-    |           ID                                                         |\r
-    |                                                                      |\r
-    |      pred  <<  Lower>>?                                              |\r
-    |                        depth=k=1  rule rule3  line 15  t10.g         |\r
-    |        set context:                                                  |\r
-    |           ID                                                         |\r
-    |                                                                      |\r
-    |  The predicate for choice 1 after expansion (but without context     |\r
-    |    information):                                                     |\r
-    |                                                                      |\r
-    |    OR expr                                                           |\r
-    |                                                                      |\r
-    |      pred  <<  isUpper(LATEXT(1))>>?                                 |\r
-    |                        depth=k=1  rule   line 1  t10.g               |\r
-    |                                                                      |\r
-    |      pred  <<  isLower(LATEXT(1))>>?                                 |\r
-    |                        depth=k=1  rule   line 2  t10.g               |\r
-    |                                                                      |\r
-    |                                                                      |\r
-    |Choice 2: rule0/2  alt 2  line 6  file t10.g                          |\r
-    |                                                                      |\r
-    |  The original predicate for choice 2 with available context          |\r
-    |    information:                                                      |\r
-    |                                                                      |\r
-    |  pred  <<  Alpha>>?                                                  |\r
-    |                    depth=k=1  rule rule0  line 6  t10.g              |\r
-    |    set context:                                                      |\r
-    |       ID                                                             |\r
-    |                                                                      |\r
-    |  The predicate for choice 2 after expansion (but without context     |\r
-    |    information):                                                     |\r
-    |                                                                      |\r
-    |  OR expr                                                             |\r
-    |                                                                      |\r
-    |    pred  <<  isUpper(LATEXT(1))>>?                                   |\r
-    |                      depth=k=1  rule   line 1  t10.g                 |\r
-    |                                                                      |\r
-    |    pred  <<  isLower(LATEXT(1))>>?                                   |\r
-    |                      depth=k=1  rule   line 2  t10.g                 |\r
-    |                                                                      |\r
-    |                                                                      |\r
-    |#endif                                                                |\r
-    +----------------------------------------------------------------------+\r
-\r
-      The comparison of the predicates for the two alternatives takes\r
-      place without context information, which means that in some cases\r
-      the predicates will be considered identical even though they operate\r
-      on disjoint lookahead sets.  Consider:\r
-\r
-            #pred Alpha\r
-\r
-            rule1: <<Alpha>>? ID\r
-                 | <<Alpha>>? Label\r
-                 ;\r
-\r
-      Because the comparison of predicates takes place without context\r
-      these will be considered identical.  The reason for comparing\r
-      without context is that otherwise it would be necessary to re-evaluate\r
-      the entire predicate expression for each possible lookahead sequence.\r
-      This would require more code to be written and more CPU time during\r
-      grammar analysis, and it is not yet clear whether anyone will even make\r
-      use of the new #pred facility.\r
-\r
-      A temporary workaround might be to use different #pred statements\r
-      for predicates you know have different context.  This would avoid\r
-      extraneous warnings.\r
-\r
-      The above example might be termed a "false positive".  Comparison\r
-      without context will also lead to "false negatives".  Consider the\r
-      following example:\r
-\r
-            #pred Alpha\r
-            #pred Beta\r
-\r
-            rule1: <<Alpha>>? A\r
-                 | rule2\r
-                 ;\r
-\r
-            rule2: <<Alpha>>? A\r
-                 | <<Beta>>?  B\r
-                 ;\r
-\r
-      The predicate used for alt 2 of rule1 is (Alpha || Beta).  This\r
-      appears to be different than the predicate Alpha used for alt1.\r
-      However, the context of Beta is B.  Thus when the lookahead is A\r
-      Beta will have no resolving power and Alpha will be used for both\r
-      alternatives.  Using the same predicate for both alternatives isn't\r
-      very helpful, but this will not be detected with 1.33MR11.\r
-\r
-      To properly handle this the predicate expression would have to be\r
-      evaluated for each distinct lookahead context.\r
-\r
-      To determine whether two predicate expressions are identical is\r
-      difficult.  The routine may fail to identify identical predicates.\r
-\r
-      The #pred feature also compares predicates to see if a choice between\r
-      alternatives which is resolved by a predicate which makes the second\r
-      choice unreachable.  Consider the following example:\r
-\r
-            #pred A         <<A(LATEXT(1)>>?\r
-            #pred B         <<B(LATEXT(1)>>?\r
-            #pred A_or_B    A || B\r
-\r
-            r   : s\r
-                | t\r
-                ;\r
-            s   : <<A_or_B>>? ID\r
-                ;\r
-            t   : <<A>>? ID\r
-                ;\r
-\r
-        ----------------------------------------------------------------------------\r
-        t11.g, line 5: warning: the predicate used to disambiguate the\r
-               first choice of  rule r\r
-             (file t11.g alt 1 line 5 and alt 2 line 6)\r
-             appears to "cover" the second predicate when compared without context.\r
-             The second predicate may have no resolving power for some lookahead\r
-               sequences.\r
-        ----------------------------------------------------------------------------\r
-\r
-#139. (Changed in MR11) Problem with -gp in C++ mode\r
-\r
-      The -gp option to add a prefix to rule names did not work in\r
-      C++ mode.  This has been fixed.\r
-\r
-      Reported by Alexey Demakov (demakov@kazbek.ispras.ru).\r
-\r
-#138. (Changed in MR11) Additional makefiles for non-MSVC++ MS systems\r
-\r
-      Sramji Ramanathan (ps@kumaran.com) has supplied makefiles for\r
-      building antlr and dlg with Win95/NT development tools that\r
-      are not based on MSVC5.  They are pccts/antlr/AntlrMS.mak and\r
-      pccts/dlg/DlgMS.mak.\r
-\r
-      The first line of the makefiles require a definition of PCCTS_HOME.\r
-\r
-      These are in additiion to the AntlrMSVC50.* and DlgMSVC50.*\r
-      supplied by Jeff Vincent (JVincent@novell.com).\r
-\r
-#137. (Changed in MR11) Token getType(), getText(), getLine() const members\r
-\r
-      --------------------------------------------------------------------\r
-      If you use ANTLRCommonToken this change probably does not affect you.\r
-      --------------------------------------------------------------------\r
-\r
-      For a long time it has bothered me that these accessor functions\r
-      in ANTLRAbstractToken were not const member functions.  I have\r
-      refrained from changing them because it require users to modify\r
-      existing token class definitions which are derived directly\r
-      from ANTLRAbstractToken.  I think it is now time.\r
-\r
-      For those who are not used to C++, a "const member function" is a\r
-      member function which does not modify its own object - the thing\r
-      to which "this" points. This is quite different from a function\r
-      which does not modify its arguments\r
-\r
-      Most token definitions based on ANTLRAbstractToken have something like\r
-      the following in order to create concrete definitions of the pure\r
-      virtual methods in ANTLRAbstractToken:\r
-\r
-        class MyToken : public ANTLRAbstractToken {\r
-            ...\r
-            ANTLRTokenType getType() {return _type; }\r
-            int getLine()            {return _line; }\r
-            ANTLRChar * getText()    {return _text; }\r
-            ...\r
-        }\r
-\r
-      The required change is simply to put "const" following the function\r
-      prototype in the header (.h file) and the definition file (.cpp if\r
-      it is not inline):\r
-\r
-        class MyToken : public ANTLRAbstractToken {\r
-            ...\r
-            ANTLRTokenType getType() const {return _type; }\r
-            int getLine() const            {return _line; }\r
-            ANTLRChar * getText() const    {return _text; }\r
-            ...\r
-        }\r
-\r
-      This was originally proposed a long time ago by Bruce\r
-      Guenter (bruceg@qcc.sk.ca).\r
-\r
-#136. (Changed in MR11) Added getLength() to ANTLRCommonToken\r
-\r
-      Classes ANTLRCommonToken and ANTLRCommonTokenNoRefCountToken\r
-      now have a member function:\r
-\r
-            int getLength() const { return strlen(getText()) }\r
-\r
-      Suggested by Sramji Ramanathan (ps@kumaran.com).\r
-\r
-#135. (Changed in MR11) Raised antlr's own default ZZLEXBUFSIZE to 8k\r
-\r
-#134a. (ansi_mr10.zip)  T.J. Parr's ANSI C grammar made 1.33MR11 compatible\r
-\r
-       There is a typographical error in the definition of BITWISEOREQ:\r
-\r
-        #token BITWISEOREQ "!=" should be "\|="\r
-\r
-       When this change is combined with the bugfix to the follow set cache\r
-       problem (Item #147) and a minor rearrangement of the grammar\r
-       (Item #134b) it becomes a k=1 ck=2 grammar.\r
-\r
-#134b. (ansi_mr10.zip)  T.J. Parr's ANSI C grammar made 1.33MR11 compatible\r
-\r
-      The following changes were made in the ansi.g grammar (along with\r
-      using -mrhoist on):\r
-\r
-        ansi.g\r
-        ======\r
-        void tracein(char *)     ====>    void tracein(const char *)\r
-        void traceout(char *)    ====>    void traceout(const char *)\r
-\r
-        <LT(1)->getType()==IDENTIFIER ? isTypeName(LT(1)->getText()) : 1>>?\r
-        ====> <<isTypeName(LT(1)->getText())>>?\r
-\r
-        <<(LT(1)->getType()==LPARENTHESIS && LT(2)->getType()==IDENTIFIER) ? \\r
-                        isTypeName(LT(2)->getText()) : 1>>?\r
-        ====> (LPARENTHESIS IDENTIFIER)? => <<isTypeName(LT(2)->getText())>>?\r
-\r
-        <<(LT(1)->getType()==LPARENTHESIS && LT(2)->getType()==IDENTIFIER) ? \\r
-                        isTypeName(LT(2)->getText()) : 1>>?\r
-        ====> (LPARENTHESIS IDENTIFIER)? => <<isTypeName(LT(2)->getText())>>?\r
-\r
-        added to init(): traceOptionValueDefault=0;\r
-        added to init(): traceOption(-1);\r
-\r
-        change rule "statement":\r
-\r
-            statement\r
-                :   plain_label_statement\r
-                |   case_label_statement\r
-                |   <<;>> expression SEMICOLON\r
-                |   compound_statement\r
-                |   selection_statement\r
-                |   iteration_statement\r
-                |   jump_statement\r
-                |   SEMICOLON\r
-                ;\r
-\r
-            plain_label_statement\r
-                :   IDENTIFIER COLON statement\r
-                ;\r
-\r
-            case_label_statement\r
-                :   CASE constant_expression COLON statement\r
-                |   DEFAULT COLON statement\r
-            ;\r
-\r
-        support.cpp\r
-        ===========\r
-        void tracein(char *)     ====>    void tracein(const char *)\r
-        void traceout(char *)    ====>    void traceout(const char *)\r
-\r
-        added to tracein():  ANTLRParser::tracein(r);  // call superclass method\r
-        added to traceout(): ANTLRParser::traceout(r); // call superclass method\r
-\r
-        Makefile\r
-        ========\r
-        added to AFLAGS: -mrhoist on -prc on\r
-\r
-#133. (Changed in 1.33MR11) Make trace options public in ANTLRParser\r
-\r
-      In checking T.J. Parr's ANSI C grammar for compatibility with\r
-      1.33MR11 discovered that it was inconvenient to have the\r
-      trace facilities with protected access.\r
-\r
-#132. (Changed in 1.33MR11) Recognition of identical predicates in alts\r
-\r
-      Prior to 1.33MR11, there would be no ambiguity warning when the\r
-      very same predicate was used to disambiguate both alternatives:\r
-\r
-        test: ref B\r
-            | ref C\r
-            ;\r
-\r
-        ref : <<pred(LATEXT(1)>>? A\r
-\r
-      In 1.33MR11 this will cause the warning:\r
-\r
-        warning: the predicates used to disambiguate rule test\r
-            (file v98.g alt 1 line 1 and alt 2 line 2)\r
-             are identical and have no resolving power\r
-\r
-        -----------------  Note  -----------------\r
-\r
-          This is different than the following case\r
-\r
-                test: <<pred(LATEXT(1))>>? A B\r
-                    | <<pred(LATEXT(1)>>?  A C\r
-                    ;\r
-\r
-          In this case there are two distinct predicates\r
-          which have exactly the same text.  In the first\r
-          example there are two references to the same\r
-          predicate.  The problem represented by this\r
-          grammar will be addressed later.\r
-\r
-#131. (Changed in 1.33MR11) Case insensitive command line options\r
-\r
-      Command line switches like "-CC" and keywords like "on", "off",\r
-      and "stdin" are no longer case sensitive in antlr, dlg, and sorcerer.\r
-\r
-#130. (Changed in 1.33MR11) Changed ANTLR_VERSION to int from string\r
-\r
-      The ANTLR_VERSION was not an integer, making it difficult to\r
-      perform conditional compilation based on the antlr version.\r
-\r
-      Henceforth, ANTLR_VERSION will be:\r
-\r
-            (base_version * 10000) + release number\r
-\r
-            thus 1.33MR11 will be: 133*100+11 = 13311\r
-\r
-      Suggested by Rainer Janssen (Rainer.Janssen@Informatik.Uni-Oldenburg.DE).\r
-\r
-#129. (Changed in 1.33MR11) Addition of ANTLR_VERSION to <parserName>.h\r
-\r
-      The following code is now inserted into <parserName>.h amd\r
-      stdpccts.h:\r
-\r
-            #ifndef ANTLR_VERSION\r
-            #define ANTLR_VERSION 13311\r
-            #endif\r
-\r
-      Suggested by Rainer Janssen (Rainer.Janssen@Informatik.Uni-Oldenburg.DE)\r
-\r
-#128. (Changed in 1.33MR11) Redundant predicate code in (<<pred>>? ...)+\r
-\r
-      Prior to 1.33MR11, the following grammar would generate\r
-      redundant tests for the "while" condition.\r
-\r
-        rule2 : (<<pred>>? X)+ X\r
-              | B\r
-              ;\r
-\r
-      The code would resemble:\r
-\r
-            if (LA(1)==X) {\r
-                if (pred) {\r
-                    do {\r
-                        if (!pred) {zzfailed_pred("  pred");}\r
-                        zzmatch(X); zzCONSUME;\r
-                    } while (LA(1)==X && pred && pred);\r
-            } else {...\r
-\r
-      With 1.33MR11 the redundant predicate test is omitted.\r
-\r
-#127. (Changed in 1.33MR11)\r
-\r
-                    Count Syntax Errors     Count DLG Errors\r
-                    -------------------     ----------------\r
-\r
-       C++ mode     ANTLRParser::           DLGLexerBase::\r
-                      syntaxErrCount          lexErrCount\r
-       C mode       zzSyntaxErrCount        zzLexErrCount\r
-\r
-       The C mode variables are global and initialized to 0.\r
-       They are *not* reset to 0 automatically when antlr is\r
-       restarted.\r
-\r
-       The C++ mode variables are public.  They are initialized\r
-       to 0 by the constructors.  They are *not* reset to 0 by the\r
-       ANTLRParser::init() method.\r
-\r
-       Suggested by Reinier van den Born (reinier@vnet.ibm.com).\r
-\r
-#126. (Changed in 1.33MR11) Addition of #first <<...>>\r
-\r
-       The #first <<...>> inserts the specified text in the output\r
-       files before any other #include statements required by pccts.\r
-       The only things before the #first text are comments and\r
-       a #define ANTLR_VERSION.\r
-\r
-       Requested by  and Esa Pulkkinen (esap@cs.tut.fi) and Alexin\r
-       Zoltan (alexin@inf.u-szeged.hu).\r
-\r
-#125. (Changed in 1.33MR11) Lookahead for (guard)? && <<p>>? predicates\r
-\r
-       When implementing the new style of guard predicate (Item #113)\r
-       in 1.33MR10 I decided to temporarily ignore the problem of\r
-       computing the "narrowest" lookahead context.\r
-\r
-       Consider the following k=1 grammar:\r
-\r
-            start : a\r
-                  | b\r
-                  ;\r
-\r
-            a     : (A)? && <<pred1(LATEXT(1))>>? ab ;\r
-            b     : (B)? && <<pred2(LATEXT(1))>>? ab ;\r
-\r
-            ab    : A | B ;\r
-\r
-       In MR10 the context for both "a" and "b" was {A B} because this is\r
-       the first set of rule "ab".  Normally, this is not a problem because\r
-       the predicate which follows the guard inhibits any ambiguity report\r
-       by antlr.\r
-\r
-       In MR11 the first set for rule "a" is {A} and for rule "b" it is {B}.\r
-\r
-#124. A Note on the New "&&" Style Guarded Predicates\r
-\r
-        I've been asked several times, "What is the difference between\r
-        the old "=>" style guard predicates and the new style "&&" guard\r
-        predicates, and how do you choose one over the other" ?\r
-\r
-        The main difference is that the "=>" does not apply the\r
-        predicate if the context guard doesn't match, whereas\r
-        the && form always does.  What is the significance ?\r
-\r
-        If you have a predicate which is not on the "leading edge"\r
-        it cannot be hoisted.  Suppose you need a predicate that\r
-        looks at LA(2).  You must introduce it manually.  The\r
-        classic example is:\r
-\r
-            castExpr :\r
-                     LP typeName RP\r
-                     | ....\r
-                     ;\r
-\r
-            typeName : <<isTypeName(LATEXT(1))>>?  ID\r
-                     | STRUCT ID\r
-                     ;\r
-\r
-        The problem  is that typeName isn't on the leading edge\r
-        of castExpr, so the predicate isTypeName won't be hoisted into\r
-        castExpr to help make a decision on which production to choose.\r
-\r
-        The *first* attempt to fix it is this:\r
-\r
-            castExpr :\r
-                     <<isTypeName(LATEXT(2))>>?\r
-                                        LP typeName RP\r
-                     | ....\r
-                     ;\r
-\r
-        Unfortunately, this won't work because it ignores\r
-        the problem of STRUCT.  The solution is to apply\r
-        isTypeName() in castExpr if LA(2) is an ID and\r
-        don't apply it when LA(2) is STRUCT:\r
-\r
-            castExpr :\r
-                     (LP ID)? => <<isTypeName(LATEXT(2))>>?\r
-                                        LP typeName RP\r
-                     | ....\r
-                     ;\r
-\r
-        In conclusion, the "=>" style guarded predicate is\r
-        useful when:\r
-\r
-            a. the tokens required for the predicate\r
-               are not on the leading edge\r
-            b. there are alternatives in the expression\r
-               selected by the predicate for which the\r
-               predicate is inappropriate\r
-\r
-        If (b) were false, then one could use a simple\r
-        predicate (assuming "-prc on"):\r
-\r
-            castExpr :\r
-                     <<isTypeName(LATEXT(2))>>?\r
-                                        LP typeName RP\r
-                     | ....\r
-                     ;\r
-\r
-            typeName : <<isTypeName(LATEXT(1))>>?  ID\r
-                     ;\r
-\r
-        So, when do you use the "&&" style guarded predicate ?\r
-\r
-        The new-style "&&" predicate should always be used with\r
-        predicate context.  The context guard is in ADDITION to\r
-        the automatically computed context.  Thus it useful for\r
-        predicates which depend on the token type for reasons\r
-        other than context.\r
-\r
-        The following example is contributed by Reinier van den Born\r
-        (reinier@vnet.ibm.com).\r
-\r
- +-------------------------------------------------------------------------+\r
- | This grammar has two ways to call functions:                            |\r
- |                                                                         |\r
- |  - a "standard" call syntax with parens and comma separated args        |\r
- |  - a shell command like syntax (no parens and spacing separated args)   |\r
- |                                                                         |\r
- | The former also allows a variable to hold the name of the function,     |\r
- | the latter can also be used to call external commands.                  |\r
- |                                                                         |\r
- | The grammar (simplified) looks like this:                               |\r
- |                                                                         |\r
- |   fun_call   :     ID "(" { expr ("," expr)* } ")"                      |\r
- |                                  /* ID is function name */              |\r
- |              | "@" ID "(" { expr ("," expr)* } ")"                      |\r
- |                                  /* ID is var containing fun name */    |\r
- |              ;                                                          |\r
- |                                                                         |\r
- |   command    : ID expr*          /* ID is function name */              |\r
- |              | path expr*        /* path is external command name */    |\r
- |              ;                                                          |\r
- |                                                                         |\r
- |   path       : ID                /* left out slashes and such */        |\r
- |              | "@" ID            /* ID is environment var */            |\r
- |              ;                                                          |\r
- |                                                                         |\r
- |   expr       : ....                                                     |\r
- |              | "(" expr ")";                                            |\r
- |                                                                         |\r
- |   call       : fun_call                                                 |\r
- |              | command                                                  |\r
- |              ;                                                          |\r
- |                                                                         |\r
- | Obviously the call is wildly ambiguous. This is more or less how this   |\r
- | is to be resolved:                                                      |\r
- |                                                                         |\r
- |    A call begins with an ID or an @ followed by an ID.                  |\r
- |                                                                         |\r
- |    If it is an ID and if it is an ext. command name  -> command         |\r
- |                       if followed by a paren         -> fun_call        |\r
- |                       otherwise                      -> command         |\r
- |                                                                         |\r
- |    If it is an @  and if the ID is a var name        -> fun_call        |\r
- |                       otherwise                      -> command         |\r
- |                                                                         |\r
- | One can implement these rules quite neatly using && predicates:         |\r
- |                                                                         |\r
- |   call       : ("@" ID)? && <<isVarName(LT(2))>>? fun_call              |\r
- |              | (ID)?     && <<isExtCmdName>>?     command               |\r
- |              | (ID "(")?                          fun_call              |\r
- |              |                                    command               |\r
- |              ;                                                          |\r
- |                                                                         |\r
- | This can be done better, so it is not an ideal example, but it          |\r
- | conveys the principle.                                                  |\r
- +-------------------------------------------------------------------------+\r
-\r
-#123. (Changed in 1.33MR11) Correct definition of operators in ATokPtr.h\r
-\r
-        The return value of operators in ANTLRTokenPtr:\r
-\r
-        changed: unsigned ... operator !=(...)\r
-             to: int ... operator != (...)\r
-        changed: unsigned ... operator ==(...)\r
-             to: int ... operator == (...)\r
-\r
-        Suggested by R.A. Nelson (cowboy@VNET.IBM.COM)\r
-\r
-#122. (Changed in 1.33MR11)  Member functions to reset DLG in C++ mode\r
-\r
-         void DLGFileReset(FILE *f) { input = f; found_eof = 0; }\r
-         void DLGStringReset(DLGChar *s) { input = s; p = &input[0]; }\r
-\r
-        Supplied by R.A. Nelson (cowboy@VNET.IBM.COM)\r
-\r
-#121. (Changed in 1.33MR11)  Another attempt to fix -o (output dir) option\r
-\r
-      Another attempt is made to improve the -o option of antlr, dlg,\r
-      and sorcerer.  This one by JVincent (JVincent@novell.com).\r
-\r
-      The current rule:\r
-\r
-        a. If -o  is not specified than any explicit directory\r
-           names are retained.\r
-\r
-        b. If -o is specified than the -o directory name overrides any\r
-           explicit directory names.\r
-\r
-        c. The directory name of the grammar file is *not* stripped\r
-           to create the main output file.  However it is stil subject\r
-           to override by the -o directory name.\r
-\r
-#120. (Changed in 1.33MR11) "-info f" output to stdout rather than stderr\r
-\r
-      Added option 0 (e.g. "-info 0") which is a noop.\r
-\r
-#119. (Changed in 1.33MR11) Ambiguity aid for grammars\r
-\r
-      The user can ask for additional information on ambiguities reported\r
-      by antlr to stdout.  At the moment, only one ambiguity report can\r
-      be created in an antlr run.\r
-\r
-      This feature is enabled using the "-aa" (Ambiguity Aid)  option.\r
-\r
-      The following options control the reporting of ambiguities:\r
-\r
-          -aa ruleName       Selects reporting by name of rule\r
-          -aa lineNumber     Selects reporting by line number\r
-                               (file name not compared)\r
-\r
-          -aam               Selects "multiple" reporting for a token\r
-                             in the intersection set of the\r
-                             alternatives.\r
-\r
-                             For instance, the token ID may appear dozens\r
-                             of times in various paths as the program\r
-                             explores the rules which are reachable from\r
-                             the point of an ambiguity. With option -aam\r
-                             every possible path the search program\r
-                             encounters is reported.\r
-\r
-                             Without -aam only the first encounter is\r
-                             reported.  This may result in incomplete\r
-                             information, but the information may be\r
-                             sufficient and much shorter.\r
-\r
-          -aad depth         Selects the depth of the search.\r
-                             The default value is 1.\r
-\r
-                             The number of paths to be searched, and the\r
-                             size of the report can grow geometrically\r
-                             with the -ck value if a full search for all\r
-                             contributions to the source of the ambiguity\r
-                             is explored.\r
-\r
-                             The depth represents the number of tokens\r
-                             in the lookahead set which are matched against\r
-                             the set of ambiguous tokens.  A depth of 1\r
-                             means that the search stops when a lookahead\r
-                             sequence of just one token is matched.\r
-\r
-                             A k=1 ck=6 grammar might generate 5,000 items\r
-                             in a report if a full depth 6 search is made\r
-                             with the Ambiguity Aid.  The source of the\r
-                             problem may be in the first token and obscured\r
-                             by the volume of data - I hesitate to call\r
-                             it information.\r
-\r
-                             When the user selects a depth > 1, the search\r
-                             is first performed at depth=1 for both\r
-                             alternatives, then depth=2 for both alternatives,\r
-                             etc.\r
-\r
-      Sample output for rule grammar in antlr.g itself:\r
-\r
-  +---------------------------------------------------------------------+\r
-  | Ambiguity Aid                                                       |\r
-  |                                                                     |\r
-  |   Choice 1: grammar/70                 line 632  file a.g           |\r
-  |   Choice 2: grammar/82                 line 644  file a.g           |\r
-  |                                                                     |\r
-  |   Intersection of lookahead[1] sets:                                |\r
-  |                                                                     |\r
-  |      "\}"             "class"          "#errclass"      "#tokclass" |\r
-  |                                                                     |\r
-  |    Choice:1  Depth:1  Group:1  ("#errclass")                        |\r
-  |  1 in (...)* block                grammar/70       line 632   a.g   |\r
-  |  2 to error                       grammar/73       line 635   a.g   |\r
-  |  3 error                          error/1          line 894   a.g   |\r
-  |  4 #token "#errclass"             error/2          line 895   a.g   |\r
-  |                                                                     |\r
-  |    Choice:1  Depth:1  Group:2  ("#tokclass")                        |\r
-  |  2 to tclass                      grammar/74       line 636   a.g   |\r
-  |  3 tclass                         tclass/1         line 937   a.g   |\r
-  |  4 #token "#tokclass"             tclass/2         line 938   a.g   |\r
-  |                                                                     |\r
-  |    Choice:1  Depth:1  Group:3  ("class")                            |\r
-  |  2 to class_def                   grammar/75       line 637   a.g   |\r
-  |  3 class_def                      class_def/1      line 669   a.g   |\r
-  |  4 #token "class"                 class_def/3      line 671   a.g   |\r
-  |                                                                     |\r
-  |    Choice:1  Depth:1  Group:4  ("\}")                               |\r
-  |  2 #token "\}"                    grammar/76       line 638   a.g   |\r
-  |                                                                     |\r
-  |    Choice:2  Depth:1  Group:5  ("#errclass")                        |\r
-  |  1 in (...)* block                grammar/83       line 645   a.g   |\r
-  |  2 to error                       grammar/93       line 655   a.g   |\r
-  |  3 error                          error/1          line 894   a.g   |\r
-  |  4 #token "#errclass"             error/2          line 895   a.g   |\r
-  |                                                                     |\r
-  |    Choice:2  Depth:1  Group:6  ("#tokclass")                        |\r
-  |  2 to tclass                      grammar/94       line 656   a.g   |\r
-  |  3 tclass                         tclass/1         line 937   a.g   |\r
-  |  4 #token "#tokclass"             tclass/2         line 938   a.g   |\r
-  |                                                                     |\r
-  |    Choice:2  Depth:1  Group:7  ("class")                            |\r
-  |  2 to class_def                   grammar/95       line 657   a.g   |\r
-  |  3 class_def                      class_def/1      line 669   a.g   |\r
-  |  4 #token "class"                 class_def/3      line 671   a.g   |\r
-  |                                                                     |\r
-  |    Choice:2  Depth:1  Group:8  ("\}")                               |\r
-  |  2 #token "\}"                    grammar/96       line 658   a.g   |\r
-  +---------------------------------------------------------------------+\r
-\r
-      For a linear lookahead set ambiguity (where k=1 or for k>1 but\r
-      when all lookahead sets [i] with i<k all have degree one) the\r
-      reports appear in the following order:\r
-\r
-        for (depth=1 ; depth <= "-aad depth" ; depth++) {\r
-          for (alternative=1; alternative <=2 ; alternative++) {\r
-            while (matches-are-found) {\r
-              group++;\r
-              print-report\r
-            };\r
-          };\r
-       };\r
-\r
-      For reporting a k-tuple ambiguity, the reports appear in the\r
-      following order:\r
-\r
-        for (depth=1 ; depth <= "-aad depth" ; depth++) {\r
-          while (matches-are-found) {\r
-            for (alternative=1; alternative <=2 ; alternative++) {\r
-              group++;\r
-              print-report\r
-            };\r
-          };\r
-       };\r
-\r
-      This is because matches are generated in different ways for\r
-      linear lookahead and k-tuples.\r
-\r
-#118. (Changed in 1.33MR11) DEC VMS makefile and VMS related changes\r
-\r
-      Revised makefiles for DEC/VMS operating system for antlr, dlg,\r
-      and sorcerer.\r
-\r
-      Reduced names of routines with external linkage to less than 32\r
-      characters to conform to DEC/VMS linker limitations.\r
-\r
-      Jean-Francois Pieronne discovered problems with dlg and antlr\r
-      due to the VMS linker not being case sensitive for names with\r
-      external linkage.  In dlg the problem was with "className" and\r
-      "ClassName".  In antlr the problem was with "GenExprSets" and\r
-      "genExprSets".\r
-\r
-      Added genmms, a version of genmk for the DEC/VMS version of make.\r
-      The source is in directory pccts/support/DECmms.\r
-\r
-      All VMS contributions by Jean-Francois Pieronne (jfp@iname.com).\r
-\r
-#117. (Changed in 1.33MR10) new EXPERIMENTAL predicate hoisting code\r
-\r
-      The hoisting of predicates into rules to create prediction\r
-      expressions is a problem in antlr.  Consider the following\r
-      example (k=1 with -prc on):\r
-\r
-        start   : (a)* "@" ;\r
-        a       : b | c ;\r
-        b       : <<isUpper(LATEXT(1))>>? A ;\r
-        c       : A ;\r
-\r
-      Prior to 1.33MR10 the code generated for "start" would resemble:\r
-\r
-        while {\r
-            if (LA(1)==A &&\r
-                    (!LA(1)==A || isUpper())) {\r
-              a();\r
-            }\r
-        };\r
-\r
-      This code is wrong because it makes rule "c" unreachable from\r
-      "start".  The essence of the problem is that antlr fails to\r
-      recognize that there can be a valid alternative within "a" even\r
-      when the predicate <<isUpper(LATEXT(1))>>? is false.\r
-\r
-      In 1.33MR10 with -mrhoist the hoisting of the predicate into\r
-      "start" is suppressed because it recognizes that "c" can\r
-      cover all the cases where the predicate is false:\r
-\r
-        while {\r
-            if (LA(1)==A) {\r
-              a();\r
-            }\r
-        };\r
-\r
-      With the antlr "-info p" switch the user will receive information\r
-      about the predicate suppression in the generated file:\r
-\r
-      --------------------------------------------------------------\r
-        #if 0\r
-\r
-        Hoisting of predicate suppressed by alternative without predicate.\r
-        The alt without the predicate includes all cases where\r
-            the predicate is false.\r
-\r
-           WITH predicate: line 7  v1.g\r
-           WITHOUT predicate: line 7  v1.g\r
-\r
-        The context set for the predicate:\r
-\r
-             A\r
-\r
-        The lookahead set for the alt WITHOUT the semantic predicate:\r
-\r
-             A\r
-\r
-        The predicate:\r
-\r
-          pred <<  isUpper(LATEXT(1))>>?\r
-                          depth=k=1  rule b  line 9  v1.g\r
-            set context:\r
-               A\r
-            tree context: null\r
-\r
-        Chain of referenced rules:\r
-\r
-            #0  in rule start (line 5 v1.g) to rule a\r
-            #1  in rule a (line 7 v1.g)\r
-\r
-        #endif\r
-      --------------------------------------------------------------\r
-\r
-      A predicate can be suppressed by a combination of alternatives\r
-      which, taken together, cover a predicate:\r
-\r
-        start   : (a)* "@" ;\r
-\r
-        a       : b | ca | cb | cc ;\r
-\r
-        b       : <<isUpper(LATEXT(1))>>? ( A | B | C ) ;\r
-\r
-        ca      : A ;\r
-        cb      : B ;\r
-        cc      : C ;\r
-\r
-      Consider a more complex example in which "c" covers only part of\r
-      a predicate:\r
-\r
-        start   : (a)* "@" ;\r
-\r
-        a       : b\r
-                | c\r
-                ;\r
-\r
-        b       : <<isUpper(LATEXT(1))>>?\r
-                    ( A\r
-                    | X\r
-                    );\r
-\r
-        c       : A\r
-                ;\r
-\r
-      Prior to 1.33MR10 the code generated for "start" would resemble:\r
-\r
-        while {\r
-            if ( (LA(1)==A || LA(1)==X) &&\r
-                    (! (LA(1)==A || LA(1)==X) || isUpper()) {\r
-              a();\r
-            }\r
-        };\r
-\r
-      With 1.33MR10 and -mrhoist the predicate context is restricted to\r
-      the non-covered lookahead.  The code resembles:\r
-\r
-        while {\r
-            if ( (LA(1)==A || LA(1)==X) &&\r
-                  (! (LA(1)==X) || isUpper()) {\r
-              a();\r
-            }\r
-        };\r
-\r
-      With the antlr "-info p" switch the user will receive information\r
-      about the predicate restriction in the generated file:\r
-\r
-      --------------------------------------------------------------\r
-        #if 0\r
-\r
-        Restricting the context of a predicate because of overlap\r
-          in the lookahead set between the alternative with the\r
-          semantic predicate and one without\r
-        Without this restriction the alternative without the predicate\r
-          could not be reached when input matched the context of the\r
-          predicate and the predicate was false.\r
-\r
-           WITH predicate: line 11  v4.g\r
-           WITHOUT predicate: line 12  v4.g\r
-\r
-        The original context set for the predicate:\r
-\r
-             A                X\r
-\r
-        The lookahead set for the alt WITHOUT the semantic predicate:\r
-\r
-             A\r
-\r
-        The intersection of the two sets\r
-\r
-             A\r
-\r
-        The original predicate:\r
-\r
-          pred <<  isUpper(LATEXT(1))>>?\r
-                          depth=k=1  rule b  line 15  v4.g\r
-            set context:\r
-               A                X\r
-            tree context: null\r
-\r
-        The new (modified) form of the predicate:\r
-\r
-          pred <<  isUpper(LATEXT(1))>>?\r
-                          depth=k=1  rule b  line 15  v4.g\r
-            set context:\r
-               X\r
-            tree context: null\r
-\r
-        #endif\r
-      --------------------------------------------------------------\r
-\r
-      The bad news about -mrhoist:\r
-\r
-        (a) -mrhoist does not analyze predicates with lookahead\r
-            depth > 1.\r
-\r
-        (b) -mrhoist does not look past a guarded predicate to\r
-            find context which might cover other predicates.\r
-\r
-      For these cases you might want to use syntactic predicates.\r
-      When a semantic predicate fails during guess mode the guess\r
-      fails and the next alternative is tried.\r
-\r
-      Limitation (a) is illustrated by the following example:\r
-\r
-        start    : (stmt)* EOF ;\r
-\r
-        stmt     : cast\r
-                 | expr\r
-                 ;\r
-        cast     : <<isTypename(LATEXT(2))>>? LP ID RP ;\r
-\r
-        expr     : LP ID RP ;\r
-\r
-      This is not much different from the first example, except that\r
-      it requires two tokens of lookahead context to determine what\r
-      to do.  This predicate is NOT suppressed because the current version\r
-      is unable to handle predicates with depth > 1.\r
-\r
-      A predicate can be combined with other predicates during hoisting.\r
-      In those cases the depth=1 predicates are still handled.  Thus,\r
-      in the following example the isUpper() predicate will be suppressed\r
-      by line #4 when hoisted from "bizarre" into "start", but will still\r
-      be present in "bizarre" in order to predict "stmt".\r
-\r
-        start    : (bizarre)* EOF ;     // #1\r
-                                        // #2\r
-        bizarre  : stmt                 // #3\r
-                 | A                    // #4\r
-                 ;\r
-\r
-        stmt     : cast\r
-                 | expr\r
-                 ;\r
-\r
-        cast     : <<isTypename(LATEXT(2))>>? LP ID RP ;\r
-\r
-        expr     : LP ID RP ;\r
-                 | <<isUpper(LATEXT(1))>>? A\r
-\r
-      Limitation (b) is illustrated by the following example of a\r
-      context guarded predicate:\r
-\r
-        rule : (A)? <<p>>?          // #1\r
-                     (A             // #2\r
-                     |B             // #3\r
-                     )              // #4\r
-             | <<q>> B              // #5\r
-             ;\r
-\r
-      Recall that this means that when the lookahead is NOT A then\r
-      the predicate "p" is ignored and it attempts to match "A|B".\r
-      Ideally, the "B" at line #3 should suppress predicate "q".\r
-      However, the current version does not attempt to look past\r
-      the guard predicate to find context which might suppress other\r
-      predicates.\r
-\r
-      In some cases -mrhoist will lead to the reporting of ambiguities\r
-      which were not visible before:\r
-\r
-        start   : (a)* "@";\r
-        a       : bc | d;\r
-        bc      : b  | c ;\r
-\r
-        b       : <<isUpper(LATEXT(1))>>? A;\r
-        c       : A ;\r
-\r
-        d       : A ;\r
-\r
-      In this case there is a true ambiguity in "a" between "bc" and "d"\r
-      which can both match "A".  Without -mrhoist the predicate in "b"\r
-      is hoisted into "a" and there is no ambiguity reported.  However,\r
-      with -mrhoist, the predicate in "b" is suppressed by "c" (as it\r
-      should be) making the ambiguity in "a" apparent.\r
-\r
-      The motivations for these changes were hoisting problems reported\r
-      by Reinier van den Born (reinier@vnet.ibm.com) and several others.\r
-\r
-#116. (Changed in 1.33MR10) C++ mode: tracein/traceout rule name is (const char *)\r
-\r
-      The prototype for C++ mode routine tracein (and traceout) has changed from\r
-      "char *" to "const char *".\r
-\r
-#115. (Changed in 1.33MR10) Using guess mode with exception handlers in C mode\r
-\r
-      The definition of the C mode macros zzmatch_wsig and zzsetmatch_wsig\r
-      neglected to consider guess mode.  When control passed to the rule's\r
-      parse exception handler the routine would exit without ever closing the\r
-      guess block. This would lead to unpredictable behavior.\r
-\r
-      In 1.33MR10 the behavior of exceptions in C mode and C++ mode should be\r
-      identical.\r
-\r
-#114. (Changed in 1.33MR10) difference in [zz]resynch() between C and C++ modes\r
-\r
-      There was a slight difference in the way C and C++ mode resynchronized\r
-      following a parsing error.  The C routine would sometimes skip an extra\r
-      token before attempting to resynchronize.\r
-\r
-      The C routine was changed to match the C++ routine.\r
-\r
-#113. (Changed in 1.33MR10) new context guarded pred: (g)? && <<p>>? expr\r
-\r
-      The existing context guarded predicate:\r
-\r
-            rule : (guard)? => <<p>>? expr\r
-                 | next_alternative\r
-                 ;\r
-\r
-      generates code which resembles:\r
-\r
-            if (lookahead(expr) && (!guard || pred)) {\r
-              expr()\r
-            } else ....\r
-\r
-      This is not suitable for some applications because it allows\r
-      expr() to be invoked when the predicate is false.  This is\r
-      intentional because it is meant to mimic automatically computed\r
-      predicate context.\r
-\r
-      The new context guarded predicate uses the guard information\r
-      differently because it has a different goal.  Consider:\r
-\r
-            rule : (guard)? && <<p>>? expr\r
-                 | next_alternative\r
-                 ;\r
-\r
-      The new style of context guarded predicate is equivalent to:\r
-\r
-            rule : <<guard==true && pred>>? expr\r
-                 | next_alternative\r
-                 ;\r
-\r
-      It generates code which resembles:\r
-\r
-            if (lookahead(expr) && guard && pred) {\r
-                expr();\r
-            } else ...\r
-\r
-      Both forms of guarded predicates severely restrict the form of\r
-      the context guard: it can contain no rule references, no\r
-      (...)*, no (...)+, and no {...}.  It may contain token and\r
-      token class references, and alternation ("|").\r
-\r
-      Addition for 1.33MR11: in the token expression all tokens must\r
-      be at the same height of the token tree:\r
-\r
-            (A ( B | C))? && ...            is ok (all height 2)\r
-            (A ( B |  ))? && ...            is not ok (some 1, some 2)\r
-            (A B C D | E F G H)? && ...     is ok (all height 4)\r
-            (A B C D | E )? && ...          is not ok (some 4, some 1)\r
-\r
-      This restriction is required in order to properly compute the lookahead\r
-      set for expressions like:\r
-\r
-            rule1 : (A B C)? && <<pred>>? rule2 ;\r
-            rule2 : (A|X) (B|Y) (C|Z);\r
-\r
-      This addition was suggested by Rienier van den Born (reinier@vnet.ibm.com)\r
-\r
-#112. (Changed in 1.33MR10) failed validation predicate in C guess mode\r
-\r
-      John Lilley (jlilley@empathy.com) suggested that failed validation\r
-      predicates abort a guess rather than reporting a failed error.\r
-      This was installed in C++ mode (Item #4).  Only now was it noticed\r
-      that the fix was never installed for C mode.\r
-\r
-#111. (Changed in 1.33MR10) moved zzTRACEIN to before init action\r
-\r
-      When the antlr -gd switch is present antlr generates calls to\r
-      zzTRACEIN at the start of a rule and zzTRACEOUT at the exit\r
-      from a rule.  Prior to 1.33MR10 Tthe call to zzTRACEIN was\r
-      after the init-action, which could cause confusion because the\r
-      init-actions were reported with the name of the enclosing rule,\r
-      rather than the active rule.\r
-\r
-#110. (Changed in 1.33MR10) antlr command line copied to generated file\r
-\r
-      The antlr command line is now copied to the generated file near\r
-      the start.\r
-\r
-#109. (Changed in 1.33MR10) improved trace information\r
-\r
-      The quality of the trace information provided by the "-gd"\r
-      switch has been improved significantly.  Here is an example\r
-      of the output from a test program.  It shows the rule name,\r
-      the first token of lookahead, the call depth, and the guess\r
-      status:\r
-\r
-        exit rule gusxx {"?"} depth 2\r
-        enter rule gusxx {"?"} depth 2\r
-        enter rule gus1 {"o"} depth 3 guessing\r
-        guess done - returning to rule gus1 {"o"} at depth 3\r
-                    (guess mode continues - an enclosing guess is still active)\r
-        guess done - returning to rule gus1 {"Z"} at depth 3\r
-                    (guess mode continues - an enclosing guess is still active)\r
-        exit rule gus1 {"Z"} depth 3 guessing\r
-        guess done - returning to rule gusxx {"o"} at depth 2 (guess mode ends)\r
-        enter rule gus1 {"o"} depth 3\r
-        guess done - returning to rule gus1 {"o"} at depth 3 (guess mode ends)\r
-        guess done - returning to rule gus1 {"Z"} at depth 3 (guess mode ends)\r
-        exit rule gus1 {"Z"} depth 3\r
-        line 1: syntax error at "Z" missing SC\r
-            ...\r
-\r
-      Rule trace reporting is controlled by the value of the integer\r
-      [zz]traceOptionValue:  when it is positive tracing is enabled,\r
-      otherwise it is disabled.  Tracing during guess mode is controlled\r
-      by the value of the integer [zz]traceGuessOptionValue.  When\r
-      it is positive AND [zz]traceOptionValue is positive rule trace\r
-      is reported in guess mode.\r
-\r
-      The values of [zz]traceOptionValue and [zz]traceGuessOptionValue\r
-      can be adjusted by subroutine calls listed below.\r
-\r
-      Depending on the presence or absence of the antlr -gd switch\r
-      the variable [zz]traceOptionValueDefault is set to 0 or 1.  When\r
-      the parser is initialized or [zz]traceReset() is called the\r
-      value of [zz]traceOptionValueDefault is copied to [zz]traceOptionValue.\r
-      The value of [zz]traceGuessOptionValue is always initialzed to 1,\r
-      but, as noted earlier, nothing will be reported unless\r
-      [zz]traceOptionValue is also positive.\r
-\r
-      When the parser state is saved/restored the value of the trace\r
-      variables are also saved/restored.  If a restore causes a change in\r
-      reporting behavior from on to off or vice versa this will be reported.\r
-\r
-      When the -gd option is selected, the macro "#define zzTRACE_RULES"\r
-      is added to appropriate output files.\r
-\r
-        C++ mode\r
-        --------\r
-        int     traceOption(int delta)\r
-        int     traceGuessOption(int delta)\r
-        void    traceReset()\r
-        int     traceOptionValueDefault\r
-\r
-        C mode\r
-        --------\r
-        int     zzTraceOption(int delta)\r
-        int     zzTraceGuessOption(int delta)\r
-        void    zzTraceReset()\r
-        int     zzTraceOptionValueDefault\r
-\r
-      The argument "delta" is added to the traceOptionValue.  To\r
-      turn on trace when inside a particular rule one:\r
-\r
-        rule : <<traceOption(+1);>>\r
-               (\r
-                rest-of-rule\r
-               )\r
-               <<traceOption(-1);>>\r
-       ;  /* fail clause */ <<traceOption(-1);>>\r
-\r
-      One can use the same idea to turn *off* tracing within a\r
-      rule by using a delta of (-1).\r
-\r
-      An improvement in the rule trace was suggested by Sramji\r
-      Ramanathan (ps@kumaran.com).\r
-\r
-#108. A Note on Deallocation of Variables Allocated in Guess Mode\r
-\r
-                            NOTE\r
-        ------------------------------------------------------\r
-        This mechanism only works for heap allocated variables\r
-        ------------------------------------------------------\r
-\r
-      The rewrite of the trace provides the machinery necessary\r
-      to properly free variables or undo actions following a\r
-      failed guess.\r
-\r
-      The macro zzUSER_GUESS_HOOK(guessSeq,zzrv) is expanded\r
-      as part of the zzGUESS macro.  When a guess is opened\r
-      the value of zzrv is 0.  When a longjmp() is executed to\r
-      undo the guess, the value of zzrv will be 1.\r
-\r
-      The macro zzUSER_GUESS_DONE_HOOK(guessSeq) is expanded\r
-      as part of the zzGUESS_DONE macro.  This is executed\r
-      whether the guess succeeds or fails as part of closing\r
-      the guess.\r
-\r
-      The guessSeq is a sequence number which is assigned to each\r
-      guess and is incremented by 1 for each guess which becomes\r
-      active.  It is needed by the user to associate the start of\r
-      a guess with the failure and/or completion (closing) of a\r
-      guess.\r
-\r
-      Guesses are nested.  They must be closed in the reverse\r
-      of the order that they are opened.\r
-\r
-      In order to free memory used by a variable during a guess\r
-      a user must write a routine which can be called to\r
-      register the variable along with the current guess sequence\r
-      number provided by the zzUSER_GUESS_HOOK macro. If the guess\r
-      fails, all variables tagged with the corresponding guess\r
-      sequence number should be released.  This is ugly, but\r
-      it would require a major rewrite of antlr 1.33 to use\r
-      some mechanism other than setjmp()/longjmp().\r
-\r
-      The order of calls for a *successful* guess would be:\r
-\r
-        zzUSER_GUESS_HOOK(guessSeq,0);\r
-        zzUSER_GUESS_DONE_HOOK(guessSeq);\r
-\r
-      The order of calls for a *failed* guess would be:\r
-\r
-        zzUSER_GUESS_HOOK(guessSeq,0);\r
-        zzUSER_GUESS_HOOK(guessSeq,1);\r
-        zzUSER_GUESS_DONE_HOOK(guessSeq);\r
-\r
-      The default definitions of these macros are empty strings.\r
-\r
-      Here is an example in C++ mode.  The zzUSER_GUESS_HOOK and\r
-      zzUSER_GUESS_DONE_HOOK macros and myGuessHook() routine\r
-      can be used without change in both C and C++ versions.\r
-\r
-      ----------------------------------------------------------------------\r
-        <<\r
-\r
-        #include "AToken.h"\r
-\r
-        typedef ANTLRCommonToken ANTLRToken;\r
-\r
-        #include "DLGLexer.h"\r
-\r
-        int main() {\r
-\r
-          {\r
-            DLGFileInput     in(stdin);\r
-            DLGLexer         lexer(&in,2000);\r
-            ANTLRTokenBuffer pipe(&lexer,1);\r
-            ANTLRCommonToken aToken;\r
-            P                parser(&pipe);\r
-\r
-            lexer.setToken(&aToken);\r
-            parser.init();\r
-            parser.start();\r
-          };\r
-\r
-          fclose(stdin);\r
-          fclose(stdout);\r
-          return 0;\r
-        }\r
-\r
-        >>\r
-\r
-        <<\r
-        char *s=NULL;\r
-\r
-        #undef zzUSER_GUESS_HOOK\r
-        #define zzUSER_GUESS_HOOK(guessSeq,zzrv) myGuessHook(guessSeq,zzrv);\r
-        #undef zzUSER_GUESS_DONE_HOOK\r
-        #define zzUSER_GUESS_DONE_HOOK(guessSeq)   myGuessHook(guessSeq,2);\r
-\r
-        void myGuessHook(int guessSeq,int zzrv) {\r
-          if (zzrv == 0) {\r
-            fprintf(stderr,"User hook: starting guess #%d\n",guessSeq);\r
-          } else if (zzrv == 1) {\r
-            free (s);\r
-            s=NULL;\r
-            fprintf(stderr,"User hook: failed guess #%d\n",guessSeq);\r
-          } else if (zzrv == 2) {\r
-            free (s);\r
-            s=NULL;\r
-            fprintf(stderr,"User hook: ending guess #%d\n",guessSeq);\r
-          };\r
-        }\r
-\r
-        >>\r
-\r
-        #token A    "a"\r
-        #token      "[\t \ \n]"     <<skip();>>\r
-\r
-        class P {\r
-\r
-        start : (top)+\r
-              ;\r
-\r
-        top   : (which) ?   <<fprintf(stderr,"%s is a which\n",s); free(s); s=NULL; >>\r
-              | other       <<fprintf(stderr,"%s is an other\n",s); free(s); s=NULL; >>\r
-              ; <<if (s != NULL) free(s); s=NULL; >>\r
-\r
-        which : which2\r
-              ;\r
-\r
-        which2 : which3\r
-              ;\r
-        which3\r
-              : (label)?         <<fprintf(stderr,"%s is a label\n",s);>>\r
-              | (global)?        <<fprintf(stderr,"%s is a global\n",s);>>\r
-              | (exclamation)?   <<fprintf(stderr,"%s is an exclamation\n",s);>>\r
-              ;\r
-\r
-        label :       <<s=strdup(LT(1)->getText());>> A ":" ;\r
-\r
-        global :      <<s=strdup(LT(1)->getText());>> A "::" ;\r
-\r
-        exclamation : <<s=strdup(LT(1)->getText());>> A "!" ;\r
-\r
-        other :       <<s=strdup(LT(1)->getText());>> "other" ;\r
-\r
-        }\r
-      ----------------------------------------------------------------------\r
-\r
-      This is a silly example, but illustrates the idea.  For the input\r
-      "a ::" with tracing enabled the output begins:\r
-\r
-      ----------------------------------------------------------------------\r
-        enter rule "start" depth 1\r
-        enter rule "top" depth 2\r
-        User hook: starting guess #1\r
-        enter rule "which" depth 3 guessing\r
-        enter rule "which2" depth 4 guessing\r
-        enter rule "which3" depth 5 guessing\r
-        User hook: starting guess #2\r
-        enter rule "label" depth 6 guessing\r
-        guess failed\r
-        User hook: failed guess #2\r
-        guess done - returning to rule "which3" at depth 5 (guess mode continues\r
-                                                 - an enclosing guess is still active)\r
-        User hook: ending guess #2\r
-        User hook: starting guess #3\r
-        enter rule "global" depth 6 guessing\r
-        exit rule "global" depth 6 guessing\r
-        guess done - returning to rule "which3" at depth 5 (guess mode continues\r
-                                                 - an enclosing guess is still active)\r
-        User hook: ending guess #3\r
-        enter rule "global" depth 6 guessing\r
-        exit rule "global" depth 6 guessing\r
-        exit rule "which3" depth 5 guessing\r
-        exit rule "which2" depth 4 guessing\r
-        exit rule "which" depth 3 guessing\r
-        guess done - returning to rule "top" at depth 2 (guess mode ends)\r
-        User hook: ending guess #1\r
-        enter rule "which" depth 3\r
-        .....\r
-      ----------------------------------------------------------------------\r
-\r
-      Remember:\r
-\r
-        (a) Only init-actions are executed during guess mode.\r
-        (b) A rule can be invoked multiple times during guess mode.\r
-        (c) If the guess succeeds the rule will be called once more\r
-              without guess mode so that normal actions will be executed.\r
-            This means that the init-action might need to distinguish\r
-              between guess mode and non-guess mode using the variable\r
-              [zz]guessing.\r
-\r
-#107. (Changed in 1.33MR10) construction of ASTs in guess mode\r
-\r
-      Prior to 1.33MR10, when using automatic AST construction in C++\r
-      mode for a rule, an AST would be constructed for elements of the\r
-      rule even while in guess mode.  In MR10 this no longer occurs.\r
-\r
-#106. (Changed in 1.33MR10) guess variable confusion\r
-\r
-      In C++ mode a guess which failed always restored the parser state\r
-      using zzGUESS_DONE as part of zzGUESS_FAIL. Prior to 1.33MR10,\r
-      C mode required an explicit call to zzGUESS_DONE after the\r
-      call to zzGUESS_FAIL.\r
-\r
-      Consider:\r
-\r
-        rule : (alpha)? beta\r
-             | ...\r
-             ;\r
-\r
-      The generated code resembles:\r
-\r
-            zzGUESS\r
-            if (!zzrv && LA(1)==ID) {   <==== line #1\r
-                alpha\r
-                zzGUESS_DONE\r
-                beta\r
-            } else {\r
-              if (! zzrv) zzGUESS_DONE  <==== line #2a\r
-              ....\r
-\r
-      However, in some cases line #2 was rendered:\r
-\r
-              if (guessing) zzGUESS_DONE  <==== line #2b\r
-\r
-      This would work for simple test cases, but would fail in\r
-      some cases where there was a guess while another guess was active.\r
-      One kind of failure would be to match up the zzGUESS_DONE at line\r
-      #2b with the "outer" guess which was still active.  The outer\r
-      guess would "succeed" when only the inner guess should have\r
-      succeeded.\r
-\r
-      In 1.33MR10 the behavior of zzGUESS and zzGUESS_FAIL in C and\r
-      and C++ mode should be identical.\r
-\r
-      The same problem appears in 1.33 vanilla in some places.  For\r
-      example:\r
-\r
-            start : { (sub)? } ;\r
-\r
-      or:\r
-\r
-            start : (\r
-                       B\r
-                    |  ( sub )?\r
-                    |  C\r
-                    )+\r
-                    ;\r
-\r
-      generates incorrect code.\r
-\r
-      The general principle is:\r
-\r
-        (a) use [zz]guessing only when deciding between a call to zzFAIL\r
-              or zzGUESS_FAIL\r
-\r
-        (b) use zzrv in all other cases\r
-\r
-      This problem was discovered while testing changes to item #105.\r
-      I believe this is now fixed.  My apologies.\r
-\r
-#105. (Changed in 1.33MR10) guess block as single alt of (...)+\r
-\r
-      Prior to 1.33MR10 the following constructs:\r
-\r
-        rule_plus : (\r
-                       (sub)?\r
-                    )+\r
-                    ;\r
-\r
-        rule_star : (\r
-                      (sub)?\r
-                    )*\r
-                    ;\r
-\r
-      generated incorrect code for the guess block (which could result\r
-      in runtime errors) because of an incorrect optimization of a\r
-      block with only a single alternative.\r
-\r
-      The fix caused some changes to the fix described in Item #49\r
-      because there are now three code generation sequences for (...)+\r
-      blocks containing a guess block:\r
-\r
-        a. single alternative which is a guess block\r
-        b. multiple alternatives in which the last is a guess block\r
-        c. all other cases\r
-\r
-      Forms like "rule_star" can have unexpected behavior when there\r
-      is a syntax error: if the subrule "sub" is not matched *exactly*\r
-      then "rule_star" will consume no tokens.\r
-\r
-      Reported by Esa Pulkkinen (esap@cs.tut.fi).\r
-\r
-#104. (Changed in 1.33MR10) -o option for dlg\r
-\r
-      There was problem with the code added by item #74 to handle the\r
-      -o option of dlg.  This should fix it.\r
-\r
-#103. (Changed in 1.33MR10) ANDed semantic predicates\r
-\r
-      Rescinded.\r
-\r
-      The optimization was a mistake.\r
-      The resulting problem is described in Item #150.\r
-\r
-#102. (Changed in 1.33MR10) allow "class parser : .... {"\r
-\r
-      The syntax of the class statement ("class parser-name {")\r
-      has been extended to allow for the specification of base\r
-      classes.  An arbirtrary number of tokens may now appear\r
-      between the class name and the "{".  They are output\r
-      again when the class declaration is generated.  For\r
-      example:\r
-\r
-        class Parser : public MyBaseClassANTLRparser {\r
-\r
-      This was suggested by a user, but I don't have a record\r
-      of who it was.\r
-\r
-#101. (Changed in 1.33MR10) antlr -info command line switch\r
-\r
-        -info\r
-\r
-            p   - extra predicate information in generated file\r
-\r
-            t   - information about tnode use:\r
-                    at the end of each rule in generated file\r
-                    summary on stderr at end of program\r
-\r
-            m   - monitor progress\r
-                    prints name of each rule as it is started\r
-                    flushes output at start of each rule\r
-\r
-            f   - first/follow set information to stdout\r
-\r
-            0   - no operation (added in 1.33MR11)\r
-\r
-      The options may be combined and may appear in any order.\r
-      For example:\r
-\r
-        antlr -info ptm -CC -gt -mrhoist on mygrammar.g\r
-\r
-#100a. (Changed in 1.33MR10) Predicate tree simplification\r
-\r
-      When the same predicates can be referenced in more than one\r
-      alternative of a block large predicate trees can be formed.\r
-\r
-      The difference that these optimizations make is so dramatic\r
-      that I have decided to use it even when -mrhoist is not selected.\r
-\r
-      Consider the following grammar:\r
-\r
-        start : ( all )* ;\r
-\r
-        all   : a\r
-              | d\r
-              | e\r
-              | f\r
-              ;\r
-\r
-        a     : c A B\r
-              | c A C\r
-              ;\r
-\r
-        c     : <<AAA(LATEXT(2))>>?\r
-              ;\r
-\r
-        d     : <<BBB(LATEXT(2))>>? B C\r
-              ;\r
-\r
-        e     : <<CCC(LATEXT(2))>>? B C\r
-              ;\r
-\r
-        f     : e X Y\r
-              ;\r
-\r
-      In rule "a" there is a reference to rule "c" in both alternatives.\r
-      The length of the predicate AAA is k=2 and it can be followed in\r
-      alternative 1 only by (A B) while in alternative 2 it can be\r
-      followed only by (A C).  Thus they do not have identical context.\r
-\r
-      In rule "all" the alternatives which refer to rules "e" and "f" allow\r
-      elimination of the duplicate reference to predicate CCC.\r
-\r
-      The table below summarized the kind of simplification performed by\r
-      1.33MR10.  In the table, X and Y stand for single predicates\r
-      (not trees).\r
-\r
-        (OR X (OR Y (OR Z)))  => (OR X Y Z)\r
-        (AND X (AND Y (AND Z)))  => (AND X Y Z)\r
-\r
-        (OR X  (... (OR  X Y) ... ))     => (OR X (... Y ... ))\r
-        (AND X (... (AND X Y) ... ))     => (AND X (... Y ... ))\r
-        (OR X  (... (AND X Y) ... ))     => (OR X (...  ... ))\r
-        (AND X (... (OR  X Y) ... ))     => (AND X (...  ... ))\r
-\r
-        (AND X)               => X\r
-        (OR X)                => X\r
-\r
-      In a test with a complex grammar for a real application, a predicate\r
-      tree with six OR nodes and 12 leaves was reduced to "(OR X Y Z)".\r
-\r
-      In 1.33MR10 there is a greater effort to release memory used\r
-      by predicates once they are no longer in use.\r
-\r
-#100b. (Changed in 1.33MR10) Suppression of extra predicate tests\r
-\r
-      The following optimizations require that -mrhoist be selected.\r
-\r
-      It is relatively easy to optimize the code generated for predicate\r
-      gates when they are of the form:\r
-\r
-            (AND X Y Z ...)\r
-        or  (OR  X Y Z ...)\r
-\r
-      where X, Y, Z, and "..." represent individual predicates (leaves) not\r
-      predicate trees.\r
-\r
-      If the predicate is an AND the contexts of the X, Y, Z, etc. are\r
-      ANDed together to create a single Tree context for the group and\r
-      context tests for the individual predicates are suppressed:\r
-\r
-            --------------------------------------------------\r
-            Note: This was incorrect.  The contexts should be\r
-            ORed together.  This has been fixed.  A more \r
-            complete description is available in item #152.\r
-            ---------------------------------------------------\r
-\r
-      Optimization 1:  (AND X Y Z ...)\r
-\r
-        Suppose the context for Xtest is LA(1)==LP and the context for\r
-        Ytest is LA(1)==LP && LA(2)==ID.\r
-\r
-            Without the optimization the code would resemble:\r
-\r
-                if (lookaheadContext &&\r
-                    !(LA(1)==LP && LA(1)==LP && LA(2)==ID) ||\r
-                        ( (! LA(1)==LP || Xtest) &&\r
-                          (! (LA(1)==LP || LA(2)==ID) || Xtest)\r
-                        )) {...\r
-\r
-            With the -mrhoist optimization the code would resemble:\r
-\r
-                if (lookaheadContext &&\r
-                    ! (LA(1)==LP && LA(2)==ID) || (Xtest && Ytest) {...\r
-\r
-      Optimization 2: (OR X Y Z ...) with identical contexts\r
-\r
-        Suppose the context for Xtest is LA(1)==ID and for Ytest\r
-        the context is also LA(1)==ID.\r
-\r
-            Without the optimization the code would resemble:\r
-\r
-                if (lookaheadContext &&\r
-                    ! (LA(1)==ID || LA(1)==ID) ||\r
-                        (LA(1)==ID && Xtest) ||\r
-                        (LA(1)==ID && Ytest) {...\r
-\r
-            With the -mrhoist optimization the code would resemble:\r
-\r
-                if (lookaheadContext &&\r
-                    (! LA(1)==ID) || (Xtest || Ytest) {...\r
-\r
-      Optimization 3: (OR X Y Z ...) with distinct contexts\r
-\r
-        Suppose the context for Xtest is LA(1)==ID and for Ytest\r
-        the context is LA(1)==LP.\r
-\r
-            Without the optimization the code would resemble:\r
-\r
-                if (lookaheadContext &&\r
-                    ! (LA(1)==ID || LA(1)==LP) ||\r
-                        (LA(1)==ID && Xtest) ||\r
-                        (LA(1)==LP && Ytest) {...\r
-\r
-            With the -mrhoist optimization the code would resemble:\r
-\r
-                if (lookaheadContext &&\r
-                        (zzpf=0,\r
-                            (LA(1)==ID && (zzpf=1) && Xtest) ||\r
-                            (LA(1)==LP && (zzpf=1) && Ytest) ||\r
-                            !zzpf) {\r
-\r
-            These may appear to be of similar complexity at first,\r
-            but the non-optimized version contains two tests of each\r
-            context while the optimized version contains only one\r
-            such test, as well as eliminating some of the inverted\r
-            logic (" !(...) || ").\r
-\r
-      Optimization 4: Computation of predicate gate trees\r
-\r
-        When generating code for the gates of predicate expressions\r
-        antlr 1.33 vanilla uses a recursive procedure to generate\r
-        "&&" and "||" expressions for testing the lookahead. As each\r
-        layer of the predicate tree is exposed a new set of "&&" and\r
-        "||" expressions on the lookahead are generated.  In many\r
-        cases the lookahead being tested has already been tested.\r
-\r
-        With -mrhoist a lookahead tree is computed for the entire\r
-        lookahead expression.  This means that predicates with identical\r
-        context or context which is a subset of another predicate's\r
-        context disappear.\r
-\r
-        This is especially important for predicates formed by rules\r
-        like the following:\r
-\r
-            uppperCaseVowel : <<isUpperCase(LATEXT(1))>>?  vowel;\r
-            vowel:          : <<isVowel(LATEXT(1))>>? LETTERS;\r
-\r
-        These predicates are combined using AND since both must be\r
-        satisfied for rule upperCaseVowel.  They have identical\r
-        context which makes this optimization very effective.\r
-\r
-      The affect of Items #100a and #100b together can be dramatic.  In\r
-      a very large (but real world) grammar one particular predicate\r
-      expression was reduced from an (unreadable) 50 predicate leaves,\r
-      195 LA(1) terms, and 5500 characters to an (easily comprehensible)\r
-      3 predicate leaves (all different) and a *single* LA(1) term.\r
-\r
-#99.  (Changed in 1.33MR10) Code generation for expression trees\r
-\r
-      Expression trees are used for k>1 grammars and predicates with\r
-      lookahead depth >1.  This optimization must be enabled using\r
-      "-mrhoist on".  (Clarification added for 1.33MR11).\r
-\r
-      In the processing of expression trees, antlr can generate long chains\r
-      of token comparisons.  Prior to 1.33MR10 there were many redundant\r
-      parenthesis which caused problems for compilers which could handle\r
-      expressions of only limited complexity.  For example, to test an\r
-      expression tree (root R A B C D), antlr would generate something\r
-      resembling:\r
-\r
-        (LA(1)==R && (LA(2)==A || (LA(2)==B || (LA(2)==C || LA(2)==D)))))\r
-\r
-      If there were twenty tokens to test then there would be twenty\r
-      parenthesis at the end of the expression.\r
-\r
-      In 1.33MR10 the generated code for tree expressions resembles:\r
-\r
-        (LA(1)==R && (LA(2)==A || LA(2)==B || LA(2)==C || LA(2)==D))\r
-\r
-      For "complex" expressions the output is indented to reflect the LA\r
-      number being tested:\r
-\r
-        (LA(1)==R\r
-            && (LA(2)==A || LA(2)==B || LA(2)==C || LA(2)==D\r
-               || LA(2)==E || LA(2)==F)\r
-        || LA(1)==S\r
-            && (LA(2)==G || LA(2)==H))\r
-\r
-\r
-      Suggested by S. Bochnak (S.Bochnak@@microTool.com.pl),\r
-\r
-#98.  (Changed in 1.33MR10) Option "-info p"\r
-\r
-      When the user selects option "-info p" the program will generate\r
-      detailed information about predicates.  If the user selects\r
-      "-mrhoist on" additional detail will be provided explaining\r
-      the promotion and suppression of predicates.  The output is part\r
-      of the generated file and sandwiched between #if 0/#endif statements.\r
-\r
-      Consider the following k=1 grammar:\r
-\r
-        start : ( all ) * ;\r
-\r
-        all   : ( a\r
-                | b\r
-                )\r
-                ;\r
-\r
-        a     : c B\r
-              ;\r
-\r
-        c     : <<LATEXT(1)>>?\r
-              | B\r
-              ;\r
-\r
-        b     : <<LATEXT(1)>>? X\r
-              ;\r
-\r
-      Below is an excerpt of the output for rule "start" for the three\r
-      predicate options (off, on, and maintenance release style hoisting).\r
-\r
-      For those who do not wish to use the "-mrhoist on" option for code\r
-      generation the option can be used in a "diagnostic" mode to provide\r
-      valuable information:\r
-\r
-            a. where one should insert null actions to inhibit hoisting\r
-            b. a chain of rule references which shows where predicates are\r
-               being hoisted\r
-\r
-      ======================================================================\r
-      Example of "-info p" with "-mrhoist on"\r
-      ======================================================================\r
-        #if 0\r
-\r
-        Hoisting of predicate suppressed by alternative without predicate.\r
-        The alt without the predicate includes all cases where the\r
-           predicate is false.\r
-\r
-           WITH predicate: line 11  v36.g\r
-           WITHOUT predicate: line 12  v36.g\r
-\r
-        The context set for the predicate:\r
-\r
-             B\r
-\r
-        The lookahead set for alt WITHOUT the semantic predicate:\r
-\r
-             B\r
-\r
-        The predicate:\r
-\r
-          pred <<  LATEXT(1)>>?  depth=k=1  rule c  line 11  v36.g\r
-\r
-            set context:\r
-               B\r
-            tree context: null\r
-\r
-        Chain of referenced rules:\r
-\r
-            #0  in rule start (line 1 v36.g) to rule all\r
-            #1  in rule all (line 3 v36.g) to rule a\r
-            #2  in rule a (line 8 v36.g) to rule c\r
-            #3  in rule c (line 11 v36.g)\r
-\r
-        #endif\r
-        &&\r
-        #if 0\r
-\r
-        pred <<  LATEXT(1)>>?  depth=k=1  rule b  line 15  v36.g\r
-\r
-          set context:\r
-             X\r
-          tree context: null\r
-\r
-        #endif\r
-      ======================================================================\r
-      Example of "-info p"  with the default -prc setting ( "-prc off")\r
-      ======================================================================\r
-        #if 0\r
-\r
-        OR\r
-          pred <<  LATEXT(1)>>?  depth=k=1  rule c  line 11  v36.g\r
-\r
-            set context:\r
-              nil\r
-            tree context: null\r
-\r
-          pred <<  LATEXT(1)>>?  depth=k=1  rule b  line 15  v36.g\r
-\r
-            set context:\r
-              nil\r
-            tree context: null\r
-\r
-        #endif\r
-      ======================================================================\r
-      Example of "-info p" with "-prc on" and "-mrhoist off"\r
-      ======================================================================\r
-        #if 0\r
-\r
-        OR\r
-          pred <<  LATEXT(1)>>?  depth=k=1  rule c  line 11  v36.g\r
-\r
-            set context:\r
-               B\r
-            tree context: null\r
-\r
-          pred <<  LATEXT(1)>>?  depth=k=1  rule b  line 15  v36.g\r
-\r
-            set context:\r
-               X\r
-            tree context: null\r
-\r
-        #endif\r
-      ======================================================================\r
-\r
-#97.  (Fixed in 1.33MR10) "Predicate applied for more than one ... "\r
-\r
-      In 1.33 vanilla, the grammar listed below produced this message for\r
-      the first alternative (only) of rule "b":\r
-\r
-            warning: predicate applied for >1 lookahead 1-sequences\r
-                [you may only want one lookahead 1-sequence to apply.\r
-                Try using a context guard '(...)? =>'\r
-\r
-      In 1.33MR10 the message is issued for both alternatives.\r
-\r
-          top     : (a)*;\r
-          a       : b | c ;\r
-\r
-          b       : <<PPP(LATEXT(1))>>? ( AAA | BBB )\r
-                  | <<QQQ(LATEXT(1))>>? ( XXX | YYY )\r
-                  ;\r
-\r
-          c       : AAA | XXX;\r
-\r
-#96.  (Fixed in 1.33MR10) Guard predicates ignored when -prc off\r
-\r
-      Prior to 1.33MR10, guard predicate code was not generated unless\r
-      "-prc on" was selected.\r
-\r
-      This was incorrect, since "-prc off"  (the default) is supposed to\r
-      disable only AUTOMATIC computation of predicate context, not the\r
-      programmer specified context supplied by guard predicates.\r
-\r
-#95.  (Fixed in 1.33MR10) Predicate guard context length was k, not max(k,ck)\r
-\r
-      Prior to 1.33MR10, predicate guards were computed to k tokens rather\r
-      than max(k,ck).  Consider the following grammar:\r
-\r
-        a     : ( A B C)? => <<AAA(LATEXT(1))>>? (A|X) (B|Y) (C|Z) ;\r
-\r
-      The code generated by 1.33 vanilla with "-k 1 -ck 3 -prc on"\r
-      for the predicate in "a" resembles:\r
-\r
-        if ( (! LA(1)==A) || AAA(LATEXT(1))) {...\r
-\r
-      With 1.33MR10 and the same options the code resembles:\r
-\r
-        if ( (! (LA(1)==A && LA(2)==B && LA(3)==C) || AAA(LATEXT(1))) {...\r
-\r
-#94.  (Fixed in 1.33MR10) Predicates followed by rule references\r
-\r
-      Prior to 1.33MR10, a semantic predicate which referenced a token\r
-      which was off the end of the rule caused an incomplete context\r
-      to be computed (with "-prc on") for the predicate under some circum-\r
-      stances.  In some cases this manifested itself as illegal C code\r
-      (e.g. "LA(2)==[Ep](1)" in the k=2 examples below:\r
-\r
-          all     : ( a ) *;\r
-\r
-          a       : <<AAA(LATEXT(2))>>? ID X\r
-                  | <<BBB(LATEXT(2))>>? Y\r
-                  | Z\r
-                  ;\r
-\r
-      This might also occur when the semantic predicate was followed\r
-      by a rule reference which was shorter than the length of the\r
-      semantic predicate:\r
-\r
-        all       : ( a ) *;\r
-\r
-        a         : <<AAA(LATEXT(2))>>? ID X\r
-                  | <<BBB(LATEXT(2))>>? y\r
-                  | Z\r
-                  ;\r
-\r
-        y         : Y ;\r
-\r
-      Depending on circumstance, the resulting context might be too\r
-      generous because it was too short, or too restrictive because\r
-      of missing alternatives.\r
-\r
-#93.  (Changed in 1.33MR10) Definition of Purify macro\r
-\r
-      Ofer Ben-Ami (gremlin@cs.huji.ac.il) has supplied a definition\r
-      for the Purify macro:\r
-\r
-        #define PURIFY(r, s) memset((char *) &(r), '\0', (s));\r
-\r
-      Note: This may not be the right thing to do for C++ objects that\r
-      have constructors.  Reported by Bonny Rais (bonny@werple.net.au).\r
-\r
-      For those cases one should #define PURIFY to an empty macro in the\r
-      #header or #first actions.\r
-\r
-#92.  (Fixed in 1.33MR10) Guarded predicates and hoisting\r
-\r
-      When a guarded predicate participates in hoisting it is linked into\r
-      a predicate expression tree.  Prior to 1.33MR10 this link was never\r
-      cleared and the next time the guard was used to construct a new\r
-      tree the link could contain a spurious reference to another element\r
-      which had previosly been joined to it in the semantic predicate tree.\r
-\r
-      For example:\r
-\r
-        start  : ( all ) *;\r
-        all    : ( a | b ) ;\r
-\r
-        start2 : ( all2 ) *;\r
-        all2    : ( a ) ;\r
-\r
-        a     : (A)? => <<AAA(LATEXT(1))>>?  A ;\r
-        b     : (B)? => <<BBB(LATEXT(1))>>?  B ;\r
-\r
-      Prior to 1.33MR10 the code for "start2" would include a spurious\r
-      reference to the BBB predicate which was left from constructing\r
-      the predicate tree for rule "start" (i.e. or(AAA,BBB) ).\r
-\r
-      In 1.33MR10 this problem is avoided by cloning the original guard\r
-      each time it is linked into a predicate tree.\r
-\r
-#91.  (Changed in 1.33MR10) Extensive changes to semantic pred hoisting\r
-\r
-            ============================================\r
-            This has been rendered obsolete by Item #117\r
-            ============================================\r
-\r
-#90.  (Fixed in 1.33MR10) Semantic pred with LT(i) and i>max(k,ck)\r
-\r
-      There is a bug in antlr 1.33 vanilla and all maintenance releases\r
-      prior to 1.33MR10 which allows semantic predicates to reference\r
-      an LT(i) or LATEXT(i) where i is larger than max(k,ck).  When\r
-      this occurs antlr will attempt to mark the ith element of an array\r
-      in which there are only max(k,ck) elements.  The result cannot\r
-      be predicted.\r
-\r
-      Using LT(i) or LATEXT(i) for i>max(k,ck) is reported as an error\r
-      in 1.33MR10.\r
-\r
-#89.  Rescinded\r
-\r
-#88.  (Fixed in 1.33MR10) Tokens used in semantic predicates in guess mode\r
-\r
-        Consider the behavior of a semantic predicate during guess mode:\r
-\r
-            rule : a:A (\r
-                         <<test($a)>>? b:B\r
-                         | c:C\r
-                       );\r
-\r
-        Prior to MR10 the assignment of the token or attribute to\r
-        $a did not occur during guess mode, which would cause the\r
-        semantic predicate to misbehave because $a would be null.\r
-\r
-        In 1.33MR10 a semantic predicate with a reference to an\r
-        element label (such as $a) forces the assignment to take\r
-        place even in guess mode.\r
-\r
-        In order to work, this fix REQUIRES use of the $label format\r
-        for token pointers and attributes referenced in semantic\r
-        predicates.\r
-\r
-        The fix does not apply to semantic predicates using the\r
-        numeric form to refer to attributes (e.g. <<test($1)>>?).\r
-        The user will receive a warning for this case.\r
-\r
-        Reported by Rob Trout (trout@mcs.cs.kent.edu).\r
-\r
-#87.  (Fixed in 1.33MR10) Malformed guard predicates\r
-\r
-      Context guard predicates may contain only references to\r
-      tokens.  They may not contain references to (...)+ and\r
-      (...)* blocks.  This is now checked.  This replaces the\r
-      fatal error message in item #78 with an appropriate\r
-      (non-fatal) error messge.\r
-\r
-      In theory, context guards should be allowed to reference\r
-      rules.  However, I have not had time to fix this.\r
-      Evaluation of the guard takes place before all rules have\r
-      been read, making it difficult to resolve a forward reference\r
-      to rule "zzz" - it hasn't been read yet !  To postpone evaluation\r
-      of the guard until all rules have been read is too much\r
-      for the moment.\r
-\r
-#86.  (Fixed in 1.33MR10) Unequal set size in set_sub\r
-\r
-      Routine set_sub() in pccts/support/set/set.h  did not work\r
-      correctly when the sets were of unequal sizes.  Rewrote\r
-      set_equ to make it simpler and remove unnecessary and\r
-      expensive calls to set_deg().  This routine was not used\r
-      in 1.33 vanila.\r
-\r
-#85.  (Changed in 1.33MR10) Allow redefinition of MaxNumFiles\r
-\r
-      Raised the maximum number of input files to 99 from 20.\r
-      Put a #ifndef/#endif around the "#define MaxNumFiles 99".\r
-\r
-#84.  (Fixed in 1.33MR10) Initialize zzBadTok in macro zzRULE\r
-\r
-      Initialize zzBadTok to NULL in zzRULE macro of AParser.h.\r
-      in order to get rid of warning messages.\r
-\r
-#83.  (Fixed in 1.33MR10) False warnings with -w2 for #tokclass\r
-\r
-      When -w2 is selected antlr gives inappropriate warnings about\r
-      #tokclass names not having any associated regular expressions.\r
-      Since a #tokclass is not a "real" token it will never have an\r
-      associated regular expression and there should be no warning.\r
-\r
-      Reported by Derek Pappas (derek.pappas@eng.sun.com)\r
-\r
-#82.  (Fixed in 1.33MR10) Computation of follow sets with multiple cycles\r
-\r
-      Reinier van den Born (reinier@vnet.ibm.com) reported a problem\r
-      in the computation of follow sets by antlr.  The problem (bug)\r
-      exists in 1.33 vanilla and all maintenance releases prior to 1.33MR10.\r
-\r
-      The problem involves the computation of follow sets when there are\r
-      cycles - rules which have mutual references.  I believe the problem\r
-      is restricted to cases where there is  more than one cycle AND\r
-      elements of those cycles have rules in common.  Even when this\r
-      occurs it may not affect the code generated - but it might.  It\r
-      might also lead to undetected ambiguities.\r
-\r
-      There were no changes in antlr or dlg output from the revised version.\r
-\r
-      The following fragment demonstates the problem by giving different\r
-      follow sets (option -pa) for var_access when built with k=1 and ck=2 on\r
-      1.33 vanilla and 1.33MR10:\r
-\r
-        echo_statement : ECHO ( echo_expr )*\r
-                       ;\r
-\r
-        echo_expr      : ( command )?\r
-                       | expression\r
-                       ;\r
-\r
-        command        : IDENTIFIER\r
-                             { concat }\r
-                       ;\r
-\r
-        expression     : operand ( OPERATOR operand )*\r
-                       ;\r
-\r
-        operand        : value\r
-                       | START command END\r
-                       ;\r
-\r
-        value          : concat\r
-                       | TYPE operand\r
-                       ;\r
-\r
-        concat         : var_access { CONCAT value }\r
-                       ;\r
-\r
-        var_access     : IDENTIFIER { INDEX }\r
-\r
-                       ;\r
-#81.  (Changed in 1.33MR10) C mode use of attributes and ASTs\r
-\r
-       Reported by Isaac Clark (irclark@mindspring.com).\r
-\r
-       C mode code ignores attributes returned by rules which are\r
-       referenced using element labels when ASTs are enabled (-gt option).\r
-\r
-         1. start : r:rule t:Token <<$start=$r;>>\r
-\r
-                The $r refrence will not work when combined with\r
-                the -gt option.\r
-\r
-         2. start : t:Token         <<$start=$t;>>\r
-\r
-                The $t reference works in all cases.\r
-\r
-         3. start : rule            <<$0=$1;>>\r
-\r
-                Numeric labels work in all cases.\r
-\r
-       With MR10 the user will receive an error message for case 1 when\r
-       the -gt option is used.\r
-\r
-#80.  (Fixed in 1.33MR10) (...)? as last alternative of block\r
-\r
-        A construct like the following:\r
-\r
-            rule : a\r
-                 | (b)?\r
-                 ;\r
-\r
-        does not make sense because there is no alternative when\r
-        the guess block fails.  This is now reported as a warning\r
-        to the user.\r
-\r
-        Previously, there was a code generation error for this case:\r
-        the guess block was not "closed"  when the guess failed.\r
-        This could cause an infinite loop or other problems.  This\r
-        is now fixed.\r
-\r
-        Example problem:\r
-\r
-            #header<<\r
-            #include <stdio.h>\r
-            #include "charptr.h"\r
-            >>\r
-\r
-            <<\r
-            #include "charptr.c"\r
-            main ()\r
-            {\r
-             ANTLR(start(),stdin);\r
-            }\r
-            >>\r
-\r
-            #token "[\ \t]+"        << zzskip(); >>\r
-            #token "[\n]"           << zzline++; zzskip(); >>\r
-\r
-            #token Word     "[a-z]+"\r
-            #token Number   "[0-9]+"\r
-\r
-\r
-            start : (test1)?\r
-                  | (test2)?\r
-                  ;\r
-            test1 : (Word Word Word Word)?\r
-                  | (Word Word Word Number)?\r
-                  ;\r
-            test2 : (Word Word Number Word)?\r
-                  | (Word Word Number Number)?\r
-            ;\r
-\r
-        Test data which caused infinite loop:\r
-\r
-            a 1 a a\r
-\r
-#79.  (Changed in 1.33MR10) Use of -fh with multiple parsers\r
-\r
-        Previously, antlr always used the pre-processor symbol\r
-        STDPCCTS_H as a gate for the file stdpccts.h.  This\r
-        caused problems when there were multiple parsers defined\r
-        because they used the same gate symbol.\r
-\r
-        In 1.33MR10, the -fh filename is used to generate the\r
-        gate file for stdpccts.h.  For instance:\r
-\r
-            antlr -fh std_parser1.h\r
-\r
-        generates the pre-processor symbol "STDPCCTS_std_parser1_H".\r
-\r
-        Reported by Ramanathan Santhanam (ps@kumaran.com).\r
-\r
-#78.  (Changed in 1.33MR9) Guard predicates that refer to rules\r
-\r
-                ------------------------\r
-                Please refer to Item #87\r
-                ------------------------\r
-\r
-        Guard predicates are processed during an early phase\r
-        of antlr (during parsing) before all data structures\r
-        are completed.\r
-\r
-        There is an apparent bug in earlier versions of 1.33\r
-        which caused guard predicates which contained references\r
-        to rules (rather than tokens) to reference a structure\r
-        which hadn't yet been initialized.\r
-\r
-        In some cases (perhaps all cases) references to rules\r
-        in guard predicates resulted in the use of "garbage".\r
-\r
-#79.  (Changed in 1.33MR9) Jeff Vincent (JVincent@novell.com)\r
-\r
-        Previously, the maximum length file name was set\r
-        arbitrarily to 300 characters in antlr, dlg, and sorcerer.\r
-\r
-        The config.h file now attempts to define the maximum length\r
-        filename using _MAX_PATH from stdlib.h before falling back\r
-        to using the value 300.\r
-\r
-#78.  (Changed in 1.33MR9) Jeff Vincent (JVincent@novell.com)\r
-\r
-        Put #ifndef/#endif around definition of ZZLEXBUFSIZE in\r
-        antlr.\r
-\r
-#77.  (Changed in 1.33MR9) Arithmetic overflow for very large grammars\r
-\r
-        In routine HandleAmbiguities() antlr attempts to compute the\r
-        number of possible elements in a set that is order of\r
-        number-of-tokens raised to the number-of-lookahead-tokens power.\r
-        For large grammars or large lookahead (e.g. -ck 7) this can\r
-        cause arithmetic overflow.\r
-\r
-        With 1.33MR9, arithmetic overflow in this computation is reported\r
-        the first time it happens.  The program continues to run and\r
-        the program branches based on the assumption that the computed\r
-        value is larger than any number computed by counting actual cases\r
-        because 2**31 is larger than the number of bits in most computers.\r
-\r
-        Before 1.33MR9 overflow was not reported.  The behavior following\r
-        overflow is not predictable by anyone but the original author.\r
-\r
-                            NOTE\r
-\r
-            In 1.33MR10 the warning message is suppressed.\r
-            The code which detects the overflow allows the\r
-            computation to continue without an error.  The\r
-            error message itself made made users worry.\r
-\r
-#76.  (Changed in 1.33MR9) Jeff Vincent (JVincent@novell.com)\r
-\r
-        Jeff Vincent has convinced me to make ANTLRCommonToken and\r
-        ANTLRCommonNoRefCountToken use variable length strings\r
-        allocated from the heap rather than fixed length strings.\r
-        By suitable definition of setText(), the copy constructor,\r
-        and operator =() it is possible to maintain "copy" semantics.\r
-        By "copy" semantics I mean that when a token is copied from\r
-        an existing token it receives its own, distinct, copy of the\r
-        text allocated from the heap rather than simply a pointer\r
-        to the original token's text.\r
-\r
-        ============================================================\r
-                        W * A * R * N * I * N * G\r
-        ============================================================\r
-\r
-        It is possible that this may cause problems for some users.\r
-        For those users I have included the old version of AToken.h as\r
-        pccts/h/AToken_traditional.h.\r
-\r
-#75.  (Changed in 1.33MR9) Bruce Guenter (bruceg@qcc.sk.ca)\r
-\r
-        Make DLGStringInput const correct.  Since this is infrequently\r
-        subclassed, it should affect few users, I hope.\r
-\r
-#74.  (Changed in 1.33MR9) -o (output directory) option\r
-\r
-        Antlr does not properly handle the -o output directory option\r
-        when the filename of the grammar contains a directory part.  For\r
-        example:\r
-\r
-            antlr -o outdir pccts_src/myfile.g\r
-\r
-        causes antlr create a file called "outdir/pccts_src/myfile.cpp.\r
-        It SHOULD create outdir/myfile.cpp\r
-\r
-        The suggested code fix has been installed in antlr, dlg, and\r
-        Sorcerer.\r
-\r
-#73.  (Changed in 1.33MR9) Hoisting of semantic predicates and -mrhoist\r
-\r
-            ============================================\r
-            This has been rendered obsolete by Item #117\r
-            ============================================\r
-\r
-#72.  (Changed in 1.33MR9) virtual saveState()/restoreState()/guess_XXX\r
-\r
-        The following methods in ANTLRParser were made virtual at\r
-        the request of S. Bochnak (S.Bochnak@microTool.com.pl):\r
-\r
-            saveState() and restoreState()\r
-            guess(), guess_fail(), and guess_done()\r
-\r
-#71.  (Changed in 1.33MR9) Access to omitted command line argument\r
-\r
-        If a switch requiring arguments is the last thing on the\r
-        command line, and the argument is omitted, antlr would core.\r
-\r
-            antlr test.g -prc\r
-\r
-        instead of\r
-\r
-            antlr test.g -prc off\r
-\r
-#70.  (Changed in 1.33MR9) Addition of MSVC .dsp and .mak build files\r
-\r
-        The following MSVC .dsp and .mak files for pccts and sorcerer\r
-        were contributed by Stanislaw Bochnak (S.Bochnak@microTool.com.pl)\r
-        and Jeff Vincent (JVincent@novell.com)\r
-\r
-        PCCTS Distribution Kit\r
-        ----------------------\r
-        pccts/PCCTSMSVC50.dsw\r
-\r
-        pccts/antlr/AntlrMSVC50.dsp\r
-        pccts/antlr/AntlrMSVC50.mak\r
-\r
-        pccts/dlg/DlgMSVC50.dsp\r
-        pccts/dlg/DlgMSVC50.mak\r
-\r
-        pccts/support/msvc.dsp\r
-\r
-        Sorcerer Distribution Kit\r
-        -------------------------\r
-        pccts/sorcerer/SorcererMSVC50.dsp\r
-        pccts/sorcerer/SorcererMSVC50.mak\r
-\r
-        pccts/sorcerer/lib/msvc.dsp\r
-\r
-#69.  (Changed in 1.33MR9) Change "unsigned int" to plain "int"\r
-\r
-       Declaration of max_token_num in misc.c as "unsigned int"\r
-       caused comparison between signed and unsigned ints giving\r
-       warning message without any special benefit.\r
-\r
-#68.  (Changed in 1.33MR9) Add void return for dlg internal_error()\r
-\r
-       Get rid of "no return value" message in internal_error()\r
-       in file dlg/support.c and dlg/dlg.h.\r
-\r
-#67.  (Changed in Sor) sor.g: lisp() has no return value\r
-\r
-       Added a "void" for the return type.\r
-\r
-#66.  (Added to Sor) sor.g: ZZLEXBUFSIZE enclosed in #ifndef/#endif\r
-\r
-       A user needed to be able to change the ZZLEXBUFSIZE for\r
-       sor. Put the definition of ZZLEXBUFSIZE inside #ifndef/#endif\r
-\r
-#65.  (Changed in 1.33MR9) PCCTSAST::deepCopy() and ast_dup() bug\r
-\r
-       Jeff Vincent (JVincent@novell.com) found that deepCopy()\r
-       made new copies of only the direct descendents.  No new\r
-       copies were made of sibling nodes,  Sibling pointers are\r
-       set to zero by shallowCopy().\r
-\r
-           PCCTS_AST::deepCopy() has been changed to make a\r
-           deep copy in the traditional sense.\r
-\r
-           The deepCopy() routine depends on the behavior of\r
-           shallowCopy().  In all sor examples I've found,\r
-           shallowCopy() zeroes the right and down pointers.\r
-\r
-       Original Tree       Original deepCopy()     Revised deepCopy\r
-       -------------       -------------------     ----------------\r
-            a->b->c         A                       A\r
-            |               |                       |\r
-            d->e->f         D                       D->E->F\r
-            |               |                       |\r
-            g->h->i         G                       G->H->I\r
-               |                                       |\r
-               j->k                                    J->K\r
-\r
-        While comparing deepCopy() for C++ mode with ast_dup for\r
-        C mode I found a problem with ast_dup().\r
-\r
-           Routine ast_dup() has been changed to make a deep copy\r
-           in the traditional sense.\r
-\r
-       Original Tree       Original ast_dup()      Revised ast_dup()\r
-       -------------       -------------------     ----------------\r
-            a->b->c         A->B->C                 A\r
-            |               |                       |\r
-            d->e->f         D->E->F                 D->E->F\r
-            |               |                       |\r
-            g->h->i         G->H->I                 G->H->I\r
-               |               |                       |\r
-               j->k            J->K                    J->K\r
-\r
-\r
-        I believe this affects transform mode sorcerer programs only.\r
-\r
-#64.  (Changed in 1.33MR9) anltr/hash.h prototype for killHashTable()\r
-\r
-#63.  (Changed in 1.33MR8) h/charptr.h does not zero pointer after free\r
-\r
-        The charptr.h routine now zeroes the pointer after free().\r
-\r
-        Reported by Jens Tingleff (jensting@imaginet.fr)\r
-\r
-#62.  (Changed in 1.33MR8) ANTLRParser::resynch had static variable\r
-\r
-        The static variable "consumed" in ANTLRParser::resynch was\r
-        changed into an instance variable of the class with the\r
-        name "resynchConsumed".\r
-\r
-        Reported by S.Bochnak@microTool.com.pl\r
-\r
-#61.  (Changed in 1.33MR8) Using rule>[i,j] when rule has no return values\r
-\r
-        Previously, the following code would cause antlr to core when\r
-        it tried to generate code for rule1 because rule2 had no return\r
-        values ("upward inheritance"):\r
-\r
-            rule1 : <<int i; int j>>\r
-                    rule2 > [i,j]\r
-                  ;\r
-\r
-            rule2 : Anything ;\r
-\r
-        Reported by S.Bochnak@microTool.com.pl\r
-\r
-        Verified correct operation of antlr MR8 when missing or extra\r
-        inheritance arguments for all combinations.  When there are\r
-        missing or extra arguments code will still be generated even\r
-        though this might cause the invocation of a subroutine with\r
-        the wrong number of arguments.\r
-\r
-#60.  (Changed in 1.33MR7) Major changes to exception handling\r
-\r
-        There were significant problems in the handling of exceptions\r
-        in 1.33 vanilla.  The general problem is that it can only\r
-        process one level of exception handler.  For example, a named\r
-        exception handler, an exception handler for an alternative, or\r
-        an exception for a subrule  always went to the rule's exception\r
-        handler if there was no "catch" which matched the exception.\r
-\r
-        In 1.33MR7 the exception handlers properly "nest".  If an\r
-        exception handler does not have a matching "catch" then the\r
-        nextmost outer exception handler is checked for an appropriate\r
-        "catch" clause, and so on until an exception handler with an\r
-        appropriate "catch" is found.\r
-\r
-        There are still undesirable features in the way exception\r
-        handlers are implemented, but I do not have time to fix them\r
-        at the moment:\r
-\r
-            The exception handlers for alternatives are outside the\r
-            block containing the alternative.  This makes it impossible\r
-            to access variables declared in a block or to resume the\r
-            parse by "falling through".  The parse can still be easily\r
-            resumed in other ways, but not in the most natural fashion.\r
-\r
-            This results in an inconsistentcy between named exception\r
-            handlers and exception handlers for alternatives.  When\r
-            an exception handler for an alternative "falls through"\r
-            it goes to the nextmost outer handler - not the "normal\r
-            action".\r
-\r
-        A major difference between 1.33MR7 and 1.33 vanilla is\r
-        the default action after an exception is caught:\r
-\r
-            1.33 Vanilla\r
-            ------------\r
-            In 1.33 vanilla the signal value is set to zero ("NoSignal")\r
-            and the code drops through to the code following the exception.\r
-            For named exception handlers this is the "normal action".\r
-            For alternative exception handlers this is the rule's handler.\r
-\r
-            1.33MR7\r
-            -------\r
-            In 1.33MR7 the signal value is NOT automatically set to zero.\r
-\r
-            There are two cases:\r
-\r
-                For named exception handlers: if the signal value has been\r
-                set to zero the code drops through to the "normal action".\r
-\r
-                For all other cases the code branches to the nextmost outer\r
-                exception handler until it reaches the handler for the rule.\r
-\r
-        The following macros have been defined for convenience:\r
-\r
-            C/C++ Mode Name\r
-            --------------------\r
-            (zz)suppressSignal\r
-                  set signal & return signal arg to 0 ("NoSignal")\r
-            (zz)setSignal(intValue)\r
-                  set signal & return signal arg to some value\r
-            (zz)exportSignal\r
-                  copy the signal value to the return signal arg\r
-\r
-        I'm not sure why PCCTS make a distinction between the local\r
-        signal value and the return signal argument, but I'm loathe\r
-        to change the code. The burden of copying the local signal\r
-        value to the return signal argument can be given to the\r
-        default signal handler, I suppose.\r
-\r
-#59.  (Changed in 1.33MR7) Prototypes for some functions\r
-\r
-        Added prototypes for the following functions to antlr.h\r
-\r
-            zzconsumeUntil()\r
-            zzconsumeUntilToken()\r
-\r
-#58.  (Changed in 1.33MR7) Added defintion of zzbufsize to dlgauto.h\r
-\r
-#57.  (Changed in 1.33MR7) Format of #line directive\r
-\r
-        Previously, the -gl directive for line 1234 would\r
-        resemble:  "# 1234 filename.g".  This caused problems\r
-        for some compilers/pre-processors.  In MR7 it generates\r
-        "#line 1234 filename.g".\r
-\r
-#56.  (Added in 1.33MR7) Jan Mikkelsen <janm@zeta.org.au>\r
-\r
-        Move PURIFY macro invocaton to after rule's init action.\r
-\r
-#55.  (Fixed in 1.33MR7) Unitialized variables in ANTLRParser\r
-\r
-        Member variables inf_labase and inf_last were not initialized.\r
-        (See item #50.)\r
-\r
-#54.  (Fixed in 1.33MR6) Brad Schick (schick@interacess.com)\r
-\r
-        Previously, the following constructs generated the same\r
-        code:\r
-\r
-        rule1 : (A B C)?\r
-              | something-else\r
-              ;\r
-\r
-        rule2 : (A B C)? ()\r
-              | something-else\r
-              ;\r
-\r
-        In all versions of pccts rule1 guesses (A B C) and then\r
-        consume all three tokens if the guess succeeds.  In MR6\r
-        rule2 guesses (A B C)  but consumes NONE of the tokens\r
-        when the guess succeeds because "()" matches epsilon.\r
-\r
-#53.  (Explanation for 1.33MR6) What happens after an exception is caught ?\r
-\r
-        The Book is silent about what happens after an exception\r
-        is caught.\r
-\r
-        The following code fragment prints "Error Action" followed\r
-        by "Normal Action".\r
-\r
-        test : Word ex:Number <<printf("Normal Action\n");>>\r
-                exception[ex]\r
-                   catch NoViableAlt:\r
-                        <<printf("Error Action\n");>>\r
-        ;\r
-\r
-        The reason for "Normal Action" is that the normal flow of the\r
-        program after a user-written exception handler is to "drop through".\r
-        In the case of an exception handler for a rule this results in\r
-        the exection of a "return" statement.  In the case of an\r
-        exception handler attached to an alternative, rule, or token\r
-        this is the code that would have executed had there been no\r
-        exception.\r
-\r
-        The user can achieve the desired result by using a "return"\r
-        statement.\r
-\r
-        test : Word ex:Number <<printf("Normal Action\n");>>\r
-                exception[ex]\r
-                   catch NoViableAlt:\r
-                        <<printf("Error Action\n"); return;>>\r
-        ;\r
-\r
-        The most powerful mechanism for recovery from parse errors\r
-        in pccts is syntactic predicates because they provide\r
-        backtracking.  Exceptions allow "return", "break",\r
-        "consumeUntil(...)", "goto _handler", "goto _fail", and\r
-        changing the _signal value.\r
-\r
-#52.  (Fixed in 1.33MR6) Exceptions without syntactic predicates\r
-\r
-        The following generates bad code in 1.33 if no syntactic\r
-        predicates are present in the grammar.\r
-\r
-        test : Word ex:Number <<printf("Normal Action\n");>>\r
-                exception[ex]\r
-                   catch NoViableAlt:\r
-                        <<printf("Error Action\n");>>\r
-\r
-        There is a reference to a guess variable.  In C mode\r
-        this causes a compiler error.  In C++ mode it generates\r
-        an extraneous check on member "guessing".\r
-\r
-        In MR6 correct code is generated for both C and C++ mode.\r
-\r
-#51.  (Added to 1.33MR6) Exception operator "@" used without exceptions\r
-\r
-        In MR6 added a warning when the exception operator "@" is\r
-        used and no exception group is defined.  This is probably\r
-        a case where "\@" or "@" is meant.\r
-\r
-#50.  (Fixed in 1.33MR6) Gunnar Rxnning (gunnar@candleweb.no)\r
-                                    http://www.candleweb.no/~gunnar/\r
-\r
-        Routines zzsave_antlr_state and zzrestore_antlr_state don't\r
-        save and restore all the data needed when switching states.\r
-\r
-        Suggested patch applied to antlr.h and err.h for MR6.\r
-\r
-#49.  (Fixed in 1.33MR6) Sinan Karasu (sinan@boeing.com)\r
-\r
-        Generated code failed to turn off guess mode when leaving a\r
-        (...)+ block which contained a guess block.  The result was\r
-        an infinite loop.  For example:\r
-\r
-                rule : (\r
-                         (x)?\r
-                         | y\r
-                       )+\r
-\r
-        Suggested code fix implemented in MR6.  Replaced\r
-\r
-            ... else if (zzcnt>1) break;\r
-\r
-        with:\r
-\r
-          C++ mode:\r
-              ... else if (zzcnt>1) {if (!zzrv) zzGUESS_DONE; break;};\r
-          C mode:\r
-              ... else if (zzcnt>1) {if (zzguessing) zzGUESS_DONE; break;};\r
-\r
-#48.  (Fixed in 1.33MR6) Invalid exception element causes core\r
-\r
-        A label attached to an invalid construct can cause\r
-        pccts to crash while processing the exception associated\r
-        with the label.  For example:\r
-\r
-        rule : t:(B C)\r
-                exception[t] catch MismatchedToken: <<printf(...);>>\r
-\r
-        Version MR6 generates the message:\r
-\r
-           reference in exception handler to undefined label 't'\r
-\r
-#47.  (Fixed in 1.33MR6) Manuel Ornato\r
-\r
-        Under some circumstances involving a k >1 or ck >1\r
-        grammar and a loop block (i.e.  (...)* ) pccts will\r
-        fail to detect a syntax error and loop indefinitely.\r
-        The problem did not exist in 1.20, but has existed\r
-        from 1.23 to the present.\r
-\r
-        Fixed in MR6.\r
-\r
-        ---------------------------------------------------\r
-        Complete test program\r
-        ---------------------------------------------------\r
-        #header<<\r
-        #include <stdio.h>\r
-        #include "charptr.h"\r
-        >>\r
-\r
-        <<\r
-        #include "charptr.c"\r
-        main ()\r
-        {\r
-         ANTLR(global(),stdin);\r
-        }\r
-        >>\r
-\r
-        #token "[\ \t]+"        << zzskip(); >>\r
-        #token "[\n]"           << zzline++; zzskip(); >>\r
-\r
-        #token B        "b"\r
-        #token C        "c"\r
-        #token D        "d"\r
-        #token E        "e"\r
-        #token LP       "\("\r
-        #token RP       "\)"\r
-\r
-        #token ANTLREOF "@"\r
-\r
-        global : (\r
-                   (E liste)\r
-                 | liste\r
-                 | listed\r
-                 )  ANTLREOF\r
-        ;\r
-\r
-        listeb : LP ( B ( B | C )* ) RP ;\r
-        listec : LP ( C ( B | C )* ) RP ;\r
-        listed : LP ( D ( B | C )* ) RP ;\r
-        liste : ( listeb | listec )* ;\r
-\r
-        ---------------------------------------------------\r
-        Sample data causing infinite loop\r
-        ---------------------------------------------------\r
-        e (d c)\r
-        ---------------------------------------------------\r
-\r
-#46.  (Fixed in 1.33MR6) Robert Richter\r
-                (Robert.Richter@infotech.tu-chemnitz.de)\r
-\r
-        This item from the list of known problems was\r
-        fixed by item #18 (below).\r
-\r
-#45.  (Fixed in 1.33MR6) Brad Schick (schick@interaccess.com)\r
-\r
-        The dependency scanner in VC++ mistakenly sees a\r
-        reference to an MPW #include file even though properly\r
-        #ifdef/#endif in config.h.  The suggested workaround\r
-        has been implemented:\r
-\r
-                #ifdef MPW\r
-                .....\r
-                #define MPW_CursorCtl_Header <CursorCtl.h>\r
-                #include MPW_CursorCtl_Header\r
-                .....\r
-                #endif\r
-\r
-#44.  (Fixed in 1.33MR6) cast malloc() to (char *) in charptr.c\r
-\r
-        Added (char *) cast for systems where malloc returns "void *".\r
-\r
-#43.  (Added to 1.33MR6) Bruce Guenter (bruceg@qcc.sk.ca)\r
-\r
-        Add setLeft() and setUp methods to ASTDoublyLinkedBase\r
-        for symmetry with setRight() and setDown() methods.\r
-\r
-#42.  (Fixed in 1.33MR6) Jeff Katcher (jkatcher@nortel.ca)\r
-\r
-        C++ style comment in antlr.c corrected.\r
-\r
-#41.  (Added in 1.33MR6) antlr -stdout\r
-\r
-        Using "antlr -stdout ..." forces the text that would\r
-        normally go to the grammar.c or grammar.cpp file to\r
-        stdout.\r
-\r
-#40.  (Added in 1.33MR6) antlr -tab to change tab stops\r
-\r
-        Using "antlr -tab number ..." changes the tab stops\r
-        for the grammar.c or grammar.cpp file.  The number\r
-        must be between 0 and 8.  Using 0 gives tab characters,\r
-        values between 1 and 8 give the appropriate number of\r
-        space characters.\r
-\r
-#39.  (Fixed in 1.33MR5) Jan Mikkelsen <janm@zeta.org.au>\r
-\r
-        Commas in function prototype still not correct under\r
-        some circumstances.  Suggested code fix installed.\r
-\r
-#38.  (Fixed in 1.33MR5) ANTLRTokenBuffer constructor\r
-\r
-        Have ANTLRTokenBuffer ctor initialize member "parser" to null.\r
-\r
-#37.  (Fixed in 1.33MR4) Bruce Guenter (bruceg@qcc.sk.ca)\r
-\r
-        In ANTLRParser::FAIL(int k,...) released memory pointed to by\r
-        f[i] (as well as f itself.  Should only free f itself.\r
-\r
-#36.  (Fixed in 1.33MR3) Cortland D. Starrett (cort@shay.ecn.purdue.edu)\r
-\r
-        Neglected to properly declare isDLGmaxToken() when fixing problem\r
-        reported by Andreas Magnusson.\r
-\r
-        Undo "_retv=NULL;" change which caused problems for return values\r
-        from rules whose return values weren't pointers.\r
-\r
-        Failed to create bin directory if it didn't exist.\r
-\r
-#35.  (Fixed in 1.33MR2) Andreas Magnusson\r
-(Andreas.Magnusson@mailbox.swipnet.se)\r
-\r
-        Repair bug introduced by 1.33MR1 for #tokdefs.  The original fix\r
-        placed "DLGmaxToken=9999" and "DLGminToken=0" in the TokenType enum\r
-        in order to fix a problem with an aggresive compiler assigning an 8\r
-        bit enum which might be too narrow.  This caused #tokdefs to assume\r
-        that there were 9999 real tokens.  The repair to the fix causes antlr to\r
-        ignore TokenTypes "DLGmaxToken" and "DLGminToken" in a #tokdefs file.\r
-\r
-#34.  (Added to 1.33MR1) Add public DLGLexerBase::set_line(int newValue)\r
-\r
-        Previously there was no public function for changing the line\r
-        number maintained by the lexer.\r
-\r
-#33.  (Fixed in 1.33MR1) Franklin Chen   (chen@adi.com)\r
-\r
-        Accidental use of EXIT_FAILURE rather than PCCTS_EXIT_FAILURE\r
-        in pccts/h/AParser.cpp.\r
-\r
-#32.  (Fixed in 1.33MR1) Franklin Chen   (chen@adi.com)\r
-\r
-        In PCCTSAST.cpp lines 405 and 466:  Change\r
-\r
-                free (t)\r
-           to\r
-                free ( (char *)t );\r
-\r
-        to match prototype.\r
-\r
-#31.   (Added to 1.33MR1) Pointer to parser in ANTLRTokenBuffer\r
-                        Pointer to parser in DLGLexerBase\r
-\r
-        The ANTLRTokenBuffer class now contains a pointer to the\r
-        parser which is using it.  This is established by the\r
-        ANTLRParser constructor calling ANTLRTokenBuffer::\r
-        setParser(ANTLRParser *p).\r
-\r
-        When ANTLRTokenBuffer::setParser(ANTLRParser *p) is\r
-        called it saves the pointer to the parser and then\r
-        calls ANTLRTokenStream::setParser(ANTLRParser *p)\r
-        so that the lexer can also save a pointer to the\r
-        parser.\r
-\r
-        There is also a function getParser() in each class\r
-        with the obvious purpose.\r
-\r
-        It is possible that these functions will return NULL\r
-        under some circumstances (e.g. a non-DLG lexer is used).\r
-\r
-#30.   (Added to 1.33MR1) function tokenName(int token) standard\r
-\r
-        The generated parser class now includes the\r
-        function:\r
-\r
-          static const ANTLRChar * tokenName(int token)\r
-\r
-        which returns a pointer to the "name" corresponding\r
-        to the token.\r
-\r
-        The base class (ANTLRParser) always includes the\r
-        member function:\r
-\r
-          const ANTLRChar * parserTokenName(int token)\r
-\r
-        which can be accessed by objects which have a pointer\r
-        to an ANTLRParser, but do not know the name of the\r
-        parser class (e.g. ANTLRTokenBuffer and DLGLexerBase).\r
-\r
-#29.   (Added to 1.33MR1) Debugging DLG lexers\r
-\r
-        If the pre-processor symbol DEBUG_LEXER is defined\r
-        then DLexerBase will include code for printing out\r
-        key information about tokens which are recognized.\r
-\r
-        The debug feature of the lexer is controlled by:\r
-\r
-          int previousDebugValue=lexer.debugLexer(newValue);\r
-\r
-                        a value of 0 disables output\r
-                        a value of 1 enables output\r
-\r
-        Even if the lexer debug code is compiled into DLexerBase\r
-        it must be enabled before any output is generated.  For\r
-        example:\r
-\r
-           DLGFileInput         in(stdin);\r
-           MyDLG                lexer(&in,2000);\r
-\r
-           lexer.setToken(&aToken);\r
-\r
-           #if DEBUG_LEXER\r
-             lexer.debugLexer(1);       // enable debug information\r
-           #endif\r
-\r
-#28.   (Added to 1.33MR1) More control over DLG header\r
-\r
-        Version 1.33MR1 adds the following directives to PCCTS\r
-        for C++ mode:\r
-\r
-          #lexprefix  <<source code>>\r
-\r
-                Adds source code to the DLGLexer.h file\r
-                after the #include "DLexerBase.h" but\r
-                before the start of the class definition.\r
-\r
-          #lexmember  <<source code>>\r
-\r
-                Adds source code to the DLGLexer.h file\r
-                as part of the DLGLexer class body.  It\r
-                appears immediately after the start of\r
-                the class and a "public: statement.\r
-\r
-#27.   (Fixed in 1.33MR1) Comments in DLG actions\r
-\r
-        Previously, DLG would not recognize comments as a special case.\r
-        Thus, ">>" in the comments would cause errors.  This is fixed.\r
-\r
-#26.   (Fixed in 1.33MR1) Removed static variables from error routines\r
-\r
-        Previously, the existence of statically allocated variables\r
-        in some of the parser's member functions posed a danger when\r
-        there was more than one parser active.\r
-\r
-        Replaced with dynamically allocated/freed variables in 1.33MR1.\r
-\r
-#25.  (Fixed in 1.33MR1)  Use of string literals in semantic predicates\r
-\r
-        Previously, it was not possible to place a string literal in\r
-        a semantic predicate because it was not properly "stringized"\r
-        for the report of a failed predicate.\r
-\r
-#24.  (Fixed in 1.33MR1)  Continuation lines for semantic predicates\r
-\r
-        Previously, it was not possible to continue semantic\r
-        predicates across a line because it was not properly\r
-        "stringized" for the report of a failed predicate.\r
-\r
-                rule : <<ifXYZ()>>?[ a very\r
-                                        long statement ]\r
-\r
-#23.  (Fixed in 1.33MR1)  {...} envelope for failed semantic predicates\r
-\r
-        Previously, there was a code generation error for failed\r
-        semantic predicates:\r
-\r
-          rule : <<xyz()>>?[ stmt1; stmt2; ]\r
-\r
-        which generated code which resembled:\r
-\r
-          if (! xyz()) stmt1; stmt2;\r
-\r
-        It now puts the statements in a {...} envelope:\r
-\r
-          if (! xyz()) { stmt1; stmt2; };\r
-\r
-#22.  (Fixed in 1.33MR1)  Continuation of #token across lines using "\"\r
-\r
-        Previously, it was not possible to continue a #token regular\r
-        expression across a line.  The trailing "\" and newline caused\r
-        a newline to be inserted into the regular expression by DLG.\r
-\r
-        Fixed in 1.33MR1.\r
-\r
-#21.  (Fixed in 1.33MR1)  Use of ">>" (right shift operator in DLG actions\r
-\r
-        It is now possible to use the C++ right shift operator ">>"\r
-        in DLG actions by using the normal escapes:\r
-\r
-                #token "shift-right"     << value=value \>\> 1;>>\r
-\r
-#20.  (Version 1.33/19-Jan-97 Karl Eccleson <karle@microrobotics.co.uk>\r
-                            P.A. Keller (P.A.Keller@bath.ac.uk)\r
-\r
-        There is a problem due to using exceptions with the -gh option.\r
-\r
-        Suggested fix now in 1.33MR1.\r
-\r
-#19.  (Fixed in 1.33MR1)             Tom Piscotti and John Lilley\r
-\r
-        There were problems suppressing messages to stdin and stdout\r
-        when running in a window environment because some functions\r
-        which uses fprint were not virtual.\r
-\r
-        Suggested change now in 1.33MR1.\r
-\r
-        I believe all functions containing error messages (excluding those\r
-        indicating internal inconsistency) have been placed in functions\r
-        which are virtual.\r
-\r
-#18.  (Version 1.33/ 22-Nov-96)  John Bair (jbair@iftime.com)\r
-\r
-        Under some combination of options a required "return _retv" is\r
-        not generated.\r
-\r
-        Suggested fix now in 1.33MR1.\r
-\r
-#17.  (Version 1.33/3-Sep-96) Ron House  (house@helios.usq.edu.au)\r
-\r
-        The routine ASTBase::predorder_action omits two "tree->"\r
-        prefixes, which results in the preorder_action belonging\r
-        to the wrong node to be invoked.\r
-\r
-        Suggested fix now in 1.33MR1.\r
-\r
-#16.  (Version 1.33/7-Jun-96)       Eli Sternheim <eli@interhdl.com>\r
-\r
-        Routine consumeUntilToken() does not check for end-of-file\r
-        condition.\r
-\r
-        Suggested fix now in 1.33MR1.\r
-\r
-#15.  (Version 1.33/8 Apr 96)   Asgeir Olafsson <olafsson@cstar.ac.com>\r
-\r
-        Problem with tree duplication of doubly linked ASTs in ASTBase.cpp.\r
-\r
-        Suggested fix now in 1.33MR1.\r
-\r
-#14.  (Version 1.33/28-Feb-96)   Andreas.Magnusson@mailbox.swipnet.se\r
-\r
-        Problem with definition of operator = (const ANTLRTokenPtr rhs).\r
-\r
-        Suggested fix now in 1.33MR1.\r
-\r
-#13.  (Version 1.33/13-Feb-96) Franklin Chen (chen@adi.com)\r
-\r
-        Sun C++ Compiler 3.0.1 can't compile testcpp/1 due to goto in\r
-        block with destructors.\r
-\r
-        Apparently fixed. Can't locate "goto".\r
-\r
-#12.  (Version 1.33/10-Nov-95)  Minor problems with 1.33 code\r
-\r
-        The following items have been fixed in 1.33MR1:\r
-\r
-          1.  pccts/antlr/main.c line 142\r
-\r
-                "void" appears in classic C code\r
-\r
-          2.  no makefile in support/genmk\r
-\r
-          3.  EXIT_FAILURE/_SUCCESS instead of PCCTS_EXIT_FAILURE/_SUCCESS\r
-\r
-                pccts/h/PCCTSAST.cpp\r
-                pccts/h/DLexerBase.cpp\r
-                pccts/testcpp/6/test.g\r
-\r
-          4.  use of "signed int" isn't accepted by AT&T cfront\r
-\r
-                pccts/h/PCCTSAST.h line 42\r
-\r
-          5.  in call to ANTLRParser::FAIL the var arg err_k is passed as\r
-              "int" but is declared "unsigned int".\r
-\r
-          6.  I believe that a failed validation predicate still does not\r
-              get put in a "{...}" envelope, despite the release notes.\r
-\r
-          7. The #token ">>" appearing in the DLG grammar description\r
-             causes DLG to generate the string literal "\>\>" which\r
-             is non-conforming and will cause some compilers to\r
-             complain (scan.c function act10 line 143 of source code).\r
-\r
-#11.  (Version 1.32b6)  Dave Kuhlman     (dkuhlman@netcom.com)\r
-\r
-        Problem with file close in gen.c.  Already fixed in 1.33.\r
-\r
-#10.  (Version 1.32b6/29-Aug-95)\r
-\r
-        pccts/antlr/main.c contains a C++ style comments on lines 149\r
-        and 176 which causes problems for most C compilers.\r
-\r
-         Already fixed in 1.33.\r
-\r
-#9.   (Version 1.32b4/14-Mar-95) dlgauto.h #include "config.h"\r
-\r
-        The file pccts/h/dlgauto.h should probably contain a #include\r
-        "config.h" as it uses the #define symbol __USE_PROTOS.\r
-\r
-        Added to 1.33MR1.\r
-\r
-#8.   (Version 1.32b4/6-Mar-95)  Michael T. Richter (mtr@igs.net)\r
-\r
-        In C++ output mode anonymous tokens from in-line regular expressions\r
-        can create enum values which are too wide for the datatype of the enum\r
-        assigned by the C++ compiler.\r
-\r
-        Fixed in 1.33MR1.\r
-\r
-#7.   (Version 1.32b4/6-Mar-95)  C++ does not imply __STDC__\r
-\r
-        In err.h the combination of # directives assumes that a C++\r
-        compiler has __STDC__ defined.  This is not necessarily true.\r
-\r
-        This problem also appears in the use of __USE_PROTOS which\r
-        is appropriate for both Standard C and C++ in antlr/gen.c\r
-        and antlr/lex.c\r
-\r
-        Fixed in 1.33MR1.\r
-\r
-#6.   (Version 1.32 ?/15-Feb-95) Name conflict for "TokenType"\r
-\r
-        Already fixed in 1.33.\r
-\r
-#5.   (23-Jan-95)        Douglas_Cuthbertson.JTIDS@jtids_qmail.hanscom.af.mil\r
-\r
-        The fail action following a semantic predicate is not enclosed in\r
-        "{...}". This can lead to problems when the fail action contains\r
-        more than one statement.\r
-\r
-        Fixed in 1.33MR1.\r
-\r
-#4 .  (Version 1.33/31-Mar-96)   jlilley@empathy.com (John Lilley)\r
-\r
-        Put briefly, a semantic predicate ought to abort a guess if it fails.\r
-\r
-        Correction suggested by J. Lilley has been added to 1.33MR1.\r
-\r
-#3 .  (Version 1.33)             P.A.Keller@bath.ac.uk\r
-\r
-        Extra commas are placed in the K&R style argument list for rules\r
-        when using both exceptions and ASTs.\r
-\r
-        Fixed in 1.33MR1.\r
-\r
-#2.   (Version 1.32b6/2-Oct-95)  Brad Schick <schick@interaccess.com>\r
-\r
-        Construct #[] generates zzastnew() in C++ mode.\r
-\r
-        Already fixed in 1.33.\r
-\r
-#1.   (Version 1.33)     Bob Bailey (robert@oakhill.sps.mot.com)\r
-\r
-        Previously, config.h assumed that all PC systems required\r
-        "short" file names.  The user can now override that\r
-        assumption with "#define LONGFILENAMES".\r
-\r
-        Added to 1.33MR1.\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/CHANGES_SUMMARY.txt b/Tools/CodeTools/TianoTools/Pccts/CHANGES_SUMMARY.txt
deleted file mode 100644 (file)
index 91defae..0000000
+++ /dev/null
@@ -1,2049 +0,0 @@
-======================================================================\r
-\r
-                       CHANGES_SUMMARY.TXT\r
-\r
-        A QUICK overview of changes from 1.33 in reverse order\r
-\r
-  A summary of additions rather than bug fixes and minor code changes.\r
-\r
-          Numbers refer to items in CHANGES_FROM_133*.TXT\r
-             which may contain additional information.\r
-\r
-                          DISCLAIMER\r
-\r
- The software and these notes are provided "as is".  They may include\r
- typographical or technical errors and their authors disclaims all\r
- liability of any kind or nature for damages due to error, fault,\r
- defect, or deficiency regardless of cause.  All warranties of any\r
- kind, either express or implied, including, but not limited to, the\r
- implied  warranties of merchantability and fitness for a particular\r
- purpose are disclaimed.\r
-\r
-======================================================================\r
-\r
-#258. You can specify a user-defined base class for your parser\r
-\r
-    The base class must constructor must have a signature similar to\r
-    that of ANTLRParser.\r
-\r
-#253. Generation of block preamble (-preamble and -preamble_first)\r
-\r
-    The antlr option -preamble causes antlr to insert the code\r
-    BLOCK_PREAMBLE at the start of each rule and block.\r
-\r
-    The antlr option -preamble_first is similar, but inserts the\r
-    code BLOCK_PREAMBLE_FIRST(PreambleFirst_123) where the symbol\r
-    PreambleFirst_123 is equivalent to the first set defined by\r
-    the #FirstSetSymbol described in Item #248.\r
-\r
-#248. Generate symbol for first set of an alternative\r
-\r
-        rr : #FirstSetSymbol(rr_FirstSet)  ( Foo | Bar ) ;\r
-\r
-#216. Defer token fetch for C++ mode\r
-\r
-    When the ANTLRParser class is built with the pre-processor option \r
-    ZZDEFER_FETCH defined, the fetch of new tokens by consume() is deferred\r
-    until LA(i) or LT(i) is called. \r
-\r
-#215. Use reset() to reset DLGLexerBase\r
-#188. Added pccts/h/DLG_stream_input.h\r
-#180. Added ANTLRParser::getEofToken()\r
-#173. -glms for Microsoft style filenames with -gl\r
-#170. Suppression for predicates with lookahead depth >1\r
-\r
-      Consider the following grammar with -ck 2 and the predicate in rule\r
-      "a" with depth 2:\r
-\r
-            r1  : (ab)* "@"\r
-                ;\r
-\r
-            ab  : a\r
-                | b\r
-                ;\r
-\r
-            a   : (A B)? => <<p(LATEXT(2))>>? A B C\r
-                ;\r
-\r
-            b   : A B C\r
-                ;\r
-\r
-      Normally, the predicate would be hoisted into rule r1 in order to\r
-      determine whether to call rule "ab".  However it should *not* be\r
-      hoisted because, even if p is false, there is a valid alternative\r
-      in rule b.  With "-mrhoistk on" the predicate will be suppressed.\r
-\r
-      If "-info p" command line option is present the following information\r
-      will appear in the generated code:\r
-\r
-                while ( (LA(1)==A)\r
-        #if 0\r
-\r
-        Part (or all) of predicate with depth > 1 suppressed by alternative\r
-            without predicate\r
-\r
-        pred  <<  p(LATEXT(2))>>?\r
-                  depth=k=2  ("=>" guard)  rule a  line 8  t1.g\r
-          tree context:\r
-            (root = A\r
-               B\r
-            )\r
-\r
-        The token sequence which is suppressed: ( A B )\r
-        The sequence of references which generate that sequence of tokens:\r
-\r
-           1 to ab          r1/1       line 1     t1.g\r
-           2 ab             ab/1       line 4     t1.g\r
-           3 to b           ab/2       line 5     t1.g\r
-           4 b              b/1        line 11    t1.g\r
-           5 #token A       b/1        line 11    t1.g\r
-           6 #token B       b/1        line 11    t1.g\r
-\r
-        #endif\r
-\r
-      A slightly more complicated example:\r
-\r
-            r1  : (ab)* "@"\r
-                ;\r
-\r
-            ab  : a\r
-                | b\r
-                ;\r
-\r
-            a   : (A B)? => <<p(LATEXT(2))>>? (A  B | D E)\r
-                ;\r
-\r
-            b   : <<q(LATEXT(2))>>? D E\r
-                ;\r
-\r
-\r
-      In this case, the sequence (D E) in rule "a" which lies behind\r
-      the guard is used to suppress the predicate with context (D E)\r
-      in rule b.\r
-\r
-                while ( (LA(1)==A || LA(1)==D)\r
-            #if 0\r
-\r
-            Part (or all) of predicate with depth > 1 suppressed by alternative\r
-                without predicate\r
-\r
-            pred  <<  q(LATEXT(2))>>?\r
-                              depth=k=2  rule b  line 11  t2.g\r
-              tree context:\r
-                (root = D\r
-                   E\r
-                )\r
-\r
-            The token sequence which is suppressed: ( D E )\r
-            The sequence of references which generate that sequence of tokens:\r
-\r
-               1 to ab          r1/1       line 1     t2.g\r
-               2 ab             ab/1       line 4     t2.g\r
-               3 to a           ab/1       line 4     t2.g\r
-               4 a              a/1        line 8     t2.g\r
-               5 #token D       a/1        line 8     t2.g\r
-               6 #token E       a/1        line 8     t2.g\r
-\r
-            #endif\r
-            &&\r
-            #if 0\r
-\r
-            pred  <<  p(LATEXT(2))>>?\r
-                              depth=k=2  ("=>" guard)  rule a  line 8  t2.g\r
-              tree context:\r
-                (root = A\r
-                   B\r
-                )\r
-\r
-            #endif\r
-\r
-            (! ( LA(1)==A && LA(2)==B ) || p(LATEXT(2)) )  {\r
-                ab();\r
-                ...\r
-\r
-#165. (Changed in MR13) option -newAST\r
-\r
-      To create ASTs from an ANTLRTokenPtr antlr usually calls\r
-      "new AST(ANTLRTokenPtr)".  This option generates a call\r
-      to "newAST(ANTLRTokenPtr)" instead.  This allows a user\r
-      to define a parser member function to create an AST object.\r
-\r
-#161. (Changed in MR13) Switch -gxt inhibits generation of tokens.h\r
-\r
-#158. (Changed in MR13) #header causes problem for pre-processors\r
-\r
-      A user who runs the C pre-processor on antlr source suggested\r
-      that another syntax be allowed.  With MR13 such directives\r
-      such as #header, #pragma, etc. may be written as "\#header",\r
-      "\#pragma", etc.  For escaping pre-processor directives inside\r
-      a #header use something like the following:\r
-\r
-            \#header\r
-            <<\r
-                \#include <stdio.h>\r
-            >>\r
-\r
-#155. (Changed in MR13) Context behind predicates can suppress\r
-\r
-      With -mrhoist enabled the context behind a guarded predicate can\r
-      be used to suppress other predicates.  Consider the following grammar:\r
-\r
-        r0 : (r1)+;\r
-\r
-        r1  : rp\r
-            | rq\r
-            ;\r
-        rp  : <<p LATEXT(1)>>? B ;\r
-        rq : (A)? => <<q LATEXT(1)>>? (A|B);\r
-\r
-      In earlier versions both predicates "p" and "q" would be hoisted into\r
-      rule r0. With MR12c predicate p is suppressed because the context which\r
-      follows predicate q includes "B" which can "cover" predicate "p".  In\r
-      other words, in trying to decide in r0 whether to call r1, it doesn't\r
-      really matter whether p is false or true because, either way, there is\r
-      a valid choice within r1.\r
-\r
-#154. (Changed in MR13) Making hoist suppression explicit using <<nohoist>>\r
-\r
-      A common error, even among experienced pccts users, is to code\r
-      an init-action to inhibit hoisting rather than a leading action.\r
-      An init-action does not inhibit hoisting.\r
-\r
-      This was coded:\r
-\r
-        rule1 : <<;>> rule2\r
-\r
-      This is what was meant:\r
-\r
-        rule1 : <<;>> <<;>> rule2\r
-\r
-      With MR13, the user can code:\r
-\r
-        rule1 : <<;>> <<nohoist>> rule2\r
-\r
-      The following will give an error message:\r
-\r
-        rule1 : <<nohoist>> rule2\r
-\r
-      If the <<nohoist>> appears as an init-action rather than a leading\r
-      action an error message is issued.  The meaning of an init-action\r
-      containing "nohoist" is unclear: does it apply to just one\r
-      alternative or to all alternatives ?\r
-\r
-#151a. Addition of ANTLRParser::getLexer(), ANTLRTokenStream::getLexer()\r
-\r
-      You must manually cast the ANTLRTokenStream to your program's\r
-      lexer class. Because the name of the lexer's class is not fixed.\r
-      Thus it is impossible to incorporate it into the DLGLexerBase\r
-      class.\r
-\r
-#151b.(Changed in MR12) ParserBlackBox member getLexer()\r
-\r
-#150. (Changed in MR12) syntaxErrCount and lexErrCount now public\r
-\r
-#149. (Changed in MR12) antlr option -info o (letter o for orphan)\r
-\r
-      If there is more than one rule which is not referenced by any\r
-      other rule then all such rules are listed.  This is useful for\r
-      alerting one to rules which are not used, but which can still\r
-      contribute to ambiguity.\r
-\r
-#148. (Changed in MR11) #token names appearing in zztokens,token_tbl\r
-\r
-      One can write:\r
-\r
-            #token Plus ("+")             "\+"\r
-            #token RP   ("(")             "\("\r
-            #token COM  ("comment begin") "/\*"\r
-\r
-      The string in parenthesis will be used in syntax error messages.\r
-\r
-#146. (Changed in MR11) Option -treport for locating "difficult" alts\r
-\r
-      It can be difficult to determine which alternatives are causing\r
-      pccts to work hard to resolve an ambiguity.  In some cases the\r
-      ambiguity is successfully resolved after much CPU time so there\r
-      is no message at all.\r
-\r
-      A rough measure of the amount of work being peformed which is\r
-      independent of the CPU speed and system load is the number of\r
-      tnodes created.  Using "-info t" gives information about the\r
-      total number of tnodes created and the peak number of tnodes.\r
-\r
-        Tree Nodes:  peak 1300k  created 1416k  lost 0\r
-\r
-      It also puts in the generated C or C++ file the number of tnodes\r
-      created for a rule (at the end of the rule).  However this\r
-      information is not sufficient to locate the alternatives within\r
-      a rule which are causing the creation of tnodes.\r
-\r
-      Using:\r
-\r
-             antlr -treport 100000 ....\r
-\r
-      causes antlr to list on stdout any alternatives which require the\r
-      creation of more than 100,000 tnodes, along with the lookahead sets\r
-      for those alternatives.\r
-\r
-      The following is a trivial case from the ansi.g grammar which shows\r
-      the format of the report.  This report might be of more interest\r
-      in cases where 1,000,000 tuples were created to resolve the ambiguity.\r
-\r
-      -------------------------------------------------------------------------\r
-        There were 0 tuples whose ambiguity could not be resolved\r
-             by full lookahead\r
-        There were 157 tnodes created to resolve ambiguity between:\r
-\r
-          Choice 1: statement/2  line 475  file ansi.g\r
-          Choice 2: statement/3  line 476  file ansi.g\r
-\r
-            Intersection of lookahead[1] sets:\r
-\r
-               IDENTIFIER\r
-\r
-            Intersection of lookahead[2] sets:\r
-\r
-               LPARENTHESIS     COLON            AMPERSAND        MINUS\r
-               STAR             PLUSPLUS         MINUSMINUS       ONESCOMPLEMENT\r
-               NOT              SIZEOF           OCTALINT         DECIMALINT\r
-               HEXADECIMALINT   FLOATONE         FLOATTWO         IDENTIFIER\r
-               STRING           CHARACTER\r
-      -------------------------------------------------------------------------\r
-\r
-#143. (Changed in MR11) Optional ";" at end of #token statement\r
-\r
-      Fixes problem of:\r
-\r
-            #token X "x"\r
-\r
-            <<\r
-                parser action\r
-            >>\r
-\r
-      Being confused with:\r
-\r
-            #token X "x" <<lexical action>>\r
-\r
-#142. (Changed in MR11) class BufFileInput subclass of DLGInputStream\r
-\r
-      Alexey Demakov (demakov@kazbek.ispras.ru) has supplied class\r
-      BufFileInput derived from DLGInputStream which provides a\r
-      function lookahead(char *string) to test characters in the\r
-      input stream more than one character ahead.\r
-      The class is located in pccts/h/BufFileInput.* of the kit.\r
-\r
-#140. #pred to define predicates\r
-\r
-      +---------------------------------------------------+\r
-      | Note: Assume "-prc on" for this entire discussion |\r
-      +---------------------------------------------------+\r
-\r
-      A problem with predicates is that each one is regarded as\r
-      unique and capable of disambiguating cases where two\r
-      alternatives have identical lookahead.  For example:\r
-\r
-        rule : <<pred(LATEXT(1))>>? A\r
-             | <<pred(LATEXT(1))>>? A\r
-             ;\r
-\r
-      will not cause any error messages or warnings to be issued\r
-      by earlier versions of pccts.  To compare the text of the\r
-      predicates is an incomplete solution.\r
-\r
-      In 1.33MR11 I am introducing the #pred statement in order to\r
-      solve some problems with predicates.  The #pred statement allows\r
-      one to give a symbolic name to a "predicate literal" or a\r
-      "predicate expression" in order to refer to it in other predicate\r
-      expressions or in the rules of the grammar.\r
-\r
-      The predicate literal associated with a predicate symbol is C\r
-      or C++ code which can be used to test the condition.  A\r
-      predicate expression defines a predicate symbol in terms of other\r
-      predicate symbols using "!", "&&", and "||".  A predicate symbol\r
-      can be defined in terms of a predicate literal, a predicate\r
-      expression, or *both*.\r
-\r
-      When a predicate symbol is defined with both a predicate literal\r
-      and a predicate expression, the predicate literal is used to generate\r
-      code, but the predicate expression is used to check for two\r
-      alternatives with identical predicates in both alternatives.\r
-\r
-      Here are some examples of #pred statements:\r
-\r
-        #pred  IsLabel       <<isLabel(LATEXT(1))>>?\r
-        #pred  IsLocalVar    <<isLocalVar(LATEXT(1))>>?\r
-        #pred  IsGlobalVar   <<isGlobalVar(LATEXT(1)>>?\r
-        #pred  IsVar         <<isVar(LATEXT(1))>>?       IsLocalVar || IsGlobalVar\r
-        #pred  IsScoped      <<isScoped(LATEXT(1))>>?    IsLabel || IsLocalVar\r
-\r
-      I hope that the use of EBNF notation to describe the syntax of the\r
-      #pred statement will not cause problems for my readers (joke).\r
-\r
-        predStatement : "#pred"\r
-                            CapitalizedName\r
-                              (\r
-                                  "<<predicate_literal>>?"\r
-                                | "<<predicate_literal>>?"  predOrExpr\r
-                                | predOrExpr\r
-                              )\r
-                      ;\r
-\r
-        predOrExpr    : predAndExpr ( "||" predAndExpr ) * ;\r
-\r
-        predAndExpr   : predPrimary ( "&&" predPrimary ) * ;\r
-\r
-        predPrimary   : CapitalizedName\r
-                      | "!" predPrimary\r
-                      | "(" predOrExpr ")"\r
-                      ;\r
-\r
-      What is the purpose of this nonsense ?\r
-\r
-      To understand how predicate symbols help, you need to realize that\r
-      predicate symbols are used in two different ways with two different\r
-      goals.\r
-\r
-        a. Allow simplification of predicates which have been combined\r
-           during predicate hoisting.\r
-\r
-        b. Allow recognition of identical predicates which can't disambiguate\r
-           alternatives with common lookahead.\r
-\r
-      First we will discuss goal (a).  Consider the following rule:\r
-\r
-            rule0: rule1\r
-                 | ID\r
-                 | ...\r
-                 ;\r
-\r
-            rule1: rule2\r
-                 | rule3\r
-                 ;\r
-\r
-            rule2: <<isX(LATEXT(1))>>? ID ;\r
-            rule3: <<!isX(LATEXT(1)>>? ID ;\r
-\r
-      When the predicates in rule2 and rule3 are combined by hoisting\r
-      to create a prediction expression for rule1 the result is:\r
-\r
-            if ( LA(1)==ID\r
-                && ( isX(LATEXT(1) || !isX(LATEXT(1) ) ) { rule1(); ...\r
-\r
-      This is inefficient, but more importantly, can lead to false\r
-      assumptions that the predicate expression distinguishes the rule1\r
-      alternative with some other alternative with lookahead ID.  In\r
-      MR11 one can write:\r
-\r
-            #pred IsX     <<isX(LATEXT(1))>>?\r
-\r
-            ...\r
-\r
-            rule2: <<IsX>>? ID  ;\r
-            rule3: <<!IsX>>? ID ;\r
-\r
-      During hoisting MR11 recognizes this as a special case and\r
-      eliminates the predicates.  The result is a prediction\r
-      expression like the following:\r
-\r
-            if ( LA(1)==ID ) { rule1(); ...\r
-\r
-      Please note that the following cases which appear to be equivalent\r
-      *cannot* be simplified by MR11 during hoisting because the hoisting\r
-      logic only checks for a "!" in the predicate action, not in the\r
-      predicate expression for a predicate symbol.\r
-\r
-        *Not* equivalent and is not simplified during hoisting:\r
-\r
-            #pred IsX      <<isX(LATEXT(1))>>?\r
-            #pred NotX     <<!isX(LATEXT(1))>>?\r
-            ...\r
-            rule2: <<IsX>>? ID  ;\r
-            rule3: <<NotX>>? ID ;\r
-\r
-        *Not* equivalent and is not simplified during hoisting:\r
-\r
-            #pred IsX      <<isX(LATEXT(1))>>?\r
-            #pred NotX     !IsX\r
-            ...\r
-            rule2: <<IsX>>? ID  ;\r
-            rule3: <<NotX>>? ID ;\r
-\r
-      Now we will discuss goal (b).\r
-\r
-      When antlr discovers that there is a lookahead ambiguity between\r
-      two alternatives it attempts to resolve the ambiguity by searching\r
-      for predicates in both alternatives.  In the past any predicate\r
-      would do, even if the same one appeared in both alternatives:\r
-\r
-            rule: <<p(LATEXT(1))>>? X\r
-                | <<p(LATEXT(1))>>? X\r
-                ;\r
-\r
-      The #pred statement is a start towards solving this problem.\r
-      During ambiguity resolution (*not* predicate hoisting) the\r
-      predicates for the two alternatives are expanded and compared.\r
-      Consider the following example:\r
-\r
-            #pred Upper     <<isUpper(LATEXT(1))>>?\r
-            #pred Lower     <<isLower(LATEXT(1))>>?\r
-            #pred Alpha     <<isAlpha(LATEXT(1))>>?  Upper || Lower\r
-\r
-            rule0: rule1\r
-                 | <<Alpha>>? ID\r
-                 ;\r
-\r
-            rule1:\r
-                 | rule2\r
-                 | rule3\r
-                 ...\r
-                 ;\r
-\r
-            rule2: <<Upper>>? ID;\r
-            rule3: <<Lower>>? ID;\r
-\r
-      The definition of #pred Alpha expresses:\r
-\r
-            a. to test the predicate use the C code "isAlpha(LATEXT(1))"\r
-\r
-            b. to analyze the predicate use the information that\r
-               Alpha is equivalent to the union of Upper and Lower,\r
-\r
-      During ambiguity resolution the definition of Alpha is expanded\r
-      into "Upper || Lower" and compared with the predicate in the other\r
-      alternative, which is also "Upper || Lower".  Because they are\r
-      identical MR11 will report a problem.\r
-\r
-    -------------------------------------------------------------------------\r
-      t10.g, line 5: warning: the predicates used to disambiguate rule rule0\r
-             (file t10.g alt 1 line 5 and alt 2 line 6)\r
-             are identical when compared without context and may have no\r
-             resolving power for some lookahead sequences.\r
-    -------------------------------------------------------------------------\r
-\r
-      If you use the "-info p" option the output file will contain:\r
-\r
-    +----------------------------------------------------------------------+\r
-    |#if 0                                                                 |\r
-    |                                                                      |\r
-    |The following predicates are identical when compared without          |\r
-    |  lookahead context information.  For some ambiguous lookahead        |\r
-    |  sequences they may not have any power to resolve the ambiguity.     |\r
-    |                                                                      |\r
-    |Choice 1: rule0/1  alt 1  line 5  file t10.g                          |\r
-    |                                                                      |\r
-    |  The original predicate for choice 1 with available context          |\r
-    |    information:                                                      |\r
-    |                                                                      |\r
-    |    OR expr                                                           |\r
-    |                                                                      |\r
-    |      pred  <<  Upper>>?                                              |\r
-    |                        depth=k=1  rule rule2  line 14  t10.g         |\r
-    |        set context:                                                  |\r
-    |           ID                                                         |\r
-    |                                                                      |\r
-    |      pred  <<  Lower>>?                                              |\r
-    |                        depth=k=1  rule rule3  line 15  t10.g         |\r
-    |        set context:                                                  |\r
-    |           ID                                                         |\r
-    |                                                                      |\r
-    |  The predicate for choice 1 after expansion (but without context     |\r
-    |    information):                                                     |\r
-    |                                                                      |\r
-    |    OR expr                                                           |\r
-    |                                                                      |\r
-    |      pred  <<  isUpper(LATEXT(1))>>?                                 |\r
-    |                        depth=k=1  rule   line 1  t10.g               |\r
-    |                                                                      |\r
-    |      pred  <<  isLower(LATEXT(1))>>?                                 |\r
-    |                        depth=k=1  rule   line 2  t10.g               |\r
-    |                                                                      |\r
-    |                                                                      |\r
-    |Choice 2: rule0/2  alt 2  line 6  file t10.g                          |\r
-    |                                                                      |\r
-    |  The original predicate for choice 2 with available context          |\r
-    |    information:                                                      |\r
-    |                                                                      |\r
-    |  pred  <<  Alpha>>?                                                  |\r
-    |                    depth=k=1  rule rule0  line 6  t10.g              |\r
-    |    set context:                                                      |\r
-    |       ID                                                             |\r
-    |                                                                      |\r
-    |  The predicate for choice 2 after expansion (but without context     |\r
-    |    information):                                                     |\r
-    |                                                                      |\r
-    |  OR expr                                                             |\r
-    |                                                                      |\r
-    |    pred  <<  isUpper(LATEXT(1))>>?                                   |\r
-    |                      depth=k=1  rule   line 1  t10.g                 |\r
-    |                                                                      |\r
-    |    pred  <<  isLower(LATEXT(1))>>?                                   |\r
-    |                      depth=k=1  rule   line 2  t10.g                 |\r
-    |                                                                      |\r
-    |                                                                      |\r
-    |#endif                                                                |\r
-    +----------------------------------------------------------------------+\r
-\r
-      The comparison of the predicates for the two alternatives takes\r
-      place without context information, which means that in some cases\r
-      the predicates will be considered identical even though they operate\r
-      on disjoint lookahead sets.  Consider:\r
-\r
-            #pred Alpha\r
-\r
-            rule1: <<Alpha>>? ID\r
-                 | <<Alpha>>? Label\r
-                 ;\r
-\r
-      Because the comparison of predicates takes place without context\r
-      these will be considered identical.  The reason for comparing\r
-      without context is that otherwise it would be necessary to re-evaluate\r
-      the entire predicate expression for each possible lookahead sequence.\r
-      This would require more code to be written and more CPU time during\r
-      grammar analysis, and it is not yet clear whether anyone will even make\r
-      use of the new #pred facility.\r
-\r
-      A temporary workaround might be to use different #pred statements\r
-      for predicates you know have different context.  This would avoid\r
-      extraneous warnings.\r
-\r
-      The above example might be termed a "false positive".  Comparison\r
-      without context will also lead to "false negatives".  Consider the\r
-      following example:\r
-\r
-            #pred Alpha\r
-            #pred Beta\r
-\r
-            rule1: <<Alpha>>? A\r
-                 | rule2\r
-                 ;\r
-\r
-            rule2: <<Alpha>>? A\r
-                 | <<Beta>>?  B\r
-                 ;\r
-\r
-      The predicate used for alt 2 of rule1 is (Alpha || Beta).  This\r
-      appears to be different than the predicate Alpha used for alt1.\r
-      However, the context of Beta is B.  Thus when the lookahead is A\r
-      Beta will have no resolving power and Alpha will be used for both\r
-      alternatives.  Using the same predicate for both alternatives isn't\r
-      very helpful, but this will not be detected with 1.33MR11.\r
-\r
-      To properly handle this the predicate expression would have to be\r
-      evaluated for each distinct lookahead context.\r
-\r
-      To determine whether two predicate expressions are identical is\r
-      difficult.  The routine may fail to identify identical predicates.\r
-\r
-      The #pred feature also compares predicates to see if a choice between\r
-      alternatives which is resolved by a predicate which makes the second\r
-      choice unreachable.  Consider the following example:\r
-\r
-            #pred A         <<A(LATEXT(1)>>?\r
-            #pred B         <<B(LATEXT(1)>>?\r
-            #pred A_or_B    A || B\r
-\r
-            r   : s\r
-                | t\r
-                ;\r
-            s   : <<A_or_B>>? ID\r
-                ;\r
-            t   : <<A>>? ID\r
-                ;\r
-\r
-        ----------------------------------------------------------------------------\r
-        t11.g, line 5: warning: the predicate used to disambiguate the\r
-               first choice of  rule r\r
-             (file t11.g alt 1 line 5 and alt 2 line 6)\r
-             appears to "cover" the second predicate when compared without context.\r
-             The second predicate may have no resolving power for some lookahead\r
-               sequences.\r
-        ----------------------------------------------------------------------------\r
-\r
-#132. (Changed in 1.33MR11) Recognition of identical predicates in alts\r
-\r
-      Prior to 1.33MR11, there would be no ambiguity warning when the\r
-      very same predicate was used to disambiguate both alternatives:\r
-\r
-        test: ref B\r
-            | ref C\r
-            ;\r
-\r
-        ref : <<pred(LATEXT(1)>>? A\r
-\r
-      In 1.33MR11 this will cause the warning:\r
-\r
-        warning: the predicates used to disambiguate rule test\r
-            (file v98.g alt 1 line 1 and alt 2 line 2)\r
-             are identical and have no resolving power\r
-\r
-        -----------------  Note  -----------------\r
-\r
-          This is different than the following case\r
-\r
-                test: <<pred(LATEXT(1))>>? A B\r
-                    | <<pred(LATEXT(1)>>?  A C\r
-                    ;\r
-\r
-          In this case there are two distinct predicates\r
-          which have exactly the same text.  In the first\r
-          example there are two references to the same\r
-          predicate.  The problem represented by this\r
-          grammar will be addressed later.\r
-\r
-\r
-#127. (Changed in 1.33MR11)\r
-\r
-                    Count Syntax Errors     Count DLG Errors\r
-                    -------------------     ----------------\r
-\r
-       C++ mode     ANTLRParser::           DLGLexerBase::\r
-                      syntaxErrCount          lexErrCount\r
-       C mode       zzSyntaxErrCount        zzLexErrCount\r
-\r
-       The C mode variables are global and initialized to 0.\r
-       They are *not* reset to 0 automatically when antlr is\r
-       restarted.\r
-\r
-       The C++ mode variables are public.  They are initialized\r
-       to 0 by the constructors.  They are *not* reset to 0 by the\r
-       ANTLRParser::init() method.\r
-\r
-       Suggested by Reinier van den Born (reinier@vnet.ibm.com).\r
-\r
-#126. (Changed in 1.33MR11) Addition of #first <<...>>\r
-\r
-       The #first <<...>> inserts the specified text in the output\r
-       files before any other #include statements required by pccts.\r
-       The only things before the #first text are comments and\r
-       a #define ANTLR_VERSION.\r
-\r
-       Requested by  and Esa Pulkkinen (esap@cs.tut.fi) and Alexin\r
-       Zoltan (alexin@inf.u-szeged.hu).\r
-\r
-#124. A Note on the New "&&" Style Guarded Predicates\r
-\r
-        I've been asked several times, "What is the difference between\r
-        the old "=>" style guard predicates and the new style "&&" guard\r
-        predicates, and how do you choose one over the other" ?\r
-\r
-        The main difference is that the "=>" does not apply the\r
-        predicate if the context guard doesn't match, whereas\r
-        the && form always does.  What is the significance ?\r
-\r
-        If you have a predicate which is not on the "leading edge"\r
-        it is cannot be hoisted.  Suppose you need a predicate that\r
-        looks at LA(2).  You must introduce it manually.  The\r
-        classic example is:\r
-\r
-            castExpr :\r
-                     LP typeName RP\r
-                     | ....\r
-                     ;\r
-\r
-            typeName : <<isTypeName(LATEXT(1))>>?  ID\r
-                     | STRUCT ID\r
-                     ;\r
-\r
-        The problem  is that isTypeName() isn't on the leading edge\r
-        of typeName, so it won't be hoisted into castExpr to help\r
-        make a decision on which production to choose.\r
-\r
-        The *first* attempt to fix it is this:\r
-\r
-            castExpr :\r
-                     <<isTypeName(LATEXT(2))>>?\r
-                                        LP typeName RP\r
-                     | ....\r
-                     ;\r
-\r
-        Unfortunately, this won't work because it ignores\r
-        the problem of STRUCT.  The solution is to apply\r
-        isTypeName() in castExpr if LA(2) is an ID and\r
-        don't apply it when LA(2) is STRUCT:\r
-\r
-            castExpr :\r
-                     (LP ID)? => <<isTypeName(LATEXT(2))>>?\r
-                                        LP typeName RP\r
-                     | ....\r
-                     ;\r
-\r
-        In conclusion, the "=>" style guarded predicate is\r
-        useful when:\r
-\r
-            a. the tokens required for the predicate\r
-               are not on the leading edge\r
-            b. there are alternatives in the expression\r
-               selected by the predicate for which the\r
-               predicate is inappropriate\r
-\r
-        If (b) were false, then one could use a simple\r
-        predicate (assuming "-prc on"):\r
-\r
-            castExpr :\r
-                     <<isTypeName(LATEXT(2))>>?\r
-                                        LP typeName RP\r
-                     | ....\r
-                     ;\r
-\r
-            typeName : <<isTypeName(LATEXT(1))>>?  ID\r
-                     ;\r
-\r
-        So, when do you use the "&&" style guarded predicate ?\r
-\r
-        The new-style "&&" predicate should always be used with\r
-        predicate context.  The context guard is in ADDITION to\r
-        the automatically computed context.  Thus it useful for\r
-        predicates which depend on the token type for reasons\r
-        other than context.\r
-\r
-        The following example is contributed by Reinier van den Born\r
-        (reinier@vnet.ibm.com).\r
-\r
- +-------------------------------------------------------------------------+\r
- | This grammar has two ways to call functions:                            |\r
- |                                                                         |\r
- |  - a "standard" call syntax with parens and comma separated args        |\r
- |  - a shell command like syntax (no parens and spacing separated args)   |\r
- |                                                                         |\r
- | The former also allows a variable to hold the name of the function,     |\r
- | the latter can also be used to call external commands.                  |\r
- |                                                                         |\r
- | The grammar (simplified) looks like this:                               |\r
- |                                                                         |\r
- |   fun_call   :     ID "(" { expr ("," expr)* } ")"                      |\r
- |                                  /* ID is function name */              |\r
- |              | "@" ID "(" { expr ("," expr)* } ")"                      |\r
- |                                  /* ID is var containing fun name */    |\r
- |              ;                                                          |\r
- |                                                                         |\r
- |   command    : ID expr*          /* ID is function name */              |\r
- |              | path expr*        /* path is external command name */    |\r
- |              ;                                                          |\r
- |                                                                         |\r
- |   path       : ID                /* left out slashes and such */        |\r
- |              | "@" ID            /* ID is environment var */            |\r
- |              ;                                                          |\r
- |                                                                         |\r
- |   expr       : ....                                                     |\r
- |              | "(" expr ")";                                            |\r
- |                                                                         |\r
- |   call       : fun_call                                                 |\r
- |              | command                                                  |\r
- |              ;                                                          |\r
- |                                                                         |\r
- | Obviously the call is wildly ambiguous. This is more or less how this   |\r
- | is to be resolved:                                                      |\r
- |                                                                         |\r
- |    A call begins with an ID or an @ followed by an ID.                  |\r
- |                                                                         |\r
- |    If it is an ID and if it is an ext. command name  -> command         |\r
- |                       if followed by a paren         -> fun_call        |\r
- |                       otherwise                      -> command         |\r
- |                                                                         |\r
- |    If it is an @  and if the ID is a var name        -> fun_call        |\r
- |                       otherwise                      -> command         |\r
- |                                                                         |\r
- | One can implement these rules quite neatly using && predicates:         |\r
- |                                                                         |\r
- |   call       : ("@" ID)? && <<isVarName(LT(2))>>? fun_call              |\r
- |              | (ID)?     && <<isExtCmdName>>?     command               |\r
- |              | (ID "(")?                          fun_call              |\r
- |              |                                    command               |\r
- |              ;                                                          |\r
- |                                                                         |\r
- | This can be done better, so it is not an ideal example, but it          |\r
- | conveys the principle.                                                  |\r
- +-------------------------------------------------------------------------+\r
-\r
-#122. (Changed in 1.33MR11)  Member functions to reset DLG in C++ mode\r
-\r
-         void DLGFileReset(FILE *f) { input = f; found_eof = 0; }\r
-         void DLGStringReset(DLGChar *s) { input = s; p = &input[0]; }\r
-\r
-        Supplied by R.A. Nelson (cowboy@VNET.IBM.COM)\r
-\r
-#119. (Changed in 1.33MR11) Ambiguity aid for grammars\r
-\r
-      The user can ask for additional information on ambiguities reported\r
-      by antlr to stdout.  At the moment, only one ambiguity report can\r
-      be created in an antlr run.\r
-\r
-      This feature is enabled using the "-aa" (Ambiguity Aid)  option.\r
-\r
-      The following options control the reporting of ambiguities:\r
-\r
-          -aa ruleName       Selects reporting by name of rule\r
-          -aa lineNumber     Selects reporting by line number\r
-                               (file name not compared)\r
-\r
-          -aam               Selects "multiple" reporting for a token\r
-                             in the intersection set of the\r
-                             alternatives.\r
-\r
-                             For instance, the token ID may appear dozens\r
-                             of times in various paths as the program\r
-                             explores the rules which are reachable from\r
-                             the point of an ambiguity. With option -aam\r
-                             every possible path the search program\r
-                             encounters is reported.\r
-\r
-                             Without -aam only the first encounter is\r
-                             reported.  This may result in incomplete\r
-                             information, but the information may be\r
-                             sufficient and much shorter.\r
-\r
-          -aad depth         Selects the depth of the search.\r
-                             The default value is 1.\r
-\r
-                             The number of paths to be searched, and the\r
-                             size of the report can grow geometrically\r
-                             with the -ck value if a full search for all\r
-                             contributions to the source of the ambiguity\r
-                             is explored.\r
-\r
-                             The depth represents the number of tokens\r
-                             in the lookahead set which are matched against\r
-                             the set of ambiguous tokens.  A depth of 1\r
-                             means that the search stops when a lookahead\r
-                             sequence of just one token is matched.\r
-\r
-                             A k=1 ck=6 grammar might generate 5,000 items\r
-                             in a report if a full depth 6 search is made\r
-                             with the Ambiguity Aid.  The source of the\r
-                             problem may be in the first token and obscured\r
-                             by the volume of data - I hesitate to call\r
-                             it information.\r
-\r
-                             When the user selects a depth > 1, the search\r
-                             is first performed at depth=1 for both\r
-                             alternatives, then depth=2 for both alternatives,\r
-                             etc.\r
-\r
-      Sample output for rule grammar in antlr.g itself:\r
-\r
-  +---------------------------------------------------------------------+\r
-  | Ambiguity Aid                                                       |\r
-  |                                                                     |\r
-  |   Choice 1: grammar/70                 line 632  file a.g           |\r
-  |   Choice 2: grammar/82                 line 644  file a.g           |\r
-  |                                                                     |\r
-  |   Intersection of lookahead[1] sets:                                |\r
-  |                                                                     |\r
-  |      "\}"             "class"          "#errclass"      "#tokclass" |\r
-  |                                                                     |\r
-  |    Choice:1  Depth:1  Group:1  ("#errclass")                        |\r
-  |  1 in (...)* block                grammar/70       line 632   a.g   |\r
-  |  2 to error                       grammar/73       line 635   a.g   |\r
-  |  3 error                          error/1          line 894   a.g   |\r
-  |  4 #token "#errclass"             error/2          line 895   a.g   |\r
-  |                                                                     |\r
-  |    Choice:1  Depth:1  Group:2  ("#tokclass")                        |\r
-  |  2 to tclass                      grammar/74       line 636   a.g   |\r
-  |  3 tclass                         tclass/1         line 937   a.g   |\r
-  |  4 #token "#tokclass"             tclass/2         line 938   a.g   |\r
-  |                                                                     |\r
-  |    Choice:1  Depth:1  Group:3  ("class")                            |\r
-  |  2 to class_def                   grammar/75       line 637   a.g   |\r
-  |  3 class_def                      class_def/1      line 669   a.g   |\r
-  |  4 #token "class"                 class_def/3      line 671   a.g   |\r
-  |                                                                     |\r
-  |    Choice:1  Depth:1  Group:4  ("\}")                               |\r
-  |  2 #token "\}"                    grammar/76       line 638   a.g   |\r
-  |                                                                     |\r
-  |    Choice:2  Depth:1  Group:5  ("#errclass")                        |\r
-  |  1 in (...)* block                grammar/83       line 645   a.g   |\r
-  |  2 to error                       grammar/93       line 655   a.g   |\r
-  |  3 error                          error/1          line 894   a.g   |\r
-  |  4 #token "#errclass"             error/2          line 895   a.g   |\r
-  |                                                                     |\r
-  |    Choice:2  Depth:1  Group:6  ("#tokclass")                        |\r
-  |  2 to tclass                      grammar/94       line 656   a.g   |\r
-  |  3 tclass                         tclass/1         line 937   a.g   |\r
-  |  4 #token "#tokclass"             tclass/2         line 938   a.g   |\r
-  |                                                                     |\r
-  |    Choice:2  Depth:1  Group:7  ("class")                            |\r
-  |  2 to class_def                   grammar/95       line 657   a.g   |\r
-  |  3 class_def                      class_def/1      line 669   a.g   |\r
-  |  4 #token "class"                 class_def/3      line 671   a.g   |\r
-  |                                                                     |\r
-  |    Choice:2  Depth:1  Group:8  ("\}")                               |\r
-  |  2 #token "\}"                    grammar/96       line 658   a.g   |\r
-  +---------------------------------------------------------------------+\r
-\r
-      For a linear lookahead set ambiguity (where k=1 or for k>1 but\r
-      when all lookahead sets [i] with i<k all have degree one) the\r
-      reports appear in the following order:\r
-\r
-        for (depth=1 ; depth <= "-aad depth" ; depth++) {\r
-          for (alternative=1; alternative <=2 ; alternative++) {\r
-            while (matches-are-found) {\r
-              group++;\r
-              print-report\r
-            };\r
-          };\r
-       };\r
-\r
-      For reporting a k-tuple ambiguity, the reports appear in the\r
-      following order:\r
-\r
-        for (depth=1 ; depth <= "-aad depth" ; depth++) {\r
-          while (matches-are-found) {\r
-            for (alternative=1; alternative <=2 ; alternative++) {\r
-              group++;\r
-              print-report\r
-            };\r
-          };\r
-       };\r
-\r
-      This is because matches are generated in different ways for\r
-      linear lookahead and k-tuples.\r
-\r
-#117. (Changed in 1.33MR10) new EXPERIMENTAL predicate hoisting code\r
-\r
-      The hoisting of predicates into rules to create prediction\r
-      expressions is a problem in antlr.  Consider the following\r
-      example (k=1 with -prc on):\r
-\r
-        start   : (a)* "@" ;\r
-        a       : b | c ;\r
-        b       : <<isUpper(LATEXT(1))>>? A ;\r
-        c       : A ;\r
-\r
-      Prior to 1.33MR10 the code generated for "start" would resemble:\r
-\r
-        while {\r
-            if (LA(1)==A &&\r
-                    (!LA(1)==A || isUpper())) {\r
-              a();\r
-            }\r
-        };\r
-\r
-      This code is wrong because it makes rule "c" unreachable from\r
-      "start".  The essence of the problem is that antlr fails to\r
-      recognize that there can be a valid alternative within "a" even\r
-      when the predicate <<isUpper(LATEXT(1))>>? is false.\r
-\r
-      In 1.33MR10 with -mrhoist the hoisting of the predicate into\r
-      "start" is suppressed because it recognizes that "c" can\r
-      cover all the cases where the predicate is false:\r
-\r
-        while {\r
-            if (LA(1)==A) {\r
-              a();\r
-            }\r
-        };\r
-\r
-      With the antlr "-info p" switch the user will receive information\r
-      about the predicate suppression in the generated file:\r
-\r
-      --------------------------------------------------------------\r
-        #if 0\r
-\r
-        Hoisting of predicate suppressed by alternative without predicate.\r
-        The alt without the predicate includes all cases where\r
-            the predicate is false.\r
-\r
-           WITH predicate: line 7  v1.g\r
-           WITHOUT predicate: line 7  v1.g\r
-\r
-        The context set for the predicate:\r
-\r
-             A\r
-\r
-        The lookahead set for the alt WITHOUT the semantic predicate:\r
-\r
-             A\r
-\r
-        The predicate:\r
-\r
-          pred <<  isUpper(LATEXT(1))>>?\r
-                          depth=k=1  rule b  line 9  v1.g\r
-            set context:\r
-               A\r
-            tree context: null\r
-\r
-        Chain of referenced rules:\r
-\r
-            #0  in rule start (line 5 v1.g) to rule a\r
-            #1  in rule a (line 7 v1.g)\r
-\r
-        #endif\r
-      --------------------------------------------------------------\r
-\r
-      A predicate can be suppressed by a combination of alternatives\r
-      which, taken together, cover a predicate:\r
-\r
-        start   : (a)* "@" ;\r
-\r
-        a       : b | ca | cb | cc ;\r
-\r
-        b       : <<isUpper(LATEXT(1))>>? ( A | B | C ) ;\r
-\r
-        ca      : A ;\r
-        cb      : B ;\r
-        cc      : C ;\r
-\r
-      Consider a more complex example in which "c" covers only part of\r
-      a predicate:\r
-\r
-        start   : (a)* "@" ;\r
-\r
-        a       : b\r
-                | c\r
-                ;\r
-\r
-        b       : <<isUpper(LATEXT(1))>>?\r
-                    ( A\r
-                    | X\r
-                    );\r
-\r
-        c       : A\r
-                ;\r
-\r
-      Prior to 1.33MR10 the code generated for "start" would resemble:\r
-\r
-        while {\r
-            if ( (LA(1)==A || LA(1)==X) &&\r
-                    (! (LA(1)==A || LA(1)==X) || isUpper()) {\r
-              a();\r
-            }\r
-        };\r
-\r
-      With 1.33MR10 and -mrhoist the predicate context is restricted to\r
-      the non-covered lookahead.  The code resembles:\r
-\r
-        while {\r
-            if ( (LA(1)==A || LA(1)==X) &&\r
-                  (! (LA(1)==X) || isUpper()) {\r
-              a();\r
-            }\r
-        };\r
-\r
-      With the antlr "-info p" switch the user will receive information\r
-      about the predicate restriction in the generated file:\r
-\r
-      --------------------------------------------------------------\r
-        #if 0\r
-\r
-        Restricting the context of a predicate because of overlap\r
-          in the lookahead set between the alternative with the\r
-          semantic predicate and one without\r
-        Without this restriction the alternative without the predicate\r
-          could not be reached when input matched the context of the\r
-          predicate and the predicate was false.\r
-\r
-           WITH predicate: line 11  v4.g\r
-           WITHOUT predicate: line 12  v4.g\r
-\r
-        The original context set for the predicate:\r
-\r
-             A                X\r
-\r
-        The lookahead set for the alt WITHOUT the semantic predicate:\r
-\r
-             A\r
-\r
-        The intersection of the two sets\r
-\r
-             A\r
-\r
-        The original predicate:\r
-\r
-          pred <<  isUpper(LATEXT(1))>>?\r
-                          depth=k=1  rule b  line 15  v4.g\r
-            set context:\r
-               A                X\r
-            tree context: null\r
-\r
-        The new (modified) form of the predicate:\r
-\r
-          pred <<  isUpper(LATEXT(1))>>?\r
-                          depth=k=1  rule b  line 15  v4.g\r
-            set context:\r
-               X\r
-            tree context: null\r
-\r
-        #endif\r
-      --------------------------------------------------------------\r
-\r
-      The bad news about -mrhoist:\r
-\r
-        (a) -mrhoist does not analyze predicates with lookahead\r
-            depth > 1.\r
-\r
-        (b) -mrhoist does not look past a guarded predicate to\r
-            find context which might cover other predicates.\r
-\r
-      For these cases you might want to use syntactic predicates.\r
-      When a semantic predicate fails during guess mode the guess\r
-      fails and the next alternative is tried.\r
-\r
-      Limitation (a) is illustrated by the following example:\r
-\r
-        start    : (stmt)* EOF ;\r
-\r
-        stmt     : cast\r
-                 | expr\r
-                 ;\r
-        cast     : <<isTypename(LATEXT(2))>>? LP ID RP ;\r
-\r
-        expr     : LP ID RP ;\r
-\r
-      This is not much different from the first example, except that\r
-      it requires two tokens of lookahead context to determine what\r
-      to do.  This predicate is NOT suppressed because the current version\r
-      is unable to handle predicates with depth > 1.\r
-\r
-      A predicate can be combined with other predicates during hoisting.\r
-      In those cases the depth=1 predicates are still handled.  Thus,\r
-      in the following example the isUpper() predicate will be suppressed\r
-      by line #4 when hoisted from "bizarre" into "start", but will still\r
-      be present in "bizarre" in order to predict "stmt".\r
-\r
-        start    : (bizarre)* EOF ;     // #1\r
-                                        // #2\r
-        bizarre  : stmt                 // #3\r
-                 | A                    // #4\r
-                 ;\r
-\r
-        stmt     : cast\r
-                 | expr\r
-                 ;\r
-\r
-        cast     : <<isTypename(LATEXT(2))>>? LP ID RP ;\r
-\r
-        expr     : LP ID RP ;\r
-                 | <<isUpper(LATEXT(1))>>? A\r
-\r
-      Limitation (b) is illustrated by the following example of a\r
-      context guarded predicate:\r
-\r
-        rule : (A)? <<p>>?          // #1\r
-                     (A             // #2\r
-                     |B             // #3\r
-                     )              // #4\r
-             | <<q>> B              // #5\r
-             ;\r
-\r
-      Recall that this means that when the lookahead is NOT A then\r
-      the predicate "p" is ignored and it attempts to match "A|B".\r
-      Ideally, the "B" at line #3 should suppress predicate "q".\r
-      However, the current version does not attempt to look past\r
-      the guard predicate to find context which might suppress other\r
-      predicates.\r
-\r
-      In some cases -mrhoist will lead to the reporting of ambiguities\r
-      which were not visible before:\r
-\r
-        start   : (a)* "@";\r
-        a       : bc | d;\r
-        bc      : b  | c ;\r
-\r
-        b       : <<isUpper(LATEXT(1))>>? A;\r
-        c       : A ;\r
-\r
-        d       : A ;\r
-\r
-      In this case there is a true ambiguity in "a" between "bc" and "d"\r
-      which can both match "A".  Without -mrhoist the predicate in "b"\r
-      is hoisted into "a" and there is no ambiguity reported.  However,\r
-      with -mrhoist, the predicate in "b" is suppressed by "c" (as it\r
-      should be) making the ambiguity in "a" apparent.\r
-\r
-      The motivations for these changes were hoisting problems reported\r
-      by Reinier van den Born (reinier@vnet.ibm.com) and several others.\r
-\r
-#113. (Changed in 1.33MR10) new context guarded pred: (g)? && <<p>>? expr\r
-\r
-      The existing context guarded predicate:\r
-\r
-            rule : (guard)? => <<p>>? expr\r
-                 | next_alternative\r
-                 ;\r
-\r
-      generates code which resembles:\r
-\r
-            if (lookahead(expr) && (!guard || pred)) {\r
-              expr()\r
-            } else ....\r
-\r
-      This is not suitable for some applications because it allows\r
-      expr() to be invoked when the predicate is false.  This is\r
-      intentional because it is meant to mimic automatically computed\r
-      predicate context.\r
-\r
-      The new context guarded predicate uses the guard information\r
-      differently because it has a different goal.  Consider:\r
-\r
-            rule : (guard)? && <<p>>? expr\r
-                 | next_alternative\r
-                 ;\r
-\r
-      The new style of context guarded predicate is equivalent to:\r
-\r
-            rule : <<guard==true && pred>>? expr\r
-                 | next_alternative\r
-                 ;\r
-\r
-      It generates code which resembles:\r
-\r
-            if (lookahead(expr) && guard && pred) {\r
-                expr();\r
-            } else ...\r
-\r
-      Both forms of guarded predicates severely restrict the form of\r
-      the context guard: it can contain no rule references, no\r
-      (...)*, no (...)+, and no {...}.  It may contain token and\r
-      token class references, and alternation ("|").\r
-\r
-      Addition for 1.33MR11: in the token expression all tokens must\r
-      be at the same height of the token tree:\r
-\r
-            (A ( B | C))? && ...            is ok (all height 2)\r
-            (A ( B |  ))? && ...            is not ok (some 1, some 2)\r
-            (A B C D | E F G H)? && ...     is ok (all height 4)\r
-            (A B C D | E )? && ...          is not ok (some 4, some 1)\r
-\r
-      This restriction is required in order to properly compute the lookahead\r
-      set for expressions like:\r
-\r
-            rule1 : (A B C)? && <<pred>>? rule2 ;\r
-            rule2 : (A|X) (B|Y) (C|Z);\r
-\r
-      This addition was suggested by Rienier van den Born (reinier@vnet.ibm.com)\r
-\r
-#109. (Changed in 1.33MR10) improved trace information\r
-\r
-      The quality of the trace information provided by the "-gd"\r
-      switch has been improved significantly.  Here is an example\r
-      of the output from a test program.  It shows the rule name,\r
-      the first token of lookahead, the call depth, and the guess\r
-      status:\r
-\r
-        exit rule gusxx {"?"} depth 2\r
-        enter rule gusxx {"?"} depth 2\r
-        enter rule gus1 {"o"} depth 3 guessing\r
-        guess done - returning to rule gus1 {"o"} at depth 3\r
-                    (guess mode continues - an enclosing guess is still active)\r
-        guess done - returning to rule gus1 {"Z"} at depth 3\r
-                    (guess mode continues - an enclosing guess is still active)\r
-        exit rule gus1 {"Z"} depth 3 guessing\r
-        guess done - returning to rule gusxx {"o"} at depth 2 (guess mode ends)\r
-        enter rule gus1 {"o"} depth 3\r
-        guess done - returning to rule gus1 {"o"} at depth 3 (guess mode ends)\r
-        guess done - returning to rule gus1 {"Z"} at depth 3 (guess mode ends)\r
-        exit rule gus1 {"Z"} depth 3\r
-        line 1: syntax error at "Z" missing SC\r
-            ...\r
-\r
-      Rule trace reporting is controlled by the value of the integer\r
-      [zz]traceOptionValue:  when it is positive tracing is enabled,\r
-      otherwise it is disabled.  Tracing during guess mode is controlled\r
-      by the value of the integer [zz]traceGuessOptionValue.  When\r
-      it is positive AND [zz]traceOptionValue is positive rule trace\r
-      is reported in guess mode.\r
-\r
-      The values of [zz]traceOptionValue and [zz]traceGuessOptionValue\r
-      can be adjusted by subroutine calls listed below.\r
-\r
-      Depending on the presence or absence of the antlr -gd switch\r
-      the variable [zz]traceOptionValueDefault is set to 0 or 1.  When\r
-      the parser is initialized or [zz]traceReset() is called the\r
-      value of [zz]traceOptionValueDefault is copied to [zz]traceOptionValue.\r
-      The value of [zz]traceGuessOptionValue is always initialzed to 1,\r
-      but, as noted earlier, nothing will be reported unless\r
-      [zz]traceOptionValue is also positive.\r
-\r
-      When the parser state is saved/restored the value of the trace\r
-      variables are also saved/restored.  If a restore causes a change in\r
-      reporting behavior from on to off or vice versa this will be reported.\r
-\r
-      When the -gd option is selected, the macro "#define zzTRACE_RULES"\r
-      is added to appropriate output files.\r
-\r
-        C++ mode\r
-        --------\r
-        int     traceOption(int delta)\r
-        int     traceGuessOption(int delta)\r
-        void    traceReset()\r
-        int     traceOptionValueDefault\r
-\r
-        C mode\r
-        --------\r
-        int     zzTraceOption(int delta)\r
-        int     zzTraceGuessOption(int delta)\r
-        void    zzTraceReset()\r
-        int     zzTraceOptionValueDefault\r
-\r
-      The argument "delta" is added to the traceOptionValue.  To\r
-      turn on trace when inside a particular rule one:\r
-\r
-        rule : <<traceOption(+1);>>\r
-               (\r
-                rest-of-rule\r
-               )\r
-               <<traceOption(-1);>>\r
-       ;  /* fail clause */ <<traceOption(-1);>>\r
-\r
-      One can use the same idea to turn *off* tracing within a\r
-      rule by using a delta of (-1).\r
-\r
-      An improvement in the rule trace was suggested by Sramji\r
-      Ramanathan (ps@kumaran.com).\r
-\r
-#108. A Note on Deallocation of Variables Allocated in Guess Mode\r
-\r
-                            NOTE\r
-        ------------------------------------------------------\r
-        This mechanism only works for heap allocated variables\r
-        ------------------------------------------------------\r
-\r
-      The rewrite of the trace provides the machinery necessary\r
-      to properly free variables or undo actions following a\r
-      failed guess.\r
-\r
-      The macro zzUSER_GUESS_HOOK(guessSeq,zzrv) is expanded\r
-      as part of the zzGUESS macro.  When a guess is opened\r
-      the value of zzrv is 0.  When a longjmp() is executed to\r
-      undo the guess, the value of zzrv will be 1.\r
-\r
-      The macro zzUSER_GUESS_DONE_HOOK(guessSeq) is expanded\r
-      as part of the zzGUESS_DONE macro.  This is executed\r
-      whether the guess succeeds or fails as part of closing\r
-      the guess.\r
-\r
-      The guessSeq is a sequence number which is assigned to each\r
-      guess and is incremented by 1 for each guess which becomes\r
-      active.  It is needed by the user to associate the start of\r
-      a guess with the failure and/or completion (closing) of a\r
-      guess.\r
-\r
-      Guesses are nested.  They must be closed in the reverse\r
-      of the order that they are opened.\r
-\r
-      In order to free memory used by a variable during a guess\r
-      a user must write a routine which can be called to\r
-      register the variable along with the current guess sequence\r
-      number provided by the zzUSER_GUESS_HOOK macro. If the guess\r
-      fails, all variables tagged with the corresponding guess\r
-      sequence number should be released.  This is ugly, but\r
-      it would require a major rewrite of antlr 1.33 to use\r
-      some mechanism other than setjmp()/longjmp().\r
-\r
-      The order of calls for a *successful* guess would be:\r
-\r
-        zzUSER_GUESS_HOOK(guessSeq,0);\r
-        zzUSER_GUESS_DONE_HOOK(guessSeq);\r
-\r
-      The order of calls for a *failed* guess would be:\r
-\r
-        zzUSER_GUESS_HOOK(guessSeq,0);\r
-        zzUSER_GUESS_HOOK(guessSeq,1);\r
-        zzUSER_GUESS_DONE_HOOK(guessSeq);\r
-\r
-      The default definitions of these macros are empty strings.\r
-\r
-      Here is an example in C++ mode.  The zzUSER_GUESS_HOOK and\r
-      zzUSER_GUESS_DONE_HOOK macros and myGuessHook() routine\r
-      can be used without change in both C and C++ versions.\r
-\r
-      ----------------------------------------------------------------------\r
-        <<\r
-\r
-        #include "AToken.h"\r
-\r
-        typedef ANTLRCommonToken ANTLRToken;\r
-\r
-        #include "DLGLexer.h"\r
-\r
-        int main() {\r
-\r
-          {\r
-            DLGFileInput     in(stdin);\r
-            DLGLexer         lexer(&in,2000);\r
-            ANTLRTokenBuffer pipe(&lexer,1);\r
-            ANTLRCommonToken aToken;\r
-            P                parser(&pipe);\r
-\r
-            lexer.setToken(&aToken);\r
-            parser.init();\r
-            parser.start();\r
-          };\r
-\r
-          fclose(stdin);\r
-          fclose(stdout);\r
-          return 0;\r
-        }\r
-\r
-        >>\r
-\r
-        <<\r
-        char *s=NULL;\r
-\r
-        #undef zzUSER_GUESS_HOOK\r
-        #define zzUSER_GUESS_HOOK(guessSeq,zzrv) myGuessHook(guessSeq,zzrv);\r
-        #undef zzUSER_GUESS_DONE_HOOK\r
-        #define zzUSER_GUESS_DONE_HOOK(guessSeq)   myGuessHook(guessSeq,2);\r
-\r
-        void myGuessHook(int guessSeq,int zzrv) {\r
-          if (zzrv == 0) {\r
-            fprintf(stderr,"User hook: starting guess #%d\n",guessSeq);\r
-          } else if (zzrv == 1) {\r
-            free (s);\r
-            s=NULL;\r
-            fprintf(stderr,"User hook: failed guess #%d\n",guessSeq);\r
-          } else if (zzrv == 2) {\r
-            free (s);\r
-            s=NULL;\r
-            fprintf(stderr,"User hook: ending guess #%d\n",guessSeq);\r
-          };\r
-        }\r
-\r
-        >>\r
-\r
-        #token A    "a"\r
-        #token      "[\t \ \n]"     <<skip();>>\r
-\r
-        class P {\r
-\r
-        start : (top)+\r
-              ;\r
-\r
-        top   : (which) ?   <<fprintf(stderr,"%s is a which\n",s); free(s); s=NULL; >>\r
-              | other       <<fprintf(stderr,"%s is an other\n",s); free(s); s=NULL; >>\r
-              ; <<if (s != NULL) free(s); s=NULL; >>\r
-\r
-        which : which2\r
-              ;\r
-\r
-        which2 : which3\r
-              ;\r
-        which3\r
-              : (label)?         <<fprintf(stderr,"%s is a label\n",s);>>\r
-              | (global)?        <<fprintf(stderr,"%s is a global\n",s);>>\r
-              | (exclamation)?   <<fprintf(stderr,"%s is an exclamation\n",s);>>\r
-              ;\r
-\r
-        label :       <<s=strdup(LT(1)->getText());>> A ":" ;\r
-\r
-        global :      <<s=strdup(LT(1)->getText());>> A "::" ;\r
-\r
-        exclamation : <<s=strdup(LT(1)->getText());>> A "!" ;\r
-\r
-        other :       <<s=strdup(LT(1)->getText());>> "other" ;\r
-\r
-        }\r
-      ----------------------------------------------------------------------\r
-\r
-      This is a silly example, but illustrates the idea.  For the input\r
-      "a ::" with tracing enabled the output begins:\r
-\r
-      ----------------------------------------------------------------------\r
-        enter rule "start" depth 1\r
-        enter rule "top" depth 2\r
-        User hook: starting guess #1\r
-        enter rule "which" depth 3 guessing\r
-        enter rule "which2" depth 4 guessing\r
-        enter rule "which3" depth 5 guessing\r
-        User hook: starting guess #2\r
-        enter rule "label" depth 6 guessing\r
-        guess failed\r
-        User hook: failed guess #2\r
-        guess done - returning to rule "which3" at depth 5 (guess mode continues\r
-                                                 - an enclosing guess is still active)\r
-        User hook: ending guess #2\r
-        User hook: starting guess #3\r
-        enter rule "global" depth 6 guessing\r
-        exit rule "global" depth 6 guessing\r
-        guess done - returning to rule "which3" at depth 5 (guess mode continues\r
-                                                 - an enclosing guess is still active)\r
-        User hook: ending guess #3\r
-        enter rule "global" depth 6 guessing\r
-        exit rule "global" depth 6 guessing\r
-        exit rule "which3" depth 5 guessing\r
-        exit rule "which2" depth 4 guessing\r
-        exit rule "which" depth 3 guessing\r
-        guess done - returning to rule "top" at depth 2 (guess mode ends)\r
-        User hook: ending guess #1\r
-        enter rule "which" depth 3\r
-        .....\r
-      ----------------------------------------------------------------------\r
-\r
-      Remember:\r
-\r
-        (a) Only init-actions are executed during guess mode.\r
-        (b) A rule can be invoked multiple times during guess mode.\r
-        (c) If the guess succeeds the rule will be called once more\r
-              without guess mode so that normal actions will be executed.\r
-            This means that the init-action might need to distinguish\r
-              between guess mode and non-guess mode using the variable\r
-              [zz]guessing.\r
-\r
-#101. (Changed in 1.33MR10) antlr -info command line switch\r
-\r
-        -info\r
-\r
-            p   - extra predicate information in generated file\r
-\r
-            t   - information about tnode use:\r
-                    at the end of each rule in generated file\r
-                    summary on stderr at end of program\r
-\r
-            m   - monitor progress\r
-                    prints name of each rule as it is started\r
-                    flushes output at start of each rule\r
-\r
-            f   - first/follow set information to stdout\r
-\r
-            0   - no operation (added in 1.33MR11)\r
-\r
-      The options may be combined and may appear in any order.\r
-      For example:\r
-\r
-        antlr -info ptm -CC -gt -mrhoist on mygrammar.g\r
-\r
-#100a. (Changed in 1.33MR10) Predicate tree simplification\r
-\r
-      When the same predicates can be referenced in more than one\r
-      alternative of a block large predicate trees can be formed.\r
-\r
-      The difference that these optimizations make is so dramatic\r
-      that I have decided to use it even when -mrhoist is not selected.\r
-\r
-      Consider the following grammar:\r
-\r
-        start : ( all )* ;\r
-\r
-        all   : a\r
-              | d\r
-              | e\r
-              | f\r
-              ;\r
-\r
-        a     : c A B\r
-              | c A C\r
-              ;\r
-\r
-        c     : <<AAA(LATEXT(2))>>?\r
-              ;\r
-\r
-        d     : <<BBB(LATEXT(2))>>? B C\r
-              ;\r
-\r
-        e     : <<CCC(LATEXT(2))>>? B C\r
-              ;\r
-\r
-        f     : e X Y\r
-              ;\r
-\r
-      In rule "a" there is a reference to rule "c" in both alternatives.\r
-      The length of the predicate AAA is k=2 and it can be followed in\r
-      alternative 1 only by (A B) while in alternative 2 it can be\r
-      followed only by (A C).  Thus they do not have identical context.\r
-\r
-      In rule "all" the alternatives which refer to rules "e" and "f" allow\r
-      elimination of the duplicate reference to predicate CCC.\r
-\r
-      The table below summarized the kind of simplification performed by\r
-      1.33MR10.  In the table, X and Y stand for single predicates\r
-      (not trees).\r
-\r
-        (OR X (OR Y (OR Z)))  => (OR X Y Z)\r
-        (AND X (AND Y (AND Z)))  => (AND X Y Z)\r
-\r
-        (OR X  (... (OR  X Y) ... ))     => (OR X (... Y ... ))\r
-        (AND X (... (AND X Y) ... ))     => (AND X (... Y ... ))\r
-        (OR X  (... (AND X Y) ... ))     => (OR X (...  ... ))\r
-        (AND X (... (OR  X Y) ... ))     => (AND X (...  ... ))\r
-\r
-        (AND X)               => X\r
-        (OR X)                => X\r
-\r
-      In a test with a complex grammar for a real application, a predicate\r
-      tree with six OR nodes and 12 leaves was reduced to "(OR X Y Z)".\r
-\r
-      In 1.33MR10 there is a greater effort to release memory used\r
-      by predicates once they are no longer in use.\r
-\r
-#100b. (Changed in 1.33MR10) Suppression of extra predicate tests\r
-\r
-      The following optimizations require that -mrhoist be selected.\r
-\r
-      It is relatively easy to optimize the code generated for predicate\r
-      gates when they are of the form:\r
-\r
-            (AND X Y Z ...)\r
-        or  (OR  X Y Z ...)\r
-\r
-      where X, Y, Z, and "..." represent individual predicates (leaves) not\r
-      predicate trees.\r
-\r
-      If the predicate is an AND the contexts of the X, Y, Z, etc. are\r
-      ANDed together to create a single Tree context for the group and\r
-      context tests for the individual predicates are suppressed:\r
-\r
-            --------------------------------------------------\r
-            Note: This was incorrect.  The contexts should be\r
-            ORed together.  This has been fixed.  A more \r
-            complete description is available in item #152.\r
-            ---------------------------------------------------\r
-\r
-      Optimization 1:  (AND X Y Z ...)\r
-\r
-        Suppose the context for Xtest is LA(1)==LP and the context for\r
-        Ytest is LA(1)==LP && LA(2)==ID.\r
-\r
-            Without the optimization the code would resemble:\r
-\r
-                if (lookaheadContext &&\r
-                    !(LA(1)==LP && LA(1)==LP && LA(2)==ID) ||\r
-                        ( (! LA(1)==LP || Xtest) &&\r
-                          (! (LA(1)==LP || LA(2)==ID) || Xtest)\r
-                        )) {...\r
-\r
-            With the -mrhoist optimization the code would resemble:\r
-\r
-                if (lookaheadContext &&\r
-                    ! (LA(1)==LP && LA(2)==ID) || (Xtest && Ytest) {...\r
-\r
-      Optimization 2: (OR X Y Z ...) with identical contexts\r
-\r
-        Suppose the context for Xtest is LA(1)==ID and for Ytest\r
-        the context is also LA(1)==ID.\r
-\r
-            Without the optimization the code would resemble:\r
-\r
-                if (lookaheadContext &&\r
-                    ! (LA(1)==ID || LA(1)==ID) ||\r
-                        (LA(1)==ID && Xtest) ||\r
-                        (LA(1)==ID && Ytest) {...\r
-\r
-            With the -mrhoist optimization the code would resemble:\r
-\r
-                if (lookaheadContext &&\r
-                    (! LA(1)==ID) || (Xtest || Ytest) {...\r
-\r
-      Optimization 3: (OR X Y Z ...) with distinct contexts\r
-\r
-        Suppose the context for Xtest is LA(1)==ID and for Ytest\r
-        the context is LA(1)==LP.\r
-\r
-            Without the optimization the code would resemble:\r
-\r
-                if (lookaheadContext &&\r
-                    ! (LA(1)==ID || LA(1)==LP) ||\r
-                        (LA(1)==ID && Xtest) ||\r
-                        (LA(1)==LP && Ytest) {...\r
-\r
-            With the -mrhoist optimization the code would resemble:\r
-\r
-                if (lookaheadContext &&\r
-                        (zzpf=0,\r
-                            (LA(1)==ID && (zzpf=1) && Xtest) ||\r
-                            (LA(1)==LP && (zzpf=1) && Ytest) ||\r
-                            !zzpf) {\r
-\r
-            These may appear to be of similar complexity at first,\r
-            but the non-optimized version contains two tests of each\r
-            context while the optimized version contains only one\r
-            such test, as well as eliminating some of the inverted\r
-            logic (" !(...) || ").\r
-\r
-      Optimization 4: Computation of predicate gate trees\r
-\r
-        When generating code for the gates of predicate expressions\r
-        antlr 1.33 vanilla uses a recursive procedure to generate\r
-        "&&" and "||" expressions for testing the lookahead. As each\r
-        layer of the predicate tree is exposed a new set of "&&" and\r
-        "||" expressions on the lookahead are generated.  In many\r
-        cases the lookahead being tested has already been tested.\r
-\r
-        With -mrhoist a lookahead tree is computed for the entire\r
-        lookahead expression.  This means that predicates with identical\r
-        context or context which is a subset of another predicate's\r
-        context disappear.\r
-\r
-        This is especially important for predicates formed by rules\r
-        like the following:\r
-\r
-            uppperCaseVowel : <<isUpperCase(LATEXT(1))>>?  vowel;\r
-            vowel:          : <<isVowel(LATEXT(1))>>? LETTERS;\r
-\r
-        These predicates are combined using AND since both must be\r
-        satisfied for rule upperCaseVowel.  They have identical\r
-        context which makes this optimization very effective.\r
-\r
-      The affect of Items #100a and #100b together can be dramatic.  In\r
-      a very large (but real world) grammar one particular predicate\r
-      expression was reduced from an (unreadable) 50 predicate leaves,\r
-      195 LA(1) terms, and 5500 characters to an (easily comprehensible)\r
-      3 predicate leaves (all different) and a *single* LA(1) term.\r
-\r
-#98.  (Changed in 1.33MR10) Option "-info p"\r
-\r
-      When the user selects option "-info p" the program will generate\r
-      detailed information about predicates.  If the user selects\r
-      "-mrhoist on" additional detail will be provided explaining\r
-      the promotion and suppression of predicates.  The output is part\r
-      of the generated file and sandwiched between #if 0/#endif statements.\r
-\r
-      Consider the following k=1 grammar:\r
-\r
-        start : ( all ) * ;\r
-\r
-        all   : ( a\r
-                | b\r
-                )\r
-                ;\r
-\r
-        a     : c B\r
-              ;\r
-\r
-        c     : <<LATEXT(1)>>?\r
-              | B\r
-              ;\r
-\r
-        b     : <<LATEXT(1)>>? X\r
-              ;\r
-\r
-      Below is an excerpt of the output for rule "start" for the three\r
-      predicate options (off, on, and maintenance release style hoisting).\r
-\r
-      For those who do not wish to use the "-mrhoist on" option for code\r
-      generation the option can be used in a "diagnostic" mode to provide\r
-      valuable information:\r
-\r
-            a. where one should insert null actions to inhibit hoisting\r
-            b. a chain of rule references which shows where predicates are\r
-               being hoisted\r
-\r
-      ======================================================================\r
-      Example of "-info p" with "-mrhoist on"\r
-      ======================================================================\r
-        #if 0\r
-\r
-        Hoisting of predicate suppressed by alternative without predicate.\r
-        The alt without the predicate includes all cases where the\r
-           predicate is false.\r
-\r
-           WITH predicate: line 11  v36.g\r
-           WITHOUT predicate: line 12  v36.g\r
-\r
-        The context set for the predicate:\r
-\r
-             B\r
-\r
-        The lookahead set for alt WITHOUT the semantic predicate:\r
-\r
-             B\r
-\r
-        The predicate:\r
-\r
-          pred <<  LATEXT(1)>>?  depth=k=1  rule c  line 11  v36.g\r
-\r
-            set context:\r
-               B\r
-            tree context: null\r
-\r
-        Chain of referenced rules:\r
-\r
-            #0  in rule start (line 1 v36.g) to rule all\r
-            #1  in rule all (line 3 v36.g) to rule a\r
-            #2  in rule a (line 8 v36.g) to rule c\r
-            #3  in rule c (line 11 v36.g)\r
-\r
-        #endif\r
-        &&\r
-        #if 0\r
-\r
-        pred <<  LATEXT(1)>>?  depth=k=1  rule b  line 15  v36.g\r
-\r
-          set context:\r
-             X\r
-          tree context: null\r
-\r
-        #endif\r
-      ======================================================================\r
-      Example of "-info p"  with the default -prc setting ( "-prc off")\r
-      ======================================================================\r
-        #if 0\r
-\r
-        OR\r
-          pred <<  LATEXT(1)>>?  depth=k=1  rule c  line 11  v36.g\r
-\r
-            set context:\r
-              nil\r
-            tree context: null\r
-\r
-          pred <<  LATEXT(1)>>?  depth=k=1  rule b  line 15  v36.g\r
-\r
-            set context:\r
-              nil\r
-            tree context: null\r
-\r
-        #endif\r
-      ======================================================================\r
-      Example of "-info p" with "-prc on" and "-mrhoist off"\r
-      ======================================================================\r
-        #if 0\r
-\r
-        OR\r
-          pred <<  LATEXT(1)>>?  depth=k=1  rule c  line 11  v36.g\r
-\r
-            set context:\r
-               B\r
-            tree context: null\r
-\r
-          pred <<  LATEXT(1)>>?  depth=k=1  rule b  line 15  v36.g\r
-\r
-            set context:\r
-               X\r
-            tree context: null\r
-\r
-        #endif\r
-      ======================================================================\r
-\r
-#60.  (Changed in 1.33MR7) Major changes to exception handling\r
-\r
-        There were significant problems in the handling of exceptions\r
-        in 1.33 vanilla.  The general problem is that it can only\r
-        process one level of exception handler.  For example, a named\r
-        exception handler, an exception handler for an alternative, or\r
-        an exception for a subrule  always went to the rule's exception\r
-        handler if there was no "catch" which matched the exception.\r
-\r
-        In 1.33MR7 the exception handlers properly "nest".  If an\r
-        exception handler does not have a matching "catch" then the\r
-        nextmost outer exception handler is checked for an appropriate\r
-        "catch" clause, and so on until an exception handler with an\r
-        appropriate "catch" is found.\r
-\r
-        There are still undesirable features in the way exception\r
-        handlers are implemented, but I do not have time to fix them\r
-        at the moment:\r
-\r
-            The exception handlers for alternatives are outside the\r
-            block containing the alternative.  This makes it impossible\r
-            to access variables declared in a block or to resume the\r
-            parse by "falling through".  The parse can still be easily\r
-            resumed in other ways, but not in the most natural fashion.\r
-\r
-            This results in an inconsistentcy between named exception\r
-            handlers and exception handlers for alternatives.  When\r
-            an exception handler for an alternative "falls through"\r
-            it goes to the nextmost outer handler - not the "normal\r
-            action".\r
-\r
-        A major difference between 1.33MR7 and 1.33 vanilla is\r
-        the default action after an exception is caught:\r
-\r
-            1.33 Vanilla\r
-            ------------\r
-            In 1.33 vanilla the signal value is set to zero ("NoSignal")\r
-            and the code drops through to the code following the exception.\r
-            For named exception handlers this is the "normal action".\r
-            For alternative exception handlers this is the rule's handler.\r
-\r
-            1.33MR7\r
-            -------\r
-            In 1.33MR7 the signal value is NOT automatically set to zero.\r
-\r
-            There are two cases:\r
-\r
-                For named exception handlers: if the signal value has been\r
-                set to zero the code drops through to the "normal action".\r
-\r
-                For all other cases the code branches to the nextmost outer\r
-                exception handler until it reaches the handler for the rule.\r
-\r
-        The following macros have been defined for convenience:\r
-\r
-            C/C++ Mode Name\r
-            --------------------\r
-            (zz)suppressSignal\r
-                  set signal & return signal arg to 0 ("NoSignal")\r
-            (zz)setSignal(intValue)\r
-                  set signal & return signal arg to some value\r
-            (zz)exportSignal\r
-                  copy the signal value to the return signal arg\r
-\r
-        I'm not sure why PCCTS make a distinction between the local\r
-        signal value and the return signal argument, but I'm loathe\r
-        to change the code. The burden of copying the local signal\r
-        value to the return signal argument can be given to the\r
-        default signal handler, I suppose.\r
-\r
-#53.  (Explanation for 1.33MR6) What happens after an exception is caught ?\r
-\r
-        The Book is silent about what happens after an exception\r
-        is caught.\r
-\r
-        The following code fragment prints "Error Action" followed\r
-        by "Normal Action".\r
-\r
-        test : Word ex:Number <<printf("Normal Action\n");>>\r
-                exception[ex]\r
-                   catch NoViableAlt:\r
-                        <<printf("Error Action\n");>>\r
-        ;\r
-\r
-        The reason for "Normal Action" is that the normal flow of the\r
-        program after a user-written exception handler is to "drop through".\r
-        In the case of an exception handler for a rule this results in\r
-        the exection of a "return" statement.  In the case of an\r
-        exception handler attached to an alternative, rule, or token\r
-        this is the code that would have executed had there been no\r
-        exception.\r
-\r
-        The user can achieve the desired result by using a "return"\r
-        statement.\r
-\r
-        test : Word ex:Number <<printf("Normal Action\n");>>\r
-                exception[ex]\r
-                   catch NoViableAlt:\r
-                        <<printf("Error Action\n"); return;>>\r
-        ;\r
-\r
-        The most powerful mechanism for recovery from parse errors\r
-        in pccts is syntactic predicates because they provide\r
-        backtracking.  Exceptions allow "return", "break",\r
-        "consumeUntil(...)", "goto _handler", "goto _fail", and\r
-        changing the _signal value.\r
-\r
-#41.  (Added in 1.33MR6) antlr -stdout\r
-\r
-        Using "antlr -stdout ..." forces the text that would\r
-        normally go to the grammar.c or grammar.cpp file to\r
-        stdout.\r
-\r
-#40.  (Added in 1.33MR6) antlr -tab to change tab stops\r
-\r
-        Using "antlr -tab number ..." changes the tab stops\r
-        for the grammar.c or grammar.cpp file.  The number\r
-        must be between 0 and 8.  Using 0 gives tab characters,\r
-        values between 1 and 8 give the appropriate number of\r
-        space characters.\r
-\r
-#34.  (Added to 1.33MR1) Add public DLGLexerBase::set_line(int newValue)\r
-\r
-        Previously there was no public function for changing the line\r
-        number maintained by the lexer.\r
-\r
-#28.   (Added to 1.33MR1) More control over DLG header\r
-\r
-        Version 1.33MR1 adds the following directives to PCCTS\r
-        for C++ mode:\r
-\r
-          #lexprefix  <<source code>>\r
-\r
-                Adds source code to the DLGLexer.h file\r
-                after the #include "DLexerBase.h" but\r
-                before the start of the class definition.\r
-\r
-          #lexmember  <<source code>>\r
-\r
-                Adds source code to the DLGLexer.h file\r
-                as part of the DLGLexer class body.  It\r
-                appears immediately after the start of\r
-                the class and a "public: statement.\r
-\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/KNOWN_PROBLEMS.txt b/Tools/CodeTools/TianoTools/Pccts/KNOWN_PROBLEMS.txt
deleted file mode 100644 (file)
index 5a9b22e..0000000
+++ /dev/null
@@ -1,241 +0,0 @@
-\r
-    =======================================================\r
-    Known Problems In PCCTS - Last revised 14 November 1998\r
-    =======================================================\r
-\r
-#17. The dlg fix for handling characters up to 255 is incorrect.\r
-\r
-    See item #207.\r
-\r
-    Reported by Frank Hartmann.\r
-        \r
-#16. A note about "&&" predicates (Mike Dimmick)\r
-\r
-    Mike Dimmick has pointed out a potential pitfall in the use of the\r
-    "&&" style predicate.  Consider:\r
-    \r
-         r0: (g)? => <<P>>?  r1\r
-             | ...\r
-             ;\r
-         r1: A | B;\r
-         \r
-    If the context guard g is not a subset of the lookahead context for r1\r
-    (in other words g is neither A nor B) then the code may execute r1 \r
-    even when the lookahead context is not satisfied.  This is an error\r
-    by the person coding the grammer, and the error should be reported to\r
-    the user, but it isn't. expect.  Some examples I've run seem to\r
-    indicate that such an error actually results in the rule becoming\r
-    unreachable.\r
-    \r
-    When g is properly coded the code is correct, the problem is when g\r
-    is not properly coded.\r
-    \r
-    A second problem reported by Mike Dimmick is that the test for a\r
-    failed validation predicate is equivalent to a test on the predicate\r
-    along.  In other words, if the "&&" has not been hoisted then it may\r
-    falsely report a validation error.\r
-\r
-#15. (Changed in MR23) Warning for LT(i), LATEXT(i) in token match actions\r
-\r
-    An bug (or at least an oddity) is that a reference to LT(1), LA(1),\r
-    or LATEXT(1) in an action which immediately follows a token match\r
-    in a rule refers to the token matched, not the token which is in\r
-    the lookahead buffer.  Consider:\13\r
-\r
-        r : abc <<action alpha>> D <<action beta>> E;\r
-\r
-    In this case LT(1) in action alpha will refer to the next token in\r
-    the lookahead buffer ("D"), but LT(1) in action beta will refer to\r
-    the token matched by D - the preceding token.\r
-\r
-    A warning has been added which warns users about this when an action\r
-    following a token match contains a reference to LT(1), LA(1), or LATEXT(1).\r
-\r
-    This behavior should be changed, but it appears in too many programs\r
-    now.  Another problem, perhaps more significant, is that the obvious\r
-    fix (moving the consume() call to before the action) could change the \r
-    order in which input is requested and output appears in existing programs.\r
-\r
-    This problem was reported, along with a fix by Benjamin Mandel\r
-    (beny@sd.co.il).  However, I felt that changing the behavior was too\r
-    dangerous for existing code.\r
-\r
-#14. Parsing bug in dlg\r
-\r
-    THM: I have been unable to reproduce this problem.\r
-\r
-    Reported by Rick Howard Mijenix Corporation (rickh@mijenix.com).\r
-\r
-    The regular expression parser (in rexpr.c) fails while\r
-    trying to parse the following regular expression:\r
-\r
-            {[a-zA-Z]:}(\\\\[a-zA-Z0-9]*)+\r
-\r
-    See my comment in the following excerpt from rexpr.c:\r
-\r
-    /*\r
-     * <regExpr>        ::= <andExpr> ( '|' {<andExpr>} )*\r
-     *\r
-     * Return -1 if syntax error\r
-     * Return  0 if none found\r
-     * Return  1 if a regExrp was found\r
-     */\r
-       static\r
-       regExpr(g)\r
-       GraphPtr g;\r
-       {\r
-           Graph g1, g2;\r
-       \r
-           if ( andExpr(&g1) == -1 )\r
-           {\r
-               return -1;\r
-           }\r
-       \r
-           while ( token == '|' )\r
-           {\r
-               int a;\r
-               next();\r
-               a = andExpr(&g2);\r
-               if ( a == -1 ) return -1;   /* syntax error below */\r
-               else if ( !a ) return 1;    /* empty alternative */\r
-               g1 = BuildNFA_AorB(g1, g2);\r
-           }\r
-       \r
-           if ( token!='\0' ) return -1;\r
-       *****\r
-       ***** It appears to fail here becuause token is 125 - the closing '}'\r
-       ***** If I change it to:\r
-       *****    if ( token!='\0' && token!='}' && token!= ')' ) return -1;\r
-       *****\r
-       ***** It succeeds, but I'm not sure this is the corrrect approach.\r
-       *****\r
-           *g = g1;\r
-           return 1;\r
-       }\r
-\r
-#13. dlg reports an invalid range for: [\0x00-\0xff]\r
-\r
-    Diagnosed by Piotr Eljasiak (eljasiak@no-spam.zt.gdansk.tpsa.pl):\r
-\r
-    Fixed in MR16.\r
-\r
-#12. Strings containing comment actions\r
-\r
-     Sequences that looked like C style comments appearing in string\r
-     literals are improperly parsed by antlr/dlg.\r
-\r
-        << fprintf(out," /* obsolete */ ");\r
-\r
-     For this case use:\r
-\r
-        << fprintf(out," \/\* obsolete \*\/ ");\r
-\r
-     Reported by K.J. Cummings (cummings@peritus.com).\r
-\r
-#11. User hook for deallocation of variables on guess fail\r
-\r
-     The mechanism outlined in Item #108 works only for\r
-     heap allocated variables.\r
-\r
-#10. Label re-initialization in ( X {y:Y} )*\r
-\r
-     If a label assignment is optional and appears in a\r
-     (...)* or (...)+ block it will not be reset to NULL\r
-     when it is skipped by a subsequent iteration.\r
-\r
-     Consider the example:\r
-\r
-            ( X { y:Y })* Z\r
-\r
-     with input:\r
-\r
-            X Y X Z\r
-\r
-     The first time through the block Y will be matched and\r
-     y will be set to point to the token.  On the second\r
-     iteration of the (...)* block there is no match for Y.\r
-     But y will not be reset to NULL, as the user might\r
-     expect, it will contain a reference to the Y that was\r
-     matched in the first iteration.\r
-\r
-     The work-around is to manually reset y:\r
-\r
-            ( X << y = NULL; >> { y:Y } )* Z\r
-\r
-        or\r
-\r
-            ( X ( y:Y | << y = NULL; >> /* epsilon */ ) )* Z\r
-\r
-     Reported by Jeff Vincent (JVincent@novell.com).\r
-\r
-#9. PCCTAST.h PCCTSAST::setType() is a noop\r
-\r
-#8. #tokdefs with ~Token and .\r
-\r
-    THM: I have been unable to reproduce this problem.\r
-\r
-    When antlr uses #tokdefs to define tokens the fields of\r
-    #errclass and #tokclass do not get properly defined.\r
-    When it subsequently attempts to take the complement of\r
-    the set of tokens (using ~Token or .) it can refer to\r
-    tokens which don't have names, generating a fatal error.\r
-\r
-#7. DLG crashes on some invalid inputs\r
-\r
-    THM:  In MR20 have fixed the most common cases.\r
-\r
-    The following token defintion will cause DLG to crash.\r
-\r
-        #token "()"\r
-\r
-    Reported by  Mengue Olivier (dolmen@bigfoot.com).\r
-\r
-#6. On MS systems \n\r is treated as two new lines\r
-\r
-    Fixed.\r
-\r
-#5. Token expressions in #tokclass\r
-\r
-    #errclass does not support TOK1..TOK2 or ~TOK syntax.\r
-    #tokclass does not support ~TOKEN syntax\r
-\r
-    A workaround for #errclass TOK1..TOK2 is to use a\r
-    #tokclass.\r
-\r
-    Reported by Dave Watola (dwatola@amtsun.jpl.nasa.gov)\r
-\r
-#4. A #tokdef must appear "early" in the grammar file.\r
-\r
-    The "early" section of the grammar file is the only\r
-    place where the following directives may appear:\r
-\r
-        #header\r
-        #first\r
-        #tokdefs\r
-        #parser\r
-\r
-    Any other kind of statement signifiies the end of the\r
-    "early" section.\r
-\r
-#3. Use of PURIFY macro for C++ mode\r
-\r
-    Item #93 of the CHANGES_FROM_1.33 describes the use of\r
-    the PURIFY macro to zero arguments to be passed by\r
-    upward inheritance.\r
-\r
-        #define PURIFY(r, s) memset((char *) &(r), '\0', (s));\r
-\r
-    This may not be the right thing to do for C++ objects that\r
-    have constructors.  Reported by Bonny Rais (bonny@werple.net.au).\r
-\r
-    For those cases one should #define PURIFY to be an empty macro\r
-    in the #header or #first actions.\r
-\r
-#2. Fixed in 1.33MR10 - See CHANGES_FROM_1.33 Item #80.\r
-\r
-#1. The quality of support for systems with 8.3 file names leaves\r
-    much to be desired.  Since the kit is distributed using the\r
-    long file names and the make file uses long file names it requires\r
-    some effort to generate.  This will probably not be changed due\r
-    to the large number of systems already written using the long\r
-    file names.\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/MPW_Read_Me b/Tools/CodeTools/TianoTools/Pccts/MPW_Read_Me
deleted file mode 100644 (file)
index 70a9d1b..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-\r
-1. You can control the creator type of generated files by changing a value of\r
-   #if control statement.\r
-\r
-\r
-   pccts:h:pcctscfg.h\r
-\r
-   line 225-231\r
-\r
-       #if 0\r
-       #define MAC_FILE_CREATOR 'MPS '   /* MPW Text files */\r
-       #endif\r
-       #if 0\r
-       #define MAC_FILE_CREATOR 'KAHL'   /* THINK C/Symantec C++ Text files */\r
-       #endif\r
-       #if 0\r
-       #define MAC_FILE_CREATOR 'CWIE'   /* Metrowerks C/C++ Text files */\r
-       #endif\r
-\r
-2.  If you want to build 68K version. You must convert all source files to Macintosh\r
-    format before compile.\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/NOTES.bcc b/Tools/CodeTools/TianoTools/Pccts/NOTES.bcc
deleted file mode 100644 (file)
index 1ac05b1..0000000
+++ /dev/null
@@ -1,184 +0,0 @@
-March 95\r
-Version 1.32 of pccts\r
\r
-At the moment this file is available via anonymous FTP at\r
\r
-        Node: marvin.ecn.purdue.edu\r
-        File: pub/pccts/1.32/NOTES.BCC\r
\r
-Mail corrections or additions to David Seidel <71333.1575@compuserve.com>\r
-===============================================================================\r
-Notes on Building PCCTS 1.32 with Borland C++\r
\r
-David Seidel, Innovative Data Concepts Incorporated\r
-CompuServe: 71333,1575\r
-Internet:   71333.1575@compuserve.com\r
-            dseidel@delphi.com\r
\r
-I have gotten ANTLR and DLG to succesfully build with BCC 4.0, but have found\r
-from experience that ANTLR, in particular, is likely to run out of memory\r
-with grammars over a certain size, or with larger values for the -k and -ck\r
-options.  Now that BCC 4.02 and the new Borland Power Pack for DOS is now\r
-available, I feel that there is no excuse not to build these tools as\r
-32-bit executables, as they ought to be.\r
\r
-For people without the Power Pack, the makefiles below should be fairly easily\r
-modified to build 16-bit real-mode executables, but I don't really recommend\r
-it.  As an alternative, you might consider the highly regarded DJGPP compiler\r
-(a DOS port of the Gnu GCC compiler, with a DOS extender included).  Hopefully\r
-some other PCCTS who has DJGPP can provode whatever advice is necessary.  The\r
-Watcom compiler is also an excellent possibility (albeit a commercial one),\r
-and I hope to make available Watcom makefiles in the near future.\r
\r
-Here are the makefiles I am using.  Both makefiles use a compiler configuration\r
-file that contains compiler switches such as optimization settings.  I call\r
-this file bor32.cfg and keep a copy in both the ANTLR and DLG subdirectories.\r
\r
-==== File: bor32.cfg (cut here) ===============================================\r
--w-\r
--RT-\r
--x-\r
--N-\r
--k-\r
--d\r
--O2-e-l\r
--Z\r
--D__STDC__=1\r
-==== End of file bor32.cfg (cut here) =========================================\r
\r
-==== File: antlr\bor32.mak (cut here) =========================================\r
-#\r
-#  ANTLR 1.32 Makefile for Borland C++ 4.02 with DPMI 32-bit DOS extender by\r
-#  David Seidel\r
-#  Innovative Data Concepts Incorporated\r
-#  71333.1575@compuserve.com (or) dseidel@delphi.com\r
-#\r
-#  Notes:   1. Compiler switches (optimization etc.) are contained in the\r
-#              file bor32.cfg.\r
-#           2. This makefile requires Borland C++ 4.02 or greater with\r
-#              the DOS Power Pack add-on package.\r
-#           3. Change the BCCDIR macro below to the topmost directory in\r
-#              which BCC is installed on your system.\r
-#\r
\r
-BCCDIR   =  d:\bc4\r
-CC       =  bcc32\r
-SET      =  ..\support\set\r
-PCCTS_H  =  ..\h\r
-ANTLR    =  ..\bin\antlr\r
-DLG      =  ..\bin\dlg\r
-CFLAGS   =  -I$(BCCDIR)\include -I. -I$(SET) -I$(PCCTS_H) -DUSER_ZZSYN \\r
- +bor32.cfg\r
-LIBS     =  dpmi32 cw32\r
-OBJ_EXT  =  obj\r
-OBJS     =  antlr.obj scan.obj err.obj bits.obj build.obj fset2.obj fset.obj \\r
- gen.obj globals.obj hash.obj lex.obj main.obj misc.obj pred.obj dialog.obj \\r
- set.obj\r
\r
-.c.obj:\r
-      $(CC) -c $(CFLAGS) {$&.c }\r
\r
-antlr.exe: $(OBJS)\r
-   tlink32 @&&|\r
--Tpe -ax -c -s -L$(BCCDIR)\lib +\r
-$(BCCDIR)\lib\c0x32 $**\r
-$@\r
\r
-$(LIBS)\r
-;\r
-|\r
-   copy *.exe ..\bin\r
\r
\r
-# *********** Target list of PC machines ***********\r
-#\r
-# Don't worry about the ambiguity messages coming from antlr\r
-# for making antlr.c etc...  [should be 10 of them, I think]\r
-#\r
\r
-# leave this commented out for initial build!\r
-#antlr.c stdpccts.h parser.dlg tokens.h err.c : antlr.g\r
-#   $(ANTLR) antlr.g\r
\r
-antlr.$(OBJ_EXT): antlr.c mode.h tokens.h\r
\r
-scan.$(OBJ_EXT): scan.c mode.h tokens.h\r
\r
-# leave this commented out for initial build!\r
-#scan.c mode.h: parser.dlg\r
-#   $(DLG) -C2 parser.dlg scan.c\r
\r
-set.$(OBJ_EXT): $(SET)\set.c\r
-   $(CC) -c $(CFLAGS) $(SET)\set.c\r
\r
-==== End of file antlr\bor32.mak (cut here) ===================================\r
\r
-==== File: dlg\bor32.mak (cut here) ===========================================\r
-#\r
-#  DLG 1.32 Makefile for Borland C++ 4.02 with DPMI 32-bit DOS extender by\r
-#  David Seidel\r
-#  Innovative Data Concepts Incorporated\r
-#  71333.1575@compuserve.com (or) dseidel@delphi.com\r
-#\r
-#  Notes:   1. Compiler switches (optimization etc.) are contained in the\r
-#              file bor32.cfg.\r
-#           2. This makefile requires Borland C++ 4.02 or greater with\r
-#              the DOS Power Pack add-on package.\r
-#           3. Change the BCCDIR macro below to the topmost directory in\r
-#              which BCC is installed on your system.\r
-#\r
\r
\r
-BCCDIR   =  d:\bc4\r
-CC       =  bcc32\r
-SET      =  ..\support\set\r
-PCCTS_H  =  ..\h\r
-ANTLR    =  ..\bin\antlr\r
-DLG      =  ..\bin\dlg\r
-CFLAGS   =  -I$(BCCDIR)\include -I. -I$(SET) -I$(PCCTS_H) -DUSER_ZZSYN \\r
- +bor32.cfg\r
-LIBS     =  dpmi32 cw32\r
-OBJ_EXT  =  obj\r
-OBJS     =  dlg_p.obj dlg_a.obj main.obj err.obj support.obj \\r
- output.obj relabel.obj automata.obj set.obj\r
\r
-.c.obj:\r
-      $(CC) -c $(CFLAGS) {$&.c }\r
\r
-dlg.exe : $(OBJS)\r
-   tlink32 @&&|\r
--Tpe -ax -c -s -L$(BCCDIR)\lib +\r
-c0x32 $**\r
-$@\r
\r
-$(LIBS)\r
-;\r
-|\r
-   copy *.exe ..\bin\r
\r
-dlg_p.obj:  dlg_p.c\r
\r
-dlg_a.obj:  dlg_a.c\r
\r
-main.obj:   main.c\r
\r
-err.obj:    err.c\r
\r
-support.obj:   support.c\r
\r
-output.obj: output.c\r
\r
-relabel.obj:   relabel.c\r
\r
-automata.obj:  automata.c\r
\r
-set.$(OBJ_EXT): $(SET)\set.c\r
-   $(CC) -c $(CFLAGS) $(SET)\set.c\r
\r
-==== End of file dlg\bor32.mak (cut here) =====================================\r
\r
\r
\r
-\r
-\r
-\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/NOTES.msvc b/Tools/CodeTools/TianoTools/Pccts/NOTES.msvc
deleted file mode 100644 (file)
index 86f8ed6..0000000
+++ /dev/null
@@ -1,189 +0,0 @@
-\r
-                        Microsoft Visual C Stuff\r
-\r
-\r
-[Tom Moog 2-Oct-98\r
-\r
-    Users of Microsoft Visual C++ should download a separate\r
-    ready-to-run zip file from my web site.  It contains \r
-    binaries, static library, and a sample project.\r
-]\r
-\r
-[\r
-  Two notes added by Tom Moog 23-Sep-97.  I believe the *.dsp and\r
-  *.mak files that were once at the end of this file are now obsolete.\r
-  \r
-  The following MSVC .dsp and .mak files for pccts and sorcerer\r
-  were contributed by Stanislaw Bochnak (S.Bochnak@microtool.com.pl)\r
-  and Jeff Vincent (jvincent@novell.com)\r
-\r
-        PCCTS Distribution Kit\r
-        ----------------------\r
-        pccts/antlr/AntlrMSVC50.dsp\r
-        pccts/antlr/AntlrMSVC50.mak\r
-\r
-        pccts/dlg/DlgMSVC50.dsp\r
-        pccts/dlg/DlgMSVC50.mak\r
-\r
-        pccts/support/genmk/watgenmk.mak\r
-        pccts/support/msvc.dsp\r
-\r
-        Sorcerer Distribution Kit\r
-        -------------------------\r
-        pccts/sorcerer/SorcererMSVC50.dsp\r
-        pccts/sorcerer/SorcererMSVC50.mak\r
-\r
-        pccts/sorcerer/lib/msvc.dsp\r
-\r
-  I do not have an MS based computer.  If you discover problems\r
-  please report them so as to save trouble for others in the future.\r
-]\r
-\r
-[\r
- Modified by Terence Parr (September 1995) to change .C to .cpp\r
-]\r
-\r
-[\r
- This file contains notes on MSVC for Windows NT console execs by Dave\r
- Seidel and an explanation of flags etc.. by John Hall; good luck,\r
- Terence\r
-]\r
-\r
-===============================================================================\r
-Date: Sat, 31 Dec 1994 11:40:36 -0500 (EST)\r
-From: David Seidel <75342.2034@compuserve.com>\r
-\r
-I've succesfully build 1.31b3 with djgpp for DOS and MSVC 2.0 for Windows \r
-NT.  The only (minor) problem I had was that GNU make (version 3.71, in the \r
-djgpp port) complained about "multiple targets" in both the antlr and dlg \r
-makefiles.  I got around the error by, in each makefile, commenting out the \r
-$(SRC) dependency, for example:\r
-\r
-   antlr: $(OBJ) #$(SRC)\r
-\r
-I don't know why this is happenning, since you haven't changed that part of \r
-the makefile at all, and I think this used to work ok...\r
-\r
-Here are the makefiles I built from within the MSVC 2.0 environment for antlr \r
-and dlg and Windows NT console executables.  Please feel free to pass them \r
-on.  Of course, as soon as 1.31 "goes gold", I will send you nice new \r
-binaries.  I'm not going to bother to keep doing both Borland and djgpp for \r
-DOS however.  Instead, I'll just keep the djgpp version up to date and also \r
-provide WinNT binaries.\r
-\r
-Dave\r
-===============================================================================\r
-\r
-         How to port PCCTS 1.10 (and 1.32 hopefully) to Visual C++\r
-\r
-                                   By\r
-\r
-                       John Hall <jhall@ivy.wpi.edu>\r
-\r
-Here is how to compile an ANTLR grammar in Visual C++.  These steps\r
-describe how to have your ANTLR grammar parse the input file the user\r
-selects when they choose File Open in your Windows application.  (Even\r
-if you aren't using Visual C++, the steps should be portable enough to\r
-other compilers.)\r
-\r
- * Make sure that ANTLR and DLG generate ANSI code (use the -ga\r
-   switch).\r
-\r
- * Set the following compiler flags in Visual C++ (these are in the\r
-   Memory Model category of the compiler options in the Project\r
-   Options menu):\r
-\r
-   FLAG MEANING\r
-   ==== ==============================================================\r
-   /AL  Large memory model (multiple data segments; data items must be\r
-    smaller than 64K).\r
-\r
-   /Gtn Allocates all items whose size is greater than or equal to n\r
-    in a new data segment.  (I let n be 256: /Gt256.)\r
-\r
-   /Gx- All references to data items are done with far addressing in\r
-    case they are placed in a far segment.\r
-\r
- * Add the following member variable to the attributes section of your\r
-   derived CDocument class (you will need to make sure you also\r
-   include stdio.h):\r
-\r
-   FILE *fp;\r
-\r
- * Add the following method to your derived CDocument class:\r
-\r
-   BOOL CAppDoc::OnOpenDocument(const char* pszPathName)\r
-   {\r
-       // Call CDocument's OnOpenDocument to do housekeeping for us\r
-       // DON'T add anything to the loading section of Serialize\r
-       if (!CDocument::OnOpenDocument(pszPathName))\r
-           return FALSE;\r
-   \r
-       // Open input file\r
-       if ((fp = fopen(pszPathName, "r")) == NULL)\r
-           return FALSE;\r
-   \r
-       // Parse input file\r
-       ANTLR(start(), fp);\r
-   \r
-       // Close input file\r
-       fclose(fp);\r
-       return TRUE;\r
-   }\r
-\r
-   (Note: additional code may be necessary, depending on your parser.\r
-   For example, if your parser uses PCCTS's symbol table library, you\r
-   will need to insert calls to zzs_init and zzs_done.)\r
-\r
- * Compile the generated C files as C++ files.  (I renamed the files\r
-   to have a .CPP extension to fool Visual C++ into thinking they were\r
-   C++ files.  One might also use the /Tp switch, but that switch\r
-   requires you separately include the filename.)  [I used this step\r
-   as an easy out for all the external linking errors I was getting\r
-   that I couldn't fix by declaring things extern "C".]\r
-\r
- * Make sure the __STDC__ portion of the generated files gets\r
-   compiled.  (Either define __STDC__ yourself or else change all\r
-   occurrences of __STDC__ to __cplusplus in the generated files.  You\r
-   can define __STDC__ in the Preprocessor category of the compiler\r
-   options.)\r
-\r
-        ================================================================\r
-        = Note 23-Sep-97: This is probably not necessary any more.     =\r
-        = With 1.33MRxxx the use of __STDC__ was replaced with the     =\r
-        = macro __USE_PROTOS to control the compilation of prototypes. =\r
-        ================================================================\r
-                        \r
-That last step is important for Visual C++, but may not apply to other\r
-compilers.  For C++ compilers, whether __STDC__ is defined is\r
-implementation dependent (ARM, page 379).  Apparently, Visual C++ does\r
-not to define it; it also does not support "old style" C function\r
-definitions (which is okay, according to page 404 of the ARM).  Those\r
-two things together caused problems when trying to port the code.\r
-When it saw this:\r
-\r
-#ifdef __STDC__\r
-void\r
-globals(AST **_root)\r
-#else\r
-globals(_root)\r
-AST **_root;\r
-#endif\r
-\r
-it skipped the __STDC__ section and tried to process the "old style"\r
-function definition, where it choked.\r
-\r
-When you finally get your parser to compile and link without error,\r
-you may get General Protection Fault errors at run time.  The problem\r
-I had was that a NULL was passed to a variable argument function\r
-without an explicit cast.  The function grabbed a pointer (32-bits)\r
-off the stack using va_arg, but the NULL was passed silently as the\r
-integer 0 (16 bits), making the resulting pointer was invalid.  (This\r
-was in PCCTS's sample C parser.)\r
-\r
-There is one other thing I might suggest to help you avoid a run-time\r
-error.  Make sure you redefine the default error reporting function,\r
-zzsyn.  To do this, put "#define USER_ZZSYN" in your #header section\r
-and put your own zzsyn somewhere.  You can then pop up a MessageBox or\r
-print the error to some output window.\r
-===============================================================================\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/README b/Tools/CodeTools/TianoTools/Pccts/README
deleted file mode 100644 (file)
index d089b63..0000000
+++ /dev/null
@@ -1,159 +0,0 @@
-\r
-                          Parr Research Corporation\r
-                                    with\r
-                  Purdue University Electrical Engineering\r
-                                    and\r
-                       University of Minnesota, AHPCRC\r
-\r
-                                Terence Parr\r
-                                Russell Quong\r
-                                 Will Cohen\r
-                                 Hank Dietz\r
-\r
-\r
-A central place for information about PCCTS 1.33 is:\r
-\r
-        http://www.polhode.com/pccts.html\r
-\r
-The maintenance release is available from:\r
-\r
-        http://www.polhode.com/pccts133mr.zip\r
-\r
-There is a ready-to-run version for win32 for Microsoft Visual Studio\r
-at the same site.  It is available from:\r
-\r
-        http://www.polhode.com/win32.zip\r
-\r
-New users should visit http://www.polhode.com/pccts.html in\r
-order to get the following document:\r
-\r
-        "Notes For New Users of PCCTS"\r
-\r
-This is a Postscript file of about 40 pages which is extremely \r
-useful for someone starting out. It is a based on 1.33mr21\r
-\r
-When you have a little more experience, be sure to review the\r
-following documents in the distribution kit:\r
-\r
-            CHANGES_FROM_133.txt\r
-            CHANGES_FROM_133_BEFORE_MR13.txt\r
-            KNOWN_PROBLEMS.txt\r
-\r
--------------------------------------------------------------------------\r
-                      INSTALLATION (Unix)\r
--------------------------------------------------------------------------\r
-0. Download http://www.polhode.com/pccts133mr.zip\r
-\r
-1. Unzip the distribution kit to your preferred location.  \r
-   If there are newline problems try using zip -a ...\r
-\r
-2. cd to the main pccts directory.\r
-\r
-3. make\r
-\r
-   This will create:\r
-\r
-        antlr\r
-        dlg\r
-        sorcerer\r
-        genmk\r
-\r
-4. Copy to /usr/local/bin or /usr/local/bin if you like.  If you\r
-   don't wish to then add pccts/bin to your path.\r
-\r
-5. To get an up-to-date list of program options execute the\r
-   program with no command line options.  To get up-to-date\r
-   documentation read CHANGES_FROM_133*.txt and KNOWN_PROBLEMS.txt\r
-   at:\r
-\r
-           http://www.polhode.com/pccts.html\r
-\r
-6. You need not create a library.  The makefile created by genmk\r
-   assumes that the files are not part of a library. \r
-\r
-   If you wish to create a library from elements of pccts/h:\r
-\r
-   If the first letter of the filename is lowercase (uppercase) it is\r
-   related to the code generated using the pccts C mode (C++ mode).\r
-   Some of the .c and .cpp files in the h directory are not meant to\r
-   be placed in a library and will not compile because they are meant\r
-   to be #include in pccts generated files which are grammar specific.\r
-\r
-   For C++ users place the following elements in the library:\r
-\r
-        AParser.cpp\r
-        ASTBase.cpp\r
-        ATokenBuffer.cpp\r
-        BufFileInput.cpp (optional)\r
-        DLexerBase.cpp\r
-        PCCTSAST.cpp\r
-        SList.cpp\r
-\r
--------------------------------------------------------------------------\r
-                    INSTALLATION (Win32)\r
--------------------------------------------------------------------------\r
-\r
-I've tried to keep the win32 kit to the minimum necessary to get \r
-up and running.  The complete kit contains additional information\r
-(some historical), source code, and DevStudio projects for \r
-rebuilding pccts from the source code.\r
-\r
-The kit is now distributed with both MSVC 5 and MSVC6 style projects.\r
-\r
-0. Download http://www.polhode.com/win32.zip.\r
-\r
-   You may also wish to download:\r
-\r
-        http://www.polhode.com/CHANGES_FROM_133.txt\r
-        http://www.polhode.com/CHANGES_FROM_133_BEFORE_MR13.txt\r
-        http://www.polhode.com/KNOWN_PROBLEMS.txt\r
-\r
-1. Unzip the distribution kit to your preferred location.\r
-\r
-   This will create:\r
-\r
-         a pccts directory tree\r
-            pccts/bin/*.exe\r
-            pccts/lib/*.lib\r
-            pccts/h/*\r
-            sorcerer/lib/*\r
-            sorcerer/h/*\r
-\r
-         an example directory tree\r
-            pccts\example\calcAST\*\r
-            pccts\example\simple\*\r
-\r
-2. Define the environment variable PCCTS to point to the main\r
-   pccts directory.\r
-\r
-3. Try building the simple project: pccts\example\simple\simple50.dsw\r
-   or simple60.dsw.\r
-\r
-4. Try building the complex project: pccts\example\calcAST\calcAST50.dsw\r
-   or calcAST60.dsw.\r
-\r
--------------------------------------------------------------------------\r
-                      INSTALLATION (DEC/VMS)\r
--------------------------------------------------------------------------\r
-\r
-DEC/VMS support added by Piéronne Jean-François (jfp@altavista.net)\r
-\r
-0. Download http://www.polhode.com/pccts133mr.zip\r
-\r
-1. Unzip the distribution kit to your preferred location.\r
-\r
-2. set default to the main pccts directory.\r
-\r
-3. @makefile.vms\r
-\r
-   This will create in directory [.bin]:\r
-\r
-        antlr.exe\r
-        dlg.exe\r
-        sorcerer.exe\r
-        genmk.exe\r
-\r
-5. To get an up-to-date list of program options execute the\r
-   program with no command line options.  To get up-to-date\r
-   documentation read CHANGES_FROM_133*.txt and KNOWN_PROBLEMS.txt\r
-   at http://www.polhode.com/pccts.html.\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/RIGHTS b/Tools/CodeTools/TianoTools/Pccts/RIGHTS
deleted file mode 100644 (file)
index 9db175f..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-\r
-SOFTWARE RIGHTS\r
-\r
-We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
-Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
-company may do whatever they wish with source code distributed with\r
-PCCTS or the code generated by PCCTS, including the incorporation of\r
-PCCTS, or its output, into commerical software.\r
-\r
-We encourage users to develop software with PCCTS.  However, we do ask\r
-that credit is given to us for developing PCCTS.  By "credit", we mean\r
-that if you incorporate our source code into one of your programs\r
-(commercial product, research project, or otherwise) that you\r
-acknowledge this fact somewhere in the documentation, research report,\r
-etc...  If you like PCCTS and have developed a nice tool with the\r
-output, please mention that you developed it using PCCTS.  In\r
-addition, we ask that this header remain intact in our source code.\r
-As long as these guidelines are kept, we expect to continue enhancing\r
-this system and expect to make other tools available as they are\r
-completed.\r
-\r
-ANTLR 1.33\r
-Terence Parr\r
-Parr Research Corporation\r
-with Purdue University and AHPCRC, University of Minnesota\r
-1989-1995\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/antlr/AntlrMS.mak b/Tools/CodeTools/TianoTools/Pccts/antlr/AntlrMS.mak
deleted file mode 100644 (file)
index 7c14993..0000000
+++ /dev/null
@@ -1,233 +0,0 @@
-# PCCTS directory\r
-\r
-# You will need to set the LIB variable similar to this.\r
-# LIB="C:/Program Files/Microsoft Visual Studio .NET 2003/Vc7/lib;c:/Microsoft Visual Studio .NET 2003/Vc7/PlatformSDK/Lib"\r
-\r
-# PCCTS_HOME=<your PCCTS_HOME>\r
-PCCTS_HOME=$(WORKSPACE)\Tools\Source\TianoTools\Pccts\r
-ANTLR_SRC=$(PCCTS_HOME)\antlr\r
-PCCTS_H=$(PCCTS_HOME)\h\r
-\r
-\r
-# Support directories\r
-SET=$(PCCTS_HOME)\support\set\r
-\r
-\r
-# Compiler stuff\r
-CC = cl\r
-CFLAGS = /nologo -I "." -I "$(PCCTS_H)" -I "$(SET)" -D "USER_ZZSYN" -D "PC" \\r
-        -D "ZZLEXBUFSIZE=65536"  /D "LONGFILENAMES" /Zi /W3 -D__USE_PROTOS /wd4700\r
-\r
-ANTLR_OBJS = antlr.obj scan.obj err.obj bits.obj build.obj fset2.obj \\r
-            fset.obj gen.obj globals.obj hash.obj lex.obj main.obj \\r
-            misc.obj pred.obj egman.obj mrhoist.obj fcache.obj\r
-\r
-SUPPORT_OBJS = set.obj\r
-\r
-# Dependencies\r
-\r
-$(WORKSPACE)\Tools\bin\antlr.exe: $(ANTLR_OBJS) $(SUPPORT_OBJS)\r
-    $(CC) $(CFLAGS) -o antlr.exe $(ANTLR_OBJS) $(SUPPORT_OBJS)\r
-    del *.obj\r
-               move antlr.exe $(WORKSPACE)\Tools\bin\r
-\r
-\r
-antlr.obj: $(ANTLR_SRC)\antlr.c \\r
-                       $(PCCTS_H)\antlr.h \\r
-                       $(PCCTS_H)\config.h \\r
-                       $(PCCTS_H)\dlgdef.h \\r
-                                       $(SET)\set.h \\r
-                                       $(ANTLR_SRC)\generic.h \\r
-                                       $(ANTLR_SRC)\hash.h \\r
-                                       $(ANTLR_SRC)\mode.h \\r
-                                       $(ANTLR_SRC)\proto.h \\r
-                                       $(ANTLR_SRC)\syn.h \\r
-                                       $(ANTLR_SRC)\tokens.h \\r
-\r
-    $(CC) -c $(CFLAGS) $(ANTLR_SRC)\antlr.c\r
-\r
-scan.obj: $(ANTLR_SRC)\scan.c \\r
-                       $(PCCTS_H)\antlr.h \\r
-                                       $(PCCTS_H)\config.h \\r
-                                       $(PCCTS_H)\dlgauto.h \\r
-                                       $(PCCTS_H)\dlgdef.h \\r
-                                       $(SET)\set.h \\r
-                                       $(ANTLR_SRC)\generic.h \\r
-                                       $(ANTLR_SRC)\hash.h \\r
-                                       $(ANTLR_SRC)\mode.h \\r
-                                       $(ANTLR_SRC)\proto.h \\r
-                                       $(ANTLR_SRC)\syn.h \\r
-                                       $(ANTLR_SRC)\tokens.h \\r
-\r
-    $(CC) -c $(CFLAGS) $(ANTLR_SRC)\scan.c\r
-\r
-err.obj: $(ANTLR_SRC)\err.c \\r
-                                       $(PCCTS_H)\antlr.h \\r
-                                       $(PCCTS_H)\config.h \\r
-                                       $(PCCTS_H)\dlgdef.h \\r
-                                       $(PCCTS_H)\err.h \\r
-                                       $(SET)\set.h \\r
-                                       $(ANTLR_SRC)\generic.h \\r
-                                       $(ANTLR_SRC)\hash.h \\r
-                                       $(ANTLR_SRC)\proto.h \\r
-                                       $(ANTLR_SRC)\syn.h \\r
-                                       $(ANTLR_SRC)\tokens.h \\r
-\r
-    $(CC) -c $(CFLAGS) $(ANTLR_SRC)\err.c\r
-\r
-bits.obj: $(ANTLR_SRC)\bits.c \\r
-                                       $(PCCTS_H)\config.h \\r
-                                       $(PCCTS_H)\dlgdef.h \\r
-                                       $(SET)\set.h \\r
-                                       $(ANTLR_SRC)\generic.h \\r
-                                       $(ANTLR_SRC)\hash.h \\r
-                                       $(ANTLR_SRC)\proto.h \\r
-                                       $(ANTLR_SRC)\syn.h \\r
-\r
-    $(CC) -c $(CFLAGS) $(ANTLR_SRC)\bits.c\r
-\r
-build.obj: $(ANTLR_SRC)\build.c \\r
-                                       $(PCCTS_H)\config.h \\r
-                                       $(PCCTS_H)\dlgdef.h \\r
-                                       $(SET)\set.h \\r
-                                       $(ANTLR_SRC)\generic.h \\r
-                                       $(ANTLR_SRC)\hash.h \\r
-                                       $(ANTLR_SRC)\proto.h \\r
-                                       $(ANTLR_SRC)\syn.h \\r
-\r
-    $(CC) -c $(CFLAGS) $(ANTLR_SRC)\build.c\r
-\r
-fset2.obj: $(ANTLR_SRC)\fset2.c \\r
-                                       $(PCCTS_H)\config.h \\r
-                                       $(PCCTS_H)\dlgdef.h \\r
-                                       $(SET)\set.h \\r
-                                       $(ANTLR_SRC)\generic.h \\r
-                                       $(ANTLR_SRC)\hash.h \\r
-                                       $(ANTLR_SRC)\proto.h \\r
-                                       $(ANTLR_SRC)\syn.h \\r
-\r
-    $(CC) -c $(CFLAGS) $(ANTLR_SRC)\fset2.c\r
-\r
-fset.obj: $(ANTLR_SRC)\fset.c \\r
-                                       $(PCCTS_H)\config.h \\r
-                                       $(PCCTS_H)\dlgdef.h \\r
-                                       $(SET)\set.h \\r
-                                       $(ANTLR_SRC)\generic.h \\r
-                                       $(ANTLR_SRC)\hash.h \\r
-                                       $(ANTLR_SRC)\proto.h \\r
-                                       $(ANTLR_SRC)\syn.h \\r
-\r
-    $(CC) -c $(CFLAGS) $(ANTLR_SRC)\fset.c\r
-\r
-gen.obj: $(ANTLR_SRC)\gen.c \\r
-                                       $(PCCTS_H)\config.h \\r
-                                       $(PCCTS_H)\dlgdef.h \\r
-                                       $(SET)\set.h \\r
-                                       $(ANTLR_SRC)\generic.h \\r
-                                       $(ANTLR_SRC)\hash.h \\r
-                                       $(ANTLR_SRC)\proto.h \\r
-                                       $(ANTLR_SRC)\syn.h \\r
-\r
-    $(CC) -c $(CFLAGS) $(ANTLR_SRC)\gen.c\r
-\r
-globals.obj: $(ANTLR_SRC)\globals.c \\r
-                                       $(PCCTS_H)\config.h \\r
-                                       $(SET)\set.h \\r
-                                       $(ANTLR_SRC)\generic.h \\r
-                                       $(ANTLR_SRC)\hash.h \\r
-                                       $(ANTLR_SRC)\proto.h \\r
-                                       $(ANTLR_SRC)\syn.h \\r
-\r
-    $(CC) -c $(CFLAGS) $(ANTLR_SRC)\globals.c\r
-\r
-hash.obj: $(ANTLR_SRC)\hash.c \\r
-                                       $(PCCTS_H)\config.h \\r
-                                       $(ANTLR_SRC)\hash.h \\r
-\r
-    $(CC) -c $(CFLAGS) $(ANTLR_SRC)\hash.c\r
-\r
-lex.obj: $(ANTLR_SRC)\lex.c \\r
-                                       $(PCCTS_H)\config.h \\r
-                                       $(SET)\set.h \\r
-                                       $(ANTLR_SRC)\generic.h \\r
-                                       $(ANTLR_SRC)\hash.h \\r
-                                       $(ANTLR_SRC)\proto.h \\r
-                                       $(ANTLR_SRC)\syn.h \\r
-\r
-    $(CC) -c $(CFLAGS) $(ANTLR_SRC)\lex.c\r
-\r
-main.obj: $(ANTLR_SRC)\main.c \\r
-                                       $(PCCTS_H)\antlr.h \\r
-                                       $(PCCTS_H)\config.h \\r
-                                       $(PCCTS_H)\dlgdef.h \\r
-                                       $(SET)\set.h \\r
-                                       $(ANTLR_SRC)\generic.h \\r
-                                       $(ANTLR_SRC)\hash.h \\r
-                                       $(ANTLR_SRC)\mode.h \\r
-                                       $(ANTLR_SRC)\proto.h \\r
-                                       $(ANTLR_SRC)\stdpccts.h \\r
-                                       $(ANTLR_SRC)\syn.h \\r
-                                       $(ANTLR_SRC)\tokens.h \\r
-\r
-    $(CC) -c $(CFLAGS) $(ANTLR_SRC)\main.c\r
-\r
-misc.obj: $(ANTLR_SRC)\misc.c \\r
-                                       $(PCCTS_H)\config.h \\r
-                                       $(PCCTS_H)\dlgdef.h \\r
-                                       $(SET)\set.h \\r
-                                       $(ANTLR_SRC)\generic.h \\r
-                                       $(ANTLR_SRC)\hash.h \\r
-                                       $(ANTLR_SRC)\proto.h \\r
-                                       $(ANTLR_SRC)\syn.h \\r
-\r
-    $(CC) -c $(CFLAGS) $(ANTLR_SRC)\misc.c\r
-\r
-pred.obj: $(ANTLR_SRC)\pred.c \\r
-                                       $(PCCTS_H)\config.h \\r
-                                       $(PCCTS_H)\dlgdef.h \\r
-                                       $(SET)\set.h \\r
-                                       $(ANTLR_SRC)\generic.h \\r
-                                       $(ANTLR_SRC)\hash.h \\r
-                                       $(ANTLR_SRC)\proto.h \\r
-                                       $(ANTLR_SRC)\syn.h \\r
-\r
-    $(CC) -c $(CFLAGS) $(ANTLR_SRC)\pred.c\r
-\r
-egman.obj: $(ANTLR_SRC)\egman.c \\r
-                                       $(PCCTS_H)\config.h \\r
-                                       $(SET)\set.h \\r
-                                       $(ANTLR_SRC)\generic.h \\r
-                                       $(ANTLR_SRC)\hash.h \\r
-                                       $(ANTLR_SRC)\proto.h \\r
-                                       $(ANTLR_SRC)\syn.h \\r
-\r
-    $(CC) -c $(CFLAGS) $(ANTLR_SRC)\egman.c\r
-\r
-mrhoist.obj: $(ANTLR_SRC)\mrhoist.c \\r
-                                       $(ANTLR_SRC)\generic.h \\r
-                                       $(ANTLR_SRC)\hash.h \\r
-                                       $(ANTLR_SRC)\proto.h \\r
-                                       $(ANTLR_SRC)\syn.h \\r
-\r
-    $(CC) -c $(CFLAGS) $(ANTLR_SRC)\mrhoist.c\r
-\r
-fcache.obj: $(ANTLR_SRC)\fcache.c \\r
-                                       $(ANTLR_SRC)\generic.h \\r
-                                       $(ANTLR_SRC)\hash.h \\r
-                                       $(ANTLR_SRC)\proto.h \\r
-                                       $(ANTLR_SRC)\syn.h \\r
-\r
-    $(CC) -c $(CFLAGS) $(ANTLR_SRC)\fcache.c\r
-\r
-set.obj: $(SET)\set.c \\r
-                                       $(PCCTS_H)\config.h \\r
-                                       $(SET)\set.h \\r
-\r
-    $(CC) -c $(CFLAGS) $(SET)\set.c\r
-\r
-clean: \r
-    del *.obj\r
-\r
-distclean:\r
-    del *.obj\r
-    del $(WORKSPACE)\Tools\bin\antlr.exe\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/antlr/AntlrPPC.mak b/Tools/CodeTools/TianoTools/Pccts/antlr/AntlrPPC.mak
deleted file mode 100644 (file)
index 9ede60d..0000000
+++ /dev/null
@@ -1,101 +0,0 @@
-#   Target:     antlrPPC\r
-#   Sources:    ::support:set:set.c\r
-#               antlr.c\r
-#               bits.c\r
-#               build.c\r
-#               egman.c\r
-#               err.c\r
-#               fcache.c\r
-#               fset2.c\r
-#               fset.c\r
-#               gen.c\r
-#               globals.c\r
-#               hash.c\r
-#               lex.c\r
-#               main.c\r
-#               misc.c\r
-#               mrhoist.c\r
-#               pred.c\r
-#               scan.c\r
-#   Created:    Sunday, May 17, 1998 10:24:53 PM\r
-#      Author:         Kenji Tanaka\r
-MAKEFILE     = antlrPPC.make\r
-Â¥MondoBuildÂ¥ = {MAKEFILE}  # Make blank to avoid rebuilds when makefile is modified\r
-Includes     = Â¶\r
-               -i "::h:" Â¶\r
-               -i "::support:set:"\r
-SymÂ¥PPC      = \r
-ObjDirÂ¥PPC   = :Obj:\r
-PPCCOptions  = {Includes} {SymÂ¥PPC} -w off -d MPW -d __STDC__=1 -d USER_ZZSYN\r
-ObjectsÂ¥PPC  = Â¶\r
-               "{ObjDirÂ¥PPC}set.c.x" Â¶\r
-               "{ObjDirÂ¥PPC}antlr.c.x" Â¶\r
-               "{ObjDirÂ¥PPC}bits.c.x" Â¶\r
-               "{ObjDirÂ¥PPC}build.c.x" Â¶\r
-               "{ObjDirÂ¥PPC}egman.c.x" Â¶\r
-               "{ObjDirÂ¥PPC}err.c.x" Â¶\r
-               "{ObjDirÂ¥PPC}fcache.c.x" Â¶\r
-               "{ObjDirÂ¥PPC}fset2.c.x" Â¶\r
-               "{ObjDirÂ¥PPC}fset.c.x" Â¶\r
-               "{ObjDirÂ¥PPC}gen.c.x" Â¶\r
-               "{ObjDirÂ¥PPC}globals.c.x" Â¶\r
-               "{ObjDirÂ¥PPC}hash.c.x" Â¶\r
-               "{ObjDirÂ¥PPC}lex.c.x" Â¶\r
-               "{ObjDirÂ¥PPC}main.c.x" Â¶\r
-               "{ObjDirÂ¥PPC}misc.c.x" Â¶\r
-               "{ObjDirÂ¥PPC}mrhoist.c.x" Â¶\r
-               "{ObjDirÂ¥PPC}pred.c.x" Â¶\r
-               "{ObjDirÂ¥PPC}scan.c.x"\r
-antlrPPC Ã„Ä {Â¥MondoBuildÂ¥} {ObjectsÂ¥PPC}\r
-       PPCLink Â¶\r
-               -o {Targ} {SymÂ¥PPC} Â¶\r
-               {ObjectsÂ¥PPC} Â¶\r
-               -t 'MPST' Â¶\r
-               -c 'MPS ' Â¶\r
-               "{SharedLibraries}InterfaceLib" Â¶\r
-               "{SharedLibraries}StdCLib" Â¶\r
-               #"{SharedLibraries}MathLib" Â¶\r
-               "{PPCLibraries}StdCRuntime.o" Â¶\r
-               "{PPCLibraries}PPCCRuntime.o" Â¶\r
-               "{PPCLibraries}PPCToolLibs.o"\r
-"{ObjDirÂ¥PPC}set.c.x" Ã„ {Â¥MondoBuildÂ¥} "::support:set:set.c"\r
-       {PPCC} "::support:set:set.c" -o {Targ} {PPCCOptions}\r
-"{ObjDirÂ¥PPC}antlr.c.x" Ã„ {Â¥MondoBuildÂ¥} antlr.c\r
-       {PPCC} antlr.c -o {Targ} {PPCCOptions}\r
-"{ObjDirÂ¥PPC}bits.c.x" Ã„ {Â¥MondoBuildÂ¥} bits.c\r
-       {PPCC} bits.c -o {Targ} {PPCCOptions}\r
-"{ObjDirÂ¥PPC}build.c.x" Ã„ {Â¥MondoBuildÂ¥} build.c\r
-       {PPCC} build.c -o {Targ} {PPCCOptions}\r
-"{ObjDirÂ¥PPC}egman.c.x" Ã„ {Â¥MondoBuildÂ¥} egman.c\r
-       {PPCC} egman.c -o {Targ} {PPCCOptions}\r
-"{ObjDirÂ¥PPC}err.c.x" Ã„ {Â¥MondoBuildÂ¥} err.c\r
-       {PPCC} err.c -o {Targ} {PPCCOptions}\r
-"{ObjDirÂ¥PPC}fcache.c.x" Ã„ {Â¥MondoBuildÂ¥} fcache.c\r
-       {PPCC} fcache.c -o {Targ} {PPCCOptions}\r
-"{ObjDirÂ¥PPC}fset2.c.x" Ã„ {Â¥MondoBuildÂ¥} fset2.c\r
-       {PPCC} fset2.c -o {Targ} {PPCCOptions}\r
-"{ObjDirÂ¥PPC}fset.c.x" Ã„ {Â¥MondoBuildÂ¥} fset.c\r
-       {PPCC} fset.c -o {Targ} {PPCCOptions}\r
-"{ObjDirÂ¥PPC}gen.c.x" Ã„ {Â¥MondoBuildÂ¥} gen.c\r
-       {PPCC} gen.c -o {Targ} {PPCCOptions}\r
-"{ObjDirÂ¥PPC}globals.c.x" Ã„ {Â¥MondoBuildÂ¥} globals.c\r
-       {PPCC} globals.c -o {Targ} {PPCCOptions}\r
-"{ObjDirÂ¥PPC}hash.c.x" Ã„ {Â¥MondoBuildÂ¥} hash.c\r
-       {PPCC} hash.c -o {Targ} {PPCCOptions}\r
-"{ObjDirÂ¥PPC}lex.c.x" Ã„ {Â¥MondoBuildÂ¥} lex.c\r
-       {PPCC} lex.c -o {Targ} {PPCCOptions}\r
-"{ObjDirÂ¥PPC}main.c.x" Ã„ {Â¥MondoBuildÂ¥} main.c\r
-       {PPCC} main.c -o {Targ} {PPCCOptions}\r
-"{ObjDirÂ¥PPC}misc.c.x" Ã„ {Â¥MondoBuildÂ¥} misc.c\r
-       {PPCC} misc.c -o {Targ} {PPCCOptions}\r
-"{ObjDirÂ¥PPC}mrhoist.c.x" Ã„ {Â¥MondoBuildÂ¥} mrhoist.c\r
-       {PPCC} mrhoist.c -o {Targ} {PPCCOptions}\r
-"{ObjDirÂ¥PPC}pred.c.x" Ã„ {Â¥MondoBuildÂ¥} pred.c\r
-       {PPCC} pred.c -o {Targ} {PPCCOptions}\r
-"{ObjDirÂ¥PPC}scan.c.x" Ã„ {Â¥MondoBuildÂ¥} scan.c\r
-       {PPCC} scan.c -o {Targ} {PPCCOptions}\r
-\r
-antlrPPC Ã„Ä antlr.r\r
-       Rez antlr.r -o antlrPPC -a\r
-Install  Ã„ antlrPPC\r
-       Duplicate -y antlrPPC "{MPW}"Tools:antlr\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/antlr/README b/Tools/CodeTools/TianoTools/Pccts/antlr/README
deleted file mode 100644 (file)
index d7fc959..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-                            ANTLR 1.33\r
-\r
-This directory contains the files necessary to build ANTLR.\r
-\r
-If you do a "make scrub", ANTLR will have to run on antlr.g and DLG\r
-will have to run on parser.dlg.  Either\r
-\r
-(1)     ANTLR uses the previous antlr in that directory to rebuild itself\r
-(2)     Needs to find antlr on the search path\r
-\r
-You will find that running "antlr -gh antlr.g" will result in about\r
-10 ambiguity warnings.  These are normal.  Don't worry.\r
-\r
-If you do a "make clean" right after installation, ANTLR and DLG should\r
-not need to run; only the C files will compile.\r
-\r
-Don't forget to go into the makefile to uncomment the appropriate\r
-definitions for your OS/architecture/compiler or see the appropriate\r
-NOTES.?? file.\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/antlr/antlr.1 b/Tools/CodeTools/TianoTools/Pccts/antlr/antlr.1
deleted file mode 100644 (file)
index acfa85b..0000000
+++ /dev/null
@@ -1,209 +0,0 @@
-.TH ANTLR 1 "September 1995" "ANTLR" "PCCTS Manual Pages"\r
-.SH NAME\r
-antlr \- ANother Tool for Language Recognition\r
-.SH SYNTAX\r
-.LP\r
-\fBantlr\fR [\fIoptions\fR] \fIgrammar_files\fR\r
-.SH DESCRIPTION\r
-.PP\r
-\fIAntlr\fP converts an extended form of context-free grammar into a\r
-set of C functions which directly implement an efficient form of\r
-deterministic recursive-descent LL(k) parser.  Context-free grammars\r
-may be augmented with predicates to allow semantics to influence\r
-parsing; this allows a form of context-sensitive parsing.  Selective\r
-backtracking is also available to handle non-LL(k) and even\r
-non-LALR(k) constructs.  \fIAntlr\fP also produces a definition of a\r
-lexer which can be automatically converted into C code for a DFA-based\r
-lexer by \fIdlg\fR.  Hence, \fIantlr\fR serves a function much like\r
-that of \fIyacc\fR, however, it is notably more flexible and is more\r
-integrated with a lexer generator (\fIantlr\fR directly generates\r
-\fIdlg\fR code, whereas \fIyacc\fR and \fIlex\fR are given independent\r
-descriptions).  Unlike \fIyacc\fR which accepts LALR(1) grammars,\r
-\fIantlr\fR accepts LL(k) grammars in an extended BNF notation \(em\r
-which eliminates the need for precedence rules.\r
-.PP\r
-Like \fIyacc\fR grammars, \fIantlr\fR grammars can use\r
-automatically-maintained symbol attribute values referenced as dollar\r
-variables.  Further, because \fIantlr\fR generates top-down parsers,\r
-arbitrary values may be inherited from parent rules (passed like\r
-function parameters).  \fIAntlr\fP also has a mechanism for creating\r
-and manipulating abstract-syntax-trees.\r
-.PP\r
-There are various other niceties in \fIantlr\fR, including the ability to\r
-spread one grammar over multiple files or even multiple grammars in a single\r
-file, the ability to generate a version of the grammar with actions stripped\r
-out (for documentation purposes), and lots more.\r
-.SH OPTIONS\r
-.IP "\fB-ck \fIn\fR"\r
-Use up to \fIn\fR symbols of lookahead when using compressed (linear\r
-approximation) lookahead.  This type of lookahead is very cheap to\r
-compute and is attempted before full LL(k) lookahead, which is of\r
-exponential complexity in the worst case.  In general, the compressed\r
-lookahead can be much deeper (e.g, \f(CW-ck 10\fP) than the full\r
-lookahead (which usually must be less than 4).\r
-.IP \fB-CC\fP\r
-Generate C++ output from both ANTLR and DLG.\r
-.IP \fB-cr\fP\r
-Generate a cross-reference for all rules.  For each rule, print a list\r
-of all other rules that reference it.\r
-.IP \fB-e1\fP\r
-Ambiguities/errors shown in low detail (default).\r
-.IP \fB-e2\fP\r
-Ambiguities/errors shown in more detail.\r
-.IP \fB-e3\fP\r
-Ambiguities/errors shown in excruciating detail.\r
-.IP "\fB-fe\fP file"\r
-Rename \fBerr.c\fP to file.\r
-.IP "\fB-fh\fP file"\r
-Rename \fBstdpccts.h\fP header (turns on \fB-gh\fP) to file.\r
-.IP "\fB-fl\fP file"\r
-Rename lexical output, \fBparser.dlg\fP, to file.\r
-.IP "\fB-fm\fP file"\r
-Rename file with lexical mode definitions, \fBmode.h\fP, to file.\r
-.IP "\fB-fr\fP file"\r
-Rename file which remaps globally visible symbols, \fBremap.h\fP, to file.\r
-.IP "\fB-ft\fP file"\r
-Rename \fBtokens.h\fP to file.\r
-.IP \fB-ga\fP\r
-Generate ANSI-compatible code (default case).  This has not been\r
-rigorously tested to be ANSI XJ11 C compliant, but it is close.  The\r
-normal output of \fIantlr\fP is currently compilable under both K&R,\r
-ANSI C, and C++\(emthis option does nothing because \fIantlr\fP\r
-generates a bunch of #ifdef's to do the right thing depending on the\r
-language.\r
-.IP \fB-gc\fP\r
-Indicates that \fIantlr\fP should generate no C code, i.e., only\r
-perform analysis on the grammar.\r
-.IP \fB-gd\fP\r
-C code is inserted in each of the \fIantlr\fR generated parsing functions to\r
-provide for user-defined handling of a detailed parse trace.  The inserted\r
-code consists of calls to the user-supplied macros or functions called\r
-\fBzzTRACEIN\fR and \fBzzTRACEOUT\fP.  The only argument is a\r
-\fIchar *\fR pointing to a C-style string which is the grammar rule\r
-recognized by the current parsing function.  If no definition is given\r
-for the trace functions, upon rule entry and exit, a message will be\r
-printed indicating that a particular rule as been entered or exited.\r
-.IP \fB-ge\fP\r
-Generate an error class for each non-terminal.\r
-.IP \fB-gh\fP\r
-Generate \fBstdpccts.h\fP for non-ANTLR-generated files to include.\r
-This file contains all defines needed to describe the type of parser\r
-generated by \fIantlr\fP (e.g. how much lookahead is used and whether\r
-or not trees are constructed) and contains the \fBheader\fP action\r
-specified by the user.\r
-.IP \fB-gk\fP\r
-Generate parsers that delay lookahead fetches until needed.  Without\r
-this option, \fIantlr\fP generates parsers which always have \fIk\fP\r
-tokens of lookahead available.\r
-.IP \fB-gl\fP\r
-Generate line info about grammar actions in C parser of the form\r
-\fB#\ \fIline\fP\ "\fIfile\fP"\fR which makes error messages from\r
-the C/C++ compiler make more sense as they will \*Qpoint\*U into the\r
-grammar file not the resulting C file.  Debugging is easier as well,\r
-because you will step through the grammar not C file.\r
-.IP \fB-gs\fR\r
-Do not generate sets for token expression lists; instead generate a\r
-\fB||\fP-separated sequence of \fBLA(1)==\fItoken_number\fR.  The\r
-default is to generate sets.\r
-.IP \fB-gt\fP\r
-Generate code for Abstract-Syntax Trees.\r
-.IP \fB-gx\fP\r
-Do not create the lexical analyzer files (dlg-related).  This option\r
-should be given when the user wishes to provide a customized lexical\r
-analyzer.  It may also be used in \fImake\fR scripts to cause only the\r
-parser to be rebuilt when a change not affecting the lexical structure\r
-is made to the input grammars.\r
-.IP "\fB-k \fIn\fR"\r
-Set k of LL(k) to \fIn\fR; i.e. set tokens of look-ahead (default==1).\r
-.IP "\fB-o\fP dir\r
-Directory where output files should go (default=".").  This is very\r
-nice for keeping the source directory clear of ANTLR and DLG spawn.\r
-.IP \fB-p\fP\r
-The complete grammar, collected from all input grammar files and\r
-stripped of all comments and embedded actions, is listed to\r
-\fBstdout\fP.  This is intended to aid in viewing the entire grammar\r
-as a whole and to eliminate the need to keep actions concisely stated\r
-so that the grammar is easier to read.  Hence, it is preferable to\r
-embed even complex actions directly in the grammar, rather than to\r
-call them as subroutines, since the subroutine call overhead will be\r
-saved.\r
-.IP \fB-pa\fP\r
-This option is the same as \fB-p\fP except that the output is\r
-annotated with the first sets determined from grammar analysis.\r
-.IP "\fB-prc on\fR\r
-Turn on the computation and hoisting of predicate context.\r
-.IP "\fB-prc off\fR\r
-Turn off the computation and hoisting of predicate context.  This\r
-option makes 1.10 behave like the 1.06 release with option \fB-pr\fR\r
-on.  Context computation is off by default.\r
-.IP "\fB-rl \fIn\fR\r
-Limit the maximum number of tree nodes used by grammar analysis to\r
-\fIn\fP.  Occasionally, \fIantlr\fP is unable to analyze a grammar\r
-submitted by the user.  This rare situation can only occur when the\r
-grammar is large and the amount of lookahead is greater than one.  A\r
-nonlinear analysis algorithm is used by PCCTS to handle the general\r
-case of LL(k) parsing.  The average complexity of analysis, however, is\r
-near linear due to some fancy footwork in the implementation which\r
-reduces the number of calls to the full LL(k) algorithm.  An error\r
-message will be displayed, if this limit is reached, which indicates\r
-the grammar construct being analyzed when \fIantlr\fP hit a\r
-non-linearity.  Use this option if \fIantlr\fP seems to go out to\r
-lunch and your disk start thrashing; try \fIn\fP=10000 to start.  Once\r
-the offending construct has been identified, try to remove the\r
-ambiguity that \fIantlr\fP was trying to overcome with large lookahead\r
-analysis.  The introduction of (...)? backtracking blocks eliminates\r
-some of these problems\ \(em \fIantlr\fP does not analyze alternatives\r
-that begin with (...)? (it simply backtracks, if necessary, at run\r
-time).\r
-.IP \fB-w1\fR\r
-Set low warning level.  Do not warn if semantic predicates and/or\r
-(...)? blocks are assumed to cover ambiguous alternatives.\r
-.IP \fB-w2\fR\r
-Ambiguous parsing decisions yield warnings even if semantic predicates\r
-or (...)? blocks are used.  Warn if predicate context computed and\r
-semantic predicates incompletely disambiguate alternative productions.\r
-.IP \fB-\fR\r
-Read grammar from standard input and generate \fBstdin.c\fP as the\r
-parser file.\r
-.SH "SPECIAL CONSIDERATIONS"\r
-.PP\r
-\fIAntlr\fP works...  we think.  There is no implicit guarantee of\r
-anything.  We reserve no \fBlegal\fP rights to the software known as\r
-the Purdue Compiler Construction Tool Set (PCCTS) \(em PCCTS is in the\r
-public domain.  An individual or company may do whatever they wish\r
-with source code distributed with PCCTS or the code generated by\r
-PCCTS, including the incorporation of PCCTS, or its output, into\r
-commercial software.  We encourage users to develop software with\r
-PCCTS.  However, we do ask that credit is given to us for developing\r
-PCCTS.  By "credit", we mean that if you incorporate our source code\r
-into one of your programs (commercial product, research project, or\r
-otherwise) that you acknowledge this fact somewhere in the\r
-documentation, research report, etc...  If you like PCCTS and have\r
-developed a nice tool with the output, please mention that you\r
-developed it using PCCTS.  As long as these guidelines are followed,\r
-we expect to continue enhancing this system and expect to make other\r
-tools available as they are completed.\r
-.SH FILES\r
-.IP *.c\r
-output C parser.\r
-.IP *.cpp\r
-output C++ parser when C++ mode is used.\r
-.IP \fBparser.dlg\fP\r
-output \fIdlg\fR lexical analyzer.\r
-.IP \fBerr.c\fP\r
-token string array, error sets and error support routines.  Not used in\r
-C++ mode.\r
-.IP \fBremap.h\fP\r
-file that redefines all globally visible parser symbols.  The use of\r
-the #parser directive creates this file.  Not used in\r
-C++ mode.\r
-.IP \fBstdpccts.h\fP\r
-list of definitions needed by C files, not generated by PCCTS, that\r
-reference PCCTS objects.  This is not generated by default.  Not used in\r
-C++ mode.\r
-.IP \fBtokens.h\fP\r
-output \fI#defines\fR for tokens used and function prototypes for\r
-functions generated for rules.\r
-.SH "SEE ALSO"\r
-.LP\r
-dlg(1), pccts(1)\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/antlr/antlr.c b/Tools/CodeTools/TianoTools/Pccts/antlr/antlr.c
deleted file mode 100644 (file)
index 8aaef79..0000000
+++ /dev/null
@@ -1,3564 +0,0 @@
-/*\r
- * A n t l r  T r a n s l a t i o n  H e a d e r\r
- *\r
- * Terence Parr, Will Cohen, and Hank Dietz: 1989-2001\r
- * Purdue University Electrical Engineering\r
- * With AHPCRC, University of Minnesota\r
- * ANTLR Version 1.33MR33\r
- *\r
- *   ..\bin\antlr -gh antlr.g\r
- *\r
- */\r
-\r
-#define ANTLR_VERSION  13333\r
-#include "pcctscfg.h"\r
-#include "pccts_stdio.h"\r
-\r
-#include "pcctscfg.h"\r
-#include "set.h"\r
-#include <ctype.h>\r
-#include "syn.h"\r
-#include "hash.h"\r
-#include "generic.h"\r
-#define zzcr_attr(attr,tok,t)\r
-#define zzSET_SIZE 20\r
-#include "antlr.h"\r
-#include "tokens.h"\r
-#include "dlgdef.h"\r
-#include "mode.h"\r
-\r
-/* MR23 In order to remove calls to PURIFY use the antlr -nopurify option */\r
-\r
-#ifndef PCCTS_PURIFY\r
-#define PCCTS_PURIFY(r,s) memset((char *) &(r),'\0',(s));\r
-#endif\r
-\r
-ANTLR_INFO\r
-\r
-\r
-/* MR20 G. Hobbelt For Borland C++ 4.x & 5.x compiling with ALL warnings enabled */\r
-#if defined(__TURBOC__)\r
-#pragma warn -aus  /* unused assignment of 'xxx' */\r
-#endif\r
-\r
-\r
-#ifdef __USE_PROTOS\r
-static void chkToken(char *, char *, char *, int);\r
-#else\r
-static void chkToken();\r
-#endif\r
-\r
-#ifdef __USE_PROTOS\r
-static int isDLGmaxToken(char *Token);                              /* MR3 */\r
-#else\r
-static int isDLGmaxToken();                                                         /* MR3 */\r
-#endif\r
-\r
-static int class_nest_level = 0;\r
-\r
-/* MR20 G. Hobbelt extern definitions moved to antlr.h */\r
-\r
-  \r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-grammar(void)\r
-#else\r
-grammar()\r
-#endif\r
-{\r
-  zzRULE;\r
-  zzBLOCK(zztasp1);\r
-  zzMake0;\r
-  {\r
-  Graph g;\r
-  {\r
-    zzBLOCK(zztasp2);\r
-    zzMake0;\r
-    {\r
-    for (;;) {\r
-      if ( !((setwd1[LA(1)]&0x1))) break;\r
-      if ( (LA(1)==94) ) {\r
-        zzmatch(94); zzCONSUME;\r
-        zzmatch(Action);\r
-        \r
-        if ( HdrAction==NULL ) {\r
-          HdrAction = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));\r
-          require(HdrAction!=NULL, "rule grammar: cannot allocate header action");\r
-          strcpy(HdrAction, LATEXT(1));\r
-        }\r
-        else warn("additional #header statement ignored");\r
- zzCONSUME;\r
-\r
-      }\r
-      else {\r
-        if ( (LA(1)==95) ) {\r
-          zzmatch(95); zzCONSUME;\r
-          zzmatch(Action);\r
-          \r
-          if ( FirstAction==NULL ) {\r
-            FirstAction = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));\r
-            require(FirstAction!=NULL, "rule grammar: cannot allocate #first action");\r
-            strcpy(FirstAction, LATEXT(1));\r
-          } else {\r
-            warn("additional #first statement ignored");\r
-          };\r
- zzCONSUME;\r
-\r
-        }\r
-        else {\r
-          if ( (LA(1)==96) ) {\r
-            zzmatch(96); zzCONSUME;\r
-            zzmatch(QuotedTerm);\r
-            \r
-            if ( GenCC ) {\r
-              warn("#parser meta-op incompatible with -CC; ignored");\r
-            }\r
-            else {\r
-              if ( strcmp(ParserName,"zzparser")==0 ) {\r
-                ParserName=StripQuotes(mystrdup(LATEXT(1)));\r
-                if ( RulePrefix[0]!='\0' )\r
-                {\r
-                  warn("#parser meta-op incompatible with '-gp prefix'; '-gp' ignored");\r
-                  RulePrefix[0]='\0';\r
-                }\r
-              }\r
-              else warn("additional #parser statement ignored");\r
-            }\r
- zzCONSUME;\r
-\r
-          }\r
-          else {\r
-            if ( (LA(1)==97) ) {\r
-              zzmatch(97); zzCONSUME;\r
-              zzmatch(QuotedTerm);\r
-              {\r
-                char *fname;\r
-                zzantlr_state st; FILE *f; struct zzdlg_state dst;\r
-                UserTokenDefsFile = mystrdup(LATEXT(1));\r
-                zzsave_antlr_state(&st);\r
-                zzsave_dlg_state(&dst);\r
-                fname = mystrdup(LATEXT(1));\r
-                f = fopen(StripQuotes(fname), "r");\r
-                if ( f==NULL ) {warn(eMsg1("cannot open token defs file '%s'", fname+1));}\r
-                else {\r
-                  ANTLRm(enum_file(fname+1), f, PARSE_ENUM_FILE);\r
-                  UserDefdTokens = 1;\r
-                }\r
-                zzrestore_antlr_state(&st);\r
-                zzrestore_dlg_state(&dst);\r
-              }\r
- zzCONSUME;\r
-\r
-            }\r
-            else break; /* MR6 code for exiting loop "for sure" */\r
-          }\r
-        }\r
-      }\r
-      zzLOOP(zztasp2);\r
-    }\r
-    zzEXIT(zztasp2);\r
-    }\r
-  }\r
-  {\r
-    zzBLOCK(zztasp2);\r
-    zzMake0;\r
-    {\r
-    for (;;) {\r
-      if ( !((setwd1[LA(1)]&0x2))) break;\r
-      if ( (LA(1)==Action) ) {\r
-        zzmatch(Action);\r
-        {\r
-          UserAction *ua = newUserAction(LATEXT(1));\r
-          ua->file = action_file; ua->line = action_line;\r
-          if ( class_nest_level>0 ) list_add(&class_before_actions, ua);\r
-          else list_add(&BeforeActions, ua);\r
-        }\r
- zzCONSUME;\r
-\r
-      }\r
-      else {\r
-        if ( (LA(1)==108) ) {\r
-          laction();\r
-        }\r
-        else {\r
-          if ( (LA(1)==109) ) {\r
-            lmember();\r
-          }\r
-          else {\r
-            if ( (LA(1)==110) ) {\r
-              lprefix();\r
-            }\r
-            else {\r
-              if ( (LA(1)==116) ) {\r
-                aLexclass();\r
-              }\r
-              else {\r
-                if ( (LA(1)==120) ) {\r
-                  token();\r
-                }\r
-                else {\r
-                  if ( (LA(1)==117) ) {\r
-                    error();\r
-                  }\r
-                  else {\r
-                    if ( (LA(1)==118) ) {\r
-                      tclass();\r
-                    }\r
-                    else {\r
-                      if ( (LA(1)==111) ) {\r
-                        aPred();\r
-                      }\r
-                      else {\r
-                        if ( (LA(1)==133) ) {\r
-                          default_exception_handler();\r
-                        }\r
-                        else {\r
-                          if ( (LA(1)==99) ) {\r
-                            class_def();\r
-                          }\r
-                          else {\r
-                            if ( (LA(1)==98) ) {\r
-                              zzmatch(98);\r
-                              \r
-                              if ( class_nest_level==0 )\r
-                              warn("missing class definition for trailing '}'");\r
-                              class_nest_level--;\r
- zzCONSUME;\r
-\r
-                            }\r
-                            else break; /* MR6 code for exiting loop "for sure" */\r
-                          }\r
-                        }\r
-                      }\r
-                    }\r
-                  }\r
-                }\r
-              }\r
-            }\r
-          }\r
-        }\r
-      }\r
-      zzLOOP(zztasp2);\r
-    }\r
-    zzEXIT(zztasp2);\r
-    }\r
-  }\r
-  rule();\r
-  g=zzaArg(zztasp1,3); SynDiag = (Junction *) zzaArg(zztasp1,3 ).left;\r
-  {\r
-    zzBLOCK(zztasp2);\r
-    zzMake0;\r
-    {\r
-    for (;;) {\r
-      if ( !((setwd1[LA(1)]&0x4))) break;\r
-      if ( (LA(1)==NonTerminal) ) {\r
-        rule();\r
-        if ( zzaArg(zztasp2,1 ).left!=NULL ) {\r
-          g.right = NULL;\r
-          \r
-/* MR21a */             /*  Avoid use of a malformed graph when CannotContinue */\r
-          /* MR21a */             /*  is already set                                     */\r
-          /* MR21a */\r
-          /* MR21a */             if (! (CannotContinue && g.left == NULL)) {\r
-            /* MR21a */               g = Or(g, zzaArg(zztasp2,1));\r
-            /* MR21a */             }\r
-          /* MR21a */                }\r
-      }\r
-      else {\r
-        if ( (LA(1)==116) ) {\r
-          aLexclass();\r
-        }\r
-        else {\r
-          if ( (LA(1)==120) ) {\r
-            token();\r
-          }\r
-          else {\r
-            if ( (LA(1)==117) ) {\r
-              error();\r
-            }\r
-            else {\r
-              if ( (LA(1)==118) ) {\r
-                tclass();\r
-              }\r
-              else {\r
-                if ( (LA(1)==111) ) {\r
-                  aPred();\r
-                }\r
-                else {\r
-                  if ( (LA(1)==99) ) {\r
-                    class_def();\r
-                  }\r
-                  else {\r
-                    if ( (LA(1)==98) ) {\r
-                      zzmatch(98);\r
-                      \r
-                      if ( class_nest_level==0 )\r
-                      warn("missing class definition for trailing '}'");\r
-                      class_nest_level--;\r
- zzCONSUME;\r
-\r
-                    }\r
-                    else break; /* MR6 code for exiting loop "for sure" */\r
-                  }\r
-                }\r
-              }\r
-            }\r
-          }\r
-        }\r
-      }\r
-      zzLOOP(zztasp2);\r
-    }\r
-    zzEXIT(zztasp2);\r
-    }\r
-  }\r
-  {\r
-    zzBLOCK(zztasp2);\r
-    zzMake0;\r
-    {\r
-    for (;;) {\r
-      if ( !((setwd1[LA(1)]&0x8))) break;\r
-      if ( (LA(1)==Action) ) {\r
-        zzmatch(Action);\r
-        {\r
-          UserAction *ua = newUserAction(LATEXT(1));\r
-          ua->file = action_file; ua->line = action_line;\r
-          if ( class_nest_level>0 ) list_add(&class_after_actions, ua);\r
-          else list_add(&AfterActions, ua);\r
-        }\r
- zzCONSUME;\r
-\r
-      }\r
-      else {\r
-        if ( (LA(1)==108) ) {\r
-          laction();\r
-        }\r
-        else {\r
-          if ( (LA(1)==109) ) {\r
-            lmember();\r
-          }\r
-          else {\r
-            if ( (LA(1)==110) ) {\r
-              lprefix();\r
-            }\r
-            else {\r
-              if ( (LA(1)==117) ) {\r
-                error();\r
-              }\r
-              else {\r
-                if ( (LA(1)==118) ) {\r
-                  tclass();\r
-                }\r
-                else {\r
-                  if ( (LA(1)==99) ) {\r
-                    class_def();\r
-                  }\r
-                  else {\r
-                    if ( (LA(1)==111) ) {\r
-                      aPred();\r
-                    }\r
-                    else {\r
-                      if ( (LA(1)==98) ) {\r
-                        zzmatch(98);\r
-                        \r
-                        if ( class_nest_level==0 )\r
-                        warn("missing class definition for trailing '}'");\r
-                        class_nest_level--;\r
- zzCONSUME;\r
-\r
-                      }\r
-                      else break; /* MR6 code for exiting loop "for sure" */\r
-                    }\r
-                  }\r
-                }\r
-              }\r
-            }\r
-          }\r
-        }\r
-      }\r
-      zzLOOP(zztasp2);\r
-    }\r
-    zzEXIT(zztasp2);\r
-    }\r
-  }\r
-  zzmatch(Eof); zzCONSUME;\r
-  zzEXIT(zztasp1);\r
-  return;\r
-fail:\r
-  zzEXIT(zztasp1);\r
-  CannotContinue=TRUE;  \r
-  zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);\r
-  zzresynch(setwd1, 0x10);\r
-  }\r
-}\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-class_def(void)\r
-#else\r
-class_def()\r
-#endif\r
-{\r
-  zzRULE;\r
-  zzBLOCK(zztasp1);\r
-  zzMake0;\r
-  {\r
-  int go=1; char name[MaxRuleName+1];\r
-  zzmatch(99); zzCONSUME;\r
-  {\r
-    zzBLOCK(zztasp2);\r
-    zzMake0;\r
-    {\r
-    if ( (LA(1)==NonTerminal) ) {\r
-      zzmatch(NonTerminal);\r
-      if(go) strncpy(name,LATEXT(1),MaxRuleName);\r
- zzCONSUME;\r
-\r
-    }\r
-    else {\r
-      if ( (LA(1)==TokenTerm) ) {\r
-        zzmatch(TokenTerm);\r
-        if(go) strncpy(name,LATEXT(1),MaxRuleName);\r
- zzCONSUME;\r
-\r
-      }\r
-      else {zzFAIL(1,zzerr1,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
-    }\r
-    zzEXIT(zztasp2);\r
-    }\r
-  }\r
-  \r
-  if ( CurrentClassName[0]!='\0' && strcmp(CurrentClassName,name)!=0\r
-  && GenCC ) {\r
-    err("only one grammar class allowed in this release");\r
-    go = 0;\r
-  }\r
-  else strcpy(CurrentClassName, name);\r
-  if ( !GenCC ) { err("class meta-op used without C++ option"); }\r
-  {\r
-    zzBLOCK(zztasp2);\r
-    zzMake0;\r
-    {\r
-    while ( (setwd1[LA(1)]&0x20) ) {\r
-      zzsetmatch(zzerr2, zzerr3);\r
-      if (ClassDeclStuff == NULL) {\r
-        /* MR10 */                   ClassDeclStuff=(char *)calloc(MaxClassDeclStuff+1,sizeof(char));\r
-        /* MR10 */              };\r
-      /* MR10 */              strncat(ClassDeclStuff," ",MaxClassDeclStuff);\r
-      /* MR10 */              strncat(ClassDeclStuff,LATEXT(1),MaxClassDeclStuff);\r
-      /* MR22 */              do {\r
-        /* MR22 */                if (0 == strcmp(LATEXT(1),"public")) break;\r
-        /* MR22 */                if (0 == strcmp(LATEXT(1),"private")) break;\r
-        /* MR22 */                if (0 == strcmp(LATEXT(1),"protected")) break;\r
-        /* MR22 */                if (0 == strcmp(LATEXT(1),"virtual")) break;\r
-        /* MR22 */                if (0 == strcmp(LATEXT(1),",")) break;\r
-        /* MR22 */                if (0 == strcmp(LATEXT(1),":")) break;\r
-        /* MR22 */                if (BaseClassName != NULL) break;\r
-        /* MR22 */                BaseClassName=(char *)calloc(strlen(LATEXT(1))+1,sizeof(char));\r
-        /* MR22 */                require(BaseClassName!=NULL, "rule grammar: cannot allocate base class name");\r
-        /* MR22 */                               strcpy(BaseClassName,LATEXT(1));\r
-        /* MR22 */              } while (0);\r
-      /* MR10 */\r
- zzCONSUME;\r
-\r
-      zzLOOP(zztasp2);\r
-    }\r
-    zzEXIT(zztasp2);\r
-    }\r
-  }\r
-  zzmatch(102);\r
-  \r
-  no_classes_found = 0;\r
-  if ( class_nest_level>=1 ) {warn("cannot have nested classes");}\r
-  else class_nest_level++;\r
- zzCONSUME;\r
-\r
-  zzEXIT(zztasp1);\r
-  return;\r
-fail:\r
-  zzEXIT(zztasp1);\r
-  CannotContinue=TRUE;  \r
-  zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);\r
-  zzresynch(setwd1, 0x40);\r
-  }\r
-}\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-rule(void)\r
-#else\r
-rule()\r
-#endif\r
-{\r
-  zzRULE;\r
-  zzBLOCK(zztasp1);\r
-  zzMake0;\r
-  {\r
-  \r
-  \r
-                       ExceptionGroup *eg;\r
-  RuleEntry *q; Junction *p; Graph r; int f, l; ECnode *e;\r
-  set toksrefd, rulesrefd;\r
-  char *pdecl=NULL, *ret=NULL, *a; CurRetDef = CurParmDef = NULL;\r
-  CurExGroups = NULL;\r
-  CurElementLabels = NULL;\r
-  CurAstLabelsInActions = NULL; /* MR27 */\r
-  /* We want a new element label hash table for each rule */\r
-  if ( Elabel!=NULL ) killHashTable(Elabel);\r
-  Elabel = newHashTable();\r
-  attribsRefdFromAction = empty;\r
-  zzmatch(NonTerminal);\r
-  q=NULL;\r
-  if ( hash_get(Rname, LATEXT(1))!=NULL ) {\r
-    err(eMsg1("duplicate rule definition: '%s'",LATEXT(1)));\r
-    CannotContinue=TRUE;\r
-  }\r
-  else\r
-  {\r
-    q = (RuleEntry *)hash_add(Rname,\r
-    LATEXT(1),\r
-    (Entry *)newRuleEntry(LATEXT(1)));\r
-    CurRule = q->str;\r
-  }\r
-  CurRuleNode = q;\r
-  f = CurFile; l = zzline;\r
-  NumRules++;\r
- zzCONSUME;\r
-\r
-  {\r
-    zzBLOCK(zztasp2);\r
-    zzMake0;\r
-    {\r
-    if ( (LA(1)==103) ) {\r
-      zzmatch(103);\r
-      if ( q!=NULL ) q->noAST = TRUE;\r
- zzCONSUME;\r
-\r
-    }\r
-    else {\r
-      if ( (setwd1[LA(1)]&0x80) ) {\r
-      }\r
-      else {zzFAIL(1,zzerr4,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
-    }\r
-    zzEXIT(zztasp2);\r
-    }\r
-  }\r
-  {\r
-    zzBLOCK(zztasp2);\r
-    zzMake0;\r
-    {\r
-    ;\r
-    if ( (setwd2[LA(1)]&0x1) ) {\r
-      {\r
-        zzBLOCK(zztasp3);\r
-        zzMake0;\r
-        {\r
-        if ( (LA(1)==104) ) {\r
-          zzmatch(104); zzCONSUME;\r
-        }\r
-        else {\r
-          if ( (LA(1)==PassAction) ) {\r
-          }\r
-          else {zzFAIL(1,zzerr5,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
-        }\r
-        zzEXIT(zztasp3);\r
-        }\r
-      }\r
-      zzmatch(PassAction);\r
-      pdecl = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));\r
-      require(pdecl!=NULL, "rule rule: cannot allocate param decl");\r
-      strcpy(pdecl, LATEXT(1));\r
-      CurParmDef = pdecl;\r
- zzCONSUME;\r
-\r
-    }\r
-    else {\r
-      if ( (setwd2[LA(1)]&0x2) ) {\r
-      }\r
-      else {zzFAIL(1,zzerr6,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
-    }\r
-    zzEXIT(zztasp2);\r
-    }\r
-  }\r
-  {\r
-    zzBLOCK(zztasp2);\r
-    zzMake0;\r
-    {\r
-    if ( (LA(1)==105) ) {\r
-      zzmatch(105); zzCONSUME;\r
-      zzmatch(PassAction);\r
-      ret = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));\r
-      require(ret!=NULL, "rule rule: cannot allocate ret type");\r
-      strcpy(ret, LATEXT(1));\r
-      CurRetDef = ret;\r
- zzCONSUME;\r
-\r
-    }\r
-    else {\r
-      if ( (setwd2[LA(1)]&0x4) ) {\r
-      }\r
-      else {zzFAIL(1,zzerr7,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
-    }\r
-    zzEXIT(zztasp2);\r
-    }\r
-  }\r
-  {\r
-    zzBLOCK(zztasp2);\r
-    zzMake0;\r
-    {\r
-    if ( (LA(1)==QuotedTerm) ) {\r
-      zzmatch(QuotedTerm);\r
-      if ( q!=NULL ) q->egroup=mystrdup(LATEXT(1));\r
- zzCONSUME;\r
-\r
-    }\r
-    else {\r
-      if ( (LA(1)==106) ) {\r
-      }\r
-      else {zzFAIL(1,zzerr8,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
-    }\r
-    zzEXIT(zztasp2);\r
-    }\r
-  }\r
-  \r
-  if ( GenEClasseForRules && q!=NULL ) {\r
-    e = newECnode;\r
-    require(e!=NULL, "cannot allocate error class node");\r
-    if ( q->egroup == NULL ) {a = q->str; a[0] = (char)toupper(a[0]);}\r
-    else a = q->egroup;\r
-    if ( Tnum( a ) == 0 )\r
-    {\r
-      e->tok = addTname( a );\r
-      list_add(&eclasses, (char *)e);\r
-      if ( q->egroup == NULL ) a[0] = (char)tolower(a[0]);\r
-      /* refers to itself */\r
-      list_add(&(e->elist), mystrdup(q->str));\r
-    }\r
-    else {\r
-      warn(eMsg1("default errclass for '%s' would conflict with token/errclass/tokclass",a));\r
-      if ( q->egroup == NULL ) a[0] = (char)tolower(a[0]);\r
-      free((char *)e);\r
-    }\r
-  }\r
-  BlkLevel++;\r
-  if (BlkLevel >= MAX_BLK_LEVEL) fatal("Blocks nested too deeply");\r
-  /* MR23 */    CurBlockID_array[BlkLevel] = CurBlockID;\r
-  /* MR23 */    CurAltNum_array[BlkLevel] = CurAltNum;\r
-  zzmatch(106);\r
-  inAlt=1;\r
- zzCONSUME;\r
-\r
-  block( &toksrefd, &rulesrefd );\r
-  r = makeBlk(zzaArg(zztasp1,7),0, NULL /* pFirstSetSymbol */ );\r
-  CurRuleBlk = (Junction *)r.left;\r
-  CurRuleBlk->blockid = CurBlockID;\r
-  CurRuleBlk->jtype = RuleBlk;\r
-  if ( q!=NULL ) CurRuleBlk->rname = q->str;\r
-  CurRuleBlk->file = f;\r
-  CurRuleBlk->line = l;\r
-  CurRuleBlk->pdecl = pdecl;\r
-  CurRuleBlk->ret = ret;\r
-  CurRuleBlk->lock = makelocks();\r
-  CurRuleBlk->pred_lock = makelocks();\r
-  CurRuleBlk->tokrefs = toksrefd;\r
-  CurRuleBlk->rulerefs = rulesrefd;\r
-  p = newJunction();   /* add EndRule Node */\r
-  ((Junction *)r.right)->p1 = (Node *)p;\r
-  r.right = (Node *) p;\r
-  p->jtype = EndRule;\r
-  p->lock = makelocks();\r
-  p->pred_lock = makelocks();\r
-  CurRuleBlk->end = p;\r
-  if ( q!=NULL ) q->rulenum = NumRules;\r
-  zzaArg(zztasp1,7) = r;\r
-  \r
-  /* MR23 */      CurBlockID_array[BlkLevel] = (-1);\r
-  /* MR23 */      CurAltNum_array[BlkLevel] = (-1);                \r
-  --BlkLevel;\r
-  altFixup();leFixup();egFixup();\r
-  zzmatch(107);\r
-  inAlt=0;\r
- zzCONSUME;\r
-\r
-  {\r
-    zzBLOCK(zztasp2);\r
-    zzMake0;\r
-    {\r
-    if ( (LA(1)==Action) ) {\r
-      zzmatch(Action);\r
-      a = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));\r
-      require(a!=NULL, "rule rule: cannot allocate error action");\r
-      strcpy(a, LATEXT(1));\r
-      CurRuleBlk->erraction = a;\r
- zzCONSUME;\r
-\r
-    }\r
-    else {\r
-      if ( (setwd2[LA(1)]&0x8) ) {\r
-      }\r
-      else {zzFAIL(1,zzerr9,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
-    }\r
-    zzEXIT(zztasp2);\r
-    }\r
-  }\r
-  {\r
-    zzBLOCK(zztasp2);\r
-    zzMake0;\r
-    {\r
-    while ( (LA(1)==133) ) {\r
-       eg  = exception_group();\r
-\r
-      if ( eg!=NULL ) {\r
-        list_add(&CurExGroups, (void *)eg);\r
-        if (eg->label == NULL || *eg->label=='\0' ) q->has_rule_exception = 1;\r
-      }\r
-      zzLOOP(zztasp2);\r
-    }\r
-    zzEXIT(zztasp2);\r
-    }\r
-  }\r
-  if ( q==NULL ) zzaArg(zztasp1,0 ).left = NULL; else zzaArg(zztasp1,0) = zzaArg(zztasp1,7);\r
-  CurRuleBlk->exceptions = CurExGroups;\r
-  CurRuleBlk->el_labels = CurElementLabels;\r
-  CurRuleNode->ast_labels_in_actions = CurAstLabelsInActions;\r
-  CurRuleNode = NULL;\r
-  zzEXIT(zztasp1);\r
-  return;\r
-fail:\r
-  zzEXIT(zztasp1);\r
-  CannotContinue=TRUE;  \r
-  zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);\r
-  zzresynch(setwd2, 0x10);\r
-  }\r
-}\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-laction(void)\r
-#else\r
-laction()\r
-#endif\r
-{\r
-  zzRULE;\r
-  zzBLOCK(zztasp1);\r
-  zzMake0;\r
-  {\r
-  char *a;\r
-  zzmatch(108); zzCONSUME;\r
-  zzmatch(Action);\r
-  \r
-  a = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));\r
-  require(a!=NULL, "rule laction: cannot allocate action");\r
-  strcpy(a, LATEXT(1));\r
-  list_add(&LexActions, a);\r
- zzCONSUME;\r
-\r
-  zzEXIT(zztasp1);\r
-  return;\r
-fail:\r
-  zzEXIT(zztasp1);\r
-  CannotContinue=TRUE;  \r
-  zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);\r
-  zzresynch(setwd2, 0x20);\r
-  }\r
-}\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-lmember(void)\r
-#else\r
-lmember()\r
-#endif\r
-{\r
-  zzRULE;\r
-  zzBLOCK(zztasp1);\r
-  zzMake0;\r
-  {\r
-  char *a;\r
-  zzmatch(109); zzCONSUME;\r
-  zzmatch(Action);\r
-  \r
-  /* MR1 */            if (! GenCC) {\r
-    /* MR1 */            err("Use #lexmember only in C++ mode (to insert code in DLG class header");\r
-    /* MR1 */          } else {\r
-    /* MR1 */            a = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));\r
-    /* MR1 */            require(a!=NULL, "rule lmember: cannot allocate action");\r
-    /* MR1 */            strcpy(a, LATEXT(1));\r
-    /* MR1 */            list_add(&LexMemberActions, a);\r
-    /* MR1 */          };\r
-  /* MR1 */\r
- zzCONSUME;\r
-\r
-  zzEXIT(zztasp1);\r
-  return;\r
-fail:\r
-  zzEXIT(zztasp1);\r
-  CannotContinue=TRUE;  \r
-  zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);\r
-  zzresynch(setwd2, 0x40);\r
-  }\r
-}\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-lprefix(void)\r
-#else\r
-lprefix()\r
-#endif\r
-{\r
-  zzRULE;\r
-  zzBLOCK(zztasp1);\r
-  zzMake0;\r
-  {\r
-  char *a;\r
-  zzmatch(110); zzCONSUME;\r
-  zzmatch(Action);\r
-  \r
-  /* MR1 */            if (! GenCC) {\r
-    /* MR1 */            err("Use #lexprefix only in C++ mode (to insert code in DLG class header");\r
-    /* MR1 */          } else {\r
-    /* MR1 */            a = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));\r
-    /* MR1 */            require(a!=NULL, "rule lprefix: cannot allocate action");\r
-    /* MR1 */            strcpy(a, LATEXT(1));\r
-    /* MR1 */            list_add(&LexPrefixActions, a);\r
-    /* MR1 */          };\r
-  /* MR1 */\r
- zzCONSUME;\r
-\r
-  zzEXIT(zztasp1);\r
-  return;\r
-fail:\r
-  zzEXIT(zztasp1);\r
-  CannotContinue=TRUE;  \r
-  zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);\r
-  zzresynch(setwd2, 0x80);\r
-  }\r
-}\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-aPred(void)\r
-#else\r
-aPred()\r
-#endif\r
-{\r
-  zzRULE;\r
-  zzBLOCK(zztasp1);\r
-  zzMake0;\r
-  {\r
-  PredEntry     *predEntry=NULL;\r
-  char          *name=NULL;\r
-  Predicate     *predExpr=NULL;\r
-  char          *predLiteral=NULL;\r
-  int           save_file;\r
-  int           save_line;\r
-  int           predExprPresent=0;\r
-  zzmatch(111);\r
-  \r
-  MR_usingPredNames=1;      /* will need to use -mrhoist version of genPredTree */\r
- zzCONSUME;\r
-\r
-  zzmatch(TokenTerm);\r
-  name=mystrdup(LATEXT(1));\r
- zzCONSUME;\r
-\r
-  \r
-  /* don't free - referenced in predicates */\r
-  \r
-            CurPredName=(char *)calloc(1,strlen(name) + 10);\r
-  strcat(CurPredName,"#pred ");\r
-  strcat(CurPredName,name);\r
-  \r
-            predEntry=(PredEntry *) hash_get(Pname,name);\r
-  if (predEntry != NULL) {\r
-  warnFL(eMsg1("#pred %s previously defined - ignored",name),\r
-  FileStr[action_file],action_line);\r
-  name=NULL;\r
-};\r
-  {\r
-    zzBLOCK(zztasp2);\r
-    zzMake0;\r
-    {\r
-    if ( (LA(1)==Pred) ) {\r
-      zzmatch(Pred);\r
-      predLiteral=mystrdup(LATEXT(1));\r
-      save_line=action_line;\r
-      save_file=action_file;\r
- zzCONSUME;\r
-\r
-      {\r
-        zzBLOCK(zztasp3);\r
-        zzMake0;\r
-        {\r
-        if ( (setwd3[LA(1)]&0x1) ) {\r
-           predExpr  = predOrExpr();\r
-\r
-          predExprPresent=1;\r
-        }\r
-        else {\r
-          if ( (setwd3[LA(1)]&0x2) ) {\r
-          }\r
-          else {zzFAIL(1,zzerr10,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
-        }\r
-        zzEXIT(zztasp3);\r
-        }\r
-      }\r
-      if (predLiteral != NULL && name != NULL) {\r
-        \r
-                      /*\r
-        *  predExpr may be NULL due to syntax errors\r
-        *    or simply omitted by the user\r
-        */\r
-        \r
-                      predEntry=newPredEntry(name);\r
-        predEntry->file=save_file;\r
-        predEntry->line=save_line;\r
-        predExpr=MR_predFlatten(predExpr);\r
-        predEntry->predLiteral=predLiteral;\r
-        if (! predExprPresent || predExpr == NULL) {\r
-          predExpr=new_pred();\r
-          predExpr->expr=predLiteral;\r
-          predExpr->source=newActionNode();\r
-          predExpr->source->action=predExpr->expr;\r
-          predExpr->source->rname=CurPredName;\r
-          predExpr->source->line=action_line;\r
-          predExpr->source->file=action_file;\r
-          predExpr->source->is_predicate=1;\r
-          predExpr->k=predicateLookaheadDepth(predExpr->source);\r
-        };\r
-        predEntry->pred=predExpr;\r
-        hash_add(Pname,name,(Entry *)predEntry);\r
-        predExpr=NULL;\r
-      };\r
-      predicate_free(predExpr);\r
-    }\r
-    else {\r
-      if ( (setwd3[LA(1)]&0x4) ) {\r
-        save_line=zzline; save_file=CurFile;\r
-         predExpr  = predOrExpr();\r
-\r
-        if (predExpr != NULL && name != NULL) {\r
-          predEntry=newPredEntry(name);\r
-          predEntry->file=CurFile;\r
-          predEntry->line=zzline;\r
-          predExpr=MR_predFlatten(predExpr);\r
-          predEntry->pred=predExpr;\r
-          hash_add(Pname,name,(Entry *)predEntry);\r
-          predExpr=NULL;\r
-        };\r
-        predicate_free(predExpr);\r
-      }\r
-      else {zzFAIL(1,zzerr11,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
-    }\r
-    zzEXIT(zztasp2);\r
-    }\r
-  }\r
-  {\r
-    zzBLOCK(zztasp2);\r
-    zzMake0;\r
-    {\r
-    if ( (LA(1)==107) ) {\r
-      zzmatch(107); zzCONSUME;\r
-    }\r
-    else {\r
-      if ( (setwd3[LA(1)]&0x8) ) {\r
-      }\r
-      else {zzFAIL(1,zzerr12,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
-    }\r
-    zzEXIT(zztasp2);\r
-    }\r
-  }\r
-  zzEXIT(zztasp1);\r
-  return;\r
-fail:\r
-  zzEXIT(zztasp1);\r
-  predicate_free(predExpr);\r
-  zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);\r
-  zzresynch(setwd3, 0x10);\r
-  }\r
-}\r
-\r
-Predicate *\r
-#ifdef __USE_PROTOS\r
-predOrExpr(void)\r
-#else\r
-predOrExpr()\r
-#endif\r
-{\r
-  Predicate *   _retv;\r
-  zzRULE;\r
-  zzBLOCK(zztasp1);\r
-  PCCTS_PURIFY(_retv,sizeof(Predicate *  ))\r
-  zzMake0;\r
-  {\r
-  Predicate     *ORnode;\r
-  Predicate     *predExpr;\r
-  Predicate     **tail=NULL;\r
-   predExpr  = predAndExpr();\r
-\r
-  \r
-  ORnode=new_pred();\r
-  ORnode->expr=PRED_OR_LIST;\r
-  if (predExpr != NULL) {\r
-    ORnode->down=predExpr;\r
-    tail=&predExpr->right;\r
-  };\r
-  {\r
-    zzBLOCK(zztasp2);\r
-    zzMake0;\r
-    {\r
-    while ( (LA(1)==112) ) {\r
-      zzmatch(112); zzCONSUME;\r
-       predExpr  = predAndExpr();\r
-\r
-      \r
-      if (predExpr != NULL) {\r
-        *tail=predExpr;\r
-        tail=&predExpr->right;\r
-      };\r
-      zzLOOP(zztasp2);\r
-    }\r
-    zzEXIT(zztasp2);\r
-    }\r
-  }\r
-  \r
-  _retv=ORnode;\r
-  ORnode=NULL;\r
-  zzEXIT(zztasp1);\r
-  return _retv;\r
-fail:\r
-  zzEXIT(zztasp1);\r
-  predicate_free(ORnode);  \r
-  zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);\r
-  zzresynch(setwd3, 0x20);\r
-  return _retv;\r
-  }\r
-}\r
-\r
-Predicate *\r
-#ifdef __USE_PROTOS\r
-predAndExpr(void)\r
-#else\r
-predAndExpr()\r
-#endif\r
-{\r
-  Predicate *   _retv;\r
-  zzRULE;\r
-  zzBLOCK(zztasp1);\r
-  PCCTS_PURIFY(_retv,sizeof(Predicate *  ))\r
-  zzMake0;\r
-  {\r
-  Predicate     *ANDnode;\r
-  Predicate     *predExpr;\r
-  Predicate     **tail=NULL;\r
-   predExpr  = predPrimary();\r
-\r
-  \r
-  ANDnode=new_pred();\r
-  ANDnode->expr=PRED_AND_LIST;\r
-  if (predExpr != NULL) {\r
-    ANDnode->down=predExpr;\r
-    tail=&predExpr->right;\r
-  };\r
-  {\r
-    zzBLOCK(zztasp2);\r
-    zzMake0;\r
-    {\r
-    while ( (LA(1)==113) ) {\r
-      zzmatch(113); zzCONSUME;\r
-       predExpr  = predPrimary();\r
-\r
-      \r
-      if (predExpr != NULL) {\r
-        *tail=predExpr;\r
-        tail=&predExpr->right;\r
-      };\r
-      zzLOOP(zztasp2);\r
-    }\r
-    zzEXIT(zztasp2);\r
-    }\r
-  }\r
-  \r
-  _retv=ANDnode;\r
-  ANDnode=NULL;\r
-  zzEXIT(zztasp1);\r
-  return _retv;\r
-fail:\r
-  zzEXIT(zztasp1);\r
-  predicate_free(ANDnode);  \r
-  zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);\r
-  zzresynch(setwd3, 0x40);\r
-  return _retv;\r
-  }\r
-}\r
-\r
-Predicate *\r
-#ifdef __USE_PROTOS\r
-predPrimary(void)\r
-#else\r
-predPrimary()\r
-#endif\r
-{\r
-  Predicate *   _retv;\r
-  zzRULE;\r
-  zzBLOCK(zztasp1);\r
-  PCCTS_PURIFY(_retv,sizeof(Predicate *  ))\r
-  zzMake0;\r
-  {\r
-  \r
-  char          *name=NULL;\r
-  PredEntry     *predEntry=NULL;\r
-  Predicate     *predExpr=NULL;\r
-  if ( (LA(1)==TokenTerm) ) {\r
-    zzmatch(TokenTerm);\r
-    name=mystrdup(LATEXT(1));\r
- zzCONSUME;\r
-\r
-    \r
-    predEntry=(PredEntry *) hash_get(Pname,name);\r
-    if (predEntry == NULL) {\r
-      warnFL(eMsg1("no previously defined #pred with name \"%s\"",name),\r
-      FileStr[CurFile],zzline);\r
-      name=NULL;\r
-      _retv=NULL;\r
-    } else {\r
-      predExpr=predicate_dup(predEntry->pred);\r
-      predExpr->predEntry=predEntry;\r
-      _retv=predExpr;\r
-    };\r
-  }\r
-  else {\r
-    if ( (LA(1)==114) ) {\r
-      zzmatch(114); zzCONSUME;\r
-       predExpr  = predOrExpr();\r
-\r
-      zzmatch(115);\r
-      \r
-      _retv=predExpr;\r
- zzCONSUME;\r
-\r
-    }\r
-    else {\r
-      if ( (LA(1)==103) ) {\r
-        zzmatch(103); zzCONSUME;\r
-         predExpr  = predPrimary();\r
-\r
-        \r
-        predExpr->inverted=!predExpr->inverted;\r
-        _retv=predExpr;\r
-      }\r
-      else {zzFAIL(1,zzerr13,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
-    }\r
-  }\r
-  zzEXIT(zztasp1);\r
-  return _retv;\r
-fail:\r
-  zzEXIT(zztasp1);\r
-  \r
-  predicate_free(predExpr);\r
-  zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);\r
-  zzresynch(setwd3, 0x80);\r
-  return _retv;\r
-  }\r
-}\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-aLexclass(void)\r
-#else\r
-aLexclass()\r
-#endif\r
-{\r
-  zzRULE;\r
-  zzBLOCK(zztasp1);\r
-  zzMake0;\r
-  {\r
-  zzmatch(116); zzCONSUME;\r
-  zzmatch(TokenTerm);\r
-  lexclass(mystrdup(LATEXT(1)));\r
- zzCONSUME;\r
-\r
-  zzEXIT(zztasp1);\r
-  return;\r
-fail:\r
-  zzEXIT(zztasp1);\r
-  CannotContinue=TRUE;  \r
-  zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);\r
-  zzresynch(setwd4, 0x1);\r
-  }\r
-}\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-error(void)\r
-#else\r
-error()\r
-#endif\r
-{\r
-  zzRULE;\r
-  zzBLOCK(zztasp1);\r
-  zzMake0;\r
-  {\r
-  char *t=NULL; ECnode *e; int go=1; TermEntry *p;\r
-  zzmatch(117); zzCONSUME;\r
-  {\r
-    zzBLOCK(zztasp2);\r
-    zzMake0;\r
-    {\r
-    ;\r
-    if ( (LA(1)==TokenTerm) ) {\r
-      zzmatch(TokenTerm);\r
-      t=mystrdup(LATEXT(1));\r
- zzCONSUME;\r
-\r
-    }\r
-    else {\r
-      if ( (LA(1)==QuotedTerm) ) {\r
-        zzmatch(QuotedTerm);\r
-        t=mystrdup(LATEXT(1));\r
- zzCONSUME;\r
-\r
-      }\r
-      else {zzFAIL(1,zzerr14,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
-    }\r
-    zzEXIT(zztasp2);\r
-    }\r
-  }\r
-  e = newECnode;\r
-  require(e!=NULL, "cannot allocate error class node");\r
-  e->lexclass = CurrentLexClass;\r
-  if ( Tnum( (t=StripQuotes(t)) ) == 0 )\r
-  {\r
-    if ( hash_get(Texpr, t) != NULL )\r
-    warn(eMsg1("errclass name conflicts with regular expression  '%s'",t));\r
-    e->tok = addTname( t );\r
-    set_orel(e->tok, &imag_tokens);\r
-    require((p=(TermEntry *)hash_get(Tname, t)) != NULL,\r
-    "hash table mechanism is broken");\r
-    p->classname = 1;  /* entry is errclass name, not token */\r
-    list_add(&eclasses, (char *)e);\r
-  }\r
-  else\r
-  {\r
-  warn(eMsg1("redefinition of errclass or conflict w/token or tokclass '%s'; ignored",t));\r
-  free( (char *)e );\r
-  go=0;\r
-}\r
-  zzmatch(102); zzCONSUME;\r
-  {\r
-    zzBLOCK(zztasp2);\r
-    zzMake0;\r
-    {\r
-    if ( (LA(1)==NonTerminal) ) {\r
-      zzmatch(NonTerminal);\r
-      if ( go ) t=mystrdup(LATEXT(1));\r
- zzCONSUME;\r
-\r
-    }\r
-    else {\r
-      if ( (LA(1)==TokenTerm) ) {\r
-        zzmatch(TokenTerm);\r
-        if ( go ) t=mystrdup(LATEXT(1));\r
- zzCONSUME;\r
-\r
-      }\r
-      else {\r
-        if ( (LA(1)==QuotedTerm) ) {\r
-          zzmatch(QuotedTerm);\r
-          if ( go ) t=mystrdup(LATEXT(1));\r
- zzCONSUME;\r
-\r
-        }\r
-        else {zzFAIL(1,zzerr15,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
-      }\r
-    }\r
-    zzEXIT(zztasp2);\r
-    }\r
-  }\r
-  if ( go ) list_add(&(e->elist), t);\r
-  {\r
-    zzBLOCK(zztasp2);\r
-    zzMake0;\r
-    {\r
-    while ( (setwd4[LA(1)]&0x2) ) {\r
-      {\r
-        zzBLOCK(zztasp3);\r
-        zzMake0;\r
-        {\r
-        if ( (LA(1)==NonTerminal) ) {\r
-          zzmatch(NonTerminal);\r
-          if ( go ) t=mystrdup(LATEXT(1));\r
- zzCONSUME;\r
-\r
-        }\r
-        else {\r
-          if ( (LA(1)==TokenTerm) ) {\r
-            zzmatch(TokenTerm);\r
-            if ( go ) t=mystrdup(LATEXT(1));\r
- zzCONSUME;\r
-\r
-          }\r
-          else {\r
-            if ( (LA(1)==QuotedTerm) ) {\r
-              zzmatch(QuotedTerm);\r
-              if ( go ) t=mystrdup(LATEXT(1));\r
- zzCONSUME;\r
-\r
-            }\r
-            else {zzFAIL(1,zzerr16,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
-          }\r
-        }\r
-        zzEXIT(zztasp3);\r
-        }\r
-      }\r
-      if ( go ) list_add(&(e->elist), t);\r
-      zzLOOP(zztasp2);\r
-    }\r
-    zzEXIT(zztasp2);\r
-    }\r
-  }\r
-  zzmatch(98); zzCONSUME;\r
-  zzEXIT(zztasp1);\r
-  return;\r
-fail:\r
-  zzEXIT(zztasp1);\r
-  CannotContinue=TRUE;  \r
-  zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);\r
-  zzresynch(setwd4, 0x4);\r
-  }\r
-}\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-tclass(void)\r
-#else\r
-tclass()\r
-#endif\r
-{\r
-  zzRULE;\r
-  zzBLOCK(zztasp1);\r
-  zzMake0;\r
-  {\r
-  char *t=NULL; TCnode *e; int go=1,tok,totok; TermEntry *p, *term, *toterm;\r
-  char *akaString=NULL; int save_file; int save_line;\r
-  char *totext=NULL;\r
-  zzmatch(118); zzCONSUME;\r
-  zzmatch(TokenTerm);\r
-  t=mystrdup(LATEXT(1));\r
- zzCONSUME;\r
-\r
-  e = newTCnode;\r
-  require(e!=NULL, "cannot allocate token class node");\r
-  e->lexclass = CurrentLexClass;\r
-  if ( Tnum( t ) == 0 )\r
-  {\r
-    e->tok = addTname( t );\r
-    set_orel(e->tok, &imag_tokens);\r
-    set_orel(e->tok, &tokclasses);\r
-    require((p=(TermEntry *)hash_get(Tname, t)) != NULL,\r
-    "hash table mechanism is broken");\r
-    p->classname = 1;  /* entry is class name, not token */\r
-    p->tclass = e;             /* save ptr to this tclass def */\r
-    list_add(&tclasses, (char *)e);\r
-  }\r
-  else\r
-  {\r
-  warn(eMsg1("redefinition of tokclass or conflict w/token '%s'; ignored",t));\r
-  free( (char *)e );\r
-  go=0;\r
-}\r
-  {\r
-    zzBLOCK(zztasp2);\r
-    zzMake0;\r
-    {\r
-    if ( (LA(1)==114) ) {\r
-      zzmatch(114); zzCONSUME;\r
-      zzmatch(QuotedTerm);\r
-      akaString=mystrdup(StripQuotes(LATEXT(1)));\r
-      /* MR11 */                   save_file=CurFile;save_line=zzline;\r
-      /* MR23 */\r
- zzCONSUME;\r
-\r
-      zzmatch(115); zzCONSUME;\r
-    }\r
-    else {\r
-      if ( (LA(1)==102) ) {\r
-      }\r
-      else {zzFAIL(1,zzerr17,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
-    }\r
-    zzEXIT(zztasp2);\r
-    }\r
-  }\r
-  \r
-  /* MR23 */         if (p!= NULL && akaString != NULL) {\r
-    /* MR23 */           if (p->akaString != NULL) {\r
-      /* MR23 */             if (strcmp(p->akaString,akaString) != 0) {\r
-        /* MR23 */                warnFL(eMsg2("this #tokclass statment conflicts with a previous #tokclass %s(\"%s\") statement",\r
-        /* MR23 */                              t,p->akaString),\r
-        /* MR23 */                                         FileStr[save_file],save_line);\r
-        /* MR23 */             };\r
-      /* MR23 */            } else {\r
-      /* MR23 */              p->akaString=akaString;\r
-      /* MR23 */            };\r
-    /* MR23 */          };\r
-  /* MR23 */\r
-  zzmatch(102); zzCONSUME;\r
-  {\r
-    zzBLOCK(zztasp2);\r
-    int zzcnt=1;\r
-    zzMake0;\r
-    {\r
-    do {\r
-      {\r
-        zzBLOCK(zztasp3);\r
-        zzMake0;\r
-        {\r
-        if ( (LA(1)==TokenTerm) ) {\r
-          zzmatch(TokenTerm);\r
-          if ( go ) {\r
-            term = (TermEntry *) hash_get(Tname, LATEXT(1));\r
-            if ( term==NULL && UserDefdTokens ) {\r
-              err("implicit token definition not allowed with #tokdefs");\r
-              go = 0;\r
-            }\r
-            else {t=mystrdup(LATEXT(1)); tok=addTname(LATEXT(1));}\r
-          }\r
- zzCONSUME;\r
-\r
-          {\r
-            zzBLOCK(zztasp4);\r
-            zzMake0;\r
-            {\r
-            if ( (LA(1)==119) ) {\r
-              zzmatch(119); zzCONSUME;\r
-              zzmatch(TokenTerm);\r
-              if ( go ) {\r
-                toterm = (TermEntry *) hash_get(Tname, LATEXT(1));\r
-                if ( toterm==NULL && UserDefdTokens ) {\r
-                  err("implicit token definition not allowed with #tokdefs");\r
-                  go = 0;\r
-                } else {\r
-                  totext=mystrdup(LATEXT(1)); totok=addTname(LATEXT(1));\r
-                }\r
-              }\r
- zzCONSUME;\r
-\r
-            }\r
-            else {\r
-              if ( (setwd4[LA(1)]&0x8) ) {\r
-              }\r
-              else {zzFAIL(1,zzerr18,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
-            }\r
-            zzEXIT(zztasp4);\r
-            }\r
-          }\r
-        }\r
-        else {\r
-          if ( (LA(1)==QuotedTerm) ) {\r
-            zzmatch(QuotedTerm);\r
-            if ( go ) {\r
-              term = (TermEntry *) hash_get(Texpr, LATEXT(1));\r
-              if ( term==NULL && UserDefdTokens ) {\r
-                err("implicit token definition not allowed with #tokdefs");\r
-                go = 0;\r
-              }\r
-              else {t=mystrdup(LATEXT(1)); tok=addTexpr(LATEXT(1));}\r
-            }\r
- zzCONSUME;\r
-\r
-          }\r
-          else {zzFAIL(1,zzerr19,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
-        }\r
-        zzEXIT(zztasp3);\r
-        }\r
-      }\r
-      if ( go ) {\r
-        if (totext == NULL) {\r
-          list_add(&(e->tlist), t);\r
-        } else {\r
-          list_add(&(e->tlist),"..");\r
-          list_add(&(e->tlist),t);\r
-          list_add(&(e->tlist),totext);\r
-        }\r
-        totext=NULL;\r
-      }\r
-      zzLOOP(zztasp2);\r
-    } while ( (setwd4[LA(1)]&0x10) );\r
-    zzEXIT(zztasp2);\r
-    }\r
-  }\r
-  zzmatch(98); zzCONSUME;\r
-  zzEXIT(zztasp1);\r
-  return;\r
-fail:\r
-  zzEXIT(zztasp1);\r
-  CannotContinue=TRUE;  \r
-  zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);\r
-  zzresynch(setwd4, 0x20);\r
-  }\r
-}\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-token(void)\r
-#else\r
-token()\r
-#endif\r
-{\r
-  zzRULE;\r
-  zzBLOCK(zztasp1);\r
-  zzMake0;\r
-  {\r
-  char *t=NULL, *e=NULL, *a=NULL; int tnum=0;\r
-  char *akaString=NULL; TermEntry *te;int save_file=0,save_line=0;\r
-  zzmatch(120);\r
-  tokenActionActive=1;\r
- zzCONSUME;\r
-\r
-  {\r
-    zzBLOCK(zztasp2);\r
-    zzMake0;\r
-    {\r
-    if ( (LA(1)==TokenTerm) ) {\r
-      zzmatch(TokenTerm);\r
-      t=mystrdup(LATEXT(1));\r
- zzCONSUME;\r
-\r
-      {\r
-        zzBLOCK(zztasp3);\r
-        zzMake0;\r
-        {\r
-        if ( (LA(1)==114) ) {\r
-          zzmatch(114); zzCONSUME;\r
-          zzmatch(QuotedTerm);\r
-          akaString=mystrdup(StripQuotes(LATEXT(1)));\r
-          /* MR11 */                   save_file=CurFile;save_line=zzline;\r
-          /* MR11 */\r
- zzCONSUME;\r
-\r
-          zzmatch(115); zzCONSUME;\r
-        }\r
-        else {\r
-          if ( (setwd4[LA(1)]&0x40) ) {\r
-          }\r
-          else {zzFAIL(1,zzerr20,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
-        }\r
-        zzEXIT(zztasp3);\r
-        }\r
-      }\r
-      {\r
-        zzBLOCK(zztasp3);\r
-        zzMake0;\r
-        {\r
-        if ( (LA(1)==121) ) {\r
-          zzmatch(121); zzCONSUME;\r
-          zzmatch(122);\r
-          tnum = atoi(LATEXT(1));\r
- zzCONSUME;\r
-\r
-        }\r
-        else {\r
-          if ( (setwd4[LA(1)]&0x80) ) {\r
-          }\r
-          else {zzFAIL(1,zzerr21,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
-        }\r
-        zzEXIT(zztasp3);\r
-        }\r
-      }\r
-    }\r
-    else {\r
-      if ( (setwd5[LA(1)]&0x1) ) {\r
-      }\r
-      else {zzFAIL(1,zzerr22,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
-    }\r
-    zzEXIT(zztasp2);\r
-    }\r
-  }\r
-  {\r
-    zzBLOCK(zztasp2);\r
-    zzMake0;\r
-    {\r
-    if ( (LA(1)==QuotedTerm) ) {\r
-      zzmatch(QuotedTerm);\r
-      e=mystrdup(LATEXT(1));\r
- zzCONSUME;\r
-\r
-    }\r
-    else {\r
-      if ( (setwd5[LA(1)]&0x2) ) {\r
-      }\r
-      else {zzFAIL(1,zzerr23,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
-    }\r
-    zzEXIT(zztasp2);\r
-    }\r
-  }\r
-  {\r
-    zzBLOCK(zztasp2);\r
-    zzMake0;\r
-    {\r
-    if ( (LA(1)==Action) ) {\r
-      zzmatch(Action);\r
-      \r
-      a = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));\r
-      require(a!=NULL, "rule token: cannot allocate action");\r
-      strcpy(a, LATEXT(1));\r
- zzCONSUME;\r
-\r
-    }\r
-    else {\r
-      if ( (setwd5[LA(1)]&0x4) ) {\r
-      }\r
-      else {zzFAIL(1,zzerr24,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
-    }\r
-    zzEXIT(zztasp2);\r
-    }\r
-  }\r
-  {\r
-    zzBLOCK(zztasp2);\r
-    zzMake0;\r
-    {\r
-    if ( (LA(1)==107) ) {\r
-      zzmatch(107); zzCONSUME;\r
-    }\r
-    else {\r
-      if ( (setwd5[LA(1)]&0x8) ) {\r
-      }\r
-      else {zzFAIL(1,zzerr25,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
-    }\r
-    zzEXIT(zztasp2);\r
-    }\r
-  }\r
-  chkToken(t, e, a, tnum);\r
-  if (t != NULL) {\r
-    te=(TermEntry *)hash_get(Tname,t);\r
-    if (te != NULL && akaString != NULL) {\r
-      if (te->akaString != NULL) {\r
-        if (strcmp(te->akaString,akaString) != 0) {\r
-          warnFL(eMsg2("this #token statment conflicts with a previous #token %s(\"%s\") statement",\r
-          t,te->akaString),\r
-          FileStr[save_file],save_line);\r
-        };\r
-      } else {\r
-        te->akaString=akaString;\r
-      };\r
-    };\r
-  };\r
-  zzEXIT(zztasp1);\r
-  return;\r
-fail:\r
-  zzEXIT(zztasp1);\r
-  CannotContinue=TRUE;  \r
-  zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);\r
-  zzresynch(setwd5, 0x10);\r
-  }\r
-}\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-block(set * toksrefd,set * rulesrefd)\r
-#else\r
-block(toksrefd,rulesrefd)\r
- set *toksrefd;\r
-set *rulesrefd ;\r
-#endif\r
-{\r
-  zzRULE;\r
-  zzBLOCK(zztasp1);\r
-  zzMake0;\r
-  {\r
-  \r
-  Graph g, b;\r
-  set saveblah;\r
-  int saveinalt = inAlt;\r
-  ExceptionGroup *eg;\r
-  * toksrefd = empty;\r
-  * rulesrefd = empty;\r
-  set_clr(AST_nodes_refd_in_actions);\r
-  CurBlockID++;\r
-  /* MR23 */      CurBlockID_array[BlkLevel] = CurBlockID;\r
-  CurAltNum = 1;\r
-  /* MR23 */      CurAltNum_array[BlkLevel] = CurAltNum;                \r
-  saveblah = attribsRefdFromAction;\r
-  attribsRefdFromAction = empty;\r
-  alt( toksrefd,rulesrefd );\r
-  b = g = zzaArg(zztasp1,1);\r
-  \r
-  if ( ((Junction *)g.left)->p1->ntype == nAction )\r
-  {\r
-    ActionNode *actionNode=(ActionNode *)\r
-    ( ( (Junction *)g.left) ->p1);\r
-    if (!actionNode->is_predicate )\r
-    {\r
-      actionNode->init_action = TRUE;\r
-      /* MR12c */              if (actionNode->noHoist) {\r
-        /* MR12c */           errFL("<<nohoist>> appears as init-action - use <<>> <<nohoist>>",\r
-        /* MR12c */                       FileStr[actionNode->file],actionNode->line);\r
-        /* MR12c */         };\r
-    }\r
-  }\r
-  ((Junction *)g.left)->blockid = CurBlockID;\r
-  {\r
-    zzBLOCK(zztasp2);\r
-    zzMake0;\r
-    {\r
-    while ( (LA(1)==133) ) {\r
-       eg  = exception_group();\r
-\r
-      \r
-      if ( eg!=NULL ) {\r
-        /* MR7 *****           eg->altID = makeAltID(CurBlockID,CurAltNum);        *****/\r
-        /* MR7 *****           CurAltStart->exception_label = eg->altID;           *****/\r
-        list_add(&CurExGroups, (void *)eg);\r
-      }\r
-      zzLOOP(zztasp2);\r
-    }\r
-    zzEXIT(zztasp2);\r
-    }\r
-  }\r
-  CurAltNum++;\r
-  /* MR23 */    CurAltNum_array[BlkLevel] = CurAltNum;\r
-  {\r
-    zzBLOCK(zztasp2);\r
-    zzMake0;\r
-    {\r
-    while ( (LA(1)==123) ) {\r
-      zzmatch(123);\r
-      inAlt=1;\r
- zzCONSUME;\r
-\r
-      alt( toksrefd,rulesrefd );\r
-      g = Or(g, zzaArg(zztasp2,2));\r
-      \r
-      ((Junction *)g.left)->blockid = CurBlockID;\r
-      {\r
-        zzBLOCK(zztasp3);\r
-        zzMake0;\r
-        {\r
-        while ( (LA(1)==133) ) {\r
-           eg  = exception_group();\r
-\r
-          \r
-          if ( eg!=NULL ) {\r
-            /* MR7 *****               eg->altID = makeAltID(CurBlockID,CurAltNum);        *****/\r
-            /* MR7 *****               CurAltStart->exception_label = eg->altID;           *****/\r
-            list_add(&CurExGroups, (void *)eg);\r
-          }\r
-          zzLOOP(zztasp3);\r
-        }\r
-        zzEXIT(zztasp3);\r
-        }\r
-      }\r
-      CurAltNum++;\r
-      /* MR23 */        CurAltNum_array[BlkLevel] = CurAltNum;\r
-      zzLOOP(zztasp2);\r
-    }\r
-    zzEXIT(zztasp2);\r
-    }\r
-  }\r
-  zzaArg(zztasp1,0) = b;\r
-  attribsRefdFromAction = saveblah; inAlt = saveinalt;\r
-  zzEXIT(zztasp1);\r
-  return;\r
-fail:\r
-  zzEXIT(zztasp1);\r
-  CannotContinue=TRUE;  \r
-  zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);\r
-  zzresynch(setwd5, 0x20);\r
-  }\r
-}\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-alt(set * toksrefd,set * rulesrefd)\r
-#else\r
-alt(toksrefd,rulesrefd)\r
- set *toksrefd;\r
-set *rulesrefd ;\r
-#endif\r
-{\r
-  zzRULE;\r
-  zzBLOCK(zztasp1);\r
-  zzMake0;\r
-  {\r
-  int n=0; Graph g; int e_num=0, old_not=0; Node *node; set elems, dif;\r
-  int first_on_line = 1, use_def_MT_handler = 0;\r
-  g.left=NULL; g.right=NULL;\r
-  \r
-                       CurAltStart = NULL;\r
-  elems = empty;\r
-  inAlt = 1;\r
-  {\r
-    zzBLOCK(zztasp2);\r
-    zzMake0;\r
-    {\r
-    if ( (LA(1)==88) ) {\r
-      zzmatch(88);\r
-      use_def_MT_handler = 1;\r
- zzCONSUME;\r
-\r
-    }\r
-    else {\r
-      if ( (setwd5[LA(1)]&0x40) ) {\r
-      }\r
-      else {zzFAIL(1,zzerr26,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
-    }\r
-    zzEXIT(zztasp2);\r
-    }\r
-  }\r
-  {\r
-    zzBLOCK(zztasp2);\r
-    zzMake0;\r
-    {\r
-    ;\r
-    while ( (setwd5[LA(1)]&0x80) ) {\r
-      {\r
-        zzBLOCK(zztasp3);\r
-        zzMake0;\r
-        {\r
-        old_not=0;\r
-        if ( (LA(1)==124) ) {\r
-          zzmatch(124);\r
-          old_not=1;\r
- zzCONSUME;\r
-\r
-        }\r
-        else {\r
-          if ( (setwd6[LA(1)]&0x1) ) {\r
-          }\r
-          else {zzFAIL(1,zzerr27,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
-        }\r
-        zzEXIT(zztasp3);\r
-        }\r
-      }\r
-       node  = element( old_not, first_on_line, use_def_MT_handler );\r
-\r
-      if ( node!=NULL && node->ntype!=nAction ) first_on_line = 0;\r
-      \r
-      if ( zzaArg(zztasp2,2 ).left!=NULL ) {\r
-        g = Cat(g, zzaArg(zztasp2,2));\r
-        n++;\r
-        if ( node!=NULL ) {\r
-          if ( node->ntype!=nAction ) e_num++;\r
-          /* record record number of all rule and token refs */\r
-          if ( node->ntype==nToken ) {\r
-            TokNode *tk = (TokNode *)((Junction *)zzaArg(zztasp2,2 ).left)->p1;\r
-            tk->elnum = e_num;\r
-            set_orel(e_num, &elems);\r
-          }\r
-          else if ( node->ntype==nRuleRef ) {\r
-            RuleRefNode *rn = (RuleRefNode *)((Junction *)zzaArg(zztasp2,2 ).left)->p1;\r
-            rn->elnum = e_num;\r
-            set_orel(e_num,  rulesrefd);\r
-          }\r
-        }\r
-      }\r
-      zzLOOP(zztasp2);\r
-    }\r
-    zzEXIT(zztasp2);\r
-    }\r
-  }\r
-  if ( n == 0 ) g = emptyAlt();\r
-  zzaArg(zztasp1,0) = g;\r
-  /* We want to reduce number of LT(i) calls and the number of\r
-  * local attribute variables in C++ mode (for moment, later we'll\r
-  * do for C also).  However, if trees are being built, they\r
-  * require most of the attrib variables to create the tree nodes\r
-  * with; therefore, we gen a token ptr for each token ref in C++\r
-  */\r
-  if ( GenCC && !GenAST )\r
-  {\r
-  /* This now free's the temp set -ATG 5/6/95 */\r
-  set temp;\r
-  temp = set_and(elems, attribsRefdFromAction);\r
-  set_orin( toksrefd, temp);\r
-  set_free(temp);\r
-}\r
-else set_orin( toksrefd, elems);\r
-if ( GenCC ) {\r
-  dif = set_dif(attribsRefdFromAction, elems);\r
-  if ( set_deg(dif)>0 )\r
-  err("one or more $i in action(s) refer to non-token elements");\r
-  set_free(dif);\r
-}\r
-set_free(elems);\r
-set_free(attribsRefdFromAction);\r
-inAlt = 0;\r
-  zzEXIT(zztasp1);\r
-  return;\r
-fail:\r
-  zzEXIT(zztasp1);\r
-  CannotContinue=TRUE;  \r
-  zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);\r
-  zzresynch(setwd6, 0x2);\r
-  }\r
-}\r
-\r
-LabelEntry *\r
-#ifdef __USE_PROTOS\r
-element_label(void)\r
-#else\r
-element_label()\r
-#endif\r
-{\r
-  LabelEntry *   _retv;\r
-  zzRULE;\r
-  zzBLOCK(zztasp1);\r
-  PCCTS_PURIFY(_retv,sizeof(LabelEntry *  ))\r
-  zzMake0;\r
-  {\r
-  TermEntry *t=NULL; LabelEntry *l=NULL; RuleEntry *r=NULL; char *lab;\r
-  zzmatch(LABEL);\r
-  lab = mystrdup(LATEXT(1));\r
- zzCONSUME;\r
-\r
-  \r
-  UsedNewStyleLabel = 1;\r
-  if ( UsedOldStyleAttrib ) err("cannot mix with new-style labels with old-style $i");\r
-  t = (TermEntry *) hash_get(Tname, lab);\r
-  if ( t==NULL ) t = (TermEntry *) hash_get(Texpr, lab);\r
-  if ( t==NULL ) r = (RuleEntry *) hash_get(Rname, lab);\r
-  if ( t!=NULL ) {\r
-    err(eMsg1("label definition clashes with token/tokclass definition: '%s'", lab));\r
-    _retv = NULL;\r
-  }\r
-  else if ( r!=NULL ) {\r
-    err(eMsg1("label definition clashes with rule definition: '%s'", lab));\r
-    _retv = NULL;\r
-  }\r
-  else {\r
-    /* we don't clash with anybody else */\r
-    l = (LabelEntry *) hash_get(Elabel, lab);\r
-    if ( l==NULL ) {   /* ok to add new element label */\r
-    l = (LabelEntry *)hash_add(Elabel,\r
-    lab,\r
-    (Entry *)newLabelEntry(lab));\r
-    /* add to list of element labels for this rule */\r
-    list_add(&CurElementLabels, (void *)lab);\r
-    /* MR7 */       leAdd(l);  /* list of labels waiting for exception group definitions */\r
-    _retv = l;\r
-  }\r
-  else {\r
-  err(eMsg1("label definitions must be unique per rule: '%s'", lab));\r
-  _retv = NULL;\r
-}\r
-}\r
-  zzmatch(106); zzCONSUME;\r
-  zzEXIT(zztasp1);\r
-  return _retv;\r
-fail:\r
-  zzEXIT(zztasp1);\r
-  zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);\r
-  zzresynch(setwd6, 0x4);\r
-  return _retv;\r
-  }\r
-}\r
-\r
-Node *\r
-#ifdef __USE_PROTOS\r
-element(int old_not,int first_on_line,int use_def_MT_handler)\r
-#else\r
-element(old_not,first_on_line,use_def_MT_handler)\r
- int old_not;\r
-int first_on_line;\r
-int use_def_MT_handler ;\r
-#endif\r
-{\r
-  Node *   _retv;\r
-  zzRULE;\r
-  zzBLOCK(zztasp1);\r
-  PCCTS_PURIFY(_retv,sizeof(Node *  ))\r
-  zzMake0;\r
-  {\r
-  \r
-  Attrib blk;\r
-  Predicate *pred = NULL;\r
-  int local_use_def_MT_handler=0;\r
-  ActionNode *act;\r
-  RuleRefNode *rr;\r
-  set toksrefd, rulesrefd;\r
-  TermEntry *term;\r
-  TokNode *p=NULL; RuleRefNode *q; int approx=0;\r
-  LabelEntry *label=NULL;\r
-  int predMsgDone=0;\r
-  int semDepth=0;\r
-  int   ampersandStyle;\r
-  int   height;         /* MR11 */\r
-  int   equal_height;   /* MR11 */\r
-  \r
-          char* pFirstSetSymbol = NULL; /* MR21 */\r
-  \r
-                 _retv = NULL;\r
-  if ( (setwd6[LA(1)]&0x8) ) {\r
-    {\r
-      zzBLOCK(zztasp2);\r
-      zzMake0;\r
-      {\r
-      if ( (LA(1)==LABEL) ) {\r
-         label  = element_label();\r
-\r
-      }\r
-      else {\r
-        if ( (setwd6[LA(1)]&0x10) ) {\r
-        }\r
-        else {zzFAIL(1,zzerr28,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
-      }\r
-      zzEXIT(zztasp2);\r
-      }\r
-    }\r
-    {\r
-      zzBLOCK(zztasp2);\r
-      zzMake0;\r
-      {\r
-      if ( (LA(1)==TokenTerm) ) {\r
-        zzmatch(TokenTerm);\r
-        \r
-        term = (TermEntry *) hash_get(Tname, LATEXT(1));\r
-        if ( term==NULL && UserDefdTokens ) {\r
-          err("implicit token definition not allowed with #tokdefs");\r
-          zzaRet.left = zzaRet.right = NULL;\r
-        }\r
-        else {\r
-          zzaRet = buildToken(LATEXT(1));\r
-          p=((TokNode *)((Junction *)zzaRet.left)->p1);\r
-          term = (TermEntry *) hash_get(Tname, LATEXT(1));\r
-          require( term!= NULL, "hash table mechanism is broken");\r
-          p->tclass = term->tclass;\r
-          p->complement =  old_not;\r
-          if ( label!=NULL ) {\r
-            p->el_label = label->str;\r
-            label->elem = (Node *)p;\r
-          }\r
-        }\r
- zzCONSUME;\r
-\r
-        {\r
-          zzBLOCK(zztasp3);\r
-          zzMake0;\r
-          {\r
-          if ( (LA(1)==119) ) {\r
-            zzmatch(119); zzCONSUME;\r
-            {\r
-              zzBLOCK(zztasp4);\r
-              zzMake0;\r
-              {\r
-              if ( (LA(1)==QuotedTerm) ) {\r
-                zzmatch(QuotedTerm);\r
-                if ( p!=NULL ) setUpperRange(p, LATEXT(1));\r
- zzCONSUME;\r
-\r
-              }\r
-              else {\r
-                if ( (LA(1)==TokenTerm) ) {\r
-                  zzmatch(TokenTerm);\r
-                  if ( p!=NULL ) setUpperRange(p, LATEXT(1));\r
- zzCONSUME;\r
-\r
-                }\r
-                else {zzFAIL(1,zzerr29,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
-              }\r
-              zzEXIT(zztasp4);\r
-              }\r
-            }\r
-          }\r
-          else {\r
-            if ( (setwd6[LA(1)]&0x20) ) {\r
-            }\r
-            else {zzFAIL(1,zzerr30,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
-          }\r
-          zzEXIT(zztasp3);\r
-          }\r
-        }\r
-        \r
-        if ( p!=NULL && (p->upper_range!=0 || p->tclass ||  old_not) )\r
-        list_add(&MetaTokenNodes, (void *)p);\r
-        {\r
-          zzBLOCK(zztasp3);\r
-          zzMake0;\r
-          {\r
-          if ( (LA(1)==125) ) {\r
-            zzmatch(125);\r
-            if ( p!=NULL ) p->astnode=ASTroot;\r
- zzCONSUME;\r
-\r
-          }\r
-          else {\r
-            if ( (setwd6[LA(1)]&0x40) ) {\r
-              if ( p!=NULL ) p->astnode=ASTchild;\r
-            }\r
-            else {\r
-              if ( (LA(1)==103) ) {\r
-                zzmatch(103);\r
-                if ( p!=NULL ) p->astnode=ASTexclude;\r
- zzCONSUME;\r
-\r
-              }\r
-              else {zzFAIL(1,zzerr31,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
-            }\r
-          }\r
-          zzEXIT(zztasp3);\r
-          }\r
-        }\r
-        {\r
-          zzBLOCK(zztasp3);\r
-          zzMake0;\r
-          {\r
-          if ( (LA(1)==88) ) {\r
-            zzmatch(88);\r
-            local_use_def_MT_handler = 1;\r
- zzCONSUME;\r
-\r
-          }\r
-          else {\r
-            if ( (setwd6[LA(1)]&0x80) ) {\r
-            }\r
-            else {zzFAIL(1,zzerr32,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
-          }\r
-          zzEXIT(zztasp3);\r
-          }\r
-        }\r
-        \r
-        if ( p!=NULL &&  first_on_line ) {\r
-          CurAltStart = (Junction *)zzaRet.left;\r
-          altAdd(CurAltStart);                                 /* MR7 */\r
-          p->altstart = CurAltStart;\r
-        }\r
-        if ( p!=NULL )\r
-        p->use_def_MT_handler =  use_def_MT_handler || local_use_def_MT_handler;\r
-        _retv = (Node *)p;\r
-      }\r
-      else {\r
-        if ( (LA(1)==QuotedTerm) ) {\r
-          zzmatch(QuotedTerm);\r
-          \r
-          term = (TermEntry *) hash_get(Texpr, LATEXT(1));\r
-          if ( term==NULL && UserDefdTokens ) {\r
-            err("implicit token definition not allowed with #tokdefs");\r
-            zzaRet.left = zzaRet.right = NULL;\r
-          }\r
-          else {\r
-            zzaRet = buildToken(LATEXT(1)); p=((TokNode *)((Junction *)zzaRet.left)->p1);\r
-            p->complement =  old_not;\r
-            if ( label!=NULL ) {\r
-              p->el_label = label->str;\r
-              label->elem = (Node *)p;\r
-            }\r
-          }\r
- zzCONSUME;\r
-\r
-          {\r
-            zzBLOCK(zztasp3);\r
-            zzMake0;\r
-            {\r
-            if ( (LA(1)==119) ) {\r
-              zzmatch(119); zzCONSUME;\r
-              {\r
-                zzBLOCK(zztasp4);\r
-                zzMake0;\r
-                {\r
-                if ( (LA(1)==QuotedTerm) ) {\r
-                  zzmatch(QuotedTerm);\r
-                  if ( p!=NULL ) setUpperRange(p, LATEXT(1));\r
- zzCONSUME;\r
-\r
-                }\r
-                else {\r
-                  if ( (LA(1)==TokenTerm) ) {\r
-                    zzmatch(TokenTerm);\r
-                    if ( p!=NULL ) setUpperRange(p, LATEXT(1));\r
- zzCONSUME;\r
-\r
-                  }\r
-                  else {zzFAIL(1,zzerr33,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
-                }\r
-                zzEXIT(zztasp4);\r
-                }\r
-              }\r
-            }\r
-            else {\r
-              if ( (setwd7[LA(1)]&0x1) ) {\r
-              }\r
-              else {zzFAIL(1,zzerr34,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
-            }\r
-            zzEXIT(zztasp3);\r
-            }\r
-          }\r
-          {\r
-            zzBLOCK(zztasp3);\r
-            zzMake0;\r
-            {\r
-            if ( (LA(1)==125) ) {\r
-              zzmatch(125);\r
-              if ( p!=NULL ) p->astnode=ASTroot;\r
- zzCONSUME;\r
-\r
-            }\r
-            else {\r
-              if ( (setwd7[LA(1)]&0x2) ) {\r
-                if ( p!=NULL ) p->astnode=ASTchild;\r
-              }\r
-              else {\r
-                if ( (LA(1)==103) ) {\r
-                  zzmatch(103);\r
-                  if ( p!=NULL ) p->astnode=ASTexclude;\r
- zzCONSUME;\r
-\r
-                }\r
-                else {zzFAIL(1,zzerr35,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
-              }\r
-            }\r
-            zzEXIT(zztasp3);\r
-            }\r
-          }\r
-          {\r
-            zzBLOCK(zztasp3);\r
-            zzMake0;\r
-            {\r
-            if ( (LA(1)==88) ) {\r
-              zzmatch(88);\r
-              local_use_def_MT_handler = 1;\r
- zzCONSUME;\r
-\r
-            }\r
-            else {\r
-              if ( (setwd7[LA(1)]&0x4) ) {\r
-              }\r
-              else {zzFAIL(1,zzerr36,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
-            }\r
-            zzEXIT(zztasp3);\r
-            }\r
-          }\r
-          \r
-          if ( p!=NULL && (p->upper_range!=0 || p->tclass ||  old_not) )\r
-          list_add(&MetaTokenNodes, (void *)p);\r
-          \r
-          if (  first_on_line ) {\r
-            CurAltStart = (Junction *)zzaRet.left;\r
-            altAdd(CurAltStart);                                 /* MR7 */\r
-            p->altstart = CurAltStart;\r
-          }\r
-          if ( p!=NULL )\r
-          p->use_def_MT_handler =  use_def_MT_handler || local_use_def_MT_handler;\r
-          _retv = (Node *)p;\r
-        }\r
-        else {\r
-          if ( (LA(1)==WildCard) ) {\r
-            if (  old_not ) warn("~ WILDCARD is an undefined operation (implies 'nothing')");\r
-            zzmatch(WildCard);\r
-            zzaRet = buildWildCard(LATEXT(1)); p=((TokNode *)((Junction *)zzaRet.left)->p1);\r
- zzCONSUME;\r
-\r
-            {\r
-              zzBLOCK(zztasp3);\r
-              zzMake0;\r
-              {\r
-              if ( (LA(1)==125) ) {\r
-                zzmatch(125);\r
-                p->astnode=ASTroot;\r
- zzCONSUME;\r
-\r
-              }\r
-              else {\r
-                if ( (setwd7[LA(1)]&0x8) ) {\r
-                  p->astnode=ASTchild;\r
-                }\r
-                else {\r
-                  if ( (LA(1)==103) ) {\r
-                    zzmatch(103);\r
-                    p->astnode=ASTexclude;\r
- zzCONSUME;\r
-\r
-                  }\r
-                  else {zzFAIL(1,zzerr37,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
-                }\r
-              }\r
-              zzEXIT(zztasp3);\r
-              }\r
-            }\r
-            list_add(&MetaTokenNodes, (void *)p);\r
-            \r
-            if (  first_on_line ) {\r
-              CurAltStart = (Junction *)zzaRet.left;\r
-              altAdd(CurAltStart);                                 /* MR7 */\r
-              p->altstart = CurAltStart;\r
-              if ( label!=NULL ) {\r
-                p->el_label = label->str;\r
-                label->elem = (Node *)p;\r
-              }\r
-            }\r
-            _retv = (Node *)p;\r
-          }\r
-          else {\r
-            if ( (LA(1)==NonTerminal) ) {\r
-              if (  old_not ) warn("~ NONTERMINAL is an undefined operation");\r
-              zzmatch(NonTerminal);\r
-              zzaRet = buildRuleRef(LATEXT(1));\r
- zzCONSUME;\r
-\r
-              {\r
-                zzBLOCK(zztasp3);\r
-                zzMake0;\r
-                {\r
-                if ( (LA(1)==103) ) {\r
-                  zzmatch(103);\r
-                  q = (RuleRefNode *) ((Junction *)zzaRet.left)->p1;\r
-                  q->astnode=ASTexclude;\r
- zzCONSUME;\r
-\r
-                }\r
-                else {\r
-                  if ( (setwd7[LA(1)]&0x10) ) {\r
-                  }\r
-                  else {zzFAIL(1,zzerr38,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
-                }\r
-                zzEXIT(zztasp3);\r
-                }\r
-              }\r
-              {\r
-                zzBLOCK(zztasp3);\r
-                zzMake0;\r
-                {\r
-                if ( (setwd7[LA(1)]&0x20) ) {\r
-                  {\r
-                    zzBLOCK(zztasp4);\r
-                    zzMake0;\r
-                    {\r
-                    if ( (LA(1)==104) ) {\r
-                      zzmatch(104); zzCONSUME;\r
-                    }\r
-                    else {\r
-                      if ( (LA(1)==PassAction) ) {\r
-                      }\r
-                      else {zzFAIL(1,zzerr39,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
-                    }\r
-                    zzEXIT(zztasp4);\r
-                    }\r
-                  }\r
-                  zzmatch(PassAction);\r
-                  addParm(((Junction *)zzaRet.left)->p1, LATEXT(1));\r
- zzCONSUME;\r
-\r
-                }\r
-                else {\r
-                  if ( (setwd7[LA(1)]&0x40) ) {\r
-                  }\r
-                  else {zzFAIL(1,zzerr40,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
-                }\r
-                zzEXIT(zztasp3);\r
-                }\r
-              }\r
-              rr=(RuleRefNode *) ((Junction *)zzaRet.left)->p1;\r
-              {\r
-                zzBLOCK(zztasp3);\r
-                zzMake0;\r
-                {\r
-                char *a;\r
-                if ( (LA(1)==105) ) {\r
-                  zzmatch(105); zzCONSUME;\r
-                  zzmatch(PassAction);\r
-                  \r
-                  a = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));\r
-                  require(a!=NULL, "rule element: cannot allocate assignment");\r
-                  strcpy(a, LATEXT(1));\r
-                  rr->assign = a;\r
- zzCONSUME;\r
-\r
-                }\r
-                else {\r
-                  if ( (setwd7[LA(1)]&0x80) ) {\r
-                  }\r
-                  else {zzFAIL(1,zzerr41,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
-                }\r
-                zzEXIT(zztasp3);\r
-                }\r
-              }\r
-              \r
-              if ( label!=NULL ) {\r
-                rr->el_label = label->str;\r
-                label->elem = (Node *)rr;\r
-              }\r
-              if (  first_on_line ) {\r
-                CurAltStart = (Junction *)zzaRet.left;\r
-                altAdd(CurAltStart);                                 /* MR7 */\r
-                ((RuleRefNode *)((Junction *)zzaRet.left)->p1)->altstart = CurAltStart;\r
-              }\r
-              _retv = (Node *)rr;\r
-            }\r
-            else {zzFAIL(1,zzerr42,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
-          }\r
-        }\r
-      }\r
-      zzEXIT(zztasp2);\r
-      }\r
-    }\r
-  }\r
-  else {\r
-    if ( (LA(1)==Action) ) {\r
-      if (  old_not )  warn("~ ACTION is an undefined operation");\r
-      zzmatch(Action);\r
-      zzaArg(zztasp1,0) = buildAction(LATEXT(1),action_file,action_line, 0);\r
- zzCONSUME;\r
-\r
-      if (  first_on_line ) {                                /* MR7 */\r
-        CurAltStart = (Junction *)zzaArg(zztasp1,0 ).left;                   /* MR7 */\r
-        altAdd(CurAltStart);                                 /* MR7 */\r
-      };\r
-      _retv = (Node *) ((Junction *)zzaArg(zztasp1,0 ).left)->p1;\r
-    }\r
-    else {\r
-      if ( (LA(1)==Pred) ) {\r
-        if (  old_not )        warn("~ SEMANTIC-PREDICATE is an undefined operation");\r
-        zzmatch(Pred);\r
-        zzaArg(zztasp1,0) = buildAction(LATEXT(1),action_file,action_line, 1);\r
- zzCONSUME;\r
-\r
-        act = (ActionNode *) ((Junction *)zzaArg(zztasp1,0 ).left)->p1;\r
-        if (numericActionLabel) {             /* MR10 */\r
-          list_add(&NumericPredLabels,act);   /* MR10 */\r
-          numericActionLabel=0;               /* MR10 */\r
-        };                                    /* MR10 */\r
-        {\r
-          zzBLOCK(zztasp2);\r
-          zzMake0;\r
-          {\r
-          char *a;\r
-          if ( (LA(1)==PassAction) ) {\r
-            zzmatch(PassAction);\r
-            \r
-            a = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));\r
-            require(a!=NULL, "rule element: cannot allocate predicate fail action");\r
-            strcpy(a, LATEXT(1));\r
-            act->pred_fail = a;\r
- zzCONSUME;\r
-\r
-          }\r
-          else {\r
-            if ( (setwd8[LA(1)]&0x1) ) {\r
-            }\r
-            else {zzFAIL(1,zzerr43,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
-          }\r
-          zzEXIT(zztasp2);\r
-          }\r
-        }\r
-        if (  first_on_line ) {                                /* MR7 */\r
-          CurAltStart = (Junction *)zzaArg(zztasp1,0 ).left;                   /* MR7 */\r
-          altAdd(CurAltStart);                                 /* MR7 */\r
-        };\r
-        _retv = (Node *)act;\r
-      }\r
-      else {\r
-        if ( (setwd8[LA(1)]&0x2) ) {\r
-          if (  old_not )      warn("~ BLOCK is an undefined operation");\r
-          BlkLevel++;\r
-          if (BlkLevel >= MAX_BLK_LEVEL) fatal("Blocks nested too deeply");\r
-          /* MR23 */    CurBlockID_array[BlkLevel] = CurBlockID;\r
-          /* MR23 */    CurAltNum_array[BlkLevel] = CurAltNum;\r
-          {\r
-            zzBLOCK(zztasp2);\r
-            zzMake0;\r
-            {\r
-            if ( (LA(1)==Pragma) ) {\r
-              zzmatch(Pragma); zzCONSUME;\r
-              {\r
-                zzBLOCK(zztasp3);\r
-                zzMake0;\r
-                {\r
-                if ( (LA(1)==126) ) {\r
-                  zzmatch(126);\r
-                  approx=LL_k;\r
- zzCONSUME;\r
-\r
-                }\r
-                else {\r
-                  if ( (LA(1)==127) ) {\r
-                    zzmatch(127);\r
-                    approx = 1;\r
- zzCONSUME;\r
-\r
-                  }\r
-                  else {\r
-                    if ( (LA(1)==128) ) {\r
-                      zzmatch(128);\r
-                      approx = 2;\r
- zzCONSUME;\r
-\r
-                    }\r
-                    else {zzFAIL(1,zzerr44,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
-                  }\r
-                }\r
-                zzEXIT(zztasp3);\r
-                }\r
-              }\r
-            }\r
-            else {\r
-              if ( (setwd8[LA(1)]&0x4) ) {\r
-              }\r
-              else {zzFAIL(1,zzerr45,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
-            }\r
-            zzEXIT(zztasp2);\r
-            }\r
-          }\r
-          {\r
-            zzBLOCK(zztasp2);\r
-            zzMake0;\r
-            {\r
-            if ( (LA(1)==FirstSetSymbol) ) {\r
-              zzmatch(FirstSetSymbol); zzCONSUME;\r
-              zzmatch(114); zzCONSUME;\r
-              {\r
-                zzBLOCK(zztasp3);\r
-                zzMake0;\r
-                {\r
-                if ( (LA(1)==NonTerminal) ) {\r
-                  zzmatch(NonTerminal);\r
-                  \r
-                  /* MR21 */                     pFirstSetSymbol = (char *) calloc(strlen(LATEXT(1))+1,\r
-                  /* MR21 */                                                    sizeof(char));\r
-                  /* MR21 */                          require(pFirstSetSymbol!=NULL,\r
-                  /* MR21 */                                  "cannot allocate first set name");\r
-                  /* MR21 */                          strcpy(pFirstSetSymbol, LATEXT(1));\r
-                  /* MR21 */\r
- zzCONSUME;\r
-\r
-                }\r
-                else {\r
-                  if ( (LA(1)==TokenTerm) ) {\r
-                    zzmatch(TokenTerm);\r
-                    \r
-                    /* MR21 */                      pFirstSetSymbol = (char *) calloc(strlen(LATEXT(1))+1,\r
-                    /* MR21 */                                                        sizeof(char));\r
-                    /* MR21 */                      require(pFirstSetSymbol!=NULL,\r
-                    /* MR21 */                              "cannot allocate first set name");\r
-                    /* MR21 */                      strcpy(pFirstSetSymbol, LATEXT(1));\r
-                    /* MR21 */\r
- zzCONSUME;\r
-\r
-                  }\r
-                  else {zzFAIL(1,zzerr46,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
-                }\r
-                zzEXIT(zztasp3);\r
-                }\r
-              }\r
-              zzmatch(115); zzCONSUME;\r
-            }\r
-            else {\r
-              if ( (setwd8[LA(1)]&0x8) ) {\r
-              }\r
-              else {zzFAIL(1,zzerr47,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
-            }\r
-            zzEXIT(zztasp2);\r
-            }\r
-          }\r
-          {\r
-            zzBLOCK(zztasp2);\r
-            zzMake0;\r
-            {\r
-            if ( (LA(1)==114) ) {\r
-              zzmatch(114); zzCONSUME;\r
-              block( &toksrefd,&rulesrefd );\r
-              zzmatch(115);\r
-              blk = zzaRet = zzaArg(zztasp2,2);\r
-              /* MR23 */      CurBlockID_array[BlkLevel] = (-1);\r
-              /* MR23 */      CurAltNum_array[BlkLevel] = (-1);                \r
-              --BlkLevel;\r
- zzCONSUME;\r
-\r
-              {\r
-                zzBLOCK(zztasp3);\r
-                zzMake0;\r
-                {\r
-                if ( (LA(1)==129) ) {\r
-                  zzmatch(129);\r
-                  zzaRet = makeLoop(zzaRet,approx,pFirstSetSymbol);\r
- zzCONSUME;\r
-\r
-                }\r
-                else {\r
-                  if ( (LA(1)==130) ) {\r
-                    zzmatch(130);\r
-                    zzaRet = makePlus(zzaRet,approx,pFirstSetSymbol);\r
- zzCONSUME;\r
-\r
-                  }\r
-                  else {\r
-                    if ( (LA(1)==131) ) {\r
-                      zzmatch(131); zzCONSUME;\r
-                      {\r
-                        zzBLOCK(zztasp4);\r
-                        zzMake0;\r
-                        {\r
-                        if ( (setwd8[LA(1)]&0x10) ) {\r
-                          {\r
-                            zzBLOCK(zztasp5);\r
-                            zzMake0;\r
-                            {\r
-                            if ( (LA(1)==132) ) {\r
-                              zzmatch(132);\r
-                              ampersandStyle=0;\r
- zzCONSUME;\r
-\r
-                            }\r
-                            else {\r
-                              if ( (LA(1)==113) ) {\r
-                                zzmatch(113);\r
-                                ampersandStyle=1;\r
- zzCONSUME;\r
-\r
-                              }\r
-                              else {zzFAIL(1,zzerr48,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
-                            }\r
-                            zzEXIT(zztasp5);\r
-                            }\r
-                          }\r
-                          zzmatch(Pred);\r
-                          zzaRet = buildAction(LATEXT(1),action_file,action_line,1);\r
- zzCONSUME;\r
-\r
-                          act = (ActionNode *) ((Junction *)zzaRet.left)->p1;\r
-                          semDepth=predicateLookaheadDepth(act);\r
-                          if (numericActionLabel) {             /* MR10 */\r
-                            list_add(&NumericPredLabels,act);   /* MR10 */\r
-                            numericActionLabel=0;               /* MR10 */\r
-                          };                                    /* MR10 */\r
-                          {\r
-                            zzBLOCK(zztasp5);\r
-                            zzMake0;\r
-                            {\r
-                            char *a;\r
-                            if ( (LA(1)==PassAction) ) {\r
-                              zzmatch(PassAction);\r
-                              \r
-                              a = (char *)calloc(strlen(LATEXT(1))+1, sizeof(char));\r
-                              require(a!=NULL, "rule element: cannot allocate predicate fail action");\r
-                              strcpy(a, LATEXT(1));\r
-                              act->pred_fail = a;\r
- zzCONSUME;\r
-\r
-                            }\r
-                            else {\r
-                              if ( (setwd8[LA(1)]&0x20) ) {\r
-                              }\r
-                              else {zzFAIL(1,zzerr49,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
-                            }\r
-                            zzEXIT(zztasp5);\r
-                            }\r
-                          }\r
-                          if ( first_on_line) {                      /* MR7 */\r
-                            CurAltStart=(Junction *)zzaRet.left;         /* MR7 */\r
-                            altAdd(CurAltStart);                     /* MR7 */\r
-                          };\r
-                          _retv = (Node *)act;\r
-                          \r
-                          pred = computePredFromContextGuard(blk,&predMsgDone);           /* MR10 */\r
-                          if ( pred==NULL) {                                              /* MR10 */\r
-                            if ( !predMsgDone) err("invalid or missing context guard");   /* MR10 */\r
-                            predMsgDone=1;                                                /* MR10 */\r
-                          } else {                                                        /* MR10 */\r
-                            act->guardNodes=(Junction *)blk.left;                       /* MR11 */\r
-                            pred->expr = act->action;\r
-                            pred->source = act;\r
-                            /* MR10 */                  pred->ampersandStyle = ampersandStyle;  /* 0 means (g)? => ... 1 means (g)? && ... */\r
-                            /* MR13 */                  if (pred->tcontext != NULL) {\r
-                              /* MR13 */                    height=MR_max_height_of_tree(pred->tcontext);\r
-                              /* MR13 */                    equal_height=MR_all_leaves_same_height(pred->tcontext,height);\r
-                              /* MR13 */                    if (! equal_height) {\r
-                                /* MR13 */                       errFL("in guarded predicates all tokens in the guard must be at the same height",\r
-                                /* MR13 */                              FileStr[act->file],act->line);\r
-                                /* MR13 */                    };\r
-                              /* MR13 */                  }\r
-                            /* MR10 */                  if (ampersandStyle) {\r
-                              /* MR10 */                                         act->ampersandPred = pred;\r
-                              /* MR11 */                    if (! HoistPredicateContext) {\r
-                                /* MR11 */                      errFL("without \"-prc on\" (guard)? && <<pred>>? ... doesn't make sense",\r
-                                /* MR11 */                              FileStr[act->file],act->line);\r
-                                /* MR11 */                    };\r
-                              /* MR10 */                  } else {\r
-                              /* MR10 */                                         act->guardpred = pred;\r
-                              /* MR10 */                  };\r
-                            /* MR10 */                  if (pred->k != semDepth) {\r
-                              /* MR10 */                     warn(eMsgd2("length of guard (%d) does not match the length of semantic predicate (%d)",\r
-                              /* MR10 */                                  pred->k,semDepth));\r
-                              /* MR10 */                  };\r
-                          }\r
-                        }\r
-                        else {\r
-                          if ( (setwd8[LA(1)]&0x40) ) {\r
-                            zzaRet = makeBlk(zzaRet,approx,pFirstSetSymbol);\r
-                            FoundGuessBlk = 1;\r
-                            ((Junction *) ((Junction *)zzaRet.left)->p1)->guess=1;\r
-                            if ( ! first_on_line ) {\r
-                              err("(...)? predicate must be first element of production");\r
-                            }\r
-                          }\r
-                          else {zzFAIL(1,zzerr50,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
-                        }\r
-                        zzEXIT(zztasp4);\r
-                        }\r
-                      }\r
-                    }\r
-                    else {\r
-                      if ( (setwd8[LA(1)]&0x80) ) {\r
-                        zzaRet = makeBlk(zzaRet,approx,pFirstSetSymbol);\r
-                      }\r
-                      else {zzFAIL(1,zzerr51,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
-                    }\r
-                  }\r
-                }\r
-                zzEXIT(zztasp3);\r
-                }\r
-              }\r
-              \r
-              if ( pred==NULL && !predMsgDone) {                                      /* MR10 */\r
-                ((Junction *)((Junction *)zzaRet.left)->p1)->blockid = CurBlockID;\r
-                ((Junction *)((Junction *)zzaRet.left)->p1)->tokrefs = toksrefd;\r
-                ((Junction *)((Junction *)zzaRet.left)->p1)->rulerefs = rulesrefd;\r
-                if (  first_on_line ) {                         /* MR7 */\r
-                  CurAltStart = (Junction *)((Junction *)((Junction *)zzaRet.left)->p1);  /* MR7 */\r
-                  altAdd(CurAltStart);                         /* MR7 */\r
-                };                                              /* MR7 */\r
-                _retv = (Node *) ((Junction *)zzaRet.left)->p1;\r
-              }\r
-            }\r
-            else {\r
-              if ( (LA(1)==102) ) {\r
-                zzmatch(102); zzCONSUME;\r
-                block( &toksrefd,&rulesrefd );\r
-                zzaRet = makeOpt(zzaArg(zztasp2,2),approx,pFirstSetSymbol);\r
-                /* MR23 */      CurBlockID_array[BlkLevel] = (-1);\r
-                /* MR23 */      CurAltNum_array[BlkLevel] = (-1);                \r
-                --BlkLevel;\r
-                zzmatch(98);\r
-                \r
-                ((Junction *)((Junction *)zzaRet.left)->p1)->blockid = CurBlockID;\r
-                ((Junction *)((Junction *)zzaRet.left)->p1)->tokrefs = toksrefd;\r
-                ((Junction *)((Junction *)zzaRet.left)->p1)->rulerefs = rulesrefd;\r
- zzCONSUME;\r
-\r
-                if (  first_on_line ) {                            /* MR7 */\r
-                  CurAltStart = (Junction *) ((Junction *)((Junction *)zzaRet.left)->p1);  /* MR7 */\r
-                  altAdd(CurAltStart);                             /* MR7 */\r
-                };\r
-                _retv = (Node *) ((Junction *)zzaRet.left)->p1;\r
-              }\r
-              else {zzFAIL(1,zzerr52,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
-            }\r
-            zzEXIT(zztasp2);\r
-            }\r
-          }\r
-        }\r
-        else {\r
-          if ( (LA(1)==129) ) {\r
-            zzmatch(129);\r
-            warn("don't you want a ')' with that '*'?"); CannotContinue=TRUE;\r
- zzCONSUME;\r
-\r
-          }\r
-          else {\r
-            if ( (LA(1)==130) ) {\r
-              zzmatch(130);\r
-              warn("don't you want a ')' with that '+'?"); CannotContinue=TRUE;\r
- zzCONSUME;\r
-\r
-            }\r
-            else {\r
-              if ( (LA(1)==105) ) {\r
-                zzmatch(105);\r
-                warn("'>' can only appear after a nonterminal"); CannotContinue=TRUE;\r
- zzCONSUME;\r
-\r
-              }\r
-              else {\r
-                if ( (LA(1)==PassAction) ) {\r
-                  zzmatch(PassAction);\r
-                  warn("[...] out of context 'rule > [...]'");\r
-                  CannotContinue=TRUE;\r
- zzCONSUME;\r
-\r
-                }\r
-                else {zzFAIL(1,zzerr53,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
-              }\r
-            }\r
-          }\r
-        }\r
-      }\r
-    }\r
-  }\r
-  zzEXIT(zztasp1);\r
-  return _retv;\r
-fail:\r
-  zzEXIT(zztasp1);\r
-  CannotContinue=TRUE;  \r
-  zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);\r
-  zzresynch(setwd9, 0x1);\r
-  return _retv;\r
-  }\r
-}\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-default_exception_handler(void)\r
-#else\r
-default_exception_handler()\r
-#endif\r
-{\r
-  zzRULE;\r
-  zzBLOCK(zztasp1);\r
-  zzMake0;\r
-  {\r
-   DefaultExGroup  = exception_group();\r
-\r
-  zzEXIT(zztasp1);\r
-  return;\r
-fail:\r
-  zzEXIT(zztasp1);\r
-  zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);\r
-  zzresynch(setwd9, 0x2);\r
-  }\r
-}\r
-\r
-ExceptionGroup *\r
-#ifdef __USE_PROTOS\r
-exception_group(void)\r
-#else\r
-exception_group()\r
-#endif\r
-{\r
-  ExceptionGroup *   _retv;\r
-  zzRULE;\r
-  zzBLOCK(zztasp1);\r
-  PCCTS_PURIFY(_retv,sizeof(ExceptionGroup *  ))\r
-  zzMake0;\r
-  {\r
-  ExceptionHandler *h; LabelEntry *label=NULL;   /* MR6 */\r
-  FoundException = 1; FoundExceptionGroup = 1;\r
-  zzmatch(133);\r
-  _retv = (ExceptionGroup *)calloc(1, sizeof(ExceptionGroup));\r
- zzCONSUME;\r
-\r
-  {\r
-    zzBLOCK(zztasp2);\r
-    zzMake0;\r
-    {\r
-    char *p;\r
-    if ( (LA(1)==PassAction) ) {\r
-      zzmatch(PassAction);\r
-      \r
-      p = LATEXT(1)+1;\r
-      p[strlen(p)-1] = '\0';           /* kill trailing space */\r
-      label = (LabelEntry *) hash_get(Elabel, LATEXT(1)+1);\r
-      if ( label==NULL )\r
-      {\r
-        err(eMsg1("unknown label in exception handler: '%s'", LATEXT(1)+1));\r
-      }\r
- zzCONSUME;\r
-\r
-    }\r
-    else {\r
-      if ( (setwd9[LA(1)]&0x4) ) {\r
-      }\r
-      else {zzFAIL(1,zzerr54,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
-    }\r
-    zzEXIT(zztasp2);\r
-    }\r
-  }\r
-  {\r
-    zzBLOCK(zztasp2);\r
-    zzMake0;\r
-    {\r
-    while ( (LA(1)==135) ) {\r
-       h  = exception_handler();\r
-\r
-      list_add(&(_retv->handlers), (void *)h);\r
-      zzLOOP(zztasp2);\r
-    }\r
-    zzEXIT(zztasp2);\r
-    }\r
-  }\r
-  {\r
-    zzBLOCK(zztasp2);\r
-    zzMake0;\r
-    {\r
-    if ( (LA(1)==134) ) {\r
-      zzmatch(134); zzCONSUME;\r
-      zzmatch(106); zzCONSUME;\r
-      zzmatch(Action);\r
-      {\r
-        ExceptionHandler *eh = (ExceptionHandler *)\r
-        calloc(1, sizeof(ExceptionHandler));\r
-        char *a = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));\r
-        require(eh!=NULL, "exception: cannot allocate handler");\r
-        require(a!=NULL, "exception: cannot allocate action");\r
-        strcpy(a, LATEXT(1));\r
-        eh->action = a;\r
-        eh->signalname = (char *) calloc(strlen("default")+1, sizeof(char));\r
-        require(eh->signalname!=NULL, "exception: cannot allocate sig name");\r
-        strcpy(eh->signalname, "default");\r
-        list_add(&(_retv->handlers), (void *)eh);\r
-      }\r
- zzCONSUME;\r
-\r
-    }\r
-    else {\r
-      if ( (setwd9[LA(1)]&0x8) ) {\r
-      }\r
-      else {zzFAIL(1,zzerr55,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
-    }\r
-    zzEXIT(zztasp2);\r
-    }\r
-  }\r
-  \r
-  if ( label!=NULL ) {\r
-    /* Record ex group in sym tab for this label */\r
-    if ( label->ex_group!=NULL ) {\r
-      err(eMsg1("duplicate exception handler for label '%s'",label->str));\r
-    } else {\r
-      label->ex_group = _retv;\r
-      /* Label the exception group itself */\r
-      _retv->label = label->str;\r
-      /* Make the labelled element pt to the exception also */\r
-      /* MR6 */          if (label->elem == NULL) {\r
-        /* MR6 */           err(eMsg1("reference in exception handler to undefined label '%s'",label->str));\r
-        /* MR6 */        } else {\r
-        switch ( label->elem->ntype ) {\r
-          case nRuleRef :\r
-          {\r
-            RuleRefNode *r = (RuleRefNode *)label->elem;\r
-            r->ex_group = _retv;\r
-            break;\r
-          }\r
-          case nToken :\r
-          {\r
-            TokNode *t = (TokNode *)label->elem;\r
-            t->ex_group = _retv;\r
-            break;\r
-          }\r
-        } /* end switch */\r
-        /* MR6 */        }; /* end test on label->elem */\r
-    } /* end test on label->ex_group */\r
-    \r
-               } /* end test on exception label */\r
-  \r
-/* MR7 */\r
-  /* MR7 */   if (BlkLevel == 1 && label == NULL) {\r
-    /* MR7 */     _retv->forRule=1;\r
-    /* MR7 */   } else if (label == NULL) {\r
-    /* MR7 */     _retv->altID = makeAltID(CurBlockID_array[BlkLevel], CurAltNum_array[BlkLevel]);\r
-    /* MR7 */     egAdd(_retv);\r
-    /* MR7 */   } else {\r
-    /* MR7 */     _retv->labelEntry=label;\r
-    /* MR7 */   };\r
-  /* MR7 */\r
-  /* MR7 */        /* You may want to remove this exc from the rule list  */\r
-  /* MR7 */            /* and handle at the labeled element site.             */\r
-  /* MR7 */\r
-  /* MR7 */   if (label != NULL) {\r
-    /* MR7 */     _retv = NULL;\r
-    /* MR7 */   };\r
-  zzEXIT(zztasp1);\r
-  return _retv;\r
-fail:\r
-  zzEXIT(zztasp1);\r
-  CannotContinue=TRUE;  \r
-  zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);\r
-  zzresynch(setwd9, 0x10);\r
-  return _retv;\r
-  }\r
-}\r
-\r
-ExceptionHandler *\r
-#ifdef __USE_PROTOS\r
-exception_handler(void)\r
-#else\r
-exception_handler()\r
-#endif\r
-{\r
-  ExceptionHandler *   _retv;\r
-  zzRULE;\r
-  zzBLOCK(zztasp1);\r
-  PCCTS_PURIFY(_retv,sizeof(ExceptionHandler *  ))\r
-  zzMake0;\r
-  {\r
-  ;\r
-  zzmatch(135);\r
-  \r
-  _retv = (ExceptionHandler *)calloc(1, sizeof(ExceptionHandler));\r
-  require(_retv!=NULL, "exception: cannot allocate handler");\r
- zzCONSUME;\r
-\r
-  {\r
-    zzBLOCK(zztasp2);\r
-    zzMake0;\r
-    {\r
-    if ( (LA(1)==NonTerminal) ) {\r
-      zzmatch(NonTerminal);\r
-      \r
-      _retv->signalname = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));\r
-      require(_retv->signalname!=NULL, "exception: cannot allocate sig name");\r
-      strcpy(_retv->signalname, LATEXT(1));\r
- zzCONSUME;\r
-\r
-    }\r
-    else {\r
-      if ( (LA(1)==TokenTerm) ) {\r
-        zzmatch(TokenTerm);\r
-        \r
-        _retv->signalname = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));\r
-        require(_retv->signalname!=NULL, "exception: cannot allocate sig name");\r
-        strcpy(_retv->signalname, LATEXT(1));\r
- zzCONSUME;\r
-\r
-      }\r
-      else {zzFAIL(1,zzerr56,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
-    }\r
-    zzEXIT(zztasp2);\r
-    }\r
-  }\r
-  zzmatch(106); zzCONSUME;\r
-  {\r
-    zzBLOCK(zztasp2);\r
-    zzMake0;\r
-    {\r
-    _retv->action = NULL;\r
-    if ( (LA(1)==Action) ) {\r
-      zzmatch(Action);\r
-      \r
-      _retv->action = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));\r
-      require(_retv->action!=NULL, "exception: cannot allocate action");\r
-      strcpy(_retv->action, LATEXT(1));\r
- zzCONSUME;\r
-\r
-    }\r
-    else {\r
-      if ( (setwd9[LA(1)]&0x20) ) {\r
-      }\r
-      else {zzFAIL(1,zzerr57,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
-    }\r
-    zzEXIT(zztasp2);\r
-    }\r
-  }\r
-  zzEXIT(zztasp1);\r
-  return _retv;\r
-fail:\r
-  zzEXIT(zztasp1);\r
-  CannotContinue=TRUE;  \r
-  zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);\r
-  zzresynch(setwd9, 0x40);\r
-  return _retv;\r
-  }\r
-}\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-enum_file(char * fname)\r
-#else\r
-enum_file(fname)\r
- char *fname ;\r
-#endif\r
-{\r
-  zzRULE;\r
-  zzBLOCK(zztasp1);\r
-  zzMake0;\r
-  {\r
-  if ( (setwd9[LA(1)]&0x80) ) {\r
-    {\r
-      zzBLOCK(zztasp2);\r
-      zzMake0;\r
-      {\r
-      if ( (LA(1)==143) ) {\r
-        zzmatch(143); zzCONSUME;\r
-        zzmatch(ID); zzCONSUME;\r
-        {\r
-          zzBLOCK(zztasp3);\r
-          zzMake0;\r
-          {\r
-          if ( (LA(1)==149) ) {\r
-            zzmatch(149); zzCONSUME;\r
-            zzmatch(ID); zzCONSUME;\r
-          }\r
-          else {\r
-            if ( (setwd10[LA(1)]&0x1) ) {\r
-            }\r
-            else {zzFAIL(1,zzerr58,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
-          }\r
-          zzEXIT(zztasp3);\r
-          }\r
-        }\r
-      }\r
-      else {\r
-        if ( (setwd10[LA(1)]&0x2) ) {\r
-        }\r
-        else {zzFAIL(1,zzerr59,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
-      }\r
-      zzEXIT(zztasp2);\r
-      }\r
-    }\r
-    {\r
-      zzBLOCK(zztasp2);\r
-      zzMake0;\r
-      {\r
-      if ( (LA(1)==151) ) {\r
-        {\r
-          zzBLOCK(zztasp3);\r
-          int zzcnt=1;\r
-          zzMake0;\r
-          {\r
-          do {\r
-            enum_def(  fname );\r
-            zzLOOP(zztasp3);\r
-          } while ( (LA(1)==151) );\r
-          zzEXIT(zztasp3);\r
-          }\r
-        }\r
-      }\r
-      else {\r
-        if ( (LA(1)==149) ) {\r
-          defines(  fname );\r
-        }\r
-        else {zzFAIL(1,zzerr60,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
-      }\r
-      zzEXIT(zztasp2);\r
-      }\r
-    }\r
-  }\r
-  else {\r
-    if ( (LA(1)==Eof) ) {\r
-    }\r
-    else {zzFAIL(1,zzerr61,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
-  }\r
-  zzEXIT(zztasp1);\r
-  return;\r
-fail:\r
-  zzEXIT(zztasp1);\r
-  zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);\r
-  zzresynch(setwd10, 0x4);\r
-  }\r
-}\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-defines(char * fname)\r
-#else\r
-defines(fname)\r
- char *fname ;\r
-#endif\r
-{\r
-  zzRULE;\r
-  zzBLOCK(zztasp1);\r
-  zzMake0;\r
-  {\r
-  int v; int maxt=(-1); char *t;\r
-  {\r
-    zzBLOCK(zztasp2);\r
-    int zzcnt=1;\r
-    zzMake0;\r
-    {\r
-    do {\r
-      zzmatch(149); zzCONSUME;\r
-      zzmatch(ID);\r
-      t = mystrdup(LATEXT(1));\r
- zzCONSUME;\r
-\r
-      zzmatch(INT);\r
-      \r
-      v = atoi(LATEXT(1));\r
-      /*                       fprintf(stderr, "#token %s=%d\n", t, v);*/\r
-      \r
-       /* MR2 Andreas Magnusson (Andreas.Magnusson@mailbox.swipnet.se) */\r
-      /* MR2 Fix to bug introduced by 1.33MR1 for #tokdefs            */\r
-      /* MR2 Don't let #tokdefs be confused by                         */\r
-      /* MR2   DLGminToken and DLGmaxToken                             */\r
-      \r
-                       if ( ! isDLGmaxToken(t)) {              /* MR2 */\r
-      TokenNum = v;\r
-      if ( v>maxt ) maxt=v;\r
-      if ( Tnum( t ) == 0 ) {\r
-      addForcedTname( t, v );\r
-    } else {\r
-    warnFL(eMsg1("redefinition of token %s; ignored",t), fname,zzline);\r
-  };\r
-};\r
- zzCONSUME;\r
-\r
-      zzLOOP(zztasp2);\r
-    } while ( (LA(1)==149) );\r
-    zzEXIT(zztasp2);\r
-    }\r
-  }\r
-  TokenNum = maxt + 1;\r
-  zzEXIT(zztasp1);\r
-  return;\r
-fail:\r
-  zzEXIT(zztasp1);\r
-  zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);\r
-  zzresynch(setwd10, 0x8);\r
-  }\r
-}\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-enum_def(char * fname)\r
-#else\r
-enum_def(fname)\r
- char *fname ;\r
-#endif\r
-{\r
-  zzRULE;\r
-  zzBLOCK(zztasp1);\r
-  zzMake0;\r
-  {\r
-  int v= 0; int maxt=(-1); char *t;\r
-  zzmatch(151); zzCONSUME;\r
-  zzmatch(ID); zzCONSUME;\r
-  zzmatch(152); zzCONSUME;\r
-  zzmatch(ID);\r
-  t = mystrdup(LATEXT(1));\r
- zzCONSUME;\r
-\r
-  {\r
-    zzBLOCK(zztasp2);\r
-    zzMake0;\r
-    {\r
-    if ( (LA(1)==153) ) {\r
-      zzmatch(153); zzCONSUME;\r
-      zzmatch(INT);\r
-      v=atoi(LATEXT(1));\r
- zzCONSUME;\r
-\r
-    }\r
-    else {\r
-      if ( (setwd10[LA(1)]&0x10) ) {\r
-        v++;\r
-      }\r
-      else {zzFAIL(1,zzerr62,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
-    }\r
-    zzEXIT(zztasp2);\r
-    }\r
-  }\r
-  \r
-  /*                   fprintf(stderr, "#token %s=%d\n", t, v);*/\r
-  TokenNum = v;\r
-  if ( v>maxt ) maxt=v;                                /* MR3 */\r
-  if ( Tnum( t ) == 0 ) addForcedTname( t, v );\r
-  else {\r
-    warnFL(eMsg1("redefinition of token %s; ignored",t), fname,zzline);\r
-  }\r
-  {\r
-    zzBLOCK(zztasp2);\r
-    zzMake0;\r
-    {\r
-    while ( (LA(1)==154) ) {\r
-      zzmatch(154); zzCONSUME;\r
-      {\r
-        zzBLOCK(zztasp3);\r
-        zzMake0;\r
-        {\r
-        if ( (LA(1)==ID)&&(isDLGmaxToken(LATEXT(1))) ) {\r
-          if (!(isDLGmaxToken(LATEXT(1)))            ) {zzfailed_pred("  isDLGmaxToken(LATEXT(1))",0 /* report */, { 0; /* no user action */ } );}\r
-          zzmatch(ID); zzCONSUME;\r
-          {\r
-            zzBLOCK(zztasp4);\r
-            zzMake0;\r
-            {\r
-            if ( (LA(1)==153) ) {\r
-              zzmatch(153); zzCONSUME;\r
-              zzmatch(INT); zzCONSUME;\r
-            }\r
-            else {\r
-              if ( (setwd10[LA(1)]&0x20) ) {\r
-              }\r
-              else {zzFAIL(1,zzerr63,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
-            }\r
-            zzEXIT(zztasp4);\r
-            }\r
-          }\r
-        }\r
-        else {\r
-          if ( (LA(1)==ID) ) {\r
-            zzmatch(ID);\r
-            t = mystrdup(LATEXT(1));\r
- zzCONSUME;\r
-\r
-            {\r
-              zzBLOCK(zztasp4);\r
-              zzMake0;\r
-              {\r
-              if ( (LA(1)==153) ) {\r
-                zzmatch(153); zzCONSUME;\r
-                zzmatch(INT);\r
-                v=atoi(LATEXT(1));\r
- zzCONSUME;\r
-\r
-              }\r
-              else {\r
-                if ( (setwd10[LA(1)]&0x40) ) {\r
-                  v++;\r
-                }\r
-                else {zzFAIL(1,zzerr64,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
-              }\r
-              zzEXIT(zztasp4);\r
-              }\r
-            }\r
-            \r
-            /*                                 fprintf(stderr, "#token %s=%d\n", t, v);*/\r
-            TokenNum = v;\r
-            if ( v>maxt ) maxt=v;                              /* MR3 */\r
-            if ( Tnum( t ) == 0 ) addForcedTname( t, v );\r
-            else {\r
-              warnFL(eMsg1("redefinition of token %s; ignored",t), fname,zzline);\r
-            }\r
-          }\r
-          else {\r
-            if ( (setwd10[LA(1)]&0x80) ) {\r
-            }\r
-            else {zzFAIL(1,zzerr65,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
-          }\r
-        }\r
-        zzEXIT(zztasp3);\r
-        }\r
-      }\r
-      zzLOOP(zztasp2);\r
-    }\r
-    zzEXIT(zztasp2);\r
-    }\r
-  }\r
-  zzmatch(155); zzCONSUME;\r
-  zzmatch(156);\r
-  TokenNum = maxt + 1;\r
- zzCONSUME;\r
-\r
-  zzEXIT(zztasp1);\r
-  return;\r
-fail:\r
-  zzEXIT(zztasp1);\r
-  zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);\r
-  zzresynch(setwd11, 0x1);\r
-  }\r
-}\r
-\r
-\r
-/* MR2 Andreas Magnusson (Andreas.Magnusson@mailbox.swipnet.se) */\r
-/* MR2 Fix to bug introduced by 1.33MR1 for #tokdefs            */\r
-/* MR2 Don't let #tokdefs be confused by                       */\r
-/* MR2   DLGminToken and DLGmaxToken                           */\r
-\r
-/* semantic check on DLGminToken and DLGmaxmaxToken in #tokdefs */\r
-\r
-#ifdef __USE_PROTOS\r
-static int isDLGmaxToken(char *Token)\r
-#else\r
-static int isDLGmaxToken(Token)\r
-char * Token;\r
-#endif\r
-{\r
-static char checkStr1[] = "DLGmaxToken";\r
-static char checkStr2[] = "DLGminToken";\r
-\r
-   if (strcmp(Token, checkStr1) == 0)\r
-return 1;\r
-else if (strcmp(Token, checkStr2) == 0)\r
-return 1;\r
-else\r
-return 0;\r
-}\r
-\r
-/* semantics of #token */\r
-static void\r
-#ifdef __USE_PROTOS\r
-chkToken(char *t, char *e, char *a, int tnum)\r
-#else\r
-chkToken(t,e,a,tnum)\r
-char *t, *e, *a;\r
-int tnum;\r
-#endif\r
-{\r
-TermEntry *p;\r
-\r
-       /* check to see that they don't try to redefine a token as a token class */\r
-if ( t!=NULL ) {\r
-p = (TermEntry *) hash_get(Tname, t);\r
-if ( p!=NULL && p->classname ) {\r
-  err(eMsg1("redefinition of #tokclass '%s' to #token not allowed; ignored",t));\r
-  if ( a!=NULL ) free((char *)a);\r
-  return;\r
-}\r
-}\r
-\r
-       if ( t==NULL && e==NULL ) {                     /* none found */\r
-err("#token requires at least token name or rexpr");\r
-}\r
-else if ( t!=NULL && e!=NULL ) {       /* both found */\r
-if ( UserDefdTokens ) {                        /* if #tokdefs, must not define new */\r
-  p = (TermEntry *) hash_get(Tname, t);\r
-  if ( p == NULL) {\r
-    err(eMsg1("new token definition '%s' not allowed - only #token with name already defined by #tokdefs file allowed",t));\r
-    return;\r
-  };\r
-}\r
-Tklink(t, e);\r
-if ( a!=NULL ) {\r
-  if ( hasAction(e) ) {\r
-    err(eMsg1("redefinition of action for %s; ignored",e));\r
-  }\r
-  else setHasAction(e, a);\r
-}\r
-}\r
-else if ( t!=NULL ) {                          /* only one found */\r
-if ( UserDefdTokens ) {\r
-  p = (TermEntry *) hash_get(Tname, t);\r
-  if (p == NULL) {\r
-    err(eMsg1("new token definition '%s' not allowed - only #token with name already defined by #tokdefs file allowed",t));\r
-  };\r
-  return;\r
-}\r
-if ( Tnum( t ) == 0 ) addTname( t );\r
-else {\r
-  err(eMsg1("redefinition of token %s; ignored",t));\r
-}\r
-if ( a!=NULL ) {\r
-  err(eMsg1("action cannot be attached to a token name (%s); ignored",t));\r
-  free((char *)a);\r
-}\r
-}\r
-else if ( e!=NULL ) {\r
-if ( Tnum( e ) == 0 ) addTexpr( e );\r
-else {\r
-  if ( hasAction(e) ) {\r
-    err(eMsg1("redefinition of action for expr %s; ignored",e));\r
-  }\r
-  else if ( a==NULL ) {\r
-    err(eMsg1("redefinition of expr %s; ignored",e));\r
-  }\r
-}\r
-if ( a!=NULL ) setHasAction(e, a);\r
-}\r
-\r
-       /* if a token type number was specified, then add the token ID and 'tnum'\r
-* pair to the ForcedTokens list.  (only applies if an id was given)\r
-*/\r
-if ( t!=NULL && tnum>0 )\r
-{\r
-if ( set_el(tnum, reserved_positions) )\r
-{\r
-  err(eMsgd("a token has already been forced to token number %d; ignored", tnum));\r
-}\r
-else\r
-{\r
-  list_add(&ForcedTokens, newForcedToken(t,tnum));\r
-  set_orel(tnum, &reserved_positions);\r
-}\r
-}\r
-}\r
-\r
-static int\r
-#ifdef __USE_PROTOS\r
-match_token(char *s, char **nxt)\r
-#else\r
-match_token(s,nxt)\r
-char *s;\r
-char **nxt;\r
-#endif\r
-{\r
-  if ( !(*s>='A' && *s<='Z') ) return 0;\r
-  s++;\r
-  while ( (*s>='a' && *s<='z') ||\r
-  (*s>='A' && *s<='Z') ||\r
-  (*s>='0' && *s<='9') ||\r
-  *s=='_' )\r
-  {\r
-    s++;\r
-  }\r
-  if ( *s!=' ' && *s!='}' ) return 0;\r
-  *nxt = s;\r
-  return 1;\r
-}\r
-\r
-static int\r
-#ifdef __USE_PROTOS\r
-match_rexpr(char *s, char **nxt)\r
-#else\r
-match_rexpr(s,nxt)\r
-char *s;\r
-char **nxt;\r
-#endif\r
-{\r
-  if ( *s!='"' ) return 0;\r
-  s++;\r
-  while ( *s!='"' )\r
-  {\r
-    if ( *s=='\n' || *s=='\r' )                   /* MR13 */\r
-    warn("eoln found in regular expression");\r
-    if ( *s=='\\' ) s++;\r
-    s++;\r
-  }\r
-  *nxt = s+1;\r
-  return 1;\r
-}\r
-\r
-/*\r
-* Walk a string "{ A .. Z }" where A..Z is a space separated list\r
-* of token references (either labels or reg exprs).  Return a\r
-* string "inlineX_set" for some unique integer X.  Basically,\r
-* we pretend as if we had seen "#tokclass inlineX { A .. Z }"\r
-* on the input stream outside of an action.\r
-*/\r
-char *\r
-#ifdef __USE_PROTOS\r
-inline_set(char *s)\r
-#else\r
-inline_set(s)\r
-char *s;\r
-#endif\r
-{\r
-  char *nxt;\r
-  fprintf(stderr, "found consumeUntil( {...} )\n");\r
-  while ( *s==' ' || *s=='\t' || *s=='\n' || *s=='\r' ) {s++;}\r
-  if ( *s!='{' )\r
-  {\r
-    err("malformed consumeUntil( {...} ); missing '{'");\r
-    return "bad_set";\r
-  }\r
-  s++;\r
-  while ( *s==' ' || *s=='\t' || *s=='\n' || *s=='\r' ) {s++;}\r
-  while ( *s!='}' )\r
-  {\r
-    if ( match_token(s,&nxt) ) fprintf(stderr, "found token %s\n", s);\r
-    else if ( match_rexpr(s,&nxt) ) fprintf(stderr, "found rexpr %s\n", s);\r
-    else {\r
-      err("invalid element in consumeUntil( {...} )");\r
-      return "bad_set";\r
-    }\r
-    s = nxt;\r
-    while ( *s==' ' || *s=='\t' || *s=='\n' || *s=='\r' ) {s++;}\r
-  }\r
-  return "inlineX_set";\r
-}\r
-\r
-/* ANTLR-specific syntax error message generator\r
-* (define USER_ZZSYN when compiling so don't get 2 definitions)\r
-*/\r
-void\r
-#ifdef __USE_PROTOS\r
-zzsyn(char *text, int tok, char *egroup, SetWordType *eset, int etok,\r
-int k, char *bad_text)\r
-#else\r
-zzsyn(text, tok, egroup, eset, etok, k, bad_text)\r
-char *text, *egroup, *bad_text;\r
-int tok;\r
-int etok;\r
-int k;\r
-SetWordType *eset;\r
-#endif\r
-{\r
-fprintf(stderr, ErrHdr, FileStr[CurFile]!=NULL?FileStr[CurFile]:"stdin", zzline);\r
-fprintf(stderr, " syntax error at \"%s\"", (tok==zzEOF_TOKEN)?"EOF":text);\r
-if ( !etok && !eset ) {fprintf(stderr, "\n"); return;}\r
-if ( k==1 ) fprintf(stderr, " missing");\r
-else\r
-{\r
-fprintf(stderr, "; \"%s\" not", bad_text);\r
-if ( zzset_deg(eset)>1 ) fprintf(stderr, " in");\r
-}\r
-if ( zzset_deg(eset)>0 ) zzedecode(eset);\r
-else fprintf(stderr, " %s", zztokens[etok]);\r
-if ( strlen(egroup) > (size_t)0 ) fprintf(stderr, " in %s", egroup);\r
-fprintf(stderr, "\n");\r
-}\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/antlr/antlr.g b/Tools/CodeTools/TianoTools/Pccts/antlr/antlr.g
deleted file mode 100644 (file)
index e6eda60..0000000
+++ /dev/null
@@ -1,2586 +0,0 @@
-/*\r
- * antlr.g     --      PCCTS Version 1.xx ANTLR\r
- *\r
- * Parse an antlr input grammar and build a syntax-diagram.\r
- *\r
- * Written in itself (needs at least 1.06 to work)\r
- *\r
- * SOFTWARE RIGHTS\r
- *\r
- * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
- * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
- * company may do whatever they wish with source code distributed with\r
- * PCCTS or the code generated by PCCTS, including the incorporation of\r
- * PCCTS, or its output, into commerical software.\r
- *\r
- * We encourage users to develop software with PCCTS.  However, we do ask\r
- * that credit is given to us for developing PCCTS.  By "credit",\r
- * we mean that if you incorporate our source code into one of your\r
- * programs (commercial product, research project, or otherwise) that you\r
- * acknowledge this fact somewhere in the documentation, research report,\r
- * etc...  If you like PCCTS and have developed a nice tool with the\r
- * output, please mention that you developed it using PCCTS.  In\r
- * addition, we ask that this header remain intact in our source code.\r
- * As long as these guidelines are kept, we expect to continue enhancing\r
- * this system and expect to make other tools available as they are\r
- * completed.\r
- *\r
- * ANTLR 1.33\r
- * Terence Parr\r
- * Parr Research Corporation\r
- * with Purdue University and AHPCRC, University of Minnesota\r
- * 1989-1995\r
- */\r
-\r
-/* MR1                                                                 */\r
-/* MR1 10-Apr-97 MR1   Replace #if logic with #include "pcctscfg.h"    */\r
-/* MR1                                                                 */\r
-\r
-#header <<\r
-       #include "pcctscfg.h"\r
-       #include "set.h"\r
-       #include <ctype.h>\r
-       #include "syn.h"\r
-       #include "hash.h"\r
-       #include "generic.h"\r
-       #define zzcr_attr(attr,tok,t)\r
-       >>\r
-\r
-<<\r
-\r
-/* MR20 G. Hobbelt For Borland C++ 4.x & 5.x compiling with ALL warnings enabled */\r
-#if defined(__TURBOC__)\r
-#pragma warn -aus  /* unused assignment of 'xxx' */\r
-#endif\r
-\r
-\r
-#ifdef __USE_PROTOS\r
-static void chkToken(char *, char *, char *, int);\r
-#else\r
-static void chkToken();\r
-#endif\r
-\r
-#ifdef __USE_PROTOS\r
-static int isDLGmaxToken(char *Token);                              /* MR3 */\r
-#else\r
-static int isDLGmaxToken();                                                         /* MR3 */\r
-#endif\r
-\r
-static int class_nest_level = 0;\r
-\r
-/* MR20 G. Hobbelt extern definitions moved to antlr.h */\r
-\r
->>\r
-\r
-#lexaction <<\r
-/* maintained, but not used for now */\r
-set AST_nodes_refd_in_actions = set_init;\r
-int inAlt = 0;\r
-set attribsRefdFromAction = set_init; /* MR20 */\r
-int UsedOldStyleAttrib = 0;\r
-int UsedNewStyleLabel = 0;\r
-#ifdef __USE_PROTOS\r
-char *inline_set(char *);\r
-#else\r
-char *inline_set();\r
-#endif\r
-\r
-/* MR1 10-Apr-97  MR1  Previously unable to put right shift operator       */\r
-/* MR1                                 in DLG action                                       */\r
-\r
-int tokenActionActive=0;                                            /* MR1 */\r
-\r
->>\r
-\r
-#lexclass STRINGS\r
-#token QuotedTerm "\""         << zzmode(START); >>\r
-#token "\n|\r|\r\n"            <<\r
-                                                       zzline++;\r
-                                                       warn("eoln found in string");\r
-                                                       zzskip();\r
-                                                       >>\r
-#token "\\(\n|\r|\r\n)"                << zzline++; zzmore(); >>\r
-#token "\\~[]"                         << zzmore(); >>\r
-#token "~[\n\r\"\\]+"          << zzmore(); >>\r
-\r
-#lexclass ACTION_STRINGS\r
-#token "\""                                    << zzmode(ACTIONS); zzmore(); >>\r
-#token "\n|\r|\r\n"                    <<\r
-                                                       zzline++;\r
-                                                       warn("eoln found in string (in user action)");\r
-                                                       zzskip();\r
-                                                       >>\r
-#token "\\(\n|\r|\r\n)"                << zzline++; zzmore(); >>\r
-#token "\\~[]"                         << zzmore(); >>\r
-#token "~[\n\r\"\\]+"                  << zzmore(); >>\r
-\r
-#lexclass ACTION_CHARS\r
-#token "'"                                     << zzmode(ACTIONS); zzmore(); >>\r
-#token "\n|\r|\r\n"                    <<\r
-                                                       zzline++;\r
-                                                       warn("eoln found in char literal (in user action)");\r
-                                                       zzskip();\r
-                                                       >>\r
-#token "\\~[]"                         << zzmore(); >>\r
-#token "~[\n\r'\\]+"           << zzmore(); >>\r
-\r
-#lexclass ACTION_COMMENTS\r
-#token "\*/"                           << zzmode(ACTIONS); zzmore(); >>\r
-#token "\*"                                    << zzmore(); >>\r
-#token "\n|\r|\r\n"                    << zzline++; zzmore(); DAWDLE; >>\r
-#token "~[\n\r\*]+"                    << zzmore(); >>\r
-\r
-#lexclass TOK_DEF_COMMENTS\r
-#token "\*/"                           << zzmode(PARSE_ENUM_FILE);\r
-                              zzmore(); >>\r
-#token "\*"                                    << zzmore(); >>\r
-#token "\n|\r|\r\n"                    << zzline++; zzmore(); DAWDLE; >>\r
-#token "~[\n\r\*]+"                    << zzmore(); >>\r
-\r
-#lexclass TOK_DEF_CPP_COMMENTS\r
-#token "\n|\r|\r\n"                    << zzline++; zzmode(PARSE_ENUM_FILE); zzskip(); DAWDLE; >>\r
-#token "~[\n\r]+"                      << zzskip(); >>\r
-\r
-#lexclass ACTION_CPP_COMMENTS\r
-#token "\n|\r|\r\n"                    << zzline++; zzmode(ACTIONS); zzmore(); DAWDLE; >>\r
-#token "~[\n\r]+"                      << zzmore(); >>\r
-\r
-#lexclass CPP_COMMENTS\r
-#token "\n|\r|\r\n"                    << zzline++; zzmode(START); zzskip(); DAWDLE; >>\r
-#token "~[\n\r]+"                      << zzskip(); >>\r
-\r
-#lexclass COMMENTS\r
-#token "\*/"                           << zzmode(START); zzskip(); >>\r
-#token "\*"                                    << zzskip(); >>\r
-#token "\n|\r|\r\n"                    << zzline++; zzskip(); DAWDLE; >>\r
-#token "~[\n\r\*]+"                    << zzskip(); >>\r
-\r
-/*\r
- * This lexical class accepts actions of type [..] and <<..>>\r
- *\r
- * It translates the following special items for C:\r
- *\r
- * $j          --> "zzaArg(current zztasp, j)"\r
- * $i.j                --> "zzaArg(zztaspi, j)"\r
- * $i.nondigit> "zzaArg(current zztasp, i).nondigit"\r
- * $$          --> "zzaRet"\r
- * $alnum      --> "alnum"                     (used to ref parameters)\r
- * $rule       --> "zzaRet"\r
- * $retval     --> "_retv.retval" if > 1 return values else "_retv"\r
- * $[token, text] --> "zzconstr_attr(token, text)"\r
- * $[]         --> "zzempty_attr()"\r
- *\r
- * It translates the following special items for C++:\r
- * (attributes are now stored with 'Token' and $i's are only\r
- *  pointers to the Tokens.  Rules don't have attributes now.)\r
- *\r
- * $j          --> "_tbj" where b is the block level\r
- * $i.j                --> "_tij"\r
- * $j->nondigit> "_tbj->nondigit"\r
- * $$          --> "$$"\r
- * $alnum      --> "alnum"                     (used to ref parameters)\r
- * $rule       --> "$rule"\r
- * $retval     --> "_retv.retval" if > 1 return values else "_retv"\r
- * $[token, text] --> invalid\r
- * $[]         --> invalid\r
- *\r
- * And, for trees:\r
- *\r
- * #0          -->     "(*_root)"\r
- * #i          --> "zzastArg(i)"\r
- * #[args]     --> "zzmk_ast(zzastnew(), args)"\r
- * #[]         --> "zzastnew()"\r
- * #( root, child1, ..., childn )\r
- *                     --> "zztmake(root, child1, ...., childn, NULL)"\r
- * #()         --> "NULL"\r
- *\r
- * For C++, ...\r
- *\r
- * #0          -->     "(*_root)"\r
- * #i          --> "_astbi" where b is the block level\r
- * #alnum      --> "alnum_ast" (used to ref #label)\r
- * #[args]     --> "new AST(args)"\r
- * #[]         --> "new AST"\r
- * #( root, child1, ..., childn )\r
- *                     --> "AST::tmake(root, child1, ...., childn, NULL)"\r
- * #()         --> "NULL"\r
- *\r
- * To escape,\r
- *\r
- * \]          --> ]\r
- * \)          --> )\r
- * \$          --> $\r
- * \#          --> #\r
- *\r
- * A stack is used to nest action terminators because they can be nested\r
- * like crazy:  << #[$[..],..] >>\r
- */\r
-#lexclass ACTIONS\r
-#token Action "\>\>"        << /* these do not nest */\r
-                              zzmode(START);\r
-                              NLATEXT[0] = ' ';\r
-                              NLATEXT[1] = ' ';\r
-                              zzbegexpr[0] = ' ';\r
-                              zzbegexpr[1] = ' ';\r
-                                                         if ( zzbufovf ) {\r
-                                                               err( eMsgd("action buffer overflow; size %d",ZZLEXBUFSIZE));\r
-                                                         }\r
-\r
-/* MR1 10-Apr-97  MR1  Previously unable to put right shift operator   */\r
-/* MR1                                 in DLG action                   */\r
-/* MR1                 Doesn't matter what kind of action it is - reset*/\r
-\r
-                             tokenActionActive=0;               /* MR1 */\r
-                            >>\r
-#token Pred "\>\>?"                    << /* these do not nest */\r
-                              zzmode(START);\r
-                              NLATEXT[0] = ' ';\r
-                              NLATEXT[1] = ' ';\r
-                              zzbegexpr[0] = '\0';\r
-                                                         if ( zzbufovf ) {\r
-                                                               err( eMsgd("predicate buffer overflow; size %d",ZZLEXBUFSIZE));\r
-                                                         };\r
-#ifdef __cplusplus__\r
-/* MR10 */                    list_apply(CurActionLabels, (void (*)(void *))mark_label_used_in_sem_pred);\r
-#else\r
-#ifdef __STDC__\r
-/* MR10 */                    list_apply(CurActionLabels, (void (*)(void *))mark_label_used_in_sem_pred);\r
-#else\r
-#ifdef __USE_PROTOS\r
-/* MRxx */                    list_apply(CurActionLabels, (void (*)(void *))mark_label_used_in_sem_pred);\r
-#else\r
-/* MR10 */                    list_apply(CurActionLabels,mark_label_used_in_sem_pred);\r
-#endif\r
-#endif\r
-#endif\r
-                            >>\r
-#token PassAction "\]"         << if ( topint() == ']' ) {\r
-                                                                 popint();\r
-                                                                 if ( istackempty() )  /* terminate action */\r
-                                                                 {\r
-                                                                         zzmode(START);\r
-                                                                         NLATEXT[0] = ' ';\r
-                                                                         zzbegexpr[0] = ' ';\r
-                                                                         if ( zzbufovf ) {\r
-                                                                               err( eMsgd("parameter buffer overflow; size %d",ZZLEXBUFSIZE));\r
-                                                                         }\r
-                                                                 }\r
-                                                                 else {\r
-                                                                         /* terminate $[..] and #[..] */\r
-                                                                         if ( GenCC ) zzreplstr("))");\r
-                                                                         else zzreplstr(")");\r
-                                                                         zzmore();\r
-                                                                 }\r
-                                                          }\r
-                                                          else if ( topint() == '|' ) { /* end of simple [...] */\r
-                                                                 popint();\r
-                                                                 zzmore();\r
-                                                          }\r
-                                                          else zzmore();\r
-                                                       >>\r
-#token "consumeUntil\( [\ \t]* \{~[\}]+\} [\ \t]* \)"\r
-                                                       <<\r
-                                                       zzmore();\r
-                                                       zzreplstr(inline_set(zzbegexpr+\r
-                                                                         strlen("consumeUntil(")));\r
-                                                       >>\r
-#token "consumeUntil\( ~[\)]+ \)"\r
-                                                       << zzmore(); >>\r
-#token "\n|\r|\r\n"                    << zzline++; zzmore(); DAWDLE; >>\r
-#token "\>"                                    << zzmore(); >>\r
-#token "$"                                     << zzmore(); >>\r
-#token "$$"                                    << if ( !GenCC ) {zzreplstr("zzaRet"); zzmore();}\r
-                                                          else err("$$ use invalid in C++ mode"); >>\r
-\r
-#token "$\[\]"                         << if ( !GenCC ) {zzreplstr("zzempty_attr"); zzmore();}\r
-                                                          else err("$[] use invalid in C++ mode"); >>\r
-#token "$\["                           <<\r
-                                                       pushint(']');\r
-                                                       if ( !GenCC ) zzreplstr("zzconstr_attr(");\r
-                                                       else err("$[..] use invalid in C++ mode");\r
-                                                       zzmore();\r
-                                                       >>\r
-#token "$[0-9]+"                       <<{\r
-                                                       static char buf[100];\r
-                            numericActionLabel=1;       /* MR10 */\r
-                                                       if ( strlen(zzbegexpr)>(size_t)85 )\r
-                                                               fatal("$i attrib ref too big");\r
-                                                       set_orel(atoi(zzbegexpr+1), &attribsRefdFromAction);\r
-                                                       if ( !GenCC ) sprintf(buf,"zzaArg(zztasp%d,%s)",\r
-                                                                               BlkLevel-1,zzbegexpr+1);\r
-                                                       else sprintf(buf,"_t%d%s",\r
-                                                                               BlkLevel-1,zzbegexpr+1);\r
-                                                       zzreplstr(buf);\r
-                                                       zzmore();\r
-                                                       UsedOldStyleAttrib = 1;\r
-                                                       if ( UsedNewStyleLabel )\r
-                                                               err("cannot mix old-style $i with new-style labels");\r
-                                                       }\r
-                                                       >>\r
-#token "$[0-9]+."                      <<{\r
-                                                       static char buf[100];\r
-                            numericActionLabel=1;       /* MR10 */\r
-                                                       if ( strlen(zzbegexpr)>(size_t)85 )\r
-                                                               fatal("$i.field attrib ref too big");\r
-                                                       zzbegexpr[strlen(zzbegexpr)-1] = ' ';\r
-                                                       set_orel(atoi(zzbegexpr+1), &attribsRefdFromAction);\r
-                                                       if ( !GenCC ) sprintf(buf,"zzaArg(zztasp%d,%s).",\r
-                                                                               BlkLevel-1,zzbegexpr+1);\r
-                                                       else sprintf(buf,"_t%d%s.",\r
-                                                                               BlkLevel-1,zzbegexpr+1);\r
-                                                       zzreplstr(buf);\r
-                                                       zzmore();\r
-                                                       UsedOldStyleAttrib = 1;\r
-                                                       if ( UsedNewStyleLabel )\r
-                                                               err("cannot mix old-style $i with new-style labels");\r
-                                                       }\r
-                                                       >>\r
-#token "$[0-9]+.[0-9]+"                <<{\r
-                                                       static char buf[100];\r
-                                                       static char i[20], j[20];\r
-                                                       char *p,*q;\r
-                            numericActionLabel=1;       /* MR10 */\r
-                                                       if (strlen(zzbegexpr)>(size_t)85) fatal("$i.j attrib ref too big");\r
-                                                       for (p=zzbegexpr+1,q= &i[0]; *p!='.'; p++) {\r
-                                                               if ( q == &i[20] )\r
-                                                                        fatalFL("i of $i.j attrib ref too big",\r
-                                                                                        FileStr[CurFile], zzline );\r
-                                                               *q++ = *p;\r
-                                                       }\r
-                                                       *q = '\0';\r
-                                                       for (p++, q= &j[0]; *p!='\0'; p++) {\r
-                                                               if ( q == &j[20] )\r
-                                                                       fatalFL("j of $i.j attrib ref too big",\r
-                                                                                       FileStr[CurFile], zzline );\r
-                                                               *q++ = *p;\r
-                                                       }\r
-                                                       *q = '\0';\r
-                                                       if ( !GenCC ) sprintf(buf,"zzaArg(zztasp%s,%s)",i,j);\r
-                                                       else sprintf(buf,"_t%s%s",i,j);\r
-                                                       zzreplstr(buf);\r
-                                                       zzmore();\r
-                                                       UsedOldStyleAttrib = 1;\r
-                                                       if ( UsedNewStyleLabel )\r
-                                                               err("cannot mix old-style $i with new-style labels");\r
-                                                       }\r
-                                                       >>\r
-#token "$[_a-zA-Z][_a-zA-Z0-9]*"\r
-                                                       <<{ static char buf[300]; LabelEntry *el;\r
-                                                       zzbegexpr[0] = ' ';\r
-                                                       if ( CurRule != NULL &&\r
-                                                                strcmp(CurRule, &zzbegexpr[1])==0 ) {\r
-                                                               if ( !GenCC ) zzreplstr("zzaRet");\r
-                                                       }\r
-                                                       else if ( CurRetDef != NULL &&\r
-                                                                         strmember(CurRetDef, &zzbegexpr[1])) {\r
-                                                                if ( hasMultipleOperands( CurRetDef ) ) {\r
-                                                                       require (strlen(zzbegexpr)<=(size_t)285,\r
-                                                                                        "$retval attrib ref too big");\r
-                                                                       sprintf(buf,"_retv.%s",&zzbegexpr[1]);\r
-                                                                       zzreplstr(buf);\r
-                                                               }\r
-                                                               else zzreplstr("_retv");\r
-                                                       }\r
-                                                       else if ( CurParmDef != NULL &&\r
-                                                                         strmember(CurParmDef, &zzbegexpr[1])) {\r
-                                                               ;\r
-                                                       }\r
-                                                       else if ( Elabel==NULL ) {\r
-                                                               { err("$-variables in actions outside of rules are not allowed"); }\r
-                                                       } else if ( (el=(LabelEntry *)hash_get(Elabel, &zzbegexpr[1]))!=NULL ) {\r
-/* MR10 */\r
-/* MR10 */                      /* element labels might exist without an elem when */\r
-/* MR10 */                      /*  it is a forward reference (to a rule)          */\r
-/* MR10 */\r
-/* MR10 */                                             if ( GenCC && (el->elem == NULL || el->elem->ntype==nRuleRef) )\r
-/* MR10 */                                                     { err(eMsg1("There are no token ptrs for rule references: '$%s'",&zzbegexpr[1])); }\r
-/* MR10 */\r
-/* MR10 */                                             if ( !GenCC && (el->elem == NULL || el->elem->ntype==nRuleRef) && GenAST) {\r
-/* MR10 */                          err("You can no longer use attributes returned by rules when also using ASTs");\r
-/* MR10 */                          err("   Use upward inheritance (\"rule >[Attrib a] : ... <<$a=...\>\>\")");\r
-/* MR10 */                      };\r
-/* MR10 */\r
-/* MR10 */                      /* keep track of <<... $label ...>> for semantic predicates in guess mode */\r
-/* MR10 */                      /* element labels contain pointer to the owners node                      */\r
-/* MR10 */\r
-/* MR10 */                      if (el->elem != NULL && el->elem->ntype == nToken) {\r
-/* MR10 */                        list_add(&CurActionLabels,el);\r
-/* MR10 */                      };\r
-                                                       }\r
-                                                       else\r
-                                                               warn(eMsg1("$%s not parameter, return value, (defined) element label",&zzbegexpr[1]));\r
-                                                       }\r
-                                                       zzmore();\r
-                                                       >>\r
-#token "#0"                                    << zzreplstr("(*_root)"); zzmore(); chkGTFlag(); >>\r
-#token "#\[\]"                         << if ( GenCC ) {\r
-                                    if (NewAST) zzreplstr("(newAST)");\r
-                                        else zzreplstr("(new AST)");}\r
-                                                          else {zzreplstr("zzastnew()");} zzmore();\r
-                                                          chkGTFlag();\r
-                                                       >>\r
-#token "#\(\)"                         << zzreplstr("NULL"); zzmore(); chkGTFlag(); >>\r
-#token "#[0-9]+"                       <<{\r
-                                                       static char buf[100];\r
-                                                       if ( strlen(zzbegexpr)>(size_t)85 )\r
-                                                               fatal("#i AST ref too big");\r
-                                                       if ( GenCC ) sprintf(buf,"_ast%d%s",BlkLevel-1,zzbegexpr+1);\r
-                                                       else sprintf(buf,"zzastArg(%s)",zzbegexpr+1);\r
-                                                       zzreplstr(buf);\r
-                                                       zzmore();\r
-                                                       set_orel(atoi(zzbegexpr+1), &AST_nodes_refd_in_actions);\r
-                                                       chkGTFlag();\r
-                                                       }\r
-                                                       >>\r
-\r
-/* MR14 Arpad Beszedes  26-May-98\r
-        Add support for #line directives when antlr source is pre-processed\r
-        #lexclass ACTIONS\r
-*/\r
-\r
-#token "#line[\ \t]* [0-9]+ {[\ \t]* \"~[\"]+\" ([\ \t]* [0-9]*)* } (\n|\r|\r\n)"\r
-        <<\r
-        zzline = atoi(zzbegexpr+5) - 1; zzline++; zzmore();\r
-        getFileNameFromTheLineInfo(FileStr[CurFile], zzbegexpr);\r
-        >>\r
-\r
-#token "#line ~[\n\r]* (\n|\r|\r\n)"\r
-        <<\r
-        zzline++; zzmore();\r
-        >>\r
-\r
-/* MR14 end of a block to support #line in antlr source code */\r
-\r
-#token "#[_a-zA-Z][_a-zA-Z0-9]*"\r
-                                                       <<\r
-                                                       if ( !(strcmp(zzbegexpr, "#ifdef")==0 ||\r
-                                                                strcmp(zzbegexpr, "#if")==0 ||\r
-                                                                strcmp(zzbegexpr, "#else")==0 ||\r
-                                                                strcmp(zzbegexpr, "#endif")==0 ||\r
-                                                                strcmp(zzbegexpr, "#ifndef")==0 ||\r
-                                                                strcmp(zzbegexpr, "#define")==0 ||\r
-                                                                strcmp(zzbegexpr, "#pragma")==0 ||\r
-                                                                strcmp(zzbegexpr, "#undef")==0 ||\r
-                                                                strcmp(zzbegexpr, "#import")==0 ||\r
-                                                                strcmp(zzbegexpr, "#line")==0 ||\r
-                                                                strcmp(zzbegexpr, "#include")==0 ||\r
-                                                                strcmp(zzbegexpr, "#error")==0) )\r
-                                                       {\r
-                                                               static char buf[100];\r
-                                                               sprintf(buf, "%s_ast", zzbegexpr+1);\r
-/* MR27 */                                             list_add(&CurAstLabelsInActions, mystrdup(zzbegexpr+1));\r
-                                                               zzreplstr(buf);\r
-                                                               chkGTFlag();\r
-                                                       }\r
-                                                       zzmore();\r
-                                                       >>\r
-#token "#\["                           <<\r
-                                                       pushint(']');\r
-                                                       if ( GenCC ) {\r
-                                if (NewAST) zzreplstr("(newAST(");\r
-                                    else zzreplstr("(new AST("); }\r
-                                                       else zzreplstr("zzmk_ast(zzastnew(),");\r
-                                                       zzmore();\r
-                                                       chkGTFlag();\r
-                                                       >>\r
-#token "#\("                           <<\r
-                                                       pushint('}');\r
-                                                       if ( GenCC ) {\r
-                                                               if (tmakeInParser) {\r
-                                                                       zzreplstr("tmake(");\r
-                                                               }\r
-                                                               else {\r
-                                                                       zzreplstr("ASTBase::tmake(");\r
-                                                               }\r
-                                                       }\r
-                                                       else {\r
-                                                               zzreplstr("zztmake(");\r
-                                                       }\r
-                                                       zzmore();\r
-                                                       chkGTFlag();\r
-                                                       >>\r
-#token "#"                                     << zzmore(); >>\r
-#token "\)"                                    <<\r
-                                                       if ( istackempty() )\r
-                                                               zzmore();\r
-                                                       else if ( topint()==')' ) {\r
-                                                               popint();\r
-                                                       }\r
-                                                       else if ( topint()=='}' ) {\r
-                                                               popint();\r
-                                                               /* terminate #(..) */\r
-                                                               zzreplstr(", NULL)");\r
-                                                       }\r
-                                                       zzmore();\r
-                                                       >>\r
-#token "\["                                    <<\r
-                                                       pushint('|');   /* look for '|' to terminate simple [...] */\r
-                                                       zzmore();\r
-                                                       >>\r
-#token "\("                                    <<\r
-                                                       pushint(')');\r
-                                                       zzmore();\r
-                                                       >>\r
-\r
-#token "\\\]"                          << zzreplstr("]");  zzmore(); >>\r
-#token "\\\)"                          << zzreplstr(")");  zzmore(); >>\r
-\r
-/* MR1 10-Apr-97  MR1  Previously unable to put right shift operator   */\r
-/* MR1                                 in DLG action                   */\r
-\r
-#token "\\>"   << if (! tokenActionActive) zzreplstr(">");      /* MR1 */\r
-                  zzmore();                                     /* MR1 */\r
-               >>                                               /* MR1 */\r
-\r
-\r
-#token "'"                                     << zzmode(ACTION_CHARS); zzmore();>>\r
-#token "\""                                    << zzmode(ACTION_STRINGS); zzmore();>>\r
-#token "\\$"                           << zzreplstr("$");  zzmore(); >>\r
-#token "\\#"                           << zzreplstr("#");  zzmore(); >>\r
-#token "\\(\n|\r|\r\n)"                << zzline++; zzmore(); >>\r
-#token "\\~[\]\)>$#]"          << zzmore(); >> /* escaped char, always ignore */\r
-#token "/"                                     << zzmore(); >>\r
-#token "/\*"                           << zzmode(ACTION_COMMENTS); zzmore(); >>\r
-#token "\*/"                           << warn("Missing /*; found dangling */ in action"); zzmore(); >>\r
-#token "//"                                    << zzmode(ACTION_CPP_COMMENTS); zzmore(); >>\r
-#token "~[\n\r\)\(\\$#\>\]\[\"'/]+" << zzmore(); >>\r
-\r
-#lexclass START\r
-#token "[\t\ ]+"                       << zzskip(); >>                         /* Ignore White */\r
-#token "\n|\r|\r\n"                    << zzline++; zzskip(); >>       /* Track Line # */\r
-#token "\["                 << zzmode(ACTIONS); zzmore();\r
-                               istackreset();\r
-                               pushint(']'); >>\r
-#token "\<\<"               << action_file=CurFile; action_line=zzline;\r
-                               zzmode(ACTIONS); zzmore();\r
-                               list_free(&CurActionLabels,0);       /* MR10 */\r
-                               numericActionLabel=0;                /* MR10 */\r
-                               istackreset();\r
-                               pushint('>'); >>\r
-#token "\""                                    << zzmode(STRINGS); zzmore(); >>\r
-#token "/\*"                           << zzmode(COMMENTS); zzskip(); >>\r
-#token "\*/"                           << warn("Missing /*; found dangling */"); zzskip(); >>\r
-#token "//"                                    << zzmode(CPP_COMMENTS); zzskip(); >>\r
-\r
-/* MR14 Arpad Beszedes  26-May-98\r
-        Add support for #line directives when antlr source is pre-processed\r
-        #lexclass START\r
-*/\r
-\r
-#token "#line[\ \t]* [0-9]+ {[\ \t]* \"~[\"]+\" ([\ \t]* [0-9]*)* } (\n|\r|\r\n)"\r
-        <<\r
-        zzline = atoi(zzbegexpr+5) - 1; zzline++; zzmore();\r
-        getFileNameFromTheLineInfo(FileStr[CurFile], zzbegexpr);\r
-        >>\r
-\r
-#token "#line ~[\n\r]* (\n|\r|\r\n)"\r
-        <<\r
-        zzline++; zzmore();\r
-        >>\r
-\r
-/* MR14 end of a block to support #line in antlr source code */\r
-\r
-/*                                                                          */\r
-/*  8-Apr-97   Regularize escape sequence for ">>"                         */\r
-/*                     appearing in string literals                                    */\r
-/*                                                                          */\r
-\r
-#token "\>\>"                  << warn("Missing <<; found dangling \>\>"); zzskip(); >> /* MR1 */\r
-#token WildCard "."\r
-#token "\@"                    <<FoundException = 1;           /* MR6 */\r
-                                 FoundAtOperator = 1;>>        /* MR6 */\r
-#token Eof                                     "@"\r
-                                                       <<      /* L o o k  F o r  A n o t h e r  F i l e */\r
-                                                       {\r
-                                                       FILE *new_input;\r
-                                                       new_input = NextFile();\r
-                                                       if ( new_input == NULL ) { NLA=Eof; return; }\r
-                                                       fclose( input );\r
-                                                       input = new_input;\r
-                                                       zzrdstream( input );\r
-                                                       zzskip();       /* Skip the Eof (@) char i.e continue */\r
-                                                       }\r
-                                                       >>\r
-\r
-#token LABEL\r
-\r
-#errclass "grammar-element" { element }\r
-#errclass "meta-symbol"                { "\}" "!" ";" "\|" "\~" "^" "\)" }\r
-\r
-#token Pragma                  "{\\}#pragma"                   /* MR21 */\r
-#token FirstSetSymbol  "{\\}#FirstSetSymbol"   /* MR21 */\r
-/*\r
- * Get a grammar -- Build a list of rules like:\r
- *\r
- *     o-->Rule1--o\r
- *     |\r
- *     o-->Rule2--o\r
- *     |\r
- *     ...\r
- *     |\r
- *     o-->RuleN--o\r
- */\r
-\r
-/* rule grammar */\r
-\r
-grammar :      <<Graph g;>>\r
-                       (       "{\\}#header" Action    /* MR13 */\r
-                               <<\r
-                               if ( HdrAction==NULL ) {\r
-                               HdrAction = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));\r
-                               require(HdrAction!=NULL, "rule grammar: cannot allocate header action");\r
-                               strcpy(HdrAction, LATEXT(1));\r
-                               }\r
-                               else warn("additional #header statement ignored");\r
-                               >>\r
-            |   "{\\}#first" Action\r
-                               <<\r
-                               if ( FirstAction==NULL ) {\r
-                                       FirstAction = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));\r
-                                       require(FirstAction!=NULL, "rule grammar: cannot allocate #first action");\r
-                                       strcpy(FirstAction, LATEXT(1));\r
-                               } else {\r
-                        warn("additional #first statement ignored");\r
-                    };\r
-                               >>\r
-\r
-                       |       "{\\}#parser" QuotedTerm\r
-                               <<\r
-                               if ( GenCC ) {\r
-                                       warn("#parser meta-op incompatible with -CC; ignored");\r
-                               }\r
-                               else {\r
-                                       if ( strcmp(ParserName,"zzparser")==0 ) {\r
-                                               ParserName=StripQuotes(mystrdup(LATEXT(1)));\r
-                                               if ( RulePrefix[0]!='\0' )\r
-                                               {\r
-                                                       warn("#parser meta-op incompatible with '-gp prefix'; '-gp' ignored");\r
-                                                       RulePrefix[0]='\0';\r
-                                               }\r
-                                       }\r
-                                       else warn("additional #parser statement ignored");\r
-                               }\r
-                               >>\r
-                       |       "{\\}#tokdefs" QuotedTerm\r
-                               <<{\r
-                               char *fname;\r
-                               zzantlr_state st; FILE *f; struct zzdlg_state dst;\r
-                               UserTokenDefsFile = mystrdup(LATEXT(1));\r
-                               zzsave_antlr_state(&st);\r
-                               zzsave_dlg_state(&dst);\r
-                               fname = mystrdup(LATEXT(1));\r
-                               f = fopen(StripQuotes(fname), "r");\r
-                               if ( f==NULL ) {warn(eMsg1("cannot open token defs file '%s'", fname+1));}\r
-                               else {\r
-                                       ANTLRm(enum_file(fname+1), f, PARSE_ENUM_FILE);\r
-                                       UserDefdTokens = 1;\r
-                               }\r
-                               zzrestore_antlr_state(&st);\r
-                               zzrestore_dlg_state(&dst);\r
-                               }>>\r
-                       )*\r
-                       (       Action\r
-                               <<{\r
-                               UserAction *ua = newUserAction(LATEXT(1));\r
-                               ua->file = action_file; ua->line = action_line;\r
-                               if ( class_nest_level>0 ) list_add(&class_before_actions, ua);\r
-                               else list_add(&BeforeActions, ua);\r
-                               }>>\r
-                       |       laction\r
-                       |       lmember                         /* MR1 */\r
-                       |       lprefix                         /* MR1 */\r
-                       |       aLexclass\r
-                       |       token\r
-                       |       error\r
-                       |       tclass\r
-            |   aPred               /* MR11 */\r
-                       |       default_exception_handler\r
-                       |       class_def\r
-                       |       "\}"\r
-                               <<\r
-                               if ( class_nest_level==0 )\r
-                                       warn("missing class definition for trailing '}'");\r
-                               class_nest_level--;\r
-                               >>\r
-                       )*\r
-            \r
-                       rule            <<g=$3; SynDiag = (Junction *) $3.left;>>\r
-                       (       rule\r
-\r
-                       <<if ( $1.left!=NULL ) {\r
-                        g.right = NULL;\r
-\r
-/* MR21a */             /*  Avoid use of a malformed graph when CannotContinue */\r
-/* MR21a */             /*  is already set                                     */\r
-/* MR21a */\r
-/* MR21a */             if (! (CannotContinue && g.left == NULL)) {\r
-/* MR21a */               g = Or(g, $1);\r
-/* MR21a */             }\r
-/* MR21a */                  }\r
-                    >>\r
-\r
-                       |       aLexclass\r
-                       |       token\r
-                       |       error\r
-                       |       tclass\r
-            |   aPred               /* MR11 */\r
-                       |       class_def\r
-                       |       "\}"\r
-                               <<\r
-                               if ( class_nest_level==0 )\r
-                                       warn("missing class definition for trailing '}'");\r
-                               class_nest_level--;\r
-                               >>\r
-                       )*\r
-                       (       Action\r
-                               <<{\r
-                               UserAction *ua = newUserAction(LATEXT(1));\r
-                               ua->file = action_file; ua->line = action_line;\r
-                               if ( class_nest_level>0 ) list_add(&class_after_actions, ua);\r
-                               else list_add(&AfterActions, ua);\r
-                               }>>\r
-                       |       laction\r
-                       |       lmember                         /* MR1 */\r
-                       |       lprefix                         /* MR1 */\r
-                       |       error\r
-                       |       tclass\r
-                       |       class_def\r
-            |   aPred               /* MR11 */\r
-                       |       "\}"\r
-                               <<\r
-                               if ( class_nest_level==0 )\r
-                                       warn("missing class definition for trailing '}'");\r
-                               class_nest_level--;\r
-                               >>\r
-                       )*\r
-                       Eof\r
-               ;\r
-               <<CannotContinue=TRUE;>>\r
-\r
-/* rule class_def */\r
-\r
-class_def\r
-       :       <<int go=1; char name[MaxRuleName+1];>>\r
-               "class"\r
-               (       NonTerminal             <<if(go) strncpy(name,LATEXT(1),MaxRuleName);>>\r
-               |       TokenTerm               <<if(go) strncpy(name,LATEXT(1),MaxRuleName);>>\r
-               )\r
-               <<\r
-               if ( CurrentClassName[0]!='\0' && strcmp(CurrentClassName,name)!=0\r
-                        && GenCC ) {\r
-                       err("only one grammar class allowed in this release");\r
-                       go = 0;\r
-               }\r
-               else strcpy(CurrentClassName, name);\r
-               >>\r
-               <<if ( !GenCC ) { err("class meta-op used without C++ option"); }>>\r
-\r
-/* MR10 */  (~ "\{"\r
-/* MR10 */            <<if (ClassDeclStuff == NULL) {\r
-/* MR10 */                   ClassDeclStuff=(char *)calloc(MaxClassDeclStuff+1,sizeof(char));\r
-/* MR10 */              };\r
-/* MR10 */              strncat(ClassDeclStuff," ",MaxClassDeclStuff);\r
-/* MR10 */              strncat(ClassDeclStuff,LATEXT(1),MaxClassDeclStuff);\r
-/* MR22 */              do {\r
-/* MR22 */                if (0 == strcmp(LATEXT(1),"public")) break;\r
-/* MR22 */                if (0 == strcmp(LATEXT(1),"private")) break;\r
-/* MR22 */                if (0 == strcmp(LATEXT(1),"protected")) break;\r
-/* MR22 */                if (0 == strcmp(LATEXT(1),"virtual")) break;\r
-/* MR22 */                if (0 == strcmp(LATEXT(1),",")) break;\r
-/* MR22 */                if (0 == strcmp(LATEXT(1),":")) break;\r
-/* MR22 */                if (BaseClassName != NULL) break;\r
-/* MR22 */                BaseClassName=(char *)calloc(strlen(LATEXT(1))+1,sizeof(char));\r
-/* MR22 */                require(BaseClassName!=NULL, "rule grammar: cannot allocate base class name");\r
-/* MR22 */                               strcpy(BaseClassName,LATEXT(1));\r
-/* MR22 */              } while (0);\r
-/* MR10 */            >>\r
-/* MR10 */  )*\r
-\r
-               "\{"\r
-               <<\r
-               no_classes_found = 0;\r
-               if ( class_nest_level>=1 ) {warn("cannot have nested classes");}\r
-               else class_nest_level++;\r
-               >>\r
-       ;\r
-       <<CannotContinue=TRUE;>>\r
-\r
-/*\r
- * Build -o-->o-R-o-->o-       where -o-R-o- is the block from rule 'block'.\r
- * Construct the RuleBlk front and EndRule node on the end of the\r
- * block.  This is used to add FOLLOW pointers to the rule end.  Add the\r
- * new rule name to the Rname hash table and sets its rulenum.\r
- * Store the parameter definitions if any are found.\r
- *\r
- * Note that locks are required on the RuleBlk and EndRule nodes to thwart\r
- * infinite recursion.\r
- *\r
- * Return the left graph pointer == NULL to indicate error/dupl rule def.\r
- */\r
-\r
-/* rule rule */\r
-\r
-rule   :       <<\r
-\r
-                       ExceptionGroup *eg;\r
-                       RuleEntry *q; Junction *p; Graph r; int f, l; ECnode *e;\r
-                       set toksrefd, rulesrefd;\r
-                       char *pdecl=NULL, *ret=NULL, *a; CurRetDef = CurParmDef = NULL;\r
-                       CurExGroups = NULL;\r
-                       CurElementLabels = NULL;\r
-                       CurAstLabelsInActions = NULL; /* MR27 */\r
-                       /* We want a new element label hash table for each rule */\r
-                       if ( Elabel!=NULL ) killHashTable(Elabel);\r
-                       Elabel = newHashTable();\r
-                       attribsRefdFromAction = empty;\r
-                       >>\r
-                       NonTerminal\r
-                       <<q=NULL;\r
-                         if ( hash_get(Rname, LATEXT(1))!=NULL ) {\r
-                                 err(eMsg1("duplicate rule definition: '%s'",LATEXT(1)));\r
-                                 CannotContinue=TRUE;\r
-                         }\r
-                         else\r
-                         {\r
-                                 q = (RuleEntry *)hash_add(Rname,\r
-                                                                                       LATEXT(1),\r
-                                                                                       (Entry *)newRuleEntry(LATEXT(1)));\r
-                             CurRule = q->str;\r
-                         }\r
-                         CurRuleNode = q;\r
-                         f = CurFile; l = zzline;\r
-                         NumRules++;\r
-                       >>\r
-                       {       "!"  <<if ( q!=NULL ) q->noAST = TRUE;>> }\r
-                       {       <<;>>\r
-                               {"\<"}\r
-                               PassAction\r
-                               <<      pdecl = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));\r
-                                       require(pdecl!=NULL, "rule rule: cannot allocate param decl");\r
-                                       strcpy(pdecl, LATEXT(1));\r
-                                       CurParmDef = pdecl;\r
-                               >>\r
-                       }\r
-                       {       "\>"\r
-                               PassAction\r
-                               <<      ret = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));\r
-                                   require(ret!=NULL, "rule rule: cannot allocate ret type");\r
-                                       strcpy(ret, LATEXT(1));\r
-                                       CurRetDef = ret;\r
-                               >>\r
-                       }\r
-                       { QuotedTerm <<if ( q!=NULL ) q->egroup=mystrdup(LATEXT(1));>> }\r
-                       <<\r
-                       if ( GenEClasseForRules && q!=NULL ) {\r
-                               e = newECnode;\r
-                               require(e!=NULL, "cannot allocate error class node");\r
-                               if ( q->egroup == NULL ) {a = q->str; a[0] = (char)toupper(a[0]);}\r
-                               else a = q->egroup;\r
-                               if ( Tnum( a ) == 0 )\r
-                               {\r
-                                       e->tok = addTname( a );\r
-                                       list_add(&eclasses, (char *)e);\r
-                                       if ( q->egroup == NULL ) a[0] = (char)tolower(a[0]);\r
-                                       /* refers to itself */\r
-                                       list_add(&(e->elist), mystrdup(q->str));\r
-                               }\r
-                               else {\r
-                                       warn(eMsg1("default errclass for '%s' would conflict with token/errclass/tokclass",a));\r
-                                       if ( q->egroup == NULL ) a[0] = (char)tolower(a[0]);\r
-                                       free((char *)e);\r
-                               }\r
-                       }\r
-                       >>\r
-                       <<BlkLevel++;\r
-              if (BlkLevel >= MAX_BLK_LEVEL) fatal("Blocks nested too deeply");\r
-/* MR23 */    CurBlockID_array[BlkLevel] = CurBlockID;\r
-/* MR23 */    CurAltNum_array[BlkLevel] = CurAltNum;                \r
-            >>\r
-\r
-                       ":" <<inAlt=1;>>\r
-                       block[&toksrefd, &rulesrefd]\r
-                       <<r = makeBlk($7,0, NULL /* pFirstSetSymbol */ );\r
-                         CurRuleBlk = (Junction *)r.left;\r
-                         CurRuleBlk->blockid = CurBlockID;\r
-                         CurRuleBlk->jtype = RuleBlk;\r
-                         if ( q!=NULL ) CurRuleBlk->rname = q->str;\r
-                         CurRuleBlk->file = f;\r
-                         CurRuleBlk->line = l;\r
-                         CurRuleBlk->pdecl = pdecl;\r
-                         CurRuleBlk->ret = ret;\r
-                         CurRuleBlk->lock = makelocks();\r
-                         CurRuleBlk->pred_lock = makelocks();\r
-                         CurRuleBlk->tokrefs = toksrefd;\r
-                         CurRuleBlk->rulerefs = rulesrefd;\r
-                         p = newJunction();    /* add EndRule Node */\r
-                         ((Junction *)r.right)->p1 = (Node *)p;\r
-                         r.right = (Node *) p;\r
-                         p->jtype = EndRule;\r
-                         p->lock = makelocks();\r
-                         p->pred_lock = makelocks();\r
-                         CurRuleBlk->end = p;\r
-                         if ( q!=NULL ) q->rulenum = NumRules;\r
-                         $7 = r;\r
-                       >>\r
-                       <<\r
-                /* MR23 */      CurBlockID_array[BlkLevel] = (-1);\r
-                /* MR23 */      CurAltNum_array[BlkLevel] = (-1);                \r
-                --BlkLevel;\r
-            >>\r
-            <<altFixup();leFixup();egFixup();>>                      /* MR7 */\r
-                       ";" <<inAlt=0;>>\r
-                       {       Action\r
-                               <<      a = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));\r
-                                       require(a!=NULL, "rule rule: cannot allocate error action");\r
-                                       strcpy(a, LATEXT(1));\r
-                                       CurRuleBlk->erraction = a;\r
-                               >>\r
-                       }\r
-                       (       exception_group > [eg]\r
-                               <<if ( eg!=NULL ) {\r
-                                       list_add(&CurExGroups, (void *)eg);\r
-                                       if (eg->label == NULL || *eg->label=='\0' ) q->has_rule_exception = 1;\r
-                           }\r
-                               >>\r
-                       )*\r
-                       <<if ( q==NULL ) $0.left = NULL; else $0 = $7;>>\r
-                       <<CurRuleBlk->exceptions = CurExGroups;>>\r
-                       <<CurRuleBlk->el_labels = CurElementLabels;>>\r
-                       <<CurRuleNode->ast_labels_in_actions = CurAstLabelsInActions;>> /* MR27 */\r
-                       <<CurRuleNode = NULL;>> /* MR27 Moved */\r
-               ;\r
-               <<CannotContinue=TRUE;>>\r
-\r
-/*\r
- * pragma      :       "{\\}#pragma" "dup\-labeled\-tokens"\r
- *                     <<Pragma_DupLabeledTokens=1;>>\r
- *             ;\r
- */\r
-\r
-/* rule laction */\r
-\r
-laction        :       <<char *a;>>\r
-\r
-                       "{\\}#lexaction"\r
-                       Action\r
-                       <<\r
-                       a = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));\r
-                       require(a!=NULL, "rule laction: cannot allocate action");\r
-                       strcpy(a, LATEXT(1));\r
-                       list_add(&LexActions, a);\r
-                       >>\r
-               ;\r
-               <<CannotContinue=TRUE;>>\r
-\r
-/* MR1                                                                     */\r
-/* MR1  11-Apr-97      Provide mechanism for inserting code into DLG class */\r
-/* MR1                   via #lexmember <<....>> & #lexprefix <<...>>      */\r
-/* MR1                                                                     */\r
-\r
-/* rule lmember */\r
-\r
-lmember:       <<char *a;>>                                         /* MR1 */\r
-\r
-/* MR1 */              "{\\}#lexmember"\r
-/* MR1 */              Action\r
-/* MR1 */              <<\r
-/* MR1 */              if (! GenCC) {\r
-/* MR1 */                err("Use #lexmember only in C++ mode (to insert code in DLG class header");\r
-/* MR1 */              } else {\r
-/* MR1 */                a = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));\r
-/* MR1 */                require(a!=NULL, "rule lmember: cannot allocate action");\r
-/* MR1 */                strcpy(a, LATEXT(1));\r
-/* MR1 */                list_add(&LexMemberActions, a);\r
-/* MR1 */              };\r
-/* MR1 */              >>\r
-/* MR1 */      ;\r
-/* MR1 */      <<CannotContinue=TRUE;>>\r
-\r
-/* rule lprefix */\r
-\r
-lprefix:       <<char *a;>>                                         /* MR1 */\r
-\r
-/* MR1 */              "{\\}#lexprefix"\r
-/* MR1 */              Action\r
-/* MR1 */              <<\r
-/* MR1 */              if (! GenCC) {\r
-/* MR1 */                err("Use #lexprefix only in C++ mode (to insert code in DLG class header");\r
-/* MR1 */              } else {\r
-/* MR1 */                a = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));\r
-/* MR1 */                require(a!=NULL, "rule lprefix: cannot allocate action");\r
-/* MR1 */                strcpy(a, LATEXT(1));\r
-/* MR1 */                list_add(&LexPrefixActions, a);\r
-/* MR1 */              };\r
-/* MR1 */              >>\r
-/* MR1 */      ;\r
-/* MR1 */      <<CannotContinue=TRUE;>>\r
-\r
-/*\r
- * #pred upper        <<isupper()>>?            predicate literal\r
- * #pred lower        <<islower()>>?            predicate literal\r
- * #pred up_or_low    upper || lower            predicate expression\r
- *                                                concealed interdependence\r
- * #pred up_or_low_2  <<isletter()>>?  A || B   predicate literal equals predicate expr\r
- *                                                analyze using lower||upper\r
- *                                                generate using isLetter()\r
- */\r
-\r
-/* rule aPref */\r
-\r
-aPred:  <<PredEntry     *predEntry=NULL;\r
-          char          *name=NULL;\r
-          Predicate     *predExpr=NULL;\r
-          char          *predLiteral=NULL;\r
-          int           save_file;\r
-          int           save_line;\r
-          int           predExprPresent=0;\r
-        >>\r
-\r
-        "{\\}#pred"\r
-\r
-        <<\r
-          MR_usingPredNames=1;      /* will need to use -mrhoist version of genPredTree */\r
-        >>\r
-\r
-                                    /* used to allow NonTerminal but it caused problems\r
-                                       when a rule name immediately followed a #pred statement */\r
-\r
-        TokenTerm     <<name=mystrdup(LATEXT(1));>>\r
-\r
-          <<\r
-            /* don't free - referenced in predicates */\r
-\r
-            CurPredName=(char *)calloc(1,strlen(name) + 10);\r
-            strcat(CurPredName,"#pred ");\r
-            strcat(CurPredName,name);\r
-\r
-            predEntry=(PredEntry *) hash_get(Pname,name);\r
-            if (predEntry != NULL) {\r
-              warnFL(eMsg1("#pred %s previously defined - ignored",name),\r
-                                              FileStr[action_file],action_line);\r
-              name=NULL;\r
-            };\r
-          >>\r
-\r
-        (\r
-\r
-            Pred    <<predLiteral=mystrdup(LATEXT(1));\r
-                      save_line=action_line;\r
-                      save_file=action_file;\r
-                    >>\r
-\r
-              {\r
-                    predOrExpr>[predExpr]   <<predExprPresent=1;>>\r
-              }\r
-\r
-              <<if (predLiteral != NULL && name != NULL) {\r
-\r
-                      /*\r
-                       *  predExpr may be NULL due to syntax errors\r
-                       *    or simply omitted by the user\r
-                      */\r
-\r
-                      predEntry=newPredEntry(name);\r
-                      predEntry->file=save_file;\r
-                      predEntry->line=save_line;\r
-                      predExpr=MR_predFlatten(predExpr);\r
-                      predEntry->predLiteral=predLiteral;\r
-                      if (! predExprPresent || predExpr == NULL) {\r
-                        predExpr=new_pred();\r
-                        predExpr->expr=predLiteral;\r
-                        predExpr->source=newActionNode();\r
-                        predExpr->source->action=predExpr->expr;\r
-                        predExpr->source->rname=CurPredName;\r
-                        predExpr->source->line=action_line;\r
-                        predExpr->source->file=action_file;\r
-                        predExpr->source->is_predicate=1;\r
-                        predExpr->k=predicateLookaheadDepth(predExpr->source);\r
-                      };\r
-                      predEntry->pred=predExpr;\r
-                      hash_add(Pname,name,(Entry *)predEntry);\r
-                      predExpr=NULL;\r
-                };\r
-                predicate_free(predExpr);\r
-              >>\r
-\r
-            |\r
-               <<save_line=zzline; save_file=CurFile;>>\r
-\r
-                predOrExpr>[predExpr]\r
-\r
-              <<if (predExpr != NULL && name != NULL) {\r
-                  predEntry=newPredEntry(name);\r
-                  predEntry->file=CurFile;\r
-                  predEntry->line=zzline;\r
-                  predExpr=MR_predFlatten(predExpr);\r
-                  predEntry->pred=predExpr;\r
-                  hash_add(Pname,name,(Entry *)predEntry);\r
-                  predExpr=NULL;\r
-                };\r
-                predicate_free(predExpr);\r
-              >>\r
-        )\r
-        {";"}\r
-;\r
-\r
-/* fail */\r
-\r
-<<predicate_free(predExpr);\r
->>\r
-\r
-/* rule predOrExpr */\r
-\r
-predOrExpr>[Predicate *result] :\r
-            <<Predicate     *ORnode;\r
-              Predicate     *predExpr;\r
-              Predicate     **tail=NULL;\r
-            >>\r
-        predAndExpr>[predExpr]\r
-            <<\r
-                ORnode=new_pred();\r
-                ORnode->expr=PRED_OR_LIST;\r
-                if (predExpr != NULL) {\r
-                    ORnode->down=predExpr;\r
-                    tail=&predExpr->right;\r
-                };\r
-            >>\r
-        ( "\|\|"  predAndExpr>[predExpr]\r
-            <<\r
-                if (predExpr != NULL) {\r
-                    *tail=predExpr;\r
-                    tail=&predExpr->right;\r
-                };\r
-            >>\r
-        )*\r
-        <<\r
-            $result=ORnode;\r
-            ORnode=NULL;\r
-        >>\r
-;\r
-\r
-/* fail */\r
-\r
-<<predicate_free(ORnode);>>\r
-\r
-/* rule predAndExpr */\r
-\r
-predAndExpr>[Predicate *result] :\r
-            <<Predicate     *ANDnode;\r
-              Predicate     *predExpr;\r
-              Predicate     **tail=NULL;\r
-            >>\r
-        predPrimary>[predExpr]\r
-            <<\r
-                ANDnode=new_pred();\r
-                ANDnode->expr=PRED_AND_LIST;\r
-                if (predExpr != NULL) {\r
-                    ANDnode->down=predExpr;\r
-                    tail=&predExpr->right;\r
-                };\r
-            >>\r
-        ( "&&"  predPrimary>[predExpr]\r
-            <<\r
-                if (predExpr != NULL) {\r
-                    *tail=predExpr;\r
-                    tail=&predExpr->right;\r
-                };\r
-            >>\r
-        )*\r
-        <<\r
-            $result=ANDnode;\r
-            ANDnode=NULL;\r
-        >>\r
-;\r
-\r
-/* fail */\r
-\r
-<<predicate_free(ANDnode);>>\r
-\r
-\r
-/* rule predPrimary */\r
-\r
-predPrimary>[Predicate *result] :\r
-            <<\r
-              char          *name=NULL;\r
-              PredEntry     *predEntry=NULL;\r
-              Predicate     *predExpr=NULL;\r
-            >>\r
-\r
-        TokenTerm            <<name=mystrdup(LATEXT(1));>>\r
-\r
-            <<\r
-                predEntry=(PredEntry *) hash_get(Pname,name);\r
-                if (predEntry == NULL) {\r
-                  warnFL(eMsg1("no previously defined #pred with name \"%s\"",name),\r
-                        FileStr[CurFile],zzline);\r
-                  name=NULL;\r
-                  $result=NULL;\r
-                } else {\r
-                  predExpr=predicate_dup(predEntry->pred);\r
-                  predExpr->predEntry=predEntry;\r
-                  $result=predExpr;\r
-                };\r
-            >>\r
-\r
-        | "\(" predOrExpr>[predExpr] "\)"\r
-            <<\r
-                $result=predExpr;\r
-            >>\r
-\r
-        | "!" predPrimary>[predExpr]\r
-            <<\r
-                predExpr->inverted=!predExpr->inverted;\r
-                $result=predExpr;\r
-            >>\r
-;\r
-\r
-/* fail */  <<\r
-              predicate_free(predExpr);\r
-            >>\r
-\r
-/* rule aLexclass */\r
-\r
-aLexclass:     "{\\}#lexclass" TokenTerm <<lexclass(mystrdup(LATEXT(1)));>>\r
-               ;\r
-               <<CannotContinue=TRUE;>>\r
-\r
-/* rule error */\r
-\r
-error  :       <<char *t=NULL; ECnode *e; int go=1; TermEntry *p;>>\r
-                       "{\\}#errclass"\r
-                       (<<;>>  TokenTerm  <<t=mystrdup(LATEXT(1));>>\r
-                       |               QuotedTerm <<t=mystrdup(LATEXT(1));>>\r
-                       )\r
-                       <<e = newECnode;\r
-                         require(e!=NULL, "cannot allocate error class node");\r
-                         e->lexclass = CurrentLexClass;\r
-                         if ( Tnum( (t=StripQuotes(t)) ) == 0 )\r
-                         {\r
-                               if ( hash_get(Texpr, t) != NULL )\r
-                                       warn(eMsg1("errclass name conflicts with regular expression  '%s'",t));\r
-                               e->tok = addTname( t );\r
-                               set_orel(e->tok, &imag_tokens);\r
-                               require((p=(TermEntry *)hash_get(Tname, t)) != NULL,\r
-                                               "hash table mechanism is broken");\r
-                               p->classname = 1;       /* entry is errclass name, not token */\r
-                               list_add(&eclasses, (char *)e);\r
-                         }\r
-                         else\r
-                         {\r
-                               warn(eMsg1("redefinition of errclass or conflict w/token or tokclass '%s'; ignored",t));\r
-                               free( (char *)e );\r
-                               go=0;\r
-                         }\r
-                       >>\r
-                       "\{"\r
-                               ( NonTerminal <<if ( go ) t=mystrdup(LATEXT(1));>>\r
-                               | TokenTerm <<if ( go ) t=mystrdup(LATEXT(1));>>\r
-                               | QuotedTerm <<if ( go ) t=mystrdup(LATEXT(1));>>\r
-                               )\r
-                               <<if ( go ) list_add(&(e->elist), t);>>\r
-                               (\r
-                                       ( NonTerminal <<if ( go ) t=mystrdup(LATEXT(1));>>\r
-                                       | TokenTerm <<if ( go ) t=mystrdup(LATEXT(1));>>\r
-                                       | QuotedTerm <<if ( go ) t=mystrdup(LATEXT(1));>>\r
-                                       )\r
-                                       <<if ( go ) list_add(&(e->elist), t);>>\r
-                               )*\r
-                       "\}"\r
-               ;\r
-               <<CannotContinue=TRUE;>>\r
-\r
-/* rule tclass */\r
-\r
-tclass :       <<char *t=NULL; TCnode *e; int go=1,tok,totok; TermEntry *p, *term, *toterm;>>\r
-            <<char *akaString=NULL; int save_file; int save_line;>>\r
-            <<char *totext=NULL; >>\r
-                       "{\\}#tokclass" TokenTerm <<t=mystrdup(LATEXT(1));>>\r
-                       <<e = newTCnode;\r
-                         require(e!=NULL, "cannot allocate token class node");\r
-                         e->lexclass = CurrentLexClass;\r
-                         if ( Tnum( t ) == 0 )\r
-                         {\r
-                               e->tok = addTname( t );\r
-                               set_orel(e->tok, &imag_tokens);\r
-                               set_orel(e->tok, &tokclasses);\r
-                               require((p=(TermEntry *)hash_get(Tname, t)) != NULL,\r
-                                               "hash table mechanism is broken");\r
-                               p->classname = 1;       /* entry is class name, not token */\r
-                               p->tclass = e;          /* save ptr to this tclass def */\r
-                               list_add(&tclasses, (char *)e);\r
-                         }\r
-                         else\r
-                         {\r
-                               warn(eMsg1("redefinition of tokclass or conflict w/token '%s'; ignored",t));\r
-                               free( (char *)e );\r
-                               go=0;\r
-                         }\r
-                       >>\r
-/* MR23 */      {\r
-/* MR23 */          "\("\r
-/* MR23 */          QuotedTerm\r
-/* MR23 */                 <<akaString=mystrdup(StripQuotes(LATEXT(1)));\r
-/* MR11 */                   save_file=CurFile;save_line=zzline;\r
-/* MR23 */                 >>\r
-/* MR23 */          "\)"\r
-/* MR23 */      }\r
-/* MR23 */\r
-/* MR23 */\r
-/* MR23 */             <<\r
-/* MR23 */         if (p!= NULL && akaString != NULL) {\r
-/* MR23 */           if (p->akaString != NULL) {\r
-/* MR23 */             if (strcmp(p->akaString,akaString) != 0) {\r
-/* MR23 */                warnFL(eMsg2("this #tokclass statment conflicts with a previous #tokclass %s(\"%s\") statement",\r
-/* MR23 */                              t,p->akaString),\r
-/* MR23 */                                         FileStr[save_file],save_line);\r
-/* MR23 */             };\r
-/* MR23 */            } else {\r
-/* MR23 */              p->akaString=akaString;\r
-/* MR23 */            };\r
-/* MR23 */          };\r
-/* MR23 */             >>\r
-\r
-                       "\{"\r
-                               (\r
-                               ( TokenTerm\r
-                                 <<if ( go ) {\r
-                                       term = (TermEntry *) hash_get(Tname, LATEXT(1));\r
-                                       if ( term==NULL && UserDefdTokens ) {\r
-                                               err("implicit token definition not allowed with #tokdefs");\r
-                                               go = 0;\r
-                                       }\r
-                                       else {t=mystrdup(LATEXT(1)); tok=addTname(LATEXT(1));}\r
-                                       }>>\r
-\r
-                        {\r
-                            ".."\r
-                            TokenTerm\r
-\r
-                                         <<if ( go ) {\r
-                                                       toterm = (TermEntry *) hash_get(Tname, LATEXT(1));\r
-                                                       if ( toterm==NULL && UserDefdTokens ) {\r
-                                                               err("implicit token definition not allowed with #tokdefs");\r
-                                                               go = 0;\r
-                                                       } else {\r
-                                        totext=mystrdup(LATEXT(1)); totok=addTname(LATEXT(1));\r
-                                    }\r
-                                           }\r
-                              >>\r
-                        }\r
-\r
-                               | QuotedTerm\r
-                                 <<if ( go ) {\r
-                                       term = (TermEntry *) hash_get(Texpr, LATEXT(1));\r
-                                       if ( term==NULL && UserDefdTokens ) {\r
-                                               err("implicit token definition not allowed with #tokdefs");\r
-                                               go = 0;\r
-                                               }\r
-                                       else {t=mystrdup(LATEXT(1)); tok=addTexpr(LATEXT(1));}\r
-                                       }>>\r
-                               )\r
-                               <<if ( go ) {\r
-                        if (totext == NULL) {\r
-                            list_add(&(e->tlist), t);\r
-                        } else {\r
-                            list_add(&(e->tlist),"..");\r
-                            list_add(&(e->tlist),t);\r
-                            list_add(&(e->tlist),totext);\r
-                        }\r
-                        totext=NULL;\r
-                      }\r
-                    >>\r
-                               )+  // MR15 Manfred Kogler - forbid empty #tokclass sets (was "+")\r
-                       "\}"\r
-               ;\r
-               <<CannotContinue=TRUE;>>\r
-\r
-/* rule token */\r
-\r
-token  :       <<char *t=NULL, *e=NULL, *a=NULL; int tnum=0;>>\r
-            <<char *akaString=NULL; TermEntry *te;int save_file=0,save_line=0;>>           /* MR11 */\r
-                       "{\\}#token"\r
-\r
-/* MR1 10-Apr-97 MR1 Allow shift right operator in DLG actions            */\r
-/* MR1                 Danger when parser feedback to lexer                       */\r
-/* MR1                                                                */\r
-\r
-                       <<tokenActionActive=1;>>                                    /* MR1 */\r
-                       {       TokenTerm  <<t=mystrdup(LATEXT(1));>>\r
-\r
-/* MR11 */      {\r
-/* MR11 */          "\("\r
-/* MR11 */          QuotedTerm\r
-/* MR11 */                 <<akaString=mystrdup(StripQuotes(LATEXT(1)));\r
-/* MR11 */                   save_file=CurFile;save_line=zzline;\r
-/* MR11 */                 >>\r
-/* MR11 */          "\)"\r
-/* MR11 */      }\r
-\r
-                               {       "=" "[0-9]+"            /* define the token type number */\r
-                                       <<tnum = atoi(LATEXT(1));>>\r
-                               }\r
-                       }\r
-                       { QuotedTerm <<e=mystrdup(LATEXT(1));>> }\r
-                       {       Action\r
-                               <<\r
-                                       a = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));\r
-                                       require(a!=NULL, "rule token: cannot allocate action");\r
-                                       strcpy(a, LATEXT(1));\r
-                               >>\r
-                       }\r
-\r
-            { ";" }     /* MR11 */\r
-\r
-                       <<chkToken(t, e, a, tnum);>>\r
-\r
-            <<if (t != NULL) {\r
-                te=(TermEntry *)hash_get(Tname,t);\r
-                if (te != NULL && akaString != NULL) {\r
-                  if (te->akaString != NULL) {\r
-                    if (strcmp(te->akaString,akaString) != 0) {\r
-                      warnFL(eMsg2("this #token statment conflicts with a previous #token %s(\"%s\") statement",\r
-                                    t,te->akaString),\r
-                        FileStr[save_file],save_line);\r
-                    };\r
-                  } else {\r
-                    te->akaString=akaString;\r
-                  };\r
-                };\r
-              };\r
-            >>\r
-               ;\r
-               <<CannotContinue=TRUE;>>\r
-\r
-/* rule block */\r
-\r
-block[set *toksrefd, set *rulesrefd]\r
-               :       <<\r
-                       Graph g, b;\r
-                       set saveblah;\r
-                       int saveinalt = inAlt;\r
-                       ExceptionGroup *eg;\r
-                       *$toksrefd = empty;\r
-                       *$rulesrefd = empty;\r
-                       set_clr(AST_nodes_refd_in_actions);\r
-                       CurBlockID++;\r
-/* MR23 */      CurBlockID_array[BlkLevel] = CurBlockID;\r
-                       CurAltNum = 1;\r
-/* MR23 */      CurAltNum_array[BlkLevel] = CurAltNum;                \r
-                       saveblah = attribsRefdFromAction;\r
-                       attribsRefdFromAction = empty;\r
-                       >>\r
-\r
-                       alt[toksrefd,rulesrefd]         <<b = g = $1;>>\r
-\r
-                       <<\r
-                       if ( ((Junction *)g.left)->p1->ntype == nAction )\r
-                       {\r
-                ActionNode *actionNode=(ActionNode *)\r
-                                         ( ( (Junction *)g.left) ->p1);\r
-                               if (!actionNode->is_predicate )\r
-                               {\r
-                                       actionNode->init_action = TRUE;\r
-/* MR12c */            if (actionNode->noHoist) {\r
-/* MR12c */           errFL("<<nohoist>> appears as init-action - use <<>> <<nohoist>>",\r
-/* MR12c */                       FileStr[actionNode->file],actionNode->line);\r
-/* MR12c */         };\r
-                               }\r
-                       }\r
-                       ((Junction *)g.left)->blockid = CurBlockID;\r
-                       >>\r
-\r
-                       (       exception_group > [eg]\r
-                               <<\r
-                               if ( eg!=NULL ) {\r
-/* MR7 *****           eg->altID = makeAltID(CurBlockID,CurAltNum);        *****/\r
-/* MR7 *****           CurAltStart->exception_label = eg->altID;           *****/\r
-                                       list_add(&CurExGroups, (void *)eg);\r
-                               }\r
-                               >>\r
-                       )*\r
-                       <<CurAltNum++;\r
-/* MR23 */    CurAltNum_array[BlkLevel] = CurAltNum;\r
-            >>\r
-\r
-                       (       "\|" <<inAlt=1;>>\r
-                               alt[toksrefd,rulesrefd]         <<g = Or(g, $2);>>\r
-                               <<\r
-                               ((Junction *)g.left)->blockid = CurBlockID;\r
-                               >>\r
-\r
-                               (       exception_group > [eg]\r
-                                       <<\r
-                                       if ( eg!=NULL ) {\r
-/* MR7 *****           eg->altID = makeAltID(CurBlockID,CurAltNum);        *****/\r
-/* MR7 *****           CurAltStart->exception_label = eg->altID;           *****/\r
-                                               list_add(&CurExGroups, (void *)eg);\r
-                                       }\r
-                                       >>\r
-                               )*\r
-\r
-                               <<CurAltNum++;\r
-/* MR23 */        CurAltNum_array[BlkLevel] = CurAltNum;                \r
-                >>\r
-\r
-                       )*\r
-                       <<$0 = b;>>\r
-                       <<attribsRefdFromAction = saveblah; inAlt = saveinalt;>>\r
-               ;\r
-               <<CannotContinue=TRUE;>>\r
-\r
-/* rule alt */\r
-\r
-alt[set *toksrefd, set *rulesrefd]\r
-               :       <<int n=0; Graph g; int e_num=0, old_not=0; Node *node; set elems, dif;\r
-                       int first_on_line = 1, use_def_MT_handler = 0;\r
-                       g.left=NULL; g.right=NULL;\r
-\r
-                       CurAltStart = NULL;\r
-                       elems = empty;\r
-                       inAlt = 1;\r
-                       >>\r
-                       {       "\@"    /* handle MismatchedToken signals with default handler */\r
-                               <<use_def_MT_handler = 1;>>\r
-                       }\r
-\r
-                       (       <<;>>       /* MR9 Removed unreferenced variable "tok" */\r
-                               { <<old_not=0;>> "\~" <<old_not=1;>> }\r
-                               element[old_not, first_on_line, use_def_MT_handler] > [node]\r
-                               <<if ( node!=NULL && node->ntype!=nAction ) first_on_line = 0;>>\r
-                               <<\r
-                               if ( $2.left!=NULL ) {\r
-                                       g = Cat(g, $2);\r
-                                       n++;\r
-                                       if ( node!=NULL ) {\r
-                                               if ( node->ntype!=nAction ) e_num++;\r
-                                               /* record record number of all rule and token refs */\r
-                                               if ( node->ntype==nToken ) {\r
-                                                       TokNode *tk = (TokNode *)((Junction *)$2.left)->p1;\r
-                                                       tk->elnum = e_num;\r
-                                                       set_orel(e_num, &elems);\r
-                                               }\r
-                                               else if ( node->ntype==nRuleRef ) {\r
-                                                       RuleRefNode *rn = (RuleRefNode *)((Junction *)$2.left)->p1;\r
-                                                       rn->elnum = e_num;\r
-                                                       set_orel(e_num, $rulesrefd);\r
-                                               }\r
-                                       }\r
-                               }\r
-                               >>\r
-                       )*\r
-                       <<if ( n == 0 ) g = emptyAlt();\r
-                         $0 = g;\r
-                         /* We want to reduce number of LT(i) calls and the number of\r
-                          * local attribute variables in C++ mode (for moment, later we'll\r
-                          * do for C also).  However, if trees are being built, they\r
-                          * require most of the attrib variables to create the tree nodes\r
-                          * with; therefore, we gen a token ptr for each token ref in C++\r
-                          */\r
-                         if ( GenCC && !GenAST )\r
-                         {\r
-                                 /* This now free's the temp set -ATG 5/6/95 */\r
-                                 set temp;\r
-                                 temp = set_and(elems, attribsRefdFromAction);\r
-                                 set_orin($toksrefd, temp);\r
-                                 set_free(temp);\r
-                         }\r
-                         else set_orin($toksrefd, elems);\r
-                         if ( GenCC ) {\r
-                               dif = set_dif(attribsRefdFromAction, elems);\r
-                               if ( set_deg(dif)>0 )\r
-                                       err("one or more $i in action(s) refer to non-token elements");\r
-                               set_free(dif);\r
-                         }\r
-                         set_free(elems);\r
-                         set_free(attribsRefdFromAction);\r
-                         inAlt = 0;\r
-                       >>\r
-               ;\r
-               <<CannotContinue=TRUE;>>\r
-\r
-/* rule element_label */\r
-\r
-element_label > [LabelEntry *label]\r
-       :       <<TermEntry *t=NULL; LabelEntry *l=NULL; RuleEntry *r=NULL; char *lab;>>\r
-               LABEL   <<lab = mystrdup(LATEXT(1));>>\r
-               <<\r
-               UsedNewStyleLabel = 1;\r
-               if ( UsedOldStyleAttrib ) err("cannot mix with new-style labels with old-style $i");\r
-               t = (TermEntry *) hash_get(Tname, lab);\r
-               if ( t==NULL ) t = (TermEntry *) hash_get(Texpr, lab);\r
-               if ( t==NULL ) r = (RuleEntry *) hash_get(Rname, lab);\r
-               if ( t!=NULL ) {\r
-                       err(eMsg1("label definition clashes with token/tokclass definition: '%s'", lab));\r
-                       $label = NULL;\r
-               }\r
-               else if ( r!=NULL ) {\r
-                       err(eMsg1("label definition clashes with rule definition: '%s'", lab));\r
-                       $label = NULL;\r
-               }\r
-               else {\r
-                       /* we don't clash with anybody else */\r
-                       l = (LabelEntry *) hash_get(Elabel, lab);\r
-                       if ( l==NULL ) {        /* ok to add new element label */\r
-                               l = (LabelEntry *)hash_add(Elabel,\r
-                                                                                  lab,\r
-                                                                                  (Entry *)newLabelEntry(lab));\r
-                               /* add to list of element labels for this rule */\r
-                               list_add(&CurElementLabels, (void *)lab);\r
-/* MR7 */       leAdd(l);  /* list of labels waiting for exception group definitions */\r
-                               $label = l;\r
-                       }\r
-                       else {\r
-                               err(eMsg1("label definitions must be unique per rule: '%s'", lab));\r
-                               $label = NULL;\r
-                       }\r
-               }\r
-               >>\r
-               ":"\r
-       ;\r
-\r
-/* rule element */\r
-\r
-element[int old_not, int first_on_line, int use_def_MT_handler] > [Node *node]\r
-               : <<\r
-                 Attrib blk;\r
-                 Predicate *pred = NULL;\r
-                 int local_use_def_MT_handler=0;\r
-                 ActionNode *act;\r
-                 RuleRefNode *rr;\r
-                 set toksrefd, rulesrefd;\r
-                 TermEntry *term;\r
-                 TokNode *p=NULL; RuleRefNode *q; int approx=0;\r
-                 LabelEntry *label=NULL;\r
-          int predMsgDone=0;\r
-          int semDepth=0;\r
-          int   ampersandStyle;\r
-          int   height;         /* MR11 */\r
-          int   equal_height;   /* MR11 */\r
-\r
-          char* pFirstSetSymbol = NULL; /* MR21 */\r
-\r
-                 $node = NULL;\r
-                 >>\r
-                 {element_label>[label]}\r
-                 ( TokenTerm\r
-                       <<\r
-                       term = (TermEntry *) hash_get(Tname, LATEXT(1));\r
-                       if ( term==NULL && UserDefdTokens ) {\r
-                               err("implicit token definition not allowed with #tokdefs");\r
-                               $$.left = $$.right = NULL;\r
-                       }\r
-                       else {\r
-                               $$ = buildToken(LATEXT(1));\r
-                               p=((TokNode *)((Junction *)$$.left)->p1);\r
-                               term = (TermEntry *) hash_get(Tname, LATEXT(1));\r
-                               require( term!= NULL, "hash table mechanism is broken");\r
-                               p->tclass = term->tclass;\r
-                               p->complement = $old_not;\r
-                               if ( label!=NULL ) {\r
-                                       p->el_label = label->str;\r
-                                       label->elem = (Node *)p;\r
-                               }\r
-                       }\r
-                       >>\r
-                       {       ".."\r
-                               (       QuotedTerm\r
-                                       <<if ( p!=NULL ) setUpperRange(p, LATEXT(1));>>\r
-                               |       TokenTerm\r
-                                       <<if ( p!=NULL ) setUpperRange(p, LATEXT(1));>>\r
-                               )\r
-                       }\r
-                       <<\r
-                       if ( p!=NULL && (p->upper_range!=0 || p->tclass || $old_not) )\r
-                               list_add(&MetaTokenNodes, (void *)p);\r
-                       >>\r
-                       (       "^"     <<if ( p!=NULL ) p->astnode=ASTroot;>>\r
-                       |               <<if ( p!=NULL ) p->astnode=ASTchild;>>\r
-                       |       "!" <<if ( p!=NULL ) p->astnode=ASTexclude;>>\r
-                       )\r
-                       { "\@" <<local_use_def_MT_handler = 1;>> }\r
-                       <<\r
-                       if ( p!=NULL && $first_on_line ) {\r
-                               CurAltStart = (Junction *)$$.left;\r
-                altAdd(CurAltStart);                                 /* MR7 */\r
-                               p->altstart = CurAltStart;\r
-                       }\r
-                       if ( p!=NULL )\r
-                               p->use_def_MT_handler = $use_def_MT_handler || local_use_def_MT_handler;\r
-                       $node = (Node *)p;\r
-                       >>\r
-                 | QuotedTerm\r
-                       <<\r
-                       term = (TermEntry *) hash_get(Texpr, LATEXT(1));\r
-                       if ( term==NULL && UserDefdTokens ) {\r
-                               err("implicit token definition not allowed with #tokdefs");\r
-                               $$.left = $$.right = NULL;\r
-                       }\r
-                       else {\r
-                               $$ = buildToken(LATEXT(1)); p=((TokNode *)((Junction *)$$.left)->p1);\r
-                               p->complement = $old_not;\r
-                               if ( label!=NULL ) {\r
-                                       p->el_label = label->str;\r
-                                       label->elem = (Node *)p;\r
-                               }\r
-                       }\r
-                       >>\r
-                       {       ".."\r
-                               (       QuotedTerm\r
-                                       <<if ( p!=NULL ) setUpperRange(p, LATEXT(1));>>\r
-                               |       TokenTerm\r
-                                       <<if ( p!=NULL ) setUpperRange(p, LATEXT(1));>>\r
-                               )\r
-                       }\r
-                       (       "^"     <<if ( p!=NULL ) p->astnode=ASTroot;>>\r
-                       |               <<if ( p!=NULL ) p->astnode=ASTchild;>>\r
-                       |       "!" <<if ( p!=NULL ) p->astnode=ASTexclude;>>\r
-                       )\r
-                       { "\@" <<local_use_def_MT_handler = 1;>> }\r
-                       <<\r
-                       if ( p!=NULL && (p->upper_range!=0 || p->tclass || $old_not) )\r
-                               list_add(&MetaTokenNodes, (void *)p);\r
-                       >>\r
-                       <<\r
-                       if ( $first_on_line ) {\r
-                               CurAltStart = (Junction *)$$.left;\r
-                altAdd(CurAltStart);                                 /* MR7 */\r
-                               p->altstart = CurAltStart;\r
-                       }\r
-                       if ( p!=NULL )\r
-                               p->use_def_MT_handler = $use_def_MT_handler || local_use_def_MT_handler;\r
-                       $node = (Node *)p;\r
-                       >>\r
-\r
-                 | <<if ( $old_not ) warn("~ WILDCARD is an undefined operation (implies 'nothing')");>>\r
-                       "."\r
-                       <<$$ = buildWildCard(LATEXT(1)); p=((TokNode *)((Junction *)$$.left)->p1);>>\r
-                       (       "^"     <<p->astnode=ASTroot;>>\r
-                       |               <<p->astnode=ASTchild;>>\r
-                       |       "!" <<p->astnode=ASTexclude;>>\r
-                       )\r
-                       <<list_add(&MetaTokenNodes, (void *)p);>>\r
-                       <<\r
-                       if ( $first_on_line ) {\r
-                               CurAltStart = (Junction *)$$.left;\r
-                altAdd(CurAltStart);                                 /* MR7 */\r
-                               p->altstart = CurAltStart;\r
-                               if ( label!=NULL ) {\r
-                                       p->el_label = label->str;\r
-                                       label->elem = (Node *)p;\r
-                               }\r
-                       }\r
-                       $node = (Node *)p;\r
-                       >>\r
-\r
-                 | <<if ( $old_not ) warn("~ NONTERMINAL is an undefined operation");>>\r
-                       NonTerminal\r
-                       <<$$ = buildRuleRef(LATEXT(1));>>\r
-                       { "!" <<q = (RuleRefNode *) ((Junction *)$$.left)->p1;\r
-                                       q->astnode=ASTexclude;>>\r
-                       }\r
-                       {       {"\<"}\r
-                               PassAction <<addParm(((Junction *)$$.left)->p1, LATEXT(1));>>\r
-                       }\r
-                       <<rr=(RuleRefNode *) ((Junction *)$$.left)->p1;>>\r
-                       {       <<char *a;>>\r
-                               "\>"\r
-                               PassAction\r
-                               <<\r
-                                       a = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));\r
-                                       require(a!=NULL, "rule element: cannot allocate assignment");\r
-                                       strcpy(a, LATEXT(1));\r
-                                       rr->assign = a;\r
-                               >>\r
-                       }\r
-                       <<\r
-                       if ( label!=NULL ) {\r
-                               rr->el_label = label->str;\r
-                               label->elem = (Node *)rr;\r
-                       }\r
-                       if ( $first_on_line ) {\r
-                               CurAltStart = (Junction *)$$.left;\r
-                altAdd(CurAltStart);                                 /* MR7 */\r
-                               ((RuleRefNode *)((Junction *)$$.left)->p1)->altstart = CurAltStart;\r
-                       }\r
-                       $node = (Node *)rr;\r
-                       >>\r
-                 )\r
-\r
-               |       <<if ( $old_not )       warn("~ ACTION is an undefined operation");>>\r
-                       Action <<$0 = buildAction(LATEXT(1),action_file,action_line, 0);>>\r
-                       <<if ( $first_on_line ) {                                /* MR7 */\r
-                CurAltStart = (Junction *)$0.left;                   /* MR7 */\r
-                altAdd(CurAltStart);                                 /* MR7 */\r
-              };>>                                                   /* MR7 */\r
-                       <<$node = (Node *) ((Junction *)$0.left)->p1;>>\r
-\r
-               |       <<if ( $old_not )       warn("~ SEMANTIC-PREDICATE is an undefined operation");>>\r
-                       Pred   <<$0 = buildAction(LATEXT(1),action_file,action_line, 1);>>\r
-                       <<act = (ActionNode *) ((Junction *)$0.left)->p1;>>\r
-            <<if (numericActionLabel) {             /* MR10 */\r
-                list_add(&NumericPredLabels,act);   /* MR10 */\r
-                numericActionLabel=0;               /* MR10 */\r
-              };                                    /* MR10 */\r
-            >>\r
-                       {       <<char *a;>>\r
-                               PassAction\r
-                               <<\r
-                               a = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));\r
-                               require(a!=NULL, "rule element: cannot allocate predicate fail action");\r
-                               strcpy(a, LATEXT(1));\r
-                               act->pred_fail = a;\r
-                               >>\r
-                       }\r
-                       <<if ( $first_on_line ) {                                /* MR7 */\r
-                CurAltStart = (Junction *)$0.left;                   /* MR7 */\r
-                altAdd(CurAltStart);                                 /* MR7 */\r
-              };>>                                                   /* MR7 */\r
-                       <<$node = (Node *)act;>>\r
-\r
-               |       <<if ( $old_not )       warn("~ BLOCK is an undefined operation");>>\r
-                       <<BlkLevel++;\r
-              if (BlkLevel >= MAX_BLK_LEVEL) fatal("Blocks nested too deeply");\r
-/* MR23 */    CurBlockID_array[BlkLevel] = CurBlockID;\r
-/* MR23 */    CurAltNum_array[BlkLevel] = CurAltNum;                \r
-            >>\r
-                       {       Pragma\r
-                               (       "approx" <<approx=LL_k;>>\r
-                               |       "LL\(1\)"  <<approx = 1;>>  /* MR20 */\r
-                               |       "LL\(2\)"  <<approx = 2;>>  /* MR20 */\r
-                )\r
-            }\r
-\r
-/* MR21 */  {  FirstSetSymbol\r
-/* MR21 */     "\("\r
-/* MR21 */             (       NonTerminal\r
-/* MR21 */                <<\r
-/* MR21 */                     pFirstSetSymbol = (char *) calloc(strlen(LATEXT(1))+1,\r
-/* MR21 */                                                    sizeof(char));\r
-/* MR21 */                          require(pFirstSetSymbol!=NULL,\r
-/* MR21 */                                  "cannot allocate first set name");\r
-/* MR21 */                          strcpy(pFirstSetSymbol, LATEXT(1));\r
-/* MR21 */                      >>\r
-/* MR21 */          |    TokenTerm\r
-/* MR21 */                  <<\r
-/* MR21 */                      pFirstSetSymbol = (char *) calloc(strlen(LATEXT(1))+1,\r
-/* MR21 */                                                        sizeof(char));\r
-/* MR21 */                      require(pFirstSetSymbol!=NULL,\r
-/* MR21 */                              "cannot allocate first set name");\r
-/* MR21 */                      strcpy(pFirstSetSymbol, LATEXT(1));\r
-/* MR21 */                  >>\r
-/* MR21 */          )\r
-/* MR21 */      "\)"\r
-/* MR21 */  }\r
-\r
-            (\r
-\r
-               "\(" block[&toksrefd,&rulesrefd] "\)"\r
-                               <<blk = $$ = $2;\r
-                        /* MR23 */      CurBlockID_array[BlkLevel] = (-1);\r
-                        /* MR23 */      CurAltNum_array[BlkLevel] = (-1);                \r
-                  --BlkLevel;\r
-            >>\r
-\r
-                               (       "\*"            <<$$ = makeLoop($$,approx,pFirstSetSymbol);>>\r
-                               |       "\+"            <<$$ = makePlus($$,approx,pFirstSetSymbol);>>\r
-                               |       "?"\r
-                                       (       \r
-                        ( "=>" <<ampersandStyle=0;>>\r
-                        | "&&" <<ampersandStyle=1;>>  /* MR10 (g)? && <<p>>? */\r
-                        )\r
-                        Pred   /* generalized predicate */\r
-                                               /* first make into a predicate */\r
-                                           <<$$ = buildAction(LATEXT(1),action_file,action_line,1);>>\r
-                                           <<act = (ActionNode *) ((Junction *)$$.left)->p1;>>\r
-                        <<semDepth=predicateLookaheadDepth(act);>>  /* MR10 */\r
-                        <<if (numericActionLabel) {             /* MR10 */\r
-                            list_add(&NumericPredLabels,act);   /* MR10 */\r
-                            numericActionLabel=0;               /* MR10 */\r
-                          };                                    /* MR10 */\r
-                        >>\r
-                                               {       <<char *a;>>\r
-                                                       PassAction\r
-                                                       <<\r
-                                                       a = (char *)calloc(strlen(LATEXT(1))+1, sizeof(char));\r
-                                                       require(a!=NULL, "rule element: cannot allocate predicate fail action");\r
-                                                       strcpy(a, LATEXT(1));\r
-                                                       act->pred_fail = a;\r
-                                                       >>\r
-                                               }\r
-                                               <<if ($first_on_line) {                      /* MR7 */\r
-                            CurAltStart=(Junction *)$$.left;         /* MR7 */\r
-                            altAdd(CurAltStart);                     /* MR7 */\r
-                          };>>\r
-                                               <<$node = (Node *)act;>>\r
-\r
-                                               /* for now, just snag context */\r
-                                               <<\r
-                                               pred = computePredFromContextGuard(blk,&predMsgDone);           /* MR10 */\r
-                                               if ( pred==NULL) {                                              /* MR10 */\r
-                          if ( !predMsgDone) err("invalid or missing context guard");   /* MR10 */\r
-                          predMsgDone=1;                                                /* MR10 */\r
-                                               } else {                                                        /* MR10 */\r
-                            act->guardNodes=(Junction *)blk.left;                       /* MR11 */\r
-                                                       pred->expr = act->action;\r
-                                                       pred->source = act;\r
-/* MR10 */                  pred->ampersandStyle = ampersandStyle;  /* 0 means (g)? => ... 1 means (g)? && ... */\r
-/* MR13 */                  if (pred->tcontext != NULL) {\r
-/* MR13 */                    height=MR_max_height_of_tree(pred->tcontext);\r
-/* MR13 */                    equal_height=MR_all_leaves_same_height(pred->tcontext,height);\r
-/* MR13 */                    if (! equal_height) {\r
-/* MR13 */                       errFL("in guarded predicates all tokens in the guard must be at the same height",\r
-/* MR13 */                              FileStr[act->file],act->line);\r
-/* MR13 */                    };\r
-/* MR13 */                  }\r
-/* MR10 */                  if (ampersandStyle) {\r
-/* MR10 */                                       act->ampersandPred = pred;\r
-/* MR11 */                    if (! HoistPredicateContext) {\r
-/* MR11 */                      errFL("without \"-prc on\" (guard)? && <<pred>>? ... doesn't make sense",\r
-/* MR11 */                              FileStr[act->file],act->line);\r
-/* MR11 */                    };\r
-/* MR10 */                  } else {\r
-/* MR10 */                                       act->guardpred = pred;\r
-/* MR10 */                  };\r
-/* MR10 */                  if (pred->k != semDepth) {\r
-/* MR10 */                     warn(eMsgd2("length of guard (%d) does not match the length of semantic predicate (%d)",\r
-/* MR10 */                                  pred->k,semDepth));\r
-/* MR10 */                  };\r
-                                               }\r
-                                               >>\r
-                                       |       <<$$ = makeBlk($$,approx,pFirstSetSymbol);\r
-                                                 FoundGuessBlk = 1;\r
-                                                 ((Junction *) ((Junction *)$$.left)->p1)->guess=1;\r
-                                                 if ( !$first_on_line ) {\r
-                                                       err("(...)? predicate must be first element of production");\r
-                                                 }\r
-                                               >>\r
-                                       )\r
-                               |       <<$$ = makeBlk($$,approx,pFirstSetSymbol);>>\r
-                               )\r
-                               <<\r
-                               if ( pred==NULL && !predMsgDone) {                                      /* MR10 */\r
-                                       ((Junction *)((Junction *)$$.left)->p1)->blockid = CurBlockID;\r
-                                       ((Junction *)((Junction *)$$.left)->p1)->tokrefs = toksrefd;\r
-                                       ((Junction *)((Junction *)$$.left)->p1)->rulerefs = rulesrefd;\r
-                                       if ( $first_on_line ) {                         /* MR7 */\r
-                                          CurAltStart = (Junction *)((Junction *)((Junction *)$$.left)->p1);  /* MR7 */\r
-                       altAdd(CurAltStart);                         /* MR7 */\r
-                    };                                              /* MR7 */\r
-                                       $node = (Node *) ((Junction *)$$.left)->p1;\r
-                               }\r
-                               >>\r
-\r
-                       |       "\{"    block[&toksrefd,&rulesrefd]\r
-                                               <<$$ = makeOpt($2,approx,pFirstSetSymbol);\r
-                                /* MR23 */      CurBlockID_array[BlkLevel] = (-1);\r
-                                /* MR23 */      CurAltNum_array[BlkLevel] = (-1);                \r
-                                --BlkLevel;\r
-                        >>\r
-                               "\}"\r
-                               <<\r
-                               ((Junction *)((Junction *)$$.left)->p1)->blockid = CurBlockID;\r
-                               ((Junction *)((Junction *)$$.left)->p1)->tokrefs = toksrefd;\r
-                               ((Junction *)((Junction *)$$.left)->p1)->rulerefs = rulesrefd;\r
-                               >>\r
-                               <<if ( $first_on_line ) {                            /* MR7 */\r
-                                       CurAltStart = (Junction *) ((Junction *)((Junction *)$$.left)->p1);  /* MR7 */\r
-                    altAdd(CurAltStart);                             /* MR7 */\r
-                  };\r
-                               >>\r
-                               <<$node = (Node *) ((Junction *)$$.left)->p1;>>\r
-\r
-                       )\r
-\r
-/* Error catching alternatives */\r
-               |       "\*"    <<warn("don't you want a ')' with that '*'?"); CannotContinue=TRUE;>>\r
-               |       "\+"    <<warn("don't you want a ')' with that '+'?"); CannotContinue=TRUE;>>\r
-               |       "\>"    <<warn("'>' can only appear after a nonterminal"); CannotContinue=TRUE;>>\r
-               |       PassAction <<warn("[...] out of context 'rule > [...]'");\r
-                                                CannotContinue=TRUE;>>\r
-               ;\r
-               <<CannotContinue=TRUE;>>\r
-\r
-/* rule default_exception_handler */\r
-\r
-default_exception_handler\r
-       :       exception_group > [DefaultExGroup]\r
-       ;\r
-\r
-/* rule exception_group */\r
-\r
-exception_group > [ExceptionGroup *eg]\r
-       :       <<ExceptionHandler *h; LabelEntry *label=NULL;    /* MR6 */\r
-                 FoundException = 1; FoundExceptionGroup = 1;>>  /* MR6 */\r
-\r
-               "exception"      <<$eg = (ExceptionGroup *)calloc(1, sizeof(ExceptionGroup));>>\r
-               {       <<char *p;>>\r
-                       PassAction              /* did they attach a label? */\r
-                       <<\r
-                       p = LATEXT(1)+1;\r
-                       p[strlen(p)-1] = '\0';          /* kill trailing space */\r
-                       label = (LabelEntry *) hash_get(Elabel, LATEXT(1)+1);\r
-                       if ( label==NULL )\r
-                       {\r
-                               err(eMsg1("unknown label in exception handler: '%s'", LATEXT(1)+1));\r
-                       }\r
-                       >>\r
-               }\r
-               (       exception_handler > [h]\r
-                       <<list_add(&($eg->handlers), (void *)h);>>\r
-               )*\r
-               {       "default" ":" Action\r
-                       <<{\r
-                       ExceptionHandler *eh = (ExceptionHandler *)\r
-                               calloc(1, sizeof(ExceptionHandler));\r
-                       char *a = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));\r
-                       require(eh!=NULL, "exception: cannot allocate handler");\r
-                       require(a!=NULL, "exception: cannot allocate action");\r
-                       strcpy(a, LATEXT(1));\r
-                       eh->action = a;\r
-                       eh->signalname = (char *) calloc(strlen("default")+1, sizeof(char));\r
-                       require(eh->signalname!=NULL, "exception: cannot allocate sig name");\r
-                       strcpy(eh->signalname, "default");\r
-                       list_add(&($eg->handlers), (void *)eh);\r
-                       }>>\r
-               }\r
-\r
-               <<\r
-               if ( label!=NULL ) {\r
-               /* Record ex group in sym tab for this label */\r
-                  if ( label->ex_group!=NULL ) {\r
-                     err(eMsg1("duplicate exception handler for label '%s'",label->str));\r
-                  } else {\r
-                         label->ex_group = $eg;\r
-                               /* Label the exception group itself */\r
-                         $eg->label = label->str;\r
-                               /* Make the labelled element pt to the exception also */\r
-/* MR6 */        if (label->elem == NULL) {\r
-/* MR6 */           err(eMsg1("reference in exception handler to undefined label '%s'",label->str));\r
-/* MR6 */        } else {\r
-                                switch ( label->elem->ntype ) {\r
-                                   case nRuleRef :\r
-                        {\r
-                                           RuleRefNode *r = (RuleRefNode *)label->elem;\r
-                                           r->ex_group = $eg;\r
-                                       break;\r
-                        }\r
-                   case nToken :\r
-                                       {\r
-                                               TokNode *t = (TokNode *)label->elem;\r
-                                               t->ex_group = $eg;\r
-                                               break;\r
-                                       }\r
-                                } /* end switch */\r
-/* MR6 */        }; /* end test on label->elem */\r
-                   } /* end test on label->ex_group */\r
-\r
-               } /* end test on exception label */\r
-\r
-/* MR7 */\r
-/* MR7 */   if (BlkLevel == 1 && label == NULL) {\r
-/* MR7 */     $eg->forRule=1;\r
-/* MR7 */   } else if (label == NULL) {\r
-/* MR7 */     $eg->altID = makeAltID(CurBlockID_array[BlkLevel], CurAltNum_array[BlkLevel]);\r
-/* MR7 */     egAdd($eg);\r
-/* MR7 */   } else {\r
-/* MR7 */     $eg->labelEntry=label;\r
-/* MR7 */   };\r
-/* MR7 */\r
-/* MR7 */          /* You may want to remove this exc from the rule list  */\r
-/* MR7 */              /* and handle at the labeled element site.             */\r
-/* MR7 */\r
-/* MR7 */   if (label != NULL) {\r
-/* MR7 */     $eg = NULL;\r
-/* MR7 */   };\r
-\r
-               >>\r
-       ;\r
-       <<CannotContinue=TRUE;>>\r
-\r
-/* rule exception_handler */\r
-\r
-exception_handler > [ExceptionHandler *eh]\r
-       :       <<;>>                               /* MR9 Removed unreferenced variable "a" */\r
-               "catch"\r
-               <<\r
-               $eh = (ExceptionHandler *)calloc(1, sizeof(ExceptionHandler));\r
-               require($eh!=NULL, "exception: cannot allocate handler");\r
-               >>\r
-               (       NonTerminal\r
-                       <<\r
-                       $eh->signalname = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));\r
-                       require($eh->signalname!=NULL, "exception: cannot allocate sig name");\r
-                       strcpy($eh->signalname, LATEXT(1));\r
-                       >>\r
-               |       TokenTerm\r
-                       <<\r
-                       $eh->signalname = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));\r
-                       require($eh->signalname!=NULL, "exception: cannot allocate sig name");\r
-                       strcpy($eh->signalname, LATEXT(1));\r
-                       >>\r
-               )\r
-               ":"\r
-               {       <<$eh->action = NULL;>>\r
-                       Action\r
-                       <<\r
-                       $eh->action = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));\r
-                       require($eh->action!=NULL, "exception: cannot allocate action");\r
-                       strcpy($eh->action, LATEXT(1));\r
-                       >>\r
-               }\r
-       ;\r
-       <<CannotContinue=TRUE;>>\r
-\r
-#token NonTerminal             "[a-z] [A-Za-z0-9_]*"\r
-                                                       <<\r
-                                                       while ( zzchar==' ' || zzchar=='\t' ) {\r
-                                                               zzadvance();\r
-                                                       }\r
-                                                       if ( zzchar == ':' && inAlt ) NLA = LABEL;\r
-                                                       >>\r
-#token TokenTerm               "[A-Z] [A-Za-z0-9_]*"\r
-                                                       <<\r
-                                                       while ( zzchar==' ' || zzchar=='\t' ) {\r
-                                                               zzadvance();\r
-                                                       }\r
-                                                       if ( zzchar == ':' && inAlt ) NLA = LABEL;\r
-                                                       >>\r
-#token "{\\}#[A-Za-z0-9_]*"    <<warn(eMsg1("unknown meta-op: %s",LATEXT(1))); zzskip(); >>\r
-\r
-#lexclass PARSE_ENUM_FILE\r
-\r
-#token "[\t\ ]+"                       << zzskip(); >>                         /* Ignore White */\r
-#token "\n|\r|\r\n"                    << zzline++; zzskip(); >>       /* Track Line # */\r
-#token "//"                                    << zzmode(TOK_DEF_CPP_COMMENTS); zzmore(); >>\r
-#token "/\*"                           << zzmode(TOK_DEF_COMMENTS); zzskip(); >>\r
-#token "#ifdef"                                << zzmode(TOK_DEF_CPP_COMMENTS); zzskip(); >>\r
-#token "#if"                           << zzmode(TOK_DEF_CPP_COMMENTS); zzskip(); >>\r
-#token "#ifndef"                       << ; >>\r
-#token "#else"                         << zzmode(TOK_DEF_CPP_COMMENTS); zzskip(); >>\r
-#token "#endif"                                << zzmode(TOK_DEF_CPP_COMMENTS); zzskip(); >>\r
-#token "#undef"                                << zzmode(TOK_DEF_CPP_COMMENTS); zzskip(); >>\r
-#token "#import"                       << zzmode(TOK_DEF_CPP_COMMENTS); zzskip(); >>\r
-#token "@"                                     << ; >>\r
-\r
-/* rule enum_file */\r
-\r
-enum_file[char *fname]\r
-       :       {       "#ifndef" ID\r
-                       {       "#define" ID /* ignore if it smells like a gate */\r
-                               /* First #define after the first #ifndef (if any) is ignored */\r
-                       }\r
-               }\r
-               (       ( enum_def[$fname] )+\r
-               |       defines[$fname]\r
-               )\r
-       |\r
-       ;\r
-\r
-/* rule defines */\r
-\r
-defines[char *fname]\r
-       :       <<int v; int maxt=(-1); char *t;>>              /* MR3 */\r
-               (\r
-                       "#define" ID\r
-                       <<t = mystrdup(LATEXT(1));>>\r
-                       INT\r
-                       <<\r
-                       v = atoi(LATEXT(1));\r
-/*                     fprintf(stderr, "#token %s=%d\n", t, v);*/\r
-\r
-       /* MR2 Andreas Magnusson (Andreas.Magnusson@mailbox.swipnet.se) */\r
-       /* MR2 Fix to bug introduced by 1.33MR1 for #tokdefs            */\r
-       /* MR2 Don't let #tokdefs be confused by                        */\r
-       /* MR2   DLGminToken and DLGmaxToken                            */\r
-\r
-                       if ( ! isDLGmaxToken(t)) {              /* MR2 */\r
-                         TokenNum = v;\r
-                         if ( v>maxt ) maxt=v;\r
-                         if ( Tnum( t ) == 0 ) {\r
-                           addForcedTname( t, v );\r
-                         } else {\r
-                           warnFL(eMsg1("redefinition of token %s; ignored",t),$fname,zzline);\r
-                         };\r
-                       };\r
-                       >>\r
-               )+\r
-               <<TokenNum = maxt + 1;>>\r
-       ;\r
-\r
-/* rule enum_def */\r
-\r
-enum_def[char *fname]\r
-       :       <<int v= 0; int maxt=(-1); char *t;>>                   /* MR3 */\r
-               "enum" ID\r
-               "\{"\r
-                       ID\r
-                       <<t = mystrdup(LATEXT(1));>>\r
-                       (       "=" INT <<v=atoi(LATEXT(1));>>\r
-                       |                       <<v++;>>\r
-                       )\r
-                       <<\r
-/*                     fprintf(stderr, "#token %s=%d\n", t, v);*/\r
-                       TokenNum = v;\r
-                       if ( v>maxt ) maxt=v;                           /* MR3 */\r
-                       if ( Tnum( t ) == 0 ) addForcedTname( t, v );\r
-                       else {\r
-                               warnFL(eMsg1("redefinition of token %s; ignored",t),$fname,zzline);\r
-                       }\r
-                       >>\r
-                       (       ","\r
-\r
-                               /* MR2 Andreas Magnusson (Andreas.Magnusson@mailbox.swipnet.se) */\r
-                               /* MR2 Fix to bug introduced by 1.33MR1 for #tokdefs            */\r
-                               /* MR2 Don't let #tokdefs be confused by                        */\r
-                               /* MR2   DLGminToken and DLGmaxToken                            */\r
-\r
-                               {\r
-                                 <<isDLGmaxToken(LATEXT(1))>>? ID { "=" INT }          /* MR2 */\r
-                               | ID                                                    /* MR2 */\r
-                                       <<t = mystrdup(LATEXT(1));>>\r
-                                       (       "=" INT <<v=atoi(LATEXT(1));>>\r
-                                       |                       <<v++;>>\r
-                                       )\r
-                                       <<\r
-/*                                     fprintf(stderr, "#token %s=%d\n", t, v);*/\r
-                                       TokenNum = v;\r
-                                       if ( v>maxt ) maxt=v;                           /* MR3 */\r
-                                       if ( Tnum( t ) == 0 ) addForcedTname( t, v );\r
-                                       else {\r
-                                               warnFL(eMsg1("redefinition of token %s; ignored",t),$fname,zzline);\r
-                                       }\r
-                                       >>\r
-                               }\r
-                       )*\r
-               "\}"\r
-               ";"\r
-               <<TokenNum = maxt + 1;>>                                        /* MR3 */\r
-       ;\r
-\r
-#token INT     "[0-9]+"\r
-#token ID      "[a-zA-Z_][_a-zA-Z0-9]*"\r
-\r
-#lexclass START\r
-\r
-/* MR14 Arpad Beszedes  26-May-98\r
-        Add support for #line directives when antlr source is pre-processed\r
-*/\r
-\r
-#lexaction\r
-<<\r
-\r
-static char *\r
-#ifdef __USE_PROTOS\r
-getFileNameFromTheLineInfo(char *toStr, char *fromStr)\r
-#else\r
-getFileNameFromTheLineInfo(toStr, fromStr)\r
-char *toStr, *fromStr;\r
-#endif\r
-{\r
-  int i, j, k;\r
-\r
-  if (!fromStr || !toStr) return toStr;\r
-\r
-  /* find the first " */\r
-\r
-  for (i=0;\r
-        (i<MaxFileName) &&\r
-        (fromStr[i] != '\n') &&\r
-        (fromStr[i] != '\r') &&\r
-        (fromStr[i] != '\"');\r
-      i++) /* nothing */ ;\r
-\r
-  if ( (i == MaxFileName) ||\r
-       (fromStr[i] == '\n') ||\r
-       (fromStr[i] == '\r') ) {\r
-    return toStr;\r
-  }\r
-\r
-  /* find the second " */\r
-\r
-  for (j=i+1;\r
-        (j<MaxFileName) &&\r
-        (fromStr[j] != '\n') &&\r
-        (fromStr[j] != '\r') &&\r
-        (fromStr[j] != '\"');\r
-       j++) /* nothing */ ;\r
-\r
-  if ((j == MaxFileName) ||\r
-      (fromStr[j] == '\n') ||\r
-      (fromStr[j] == '\r') ) {\r
-    return toStr;\r
-  }\r
-\r
-  /* go back until the last / or \ */\r
-\r
-  for (k=j-1;\r
-        (fromStr[k] != '\"') &&\r
-        (fromStr[k] != '/') &&\r
-        (fromStr[k] != '\\');\r
-       k--) /* nothing */ ;\r
-\r
-  /* copy the string after " / or \ into toStr */\r
-\r
-  for (i=k+1; fromStr[i] != '\"'; i++) {\r
-    toStr[i-k-1] = fromStr[i];\r
-  }\r
-\r
-  toStr[i-k-1] = '\0';\r
-\r
-  return toStr;\r
-}\r
-\r
-/* MR14 end of a block to support #line in antlr source code */\r
-\r
->>\r
-\r
-<<\r
-\r
-/* MR2 Andreas Magnusson (Andreas.Magnusson@mailbox.swipnet.se) */\r
-/* MR2 Fix to bug introduced by 1.33MR1 for #tokdefs            */\r
-/* MR2 Don't let #tokdefs be confused by                       */\r
-/* MR2   DLGminToken and DLGmaxToken                           */\r
-\r
-/* semantic check on DLGminToken and DLGmaxmaxToken in #tokdefs */\r
-\r
-#ifdef __USE_PROTOS\r
-static int isDLGmaxToken(char *Token)\r
-#else\r
-static int isDLGmaxToken(Token)\r
-  char *       Token;\r
-#endif\r
-{\r
-   static char checkStr1[] = "DLGmaxToken";\r
-   static char checkStr2[] = "DLGminToken";\r
-\r
-   if (strcmp(Token, checkStr1) == 0)\r
-      return 1;\r
-   else if (strcmp(Token, checkStr2) == 0)\r
-      return 1;\r
-   else\r
-      return 0;\r
-}\r
-\r
-/* semantics of #token */\r
-static void\r
-#ifdef __USE_PROTOS\r
-chkToken(char *t, char *e, char *a, int tnum)\r
-#else\r
-chkToken(t,e,a,tnum)\r
-char *t, *e, *a;\r
-int tnum;\r
-#endif\r
-{\r
-       TermEntry *p;\r
-\r
-       /* check to see that they don't try to redefine a token as a token class */\r
-       if ( t!=NULL ) {\r
-               p = (TermEntry *) hash_get(Tname, t);\r
-               if ( p!=NULL && p->classname ) {\r
-                       err(eMsg1("redefinition of #tokclass '%s' to #token not allowed; ignored",t));\r
-                       if ( a!=NULL ) free((char *)a);\r
-                       return;\r
-               }\r
-       }\r
-\r
-       if ( t==NULL && e==NULL ) {                     /* none found */\r
-               err("#token requires at least token name or rexpr");\r
-       }\r
-       else if ( t!=NULL && e!=NULL ) {        /* both found */\r
-               if ( UserDefdTokens ) {                 /* if #tokdefs, must not define new */\r
-                       p = (TermEntry *) hash_get(Tname, t);\r
-                       if ( p == NULL) {\r
-err(eMsg1("new token definition '%s' not allowed - only #token with name already defined by #tokdefs file allowed",t));\r
-                       return;\r
-            };\r
-               }\r
-               Tklink(t, e);\r
-               if ( a!=NULL ) {\r
-                       if ( hasAction(e) ) {\r
-                               err(eMsg1("redefinition of action for %s; ignored",e));\r
-                       }\r
-                       else setHasAction(e, a);\r
-               }\r
-       }\r
-       else if ( t!=NULL ) {                           /* only one found */\r
-               if ( UserDefdTokens ) {\r
-                       p = (TermEntry *) hash_get(Tname, t);\r
-            if (p == NULL) {\r
-err(eMsg1("new token definition '%s' not allowed - only #token with name already defined by #tokdefs file allowed",t));\r
-            };\r
-                   return;\r
-               }\r
-               if ( Tnum( t ) == 0 ) addTname( t );\r
-               else {\r
-                       err(eMsg1("redefinition of token %s; ignored",t));\r
-               }\r
-               if ( a!=NULL ) {\r
-                       err(eMsg1("action cannot be attached to a token name (%s); ignored",t));\r
-                       free((char *)a);\r
-               }\r
-       }\r
-       else if ( e!=NULL ) {\r
-               if ( Tnum( e ) == 0 ) addTexpr( e );\r
-               else {\r
-                       if ( hasAction(e) ) {\r
-                               err(eMsg1("redefinition of action for expr %s; ignored",e));\r
-                       }\r
-                       else if ( a==NULL ) {\r
-                               err(eMsg1("redefinition of expr %s; ignored",e));\r
-                       }\r
-               }\r
-               if ( a!=NULL ) setHasAction(e, a);\r
-       }\r
-\r
-       /* if a token type number was specified, then add the token ID and 'tnum'\r
-        * pair to the ForcedTokens list.  (only applies if an id was given)\r
-        */\r
-       if ( t!=NULL && tnum>0 )\r
-       {\r
-               if ( set_el(tnum, reserved_positions) )\r
-               {\r
-                       err(eMsgd("a token has already been forced to token number %d; ignored", tnum));\r
-               }\r
-               else\r
-               {\r
-                       list_add(&ForcedTokens, newForcedToken(t,tnum));\r
-                       set_orel(tnum, &reserved_positions);\r
-               }\r
-       }\r
-}\r
->>\r
-\r
-<<\r
-static int\r
-#ifdef __USE_PROTOS\r
-match_token(char *s, char **nxt)\r
-#else\r
-match_token(s,nxt)\r
-char *s;\r
-char **nxt;\r
-#endif\r
-{\r
-    if ( !(*s>='A' && *s<='Z') ) return 0;\r
-       s++;\r
-    while ( (*s>='a' && *s<='z') ||\r
-                   (*s>='A' && *s<='Z') ||\r
-                   (*s>='0' && *s<='9') ||\r
-                   *s=='_' )\r
-    {\r
-          s++;\r
-       }\r
-       if ( *s!=' ' && *s!='}' ) return 0;\r
-       *nxt = s;\r
-       return 1;\r
-}\r
-\r
-static int\r
-#ifdef __USE_PROTOS\r
-match_rexpr(char *s, char **nxt)\r
-#else\r
-match_rexpr(s,nxt)\r
-char *s;\r
-char **nxt;\r
-#endif\r
-{\r
-    if ( *s!='"' ) return 0;\r
-       s++;\r
-    while ( *s!='"' )\r
-    {\r
-          if ( *s=='\n' || *s=='\r' )                   /* MR13 */\r
-                 warn("eoln found in regular expression");\r
-          if ( *s=='\\' ) s++;\r
-          s++;\r
-       }\r
-       *nxt = s+1;\r
-       return 1;\r
-}\r
-\r
-/*\r
- * Walk a string "{ A .. Z }" where A..Z is a space separated list\r
- * of token references (either labels or reg exprs).  Return a\r
- * string "inlineX_set" for some unique integer X.  Basically,\r
- * we pretend as if we had seen "#tokclass inlineX { A .. Z }"\r
- * on the input stream outside of an action.\r
- */\r
-char *\r
-#ifdef __USE_PROTOS\r
-inline_set(char *s)\r
-#else\r
-inline_set(s)\r
-char *s;\r
-#endif\r
-{\r
-       char *nxt;\r
-    fprintf(stderr, "found consumeUntil( {...} )\n");\r
-       while ( *s==' ' || *s=='\t' || *s=='\n' || *s=='\r' ) {s++;}\r
-       if ( *s!='{' )\r
-       {\r
-          err("malformed consumeUntil( {...} ); missing '{'");\r
-          return "bad_set";\r
-       }\r
-       s++;\r
-       while ( *s==' ' || *s=='\t' || *s=='\n' || *s=='\r' ) {s++;}\r
-       while ( *s!='}' )\r
-       {\r
-           if ( match_token(s,&nxt) ) fprintf(stderr, "found token %s\n", s);\r
-               else if ( match_rexpr(s,&nxt) ) fprintf(stderr, "found rexpr %s\n", s);\r
-               else {\r
-                   err("invalid element in consumeUntil( {...} )");\r
-                       return "bad_set";\r
-               }\r
-               s = nxt;\r
-               while ( *s==' ' || *s=='\t' || *s=='\n' || *s=='\r' ) {s++;}\r
-       }\r
-       return "inlineX_set";\r
-}\r
->>\r
-\r
-<<\r
-/* ANTLR-specific syntax error message generator\r
- * (define USER_ZZSYN when compiling so don't get 2 definitions)\r
- */\r
-void\r
-#ifdef __USE_PROTOS\r
-zzsyn(char *text, int tok, char *egroup, SetWordType *eset, int etok,\r
-int k, char *bad_text)\r
-#else\r
-zzsyn(text, tok, egroup, eset, etok, k, bad_text)\r
-char *text, *egroup, *bad_text;\r
-int tok;\r
-int etok;\r
-int k;\r
-SetWordType *eset;\r
-#endif\r
-{\r
-       fprintf(stderr, ErrHdr, FileStr[CurFile]!=NULL?FileStr[CurFile]:"stdin", zzline);\r
-       fprintf(stderr, " syntax error at \"%s\"", (tok==zzEOF_TOKEN)?"EOF":text);\r
-       if ( !etok && !eset ) {fprintf(stderr, "\n"); return;}\r
-       if ( k==1 ) fprintf(stderr, " missing");\r
-       else\r
-       {\r
-               fprintf(stderr, "; \"%s\" not", bad_text);\r
-               if ( zzset_deg(eset)>1 ) fprintf(stderr, " in");\r
-       }\r
-       if ( zzset_deg(eset)>0 ) zzedecode(eset);\r
-       else fprintf(stderr, " %s", zztokens[etok]);\r
-       if ( strlen(egroup) > (size_t)0 ) fprintf(stderr, " in %s", egroup);\r
-       fprintf(stderr, "\n");\r
-}\r
->>\r
-\r
-#lexaction <<\r
-#ifdef __USE_PROTOS\r
-void mark_label_used_in_sem_pred(LabelEntry *le)              /* MR10 */\r
-#else\r
-void mark_label_used_in_sem_pred(le)                          /* MR10 */\r
-  LabelEntry    *le;\r
-#endif\r
-{\r
-  TokNode   *tn;\r
-  require (le->elem->ntype == nToken,"mark_label_used... ntype != nToken");\r
-  tn=(TokNode *)le->elem;\r
-  require (tn->label != 0,"mark_label_used... TokNode has no label");\r
-  tn->label_used_in_semantic_pred=1;\r
-}\r
->>\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/antlr/antlr.r b/Tools/CodeTools/TianoTools/Pccts/antlr/antlr.r
deleted file mode 100644 (file)
index e3de387..0000000
+++ /dev/null
@@ -1,787 +0,0 @@
-/*\r
-       File:           antlrMPW.r\r
-       Target:         antlr 133MR\r
-       Created:    Monday, June 15, 1998 4:41:11 AM\r
-       Author:         Kenji Tanaka (kentar@osa.att.ne.jp)\r
-*/\r
-\r
-#include "cmdo.r"\r
-\r
-resource 'cmdo' (128, "Antlr") {\r
-       {       /* array dialogs: 5 elements */\r
-               /* [1] */\r
-               295,\r
-               "ANTLR -- Purdue Compiler Construction To"\r
-               "ol Set (PCCTS) LL(k) parser generator.",\r
-               {       /* array itemArray: 12 elements */\r
-                       /* [1] */\r
-                       NotDependent {\r
-\r
-                       },\r
-                       CheckOption {\r
-                               NotSet,\r
-                               {18, 23, 33, 223},\r
-                               "Read grammar from stdin",\r
-                               "-",\r
-                               "Read grammar from stdin."\r
-                       },\r
-                       /* [2] */\r
-                       NotDependent {\r
-\r
-                       },\r
-                       CheckOption {\r
-                               NotSet,\r
-                               {38, 23, 53, 310},\r
-                               "Send grammar.c/grammar.cpp to stdout",\r
-                               "-stdout",\r
-                               "Send grammar.c/grammar.cpp to stdout."\r
-                       },\r
-                       /* [3] */\r
-                       NotDependent {\r
-\r
-                       },\r
-                       MultiFiles {\r
-                               "Grammar File(s)É",\r
-                               "Choose the grammar specification files y"\r
-                               "ou wish to have ANTLR process.",\r
-                               {79, 22, 98, 152},\r
-                               "Grammar specification:",\r
-                               "",\r
-                               MultiInputFiles {\r
-                                       {       /* array MultiTypesArray: 1 elements */\r
-                                               /* [1] */\r
-                                               text\r
-                                       },\r
-                                       ".g",\r
-                                       "Files ending in .g",\r
-                                       "All text files"\r
-                               }\r
-                       },\r
-                       /* [4] */\r
-                       NotDependent {\r
-\r
-                       },\r
-                       Files {\r
-                               DirOnly,\r
-                               OptionalFile {\r
-                                       {58, 168, 74, 298},\r
-                                       {79, 169, 98, 299},\r
-                                       "Output Directory",\r
-                                       ":",\r
-                                       "-o",\r
-                                       "",\r
-                                       "Choose the directory where ANTLR will pu"\r
-                                       "t its output.",\r
-                                       dim,\r
-                                       "Output DirectoryÉ",\r
-                                       "",\r
-                                       ""\r
-                               },\r
-                               NoMore {\r
-\r
-                               }\r
-                       },\r
-                       /* [5] */\r
-                       NotDependent {\r
-\r
-                       },\r
-                       Redirection {\r
-                               StandardOutput,\r
-                               {126, 27}\r
-                       },\r
-                       /* [6] */\r
-                       NotDependent {\r
-\r
-                       },\r
-                       Redirection {\r
-                               DiagnosticOutput,\r
-                               {126, 178}\r
-                       },\r
-                       /* [7] */\r
-                       NotDependent {\r
-\r
-                       },\r
-                       TextBox {\r
-                               gray,\r
-                               {117, 20, 167, 300},\r
-                               "Redirection"\r
-                       },\r
-                       /* [8] */\r
-                       NotDependent {\r
-\r
-                       },\r
-                       NestedDialog {\r
-                               5,\r
-                               {20, 324, 40, 460},\r
-                               "Parse OptionsÉ",\r
-                               "Parse control options may be set with th"\r
-                               "is button."\r
-                       },\r
-                       /* [9] */\r
-                       NotDependent {\r
-\r
-                       },\r
-                       NestedDialog {\r
-                               2,\r
-                               {50, 324, 70, 460},\r
-                               "Generate OptionsÉ",\r
-                               "Various command line options may be set "\r
-                               "with this button."\r
-                       },\r
-                       /* [10] */\r
-                       NotDependent {\r
-\r
-                       },\r
-                       NestedDialog {\r
-                               3,\r
-                               {78, 324, 98, 460},\r
-                               "More OptionsÉ",\r
-                               "Antlr has ALOT of options. There are eve"\r
-                               "n more to be found with this button."\r
-                       },\r
-                       /* [11] */\r
-                       NotDependent {\r
-\r
-                       },\r
-                       NestedDialog {\r
-                               4,\r
-                               {106, 324, 126, 460},\r
-                               "Rename OptionsÉ",\r
-                               "Options for renaming output files may be"\r
-                               " set with this button."\r
-                       },\r
-                       /* [12] */\r
-                       NotDependent {\r
-\r
-                       },\r
-                       VersionDialog {\r
-                               VersionString {\r
-                                       "1.33MR"\r
-                               },\r
-                               "PCCTS was written by Terence Parr, Russe"\r
-                               "ll Quong, Will Cohen, and Hank Dietz: 19"\r
-                               "89-1998. MPW port by Scott Haney.",\r
-                               noDialog\r
-                       }\r
-               },\r
-               /* [2] */\r
-               295,\r
-               "Use this dialog to specify command line "\r
-               "Generate Options.",\r
-               {       /* array itemArray: 15 elements */\r
-                       /* [1] */\r
-                       NotDependent {\r
-\r
-                       },\r
-                       CheckOption {\r
-                               NotSet,\r
-                               {18, 25, 33, 225},\r
-                               "Generate C++ code",\r
-                               "-CC",\r
-                               "Generate C++ output from both ANTLR and "\r
-                               "DLG."\r
-                       },\r
-                       /* [2] */\r
-                       NotDependent {\r
-\r
-                       },\r
-                       CheckOption {\r
-                               NotSet,\r
-                               {38, 25, 53, 225},\r
-                               "Generate ASTs",\r
-                               "-gt",\r
-                               "Generate code for Abstract-Syntax-Trees "\r
-                               "(ASTs)."\r
-                       },\r
-                       /* [3] */\r
-                       NotDependent {\r
-\r
-                       },\r
-                       CheckOption {\r
-                               NotSet,\r
-                               {58, 25, 73, 225},\r
-                               "Generate line info",\r
-                               "-gl",\r
-                               "If this option is checked, ANTLR will ge"\r
-                               "nerate line info about grammaractions, t"\r
-                               "hereby making debugging easier since com"\r
-                               "pile errors will point to the grammar fi"\r
-                               "le."\r
-                       },\r
-                       /* [4] */\r
-                       NotDependent {\r
-\r
-                       },\r
-                       CheckOption {\r
-                               NotSet,\r
-                               {78, 25, 93, 225},\r
-                               "Generate error classes",\r
-                               "-ge",\r
-                               "If this option is checked, ANTLR will ge"\r
-                               "nerate an error class foreach non-termin"\r
-                               "al."\r
-                       },\r
-                       /* [5] */\r
-                       NotDependent {\r
-\r
-                       },\r
-                       CheckOption {\r
-                               NotSet,\r
-                               {98, 25, 113, 225},\r
-                               "Don't generate Code",\r
-                               "-gc",\r
-                               "If this option is checked, ANTLR will ge"\r
-                               "nerate no code, i.e. it will only perfor"\r
-                               "m analysis on the grammar."\r
-                       },\r
-                       /* [6] */\r
-                       NotDependent {\r
-\r
-                       },\r
-                       CheckOption {\r
-                               NotSet,\r
-                               {118, 25, 133, 225},\r
-                               "Delay lookahead fetches",\r
-                               "-gk",\r
-                               "If this option is checked, ANTLR will ge"\r
-                               "nerate a parser that delays lookahead fe"\r
-                               "tches until needed."\r
-                       },\r
-                       /* [7] */\r
-                       NotDependent {\r
-\r
-                       },\r
-                       CheckOption {\r
-                               NotSet,\r
-                               {138, 25, 153, 225},\r
-                               "Use newAST(...)",\r
-                               "-newAST",\r
-                               "In C++ mode use \"newAST(...)\" rather tha"\r
-                               "n \"new AST(...)\""\r
-                       },\r
-                       /* [8] */\r
-                       NotDependent {\r
-\r
-                       },\r
-                       CheckOption {\r
-                               NotSet,\r
-                               {18, 235, 33, 435},\r
-                               "Support parse traces",\r
-                               "-gd",\r
-                               "If this option is checked, ANTLR inserts"\r
-                               " code in each parsing function to provid"\r
-                               "e for user-defined handling of a detaile"\r
-                               "d parse trace. The code consists of call"\r
-                               "s to zzTRACEIN and zzTRACEOUT."\r
-                       },\r
-                       /* [9] */\r
-                       NotDependent {\r
-\r
-                       },\r
-                       CheckOption {\r
-                               NotSet,\r
-                               {38, 235, 53, 435},\r
-                               "Generate cross-references",\r
-                               "-cr",\r
-                               "If this option is checked, ANTLR will ge"\r
-                               "nerate a cross reference for all rules. "\r
-                               "For each rule it will print a list of al"\r
-                               "l other rules that refrence it."\r
-                       },\r
-                       /* [10] */\r
-                       NotDependent {\r
-\r
-                       },\r
-                       CheckOption {\r
-                               NotSet,\r
-                               {58, 235, 73, 435},\r
-                               "Don't create Lexer files",\r
-                               "-gx",\r
-                               "If this option is checked, ANTLR will no"\r
-                               "t generate DLG-related output files. Thi"\r
-                               "s option should be used if one wants a c"\r
-                               "ustom lexical analyzer or if one has mad"\r
-                               "e changes to the grammar not affecting t"\r
-                               "he lexical structure."\r
-                       },\r
-                       /* [11] */\r
-                       NotDependent {\r
-\r
-                       },\r
-                       CheckOption {\r
-                               NotSet,\r
-                               {78, 235, 93, 460},\r
-                               "Don't generate token expr sets",\r
-                               "-gs",\r
-                               "If this option is checked, ANTLR will no"\r
-                               "t generate sets for token expression set"\r
-                               "s; instead, it will generate a || separa"\r
-                               "ted sequence of LA(1)==token #. "\r
-                       },\r
-                       /* [12] */\r
-                       NotDependent {\r
-\r
-                       },\r
-                       CheckOption {\r
-                               NotSet,\r
-                               {98, 235, 113, 460},\r
-                               "Generate ANSI-compatible",\r
-                               "-ga",\r
-                               "Generate ANSI-compatible code (default=F"\r
-                               "ALSE)"\r
-                       },\r
-                       /* [13] */\r
-                       NotDependent {\r
-\r
-                       },\r
-                       CheckOption {\r
-                               NotSet,\r
-                               {118, 235, 133, 460},\r
-                               "Don't generate tokens.h",\r
-                               "-gxt",\r
-                               "Do not generate tokens.h (default=FALSE)"\r
-                       },\r
-                       /* [13] */\r
-                       NotDependent {\r
-\r
-                       },\r
-                       CheckOption {\r
-                               NotSet,\r
-                               {138, 235, 153, 460},\r
-                               "Provide \"(alpha)? beta\" info",\r
-                               "-alpha",\r
-                               "Provide additional information for \"(alpha)? beta\" error messages"\r
-                       },\r
-                       /* [14] */\r
-                       NotDependent {\r
-\r
-                       },\r
-                       RegularEntry {\r
-                               "Tabs(1 to 8):",\r
-                               {162, 23, 177, 117},\r
-                               {163, 125, 179, 196},\r
-                               "",\r
-                               keepCase,\r
-                               "-tab",\r
-                               "Width of tabs (1 to 8) for grammar.c/gra"\r
-                               "mmar.cpp files."\r
-                       },\r
-                       /* [15] */\r
-                       NotDependent {\r
-\r
-                       },\r
-                       RegularEntry {\r
-                               "Function Prefix:",\r
-                               {161, 236, 177, 342},\r
-                               {162, 345, 177, 454},\r
-                               "",\r
-                               keepCase,\r
-                               "-gp",\r
-                               "Prefix all generated rule functions with"\r
-                               " a string."\r
-                       }\r
-               },\r
-               /* [3] */\r
-               295,\r
-               "Use this dialog to specify still more co"\r
-               "mmand line options.",\r
-               {       /* array itemArray: 12 elements */\r
-                       /* [1] */\r
-                       NotDependent {\r
-\r
-                       },\r
-                       RadioButtons {\r
-                               {       /* array radioArray: 3 elements */\r
-                                       /* [1] */\r
-                                       {38, 25, 53, 85}, "None", "", Set, "When this option is selected, ANTLR will"\r
-                                       " not print the grammar to stdout.",\r
-                                       /* [2] */\r
-                                       {38, 100, 53, 160}, "Yes", "-p", NotSet, "When this option is selected, ANTLR will"\r
-                                       " print the grammar, stripped of all acti"\r
-                                       "ons and comments, to stdout.",\r
-                                       /* [3] */\r
-                                       {38, 175, 53, 235}, "More", "-pa", NotSet, "When this option is selected, ANTLR will"\r
-                                       " print the grammar, stripped of all acti"\r
-                                       "ons and comments, to stdout. It will als"\r
-                                       "o annotate the output with the first set"\r
-                                       "s determined from grammar analysis."\r
-                               }\r
-                       },\r
-                       /* [2] */\r
-                       NotDependent {\r
-\r
-                       },\r
-                       TextBox {\r
-                               gray,\r
-                               {28, 15, 60, 250},\r
-                               "Grammar Printing"\r
-                       },\r
-                       /* [3] */\r
-                       NotDependent {\r
-\r
-                       },\r
-                       RadioButtons {\r
-                               {       /* array radioArray: 3 elements */\r
-                                       /* [1] */\r
-                                       {88, 25, 103, 85}, "Low", "", Set, "When this option is selected, ANTLR will"\r
-                                       " show ambiguities/errors in low detail.",\r
-                                       /* [2] */\r
-                                       {88, 100, 103, 160}, "Medium", "-e2", NotSet, "When this option is selected, ANTLR will"\r
-                                       " show ambiguities/errors in more detail.",\r
-                                       /* [3] */\r
-                                       {88, 175, 103, 235}, "High", "-e3", NotSet, "When this option is selected, ANTLR will"\r
-                                       " show ambiguities/errors in excruciating"\r
-                                       " detail."\r
-                               }\r
-                       },\r
-                       /* [4] */\r
-                       NotDependent {\r
-\r
-                       },\r
-                       TextBox {\r
-                               gray,\r
-                               {78, 15, 110, 250},\r
-                               "Error reporting"\r
-                       },\r
-                       /* [5] */\r
-                       NotDependent {\r
-\r
-                       },\r
-                       CheckOption {\r
-                               NotSet,\r
-                               {130, 22, 145, 222},\r
-                               "More warnings",\r
-                               "-w2",\r
-                               "If this option is checked, ANTLR will wa"\r
-                               "rn if semantic predicates and/or (É)? bl"\r
-                               "ocks are assumed to cover ambiguous alte"\r
-                               "rnatives."\r
-                       },\r
-                       /* [6] */\r
-                       NotDependent {\r
-\r
-                       },\r
-                       RegularEntry {\r
-                               "Report when tnode usage exceeds:",\r
-                               {162, 23, 180, 253},\r
-                               {162, 255, 178, 326},\r
-                               "",\r
-                               keepCase,\r
-                               "-treport",\r
-                               "Report when tnode usage exceeds value du"\r
-                               "ring ambiguity resolution."\r
-                       },\r
-                       /* [7] */\r
-                       NotDependent {\r
-\r
-                       },\r
-                       CheckOption {\r
-                               NotSet,\r
-                               {40, 292, 55, 431},\r
-                               "Predicate",\r
-                               "-info p",\r
-                               "With the antlr \"-info p\" switch the user"\r
-                               " will receive information about the pred"\r
-                               "icate suppression in the generated file."\r
-                       },\r
-                       /* [8] */\r
-                       NotDependent {\r
-\r
-                       },\r
-                       CheckOption {\r
-                               NotSet,\r
-                               {60, 292, 75, 430},\r
-                               "Tree Nodes",\r
-                               "-info t",\r
-                               "Using \"-info t\" gives information about "\r
-                               "the total number of tnodes created and t"\r
-                               "he peak number of tnodes."\r
-                       },\r
-                       /* [9] */\r
-                       NotDependent {\r
-\r
-                       },\r
-                       CheckOption {\r
-                               NotSet,\r
-                               {80, 292, 95, 425},\r
-                               "First/follow",\r
-                               "-info f",\r
-                               "first/follow set information."\r
-                       },\r
-                       /* [10] */\r
-                       NotDependent {\r
-\r
-                       },\r
-                       CheckOption {\r
-                               NotSet,\r
-                               {100, 292, 115, 425},\r
-                               "Monitor progress",\r
-                               "-info m",\r
-                               "prints name of each rule as it is starte"\r
-                               "d and flushes output at start of each rule."\r
-                       },\r
-                       /* [11] */\r
-                       NotDependent {\r
-\r
-                       },\r
-                       CheckOption {\r
-                               NotSet,\r
-                               {120, 292, 135, 416},\r
-                               "Orphan rules",\r
-                               "-info o",\r
-                               "If there is more than one rule which is "\r
-                               "not referenced by any other rule then al"\r
-                               "l such rules are listed."\r
-                       },\r
-                       /* [12] */\r
-                       NotDependent {\r
-\r
-                       },\r
-                       TextBox {\r
-                               gray,\r
-                               {28, 279, 147, 451},\r
-                               "Extra info"\r
-                       }\r
-               },\r
-               /* [4] */\r
-               295,\r
-               "Use this dialog to specify command line "\r
-               "options relating to renaming output file"\r
-               "s.",\r
-               {       /* array itemArray: 7 elements */\r
-                       /* [1] */\r
-                       NotDependent {\r
-\r
-                       },\r
-                       RegularEntry {\r
-                               "Errors file name:",\r
-                               {35, 25, 50, 205},\r
-                               {35, 205, 51, 300},\r
-                               "err.c",\r
-                               keepCase,\r
-                               "-fe",\r
-                               "This entry specifies the name ANTLR uses"\r
-                               " for the errors file."\r
-                       },\r
-                       /* [2] */\r
-                       NotDependent {\r
-\r
-                       },\r
-                       RegularEntry {\r
-                               "Lexical output name:",\r
-                               {60, 25, 75, 205},\r
-                               {60, 205, 76, 300},\r
-                               "parser.dlg",\r
-                               keepCase,\r
-                               "-fl",\r
-                               "This entry specifies the name ANTLR uses"\r
-                               " for the lexical output file."\r
-                       },\r
-                       /* [3] */\r
-                       NotDependent {\r
-\r
-                       },\r
-                       RegularEntry {\r
-                               "Lexical modes name:",\r
-                               {85, 25, 100, 205},\r
-                               {85, 205, 101, 300},\r
-                               "mode.h",\r
-                               keepCase,\r
-                               "-fm",\r
-                               "This entry specifies the name ANTLR uses"\r
-                               " for the lexical mode definitions file."\r
-                       },\r
-                       /* [4] */\r
-                       NotDependent {\r
-\r
-                       },\r
-                       RegularEntry {\r
-                               "Remap file name:",\r
-                               {110, 25, 125, 205},\r
-                               {110, 205, 126, 300},\r
-                               "remap.h",\r
-                               keepCase,\r
-                               "-fr",\r
-                               "This entry specifies the name ANTLR uses"\r
-                               " for the file that remaps globally visib"\r
-                               "le symbols."\r
-                       },\r
-                       /* [5] */\r
-                       NotDependent {\r
-\r
-                       },\r
-                       RegularEntry {\r
-                               "Tokens file name:",\r
-                               {135, 25, 150, 205},\r
-                               {135, 205, 151, 300},\r
-                               "tokens.h",\r
-                               keepCase,\r
-                               "-ft",\r
-                               "This entry specifies the name ANTLR uses"\r
-                               " for the tokens file."\r
-                       },\r
-                       /* [6] */\r
-                       NotDependent {\r
-\r
-                       },\r
-                       CheckOption {\r
-                               NotSet,\r
-                               {160, 25, 175, 175},\r
-                               "Create std header",\r
-                               "-gh",\r
-                               "If this option is checked, ANTLR will cr"\r
-                               "eate a standard header file named, by de"\r
-                               "fault 'stdpccts.h'. This name can be alt"\r
-                               "ered using the entry right next door."\r
-                       },\r
-                       /* [7] */\r
-                       Or {\r
-                               {       /* array OrArray: 1 elements */\r
-                                       /* [1] */\r
-                                       6\r
-                               }\r
-                       },\r
-                       RegularEntry {\r
-                               "Std header file name:",\r
-                               {160, 175, 175, 355},\r
-                               {160, 355, 176, 450},\r
-                               "stdpccts.h",\r
-                               keepCase,\r
-                               "-fh",\r
-                               "This entry specifies the name ANTLR uses"\r
-                               " for the standard header file."\r
-                       }\r
-               },\r
-               /* [5] */\r
-               295,\r
-               "Use this dialog to specify parse options"\r
-               ".",\r
-               {       /* array itemArray: 9 elements */\r
-                       /* [1] */\r
-                       NotDependent {\r
-\r
-                       },\r
-                       RegularEntry {\r
-                               "Lookahead:",\r
-                               {23, 27, 38, 152},\r
-                               {46, 29, 62, 154},\r
-                               "1",\r
-                               keepCase,\r
-                               "-k",\r
-                               "This entry specifies the number of token"\r
-                               "s of lookahead."\r
-                       },\r
-                       /* [2] */\r
-                       NotDependent {\r
-\r
-                       },\r
-                       RegularEntry {\r
-                               "Compr lookahead:",\r
-                               {22, 167, 37, 292},\r
-                               {46, 172, 62, 297},\r
-                               "",\r
-                               keepCase,\r
-                               "-ck",\r
-                               "This entry specifies the number of token"\r
-                               "s of lookahead when using compressed (li"\r
-                               "near approximation) lookahead. In genera"\r
-                               "l, the compressed lookahead is much deep"\r
-                               "er than the full lookahead."\r
-                       },\r
-                       /* [3] */\r
-                       NotDependent {\r
-\r
-                       },\r
-                       RegularEntry {\r
-                               "Max tree nodes:",\r
-                               {22, 312, 37, 437},\r
-                               {46, 315, 62, 445},\r
-                               "",\r
-                               keepCase,\r
-                               "-rl",\r
-                               "This entry specifies the maximum number "\r
-                               "of tokens of tree nodes used by the gram"\r
-                               "mar analysis."\r
-                       },\r
-                       /* [4] */\r
-                       NotDependent {\r
-\r
-                       },\r
-                       CheckOption {\r
-                               NotSet,\r
-                               {76, 25, 91, 350},\r
-                               "Maintenance Release style hoisting",\r
-                               "-mrhoist",\r
-                               "Turn on/off k=1 Maintenance Release styl"\r
-                               "e hoisting."\r
-                       },\r
-                       /* [5] */\r
-                       NotDependent {\r
-\r
-                       },\r
-                       CheckOption {\r
-                               NotSet,\r
-                               {96, 25, 111, 431},\r
-                               "EXPERIMENTAL Maintenance Release style h"\r
-                               "oisting",\r
-                               "-mrhoistk",\r
-                               "Turn on/off k>1 EXPERIMENTAL Maintenance"\r
-                               " Release style hoisting."\r
-                       },\r
-                       /* [6] */\r
-                       NotDependent {\r
-\r
-                       },\r
-                       CheckOption {\r
-                               NotSet,\r
-                               {116, 25, 131, 363},\r
-                               "Compute context for hoisted predicates",\r
-                               "-prc on",\r
-                               "Turn on/off computation of context for h"\r
-                               "oisted predicates."\r
-                       },\r
-                       /* [7] */\r
-                       NotDependent {\r
-\r
-                       },\r
-                       RegularEntry {\r
-                               "Ambiguity aid:",\r
-                               {140, 27, 155, 125},\r
-                               {141, 135, 155, 209},\r
-                               "",\r
-                               keepCase,\r
-                               "-aa",\r
-                               "Ambiguity aid for a rule (rule name or l"\r
-                               "ine number)."\r
-                       },\r
-                       /* [8] */\r
-                       NotDependent {\r
-\r
-                       },\r
-                       RegularEntry {\r
-                               "Limits exp growth:",\r
-                               {140, 236, 155, 361},\r
-                               {139, 372, 155, 452},\r
-                               "",\r
-                               keepCase,\r
-                               "-aad",\r
-                               "Limits exp growth of -aa listing - defau"\r
-                               "lt=1 (max=ck value)."\r
-                       },\r
-                       /* [9] */\r
-                       NotDependent {\r
-\r
-                       },\r
-                       CheckOption {\r
-                               NotSet,\r
-                               {164, 26, 179, 366},\r
-                               "Lookahead token may appear multiple time"\r
-                               "s",\r
-                               "-aam",\r
-                               "Lookahead token may appear multiple time"\r
-                               "s in -aa listing."\r
-                       }\r
-               }\r
-       }\r
-};\r
-\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/antlr/antlr1.txt b/Tools/CodeTools/TianoTools/Pccts/antlr/antlr1.txt
deleted file mode 100644 (file)
index 4a7d22e..0000000
+++ /dev/null
@@ -1,264 +0,0 @@
-\r
-\r
-\r
-ANTLR(1)               PCCTS Manual Pages                ANTLR(1)\r
-\r
-\r
-\r
-NAME\r
-     antlr - ANother Tool for Language Recognition\r
-\r
-SYNTAX\r
-     antlr [_\bo_\bp_\bt_\bi_\bo_\bn_\bs] _\bg_\br_\ba_\bm_\bm_\ba_\br__\bf_\bi_\bl_\be_\bs\r
-\r
-DESCRIPTION\r
-     _\bA_\bn_\bt_\bl_\br converts an extended form of context-free grammar into\r
-     a set of C functions which directly implement an efficient\r
-     form of deterministic recursive-descent LL(k) parser.\r
-     Context-free grammars may be augmented with predicates to\r
-     allow semantics to influence parsing; this allows a form of\r
-     context-sensitive parsing.  Selective backtracking is also\r
-     available to handle non-LL(k) and even non-LALR(k) con-\r
-     structs.  _\bA_\bn_\bt_\bl_\br also produces a definition of a lexer which\r
-     can be automatically converted into C code for a DFA-based\r
-     lexer by _\bd_\bl_\bg.  Hence, _\ba_\bn_\bt_\bl_\br serves a function much like that\r
-     of _\by_\ba_\bc_\bc, however, it is notably more flexible and is more\r
-     integrated with a lexer generator (_\ba_\bn_\bt_\bl_\br directly generates\r
-     _\bd_\bl_\bg code, whereas _\by_\ba_\bc_\bc and _\bl_\be_\bx are given independent\r
-     descriptions).  Unlike _\by_\ba_\bc_\bc which accepts LALR(1) grammars,\r
-     _\ba_\bn_\bt_\bl_\br accepts LL(k) grammars in an extended BNF notation -\r
-     which eliminates the need for precedence rules.\r
-\r
-     Like _\by_\ba_\bc_\bc grammars, _\ba_\bn_\bt_\bl_\br grammars can use automatically-\r
-     maintained symbol attribute values referenced as dollar\r
-     variables.  Further, because _\ba_\bn_\bt_\bl_\br generates top-down\r
-     parsers, arbitrary values may be inherited from parent rules\r
-     (passed like function parameters).  _\bA_\bn_\bt_\bl_\br also has a mechan-\r
-     ism for creating and manipulating abstract-syntax-trees.\r
-\r
-     There are various other niceties in _\ba_\bn_\bt_\bl_\br, including the\r
-     ability to spread one grammar over multiple files or even\r
-     multiple grammars in a single file, the ability to generate\r
-     a version of the grammar with actions stripped out (for\r
-     documentation purposes), and lots more.\r
-\r
-OPTIONS\r
-     -ck _\bn\r
-          Use up to _\bn symbols of lookahead when using compressed\r
-          (linear approximation) lookahead.  This type of looka-\r
-          head is very cheap to compute and is attempted before\r
-          full LL(k) lookahead, which is of exponential complex-\r
-          ity in the worst case.  In general, the compressed loo-\r
-          kahead can be much deeper (e.g, -ck 10) _\bt_\bh_\ba_\bn _\bt_\bh_\be _\bf_\bu_\bl_\bl\r
-          _\bl_\bo_\bo_\bk_\ba_\bh_\be_\ba_\bd (_\bw_\bh_\bi_\bc_\bh _\bu_\bs_\bu_\ba_\bl_\bl_\by _\bm_\bu_\bs_\bt _\bb_\be _\bl_\be_\bs_\bs _\bt_\bh_\ba_\bn _\b4).\r
-\r
-     -CC  Generate C++ output from both ANTLR and DLG.\r
-\r
-     -cr  Generate a cross-reference for all rules.  For each\r
-          rule, print a list of all other rules that reference\r
-          it.\r
-\r
-     -e1  Ambiguities/errors shown in low detail (default).\r
-\r
-     -e2  Ambiguities/errors shown in more detail.\r
-\r
-     -e3  Ambiguities/errors shown in excruciating detail.\r
-\r
-     -fe file\r
-          Rename err.c to file.\r
-\r
-     -fh file\r
-          Rename stdpccts.h header (turns on -gh) to file.\r
-\r
-     -fl file\r
-          Rename lexical output, parser.dlg, to file.\r
-\r
-     -fm file\r
-          Rename file with lexical mode definitions, mode.h, to\r
-          file.\r
-\r
-     -fr file\r
-          Rename file which remaps globally visible symbols,\r
-          remap.h, to file.\r
-\r
-     -ft file\r
-          Rename tokens.h to file.\r
-\r
-     -ga  Generate ANSI-compatible code (default case).  This has\r
-          not been rigorously tested to be ANSI XJ11 C compliant,\r
-          but it is close.  The normal output of _\ba_\bn_\bt_\bl_\br is\r
-          currently compilable under both K&R, ANSI C, and C++-\r
-          this option does nothing because _\ba_\bn_\bt_\bl_\br generates a\r
-          bunch of #ifdef's to do the right thing depending on\r
-          the language.\r
-\r
-     -gc  Indicates that _\ba_\bn_\bt_\bl_\br should generate no C code, i.e.,\r
-          only perform analysis on the grammar.\r
-\r
-     -gd  C code is inserted in each of the _\ba_\bn_\bt_\bl_\br generated pars-\r
-          ing functions to provide for user-defined handling of a\r
-          detailed parse trace.  The inserted code consists of\r
-          calls to the user-supplied macros or functions called\r
-          zzTRACEIN and zzTRACEOUT.  The only argument is a _\bc_\bh_\ba_\br\r
-          * pointing to a C-style string which is the grammar\r
-          rule recognized by the current parsing function.  If no\r
-          definition is given for the trace functions, upon rule\r
-          entry and exit, a message will be printed indicating\r
-          that a particular rule as been entered or exited.\r
-\r
-     -ge  Generate an error class for each non-terminal.\r
-\r
-     -gh  Generate stdpccts.h for non-ANTLR-generated files to\r
-          include.  This file contains all defines needed to\r
-          describe the type of parser generated by _\ba_\bn_\bt_\bl_\br (e.g.\r
-          how much lookahead is used and whether or not trees are\r
-          constructed) and contains the header action specified\r
-          by the user.\r
-\r
-     -gk  Generate parsers that delay lookahead fetches until\r
-          needed.  Without this option, _\ba_\bn_\bt_\bl_\br generates parsers\r
-          which always have _\bk tokens of lookahead available.\r
-\r
-     -gl  Generate line info about grammar actions in C parser of\r
-          the form # _\bl_\bi_\bn_\be "_\bf_\bi_\bl_\be" which makes error messages from\r
-          the C/C++ compiler make more sense as they will point\r
-          into the grammar file not the resulting C file.\r
-          Debugging is easier as well, because you will step\r
-          through the grammar not C file.\r
-\r
-     -gs  Do not generate sets for token expression lists;\r
-          instead generate a ||-separated sequence of\r
-          LA(1)==_\bt_\bo_\bk_\be_\bn__\bn_\bu_\bm_\bb_\be_\br.  The default is to generate sets.\r
-\r
-     -gt  Generate code for Abstract-Syntax Trees.\r
-\r
-     -gx  Do not create the lexical analyzer files (dlg-related).\r
-          This option should be given when the user wishes to\r
-          provide a customized lexical analyzer.  It may also be\r
-          used in _\bm_\ba_\bk_\be scripts to cause only the parser to be\r
-          rebuilt when a change not affecting the lexical struc-\r
-          ture is made to the input grammars.\r
-\r
-     -k _\bn Set k of LL(k) to _\bn; i.e. set tokens of look-ahead\r
-          (default==1).\r
-\r
-     -o dir\r
-          Directory where output files should go (default=".").\r
-          This is very nice for keeping the source directory\r
-          clear of ANTLR and DLG spawn.\r
-\r
-     -p   The complete grammar, collected from all input grammar\r
-          files and stripped of all comments and embedded\r
-          actions, is listed to stdout.  This is intended to aid\r
-          in viewing the entire grammar as a whole and to elim-\r
-          inate the need to keep actions concisely stated so that\r
-          the grammar is easier to read.  Hence, it is preferable\r
-          to embed even complex actions directly in the grammar,\r
-          rather than to call them as subroutines, since the sub-\r
-          routine call overhead will be saved.\r
-\r
-     -pa  This option is the same as -p except that the output is\r
-          annotated with the first sets determined from grammar\r
-          analysis.\r
-\r
-     -prc on\r
-          Turn on the computation and hoisting of predicate con-\r
-          text.\r
-\r
-     -prc off\r
-          Turn off the computation and hoisting of predicate con-\r
-          text.  This option makes 1.10 behave like the 1.06\r
-          release with option -pr on.  Context computation is off\r
-          by default.\r
-\r
-     -rl _\bn\r
-          Limit the maximum number of tree nodes used by grammar\r
-          analysis to _\bn.  Occasionally, _\ba_\bn_\bt_\bl_\br is unable to\r
-          analyze a grammar submitted by the user.  This rare\r
-          situation can only occur when the grammar is large and\r
-          the amount of lookahead is greater than one.  A non-\r
-          linear analysis algorithm is used by PCCTS to handle\r
-          the general case of LL(k) parsing.  The average com-\r
-          plexity of analysis, however, is near linear due to\r
-          some fancy footwork in the implementation which reduces\r
-          the number of calls to the full LL(k) algorithm.  An\r
-          error message will be displayed, if this limit is\r
-          reached, which indicates the grammar construct being\r
-          analyzed when _\ba_\bn_\bt_\bl_\br hit a non-linearity.  Use this\r
-          option if _\ba_\bn_\bt_\bl_\br seems to go out to lunch and your disk\r
-          start thrashing; try _\bn=10000 to start.  Once the\r
-          offending construct has been identified, try to remove\r
-          the ambiguity that _\ba_\bn_\bt_\bl_\br was trying to overcome with\r
-          large lookahead analysis.  The introduction of (...)?\r
-          backtracking blocks eliminates some of these problems -\r
-          _\ba_\bn_\bt_\bl_\br does not analyze alternatives that begin with\r
-          (...)? (it simply backtracks, if necessary, at run\r
-          time).\r
-\r
-     -w1  Set low warning level.  Do not warn if semantic\r
-          predicates and/or (...)? blocks are assumed to cover\r
-          ambiguous alternatives.\r
-\r
-     -w2  Ambiguous parsing decisions yield warnings even if\r
-          semantic predicates or (...)? blocks are used.  Warn if\r
-          predicate context computed and semantic predicates\r
-          incompletely disambiguate alternative productions.\r
-\r
-     -    Read grammar from standard input and generate stdin.c\r
-          as the parser file.\r
-\r
-SPECIAL CONSIDERATIONS\r
-     _\bA_\bn_\bt_\bl_\br works...  we think.  There is no implicit guarantee of\r
-     anything.  We reserve no legal rights to the software known\r
-     as the Purdue Compiler Construction Tool Set (PCCTS) - PCCTS\r
-     is in the public domain.  An individual or company may do\r
-     whatever they wish with source code distributed with PCCTS\r
-     or the code generated by PCCTS, including the incorporation\r
-     of PCCTS, or its output, into commercial software.  We\r
-     encourage users to develop software with PCCTS.  However, we\r
-     do ask that credit is given to us for developing PCCTS.  By\r
-     "credit", we mean that if you incorporate our source code\r
-     into one of your programs (commercial product, research pro-\r
-     ject, or otherwise) that you acknowledge this fact somewhere\r
-     in the documentation, research report, etc...  If you like\r
-     PCCTS and have developed a nice tool with the output, please\r
-     mention that you developed it using PCCTS.  As long as these\r
-     guidelines are followed, we expect to continue enhancing\r
-     this system and expect to make other tools available as they\r
-     are completed.\r
-\r
-FILES\r
-     *.c  output C parser.\r
-\r
-     *.cpp\r
-          output C++ parser when C++ mode is used.\r
-\r
-     parser.dlg\r
-          output _\bd_\bl_\bg lexical analyzer.\r
-\r
-     err.c\r
-          token string array, error sets and error support rou-\r
-          tines.  Not used in C++ mode.\r
-\r
-     remap.h\r
-          file that redefines all globally visible parser sym-\r
-          bols.  The use of the #parser directive creates this\r
-          file.  Not used in C++ mode.\r
-\r
-     stdpccts.h\r
-          list of definitions needed by C files, not generated by\r
-          PCCTS, that reference PCCTS objects.  This is not gen-\r
-          erated by default.  Not used in C++ mode.\r
-\r
-     tokens.h\r
-          output #_\bd_\be_\bf_\bi_\bn_\be_\bs for tokens used and function prototypes\r
-          for functions generated for rules.\r
-\r
-\r
-SEE ALSO\r
-     dlg(1), pccts(1)\r
-\r
-\r
-\r
-\r
-\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/antlr/bits.c b/Tools/CodeTools/TianoTools/Pccts/antlr/bits.c
deleted file mode 100644 (file)
index ddd9bd6..0000000
+++ /dev/null
@@ -1,1025 +0,0 @@
-/* bits.c -- manage creation and output of bit sets used by the parser.\r
- *\r
- * SOFTWARE RIGHTS\r
- *\r
- * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
- * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
- * company may do whatever they wish with source code distributed with\r
- * PCCTS or the code generated by PCCTS, including the incorporation of\r
- * PCCTS, or its output, into commerical software.\r
- *\r
- * We encourage users to develop software with PCCTS.  However, we do ask\r
- * that credit is given to us for developing PCCTS.  By "credit",\r
- * we mean that if you incorporate our source code into one of your\r
- * programs (commercial product, research project, or otherwise) that you\r
- * acknowledge this fact somewhere in the documentation, research report,\r
- * etc...  If you like PCCTS and have developed a nice tool with the\r
- * output, please mention that you developed it using PCCTS.  In\r
- * addition, we ask that this header remain intact in our source code.\r
- * As long as these guidelines are kept, we expect to continue enhancing\r
- * this system and expect to make other tools available as they are\r
- * completed.\r
- *\r
- * ANTLR 1.33\r
- * Terence Parr\r
- * Parr Research Corporation\r
- * with Purdue University and AHPCRC, University of Minnesota\r
- * 1989-2001\r
- */\r
-\r
-#include <stdio.h>\r
-#include <stdlib.h>\r
-#include <ctype.h>\r
-#include <assert.h>\r
-#include "pcctscfg.h"\r
-#include "set.h"\r
-#include "syn.h"\r
-#include "hash.h"\r
-#include "generic.h"\r
-#include "dlgdef.h"\r
-\r
-/* char is only thing that is pretty much always known == 8 bits\r
- * This allows output of antlr (set stuff, anyway) to be androgynous (portable)\r
- */\r
-typedef unsigned char SetWordType;\r
-#define BitsPerByte            8\r
-#define BitsPerWord            BitsPerByte*sizeof(SetWordType)\r
-\r
-static SetWordType *setwd = NULL;\r
-int setnum = -1;\r
-int wordnum = 0;\r
-\r
-int esetnum = 0;\r
-\r
-/* Used to convert native wordsize, which ANTLR uses (via set.c) to manipulate sets,\r
-   to bytes that are most portable size-wise.\r
-   */\r
-void\r
-#ifdef __USE_PROTOS\r
-DumpIntAsChars( FILE *f, char *format, unsigned wd )\r
-#else\r
-DumpIntAsChars( f, format, wd )\r
-FILE *f;\r
-char *format;\r
-unsigned wd;\r
-#endif\r
-{\r
-       int i;\r
-       /* uses max of 32 bit unsigned integer for the moment */\r
-       static unsigned long byte_mask[sizeof(unsigned long)] =\r
-                               { 0xFF, 0xFF00UL, 0xFF0000UL, 0xFF000000UL };  /* MR20 G. Hobbelt */\r
-/*                               0xFF00000000, 0xFF0000000000, 0xFF000000000000, 0xFF00000000000000 };*/\r
-\r
-       /* for each byte in the word */\r
-       assert(sizeof(unsigned) <= 4); /* M20 G. Hobbelt Sanity check */\r
-       for (i=0; i<sizeof(unsigned); i++)\r
-       {\r
-               /* mask out the ith byte and shift down to the first 8 bits */\r
-               fprintf(f, format, (wd&byte_mask[i])>>(i*BitsPerByte));\r
-               if ( i<sizeof(unsigned)-1) fprintf(f, ",");\r
-       }\r
-}\r
-\r
-/* Create a new setwd (ignoring [Ep] token on end) */\r
-void\r
-#ifdef __USE_PROTOS\r
-NewSetWd( void )\r
-#else\r
-NewSetWd( )\r
-#endif\r
-{\r
-       SetWordType *p;\r
-\r
-       if ( setwd == NULL )\r
-       {\r
-               setwd = (SetWordType *) calloc(TokenNum, sizeof(SetWordType));\r
-               require(setwd!=NULL, "NewSetWd: cannot alloc set wd\n");\r
-       }\r
-       for (p = setwd; p<&(setwd[TokenNum]); p++)  {*p=0;}\r
-       wordnum++;\r
-}\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-DumpSetWd( void )\r
-#else\r
-DumpSetWd( )\r
-#endif\r
-{\r
-       if ( GenCC ) DumpSetWdForCC();\r
-       else DumpSetWdForC();\r
-}\r
-\r
-/* Dump the current setwd to ErrFile. 0..MaxTokenVal */\r
-void\r
-#ifdef __USE_PROTOS\r
-DumpSetWdForC( void )\r
-#else\r
-DumpSetWdForC( )\r
-#endif\r
-{\r
-       int i,c=1;\r
-\r
-       if ( setwd==NULL ) return;\r
-       fprintf(DefFile, "extern SetWordType setwd%d[];\n", wordnum);\r
-       fprintf(ErrFile,\r
-                       "SetWordType setwd%d[%d] = {", wordnum, TokenNum-1);\r
-       for (i=0; i<TokenNum-1; i++)\r
-       {\r
-               DAWDLE;\r
-               if ( i!=0 ) fprintf(ErrFile, ",");\r
-               if ( c == 8 ) {fprintf(ErrFile, "\n\t"); c=1;} else c++;\r
-               fprintf(ErrFile, "0x%x", setwd[i]);\r
-       }\r
-       fprintf(ErrFile, "};\n");\r
-}\r
-\r
-/* Dump the current setwd to Parser.C file. 0..MaxTokenVal;\r
- * Only used if -CC on.\r
- */\r
-void\r
-#ifdef __USE_PROTOS\r
-DumpSetWdForCC( void )\r
-#else\r
-DumpSetWdForCC( )\r
-#endif\r
-{\r
-       int i,c=1;\r
-\r
-       if ( setwd==NULL ) return;\r
-       fprintf(Parser_h, "\tstatic SetWordType setwd%d[%d];\n", wordnum, TokenNum-1);\r
-       fprintf(Parser_c,\r
-                       "SetWordType %s::setwd%d[%d] = {", CurrentClassName, wordnum,\r
-                       TokenNum-1);\r
-       for (i=0; i<TokenNum-1; i++)\r
-       {\r
-               DAWDLE;\r
-               if ( i!=0 ) fprintf(Parser_c, ",");\r
-               if ( c == 8 ) {fprintf(Parser_c, "\n\t"); c=1;} else c++;\r
-               fprintf(Parser_c, "0x%x", setwd[i]);\r
-       }\r
-       fprintf(Parser_c, "};\n");\r
-}\r
-\r
-/* Make a new set.  Dump old setwd and create new setwd if current setwd is full */\r
-void\r
-#ifdef __USE_PROTOS\r
-NewSet( void )\r
-#else\r
-NewSet( )\r
-#endif\r
-{\r
-       setnum++;\r
-       if ( setnum==BitsPerWord )              /* is current setwd full? */\r
-       {\r
-               DumpSetWd(); NewSetWd(); setnum = 0;\r
-       }\r
-}\r
-\r
-/* s is a set of tokens.  Turn on bit at each token position in set 'setnum' */\r
-void\r
-#ifdef __USE_PROTOS\r
-FillSet( set s )\r
-#else\r
-FillSet( s )\r
-set s;\r
-#endif\r
-{\r
-       SetWordType mask=(((unsigned)1)<<setnum);\r
-       unsigned int e;\r
-\r
-       while ( !set_nil(s) )\r
-       {\r
-               e = set_int(s);\r
-               set_rm(e, s);\r
-               setwd[e] |= mask;\r
-       }\r
-}\r
-\r
-                                       /* E r r o r  C l a s s  S t u f f */\r
-\r
-/* compute the FIRST of a rule for the error class stuff */\r
-static set\r
-#ifdef __USE_PROTOS\r
-Efirst( char *rule, ECnode *eclass )\r
-#else\r
-Efirst( rule, eclass )\r
-char *rule;\r
-ECnode *eclass;\r
-#endif\r
-{\r
-       set rk, a;\r
-       Junction *r;\r
-       RuleEntry *q = (RuleEntry *) hash_get(Rname, rule);\r
-\r
-       if ( q == NULL )\r
-       {\r
-               warnNoFL(eMsg2("undefined rule '%s' referenced in errclass '%s'; ignored",\r
-                                               rule, TokenString(eclass->tok)));\r
-               return empty;\r
-       }\r
-       r = RulePtr[q->rulenum];\r
-       r->end->halt = TRUE;            /* don't let reach fall off end of rule here */\r
-       rk = empty;\r
-       REACH(r, 1, &rk, a);\r
-       r->end->halt = FALSE;\r
-       return a;\r
-}\r
-\r
-/*\r
- * scan the list of tokens/eclasses/nonterminals filling the new eclass\r
- * with the set described by the list.  Note that an eclass can be\r
- * quoted to allow spaces etc... However, an eclass must not conflict\r
- * with a reg expr found elsewhere.  The reg expr will be taken over\r
- * the eclass name.\r
- */\r
-static void\r
-#ifdef __USE_PROTOS\r
-doEclass( char *eclass )\r
-#else\r
-doEclass( eclass )\r
-char *eclass;\r
-#endif\r
-{\r
-       TermEntry *q;\r
-       ECnode *p;\r
-       TCnode *tcnode;\r
-       ListNode *e;\r
-       unsigned int t;\r
-       unsigned deg=0;\r
-       set a;\r
-       require(eclass!=NULL, "doEclass: NULL eset");\r
-       \r
-       p = (ECnode *) eclass;\r
-       lexmode(p->lexclass);   /* switch to lexclass where errclass is defined */\r
-       p->eset = empty;\r
-       for (e = (p->elist)->next; e!=NULL; e=e->next)\r
-       {\r
-               q = NULL;                                                               /* MR23 */\r
-\r
-               if ( islower( *((char *)e->elem) ) )    /* is it a rule ref? (alias FIRST request) */\r
-               {\r
-                       a = Efirst((char *)e->elem, p);\r
-                       set_orin(&p->eset, a);\r
-                       deg += set_deg(a);\r
-                       set_free( a );\r
-                       continue;\r
-               }\r
-               else if ( *((char *)e->elem)=='"' )\r
-               {\r
-                       t = 0;\r
-                       q = (TermEntry *) hash_get(Texpr, (char *) e->elem);\r
-                       if ( q == NULL )\r
-                       {\r
-                               /* if quoted and not an expr look for eclass name */\r
-                               q = (TermEntry *) hash_get(Tname, *((char **)&(e->elem))=StripQuotes((char *)e->elem));\r
-                               if ( q != NULL ) t = q->token;\r
-                       }\r
-                       else t = q->token;\r
-               }\r
-               else    /* labelled token/eclass/tokclass */\r
-               {\r
-                       q = (TermEntry *) hash_get(Tname, (char *)e->elem);\r
-                       if ( q != NULL )\r
-                       {\r
-                               if ( strcmp((char *)e->elem, TokenString(p->tok))==0 )\r
-                               {\r
-                                       warnNoFL(eMsg1("self-referential error class '%s'; ignored",\r
-                                                                  (char *)e->elem));\r
-                                       continue;\r
-                               }\r
-                               else\r
-                                       t = q->token;\r
-                       }\r
-                       else t=0;\r
-               }\r
-               if ( t!=0 )\r
-               {\r
-                       if (isTermEntryTokClass(q))  {                  /* MR23 */\r
-                           tcnode = q->tclass;                                 /* MR23 */\r
-                               set_orin(&p->eset, tcnode->tset);       /* MR23 */\r
-                               deg = set_deg(p->eset);                         /* MR23 */\r
-                       }                                                                               /* MR23 */\r
-                       else {\r
-                               set_orel(t, &p->eset);\r
-                               deg++;\r
-                       }\r
-               }\r
-               else warnNoFL(eMsg2("undefined token '%s' referenced in errclass '%s'; ignored",\r
-                                                       (char *)e->elem, TokenString(p->tok)));\r
-       }\r
-       p->setdeg = deg;\r
-}\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-ComputeErrorSets( void )\r
-#else\r
-ComputeErrorSets( )\r
-#endif\r
-{\r
-#ifdef __cplusplus\r
-    list_apply(eclasses, (void (*)(void *)) doEclass);\r
-#else\r
-#ifdef __USE_PROTOS\r
-    list_apply(eclasses, (void (*)(void *)) doEclass);\r
-#else\r
-    list_apply(eclasses, doEclass);\r
-#endif\r
-#endif\r
-}\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-ComputeTokSets( void )\r
-#else\r
-ComputeTokSets( )\r
-#endif\r
-{\r
-       ListNode *t, *e = NULL, *e1, *e2;\r
-       int something_changed;\r
-    int i;\r
-       TCnode *p;\r
-       TermEntry *q, *q1, *q2;\r
-\r
-       if ( tclasses == NULL ) return;\r
-\r
-       /* turn lists of token/tokclass references into sets */\r
-       for (t = tclasses->next; t!=NULL; t=t->next)\r
-       {\r
-               p = (TCnode *) t->elem;\r
-\r
-               /* if wild card, then won't have entries in tclass, assume all_tokens */\r
-               if ( p->tok == WildCardToken )\r
-               {\r
-                       p->tset = set_dup(all_tokens);\r
-                       continue;\r
-               }\r
-\r
-               lexmode(p->lexclass);   /* switch to lexclass where tokclass is defined */\r
-               p->tset = empty;\r
-\r
-               /* instantiate all tokens/token_classes into the tset */\r
-               for (e = (p->tlist)->next; e!=NULL; e=e->next)\r
-               {\r
-                       char *tokstr;\r
-                       tokstr = (char *)e->elem;\r
-                       if ( *tokstr == '"' ) {\r
-                q = (TermEntry *) hash_get(Texpr, tokstr);\r
-                       require(q!=NULL, "ComputeTokSets: no token def");\r
-                       set_orel(q->token, &p->tset);\r
-                       } else if (tokstr[0] == '.') {\r
-                e1=e->next;\r
-                e2=e1->next;\r
-                e=e2;\r
-                q1= (TermEntry *) hash_get(Tname, (char *)e1->elem);\r
-                       require(q1!=NULL, "ComputeTokSets: no token def");\r
-                q2= (TermEntry *) hash_get(Tname, (char *)e2->elem);\r
-                       require(q2!=NULL, "ComputeTokSets: no token def");\r
-\r
-                if (set_el(q1->token,imag_tokens)) {\r
-errNoFL(eMsg2("can't define #tokclass %s using #tokclass or #errclass %s",\r
-                        TokenString(p->tok),(char *)e1->elem) );\r
-                }\r
-                if (set_el(q2->token,imag_tokens)) {\r
-errNoFL(eMsg2("can't define #tokclass %s using #tokclass or #errclass %s",\r
-                        TokenString(p->tok),(char *)e2->elem) );\r
-                }\r
-                if (q1->token > q2->token) {\r
-errNoFL(eMsg3("for #tokclass %s %s..%s - first token number > second token number",\r
-                        TokenString(p->tok),(char *)e1->elem,(char *)e2->elem) );\r
-                  for (i=q2->token; i<=q1->token; i++) { set_orel(i, &p->tset); }\r
-                } else {\r
-                  for (i=q1->token; i<=q2->token; i++) { set_orel(i, &p->tset); }\r
-                }\r
-            } else {\r
-                q = (TermEntry *) hash_get(Tname, tokstr);\r
-                       require(q!=NULL, "ComputeTokSets: no token def");\r
-                       set_orel(q->token, &p->tset);\r
-            }\r
-               }\r
-       }\r
-\r
-       /* Go thru list of tokclasses again looking for tokclasses in sets */\r
-again:\r
-       something_changed = 0;\r
-       for (t = tclasses->next; t!=NULL; t=t->next)\r
-       {\r
-               set tcl;\r
-               p = (TCnode *) t->elem;\r
-               tcl = set_and(p->tset, tokclasses);\r
-               if ( !set_nil(tcl) )\r
-               {\r
-                       int tk;\r
-                       /* replace refs to tokclasses with the associated set of tokens */\r
-                       something_changed = 1;\r
-                       while ( !set_nil(tcl) )\r
-                       {\r
-                               tk = set_int(tcl);              /* grab one of the tok class refs */\r
-                               set_rm(tk, tcl);\r
-                               if ( p->tok != tk )             /* tokclass ref to yourself? */\r
-                               {\r
-                                       q = (TermEntry *) hash_get(Tname, TokenString(tk));\r
-                                       require(q!=NULL, "#tokclass not in hash table");\r
-                                       set_orin(&p->tset, q->tclass->tset);\r
-                               }\r
-                               set_rm(tk, p->tset);    /* remove ref that we replaced */\r
-                       }\r
-               }\r
-               set_free(tcl);\r
-       }\r
-       if ( something_changed ) goto again;\r
-}\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-DumpRemainingTokSets(void)\r
-#else\r
-DumpRemainingTokSets()\r
-#endif\r
-{\r
-       TCnode *p;\r
-       ListNode *t;\r
-\r
-       /* Go thru tclasses (for the last time) and dump the sets not dumped\r
-        * during code gen; yes, this is a bogus way to do this, but ComputeTokSets()\r
-        * can't dump the defs as the error file and tok file has not been created\r
-        * yet etc...\r
-        */\r
-       if ( tclasses==NULL ) return;\r
-       for (t = tclasses->next; t!=NULL; t=t->next)\r
-       {\r
-               unsigned e;\r
-               p = (TCnode *) t->elem;\r
-               if ( p->dumped ) continue;\r
-               e = DefErrSet(&(p->tset), 0, TokenString(p->tok));\r
-               p->dumped = 1;\r
-               p->setnum = e;\r
-       }\r
-}\r
-\r
-\r
-/* replace a subset of an error set with an error class name if a subset is found\r
- * repeat process until no replacements made\r
- */\r
-void\r
-#ifdef __USE_PROTOS\r
-SubstErrorClass( set *f )\r
-#else\r
-SubstErrorClass( f )\r
-set *f;\r
-#endif\r
-{\r
-       int max, done = 0;\r
-       ListNode *p;\r
-       ECnode *ec, *maxclass = NULL;\r
-       set a;\r
-       require(f!=NULL, "SubstErrorClass: NULL eset");\r
-\r
-       if ( eclasses == NULL ) return;\r
-       while ( !done )\r
-       {\r
-               max = 0;\r
-               maxclass = NULL;\r
-               for (p=eclasses->next; p!=NULL; p=p->next)      /* chk all error classes */\r
-               {\r
-                       ec = (ECnode *) p->elem;\r
-                       if ( ec->setdeg > max )\r
-                       {\r
-                               if ( set_sub(ec->eset, *f) || set_equ(ec->eset, *f) )\r
-                                       {maxclass = ec; max=ec->setdeg;}\r
-                       }\r
-               }\r
-               if ( maxclass != NULL ) /* if subset found, replace with token */\r
-               {\r
-                       a = set_dif(*f, maxclass->eset);\r
-                       set_orel((unsigned)maxclass->tok, &a);\r
-                       set_free(*f);\r
-                       *f = a;\r
-               }\r
-               else done = 1;\r
-       }\r
-}\r
-\r
-int\r
-#ifdef __USE_PROTOS\r
-DefErrSet1(int nilOK, set *f, int subst, char *name )\r
-#else\r
-DefErrSet1(nilOK, f, subst, name )\r
-int nilOK;\r
-set *f;\r
-int subst;                     /* should be substitute error classes? */\r
-char *name;\r
-#endif\r
-{\r
-       if ( GenCC ) return DefErrSetForCC1(nilOK, f, subst, name, "_set");\r
-       else return DefErrSetForC1(nilOK, f, subst, name, "_set");\r
-}\r
-\r
-int\r
-#ifdef __USE_PROTOS\r
-DefErrSet( set *f, int subst, char *name )\r
-#else\r
-DefErrSet( f, subst, name )\r
-set *f;\r
-int subst;                     /* should be substitute error classes? */\r
-char *name;\r
-#endif\r
-{\r
-    return DefErrSet1(0,f,subst,name);\r
-}\r
-\r
-int\r
-#ifdef __USE_PROTOS\r
-DefErrSetWithSuffix(int nilOK, set *f, int subst, char *name, const char* suffix)\r
-#else\r
-DefErrSetWithSuffix(nilOK, f, subst, name, suffix )\r
-int nilOK;\r
-set *f;\r
-int subst;                     /* should be substitute error classes? */\r
-char *name;\r
-char *suffix;\r
-#endif\r
-{\r
-       if ( GenCC ) return DefErrSetForCC1(nilOK, f, subst, name, suffix );\r
-       else return DefErrSetForC1(nilOK, f, subst, name, suffix);\r
-}\r
-\r
-/* Define a new error set.  WARNING...set-implementation dependent.\r
- */\r
-int\r
-#ifdef __USE_PROTOS\r
-DefErrSetForC1(int nilOK, set *f, int subst, char * name, const char * suffix)\r
-#else\r
-DefErrSetForC1(nilOK, f, subst, name, suffix)\r
-int nilOK;          /* MR13 */\r
-set *f;\r
-int subst;                     /* should be substitute error classes? */\r
-char *name;\r
-const char *suffix;\r
-#endif\r
-{\r
-       unsigned *p, *endp;\r
-       int e=1;\r
-\r
-    if (!nilOK)        require(!set_nil(*f), "DefErrSetForC1: nil set to dump?");\r
-\r
-       if ( subst ) SubstErrorClass(f);\r
-       p = f->setword;\r
-       endp = &(f->setword[f->n]);\r
-       esetnum++;\r
-       if ( name!=NULL )\r
-               fprintf(DefFile, "extern SetWordType %s%s[];\n", name, suffix);\r
-       else\r
-               fprintf(DefFile, "extern SetWordType zzerr%d[];\n", esetnum);\r
-       if ( name!=NULL ) {\r
-               fprintf(ErrFile, "SetWordType %s%s[%d] = {",\r
-                               name,\r
-                suffix,\r
-                               NumWords(TokenNum-1)*sizeof(unsigned));\r
-       }\r
-       else {\r
-               fprintf(ErrFile, "SetWordType zzerr%d[%d] = {",\r
-                               esetnum,\r
-                               NumWords(TokenNum-1)*sizeof(unsigned));\r
-       }\r
-       while ( p < endp )\r
-       {\r
-               if ( e > 1 ) fprintf(ErrFile, ", ");\r
-               DumpIntAsChars(ErrFile, "0x%x", *p++);\r
-               if ( e == 3 )\r
-               {\r
-                       DAWDLE;\r
-                       if ( p < endp ) fprintf(ErrFile, ",");\r
-                       fprintf(ErrFile, "\n\t");\r
-                       e=1;\r
-               }\r
-               else e++;\r
-       }\r
-       fprintf(ErrFile, "};\n");\r
-\r
-       return esetnum;\r
-}\r
-\r
-int\r
-#ifdef __USE_PROTOS\r
-DefErrSetForC( set *f, int subst, char *name )\r
-#else\r
-DefErrSetForC( f, subst, name )\r
-set *f;\r
-int subst;                     /* should be substitute error classes? */\r
-char *name;\r
-#endif\r
-{\r
-  return DefErrSetForC1(0,f,subst,name, "_set");\r
-}\r
-\r
-/* Define a new error set.  WARNING...set-implementation dependent;\r
- * Only used when -CC on.\r
- */\r
-\r
-int\r
-#ifdef __USE_PROTOS\r
-DefErrSetForCC1(int nilOK, set *f, int subst, char *name, const char *suffix )\r
-#else\r
-DefErrSetForCC1(nilOK, f, subst, name, suffix )\r
-int nilOK;          /* MR13 */\r
-set *f;\r
-int subst;                     /* should be substitute error classes? */\r
-char *name;\r
-const char *suffix;\r
-#endif\r
-{\r
-       unsigned *p, *endp;\r
-       int e=1;\r
-\r
-    if (!nilOK)        require(!set_nil(*f), "DefErrSetForCC1: nil set to dump?");\r
-\r
-       if ( subst ) SubstErrorClass(f);\r
-       p = f->setword;\r
-       endp = &(f->setword[f->n]);\r
-       esetnum++;\r
-\r
-       if ( name!=NULL ) {\r
-               fprintf(Parser_h, "\tstatic SetWordType %s%s[%d];\n", name, suffix,\r
-                               NumWords(TokenNum-1)*sizeof(unsigned));\r
-               fprintf(Parser_c, "SetWordType %s::%s%s[%d] = {",\r
-                               CurrentClassName,\r
-                               name,\r
-                               suffix,\r
-                               NumWords(TokenNum-1)*sizeof(unsigned));\r
-       }\r
-       else {\r
-               fprintf(Parser_c, "SetWordType %s::err%d[%d] = {",\r
-                               CurrentClassName,\r
-                               esetnum,\r
-                               NumWords(TokenNum-1)*sizeof(unsigned));\r
-               fprintf(Parser_h, "\tstatic SetWordType err%d[%d];\n", esetnum,\r
-                               NumWords(TokenNum-1)*sizeof(unsigned));\r
-       }\r
-\r
-       while ( p < endp )\r
-       {\r
-               if ( e > 1 ) fprintf(Parser_c, ", ");\r
-               DumpIntAsChars(Parser_c, "0x%x", *p++);\r
-               if ( e == 3 )\r
-               {\r
-                       if ( p < endp ) fprintf(Parser_c, ",");\r
-                       fprintf(Parser_c, "\n\t");\r
-                       e=1;\r
-               }\r
-               else e++;\r
-       }\r
-       fprintf(Parser_c, "};\n");\r
-\r
-       return esetnum;\r
-}\r
-\r
-int\r
-#ifdef __USE_PROTOS\r
-DefErrSetForCC( set *f, int subst, char *name )\r
-#else\r
-DefErrSetForCC( f, subst, name )\r
-set *f;\r
-int subst;                     /* should be substitute error classes? */\r
-char *name;\r
-#endif\r
-{\r
-  return DefErrSetForCC1(0,f,subst,name, "_set");\r
-}\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-GenParser_c_Hdr(void)\r
-#else\r
-GenParser_c_Hdr()\r
-#endif\r
-{\r
-       int i,j;\r
-    TermEntry   *te;\r
-    char * hasAkaName = NULL;                                                                  /* MR23 */\r
-\r
-       hasAkaName = (char *) malloc(TokenNum+1);                                       /* MR23 */\r
-       require(hasAkaName!=NULL, "Cannot alloc hasAkaName\n");         /* MR23 */\r
-       for (i = 0; i < TokenNum; i++) hasAkaName[i]='0';                       /* MR23 */\r
-       hasAkaName[TokenNum] = 0;                                   /* MR23 */\r
-\r
-       fprintf(Parser_c, "/*\n");\r
-       fprintf(Parser_c, " * %s: P a r s e r  S u p p o r t\n", CurrentClassName);\r
-       fprintf(Parser_c, " *\n");\r
-       fprintf(Parser_c, " * Generated from:");\r
-       for (i=0; i<NumFiles; i++) fprintf(Parser_c, " %s", FileStr[i]);\r
-       fprintf(Parser_c, "\n");\r
-       fprintf(Parser_c, " *\n");\r
-       fprintf(Parser_c, " * Terence Parr, Russell Quong, Will Cohen, and Hank Dietz: 1989-2001\n");\r
-       fprintf(Parser_c, " * Parr Research Corporation\n");\r
-       fprintf(Parser_c, " * with Purdue University Electrical Engineering\n");\r
-       fprintf(Parser_c, " * with AHPCRC, University of Minnesota\n");\r
-       fprintf(Parser_c, " * ANTLR Version %s\n", Version);\r
-       fprintf(Parser_c, " */\n\n");\r
-       \r
-  if ( FirstAction != NULL ) dumpAction(FirstAction,Parser_c, 0, -1, 0, 1);    /* MR11 MR15b */\r
-\r
-       fprintf(Parser_c, "#define ANTLR_VERSION        %s\n", VersionDef);\r
-\r
-       fprintf(Parser_c, "#include \"pcctscfg.h\"\n");\r
-       fprintf(Parser_c, "#include \"pccts_stdio.h\"\n");\r
-       fprintf(Parser_c, "#define ANTLR_SUPPORT_CODE\n");\r
-       if ( UserTokenDefsFile != NULL )\r
-          fprintf(Parser_c, "#include %s\n", UserTokenDefsFile);\r
-       else\r
-          fprintf(Parser_c, "#include \"%s\"\n", DefFileName);\r
-\r
-       fprintf(Parser_c, "#include \"%s.h\"\n\n", CurrentClassName);\r
-\r
-       fprintf(Parser_c, "const ANTLRChar *%s::tokenName(int tok) ",   /* MR1 */\r
-                                       CurrentClassName);                              /* MR1 */\r
-       fprintf(Parser_c, "  { return _token_tbl[tok]; }\n");           /* MR1 */ /* MR10 */\r
-       /* Dump a Parser::tokens for each automaton */\r
-       fprintf(Parser_c, "\nconst ANTLRChar *%s::_token_tbl[]={\n",\r
-                                                 CurrentClassName); /* MR20 */\r
-       fprintf(Parser_c, "\t/* 00 */\t\"Invalid\"");\r
-\r
-       for (i=1; i<TokenNum-1; i++)\r
-       {\r
-               DAWDLE;\r
-               if ( i == EpToken ) continue;\r
-               /* remapped to invalid token? */\r
-               if ( TokenInd!=NULL && TokenInd[i]>=LastTokenCounted )\r
-               {\r
-                       fprintf(Parser_c, ",\n\t/* %02d */\t\"invalid\"", i);\r
-                       continue;\r
-               }\r
-               if ( TokenString(i) != NULL ) {\r
-           te=(TermEntry *) hash_get(Tname,TokenString(i));                     /* MR11 */\r
-            if (te == NULL || te->akaString == NULL) {                          /* MR11 */\r
-                     fprintf(Parser_c, ",\n\t/* %02d */\t\"%s\"", i, TokenString(i));\r
-            } else {\r
-                         hasAkaName[i] = '1';                                                                                      /* MR23 */\r
-                     fprintf(Parser_c, ",\n\t/* %02d */\t\"%s\"", i, te->akaString);   /* MR11 */\r
-            }\r
-        }\r
-               else\r
-               {\r
-                       /* look in all lexclasses for the reg expr */\r
-                       for (j=0; j<NumLexClasses; j++)\r
-                       {\r
-                               lexmode(j);\r
-                               if ( ExprString(i) != NULL )\r
-                               {\r
-                                       fprintf(Parser_c, ",\n\t/* %02d */\t", i);\r
-                                       dumpExpr(Parser_c, ExprString(i));\r
-                                       break;\r
-                               }\r
-                       }\r
-                       if ( j>=NumLexClasses )\r
-                       {\r
-                               if ( UserDefdTokens )\r
-                               {\r
-                                       fprintf(Parser_c, ",\n\t/* %02d */\t\"\"", i);\r
-                               }\r
-                               else\r
-                                       fatal_internal(eMsgd("No label or expr for token %d",i));\r
-                       }\r
-               }\r
-       }\r
-       fprintf(Parser_c, "\n};\n");\r
-\r
-       /* Build constructors */\r
-       fprintf(Parser_c, "\n%s::", CurrentClassName);\r
-       fprintf(Parser_c,       "%s(ANTLRTokenBuffer *input) : %s(input,%d,%d,%d,%d)\n",\r
-                                               CurrentClassName,\r
-                                               (BaseClassName == NULL ? "ANTLRParser" : BaseClassName),\r
-                                               OutputLL_k,\r
-                                               FoundGuessBlk,\r
-                                               DemandLookahead,\r
-                                               NumWords(TokenNum-1)*sizeof(unsigned));\r
-       fprintf(Parser_c, "{\n");\r
-       fprintf(Parser_c, "\ttoken_tbl = _token_tbl;\n");\r
-    if (TraceGen) {\r
-      fprintf(Parser_c, "\ttraceOptionValueDefault=1;\t\t// MR10 turn trace ON\n");\r
-    } else {\r
-      fprintf(Parser_c, "\ttraceOptionValueDefault=0;\t\t// MR10 turn trace OFF\n");\r
-    };\r
-       fprintf(Parser_c, "}\n\n");\r
-       free ( (void *) hasAkaName);\r
-}\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-GenParser_h_Hdr(void)\r
-#else\r
-GenParser_h_Hdr()\r
-#endif\r
-{\r
-       int i;\r
-\r
-       fprintf(Parser_h, "/*\n");\r
-       fprintf(Parser_h, " * %s: P a r s e r  H e a d e r \n", CurrentClassName);\r
-       fprintf(Parser_h, " *\n");\r
-       fprintf(Parser_h, " * Generated from:");\r
-       for (i=0; i<NumFiles; i++) fprintf(Parser_h, " %s", FileStr[i]);\r
-       fprintf(Parser_h, "\n");\r
-       fprintf(Parser_h, " *\n");\r
-       fprintf(Parser_h, " * Terence Parr, Russell Quong, Will Cohen, and Hank Dietz: 1989-2001\n");\r
-       fprintf(Parser_h, " * Parr Research Corporation\n");\r
-       fprintf(Parser_h, " * with Purdue University Electrical Engineering\n");\r
-       fprintf(Parser_h, " * with AHPCRC, University of Minnesota\n");\r
-       fprintf(Parser_h, " * ANTLR Version %s\n", Version);\r
-       fprintf(Parser_h, " */\n\n");\r
-\r
-  if ( FirstAction != NULL ) dumpAction( FirstAction, Parser_h, 0, -1, 0, 1);         /* MR11 MR15b */\r
-\r
-       fprintf(Parser_h, "#ifndef %s_h\n", CurrentClassName);\r
-       fprintf(Parser_h, "#define %s_h\n\n", CurrentClassName);\r
-\r
-    fprintf(Parser_h, "#ifndef ANTLR_VERSION\n");\r
-    fprintf(Parser_h, "#define ANTLR_VERSION %s\n",VersionDef);\r
-    fprintf(Parser_h, "#endif\n\n");\r
-\r
-       if ( GenAST ) fprintf(Parser_h, "class ASTBase;\n");\r
-    if (TraceGen) {\r
-      fprintf(Parser_h,"#ifndef zzTRACE_RULES\n");  /* MR20 */\r
-      fprintf(Parser_h,"#define zzTRACE_RULES\n");  /* MR20 */\r
-      fprintf(Parser_h,"#endif\n");                 /* MR22 */\r
-    };\r
-       fprintf(Parser_h, "#include \"%s\"\n\n", APARSER_H);\r
-\r
-       if ( HdrAction != NULL ) dumpAction( HdrAction, Parser_h, 0, -1, 0, 1);\r
-       \r
-/* MR10 */    if (ClassDeclStuff == NULL) {\r
-/* MR10 */     fprintf(Parser_h, "class %s : public ANTLRParser {\n", CurrentClassName);\r
-/* MR10 */    } else {\r
-/* MR10 */      fprintf(Parser_h, "class %s %s {\n",CurrentClassName,ClassDeclStuff);\r
-/* MR10 */    };\r
-\r
-       fprintf(Parser_h, "public:\n");                                           /* MR1 */\r
-       fprintf(Parser_h, "\tstatic  const ANTLRChar *tokenName(int tk);\n");/* MR1 */\r
-    fprintf(Parser_h, "\tenum { SET_SIZE = %i };\n",TokenNum-1);         /* MR21 */\r
-       fprintf(Parser_h, "protected:\n");\r
-       fprintf(Parser_h, "\tstatic const ANTLRChar *_token_tbl[];\n");     /* MR20 */\r
-       fprintf(Parser_h, "private:\n");\r
-}\r
-\r
-/* Currently, this is only used in !GenCC mode */\r
-void\r
-#ifdef __USE_PROTOS\r
-GenErrHdr( void )\r
-#else\r
-GenErrHdr( )\r
-#endif\r
-{\r
-       int i, j;\r
-    TermEntry   *te;\r
-\r
-       fprintf(ErrFile, "/*\n");\r
-       fprintf(ErrFile, " * A n t l r  S e t s / E r r o r  F i l e  H e a d e r\n");\r
-       fprintf(ErrFile, " *\n");\r
-       fprintf(ErrFile, " * Generated from:");\r
-       for (i=0; i<NumFiles; i++) fprintf(ErrFile, " %s", FileStr[i]);\r
-       fprintf(ErrFile, "\n");\r
-       fprintf(ErrFile, " *\n");\r
-       fprintf(ErrFile, " * Terence Parr, Russell Quong, Will Cohen, and Hank Dietz: 1989-2001\n");\r
-       fprintf(ErrFile, " * Parr Research Corporation\n");\r
-       fprintf(ErrFile, " * with Purdue University Electrical Engineering\n");\r
-       fprintf(ErrFile, " * With AHPCRC, University of Minnesota\n");\r
-       fprintf(ErrFile, " * ANTLR Version %s\n", Version);\r
-       fprintf(ErrFile, " */\n\n");\r
-\r
-  if ( FirstAction != NULL ) dumpAction( FirstAction, ErrFile, 0, -1, 0, 1);         /* MR11 MR15b */\r
-       \r
-  fprintf(ErrFile, "#define ANTLR_VERSION      %s\n", VersionDef);\r
-\r
-  fprintf(ErrFile, "#include \"pcctscfg.h\"\n");\r
-       fprintf(ErrFile, "#include \"pccts_stdio.h\"\n");\r
-       if ( strcmp(ParserName, DefaultParserName)!=0 )\r
-               fprintf(ErrFile, "#define %s %s\n", DefaultParserName, ParserName);\r
-       if ( strcmp(ParserName, DefaultParserName)!=0 )\r
-               fprintf(ErrFile, "#include \"%s\"\n", RemapFileName);\r
-       if ( HdrAction != NULL ) dumpAction( HdrAction, ErrFile, 0, -1, 0, 1 );\r
-       if ( FoundGuessBlk )\r
-       {\r
-               fprintf(ErrFile, "#define ZZCAN_GUESS\n");\r
-               fprintf(ErrFile, "#include \"pccts_setjmp.h\"\n");\r
-       }\r
-    if (TraceGen) {\r
-      fprintf(ErrFile,"#ifndef zzTRACE_RULES\n");  /* MR20 */\r
-      fprintf(ErrFile,"#define zzTRACE_RULES\n");  /* MR20 */\r
-      fprintf(ErrFile,"#endif\n");                 /* MR22 */\r
-    };\r
-\r
-       if ( OutputLL_k > 1 ) fprintf(ErrFile, "#define LL_K %d\n", OutputLL_k);\r
-#ifdef DUM\r
-       if ( LexGen ) fprintf(ErrFile, "#define zzEOF_TOKEN %d\n", (TokenInd!=NULL?TokenInd[EofToken]:EofToken));\r
-#endif\r
-       fprintf(ErrFile, "#define zzSET_SIZE %d\n", NumWords(TokenNum-1)*sizeof(unsigned));\r
-       if ( DemandLookahead ) fprintf(ErrFile, "#define DEMAND_LOOK\n");\r
-       fprintf(ErrFile, "#include \"antlr.h\"\n");\r
-       if ( GenAST ) fprintf(ErrFile, "#include \"ast.h\"\n");\r
-                       \r
-    if ( UserDefdTokens ) fprintf(ErrFile, "#include %s\n", UserTokenDefsFile);\r
-       /* still need this one as it has the func prototypes */\r
-       fprintf(ErrFile, "#include \"%s\"\n", DefFileName);\r
-       fprintf(ErrFile, "#include \"dlgdef.h\"\n");\r
-       fprintf(ErrFile, "#include \"err.h\"\n\n");\r
-\r
-       /* Dump a zztokens for each automaton */\r
-       if ( strcmp(ParserName, DefaultParserName)!=0 )\r
-       {\r
-               fprintf(ErrFile, "ANTLRChar *%s_zztokens[%d]={\n", ParserName, TokenNum-1);\r
-       }\r
-       else\r
-       {\r
-               fprintf(ErrFile, "ANTLRChar *zztokens[%d]={\n", TokenNum-1);\r
-       }\r
-       fprintf(ErrFile, "\t/* 00 */\t\"Invalid\"");\r
-       for (i=1; i<TokenNum-1; i++)\r
-       {\r
-               DAWDLE;\r
-               if ( i == EpToken ) continue;\r
-               /* remapped to invalid token? */\r
-               if ( TokenInd!=NULL && TokenInd[i]>=LastTokenCounted )\r
-               {\r
-                       fprintf(ErrFile, ",\n\t/* %02d */\t\"invalid\"", i);\r
-                       continue;\r
-               }\r
-               if ( TokenString(i) != NULL ) {\r
-            te=(TermEntry *) hash_get(Tname,TokenString(i));                     /* MR11 */\r
-            if (te == NULL || te->akaString == NULL) {                          /* MR11 */\r
-                         fprintf(ErrFile, ",\n\t/* %02d */\t\"%s\"", i, TokenString(i));\r
-            } else {\r
-                         fprintf(ErrFile, ",\n\t/* %02d */\t\"%s\"", i, te->akaString);    /* MR11 */\r
-            }\r
-        }\r
-               else\r
-               {\r
-                       /* look in all lexclasses for the reg expr */\r
-                       for (j=0; j<NumLexClasses; j++)\r
-                       {\r
-                               lexmode(j);\r
-                               if ( ExprString(i) != NULL )\r
-                               {\r
-                                       fprintf(ErrFile, ",\n\t/* %02d */\t", i);\r
-                                       dumpExpr(ErrFile, ExprString(i));\r
-                                       break;\r
-                               }\r
-                       }\r
-                       if ( j>=NumLexClasses )\r
-                       {\r
-                               if ( UserDefdTokens )\r
-                               {\r
-                                       fprintf(ErrFile, ",\n\t/* %02d */\t\"\"", i);\r
-                               }\r
-                               else\r
-                                       fatal_internal(eMsgd("No label or expr for token %d",i));\r
-                       }\r
-               }\r
-       }\r
-       fprintf(ErrFile, "\n};\n");\r
-}\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-dumpExpr( FILE *f, char *e )\r
-#else\r
-dumpExpr( f, e )\r
-FILE *f;\r
-char *e;\r
-#endif\r
-{\r
-       while ( *e!='\0' )\r
-       {\r
-               if ( *e=='\\' && *(e+1)=='\\' )\r
-                       {putc('\\', f); putc('\\', f); e+=2;}\r
-               else if ( *e=='\\' && *(e+1)=='"' )\r
-                       {putc('\\', f); putc('"', f); e+=2;}\r
-               else if ( *e=='\\' ) {putc('\\', f); putc('\\', f); e++;}\r
-               else {putc(*e, f); e++;}\r
-       }\r
-}\r
-\r
-int\r
-#ifdef __USE_PROTOS\r
-isTermEntryTokClass(TermEntry *te)\r
-#else\r
-isTermEntryTokClass(te)\r
-TermEntry *te;\r
-#endif\r
-{\r
-       ListNode *t;\r
-       TCnode *p;\r
-       TermEntry *q;\r
-       char *tokstr;\r
-\r
-       if (tclasses == NULL) return 0;\r
-\r
-       for (t = tclasses->next; t!=NULL; t=t->next)\r
-       {\r
-               p = (TCnode *) t->elem;\r
-               tokstr = TokenString(p->tok);\r
-               lexmode(p->lexclass);   /* switch to lexclass where tokclass is defined */\r
-        q = (TermEntry *) hash_get(Tname, tokstr);\r
-               if (q == te) return 1;\r
-       }\r
-       return 0;\r
-}\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/antlr/build.c b/Tools/CodeTools/TianoTools/Pccts/antlr/build.c
deleted file mode 100644 (file)
index 4eb3b02..0000000
+++ /dev/null
@@ -1,813 +0,0 @@
-/*\r
- * build.c -- functions associated with building syntax diagrams.\r
- *\r
- * SOFTWARE RIGHTS\r
- *\r
- * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
- * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
- * company may do whatever they wish with source code distributed with\r
- * PCCTS or the code generated by PCCTS, including the incorporation of\r
- * PCCTS, or its output, into commerical software.\r
- *\r
- * We encourage users to develop software with PCCTS.  However, we do ask\r
- * that credit is given to us for developing PCCTS.  By "credit",\r
- * we mean that if you incorporate our source code into one of your\r
- * programs (commercial product, research project, or otherwise) that you\r
- * acknowledge this fact somewhere in the documentation, research report,\r
- * etc...  If you like PCCTS and have developed a nice tool with the\r
- * output, please mention that you developed it using PCCTS.  In\r
- * addition, we ask that this header remain intact in our source code.\r
- * As long as these guidelines are kept, we expect to continue enhancing\r
- * this system and expect to make other tools available as they are\r
- * completed.\r
- *\r
- * ANTLR 1.33\r
- * Terence Parr\r
- * Parr Research Corporation\r
- * with Purdue University and AHPCRC, University of Minnesota\r
- * 1989-2001\r
- */\r
-\r
-#include <stdio.h>\r
-#include <stdlib.h>\r
-#include <ctype.h>\r
-#include "pcctscfg.h"\r
-#include "set.h"\r
-#include "syn.h"\r
-#include "hash.h"\r
-#include "generic.h"\r
-#include "dlgdef.h"\r
-\r
-#define SetBlk(g, t, approx, first_set_symbol) {                               \\r
-                       ((Junction *)g.left)->jtype = t;                                                \\r
-                       ((Junction *)g.left)->approx = approx;                                  \\r
-                       ((Junction *)g.left)->pFirstSetSymbol = first_set_symbol;   \\r
-                       ((Junction *)g.left)->end = (Junction *) g.right;               \\r
-                       ((Junction *)g.right)->jtype = EndBlk;}\r
-\r
-/* Add the parameter string 'parm' to the parms field of a block-type junction\r
- * g.left points to the sentinel node on a block.  i.e. g.left->p1 points to\r
- * the actual junction with its jtype == some block-type.\r
- */\r
-void\r
-#ifdef __USE_PROTOS\r
-addParm( Node *p, char *parm )\r
-#else\r
-addParm( p, parm )\r
-Node *p;\r
-char *parm;\r
-#endif\r
-{\r
-       char *q = (char *) malloc( strlen(parm) + 1 );\r
-       require(p!=NULL, "addParm: NULL object\n");\r
-       require(q!=NULL, "addParm: unable to alloc parameter\n");\r
-\r
-       strcpy(q, parm);\r
-       if ( p->ntype == nRuleRef )\r
-       {\r
-               ((RuleRefNode *)p)->parms = q;\r
-       }\r
-       else if ( p->ntype == nJunction )\r
-       {\r
-               ((Junction *)p)->parm = q;      /* only one parameter allowed on subrules */\r
-       }\r
-       else fatal_internal("addParm: invalid node for adding parm");\r
-}\r
-\r
-/*\r
- * Build an action node for the syntax diagram\r
- *\r
- * buildAction(ACTION) ::= --o-->ACTION-->o--\r
- *\r
- * Where o is a junction node.\r
- */\r
-Graph\r
-#ifdef __USE_PROTOS\r
-buildAction( char *action, int file, int line, int is_predicate )\r
-#else\r
-buildAction( action, file, line, is_predicate )\r
-char *action;\r
-int file;\r
-int line;\r
-int is_predicate;\r
-#endif\r
-{\r
-       Junction *j1, *j2;\r
-       Graph g;\r
-       ActionNode *a;\r
-       require(action!=NULL, "buildAction: invalid action");\r
-       \r
-       j1 = newJunction();\r
-       j2 = newJunction();\r
-       a = newActionNode();\r
-       a->action = (char *) malloc( strlen(action)+1 );\r
-       require(a->action!=NULL, "buildAction: cannot alloc space for action\n");\r
-       strcpy(a->action, action);\r
-       j1->p1 = (Node *) a;\r
-       a->next = (Node *) j2;\r
-       a->is_predicate = is_predicate;\r
-\r
-    if (is_predicate) {\r
-        PredEntry   *predEntry;\r
-        char        *t;\r
-        char        *key;\r
-        char        *u;\r
-        int         inverted=0;\r
-\r
-        t=key=(char *)calloc(1,strlen(a->action)+1);\r
-\r
-        for (u=a->action; *u != '\0' ; u++) {\r
-          if (*u != ' ') {\r
-            if (t==key && *u=='!') {\r
-              inverted=!inverted;\r
-            } else {\r
-              *t++=*u;\r
-            };\r
-          };\r
-        };\r
-\r
-        *t='\0';\r
-\r
-\r
-        predEntry=(PredEntry *)hash_get(Pname,key);\r
-        a->predEntry=predEntry;\r
-        if (predEntry != NULL) a->inverted=inverted;\r
-    } else {\r
-/* MR12c */      char  *strStart=a->action;\r
-/* MR12c */      char  *strEnd;\r
-/* MR12c */      strEnd=strStart+strlen(strStart)-1;\r
-/* MR12c */      for ( ; strEnd >= strStart &&  isspace(*strEnd); strEnd--) *strEnd=0;\r
-/* MR12c */      while (*strStart != '\0' && isspace(*strStart)) strStart++;\r
-/* MR12c */      if (ci_strequ(strStart,"nohoist")) {\r
-/* MR12c */        a->noHoist=1;\r
-/* MR12c */      }\r
-       }\r
-\r
-       g.left = (Node *) j1; g.right = (Node *) j2;\r
-       a->file = file;\r
-       a->line = line;\r
-       a->rname = CurRule;     /* MR10 */\r
-       return g;\r
-}\r
-\r
-/*\r
- * Build a token node for the syntax diagram\r
- *\r
- * buildToken(TOKEN) ::= --o-->TOKEN-->o--\r
- *\r
- * Where o is a junction node.\r
- */\r
-Graph\r
-#ifdef __USE_PROTOS\r
-buildToken( char *text )\r
-#else\r
-buildToken( text )\r
-char *text;\r
-#endif\r
-{\r
-       Junction *j1, *j2;\r
-       Graph g;\r
-       TokNode *t;\r
-       require(text!=NULL, "buildToken: invalid token name");\r
-       \r
-       j1 = newJunction();\r
-       j2 = newJunction();\r
-       t = newTokNode();\r
-       t->altstart = CurAltStart;\r
-       if ( *text == '"' ) {t->label=FALSE; t->token = addTexpr( text );}\r
-       else {t->label=TRUE; t->token = addTname( text );}\r
-       j1->p1 = (Node *) t;\r
-       t->next = (Node *) j2;\r
-       g.left = (Node *) j1; g.right = (Node *) j2;\r
-       return g;\r
-}\r
-\r
-/*\r
- * Build a wild-card node for the syntax diagram\r
- *\r
- * buildToken(TOKEN) ::= --o-->'.'-->o--\r
- *\r
- * Where o is a junction node.\r
- */\r
-Graph\r
-#ifdef __USE_PROTOS\r
-buildWildCard( char *text )\r
-#else\r
-buildWildCard( text )\r
-char *text;\r
-#endif\r
-{\r
-       Junction *j1, *j2;\r
-       Graph g;\r
-       TokNode *t;\r
-       TCnode *w;\r
-       TermEntry *p;\r
-       require(text!=NULL, "buildWildCard: invalid token name");\r
-       \r
-       j1 = newJunction();\r
-       j2 = newJunction();\r
-       t = newTokNode();\r
-\r
-       /* If the ref a wild card, make a token class for it */\r
-       if ( Tnum(WildCardString) == 0 )\r
-       {\r
-               w = newTCnode;\r
-               w->tok = addTname( WildCardString );\r
-               set_orel(w->tok, &imag_tokens);\r
-               set_orel(w->tok, &tokclasses);\r
-               WildCardToken = w->tok;\r
-               require((p=(TermEntry *)hash_get(Tname, WildCardString)) != NULL,\r
-                               "hash table mechanism is broken");\r
-               p->classname = 1;       /* entry is class name, not token */\r
-               p->tclass = w;          /* save ptr to this tclass def */\r
-               list_add(&tclasses, (char *)w);\r
-       }\r
-       else {\r
-               p=(TermEntry *)hash_get(Tname, WildCardString);\r
-               require( p!= NULL, "hash table mechanism is broken");\r
-               w = p->tclass;\r
-       }\r
-\r
-       t->token = w->tok;\r
-       t->wild_card = 1;\r
-       t->tclass = w;\r
-\r
-       t->altstart = CurAltStart;\r
-       j1->p1 = (Node *) t;\r
-       t->next = (Node *) j2;\r
-       g.left = (Node *) j1; g.right = (Node *) j2;\r
-       return g;\r
-}\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-setUpperRange(TokNode *t, char *text)\r
-#else\r
-setUpperRange(t, text)\r
-TokNode *t;\r
-char *text;\r
-#endif\r
-{\r
-       require(t!=NULL, "setUpperRange: NULL token node");\r
-       require(text!=NULL, "setUpperRange: NULL token string");\r
-\r
-       if ( *text == '"' ) {t->upper_range = addTexpr( text );}\r
-       else {t->upper_range = addTname( text );}\r
-}\r
-\r
-/*\r
- * Build a rule reference node of the syntax diagram\r
- *\r
- * buildRuleRef(RULE) ::= --o-->RULE-->o--\r
- *\r
- * Where o is a junction node.\r
- *\r
- * If rule 'text' has been defined already, don't alloc new space to store string.\r
- * Set r->text to point to old copy in string table.\r
- */\r
-Graph\r
-#ifdef __USE_PROTOS\r
-buildRuleRef( char *text )\r
-#else\r
-buildRuleRef( text )\r
-char *text;\r
-#endif\r
-{\r
-       Junction *j1, *j2;\r
-       Graph g;\r
-       RuleRefNode *r;\r
-       RuleEntry *p;\r
-       require(text!=NULL, "buildRuleRef: invalid rule name");\r
-       \r
-       j1 = newJunction();\r
-       j2 = newJunction();\r
-       r = newRNode();\r
-       r->altstart = CurAltStart;\r
-       r->assign = NULL;\r
-       if ( (p=(RuleEntry *)hash_get(Rname, text)) != NULL ) r->text = p->str;\r
-       else r->text = mystrdup( text );\r
-       j1->p1  = (Node *) r;\r
-       r->next = (Node *) j2;\r
-       g.left = (Node *) j1; g.right = (Node *) j2;\r
-       return g;\r
-}\r
-\r
-/*\r
- * Or two subgraphs into one graph via:\r
- *\r
- * Or(G1, G2) ::= --o-G1-o--\r
- *                  |    ^\r
- *                                     v    |\r
- *                  o-G2-o\r
- *\r
- * Set the altnum of junction starting G2 to 1 + altnum of junction starting G1.\r
- * If, however, the G1 altnum is 0, make it 1 and then\r
- * make G2 altnum = G1 altnum + 1.\r
- */\r
-Graph\r
-#ifdef __USE_PROTOS\r
-Or( Graph g1, Graph g2 )\r
-#else\r
-Or( g1, g2 )\r
-Graph g1;\r
-Graph g2;\r
-#endif\r
-{\r
-       Graph g;\r
-       require(g1.left != NULL, "Or: invalid graph");\r
-       require(g2.left != NULL && g2.right != NULL, "Or: invalid graph");\r
-\r
-       ((Junction *)g1.left)->p2 = g2.left;\r
-       ((Junction *)g2.right)->p1 = g1.right;\r
-       /* set altnums */\r
-       if ( ((Junction *)g1.left)->altnum == 0 ) ((Junction *)g1.left)->altnum = 1;\r
-       ((Junction *)g2.left)->altnum = ((Junction *)g1.left)->altnum + 1;\r
-       g.left = g2.left;\r
-       g.right = g1.right;\r
-       return g;\r
-}\r
-\r
-/*\r
- * Catenate two subgraphs\r
- *\r
- * Cat(G1, G2) ::= --o-G1-o-->o-G2-o--\r
- * Cat(NULL,G2)::= --o-G2-o--\r
- * Cat(G1,NULL)::= --o-G1-o--\r
- */\r
-Graph\r
-#ifdef __USE_PROTOS\r
-Cat( Graph g1, Graph g2 )\r
-#else\r
-Cat( g1, g2 )\r
-Graph g1;\r
-Graph g2;\r
-#endif\r
-{\r
-       Graph g;\r
-       \r
-       if ( g1.left == NULL && g1.right == NULL ) return g2;\r
-       if ( g2.left == NULL && g2.right == NULL ) return g1;\r
-       ((Junction *)g1.right)->p1 = g2.left;\r
-       g.left = g1.left;\r
-       g.right = g2.right;\r
-       return g;\r
-}\r
-\r
-/*\r
- * Make a subgraph an optional block\r
- *\r
- * makeOpt(G) ::= --o-->o-G-o-->o--\r
- *                      |          ^\r
- *                                             v           |\r
- *                                         o-------o\r
- *\r
- * Note that this constructs {A|B|...|Z} as if (A|B|...|Z|) was found.\r
- *\r
- * The node on the far right is added so that every block owns its own\r
- * EndBlk node.\r
- */\r
-Graph\r
-#ifdef __USE_PROTOS\r
-makeOpt( Graph g1, int approx, char * pFirstSetSymbol )\r
-#else\r
-makeOpt( g1, approx, pFirstSetSymbol )\r
-Graph g1;\r
-int approx;\r
-char * pFirstSetSymbol;\r
-#endif\r
-{\r
-       Junction *j1,*j2,*p;\r
-       Graph g;\r
-       require(g1.left != NULL && g1.right != NULL, "makeOpt: invalid graph");\r
-\r
-       j1 = newJunction();\r
-       j2 = newJunction();\r
-       ((Junction *)g1.right)->p1 = (Node *) j2;       /* add node to G at end */\r
-\r
-    /*  MR21\r
-     *\r
-     *  There is code in genBlk which recognizes the node created\r
-     *  by emptyAlt() as a special case and bypasses it.  We don't\r
-     *  want this to happen for the optBlk.\r
-     */\r
-\r
-       g = emptyAlt3(); /* MR21 */\r
-       if ( ((Junction *)g1.left)->altnum == 0 ) ((Junction *)g1.left)->altnum = 1;\r
-       ((Junction *)g.left)->altnum = ((Junction *)g1.left)->altnum + 1;\r
-       for(p=(Junction *)g1.left; p->p2!=NULL; p=(Junction *)p->p2)\r
-               {;}                                                                             /* find last alt */\r
-       p->p2 = g.left;                                                         /* add optional alternative */\r
-       ((Junction *)g.right)->p1 = (Node *)j2;         /* opt alt points to EndBlk */\r
-       g1.right = (Node *)j2;\r
-       SetBlk(g1, aOptBlk, approx, pFirstSetSymbol);\r
-       j1->p1 = g1.left;                                                       /* add generic node in front */\r
-       g.left = (Node *) j1;\r
-       g.right = g1.right;\r
-       return g;\r
-}\r
-\r
-/*\r
- * Make a graph into subblock\r
- *\r
- * makeBlk(G) ::= --o-->o-G-o-->o--\r
- *\r
- * The node on the far right is added so that every block owns its own\r
- * EndBlk node.\r
- */\r
-Graph\r
-#ifdef __USE_PROTOS\r
-makeBlk( Graph g1, int approx, char * pFirstSetSymbol )\r
-#else\r
-makeBlk( g1, approx, pFirstSetSymbol )\r
-Graph g1;\r
-int approx;\r
-char * pFirstSetSymbol;\r
-#endif\r
-{\r
-       Junction *j,*j2;\r
-       Graph g;\r
-       require(g1.left != NULL && g1.right != NULL, "makeBlk: invalid graph");\r
-\r
-       j = newJunction();\r
-       j2 = newJunction();\r
-       ((Junction *)g1.right)->p1 = (Node *) j2;       /* add node to G at end */\r
-       g1.right = (Node *)j2;\r
-       SetBlk(g1, aSubBlk, approx, pFirstSetSymbol);\r
-       j->p1 = g1.left;                                                        /* add node in front */\r
-       g.left = (Node *) j;\r
-       g.right = g1.right;\r
-\r
-       return g;\r
-}\r
-\r
-/*\r
- * Make a subgraph into a loop (closure) block -- (...)*\r
- *\r
- * makeLoop(G) ::=       |---|\r
- *                                          v   |\r
- *                        --o-->o-->o-G-o-->o--\r
- *                   |           ^\r
- *                   v           |\r
- *                                      o-----------o\r
- *\r
- * After making loop, always place generic node out front.  It becomes\r
- * the start of enclosing block.  The aLoopBlk is the target of the loop.\r
- *\r
- * Loop blks have TWO EndBlk nodes--the far right and the node that loops back\r
- * to the aLoopBlk node.  Node with which we can branch past loop == aLoopBegin and\r
- * one which is loop target == aLoopBlk.\r
- * The branch-past (initial) aLoopBegin node has end\r
- * pointing to the last EndBlk node.  The loop-target node has end==NULL.\r
- *\r
- * Loop blocks have a set of locks (from 1..CLL_k) on the aLoopBlk node.\r
- */\r
-Graph\r
-#ifdef __USE_PROTOS\r
-makeLoop( Graph g1, int approx, char * pFirstSetSymbol )\r
-#else\r
-makeLoop( g1, approx, pFirstSetSymbol)\r
-Graph g1;\r
-int approx;\r
-char * pFirstSetSymbol;\r
-#endif\r
-{\r
-       Junction *back, *front, *begin;\r
-       Graph g;\r
-       require(g1.left != NULL && g1.right != NULL, "makeLoop: invalid graph");\r
-\r
-       back = newJunction();\r
-       front = newJunction();\r
-       begin = newJunction();\r
-       g = emptyAlt3();\r
-       ((Junction *)g1.right)->p2 = g1.left;           /* add loop branch to G */\r
-       ((Junction *)g1.right)->p1 = (Node *) back;     /* add node to G at end */\r
-       ((Junction *)g1.right)->jtype = EndBlk;         /* mark 1st EndBlk node */\r
-       ((Junction *)g1.left)->jtype = aLoopBlk;        /* mark 2nd aLoopBlk node */\r
-       ((Junction *)g1.left)->end = (Junction *) g1.right;\r
-       ((Junction *)g1.left)->lock = makelocks();\r
-       ((Junction *)g1.left)->pred_lock = makelocks();\r
-       g1.right = (Node *) back;\r
-       begin->p1 = (Node *) g1.left;\r
-       g1.left = (Node *) begin;\r
-       begin->p2 = (Node *) g.left;                            /* make bypass arc */\r
-       ((Junction *)g.right)->p1 = (Node *) back;\r
-       SetBlk(g1, aLoopBegin, approx, pFirstSetSymbol);\r
-       front->p1 = g1.left;                                            /* add node to front */\r
-       g1.left = (Node *) front;\r
-\r
-       return g1;\r
-}\r
-\r
-/*\r
- * Make a subgraph into a plus block -- (...)+ -- 1 or more times\r
- *\r
- * makePlus(G) ::=      |---|\r
- *                                      v   |\r
- *                        --o-->o-G-o-->o--\r
- *\r
- * After making loop, always place generic node out front.  It becomes\r
- * the start of enclosing block.  The aPlusBlk is the target of the loop.\r
- *\r
- * Plus blks have TWO EndBlk nodes--the far right and the node that loops back\r
- * to the aPlusBlk node.\r
- *\r
- * Plus blocks have a set of locks (from 1..CLL_k) on the aPlusBlk node.\r
- */\r
-Graph\r
-#ifdef __USE_PROTOS\r
-makePlus( Graph g1, int approx, char * pFirstSetSymbol)\r
-#else\r
-makePlus( g1, approx, pFirstSetSymbol)\r
-Graph g1;\r
-int approx;\r
-char * pFirstSetSymbol;\r
-#endif\r
-{\r
-       int has_empty_alt_already = 0;\r
-       Graph g;\r
-       Junction *j2, *j3, *first_alt;\r
-       Junction *last_alt=NULL, *p;\r
-       require(g1.left != NULL && g1.right != NULL, "makePlus: invalid graph");\r
-\r
-       first_alt = (Junction *)g1.left;\r
-       j2 = newJunction();\r
-       j3 = newJunction();\r
-       if ( ((Junction *)g1.left)->altnum == 0 ) ((Junction *)g1.left)->altnum = 1;\r
-       ((Junction *)g1.right)->p2 = g1.left;           /* add loop branch to G */\r
-       ((Junction *)g1.right)->p1 = (Node *) j2;       /* add node to G at end */\r
-       ((Junction *)g1.right)->jtype = EndBlk;         /* mark 1st EndBlk node */\r
-       g1.right = (Node *) j2;\r
-       SetBlk(g1, aPlusBlk, approx, pFirstSetSymbol);\r
-       ((Junction *)g1.left)->lock = makelocks();\r
-       ((Junction *)g1.left)->pred_lock = makelocks();\r
-       j3->p1 = g1.left;                                                       /* add node to front */\r
-       g1.left = (Node *) j3;\r
-\r
-       /* add an optional branch which is the "exit" branch of loop */\r
-       /* FIRST, check to ensure that there does not already exist\r
-        * an optional path.\r
-        */\r
-       /* find last alt */\r
-       for(p=first_alt; p!=NULL; p=(Junction *)p->p2)\r
-       {\r
-               if ( p->p1->ntype == nJunction &&\r
-                        p->p1!=NULL &&\r
-                        ((Junction *)p->p1)->jtype==Generic &&\r
-                        ((Junction *)p->p1)->p1!=NULL &&\r
-                        ((Junction *)((Junction *)p->p1)->p1)->jtype==EndBlk )\r
-               {\r
-                       has_empty_alt_already = 1;\r
-               }\r
-               last_alt = p;\r
-       }\r
-       if ( !has_empty_alt_already )\r
-       {\r
-               require(last_alt!=NULL, "last_alt==NULL; bad (..)+");\r
-               g = emptyAlt();\r
-               last_alt->p2 = g.left;\r
-               ((Junction *)g.right)->p1 = (Node *) j2;\r
-\r
-               /* make sure lookahead computation ignores this alt for\r
-               * FIRST("(..)+"); but it's still used for computing the FIRST\r
-               * of each alternative.\r
-               */\r
-               ((Junction *)g.left)->ignore = 1;\r
-       }\r
-\r
-       return g1;\r
-}\r
-\r
-/*\r
- * Return an optional path:  --o-->o--\r
- */\r
-\r
-Graph\r
-#ifdef __USE_PROTOS\r
-emptyAlt( void )\r
-#else\r
-emptyAlt( )\r
-#endif\r
-{\r
-       Junction *j1, *j2;\r
-       Graph g;\r
-\r
-       j1 = newJunction();\r
-       j2 = newJunction();\r
-       j1->p1 = (Node *) j2;\r
-       g.left = (Node *) j1;\r
-       g.right = (Node *) j2;\r
-       \r
-       return g;\r
-}\r
-\r
-/*  MR21\r
- *\r
- *  There is code in genBlk which recognizes the node created\r
- *  by emptyAlt() as a special case and bypasses it.  We don't\r
- *  want this to happen for the optBlk.\r
- */\r
-\r
-Graph\r
-#ifdef __USE_PROTOS\r
-emptyAlt3( void )\r
-#else\r
-emptyAlt3( )\r
-#endif\r
-{\r
-       Junction *j1, *j2, *j3;\r
-       Graph g;\r
-\r
-       j1 = newJunction();\r
-       j2 = newJunction();\r
-    j3 = newJunction();\r
-       j1->p1 = (Node *) j2;\r
-       j2->p1 = (Node *) j3;\r
-       g.left = (Node *) j1;\r
-       g.right = (Node *) j3;\r
-       \r
-       return g;\r
-}\r
-\r
-/* N o d e  A l l o c a t i o n */\r
-\r
-TokNode *\r
-#ifdef __USE_PROTOS\r
-newTokNode( void )\r
-#else\r
-newTokNode( )\r
-#endif\r
-{\r
-       static TokNode *FreeList = NULL;\r
-       TokNode *p, *newblk;\r
-\r
-       if ( FreeList == NULL )\r
-       {\r
-               newblk = (TokNode *)calloc(TokenBlockAllocSize, sizeof(TokNode));\r
-               if ( newblk == NULL )\r
-                       fatal_internal(eMsg1("out of memory while building rule '%s'",CurRule));\r
-               for (p=newblk; p<&(newblk[TokenBlockAllocSize]); p++)\r
-               {\r
-                       p->next = (Node *)FreeList;     /* add all new token nodes to FreeList */\r
-                       FreeList = p;\r
-               }\r
-       }\r
-       p = FreeList;\r
-       FreeList = (TokNode *)FreeList->next;/* remove a TokNode node */\r
-       p->next = NULL;                                         /* NULL the ptr we used */\r
-    memset( (char *) p, 0, sizeof(TokNode));        /* MR10 */\r
-       p->ntype = nToken;\r
-       p->rname = CurRule;\r
-       p->file = CurFile;\r
-       p->line = zzline;\r
-       p->altstart = NULL;\r
-\r
-       return p;\r
-}\r
-\r
-RuleRefNode *\r
-#ifdef __USE_PROTOS\r
-newRNode( void )\r
-#else\r
-newRNode( )\r
-#endif\r
-{\r
-       static RuleRefNode *FreeList = NULL;\r
-       RuleRefNode *p, *newblk;\r
-\r
-       if ( FreeList == NULL )\r
-       {\r
-               newblk = (RuleRefNode *)calloc(RRefBlockAllocSize, sizeof(RuleRefNode));\r
-               if ( newblk == NULL )\r
-                       fatal_internal(eMsg1("out of memory while building rule '%s'",CurRule));\r
-               for (p=newblk; p<&(newblk[RRefBlockAllocSize]); p++)\r
-               {\r
-                       p->next = (Node *)FreeList;     /* add all new rref nodes to FreeList */\r
-                       FreeList = p;\r
-               }\r
-       }\r
-       p = FreeList;\r
-       FreeList = (RuleRefNode *)FreeList->next;/* remove a Junction node */\r
-       p->next = NULL;                                         /* NULL the ptr we used */\r
-    memset( (char *) p, 0, sizeof(RuleRefNode));        /* MR10 */\r
-       p->ntype = nRuleRef;\r
-       p->rname = CurRule;\r
-       p->file = CurFile;\r
-       p->line = zzline;\r
-       p->astnode = ASTinclude;\r
-       p->altstart = NULL;\r
-       \r
-       return p;\r
-}\r
-\r
-static int junctionSeqNumber=0;         /* MR10 */\r
-\r
-Junction *\r
-#ifdef __USE_PROTOS\r
-newJunction( void )\r
-#else\r
-newJunction( )\r
-#endif\r
-{\r
-       static Junction *FreeList = NULL;\r
-       Junction *p, *newblk;\r
-\r
-       if ( FreeList == NULL )\r
-       {\r
-               newblk = (Junction *)calloc(JunctionBlockAllocSize, sizeof(Junction));\r
-               if ( newblk == NULL )\r
-                       fatal_internal(eMsg1("out of memory while building rule '%s'",CurRule));\r
-               for (p=newblk; p<&(newblk[JunctionBlockAllocSize]); p++)\r
-               {\r
-                       p->p1 = (Node *)FreeList;       /* add all new Junction nodes to FreeList */\r
-                       FreeList = p;\r
-               }\r
-       }\r
-       p = FreeList;\r
-       FreeList = (Junction *)FreeList->p1;/* remove a Junction node */\r
-       p->p1 = NULL;                                           /* NULL the ptr we used */\r
-    memset( (char *) p, 0, sizeof(Junction));       /* MR10 */\r
-       p->ntype = nJunction;\r
-       p->visited = 0;\r
-       p->jtype = Generic;\r
-       p->rname = CurRule;\r
-       p->file = CurFile;\r
-       p->line = zzline;\r
-       p->exception_label = NULL;\r
-       p->fset = (set *) calloc(CLL_k+1, sizeof(set));\r
-       require(p->fset!=NULL, "cannot allocate fset in newJunction");\r
-    p->seq=++junctionSeqNumber;     /* MR10 */\r
-\r
-       return p;\r
-}\r
-\r
-ActionNode *\r
-#ifdef __USE_PROTOS\r
-newActionNode( void )\r
-#else\r
-newActionNode( )\r
-#endif\r
-{\r
-       static ActionNode *FreeList = NULL;\r
-       ActionNode *p, *newblk;\r
-\r
-       if ( FreeList == NULL )\r
-       {\r
-               newblk = (ActionNode *)calloc(ActionBlockAllocSize, sizeof(ActionNode));\r
-               if ( newblk == NULL )\r
-                       fatal_internal(eMsg1("out of memory while building rule '%s'",CurRule));\r
-               for (p=newblk; p<&(newblk[ActionBlockAllocSize]); p++)\r
-               {\r
-                       p->next = (Node *)FreeList;     /* add all new Action nodes to FreeList */\r
-                       FreeList = p;\r
-               }\r
-       }\r
-       p = FreeList;\r
-       FreeList = (ActionNode *)FreeList->next;/* remove an Action node */\r
-    memset( (char *) p, 0, sizeof(ActionNode));     /* MR10 */\r
-       p->ntype = nAction;\r
-       p->next = NULL;                                         /* NULL the ptr we used */\r
-       p->done = 0;\r
-       p->pred_fail = NULL;\r
-       p->guardpred = NULL;\r
-    p->ampersandPred = NULL;\r
-       return p;\r
-}\r
-\r
-/*\r
- * allocate the array of locks (1..CLL_k) used to inhibit infinite recursion.\r
- * Infinite recursion can occur in (..)* blocks, FIRST calcs and FOLLOW calcs.\r
- * Therefore, we need locks on aLoopBlk, RuleBlk, EndRule nodes.\r
- *\r
- * if ( lock[k]==TRUE ) then we have been here before looking for k tokens\r
- * of lookahead.\r
- */\r
-char *\r
-#ifdef __USE_PROTOS\r
-makelocks( void )\r
-#else\r
-makelocks( )\r
-#endif\r
-{\r
-       char *p = (char *) calloc(CLL_k+1, sizeof(char));\r
-       require(p!=NULL, "cannot allocate lock array");\r
-       \r
-       return p;\r
-}\r
-\r
-#if 0\r
-** #ifdef __USE_PROTOS\r
-** void my_memset(char *p,char value,int count)\r
-** #else\r
-** void my_memset(p,value,count)\r
-**   char      *p;\r
-**   char      value;\r
-**   int       count;\r
-** #endif\r
-** {\r
-**    int      i;\r
-**\r
-**    for (i=0; i<count; i++) {\r
-**     p[i]=value;\r
-**   };\r
-** }\r
-#endif\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/antlr/build.xml b/Tools/CodeTools/TianoTools/Pccts/antlr/build.xml
deleted file mode 100644 (file)
index dfc1455..0000000
+++ /dev/null
@@ -1,129 +0,0 @@
-<?xml version="1.0" ?>\r
-<!--\r
-Copyright (c) 2006, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
--->\r
-<project default="GenTool" basedir=".">\r
-<!--\r
-    EDK antlr Tool\r
-  Copyright (c) 2006, Intel Corporation\r
--->\r
-  <property name="ToolName" value="antlr"/>\r
-\r
-  <taskdef resource="cpptasks.tasks"/>\r
-  <typedef resource="cpptasks.types"/>\r
-  <taskdef resource="net/sf/antcontrib/antlib.xml"/>\r
-\r
-  <target name="init">\r
-               <condition property="CheckDepends">\r
-                 <uptodate targetfile="${WORKSPACE}/Tools/bin/antlr.exe">\r
-                         <srcfiles dir="." includes="*.c *.h *.g"/>\r
-                       </uptodate>\r
-               </condition>\r
-               <if>\r
-                 <equals arg1="${CheckDepends}" arg2="true"/>\r
-                       <then>\r
-                               <echo message="Executable, antlr.exe, is up to date."/>\r
-                       </then>\r
-      <else>\r
-        <echo message="Building the EDK Pccts Tool: ${ToolName}"/>\r
-      </else>\r
-               </if>\r
-  </target>\r
-\r
-  <target name="GenTool" depends="init" unless="CheckDepends">\r
-    <if>\r
-      <equals arg1="${ToolChain}" arg2="msvc"/>\r
-                       <then>\r
-         <exec dir="${PACKAGE_DIR}/Pccts/antlr" executable="nmake" failonerror="TRUE">\r
-                 <arg line="-f AntlrMS.mak"/>\r
-               </exec>\r
-                 </then>\r
-               <elseif>\r
-        <istrue value="${cygwin}"/>\r
-                   <then>\r
-           <exec dir="${PACKAGE_DIR}/Pccts/antlr" executable="make" failonerror="TRUE">\r
-                 <arg line="-f makefile.cygwin"/>\r
-               </exec>\r
-                   </then>\r
-      </elseif>\r
-      <elseif>\r
-        <istrue value="${gcc}"/>\r
-        <then>\r
-           <exec dir="${PACKAGE_DIR}/Pccts/antlr" executable="make" failonerror="TRUE">\r
-                 <arg line="-f makefile BIN_DIR=${BIN_DIR}"/>\r
-               </exec>\r
-        </then>\r
-                 </elseif>\r
-               </if>\r
-    <echo message="The EDK Tool: ${ToolName} build has completed!"/>\r
-       </target>\r
-\r
-  <target name="clean">\r
-    <echo message="Removing Intermediate Files Only"/>  \r
-    <if>\r
-      <equals arg1="${ToolChain}" arg2="msvc"/>\r
-                       <then>\r
-         <exec dir="${PACKAGE_DIR}/Pccts/antlr" executable="nmake" failonerror="TRUE">\r
-                 <arg line="-f AntlrMS.mak clean"/>\r
-               </exec>\r
-                 </then>\r
-    <elseif>\r
-      <istrue value="${cygwin}"/>\r
-      <then>\r
-         <exec dir="${PACKAGE_DIR}/Pccts/antlr" executable="make" failonerror="TRUE">\r
-                 <arg line="-f makefile.cygwin clean"/>\r
-               </exec>\r
-      </then>\r
-               </elseif>\r
-               <elseif>\r
-      <istrue value="${gcc}"/>\r
-      <then>\r
-         <exec dir="${PACKAGE_DIR}/Pccts/antlr" executable="make" failonerror="TRUE">\r
-                 <arg line="-f makefile clean"/>\r
-               </exec>\r
-      </then>\r
-               </elseif>\r
-               </if>\r
-  </target>\r
-\r
-  <target name="cleanall">\r
-    <echo message="Removing Object Files and the Executable: ${ToolName}${ext_exe}"/>  \r
-    <if>\r
-      <equals arg1="${ToolChain}" arg2="msvc"/>\r
-                       <then>\r
-         <exec dir="${PACKAGE_DIR}/Pccts/antlr" executable="nmake" failonerror="FALSE">\r
-                 <arg line="-f AntlrMS.mak clean"/>\r
-               </exec>\r
-                 </then>\r
-               <elseif>\r
-      <istrue value="${cygwin}"/>\r
-                       <then>\r
-        <echo message="Building antlr with cygwin gcc"/>\r
-         <exec dir="${PACKAGE_DIR}/Pccts/antlr" executable="make" failonerror="FALSE">\r
-                 <arg line="-f makefile.cygwin clean"/>\r
-               </exec>\r
-                 </then>\r
-               </elseif>\r
-               <elseif>\r
-      <istrue value="${gcc}"/>\r
-      <then>\r
-        <echo message="Building antlr with gcc"/>\r
-         <exec dir="${PACKAGE_DIR}/Pccts/antlr" executable="make" failonerror="FALSE">\r
-                 <arg line="-f makefile clean"/>\r
-               </exec>\r
-      </then>\r
-               </elseif>\r
-               </if>\r
-    <delete failonerror="false" quiet="true" includeEmptyDirs="true">\r
-      <fileset file="${BIN_DIR}/${ToolName}${ext_exe}"/>\r
-    </delete>\r
-  </target>\r
-\r
-</project>\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/antlr/dumpcycles.c b/Tools/CodeTools/TianoTools/Pccts/antlr/dumpcycles.c
deleted file mode 100644 (file)
index 8156159..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-#include <stdio.h>\r
-#include <ctype.h>\r
-\r
-#include "set.h"\r
-#include "syn.h"\r
-#include "hash.h"\r
-#include "generic.h"\r
-\r
-void \r
-#ifdef __USE_PROTOS\r
-dumpcycles(void)\r
-#else\r
-dumpcycles()\r
-#endif\r
-{\r
-  Cycle         *c;\r
-  CacheEntry    *f;\r
-  ListNode      *p;\r
-  int           i=0;\r
-  int           k;\r
-  int           degree;\r
-\r
-  for (k=1; k <= CLL_k; k++) {\r
-    if (Cycles[k] == NULL) continue;\r
-\r
-    for (p = Cycles[k]->next; p!=NULL; p=p->next) {\r
-         c = (Cycle *) p->elem;\r
-      degree=set_deg(c->cyclicDep);\r
-         fprintf(stderr,"Cycle %d: (degree %d) %s -->\n", i++, degree, RulePtr[c->croot]->rname);\r
-      fprintf(stderr,"    *self*\n");\r
-      MR_dumpRuleSet(c->cyclicDep);\r
-      fprintf(stderr,"\n");\r
-         f = (CacheEntry *)\r
-                       hash_get(Fcache,Fkey(RulePtr[c->croot]->rname,'o',k));\r
-      if (f == NULL) {\r
-        fprintf(stderr,"    *** FOLLOW(%s) must be in cache but isn't ***\n",\r
-                                         RulePtr[c->croot]->rname);\r
-      };\r
-    };\r
-  };\r
-}\r
-\r
-void \r
-#ifdef __USE_PROTOS\r
-dumpfostack(int k) \r
-#else\r
-dumpfostack(k) \r
-int k;\r
-#endif\r
-{\r
-  int   i=0;\r
-  int   *pi;\r
-\r
-  fprintf(stderr,"\n");\r
-  if (FoStack[k] == NULL) {\r
-    fprintf(stderr,"FoStack[%d] is null\n",k);\r
-  };\r
-  if (FoTOS[k] == NULL) {\r
-    fprintf(stderr,"FoTOS[%d] is null\n",k);\r
-  }\r
-  if (FoTOS[k] != NULL && FoStack[k] != NULL) {\r
-    for (pi=FoStack[k]; pi <= FoTOS[k]; pi++) {\r
-      i++;\r
-      fprintf(stderr,"#%d  rule %d  %s\n",i,*pi,RulePtr[*pi]->rname);\r
-    }\r
-  }\r
-}\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/antlr/dumpnode.c b/Tools/CodeTools/TianoTools/Pccts/antlr/dumpnode.c
deleted file mode 100644 (file)
index 2a34c6f..0000000
+++ /dev/null
@@ -1,423 +0,0 @@
-#include <stdio.h>\r
-#include <ctype.h>\r
-\r
-#include "set.h"\r
-#include "syn.h"\r
-#include "hash.h"\r
-#include "generic.h"\r
-\r
-#ifdef __USE_PROTOS\r
-void dumpset1(set s)\r
-#else\r
-void dumpset1(s)\r
-  set   s;\r
-#endif\r
-{\r
-  if (set_nil(s)) {\r
-    fprintf(stderr,"{}");\r
-  } else {\r
-    s_fprT(stderr,s);\r
-  };\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-void dumpset(set s)\r
-#else\r
-void dumpset(s)\r
-  set   s;\r
-#endif\r
-{\r
-  dumpset1(s);\r
-  fprintf(stderr,"\n");\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-int isEndRule(Node * p)\r
-#else\r
-int isEndRule(p)\r
-  Node *    p;\r
-#endif\r
-{\r
-  int       result=0;\r
-  if ( p->ntype == nJunction &&\r
-       ( (Junction *) p)->jtype == EndRule) {\r
-    result=1;\r
-  };\r
-  return result;\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-void dumppred1(int depth,Predicate *p)\r
-#else\r
-void dumppred1(depth,p)\r
-  int           depth;\r
-  Predicate     *p;\r
-#endif\r
-{\r
-  int       i;\r
-  int       k;\r
-\r
-  for (i=0; i<depth ; i++) {\r
-    fprintf(stderr,"  ");\r
-  };\r
-  if (p->expr == PRED_AND_LIST ||\r
-      p->expr == PRED_OR_LIST) {\r
-    fprintf(stderr," %s", (p->expr == NULL ? "null expr" : p->expr));\r
-    if (p->inverted) fprintf(stderr," predicate inverted !");\r
-    if (p->redundant) {\r
-      fprintf(stderr," Redundant!");\r
-    };\r
-    if (p->isConst) fprintf(stderr," const %d !",p->constValue);\r
-    fprintf(stderr,"\n");\r
-  } else {\r
-    fprintf(stderr,"predicate k=%d",p->k);\r
-    k=set_int(p->completionSet);\r
-    if (k >= 0) {\r
-      fprintf(stderr," Incomplete Set=%d !",k);\r
-    };\r
-    k=set_int(p->completionTree);\r
-    if (k >= 0) {\r
-      fprintf(stderr," Incomplete Tree=%d !",k);\r
-    };\r
-    if (p->redundant) {\r
-      fprintf(stderr," Redundant!");\r
-    };\r
-    fprintf(stderr," \"%s\" (%x)", (p->expr == NULL ? "null expr" : p->expr) ,p);\r
-    if (p->source != NULL) {\r
-       fprintf(stderr,"line %d",p->source->line);\r
-    };\r
-    if (p->inverted) fprintf(stderr," predicate inverted !");\r
-    fprintf(stderr,"\n");\r
-    for (i=0; i<depth ; i++) {\r
-      fprintf(stderr,"  ");\r
-    };\r
-    fprintf(stderr,"scontext: ");\r
-    dumpset(p->scontext[1]);\r
-    for (i=0; i<depth ; i++) {\r
-      fprintf(stderr,"  ");\r
-    };\r
-    fprintf(stderr,"tcontext: ");\r
-    preorder(p->tcontext);\r
-    fprintf(stderr,"\n");\r
-  };\r
-  fprintf(stderr,"\n");\r
-  if (p->down != NULL) {\r
-    dumppred1(depth+1,p->down);\r
-  };\r
-  if (p->right != NULL) {\r
-    dumppred1(depth,p->right);\r
-  };\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-void dumppred(Predicate *p)\r
-#else\r
-void dumppred(p)\r
-  Predicate     *p;\r
-#endif\r
-{\r
-  fprintf(stderr,"---------------------------------\n");\r
-  dumppred1(0,p);\r
-  fprintf(stderr,"\n");\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-void dumppredtree(Predicate *p)\r
-#else\r
-void dumppredtree(p)\r
-  Predicate     *p;\r
-#endif\r
-{\r
-  fprintf(stderr,"predicate k=%d \"%s\" line %d\n",p->k,p->expr,p->source->line);\r
-  dumpset(p->scontext[1]);\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-void dumppredexpr(Predicate *p)\r
-#else\r
-void dumppredexpr(p)\r
-  Predicate     *p;\r
-#endif\r
-{\r
-  fprintf(stderr,"    pred expr \"%s\"\n",p->expr);\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-void dt(Tree *t)\r
-#else\r
-void dt(t)\r
-  Tree  *t;\r
-#endif\r
-{\r
-  MR_dumpTreeF(stderr,0,t,5);\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-void d(Node * p)\r
-#else\r
-void d(p)\r
-  Node *    p;\r
-#endif\r
-{\r
-\r
-  Junction      *j;\r
-  RuleRefNode   *r;\r
-  TokNode       *t;\r
-  ActionNode    *a;\r
-\r
-  if (p==NULL) {\r
-    fprintf(stderr,"dumpNode: Node is NULL");\r
-    return;\r
-  };\r
-\r
-  switch (p->ntype) {\r
-    case nJunction :\r
-      j = (Junction *) p;\r
-      fprintf(stderr, "Junction (#%d in rule %s line %d) ",j->seq,j->rname,j->line);\r
-      if (j->guess) fprintf(stderr,"guess block ");\r
-      switch (j->jtype ) {\r
-        case aSubBlk :\r
-          fprintf(stderr,"aSubBlk");\r
-          break;\r
-        case aOptBlk :\r
-          fprintf(stderr,"aOptBlk");\r
-          break;\r
-        case aLoopBegin :\r
-          fprintf(stderr,"aLoopBeginBlk");\r
-          break;\r
-        case aLoopBlk :\r
-          fprintf(stderr,"aLoopBlk");\r
-          break;\r
-        case aPlusBlk :\r
-          fprintf(stderr,"aPlusBlk");\r
-          break;\r
-        case EndBlk :\r
-          fprintf(stderr,"EndBlk");\r
-          break;\r
-        case RuleBlk :\r
-          fprintf(stderr,"RuleBlk");\r
-          break;\r
-        case Generic :\r
-          fprintf(stderr,"Generic");\r
-          break;\r
-        case EndRule :\r
-          fprintf(stderr,"EndRule");\r
-          break;\r
-      };\r
-      if (j->halt) fprintf(stderr,"  halt!");\r
-      if (j->p1) fprintf(stderr," p1 valid");\r
-      if (j->p2) {\r
-        if (j->p2->ntype == nJunction) {\r
-           fprintf(stderr," (p2=#%d)",( (Junction *) j->p2)->seq);\r
-        } else {\r
-           fprintf(stderr," (p2 valid)");\r
-        };\r
-      };\r
-         if (j->ignore) fprintf(stderr, " ignore/plus-block-bypass");\r
-      if (j->fset != NULL && set_deg(*j->fset) != 0) {\r
-         fprintf(stderr,"\nfset:\n");\r
-         dumpset(*j->fset);\r
-      };\r
-      if (j->ftree != NULL) {\r
-         fprintf(stderr,"\nftree:\n");\r
-         preorder(j->ftree);\r
-      };\r
-      fprintf(stderr,"\n");\r
-      break;\r
-    case nRuleRef :\r
-       r = (RuleRefNode *) p;\r
-       fprintf(stderr, "RuleRefNode (in rule %s line %d) to rule %s\n", r->rname,r->line,r->text);\r
-       break;\r
-    case nToken :\r
-       t = (TokNode *) p;\r
-       fprintf(stderr, "TokNode (in rule %s line %d) token %s\n",t->rname,t->line,TerminalString(t->token));\r
-       break;\r
-    case nAction :\r
-       a =(ActionNode *) p;\r
-       if (a->is_predicate) {\r
-         fprintf(stderr, "Predicate (in rule %s line %d) %s",a->rname,a->line,a->action);\r
-         if (a->inverted) fprintf(stderr," action inverted !");\r
-         if (a->guardpred != NULL) {\r
-           fprintf(stderr," guarded");\r
-           dumppredexpr(a->guardpred);\r
-           if (a->ampersandPred) {\r
-             fprintf(stderr," \"&&\" style");\r
-           } else {\r
-             fprintf(stderr," \"=>\" style");\r
-           };\r
-         };\r
-         if (a->predEntry != NULL) fprintf(stderr," predEntry \"%s\" ",a->predEntry->str);\r
-         fprintf(stderr,"\n");\r
-       } else if (a->init_action) {\r
-         fprintf(stderr, "Init-Action (in rule %s line %d) %s\n",a->rname,a->line,a->action);\r
-       } else {\r
-         fprintf(stderr, "Action (in rule %s line %d) %s\n",a->rname,a->line,a->action);\r
-       };\r
-       break;\r
-   };\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-Node * dp1(Node * p)\r
-#else\r
-Node * dp1(p)\r
-  Node *    p;\r
-#endif\r
-{\r
-  Node  *result=NULL;\r
-\r
-  if (p->ntype == nJunction) {\r
-    result=( (Junction *) p )->p1;\r
-    d(result);\r
-  } else {\r
-    fprintf(stderr,"dp1: Not a Junction node");\r
-  };\r
-  return result;\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-Node * dp2(Node * p)\r
-#else\r
-Node * dp2(p)\r
-  Node *    p;\r
-#endif\r
-{\r
-  Node  *result=NULL;\r
-\r
-  if (p->ntype == nJunction) {\r
-    result=( (Junction *) p )->p2;\r
-    d(result);\r
-  } else {\r
-    fprintf(stderr,"dp2: Not a Junction node");\r
-  };\r
-  return result;\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-Node * dn(Node * p)\r
-#else\r
-Node * dn(p)\r
-  Node *    p;\r
-#endif\r
-\r
-{\r
-  Node  *result=NULL;\r
-\r
-  if (p->ntype == nRuleRef) {\r
-    result=( (RuleRefNode *)p )->next;\r
-  } else if (p->ntype == nAction) {\r
-    result=( (ActionNode *)p )->next;\r
-  } else if (p->ntype == nToken) {\r
-    result=( (TokNode *)p )->next;\r
-  } else {\r
-    fprintf(stderr,"No next field: Neither a RuleRefNode, ActionNode, nor TokNode");\r
-  };\r
-  if (result != NULL) d(result);\r
-  return result;\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-void df(Node * p)\r
-#else\r
-void df(p)\r
-  Node *    p;\r
-#endif\r
-{\r
-  int       count=0;\r
-  Node      *next;\r
-\r
-  fprintf(stderr,"\n#%d ",++count);\r
-  d(p);\r
-\r
-  for (next=p; next != NULL && !isEndRule(next) ; ) {\r
-    fprintf(stderr,"#%d ",++count);\r
-    if (next->ntype == nJunction) {\r
-      next=dp1(next);\r
-    } else {\r
-      next=dn(next);\r
-    };\r
-  };\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-Node * dfn(Node * p,int target)\r
-#else\r
-Node * dfn(p,target)\r
-  Node *    p;\r
-  int       target;\r
-#endif\r
-{\r
-  Node      *result=NULL;\r
-  int       count=0;\r
-  Node      *next;\r
-\r
-  fprintf(stderr,"#%d ",++count);\r
-  d(p);\r
-\r
-  for (next=p; next != NULL && !isEndRule(next) ; ) {\r
-    fprintf(stderr,"#%d ",++count);\r
-    if (next->ntype == nJunction) {\r
-      next=dp1(next);\r
-    } else {\r
-      next=dn(next);\r
-    };\r
-    if (count == target) {\r
-      result=next;\r
-      break;\r
-    };\r
-  };\r
-  return result;\r
-}\r
-\r
-\r
-static int findnodeMatch;\r
-\r
-#ifdef __USE_PROTOS\r
-Junction *findnode1(Node *n)\r
-#else\r
-Junction *findnode1(n)\r
-  Node  *n;\r
-#endif\r
-{\r
-   Node         *next;\r
-   Junction     *j;\r
-   Junction     *match;\r
-\r
-   if (n == NULL) return NULL;\r
-   if (n->ntype == nJunction) {\r
-     j=(Junction *) n;\r
-     if (j->seq == findnodeMatch) return j;\r
-     if (j->jtype == EndRule) return NULL;\r
-     if (j->jtype != RuleBlk && j->jtype != EndBlk) {\r
-       if (j->p2 != NULL && !j->ignore) {\r
-          match=findnode1(j->p2);\r
-          if (match != NULL) return match;\r
-       };\r
-     };\r
-   };\r
-   next=MR_advance(n);\r
-   return findnode1(next);\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-Junction *findnode(int match)\r
-#else\r
-Junction *findnode(match)\r
-  int   match;\r
-#endif\r
-{\r
-  Junction  *j;\r
-  Junction  *result=NULL;\r
-\r
-  findnodeMatch=match;\r
-\r
-  for (j=SynDiag; j != NULL; j=(Junction *)j->p2) {\r
-    require (j->ntype == nJunction && j->jtype == RuleBlk,"Not a rule block");\r
-    result=findnode1( (Node *) j);\r
-    if (result != NULL) break;\r
-  };\r
-  if (result != NULL) {\r
-    d( (Node *) result);\r
-  };\r
-  return result;\r
-}\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/antlr/egman.c b/Tools/CodeTools/TianoTools/Pccts/antlr/egman.c
deleted file mode 100644 (file)
index c8a633f..0000000
+++ /dev/null
@@ -1,328 +0,0 @@
-/*\r
- * egman.c\r
- *\r
- * SOFTWARE RIGHTS\r
- *\r
- * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
- * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
- * company may do whatever they wish with source code distributed with\r
- * PCCTS or the code generated by PCCTS, including the incorporation of\r
- * PCCTS, or its output, into commerical software.\r
- *\r
- * We encourage users to develop software with PCCTS.  However, we do ask\r
- * that credit is given to us for developing PCCTS.  By "credit",\r
- * we mean that if you incorporate our source code into one of your\r
- * programs (commercial product, research project, or otherwise) that you\r
- * acknowledge this fact somewhere in the documentation, research report,\r
- * etc...  If you like PCCTS and have developed a nice tool with the\r
- * output, please mention that you developed it using PCCTS.  In\r
- * addition, we ask that this header remain intact in our source code.\r
- * As long as these guidelines are kept, we expect to continue enhancing\r
- * this system and expect to make other tools available as they are\r
- * completed.\r
- *\r
- * ANTLR 1.33MR10\r
- * 2001\r
- *\r
- */\r
-\r
-#include <stdio.h>\r
-#include <stdlib.h>\r
-\r
-#include "set.h"\r
-#include "syn.h"\r
-#include "hash.h"\r
-#include "generic.h"\r
-#include "proto.h"\r
-\r
-static ExceptionGroup **egArray=NULL;   /* ExceptionGroup by BlkLevel */\r
-static LabelEntry     **leArray=NULL;   /* LabelEntry by BlkLevel     */\r
-static Junction       **altArray=NULL;  /* start of alternates        */\r
-static int              arraySize=0;\r
-static int              highWater=0;\r
-static ExceptionGroup *lastEG=NULL;     /* used in altFixup()         */\r
-static int             lastBlkLevel=0;  /* used in altFixup()         */\r
-\r
-#ifdef __USE_PROTOS\r
-static void arrayCheck(void);\r
-#else\r
-static void arrayCheck();\r
-#endif\r
-\r
-/* Called to add an exception group for an alternative EG */\r
-\r
-#ifdef __USE_PROTOS\r
-void egAdd(ExceptionGroup * eg)\r
-#else\r
-void egAdd(eg)\r
-ExceptionGroup *eg;\r
-#endif\r
-{\r
-  int               i;\r
-\r
-  ExceptionGroup    *nextEG;\r
-  ExceptionGroup    *innerEG;\r
-\r
-  LabelEntry        *nextLE;\r
-  LabelEntry        *innerLE;\r
-\r
-  Junction          *nextAlt;\r
-  Junction          *innerAlt;\r
-\r
-  lastEG=eg;\r
-  lastBlkLevel=BlkLevel;\r
-\r
-  arrayCheck();\r
-  eg->pendingLink=egArray[BlkLevel];\r
-  egArray[BlkLevel]=eg;\r
-\r
-  /* EG for alternates already have their altID filled in      */\r
-\r
-  for (i=BlkLevel+1; i<=highWater ; i++) {\r
-    for (innerEG=egArray[i]; innerEG != NULL ; innerEG=nextEG) {\r
-      nextEG=innerEG->pendingLink;\r
-      innerEG->pendingLink=NULL;\r
-      innerEG->outerEG=eg;\r
-    };\r
-    egArray[i]=NULL;\r
-  };\r
-\r
-  /*\r
-   *  for patching up the LabelEntry you might use an EG for the\r
-   *  current alternative - unlike patching up an alternative EG\r
-   *    i.e. start the loop at BlkLevel rather than (BlkLevel+1)\r
-   *  fill it in only if the EG and the LE are for the very\r
-   *    same alternative if they're at the same BlkLevel\r
-   *  it's easier to leave the LE on this list (filled in) rather than\r
-   *    trying to selectively remove it.  It will eventually be\r
-   *    removed anyway when the BlkLevel gets small enough.\r
-   */\r
-\r
-  for (i=BlkLevel; i<=highWater ; i++) {\r
-    for (innerLE=leArray[i]; innerLE != NULL ; innerLE=nextLE) {\r
-      nextLE=innerLE->pendingLink;\r
-      if (BlkLevel != i ||\r
-        innerLE->curAltNum == CurAltNum_array[BlkLevel]) {\r
-        if (innerLE->outerEG == NULL) {\r
-          innerLE->outerEG=eg;\r
-        };\r
-      };\r
-    };\r
-    if (BlkLevel != i) leArray[i]=NULL;\r
-  };\r
-\r
-/*\r
- * For the start of alternatives it is necessary to make a\r
- * distinction between the exception group for the current\r
- * alternative and the "fallback" EG for the block which\r
- * contains the alternative\r
- *\r
- * The fallback outerEG is used to handle the case where\r
- * no alternative of a block matches.  In that case the\r
- * signal is "NoViableAlt" (or "NoSemViableAlt" and the\r
- * generator needs the EG of the block CONTAINING the\r
- * current one.\r
- *\r
- *      rule: ( ( ( a\r
- *                | b\r
- *                )\r
- *              | c\r
- *              )\r
- *            | d\r
- *            );\r
- */\r
-\r
-  for (i=BlkLevel; i <= highWater ; i++) {\r
-    for (innerAlt=altArray[i]; innerAlt != NULL ; innerAlt=nextAlt) {\r
-      nextAlt=innerAlt->pendingLink;\r
-\r
-      /*  first fill in the EG for the current alternative         */\r
-      /*  but leave it on the list in order to get the fallback EG */\r
-      /*  if the EG is at the same LEVEL as the alternative then   */\r
-      /*    fill it in only if in the very same alternative        */\r
-      /*                                                           */\r
-      /*        rule: ( a                                          */\r
-      /*              | b                                          */\r
-      /*              | c  exception ...                           */\r
-      /*              )                                            */\r
-      /*                                                           */\r
-      /*  if the EG is outside the alternative (e.g. BlkLevel < i) */\r
-      /*    then it doesn't matter about the alternative           */\r
-      /*                                                           */\r
-      /*        rule: ( a                                          */\r
-      /*              | b                                          */\r
-      /*              | c                                          */\r
-      /*              )   exception ...                            */\r
-      /*                                                           */\r
-\r
-#if 0\r
-      printf("BlkLevel=%d i=%d altnum=%d CurAltNum=%d altID=%s\n",\r
-        BlkLevel,i,innerAlt->curAltNum,CurAltNum_array[BlkLevel],eg->altID);\r
-#endif\r
-      if (BlkLevel != i ||\r
-          innerAlt->curAltNum == CurAltNum_array[BlkLevel]) {\r
-        if (innerAlt->exception_label == NULL) {\r
-          innerAlt->exception_label=eg->altID;\r
-        };\r
-      };\r
-\r
-      /*  ocurs at a later pass then for the exception_label       */\r
-      /*  if an outerEG has been found then fill in the outer EG   */\r
-      /*  remove if from the list when the BlkLevel gets smaller   */\r
-\r
-      if (BlkLevel != i) {\r
-        if (innerAlt->outerEG == NULL) {\r
-          innerAlt->outerEG=eg;\r
-        };\r
-      };\r
-    };\r
-    if (BlkLevel != i) altArray[i]=NULL;\r
-  };\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-void leAdd(LabelEntry * le)\r
-#else\r
-void leAdd(le)\r
-LabelEntry *le;\r
-#endif\r
-\r
-{\r
-  arrayCheck();\r
-  le->pendingLink=leArray[BlkLevel];\r
-  le->curAltNum=CurAltNum_array[BlkLevel];\r
-  leArray[BlkLevel]=le;\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-void altAdd(Junction *alt)\r
-#else\r
-void altAdd(alt)\r
-Junction *alt;\r
-#endif\r
-\r
-{\r
-  arrayCheck();\r
-#if 0\r
-  printf("BlkLevel=%d CurAltNum=%d\n",\r
-            BlkLevel,CurAltNum_array[BlkLevel]);\r
-#endif\r
-  alt->curAltNum=CurAltNum_array[BlkLevel];\r
-  alt->pendingLink=altArray[BlkLevel];\r
-  altArray[BlkLevel]=alt;\r
-}\r
-\r
-static void \r
-#ifdef __USE_PROTOS\r
-arrayCheck(void)\r
-#else\r
-arrayCheck()\r
-#endif\r
-{\r
-  ExceptionGroup    **egArrayNew;\r
-  LabelEntry        **leArrayNew;\r
-  Junction          **altArrayNew;\r
-  int               arraySizeNew;\r
-  int               i;\r
-\r
-  if (BlkLevel > highWater) highWater=BlkLevel;\r
-\r
-  if (BlkLevel >= arraySize) {\r
-    arraySizeNew=BlkLevel+5;   /* MR20 */\r
-    egArrayNew=(ExceptionGroup **)\r
-        calloc(arraySizeNew,sizeof(ExceptionGroup *));\r
-    leArrayNew=(LabelEntry **)\r
-        calloc(arraySizeNew,sizeof(LabelEntry *));\r
-    altArrayNew=(Junction **)\r
-        calloc(arraySizeNew,sizeof(Junction *));\r
-    for (i=0; i<arraySize ; i++) {\r
-      egArrayNew[i]=egArray[i];\r
-      leArrayNew[i]=leArray[i];\r
-      altArrayNew[i]=altArray[i];\r
-    };\r
-    arraySize=arraySizeNew;\r
-    if (egArray != NULL) free( (char *) egArray);\r
-    if (leArray != NULL) free( (char *) leArray);\r
-    if (altArray != NULL) free( (char *) altArray);\r
-    egArray=egArrayNew;\r
-    leArray=leArrayNew;\r
-    altArray=altArrayNew;\r
-  };\r
-}\r
-\r
-/* always call leFixup() BEFORE egFixup() */\r
-\r
-void \r
-#ifdef __USE_PROTOS\r
-egFixup(void) \r
-#else\r
-egFixup()\r
-#endif\r
-{\r
-  int               i;\r
-  ExceptionGroup    *nextEG;\r
-  ExceptionGroup    *innerEG;\r
-\r
-  for (i=1; i<=highWater ; i++) {\r
-    for (innerEG=egArray[i]; innerEG != NULL ; innerEG=nextEG) {\r
-      nextEG=innerEG->pendingLink;\r
-      innerEG->pendingLink=NULL;\r
-    };\r
-    egArray[i]=NULL;\r
-  };\r
-  lastEG=NULL;\r
-  lastBlkLevel=0;\r
-}\r
-\r
-/* always call leFixup() BEFORE egFixup() */\r
-\r
-#ifdef __USE_PROTOS\r
-void leFixup(void) \r
-#else\r
-void leFixup() \r
-#endif\r
-{\r
-\r
-  int               i;\r
-  LabelEntry        *nextLE;\r
-  LabelEntry        *innerLE;\r
-\r
-  for (i=BlkLevel; i<=highWater ; i++) {\r
-    for (innerLE=leArray[i]; innerLE != NULL ; innerLE=nextLE) {\r
-      nextLE=innerLE->pendingLink;\r
-      innerLE->pendingLink=NULL;\r
-    };\r
-    leArray[i]=NULL;\r
-  };\r
-}\r
-\r
-/* always call altFixup() BEFORE egFixup() */\r
-\r
-#ifdef __USE_PROTOS\r
-void altFixup(void)\r
-#else\r
-void altFixup() \r
-#endif\r
-{\r
-\r
-  int               i;\r
-  Junction          *nextAlt;\r
-  Junction          *innerAlt;\r
-\r
-  for (i=BlkLevel; i<=highWater ; i++) {\r
-    for (innerAlt=altArray[i]; innerAlt != NULL ; innerAlt=nextAlt) {\r
-\r
-      /*  if an outerEG has been found then fill in the outer EG   */\r
-\r
-      if (lastBlkLevel <= i) {\r
-        if (innerAlt->outerEG == NULL) {\r
-          innerAlt->outerEG=lastEG;\r
-        };\r
-      };\r
-      nextAlt=innerAlt->pendingLink;\r
-      innerAlt->pendingLink=NULL;\r
-    };\r
-    altArray[i]=NULL;\r
-  };\r
-}\r
-\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/antlr/err.c b/Tools/CodeTools/TianoTools/Pccts/antlr/err.c
deleted file mode 100644 (file)
index ca23939..0000000
+++ /dev/null
@@ -1,538 +0,0 @@
-/*\r
- * A n t l r  S e t s / E r r o r  F i l e  H e a d e r\r
- *\r
- * Generated from: antlr.g\r
- *\r
- * Terence Parr, Russell Quong, Will Cohen, and Hank Dietz: 1989-2001\r
- * Parr Research Corporation\r
- * with Purdue University Electrical Engineering\r
- * With AHPCRC, University of Minnesota\r
- * ANTLR Version 1.33MR33\r
- */\r
-\r
-#define ANTLR_VERSION  13333\r
-#include "pcctscfg.h"\r
-#include "pccts_stdio.h"\r
-\r
-#include "pcctscfg.h"\r
-#include "set.h"\r
-#include <ctype.h>\r
-#include "syn.h"\r
-#include "hash.h"\r
-#include "generic.h"\r
-#define zzcr_attr(attr,tok,t)\r
-#define zzSET_SIZE 20\r
-#include "antlr.h"\r
-#include "tokens.h"\r
-#include "dlgdef.h"\r
-#include "err.h"\r
-\r
-ANTLRChar *zztokens[157]={\r
-       /* 00 */        "Invalid",\r
-       /* 01 */        "Eof",\r
-       /* 02 */        "QuotedTerm",\r
-       /* 03 */        "\\n|\\r|\\r\\n",\r
-       /* 04 */        "\\(\\n|\\r|\\r\\n)",\r
-       /* 05 */        "\\~[]",\r
-       /* 06 */        "~[\\n\\r\"\\]+",\r
-       /* 07 */        "\"",\r
-       /* 08 */        "\\n|\\r|\\r\\n",\r
-       /* 09 */        "\\(\\n|\\r|\\r\\n)",\r
-       /* 10 */        "\\~[]",\r
-       /* 11 */        "~[\\n\\r\"\\]+",\r
-       /* 12 */        "'",\r
-       /* 13 */        "\\n|\\r|\\r\\n",\r
-       /* 14 */        "\\~[]",\r
-       /* 15 */        "~[\\n\\r'\\]+",\r
-       /* 16 */        "\\*/",\r
-       /* 17 */        "\\*",\r
-       /* 18 */        "\\n|\\r|\\r\\n",\r
-       /* 19 */        "~[\\n\\r\\*]+",\r
-       /* 20 */        "\\*/",\r
-       /* 21 */        "\\*",\r
-       /* 22 */        "\\n|\\r|\\r\\n",\r
-       /* 23 */        "~[\\n\\r\\*]+",\r
-       /* 24 */        "\\n|\\r|\\r\\n",\r
-       /* 25 */        "~[\\n\\r]+",\r
-       /* 26 */        "\\n|\\r|\\r\\n",\r
-       /* 27 */        "~[\\n\\r]+",\r
-       /* 28 */        "\\n|\\r|\\r\\n",\r
-       /* 29 */        "~[\\n\\r]+",\r
-       /* 30 */        "\\*/",\r
-       /* 31 */        "\\*",\r
-       /* 32 */        "\\n|\\r|\\r\\n",\r
-       /* 33 */        "~[\\n\\r\\*]+",\r
-       /* 34 */        "Action",\r
-       /* 35 */        "Pred",\r
-       /* 36 */        "PassAction",\r
-       /* 37 */        "consumeUntil\\( [\\ \\t]* \\{~[\\}]+\\} [\\ \\t]* \\)",\r
-       /* 38 */        "consumeUntil\\( ~[\\)]+ \\)",\r
-       /* 39 */        "\\n|\\r|\\r\\n",\r
-       /* 40 */        "\\>",\r
-       /* 41 */        "$",\r
-       /* 42 */        "$$",\r
-       /* 43 */        "$\\[\\]",\r
-       /* 44 */        "$\\[",\r
-       /* 45 */        "$[0-9]+",\r
-       /* 46 */        "$[0-9]+.",\r
-       /* 47 */        "$[0-9]+.[0-9]+",\r
-       /* 48 */        "$[_a-zA-Z][_a-zA-Z0-9]*",\r
-       /* 49 */        "#0",\r
-       /* 50 */        "#\\[\\]",\r
-       /* 51 */        "#\\(\\)",\r
-       /* 52 */        "#[0-9]+",\r
-       /* 53 */        "#line[\\ \\t]* [0-9]+ {[\\ \\t]* \"~[\"]+\" ([\\ \\t]* [0-9]*)* } (\\n|\\r|\\r\\n)",\r
-       /* 54 */        "#line ~[\\n\\r]* (\\n|\\r|\\r\\n)",\r
-       /* 55 */        "#[_a-zA-Z][_a-zA-Z0-9]*",\r
-       /* 56 */        "#\\[",\r
-       /* 57 */        "#\\(",\r
-       /* 58 */        "#",\r
-       /* 59 */        "\\)",\r
-       /* 60 */        "\\[",\r
-       /* 61 */        "\\(",\r
-       /* 62 */        "\\\\]",\r
-       /* 63 */        "\\\\)",\r
-       /* 64 */        "\\>",\r
-       /* 65 */        "'",\r
-       /* 66 */        "\"",\r
-       /* 67 */        "\\$",\r
-       /* 68 */        "\\#",\r
-       /* 69 */        "\\(\\n|\\r|\\r\\n)",\r
-       /* 70 */        "\\~[\\]\\)>$#]",\r
-       /* 71 */        "/",\r
-       /* 72 */        "/\\*",\r
-       /* 73 */        "\\*/",\r
-       /* 74 */        "//",\r
-       /* 75 */        "~[\\n\\r\\)\\(\\$#\\>\\]\\[\"'/]+",\r
-       /* 76 */        "[\\t\\ ]+",\r
-       /* 77 */        "\\n|\\r|\\r\\n",\r
-       /* 78 */        "\\[",\r
-       /* 79 */        "\\<\\<",\r
-       /* 80 */        "\"",\r
-       /* 81 */        "/\\*",\r
-       /* 82 */        "\\*/",\r
-       /* 83 */        "//",\r
-       /* 84 */        "#line[\\ \\t]* [0-9]+ {[\\ \\t]* \"~[\"]+\" ([\\ \\t]* [0-9]*)* } (\\n|\\r|\\r\\n)",\r
-       /* 85 */        "#line ~[\\n\\r]* (\\n|\\r|\\r\\n)",\r
-       /* 86 */        "\\>\\>",\r
-       /* 87 */        "WildCard",\r
-       /* 88 */        "\\@",\r
-       /* 89 */        "LABEL",\r
-       /* 90 */        "grammar-element",\r
-       /* 91 */        "meta-symbol",\r
-       /* 92 */        "Pragma",\r
-       /* 93 */        "FirstSetSymbol",\r
-       /* 94 */        "{\\}#header",\r
-       /* 95 */        "{\\}#first",\r
-       /* 96 */        "{\\}#parser",\r
-       /* 97 */        "{\\}#tokdefs",\r
-       /* 98 */        "\\}",\r
-       /* 99 */        "class",\r
-       /* 100 */       "NonTerminal",\r
-       /* 101 */       "TokenTerm",\r
-       /* 102 */       "\\{",\r
-       /* 103 */       "!",\r
-       /* 104 */       "\\<",\r
-       /* 105 */       "\\>",\r
-       /* 106 */       ":",\r
-       /* 107 */       ";",\r
-       /* 108 */       "{\\}#lexaction",\r
-       /* 109 */       "{\\}#lexmember",\r
-       /* 110 */       "{\\}#lexprefix",\r
-       /* 111 */       "{\\}#pred",\r
-       /* 112 */       "\\|\\|",\r
-       /* 113 */       "&&",\r
-       /* 114 */       "\\(",\r
-       /* 115 */       "\\)",\r
-       /* 116 */       "{\\}#lexclass",\r
-       /* 117 */       "{\\}#errclass",\r
-       /* 118 */       "{\\}#tokclass",\r
-       /* 119 */       "..",\r
-       /* 120 */       "{\\}#token",\r
-       /* 121 */       "=",\r
-       /* 122 */       "[0-9]+",\r
-       /* 123 */       "\\|",\r
-       /* 124 */       "\\~",\r
-       /* 125 */       "^",\r
-       /* 126 */       "approx",\r
-       /* 127 */       "LL\\(1\\)",\r
-       /* 128 */       "LL\\(2\\)",\r
-       /* 129 */       "\\*",\r
-       /* 130 */       "\\+",\r
-       /* 131 */       "?",\r
-       /* 132 */       "=>",\r
-       /* 133 */       "exception",\r
-       /* 134 */       "default",\r
-       /* 135 */       "catch",\r
-       /* 136 */       "{\\}#[A-Za-z0-9_]*",\r
-       /* 137 */       "[\\t\\ ]+",\r
-       /* 138 */       "\\n|\\r|\\r\\n",\r
-       /* 139 */       "//",\r
-       /* 140 */       "/\\*",\r
-       /* 141 */       "#ifdef",\r
-       /* 142 */       "#if",\r
-       /* 143 */       "#ifndef",\r
-       /* 144 */       "#else",\r
-       /* 145 */       "#endif",\r
-       /* 146 */       "#undef",\r
-       /* 147 */       "#import",\r
-       /* 148 */       "ID",\r
-       /* 149 */       "#define",\r
-       /* 150 */       "INT",\r
-       /* 151 */       "enum",\r
-       /* 152 */       "\\{",\r
-       /* 153 */       "=",\r
-       /* 154 */       ",",\r
-       /* 155 */       "\\}",\r
-       /* 156 */       ";"\r
-};\r
-SetWordType zzerr1[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,\r
-       0x30,0x0,0x0,0x0, 0x0,0x0,0x0,0x0};\r
-SetWordType zzerr2[20] = {0xfc,0xff,0xff,0xff, 0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xf3,\r
-       0xbf,0xff,0xff,0xff, 0xff,0xff,0xff,0x1f};\r
-SetWordType zzerr3[20] = {0xfc,0xff,0xff,0xff, 0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xfb,\r
-       0x3b,0xf7,0xf7,0xc7, 0xff,0xff,0xff,0x1f};\r
-SetWordType zzerr4[20] = {0x4,0x0,0x0,0x0, 0x10,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,\r
-       0x80,0x7,0x0,0x0, 0x0,0x0,0x0,0x0};\r
-SetWordType setwd1[157] = {0x0,0x50,0xa0,0x20,0x20,0x20,0x20,\r
-       0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,\r
-       0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,\r
-       0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,\r
-       0x20,0x20,0x20,0x6a,0x20,0xa0,0x20,0x20,\r
-       0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,\r
-       0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,\r
-       0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,\r
-       0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,\r
-       0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,\r
-       0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,\r
-       0x20,0x20,0x20,0x0,0x0,0x20,0x20,0x21,\r
-       0x21,0x21,0x21,0x6e,0x6e,0x64,0x20,0x0,\r
-       0x20,0xa0,0xa0,0xa0,0x20,0x6a,0x6a,0x6a,\r
-       0x6e,0x20,0x20,0x20,0x20,0x66,0x6e,0x6e,\r
-       0x20,0x66,0x20,0x20,0x20,0x20,0x20,0x20,\r
-       0x20,0x20,0x20,0x20,0x20,0x20,0x62,0x20,\r
-       0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,\r
-       0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,\r
-       0x20,0x20,0x20,0x20,0x20,0x20};\r
-SetWordType zzerr5[20] = {0x0,0x0,0x0,0x0, 0x10,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,\r
-       0x0,0x1,0x0,0x0, 0x0,0x0,0x0,0x0};\r
-SetWordType zzerr6[20] = {0x4,0x0,0x0,0x0, 0x10,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,\r
-       0x0,0x7,0x0,0x0, 0x0,0x0,0x0,0x0};\r
-SetWordType zzerr7[20] = {0x4,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,\r
-       0x0,0x6,0x0,0x0, 0x0,0x0,0x0,0x0};\r
-SetWordType zzerr8[20] = {0x4,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,\r
-       0x0,0x4,0x0,0x0, 0x0,0x0,0x0,0x0};\r
-SetWordType zzerr9[20] = {0x2,0x0,0x0,0x0, 0x4,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,\r
-       0x1c,0xf0,0x70,0x1, 0x20,0x0,0x0,0x0};\r
-SetWordType setwd2[157] = {0x0,0xf8,0x6,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0xf8,0x0,0x1,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0xf8,0xf8,0xf8,0x0,0x0,\r
-       0x0,0x1,0x2,0x6,0x0,0xf8,0xf8,0xf8,\r
-       0xf8,0x0,0x0,0x0,0x0,0xf8,0xf8,0xf8,\r
-       0x0,0xf8,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0xe8,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0};\r
-SetWordType zzerr10[20] = {0x2,0x0,0x0,0x0, 0x4,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,\r
-       0xbc,0xf8,0x74,0x1, 0x20,0x0,0x0,0x0};\r
-SetWordType zzerr11[20] = {0x0,0x0,0x0,0x0, 0x8,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,\r
-       0xa0,0x0,0x4,0x0, 0x0,0x0,0x0,0x0};\r
-SetWordType zzerr12[20] = {0x2,0x0,0x0,0x0, 0x4,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,\r
-       0x1c,0xf8,0x70,0x1, 0x20,0x0,0x0,0x0};\r
-SetWordType zzerr13[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,\r
-       0xa0,0x0,0x4,0x0, 0x0,0x0,0x0,0x0};\r
-SetWordType setwd3[157] = {0x0,0xfa,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0xfa,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0xfa,0xfa,0xfa,0x5,0x0,\r
-       0x5,0x0,0x0,0x0,0xe2,0xfa,0xfa,0xfa,\r
-       0xfa,0xc0,0x80,0x5,0xe0,0xfa,0xfa,0xfa,\r
-       0x0,0xfa,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0xfa,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0};\r
-SetWordType zzerr14[20] = {0x4,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,\r
-       0x20,0x0,0x0,0x0, 0x0,0x0,0x0,0x0};\r
-SetWordType zzerr15[20] = {0x4,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,\r
-       0x30,0x0,0x0,0x0, 0x0,0x0,0x0,0x0};\r
-SetWordType zzerr16[20] = {0x4,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,\r
-       0x30,0x0,0x0,0x0, 0x0,0x0,0x0,0x0};\r
-SetWordType zzerr17[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,\r
-       0x40,0x0,0x4,0x0, 0x0,0x0,0x0,0x0};\r
-SetWordType zzerr18[20] = {0x4,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,\r
-       0x24,0x0,0x80,0x0, 0x0,0x0,0x0,0x0};\r
-SetWordType zzerr19[20] = {0x4,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,\r
-       0x20,0x0,0x0,0x0, 0x0,0x0,0x0,0x0};\r
-SetWordType zzerr20[20] = {0x6,0x0,0x0,0x0, 0x4,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,\r
-       0x1c,0xf8,0x74,0x3, 0x20,0x0,0x0,0x0};\r
-SetWordType zzerr21[20] = {0x6,0x0,0x0,0x0, 0x4,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,\r
-       0x1c,0xf8,0x70,0x3, 0x20,0x0,0x0,0x0};\r
-SetWordType setwd4[157] = {0x0,0xe5,0xda,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0xe5,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0xed,0xe5,0xe7,0x1a,0x0,\r
-       0x0,0x0,0x0,0x0,0xc0,0xe5,0xe5,0xe5,\r
-       0xe5,0x0,0x0,0x0,0x0,0xe5,0xe5,0xe5,\r
-       0x0,0xe5,0x40,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0xe5,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0};\r
-SetWordType zzerr22[20] = {0x6,0x0,0x0,0x0, 0x4,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,\r
-       0x3c,0xf8,0x70,0x1, 0x20,0x0,0x0,0x0};\r
-SetWordType zzerr23[20] = {0x6,0x0,0x0,0x0, 0x4,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,\r
-       0x1c,0xf8,0x70,0x1, 0x20,0x0,0x0,0x0};\r
-SetWordType zzerr24[20] = {0x2,0x0,0x0,0x0, 0x4,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,\r
-       0x1c,0xf8,0x70,0x1, 0x20,0x0,0x0,0x0};\r
-SetWordType zzerr25[20] = {0x2,0x0,0x0,0x0, 0x4,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,\r
-       0x1c,0xf8,0x70,0x1, 0x20,0x0,0x0,0x0};\r
-SetWordType zzerr26[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x5,\r
-       0x4,0x8,0x8,0x18, 0x20,0x0,0x0,0x0};\r
-SetWordType setwd5[157] = {0x0,0x1f,0xc1,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0xdf,0xc0,0xc0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0xc0,0x0,0xc0,0x0,0x0,0xc0,0xc0,0x0,\r
-       0x0,0x0,0x0,0x7f,0x1f,0xdf,0xc0,0xc0,\r
-       0x0,0x0,0xc0,0x0,0x67,0x1f,0x1f,0x1f,\r
-       0x1f,0x0,0x0,0xc0,0x60,0x1f,0x1f,0x1f,\r
-       0x0,0x1f,0x0,0x0,0x40,0xc0,0x0,0x0,\r
-       0x0,0x0,0xc0,0xc0,0x0,0x0,0x5f,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0};\r
-SetWordType zzerr27[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x4,\r
-       0x0,0x0,0x0,0x10, 0x0,0x0,0x0,0x0};\r
-SetWordType zzerr28[20] = {0x4,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x80,0x2,\r
-       0x30,0x0,0x0,0x0, 0x0,0x0,0x0,0x0};\r
-SetWordType zzerr29[20] = {0x4,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,\r
-       0x20,0x0,0x0,0x0, 0x0,0x0,0x0,0x0};\r
-SetWordType zzerr30[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0xd,\r
-       0x0,0x0,0x80,0x0, 0x20,0x0,0x0,0x0};\r
-SetWordType zzerr31[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0xd,\r
-       0x0,0x0,0x0,0x0, 0x20,0x0,0x0,0x0};\r
-SetWordType zzerr32[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x5,\r
-       0x4,0x8,0x8,0x18, 0x20,0x0,0x0,0x0};\r
-SetWordType zzerr33[20] = {0x4,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,\r
-       0x20,0x0,0x0,0x0, 0x0,0x0,0x0,0x0};\r
-SetWordType setwd6[157] = {0x0,0x0,0xfd,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0xe1,0xe1,0xe1,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0xfd,0x60,0xe9,0x0,0x0,0xe1,0xe1,0x0,\r
-       0x0,0x0,0x0,0xe2,0x0,0xfd,0xfd,0xe1,\r
-       0x20,0x0,0xe1,0x0,0xe2,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0xe1,0xe2,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0xe2,0xe0,0x20,0x0,\r
-       0x0,0x0,0xe1,0xe1,0x0,0x0,0xe2,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0};\r
-SetWordType zzerr34[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0xd,\r
-       0x0,0x0,0x80,0x0, 0x20,0x0,0x0,0x0};\r
-SetWordType zzerr35[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0xd,\r
-       0x0,0x0,0x0,0x0, 0x20,0x0,0x0,0x0};\r
-SetWordType zzerr36[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x5,\r
-       0x4,0x8,0x8,0x18, 0x20,0x0,0x0,0x0};\r
-SetWordType zzerr37[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0xc,\r
-       0x0,0x0,0x0,0x0, 0x20,0x0,0x0,0x0};\r
-SetWordType zzerr38[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x4,\r
-       0x84,0x9,0x8,0x18, 0x20,0x0,0x0,0x0};\r
-SetWordType zzerr39[20] = {0x0,0x0,0x0,0x0, 0x10,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,\r
-       0x0,0x1,0x0,0x0, 0x0,0x0,0x0,0x0};\r
-SetWordType zzerr40[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x4,\r
-       0x4,0x9,0x8,0x18, 0x20,0x0,0x0,0x0};\r
-SetWordType zzerr41[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x4,\r
-       0x4,0x8,0x8,0x18, 0x20,0x0,0x0,0x0};\r
-SetWordType zzerr42[20] = {0x4,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x80,0x0,\r
-       0x30,0x0,0x0,0x0, 0x0,0x0,0x0,0x0};\r
-SetWordType setwd7[157] = {0x0,0x0,0xdf,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0xdf,0xdf,0xff,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0xdf,0x3,0xdf,0x0,0x0,0xdf,0xdf,0x0,\r
-       0x0,0x0,0x0,0xdf,0x0,0xdf,0xdf,0xdf,\r
-       0x1,0x30,0xdf,0x0,0xdf,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0xdf,0xdf,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0xdf,0xdf,0x1,0x0,\r
-       0x0,0x0,0xdf,0xdf,0x0,0x0,0xdf,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0};\r
-SetWordType zzerr43[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x4,\r
-       0x4,0x8,0x8,0x18, 0x20,0x0,0x0,0x0};\r
-SetWordType zzerr44[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0xc0, 0x1,0x0,0x0,0x0};\r
-SetWordType zzerr45[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x30,\r
-       0x40,0x0,0x4,0x0, 0x0,0x0,0x0,0x0};\r
-SetWordType zzerr46[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,\r
-       0x30,0x0,0x0,0x0, 0x0,0x0,0x0,0x0};\r
-SetWordType zzerr47[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x20,\r
-       0x40,0x0,0x4,0x0, 0x0,0x0,0x0,0x0};\r
-SetWordType zzerr48[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x2,0x0, 0x10,0x0,0x0,0x0};\r
-SetWordType zzerr49[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x4,\r
-       0x4,0x8,0x8,0x18, 0x20,0x0,0x0,0x0};\r
-SetWordType zzerr50[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x4,\r
-       0x4,0x8,0xa,0x18, 0x30,0x0,0x0,0x0};\r
-SetWordType zzerr51[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x4,\r
-       0x4,0x8,0x8,0x18, 0x28,0x0,0x0,0x0};\r
-SetWordType zzerr52[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,\r
-       0x40,0x0,0x4,0x0, 0x0,0x0,0x0,0x0};\r
-SetWordType zzerr53[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x4,\r
-       0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0};\r
-SetWordType setwd8[157] = {0x0,0x0,0xe1,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0xe1,0xe1,0xe1,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0xe1,0x0,0xe1,0x0,0x0,0xe3,0xe7,0x0,\r
-       0x0,0x0,0x0,0xe1,0x0,0xe1,0xe1,0xef,\r
-       0x0,0x0,0xe1,0x0,0xe1,0x0,0x0,0x0,\r
-       0x0,0x0,0x10,0xef,0xe1,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0xe1,0xe1,0x0,0x0,\r
-       0x0,0x0,0xe1,0xe1,0x0,0x10,0xe1,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0};\r
-SetWordType zzerr54[20] = {0x2,0x0,0x0,0x0, 0x14,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,\r
-       0x1c,0xf8,0x78,0x9, 0xe0,0x0,0x0,0x0};\r
-SetWordType zzerr55[20] = {0x2,0x0,0x0,0x0, 0x4,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,\r
-       0x1c,0xf8,0x78,0x9, 0x60,0x0,0x0,0x0};\r
-SetWordType zzerr56[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,\r
-       0x30,0x0,0x0,0x0, 0x0,0x0,0x0,0x0};\r
-SetWordType zzerr57[20] = {0x2,0x0,0x0,0x0, 0x4,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,\r
-       0x1c,0xf8,0x78,0x9, 0xe0,0x0,0x0,0x0};\r
-SetWordType setwd9[157] = {0x0,0x7c,0x1,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x7f,0x1,0x1,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x1,0x0,0x1,0x0,0x0,0x1,0x1,0x0,\r
-       0x0,0x0,0x0,0x7f,0x7e,0x7f,0x1,0x1,\r
-       0x0,0x0,0x1,0x0,0x7d,0x7e,0x7e,0x7e,\r
-       0x7e,0x0,0x0,0x1,0x7d,0x7e,0x7e,0x7e,\r
-       0x0,0x7e,0x0,0x0,0x7d,0x1,0x0,0x0,\r
-       0x0,0x0,0x1,0x1,0x0,0x0,0x7f,0x64,\r
-       0x64,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x80,0x0,0x0,0x0,0x0,0x0,0x80,0x0,\r
-       0x80,0x0,0x0,0x0,0x0,0x0};\r
-SetWordType zzerr58[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0, 0x0,0x0,0xa0,0x0};\r
-SetWordType zzerr59[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0, 0x0,0x80,0xa0,0x0};\r
-SetWordType zzerr60[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0, 0x0,0x0,0xa0,0x0};\r
-SetWordType zzerr61[20] = {0x2,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0, 0x0,0x80,0xa0,0x0};\r
-SetWordType zzerr62[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0xe};\r
-SetWordType zzerr63[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0xe};\r
-SetWordType zzerr64[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0xe};\r
-SetWordType zzerr65[20] = {0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0, 0x0,0x0,0x10,0xc};\r
-SetWordType setwd10[157] = {0x0,0xc,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x3,0x0,\r
-       0x3,0x0,0x0,0xf0,0xf0,0x0};\r
-SetWordType setwd11[157] = {0x0,0x1,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,\r
-       0x1,0x0,0x0,0x0,0x0,0x0};\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/antlr/fcache.c b/Tools/CodeTools/TianoTools/Pccts/antlr/fcache.c
deleted file mode 100644 (file)
index ff7dcdf..0000000
+++ /dev/null
@@ -1,123 +0,0 @@
-/*\r
- * fcache.c\r
- *\r
- * SOFTWARE RIGHTS\r
- *\r
- * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
- * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
- * company may do whatever they wish with source code distributed with\r
- * PCCTS or the code generated by PCCTS, including the incorporation of\r
- * PCCTS, or its output, into commerical software.\r
- *\r
- * We encourage users to develop software with PCCTS.  However, we do ask\r
- * that credit is given to us for developing PCCTS.  By "credit",\r
- * we mean that if you incorporate our source code into one of your\r
- * programs (commercial product, research project, or otherwise) that you\r
- * acknowledge this fact somewhere in the documentation, research report,\r
- * etc...  If you like PCCTS and have developed a nice tool with the\r
- * output, please mention that you developed it using PCCTS.  In\r
- * addition, we ask that this header remain intact in our source code.\r
- * As long as these guidelines are kept, we expect to continue enhancing\r
- * this system and expect to make other tools available as they are\r
- * completed.\r
- *\r
- * ANTLR 1.33MR10\r
- *\r
- */\r
-\r
-#include <stdio.h>\r
-#include <ctype.h>\r
-\r
-#include "pcctscfg.h"\r
-\r
-#include "set.h"\r
-#include "syn.h"\r
-#include "hash.h"\r
-#include "generic.h"\r
-\r
-#ifdef __USE_PROTOS\r
-CacheEntry *dumpFcache1(char *prev)\r
-#else\r
-CacheEntry *dumpFcache1(prev)\r
-  char  *prev;\r
-#endif\r
-{\r
-    Entry   **table=Fcache;\r
-\r
-    int     low=0;\r
-    int     hi=0;\r
-\r
-    CacheEntry  *least=NULL;\r
-\r
-       Entry   **p;\r
-\r
-       for (p=table; p<&(table[HashTableSize]); p++) {\r
-\r
-               CacheEntry *q =(CacheEntry *) *p;\r
-               \r
-               if ( q != NULL && low==0 ) low = p-table;\r
-               while ( q != NULL ) {\r
-            if (strcmp(q->str,prev) > 0) {\r
-              if (least == NULL) {\r
-                least=q;\r
-              } else {\r
-                if (strcmp(q->str,least->str) < 0) {\r
-                  least=q;\r
-                };\r
-              };\r
-            };\r
-                       q = q->next;\r
-               };\r
-\r
-               if ( *p != NULL ) hi = p-table;\r
-       }\r
-    return least;\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-void reportFcache(CacheEntry *q)\r
-#else\r
-void reportFcache(q)\r
-  CacheEntry    *q;\r
-#endif\r
-{\r
-    char        *qstr;\r
-\r
-    fprintf(stdout,"\nrule ");\r
-    for (qstr=q->str; *qstr != '*' ; qstr++) {\r
-      fprintf(stdout,"%c",*qstr);\r
-    };\r
-\r
-    qstr++;\r
-    if (*qstr == 'i') fprintf(stdout," First[");\r
-    if (*qstr == 'o') fprintf(stdout," Follow[");\r
-    qstr++;\r
-    fprintf(stdout,"%s]",qstr);\r
-    if (q->incomplete) fprintf(stdout," *** incomplete ***");\r
-    fprintf(stdout,"\n");\r
-    MR_dumpTokenSet(stdout,1,q->fset);\r
-}\r
-\r
-void \r
-#ifdef __USE_PROTOS\r
-DumpFcache(void) \r
-#else\r
-DumpFcache() \r
-#endif\r
-{\r
-\r
-    char        *prev="";\r
-    int          n=0;\r
-    CacheEntry  *next;\r
-\r
-    fprintf(stdout,"\n\nDump of First/Follow Cache\n");\r
-\r
-    for(;;) {\r
-      next=dumpFcache1(prev);\r
-      if (next == NULL) break;\r
-      reportFcache(next);\r
-      ++n;\r
-      prev=next->str;\r
-    };\r
-    fprintf(stdout,"\nEnd dump of First/Follow Cache\n");\r
-}\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/antlr/fset.c b/Tools/CodeTools/TianoTools/Pccts/antlr/fset.c
deleted file mode 100644 (file)
index e1a76ec..0000000
+++ /dev/null
@@ -1,1555 +0,0 @@
-/*\r
- * fset.c\r
- *\r
- * Compute FIRST and FOLLOW sets.\r
- *\r
- * SOFTWARE RIGHTS\r
- *\r
- * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
- * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
- * company may do whatever they wish with source code distributed with\r
- * PCCTS or the code generated by PCCTS, including the incorporation of\r
- * PCCTS, or its output, into commerical software.\r
- *\r
- * We encourage users to develop software with PCCTS.  However, we do ask\r
- * that credit is given to us for developing PCCTS.  By "credit",\r
- * we mean that if you incorporate our source code into one of your\r
- * programs (commercial product, research project, or otherwise) that you\r
- * acknowledge this fact somewhere in the documentation, research report,\r
- * etc...  If you like PCCTS and have developed a nice tool with the\r
- * output, please mention that you developed it using PCCTS.  In\r
- * addition, we ask that this header remain intact in our source code.\r
- * As long as these guidelines are kept, we expect to continue enhancing\r
- * this system and expect to make other tools available as they are\r
- * completed.\r
- *\r
- * ANTLR 1.33\r
- * Terence Parr\r
- * Parr Research Corporation\r
- * with Purdue University and AHPCRC, University of Minnesota\r
- * 1989-2001\r
- */\r
-\r
-#include <stdio.h>\r
-#include <stdlib.h>\r
-\r
-#include "pcctscfg.h"\r
-\r
-#include "set.h"\r
-#include "syn.h"\r
-#include "hash.h"\r
-#include "generic.h"\r
-#include "dlgdef.h"\r
-#include "limits.h"\r
-\r
-#ifdef __USE_PROTOS\r
-static void ensure_predicates_cover_ambiguous_lookahead_sequences\r
-                                    (Junction *, Junction *, char *, Tree *);\r
-#else\r
-static void ensure_predicates_cover_ambiguous_lookahead_sequences();\r
-#endif\r
-\r
-/*\r
- * What tokens are k tokens away from junction q?\r
- *\r
- * Follow both p1 and p2 paths (unless RuleBlk) to collect the tokens k away from this\r
- * node.\r
- * We lock the junction according to k--the lookahead.  If we have been at this\r
- * junction before looking for the same, k, number of lookahead tokens, we will\r
- * do it again and again...until we blow up the stack.  Locks are only used on aLoopBlk,\r
- * RuleBlk, aPlusBlk and EndRule junctions to remove/detect infinite recursion from\r
- * FIRST and FOLLOW calcs.\r
- *\r
- * If p->jtype == EndRule we are going to attempt a FOLLOW.  (FOLLOWs are really defined\r
- * in terms of FIRST's, however).  To proceed with the FOLLOW, p->halt cannot be\r
- * set.  p->halt is set to indicate that a reference to the current rule is in progress\r
- * and the FOLLOW is not desirable.\r
- *\r
- * If we attempt a FOLLOW and find that there is no FOLLOW or REACHing beyond the EndRule\r
- * junction yields an empty set, replace the empty set with EOF.  No FOLLOW means that\r
- * only EOF can follow the current rule.  This normally occurs only on the start symbol\r
- * since all other rules are referenced by another rule somewhere.\r
- *\r
- * Normally, both p1 and p2 are followed.  However, checking p2 on a RuleBlk node is\r
- * the same as checking the next rule which is clearly incorrect.\r
- *\r
- * Cycles in the FOLLOW sense are possible.  e.g. Fo(c) requires Fo(b) which requires\r
- * Fo(c).  Both Fo(b) and Fo(c) are defined to be Fo(b) union Fo(c).  Let's say\r
- * Fo(c) is attempted first.  It finds all of the FOLLOW symbols and then attempts\r
- * to do Fo(b) which finds of its FOLLOW symbols.  So, we have:\r
- *\r
- *                  Fo(c)\r
- *                 /     \\r
- *              a set    Fo(b)\r
- *                      /     \\r
- *                   a set    Fo(c) .....Hmmmm..... Infinite recursion!\r
- *\r
- * The 2nd Fo(c) is not attempted and Fo(b) is left deficient, but Fo(c) is now\r
- * correctly Fo(c) union Fo(b).  We wish to pick up where we left off, so the fact\r
- * that Fo(b) terminated early means that we lack Fo(c) in the Fo(b) set already\r
- * laying around.  SOOOOoooo, we track FOLLOW cycles.  All FOLLOW computations are\r
- * cached in a hash table.  After the sequence of FOLLOWs finish, we reconcile all\r
- * cycles --> correct all Fo(rule) sets in the cache.\r
- *\r
- * Confused? Good! Read my MS thesis [Purdue Technical Report TR90-30].\r
- * TJP 8/93 -- can now read PhD thesis from Purdue.\r
- *\r
- * Also, FIRST sets are cached in the hash table.  Keys are (rulename,Fi/Fo,k).\r
- * Only FIRST sets, for which the FOLLOW is not included, are stored.\r
- *\r
- * SPECIAL CASE of (...)+ blocks:\r
- * I added an optional alt so that the alts could see what\r
- * was behind the (...)+ block--thus using enough lookahead\r
- * to branch out rather than just enough to distinguish\r
- * between alts in the (...)+.  However, when the FIRST("(...)+") is\r
- * is needed, must not use this last "optional" alt.  This routine\r
- * turns off this path by setting a new 'ignore' flag for\r
- * the alt and then resetting it afterwards.\r
- */\r
-\r
-set\r
-#ifdef __USE_PROTOS\r
-rJunc( Junction *p, int k, set *rk )\r
-#else\r
-rJunc( p, k, rk )\r
-Junction *p;\r
-int k;\r
-set *rk;\r
-#endif\r
-{\r
-       set     a, b;\r
-\r
-       require(p!=NULL,                                "rJunc: NULL node");\r
-       require(p->ntype==nJunction,    "rJunc: not junction");\r
-\r
-#ifdef DBG_LL1\r
-       if ( p->jtype == RuleBlk ) fprintf(stderr, "FIRST(%s,%d) \n",((Junction *)p)->rname,k);\r
-       else fprintf(stderr, "rJunc: %s in rule %s\n",\r
-                       decodeJType[p->jtype], ((Junction *)p)->rname);\r
-#endif\r
-       /* if this is one of the added optional alts for (...)+ then return */\r
-\r
-    /* no need to pop backtrace - hasn't been pushed */\r
-\r
-       if ( p->ignore ) return empty;\r
-\r
-    if (MR_MaintainBackTrace) MR_pointerStackPush(&MR_BackTraceStack,p);\r
-\r
-/* MR14 */    if (AlphaBetaTrace && p->alpha_beta_guess_end) {\r
-/* MR14 */         warnFL(\r
-/* MR14 */           "not possible to compute follow set for alpha in an \"(alpha)? beta\" block.  ",\r
-/* MR14 */                 FileStr[p->file],p->line);\r
-/* MR14 */         MR_alphaBetaTraceReport();\r
-/* MR14 */    };\r
-\r
-/* MR14 */    if (p->alpha_beta_guess_end) {\r
-/* MR14 */      if (MR_MaintainBackTrace) MR_pointerStackPop(&MR_BackTraceStack);\r
-/* MR14 */      return empty;\r
-/* MR14 */    }\r
-\r
-       /* locks are valid for aLoopBlk,aPlusBlk,RuleBlk,EndRule junctions only */\r
-       if ( p->jtype==aLoopBlk || p->jtype==RuleBlk ||\r
-                p->jtype==aPlusBlk || p->jtype==EndRule )\r
-       {\r
-               require(p->lock!=NULL, "rJunc: lock array is NULL");\r
-               if ( p->lock[k] )\r
-               {\r
-                       if ( p->jtype == EndRule )      /* FOLLOW cycle? */\r
-                       {\r
-#ifdef DBG_LL1\r
-                               fprintf(stderr, "FOLLOW cycle to %s: panic!\n", p->rname);\r
-#endif\r
-                if (! MR_AmbSourceSearch) RegisterCycle(p->rname, k);\r
-                       }\r
-            if (MR_MaintainBackTrace) MR_pointerStackPop(&MR_BackTraceStack);\r
-                       return empty;\r
-               }\r
-               if ( p->jtype == RuleBlk &&\r
-                 p->end->halt  &&\r
-                     ! MR_AmbSourceSearch)     /* check for FIRST cache */\r
-               {\r
-                       CacheEntry *q = (CacheEntry *) hash_get(Fcache, Fkey(p->rname,'i',k));\r
-                       if ( q != NULL )\r
-                       {\r
-                               set_orin(rk, q->rk);\r
-                if (MR_MaintainBackTrace) MR_pointerStackPop(&MR_BackTraceStack);\r
-                               return set_dup( q->fset );\r
-                       }\r
-               }\r
-               if ( p->jtype == EndRule &&\r
-                !p->halt &&                     /* MR11 was using cache even when halt set */\r
-                     ! MR_AmbSourceSearch)             /* FOLLOW set cached already? */\r
-               {\r
-                       CacheEntry *q = (CacheEntry *) hash_get(Fcache, Fkey(p->rname,'o',k));\r
-                       if ( q != NULL )\r
-                       {\r
-#ifdef DBG_LL1\r
-                               fprintf(stderr, "cache for FOLLOW(%s,%d):", p->rname,k);\r
-                               s_fprT(stderr, q->fset);\r
-                               if ( q->incomplete ) fprintf(stderr, " (incomplete)");\r
-                               fprintf(stderr, "\n");\r
-#endif\r
-                               if ( !q->incomplete )\r
-                               {\r
-                    if (MR_MaintainBackTrace) MR_pointerStackPop(&MR_BackTraceStack);\r
-                                       return set_dup( q->fset );\r
-                               }\r
-                       }\r
-               }\r
-               p->lock[k] = TRUE;      /* This rule is busy */\r
-       }\r
-\r
-       a = b = empty;\r
-\r
-       if ( p->jtype == EndRule )\r
-       {\r
-               if (p->halt )                   /* don't want FOLLOW here? */ /* unless MR10 hoisting */\r
-               {\r
-                     p->lock[k] = FALSE;\r
-                         set_orel(k, rk);                                              /* indicate this k value needed */\r
-              if (MR_MaintainBackTrace) MR_pointerStackPop(&MR_BackTraceStack);\r
-                         return empty;\r
-               }\r
-               if (! MR_AmbSourceSearch) FoPush(p->rname, k);          /* Attempting FOLLOW */\r
-               if ( p->p1 == NULL ) set_orel((TokenInd!=NULL?TokenInd[EofToken]:EofToken), &a);/* if no FOLLOW assume EOF */\r
-#ifdef DBG_LL1\r
-               fprintf(stderr, "-->FOLLOW(%s,%d)\n", p->rname,k);\r
-#endif\r
-       }\r
-\r
-       if ( p->p1 != NULL ) {\r
-/* MR14 */      if (p->guess) {\r
-/* MR14 */        if (p->guess_analysis_point == NULL) {\r
-/* MR14 */           Node * guess_point;\r
-/* MR14 */           guess_point=(Node *)analysis_point(p);\r
-/* MR14 */           if (guess_point == (Node *)p) {\r
-/* MR14 */             guess_point=p->p1;\r
-/* MR14 */           }\r
-/* MR14 */           p->guess_analysis_point=guess_point;\r
-/* MR14 */        }\r
-/* MR14 */        REACH(p->guess_analysis_point, k, rk, a);\r
-                } else {\r
-                  REACH(p->p1, k, rk, a);\r
-                }\r
-    }  \r
-\r
-       /* C a c h e  R e s u l t s */\r
-\r
-       if ( p->jtype == RuleBlk && p->end->halt && ! MR_AmbSourceSearch)               /* can save FIRST set? */\r
-       {\r
-               CacheEntry *q = newCacheEntry( Fkey(p->rname,'i',k) );\r
-               /*fprintf(stderr, "Caching %s FIRST %d\n", p->rname, k);*/\r
-               hash_add(Fcache, Fkey(p->rname,'i',k), (Entry *)q);\r
-               q->fset = set_dup( a );\r
-               q->rk = set_dup( *rk );\r
-       }\r
-\r
-       if ( p->jtype == EndRule &&\r
-            !p->halt &&                         /* MR11 was using cache even with halt set */\r
-                 ! MR_AmbSourceSearch)                 /* just completed FOLLOW? */\r
-       {\r
-               /* Cache Follow set */\r
-               CacheEntry *q = (CacheEntry *) hash_get(Fcache, Fkey(p->rname,'o',k));\r
-               if ( q==NULL )\r
-               {\r
-                       q = newCacheEntry( Fkey(p->rname,'o',k) );\r
-                       hash_add(Fcache, Fkey(p->rname,'o',k), (Entry *)q);\r
-               }\r
-               /*fprintf(stderr, "Caching %s FOLLOW %d\n", p->rname, k);*/\r
-               if ( set_nil(a) && !q->incomplete )\r
-               {\r
-                       /* Don't ever save a nil set as complete.\r
-                        * Turn it into an eof set.\r
-                        */\r
-                       set_orel(EofToken, &a);\r
-               }\r
-               set_orin(&(q->fset), a);\r
-               FoPop( k );\r
-               if ( FoTOS[k] == NULL && Cycles[k] != NULL ) ResolveFoCycles(k);\r
-#ifdef DBG_LL1\r
-               fprintf(stderr, "saving FOLLOW(%s,%d):", p->rname, k);\r
-               s_fprT(stderr, q->fset);\r
-               if ( q->incomplete ) fprintf(stderr, " (incomplete)");\r
-               fprintf(stderr, "\n");\r
-#endif\r
-       }\r
-       \r
-    if (p->jtype != RuleBlk && p->p2 != NULL && /* MR14 */ ! p->guess) {\r
-       REACH(p->p2, k, rk, b);\r
-    }  \r
-\r
-       if ( p->jtype==aLoopBlk || p->jtype==RuleBlk ||\r
-                p->jtype==aPlusBlk || p->jtype==EndRule )\r
-               p->lock[k] = FALSE;                                                     /* unlock node */\r
-\r
-       set_orin(&a, b);\r
-       set_free(b);\r
-    if (MR_MaintainBackTrace) MR_pointerStackPop(&MR_BackTraceStack);\r
-       return a;\r
-}\r
-\r
-set\r
-#ifdef __USE_PROTOS\r
-rRuleRef( RuleRefNode *p, int k, set *rk_out )\r
-#else\r
-rRuleRef( p, k, rk_out )\r
-RuleRefNode *p;\r
-int k;\r
-set *rk_out;\r
-#endif\r
-{\r
-       set rk;\r
-       Junction *r;\r
-       int k2;\r
-       set a, rk2, b;\r
-       int save_halt;\r
-       RuleEntry *q = (RuleEntry *) hash_get(Rname, p->text);\r
-       require(p!=NULL,                        "rRuleRef: NULL node");\r
-       require(p->ntype==nRuleRef,     "rRuleRef: not rule ref");\r
-\r
-#ifdef DBG_LL1\r
-       fprintf(stderr, "rRuleRef: %s\n", p->text);\r
-#endif\r
-\r
-    if (MR_MaintainBackTrace) MR_pointerStackPush(&MR_BackTraceStack,p);\r
-\r
-       if ( q == NULL )\r
-       {\r
-               warnFL( eMsg1("rule %s not defined",p->text), FileStr[p->file], p->line );\r
-               REACH(p->next, k, rk_out, a);\r
-        if (MR_MaintainBackTrace) MR_pointerStackPop(&MR_BackTraceStack);\r
-               return a;\r
-       }\r
-       rk2 = empty;\r
-\r
-/* MR9 Problems with rule references in guarded predicates */\r
-/* MR9    Perhaps can use hash table to find rule ?        */\r
-\r
-/* MR9 */    if (RulePtr == NULL) {\r
-/* MR9 */        fatalFL(eMsg2("Rule %s uses rule %s via RulePtr before it has been initialized",\r
-/* MR9 */                                p->rname,q->str),FileStr[p->file],p->line);\r
-/* MR9 */    };\r
-\r
-       r = RulePtr[q->rulenum];\r
-       if ( r->lock[k] )\r
-       {\r
-               errNoFL( eMsg2("infinite left-recursion to rule %s from rule %s",\r
-                                               r->rname, p->rname) );\r
-\r
-        if (MR_MaintainBackTrace) MR_pointerStackPop(&MR_BackTraceStack);\r
-\r
-               return empty;\r
-       }\r
-\r
-       save_halt = r->end->halt;\r
-       r->end->halt = TRUE;            /* don't let reach fall off end of rule here */\r
-       rk = empty;\r
-       REACH(r, k, &rk, a);\r
-       r->end->halt = save_halt;\r
-       while ( !set_nil(rk) ) {\r
-               k2 = set_int(rk);               /* MR11 this messes up the ambiguity search routine */\r
-               set_rm(k2, rk);\r
-               REACH(p->next, k2, &rk2, b);    /* MR11 by changing the value of k                  */\r
-               set_orin(&a, b);\r
-               set_free(b);\r
-       }\r
-       set_free(rk);                           /* this has no members, but free it's memory */\r
-       set_orin(rk_out, rk2);          /* remember what we couldn't do */\r
-       set_free(rk2);\r
-    if (MR_MaintainBackTrace) MR_pointerStackPop(&MR_BackTraceStack);\r
-       return a;\r
-}\r
-\r
-/*\r
- * Return FIRST sub k ( token_node )\r
- *\r
- * TJP 10/11/93 modified this so that token nodes that are actually\r
- * ranges (T1..T2) work.\r
- */\r
-set\r
-#ifdef __USE_PROTOS\r
-rToken( TokNode *p, int k, set *rk )\r
-#else\r
-rToken( p, k, rk )\r
-TokNode *p;\r
-int k;\r
-set *rk;\r
-#endif\r
-{\r
-       set a;\r
-\r
-       require(p!=NULL,                        "rToken: NULL node");\r
-       require(p->ntype==nToken,       "rToken: not token node");\r
-\r
-#ifdef DBG_LL1\r
-       fprintf(stderr, "rToken: %s\n", (TokenString(p->token)!=NULL)?TokenString(p->token):\r
-                                                                       ExprString(p->token));\r
-#endif\r
-\r
-\r
-    if (MR_MaintainBackTrace) MR_pointerStackPush(&MR_BackTraceStack,p);\r
-\r
-    if (MR_AmbSourceSearch && (k-1) == 0) {\r
-\r
-      set       localConstrain;\r
-      set       intersection;\r
-\r
-      localConstrain=fset[maxk-k+1];\r
-\r
-      if (! set_nil(p->tset)) {\r
-        intersection=set_and(localConstrain,p->tset);\r
-        if (! set_nil(intersection)) {\r
-          MR_backTraceReport();\r
-        };\r
-        set_free(intersection);\r
-      } else {\r
-        if (set_el( (unsigned) p->token,localConstrain)) {\r
-          MR_backTraceReport();\r
-        }\r
-      };\r
-    };\r
-\r
-       if ( k-1 == 0 ) {\r
-\r
-        if (MR_MaintainBackTrace) MR_pointerStackPop(&MR_BackTraceStack);\r
-\r
-               if ( !set_nil(p->tset) ) {\r
-            return set_dup(p->tset);\r
-        } else {\r
-               return set_of(p->token);\r
-        };\r
-       }\r
-\r
-       REACH(p->next, k-1, rk, a);\r
-       \r
-    if (MR_MaintainBackTrace) MR_pointerStackPop(&MR_BackTraceStack);\r
-\r
-       return a;\r
-}\r
-\r
-set\r
-#ifdef __USE_PROTOS\r
-rAction( ActionNode *p, int k, set *rk )\r
-#else\r
-rAction( p, k, rk )\r
-ActionNode *p;\r
-int k;\r
-set *rk;\r
-#endif\r
-{\r
-       set a;\r
-\r
-       require(p!=NULL,                        "rJunc: NULL node");\r
-       require(p->ntype==nAction,      "rJunc: not action");\r
-       \r
-/* MR11 */    if (p->is_predicate && p->ampersandPred != NULL) {\r
-/* MR11 */      Predicate   *pred=p->ampersandPred;\r
-/* MR11 */      if (k <= pred->k) {\r
-/* MR11 */        REACH(p->guardNodes,k,rk,a);\r
-/* MR11 */        return a;\r
-/* MR11 */      };\r
-/* MR11 */    };\r
-\r
-    /* it might be a good idea when doing an MR_AmbSourceSearch\r
-       to *not* look behind predicates under some circumstances\r
-       we'll look into that later\r
-    */\r
-\r
-       REACH(p->next, k, rk, a);       /* ignore actions */\r
-       return a;\r
-}\r
-\r
-                               /* A m b i g u i t y  R e s o l u t i o n */\r
-\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-dumpAmbigMsg( set *fset, FILE *f, int want_nls )\r
-#else\r
-dumpAmbigMsg( fset, f, want_nls )\r
-set *fset;\r
-FILE *f;\r
-int want_nls;\r
-#endif\r
-{\r
-       int i;\r
-\r
-    set     copy;               /* MR11 */\r
-\r
-       if ( want_nls ) fprintf(f, "\n\t");\r
-       else fprintf(f, " ");\r
-\r
-       for (i=1; i<=CLL_k; i++)\r
-       {\r
-        copy=set_dup(fset[i]);  /* MR11 */\r
-\r
-               if ( i>1 )\r
-               {\r
-                       if ( !want_nls ) fprintf(f, ", ");\r
-               }\r
-               if ( set_deg(copy) > 3 && elevel == 1 )\r
-               {\r
-                       int e,m;\r
-                       fprintf(f, "{");\r
-                       for (m=1; m<=3; m++)\r
-                       {\r
-                               e=set_int(copy);\r
-                               fprintf(f, " %s", TerminalString(e));\r
-                               set_rm(e, copy);\r
-                       }\r
-                       fprintf(f, " ... }");\r
-               }\r
-               else s_fprT(f, copy);\r
-               if ( want_nls ) fprintf(f, "\n\t");\r
-        set_free(copy);\r
-       }\r
-       fprintf(f, "\n");\r
-\r
-}\r
-\r
-static void\r
-#ifdef __USE_PROTOS\r
-verify_context(Predicate *predicate)\r
-#else\r
-verify_context(predicate)\r
-Predicate *predicate;\r
-#endif\r
-{\r
-       if ( predicate == NULL ) return;\r
-\r
-       if ( predicate->expr == PRED_OR_LIST ||\r
-                predicate->expr == PRED_AND_LIST )\r
-       {\r
-               verify_context(predicate->down);\r
-               verify_context(predicate->right);       /* MR10 */\r
-               return;\r
-       }\r
-\r
-       if ( !predicate->source->ctxwarned && predicate->source->guardpred==NULL &&\r
-                ((predicate->k > 1 &&\r
-                !is_single_tuple(predicate->tcontext)) ||\r
-                ( predicate->k == 1 &&\r
-                         set_deg(predicate->scontext[1])>1 )) )\r
-       {\r
-\r
-/* MR9 Suppress annoying messages caused by our own clever(?) fix */\r
-\r
-               fprintf(stderr, ErrHdr, FileStr[predicate->source->file],\r
-                               predicate->source->line);\r
-               fprintf(stderr, " warning: predicate applied for >1 lookahead %d-sequences\n", predicate->k);\r
-               fprintf(stderr, ErrHdr, FileStr[predicate->source->file],\r
-                               predicate->source->line);\r
-               fprintf(stderr, "     predicate text: \"%s\"\n",\r
-                        (predicate->expr == NULL ? "(null)" : predicate->expr) );\r
-               fprintf(stderr, ErrHdr, FileStr[predicate->source->file],\r
-                               predicate->source->line);\r
-               fprintf(stderr, "     You may only want one lookahead %d-sequence to apply\n", predicate->k);\r
-               fprintf(stderr, ErrHdr, FileStr[predicate->source->file],\r
-                               predicate->source->line);\r
-               fprintf(stderr, "     Try using a context guard '(...)? =>'\n");\r
-               predicate->source->ctxwarned = 1;\r
-       }\r
-    verify_context(predicate->right);       /* MR10 */\r
-}\r
-\r
-/*\r
- * If delta is the set of ambiguous lookahead sequences, then make sure that\r
- * the predicate(s) for productions alt1,alt2 cover the sequences in delta.\r
- *\r
- * For example,\r
- *     a : <<PRED1>>? (A B|A C)\r
- *       | b\r
- *    ;\r
- *     b : <<PRED2>>? A B\r
- *       | A C\r
- *       ;\r
- *\r
- * This should give a warning that (A C) predicts both productions and alt2\r
- * does not have a predicate in the production that generates (A C).\r
- *\r
- * The warning detection is simple.  Let delta = LOOK(alt1) intersection LOOK(alt2).\r
- * Now, if ( delta set-difference context(predicates-for-alt1) != empty then\r
- * alt1 does not "cover" all ambiguous sequences.\r
- *\r
- * If ambig is nonempty, then ambig in LL(k) sense -> use tree info; else use fset\r
- * info.  Actually, sets are used only if k=1 for this grammar.\r
- */\r
-static void\r
-#ifdef __USE_PROTOS\r
-ensure_predicates_cover_ambiguous_lookahead_sequences\r
-                        ( Junction *alt1, Junction *alt2, char *sub, Tree *ambig )\r
-#else\r
-ensure_predicates_cover_ambiguous_lookahead_sequences( alt1, alt2, sub, ambig )\r
-Junction *alt1;\r
-Junction *alt2;\r
-char *sub;\r
-Tree *ambig;\r
-#endif\r
-{\r
-       if ( !ParseWithPredicates ) return;\r
-\r
-       if ( ambig!=NULL )\r
-       {\r
-               Tree *non_covered = NULL;\r
-               if ( alt1->predicate!=NULL )\r
-                       non_covered = tdif(ambig, alt1->predicate, alt1->fset, alt2->fset);\r
-               if ( (non_covered!=NULL || alt1->predicate==NULL) && WarningLevel>1 )\r
-               {\r
-                       fprintf(stderr, ErrHdr, FileStr[alt1->file], alt1->line);\r
-                       fprintf(stderr, " warning: alt %d %shas no predicate to resolve ambiguity",\r
-                                                       alt1->altnum, sub);\r
-                       if ( alt1->predicate!=NULL && non_covered!=NULL )\r
-                       {\r
-                               fprintf(stderr, " upon");\r
-                               preorder(non_covered);\r
-                       }\r
-                       else if ( alt1->predicate==NULL )\r
-                       {\r
-                               fprintf(stderr, " upon");\r
-                               preorder(ambig->down);\r
-                       }\r
-                       fprintf(stderr, "\n");\r
-               }\r
-               Tfree(non_covered);\r
-               non_covered = NULL;\r
-               if ( alt2->predicate!=NULL )\r
-                       non_covered = tdif(ambig, alt2->predicate, alt1->fset, alt2->fset);\r
-               if ( (non_covered!=NULL || alt2->predicate==NULL) && WarningLevel>1 )\r
-               {\r
-                       fprintf(stderr, ErrHdr, FileStr[alt2->file], alt2->line);\r
-                       fprintf(stderr, " warning: alt %d %shas no predicate to resolve ambiguity",\r
-                                                       alt2->altnum, sub);\r
-                       if ( alt2->predicate!=NULL && non_covered!=NULL )\r
-                       {\r
-                               fprintf(stderr, " upon");\r
-                               preorder(non_covered);\r
-                       }\r
-                       else if ( alt2->predicate==NULL )\r
-                       {\r
-                               fprintf(stderr, " upon");\r
-                               preorder(ambig->down);\r
-                       }\r
-                       fprintf(stderr, "\n");\r
-               }\r
-               Tfree(non_covered);\r
-       }\r
-       else if ( !set_nil(alt1->fset[1]) )\r
-       {\r
-               set delta, non_covered;\r
-               delta = set_and(alt1->fset[1], alt2->fset[1]);\r
-               non_covered = set_dif(delta, covered_set(alt1->predicate));\r
-               if ( set_deg(non_covered)>0 && WarningLevel>1 )\r
-               {\r
-                       fprintf(stderr, ErrHdr, FileStr[alt1->file], alt1->line);\r
-                       fprintf(stderr, " warning: alt %d %shas no predicate to resolve ambiguity",\r
-                                                       alt1->altnum, sub);\r
-                       if ( alt1->predicate!=NULL )\r
-                       {\r
-                               fprintf(stderr, " upon ");\r
-                               s_fprT(stderr, non_covered);\r
-                       }\r
-                       fprintf(stderr, "\n");\r
-               }\r
-               set_free( non_covered );\r
-               non_covered = set_dif(delta, covered_set(alt2->predicate));\r
-               if ( set_deg(non_covered)>0 && WarningLevel>1 )\r
-               {\r
-                       fprintf(stderr, ErrHdr, FileStr[alt2->file], alt2->line);\r
-                       fprintf(stderr, " warning: alt %d %shas no predicate to resolve ambiguity",\r
-                                                       alt2->altnum, sub);\r
-                       if ( alt2->predicate!=NULL )\r
-                       {\r
-                               fprintf(stderr, " upon ");\r
-                               s_fprT(stderr, non_covered);\r
-                       }\r
-                       fprintf(stderr, "\n");\r
-               }\r
-               set_free( non_covered );\r
-               set_free( delta );\r
-       }\r
-       else fatal_internal("productions have no lookahead in predicate checking routine");\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-void MR_doPredicatesHelp(int inGuessBlock,Junction *alt1,Junction *alt2,int jtype,char *sub)\r
-#else\r
-void MR_doPredicatesHelp(inGuessBlock,alt1,alt2,jtype,sub)\r
-  int       inGuessBlock;\r
-  Junction  *alt1;\r
-  Junction  *alt2;\r
-  int       jtype;\r
-  char      *sub;\r
-#endif\r
-{\r
-    Predicate   *p1;\r
-    Predicate   *p2;\r
-\r
-    Junction    *parentRule=MR_nameToRuleBlk(alt1->rname);\r
-\r
-    if (inGuessBlock && WarningLevel <= 1) return;\r
-\r
-    /* let antlr give the usual error message */\r
-\r
-    if (alt1->predicate == NULL && alt2->predicate == NULL) return;\r
-\r
-    if ( (jtype == RuleBlk || jtype == aSubBlk)\r
-             && (alt1->predicate == NULL && alt2->predicate != NULL)) {\r
-        fprintf(stderr, ErrHdr, FileStr[parentRule->file],parentRule->line);\r
-        fprintf(stderr," warning: alt %d line %d and alt %d line %d of %s\n%s%s%s",\r
-          alt1->altnum,\r
-          alt1->line,\r
-          alt2->altnum,\r
-          alt2->line,\r
-          sub,\r
-          "     These alts have ambig lookahead sequences resolved by a predicate for\n",\r
-          "     the second choice. The second choice may not be reachable.\n",\r
-          "     You may want to use a complementary predicate or rearrange the alts\n"\r
-        );\r
-        return;\r
-    };\r
-\r
-    /* first do the easy comparison.  then do the hard one */\r
-\r
-    if (MR_comparePredicates(alt1->predicate,alt2->predicate)) {\r
-\r
-      if (jtype == aLoopBegin || jtype == aPlusBlk ) {\r
-\r
-        /* I'm not sure this code is reachable.\r
-           Predicates following a (...)+ or (...)* block are probably\r
-             considered validation predicates and therefore not\r
-             participate in the predication expression\r
-        */\r
-\r
-       fprintf(stderr, ErrHdr,FileStr[parentRule->file],parentRule->line);\r
-        fprintf(stderr," warning: %s of %s in rule %s\n     (file %s alt %d line %d and alt %d line %d)\n%s",\r
-          "the predicates used to disambiguate optional/exit paths of ",\r
-          sub,\r
-          CurRule,\r
-          FileStr[alt1->file],\r
-          alt1->altnum,\r
-          alt1->line,\r
-          alt2->altnum,\r
-          alt2->line,\r
-          "     are identical and have no resolving power\n");\r
-      } else {\r
-       fprintf(stderr, ErrHdr, FileStr[parentRule->file], parentRule->line);\r
-        fprintf(stderr," warning: %s rule %s\n     (file %s alt %d line %d and alt %d line %d)\n%s",\r
-          "the predicates used to disambiguate",\r
-          CurRule,\r
-          FileStr[alt1->file],\r
-          alt1->altnum,\r
-          alt1->line,\r
-          alt2->altnum,\r
-          alt2->line,\r
-          "     are identical and have no resolving power\n");\r
-      };\r
-    } else {\r
-      p1=predicate_dup_without_context(alt1->predicate);\r
-      p1=MR_unfold(p1);\r
-      MR_clearPredEntry(p1);\r
-      MR_simplifyInverted(p1,0);\r
-      p1=MR_predSimplifyALL(p1);\r
-      p2=predicate_dup_without_context(alt2->predicate);\r
-      p2=MR_unfold(p2);\r
-      MR_clearPredEntry(p2);\r
-      MR_simplifyInverted(p2,0);\r
-      p2=MR_predSimplifyALL(p2);\r
-      if (MR_comparePredicates(p1,p2)) {\r
-        if (jtype == aLoopBegin || jtype == aPlusBlk ) {\r
-          fprintf(stderr, ErrHdr, FileStr[parentRule->file], parentRule->line);\r
-          fprintf(stderr," warning: %s of %s in rule %s\n     (file %s alt %d line %d and alt %d line %d)\n%s%s",\r
-            "the predicates used to disambiguate optional/exit paths of ",\r
-            sub,\r
-            CurRule,\r
-            FileStr[alt1->file],\r
-            alt1->altnum,\r
-            alt1->line,\r
-            alt2->altnum,\r
-            alt2->line,\r
-            "     are identical when compared without context and may have no\n",\r
-            "     resolving power for some lookahead sequences.\n");\r
-        } else {\r
-          fprintf(stderr, ErrHdr, FileStr[parentRule->file], parentRule->line);\r
-          fprintf(stderr," warning: %s rule %s\n     (file %s alt %d line %d and alt %d line %d)\n%s%s",\r
-            "the predicates used to disambiguate",\r
-            CurRule,\r
-            FileStr[alt1->file],\r
-            alt1->altnum,\r
-            alt1->line,\r
-            alt2->altnum,\r
-            alt2->line,\r
-            "     are identical when compared without context and may have no\n",\r
-            "     resolving power for some lookahead sequences.\n");\r
-        };\r
-        if (InfoP) {\r
-          fprintf(output,"\n#if 0\n\n");\r
-          fprintf(output,"The following predicates are identical when compared without\n");\r
-          fprintf(output,"  lookahead context information.  For some ambiguous lookahead\n");\r
-          fprintf(output,"  sequences they may not have any power to resolve the ambiguity.\n");\r
-          fprintf(output,"\n");\r
-\r
-          fprintf(output,"Choice 1: %s  alt %d  line %d  file %s\n\n",\r
-                  MR_ruleNamePlusOffset( (Node *) alt1),\r
-                  alt1->altnum,\r
-                  alt1->line,\r
-                  FileStr[alt1->file]);\r
-          fprintf(output,"  The original predicate for choice 1 with available context information:\n\n");\r
-          MR_dumpPred1(2,alt1->predicate,1);\r
-          fprintf(output,"  The predicate for choice 1 after expansion (but without context information):\n\n");\r
-          MR_dumpPred1(2,p1,0);\r
-          if (p1 == NULL) {\r
-            Predicate   *phelp;\r
-            fprintf(output,"  The predicate for choice 1 after expansion (but before simplification)\n\n");\r
-            phelp=predicate_dup_without_context(alt1->predicate);\r
-            phelp=MR_unfold(phelp);\r
-            MR_clearPredEntry(phelp);\r
-            MR_simplifyInverted(phelp,0);\r
-            phelp=MR_predSimplifyALLX(phelp,1);\r
-            MR_dumpPred1(2,phelp,0);\r
-            predicate_free(phelp);\r
-          };\r
-          fprintf(output,"\n");\r
-\r
-          fprintf(output,"Choice 2: %s  alt %d  line %d  file %s\n\n",\r
-                  MR_ruleNamePlusOffset( (Node *) alt2),\r
-                  alt2->altnum,\r
-                  alt2->line,\r
-                  FileStr[alt2->file]);\r
-          fprintf(output,"  The original predicate for choice 2 with available context information:\n\n");\r
-          MR_dumpPred1(1,alt2->predicate,1);\r
-          fprintf(output,"  The predicate for choice 2 after expansion (but without context information):\n\n");\r
-          MR_dumpPred1(1,p2,0);\r
-          if (p2 == NULL) {\r
-            Predicate   *phelp;\r
-            fprintf(output,"  The predicate for choice 2 after expansion (but before simplification)\n\n");\r
-            phelp=predicate_dup_without_context(alt2->predicate);\r
-            phelp=MR_unfold(phelp);\r
-            MR_clearPredEntry(phelp);\r
-            MR_simplifyInverted(phelp,0);\r
-            phelp=MR_predSimplifyALLX(phelp,1);\r
-            MR_dumpPred1(2,phelp,0);\r
-            predicate_free(phelp);\r
-          };\r
-          fprintf(output,"\n#endif\n");\r
-        };\r
-      } else if (MR_secondPredicateUnreachable(p1,p2)) {\r
-        if (jtype == aLoopBegin || jtype == aPlusBlk ) {\r
-          fprintf(stderr, ErrHdr, FileStr[parentRule->file], parentRule->line);\r
-          fprintf(stderr," warning: %s of %s in rule %s\n     (file %s alt %d line %d and alt %d line %d)\n%s%s",\r
-            "the predicate used to disambiguate the first choice of the optional/exit paths of ",\r
-            sub,\r
-            CurRule,\r
-            FileStr[alt1->file],\r
-            alt1->altnum,\r
-            alt1->line,\r
-            alt2->altnum,\r
-            alt2->line,\r
-            "     appears to \"cover\" the second predicate when compared without context.\n",\r
-            "     The second predicate may have no resolving power for some lookahead sequences.\n");\r
-        } else {\r
-          fprintf(stderr, ErrHdr, FileStr[parentRule->file], parentRule->line);\r
-          fprintf(stderr," warning: %s rule %s\n     (file %s alt %d line %d and alt %d line %d)\n%s%s",\r
-            "the predicate used to disambiguate the first choice of",\r
-            CurRule,\r
-            FileStr[alt1->file],\r
-            alt1->altnum,\r
-            alt1->line,\r
-            alt2->altnum,\r
-            alt2->line,\r
-            "     appears to \"cover\" the second predicate when compared without context.\n",\r
-            "     The second predicate may have no resolving power for some lookahead sequences.\n");\r
-        };\r
-        if (InfoP) {\r
-          fprintf(output,"\n#if 0\n\n");\r
-          fprintf(output,"The first predicate appears to \"cover\" the second predicate when they\n");\r
-          fprintf(output,"  are compared without lookahead context information.  For some ambiguous\n");\r
-          fprintf(output,"  lookahead sequences the second predicate may not have any power to\n");\r
-          fprintf(output,"  resolve the ambiguity.\n");\r
-          fprintf(output,"\n");\r
-          fprintf(output,"Choice 1: %s  alt %d  line %d  file %s\n\n",\r
-                  MR_ruleNamePlusOffset( (Node *) alt1),\r
-                  alt1->altnum,\r
-                  alt1->line,\r
-                  FileStr[alt1->file]);\r
-          fprintf(output,"  The original predicate for choice 1 with available context information:\n\n");\r
-          MR_dumpPred1(2,alt1->predicate,1);\r
-          fprintf(output,"  The predicate for choice 1 after expansion (but without context information):\n\n");\r
-          MR_dumpPred1(2,p1,0);\r
-          if (p1 == NULL) {\r
-            Predicate   *phelp;\r
-            fprintf(output,"  The predicate for choice 1 after expansion (but before simplification)\n\n");\r
-            phelp=predicate_dup_without_context(alt1->predicate);\r
-            phelp=MR_unfold(phelp);\r
-            MR_clearPredEntry(phelp);\r
-            MR_simplifyInverted(phelp,0);\r
-            phelp=MR_predSimplifyALLX(phelp,1);\r
-            MR_dumpPred1(2,phelp,0);\r
-            predicate_free(phelp);\r
-          };\r
-          fprintf(output,"\n");\r
-\r
-          fprintf(output,"Choice 2: %s  alt %d  line %d  file %s\n\n",\r
-                  MR_ruleNamePlusOffset( (Node *) alt2),\r
-                  alt2->altnum,\r
-                  alt2->line,\r
-                  FileStr[alt2->file]);\r
-          fprintf(output,"  The original predicate for choice 2 with available context information:\n\n");\r
-          MR_dumpPred1(1,alt2->predicate,1);\r
-          fprintf(output,"  The predicate for choice 2 after expansion (but without context information):\n\n");\r
-          MR_dumpPred1(1,p2,0);\r
-          if (p2 == NULL) {\r
-            Predicate   *phelp;\r
-            fprintf(output,"  The predicate for choice 2 after expansion (but before simplification)\n\n");\r
-            phelp=predicate_dup_without_context(alt2->predicate);\r
-            phelp=MR_unfold(phelp);\r
-            MR_clearPredEntry(phelp);\r
-            MR_simplifyInverted(phelp,0);\r
-            phelp=MR_predSimplifyALLX(phelp,1);\r
-            MR_dumpPred1(2,phelp,0);\r
-            predicate_free(phelp);\r
-          };\r
-          fprintf(output,"\n#endif\n");\r
-        };\r
-      };\r
-      predicate_free(p1);\r
-      predicate_free(p2);\r
-    };\r
-}\r
-\r
-static  int     totalOverflow=0;                /* MR9 */\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-HandleAmbiguity( Junction *block, Junction *alt1, Junction *alt2, int jtype )\r
-#else\r
-HandleAmbiguity( block, alt1, alt2, jtype )\r
-Junction *block;\r
-Junction *alt1;\r
-Junction *alt2;\r
-int jtype;\r
-#endif\r
-{\r
-       unsigned **ftbl;\r
-       set *fset, b;\r
-       int i, numAmbig,n2;\r
-       Tree *ambig=NULL, *t, *u;\r
-       char *sub = "";\r
-    long    n;\r
-    int     thisOverflow=0;             /* MR9 */\r
-    long    set_deg_value;              /* MR10 */\r
-    long    threshhold;                 /* MR10 */\r
-\r
-       require(block!=NULL, "NULL block");\r
-       require(block->ntype==nJunction, "invalid block");\r
-\r
-       /* These sets are used to constrain LL_k set, but are made CLL_k long anyway */\r
-       fset = (set *) calloc(CLL_k+1, sizeof(set));\r
-       require(fset!=NULL, "cannot allocate fset");\r
-       ftbl = (unsigned **) calloc(CLL_k+1, sizeof(unsigned *));\r
-       require(ftbl!=NULL, "cannot allocate ftbl");\r
-\r
-       /* create constraint table and count number of possible ambiguities (use<=LL_k) */\r
-       for (n=1,i=1; i<=CLL_k; i++)\r
-       {\r
-                       b = set_and(alt1->fset[i], alt2->fset[i]);\r
-/* MR9 */       set_deg_value = set_deg(b);\r
-/* MR10 */      if (n > 0) {\r
-/* MR10 */        threshhold = LONG_MAX / n;\r
-/* MR10 */        if (set_deg_value <= threshhold) {\r
-/* MR10 */             n *= set_deg_value;\r
-/* MR10 */        } else {\r
-/* MR10 */          n=LONG_MAX;\r
-/* MR9 */           if (totalOverflow == 0) {\r
-#if 0\r
-                      /* MR10 comment this out because it just makes users worry */\r
-\r
-/* MR9 */             warnNoFL("Overflow in computing number of possible ambiguities in HandleAmbiguity\n");\r
-#endif\r
-/* MR9 */           };\r
-/* MR9 */           thisOverflow++;\r
-/* MR9 */           totalOverflow++;\r
-/* MR9 */         };\r
-/* MR10 */      } else {\r
-/* MR10 */        n *= set_deg_value;\r
-/* MR9 */       };\r
-               fset[i] = set_dup(b);\r
-               ftbl[i] = set_pdq(b);\r
-               set_free(b);\r
-       }\r
-\r
-       switch ( jtype )\r
-       {\r
-               case aSubBlk: sub = "of (..) "; break;\r
-               case aOptBlk: sub = "of {..} "; break;\r
-               case aLoopBegin: sub = "of (..)* "; break;\r
-               case aLoopBlk: sub = "of (..)* "; break;\r
-               case aPlusBlk: sub = "of (..)+ "; break;\r
-               case RuleBlk: sub = "of the rule itself "; break;\r
-               default : sub = ""; break;\r
-       }\r
-\r
-       /* If the block is marked as a compressed lookahead only block, then\r
-        * simply return; ambiguity warning is given only at warning level 2.\r
-        */\r
-       if ( block->approx>0 )\r
-       {\r
-               if ( ParseWithPredicates )\r
-               {\r
-            if (alt1->predicate != NULL) predicate_free(alt1->predicate);  /* MR12 */\r
-            if (alt2->predicate != NULL) predicate_free(alt2->predicate);  /* MR12 */\r
-\r
-            require(MR_PredRuleRefStack.count == 0,"PredRuleRef stack not empty");\r
-               alt1->predicate = MR_find_predicates_and_supp((Node *)alt1->p1);\r
-            require(MR_PredRuleRefStack.count == 0,"PredRuleRef stack not empty");\r
-            require (MR_predicate_context_completed(alt1->predicate),"predicate alt 1 not completed");\r
-            alt1->predicate=MR_predSimplifyALL(alt1->predicate);\r
-\r
-            require(MR_PredRuleRefStack.count == 0,"PredRuleRef stack not empty");\r
-               alt2->predicate = MR_find_predicates_and_supp((Node *)alt2->p1);\r
-            require(MR_PredRuleRefStack.count == 0,"PredRuleRef stack not empty");\r
-            require (MR_predicate_context_completed(alt2->predicate),"predicate alt 2 not completed");\r
-            alt2->predicate=MR_predSimplifyALL(alt2->predicate);\r
-\r
-            MR_doPredicatesHelp(0,alt1,alt2,jtype,sub);\r
-\r
-                       if ( HoistPredicateContext\r
-                    && (alt1->predicate!=NULL||alt2->predicate!=NULL) )\r
-                       {\r
-                               verify_context(alt1->predicate);\r
-                               verify_context(alt2->predicate);\r
-                       }\r
-\r
-                       if ( HoistPredicateContext\r
-                     && (alt1->predicate!=NULL||alt2->predicate!=NULL)\r
-                     && WarningLevel>1 )\r
-                       ensure_predicates_cover_ambiguous_lookahead_sequences(alt1, alt2, sub, ambig);\r
-               }\r
-\r
-               if ( WarningLevel>1 )\r
-               {\r
-                       fprintf(stderr, ErrHdr, FileStr[alt1->file], alt1->line);\r
-                       if ( jtype == aLoopBegin || jtype == aPlusBlk )\r
-                               fprintf(stderr, " warning: optional/exit path and alt(s) %sambiguous upon", sub);\r
-                       else\r
-                               fprintf(stderr, " warning(approx): alts %d and %d %sambiguous upon",\r
-                                               alt1->altnum, alt2->altnum, sub);\r
-                       dumpAmbigMsg(fset, stderr, 0);\r
-            MR_traceAmbSource(fset,alt1,alt2);\r
-               }\r
-               for (i=1; i<=CLL_k; i++) set_free( fset[i] );\r
-               free((char *)fset);\r
-               for (i=1; i<=CLL_k; i++) free( (char *)ftbl[i] );\r
-               free((char *)ftbl);\r
-               return;\r
-    }\r
-\r
-       /* if all sets have degree 1 for k<LL_k, then must be ambig upon >=1 permutation;\r
-        * don't bother doing full LL(k) analysis.\r
-        * (This "if" block handles the LL(1) case)\r
-        */\r
-\r
-       n2 = 0;\r
-       for (i=1; i<LL_k; i++) n2 += set_deg(alt1->fset[i])+set_deg(alt2->fset[i]);\r
-\r
-    /* here STARTS the special case in which the lookahead sets for alt1 and alt2\r
-       all have degree 1 for k<LL_k (including LL_k=1)\r
-    */\r
-\r
-       if ( n2==2*(LL_k-1) )\r
-       {\r
-\r
-        /* TJP: added to fix the case where LL(1) and syntactic predicates didn't\r
-         * work.  It now recognizes syntactic predicates, but does not like combo:\r
-         * LL(1)/syn/sem predicates. (10/24/93)\r
-         */\r
-\r
-               if ( first_item_is_guess_block_extra((Junction *)alt1->p1)!=NULL )\r
-               {\r
-                       if ( WarningLevel==1 )\r
-                       {\r
-                               for (i=1; i<=CLL_k; i++) set_free( fset[i] );\r
-                               free((char *)fset);\r
-                               for (i=1; i<=CLL_k; i++) free( (char *)ftbl[i] );\r
-                               free((char *)ftbl);\r
-                               return;\r
-                       }\r
-\r
-                       fprintf(stderr, ErrHdr, FileStr[alt1->file], alt1->line);\r
-                       if ( jtype == aLoopBegin || jtype == aPlusBlk )\r
-                          fprintf(stderr, " warning: optional/exit path and alt(s) %sambiguous upon", sub);\r
-                       else\r
-                          fprintf(stderr, " warning: alts %d and %d %sambiguous upon",\r
-                                          alt1->altnum, alt2->altnum, sub);\r
-                       dumpAmbigMsg(fset, stderr, 0);\r
-            MR_traceAmbSource(fset,alt1,alt2);\r
-               }\r
-\r
-               ambig = NULL;\r
-               if ( LL_k>1 ) ambig = make_tree_from_sets(alt1->fset, alt2->fset);\r
-               if ( ParseWithPredicates )\r
-               {\r
-           if (alt1->predicate != NULL) predicate_free(alt1->predicate);  /* MR12 */\r
-           if (alt2->predicate != NULL) predicate_free(alt2->predicate);  /* MR12 */\r
-\r
-           require(MR_PredRuleRefStack.count == 0,"PredRuleRef stack not empty");\r
-           alt1->predicate = MR_find_predicates_and_supp((Node *)alt1->p1);\r
-           require(MR_PredRuleRefStack.count == 0,"PredRuleRef stack not empty");\r
-           require (MR_predicate_context_completed(alt1->predicate),"predicate alt 1 not completed");\r
-           alt1->predicate=MR_predSimplifyALL(alt1->predicate);\r
-\r
-           require(MR_PredRuleRefStack.count == 0,"PredRuleRef stack not empty");\r
-          alt2->predicate = MR_find_predicates_and_supp((Node *)alt2->p1);\r
-           require(MR_PredRuleRefStack.count == 0,"PredRuleRef stack not empty");\r
-           require (MR_predicate_context_completed(alt2->predicate),"predicate alt 2 not completed");\r
-           alt2->predicate=MR_predSimplifyALL(alt2->predicate);\r
-\r
-           MR_doPredicatesHelp(0,alt1,alt2,jtype,sub);\r
-\r
-                  if ( HoistPredicateContext && (alt1->predicate!=NULL||alt2->predicate!=NULL) )\r
-                  {\r
-                               verify_context(alt1->predicate);\r
-                               verify_context(alt2->predicate);\r
-                  }\r
-                  if (HoistPredicateContext&&(alt1->predicate!=NULL||alt2->predicate!=NULL) && WarningLevel>1)\r
-                         ensure_predicates_cover_ambiguous_lookahead_sequences(alt1, alt2, sub, ambig);\r
-                  if ( WarningLevel == 1 &&\r
-                          (alt1->predicate!=NULL||alt2->predicate!=NULL))\r
-                  {\r
-                         for (i=1; i<=CLL_k; i++) set_free( fset[i] );\r
-                         free((char *)fset);\r
-                         for (i=1; i<=CLL_k; i++) free( (char *)ftbl[i] );\r
-                         free((char *)ftbl);\r
-                         Tfree(ambig);\r
-                         return;\r
-                  }\r
-               }\r
-/* end TJP (10/24/93) */\r
-\r
-               fprintf(stderr, ErrHdr, FileStr[alt1->file], alt1->line);\r
-               if ( jtype == aLoopBegin || jtype == aPlusBlk )\r
-                       fprintf(stderr, " warning: optional/exit path and alt(s) %sambiguous upon", sub);\r
-               else\r
-                  fprintf(stderr, " warning: alts %d and %d %sambiguous upon",\r
-                                  alt1->altnum, alt2->altnum, sub);\r
-               if ( elevel == 3 && LL_k>1 )\r
-               {\r
-                  preorder(ambig);\r
-                  fprintf(stderr, "\n");\r
-              for (i=1; i<=CLL_k; i++) set_free( fset[i] );\r
-          free((char *)fset);\r
-                  for (i=1; i<=CLL_k; i++) free( (char *)ftbl[i] );\r
-                  free((char *)ftbl);\r
-                  Tfree(ambig);\r
-                  return;\r
-        };\r
-\r
-               Tfree(ambig);\r
-               dumpAmbigMsg(fset, stderr, 0);\r
-\r
-        /* because this is a special case in which both alt1 and alt2 have\r
-           lookahead sets of degree 1 for k<LL_k (including k=1) the linear\r
-           lookahead style search is adequate\r
-        */\r
-\r
-        MR_traceAmbSource(fset,alt1,alt2);\r
-\r
-               for (i=1; i<=CLL_k; i++) set_free( fset[i] );\r
-               free((char *)fset);\r
-               for (i=1; i<=CLL_k; i++) free( (char *)ftbl[i] );\r
-               free((char *)ftbl);\r
-               return;\r
-       }\r
-\r
-    /* here ENDS the special case in which the lookahead sets for alt1 and alt2\r
-       all have degree 1 for k<LL_k (including LL_k=1)\r
-    */\r
-\r
-       /* in case tree construction runs out of memory, set info to make good err msg */\r
-\r
-       CurAmbigAlt1 = alt1->altnum;\r
-       CurAmbigAlt2 = alt2->altnum;\r
-       CurAmbigbtype = sub;\r
-       CurAmbigfile = alt1->file;\r
-       CurAmbigline = alt1->line;\r
-       \r
-       /* Don't do full LL(n) analysis if (...)? block because the block,\r
-          by definition, defies LL(n) analysis.\r
-          If guess (...)? block and ambiguous then don't remove anything from\r
-          2nd alt to resolve ambig.\r
-          Want to predict with LL sup 1 ( n ) decision not LL(n) if guess block\r
-          since it is much cheaper than LL(n).  LL sup 1 ( n ) "covers" the LL(n)\r
-          lookahead information.\r
-\r
-          Note: LL(n) context cannot be computed for semantic predicates when\r
-          followed by (..)?.\r
-\r
-          If (..)? then we scream "AAAHHHH!  No LL(n) analysis will help"\r
-\r
-       Is 'ambig' always defined if we enter this if?  I hope so\r
-          because the 'ensure...()' func references it. TJP Nov 1993.\r
-          */\r
-\r
-       /* THM MR30:  Instead of using first_item_is_guss_block we use\r
-          first_item_is_guess_block_extra which will look inside a\r
-          loop block for a guess block.  In other words ( (...)? )*.\r
-          It there is an ambiguity in this circumstance then we suppress\r
-          the normal methods of resolving ambiguities.\r
-       */\r
-\r
-       if ( first_item_is_guess_block_extra((Junction *)alt1->p1)!=NULL )\r
-       {\r
-               if ( ParseWithPredicates )\r
-               {\r
-            if (alt1->predicate != NULL) predicate_free(alt1->predicate);  /* MR12 */\r
-            if (alt2->predicate != NULL) predicate_free(alt2->predicate);  /* MR12 */\r
-            require(MR_PredRuleRefStack.count == 0,"PredRuleRef stack not empty");\r
-               alt1->predicate = MR_find_predicates_and_supp((Node *)alt1->p1);\r
-            require(MR_PredRuleRefStack.count == 0,"PredRuleRef stack not empty");\r
-            require (MR_predicate_context_completed(alt1->predicate),"predicate alt 1 not completed");\r
-            alt1->predicate=MR_predSimplifyALL(alt1->predicate);\r
-\r
-            require(MR_PredRuleRefStack.count == 0,"PredRuleRef stack not empty");\r
-               alt2->predicate = MR_find_predicates_and_supp((Node *)alt2->p1);\r
-            require(MR_PredRuleRefStack.count == 0,"PredRuleRef stack not empty");\r
-            require (MR_predicate_context_completed(alt2->predicate),"predicate alt 2 not completed");\r
-            alt2->predicate=MR_predSimplifyALL(alt2->predicate);\r
-\r
-            MR_doPredicatesHelp(1,alt1,alt2,jtype,sub);\r
-\r
-                       if ( HoistPredicateContext && (alt1->predicate!=NULL||alt2->predicate!=NULL) )\r
-                       {\r
-                               verify_context(alt1->predicate);\r
-                               verify_context(alt2->predicate);\r
-                       }\r
-                       if ( HoistPredicateContext && (alt1->predicate!=NULL||alt2->predicate!=NULL) && WarningLevel>1 )\r
-                               ensure_predicates_cover_ambiguous_lookahead_sequences(alt1, alt2, sub, ambig);\r
-                       if ( WarningLevel==1 &&\r
-                               (alt1->predicate!=NULL||alt2->predicate!=NULL))\r
-                       {\r
-                               for (i=1; i<=CLL_k; i++) set_free( fset[i] );\r
-                               free((char *)fset);\r
-                               for (i=1; i<=CLL_k; i++) free( (char *)ftbl[i] );\r
-                               free((char *)ftbl);\r
-                               return;\r
-                       }\r
-               }\r
-\r
-               if ( WarningLevel>1 )\r
-               {\r
-                       fprintf(stderr, ErrHdr, FileStr[alt1->file], alt1->line);\r
-                       if ( jtype == aLoopBegin || jtype == aPlusBlk )\r
-                               fprintf(stderr, " warning: optional/exit path and alt(s) %sambiguous upon", sub);\r
-                       else\r
-                               fprintf(stderr, " warning: alts %d and %d %sambiguous upon",\r
-                                               alt1->altnum, alt2->altnum, sub);\r
-                       dumpAmbigMsg(fset, stderr, 0);\r
-            MR_traceAmbSource(fset,alt1,alt2);\r
-               }\r
-\r
-               for (i=1; i<=CLL_k; i++) set_free( fset[i] );\r
-               free((char *)fset);\r
-               for (i=1; i<=CLL_k; i++) free( (char *)ftbl[i] );\r
-               free((char *)ftbl);\r
-               return;\r
-       }\r
-       \r
-       /* Not resolved with (..)? block.  Do full LL(n) analysis */\r
-       \r
-       /* ambig is the set of k-tuples truly in common between alt 1 and alt 2 */\r
-    /* MR11 VerifyAmbig once used fset destructively */\r
-\r
-       ambig = VerifyAmbig(alt1, alt2, ftbl, fset, &t, &u, &numAmbig);\r
-\r
-       /* are all things in intersection really ambigs? */\r
-\r
-       if (thisOverflow ||  numAmbig < n )                     /* MR9 */\r
-       {\r
-               Tree *v;\r
-\r
-               /* remove ambig permutation from 2nd alternative to resolve ambig;\r
-                * We want to compute the set of artificial tuples, arising from\r
-                * LL sup 1 (n) compression, that collide with real tuples from the\r
-                * 2nd alternative.  This is the set of "special case" tuples that\r
-                * the LL sup 1 (n) decision template maps incorrectly.\r
-                */\r
-\r
-        /* when generating code in genExpr() it does\r
-         *\r
-         *      if ( genExprSets(j->fset) && !genExprTree(j->ftree)) {...\r
-         *\r
-         * Sooooo the j->ftree is the tree of alt2\r
-         *               after removal of conflicts, not alt1 !\r
-         */\r
-\r
-               if ( ambig!=NULL )\r
-               {\r
-            /* at the top of ambig is an ALT node */\r
-\r
-                       for (v=ambig->down; v!=NULL; v=v->right)\r
-                       {\r
-                               u = trm_perm(u, v);     /* remove v FROM u */\r
-                       }\r
-/*                     fprintf(stderr, "after rm alt2:"); preorder(u); fprintf(stderr, "\n");*/\r
-               }\r
-               Tfree( t );\r
-               alt1->ftree = tappend(alt1->ftree, u);\r
-               alt1->ftree = tleft_factor(alt1->ftree);\r
-       }\r
-\r
-       if ( ambig==NULL )\r
-       {\r
-               for (i=1; i<=CLL_k; i++) set_free( fset[i] );\r
-               free((char *)fset);\r
-               for (i=1; i<=CLL_k; i++) free( (char *)ftbl[i] );\r
-               free((char *)ftbl);\r
-               return;\r
-       }\r
-\r
-       ambig = tleft_factor(ambig);\r
-\r
-/* TJP:\r
- * At this point, we surely have an LL(k) ambiguity.  Check for predicates\r
- */\r
-       if ( ParseWithPredicates )\r
-       {\r
-        if (alt1->predicate != NULL) predicate_free(alt1->predicate);  /* MR12 */\r
-        if (alt2->predicate != NULL) predicate_free(alt2->predicate);  /* MR12 */\r
-        require(MR_PredRuleRefStack.count == 0,"PredRuleRef stack not empty");\r
-       alt1->predicate = MR_find_predicates_and_supp((Node *)alt1->p1);\r
-        require(MR_PredRuleRefStack.count == 0,"PredRuleRef stack not empty");\r
-        require (MR_predicate_context_completed(alt1->predicate),"predicate alt 1 not completed");\r
-        alt1->predicate=MR_predSimplifyALL(alt1->predicate);\r
-\r
-        require(MR_PredRuleRefStack.count == 0,"PredRuleRef stack not empty");\r
-               alt2->predicate = MR_find_predicates_and_supp((Node *)alt2->p1);\r
-        require(MR_PredRuleRefStack.count == 0,"PredRuleRef stack not empty");\r
-        require (MR_predicate_context_completed(alt2->predicate),"predicate alt 2 not completed");\r
-        alt2->predicate=MR_predSimplifyALL(alt2->predicate);\r
-\r
-        MR_doPredicatesHelp(0,alt1,alt2,jtype,sub);\r
-\r
-               if ( HoistPredicateContext && (alt1->predicate!=NULL||alt2->predicate!=NULL) )\r
-               {\r
-                       verify_context(alt1->predicate);\r
-                       verify_context(alt2->predicate);\r
-               }\r
-               if ( HoistPredicateContext && (alt1->predicate!=NULL||alt2->predicate!=NULL) && WarningLevel>1 )\r
-                  ensure_predicates_cover_ambiguous_lookahead_sequences(alt1, alt2, sub, ambig);\r
-               if ( WarningLevel==1 &&\r
-                       (alt1->predicate!=NULL||alt2->predicate!=NULL))\r
-               {\r
-\r
-                       /* We found at least one pred for at least one of the alts;\r
-                        * If warnings are low, just return.\r
-                        */\r
-\r
-                       Tfree(ambig);\r
-            for (i=1; i<=CLL_k; i++) set_free( fset[i] );\r
-           free((char *)fset);\r
-               for (i=1; i<=CLL_k; i++) free( (char *)ftbl[i] );\r
-               free((char *)ftbl);\r
-                       return;\r
-               }\r
-               /* else we're gonna give a warning */\r
-       }\r
-/* end TJP addition */\r
-\r
-       fprintf(stderr, ErrHdr, FileStr[alt1->file], alt1->line);\r
-       if ( jtype == aLoopBegin || jtype == aPlusBlk )\r
-               fprintf(stderr, " warning: optional/exit path and alt(s) %sambiguous upon", sub);\r
-       else\r
-               fprintf(stderr, " warning: alts %d and %d %sambiguous upon",\r
-                                       alt1->altnum, alt2->altnum, sub);\r
-       if ( elevel == 3 )\r
-       {\r
-               preorder(ambig->down);      /* <===== k>1 ambiguity message data */\r
-               fprintf(stderr, "\n");\r
-       } else {\r
-        MR_skipped_e3_report=1;\r
-       dumpAmbigMsg(fset, stderr, 0);\r
-    };\r
-\r
-    MR_traceAmbSourceK(ambig,alt1,alt2);     /* <====== k>1 ambiguity aid */\r
-\r
-       Tfree(ambig);\r
-\r
-    for (i=1; i<=CLL_k; i++) set_free( fset[i] );\r
-       free((char *)fset);\r
-       for (i=1; i<=CLL_k; i++) free( (char *)ftbl[i] );\r
-       free((char *)ftbl);\r
-}\r
-\r
-/* Don't analyze alpha block of (alpha)?beta; if (alpha)? then analyze\r
- * Return the 1st node of the beta block if present else return j.\r
- */\r
-Junction *\r
-#ifdef __USE_PROTOS\r
-analysis_point( Junction *j )\r
-#else\r
-analysis_point( j )\r
-Junction *j;\r
-#endif\r
-{\r
-       Junction *gblock;\r
-\r
-    /* MR13b  When there was an action/predicate preceding a guess block\r
-              the guess block became invisible at the analysis_point.\r
-\r
-              first_item_is_guess_block accepts any kind of node,\r
-              despite the fact that the formal is a junction.  But\r
-              I don't want to have to change it all over the place\r
-              until I know it works.\r
-    */\r
-\r
-       if ( j->ntype != nJunction && j->ntype != nAction) return j;\r
-\r
-       gblock = first_item_is_guess_block((Junction *)j);\r
-\r
-       if ( gblock!=NULL )\r
-       {\r
-               Junction *past = gblock->end;\r
-               Junction *p;\r
-               require(past!=NULL, "analysis_point: no end block on (...)? block");\r
-\r
-               for (p=(Junction *)past->p1; p!=NULL; )\r
-               {\r
-                       if ( p->ntype==nAction )\r
-                       {\r
-                               p=(Junction *)((ActionNode *)p)->next;\r
-                               continue;\r
-                       }\r
-                       if ( p->ntype!=nJunction )\r
-                       {\r
-                past->alpha_beta_guess_end=1;           /* MR14 */\r
-                               return (Junction *)past->p1;\r
-                       }\r
-                       if ( p->jtype==EndBlk || p->jtype==EndRule )\r
-                       {\r
-                               return j;\r
-                       }\r
-/* MR6                                                                                                       */\r
-/* MR6 A guess block is of the form "(alpha)? beta" or "(alpha)?".           */\r
-/* MR6  When beta is omitted (second form) this means "(alpha)? alpha".       */\r
-/* MR6  The program does not store another copy of alpha in this case.        */\r
-/* MR6  During analysis when the program needs to know what follows the       */\r
-/* MR6    guess clause.  It calls this routine.                               */\r
-/* MR6                                                                        */\r
-/* MR6      If it is of the form "(alpha)? beta" it returns a pointer to beta.*/\r
-/* MR6                                                                        */\r
-/* MR6      If it is of the form "(alpha)?" it returns a pointer to the guess */\r
-/* MR6        block itself thereby reusing the junction tree.                 */\r
-/* MR6                                                                        */\r
-/* MR6  It works by searching the "next in sequence" chain (skipping actions) */\r
-/* MR6    searching for a RuleRef or Token node.  (Those are the only 4 kinds */\r
-/* MR6    of nodes: Junctions, RuleRef, Token, and Action.)                   */\r
-/* MR6                                                                        */\r
-/* MR6  This won't work for the special case "(alpha)? ()" because it has no  */\r
-/* MR6    rule references or token nodes.  It eventually encounters a         */\r
-/* MR6   junction of type EndBlk or EndRule and says to its caller: nothing  */\r
-/* MR6    more here to analyze - must be of the form "(alpha)?".              */\r
-/* MR6                                                                        */\r
-/* MR6  In the case of "(alpha)? ()" it should return a pointer to "()"       */\r
-/* MR6                                                                        */\r
-/* MR6  I think.                                                              */\r
-/* MR6                                                                        */\r
-                       if ( p->jtype!=Generic) {                                          /* MR6 */\r
-                past->alpha_beta_guess_end=1;                          /* MR14 */\r
-                               return (Junction *)past->p1;                           /* MR6 */\r
-                       };                                                                             /* MR6 */\r
-                       p=(Junction *)p->p1;\r
-               }\r
-       }\r
-       return j;\r
-}\r
-\r
-set\r
-#ifdef __USE_PROTOS\r
-First( Junction *j, int k, int jtype, int *max_k )\r
-#else\r
-First( j, k, jtype, max_k )\r
-Junction *j;\r
-int k;\r
-int jtype;\r
-int *max_k;\r
-#endif\r
-{\r
-       Junction *alt1, *alt2;\r
-       set a, rk, fCurBlk;\r
-       int savek;\r
-       int p1, p2;\r
-\r
-    int     save_maintainBackTrace;\r
-\r
-       require(j->ntype==nJunction, "First: non junction passed");\r
-\r
-       /* C o m p u t e  F I R S T  s e t  w i t h  k  l o o k a h e a d */\r
-       fCurBlk = rk = empty;\r
-       for (alt1=j; alt1!=NULL; alt1 = (Junction *)alt1->p2 )\r
-       {\r
-               Junction * p = NULL;\r
-               Junction * p1junction = NULL;\r
-               p = analysis_point((Junction *)alt1->p1);\r
-               p1junction = (Junction *) (alt1->p1);\r
-#if 0\r
-               if (p != p1junction) {\r
-                       fprintf(stdout,"Analysis point for #%d is #%d", p1junction->seq, p->seq); /* debug */\r
-               }\r
-#endif\r
-               REACH(p, k, &rk, alt1->fset[k]);\r
-               require(set_nil(rk), "rk != nil");\r
-               set_free(rk);\r
-               set_orin(&fCurBlk, alt1->fset[k]);\r
-       }\r
-\r
-       /* D e t e c t  A m b i g u i t i e s */\r
-       *max_k = 1;\r
-       for (p1=1,alt1=j; alt1!=NULL; alt1 = (Junction *)alt1->p2, p1++)\r
-       {\r
-               for (p2=1,alt2=(Junction *)alt1->p2; alt2!=NULL; alt2 = (Junction *)alt2->p2, p2++)\r
-               {\r
-                       savek = k;\r
-                       a = set_and(alt1->fset[k], alt2->fset[k]);\r
-                       while ( !set_nil(a) )\r
-                       {\r
-                               /* if we have hit the max k requested, just give warning */\r
-                               if ( j->approx==k ) {\r
-                               }\r
-\r
-                               if ( k==CLL_k )\r
-                               {\r
-#ifdef NOT_USED\r
-***                                    int save_LL_k = LL_k;\r
-***                                    int save_CLL_k = CLL_k;\r
-***                                    /* Get new LL_k from interactive feature if enabled */\r
-***                                    if ( AImode )\r
-***                                            AmbiguityDialog(j, jtype, alt1, alt2, &CLL_k, &LL_k);\r
-#endif\r
-                                       *max_k = CLL_k;\r
-                    save_maintainBackTrace=MR_MaintainBackTrace;\r
-                    if (AlphaBetaTrace) MR_MaintainBackTrace=0;\r
-                                       HandleAmbiguity(j, alt1, alt2, jtype);\r
-                    MR_MaintainBackTrace=save_maintainBackTrace;\r
-                                       break;\r
-                               }\r
-                               else\r
-                               {\r
-                                       Junction *p = analysis_point((Junction *)alt1->p1);\r
-                                       Junction *q = analysis_point((Junction *)alt2->p1);\r
-                                       k++;    /* attempt ambig alts again with more lookahead */\r
-\r
-                                       REACH(p, k, &rk, alt1->fset[k]);\r
-                                       require(set_nil(rk), "rk != nil");\r
-                                       REACH(q, k, &rk, alt2->fset[k]);\r
-                                       require(set_nil(rk), "rk != nil");\r
-                                       set_free(a);\r
-                                       a = set_and(alt1->fset[k], alt2->fset[k]);\r
-                                       if ( k > *max_k ) *max_k = k;\r
-                               }\r
-                       }\r
-                       set_free(a);\r
-                       k = savek;\r
-               }\r
-       }\r
-\r
-       return fCurBlk;\r
-}\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/antlr/fset2.c b/Tools/CodeTools/TianoTools/Pccts/antlr/fset2.c
deleted file mode 100644 (file)
index 7f686a5..0000000
+++ /dev/null
@@ -1,2250 +0,0 @@
-/*\r
- * fset2.c\r
- *\r
- * Compute FIRST sets for full LL(k)\r
- *\r
- * SOFTWARE RIGHTS\r
- *\r
- * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
- * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
- * company may do whatever they wish with source code distributed with\r
- * PCCTS or the code generated by PCCTS, including the incorporation of\r
- * PCCTS, or its output, into commerical software.\r
- *\r
- * We encourage users to develop software with PCCTS.  However, we do ask\r
- * that credit is given to us for developing PCCTS.  By "credit",\r
- * we mean that if you incorporate our source code into one of your\r
- * programs (commercial product, research project, or otherwise) that you\r
- * acknowledge this fact somewhere in the documentation, research report,\r
- * etc...  If you like PCCTS and have developed a nice tool with the\r
- * output, please mention that you developed it using PCCTS.  In\r
- * addition, we ask that this header remain intact in our source code.\r
- * As long as these guidelines are kept, we expect to continue enhancing\r
- * this system and expect to make other tools available as they are\r
- * completed.\r
- *\r
- * ANTLR 1.33\r
- * Terence Parr\r
- * Parr Research Corporation\r
- * with Purdue University and AHPCRC, University of Minnesota\r
- * 1989-2001\r
- */\r
-\r
-#include <stdio.h>\r
-#include "pcctscfg.h"\r
-#include <stdlib.h>\r
-\r
-#ifdef PCCTS_USE_STDARG\r
-#include <stdarg.h>\r
-#else\r
-#include <varargs.h>\r
-#endif\r
-\r
-#include "set.h"\r
-#include "syn.h"\r
-#include "hash.h"\r
-#include "generic.h"\r
-#include "dlgdef.h"\r
-\r
-/* ick! globals.  Used by permute() to track which elements of a set have been used */\r
-\r
-static int *findex;\r
-set *fset;              /* MR11 make global */\r
-static unsigned **ftbl;\r
-static set *constrain; /* pts into fset. constrains tToken() to 'constrain' */\r
-int ConstrainSearch;\r
-int maxk;               /* set to initial k upon tree construction request */\r
-                        /* MR11 make global */\r
-static Tree *FreeList = NULL;\r
-\r
-#ifdef __USE_PROTOS\r
-static int tmember_of_context(Tree *, Predicate *);\r
-#else\r
-static int tmember_of_context();\r
-#endif\r
-\r
-#if TREE_DEBUG\r
-set     set_of_tnodes_in_use;\r
-int     stop_on_tnode_seq_number=(-1);     /* (-1) to disable */\r
-#endif\r
-\r
-/* Do root\r
- * Then each sibling\r
- */\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-preorder( Tree *tree )\r
-#else\r
-preorder( tree )\r
-Tree *tree;\r
-#endif\r
-{\r
-       if ( tree == NULL ) return;\r
-       if ( tree->down != NULL ) fprintf(stderr, " (");\r
-       if ( tree->token == ALT ) fprintf(stderr, " ALT");\r
-       else fprintf(stderr, " %s", TerminalString(tree->token));\r
-       if ( tree->token==EpToken ) fprintf(stderr, "(%d)", tree->v.rk);\r
-       preorder(tree->down);\r
-       if ( tree->down != NULL ) fprintf(stderr, " )");\r
-       preorder(tree->right);\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-int MR_tree_matches_constraints(int k,set * constrain,Tree *t)\r
-#else\r
-int MR_tree_matches_constraints(k,constrain,t)\r
-  int       k;\r
-  set *     constrain;\r
-  Tree *    t;\r
-#endif\r
-{\r
-  int       i;\r
-  Tree      *u;\r
-\r
-  if (k == 0) return 1;\r
-\r
-  /* for testing guard predicates: if the guard tree is shorter\r
-     than the constraint then it is a match.  The reason is that\r
-     a guard of (A B) should be equivalent to a guard of (A B . . .)\r
-     where "." matches every token.  Thus a match which runs out\r
-     of tree before constraint is a match.\r
-  */\r
-\r
-  if (t == NULL) return 1;\r
-  require (set_deg(constrain[0]) == 1,\r
-            "MR_tree_matches_constraints: set_deg != 1");\r
-  i=set_int(constrain[0]);\r
-  if (t->token != i) return 0;\r
-  if (k-1 == 0) return 1;\r
-  for (u=t->down; u != NULL; u=u->right) {\r
-    if (MR_tree_matches_constraints(k-1,&constrain[1],u)) {\r
-       return 1;\r
-    };\r
-  };\r
-  return 0;\r
-}\r
-\r
-/* check the depth of each primary sibling to see that it is exactly\r
- * k deep. e.g.;\r
- *\r
- *     ALT\r
- *   |\r
- *   A ------- B\r
- *   |         |\r
- *   C -- D    E\r
- *\r
- * Remove all branches <= k deep.\r
- *\r
- * Added by TJP 9-23-92 to make the LL(k) constraint mechanism to work.\r
- */\r
-\r
-static int pruneCount=0;\r
-static int prunePeak=200;\r
-\r
-Tree *\r
-#ifdef __USE_PROTOS\r
-prune( Tree *t, int k )\r
-#else\r
-prune( t, k )\r
-Tree *t;\r
-int k;\r
-#endif\r
-{\r
-    pruneCount++;\r
-    if (pruneCount > prunePeak+100) {\r
-      prunePeak=pruneCount;\r
-#if 0\r
-***   fprintf(stderr,"pruneCount=%d\n",pruneCount);\r
-/***  preorder(t);   ***/\r
-***   fprintf(stderr,"\n",pruneCount);\r
-#endif\r
-    };\r
-    if ( t == NULL ) {\r
-        pruneCount--;\r
-        return NULL;\r
-    };\r
-    if ( t->token == ALT ) fatal_internal("prune: ALT node in FIRST tree");\r
-    if ( t->right!=NULL ) t->right = prune(t->right, k);\r
-    if ( k>1 )\r
-       {\r
-               if ( t->down!=NULL ) t->down = prune(t->down, k-1);\r
-               if ( t->down == NULL )\r
-               {\r
-                       Tree *r = t->right;\r
-                       t->right = NULL;\r
-                       Tfree(t);\r
-            pruneCount--;\r
-                       return r;\r
-               }\r
-       }\r
-    pruneCount--;\r
-    return t;\r
-}\r
-\r
-/* build a tree (root child1 child2 ... NULL) */\r
-#ifdef PCCTS_USE_STDARG\r
-Tree *tmake(Tree *root, ...)\r
-#else\r
-Tree *tmake(va_alist)\r
-va_dcl\r
-#endif\r
-{\r
-       Tree *w;\r
-       va_list ap;\r
-       Tree *child, *sibling=NULL, *tail=NULL;\r
-#ifndef PCCTS_USE_STDARG\r
-       Tree *root;\r
-#endif\r
-\r
-#ifdef PCCTS_USE_STDARG\r
-       va_start(ap, root);\r
-#else\r
-       va_start(ap);\r
-       root = va_arg(ap, Tree *);\r
-#endif\r
-       child = va_arg(ap, Tree *);\r
-       while ( child != NULL )\r
-       {\r
-#ifdef DUM\r
-               /* added "find end of child" thing TJP March 1994 */\r
-               for (w=child; w->right!=NULL; w=w->right) {;} /* find end of child */\r
-#else\r
-               w = child;\r
-#endif\r
-\r
-               if ( sibling == NULL ) {sibling = child; tail = w;}\r
-               else {tail->right = child; tail = w;}\r
-               child = va_arg(ap, Tree *);\r
-       }\r
-\r
-       /* was "root->down = sibling;" */\r
-       if ( root==NULL ) root = sibling;\r
-       else root->down = sibling;\r
-\r
-       va_end(ap);\r
-       return root;\r
-}\r
-\r
-Tree *\r
-#ifdef __USE_PROTOS\r
-tnode( int tok )\r
-#else\r
-tnode( tok )\r
-int tok;\r
-#endif\r
-{\r
-       Tree *p, *newblk;\r
-       static int n=0;\r
-       \r
-       if ( FreeList == NULL )\r
-       {\r
-               /*fprintf(stderr, "tnode: %d more nodes\n", TreeBlockAllocSize);*/\r
-               if ( TreeResourceLimit > 0 )\r
-               {\r
-                       if ( (n+TreeBlockAllocSize) >= TreeResourceLimit )\r
-                       {\r
-                               fprintf(stderr, ErrHdr, FileStr[CurAmbigfile], CurAmbigline);\r
-                               fprintf(stderr, " hit analysis resource limit while analyzing alts %d and %d %s\n",\r
-                                                               CurAmbigAlt1,\r
-                                                               CurAmbigAlt2,\r
-                                                               CurAmbigbtype);\r
-                               exit(PCCTS_EXIT_FAILURE);\r
-                       }\r
-               }\r
-               newblk = (Tree *)calloc(TreeBlockAllocSize, sizeof(Tree));\r
-               if ( newblk == NULL )\r
-               {\r
-                       fprintf(stderr, ErrHdr, FileStr[CurAmbigfile], CurAmbigline);\r
-                       fprintf(stderr, " out of memory while analyzing alts %d and %d %s\n",\r
-                                                       CurAmbigAlt1,\r
-                                                       CurAmbigAlt2,\r
-                                                       CurAmbigbtype);\r
-                       exit(PCCTS_EXIT_FAILURE);\r
-               }\r
-               n += TreeBlockAllocSize;\r
-               for (p=newblk; p<&(newblk[TreeBlockAllocSize]); p++)\r
-               {\r
-                       p->right = FreeList;    /* add all new Tree nodes to Free List */\r
-                       FreeList = p;\r
-               }\r
-       }\r
-       p = FreeList;\r
-       FreeList = FreeList->right;             /* remove a tree node */\r
-       p->right = NULL;                                /* zero out ptrs */\r
-       p->down = NULL;\r
-       p->token = tok;\r
-\r
-    TnodesAllocated++;                                      /* MR10 */\r
-    TnodesInUse++;                                          /* MR10 */\r
-    if (TnodesInUse > TnodesPeak) TnodesPeak=TnodesInUse;   /* MR10 */\r
-\r
-#ifdef TREE_DEBUG\r
-       require(!p->in_use, "tnode: node in use!");\r
-       p->in_use = 1;\r
-    p->seq=TnodesAllocated;\r
-    set_orel( (unsigned) TnodesAllocated,&set_of_tnodes_in_use);\r
-    if (stop_on_tnode_seq_number == p->seq) {\r
-      fprintf(stderr,"\n*** just allocated tnode #%d ***\n",\r
-            stop_on_tnode_seq_number);\r
-    };\r
-#endif\r
-       return p;\r
-}\r
-\r
-static Tree *\r
-#ifdef __USE_PROTOS\r
-eofnode( int k )\r
-#else\r
-eofnode( k )\r
-int k;\r
-#endif\r
-{\r
-       Tree *t=NULL;\r
-       int i;\r
-\r
-       for (i=1; i<=k; i++)\r
-       {\r
-               t = tmake(tnode((TokenInd!=NULL?TokenInd[EofToken]:EofToken)), t, NULL);\r
-       }\r
-       return t;\r
-}\r
-\r
-\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-_Tfree( Tree *t )\r
-#else\r
-_Tfree( t )\r
-Tree *t;\r
-#endif\r
-{\r
-       if ( t!=NULL )\r
-       {\r
-#ifdef TREE_DEBUG\r
-        if (t->seq == stop_on_tnode_seq_number) {\r
-           fprintf(stderr,"\n*** just freed tnode #%d ***\n",t->seq);\r
-        };\r
-               require(t->in_use, "_Tfree: node not in use!");\r
-               t->in_use = 0;\r
-        set_rm( (unsigned) t->seq,set_of_tnodes_in_use);\r
-#endif\r
-               t->right = FreeList;\r
-               FreeList = t;\r
-        TnodesInUse--;                   /* MR10 */\r
-       }\r
-}\r
-\r
-/* tree duplicate */\r
-Tree *\r
-#ifdef __USE_PROTOS\r
-tdup( Tree *t )\r
-#else\r
-tdup( t )\r
-Tree *t;\r
-#endif\r
-{\r
-       Tree *u;\r
-       \r
-       if ( t == NULL ) return NULL;\r
-       u = tnode(t->token);\r
-       u->v.rk = t->v.rk;\r
-       u->right = tdup(t->right);\r
-       u->down = tdup(t->down);\r
-       return u;\r
-}\r
-\r
-/* tree duplicate (assume tree is a chain downwards) */\r
-Tree *\r
-#ifdef __USE_PROTOS\r
-tdup_chain( Tree *t )\r
-#else\r
-tdup_chain( t )\r
-Tree *t;\r
-#endif\r
-{\r
-       Tree *u;\r
-       \r
-       if ( t == NULL ) return NULL;\r
-       u = tnode(t->token);\r
-       u->v.rk = t->v.rk;\r
-       u->down = tdup(t->down);\r
-       return u;\r
-}\r
-\r
-Tree *\r
-#ifdef __USE_PROTOS\r
-tappend( Tree *t, Tree *u )\r
-#else\r
-tappend( t, u )\r
-Tree *t;\r
-Tree *u;\r
-#endif\r
-{\r
-       Tree *w;\r
-\r
-/*** fprintf(stderr, "tappend(");\r
- *** preorder(t); fprintf(stderr, ",");\r
- *** preorder(u); fprintf(stderr, " )\n");\r
-*/\r
-       if ( t == NULL ) return u;\r
-       if ( t->token == ALT && t->right == NULL ) return tappend(t->down, u);\r
-       for (w=t; w->right!=NULL; w=w->right) {;}\r
-       w->right = u;\r
-       return t;\r
-}\r
-\r
-/* dealloc all nodes in a tree */\r
-void\r
-#ifdef __USE_PROTOS\r
-Tfree( Tree *t )\r
-#else\r
-Tfree( t )\r
-Tree *t;\r
-#endif\r
-{\r
-       if ( t == NULL ) return;\r
-       Tfree( t->down );\r
-       Tfree( t->right );\r
-       _Tfree( t );\r
-}\r
-\r
-/* find all children (alts) of t that require remaining_k nodes to be LL_k\r
- * tokens long.\r
- *\r
- * t-->o\r
- *     |\r
- *     a1--a2--...--an         <-- LL(1) tokens\r
- *     |   |        |\r
- *     b1  b2  ...  bn         <-- LL(2) tokens\r
- *     |   |        |\r
- *     .   .        .\r
- *     .   .        .\r
- *     z1  z2  ...  zn         <-- LL(LL_k) tokens\r
- *\r
- * We look for all [Ep] needing remaining_k nodes and replace with u.\r
- * u is not destroyed or actually used by the tree (a copy is made).\r
- */\r
-Tree *\r
-#ifdef __USE_PROTOS\r
-tlink( Tree *t, Tree *u, int remaining_k )\r
-#else\r
-tlink( t, u, remaining_k )\r
-Tree *t;\r
-Tree *u;\r
-int remaining_k;\r
-#endif\r
-{\r
-       Tree *p;\r
-       require(remaining_k!=0, "tlink: bad tree");\r
-\r
-       if ( t==NULL ) return NULL;\r
-       /*fprintf(stderr, "tlink: u is:"); preorder(u); fprintf(stderr, "\n");*/\r
-       if ( t->token == EpToken && t->v.rk == remaining_k )\r
-       {\r
-               require(t->down==NULL, "tlink: invalid tree");\r
-               if ( u == NULL ) {\r
-/* MR10 */  Tree  *tt=t->right;\r
-/* MR10 */  _Tfree(t);\r
-/* MR10 */  return tt;\r
-        };\r
-               p = tdup( u );\r
-               p->right = t->right;\r
-               _Tfree( t );\r
-               return p;\r
-       }\r
-       t->down = tlink(t->down, u, remaining_k);\r
-       t->right = tlink(t->right, u, remaining_k);\r
-       return t;\r
-}\r
-\r
-/* remove as many ALT nodes as possible while still maintaining semantics */\r
-Tree *\r
-#ifdef __USE_PROTOS\r
-tshrink( Tree *t )\r
-#else\r
-tshrink( t )\r
-Tree *t;\r
-#endif\r
-{\r
-       if ( t == NULL ) return NULL;\r
-       t->down = tshrink( t->down );\r
-       t->right = tshrink( t->right );\r
-       if ( t->down == NULL )\r
-       {\r
-               if ( t->token == ALT )\r
-               {\r
-                       Tree *u = t->right;\r
-                       _Tfree(t);\r
-                       return u;                       /* remove useless alts */\r
-               }\r
-               return t;\r
-       }\r
-\r
-       /* (? (ALT (? ...)) s) ==> (? (? ...) s) where s = sibling, ? = match any */\r
-       if ( t->token == ALT && t->down->right == NULL)\r
-       {\r
-               Tree *u = t->down;\r
-               u->right = t->right;\r
-               _Tfree( t );\r
-               return u;\r
-       }\r
-       /* (? (A (ALT t)) s) ==> (? (A t) s) where A is a token; s,t siblings */\r
-       if ( t->token != ALT && t->down->token == ALT && t->down->right == NULL )\r
-       {\r
-               Tree *u = t->down->down;\r
-               _Tfree( t->down );\r
-               t->down = u;\r
-               return t;\r
-       }\r
-       return t;\r
-}\r
-\r
-Tree *\r
-#ifdef __USE_PROTOS\r
-tflatten( Tree *t )\r
-#else\r
-tflatten( t )\r
-Tree *t;\r
-#endif\r
-{\r
-       if ( t == NULL ) return NULL;\r
-       t->down = tflatten( t->down );\r
-       t->right = tflatten( t->right );\r
-       if ( t->down == NULL ) return t;\r
-       \r
-       if ( t->token == ALT )\r
-       {\r
-               Tree *u;\r
-               /* find tail of children */\r
-               for (u=t->down; u->right!=NULL; u=u->right) {;}\r
-               u->right = t->right;\r
-               u = t->down;\r
-               _Tfree( t );\r
-               return u;\r
-       }\r
-       return t;\r
-}\r
-\r
-Tree *\r
-#ifdef __USE_PROTOS\r
-tJunc( Junction *p, int k, set *rk )\r
-#else\r
-tJunc( p, k, rk )\r
-Junction *p;\r
-int k;\r
-set *rk;\r
-#endif\r
-{\r
-       Tree *t=NULL, *u=NULL;\r
-       Junction *alt;\r
-       Tree *tail=NULL, *r;\r
-\r
-#ifdef DBG_TRAV\r
-       fprintf(stderr, "tJunc(%d): %s in rule %s\n", k,\r
-                       decodeJType[p->jtype], ((Junction *)p)->rname);\r
-#endif\r
-\r
-/* MR14 */    if (AlphaBetaTrace && p->alpha_beta_guess_end) {\r
-/* MR14 */         warnFL(\r
-/* MR14 */           "not possible to compute follow set for alpha in an \"(alpha)? beta\" block.  ",\r
-/* MR14 */                 FileStr[p->file],p->line);\r
-/* MR14 */         MR_alphaBetaTraceReport();\r
-/* MR14 */    };\r
-\r
-/* MR14 */    if (p->alpha_beta_guess_end) {\r
-/* MR14 */      return NULL;\r
-/* MR14 */    }\r
-\r
-       if ( p->jtype==aLoopBlk || p->jtype==RuleBlk ||\r
-                p->jtype==aPlusBlk || p->jtype==aSubBlk || p->jtype==aOptBlk )\r
-       {\r
-               if ( p->jtype!=aSubBlk && p->jtype!=aOptBlk ) {\r
-                       require(p->lock!=NULL, "rJunc: lock array is NULL");\r
-                       if ( p->lock[k] ) return NULL;\r
-                       p->lock[k] = TRUE;\r
-               }\r
-\r
-/* MR10 */    if (MR_MaintainBackTrace) {\r
-/* MR10 */      if (p->jtype != Generic) MR_pointerStackPush(&MR_BackTraceStack,p);\r
-/* MR10 */    };\r
-\r
-               TRAV(p->p1, k, rk, tail);\r
-\r
-/* MR10 */    if (MR_MaintainBackTrace) {\r
-/* MR10 */      if (p->jtype != Generic) MR_pointerStackPop(&MR_BackTraceStack);\r
-/* MR10 */    };\r
-\r
-               if ( p->jtype==RuleBlk ) {p->lock[k] = FALSE; return tail;}\r
-               r = tmake(tnode(ALT), tail, NULL);\r
-               for (alt=(Junction *)p->p2; alt!=NULL; alt = (Junction *)alt->p2)\r
-               {\r
-                       /* if this is one of the added optional alts for (...)+ then break */\r
-                       if ( alt->ignore ) break;\r
-\r
-                       if ( tail==NULL ) {TRAV(alt->p1, k, rk, tail); r->down = tail;}\r
-                       else\r
-                       {\r
-/* MR10 */    if (MR_MaintainBackTrace) {\r
-/* MR10 */      if (p->jtype != Generic) MR_pointerStackPush(&MR_BackTraceStack,p);\r
-/* MR10 */    };\r
-\r
-                               TRAV(alt->p1, k, rk, tail->right);\r
-\r
-/* MR10 */    if (MR_MaintainBackTrace) {\r
-/* MR10 */      if (p->jtype != Generic) MR_pointerStackPop(&MR_BackTraceStack);\r
-/* MR10 */    };\r
-                               if ( tail->right != NULL ) tail = tail->right;\r
-                       }\r
-               }\r
-               if ( p->jtype!=aSubBlk && p->jtype!=aOptBlk ) p->lock[k] = FALSE;\r
-#ifdef DBG_TREES\r
-               fprintf(stderr, "blk(%s) returns:",((Junction *)p)->rname); preorder(r); fprintf(stderr, "\n");\r
-#endif\r
-               if ( r->down == NULL ) {_Tfree(r); return NULL;}\r
-               return r;\r
-       }\r
-\r
-       if ( p->jtype==EndRule )\r
-       {\r
-               if ( p->halt )                                          /* don't want FOLLOW here? */\r
-               {\r
-/****          if ( ContextGuardTRAV ) return NULL; ****/\r
-                       set_orel( (unsigned) k, rk);    /* indicate this k value needed */ /* MR10 cast */\r
-                       t = tnode(EpToken);\r
-                       t->v.rk = k;\r
-                       return t;\r
-               }\r
-               require(p->lock!=NULL, "rJunc: lock array is NULL");\r
-               if ( p->lock[k] ) return NULL;\r
-               /* if no FOLLOW assume k EOF's */\r
-               if ( p->p1 == NULL ) return eofnode(k);\r
-               p->lock[k] = TRUE;\r
-       }\r
-\r
-/* MR14 */     if (p->p1 != NULL && p->guess &&  p->guess_analysis_point == NULL) {\r
-/* MR14 */    Node * guess_point;\r
-/* MR14 */    guess_point=(Node *)analysis_point(p);\r
-/* MR14 */    if (guess_point == (Node *)p) {\r
-/* MR14 */      guess_point=p->p1;\r
-/* MR14 */    }\r
-/* MR14 */    p->guess_analysis_point=guess_point;\r
-/* MR14 */  }  \r
-\r
-       if ( p->p2 == NULL )\r
-       {\r
-\r
-/* MR10 */    if (MR_MaintainBackTrace) {\r
-/* MR10 */      if (p->jtype != Generic) MR_pointerStackPush(&MR_BackTraceStack,p);\r
-/* MR10 */    };\r
-\r
-/* M14 */        if (p->guess_analysis_point != NULL) {\r
-/* M14 */                 TRAV(p->guess_analysis_point, k, rk,t);\r
-/* M14 */        } else {\r
-                          TRAV(p->p1, k, rk,t);\r
-/* M14 */        }\r
-\r
-/* MR10 */    if (MR_MaintainBackTrace) {\r
-/* MR10 */      if (p->jtype != Generic) MR_pointerStackPop(&MR_BackTraceStack);\r
-/* MR10 */    };\r
-\r
-               if ( p->jtype==EndRule ) p->lock[k]=FALSE;\r
-               return t;\r
-       }\r
-\r
-/* MR10 */    if (MR_MaintainBackTrace) {\r
-/* MR10 */      if (p->jtype != Generic) MR_pointerStackPush(&MR_BackTraceStack,p);\r
-/* MR10 */    };\r
-\r
-/* M14 */        if (p->guess_analysis_point != NULL) {\r
-/* M14 */                 TRAV(p->guess_analysis_point, k, rk,t);\r
-/* M14 */        } else {\r
-                          TRAV(p->p1, k, rk,t);\r
-/* M14 */        }\r
-\r
-/* MR10 */    if (MR_MaintainBackTrace) {\r
-/* MR10 */      if (p->jtype != Generic) MR_pointerStackPop(&MR_BackTraceStack);\r
-/* MR10 */    };\r
-\r
-       if ( p->jtype!=RuleBlk && /* MR14 */ !p->guess) TRAV(p->p2, k, rk, u);\r
-\r
-       if ( p->jtype==EndRule ) p->lock[k] = FALSE;/* unlock node */\r
-\r
-       if ( t==NULL ) return tmake(tnode(ALT), u, NULL);\r
-       return tmake(tnode(ALT), t, u, NULL);\r
-}\r
-\r
-Tree *\r
-#ifdef __USE_PROTOS\r
-tRuleRef( RuleRefNode *p, int k, set *rk_out )\r
-#else\r
-tRuleRef( p, k, rk_out )\r
-RuleRefNode *p;\r
-int k;\r
-set *rk_out;\r
-#endif\r
-{\r
-       int k2;\r
-       Tree *t=NULL, *u=NULL;\r
-       Junction *r;\r
-       set rk, rk2;\r
-       int save_halt;\r
-       RuleEntry *q = (RuleEntry *) hash_get(Rname, p->text);\r
-       \r
-#ifdef DBG_TRAV\r
-       fprintf(stderr, "tRuleRef: %s\n", p->text);\r
-#endif\r
-       if ( q == NULL )\r
-       {\r
-               TRAV(p->next, k, rk_out, t);/* ignore undefined rules */\r
-               return t;\r
-       }\r
-       rk = rk2 = empty;\r
-    if (RulePtr == NULL) fatal("RulePtr==NULL");\r
-       r = RulePtr[q->rulenum];\r
-       if ( r->lock[k] ) return NULL;\r
-       save_halt = r->end->halt;\r
-       r->end->halt = TRUE;            /* don't let reach fall off end of rule here */\r
-\r
-/* MR10 */    if (MR_MaintainBackTrace) {\r
-/* MR10 */      MR_pointerStackPush(&MR_BackTraceStack,p);\r
-/* MR10 */    };\r
-\r
-       TRAV(r, k, &rk, t);\r
-\r
-/* MR10 */    if (MR_MaintainBackTrace) {\r
-/* MR10 */      MR_pointerStackPop(&MR_BackTraceStack);\r
-/* MR10 */    };\r
-\r
-       r->end->halt = save_halt;\r
-#ifdef DBG_TREES\r
-       fprintf(stderr, "after ruleref, t is:"); preorder(t); fprintf(stderr, "\n");\r
-#endif\r
-       t = tshrink( t );\r
-       while ( !set_nil(rk) ) {        /* any k left to do? if so, link onto tree */\r
-               k2 = set_int(rk);\r
-               set_rm(k2, rk);\r
-\r
-/* MR10 */    if (MR_MaintainBackTrace) {\r
-/* MR10 */      MR_pointerStackPush(&MR_BackTraceStack,p);\r
-/* MR10 */    };\r
-\r
-               TRAV(p->next, k2, &rk2, u);\r
-\r
-/* MR10 */    if (MR_MaintainBackTrace) {\r
-/* MR10 */      MR_pointerStackPop(&MR_BackTraceStack);\r
-/* MR10 */    };\r
-\r
-               t = tlink(t, u, k2);    /* any alts missing k2 toks, add u onto end */\r
-        Tfree(u);               /* MR10 */\r
-       }\r
-       set_free(rk);                           /* rk is empty, but free it's memory */\r
-       set_orin(rk_out, rk2);          /* remember what we couldn't do */\r
-       set_free(rk2);\r
-       return t;\r
-}\r
-\r
-Tree *\r
-#ifdef __USE_PROTOS\r
-tToken( TokNode *p, int k, set *rk )\r
-#else\r
-tToken( p, k, rk )\r
-TokNode *p;\r
-int k;\r
-set *rk;\r
-#endif\r
-{\r
-       Tree *t=NULL, *tset=NULL, *u;\r
-\r
-       if (ConstrainSearch) {\r
-      if (MR_AmbSourceSearch) {\r
-               require(constrain>=fset&&constrain<=&(fset[CLL_k]),"tToken: constrain is not a valid set");\r
-      } else {\r
-               require(constrain>=fset&&constrain<=&(fset[LL_k]),"tToken: constrain is not a valid set");\r
-      };\r
-      constrain = &fset[maxk-k+1];\r
-       }\r
-\r
-#ifdef DBG_TRAV\r
-               fprintf(stderr, "tToken(%d): %s\n", k, TerminalString(p->token));\r
-               if ( ConstrainSearch ) {\r
-                       fprintf(stderr, "constrain is:"); s_fprT(stderr, *constrain); fprintf(stderr, "\n");\r
-               }\r
-#endif\r
-\r
-       /* is it a meta token (set of tokens)? */\r
-\r
-       if ( !set_nil(p->tset) )\r
-       {\r
-               unsigned e=0;\r
-               set a;\r
-               Tree *n, *tail = NULL;\r
-\r
-               if ( ConstrainSearch ) {\r
-          a = set_and(p->tset, *constrain);\r
-          if (set_nil(a)) {         /* MR10 */\r
-            set_free(a);            /* MR11 */\r
-            return NULL;            /* MR10 */\r
-          };                        /* MR10 */\r
-               } else {\r
-          a = set_dup(p->tset);\r
-        };\r
-\r
-               for (; !set_nil(a); set_rm(e, a))\r
-               {\r
-                       e = set_int(a);\r
-                       n = tnode(e);\r
-                       if ( tset==NULL ) { tset = n; tail = n; }\r
-                       else { tail->right = n; tail = n; }\r
-               }\r
-               set_free( a );\r
-       }\r
-       else if ( ConstrainSearch && !set_el(p->token, *constrain) )\r
-    {\r
-/*      fprintf(stderr, "ignoring token %s(%d)\n", TerminalString(p->token),\r
-                k);*/\r
-        return NULL;\r
-    }\r
-       else {\r
-        tset = tnode( p->token );\r
-    };\r
-\r
-/* MR10 */    if (MR_MaintainBackTrace) {\r
-/* MR10 */      if (k == 1) {\r
-/* MR10 */        MR_pointerStackPush(&MR_BackTraceStack,p);\r
-/* MR13 */        if (MR_SuppressSearch) {\r
-/* MR13 */          MR_suppressSearchReport();\r
-/* MR13 */        } else {\r
-/* MR10 */          MR_backTraceReport();\r
-/* MR13 */        };\r
-/* MR10 */        MR_pointerStackPop(&MR_BackTraceStack);\r
-/* MR11 */        Tfree(tset);\r
-/* MR11 */        return NULL;\r
-/* MR10 */      };\r
-/* MR10 */    };\r
-\r
-       if ( k == 1 ) return tset;\r
-\r
-    if (MR_MaintainBackTrace) {\r
-      MR_pointerStackPush(&MR_BackTraceStack,p);\r
-    };\r
-\r
-       TRAV(p->next, k-1, rk, t);\r
-\r
-    if (MR_MaintainBackTrace) {\r
-      Tfree(t);\r
-      Tfree(tset);\r
-      MR_pointerStackPop(&MR_BackTraceStack);\r
-      return NULL;\r
-    };\r
-\r
-       /* here, we are positive that, at least, this tree will not contribute\r
-        * to the LL(2) tree since it will be too shallow, IF t==NULL.\r
-        * If doing a context guard walk, then don't prune.\r
-        */\r
-       if ( t == NULL && !ContextGuardTRAV )   /* tree will be too shallow */\r
-       {\r
-               if ( tset!=NULL ) Tfree( tset );\r
-               return NULL;\r
-       }\r
-#ifdef DBG_TREES\r
-       fprintf(stderr, "tToken(%d)->next:",k); preorder(t); fprintf(stderr, "\n");\r
-#endif\r
-\r
-       /* if single token root, then just make new tree and return */\r
-    /* MR10 - set_nil(p->tset) isn't a good test because of ConstraintSearch */\r
-\r
-       if (tset->right == NULL) return tmake(tset, t, NULL);    /* MR10 */\r
-\r
-       /* here we must make a copy of t as a child of each element of the tset;\r
-        * e.g., "T1..T3 A" would yield ( nil ( T1 A ) ( T2 A ) ( T3 A ) )\r
-        */\r
-       for (u=tset; u!=NULL; u=u->right)\r
-       {\r
-               /* make a copy of t and hook it onto bottom of u */\r
-               u->down = tdup(t);\r
-       }\r
-       Tfree( t );\r
-#ifdef DBG_TREES\r
-       fprintf(stderr, "range is:"); preorder(tset); fprintf(stderr, "\n");\r
-#endif\r
-       return tset;\r
-}\r
-\r
-Tree *\r
-#ifdef __USE_PROTOS\r
-tAction( ActionNode *p, int k, set *rk )\r
-#else\r
-tAction( p, k, rk )\r
-ActionNode *p;\r
-int k;\r
-set *rk;\r
-#endif\r
-{\r
-       Tree        *t=NULL;\r
-    set         *save_fset=NULL;\r
-    int         i;\r
-\r
-       /* fprintf(stderr, "tAction\n"); */\r
-\r
-/*  An MR_SuppressSearch is looking for things that can be\r
-      reached even when the predicate is false.\r
-\r
-    There are three kinds of predicates:\r
-        plain:              r1: <<p>>? r2\r
-        guarded:            r1: (A)? => <<p>>? r2\r
-        ampersand style:    r1: (A)? && <<p>>? r2\r
-\r
-    Of the three kinds of predicates, only a guard predicate\r
-      has things which are reachable even when the predicate\r
-      is false.  To be reachable the constraint must *not*\r
-      match the guard.\r
-\r
-*/\r
-\r
-    if (p->is_predicate && MR_SuppressSearch) {\r
-\r
-      Predicate     *pred=p->guardpred;\r
-\r
-      if (pred == NULL) {\r
-        t=NULL;\r
-        goto EXIT;\r
-      };\r
-      constrain = &fset[maxk-k+1];\r
-      if (pred->k == 1) {\r
-        set     dif;\r
-        dif=set_dif(*constrain,pred->scontext[1]);\r
-        if (set_nil(dif)) {\r
-          set_free(dif);\r
-          t=NULL;\r
-          goto EXIT;\r
-        };\r
-        set_free(dif);\r
-      } else {\r
-        if (MR_tree_matches_constraints(k,constrain,pred->tcontext)) {\r
-          t=NULL;\r
-          goto EXIT;\r
-        };\r
-      }\r
-    };\r
-\r
-    /* The ampersand predicate differs from the\r
-         other predicates because its first set\r
-         is a subset of the first set behind the predicate\r
-\r
-            r1: (A)? && <<p>>? r2 ;\r
-            r2: A | B;\r
-\r
-       In this case first[1] of r1 is A, even\r
-         though first[1] of r2 is {A B}.\r
-    */\r
-\r
-    if (p->is_predicate && p->ampersandPred != NULL) {\r
-\r
-      Predicate     *pred=p->ampersandPred;\r
-      Tree          *tAND;\r
-      Tree          *tset;\r
-\r
-      if (k <= pred->k) {\r
-        if (MR_MaintainBackTrace) MR_pointerStackPush(&MR_BackTraceStack,p);\r
-        TRAV(p->guardNodes,k,rk,t);\r
-        if (MR_MaintainBackTrace) MR_pointerStackPop(&MR_BackTraceStack);\r
-        return t;\r
-      } else {\r
-        require (k>1,"tAction for ampersandpred: k <= 1");\r
-        if (ConstrainSearch) {\r
-          if (MR_AmbSourceSearch) {\r
-               require(constrain>=fset&&constrain<=&(fset[CLL_k]),\r
-                                "tToken: constrain is not a valid set");\r
-          } else {\r
-               require(constrain>=fset&&constrain<=&(fset[LL_k]),\r
-                                "tToken: constrain is not a valid set");\r
-          };\r
-          save_fset=(set *) calloc (CLL_k+1,sizeof(set));\r
-          require (save_fset != NULL,"tAction save_fset alloc");\r
-          for (i=1; i <= CLL_k ; i++) {\r
-            save_fset[i]=set_dup(fset[i]);\r
-          };\r
-          if (pred->k == 1) {\r
-            constrain = &fset[maxk-k+1];\r
-            set_andin(constrain,pred->scontext[1]);\r
-            if (set_nil(*constrain)) {\r
-              t=NULL;\r
-              goto EXIT;\r
-            };\r
-          } else {\r
-            constrain = &fset[maxk-k+1];\r
-            if (! MR_tree_matches_constraints(pred->k,constrain,pred->tcontext)) {\r
-               t=NULL;\r
-               goto EXIT;\r
-            };  /* end loop on i          */\r
-          }; /* end loop on pred scontext/tcontext */\r
-        }; /* end if on k > pred->k     */\r
-      }; /* end if on constrain search  */\r
-\r
-      TRAV(p->next,k,rk,t);\r
-\r
-      if (t != NULL) {\r
-        t=tshrink(t);\r
-        t=tflatten(t);\r
-        t=tleft_factor(t);\r
-        if (pred->tcontext != NULL) {\r
-          tAND=MR_computeTreeAND(t,pred->tcontext);\r
-        } else {\r
-          tset=MR_make_tree_from_set(pred->scontext[1]);\r
-          tAND=MR_computeTreeAND(t,tset);\r
-          Tfree(tset);\r
-        };\r
-        Tfree(t);\r
-        t=tAND;\r
-      };\r
-      goto EXIT;\r
-\r
-    }; /* end if on ampersand predicate */\r
-\r
-    TRAV(p->next,k,rk,t);\r
-\r
-EXIT:\r
-    if (save_fset != NULL) {\r
-      for (i=1 ; i <= CLL_k ; i++) {\r
-        set_free(fset[i]);\r
-        fset[i]=save_fset[i];\r
-      };\r
-      free ( (char *) save_fset);\r
-    };\r
-       return t;\r
-}\r
-\r
-/* see if e exists in s as a possible input permutation (e is always a chain) */\r
-\r
-int\r
-#ifdef __USE_PROTOS\r
-tmember( Tree *e, Tree *s )\r
-#else\r
-tmember( e, s )\r
-Tree *e;\r
-Tree *s;\r
-#endif\r
-{\r
-       if ( e==NULL||s==NULL ) return 0;\r
-/** fprintf(stderr, "tmember(");\r
-***    preorder(e); fprintf(stderr, ",");\r
-***    preorder(s); fprintf(stderr, " )\n");\r
-*/\r
-       if ( s->token == ALT && s->right == NULL ) return tmember(e, s->down);\r
-       if ( e->token!=s->token )\r
-       {\r
-               if ( s->right==NULL ) return 0;\r
-               return tmember(e, s->right);\r
-       }\r
-       if ( e->down==NULL && s->down == NULL ) return 1;\r
-       if ( tmember(e->down, s->down) ) return 1;\r
-       if ( s->right==NULL ) return 0;\r
-       return tmember(e, s->right);\r
-}\r
-\r
-/* see if e exists in s as a possible input permutation (e is always a chain);\r
- * Only check s to the depth of e.  In other words, 'e' can be a shorter\r
- * sequence than s.\r
- */\r
-int\r
-#ifdef __USE_PROTOS\r
-tmember_constrained( Tree *e, Tree *s)\r
-#else\r
-tmember_constrained( e, s )\r
-Tree *e;\r
-Tree *s;\r
-#endif\r
-{\r
-       if ( e==NULL||s==NULL ) return 0;\r
-/**    fprintf(stderr, "tmember_constrained(");\r
-***    preorder(e); fprintf(stderr, ",");\r
-***    preorder(s); fprintf(stderr, " )\n");\r
-**/\r
-       if ( s->token == ALT && s->right == NULL )\r
-               return tmember_constrained(e, s->down);\r
-       if ( e->token!=s->token )\r
-       {\r
-               if ( s->right==NULL ) return 0;\r
-               return tmember_constrained(e, s->right);\r
-       }\r
-       if ( e->down == NULL ) return 1; /* if s is matched to depth of e return */\r
-       if ( tmember_constrained(e->down, s->down) ) return 1;\r
-       if ( s->right==NULL ) return 0;\r
-       return tmember_constrained(e, s->right);\r
-}\r
-\r
-/* combine (? (A t) ... (A u) ...) into (? (A t u)) */\r
-Tree *\r
-#ifdef __USE_PROTOS\r
-tleft_factor( Tree *t )\r
-#else\r
-tleft_factor( t )\r
-Tree *t;\r
-#endif\r
-{\r
-       Tree *u, *v, *trail, *w;\r
-\r
-       /* left-factor what is at this level */\r
-       if ( t == NULL ) return NULL;\r
-       for (u=t; u!=NULL; u=u->right)\r
-       {\r
-               trail = u;\r
-               v=u->right;\r
-               while ( v!=NULL )\r
-               {\r
-                       if ( u->token == v->token )\r
-                       {\r
-                               if ( u->down!=NULL )\r
-                               {\r
-                                       for (w=u->down; w->right!=NULL; w=w->right) {;}\r
-                                       w->right = v->down;     /* link children together */\r
-                               }\r
-                               else u->down = v->down;\r
-                               trail->right = v->right;                /* unlink factored node */\r
-                               _Tfree( v );\r
-                               v = trail->right;\r
-                       }\r
-                       else {trail = v; v=v->right;}\r
-               }\r
-       }\r
-       /* left-factor what is below */\r
-       for (u=t; u!=NULL; u=u->right) u->down = tleft_factor( u->down );\r
-       return t;\r
-}\r
-\r
-/* remove the permutation p from t if present */\r
-Tree *\r
-#ifdef __USE_PROTOS\r
-trm_perm( Tree *t, Tree *p )\r
-#else\r
-trm_perm( t, p )\r
-Tree *t;\r
-Tree *p;\r
-#endif\r
-{\r
-       /*\r
-       fprintf(stderr, "trm_perm(");\r
-       preorder(t); fprintf(stderr, ",");\r
-       preorder(p); fprintf(stderr, " )\n");\r
-       */\r
-       if ( t == NULL || p == NULL ) return NULL;\r
-       if ( t->token == ALT )\r
-       {\r
-               t->down = trm_perm(t->down, p);\r
-               if ( t->down == NULL )                          /* nothing left below, rm cur node */\r
-               {\r
-                       Tree *u = t->right;\r
-                       _Tfree( t );\r
-                       return trm_perm(u, p);\r
-               }\r
-               t->right = trm_perm(t->right, p);       /* look for more instances of p */\r
-               return t;\r
-       }\r
-       if ( p->token != t->token )                             /* not found, try a sibling */\r
-       {\r
-               t->right = trm_perm(t->right, p);\r
-               return t;\r
-       }\r
-       t->down = trm_perm(t->down, p->down);\r
-       if ( t->down == NULL )                                  /* nothing left below, rm cur node */\r
-       {\r
-               Tree *u = t->right;\r
-               _Tfree( t );\r
-               return trm_perm(u, p);\r
-       }\r
-       t->right = trm_perm(t->right, p);               /* look for more instances of p */\r
-       return t;\r
-}\r
-\r
-/* add the permutation 'perm' to the LL_k sets in 'fset' */\r
-void\r
-#ifdef __USE_PROTOS\r
-tcvt( set *fset, Tree *perm )\r
-#else\r
-tcvt( fset, perm )\r
-set *fset;\r
-Tree *perm;\r
-#endif\r
-{\r
-       if ( perm==NULL ) return;\r
-       set_orel(perm->token, fset);\r
-       tcvt(fset+1, perm->down);\r
-}\r
-\r
-/* for each element of ftbl[k], make it the root of a tree with permute(ftbl[k+1])\r
- * as a child.\r
- */\r
-Tree *\r
-#ifdef __USE_PROTOS\r
-permute( int k, int max_k )\r
-#else\r
-permute( k, max_k )\r
-int k, max_k;\r
-#endif\r
-{\r
-       Tree *t, *u;\r
-       \r
-       if ( k>max_k ) return NULL;\r
-       if ( ftbl[k][findex[k]] == nil ) return NULL;\r
-       t = permute(k+1, max_k);\r
-       if ( t==NULL&&k<max_k )         /* no permutation left below for k+1 tokens? */\r
-       {\r
-               findex[k+1] = 0;\r
-               (findex[k])++;                  /* try next token at this k */\r
-               return permute(k, max_k);\r
-       }\r
-       \r
-       u = tmake(tnode(ftbl[k][findex[k]]), t, NULL);\r
-       if ( k == max_k ) (findex[k])++;\r
-       return u;\r
-}\r
-\r
-/* Compute LL(k) trees for alts alt1 and alt2 of p.\r
- * function result is tree of ambiguous input permutations\r
- *\r
- * ALGORITHM may change to look for something other than LL_k size\r
- * trees ==> maxk will have to change.\r
- */\r
-Tree *\r
-#ifdef __USE_PROTOS\r
-VerifyAmbig( Junction *alt1, Junction *alt2, unsigned **ft, set *fs, Tree **t, Tree **u, int *numAmbig )\r
-#else\r
-VerifyAmbig( alt1, alt2, ft, fs, t, u, numAmbig )\r
-Junction *alt1;\r
-Junction *alt2;\r
-unsigned **ft;\r
-set *fs;\r
-Tree **t;\r
-Tree **u;\r
-int *numAmbig;\r
-#endif\r
-{\r
-       set rk;\r
-       Tree *perm, *ambig=NULL;\r
-       Junction *p;\r
-       int k;\r
-    int    tnodes_at_start=TnodesAllocated;\r
-    int    tnodes_at_end;\r
-    int    tnodes_used;\r
-    set    *save_fs;\r
-    int    j;\r
-\r
-    save_fs=(set *) calloc(CLL_k+1,sizeof(set));\r
-    require(save_fs != NULL,"save_fs calloc");\r
-\r
-    for (j=0; j <= CLL_k ; j++) save_fs[j]=set_dup(fs[j]);\r
-\r
-       maxk = LL_k;                            /* NOTE: for now, we look for LL_k */\r
-       ftbl = ft;\r
-       fset = fs;\r
-       constrain = &(fset[1]);\r
-       findex = (int *) calloc(LL_k+1, sizeof(int));\r
-       if ( findex == NULL )\r
-       {\r
-               fprintf(stderr, ErrHdr, FileStr[CurAmbigfile], CurAmbigline);\r
-               fprintf(stderr, " out of memory while analyzing alts %d and %d of %s\n",\r
-                                               CurAmbigAlt1,\r
-                                               CurAmbigAlt2,\r
-                                               CurAmbigbtype);\r
-               exit(PCCTS_EXIT_FAILURE);\r
-       }\r
-       for (k=1; k<=LL_k; k++) findex[k] = 0;\r
-\r
-       rk = empty;\r
-       ConstrainSearch = 1;    /* consider only tokens in ambig sets */\r
-\r
-       p = analysis_point((Junction *)alt1->p1);\r
-       TRAV(p, LL_k, &rk, *t);\r
-       *t = tshrink( *t );\r
-       *t = tflatten( *t );\r
-       *t = tleft_factor( *t );    /* MR10 */\r
-       *t = prune(*t, LL_k);\r
-       *t = tleft_factor( *t );\r
-\r
-/***   fprintf(stderr, "after shrink&flatten&prune&left_factor:"); preorder(*t); fprintf(stderr, "\n");*/\r
-       if ( *t == NULL )\r
-       {\r
-/***   fprintf(stderr, "TreeIncomplete --> no LL(%d) ambiguity\n", LL_k);*/\r
-               Tfree( *t );    /* kill if impossible to have ambig */\r
-               *t = NULL;\r
-       }\r
-\r
-       p = analysis_point((Junction *)alt2->p1);\r
-\r
-       TRAV(p, LL_k, &rk, *u);\r
-       *u = tshrink( *u );\r
-       *u = tflatten( *u );\r
-       *t = tleft_factor( *t );    /* MR10 */\r
-       *u = prune(*u, LL_k);\r
-       *u = tleft_factor( *u );\r
-/*     fprintf(stderr, "after shrink&flatten&prune&lfactor:"); preorder(*u); fprintf(stderr, "\n");*/\r
-       if ( *u == NULL )\r
-       {\r
-/*             fprintf(stderr, "TreeIncomplete --> no LL(%d) ambiguity\n", LL_k);*/\r
-               Tfree( *u );\r
-               *u = NULL;\r
-       }\r
-\r
-       for (k=1; k<=LL_k; k++) set_clr( fs[k] );\r
-\r
-       ambig = tnode(ALT);\r
-       k = 0;\r
-       if ( *t!=NULL && *u!=NULL )\r
-       {\r
-               while ( (perm=permute(1,LL_k))!=NULL )\r
-               {\r
-/*                     fprintf(stderr, "chk perm:"); preorder(perm); fprintf(stderr, "\n");*/\r
-                       if ( tmember(perm, *t) && tmember(perm, *u) )\r
-                       {\r
-/*                             fprintf(stderr, "ambig upon"); preorder(perm); fprintf(stderr, "\n");*/\r
-\r
-                               k++;\r
-                               perm->right = ambig->down;\r
-                               ambig->down = perm;\r
-                               tcvt(&(fs[1]), perm);\r
-                       }\r
-                       else Tfree( perm );\r
-               }\r
-       }\r
-\r
-    for (j=0; j <= CLL_k ; j++) fs[j]=save_fs[j];\r
-    free( (char *) save_fs);\r
-\r
-    tnodes_at_end=TnodesAllocated;\r
-    tnodes_used=tnodes_at_end - tnodes_at_start;\r
-\r
-    if (TnodesReportThreshold > 0 && tnodes_used > TnodesReportThreshold) {\r
-      fprintf(stdout,"There were %d tuples whose ambiguity could not be resolved by full lookahead\n",k);\r
-      fprintf(stdout,"There were %d tnodes created to resolve ambiguity between:\n\n",tnodes_used);\r
-      fprintf(stdout,"  Choice 1: %s  line %d  file %s\n",\r
-                                 MR_ruleNamePlusOffset( (Node *) alt1),alt1->line,FileStr[alt1->file]);\r
-      fprintf(stdout,"  Choice 2: %s  line %d  file %s\n",\r
-                                 MR_ruleNamePlusOffset( (Node *) alt2),alt2->line,FileStr[alt2->file]);\r
-      for (j=1; j <= CLL_k ; j++) {\r
-        fprintf(stdout,"\n    Intersection of lookahead[%d] sets:\n",j);\r
-        MR_dumpTokenSet(stdout,2,fs[j]);\r
-      };\r
-      fprintf(stdout,"\n");\r
-    };\r
-\r
-       *numAmbig = k;\r
-       if ( ambig->down == NULL ) {_Tfree(ambig); ambig = NULL;}\r
-       free( (char *)findex );\r
-/*     fprintf(stderr, "final ambig:"); preorder(ambig); fprintf(stderr, "\n");*/\r
-       return ambig;\r
-}\r
-\r
-static Tree *\r
-#ifdef __USE_PROTOS\r
-bottom_of_chain( Tree *t )\r
-#else\r
-bottom_of_chain( t )\r
-Tree *t;\r
-#endif\r
-{\r
-    if ( t==NULL ) return NULL;\r
-    for (; t->down != NULL; t=t->down) {;}\r
-    return t;\r
-}\r
-\r
-/*\r
- * Make a tree from k sets where the degree of the first k-1 sets is 1.\r
- */\r
-Tree *\r
-#ifdef __USE_PROTOS\r
-make_tree_from_sets( set *fset1, set *fset2 )\r
-#else\r
-make_tree_from_sets( fset1, fset2 )\r
-set *fset1;\r
-set *fset2;\r
-#endif\r
-{\r
-       set inter;\r
-       int i;\r
-       Tree *t=NULL, *n, *u;\r
-       unsigned *p,*q;\r
-       require(LL_k>1, "make_tree_from_sets: LL_k must be > 1");\r
-\r
-       /* do the degree 1 sets first */\r
-       for (i=1; i<=LL_k-1; i++)\r
-       {\r
-               inter = set_and(fset1[i], fset2[i]);\r
-               require(set_deg(inter)==1, "invalid set to tree conversion");\r
-               n = tnode(set_int(inter));\r
-               if (t==NULL) t=n; else tmake(t, n, NULL);\r
-               set_free(inter);\r
-       }\r
-\r
-       /* now add the chain of tokens at depth k */\r
-       u = bottom_of_chain(t);\r
-       inter = set_and(fset1[LL_k], fset2[LL_k]);\r
-       if ( (q=p=set_pdq(inter)) == NULL ) fatal_internal("Can't alloc space for set_pdq");\r
-       /* first one is linked to bottom, then others are sibling linked */\r
-       n = tnode(*p++);\r
-       u->down = n;\r
-       u = u->down;\r
-       while ( *p != nil )\r
-       {\r
-               n = tnode(*p);\r
-               u->right = n;\r
-               u = u->right;\r
-               p++;\r
-       }\r
-       free((char *)q);\r
-\r
-       return t;\r
-}\r
-\r
-/* create and return the tree of lookahead k-sequences that are in t, but not\r
- * in the context of predicates in predicate list p.\r
- */\r
-Tree *\r
-#ifdef __USE_PROTOS\r
-tdif( Tree *ambig_tuples, Predicate *p, set *fset1, set *fset2 )\r
-#else\r
-tdif( ambig_tuples, p, fset1, fset2 )\r
-Tree *ambig_tuples;\r
-Predicate *p;\r
-set *fset1;\r
-set *fset2;\r
-#endif\r
-{\r
-       unsigned **ft;\r
-       Tree *dif=NULL;\r
-       Tree *perm;\r
-       set b;\r
-       int i,k;\r
-\r
-       if ( p == NULL ) return tdup(ambig_tuples);\r
-\r
-       ft = (unsigned **) calloc(CLL_k+1, sizeof(unsigned *));\r
-       require(ft!=NULL, "cannot allocate ft");\r
-       for (i=1; i<=CLL_k; i++)\r
-       {\r
-               b = set_and(fset1[i], fset2[i]);\r
-               ft[i] = set_pdq(b);\r
-               set_free(b);\r
-       }\r
-       findex = (int *) calloc(LL_k+1, sizeof(int));\r
-       if ( findex == NULL )\r
-       {\r
-               fatal_internal("out of memory in tdif while checking predicates");\r
-       }\r
-       for (k=1; k<=LL_k; k++) findex[k] = 0;\r
-\r
-#ifdef DBG_TRAV\r
-       fprintf(stderr, "tdif_%d[", p->k);\r
-       preorder(ambig_tuples);\r
-       fprintf(stderr, ",");\r
-       preorder(p->tcontext);\r
-       fprintf(stderr, "] =");\r
-#endif\r
-\r
-       ftbl = ft;\r
-       while ( (perm=permute(1,p->k))!=NULL )\r
-       {\r
-#ifdef DBG_TRAV\r
-               fprintf(stderr, "test perm:"); preorder(perm); fprintf(stderr, "\n");\r
-#endif\r
-               if ( tmember_constrained(perm, ambig_tuples) &&\r
-                        !tmember_of_context(perm, p) )\r
-               {\r
-#ifdef DBG_TRAV\r
-                       fprintf(stderr, "satisfied upon"); preorder(perm); fprintf(stderr, "\n");\r
-#endif\r
-                       k++;\r
-                       if ( dif==NULL ) dif = perm;\r
-                       else\r
-                       {\r
-                               perm->right = dif;\r
-                               dif = perm;\r
-                       }\r
-               }\r
-               else Tfree( perm );\r
-       }\r
-\r
-#ifdef DBG_TRAV\r
-       preorder(dif);\r
-       fprintf(stderr, "\n");\r
-#endif\r
-\r
-       for (i=1; i<=CLL_k; i++) free( (char *)ft[i] );\r
-       free((char *)ft);\r
-       free((char *)findex);\r
-\r
-       return dif;\r
-}\r
-\r
-/* is lookahead sequence t a member of any context tree for any\r
- * predicate in p?\r
- */\r
-static int\r
-#ifdef __USE_PROTOS\r
-tmember_of_context( Tree *t, Predicate *p )\r
-#else\r
-tmember_of_context( t, p )\r
-Tree *t;\r
-Predicate *p;\r
-#endif\r
-{\r
-       for (; p!=NULL; p=p->right)\r
-       {\r
-               if ( p->expr==PRED_AND_LIST || p->expr==PRED_OR_LIST )\r
-                       return tmember_of_context(t, p->down);\r
-               if ( tmember_constrained(t, p->tcontext) ) return 1;\r
-               if ( tmember_of_context(t, p->down) ) return 1;\r
-       }\r
-       return 0;\r
-}\r
-\r
-int\r
-#ifdef __USE_PROTOS\r
-is_single_tuple( Tree *t )\r
-#else\r
-is_single_tuple( t )\r
-Tree *t;\r
-#endif\r
-{\r
-       if ( t == NULL ) return 0;\r
-       if ( t->right != NULL ) return 0;\r
-       if ( t->down == NULL ) return 1;\r
-       return is_single_tuple(t->down);\r
-}\r
-\r
-\r
-/* MR10 Check that a context guard contains only allowed things */\r
-/* MR10   (mainly token references).                            */\r
-\r
-#ifdef __USE_PROTOS\r
-int contextGuardOK(Node *p,int h,int *hmax)\r
-#else\r
-int contextGuardOK(p,h,hmax)\r
-  Node  *p;\r
-  int   h;\r
-  int   *hmax;\r
-#endif\r
-{\r
-    Junction     *j;\r
-    TokNode      *tn;\r
-\r
-    if (p == NULL) return 1;\r
-    if (p->ntype == nToken) {\r
-      h++;\r
-      if (h > *hmax) *hmax=h;\r
-      tn=(TokNode *)p;\r
-      if (tn->el_label != NULL) {\r
-        warnFL(eMsg1("a label (\"%s\") for a context guard element is meaningless",tn->el_label),\r
-                             FileStr[p->file],p->line);\r
-      };\r
-      return contextGuardOK( ( (TokNode *) p)->next,h,hmax);\r
-    } else if (p->ntype == nAction) {\r
-      goto Fail;\r
-    } else if (p->ntype == nRuleRef) {\r
-      goto Fail;\r
-    } else {\r
-      require (p->ntype == nJunction,"Unexpected ntype");\r
-      j=(Junction *) p;\r
-      if (j->jtype != Generic &&\r
-          j->jtype != aSubBlk &&        /* pretty sure this one is allowed */\r
-/****     j->jtype != aOptBlk && ****/  /* pretty sure this one is allowed */ /* MR11 not any more ! */\r
-          j->jtype != EndBlk) {\r
-        errFL("A context guard may not contain an option block: {...} or looping block: (...)* or (...)+",\r
-                  FileStr[p->file],p->line);\r
-        contextGuardOK(j->p1,h,hmax);\r
-        return 0;\r
-      };\r
-      /* do both p1 and p2 so use | rather than ||  */\r
-      return contextGuardOK(j->p2,h,hmax) | contextGuardOK(j->p1,h,hmax);\r
-    };\r
-Fail:\r
-    errFL("A context guard may contain only Token references - guard will be ignored",\r
-                             FileStr[p->file],p->line);\r
-    contextGuardOK( ( (ActionNode *) p)->next,h,hmax);\r
-    return 0;\r
-}\r
-\r
-/*\r
- * Look at a (...)? generalized-predicate context-guard and compute\r
- * either a lookahead set (k==1) or a lookahead tree for k>1.  The\r
- * k level is determined by the guard itself rather than the LL_k\r
- * variable.  For example, ( A B )? is an LL(2) guard and ( ID )?\r
- * is an LL(1) guard.  For the moment, you can only have a single\r
- * tuple in the guard.  Physically, the block must look like this\r
- *   --o-->TOKEN-->o-->o-->TOKEN-->o-- ... -->o-->TOKEN-->o--\r
- * An error is printed for any other type.\r
- */\r
-Predicate *\r
-#ifdef __USE_PROTOS\r
-computePredFromContextGuard(Graph blk,int *msgDone)    /* MR10 */\r
-#else\r
-computePredFromContextGuard(blk,msgDone)               /* MR10 */\r
-  Graph     blk;\r
-  int       *msgDone;                                       /* MR10 */\r
-#endif\r
-{\r
-    Junction *junc = (Junction *)blk.left, *p;\r
-    Tree        *t=NULL;\r
-       Predicate   *pred = NULL;\r
-       set         scontext, rk;\r
-    int         ok;\r
-    int         hmax=0;\r
-\r
-    require(junc!=NULL && junc->ntype == nJunction, "bad context guard");\r
-\r
-/* MR10 Check for anything other than Tokens and generic junctions */\r
-\r
-    *msgDone=0;                                             /* MR10 */\r
-    ok=contextGuardOK( (Node *)junc,0,&hmax);               /* MR10 */\r
-    if (! ok) {                                             /* MR10 */\r
-      *msgDone=1;                                           /* MR10 */\r
-      return NULL;                                          /* MR10 */\r
-    };                                                      /* MR10 */\r
-    if (hmax == 0) {\r
-errFL("guard is 0 tokens long",FileStr[junc->file],junc->line);          /* MR11 */\r
-      *msgDone=1;\r
-      return NULL;\r
-    };\r
-    if (hmax > CLL_k) {                                     /* MR10 */\r
-errFL(eMsgd2("guard is %d tokens long - lookahead is limited to max(k,ck)==%d", /* MR10 */\r
-        hmax,CLL_k),                                        /* MR10 */\r
-        FileStr[junc->file],junc->line);                    /* MR10 */\r
-      *msgDone=1;                                           /* MR10 */\r
-      return NULL;                                          /* MR10 */\r
-    };                                                      /* MR10 */\r
-\r
-       rk = empty;\r
-       p = junc;\r
-       pred = new_pred();\r
-       pred->k = hmax;     /* MR10 should be CLL_k, not LLK ? */\r
-       if (hmax > 1 )      /* MR10 was LL_k                   */\r
-       {\r
-               ConstrainSearch = 0;\r
-               ContextGuardTRAV = 1;\r
-               TRAV(p, hmax, &rk, t);  /* MR10 was LL_k */\r
-               ContextGuardTRAV = 0;\r
-               set_free(rk);\r
-               t = tshrink( t );\r
-               t = tflatten( t );\r
-               t = tleft_factor( t );\r
-/*\r
-               fprintf(stderr, "ctx guard:");\r
-               preorder(t);\r
-               fprintf(stderr, "\n");\r
-*/\r
-               pred->tcontext = t;\r
-       }\r
-       else\r
-       {\r
-               REACH(p, 1, &rk, scontext);\r
-               require(set_nil(rk), "rk != nil");\r
-               set_free(rk);\r
-/*\r
-               fprintf(stderr, "LL(1) ctx guard is:");\r
-               s_fprT(stderr, scontext);\r
-               fprintf(stderr, "\n");\r
-*/\r
-               pred->scontext[1] = scontext;\r
-       }\r
-\r
-    list_add(&ContextGuardPredicateList,pred);     /* MR13 */\r
-\r
-       return pred;\r
-}\r
-\r
-/* MR13\r
-   When the context guard is originally computed the\r
-   meta-tokens are not known.\r
-*/\r
-\r
-#ifdef __USE_PROTOS\r
-void recomputeContextGuard(Predicate *pred)\r
-#else\r
-void recomputeContextGuard(pred)\r
-    Predicate   *pred;\r
-#endif\r
-{\r
-    Tree *          t=NULL;\r
-       set             scontext;\r
-    set             rk;\r
-    ActionNode *    actionNode;\r
-    Junction *      p;\r
-\r
-    actionNode=pred->source;\r
-    require (actionNode != NULL,"context predicate's source == NULL");\r
-\r
-    p=actionNode->guardNodes;\r
-    require (p != NULL,"context predicate's guardNodes == NULL");\r
-\r
-       rk = empty;\r
-       if (pred->k > 1 )\r
-       {\r
-               ConstrainSearch = 0;\r
-               ContextGuardTRAV = 1;\r
-               TRAV(p, pred->k, &rk, t);\r
-               ContextGuardTRAV = 0;\r
-               set_free(rk);\r
-               t = tshrink( t );\r
-               t = tflatten( t );\r
-               t = tleft_factor( t );\r
-        Tfree(pred->tcontext);\r
-               pred->tcontext = t;\r
-       }\r
-       else\r
-       {\r
-               REACH(p, 1, &rk, scontext);\r
-               require(set_nil(rk), "rk != nil");\r
-               set_free(rk);\r
-        set_free(pred->scontext[1]);\r
-               pred->scontext[1] = scontext;\r
-       }\r
-}\r
-\r
-/* MR11 - had enough of flags yet ? */\r
-\r
-int     MR_AmbSourceSearch=0;\r
-int     MR_AmbSourceSearchGroup=0;\r
-int     MR_AmbSourceSearchChoice=0;\r
-int     MR_AmbSourceSearchLimit=0;\r
-int     MR_matched_AmbAidRule=0;\r
-\r
-static    set         *matchSets[2]={NULL,NULL};\r
-static    int         *tokensInChain=NULL;\r
-static    Junction    *MR_AmbSourceSearchJ[2];\r
-\r
-void MR_traceAmbSourceKclient()\r
-{\r
-  int       i;\r
-  set       *save_fset;\r
-  int       save_ConstrainSearch;\r
-  set       incomplete;\r
-  Tree      *t;\r
-\r
-  if (matchSets[0] == NULL) {\r
-    matchSets[0]=(set *) calloc (CLL_k+1,sizeof(set));\r
-    require (matchSets[0] != NULL,"matchSets[0] alloc");\r
-    matchSets[1]=(set *) calloc (CLL_k+1,sizeof(set));\r
-    require (matchSets[1] != NULL,"matchSets[1] alloc");\r
-  };\r
-\r
-  for (i=1 ; i <= MR_AmbSourceSearchLimit ; i++) {\r
-    set_clr(matchSets[0][i]);\r
-    set_orel( (unsigned) tokensInChain[i],\r
-                              &matchSets[0][i]);\r
-    set_clr(matchSets[1][i]);\r
-    set_orel( (unsigned) tokensInChain[i],\r
-                              &matchSets[1][i]);\r
-  };\r
-\r
-  save_fset=fset;\r
-  save_ConstrainSearch=ConstrainSearch;\r
-\r
-\r
-\r
-  for (i=0 ; i < 2 ; i++) {\r
-\r
-#if 0\r
-**    fprintf(stdout,"  Choice:%d  Depth:%d  ",i+1,MR_AmbSourceSearchLimit);\r
-**    fprintf(stdout,"(");\r
-**    for (j=1 ; j <= MR_AmbSourceSearchLimit ; j++) {\r
-**      if (j != 1) fprintf(stdout," ");\r
-**      fprintf(stdout,"%s",TerminalString(tokensInChain[j]));\r
-**    };\r
-**    fprintf(stdout,")\n\n");\r
-#endif\r
-\r
-    fset=matchSets[i];\r
-\r
-    MR_AmbSourceSearch=1;\r
-    MR_MaintainBackTrace=1;\r
-    MR_AmbSourceSearchChoice=i;\r
-    ConstrainSearch=1;\r
-\r
-    maxk = MR_AmbSourceSearchLimit;\r
-\r
-    incomplete=empty;\r
-    t=NULL;\r
-\r
-    constrain = &(fset[1]);\r
-    MR_pointerStackReset(&MR_BackTraceStack);\r
-\r
-    TRAV(MR_AmbSourceSearchJ[i],maxk,&incomplete,t);\r
-\r
-    Tfree(t);\r
-\r
-    require (set_nil(incomplete),"MR_traceAmbSourceK TRAV incomplete");\r
-    require (MR_BackTraceStack.count == 0,"K: MR_BackTraceStack.count != 0");\r
-\r
-    set_free(incomplete);\r
-  };\r
-\r
-  ConstrainSearch=save_ConstrainSearch;\r
-  fset=save_fset;\r
-  MR_AmbSourceSearch=0;\r
-  MR_MaintainBackTrace=0;\r
-  MR_AmbSourceSearchChoice=0;\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-Tree *tTrunc(Tree *t,int depth)\r
-#else\r
-Tree *tTrunc(t,depth)\r
-  Tree  *t;\r
-#endif\r
-{\r
-    Tree    *u;\r
-\r
-    require ( ! (t == NULL && depth > 0),"tree too short");\r
-\r
-    if (depth == 0) return NULL;\r
-\r
-    if (t->token == ALT) {\r
-      u=tTrunc(t->down,depth);\r
-    } else {\r
-      u=tnode(t->token);\r
-      u->down=tTrunc(t->down,depth-1);\r
-    };\r
-    if (t->right != NULL) u->right=tTrunc(t->right,depth);\r
-    return u;\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-void MR_iterateOverTree(Tree *t,int chain[])\r
-#else\r
-void MR_iterateOverTree(t,chain)\r
-  Tree          *t;\r
-  int           chain[];\r
-#endif\r
-{\r
-  if (t == NULL) return;\r
-  chain[0]=t->token;\r
-  if (t->down != NULL) {\r
-    MR_iterateOverTree(t->down,&chain[1]);\r
-  } else {\r
-    MR_traceAmbSourceKclient();\r
-  };\r
-  MR_iterateOverTree(t->right,&chain[0]);\r
-  chain[0]=0;\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-void MR_traceAmbSourceK(Tree *t,Junction *alt1,Junction *alt2)\r
-#else\r
-void MR_traceAmbSourceK(t,alt1,alt2)\r
-  Tree      *t;\r
-  Junction  *alt1;\r
-  Junction  *alt2;\r
-#endif\r
-{\r
-    int         i;\r
-    int         depth;\r
-    int         maxDepth;\r
-    Tree        *truncatedTree;\r
-\r
-    if (MR_AmbAidRule == NULL) return;\r
-\r
-    if ( ! (\r
-            strcmp(MR_AmbAidRule,alt1->rname) == 0 ||\r
-            strcmp(MR_AmbAidRule,alt2->rname) == 0 ||\r
-            MR_AmbAidLine==alt1->line ||\r
-            MR_AmbAidLine==alt2->line\r
-           )\r
-       ) return;\r
-\r
-    MR_matched_AmbAidRule++;\r
-\r
-    /* there are no token sets in trees, only in TokNodes */\r
-\r
-    MR_AmbSourceSearchJ[0]=analysis_point( (Junction *) alt1->p1);\r
-    MR_AmbSourceSearchJ[1]=analysis_point( (Junction *) alt2->p1);\r
-\r
-    if (tokensInChain == NULL) {\r
-      tokensInChain=(int *) calloc (CLL_k+1,sizeof(int));\r
-      require (tokensInChain != NULL,"tokensInChain alloc");\r
-    };\r
-\r
-    MR_AmbSourceSearchGroup=0;\r
-\r
-    fprintf(stdout,"\n");\r
-    fprintf(stdout,"  Ambiguity Aid                 ");\r
-    fprintf(stdout,\r
-                (MR_AmbAidDepth <= LL_k ?\r
-                    "(-k %d  -aa %s  %s  -aad %d)\n\n" :\r
-                        "(-k %d  -aa %s  %s  [-k value limits -aad %d])\n\n"),\r
-                LL_k,\r
-                MR_AmbAidRule,\r
-                (MR_AmbAidMultiple ? "-aam" : ""),\r
-                MR_AmbAidDepth);\r
-\r
-    for (i=0 ; i < 2 ; i++) {\r
-      fprintf(stdout,"    Choice %d: %-25s  line %d  file %s\n",\r
-                  (i+1),\r
-                  MR_ruleNamePlusOffset( (Node *) MR_AmbSourceSearchJ[i]),\r
-                  MR_AmbSourceSearchJ[i]->line,\r
-                  FileStr[MR_AmbSourceSearchJ[i]->file]);\r
-    };\r
-\r
-    fprintf(stdout,"\n");\r
-\r
-    if (MR_AmbAidDepth < LL_k) {\r
-      maxDepth=MR_AmbAidDepth;\r
-    } else {\r
-      maxDepth=LL_k;\r
-    };\r
-\r
-    for (depth=1 ; depth <= maxDepth; depth++) {\r
-      MR_AmbSourceSearchLimit=depth;\r
-      if (depth < LL_k) {\r
-        truncatedTree=tTrunc(t,depth);\r
-        truncatedTree=tleft_factor(truncatedTree);\r
-        MR_iterateOverTree(truncatedTree,&tokensInChain[1]);    /* <===== */\r
-        Tfree(truncatedTree);\r
-      } else {\r
-        MR_iterateOverTree(t,tokensInChain);                /* <===== */\r
-      };\r
-      fflush(stdout);\r
-      fflush(stderr);\r
-    };\r
-\r
-    fprintf(stdout,"\n");\r
-    MR_AmbSourceSearch=0;\r
-    MR_MaintainBackTrace=0;\r
-    MR_AmbSourceSearchGroup=0;\r
-    MR_AmbSourceSearchChoice=0;\r
-    MR_AmbSourceSearchLimit=0;\r
-\r
-}\r
-\r
-\r
-/* this if for k=1 grammars only\r
-\r
-   this is approximate only because of the limitations of linear\r
-   approximation lookahead.  Don't want to do a k=3 search when\r
-   the user only specified a ck=3 grammar\r
-*/\r
-\r
-#ifdef __USE_PROTOS\r
-void MR_traceAmbSource(set *matchSets,Junction *alt1, Junction *alt2)\r
-#else\r
-void MR_traceAmbSource(matchSets,alt1,alt2)\r
-  set       *matchSets;\r
-  Junction  *alt1;\r
-  Junction  *alt2;\r
-#endif\r
-{\r
-    set         *save_fset;\r
-    Junction    *p[2];\r
-    int         i;\r
-    int         j;\r
-    set         *dup_matchSets;\r
-    set         intersection;\r
-    set         incomplete;\r
-    set         tokensUsed;\r
-    int         depth;\r
-\r
-    if (MR_AmbAidRule == NULL) return;\r
-    if ( ! (\r
-            strcmp(MR_AmbAidRule,alt1->rname) == 0 ||\r
-            strcmp(MR_AmbAidRule,alt2->rname) == 0 ||\r
-            MR_AmbAidLine==alt1->line ||\r
-            MR_AmbAidLine==alt2->line\r
-           )\r
-       ) return;\r
-\r
-    MR_matched_AmbAidRule++;\r
-\r
-    save_fset=fset;\r
-\r
-    dup_matchSets=(set *) calloc(CLL_k+1,sizeof(set));\r
-    require (dup_matchSets != NULL,"Can't allocate dup_matchSets");\r
-\r
-    p[0]=analysis_point( (Junction *) alt1->p1);\r
-    p[1]=analysis_point( (Junction *) alt2->p1);\r
-\r
-    fprintf(stdout,"\n");\r
-\r
-    fprintf(stdout,"  Ambiguity Aid                 ");\r
-    fprintf(stdout,\r
-                (MR_AmbAidDepth <= CLL_k ?\r
-                    "(-ck %d  -aa %s  %s  -aad %d)\n\n" :\r
-                        "(-ck %d  -aa %s  %s  [-ck value limits -aad %d])\n\n"),\r
-                CLL_k,\r
-                MR_AmbAidRule,\r
-                (MR_AmbAidMultiple ? "-aam" : ""),\r
-                MR_AmbAidDepth);\r
-\r
-    for (i=0 ; i < 2 ; i++) {\r
-      fprintf(stdout,"    Choice %d: %-25s  line %d  file %s\n",\r
-                            (i+1),\r
-                            MR_ruleNamePlusOffset( (Node *) p[i]),\r
-                            p[i]->line,FileStr[p[i]->file]);\r
-    };\r
-\r
-    for (j=1; j <= CLL_k ; j++) {\r
-      fprintf(stdout,"\n    Intersection of lookahead[%d] sets:\n",j);\r
-      intersection=set_and(alt1->fset[j],alt2->fset[j]);\r
-      MR_dumpTokenSet(stdout,2,intersection);\r
-      set_free(intersection);\r
-    };\r
-\r
-    fprintf(stdout,"\n");\r
-\r
-    require (1 <= MR_AmbAidDepth && MR_AmbAidDepth <= CLL_k,\r
-                "illegal MR_AmbAidDepth");\r
-\r
-    MR_AmbSourceSearchGroup=0;\r
-    for (depth=1; depth <= MR_AmbAidDepth; depth++) {\r
-        MR_AmbSourceSearchLimit=depth;\r
-        for (i=0 ; i < 2 ; i++) {\r
-\r
-/***        fprintf(stdout,"  Choice:%d  Depth:%d\n\n",i+1,depth);  ***/\r
-\r
-            for (j=0 ; j <= CLL_k ; j++) { dup_matchSets[j]=set_dup(matchSets[j]); };\r
-            fset=dup_matchSets;\r
-\r
-            fflush(output);\r
-            fflush(stdout);\r
-\r
-            MR_AmbSourceSearch=1;\r
-            MR_MaintainBackTrace=1;\r
-            MR_AmbSourceSearchChoice=i;\r
-\r
-            maxk = depth;\r
-            tokensUsed=empty;\r
-            incomplete=empty;\r
-\r
-            constrain = &(fset[1]);\r
-            MR_pointerStackReset(&MR_BackTraceStack);\r
-\r
-            REACH(p[i],depth,&incomplete,tokensUsed);\r
-\r
-            fflush(output);\r
-            fflush(stdout);\r
-\r
-            require (set_nil(incomplete),"MR_traceAmbSource REACH incomplete");\r
-            require (MR_BackTraceStack.count == 0,"1: MR_BackTraceStack.count != 0");\r
-\r
-            set_free(incomplete);\r
-            set_free(tokensUsed);\r
-\r
-            for (j=0 ; j <= CLL_k ; j++) { set_free(dup_matchSets[j]); };\r
-        };\r
-    };\r
-\r
-    fprintf(stdout,"\n");\r
-\r
-    MR_AmbSourceSearch=0;\r
-    MR_MaintainBackTrace=0;\r
-    MR_AmbSourceSearchGroup=0;\r
-    MR_AmbSourceSearchChoice=0;\r
-    MR_AmbSourceSearchLimit=0;\r
-\r
-    fset=save_fset;\r
-    free ( (char *) dup_matchSets);\r
-}\r
-\r
-static int itemCount;\r
-\r
-void MR_backTraceDumpItemReset() {\r
-  itemCount=0;\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-void MR_backTraceDumpItem(FILE *f,int skip,Node *n)\r
-#else\r
-void MR_backTraceDumpItem(f,skip,n)\r
-  FILE      *f;\r
-  int       skip;\r
-  Node      *n;\r
-#endif\r
-{\r
-  TokNode       *tn;\r
-  RuleRefNode   *rrn;\r
-  Junction      *j;\r
-  ActionNode    *a;\r
-\r
-  switch (n->ntype) {\r
-    case nToken:\r
-        itemCount++; if (skip) goto EXIT;\r
-        tn=(TokNode *)n;\r
-        if (set_nil(tn->tset)) {\r
-          fprintf(f,"  %2d #token %-23s",itemCount,TerminalString(tn->token));\r
-        } else {\r
-          fprintf(f,"  %2d #tokclass %-20s",itemCount,TerminalString(tn->token));\r
-        };\r
-        break;\r
-    case nRuleRef:\r
-        itemCount++; if (skip) goto EXIT;\r
-        rrn=(RuleRefNode *)n;\r
-        fprintf(f,"  %2d to %-27s",itemCount,rrn->text);\r
-        break;\r
-    case nAction:\r
-        a=(ActionNode *)n;\r
-        goto EXIT;\r
-    case nJunction:\r
-\r
-      j=(Junction *)n;\r
-\r
-      switch (j->jtype) {\r
-        case aSubBlk:\r
-            if (j->guess) {\r
-              itemCount++; if (skip) goto EXIT;\r
-              fprintf(f,"  %2d %-30s",itemCount,"in (...)? block at");\r
-              break;\r
-            };\r
-/******     fprintf(f,"  %2d %-32s",itemCount,"in (...) block at");  *******/\r
-/******     break;                                                          *******/\r
-            goto EXIT;\r
-        case aOptBlk:\r
-            itemCount++; if (skip) goto EXIT;\r
-            fprintf(f,"  %2d %-30s",itemCount,"in {...} block");\r
-            break;\r
-        case aLoopBlk:\r
-            itemCount++; if (skip) goto EXIT;\r
-            fprintf(f,"  %2d %-30s",itemCount,"in (...)* block");\r
-            break;\r
-        case EndBlk:\r
-            if (j->alpha_beta_guess_end) {\r
-              itemCount++; if (skip) goto EXIT;\r
-              fprintf(f,"  %2d %-30s",itemCount,"end (...)? block at");\r
-              break;\r
-            };\r
-            goto EXIT;\r
-/******     fprintf(f,"  %2d %-32s",itemCount,"end of a block at");     *****/\r
-/******     break;                                                             *****/\r
-        case RuleBlk:\r
-            itemCount++; if (skip) goto EXIT;\r
-            fprintf(f,"  %2d %-30s",itemCount,j->rname);\r
-            break;\r
-        case Generic:\r
-            goto EXIT;\r
-        case EndRule:\r
-            itemCount++; if (skip) goto EXIT;\r
-            fprintf (f,"  %2d end %-26s",itemCount,j->rname);\r
-            break;\r
-        case aPlusBlk:\r
-            itemCount++; if (skip) goto EXIT;\r
-            fprintf(f,"  %2d %-30s",itemCount,"in (...)+ block");\r
-            break;\r
-        case aLoopBegin:\r
-            goto EXIT;\r
-      };\r
-      break;\r
-  };\r
-  fprintf(f," %-23s line %-4d  %s\n",MR_ruleNamePlusOffset(n),n->line,FileStr[n->file]);\r
-EXIT:\r
-  return;\r
-}\r
-\r
-\r
-static PointerStack     previousBackTrace={0,0,NULL};\r
-\r
-#ifdef __USE_PROTOS\r
-void MR_backTraceReport(void)\r
-#else\r
-void MR_backTraceReport()\r
-#endif\r
-{\r
-  int       i;\r
-  int       match = 0;\r
-  int       limitMatch;\r
-\r
-  Node      *p;\r
-  TokNode   *tn;\r
-  set       remainder;\r
-  int       depth;\r
-\r
-  /* Even when doing a k=2 search this routine can get\r
-       called when there is only 1 token on the stack.\r
-     This is because something like rRuleRef can change\r
-       the search value of k from 2 to 1 temporarily.\r
-     It does this because the it wants to know the k=1\r
-       first set before it does a k=2 search\r
-  */\r
-\r
-  depth=0;\r
-  for (i=0; i < MR_BackTraceStack.count ; i++) {\r
-    p=(Node *) MR_BackTraceStack.data[i];\r
-    if (p->ntype == nToken) depth++;\r
-  };\r
-\r
-/* MR14 */  if (MR_AmbSourceSearch) {\r
-/* MR14 */     require (depth <= MR_AmbSourceSearchLimit,"depth > MR_AmbSourceSearchLimit");\r
-/* MR14 */  }\r
-\r
-  /* MR23 THM - Traceback report was being called at the wrong time for -alpha reports */\r
-  /*            Reported by Arpad Beszedes (beszedes@inf.u-szeged.hu)                  */\r
-\r
-  if (MR_AmbSourceSearchLimit == 0 || depth < MR_AmbSourceSearchLimit) {\r
-    return;\r
-  };\r
-\r
-  MR_backTraceDumpItemReset();\r
-\r
-  limitMatch=MR_BackTraceStack.count;\r
-  if (limitMatch > previousBackTrace.count) {\r
-    limitMatch=previousBackTrace.count;\r
-  };\r
-\r
-  for (match=0; match < limitMatch; match++) {\r
-    if (MR_BackTraceStack.data[match] !=\r
-        previousBackTrace.data[match]) {\r
-      break;\r
-    };\r
-  };\r
-\r
-  /* not sure at the moment why there would be duplicates */\r
-\r
-  if (match != MR_BackTraceStack.count) {\r
-\r
-    fprintf(stdout,"     Choice:%d  Depth:%d  Group:%d",\r
-        (MR_AmbSourceSearchChoice+1),\r
-        MR_AmbSourceSearchLimit,\r
-        ++MR_AmbSourceSearchGroup);\r
-\r
-    depth=0;\r
-    fprintf(stdout,"  (");\r
-    for (i=0; i < MR_BackTraceStack.count ; i++) {\r
-      p=(Node *) MR_BackTraceStack.data[i];\r
-      if (p->ntype != nToken) continue;\r
-      tn=(TokNode *)p;\r
-      if (depth != 0) fprintf(stdout," ");\r
-      fprintf(stdout,TerminalString(tn->token));\r
-      depth++;\r
-      if (! MR_AmbAidMultiple) {\r
-        if (set_nil(tn->tset)) {\r
-          set_rm( (unsigned) tn->token,fset[depth]);\r
-        } else {\r
-          remainder=set_dif(fset[depth],tn->tset);\r
-          set_free(fset[depth]);\r
-          fset[depth]=remainder;\r
-        };\r
-      };\r
-    };\r
-    fprintf(stdout,")\n");\r
-\r
-    for (i=0; i < MR_BackTraceStack.count ; i++) {\r
-      MR_backTraceDumpItem(stdout, (i<match) ,(Node *) MR_BackTraceStack.data[i]);\r
-    };\r
-    fprintf(stdout,"\n");\r
-    fflush(stdout);\r
-\r
-    MR_pointerStackReset(&previousBackTrace);\r
-\r
-    for (i=0; i < MR_BackTraceStack.count ; i++) {\r
-      MR_pointerStackPush(&previousBackTrace,MR_BackTraceStack.data[i]);\r
-    };\r
-\r
-  };\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-void MR_setConstrainPointer(set * newConstrainValue)\r
-#else\r
-void MR_setConstrainPointer(newConstrainValue)\r
-  set * newConstrainValue;\r
-#endif\r
-{\r
-       constrain=newConstrainValue;\r
-}\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/antlr/gen.c b/Tools/CodeTools/TianoTools/Pccts/antlr/gen.c
deleted file mode 100644 (file)
index 368a96b..0000000
+++ /dev/null
@@ -1,4797 +0,0 @@
-/*\r
- * gen.c\r
- *\r
- * Generate C code (ANSI, K&R, C++)\r
- *\r
- * SOFTWARE RIGHTS\r
- *\r
- * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
- * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
- * company may do whatever they wish with source code distributed with\r
- * PCCTS or the code generated by PCCTS, including the incorporation of\r
- * PCCTS, or its output, into commerical software.\r
- *\r
- * We encourage users to develop software with PCCTS.  However, we do ask\r
- * that credit is given to us for developing PCCTS.  By "credit",\r
- * we mean that if you incorporate our source code into one of your\r
- * programs (commercial product, research project, or otherwise) that you\r
- * acknowledge this fact somewhere in the documentation, research report,\r
- * etc...  If you like PCCTS and have developed a nice tool with the\r
- * output, please mention that you developed it using PCCTS.  In\r
- * addition, we ask that this header remain intact in our source code.\r
- * As long as these guidelines are kept, we expect to continue enhancing\r
- * this system and expect to make other tools available as they are\r
- * completed.\r
- *\r
- * ANTLR 1.33\r
- * Terence Parr\r
- * Parr Research Corporation\r
- * with Purdue University and AHPCRC, University of Minnesota\r
- * 1989-2001\r
- */\r
-\r
-#include <stdio.h>\r
-#include <stdlib.h>\r
-#include <ctype.h>\r
-#include "pcctscfg.h"\r
-#include "set.h"\r
-#include "syn.h"\r
-#include "hash.h"\r
-#include "generic.h"\r
-#include "dlgdef.h"\r
-\r
-#define NumExprPerLine 4\r
-static int on1line=0;\r
-static set tokensRefdInBlock;\r
-\r
-                                       /* T r a n s l a t i o n  T a b l e s */\r
-\r
-/* C_Trans[node type] == pointer to function that knows how to translate that node. */\r
-#ifdef __cplusplus\r
-void (*C_Trans[NumNodeTypes+1])(...) = {\r
-       NULL,\r
-       NULL,                                   /* See next table.\r
-Junctions have many types */\r
-       (void (*)(...)) genRuleRef,\r
-       (void (*)(...)) genToken,\r
-       (void (*)(...)) genAction\r
- };\r
-#else\r
-void (*C_Trans[NumNodeTypes+1])() = {\r
-       NULL,\r
-       NULL,                                   /* See next table.\r
-Junctions have many types */\r
-       genRuleRef,\r
-       genToken,\r
-       genAction\r
- };\r
-#endif\r
-\r
-/* C_JTrans[Junction type] == pointer to function that knows how to translate that\r
- * kind of junction node.\r
- */\r
-#ifdef __cplusplus\r
-void (*C_JTrans[NumJuncTypes+1])(...) = {\r
-       NULL,\r
-       (void (*)(...)) genSubBlk,\r
-       (void (*)(...)) genOptBlk,\r
-       (void (*)(...)) genLoopBlk,\r
-       (void (*)(...)) genEndBlk,\r
-       (void (*)(...)) genRule,\r
-       (void (*)(...)) genJunction,\r
-       (void (*)(...)) genEndRule,\r
-       (void (*)(...)) genPlusBlk,\r
-       (void (*)(...)) genLoopBegin\r
- };\r
-#else\r
-void (*C_JTrans[NumJuncTypes+1])() = {\r
-       NULL,\r
-       genSubBlk,\r
-       genOptBlk,\r
-       genLoopBlk,\r
-       genEndBlk,\r
-       genRule,\r
-       genJunction,\r
-       genEndRule,\r
-       genPlusBlk,\r
-       genLoopBegin\r
- };\r
-#endif\r
-\r
-#define PastWhiteSpace(s)      while (*(s) == ' ' || *(s) == '\t') {s++;}\r
-\r
-static int tabs = 0;\r
-\r
-/* MR6 Got tired of text running off page when using standard tab stops */\r
-\r
-#define TAB { int i;                                                                   \\r
-             if (TabWidth==0) {                                                        \\r
-                for (i=0; i<tabs; i++) fputc('\t', output);                            \\r
-             } else {                                                                  \\r
-                for (i=0; i<tabs*TabWidth; i++) fputc(' ',output);                     \\r
-             };                                                                        \\r
-           }\r
-\r
-static void\r
-#ifdef __USE_PROTOS\r
-tab( void )\r
-#else\r
-tab( )\r
-#endif\r
-TAB\r
-\r
-#ifdef __USE_PROTOS\r
-static char *tokenFollowSet(TokNode *);\r
-static ActionNode *findImmedAction( Node * );\r
-static void dumpRetValAssign(char *, char *, RuleRefNode *);           /* MR30 */\r
-static void dumpAfterActions(FILE *output);\r
-static set ComputeErrorSet(Junction *, int, int);\r
-static void makeErrorClause(Junction *, set, int, int);\r
-static void DumpFuncHeader( Junction *, RuleEntry * );\r
-static int has_guess_block_as_first_item(Junction *);\r
-static int genExprSets(set *, int);\r
-static void genExprTree( Tree *t, int k );\r
-static void genExprTreeOriginal( Tree *t, int k );                  /* MR10 */\r
-static char * findOuterHandlerLabel(ExceptionGroup *eg);            /* MR7 */\r
-static void OutLineInfo(FILE *file,int line,char *fileName);        /* MR14 */\r
-#else\r
-static char *tokenFollowSet();\r
-static ActionNode *findImmedAction();\r
-static void dumpRetValAssign();\r
-static void dumpAfterActions();\r
-static set ComputeErrorSet();\r
-static void makeErrorClause();\r
-static void DumpFuncHeader();\r
-static int has_guess_block_as_first_item();\r
-static int genExprSets();\r
-static void genExprTree();\r
-static void genExprTreeOriginal();                                  /* MR10 */\r
-static char * findOuterHandlerLabel();                              /* MR7 */\r
-static void OutLineInfo();                                          /* MR14 */\r
-#endif\r
-\r
-#define gen(s)                 {tab(); fprintf(output, s);}\r
-#define gen1(s,a)              {tab(); fprintf(output, s,a);}\r
-#define gen2(s,a,b)            {tab(); fprintf(output, s,a,b);}\r
-#define gen3(s,a,b,c)  {tab(); fprintf(output, s,a,b,c);}\r
-#define gen4(s,a,b,c,d)        {tab(); fprintf(output, s,a,b,c,d);}\r
-#define gen5(s,a,b,c,d,e)      {tab(); fprintf(output, s,a,b,c,d,e);}\r
-#define gen6(s,a,b,c,d,e,f)    {tab(); fprintf(output, s,a,b,c,d,e,f);}\r
-#define gen7(s,a,b,c,d,e,f,g)  {tab(); fprintf(output, s,a,b,c,d,e,f,g);}\r
-\r
-#define _gen(s)                        {fprintf(output, s);}\r
-#define _gen1(s,a)             {fprintf(output, s,a);}\r
-#define _gen2(s,a,b)   {fprintf(output, s,a,b);}\r
-#define _gen3(s,a,b,c) {fprintf(output, s,a,b,c);}\r
-#define _gen4(s,a,b,c,d){fprintf(output, s,a,b,c,d);}\r
-#define _gen5(s,a,b,c,d,e){fprintf(output, s,a,b,c,d,e);}\r
-#define _gen6(s,a,b,c,d,e,f){fprintf(output, s,a,b,c,d,e,f);}\r
-#define _gen7(s,a,b,c,d,e,f,g){fprintf(output, s,a,b,c,d,e,f,g);}\r
-\r
-\r
-/* MR11 a convenient place to set a break point */\r
-\r
-#ifdef __USE_PROTOS\r
-void MR_break(void) \r
-#else\r
-void MR_break() \r
-#endif\r
-{\r
-  return;\r
-}\r
-\r
-/* MR10 genTraceOut(Junction *)      */\r
-\r
-#ifdef __USE_PROTOS\r
-static void genTraceOut(Junction *q)\r
-#else\r
-static void genTraceOut(q)\r
-  Junction  *q;\r
-#endif\r
-{\r
-  if ( TraceGen ) {\r
-               if ( GenCC ) {gen1("zzTRACEOUT(\"%s\");\n", q->rname);}\r
-               else gen1("zzTRACEOUT((ANTLRChar *)\"%s\");\n", q->rname);\r
-  }\r
-}\r
-\r
-static void\r
-#ifdef __USE_PROTOS\r
-warn_about_using_gk_option(void)\r
-#else\r
-warn_about_using_gk_option()\r
-#endif\r
-{\r
-       static int warned_already=0;\r
-\r
-       if ( !DemandLookahead || warned_already ) return;\r
-       warned_already = 1;\r
-       warnNoFL("-gk option could cause trouble for <<...>>? predicates");\r
-}\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-freeBlkFsets( Junction *q )\r
-#else\r
-freeBlkFsets( q )\r
-Junction *q;\r
-#endif\r
-{\r
-       int i;\r
-       Junction *alt;\r
-       require(q!=NULL, "freeBlkFsets: invalid node");\r
-\r
-       for (alt=q; alt != NULL; alt= (Junction *) alt->p2 )\r
-       {\r
-               for (i=1; i<=CLL_k; i++) set_free(alt->fset[i]);\r
-       }\r
-}\r
-\r
-/*\r
- * Generate a local variable allocation for each token references\r
- * in this block.\r
- */\r
-static void\r
-#ifdef __USE_PROTOS\r
-genTokenPointers( Junction *q )\r
-#else\r
-genTokenPointers( q )\r
-Junction *q;\r
-#endif\r
-{\r
-       /* Rule refs are counted and can be referenced, but their\r
-        * value is not set to anything useful ever.\r
-        *\r
-     * The ptrs are to be named _tij where i is the current level\r
-        * and j is the element number within an alternative.\r
-        */\r
-       int first=1, t=0;\r
-       set a;\r
-       tokensRefdInBlock = q->tokrefs;\r
-\r
-       if ( set_deg(q->tokrefs) == 0 ) return;\r
-       a = set_dup(q->tokrefs);\r
-       gen("ANTLRTokenPtr ");\r
-       for (; !set_nil(a); set_rm(t, a))\r
-       {\r
-               t = set_int(a);\r
-               if ( first ) first = 0;\r
-               else _gen(",");\r
-               if ( !DontCopyTokens ) _gen2("_tv%d%d,", BlkLevel, t);\r
-               _gen2("_t%d%d", BlkLevel, t);\r
-               if ( !DontCopyTokens ) {_gen2("= &_tv%d%d", BlkLevel, t);}\r
-               else _gen("=NULL");\r
-       }\r
-       _gen(";\n");\r
-       set_free(a);\r
-}\r
-\r
-static int\r
-#ifdef __USE_PROTOS\r
-hasDefaultException(ExceptionGroup *eg)\r
-#else\r
-hasDefaultException(eg)\r
-ExceptionGroup *eg;\r
-#endif\r
-{\r
-    ListNode *q;\r
-\r
-    for (q = eg->handlers->next; q!=NULL; q=q->next)\r
-    {\r
-        ExceptionHandler *eh = (ExceptionHandler *)q->elem;\r
-        if ( strcmp("default", eh->signalname)==0 ) {\r
-            return 1;\r
-        }\r
-    }\r
-    return 0;\r
-}\r
-static void\r
-#ifdef __USE_PROTOS\r
-dumpException(ExceptionGroup *eg, int no_default_case)\r
-#else\r
-dumpException(eg, no_default_case)\r
-ExceptionGroup *eg;\r
-int no_default_case;\r
-#endif\r
-{\r
-    char    *outerLabel;                                             /* MR7 */\r
-    int     altHandler=0;                                            /* MR7 */\r
-    int     namedHandler=0;                                          /* MR7 */\r
-\r
-    outerLabel=findOuterHandlerLabel(eg);                            /* MR7 */\r
-\r
-    if (eg->label != NULL) {                                         /* MR7 */\r
-      namedHandler=1;                                                /* MR7 */\r
-    } else if (eg->forRule) {                                        /* MR7 */\r
-      /* nothing */                                                  /* MR20 */\r
-    } else {                                                         /* MR7 */\r
-      altHandler=1;                                                  /* MR7 */\r
-    };                                                               /* MR7 */\r
-\r
-#if 0\r
-**     if (! eg->used) {                                             /* MR7 */\r
-**             warnFL("exception group never used",                         /* MR7 */\r
-**             FileStr[eg->altstart->file],eg->altstart->line);      /* MR7 */\r
-**     };                                                            /* MR7 */\r
-#endif\r
-\r
-    if (namedHandler) {                                              /* MR7 */\r
-         gen1("switch ( _signal ) {  /* [%s] */\n",eg->label);          /* MR7 */\r
-    } else {                                                         /* MR7 */\r
-         gen("switch ( _signal ) {\n");                                 /* MR7 */\r
-      gen("case NoSignal: break;  /* MR7 */\n");                     /* MR7 */\r
-    };                                                               /* MR7 */\r
-       {\r
-               ListNode *q;\r
-               for (q = eg->handlers->next; q!=NULL; q=q->next)\r
-               {\r
-                       ExceptionHandler *eh = (ExceptionHandler *)q->elem;\r
-                       if ( strcmp("default", eh->signalname)==0 ) {\r
-                               gen("default :\n");\r
-                               tabs++;\r
-                               dumpAction(eh->action, output, tabs, -1, 1, 1);\r
-                gen("_signal=NoSignal;  /* MR7 */\n");                  /* MR7 */\r
-                gen("break;  /* MR7 */\n");                             /* MR7 */\r
-                               tabs--;\r
-                               gen("}\n");\r
-\r
-                /* copied from later code in dumpException */        /* MR7 */\r
-\r
-                if (namedHandler) {                                  /* MR7 */\r
-                  gen("if (_signal != NoSignal)");                   /* MR7 */\r
-                  _gen1(" goto %s_handler;  /* MR7 */\n",outerLabel);/* MR7 */\r
-                } else if (altHandler) {                             /* MR7 */\r
-                  gen1("goto %s_handler;  /* MR7 */\n",outerLabel);  /* MR7 */\r
-                };\r
-                               return;\r
-                       }\r
-                       gen1("case %s :\n", eh->signalname);\r
-                       tabs++;\r
-                       if ( eh->action != NULL )\r
-                       {\r
-                               dumpAction(eh->action, output, tabs, -1, 1, 1);\r
-                gen("break;  /* MR7 */\n");                          /* MR7 */\r
-                       }\r
-                       tabs--;\r
-               }\r
-       }\r
-       if ( no_default_case ) return;\r
-\r
-       gen("default :\n");\r
-    tabs++;                                                         /* MR7 */\r
-    gen("break;  /* MR7 */\n");                                     /* MR7 */\r
-    tabs--;                                                         /* MR7 */\r
-\r
-       tabs++;\r
-/***** gen("*_retsignal = _signal;\n"); *****/\r
-\r
-       tabs--;\r
-       gen("}\n");\r
-\r
-    if (namedHandler) {                                             /* MR7 */\r
-      gen("if (_signal != NoSignal)");                              /* MR7 */\r
-      _gen1(" goto %s_handler;  /* MR7 */\n",outerLabel);           /* MR7 */\r
-    } else if (altHandler) {                                        /* MR7 */\r
-      gen1("goto %s_handler;  /* MR7 */\n",outerLabel);             /* MR7 */\r
-    };\r
-\r
-}\r
-\r
-static void\r
-#ifdef __USE_PROTOS\r
-dumpExceptions(ListNode *list)\r
-#else\r
-dumpExceptions(list)\r
-ListNode *list;\r
-#endif\r
-{\r
-       ListNode *p;\r
-\r
-       for (p = list->next; p!=NULL; p=p->next)\r
-       {\r
-               ExceptionGroup *eg = (ExceptionGroup *) p->elem;\r
-               _gen2("%s%s_handler:\n",\r
-                         eg->label==NULL?"":eg->label,\r
-                         eg->altID==NULL?"":eg->altID);\r
-               if ( eg->altID!=NULL ) dumpException(eg, 0);\r
-               else {\r
-                       /* This must be the rule exception handler */\r
-                       dumpException(eg, 1);\r
-                       if ( !hasDefaultException(eg) )\r
-            {\r
-                gen("default :\n");\r
-                tabs++;\r
-                gen("zzdflthandlers(_signal,_retsignal);\n");\r
-                tabs--;\r
-                gen("}\n");\r
-            }\r
-               }\r
-       }\r
-}\r
-\r
-/* For each element label that is found in a rule, generate a unique\r
- * Attribute (and AST pointer if GenAST) variable.\r
- */\r
-void\r
-#ifdef __USE_PROTOS\r
-genElementLabels(ListNode *list)\r
-#else\r
-genElementLabels(list)\r
-ListNode *list;\r
-#endif\r
-{\r
-       int first=1;\r
-       ListNode *p;\r
-\r
-       if ( GenCC ) {gen("ANTLRTokenPtr");}\r
-       else {gen("Attrib");}\r
-       for (p = list->next; p!=NULL; p=p->next)\r
-       {\r
-               char *ep = (char *)p->elem;\r
-               if ( first ) first = 0;\r
-               else _gen(",");\r
-               if ( GenCC ) {_gen1(" %s=NULL",ep);}\r
-               else {_gen1(" %s",ep);}\r
-       }\r
-       _gen(";\n");\r
-\r
-       if ( !GenAST ) return;\r
-\r
-       first = 1;\r
-       gen("AST");\r
-       for (p = list->next; p!=NULL; p=p->next)\r
-       {\r
-               char *ep = (char *)p->elem;\r
-               if ( first ) first = 0;\r
-               else _gen(",");\r
-               _gen1(" *%s_ast=NULL",ep);\r
-       }\r
-       _gen(";\n");\r
-}\r
-\r
-/*\r
- * Generate a local variable allocation for each token or rule reference\r
- * in this block.\r
- */\r
-static void\r
-#ifdef __USE_PROTOS\r
-genASTPointers( Junction *q )\r
-#else\r
-genASTPointers( q )\r
-Junction *q;\r
-#endif\r
-{\r
-       int first=1, t;\r
-       set a;\r
-\r
-       a = set_or(q->tokrefs, q->rulerefs);\r
-       if ( set_deg(a) > 0 )\r
-       {\r
-               gen("AST ");\r
-               for (; !set_nil(a); set_rm(t, a))\r
-               {\r
-                       t = set_int(a);\r
-                       if ( first ) first = 0;\r
-                       else _gen(",");\r
-                       _gen2("*_ast%d%d=NULL", BlkLevel, t);\r
-               }\r
-               set_free(a);\r
-       }\r
-       _gen(";\n");\r
-}\r
-\r
-static void\r
-#ifdef __USE_PROTOS\r
-BLOCK_Head( void )\r
-#else\r
-BLOCK_Head( )\r
-#endif\r
-{\r
-       gen("{\n");\r
-       tabs++;\r
-       if ( !GenCC ) gen1("zzBLOCK(zztasp%d);\n", BlkLevel);\r
-}\r
-\r
-static void\r
-#ifdef __USE_PROTOS\r
-BLOCK_Tail( void )\r
-#else\r
-BLOCK_Tail( )\r
-#endif\r
-{\r
-       if ( !GenCC ) gen1("zzEXIT(zztasp%d);\n", BlkLevel);\r
-       if ( !GenCC ) gen("}\n");\r
-       tabs--;\r
-       gen("}\n");\r
-}\r
-\r
-static void\r
-#ifdef __USE_PROTOS\r
-BLOCK_Preamble( Junction *q )\r
-#else\r
-BLOCK_Preamble( q )\r
-Junction *q;\r
-#endif\r
-{\r
-       ActionNode *a;\r
-       Junction *begin;\r
-\r
-       BLOCK_Head();\r
-       if ( GenCC ) genTokenPointers(q);\r
-       if ( GenCC&&GenAST ) genASTPointers(q);\r
-       if ( q->jtype == aPlusBlk ) gen("int zzcnt=1;\n");\r
-       if ( q->parm != NULL && !q->predparm ) gen1("zzaPush(%s);\n", q->parm)\r
-       else if ( !GenCC ) gen("zzMake0;\n");\r
-       if ( !GenCC ) gen("{\n");\r
-       if ( q->jtype == aLoopBegin ) begin = (Junction *) ((Junction *)q->p1);\r
-       else begin = q;\r
-       if ( has_guess_block_as_first_item(begin) )\r
-       {\r
-               gen("zzGUESS_BLOCK\n");\r
-       }\r
-       if ( q->jtype == aLoopBegin )\r
-               a = findImmedAction( ((Junction *)q->p1)->p1 ); /* look at aLoopBlk */\r
-       else\r
-               a = findImmedAction( q->p1 );\r
-       if ( a!=NULL && !a->is_predicate) {\r
-/* MR21 */ if (!a->noHoist) dumpActionPlus(a, a->action, output, tabs, a->file, a->line, 1);\r
-                  a->done = 1; /* remove action. We have already handled it */\r
-       }\r
-}\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-genCombinedPredTreeContextOrig( Predicate *p )\r
-#else\r
-genCombinedPredTreeContextOrig( p )\r
-Predicate *p;\r
-#endif\r
-{\r
-       static set *ctx=NULL;           /* genExprSets() is destructive, make copy*/\r
-       require(p!=NULL, "can't make context tree for NULL pred tree");\r
-\r
-#ifdef DBG_PRED\r
-       fprintf(stderr, "enter genCombinedPredTreeContextOrig(%s,0x%x) with sets:\n", p->expr, p);\r
-       s_fprT(stderr, p->scontext[1]);\r
-       fprintf(stderr, "\n");\r
-#endif\r
-       if ( p->down == NULL )\r
-       {\r
-/***   if ( p->k>1 && p->tcontext!=NULL ) ***/\r
-               if ( p->tcontext!=NULL )\r
-               {\r
-                       _gen("(");\r
-                       genExprTree(p->tcontext, 1);\r
-                       _gen(")");\r
-               }\r
-/***   else if ( p->k==1 && set_deg(p->scontext[1])>0 ) ***/\r
-               else if ( set_deg(p->scontext[1])>0 )\r
-               {\r
-                       if ( ctx==NULL ) ctx = (set *)calloc(CLL_k+1, sizeof(set));\r
-                       require(ctx!=NULL, "ctx cannot allocate");\r
-                       ctx[0]=empty;\r
-                       ctx[1]=set_dup(p->scontext[1]);\r
-                       _gen("(");\r
-                       genExprSets(&(ctx[0]), p->k);\r
-                       _gen(")");\r
-                       set_free(ctx[1]);\r
-               }\r
-               else if ( p->expr==PRED_AND_LIST || p->expr==PRED_OR_LIST ) {\r
-                       fatal_internal("pred tree is orphan OR or AND list");\r
-               }\r
-               else {\r
-            if (! HoistPredicateContext) {\r
-              _gen(" 1 /* no context: prc is off */ ");\r
-            } else {\r
-              fatal_internal("pred tree context is empty");\r
-            };\r
-               }\r
-               return;\r
-       }\r
-\r
-/* MR10 - make AND just like OR */\r
-\r
-       if ( p->expr == PRED_AND_LIST )\r
-       {\r
-        Predicate *list = p->down;\r
-        for (; list!=NULL; list=list->right)\r
-        {\r
-            genCombinedPredTreeContextOrig(list);\r
-                        if ( list->right!=NULL ) _gen("|| /* MR10 was wrong */ ");\r
-        };\r
-               return;\r
-       }\r
-\r
-       if ( p->expr == PRED_OR_LIST )\r
-       {\r
-        Predicate *list = p->down;\r
-        for (; list!=NULL; list=list->right)\r
-        {\r
-           genCombinedPredTreeContextOrig(list);\r
-           if ( list->right!=NULL ) _gen("||");\r
-        };\r
-        return;\r
-     };\r
-\r
-       fatal("pred tree is really wacked");\r
-}\r
-\r
-/* [genCombinedPredTreeContext] */\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-genCombinedPredTreeContext( Predicate *p )\r
-#else\r
-genCombinedPredTreeContext( p )\r
-Predicate *p;\r
-#endif\r
-{\r
-  Tree  *t;\r
-  int   predDepth=0;\r
-\r
-  if (0 && ! MR_usingPredNames && ! MRhoisting) {\r
-    genCombinedPredTreeContextOrig(p);\r
-  } else {\r
-/* MR13 */    MR_pred_depth(p,&predDepth);\r
-/* MR13 */    if (predDepth == 1) {\r
-/* MR13 */\r
-/* MR13 */      set   scontext[2];\r
-/* MR13 */      scontext[0]=empty;\r
-/* MR13 */      scontext[1]=MR_compute_pred_set(p);\r
-/* MR13 */      if (set_nil(scontext[1])) {\r
-/* MR13 */        _gen(" 1 /* MR12 no context (-prc off) */ ");\r
-/* MR13 */      } else {\r
-/* MR13 */        _gen("(");\r
-/* MR13 */        genExprSets(&scontext[0], 1);\r
-/* MR13 */        set_free(scontext[1]);\r
-/* MR13 */        _gen(")");\r
-/* MR13 */      };\r
-\r
-    } else {\r
-      t=MR_compute_pred_tree_context(p);\r
-      if (t == NULL) {\r
-        _gen(" 1 /* MR12 no context (-prc off) */ ");\r
-      } else {\r
-        _gen("(");\r
-        genExprTree(t, 1);\r
-        Tfree(t);   /* MR10 */\r
-        _gen(")");\r
-      };\r
-    };\r
-  };\r
-}\r
-\r
-/* [genPredTreeGate] */\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-genPredTreeGate( Predicate *p, int in_and_expr )\r
-#else\r
-genPredTreeGate( p, in_and_expr )\r
-Predicate *p;\r
-int in_and_expr;\r
-#endif\r
-{\r
-       if ( in_and_expr )\r
-       {\r
-               _gen("!(");\r
-               genCombinedPredTreeContext(p);\r
-               _gen(")||");\r
-               if ( p->down!=NULL ) _gen("\n");\r
-       }\r
-       else\r
-       {\r
-               _gen("(");\r
-               genCombinedPredTreeContext(p);\r
-               _gen(")&&");\r
-               if ( p->down!=NULL ) _gen("\n");\r
-       }\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-void genPredEntry(Predicate *p,int outer)\r
-#else\r
-void genPredEntry(p,outer)\r
-  Predicate     *p;\r
-  int           outer;\r
-#endif\r
-{\r
-    int         inverted=0;\r
-    Predicate   *q;\r
-    int         localOuter=outer;\r
-    int         needRP=0;\r
-\r
-    if (p == NULL) return;\r
-\r
-    if (p->predEntry != NULL && p->predEntry->predLiteral != NULL) {\r
-      if (p->inverted != p->predEntry->pred->inverted) {\r
-        _gen("! /* inverted pred */ (");\r
-        needRP=1;\r
-      } else {\r
-        if (!localOuter) _gen("(");\r
-        needRP=1;\r
-      };\r
-      dumpAction(p->predEntry->predLiteral,output,0,p->source->file,p->source->line,0);\r
-      if (needRP) _gen(")");\r
-      return;\r
-    };\r
-\r
-    inverted=p->inverted;\r
-\r
-    if (inverted) {\r
-      _gen(" ! /* inverted pred */ (");\r
-      localOuter=1;\r
-    };\r
-\r
-    if (p->expr == PRED_OR_LIST) {\r
-      if (!localOuter) _gen("(");\r
-      for (q=p->down; q != NULL ; q=q->right) {\r
-        genPredEntry(q,0);\r
-        if (q->right != NULL) _gen(" || ");\r
-      };\r
-      if (!localOuter) _gen(")");\r
-    } else if (p->expr == PRED_AND_LIST) {\r
-      if (!localOuter) _gen("(");\r
-      for (q=p->down; q != NULL ; q=q->right) {\r
-        genPredEntry(q,0);\r
-        if (q->right != NULL) _gen(" && ");\r
-      };\r
-      if (!localOuter) _gen(")");\r
-    } else {\r
-      if (!localOuter) _gen("(");\r
-      require (p->source != NULL,"predEntry->source == NULL");\r
-      require (p->source->inverted == 0,"dumpPredEntry p->source->inverted != 0");\r
-      dumpAction(p->source->action,output,0,p->source->file,p->source->line,0);\r
-      if (!localOuter) _gen(")");\r
-    };\r
-\r
-    if (inverted) {\r
-        _gen(")");\r
-    }\r
-}\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-dumpPredAction(ActionNode *anode,\r
-                    char *s,FILE *output,int tabs,int file,int line,int final_newline)\r
-#else\r
-dumpPredAction(anode,\r
-                    s,output,tabs,file,line,final_newline)\r
-\r
-    ActionNode  *anode;\r
-    char        *s;\r
-    FILE        *output;\r
-    int         tabs;\r
-    int         file;\r
-    int         line;\r
-    int         final_newline;\r
-#endif\r
-{\r
-    PredEntry   *predEntry=anode->predEntry;\r
-    int         inverted=anode->inverted;\r
-    Predicate   *workPred;\r
-\r
-    if (predEntry == NULL) {\r
-\r
-      /* inline predicate literal */\r
-\r
-      require(inverted == 0,"dumpPredAction action->inverted");\r
-         dumpAction(s,output,tabs,file,line,final_newline);\r
-\r
-    } else {\r
-\r
-      /* a reference to a predicate - possibly with an inverted source */\r
-\r
-      if (predEntry->predLiteral != NULL) {\r
-        if (inverted) _gen("! /* inverted pred */ (");\r
-        dumpAction(predEntry->predLiteral,output,0,anode->file,anode->line,0);\r
-        if (inverted) _gen(")");\r
-      } else {\r
-        workPred=predicate_dup(predEntry->pred);\r
-        if (inverted) workPred->inverted=!workPred->inverted;\r
-        genPredEntry(workPred,1);\r
-        predicate_free(workPred);\r
-      };\r
-    };\r
-}\r
-\r
-/* [genPred] */\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-genPred(Predicate *p, Node *j,int suppress_sva)\r
-#else\r
-genPred(p,j,suppress_sva)\r
-    Predicate   *p;\r
-    Node        *j;\r
-    int         suppress_sva;\r
-#endif\r
-{\r
-       if ( FoundException && !suppress_sva) {_gen("(_sva=(");}    /* MR11 suppress_sva */\r
-       else {_gen("(");}\r
-       if ( GenLineInfo && j->file != -1 ) _gen("\n");\r
-    if (p->source != NULL && p->source->ampersandPred != NULL) {\r
-      if (p->source->ampersandPred->k == 1) {\r
-\r
-            set     ctx[2];\r
-\r
-                       ctx[0]=empty;\r
-                       ctx[1]=set_dup(p->source->ampersandPred->scontext[1]);\r
-\r
-                       _gen("(");\r
-                       genExprSets(&(ctx[0]), p->k);\r
-                       _gen(") && ");\r
-                       set_free(ctx[1]);\r
-      } else {\r
-        _gen("( ");\r
-        genExprTree(p->source->ampersandPred->tcontext,1);\r
-               _gen(" ) && ");\r
-      };\r
-    };\r
-\r
-    dumpPredAction((ActionNode *)p->source,\r
-                p->expr, output, 0, -1 /*indicates no line info*/, j->line, 0);\r
-\r
-       if ( FoundException && !suppress_sva)   /* MR11 suppress_sva */\r
-         {_gen("),_sva)");}    /* MR10 - get red of "meant ==" messages */\r
-       else {_gen(")");}\r
-}\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-MR_distinctORcontextOpt(Predicate *p,Node *j,int in_and_expr)\r
-#else\r
-MR_distinctORcontextOpt(p,j,in_and_expr)\r
-    Predicate   *p;\r
-    Node        *j;\r
-    int         in_and_expr;\r
-#endif\r
-{\r
-    Predicate   *q;\r
-\r
-    _gen(" /* MR10 Distinct OR context optimization */ \n");\r
-\r
-    if (in_and_expr) {\r
-      gen("zzpf=0,\n");\r
-      for (q=p->down; q != NULL; q=q->right) {\r
-        gen("(  ");\r
-        genCombinedPredTreeContext(q);\r
-        _gen(" && (zzpf=1, ");\r
-        genPred(q,j,0);\r
-        _gen("  )) ||\n");\r
-      };\r
-      gen("!zzpf)");\r
-    } else {\r
-      require (0,\r
-            "MR_distinctORcontextOpt: can't get here when using MR_predSimplify");\r
-#if 0\r
-**      for (q=p->down; q != NULL; q=q->right) {\r
-**        gen("(  ");\r
-**        genCombinedPredTreeContext(q);\r
-**        _gen(" && ");\r
-**        genPred(q,j);\r
-**        if (q->right != NULL) {\r
-**          _gen("  ) ||\n");\r
-**        };\r
-**      };\r
-**      gen(")");\r
-#endif\r
-   };\r
-}\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-genPredTreeOrig( Predicate *p, Node *j, int in_and_expr )\r
-#else\r
-genPredTreeOrig( p, j, in_and_expr )\r
-Predicate *p;\r
-Node *j;\r
-int in_and_expr;\r
-#endif\r
-{\r
-\r
-/* MR10 */  int     allHaveContext=1;\r
-/* MR10 */  int     noneHaveContext=1;\r
-\r
-/* MR10 */  MR_predContextPresent(p,&allHaveContext,&noneHaveContext);\r
-\r
-       if ( ! noneHaveContext )                  /* MR10 context guards ignored when -prc off */\r
-       {\r
-               _gen("(");\r
-               genPredTreeGate(p, in_and_expr);\r
-       }\r
-\r
-       /* if leaf node, just gen predicate */\r
-\r
-       if ( p->down==NULL )\r
-       {\r
-               genPred(p,j,0);\r
-               if ( ! noneHaveContext ) _gen(")");   /* MR10 context guards ignored when -prc off */\r
-               return;\r
-       }\r
-\r
-       /* if AND list, do both preds (only two possible) */\r
-       if ( p->expr == PRED_AND_LIST )\r
-       {\r
-#if 0\r
-**             _gen("(");\r
-**             genPredTreeOrig(p->down, j, 1);\r
-**             _gen("&&");\r
-**             genPredTreeOrig(p->down->right, j, 1);\r
-**             _gen(")");\r
-**             if ( ! noneHaveContext ) _gen(")");    /* MR10 context guards ignored when -prc off */\r
-**             return;\r
-#endif\r
-        /* MR11 - make it work with AND with more than two children - like OR */\r
-\r
-               Predicate *list;\r
-               _gen("(");\r
-               list = p->down;\r
-               for (; list!=NULL; list=list->right)\r
-               {\r
-                       genPredTreeOrig(list, j, 1);\r
-                       if ( list->right!=NULL ) _gen("&&");\r
-               }\r
-               _gen(")");\r
-               if ( ! noneHaveContext ) _gen(")");    /* MR10 context guards ignored when -prc off */\r
-               return;\r
-    };\r
-\r
-       if ( p->expr == PRED_OR_LIST )\r
-       {\r
-               Predicate *list;\r
-               _gen("(");\r
-               list = p->down;\r
-               for (; list!=NULL; list=list->right)\r
-               {\r
-                       genPredTreeOrig(list, j, 0);\r
-                       if ( list->right!=NULL ) _gen("||");\r
-               }\r
-               _gen(")");\r
-               if ( ! noneHaveContext ) _gen(")");    /* MR10 context guards ignored when -prc off */\r
-               return;\r
-       }\r
-\r
-       fatal_internal("genPredTreeOrig: predicate tree is wacked");\r
-}\r
-\r
-#if 0\r
-**   Predicate member dummyPredDepth is no longer used in MR10\r
-**     but we might need it again in the future\r
-**\r
-**   if (MRhoisting) {\r
-**     if ( !noneHaveContext &&\r
-**          ! in_and_expr &&\r
-**          p->source != NULL &&\r
-**          p->source->dummyPredicateDepth > 0 &&\r
-**          p->down == NULL) {\r
-**             _gen("(");\r
-**             genCombinedPredTreeContext(p);\r
-**             _gen("  )\n");\r
-**             return;\r
-**     };\r
-**   };\r
-#endif\r
-\r
-/* [genPredTree] */\r
-\r
-/* in_and_expr\r
-\r
-   what to do if the context is wrong\r
-   what to do if the context is correct but the predicate is false\r
-\r
-   remember: if the context is wrong it's the same as if the\r
-             predicate is true as far as enabling an alternative\r
-\r
-        Consider (AND p q r)\r
-\r
-        if in an ... && ... expression then you don't want\r
-        the entire predicate chain to fail just because the\r
-        context for one component is wrong: so return true\r
-\r
-        Consider (OR p q r)\r
-\r
-        if in an ... || ... expression then you don't want\r
-        the entire predicate chain to succeed just because\r
-        the context for one component is correct when the\r
-        corresponding test is false: so return false when\r
-        the context is correct but the test is false.\r
-*/\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-genPredTree( Predicate *p, Node *j, int in_and_expr, int suppress_sva )\r
-#else\r
-genPredTree( p, j, in_and_expr, suppress_sva)\r
-  Predicate     *p;\r
-  Node          *j;\r
-  int           in_and_expr;\r
-  int           suppress_sva;\r
-#endif\r
-{\r
-\r
-    int         allHaveContext=1;\r
-    int         noneHaveContext=1;\r
-    Tree        *groupTree;\r
-    Tree        *oneTree;\r
-    Predicate   *q;\r
-    int         identicalORcontextOptimization=0;\r
-    int         identicalANDcontextOptimization=0;\r
-\r
-    if (0 && !MR_usingPredNames && !MRhoisting) {\r
-      genPredTreeOrig(p,j,in_and_expr);\r
-      return;\r
-    };\r
-\r
-    MR_predContextPresent(p,&allHaveContext,&noneHaveContext);\r
-\r
-       if ( ! noneHaveContext ) {                 /* MR10 context guards ignored when -prc off */\r
-\r
-      _gen("(");\r
-\r
-            /* MR10 optimize OR predicates which are all leaves */\r
-\r
-      if (p->expr == PRED_OR_LIST && MR_allPredLeaves(p->down)) {\r
-        groupTree=MR_compute_pred_tree_context(p);\r
-        for (q=p->down ; q != NULL ; q=q->right) {\r
-          oneTree=MR_compute_pred_tree_context(q);\r
-          if (! MR_tree_equ(groupTree,oneTree)) {\r
-            Tfree(oneTree);\r
-            break;\r
-          };\r
-          Tfree(oneTree);\r
-        };\r
-        Tfree(groupTree);\r
-        if (q == NULL) {\r
-          _gen("/* MR10 individual OR gates suppressed when all predicates are leaves");\r
-          _gen(" with identical context */\n");\r
-          genPredTreeGate(p,in_and_expr);   /* use the parent's in_and_expr for this gate */\r
-          identicalORcontextOptimization=1;\r
-        } else {\r
-          MR_distinctORcontextOpt(p,j,in_and_expr);\r
-          return;\r
-        };\r
-      } else if (p->expr == PRED_AND_LIST && MR_allPredLeaves(p->down)) {\r
-\r
-            /* MR12 optimize AND predicates which are all leaves */\r
-\r
-        groupTree=MR_compute_pred_tree_context(p);\r
-        for (q=p->down ; q != NULL ; q=q->right) {\r
-          oneTree=MR_compute_pred_tree_context(q);\r
-          if (! MR_tree_equ(groupTree,oneTree)) {\r
-            Tfree(oneTree);\r
-            break;\r
-          };\r
-          Tfree(oneTree);\r
-        };\r
-        Tfree(groupTree);\r
-        if (q == NULL) {\r
-          _gen("/* MR12 individual AND gates suppressed when all predicates are leaves");\r
-          _gen(" with identical context */\n");\r
-          genPredTreeGate(p,in_and_expr);   /* use the parent's in_and_expr for this gate */\r
-          identicalANDcontextOptimization=1;\r
-        } else {\r
-          genPredTreeGate(p, in_and_expr);\r
-        };\r
-      } else {\r
-           genPredTreeGate(p, in_and_expr);\r
-      };\r
-       }\r
-\r
-       /* if leaf node, just gen predicate */\r
-\r
-       if ( p->down==NULL )\r
-       {\r
-               genPred(p,j,suppress_sva);\r
-               if ( ! noneHaveContext ) _gen(")");   /* MR10 context guards ignored when -prc off */\r
-               return;\r
-       }\r
-\r
-       /* if AND list, do both preds (only two possible) */\r
-    /* MR10    not any more ! */\r
-\r
-       if ( p->expr == PRED_AND_LIST )\r
-       {\r
-               Predicate *list;\r
-               _gen("(");\r
-               list = p->down;\r
-        for (; list != NULL; list=list->right) {\r
-          if (identicalANDcontextOptimization) {\r
-            genPred(list, j,suppress_sva);\r
-          } else {\r
-                   genPredTree(list, j, 1, suppress_sva);  /* in and context */\r
-          };\r
-          if ( list->right!=NULL ) _gen("&&");\r
-        };\r
-               _gen(")");\r
-               if ( ! noneHaveContext ) _gen(")");    /* MR10 context guards ignored when -prc off */\r
-               return;\r
-       }\r
-\r
-       if ( p->expr == PRED_OR_LIST )\r
-       {\r
-               Predicate *list;\r
-               _gen("(");\r
-               list = p->down;\r
-               for (; list!=NULL; list=list->right)\r
-               {\r
-            if (identicalORcontextOptimization) {\r
-                 genPred(list, j,suppress_sva);\r
-            } else {\r
-                     genPredTree(list, j, 0, suppress_sva);\r
-            };\r
-                       if ( list->right!=NULL ) _gen("||");\r
-               }\r
-               _gen(")");\r
-               if ( ! noneHaveContext ) _gen(")");    /* MR10 context guards ignored when -prc off */\r
-               return;\r
-       }\r
-\r
-       fatal_internal("predicate tree is wacked");\r
-}\r
-\r
-/* [genPredTreeMainXX] */\r
-\r
-Predicate *     /* MR10 */\r
-#ifdef __USE_PROTOS\r
-genPredTreeMainXX( Predicate *p, Node *j ,int in_and_expr)\r
-#else\r
-genPredTreeMainXX( p, j ,in_and_expr)\r
-    Predicate   *p;\r
-    Node        *j;\r
-    int         in_and_expr;\r
-#endif\r
-{\r
-\r
-    int     allHaveContext=1;\r
-    int     noneHaveContext=1;\r
-\r
-#if 0\r
-    fprintf(stderr,"Pred before\n");\r
-    dumppred(p);\r
-    fprintf(stderr,"\n");\r
-    fprintf(stderr,"Pred after\n");\r
-    dumppred(p);\r
-    fprintf(stderr,"\n");\r
-#endif\r
-\r
-    p=MR_predSimplifyALL(p);    /* MR10 */\r
-\r
-    require (MR_predicate_context_completed(p),"predicate context is not complete");\r
-\r
-    MR_cleanup_pred_trees(p);   /* MR10 */\r
-\r
-    MR_predContextPresent(p,&allHaveContext,&noneHaveContext);\r
-    if (!noneHaveContext & !allHaveContext) {\r
-      warnFL("predicate contains elements both with and without context",\r
-                FileStr[j->file],j->line);\r
-    };\r
-\r
-    if (InfoP) {\r
-       _gen("\n#if 0\n\n");\r
-       MR_dumpPred(p,1);\r
-       _gen("#endif\n");\r
-    };\r
-       genPredTree(p,j,in_and_expr,0);\r
-    return p;\r
-}\r
-\r
-Predicate *     /* MR10 */\r
-#ifdef __USE_PROTOS\r
-genPredTreeMain( Predicate *p, Node *j)\r
-#else\r
-genPredTreeMain( p, j)\r
-    Predicate   *p;\r
-    Node        *j;\r
-#endif\r
-{\r
-  return genPredTreeMainXX(p,j,1);\r
-}\r
-\r
-static void\r
-#ifdef __USE_PROTOS\r
-genExprTreeOriginal( Tree *t, int k )\r
-#else\r
-genExprTreeOriginal( t, k )\r
-Tree *t;\r
-int k;\r
-#endif\r
-{\r
-       require(t!=NULL, "genExprTreeOriginal: NULL tree");\r
-       \r
-       if ( t->token == ALT )\r
-       {\r
-               _gen("("); genExprTreeOriginal(t->down, k); _gen(")");\r
-               if ( t->right!=NULL )\r
-               {\r
-                       _gen("||");\r
-                       on1line++;\r
-                       if ( on1line > NumExprPerLine ) { on1line=0; _gen("\n"); }\r
-                       _gen("("); genExprTreeOriginal(t->right, k); _gen(")");\r
-               }\r
-               return;\r
-       }\r
-       if ( t->down!=NULL ) _gen("(");\r
-       _gen1("LA(%d)==",k);\r
-       if ( TokenString(t->token) == NULL ) _gen1("%d", t->token)\r
-       else _gen1("%s", TokenString(t->token));\r
-       if ( t->down!=NULL )\r
-       {\r
-               _gen("&&");\r
-               on1line++;\r
-               if ( on1line > NumExprPerLine ) { on1line=0; _gen("\n"); }\r
-               _gen("("); genExprTreeOriginal(t->down, k+1); _gen(")");\r
-       }\r
-       if ( t->down!=NULL ) _gen(")");\r
-       if ( t->right!=NULL )\r
-       {\r
-               _gen("||");\r
-               on1line++;\r
-               if ( on1line > NumExprPerLine ) { on1line=0; _gen("\n"); }\r
-               _gen("("); genExprTreeOriginal(t->right, k); _gen(")");\r
-       }\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-static void MR_LAtokenString(int k,int token)\r
-#else\r
-static void MR_LAtokenString(k,token)\r
-  int   k;\r
-  int   token;\r
-#endif\r
-{\r
-    char    *ts;\r
-\r
-    ts=TokenString(token);\r
-    if (ts == NULL) {\r
-      _gen2(" LA(%d)==%d",k,token);\r
-    } else {\r
-      _gen2(" LA(%d)==%s",k,ts);\r
-    };\r
-}\r
-\r
-\r
-#ifdef __USE_PROTOS\r
-static int MR_countLeaves(Tree *t)\r
-#else\r
-static int MR_countLeaves(t)\r
-  Tree  *t;\r
-#endif\r
-{\r
-  if (t == NULL) return 0;\r
-  if (t->token == ALT) {\r
-    return MR_countLeaves(t->down)+MR_countLeaves(t->right);\r
-  } else {\r
-    return 1+MR_countLeaves(t->down)+MR_countLeaves(t->right);\r
-  };\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-static void MR_genOneLine(Tree *tree,int k)\r
-#else\r
-static void MR_genOneLine(tree,k)\r
-  Tree      *tree;\r
-  int       k;\r
-#endif\r
-{\r
-    if (tree == NULL) return;\r
-    if (tree->token == ALT) {\r
-       MR_genOneLine(tree->down,k);\r
-    } else {\r
-       MR_LAtokenString(k,tree->token);\r
-       if (tree->down != NULL &&\r
-           tree->down->right == NULL) {\r
-          _gen(" &&");\r
-          MR_genOneLine(tree->down,k+1);\r
-       } else if (tree->down != NULL) {\r
-         _gen(" && (");\r
-         MR_genOneLine(tree->down,k+1);\r
-         _gen(")");\r
-       };\r
-    };\r
-    if (tree->right != NULL) {\r
-      _gen(" ||");\r
-      MR_genOneLine(tree->right,k);\r
-    };\r
-}\r
-\r
-static int across;\r
-static int depth;\r
-static int lastkonline;\r
-\r
-#ifdef __USE_PROTOS\r
-static void MR_genMultiLine(Tree *tree,int k)\r
-#else\r
-static void MR_genMultiLine(tree,k)\r
-  Tree  *tree;\r
-  int   k;\r
-#endif\r
-{\r
-    int     i;\r
-\r
-    if (tree == NULL) return;\r
-    if (tree->token == ALT) {\r
-      MR_genMultiLine(tree,k);\r
-    } else {\r
-      MR_LAtokenString(k,tree->token);\r
-      lastkonline=k;\r
-      across++;\r
-      if (tree->down != NULL && tree->down->right == NULL) {\r
-        if (across > 3) {\r
-          _gen("\n");\r
-          across=0;\r
-          lastkonline=0;\r
-          for (i=0 ; i < depth+k ; i++) _gen("   ");\r
-          _gen("&&");\r
-        } else {\r
-          _gen(" &&");\r
-        };\r
-        MR_genMultiLine(tree->down,k+1);\r
-      } else if (tree->down != NULL) {\r
-        _gen("\n");\r
-        lastkonline=0;\r
-        across=0;\r
-        for (i=0 ; i < depth+k ; i++) _gen("   ");\r
-        _gen("&& (");\r
-        MR_genMultiLine(tree->down,k+1);\r
-        _gen(")");\r
-      };\r
-    };\r
-    if (tree->right != NULL) {\r
-      if (k < lastkonline) {\r
-        _gen("\n");\r
-        across=0;\r
-        lastkonline=0;\r
-        for (i=0; i < depth+k-1 ; i++) _gen("   ");\r
-        _gen("||");\r
-      } else if (across > 3 ) {\r
-        _gen("\n");\r
-        across=0;\r
-        lastkonline=0;\r
-        for (i=0; i < depth+k ; i++) _gen("   ");\r
-        _gen("||");\r
-      } else {\r
-        _gen(" ||");\r
-      };\r
-      MR_genMultiLine(tree->right,k);\r
-    };\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-static void genExprTree(Tree *tree,int k)\r
-#else\r
-static void genExprTree(tree,k)\r
-  Tree  *tree;\r
-  int   k;\r
-#endif\r
-{\r
-    int     count;\r
-\r
-#if 0\r
-    /* MR20 THM This was probably an error.\r
-            The routine should probably reference that static \r
-            "across" and this declaration hides it.\r
-    */\r
-\r
-    int     across;\r
-#endif\r
-  \r
-    require (tree != NULL,"genExprTree: tree is NULL");\r
-    require (k > 0,"genExprTree: k <= 0");\r
-\r
-    if (0 && !MRhoisting) {   /* MR11 make new version standard */\r
-      genExprTreeOriginal(tree,k);\r
-    } else {\r
-      count=MR_countLeaves(tree);\r
-      if (count < 5) {\r
-        MR_genOneLine(tree,k);\r
-      } else {\r
-        _gen("\n");\r
-        across=0;\r
-        depth=0;\r
-        lastkonline=0;\r
-        MR_genMultiLine(tree,k);\r
-        _gen("\n");\r
-      };\r
-    };\r
-}\r
-\r
-\r
-/*\r
- * Generate LL(k) type expressions of the form:\r
- *\r
- *              (LA(1) == T1 || LA(1) == T2 || ... || LA(1) == Tn) &&\r
- *              (LA(2) == T1 || LA(2) == T2 || ... || LA(2) == Tn) &&\r
- *                     .....\r
- *              (LA(k) == T1 || LA(k) == T2 || ... || LA(k) == Tn)\r
- *\r
- * If GenExprSetsOpt generate:\r
- *\r
- *             (setwdi[LA(1)]&(1<<j)) && (setwdi[LA(2)]&(1<<j)) ...\r
- *\r
- * where n is set_deg(expr) and Ti is some random token and k is the last nonempty\r
- * set in fset <=CLL_k.\r
- * k=1..CLL_k where CLL_k >= 1.\r
- *\r
- * This routine is visible only to this file and cannot answer a TRANS message.\r
- *\r
- */\r
-\r
-/*  [genExpr] */\r
-\r
-static int\r
-#ifdef __USE_PROTOS\r
-genExpr( Junction *j )\r
-#else\r
-genExpr( j )\r
-Junction *j;\r
-#endif\r
-{\r
-       int max_k;\r
-\r
-       /* if full LL(k) is sufficient, then don't use approximate (-ck) lookahead\r
-        * from CLL_k..LL_k\r
-        */\r
-       {\r
-               int limit;\r
-               if ( j->ftree!=NULL ) limit = LL_k;\r
-               else limit = CLL_k;\r
-               max_k = genExprSets(j->fset, limit);\r
-       }\r
-\r
-       /* Do tests for real tuples from other productions that conflict with\r
-        * artificial tuples generated by compression (using sets of tokens\r
-        * rather than k-trees).\r
-        */\r
-       if ( j->ftree != NULL )\r
-       {\r
-               _gen(" && !("); genExprTree(j->ftree, 1); _gen(")");\r
-       }\r
-\r
-       if ( ParseWithPredicates && j->predicate!=NULL )\r
-       {\r
-               Predicate *p = j->predicate;\r
-               warn_about_using_gk_option();\r
-               _gen("&&");\r
-               j->predicate=genPredTreeMain(p, (Node *)j);     /* MR10 */\r
-       }\r
-\r
-       return max_k;\r
-}\r
-\r
-static int\r
-#ifdef __USE_PROTOS\r
-genExprSets( set *fset, int limit )\r
-#else\r
-genExprSets( fset, limit )\r
-set *fset;\r
-int limit;\r
-#endif\r
-{\r
-       int k = 1;\r
-       int max_k = 0;\r
-       unsigned *e, *g, firstTime=1;\r
-\r
-    if (set_nil(fset[1])) {\r
-      _gen(" 0 /* MR13 empty set expression  - undefined rule ? infinite left recursion ? */ ");\r
-      MR_BadExprSets++;\r
-    };\r
-\r
-       if ( GenExprSetsOpt )\r
-       {\r
-               while ( k <= limit && !set_nil(fset[k]) )   /* MR11 */\r
-               {\r
-                       if ( set_deg(fset[k])==1 )      /* too simple for a set? */\r
-                       {\r
-                               int e;\r
-                               _gen1("(LA(%d)==",k);\r
-                               e = set_int(fset[k]);\r
-                               if ( TokenString(e) == NULL ) _gen1("%d)", e)\r
-                               else _gen1("%s)", TokenString(e));\r
-                       }\r
-                       else\r
-                       {\r
-                               NewSet();\r
-                               FillSet( fset[k] );\r
-                               _gen3("(setwd%d[LA(%d)]&0x%x)", wordnum, k, 1<<setnum);\r
-                       }\r
-                       if ( k>max_k ) max_k = k;\r
-                       if ( k == CLL_k ) break;\r
-                       k++;\r
-                       if ( k<=limit && !set_nil(fset[k]) ) _gen(" && ");  /* MR11 */\r
-                       on1line++;\r
-                       if ( on1line > NumExprPerLine ) { on1line=0; _gen("\n"); }\r
-               }\r
-               return max_k;\r
-       }\r
-\r
-       while ( k<= limit &&  !set_nil(fset[k]) )       /* MR11 */\r
-       {\r
-               if ( (e=g=set_pdq(fset[k])) == NULL ) fatal_internal("genExpr: cannot allocate IF expr pdq set");\r
-               for (; *e!=nil; e++)\r
-               {\r
-                       if ( !firstTime ) _gen(" || ") else { _gen("("); firstTime = 0; }\r
-                       on1line++;\r
-                       if ( on1line > NumExprPerLine ) { on1line=0; _gen("\n"); }\r
-                       _gen1("LA(%d)==",k);\r
-                       if ( TokenString(*e) == NULL ) _gen1("%d", *e)\r
-                       else _gen1("%s", TokenString(*e));\r
-               }\r
-               free( (char *)g );\r
-               _gen(")");\r
-               if ( k>max_k ) max_k = k;\r
-               if ( k == CLL_k ) break;\r
-               k++;\r
-               if ( k <= limit && !set_nil(fset[k]) ) { firstTime=1; _gen(" && "); }   /* MR11 */\r
-               on1line++;\r
-               if ( on1line > NumExprPerLine ) { on1line=0; _gen("\n"); }\r
-       }\r
-       return max_k;\r
-}\r
-\r
-/*\r
- * Generate code for any type of block.  If the last alternative in the block is\r
- * empty (not even an action) don't bother doing it.  This permits us to handle\r
- * optional and loop blocks as well.\r
- *\r
- * Only do this block, return after completing the block.\r
- * This routine is visible only to this file and cannot answer a TRANS message.\r
- */\r
-static set\r
-#ifdef __USE_PROTOS\r
-genBlk( Junction *q, int jtype, int *max_k, int *need_right_curly, int * lastAltEmpty /* MR23 */)\r
-#else\r
-genBlk( q, jtype, max_k, need_right_curly, lastAltEmpty /* MR23 */)\r
-Junction *q;\r
-int jtype;\r
-int *max_k;\r
-int *need_right_curly;\r
-int *lastAltEmpty; /* MR23 */\r
-#endif\r
-{\r
-       set f;\r
-       Junction *alt;\r
-       int a_guess_in_block = 0;\r
-       require(q!=NULL,                                "genBlk: invalid node");\r
-       require(q->ntype == nJunction,  "genBlk: not junction");\r
-       *need_right_curly=0;\r
-       *lastAltEmpty = 0;              /* MR23 */\r
-       if ( q->p2 == NULL )    /* only one alternative?  Then don't need if */\r
-       {       \r
-               if (first_item_is_guess_block((Junction *)q->p1)!=NULL )\r
-               {\r
-            if (jtype != aLoopBlk && jtype != aOptBlk && jtype != aPlusBlk) {\r
-                         warnFL("(...)? as only alternative of block is unnecessary", FileStr[q->file], q->line);\r
-            };\r
-                   gen("zzGUESS\n");   /* guess anyway to make output code consistent */\r
-/* MR10 disable */  /**** gen("if ( !zzrv )\n"); ****/\r
-/* MR10 */          gen("if ( !zzrv ) {\n"); tabs++; (*need_right_curly)++;\r
-        };\r
-               TRANS(q->p1);\r
-               return empty;           /* no decision to be made-->no error set */\r
-       }\r
-\r
-       f = First(q, 1, jtype, max_k);\r
-       for (alt=q; alt != NULL; alt= (Junction *) alt->p2 )\r
-       {\r
-               if ( alt->p2 == NULL )                                  /* chk for empty alt */\r
-               {       \r
-                       Node *p = alt->p1;\r
-                       if ( p->ntype == nJunction )\r
-                       {\r
-                               /* we have empty alt */\r
-/* MR23\r
-   There is a conflict between giving good error information for non-exceptions\r
-   and making life easy for those using parser exception handling.  Consider:\r
-\r
-         r: { A } b;\r
-                b: B;\r
-                \r
-                  with input "C"\r
-\r
-   Before MR21 the error message would be "expecting B - found C".  After MR21\r
-   the error message would be "expcect A, B - found C".  This was good, but it\r
-   caused problems for those using parser exceptions because the reference to\r
-   B was generated inside the {...} where B really wasn't part of the block.\r
-\r
-   In MR23 this has been changed for the case where exceptions are in use to\r
-   not generate the extra check in the tail of the {A} block.\r
-*/\r
-\r
-\r
-/* MR23 */     if (isEmptyAlt( ((Junction *)p)->p1, (Node *)q->end)) {\r
-/* MR23 */      *lastAltEmpty = 1;\r
-/* MR23 */             if (FoundException) {\r
-/* MR23 */                     /* code to restore state if a prev alt didn't follow guess */\r
-/* MR23 */                     if ( a_guess_in_block && jtype != aPlusBlk) {\r
-/* MR23 */                             gen("if ( !zzrv ) zzGUESS_DONE; /* MR28 */\n");\r
-/* MR23 */                     }\r
-/* MR23 */                     break;\r
-/* MR23 */             };\r
-/* MR28 */      if (jtype == aPlusBlk) {\r
-/* MR28 */          break;\r
-/* MR28 */      }\r
-/* MR23 */     }\r
-               }\r
-       } /* end of for loop on alt */\r
-\r
-/* MR10 */        if (alt->p2 == NULL &&\r
-/* MR10 */               ( q->jtype == aSubBlk || q->jtype == RuleBlk) ) {\r
-/* MR10 */          if (first_item_is_guess_block(alt)) {\r
-/* MR10 */               warnFL("(...)? as last alternative of block is unnecessary",\r
-/* MR10 */                                FileStr[alt->file],alt->line);\r
-/* MR10 */          };\r
-/* MR10 */        };\r
-\r
-               if ( alt != q ) gen("else ")\r
-               else\r
-               {\r
-                       if ( DemandLookahead ) {\r
-                               if ( !GenCC ) {gen1("LOOK(%d);\n", *max_k);}\r
-                               else gen1("look(%d);\n", *max_k);\r
-                       }\r
-               }\r
-\r
-               if ( alt!=q )\r
-               {\r
-                       _gen("{\n");\r
-                       tabs++;\r
-                       (*need_right_curly)++;\r
-                       /* code to restore state if a prev alt didn't follow guess */\r
-                       if ( a_guess_in_block )\r
-                               gen("if ( !zzrv ) zzGUESS_DONE;\n");\r
-               }\r
-               if ( first_item_is_guess_block((Junction *)alt->p1)!=NULL )\r
-               {\r
-                       a_guess_in_block = 1;\r
-                       gen("zzGUESS\n");\r
-               }\r
-               gen("if ( ");\r
-               if ( first_item_is_guess_block((Junction *)alt->p1)!=NULL ) _gen("!zzrv && ");\r
-               genExpr(alt);\r
-               _gen(" ) ");\r
-               _gen("{\n");\r
-               tabs++;\r
-               TRANS(alt->p1);\r
-               --tabs;\r
-               gen("}\n");\r
-/* MR10 */        if (alt->p2 == NULL) {\r
-/* MR10 */          if (first_item_is_guess_block(alt)) {\r
-/* MR10 */            gen("/* MR10 */ else {\n");\r
-/* MR10 */            tabs++;\r
-/* MR10 */               (*need_right_curly)++;\r
-/* MR10 */               /* code to restore state if a prev alt didn't follow guess */\r
-/* MR10 */            gen("/* MR10 */ if ( !zzrv ) zzGUESS_DONE;\n");\r
-/* MR10 */            gen("/* MR10 */ if (0) {}     /* last alternative of block is guess block */\n");\r
-/* MR10 */          };\r
-/* MR10 */        };\r
-       }\r
-       return f;\r
-}\r
-\r
-static int\r
-#ifdef __USE_PROTOS\r
-has_guess_block_as_first_item( Junction *q )\r
-#else\r
-has_guess_block_as_first_item( q )\r
-Junction *q;\r
-#endif\r
-{\r
-       Junction *alt;\r
-\r
-       for (alt=q; alt != NULL; alt= (Junction *) alt->p2 )\r
-       {\r
-               if ( first_item_is_guess_block((Junction *)alt->p1)!=NULL ) return 1;\r
-       }\r
-       return 0;\r
-}\r
-\r
-static int\r
-#ifdef __USE_PROTOS\r
-has_guess_block_as_last_item( Junction *q )\r
-#else\r
-has_guess_block_as_last_item( q )\r
-Junction *q;\r
-#endif\r
-{\r
-       Junction *alt;\r
-\r
-    if (q == NULL) return 0;\r
-       for (alt=q; alt->p2 != NULL && !( (Junction *) alt->p2)->ignore; alt= (Junction *) alt->p2 ) {};\r
-    return first_item_is_guess_block( (Junction *) alt->p1) != NULL;\r
-}\r
-\r
-/* MR30 See description of first_item_is_guess_block for background */\r
-\r
-Junction *\r
-#ifdef __USE_PROTOS\r
-first_item_is_guess_block_extra(Junction *q )\r
-#else\r
-first_item_is_guess_block_extra(q)\r
-Junction *q;\r
-#endif\r
-{\r
-       while ( q!=NULL &&\r
-            (  ( q->ntype==nAction ) ||\r
-               ( q->ntype==nJunction &&\r
-                    (q->jtype==Generic || q->jtype == aLoopBlk) \r
-               )\r
-            )\r
-          )\r
-       {\r
-               if ( q->ntype==nJunction ) q = (Junction *)q->p1;\r
-               else q = (Junction *) ((ActionNode *)q)->next;\r
-       }\r
-\r
-       if ( q==NULL ) return NULL;\r
-       if ( q->ntype!=nJunction ) return NULL;\r
-       if ( q->jtype!=aSubBlk ) return NULL;\r
-       if ( !q->guess ) return NULL;\r
-\r
-       return q;\r
-}\r
-\r
-/* return NULL if 1st item of alt is NOT (...)? block; else return ptr to aSubBlk node\r
- * of (...)?;  This function ignores actions and predicates.\r
- */\r
-\r
-Junction *\r
-#ifdef __USE_PROTOS\r
-first_item_is_guess_block( Junction *q )\r
-#else\r
-first_item_is_guess_block( q )\r
-Junction *q;\r
-#endif\r
-{\r
-       Junction * qOriginal = q;       /* DEBUG */\r
-\r
-    /* MR14  Couldn't find aSubBlock which was a guess block when it lay\r
-             behind aLoopBlk.  The aLoopBlk only appear in conjunction with\r
-             aLoopBegin, but the routine didn't know that.  I think.\r
-\r
-       MR14a Added extra parentheses to clarify precedence\r
-\r
-          MR30  This appears to have been a mistake.  The First set was then\r
-                computed incorrectly for:\r
-\r
-                                       r : ( (A)? B\r
-                                           | C\r
-                                               )*\r
-                        \r
-                        The routine analysis_point was seeing the guess block when\r
-                        it was still analyzing the loopBegin block.  As a consequence,\r
-                        when it looked for the analysis_point it was processing the B, but\r
-                        skipping over the C alternative altogether because it thought\r
-                        it was looking at a guess block, not realizing there was a loop\r
-                        block in front of the loopBegin.\r
-\r
-             loopBegin  loopBlk  subBlk/guess  A  G  EB  G  B EB EB  EB  ER\r
-                           |          |          |                     ^   ^\r
-                               |                  |                                |   |\r
-                |          +-> G  C G ----------------------+   |\r
-                |                                               |\r
-                               +--- G G G -------------------------------------+\r
-    \r
-                        Reported by Arpad Beszedes (beszedes@inf.u-szeged.hu).\r
-\r
-               MR30  This is still more complicated.  This fix caused ambiguity messages\r
-               to be reported for "( (A B)? )* A B" but not for "( (A B)? )+".  Why is\r
-               there a difference when these are outwardly identical ?  It is because the\r
-               start of a (...)* block is represented by two nodes: a loopBegin block\r
-               followed by a loopBlock whereas the start of a (...)+ block is\r
-               represented as a single node: a plusBlock.  So if first_item_is_guess_block\r
-               is called when the current node is a loopBegin it starts with the\r
-               loop block rather than the the sub block which follows the loop block.\r
-               However, we can't just skip past the loop block because some routines\r
-               depend on the old implementation.  So, we provide a new implementation\r
-               which does skip the loopBlock.  However, which should be called when ?\r
-               I'm not sure, but my guess is that first_item_is_guess_block_extra (the\r
-               new one) should only be called for the ambiguity routines.\r
-\r
-    */\r
-\r
-       while ( q!=NULL &&\r
-            (  ( q->ntype==nAction ) ||\r
-               ( q->ntype==nJunction &&\r
-                    (q->jtype==Generic /*** || q->jtype == aLoopBlk ***/ ) /*** MR30 Undo MR14 change ***/\r
-               )\r
-            )\r
-          )\r
-       {\r
-               if ( q->ntype==nJunction ) q = (Junction *)q->p1;\r
-               else q = (Junction *) ((ActionNode *)q)->next;\r
-       }\r
-\r
-       if ( q==NULL ) return NULL;\r
-       if ( q->ntype!=nJunction ) return NULL;\r
-       if ( q->jtype!=aSubBlk ) return NULL;\r
-       if ( !q->guess ) return NULL;\r
-\r
-       return q;\r
-}\r
-\r
-/* MR1                                                                                     */\r
-/* MR1  10-Apr-97 MR1 Routine to stringize failed semantic predicates msgs  */\r
-/* MR1                                                                                 */\r
-\r
-#define STRINGIZEBUFSIZE 1024\r
-\r
-static char stringizeBuf[STRINGIZEBUFSIZE];\r
-char *\r
-#ifdef __USE_PROTOS\r
-stringize(char * s)\r
-#else\r
-stringize(s)\r
-char *s;\r
-#endif\r
-\r
-{\r
-  char         *p;\r
-  char         *stop;\r
-\r
-  p=stringizeBuf;\r
-  stop=&stringizeBuf[1015];\r
-\r
-  if (s != 0) {\r
-    while (*s != 0) {\r
-      if (p >= stop) {\r
-       goto stringizeStop;\r
-      } else if (*s == '\n') {\r
-        *p++='\\';\r
-        *p++='n';\r
-        *p++='\\';\r
-       *p++=*s++;\r
-      } else if (*s == '\\') {\r
-       *p++=*s;\r
-       *p++=*s++;\r
-      } else if (*s == '\"') {\r
-        *p++='\\';\r
-       *p++=*s++;\r
-        while (*s != 0) {\r
-          if (p >= stop) {\r
-            goto stringizeStop;\r
-         } else if (*s == '\n') {\r
-           *p++='\\';\r
-           *p++=*s++;\r
-         } else if (*s == '\\') {\r
-           *p++=*s++;\r
-           *p++=*s++;\r
-         } else if (*s == '\"') {\r
-           *p++='\\';\r
-           *p++=*s++;\r
-           break;\r
-         } else {\r
-           *p++=*s++;\r
-          };\r
-        };\r
-      } else if (*s == '\'') {\r
-       *p++=*s++;\r
-        while (*s != 0) {\r
-          if (p >= stop) {\r
-            goto stringizeStop;\r
-         } else if (*s == '\'') {\r
-           *p++=*s++;\r
-           break;\r
-         } else if (*s == '\\') {\r
-           *p++=*s++;\r
-           *p++=*s++;\r
-         } else if (*s == '\"') {\r
-           *p++='\\';\r
-           *p++=*s++;\r
-           break;\r
-         } else {\r
-           *p++=*s++;\r
-          };\r
-        };\r
-      } else {\r
-        *p++=*s++;\r
-      };\r
-    };\r
-  };\r
-  goto stringizeExit;\r
-stringizeStop:\r
-  *p++='.';            \r
-  *p++='.';            \r
-  *p++='.';            \r
-stringizeExit:\r
-  *p=0;\r
-  return stringizeBuf;\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-int isNullAction(char *s)\r
-#else\r
-int isNullAction(s)\r
-  char  *s;\r
-#endif\r
-{\r
-  char  *p;\r
-  for (p=s; *p != '\0' ; p++) {\r
-    if (*p != ';' && *p !=' ') return 0;\r
-  };\r
-  return 1;\r
-}\r
-/* MR1                                                                                                     */\r
-/* MR1 End of Routine to stringize code for failed predicates msgs         */\r
-/* MR1                                                                                 */\r
-\r
-/* Generate an action.  Don't if action is NULL which means that it was already\r
- * handled as an init action.\r
- */\r
-void\r
-#ifdef __USE_PROTOS\r
-genAction( ActionNode *p )\r
-#else\r
-genAction( p )\r
-ActionNode *p;\r
-#endif\r
-{\r
-       require(p!=NULL,                        "genAction: invalid node and/or rule");\r
-       require(p->ntype==nAction,      "genAction: not action");\r
-\r
-       if ( !p->done )  /* MR10 */ /* MR11 */\r
-       {\r
-               if ( p->is_predicate)\r
-               {\r
-                       if ( p->guardpred != NULL )\r
-                       {\r
-                Predicate *guardDup=predicate_dup(p->guardpred); /* MR10 */\r
-                gen("if (!");\r
-                               guardDup=genPredTreeMain(guardDup, (Node *)p);\r
-                predicate_free(guardDup);\r
-                       }\r
-/* MR10 */  else if (p->ampersandPred != NULL) {\r
-/* MR10 */      gen("if (!");\r
-/* MR10 */      p->ampersandPred=genPredTreeMain(p->ampersandPred, (Node *)p);\r
-/* MR10 */  }\r
-                       else\r
-                       {\r
-                               gen("if (!(");\r
-                               /* make sure that '#line n' is on front of line */\r
-                               if ( GenLineInfo && p->file != -1 ) _gen("\n");\r
-                               dumpPredAction(p,p->action, output, 0, p->file, p->line, 0);\r
-                               _gen(")");\r
-                       }\r
-\r
-/* MR23 Change failed predicate macro to have three arguments:\r
-\r
-        macro arg 1: The stringized predicate itself\r
-        macro arg 2: 0 => no user-defined error action\r
-                     1 => user-defined error action\r
-        macro arg 3: The user-defined error action\r
-\r
-   This gives the user more control of the error action.\r
-*/\r
-                       tabs++;\r
-                       gen3(") {zzfailed_pred(\"%s\",%s, { %s } );}\n",         /* MR23 */\r
-                                       stringize(p->action),                            /* MR23 */\r
-                    (p->pred_fail == NULL ?                          /* MR23/MR27 */\r
-                               "0 /* report */" : "1 /* user action */"),   /* MR23/MR27 */\r
-                    (p->pred_fail == NULL ?                          /* MR23 */\r
-                        "0; /* no user action */" : p->pred_fail));  /* MR23 */\r
-                       tabs--;\r
-               }\r
-               else    /* not a predicate */\r
-               {\r
-            if (! isNullAction(p->action) && !p->noHoist) {\r
-                         if ( FoundGuessBlk ) {\r
-                               if ( GenCC ) {\r
-                  gen("if ( !guessing ) {\n");\r
-                } else {\r
-                                 gen("zzNON_GUESS_MODE {\n");\r
-                };\r
-              };\r
-                         dumpActionPlus(p, p->action, output, tabs, p->file, p->line, 1); /* MR21 */\r
-                         if ( FoundGuessBlk ) gen("}\n");\r
-            };\r
-               }\r
-       }\r
-       TRANS(p->next)\r
-}\r
-\r
-/*\r
- *             if invoking rule has !noAST pass zzSTR to rule ref and zzlink it in\r
- *             else pass addr of temp root ptr (&_ast) (don't zzlink it in).\r
- *\r
- *             if ! modifies rule-ref, then never link it in and never pass zzSTR.\r
- *             Always pass address of temp root ptr.\r
- */\r
-void\r
-#ifdef __USE_PROTOS\r
-genRuleRef( RuleRefNode *p )\r
-#else\r
-genRuleRef( p )\r
-RuleRefNode *p;\r
-#endif\r
-{\r
-       Junction *q;\r
-       char *handler_id = "";\r
-       RuleEntry *r, *r2;\r
-       char *parm = "", *exsig = "";\r
-\r
-    int     genRuleRef_emittedGuessGuard=0;     /* MR10 */\r
-\r
-       require(p!=NULL,                        "genRuleRef: invalid node and/or rule");\r
-       require(p->ntype==nRuleRef, "genRuleRef: not rule reference");\r
-       \r
-       if ( p->altstart!=NULL && p->altstart->exception_label!=NULL )\r
-               handler_id = p->altstart->exception_label;\r
-\r
-       r = (RuleEntry *) hash_get(Rname, p->text);\r
-       if ( r == NULL )\r
-       {\r
-               warnFL( eMsg1("rule %s not defined",\r
-                                         p->text), FileStr[p->file], p->line );\r
-               return;\r
-       }\r
-\r
-/* MR8 5-Aug-97     Reported by S.Bochnak@microtool.com.pl                  */\r
-/*                  Don't do assign when no return values declared          */\r
-/*                  Move definition of q up and use it to guard p->assign   */\r
-\r
-       q = RulePtr[r->rulenum];        /* find definition of ref'd rule */  /* MR8 */\r
-\r
-       r2 = (RuleEntry *) hash_get(Rname, p->rname);\r
-       if ( r2 == NULL ) {warnNoFL("Rule hash table is screwed up beyond belief"); return;}\r
-\r
-    OutLineInfo(output,p->line,FileStr[p->file]);\r
-\r
-       if ( GenCC && GenAST ) {\r
-               gen("_ast = NULL;\n");\r
-       }\r
-\r
-       if ( FoundGuessBlk && p->assign!=NULL && q->ret != NULL ) {      /* MR8 */\r
-               if ( GenCC ) {\r
-          gen("if ( !guessing ) {\n");\r
-        } else {\r
-          gen("zzNON_GUESS_MODE {\n");\r
-        };\r
-        tabs++;                                                      /* MR11 */\r
-        genRuleRef_emittedGuessGuard=1;                              /* MR11 */\r
-    };\r
-\r
-       if ( FoundException ) exsig = "&_signal";\r
-\r
-       tab();\r
-       if ( GenAST )\r
-       {\r
-               if ( GenCC ) {\r
-/****                  if ( r2->noAST || p->astnode==ASTexclude )\r
-****/\r
-                       {\r
-/****                          _gen("_ast = NULL;\n");\r
-****/\r
-                               parm = "&_ast";\r
-                       }\r
-/*** we always want to set just a pointer now, then set correct\r
-pointer after\r
-\r
-                       else {\r
-                               _gen("_astp =\r
-(_tail==NULL)?(&_sibling):(&(_tail->_right));\n");\r
-                               parm = "_astp";\r
-                       }\r
-****/\r
-               }\r
-               else {\r
-                       if ( r2->noAST || p->astnode==ASTexclude )\r
-                       {\r
-                               _gen("_ast = NULL; ");\r
-                               parm = "&_ast";\r
-                       }\r
-                       else parm = "zzSTR";\r
-               }\r
-               if ( p->assign!=NULL && q->ret!=NULL )                       /* MR8 */\r
-               {\r
-                       if ( !hasMultipleOperands(p->assign) ) {_gen1("%s = ",p->assign);} /* MR23 */\r
-                       else _gen1("{ struct _rv%d _trv; _trv = ", r->rulenum);\r
-               }\r
-               if ( FoundException ) {\r
-                       _gen5("%s%s(%s,&_signal%s%s); ",\r
-                                 RulePrefix,\r
-                                 p->text,\r
-                                 parm,\r
-                                 (p->parms!=NULL)?",":"",\r
-                                 (p->parms!=NULL)?p->parms:"");\r
-                       if ( p->ex_group!=NULL ) {\r
-                               _gen("\n");\r
-                               gen("if (_signal) {\n");\r
-                               tabs++;\r
-                               dumpException(p->ex_group, 0);\r
-                               tabs--;\r
-                               gen("}");\r
-                       }\r
-                       else {\r
-                               _gen1("if (_signal) goto %s_handler;", handler_id);\r
-                       }\r
-               }\r
-               else {\r
-                       _gen5("%s%s(%s%s%s);",\r
-                                 RulePrefix,\r
-                                 p->text,\r
-                                 parm,\r
-                                 (p->parms!=NULL)?",":"",\r
-                                 (p->parms!=NULL)?p->parms:"");\r
-               }\r
-               if ( GenCC && (r2->noAST || p->astnode==ASTexclude) )\r
-               {\r
-                       /* rule has a ! or element does */\r
-                       /* still need to assign to #i so we can play with it */\r
-                       _gen("\n");\r
-                       gen2("_ast%d%d = (AST *)_ast;", BlkLevel-1, p->elnum);\r
-               }\r
-               else if ( !r2->noAST && p->astnode == ASTinclude )\r
-               {\r
-                       /* rule doesn't have a ! and neither does element */\r
-/* MR10 */  if (FoundGuessBlk && !genRuleRef_emittedGuessGuard) {\r
-/* MR10 */    _gen("\n");\r
-/* MR10 */    if (GenCC) gen ("if (!guessing) {    /* MR10 */")\r
-/* MR10 */          else gen ("if (!zzguessing) {    /* MR10 */\n");\r
-/* MR10 */    tabs++;\r
-/* MR10 */  };\r
-                       if ( GenCC ) {\r
-                               _gen("\n");\r
-                               gen("if ( _tail==NULL ) _sibling = _ast; else _tail->setRight(_ast);\n");\r
-                               gen2("_ast%d%d = (AST *)_ast;\n", BlkLevel-1, p->elnum);\r
-                               tab();\r
-                       }\r
-                       else _gen(" ");\r
-            if ( GenCC ) {\r
-                _gen("ASTBase::"); }\r
-                else _gen("zz");\r
-                       _gen("link(_root, &_sibling, &_tail);");\r
-\r
-/* MR10 */  if (FoundGuessBlk && !genRuleRef_emittedGuessGuard) {     /* MR10 */\r
-/* MR10 */    _gen("\n");\r
-/* MR10 */    tabs--;\r
-/* MR10 */    if (GenCC) gen ("};    /* MR10 */")\r
-/* MR10 */          else gen ("};    /* MR10 */");\r
-/* MR10 */  };\r
-               }\r
-       }\r
-       else\r
-       {\r
-               if ( p->assign!=NULL && q->ret!=NULL )                       /* MR8 */\r
-               {\r
-                       if ( !hasMultipleOperands(p->assign) ) {_gen1("%s = ",p->assign);} /* MR23 */\r
-                       else _gen1("{ struct _rv%d _trv; _trv = ", r->rulenum);\r
-               }\r
-               if ( FoundException ) {\r
-                       _gen4("%s%s(&_signal%s%s); ",\r
-                                 RulePrefix,\r
-                                 p->text,\r
-                                 (p->parms!=NULL)?",":"",\r
-                                 (p->parms!=NULL)?p->parms:"");\r
-                       if ( p->ex_group!=NULL ) {\r
-                               _gen("\n");\r
-                               gen("if (_signal) {\n");\r
-                               tabs++;\r
-                               dumpException(p->ex_group, 0);\r
-                               tabs--;\r
-                               gen("}");\r
-                       }\r
-                       else {\r
-                               _gen1("if (_signal) goto %s_handler;", handler_id);\r
-                       }\r
-               }\r
-               else {\r
-                       _gen3("%s%s(%s);",\r
-                                 RulePrefix,\r
-                                 p->text,\r
-                                 (p->parms!=NULL)?p->parms:"");\r
-               }\r
-               if ( p->assign!=NULL && q->ret!=NULL ) _gen("\n");           /* MR8 */\r
-       }\r
-\r
-       if ( p->assign!=NULL && q->ret!=NULL) {                          /* MR8 */\r
-               if ( hasMultipleOperands(p->assign) )                        /* MR23 */\r
-               {\r
-                       _gen("\n");\r
-                       dumpRetValAssign(p->assign, q->ret, p);                  /* MR30 */\r
-                       _gen("}");\r
-               }\r
-       }\r
-       _gen("\n");\r
-\r
-       /* Handle element labels now */\r
-       if ( p->el_label!=NULL )\r
-       {\r
-               if ( GenAST )\r
-               {\r
-                       if ( GenCC ) {\r
-                               gen3("%s_ast = _ast%d%d;\n", p->el_label, BlkLevel-1, p->elnum);\r
-                       }\r
-                       else {gen1("%s_ast = zzastCur;\n", p->el_label);}\r
-               }\r
-               else if (!GenCC ) {\r
-                       gen1("%s = zzaCur;\n", p->el_label);\r
-        }\r
-       }\r
-\r
-       if ( FoundGuessBlk && p->assign!=NULL && q->ret!=NULL ) {       /* MR8 */\r
-               /* in guessing mode, don't branch to handler upon error */\r
-        tabs--;                                                     /* MR11 */\r
-               gen("} else {\n");\r
-        tabs++;                                                     /* MR11 */\r
-               if ( FoundException ) {\r
-                       gen6("%s%s(%s%s&_signal%s%s);\n",\r
-                                RulePrefix,\r
-                                p->text,\r
-                                parm,\r
-                 (*parm!='\0')?",":"",\r
-                 (p->parms!=NULL)?",":"",\r
-                                (p->parms!=NULL)?p->parms:"");\r
-               }\r
-               else {\r
-                       gen5("%s%s(%s%s%s);\n",\r
-                                RulePrefix,\r
-                                p->text,\r
-                                parm,\r
-                                (p->parms!=NULL && *parm!='\0')?",":"",\r
-                                (p->parms!=NULL)?p->parms:"");\r
-               }\r
-        tabs--;                                                     /* MR11 */\r
-               gen("}\n");\r
-       }\r
-       TRANS(p->next)\r
-}\r
-\r
-/*\r
- * Generate code to match a token.\r
- *\r
- * Getting the next token is tricky.  We want to ensure that any action\r
- * following a token is executed before the next GetToken();\r
- */\r
-void\r
-#ifdef __USE_PROTOS\r
-genToken( TokNode *p )\r
-#else\r
-genToken( p )\r
-TokNode *p;\r
-#endif\r
-{\r
-       RuleEntry *r;\r
-       char *handler_id = "";\r
-       ActionNode *a;\r
-       char *set_name;\r
-       char *set_nameErrSet;\r
-       int complement;\r
-       int ast_label_in_action = 0;    /* MR27 */\r
-       int pushedCmodeAST = 0;                 /* MR27 */\r
-\r
-       require(p!=NULL,                        "genToken: invalid node and/or rule");\r
-       require(p->ntype==nToken,       "genToken: not token");\r
-       if ( p->altstart!=NULL && p->altstart->exception_label!=NULL )\r
-               handler_id = p->altstart->exception_label;\r
-\r
-       r = (RuleEntry *) hash_get(Rname, p->rname);\r
-       if ( r == NULL ) {warnNoFL("Rule hash table is screwed up beyond belief"); return;}\r
-\r
-/*\r
- * MR27 Has the element label been referenced as an AST (with the # operator) ?\r
- *      If so, then we'll want to build the AST even though the user has used\r
- *      the ! operator.\r
- */\r
-/* MR27 */     if (GenAST && p->el_label != NULL) {\r
-/* MR27 */             ast_label_in_action = list_search_cstring(r->ast_labels_in_actions,\r
-/* MR27 */                                                       p->el_label);\r
-/* MR27 */     }\r
-       \r
-    OutLineInfo(output,p->line,FileStr[p->file]);\r
-\r
-       if ( !set_nil(p->tset) )        /* implies '.', ~Tok, or tokenclass */\r
-       {\r
-               unsigned e;\r
-               unsigned eErrSet = 0;\r
-               set b;\r
-               set bErrSet;                                    /* MR23 */\r
-               b = set_dup(p->tset);\r
-               bErrSet = set_dup(p->tset);         /* MR23 */\r
-               complement = p->complement; /* MR23 */\r
-               if ( p->tclass!=NULL  && complement == 0 /* MR23 */) { /* token class not complemented*/\r
-                       static char buf[MaxRuleName+20];            /* MR23 */\r
-                       static char bufErrSet[MaxRuleName+20];  /* MR23 */\r
-                       if ( p->tclass->dumped ) {\r
-                               e = p->tclass->setnum;\r
-                               eErrSet = p->tclass->setnumErrSet;\r
-                       }\r
-                       else {\r
-                               e = DefErrSet(&b, 0, TokenString(p->token));\r
-                               eErrSet = DefErrSetWithSuffix(0, &bErrSet, 1, TokenString(p->token), "_errset");\r
-                               p->tclass->dumped = 1;  /* indicate set has been created */\r
-                               p->tclass->setnum = e;\r
-                               p->tclass->setnumErrSet = eErrSet;                                      /* MR23 */\r
-                       }\r
-                       sprintf(buf, "%s_set", TokenString(p->token));\r
-                       sprintf(bufErrSet, "%s_errset", TokenString(p->token)); /* MR23 */\r
-                       set_name = buf;\r
-                       set_nameErrSet = bufErrSet;                                                             /* MR23 */\r
-               }\r
-\r
-               /* MR23 - Forgot about the case of ~TOKCLASS. */\r
-\r
-               else if ( p->tclass!=NULL  && complement != 0 /* MR23 */)\r
-               {\r
-                       static char buf[MaxRuleName+20];            /* MR23 */\r
-                       static char bufErrSet[MaxRuleName+20];  /* MR23 */\r
-                       if ( p->tclass->dumpedComplement ) {\r
-                               e = p->tclass->setnumComplement;\r
-                               eErrSet = p->tclass->setnumErrSetComplement;\r
-                       }\r
-                       else {\r
-                               e = DefErrSetWithSuffix(0, &b, 0, TokenString(p->token), "_setbar");\r
-                               eErrSet = DefErrSetWithSuffix(0, &bErrSet, 1, TokenString(p->token), "_errsetbar");\r
-                               p->tclass->dumpedComplement = 1;        /* indicate set has been created */\r
-                               p->tclass->setnumComplement = e;\r
-                               p->tclass->setnumErrSetComplement = eErrSet;                                    /* MR23 */\r
-                       }\r
-                       sprintf(buf, "%s_setbar", TokenString(p->token));\r
-                       sprintf(bufErrSet, "%s_errsetbar", TokenString(p->token));      /* MR23 */\r
-                       set_name = buf;\r
-                       set_nameErrSet = bufErrSet;                                                             /* MR23 */\r
-               }\r
-               else {                                  /* wild card */\r
-                       static char buf[sizeof("zzerr")+10];\r
-                       static char bufErrSet[sizeof("zzerr")+10];\r
-                       int n = DefErrSet( &b, 0, NULL );\r
-                       int nErrSet = DefErrSetWithSuffix(0, &bErrSet, 1, NULL, "_set");\r
-                       if ( GenCC ) sprintf(buf, "err%d", n);\r
-                       else sprintf(buf, "zzerr%d", n);\r
-                       if ( GenCC ) sprintf(bufErrSet, "err%d", nErrSet);\r
-                       else sprintf(bufErrSet, "zzerr%d", nErrSet);\r
-                       set_name = buf;\r
-                       set_nameErrSet = bufErrSet;\r
-               }\r
-\r
-               if ( !FoundException ) {\r
-/* MR23 */             gen2("zzsetmatch(%s, %s);", set_name, set_nameErrSet);\r
-               }\r
-               else if ( p->ex_group==NULL ) {\r
-            if ( p->use_def_MT_handler )\r
-                gen3("zzsetmatch_wdfltsig(%s,(ANTLRTokenType)%d,%s);",\r
-                     set_name,\r
-                     p->token,\r
-                     tokenFollowSet(p))\r
-            else\r
-                gen2("zzsetmatch_wsig(%s, %s_handler);",\r
-                     set_name,\r
-                     handler_id);\r
-               }\r
-               else\r
-               {\r
-                       gen1("if ( !_setmatch_wsig(%s) ) {\n", set_name);\r
-                       tabs++;\r
-/* MR6 */      if (FoundGuessBlk) {\r
-/* MR6 */        if ( GenCC ) {gen("if ( guessing ) goto fail;\n");}\r
-/* MR6 */        else gen("if ( zzguessing ) goto fail;\n");\r
-/* MR6 */      };\r
-                       gen("_signal=MismatchedToken;\n");\r
-                       dumpException(p->ex_group, 0);\r
-                       tabs--;\r
-                       gen("}\n");\r
-               }\r
-               set_free(b);\r
-               set_free(bErrSet);\r
-       }\r
-       else if ( TokenString(p->token)!=NULL )\r
-       {\r
-               if ( FoundException ) {\r
-                       if ( p->use_def_MT_handler )\r
-                               gen2("zzmatch_wdfltsig(%s,%s);",TokenString(p->token),tokenFollowSet(p))\r
-                       else if ( p->ex_group==NULL )\r
-                       {\r
-                               gen2("zzmatch_wsig(%s, %s_handler);",\r
-                                        TokenString(p->token),\r
-                                        handler_id);\r
-                       }\r
-                       else\r
-                       {\r
-/* MR6 */              if (GenCC) {\r
-/* MR6 */                gen1("if ( !_match_wsig(%s) ) {\n", TokenString(p->token));\r
-/* MR6 */              } else {\r
-/* MR6 */                gen1("if ( !_zzmatch_wsig(%s) ) {\n", TokenString(p->token));\r
-/* MR6 */              };\r
-                               tabs++;\r
-/* MR6 */              if (FoundGuessBlk) {\r
-/* MR6 */                if ( GenCC ) {gen("if ( guessing ) goto fail;\n");}\r
-/* MR6 */                else gen("if ( zzguessing ) goto fail;\n");\r
-/* MR6 */              };\r
-                               gen("_signal=MismatchedToken;\n");\r
-                               dumpException(p->ex_group, 0);\r
-                               tabs--;\r
-                               gen("}\n");\r
-                       }\r
-               }\r
-               else gen1("zzmatch(%s);", TokenString(p->token));\r
-       }\r
-       else {\r
-        if ( FoundException ) {\r
-            if ( p->use_def_MT_handler )\r
-                               gen2("zzmatch_wdfltsig((ANTLRTokenType)%d,%s);",\r
-                                        p->token,tokenFollowSet(p))\r
-            else\r
-                gen2("zzmatch_wsig(%d,%s_handler);",p->token,handler_id);\r
-        }\r
-               else {gen1("zzmatch(%d);", p->token);}\r
-       }\r
-\r
-       a = findImmedAction( p->next );\r
-       /* generate the token labels */\r
-       if ( GenCC && p->elnum>0 )\r
-       {\r
-               /* If building trees in C++, always gen the LT() assigns */\r
-               if ( set_el(p->elnum, tokensRefdInBlock) || GenAST )\r
-               {\r
-/* MR10 */     if ( FoundGuessBlk ) {\r
-/* MR10 */    gen("\n");\r
-/* MR10 */    if (p->label_used_in_semantic_pred) {\r
-/* MR10 */             gen2(" _t%d%d = (ANTLRTokenPtr)LT(1);  /* MR10 */\n", BlkLevel-1, p->elnum);\r
-/* MR10 */    } else {\r
-/* MR10 */             gen("if ( !guessing ) {\n"); tab();\r
-/* MR10 */             _gen2(" _t%d%d = (ANTLRTokenPtr)LT(1);\n", BlkLevel-1, p->elnum);\r
-/* MR10 */      gen("}\n");\r
-/* MR10 */    };\r
-/* MR10 */  } else {\r
-/* MR10 */       _gen2(" _t%d%d = (ANTLRTokenPtr)LT(1);", BlkLevel-1, p->elnum);\r
-/* MR10 */  };\r
-/* MR10 */\r
-               }\r
-\r
-/*\r
- *  MR23 labase is never used in the C++ runtime library.\r
- *       and this code is generated only in C++ mode\r
- */\r
-\r
-/***           if ( LL_k>1 )                                    / * MR23 disabled */\r
-/***                   if ( !DemandLookahead ) _gen(" labase++;");  / * MR23 disabled */\r
-/***           _gen("\n");                                      / * MR23 disabled */\r
-/***           tab();                                           / * MR23 disabled */\r
-       }\r
-       if ( GenAST )\r
-       {\r
-               if ( FoundGuessBlk &&\r
-                               (ast_label_in_action || !(p->astnode == ASTexclude || r->noAST)) )\r
-               {\r
-                       if ( GenCC ) {_gen("if ( !guessing ) {\n"); tab();}\r
-                       else {_gen("zzNON_GUESS_MODE {\n"); tab();}\r
-               }\r
-\r
-/* MR27 addition when labels referenced when operator ! used */\r
-\r
-               pushedCmodeAST = 0; /* MR27 */\r
-               if (ast_label_in_action && (p->astnode == ASTexclude || r->noAST)) {\r
-                       _gen("\n");\r
-                       if (GenCC) {\r
-/* MR13 */      if (NewAST) {\r
-/* MR13 */         gen4("_ast%d%d = newAST(_t%d%d); /* MR27 */\n", BlkLevel-1, p->elnum, BlkLevel-1, p->elnum);\r
-/* MR13 */      } else {\r
-/* MR13 */         gen4("_ast%d%d = new AST(_t%d%d); /* MR27 */\n", BlkLevel-1, p->elnum, BlkLevel-1, p->elnum);\r
-/* MR13 */      }\r
-                       }\r
-                       else {\r
-                               pushedCmodeAST = 1;\r
-                               gen("zzastPush(zzmk_ast(zzastnew(),zzaCur)); /* MR27 */");\r
-                       }\r
-               }\r
-\r
-/* end MR27 addition for labels referenced when operator ! used */\r
-\r
-               if (!r->noAST )\r
-               {\r
-                       if (GenCC && !(p->astnode == ASTexclude) ) {\r
-                               _gen("\n");\r
-/* MR13 */      if (NewAST) {\r
-/* MR13 */         gen4("_ast%d%d = newAST(_t%d%d);\n", BlkLevel-1, p->elnum, BlkLevel-1, p->elnum);\r
-/* MR13 */      } else {\r
-/* MR13 */         gen4("_ast%d%d = new AST(_t%d%d);\n", BlkLevel-1, p->elnum, BlkLevel-1, p->elnum);\r
-/* MR13 */      }\r
-                               tab();\r
-                       }\r
-                       if ( GenCC && !(p->astnode == ASTexclude) )\r
-                               {_gen2("_ast%d%d->", BlkLevel-1, p->elnum);}\r
-                       else _gen(" ");\r
-                       if ( p->astnode==ASTchild ) {\r
-                               if ( !GenCC ) _gen("zz");\r
-                               _gen("subchild(_root, &_sibling, &_tail);");\r
-                       }\r
-                       else if ( p->astnode==ASTroot ) {\r
-                               if ( !GenCC ) _gen("zz");\r
-                               _gen("subroot(_root, &_sibling, &_tail);");\r
-                       }\r
-                       if ( GenCC && !(p->astnode == ASTexclude) ) {\r
-                               _gen("\n");\r
-                               tab();\r
-                       }\r
-               }\r
-               else if ( !GenCC ) {\r
-                       if (! pushedCmodeAST) _gen(" zzastDPush;");\r
-               }\r
-               if ( FoundGuessBlk &&\r
-                               (ast_label_in_action || !(p->astnode == ASTexclude || r->noAST)) )\r
-                       {gen("}\n"); tab();}\r
-       }\r
-\r
-       /* Handle element labels now */\r
-       if ( p->el_label!=NULL )\r
-       {\r
-        int     done_NON_GUESSMODE=0;\r
-\r
-               _gen("\n");\r
-\r
-/* MR10 */    /* do Attrib / Token ptr for token label used in semantic pred */\r
-/* MR10 */    /* for these cases do assign even in guess mode                */\r
-/* MR10 */\r
-/* MR10 */    if (p->label_used_in_semantic_pred) {\r
-/* MR10 */      if ( GenCC ) {\r
-/* MR10 */        if ( set_el(p->elnum, tokensRefdInBlock) || GenAST ) {\r
-/* MR10 */          gen3("%s = _t%d%d;", p->el_label, BlkLevel-1, p->elnum);\r
-/* MR10 */        } else {\r
-/* MR10 */          gen1("%s = (ANTLRTokenPtr)LT(1);\n", p->el_label);\r
-/* MR10 */        };\r
-/* MR10 */      } else {\r
-/* MR10 */               gen1("%s = zzaCur;", p->el_label);\r
-/* MR10 */      };\r
-/* MR10 */      if (FoundGuessBlk) _gen("  /* MR10 */");\r
-/* MR10 */      _gen("\n");\r
-/* MR10 */    };\r
-\r
-               /* Do Attrib / Token ptr */\r
-\r
-/* MR10 */  if (! p->label_used_in_semantic_pred) {\r
-/* MR10 */\r
-/* MR10 */      if ( FoundGuessBlk ) {\r
-/* MR10 */        if (! done_NON_GUESSMODE) {\r
-/* MR10 */          done_NON_GUESSMODE=1;\r
-/* MR10 */          if ( GenCC ) {gen("if ( !guessing ) {\n"); tab();}\r
-/* MR10 */          else {gen("zzNON_GUESS_MODE {\n"); tab();}\r
-/* MR10 */        };\r
-/* MR10 */      };\r
-/* MR10 */\r
-/* MR10 */      if ( GenCC ) {\r
-/* MR10 */        if ( set_el(p->elnum, tokensRefdInBlock) || GenAST ) {\r
-/* MR10 */          gen3("%s = _t%d%d;\n", p->el_label, BlkLevel-1, p->elnum);\r
-/* MR10 */        } else {\r
-/* MR10 */          gen1("%s = (ANTLRTokenPtr)LT(1);\n", p->el_label);\r
-/* MR10 */        };\r
-/* MR10 */      } else {\r
-/* MR10 */        gen1("%s = zzaCur;\n", p->el_label);\r
-/* MR10 */      };\r
-/* MR10 */  };\r
-\r
-               /* Do AST ptr */\r
-\r
-               if (GenAST && (ast_label_in_action || !(p->astnode == ASTexclude || r->noAST) )) /* MR27 */\r
-               {\r
-\r
-/* MR10 */      if ( FoundGuessBlk ) {\r
-/* MR10 */        if (! done_NON_GUESSMODE) {\r
-/* MR10 */          done_NON_GUESSMODE=1;\r
-/* MR10 */          if ( GenCC ) {gen("if ( !guessing ) {\n"); tab();}\r
-/* MR10 */          else {gen("zzNON_GUESS_MODE {\n"); tab();}\r
-/* MR10 */        };\r
-/* MR10 */      };\r
-\r
-                       if ( GenCC ) {\r
-                               gen3("%s_ast = _ast%d%d;\n", p->el_label, BlkLevel-1, p->elnum);\r
-                       }\r
-                       else {gen1("%s_ast = zzastCur;\n", p->el_label);}\r
-               }\r
-\r
-/* MR10 */  if (done_NON_GUESSMODE) {\r
-/* MR10 */    gen("}\n"); tab();\r
-/* MR10 */  };\r
-\r
-       }\r
-\r
-       /* Handle any actions immediately following action */\r
-       if ( a != NULL )  /* MR10 */ /* MR11 */\r
-    {\r
-       /* delay next token fetch until after action */\r
-               _gen("\n");\r
-               if ( a->is_predicate)\r
-               {\r
-#if 0\r
-/* Disabled in MR30 ************************************************************\r
-   And moved into genAction\r
-   *****************************************************************************\r
-*/\r
\r
-           gen("if (!(");\r
-\r
-                       /* make sure that '#line n' is on front of line */  /* MR14 */\r
-                       if ( GenLineInfo && p->file != -1 ) _gen("\n");     /* MR14 */\r
-                       dumpPredAction(a,a->action, output, 0, a->file, a->line, 0);\r
-\r
-/* MR23 Change failed predicate macro to have three arguments:\r
-\r
-        macro arg 1: The stringized predicate itself\r
-        macro arg 2: 0 => no user-defined error action\r
-                     1 => user-defined error action\r
-        macro arg 3: The user-defined error action\r
-\r
-   This gives the user more control of the error action.\r
-*/\r
-                       _gen(")) \n");\r
-                       tabs++;\r
-                       gen3(" {zzfailed_pred(\"%s\",%s,{ %s } );}\n",           /* MR23 */\r
-                                       stringize(a->action),                            /* MR23 */\r
-                    (a->pred_fail == NULL ?                          /* MR23/MR27 */\r
-                               "0 /* report */" : "1 /* user action */"),   /* MR23/MR27 */\r
-                    (a->pred_fail == NULL ?                          /* MR23 */\r
-                        "0; /* no user action */" : a->pred_fail));  /* MR23 */\r
-                       tabs--;\r
-/* Disabled in MR30 ************************************************************\r
-   And moved into genAction\r
-   *****************************************************************************\r
-*/\r
-#endif\r
-               }\r
-               else    /* MR9 a regular action - not a predicate action */\r
-               {\r
-\r
-/* MR23: Search an action which is not a predicate for LT(i),\r
-         LA(i), or LATEXT(i) in order to warn novice users that\r
-         it refers to the previous matched token, not the next\r
-         one.  This is different than the case for semantic\r
-         predicates.\r
-*/\r
-                                 \r
-/* MR23 */    if (GenCC) {\r
-/* MR23 */         if (strstr(a->action, "LT(") != NULL) LTinTokenAction = 1;\r
-/* MR23 */    }\r
-/* MR23 */    else {\r
-/* MR23 */      if (strstr(a->action, "LA(") != NULL) LTinTokenAction = 1;            \r
-/* MR23 */      if (strstr(a->action, "LATEXT(") != NULL) LTinTokenAction = 1;\r
-/* MR23 */    }\r
-\r
-                       if ( FoundGuessBlk ) {\r
-                               if ( GenCC ) {gen("if ( !guessing ) {\n");}\r
-                               else gen("zzNON_GUESS_MODE {\n");\r
-                       }\r
-                       dumpActionPlus(a, a->action, output, tabs, a->file, a->line, 1); /* MR21 */\r
-                       if ( FoundGuessBlk ) gen("}\n");\r
-                       a->done = 1; /* MR30 */\r
-               }\r
-/***    a->done = 1;  MR30 Moved up into then branch for true actions, but not predicates ***/\r
-               if ( !DemandLookahead ) {\r
-                       if ( GenCC ) {\r
-                               if ( FoundException && p->use_def_MT_handler ) gen("if (!_signal)");\r
-                               _gen(" consume();")\r
-                if ( FoundException && p->use_def_MT_handler )\r
-                    _gen(" _signal=NoSignal;");\r
-                _gen("\n");\r
-                       }\r
-            else\r
-            {\r
-                if ( FoundException && p->use_def_MT_handler ) _gen("if (!_signal)");\r
-                                       _gen(" zzCONSUME;\n");\r
-                if ( FoundException && p->use_def_MT_handler ) _gen(" _signal=NoSignal;");\r
-                _gen("\n");\r
-            }\r
-               }\r
-               else gen("\n");\r
-               if (a->done) {                  /* MR30 */\r
-                       TRANS( a->next );   /* MR30 */\r
-               }                                               /* MR30 */\r
-               else {                                  /* MR30 */\r
-                       TRANS( p->next );       /* MR30 */\r
-               }                                               /* MR30 */\r
-       }\r
-       else\r
-       {\r
-        if ( !DemandLookahead ) {\r
-                       if ( GenCC ) {\r
-                               if (FoundException && p->use_def_MT_handler) _gen("if (!_signal)");\r
-                               _gen(" consume();")\r
-                               if (FoundException&&p->use_def_MT_handler) _gen(" _signal=NoSignal;");\r
-                               _gen("\n");\r
-                       }\r
-                       else {\r
-                               if (FoundException && p->use_def_MT_handler) _gen("if (!_signal)");\r
-                               _gen(" zzCONSUME;");\r
-                               if ( FoundException && p->use_def_MT_handler ) _gen(" _signal=NoSignal;");\r
-                               _gen("\n");\r
-                       }\r
-               }\r
-               else _gen("\n");\r
-               TRANS(p->next);\r
-       }\r
-}\r
-\r
-/*  MR21\r
- *\r
- *  There was a bug in the code generation for {...} which causes it\r
- *  to omit the optional tokens from the error messages.  The easiest\r
- *  way to fix this was to make the opt block look like a sub block:\r
- *\r
- *          { a | b | c }\r
- *\r
- *  becomes (internally):\r
- *\r
- *          ( a | b | c | )\r
- *\r
- *  The code for genOptBlk is now identical to genSubBlk except for\r
- *  cosmetic changes.\r
- */\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-genOptBlk( Junction *q )\r
-#else\r
-genOptBlk( q )\r
-Junction *q;\r
-#endif\r
-{\r
-       int max_k;\r
-       set f;\r
-       int need_right_curly;\r
-       set savetkref;\r
-       int lastAltEmpty;                       /* MR23 */\r
-       savetkref = tokensRefdInBlock;\r
-       require(q->ntype == nJunction,  "genOptBlk: not junction");\r
-       require(q->jtype == aOptBlk,    "genOptBlk: not opt block");\r
-\r
-    OutLineInfo(output,q->line,FileStr[q->file]);\r
-       BLOCK_Preamble(q);\r
-       BlkLevel++;\r
-    BlockPreambleOption(q,q->pFirstSetSymbol); /* MR21 */\r
-       f = genBlk(q, aOptBlk, &max_k, &need_right_curly, &lastAltEmpty /* MR23 */);\r
-/* MR23\r
-   Bypass error clause generation when exceptions are used in {...} block \r
-   See multi-line note in genBlk near call to isEmptyAlt.\r
-*/\r
-       if (! FoundException) {\r
-           if ( q->p2 != NULL ) {tab(); makeErrorClause(q,f,max_k,0 /* use plus block bypass ? */ );}\r
-       }\r
-       else {\r
-               gen("/* MR23 skip error clause for {...} when exceptions in use */\n");\r
-       }\r
-       { int i; for (i=1; i<=need_right_curly; i++) {tabs--; gen("}\n");} }\r
-       freeBlkFsets(q);\r
-       --BlkLevel;\r
-       BLOCK_Tail();\r
-\r
-       if ( q->guess )\r
-       {\r
-               gen("zzGUESS_DONE\n");\r
-       }\r
-\r
-       /* must duplicate if (alpha)?; one guesses (validates), the\r
-        * second pass matches */\r
-       if ( q->guess && analysis_point(q)==q )\r
-       {\r
-        OutLineInfo(output,q->line,FileStr[q->file]);\r
-               BLOCK_Preamble(q);\r
-               BlkLevel++;\r
-               f = genBlk(q, aSubBlk, &max_k, &need_right_curly, &lastAltEmpty /* MR23 */);\r
-               if ( q->p2 != NULL ) {tab(); makeErrorClause(q,f,max_k,0 /* use plus block bypass ? */ );}\r
-               { int i; for (i=1; i<=need_right_curly; i++) {tabs--; gen("}\n");} }\r
-               freeBlkFsets(q);\r
-               --BlkLevel;\r
-               BLOCK_Tail();\r
-       }\r
-\r
-       tokensRefdInBlock = savetkref;\r
-       if (q->end->p1 != NULL) TRANS(q->end->p1);\r
-}\r
-\r
-/*\r
- * Generate code for a loop blk of form:\r
- *\r
- *                              |---|\r
- *                              v   |\r
- *                        --o-G-o-->o--\r
- */\r
-void\r
-#ifdef __USE_PROTOS\r
-genLoopBlk( Junction *begin, Junction *q, Junction *start, int max_k )\r
-#else\r
-genLoopBlk( begin, q, start, max_k )\r
-Junction *begin;\r
-Junction *q;\r
-Junction *start;       /* where to start generating code from */\r
-int max_k;\r
-#endif\r
-{\r
-       set         f;\r
-       int         need_right_curly;\r
-       set         savetkref;\r
-    Junction    *guessBlock;    /* MR10 */\r
-    int         singleAlt;      /* MR10 */\r
-       int                     lastAltEmpty;   /* MR23 */\r
-\r
-       savetkref = tokensRefdInBlock;\r
-       require(q->ntype == nJunction,  "genLoopBlk: not junction");\r
-       require(q->jtype == aLoopBlk,   "genLoopBlk: not loop block");\r
-\r
-       if ( q->visited ) return;\r
-       q->visited = TRUE;\r
-\r
-    /* first_item_is_guess_block doesn't care what kind of node it is */\r
-\r
-    guessBlock=first_item_is_guess_block( (Junction *) q->p1);  /* MR10 */\r
-    singleAlt=q->p2==NULL;                                      /* MR10 */\r
-\r
-       if (singleAlt && !guessBlock)       /* MR10 */ /* only one alternative? */\r
-       {\r
-               if ( DemandLookahead ) {\r
-                       if ( !GenCC ) {gen1("LOOK(%d);\n", max_k);}\r
-                       else gen1("look(%d);\n", max_k);\r
-               }\r
-               gen("while ( ");\r
-               if ( begin!=NULL ) genExpr(begin);\r
-               else genExpr(q);\r
-               /* if no predicates have been hoisted for this single alt (..)*\r
-                * do so now\r
-                */\r
-        require(MR_PredRuleRefStack.count == 0,"PredRuleRef stack not empty");\r
-               if ( ParseWithPredicates && begin->predicate==NULL )\r
-               {\r
-                       Predicate *a = MR_find_predicates_and_supp((Node *)q->p1);\r
-            require(MR_PredRuleRefStack.count == 0,"PredRuleRef stack not empty");\r
-\r
-                       if ( a!=NULL )\r
-                       {\r
-                               _gen("&&");\r
-                               a=genPredTreeMain(a, (Node *)q);    /* MR10 */\r
-                       }\r
-/* MR10 */  if (MRhoisting) {\r
-/* MR10 */    predicate_free(a);\r
-/* MR10 */  };\r
-               }\r
-               _gen(" ) {\n");\r
-               tabs++;\r
-               TRANS(q->p1);\r
-               if ( !GenCC ) gen1("zzLOOP(zztasp%d);\n", BlkLevel-1);\r
-               if ( DemandLookahead ) {\r
-                       if ( !GenCC ) {gen1("LOOK(%d);\n", max_k);}\r
-                       else gen1("look(%d);\n", max_k);\r
-               }\r
-               --tabs;\r
-               gen("}\n");\r
-               freeBlkFsets(q);\r
-               q->visited = FALSE;\r
-               tokensRefdInBlock = savetkref;\r
-               return;\r
-       }\r
-       gen("for (;;) {\n");        /* MR20 G. Hobbelt */\r
-       tabs++;\r
-/* MR6                                                                                 */\r
-/* MR6            "begin" can never be null when called from genLoopBegin      */\r
-/* MR6     because q==(Junction *)begin->p1 and we know q is valid     */\r
-/* MR6                                                                                         */\r
-/* MR6    from genLoopBegin:                                                           */\r
-/* MR6                                                                                             */\r
-/* MR6          if ( LL_k>1 && !set_nil(q->fset[2]) )                          */\r
-/* MR6            genLoopBlk( q, (Junction *)q->p1, q, max_k );            */\r
-/* MR6         else genLoopBlk( q, (Junction *)q->p1, NULL, max_k );   */\r
-/* MR6                                                                                         */\r
-       if ( begin!=NULL )\r
-       {\r
-               if ( DemandLookahead )\r
-               {\r
-                       if ( !GenCC ) {gen1("LOOK(%d);\n", max_k);}\r
-                       else gen1("look(%d);\n", max_k);\r
-               }\r
-               /* The bypass arc of the (...)* predicts what to do when you fail, but\r
-                * ONLY after having tested the loop start expression.  To avoid this,\r
-                * we simply break out of the (...)* loop when we find something that\r
-                * is not in the prediction of the loop (all alts thereof).\r
-                */\r
-               gen("if ( !(");\r
-\r
-/***   TJP says: It used to use the prediction expression for the bypass arc\r
-       of the (...)*.  HOWEVER, if a non LL^1(k) decision was found, this\r
-       thing would miss the ftree stored in the aLoopBegin node and generate\r
-       an LL^1(k) decision anyway.\r
-\r
- ***           genExpr((Junction *)begin->p2);\r
- ***/\r
-\r
-            genExpr((Junction *)begin);\r
-            _gen(")) break;\n");\r
-\r
-       }\r
-\r
-       /* generate code for terminating loop (this is optional branch) */\r
-\r
-       f = genBlk(q, aLoopBlk, &max_k, &need_right_curly, &lastAltEmpty /* MR23 */);\r
-       set_free(f);\r
-       freeBlkFsets(q);\r
-\r
-       /* generate code for terminating loop (this is optional branch) */\r
-\r
-/* MR6                                                                                                     */\r
-/* MR6  30-May-97 Bug reported by Manuel Ornato                                            */\r
-/* MR6            A definite bug involving the exit from a loop block   */\r
-/* MR6                   In 1.23 and later versions (including 1.33) Instead       */\r
-/* MR6              exiting the block and reporting a syntax error the  */\r
-/* MR6             code loops forever.                                                 */\r
-/* MR6           Looking at 1.20 which generates proper code it is not */\r
-/* MR6             clear which of two changes should be undone.            */\r
-/* MR6           This is my best guess.                                    */\r
-/* MR6           From earlier MR6 note we know that begin can never be     */\r
-/* MR6             null when genLoopBlk called from genLoopBegin           */\r
-/* MR6 */\r
-/* MR6 */ if ( begin==NULL) {\r
-/* MR6 */   /* code for exiting loop "for sure" */\r
-/* MR6 */   gen("/* Suppressed by MR6 */ /*** else break; ***/\n");\r
-/* MR6 */ };\r
-\r
-/* MR10 */if (singleAlt && guessBlock) {\r
-/* MR10 */  tabs--;\r
-/* MR6 */   gen("} else break; /* MR6 code for exiting loop \"for sure\" */\n");\r
-/* MR10 */  need_right_curly--;\r
-/* MR10 */ } else {\r
-/* MR6 */   gen("else break; /* MR6 code for exiting loop \"for sure\" */\n");\r
-/* MR10 */ };\r
-\r
-       { int i; for (i=1; i<=need_right_curly; i++) {tabs--; gen("}\n");} }\r
-       if ( !GenCC ) gen1("zzLOOP(zztasp%d);\n", BlkLevel-1);\r
-       --tabs;\r
-       gen("}\n");\r
-       q->visited = FALSE;\r
-       tokensRefdInBlock = savetkref;\r
-}\r
-\r
-/*\r
- * Generate code for a loop blk of form:\r
- *\r
- *                                      |---|\r
- *                                          v   |\r
- *                        --o-->o-->o-G-o-->o--\r
- *                   |           ^\r
- *                   v           |\r
- *                                      o-----------o\r
- *\r
- * q->end points to the last node (far right) in the blk.\r
- *\r
- * Note that q->end->jtype must be 'EndBlk'.\r
- *\r
- * Generate code roughly of the following form:\r
- *\r
- *     do {\r
- *             ... code for alternatives ...\r
- *  } while ( First Set of aLoopBlk );\r
- *\r
- *     OR if > 1 alternative\r
- *\r
- *     do {\r
- *             ... code for alternatives ...\r
- *             else break;\r
- *  } while ( 1 );\r
- */\r
-void\r
-#ifdef __USE_PROTOS\r
-genLoopBegin( Junction *q )\r
-#else\r
-genLoopBegin( q )\r
-Junction *q;\r
-#endif\r
-{\r
-       set f;\r
-       int i;\r
-       int max_k;\r
-       set savetkref;\r
-       savetkref = tokensRefdInBlock;\r
-       require(q!=NULL,                                "genLoopBegin: invalid node and/or rule");\r
-       require(q->ntype == nJunction,  "genLoopBegin: not junction");\r
-       require(q->jtype == aLoopBegin, "genLoopBegin: not loop block");\r
-       require(q->p2!=NULL,                    "genLoopBegin: invalid Loop Graph");\r
-\r
-    OutLineInfo(output,q->line,FileStr[q->file]);\r
-\r
-       BLOCK_Preamble(q);\r
-       BlkLevel++;\r
-    BlockPreambleOption(q,q->pFirstSetSymbol);       /* MR21 */\r
-       f = First(q, 1, aLoopBegin, &max_k);\r
-       /* If not simple LL(1), must specify to start at LoopBegin, not LoopBlk */\r
-       if ( LL_k>1 && !set_nil(q->fset[2]) )\r
-               genLoopBlk( q, (Junction *)q->p1, q, max_k );\r
-       else genLoopBlk( q, (Junction *)q->p1, NULL, max_k );\r
-\r
-       for (i=1; i<=CLL_k; i++) set_free(q->fset[i]);\r
-       for (i=1; i<=CLL_k; i++) set_free(((Junction *)q->p2)->fset[i]);\r
-       --BlkLevel;\r
-       BLOCK_Tail();\r
-       set_free(f);\r
-       tokensRefdInBlock = savetkref;\r
-/* MR21 */     if (MR_BlkErr) {\r
-/* MR21 */             set f, fArray[2];\r
-/* MR21 */             f = ComputeErrorSet(q,1,0 /* use plus block bypass ? */ );\r
-/* MR21 */      fArray[0]= empty;\r
-/* MR21 */             fArray[1]= set_dup(f);\r
-/* MR21 */      gen("if (");\r
-/* MR21 */      genExprSets(fArray,1);  /* note: destroys set arguments */\r
-/* MR21 */      _gen(") { /* MR21 option -mrblksynerr */\n");\r
-/* MR21 */      tabs++;\r
-/* MR21 */      tab();\r
-/* MR21 */      _gen("/* nothing */ }\n");\r
-/* MR21 */      tab();\r
-/* MR21 */      makeErrorClause(q,f,1,0 /* use plus block bypass ? */ );  /* frees set */\r
-/* MR21 */      tabs--;\r
-/* MR21 */     };\r
-       if (q->end->p1 != NULL) TRANS(q->end->p1);\r
-}\r
-\r
-/*\r
- * Generate code for a loop blk of form:\r
- *\r
- *                                      |---|\r
- *                                      v   |\r
- *                            --o-G-o-->o--\r
- *\r
- * q->end points to the last node (far right) in the blk.\r
- * Note that q->end->jtype must be 'EndBlk'.\r
- *\r
- * Generate code roughly of the following form:\r
- *\r
- *     do {\r
- *             ... code for alternatives ...\r
- *  } while ( First Set of aPlusBlk );\r
- *\r
- *     OR if > 1 alternative\r
- *\r
- *     do {\r
- *             ... code for alternatives ...\r
- *             else if not 1st time through, break;\r
- *  } while ( 1 );\r
- */\r
-void\r
-#ifdef __USE_PROTOS\r
-genPlusBlk( Junction *q )\r
-#else\r
-genPlusBlk( q )\r
-Junction *q;\r
-#endif\r
-{\r
-       int         max_k;\r
-       set         f;\r
-       int         need_right_curly;\r
-       int                     lastAltEmpty;   /* MR23 */\r
-       set         savetkref;\r
-    Junction    *guessBlock;    /* MR10 */\r
-    int         singleAlt;      /* MR10 */\r
-\r
-       savetkref = tokensRefdInBlock;\r
-       require(q!=NULL,                                "genPlusBlk: invalid node and/or rule");\r
-       require(q->ntype == nJunction,  "genPlusBlk: not junction");\r
-       require(q->jtype == aPlusBlk,   "genPlusBlk: not Plus block");\r
-       require(q->p2 != NULL,                  "genPlusBlk: not a valid Plus block");\r
-\r
-       if ( q->visited ) return;\r
-       q->visited = TRUE;\r
-    OutLineInfo(output,q->line,FileStr[q->file]);\r
-       BLOCK_Preamble(q);\r
-       BlkLevel++;\r
-\r
-    BlockPreambleOption((Junction *)q, q->pFirstSetSymbol);       /* MR21 */\r
-    \r
-    /* first_item_is_guess_block  doesn't care what kind of node it is */\r
-\r
-    guessBlock=first_item_is_guess_block( (Junction *)q->p1);   /* MR10 */\r
-\r
-       /* if the ignore flag is set on the 2nd alt and that alt is empty,\r
-        * then it is the implied optional alternative that we added for (...)+\r
-        * and, hence, only 1 alt.\r
-        */\r
-\r
-/* MR10  Reported by Pulkkinen Esa (esap@cs.tut.fi)\r
- *       Outer code for guess blocks ignored when there is only one alt\r
- *         for a (...)+ block.\r
- *       Force use of regular code rather than "optimized" code for that case\r
- */\r
-\r
-    singleAlt=( ( (Junction *) q->p2)->p2 == NULL) &&\r
-                 ( ( (Junction *) q->p2)->ignore );                    /* only one alternative? */\r
-\r
-    if (singleAlt && !guessBlock)   /* MR10 */\r
-       {\r
-\r
-               Predicate *a=NULL;\r
-               /* if the only alt has a semantic predicate, hoist it; must test before\r
-                * entering loop.\r
-                */\r
-               if ( ParseWithPredicates )\r
-               {\r
-            require(MR_PredRuleRefStack.count == 0,"PredRuleRef stack not empty");\r
-                       a = MR_find_predicates_and_supp((Node *)q);\r
-            require(MR_PredRuleRefStack.count == 0,"PredRuleRef stack not empty");\r
-\r
-                       if ( a!=NULL ) {\r
-                               gen("if (");\r
-                               a=genPredTreeMain(a, (Node *)q);    /* MR10 */\r
-                               _gen(") {\n");\r
-                       }\r
-               }\r
-               gen("do {\n");\r
-               tabs++;\r
-               TRANS(q->p1);\r
-               if ( !GenCC ) gen1("zzLOOP(zztasp%d);\n", BlkLevel-1);\r
-               f = First(q, 1, aPlusBlk, &max_k);\r
-               if ( DemandLookahead ) {\r
-                       if ( !GenCC ) {gen1("LOOK(%d);\n", max_k);}\r
-                       else gen1("look(%d);\n", max_k);\r
-               }\r
-               --tabs;\r
-               gen("} while ( ");\r
-               if ( q->parm!=NULL && q->predparm ) _gen1("(%s) && ", q->parm);\r
-               genExpr(q);\r
-               if ( ParseWithPredicates && a!=NULL )\r
-               {\r
-            if (! MR_comparePredicates(q->predicate,a)) {\r
-                       _gen("&&");\r
-                       a=genPredTreeMain(a, (Node *)q);    /* MR10 */\r
-            };\r
-               }\r
-               _gen(" );\n");\r
-               if ( ParseWithPredicates && a!=NULL ) gen("}\n");\r
-               --BlkLevel;\r
-               BLOCK_Tail();\r
-               q->visited = FALSE;\r
-               freeBlkFsets(q);\r
-               set_free(f);\r
-               tokensRefdInBlock = savetkref;\r
-/* MR21 */     if (MR_BlkErr) {\r
-/* MR21 */             set f, fArray[2];\r
-/* MR21 */             f = ComputeErrorSet(q,1,1 /* use plus block bypass ? */ );\r
-/* MR21 */      fArray[0]= empty;\r
-/* MR21 */             fArray[1]= set_dup(f);\r
-/* MR21 */      gen("if (");\r
-/* MR21 */      genExprSets(fArray,1);  /* note: destroys set arguments */\r
-/* MR21 */      _gen(") { /* MR21 option -mrblksynerr */\n");\r
-/* MR21 */      tabs++;\r
-/* MR21 */      tab();\r
-/* MR21 */      _gen("/* nothing */ }\n");\r
-/* MR21 */      tab();\r
-/* MR21 */      makeErrorClause(q,f,1,1 /* use plus block bypass ? */ );  /* frees set */\r
-/* MR21 */      tabs--;\r
-/* MR21 */     };\r
-               if (q->end->p1 != NULL) TRANS(q->end->p1);\r
-/* MR10 */  if (MRhoisting) {\r
-/* MR10 */    predicate_free(a);\r
-/* MR10 */  };\r
-               return;\r
-       }\r
-       gen("do {\n");\r
-       tabs++;\r
-       f = genBlk(q, aPlusBlk, &max_k, &need_right_curly, &lastAltEmpty /* MR23 */);\r
-/* MR6                                                                                         */\r
-/* MR6 Sinan Karasu    (sinan@tardis.ds.boeing.com)                    */\r
-/* MR6    Failed to turn off guess mode when leaving block             */\r
-/* MR6                                                                                         */\r
-/* MR6  */ if ( has_guess_block_as_last_item(q) ) {\r
-/* MR10 */   gen("/* MR10 ()+ */ else {\n");\r
-/* MR10 */   tabs++;\r
-/* MR10 */   need_right_curly++;\r
-/* MR10 */   gen("/* MR10 ()+ */ if ( !zzrv ) zzGUESS_DONE;\n");\r
-/* MR6  */   gen("/* MR10 ()+ */ if ( zzcnt > 1 ) break;\n");\r
-/* MR10 */ } else {\r
-/* MR10 */   gen("/* MR10 ()+ */ else {\n");\r
-/* MR10 */   tabs++;\r
-/* MR10 */   need_right_curly++;\r
-/* MR10 */   gen("if ( zzcnt > 1 ) break;\n");\r
-/* MR10 */ };\r
-\r
-/* MR21 */     if (MR_BlkErr && 1 >= max_k) {\r
-/* MR21 */             set f;\r
-/* MR21 */             f = ComputeErrorSet(q,1,0 /* use plus block bypass ? */ );\r
-/* MR21 */      tabs++;\r
-/* MR21 */      tab();\r
-/* MR21 */      makeErrorClause(q,f,1,0 /* use plus block bypass ? */ );  /* frees set */\r
-/* MR21 */      tabs--;\r
-/* MR21 */     }\r
-/* MR21 */  else {\r
-                               tab();\r
-                makeErrorClause(q,f,max_k,1 /* use plus block bypass ? */);\r
-                                                                                   /* MR21 I think this generates the wrong set ? */\r
-                                            /* MR21 because it includes the plus block bypass ? */\r
-                                                                                   /* MR21 but I'm afraid to change it without additional checking */\r
-            }\r
-\r
-       { int i; for (i=1; i<=need_right_curly; i++) {tabs--; gen("}\n");} }\r
-       freeBlkFsets(q);\r
-       gen("zzcnt++;");\r
-       if ( !GenCC ) _gen1(" zzLOOP(zztasp%d);", BlkLevel-1);\r
-       _gen("\n");\r
-       if ( DemandLookahead ) {\r
-               if ( !GenCC ) {gen1("LOOK(%d);\n", max_k);}\r
-               else gen1("look(%d);\n", max_k);\r
-       }\r
-       --tabs;\r
-       if ( q->parm!=NULL && q->predparm ) {gen1("} while (%s);\n", q->parm);}\r
-       else gen("} while ( 1 );\n");\r
-       --BlkLevel;\r
-       BLOCK_Tail();\r
-       q->visited = FALSE;\r
-       tokensRefdInBlock = savetkref;\r
-/* MR21 */     if (MR_BlkErr) {\r
-/* MR21 */             set f, fArray[2];\r
-/* MR21 */             f = ComputeErrorSet(q,1,1 /* use plus block bypass ? */ );\r
-/* MR21 */      fArray[0]= empty;\r
-/* MR21 */             fArray[1]= set_dup(f);\r
-/* MR21 */      gen("if (");\r
-/* MR21 */      genExprSets(fArray,1);  /* note: destroys set arguments */\r
-/* MR21 */      _gen(") { /* MR21 option -mrblksynerr */\n");\r
-/* MR21 */      tabs++;\r
-/* MR21 */      tab();\r
-/* MR21 */      _gen("/* nothing */ }\n");\r
-/* MR21 */      tab();\r
-/* MR21 */      makeErrorClause(q,f,1,1 /* use plus block bypass ? */ );  /* frees set */\r
-/* MR21 */      tabs--;\r
-/* MR21 */     };\r
-       if (q->end->p1 != NULL) TRANS(q->end->p1);\r
-}\r
-\r
-/*\r
- * Generate code for a sub blk of alternatives of form:\r
- *\r
- *                            --o-G1--o--\r
- *                                      |     ^\r
- *                                      v    /|\r
- *                              o-G2-o|\r
- *                                      |     ^\r
- *                                      v     |\r
- *                                ..........\r
- *                                      |     ^\r
- *                                      v    /\r
- *                              o-Gn-o\r
- *\r
- * q points to the 1st junction of blk (upper-left).\r
- * q->end points to the last node (far right) in the blk.\r
- * Note that q->end->jtype must be 'EndBlk'.\r
- * The last node in every alt points to q->end.\r
- *\r
- * Generate code of the following form:\r
- *     if ( First(G1) ) {\r
- *             ...code for G1...\r
- *     }\r
- *     else if ( First(G2) ) {\r
- *             ...code for G2...\r
- *     }\r
- *     ...\r
- *     else {\r
- *             ...code for Gn...\r
- *     }\r
- */\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-genSubBlk( Junction *q )\r
-#else\r
-genSubBlk( q )\r
-Junction *q;\r
-#endif\r
-{\r
-       int max_k;\r
-       set f;\r
-       int need_right_curly;\r
-       int lastAltEmpty;               /* MR23 */\r
-       set savetkref;\r
-       savetkref = tokensRefdInBlock;\r
-       require(q->ntype == nJunction,  "genSubBlk: not junction");\r
-       require(q->jtype == aSubBlk,    "genSubBlk: not subblock");\r
-\r
-    OutLineInfo(output,q->line,FileStr[q->file]);\r
-       BLOCK_Preamble(q);\r
-       BlkLevel++;\r
-    BlockPreambleOption(q,q->pFirstSetSymbol);       /* MR21 */\r
-       f = genBlk(q, aSubBlk, &max_k, &need_right_curly, &lastAltEmpty /* MR23 */);\r
-\r
-/* MR23\r
-   Bypass error clause generation when exceptions are used in a sub block\r
-   in which the last alternative is epsilon.  Example: "(A | B | )". \r
-   See multi-line note in genBlk near call to isEmptyAlt.\r
-*/\r
-       if (FoundException && lastAltEmpty) {\r
-               gen("/* MR23 skip error clause for (...| epsilon) when exceptions in use */\n");\r
-       }\r
-       else {\r
-               if ( q->p2 != NULL ) {tab(); makeErrorClause(q,f,max_k,0 /* use plus block bypass ? */ );}\r
-       }\r
-    \r
-       { int i; for (i=1; i<=need_right_curly; i++) {tabs--; gen("}\n");} }\r
-       freeBlkFsets(q);\r
-       --BlkLevel;\r
-       BLOCK_Tail();\r
-\r
-       if ( q->guess )\r
-       {\r
-               gen("zzGUESS_DONE\n");\r
-       }\r
-\r
-       /* must duplicate if (alpha)?; one guesses (validates), the\r
-        * second pass matches */\r
-       if ( q->guess && analysis_point(q)==q )\r
-       {\r
-        OutLineInfo(output,q->line,FileStr[q->file]);\r
-               BLOCK_Preamble(q);\r
-               BlkLevel++;\r
-               f = genBlk(q, aSubBlk, &max_k, &need_right_curly, &lastAltEmpty /* MR23 */);\r
-               if ( q->p2 != NULL ) {tab(); makeErrorClause(q,f,max_k,0 /* use plus block bypass ? */);}\r
-               { int i; for (i=1; i<=need_right_curly; i++) {tabs--; gen("}\n");} }\r
-               freeBlkFsets(q);\r
-               --BlkLevel;\r
-               BLOCK_Tail();\r
-       }\r
-\r
-       tokensRefdInBlock = savetkref;\r
-       if (q->end->p1 != NULL) TRANS(q->end->p1);\r
-}\r
-\r
-static int TnodesAllocatedPrevRule=0;\r
-\r
-/*\r
- * Generate code for a rule.\r
- *\r
- *             rule--> o-->o-Alternatives-o-->o\r
- * Or,\r
- *             rule--> o-->o-Alternative-o-->o\r
- *\r
- * The 1st junction is a RuleBlk.  The second can be a SubBlk or just a junction\r
- * (one alternative--no block), the last is EndRule.\r
- * The second to last is EndBlk if more than one alternative exists in the rule.\r
- *\r
- * To get to the init-action for a rule, we must bypass the RuleBlk,\r
- * and possible SubBlk.\r
- * Mark any init-action as generated so genBlk() does not regenerate it.\r
- */\r
-void\r
-#ifdef __USE_PROTOS\r
-genRule( Junction *q )\r
-#else\r
-genRule( q )\r
-Junction *q;\r
-#endif\r
-{\r
-\r
-       const char * returnValueInitializer;\r
-\r
-do {    /* MR10     Change recursion into iteration         */\r
-\r
-       int max_k;\r
-       set follow, rk, f;\r
-       ActionNode *a;\r
-       RuleEntry *r;\r
-       int lastAltEmpty;               /* MR23 */\r
-       static int file = -1;\r
-       int need_right_curly;\r
-       require(q->ntype == nJunction,  "genRule: not junction");\r
-       require(q->jtype == RuleBlk,    "genRule: not rule");\r
-\r
-/* MR14 */    require (MR_BackTraceStack.count == 0,"-alpha MR_BackTraceStack.count != 0");\r
-/* MR14 */    MR_pointerStackReset(&MR_BackTraceStack);\r
-/* MR14 */    if (AlphaBetaTrace) MR_MaintainBackTrace=1;\r
-\r
-    CurRule=q->rname;                               /* MR11 */\r
-\r
-       r = (RuleEntry *) hash_get(Rname, q->rname);\r
-       if ( r == NULL ) warnNoFL("Rule hash table is screwed up beyond belief");\r
-       if ( q->file != file )          /* open new output file if need to */\r
-       {\r
-/* MR6                                                                                 */\r
-/* MR6  Simpler to debug when output goes to stdout rather than a file         */\r
-/* MR6                                                                                 */\r
-/* MR6 */      if (UseStdout) {\r
-/* MR6 */        output = stdout;\r
-/* MR6 */      } else {\r
-/* MR6 */        if ( output != NULL) fclose( output );\r
-/* MR6 */        output = fopen(OutMetaName(outname(FileStr[q->file])), "w");\r
-/* MR6 */      };\r
-               require(output != NULL, "genRule: can't open output file");\r
-\r
-#ifdef SPECIAL_FOPEN\r
-       special_fopen_actions(OutMetaName(outname(FileStr[q->file]))); /* MR1 */\r
-#endif\r
-               if ( file == -1 ) genHdr1(q->file);\r
-               else genHdr(q->file);\r
-               file = q->file;\r
-       }\r
-\r
-    if (InfoM) {\r
-      fprintf(stderr,"    rule %s\n",q->rname);\r
-      fflush(output);\r
-    };\r
-\r
-#if 0\r
-    if (strcmp(q->rname,"***debug***") == 0) {\r
-      fprintf(stderr,"***debug*** %s reached\n",q->rname);\r
-      MR_break();\r
-    };\r
-#endif\r
-\r
-       DumpFuncHeader(q,r);\r
-       tabs++;\r
-\r
-       /* MR23 \r
-          \r
-          If there is a single return value then it can be initialized in \r
-          the declaration using assignment syntax.  If there are multiple\r
-          return values then antlr creates a struct and initialization takes\r
-          place element by element for each element of the struct.  For\r
-       multiple elements the initialization is by assignment so we have\r
-       to wait until all declarations are done before emitting that code -\r
-       because of restrictions in C which don't exist in C++.\r
-\r
-       In the past (before MR23) the only kind of initialization was\r
-          the PURIFY macro which was just a memset() of 0.  Now we allow\r
-          the user to specify an initial value.  PURIFY is still used in C\r
-          mode because C does not have constructors.  However, PURIFY is\r
-          not used in C++ mode because it might overwrite information created\r
-          by elements which have their own ctor.\r
-       \r
-       */\r
-\r
-       if ( q->ret!=NULL )\r
-       {\r
-               if ( hasMultipleOperands(q->ret) )                         /* MR23 */\r
-               {\r
-\r
-            /* Emit initialization code later. */\r
-\r
-                       gen1("struct _rv%d _retv;\n",r->rulenum);\r
-               }\r
-               else\r
-               {\r
-            /* Emit initialization code now. */\r
-\r
-                       tab();\r
-                       DumpType(q->ret, output);\r
-            returnValueInitializer = getInitializer(q->ret);\r
-            if (returnValueInitializer == NULL) {                  /* MR23 */\r
-                       gen(" _retv;\n");                                   /* MR1 MR3 */\r
-            }                                                      /* MR23 */\r
-            else {                                                 /* MR23 */\r
-                gen1(" _retv = %s;\n", returnValueInitializer);    /* MR23 */\r
-            }                                                      /* MR23 */\r
-               }\r
-       }\r
-\r
-    OutLineInfo(output,q->line,FileStr[q->file]);\r
-\r
-    if (InfoM) {\r
-      fflush(output);\r
-    };\r
-\r
-       gen("zzRULE;\n");\r
-       if ( FoundException )\r
-       {\r
-               gen("int _sva=1;\n");\r
-       }\r
-       if ( GenCC && GenAST )\r
-               gen("ASTBase *_ast = NULL, *_sibling = NULL, *_tail = NULL;\n");\r
-       if ( GenCC ) genTokenPointers(q);\r
-       if ( GenCC&&GenAST ) genASTPointers(q);\r
-       if ( q->el_labels!=NULL ) genElementLabels(q->el_labels);\r
-       if ( FoundException ) gen("int _signal=NoSignal;\n");\r
-\r
-       if ( !GenCC ) gen1("zzBLOCK(zztasp%d);\n", BlkLevel);\r
-\r
-/* MR10 */  /* move zzTRACEIN to before init action */\r
-\r
-/* MR10 */     if ( TraceGen ) {\r
-/* MR10 */             if ( GenCC ) {gen1("zzTRACEIN(\"%s\");\n", q->rname);}\r
-/* MR10 */             else gen1("zzTRACEIN((ANTLRChar *)\"%s\");\n", q->rname);\r
-/* MR10 */     }\r
-\r
-/* MR7      Moved PURIFY() to after all local variables have been declared */\r
-/* MR7      so that the generated code is valid C as well as C++           */\r
-/* MR7        Jan Mikkelsen 10-June-1997                                   */\r
-\r
-\r
-     /*\r
-       MR23    Do the PURIFY macro only for C mode.\r
-               C++ users should use constructors or initialization expressions.\r
-     */\r
-\r
-       if ( q->ret != NULL )                                            /* MR7 */\r
-       {                                                                /* MR7 */\r
-               if (hasMultipleOperands(q->ret)) {                           /* MR23 */\r
-                       if (PURIFY == TRUE) {\r
-                gen1("PCCTS_PURIFY(_retv,sizeof(struct _rv%d))\n",r->rulenum); /* MR23 */\r
-            }\r
-        }                                                            /* MR7 */\r
-               else {                                                       /* MR7 */\r
-\r
-                       /* MR23\r
-                          If there were only one return value operand and\r
-                          it had an initializer then it would have been\r
-                          initiailized in the declaration.\r
-                       */\r
-\r
-                       returnValueInitializer = getInitializer(q->ret);         /* MR23 */\r
-                       if (returnValueInitializer == NULL) {                    /* MR23 */\r
-                       if (PURIFY == TRUE) {\r
-                               gen("PCCTS_PURIFY(_retv,sizeof(");               /* MR23 */\r
-                               DumpType(q->ret, output);                        /* MR7 */\r
-                                       gen("))\n");                                     /* MR7 */\r
-                               }\r
-                       }                                                        /* MR23 */\r
-               }                                                            /* MR7 */\r
-\r
-        if (hasMultipleOperands(q->ret)) {                           /* MR23 */\r
-          DumpInitializers(output, r, q->ret);                       /* MR23 */\r
-        }\r
-\r
-       }\r
-       if ( !GenCC ) gen("zzMake0;\n");\r
-       if ( FoundException ) gen("*_retsignal = NoSignal;\n");\r
-\r
-       if ( !GenCC ) gen("{\n");\r
-\r
-       if ( has_guess_block_as_first_item((Junction *)q->p1) )\r
-       {\r
-               gen("zzGUESS_BLOCK\n");\r
-       }\r
-\r
-       /* L o o k  F o r  I n i t  A c t i o n */\r
-       if ( ((Junction *)q->p1)->jtype == aSubBlk )\r
-               a = findImmedAction( ((Junction *)q->p1)->p1 );\r
-       else\r
-               a = findImmedAction( q->p1 );   /* only one alternative in rule */\r
-       if ( a!=NULL && !a->is_predicate)\r
-       {\r
- /* MR21 */ if (!a->noHoist) dumpActionPlus(a, a->action, output, tabs, a->file, a->line, 1);\r
-                   a->done = 1;        /* ignore action. We have already handled it */\r
-       }\r
-\r
-       BlkLevel++;\r
-       q->visited = TRUE;                              /* mark RULE as visited for FIRST/FOLLOW */\r
-    BlockPreambleOption((Junction *)q->p1, NULL);   /* MR21 */\r
-       f = genBlk((Junction *)q->p1, RuleBlk, &max_k, &need_right_curly, &lastAltEmpty /* MR23 */);\r
-       if ( q->p1 != NULL )\r
-               if ( ((Junction *)q->p1)->p2 != NULL )\r
-                       {tab(); makeErrorClause((Junction *)q->p1,f,max_k,0 /* use plus block bypass ? */);}\r
-       { int i; for (i=1; i<=need_right_curly; i++) {tabs--; gen("}\n");} }\r
-       freeBlkFsets((Junction *)q->p1);\r
-       q->visited = FALSE;\r
-       --BlkLevel;\r
-       if ( !GenCC ) gen1("zzEXIT(zztasp%d);\n", BlkLevel);\r
-\r
-    genTraceOut(q);\r
-\r
-       if ( q->ret!=NULL ) gen("return _retv;\n") else gen("return;\n");\r
-       /* E r r o r  R e c o v e r y */\r
-       NewSet();\r
-       rk = empty;\r
-\r
-/* MR14 */    if (r->dontComputeErrorSet) {\r
-/* MR14 */      follow=empty;\r
-              } else {\r
-                MR_pointerStackReset(&MR_BackTraceStack);   /* MR14 */\r
-                MR_ErrorSetComputationActive=1;\r
-                REACH(q->end, 1, &rk, follow);\r
-                MR_ErrorSetComputationActive=0;\r
-                require (MR_BackTraceStack.count == 0,"K: MR_BackTraceStack.count != 0");\r
-              }\r
-\r
-  FillSet( follow );\r
-       set_free( follow );\r
-\r
-  /* MR20 G. Hobbelt \r
-     Isn't it so that "fail:" is ONLY referenced when:\r
-\r
-        !FoundException || FoundGuessBlk ?\r
-\r
-     Therefore add the "if" around this piece of code generation...\r
-\r
-     Should guessing mode also use _handler label instead of "fail"\r
-     when exception handling is active? gen can automatically put \r
-     "if (guessing)" there so as to skip all kinds of user code.\r
-\r
-   */\r
-\r
-       if ( !FoundException || FoundGuessBlk )  /* MR20 G. Hobbelt */\r
-  {                                          /* MR20 G. Hobbelt */\r
-       _gen("fail:\n");\r
-       if ( !GenCC ) gen("zzEXIT(zztasp1);\n");\r
-       if ( FoundGuessBlk ) {\r
-               if ( !GenCC ) {gen("if ( zzguessing ) zzGUESS_FAIL;\n");}\r
-               else gen("if ( guessing ) zzGUESS_FAIL;\n");\r
-       }\r
-       if ( q->erraction!=NULL )\r
-               dumpAction(q->erraction, output, tabs, q->file, q->line, 1);\r
-       if ( GenCC )\r
-       {\r
-               gen1("syn(zzBadTok, %s, zzMissSet, zzMissTok, zzErrk);\n",\r
-                        r->egroup==NULL?"(ANTLRChar *)\"\"":r->egroup);\r
-       }\r
-       else\r
-       {\r
-               gen1("zzsyn(zzMissText, zzBadTok, %s, zzMissSet, zzMissTok, zzErrk, zzBadText);\n",\r
-                        r->egroup==NULL?"(ANTLRChar *)\"\"":r->egroup);\r
-       }\r
-       gen3("%sresynch(setwd%d, 0x%x);\n", GenCC?"":"zz", wordnum, 1<<setnum);\r
-\r
-       if ( q->ret!=NULL ) {\r
-      genTraceOut(q);\r
-      gen("return _retv;\n");\r
-    } else if ( q->exceptions!=NULL ) {\r
-      genTraceOut(q);\r
-      gen("return;\n");\r
-    } else if (!FoundException) {       /* MR10 */\r
-      genTraceOut(q);                   /* MR10 */\r
-    };\r
-\r
-  }                                        /* MR20 G. Hobbelt */\r
-\r
-       if ( !GenCC ) gen("}\n");\r
-\r
-       /* Gen code for exception handlers */\r
-    /* make sure each path out contains genTraceOut() */\r
-\r
-       if ( q->exceptions!=NULL )\r
-       {\r
-\r
-               gen("/* exception handlers */\n");\r
-\r
-               dumpExceptions(q->exceptions);\r
-\r
-        if ( !r->has_rule_exception )\r
-        {\r
-            _gen("_handler:\n");\r
-            gen("zzdflthandlers(_signal,_retsignal);\n");\r
-        }\r
-/*  MR20 G. Gobbelt   The label "adios" is never referenced */\r
-\r
-#if 0\r
-       _gen("_adios:\n");\r
-#endif\r
-    if ( q->ret!=NULL ) {\r
-            genTraceOut(q);\r
-            gen("return _retv;\n");\r
-        }\r
-               else {\r
-            genTraceOut(q);\r
-            gen("return;\n");\r
-        }\r
-       }\r
-       else if ( FoundException )\r
-       {\r
-      _gen("_handler:\n");\r
-      gen("zzdflthandlers(_signal,_retsignal);\n");\r
-\r
-/* MR1                                                                      */\r
-/* MR1  7-Apr-97 Fix suggested by: John Bair (jbair@iftime.com)            */\r
-/* MR1                                                                                             */\r
-\r
-         if ( q->ret != NULL) {                                                     /* MR1 */\r
-            genTraceOut(q);                                          /* MR10 */\r
-            gen("return _retv;\n");                                             /* MR1 */\r
-      } else {                                                                      /* MR1 */\r
-            genTraceOut(q);                                          /* MR10 */\r
-            gen("return;\n")    ;                                                   /* MR1 */\r
-      };                                                                                    /* MR1 */\r
-       }\r
-\r
-       tabs--;\r
-       gen("}\n");\r
-\r
-/* MR10     Tired of looking at stacks that are as deep as the number of    */\r
-/* MR10       rules.  Changes recursion to iteration.                       */\r
-\r
-    MR_releaseResourcesUsedInRule( (Node *) q );      /* MR10 */\r
-\r
-    if (InfoT) {\r
-      fprintf(output,"\n/* tnodes created for rule %s:  %d */\n",\r
-                q->rname, (TnodesAllocated-TnodesAllocatedPrevRule) );\r
-    };\r
-\r
-    TnodesAllocatedPrevRule=TnodesAllocated;\r
-\r
-    if (q->p2 == NULL) dumpAfterActions( output );\r
-    q=(Junction *)q->p2;\r
-    require(q==NULL || q->jtype==RuleBlk,"RuleBlk p2 does not point to another RuleBlk");\r
-\r
-} while (q != NULL);\r
-\r
-/**** The old code                           ****/\r
-/****  if ( q->p2 != NULL ) {TRANS(q->p2);} ****/ /* generate code for next rule too */\r
-/****  else dumpAfterActions( output );     ****/\r
-\r
-}\r
-\r
-\r
-/* This is for the function definition, not the declaration. */\r
-\r
-static void\r
-#ifdef __USE_PROTOS\r
-DumpFuncHeader( Junction *q, RuleEntry *r )\r
-#else\r
-DumpFuncHeader( q, r )\r
-Junction *q;\r
-RuleEntry *r;\r
-#endif\r
-{\r
-/*                                                                                                         */\r
-/*  MR1 10-Apr-97  MR1  Simplify insertion of commas in function header     */\r
-/*                                                                                                         */\r
-       int     needComma;                                                                       /* MR1 */\r
-\r
-\r
-       /* A N S I */\r
-       _gen("\n");\r
-       if ( q->ret!=NULL )\r
-       {\r
-               if ( hasMultipleOperands(q->ret) )                            /* MR23 */\r
-               {\r
-                       if (GenCC) gen2("%s::_rv%d\n", CurrentClassName, r->rulenum)\r
-                       else gen1("struct _rv%d\n",r->rulenum);\r
-               }\r
-               else\r
-               {\r
-                       DumpType(q->ret, output);\r
-                       gen("\n");\r
-               }\r
-       }\r
-       else\r
-       {\r
-               _gen("void\n");\r
-       }\r
-/*  MR1                                                                                    */\r
-/*  MR1        10-Apr-97  133MR1       Replace __STDC__ with __USE_PROTOS              */\r
-/*  MR1                                                                                                        */\r
-       if ( !GenCC ) _gen("#ifdef __USE_PROTOS\n");                 /* MR1 */\r
-       if ( !GenCC ) gen2("%s%s(", RulePrefix, q->rname)\r
-       else gen3("%s::%s%s(", CurrentClassName, RulePrefix,q->rname);\r
-\r
-       /* If we generate C++ method names, we must hide default arguments */\r
-        /* which can appear in the parameter declaration list.             */\r
-        /* NOTICE: this is done only here, for the method definition, but  */\r
-        /*         not for the method declaration inside the class         */\r
-        /*         definition. This is exactly the behaviour defined in    */\r
-        /*         C++ standard for default paramters.                     */\r
-\r
-       DumpANSIFunctionArgDef(output,q, 0 /* emit initializers ? */);\r
-       _gen("\n");\r
-\r
-       if ( GenCC ) {\r
-      gen("{\n");\r
-      return;\r
-    }\r
-\r
-       /* K & R */\r
-       gen("#else\n");\r
-       gen2("%s%s(", RulePrefix, q->rname);\r
-       needComma=0;                                                                         /* MR1 */\r
-       if ( GenAST )                                                                        /* MR1 */\r
-       {                                                                                            /* MR1 */\r
-               _gen("_root");                                                               /* MR1 */\r
-               needComma=1;                                                                 /* MR1 */\r
-       }                                                                                            /* MR1 */\r
-       if ( FoundException )                                                            /* MR1 */\r
-       {                                                                                            /* MR1 */\r
-               if (needComma) {_gen(",");needComma=0;};                         /* MR1 */\r
-               _gen("_retsignal");                                                          /* MR1 */\r
-               needComma=1;                                                                 /* MR1 */\r
-       }                                                                                            /* MR1 */\r
-/* MR5 Change below by Jan Mikkelsen (janm@zeta.org.au) 26-May-97      MR5 */\r
-       DumpListOfParmNames( q->pdecl, output, needComma );                  /* MR5 */\r
-       gen(")\n");\r
-       if ( GenAST ) gen("AST **_root;\n");\r
-       if ( FoundException ) gen("int *_retsignal;\n");\r
-       DumpOldStyleParms( q->pdecl, output );\r
-       gen("#endif\n");\r
-    gen("{\n");\r
-}\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-DumpANSIFunctionArgDef(FILE *f, Junction *q, int bInitializer)\r
-#else\r
-DumpANSIFunctionArgDef(f,q,bInitializer)\r
-FILE *f;\r
-Junction *q;\r
-int bInitializer;\r
-#endif\r
-{\r
-       if ( GenAST )\r
-       {\r
-               if ( GenCC ) {fprintf(f,"ASTBase **_root");}\r
-               else fprintf(f,"AST**_root");\r
-               if ( !FoundException && q->pdecl!=NULL ) fprintf(f,",");\r
-       }\r
-       if ( FoundException )\r
-       {\r
-               if ( GenAST ) fprintf(f,",");\r
-               fprintf(f,"int *_retsignal");\r
-               if ( q->pdecl!=NULL ) {\r
-            fprintf(f,",");\r
-        }\r
-       }\r
-       if ( q->pdecl!=NULL ) {\r
-        DumpFormals(f, q->pdecl, bInitializer);     /* MR23 */\r
-    }\r
-       else {\r
-        if ( !GenAST && !FoundException ) {\r
-            fprintf(f,"void");\r
-        }\r
-    }\r
-       fprintf(f,")");\r
-}\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-genJunction( Junction *q )\r
-#else\r
-genJunction( q )\r
-Junction *q;\r
-#endif\r
-{\r
-       require(q->ntype == nJunction,  "genJunction: not junction");\r
-       require(q->jtype == Generic,    "genJunction: not generic junction");\r
-\r
-       if ( q->p1 != NULL ) TRANS(q->p1);\r
-       if ( q->p2 != NULL ) TRANS(q->p2);\r
-}\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-genEndBlk( Junction *q )\r
-#else\r
-genEndBlk( q )\r
-Junction *q;\r
-#endif\r
-{\r
-}\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-genEndRule( Junction *q )\r
-#else\r
-genEndRule( q )\r
-Junction *q;\r
-#endif\r
-{\r
-}\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-genHdr( int file )\r
-#else\r
-genHdr( file )\r
-int file;\r
-#endif\r
-{\r
-    int     i;\r
-\r
-       _gen("/*\n");\r
-       _gen(" * A n t l r  T r a n s l a t i o n  H e a d e r\n");\r
-       _gen(" *\n");\r
-       _gen(" * Terence Parr, Will Cohen, and Hank Dietz: 1989-2001\n");\r
-       _gen(" * Purdue University Electrical Engineering\n");\r
-       _gen(" * With AHPCRC, University of Minnesota\n");\r
-       _gen1(" * ANTLR Version %s\n", Version);\r
-       _gen(" *\n");\r
-/* MR10 */    _gen(" *  ");\r
-/* MR10 */    for (i=0 ; i < Save_argc ; i++) {\r
-/* MR10 */      _gen(" ");\r
-/* MR10 */      _gen(Save_argv[i]);\r
-/* MR10 */    };\r
-       _gen("\n");\r
-       _gen(" *\n");\r
-    _gen(" */\n\n");\r
-       if (FirstAction != NULL ) dumpAction( FirstAction, output, 0, -1, 0, 1);    /* MR11 MR15b */\r
-       _gen1("#define ANTLR_VERSION    %s\n", VersionDef);\r
-       _gen("#include \"pcctscfg.h\"\n");\r
-       _gen("#include \"pccts_stdio.h\"\n");\r
-       if ( strcmp(ParserName, DefaultParserName)!=0 )\r
-               _gen2("#define %s %s\n", DefaultParserName, ParserName);\r
-       if ( strcmp(ParserName, DefaultParserName)!=0 )\r
-               {_gen1("#include \"%s\"\n", RemapFileName);}\r
-    OutLineInfo(output,1,FileStr[file]);\r
-       if ( GenCC ) {\r
-               if ( UserTokenDefsFile != NULL )\r
-                       fprintf(output, "#include %s\n", UserTokenDefsFile);\r
-               else\r
-                       fprintf(output, "#include \"%s\"\n", DefFileName);\r
-       }\r
-\r
-       if ( HdrAction != NULL ) dumpAction( HdrAction, output, 0, -1, 0, 1);\r
-       if ( !GenCC && FoundGuessBlk )\r
-       {\r
-               _gen("#define ZZCAN_GUESS\n");\r
-               _gen("#include \"pccts_setjmp.h\"\n");  /* MR15 K.J. Cummings (cummings@peritus.com) */\r
-       }\r
-       if ( FoundException )\r
-       {\r
-               _gen("#define EXCEPTION_HANDLING\n");\r
-               _gen1("#define NUM_SIGNALS %d\n", NumSignals);\r
-       }\r
-       if ( !GenCC && OutputLL_k > 1 ) _gen1("#define LL_K %d\n", OutputLL_k);\r
-       if ( GenAST&&!GenCC ) _gen("#define GENAST\n\n");\r
-       if ( GenAST ) {\r
-               if ( GenCC ) {_gen1("#include \"%s\"\n\n", ASTBASE_H);}\r
-               else _gen("#include \"ast.h\"\n\n");\r
-       }\r
-       if ( !GenCC && DemandLookahead ) _gen("#define DEMAND_LOOK\n\n");\r
-#ifdef DUM\r
-       if ( !GenCC && LexGen ) {\r
-               _gen1("#define zzEOF_TOKEN %d\n", (TokenInd!=NULL?TokenInd[EofToken]:EofToken));\r
-       }\r
-#endif\r
-       /* ###WARNING: This will have to change when SetWordSize changes */\r
-       if ( !GenCC ) _gen1("#define zzSET_SIZE %d\n", NumWords(TokenNum-1)*sizeof(unsigned));\r
-    if (TraceGen) {\r
-      _gen("#ifndef zzTRACE_RULES\n");  /* MR20 */\r
-      _gen("#define zzTRACE_RULES\n");  /* MR20 */\r
-      _gen("#endif\n");                 /* MR22 */\r
-    };\r
-       if ( !GenCC ) {_gen("#include \"antlr.h\"\n");}\r
-       else {\r
-               _gen1("#include \"%s\"\n", APARSER_H);\r
-               _gen1("#include \"%s.h\"\n", CurrentClassName);\r
-       }\r
-       if ( !GenCC ) {\r
-               if ( UserDefdTokens )\r
-                       {_gen1("#include %s\n", UserTokenDefsFile);}\r
-               /* still need this one as it has the func prototypes */\r
-               _gen1("#include \"%s\"\n", DefFileName);\r
-       }\r
-       /* still need this one as it defines the DLG interface */\r
-       if ( !GenCC ) _gen("#include \"dlgdef.h\"\n");\r
-       if ( LexGen && GenCC ) _gen1("#include \"%s\"\n", DLEXERBASE_H);\r
-       if ( GenCC ) _gen1("#include \"%s\"\n", ATOKPTR_H);\r
-       if ( !GenCC && LexGen ) _gen1("#include \"%s\"\n", ModeFileName);\r
-\r
-/* MR10  Ofer Ben-Ami (gremlin@cs.huji.ac.il)           */\r
-/* MR10    Finally, a definition of the Purify macro    */\r
-\r
-    if (PURIFY == TRUE) {                                                   /* MR23 */\r
-        _gen("\n/* MR23 In order to remove calls to PURIFY use the antlr"); /* MR23 */\r
-        _gen(" -nopurify option */\n\n");                                   /* MR23 */\r
-       _gen("#ifndef PCCTS_PURIFY\n");\r
-        _gen("#define PCCTS_PURIFY(r,s) memset((char *) &(r),'\\0',(s));\n");\r
-        _gen("#endif\n\n");\r
-    }                                                                       /* MR23 */\r
-}\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-genHdr1( int file )\r
-#else\r
-genHdr1( file )\r
-int file;\r
-#endif\r
-{\r
-       ListNode *p;\r
-\r
-       genHdr(file);\r
-       if ( GenAST )\r
-       {\r
-               if ( !GenCC ) {\r
-                       _gen("#include \"ast.c\"\n");\r
-                       _gen("zzASTgvars\n\n");\r
-               }\r
-       }\r
-       if ( !GenCC ) _gen("ANTLR_INFO\n");\r
-       if ( BeforeActions != NULL )\r
-       {\r
-               for (p = BeforeActions->next; p!=NULL; p=p->next)\r
-               {\r
-                       UserAction *ua = (UserAction *)p->elem;\r
-                       dumpAction( ua->action, output, 0, ua->file, ua->line, 1);\r
-               }\r
-       }\r
-\r
-       if ( !FoundException ) return;\r
-\r
-       if ( GenCC )\r
-       {\r
-               _gen1("\nvoid %s::\n", CurrentClassName);\r
-               _gen("zzdflthandlers( int _signal, int *_retsignal )\n");\r
-               _gen("{\n");\r
-       }\r
-       else\r
-       {\r
-               _gen("\nvoid\n");\r
-/*  MR1                                                                                        */\r
-/*  MR1        10-Apr-97  133MR1       Replace __STDC__ with __USE_PROTOS              */\r
-/*  MR1                                                                            */\r
-           _gen("#ifdef __USE_PROTOS\n");                               /* MR1 */\r
-               _gen("zzdflthandlers( int _signal, int *_retsignal )\n");\r
-               _gen("#else\n");\r
-               _gen("zzdflthandlers( _signal, _retsignal )\n");\r
-               _gen("int _signal;\n");\r
-               _gen("int *_retsignal;\n");\r
-               _gen("#endif\n");\r
-               _gen("{\n");\r
-       }\r
-       tabs++;\r
-       if ( DefaultExGroup!=NULL )\r
-       {\r
-               dumpException(DefaultExGroup, 1);\r
-               if ( !hasDefaultException(DefaultExGroup) )\r
-               {\r
-                       gen("default :\n");\r
-                       tabs++;\r
-                       gen("*_retsignal = _signal;\n");\r
-                       tabs--;\r
-                       gen("}\n");\r
-               }\r
-       }\r
-       else {\r
-               gen("*_retsignal = _signal;\n");\r
-       }\r
-\r
-       tabs--;\r
-       _gen("}\n\n");\r
-}\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-genStdPCCTSIncludeFile( FILE *f,char *gate )    /* MR10 */\r
-#else\r
-genStdPCCTSIncludeFile( f , gate)               /* MR10 */\r
-FILE *f;\r
-char * gate;                                    /* MR10 */\r
-#endif\r
-{\r
-/* MR10 Ramanathan Santhanam (ps@kumaran.com)           */\r
-/* MR10 Same preprocessor symbol use to gate stdpccts.h */\r
-/* MR10   even when two grammars are in use.            */\r
-/* MR10 Derive gate symbol from -fh filename            */\r
-\r
-    if (gate == NULL) {\r
-      fprintf(f,"#ifndef STDPCCTS_H\n");          /* MR10 */\r
-      fprintf(f,"#define STDPCCTS_H\n");          /* MR10 */\r
-    } else {\r
-      fprintf(f,"#ifndef STDPCCTS_%s_H\n",gate);  /* MR10 */\r
-      fprintf(f,"#define STDPCCTS_%s_H\n",gate);  /* MR10 */\r
-    };\r
-       fprintf(f,"/*\n");\r
-    if (gate == NULL) {\r
-         fprintf(f," * %s -- P C C T S  I n c l u d e\n", stdpccts);\r
-    } else {\r
-         fprintf(f," * Standard PCCTS include file with -fh %s -- P C C T S  I n c l u d e\n", stdpccts);\r
-    }\r
-       fprintf(f," *\n");\r
-       fprintf(f," * Terence Parr, Will Cohen, and Hank Dietz: 1989-2001\n");\r
-       fprintf(f," * Purdue University Electrical Engineering\n");\r
-       fprintf(f," * With AHPCRC, University of Minnesota\n");\r
-       fprintf(f," * ANTLR Version %s\n", Version);\r
-       fprintf(f," */\n\n");\r
-\r
-    fprintf(f,"#ifndef ANTLR_VERSION\n");\r
-       fprintf(f,"#define ANTLR_VERSION        %s\n", VersionDef);\r
-    fprintf(f,"#endif\n\n");\r
-\r
-    if (FirstAction != NULL ) dumpAction(FirstAction, f, 0, -1, 0, 1);  /* MR11 */\r
-\r
-       fprintf(f,"#include \"pcctscfg.h\"\n");\r
-       fprintf(f,"#include \"pccts_stdio.h\"\n");\r
-       if ( GenCC )\r
-       {\r
-               if ( UserDefdTokens )\r
-                       fprintf(f, "#include %s\n", UserTokenDefsFile);\r
-               else {\r
-                       fprintf(f, "#include \"%s\"\n", DefFileName);\r
-               }\r
-\r
-               fprintf(f, "#include \"%s\"\n", ATOKEN_H);\r
-\r
-               if ( HdrAction != NULL ) dumpAction( HdrAction, f, 0, -1, 0, 1);\r
-\r
-               fprintf(f, "#include \"%s\"\n", ATOKENBUFFER_H);\r
-\r
-               if ( OutputLL_k > 1 ) fprintf(f,"static const unsigned LL_K=%d;\n", OutputLL_k);\r
-               if ( GenAST ) {\r
-                       fprintf(f, "#include \"%s\"\n", ASTBASE_H);\r
-               }\r
-\r
-        if (TraceGen) {\r
-          fprintf(f,"#ifndef zzTRACE_RULES\n");  /* MR20 */\r
-          fprintf(f,"#define zzTRACE_RULES\n");  /* MR20 */\r
-          fprintf(f,"#endif\n");                 /* MR22 */\r
-        };\r
-\r
-               fprintf(f,"#include \"%s\"\n", APARSER_H);\r
-               fprintf(f,"#include \"%s.h\"\n", CurrentClassName);\r
-               if ( LexGen ) fprintf(f,"#include \"%s\"\n", DLEXERBASE_H);\r
-               fprintf(f, "#endif\n");\r
-               return;\r
-       }\r
-\r
-       if ( strcmp(ParserName, DefaultParserName)!=0 )\r
-               fprintf(f, "#define %s %s\n", DefaultParserName, ParserName);\r
-       if ( strcmp(ParserName, DefaultParserName)!=0 )\r
-               fprintf(f, "#include \"%s\"\n", RemapFileName);\r
-       if ( UserTokenDefsFile != NULL )\r
-          fprintf(f, "#include %s\n", UserTokenDefsFile);\r
-       if ( HdrAction != NULL ) dumpAction( HdrAction, f, 0, -1, 0, 1);\r
-       if ( FoundGuessBlk )\r
-       {\r
-               fprintf(f,"#define ZZCAN_GUESS\n");\r
-               fprintf(f,"#include \"pccts_setjmp.h\"\n");\r
-       }\r
-    if (TraceGen) {\r
-      fprintf(f,"#ifndef zzTRACE_RULES\n");  /* MR20 */\r
-      fprintf(f,"#define zzTRACE_RULES\n");  /* MR20 */\r
-      fprintf(f,"#endif\n");                 /* MR22 */\r
-    };\r
-       if ( OutputLL_k > 1 ) fprintf(f,"#define LL_K %d\n", OutputLL_k);\r
-       if ( GenAST ) fprintf(f,"#define GENAST\n");\r
-       if ( FoundException )\r
-       {\r
-/* MR1  7-Apr-97  1.33MR1                                                                 */\r
-/* MR1            Fix suggested by:                                               */\r
-/* MR1            Francois-Xavier Fontaine (fontaine_f@istvax.ist.lu)         */\r
-\r
-               fprintf(f,"#define EXCEPTION_HANDLING\n");                  /* MR1 */\r
-               fprintf(f,"#define NUM_SIGNALS %d\n", NumSignals);          /* MR1 */\r
-       }\r
-       if ( DemandLookahead ) fprintf(f,"#define DEMAND_LOOK\n");\r
-#ifdef DUM\r
-       if ( LexGen ) fprintf(f, "#define zzEOF_TOKEN %d\n", (TokenInd!=NULL?TokenInd[EofToken]:EofToken));\r
-#endif\r
-       /* ###WARNING: This will have to change when SetWordSize changes */\r
-       fprintf(f, "#define zzSET_SIZE %d\n", NumWords(TokenNum-1)*sizeof(unsigned));\r
-    if (TraceGen) {\r
-      fprintf(f,"#ifndef zzTRACE_RULES\n");  /* MR20 */\r
-      fprintf(f,"#define zzTRACE_RULES\n");  /* MR20 */\r
-      fprintf(f,"#endif\n");                 /* MR22 */\r
-    };\r
-       fprintf(f,"#include \"antlr.h\"\n");\r
-       if ( GenAST ) fprintf(f,"#include \"ast.h\"\n");\r
-       if ( UserDefdTokens )\r
-               fprintf(f, "#include %s\n", UserTokenDefsFile);\r
-       /* still need this one as it has the func prototypes */\r
-       fprintf(f, "#include \"%s\"\n", DefFileName);\r
-       /* still need this one as it defines the DLG interface */\r
-       fprintf(f,"#include \"dlgdef.h\"\n");\r
-       /* don't need this one unless DLG is used */\r
-       if ( LexGen ) fprintf(f,"#include \"%s\"\n", ModeFileName);\r
-       fprintf(f,"#endif\n");\r
-}\r
-\r
-/* dump action 's' to file 'output' starting at "local" tab 'tabs'\r
-   Dump line information in front of action if GenLineInfo is set\r
-   If file == -1 then GenLineInfo is ignored.\r
-   The user may redefine the LineInfoFormatStr to his/her liking\r
-   most compilers will like the default, however.\r
-\r
-   June '93; changed so that empty lines are left alone so that\r
-   line information is correct for the compiler/debuggers.\r
-*/\r
-void\r
-#ifdef __USE_PROTOS\r
-dumpAction( char *s, FILE *output, int tabs, int file, int line,\r
-int final_newline )\r
-#else\r
-dumpAction( s, output, tabs, file, line, final_newline )\r
-char *s;\r
-FILE *output;\r
-int tabs;\r
-int file;\r
-int line;\r
-int final_newline;\r
-#endif\r
-{\r
-    int inDQuote, inSQuote;\r
-    require(s!=NULL,           "dumpAction: NULL action");\r
-    require(output!=NULL,      eMsg1("dumpAction: output FILE is NULL for %s",s));\r
-\r
-       if ( GenLineInfo && file != -1 )\r
-       {\r
-        OutLineInfo(output,line,FileStr[file]);\r
-       }\r
-    PastWhiteSpace( s );\r
-       /* don't print a tab if first non-white char is a # (preprocessor command) */\r
-       if ( *s!='#' ) {TAB;}\r
-    inDQuote = inSQuote = FALSE;\r
-    while ( *s != '\0' )\r
-    {\r
-        if ( *s == '\\' )\r
-        {\r
-            fputc( *s++, output ); /* Avoid '"' Case */\r
-            if ( *s == '\0' ) return;\r
-            if ( *s == '\'' ) fputc( *s++, output );\r
-            if ( *s == '\"' ) fputc( *s++, output );\r
-        }\r
-        if ( *s == '\'' )\r
-        {\r
-            if ( !inDQuote ) inSQuote = !inSQuote;\r
-        }\r
-        if ( *s == '"' )\r
-        {\r
-            if ( !inSQuote ) inDQuote = !inDQuote;\r
-        }\r
-        if ( *s == '\n' )\r
-        {\r
-            fputc('\n', output);\r
-                       s++;\r
-            PastWhiteSpace( s );\r
-            if ( *s == '}' )\r
-            {\r
-                --tabs;\r
-                               TAB;\r
-                fputc( *s++, output );\r
-                continue;\r
-            }\r
-            if ( *s == '\0' ) return;\r
-                       if ( *s != '#' )        /* #define, #endif etc.. start at col 1 */\r
-            {\r
-                               TAB;\r
-                       }\r
-        }\r
-        if ( *s == '}' && !(inSQuote || inDQuote) )\r
-        {\r
-            --tabs;            /* Indent one fewer */\r
-        }\r
-        if ( *s == '{' && !(inSQuote || inDQuote) )\r
-        {\r
-            tabs++;            /* Indent one more */\r
-        }\r
-        fputc( *s, output );\r
-        s++;\r
-    }\r
-    if ( final_newline ) fputc('\n', output);\r
-}\r
-\r
-static void\r
-#ifdef __USE_PROTOS\r
-dumpAfterActions( FILE *output )\r
-#else\r
-dumpAfterActions( output )\r
-FILE *output;\r
-#endif\r
-{\r
-       ListNode *p;\r
-       require(output!=NULL, "dumpAfterActions: output file was NULL for some reason");\r
-       if ( AfterActions != NULL )\r
-       {\r
-               for (p = AfterActions->next; p!=NULL; p=p->next)\r
-               {\r
-                       UserAction *ua = (UserAction *)p->elem;\r
-                       dumpAction( ua->action, output, 0, ua->file, ua->line, 1);\r
-               }\r
-       }\r
-       fclose( output );\r
-}\r
-\r
-/*\r
- * Find the next action in the stream of execution.  Do not pass\r
- * junctions with more than one path leaving them.\r
- * Only pass generic junctions.\r
- *\r
- *     Scan forward while (generic junction with p2==NULL)\r
- *     If we stop on an action, return ptr to the action\r
- *     else return NULL;\r
- */\r
-static ActionNode *\r
-#ifdef __USE_PROTOS\r
-findImmedAction( Node *q )\r
-#else\r
-findImmedAction( q )\r
-Node *q;\r
-#endif\r
-{\r
-       Junction *j;\r
-       require(q!=NULL, "findImmedAction: NULL node");\r
-       require(q->ntype>=1 && q->ntype<=NumNodeTypes, "findImmedAction: invalid node");\r
-       \r
-       while ( q->ntype == nJunction )\r
-       {\r
-               j = (Junction *)q;\r
-               if ( j->jtype != Generic || j->p2 != NULL ) return NULL;\r
-               q = j->p1;\r
-               if ( q == NULL ) return NULL;\r
-       }\r
-       if ( q->ntype == nAction ) return (ActionNode *)q;\r
-       return NULL;\r
-}\r
-\r
-static void\r
-#ifdef __USE_PROTOS\r
-dumpRetValAssign( char *retval, char *ret_def, RuleRefNode * ruleRef /* MR30 */)\r
-#else\r
-dumpRetValAssign( retval, ret_def, ruleRef /* MR30 */)\r
-char *retval;\r
-char *ret_def;\r
-RuleRefNode *ruleRefNode;\r
-#endif\r
-{\r
-       char *q = ret_def;\r
-       \r
-       tab();\r
-       while ( *retval != '\0' && *q != '\0')\r
-       {\r
-               while ( isspace((*retval)) ) retval++;\r
-               while ( *retval!=',' && *retval!='\0' ) fputc(*retval++, output);\r
-               fprintf(output, " = _trv.");\r
-               \r
-               DumpNextNameInDef(&q, output);\r
-               while ( isspace(*q) ) q++;\r
-               fputc(';', output); fputc(' ', output);\r
-               if ( *retval == ',' ) retval++;\r
-       }\r
-       if (*retval == '\0' && *q != '\0') {\r
-/* MR30 */    errFL("Fewer output values than output formals for rule reference",\r
-/* MR30 */                 FileStr[ruleRef->file],ruleRef->line);\r
-       }\r
-       if (*retval != '\0' && *q == '\0') {\r
-/* MR30 */    errFL("More output actuals than output formals for rule reference",\r
-/* MR30 */                 FileStr[ruleRef->file],ruleRef->line);\r
-       }\r
-}\r
-\r
-/* This function computes the set of tokens that can possibly be seen k\r
- * tokens in the future from point j\r
- */\r
-\r
-static set\r
-#ifdef __USE_PROTOS\r
-ComputeErrorSet( Junction *j, int k, int usePlusBlockBypass)\r
-#else\r
-ComputeErrorSet( j, k, usePlusBlockBypass )\r
-Junction *j;\r
-int k;\r
-int usePlusBlockBypass;\r
-#endif\r
-{\r
-       Junction *alt1;\r
-       set a, rk, f;\r
-       require(j->ntype==nJunction, "ComputeErrorSet: non junction passed");\r
-\r
-       f = rk = empty;\r
-       for (alt1=j; alt1!=NULL; alt1 = (Junction *)alt1->p2)\r
-       {\r
-        if (alt1->ignore && ! usePlusBlockBypass) continue;     /* MR21 - Ignore aPlusBlk forward p2 */\r
-               REACH(alt1->p1, k, &rk, a);\r
-               require(set_nil(rk), "ComputeErrorSet: rk != nil");\r
-               set_free(rk);\r
-               set_orin(&f, a);\r
-               set_free(a);\r
-       }\r
-       return f;\r
-}\r
-\r
-static char *\r
-#ifdef __USE_PROTOS\r
-tokenFollowSet(TokNode *p)\r
-#else\r
-tokenFollowSet(p)\r
-TokNode *p;\r
-#endif\r
-{\r
-    static char buf[100];\r
-    set rk, a;\r
-    int n;\r
-    rk = empty;\r
-\r
-    REACH(p->next, 1, &rk, a);\r
-    require(set_nil(rk), "rk != nil");\r
-    set_free(rk);\r
-    n = DefErrSet( &a, 0, NULL );\r
-    set_free(a);\r
-    if ( GenCC )\r
-        sprintf(buf, "err%d", n);\r
-    else\r
-        sprintf(buf, "zzerr%d", n);\r
-    return buf;\r
-}\r
-\r
-static void\r
-#ifdef __USE_PROTOS\r
-makeErrorClause( Junction *q, set f, int max_k, int usePlusBlockBypass )\r
-#else\r
-makeErrorClause( q, f, max_k, usePlusBlockBypass )\r
-Junction *q;\r
-set f;\r
-int max_k;\r
-int usePlusBlockBypass;\r
-#endif\r
-{\r
-    char *  handler_id="";                                           /* MR7 */\r
-    int     nilf=0;                                                  /* MR13 */\r
-    RuleEntry *ruleEntry;                                            /* MR14 */\r
-\r
-       if ( FoundException )\r
-       {\r
-               _gen("else {\n");\r
-               tabs++;\r
-               if ( FoundGuessBlk )\r
-               {\r
-                       if ( GenCC ) {gen("if ( guessing ) goto fail;\n");}\r
-                       else gen("if ( zzguessing ) goto fail;\n");\r
-               }\r
-               gen("if (_sva) _signal=NoViableAlt;\n");\r
-               gen("else _signal=NoSemViableAlt;\n");\r
-        if (q->outerEG != NULL) {\r
-          handler_id=q->outerEG->altID;\r
-#if 0\r
-        } else {\r
-          printf("q->curAltNum=%d q->exception_label=%s\n",q->curAltNum,q->exception_label);\r
-          gen("*** DEBUG *** outerEG==NULL\n");\r
-#endif\r
-        };\r
-               gen1("goto %s_handler;  /* MR7 */\n",handler_id);    /* MR7 */\r
-               tabs--;\r
-               gen("}\n");\r
-               return;\r
-       }\r
-\r
-       if ( max_k == 1 )\r
-       {\r
-/* MR13 */  nilf=set_nil(f);\r
-               if ( GenCC ) {\r
-              _gen1("else {FAIL(1,err%d", DefErrSet1(1,&f,1,NULL));\r
-            } else {\r
-               _gen1("else {zzFAIL(1,zzerr%d", DefErrSet1(1,&f,1,NULL));\r
-            };\r
-               set_free(f);\r
-       }\r
-       else\r
-       {\r
-               int i;\r
-               set_free(f);\r
-               if ( GenCC ) {_gen1("else {FAIL(%d", max_k);}\r
-               else _gen1("else {zzFAIL(%d", max_k);\r
-\r
-    ruleEntry = (RuleEntry *) hash_get(Rname,q->rname);\r
-\r
-               for (i=1; i<=max_k; i++)\r
-               {\r
-/* MR14 */  if (ruleEntry->dontComputeErrorSet) {\r
-/* MR14 */    f=empty;\r
-            } else {\r
-             f = ComputeErrorSet(q, i, usePlusBlockBypass /* use plus block bypass ? */ );\r
-            }\r
-\r
-      if ( GenCC ) {_gen1(",err%d", DefErrSet( &f, 1, NULL ));}\r
-                       else _gen1(",zzerr%d", DefErrSet( &f, 1, NULL ));\r
-                       \r
-                       set_free(f);\r
-               }\r
-       }\r
-       _gen(",&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\n");\r
-/* MR13 */  if (nilf) {\r
-/* MR13 */    errFL("empty error set for alt - probably because of undefined rule or infinite left recursion",\r
-/* MR13 */                 FileStr[q->file],q->line);\r
-/* MR13 */    gen(" /* MR13 empty error set for this alt - undef rule ? infinite left recursion ? */");\r
-/* MR13 */  };\r
-}\r
-\r
-static                                                               /* MR7 */\r
-#ifdef __USE_PROTOS\r
-char * findOuterHandlerLabel(ExceptionGroup *eg)                     /* MR7 */\r
-#else\r
-char * findOuterHandlerLabel(eg)                                     /* MR7 */\r
-ExceptionGroup *eg;                                                  /* MR7 */\r
-#endif\r
-{\r
-  char              *label=NULL;                                     /* MR7 */\r
-  ExceptionGroup    *outerEG;                                        /* MR7 */\r
-\r
-  if (eg->forRule == 0) {                                            /* MR7 */\r
-    if (eg->labelEntry != NULL) {                                    /* MR7 */\r
-      outerEG=eg->labelEntry->outerEG;                               /* MR7 */\r
-      if (outerEG != NULL) {                                         /* MR7 */\r
-        label=outerEG->altID;                                        /* MR7 */\r
-        outerEG->used=1;                                             /* MR7 */\r
-      };                                                             /* MR7 */\r
-    } else if (eg->outerEG != NULL) {                                /* MR7 */\r
-      outerEG=eg->outerEG;                                           /* MR7 */\r
-      label=outerEG->altID;                                          /* MR7 */\r
-      outerEG->used=1;                                               /* MR7 */\r
-    };                                                               /* MR7 */\r
-  };                                                                 /* MR7 */\r
-  return (label==NULL ? "" : label);                                 /* MR7 */\r
-}                                                                    /* MR7 */\r
-\r
-/*** debug ***/\r
-#if 0\r
-** static                                                               /* MR7 */\r
-** #ifdef __USE_PROTOS\r
-** char * findOuterAltHandlerLabel(Junction *startJ)                    /* MR7 */\r
-** #else\r
-** char * findOuterAltHandlerLabel(startJ)                              /* MR7 */\r
-** Junction *startJ;                                                    /* MR7 */\r
-** #endif\r
-** {                                                                    /* MR7 */\r
-**   char      *label=NULL;                                             /* MR7 */\r
-**   Junction  *alt;                                                    /* MR7 */\r
-**                                                                      /* MR7 */\r
-**   for (alt=startJ; alt != NULL; alt=alt->outerAltstart) {            /* MR7 */\r
-**     label=alt->exception_label;                                      /* MR7 */\r
-**     if (label != NULL) break;                                        /* MR7 */\r
-**   };                                                                 /* MR7 */\r
-**   return (label==NULL ? "" : label);                                 /* MR7 */\r
-** }                                                                    /* MR7 */\r
-#endif\r
-\r
-#ifdef __USE_PROTOS\r
-static void OutLineInfo(FILE *file,int line,char *fileName)\r
-#else\r
-static void OutLineInfo(file,line,fileName)\r
-  FILE *    file;\r
-  int       line;\r
-  char *    fileName;\r
-#endif\r
-{\r
-    static  char * prevFileName=NULL;\r
-    static  char * prevFileNameMS=NULL;\r
-\r
-    char *  p;\r
-    char *  q;\r
-\r
-    if (! GenLineInfo) return;\r
-\r
-    if (!GenLineInfoMS) {\r
-           fprintf(file, LineInfoFormatStr,line,fileName);\r
-    } else {\r
-      if (fileName == prevFileName) {\r
-           fprintf(file, LineInfoFormatStr,line,prevFileNameMS);\r
-      } else {\r
-        if (prevFileNameMS != NULL) free (prevFileNameMS);\r
-        prevFileNameMS=(char *)calloc(1,strlen(fileName)+1);\r
-        require(prevFileNameMS != NULL,"why not do this in calloc wrapper");\r
-        q=prevFileNameMS;\r
-        for (p=fileName; *p != 0; p++) {\r
-            *q=*p;\r
-            if (*q == '\\') *q='/';\r
-            q++;\r
-        }\r
-      }\r
-      prevFileName=fileName;\r
-    };\r
-}\r
-\r
-#if 0\r
-\r
-/* MR21 */\r
-\r
-#ifdef __USE_PROTOS\r
-void OutFirstSetSymbol(Junction *q, char * pSymbol)\r
-#else\r
-void OutFirstSetSymbol(q, pSymbol)\r
-    Junction* q;\r
-       char * pSymbol\r
-#endif\r
-{\r
-\r
-       set f;\r
-    if (pSymbol == NULL) return;\r
-       gen1("/** #FirstSetSymbol(%s) **/\n",pSymbol);\r
-    f = ComputeErrorSet(q, 1, 0 /* use plus block bypass ? */);\r
-    DefErrSetWithSuffix (0 /* nil ok */, &f,0 /* no substitute */, pSymbol, "");\r
-    set_free(f);\r
-}\r
-#endif\r
-\r
-/* MR21 */\r
-\r
-#ifdef __USE_PROTOS\r
-void BlockPreambleOption(Junction *q, char * pSymbol)\r
-#else\r
-void BlockPreambleOption(q, pSymbol)\r
-    Junction* q;\r
-       char * pSymbol;\r
-#endif\r
-{\r
-       set f = empty;\r
-    if (pSymbol != NULL) {\r
-        f = ComputeErrorSet(q, 1, 0 /* use plus block bypass ? */);\r
-       gen1("/** #FirstSetSymbol(%s) **/\n",pSymbol);\r
-        DefErrSetWithSuffix (0 /* nil ok */, &f,0 /* no substitute */, pSymbol, "");\r
-    }\r
-    set_free(f);\r
-}\r
-\r
-/* MR21 */\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-dumpActionPlus(ActionNode *a, char *s, FILE *output, int tabs, int file, int line,\r
-int final_newline )\r
-#else\r
-dumpActionPlus(a, s, output, tabs, file, line, final_newline )\r
-ActionNode *a;\r
-char *s;\r
-FILE *output;\r
-int tabs;\r
-int file;\r
-int line;\r
-int final_newline;\r
-#endif\r
-{\r
-    dumpAction(s,output,tabs,file,line,final_newline);\r
-}\r
-\r
-\r
-#if 0\r
-** #ifdef __USE_PROTOS\r
-** void MR_ErrorSets(Junction *q, int max_k, int usePlusBlockBypass)\r
-** #else\r
-** void MR_ErrorSets(q, max_k, usePlusBlockBypass)\r
-** Junction *q;\r
-** int max_k;\r
-** int usePlusBlockBypass;\r
-** #endif\r
-** {\r
-**     int k;\r
-**     set setResult;\r
-**     Junction* alt1;\r
-**     Junction* p;\r
-**     set rk;\r
-** \r
-**     require (max_k <= CLL_k, "k > CLL_k");\r
-** \r
-** \r
-**     for (k = 1; k <= CLL_k; k++) {set_clr(q->fset[k]); }\r
-** \r
-**     for (k = 1; k <= max_k; k++) {\r
-**         for (alt1=q; alt1 != NULL; alt1 = (Junction *)alt1->p2)\r
-**             {\r
-**             if (alt1->ignore && ! usePlusBlockBypass) continue;\r
-**             p = analysis_point((Junction *)alt1->p1);\r
-**                     REACH(p, k, &rk, setResult);\r
-**                     require(set_nil(rk), "rk != nil");\r
-**             set_orin(&q->fset[k], setResult);\r
-**             }\r
-**     }\r
-** }\r
-#endif\r
-\r
-\r
-#ifdef __USE_PROTOS\r
-void DumpInitializers(FILE* output, RuleEntry *r, char * pReturn)\r
-#else\r
-void DumpInitializers(output, r, pReturn)\r
-FILE* output;\r
-RuleEntry *r;\r
-char * pReturn;\r
-#endif\r
-{\r
-       char *p = pReturn;\r
-       char *pDataType;\r
-       char *pSymbol;\r
-       char *pEqualSign;\r
-       char *pValue;\r
-       char *pSeparator;\r
-       int nest = 0;\r
-    char *q;\r
-\r
-       require(pReturn!=NULL, "DumpInitializer: invalid string"); \r
-\r
-    while (*p != 0) {\r
-       p = endFormal(p,\r
-                             &pDataType,\r
-                                 &pSymbol,\r
-                                 &pEqualSign,\r
-                                 &pValue,\r
-                                 &pSeparator,\r
-                                 &nest);\r
-        if (nest != 0) return;\r
-        if (pValue != NULL) {\r
-                       tab();\r
-            q = strBetween(pSymbol, pEqualSign, pSeparator);\r
-            fprintf(output, "_retv.%s", q);\r
-            q = strBetween(pValue, NULL, pSeparator);\r
-            fprintf(output, " = %s;\n", q);\r
-        }\r
-    }\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-void DumpFormals(FILE* output, char * pReturn, int bInitializer)\r
-#else\r
-void DumpFormals(output, pReturn, bInitializer)\r
-FILE* output;\r
-char * pReturn;\r
-int bInitializer;\r
-#endif\r
-{\r
-       char *p = pReturn;\r
-       char *pDataType;\r
-       char *pSymbol;\r
-       char *pEqualSign;\r
-       char *pValue;\r
-       char *pSeparator;\r
-       int nest = 0;\r
-    char *q;\r
-    int count = 0;\r
-\r
-       require(pReturn!=NULL, "DumpFormals: invalid string"); \r
-\r
-    while (*p != 0) {\r
-       p = endFormal(p,\r
-                             &pDataType,\r
-                                 &pSymbol,\r
-                                 &pEqualSign,\r
-                                 &pValue,\r
-                                 &pSeparator,\r
-                                 &nest);\r
-        if (nest != 0) return;\r
-        if (count > 0) fprintf(output,",");\r
-        if (pDataType != NULL && pSymbol != NULL) {\r
-            q = strBetween(pDataType, pSymbol, pSeparator);\r
-            fprintf(output, "%s", q);\r
-            q = strBetween(pSymbol, pEqualSign, pSeparator);\r
-            fprintf(output," %s",q);\r
-            if (pValue != NULL) {\r
-                q = strBetween(pValue, NULL, pSeparator);\r
-                if (bInitializer != 0) {\r
-                    fprintf(output, " = %s", q);\r
-                }\r
-            }\r
-        }\r
-        count++;\r
-    }\r
-}\r
-\r
-/* MR23 Check for empty alt in a more intelligent way.\r
-        Previously, an empty alt for genBlk had to point directly\r
-               to the endBlock.  This did not work once I changed {...}\r
-               blocks to look like (...|...| epsilon) since there were\r
-               intervening generics.  This fixes the problem for this\r
-               particular case.  Things like actions or empty blocks of\r
-               various kinds will still cause problems, but I wasnt't\r
-               prepared to handle pathological cases like (A|()*). It\r
-               does handle (A | ()), which is a recommended idiom for\r
-               epsilon.\r
-\r
-        Actually, this isn't quite correct since it doesn't handle\r
-               the case of the ignore bit in the plus block bypass, but\r
-               I'm too tired to figure out the correct fix, and will just\r
-               work around it.\r
-*/\r
-\r
-#ifdef __USE_PROTOS\r
-int isEmptyAlt(Node * alt, Node * endBlock)\r
-#else\r
-int isEmptyAlt(alt, endBlock)\r
-Node * alt;\r
-Node * endBlock;\r
-#endif\r
-{\r
-       Node * n = alt;\r
-       Junction * j;\r
-       while (n != endBlock) {\r
-               switch (n->ntype) {\r
-\r
-                       case nRuleRef:\r
-                               return 0;\r
-\r
-                       case nToken:\r
-                               return 0;\r
-\r
-                       case nAction:\r
-                               return 0;\r
-\r
-                       case nJunction:\r
-                               goto JUNCTION;\r
-\r
-                       default:\r
-                               fatal_internal("Invalid node type");\r
-                               return 0;\r
-               }\r
-JUNCTION:\r
-               j = (Junction *) n;\r
-\r
-               switch (j->jtype) {\r
-                       case Generic:\r
-                               {\r
-                                       n = j->p1;\r
-                                       goto NEXT;\r
-                               }\r
-\r
-                       case aSubBlk:\r
-                               {\r
-                                       n = j->p1;      /* MR26 */\r
-                                       goto NEXT;      /* MR26 */\r
-                               }\r
-\r
-                       case EndBlk:\r
-                                       return 0;\r
-\r
-                       case EndRule:\r
-                                       return 1;\r
-\r
-                       default:\r
-                                       return 0;\r
-               }\r
-NEXT: continue;\r
-       }\r
-       return 1;\r
-}\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/antlr/generic.h b/Tools/CodeTools/TianoTools/Pccts/antlr/generic.h
deleted file mode 100644 (file)
index 8d736d5..0000000
+++ /dev/null
@@ -1,286 +0,0 @@
-/*\r
- * generic.h -- generic include stuff for new PCCTS ANTLR.\r
- *\r
- * SOFTWARE RIGHTS\r
- *\r
- * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
- * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
- * company may do whatever they wish with source code distributed with\r
- * PCCTS or the code generated by PCCTS, including the incorporation of\r
- * PCCTS, or its output, into commerical software.\r
- *\r
- * We encourage users to develop software with PCCTS.  However, we do ask\r
- * that credit is given to us for developing PCCTS.  By "credit",\r
- * we mean that if you incorporate our source code into one of your\r
- * programs (commercial product, research project, or otherwise) that you\r
- * acknowledge this fact somewhere in the documentation, research report,\r
- * etc...  If you like PCCTS and have developed a nice tool with the\r
- * output, please mention that you developed it using PCCTS.  In\r
- * addition, we ask that this header remain intact in our source code.\r
- * As long as these guidelines are kept, we expect to continue enhancing\r
- * this system and expect to make other tools available as they are\r
- * completed.\r
- *\r
- * ANTLR 1.33\r
- * Terence Parr\r
- * Parr Research Corporation\r
- * with Purdue University and AHPCRC, University of Minnesota\r
- * 1989-2001\r
- */\r
-\r
-#define StrSame                        0\r
-\r
-#define DefaultParserName      "zzparser"\r
-\r
-/* MR9  JVincent@novell.com     Allow user to override default ZZLEXBUFSIZE  */\r
-/* MR11 thm                     Raise antlr's own default ZZLEXBUFSIZE to 8k */\r
-/* MR22 thm                     Raise antlr's own default ZZLEXBUFSIZE to 32k */\r
-\r
-#ifndef ZZLEXBUFSIZE\r
-#define ZZLEXBUFSIZE 32000\r
-#endif\r
-\r
-/* Tree/FIRST/FOLLOW defines -- valid only after all grammar has been read */\r
-#define ALT                    TokenNum+1\r
-#define SET                    TokenNum+2\r
-#define TREE_REF       TokenNum+3\r
-\r
-                                       /* E r r o r  M a c r o s */\r
-\r
-#define fatal(err)     fatalFL(err, __FILE__, __LINE__)\r
-#define fatal_internal(err)    fatal_intern(err, __FILE__, __LINE__)\r
-\r
-\r
-#define eMsg1(s,a)     eMsg3(s,a,NULL,NULL)\r
-#define eMsg2(s,a,b)   eMsg3(s,a,b,NULL)\r
-\r
-                               /* S a n i t y  C h e c k i n g */\r
-\r
-#ifndef require\r
-#define require(expr, err) {if ( !(expr) ) fatal_internal(err);}\r
-#endif\r
-\r
-                                       /* L i s t  N o d e s */\r
-\r
-typedef struct _ListNode {\r
-                       void *elem;                     /* pointer to any kind of element */\r
-                       struct _ListNode *next;\r
-               } ListNode;\r
-\r
-/* Define a Cycle node which is used to track lists of cycles for later\r
- * reconciliation by ResolveFoCycles().\r
- */\r
-typedef struct _c {\r
-                       int croot;                      /* cycle root */\r
-                       set cyclicDep;          /* cyclic dependents */\r
-                       unsigned deg;           /* degree of FOLLOW set of croot */\r
-               } Cycle;\r
-\r
-typedef struct _e {\r
-                       int tok;                        /* error class name == TokenStr[tok] */\r
-                       ListNode *elist;        /* linked list of elements in error set */\r
-                       set eset;\r
-                       int setdeg;                     /* how big is the set */\r
-                       int lexclass;           /* which lex class is it in? */\r
-               } ECnode;\r
-\r
-typedef struct _TCnode {\r
-                       int tok;                        /* token class name */\r
-                       ListNode *tlist;        /* linked list of elements in token set */\r
-                       set tset;\r
-                       int lexclass;           /* which lex class is it in? */\r
-                       unsigned char dumped; /* this def has been been dumped */\r
-                       unsigned char dumpedComplement; /* this def has been been dumped */\r
-                       unsigned setnum;        /* which set number is this guy? (if dumped) */\r
-                       unsigned setnumComplement;               /* MR23 */\r
-                       unsigned setnumErrSet;                   /* MR23 which set is this #tokclass error set (if dumped) */\r
-                       unsigned setnumErrSetComplement; /* MR23 */\r
-               } TCnode;\r
-\r
-typedef struct _ft {\r
-                       char *token;            /* id of token type to remap */\r
-                       int tnum;                       /* move token type to which token position */\r
-               } ForcedToken;\r
-\r
-typedef struct _ContextGuardPredicates {    /* MR13 */\r
-            Predicate *pred;                /* MR13 */\r
-        } ContextGuardPredicates;           /* MR13 */\r
-\r
-#define newListNode    (ListNode *) calloc(1, sizeof(ListNode));\r
-#define newCycle       (Cycle *) calloc(1, sizeof(Cycle));\r
-#define newECnode      (ECnode *) calloc(1, sizeof(ECnode));\r
-#define newTCnode      (TCnode *) calloc(1, sizeof(TCnode));\r
-\r
-\r
-                               /* H a s h  T a b l e  E n t r i e s */\r
-\r
-typedef struct _t {                            /* Token name or expression */\r
-                       char *str;\r
-                       struct _t *next;\r
-                       int token;                      /* token number */\r
-                       unsigned char classname;        /* is it a err/tok class name or token */\r
-                       TCnode *tclass;         /* ptr to token class */\r
-                       char *action;\r
-            char *akaString;\r
-               } TermEntry;\r
-\r
-typedef struct _r {                            /* Rule name and ptr to start of rule */\r
-                       char *str;\r
-                       struct _t *next;\r
-                       int rulenum;            /* RulePtr[rulenum]== ptr to RuleBlk junction */\r
-                       unsigned char noAST;/* gen AST construction code? (def==gen code) */\r
-                       char *egroup;           /* which error group (err reporting stuff) */\r
-#if 0\r
-                       /* MR27  This appears to never be used.  Delete this code later. */\r
-\r
-                       ListNode *el_labels;/* list of element labels ref in all of rule */\r
-#endif\r
-                       ListNode *ast_labels_in_actions; /* MR27 */\r
-            unsigned char has_rule_exception;\r
-            char dontComputeErrorSet;    /* MR14 - don't compute error set\r
-                                          special for rule in alpha part of\r
-                                          (alpha)? beta block */\r
-               } RuleEntry;\r
-\r
-typedef struct _f {                            /* cache Fi/Fo set */\r
-                       char *str;                      /* key == (rulename, computation, k) */\r
-                       struct _f *next;\r
-                       set fset;                       /* First/Follow of rule */\r
-                       set rk;                         /* set of k's remaining to be done after ruleref */\r
-                       int incomplete;         /* only w/FOLLOW sets.  Use only if complete */\r
-               } CacheEntry;\r
-\r
-typedef struct _LabelEntry {   /* element labels */\r
-                       char *str;\r
-                       struct _f *next;\r
-                       Node *elem;                     /* which element does it point to? */\r
-                       ExceptionGroup *ex_group;\r
-                                                               /* Is there an exception attached to label? */\r
-            ExceptionGroup *outerEG;                                 /* MR7 */\r
-                                /* next EG if ex_group doesn't catch it MR7 */\r
-            struct _LabelEntry  *pendingLink;                        /* MR7 */\r
-                                /* too lazy to use ListNode ?           MR7 */\r
-            int     curAltNum;                                       /* MR7 */\r
-               } LabelEntry;\r
-\r
-typedef struct _SignalEntry {\r
-                       char *str;\r
-                       struct _f *next;\r
-                       int signum;                     /* unique signal number */\r
-               } SignalEntry;\r
-\r
-typedef struct _PredEntry {                            /* MR11 predicate name and ptr to string */\r
-                       char              *str;\r
-            struct _PredEntry *next;\r
-            int               file;\r
-            int               line;\r
-            Predicate         *pred;\r
-            char              *predLiteral;\r
-               } PredEntry;\r
-\r
-typedef struct _PointerStack {      /* MR10 */\r
-        int     count;\r
-        int     size;\r
-        void    **data;\r
-        } PointerStack;\r
-\r
-#define newTermEntry(s)                (TermEntry *) newEntry(s, sizeof(TermEntry))\r
-#define newRuleEntry(s)                (RuleEntry *) newEntry(s, sizeof(RuleEntry))\r
-#define newCacheEntry(s)       (CacheEntry *) newEntry(s, sizeof(CacheEntry))\r
-#define newLabelEntry(s)       (LabelEntry *) newEntry(s, sizeof(LabelEntry))\r
-#define newSignalEntry(s)      (SignalEntry *) newEntry(s, sizeof(SignalEntry))\r
-#define newPredEntry(s)     (PredEntry *) newEntry(s,sizeof(PredEntry))\r
-\r
-typedef struct _UserAction {\r
-                       char *action;\r
-                       int file, line;\r
-               } UserAction;\r
-\r
-\r
-                                       /* L e x i c a l  C l a s s */\r
-\r
-/* to switch lex classes, switch ExprStr and Texpr (hash table) */\r
-typedef struct _lc {\r
-                       char *classnum, **exprs;\r
-                       Entry **htable;\r
-               } LClass;\r
-\r
-typedef struct _exprOrder {\r
-                       char *expr;\r
-                       int lclass;\r
-               } Expr;\r
-\r
-\r
-typedef Graph Attrib;\r
-\r
-                                               /* M a x i m u m s */\r
-\r
-/* MR20 Note G. Hobbelt These values are superceded by values in hash.h */\r
-\r
-#ifndef HashTableSize\r
-#define HashTableSize  253\r
-#endif\r
-#ifndef StrTableSize\r
-#define StrTableSize   15000   /* all tokens, nonterminals, rexprs stored here */\r
-#endif\r
-#define MaxLexClasses  50              /* how many automatons */\r
-/* TokenStart and EofToken are ignored if #tokdefs meta-op is used */\r
-#define TokenStart             2               /* MUST be in 1 + EofToken */\r
-#define EofToken               1               /* Always predefined to be 1 */\r
-\r
-#ifndef MaxNumFiles\r
-#define MaxNumFiles            99\r
-#endif\r
-\r
-/**** MR9 JVincent@novell.com  Move to pcctscfg.h */\r
-/**** #define MaxFileName              300     ****/ /* MR9  Move to pcctscfg.h */ /* largest file name size */\r
-\r
-#define MaxRuleName            100             /* largest rule name size */\r
-#define TSChunk                        100             /* how much to expand TokenStr/ExprStr each time */\r
-#define TIChunk                        TSChunk /* expand TokenInd by same as TokenStr to mirror them */\r
-#define FoStackSize            100             /* deepest FOLLOW recursion possible */\r
-\r
-#define MaxClassDeclStuff   256    /* MR10 */\r
-\r
-#define NumPredefinedSignals 3\r
-\r
-           /* S t a n d a r d  S i g n a l s */\r
-\r
-#define sigNoSignal                            0\r
-#define sigMismatchedToken             1\r
-#define sigNoViableAlt                 2\r
-#define sigNoSemViableAlt              3\r
-\r
-\r
-\r
-/* AST token types */\r
-#define ASTexclude             0\r
-#define ASTchild               1\r
-#define ASTroot                        2\r
-#define ASTinclude             3               /* include subtree made by rule ref */\r
-\r
-\r
-#define PredictionVariable                             "zzpr_expr"\r
-#define PredictionLexClassSuffix               "_zzpred"\r
-\r
-#define WildCardString                                 "WildCard"\r
-\r
-#if 0\r
-    /*  Removed in version 1.33MR19\r
-        Don't understand why this never caused problems before\r
-    */\r
-\r
-    /*********************************************************\r
-    #ifndef ANTLRm\r
-       #define ANTLRm(st, f, _m)       zzbufsize = ZZLEXBUFSIZE;\\r
-                                       zzmode(_m);                                     \\r
-                                       zzenterANTLR(f);                        \\r
-                                       st; ++zzasp;                            \\r
-                                       zzleaveANTLR(f);\r
-       #endif                                          \r
-    *********************************************************/\r
-#endif\r
-\r
-#include "proto.h"\r
-#include "pcctscfg.h"   /* MR14 */\r
-#include <string.h>\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/antlr/globals.c b/Tools/CodeTools/TianoTools/Pccts/antlr/globals.c
deleted file mode 100644 (file)
index 59d0032..0000000
+++ /dev/null
@@ -1,484 +0,0 @@
-/*\r
- * globals.c   --      File containing all variables/tables visible to all files.\r
- *\r
- * SOFTWARE RIGHTS\r
- *\r
- * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
- * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
- * company may do whatever they wish with source code distributed with\r
- * PCCTS or the code generated by PCCTS, including the incorporation of\r
- * PCCTS, or its output, into commerical software.\r
- *\r
- * We encourage users to develop software with PCCTS.  However, we do ask\r
- * that credit is given to us for developing PCCTS.  By "credit",\r
- * we mean that if you incorporate our source code into one of your\r
- * programs (commercial product, research project, or otherwise) that you\r
- * acknowledge this fact somewhere in the documentation, research report,\r
- * etc...  If you like PCCTS and have developed a nice tool with the\r
- * output, please mention that you developed it using PCCTS.  In\r
- * addition, we ask that this header remain intact in our source code.\r
- * As long as these guidelines are kept, we expect to continue enhancing\r
- * this system and expect to make other tools available as they are\r
- * completed.\r
- *\r
- * ANTLR 1.33\r
- * Terence Parr\r
- * Parr Research Corporation\r
- * with Purdue University and AHPCRC, University of Minnesota\r
- * 1989-2001\r
- */\r
-\r
-#include <stdio.h>\r
-\r
-#include "pcctscfg.h"\r
-\r
-#include "set.h"\r
-#include "syn.h"\r
-#include "hash.h"\r
-#include "generic.h"\r
-\r
-char Version[] = "1.33MR33" ;  /* PCCTS version number */                         /* MRXXX */\r
-char VersionDef[] = "13333";    /* same (except int equiv for preproc symbol) */ /* MRXXX */\r
-\r
-char LexStartSymbol[] = "START";/* Name of starting lexical class/automaton */\r
-char *RemapFileName = "remap.h";\r
-char *DlgFileName = "parser.dlg";\r
-char *DefFileName = "tokens.h";\r
-char *ErrFileName = "err.c";\r
-char *ModeFileName = "mode.h";\r
-char *StdMsgName = NULL;\r
-\r
-char *ParserName = DefaultParserName;\r
-\r
-/* list of PCCTS supplied support symbols; these are renamed when more than\r
- * one ANTLR-generated parsers are linked together to avoid name conflicts.\r
- * Can't use '##' ANSIC preprocessor concat operator with K&R and:\r
- *             #define zzskip  zzparser ## skip\r
- * will not work for ANSI/C++ as 'zzparserskip' is created w/o zzparser\r
- * being substituted--ack!!!\r
- */\r
-char *StandardSymbols[] = {\r
-/* ANTLR stuff */\r
-       "zzStackOvfMsg",\r
-       "zzasp",\r
-       "zzaStack",\r
-       "inf_tokens",\r
-       "inf_text",\r
-       "inf_text_buffer",\r
-       "inf_text_buffer_ptr",\r
-       "inf_text_buffer_size",\r
-       "inf_labase",\r
-       "inf_last",\r
-       "inf_lap",\r
-       "zztokenLA",\r
-       "zztextLA",\r
-       "zzlap",\r
-       "zzlabase",\r
-       "zztoktext",\r
-       "zztoken",\r
-       "zzdirty",\r
-       "zzguessing",\r
-       "zzguess_start",\r
-       "zzresynch",\r
-       "zzinf_tokens",\r
-       "zzinf_text",\r
-       "zzinf_text_buffer",\r
-       "zzinf_labase",\r
-       "zzinf_last",\r
-       "zzfill_inf_look",\r
-       "zzFAIL",\r
-       "zzsave_antlr_state",\r
-       "zzrestore_antlr_state",\r
-       "zzsyn",\r
-       "zzset_el",\r
-       "zzset_deg",\r
-       "zzedecode",\r
-       "_zzsetmatch",\r
-       "_zzmatch",\r
-       "_inf_zzgettok",\r
-    "zzconsumeUntil",\r
-    "zzconsumeUntilToken",\r
-    "_zzmatch_wsig",\r
-    "_zzsetmatch_wsig",\r
-    "_zzmatch_wdfltsig",\r
-    "_zzsetmatch_wdfltsig",\r
-       "zzdflthandlers",\r
-/* DLG stuff */\r
-       "zzreal_line",\r
-       "zzcharfull",\r
-       "zzerr",\r
-       "zzlextext",\r
-       "zzbegexpr",\r
-       "zzendexpr",\r
-       "zzbufsize",\r
-       "zzbegcol",\r
-       "zzendcol",\r
-       "zzline",\r
-       "zzchar",\r
-       "zzbufovf",\r
-       "zzrdstream",\r
-       "zzrdfunc",\r
-       "zzrdstr",\r
-       "zzclose_stream",\r
-       "zzsave_dlg_state",\r
-       "zzrestore_dlg_state",\r
-       "zzmode",\r
-       "zzskip",\r
-       "zzmore",\r
-       "zzreplchar",\r
-       "zzreplstr",\r
-       "zzgettok",\r
-       "zzadvance",\r
-       "zzerrstd",\r
-       "zzerr_in",\r
-       "zzconstr_attr",\r
-       "zzempty_attr",\r
-       "zzerraction",\r
-       "zztokens",                     /* list of token regular expressions */\r
-       "dfa",\r
-       "accepts",\r
-       "actions",\r
-    "zzTraceOptionValue",       /* MR10 */\r
-    "zzTraceGuessOptionValue",  /* MR10 */\r
-    "zzTraceCurrentRuleName",   /* MR10 */\r
-    "zzTraceDepth",             /* MR10 */\r
-    "zzGuessSeq",               /* MR10 */\r
-    "zzSyntaxErrCount",         /* MR11 */\r
-    "zzLexErrCount",            /* MR11 */\r
-    "zzTraceGuessDone",         /* MR13 - BJS */\r
-    "zzTraceGuessFail",         /* MR13 - BJS */\r
-    "zzTraceGuessOption",       /* MR13 - BJS */\r
-    "zzTraceIn",                /* MR13 - BJS */\r
-    "zzTraceOption",            /* MR13 - BJS */\r
-    "zzTraceOut",               /* MR13 - BJS */\r
-    "zzTraceReset",             /* MR13 - BJS */\r
-       NULL            /* must be present */\r
-};\r
-\r
-/* list of PCCTS supplied support functions; these are renamed when more than\r
- * one ANTLR-generated parsers are linked together to avoid name conflicts.\r
- */\r
-char *ASTSymbols[] = {\r
-       "AST",\r
-       "zzast_sp",\r
-       "zzastStack",\r
-       "zzlink",\r
-       "zzastnew",\r
-       "zzsubchild",\r
-       "zzsubroot",\r
-       "zzpre_ast",\r
-       "zzfree_ast",\r
-       "zztmake",\r
-       "zzdup_ast",\r
-       "zztfree",\r
-       "zzdouble_link",\r
-       NULL            /* must be present */\r
-};\r
-\r
-/* Current ambiguity examination information */\r
-int CurAmbigAlt1, CurAmbigAlt2, CurAmbigline, CurAmbigfile;\r
-char *CurAmbigbtype;\r
-\r
-\r
-                                               /* M e t h o d  T a b l e s */\r
-/*\r
- * The following tables are used to fill syntax diagram nodes with the correct\r
- * function pointers for computing FIRST sets and printing themselves.\r
- */\r
-\r
-/* fpTraverse[node type] == pointer to function that calculates trees\r
- * representing the FIRST sets for that node (maintains spatial info).\r
- * We use 'struct _tree' not 'tree' due to a g++ 2.4.3 bug.\r
- */\r
-#ifdef __cplusplus\r
-struct _tree *(*fpTraverse[NumNodeTypes+1])(... /* Node *, int, set * */) = {\r
-       NULL,\r
-       (struct _tree *(*)(...)) tJunc,\r
-       (struct _tree *(*)(...)) tRuleRef,\r
-       (struct _tree *(*)(...)) tToken,\r
-       (struct _tree *(*)(...)) tAction\r
-};\r
-#else\r
-Tree *(*fpTraverse[NumNodeTypes+1])() = {\r
-       NULL,\r
-       tJunc,\r
-       tRuleRef,\r
-       tToken,\r
-       tAction\r
-};\r
-#endif\r
-\r
-/* fpReach[node type] == pointer to function that calculates FIRST set for\r
- * that node. (r stands for reach).  We use 'struct _set' not 'set'\r
- * due to a g++ 2.4.3 bug.\r
- */\r
-#ifdef __cplusplus\r
-struct _set (*fpReach[NumNodeTypes+1])(... /* Node *, int, set * */) = {\r
-       NULL,\r
-       (struct _set (*)(...)) rJunc,\r
-       (struct _set (*)(...)) rRuleRef,\r
-       (struct _set (*)(...)) rToken,\r
-       (struct _set (*)(...)) rAction\r
-};\r
-#else\r
-set (*fpReach[NumNodeTypes+1])() = {\r
-       NULL,\r
-       rJunc,\r
-       rRuleRef,\r
-       rToken,\r
-       rAction\r
-};\r
-#endif\r
-\r
-/* fpPrint[node type] == pointer to function that knows how to print that node. */\r
-#ifdef __cplusplus\r
-void (*fpPrint[NumNodeTypes+1])(... /* Node * */) = {\r
-       NULL,\r
-       (void (*)(...)) pJunc,\r
-       (void (*)(...)) pRuleRef,\r
-       (void (*)(...)) pToken,\r
-       (void (*)(...)) pAction\r
-};\r
-#else\r
-void (*fpPrint[NumNodeTypes+1])() = {\r
-       NULL,\r
-       pJunc,\r
-       pRuleRef,\r
-       pToken,\r
-       pAction\r
-};\r
-#endif\r
-\r
-char *decodeJType[] = {\r
-       "invalid",\r
-       "aSubBlk",\r
-       "aOptBlk",\r
-       "aLoopBlk",\r
-       "EndBlk",\r
-       "RuleBlk",\r
-       "Generic",\r
-       "EndRule",\r
-       "aPlusBlk",\r
-       "aLoopBegin"\r
-};\r
-\r
-\r
-                                                       /* H a s h  T a b l e s */\r
-\r
-Entry  **Tname,                        /* Table of all token names (maps name to tok num)*/\r
-               **Texpr,                        /* Table of all token expressions\r
-                                                          (maps expr to tok num) */\r
-               **Rname,                        /* Table of all Rules (has ptr to start of rule) */\r
-               **Fcache,                       /* Cache of First/Follow Computations */\r
-               **Tcache;                       /* Tree cache; First/Follow for permute trees */\r
-Entry  **Elabel;                       /* Table of all element label names */\r
-Entry  **Sname;                        /* Signal names */\r
-Entry   **Pname;            /* symbolic predicate names MR11 */\r
-\r
-\r
-                                                       /* V a r i a b l e s */\r
-\r
-int     Save_argc;          /* MR10 */\r
-char    **Save_argv;        /* MR10 */\r
-int            EpToken=0;                      /* Imaginary Epsilon token number */\r
-int            WildCardToken=0;\r
-int            CurFile= -1;            /* Index into FileStr table */\r
-char    *CurPredName=NULL;  /* MR11 */\r
-char   *CurRule=NULL;          /* Pointer to current rule name */\r
-int     CurRuleDebug=0;     /* MR13 debug flag */\r
-RuleEntry *CurRuleNode=NULL;/* Pointer to current rule node in syntax tree */\r
-char   *CurRetDef=NULL;        /* Pointer to current return type definition */\r
-char   *CurParmDef=NULL;       /* Pointer to current parameter definition */\r
-Junction *CurRuleBlk=NULL;     /* Pointer to current block node for enclosing block */\r
-ListNode *CurExGroups=NULL;    /* Current list of exception groups for rule/alts */\r
-ListNode *CurElementLabels=NULL;\r
-ListNode *CurAstLabelsInActions=NULL; /* MR27 */\r
-\r
-/* MR10  used by <<>>? to set "label_used_in_semantic_pred"  */\r
-/* MR10  this will force LT(i) assignment even in guess mode */\r
-\r
-ListNode *CurActionLabels=NULL;     /* MR10 Element Labels appearing in last action */\r
-int      numericActionLabel=0 ;     /* MR10 << ... $1 ... >> or << ... $1 ... >>?   */\r
-ListNode *NumericPredLabels=NULL;   /* MR10 << ... $1 ... >>?  ONLY                 */\r
-ListNode *ContextGuardPredicateList=NULL;  /* MR13 for re-evaluating predicates\r
-                                                   after meta tokens are defined    */\r
-\r
-int            CurBlockID=0;           /* Unique int for each block */\r
-int            CurAltNum=0;\r
-Junction *CurAltStart = NULL;  /* Junction node that starts the alt */\r
-Junction *OuterAltStart = NULL; /* For chaining exception groups        MR7 */\r
-int            NumRules=0;                     /* Rules are from 1 to n */\r
-FILE   *output=NULL;           /* current parser output file */\r
-FILE   *input=NULL;            /* current grammar input file */\r
-char   *FileStr[MaxNumFiles];/* Ptr to array of file names on command-line */\r
-int            NumFiles=0;                     /* current grammar file number */\r
-#ifdef __cplusplus\r
-void   (**fpTrans)(...),       /* array of ptrs to funcs that translate nodes */\r
-               (**fpJTrans)(...);      /*  ... that translate junctions */\r
-#else\r
-void   (**fpTrans)(),          /* array of ptrs to funcs that translate nodes */\r
-               (**fpJTrans)();         /*  ... that translate junctions */\r
-#endif\r
-int            **FoStack;                      /* Array of LL_k ptrs to stacks of rule numbers */\r
-int            **FoTOS;                        /* FOLLOW stack top-of-stack pointers */\r
-Junction *SynDiag = NULL;      /* Pointer to start of syntax diagram */\r
-int            BlkLevel=1;                     /* Current block level.  Set by antlr.g, used by\r
-                                                        * scanner to translate $i.j attributes */\r
-set            reserved_positions;     /* set of token positions reserved by '#token T=i' cmds */\r
-set            all_tokens;                     /* set of all token types */\r
-set            imag_tokens;            /* set of all imaginary token types (EpToken, errclasses...) */\r
-set            tokclasses;                     /* set of all token class token types */\r
-ListNode *ForcedTokens = 0;    /* list of token_id/token_num pairs to remap */\r
-ListNode *MetaTokenNodes=NULL; /* list of meta token refs such as token classes etc... */\r
-int            *TokenInd=NULL;         /* an indirection level between token num and position\r
-                                                        * of that token def in TokenStr and ExprStr */\r
-int            LastTokenCounted=0;     /* ==TokenNum if no token renumbering (same as old TokenNum) */\r
-int            TokenNum=TokenStart;\r
-char   **TokenStr=NULL;        /* map token # to token name */\r
-char   **ExprStr=NULL;         /* map token # to expr */\r
-Junction **RulePtr=NULL;       /* map rule # to RuleBlk node of rule */\r
-ListNode *ExprOrder=NULL;      /* list of exprs as they are found in grammar */\r
-ListNode *BeforeActions=NULL;/* list of grammar actions before rules */\r
-ListNode *AfterActions=NULL;/* list of grammar actions after rules */\r
-ListNode *LexActions=NULL;     /* list of lexical actions */\r
-\r
-/* MR1                                                                                     */\r
-/* MR1  11-Apr-97      Provide mechanism for inserting code into DLG class     */\r
-/* MR1                         via #lexmember <<....>>                             */\r
-/* MR1                         via #lexprefix <<....>>                             */\r
-/* MR1                                                                                     */\r
-\r
-ListNode *LexMemberActions=NULL;/* list of lexical header member decl   MR1 */\r
-ListNode *LexPrefixActions=NULL;/* list of lexical header #include decl MR1 */\r
-ListNode **Cycles=NULL;                /* list of cycles (for each k) found when\r
-                                                          doing FOLLOWs */\r
-ListNode *eclasses=NULL;       /* list of error classes */\r
-ListNode *tclasses=NULL;       /* list of token classes */\r
-LClass  lclass[MaxLexClasses]; /* array of lex class definitions */\r
-int             CurrentLexClass;       /* index into lclass */\r
-int             NumLexClasses=0;       /* in range 1..MaxLexClasses (init 0) */\r
-\r
-char   *HdrAction=NULL;        /* action defined with #header */\r
-char    *FirstAction=NULL;  /* action defined with #first MR11 */\r
-FILE   *ErrFile;                       /* sets and error recovery stuff */\r
-FILE   *DefFile=NULL;          /* list of tokens, return value structs, setwd defs */\r
-FILE    *MRinfoFile=NULL;   /* MR10 information file */\r
-int     MRinfo=0;           /* MR10 */\r
-int     MRinfoSeq=0;        /* MR10 */\r
-int     InfoP=0;            /* MR10 predicates        */\r
-int     InfoT=0;            /* MR10 tnodes            */\r
-int     InfoF=0;            /* MR10 first/follow sets */\r
-int     InfoM=0;            /* MR10 monitor progress  */\r
-int     InfoO=0;            /* MR12 orphan rules      */\r
-int     TnodesInUse=0;      /* MR10 */\r
-int     TnodesPeak=0;       /* MR10 */\r
-int     TnodesAllocated=0;  /* MR10 */\r
-int     TnodesReportThreshold=0;    /* MR11 */\r
-int     PotentialSuppression=0; /* MR10 */\r
-int     PotentialDummy=0;       /* MR10 */\r
-int            CannotContinue=FALSE;\r
-int            OutputLL_k = 1;         /* LL_k for parsing must be power of 2 */\r
-int            action_file;            /* used to track start of action */\r
-int            action_line;\r
-int            FoundGuessBlk=0;        /* there is a (...)? block somewhere in grammar */\r
-int            FoundException=0;       /* there is an exception somewhere in grammar */\r
-/* MR6 Distinguish between @ operator and real exception                   */\r
-/* MR6    by keeping separate flags for @ operator and real exceptions             */\r
-int            FoundAtOperator=0;                                                           /* MR6 */\r
-int            FoundExceptionGroup=0;                                               /* MR6 */\r
-int            pLevel=0;                       /* print Level */\r
-int            pAlt1,pAlt2;            /* print "==>" in front of these alts */\r
-\r
-/* C++ output stuff */\r
-FILE   *Parser_h,                      /* where subclass of ANTLRParser goes */\r
-               *Parser_c;                      /* where code for subclass of ANTLRParser goes */\r
-char   Parser_h_Name[MaxFileName+1] = "";\r
-char   Parser_c_Name[MaxFileName+1] = "";\r
-char    MRinfoFile_Name[MaxFileName+1] = "";                /* MR10 */\r
-char    *ClassDeclStuff=NULL;                               /* MR10 */\r
-char    *BaseClassName=NULL;                                /* MR22 */\r
-/* list of actions inside the #class {...} defs */\r
-ListNode *class_before_actions=NULL;\r
-ListNode *class_after_actions=NULL;\r
-\r
-char   CurrentClassName[MaxRuleName]="";\r
-int            no_classes_found=1;\r
-char   *UserTokenDefsFile;\r
-int            UserDefdTokens=0;       /* found #tokdefs? */\r
-char   *OutputDirectory=TopDirectory;\r
-ExceptionGroup *DefaultExGroup = NULL;\r
-int            NumSignals = NumPredefinedSignals;\r
-int            ContextGuardTRAV=0;\r
-\r
-char    *MR_AmbAidRule=NULL;        /* MR11 */\r
-int     MR_AmbAidLine=0;            /* MR11 */\r
-int     MR_AmbAidDepth=0;           /* MR11 */\r
-int     MR_AmbAidMultiple=0;        /* MR11 */\r
-int     MR_skipped_e3_report=0;     /* MR11 */\r
-int     MR_usingPredNames=0;        /* MR11 */\r
-int     MR_BadExprSets=0;           /* MR13 */\r
-int     MR_Inhibit_Tokens_h_Gen=0;  /* MR13 */\r
-int     NewAST=0;                   /* MR13 */\r
-int            tmakeInParser=0;            /* MR23 */\r
-int     AlphaBetaTrace=0;           /* MR14 */\r
-int            MR_BlkErr=0;                            /* MR21 */\r
-int     MR_AlphaBetaMessageCount=0; /* MR14 */\r
-int     MR_AlphaBetaWarning=0;      /* MR14 */\r
-int     MR_ErrorSetComputationActive=0;     /* MR14 */\r
-int     MR_MaintainBackTrace=0;             /* MR14 */\r
-set     MR_CompromisedRules;        /* MR14 */\r
-\r
-Junction    *MR_RuleBlkWithHalt;    /* MR10 */\r
-\r
-                                       /* C m d - L i n e  O p t i o n s */\r
-\r
-int            LL_k=1;                         /* how many tokens of full lookahead */\r
-int            CLL_k= -1;                      /* how many tokens of compressed lookahead */\r
-int            PrintOut = FALSE;       /* print out the grammar */\r
-int            PrintAnnotate = FALSE;/* annotate printout with FIRST sets */\r
-int            CodeGen=TRUE;           /* Generate output code? */\r
-int            LexGen=TRUE;            /* Generate lexical files? (tokens.h, parser.dlg) */\r
-int            GenAST=FALSE;           /* Generate AST's? */\r
-int            GenANSI=FALSE;          /* Generate ANSI code where necessary */\r
-int            GenExprSetsOpt=TRUE;/* use sets not (LA(1)==tok) expression lists */\r
-int            GenCR=FALSE;            /* Generate cross reference? */\r
-int            GenLineInfo=FALSE;      /* Generate # line "file" stuff? */\r
-int            GenLineInfoMS=FALSE;/* Like -gl but replace "\" with "/" for MS C/C++ systems */\r
-int            TraceGen=FALSE;         /* Generate code to trace rule invocation */\r
-int            elevel=1;                       /* error level for ambiguity messages */\r
-int            GenEClasseForRules=0;/* don't generate eclass for each rule */\r
-int            TreeResourceLimit= -1;/* don't limit tree resource */\r
-int            DemandLookahead = 0;/* demand/delayed lookahead or not */\r
-char   *RulePrefix = "";       /* prefix each generated rule with this */\r
-char   *stdpccts = "stdpccts.h";/* where to generate std pccts include file */\r
-int            GenStdPccts = 0;        /* don't gen stdpccts.h? */\r
-int            ParseWithPredicates = 1;\r
-int            WarningLevel = 1;\r
-int            UseStdout = 0;                                  /* MR6 */\r
-int            TabWidth = 2;                                   /* MR6 */ /* MR27 */\r
-int            HoistPredicateContext = 0;\r
-int     MRhoisting = 0;                 /* MR9 */\r
-int     MRhoistingk = 0;                /* MR13 */\r
-int     MR_debugGenRule=0;              /* MR11 */\r
-\r
-int            GenCC = 0;                      /* Generate C++ output */\r
-\r
-PointerStack MR_BackTraceStack={0,0,NULL};            /* MR10 */\r
-PointerStack MR_PredRuleRefStack={0,0,NULL};          /* MR10 */\r
-PointerStack MR_RuleBlkWithHaltStack={0,0,NULL};      /* MR10 */\r
-\r
-/* DontCopyTokens and Pragma_DupLabeledTokens were a bad idea.  I've just\r
-   turned them off rather than backpatching the code.  Who knows?  We\r
-   may need them in the future.\r
- */\r
-int            DontCopyTokens = 1;     /* in C++, don't copy ANTLRToken passed to ANTLR */\r
-\r
-/* Remember if LT(i), LA(i), or LATEXT(i) used in an action which is not\r
-   a predicate.  If so, give a warning for novice users.\r
-*/\r
-\r
-int     LTinTokenAction = 0; /* MR23 */\r
-int     PURIFY = 1;          /* MR23 */\r
-\r
-int     CurBlockID_array[MAX_BLK_LEVEL]; /* MR23 */\r
-int     CurAltNum_array[MAX_BLK_LEVEL]; /* MR23 */\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/antlr/hash.c b/Tools/CodeTools/TianoTools/Pccts/antlr/hash.c
deleted file mode 100644 (file)
index 68fe8fd..0000000
+++ /dev/null
@@ -1,221 +0,0 @@
-/*\r
- * hash.c\r
- *\r
- * Manage hash tables.\r
- *\r
- * The following functions are visible:\r
- *\r
- *             char    *mystrdup(char *);              Make space and copy string\r
- *             Entry   **newHashTable();               Create and return initialized hash table\r
- *             Entry   *hash_add(Entry **, char *, Entry *)\r
- *             Entry   *hash_get(Entry **, char *)\r
- *\r
- * SOFTWARE RIGHTS\r
- *\r
- * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
- * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
- * company may do whatever they wish with source code distributed with\r
- * PCCTS or the code generated by PCCTS, including the incorporation of\r
- * PCCTS, or its output, into commerical software.\r
- *\r
- * We encourage users to develop software with PCCTS.  However, we do ask\r
- * that credit is given to us for developing PCCTS.  By "credit",\r
- * we mean that if you incorporate our source code into one of your\r
- * programs (commercial product, research project, or otherwise) that you\r
- * acknowledge this fact somewhere in the documentation, research report,\r
- * etc...  If you like PCCTS and have developed a nice tool with the\r
- * output, please mention that you developed it using PCCTS.  In\r
- * addition, we ask that this header remain intact in our source code.\r
- * As long as these guidelines are kept, we expect to continue enhancing\r
- * this system and expect to make other tools available as they are\r
- * completed.\r
- *\r
- * ANTLR 1.33\r
- * Terence Parr\r
- * Parr Research Corporation\r
- * with Purdue University and AHPCRC, University of Minnesota\r
- * 1989-2001\r
- */\r
-\r
-#include <stdio.h>\r
-#include "pcctscfg.h"\r
-#include "hash.h"\r
-\r
-#ifdef __USE_PROTOS\r
-#include <stdlib.h>\r
-#else\r
-#ifdef VAXC\r
-#include <stdlib.h>\r
-#else\r
-#include <malloc.h>\r
-#endif\r
-#endif\r
-#include <string.h>\r
-\r
-#define StrSame                0\r
-\r
-#define fatal(err)                                                                                                                     \\r
-                       {fprintf(stderr, "%s(%d):", __FILE__, __LINE__);                                \\r
-                       fprintf(stderr, " %s\n", err); exit(PCCTS_EXIT_FAILURE);}\r
-#define require(expr, err) {if ( !(expr) ) fatal(err);}\r
-\r
-static unsigned size = HashTableSize;\r
-static char *strings = NULL;\r
-static char *strp;\r
-static unsigned strsize = StrTableSize;\r
-\r
-/* create the hash table and string table for terminals (string table only once) */\r
-Entry **\r
-#ifdef __USE_PROTOS\r
-newHashTable( void )\r
-#else\r
-newHashTable( )\r
-#endif\r
-{\r
-       Entry **table;\r
-       \r
-       table = (Entry **) calloc(size, sizeof(Entry *));\r
-       require( table != NULL, "cannot allocate hash table");\r
-       if ( strings == NULL )\r
-       {\r
-               strings = (char *) calloc(strsize, sizeof(char));\r
-               require( strings != NULL, "cannot allocate string table");\r
-               strp = strings;\r
-       }\r
-       return table;\r
-}\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-killHashTable( Entry **table )\r
-#else\r
-killHashTable( table )\r
-Entry **table;\r
-#endif\r
-{\r
-       /* for now, just free table, forget entries */\r
-       free( (char *) table );     /* MR10 cast */\r
-}\r
-\r
-/* Given a table, add 'rec' with key 'key' (add to front of list). return ptr to entry */\r
-Entry *\r
-#ifdef __USE_PROTOS\r
-hash_add( Entry **table, char *key, Entry *rec )\r
-#else\r
-hash_add( table, key, rec )\r
-Entry **table;\r
-char *key;\r
-Entry *rec;\r
-#endif\r
-{\r
-       unsigned h=0;\r
-       char *p=key;\r
-       require(table!=NULL && key!=NULL && rec!=NULL, "add: invalid addition");\r
-       \r
-       Hash(p,h,size);\r
-       rec->next = table[h];                   /* Add to singly-linked list */\r
-       table[h] = rec;\r
-       return rec;\r
-}\r
-\r
-/* Return ptr to 1st entry found in table under key (return NULL if none found) */\r
-Entry *\r
-#ifdef __USE_PROTOS\r
-hash_get( Entry **table, char *key )\r
-#else\r
-hash_get( table, key )\r
-Entry **table;\r
-char *key;\r
-#endif\r
-{\r
-       unsigned h=0;\r
-       char *p=key;\r
-       Entry *q;\r
-/*     require(table!=NULL && key!=NULL, "get: invalid table and/or key");*/\r
-       if ( !(table!=NULL && key!=NULL) ) *((char *) 34) = 3;\r
-       \r
-       Hash(p,h,size);\r
-       for (q = table[h]; q != NULL; q = q->next)\r
-       {\r
-               if ( strcmp(key, q->str) == StrSame ) return( q );\r
-       }\r
-       return( NULL );\r
-}\r
-\r
-#ifdef DEBUG_HASH\r
-void\r
-#ifdef __USE_PROTOS\r
-hashStat( Entry **table )\r
-#else\r
-hashStat( table )\r
-Entry **table;\r
-#endif\r
-{\r
-       static unsigned short count[20];\r
-       int i,n=0,low=0, hi=0;\r
-       Entry **p;\r
-       float avg=0.0;\r
-       \r
-       for (i=0; i<20; i++) count[i] = 0;\r
-       for (p=table; p<&(table[size]); p++)\r
-       {\r
-               Entry *q = *p;\r
-               int len;\r
-               \r
-               if ( q != NULL && low==0 ) low = p-table;\r
-               len = 0;\r
-               if ( q != NULL ) fprintf(stderr, "[%d]", p-table);\r
-               while ( q != NULL )\r
-               {\r
-                       len++;\r
-                       n++;\r
-                       fprintf(stderr, " %s", q->str);\r
-                       q = q->next;\r
-                       if ( q == NULL ) fprintf(stderr, "\n");\r
-               }\r
-               count[len]++;\r
-               if ( *p != NULL ) hi = p-table;\r
-       }\r
-\r
-       fprintf(stderr, "Storing %d recs used %d hash positions out of %d\n",\r
-                                       n, size-count[0], size);\r
-       fprintf(stderr, "%f %% utilization\n",\r
-                                       ((float)(size-count[0]))/((float)size));\r
-       for (i=0; i<20; i++)\r
-       {\r
-               if ( count[i] != 0 )\r
-               {\r
-                       avg += (((float)(i*count[i]))/((float)n)) * i;\r
-                       fprintf(stderr, "Bucket len %d == %d (%f %% of recs)\n",\r
-                                                       i, count[i], ((float)(i*count[i]))/((float)n));\r
-               }\r
-       }\r
-       fprintf(stderr, "Avg bucket length %f\n", avg);\r
-       fprintf(stderr, "Range of hash function: %d..%d\n", low, hi);\r
-}\r
-#endif\r
-\r
-/* Add a string to the string table and return a pointer to it.\r
- * Bump the pointer into the string table to next avail position.\r
- */\r
-char *\r
-#ifdef __USE_PROTOS\r
-mystrdup( char *s )\r
-#else\r
-mystrdup( s )\r
-char *s;\r
-#endif\r
-{\r
-       char *start=strp;\r
-       require(s!=NULL, "mystrdup: NULL string");\r
-\r
-       while ( *s != '\0' )\r
-       {\r
-               require( strp <= &(strings[strsize-2]),\r
-                                "string table overflow\nIncrease StrTableSize in hash.h and recompile hash.c\n");\r
-               *strp++ = *s++;\r
-       }\r
-       *strp++ = '\0';\r
-\r
-       return( start );\r
-}\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/antlr/hash.h b/Tools/CodeTools/TianoTools/Pccts/antlr/hash.h
deleted file mode 100644 (file)
index 3969c40..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-/*\r
- * hash.h -- define hash table entries, sizes, hash function...\r
- *\r
- * SOFTWARE RIGHTS\r
- *\r
- * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
- * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
- * company may do whatever they wish with source code distributed with\r
- * PCCTS or the code generated by PCCTS, including the incorporation of\r
- * PCCTS, or its output, into commerical software.\r
- *\r
- * We encourage users to develop software with PCCTS.  However, we do ask\r
- * that credit is given to us for developing PCCTS.  By "credit",\r
- * we mean that if you incorporate our source code into one of your\r
- * programs (commercial product, research project, or otherwise) that you\r
- * acknowledge this fact somewhere in the documentation, research report,\r
- * etc...  If you like PCCTS and have developed a nice tool with the\r
- * output, please mention that you developed it using PCCTS.  In\r
- * addition, we ask that this header remain intact in our source code.\r
- * As long as these guidelines are kept, we expect to continue enhancing\r
- * this system and expect to make other tools available as they are\r
- * completed.\r
- *\r
- * ANTLR 1.33\r
- * Terence Parr\r
- * Parr Research Corporation\r
- * with Purdue University and AHPCRC, University of Minnesota\r
- * 1989-2001\r
- */\r
-\r
-                               /* H a s h  T a b l e  S t u f f */\r
-\r
-#ifndef HashTableSize\r
-#define HashTableSize  553\r
-#endif\r
-\r
-#ifndef StrTableSize\r
-#ifdef PC32\r
-#define StrTableSize   1000000\r
-#endif\r
-#endif\r
-\r
-#ifndef StrTableSize\r
-#ifdef PC\r
-#define StrTableSize 655200\r
-#endif\r
-#endif\r
-\r
-#ifndef StrTableSize\r
-#define StrTableSize 1000000\r
-#endif\r
-\r
-typedef struct _entry {                /* Minimum hash table entry -- superclass */\r
-                       char *str;\r
-                       struct _entry *next;\r
-               } Entry;\r
-\r
-/* Hash 's' using 'size', place into h (s is modified) */\r
-#define Hash(s,h,size)                                                         \\r
-       {while ( *s != '\0' ) h = (h<<1) + *s++;                \\r
-       h %= size;}\r
-\r
-#ifdef __USE_PROTOS\r
-Entry  *hash_get(Entry **, char *),\r
-               **newHashTable(void),\r
-               *hash_add(Entry **, char *, Entry *);\r
-\r
-void   killHashTable(Entry **);\r
-\r
-#else\r
-Entry *hash_get(), **newHashTable(), *hash_add();\r
-void   killHashTable();        /* MR9 23-Sep-97 */\r
-#endif\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/antlr/lex.c b/Tools/CodeTools/TianoTools/Pccts/antlr/lex.c
deleted file mode 100644 (file)
index 8c524fe..0000000
+++ /dev/null
@@ -1,878 +0,0 @@
-/*\r
- * lex.c       --      Generate all of the lexical type files: parser.dlg tokens.h\r
- *\r
- * SOFTWARE RIGHTS\r
- *\r
- * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
- * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
- * company may do whatever they wish with source code distributed with\r
- * PCCTS or the code generated by PCCTS, including the incorporation of\r
- * PCCTS, or its output, into commerical software.\r
- *\r
- * We encourage users to develop software with PCCTS.  However, we do ask\r
- * that credit is given to us for developing PCCTS.  By "credit",\r
- * we mean that if you incorporate our source code into one of your\r
- * programs (commercial product, research project, or otherwise) that you\r
- * acknowledge this fact somewhere in the documentation, research report,\r
- * etc...  If you like PCCTS and have developed a nice tool with the\r
- * output, please mention that you developed it using PCCTS.  In\r
- * addition, we ask that this header remain intact in our source code.\r
- * As long as these guidelines are kept, we expect to continue enhancing\r
- * this system and expect to make other tools available as they are\r
- * completed.\r
- *\r
- * ANTLR 1.33\r
- * Terence Parr\r
- * Parr Research Corporation\r
- * with Purdue University and AHPCRC, University of Minnesota\r
- * 1989-2001\r
- */\r
-\r
-#include <stdio.h>\r
-#include <ctype.h>\r
-/* MR1                                                                                         */\r
-/* MR1  10-Apr-97  MR1 Replace use of __STDC__ with __USE_PROTOS           */\r
-/* MR1                                                                                 */\r
-#include "pcctscfg.h"\r
-#include "set.h"\r
-#include "syn.h"\r
-#include "hash.h"\r
-#include "generic.h"\r
-\r
-#define DLGErrorString "invalid token"\r
-\r
-/* Generate a complete lexical description of the lexemes found in the grammar */\r
-void\r
-#ifdef __USE_PROTOS\r
-genLexDescr( void )\r
-#else\r
-genLexDescr( )\r
-#endif\r
-{\r
-       ListNode *p;\r
-       FILE *dlgFile = fopen(OutMetaName(DlgFileName), "w");\r
-       require(dlgFile!=NULL, eMsg1("genLexFile: cannot open %s", OutMetaName(DlgFileName)) );\r
-#ifdef SPECIAL_FOPEN\r
-       special_fopen_actions(OutMetaName(DlgFileName));                     /* MR1 */\r
-#endif\r
-       fprintf(dlgFile, "<<\n");\r
-       fprintf(dlgFile, "/* %s -- DLG Description of scanner\n", DlgFileName);\r
-       fprintf(dlgFile, " *\n");\r
-       fprintf(dlgFile, " * Generated from:");\r
-       {int i; for (i=0; i<NumFiles; i++) fprintf(dlgFile, " %s", FileStr[i]);}\r
-       fprintf(dlgFile, "\n");\r
-       fprintf(dlgFile, " *\n");\r
-       fprintf(dlgFile, " * Terence Parr, Will Cohen, and Hank Dietz: 1989-2001\n");\r
-       fprintf(dlgFile, " * Purdue University Electrical Engineering\n");\r
-       fprintf(dlgFile, " * With AHPCRC, University of Minnesota\n");\r
-       fprintf(dlgFile, " * ANTLR Version %s\n", Version);\r
-       fprintf(dlgFile, " */\n\n");\r
-    if (FirstAction != NULL ) dumpAction( FirstAction, dlgFile, 0, -1, 0, 1 );  /* MR11 MR15b */\r
-    fprintf(dlgFile, "#define ANTLR_VERSION    %s\n", VersionDef);\r
-       if ( GenCC )\r
-       {\r
-               if ( !UserDefdTokens ) fprintf(dlgFile, "#include \"%s\"\n", DefFileName);\r
-               else fprintf(dlgFile, "#include %s\n", UserTokenDefsFile);\r
-               fprintf(dlgFile, "#include \"%s\"\n", ATOKEN_H);\r
-               if ( GenAST ) fprintf(dlgFile, "#include \"%s\"\n", ASTBASE_H);\r
-               if ( HdrAction != NULL ) dumpAction( HdrAction, dlgFile, 0, -1, 0, 1 );\r
-       }\r
-       else\r
-       {\r
-               fprintf(dlgFile, "#include \"pcctscfg.h\"\n");\r
-               fprintf(dlgFile, "#include \"pccts_stdio.h\"\n");\r
-               if ( strcmp(ParserName, DefaultParserName)!=0 )\r
-                       fprintf(dlgFile, "#define %s %s\n", DefaultParserName, ParserName);\r
-               if ( strcmp(ParserName, DefaultParserName)!=0 )\r
-                       fprintf(dlgFile, "#include \"%s\"\n", RemapFileName);\r
-               if ( HdrAction != NULL ) dumpAction( HdrAction, dlgFile, 0, -1, 0, 1 );\r
-               if ( FoundGuessBlk )\r
-               {\r
-                       fprintf(dlgFile, "#define ZZCAN_GUESS\n");\r
-                       fprintf(dlgFile, "#include \"pccts_setjmp.h\"\n");\r
-               }\r
-               if ( OutputLL_k > 1 ) fprintf(dlgFile, "#define LL_K %d\n", OutputLL_k);\r
-               if ( DemandLookahead ) fprintf(dlgFile, "#define DEMAND_LOOK\n");\r
-        if (TraceGen) {\r
-          fprintf(dlgFile,"#ifndef zzTRACE_RULES\n");  /* MR20 */\r
-          fprintf(dlgFile,"#define zzTRACE_RULES\n");  /* MR20 */\r
-          fprintf(dlgFile,"#endif\n");  /* MR22 */\r
-        };\r
-               fprintf(dlgFile, "#include \"antlr.h\"\n");\r
-               if ( GenAST ) {\r
-                       fprintf(dlgFile, "#include \"ast.h\"\n");\r
-               }\r
-               if ( UserDefdTokens )\r
-                       fprintf(dlgFile, "#include %s\n", UserTokenDefsFile);\r
-               /* still need this one as it has the func prototypes */\r
-               fprintf(dlgFile, "#include \"%s\"\n", DefFileName);\r
-               fprintf(dlgFile, "#include \"dlgdef.h\"\n");\r
-               fprintf(dlgFile, "LOOKAHEAD\n");\r
-               fprintf(dlgFile, "\n");\r
-               fprintf(dlgFile, "void\n");\r
-               fprintf(dlgFile, "#ifdef __USE_PROTOS\n");\r
-               fprintf(dlgFile, "zzerraction(void)\n");\r
-               fprintf(dlgFile, "#else\n");\r
-               fprintf(dlgFile, "zzerraction()\n");\r
-               fprintf(dlgFile, "#endif\n");\r
-               fprintf(dlgFile, "{\n");\r
-               fprintf(dlgFile, "\t(*zzerr)(\"%s\");\n", DLGErrorString);\r
-               fprintf(dlgFile, "\tzzadvance();\n");\r
-               fprintf(dlgFile, "\tzzskip();\n");\r
-               fprintf(dlgFile, "}\n");\r
-       }\r
-       fprintf(dlgFile, ">>\n\n");\r
-\r
-       /* dump all actions */\r
-\r
-/* MR1                                                                                                     */\r
-/* MR1  11-Apr-97      Provide mechanism for inserting code into DLG class     */\r
-/* MR1                   via <<%%lexmember ....>> & <<%%lexprefix ...>>            */\r
-/* MR1                                                                                     */\r
-          if (LexActions != NULL) {\r
-            for (p = LexActions->next; p!=NULL; p=p->next)\r
-               {\r
-/* MR1 */      fprintf(dlgFile, "<<%%%%lexaction\n");\r
-                       dumpAction( (char *)p->elem, dlgFile, 0, -1, 0, 1 );\r
-                       fprintf(dlgFile, ">>\n\n");\r
-               }\r
-         };\r
-\r
-/* MR1 */ if (GenCC) {\r
-/* MR1 */   fprintf(dlgFile,"<<%%%%parserclass %s>>\n\n",CurrentClassName);\r
-/* MR1 */ };\r
-\r
-/* MR1 */ if (LexPrefixActions != NULL) {\r
-/* MR1 */   for (p = LexPrefixActions->next; p!=NULL; p=p->next)\r
-/* MR1 */       {\r
-/* MR1 */               fprintf(dlgFile, "<<%%%%lexprefix\n");\r
-/* MR1 */               dumpAction( (char *)p->elem, dlgFile, 0, -1, 0, 1 );\r
-/* MR1 */               fprintf(dlgFile, ">>\n\n");\r
-/* MR1 */       }\r
-/* MR1 */ };\r
-\r
-/* MR1 */ if (LexMemberActions != NULL) {\r
-/* MR1 */   for (p = LexMemberActions->next; p!=NULL; p=p->next)\r
-/* MR1 */       {\r
-/* MR1 */               fprintf(dlgFile, "<<%%%%lexmember\n");\r
-/* MR1 */               dumpAction( (char *)p->elem, dlgFile, 0, -1, 0, 1 );\r
-/* MR1 */               fprintf(dlgFile, ">>\n\n");\r
-/* MR1 */       }\r
-/* MR1 */ };\r
-\r
-       /* dump all regular expression rules/actions (skip sentinel node) */\r
-       if ( ExprOrder == NULL ) {\r
-               warnNoFL("no regular expressions found in grammar");\r
-       }\r
-       else dumpLexClasses(dlgFile);\r
-       fprintf(dlgFile, "%%%%\n");\r
-       fclose( dlgFile );\r
-}\r
-\r
-/* For each lexical class, scan ExprOrder looking for expressions\r
- * in that lexical class.  Print out only those that match.\r
- * Each element of the ExprOrder list has both an expr and an lclass\r
- * field.\r
- */\r
-void\r
-#ifdef __USE_PROTOS\r
-dumpLexClasses( FILE *dlgFile )\r
-#else\r
-dumpLexClasses( dlgFile )\r
-FILE *dlgFile;\r
-#endif\r
-{\r
-       int i;\r
-       TermEntry *t;\r
-       ListNode *p;\r
-       Expr *q;\r
-\r
-       for (i=0; i<NumLexClasses; i++)\r
-       {\r
-               fprintf(dlgFile, "\n%%%%%s\n\n", lclass[i].classnum);\r
-               for (p=ExprOrder->next; p!=NULL; p=p->next)\r
-               {\r
-                       q = (Expr *) p->elem;\r
-                       if ( q->lclass != i ) continue;\r
-                       lexmode(i);\r
-                       t = (TermEntry *) hash_get(Texpr, q->expr);\r
-                       require(t!=NULL, eMsg1("genLexDescr: rexpr %s not in hash table",q->expr) );\r
-                       if ( t->token == EpToken ) continue;\r
-                       fprintf(dlgFile, "%s\n\t<<\n", StripQuotes(q->expr));\r
-                       /* replace " killed by StripQuotes() */\r
-                       q->expr[ strlen(q->expr) ] = '"';\r
-                       if ( !GenCC ) {\r
-                               if ( TokenString(t->token) != NULL )\r
-                                       fprintf(dlgFile, "\t\tNLA = %s;\n", TokenString(t->token));\r
-                               else\r
-                                       fprintf(dlgFile, "\t\tNLA = %d;\n", t->token);\r
-                       }\r
-                       if ( t->action != NULL ) dumpAction( t->action, dlgFile, 2,-1,0,1 );\r
-                       if ( GenCC ) {\r
-                               if ( TokenString(t->token) != NULL )\r
-                                       fprintf(dlgFile, "\t\treturn %s;\n", TokenString(t->token));\r
-                               else\r
-                                       fprintf(dlgFile, "\t\treturn (ANTLRTokenType)%d;\n", t->token);\r
-                       }\r
-                       fprintf(dlgFile, "\t>>\n\n");\r
-               }\r
-       }\r
-}\r
-\r
-/* Strip the leading path (if any) from a filename */\r
-char *\r
-#ifdef __USE_PROTOS\r
-StripPath( char *fileName )\r
-#else\r
-StripPath( fileName )\r
-char *fileName;\r
-#endif\r
-{\r
-       char *p;\r
-       static char dirSym[2] = DirectorySymbol;\r
-\r
-       if(NULL != (p = strrchr(fileName, dirSym[0])))\r
-               p++;\r
-       else\r
-               p = fileName;\r
-\r
-       return(p);\r
-}\r
-\r
-/* Generate a list of #defines && list of struct definitions for\r
- * aggregate retv's */\r
-void\r
-#ifdef __USE_PROTOS\r
-genDefFile( void )\r
-#else\r
-genDefFile( )\r
-#endif\r
-{\r
-       int i;\r
-\r
-       /* If C++ mode and #tokdef used, then don't need anything in here since\r
-        * C++ puts all definitions in the class file name.\r
-        */\r
-       if ( GenCC && UserTokenDefsFile ) return;\r
-    if ( MR_Inhibit_Tokens_h_Gen) return;\r
-\r
-       DefFile = fopen(OutMetaName(DefFileName), "w");\r
-       require(DefFile!=NULL, eMsg1("genDefFile: cannot open %s", OutMetaName(DefFileName)) );\r
-#ifdef SPECIAL_FOPEN\r
-       special_fopen_actions(OutMetaName(DefFileName));                     /* MR1 */\r
-#endif\r
-       fprintf(DefFile, "#ifndef %s\n", StripPath(gate_symbol(DefFileName)));\r
-       fprintf(DefFile, "#define %s\n", StripPath(gate_symbol(DefFileName)));\r
-\r
-       fprintf(DefFile, "/* %s -- List of labelled tokens and stuff\n", DefFileName);\r
-       fprintf(DefFile, " *\n");\r
-       fprintf(DefFile, " * Generated from:");\r
-       for (i=0; i<NumFiles; i++) fprintf(DefFile, " %s", FileStr[i]);\r
-       fprintf(DefFile, "\n");\r
-       fprintf(DefFile, " *\n");\r
-       fprintf(DefFile, " * Terence Parr, Will Cohen, and Hank Dietz: 1989-2001\n");\r
-       fprintf(DefFile, " * Purdue University Electrical Engineering\n");\r
-       fprintf(DefFile, " * ANTLR Version %s\n", Version);\r
-       fprintf(DefFile, " */\n");\r
-\r
-       if ( !GenCC && LexGen ) {\r
-               fprintf(DefFile,"#define zzEOF_TOKEN %d\n",\r
-                               TokenInd!=NULL?TokenInd[EofToken]:EofToken);\r
-       }\r
-\r
-       if ( !UserDefdTokens )\r
-       {\r
-               int first=1;\r
-\r
-               if ( GenCC ) fprintf(DefFile, "enum ANTLRTokenType {\n");\r
-               for (i=1; i<TokenNum; i++)\r
-               {\r
-                       /* Don't do EpToken or expr w/o labels */\r
-                       if ( TokenString(i)!=NULL && i != EpToken )\r
-                       {\r
-                               TermEntry *p;\r
-                               \r
-                               if ( WarningLevel>1 )\r
-                               {\r
-                                       int j;\r
-                                       /* look in all lexclasses for the reg expr */\r
-\r
-/* MR10  Derek Pappas                                                */\r
-/* MR10     A #tokclass doesn't have associated regular expressiones */\r
-/* MR10        so don't warn user about it's omission                */\r
-\r
-                    p = (TermEntry *) hash_get(Tname, TokenString(i));\r
-\r
-                    if (p != NULL && ! p->classname) {\r
-                                       for (j=0; j<NumLexClasses; j++)\r
-                                       {\r
-                                               lexmode(j);\r
-                                               if ( ExprString(i)!=NULL ) break;\r
-                                       }\r
-                                       if ( j>=NumLexClasses )\r
-                                       {\r
-                                               warnNoFL(eMsg1("token label has no associated rexpr: %s",TokenString(i)));\r
-                                       }\r
-                    };\r
-                               }\r
-                               require((p=(TermEntry *)hash_get(Tname, TokenString(i))) != NULL,\r
-                                               "token not in sym tab when it should be");\r
-                               if ( !p->classname )\r
-                               {\r
-                                       if ( GenCC ) {\r
-                                               if ( !first ) fprintf(DefFile, ",\n");\r
-                                               first = 0;\r
-                                               fprintf(DefFile, "\t%s=%d", TokenString(i), i);\r
-                                       }\r
-                                       else\r
-                                               fprintf(DefFile, "#define %s %d\n", TokenString(i), i);\r
-                               }\r
-                       }\r
-               }\r
-/* MR1                                                                                                     */\r
-/* MR1  10-Apr-97 133MR1       Prevent use of varying sizes of integer     */\r
-/* MR1                         for the enum ANTLRTokenType                             */\r
-/* MR1                                                                    */\r
-               if ( GenCC ) {                                                           /* MR1 */\r
-                        if ( !first ) fprintf(DefFile, ",\n");                  /* MR14 */\r
-                    fprintf(DefFile, "\tDLGminToken=0");                 /* MR1 */\r
-                    fprintf(DefFile, ",\n\tDLGmaxToken=9999};\n");          /* MR1 */\r
-                };                                                                          /* MR1 */\r
-       }\r
-\r
-       if ( !GenCC ) GenRulePrototypes(DefFile, SynDiag);\r
-\r
-       fprintf(DefFile, "\n#endif\n");\r
-}\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-GenRemapFile( void )\r
-#else\r
-GenRemapFile( )\r
-#endif\r
-{\r
-       if ( strcmp(ParserName, DefaultParserName)!=0 )\r
-       {\r
-               FILE *f;\r
-               int i;\r
-\r
-               f = fopen(OutMetaName(RemapFileName), "w");\r
-               require(f!=NULL, eMsg1("GenRemapFile: cannot open %s", OutMetaName(RemapFileName)) );\r
-#ifdef SPECIAL_FOPEN\r
-               special_fopen_actions(OutMetaName(RemapFileName));           /* MR1 */\r
-#endif\r
-               fprintf(f, "/* %s -- List of symbols to remap\n", RemapFileName);\r
-               fprintf(f, " *\n");\r
-               fprintf(f, " * Generated from:");\r
-               for (i=0; i<NumFiles; i++) fprintf(f, " %s", FileStr[i]);\r
-               fprintf(f, "\n");\r
-               fprintf(f, " *\n");\r
-               fprintf(f, " * Terence Parr, Will Cohen, and Hank Dietz: 1989-2001\n");\r
-               fprintf(f, " * Purdue University Electrical Engineering\n");\r
-               fprintf(f, " * ANTLR Version %s\n", Version);\r
-               fprintf(f, " */\n");\r
-\r
-               GenRuleFuncRedefs(f, SynDiag);\r
-               GenPredefinedSymbolRedefs(f);\r
-               if ( GenAST ) GenASTSymbolRedefs(f);\r
-               GenSetRedefs(f);\r
-\r
-               fclose(f);\r
-       }\r
-}\r
-\r
-/* Generate a bunch of #defines that rename all functions to be "ParserName_func" */\r
-void\r
-#ifdef __USE_PROTOS\r
-GenRuleFuncRedefs( FILE *f, Junction *p )\r
-#else\r
-GenRuleFuncRedefs( f, p )\r
-FILE *f;\r
-Junction *p;\r
-#endif\r
-{\r
-       fprintf(f, "\n/* rename rule functions to be 'ParserName_func' */\n");\r
-       while ( p!=NULL )\r
-       {\r
-               fprintf(f, "#define %s %s_%s\n", p->rname, ParserName, p->rname);\r
-               p = (Junction *)p->p2;\r
-       }\r
-}\r
-\r
-/* Generate a bunch of #defines that rename all standard symbols to be\r
- * "ParserName_symbol".  The list of standard symbols to change is in\r
- * globals.c.\r
- */\r
-void\r
-#ifdef __USE_PROTOS\r
-GenPredefinedSymbolRedefs( FILE *f )\r
-#else\r
-GenPredefinedSymbolRedefs( f )\r
-FILE *f;\r
-#endif\r
-{\r
-       char **p;\r
-\r
-       fprintf(f, "\n/* rename PCCTS-supplied symbols to be 'ParserName_symbol' */\n");\r
-       for (p = &StandardSymbols[0]; *p!=NULL; p++)\r
-       {\r
-               fprintf(f, "#define %s %s_%s\n", *p, ParserName, *p);\r
-       }\r
-}\r
-\r
-/* Generate a bunch of #defines that rename all AST symbols to be\r
- * "ParserName_symbol".  The list of AST symbols to change is in\r
- * globals.c.\r
- */\r
-void\r
-#ifdef __USE_PROTOS\r
-GenASTSymbolRedefs( FILE *f )\r
-#else\r
-GenASTSymbolRedefs( f )\r
-FILE *f;\r
-#endif\r
-{\r
-       char **p;\r
-\r
-       fprintf(f, "\n/* rename PCCTS-supplied AST symbols to be 'ParserName_symbol' */\n");\r
-       for (p = &ASTSymbols[0]; *p!=NULL; p++)\r
-       {\r
-               fprintf(f, "#define %s %s_%s\n", *p, ParserName, *p);\r
-       }\r
-}\r
-\r
-/* redefine all sets generated by ANTLR; WARNING:  'zzerr', 'setwd' must match\r
- * use in bits.c (DumpSetWd() etc...)\r
- */\r
-void\r
-#ifdef __USE_PROTOS\r
-GenSetRedefs( FILE *f )\r
-#else\r
-GenSetRedefs( f )\r
-FILE *f;\r
-#endif\r
-{\r
-       int i;\r
-\r
-       for (i=1; i<=wordnum; i++)\r
-       {\r
-               fprintf(f, "#define setwd%d %s_setwd%d\n", i, ParserName, i);\r
-       }\r
-       for (i=1; i<=esetnum; i++)\r
-       {\r
-               fprintf(f, "#define zzerr%d %s_err%d\n", i, ParserName, i);\r
-       }\r
-}\r
-\r
-/* Find all return types/parameters that require structs and def\r
- * all rules with ret types.\r
- *\r
- * This is for the declaration, not the definition.\r
- */\r
-void\r
-#ifdef __USE_PROTOS\r
-GenRulePrototypes( FILE *f, Junction *p )\r
-#else\r
-GenRulePrototypes( f, p )\r
-FILE *f;\r
-Junction *p;\r
-#endif\r
-{\r
-       int i;\r
-\r
-       i = 1;\r
-       while ( p!=NULL )\r
-       {\r
-               if ( p->ret != NULL )\r
-               {\r
-/* MR23 */     if ( hasMultipleOperands(p->ret) )\r
-                       {\r
-                               DumpRetValStruct(f, p->ret, i);\r
-                       }\r
-                       fprintf(f, "\n#ifdef __USE_PROTOS\n");\r
-/* MR23 */     if ( hasMultipleOperands(p->ret) ) \r
-                       {\r
-                               fprintf(f, "extern struct _rv%d", i);\r
-                       }\r
-                       else\r
-                       {\r
-                               fprintf(f, "extern ");\r
-                               DumpType(p->ret, f);\r
-                       }\r
-                       fprintf(f, " %s%s(", RulePrefix, p->rname);\r
-                       DumpANSIFunctionArgDef(f,p,1 /* emit initializers ? */);\r
-                       fprintf(f, ";\n");\r
-                       fprintf(f, "#else\n");\r
-/* MR23 */     if ( hasMultipleOperands(p->ret) )\r
-                       {\r
-                               fprintf(f, "extern struct _rv%d", i);\r
-                       }\r
-                       else\r
-                       {\r
-                               fprintf(f, "extern ");\r
-                               DumpType(p->ret, f);\r
-                       }\r
-                       fprintf(f, " %s%s();\n", RulePrefix, p->rname);\r
-                       fprintf(f, "#endif\n");\r
-               }\r
-               else\r
-               {\r
-                       fprintf(f, "\n#ifdef __USE_PROTOS\n");\r
-                       fprintf(f, "void %s%s(", RulePrefix, p->rname);\r
-                       DumpANSIFunctionArgDef(f,p, 1 /* emit initializers ? */ );\r
-                       fprintf(f, ";\n");\r
-#ifdef OLD\r
-                       if ( p->pdecl != NULL || GenAST )\r
-                       {\r
-                               if ( GenAST ) {\r
-                                       fprintf(f, "AST **%s",(p->pdecl!=NULL)?",":"");\r
-                               }\r
-                               if ( p->pdecl!=NULL ) fprintf(f, "%s", p->pdecl);\r
-                       }\r
-                       else fprintf(f, "void");\r
-                       fprintf(f, ");\n");\r
-#endif\r
-                       fprintf(f, "#else\n");\r
-                       fprintf(f, "extern void %s%s();\n", RulePrefix, p->rname);\r
-                       fprintf(f, "#endif\n");\r
-               }\r
-               i++;\r
-               p = (Junction *)p->p2;\r
-       }\r
-}\r
-\r
-/* Define all rules in the class.h file; generate any required\r
- * struct definitions first, however.\r
- */\r
-void\r
-#ifdef __USE_PROTOS\r
-GenRuleMemberDeclarationsForCC( FILE *f, Junction *q )\r
-#else\r
-GenRuleMemberDeclarationsForCC( f, q )\r
-FILE *f;\r
-Junction *q;\r
-#endif\r
-{\r
-       Junction *p = q;\r
-       int i;\r
-\r
-       fprintf(f, "private:\n");\r
-\r
-       /* Dump dflt handler declaration */\r
-       fprintf(f, "\tvoid zzdflthandlers( int _signal, int *_retsignal );\n\n");\r
-\r
-       fprintf(f, "public:\n");\r
-\r
-       /* Dump return value structs */\r
-       i = 1;\r
-       while ( p!=NULL )\r
-       {\r
-               if ( p->ret != NULL )\r
-               {\r
-/* MR23 */     if ( hasMultipleOperands(p->ret) )\r
-                       {\r
-                               DumpRetValStruct(f, p->ret, i);\r
-                       }\r
-               }\r
-               i++;\r
-               p = (Junction *)p->p2;\r
-       }\r
-\r
-       /* Dump member func defs && CONSTRUCTOR */\r
-       fprintf(f, "\t%s(ANTLRTokenBuffer *input);\n", CurrentClassName);\r
-/*\r
-       fprintf(f, "\t%s(ANTLRTokenBuffer *input, ANTLRTokenType eof);\n",\r
-                          CurrentClassName);\r
-*/\r
-\r
-       i = 1;\r
-       p = q;\r
-       while ( p!=NULL )\r
-       {\r
-               if ( p->ret != NULL )\r
-               {\r
-/* MR23 */     if ( hasMultipleOperands(p->ret) )\r
-                       {\r
-                               fprintf(f, "\tstruct _rv%d", i);\r
-                       }\r
-                       else\r
-                       {\r
-                               fprintf(f, "\t");\r
-                               DumpType(p->ret, f);\r
-                       }\r
-                       fprintf(f, " %s%s(",RulePrefix,p->rname);\r
-                       DumpANSIFunctionArgDef(f,p, 1 /* emit initializers ? */ );\r
-                       fprintf(f, ";\n");\r
-#ifdef OLD\r
-                       if ( p->pdecl != NULL || GenAST )\r
-                       {\r
-                               if ( GenAST ) fprintf(f, "ASTBase **%s",(p->pdecl!=NULL)?",":"");\r
-                               if ( p->pdecl!=NULL ) fprintf(f, "%s", p->pdecl);\r
-                       }\r
-                       fprintf(f, ");\n");\r
-#endif\r
-               }\r
-               else\r
-               {\r
-                       fprintf(f, "\tvoid %s%s(",RulePrefix,p->rname);\r
-                       DumpANSIFunctionArgDef(f,p, 1 /* emit initializers ? */);\r
-                       fprintf(f, ";\n");\r
-#ifdef OLD\r
-                       if ( p->pdecl != NULL || GenAST )\r
-                       {\r
-                               if ( GenAST ) fprintf(f, "ASTBase **%s",(p->pdecl!=NULL)?",":"");\r
-                               if ( p->pdecl!=NULL ) fprintf(f, "%s", p->pdecl);\r
-                       }\r
-                       fprintf(f, ");\n");\r
-#endif\r
-               }\r
-               i++;\r
-               p = (Junction *)p->p2;\r
-       }\r
-}\r
-\r
-/* Given a list of ANSI-style parameter declarations, print out a\r
- * comma-separated list of the symbols (w/o types).\r
- * Basically, we look for a comma, then work backwards until start of\r
- * the symbol name.  Then print it out until 1st non-alnum char.  Now,\r
- * move on to next parameter.\r
- *\r
- */\r
-\r
-/* MR5         Jan Mikkelsen 26-May-97 - added initalComma parameter              */\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-DumpListOfParmNames(char *pdecl, FILE *output, int initialComma)    /* MR5 */\r
-#else\r
-DumpListOfParmNames(pdecl, output, initialComma)                           /* MR5 */\r
-char *pdecl;                                                                           /* MR5 */\r
-FILE *output;                                                                              /* MR5 */\r
-int initialComma;                                                              /* MR5 */\r
-#endif\r
-{\r
-       int firstTime = 1, done = 0;\r
-       require(output!=NULL, "DumpListOfParmNames: NULL parm");\r
-\r
-       if ( pdecl == NULL ) return;\r
-       while ( !done )\r
-       {\r
-               if ( !firstTime || initialComma ) putc(',', output);        /* MR5 */\r
-               done = DumpNextNameInDef(&pdecl, output);\r
-               firstTime = 0;\r
-       }\r
-}\r
-\r
-/* given a list of parameters or return values, dump the next\r
- * name to output.  Return 1 if last one just printed, 0 if more to go.\r
- */\r
-\r
-/* MR23 Total rewrite */\r
-\r
-int\r
-#ifdef __USE_PROTOS\r
-DumpNextNameInDef( char **q, FILE *output )\r
-#else\r
-DumpNextNameInDef( q, output )\r
-char **q;\r
-FILE *output;\r
-#endif\r
-{\r
-       char *p;\r
-       char *t;\r
-       char *pDataType;\r
-       char *pSymbol;\r
-       char *pEqualSign;\r
-       char *pValue;\r
-       char *pSeparator;\r
-       int nest = 0;\r
-\r
-       p = endFormal(*q,\r
-                             &pDataType,\r
-                                 &pSymbol,\r
-                                 &pEqualSign,\r
-                                 &pValue,\r
-                                 &pSeparator,\r
-                                 &nest);\r
-\r
-    /* MR26 Handle rule arguments such as: IIR_Bool (IIR_Decl::*contstraint)()\r
-       For this we need to strip off anything which follows the symbol.\r
-     */\r
-\r
-/* MR26 */  t = pSymbol;\r
-/* MR26 */     if (t != NULL) {\r
-/* MR26 */             for (t = pSymbol; *t != 0; t++) {\r
-/* MR26 */                     if (! (isalpha(*t) || isdigit(*t) || *t == '_' || *t == '$')) break;\r
-/* MR26 */             }\r
-/* MR26 */     }\r
-/* MR26 */     fprintf(output,strBetween(pSymbol, t, pSeparator));\r
-\r
-    *q = p;\r
-    return (*pSeparator  == 0);\r
-}\r
-\r
-/* Given a list of ANSI-style parameter declarations, dump K&R-style\r
- * declarations, one per line for each parameter.  Basically, convert\r
- * comma to semi-colon, newline.\r
- */\r
-void\r
-#ifdef __USE_PROTOS\r
-DumpOldStyleParms( char *pdecl, FILE *output )\r
-#else\r
-DumpOldStyleParms( pdecl, output )\r
-char *pdecl;\r
-FILE *output;\r
-#endif\r
-{\r
-       require(output!=NULL, "DumpOldStyleParms: NULL parm");\r
-\r
-       if ( pdecl == NULL ) return;\r
-       while ( *pdecl != '\0' )\r
-       {\r
-               if ( *pdecl == ',' )\r
-               {\r
-                       pdecl++;\r
-                       putc(';', output); putc('\n', output);\r
-                       while ( *pdecl==' ' || *pdecl=='\t' || *pdecl=='\n' ) pdecl++;\r
-               }\r
-               else {putc(*pdecl, output); pdecl++;}\r
-       }\r
-       putc(';', output);\r
-       putc('\n', output);\r
-}\r
-\r
-/* Take in a type definition (type + symbol) and print out type only */\r
-/* MR23 Total rewrite */\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-DumpType( char *s, FILE *f )\r
-#else\r
-DumpType( s, f )\r
-char *s;\r
-FILE *f;\r
-#endif\r
-{\r
-       char *p;\r
-       char *pDataType;\r
-       char *pSymbol;\r
-       char *pEqualSign;\r
-       char *pValue;\r
-       char *pSeparator;\r
-       int nest = 0;\r
-\r
-       require(s!=NULL, "DumpType: invalid type string"); \r
-\r
-       p = endFormal(s,\r
-                             &pDataType,\r
-                                 &pSymbol,\r
-                                 &pEqualSign,\r
-                                 &pValue,\r
-                                 &pSeparator,\r
-                                 &nest);\r
-       fprintf(f,strBetween(pDataType, pSymbol, pSeparator));\r
-}\r
-\r
-/* check to see if string e is a word in string s */\r
-int\r
-#ifdef __USE_PROTOS\r
-strmember( char *s, char *e )\r
-#else\r
-strmember( s, e )\r
-char *s;\r
-char *e;\r
-#endif\r
-{\r
-    register char *p;\r
-    require(s!=NULL&&e!=NULL, "strmember: NULL string");\r
-\r
-    if ( *e=='\0' ) return 1;   /* empty string is always member */\r
-    do {\r
-       while ( *s!='\0' && !isalnum(*s) && *s!='_' )\r
-       ++s;\r
-       p = e;\r
-       while ( *p!='\0' && *p==*s ) {p++; s++;}\r
-       if ( *p=='\0' ) {\r
-           if ( *s=='\0' ) return 1;\r
-           if ( !isalnum (*s) && *s != '_' ) return 1;\r
-       }\r
-       while ( isalnum(*s) || *s == '_' )\r
-       ++s;\r
-    } while ( *s!='\0' );\r
-    return 0;\r
-}\r
-\r
-#if 0\r
-\r
-/* MR23 Replaced by hasMultipleOperands() */\r
-\r
-int\r
-#ifdef __USE_PROTOS\r
-HasComma( char *s )\r
-#else\r
-HasComma( s )\r
-char *s;\r
-#endif\r
-{\r
-       while (*s!='\0')\r
-               if ( *s++ == ',' ) return 1;\r
-       return 0;\r
-}\r
-#endif\r
-\r
-\r
-/* MR23 Total rewrite */\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-DumpRetValStruct( FILE *f, char *ret, int i )\r
-#else\r
-DumpRetValStruct( f, ret, i )\r
-FILE *f;\r
-char *ret;\r
-int i;\r
-#endif\r
-{\r
-       char *p = ret;\r
-       char *pDataType;\r
-       char *pSymbol;\r
-       char *pEqualSign;\r
-       char *pValue;\r
-       char *pSeparator;\r
-    int nest = 0;\r
-\r
-       fprintf(f, "\nstruct _rv%d {\n", i);\r
-       while (*p != 0 && nest == 0) {\r
-               p = endFormal(p,\r
-                                 &pDataType,\r
-                                         &pSymbol,\r
-                                         &pEqualSign,\r
-                                         &pValue,\r
-                                         &pSeparator,\r
-                                         &nest);\r
-               fprintf(f,"\t");\r
-               fprintf(f,strBetween(pDataType, pSymbol, pSeparator));\r
-               fprintf(f," ");\r
-               fprintf(f,strBetween(pSymbol, pEqualSign, pSeparator));\r
-               fprintf(f,";\n");\r
-    }\r
-       fprintf(f,"};\n");\r
-}\r
-\r
-/* given "s" yield s -- DESTRUCTIVE (we modify s if starts with " else return s) */\r
-char *\r
-#ifdef __USE_PROTOS\r
-StripQuotes( char *s )\r
-#else\r
-StripQuotes( s )\r
-char *s;\r
-#endif\r
-{\r
-       if ( *s == '"' )\r
-       {\r
-               s[ strlen(s)-1 ] = '\0';    /* remove last quote */\r
-               return( s+1 );                          /* return address past initial quote */\r
-       }\r
-       return( s );\r
-}\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/antlr/main.c b/Tools/CodeTools/TianoTools/Pccts/antlr/main.c
deleted file mode 100644 (file)
index 051ee4e..0000000
+++ /dev/null
@@ -1,1747 +0,0 @@
-/*\r
- * main.c -- main program for PCCTS ANTLR.\r
- *\r
- * SOFTWARE RIGHTS\r
- *\r
- * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
- * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
- * company may do whatever they wish with source code distributed with\r
- * PCCTS or the code generated by PCCTS, including the incorporation of\r
- * PCCTS, or its output, into commerical software.\r
- *\r
- * We encourage users to develop software with PCCTS.  However, we do ask\r
- * that credit is given to us for developing PCCTS.  By "credit",\r
- * we mean that if you incorporate our source code into one of your\r
- * programs (commercial product, research project, or otherwise) that you\r
- * acknowledge this fact somewhere in the documentation, research report,\r
- * etc...  If you like PCCTS and have developed a nice tool with the\r
- * output, please mention that you developed it using PCCTS.  In\r
- * addition, we ask that this header remain intact in our source code.\r
- * As long as these guidelines are kept, we expect to continue enhancing\r
- * this system and expect to make other tools available as they are\r
- * completed.\r
- *\r
- * ANTLR 1.33\r
- * Terence Parr\r
- * Parr Research Corporation\r
- * with Purdue University and AHPCRC, University of Minnesota\r
- * 1989-2001\r
- */\r
-\r
-/* To set a breakpoint just before exit look for "cleanUp".    */\r
-/* To set a breakpoint for fatal error look for "fatal_intern" */\r
-\r
-#include <stdio.h>\r
-\r
-#include "pcctscfg.h"\r
-#include "stdpccts.h"\r
-\r
-#define MAX_INT_STACK 50\r
-static int istack[MAX_INT_STACK];              /* Int stack */\r
-static int isp = MAX_INT_STACK;\r
-\r
-static int DontAcceptFiles = 0;                        /* if stdin, don't read files */\r
-static int DontAcceptStdin = 0;                        /* if files seen first, don't accept stdin */\r
-\r
-static int tnodes_used_in_guard_predicates_etc;     /* MR10 */\r
-\r
-               /* C m d - L i n e  O p t i o n  S t r u c t  &  F u n c s */\r
-\r
-typedef struct _Opt {\r
-                       char *option;\r
-                       int  arg;\r
-#ifdef __cplusplus\r
-                       void (*process)(...);\r
-#else\r
-                       void (*process)();\r
-#endif\r
-                       char *descr;\r
-               } Opt;\r
-\r
-#ifdef __USE_PROTOS\r
-extern void ProcessArgs(int, char **, Opt *);\r
-#else\r
-extern void ProcessArgs();\r
-#endif\r
-\r
-#ifdef __USE_PROTOS\r
-int ci_strequ(char *a,char *b)\r
-#else\r
-int ci_strequ(a,b)\r
-  char  *a;\r
-  char  *b;\r
-#endif\r
-{\r
-  for ( ;*a != 0 && *b != 0; a++, b++) {\r
-    if (toupper(*a) != toupper(*b)) return 0;\r
-  }\r
-  return (*a == *b);\r
-}\r
-\r
-static void\r
-#ifdef __USE_PROTOS\r
-pStdin( void )\r
-#else\r
-pStdin( )\r
-#endif\r
-{\r
-       if ( DontAcceptStdin )\r
-       {\r
-               warnNoFL("'-' (stdin) ignored as files were specified first");\r
-               return;\r
-       }\r
-\r
-       require(NumFiles<MaxNumFiles,"exceeded max # of input files");\r
-       FileStr[NumFiles++] = "stdin";\r
-       DontAcceptFiles = 1;\r
-}\r
-\r
-static void\r
-#ifdef __USE_PROTOS\r
-pFile( char *s )\r
-#else\r
-pFile( s )\r
-char *s;\r
-#endif\r
-{\r
-       if ( *s=='-' ) { warnNoFL( eMsg1("invalid option: '%s'",s) ); return; }\r
-       if ( DontAcceptFiles )\r
-       {\r
-               warnNoFL(eMsg1("file '%s' ignored as '-' (stdin option) was specified first",s));\r
-               return;\r
-       }\r
-\r
-       require(NumFiles<MaxNumFiles,"exceeded max # of input files");\r
-       FileStr[NumFiles++] = s;\r
-       DontAcceptStdin = 1;\r
-}\r
-\r
-/* MR14\r
-        Allow input to be a file containing a list of files\r
-        Bernard Giroud (b_giroud@decus.ch)\r
-*/\r
-\r
-static void\r
-#ifdef __USE_PROTOS\r
-pFileList( char *s, char *t )\r
-#else\r
-pFileList( s, t )\r
-char *s;\r
-char *t;\r
-#endif\r
-{\r
-#define MaxFLArea 1024\r
-       FILE *fl;\r
-       static char Fn_in_Fl[MaxFLArea] = "";\r
-        char one_fn[MaxFileName];\r
-       char *flp = &Fn_in_Fl[0];\r
-       int fnl, left = MaxFLArea, i;\r
-\r
-       if ( *t=='-' ) { warnNoFL( eMsg1("invalid option: '%s'",t) ); return; }\r
-       if ( DontAcceptFiles )\r
-       {\r
-               warnNoFL(eMsg1("file '%s' ignored as '-' (stdin option) was specified first",t));\r
-               return;\r
-       }\r
-\r
-        if ((fl = fopen(t, "r")) == NULL)\r
-       {\r
-               warnNoFL(eMsg1("file '%s' can't be opened", t));\r
-               return;\r
-       }\r
-        for (;;)\r
-       {\r
-               if (fgets(one_fn, 128 - 1, fl) == NULL)\r
-                       break;\r
-               fnl = strlen(one_fn);\r
-               require(fnl<=left, "no more room in File List Area");\r
-               /* drop the trailing LF */\r
-               if (one_fn[fnl - 1] == 0x0a) one_fn[fnl - 1] = ' ';\r
-               strcat(Fn_in_Fl, one_fn);\r
-               left = left - fnl;\r
-               require(NumFiles<MaxNumFiles,"exceeded max # of input files");\r
-               FileStr[NumFiles++] = flp;\r
-               flp = flp + fnl;\r
-       }\r
-       fclose(fl);\r
-       for (i=0;i < MaxFLArea;i++) if (Fn_in_Fl[i] == ' ') Fn_in_Fl[i] = '\0';\r
-       DontAcceptStdin = 1;\r
-}\r
-\r
-static void\r
-#ifdef __USE_PROTOS\r
-pLLK( char *s, char *t )\r
-#else\r
-pLLK( s, t )\r
-char *s;\r
-char *t;\r
-#endif\r
-{\r
-       LL_k = atoi(t);\r
-       if ( LL_k <= 0 ) {\r
-               warnNoFL("must have at least one token of lookahead (setting to 1)");\r
-               LL_k = 1;\r
-       }\r
-}\r
-\r
-static void\r
-#ifdef __USE_PROTOS\r
-pCk( char *s, char *t )\r
-#else\r
-pCk( s, t )\r
-char *s;\r
-char *t;\r
-#endif\r
-{\r
-       CLL_k = atoi(t);\r
-       if ( CLL_k <= 0 ) {\r
-               warnNoFL("must have at least one token of look-ahead (setting to 1)");\r
-               CLL_k = 1;\r
-       }\r
-}\r
-\r
-static void                                                                                 /* MR6 */\r
-#ifdef __USE_PROTOS\r
-pTab( char *s, char *t )                                                            /* MR6 */\r
-#else\r
-pTab( s, t )                                                                        /* MR6 */\r
-char *s;                                                                                        /* MR6 */\r
-char *t;                                                                                        /* MR6 */\r
-#endif\r
-{                                                                                                   /* MR6 */\r
-       TabWidth = atoi(t);                                                                  /* MR6 */\r
-       if ( TabWidth < 0 || TabWidth > 8 ) {                                /* MR6 */\r
-               warnNoFL("tab width must be between 1 and 8");               /* MR6 */\r
-         TabWidth=0;                                                                        /* MR6 */\r
-       }                                                                                            /* MR6 */\r
-}                                                                                               /* MR6 */\r
-\r
-static int ambAidDepthSpecified=0;                                   /* MR11 */\r
-\r
-static void                                                                                 /* MR11 */\r
-#ifdef __USE_PROTOS\r
-pAAd( char *s, char *t )                                                            /* MR11 */\r
-#else\r
-pAAd( s, t )                                                                        /* MR11 */\r
-char *s;                                                                                        /* MR11 */\r
-char *t;                                                                                        /* MR11 */\r
-#endif\r
-{                                                                                                   /* MR11 */\r
-    ambAidDepthSpecified=1;                                          /* MR11 */\r
-       MR_AmbAidDepth = atoi(t);                                                        /* MR11 */\r
-}                                                                                               /* MR11 */\r
-\r
-static void                                                                                 /* MR11 */\r
-#ifdef __USE_PROTOS\r
-pTreport( char *s, char *t )                                                /* MR11 */\r
-#else\r
-pTreport( s, t )                                                                            /* MR11 */\r
-    char *s;                                                                                /* MR11 */\r
-    char *t;                                                                                /* MR11 */\r
-#endif\r
-{                                                                                                   /* MR11 */\r
-       TnodesReportThreshold = atoi(t);                                                 /* MR11 */\r
-}                                                                                               /* MR11 */\r
-\r
-#ifdef __USE_PROTOS\r
-void chkGTFlag(void)                                       /* 7-Apr-97 MR1 */\r
-#else\r
-void chkGTFlag()                                            /* 7-Apr-97 MR1 */\r
-#endif\r
-{\r
-       if ( !GenAST )\r
-               warn("#-variable or other AST item referenced w/o -gt option");\r
-}\r
-\r
-\r
-#ifdef __USE_PROTOS\r
-static void pInfo(char *s, char *t)                         /* MR10 */\r
-#else\r
-static void pInfo(s,t)                                      /* MR10 */\r
-  char  *s;\r
-  char  *t;\r
-#endif\r
-{\r
-  char  *p;\r
-  int   q;\r
-  for (p=t; *p != 0; p++) {\r
-    q=tolower(*p);\r
-    if (q=='t') {\r
-      InfoT=1;\r
-    } else if (q=='p') {\r
-      InfoP=1;\r
-    } else if (q=='m') {\r
-      InfoM=1;\r
-    } else if (q=='o') {\r
-      InfoO=1;\r
-    } else if (q=='0') {\r
-      ; /* nothing */\r
-    } else if (q=='f') {\r
-      InfoF=1;\r
-    } else {\r
-      warnNoFL(eMsgd("unrecognized -info option \"%c\"",(int)*p));\r
-    };\r
-  };\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-static void pCGen(void)        { CodeGen = FALSE; LexGen = FALSE; }\r
-static void pLGen(void)        { LexGen = FALSE; }\r
-static void pXTGen(void){ MR_Inhibit_Tokens_h_Gen = TRUE; }\r
-static void pTGen(void)        { TraceGen = TRUE; }\r
-static void pSGen(void)        { GenExprSetsOpt = FALSE; }\r
-static void pPrt(void) { PrintOut = TRUE; pCGen(); pLGen(); }\r
-static void pPrtA(void)        { PrintOut = TRUE; PrintAnnotate = TRUE; pCGen(); pLGen(); }\r
-static void pAst(void) { GenAST = TRUE; }\r
-static void pANSI(void)        { GenANSI = TRUE; }\r
-static void pCr(void)  { GenCR = TRUE; }\r
-static void pNOPURIFY(void)    { PURIFY = FALSE; }\r
-/*static void pCt(void)        { warnNoFL("-ct option is now the default"); }*/\r
-static void pLI(void)  { GenLineInfo = TRUE; GenLineInfoMS = FALSE; } /* MR14 */\r
-static void pLIms(void)        { GenLineInfo = TRUE; GenLineInfoMS = TRUE; }  /* MR14 */\r
-static void pFr(char *s, char *t) {RemapFileName = t;}\r
-static void pFe(char *s, char *t) {ErrFileName = t;}\r
-static void pFl(char *s, char *t) {DlgFileName = t;}\r
-static void pFm(char *s, char *t) {ModeFileName = t;}\r
-static void pFt(char *s, char *t) {DefFileName = t;}\r
-\r
-static void pE1(void)  { elevel = 1; }\r
-static void pE2(void)  { elevel = 2; }\r
-static void pE3(void)  { elevel = 3; }\r
-static void pEGen(void)        { GenEClasseForRules = 1; }\r
-static void pDL(void)\r
-       {\r
-           DemandLookahead = 1;\r
-           if ( GenCC ) {\r
-                       warnNoFL("-gk does not work currently in C++ mode; -gk turned off");\r
-                       DemandLookahead = 0;\r
-           }\r
-       }\r
-\r
-static void pAA(char *s,char *t) {MR_AmbAidRule = t;}               /* MR11 */\r
-static void pAAm(char *s){MR_AmbAidMultiple = 1;}                   /* MR11 */\r
-static void pGHdr(void)        { GenStdPccts = 1; }\r
-static void pFHdr(char *s, char *t) { stdpccts = t; pGHdr(); }\r
-static void pW1(void) { WarningLevel = 1; }\r
-static void pNewAST(void) { NewAST = 1; }                           /* MR13 */\r
-static void ptmakeInParser(void) { tmakeInParser = 1; }             /* MR23 */\r
-static void pAlpha(void) { AlphaBetaTrace = 1; }                    /* MR14 */\r
-static void pMR_BlkErr(void) { MR_BlkErr = 1; }                     /* MR21 */\r
-static void pStdout(void) {UseStdout = 1; }                                /* MR6 */\r
-static void pW2(void) { WarningLevel = 2; }\r
-static void pCC(void) { GenCC = TRUE; }\r
-#else\r
-static void pCGen()    { CodeGen = FALSE; LexGen = FALSE; }\r
-static void pLGen()    { LexGen = FALSE; }\r
-static void pXTGen(){ MR_Inhibit_Tokens_h_Gen = TRUE; }             /* MR14 */\r
-static void pTGen()    { TraceGen = TRUE; }\r
-static void pSGen()    { GenExprSetsOpt = FALSE; }\r
-static void pPrt()             { PrintOut = TRUE; pCGen(); pLGen(); }\r
-static void pPrtA()    { PrintOut = TRUE; PrintAnnotate = TRUE; pCGen(); pLGen(); }\r
-static void pAst()             { GenAST = TRUE; }\r
-static void pANSI()    { GenANSI = TRUE; }\r
-static void pCr()              { GenCR = TRUE; }\r
-static void pNOPURIFY()        { PURIFY = FALSE; }\r
-\r
-/*static void pCt()            { warnNoFL("-ct option is now the default"); }*/\r
-static void pLI()          { GenLineInfo = TRUE; GenLineInfoMS = FALSE; }  /* MR14 */\r
-static void pLIms()        { GenLineInfo = TRUE; GenLineInfoMS = TRUE; }   /* MR14 */\r
-static void pFr(s,t) char *s, *t; {RemapFileName = t;}\r
-static void pFe(s,t) char *s, *t; {ErrFileName = t;}\r
-static void pFl(s,t) char *s, *t; {DlgFileName = t;}\r
-static void pFm(s,t) char *s, *t; {ModeFileName = t;}\r
-static void pFt(s,t) char *s, *t; {DefFileName = t;}\r
-\r
-static void pE1()              { elevel = 1; }\r
-static void pE2()              { elevel = 2; }\r
-static void pE3()              { elevel = 3; }\r
-static void pEGen()    { GenEClasseForRules = 1; }\r
-static void pDL()\r
-       {\r
-           DemandLookahead = 1;\r
-           if ( GenCC ) {\r
-          warnNoFL("-gk does not work currently in C++ mode; -gk turned off");\r
-             DemandLookahead = 0;\r
-           }\r
-       }\r
-\r
-static void pAA(s,t) char *s; char *t; {MR_AmbAidRule = t;}          /* MR11 BJS 20-Mar-98 */\r
-static void pAAm(s) char *s; {MR_AmbAidMultiple = 1;}                /* MR11 BJS 20-Mar-98 */\r
-static void pGHdr()    { GenStdPccts = 1; }\r
-static void pFHdr(s,t) char *s, *t; { stdpccts = t; pGHdr(); }\r
-static void pW1() { WarningLevel = 1; }\r
-static void pNewAST() { NewAST = 1; }                                /* MR13 */\r
-static void ptmakeInParser() { tmakeInParser = 1; }                  /* MR23 */\r
-static void pAlpha() { AlphaBetaTrace = 1; }                         /* MR14 */\r
-static void pMR_BlkErr() { MR_BlkErr = 1; }                          /* MR21 */\r
-static void pStdout() {UseStdout = 1; }                                     /* MR6 */\r
-static void pW2() { WarningLevel = 2; }\r
-static void pCC() { GenCC = TRUE; }\r
-#endif\r
-\r
-static void\r
-#ifdef __USE_PROTOS\r
-pPre( char *s, char *t )\r
-#else\r
-pPre( s, t )\r
-char *s;\r
-char *t;\r
-#endif\r
-{\r
-       RulePrefix = t;\r
-}\r
-\r
-static void\r
-#ifdef __USE_PROTOS\r
-pOut( char *s, char *t )\r
-#else\r
-pOut( s, t )\r
-char *s;\r
-char *t;\r
-#endif\r
-{\r
-       OutputDirectory = t;\r
-}\r
-\r
-static void\r
-#ifdef __USE_PROTOS\r
-pPred( void )\r
-#else\r
-pPred( )\r
-#endif\r
-{\r
-       warnNoFL("-pr is no longer used (predicates employed if present); see -prc, -mrhoist, -mrhoistk");\r
-/*\r
-**     if ( DemandLookahead )\r
-**             warnNoFL("-gk conflicts with -pr; -gk turned off");\r
-**     DemandLookahead = 0;\r
-**     HoistPredicateContext = 0;\r
-*/\r
-}\r
-\r
-static void\r
-#ifdef __USE_PROTOS\r
-pPredCtx( char *s, char *t )\r
-#else\r
-pPredCtx(s,t)\r
-char *s;\r
-char *t;\r
-#endif\r
-{\r
-       if ( ci_strequ(t,"on")) HoistPredicateContext = 1;\r
-       else if ( ci_strequ(t,"off")) HoistPredicateContext = 0;\r
-       if ( DemandLookahead )\r
-       {\r
-               warnNoFL("-gk incompatible with semantic predicate usage; -gk turned off");\r
-               DemandLookahead = 0;\r
-       }\r
-}\r
-\r
-static void\r
-#ifdef __USE_PROTOS\r
-pMRhoist( char *s, char *t )\r
-#else\r
-pMRhoist(s,t)\r
-char *s;\r
-char *t;\r
-#endif\r
-{\r
-       if ( ci_strequ(t,"on")) MRhoisting = 1;\r
-       else if ( ci_strequ(t,"off")==0 ) MRhoisting = 0;\r
-    if (MRhoisting) {\r
-        fprintf(stderr,"Maintenance Release style hoisting enabled for predicates with lookahead depth = 1\n");\r
-        fprintf(stderr,"  No longer considered experimental\n");\r
-        fprintf(stderr,"  Can't consider suppression for predicates with lookahead depth > 1\n");\r
-        fprintf(stderr,"  Implies -prc on but does *not* imply -mrhoistk for k>1 predicates\n");\r
-        fprintf(stderr,"  This is a reminder, not a warning or error.\n");\r
-    };\r
-}\r
-\r
-static void\r
-#ifdef __USE_PROTOS\r
-pMRhoistk( char *s, char *t )\r
-#else\r
-pMRhoistk(s,t)\r
-char *s;\r
-char *t;\r
-#endif\r
-{\r
-       if ( ci_strequ(t,"on")) MRhoistingk = 1;\r
-       else if ( ci_strequ(t,"off")==0 ) MRhoistingk = 0;\r
-    if (MRhoistingk) {\r
-        fprintf(stderr,"EXPERIMENTAL Maintenance Release style hoisting enabled\n");\r
-        fprintf(stderr,"  Applies to predicates with lookahead depth > 1\n");\r
-        fprintf(stderr,"  Implies -prc on and -mrhoist on\n");\r
-    };\r
-}\r
-\r
-static void\r
-#ifdef __USE_PROTOS\r
-pTRes( char *s, char *t )\r
-#else\r
-pTRes( s, t )\r
-char *s;\r
-char *t;\r
-#endif\r
-{\r
-       TreeResourceLimit = atoi(t);\r
-       if ( TreeResourceLimit <= 0 )\r
-       {\r
-               warnNoFL("analysis resource limit (# of tree nodes) must be greater than 0");\r
-               TreeResourceLimit = -1; /* set to no limit */\r
-       }\r
-}\r
-\r
-Opt options[] = {\r
-#ifdef __cplusplus\r
-    { "-CC", 0, (void (*)(...)) pCC,   "Generate C++ output (default=FALSE)"},\r
-    { "-ck", 1, (void (*)(...)) pCk,   "Set compressed lookahead depth; fast approximate lookahead"},\r
-    { "-cr", 0, (void (*)(...)) pCr,   "Generate cross reference (default=FALSE)"},\r
-    { "-e1", 0, (void (*)(...)) pE1,   "Ambiguities/errors shown in low detail (default)"},\r
-    { "-e2", 0, (void (*)(...)) pE2,   "Ambiguities/errors shown in more detail"},\r
-    { "-e3", 0, (void (*)(...)) pE3,\r
-       "Ambiguities for k>1 grammars shown with exact tuples (not lookahead sets)"},\r
-    { "-f",  1, (void (*)(...)) pFileList,"Read names of grammar files from specified file"}, /* MR14 */\r
-    { "-fe", 1, (void (*)(...)) pFe,   "Rename err.c"},\r
-    { "-fh", 1, (void (*)(...)) pFHdr, "Rename stdpccts.h header (turns on -gh)"},\r
-    { "-fl", 1, (void (*)(...)) pFl,   "Rename lexical output--parser.dlg"},\r
-    { "-fm", 1, (void (*)(...)) pFm,   "Rename mode.h"},\r
-    { "-fr", 1, (void (*)(...)) pFr,   "Rename remap.h"},\r
-    { "-ft", 1, (void (*)(...)) pFt,   "Rename tokens.h"},\r
-    { "-ga", 0, (void (*)(...)) pANSI, "Generate ANSI-compatible code (default=FALSE)"},\r
-    { "-gc", 0, (void (*)(...)) pCGen, "Do not generate output parser code (default=FALSE)"},\r
-    { "-gd", 0, (void (*)(...)) pTGen, "Generate code to trace rule invocation (default=FALSE)"},\r
-    { "-ge", 0, (void (*)(...)) pEGen, "Generate an error class for each non-terminal (default=FALSE)"},\r
-    { "-gh", 0, (void (*)(...)) pGHdr, "Generate stdpccts.h for non-ANTLR-generated-files to include"},\r
-    { "-gk", 0, (void (*)(...)) pDL,   "Generate parsers that delay lookahead fetches until needed"},\r
-    { "-gl", 0, (void (*)(...)) pLI,   "Generate line info about grammar actions in parser"},\r
-    { "-glms", 0, (void (*)(...)) pLIms,"Like -gl but replace '\\' with '/' in #line filenames for MS C/C++ systems"},\r
-    { "-gp", 1, (void (*)(...)) pPre,  "Prefix all generated rule functions with a string"},\r
-    { "-gs", 0, (void (*)(...)) pSGen, "Do not generate sets for token expression lists (default=FALSE)"},\r
-    { "-gt", 0, (void (*)(...)) pAst,  "Generate code for Abstract-Syntax-Trees (default=FALSE)"},\r
-    { "-gx", 0, (void (*)(...)) pLGen, "Do not generate lexical (dlg-related) files (default=FALSE)"},\r
-    { "-gxt",0, (void (*)(...)) pXTGen,        "Do not generate tokens.h (default=FALSE)"},\r
-    { "-k",  1, (void (*)(...)) pLLK,  "Set full LL(k) lookahead depth (default==1)"},\r
-    { "-o",  1, (void (*)(...)) pOut,  OutputDirectoryOption},\r
-    { "-p",  0, (void (*)(...)) pPrt,  "Print out the grammar w/o actions (default=no)"},\r
-    { "-pa", 0, (void (*)(...)) pPrtA, "Print out the grammar w/o actions & w/FIRST sets (default=no)"},\r
-    { "-pr",0, (void (*)(...)) pPred,  "no longer used; predicates employed if present"},\r
-    { "-prc", 1, (void (*)(...)) pPredCtx,"Turn on/off computation of context for hoisted predicates"},\r
-       { "-rl", 1, (void (*)(...)) pTRes,      "Limit max # of tree nodes used by grammar analysis"},\r
-    { "-stdout",0,  (void (*)(...)) pStdout,"Send grammar.c/grammar.cpp to stdout"},           /* MR6 */\r
-       { "-tab", 1, (void (*)(...)) pTab,      "Width of tabs (1 to 8) for grammar.c/grammar.cpp files"}, /* MR6 */\r
-       { "-w1", 0, (void (*)(...)) pW1,        "Set the warning level to 1 (default)"},\r
-       { "-w2", 0, (void (*)(...)) pW2,        "Ambiguities yield warnings even if predicates or (...)? block"},\r
-       { "-",   0, (void (*)(...)) pStdin,     "Read grammar from stdin" },\r
-    { "-mrhoist",1, (void (*)(...)) pMRhoist,                                                  /* MR9 */\r
-                                        "Turn on/off k=1 Maintenance Release style hoisting"},  /* MR9 */\r
-    { "-mrhoistk",1, (void (*)(...)) pMRhoistk,                                                  /* MR9 */\r
-                                        "Turn on/off EXPERIMENTAL k>1 Maintenance Release style hoisting"},  /* MR13 */\r
-    { "-aa"  , 1, (void (*)(...)) pAA,  "Ambiguity aid for a rule (rule name or line number)"},          /* MR11 */\r
-    { "-aam" , 0, (void (*)(...)) pAAm,\r
-                                         "Lookahead token may appear multiple times in -aa listing"},    /* MR11 */\r
-    { "-aad" , 1, (void (*)(...)) pAAd,\r
-                                         "Limits exp growth of -aa listing - default=1 (max=ck value)"}, /* MR11 */\r
-       { "-info", 1, (void (*)(...)) pInfo,\r
-      "Extra info: p=pred t=tnodes f=first/follow m=monitor o=orphans 0=noop"},                          /* MR12 */\r
-    { "-treport",1,(void (*)(...)) pTreport,\r
-                        "Report when tnode usage exceeds value during ambiguity resolution"},            /* MR11 */\r
-       { "-newAST", 0, (void (*)(...)) pNewAST,\r
-                 "In C++ mode use \"newAST(...)\" rather than \"new AST(...)\""},                        /* MR13 */\r
-       { "-tmake", 0, (void (*)(...)) ptmakeInParser,\r
-                 "In C++ mode use parser's tmake method rather than \"ASTBase::tmake(...)\""},                  /* MR23 */\r
-    { "-alpha",0,(void (*)(...)) pAlpha,\r
-                 "Provide additional information for \"(alpha)? beta\" error messages"},                 /* MR14 */\r
-    { "-mrblkerr",0,(void (*)(...)) pMR_BlkErr,                                        /* MR21 */\r
-                 "EXPERIMENTAL change to (...)* and (...)+ syntax error sets"},        /* MR21 */\r
-       { "-nopurify",0,(void (*)(...)) pNOPURIFY,\r
-               "Don't use the notorious PURIFY macro (replaced by MR23 initial value syntax) to zero return arguments of rules"},   /* MR23 */\r
-    { "*",   0, (void (*)(...)) pFile,         "" },   /* anything else is a file */\r
-#else\r
-    { "-CC", 0, pCC,   "Generate C++ output (default=FALSE)"},\r
-    { "-cr", 0, pCr,   "Generate cross reference (default=FALSE)"},\r
-    { "-ck", 1, pCk,   "Set compressed lookahead depth; fast approximate lookahead"},\r
-    { "-e1", 0, pE1,   "Ambiguities/errors shown in low detail (default)"},\r
-    { "-e2", 0, pE2,   "Ambiguities/errors shown in more detail"},\r
-    { "-e3", 0, pE3,           "Ambiguities for k>1 grammars shown with exact tuples (not lookahead sets)"},\r
-    { "-f",  1, pFileList,"Read names of grammar files from specified file"},   /* MR14 */\r
-    { "-fe", 1, pFe,   "Rename err.c"},\r
-    { "-fh", 1, pFHdr, "Rename stdpccts.h header (turns on -gh)"},\r
-    { "-fl", 1, pFl,   "Rename lexical output--parser.dlg"},\r
-    { "-fm", 1, pFm,   "Rename mode.h"},\r
-    { "-fr", 1, pFr,   "Rename remap.h"},\r
-    { "-ft", 1, pFt,   "Rename tokens.h"},\r
-    { "-ga", 0, pANSI, "Generate ANSI-compatible code (default=FALSE)"},\r
-    { "-gc", 0, pCGen, "Do not generate output parser code (default=FALSE)"},\r
-    { "-gd", 0, pTGen, "Generate code to trace rule invocation (default=FALSE)"},\r
-    { "-ge", 0, pEGen, "Generate an error class for each non-terminal (default=FALSE)"},\r
-    { "-gh", 0, pGHdr, "Generate stdpccts.h for non-ANTLR-generated-files to include"},\r
-    { "-gk", 0, pDL,   "Generate parsers that delay lookahead fetches until needed"},\r
-    { "-gl", 0, pLI,   "Generate line info about grammar actions in C parser"},\r
-    { "-glms", 0, pLIms,"Like -gl but replace '\\' with '/' in #line filenames for MS C/C++ systems"},\r
-    { "-gp", 1, pPre,  "Prefix all generated rule functions with a string"},\r
-    { "-gs", 0, pSGen, "Do not generate sets for token expression lists (default=FALSE)"},\r
-    { "-gt", 0, pAst,  "Generate code for Abstract-Syntax-Trees (default=FALSE)"},\r
-    { "-gx", 0, pLGen, "Do not generate lexical (dlg-related) files (default=FALSE)"},\r
-    { "-gxt",0, pXTGen,        "Do not generate tokens.h (default=FALSE)"},\r
-    { "-k",  1, pLLK,  "Set full LL(k) lookahead depth (default==1)"},\r
-    { "-o",  1, pOut,  OutputDirectoryOption},\r
-    { "-p",  0, pPrt,  "Print out the grammar w/o actions (default=no)"},\r
-    { "-pa", 0, pPrtA, "Print out the grammar w/o actions & w/FIRST sets (default=no)"},\r
-    { "-pr",0, pPred,  "no longer used; predicates employed if present"},\r
-    { "-prc", 1, pPredCtx,"Turn on/off computation of context for hoisted predicates"},\r
-    { "-rl", 1, pTRes, "Limit max # of tree nodes used by grammar analysis"},\r
-    { "-stdout",0, pStdout,    "Send grammar.c/grammar.cpp to stdout"},               /* MR6 */\r
-    { "-tab", 1, pTab, "Width of tabs (1 to 8) for grammar.c/grammar.cpp files"}, /* MR6 */\r
-       { "-w1", 0, pW1,        "Set the warning level to 1 (default)"},\r
-       { "-w2", 0, pW2,        "Ambiguities yield warnings even if predicates or (...)? block"},\r
-    { "-mrhoist",1,pMRhoist,                                                       /* MR9 */\r
-                         "Turn on/off k=1 Maintenance Release style hoisting"},  /* MR9 */\r
-    { "-mrhoistk",1,pMRhoistk,                                                       /* MR13 */\r
-                         "Turn on/off k>1 EXPERIMENTAL Maintenance Release style hoisting"},  /* MR13 */\r
-    { "-aa"  ,1,pAA,     "Ambiguity aid for a rule (rule name or line number)"},          /* MR11 */\r
-    { "-aam" ,0,pAAm,\r
-                         "Lookahead token may appear multiple times in -aa listing"},     /* MR11 */\r
-    { "-aad" ,1,pAAd,\r
-                         "Limits exp growth of -aa listing - default=1 (max=ck value)"},  /* MR11 */\r
-       { "-info",1,pInfo,\r
-      "Extra info: p=pred t=tnodes f=first/follow m=monitor o=orphans 0=noop"},           /* MR11 */\r
-    { "-treport",1,pTreport,\r
-                        "Report when tnode usage exceeds value during ambiguity resolution"},   /* MR11 */\r
-       { "-newAST", 0, pNewAST,\r
-                 "In C++ mode use \"newAST(...)\" rather than \"new AST(...)\""},         /* MR13 */\r
-       { "-tmake", 0, ptmakeInParser,\r
-                 "In C++ mode use parser's tmake method rather than \"ASTBase::tmake(...)\""},   /* MR23 */\r
-    { "-alpha",0, pAlpha,\r
-                 "Provide additional information for \"(alpha)? beta\" error messages"},  /* MR14 */\r
-    { "-mrblkerr",0,pMR_BlkErr,                                                           /* MR21 */\r
-                 "EXPERIMENTAL change to (...)* and (...)+ syntax error sets"},           /* MR21 */\r
-       { "-nopurify",0,pNOPURIFY,\r
-               "Don't use the notorious PURIFY macro (replaced by MR23 initial value syntax) to zero return arguments of rules"},   /* MR23 */\r
-       { "-",   0, pStdin,     "Read grammar from stdin" },\r
-       { "*",   0, pFile,      "" },   /* anything else is a file */\r
-#endif\r
-       { NULL,  0, NULL }\r
- };\r
-\r
-void readDescr();\r
-void cleanUp();\r
-\r
-#ifdef __USE_PROTOS\r
-static void buildRulePtr( void );\r
-static void help( void );\r
-static void init( void );\r
-static void CompleteTokenSetRefs( void );\r
-static void ensure_no_C_file_collisions(char *);\r
-static void CompleteContextGuards(void);\r
-#else\r
-static void buildRulePtr( );\r
-static void help( );\r
-static void init( );\r
-static void CompleteTokenSetRefs( );\r
-static void ensure_no_C_file_collisions();\r
-static void CompleteContextGuards();\r
-#endif\r
-\r
-static void\r
-#ifdef __USE_PROTOS  /* <BJS> */\r
-report_numericPredLabels(ActionNode *a)\r
-#else\r
-report_numericPredLabels(a)\r
-ActionNode *a;\r
-#endif\r
-{                                                                           /* MR10 */\r
-  warnFL("numeric references to attributes (e.g. $i or $i.j) in semantic pred will be null during guess mode",  /* MR10 */\r
-            FileStr[a->file],a->line);                                      /* MR10 */\r
-}                                                                           /* MR10 */\r
-\r
-                                                               /* M a i n */\r
-\r
-int\r
-#ifdef __USE_PROTOS\r
-main( int argc, char *argv[] )\r
-#else\r
-main( argc, argv )\r
-int argc;\r
-char *argv[];\r
-#endif\r
-{\r
-       int i;\r
-       static char EPSTR[] = "[Ep]";\r
-\r
-    Save_argc=argc;                                                  /* MR10 */\r
-    Save_argv=argv;                                                  /* MR10 */\r
-\r
-/*     malloc_debug(8);*/\r
-\r
-#ifdef SPECIAL_INITS\r
-    special_inits();                                                 /* MR1 */\r
-#endif\r
-       fprintf(stderr, "Antlr parser generator   Version %s   1989-2001\n", Version);\r
-       if ( argc == 1 ) { help(); zzDIE; }\r
-       ProcessArgs(argc-1, &(argv[1]), options);\r
-\r
-/* MR14 */    if (MR_AmbAidRule && AlphaBetaTrace) {\r
-/* MR14 */       fatal("Can't specify both -aa (ambiguity aid) and -alpha (\"(alpha)? beta\" aid)");\r
-/* MR14 */    }\r
-\r
-    if (MRhoistingk) {              /* MR13 */\r
-      HoistPredicateContext=1;      /* MR13 */\r
-      MRhoisting=1;                 /* MR13 */\r
-    };                              /* MR13 */\r
-    if (MRhoisting && ! HoistPredicateContext) {\r
-/***      warnNoFL("Using \"-mrhoist\" forces \"-prc on\"");    ***/\r
-      HoistPredicateContext=1;\r
-    };\r
-    if (HoistPredicateContext && ! MRhoisting) {\r
-        warnNoFL("When using predicate context (-prc on) -mrhoist on is recommended");\r
-    }\r
-       /* Fix lookahead depth */\r
-       /* Compressed lookahead must always be larger than or equal to full lookahead */\r
-       if ( CLL_k < LL_k  && CLL_k>0 )\r
-       {\r
-               warnNoFL("must have compressed lookahead >= full LL(k) lookahead (setting -ck to -k)");\r
-               CLL_k = LL_k;\r
-       }\r
-       if ( CLL_k == -1 ) CLL_k = LL_k;\r
-       OutputLL_k = CLL_k;\r
-       if ( ((CLL_k-1)&CLL_k)!=0 ) { /* output ll(k) must be power of 2 */\r
-               int n;\r
-               for(n=1; n<CLL_k; n<<=1) {;}\r
-               OutputLL_k = n;\r
-       };\r
-\r
-       if (MR_BlkErr) {\r
-               warnNoFL("The -mrblkerr option is EXPERIMENTAL");\r
-        if (LL_k > 1) {\r
-               warnNoFL("The -mrblkerr option is designed only for k=1 ck=1 grammars");\r
-        }\r
-       };\r
-\r
-    if ( ! ambAidDepthSpecified) {\r
-      MR_AmbAidDepth=1;\r
-    } else {\r
-      if (MR_AmbAidDepth > CLL_k || MR_AmbAidDepth <= 0) {\r
-        warnNoFL(eMsgd(\r
-            "Ambiguity aid depth (\"-aad ...\") must be a number between 1 and max(k,ck)=%d",CLL_k));\r
-        MR_AmbAidDepth=1;\r
-      };\r
-      if (MR_AmbAidDepth == 0) {\r
-        MR_AmbAidDepth=2;\r
-      };\r
-    };\r
-\r
-    if (MR_AmbAidRule != NULL) MR_AmbAidLine=atoi(MR_AmbAidRule);\r
-\r
-       fpTrans = &(C_Trans[0]);                /* Translate to C Language */\r
-       fpJTrans = &(C_JTrans[0]);\r
-       init();\r
-       lexclass(LexStartSymbol);\r
-\r
-       readDescr();\r
-       LastTokenCounted = TokenNum;\r
-       RemapForcedTokens();\r
-       if ( CannotContinue ) {cleanUp(); zzDIE;}\r
-       if ( GenCC && no_classes_found ) fatal("required grammar class not found (exiting...)");\r
-       if ( WarningLevel>1 && HdrAction == NULL )\r
-          warnNoFL("no #header action was found");\r
-       if ( FoundAtOperator && ! FoundExceptionGroup) {\r
-          warnNoFL("found the exception operator '@' - but no exception group was found");\r
-       };\r
-       EpToken = addTname(EPSTR);              /* add imaginary token epsilon */\r
-       set_orel(EpToken, &imag_tokens);\r
-\r
-       /* this won't work for hand-built scanners since EofToken is not\r
-        * known.  Forces EOF to be token type 1.\r
-        */\r
-       set_orel(EofToken, &imag_tokens);\r
-\r
-       set_size(NumWords(TokenNum-1));\r
-\r
-       /* compute the set of all known token types\r
-        * It represents the set of tokens from 1 to last_token_num + the\r
-        * reserved positions above that (if any).  Don't include the set of\r
-        * imaginary tokens such as the token/error classes or EOF.\r
-        */\r
-       {\r
-               set a;\r
-               a = set_dup(reserved_positions);\r
-               for (i=1; i<TokenNum; i++) { set_orel(i, &a); }\r
-               all_tokens = set_dif(a, imag_tokens);\r
-               set_free(a);\r
-       }\r
-\r
-       ComputeTokSets();                               /* Compute #tokclass sets */\r
-       CompleteTokenSetRefs();                 /* Change complex nodes in syn diag */\r
-    CompleteContextGuards();        /* MR13 */\r
-\r
-       if ( CodeGen ) genDefFile();    /* create tokens.h */\r
-       if ( LexGen ) genLexDescr();    /* create parser.dlg */\r
-\r
-       if ( GenStdPccts )\r
-       {\r
-               FILE *f = fopen(OutMetaName(stdpccts), "w");\r
-               if ( f==NULL ) {warnNoFL( eMsg1("can't create %s",OutMetaName(stdpccts)) );}\r
-               else\r
-               {\r
-#ifdef SPECIAL_FOPEN\r
-                       special_fopen_actions(OutMetaName(stdpccts));            /* MR1 */\r
-#endif\r
-            if (strcmp(stdpccts,"stdpccts.h") == 0) {                /* MR10 */\r
-                     genStdPCCTSIncludeFile(f,NULL);                        /* MR10 */\r
-            } else {                                                 /* MR10 */\r
-                     genStdPCCTSIncludeFile(f,pcctsBaseName(stdpccts));     /* MR32 */\r
-            };\r
-                       fclose(f);\r
-               }\r
-       }\r
-\r
-       buildRulePtr();                                 /* create mapping from rule # to RuleBlk junction */\r
-       ComputeErrorSets();\r
-       FoLink( (Node *)SynDiag );              /* add follow links to end of all rules */\r
-       \r
-       if ( GenCR ) GenCrossRef( SynDiag );\r
-\r
-       if ( CodeGen )\r
-       {\r
-               if ( SynDiag == NULL )\r
-               {\r
-                       warnNoFL("no grammar description recognized");\r
-                       cleanUp();\r
-                       zzDIE;\r
-               }\r
-               else if ( !GenCC ) {\r
-                       ErrFile = fopen(OutMetaName(ErrFileName), "w");\r
-                       require(ErrFile != NULL, "main: can't open err file");\r
-#ifdef SPECIAL_FOPEN\r
-                     special_fopen_actions(OutMetaName(ErrFileName));   /* MR1 */\r
-#endif\r
-                       NewSetWd();\r
-                       GenErrHdr();\r
-                       TRANS(SynDiag);                 /* Translate to the target language */\r
-                       DumpSetWd();\r
-                       DumpRemainingTokSets();\r
-                       fclose( ErrFile );\r
-               }\r
-               else {\r
-                       strcpy(Parser_h_Name, CurrentClassName);\r
-                       strcat(Parser_h_Name, ".h");\r
-                       strcpy(Parser_c_Name, CurrentClassName);\r
-                       strcat(Parser_c_Name, CPP_FILE_SUFFIX);\r
-                       ensure_no_C_file_collisions(Parser_c_Name);\r
-                       Parser_h = fopen(OutMetaName(Parser_h_Name), "w");\r
-                       require(Parser_h != NULL, "main: can't open class Parserx.h file");\r
-#ifdef SPECIAL_FOPEN\r
-                   special_fopen_actions(OutMetaName(Parser_h_Name));       /* MR1 */\r
-#endif\r
-                       Parser_c = fopen(OutMetaName(Parser_c_Name), "w");\r
-                       require(Parser_c != NULL, "main: can't open class Parserx.c file");\r
-#ifdef SPECIAL_FOPEN\r
-                   special_fopen_actions(OutMetaName(Parser_c_Name));       /* MR1 */\r
-#endif\r
-                       GenParser_h_Hdr();\r
-                       if ( class_before_actions != NULL )\r
-                       {\r
-                               ListNode *p;\r
-                               for (p = class_before_actions->next; p!=NULL; p=p->next)\r
-                               {\r
-                                       UserAction *ua = (UserAction *)p->elem;\r
-                                       dumpAction( ua->action, Parser_h, 0, ua->file, ua->line, 1);\r
-                               }\r
-                       }\r
-                       GenParser_c_Hdr();\r
-                       fprintf(Parser_h, "protected:\n");  /* MR20 */\r
-                       NewSetWd();\r
-                       TRANS(SynDiag);                 /* Translate to the target language */\r
-                       DumpSetWd();\r
-                       GenRuleMemberDeclarationsForCC(Parser_h, SynDiag);\r
-                       if ( class_after_actions != NULL )\r
-                       {\r
-                               ListNode *p;\r
-                               for (p = class_after_actions->next; p!=NULL; p=p->next)\r
-                               {\r
-                                       UserAction *ua = (UserAction *)p->elem;\r
-                                       dumpAction( ua->action, Parser_h, 0, ua->file, ua->line, 1);\r
-                               }\r
-                       }\r
-                       DumpRemainingTokSets();\r
-                       fprintf(Parser_h, "};\n");\r
-                       fprintf(Parser_h, "\n#endif /* %s_h */\n", CurrentClassName);\r
-                       fclose( Parser_h );\r
-                       fclose( Parser_c );\r
-               }\r
-       }\r
-\r
-    MR_orphanRules(stderr);\r
-    if (LTinTokenAction && WarningLevel >= 2) {\r
-               if (GenCC) {\r
-                       warnNoFL("At least one <<action>> following a token match contains a reference to LT(...)\n      this will reference the immediately preceding token,\n      not the one which follows as is the case with semantic predicates.");\r
-               }\r
-                       warnNoFL("At least one <<action>> following a token match contains a reference to LA(...) or LATEXT(...)\n      this will reference the immediately preceding token,\n      not the one which follows as is the case with semantic predicates.");\r
-       }\r
-\r
-       if ( PrintOut )\r
-       {\r
-               if ( SynDiag == NULL ) {warnNoFL("no grammar description recognized");}\r
-               else PRINT(SynDiag);\r
-       }\r
-\r
-#ifdef DBG_LL1\r
-#endif\r
-       GenRemapFile();                                 /* create remap.h */\r
-/* MR10 */    if (FoundGuessBlk) {\r
-#ifdef __cplusplus__\r
-/* MR10 */      list_apply(NumericPredLabels, (void (*)(void *))report_numericPredLabels);\r
-#else\r
-#ifdef __USE_PROTOS\r
-/* MR10 */      list_apply(NumericPredLabels, (void (*)(void *))report_numericPredLabels);\r
-#else\r
-/* MR10 */      list_apply(NumericPredLabels,report_numericPredLabels);\r
-#endif\r
-#endif\r
-/* MR10 */    };\r
-\r
-    if (InfoT && TnodesAllocated > 0) {\r
-      if (TnodesPeak > 10000) {\r
-        fprintf(stdout,"\nTree Nodes:  peak %dk  created %dk  lost %d\n",\r
-                        (TnodesPeak/1000),\r
-                        (TnodesAllocated/1000),\r
-                        TnodesInUse-tnodes_used_in_guard_predicates_etc);\r
-       } else {\r
-         fprintf(stdout,"\nTree Nodes:  peak %d  created %d  lost %d\n",\r
-                        TnodesPeak,\r
-                        TnodesAllocated,\r
-                        TnodesInUse-tnodes_used_in_guard_predicates_etc);\r
-       };\r
-    };\r
-    if (InfoF) {\r
-      DumpFcache();\r
-    };\r
-    if (MR_skipped_e3_report) {\r
-      fprintf(stderr,"note: use -e3 to get exact information on ambiguous tuples\n");\r
-    };\r
-    if (MR_BadExprSets != 0) {\r
-      fprintf(stderr,"note: Unreachable C or C++ code was generated for empty expression sets,\n");\r
-      fprintf(stderr,"        probably due to undefined rules or infinite left recursion.\n");\r
-      fprintf(stderr,"      To locate: search the generated code for \"empty set expression\"\n");\r
-    };\r
-    if (MR_AmbAidRule != NULL && MR_matched_AmbAidRule==0) {\r
-      RuleEntry *q = (RuleEntry *) hash_get(Rname,MR_AmbAidRule);\r
-      if (MR_AmbAidLine == 0 && q == NULL) {\r
-         warnNoFL(eMsg2("there is no rule \"%s\" so \"-aa %s\" will never match",\r
-                                                        MR_AmbAidRule,MR_AmbAidRule));\r
-      } else {\r
-        warnNoFL(eMsg1("there was no ambiguity that matched \"-aa %s\"",MR_AmbAidRule));\r
-      };\r
-    };\r
-    if (AlphaBetaTrace) {\r
-\r
-      if (MR_AlphaBetaMessageCount == 0) {\r
-         fprintf(stderr,"note: there were no messages about \"(alpha)? beta\" blocks added to the generated code\n");\r
-      } else {\r
-         fprintf(stderr,"note: there were %d messages about \"(alpha)? beta\" blocks added to the generated code\n",\r
-                    MR_AlphaBetaMessageCount);\r
-      }\r
-\r
-      if (set_null(MR_CompromisedRules)) {\r
-         fprintf(stderr,"note: the list of rules with compromised follow sets is empty\n");\r
-      } else {\r
-         fprintf(stderr,"note: the following is a list of rules which *may* have incorrect\n");\r
-         fprintf(stderr,"      follow sets computed as a result of an \"(alpha)? beta\" block\n");\r
-         fprintf(stderr,"\n");\r
-         MR_dumpRuleSet(MR_CompromisedRules);\r
-         fprintf(stderr,"\n");\r
-      }\r
-    }\r
-       cleanUp();\r
-       exit(PCCTS_EXIT_SUCCESS);\r
-    return 0;           /* MR11 make compilers happy */ \r
-}\r
-\r
-static void \r
-#ifdef __USE_PROTOS \r
-init( void )\r
-#else\r
-init( )\r
-#endif\r
-{\r
-       SignalEntry *q;\r
-\r
-       Tname = newHashTable();\r
-       Rname = newHashTable();\r
-       Fcache = newHashTable();\r
-       Tcache = newHashTable();\r
-       Sname = newHashTable();\r
-    Pname = newHashTable();     /* MR11 */\r
-\r
-       /* Add default signal names */\r
-       q = (SignalEntry *)hash_add(Sname,\r
-                                                         "NoViableAlt",\r
-                                                         (Entry *)newSignalEntry("NoViableAlt"));\r
-       require(q!=NULL, "cannot alloc signal entry");\r
-       q->signum = sigNoViableAlt;\r
-       q = (SignalEntry *)hash_add(Sname,\r
-                                                         "MismatchedToken",\r
-                                                         (Entry *)newSignalEntry("MismatchedToken"));\r
-       require(q!=NULL, "cannot alloc signal entry");\r
-       q->signum = sigMismatchedToken;\r
-       q = (SignalEntry *)hash_add(Sname,\r
-                                                         "NoSemViableAlt",\r
-                                                         (Entry *)newSignalEntry("NoSemViableAlt"));\r
-       require(q!=NULL, "cannot alloc signal entry");\r
-       q->signum = sigNoSemViableAlt;\r
-       \r
-       reserved_positions = empty;\r
-       all_tokens = empty;\r
-       imag_tokens = empty;\r
-       tokclasses = empty;\r
-       TokenStr = (char **) calloc(TSChunk, sizeof(char *));\r
-       require(TokenStr!=NULL, "main: cannot allocate TokenStr");\r
-       FoStack = (int **) calloc(CLL_k+1, sizeof(int *));\r
-       require(FoStack!=NULL, "main: cannot allocate FoStack");\r
-       FoTOS = (int **) calloc(CLL_k+1, sizeof(int *));\r
-       require(FoTOS!=NULL, "main: cannot allocate FoTOS");\r
-       Cycles = (ListNode **) calloc(CLL_k+1, sizeof(ListNode *));\r
-       require(Cycles!=NULL, "main: cannot allocate Cycles List");\r
-    MR_CompromisedRules=empty;  /* MR14 */\r
-}\r
-\r
-static void\r
-#ifdef __USE_PROTOS\r
-help( void )\r
-#else\r
-help( )\r
-#endif\r
-{\r
-       Opt *p = options;\r
-       fprintf(stderr, "antlr [options] f1 f2 ... fn\n");\r
-       while ( *(p->option) != '*' )\r
-       {\r
-               fprintf(stderr, "    %-9s%s   %s\n",\r
-                                               p->option,\r
-                                               (p->arg)?"___":"   ",\r
-                                               p->descr);\r
-               p++;\r
-       }\r
-}\r
-\r
-/* The RulePtr array is filled in here.  RulePtr exists primarily\r
- * so that sets of rules can be maintained for the FOLLOW caching\r
- * mechanism found in rJunc().  RulePtr maps a rule num from 1 to n\r
- * to a pointer to its RuleBlk junction where n is the number of rules.\r
- */\r
-static void\r
-#ifdef __USE_PROTOS\r
-buildRulePtr( void )\r
-#else\r
-buildRulePtr( )\r
-#endif\r
-{\r
-       int r=1;\r
-       Junction *p  = SynDiag;\r
-       RulePtr = (Junction **) calloc(NumRules+1, sizeof(Junction *));\r
-       require(RulePtr!=NULL, "cannot allocate RulePtr array");\r
-       \r
-       while ( p!=NULL )\r
-       {\r
-               require(r<=NumRules, "too many rules???");\r
-               RulePtr[r++] = p;\r
-               p = (Junction *)p->p2;\r
-       }\r
-}\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-dlgerror(const char *s)\r
-#else\r
-dlgerror(s)\r
-char *s;\r
-#endif\r
-{\r
-       fprintf(stderr, ErrHdr, FileStr[CurFile], zzline);\r
-       fprintf(stderr, " lexical error: %s (text was '%s')\n",\r
-                                       ((s == NULL) ? "Lexical error" : s), zzlextext);\r
-}\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-readDescr( void )\r
-#else\r
-readDescr( )\r
-#endif\r
-{\r
-       zzerr = dlgerror;\r
-       input = NextFile();\r
-       if ( input==NULL ) fatal("No grammar description found (exiting...)");\r
-       ANTLR(grammar(), input);\r
-    tnodes_used_in_guard_predicates_etc=TnodesInUse;    /* MR10 */\r
-}\r
-\r
-FILE *\r
-#ifdef __USE_PROTOS\r
-NextFile( void )\r
-#else\r
-NextFile( )\r
-#endif\r
-{\r
-       FILE *f;\r
-\r
-       for (;;)\r
-       {\r
-               CurFile++;\r
-               if ( CurFile >= NumFiles ) return(NULL);\r
-               if ( ci_strequ(FileStr[CurFile],"stdin")) return stdin;\r
-               f = fopen(FileStr[CurFile], "r");\r
-               if ( f == NULL )\r
-               {\r
-                       warnNoFL( eMsg1("file %s doesn't exist; ignored", FileStr[CurFile]) );\r
-               }\r
-               else\r
-               {\r
-                       return(f);\r
-               }\r
-       }\r
-}\r
-\r
-/*\r
- * Return a string corresponding to the output file name associated\r
- * with the input file name passed in.\r
- *\r
- * Observe the following rules:\r
- *\r
- *             f.e             --> f".c"\r
- *             f               --> f".c"\r
- *             f.              --> f".c"\r
- *             f.e.g   --> f.e".c"\r
- *\r
- * Where f,e,g are arbitrarily long sequences of characters in a file\r
- * name.\r
- *\r
- * In other words, if a ".x" appears on the end of a file name, make it\r
- * ".c".  If no ".x" appears, append ".c" to the end of the file name.\r
- *\r
- * C++ mode using .cpp not .c.\r
- *\r
- * Use malloc() for new string.\r
- */\r
-\r
-char *\r
-#ifdef __USE_PROTOS\r
-outname( char *fs )\r
-#else\r
-outname( fs )\r
-char *fs;\r
-#endif\r
-{\r
-    if ( GenCC) {\r
-      return outnameX(fs,CPP_FILE_SUFFIX);\r
-    } else {\r
-      return outnameX(fs,".c");\r
-    };\r
-}\r
-\r
-char *\r
-#ifdef __USE_PROTOS\r
-outnameX( char *fs ,char *suffix)\r
-#else\r
-outnameX( fs , suffix )\r
-char *fs;\r
-char *suffix;\r
-#endif\r
-{\r
-       static char buf[MaxFileName+1];\r
-       char *p;\r
-       require(fs!=NULL&&*fs!='\0', "outname: NULL filename");\r
-\r
-       p = buf;\r
-       strcpy(buf, fs);\r
-       while ( *p != '\0' )  {p++;}                    /* Stop on '\0' */\r
-       while ( *p != '.' && p != buf ) {--p;}  /* Find '.' */\r
-       if ( p != buf ) *p = '\0';                              /* Found '.' */\r
-       require(strlen(buf) + 2 < (size_t)MaxFileName, "outname: filename too big");\r
-    strcat(buf,suffix);\r
-       return( buf );\r
-}\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-fatalFL( char *err_, char *f, int l )\r
-#else\r
-fatalFL( err_, f, l )\r
-char *err_;\r
-char *f;\r
-int l;\r
-#endif\r
-{\r
-       fprintf(stderr, ErrHdr, f, l);\r
-       fprintf(stderr, " %s\n", err_);\r
-       cleanUp();\r
-       exit(PCCTS_EXIT_FAILURE);\r
-}\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-fatal_intern( char *err_, char *f, int l )\r
-#else\r
-fatal_intern( err_, f, l )\r
-char *err_;\r
-char *f;\r
-int l;\r
-#endif\r
-{\r
-       fprintf(stderr, ErrHdr, f, l);\r
-       fprintf(stderr, " #$%%*&@# internal error: %s\n", err_);\r
-       fprintf(stderr, ErrHdr, f, l);\r
-       fprintf(stderr, " [complain to nearest government official\n");\r
-       fprintf(stderr, ErrHdr, f, l);\r
-       fprintf(stderr, "  or send hate-mail to parrt@parr-research.com;\n");\r
-       fprintf(stderr, ErrHdr, f, l);\r
-       fprintf(stderr, "  please pray to the ``bug'' gods that there is a trival fix.]\n");\r
-       cleanUp();\r
-       exit(PCCTS_EXIT_FAILURE);\r
-}\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-cleanUp( void )\r
-#else\r
-cleanUp( )\r
-#endif\r
-{\r
-       if ( DefFile != NULL) fclose( DefFile );\r
-}\r
-\r
-/* sprintf up to 3 strings */\r
-char *\r
-#ifdef __USE_PROTOS\r
-eMsg3( char *s, char *a1, char *a2, char *a3 )\r
-#else\r
-eMsg3( s, a1, a2, a3 )\r
-char *s;\r
-char *a1;\r
-char *a2;\r
-char *a3;\r
-#endif\r
-{\r
-       static char buf[250];                   /* DANGEROUS as hell !!!!!! */\r
-       \r
-       sprintf(buf, s, a1, a2, a3);\r
-       return( buf );\r
-}\r
-\r
-/* sprintf a decimal */\r
-char *\r
-#ifdef __USE_PROTOS\r
-eMsgd( char *s, int d )\r
-#else\r
-eMsgd( s, d )\r
-char *s;\r
-int d;\r
-#endif\r
-{\r
-       static char buf[250];                   /* DANGEROUS as hell !!!!!! */\r
-       \r
-       sprintf(buf, s, d);\r
-       return( buf );\r
-}\r
-\r
-char *\r
-#ifdef __USE_PROTOS\r
-eMsgd2( char *s, int d1,int d2)\r
-#else\r
-eMsgd2( s, d1, d2 )\r
-char *s;\r
-int d1;\r
-int d2;\r
-#endif\r
-{\r
-       static char buf[250];                   /* DANGEROUS as hell !!!!!! */\r
-       \r
-       sprintf(buf, s, d1, d2);\r
-       return( buf );\r
-}\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-s_fprT( FILE *f, set e )\r
-#else\r
-s_fprT( f, e )\r
-FILE *f;\r
-set e;\r
-#endif\r
-{\r
-       register unsigned *p;\r
-       unsigned *q;\r
-\r
-       if ( set_nil(e) ) return;\r
-       if ( (q=p=set_pdq(e)) == NULL ) fatal_internal("Can't alloc space for set_pdq");\r
-       fprintf(f, "{");\r
-       while ( *p != nil )\r
-       {\r
-               fprintf(f, " %s", TerminalString(*p));\r
-               p++;\r
-       }\r
-       fprintf(f, " }");\r
-       free((char *)q);\r
-}\r
-\r
-/* Return the token name or regular expression for a token number. */\r
-char *\r
-#ifdef __USE_PROTOS\r
-TerminalString( int token )\r
-#else\r
-TerminalString( token )\r
-int token;\r
-#endif\r
-{\r
-       int     j;\r
-        static    char    imag_name[20];\r
-\r
-       /* look in all lexclasses for the token */\r
-       if ( TokenString(token) != NULL ) return TokenString(token);\r
-       for (j=0; j<NumLexClasses; j++)\r
-       {\r
-               lexmode(j);\r
-               if ( ExprString(token) != NULL ) return ExprString(token);\r
-       }\r
-\r
-    if (1) {\r
-      sprintf(imag_name,"UnknownToken#%d",token);           /* MR13 */\r
-      return imag_name;                                     /* MR13 */\r
-    }\r
-\r
-       require(j<NumLexClasses, eMsgd("No label or expr for token %d",token));\r
-       return "invalid";\r
-}\r
-\r
-                    /* S i m p l e  I n t  S t a c k */\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-pushint( int i )\r
-#else\r
-pushint( i )\r
-int i;\r
-#endif\r
-{\r
-       require(isp>0, "pushint: stack overflow");\r
-       istack[--isp] = i;\r
-}\r
-\r
-int\r
-#ifdef __USE_PROTOS\r
-popint( void )\r
-#else\r
-popint( )\r
-#endif\r
-{\r
-       require(isp<MAX_INT_STACK, "popint: stack underflow");\r
-       return istack[isp++];\r
-}\r
-\r
-int\r
-#ifdef __USE_PROTOS\r
-istacksize( void )\r
-#else\r
-istacksize( )\r
-#endif\r
-{\r
-       return MAX_INT_STACK-isp;\r
-}\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-istackreset( void )\r
-#else\r
-istackreset( )\r
-#endif\r
-{\r
-       isp = MAX_INT_STACK;\r
-}\r
-\r
-int\r
-#ifdef __USE_PROTOS\r
-istackempty( void )\r
-#else\r
-istackempty( )\r
-#endif\r
-{\r
-       return isp==MAX_INT_STACK;\r
-}\r
-\r
-int\r
-#ifdef __USE_PROTOS\r
-topint( void )\r
-#else\r
-topint( )\r
-#endif\r
-{\r
-       require(isp<MAX_INT_STACK, "topint: stack underflow");\r
-       return istack[isp];\r
-}\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-ProcessArgs( int argc, char **argv, Opt *options )\r
-#else\r
-ProcessArgs( argc, argv, options )\r
-int argc;\r
-char **argv;\r
-Opt *options;\r
-#endif\r
-{\r
-       Opt *p;\r
-       require(argv!=NULL, "ProcessArgs: command line NULL");\r
-\r
-       while ( argc-- > 0 )\r
-       {\r
-               p = options;\r
-               while ( p->option != NULL )\r
-               {\r
-                       if ( strcmp(p->option, "*") == 0 ||\r
-                                ci_strequ(p->option, *argv) == 1 )\r
-                       {\r
-                               if ( p->arg )\r
-                               {\r
-/* MR9  26-Sep-97   Check for argv valid                */\r
-                    if (argc-- > 0) {\r
-                                       (*p->process)( *argv, *(argv+1) );\r
-                                           argv++;\r
-                    } else {\r
-fprintf(stderr,"error: required argument for option %s omitted\n",*argv);\r
-exit(PCCTS_EXIT_FAILURE);\r
-                    };\r
-                               }\r
-                               else\r
-                                       (*p->process)( *argv );\r
-                               break;\r
-                       }\r
-                       p++;\r
-               }\r
-               argv++;\r
-       }\r
-}\r
-\r
-static void \r
-#ifdef __USE_PROTOS\r
-CompleteContextGuards(void)\r
-#else\r
-CompleteContextGuards()\r
-#endif\r
-{\r
-    ListNode *      p;\r
-    Predicate *     pred;\r
-\r
-    if (ContextGuardPredicateList == NULL) return;\r
-\r
-    for (p=ContextGuardPredicateList->next; p != NULL; p=p->next) {\r
-      pred=(Predicate *)p->elem;\r
-      recomputeContextGuard(pred);\r
-    }\r
-}\r
-\r
-/* Go back into the syntax diagram and compute all meta tokens; i.e.\r
- * turn all '.', ranges, token class refs etc... into actual token sets\r
- */\r
-static void\r
-#ifdef __USE_PROTOS\r
-CompleteTokenSetRefs(void)\r
-#else\r
-CompleteTokenSetRefs()\r
-#endif\r
-{\r
-       ListNode *p;\r
-\r
-       if ( MetaTokenNodes==NULL ) return;\r
-       for (p = MetaTokenNodes->next; p!=NULL; p=p->next)\r
-       {\r
-               set a,b;\r
-\r
-               TokNode *q = (TokNode *)p->elem;\r
-               if ( q->wild_card )\r
-               {\r
-                       q->tset = all_tokens;\r
-               }\r
-               else if ( q->tclass!=NULL )\r
-               {\r
-                       if ( q->complement ) q->tset = set_dif(all_tokens, q->tclass->tset);\r
-                       else q->tset = q->tclass->tset;\r
-               }\r
-               else if ( q->upper_range!=0 )\r
-               {\r
-                       /* we have a range on our hands: make a set from q->token .. q->upper_range */\r
-                       int i;\r
-                       a = empty;\r
-                       for (i=q->token; i<=q->upper_range; i++) { set_orel(i, &a); }   /* MR13 */\r
-\r
-/* MR13 */    if (q->complement) {\r
-/* MR13 */      q->tset = set_dif(all_tokens, a);\r
-/* MR13 */        set_free(a);\r
-/* MR13 */      } else {\r
-/* MR13 */           q->tset = a;\r
-/* MR13 */      }\r
-\r
-        }\r
-\r
-               /* at this point, it can only be a complemented single token */\r
-               else if ( q->complement )\r
-               {\r
-                       a = set_of(q->token);\r
-                       b = set_dif(all_tokens, a);\r
-                       set_free(a);\r
-                       q->tset=b;\r
-               }\r
-               else fatal("invalid meta token");\r
-       }\r
-}\r
-\r
-/* MR10: Jeff Vincent\r
-   MR10: Changed to remove directory information from n only if\r
-   MR10: if OutputDirectory was changed by user (-o option)\r
-*/\r
-\r
-char *\r
-#ifdef __USE_PROTOS\r
-OutMetaName(char *n)\r
-#else\r
-OutMetaName(n)\r
-char *n;\r
-#endif\r
-{      \r
-    static char *dir_sym = DirectorySymbol;\r
-    static char newname[MaxFileName+1];\r
-    char *p;\r
-\r
-       /* If OutputDirectory is same as TopDirectory (platform default) then leave n alone. */\r
-    if (strcmp(OutputDirectory, TopDirectory) == 0)            /* TopDirectory is "." on Unix. */\r
-               return n;\r
-\r
-       /* p will point to filename without path information */\r
-       if ((p = strrchr(n, *dir_sym)) != NULL)                         /* Directory symbol is "/" on Unix. */\r
-               p++;\r
-       else\r
-               p = n;\r
-\r
-       /* Copy new output directory into newname[] */\r
-       strcpy(newname, OutputDirectory);\r
-\r
-       /* if new output directory does not have trailing dir_sym, add it! */\r
-       if (newname[strlen(newname)-1] != *dir_sym) {\r
-               strcat(newname, dir_sym);\r
-       }\r
-       strcat(newname, p);\r
-       return newname;\r
-}\r
-\r
-char *\r
-#ifdef __USE_PROTOS\r
-pcctsBaseName(char *n) /* MR32 */\r
-#else\r
-pcctsBaseName(n)\r
-char *n;\r
-#endif\r
-{\r
-    static char newname[MaxFileName+1];\r
-    static char* dir_sym = DirectorySymbol;\r
-    int count = 0;\r
-    char *p;\r
-\r
-    p = n;\r
-\r
-    while ( *p != '\0' )  {p++;}                    /* go to end of string */\r
-    while ( (*p != *dir_sym) && (p != n) ) {--p;}   /* Find last DirectorySymbol */\r
-    while ( *p == *dir_sym) p++;                    /* step forward if we're on a dir symbol */\r
-    while ( *p != '\0' && *p != '.')\r
-    {\r
-        newname[count++] = *p;\r
-        p++;\r
-    }                                               /* create a new name */\r
-    newname[count] = '\0';\r
-    return newname;\r
-}\r
-\r
-static void\r
-#ifdef __USE_PROTOS\r
-ensure_no_C_file_collisions(char *class_c_file)\r
-#else\r
-ensure_no_C_file_collisions(class_c_file)\r
-char *class_c_file;\r
-#endif\r
-{\r
-       int i;\r
-\r
-       for (i=0; i<NumFiles; i++)\r
-       {\r
-\r
-#ifdef PCCTS_CASE_INSENSITIVE_FILE_NAME\r
-               /* assume that file names are case insensitive */\r
-               if ( STRICMP(outname(FileStr[i]), class_c_file)==0 )\r
-#else\r
-               if ( strcmp(outname(FileStr[i]), class_c_file)==0 )\r
-#endif\r
-               {\r
-                       fatal(eMsg1("class def output file conflicts with parser output file: %s",\r
-                                               outname(FileStr[i])));\r
-               }\r
-       }\r
-}\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-warnNoFL(char *err)\r
-#else\r
-warnNoFL(err)\r
-char *err;\r
-#endif\r
-{\r
-       fprintf(stderr, "warning: %s\n", err);\r
-}\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-warnFL(char *err,char *f,int l)\r
-#else\r
-warnFL(err,f,l)\r
-char *f;\r
-int l;\r
-char *err;\r
-#endif\r
-{\r
-       fprintf(stderr, ErrHdr, f, l);                                          \r
-       fprintf(stderr, " warning: %s\n", err);\r
-}\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-warn(char *err)                                                                                                \r
-#else\r
-warn(err)                                                                                              \r
-char *err;\r
-#endif\r
-{\r
-       /* back up the file number if we hit an error at the end of the last file */\r
-       if ( CurFile >= NumFiles && CurFile >= 1 ) CurFile--;\r
-       fprintf(stderr, ErrHdr, FileStr[CurFile], zzline);\r
-       fprintf(stderr, " warning: %s\n", err);\r
-}\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-warnNoCR( char *err )\r
-#else\r
-warnNoCR( err )                                                                                        \r
-char *err;\r
-#endif\r
-{\r
-       /* back up the file number if we hit an error at the end of the last file */\r
-       if ( CurFile >= NumFiles && CurFile >= 1 ) CurFile--;\r
-       fprintf(stderr, ErrHdr, FileStr[CurFile], zzline);\r
-       fprintf(stderr, " warning: %s", err);\r
-}\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-errNoFL(char *err)\r
-#else\r
-errNoFL(err)\r
-char *err;\r
-#endif\r
-{\r
-       fprintf(stderr, "error: %s\n", err);\r
-}\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-errFL(char *err,char *f,int l)\r
-#else\r
-errFL(err,f,l)\r
-char *err;\r
-char *f;\r
-int l;\r
-#endif\r
-{\r
-       fprintf(stderr, ErrHdr, f, l);                                          \r
-       fprintf(stderr, " error: %s\n", err);\r
-}\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-err(char *err)                                                                                         \r
-#else\r
-err(err)                                                                                               \r
-char *err;\r
-#endif\r
-{\r
-       /* back up the file number if we hit an error at the end of the last file */\r
-       if ( CurFile >= NumFiles && CurFile >= 1 ) CurFile--;\r
-       fprintf(stderr, ErrHdr, FileStr[CurFile], zzline);\r
-       fprintf(stderr, " error: %s\n", err);\r
-}\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-errNoCR( char *err )                                                                                   \r
-#else\r
-errNoCR( err )                                                                                 \r
-char *err;\r
-#endif\r
-{\r
-       /* back up the file number if we hit an error at the end of the last file */\r
-       if ( CurFile >= NumFiles && CurFile >= 1 ) CurFile--;\r
-       fprintf(stderr, ErrHdr, FileStr[CurFile], zzline);\r
-       fprintf(stderr, " error: %s", err);\r
-}\r
-\r
-UserAction *\r
-#ifdef __USE_PROTOS\r
-newUserAction(char *s)\r
-#else\r
-newUserAction(s)\r
-char *s;\r
-#endif\r
-{\r
-       UserAction *ua = (UserAction *) calloc(1, sizeof(UserAction));\r
-       require(ua!=NULL, "cannot allocate UserAction");\r
-\r
-       ua->action = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char));\r
-       strcpy(ua->action, s);\r
-       return ua;\r
-}\r
-\r
-/* Added by TJP September 1994 */\r
-/* Take in file.h and return file_h; names w/o '.'s are left alone */\r
-char *\r
-#ifdef __USE_PROTOS\r
-gate_symbol(char *name)\r
-#else\r
-gate_symbol(name)\r
-char *name;\r
-#endif\r
-{\r
-       static char buf[100];\r
-       char *p;\r
-       sprintf(buf, "%s", name);\r
-\r
-       for (p=buf; *p!='\0'; p++)\r
-       {\r
-               if ( *p=='.' ) *p = '_';\r
-       }\r
-       return buf;\r
-}\r
-\r
-char *\r
-#ifdef __USE_PROTOS\r
-makeAltID(int blockid, int altnum)\r
-#else\r
-makeAltID(blockid, altnum)\r
-int blockid;\r
-int altnum;\r
-#endif\r
-{\r
-       static char buf[100];\r
-       char *p;\r
-       sprintf(buf, "_blk%d_alt%d", blockid, altnum);\r
-       p = (char *)malloc(strlen(buf)+1);\r
-       strcpy(p, buf);\r
-       return p;\r
-}\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/antlr/makefile b/Tools/CodeTools/TianoTools/Pccts/antlr/makefile
deleted file mode 100644 (file)
index 2aa6cdf..0000000
+++ /dev/null
@@ -1,218 +0,0 @@
-#\r
-# Makefile for ANTLR 1.33\r
-#\r
-# SOFTWARE RIGHTS\r
-#\r
-# We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
-# Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
-# company may do whatever they wish with source code distributed with\r
-# PCCTS or the code generated by PCCTS, including the incorporation of\r
-# PCCTS, or its output, into commerical software.\r
-# \r
-# We encourage users to develop software with PCCTS.  However, we do ask\r
-# that credit is given to us for developing PCCTS.  By "credit",\r
-# we mean that if you incorporate our source code into one of your\r
-# programs (commercial product, research project, or otherwise) that you\r
-# acknowledge this fact somewhere in the documentation, research report,\r
-# etc...  If you like PCCTS and have developed a nice tool with the\r
-# output, please mention that you developed it using PCCTS.  In\r
-# addition, we ask that this header remain intact in our source code.\r
-# As long as these guidelines are kept, we expect to continue enhancing\r
-# this system and expect to make other tools available as they are\r
-# completed.\r
-#\r
-# ANTLR 1.33\r
-# Terence Parr\r
-# Parr Research Corporation\r
-# with Purdue University\r
-# and AHPCRC, University of Minnesota\r
-# 1989-1995\r
-#\r
-# Ported to Borland C++, IBM C-Set/2 and Microsoft 6.0 by\r
-# Ed Harfmann\r
-# Micro Data Base Systems\r
-# Lafayette, Indiana\r
-#\r
-SET=../support/set\r
-PCCTS_H=../h\r
-\r
-##\r
-## Uncomment the appropriate section to build\r
-## (both targets and 'make' variable definitions)\r
-## Note that UNIX is the default\r
-##\r
-\r
-#\r
-#   OS/2 & DOS 16 bit using MSC 6.0\r
-#\r
-#CC=cl\r
-#ANTLR=..\bin\antlr\r
-#DLG=..\bin\dlg\r
-#CFLAGS= -I. -I$(SET) -I$(PCCTS_H) /AL /Za /W3 -DPC -DUSER_ZZSYN\r
-#OUT_OBJ = -Fo\r
-#LIBS=/NOD:LLIBCE LLIBCEP\r
-#OBJ_EXT = obj\r
-#\r
-#antlr.exe: antlr.obj scan.obj err.obj bits.obj build.obj fset2.obj \\r
-#        fset.obj gen.obj globals.obj hash.obj lex.obj main.obj \\r
-#        misc.obj set.obj pred.obj egamn.obj\r
-#       link @<<\r
-#$** /NOI\r
-#$@ /STACK:14336\r
-#\r
-#$(LIBS: = +^\r
-#)\r
-#$(DEF_FILE) $(LFLAGS) ;\r
-#<<\r
-#        bind $@ c:\os2\doscalls.lib\r
-#        copy *.exe ..\bin\r
-#\r
-\r
-#\r
-#   Borland C++ for DOS\r
-#\r
-#CC=bcc\r
-#ANTLR=..\bin\antlr\r
-#DLG=..\bin\dlg\r
-#CFLAGS= -I. -I$(SET) -I$(PCCTS_H) -ml -ff- -w- -DPC -DUSER_ZZSYN\r
-#OUT_OBJ = -o\r
-#LIBS= emu mathl cl\r
-#OBJ_EXT = obj\r
-#\r
-#antlr.exe: antlr.obj scan.obj err.obj bits.obj build.obj fset2.obj \\r
-#        fset.obj gen.obj globals.obj hash.obj lex.obj main.obj \\r
-#        misc.obj set.obj pred.obj egman.obj mrhoist.obj fcache.obj\r
-#       tlink @&&|\r
-#C0L $**\r
-#$@ /Tde /c\r
-#\r
-#$(LIBS)\r
-#$(DEF_FILE) $(LFLAGS) ;\r
-#|\r
-#        copy *.exe ..\bin\r
-#\r
-\r
-#\r
-# C-Set/2 for OS/2\r
-#\r
-#CC=icc\r
-#CFLAGS= -I. -I$(SET) -I$(PCCTS_H) /Sa /W3 -DUSER_ZZSYN -D__STDC__\r
-#OUT_OBJ = -Fo\r
-#LIBS=\r
-#ANTLR=..\bin\antlr\r
-#DLG=..\bin\dlg\r
-#OBJ_EXT = obj\r
-#\r
-#antlr.exe: antlr.obj scan.obj err.obj bits.obj build.obj fset2.obj \\r
-#        fset.obj gen.obj globals.obj hash.obj lex.obj main.obj \\r
-#        misc.obj set.obj pred.obj egman.obj mrhoist.obj fcache.obj\r
-#        link386 @<<\r
-#$** /NOI\r
-#$@ /STACK:32768\r
-#\r
-#$(LIBS: = +^\r
-#)\r
-#$(DEF_FILE) $(LFLAGS) ;\r
-#<<\r
-#        copy *.exe ..\bin\r
-#\r
-\r
-#\r
-# Borland C++ for OS/2\r
-#\r
-#CC=bcc\r
-#CFLAGS= -I. -I$(SET) -I$(PCCTS_H) -w- -v -DUSER_ZZSYN\r
-#OUT_OBJ = -o\r
-#LIBS= c2 os2\r
-#\r
-#ANTLR=..\bin\antlr\r
-#DLG=..\bin\dlg\r
-#OBJ_EXT = obj\r
-#antlr.exe: antlr.obj scan.obj err.obj bits.obj build.obj fset2.obj \\r
-#        fset.obj gen.obj globals.obj hash.obj lex.obj main.obj \\r
-#        misc.obj set.obj pred.obj egman.obj mrhoist.obj fcache.obj\r
-#        tlink @&&|\r
-#c02 $** -c -v\r
-#antlr.exe\r
-#\r
-#C2 os2\r
-#\r
-#|\r
-#        copy *.exe ..\bin\r
-#\r
-\r
-# *********** Target list of PC machines ***********\r
-#\r
-# Don't worry about the ambiguity messages coming from antlr\r
-# for making antlr.c etc...  [should be 10 of them, I think]\r
-#\r
-#antlr.c stdpccts.h parser.dlg tokens.h err.c : antlr.g\r
-#      $(ANTLR) antlr.g\r
-#\r
-#antlr.$(OBJ_EXT): antlr.c mode.h tokens.h\r
-#\r
-#scan.$(OBJ_EXT): scan.c mode.h tokens.h\r
-#\r
-#scan.c mode.h: parser.dlg\r
-#      $(DLG) -C2 parser.dlg scan.c\r
-#\r
-#set.$(OBJ_EXT): $(SET)/set.c\r
-#      $(CC) $(CFLAGS) -c $(OUT_OBJ)set.$(OBJ_EXT) $(SET)/set.c\r
-\r
-\r
-\r
-#\r
-#   UNIX  (default)\r
-#\r
-CC=gcc\r
-COPT=-O\r
-ANTLR=${BIN_DIR}/antlr\r
-DLG=${BIN_DIR}/dlg\r
-OBJ_EXT=o\r
-OUT_OBJ = -o\r
-CFLAGS= $(COPT) -I. -I$(SET) -I$(PCCTS_H) -DUSER_ZZSYN $(COTHER) -DZZLEXBUFSIZE=65536\r
-#\r
-# SGI Users, use this CFLAGS\r
-#\r
-#CFLAGS= -O -I. -I$(SET) -I$(PCCTS_H) -DUSER_ZZSYN -woff 3262\r
-OBJ=antlr.o scan.o err.o bits.o build.o fset2.o fset.o gen.o  \\r
-        globals.o hash.o lex.o main.o misc.o set.o pred.o egman.o mrhoist.o fcache.o\r
-\r
-antlr : $(OBJ) $(SRC)\r
-               $(CC) $(CFLAGS) -o $(BIN_DIR)/antlr $(OBJ)\r
-\r
-# what files does PCCTS generate (both ANTLR and DLG)\r
-PCCTS_GEN=antlr.c scan.c err.c tokens.h mode.h parser.dlg stdpccts.h remap.h\r
-\r
-SRC=antlr.c scan.c err.c bits.c build.c fset2.c fset.c gen.c globals.c \\r
-       hash.c lex.c main.c misc.c $(SET)/set.c pred.c egman.c mrhoist.c fcache.c\r
-\r
-#\r
-# Don't worry about the ambiguity messages coming from antlr\r
-# for making antlr.c etc...  [should be 10 of them, I think]\r
-#\r
-#antlr.c stdpccts.h parser.dlg tokens.h err.c : antlr.g\r
-#      $(ANTLR) -gh antlr.g\r
-\r
-antlr.o : antlr.c mode.h tokens.h\r
-\r
-scan.o : scan.c mode.h tokens.h\r
-\r
-#scan.c mode.h: parser.dlg\r
-#      $(DLG) -C2 parser.dlg scan.c\r
-\r
-set.o : $(SET)/set.c\r
-       $(CC) $(CFLAGS) -c -o set.o $(SET)/set.c\r
-\r
-\r
-#\r
-# ****** These next targets are common to UNIX and PC world ********\r
-#\r
-\r
-#clean up all the intermediate files\r
-clean:\r
-       rm -f *.$(OBJ_EXT) core\r
-\r
-#remove everything in clean plus the PCCTS files generated\r
-scrub:\r
-       rm -f $(PCCTS_GEN) *.$(OBJ_EXT) core\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/antlr/makefile.cygwin b/Tools/CodeTools/TianoTools/Pccts/antlr/makefile.cygwin
deleted file mode 100644 (file)
index 956de0b..0000000
+++ /dev/null
@@ -1,219 +0,0 @@
-#\r
-# Makefile for ANTLR 1.33\r
-#\r
-# SOFTWARE RIGHTS\r
-#\r
-# We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
-# Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
-# company may do whatever they wish with source code distributed with\r
-# PCCTS or the code generated by PCCTS, including the incorporation of\r
-# PCCTS, or its output, into commerical software.\r
-# \r
-# We encourage users to develop software with PCCTS.  However, we do ask\r
-# that credit is given to us for developing PCCTS.  By "credit",\r
-# we mean that if you incorporate our source code into one of your\r
-# programs (commercial product, research project, or otherwise) that you\r
-# acknowledge this fact somewhere in the documentation, research report,\r
-# etc...  If you like PCCTS and have developed a nice tool with the\r
-# output, please mention that you developed it using PCCTS.  In\r
-# addition, we ask that this header remain intact in our source code.\r
-# As long as these guidelines are kept, we expect to continue enhancing\r
-# this system and expect to make other tools available as they are\r
-# completed.\r
-#\r
-# ANTLR 1.33\r
-# Terence Parr\r
-# Parr Research Corporation\r
-# with Purdue University\r
-# and AHPCRC, University of Minnesota\r
-# 1989-1995\r
-#\r
-# Ported to Borland C++, IBM C-Set/2 and Microsoft 6.0 by\r
-# Ed Harfmann\r
-# Micro Data Base Systems\r
-# Lafayette, Indiana\r
-#\r
-SET=../support/set\r
-PCCTS_H=../h\r
-\r
-##\r
-## Uncomment the appropriate section to build\r
-## (both targets and 'make' variable definitions)\r
-## Note that UNIX is the default\r
-##\r
-\r
-#\r
-#   OS/2 & DOS 16 bit using MSC 6.0\r
-#\r
-#CC=cl\r
-#ANTLR=..\bin\antlr\r
-#DLG=..\bin\dlg\r
-#CFLAGS= -I. -I$(SET) -I$(PCCTS_H) /AL /Za /W3 -DPC -DUSER_ZZSYN\r
-#OUT_OBJ = -Fo\r
-#LIBS=/NOD:LLIBCE LLIBCEP\r
-#OBJ_EXT = obj\r
-#\r
-#antlr.exe: antlr.obj scan.obj err.obj bits.obj build.obj fset2.obj \\r
-#        fset.obj gen.obj globals.obj hash.obj lex.obj main.obj \\r
-#        misc.obj set.obj pred.obj egamn.obj\r
-#       link @<<\r
-#$** /NOI\r
-#$@ /STACK:14336\r
-#\r
-#$(LIBS: = +^\r
-#)\r
-#$(DEF_FILE) $(LFLAGS) ;\r
-#<<\r
-#        bind $@ c:\os2\doscalls.lib\r
-#        copy *.exe ..\bin\r
-#\r
-\r
-#\r
-#   Borland C++ for DOS\r
-#\r
-#CC=bcc\r
-#ANTLR=..\bin\antlr\r
-#DLG=..\bin\dlg\r
-#CFLAGS= -I. -I$(SET) -I$(PCCTS_H) -ml -ff- -w- -DPC -DUSER_ZZSYN\r
-#OUT_OBJ = -o\r
-#LIBS= emu mathl cl\r
-#OBJ_EXT = obj\r
-#\r
-#antlr.exe: antlr.obj scan.obj err.obj bits.obj build.obj fset2.obj \\r
-#        fset.obj gen.obj globals.obj hash.obj lex.obj main.obj \\r
-#        misc.obj set.obj pred.obj egman.obj mrhoist.obj fcache.obj\r
-#       tlink @&&|\r
-#C0L $**\r
-#$@ /Tde /c\r
-#\r
-#$(LIBS)\r
-#$(DEF_FILE) $(LFLAGS) ;\r
-#|\r
-#        copy *.exe ..\bin\r
-#\r
-\r
-#\r
-# C-Set/2 for OS/2\r
-#\r
-#CC=icc\r
-#CFLAGS= -I. -I$(SET) -I$(PCCTS_H) /Sa /W3 -DUSER_ZZSYN -D__STDC__\r
-#OUT_OBJ = -Fo\r
-#LIBS=\r
-#ANTLR=..\bin\antlr\r
-#DLG=..\bin\dlg\r
-#OBJ_EXT = obj\r
-#\r
-#antlr.exe: antlr.obj scan.obj err.obj bits.obj build.obj fset2.obj \\r
-#        fset.obj gen.obj globals.obj hash.obj lex.obj main.obj \\r
-#        misc.obj set.obj pred.obj egman.obj mrhoist.obj fcache.obj\r
-#        link386 @<<\r
-#$** /NOI\r
-#$@ /STACK:32768\r
-#\r
-#$(LIBS: = +^\r
-#)\r
-#$(DEF_FILE) $(LFLAGS) ;\r
-#<<\r
-#        copy *.exe ..\bin\r
-#\r
-\r
-#\r
-# Borland C++ for OS/2\r
-#\r
-#CC=bcc\r
-#CFLAGS= -I. -I$(SET) -I$(PCCTS_H) -w- -v -DUSER_ZZSYN\r
-#OUT_OBJ = -o\r
-#LIBS= c2 os2\r
-#\r
-#ANTLR=..\bin\antlr\r
-#DLG=..\bin\dlg\r
-#OBJ_EXT = obj\r
-#antlr.exe: antlr.obj scan.obj err.obj bits.obj build.obj fset2.obj \\r
-#        fset.obj gen.obj globals.obj hash.obj lex.obj main.obj \\r
-#        misc.obj set.obj pred.obj egman.obj mrhoist.obj fcache.obj\r
-#        tlink @&&|\r
-#c02 $** -c -v\r
-#antlr.exe\r
-#\r
-#C2 os2\r
-#\r
-#|\r
-#        copy *.exe ..\bin\r
-#\r
-\r
-# *********** Target list of PC machines ***********\r
-#\r
-# Don't worry about the ambiguity messages coming from antlr\r
-# for making antlr.c etc...  [should be 10 of them, I think]\r
-#\r
-#antlr.c stdpccts.h parser.dlg tokens.h err.c : antlr.g\r
-#      $(ANTLR) antlr.g\r
-#\r
-#antlr.$(OBJ_EXT): antlr.c mode.h tokens.h\r
-#\r
-#scan.$(OBJ_EXT): scan.c mode.h tokens.h\r
-#\r
-#scan.c mode.h: parser.dlg\r
-#      $(DLG) -C2 parser.dlg scan.c\r
-#\r
-#set.$(OBJ_EXT): $(SET)/set.c\r
-#      $(CC) $(CFLAGS) -c $(OUT_OBJ)set.$(OBJ_EXT) $(SET)/set.c\r
-\r
-\r
-\r
-#\r
-#   UNIX  (default)\r
-#\r
-BIN_DIR=../../../../bin\r
-CC=gcc\r
-COPT=-O\r
-ANTLR=$(BIN_DIR)/antlr.exe\r
-DLG=${BIN_DIR}/dlg.exe\r
-OBJ_EXT=o\r
-OUT_OBJ = -o\r
-CFLAGS= $(COPT) -I. -I$(SET) -I$(PCCTS_H) -DUSER_ZZSYN $(COTHER) -DZZLEXBUFSIZE=65536\r
-#\r
-# SGI Users, use this CFLAGS\r
-#\r
-#CFLAGS= -O -I. -I$(SET) -I$(PCCTS_H) -DUSER_ZZSYN -woff 3262\r
-OBJ=antlr.o scan.o err.o bits.o build.o fset2.o fset.o gen.o  \\r
-        globals.o hash.o lex.o main.o misc.o set.o pred.o egman.o mrhoist.o fcache.o\r
-\r
-antlr : $(OBJ) $(SRC)\r
-               $(CC) $(CFLAGS) -o $(BIN_DIR)/antlr.exe $(OBJ)\r
-\r
-# what files does PCCTS generate (both ANTLR and DLG)\r
-PCCTS_GEN=antlr.c scan.c err.c tokens.h mode.h parser.dlg stdpccts.h remap.h\r
-\r
-SRC=antlr.c scan.c err.c bits.c build.c fset2.c fset.c gen.c globals.c \\r
-       hash.c lex.c main.c misc.c $(SET)/set.c pred.c egman.c mrhoist.c fcache.c\r
-\r
-#\r
-# Don't worry about the ambiguity messages coming from antlr\r
-# for making antlr.c etc...  [should be 10 of them, I think]\r
-#\r
-#antlr.c stdpccts.h parser.dlg tokens.h err.c : antlr.g\r
-#      $(ANTLR) -gh antlr.g\r
-\r
-antlr.o : antlr.c mode.h tokens.h\r
-\r
-scan.o : scan.c mode.h tokens.h\r
-\r
-#scan.c mode.h: parser.dlg\r
-#      $(DLG) -C2 parser.dlg scan.c\r
-\r
-set.o : $(SET)/set.c\r
-       $(CC) $(CFLAGS) -c -o set.o $(SET)/set.c\r
-\r
-\r
-#\r
-# ****** These next targets are common to UNIX and PC world ********\r
-#\r
-\r
-#clean up all the intermediate files\r
-clean:\r
-       rm -f *.$(OBJ_EXT) core\r
-\r
-#remove everything in clean plus the PCCTS files generated\r
-scrub:\r
-       rm -f $(PCCTS_GEN) *.$(OBJ_EXT) core\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/antlr/makefile1 b/Tools/CodeTools/TianoTools/Pccts/antlr/makefile1
deleted file mode 100644 (file)
index dffc709..0000000
+++ /dev/null
@@ -1,96 +0,0 @@
-#\r
-# Makefile for ANTLR 1.33\r
-#\r
-# SOFTWARE RIGHTS\r
-#\r
-# We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
-# Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
-# company may do whatever they wish with source code distributed with\r
-# PCCTS or the code generated by PCCTS, including the incorporation of\r
-# PCCTS, or its output, into commerical software.\r
-# \r
-# We encourage users to develop software with PCCTS.  However, we do ask\r
-# that credit is given to us for developing PCCTS.  By "credit",\r
-# we mean that if you incorporate our source code into one of your\r
-# programs (commercial product, research project, or otherwise) that you\r
-# acknowledge this fact somewhere in the documentation, research report,\r
-# etc...  If you like PCCTS and have developed a nice tool with the\r
-# output, please mention that you developed it using PCCTS.  In\r
-# addition, we ask that this header remain intact in our source code.\r
-# As long as these guidelines are kept, we expect to continue enhancing\r
-# this system and expect to make other tools available as they are\r
-# completed.\r
-#\r
-# ANTLR 1.33\r
-# Terence Parr\r
-# Parr Research Corporation\r
-# with Purdue University\r
-# and AHPCRC, University of Minnesota\r
-# 1989-1995\r
-#\r
-# Ported to Borland C++, IBM C-Set/2 and Microsoft 6.0 by\r
-# Ed Harfmann\r
-# Micro Data Base Systems\r
-# Lafayette, Indiana\r
-#\r
-SET=../support/set\r
-PCCTS_H=../h\r
-\r
-#\r
-#   UNIX  (default)\r
-#\r
-CC=cc\r
-ANTLR=${WORKSPACE}/Tools/bin/antlr\r
-DLG=${WORKSPACE}/Tools/bin/dlg\r
-OBJ_EXT=o\r
-OUT_OBJ = -o\r
-ANSI=-ansi\r
-AOTHER=\r
-CFLAGS= -O0 -g -I. -I$(SET) -I$(PCCTS_H) -DUSER_ZZSYN $(COTHER) $(ANSI) -DZZLEXBUFSIZE=32000\r
-#\r
-# SGI Users, use this CFLAGS\r
-#\r
-#CFLAGS= -O -I. -I$(SET) -I$(PCCTS_H) -DUSER_ZZSYN -woff 3262\r
-\r
-OBJ=antlr.o scan.o err.o bits.o build.o fset2.o fset.o gen.o \\r
-        globals.o hash.o lex.o main.o misc.o set.o pred.o egman.o mrhoist.o fcache.o $(OBJOTHER)\r
-\r
-antlr : $(OBJ) $(SRC)\r
-               $(CC) $(CFLAGS) -o antlr $(OBJ)\r
-               mv antlr ${WORKSPACE}/Tools/bin\r
-\r
-# what files does PCCTS generate (both ANTLR and DLG)\r
-PCCTS_GEN=antlr.c scan.c err.c tokens.h mode.h parser.dlg stdpccts.h remap.h\r
-\r
-SRC=antlr.c scan.c err.c bits.c build.c fset2.c fset.c gen.c globals.c \\r
-       hash.c lex.c main.c misc.c $(SET)/set.c pred.c egman.c mrhoist.c fcache.c\r
-\r
-#\r
-# Don't worry about the ambiguity messages coming from antlr\r
-# for making antlr.c etc...  [should be 10 of them, I think]\r
-#\r
-antlr.c stdpccts.h parser.dlg tokens.h err.c : antlr.g\r
-       $(ANTLR) -gh antlr.g $(AOTHER)\r
-\r
-antlr.o : antlr.c mode.h tokens.h\r
-\r
-scan.o : scan.c mode.h tokens.h\r
-\r
-scan.c mode.h: parser.dlg\r
-       $(DLG) -C2 parser.dlg scan.c\r
-\r
-set.o : $(SET)/set.c\r
-       $(CC) $(CFLAGS) -c -o set.o $(SET)/set.c\r
-\r
-\r
-#\r
-# ****** These next targets are common to UNIX and PC world ********\r
-#\r
-\r
-#clean up all the intermediate files\r
-clean:\r
-       rm -f *.$(OBJ_EXT) core\r
-\r
-#remove everything in clean plus the PCCTS files generated\r
-scrub:\r
-       rm -f $(PCCTS_GEN) *.$(OBJ_EXT) core\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/antlr/misc.c b/Tools/CodeTools/TianoTools/Pccts/antlr/misc.c
deleted file mode 100644 (file)
index 3f58da3..0000000
+++ /dev/null
@@ -1,1864 +0,0 @@
-/*\r
- * misc.c\r
- *\r
- * Manage tokens, regular expressions.\r
- * Print methods for debugging\r
- * Compute follow lists onto tail ends of rules.\r
- *\r
- * The following functions are visible:\r
- *\r
- *             int             addTname(char *);               Add token name\r
- *             int             addTexpr(char *);               Add token expression\r
- *             int             Tnum(char *);                   Get number of expr/token\r
- *             void    Tklink(char *, char *); Link a name with an expression\r
- *             int             hasAction(expr);                Does expr already have action assigned?\r
- *             void    setHasAction(expr);             Indicate that expr now has an action\r
- *             Entry   *newEntry(char *,int);  Create new table entry with certain size\r
- *             void    list_add(ListNode **list, char *e)\r
- *      void    list_free(ListNode **list, int freeData);   *** MR10 ***\r
- *             void    list_apply(ListNode *list, void (*f)())\r
- *             void    lexclass(char *m);              switch to new/old lexical class\r
- *             void    lexmode(int i);                 switch to old lexical class i\r
- *\r
- * SOFTWARE RIGHTS\r
- *\r
- * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
- * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
- * company may do whatever they wish with source code distributed with\r
- * PCCTS or the code generated by PCCTS, including the incorporation of\r
- * PCCTS, or its output, into commerical software.\r
- *\r
- * We encourage users to develop software with PCCTS.  However, we do ask\r
- * that credit is given to us for developing PCCTS.  By "credit",\r
- * we mean that if you incorporate our source code into one of your\r
- * programs (commercial product, research project, or otherwise) that you\r
- * acknowledge this fact somewhere in the documentation, research report,\r
- * etc...  If you like PCCTS and have developed a nice tool with the\r
- * output, please mention that you developed it using PCCTS.  In\r
- * addition, we ask that this header remain intact in our source code.\r
- * As long as these guidelines are kept, we expect to continue enhancing\r
- * this system and expect to make other tools available as they are\r
- * completed.\r
- *\r
- * ANTLR 1.33\r
- * Terence Parr\r
- * Parr Research Corporation\r
- * with Purdue University and AHPCRC, University of Minnesota\r
- * 1989-2001\r
- */\r
-\r
-#include <stdio.h>\r
-#include "pcctscfg.h"\r
-#include "set.h"\r
-#include "syn.h"\r
-#include "hash.h"\r
-#include "generic.h"\r
-#include "dlgdef.h"\r
-#include <ctype.h>\r
-\r
-static int tsize=TSChunk;              /* size of token str arrays */\r
-\r
-static void\r
-#ifdef __USE_PROTOS\r
-RemapForcedTokensInSyntaxDiagram(Node *);\r
-#else\r
-RemapForcedTokensInSyntaxDiagram();\r
-#endif\r
-\r
-                               /* T o k e n  M a n i p u l a t i o n */\r
-\r
-/*\r
- * add token 't' to the TokenStr/Expr array.  Make more room if necessary.\r
- * 't' is either an expression or a token name.\r
- *\r
- * There is only one TokenStr array, but multiple ExprStr's.  Therefore,\r
- * for each lex class (element of lclass) we must extend the ExprStr array.\r
- * ExprStr's and TokenStr are always all the same size.\r
- *\r
- * Also, there is a Texpr hash table for each automaton.\r
- */\r
-static void\r
-#ifdef __USE_PROTOS\r
-Ttrack( char *t )\r
-#else\r
-Ttrack( t )\r
-char *t;\r
-#endif\r
-{\r
-       if ( TokenNum >= tsize )        /* terminal table overflow? */\r
-       {\r
-               char **p;\r
-               int i, more, j;\r
-\r
-               more = TSChunk * (1 + ((TokenNum-tsize) / TSChunk));\r
-               tsize += more;\r
-               TokenStr = (char **) realloc((char *)TokenStr, tsize*sizeof(char *));\r
-               require(TokenStr != NULL, "Ttrack: can't extend TokenStr");\r
-               for (i=0; i<NumLexClasses; i++)\r
-               {\r
-                       lclass[i].exprs = (char **)\r
-                                                         realloc((char *)lclass[i].exprs, tsize*sizeof(char *));\r
-                       require(lclass[i].exprs != NULL, "Ttrack: can't extend ExprStr");\r
-                       for (p= &lclass[i].exprs[tsize-more],j=1; j<=more; j++) *p++ = NULL;\r
-               }\r
-               for (p= &TokenStr[tsize-more],i=1; i<=more; i++) *p++ = NULL;\r
-               lexmode( CurrentLexClass ); /* reset ExprStr in case table moved */\r
-       }\r
-       /* note: we use the actual ExprStr/TokenStr array\r
-        * here as TokenInd doesn't exist yet\r
-        */\r
-       if ( *t == '"' ) ExprStr[TokenNum] = t;\r
-       else TokenStr[TokenNum] = t;\r
-}\r
-\r
-static Expr *\r
-#ifdef __USE_PROTOS\r
-newExpr( char *e )\r
-#else\r
-newExpr( e )\r
-char *e;\r
-#endif\r
-{\r
-       Expr *p = (Expr *) calloc(1, sizeof(Expr));\r
-       require(p!=NULL, "newExpr: cannot alloc Expr node");\r
-\r
-       p->expr = e;\r
-       p->lclass = CurrentLexClass;\r
-       return p;\r
-}\r
-\r
-/* switch to lexical class/mode m.  This amounts to creating a new\r
- * lex mode if one does not already exist and making ExprStr point\r
- * to the correct char string array.  We must also switch Texpr tables.\r
- *\r
- * BTW, we need multiple ExprStr arrays because more than one automaton\r
- * may have the same label for a token, but with different expressions.\r
- * We need to track an expr for each automaton.  If we disallowed this\r
- * feature, only one ExprStr would be required.\r
- */\r
-void\r
-#ifdef __USE_PROTOS\r
-lexclass( char *m )\r
-#else\r
-lexclass( m )\r
-char *m;\r
-#endif\r
-{\r
-       int i;\r
-       TermEntry *p;\r
-       static char EOFSTR[] = "\"@\"";\r
-\r
-       if ( hash_get(Tname, m) != NULL )\r
-       {\r
-               warn(eMsg1("lexclass name conflicts with token/errclass label '%s'",m));\r
-       }\r
-       /* does m already exist? */\r
-       i = LexClassIndex(m);\r
-       if ( i != -1 ) {lexmode(i); return;}\r
-       /* must make new one */\r
-       NumLexClasses++;\r
-       CurrentLexClass = NumLexClasses-1;\r
-       require(NumLexClasses<=MaxLexClasses, "number of allowable lexclasses exceeded\nIncrease MaxLexClasses in generic.h and recompile all C files");\r
-       lclass[CurrentLexClass].classnum = m;\r
-       lclass[CurrentLexClass].exprs = (char **) calloc(tsize, sizeof(char *));\r
-       require(lclass[CurrentLexClass].exprs!=NULL,\r
-                       "lexclass: cannot allocate ExprStr");\r
-       lclass[CurrentLexClass].htable = newHashTable();\r
-       ExprStr = lclass[CurrentLexClass].exprs;\r
-       Texpr = lclass[CurrentLexClass].htable;\r
-       /* define EOF for each automaton */\r
-       p = newTermEntry( EOFSTR );\r
-       p->token = EofToken;    /* couldn't have remapped tokens yet, use EofToken */\r
-       hash_add(Texpr, EOFSTR, (Entry *)p);\r
-       list_add(&ExprOrder, (void *)newExpr(EOFSTR));\r
-       /* note: we use the actual ExprStr array\r
-        * here as TokenInd doesn't exist yet\r
-        */\r
-       ExprStr[EofToken] = EOFSTR;\r
-}\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-lexmode( int i )\r
-#else\r
-lexmode( i )\r
-int i;\r
-#endif\r
-{\r
-       require(i<NumLexClasses, "lexmode: invalid mode");\r
-       ExprStr = lclass[i].exprs;\r
-       Texpr = lclass[i].htable;\r
-       CurrentLexClass = i;\r
-}\r
-\r
-/* return index into lclass array of lexical class. return -1 if nonexistent */\r
-int\r
-#ifdef __USE_PROTOS\r
-LexClassIndex( char *cl )\r
-#else\r
-LexClassIndex( cl )\r
-char *cl;\r
-#endif\r
-{\r
-       int i;\r
-\r
-       for (i=0; i<NumLexClasses; i++)\r
-       {\r
-               if ( strcmp(lclass[i].classnum, cl) == 0 ) return i;\r
-       }\r
-       return -1;\r
-}\r
-\r
-int\r
-#ifdef __USE_PROTOS\r
-hasAction( char *expr )\r
-#else\r
-hasAction( expr )\r
-char *expr;\r
-#endif\r
-{\r
-       TermEntry *p;\r
-       require(expr!=NULL, "hasAction: invalid expr");\r
-\r
-       p = (TermEntry *) hash_get(Texpr, expr);\r
-       require(p!=NULL, eMsg1("hasAction: expr '%s' doesn't exist",expr));\r
-       return (p->action!=NULL);\r
-}\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-setHasAction( char *expr, char *action )\r
-#else\r
-setHasAction( expr, action )\r
-char *expr;\r
-char *action;\r
-#endif\r
-{\r
-       TermEntry *p;\r
-       require(expr!=NULL, "setHasAction: invalid expr");\r
-\r
-       p = (TermEntry *) hash_get(Texpr, expr);\r
-       require(p!=NULL, eMsg1("setHasAction: expr '%s' doesn't exist",expr));\r
-       p->action = action;\r
-}\r
-\r
-ForcedToken *\r
-#ifdef __USE_PROTOS\r
-newForcedToken(char *token, int tnum)\r
-#else\r
-newForcedToken(token, tnum)\r
-char *token;\r
-int tnum;\r
-#endif\r
-{\r
-       ForcedToken *ft = (ForcedToken *) calloc(1, sizeof(ForcedToken));\r
-       require(ft!=NULL, "out of memory");\r
-       ft->token = token;\r
-       ft->tnum = tnum;\r
-       return ft;\r
-}\r
-\r
-/*\r
- * Make a token indirection array that remaps token numbers and then walk\r
- * the appropriate symbol tables and SynDiag to change token numbers\r
- */\r
-void\r
-#ifdef __USE_PROTOS\r
-RemapForcedTokens(void)\r
-#else\r
-RemapForcedTokens()\r
-#endif\r
-{\r
-       ListNode *p;\r
-       ForcedToken *q;\r
-       int max_token_number=0;     /* MR9 23-Sep-97 Removed "unsigned" */\r
-       int i;\r
-\r
-       if ( ForcedTokens == NULL ) return;\r
-\r
-       /* find max token num */\r
-       for (p = ForcedTokens->next; p!=NULL; p=p->next)\r
-       {\r
-               q = (ForcedToken *) p->elem;\r
-               if ( q->tnum > max_token_number ) max_token_number = q->tnum;\r
-       }\r
-       fprintf(stderr, "max token number is %d\n", max_token_number);\r
-\r
-       /* make token indirection array */\r
-       TokenInd = (int *) calloc(max_token_number+1, sizeof(int));\r
-       LastTokenCounted = TokenNum;\r
-       TokenNum = max_token_number+1;\r
-       require(TokenInd!=NULL, "RemapForcedTokens: cannot allocate TokenInd");\r
-\r
-       /* fill token indirection array and change token id htable ; swap token indices */\r
-       for (i=1; i<TokenNum; i++) TokenInd[i] = i;\r
-       for (p = ForcedTokens->next; p!=NULL; p=p->next)\r
-       {\r
-               TermEntry *te;\r
-               int old_pos, t;\r
-\r
-               q = (ForcedToken *) p->elem;\r
-               fprintf(stderr, "%s forced to %d\n", q->token, q->tnum);\r
-               te = (TermEntry *) hash_get(Tname, q->token);\r
-               require(te!=NULL, "RemapForcedTokens: token not in hash table");\r
-               old_pos = te->token;\r
-               fprintf(stderr, "Before: TokenInd[old_pos==%d] is %d\n", old_pos, TokenInd[old_pos]);\r
-               fprintf(stderr, "Before: TokenInd[target==%d] is %d\n", q->tnum, TokenInd[q->tnum]);\r
-               q = (ForcedToken *) p->elem;\r
-               t = TokenInd[old_pos];\r
-               TokenInd[old_pos] = q->tnum;\r
-               TokenInd[q->tnum] = t;\r
-               te->token = q->tnum;            /* update token type id symbol table */\r
-               fprintf(stderr, "After: TokenInd[old_pos==%d] is %d\n", old_pos, TokenInd[old_pos]);\r
-               fprintf(stderr, "After: TokenInd[target==%d] is %d\n", q->tnum, TokenInd[q->tnum]);\r
-\r
-               /* Change the token number in the sym tab entry for the exprs\r
-                * at the old position of the token id and the target position\r
-                */\r
-               /* update expr at target (if any) of forced token id */\r
-               if ( q->tnum < TokenNum )       /* is it a valid position? */\r
-               {\r
-                       for (i=0; i<NumLexClasses; i++)\r
-                       {\r
-                               if ( lclass[i].exprs[q->tnum]!=NULL )\r
-                               {\r
-                                       /* update the symbol table for this expr */\r
-                                       TermEntry *e = (TermEntry *) hash_get(lclass[i].htable, lclass[i].exprs[q->tnum]);\r
-                                       require(e!=NULL, "RemapForcedTokens: expr not in hash table");\r
-                                       e->token = old_pos;\r
-                                       fprintf(stderr, "found expr '%s' at target %d in lclass[%d]; changed to %d\n",\r
-                                                       lclass[i].exprs[q->tnum], q->tnum, i, old_pos);\r
-                               }\r
-                       }\r
-               }\r
-               /* update expr at old position (if any) of forced token id */\r
-               for (i=0; i<NumLexClasses; i++)\r
-               {\r
-                       if ( lclass[i].exprs[old_pos]!=NULL )\r
-                       {\r
-                               /* update the symbol table for this expr */\r
-                               TermEntry *e = (TermEntry *) hash_get(lclass[i].htable, lclass[i].exprs[old_pos]);\r
-                               require(e!=NULL, "RemapForcedTokens: expr not in hash table");\r
-                               e->token = q->tnum;\r
-                               fprintf(stderr, "found expr '%s' for id %s in lclass[%d]; changed to %d\n",\r
-                                               lclass[i].exprs[old_pos], q->token, i, q->tnum);\r
-                       }\r
-               }\r
-       }\r
-\r
-       /* Update SynDiag */\r
-       RemapForcedTokensInSyntaxDiagram((Node *)SynDiag);\r
-}\r
-\r
-static void\r
-#ifdef __USE_PROTOS\r
-RemapForcedTokensInSyntaxDiagram(Node *p)\r
-#else\r
-RemapForcedTokensInSyntaxDiagram(p)\r
-Node *p;\r
-#endif\r
-{\r
-       Junction *j = (Junction *) p;\r
-       RuleRefNode *r = (RuleRefNode *) p;\r
-       TokNode *t = (TokNode *)p;\r
-\r
-       if ( p==NULL ) return;\r
-       require(p->ntype>=1 && p->ntype<=NumNodeTypes,  "Remap...: invalid diagram node");\r
-       switch ( p->ntype )\r
-       {\r
-               case nJunction :\r
-                       if ( j->visited ) return;\r
-                       if ( j->jtype == EndRule ) return;\r
-                       j->visited = TRUE;\r
-                       RemapForcedTokensInSyntaxDiagram( j->p1 );\r
-                       RemapForcedTokensInSyntaxDiagram( j->p2 );\r
-                       j->visited = FALSE;\r
-                       return;\r
-               case nRuleRef :\r
-                       RemapForcedTokensInSyntaxDiagram( r->next );\r
-                       return;\r
-               case nToken :\r
-                       if ( t->remapped ) return;      /* we've been here before */\r
-                       t->remapped = 1;\r
-                       fprintf(stderr, "remapping %d to %d\n", t->token, TokenInd[t->token]);\r
-                       t->token = TokenInd[t->token];\r
-                       RemapForcedTokensInSyntaxDiagram( t->next );\r
-                       return;\r
-               case nAction :\r
-                       RemapForcedTokensInSyntaxDiagram( ((ActionNode *)p)->next );\r
-                       return;\r
-               default :\r
-                       fatal_internal("invalid node type");\r
-       }\r
-}\r
-\r
-/*\r
- * Add a token name.  Return the token number associated with it.  If it already\r
- * exists, then return the token number assigned to it.\r
- *\r
- * Track the order in which tokens are found so that the DLG output maintains\r
- * that order.  It also lets us map token numbers to strings.\r
- */\r
-int\r
-#ifdef __USE_PROTOS\r
-addTname( char *token )\r
-#else\r
-addTname( token )\r
-char *token;\r
-#endif\r
-{\r
-       TermEntry *p;\r
-       require(token!=NULL, "addTname: invalid token name");\r
-\r
-       if ( (p=(TermEntry *)hash_get(Tname, token)) != NULL ) return p->token;\r
-       p = newTermEntry( token );\r
-       Ttrack( p->str );\r
-       p->token = TokenNum++;\r
-       hash_add(Tname, token, (Entry *)p);\r
-       return p->token;\r
-}\r
-\r
-/* This is the same as addTname except we force the TokenNum to be tnum.\r
- * We don't have to use the Forced token stuff as no tokens will have\r
- * been defined with #tokens when this is called.  This is only called\r
- * when a #tokdefs meta-op is used.\r
- */\r
-int\r
-#ifdef __USE_PROTOS\r
-addForcedTname( char *token, int tnum )\r
-#else\r
-addForcedTname( token, tnum )\r
-char *token;\r
-int tnum;\r
-#endif\r
-{\r
-       TermEntry *p;\r
-       require(token!=NULL, "addTname: invalid token name");\r
-\r
-       if ( (p=(TermEntry *)hash_get(Tname, token)) != NULL ) return p->token;\r
-       p = newTermEntry( token );\r
-       Ttrack( p->str );\r
-       p->token = tnum;\r
-       hash_add(Tname, token, (Entry *)p);\r
-       return p->token;\r
-}\r
-\r
-/*\r
- * Add a token expr.  Return the token number associated with it.  If it already\r
- * exists, then return the token number assigned to it.\r
- */\r
-int\r
-#ifdef __USE_PROTOS\r
-addTexpr( char *expr )\r
-#else\r
-addTexpr( expr )\r
-char *expr;\r
-#endif\r
-{\r
-       TermEntry *p;\r
-       require(expr!=NULL, "addTexpr: invalid regular expression");\r
-\r
-       if ( (p=(TermEntry *)hash_get(Texpr, expr)) != NULL ) return p->token;\r
-       p = newTermEntry( expr );\r
-       Ttrack( p->str );\r
-       /* track the order in which they occur */\r
-       list_add(&ExprOrder, (void *)newExpr(p->str));\r
-       p->token = TokenNum++;\r
-       hash_add(Texpr, expr, (Entry *)p);\r
-       return p->token;\r
-}\r
-\r
-/* return the token number of 'term'.  Return 0 if no 'term' exists */\r
-int\r
-#ifdef __USE_PROTOS\r
-Tnum( char *term )\r
-#else\r
-Tnum( term )\r
-char *term;\r
-#endif\r
-{\r
-       TermEntry *p;\r
-       require(term!=NULL, "Tnum: invalid terminal");\r
-       \r
-       if ( *term=='"' ) p = (TermEntry *) hash_get(Texpr, term);\r
-       else p = (TermEntry *) hash_get(Tname, term);\r
-       if ( p == NULL ) return 0;\r
-       else return p->token;\r
-}\r
-\r
-/* associate a Name with an expr.  If both have been already assigned\r
- * token numbers, then an error is reported.  Add the token or expr\r
- * that has not been added if no error.  This 'represents' the #token\r
- * ANTLR pseudo-op.  If both have not been defined, define them both\r
- * linked to same token number.\r
- */\r
-void\r
-#ifdef __USE_PROTOS\r
-Tklink( char *token, char *expr )\r
-#else\r
-Tklink( token, expr )\r
-char *token;\r
-char *expr;\r
-#endif\r
-{\r
-       TermEntry *p, *q;\r
-       require(token!=NULL && expr!=NULL, "Tklink: invalid token name and/or expr");\r
-\r
-       p = (TermEntry *) hash_get(Tname, token);\r
-       q = (TermEntry *) hash_get(Texpr, expr);\r
-       if ( p != NULL && q != NULL )   /* both defined */\r
-       {\r
-               warn( eMsg2("token name %s and rexpr %s already defined; ignored",\r
-                                       token, expr) );\r
-               return;\r
-       }\r
-       if ( p==NULL && q==NULL )               /* both not defined */\r
-       {\r
-               int t = addTname( token );\r
-               q = newTermEntry( expr );\r
-               hash_add(Texpr, expr, (Entry *)q);\r
-               q->token = t;\r
-               /* note: we use the actual ExprStr array\r
-                * here as TokenInd doesn't exist yet\r
-                */\r
-               ExprStr[t] = q->str;\r
-               /* track the order in which they occur */\r
-               list_add(&ExprOrder, (void *)newExpr(q->str));\r
-               return;\r
-       }\r
-       if ( p != NULL )                                /* one is defined, one is not */\r
-       {\r
-               q = newTermEntry( expr );\r
-               hash_add(Texpr, expr, (Entry *)q);\r
-               q->token = p->token;\r
-               ExprStr[p->token] = q->str;     /* both expr and token str defined now */\r
-               list_add(&ExprOrder, (void *)newExpr(q->str));\r
-       }\r
-       else                                                    /* trying to associate name with expr here*/\r
-       {\r
-               p = newTermEntry( token );\r
-               hash_add(Tname, token, (Entry *)p);\r
-               p->token = q->token;\r
-               TokenStr[p->token] = p->str;/* both expr and token str defined now */\r
-       }\r
-}\r
-\r
-/*\r
- * Given a string, this function allocates and returns a pointer to a\r
- * hash table record of size 'sz' whose "str" pointer is reset to a position\r
- * in the string table.\r
- */\r
-Entry *\r
-#ifdef __USE_PROTOS\r
-newEntry( char *text, int sz )\r
-#else\r
-newEntry( text, sz )\r
-char *text;\r
-int sz;\r
-#endif\r
-{\r
-       Entry *p;\r
-       require(text!=NULL, "new: NULL terminal");\r
-       \r
-       if ( (p = (Entry *) calloc(1,sz)) == 0 )\r
-       {\r
-               fatal_internal("newEntry: out of memory for terminals\n");\r
-               exit(PCCTS_EXIT_FAILURE);\r
-       }\r
-       p->str = mystrdup(text);\r
-       \r
-       return(p);\r
-}\r
-\r
-/*\r
- * add an element to a list.\r
- *\r
- * Any non-empty list has a sentinel node whose 'elem' pointer is really\r
- * a pointer to the last element.  (i.e. length(list) = #elemIn(list)+1).\r
- * Elements are appended to the list.\r
- */\r
-void\r
-#ifdef __USE_PROTOS\r
-list_add( ListNode **list, void *e )\r
-#else\r
-list_add( list, e )\r
-ListNode **list;\r
-void *e;\r
-#endif\r
-{\r
-       ListNode *p, *tail;\r
-       require(e!=NULL, "list_add: attempting to add NULL list element");\r
-\r
-       p = newListNode;\r
-       require(p!=NULL, "list_add: cannot alloc new list node");\r
-       p->elem = e;\r
-       if ( *list == NULL )\r
-       {\r
-               ListNode *sentinel = newListNode;\r
-               require(sentinel!=NULL, "list_add: cannot alloc sentinel node");\r
-               *list=sentinel;\r
-               sentinel->next = p;\r
-               sentinel->elem = (char *)p;             /* set tail pointer */\r
-       }\r
-       else                                                            /* find end of list */\r
-       {\r
-               tail = (ListNode *) (*list)->elem;      /* get tail pointer */\r
-               tail->next = p;\r
-               (*list)->elem = (char *) p;             /* reset tail */\r
-       }\r
-}\r
-\r
-/* MR10 list_free() frees the ListNode elements in the list       */\r
-/* MR10   if freeData then free the data elements of the list too */\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-list_free(ListNode **list,int freeData)\r
-#else\r
-list_free(list,freeData)\r
-  ListNode      **list;\r
-  int           freeData;\r
-#endif\r
-{\r
-       ListNode *p;\r
-    ListNode *next;\r
-\r
-       if (list == NULL) return;\r
-    if (*list == NULL) return;\r
-       for (p=*list; p != NULL; p=next) {\r
-      next=p->next;\r
-      if (freeData && p->elem != NULL) {\r
-        free( (char *) p->elem);\r
-      };\r
-      free( (char *) p);\r
-    };\r
-    *list=NULL;\r
-}\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-list_apply( ListNode *list, void (*f)(void *) )\r
-#else\r
-list_apply( list, f )\r
-ListNode *list;\r
-void (*f)();\r
-#endif\r
-{\r
-       ListNode *p;\r
-       require(f!=NULL, "list_apply: NULL function to apply");\r
-\r
-       if ( list == NULL ) return;\r
-       for (p = list->next; p!=NULL; p=p->next) (*f)( p->elem );\r
-}\r
-\r
-/* MR27 */\r
-\r
-#ifdef __USE_PROTOS\r
-int list_search_cstring(ListNode *list, char * cstring)\r
-#else\r
-int list_search_cstring(list, cstring)\r
-  ListNode * list;\r
-  char * cstring;\r
-#endif\r
-{\r
-       ListNode *p;\r
-       if (list == NULL ) return 0;\r
-       for (p = list->next; p!=NULL; p=p->next) {\r
-               if (p->elem == NULL) continue;\r
-               if (0 == strcmp((char *) p->elem , cstring)) return 1;\r
-       }\r
-       return 0;\r
-}\r
-\r
-                       /* F O L L O W  C y c l e  S t u f f */\r
-               \r
-/* make a key based upon (rulename, computation, k value).\r
- * Computation values are 'i'==FIRST, 'o'==FOLLOW.\r
- */\r
-\r
-/* MR10  Make the key all characters so it can be read easily   */\r
-/* MR10    by a simple dump program.  Also, separates           */\r
-/* MR10   'o' and 'i' from rule name                            */\r
-\r
-char *\r
-#ifdef __USE_PROTOS\r
-Fkey( char *rule, int computation, int k )\r
-#else\r
-Fkey( rule, computation, k )\r
-char *rule;\r
-int computation;\r
-int k;\r
-#endif\r
-{\r
-       static char key[MaxRuleName+2+2+1];                                 /* MR10 */\r
-       int i;\r
-       \r
-       if ( k > 99 )                                                       /* MR10 */\r
-               fatal("k>99 is too big for this implementation of ANTLR!\n");   /* MR10 */\r
-       if ( (i=strlen(rule)) > MaxRuleName )                               /* MR10 */\r
-               fatal( eMsgd("rule name > max of %d\n", MaxRuleName) );         /* MR10 */\r
-       strcpy(key,rule);\r
-\r
-/* MR10 */     key[i]='*';\r
-/* MR10 */     key[i+1] = (char) computation; /* MR20 G. Hobbelt */\r
-/* MR10 */     if (k < 10) {\r
-/* MR10 */       key[i+2] = (char) ( '0' + k);\r
-/* MR10 */      key[i+3] = '\0';\r
-/* MR10 */     } else {\r
-/* MR10 */       key[i+2] = (char) ( '0' + k/10);\r
-/* MR10 */       key[i+3] = (char) ( '0' + k % 10);\r
-/* MR10 */       key[i+4] = '\0';\r
-/* MR10 */     };\r
-\r
-       return key;\r
-}\r
-\r
-/* Push a rule onto the kth FOLLOW stack */\r
-void\r
-#ifdef __USE_PROTOS\r
-FoPush( char *rule, int k )\r
-#else\r
-FoPush( rule, k )\r
-char *rule;\r
-int k;\r
-#endif\r
-{\r
-       RuleEntry *r;\r
-       require(rule!=NULL, "FoPush: tried to push NULL rule");\r
-       require(k<=CLL_k,       "FoPush: tried to access non-existent stack");\r
-\r
-       /*fprintf(stderr, "FoPush(%s)\n", rule);*/\r
-       r = (RuleEntry *) hash_get(Rname, rule);\r
-       if ( r == NULL ) {fatal_internal( eMsg1("rule %s must be defined but isn't", rule) );}\r
-       if ( FoStack[k] == NULL )               /* Does the kth stack exist yet? */\r
-       {\r
-               /*fprintf(stderr, "allocating FoStack\n");*/\r
-               FoStack[k] = (int *) calloc(FoStackSize, sizeof(int));\r
-               require(FoStack[k]!=NULL, "FoPush: cannot allocate FOLLOW stack\n");\r
-       }\r
-       if ( FoTOS[k] == NULL )\r
-       {\r
-               FoTOS[k]=FoStack[k];\r
-               *(FoTOS[k]) = r->rulenum;\r
-       }\r
-       else\r
-       {\r
-#ifdef MEMCHK\r
-               require(valid(FoStack[k]), "FoPush: invalid FoStack");\r
-#endif\r
-               if ( FoTOS[k] >= &(FoStack[k][FoStackSize-1]) )\r
-                       fatal( eMsgd("exceeded max depth of FOLLOW recursion (%d)\n",\r
-                                               FoStackSize) );\r
-               require(FoTOS[k]>=FoStack[k],\r
-                               eMsg1("FoPush: FoStack stack-ptr is playing out of its sandbox",\r
-                                         rule));\r
-               ++(FoTOS[k]);\r
-               *(FoTOS[k]) = r->rulenum;\r
-       }\r
-       {\r
-               /*\r
-****           int *p;\r
-****           fprintf(stderr, "FoStack[k=%d]:\n", k);\r
-****           for (p=FoStack[k]; p<=FoTOS[k]; p++)\r
-****           {\r
-****                   fprintf(stderr, "\t%s\n", RulePtr[*p]->rname);\r
-****           }\r
-               */\r
-       }\r
-}\r
-\r
-/* Pop one rule off of the FOLLOW stack.  TOS ptr is NULL if empty. */\r
-void\r
-#ifdef __USE_PROTOS\r
-FoPop( int k )\r
-#else\r
-FoPop( k )\r
-int k;\r
-#endif\r
-{\r
-       require(k<=CLL_k, "FoPop: tried to access non-existent stack");\r
-       /*fprintf(stderr, "FoPop\n");*/\r
-       require(FoTOS[k]>=FoStack[k]&&FoTOS[k]<=&(FoStack[k][FoStackSize-1]),\r
-                       "FoPop: FoStack stack-ptr is playing out of its sandbox");\r
-       if ( FoTOS[k] == FoStack[k] ) FoTOS[k] = NULL;\r
-       else (FoTOS[k])--;\r
-}\r
-\r
-/* Compute FOLLOW cycle.\r
- * Mark all FOLLOW sets for rules in cycle as incomplete.\r
- * Then, save cycle on the cycle list (Cycles) for later resolution.\r
- * The Cycle is stored in the form:\r
- *             (head of cycle==croot, rest of rules in cycle==cyclicDep)\r
- *\r
- * e.g. (Fo means "FOLLOW of", "-->" means requires or depends on)\r
- *\r
- *             Fo(x)-->Fo(a)-->Fo(b)-->Fo(c)-->Fo(x)\r
- *                                                                                ^----Infinite recursion (cycle)\r
- *\r
- * the cycle would be: x -> {a,b,c} or stored as (x,{a,b,c}).  Fo(x) depends\r
- * on the FOLLOW of a,b, and c.  The root of a cycle is always complete after\r
- * Fo(x) finishes.  Fo(a,b,c) however are not.  It turns out that all rules\r
- * in a FOLLOW cycle have the same FOLLOW set.\r
- */\r
-void\r
-#ifdef __USE_PROTOS\r
-RegisterCycle( char *rule, int k )\r
-#else\r
-RegisterCycle( rule, k )\r
-char *rule;\r
-int k;\r
-#endif\r
-{\r
-       CacheEntry *f;\r
-       Cycle *c;\r
-       int *p;\r
-       RuleEntry *r;\r
-       require(rule!=NULL, "RegisterCycle: tried to register NULL rule");\r
-       require(k<=CLL_k,       "RegisterCycle: tried to access non-existent stack");\r
-\r
-       /*fprintf(stderr, "RegisterCycle(%s)\n", rule);*/\r
-       /* Find cycle start */\r
-       r = (RuleEntry *) hash_get(Rname, rule);\r
-       require(r!=NULL,eMsg1("rule %s must be defined but isn't", rule));\r
-       require(FoTOS[k]>=FoStack[k]&&FoTOS[k]<=&(FoStack[k][FoStackSize-1]),\r
-                       eMsg1("RegisterCycle(%s): FoStack stack-ptr is playing out of its sandbox",\r
-                                 rule));\r
-/***   if ( FoTOS[k]<FoStack[k]||FoTOS[k]>&(FoStack[k][FoStackSize-1]) )\r
-****   {\r
-****           fprintf(stderr, "RegisterCycle(%s): FoStack stack-ptr is playing out of its sandbox\n",\r
-****                                           rule);\r
-****           fprintf(stderr, "RegisterCycle: sp==0x%x out of bounds 0x%x...0x%x\n",\r
-****                                           FoTOS[k], FoStack[k], &(FoStack[k][FoStackSize-1]));\r
-****           exit(PCCTS_EXIT_FAILURE);\r
-****   }\r
-****/\r
-\r
-#ifdef MEMCHK\r
-       require(valid(FoStack[k]), "RegisterCycle: invalid FoStack");\r
-#endif\r
-       for (p=FoTOS[k]; *p != r->rulenum && p >= FoStack[k]; --p) {;}\r
-       require(p>=FoStack[k], "RegisterCycle: FoStack is screwed up beyond belief");\r
-       if ( p == FoTOS[k] ) return;    /* don't worry about cycles to oneself */\r
-       \r
-       /* compute cyclic dependents (rules in cycle except head) */\r
-       c = newCycle;\r
-       require(c!=NULL, "RegisterCycle: couldn't alloc new cycle");\r
-       c->cyclicDep = empty;\r
-       c->croot = *p++;                /* record root of cycle */\r
-       for (; p<=FoTOS[k]; p++)\r
-       {\r
-               /* Mark all dependent rules as incomplete */\r
-               f = (CacheEntry *) hash_get(Fcache, Fkey(RulePtr[*p]->rname,'o',k));\r
-               if ( f==NULL )\r
-               {\r
-                       f = newCacheEntry( Fkey(RulePtr[*p]->rname,'o',k) );\r
-                       hash_add(Fcache, Fkey(RulePtr[*p]->rname,'o',k), (Entry *)f);\r
-               }\r
-               f->incomplete = TRUE;\r
-               \r
-               set_orel(*p, &(c->cyclicDep)); /* mark rule as dependent of croot */\r
-       }\r
-       list_add(&(Cycles[k]), (void *)c);\r
-}\r
-\r
-/* make all rules in cycle complete\r
- *\r
- * while ( some set has changed ) do\r
- *             for each cycle do\r
- *                     if degree of FOLLOW set for croot > old degree then\r
- *                             update all FOLLOW sets for rules in cyclic dependency\r
- *                             change = TRUE\r
- *                     endif\r
- *             endfor\r
- * endwhile\r
- */\r
-void\r
-#ifdef __USE_PROTOS\r
-ResolveFoCycles( int k )\r
-#else\r
-ResolveFoCycles( k )\r
-int k;\r
-#endif\r
-{\r
-       ListNode *p, *q;\r
-       Cycle *c;\r
-       int changed = 1;\r
-       CacheEntry *f,*g;\r
-       int r;\r
-/*  int i;  */  /* MR10 not useful */\r
-       unsigned d;\r
-\r
-    unsigned    *cursor;        /* MR10 */\r
-    unsigned    *origin;        /* MR10 */\r
-       \r
-       /*fprintf(stderr, "Resolving following cycles for %d\n", k);*/\r
-       while ( changed )\r
-       {\r
-               changed = 0;\r
-/* MR10 i = 0;  */\r
-               for (p = Cycles[k]->next; p!=NULL; p=p->next)\r
-               {\r
-                       c = (Cycle *) p->elem;\r
-                       /*fprintf(stderr, "cycle %d: %s -->", i++, RulePtr[c->croot]->rname);*/\r
-                       /*s_fprT(stderr, c->cyclicDep);*/\r
-                       /*fprintf(stderr, "\n");*/\r
-                       f = (CacheEntry *)\r
-                                       hash_get(Fcache, Fkey(RulePtr[c->croot]->rname,'o',k));\r
-                       require(f!=NULL, eMsg1("FOLLOW(%s) must be in cache but isn't", RulePtr[c->croot]->rname) );\r
-                       if ( (d=set_deg(f->fset)) > c->deg )\r
-                       {\r
-                               /*fprintf(stderr, "Fo(%s) has changed\n", RulePtr[c->croot]->rname);*/\r
-                               changed = 1;\r
-                               c->deg = d;             /* update cycle FOLLOW set degree */\r
-\r
-/* MR10 */      origin=set_pdq(c->cyclicDep);\r
-/* MR10 */      for (cursor=origin; *cursor != nil; cursor++) {\r
-/* MR10 */         r=*cursor;\r
-\r
-/********              while ( !set_nil(c->cyclicDep) ) {      *****/\r
-/********                                      r = set_int(c->cyclicDep);  *****/\r
-/********                                      set_rm(r, c->cyclicDep);    *****/\r
-\r
-                                       /*fprintf(stderr, "updating Fo(%s)\n", RulePtr[r]->rname);*/\r
-                                       g = (CacheEntry *)\r
-                                                       hash_get(Fcache, Fkey(RulePtr[r]->rname,'o',k));\r
-                                       require(g!=NULL, eMsg1("FOLLOW(%s) must be in cache but isn't", RulePtr[r]->rname) );\r
-                                       set_orin(&(g->fset), f->fset);\r
-                                       g->incomplete = FALSE;\r
-                               }\r
-/* MR10 */      free( (char *) origin);\r
-/* MR10 */      origin=NULL;\r
-                       }\r
-               }\r
-/* MR10 - this if statement appears to be meaningless since i is always 0 */\r
-/* MR10                if ( i == 1 ) changed = 0;      */ /* if only 1 cycle, no need to repeat */\r
-       }\r
-       /* kill Cycle list */\r
-       for (q = Cycles[k]->next; q != NULL; q=p)\r
-       {\r
-               p = q->next;\r
-               set_free( ((Cycle *)q->elem)->cyclicDep );\r
-               free((char *)q);\r
-       }\r
-       free( (char *)Cycles[k] );\r
-       Cycles[k] = NULL;\r
-}\r
-\r
-\r
-                       /* P r i n t i n g  S y n t a x  D i a g r a m s */\r
-\r
-static void\r
-#ifdef __USE_PROTOS\r
-pBlk( Junction *q, int btype )\r
-#else\r
-pBlk( q, btype )\r
-Junction *q;\r
-int btype;\r
-#endif\r
-{\r
-       int k,a;\r
-       Junction *alt, *p;\r
-\r
-       q->end->pvisited = TRUE;\r
-       if ( btype == aLoopBegin )\r
-       {\r
-               require(q->p2!=NULL, "pBlk: invalid ()* block");\r
-               PRINT(q->p1);\r
-               alt = (Junction *)q->p2;\r
-               PRINT(alt->p1);\r
-               if ( PrintAnnotate )\r
-               {\r
-                       printf(" /* Opt ");\r
-                       k = 1;\r
-                       while ( !set_nil(alt->fset[k]) )\r
-                       {\r
-                               s_fprT(stdout, alt->fset[k]);\r
-                               if ( k++ == CLL_k ) break;\r
-                               if ( !set_nil(alt->fset[k]) ) printf(", ");\r
-                       }\r
-                       printf(" */\n");\r
-               }\r
-               return;\r
-       }\r
-       for (a=1,alt=q; alt != NULL; alt= (Junction *) alt->p2, a++)\r
-       {\r
-               if ( alt->p1 != NULL ) PRINT(alt->p1);\r
-               if ( PrintAnnotate )\r
-               {\r
-                       printf( " /* [%d] ", alt->altnum);\r
-                       k = 1;\r
-                       while ( !set_nil(alt->fset[k]) )\r
-                       {\r
-                               s_fprT(stdout, alt->fset[k]);\r
-                               if ( k++ == CLL_k ) break;\r
-                               if ( !set_nil(alt->fset[k]) ) printf(", ");\r
-                       }\r
-                       if ( alt->p2 == NULL && btype == aOptBlk )\r
-                               printf( " (optional branch) */\n");\r
-                       else printf( " */\n");\r
-               }\r
-\r
-               /* ignore implied empty alt of Plus blocks */\r
-               if ( alt->p2 != NULL && ((Junction *)alt->p2)->ignore ) break;\r
-\r
-               if ( alt->p2 != NULL && !(((Junction *)alt->p2)->p2==NULL && btype == aOptBlk) )\r
-               {\r
-                       if ( pLevel == 1 )\r
-                       {\r
-                               printf("\n");\r
-                               if ( a+1==pAlt1 || a+1==pAlt2 ) printf("=>");\r
-                               printf("\t");\r
-                       }\r
-                       else printf(" ");\r
-                       printf("|");\r
-                       if ( pLevel == 1 )\r
-                       {\r
-                               p = (Junction *) ((Junction *)alt->p2)->p1;\r
-                               while ( p!=NULL )\r
-                               {\r
-                                       if ( p->ntype==nAction )\r
-                                       {\r
-                                               p=(Junction *)((ActionNode *)p)->next;\r
-                                               continue;\r
-                                       }\r
-                                       if ( p->ntype!=nJunction )\r
-                                       {\r
-                                               break;\r
-                                       }\r
-                                       if ( p->jtype==EndBlk || p->jtype==EndRule )\r
-                                       {\r
-                                               p = NULL;\r
-                                               break;\r
-                                       }\r
-                                       p = (Junction *)p->p1;\r
-                               }\r
-                               if ( p==NULL ) printf("\n\t");  /* Empty alt? */\r
-                       }\r
-               }\r
-       }\r
-       q->end->pvisited = FALSE;\r
-}\r
-\r
-/* How to print out a junction */\r
-void\r
-#ifdef __USE_PROTOS\r
-pJunc( Junction *q )\r
-#else\r
-pJunc( q )\r
-Junction *q;\r
-#endif\r
-{\r
-       int dum_k;\r
-       int doing_rule;\r
-       require(q!=NULL, "pJunc: NULL node");\r
-       require(q->ntype==nJunction, "pJunc: not junction");\r
-       \r
-       if ( q->pvisited == TRUE ) return;\r
-       q->pvisited = TRUE;\r
-       switch ( q->jtype )\r
-       {\r
-               case aSubBlk :\r
-                       if ( PrintAnnotate ) First(q, 1, q->jtype, &dum_k);\r
-                       if ( q->end->p1 != NULL && ((Junction *)q->end->p1)->ntype==nJunction &&\r
-                                ((Junction *)q->end->p1)->jtype == EndRule ) doing_rule = 1;\r
-                       else doing_rule = 0;\r
-                       pLevel++;\r
-                       if ( pLevel==1 )\r
-                       {\r
-                               if ( pAlt1==1 ) printf("=>");\r
-                               printf("\t");\r
-                       }\r
-                       else printf(" ");\r
-                       if ( doing_rule )\r
-                       {\r
-                               if ( pLevel==1 ) printf(" ");\r
-                               pBlk(q,q->jtype);\r
-                       }\r
-                       else {\r
-                               printf("(");\r
-                               if ( pLevel==1 ) printf(" ");\r
-                               pBlk(q,q->jtype);\r
-                               if ( pLevel>1 ) printf(" ");\r
-                               printf(")");\r
-                       }\r
-                       if ( q->guess ) printf("?");\r
-                       pLevel--;\r
-                       if ( PrintAnnotate ) freeBlkFsets(q);\r
-                       if ( q->end->p1 != NULL ) PRINT(q->end->p1);\r
-                       break;\r
-               case aOptBlk :\r
-                       if ( PrintAnnotate ) First(q, 1, q->jtype, &dum_k);\r
-                       pLevel++;\r
-                       if ( pLevel==1 )\r
-                       {\r
-                               if ( pAlt1==1 ) printf("=>");\r
-                               printf("\t");\r
-                       }\r
-                       else printf(" ");\r
-                       printf("{");\r
-                       if ( pLevel==1 ) printf(" ");\r
-                       pBlk(q,q->jtype);\r
-                       if ( pLevel>1 ) printf(" ");\r
-                       else printf("\n\t");\r
-                       printf("}");\r
-                       pLevel--;\r
-                       if ( PrintAnnotate ) freeBlkFsets(q);\r
-                       if ( q->end->p1 != NULL ) PRINT(q->end->p1);\r
-                       break;\r
-               case aLoopBegin :\r
-                       if ( PrintAnnotate ) First(q, 1, q->jtype, &dum_k);\r
-                       pLevel++;\r
-                       if ( pLevel==1 )\r
-                       {\r
-                               if ( pAlt1==1 ) printf("=>");\r
-                               printf("\t");\r
-                       }\r
-                       else printf(" ");\r
-                       printf("(");\r
-                       if ( pLevel==1 ) printf(" ");\r
-                       pBlk(q,q->jtype);\r
-                       if ( pLevel>1 ) printf(" ");\r
-                       else printf("\n\t");\r
-                       printf(")*");\r
-                       pLevel--;\r
-                       if ( PrintAnnotate ) freeBlkFsets(q);\r
-                       if ( q->end->p1 != NULL ) PRINT(q->end->p1);\r
-                       break;\r
-               case aLoopBlk :\r
-                       if ( PrintAnnotate ) First(q, 1, q->jtype, &dum_k);\r
-                       pBlk(q,q->jtype);\r
-                       if ( PrintAnnotate ) freeBlkFsets(q);\r
-                       break;\r
-               case aPlusBlk :\r
-                       if ( PrintAnnotate ) First(q, 1, q->jtype, &dum_k);\r
-                       pLevel++;\r
-                       if ( pLevel==1 )\r
-                       {\r
-                               if ( pAlt1==1 ) printf("=>");\r
-                               printf("\t");\r
-                       }\r
-                       else printf(" ");\r
-                       printf("(");\r
-                       if ( pLevel==1 ) printf(" ");\r
-                       pBlk(q,q->jtype);\r
-                       if ( pLevel>1 ) printf(" ");\r
-                       printf(")+");\r
-                       pLevel--;\r
-                       if ( PrintAnnotate ) freeBlkFsets(q);\r
-                       if ( q->end->p1 != NULL ) PRINT(q->end->p1);\r
-                       break;\r
-               case EndBlk :\r
-                       break;\r
-               case RuleBlk :\r
-                       printf( "\n%s :\n", q->rname);\r
-                       PRINT(q->p1);\r
-                       if ( q->p2 != NULL ) PRINT(q->p2);\r
-                       break;\r
-               case Generic :\r
-                       if ( q->p1 != NULL ) PRINT(q->p1);\r
-                       q->pvisited = FALSE;\r
-                       if ( q->p2 != NULL ) PRINT(q->p2);\r
-                       break;\r
-               case EndRule :\r
-                       printf( "\n\t;\n");\r
-                       break;\r
-       }\r
-       q->pvisited = FALSE;\r
-}\r
-\r
-/* How to print out a rule reference node */\r
-void\r
-#ifdef __USE_PROTOS\r
-pRuleRef( RuleRefNode *p )\r
-#else\r
-pRuleRef( p )\r
-RuleRefNode *p;\r
-#endif\r
-{\r
-       require(p!=NULL, "pRuleRef: NULL node");\r
-       require(p->ntype==nRuleRef, "pRuleRef: not rule ref node");\r
-       \r
-       printf( " %s", p->text);\r
-       PRINT(p->next);\r
-}\r
-\r
-/* How to print out a terminal node */\r
-void\r
-#ifdef __USE_PROTOS\r
-pToken( TokNode *p )\r
-#else\r
-pToken( p )\r
-TokNode *p;\r
-#endif\r
-{\r
-       require(p!=NULL, "pToken: NULL node");\r
-       require(p->ntype==nToken, "pToken: not token node");\r
-\r
-       if ( p->wild_card ) printf(" .");\r
-       printf( " %s", TerminalString(p->token));\r
-       PRINT(p->next);\r
-}\r
-\r
-/* How to print out a terminal node */\r
-void\r
-#ifdef __USE_PROTOS\r
-pAction( ActionNode *p )\r
-#else\r
-pAction( p )\r
-ActionNode *p;\r
-#endif\r
-{\r
-       require(p!=NULL, "pAction: NULL node");\r
-       require(p->ntype==nAction, "pAction: not action node");\r
-       \r
-       PRINT(p->next);\r
-}\r
-\r
-                                       /* F i l l  F o l l o w  L i s t s */\r
-\r
-/*\r
- * Search all rules for all rule reference nodes, q to rule, r.\r
- * Add q->next to follow list dangling off of rule r.\r
- * i.e.\r
- *\r
- *             r: -o-R-o-->o--> Ptr to node following rule r in another rule\r
- *                                     |\r
- *                                     o--> Ptr to node following another reference to r.\r
- *\r
- * This is the data structure employed to avoid FOLLOW set computation.  We\r
- * simply compute the FIRST (reach) of the EndRule Node which follows the\r
- * list found at the end of all rules which are referenced elsewhere.  Rules\r
- * not invoked by other rules have no follow list (r->end->p1==NULL).\r
- * Generally, only start symbols are not invoked by another rule.\r
- *\r
- * Note that this mechanism also gives a free cross-reference mechanism.\r
- *\r
- * The entire syntax diagram is layed out like this:\r
- *\r
- * SynDiag\r
- *     |\r
- *     v\r
- *     o-->R1--o\r
- *     |\r
- *     o-->R2--o\r
- *     |\r
- *     ...\r
- *     |\r
- *     o-->Rn--o\r
- *\r
- */\r
-void\r
-#ifdef __USE_PROTOS\r
-FoLink( Node *p )\r
-#else\r
-FoLink( p )\r
-Node *p;\r
-#endif\r
-{\r
-       RuleEntry *q;\r
-       Junction *j = (Junction *) p;\r
-       RuleRefNode *r = (RuleRefNode *) p;\r
-\r
-       if ( p==NULL ) return;\r
-       require(p->ntype>=1 && p->ntype<=NumNodeTypes,\r
-                       eMsgd("FoLink: invalid diagram node: ntype==%d",p->ntype));\r
-       switch ( p->ntype )\r
-       {\r
-               case nJunction :\r
-                       if ( j->fvisited ) return;\r
-                       if ( j->jtype == EndRule ) return;\r
-                       j->fvisited = TRUE;\r
-                       FoLink( j->p1 );\r
-                       FoLink( j->p2 );\r
-/* MR14 */\r
-/* MR14 */  /* Need to determine whether the guess block is an         */\r
-/* MR14 */  /* of the form (alpha)? beta before follow sets are        */\r
-/* MR14 */  /* computed.  This is necessary to solve problem           */\r
-/* MR14 */  /* of doing follow on the alpha of an (alpha)? beta block. */\r
-/* MR14 */\r
-/* MR14 */  /* This is performed by analysis_point as a side-effect.   */\r
-/* MR14 */\r
-/* MR14 */\r
-/* MR14 */  if (j->jtype == aSubBlk && j->guess) {\r
-/* MR14 */    Junction *ignore;\r
-/* MR14 */    ignore=analysis_point(j);\r
-/* MR14 */  }\r
-/* MR14 */\r
-                       return;\r
-               case nRuleRef :\r
-                       if ( r->linked ) return;\r
-                       q = (RuleEntry *) hash_get(Rname, r->text);\r
-                       if ( q == NULL )\r
-                       {\r
-                               warnFL( eMsg1("rule %s not defined",r->text), FileStr[r->file], r->line );\r
-                       }\r
-                       else\r
-                       {\r
-                               if ( r->parms!=NULL && RulePtr[q->rulenum]->pdecl==NULL )\r
-                               {\r
-                                       warnFL( eMsg1("rule %s accepts no parameter(s)", r->text),\r
-                                                       FileStr[r->file], r->line );\r
-                               }\r
-                               if ( r->parms==NULL && RulePtr[q->rulenum]->pdecl!=NULL )\r
-                               {\r
-                                       warnFL( eMsg1("rule %s requires parameter(s)", r->text),\r
-                                                       FileStr[r->file], r->line );\r
-                               }\r
-                               if ( r->assign!=NULL && RulePtr[q->rulenum]->ret==NULL )\r
-                               {\r
-                                       warnFL( eMsg1("rule %s yields no return value(s)", r->text),\r
-                                                       FileStr[r->file], r->line );\r
-                               }\r
-                               if ( r->assign==NULL && RulePtr[q->rulenum]->ret!=NULL )\r
-                               {\r
-                                       warnFL( eMsg1("rule %s returns a value(s)", r->text),\r
-                                                       FileStr[r->file], r->line );\r
-                               }\r
-                               if ( !r->linked )\r
-                               {\r
-                                       addFoLink(      r->next, r->rname, RulePtr[q->rulenum] );\r
-                                       r->linked = TRUE;\r
-                               }\r
-                       }\r
-                       FoLink( r->next );\r
-                       return;\r
-               case nToken :\r
-                       FoLink( ((TokNode *)p)->next );\r
-                       return;\r
-               case nAction :\r
-                       FoLink( ((ActionNode *)p)->next );\r
-                       return;\r
-               default :\r
-                       fatal_internal("invalid node type");\r
-       }\r
-}\r
-\r
-/*\r
- * Add a reference to the end of a rule.\r
- *\r
- * 'r' points to the RuleBlk node in a rule.  r->end points to the last node\r
- * (EndRule jtype) in a rule.\r
- *\r
- * Initial:\r
- *             r->end -->      o\r
- *\r
- * After:\r
- *             r->end -->      o-->o--> Ptr to node following rule r in another rule\r
- *                                             |\r
- *                                             o--> Ptr to node following another reference to r.\r
- *\r
- * Note that the links are added to the head of the list so that r->end->p1\r
- * always points to the most recently added follow-link.  At the end, it should\r
- * point to the last reference found in the grammar (starting from the 1st rule).\r
- */\r
-void\r
-#ifdef __USE_PROTOS\r
-addFoLink( Node *p, char *rname, Junction *r )\r
-#else\r
-addFoLink( p, rname, r )\r
-Node *p;\r
-char *rname;\r
-Junction *r;\r
-#endif\r
-{\r
-       Junction *j;\r
-       require(r!=NULL,                                "addFoLink: incorrect rule graph");\r
-       require(r->end!=NULL,                   "addFoLink: incorrect rule graph");\r
-       require(r->end->jtype==EndRule, "addFoLink: incorrect rule graph");\r
-       require(p!=NULL,                                "addFoLink: NULL FOLLOW link");\r
-\r
-       j = newJunction();\r
-       j->rname = rname;                       /* rname on follow links point to target rule */\r
-       j->p1 = p;                                      /* link to other rule */\r
-       j->p2 = (Node *) r->end->p1;/* point to head of list */\r
-       r->end->p1 = (Node *) j;        /* reset head to point to new node */\r
-}\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-GenCrossRef( Junction *p )\r
-#else\r
-GenCrossRef( p )\r
-Junction *p;\r
-#endif\r
-{\r
-       set a;\r
-       Junction *j;\r
-       RuleEntry *q;\r
-       unsigned e;\r
-       require(p!=NULL, "GenCrossRef: why are you passing me a null grammar?");\r
-\r
-       printf("Cross Reference:\n\n");\r
-       a = empty;\r
-       for (; p!=NULL; p = (Junction *)p->p2)\r
-       {\r
-               printf("Rule %20s referenced by {", p->rname);\r
-               /* make a set of rules for uniqueness */\r
-               for (j = (Junction *)(p->end)->p1; j!=NULL; j = (Junction *)j->p2)\r
-               {\r
-                       q = (RuleEntry *) hash_get(Rname, j->rname);\r
-                       require(q!=NULL, "GenCrossRef: FoLinks are screwed up");\r
-                       set_orel(q->rulenum, &a);\r
-               }\r
-               for (; !set_nil(a); set_rm(e, a))\r
-               {\r
-                       e = set_int(a);\r
-                       printf(" %s", RulePtr[e]->rname);\r
-               }\r
-               printf(" }\n");\r
-       }\r
-       set_free( a );\r
-}\r
-\r
-/*\r
-   The single argument is a pointer to the start of an element of a\r
-   C++ style function prototypet list.  Given a pointer to the start of\r
-   an formal we must locate the comma (or the end of the string)\r
-   and locate the datatype, formal name, and initial value expression.\r
-\r
-   The function returns a pointer to the character following the comma\r
-   which terminates the formal declaration, or a pointer to the end of\r
-   the string if none was found.\r
-\r
-   I thought we were parsing specialists, how come I'm doing this by\r
-   hand written code ?\r
-\r
-   Examples of input:\r
\r
-        Foo f,\r
-        Foo f = Foo(1),\r
-        Foo f = Foo(1,2),\r
-        Foo f = &farray[1,2],\r
-        Foo f = ",",\r
-        Foo f = ',',\r
-        TFoo<int,char> f = TFoo<int,char>(1,2),\r
-\r
-   A non-zero value for nesting indicates a problem matching '(' and ')',\r
-   '[' and ']', '<' and '>', '{' and '}', or improperly terminated string\r
-   or character literal.\r
-\r
-*/\r
-\r
-\r
-/*\r
- *  Don't care if it is a valid string literal or not, just find the end\r
- *  Start with pointer to leading "\""\r
- */\r
-\r
-#ifdef __USE_PROTOS\r
-char * skipStringLiteral(char *pCurrent)\r
-#else\r
-char * skipStringLiteral(pCurrent)\r
-char *pCurrent;\r
-#endif\r
-{\r
-  char *p = pCurrent;\r
-  if (*p == 0) return p;\r
-  require (*p == '\"', "skipStringLiteral")\r
-  p++;\r
-  for (p = p; *p != 0; p++) {\r
-    if (*p == '\\') {\r
-      p++;\r
-      if (*p == 0) break;\r
-      p++;\r
-    }\r
-    if (*p == '\"') {\r
-      p++;\r
-      break;\r
-    }\r
-  }\r
-  return p;\r
-}\r
-\r
-/*\r
- *  Don't care if it is a valid character literal or not, just find the end\r
- *  Start with pointer to leading "'"\r
- */\r
-\r
-#ifdef __USE_PROTOS\r
-char * skipCharLiteral(char *pStart)\r
-#else\r
-char * skipCharLiteral(pStart)\r
- char *pStart;\r
-#endif\r
-{\r
-  char *p = pStart;\r
-  if (*p == 0) return p;\r
-  require (*p == '\'', "skipCharLiteral")\r
-  p++;\r
-  for (p = p; *p != 0; p++) {\r
-    if (*p == '\\') {\r
-      p++;\r
-      if (*p == 0) break;\r
-      p++;\r
-    }\r
-    if (*p == '\'') {\r
-      p++;\r
-      break;\r
-    }\r
-  }\r
-  return p;\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-char * skipSpaces(char *pStart)\r
-#else\r
-char * skipSpaces(pStart)\r
-char * pStart;\r
-#endif\r
-{\r
-  char *p = pStart;\r
-  while (*p != 0 && isspace(*p)) p++;\r
-  return p;\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-char * skipToSeparatorOrEqualSign(char *pStart, int *pNest)\r
-#else\r
-char * skipToSeparatorOrEqualSign(pStart, pNest)\r
-char *pStart;\r
-int *pNest;\r
-#endif\r
-{\r
-  char *p = pStart;\r
-  \r
-  int nest = 0;\r
-\r
-  *pNest = (-1);\r
-\r
-  while (*p != 0) {\r
-    switch (*p) {\r
-\r
-      case '(' :\r
-      case '[' :\r
-      case '<' :\r
-      case '{' :\r
-        nest++;\r
-        p++;\r
-        break;\r
-\r
-      case ')' :\r
-      case ']' :\r
-      case '>' :\r
-      case '}' :\r
-        nest--;\r
-        p++;\r
-        break;\r
-      \r
-      case '"' :\r
-        p = skipStringLiteral(p);\r
-        break;\r
-  \r
-      case '\'' :\r
-        p = skipCharLiteral(p);\r
-        break;\r
-\r
-      case '\\':\r
-        p++;\r
-        if (*p == 0) goto EXIT;\r
-        p++;\r
-        break;\r
-\r
-      case ',':\r
-      case '=':\r
-        if (nest == 0) goto EXIT;\r
-               p++;\r
-        break;\r
-\r
-      default:\r
-        p++;\r
-    }\r
-  }\r
-EXIT:\r
-  *pNest = nest;\r
-  return p;\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-char * skipToSeparator(char *pStart, int *pNest)\r
-#else\r
-char * skipToSeparator(pStart, pNest)\r
-char *pStart;\r
-int *pNest;\r
-#endif\r
-{\r
-  char * p = pStart;\r
-  for ( ; ; ) {\r
-    p = skipToSeparatorOrEqualSign(p, pNest);\r
-    if (*pNest != 0) return p;\r
-    if (*p == ',') return p;\r
-    if (*p == 0) return p;\r
-       p++;\r
-  }\r
-}\r
-\r
-/* skip to just past the "=" separating the declaration from the initialization value */\r
-\r
-#ifdef __USE_PROTOS\r
-char * getInitializer(char *pStart)\r
-#else\r
-char * getInitializer(pStart)\r
-char * pStart;\r
-#endif\r
-{\r
-       char *p;\r
-       char *pDataType;\r
-       char *pSymbol;\r
-       char *pEqualSign;\r
-       char *pValue;\r
-       char *pSeparator;\r
-       int nest = 0;\r
-\r
-       require(pStart!=NULL, "getInitializer: invalid string"); \r
-\r
-       p = endFormal(pStart,\r
-                             &pDataType,\r
-                                 &pSymbol,\r
-                                 &pEqualSign,\r
-                                 &pValue,\r
-                                 &pSeparator,\r
-                                 &nest);\r
-    if (nest != 0) return NULL;\r
-    if (pEqualSign == NULL) return NULL;\r
-    if (pValue == NULL) return NULL;\r
-       return strBetween(pValue, NULL, pSeparator);\r
-}\r
-\r
-/*\r
-   Examines the string from pStart to pEnd-1.\r
-   If the string has 0 length or is entirely white space\r
-   returns 1.  Otherwise 0.\r
-*/\r
-\r
-#ifdef __USE_PROTOS\r
-int isWhiteString(const char *pStart, const char *pEnd)\r
-#else\r
-int isWhiteString(pStart, pEnd)\r
-const char *pStart;\r
-const char *pEnd;\r
-#endif\r
-{\r
-  const char *p;\r
-  for (p = pStart; p < pEnd; p++) {\r
-    if (! isspace(*p)) return 0;\r
-  }\r
-  return 1;\r
-}\r
-\r
-/*\r
-   This replaces HasComma() which couldn't distinguish\r
-\r
-        foo ["a,b"]\r
-\r
-   from:\r
-\r
-        foo[a,b]\r
-\r
-*/\r
-\r
-#ifdef __USE_PROTOS\r
-int hasMultipleOperands(char *pStart)\r
-#else\r
-int hasMultipleOperands(pStart)\r
-char *pStart;\r
-#endif\r
-{\r
-  char *p = pStart;\r
-  int nest = 0;\r
-\r
-  p = skipSpaces(p);\r
-  if (*p == 0) return 0;\r
-  p = skipToSeparator(p, &nest);\r
-  if (nest == 0 && *p == ',') return 1;\r
-  return 0;\r
-}\r
-\r
-\r
-#define MAX_STR_BETWEEN_WORK_AREA 1000\r
-\r
-static char strBetweenWorkArea[MAX_STR_BETWEEN_WORK_AREA];\r
-\r
-\r
-/*\r
-       strBetween(pStart, pNext, pStop)\r
-\r
-    Creates a null terminated string by copying the text between two pointers\r
-       to a work area.  The start of the string is pStart.  The end of the string\r
-       is the character before pNext, or if pNext is null then the character before\r
-       pStop.  Trailing spaces are not included in the copy operation.\r
-       \r
-       This is used when a string contains several parts.  The pNext part may be\r
-       optional.  The pStop will stop the scan when the optional part is not present\r
-       (is a null pointer).\r
-*/\r
-\r
-#ifdef __USE_PROTOS\r
-char *strBetween(char *pStart, char *pNext, char *pStop)\r
-#else\r
-char *strBetween(pStart, pNext, pStop)\r
-char *pStart;\r
-char *pNext;\r
-char *pStop;\r
-#endif\r
-{\r
-  char *p;\r
-  char *q = strBetweenWorkArea;\r
-  const char *pEnd;\r
-\r
-  pEnd = (pNext != NULL) ? pNext : pStop;\r
-\r
-  require (pEnd != NULL, "pEnd == NULL");\r
-  require (pEnd >= pStart, "pEnd < pStart");\r
-  for (pEnd--; pEnd >= pStart; pEnd--) { /* MR31 */\r
-       if (! isspace(*pEnd)) break;\r
-  }\r
-  for (p = pStart;\r
-       p <= pEnd && q < &strBetweenWorkArea[MAX_STR_BETWEEN_WORK_AREA-2];\r
-          p++, q++) {\r
-        *q = *p;\r
-  }\r
-  *q = 0;\r
-  return strBetweenWorkArea;\r
-}\r
-\r
-/*\r
-   function     Returns pointer to character following separator at\r
-   value        which to continue search for next formal.  If at the\r
-                end of the string a pointer to the null byte at the\r
-                end of the string is returned.\r
-\r
-   pStart       Pointer to the starting position of the formal list\r
-\r
-                This may be the middle of a longer string, for example\r
-                when looking for the end of formal #3 starting from\r
-                the middle of the complete formal list.\r
-\r
-   ppDataType   Returns a pointer to the start of the data type in the\r
-                formal. Example: pointer to "Foo".\r
-\r
-   ppSymbol     Returns a pointer to the start of the formal symbol.\r
-                Example: pointer to "f".\r
-\r
-   ppEqualSign  Returns a pointer to the equal sign separating the\r
-                formal symbol from the initial value.  If there is \r
-                no "=" then this will be NULL.\r
-\r
-   ppValue      Returns a pointer to the initial value part of the\r
-                formal declaration.  Example: pointer to "&farray[1,2]"\r
-\r
-   ppSeparator  Returns a pointer to the character which terminated the\r
-                scan.  This should be a pointer to a comma or a null\r
-                byte which terminates the string.\r
-\r
-   pNest        Returns the nesting level when a separator was found.\r
-                This is non-zero for any kind of error.  This is zero\r
-                for a successful parse of this portion of the formal\r
-                list.\r
-\r
-*/ \r
\r
-#ifdef __USE_PROTOS\r
-char * endFormal(char *pStart,\r
-                 char **ppDataType,\r
-                 char **ppSymbol,\r
-                 char **ppEqualSign,\r
-                 char **ppValue,\r
-                 char **ppSeparator,\r
-                 int *pNest)\r
-#else\r
-char * endFormal(pStart,\r
-                            ppDataType,\r
-                                ppSymbol,\r
-                                ppEqualSign,\r
-                                ppValue,\r
-                                ppSeparator,\r
-                                pNest)\r
-char *pStart;\r
-char **ppDataType;\r
-char **ppSymbol;\r
-char **ppEqualSign;\r
-char **ppValue;\r
-char **ppSeparator;\r
-int *pNest;\r
-\r
-#endif\r
-{\r
-  char *p = pStart;\r
-  char *q;\r
-\r
-  *ppDataType = NULL;\r
-  *ppSymbol = NULL;\r
-  *ppEqualSign = NULL;\r
-  *ppValue = NULL;\r
-  *ppSeparator = NULL;\r
-\r
-  *pNest = 0;\r
-\r
-  /* The first non-blank is the start of the datatype */\r
-\r
-  p = skipSpaces(p);\r
-  if (*p == 0) goto EXIT;\r
-  *ppDataType = p;\r
-\r
-  /* We are not looking for the symbol, we are looking\r
-     for the separator that follows the symbol.  Then\r
-     we'll back up.\r
-   \r
-     Search for the ',' or '=" or null terminator.\r
-   */\r
-\r
-  p = skipToSeparatorOrEqualSign(p, pNest);\r
-\r
-  if (*pNest != 0) goto EXIT;\r
-\r
-  /*\r
-     Work backwards to find start of symbol\r
-     Skip spaces between the end of symbol and separator\r
-     Assume that there are no spaces in the formal, but\r
-     there is a space preceding the formal\r
-  */\r
-\r
-  for (q = &p[-1]; q >= *ppDataType; q--) {\r
-    if (! isspace(*q)) break;\r
-  }\r
-  if (q < *ppDataType) goto EXIT;\r
-\r
-  /*\r
-     MR26 Handle things like: IIR_Bool (IIR_Decl::*constraint)()\r
-     Backup until we hit the end of a symbol string, then find the\r
-     start of the symbol string.  This wont' work for functions\r
-     with prototypes, but works for the most common cases.  For\r
-     others, use typedef names.\r
-   */\r
-\r
-/* MR26 */  for (q = q; q >= *ppDataType; q--) {\r
-/* MR26 */    if (isalpha(*q) || isdigit(*q) || *q == '_' || *q == '$') break;\r
-/* MR26 */  }\r
-/* MR26 */  if (q < *ppDataType) goto EXIT;\r
-\r
-  for (q = q; q >= *ppDataType; q--) {\r
-    if ( ! (isalpha(*q) || isdigit(*q) || *q == '_' || *q == '$')) break;\r
-  }\r
-\r
-  *ppSymbol = &q[1];\r
-\r
-  if (*p == ',' || *p == 0) {\r
-    *ppSeparator = p;\r
-    goto EXIT;\r
-  }\r
-\r
-  *ppEqualSign = p;\r
-  p = skipSpaces(++p);\r
-  *ppValue = p;\r
-  if (*p == 0) goto EXIT;\r
-\r
-\r
-  while (*p != 0 && *pNest == 0 && *p != ',') {\r
-      p = skipToSeparator(p, pNest);\r
-  }\r
-  if (*pNest == 0) *ppSeparator = p;\r
-\r
-EXIT:\r
-  if (*p == ',') p++;\r
-  return p;\r
-}\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/antlr/mode.h b/Tools/CodeTools/TianoTools/Pccts/antlr/mode.h
deleted file mode 100644 (file)
index c08bf31..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-#define START 0\r
-#define STRINGS 1\r
-#define ACTION_STRINGS 2\r
-#define ACTION_CHARS 3\r
-#define ACTION_COMMENTS 4\r
-#define TOK_DEF_COMMENTS 5\r
-#define TOK_DEF_CPP_COMMENTS 6\r
-#define ACTION_CPP_COMMENTS 7\r
-#define CPP_COMMENTS 8\r
-#define COMMENTS 9\r
-#define ACTIONS 10\r
-#define PARSE_ENUM_FILE 11\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/antlr/mrhoist.c b/Tools/CodeTools/TianoTools/Pccts/antlr/mrhoist.c
deleted file mode 100644 (file)
index 110bf59..0000000
+++ /dev/null
@@ -1,3030 +0,0 @@
-/*\r
- * mrhoist.c\r
- *\r
- * SOFTWARE RIGHTS\r
- *\r
- * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
- * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
- * company may do whatever they wish with source code distributed with\r
- * PCCTS or the code generated by PCCTS, including the incorporation of\r
- * PCCTS, or its output, into commerical software.\r
- *\r
- * We encourage users to develop software with PCCTS.  However, we do ask\r
- * that credit is given to us for developing PCCTS.  By "credit",\r
- * we mean that if you incorporate our source code into one of your\r
- * programs (commercial product, research project, or otherwise) that you\r
- * acknowledge this fact somewhere in the documentation, research report,\r
- * etc...  If you like PCCTS and have developed a nice tool with the\r
- * output, please mention that you developed it using PCCTS.  In\r
- * addition, we ask that this header remain intact in our source code.\r
- * As long as these guidelines are kept, we expect to continue enhancing\r
- * this system and expect to make other tools available as they are\r
- * completed.\r
- *\r
- * ANTLR 1.33MR10\r
- *\r
- */\r
-\r
-#include <stdio.h>\r
-\r
-#include "pcctscfg.h"\r
-\r
-#include "set.h"\r
-#include "syn.h"\r
-#include "hash.h"\r
-#include "generic.h"\r
-#include "dlgdef.h"\r
-#include <ctype.h>\r
-\r
-#ifdef __USE_PROTOS\r
-void dumppred(Predicate *);\r
-#else\r
-void dumppred();\r
-#endif\r
-\r
-/*\r
-  Try to determine whether predicate "first" is true for\r
-    all cases where "second" is true.  Comparison takes place\r
-    without regard to context.\r
-  Assumes that predicate symbols have been expanded.\r
-  Assumes that there are no NAND or NOR nodes\r
-\r
-*/\r
-\r
-#ifdef __USE_PROTOS\r
-int MR_secondPredicateUnreachable(Predicate *first,Predicate *second)\r
-#else\r
-int MR_secondPredicateUnreachable(first,second)\r
-  Predicate     *first;\r
-  Predicate     *second;\r
-#endif\r
-{\r
-  Predicate     *f;\r
-  Predicate     *s;\r
-\r
-  if (first == NULL) {\r
-    return 1;\r
-  } else if (second == NULL) {\r
-    return 0;\r
-  } else if (first->down == NULL && second->down == NULL) {\r
-    if (first->source == second->source &&\r
-        first->inverted == second->inverted) {\r
-      return 1; /* look identical - will never reach alt2 */\r
-    } else {\r
-      return 0; /* look different */\r
-    };\r
-  } else if (first->down == NULL && second->down != NULL) {\r
-\r
-    if (second->expr == PRED_AND_LIST) {\r
-\r
-      /* unreachable if first covers any child of second */\r
-\r
-      for (s=second->down; s != NULL; s=s->right) {\r
-        if (MR_secondPredicateUnreachable(first,s)) {\r
-          return 1;\r
-        };\r
-      };\r
-      return 0;\r
-    } else if (second->expr == PRED_OR_LIST) {\r
-\r
-      /* unreachable if first covers every child of second */\r
-\r
-      for (s=second->down; s != NULL; s=s->right) {\r
-        if (!MR_secondPredicateUnreachable(first,s)) {\r
-          return 0;\r
-        };\r
-      };\r
-      return 1;\r
-    } else {\r
-      require (0,"Illegal pred->expr");\r
-      return 0; /* MR20 Make compiler happy */\r
-    };\r
-  } else if (first->down != NULL && second->down == NULL) {\r
-    if (first->expr == PRED_AND_LIST) {\r
-\r
-      /* unreachable if every child of first covers second */\r
-\r
-      for (f=first->down; f != NULL; f=f->right) {\r
-        if (!MR_secondPredicateUnreachable(f,second)) {\r
-          return 0;\r
-        };\r
-      };\r
-      return 1;\r
-    } else if (first->expr == PRED_OR_LIST) {\r
-\r
-      /* unreachable if any child of first covers second */\r
-\r
-      for (f=first->down; f != NULL; f=f->right) {\r
-        if (MR_secondPredicateUnreachable(f,second)) {\r
-          return 1;\r
-        };\r
-      };\r
-      return 0;\r
-    } else {\r
-      require (0,"Illegal predicate->expr");\r
-      return 0; /* MR20 Make compiler happy */\r
-    };\r
-  } else {\r
-\r
-    if (first->expr == PRED_AND_LIST && second->expr == PRED_AND_LIST) {\r
-\r
-      /* unreachable if each child of first covers at least one child of second */\r
-\r
-      for (f=first->down; f != NULL ; f=f->right) {\r
-        for (s=second->down; s != NULL ; s=s->right) {\r
-          if (MR_secondPredicateUnreachable(f,s)) goto A_next_f;\r
-        };\r
-        return 0;\r
-A_next_f:\r
-        continue;\r
-      };\r
-      return 1;\r
-\r
-    } else if (first->expr == PRED_AND_LIST && second->expr == PRED_OR_LIST) {\r
-\r
-      /* unreachable if each child of first covers ALL of second's children */\r
-\r
-      for (f=first->down; f != NULL ; f=f->right) {\r
-        for (s=second->down; s != NULL ; s=s->right) {\r
-          if (!MR_secondPredicateUnreachable(f,s)) return 0;\r
-        };\r
-      };\r
-      return 1;\r
-\r
-    } else if (first->expr == PRED_OR_LIST && second->expr == PRED_AND_LIST) {\r
-\r
-      /* unreachable if any child of second is covered by any child of first */\r
-\r
-      for (f=first->down; f != NULL ; f=f->right) {\r
-        for (s=second->down; s != NULL ; s=s->right) {\r
-          if (MR_secondPredicateUnreachable(f,s)) return 1;\r
-        };\r
-      };\r
-      return 0;\r
-\r
-    } else if (first->expr == PRED_OR_LIST && second->expr == PRED_OR_LIST) {\r
-\r
-      /* unreachable if every child of second is covered by some child of first */\r
-\r
-      for (f=first->down; f != NULL ; f=f->right) {\r
-        for (s=second->down; s != NULL ; s=s->right) {\r
-          if (MR_secondPredicateUnreachable(f,s)) goto B_next_f;\r
-        };\r
-        return 0;\r
-B_next_f:\r
-       continue;\r
-      };\r
-      return 1;\r
-\r
-    } else {\r
-      require (0,"Illegal predicate->expr");\r
-      return 0; /* MR20 Make compiler happy */\r
-    };\r
-  };\r
-  return 0; /* MR20 MSVC 5.0 complains about missing return statement */\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-void MR_xxxIndent(FILE *f,int depth)\r
-#else\r
-void MR_xxxIndent(f,depth)\r
-  FILE  *f;\r
-  int   depth;\r
-#endif\r
-{\r
-  int   i;\r
-\r
-  for (i=0; i<depth ; i++) {\r
-    fprintf(f,"  ");\r
-  };\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-void MR_stderrIndent(int depth)\r
-#else\r
-void MR_stderrIndent(depth)\r
-  int   depth;\r
-#endif\r
-{\r
-  MR_xxxIndent(stderr,depth);\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-void MR_outputIndent(int depth)\r
-#else\r
-void MR_outputIndent(depth)\r
-  int   depth;\r
-#endif\r
-{\r
-  MR_xxxIndent(output,depth);\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-void MR_set_reuse(set *s)\r
-#else\r
-void MR_set_reuse(s)\r
-  set   *s;\r
-#endif\r
-{\r
-  set_free(*s);\r
-  *s=empty;\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-void MR_dumpPredRuleRefStack(FILE *iounit,int indent)\r
-#else\r
-void MR_dumpPredRuleRefStack(iounit,indent)\r
-  FILE  *iounit;\r
-  int   indent;\r
-#endif\r
-{\r
-    int             i;\r
-    int             j;\r
-    int             count=MR_PredRuleRefStack.count;\r
-    RuleRefNode     *rrn=NULL;\r
-    Junction        *lastOne;\r
-\r
-    if (count == 0) {\r
-      fprintf(iounit,"empty\n");\r
-      return;\r
-    };\r
-    for (i=0; i < count; i++) {\r
-      rrn=(RuleRefNode *) MR_PredRuleRefStack.data[i];\r
-      for (j=0; j<indent; j++) fprintf(iounit," ");\r
-      fprintf(iounit,"#%-2d in rule %s (line %d %s) to rule %s\n",\r
-            i,rrn->rname,rrn->line,FileStr[rrn->file],rrn->text);\r
-    };\r
-    lastOne=MR_ruleReferenced(rrn);\r
-    if (lastOne != NULL) {\r
-      for (j=0; j<indent; j++) fprintf(iounit," ");\r
-      fprintf(iounit,"#%-2d in rule %s (line %d %s)\n",\r
-        count,lastOne->rname,lastOne->line,FileStr[lastOne->file]);\r
-    };\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-void MR_dumpTreeF(FILE *f,int depth,Tree *tree,int across)\r
-#else\r
-void MR_dumpTreeF(f,depth,tree,across)\r
-  FILE  *f;\r
-  Tree  *tree;\r
-  int   depth;\r
-  int   across;\r
-#endif\r
-{\r
-    int     newAcross=across;\r
-\r
-       if (tree == NULL ) return;\r
-       if (tree->down != NULL ) {\r
-      fprintf(output,"\n");\r
-      MR_outputIndent(depth);\r
-      fprintf(output, "(root =");\r
-    };\r
-       if (tree->token == ALT ) {\r
-      fprintf(output," %-16s","Alt");\r
-       } else if (tree->token==EpToken ) {\r
-      fprintf(output,"(%d)%13s",tree->v.rk," ");\r
-       } else {\r
-      fprintf(output," %-16s",TerminalString(tree->token));\r
-    };\r
-    if (tree->down != NULL) {\r
-      fprintf(output,"\n");\r
-      MR_outputIndent(depth+1);\r
-      MR_dumpTreeF(f,depth+1,tree->down,1);\r
-      newAcross=0;\r
-      fprintf(output,"\n");\r
-      MR_outputIndent(depth);\r
-      fprintf(output,")");\r
-    };\r
-    if (newAcross > 3) {\r
-      fprintf(output,"\n");\r
-      MR_outputIndent(depth);\r
-      newAcross=0;\r
-    };\r
-    MR_dumpTreeF(f,depth,tree->right,newAcross+1);\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-void MR_dumpTreeX(int depth,Tree *tree,int across)\r
-#else\r
-void MR_dumpTreeX(depth,tree,across)\r
-  Tree  *tree;\r
-  int   depth;\r
-  int   across;\r
-#endif\r
-{\r
-  MR_dumpTreeF(output,depth,tree,across);\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-void MR_dumpTokenSet(FILE *f,int depth,set s)\r
-#else\r
-void MR_dumpTokenSet(f,depth,s)\r
-  FILE  *f;\r
-  int   depth;\r
-  set   s;\r
-#endif\r
-{\r
-    int     i;\r
-    int     j;\r
-\r
-    unsigned  *pdq;\r
-\r
-    if (set_nil(s)) {\r
-      fprintf(f,"\n");\r
-      MR_xxxIndent(f,depth+1);\r
-      fprintf(f,"nil\n");\r
-      return;\r
-    };\r
-\r
-    pdq=set_pdq(s);\r
-    require(pdq != NULL,"set_pdq failed");\r
-    i=0;\r
-    for (i=0 ; ; i=i+4) {\r
-      fprintf(f,"\n");\r
-      MR_xxxIndent(f,depth+1);\r
-      for (j=0; j < 4 ; j++) {\r
-        if (pdq[i+j] == nil) break;\r
-        fprintf(f," %-16s",TerminalString(pdq[i+j]));\r
-      };\r
-      if (pdq[i+j] == nil) break;\r
-    };\r
-    fprintf(f,"\n");\r
-    free( (char *) pdq);\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-void MR_dumpPred1(int depth,Predicate *p,int withContext)\r
-#else\r
-void MR_dumpPred1(depth,p,withContext)\r
-  int           depth;\r
-  Predicate     *p;\r
-  int           withContext;\r
-#endif\r
-{\r
-  unsigned      k;\r
-\r
-  if (p == NULL) {\r
-    MR_outputIndent(depth);\r
-    fprintf(output,"The predicate is empty (or always true)\n\n");\r
-    return;\r
-  };\r
-  if (p->down != NULL) {\r
-    MR_outputIndent(depth);\r
-    if (p->inverted) {\r
-\r
-        /* MR14a Left out print expression in fprintf\r
-                 Reported by Manuel Kessler (mlkessle@cip.physik.uni-wuerzburg.de)\r
-        */\r
-\r
-      if (p->expr == PRED_AND_LIST) fprintf(output,"%s NAND (not AND) expr\n\n",p->expr);\r
-      if (p->expr == PRED_OR_LIST) fprintf(output,"%s NOR (not OR) expr\n\n",p->expr);\r
-    } else {\r
-      fprintf(output,"%s expr\n\n",p->expr);\r
-    };\r
-  } else {\r
-    MR_outputIndent(depth);\r
-    fprintf(output,"pred %s <<%s>>?\n",\r
-            (p->inverted ? " *not*" : ""),\r
-            (p->expr == NULL ? "null expr" : p->expr));\r
-    MR_outputIndent(depth+1);\r
-    fprintf(output,"              ");\r
-    fprintf(output,"  depth=k=%d",p->k);\r
-    if (p->source != NULL && p->source->guardpred) {\r
-      fprintf(output,"  (\"=>\" guard)");\r
-    }\r
-    if (p->source != NULL && p->source->ampersandPred != NULL) {\r
-      fprintf(output,"  (\"&&\" guard)");\r
-    };\r
-    k=set_int(p->completionSet);\r
-    if (k != nil) {\r
-      fprintf(output," Incomplete Set at k=%d !",k);\r
-    };\r
-    k=set_int(p->completionTree);\r
-    if (k != nil) {\r
-      fprintf(output," Incomplete Tree at k=%d !",k);\r
-    };\r
-    if (p->source != NULL) {\r
-      fprintf(output,"  rule %s  line %d  %s",\r
-                    p->source->rname,p->source->line,FileStr[p->source->file]);\r
-    };\r
-    fprintf(output,"\n");\r
-    if (withContext &&\r
-            (HoistPredicateContext ||\r
-             ! set_nil(p->scontext[1]) ||\r
-             p->tcontext != NULL)) {\r
-      if (p->k == 1) {\r
-        MR_outputIndent(depth+1);\r
-        fprintf(output,"set context: ");\r
-        MR_dumpTokenSet(output,depth+1,p->scontext[1]);\r
-      }\r
-      if (p->k != 1) {\r
-        MR_outputIndent(depth+1);\r
-        fprintf(output,"tree context:");\r
-        if (p->tcontext == NULL) {\r
-          fprintf(output," null");\r
-        } else {\r
-          MR_dumpTreeX(depth+2,p->tcontext,0);\r
-        };\r
-        fprintf(output,"\n");\r
-      };\r
-    };\r
-    fprintf(output,"\n");\r
-  };\r
-  if (p->down != NULL) {\r
-    MR_dumpPred1(depth+1,p->down,withContext);\r
-  };\r
-  if (p->right != NULL) {\r
-    MR_dumpPred1(depth,p->right,withContext);\r
-  };\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-void MR_dumpPred(Predicate *p,int withContext)\r
-#else\r
-void MR_dumpPred(p,withContext)\r
-  Predicate     *p;\r
-  int           withContext;\r
-#endif\r
-{\r
-  MR_dumpPred1(0,p,withContext);\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-Tree * MR_make_tree_from_set(set s)\r
-#else\r
-Tree * MR_make_tree_from_set(s)\r
-  set   s;\r
-#endif\r
-{\r
-  Tree  *t=NULL;\r
-  Tree  *node;\r
-  Tree  **tp=&t;\r
-  int   i;\r
-\r
-  unsigned *pdq=set_pdq(s);\r
-\r
-  if (pdq != NULL) {\r
-    for (i=0 ; pdq[i] != nil ; i++) {\r
-      node=tnode( (int) pdq[i]);\r
-      *tp=node;\r
-      tp=&(node->right);\r
-    };\r
-    *tp=NULL;\r
-    free ( (char *) pdq);\r
-  };\r
-  return t;\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-void MR_check_pred_too_long(Predicate *p,set completion)\r
-#else\r
-void MR_check_pred_too_long(p,completion)\r
-  Predicate     *p;\r
-  set           completion;\r
-#endif\r
-{\r
-  if (p != NULL &&\r
-      p->source != NULL &&\r
-      ! p->source->predTooLong) {\r
-    if ( !set_nil(completion)) {\r
-      p->source->predTooLong=1;\r
-warnFL("It is unusual (but ok) for a semantic predicate to test context past the end of its own rule",\r
-                                FileStr[p->source->file],p->source->line);\r
-    };\r
-  };\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-int MR_predicate_context_completed(Predicate *p)\r
-#else\r
-int MR_predicate_context_completed(p)\r
-  Predicate     *p;\r
-#endif\r
-{\r
-  if (p == NULL) return 1;\r
-  if (p->expr != PRED_AND_LIST &&\r
-      p->expr != PRED_OR_LIST) {\r
-    if ( ! set_nil(p->completionSet)) return 0;\r
-    if ( ! set_nil(p->completionTree)) return 0;\r
-  };\r
-  return MR_predicate_context_completed(p->down) &\r
-         MR_predicate_context_completed(p->right);\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-Node * MR_advance(Node *n)\r
-#else\r
-Node * MR_advance(n)\r
-  Node  *n;\r
-#endif\r
-{\r
-    if (n == NULL) return NULL;\r
-    switch (n->ntype) {\r
-      case nJunction:   return ((Junction *)n)->p1;\r
-      case nToken:      return ((TokNode *)n)->next;\r
-      case nRuleRef:    return ((RuleRefNode *)n)->next;\r
-      case nAction:     return ((ActionNode *)n)->next;\r
-      default:          return NULL;\r
-    };\r
-  return NULL; /* MSVC 5.0 complains about missing return statement */\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-Junction * MR_find_endRule(Node *n)\r
-#else\r
-Junction * MR_find_endRule(n)\r
-  Node  *n;\r
-#endif\r
-{\r
-    Node    *next;\r
-    if (n == NULL) return NULL;\r
-    for (next=n; next != NULL; next=MR_advance(next)) {\r
-      if (next->ntype == nJunction &&\r
-            ( (Junction *) next)->jtype == EndRule) {\r
-        break;\r
-      };\r
-    };\r
-    return (Junction *)next;\r
-}\r
-\r
-/*\r
-   Intersection:  a branch which is shorter is chosen\r
-   over one which is longer: (A B C) intersect (A B) yields (A B).\r
-\r
-   AND: a branch which is longer is chosen over the one\r
-   which is shorter: (A B C) AND (A B) yields (A B C)\r
-\r
-*/\r
-\r
-#ifdef __USE_PROTOS\r
-Tree *MR_computeTreeIntersection(Tree *l,Tree *r)\r
-#else\r
-Tree *MR_computeTreeIntersection(l,r)\r
-    Tree    *l;\r
-    Tree    *r;\r
-#endif\r
-{\r
-    Tree    *result=NULL;\r
-    Tree    **tail;\r
-    Tree    *p;\r
-    Tree    *q;\r
-    Tree    *match;\r
-\r
-    if (l == NULL || r == NULL) return NULL;\r
-    for (p=l; p != NULL; p=p->right) {\r
-      require(p->token != EpToken,"MR_computeTreeIntersection: p->EpToken unexpected\n");\r
-      require (p->token != ALT,"MR_computeTreeIntersection: p->ALT unexpected\n");\r
-    };\r
-    for (q=r; q != NULL; q=q->right) {\r
-      require(q->token != EpToken,"MR_computeTreeIntersection: q->EpToken unexpected\n");\r
-      require(q->token != ALT,"MR_computeTreeIntersection: q->ALT unexpected\n");\r
-    };\r
-\r
-    result=tnode(ALT);\r
-    tail=&(result->down);\r
-\r
-    for (p=l; p != NULL ; p=p->right) {\r
-      for (q=r; q != NULL ; q=q->right) {\r
-        if (p->token == q->token) {\r
-          match=tnode(p->token);\r
-          match->down=MR_computeTreeIntersection(p->down,q->down);\r
-          *tail=match;\r
-          tail=&(match->right);\r
-        };\r
-      };\r
-    };\r
-\r
-    *tail=NULL;\r
-    result=tshrink(result);\r
-    result=tflatten( result );\r
-    result=tleft_factor( result );\r
-    return result;\r
-}\r
-\r
-/* the predicates which are ANDed together have a common\r
-   context:  they must all have common roots.  Thus the\r
-   AND operation is more like an OR operation because\r
-   branches which are longer are grafted onto shorter\r
-   branches of the AND tree.  For instance combining\r
-   (A B C) with (A B C D) gives (A B C D).  There\r
-   should never be a case of (A B C) and (A B D) because\r
-   they have the same context.\r
-\r
-   Actually, this may not be true once one throws in\r
-   guard predicates which are defined by the user, not\r
-   the context.\r
-*/\r
-\r
-/* requires input trees to be in "canonical" format */\r
-\r
-#ifdef __USE_PROTOS\r
-Tree *MR_computeTreeAND(Tree *l,Tree *r)\r
-#else\r
-Tree *MR_computeTreeAND(l,r)\r
-    Tree    *l;\r
-    Tree    *r;\r
-#endif\r
-{\r
-    Tree    *result=NULL;\r
-    Tree    **tail;\r
-    Tree    *p;\r
-    Tree    *q;\r
-    Tree    *match;\r
-\r
-    if (l == NULL) return tdup(r);\r
-    if (r == NULL) return tdup(l);\r
-\r
-    for (p=l; p != NULL; p=p->right) {\r
-/**** require(p->token != EpToken,"MR_computeTreeAND: p->EpToken unexpected\n"); ****/\r
-      require (p->token != ALT,"MR_computeTreeAND: p->ALT unexpected\n");\r
-    };\r
-    for (q=r; q != NULL; q=q->right) {\r
-/**** require(q->token != EpToken,"MR_computeTreeAND: q->EpToken unexpected\n"); ****/\r
-      require(q->token != ALT,"MR_computeTreeAND: q->ALT unexpected\n");\r
-    };\r
-\r
-    result=tnode(ALT);\r
-    tail=&(result->down);\r
-\r
-    for (p=l; p != NULL ; p=p->right) {\r
-      for (q=r; q != NULL ; q=q->right) {\r
-        if (p->token == q->token) {\r
-          match=tnode(p->token);\r
-          match->down=MR_computeTreeAND(p->down,q->down);\r
-          *tail=match;\r
-          tail=&(match->right);\r
-        };\r
-      };\r
-    };\r
-\r
-    *tail=NULL;\r
-    result=tshrink(result);\r
-    result=tflatten( result );\r
-    result=tleft_factor( result );\r
-    return result;\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-void MR_union_plain_sets1(Predicate *p,set *theUnion)\r
-#else\r
-void MR_union_plain_sets1(p,theUnion)\r
-  Predicate     *p;\r
-  set           *theUnion;\r
-#endif\r
-{\r
-  if (p == NULL) return;\r
-  MR_union_plain_sets1(p->down,theUnion);\r
-  MR_union_plain_sets1(p->right,theUnion);\r
-  set_orin(theUnion,p->plainSet);\r
-  return;\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-set MR_union_plain_sets(Predicate *p)\r
-#else\r
-set MR_union_plain_sets(p)\r
-  Predicate     *p;\r
-#endif\r
-{\r
-  set   theUnion;\r
-\r
-  theUnion=empty;\r
-\r
-  MR_union_plain_sets1(p,&theUnion);\r
-  return theUnion;\r
-}\r
-\r
-/* does NOT left factor: do not want to merge\r
-     (A B) with (A) to get (A B)\r
-   in fact the opposite: (A B) with (A) gives (A)\r
-*/\r
-\r
-#ifdef __USE_PROTOS\r
-Tree *MR_compute_pred_tree_ctxXX(Predicate *p)\r
-#else\r
-Tree *MR_compute_pred_tree_ctxXX(p)\r
-  Predicate     *p;\r
-#endif\r
-{\r
-    Tree        *result=NULL;\r
-    Predicate   *q;\r
-    Tree        *t;\r
-\r
-    if (p == NULL) return NULL;\r
-\r
-/* this appears strange: why do we OR the context\r
-   of and AND predicate ?  It is because of the way\r
-   that predicates are evaluated: if the context is\r
-   wrong then it's the same as if the predicate was\r
-   true.  That means that even when one leg of an\r
-   AND has unmatched context, if the other leg has\r
-   matched context and is true then the predicate\r
-   succeeds.  It's only when all the legs have unmatched\r
-   context that this one can skip evaluation of the\r
-   predicates.\r
-*/\r
-    if (p->expr == PRED_OR_LIST ||\r
-        p->expr == PRED_AND_LIST) {\r
-      for (q=p->down; q != NULL ; q=q->right) {\r
-        t=MR_compute_pred_tree_ctxXX(q);\r
-        result=tappend(result,t);\r
-        t=NULL;\r
-      };\r
-\r
-      result=tshrink(result);\r
-      result=tflatten( result );\r
-\r
-/* does NOT left factor: do not want to merge\r
-     (A B) with (A) to get (A B)\r
-   in fact the opposite: (A B) with (A) gives (A)\r
-*/\r
-\r
-/**** result=tleft_factor( result ); ****/\r
-      return result;\r
-    };\r
-\r
-#if 0\r
-**    if (p->expr == PRED_AND_LIST) {\r
-**\r
-**      Predicate     *l;\r
-**      Predicate     *r;\r
-**      Tree          *l1;\r
-**      Tree          *r1;\r
-**      Tree          *prevl1;\r
-**\r
-**      l=p->down;\r
-**      require (l->right != NULL,"MR_compute_pred_tree - AND has only one child");\r
-**\r
-**/* l1 and r1 should already be in "canonical" format */\r
-**\r
-**      l1=MR_compute_pred_tree(l);\r
-**      for (r=l->right; r != NULL; r=r->right) {\r
-**        r1=MR_compute_pred_tree(r);\r
-**        prevl1=l1;\r
-**        l1=MR_computeTreeAND(l1,r1);\r
-**        Tfree(r1);\r
-**        Tfree(prevl1);\r
-**      };\r
-**\r
-**/* result from computeTreeAND should be in "canonical" format */\r
-**\r
-**      result=l1;\r
-**\r
-**/* result of MR_computeTreeAND should be in "canonical" format */\r
-**\r
-**      return result;\r
-**    };\r
-#endif\r
-\r
-    if (p->k == 1) {\r
-      result=MR_make_tree_from_set(p->scontext[1]);\r
-    } else {\r
-      result=tdup(p->tcontext);\r
-      result=MR_remove_epsilon_from_tree(result);\r
-      result=tshrink(result);\r
-      result=tflatten(result);\r
-      result=tleft_factor(result);\r
-    };\r
-    return result;\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-void MR_pred_depth(Predicate *p,int *maxDepth)\r
-#else\r
-void MR_pred_depth(p,maxDepth)\r
-  Predicate     *p;\r
-  int           *maxDepth;\r
-#endif\r
-{\r
-  if (p == NULL) return;\r
-  if (p->expr != PRED_OR_LIST &&\r
-      p->expr != PRED_AND_LIST) {\r
-    if (p->k > *maxDepth) *maxDepth=p->k;\r
-  };\r
-  MR_pred_depth(p->down,maxDepth);\r
-  MR_pred_depth(p->right,maxDepth);\r
-}\r
-\r
-/* this computes the OR of all the contexts */\r
-\r
-#ifdef __USE_PROTOS\r
-set MR_compute_pred_set(Predicate *p)\r
-#else\r
-set MR_compute_pred_set(p)\r
-  Predicate     *p;\r
-#endif\r
-{\r
-    set         result;\r
-    Predicate   *q;\r
-\r
-    result=empty;\r
-\r
-    if (p == NULL) return empty;\r
-\r
-    if (p->expr == PRED_OR_LIST ||\r
-        p->expr == PRED_AND_LIST) {         /* yes, I do mean PRED_AND_LIST !   */\r
-                                            /* remember: r1: (A)? => <<p>>? r2; */\r
-                                            /*           r2: (B)? => <<q>>? r3; */\r
-      set   t;\r
-\r
-      t=empty;\r
-      result=empty;\r
-\r
-      for (q=p->down; q != NULL; q=q->right) {\r
-        t=MR_compute_pred_set(q);\r
-        set_orin(&result,t);\r
-        set_free(t);\r
-      };\r
-      return result;\r
-    } else if (p->k > 1) {\r
-      return empty;\r
-    } else {\r
-      return set_dup(p->scontext[1]);\r
-    };\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-set MR_First(int ck,Junction *j,set *incomplete)\r
-#else\r
-set MR_First(ck,j,incomplete)\r
-  int       ck;\r
-  Junction  *j;\r
-  set       *incomplete;\r
-#endif\r
-{\r
-    Junction    *p;\r
-    set         tokensUsed;\r
-\r
-    tokensUsed=empty;\r
-\r
-       require(j->ntype==nJunction, "MR_First: non junction passed");\r
-\r
-       p = analysis_point((Junction *)j->p1);\r
-\r
-       REACH(p,ck,incomplete,tokensUsed);\r
-\r
-    return tokensUsed;\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-void MR_cleanup_pred_trees(Predicate *p)\r
-#else\r
-void MR_cleanup_pred_trees(p)\r
-  Predicate     *p;\r
-#endif\r
-{\r
-  Tree      *t;\r
-\r
-  if (p == NULL) return;\r
-  if (p->expr != PRED_OR_LIST &&\r
-      p->expr != PRED_AND_LIST) {\r
-    t=p->tcontext;\r
-    t=tshrink(t);\r
-    t=tflatten(t);\r
-    t=tleft_factor(t);\r
-    p->tcontext=t;\r
-  };\r
-  MR_cleanup_pred_trees(p->down);\r
-  MR_cleanup_pred_trees(p->right);\r
-}\r
-\r
-/* does NOT return canonical tree */\r
-\r
-#ifdef __USE_PROTOS\r
-Tree * MR_remove_epsilon_from_tree(Tree *t)\r
-#else\r
-Tree * MR_remove_epsilon_from_tree(t)\r
-  Tree  *t;\r
-#endif\r
-{\r
-  if (t == NULL) return NULL;\r
-\r
-  /* I think ALT can be ignored as a special case */\r
-\r
-  if (t->token != EpToken) {\r
-    t->down=MR_remove_epsilon_from_tree(t->down);\r
-    t->right=MR_remove_epsilon_from_tree(t->right);\r
-    return t;\r
-  } else {\r
-    Tree    *u;\r
-    u=MR_remove_epsilon_from_tree(t->right);\r
-    t->right=NULL;\r
-    Tfree(t);\r
-    return u;\r
-  };\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-void MR_complete_set(int predDepth,set *tokensUsed,set *incomplete)\r
-#else\r
-void MR_complete_set(predDepth,tokensUsed,incomplete)\r
-  int       predDepth;\r
-  set       *tokensUsed;\r
-  set       *incomplete;\r
-#endif\r
-{\r
-    int             i;\r
-    RuleRefNode     *ruleRef;\r
-       set             rk2;\r
-    set             b;\r
-       int             k2;\r
-    Junction        *save_MR_RuleBlkWithHalt;\r
-\r
-    if (set_int(*incomplete) > (unsigned) predDepth) {\r
-      return;\r
-    };\r
-\r
-    require(MR_PredRuleRefStack.count == MR_RuleBlkWithHaltStack.count,\r
-                "RuleRefStack and RuleBlkWithHaltStack not same size");\r
-\r
-    require(MR_RuleBlkWithHalt == NULL ||\r
-         (MR_RuleBlkWithHalt->jtype == RuleBlk && MR_RuleBlkWithHalt->end->halt == TRUE),\r
-                     "RuleBlkWithHalt has no halt set");\r
-\r
-    save_MR_RuleBlkWithHalt=MR_RuleBlkWithHalt;\r
-\r
-    if (MR_RuleBlkWithHalt != NULL) {\r
-      MR_RuleBlkWithHalt->end->halt=FALSE;\r
-    };\r
-\r
-    for (i=MR_PredRuleRefStack.count-1; i >= 0 ; i--) {\r
-      ruleRef=(RuleRefNode *)MR_PredRuleRefStack.data[i];\r
-      if (ruleRef == NULL) continue;\r
-\r
-      MR_RuleBlkWithHalt=(Junction *)MR_RuleBlkWithHaltStack.data[i];\r
-      if (MR_RuleBlkWithHalt != NULL) MR_RuleBlkWithHalt->end->halt=TRUE;\r
-\r
-      rk2=empty;\r
-      b=empty;\r
-\r
-      while ( !set_nil(*incomplete) ) {\r
-               k2=set_int(*incomplete);\r
-        if (k2 > predDepth) break;                    /* <=== another exit from loop */\r
-               set_rm(k2,*incomplete);\r
-        REACH(ruleRef->next,k2,&rk2,b);\r
-               set_orin(tokensUsed,b);\r
-               set_free(b);\r
-      };\r
-\r
-      if (MR_RuleBlkWithHalt != NULL) MR_RuleBlkWithHalt->end->halt=FALSE;\r
-\r
-         set_orin(incomplete,rk2);                       /* remember what we couldn't do */\r
-      set_free(rk2);\r
-         if (set_int(*incomplete) > (unsigned) predDepth) break;    /* <=== another exit from loop */\r
-    };\r
-\r
-    MR_RuleBlkWithHalt=save_MR_RuleBlkWithHalt;\r
-    if (MR_RuleBlkWithHalt != NULL) {\r
-      MR_RuleBlkWithHalt->end->halt=TRUE;\r
-    };\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-void MR_complete_tree(int predDepth,Tree **t,set *incomplete)\r
-#else\r
-void MR_complete_tree(predDepth,t,incomplete)\r
-  int       predDepth;\r
-  Tree      **t;\r
-  set       *incomplete;\r
-#endif\r
-{\r
-    int             i;\r
-    RuleRefNode     *ruleRef;\r
-       set             rk2;\r
-    Tree            *u;\r
-       unsigned        k2;\r
-    Junction        *save_MR_RuleBlkWithHalt;\r
-    int             saveConstrainSearch;\r
-\r
-    if (set_int(*incomplete) > (unsigned) predDepth) {\r
-      return;\r
-    };\r
-\r
-    require(MR_PredRuleRefStack.count == MR_RuleBlkWithHaltStack.count,\r
-                "RuleRefStack and RuleBlkWithHaltStack not same size");\r
-\r
-    require(MR_RuleBlkWithHalt == NULL ||\r
-         (MR_RuleBlkWithHalt->jtype == RuleBlk && MR_RuleBlkWithHalt->end->halt == TRUE),\r
-                     "RuleBlkWithHalt has no halt set");\r
-\r
-    save_MR_RuleBlkWithHalt=MR_RuleBlkWithHalt;\r
-    saveConstrainSearch=ConstrainSearch;\r
-    ConstrainSearch=0;\r
-\r
-    if (MR_RuleBlkWithHalt != NULL) {\r
-      MR_RuleBlkWithHalt->end->halt=FALSE;\r
-    };\r
-\r
-    for (i=MR_PredRuleRefStack.count-1; i >= 0 ; i--) {\r
-      ruleRef=(RuleRefNode *)MR_PredRuleRefStack.data[i];\r
-      if (ruleRef == NULL) continue;\r
-\r
-      MR_RuleBlkWithHalt=(Junction *)MR_RuleBlkWithHaltStack.data[i];\r
-\r
-      if (MR_RuleBlkWithHalt != NULL) MR_RuleBlkWithHalt->end->halt=TRUE;\r
-\r
-      rk2=empty;\r
-\r
-      while ( !set_nil(*incomplete) ) {        \r
-               k2 = set_int(*incomplete);\r
-        if (k2 > (unsigned) predDepth) break;       /* <=== another exit from loop */\r
-               set_rm(k2,*incomplete);\r
-               u = NULL;\r
-\r
-        TRAV(ruleRef->next,k2,&rk2,u);\r
-\r
-                       /* any subtrees missing k2 tokens, add u onto end */\r
-\r
-               *t=tlink(*t,u,k2);\r
-        Tfree(u);\r
-      }\r
-\r
-         set_orin(incomplete,rk2);         /* remember what we couldn't do */\r
-      set_free(rk2);\r
-\r
-      if (MR_RuleBlkWithHalt != NULL) MR_RuleBlkWithHalt->end->halt=FALSE;\r
-\r
-         if (set_int(*incomplete) > (unsigned) predDepth) break;    /* <=== another exit from loop */\r
-    };\r
-\r
-    MR_RuleBlkWithHalt=save_MR_RuleBlkWithHalt;\r
-\r
-    if (MR_RuleBlkWithHalt != NULL) {\r
-      MR_RuleBlkWithHalt->end->halt=TRUE;\r
-    };\r
-    ConstrainSearch=saveConstrainSearch;\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-void MR_complete_predicates(int predDepth,Predicate *pred)\r
-#else\r
-void MR_complete_predicates(predDepth,pred)\r
-  int           predDepth;\r
-  Predicate     *pred;\r
-#endif\r
-{\r
-  if (pred == NULL) return;\r
-  if (pred->expr != PRED_AND_LIST &&\r
-      pred->expr != PRED_OR_LIST) {\r
-    MR_complete_set(predDepth,&(pred->scontext[1]),&(pred->completionSet));\r
-    MR_complete_tree(predDepth,&(pred->tcontext),&(pred->completionTree));\r
-  };\r
-  MR_complete_predicates(predDepth,pred->down);\r
-  MR_complete_predicates(predDepth,pred->right);\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-Junction * MR_junctionWithoutP2(Junction *j)\r
-#else\r
-Junction * MR_junctionWithoutP2(j)\r
-  Junction  *j;\r
-#endif\r
-{\r
-  Junction  *thisAlt;\r
-\r
-/* don't want to follow p2 to the next alternative of this rule */\r
-/* insert a generic node with null p2 if necessary              */\r
-/* however FIRST requires a junction                            */\r
-\r
-  thisAlt=j;\r
-  if (thisAlt->p2 != NULL) {\r
-    if (thisAlt->p1->ntype == nJunction) {\r
-      thisAlt=(Junction *) thisAlt->p1;\r
-    } else {\r
-      thisAlt=newJunction();\r
-      thisAlt->p1=j->p1;\r
-      thisAlt->rname=j->rname;\r
-      thisAlt->file=j->file;\r
-      thisAlt->line=j->line;\r
-      j->p1=(Node *)thisAlt;\r
-    };\r
-  };\r
-  return thisAlt;\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-int MR_tree_equ(Tree *big, Tree *small) {\r
-#else\r
-int MR_tree_equ(big,small)\r
-  Tree  *big;\r
-  Tree  *small;\r
-{\r
-#endif\r
-\r
-  Tree      *b;\r
-  Tree      *s;\r
-  int       bcount=0;\r
-  int       scount=0;\r
-\r
-  if (small == NULL && big == NULL) return 1;\r
-  if (small == NULL) return 0;\r
-  if (big == NULL) return 0;\r
-\r
-  if (small->token == ALT) {\r
-    require(small->right == NULL,\r
-                "MR_tree_equ: small: ALT node has siblings");\r
-    return MR_tree_equ(big,small->down);\r
-  };\r
-  if (big->token == ALT) {\r
-    require(big->right == NULL,\r
-                "MR_tree_equ: big: ALT node has siblings");\r
-    return MR_tree_equ(big->down,small);\r
-  };\r
-  for (s=small; s != NULL; s=s->right) {\r
-    scount++;\r
-    require(s->token != EpToken,"MR_tree_equ: s->EpToken unexpected\n");\r
-  };\r
-  for (b=big; b != NULL; b=b->right) {\r
-    bcount++;\r
-    require(b->token != EpToken,"MR_tree_equ: b->EpToken unexpected\n");\r
-  };\r
-\r
-  if (bcount != scount) return 0;\r
-\r
-  for (s=small; s != NULL; s=s->right) {\r
-    for (b=big; b!= NULL; b=b->right) {\r
-      if (s->token == b->token) {\r
-        if (MR_tree_equ(b->down,s->down)) goto next_s;\r
-      };\r
-    };\r
-    return 0;\r
-next_s:\r
-    continue;\r
-  };\r
-  return 1;\r
-}\r
-\r
-/* this does not compare sources - only contexts ! */\r
-\r
-#ifdef __USE_PROTOS\r
-int MR_identicalContext(Predicate *p,Predicate *q)\r
-#else\r
-int MR_identicalContext(p,q)\r
-  Predicate     *p;\r
-  Predicate     *q;\r
-#endif\r
-{\r
-  if (p->k != q->k) return 0;\r
-  require ( (p->tcontext == NULL) == (q->tcontext == NULL),\r
-        "tcontext inconsistent");\r
-  if (p->k == 1) {\r
-    return set_equ(p->scontext[1],q->scontext[1]);\r
-  } else {\r
-    return MR_tree_equ(p->tcontext,q->tcontext);\r
-  };\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-void MR_reportSetSuppression(int predDepth,\r
-            set predSet,set plainSet,Junction *jPred,Junction *jPlain,Predicate *p)\r
-#else\r
-void MR_reportSetSuppression(predDepth,predSet,plainSet,jPred,jPlain,p)\r
-  int       predDepth;\r
-  set       predSet;\r
-  set       plainSet;\r
-  Junction  *jPred;\r
-  Junction  *jPlain;\r
-  Predicate *p;\r
-#endif\r
-{\r
-  if (InfoP) {\r
-    fprintf(output,"\n#if 0\n\n");\r
-    fprintf(output,"Hoisting of predicate suppressed by alternative without predicate.\n");\r
-    fprintf(output,"The alt without the predicate includes all cases where the predicate is false.\n\n");\r
-    fprintf(output,"   WITH predicate: line %d  %s\n",jPred->line,FileStr[jPred->file]);\r
-    if (jPlain != NULL) {\r
-      fprintf(output,"   WITHOUT predicate: line %d  %s\n",jPlain->line,FileStr[jPlain->file]);\r
-    } else {\r
-      fprintf(output,"   WITHOUT predicate: all alternatives without predicates (combined)\n");\r
-    };\r
-    if (predDepth == 1) {\r
-      fprintf(output,"\nThe context set for the predicate:\n");\r
-      MR_dumpTokenSet(output,1,predSet);\r
-    };\r
-    fprintf(output,"\nThe lookahead set for the alt WITHOUT the semantic predicate:\n");\r
-    MR_dumpTokenSet(output,1,plainSet);\r
-    fprintf(output,"\nThe predicate:\n\n");\r
-    MR_dumpPred1(1,p,1);\r
-    fprintf(output,"Chain of referenced rules:\n\n");\r
-    MR_dumpPredRuleRefStack(output,4);\r
-    fprintf(output,"\n#endif\n");\r
-  };\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-void MR_reportSetRestriction(int predDepth,set predSet,set plainSet,\r
-            Junction *jPred,Junction *jPlain,Predicate *origPred,Predicate *newPred)\r
-#else\r
-void MR_reportSetRestriction(predDepth,predSet,plainSet,jPred,jPlain,origPred,newPred)\r
-  int       predDepth;\r
-  set       predSet;\r
-  set       plainSet;\r
-  Junction  *jPred;\r
-  Junction  *jPlain;\r
-  Predicate *origPred;\r
-  Predicate *newPred;\r
-#endif\r
-{\r
-  set       intersect;\r
-\r
-  intersect=empty;\r
-\r
-  if (! InfoP) return;\r
-  fprintf(output,"\n#if 0\n\n");\r
-  fprintf(output,"Restricting the context of a predicate because of overlap in the lookahead set\n");\r
-  fprintf(output,"  between the alternative with the semantic predicate and one without\n");\r
-  fprintf(output,"Without this restriction the alternative without the predicate could not\n");\r
-  fprintf(output,"  be reached when input matched the context of the predicate and the predicate\n");\r
-  fprintf(output,"  was false.\n\n");\r
-\r
-  fprintf(output,"   WITH predicate: line %d  %s\n",jPred->line,FileStr[jPred->file]);\r
-  if (jPlain != NULL) {\r
-    fprintf(output,"   WITHOUT predicate: line %d  %s\n",jPlain->line,FileStr[jPlain->file]);\r
-  } else {\r
-    fprintf(output,"   WITHOUT predicate: all alternatives without predicates (combined)\n");\r
-  };\r
-  if (predDepth == 1) {\r
-    fprintf(output,"\nThe original context set for the predicate:\n");\r
-    MR_dumpTokenSet(output,1,predSet);\r
-  };\r
-  fprintf(output,"\nThe lookahead set for the alt WITHOUT the semantic predicate:\n");\r
-  MR_dumpTokenSet(output,1,plainSet);\r
-  if (predDepth == 1) {\r
-    fprintf(output,"\nThe intersection of the two sets\n");\r
-    intersect=set_and(predSet,plainSet);\r
-    MR_dumpTokenSet(output,1,intersect);\r
-    set_free(intersect);\r
-  };\r
-  fprintf(output,"\nThe original predicate:\n\n");\r
-  MR_dumpPred1(1,origPred,1);\r
-  fprintf(output,"The new (modified) form of the predicate:\n\n");\r
-  MR_dumpPred1(1,newPred,1);\r
-  fprintf(output,"#endif\n");\r
-}\r
-\r
-/* don't use Pass3 by itself unless you know that inverted is not important */\r
-\r
-#ifdef __USE_PROTOS\r
-Predicate * MR_removeRedundantPredPass3(Predicate *p)\r
-#else\r
-Predicate * MR_removeRedundantPredPass3(p)\r
-  Predicate *p;\r
-#endif\r
-{\r
-  Predicate     *q;\r
-\r
-  if (p == NULL) return NULL;\r
-  p->right=MR_removeRedundantPredPass3(p->right);\r
-  p->down=MR_removeRedundantPredPass3(p->down);\r
-  if (p->redundant) {\r
-    q=p->right;\r
-    p->right=NULL;\r
-    predicate_free(p);\r
-    return q;\r
-  };\r
-  if (p->expr == PRED_AND_LIST ||\r
-      p->expr == PRED_OR_LIST) {\r
-    if (p->down == NULL) {\r
-      q=p->right;\r
-      p->right=NULL;\r
-      predicate_free(p);\r
-      return q;\r
-    };\r
-    if (p->down != NULL && p->down->right == NULL) {\r
-      q=p->down;\r
-      q->right=p->right;\r
-      p->right=NULL;\r
-      p->down=NULL;\r
-      return q;\r
-    };\r
-  };\r
-  return p;\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-void MR_removeRedundantPredPass2(Predicate *p)\r
-#else\r
-void MR_removeRedundantPredPass2(p)\r
-  Predicate *p;\r
-#endif\r
-{\r
-  Predicate     *q;\r
-\r
-  if (p == NULL) return;\r
-\r
-  if (p->expr == PRED_AND_LIST) {\r
-    for (q=p->down ; q != NULL ; q=q->right) {\r
-      MR_removeRedundantPredPass2(q);\r
-      if (q->isConst) {\r
-        if (q->constValue == 0) {\r
-          p->isConst=1;\r
-          p->constValue=0;\r
-          return;\r
-        } else {\r
-          q->redundant=1;\r
-        };\r
-      };\r
-    };\r
-  };\r
-\r
-  if (p->expr == PRED_OR_LIST) {\r
-    for (q=p->down ; q != NULL ; q=q->right) {\r
-      MR_removeRedundantPredPass2(q);\r
-      if (q->isConst) {\r
-        if (q->constValue == 0) {\r
-          q->redundant=1;\r
-        } else {\r
-          p->isConst=1;\r
-          p->constValue=1;\r
-          return;\r
-        };\r
-      };\r
-    };\r
-  };\r
-\r
-  return;\r
-}\r
-\r
-#if 0\r
-   this totally ignores the implications of guarded predicates\r
-     in which the part after the guard could possibly cover a predicate.\r
-   that would be much harder:\r
-\r
-        rule : (A)? => <<p>>? sub1;     /* 1 */\r
-             | (B)? => <<r>>? sub2      /* 2 */\r
-        sub1 : (A)? => <<q>>? A B       /* 3 */\r
-             | B                        /* 4 - suppresses line 2 */\r
-             ;\r
-#endif\r
-\r
-#ifdef __USE_PROTOS\r
-void MR_apply_restriction1(Predicate *pred,set *plainSet,int *changed)\r
-#else\r
-void MR_apply_restriction1(pred,plainSet,changed)\r
-  Predicate     *pred;\r
-  set           *plainSet;\r
-  int           *changed;\r
-#endif\r
-{\r
-  if (pred == NULL) return;\r
-  MR_apply_restriction1(pred->right,plainSet,changed);\r
-  if (pred->down != NULL) {\r
-    MR_apply_restriction1(pred->down,plainSet,changed);\r
-  } else {\r
-    set     t;\r
-    if (pred->k == 1) {\r
-      t=set_dif(pred->scontext[1],*plainSet);\r
-      if (*changed == 0 &&\r
-          !set_equ(t,pred->scontext[1])) {\r
-        *changed=1;\r
-      };\r
-      if (set_nil(t)) {\r
-        pred->redundant=1;\r
-      };\r
-      set_free(pred->scontext[1]);\r
-      pred->scontext[1]=t;\r
-    };\r
-  };\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-void MR_orin_plainSet(Predicate *p,set plainSet)\r
-#else\r
-void MR_orin_plainSet(p,plainSet)\r
-  Predicate     *p;\r
-  set           plainSet;\r
-#endif\r
-{\r
-  if (p == NULL) return;\r
-  MR_orin_plainSet(p->down,plainSet);\r
-  MR_orin_plainSet(p->right,plainSet);\r
-  set_orin(&p->plainSet,plainSet);\r
-}\r
-\r
-Predicate   *PRED_SUPPRESS;\r
-\r
-#ifdef __USE_PROTOS\r
-Predicate * MR_find_in_aSubBlk(Junction *alt)\r
-#else\r
-Predicate * MR_find_in_aSubBlk(alt)\r
-  Junction  *alt;\r
-#endif\r
-{\r
-    Predicate       *root=NULL;\r
-    Predicate       **tail=NULL;\r
-\r
-       Junction        *p;\r
-\r
-    int             nAlts=0;\r
-    Junction        **jList;\r
-    Predicate       **predList;\r
-    int             *matchList;\r
-    set             predSet;\r
-    int             i;\r
-    int             j;\r
-    int             m;\r
-    int             predDepth;\r
-    set             incomplete;\r
-    set             union_plainSet;\r
-    set             setChange;\r
-    int             changed;\r
-    Predicate       *newPred;\r
-    set             setDif;\r
-    Predicate       *origPred;\r
-    int             depth1=1;             /* const int */\r
-    set             *plainContext;\r
-    set             plainSet;\r
-\r
-    predSet=empty;\r
-    incomplete=empty;\r
-    union_plainSet=empty;\r
-    setChange=empty;\r
-    setDif=empty;\r
-    plainSet=empty;\r
-\r
-    if (PRED_SUPPRESS == NULL) {\r
-      PRED_SUPPRESS=new_pred();\r
-      PRED_SUPPRESS->expr="Predicate Suppressed";\r
-    };\r
-\r
-    /* this section just counts the number of "interesting" alternatives  */\r
-    /*   in order to allocate arrays                                      */\r
-\r
-       for (p=alt; p!=NULL; p=(Junction *)p->p2) {\r
-         /* ignore empty alts */\r
-         if ( p->p1->ntype != nJunction ||\r
-               ((Junction *)p->p1)->jtype != EndBlk )  {\r
-        nAlts++;\r
-      };\r
-    };\r
-\r
-    /* if this is a (...)+ block then don't count the last alt because\r
-       it can't be taken until at least one time through the block.\r
-       In other words it isn't a real choice until the (...)+ is entered\r
-         at which point the hoisting issue is moot.\r
-       Maybe look at "ignore" instead ?\r
-    */\r
-\r
-    if (alt->jtype == aPlusBlk) {\r
-      nAlts--;\r
-    };\r
-\r
-    jList=(Junction **)calloc(nAlts,sizeof(Junction *));\r
-    require(jList!=NULL,"cannot allocate MR_find_in_aSubBlk jList");\r
-\r
-    plainContext=(set *)calloc(nAlts,sizeof(set));\r
-    require(plainContext!=NULL,"cannot allocate MR_find_in_aSubBlk plainContext");\r
-    for (m=0; m < nAlts; m++) plainContext[m]=empty;\r
-\r
-    predList=(Predicate **)calloc(nAlts,sizeof(Predicate *));\r
-    require(predList!=NULL,"cannot allocate MR_find_in_aSubBlk predList");\r
-\r
-    matchList=(int *)calloc(nAlts,sizeof(int));\r
-    require(matchList!=NULL,"cannot allocate MR_find_in_aSubBlk matchList");\r
-\r
-    /* this section just fills in the arrays previously allocated       */\r
-    /* the most interesting one is matchList[]                          */\r
-    /*                                                                  */\r
-    /*   bit 0 => this alt has a semantic pred which is "covered"       */\r
-    /*              by an alt without a semantic pred.  Don't hoist.    */\r
-\r
-       for (i=0,p=alt;\r
-         p!=NULL && i<nAlts;\r
-         i++,p=(Junction *)p->p2) {\r
-\r
-         /* ignore empty alts */\r
-\r
-         if ( p->p1->ntype != nJunction ||\r
-               ((Junction *)p->p1)->jtype != EndBlk )  {\r
-        jList[i]=MR_junctionWithoutP2(p);\r
-        predList[i]=find_predicates(p->p1);      /* should be jList ????? */\r
-        if (predList[i] != NULL) {\r
-          MR_cleanup_pred_trees(predList[i]);    /* flatten & left factor */\r
-          plainContext[i]=MR_union_plain_sets(predList[i]);\r
-        } else {\r
-          MR_set_reuse(&plainSet);\r
-          MR_set_reuse(&incomplete);\r
-          plainSet=MR_First(depth1,jList[i],&incomplete);\r
-          MR_complete_set(depth1,&plainSet,&incomplete);\r
-          require(set_nil(incomplete),"couldn't complete k=1");\r
-          plainContext[i]=plainSet;\r
-          plainSet=empty;\r
-        };\r
-        set_orin(&union_plainSet,plainContext[i]);\r
-      };\r
-    };\r
-\r
-    if (nAlts == 1) {\r
-      goto EXIT_SIMPLE;\r
-    };\r
-\r
-/*\r
- *  Looking for cases where alt i has a semantic pred and alt j does not.\r
- *  Don't care about cases where lookahead for semantic predicates overlap\r
- *    because normal predicate hoisting does the correct thing automatically.\r
- *  Don't care about cases where lookahead for alts without semantic predicates\r
- *    overlap because normal prediction does the correct thing automatically.\r
- *\r
- *  When we find such a case check for one of three subcases:\r
- *\r
- *      1.  if lookahead for alt i is contained in the lookahead for any\r
- *          alt j then ignore semantic predicate of alt i\r
- *      2.  if lookahead for alt i is not contained in the lookahead for\r
- *          any alt j then add add predicate i to the OR list to be hoisted\r
- *      3.  if lookahead for alt i overlaps the lookahead for some alt j then\r
- *          add a dummy semantic predicate for alt j\r
- *\r
- *  There is an implicit assumption that the context of all alternatives following\r
- *  the rule being processed here are identical (but may vary from hoist to\r
- *  hoist depending on the place where the rule was invoked that led to hoisting\r
- *  these predicates.  In othere words in the fragment:\r
- *\r
- *            ( <<a>>? a1 a2 a3 | <<b>>? b1 b2 b3 )\r
- *\r
- *  both a3 and b3 have the same follow sets  because they are both at the end of\r
- *  alternatives in the same block.\r
- */\r
-\r
-    for (i=0; i < nAlts; i++) {\r
-      if (jList[i] == NULL) continue;\r
-      if (predList[i] == NULL) continue;\r
-\r
-        /* if the predicate depth turns out to be one token only */\r
-        /*   then it is can be easily represented as a set and   */\r
-        /*   compared to the junction set create by MR_First()   */\r
-\r
-      predDepth=0;\r
-      MR_pred_depth(predList[i],&predDepth);\r
-      require (predDepth >= 1,"MR_find_in_aSubBlk: pred depth < 1");\r
-      require (predDepth <= CLL_k,"MR_find_in_aSubBlk: predDepth > CLL_k");\r
-\r
-        /* complete predicates to predDepth\r
-           If completed to depth=1 then the context would be incomplete.\r
-           The context would be truncated and the predicate simplify routine\r
-             would have incomplete information.  It would lead to\r
-             either false matches of failure to find true matches.\r
-        */\r
-\r
-      MR_complete_predicates(predDepth,predList[i]);\r
-\r
-      if (predList[i] != NULL) {\r
-        MR_cleanup_pred_trees(predList[i]);    /* flatten & left factor */\r
-      };\r
-\r
-      /* If the predicate depth is 1 then it is possible to suppress\r
-           a predicate completely using a single plain alt.  Check for suppression\r
-           by a single plain alt first because it gives better messages.  If that\r
-           fails try the union of all the plain alts.\r
-      */\r
-\r
-      if (predDepth == 1) {\r
-\r
-        MR_set_reuse(&predSet);\r
-        predSet=MR_compute_pred_set(predList[i]);   /* ignores k>1 predicates */\r
-\r
-        for (j=0; j < nAlts; j++) {\r
-          if (jList[j] == NULL) continue;\r
-          if (j == i) continue;\r
-\r
-          MR_set_reuse(&setDif);\r
-          setDif=set_dif(predSet,plainContext[j]);\r
-          if (set_nil(setDif)) {\r
-            matchList[i] |= 1;\r
-            MR_reportSetSuppression(predDepth,predSet,plainContext[j],jList[i],jList[j],predList[i]);\r
-            predicate_free(predList[i]);\r
-            predList[i]=PRED_SUPPRESS;\r
-            goto next_i;\r
-          };\r
-\r
-        }; /* end loop on j */\r
-\r
-        changed=0;\r
-\r
-        /* predicate_dup is only to give good error messages */\r
-        /* remember to do a predicate_free()                 */\r
-\r
-        origPred=predicate_dup(predList[i]);\r
-        MR_apply_restriction1(predList[i],&union_plainSet,&changed);\r
-        if (changed) {\r
-\r
-          /* don't use Pass3 by itself unless you know that inverted is not important */\r
-\r
-          newPred=MR_removeRedundantPredPass3(predList[i]);\r
-          newPred=MR_predSimplifyALL(newPred);\r
-          if (newPred == NULL) {\r
-            matchList[i] |= 1;\r
-            MR_reportSetSuppression(predDepth,predSet,union_plainSet,jList[i],\r
-                                                            NULL,origPred);\r
-            predList[i]=PRED_SUPPRESS;\r
-          } else {\r
-            MR_reportSetRestriction(predDepth,predSet,union_plainSet,jList[i],\r
-                                                    NULL,origPred,newPred);\r
-            predList[i]=newPred;\r
-          };\r
-        };\r
-        predicate_free(origPred);\r
-        origPred=NULL;\r
-      };\r
-\r
-      /*\r
-         If the predicate depth is > 1 then it can't be suppressed completely\r
-           because the code doesn't support inspection of such things.  They're\r
-           much messier than k=1 sets.\r
-      */\r
-\r
-      if (predDepth > 1 ) {\r
-\r
-        changed=0;\r
-\r
-        /* predicate_dup is only to give good error messages */\r
-        /* remember to do a predicate_free()                 */\r
-\r
-        origPred=predicate_dup(predList[i]);\r
-        MR_apply_restriction1(predList[i],&union_plainSet,&changed);\r
-        if (changed) {\r
-          newPred=MR_removeRedundantPredPass3(predList[i]);\r
-          newPred=MR_predSimplifyALL(newPred);\r
-          if (newPred == NULL) {\r
-            matchList[i] |= 1;\r
-            MR_reportSetSuppression(predDepth,predSet,union_plainSet,jList[i],\r
-                                                            NULL,origPred);\r
-            predList[i]=PRED_SUPPRESS;\r
-          } else {\r
-            MR_reportSetRestriction(predDepth,predSet,union_plainSet,jList[i],\r
-                                                    NULL,origPred,newPred);\r
-            predList[i]=newPred;\r
-          };\r
-        };\r
-        predicate_free(origPred);\r
-        origPred=NULL;\r
-      };\r
-next_i:\r
-      continue;\r
-    };\r
-\r
-EXIT_SIMPLE:\r
-\r
-    root = new_pred();\r
-    root->expr=PRED_OR_LIST;\r
-    tail = &(root->down);\r
-\r
-    for (i=0 ; i< nAlts ; i++) {\r
-      if (jList[i] == NULL) continue;\r
-\r
-      if (predList[i] == NULL) {\r
-        continue;\r
-      } else if ( (matchList[i] & 1) != 0) {\r
-        if (predList[i] != PRED_SUPPRESS) {\r
-          predicate_free(predList[i]);\r
-        };\r
-        continue;\r
-      };\r
-\r
-      /* make an OR list of predicates */\r
-\r
-      *tail=predList[i];\r
-      tail=&(predList[i]->right);\r
-    };\r
-\r
-       /* if just one pred, remove OR root */\r
-\r
-       if (root->down == NULL) {\r
-      predicate_free(root);\r
-      root=NULL;\r
-    } else if (root->down->right == NULL) {\r
-      Predicate     *p=root->down;\r
-      root->down=NULL;\r
-      predicate_free(root);\r
-      root=p;\r
-       }\r
-\r
-    root=MR_predSimplifyALL(root);\r
-\r
-    MR_orin_plainSet(root,union_plainSet);\r
-\r
-    set_free(predSet);\r
-    set_free(union_plainSet);\r
-    set_free(incomplete);\r
-    set_free(setChange);\r
-    set_free(setDif);\r
-\r
-    for (m=0; m < nAlts; m++) set_free(plainContext[m]);\r
-\r
-    free ( (char *) jList);\r
-    free ( (char *) predList);\r
-    free ( (char *) matchList);\r
-    free ( (char *) plainContext);\r
-\r
-       return root;\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-void MR_predContextPresent(Predicate *p,int *allHaveContext,int *noneHaveContext)\r
-#else\r
-void MR_predContextPresent(p,allHaveContext,noneHaveContext)\r
-  Predicate     *p;\r
-  int           *allHaveContext;\r
-  int           *noneHaveContext;\r
-#endif\r
-{\r
-  if (p == NULL) return;\r
-  MR_predContextPresent(p->right,allHaveContext,noneHaveContext);\r
-  if (p->expr != PRED_AND_LIST &&\r
-      p->expr != PRED_OR_LIST) {\r
-    if (set_nil(p->scontext[1]) == 0 ||\r
-            (p->tcontext != NULL)) {\r
-      *noneHaveContext=0;\r
-    } else {\r
-      *allHaveContext=0;\r
-    };\r
-  };\r
-  MR_predContextPresent(p->down,allHaveContext,noneHaveContext);\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-int MR_pointerStackPush(PointerStack *ps,void *dataPointer)\r
-#else\r
-int MR_pointerStackPush(ps,dataPointer)\r
-  PointerStack  *ps;\r
-  void          *dataPointer;\r
-#endif\r
-{\r
-  void             **newStack;\r
-  int              newSize;\r
-  int              i;\r
-\r
-  if (ps->count == ps->size) {\r
-    newSize=20+ps->size*2;\r
-    newStack=(void **)calloc(newSize,sizeof(void *));\r
-    require (newStack != NULL,"cannot allocate PointerStack");\r
-    for (i=0; i < ps->size; i++) {\r
-      newStack[i]=ps->data[i];\r
-    };\r
-    if (ps->data != NULL) free( (char *) ps->data);\r
-    ps->data=newStack;\r
-    ps->size=newSize;\r
-  };\r
-  ps->data[ps->count]=dataPointer;\r
-  ps->count++;\r
-  return ps->count-1;\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-void * MR_pointerStackPop(PointerStack *ps)\r
-#else\r
-void * MR_pointerStackPop(ps)\r
-  PointerStack  *ps;\r
-#endif\r
-{\r
-  void  *dataPointer;\r
-\r
-  require(ps->count > 0,"MR_pointerStackPop underflow");\r
-\r
-  dataPointer=ps->data[ps->count-1];\r
-  ps->data[ps->count-1]=NULL;\r
-  (ps->count)--;\r
-  return dataPointer;\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-void * MR_pointerStackTop(PointerStack *ps)\r
-#else\r
-void * MR_pointerStackTop(ps)\r
-  PointerStack  *ps;\r
-#endif\r
-{\r
-  require(ps->count > 0,"MR_pointerStackTop underflow");\r
-  return ps->data[ps->count-1];\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-void MR_pointerStackReset(PointerStack *ps)\r
-#else\r
-void MR_pointerStackReset(ps)\r
-  PointerStack  *ps;\r
-#endif\r
-{\r
-  int i;\r
-  if (ps->data != NULL) {\r
-    for (i=0; i < ps->count ; i++) {\r
-       ps->data[i]=NULL;\r
-    };\r
-  };\r
-  ps->count=0;\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-Junction *MR_nameToRuleBlk(char *name)\r
-#else\r
-Junction *MR_nameToRuleBlk(name)\r
-  char  *name;\r
-#endif\r
-{\r
-    RuleEntry *q;\r
-\r
-    require (RulePtr != NULL,"MR_nameToRule: RulePtr not initialized");\r
-\r
-    if (name == NULL) return NULL;\r
-\r
-    q = (RuleEntry *) hash_get(Rname,name);\r
-\r
-       if ( q == NULL ) {\r
-      return NULL;\r
-    } else {\r
-      return RulePtr[q->rulenum];\r
-    };\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-Junction * MR_ruleReferenced(RuleRefNode *rrn)\r
-#else\r
-Junction * MR_ruleReferenced(rrn)\r
-  RuleRefNode   *rrn;\r
-#endif\r
-{\r
-    return MR_nameToRuleBlk(rrn->text);\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-void MR_comparePredLeaves(Predicate *me,Predicate *myParent,Predicate *him,Predicate *hisParent)\r
-#else\r
-void MR_comparePredLeaves(me,myParent,him,hisParent)\r
-    Predicate *me;\r
-    Predicate *myParent;\r
-    Predicate *him;\r
-    Predicate *hisParent;\r
-#endif\r
-{\r
-    if (me == NULL) return;\r
-    if (me == him) {\r
-      MR_comparePredLeaves(me->right,myParent,him,hisParent);\r
-      return;\r
-    } else if (me->expr == PRED_AND_LIST ||\r
-               me->expr == PRED_OR_LIST) {\r
-      MR_comparePredLeaves(me->down,me,him,hisParent);\r
-      MR_comparePredLeaves(me->right,myParent,him,hisParent);\r
-      return;\r
-    } else {\r
-      if (me->source != NULL) {\r
-\r
-        /* predicate->invert can be set only in the predEntry predicates        */\r
-        /* thus they are only visible after the predEntry predicates have been "unfolded" */\r
-\r
-        int     sameSource=(me->source == him->source);\r
-        int     sameInvert=1 &\r
-                 (1 + me->inverted + him->inverted + me->source->inverted + him->source->inverted);\r
-        int     samePredEntry=(me->source->predEntry != NULL\r
-                                 && him->source->predEntry != NULL\r
-                                    && me->source->predEntry == him->source->predEntry);\r
-        if (sameInvert && (sameSource || samePredEntry)) {\r
-          if (MR_identicalContext(me,him)) {\r
-\r
-            /* identical predicates */\r
-\r
-            if (hisParent->expr == PRED_OR_LIST &&\r
-                myParent->expr == PRED_OR_LIST) {\r
-              me->redundant=1;\r
-            } else if (hisParent->expr == PRED_AND_LIST &&\r
-                       myParent->expr == PRED_AND_LIST) {\r
-              me->redundant=1;\r
-            } else if (  (hisParent->expr == PRED_OR_LIST &&\r
-                          myParent->expr == PRED_AND_LIST)\r
-                       ||\r
-                         (hisParent->expr == PRED_AND_LIST &&\r
-                          myParent->expr == PRED_OR_LIST)\r
-                      ) {\r
-              myParent->redundant=1;\r
-            } else {\r
-              require (0,"MR_comparePredLeaves: not both PRED_LIST");\r
-            };\r
-          };\r
-        };  /* end same source or same predEntrr with same invert sense */\r
-\r
-        /* same predEntry but opposite invert sense */\r
-\r
-        if (!sameInvert && (sameSource || samePredEntry)) {\r
-          if (MR_identicalContext(me,him)) {\r
-            if (hisParent->expr == PRED_OR_LIST &&\r
-                myParent->expr == PRED_OR_LIST) {\r
-              myParent->isConst=1;\r
-              myParent->constValue=1;\r
-            } else if (hisParent->expr == PRED_AND_LIST &&\r
-                       myParent->expr == PRED_AND_LIST) {\r
-              myParent->isConst=1;\r
-              myParent->constValue=0;\r
-            } else if (  (hisParent->expr == PRED_OR_LIST &&\r
-                          myParent->expr == PRED_AND_LIST)\r
-                       ||\r
-                         (hisParent->expr == PRED_AND_LIST &&\r
-                          myParent->expr == PRED_OR_LIST)\r
-                      ) {\r
-              me->redundant=1;\r
-            } else {\r
-              require (0,"MR_comparePredLeaves: not both PRED_LIST");\r
-            };\r
-          };\r
-        };  /* end same predEntry with opposite invert sense */\r
-      };\r
-\r
-      MR_comparePredLeaves(me->right,myParent,him,hisParent);\r
-      return;\r
-    };\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-void MR_removeRedundantPredPass1(Predicate *me,Predicate *myParent)\r
-#else\r
-void MR_removeRedundantPredPass1(me,myParent)\r
-  Predicate     *me;\r
-  Predicate     *myParent;\r
-#endif\r
-{\r
-    if (me == NULL) return;\r
-    if (me->redundant) {\r
-      MR_removeRedundantPredPass1(me->right,myParent);\r
-      return;\r
-    };\r
-    if (me->expr == PRED_AND_LIST ||\r
-        me->expr == PRED_OR_LIST) {\r
-      MR_removeRedundantPredPass1(me->down,me);\r
-      MR_removeRedundantPredPass1(me->right,myParent);\r
-    } else {\r
-      require (me->source != NULL,"me->source == NULL");\r
-      if (myParent != NULL) {\r
-        MR_comparePredLeaves(myParent->down,myParent,me,myParent);\r
-      };\r
-      MR_removeRedundantPredPass1(me->right,myParent);\r
-    };\r
-}\r
-\r
-/* pretty much ignores things with the inverted bit set */\r
-\r
-#ifdef __USE_PROTOS\r
-Predicate *MR_predFlatten(Predicate *p)\r
-#else\r
-Predicate *MR_predFlatten(p)\r
-  Predicate     *p;\r
-#endif\r
-{\r
-    if (p == NULL) return NULL;\r
-    if (p->expr == PRED_OR_LIST\r
-        || p->expr == PRED_AND_LIST) {\r
-\r
-      Predicate     *child;\r
-      Predicate     *gchild;\r
-      Predicate     **tail;\r
-      Predicate     *next;\r
-      char          *PRED_XXX_LIST=p->expr;\r
-\r
-      require (p->down != NULL,"MR_predFlatten AND/OR no child");\r
-\r
-\r
-      p->down=MR_predFlatten(p->down);\r
-      p->right=MR_predFlatten(p->right);\r
-      child=p->down;\r
-      if (child->right == NULL) {\r
-        child->right=p->right;\r
-        p->right=NULL;\r
-        p->down=NULL;\r
-        if (p->inverted) child->inverted=!child->inverted;\r
-        predicate_free(p);\r
-        return child;\r
-      };\r
-\r
-      /* make a single list of all children and grandchildren */\r
-\r
-      tail=&(p->down);\r
-      for (child=p->down; child != NULL; child=next) {\r
-        if (child->expr != PRED_XXX_LIST\r
-              || child->inverted\r
-                || child->predEntry != NULL) {\r
-          *tail=child;\r
-          tail=&(child->right);\r
-          next=child->right;\r
-        } else {\r
-          for (gchild=child->down;\r
-               gchild != NULL;\r
-               gchild=gchild->right) {\r
-            *tail=gchild;\r
-            tail=&(gchild->right);\r
-          };\r
-          next=child->right;\r
-          child->right=NULL;\r
-          child->down=NULL;\r
-          predicate_free(child);\r
-        };\r
-      };\r
-      *tail=NULL;\r
-      return p;\r
-    } else {\r
-      p->right=MR_predFlatten(p->right);\r
-      return p;\r
-    };\r
-}\r
-\r
-static char *alwaysFalseWarning=NULL;\r
-\r
-#ifdef __USE_PROTOS\r
-Predicate *checkPredicateConflict(Predicate *p)\r
-#else\r
-Predicate *checkPredicateConflict(p)\r
-  Predicate     *p;\r
-#endif\r
-{\r
-  if (p->isConst) {\r
-    if (p->constValue == 1) {\r
-      predicate_free(p);\r
-      return NULL;\r
-    } else {\r
-      if (InfoP && !p->conflictReported) {\r
-        p->conflictReported=1;\r
-        fprintf(output,"\n#if 0\n\n");\r
-        fprintf(output,"The following predicate expression will always be false:\n\n");\r
-        MR_dumpPred1(1,p,1);\r
-        fprintf(output,"\n#endif\n");\r
-      };\r
-\r
-      if (alwaysFalseWarning != CurRule) {\r
-        alwaysFalseWarning=CurRule;\r
-        if (InfoP) {\r
-          warnNoFL(eMsg1("one (or more) predicate expression hoisted into rule \"%s\" are always false \\r
-- see output file for more information",CurRule));\r
-        } else {\r
-          warnNoFL(eMsg1("one (or more) predicate expressions hoisted into rule \"%s\" are always false \\r
-- use \"-info p\" for more information",CurRule));\r
-        };\r
-      };\r
-    };\r
-  };\r
-  return p;\r
-}\r
-\r
-\r
-#ifdef __USE_PROTOS\r
-int MR_countPredNodes(Predicate *p)\r
-#else\r
-int MR_countPredNodes(p)\r
-  Predicate     *p;\r
-#endif\r
-{\r
-  if (p == NULL) return 0;\r
-  return 1 + MR_countPredNodes(p->down) + MR_countPredNodes(p->right);\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-Predicate *MR_predSimplifyALLX(Predicate *p,int skipPass3)\r
-#else\r
-Predicate *MR_predSimplifyALLX(p,skipPass3)\r
-  Predicate     *p;\r
-  int           skipPass3;\r
-#endif\r
-{\r
-  int       countBefore;\r
-  int       countAfter;\r
-\r
-  countAfter=MR_countPredNodes(p);\r
-\r
-  do {\r
-      if (p == NULL) return NULL;\r
-      if (p->right == NULL && p->down == NULL) return p;\r
-      countBefore=countAfter;\r
-      MR_simplifyInverted(p,0);\r
-      p=MR_predFlatten(p);\r
-      MR_removeRedundantPredPass1(p,NULL);\r
-      MR_removeRedundantPredPass2(p);\r
-      if (! skipPass3) {\r
-        p=checkPredicateConflict(p);\r
-        p=MR_removeRedundantPredPass3(p);\r
-      };\r
-      countAfter=MR_countPredNodes(p);\r
-  } while (countBefore != countAfter);\r
-\r
-  return p;\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-Predicate *MR_predSimplifyALL(Predicate *p)\r
-#else\r
-Predicate *MR_predSimplifyALL(p)\r
-  Predicate     *p;\r
-#endif\r
-{\r
-  return MR_predSimplifyALLX(p,0);\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-void MR_releaseResourcesUsedInRule(Node *n)\r
-#else\r
-void MR_releaseResourcesUsedInRule(n)\r
-  Node  *n;\r
-#endif\r
-{\r
-   Node         *next;\r
-   Junction     *j;\r
-   int          i;\r
-\r
-   if (n == NULL) return;\r
-   if (n->ntype == nJunction) {\r
-     j=(Junction *) n;\r
-\r
-     if (j->predicate != NULL) {\r
-       predicate_free(j->predicate);\r
-       j->predicate=NULL;\r
-     };\r
-     for (i=0; i< CLL_k; i++) {\r
-       set_free(j->fset[i]);\r
-       j->fset[i]=empty;\r
-     };\r
-     if (j->ftree != NULL) {\r
-       Tfree(j->ftree);\r
-       j->ftree=NULL;\r
-     };\r
-     if (j->jtype == EndRule) return;\r
-     if (j->jtype != RuleBlk && j->jtype != EndBlk) {\r
-       if (j->p2 != NULL && !j->ignore) {   /* MR11 */\r
-          MR_releaseResourcesUsedInRule(j->p2);\r
-       };\r
-     };\r
-   };\r
-   next=MR_advance(n);\r
-   MR_releaseResourcesUsedInRule(next);\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-int MR_allPredLeaves(Predicate *p)\r
-#else\r
-int MR_allPredLeaves(p)\r
-  Predicate *p;\r
-#endif\r
-{\r
-  Predicate     *q;\r
-\r
-  if (p == NULL) return 1;\r
-\r
-  for (q=p; q != NULL; q=q->right) {\r
-   if (q->down != NULL) return 0;\r
-  };\r
-  return 1;\r
-}\r
-\r
-/* make sure it works for the last rule in a file */\r
-\r
-#ifdef __USE_PROTOS\r
-int MR_offsetFromRule(Node *n)\r
-#else\r
-int MR_offsetFromRule(n)\r
-  Node      *n;\r
-#endif\r
-{\r
-  Junction  *j;\r
-  int       offset=(-1);\r
-\r
-  for (j=SynDiag; j != NULL; j=(Junction *)j->p2) {\r
-\r
-    require (j->ntype == nJunction && j->jtype == RuleBlk,"Not a rule block");\r
-\r
-    if (n->file < j->file) {\r
-      return offset;\r
-    };\r
-    if (n->file == j->file) {\r
-      if (n->line < j->line) {\r
-        return (offset < 0) ? 0 : offset;\r
-      } else {\r
-        offset=n->line - j->line;\r
-        if (offset == 0) return 0;\r
-      };\r
-    };\r
-  };\r
-  return offset;\r
-}\r
-\r
-#define ruleNameMax 50\r
-\r
-static char ruleNameStatic1[ruleNameMax];\r
-static char ruleNameStatic2[ruleNameMax+10];\r
-\r
-#ifdef __USE_PROTOS\r
-char * MR_ruleNamePlusOffset(Node *n)\r
-#else\r
-char * MR_ruleNamePlusOffset(n)\r
-  Node      *n;\r
-#endif\r
-{\r
-    int     offset=MR_offsetFromRule(n);\r
-\r
-    strncpy(ruleNameStatic1,n->rname,ruleNameMax);\r
-    if (offset < 0) {\r
-      sprintf(ruleNameStatic2,"%s/?",ruleNameStatic1);\r
-    } else {\r
-      sprintf(ruleNameStatic2,"%s/%d",ruleNameStatic1,offset+1);\r
-    };\r
-    return ruleNameStatic2;\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-int MR_max_height_of_tree(Tree *t)\r
-#else\r
-int MR_max_height_of_tree(t)\r
-  Tree  *t;\r
-#endif\r
-{\r
-  int       h;\r
-  int       height=0;\r
-  Tree      *u;\r
-\r
-  if (t == NULL) return 0;\r
-\r
-  require (t->token != ALT && t->token != EpToken,"MR_max_height_of_tree ALT or EpToken");\r
-\r
-  for (u=t; u != NULL; u=u->right) {\r
-    h=MR_max_height_of_tree(u->down)+1;\r
-    if (h > height) height=h;\r
-  };\r
-  return height;\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-int MR_all_leaves_same_height(Tree *t,int depth)\r
-#else\r
-int MR_all_leaves_same_height(t,depth)\r
-  Tree  *t;\r
-  int   depth;\r
-#endif\r
-{\r
-  if (t == NULL) {\r
-    return (depth==0);\r
-  };\r
-\r
-  require (t->token != ALT && t->token != EpToken,"MR_all_leaves_same_height ALT or EpToken");\r
-\r
-  if (depth == 0) {\r
-    return 0;\r
-  } else {\r
-    if ( ! MR_all_leaves_same_height(t->down,depth-1)) {\r
-      return 0;\r
-    };\r
-    if (t->right == NULL) {\r
-      return 1;\r
-    } else {\r
-      return MR_all_leaves_same_height(t->right,depth);\r
-    };\r
-  };\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-void MR_projectTreeOntoSet(Tree *tree,int ck,set *ckset)\r
-#else\r
-void MR_projectTreeOntoSet(tree,ck,ckset)\r
-  Tree  *tree;\r
-  int   ck;\r
-  set   *ckset;\r
-#endif\r
-{\r
-    if (tree == NULL) return;\r
-\r
-    require(tree->token != EpToken,"MR_projectTreeOntoSet: EpToken unexpected\n");\r
-\r
-    MR_projectTreeOntoSet(tree->right,ck,ckset);\r
-    if (tree->token == ALT) {\r
-      MR_projectTreeOntoSet(tree->down,ck,ckset);\r
-    } else {\r
-      if (ck > 1) {\r
-        MR_projectTreeOntoSet(tree->down,ck-1,ckset);\r
-      } else {\r
-        set_orel(tree->token,ckset);\r
-      };\r
-    };\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-int MR_comparePredicates(Predicate *a,Predicate *b)\r
-#else\r
-int MR_comparePredicates(a,b)\r
-  Predicate     *a;\r
-  Predicate     *b;\r
-#endif\r
-{\r
-  Predicate     *p;\r
-  Predicate     *q;\r
-\r
-  if (a == b) return 1;\r
-  if (a == NULL || b == NULL ) return 0;\r
-  if (a->down == NULL && b->down == NULL) {\r
-\r
-    /* predicate->invert can be set only in the predEntry predicates                  */\r
-    /* thus they are only visible after the predEntry predicates have been "unfolded" */\r
-\r
-    int     sameSource=(a->source == b->source);\r
-    int     sameInvert= 1 & (1 +a->inverted + b->inverted +\r
-                                a->source->inverted + b->source->inverted);\r
-    int     samePredEntry=(a->source->predEntry != NULL\r
-                                 && b->source->predEntry != NULL\r
-                                    && a->source->predEntry == b->source->predEntry);\r
-    if (sameInvert && (sameSource || samePredEntry)) {\r
-      if (MR_identicalContext(a,b)) {\r
-         return 1;\r
-      };\r
-    };\r
-    return 0;\r
-  };\r
-  if (a->down == NULL || b->down == NULL) return 0;\r
-  if (a->expr != b->expr) return 0;\r
-\r
-  for (p=a->down; p != NULL; p=p->right) {\r
-    for (q=b->down; q != NULL; q=q->right) {\r
-      if (MR_comparePredicates(p,q)) goto NEXT_P;\r
-    };\r
-    return 0;\r
-NEXT_P:\r
-    continue;\r
-  };\r
-  return 1;\r
-}\r
-\r
-/*\r
- *  action->inverted can be set only when a predicate symbol appears in\r
- *      a rule:  "rule : <<!XXX>>? X".  It cannot be set under any\r
- *      other circumstances.  In particular it cannot be set by\r
- *      "#pred NotA !A" or by "#pred Nota <<!A>>?".  The first case\r
- *      creates a predEntry and the predicate expression of that predEntry\r
- *      has inverted set.  In the second case, the code for handling "!"\r
- *      is only present in buildAction, which is not called by the #pred\r
- *      semantic routines, only when a <<...>>? is recognized as part of\r
- *      a rule definition.\r
- *\r
- *  predicate->inverted can only be set by a predicate created by a #pred\r
- *      expression, such as "#pred NotA !A" or "#pred NotXY ! (X && Y) or\r
- *      "#pred XbarY !(X && Y)".  In particular, it cannot be set by any\r
- *      predicate expression occurring under any other circumstances.\r
- *      The #pred predicate expresssions are stored with in predEntry->pred\r
- *      and do not normally appear anywhere else until the predicates are\r
- *      "unfolded" in order to recognize redundancies, conflicts, and\r
- *      tautologies.\r
- *\r
- *  The unfold routine expands all references to #pred expressions.\r
- *\r
- *  The simplifyInvert goes through and propagates the invert bit so that\r
- *      all OR and AND nodes are un-inverted.\r
- *\r
- *  Note that !(A and B) => (!A or !B)\r
- *            !(A or B)  => (!A and !B)\r
- *\r
- *  MR_unfold() is called to expand predicate symbols by replacing predicates\r
- *    that reference predicate entries with the copies of the predicate entries.\r
- *    Each reference receives a duplicate of the original.  This is necessary\r
- *    because the next phase involves simplification and removal of redundant\r
- *    predicate nodes.  Anyway, the point I'm making is that predicate->invert\r
- *    should not be set in any predicate until it has been expanded.\r
- *\r
- *    This is a recursive structure, but there is no need for "recursive expansion"\r
- *    by which I mean a predicate symbol refers to other predicate symbols which\r
- *    must also be expanded.\r
- *\r
- *    Recursive expansion is *not* performed by this routine because it is not\r
- *    necessary.  Expansion of references is performed by predPrimary when\r
- *    a new predicate symbol is created by referring to others in the pred expr.\r
- */\r
-\r
-#ifdef __USE_PROTOS\r
-Predicate *MR_unfold(Predicate *pred)\r
-#else\r
-Predicate *MR_unfold(pred)\r
-  Predicate     *pred;\r
-#endif\r
-{\r
-  Predicate     *result;\r
-\r
-  if (pred == NULL) return NULL;\r
-\r
-  pred->right=MR_unfold(pred->right);\r
-\r
-  if (pred->down == NULL) {\r
-    if (pred->source->predEntry != NULL) {\r
-      if (pred->source->predEntry->pred == NULL) {\r
-        ; /* do nothing */ /* a reference to a literal #pred (perhaps with "!" */\r
-      } else {\r
-        result=predicate_dup_without_context(pred->source->predEntry->pred);\r
-        if (pred->inverted) {\r
-          result->inverted=!result->inverted;\r
-        };\r
-        if (pred->source->inverted) {\r
-          result->inverted=!result->inverted;\r
-        };\r
-        result->right=pred->right;\r
-        pred->right=NULL;\r
-        predicate_free(pred);\r
-/***    result=MR_unfold(result); *** not necessary */    /* recursive expansion */\r
-        return result;\r
-      };\r
-    } else {\r
-      ; /* do nothing */ /* an inline literal predicate */\r
-    };\r
-  } else {\r
-    pred->down=MR_unfold(pred->down);\r
-  };\r
-  return pred;\r
-}\r
-\r
-/* this should be called immediately after MR_unfold() and\r
-   at no other times\r
-*/\r
-\r
-#ifdef __USE_PROTOS\r
-void MR_simplifyInverted(Predicate *pred,int inverted)\r
-#else\r
-void MR_simplifyInverted(pred,inverted)\r
-  Predicate     *pred;\r
-  int           inverted;\r
-#endif\r
-{\r
-  int       newInverted;\r
-\r
-  if (pred == NULL) return;\r
-\r
-  MR_simplifyInverted(pred->right,inverted);\r
-\r
-  newInverted= 1 & (inverted + pred->inverted);\r
-\r
-  if (pred->down == NULL) {\r
-    pred->inverted=newInverted;\r
-  } else {\r
-    if (newInverted != 0) {\r
-      if (pred->expr == PRED_AND_LIST) {\r
-        pred->expr=PRED_OR_LIST;\r
-      } else {\r
-        pred->expr=PRED_AND_LIST;\r
-      };\r
-    };\r
-    pred->inverted=0;\r
-    MR_simplifyInverted(pred->down,newInverted);\r
-  };\r
-}\r
-\r
-/* only remove it from AND and OR nodes, not leaves */\r
-\r
-#ifdef __USE_PROTOS\r
-void MR_clearPredEntry(Predicate *p)\r
-#else\r
-void MR_clearPredEntry(p)\r
-  Predicate     *p;\r
-#endif\r
-{\r
-   if (p == NULL) return;\r
-   MR_clearPredEntry(p->down);\r
-   MR_clearPredEntry(p->right);\r
-   if (p->down != NULL) p->predEntry=NULL;\r
-}\r
-\r
-\r
-#ifdef __USE_PROTOS\r
-void MR_orphanRules(FILE *f)\r
-#else\r
-void MR_orphanRules(f)\r
-  FILE      *f;\r
-#endif\r
-{\r
-       set         a;\r
-    Junction    *p;\r
-    unsigned    e;\r
-    RuleEntry   *re;\r
-\r
-       a=empty;\r
-\r
-    if (! InfoO) return;\r
-\r
-       for (p=SynDiag; p!=NULL; p = (Junction *)p->p2) {\r
-      if ( (Junction *) (p->end)->p1 == NULL) {\r
-        re=(RuleEntry *) hash_get(Rname,p->rname);\r
-        require (re != NULL,"RuleEntry == NULL");\r
-               set_orel(re->rulenum, &a);\r
-      }\r
-       }\r
-\r
-    if (set_deg(a) > 1) {\r
-      fprintf(f,"note: Start rules: {");\r
-      for (; !set_nil(a); set_rm(e,a)) {\r
-        e=set_int(a);\r
-        fprintf(f," %s",RulePtr[e]->rname);\r
-      };\r
-      fprintf(f," }\n");\r
-    };\r
-       set_free( a );\r
-}\r
-\r
-/*  merge (X Y) and (X) to create (X)  */\r
-\r
-static int      *mergeChain;\r
-static Tree     *mergeTree;\r
-\r
-#ifdef __USE_PROTOS\r
-Tree *MR_merge_tree_contexts_client(Tree *t,int chain[])\r
-#else\r
-Tree *MR_merge_tree_contexts_client(t,chain)\r
-  Tree  *t;\r
-  int   chain[];\r
-#endif\r
-{\r
-  if (t == NULL)  return NULL;\r
-  if (chain[0] == 0) {\r
-    Tree    *u=t->right;\r
-    t->right=NULL;\r
-    Tfree(t);\r
-    return MR_merge_tree_contexts_client(u,&chain[0]);\r
-  }\r
-  if (chain[0] == t->token) {\r
-    t->down=MR_merge_tree_contexts_client(t->down,&chain[1]);\r
-  };\r
-  t->right=MR_merge_tree_contexts_client(t->right,&chain[0]);\r
-  return t;\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-void MR_iterateOverTreeContexts(Tree *t,int chain[])\r
-#else\r
-void MR_iterateOverTreeContexts(t,chain)\r
-  Tree          *t;\r
-  int           chain[];\r
-#endif\r
-{\r
-  if (t == NULL) return;\r
-  chain[0]=t->token;\r
-  if (t->down != NULL) {\r
-    MR_iterateOverTreeContexts(t->down,&chain[1]);\r
-  } else {\r
-    MR_merge_tree_contexts_client(mergeTree,mergeChain);\r
-  };\r
-  MR_iterateOverTreeContexts(t->right,&chain[0]);\r
-  chain[0]=0;\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-Tree *MR_merge_tree_contexts(Tree *t)\r
-#else\r
-Tree *MR_merge_tree_contexts(t)\r
-  Tree  *t;\r
-#endif\r
-{\r
-    int     h=MR_max_height_of_tree(t);\r
-\r
-    mergeTree=t;\r
-    mergeChain=(int *) calloc(h+1,sizeof(int));\r
-    require (mergeChain != NULL,"MR_merge_tree_contexts: can't alloc chain");\r
-    MR_iterateOverTreeContexts(t,mergeChain);\r
-    t=tshrink(t);\r
-    t=tflatten(t);\r
-    t=tleft_factor(t);\r
-    free ( (char *) mergeChain);\r
-    mergeChain=NULL;\r
-    return t;\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-Tree *MR_compute_pred_tree_context(Predicate *p)\r
-#else\r
-Tree *MR_compute_pred_tree_context(p)\r
-  Predicate *p;\r
-#endif\r
-{\r
-  Tree  *t;\r
-\r
-  t=MR_compute_pred_tree_ctxXX(p);\r
-  MR_merge_tree_contexts(t);\r
-  return t;\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-void MR_guardPred_plainSet(ActionNode *anode,Predicate *pred)\r
-#else\r
-void MR_guardPred_plainSet(anode,pred)\r
-  ActionNode    *anode;\r
-  Predicate     *pred;\r
-#endif\r
-{\r
-  Junction      *j;\r
-  Predicate     *workPred;\r
-  set           maskSet;\r
-\r
-  maskSet=empty;\r
-\r
-  if (!MRhoisting) return;\r
-\r
-  /* it doesn't really matter whether the predicate has\r
-     depth k=1 or k>1 because we're not really looking\r
-     at the predicate itself, just the stuff "behind"\r
-     the predicate.\r
-  */\r
-\r
-  /* shouldn't have to worry about REACHing off the end\r
-     of the rule containing the predicate because the\r
-     Rule->end->halt should have been set already by the\r
-     the code which handles RuleRef nodes.\r
-\r
-     We don't want to REACH off the end of the rule because\r
-     this would give the "global" follow context rather than\r
-     the "local" context.\r
-\r
-         r1a : (A)? => <<p>>? r2 (A|B)\r
-         r1b : (A)? => <<p>>? r2 (A|C)\r
-         r2  : ();\r
-\r
-     For r1a we want follow of predicate = {A B}\r
-             we want plainSet = {B}\r
-     For r1b we want follow of predicate = {A C}\r
-             we want plainSet = {C}\r
-  */\r
-\r
-  require (anode->next->ntype == nJunction,"MR_guardpred_plainSet not Junction");\r
-  j=(Junction *)(anode->next);\r
-\r
-  workPred=predicate_dup_without_context(pred);\r
-  workPred->k=1;\r
-  workPred->scontext[1]=MR_First(1,j, &(workPred->completionSet) );\r
-  MR_complete_predicates(1,workPred);\r
-  if (pred->k == 1) {\r
-    maskSet=pred->scontext[1];\r
-  } else {\r
-    MR_projectTreeOntoSet(pred->tcontext,1,&maskSet);\r
-  }\r
-  pred->plainSet=set_dif(workPred->scontext[1],maskSet);\r
-  predicate_free(workPred);\r
-}\r
-\r
-/*******************************************************************************/\r
-\r
-static Tree *       suppressTree;\r
-static int *        suppressChain;  /* element 0 not used */\r
-static set *        suppressSets;\r
-static Node *       suppressNode;\r
-static int          suppressChainLength;\r
-int                 MR_SuppressSearch=0;\r
-static int          suppressSucceeded;\r
-static Predicate *  suppressPredicate;\r
-\r
-#ifdef __USE_PROTOS\r
-int MR_isChain(Tree *t)\r
-#else\r
-int MR_isChain(t)\r
-  Tree  *t;\r
-#endif\r
-{\r
-  Tree  *u;\r
-\r
-  for (u=t; u != NULL; u=u->down) {\r
-    if (u->right != NULL) return 0;\r
-  }\r
-  return 1;\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-int MR_suppressK_client(Tree *tree,int tokensInChain[])\r
-#else\r
-int MR_suppressK_client(tree,tokensInChain)\r
-  Tree      *tree;\r
-  int       tokensInChain[];\r
-#endif\r
-{\r
-  int       i;\r
-  set       *save_fset;\r
-  int       save_ConstrainSearch;\r
-  set       incomplete;\r
-  Tree      *t;\r
-\r
-  suppressSucceeded=0;  /* volatile */\r
-\r
-  if (suppressSets == NULL) {\r
-    suppressSets=(set *) calloc (CLL_k+1,sizeof(set));\r
-    require (suppressSets != NULL,"MR_suppressK_client: suppressSets alloc");\r
-  };\r
-\r
-  for (suppressChainLength=1;\r
-       tokensInChain[suppressChainLength+1] != 0;\r
-       suppressChainLength++) {};\r
-\r
-  require (suppressChainLength != 0,"MR_suppressK_client: chain empty");\r
-\r
-  for (i=1 ; i <= suppressChainLength ; i++) {\r
-    set_clr(suppressSets[i]);\r
-    set_orel( (unsigned) tokensInChain[i],\r
-                              &suppressSets[i]);\r
-  };\r
-\r
-  save_fset=fset;\r
-  save_ConstrainSearch=ConstrainSearch;\r
-\r
-  fset=suppressSets;\r
-\r
-  MR_SuppressSearch=1;\r
-  MR_AmbSourceSearch=1;\r
-  MR_MaintainBackTrace=1;\r
-  ConstrainSearch=1;\r
-\r
-  maxk = suppressChainLength;\r
-\r
-  incomplete=empty;\r
-  t=NULL;\r
-\r
-/***  constrain = &(fset[1]); ***/\r
-\r
-  MR_setConstrainPointer(&(fset[1]));  /* MR18 */\r
-  \r
-  MR_pointerStackReset(&MR_BackTraceStack);\r
-\r
-  TRAV(suppressNode,maxk,&incomplete,t);\r
-\r
-  Tfree(t);\r
-\r
-  require (set_nil(incomplete),"MR_suppressK_client TRAV incomplete");\r
-  require (MR_BackTraceStack.count == 0,\r
-            "MR_suppressK_client: MR_BackTraceStack.count != 0");\r
-  set_free(incomplete);\r
-\r
-  ConstrainSearch=save_ConstrainSearch;\r
-  fset=save_fset;\r
-\r
-  MR_AmbSourceSearch=0;\r
-  MR_MaintainBackTrace=0;\r
-  MR_SuppressSearch=0;\r
-  return suppressSucceeded;\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-Tree * MR_iterateOverTreeSuppressK(Tree *t,int chain[])\r
-#else\r
-Tree * MR_iterateOverTreeSuppressK(t,chain)\r
-  Tree          *t;\r
-  int           chain[];\r
-#endif\r
-{\r
-  if (t == NULL) return NULL;\r
-  t->right=MR_iterateOverTreeSuppressK(t->right,&chain[0]);\r
-  chain[0]=t->token;\r
-  if (t->down != NULL) {\r
-    t->down=MR_iterateOverTreeSuppressK(t->down,&chain[1]);\r
-    if (t->down == NULL) {\r
-      Tree *u=t->right;\r
-      t->right=NULL;\r
-      Tfree(t);\r
-      chain[0]=0;\r
-      return u;\r
-    };\r
-  } else {\r
-    MR_suppressK_client(suppressTree,suppressChain);\r
-    if (suppressSucceeded) {\r
-      Tree  *u=t->right;\r
-      t->right=NULL;\r
-      Tfree(t);\r
-      chain[0]=0;\r
-      return u;\r
-    };\r
-  };\r
-  chain[0]=0;\r
-  return t;\r
-}\r
-\r
-/* @@@ */\r
-\r
-#ifdef __USE_PROTOS\r
-Predicate * MR_suppressK(Node *j,Predicate *p)\r
-#else\r
-Predicate * MR_suppressK(j,p)\r
-  Node          *j;\r
-  Predicate     *p;\r
-#endif\r
-{\r
-  Predicate     *result;\r
-  int           guardPred=0;\r
-  int           ampersandPred=0;\r
-  Node          *nodePrime;\r
-\r
-  if (! MRhoistingk) {\r
-     return p;\r
-  }\r
-\r
-  if (! MRhoisting) return p;\r
-  if (CLL_k == 1) return p;\r
-\r
-  if (suppressChain == NULL) {\r
-    suppressChain=(int *) calloc(CLL_k+2,sizeof(int));\r
-    require (suppressChain != NULL,"MR_suppressK: can't allocate chain");\r
-  }\r
-\r
-  if (p == NULL) return NULL;\r
-\r
-  if (j->ntype == nJunction) {\r
-    nodePrime=(Node *) MR_junctionWithoutP2( (Junction *) j);\r
-  } else {\r
-    nodePrime=j;\r
-  };\r
-\r
-  p->down=MR_suppressK(j,p->down);\r
-  p->right=MR_suppressK(j,p->right);\r
-  if (p->down != NULL) {\r
-    result=p;\r
-    goto EXIT;\r
-  };\r
-  if (p->k == 1) {\r
-    result=p;\r
-    goto EXIT;\r
-  };\r
-\r
-  if (p->source != NULL) {\r
-    if (p->source->guardpred != NULL) guardPred=1;\r
-    if (p->source->ampersandPred != NULL) ampersandPred=1;\r
-  }\r
-\r
-  suppressPredicate=p;\r
-  suppressNode=nodePrime;   /* was j*/\r
-\r
-  suppressTree=p->tcontext;\r
-\r
-  if (guardPred || ampersandPred) {\r
-    p->tcontext=MR_iterateOverTreeSuppressK(suppressTree,&suppressChain[1]);\r
-    if (p->tcontext == NULL) {\r
-      predicate_free(p);\r
-      result=NULL;\r
-      goto EXIT;\r
-    };\r
-  } else {\r
-    if (MR_isChain(p->tcontext)) {\r
-      p->tcontext=MR_iterateOverTreeSuppressK(suppressTree,&suppressChain[1]);\r
-      if (p->tcontext == NULL) {\r
-        predicate_free(p);\r
-        result=NULL;\r
-        goto EXIT;\r
-      };\r
-    }\r
-  }\r
-  result=p;\r
-EXIT:\r
-  return result;\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-void MR_suppressSearchReport(void)\r
-#else\r
-void MR_suppressSearchReport()\r
-#endif\r
-{\r
-  int       i;\r
-  Node      *p;\r
-  TokNode   *tn;\r
-  int       depth;\r
-  set       setAnd;\r
-\r
-  /* number of tokens in back trace stack matches length of chain */\r
-\r
-  depth=0;\r
-  for (i=0; i < MR_BackTraceStack.count ; i++) {\r
-    p=(Node *) MR_BackTraceStack.data[i];\r
-    if (p->ntype == nToken) depth++;\r
-  };\r
-\r
-  require (depth == suppressChainLength,"depth > suppressChainLength");\r
-\r
-  /* token codes match chain */\r
-\r
-  depth=0;\r
-  for (i=0; i < MR_BackTraceStack.count ; i++) {\r
-    p=(Node *) MR_BackTraceStack.data[i];\r
-    if (p->ntype != nToken) continue;\r
-    tn=(TokNode *) p;\r
-    depth++;\r
-    if (set_nil(tn->tset)) {\r
-      require(set_el( (unsigned) tn->token,fset[depth]),\r
-        "MR_suppressSearchReport: no match to #token in chain");\r
-    } else {\r
-      setAnd=set_and(fset[depth],tn->tset);\r
-      require(!set_nil(setAnd),\r
-        "MR_suppressSearchReport: no match to #token set in chain");\r
-      set_free(setAnd);\r
-    };\r
-  };\r
-\r
-  /* have a match - now remove it from the predicate */\r
-\r
-  suppressSucceeded=1;\r
-\r
-  if (suppressSucceeded) {\r
-    fprintf(output,"\n");\r
-    fprintf(output,"#if 0\n");\r
-    fprintf(output,"\n");\r
-    fprintf(output,"Part (or all) of predicate with depth > 1 suppressed by ");\r
-        fprintf(output,"alternative without predicate\n\n");\r
-    MR_dumpPred(suppressPredicate,1);\r
-    fprintf(output,"The token sequence which is suppressed:");\r
-    fprintf(output," (");\r
-    for (i=1; i <= suppressChainLength; i++) {\r
-      fprintf(output," %s",TerminalString(suppressChain[i]));\r
-    };\r
-    fprintf(output," )\n");\r
-    fprintf(output,"The sequence of references which generate that sequence of tokens:\n\n");\r
-\r
-    MR_backTraceDumpItemReset();\r
-\r
-    for (i=0; i < MR_BackTraceStack.count ; i++) {\r
-       MR_backTraceDumpItem(output,0,(Node *) MR_BackTraceStack.data[i]);\r
-    };\r
-    fprintf(output,"\n");\r
-    fprintf(output,"#endif\n");\r
-  }\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-void MR_markCompromisedRule(Node *n)\r
-#else\r
-void MR_markCompromisedRule(n)\r
-  Node *n;\r
-#endif\r
-{\r
-  RuleEntry     *q;\r
-  Node          *mark=NULL;\r
-  Junction      *j;\r
-\r
-  if (n->ntype == nRuleRef) {\r
-    mark=(Node *) MR_ruleReferenced( (RuleRefNode *) n);\r
-  } else if (n->ntype == nToken) {\r
-    mark=n;\r
-  } else if (n->ntype == nJunction) {\r
-    j=(Junction *)n;\r
-    switch (j->jtype) {\r
-      case aOptBlk:\r
-      case aLoopBlk:\r
-      case RuleBlk:\r
-      case EndRule:\r
-      case aPlusBlk:\r
-      case aLoopBegin:\r
-        mark=n;\r
-        break;\r
-      default:\r
-        break;\r
-    };\r
-  }\r
-\r
-  if (mark == NULL) return;\r
-\r
-  require (RulePtr != NULL,"RulePtr not initialized");\r
-\r
-  q = (RuleEntry *) hash_get(Rname,mark->rname);\r
-  require (q != NULL,"RuleEntry not found");\r
-  set_orel(q->rulenum,&MR_CompromisedRules);\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-void MR_alphaBetaTraceReport(void)\r
-#else\r
-void MR_alphaBetaTraceReport()\r
-#endif\r
-{\r
-  int       i;\r
-\r
-  if (! AlphaBetaTrace) return;\r
-\r
-  MR_AlphaBetaMessageCount++;\r
-\r
-  fprintf(output,"\n");\r
-  fprintf(output,"#if 0\n");\r
-  fprintf(output,"\n");\r
-  fprintf(output,"Trace of references leading to attempt to compute the follow set of\n");\r
-  fprintf(output,"alpha in an \"(alpha)? beta\" block. It is not possible for antlr to\n");\r
-  fprintf(output,"compute this follow set because it is not known what part of beta has\n");\r
-  fprintf(output,"already been matched by alpha and what part remains to be matched.\n");\r
-  fprintf(output,"\n");\r
-  fprintf(output,"Rules which make use of the incorrect follow set will also be incorrect\n");\r
-  fprintf(output,"\n");\r
-\r
-  MR_backTraceDumpItemReset();\r
-\r
-  for (i=0; i < MR_BackTraceStack.count ; i++) {\r
-     MR_backTraceDumpItem(output,0,(Node *) MR_BackTraceStack.data[i]);\r
-     if (i < MR_BackTraceStack.count-1) {\r
-        MR_markCompromisedRule( (Node *) MR_BackTraceStack.data[i]);\r
-     };\r
-  };\r
-  fprintf(output,"\n");\r
-  fprintf(output,"#endif\n");\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-void MR_dumpRuleSet(set s)\r
-#else\r
-void MR_dumpRuleSet(s)\r
-  set   s;\r
-#endif\r
-{\r
-    unsigned    *cursor;\r
-    unsigned    *origin=set_pdq(s);\r
-\r
-    require(origin != NULL,"set_pdq failed");\r
-\r
-    if (RulePtr == NULL) {\r
-      fprintf(stderr,"RulePtr[] not yet initialized");\r
-    } else {\r
-      for (cursor=origin; *cursor != nil ; cursor++) {\r
-/****   if (cursor != origin) fprintf(stderr,","); ****/\r
-        fprintf(stderr,"    %s",RulePtr[*cursor]->rname);\r
-        fprintf(stderr,"\n");\r
-      };\r
-      free( (char *) origin);\r
-    };\r
-}\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/antlr/parser.dlg b/Tools/CodeTools/TianoTools/Pccts/antlr/parser.dlg
deleted file mode 100644 (file)
index 8c43dff..0000000
+++ /dev/null
@@ -1,1387 +0,0 @@
-<<\r
-/* parser.dlg -- DLG Description of scanner\r
- *\r
- * Generated from: antlr.g\r
- *\r
- * Terence Parr, Will Cohen, and Hank Dietz: 1989-2001\r
- * Purdue University Electrical Engineering\r
- * With AHPCRC, University of Minnesota\r
- * ANTLR Version 1.33MR33\r
- */\r
-\r
-#define ANTLR_VERSION  13333\r
-#include "pcctscfg.h"\r
-#include "pccts_stdio.h"\r
-\r
-#include "pcctscfg.h"\r
-#include "set.h"\r
-#include <ctype.h>\r
-#include "syn.h"\r
-#include "hash.h"\r
-#include "generic.h"\r
-#define zzcr_attr(attr,tok,t)\r
-#include "antlr.h"\r
-#include "tokens.h"\r
-#include "dlgdef.h"\r
-LOOKAHEAD\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-zzerraction(void)\r
-#else\r
-zzerraction()\r
-#endif\r
-{\r
-       (*zzerr)("invalid token");\r
-       zzadvance();\r
-       zzskip();\r
-}\r
->>\r
-\r
-<<%%lexaction\r
-\r
-/* maintained, but not used for now */\r
-set AST_nodes_refd_in_actions = set_init;\r
-int inAlt = 0;\r
-set attribsRefdFromAction = set_init; /* MR20 */\r
-int UsedOldStyleAttrib = 0;\r
-int UsedNewStyleLabel = 0;\r
-#ifdef __USE_PROTOS\r
-char *inline_set(char *);\r
-#else\r
-char *inline_set();\r
-#endif\r
-\r
-/* MR1 10-Apr-97  MR1  Previously unable to put right shift operator       */\r
-/* MR1                                 in DLG action                                       */\r
-\r
-int tokenActionActive=0;                                            /* MR1 */\r
-\r
-  \r
->>\r
-\r
-<<%%lexaction\r
-\r
-\r
-static char *\r
-#ifdef __USE_PROTOS\r
-getFileNameFromTheLineInfo(char *toStr, char *fromStr)\r
-#else\r
-getFileNameFromTheLineInfo(toStr, fromStr)\r
-char *toStr, *fromStr;\r
-#endif\r
-{\r
-  int i, j, k;\r
-  \r
-  if (!fromStr || !toStr) return toStr;\r
-  \r
-  /* find the first " */\r
-  \r
-  for (i=0;\r
-  (i<MaxFileName) &&\r
-  (fromStr[i] != '\n') &&\r
-  (fromStr[i] != '\r') &&\r
-  (fromStr[i] != '\"');\r
-  i++) /* nothing */ ;\r
-  \r
-  if ( (i == MaxFileName) ||\r
-  (fromStr[i] == '\n') ||\r
-  (fromStr[i] == '\r') ) {\r
-  return toStr;\r
-}\r
-\r
-  /* find the second " */\r
-\r
-  for (j=i+1;\r
-(j<MaxFileName) &&\r
-(fromStr[j] != '\n') &&\r
-(fromStr[j] != '\r') &&\r
-(fromStr[j] != '\"');\r
-j++) /* nothing */ ;\r
-\r
-  if ((j == MaxFileName) ||\r
-(fromStr[j] == '\n') ||\r
-(fromStr[j] == '\r') ) {\r
-  return toStr;\r
-}\r
-\r
-  /* go back until the last / or \ */\r
-\r
-  for (k=j-1;\r
-(fromStr[k] != '\"') &&\r
-(fromStr[k] != '/') &&\r
-(fromStr[k] != '\\');\r
-k--) /* nothing */ ;\r
-\r
-  /* copy the string after " / or \ into toStr */\r
-\r
-  for (i=k+1; fromStr[i] != '\"'; i++) {\r
-toStr[i-k-1] = fromStr[i];\r
-}\r
-\r
-  toStr[i-k-1] = '\0';\r
-\r
-  return toStr;\r
-}\r
-\r
-/* MR14 end of a block to support #line in antlr source code */\r
-\r
-  \r
->>\r
-\r
-<<%%lexaction\r
-\r
-#ifdef __USE_PROTOS\r
-void mark_label_used_in_sem_pred(LabelEntry *le)              /* MR10 */\r
-#else\r
-void mark_label_used_in_sem_pred(le)                          /* MR10 */\r
-LabelEntry    *le;\r
-#endif\r
-{\r
-  TokNode   *tn;\r
-  require (le->elem->ntype == nToken,"mark_label_used... ntype != nToken");\r
-  tn=(TokNode *)le->elem;\r
-  require (tn->label != 0,"mark_label_used... TokNode has no label");\r
-  tn->label_used_in_semantic_pred=1;\r
-}\r
->>\r
-\r
-\r
-%%START\r
-\r
-@\r
-       <<\r
-               NLA = Eof;\r
-    /* L o o k  F o r  A n o t h e r  F i l e */\r
-    {\r
-      FILE *new_input;\r
-      new_input = NextFile();\r
-      if ( new_input == NULL ) { NLA=Eof; return; }\r
-      fclose( input );\r
-      input = new_input;\r
-      zzrdstream( input );\r
-      zzskip();        /* Skip the Eof (@) char i.e continue */\r
-    }\r
-       >>\r
-\r
-[\t\ ]+\r
-       <<\r
-               NLA = 76;\r
-    zzskip();   \r
-       >>\r
-\r
-\n|\r|\r\n\r
-       <<\r
-               NLA = 77;\r
-    zzline++; zzskip();   \r
-       >>\r
-\r
-\[\r
-       <<\r
-               NLA = 78;\r
-    zzmode(ACTIONS); zzmore();\r
-    istackreset();\r
-    pushint(']');   \r
-       >>\r
-\r
-\<\<\r
-       <<\r
-               NLA = 79;\r
-    action_file=CurFile; action_line=zzline;\r
-    zzmode(ACTIONS); zzmore();\r
-    list_free(&CurActionLabels,0);       /* MR10 */\r
-    numericActionLabel=0;                /* MR10 */\r
-    istackreset();\r
-    pushint('>');   \r
-       >>\r
-\r
-\"\r
-       <<\r
-               NLA = 80;\r
-    zzmode(STRINGS); zzmore();   \r
-       >>\r
-\r
-/\*\r
-       <<\r
-               NLA = 81;\r
-    zzmode(COMMENTS); zzskip();   \r
-       >>\r
-\r
-\*/\r
-       <<\r
-               NLA = 82;\r
-    warn("Missing /*; found dangling */"); zzskip();   \r
-       >>\r
-\r
-//\r
-       <<\r
-               NLA = 83;\r
-    zzmode(CPP_COMMENTS); zzskip();   \r
-       >>\r
-\r
-#line[\ \t]* [0-9]+ {[\ \t]* \"~[\"]+\" ([\ \t]* [0-9]*)* } (\n|\r|\r\n)\r
-       <<\r
-               NLA = 84;\r
-    \r
-    zzline = atoi(zzbegexpr+5) - 1; zzline++; zzmore();\r
-    getFileNameFromTheLineInfo(FileStr[CurFile], zzbegexpr);\r
-       >>\r
-\r
-#line ~[\n\r]* (\n|\r|\r\n)\r
-       <<\r
-               NLA = 85;\r
-    \r
-    zzline++; zzmore();\r
-       >>\r
-\r
-\>\>\r
-       <<\r
-               NLA = 86;\r
-    warn("Missing <<; found dangling \>\>"); zzskip();   \r
-       >>\r
-\r
-.\r
-       <<\r
-               NLA = WildCard;\r
-       >>\r
-\r
-\@\r
-       <<\r
-               NLA = 88;\r
-    FoundException = 1;                /* MR6 */\r
-    FoundAtOperator = 1;  \r
-       >>\r
-\r
-{\\}#pragma\r
-       <<\r
-               NLA = Pragma;\r
-       >>\r
-\r
-{\\}#FirstSetSymbol\r
-       <<\r
-               NLA = FirstSetSymbol;\r
-       >>\r
-\r
-{\\}#header\r
-       <<\r
-               NLA = 94;\r
-       >>\r
-\r
-{\\}#first\r
-       <<\r
-               NLA = 95;\r
-       >>\r
-\r
-{\\}#parser\r
-       <<\r
-               NLA = 96;\r
-       >>\r
-\r
-{\\}#tokdefs\r
-       <<\r
-               NLA = 97;\r
-       >>\r
-\r
-\}\r
-       <<\r
-               NLA = 98;\r
-       >>\r
-\r
-class\r
-       <<\r
-               NLA = 99;\r
-       >>\r
-\r
-\{\r
-       <<\r
-               NLA = 102;\r
-       >>\r
-\r
-!\r
-       <<\r
-               NLA = 103;\r
-       >>\r
-\r
-\<\r
-       <<\r
-               NLA = 104;\r
-       >>\r
-\r
-\>\r
-       <<\r
-               NLA = 105;\r
-       >>\r
-\r
-:\r
-       <<\r
-               NLA = 106;\r
-       >>\r
-\r
-;\r
-       <<\r
-               NLA = 107;\r
-       >>\r
-\r
-{\\}#lexaction\r
-       <<\r
-               NLA = 108;\r
-       >>\r
-\r
-{\\}#lexmember\r
-       <<\r
-               NLA = 109;\r
-       >>\r
-\r
-{\\}#lexprefix\r
-       <<\r
-               NLA = 110;\r
-       >>\r
-\r
-{\\}#pred\r
-       <<\r
-               NLA = 111;\r
-       >>\r
-\r
-\|\|\r
-       <<\r
-               NLA = 112;\r
-       >>\r
-\r
-&&\r
-       <<\r
-               NLA = 113;\r
-       >>\r
-\r
-\(\r
-       <<\r
-               NLA = 114;\r
-       >>\r
-\r
-\)\r
-       <<\r
-               NLA = 115;\r
-       >>\r
-\r
-{\\}#lexclass\r
-       <<\r
-               NLA = 116;\r
-       >>\r
-\r
-{\\}#errclass\r
-       <<\r
-               NLA = 117;\r
-       >>\r
-\r
-{\\}#tokclass\r
-       <<\r
-               NLA = 118;\r
-       >>\r
-\r
-..\r
-       <<\r
-               NLA = 119;\r
-       >>\r
-\r
-{\\}#token\r
-       <<\r
-               NLA = 120;\r
-       >>\r
-\r
-=\r
-       <<\r
-               NLA = 121;\r
-       >>\r
-\r
-[0-9]+\r
-       <<\r
-               NLA = 122;\r
-       >>\r
-\r
-\|\r
-       <<\r
-               NLA = 123;\r
-       >>\r
-\r
-\~\r
-       <<\r
-               NLA = 124;\r
-       >>\r
-\r
-^\r
-       <<\r
-               NLA = 125;\r
-       >>\r
-\r
-approx\r
-       <<\r
-               NLA = 126;\r
-       >>\r
-\r
-LL\(1\)\r
-       <<\r
-               NLA = 127;\r
-       >>\r
-\r
-LL\(2\)\r
-       <<\r
-               NLA = 128;\r
-       >>\r
-\r
-\*\r
-       <<\r
-               NLA = 129;\r
-       >>\r
-\r
-\+\r
-       <<\r
-               NLA = 130;\r
-       >>\r
-\r
-?\r
-       <<\r
-               NLA = 131;\r
-       >>\r
-\r
-=>\r
-       <<\r
-               NLA = 132;\r
-       >>\r
-\r
-exception\r
-       <<\r
-               NLA = 133;\r
-       >>\r
-\r
-default\r
-       <<\r
-               NLA = 134;\r
-       >>\r
-\r
-catch\r
-       <<\r
-               NLA = 135;\r
-       >>\r
-\r
-[a-z] [A-Za-z0-9_]*\r
-       <<\r
-               NLA = NonTerminal;\r
-    \r
-    while ( zzchar==' ' || zzchar=='\t' ) {\r
-      zzadvance();\r
-    }\r
-    if ( zzchar == ':' && inAlt ) NLA = LABEL;\r
-       >>\r
-\r
-[A-Z] [A-Za-z0-9_]*\r
-       <<\r
-               NLA = TokenTerm;\r
-    \r
-    while ( zzchar==' ' || zzchar=='\t' ) {\r
-      zzadvance();\r
-    }\r
-    if ( zzchar == ':' && inAlt ) NLA = LABEL;\r
-       >>\r
-\r
-{\\}#[A-Za-z0-9_]*\r
-       <<\r
-               NLA = 136;\r
-    warn(eMsg1("unknown meta-op: %s",LATEXT(1))); zzskip();   \r
-       >>\r
-\r
-\r
-%%STRINGS\r
-\r
-@\r
-       <<\r
-               NLA = Eof;\r
-       >>\r
-\r
-\"\r
-       <<\r
-               NLA = QuotedTerm;\r
-    zzmode(START);   \r
-       >>\r
-\r
-\n|\r|\r\n\r
-       <<\r
-               NLA = 3;\r
-    \r
-    zzline++;\r
-    warn("eoln found in string");\r
-    zzskip();\r
-       >>\r
-\r
-\\(\n|\r|\r\n)\r
-       <<\r
-               NLA = 4;\r
-    zzline++; zzmore();   \r
-       >>\r
-\r
-\\~[]\r
-       <<\r
-               NLA = 5;\r
-    zzmore();   \r
-       >>\r
-\r
-~[\n\r\"\\]+\r
-       <<\r
-               NLA = 6;\r
-    zzmore();   \r
-       >>\r
-\r
-\r
-%%ACTION_STRINGS\r
-\r
-@\r
-       <<\r
-               NLA = Eof;\r
-       >>\r
-\r
-\"\r
-       <<\r
-               NLA = 7;\r
-    zzmode(ACTIONS); zzmore();   \r
-       >>\r
-\r
-\n|\r|\r\n\r
-       <<\r
-               NLA = 8;\r
-    \r
-    zzline++;\r
-    warn("eoln found in string (in user action)");\r
-    zzskip();\r
-       >>\r
-\r
-\\(\n|\r|\r\n)\r
-       <<\r
-               NLA = 9;\r
-    zzline++; zzmore();   \r
-       >>\r
-\r
-\\~[]\r
-       <<\r
-               NLA = 10;\r
-    zzmore();   \r
-       >>\r
-\r
-~[\n\r\"\\]+\r
-       <<\r
-               NLA = 11;\r
-    zzmore();   \r
-       >>\r
-\r
-\r
-%%ACTION_CHARS\r
-\r
-@\r
-       <<\r
-               NLA = Eof;\r
-       >>\r
-\r
-'\r
-       <<\r
-               NLA = 12;\r
-    zzmode(ACTIONS); zzmore();   \r
-       >>\r
-\r
-\n|\r|\r\n\r
-       <<\r
-               NLA = 13;\r
-    \r
-    zzline++;\r
-    warn("eoln found in char literal (in user action)");\r
-    zzskip();\r
-       >>\r
-\r
-\\~[]\r
-       <<\r
-               NLA = 14;\r
-    zzmore();   \r
-       >>\r
-\r
-~[\n\r'\\]+\r
-       <<\r
-               NLA = 15;\r
-    zzmore();   \r
-       >>\r
-\r
-\r
-%%ACTION_COMMENTS\r
-\r
-@\r
-       <<\r
-               NLA = Eof;\r
-       >>\r
-\r
-\*/\r
-       <<\r
-               NLA = 16;\r
-    zzmode(ACTIONS); zzmore();   \r
-       >>\r
-\r
-\*\r
-       <<\r
-               NLA = 17;\r
-    zzmore();   \r
-       >>\r
-\r
-\n|\r|\r\n\r
-       <<\r
-               NLA = 18;\r
-    zzline++; zzmore(); DAWDLE;   \r
-       >>\r
-\r
-~[\n\r\*]+\r
-       <<\r
-               NLA = 19;\r
-    zzmore();   \r
-       >>\r
-\r
-\r
-%%TOK_DEF_COMMENTS\r
-\r
-@\r
-       <<\r
-               NLA = Eof;\r
-       >>\r
-\r
-\*/\r
-       <<\r
-               NLA = 20;\r
-    zzmode(PARSE_ENUM_FILE);\r
-    zzmore();   \r
-       >>\r
-\r
-\*\r
-       <<\r
-               NLA = 21;\r
-    zzmore();   \r
-       >>\r
-\r
-\n|\r|\r\n\r
-       <<\r
-               NLA = 22;\r
-    zzline++; zzmore(); DAWDLE;   \r
-       >>\r
-\r
-~[\n\r\*]+\r
-       <<\r
-               NLA = 23;\r
-    zzmore();   \r
-       >>\r
-\r
-\r
-%%TOK_DEF_CPP_COMMENTS\r
-\r
-@\r
-       <<\r
-               NLA = Eof;\r
-       >>\r
-\r
-\n|\r|\r\n\r
-       <<\r
-               NLA = 24;\r
-    zzline++; zzmode(PARSE_ENUM_FILE); zzskip(); DAWDLE;   \r
-       >>\r
-\r
-~[\n\r]+\r
-       <<\r
-               NLA = 25;\r
-    zzskip();   \r
-       >>\r
-\r
-\r
-%%ACTION_CPP_COMMENTS\r
-\r
-@\r
-       <<\r
-               NLA = Eof;\r
-       >>\r
-\r
-\n|\r|\r\n\r
-       <<\r
-               NLA = 26;\r
-    zzline++; zzmode(ACTIONS); zzmore(); DAWDLE;   \r
-       >>\r
-\r
-~[\n\r]+\r
-       <<\r
-               NLA = 27;\r
-    zzmore();   \r
-       >>\r
-\r
-\r
-%%CPP_COMMENTS\r
-\r
-@\r
-       <<\r
-               NLA = Eof;\r
-       >>\r
-\r
-\n|\r|\r\n\r
-       <<\r
-               NLA = 28;\r
-    zzline++; zzmode(START); zzskip(); DAWDLE;   \r
-       >>\r
-\r
-~[\n\r]+\r
-       <<\r
-               NLA = 29;\r
-    zzskip();   \r
-       >>\r
-\r
-\r
-%%COMMENTS\r
-\r
-@\r
-       <<\r
-               NLA = Eof;\r
-       >>\r
-\r
-\*/\r
-       <<\r
-               NLA = 30;\r
-    zzmode(START); zzskip();   \r
-       >>\r
-\r
-\*\r
-       <<\r
-               NLA = 31;\r
-    zzskip();   \r
-       >>\r
-\r
-\n|\r|\r\n\r
-       <<\r
-               NLA = 32;\r
-    zzline++; zzskip(); DAWDLE;   \r
-       >>\r
-\r
-~[\n\r\*]+\r
-       <<\r
-               NLA = 33;\r
-    zzskip();   \r
-       >>\r
-\r
-\r
-%%ACTIONS\r
-\r
-@\r
-       <<\r
-               NLA = Eof;\r
-       >>\r
-\r
-\>\>\r
-       <<\r
-               NLA = Action;\r
-    /* these do not nest */\r
-    zzmode(START);\r
-    NLATEXT[0] = ' ';\r
-    NLATEXT[1] = ' ';\r
-    zzbegexpr[0] = ' ';\r
-    zzbegexpr[1] = ' ';\r
-    if ( zzbufovf ) {\r
-      err( eMsgd("action buffer overflow; size %d",ZZLEXBUFSIZE));\r
-    }\r
-    \r
-/* MR1 10-Apr-97  MR1  Previously unable to put right shift operator   */\r
-    /* MR1                                     in DLG action                   */\r
-    /* MR1                     Doesn't matter what kind of action it is - reset*/\r
-    \r
-                             tokenActionActive=0;               /* MR1 */\r
-       >>\r
-\r
-\>\>?\r
-       <<\r
-               NLA = Pred;\r
-    /* these do not nest */\r
-    zzmode(START);\r
-    NLATEXT[0] = ' ';\r
-    NLATEXT[1] = ' ';\r
-    zzbegexpr[0] = '\0';\r
-    if ( zzbufovf ) {\r
-      err( eMsgd("predicate buffer overflow; size %d",ZZLEXBUFSIZE));\r
-    };\r
-#ifdef __cplusplus__\r
-    /* MR10 */                    list_apply(CurActionLabels, (void (*)(void *))mark_label_used_in_sem_pred);\r
-#else\r
-#ifdef __STDC__\r
-    /* MR10 */                    list_apply(CurActionLabels, (void (*)(void *))mark_label_used_in_sem_pred);\r
-#else\r
-#ifdef __USE_PROTOS\r
-    /* MRxx */                    list_apply(CurActionLabels, (void (*)(void *))mark_label_used_in_sem_pred);\r
-#else\r
-    /* MR10 */                    list_apply(CurActionLabels,mark_label_used_in_sem_pred);\r
-#endif\r
-#endif\r
-#endif\r
-       >>\r
-\r
-\]\r
-       <<\r
-               NLA = PassAction;\r
-    if ( topint() == ']' ) {\r
-      popint();\r
-      if ( istackempty() )     /* terminate action */\r
-      {\r
-        zzmode(START);\r
-        NLATEXT[0] = ' ';\r
-        zzbegexpr[0] = ' ';\r
-        if ( zzbufovf ) {\r
-          err( eMsgd("parameter buffer overflow; size %d",ZZLEXBUFSIZE));\r
-        }\r
-      }\r
-      else {\r
-        /* terminate $[..] and #[..] */\r
-        if ( GenCC ) zzreplstr("))");\r
-        else zzreplstr(")");\r
-        zzmore();\r
-      }\r
-    }\r
-    else if ( topint() == '|' ) { /* end of simple [...] */\r
-      popint();\r
-      zzmore();\r
-    }\r
-    else zzmore();\r
-       >>\r
-\r
-consumeUntil\( [\ \t]* \{~[\}]+\} [\ \t]* \)\r
-       <<\r
-               NLA = 37;\r
-    \r
-    zzmore();\r
-    zzreplstr(inline_set(zzbegexpr+\r
-    strlen("consumeUntil(")));\r
-       >>\r
-\r
-consumeUntil\( ~[\)]+ \)\r
-       <<\r
-               NLA = 38;\r
-    zzmore();   \r
-       >>\r
-\r
-\n|\r|\r\n\r
-       <<\r
-               NLA = 39;\r
-    zzline++; zzmore(); DAWDLE;   \r
-       >>\r
-\r
-\>\r
-       <<\r
-               NLA = 40;\r
-    zzmore();   \r
-       >>\r
-\r
-$\r
-       <<\r
-               NLA = 41;\r
-    zzmore();   \r
-       >>\r
-\r
-$$\r
-       <<\r
-               NLA = 42;\r
-    if ( !GenCC ) {zzreplstr("zzaRet"); zzmore();}\r
-    else err("$$ use invalid in C++ mode");   \r
-       >>\r
-\r
-$\[\]\r
-       <<\r
-               NLA = 43;\r
-    if ( !GenCC ) {zzreplstr("zzempty_attr"); zzmore();}\r
-    else err("$[] use invalid in C++ mode");   \r
-       >>\r
-\r
-$\[\r
-       <<\r
-               NLA = 44;\r
-    \r
-    pushint(']');\r
-    if ( !GenCC ) zzreplstr("zzconstr_attr(");\r
-    else err("$[..] use invalid in C++ mode");\r
-    zzmore();\r
-       >>\r
-\r
-$[0-9]+\r
-       <<\r
-               NLA = 45;\r
-    {\r
-      static char buf[100];\r
-      numericActionLabel=1;       /* MR10 */\r
-      if ( strlen(zzbegexpr)>(size_t)85 )\r
-      fatal("$i attrib ref too big");\r
-      set_orel(atoi(zzbegexpr+1), &attribsRefdFromAction);\r
-      if ( !GenCC ) sprintf(buf,"zzaArg(zztasp%d,%s)",\r
-      BlkLevel-1,zzbegexpr+1);\r
-      else sprintf(buf,"_t%d%s",\r
-      BlkLevel-1,zzbegexpr+1);\r
-      zzreplstr(buf);\r
-      zzmore();\r
-      UsedOldStyleAttrib = 1;\r
-      if ( UsedNewStyleLabel )\r
-      err("cannot mix old-style $i with new-style labels");\r
-    }\r
-       >>\r
-\r
-$[0-9]+.\r
-       <<\r
-               NLA = 46;\r
-    {\r
-      static char buf[100];\r
-      numericActionLabel=1;       /* MR10 */\r
-      if ( strlen(zzbegexpr)>(size_t)85 )\r
-      fatal("$i.field attrib ref too big");\r
-      zzbegexpr[strlen(zzbegexpr)-1] = ' ';\r
-      set_orel(atoi(zzbegexpr+1), &attribsRefdFromAction);\r
-      if ( !GenCC ) sprintf(buf,"zzaArg(zztasp%d,%s).",\r
-      BlkLevel-1,zzbegexpr+1);\r
-      else sprintf(buf,"_t%d%s.",\r
-      BlkLevel-1,zzbegexpr+1);\r
-      zzreplstr(buf);\r
-      zzmore();\r
-      UsedOldStyleAttrib = 1;\r
-      if ( UsedNewStyleLabel )\r
-      err("cannot mix old-style $i with new-style labels");\r
-    }\r
-       >>\r
-\r
-$[0-9]+.[0-9]+\r
-       <<\r
-               NLA = 47;\r
-    {\r
-      static char buf[100];\r
-      static char i[20], j[20];\r
-      char *p,*q;\r
-      numericActionLabel=1;       /* MR10 */\r
-      if (strlen(zzbegexpr)>(size_t)85) fatal("$i.j attrib ref too big");\r
-      for (p=zzbegexpr+1,q= &i[0]; *p!='.'; p++) {\r
-        if ( q == &i[20] )\r
-        fatalFL("i of $i.j attrib ref too big",\r
-        FileStr[CurFile], zzline );\r
-        *q++ = *p;\r
-      }\r
-      *q = '\0';\r
-      for (p++, q= &j[0]; *p!='\0'; p++) {\r
-        if ( q == &j[20] )\r
-        fatalFL("j of $i.j attrib ref too big",\r
-        FileStr[CurFile], zzline );\r
-        *q++ = *p;\r
-      }\r
-      *q = '\0';\r
-      if ( !GenCC ) sprintf(buf,"zzaArg(zztasp%s,%s)",i,j);\r
-      else sprintf(buf,"_t%s%s",i,j);\r
-      zzreplstr(buf);\r
-      zzmore();\r
-      UsedOldStyleAttrib = 1;\r
-      if ( UsedNewStyleLabel )\r
-      err("cannot mix old-style $i with new-style labels");\r
-    }\r
-       >>\r
-\r
-$[_a-zA-Z][_a-zA-Z0-9]*\r
-       <<\r
-               NLA = 48;\r
-    { static char buf[300]; LabelEntry *el;\r
-      zzbegexpr[0] = ' ';\r
-      if ( CurRule != NULL &&\r
-      strcmp(CurRule, &zzbegexpr[1])==0 ) {\r
-        if ( !GenCC ) zzreplstr("zzaRet");\r
-      }\r
-      else if ( CurRetDef != NULL &&\r
-      strmember(CurRetDef, &zzbegexpr[1])) {\r
-        if ( hasMultipleOperands( CurRetDef ) ) {\r
-          require (strlen(zzbegexpr)<=(size_t)285,\r
-          "$retval attrib ref too big");\r
-          sprintf(buf,"_retv.%s",&zzbegexpr[1]);\r
-          zzreplstr(buf);\r
-        }\r
-        else zzreplstr("_retv");\r
-      }\r
-      else if ( CurParmDef != NULL &&\r
-      strmember(CurParmDef, &zzbegexpr[1])) {\r
-      ;\r
-    }\r
-    else if ( Elabel==NULL ) {\r
-    { err("$-variables in actions outside of rules are not allowed"); }\r
-  } else if ( (el=(LabelEntry *)hash_get(Elabel, &zzbegexpr[1]))!=NULL ) {\r
-  /* MR10 */\r
-  /* MR10 */                      /* element labels might exist without an elem when */\r
-  /* MR10 */                      /*  it is a forward reference (to a rule)          */\r
-  /* MR10 */\r
-  /* MR10 */                                           if ( GenCC && (el->elem == NULL || el->elem->ntype==nRuleRef) )\r
-  /* MR10 */                                                   { err(eMsg1("There are no token ptrs for rule references: '$%s'",&zzbegexpr[1])); }\r
-  /* MR10 */\r
-  /* MR10 */                                           if ( !GenCC && (el->elem == NULL || el->elem->ntype==nRuleRef) && GenAST) {\r
-  /* MR10 */                          err("You can no longer use attributes returned by rules when also using ASTs");\r
-  /* MR10 */                          err("   Use upward inheritance (\"rule >[Attrib a] : ... <<$a=...\>\>\")");\r
-  /* MR10 */                      };\r
-  /* MR10 */\r
-  /* MR10 */                      /* keep track of <<... $label ...>> for semantic predicates in guess mode */\r
-  /* MR10 */                      /* element labels contain pointer to the owners node                      */\r
-  /* MR10 */\r
-  /* MR10 */                      if (el->elem != NULL && el->elem->ntype == nToken) {\r
-  /* MR10 */                        list_add(&CurActionLabels,el);\r
-  /* MR10 */                      };\r
-}\r
-else\r
-warn(eMsg1("$%s not parameter, return value, (defined) element label",&zzbegexpr[1]));\r
-}\r
-zzmore();\r
-       >>\r
-\r
-#0\r
-       <<\r
-               NLA = 49;\r
-    zzreplstr("(*_root)"); zzmore(); chkGTFlag();   \r
-       >>\r
-\r
-#\[\]\r
-       <<\r
-               NLA = 50;\r
-    if ( GenCC ) {\r
-      if (NewAST) zzreplstr("(newAST)");\r
-      else zzreplstr("(new AST)");}\r
-    else {zzreplstr("zzastnew()");} zzmore();\r
-    chkGTFlag();\r
-       >>\r
-\r
-#\(\)\r
-       <<\r
-               NLA = 51;\r
-    zzreplstr("NULL"); zzmore(); chkGTFlag();   \r
-       >>\r
-\r
-#[0-9]+\r
-       <<\r
-               NLA = 52;\r
-    {\r
-      static char buf[100];\r
-      if ( strlen(zzbegexpr)>(size_t)85 )\r
-      fatal("#i AST ref too big");\r
-      if ( GenCC ) sprintf(buf,"_ast%d%s",BlkLevel-1,zzbegexpr+1);\r
-      else sprintf(buf,"zzastArg(%s)",zzbegexpr+1);\r
-      zzreplstr(buf);\r
-      zzmore();\r
-      set_orel(atoi(zzbegexpr+1), &AST_nodes_refd_in_actions);\r
-      chkGTFlag();\r
-    }\r
-       >>\r
-\r
-#line[\ \t]* [0-9]+ {[\ \t]* \"~[\"]+\" ([\ \t]* [0-9]*)* } (\n|\r|\r\n)\r
-       <<\r
-               NLA = 53;\r
-    \r
-    zzline = atoi(zzbegexpr+5) - 1; zzline++; zzmore();\r
-    getFileNameFromTheLineInfo(FileStr[CurFile], zzbegexpr);\r
-       >>\r
-\r
-#line ~[\n\r]* (\n|\r|\r\n)\r
-       <<\r
-               NLA = 54;\r
-    \r
-    zzline++; zzmore();\r
-       >>\r
-\r
-#[_a-zA-Z][_a-zA-Z0-9]*\r
-       <<\r
-               NLA = 55;\r
-    \r
-    if ( !(strcmp(zzbegexpr, "#ifdef")==0 ||\r
-    strcmp(zzbegexpr, "#if")==0 ||\r
-    strcmp(zzbegexpr, "#else")==0 ||\r
-    strcmp(zzbegexpr, "#endif")==0 ||\r
-    strcmp(zzbegexpr, "#ifndef")==0 ||\r
-    strcmp(zzbegexpr, "#define")==0 ||\r
-    strcmp(zzbegexpr, "#pragma")==0 ||\r
-    strcmp(zzbegexpr, "#undef")==0 ||\r
-    strcmp(zzbegexpr, "#import")==0 ||\r
-    strcmp(zzbegexpr, "#line")==0 ||\r
-    strcmp(zzbegexpr, "#include")==0 ||\r
-    strcmp(zzbegexpr, "#error")==0) )\r
-    {\r
-      static char buf[100];\r
-      sprintf(buf, "%s_ast", zzbegexpr+1);\r
-      /* MR27 */                                               list_add(&CurAstLabelsInActions, mystrdup(zzbegexpr+1));\r
-      zzreplstr(buf);\r
-      chkGTFlag();\r
-    }\r
-    zzmore();\r
-       >>\r
-\r
-#\[\r
-       <<\r
-               NLA = 56;\r
-    \r
-    pushint(']');\r
-    if ( GenCC ) {\r
-      if (NewAST) zzreplstr("(newAST(");\r
-      else zzreplstr("(new AST("); }\r
-    else zzreplstr("zzmk_ast(zzastnew(),");\r
-    zzmore();\r
-    chkGTFlag();\r
-       >>\r
-\r
-#\(\r
-       <<\r
-               NLA = 57;\r
-    \r
-    pushint('}');\r
-    if ( GenCC ) {\r
-      if (tmakeInParser) {\r
-        zzreplstr("tmake(");\r
-      }\r
-      else {\r
-        zzreplstr("ASTBase::tmake(");\r
-      }\r
-    }\r
-    else {\r
-      zzreplstr("zztmake(");\r
-    }\r
-    zzmore();\r
-    chkGTFlag();\r
-       >>\r
-\r
-#\r
-       <<\r
-               NLA = 58;\r
-    zzmore();   \r
-       >>\r
-\r
-\)\r
-       <<\r
-               NLA = 59;\r
-    \r
-    if ( istackempty() )\r
-    zzmore();\r
-    else if ( topint()==')' ) {\r
-      popint();\r
-    }\r
-    else if ( topint()=='}' ) {\r
-      popint();\r
-      /* terminate #(..) */\r
-      zzreplstr(", NULL)");\r
-    }\r
-    zzmore();\r
-       >>\r
-\r
-\[\r
-       <<\r
-               NLA = 60;\r
-    \r
-    pushint('|');      /* look for '|' to terminate simple [...] */\r
-    zzmore();\r
-       >>\r
-\r
-\(\r
-       <<\r
-               NLA = 61;\r
-    \r
-    pushint(')');\r
-    zzmore();\r
-       >>\r
-\r
-\\\]\r
-       <<\r
-               NLA = 62;\r
-    zzreplstr("]");  zzmore();   \r
-       >>\r
-\r
-\\\)\r
-       <<\r
-               NLA = 63;\r
-    zzreplstr(")");  zzmore();   \r
-       >>\r
-\r
-\\>\r
-       <<\r
-               NLA = 64;\r
-    if (! tokenActionActive) zzreplstr(">");    /* MR1 */\r
-    zzmore();                                   /* MR1 */\r
-       >>\r
-\r
-'\r
-       <<\r
-               NLA = 65;\r
-    zzmode(ACTION_CHARS); zzmore();  \r
-       >>\r
-\r
-\"\r
-       <<\r
-               NLA = 66;\r
-    zzmode(ACTION_STRINGS); zzmore();  \r
-       >>\r
-\r
-\\$\r
-       <<\r
-               NLA = 67;\r
-    zzreplstr("$");  zzmore();   \r
-       >>\r
-\r
-\\#\r
-       <<\r
-               NLA = 68;\r
-    zzreplstr("#");  zzmore();   \r
-       >>\r
-\r
-\\(\n|\r|\r\n)\r
-       <<\r
-               NLA = 69;\r
-    zzline++; zzmore();   \r
-       >>\r
-\r
-\\~[\]\)>$#]\r
-       <<\r
-               NLA = 70;\r
-    zzmore();   \r
-       >>\r
-\r
-/\r
-       <<\r
-               NLA = 71;\r
-    zzmore();   \r
-       >>\r
-\r
-/\*\r
-       <<\r
-               NLA = 72;\r
-    zzmode(ACTION_COMMENTS); zzmore();   \r
-       >>\r
-\r
-\*/\r
-       <<\r
-               NLA = 73;\r
-    warn("Missing /*; found dangling */ in action"); zzmore();   \r
-       >>\r
-\r
-//\r
-       <<\r
-               NLA = 74;\r
-    zzmode(ACTION_CPP_COMMENTS); zzmore();   \r
-       >>\r
-\r
-~[\n\r\)\(\\$#\>\]\[\"'/]+\r
-       <<\r
-               NLA = 75;\r
-    zzmore();   \r
-       >>\r
-\r
-\r
-%%PARSE_ENUM_FILE\r
-\r
-@\r
-       <<\r
-               NLA = Eof;\r
-    ;   \r
-       >>\r
-\r
-[\t\ ]+\r
-       <<\r
-               NLA = 137;\r
-    zzskip();   \r
-       >>\r
-\r
-\n|\r|\r\n\r
-       <<\r
-               NLA = 138;\r
-    zzline++; zzskip();   \r
-       >>\r
-\r
-//\r
-       <<\r
-               NLA = 139;\r
-    zzmode(TOK_DEF_CPP_COMMENTS); zzmore();   \r
-       >>\r
-\r
-/\*\r
-       <<\r
-               NLA = 140;\r
-    zzmode(TOK_DEF_COMMENTS); zzskip();   \r
-       >>\r
-\r
-#ifdef\r
-       <<\r
-               NLA = 141;\r
-    zzmode(TOK_DEF_CPP_COMMENTS); zzskip();   \r
-       >>\r
-\r
-#if\r
-       <<\r
-               NLA = 142;\r
-    zzmode(TOK_DEF_CPP_COMMENTS); zzskip();   \r
-       >>\r
-\r
-#ifndef\r
-       <<\r
-               NLA = 143;\r
-    ;   \r
-       >>\r
-\r
-#else\r
-       <<\r
-               NLA = 144;\r
-    zzmode(TOK_DEF_CPP_COMMENTS); zzskip();   \r
-       >>\r
-\r
-#endif\r
-       <<\r
-               NLA = 145;\r
-    zzmode(TOK_DEF_CPP_COMMENTS); zzskip();   \r
-       >>\r
-\r
-#undef\r
-       <<\r
-               NLA = 146;\r
-    zzmode(TOK_DEF_CPP_COMMENTS); zzskip();   \r
-       >>\r
-\r
-#import\r
-       <<\r
-               NLA = 147;\r
-    zzmode(TOK_DEF_CPP_COMMENTS); zzskip();   \r
-       >>\r
-\r
-#define\r
-       <<\r
-               NLA = 149;\r
-       >>\r
-\r
-enum\r
-       <<\r
-               NLA = 151;\r
-       >>\r
-\r
-\{\r
-       <<\r
-               NLA = 152;\r
-       >>\r
-\r
-=\r
-       <<\r
-               NLA = 153;\r
-       >>\r
-\r
-,\r
-       <<\r
-               NLA = 154;\r
-       >>\r
-\r
-\}\r
-       <<\r
-               NLA = 155;\r
-       >>\r
-\r
-;\r
-       <<\r
-               NLA = 156;\r
-       >>\r
-\r
-[0-9]+\r
-       <<\r
-               NLA = INT;\r
-       >>\r
-\r
-[a-zA-Z_][_a-zA-Z0-9]*\r
-       <<\r
-               NLA = ID;\r
-       >>\r
-\r
-%%\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/antlr/pred.c b/Tools/CodeTools/TianoTools/Pccts/antlr/pred.c
deleted file mode 100644 (file)
index eb11c4d..0000000
+++ /dev/null
@@ -1,821 +0,0 @@
-/*\r
- * pred.c -- source for predicate detection, manipulation\r
- *\r
- * SOFTWARE RIGHTS\r
- *\r
- * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
- * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
- * company may do whatever they wish with source code distributed with\r
- * PCCTS or the code generated by PCCTS, including the incorporation of\r
- * PCCTS, or its output, into commerical software.\r
- *\r
- * We encourage users to develop software with PCCTS.  However, we do ask\r
- * that credit is given to us for developing PCCTS.  By "credit",\r
- * we mean that if you incorporate our source code into one of your\r
- * programs (commercial product, research project, or otherwise) that you\r
- * acknowledge this fact somewhere in the documentation, research report,\r
- * etc...  If you like PCCTS and have developed a nice tool with the\r
- * output, please mention that you developed it using PCCTS.  In\r
- * addition, we ask that this header remain intact in our source code.\r
- * As long as these guidelines are kept, we expect to continue enhancing\r
- * this system and expect to make other tools available as they are\r
- * completed.\r
- *\r
- * ANTLR 1.33\r
- * Terence Parr\r
- * Parr Research Corporation\r
- * with Purdue University and AHPCRC, University of Minnesota\r
- * 1989-2001\r
- */\r
-\r
-#include <stdio.h>\r
-#include "pcctscfg.h"\r
-#include "set.h"\r
-#include "syn.h"\r
-#include "hash.h"\r
-#include "generic.h"\r
-#include "dlgdef.h"\r
-#include <ctype.h>\r
-\r
-#ifdef __USE_PROTOS\r
-static void complete_context_sets(RuleRefNode *, Predicate *);\r
-static void complete_context_trees(RuleRefNode *, Predicate *);\r
-#else\r
-static void complete_context_sets();\r
-static void complete_context_trees();\r
-#endif\r
-\r
-char *PRED_AND_LIST = "AND";\r
-char *PRED_OR_LIST = "OR";\r
-\r
-/*\r
- * In C mode, return the largest constant integer found as the\r
- * sole argument to LATEXT(i).\r
- *\r
- * In C++ mode, return the largest constant integer found as the\r
- * sole argument to LT(i) given that the char before is nonalpha.\r
- */\r
-\r
-int\r
-#ifdef __USE_PROTOS\r
-predicateLookaheadDepth(ActionNode *a)\r
-#else\r
-predicateLookaheadDepth(a)\r
-ActionNode *a;\r
-#endif\r
-{\r
-       int     max_k=0;\r
-\r
-    if (a->predEntry != NULL) {\r
-       MR_pred_depth(a->predEntry->pred,&max_k);\r
-       goto PREDENTRY_EXIT;\r
-    }\r
-\r
-       if ( GenCC )\r
-       {\r
-               /* scan for LT(i) */\r
-               int k = 0;\r
-               char *p = a->action;\r
-               while ( p!=NULL )\r
-               {\r
-                       p = strstr(p, "LT(");\r
-                       if ( p!=NULL )\r
-                       {\r
-                               if ( p>=a->action && !isalpha(*(p-1)) )\r
-                               {\r
-                                       k = atoi(p+strlen("LT("));\r
-                                       if ( k>max_k ) max_k=k;\r
-                               }\r
-                               p += strlen("LT(");\r
-                       }\r
-               }\r
-       }\r
-       else {\r
-               /* scan for LATEXT(i) */\r
-               int k = 0;\r
-               char *p = a->action;\r
-               while ( p!=NULL )\r
-               {\r
-                       p = strstr(p, "LATEXT(");\r
-                       if ( p!=NULL )\r
-                       {\r
-                               p += strlen("LATEXT(");\r
-                               k = atoi(p);\r
-                               if ( k>max_k ) max_k=k;\r
-                       }\r
-               }\r
-       }\r
-\r
-       if (max_k==0) {\r
-               max_k = 1;         /* MR33 Badly designed if didn't set max_k when CLL_k = 1 */\r
-               if (CLL_k > 1) /* MR27 Don't warn if max(k,ck) == 1 */\r
-               {\r
-                       if ( !a->frmwarned )\r
-                       {\r
-                               a->frmwarned = 1;\r
-                               warnFL(eMsg1("predicate: %s missing, bad, or with i=0; assuming i=1",\r
-                                                        GenCC?"LT(i)":"LATEXT(i)"),\r
-                                          FileStr[a->file], a->line);\r
-                       }\r
-               }\r
-       }\r
-\r
-/* MR10 */    if ( max_k > CLL_k) {\r
-/* MR10 */             if ( !a->frmwarned )\r
-/* MR10 */        {\r
-/* MR10 */                     a->frmwarned = 1;\r
-/* MR11 */ errFL(eMsgd2("predicate refers to lookahead token %d. Semantic lookahead is limited to max(k,ck)==%d",\r
-/* MR10 */                        max_k,CLL_k),\r
-/* MR10 */                        FileStr[a->file],a->line);\r
-/* MR10 */          if (max_k >= OutputLL_k) {\r
-/* MR10 */            if (!GenCC) {\r
-/* MR10 */              errFL(eMsgd("    the lookahead buffer size in C mode is %d token(s) (including the one just recognized)",\r
-/* MR10 */                        OutputLL_k),\r
-/* MR10 */                        FileStr[a->file],a->line);\r
-/* MR10 */            };\r
-/* MR10 */          };\r
-/* MR10 */        };\r
-/* MR10 */        max_k= CLL_k;\r
-/* MR10 */    };\r
-\r
-PREDENTRY_EXIT:\r
-       return max_k;\r
-}\r
-\r
-/* Find all predicates in a block of alternatives.  DO NOT find predicates\r
- * behind the block because that predicate could depend on things set in\r
- * one of the nonoptional blocks\r
- */\r
-\r
-Predicate *\r
-#ifdef __USE_PROTOS\r
-find_in_aSubBlk( Junction *alt )\r
-#else\r
-find_in_aSubBlk( alt )\r
-Junction *alt;\r
-#endif\r
-{\r
-       Predicate *a, *head=NULL, *tail=NULL, *root=NULL;\r
-       Junction *p = alt;\r
-\r
-    if (MRhoisting) {\r
-      return MR_find_in_aSubBlk(alt);\r
-    };\r
-       for (; p!=NULL; p=(Junction *)p->p2)\r
-       {\r
-               /* ignore empty alts */\r
-               if ( p->p1->ntype != nJunction ||\r
-                        ((Junction *)p->p1)->jtype != EndBlk )\r
-               {\r
-                       a = find_predicates(p->p1);     /* get preds for this alt */\r
-                       if ( a==NULL ) continue;\r
-\r
-                       /* make an OR list of predicates */\r
-                       if ( head==NULL )\r
-                       {\r
-                               root = new_pred();\r
-                               root->expr = PRED_OR_LIST;\r
-                               head = tail = a;\r
-                               root->down = head;\r
-                       }\r
-                       else {\r
-                               tail->right = a;\r
-                               a->left = tail;\r
-                               a->up = tail->up;\r
-                               tail = a;\r
-                       }\r
-               }\r
-       }\r
-\r
-       /* if just one pred, remove OR root */\r
-       if ( root!=NULL && root->down->right == NULL )\r
-       {\r
-               Predicate *d = root->down;\r
-               free( (char *) root);\r
-               return d;\r
-       }\r
-\r
-       return root;\r
-}\r
-\r
-Predicate *\r
-#ifdef __USE_PROTOS\r
-find_in_aOptBlk( Junction *alt )\r
-#else\r
-find_in_aOptBlk( alt )\r
-Junction *alt;\r
-#endif\r
-{\r
-       return find_in_aSubBlk( alt );\r
-}\r
-\r
-Predicate *\r
-#ifdef __USE_PROTOS\r
-find_in_aLoopBegin( Junction *alt )\r
-#else\r
-find_in_aLoopBegin( alt )\r
-Junction *alt;\r
-#endif\r
-{\r
-       return find_in_aSubBlk( (Junction *) alt->p1 ); /* get preds in alts */\r
-}\r
-\r
-Predicate *\r
-#ifdef __USE_PROTOS\r
-find_in_aPlusBlk( Junction *alt )\r
-#else\r
-find_in_aPlusBlk( alt )\r
-Junction *alt;\r
-#endif\r
-{\r
-       require(alt!=NULL&&alt->p2!=NULL, "invalid aPlusBlk");\r
-       return find_in_aSubBlk( alt );\r
-}\r
-\r
-/* Look for a predicate;\r
- *\r
- * Do not pass anything but Junction nodes; no Actions, Tokens, RuleRefs.\r
- * This means that a "hoisting distance" of zero is the only distance\r
- * allowable.  Init actions are ignored.\r
- *\r
- * WARNING:\r
- *             Assumes no (..)? block after predicate for the moment.\r
- *             Does not check to see if pred is in production that can generate\r
- *                     a sequence contained in the set of ambiguous tuples.\r
- *\r
- * Return the predicate found if any.\r
- */\r
-\r
-\r
-Predicate *\r
-#ifdef __USE_PROTOS\r
-find_predicates( Node *alt )\r
-#else\r
-find_predicates( alt )\r
-Node *alt;\r
-#endif\r
-{\r
-#ifdef DBG_PRED\r
-       Junction *j;\r
-       RuleRefNode *r;\r
-       TokNode *t;\r
-#endif\r
-       Predicate *pred;\r
-\r
-       if ( alt==NULL ) return NULL;\r
-\r
-#ifdef DBG_PRED\r
-       switch ( alt->ntype )\r
-       {\r
-               case nJunction :\r
-                       j = (Junction *) alt;\r
-                       fprintf(stderr, "Junction(in %s)", j->rname);\r
-                       switch ( j->jtype )\r
-                       {\r
-                               case aSubBlk :\r
-                                       fprintf(stderr,"aSubBlk\n");\r
-                                       break;\r
-                               case aOptBlk :\r
-                                       fprintf(stderr,"aOptBlk\n");\r
-                                       break;\r
-                               case aLoopBegin :\r
-                                       fprintf(stderr,"aLoopBeginBlk\n");\r
-                                       break;\r
-                               case aLoopBlk :\r
-                                       fprintf(stderr,"aLoopBlk\n");\r
-                                       break;\r
-                               case aPlusBlk :\r
-                                       fprintf(stderr,"aPlusBlk\n");\r
-                                       break;\r
-                               case EndBlk :\r
-                                       fprintf(stderr,"EndBlk\n");\r
-                                       break;\r
-                               case RuleBlk :\r
-                                       fprintf(stderr,"RuleBlk\n");\r
-                                       break;\r
-                               case Generic :\r
-                                       fprintf(stderr,"Generic\n");\r
-                                       break;\r
-                               case EndRule :\r
-                                       fprintf(stderr,"EndRule\n");\r
-                                       break;\r
-                       }\r
-                       break;\r
-               case nRuleRef :\r
-                       r = (RuleRefNode *) alt;\r
-                       fprintf(stderr, "RuleRef(in %s)\n", r->rname);\r
-                       break;\r
-               case nToken :\r
-                       t = (TokNode *) alt;\r
-                       fprintf(stderr, "TokenNode(in %s)%s\n", t->rname, TokenString(t->token));\r
-                       break;\r
-               case nAction :\r
-                       fprintf(stderr, "Action\n");\r
-                       break;\r
-       }\r
-#endif\r
-\r
-       switch ( alt->ntype )\r
-       {\r
-               case nJunction :\r
-               {\r
-                       Predicate *a, *b;\r
-                       Junction *p = (Junction *) alt; \r
-\r
-                       /* lock nodes */\r
-                       if ( p->jtype==aLoopBlk || p->jtype==RuleBlk ||\r
-                                p->jtype==aPlusBlk || p->jtype==EndRule )\r
-                       {\r
-                               require(p->pred_lock!=NULL, "rJunc: lock array is NULL");\r
-                               if ( p->pred_lock[1] )\r
-                               {\r
-                                       return NULL;\r
-                               }\r
-                               p->pred_lock[1] = TRUE;\r
-                       }\r
-\r
-                       switch ( p->jtype )\r
-                       {\r
-                               case aSubBlk :\r
-                                       a = find_in_aSubBlk(p);\r
-                                       return a;       /* nothing is visible past this guy */\r
-                               case aOptBlk :\r
-                                       a = find_in_aOptBlk(p);\r
-                                       return a;\r
-                               case aLoopBegin :\r
-                                       a = find_in_aLoopBegin(p);\r
-                                       return a;\r
-                               case aLoopBlk :\r
-                                       a = find_in_aSubBlk(p);\r
-                                       p->pred_lock[1] = FALSE;\r
-                                       return a;\r
-                               case aPlusBlk :\r
-                                       a = find_in_aPlusBlk(p);\r
-                                       p->pred_lock[1] = FALSE;\r
-                                       return a;       /* nothing is visible past this guy */\r
-                               case RuleBlk :\r
-                                       a = find_predicates(p->p1);\r
-                                       p->pred_lock[1] = FALSE;\r
-                                       return a;\r
-                               case Generic :\r
-                                       a = find_predicates(p->p1);\r
-                                       b = find_predicates(p->p2);\r
-                                       if ( p->pred_lock!=NULL ) p->pred_lock[1] = FALSE;\r
-                                       if ( a==NULL ) return b;\r
-                                       if ( b==NULL ) return a;\r
-                                       /* otherwise OR the two preds together */\r
-                                       {\r
-                                       fatal_internal("hit unknown situation during predicate hoisting");\r
-                                       }\r
-                               case EndBlk :\r
-                               case EndRule :  /* Find no predicates after a rule ref */\r
-                                       return NULL;\r
-                               default:\r
-                                       fatal_internal("this cannot be printed\n");\r
-                                       break;\r
-                       }\r
-               }\r
-               case nAction :\r
-               {\r
-                       ActionNode *p = (ActionNode *) alt;\r
-            if ( p->noHoist) return NULL;                           /* MR12c */\r
-                       if ( p->init_action ) return find_predicates(p->next);\r
-                       if ( p->is_predicate )\r
-                       {\r
-                               Tree *t=NULL;\r
-#ifdef DBG_PRED\r
-                               fprintf(stderr, "predicate: <<%s>>?\n", p->action);\r
-#endif\r
-                               if ( p->guardpred!=NULL )\r
-                               {\r
-                                       pred = predicate_dup(p->guardpred);\r
-                    MR_guardPred_plainSet(p,pred);                  /* MR12c */\r
-                               }\r
-                               else\r
-                               {\r
-                                       pred = new_pred();\r
-                                       pred->k = predicateLookaheadDepth(p);\r
-                                       pred->source = p;\r
-                                       pred->expr = p->action;\r
-                                       if ( HoistPredicateContext && pred->k > 1 )\r
-                                       {\r
-                                               /* MR30 No need to use first_item_is_guess_block_extra\r
-                                                  since we know this is an action, not a (...)* or\r
-                                                  (...)+ block.\r
-                                               */\r
-\r
-                                               if ( first_item_is_guess_block((Junction *)p->next) )\r
-                                               {\r
-                            warnFL("cannot compute context of predicate in front of (..)? block",\r
-                            FileStr[p->file], p->line);\r
-                                               }\r
-                                               else\r
-                                               {\r
-                                                       ConstrainSearch = 0;\r
-/* MR11 */                  if (p->ampersandPred != NULL) {\r
-/* MR11 */                                     TRAV(p,\r
-/* MR11 */                                                      pred->k,\r
-/* MR11 */                                              &(pred->completionTree), t);\r
-/* MR11 */                  } else {\r
-                                                       TRAV(p->next,\r
-                                                                pred->k,\r
-                                                                &(pred->completionTree), t);\r
-                            };\r
-                                                       pred->tcontext = t;\r
-                            MR_check_pred_too_long(pred,pred->completionTree);\r
-#ifdef DBG_PRED\r
-                                                       fprintf(stderr, "LL(%d) context:", pred->k);\r
-                                                       preorder(t);\r
-                                                       fprintf(stderr, "\n");\r
-#endif\r
-                                               }\r
-                                       }\r
-                                       else if ( HoistPredicateContext && pred->k == 1 )\r
-                                       {\r
-                                               pred->scontext[1] = empty;\r
-                                               /* MR30 No need to use first_item_is_guess_block_extra\r
-                                                  since we know this is an action.\r
-                                               */\r
-                                               if ( first_item_is_guess_block((Junction *)p->next) )\r
-                                               {\r
-                        warnFL("cannot compute context of predicate in front of (..)? block",\r
-                                             FileStr[p->file], p->line);\r
-                                               }\r
-                                               else\r
-                                               {\r
-                                                       REACH((Junction *)p->next,\r
-                                                                 1,\r
-                                                                 &(pred->completionSet),\r
-                                                                 pred->scontext[1]);\r
-                            MR_check_pred_too_long(pred,pred->completionSet);\r
-#ifdef DBG_PRED\r
-                                                       fprintf(stderr, "LL(1) context:");\r
-                                                       s_fprT(stderr, pred->scontext[1]);\r
-                                                       fprintf(stderr, "\n");\r
-#endif\r
-                                               }\r
-                                       }\r
-                               }\r
-                               {\r
-                                       Predicate  *d = find_predicates(p->next);\r
-                    Predicate  *root;\r
-\r
-/* Warning: Doesn't seem like the up pointers will all be set correctly;\r
- * TJP: that's ok, we're not using them now.\r
- */\r
-                                       if ( d!=NULL )\r
-                                       {\r
-                                               root = new_pred();\r
-                                               root->expr = PRED_AND_LIST;\r
-                                               root->down = pred;\r
-                                               pred->right = d;\r
-                                               pred->up = root;\r
-                                               d->left = pred;\r
-                                               d->up = pred->up;\r
-                                               return root;\r
-                                       }\r
-                               }\r
-                               return pred;\r
-                       }\r
-                       return NULL;\r
-               }\r
-               case nRuleRef :\r
-               {\r
-                       Predicate   *a;\r
-                       RuleRefNode *p = (RuleRefNode *) alt;\r
-                       Junction    *r;\r
-            Junction    *save_MR_RuleBlkWithHalt;\r
-\r
-                       RuleEntry *q = (RuleEntry *) hash_get(Rname, p->text);\r
-                       if ( q == NULL )\r
-                       {\r
-                               warnFL( eMsg1("rule %s not defined",p->text), FileStr[p->file], p->line );\r
-                               return NULL;\r
-                       }\r
-                       r = RulePtr[q->rulenum];\r
-                       if ( r->pred_lock[1] )\r
-                       {\r
-                               /* infinite left-recursion; ignore 'cause LL sup 1 (k) analysis\r
-                                * must have seen it earlier.\r
-                                */\r
-                               return NULL;\r
-                       }\r
-\r
-            /* MR10 There should only be one halt set at a time.        */\r
-            /* MR10 Life would have been easier with a global variable  */\r
-            /* MR10    (at least for this particular need)              */\r
-            /* MR10 Unset the old one and set the new one, later undo.  */\r
-\r
-            require(r->end->halt == FALSE,"should only have one halt at a time");\r
-\r
-/* MR10 */  require(MR_RuleBlkWithHalt == NULL ||\r
-/* MR10 */          (MR_RuleBlkWithHalt->jtype == RuleBlk && MR_RuleBlkWithHalt->end->halt == TRUE),\r
-/* MR10 */             "RuleBlkWithHalt->end not RuleBlk or does not have halt set");\r
-/* MR10 */  if (MR_RuleBlkWithHalt != NULL) {\r
-/* MR10 */    MR_RuleBlkWithHalt->end->halt=FALSE;\r
-/* MR10 */  };\r
-\r
-/***        fprintf(stderr,"\nSetting halt on junction #%d\n",r->end->seq);     ***/\r
-\r
-            require(r->end->halt == FALSE,"rule->end->halt already set");\r
-\r
-            save_MR_RuleBlkWithHalt=MR_RuleBlkWithHalt;\r
-\r
-/* MR10 */  MR_pointerStackPush(&MR_RuleBlkWithHaltStack,MR_RuleBlkWithHalt);\r
-/* MR10 */  MR_pointerStackPush(&MR_PredRuleRefStack,p);\r
-\r
-                       r->end->halt = TRUE;\r
-/* MR10 */  MR_RuleBlkWithHalt=r;\r
-\r
-                       a = find_predicates((Node *)r);\r
-\r
-            require(r->end->halt == TRUE,"rule->end->halt not set");\r
-            r->end->halt = FALSE;\r
-\r
-/* MR10 */  MR_pointerStackPop(&MR_PredRuleRefStack);\r
-/* MR10 */  MR_RuleBlkWithHalt=(Junction *) MR_pointerStackPop(&MR_RuleBlkWithHaltStack);\r
-\r
-            require (MR_RuleBlkWithHalt==save_MR_RuleBlkWithHalt,\r
-                    "RuleBlkWithHaltStack not consistent");\r
-\r
-/* MR10 */  require(MR_RuleBlkWithHalt == NULL ||\r
-/* MR10 */          (MR_RuleBlkWithHalt->jtype == RuleBlk && MR_RuleBlkWithHalt->end->halt == FALSE),\r
-/* MR10 */             "RuleBlkWithHalt->end not RuleBlk or has no halt set");\r
-/* MR10 */  if (MR_RuleBlkWithHalt != NULL) {\r
-/* MR10 */    MR_RuleBlkWithHalt->end->halt=TRUE;\r
-/* MR10 */  };\r
-\r
-/***        fprintf(stderr,"\nRestoring halt on junction #%d\n",r->end->seq);   ***/\r
-\r
-                       if ( a==NULL ) return NULL;\r
-\r
-                       /* attempt to compute the "local" FOLLOW just like in normal lookahead\r
-                        * computation if needed\r
-                        */\r
-\r
-                       complete_context_sets(p,a);\r
-                       complete_context_trees(p,a);\r
-\r
-/* MR10 */  MR_cleanup_pred_trees(a);\r
-\r
-                       return a;\r
-               }\r
-               case nToken :\r
-                       break;\r
-       }\r
-\r
-       return NULL;\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-Predicate *MR_find_predicates_and_supp(Node *alt)\r
-#else\r
-Predicate *MR_find_predicates_and_supp(alt)\r
-  Node      *alt;\r
-#endif\r
-{\r
-    Predicate   *p;\r
-\r
-    p=find_predicates(alt);\r
-    p=MR_suppressK(alt,p);\r
-    return p;\r
-}\r
-\r
-Predicate *\r
-#ifdef __USE_PROTOS\r
-new_pred( void )\r
-#else\r
-new_pred( )\r
-#endif\r
-{\r
-       Predicate *p = (Predicate *) calloc(1,sizeof(Predicate)); /* MR10 */\r
-       require(p!=NULL, "new_pred: cannot alloc predicate");\r
-    p->scontext[0]=empty;\r
-    p->scontext[1]=empty;\r
-    p->completionTree=empty;\r
-    p->completionSet=empty;\r
-    p->plainSet=empty;\r
-       return p;\r
-}\r
-\r
-static void\r
-#ifdef __USE_PROTOS\r
-complete_context_sets( RuleRefNode *p, Predicate *a )\r
-#else\r
-complete_context_sets( p, a )\r
-RuleRefNode *p;\r
-Predicate *a;\r
-#endif\r
-{\r
-       set rk2, b;\r
-       int k2;\r
-\r
-#ifdef DBG_PRED\r
-       fprintf(stderr, "enter complete_context_sets\n");\r
-#endif\r
-       for (; a!=NULL; a=a->right)\r
-       {\r
-               if ( a->expr == PRED_AND_LIST || a->expr == PRED_OR_LIST )\r
-               {\r
-                       complete_context_sets(p,a->down);\r
-                       continue;\r
-               }\r
-               rk2 = b = empty;\r
-               while ( !set_nil(a->completionSet) )\r
-               {\r
-                       k2 = set_int(a->completionSet);\r
-                       set_rm(k2, a->completionSet);\r
-\r
-            REACH(p->next, k2, &rk2, b);\r
-                       set_orin(&(a->scontext[1]), b);\r
-                       set_free(b);\r
-               }\r
-\r
-               set_orin(&(a->completionSet), rk2);/* remember what we couldn't do */\r
-               set_free(rk2);\r
-#ifdef DBG_PRED\r
-               fprintf(stderr, "LL(1) context for %s(addr 0x%x) after ruleref:", a->expr, a);\r
-               s_fprT(stderr, a->scontext[1]);\r
-               fprintf(stderr, "\n");\r
-#endif\r
-/*             complete_context_sets(p, a->down);*/\r
-       }\r
-#ifdef DBG_PRED\r
-       fprintf(stderr, "exit complete_context_sets\n");\r
-#endif\r
-}\r
-\r
-static void\r
-#ifdef __USE_PROTOS\r
-complete_context_trees( RuleRefNode *p, Predicate *a )\r
-#else\r
-complete_context_trees( p, a )\r
-RuleRefNode *p;\r
-Predicate *a;\r
-#endif\r
-{\r
-       set rk2;\r
-       int k2;\r
-       Tree *u;\r
-\r
-#ifdef DBG_PRED\r
-       fprintf(stderr, "enter complete_context_trees\n");\r
-#endif\r
-       for (; a!=NULL; a=a->right)\r
-       {\r
-               if ( a->expr == PRED_AND_LIST || a->expr == PRED_OR_LIST )\r
-               {\r
-                       complete_context_trees(p, a->down);\r
-                       continue;\r
-               }\r
-               rk2 = empty;\r
-\r
-               /* any k left to do? if so, link onto tree */\r
-               while ( !set_nil(a->completionTree) )\r
-               {       \r
-                       k2 = set_int(a->completionTree);\r
-                       set_rm(k2, a->completionTree);\r
-                       u = NULL;\r
-\r
-            TRAV(p->next, k2, &rk2, u);\r
-\r
-                       /* any subtrees missing k2 tokens, add u onto end */\r
-                       a->tcontext = tlink(a->tcontext, u, k2);\r
-            Tfree(u);   /* MR10 */\r
-               }\r
-               set_orin(&(a->completionTree), rk2);/* remember what we couldn't do */\r
-               set_free(rk2);\r
-#ifdef DBG_PRED\r
-               fprintf(stderr, "LL(i<%d) context after ruleref:", LL_k);\r
-               preorder(a->tcontext);\r
-               fprintf(stderr, "\n");\r
-#endif\r
-/*             complete_context_trees(p, a->down);*/\r
-       }\r
-#ifdef DBG_PRED\r
-       fprintf(stderr, "exit complete_context_trees\n");\r
-#endif\r
-}\r
-\r
-/* Walk a list of predicates and return the set of all tokens in scontext[1]'s */\r
-set\r
-#ifdef __USE_PROTOS\r
-covered_set( Predicate *p )\r
-#else\r
-covered_set( p )\r
-Predicate *p;\r
-#endif\r
-{\r
-       set a;\r
-\r
-       a = empty;\r
-       for (; p!=NULL; p=p->right)\r
-       {\r
-               if ( p->expr == PRED_AND_LIST || p->expr == PRED_OR_LIST )\r
-               {\r
-                       set_orin(&a, covered_set(p->down));\r
-                       continue;\r
-               }\r
-               set_orin(&a, p->scontext[1]);\r
-               set_orin(&a, covered_set(p->down));\r
-       }\r
-       return a;\r
-}\r
-\r
-/* MR10 predicate_free()\r
-   MR10 Don't free the leaf nodes since they are part of the action node\r
-*/\r
-\r
-#ifdef __USE_PROTOS\r
-void predicate_free(Predicate *p)\r
-#else\r
-void predicate_free(p)\r
-  Predicate     *p;\r
-#endif\r
-{\r
-  if (p == NULL) return;\r
-  predicate_free(p->right);\r
-  predicate_free(p->down);\r
-  if (p->cloned ||\r
-      p->source == NULL ||\r
-      p->source->guardpred == NULL ||\r
-      p->expr == PRED_AND_LIST ||\r
-      p->expr == PRED_OR_LIST) {\r
-    set_free(p->scontext[1]);\r
-    set_free(p->completionSet);\r
-    set_free(p->completionTree);\r
-    set_free(p->plainSet);\r
-    Tfree(p->tcontext);\r
-    free( (char *) p);\r
-  } else {\r
-    p->right=NULL;\r
-    p->down=NULL;  /* MR13 *** debug */\r
-  };\r
-}\r
-\r
-/* MR10 predicate_dup() */\r
-\r
-#ifdef __USE_PROTOS\r
-Predicate * predicate_dup_xxx(Predicate *p,int contextToo)\r
-#else\r
-Predicate * predicate_dup_xxx(p,contextToo)\r
-  Predicate     *p;\r
-  int           contextToo;\r
-#endif\r
-{\r
-  Predicate     *q;\r
-\r
-  if (p == NULL) return NULL;\r
-  q=new_pred();\r
-  q->down=predicate_dup(p->down);\r
-  q->right=predicate_dup(p->right);\r
-\r
-  /*\r
-     don't replicate expr - it is read-only\r
-     and address comparison is used to look\r
-     for identical predicates.\r
-  */\r
-\r
-  q->expr=p->expr;\r
-  q->k=p->k;\r
-  q->source=p->source;\r
-  q->cloned=1;\r
-  q->ampersandStyle=p->ampersandStyle;\r
-  q->inverted=p->inverted;\r
-  q->predEntry=p->predEntry;\r
-  q->plainSet=set_dup(p->plainSet);\r
-\r
-  if (contextToo) {\r
-    q->tcontext=tdup(p->tcontext);\r
-    q->scontext[0]=set_dup(p->scontext[0]);\r
-    q->scontext[1]=set_dup(p->scontext[1]);\r
-    q->completionTree=set_dup(p->completionTree);\r
-    q->completionSet=set_dup(p->completionSet);\r
-  };\r
-\r
-  /* don't need to dup "redundant" */\r
-\r
-  return q;\r
-\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-Predicate * predicate_dup_without_context(Predicate *p)\r
-#else\r
-Predicate * predicate_dup_without_context(p)\r
-  Predicate     *p;\r
-#endif\r
-{\r
-  return predicate_dup_xxx(p,0);\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-Predicate * predicate_dup(Predicate *p)\r
-#else\r
-Predicate * predicate_dup(p)\r
-  Predicate     *p;\r
-#endif\r
-{\r
-  return predicate_dup_xxx(p,1);\r
-}\r
-\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/antlr/proto.h b/Tools/CodeTools/TianoTools/Pccts/antlr/proto.h
deleted file mode 100644 (file)
index 53035e7..0000000
+++ /dev/null
@@ -1,852 +0,0 @@
-/*\r
- * proto.h -- function prototypes\r
- *\r
- * SOFTWARE RIGHTS\r
- *\r
- * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
- * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
- * company may do whatever they wish with source code distributed with\r
- * PCCTS or the code generated by PCCTS, including the incorporation of\r
- * PCCTS, or its output, into commerical software.\r
- *\r
- * We encourage users to develop software with PCCTS.  However, we do ask\r
- * that credit is given to us for developing PCCTS.  By "credit",\r
- * we mean that if you incorporate our source code into one of your\r
- * programs (commercial product, research project, or otherwise) that you\r
- * acknowledge this fact somewhere in the documentation, research report,\r
- * etc...  If you like PCCTS and have developed a nice tool with the\r
- * output, please mention that you developed it using PCCTS.  In\r
- * addition, we ask that this header remain intact in our source code.\r
- * As long as these guidelines are kept, we expect to continue enhancing\r
- * this system and expect to make other tools available as they are\r
- * completed.\r
- *\r
- * ANTLR 1.33\r
- * Terence Parr\r
- * Parr Research Corporation\r
- * with Purdue University and AHPCRC, University of Minnesota\r
- * 1989-2001\r
- */\r
-\r
-                           /* V a r i a b l e s */\r
-\r
-extern int tp;\r
-extern Junction *SynDiag;\r
-extern char Version[];\r
-extern char VersionDef[];\r
-#ifdef __cplusplus\r
-extern void (*fpPrint[])(...);\r
-#else\r
-extern void (*fpPrint[])();\r
-#endif\r
-#ifdef __cplusplus\r
-extern struct _set (*fpReach[])(...);\r
-#else\r
-extern struct _set (*fpReach[])();\r
-#endif\r
-#ifdef __cplusplus\r
-extern struct _tree *(*fpTraverse[])(...);\r
-#else\r
-extern struct _tree *(*fpTraverse[])();\r
-#endif\r
-#ifdef __cplusplus\r
-extern void (**fpTrans)(...);\r
-#else\r
-extern void (**fpTrans)();\r
-#endif\r
-#ifdef __cplusplus\r
-extern void (**fpJTrans)(...);\r
-#else\r
-extern void (**fpJTrans)();\r
-#endif\r
-#ifdef __cplusplus\r
-extern void (*C_Trans[NumNodeTypes+1])(...);\r
-#else\r
-extern void (*C_Trans[])();\r
-#endif\r
-#ifdef __cplusplus\r
-extern void (*C_JTrans[NumJuncTypes+1])(...);\r
-#else\r
-extern void (*C_JTrans[])();\r
-#endif\r
-extern int BlkLevel;\r
-extern int CurFile;\r
-extern char *CurPredName;\r
-extern char *CurRule;\r
-extern int  CurRuleDebug;                       /* MR13 */\r
-extern Junction *CurRuleBlk;\r
-extern RuleEntry *CurRuleNode;\r
-extern ListNode *CurElementLabels;\r
-extern ListNode *CurAstLabelsInActions;         /* MR27 */\r
-extern ListNode *ContextGuardPredicateList;     /* MR13 */\r
-extern ListNode *CurActionLabels;\r
-extern int numericActionLabel;        /* MR10 << ... $1 ... >> or << ... $1 ... >>?   */\r
-extern ListNode *NumericPredLabels;   /* MR10 << ... $1 ... >>?  ONLY                 */\r
-extern char *FileStr[];\r
-extern int NumFiles;\r
-extern int EpToken;\r
-extern int WildCardToken;\r
-extern Entry   **Tname,\r
-                               **Texpr,\r
-                               **Rname,\r
-                               **Fcache,\r
-                               **Tcache,\r
-                               **Elabel,\r
-                               **Sname,\r
-                **Pname;    /* MR11 */\r
-extern ListNode *ExprOrder;\r
-extern ListNode **Cycles;\r
-extern int TokenNum;\r
-extern int LastTokenCounted;\r
-extern ListNode *BeforeActions, *AfterActions, *LexActions;\r
-\r
-/* MR1                                                                                             */\r
-/* MR1  11-Apr-97      Provide mechanism for inserting code into DLG class     */\r
-/* MR1                   via #lexmember <<....>> & #lexprefix <<...>>              */\r
-/* MR1                                                                     */\r
-\r
-extern ListNode *LexMemberActions;                                          /* MR1 */\r
-extern ListNode *LexPrefixActions;                                          /* MR1 */\r
-\r
-extern set *fset;   /* for constrained search */             /* MR11 */\r
-extern int maxk;    /* for constrained search */             /* MR11 */\r
-extern int Save_argc;                                        /* MR10 */\r
-extern char **Save_argv;                                     /* MR10 */\r
-extern ListNode *eclasses, *tclasses;\r
-extern char    *HdrAction;\r
-extern char *FirstAction;                                    /* MR11 */\r
-extern FILE    *ErrFile;\r
-extern char *RemapFileName;\r
-extern char *ErrFileName;\r
-extern char *DlgFileName;\r
-extern char *DefFileName;\r
-extern char *ModeFileName;\r
-extern char *StdMsgName;\r
-extern int NumRules;\r
-extern Junction **RulePtr;\r
-extern int LL_k;\r
-extern int CLL_k;\r
-extern char *decodeJType[];\r
-extern int PrintOut;\r
-extern int PrintAnnotate;\r
-extern int CodeGen;\r
-extern int LexGen;\r
-extern int esetnum;\r
-extern int setnum;\r
-extern int wordnum;\r
-extern int GenAST;\r
-extern int GenANSI;\r
-extern int **FoStack;\r
-extern int **FoTOS;\r
-extern int GenExprSetsOpt;\r
-extern FILE *DefFile;\r
-extern int CannotContinue;\r
-extern int GenCR;\r
-extern int GenLineInfo;\r
-extern int GenLineInfoMS;\r
-extern int action_file, action_line;\r
-extern int TraceGen;\r
-extern int CurAmbigAlt1, CurAmbigAlt2, CurAmbigline, CurAmbigfile;\r
-extern char *CurAmbigbtype;\r
-extern int elevel;\r
-extern int GenEClasseForRules;\r
-extern FILE *input, *output;\r
-extern char **TokenStr, **ExprStr;\r
-extern int CurrentLexClass, NumLexClasses;\r
-extern LClass lclass[];\r
-extern char LexStartSymbol[];\r
-extern char    *CurRetDef;\r
-extern char    *CurParmDef;\r
-extern int OutputLL_k;\r
-extern int TreeResourceLimit;\r
-extern int DemandLookahead;\r
-extern char *RulePrefix;\r
-extern int GenStdPccts;\r
-extern char *stdpccts;\r
-extern int ParseWithPredicates;\r
-extern int ConstrainSearch;\r
-extern int PURIFY;                                                                                                     /* MR23 */\r
-\r
-extern set MR_CompromisedRules;                                     /* MR14 */\r
-extern int MR_AmbSourceSearch;                                      /* MR11 */\r
-extern int MR_SuppressSearch;                                       /* MR13 */\r
-extern int MR_AmbSourceSearchGroup;                                 /* MR11 */\r
-extern int MR_AmbSourceSearchChoice;                                /* MR11 */\r
-extern int MR_AmbSourceSearchLimit;                                 /* MR11 */\r
-extern int MR_usingPredNames;                                       /* MR11 */\r
-extern int MR_ErrorSetComputationActive;                            /* MR14 */\r
-extern char *MR_AmbAidRule;                                         /* MR11 */\r
-extern int   MR_AmbAidLine;                                         /* MR11 */\r
-extern int   MR_AmbAidMultiple;                                     /* MR11 */\r
-extern int MR_AmbAidDepth;                                          /* MR11 */\r
-extern int MR_skipped_e3_report;                                    /* MR11 */\r
-extern int MR_matched_AmbAidRule;                                   /* MR11 */\r
-extern int MR_Inhibit_Tokens_h_Gen;                                 /* MR13 */\r
-extern int NewAST;                                                  /* MR13 */\r
-extern int tmakeInParser;                                           /* MR23 */\r
-extern int AlphaBetaTrace;                                          /* MR14 */\r
-extern int MR_BlkErr;                                               /* MR21 */\r
-extern int MR_AlphaBetaWarning;                                     /* MR14 */\r
-extern int MR_AlphaBetaMessageCount;                                /* MR14 */\r
-extern int MR_MaintainBackTrace;                                    /* MR14 */\r
-extern int MR_BadExprSets;                                          /* MR13 */\r
-extern int FoundGuessBlk;\r
-extern int FoundException;\r
-extern int FoundAtOperator;                                                         /* MR6 */\r
-extern int FoundExceptionGroup;                                      /* MR6 */\r
-extern int WarningLevel;\r
-extern int UseStdout;                                                               /* MR6 */\r
-extern int TabWidth;                                                                /* MR6 */\r
-extern int pLevel;\r
-extern int pAlt1;\r
-extern int pAlt2;\r
-extern int AImode;\r
-extern int HoistPredicateContext;\r
-extern int MRhoisting;                                               /* MR9 */\r
-extern int MRhoistingk;                                              /* MR13 */\r
-extern int MR_debugGenRule;                                          /* MR11 */\r
-extern int GenCC;\r
-extern char *ParserName;\r
-extern char *StandardSymbols[];\r
-extern char *ASTSymbols[];\r
-extern set reserved_positions;\r
-extern set all_tokens;\r
-extern set imag_tokens;\r
-extern set tokclasses;\r
-extern ListNode *ForcedTokens;\r
-extern int *TokenInd;\r
-extern FILE *Parser_h, *Parser_c;\r
-extern char CurrentClassName[];\r
-extern int no_classes_found;\r
-extern char Parser_h_Name[];\r
-extern char Parser_c_Name[];\r
-extern char MRinfoFile_Name[];                                      /* MR10 */\r
-extern FILE *MRinfoFile;                                            /* MR10 */\r
-extern int MRinfo;                                                  /* MR10 */\r
-extern int MRinfoSeq;                                               /* MR10 */\r
-extern int InfoP;                                                   /* MR10 */\r
-extern int InfoT;                                                   /* MR10 */\r
-extern int InfoF;                                                   /* MR10 */\r
-extern int InfoM;                                                   /* MR10 */\r
-extern int InfoO;                                                   /* MR12 */\r
-extern int PotentialSuppression;                                    /* MR10 */\r
-extern int PotentialDummy;                                          /* MR10 */\r
-extern int TnodesInUse;                                             /* MR10 */\r
-extern int TnodesPeak;                                              /* MR10 */\r
-extern int TnodesReportThreshold;                                   /* MR11 */\r
-extern int TnodesAllocated;                                         /* MR10 */\r
-extern char *ClassDeclStuff;                                        /* MR10 */\r
-extern char *BaseClassName;                                         /* MR22 */\r
-extern ListNode *class_before_actions, *class_after_actions;\r
-extern char *UserTokenDefsFile;\r
-extern int UserDefdTokens;\r
-extern ListNode *MetaTokenNodes;\r
-extern char *OutputDirectory;\r
-extern int DontCopyTokens;\r
-extern int LTinTokenAction;                                         /* MR23 */\r
-extern set AST_nodes_refd_in_actions;\r
-extern ListNode *CurExGroups;\r
-extern int CurBlockID;\r
-extern int CurAltNum;\r
-extern Junction *CurAltStart;\r
-extern Junction *OuterAltStart;               /* chain exception groups MR7 */\r
-extern ExceptionGroup *DefaultExGroup;\r
-extern int NumSignals;\r
-extern int ContextGuardTRAV;\r
-extern Junction *MR_RuleBlkWithHalt;            /* MR10 */\r
-extern PointerStack MR_BackTraceStack;          /* MR10 */\r
-extern PointerStack MR_PredRuleRefStack;        /* MR10 */\r
-extern PointerStack MR_RuleBlkWithHaltStack;    /* MR10 */\r
-\r
-/*                                                                     */\r
-/* MR1 10-Apr-97  MR1  Previously unable to put right shift operator       */\r
-/* MR1                                 in DLG action                                       */\r
-/*                                                                                                         */\r
-extern int tokenActionActive;                                       /* MR1 */\r
-\r
-extern char *PRED_OR_LIST;                                          /* MR10 */\r
-extern char *PRED_AND_LIST;                                         /* MR10 */\r
-\r
-#ifdef __VMS\r
-#define STRICMP strcasecmp /* MR21 */\r
-#else\r
-#define STRICMP stricmp /* MR21 */\r
-#endif\r
-\r
-/* MR26 */\r
-#ifdef PCCTS_USE_STDARG\r
-extern Tree *tmake(Tree *root, ...);\r
-#else\r
-extern Tree *tmake();\r
-#endif\r
-\r
-#ifdef __USE_PROTOS\r
-extern int STRICMP(const char*, const char*);\r
-extern void istackreset(void);\r
-extern int istacksize(void);\r
-extern void pushint(int);\r
-extern int popint( void );\r
-extern int istackempty( void );\r
-extern int topint( void );\r
-extern void NewSetWd( void );\r
-extern void DumpSetWd( void );\r
-extern void DumpSetWdForC( void );\r
-extern void DumpSetWdForCC( void );\r
-extern void NewSet( void );\r
-extern void FillSet( set );\r
-extern void ComputeErrorSets( void );\r
-extern void ComputeTokSets( void );\r
-extern void SubstErrorClass( set * );\r
-extern int DefErrSet( set *, int, char * );\r
-extern int DefErrSetForC( set *, int, char * );\r
-extern int DefErrSetForCC( set *, int, char * );\r
-extern int DefErrSet1(int, set *, int, char *);                         /* MR21 */\r
-extern int DefErrSetForC1(int, set *, int, char *, const char* );       /* MR21 */\r
-extern int DefErrSetForCC1(int, set *, int, char *, const char* );      /* MR21 */\r
-extern int DefErrSetWithSuffix(int, set *, int, char *, const char *);  /* MR21 */\r
-extern void GenErrHdr( void );\r
-extern void dumpExpr( FILE *, char * );\r
-extern void addParm( Node *, char * );\r
-extern Graph buildAction( char *, int, int, int );\r
-extern Graph buildToken( char * );\r
-extern Graph buildWildCard( char * );\r
-extern Graph buildRuleRef( char * );\r
-extern Graph Or( Graph, Graph );\r
-extern Graph Cat( Graph, Graph );\r
-extern Graph makeOpt( Graph, int, char *);\r
-extern Graph makeBlk( Graph, int, char *);\r
-extern Graph makeLoop( Graph, int, char *);\r
-extern Graph makePlus( Graph, int, char *);\r
-extern Graph emptyAlt( void );\r
-extern Graph emptyAlt3( void );\r
-extern TokNode * newTokNode( void );\r
-extern RuleRefNode * newRNode( void );\r
-extern Junction * newJunction( void );\r
-extern ActionNode * newActionNode( void );\r
-extern char * makelocks( void );\r
-extern void preorder( Tree * );\r
-extern Tree * tnode( int );\r
-extern void _Tfree( Tree * );\r
-extern Tree * tdup( Tree * );\r
-extern int is_single_tuple( Tree * );\r
-extern Tree * tappend( Tree *, Tree * );\r
-extern void Tfree( Tree * );\r
-extern Tree * tlink( Tree *, Tree *, int );\r
-extern Tree * tshrink( Tree * );\r
-extern Tree * tflatten( Tree * );\r
-extern Tree * tJunc( Junction *, int, set * );\r
-extern Tree * tRuleRef( RuleRefNode *, int, set * );\r
-extern Tree * tToken( TokNode *, int, set * );\r
-extern Tree * tAction( ActionNode *, int, set * );\r
-extern int tmember( Tree *, Tree * );\r
-extern int tmember_constrained( Tree *, Tree * );\r
-extern Tree * tleft_factor( Tree * );\r
-extern Tree * trm_perm( Tree *, Tree * );\r
-extern void tcvt( set *, Tree * );\r
-extern Tree * permute( int, int );\r
-extern Tree * VerifyAmbig( Junction *, Junction *, unsigned **, set *, Tree **, Tree **, int * );\r
-extern set rJunc( Junction *, int, set * );\r
-extern set rRuleRef( RuleRefNode *, int, set * );\r
-extern set rToken( TokNode *, int, set * );\r
-extern set rAction( ActionNode *, int, set * );\r
-extern void HandleAmbiguity( Junction *, Junction *, Junction *, int );\r
-extern set First( Junction *, int, int, int * );\r
-extern void freeBlkFsets( Junction * );\r
-extern void genAction( ActionNode * );\r
-extern void genRuleRef( RuleRefNode * );\r
-extern void genToken( TokNode * );\r
-extern void genOptBlk( Junction * );\r
-extern void genLoopBlk( Junction *, Junction *, Junction *, int );\r
-extern void genLoopBegin( Junction * );\r
-extern void genPlusBlk( Junction * );\r
-extern void genSubBlk( Junction * );\r
-extern void genRule( Junction * );\r
-extern void genJunction( Junction * );\r
-extern void genEndBlk( Junction * );\r
-extern void genEndRule( Junction * );\r
-extern void genHdr( int );\r
-extern void genHdr1( int );\r
-extern void dumpAction( char *, FILE *, int, int, int, int );\r
-extern void dumpActionPlus(ActionNode*, char *, FILE *, int, int, int, int );   /* MR21 */\r
-extern Entry ** newHashTable( void );\r
-extern Entry * hash_add( Entry **, char *, Entry * );\r
-extern Entry * hash_get( Entry **, char * );\r
-extern void hashStat( Entry ** );\r
-extern char * mystrdup( char * );\r
-extern void genLexDescr( void );\r
-extern void dumpLexClasses( FILE * );\r
-extern void genDefFile( void );\r
-extern void DumpListOfParmNames( char *, FILE *, int );        /* MR5 janm 26-May-97 */\r
-extern int DumpNextNameInDef( char **, FILE * );\r
-extern void DumpOldStyleParms( char *, FILE * );\r
-extern void DumpType( char *, FILE * );\r
-extern int strmember( char *, char * );\r
-/* extern int HasComma( char * ); MR23 Replaced by hasMultipleOperands() */\r
-extern void DumpRetValStruct( FILE *, char *, int );\r
-extern char * StripQuotes( char * );\r
-extern int main( int, char *[] );\r
-extern void readDescr( void );\r
-extern FILE * NextFile( void );\r
-extern char * outnameX( char *, char *);\r
-extern char * outname( char * );\r
-extern void fatalFL( char *, char *, int );\r
-extern void fatal_intern( char *, char *, int );\r
-extern void cleanUp( void );\r
-extern char * eMsg3( char *, char *, char *, char * );\r
-extern char * eMsgd( char *, int );\r
-extern char * eMsgd2( char *, int, int );\r
-extern void s_fprT( FILE *, set );\r
-extern char * TerminalString( int );\r
-extern void lexclass( char * );\r
-extern void lexmode( int );\r
-extern int LexClassIndex( char * );\r
-extern int hasAction( char * );\r
-extern void setHasAction( char *, char * );\r
-extern int addTname( char * );\r
-extern int addTexpr( char * );\r
-extern int Tnum( char * );\r
-extern void Tklink( char *, char * );\r
-extern Entry * newEntry( char *, int );\r
-extern void list_add( ListNode **, void * );\r
-extern void list_free( ListNode **, int freeData );     /* MR10 */\r
-extern void list_apply( ListNode *, void (*)(void *) );\r
-extern int list_search_cstring (ListNode *, char *);    /* MR27 */\r
-extern char * Fkey( char *, int, int );\r
-extern void FoPush( char *, int );\r
-extern void FoPop( int );\r
-extern void RegisterCycle( char *, int );\r
-extern void ResolveFoCycles( int );\r
-extern void pJunc( Junction * );\r
-extern void pRuleRef( RuleRefNode * );\r
-extern void pToken( TokNode * );\r
-extern void pAction( ActionNode * );\r
-extern void FoLink( Node * );\r
-extern void addFoLink( Node *, char *, Junction * );\r
-extern void GenCrossRef( Junction * );\r
-extern void defErr( char *, long, long, long, long, long, long );\r
-extern void genStdPCCTSIncludeFile(FILE *,char *);                  /* MR10 */\r
-extern char * pcctsBaseName(char *);                                /* MR32 */\r
-extern Predicate *find_predicates(Node *);                          /* MR10 */\r
-extern Predicate *MR_find_predicates_and_supp(Node *);              /* MR13 */\r
-extern int predicateLookaheadDepth(ActionNode *);                   /* MR10 */\r
-extern void predicate_free(Predicate *);                            /* MR10 */\r
-extern Predicate * predicate_dup(Predicate *);                      /* MR10 */\r
-extern Predicate * predicate_dup_without_context(Predicate *);      /* MR11 */\r
-extern void GenRulePrototypes(FILE *, Junction *);\r
-extern Junction *first_item_is_guess_block(Junction *);\r
-extern Junction *first_item_is_guess_block_extra(Junction * q);                /* MR30 */\r
-extern Junction *analysis_point(Junction *);\r
-extern Tree *make_tree_from_sets(set *, set *);\r
-extern Tree *tdup_chain(Tree *);\r
-extern Tree *tdif(Tree *, Predicate *, set *, set *);\r
-extern set covered_set(Predicate *);\r
-extern void AmbiguityDialog(Junction *, int, Junction *, Junction *, int *, int *);\r
-extern void dumpAmbigMsg(set *, FILE *, int);\r
-extern void GenRuleFuncRedefs(FILE *, Junction *);\r
-extern void GenPredefinedSymbolRedefs(FILE *);\r
-extern void GenASTSymbolRedefs(FILE *);\r
-extern void GenRemapFile(void);\r
-extern void GenSetRedefs(FILE *);\r
-extern ForcedToken *newForcedToken(char *, int);\r
-extern void RemapForcedTokens(void);\r
-extern char *TokenOrExpr(int);\r
-extern void setUpperRange(TokNode *, char *);\r
-extern void GenParser_c_Hdr(void);\r
-extern void GenParser_h_Hdr(void);\r
-extern void GenRuleMemberDeclarationsForCC(FILE *, Junction *);\r
-extern int addForcedTname( char *, int );\r
-extern char *OutMetaName(char *);\r
-extern void OutFirstSetSymbol(Junction *q, char *);                 /* MR21 */\r
-extern void warnNoFL(char *err);\r
-extern void warnFL(char *err,char *f,int l);\r
-extern void warn(char *err);\r
-extern void warnNoCR( char *err );\r
-extern void errNoFL(char *err);\r
-extern void errFL(char *err,char *f,int l);\r
-extern void err(char *err);\r
-extern void errNoCR( char *err );\r
-extern void genPredTree( Predicate *p, Node *j, int ,int);\r
-extern UserAction *newUserAction(char *);\r
-extern char *gate_symbol(char *name);\r
-extern char *makeAltID(int blockid, int altnum);\r
-extern void DumpRemainingTokSets(void);\r
-extern void DumpANSIFunctionArgDef(FILE *f, Junction *q, int bInit);  /* MR23 */\r
-extern void DumpFormals(FILE *, char *, int bInit);                   /* MR23 */\r
-extern char* hideDefaultArgs(const char* pdecl);                      /* MR22 VHS */\r
-extern Predicate *computePredFromContextGuard(Graph,int *msgDone);    /* MR21 */\r
-extern void recomputeContextGuard(Predicate *);                       /* MR13 */\r
-extern Predicate *new_pred(void);\r
-extern void chkGTFlag(void);\r
-extern void leAdd(LabelEntry *);                                     /* MR7 */\r
-extern void leFixup(void);                                           /* MR7 */\r
-extern void egAdd(ExceptionGroup *);                                 /* MR7 */\r
-extern void egFixup(void);                                           /* MR7 */\r
-extern void altAdd(Junction *);                                      /* MR7 */\r
-extern void altFixup(void);                                          /* MR7 */\r
-extern Predicate * MR_find_in_aSubBlk(Junction *alt);                /* MR10 */\r
-extern Predicate * MR_predFlatten(Predicate *p);                                    /* MR10 */\r
-extern Predicate * MR_predSimplifyALL(Predicate *p);                /* MR10 */\r
-extern Predicate * MR_predSimplifyALLX(Predicate *p,int skipPass3);  /* MR10 */\r
-extern int MR_allPredLeaves(Predicate *p);                           /* MR10 */\r
-extern void MR_cleanup_pred_trees(Predicate *p);                     /* MR10 */\r
-extern int MR_predicate_context_completed(Predicate *p);             /* MR10 */\r
-extern void MR_check_pred_too_long(Predicate *p,set completion);     /* MR10 */\r
-extern Tree * MR_remove_epsilon_from_tree(Tree *t);                  /* MR10 */\r
-extern Tree * MR_computeTreeAND(Tree *l,Tree *r);                                       /* MR10 */\r
-extern int MR_tree_equ(Tree *big, Tree *small);                                         /* MR10 */\r
-extern set MR_First(int ck,Junction *j,set *incomplete);                    /* MR10 */\r
-extern set MR_compute_pred_set(Predicate *p);                       /* MR10 */\r
-extern Tree * MR_compute_pred_tree_context(Predicate *p);           /* MR10 */\r
-extern int MR_pointerStackPush(PointerStack *,void *);               /* MR10 */\r
-extern void * MR_pointerStackPop(PointerStack *);                    /* MR10 */\r
-extern void * MR_pointerStackTop(PointerStack *);                    /* MR10 */\r
-extern void MR_pointerStackReset(PointerStack *);                    /* MR10 */\r
-extern void MR_backTraceReport(void);                                /* MR10 */\r
-extern void MR_alphaBetaTraceReport(void);                           /* MR14 */\r
-extern void MR_dumpRuleSet(set);                                     /* MR14 */\r
-extern void MR_predContextPresent(Predicate *p,int *,int *);         /* MR10 */\r
-extern void MR_dumpPred(Predicate *p,int withContext);               /* MR10 */\r
-extern void MR_dumpPred1(int,Predicate *p,int withContext);          /* MR10 */\r
-extern void MR_xxxIndent(FILE *f,int depth);                         /* MR11 */\r
-extern void MR_outputIndent(int depth);                              /* MR11 */\r
-extern void MR_stderrIndent(int depth);                              /* MR11 */\r
-extern Junction * MR_ruleReferenced(RuleRefNode *rrn);               /* MR10 */\r
-extern Junction * MR_nameToRuleBlk(char *);                          /* MR10 */\r
-extern void MR_releaseResourcesUsedInRule(Node *);                   /* MR10 */\r
-extern void MR_dumpTreeX(int depth,Tree *t,int across);              /* MR10 */\r
-extern void MR_dumpTreeF(FILE *f,int depth,Tree *t,int across);      /* MR10 */\r
-extern void DumpFcache(void);                                        /* MR10 */\r
-extern void MR_dumpTokenSet(FILE *f,int depth,set s);                /* MR10 */\r
-extern void MR_traceAmbSource(set *,Junction *,Junction *);          /* MR11 */\r
-extern void MR_traceAmbSourceK(Tree *,Junction *a1,Junction *a2);    /* MR11 */\r
-extern void MR_traceAmbSourceKclient(void);                          /* MR20 */\r
-extern Node *MR_advance(Node *);                                     /* MR11 */\r
-extern int  MR_offsetFromRule(Node *);                               /* MR11 */\r
-extern char *MR_ruleNamePlusOffset(Node *);                          /* MR11 */\r
-extern int  MR_max_height_of_tree(Tree *);                           /* MR11 */\r
-extern int  MR_all_leaves_same_height(Tree *,int);                   /* MR11 */\r
-extern void MR_projectTreeOntoSet(Tree *t,int k,set *);              /* MR11 */\r
-extern Tree *MR_make_tree_from_set(set);                             /* MR11 */\r
-extern Predicate *MR_removeRedundantPredPass3(Predicate *);          /* MR11 */\r
-extern void MR_pred_depth(Predicate *,int *);                        /* MR11 */\r
-extern int  MR_comparePredicates(Predicate *,Predicate *);           /* MR11 */\r
-extern Predicate * MR_unfold(Predicate *);                           /* MR11 */\r
-extern void MR_simplifyInverted(Predicate *,int);                    /* MR11 */\r
-extern int  MR_secondPredicateUnreachable                            /* MR11 */\r
-            (Predicate *first,Predicate *second);                    /* MR11 */\r
-extern void MR_clearPredEntry(Predicate *);                          /* MR11 */\r
-extern void MR_orphanRules(FILE *);                                  /* MR12 */\r
-extern void MR_merge_contexts(Tree *);                               /* MR12 */\r
-extern int  ci_strequ(char *,char *);                                 /* MR12 */\r
-extern void MR_guardPred_plainSet(ActionNode *anode,Predicate *);    /* MR12c */\r
-extern void MR_suppressSearchReport(void);                           /* MR12c */\r
-extern Predicate * MR_suppressK(Node *,Predicate *);                 /* MR13 */\r
-extern void MR_backTraceDumpItem(FILE *,int skip,Node *n);           /* MR13 */\r
-extern void MR_backTraceDumpItemReset(void);                         /* MR13 */\r
-extern Junction * MR_junctionWithoutP2(Junction *);                  /* MR13 */\r
-extern void MR_setConstrainPointer(set *);                                                      /* MR18 */\r
-extern void BlockPreambleOption(Junction *q, char * pSymbol);        /* MR23 */\r
-extern char* getInitializer(char *);                                 /* MR23 */\r
-extern char *endFormal(char *pStart,                                 /* MR23 */\r
-                                          char **ppDataType,                            /* MR23 */\r
-                                          char **ppSymbol,                              /* MR23 */\r
-                                          char **ppEqualSign,                           /* MR23 */\r
-                                          char **ppValue,                               /* MR23 */\r
-                                          char **ppSeparator,                           /* MR23 */\r
-                                          int *pNext);                                  /* MR23 */\r
-extern char *strBetween(char *pStart,                                /* MR23 */\r
-                                               char *pNext,                                 /* MR23 */\r
-                                               char *pStop);                                /* MR23 */\r
-extern int hasMultipleOperands(char *);                              /* MR23 */\r
-extern void DumpInitializers(FILE*, RuleEntry*, char*);              /* MR23 */\r
-extern int isTermEntryTokClass(TermEntry *);                                            /* MR23 */\r
-extern int isEmptyAlt(Node *, Node *);                               /* MR23 */\r
-#else\r
-extern int STRICMP();\r
-extern void istackreset();\r
-extern int istacksize();\r
-extern void pushint();\r
-extern int popint();\r
-extern int istackempty();\r
-extern int topint();\r
-extern void NewSetWd();\r
-extern void DumpSetWd();\r
-extern void DumpSetWdForC();\r
-extern void DumpSetWdForCC();\r
-extern void NewSet();\r
-extern void FillSet();\r
-extern void ComputeErrorSets();\r
-extern void ComputeTokSets();\r
-extern void SubstErrorClass();\r
-extern int DefErrSet();\r
-extern int DefErrSetForC();\r
-extern int DefErrSetForCC();\r
-extern int DefErrSet1();\r
-extern int DefErrSetForC1();\r
-extern int DefErrSetForCC1();\r
-extern int DefErrSetWithSuffix();                                   /* MR21 */\r
-extern void GenErrHdr();\r
-extern void dumpExpr();\r
-extern void addParm();\r
-extern Graph buildAction();\r
-extern Graph buildToken();\r
-extern Graph buildWildCard();\r
-extern Graph buildRuleRef();\r
-extern Graph Or();\r
-extern Graph Cat();\r
-extern Graph makeOpt();\r
-extern Graph makeBlk();\r
-extern Graph makeLoop();\r
-extern Graph makePlus();\r
-extern Graph emptyAlt();\r
-extern Graph emptyAlt3();\r
-extern TokNode * newTokNode();\r
-extern RuleRefNode * newRNode();\r
-extern Junction * newJunction();\r
-extern ActionNode * newActionNode();\r
-extern char * makelocks();\r
-extern void preorder();\r
-extern Tree * tnode();\r
-extern void _Tfree();\r
-extern Tree * tdup();\r
-extern int is_single_tuple();\r
-extern Tree * tappend();\r
-extern void Tfree();\r
-extern Tree * tlink();\r
-extern Tree * tshrink();\r
-extern Tree * tflatten();\r
-extern Tree * tJunc();\r
-extern Tree * tRuleRef();\r
-extern Tree * tToken();\r
-extern Tree * tAction();\r
-extern int tmember();\r
-extern int tmember_constrained();\r
-extern Tree * tleft_factor();\r
-extern Tree * trm_perm();\r
-extern void tcvt();\r
-extern Tree * permute();\r
-extern Tree * VerifyAmbig();\r
-extern set rJunc();\r
-extern set rRuleRef();\r
-extern set rToken();\r
-extern set rAction();\r
-extern void HandleAmbiguity();\r
-extern set First();\r
-extern void freeBlkFsets();\r
-extern void genAction();\r
-extern void genRuleRef();\r
-extern void genToken();\r
-extern void genOptBlk();\r
-extern void genLoopBlk();\r
-extern void genLoopBegin();\r
-extern void genPlusBlk();\r
-extern void genSubBlk();\r
-extern void genRule();\r
-extern void genJunction();\r
-extern void genEndBlk();\r
-extern void genEndRule();\r
-extern void genHdr();\r
-extern void genHdr1();\r
-extern void dumpAction();\r
-extern void dumpActionPlus();                           /* MR21 */\r
-extern Entry ** newHashTable();\r
-extern Entry * hash_add();\r
-extern Entry * hash_get();\r
-extern void hashStat();\r
-extern char * mystrdup();\r
-extern void genLexDescr();\r
-extern void dumpLexClasses();\r
-extern void genDefFile();\r
-extern void DumpListOfParmNames();                    /* MR5 janm 26-May-97 */\r
-extern int DumpNextNameInDef();\r
-extern void DumpOldStyleParms();\r
-extern void DumpType();\r
-extern int strmember();\r
-/* extern int HasComma(); MR23 Replaced by hasMultipleOperands() */\r
-extern void DumpRetValStruct();\r
-extern char * StripQuotes();\r
-extern int main();\r
-extern void readDescr();\r
-extern FILE * NextFile();\r
-extern char * outnameX();\r
-extern char * outname();\r
-extern void fatalFL();\r
-extern void fatal_intern();\r
-extern void cleanUp();\r
-extern char * eMsg3();\r
-extern char * eMsgd();\r
-extern char * eMsgd2();\r
-extern void s_fprT();\r
-extern char * TerminalString();\r
-extern void lexclass();\r
-extern void lexmode();\r
-extern int LexClassIndex();\r
-extern int hasAction();\r
-extern void setHasAction();\r
-extern int addTname();\r
-extern int addTexpr();\r
-extern int Tnum();\r
-extern void Tklink();\r
-extern Entry * newEntry();\r
-extern void list_add();\r
-extern void list_free();                /* MR10 */\r
-extern void list_apply();\r
-extern int list_search_cstring ();      /* MR27 */\r
-extern char * Fkey();\r
-extern void FoPush();\r
-extern void FoPop();\r
-extern void RegisterCycle();\r
-extern void ResolveFoCycles();\r
-extern void pJunc();\r
-extern void pRuleRef();\r
-extern void pToken();\r
-extern void pAction();\r
-extern void FoLink();\r
-extern void addFoLink();\r
-extern void GenCrossRef();\r
-extern void defErr();\r
-extern void genStdPCCTSIncludeFile();\r
-extern char * pcctsBaseName();                                /* MR32 */\r
-extern Predicate *find_predicates();\r
-extern Predicate *MR_find_predicates_and_supp();              /* MR13 */\r
-extern int predicateLookaheadDepth();                         /* MR10 */\r
-extern void predicate_free();                                 /* MR10 */\r
-extern Predicate * predicate_dup();                           /* MR10 */\r
-extern Predicate * predicate_dup_without_context();           /* MR11 */\r
-extern void GenRulePrototypes();\r
-extern Junction *first_item_is_guess_block();\r
-extern Junction *first_item_is_guess_block_extra();                      /* MR30 */\r
-extern Junction *analysis_point();\r
-extern Tree *make_tree_from_sets();\r
-extern Tree *tdup_chain();\r
-extern Tree *tdif();\r
-extern set covered_set();\r
-extern void AmbiguityDialog();\r
-extern void dumpAmbigMsg();\r
-extern void GenRuleFuncRedefs();\r
-extern void GenPredefinedSymbolRedefs();\r
-extern void GenASTSymbolRedefs();\r
-extern void GenRemapFile();\r
-extern void GenSetRedefs();\r
-extern ForcedToken *newForcedToken();\r
-extern void RemapForcedTokens();\r
-extern char *TokenOrExpr();\r
-extern void setUpperRange();\r
-extern void GenParser_c_Hdr();\r
-extern void GenParser_h_Hdr();\r
-extern void GenRuleMemberDeclarationsForCC();\r
-extern int addForcedTname();\r
-extern char *OutMetaName();\r
-extern void OutFirstSetSymbol();                            /* MR21 */\r
-extern void warnNoFL();\r
-extern void warnFL();\r
-extern void warn();\r
-extern void warnNoCR();\r
-extern void errNoFL();\r
-extern void errFL();\r
-extern void err();\r
-extern void errNoCR();\r
-extern void genPredTree();\r
-extern UserAction *newUserAction();\r
-extern char *gate_symbol();\r
-extern char *makeAltID();\r
-extern void DumpRemainingTokSets();\r
-extern void DumpANSIFunctionArgDef();\r
-extern void DumpFormals();                                           /* MR23 */\r
-extern char* hideDefaultArgs();                                      /* MR22 VHS */\r
-extern Predicate *computePredFromContextGuard();\r
-extern void recomputeContextGuard();                                 /* MR13 */\r
-extern Predicate *new_pred();\r
-extern void chkGTFlag();\r
-extern void leAdd();                                                 /* MR7 */\r
-extern void leFixup();                                               /* MR7 */\r
-extern void egAdd();                                                 /* MR7 */\r
-extern void egFixup();                                               /* MR7 */\r
-extern void altAdd();                                                /* MR7 */\r
-extern void altFixup();                                              /* MR7 */\r
-extern Predicate * MR_find_in_aSubBlk();                                       /* MR10 */\r
-extern Predicate * MR_predFlatten();                                                   /* MR10 */\r
-extern Predicate * MR_predSimplifyALL();                            /* MR10 */\r
-extern Predicate * MR_predSimplifyALLX();                           /* MR10 */\r
-extern void MR_cleanup_pred_trees();                                /* MR10 */\r
-extern int MR_allPredLeaves();                                      /* MR10 */\r
-extern int MR_predicate_context_completed();                        /* MR10 */\r
-extern void MR_check_pred_too_long();                               /* MR10 */\r
-extern Tree * MR_remove_epsilon_from_tree();                                   /* MR10 */\r
-extern Tree * MR_computeTreeAND();                                                     /* MR10 */\r
-extern int MR_tree_equ();                                                      /* MR10 */\r
-extern set MR_First();                                                         /* MR10 */\r
-extern set MR_compute_pred_set();                                                  /* MR10 */\r
-extern Tree * MR_compute_pred_tree_context();                                  /* MR10 */\r
-extern int MR_pointerStackPush();                                   /* MR10 */\r
-extern void * MR_pointerStackPop();                                 /* MR10 */\r
-extern void * MR_pointerStackTop();                                 /* MR10 */\r
-extern void MR_pointerStackReset();                                 /* MR10 */\r
-extern void MR_backTraceReport();                                   /* MR10 */\r
-extern void MR_alphaBetaTraceReport();                              /* MR14 */\r
-extern void MR_dumpRuleSet();                                       /* MR14 */\r
-extern void MR_predContextPresent();                                /* MR10 */\r
-extern void MR_dumpPred();                                          /* MR10 */\r
-extern void MR_dumpPred1();                                         /* MR10 */\r
-extern void MR_xxxIndent();                                         /* MR11 */\r
-extern void MR_stderrIndent();                                      /* MR11 */\r
-extern void MR_outputIndent();                                      /* MR11 */\r
-extern Junction * MR_ruleReferenced();                              /* MR10 */\r
-extern void MR_releaseResourcesUsedInRule();                        /* MR10 */\r
-extern void MR_dumpTreeX();                                         /* MR10 */\r
-extern void MR_dumpTreeF();                                         /* MR10 */\r
-extern void DumpFcache();                                           /* MR10 */\r
-extern void MR_dumpTokenSet();                                      /* MR10 */\r
-extern void MR_traceAmbSource();                                    /* MR11 */\r
-extern Node *MR_advance();                                          /* MR11 */\r
-extern int  MR_offsetFromRule();                                    /* MR11 */\r
-extern char *MR_ruleNamePlusOffset();                               /* MR11 */\r
-extern void MR_traceAmbSourceK();                                   /* MR11 */\r
-extern void MR_traceAmbSourceKclient();                             /* [i_a] added */\r
-extern int  MR_max_height_of_tree();                                /* MR11 */\r
-extern int  MR_all_leaves_same_height();                            /* MR11 */\r
-extern void MR_projectTreeOntoSet();                                /* MR11 */\r
-extern Tree *MR_make_tree_from_set();                               /* MR11 */\r
-extern Predicate *MR_removeRedundantPredPass3();                    /* MR11 */\r
-extern void MR_pred_depth();                                        /* MR11 */\r
-extern int  MR_comparePredicates();                                 /* MR11 */\r
-extern Predicate * MR_unfold();                                     /* MR11 */\r
-extern void MR_simplifyInverted();                                  /* MR11 */\r
-extern int  MR_secondPredicateUnreachable();                        /* MR11 */\r
-extern Junction * MR_nameToRuleBlk();                               /* MR10 */\r
-extern void MR_clearPredEntry();                                    /* MR11 */\r
-extern void MR_orphanRules();                                       /* MR12 */\r
-extern void MR_merge_contexts();                                    /* MR12 */\r
-extern int ci_strequ();                                             /* MR12 */\r
-extern void MR_guardPred_plainSet();                                /* MR12c */\r
-extern void MR_suppressSearchReport();                              /* MR12c */\r
-extern Predicate * MR_suppressK();                                  /* MR13 */\r
-extern void MR_backTraceDumpItem();                                 /* MR13 */\r
-extern void MR_backTraceDumpItemReset();                            /* MR13 */\r
-extern Junction * MR_junctionWithoutP2();                           /* MR13 */\r
-extern void MR_setConstrainPointer();                                                      /* MR18 */\r
-extern void BlockPreambleOption();                                  /* MR23 */\r
-extern char* getInitializer();                                      /* MR23 */\r
-extern int hasMultipleOperands();                                   /* MR23 */\r
-extern char *endFormal();                                           /* MR23 */\r
-extern char *strBetween();                                          /* MR23 */\r
-extern void DumpInitializers();                                     /* MR23 */\r
-extern int isTermEntryTokClass();                                                                  /* MR23 */\r
-extern int isEmptyAlt();\r
-\r
-#endif\r
-\r
-#ifdef __USE_PROTOS\r
-#include <stdlib.h>\r
-#endif\r
-\r
-/* MR20 G. Hobbelt  Create proper externs for dlg variables */\r
-\r
-extern set attribsRefdFromAction;\r
-extern int inAlt;\r
-extern int UsedOldStyleAttrib;\r
-extern int UsedNewStyleLabel;\r
-\r
-#define MAX_BLK_LEVEL 100                       /* MR23 */\r
-extern int     CurBlockID_array[MAX_BLK_LEVEL]; /* MR23 */\r
-extern int     CurAltNum_array[MAX_BLK_LEVEL];  /* MR23 */\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/antlr/scan.c b/Tools/CodeTools/TianoTools/Pccts/antlr/scan.c
deleted file mode 100644 (file)
index 9b4bde0..0000000
+++ /dev/null
@@ -1,5735 +0,0 @@
-\r
-/* parser.dlg -- DLG Description of scanner\r
- *\r
- * Generated from: antlr.g\r
- *\r
- * Terence Parr, Will Cohen, and Hank Dietz: 1989-2001\r
- * Purdue University Electrical Engineering\r
- * With AHPCRC, University of Minnesota\r
- * ANTLR Version 1.33MR33\r
- */\r
-\r
-#define ANTLR_VERSION  13333\r
-#include "pcctscfg.h"\r
-#include "pccts_stdio.h"\r
-\r
-#include "pcctscfg.h"\r
-#include "set.h"\r
-#include <ctype.h>\r
-#include "syn.h"\r
-#include "hash.h"\r
-#include "generic.h"\r
-#define zzcr_attr(attr,tok,t)\r
-#include "antlr.h"\r
-#include "tokens.h"\r
-#include "dlgdef.h"\r
-LOOKAHEAD\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-zzerraction(void)\r
-#else\r
-zzerraction()\r
-#endif\r
-{\r
-       (*zzerr)("invalid token");\r
-       zzadvance();\r
-       zzskip();\r
-}\r
-/*\r
- * D L G tables\r
- *\r
- * Generated from: parser.dlg\r
- *\r
- * 1989-2001 by  Will Cohen, Terence Parr, and Hank Dietz\r
- * Purdue University Electrical Engineering\r
- * DLG Version 1.33MR33\r
- */\r
-\r
-#include "mode.h"\r
-\r
-\r
-\r
-\r
-/* maintained, but not used for now */\r
-set AST_nodes_refd_in_actions = set_init;\r
-int inAlt = 0;\r
-set attribsRefdFromAction = set_init; /* MR20 */\r
-int UsedOldStyleAttrib = 0;\r
-int UsedNewStyleLabel = 0;\r
-#ifdef __USE_PROTOS\r
-char *inline_set(char *);\r
-#else\r
-char *inline_set();\r
-#endif\r
-\r
-/* MR1 10-Apr-97  MR1  Previously unable to put right shift operator       */\r
-/* MR1                                 in DLG action                                       */\r
-\r
-int tokenActionActive=0;                                            /* MR1 */\r
-\r
-  \r
-\r
-\r
-\r
-static char *\r
-#ifdef __USE_PROTOS\r
-getFileNameFromTheLineInfo(char *toStr, char *fromStr)\r
-#else\r
-getFileNameFromTheLineInfo(toStr, fromStr)\r
-char *toStr, *fromStr;\r
-#endif\r
-{\r
-  int i, j, k;\r
-  \r
-  if (!fromStr || !toStr) return toStr;\r
-  \r
-  /* find the first " */\r
-  \r
-  for (i=0;\r
-  (i<MaxFileName) &&\r
-  (fromStr[i] != '\n') &&\r
-  (fromStr[i] != '\r') &&\r
-  (fromStr[i] != '\"');\r
-  i++) /* nothing */ ;\r
-  \r
-  if ( (i == MaxFileName) ||\r
-  (fromStr[i] == '\n') ||\r
-  (fromStr[i] == '\r') ) {\r
-  return toStr;\r
-}\r
-\r
-  /* find the second " */\r
-\r
-  for (j=i+1;\r
-(j<MaxFileName) &&\r
-(fromStr[j] != '\n') &&\r
-(fromStr[j] != '\r') &&\r
-(fromStr[j] != '\"');\r
-j++) /* nothing */ ;\r
-\r
-  if ((j == MaxFileName) ||\r
-(fromStr[j] == '\n') ||\r
-(fromStr[j] == '\r') ) {\r
-  return toStr;\r
-}\r
-\r
-  /* go back until the last / or \ */\r
-\r
-  for (k=j-1;\r
-(fromStr[k] != '\"') &&\r
-(fromStr[k] != '/') &&\r
-(fromStr[k] != '\\');\r
-k--) /* nothing */ ;\r
-\r
-  /* copy the string after " / or \ into toStr */\r
-\r
-  for (i=k+1; fromStr[i] != '\"'; i++) {\r
-toStr[i-k-1] = fromStr[i];\r
-}\r
-\r
-  toStr[i-k-1] = '\0';\r
-\r
-  return toStr;\r
-}\r
-\r
-/* MR14 end of a block to support #line in antlr source code */\r
-\r
-  \r
-\r
-\r
-#ifdef __USE_PROTOS\r
-void mark_label_used_in_sem_pred(LabelEntry *le)              /* MR10 */\r
-#else\r
-void mark_label_used_in_sem_pred(le)                          /* MR10 */\r
-LabelEntry    *le;\r
-#endif\r
-{\r
-  TokNode   *tn;\r
-  require (le->elem->ntype == nToken,"mark_label_used... ntype != nToken");\r
-  tn=(TokNode *)le->elem;\r
-  require (tn->label != 0,"mark_label_used... TokNode has no label");\r
-  tn->label_used_in_semantic_pred=1;\r
-}\r
-\r
-static void act1()\r
-{ \r
-               NLA = Eof;\r
-    /* L o o k  F o r  A n o t h e r  F i l e */\r
-    {\r
-      FILE *new_input;\r
-      new_input = NextFile();\r
-      if ( new_input == NULL ) { NLA=Eof; return; }\r
-      fclose( input );\r
-      input = new_input;\r
-      zzrdstream( input );\r
-      zzskip();        /* Skip the Eof (@) char i.e continue */\r
-    }\r
-       }\r
-\r
-\r
-static void act2()\r
-{ \r
-               NLA = 76;\r
-    zzskip();   \r
-       }\r
-\r
-\r
-static void act3()\r
-{ \r
-               NLA = 77;\r
-    zzline++; zzskip();   \r
-       }\r
-\r
-\r
-static void act4()\r
-{ \r
-               NLA = 78;\r
-    zzmode(ACTIONS); zzmore();\r
-    istackreset();\r
-    pushint(']');   \r
-       }\r
-\r
-\r
-static void act5()\r
-{ \r
-               NLA = 79;\r
-    action_file=CurFile; action_line=zzline;\r
-    zzmode(ACTIONS); zzmore();\r
-    list_free(&CurActionLabels,0);       /* MR10 */\r
-    numericActionLabel=0;                /* MR10 */\r
-    istackreset();\r
-    pushint('>');   \r
-       }\r
-\r
-\r
-static void act6()\r
-{ \r
-               NLA = 80;\r
-    zzmode(STRINGS); zzmore();   \r
-       }\r
-\r
-\r
-static void act7()\r
-{ \r
-               NLA = 81;\r
-    zzmode(COMMENTS); zzskip();   \r
-       }\r
-\r
-\r
-static void act8()\r
-{ \r
-               NLA = 82;\r
-    warn("Missing /*; found dangling */"); zzskip();   \r
-       }\r
-\r
-\r
-static void act9()\r
-{ \r
-               NLA = 83;\r
-    zzmode(CPP_COMMENTS); zzskip();   \r
-       }\r
-\r
-\r
-static void act10()\r
-{ \r
-               NLA = 84;\r
-    \r
-    zzline = atoi(zzbegexpr+5) - 1; zzline++; zzmore();\r
-    getFileNameFromTheLineInfo(FileStr[CurFile], zzbegexpr);\r
-       }\r
-\r
-\r
-static void act11()\r
-{ \r
-               NLA = 85;\r
-    \r
-    zzline++; zzmore();\r
-       }\r
-\r
-\r
-static void act12()\r
-{ \r
-               NLA = 86;\r
-    warn("Missing <<; found dangling >>"); zzskip();   \r
-       }\r
-\r
-\r
-static void act13()\r
-{ \r
-               NLA = WildCard;\r
-       }\r
-\r
-\r
-static void act14()\r
-{ \r
-               NLA = 88;\r
-    FoundException = 1;                /* MR6 */\r
-    FoundAtOperator = 1;  \r
-       }\r
-\r
-\r
-static void act15()\r
-{ \r
-               NLA = Pragma;\r
-       }\r
-\r
-\r
-static void act16()\r
-{ \r
-               NLA = FirstSetSymbol;\r
-       }\r
-\r
-\r
-static void act17()\r
-{ \r
-               NLA = 94;\r
-       }\r
-\r
-\r
-static void act18()\r
-{ \r
-               NLA = 95;\r
-       }\r
-\r
-\r
-static void act19()\r
-{ \r
-               NLA = 96;\r
-       }\r
-\r
-\r
-static void act20()\r
-{ \r
-               NLA = 97;\r
-       }\r
-\r
-\r
-static void act21()\r
-{ \r
-               NLA = 98;\r
-       }\r
-\r
-\r
-static void act22()\r
-{ \r
-               NLA = 99;\r
-       }\r
-\r
-\r
-static void act23()\r
-{ \r
-               NLA = 102;\r
-       }\r
-\r
-\r
-static void act24()\r
-{ \r
-               NLA = 103;\r
-       }\r
-\r
-\r
-static void act25()\r
-{ \r
-               NLA = 104;\r
-       }\r
-\r
-\r
-static void act26()\r
-{ \r
-               NLA = 105;\r
-       }\r
-\r
-\r
-static void act27()\r
-{ \r
-               NLA = 106;\r
-       }\r
-\r
-\r
-static void act28()\r
-{ \r
-               NLA = 107;\r
-       }\r
-\r
-\r
-static void act29()\r
-{ \r
-               NLA = 108;\r
-       }\r
-\r
-\r
-static void act30()\r
-{ \r
-               NLA = 109;\r
-       }\r
-\r
-\r
-static void act31()\r
-{ \r
-               NLA = 110;\r
-       }\r
-\r
-\r
-static void act32()\r
-{ \r
-               NLA = 111;\r
-       }\r
-\r
-\r
-static void act33()\r
-{ \r
-               NLA = 112;\r
-       }\r
-\r
-\r
-static void act34()\r
-{ \r
-               NLA = 113;\r
-       }\r
-\r
-\r
-static void act35()\r
-{ \r
-               NLA = 114;\r
-       }\r
-\r
-\r
-static void act36()\r
-{ \r
-               NLA = 115;\r
-       }\r
-\r
-\r
-static void act37()\r
-{ \r
-               NLA = 116;\r
-       }\r
-\r
-\r
-static void act38()\r
-{ \r
-               NLA = 117;\r
-       }\r
-\r
-\r
-static void act39()\r
-{ \r
-               NLA = 118;\r
-       }\r
-\r
-\r
-static void act40()\r
-{ \r
-               NLA = 119;\r
-       }\r
-\r
-\r
-static void act41()\r
-{ \r
-               NLA = 120;\r
-       }\r
-\r
-\r
-static void act42()\r
-{ \r
-               NLA = 121;\r
-       }\r
-\r
-\r
-static void act43()\r
-{ \r
-               NLA = 122;\r
-       }\r
-\r
-\r
-static void act44()\r
-{ \r
-               NLA = 123;\r
-       }\r
-\r
-\r
-static void act45()\r
-{ \r
-               NLA = 124;\r
-       }\r
-\r
-\r
-static void act46()\r
-{ \r
-               NLA = 125;\r
-       }\r
-\r
-\r
-static void act47()\r
-{ \r
-               NLA = 126;\r
-       }\r
-\r
-\r
-static void act48()\r
-{ \r
-               NLA = 127;\r
-       }\r
-\r
-\r
-static void act49()\r
-{ \r
-               NLA = 128;\r
-       }\r
-\r
-\r
-static void act50()\r
-{ \r
-               NLA = 129;\r
-       }\r
-\r
-\r
-static void act51()\r
-{ \r
-               NLA = 130;\r
-       }\r
-\r
-\r
-static void act52()\r
-{ \r
-               NLA = 131;\r
-       }\r
-\r
-\r
-static void act53()\r
-{ \r
-               NLA = 132;\r
-       }\r
-\r
-\r
-static void act54()\r
-{ \r
-               NLA = 133;\r
-       }\r
-\r
-\r
-static void act55()\r
-{ \r
-               NLA = 134;\r
-       }\r
-\r
-\r
-static void act56()\r
-{ \r
-               NLA = 135;\r
-       }\r
-\r
-\r
-static void act57()\r
-{ \r
-               NLA = NonTerminal;\r
-    \r
-    while ( zzchar==' ' || zzchar=='\t' ) {\r
-      zzadvance();\r
-    }\r
-    if ( zzchar == ':' && inAlt ) NLA = LABEL;\r
-       }\r
-\r
-\r
-static void act58()\r
-{ \r
-               NLA = TokenTerm;\r
-    \r
-    while ( zzchar==' ' || zzchar=='\t' ) {\r
-      zzadvance();\r
-    }\r
-    if ( zzchar == ':' && inAlt ) NLA = LABEL;\r
-       }\r
-\r
-\r
-static void act59()\r
-{ \r
-               NLA = 136;\r
-    warn(eMsg1("unknown meta-op: %s",LATEXT(1))); zzskip();   \r
-       }\r
-\r
-static unsigned char shift0[257] = {\r
-  0, 58, 58, 58, 58, 58, 58, 58, 58, 58, \r
-  1, 2, 58, 58, 3, 58, 58, 58, 58, 58, \r
-  58, 58, 58, 58, 58, 58, 58, 58, 58, 58, \r
-  58, 58, 58, 1, 40, 6, 9, 58, 58, 45, \r
-  58, 46, 47, 8, 52, 58, 58, 18, 7, 16, \r
-  14, 15, 16, 16, 16, 16, 16, 16, 16, 41, \r
-  42, 5, 48, 17, 53, 19, 56, 56, 56, 56, \r
-  56, 26, 56, 56, 56, 56, 56, 51, 56, 56, \r
-  56, 56, 56, 56, 29, 56, 56, 56, 56, 56, \r
-  56, 56, 4, 20, 58, 50, 57, 58, 23, 31, \r
-  38, 34, 13, 35, 24, 33, 11, 55, 36, 10, \r
-  25, 12, 32, 21, 55, 22, 27, 28, 54, 55, \r
-  55, 43, 30, 55, 39, 44, 37, 49, 58, 58, \r
-  58, 58, 58, 58, 58, 58, 58, 58, 58, 58, \r
-  58, 58, 58, 58, 58, 58, 58, 58, 58, 58, \r
-  58, 58, 58, 58, 58, 58, 58, 58, 58, 58, \r
-  58, 58, 58, 58, 58, 58, 58, 58, 58, 58, \r
-  58, 58, 58, 58, 58, 58, 58, 58, 58, 58, \r
-  58, 58, 58, 58, 58, 58, 58, 58, 58, 58, \r
-  58, 58, 58, 58, 58, 58, 58, 58, 58, 58, \r
-  58, 58, 58, 58, 58, 58, 58, 58, 58, 58, \r
-  58, 58, 58, 58, 58, 58, 58, 58, 58, 58, \r
-  58, 58, 58, 58, 58, 58, 58, 58, 58, 58, \r
-  58, 58, 58, 58, 58, 58, 58, 58, 58, 58, \r
-  58, 58, 58, 58, 58, 58, 58, 58, 58, 58, \r
-  58, 58, 58, 58, 58, 58, 58\r
-};\r
-\r
-\r
-static void act60()\r
-{ \r
-               NLA = Eof;\r
-       }\r
-\r
-\r
-static void act61()\r
-{ \r
-               NLA = QuotedTerm;\r
-    zzmode(START);   \r
-       }\r
-\r
-\r
-static void act62()\r
-{ \r
-               NLA = 3;\r
-    \r
-    zzline++;\r
-    warn("eoln found in string");\r
-    zzskip();\r
-       }\r
-\r
-\r
-static void act63()\r
-{ \r
-               NLA = 4;\r
-    zzline++; zzmore();   \r
-       }\r
-\r
-\r
-static void act64()\r
-{ \r
-               NLA = 5;\r
-    zzmore();   \r
-       }\r
-\r
-\r
-static void act65()\r
-{ \r
-               NLA = 6;\r
-    zzmore();   \r
-       }\r
-\r
-static unsigned char shift1[257] = {\r
-  0, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 2, 5, 5, 3, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 1, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 4, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5\r
-};\r
-\r
-\r
-static void act66()\r
-{ \r
-               NLA = Eof;\r
-       }\r
-\r
-\r
-static void act67()\r
-{ \r
-               NLA = 7;\r
-    zzmode(ACTIONS); zzmore();   \r
-       }\r
-\r
-\r
-static void act68()\r
-{ \r
-               NLA = 8;\r
-    \r
-    zzline++;\r
-    warn("eoln found in string (in user action)");\r
-    zzskip();\r
-       }\r
-\r
-\r
-static void act69()\r
-{ \r
-               NLA = 9;\r
-    zzline++; zzmore();   \r
-       }\r
-\r
-\r
-static void act70()\r
-{ \r
-               NLA = 10;\r
-    zzmore();   \r
-       }\r
-\r
-\r
-static void act71()\r
-{ \r
-               NLA = 11;\r
-    zzmore();   \r
-       }\r
-\r
-static unsigned char shift2[257] = {\r
-  0, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 2, 5, 5, 3, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 1, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 4, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5\r
-};\r
-\r
-\r
-static void act72()\r
-{ \r
-               NLA = Eof;\r
-       }\r
-\r
-\r
-static void act73()\r
-{ \r
-               NLA = 12;\r
-    zzmode(ACTIONS); zzmore();   \r
-       }\r
-\r
-\r
-static void act74()\r
-{ \r
-               NLA = 13;\r
-    \r
-    zzline++;\r
-    warn("eoln found in char literal (in user action)");\r
-    zzskip();\r
-       }\r
-\r
-\r
-static void act75()\r
-{ \r
-               NLA = 14;\r
-    zzmore();   \r
-       }\r
-\r
-\r
-static void act76()\r
-{ \r
-               NLA = 15;\r
-    zzmore();   \r
-       }\r
-\r
-static unsigned char shift3[257] = {\r
-  0, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 2, 5, 5, 3, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  1, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 4, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5\r
-};\r
-\r
-\r
-static void act77()\r
-{ \r
-               NLA = Eof;\r
-       }\r
-\r
-\r
-static void act78()\r
-{ \r
-               NLA = 16;\r
-    zzmode(ACTIONS); zzmore();   \r
-       }\r
-\r
-\r
-static void act79()\r
-{ \r
-               NLA = 17;\r
-    zzmore();   \r
-       }\r
-\r
-\r
-static void act80()\r
-{ \r
-               NLA = 18;\r
-    zzline++; zzmore(); DAWDLE;   \r
-       }\r
-\r
-\r
-static void act81()\r
-{ \r
-               NLA = 19;\r
-    zzmore();   \r
-       }\r
-\r
-static unsigned char shift4[257] = {\r
-  0, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 3, 5, 5, 4, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 1, 5, 5, 5, 5, 2, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5\r
-};\r
-\r
-\r
-static void act82()\r
-{ \r
-               NLA = Eof;\r
-       }\r
-\r
-\r
-static void act83()\r
-{ \r
-               NLA = 20;\r
-    zzmode(PARSE_ENUM_FILE);\r
-    zzmore();   \r
-       }\r
-\r
-\r
-static void act84()\r
-{ \r
-               NLA = 21;\r
-    zzmore();   \r
-       }\r
-\r
-\r
-static void act85()\r
-{ \r
-               NLA = 22;\r
-    zzline++; zzmore(); DAWDLE;   \r
-       }\r
-\r
-\r
-static void act86()\r
-{ \r
-               NLA = 23;\r
-    zzmore();   \r
-       }\r
-\r
-static unsigned char shift5[257] = {\r
-  0, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 3, 5, 5, 4, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 1, 5, 5, 5, 5, 2, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5\r
-};\r
-\r
-\r
-static void act87()\r
-{ \r
-               NLA = Eof;\r
-       }\r
-\r
-\r
-static void act88()\r
-{ \r
-               NLA = 24;\r
-    zzline++; zzmode(PARSE_ENUM_FILE); zzskip(); DAWDLE;   \r
-       }\r
-\r
-\r
-static void act89()\r
-{ \r
-               NLA = 25;\r
-    zzskip();   \r
-       }\r
-\r
-static unsigned char shift6[257] = {\r
-  0, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
-  3, 1, 3, 3, 2, 3, 3, 3, 3, 3, \r
-  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
-  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
-  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
-  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
-  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
-  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
-  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
-  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
-  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
-  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
-  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
-  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
-  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
-  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
-  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
-  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
-  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
-  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
-  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
-  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
-  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
-  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
-  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
-  3, 3, 3, 3, 3, 3, 3\r
-};\r
-\r
-\r
-static void act90()\r
-{ \r
-               NLA = Eof;\r
-       }\r
-\r
-\r
-static void act91()\r
-{ \r
-               NLA = 26;\r
-    zzline++; zzmode(ACTIONS); zzmore(); DAWDLE;   \r
-       }\r
-\r
-\r
-static void act92()\r
-{ \r
-               NLA = 27;\r
-    zzmore();   \r
-       }\r
-\r
-static unsigned char shift7[257] = {\r
-  0, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
-  3, 1, 3, 3, 2, 3, 3, 3, 3, 3, \r
-  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
-  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
-  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
-  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
-  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
-  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
-  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
-  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
-  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
-  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
-  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
-  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
-  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
-  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
-  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
-  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
-  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
-  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
-  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
-  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
-  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
-  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
-  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
-  3, 3, 3, 3, 3, 3, 3\r
-};\r
-\r
-\r
-static void act93()\r
-{ \r
-               NLA = Eof;\r
-       }\r
-\r
-\r
-static void act94()\r
-{ \r
-               NLA = 28;\r
-    zzline++; zzmode(START); zzskip(); DAWDLE;   \r
-       }\r
-\r
-\r
-static void act95()\r
-{ \r
-               NLA = 29;\r
-    zzskip();   \r
-       }\r
-\r
-static unsigned char shift8[257] = {\r
-  0, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
-  3, 1, 3, 3, 2, 3, 3, 3, 3, 3, \r
-  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
-  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
-  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
-  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
-  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
-  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
-  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
-  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
-  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
-  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
-  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
-  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
-  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
-  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
-  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
-  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
-  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
-  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
-  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
-  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
-  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
-  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
-  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \r
-  3, 3, 3, 3, 3, 3, 3\r
-};\r
-\r
-\r
-static void act96()\r
-{ \r
-               NLA = Eof;\r
-       }\r
-\r
-\r
-static void act97()\r
-{ \r
-               NLA = 30;\r
-    zzmode(START); zzskip();   \r
-       }\r
-\r
-\r
-static void act98()\r
-{ \r
-               NLA = 31;\r
-    zzskip();   \r
-       }\r
-\r
-\r
-static void act99()\r
-{ \r
-               NLA = 32;\r
-    zzline++; zzskip(); DAWDLE;   \r
-       }\r
-\r
-\r
-static void act100()\r
-{ \r
-               NLA = 33;\r
-    zzskip();   \r
-       }\r
-\r
-static unsigned char shift9[257] = {\r
-  0, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 3, 5, 5, 4, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 1, 5, 5, 5, 5, 2, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, \r
-  5, 5, 5, 5, 5, 5, 5\r
-};\r
-\r
-\r
-static void act101()\r
-{ \r
-               NLA = Eof;\r
-       }\r
-\r
-\r
-static void act102()\r
-{ \r
-               NLA = Action;\r
-    /* these do not nest */\r
-    zzmode(START);\r
-    NLATEXT[0] = ' ';\r
-    NLATEXT[1] = ' ';\r
-    zzbegexpr[0] = ' ';\r
-    zzbegexpr[1] = ' ';\r
-    if ( zzbufovf ) {\r
-      err( eMsgd("action buffer overflow; size %d",ZZLEXBUFSIZE));\r
-    }\r
-    \r
-/* MR1 10-Apr-97  MR1  Previously unable to put right shift operator   */\r
-    /* MR1                                     in DLG action                   */\r
-    /* MR1                     Doesn't matter what kind of action it is - reset*/\r
-    \r
-                             tokenActionActive=0;               /* MR1 */\r
-       }\r
-\r
-\r
-static void act103()\r
-{ \r
-               NLA = Pred;\r
-    /* these do not nest */\r
-    zzmode(START);\r
-    NLATEXT[0] = ' ';\r
-    NLATEXT[1] = ' ';\r
-    zzbegexpr[0] = '\0';\r
-    if ( zzbufovf ) {\r
-      err( eMsgd("predicate buffer overflow; size %d",ZZLEXBUFSIZE));\r
-    };\r
-#ifdef __cplusplus__\r
-    /* MR10 */                    list_apply(CurActionLabels, (void (*)(void *))mark_label_used_in_sem_pred);\r
-#else\r
-#ifdef __STDC__\r
-    /* MR10 */                    list_apply(CurActionLabels, (void (*)(void *))mark_label_used_in_sem_pred);\r
-#else\r
-#ifdef __USE_PROTOS\r
-    /* MRxx */                    list_apply(CurActionLabels, (void (*)(void *))mark_label_used_in_sem_pred);\r
-#else\r
-    /* MR10 */                    list_apply(CurActionLabels,mark_label_used_in_sem_pred);\r
-#endif\r
-#endif\r
-#endif\r
-       }\r
-\r
-\r
-static void act104()\r
-{ \r
-               NLA = PassAction;\r
-    if ( topint() == ']' ) {\r
-      popint();\r
-      if ( istackempty() )     /* terminate action */\r
-      {\r
-        zzmode(START);\r
-        NLATEXT[0] = ' ';\r
-        zzbegexpr[0] = ' ';\r
-        if ( zzbufovf ) {\r
-          err( eMsgd("parameter buffer overflow; size %d",ZZLEXBUFSIZE));\r
-        }\r
-      }\r
-      else {\r
-        /* terminate $[..] and #[..] */\r
-        if ( GenCC ) zzreplstr("))");\r
-        else zzreplstr(")");\r
-        zzmore();\r
-      }\r
-    }\r
-    else if ( topint() == '|' ) { /* end of simple [...] */\r
-      popint();\r
-      zzmore();\r
-    }\r
-    else zzmore();\r
-       }\r
-\r
-\r
-static void act105()\r
-{ \r
-               NLA = 37;\r
-    \r
-    zzmore();\r
-    zzreplstr(inline_set(zzbegexpr+\r
-    strlen("consumeUntil(")));\r
-       }\r
-\r
-\r
-static void act106()\r
-{ \r
-               NLA = 38;\r
-    zzmore();   \r
-       }\r
-\r
-\r
-static void act107()\r
-{ \r
-               NLA = 39;\r
-    zzline++; zzmore(); DAWDLE;   \r
-       }\r
-\r
-\r
-static void act108()\r
-{ \r
-               NLA = 40;\r
-    zzmore();   \r
-       }\r
-\r
-\r
-static void act109()\r
-{ \r
-               NLA = 41;\r
-    zzmore();   \r
-       }\r
-\r
-\r
-static void act110()\r
-{ \r
-               NLA = 42;\r
-    if ( !GenCC ) {zzreplstr("zzaRet"); zzmore();}\r
-    else err("$$ use invalid in C++ mode");   \r
-       }\r
-\r
-\r
-static void act111()\r
-{ \r
-               NLA = 43;\r
-    if ( !GenCC ) {zzreplstr("zzempty_attr"); zzmore();}\r
-    else err("$[] use invalid in C++ mode");   \r
-       }\r
-\r
-\r
-static void act112()\r
-{ \r
-               NLA = 44;\r
-    \r
-    pushint(']');\r
-    if ( !GenCC ) zzreplstr("zzconstr_attr(");\r
-    else err("$[..] use invalid in C++ mode");\r
-    zzmore();\r
-       }\r
-\r
-\r
-static void act113()\r
-{ \r
-               NLA = 45;\r
-    {\r
-      static char buf[100];\r
-      numericActionLabel=1;       /* MR10 */\r
-      if ( strlen(zzbegexpr)>(size_t)85 )\r
-      fatal("$i attrib ref too big");\r
-      set_orel(atoi(zzbegexpr+1), &attribsRefdFromAction);\r
-      if ( !GenCC ) sprintf(buf,"zzaArg(zztasp%d,%s)",\r
-      BlkLevel-1,zzbegexpr+1);\r
-      else sprintf(buf,"_t%d%s",\r
-      BlkLevel-1,zzbegexpr+1);\r
-      zzreplstr(buf);\r
-      zzmore();\r
-      UsedOldStyleAttrib = 1;\r
-      if ( UsedNewStyleLabel )\r
-      err("cannot mix old-style $i with new-style labels");\r
-    }\r
-       }\r
-\r
-\r
-static void act114()\r
-{ \r
-               NLA = 46;\r
-    {\r
-      static char buf[100];\r
-      numericActionLabel=1;       /* MR10 */\r
-      if ( strlen(zzbegexpr)>(size_t)85 )\r
-      fatal("$i.field attrib ref too big");\r
-      zzbegexpr[strlen(zzbegexpr)-1] = ' ';\r
-      set_orel(atoi(zzbegexpr+1), &attribsRefdFromAction);\r
-      if ( !GenCC ) sprintf(buf,"zzaArg(zztasp%d,%s).",\r
-      BlkLevel-1,zzbegexpr+1);\r
-      else sprintf(buf,"_t%d%s.",\r
-      BlkLevel-1,zzbegexpr+1);\r
-      zzreplstr(buf);\r
-      zzmore();\r
-      UsedOldStyleAttrib = 1;\r
-      if ( UsedNewStyleLabel )\r
-      err("cannot mix old-style $i with new-style labels");\r
-    }\r
-       }\r
-\r
-\r
-static void act115()\r
-{ \r
-               NLA = 47;\r
-    {\r
-      static char buf[100];\r
-      static char i[20], j[20];\r
-      char *p,*q;\r
-      numericActionLabel=1;       /* MR10 */\r
-      if (strlen(zzbegexpr)>(size_t)85) fatal("$i.j attrib ref too big");\r
-      for (p=zzbegexpr+1,q= &i[0]; *p!='.'; p++) {\r
-        if ( q == &i[20] )\r
-        fatalFL("i of $i.j attrib ref too big",\r
-        FileStr[CurFile], zzline );\r
-        *q++ = *p;\r
-      }\r
-      *q = '\0';\r
-      for (p++, q= &j[0]; *p!='\0'; p++) {\r
-        if ( q == &j[20] )\r
-        fatalFL("j of $i.j attrib ref too big",\r
-        FileStr[CurFile], zzline );\r
-        *q++ = *p;\r
-      }\r
-      *q = '\0';\r
-      if ( !GenCC ) sprintf(buf,"zzaArg(zztasp%s,%s)",i,j);\r
-      else sprintf(buf,"_t%s%s",i,j);\r
-      zzreplstr(buf);\r
-      zzmore();\r
-      UsedOldStyleAttrib = 1;\r
-      if ( UsedNewStyleLabel )\r
-      err("cannot mix old-style $i with new-style labels");\r
-    }\r
-       }\r
-\r
-\r
-static void act116()\r
-{ \r
-               NLA = 48;\r
-    { static char buf[300]; LabelEntry *el;\r
-      zzbegexpr[0] = ' ';\r
-      if ( CurRule != NULL &&\r
-      strcmp(CurRule, &zzbegexpr[1])==0 ) {\r
-        if ( !GenCC ) zzreplstr("zzaRet");\r
-      }\r
-      else if ( CurRetDef != NULL &&\r
-      strmember(CurRetDef, &zzbegexpr[1])) {\r
-        if ( hasMultipleOperands( CurRetDef ) ) {\r
-          require (strlen(zzbegexpr)<=(size_t)285,\r
-          "$retval attrib ref too big");\r
-          sprintf(buf,"_retv.%s",&zzbegexpr[1]);\r
-          zzreplstr(buf);\r
-        }\r
-        else zzreplstr("_retv");\r
-      }\r
-      else if ( CurParmDef != NULL &&\r
-      strmember(CurParmDef, &zzbegexpr[1])) {\r
-      ;\r
-    }\r
-    else if ( Elabel==NULL ) {\r
-    { err("$-variables in actions outside of rules are not allowed"); }\r
-  } else if ( (el=(LabelEntry *)hash_get(Elabel, &zzbegexpr[1]))!=NULL ) {\r
-  /* MR10 */\r
-  /* MR10 */                      /* element labels might exist without an elem when */\r
-  /* MR10 */                      /*  it is a forward reference (to a rule)          */\r
-  /* MR10 */\r
-  /* MR10 */                                           if ( GenCC && (el->elem == NULL || el->elem->ntype==nRuleRef) )\r
-  /* MR10 */                                                   { err(eMsg1("There are no token ptrs for rule references: '$%s'",&zzbegexpr[1])); }\r
-  /* MR10 */\r
-  /* MR10 */                                           if ( !GenCC && (el->elem == NULL || el->elem->ntype==nRuleRef) && GenAST) {\r
-  /* MR10 */                          err("You can no longer use attributes returned by rules when also using ASTs");\r
-  /* MR10 */                          err("   Use upward inheritance (\"rule >[Attrib a] : ... <<$a=...>>\")");\r
-  /* MR10 */                      };\r
-  /* MR10 */\r
-  /* MR10 */                      /* keep track of <<... $label ...>> for semantic predicates in guess mode */\r
-  /* MR10 */                      /* element labels contain pointer to the owners node                      */\r
-  /* MR10 */\r
-  /* MR10 */                      if (el->elem != NULL && el->elem->ntype == nToken) {\r
-  /* MR10 */                        list_add(&CurActionLabels,el);\r
-  /* MR10 */                      };\r
-}\r
-else\r
-warn(eMsg1("$%s not parameter, return value, (defined) element label",&zzbegexpr[1]));\r
-}\r
-zzmore();\r
-       }\r
-\r
-\r
-static void act117()\r
-{ \r
-               NLA = 49;\r
-    zzreplstr("(*_root)"); zzmore(); chkGTFlag();   \r
-       }\r
-\r
-\r
-static void act118()\r
-{ \r
-               NLA = 50;\r
-    if ( GenCC ) {\r
-      if (NewAST) zzreplstr("(newAST)");\r
-      else zzreplstr("(new AST)");}\r
-    else {zzreplstr("zzastnew()");} zzmore();\r
-    chkGTFlag();\r
-       }\r
-\r
-\r
-static void act119()\r
-{ \r
-               NLA = 51;\r
-    zzreplstr("NULL"); zzmore(); chkGTFlag();   \r
-       }\r
-\r
-\r
-static void act120()\r
-{ \r
-               NLA = 52;\r
-    {\r
-      static char buf[100];\r
-      if ( strlen(zzbegexpr)>(size_t)85 )\r
-      fatal("#i AST ref too big");\r
-      if ( GenCC ) sprintf(buf,"_ast%d%s",BlkLevel-1,zzbegexpr+1);\r
-      else sprintf(buf,"zzastArg(%s)",zzbegexpr+1);\r
-      zzreplstr(buf);\r
-      zzmore();\r
-      set_orel(atoi(zzbegexpr+1), &AST_nodes_refd_in_actions);\r
-      chkGTFlag();\r
-    }\r
-       }\r
-\r
-\r
-static void act121()\r
-{ \r
-               NLA = 53;\r
-    \r
-    zzline = atoi(zzbegexpr+5) - 1; zzline++; zzmore();\r
-    getFileNameFromTheLineInfo(FileStr[CurFile], zzbegexpr);\r
-       }\r
-\r
-\r
-static void act122()\r
-{ \r
-               NLA = 54;\r
-    \r
-    zzline++; zzmore();\r
-       }\r
-\r
-\r
-static void act123()\r
-{ \r
-               NLA = 55;\r
-    \r
-    if ( !(strcmp(zzbegexpr, "#ifdef")==0 ||\r
-    strcmp(zzbegexpr, "#if")==0 ||\r
-    strcmp(zzbegexpr, "#else")==0 ||\r
-    strcmp(zzbegexpr, "#endif")==0 ||\r
-    strcmp(zzbegexpr, "#ifndef")==0 ||\r
-    strcmp(zzbegexpr, "#define")==0 ||\r
-    strcmp(zzbegexpr, "#pragma")==0 ||\r
-    strcmp(zzbegexpr, "#undef")==0 ||\r
-    strcmp(zzbegexpr, "#import")==0 ||\r
-    strcmp(zzbegexpr, "#line")==0 ||\r
-    strcmp(zzbegexpr, "#include")==0 ||\r
-    strcmp(zzbegexpr, "#error")==0) )\r
-    {\r
-      static char buf[100];\r
-      sprintf(buf, "%s_ast", zzbegexpr+1);\r
-      /* MR27 */                                               list_add(&CurAstLabelsInActions, mystrdup(zzbegexpr+1));\r
-      zzreplstr(buf);\r
-      chkGTFlag();\r
-    }\r
-    zzmore();\r
-       }\r
-\r
-\r
-static void act124()\r
-{ \r
-               NLA = 56;\r
-    \r
-    pushint(']');\r
-    if ( GenCC ) {\r
-      if (NewAST) zzreplstr("(newAST(");\r
-      else zzreplstr("(new AST("); }\r
-    else zzreplstr("zzmk_ast(zzastnew(),");\r
-    zzmore();\r
-    chkGTFlag();\r
-       }\r
-\r
-\r
-static void act125()\r
-{ \r
-               NLA = 57;\r
-    \r
-    pushint('}');\r
-    if ( GenCC ) {\r
-      if (tmakeInParser) {\r
-        zzreplstr("tmake(");\r
-      }\r
-      else {\r
-        zzreplstr("ASTBase::tmake(");\r
-      }\r
-    }\r
-    else {\r
-      zzreplstr("zztmake(");\r
-    }\r
-    zzmore();\r
-    chkGTFlag();\r
-       }\r
-\r
-\r
-static void act126()\r
-{ \r
-               NLA = 58;\r
-    zzmore();   \r
-       }\r
-\r
-\r
-static void act127()\r
-{ \r
-               NLA = 59;\r
-    \r
-    if ( istackempty() )\r
-    zzmore();\r
-    else if ( topint()==')' ) {\r
-      popint();\r
-    }\r
-    else if ( topint()=='}' ) {\r
-      popint();\r
-      /* terminate #(..) */\r
-      zzreplstr(", NULL)");\r
-    }\r
-    zzmore();\r
-       }\r
-\r
-\r
-static void act128()\r
-{ \r
-               NLA = 60;\r
-    \r
-    pushint('|');      /* look for '|' to terminate simple [...] */\r
-    zzmore();\r
-       }\r
-\r
-\r
-static void act129()\r
-{ \r
-               NLA = 61;\r
-    \r
-    pushint(')');\r
-    zzmore();\r
-       }\r
-\r
-\r
-static void act130()\r
-{ \r
-               NLA = 62;\r
-    zzreplstr("]");  zzmore();   \r
-       }\r
-\r
-\r
-static void act131()\r
-{ \r
-               NLA = 63;\r
-    zzreplstr(")");  zzmore();   \r
-       }\r
-\r
-\r
-static void act132()\r
-{ \r
-               NLA = 64;\r
-    if (! tokenActionActive) zzreplstr(">");    /* MR1 */\r
-    zzmore();                                   /* MR1 */\r
-       }\r
-\r
-\r
-static void act133()\r
-{ \r
-               NLA = 65;\r
-    zzmode(ACTION_CHARS); zzmore();  \r
-       }\r
-\r
-\r
-static void act134()\r
-{ \r
-               NLA = 66;\r
-    zzmode(ACTION_STRINGS); zzmore();  \r
-       }\r
-\r
-\r
-static void act135()\r
-{ \r
-               NLA = 67;\r
-    zzreplstr("$");  zzmore();   \r
-       }\r
-\r
-\r
-static void act136()\r
-{ \r
-               NLA = 68;\r
-    zzreplstr("#");  zzmore();   \r
-       }\r
-\r
-\r
-static void act137()\r
-{ \r
-               NLA = 69;\r
-    zzline++; zzmore();   \r
-       }\r
-\r
-\r
-static void act138()\r
-{ \r
-               NLA = 70;\r
-    zzmore();   \r
-       }\r
-\r
-\r
-static void act139()\r
-{ \r
-               NLA = 71;\r
-    zzmore();   \r
-       }\r
-\r
-\r
-static void act140()\r
-{ \r
-               NLA = 72;\r
-    zzmode(ACTION_COMMENTS); zzmore();   \r
-       }\r
-\r
-\r
-static void act141()\r
-{ \r
-               NLA = 73;\r
-    warn("Missing /*; found dangling */ in action"); zzmore();   \r
-       }\r
-\r
-\r
-static void act142()\r
-{ \r
-               NLA = 74;\r
-    zzmode(ACTION_CPP_COMMENTS); zzmore();   \r
-       }\r
-\r
-\r
-static void act143()\r
-{ \r
-               NLA = 75;\r
-    zzmore();   \r
-       }\r
-\r
-static unsigned char shift10[257] = {\r
-  0, 33, 33, 33, 33, 33, 33, 33, 33, 33, \r
-  16, 19, 33, 33, 20, 33, 33, 33, 33, 33, \r
-  33, 33, 33, 33, 33, 33, 33, 33, 33, 33, \r
-  33, 33, 33, 16, 33, 28, 27, 21, 33, 33, \r
-  30, 15, 18, 32, 33, 33, 33, 25, 31, 23, \r
-  24, 24, 24, 24, 24, 24, 24, 24, 24, 33, \r
-  33, 33, 33, 1, 2, 33, 26, 26, 26, 26, \r
-  26, 26, 26, 26, 26, 26, 26, 26, 26, 26, \r
-  26, 26, 26, 26, 26, 26, 11, 26, 26, 26, \r
-  26, 26, 22, 29, 3, 33, 26, 33, 26, 26, \r
-  4, 26, 10, 26, 26, 26, 13, 26, 26, 14, \r
-  9, 6, 5, 26, 26, 26, 7, 12, 8, 26, \r
-  26, 26, 26, 26, 17, 33, 34, 33, 33, 33, \r
-  33, 33, 33, 33, 33, 33, 33, 33, 33, 33, \r
-  33, 33, 33, 33, 33, 33, 33, 33, 33, 33, \r
-  33, 33, 33, 33, 33, 33, 33, 33, 33, 33, \r
-  33, 33, 33, 33, 33, 33, 33, 33, 33, 33, \r
-  33, 33, 33, 33, 33, 33, 33, 33, 33, 33, \r
-  33, 33, 33, 33, 33, 33, 33, 33, 33, 33, \r
-  33, 33, 33, 33, 33, 33, 33, 33, 33, 33, \r
-  33, 33, 33, 33, 33, 33, 33, 33, 33, 33, \r
-  33, 33, 33, 33, 33, 33, 33, 33, 33, 33, \r
-  33, 33, 33, 33, 33, 33, 33, 33, 33, 33, \r
-  33, 33, 33, 33, 33, 33, 33, 33, 33, 33, \r
-  33, 33, 33, 33, 33, 33, 33, 33, 33, 33, \r
-  33, 33, 33, 33, 33, 33, 33\r
-};\r
-\r
-\r
-static void act144()\r
-{ \r
-               NLA = Eof;\r
-    ;   \r
-       }\r
-\r
-\r
-static void act145()\r
-{ \r
-               NLA = 137;\r
-    zzskip();   \r
-       }\r
-\r
-\r
-static void act146()\r
-{ \r
-               NLA = 138;\r
-    zzline++; zzskip();   \r
-       }\r
-\r
-\r
-static void act147()\r
-{ \r
-               NLA = 139;\r
-    zzmode(TOK_DEF_CPP_COMMENTS); zzmore();   \r
-       }\r
-\r
-\r
-static void act148()\r
-{ \r
-               NLA = 140;\r
-    zzmode(TOK_DEF_COMMENTS); zzskip();   \r
-       }\r
-\r
-\r
-static void act149()\r
-{ \r
-               NLA = 141;\r
-    zzmode(TOK_DEF_CPP_COMMENTS); zzskip();   \r
-       }\r
-\r
-\r
-static void act150()\r
-{ \r
-               NLA = 142;\r
-    zzmode(TOK_DEF_CPP_COMMENTS); zzskip();   \r
-       }\r
-\r
-\r
-static void act151()\r
-{ \r
-               NLA = 143;\r
-    ;   \r
-       }\r
-\r
-\r
-static void act152()\r
-{ \r
-               NLA = 144;\r
-    zzmode(TOK_DEF_CPP_COMMENTS); zzskip();   \r
-       }\r
-\r
-\r
-static void act153()\r
-{ \r
-               NLA = 145;\r
-    zzmode(TOK_DEF_CPP_COMMENTS); zzskip();   \r
-       }\r
-\r
-\r
-static void act154()\r
-{ \r
-               NLA = 146;\r
-    zzmode(TOK_DEF_CPP_COMMENTS); zzskip();   \r
-       }\r
-\r
-\r
-static void act155()\r
-{ \r
-               NLA = 147;\r
-    zzmode(TOK_DEF_CPP_COMMENTS); zzskip();   \r
-       }\r
-\r
-\r
-static void act156()\r
-{ \r
-               NLA = 149;\r
-       }\r
-\r
-\r
-static void act157()\r
-{ \r
-               NLA = 151;\r
-       }\r
-\r
-\r
-static void act158()\r
-{ \r
-               NLA = 152;\r
-       }\r
-\r
-\r
-static void act159()\r
-{ \r
-               NLA = 153;\r
-       }\r
-\r
-\r
-static void act160()\r
-{ \r
-               NLA = 154;\r
-       }\r
-\r
-\r
-static void act161()\r
-{ \r
-               NLA = 155;\r
-       }\r
-\r
-\r
-static void act162()\r
-{ \r
-               NLA = 156;\r
-       }\r
-\r
-\r
-static void act163()\r
-{ \r
-               NLA = INT;\r
-       }\r
-\r
-\r
-static void act164()\r
-{ \r
-               NLA = ID;\r
-       }\r
-\r
-static unsigned char shift11[257] = {\r
-  0, 27, 27, 27, 27, 27, 27, 27, 27, 27, \r
-  1, 2, 27, 27, 3, 27, 27, 27, 27, 27, \r
-  27, 27, 27, 27, 27, 27, 27, 27, 27, 27, \r
-  27, 27, 27, 1, 27, 27, 6, 27, 27, 27, \r
-  27, 27, 27, 5, 27, 22, 27, 27, 4, 25, \r
-  25, 25, 25, 25, 25, 25, 25, 25, 25, 27, \r
-  24, 27, 21, 27, 27, 27, 26, 26, 26, 26, \r
-  26, 26, 26, 26, 26, 26, 26, 26, 26, 26, \r
-  26, 26, 26, 26, 26, 26, 26, 26, 26, 26, \r
-  26, 26, 27, 27, 27, 27, 26, 27, 26, 26, \r
-  26, 9, 10, 8, 26, 26, 7, 26, 26, 12, \r
-  15, 11, 17, 16, 26, 18, 13, 19, 14, 26, \r
-  26, 26, 26, 26, 20, 27, 23, 27, 27, 27, \r
-  27, 27, 27, 27, 27, 27, 27, 27, 27, 27, \r
-  27, 27, 27, 27, 27, 27, 27, 27, 27, 27, \r
-  27, 27, 27, 27, 27, 27, 27, 27, 27, 27, \r
-  27, 27, 27, 27, 27, 27, 27, 27, 27, 27, \r
-  27, 27, 27, 27, 27, 27, 27, 27, 27, 27, \r
-  27, 27, 27, 27, 27, 27, 27, 27, 27, 27, \r
-  27, 27, 27, 27, 27, 27, 27, 27, 27, 27, \r
-  27, 27, 27, 27, 27, 27, 27, 27, 27, 27, \r
-  27, 27, 27, 27, 27, 27, 27, 27, 27, 27, \r
-  27, 27, 27, 27, 27, 27, 27, 27, 27, 27, \r
-  27, 27, 27, 27, 27, 27, 27, 27, 27, 27, \r
-  27, 27, 27, 27, 27, 27, 27, 27, 27, 27, \r
-  27, 27, 27, 27, 27, 27, 27\r
-};\r
-\r
-#define DfaStates      436\r
-typedef unsigned short DfaState;\r
-\r
-static DfaState st0[60] = {\r
-  1, 2, 3, 4, 5, 6, 7, 8, 9, 10, \r
-  11, 11, 11, 12, 13, 13, 13, 14, 15, 16, \r
-  17, 11, 11, 18, 11, 11, 19, 11, 11, 19, \r
-  11, 11, 11, 11, 20, 11, 11, 21, 22, 23, \r
-  24, 25, 26, 11, 27, 28, 29, 30, 31, 32, \r
-  33, 34, 35, 36, 11, 11, 19, 436, 436, 436\r
-};\r
-\r
-static DfaState st1[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st2[60] = {\r
-  436, 2, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st3[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st4[60] = {\r
-  436, 436, 37, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st5[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st6[60] = {\r
-  436, 436, 436, 436, 436, 38, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st7[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st8[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 39, 40, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st9[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 41, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st10[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  42, 43, 43, 44, 43, 43, 43, 436, 436, 436, \r
-  436, 45, 43, 43, 43, 43, 46, 43, 47, 43, \r
-  43, 43, 43, 48, 43, 49, 43, 436, 43, 436, \r
-  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
-  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
-};\r
-\r
-static DfaState st11[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  50, 50, 50, 50, 50, 50, 50, 436, 436, 436, \r
-  436, 50, 50, 50, 50, 50, 50, 50, 50, 50, \r
-  50, 50, 50, 50, 50, 50, 50, 436, 50, 436, \r
-  436, 436, 436, 50, 436, 436, 436, 436, 436, 436, \r
-  436, 50, 436, 436, 50, 50, 50, 50, 436, 436\r
-};\r
-\r
-static DfaState st12[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  50, 50, 50, 50, 50, 50, 50, 436, 436, 436, \r
-  436, 50, 50, 50, 50, 50, 50, 50, 50, 50, \r
-  50, 50, 50, 50, 50, 50, 50, 436, 50, 436, \r
-  436, 436, 436, 51, 436, 436, 436, 436, 436, 436, \r
-  436, 50, 436, 436, 50, 50, 50, 50, 436, 436\r
-};\r
-\r
-static DfaState st13[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 13, 13, 13, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st14[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 52, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st15[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 53, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st16[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st17[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 54, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st18[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  50, 50, 50, 50, 50, 50, 50, 436, 436, 436, \r
-  436, 55, 50, 50, 50, 50, 50, 50, 50, 50, \r
-  50, 50, 50, 50, 50, 50, 50, 436, 50, 436, \r
-  436, 436, 436, 50, 436, 436, 436, 436, 436, 436, \r
-  436, 50, 436, 436, 50, 50, 50, 50, 436, 436\r
-};\r
-\r
-static DfaState st19[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  56, 56, 56, 56, 56, 56, 56, 436, 436, 436, \r
-  436, 56, 56, 56, 56, 56, 56, 56, 56, 56, \r
-  56, 56, 56, 56, 56, 56, 56, 436, 56, 436, \r
-  436, 436, 436, 56, 436, 436, 436, 436, 436, 436, \r
-  436, 56, 436, 436, 56, 56, 56, 56, 436, 436\r
-};\r
-\r
-static DfaState st20[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  50, 50, 50, 57, 50, 50, 50, 436, 436, 436, \r
-  436, 50, 50, 50, 50, 50, 50, 50, 50, 50, \r
-  50, 50, 50, 50, 50, 50, 50, 436, 50, 436, \r
-  436, 436, 436, 50, 436, 436, 436, 436, 436, 436, \r
-  436, 50, 436, 436, 50, 50, 50, 50, 436, 436\r
-};\r
-\r
-static DfaState st21[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st22[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  58, 50, 50, 50, 50, 50, 50, 436, 436, 436, \r
-  436, 50, 50, 59, 50, 50, 50, 50, 50, 50, \r
-  50, 50, 50, 50, 50, 50, 50, 436, 50, 436, \r
-  436, 436, 436, 50, 436, 436, 436, 436, 436, 436, \r
-  436, 50, 436, 436, 50, 50, 50, 50, 436, 436\r
-};\r
-\r
-static DfaState st23[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st24[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st25[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st26[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st27[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 60, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st28[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 61, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st29[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st30[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st31[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 62, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st32[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st33[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st34[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  56, 56, 56, 56, 56, 56, 56, 436, 436, 436, \r
-  436, 56, 56, 56, 56, 56, 56, 56, 56, 56, \r
-  56, 56, 56, 56, 56, 56, 56, 436, 56, 436, \r
-  436, 436, 436, 56, 436, 436, 436, 436, 436, 436, \r
-  436, 63, 436, 436, 56, 56, 56, 56, 436, 436\r
-};\r
-\r
-static DfaState st35[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st36[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st37[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st38[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st39[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st40[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st41[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st42[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  43, 64, 43, 65, 43, 43, 43, 436, 436, 436, \r
-  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
-  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
-  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
-};\r
-\r
-static DfaState st43[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
-  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
-  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
-  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
-};\r
-\r
-static DfaState st44[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
-  436, 43, 66, 43, 43, 43, 43, 43, 43, 43, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
-  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
-  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
-};\r
-\r
-static DfaState st45[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
-  436, 43, 67, 68, 43, 43, 43, 43, 43, 43, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
-  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
-  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
-};\r
-\r
-static DfaState st46[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  43, 69, 43, 43, 43, 43, 43, 436, 436, 436, \r
-  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
-  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
-  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
-};\r
-\r
-static DfaState st47[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
-  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
-  43, 43, 70, 43, 43, 43, 43, 436, 43, 436, \r
-  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
-  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
-};\r
-\r
-static DfaState st48[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  43, 43, 43, 71, 43, 43, 43, 436, 436, 436, \r
-  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
-  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
-  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
-};\r
-\r
-static DfaState st49[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  43, 72, 43, 43, 43, 43, 43, 436, 436, 436, \r
-  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
-  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
-  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
-};\r
-\r
-static DfaState st50[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  50, 50, 50, 50, 50, 50, 50, 436, 436, 436, \r
-  436, 50, 50, 50, 50, 50, 50, 50, 50, 50, \r
-  50, 50, 50, 50, 50, 50, 50, 436, 50, 436, \r
-  436, 436, 436, 50, 436, 436, 436, 436, 436, 436, \r
-  436, 50, 436, 436, 50, 50, 50, 50, 436, 436\r
-};\r
-\r
-static DfaState st51[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  50, 50, 50, 50, 50, 50, 50, 436, 436, 436, \r
-  436, 50, 50, 50, 50, 50, 50, 50, 50, 50, \r
-  50, 50, 50, 50, 50, 50, 50, 436, 73, 436, \r
-  436, 436, 436, 50, 436, 436, 436, 436, 436, 436, \r
-  436, 50, 436, 436, 50, 50, 50, 50, 436, 436\r
-};\r
-\r
-static DfaState st52[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st53[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st54[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  74, 43, 43, 44, 43, 43, 43, 436, 436, 436, \r
-  436, 45, 43, 43, 43, 43, 46, 43, 47, 43, \r
-  43, 43, 43, 48, 43, 49, 43, 436, 43, 436, \r
-  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
-  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
-};\r
-\r
-static DfaState st55[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  50, 50, 50, 50, 50, 50, 50, 436, 436, 436, \r
-  436, 75, 50, 50, 50, 50, 50, 50, 50, 50, \r
-  50, 50, 50, 50, 50, 50, 50, 436, 50, 436, \r
-  436, 436, 436, 50, 436, 436, 436, 436, 436, 436, \r
-  436, 50, 436, 436, 50, 50, 50, 50, 436, 436\r
-};\r
-\r
-static DfaState st56[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  56, 56, 56, 56, 56, 56, 56, 436, 436, 436, \r
-  436, 56, 56, 56, 56, 56, 56, 56, 56, 56, \r
-  56, 56, 56, 56, 56, 56, 56, 436, 56, 436, \r
-  436, 436, 436, 56, 436, 436, 436, 436, 436, 436, \r
-  436, 56, 436, 436, 56, 56, 56, 56, 436, 436\r
-};\r
-\r
-static DfaState st57[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  50, 50, 50, 50, 50, 50, 50, 436, 436, 436, \r
-  436, 50, 50, 50, 50, 50, 50, 50, 50, 50, \r
-  50, 50, 50, 50, 50, 76, 50, 436, 50, 436, \r
-  436, 436, 436, 50, 436, 436, 436, 436, 436, 436, \r
-  436, 50, 436, 436, 50, 50, 50, 50, 436, 436\r
-};\r
-\r
-static DfaState st58[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  50, 50, 50, 50, 50, 50, 50, 436, 436, 436, \r
-  436, 50, 50, 77, 50, 50, 50, 50, 50, 50, \r
-  50, 50, 50, 50, 50, 50, 50, 436, 50, 436, \r
-  436, 436, 436, 50, 436, 436, 436, 436, 436, 436, \r
-  436, 50, 436, 436, 50, 50, 50, 50, 436, 436\r
-};\r
-\r
-static DfaState st59[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  50, 50, 50, 50, 50, 50, 50, 436, 436, 436, \r
-  436, 50, 50, 50, 50, 50, 50, 50, 78, 50, \r
-  50, 50, 50, 50, 50, 50, 50, 436, 50, 436, \r
-  436, 436, 436, 50, 436, 436, 436, 436, 436, 436, \r
-  436, 50, 436, 436, 50, 50, 50, 50, 436, 436\r
-};\r
-\r
-static DfaState st60[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st61[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st62[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st63[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  56, 56, 56, 56, 56, 56, 56, 436, 436, 436, \r
-  436, 56, 56, 56, 56, 56, 56, 56, 56, 56, \r
-  56, 56, 56, 56, 56, 56, 56, 436, 56, 436, \r
-  436, 436, 436, 56, 436, 436, 79, 436, 436, 436, \r
-  436, 56, 436, 436, 56, 56, 56, 56, 436, 436\r
-};\r
-\r
-static DfaState st64[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  43, 43, 80, 43, 43, 43, 43, 436, 436, 436, \r
-  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
-  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
-  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
-};\r
-\r
-static DfaState st65[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
-  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
-  436, 436, 436, 81, 436, 436, 436, 436, 436, 436, \r
-  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
-};\r
-\r
-static DfaState st66[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
-  436, 43, 82, 43, 43, 43, 43, 43, 43, 43, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
-  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
-  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
-};\r
-\r
-static DfaState st67[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  43, 43, 43, 83, 43, 43, 43, 436, 436, 436, \r
-  436, 43, 43, 84, 43, 43, 43, 43, 43, 43, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
-  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
-  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
-};\r
-\r
-static DfaState st68[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
-  436, 43, 85, 43, 43, 43, 43, 43, 43, 43, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
-  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
-  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
-};\r
-\r
-static DfaState st69[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
-  436, 43, 86, 43, 43, 43, 43, 43, 43, 43, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
-  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
-  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
-};\r
-\r
-static DfaState st70[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
-  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
-  43, 43, 43, 43, 43, 43, 87, 436, 43, 436, \r
-  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
-  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
-};\r
-\r
-static DfaState st71[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
-  436, 43, 43, 88, 43, 43, 43, 43, 43, 43, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
-  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
-  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
-};\r
-\r
-static DfaState st72[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
-  436, 43, 89, 43, 43, 43, 43, 43, 43, 43, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
-  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
-  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
-};\r
-\r
-static DfaState st73[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  50, 50, 50, 90, 50, 50, 50, 436, 436, 436, \r
-  436, 50, 50, 50, 50, 50, 50, 50, 50, 50, \r
-  50, 50, 50, 50, 50, 50, 50, 436, 50, 436, \r
-  436, 436, 436, 50, 436, 436, 436, 436, 436, 436, \r
-  436, 50, 436, 436, 50, 50, 50, 50, 436, 436\r
-};\r
-\r
-static DfaState st74[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  43, 43, 43, 65, 43, 43, 43, 436, 436, 436, \r
-  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
-  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
-  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
-};\r
-\r
-static DfaState st75[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  50, 50, 50, 50, 50, 50, 50, 436, 436, 436, \r
-  436, 50, 91, 50, 50, 50, 50, 50, 50, 50, \r
-  50, 50, 50, 50, 50, 50, 50, 436, 50, 436, \r
-  436, 436, 436, 50, 436, 436, 436, 436, 436, 436, \r
-  436, 50, 436, 436, 50, 50, 50, 50, 436, 436\r
-};\r
-\r
-static DfaState st76[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  50, 50, 50, 50, 50, 50, 50, 436, 436, 436, \r
-  436, 50, 50, 92, 50, 50, 50, 50, 50, 50, \r
-  50, 50, 50, 50, 50, 50, 50, 436, 50, 436, \r
-  436, 436, 436, 50, 436, 436, 436, 436, 436, 436, \r
-  436, 50, 436, 436, 50, 50, 50, 50, 436, 436\r
-};\r
-\r
-static DfaState st77[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  50, 50, 50, 50, 50, 50, 50, 436, 436, 436, \r
-  436, 50, 50, 50, 50, 50, 50, 93, 50, 50, \r
-  50, 50, 50, 50, 50, 50, 50, 436, 50, 436, \r
-  436, 436, 436, 50, 436, 436, 436, 436, 436, 436, \r
-  436, 50, 436, 436, 50, 50, 50, 50, 436, 436\r
-};\r
-\r
-static DfaState st78[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  50, 50, 50, 50, 50, 50, 50, 436, 436, 436, \r
-  436, 50, 50, 50, 50, 50, 50, 50, 50, 50, \r
-  50, 50, 50, 50, 50, 50, 50, 436, 94, 436, \r
-  436, 436, 436, 50, 436, 436, 436, 436, 436, 436, \r
-  436, 50, 436, 436, 50, 50, 50, 50, 436, 436\r
-};\r
-\r
-static DfaState st79[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 95, 96, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st80[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  43, 43, 43, 97, 43, 43, 43, 436, 436, 436, \r
-  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
-  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
-  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
-};\r
-\r
-static DfaState st81[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
-  436, 98, 43, 99, 43, 100, 43, 43, 43, 43, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 101, 436, \r
-  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
-  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
-};\r
-\r
-static DfaState st82[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
-  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 102, 436, \r
-  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
-  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
-};\r
-\r
-static DfaState st83[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
-  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
-  43, 43, 43, 43, 103, 43, 43, 436, 43, 436, \r
-  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
-  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
-};\r
-\r
-static DfaState st84[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
-  436, 43, 43, 43, 104, 43, 43, 43, 43, 43, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
-  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
-  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
-};\r
-\r
-static DfaState st85[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
-  436, 43, 43, 43, 43, 43, 43, 105, 43, 43, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
-  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
-  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
-};\r
-\r
-static DfaState st86[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
-  436, 43, 43, 43, 43, 43, 43, 106, 43, 43, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
-  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
-  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
-};\r
-\r
-static DfaState st87[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  43, 43, 43, 107, 43, 43, 43, 436, 436, 436, \r
-  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
-  43, 43, 43, 43, 108, 43, 43, 436, 109, 436, \r
-  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
-  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
-};\r
-\r
-static DfaState st88[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
-  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
-  43, 43, 43, 43, 110, 43, 43, 436, 43, 436, \r
-  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
-  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
-};\r
-\r
-static DfaState st89[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
-  436, 43, 43, 43, 43, 43, 43, 111, 43, 43, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
-  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
-  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
-};\r
-\r
-static DfaState st90[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  50, 50, 50, 50, 50, 50, 50, 436, 436, 436, \r
-  436, 112, 50, 50, 50, 50, 50, 50, 50, 50, \r
-  50, 50, 50, 50, 50, 50, 50, 436, 50, 436, \r
-  436, 436, 436, 50, 436, 436, 436, 436, 436, 436, \r
-  436, 50, 436, 436, 50, 50, 50, 50, 436, 436\r
-};\r
-\r
-static DfaState st91[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  50, 50, 50, 50, 50, 50, 50, 436, 436, 436, \r
-  436, 50, 50, 50, 50, 50, 50, 50, 50, 50, \r
-  50, 50, 113, 50, 50, 50, 50, 436, 50, 436, \r
-  436, 436, 436, 50, 436, 436, 436, 436, 436, 436, \r
-  436, 50, 436, 436, 50, 50, 50, 50, 436, 436\r
-};\r
-\r
-static DfaState st92[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  50, 50, 50, 50, 50, 50, 50, 436, 436, 436, \r
-  436, 50, 50, 50, 50, 50, 50, 50, 50, 50, \r
-  50, 50, 50, 50, 50, 50, 50, 436, 50, 436, \r
-  436, 436, 436, 50, 436, 436, 436, 436, 436, 436, \r
-  436, 50, 436, 436, 114, 50, 50, 50, 436, 436\r
-};\r
-\r
-static DfaState st93[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  50, 50, 50, 50, 50, 50, 50, 436, 436, 436, \r
-  436, 50, 50, 50, 50, 50, 50, 115, 50, 50, \r
-  50, 50, 50, 50, 50, 50, 50, 436, 50, 436, \r
-  436, 436, 436, 50, 436, 436, 436, 436, 436, 436, \r
-  436, 50, 436, 436, 50, 50, 50, 50, 436, 436\r
-};\r
-\r
-static DfaState st94[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  50, 50, 50, 50, 50, 50, 50, 436, 436, 436, \r
-  436, 50, 50, 50, 50, 50, 50, 50, 50, 50, \r
-  50, 50, 50, 116, 50, 50, 50, 436, 50, 436, \r
-  436, 436, 436, 50, 436, 436, 436, 436, 436, 436, \r
-  436, 50, 436, 436, 50, 50, 50, 50, 436, 436\r
-};\r
-\r
-static DfaState st95[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 117, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st96[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 118, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st97[60] = {\r
-  436, 119, 120, 121, 122, 122, 122, 122, 122, 122, \r
-  123, 123, 123, 123, 124, 124, 124, 122, 122, 122, \r
-  122, 123, 123, 123, 123, 123, 123, 123, 123, 123, \r
-  123, 123, 123, 123, 123, 123, 123, 122, 123, 122, \r
-  122, 122, 122, 123, 122, 122, 122, 122, 122, 122, \r
-  122, 123, 122, 122, 123, 123, 123, 123, 122, 436\r
-};\r
-\r
-static DfaState st98[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
-  436, 43, 125, 43, 43, 43, 43, 43, 43, 43, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
-  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
-  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
-};\r
-\r
-static DfaState st99[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
-  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 126, 436, \r
-  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
-  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
-};\r
-\r
-static DfaState st100[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  43, 43, 43, 127, 43, 43, 43, 436, 436, 436, \r
-  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
-  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
-  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
-};\r
-\r
-static DfaState st101[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  128, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
-  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
-  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
-  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
-};\r
-\r
-static DfaState st102[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  129, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
-  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
-  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
-  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
-};\r
-\r
-static DfaState st103[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
-  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
-  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
-  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
-};\r
-\r
-static DfaState st104[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
-  436, 43, 43, 43, 43, 130, 43, 43, 43, 43, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
-  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
-  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
-};\r
-\r
-static DfaState st105[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  43, 43, 43, 131, 43, 43, 43, 436, 436, 436, \r
-  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
-  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
-  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
-};\r
-\r
-static DfaState st106[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
-  436, 43, 43, 43, 43, 43, 43, 43, 132, 43, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
-  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
-  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
-};\r
-\r
-static DfaState st107[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  43, 43, 133, 43, 43, 43, 43, 436, 436, 436, \r
-  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
-  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
-  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
-};\r
-\r
-static DfaState st108[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  43, 43, 43, 134, 43, 43, 43, 436, 436, 436, \r
-  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
-  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
-  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
-};\r
-\r
-static DfaState st109[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  135, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
-  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
-  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
-  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
-};\r
-\r
-static DfaState st110[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  43, 43, 43, 136, 43, 43, 43, 436, 436, 436, \r
-  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
-  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
-  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
-};\r
-\r
-static DfaState st111[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
-  436, 43, 43, 43, 43, 43, 43, 43, 137, 43, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
-  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
-  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
-};\r
-\r
-static DfaState st112[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  50, 50, 50, 50, 50, 50, 50, 436, 436, 436, \r
-  436, 50, 50, 50, 50, 50, 50, 50, 138, 50, \r
-  50, 50, 50, 50, 50, 50, 50, 436, 50, 436, \r
-  436, 436, 436, 50, 436, 436, 436, 436, 436, 436, \r
-  436, 50, 436, 436, 50, 50, 50, 50, 436, 436\r
-};\r
-\r
-static DfaState st113[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  50, 50, 50, 50, 50, 50, 50, 436, 436, 436, \r
-  436, 50, 50, 50, 50, 50, 50, 50, 50, 50, \r
-  50, 50, 50, 50, 50, 50, 50, 436, 50, 436, \r
-  436, 436, 436, 139, 436, 436, 436, 436, 436, 436, \r
-  436, 50, 436, 436, 50, 50, 50, 50, 436, 436\r
-};\r
-\r
-static DfaState st114[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  140, 50, 50, 50, 50, 50, 50, 436, 436, 436, \r
-  436, 50, 50, 50, 50, 50, 50, 50, 50, 50, \r
-  50, 50, 50, 50, 50, 50, 50, 436, 50, 436, \r
-  436, 436, 436, 50, 436, 436, 436, 436, 436, 436, \r
-  436, 50, 436, 436, 50, 50, 50, 50, 436, 436\r
-};\r
-\r
-static DfaState st115[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  50, 50, 50, 50, 50, 50, 50, 436, 436, 436, \r
-  436, 50, 50, 50, 50, 50, 50, 50, 50, 50, \r
-  50, 50, 50, 50, 50, 50, 50, 436, 50, 436, \r
-  436, 436, 436, 50, 436, 436, 436, 436, 436, 436, \r
-  436, 50, 436, 436, 50, 50, 50, 50, 436, 436\r
-};\r
-\r
-static DfaState st116[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  50, 50, 50, 50, 50, 50, 50, 436, 436, 436, \r
-  436, 50, 50, 50, 50, 50, 50, 50, 50, 50, \r
-  50, 50, 50, 50, 50, 50, 50, 436, 50, 436, \r
-  436, 436, 436, 50, 436, 436, 436, 436, 436, 436, \r
-  436, 50, 436, 436, 50, 50, 50, 50, 436, 436\r
-};\r
-\r
-static DfaState st117[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st118[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st119[60] = {\r
-  436, 119, 120, 121, 122, 122, 122, 122, 122, 122, \r
-  122, 122, 122, 122, 141, 141, 141, 122, 122, 122, \r
-  122, 122, 122, 122, 122, 122, 122, 122, 122, 122, \r
-  122, 122, 122, 122, 122, 122, 122, 122, 122, 122, \r
-  122, 122, 122, 122, 122, 122, 122, 122, 122, 122, \r
-  122, 122, 122, 122, 122, 122, 122, 122, 122, 436\r
-};\r
-\r
-static DfaState st120[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st121[60] = {\r
-  436, 436, 142, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st122[60] = {\r
-  436, 122, 120, 121, 122, 122, 122, 122, 122, 122, \r
-  122, 122, 122, 122, 122, 122, 122, 122, 122, 122, \r
-  122, 122, 122, 122, 122, 122, 122, 122, 122, 122, \r
-  122, 122, 122, 122, 122, 122, 122, 122, 122, 122, \r
-  122, 122, 122, 122, 122, 122, 122, 122, 122, 122, \r
-  122, 122, 122, 122, 122, 122, 122, 122, 122, 436\r
-};\r
-\r
-static DfaState st123[60] = {\r
-  436, 122, 120, 121, 122, 122, 122, 122, 122, 122, \r
-  123, 123, 123, 123, 123, 123, 123, 122, 122, 122, \r
-  122, 123, 123, 123, 123, 123, 123, 123, 123, 123, \r
-  123, 123, 123, 123, 123, 123, 123, 122, 123, 122, \r
-  122, 122, 122, 123, 122, 122, 122, 122, 122, 122, \r
-  122, 123, 122, 122, 123, 123, 123, 123, 122, 436\r
-};\r
-\r
-static DfaState st124[60] = {\r
-  436, 143, 144, 145, 122, 122, 146, 122, 122, 122, \r
-  123, 123, 123, 123, 124, 124, 124, 122, 122, 122, \r
-  122, 123, 123, 123, 123, 123, 123, 123, 123, 123, \r
-  123, 123, 123, 123, 123, 123, 123, 122, 123, 122, \r
-  122, 122, 122, 123, 122, 122, 122, 122, 122, 122, \r
-  122, 123, 122, 122, 123, 123, 123, 123, 122, 436\r
-};\r
-\r
-static DfaState st125[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  43, 43, 43, 147, 43, 43, 43, 436, 436, 436, \r
-  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
-  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
-  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
-};\r
-\r
-static DfaState st126[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
-  436, 43, 43, 43, 43, 43, 43, 43, 148, 43, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
-  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
-  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
-};\r
-\r
-static DfaState st127[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
-  436, 43, 43, 43, 43, 149, 43, 43, 43, 43, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
-  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
-  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
-};\r
-\r
-static DfaState st128[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
-  436, 43, 43, 150, 43, 43, 43, 43, 43, 43, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
-  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
-  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
-};\r
-\r
-static DfaState st129[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
-  436, 43, 43, 151, 43, 43, 43, 43, 43, 43, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
-  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
-  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
-};\r
-\r
-static DfaState st130[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
-  436, 43, 43, 152, 43, 43, 43, 43, 43, 43, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
-  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
-  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
-};\r
-\r
-static DfaState st131[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
-  436, 43, 153, 43, 43, 43, 43, 43, 43, 43, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
-  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
-  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
-};\r
-\r
-static DfaState st132[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
-  436, 43, 43, 43, 43, 43, 43, 43, 43, 154, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
-  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
-  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
-};\r
-\r
-static DfaState st133[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
-  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
-  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
-  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
-};\r
-\r
-static DfaState st134[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
-  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
-  43, 43, 43, 43, 43, 155, 43, 436, 43, 436, \r
-  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
-  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
-};\r
-\r
-static DfaState st135[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
-  436, 43, 43, 156, 43, 43, 43, 43, 43, 43, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
-  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
-  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
-};\r
-\r
-static DfaState st136[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
-  436, 43, 157, 43, 43, 43, 43, 43, 43, 43, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
-  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
-  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
-};\r
-\r
-static DfaState st137[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
-  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
-  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
-  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
-};\r
-\r
-static DfaState st138[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  50, 158, 50, 50, 50, 50, 50, 436, 436, 436, \r
-  436, 50, 50, 50, 50, 50, 50, 50, 50, 50, \r
-  50, 50, 50, 50, 50, 50, 50, 436, 50, 436, \r
-  436, 436, 436, 50, 436, 436, 436, 436, 436, 436, \r
-  436, 50, 436, 436, 50, 50, 50, 50, 436, 436\r
-};\r
-\r
-static DfaState st139[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  50, 50, 50, 50, 50, 50, 50, 436, 436, 436, \r
-  436, 50, 50, 50, 50, 50, 50, 50, 50, 50, \r
-  50, 50, 50, 50, 50, 50, 50, 436, 50, 436, \r
-  436, 436, 436, 50, 436, 436, 436, 436, 436, 436, \r
-  436, 50, 436, 436, 50, 50, 50, 50, 436, 436\r
-};\r
-\r
-static DfaState st140[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  50, 50, 50, 50, 50, 50, 50, 436, 436, 436, \r
-  436, 50, 50, 50, 50, 50, 50, 50, 159, 50, \r
-  50, 50, 50, 50, 50, 50, 50, 436, 50, 436, \r
-  436, 436, 436, 50, 436, 436, 436, 436, 436, 436, \r
-  436, 50, 436, 436, 50, 50, 50, 50, 436, 436\r
-};\r
-\r
-static DfaState st141[60] = {\r
-  436, 143, 144, 145, 122, 122, 146, 122, 122, 122, \r
-  122, 122, 122, 122, 141, 141, 141, 122, 122, 122, \r
-  122, 122, 122, 122, 122, 122, 122, 122, 122, 122, \r
-  122, 122, 122, 122, 122, 122, 122, 122, 122, 122, \r
-  122, 122, 122, 122, 122, 122, 122, 122, 122, 122, \r
-  122, 122, 122, 122, 122, 122, 122, 122, 122, 436\r
-};\r
-\r
-static DfaState st142[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st143[60] = {\r
-  436, 143, 120, 121, 122, 122, 146, 122, 122, 122, \r
-  122, 122, 122, 122, 122, 122, 122, 122, 122, 122, \r
-  122, 122, 122, 122, 122, 122, 122, 122, 122, 122, \r
-  122, 122, 122, 122, 122, 122, 122, 122, 122, 122, \r
-  122, 122, 122, 122, 122, 122, 122, 122, 122, 122, \r
-  122, 122, 122, 122, 122, 122, 122, 122, 122, 436\r
-};\r
-\r
-static DfaState st144[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st145[60] = {\r
-  436, 436, 160, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st146[60] = {\r
-  436, 161, 162, 163, 161, 161, 122, 161, 161, 161, \r
-  161, 161, 161, 161, 161, 161, 161, 161, 161, 161, \r
-  161, 161, 161, 161, 161, 161, 161, 161, 161, 161, \r
-  161, 161, 161, 161, 161, 161, 161, 161, 161, 161, \r
-  161, 161, 161, 161, 161, 161, 161, 161, 161, 161, \r
-  161, 161, 161, 161, 161, 161, 161, 161, 161, 436\r
-};\r
-\r
-static DfaState st147[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
-  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
-  43, 43, 43, 43, 43, 164, 43, 436, 43, 436, \r
-  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
-  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
-};\r
-\r
-static DfaState st148[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  43, 165, 43, 43, 43, 43, 43, 436, 436, 436, \r
-  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
-  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
-  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
-};\r
-\r
-static DfaState st149[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
-  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
-  43, 166, 43, 43, 43, 43, 43, 436, 43, 436, \r
-  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
-  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
-};\r
-\r
-static DfaState st150[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
-  436, 43, 43, 43, 43, 43, 43, 167, 43, 43, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
-  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
-  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
-};\r
-\r
-static DfaState st151[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
-  436, 43, 43, 43, 43, 43, 43, 168, 43, 43, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
-  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
-  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
-};\r
-\r
-static DfaState st152[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
-  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
-  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
-  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
-};\r
-\r
-static DfaState st153[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
-  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
-  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
-  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
-};\r
-\r
-static DfaState st154[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  43, 43, 43, 169, 43, 43, 43, 436, 436, 436, \r
-  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
-  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
-  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
-};\r
-\r
-static DfaState st155[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
-  436, 43, 43, 43, 43, 43, 43, 170, 43, 43, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
-  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
-  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
-};\r
-\r
-static DfaState st156[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
-  436, 43, 43, 43, 43, 43, 43, 171, 43, 43, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
-  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
-  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
-};\r
-\r
-static DfaState st157[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
-  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
-  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
-  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
-};\r
-\r
-static DfaState st158[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  50, 50, 50, 50, 50, 50, 50, 436, 436, 436, \r
-  436, 50, 50, 50, 50, 50, 50, 50, 50, 50, \r
-  50, 50, 172, 50, 50, 50, 50, 436, 50, 436, \r
-  436, 436, 436, 50, 436, 436, 436, 436, 436, 436, \r
-  436, 50, 436, 436, 50, 50, 50, 50, 436, 436\r
-};\r
-\r
-static DfaState st159[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  50, 50, 50, 50, 50, 50, 50, 436, 436, 436, \r
-  436, 50, 50, 50, 50, 50, 50, 50, 50, 50, \r
-  50, 50, 50, 50, 50, 50, 50, 436, 50, 436, \r
-  436, 436, 436, 50, 436, 436, 436, 436, 436, 436, \r
-  436, 50, 436, 436, 50, 50, 50, 50, 436, 436\r
-};\r
-\r
-static DfaState st160[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st161[60] = {\r
-  436, 161, 162, 163, 161, 161, 173, 161, 161, 161, \r
-  161, 161, 161, 161, 161, 161, 161, 161, 161, 161, \r
-  161, 161, 161, 161, 161, 161, 161, 161, 161, 161, \r
-  161, 161, 161, 161, 161, 161, 161, 161, 161, 161, \r
-  161, 161, 161, 161, 161, 161, 161, 161, 161, 161, \r
-  161, 161, 161, 161, 161, 161, 161, 161, 161, 436\r
-};\r
-\r
-static DfaState st162[60] = {\r
-  436, 174, 174, 174, 174, 174, 175, 174, 174, 174, \r
-  174, 174, 174, 174, 174, 174, 174, 174, 174, 174, \r
-  174, 174, 174, 174, 174, 174, 174, 174, 174, 174, \r
-  174, 174, 174, 174, 174, 174, 174, 174, 174, 174, \r
-  174, 174, 174, 174, 174, 174, 174, 174, 174, 174, \r
-  174, 174, 174, 174, 174, 174, 174, 174, 174, 436\r
-};\r
-\r
-static DfaState st163[60] = {\r
-  436, 174, 176, 174, 174, 174, 175, 174, 174, 174, \r
-  174, 174, 174, 174, 174, 174, 174, 174, 174, 174, \r
-  174, 174, 174, 174, 174, 174, 174, 174, 174, 174, \r
-  174, 174, 174, 174, 174, 174, 174, 174, 174, 174, \r
-  174, 174, 174, 174, 174, 174, 174, 174, 174, 174, \r
-  174, 174, 174, 174, 174, 174, 174, 174, 174, 436\r
-};\r
-\r
-static DfaState st164[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  43, 177, 43, 43, 43, 43, 43, 436, 436, 436, \r
-  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
-  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
-  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
-};\r
-\r
-static DfaState st165[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
-  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
-  43, 43, 178, 43, 43, 43, 43, 436, 43, 436, \r
-  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
-  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
-};\r
-\r
-static DfaState st166[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  43, 43, 43, 179, 43, 43, 43, 436, 436, 436, \r
-  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
-  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
-  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
-};\r
-\r
-static DfaState st167[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
-  436, 43, 43, 43, 43, 43, 43, 180, 43, 43, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
-  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
-  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
-};\r
-\r
-static DfaState st168[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
-  436, 43, 43, 43, 43, 43, 43, 181, 43, 43, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
-  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
-  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
-};\r
-\r
-static DfaState st169[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
-  436, 43, 43, 43, 43, 43, 43, 43, 182, 43, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
-  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
-  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
-};\r
-\r
-static DfaState st170[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
-  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
-  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
-  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
-};\r
-\r
-static DfaState st171[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
-  436, 43, 43, 43, 43, 43, 43, 183, 43, 43, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
-  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
-  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
-};\r
-\r
-static DfaState st172[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  50, 50, 184, 50, 50, 50, 50, 436, 436, 436, \r
-  436, 50, 50, 50, 50, 50, 50, 50, 50, 50, \r
-  50, 50, 50, 50, 50, 50, 50, 436, 50, 436, \r
-  436, 436, 436, 50, 436, 436, 436, 436, 436, 436, \r
-  436, 50, 436, 436, 50, 50, 50, 50, 436, 436\r
-};\r
-\r
-static DfaState st173[60] = {\r
-  436, 185, 144, 145, 122, 122, 122, 122, 122, 122, \r
-  122, 122, 122, 122, 186, 186, 186, 122, 122, 122, \r
-  122, 122, 122, 122, 122, 122, 122, 122, 122, 122, \r
-  122, 122, 122, 122, 122, 122, 122, 122, 122, 122, \r
-  122, 122, 122, 122, 122, 122, 122, 122, 122, 122, \r
-  122, 122, 122, 122, 122, 122, 122, 122, 122, 436\r
-};\r
-\r
-static DfaState st174[60] = {\r
-  436, 174, 174, 174, 174, 174, 175, 174, 174, 174, \r
-  174, 174, 174, 174, 174, 174, 174, 174, 174, 174, \r
-  174, 174, 174, 174, 174, 174, 174, 174, 174, 174, \r
-  174, 174, 174, 174, 174, 174, 174, 174, 174, 174, \r
-  174, 174, 174, 174, 174, 174, 174, 174, 174, 174, \r
-  174, 174, 174, 174, 174, 174, 174, 174, 174, 436\r
-};\r
-\r
-static DfaState st175[60] = {\r
-  436, 187, 188, 189, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 190, 190, 190, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st176[60] = {\r
-  436, 174, 174, 174, 174, 174, 175, 174, 174, 174, \r
-  174, 174, 174, 174, 174, 174, 174, 174, 174, 174, \r
-  174, 174, 174, 174, 174, 174, 174, 174, 174, 174, \r
-  174, 174, 174, 174, 174, 174, 174, 174, 174, 174, \r
-  174, 174, 174, 174, 174, 174, 174, 174, 174, 174, \r
-  174, 174, 174, 174, 174, 174, 174, 174, 174, 436\r
-};\r
-\r
-static DfaState st177[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
-  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
-  436, 436, 436, 191, 436, 436, 436, 436, 436, 436, \r
-  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
-};\r
-\r
-static DfaState st178[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  43, 43, 192, 43, 43, 43, 43, 436, 436, 436, \r
-  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
-  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
-  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
-};\r
-\r
-static DfaState st179[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
-  436, 43, 193, 43, 43, 43, 43, 43, 43, 43, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
-  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
-  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
-};\r
-\r
-static DfaState st180[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
-  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
-  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
-  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
-};\r
-\r
-static DfaState st181[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
-  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
-  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
-  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
-};\r
-\r
-static DfaState st182[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
-  436, 43, 43, 43, 43, 43, 43, 43, 43, 194, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
-  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
-  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
-};\r
-\r
-static DfaState st183[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
-  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
-  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
-  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
-};\r
-\r
-static DfaState st184[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  50, 50, 50, 50, 50, 50, 50, 436, 436, 436, \r
-  436, 50, 50, 50, 50, 50, 50, 50, 50, 50, \r
-  50, 50, 50, 50, 50, 50, 50, 436, 50, 436, \r
-  436, 436, 436, 50, 436, 436, 436, 436, 436, 436, \r
-  436, 50, 436, 436, 50, 50, 50, 50, 436, 436\r
-};\r
-\r
-static DfaState st185[60] = {\r
-  436, 185, 144, 145, 122, 122, 122, 122, 122, 122, \r
-  122, 122, 122, 122, 186, 186, 186, 122, 122, 122, \r
-  122, 122, 122, 122, 122, 122, 122, 122, 122, 122, \r
-  122, 122, 122, 122, 122, 122, 122, 122, 122, 122, \r
-  122, 122, 122, 122, 122, 122, 122, 122, 122, 122, \r
-  122, 122, 122, 122, 122, 122, 122, 122, 122, 436\r
-};\r
-\r
-static DfaState st186[60] = {\r
-  436, 185, 144, 145, 122, 122, 122, 122, 122, 122, \r
-  122, 122, 122, 122, 186, 186, 186, 122, 122, 122, \r
-  122, 122, 122, 122, 122, 122, 122, 122, 122, 122, \r
-  122, 122, 122, 122, 122, 122, 122, 122, 122, 122, \r
-  122, 122, 122, 122, 122, 122, 122, 122, 122, 122, \r
-  122, 122, 122, 122, 122, 122, 122, 122, 122, 436\r
-};\r
-\r
-static DfaState st187[60] = {\r
-  436, 187, 188, 189, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 190, 190, 190, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st188[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st189[60] = {\r
-  436, 436, 195, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st190[60] = {\r
-  436, 187, 188, 189, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 190, 190, 190, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st191[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
-  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
-  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
-  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
-};\r
-\r
-static DfaState st192[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
-  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
-  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
-  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
-};\r
-\r
-static DfaState st193[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
-  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
-  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
-  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
-};\r
-\r
-static DfaState st194[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
-  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
-  196, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
-  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
-  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
-};\r
-\r
-static DfaState st195[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st196[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
-  436, 43, 43, 43, 43, 197, 43, 43, 43, 43, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
-  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
-  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
-};\r
-\r
-static DfaState st197[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
-  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
-  43, 198, 43, 43, 43, 43, 43, 436, 43, 436, \r
-  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
-  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
-};\r
-\r
-static DfaState st198[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
-  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
-  43, 43, 199, 43, 43, 43, 43, 436, 43, 436, \r
-  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
-  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
-};\r
-\r
-static DfaState st199[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  200, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
-  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
-  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
-  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
-};\r
-\r
-static DfaState st200[60] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 436, 436, \r
-  436, 43, 43, 43, 43, 43, 43, 43, 43, 43, \r
-  43, 43, 43, 43, 43, 43, 43, 436, 43, 436, \r
-  436, 436, 436, 43, 436, 436, 436, 436, 436, 436, \r
-  436, 43, 436, 436, 43, 43, 43, 43, 436, 436\r
-};\r
-\r
-static DfaState st201[7] = {\r
-  202, 203, 204, 205, 206, 207, 436\r
-};\r
-\r
-static DfaState st202[7] = {\r
-  436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st203[7] = {\r
-  436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st204[7] = {\r
-  436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st205[7] = {\r
-  436, 436, 208, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st206[7] = {\r
-  436, 209, 210, 211, 209, 209, 436\r
-};\r
-\r
-static DfaState st207[7] = {\r
-  436, 436, 436, 436, 436, 207, 436\r
-};\r
-\r
-static DfaState st208[7] = {\r
-  436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st209[7] = {\r
-  436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st210[7] = {\r
-  436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st211[7] = {\r
-  436, 436, 212, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st212[7] = {\r
-  436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st213[7] = {\r
-  214, 215, 216, 217, 218, 219, 436\r
-};\r
-\r
-static DfaState st214[7] = {\r
-  436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st215[7] = {\r
-  436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st216[7] = {\r
-  436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st217[7] = {\r
-  436, 436, 220, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st218[7] = {\r
-  436, 221, 222, 223, 221, 221, 436\r
-};\r
-\r
-static DfaState st219[7] = {\r
-  436, 436, 436, 436, 436, 219, 436\r
-};\r
-\r
-static DfaState st220[7] = {\r
-  436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st221[7] = {\r
-  436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st222[7] = {\r
-  436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st223[7] = {\r
-  436, 436, 224, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st224[7] = {\r
-  436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st225[7] = {\r
-  226, 227, 228, 229, 230, 231, 436\r
-};\r
-\r
-static DfaState st226[7] = {\r
-  436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st227[7] = {\r
-  436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st228[7] = {\r
-  436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st229[7] = {\r
-  436, 436, 232, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st230[7] = {\r
-  436, 233, 233, 233, 233, 233, 436\r
-};\r
-\r
-static DfaState st231[7] = {\r
-  436, 436, 436, 436, 436, 231, 436\r
-};\r
-\r
-static DfaState st232[7] = {\r
-  436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st233[7] = {\r
-  436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st234[7] = {\r
-  235, 236, 237, 238, 239, 237, 436\r
-};\r
-\r
-static DfaState st235[7] = {\r
-  436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st236[7] = {\r
-  436, 436, 240, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st237[7] = {\r
-  436, 436, 237, 436, 436, 237, 436\r
-};\r
-\r
-static DfaState st238[7] = {\r
-  436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st239[7] = {\r
-  436, 436, 436, 241, 436, 436, 436\r
-};\r
-\r
-static DfaState st240[7] = {\r
-  436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st241[7] = {\r
-  436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st242[7] = {\r
-  243, 244, 245, 246, 247, 245, 436\r
-};\r
-\r
-static DfaState st243[7] = {\r
-  436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st244[7] = {\r
-  436, 436, 248, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st245[7] = {\r
-  436, 436, 245, 436, 436, 245, 436\r
-};\r
-\r
-static DfaState st246[7] = {\r
-  436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st247[7] = {\r
-  436, 436, 436, 249, 436, 436, 436\r
-};\r
-\r
-static DfaState st248[7] = {\r
-  436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st249[7] = {\r
-  436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st250[5] = {\r
-  251, 252, 253, 254, 436\r
-};\r
-\r
-static DfaState st251[5] = {\r
-  436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st252[5] = {\r
-  436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st253[5] = {\r
-  436, 255, 436, 436, 436\r
-};\r
-\r
-static DfaState st254[5] = {\r
-  436, 436, 436, 254, 436\r
-};\r
-\r
-static DfaState st255[5] = {\r
-  436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st256[5] = {\r
-  257, 258, 259, 260, 436\r
-};\r
-\r
-static DfaState st257[5] = {\r
-  436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st258[5] = {\r
-  436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st259[5] = {\r
-  436, 261, 436, 436, 436\r
-};\r
-\r
-static DfaState st260[5] = {\r
-  436, 436, 436, 260, 436\r
-};\r
-\r
-static DfaState st261[5] = {\r
-  436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st262[5] = {\r
-  263, 264, 265, 266, 436\r
-};\r
-\r
-static DfaState st263[5] = {\r
-  436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st264[5] = {\r
-  436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st265[5] = {\r
-  436, 267, 436, 436, 436\r
-};\r
-\r
-static DfaState st266[5] = {\r
-  436, 436, 436, 266, 436\r
-};\r
-\r
-static DfaState st267[5] = {\r
-  436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st268[7] = {\r
-  269, 270, 271, 272, 273, 271, 436\r
-};\r
-\r
-static DfaState st269[7] = {\r
-  436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st270[7] = {\r
-  436, 436, 274, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st271[7] = {\r
-  436, 436, 271, 436, 436, 271, 436\r
-};\r
-\r
-static DfaState st272[7] = {\r
-  436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st273[7] = {\r
-  436, 436, 436, 275, 436, 436, 436\r
-};\r
-\r
-static DfaState st274[7] = {\r
-  436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st275[7] = {\r
-  436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st276[36] = {\r
-  277, 278, 279, 280, 281, 279, 279, 279, 279, 279, \r
-  279, 279, 279, 279, 279, 282, 279, 279, 283, 284, \r
-  285, 286, 287, 279, 279, 279, 279, 288, 289, 290, \r
-  291, 292, 293, 279, 279, 436\r
-};\r
-\r
-static DfaState st277[36] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st278[36] = {\r
-  436, 294, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st279[36] = {\r
-  436, 436, 279, 436, 279, 279, 279, 279, 279, 279, \r
-  279, 279, 279, 279, 279, 436, 279, 279, 436, 436, \r
-  436, 436, 436, 279, 279, 279, 279, 436, 436, 436, \r
-  436, 436, 279, 279, 279, 436\r
-};\r
-\r
-static DfaState st280[36] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st281[36] = {\r
-  436, 436, 279, 436, 279, 295, 279, 279, 279, 279, \r
-  279, 279, 279, 279, 279, 436, 279, 279, 436, 436, \r
-  436, 436, 436, 279, 279, 279, 279, 436, 436, 436, \r
-  436, 436, 279, 279, 279, 436\r
-};\r
-\r
-static DfaState st282[36] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st283[36] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st284[36] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st285[36] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 296, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st286[36] = {\r
-  436, 436, 436, 436, 297, 297, 297, 297, 297, 297, \r
-  297, 297, 297, 297, 297, 436, 436, 436, 436, 436, \r
-  436, 298, 299, 300, 300, 436, 297, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st287[36] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st288[36] = {\r
-  436, 436, 436, 436, 301, 301, 301, 301, 301, 301, \r
-  301, 301, 301, 301, 302, 303, 436, 436, 436, 436, \r
-  436, 436, 304, 305, 306, 436, 301, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st289[36] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st290[36] = {\r
-  436, 307, 308, 309, 308, 308, 308, 308, 308, 308, \r
-  308, 308, 308, 308, 308, 308, 308, 308, 310, 311, \r
-  312, 313, 308, 308, 308, 308, 308, 314, 308, 308, \r
-  308, 308, 308, 308, 308, 436\r
-};\r
-\r
-static DfaState st291[36] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st292[36] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 315, 316, 436, 436, 436\r
-};\r
-\r
-static DfaState st293[36] = {\r
-  436, 436, 279, 436, 279, 279, 279, 279, 279, 279, \r
-  279, 279, 279, 279, 279, 436, 279, 279, 436, 436, \r
-  436, 436, 436, 279, 279, 279, 279, 436, 436, 436, \r
-  436, 317, 279, 279, 279, 436\r
-};\r
-\r
-static DfaState st294[36] = {\r
-  436, 436, 318, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st295[36] = {\r
-  436, 436, 279, 436, 279, 279, 319, 279, 279, 279, \r
-  279, 279, 279, 279, 279, 436, 279, 279, 436, 436, \r
-  436, 436, 436, 279, 279, 279, 279, 436, 436, 436, \r
-  436, 436, 279, 279, 279, 436\r
-};\r
-\r
-static DfaState st296[36] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st297[36] = {\r
-  436, 436, 436, 436, 320, 320, 320, 320, 320, 320, \r
-  320, 320, 320, 320, 320, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 320, 320, 436, 320, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st298[36] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st299[36] = {\r
-  436, 436, 436, 321, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st300[36] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 300, 300, 322, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st301[36] = {\r
-  436, 436, 436, 436, 323, 323, 323, 323, 323, 323, \r
-  323, 323, 323, 323, 323, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 323, 323, 436, 323, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st302[36] = {\r
-  436, 436, 436, 436, 323, 323, 323, 323, 323, 323, \r
-  323, 323, 323, 324, 323, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 323, 323, 436, 323, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st303[36] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 325, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st304[36] = {\r
-  436, 436, 436, 326, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st305[36] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 306, 306, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st306[36] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 306, 306, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st307[36] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st308[36] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st309[36] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st310[36] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st311[36] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st312[36] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 327, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st313[36] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st314[36] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st315[36] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st316[36] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st317[36] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st318[36] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st319[36] = {\r
-  436, 436, 279, 436, 279, 279, 279, 328, 279, 279, \r
-  279, 279, 279, 279, 279, 436, 279, 279, 436, 436, \r
-  436, 436, 436, 279, 279, 279, 279, 436, 436, 436, \r
-  436, 436, 279, 279, 279, 436\r
-};\r
-\r
-static DfaState st320[36] = {\r
-  436, 436, 436, 436, 320, 320, 320, 320, 320, 320, \r
-  320, 320, 320, 320, 320, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 320, 320, 436, 320, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st321[36] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st322[36] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 329, 329, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st323[36] = {\r
-  436, 436, 436, 436, 323, 323, 323, 323, 323, 323, \r
-  323, 323, 323, 323, 323, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 323, 323, 436, 323, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st324[36] = {\r
-  436, 436, 436, 436, 323, 323, 330, 323, 323, 323, \r
-  323, 323, 323, 323, 323, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 323, 323, 436, 323, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st325[36] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st326[36] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st327[36] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st328[36] = {\r
-  436, 436, 279, 436, 279, 279, 279, 279, 331, 279, \r
-  279, 279, 279, 279, 279, 436, 279, 279, 436, 436, \r
-  436, 436, 436, 279, 279, 279, 279, 436, 436, 436, \r
-  436, 436, 279, 279, 279, 436\r
-};\r
-\r
-static DfaState st329[36] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 329, 329, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st330[36] = {\r
-  436, 436, 436, 436, 323, 323, 323, 323, 323, 323, \r
-  332, 323, 323, 323, 323, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 323, 323, 436, 323, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st331[36] = {\r
-  436, 436, 279, 436, 279, 279, 279, 279, 279, 333, \r
-  279, 279, 279, 279, 279, 436, 279, 279, 436, 436, \r
-  436, 436, 436, 279, 279, 279, 279, 436, 436, 436, \r
-  436, 436, 279, 279, 279, 436\r
-};\r
-\r
-static DfaState st332[36] = {\r
-  436, 334, 334, 334, 335, 335, 335, 335, 335, 335, \r
-  335, 335, 335, 335, 335, 334, 336, 334, 334, 337, \r
-  338, 334, 334, 339, 339, 334, 335, 334, 334, 334, \r
-  334, 334, 334, 334, 334, 436\r
-};\r
-\r
-static DfaState st333[36] = {\r
-  436, 436, 279, 436, 279, 279, 279, 279, 279, 279, \r
-  340, 279, 279, 279, 279, 436, 279, 279, 436, 436, \r
-  436, 436, 436, 279, 279, 279, 279, 436, 436, 436, \r
-  436, 436, 279, 279, 279, 436\r
-};\r
-\r
-static DfaState st334[36] = {\r
-  436, 334, 334, 334, 334, 334, 334, 334, 334, 334, \r
-  334, 334, 334, 334, 334, 334, 334, 334, 334, 337, \r
-  338, 334, 334, 334, 334, 334, 334, 334, 334, 334, \r
-  334, 334, 334, 334, 334, 436\r
-};\r
-\r
-static DfaState st335[36] = {\r
-  436, 334, 334, 334, 335, 335, 335, 335, 335, 335, \r
-  335, 335, 335, 335, 335, 334, 334, 334, 334, 337, \r
-  338, 334, 334, 335, 335, 334, 335, 334, 334, 334, \r
-  334, 334, 334, 334, 334, 436\r
-};\r
-\r
-static DfaState st336[36] = {\r
-  436, 334, 334, 334, 334, 334, 334, 334, 334, 334, \r
-  334, 334, 334, 334, 334, 334, 336, 334, 334, 337, \r
-  338, 334, 334, 341, 341, 334, 334, 334, 334, 334, \r
-  334, 334, 334, 334, 334, 436\r
-};\r
-\r
-static DfaState st337[36] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st338[36] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 342, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st339[36] = {\r
-  436, 334, 334, 334, 335, 335, 335, 335, 335, 335, \r
-  335, 335, 335, 335, 335, 334, 343, 334, 334, 344, \r
-  345, 334, 334, 339, 339, 334, 335, 334, 346, 334, \r
-  334, 334, 334, 334, 334, 436\r
-};\r
-\r
-static DfaState st340[36] = {\r
-  436, 436, 279, 436, 279, 279, 279, 279, 279, 279, \r
-  279, 347, 279, 279, 279, 436, 279, 279, 436, 436, \r
-  436, 436, 436, 279, 279, 279, 279, 436, 436, 436, \r
-  436, 436, 279, 279, 279, 436\r
-};\r
-\r
-static DfaState st341[36] = {\r
-  436, 334, 334, 334, 334, 334, 334, 334, 334, 334, \r
-  334, 334, 334, 334, 334, 334, 343, 334, 334, 344, \r
-  345, 334, 334, 341, 341, 334, 334, 334, 346, 334, \r
-  334, 334, 334, 334, 334, 436\r
-};\r
-\r
-static DfaState st342[36] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st343[36] = {\r
-  436, 334, 334, 334, 334, 334, 334, 334, 334, 334, \r
-  334, 334, 334, 334, 334, 334, 343, 334, 334, 337, \r
-  338, 334, 334, 334, 334, 334, 334, 334, 346, 334, \r
-  334, 334, 334, 334, 334, 436\r
-};\r
-\r
-static DfaState st344[36] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st345[36] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 348, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st346[36] = {\r
-  436, 349, 349, 349, 349, 349, 349, 349, 349, 349, \r
-  349, 349, 349, 349, 349, 349, 349, 349, 349, 350, \r
-  351, 349, 349, 349, 349, 349, 349, 349, 334, 349, \r
-  349, 349, 349, 349, 349, 436\r
-};\r
-\r
-static DfaState st347[36] = {\r
-  436, 436, 279, 436, 279, 279, 352, 279, 279, 279, \r
-  279, 279, 279, 279, 279, 436, 279, 279, 436, 436, \r
-  436, 436, 436, 279, 279, 279, 279, 436, 436, 436, \r
-  436, 436, 279, 279, 279, 436\r
-};\r
-\r
-static DfaState st348[36] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st349[36] = {\r
-  436, 349, 349, 349, 349, 349, 349, 349, 349, 349, \r
-  349, 349, 349, 349, 349, 349, 349, 349, 349, 350, \r
-  351, 349, 349, 349, 349, 349, 349, 349, 353, 349, \r
-  349, 349, 349, 349, 349, 436\r
-};\r
-\r
-static DfaState st350[36] = {\r
-  436, 354, 354, 354, 354, 354, 354, 354, 354, 354, \r
-  354, 354, 354, 354, 354, 354, 354, 354, 354, 354, \r
-  354, 354, 354, 354, 354, 354, 354, 354, 355, 354, \r
-  354, 354, 354, 354, 354, 436\r
-};\r
-\r
-static DfaState st351[36] = {\r
-  436, 354, 354, 354, 354, 354, 354, 354, 354, 354, \r
-  354, 354, 354, 354, 354, 354, 354, 354, 354, 356, \r
-  354, 354, 354, 354, 354, 354, 354, 354, 355, 354, \r
-  354, 354, 354, 354, 354, 436\r
-};\r
-\r
-static DfaState st352[36] = {\r
-  436, 436, 279, 436, 279, 279, 279, 279, 279, 279, \r
-  279, 279, 357, 279, 279, 436, 279, 279, 436, 436, \r
-  436, 436, 436, 279, 279, 279, 279, 436, 436, 436, \r
-  436, 436, 279, 279, 279, 436\r
-};\r
-\r
-static DfaState st353[36] = {\r
-  436, 334, 334, 334, 334, 334, 334, 334, 334, 334, \r
-  334, 334, 334, 334, 334, 334, 358, 334, 334, 344, \r
-  345, 334, 334, 359, 359, 334, 334, 334, 334, 334, \r
-  334, 334, 334, 334, 334, 436\r
-};\r
-\r
-static DfaState st354[36] = {\r
-  436, 354, 354, 354, 354, 354, 354, 354, 354, 354, \r
-  354, 354, 354, 354, 354, 354, 354, 354, 354, 354, \r
-  354, 354, 354, 354, 354, 354, 354, 354, 355, 354, \r
-  354, 354, 354, 354, 354, 436\r
-};\r
-\r
-static DfaState st355[36] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 360, 436, 436, 361, \r
-  362, 436, 436, 363, 363, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st356[36] = {\r
-  436, 354, 354, 354, 354, 354, 354, 354, 354, 354, \r
-  354, 354, 354, 354, 354, 354, 354, 354, 354, 354, \r
-  354, 354, 354, 354, 354, 354, 354, 354, 355, 354, \r
-  354, 354, 354, 354, 354, 436\r
-};\r
-\r
-static DfaState st357[36] = {\r
-  436, 436, 279, 436, 279, 279, 279, 279, 279, 279, \r
-  279, 279, 279, 364, 279, 436, 279, 279, 436, 436, \r
-  436, 436, 436, 279, 279, 279, 279, 436, 436, 436, \r
-  436, 436, 279, 279, 279, 436\r
-};\r
-\r
-static DfaState st358[36] = {\r
-  436, 334, 334, 334, 334, 334, 334, 334, 334, 334, \r
-  334, 334, 334, 334, 334, 334, 358, 334, 334, 344, \r
-  345, 334, 334, 359, 359, 334, 334, 334, 334, 334, \r
-  334, 334, 334, 334, 334, 436\r
-};\r
-\r
-static DfaState st359[36] = {\r
-  436, 334, 334, 334, 334, 334, 334, 334, 334, 334, \r
-  334, 334, 334, 334, 334, 334, 358, 334, 334, 344, \r
-  345, 334, 334, 359, 359, 334, 334, 334, 334, 334, \r
-  334, 334, 334, 334, 334, 436\r
-};\r
-\r
-static DfaState st360[36] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 360, 436, 436, 361, \r
-  362, 436, 436, 363, 363, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st361[36] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st362[36] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 365, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st363[36] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 360, 436, 436, 361, \r
-  362, 436, 436, 363, 363, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st364[36] = {\r
-  436, 436, 279, 436, 279, 279, 279, 279, 279, 279, \r
-  279, 279, 279, 279, 366, 436, 279, 279, 436, 436, \r
-  436, 436, 436, 279, 279, 279, 279, 436, 436, 436, \r
-  436, 436, 279, 279, 279, 436\r
-};\r
-\r
-static DfaState st365[36] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st366[36] = {\r
-  436, 436, 279, 436, 279, 279, 279, 279, 279, 279, \r
-  279, 279, 279, 279, 279, 367, 279, 279, 436, 436, \r
-  436, 436, 436, 279, 279, 279, 279, 436, 436, 436, \r
-  436, 436, 279, 279, 279, 436\r
-};\r
-\r
-static DfaState st367[36] = {\r
-  436, 368, 368, 368, 368, 368, 368, 368, 368, 368, \r
-  368, 368, 368, 368, 368, 368, 369, 370, 436, 368, \r
-  368, 368, 368, 368, 368, 368, 368, 368, 368, 368, \r
-  368, 368, 368, 368, 368, 436\r
-};\r
-\r
-static DfaState st368[36] = {\r
-  436, 368, 368, 368, 368, 368, 368, 368, 368, 368, \r
-  368, 368, 368, 368, 368, 368, 368, 368, 371, 368, \r
-  368, 368, 368, 368, 368, 368, 368, 368, 368, 368, \r
-  368, 368, 368, 368, 368, 436\r
-};\r
-\r
-static DfaState st369[36] = {\r
-  436, 368, 368, 368, 368, 368, 368, 368, 368, 368, \r
-  368, 368, 368, 368, 368, 368, 369, 370, 371, 368, \r
-  368, 368, 368, 368, 368, 368, 368, 368, 368, 368, \r
-  368, 368, 368, 368, 368, 436\r
-};\r
-\r
-static DfaState st370[36] = {\r
-  436, 372, 372, 372, 372, 372, 372, 372, 372, 372, \r
-  372, 372, 372, 372, 372, 372, 372, 372, 373, 372, \r
-  372, 372, 372, 372, 372, 372, 372, 372, 372, 372, \r
-  372, 372, 372, 372, 368, 436\r
-};\r
-\r
-static DfaState st371[36] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st372[36] = {\r
-  436, 372, 372, 372, 372, 372, 372, 372, 372, 372, \r
-  372, 372, 372, 372, 372, 372, 372, 372, 373, 372, \r
-  372, 372, 372, 372, 372, 372, 372, 372, 372, 372, \r
-  372, 372, 372, 372, 374, 436\r
-};\r
-\r
-static DfaState st373[36] = {\r
-  436, 375, 375, 375, 375, 375, 375, 375, 375, 375, \r
-  375, 375, 375, 375, 375, 375, 375, 375, 375, 375, \r
-  375, 375, 375, 375, 375, 375, 375, 375, 375, 375, \r
-  375, 375, 375, 375, 376, 436\r
-};\r
-\r
-static DfaState st374[36] = {\r
-  436, 368, 368, 368, 368, 368, 368, 368, 368, 368, \r
-  368, 368, 368, 368, 368, 368, 377, 368, 378, 368, \r
-  368, 368, 368, 368, 368, 368, 368, 368, 368, 368, \r
-  368, 368, 368, 368, 368, 436\r
-};\r
-\r
-static DfaState st375[36] = {\r
-  436, 375, 375, 375, 375, 375, 375, 375, 375, 375, \r
-  375, 375, 375, 375, 375, 375, 375, 375, 375, 375, \r
-  375, 375, 375, 375, 375, 375, 375, 375, 375, 375, \r
-  375, 375, 375, 375, 376, 436\r
-};\r
-\r
-static DfaState st376[36] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 379, 436, 380, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st377[36] = {\r
-  436, 368, 368, 368, 368, 368, 368, 368, 368, 368, \r
-  368, 368, 368, 368, 368, 368, 377, 368, 378, 368, \r
-  368, 368, 368, 368, 368, 368, 368, 368, 368, 368, \r
-  368, 368, 368, 368, 368, 436\r
-};\r
-\r
-static DfaState st378[36] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st379[36] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 379, 436, 380, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st380[36] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st381[28] = {\r
-  382, 383, 384, 385, 386, 436, 387, 388, 388, 388, \r
-  389, 388, 388, 388, 388, 388, 388, 388, 388, 388, \r
-  390, 391, 392, 393, 394, 395, 388, 436\r
-};\r
-\r
-static DfaState st382[28] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st383[28] = {\r
-  436, 383, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st384[28] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st385[28] = {\r
-  436, 436, 396, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st386[28] = {\r
-  436, 436, 436, 436, 397, 398, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st387[28] = {\r
-  436, 436, 436, 436, 436, 436, 436, 399, 436, 400, \r
-  401, 436, 436, 436, 402, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st388[28] = {\r
-  436, 436, 436, 436, 436, 436, 436, 403, 403, 403, \r
-  403, 403, 403, 403, 403, 403, 403, 403, 403, 403, \r
-  436, 436, 436, 436, 436, 403, 403, 436\r
-};\r
-\r
-static DfaState st389[28] = {\r
-  436, 436, 436, 436, 436, 436, 436, 403, 403, 403, \r
-  403, 404, 403, 403, 403, 403, 403, 403, 403, 403, \r
-  436, 436, 436, 436, 436, 403, 403, 436\r
-};\r
-\r
-static DfaState st390[28] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st391[28] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st392[28] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st393[28] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st394[28] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st395[28] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 395, 436, 436\r
-};\r
-\r
-static DfaState st396[28] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st397[28] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st398[28] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st399[28] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 405, 436, \r
-  436, 436, 436, 436, 436, 406, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st400[28] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  407, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st401[28] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 408, 409, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st402[28] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 410, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st403[28] = {\r
-  436, 436, 436, 436, 436, 436, 436, 403, 403, 403, \r
-  403, 403, 403, 403, 403, 403, 403, 403, 403, 403, \r
-  436, 436, 436, 436, 436, 403, 403, 436\r
-};\r
-\r
-static DfaState st404[28] = {\r
-  436, 436, 436, 436, 436, 436, 436, 403, 403, 403, \r
-  403, 403, 403, 403, 411, 403, 403, 403, 403, 403, \r
-  436, 436, 436, 436, 436, 403, 403, 436\r
-};\r
-\r
-static DfaState st405[28] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 412, \r
-  436, 413, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st406[28] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 414, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st407[28] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 415, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st408[28] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 416, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st409[28] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 417, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st410[28] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 418, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st411[28] = {\r
-  436, 436, 436, 436, 436, 436, 436, 403, 403, 403, \r
-  403, 403, 403, 403, 403, 419, 403, 403, 403, 403, \r
-  436, 436, 436, 436, 436, 403, 403, 436\r
-};\r
-\r
-static DfaState st412[28] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  420, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st413[28] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 421, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st414[28] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 422, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st415[28] = {\r
-  436, 436, 436, 436, 436, 436, 436, 423, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st416[28] = {\r
-  436, 436, 436, 436, 436, 436, 436, 424, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st417[28] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  425, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st418[28] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  426, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st419[28] = {\r
-  436, 436, 436, 436, 436, 436, 436, 403, 403, 403, \r
-  403, 403, 403, 403, 403, 403, 403, 403, 403, 403, \r
-  436, 436, 436, 436, 436, 403, 403, 436\r
-};\r
-\r
-static DfaState st420[28] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 427, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st421[28] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  428, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st422[28] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 429, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st423[28] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 430, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st424[28] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 431, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st425[28] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st426[28] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 432, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st427[28] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st428[28] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 433, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st429[28] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 434, \r
-  436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st430[28] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  435, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st431[28] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st432[28] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st433[28] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st434[28] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-static DfaState st435[28] = {\r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436, 436, 436, \r
-  436, 436, 436, 436, 436, 436, 436, 436\r
-};\r
-\r
-\r
-DfaState *dfa[436] = {\r
-       st0,\r
-       st1,\r
-       st2,\r
-       st3,\r
-       st4,\r
-       st5,\r
-       st6,\r
-       st7,\r
-       st8,\r
-       st9,\r
-       st10,\r
-       st11,\r
-       st12,\r
-       st13,\r
-       st14,\r
-       st15,\r
-       st16,\r
-       st17,\r
-       st18,\r
-       st19,\r
-       st20,\r
-       st21,\r
-       st22,\r
-       st23,\r
-       st24,\r
-       st25,\r
-       st26,\r
-       st27,\r
-       st28,\r
-       st29,\r
-       st30,\r
-       st31,\r
-       st32,\r
-       st33,\r
-       st34,\r
-       st35,\r
-       st36,\r
-       st37,\r
-       st38,\r
-       st39,\r
-       st40,\r
-       st41,\r
-       st42,\r
-       st43,\r
-       st44,\r
-       st45,\r
-       st46,\r
-       st47,\r
-       st48,\r
-       st49,\r
-       st50,\r
-       st51,\r
-       st52,\r
-       st53,\r
-       st54,\r
-       st55,\r
-       st56,\r
-       st57,\r
-       st58,\r
-       st59,\r
-       st60,\r
-       st61,\r
-       st62,\r
-       st63,\r
-       st64,\r
-       st65,\r
-       st66,\r
-       st67,\r
-       st68,\r
-       st69,\r
-       st70,\r
-       st71,\r
-       st72,\r
-       st73,\r
-       st74,\r
-       st75,\r
-       st76,\r
-       st77,\r
-       st78,\r
-       st79,\r
-       st80,\r
-       st81,\r
-       st82,\r
-       st83,\r
-       st84,\r
-       st85,\r
-       st86,\r
-       st87,\r
-       st88,\r
-       st89,\r
-       st90,\r
-       st91,\r
-       st92,\r
-       st93,\r
-       st94,\r
-       st95,\r
-       st96,\r
-       st97,\r
-       st98,\r
-       st99,\r
-       st100,\r
-       st101,\r
-       st102,\r
-       st103,\r
-       st104,\r
-       st105,\r
-       st106,\r
-       st107,\r
-       st108,\r
-       st109,\r
-       st110,\r
-       st111,\r
-       st112,\r
-       st113,\r
-       st114,\r
-       st115,\r
-       st116,\r
-       st117,\r
-       st118,\r
-       st119,\r
-       st120,\r
-       st121,\r
-       st122,\r
-       st123,\r
-       st124,\r
-       st125,\r
-       st126,\r
-       st127,\r
-       st128,\r
-       st129,\r
-       st130,\r
-       st131,\r
-       st132,\r
-       st133,\r
-       st134,\r
-       st135,\r
-       st136,\r
-       st137,\r
-       st138,\r
-       st139,\r
-       st140,\r
-       st141,\r
-       st142,\r
-       st143,\r
-       st144,\r
-       st145,\r
-       st146,\r
-       st147,\r
-       st148,\r
-       st149,\r
-       st150,\r
-       st151,\r
-       st152,\r
-       st153,\r
-       st154,\r
-       st155,\r
-       st156,\r
-       st157,\r
-       st158,\r
-       st159,\r
-       st160,\r
-       st161,\r
-       st162,\r
-       st163,\r
-       st164,\r
-       st165,\r
-       st166,\r
-       st167,\r
-       st168,\r
-       st169,\r
-       st170,\r
-       st171,\r
-       st172,\r
-       st173,\r
-       st174,\r
-       st175,\r
-       st176,\r
-       st177,\r
-       st178,\r
-       st179,\r
-       st180,\r
-       st181,\r
-       st182,\r
-       st183,\r
-       st184,\r
-       st185,\r
-       st186,\r
-       st187,\r
-       st188,\r
-       st189,\r
-       st190,\r
-       st191,\r
-       st192,\r
-       st193,\r
-       st194,\r
-       st195,\r
-       st196,\r
-       st197,\r
-       st198,\r
-       st199,\r
-       st200,\r
-       st201,\r
-       st202,\r
-       st203,\r
-       st204,\r
-       st205,\r
-       st206,\r
-       st207,\r
-       st208,\r
-       st209,\r
-       st210,\r
-       st211,\r
-       st212,\r
-       st213,\r
-       st214,\r
-       st215,\r
-       st216,\r
-       st217,\r
-       st218,\r
-       st219,\r
-       st220,\r
-       st221,\r
-       st222,\r
-       st223,\r
-       st224,\r
-       st225,\r
-       st226,\r
-       st227,\r
-       st228,\r
-       st229,\r
-       st230,\r
-       st231,\r
-       st232,\r
-       st233,\r
-       st234,\r
-       st235,\r
-       st236,\r
-       st237,\r
-       st238,\r
-       st239,\r
-       st240,\r
-       st241,\r
-       st242,\r
-       st243,\r
-       st244,\r
-       st245,\r
-       st246,\r
-       st247,\r
-       st248,\r
-       st249,\r
-       st250,\r
-       st251,\r
-       st252,\r
-       st253,\r
-       st254,\r
-       st255,\r
-       st256,\r
-       st257,\r
-       st258,\r
-       st259,\r
-       st260,\r
-       st261,\r
-       st262,\r
-       st263,\r
-       st264,\r
-       st265,\r
-       st266,\r
-       st267,\r
-       st268,\r
-       st269,\r
-       st270,\r
-       st271,\r
-       st272,\r
-       st273,\r
-       st274,\r
-       st275,\r
-       st276,\r
-       st277,\r
-       st278,\r
-       st279,\r
-       st280,\r
-       st281,\r
-       st282,\r
-       st283,\r
-       st284,\r
-       st285,\r
-       st286,\r
-       st287,\r
-       st288,\r
-       st289,\r
-       st290,\r
-       st291,\r
-       st292,\r
-       st293,\r
-       st294,\r
-       st295,\r
-       st296,\r
-       st297,\r
-       st298,\r
-       st299,\r
-       st300,\r
-       st301,\r
-       st302,\r
-       st303,\r
-       st304,\r
-       st305,\r
-       st306,\r
-       st307,\r
-       st308,\r
-       st309,\r
-       st310,\r
-       st311,\r
-       st312,\r
-       st313,\r
-       st314,\r
-       st315,\r
-       st316,\r
-       st317,\r
-       st318,\r
-       st319,\r
-       st320,\r
-       st321,\r
-       st322,\r
-       st323,\r
-       st324,\r
-       st325,\r
-       st326,\r
-       st327,\r
-       st328,\r
-       st329,\r
-       st330,\r
-       st331,\r
-       st332,\r
-       st333,\r
-       st334,\r
-       st335,\r
-       st336,\r
-       st337,\r
-       st338,\r
-       st339,\r
-       st340,\r
-       st341,\r
-       st342,\r
-       st343,\r
-       st344,\r
-       st345,\r
-       st346,\r
-       st347,\r
-       st348,\r
-       st349,\r
-       st350,\r
-       st351,\r
-       st352,\r
-       st353,\r
-       st354,\r
-       st355,\r
-       st356,\r
-       st357,\r
-       st358,\r
-       st359,\r
-       st360,\r
-       st361,\r
-       st362,\r
-       st363,\r
-       st364,\r
-       st365,\r
-       st366,\r
-       st367,\r
-       st368,\r
-       st369,\r
-       st370,\r
-       st371,\r
-       st372,\r
-       st373,\r
-       st374,\r
-       st375,\r
-       st376,\r
-       st377,\r
-       st378,\r
-       st379,\r
-       st380,\r
-       st381,\r
-       st382,\r
-       st383,\r
-       st384,\r
-       st385,\r
-       st386,\r
-       st387,\r
-       st388,\r
-       st389,\r
-       st390,\r
-       st391,\r
-       st392,\r
-       st393,\r
-       st394,\r
-       st395,\r
-       st396,\r
-       st397,\r
-       st398,\r
-       st399,\r
-       st400,\r
-       st401,\r
-       st402,\r
-       st403,\r
-       st404,\r
-       st405,\r
-       st406,\r
-       st407,\r
-       st408,\r
-       st409,\r
-       st410,\r
-       st411,\r
-       st412,\r
-       st413,\r
-       st414,\r
-       st415,\r
-       st416,\r
-       st417,\r
-       st418,\r
-       st419,\r
-       st420,\r
-       st421,\r
-       st422,\r
-       st423,\r
-       st424,\r
-       st425,\r
-       st426,\r
-       st427,\r
-       st428,\r
-       st429,\r
-       st430,\r
-       st431,\r
-       st432,\r
-       st433,\r
-       st434,\r
-       st435\r
-};\r
-\r
-\r
-DfaState accepts[437] = {\r
-  0, 1, 2, 3, 3, 4, 25, 6, 0, 50, \r
-  59, 57, 57, 43, 26, 13, 14, 0, 57, 58, \r
-  57, 21, 57, 23, 24, 27, 28, 44, 0, 35, \r
-  36, 42, 45, 46, 58, 51, 52, 3, 5, 9, \r
-  7, 8, 59, 59, 59, 59, 59, 59, 59, 59, \r
-  57, 57, 12, 40, 59, 57, 58, 57, 57, 57, \r
-  33, 34, 53, 58, 59, 59, 59, 59, 59, 59, \r
-  59, 59, 59, 57, 59, 57, 57, 57, 57, 0, \r
-  59, 59, 59, 59, 59, 59, 59, 59, 59, 59, \r
-  57, 57, 57, 57, 57, 0, 0, 59, 59, 59, \r
-  59, 59, 59, 32, 59, 59, 59, 59, 59, 59, \r
-  59, 59, 57, 57, 57, 22, 56, 48, 49, 0, \r
-  11, 11, 0, 59, 59, 59, 59, 59, 59, 59, \r
-  59, 59, 59, 41, 59, 59, 59, 18, 57, 47, \r
-  57, 0, 11, 0, 10, 10, 0, 59, 59, 59, \r
-  59, 59, 15, 19, 59, 59, 59, 17, 57, 55, \r
-  10, 0, 11, 11, 59, 59, 59, 59, 59, 59, \r
-  20, 59, 57, 0, 0, 0, 11, 59, 59, 59, \r
-  37, 38, 59, 39, 54, 0, 0, 0, 10, 10, \r
-  0, 31, 29, 30, 59, 10, 59, 59, 59, 59, \r
-  16, 0, 60, 61, 62, 62, 0, 65, 62, 64, \r
-  63, 63, 63, 0, 66, 67, 68, 68, 0, 71, \r
-  68, 70, 69, 69, 69, 0, 72, 73, 74, 74, \r
-  0, 76, 74, 75, 0, 77, 79, 81, 80, 80, \r
-  78, 80, 0, 82, 84, 86, 85, 85, 83, 85, \r
-  0, 87, 88, 88, 89, 88, 0, 90, 91, 91, \r
-  92, 91, 0, 93, 94, 94, 95, 94, 0, 96, \r
-  98, 100, 99, 99, 97, 99, 0, 101, 108, 143, \r
-  104, 143, 129, 127, 107, 107, 109, 128, 126, 134, \r
-  0, 133, 139, 143, 102, 143, 107, 116, 110, 112, \r
-  113, 123, 123, 125, 124, 117, 120, 132, 138, 130, \r
-  131, 137, 137, 135, 136, 142, 140, 141, 103, 143, \r
-  116, 111, 114, 123, 123, 119, 118, 137, 143, 115, \r
-  123, 143, 123, 143, 0, 123, 0, 122, 122, 123, \r
-  143, 0, 122, 0, 121, 121, 0, 143, 121, 0, \r
-  122, 122, 143, 0, 0, 0, 122, 143, 0, 0, \r
-  0, 121, 121, 0, 143, 121, 143, 0, 0, 0, \r
-  0, 106, 0, 106, 0, 0, 0, 0, 105, 0, \r
-  105, 0, 144, 145, 146, 146, 0, 0, 164, 164, \r
-  158, 159, 160, 161, 162, 163, 146, 147, 148, 0, \r
-  0, 0, 0, 164, 164, 150, 0, 0, 0, 0, \r
-  0, 164, 0, 0, 0, 0, 0, 0, 0, 157, \r
-  0, 0, 0, 0, 0, 152, 0, 149, 0, 0, \r
-  0, 153, 154, 151, 155, 156, 0\r
-};\r
-\r
-void (*actions[165])() = {\r
-       zzerraction,\r
-       act1,\r
-       act2,\r
-       act3,\r
-       act4,\r
-       act5,\r
-       act6,\r
-       act7,\r
-       act8,\r
-       act9,\r
-       act10,\r
-       act11,\r
-       act12,\r
-       act13,\r
-       act14,\r
-       act15,\r
-       act16,\r
-       act17,\r
-       act18,\r
-       act19,\r
-       act20,\r
-       act21,\r
-       act22,\r
-       act23,\r
-       act24,\r
-       act25,\r
-       act26,\r
-       act27,\r
-       act28,\r
-       act29,\r
-       act30,\r
-       act31,\r
-       act32,\r
-       act33,\r
-       act34,\r
-       act35,\r
-       act36,\r
-       act37,\r
-       act38,\r
-       act39,\r
-       act40,\r
-       act41,\r
-       act42,\r
-       act43,\r
-       act44,\r
-       act45,\r
-       act46,\r
-       act47,\r
-       act48,\r
-       act49,\r
-       act50,\r
-       act51,\r
-       act52,\r
-       act53,\r
-       act54,\r
-       act55,\r
-       act56,\r
-       act57,\r
-       act58,\r
-       act59,\r
-       act60,\r
-       act61,\r
-       act62,\r
-       act63,\r
-       act64,\r
-       act65,\r
-       act66,\r
-       act67,\r
-       act68,\r
-       act69,\r
-       act70,\r
-       act71,\r
-       act72,\r
-       act73,\r
-       act74,\r
-       act75,\r
-       act76,\r
-       act77,\r
-       act78,\r
-       act79,\r
-       act80,\r
-       act81,\r
-       act82,\r
-       act83,\r
-       act84,\r
-       act85,\r
-       act86,\r
-       act87,\r
-       act88,\r
-       act89,\r
-       act90,\r
-       act91,\r
-       act92,\r
-       act93,\r
-       act94,\r
-       act95,\r
-       act96,\r
-       act97,\r
-       act98,\r
-       act99,\r
-       act100,\r
-       act101,\r
-       act102,\r
-       act103,\r
-       act104,\r
-       act105,\r
-       act106,\r
-       act107,\r
-       act108,\r
-       act109,\r
-       act110,\r
-       act111,\r
-       act112,\r
-       act113,\r
-       act114,\r
-       act115,\r
-       act116,\r
-       act117,\r
-       act118,\r
-       act119,\r
-       act120,\r
-       act121,\r
-       act122,\r
-       act123,\r
-       act124,\r
-       act125,\r
-       act126,\r
-       act127,\r
-       act128,\r
-       act129,\r
-       act130,\r
-       act131,\r
-       act132,\r
-       act133,\r
-       act134,\r
-       act135,\r
-       act136,\r
-       act137,\r
-       act138,\r
-       act139,\r
-       act140,\r
-       act141,\r
-       act142,\r
-       act143,\r
-       act144,\r
-       act145,\r
-       act146,\r
-       act147,\r
-       act148,\r
-       act149,\r
-       act150,\r
-       act151,\r
-       act152,\r
-       act153,\r
-       act154,\r
-       act155,\r
-       act156,\r
-       act157,\r
-       act158,\r
-       act159,\r
-       act160,\r
-       act161,\r
-       act162,\r
-       act163,\r
-       act164\r
-};\r
-\r
-static DfaState dfa_base[] = {\r
-       0,\r
-       201,\r
-       213,\r
-       225,\r
-       234,\r
-       242,\r
-       250,\r
-       256,\r
-       262,\r
-       268,\r
-       276,\r
-       381\r
-};\r
-\r
-static unsigned char *b_class_no[] = {\r
-       shift0,\r
-       shift1,\r
-       shift2,\r
-       shift3,\r
-       shift4,\r
-       shift5,\r
-       shift6,\r
-       shift7,\r
-       shift8,\r
-       shift9,\r
-       shift10,\r
-       shift11\r
-};\r
-\r
-\r
-\r
-#define ZZSHIFT(c) (b_class_no[zzauto][1+c])\r
-#define MAX_MODE 12\r
-#include "dlgauto.h"\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/antlr/stdpccts.h b/Tools/CodeTools/TianoTools/Pccts/antlr/stdpccts.h
deleted file mode 100644 (file)
index ccdc21c..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-#ifndef STDPCCTS_H\r
-#define STDPCCTS_H\r
-/*\r
- * stdpccts.h -- P C C T S  I n c l u d e\r
- *\r
- * Terence Parr, Will Cohen, and Hank Dietz: 1989-2001\r
- * Purdue University Electrical Engineering\r
- * With AHPCRC, University of Minnesota\r
- * ANTLR Version 1.33MR33\r
- */\r
-\r
-#ifndef ANTLR_VERSION\r
-#define ANTLR_VERSION  13333\r
-#endif\r
-\r
-#include "pcctscfg.h"\r
-#include "pccts_stdio.h"\r
-\r
-#include "pcctscfg.h"\r
-#include "set.h"\r
-#include <ctype.h>\r
-#include "syn.h"\r
-#include "hash.h"\r
-#include "generic.h"\r
-#define zzcr_attr(attr,tok,t)\r
-#define zzSET_SIZE 20\r
-#include "antlr.h"\r
-#include "tokens.h"\r
-#include "dlgdef.h"\r
-#include "mode.h"\r
-#endif\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/antlr/syn.h b/Tools/CodeTools/TianoTools/Pccts/antlr/syn.h
deleted file mode 100644 (file)
index a23d196..0000000
+++ /dev/null
@@ -1,390 +0,0 @@
-/*\r
- * syn.h\r
- *\r
- * This file includes definitions and macros associated with syntax diagrams\r
- *\r
- * SOFTWARE RIGHTS\r
- *\r
- * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
- * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
- * company may do whatever they wish with source code distributed with\r
- * PCCTS or the code generated by PCCTS, including the incorporation of\r
- * PCCTS, or its output, into commerical software.\r
- *\r
- * We encourage users to develop software with PCCTS.  However, we do ask\r
- * that credit is given to us for developing PCCTS.  By "credit",\r
- * we mean that if you incorporate our source code into one of your\r
- * programs (commercial product, research project, or otherwise) that you\r
- * acknowledge this fact somewhere in the documentation, research report,\r
- * etc...  If you like PCCTS and have developed a nice tool with the\r
- * output, please mention that you developed it using PCCTS.  In\r
- * addition, we ask that this header remain intact in our source code.\r
- * As long as these guidelines are kept, we expect to continue enhancing\r
- * this system and expect to make other tools available as they are\r
- * completed.\r
- *\r
- * ANTLR 1.33\r
- * Terence Parr\r
- * Parr Research Corporation\r
- * with Purdue University and AHPCRC, University of Minnesota\r
- * 1989-2001\r
- */\r
-\r
-#include "set.h"\r
-\r
-#define NumNodeTypes   4\r
-#define NumJuncTypes   9\r
-\r
-/* List the different node types */\r
-#define nJunction              1\r
-#define nRuleRef               2\r
-#define nToken                 3\r
-#define nAction                        4\r
-\r
-/* Different types of junctions */\r
-#define aSubBlk                        1\r
-#define aOptBlk                        2\r
-#define aLoopBlk               3\r
-#define EndBlk                 4\r
-#define RuleBlk                        5\r
-#define Generic                        6       /* just a junction--no unusual characteristics */\r
-#define EndRule                        7\r
-#define aPlusBlk               8\r
-#define aLoopBegin             9\r
-\r
-typedef int NodeType;\r
-\r
-#define TreeBlockAllocSize             500\r
-#define JunctionBlockAllocSize 200\r
-#define ActionBlockAllocSize   50\r
-#define RRefBlockAllocSize             100\r
-#define TokenBlockAllocSize            100\r
-\r
-#ifdef __cplusplus\r
-class ActionNode;\r
-class Junction;\r
-#endif\r
-\r
-/* note that 'right' is used by the tree node allocator as a ptr for linked list */\r
-typedef struct _tree {\r
-                       struct _tree *down, *right;\r
-                       int token;\r
-                       union {\r
-                               int rk; /* if token==EpToken, => how many more tokens req'd */\r
-                               struct _tree *tref;     /* if token==TREE_REF */\r
-                               set sref;                       /* if token==SET */\r
-                       } v;\r
-#ifdef TREE_DEBUG\r
-                       int in_use;\r
-            int seq;\r
-#endif\r
-               } Tree;\r
-\r
-\r
-/* a predicate is defined to be a predicate action and a token tree with\r
- * context info (if used); later, this struct may include the\r
- * "hoisting distance" when we hoist past tokens.\r
- *\r
- * A tree is used to indicate && vs ||\r
- *\r
- *    p\r
- *    |\r
- *    q--r\r
- *\r
- * indicates p && (q||r).\r
- *\r
- * If expr is PRED_AND_LIST or PRED_OR_LIST, then it's an operation node\r
- * and indicates the start of an && or || list.\r
- */\r
-\r
-typedef struct _Predicate {\r
-       struct _Predicate *down, *right;        /* these have to be first */\r
-       struct _Predicate *up, *left;           /* doubly-link me */\r
-       char *expr;\r
-       Tree *tcontext; /* used if lookahead depth of > one is needed (tree) */\r
-       int k;                  /* lookahead depth for this tcontext */\r
-       set scontext[2];/* used if lookahead depth of one is needed (set) */\r
-                                       /* scontext[0] is not used; only needed so genExprSets()\r
-                                          routine works (it expects an array)\r
-                                        */\r
-       set completionTree;     /* which lookahead depths are required to complete tcontext? */\r
-    set completionSet;  /* MR10 separate completion set for sets and trees           */\r
-    struct _PredEntry *predEntry;         /* MR11 */\r
-\r
-#ifdef __cplusplus\r
-       ActionNode *source;     /* where did this predicate come from? */\r
-#else\r
-       struct _anode *source;  /* where did this predicate come from? */\r
-#endif\r
-\r
-    char             cloned;               /* MR10 don't want to free original guard pred */\r
-    char             redundant;            /* MR10 predicate tree simplification          */\r
-    char             ampersandStyle;       /* MR10  (g)? && <<p>>?                        */\r
-    char             inverted;             /* MR11 ! predName */\r
-    char             isConst;              /* MR11 */\r
-    char             constValue;           /* MR11 */\r
-    char             conflictReported;     /* MR11 */\r
-\r
-    set              plainSet;             /* MR12b */\r
-\r
-    /*** remember to change new_predicate() and predicate_dup() when changing this ***/\r
-\r
-} Predicate;\r
-\r
-typedef struct _ExceptionHandler {\r
-                       char *signalname;\r
-                       char *action;\r
-               } ExceptionHandler;\r
-\r
-typedef struct _ExceptionGroup {\r
-                       struct _ListNode *handlers; /* list of ExceptionHandler's */\r
-                       char *label;            /* label==""; implies not attached to any\r
-                                                                * particular rule ref.\r
-                                                                */\r
-                       char *altID;            /* which alt did it come from (blk#:alt#) */\r
-\r
-            struct _ExceptionGroup  *pendingLink; /* for alternative EG MR7 */\r
-            struct _ExceptionGroup  *outerEG;     /* for alternative EG MR7 */\r
-            struct _LabelEntry      *labelEntry;  /* for alternative EG MR7 */\r
-            int                     forRule;                         /* MR7 */\r
-            int                     used;                            /* MR7 */\r
-               } ExceptionGroup ;\r
-\r
-\r
-#define TokenString(_i)                        ((TokenInd!=NULL)?TokenStr[TokenInd[_i]]:TokenStr[_i])\r
-#define ExprString(_i)                 ((TokenInd!=NULL)?ExprStr[TokenInd[_i]]:ExprStr[_i])\r
-\r
-\r
-                               /* M e s s a g e  P a s s i n g  T o  N o d e s */\r
-\r
-/*\r
- * assumes a 'Junction *r' exists.  This macro calls a function with\r
- * the pointer to the node to operate on and a pointer to the rule\r
- * in which it is enclosed.\r
- */\r
-#define TRANS(p)       {if ( (p)==NULL ) fatal("TRANS: NULL object");          \\r
-                                       if ( (p)->ntype == nJunction ) (*(fpJTrans[((Junction *)(p))->jtype]))( p );\\r
-                                       else (*(fpTrans[(p)->ntype]))( p );}\r
-\r
-#define PRINT(p)       {if ( (p)==NULL ) fatal("PRINT: NULL object");\\r
-                                       (*(fpPrint[(p)->ntype]))( p );}\r
-\r
-#define REACH(p,k,rk,a) {if ( (p)==NULL ) fatal("REACH: NULL object");\\r
-                                       (a) = (*(fpReach[(p)->ntype]))( p, k, rk );}\r
-\r
-#define TRAV(p,k,rk,a) {if ( (p)==NULL ) {\\r
-                                         if ( ContextGuardTRAV ) (a)=NULL; \\r
-                                         else fatal("TRAV: NULL object");\\r
-                                   } \\r
-                                       else (a) = (*(fpTraverse[(p)->ntype]))( p, k, rk );}\r
-\r
-/**\r
-*** #define TRAV(p,k,rk,a) {if ( (p)==NULL ) fatal("TRAV: NULL object");\\r
-***                                    (a) = (*(fpTraverse[(p)->ntype]))( p, k, rk );}\r
-**/\r
-\r
-/* All syntax diagram nodes derive from Node -- superclass\r
- */\r
-#ifdef __cplusplus\r
-class Node {\r
-public:\r
-                       NodeType ntype;\r
-                       char *rname;            /* what rule does this element live in? */\r
-                       int file;                       /* index in FileStr */\r
-                       int line;                       /* line number that element occurs on */\r
-               };\r
-#else\r
-typedef struct _node {\r
-                       NodeType ntype;\r
-                       char *rname;            /* what rule does this element live in? */\r
-                       int file;                       /* index in FileStr */\r
-                       int line;                       /* line number that element occurs on */\r
-               } Node;\r
-#endif\r
-\r
-#ifdef __cplusplus\r
-class ActionNode : public Node {\r
-public:\r
-#else\r
-typedef struct _anode {\r
-                       NodeType ntype;\r
-                       char *rname;            /* what rule does this action live in? */\r
-                       int file;                       /* index in FileStr (name of file with action) */\r
-                       int line;                       /* line number that action occurs on */\r
-#endif\r
-                       Node *next;\r
-                       char *action;\r
-                       int is_predicate;       /* true if action is a <<...>>? predicate action */\r
-                       int done;                       /* don't dump if action dumped (used for predicates) */\r
-                       int init_action;        /* is this the 1st action of 1st prod of block? */\r
-                       char *pred_fail;        /* what to do/print when predicate fails */\r
-                       Predicate  *guardpred;  /* if '(context)? =>' was present, already done */\r
-                       unsigned char frmwarned;/* have we dumped a warning for pred yet? */\r
-                       unsigned char ctxwarned;/* have we dumped a warning for pred yet? */\r
-            unsigned char predTooLong;     /* MR10 have we dumped warning for pred yet */\r
-            unsigned char noHoist;         /* MR12 literally "noHoist" */\r
-            Predicate         *ampersandPred;     /* MR10   (g)? && <<p>>? expr   */\r
-#ifdef __cplusplus\r
-            Junction          *guardNodes;        /* MR11 */\r
-#else\r
-            struct _junct     *guardNodes;        /* MR11 */\r
-#endif\r
-            struct _PredEntry *predEntry;         /* MR11 */\r
-            int               inverted;           /* MR11 <<!predSymbol>>? */\r
-#ifdef __cplusplus\r
-               };\r
-#else\r
-               } ActionNode;\r
-#endif\r
-\r
-#ifdef __cplusplus\r
-class TokNode : public Node {\r
-public:\r
-#else\r
-typedef struct _toknode {\r
-                       NodeType ntype;\r
-                       char *rname;            /* name of rule it's in */\r
-                       int file;                       /* index in FileStr (name of file with rule) */\r
-                       int line;                       /* line number that token occurs on */\r
-#endif\r
-                       Node *next;\r
-                       int token;\r
-                       int astnode;            /* leaf/root/excluded (used to build AST's) */\r
-                       unsigned char label;/* token label or expression ? */\r
-                       unsigned char remapped;\r
-                                                               /* used if token id's are forced to certain positions;\r
-                                                                * a function walks the tree reassigning token numbers */\r
-                       int upper_range;    /* MR13 - was char */\r
-                                                               /* used only if Token is of type T1..T2; in this case,\r
-                                                                * use token..upper_range as the range; else\r
-                                                                * upper_range must be 0 */\r
-                       unsigned char wild_card;\r
-                                                               /* indicates that the token is the "." wild-card;\r
-                                                                * field token is ignored if wild_card is set\r
-                                                                */\r
-                       unsigned int elnum; /* element number within the alternative */\r
-#ifdef __cplusplus\r
-                       Junction *altstart;     /* pointer to node that starts alt */\r
-#else\r
-                       struct _junct *altstart;        /* pointer to node that starts alt */\r
-#endif\r
-                       struct _TCnode *tclass;         /* token class if tokclass ref */\r
-                       set tset;                       /* set of tokens represented by meta token */\r
-                       char *el_label;         /* el_label:toknode */\r
-                       unsigned char complement;       /* complement the set? */\r
-                       ExceptionGroup *ex_group;       /* any exception[el_label] attached? */\r
-            unsigned char use_def_MT_handler;\r
-            unsigned char label_used_in_semantic_pred;  /* MR10 */\r
-#ifdef __cplusplus\r
-               };\r
-#else\r
-               } TokNode;\r
-#endif\r
-\r
-#ifdef __cplusplus\r
-class RuleRefNode : public Node {\r
-public:\r
-#else\r
-typedef struct _rrnode {\r
-                       NodeType ntype;\r
-                       char *rname;            /* name of rule it's in */\r
-                       int file;                       /* index in FileStr (name of file with rule)\r
-                                                                  it's in */\r
-                       int line;                       /* line number that rule ref occurs on */\r
-#endif\r
-                       Node *next;\r
-                       char *text;                     /* reference to which rule */\r
-                       char *parms;            /* point to parameters of rule invocation\r
-                                                                  (if present) */\r
-                       char *assign;           /* point to left-hand-side of assignment\r
-                                                                  (if any) */\r
-                       int linked;                     /* Has a FoLink already been established? */\r
-                       int astnode;            /* excluded? (used to build AST's) */\r
-                       unsigned int elnum; /* element number within the alternative */\r
-#ifdef __cplusplus\r
-                       Junction *altstart;\r
-#else\r
-                       struct _junct *altstart;\r
-#endif\r
-                       char *el_label;         /* el_label:rrnode */\r
-                       ExceptionGroup *ex_group;       /* any exception[el_label] attached? */\r
-#ifdef __cplusplus\r
-               };\r
-#else\r
-               } RuleRefNode;\r
-#endif\r
-\r
-#ifdef __cplusplus\r
-class Junction : public Node {\r
-public:\r
-#else\r
-typedef struct _junct {\r
-                       NodeType ntype;\r
-                       char *rname;            /* name of rule junction is in */\r
-                       int file;                       /* index in FileStr (name of file with rule)\r
-                                                                  if blk == RuleBlk */\r
-                       int line;                       /* line number that rule occurs on */\r
-#endif\r
-            int seq;            /* MR10 sequence number */\r
-                       char ignore;            /* used by FIRST computation to ignore\r
-                                                                  empty alt added for the (...)+ blks */\r
-                       char visited;           /* used by recursive routines to avoid\r
-                                                                  infinite recursion */\r
-                       char pvisited;          /* used by print routines to avoid\r
-                                                                  infinite recursion */\r
-                       char fvisited;          /* used by FoLink() to avoid\r
-                                                                  infinite recursion */\r
-                       char *lock;                     /* used by REACH to track infinite recursion */\r
-                       char *pred_lock;        /* used by find_predicates to track infinite recursion */\r
-                       int altnum;                     /* used in subblocks. altnum==0 means not an\r
-                                                                  alt of subrule */\r
-                       int jtype;                      /* annotation for code-gen/FIRST/FOLLOW.\r
-                                                                  Junction type */\r
-#ifdef __cplusplus\r
-                       Junction *end;          /* pointer to node with EndBlk in it\r
-                                                                  if blk == a block type */\r
-#else\r
-                       struct _junct *end;     /* pointer to node with EndBlk in it\r
-                                                                  if blk == a block type */\r
-#endif\r
-                       Node *p1, *p2;\r
-                       char  halt;                     /* never move past a junction with halt==TRUE */ /* MR10 was int */\r
-                       char *pdecl;            /* point to declaration of parameters on rule\r
-                                                                  (if present) */\r
-                       char *parm;                     /* point to parameter of block invocation\r
-                                                                  (if present) */\r
-                       char predparm;          /* indicates that the 'parm' is a predicate\r
-                                                                * to be used in the while loop generated\r
-                                                                * for blocks */ /* MR10 was int */\r
-                       char *ret;                      /* point to return type of rule (if present) */\r
-                       char *erraction;        /* point to error action (if present) */\r
-                       int blockid;            /* this is a unique ID */\r
-                       char *exception_label;  /* goto label for this alt */\r
-                       set *fset;                      /* used for code generation */\r
-                       Tree *ftree;            /* used for code generation */\r
-                       Predicate *predicate;/* predicate that can be used to disambiguate */\r
-                       char guess;                     /* true if (...)? block */\r
-            char alpha_beta_guess_end;      /* MR14 1 => end block of guess sub block  */\r
-            Node *guess_analysis_point;     /* MR14 */\r
-                       char approx;            /* limit block to use linear approx lookahead? */\r
-                       set tokrefs;            /* if ith element of alt is tokref then i is member */\r
-                       set rulerefs;           /* if ith element of alt is rule ref then i is member */\r
-                       struct _ListNode *exceptions; /* list of exceptions groups for rule */\r
-                       struct _ListNode *el_labels;  /* list of element labels for rule */\r
-            ExceptionGroup   *outerEG;                               /* MR7 */\r
-            int              curAltNum;                              /* MR7 */\r
-            char* pFirstSetSymbol;   /* #pragma FirstSetSymbol(Foo)     MR21 */\r
-#ifdef __cplusplus\r
-            Junction         *pendingLink;                           /* MR7 */\r
-#else\r
-            struct _junct    *pendingLink;                           /* MR7 */\r
-#endif\r
-            char             overlap_warning;                        /* MR10 */\r
-#ifdef __cplusplus\r
-               };\r
-#else\r
-               } Junction;\r
-#endif\r
-\r
-typedef struct { Node *left, *right;} Graph;\r
-\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/antlr/tokens.h b/Tools/CodeTools/TianoTools/Pccts/antlr/tokens.h
deleted file mode 100644 (file)
index 91a53a8..0000000
+++ /dev/null
@@ -1,246 +0,0 @@
-#ifndef tokens_h\r
-#define tokens_h\r
-/* tokens.h -- List of labelled tokens and stuff\r
- *\r
- * Generated from: antlr.g\r
- *\r
- * Terence Parr, Will Cohen, and Hank Dietz: 1989-2001\r
- * Purdue University Electrical Engineering\r
- * ANTLR Version 1.33MR33\r
- */\r
-#define zzEOF_TOKEN 1\r
-#define Eof 1\r
-#define QuotedTerm 2\r
-#define Action 34\r
-#define Pred 35\r
-#define PassAction 36\r
-#define WildCard 87\r
-#define LABEL 89\r
-#define Pragma 92\r
-#define FirstSetSymbol 93\r
-#define NonTerminal 100\r
-#define TokenTerm 101\r
-#define ID 148\r
-#define INT 150\r
-\r
-#ifdef __USE_PROTOS\r
-void grammar(void);\r
-#else\r
-extern void grammar();\r
-#endif\r
-\r
-#ifdef __USE_PROTOS\r
-void class_def(void);\r
-#else\r
-extern void class_def();\r
-#endif\r
-\r
-#ifdef __USE_PROTOS\r
-void rule(void);\r
-#else\r
-extern void rule();\r
-#endif\r
-\r
-#ifdef __USE_PROTOS\r
-void laction(void);\r
-#else\r
-extern void laction();\r
-#endif\r
-\r
-#ifdef __USE_PROTOS\r
-void lmember(void);\r
-#else\r
-extern void lmember();\r
-#endif\r
-\r
-#ifdef __USE_PROTOS\r
-void lprefix(void);\r
-#else\r
-extern void lprefix();\r
-#endif\r
-\r
-#ifdef __USE_PROTOS\r
-void aPred(void);\r
-#else\r
-extern void aPred();\r
-#endif\r
-\r
-#ifdef __USE_PROTOS\r
-extern Predicate * predOrExpr(void);\r
-#else\r
-extern Predicate * predOrExpr();\r
-#endif\r
-\r
-#ifdef __USE_PROTOS\r
-extern Predicate * predAndExpr(void);\r
-#else\r
-extern Predicate * predAndExpr();\r
-#endif\r
-\r
-#ifdef __USE_PROTOS\r
-extern Predicate * predPrimary(void);\r
-#else\r
-extern Predicate * predPrimary();\r
-#endif\r
-\r
-#ifdef __USE_PROTOS\r
-void aLexclass(void);\r
-#else\r
-extern void aLexclass();\r
-#endif\r
-\r
-#ifdef __USE_PROTOS\r
-void error(void);\r
-#else\r
-extern void error();\r
-#endif\r
-\r
-#ifdef __USE_PROTOS\r
-void tclass(void);\r
-#else\r
-extern void tclass();\r
-#endif\r
-\r
-#ifdef __USE_PROTOS\r
-void token(void);\r
-#else\r
-extern void token();\r
-#endif\r
-\r
-#ifdef __USE_PROTOS\r
-void block(set * toksrefd,set * rulesrefd);\r
-#else\r
-extern void block();\r
-#endif\r
-\r
-#ifdef __USE_PROTOS\r
-void alt(set * toksrefd,set * rulesrefd);\r
-#else\r
-extern void alt();\r
-#endif\r
-\r
-#ifdef __USE_PROTOS\r
-extern LabelEntry * element_label(void);\r
-#else\r
-extern LabelEntry * element_label();\r
-#endif\r
-\r
-#ifdef __USE_PROTOS\r
-extern Node * element(int old_not,int first_on_line,int use_def_MT_handler);\r
-#else\r
-extern Node * element();\r
-#endif\r
-\r
-#ifdef __USE_PROTOS\r
-void default_exception_handler(void);\r
-#else\r
-extern void default_exception_handler();\r
-#endif\r
-\r
-#ifdef __USE_PROTOS\r
-extern ExceptionGroup * exception_group(void);\r
-#else\r
-extern ExceptionGroup * exception_group();\r
-#endif\r
-\r
-#ifdef __USE_PROTOS\r
-extern ExceptionHandler * exception_handler(void);\r
-#else\r
-extern ExceptionHandler * exception_handler();\r
-#endif\r
-\r
-#ifdef __USE_PROTOS\r
-void enum_file(char * fname);\r
-#else\r
-extern void enum_file();\r
-#endif\r
-\r
-#ifdef __USE_PROTOS\r
-void defines(char * fname);\r
-#else\r
-extern void defines();\r
-#endif\r
-\r
-#ifdef __USE_PROTOS\r
-void enum_def(char * fname);\r
-#else\r
-extern void enum_def();\r
-#endif\r
-\r
-#endif\r
-extern SetWordType zzerr1[];\r
-extern SetWordType zzerr2[];\r
-extern SetWordType zzerr3[];\r
-extern SetWordType zzerr4[];\r
-extern SetWordType setwd1[];\r
-extern SetWordType zzerr5[];\r
-extern SetWordType zzerr6[];\r
-extern SetWordType zzerr7[];\r
-extern SetWordType zzerr8[];\r
-extern SetWordType zzerr9[];\r
-extern SetWordType setwd2[];\r
-extern SetWordType zzerr10[];\r
-extern SetWordType zzerr11[];\r
-extern SetWordType zzerr12[];\r
-extern SetWordType zzerr13[];\r
-extern SetWordType setwd3[];\r
-extern SetWordType zzerr14[];\r
-extern SetWordType zzerr15[];\r
-extern SetWordType zzerr16[];\r
-extern SetWordType zzerr17[];\r
-extern SetWordType zzerr18[];\r
-extern SetWordType zzerr19[];\r
-extern SetWordType zzerr20[];\r
-extern SetWordType zzerr21[];\r
-extern SetWordType setwd4[];\r
-extern SetWordType zzerr22[];\r
-extern SetWordType zzerr23[];\r
-extern SetWordType zzerr24[];\r
-extern SetWordType zzerr25[];\r
-extern SetWordType zzerr26[];\r
-extern SetWordType setwd5[];\r
-extern SetWordType zzerr27[];\r
-extern SetWordType zzerr28[];\r
-extern SetWordType zzerr29[];\r
-extern SetWordType zzerr30[];\r
-extern SetWordType zzerr31[];\r
-extern SetWordType zzerr32[];\r
-extern SetWordType zzerr33[];\r
-extern SetWordType setwd6[];\r
-extern SetWordType zzerr34[];\r
-extern SetWordType zzerr35[];\r
-extern SetWordType zzerr36[];\r
-extern SetWordType zzerr37[];\r
-extern SetWordType zzerr38[];\r
-extern SetWordType zzerr39[];\r
-extern SetWordType zzerr40[];\r
-extern SetWordType zzerr41[];\r
-extern SetWordType zzerr42[];\r
-extern SetWordType setwd7[];\r
-extern SetWordType zzerr43[];\r
-extern SetWordType zzerr44[];\r
-extern SetWordType zzerr45[];\r
-extern SetWordType zzerr46[];\r
-extern SetWordType zzerr47[];\r
-extern SetWordType zzerr48[];\r
-extern SetWordType zzerr49[];\r
-extern SetWordType zzerr50[];\r
-extern SetWordType zzerr51[];\r
-extern SetWordType zzerr52[];\r
-extern SetWordType zzerr53[];\r
-extern SetWordType setwd8[];\r
-extern SetWordType zzerr54[];\r
-extern SetWordType zzerr55[];\r
-extern SetWordType zzerr56[];\r
-extern SetWordType zzerr57[];\r
-extern SetWordType setwd9[];\r
-extern SetWordType zzerr58[];\r
-extern SetWordType zzerr59[];\r
-extern SetWordType zzerr60[];\r
-extern SetWordType zzerr61[];\r
-extern SetWordType zzerr62[];\r
-extern SetWordType zzerr63[];\r
-extern SetWordType zzerr64[];\r
-extern SetWordType zzerr65[];\r
-extern SetWordType setwd10[];\r
-extern SetWordType setwd11[];\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/build.xml b/Tools/CodeTools/TianoTools/Pccts/build.xml
deleted file mode 100644 (file)
index 4f4e0a9..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-<?xml version="1.0" ?>\r
-<!--\r
-Copyright (c) 2006, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
--->\r
-<project default="GenTool" basedir=".">\r
-<!--\r
-    EDK Pccts Tool\r
-  Copyright (c) 2006, Intel Corporation\r
-  <property name="ToolName" value="Pccts"/>\r
--->\r
-\r
-  <taskdef resource="cpptasks.tasks"/>\r
-  <typedef resource="cpptasks.types"/>\r
-  <taskdef resource="net/sf/antcontrib/antlib.xml"/>\r
-\r
-  <target name="init">\r
-    <echo message="Building the EDK Pccts Tools"/>\r
-  </target>\r
-\r
-  <target name="GenTool" depends="init, Pccts">\r
-    <echo message="The EDK Pccts Tools build has completed!"/>\r
-  </target>\r
-\r
-  <target name="Pccts" depends="init">\r
-    <subant target="" inheritall="true">\r
-       <fileset dir="${PACKAGE_DIR}/Pccts/antlr" includes="build.xml"/>\r
-    </subant>\r
-    <subant target="" inheritall="true">\r
-      <fileset dir="${PACKAGE_DIR}/Pccts/dlg" includes="build.xml"/>\r
-    </subant>\r
-  </target>\r
-\r
-  <target name="clean">\r
-    <ant dir="${PACKAGE_DIR}/Pccts/antlr" target="clean" inheritAll="true"/>\r
-    <ant dir="${PACKAGE_DIR}/Pccts/dlg" target="clean" inheritAll="true"/>\r
-  </target>\r
-\r
-  <target name="cleanall">\r
-    <ant dir="${PACKAGE_DIR}/Pccts/antlr" target="cleanall" inheritAll="true"/>\r
-    <ant dir="${PACKAGE_DIR}/Pccts/dlg" target="cleanall" inheritAll="true"/>\r
-  </target>\r
-\r
-</project>\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/dlg/DlgMS.mak b/Tools/CodeTools/TianoTools/Pccts/dlg/DlgMS.mak
deleted file mode 100644 (file)
index 4a9019b..0000000
+++ /dev/null
@@ -1,121 +0,0 @@
-# PCCTS directory\r
-\r
-# You will need to set the LIB variable similar to this.\r
-# LIB="C:/Program Files/Microsoft Visual Studio .NET 2003/Vc7/lib;c:/Microsoft Visual Studio .NET 2003/Vc7/PlatformSDK/Lib"\r
-\r
-# PCCTS_HOME=<your PCCTS_HOME>\r
-PCCTS_HOME=$(WORKSPACE)\Tools\Source\TianoTools\Pccts\r
-DLG_SRC=$(PCCTS_HOME)\dlg\r
-PCCTS_H=$(PCCTS_HOME)\h\r
-\r
-\r
-# Support directories\r
-SET=$(PCCTS_HOME)\support\set\r
-\r
-\r
-# Compiler stuff\r
-CC = cl\r
-CFLAGS = /nologo -I "." -I "$(PCCTS_H)" -I "$(SET)" -D "USER_ZZSYN" -D "PC" \\r
-        -D "ZZLEXBUFSIZE=65536"  /D "LONGFILENAMES" /W3 /Zi\r
-\r
-DLG_OBJS = dlg_p.obj dlg_a.obj main.obj err.obj support.obj \\r
-           output.obj relabel.obj automata.obj\r
-\r
-SUPPORT_OBJS = set.obj\r
-\r
-# Dependencies\r
-\r
-dlg.exe: $(DLG_OBJS) $(SUPPORT_OBJS)\r
-    $(CC) $(CFLAGS) -o dlg.exe $(DLG_OBJS) $(SUPPORT_OBJS)\r
-    del *.obj\r
-    del *.ilk\r
-    del *.pdb\r
-               move dlg.exe $(WORKSPACE)\Tools\bin\.\r
-\r
-dlg_p.obj: $(DLG_SRC)\dlg_p.c \\r
-                                       $(PCCTS_H)\antlr.h \\r
-                                       $(PCCTS_H)\config.h \\r
-                                       $(PCCTS_H)\dlgdef.h \\r
-                                       $(SET)\set.h \\r
-                       $(DLG_SRC)\dlg.h \\r
-                       $(DLG_SRC)\mode.h \\r
-                       $(DLG_SRC)\tokens.h \\r
-\r
-    $(CC) -c $(CFLAGS) $(DLG_SRC)\dlg_p.c\r
-\r
-dlg_a.obj: $(DLG_SRC)\dlg_a.c \\r
-                                       $(PCCTS_H)\antlr.h \\r
-                                       $(PCCTS_H)\config.h \\r
-                                       $(PCCTS_H)\dlgauto.h \\r
-                                       $(PCCTS_H)\dlgdef.h \\r
-                                       $(SET)\set.h \\r
-                       $(DLG_SRC)\dlg.h \\r
-                       $(DLG_SRC)\mode.h \\r
-                       $(DLG_SRC)\tokens.h \\r
-\r
-    $(CC) -c $(CFLAGS) $(DLG_SRC)\dlg_a.c\r
-\r
-main.obj: $(DLG_SRC)\main.c \\r
-                                       $(PCCTS_H)\antlr.h \\r
-                                       $(PCCTS_H)\config.h \\r
-                                       $(PCCTS_H)\dlgdef.h \\r
-                                       $(SET)\set.h \\r
-                       $(DLG_SRC)\dlg.h \\r
-                       $(DLG_SRC)\mode.h \\r
-                       $(DLG_SRC)\stdpccts.h \\r
-                       $(DLG_SRC)\tokens.h \\r
-\r
-    $(CC) -c $(CFLAGS) $(DLG_SRC)\main.c\r
-\r
-err.obj: $(DLG_SRC)\err.c \\r
-                                       $(PCCTS_H)\antlr.h \\r
-                                       $(PCCTS_H)\config.h \\r
-                                       $(PCCTS_H)\dlgdef.h \\r
-                                       $(PCCTS_H)\err.h \\r
-                                       $(SET)\set.h \\r
-                       $(DLG_SRC)\dlg.h \\r
-                       $(DLG_SRC)\tokens.h \\r
-\r
-    $(CC) -c $(CFLAGS) $(DLG_SRC)\err.c\r
-\r
-support.obj: $(DLG_SRC)\support.c \\r
-                                       $(PCCTS_H)\config.h \\r
-                                       $(SET)\set.h \\r
-                       $(DLG_SRC)\dlg.h \\r
-\r
-    $(CC) -c $(CFLAGS) $(DLG_SRC)\support.c\r
-\r
-output.obj: $(DLG_SRC)\output.c \\r
-                                       $(PCCTS_H)\config.h \\r
-                                       $(SET)\set.h \\r
-                       $(DLG_SRC)\dlg.h \\r
-\r
-    $(CC) -c $(CFLAGS) $(DLG_SRC)\output.c\r
-\r
-relabel.obj: $(DLG_SRC)\relabel.c \\r
-                                       $(PCCTS_H)\config.h \\r
-                                       $(SET)\set.h \\r
-                       $(DLG_SRC)\dlg.h \\r
-\r
-    $(CC) -c $(CFLAGS) $(DLG_SRC)\relabel.c\r
-\r
-automata.obj: $(DLG_SRC)\automata.c \\r
-                                       $(PCCTS_H)\config.h \\r
-                                       $(SET)\set.h \\r
-                       $(DLG_SRC)\dlg.h \\r
-\r
-    $(CC) -c $(CFLAGS) $(DLG_SRC)\automata.c\r
-\r
-\r
-set.obj: $(SET)\set.c \\r
-                                       $(PCCTS_H)\config.h \\r
-                                       $(SET)\set.h \\r
-\r
-    $(CC) -c $(CFLAGS) $(SET)\set.c\r
-\r
-clean: \r
-    del *.obj\r
-\r
-distclean:\r
-    del *.obj\r
-    del $(WORKSPACE)\Tools\bin\dlg.exe\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/dlg/DlgPPC.mak b/Tools/CodeTools/TianoTools/Pccts/dlg/DlgPPC.mak
deleted file mode 100644 (file)
index 55b643a..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-#   File:       dlgPPC.make\r
-#   Target:     dlgPPC\r
-#   Sources:    automata.c\r
-#               dlg_a.c\r
-#               dlg_p.c\r
-#               err.c\r
-#               main.c\r
-#               output.c\r
-#               relabel.c\r
-#               support.c\r
-#               ::support:set:set.c\r
-#   Created:    Sunday, May 17, 1998 11:34:20 PM\r
-#      Author:         Kenji Tanaka\r
-\r
-\r
-MAKEFILE     = dlgPPC.make\r
-Â¥MondoBuildÂ¥ = {MAKEFILE}  # Make blank to avoid rebuilds when makefile is modified\r
-Includes     = Â¶\r
-               -i "::h:" Â¶\r
-               -i "::support:set:"\r
-SymÂ¥PPC      = \r
-ObjDirÂ¥PPC   = ":Obj:"\r
-\r
-PPCCOptions  = {Includes} {SymÂ¥PPC}  -w off -d MPW -d __STDC__=1 -d USER_ZZSYN\r
-\r
-ObjectsÂ¥PPC  = Â¶\r
-               "{ObjDirÂ¥PPC}automata.c.x" Â¶\r
-               "{ObjDirÂ¥PPC}dlg_a.c.x" Â¶\r
-               "{ObjDirÂ¥PPC}dlg_p.c.x" Â¶\r
-               "{ObjDirÂ¥PPC}err.c.x" Â¶\r
-               "{ObjDirÂ¥PPC}main.c.x" Â¶\r
-               "{ObjDirÂ¥PPC}output.c.x" Â¶\r
-               "{ObjDirÂ¥PPC}relabel.c.x" Â¶\r
-               "{ObjDirÂ¥PPC}support.c.x" Â¶\r
-               "{ObjDirÂ¥PPC}set.c.x"\r
-\r
-\r
-dlgPPC Ã„Ä {Â¥MondoBuildÂ¥} {ObjectsÂ¥PPC}\r
-       PPCLink Â¶\r
-               -o {Targ} {SymÂ¥PPC} Â¶\r
-               {ObjectsÂ¥PPC} Â¶\r
-               -t 'MPST' Â¶\r
-               -c 'MPS ' Â¶\r
-               "{SharedLibraries}InterfaceLib" Â¶\r
-               "{SharedLibraries}StdCLib" Â¶\r
-               "{SharedLibraries}MathLib" Â¶\r
-               "{PPCLibraries}StdCRuntime.o" Â¶\r
-               "{PPCLibraries}PPCCRuntime.o" Â¶\r
-               "{PPCLibraries}PPCToolLibs.o"\r
-\r
-\r
-"{ObjDirÂ¥PPC}automata.c.x" Ã„ {Â¥MondoBuildÂ¥} automata.c\r
-       {PPCC} automata.c -o {Targ} {PPCCOptions}\r
-\r
-"{ObjDirÂ¥PPC}dlg_a.c.x" Ã„ {Â¥MondoBuildÂ¥} dlg_a.c\r
-       {PPCC} dlg_a.c -o {Targ} {PPCCOptions}\r
-\r
-"{ObjDirÂ¥PPC}dlg_p.c.x" Ã„ {Â¥MondoBuildÂ¥} dlg_p.c\r
-       {PPCC} dlg_p.c -o {Targ} {PPCCOptions}\r
-\r
-"{ObjDirÂ¥PPC}err.c.x" Ã„ {Â¥MondoBuildÂ¥} err.c\r
-       {PPCC} err.c -o {Targ} {PPCCOptions}\r
-\r
-"{ObjDirÂ¥PPC}main.c.x" Ã„ {Â¥MondoBuildÂ¥} main.c\r
-       {PPCC} main.c -o {Targ} {PPCCOptions}\r
-\r
-"{ObjDirÂ¥PPC}output.c.x" Ã„ {Â¥MondoBuildÂ¥} output.c\r
-       {PPCC} output.c -o {Targ} {PPCCOptions}\r
-\r
-"{ObjDirÂ¥PPC}relabel.c.x" Ã„ {Â¥MondoBuildÂ¥} relabel.c\r
-       {PPCC} relabel.c -o {Targ} {PPCCOptions}\r
-\r
-"{ObjDirÂ¥PPC}support.c.x" Ã„ {Â¥MondoBuildÂ¥} support.c\r
-       {PPCC} support.c -o {Targ} {PPCCOptions}\r
-\r
-"{ObjDirÂ¥PPC}set.c.x" Ã„ {Â¥MondoBuildÂ¥} "::support:set:set.c"\r
-       {PPCC} "::support:set:set.c" -o {Targ} {PPCCOptions}\r
-\r
-\r
-dlgPPC Ã„Ä dlg.r\r
-       Rez dlg.r -o dlgPPC -a\r
-\r
-Install  Ã„ dlgPPC\r
-       Duplicate -y dlgPPC "{MPW}"Tools:dlg\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/dlg/automata.c b/Tools/CodeTools/TianoTools/Pccts/dlg/automata.c
deleted file mode 100644 (file)
index d6d5d78..0000000
+++ /dev/null
@@ -1,353 +0,0 @@
-/* Automata conversion functions for DLG\r
- *\r
- * SOFTWARE RIGHTS\r
- *\r
- * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
- * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
- * company may do whatever they wish with source code distributed with\r
- * PCCTS or the code generated by PCCTS, including the incorporation of\r
- * PCCTS, or its output, into commerical software.\r
- *\r
- * We encourage users to develop software with PCCTS.  However, we do ask\r
- * that credit is given to us for developing PCCTS.  By "credit",\r
- * we mean that if you incorporate our source code into one of your\r
- * programs (commercial product, research project, or otherwise) that you\r
- * acknowledge this fact somewhere in the documentation, research report,\r
- * etc...  If you like PCCTS and have developed a nice tool with the\r
- * output, please mention that you developed it using PCCTS.  In\r
- * addition, we ask that this header remain intact in our source code.\r
- * As long as these guidelines are kept, we expect to continue enhancing\r
- * this system and expect to make other tools available as they are\r
- * completed.\r
- *\r
- * DLG 1.33\r
- * Will Cohen\r
- * With mods by Terence Parr; AHPCRC, University of Minnesota\r
- * 1989-2001\r
- */\r
-\r
-#include <stdio.h>\r
-#include "pcctscfg.h"\r
-#include "dlg.h"\r
-#ifdef MEMCHK\r
-#include "trax.h"\r
-#else\r
-#ifdef __STDC__\r
-#include <stdlib.h>\r
-#else\r
-#include <malloc.h>\r
-#endif /* __STDC__ */\r
-#endif\r
-\r
-#define hash_list struct _hash_list_\r
-hash_list{\r
-       hash_list *next;        /* next thing in list */\r
-       dfa_node *node;\r
- };\r
-\r
-int    dfa_allocated = 0;      /* keeps track of number of dfa nodes */\r
-dfa_node       **dfa_array;    /* root of binary tree that stores dfa array */\r
-dfa_node       *dfa_model_node;\r
-hash_list      *dfa_hash[HASH_SIZE];   /* used to quickly find */\r
-                                       /* desired dfa node */\r
-\r
-void \r
-#ifdef __USE_PROTOS\r
-make_dfa_model_node(int width)\r
-#else\r
-make_dfa_model_node(width)\r
-int width;\r
-#endif\r
-{\r
-       register int i;\r
-       dfa_model_node = (dfa_node*) malloc(sizeof(dfa_node)\r
-                        + sizeof(int)*width);\r
-       dfa_model_node->node_no = -1; /* impossible value for real dfa node */\r
-       dfa_model_node->dfa_set = 0;\r
-       dfa_model_node->alternatives = FALSE;\r
-       dfa_model_node->done = FALSE;\r
-       dfa_model_node->nfa_states = empty;\r
-       for(i = 0; i<width; i++){\r
-               dfa_model_node->trans[i] = NIL_INDEX;\r
-       }\r
-}\r
-\r
-\r
-/* adds a new nfa to the binary tree and returns a pointer to it */\r
-dfa_node *\r
-#ifdef __USE_PROTOS\r
-new_dfa_node(set nfa_states)\r
-#else\r
-new_dfa_node(nfa_states)\r
-set nfa_states;\r
-#endif\r
-{\r
-       register int j;\r
-       register dfa_node *t;\r
-       static int dfa_size=0;  /* elements dfa_array[] can hold */\r
-\r
-       ++dfa_allocated;\r
-       if (dfa_size<=dfa_allocated){\r
-               /* need to redo array */\r
-               if (!dfa_array){\r
-                       /* need some to do inital allocation */\r
-                       dfa_size=dfa_allocated+DFA_MIN;\r
-                       dfa_array=(dfa_node **) malloc(sizeof(dfa_node*)*\r
-                               dfa_size);\r
-               }else{\r
-                       /* need more space */\r
-                       dfa_size=2*(dfa_allocated+1);\r
-                       dfa_array=(dfa_node **) realloc(dfa_array,\r
-                               sizeof(dfa_node*)*dfa_size);\r
-               }\r
-       }\r
-       /* fill out entry in array */\r
-       t = (dfa_node*) malloc(sizeof(nfa_node)+sizeof(int)*class_no);\r
-       *t = *dfa_model_node;\r
-       for (j=0; j<class_no; ++j)\r
-               t->trans[j] = NIL_INDEX;\r
-       t->node_no = dfa_allocated;\r
-       t->nfa_states = set_dup(nfa_states);\r
-       dfa_array[dfa_allocated] = t;\r
-       return t;\r
-}\r
-\r
-\r
-/* past a pointer to the start start of the nfa graph\r
- * nfa_to_dfa convers this graph to dfa.  The function returns\r
- * a pointer to the first dfa state.\r
- * NOTE:  The function that prints out the table will have to figure out how\r
- * to find the other dfa states given the first dfa_state and the number of dfa\r
- * nodes allocated\r
- */\r
-dfa_node **\r
-#ifdef __USE_PROTOS\r
-nfa_to_dfa(nfa_node *start)\r
-#else\r
-nfa_to_dfa(start)\r
-nfa_node *start;\r
-#endif\r
-{\r
-       register dfa_node *d_state, *trans_d_state;\r
-       register int a;\r
-       set t;\r
-       int last_done;\r
-       unsigned *nfa_list;\r
-       unsigned *reach_list;\r
-\r
-       reach_list = (unsigned *) malloc((2+nfa_allocated)*sizeof(unsigned));\r
-       if (!start) return NULL;\r
-       t = set_of(NFA_NO(start));\r
-       _set_pdq(t,reach_list);\r
-       closure(&t,reach_list);\r
-       /* Make t a dfa state */\r
-       d_state = dfastate(t);\r
-       last_done = DFA_NO(d_state);\r
-       \r
-       do {\r
-               /* Mark dfa state x as "done" */\r
-               d_state->done = TRUE;\r
-               nfa_list = set_pdq(d_state->nfa_states);\r
-               for (a = 0; a<class_no; ++a) {\r
-                       /* Add NFA states reached by a from d_state */\r
-                       reach(nfa_list,a,reach_list);\r
-                       /* Were any states found? */\r
-                       if ((*reach_list)!=nil) {\r
-                               /* was t=empty; */\r
-                               set_free(t);\r
-                               /* yes, compute closure */\r
-                               closure(&t,reach_list);\r
-                               /* Make DFA state of it ... */\r
-                               trans_d_state = dfastate(t);\r
-                               /* And make transition x->t, labeled with a */\r
-                               d_state->trans[a] = DFA_NO(trans_d_state);\r
-                               d_state->alternatives = TRUE;\r
-                       }\r
-               }\r
-               free(nfa_list);\r
-               ++last_done; /* move forward in queue */\r
-               /* And so forth until nothing isn't done */\r
-               d_state = DFA(last_done);\r
-       } while (last_done<=dfa_allocated);\r
-\r
-       free(reach_list);\r
-       set_free(t);\r
-\r
-       /* returns pointer to the array that holds the automaton */\r
-       return dfa_array;\r
-}\r
-\r
-void \r
-#ifdef __USE_PROTOS\r
-clear_hash(void)\r
-#else\r
-clear_hash()\r
-#endif\r
-{\r
-       register int i;\r
-\r
-       for(i=0; i<HASH_SIZE; ++i)\r
-               dfa_hash[i] = 0;\r
-}\r
-\r
-#if HASH_STAT\r
-void\r
-#ifdef __USE_PROTOS\r
-fprint_hash_stats(FILE *f)\r
-#else\r
-fprint_hash_stats(f)\r
-FILE *f;\r
-#endif\r
-{\r
-       register hash_list *p;\r
-       register int i,j;\r
-       register total;\r
-\r
-       total=0;\r
-       for(i=0; i<HASH_SIZE; ++i){\r
-               j=0;\r
-               p = dfa_hash[i];\r
-               while(p){\r
-                       ++j;\r
-                       p = p->next;\r
-               }\r
-               total+=j;\r
-               fprintf(f,"bin[%d] has %d\n",i,j);\r
-       }\r
-       fprintf(f,"total = %d\n",total);\r
-}\r
-#endif\r
-\r
-/* Returns a pointer to a dfa node that has the same nfa nodes in it.\r
- * This may or maynot be a newly created node.\r
- */\r
-dfa_node *\r
-#ifdef __USE_PROTOS\r
-dfastate(set nfa_states)\r
-#else\r
-dfastate(nfa_states)\r
-set nfa_states;\r
-#endif\r
-{\r
-       register hash_list *p;\r
-       int bin;\r
-\r
-       /* hash using set and see if it exists */\r
-       bin = set_hash(nfa_states,HASH_SIZE);\r
-       p = dfa_hash[bin];\r
-       while(p && !set_equ(nfa_states,(p->node)->nfa_states)){\r
-               p = p->next;\r
-       }\r
-       if(!p){\r
-               /* next state to add to hash table */\r
-               p = (hash_list*)malloc(sizeof(hash_list));\r
-               p->node = new_dfa_node(nfa_states);\r
-               p->next = dfa_hash[bin];\r
-               dfa_hash[bin] = p;\r
-       }\r
-       return (p->node);\r
-}\r
-\r
-\r
-/* this reach assumes the closure has been done already on set */\r
-int \r
-#ifdef __USE_PROTOS\r
-reach(unsigned *nfa_list, register int a, unsigned *reach_list)\r
-#else\r
-reach(nfa_list, a, reach_list)\r
-unsigned *nfa_list;\r
-register int a;\r
-unsigned *reach_list;\r
-#endif\r
-{\r
-       register unsigned *e;\r
-       register nfa_node *node;\r
-       int t=0;\r
-\r
-       e = nfa_list;\r
-       if (e){\r
-               while (*e != nil){\r
-                       node = NFA(*e);\r
-                       if (set_el(a,node->label)){\r
-                               t=1;\r
-                               *reach_list=NFA_NO(node->trans[0]);\r
-                               ++reach_list;\r
-                       }\r
-                       ++e;\r
-               }\r
-       }\r
-       *reach_list=nil;\r
-       return t;\r
-}\r
-\r
-/* finds all the nodes that can be reached by epsilon transitions\r
-   from the set of a nodes and returns puts them back in set b */\r
-set \r
-#ifdef __USE_PROTOS\r
-closure(set *b, unsigned *reach_list)\r
-#else\r
-closure(b, reach_list)\r
-set *b;\r
-unsigned *reach_list;\r
-#endif\r
-{\r
-       register nfa_node *node,*n;     /* current node being examined */\r
-       register unsigned *e;\r
-\r
-       ++operation_no;\r
-#if 0\r
-       t = e = set_pdq(*b);\r
-#else\r
-       e=reach_list;\r
-#endif\r
-       while (*e != nil){\r
-               node = NFA(*e);\r
-               set_orel(NFA_NO(node),b);\r
-               /* mark it done */\r
-               node->nfa_set = operation_no;\r
-               if ((n=node->trans[0]) != NIL_INDEX && set_nil(node->label) &&\r
-                 (n->nfa_set != operation_no)){\r
-                       /* put in b */\r
-                       set_orel(NFA_NO(n),b);\r
-                       close1(n,operation_no,b);\r
-               }\r
-               if ((n=node->trans[1]) != NIL_INDEX &&\r
-                 (n->nfa_set != operation_no)){\r
-                       /* put in b */\r
-                       set_orel(NFA_NO(node->trans[1]),b);\r
-                       close1(n,operation_no,b);\r
-               }\r
-               ++e;\r
-       }\r
-#if 0\r
-       free(t);\r
-#endif\r
-       return *b;\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-void close1(nfa_node *node, int o, set *b)\r
-#else\r
-void close1(node,o,b)\r
-nfa_node *node;\r
-int o; /* marker to avoid cycles */\r
-set *b;\r
-#endif\r
-{\r
-       register nfa_node *n;   /* current node being examined */\r
-\r
-       /* mark it done */\r
-       node->nfa_set = o;\r
-       if ((n=node->trans[0]) != NIL_INDEX && set_nil(node->label) &&\r
-         (n->nfa_set != o)){\r
-               /* put in b */\r
-               set_orel(NFA_NO(n),b);\r
-               close1(n,o,b);\r
-       }\r
-       if ((n=node->trans[1]) != NIL_INDEX &&\r
-         (n->nfa_set != o)){\r
-               /* put in b */\r
-               set_orel(NFA_NO(node->trans[1]),b);\r
-               close1(n,o,b);\r
-       }\r
-}\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/dlg/build.xml b/Tools/CodeTools/TianoTools/Pccts/dlg/build.xml
deleted file mode 100644 (file)
index 4195950..0000000
+++ /dev/null
@@ -1,121 +0,0 @@
-<?xml version="1.0" ?>\r
-<!--\r
-Copyright (c) 2006, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
--->\r
-<project default="GenTool" basedir=".">\r
-<!--\r
-    EDK Pccts Tool: dlg\r
-  Copyright (c) 2006, Intel Corporation\r
--->\r
-  <property name="ToolName" value="dlg"/>\r
-\r
-  <taskdef resource="cpptasks.tasks"/>\r
-  <typedef resource="cpptasks.types"/>\r
-  <taskdef resource="net/sf/antcontrib/antlib.xml"/>\r
-\r
-  <property name="PACKAGE_DIR" value="${WORKSPACE}/Tools"/>\r
-\r
-  <target name="init">\r
-               <condition property="CheckDepends">\r
-                 <uptodate targetfile="${WORKSPACE}/Tools/bin/dlg.exe">\r
-                         <srcfiles dir="." includes="*.c *.h *.g"/>\r
-                       </uptodate>\r
-               </condition>\r
-               <if>\r
-                 <equals arg1="${CheckDepends}" arg2="true"/>\r
-                       <then>\r
-                               <echo message="Executable, dlg.exe, is up to date."/>\r
-                       </then>\r
-      <else>\r
-        <echo message="Building the EDK Pccts Tool: ${ToolName}"/>\r
-      </else>\r
-               </if>\r
-  </target>\r
-\r
-  <target name="GenTool" depends="init" unless="CheckDepends">\r
-    <if>\r
-      <equals arg1="${ToolChain}" arg2="msvc"/>\r
-                       <then>\r
-         <exec dir="${PACKAGE_DIR}/Pccts/dlg" executable="nmake" failonerror="TRUE">\r
-                 <arg line="-f DlgMS.mak"/>\r
-               </exec>\r
-                 </then>\r
-               <elseif>\r
-      <istrue value="${cygwin}"/>\r
-      <then>\r
-         <exec dir="${PACKAGE_DIR}/Pccts/dlg" executable="make" failonerror="TRUE">\r
-                 <arg line="-f makefile.cygwin"/>\r
-               </exec>\r
-      </then>\r
-    </elseif>\r
-               <elseif>\r
-      <equals arg1="${ToolChain}" arg2="gcc"/>\r
-                       <then>\r
-         <exec dir="${PACKAGE_DIR}/Pccts/dlg" executable="make" failonerror="TRUE">\r
-                 <arg line="-f makefile BIN_DIR=${BIN_DIR}"/>\r
-               </exec>\r
-                 </then>\r
-               </elseif>\r
-               </if>\r
-    <echo message="The EDK Tool: ${ToolName} build has completed!"/>\r
-       </target>\r
-\r
-  <target name="clean">\r
-    <echo message="Removing Intermediate Files Only"/>  \r
-    <if>\r
-      <equals arg1="${ToolChain}" arg2="msvc"/>\r
-                       <then>\r
-         <exec dir="${PACKAGE_DIR}/Pccts/dlg" executable="nmake" failonerror="TRUE">\r
-                 <arg line="-f DlgMS.mak clean"/>\r
-               </exec>\r
-                 </then>\r
-    <elseif>\r
-      <istrue value="${cygwin}"/>\r
-      <then>\r
-         <exec dir="${PACKAGE_DIR}/Pccts/dlg" executable="make" failonerror="TRUE">\r
-                 <arg line="-f makefile.cygwin clean"/>\r
-               </exec>\r
-      </then>\r
-               </elseif>\r
-               <elseif>\r
-      <equals arg1="${ToolChain}" arg2="gcc"/>\r
-                       <then>\r
-         <exec dir="${PACKAGE_DIR}/Pccts/dlg" executable="make" failonerror="TRUE">\r
-                 <arg line="-f makefile clean"/>\r
-               </exec>\r
-                 </then>\r
-               </elseif>\r
-               </if>\r
-  </target>\r
-\r
-  <target name="cleanall">\r
-    <echo message="Removing Object Files and the Executable: ${ToolName}${ext_exe}"/>  \r
-    <if>\r
-      <equals arg1="${ToolChain}" arg2="msvc"/>\r
-                       <then>\r
-         <exec dir="${PACKAGE_DIR}/Pccts/dlg" executable="nmake" failonerror="FALSE">\r
-                 <arg line="-f DlgMS.mak clean"/>\r
-               </exec>\r
-                 </then>\r
-               <elseif>\r
-      <equals arg1="${ToolChain}" arg2="gcc"/>\r
-                       <then>\r
-         <exec dir="${PACKAGE_DIR}/Pccts/dlg" executable="make" failonerror="FALSE">\r
-                 <arg line="-f makefile clean"/>\r
-               </exec>\r
-                 </then>\r
-               </elseif>\r
-               </if>\r
-    <delete failonerror="false" quiet="true" includeEmptyDirs="true">\r
-      <fileset file="${BIN_DIR}/${ToolName}${ext_exe}"/>\r
-    </delete>\r
-  </target>\r
-\r
-</project>\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/dlg/dlg.1 b/Tools/CodeTools/TianoTools/Pccts/dlg/dlg.1
deleted file mode 100644 (file)
index f68e3ae..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-.TH dlg 1 "April 1994" "DLG" "PCCTS Manual Pages"\r
-.SH NAME\r
-dlg \- DFA Lexical Analyzer Generator\r
-.SH SYNTAX\r
-.LP\r
-\fBdlg\fR [\fIoptions\fR] \fIlexical_spec\fR [\fIoutput_file\fR]\r
-.SH DESCRIPTION\r
-.B dlg\r
-is a tool that produces fast deterministic finite automata for recognizing\r
-regular expressions in input.\r
-.SH OPTIONS\r
-.IP "\fB-CC\fR"\r
-Generate C++ output.  The \fIoutput_file\fP is not specified in this\r
-case.\r
-.IP "\fB-C\fR[\fP level\fR]\r
-Where \fPlevel\fR is the compression level used.  0 indications no\r
-compression, 1 removes all unused characters from the transition from table,\r
-and 2 maps equivalent characters into the same character classes.  It is\r
-suggested that level -C2 is used, since it will significantly reduce the size\r
-of the dfa produced for lexical analyzer.\r
-.IP "\fB-m\fP\r
-Produces the header file for the lexical mode with a name other than\r
-the default name of "mode.h".\r
-.IP \fB-i\fP\r
-An interactive, or as interactive as possible, parser is produced.  A character\r
-is only obtained when required to decide which state to go to.  Some care\r
-must be taken to obtain accept states that do not require look ahead at the\r
-next character to determine if that is the stop state.  Any regular expression\r
-with a Kleene closure at the end is guaranteed to require another character\r
-of look ahead.\r
-.IP "\fB-cl\fP class\r
-Specify a class name for DLG to generate.  The default is DLGLexer.\r
-'class' will be a subclass of DLGLexerBase; only used for -CC.\r
-.IP \fB-ci\fP\r
-The automaton will treat upper and lower case characters identically.\r
-This is accomplished in the automaton; the characters in the lexical\r
-buffer are unmodified.\r
-.IP \fB-cs\fP\r
-Upper and lower case characters are treated as distinct.  This is the\r
-default.\r
-.IP "\fB-o\fP dir\r
-Directory where output files should go (default=".").  This is very\r
-nice for keeping the source directory clear of ANTLR and DLG spawn.\r
-.IP \fB-Wambiguity\fP\r
-Warns if more than one regular expression could match the same character\r
-sequence.  The warnings give the numbers of the expressions in the dlg\r
-lexical specification file.  The numbering of the expressions starts at one.\r
-Multiple warnings may be print for the same expressions.\r
-.IP \-\r
-Used in place of file names to get input from standard in or send output\r
-to standard out.\r
-.SH "SPECIAL CONSIDERATIONS"\r
-.PP\r
-\fIDlg\fP works...  we think.  There is no implicit guarantee of\r
-anything.  We reserve no \fBlegal\fP rights to the software known as\r
-the Purdue Compiler Construction Tool Set (PCCTS) \(em PCCTS is in the\r
-public domain.  An individual or company may do whatever they wish\r
-with source code distributed with PCCTS or the code generated by\r
-PCCTS, including the incorporation of PCCTS, or its output, into\r
-commercial software.  We encourage users to develop software with\r
-PCCTS.  However, we do ask that credit is given to us for developing\r
-PCCTS.  By "credit", we mean that if you incorporate our source code\r
-into one of your programs (commercial product, research project, or\r
-otherwise) that you acknowledge this fact somewhere in the\r
-documentation, research report, etc...  If you like PCCTS and have\r
-developed a nice tool with the output, please mention that you\r
-developed it using PCCTS.  As long as these guidelines are followed, we\r
-expect to continue enhancing this system and expect to make other\r
-tools available as they are completed.\r
-.SH FILES\r
-.B mode.h\r
-,\r
-.B dlgauto.h\r
-,\r
-.B dlgdef.h\r
-.SH SEE ALSO\r
-.BR antlr (1),\r
-.BR pccts (1)\r
-.SH BUGS\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/dlg/dlg.h b/Tools/CodeTools/TianoTools/Pccts/dlg/dlg.h
deleted file mode 100644 (file)
index 9f387c0..0000000
+++ /dev/null
@@ -1,250 +0,0 @@
-/* dlg header file\r
- *\r
- * SOFTWARE RIGHTS\r
- *\r
- * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
- * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
- * company may do whatever they wish with source code distributed with\r
- * PCCTS or the code generated by PCCTS, including the incorporation of\r
- * PCCTS, or its output, into commerical software.\r
- *\r
- * We encourage users to develop software with PCCTS.  However, we do ask\r
- * that credit is given to us for developing PCCTS.  By "credit",\r
- * we mean that if you incorporate our source code into one of your\r
- * programs (commercial product, research project, or otherwise) that you\r
- * acknowledge this fact somewhere in the documentation, research report,\r
- * etc...  If you like PCCTS and have developed a nice tool with the\r
- * output, please mention that you developed it using PCCTS.  In\r
- * addition, we ask that this header remain intact in our source code.\r
- * As long as these guidelines are kept, we expect to continue enhancing\r
- * this system and expect to make other tools available as they are\r
- * completed.\r
- *\r
- * DLG 1.33\r
- * Will Cohen\r
- * With mods by Terence Parr; AHPCRC, University of Minnesota\r
- * 1989-2001\r
- */\r
-\r
-/* MR1 Move pcctscfg.h to top of file                                  */\r
-\r
-#include "pcctscfg.h"                                          \r
-\r
-/* turn off warnings for unreferenced labels */\r
-\r
-#ifdef _MSC_VER\r
-#pragma warning(disable:4102)\r
-#endif\r
-\r
-#include "set.h"\r
-\r
-#define TRUE   1\r
-#define FALSE  0\r
-\r
-/***** output related stuff *******************/\r
-#define IN     input_stream\r
-#define OUT    output_stream\r
-\r
-#define MAX_MODES      50      /* number of %%names allowed */\r
-#define MAX_ON_LINE    10\r
-\r
-#define NFA_MIN                64      /* minimum nfa_array size */\r
-#define DFA_MIN                64      /* minimum dfa_array size */\r
-\r
-#define DEFAULT_CLASSNAME "DLGLexer"\r
-\r
-/* these macros allow the size of the character set to be easily changed */\r
-/* NOTE: do NOT change MIN_CHAR since EOF is the lowest char, -1 */\r
-#define MIN_CHAR (-1)  /* lowest possible character possible on input */\r
-#define MAX_CHAR 255   /* highest possible character possible on input */\r
-#define CHAR_RANGE (1+(MAX_CHAR) - (MIN_CHAR))\r
-\r
-/* indicates that the not an "array" reference */\r
-#define NIL_INDEX 0\r
-\r
-/* size of hash table used to find dfa_states quickly */\r
-#define HASH_SIZE 211\r
-\r
-#define nfa_node struct _nfa_node\r
-nfa_node {\r
-       int             node_no;\r
-       int             nfa_set;\r
-       int             accept; /* what case to use */\r
-       nfa_node        *trans[2];\r
-       set             label;  /* one arc always labelled with epsilon */\r
-};\r
-\r
-#define dfa_node struct _dfa_node\r
-dfa_node {\r
-       int             node_no;\r
-       int             dfa_set;\r
-       int             alternatives;   /* used for interactive mode */\r
-                                       /* are more characters needed */\r
-       int             done;\r
-       set             nfa_states;\r
-       int             trans[1];/* size of transition table depends on\r
-                                 * number of classes required for automata.\r
-                                 */\r
-\r
-\r
-};\r
-\r
-/******** macros for accessing the NFA and DFA nodes ****/\r
-#define NFA(x) (nfa_array[x])\r
-#define DFA(x) (dfa_array[x])\r
-#define DFA_NO(x) ( (x) ? (x)->node_no : NIL_INDEX)\r
-#define NFA_NO(x) ( (x) ? (x)->node_no : NIL_INDEX)\r
-\r
-/******** wrapper for memory checking ***/\r
-/*#define malloc(x)    dlg_malloc((x),__FILE__,__LINE__)*/\r
-\r
-/*#define calloc(x,y)  dlg_calloc((x),(y),__FILE__,__LINE__)*/\r
-\r
-/******** antlr attributes *************/\r
-typedef struct {\r
-       unsigned char letter;\r
-       nfa_node *l,*r;\r
-       set label;\r
-       } Attrib;\r
-\r
-#define zzcr_attr(attr, token, text) {                                 \\r
-       (attr)->letter = text[0]; (attr)->l = NULL;                     \\r
-       (attr)->r = NULL; (attr)->label = empty;                        \\r
-}\r
-#define zzd_attr(a)    set_free((a)->label);\r
-\r
-/******************** Variable ******************************/\r
-extern char    program[];      /* tells what program this is */\r
-extern char    version[];      /* tells what version this is */\r
-extern char    *file_str[];    /* file names being used */\r
-extern int     err_found;      /* flag to indicate error occured */\r
-extern int     action_no;      /* last action function printed */\r
-extern int     func_action;    /* should actions be turned into functions?*/\r
-extern set     used_chars;     /* used to label trans. arcs */\r
-extern set     used_classes;   /* classes or chars used to label trans. arcs */\r
-extern int     class_no;       /* number of classes used */\r
-extern set     class_sets[];   /* shows char. in each class */\r
-extern set     normal_chars;   /* mask off unused portion of set */\r
-extern int     comp_level;     /* what compression level to use */\r
-extern int     interactive;    /* interactive scanner (avoid lookahead)*/\r
-extern int     mode_counter;   /* keeps track of the number of %%name */\r
-extern int     dfa_basep[];    /* start of each group of dfa */\r
-extern int     dfa_class_nop[];/* number of transistion arcs in */\r
-                               /* each dfa in each mode */\r
-extern int     nfa_allocated;\r
-extern int     dfa_allocated;\r
-extern nfa_node        **nfa_array;    /* start of nfa "array" */\r
-extern dfa_node        **dfa_array;    /* start of dfa "array" */\r
-extern int     operation_no;   /* unique number for each operation */\r
-extern FILE    *input_stream;  /* where description read from */\r
-extern FILE    *output_stream; /* where to put the output */\r
-extern FILE    *mode_stream;   /* where to put the mode output */\r
-extern FILE    *class_stream;\r
-extern char    *mode_file;     /* name of file for mode output */\r
-extern int     gen_ansi;       /* produce ansi compatible code */\r
-extern int     case_insensitive;/* ignore case of input spec. */\r
-extern int     warn_ambig;     /* show if regular expressions ambiguous */\r
-extern int     gen_cpp;\r
-extern char *cl_file_str;\r
-extern int     firstLexMember; /* MR1 */\r
-extern char *OutputDirectory;\r
-extern char    *class_name;\r
-\r
-/******************** Functions ******************************/\r
-#ifdef __USE_PROTOS\r
-extern char    *dlg_malloc(int, char *, int); /* wrapper malloc */\r
-extern char    *dlg_calloc(int, int, char *, int); /* wrapper calloc */\r
-extern int     reach(unsigned *, register int, unsigned *);\r
-extern set     closure(set *, unsigned *);\r
-extern dfa_node *new_dfa_node(set);\r
-extern nfa_node *new_nfa_node(void);\r
-extern dfa_node *dfastate(set);\r
-extern dfa_node **nfa_to_dfa(nfa_node *);\r
-extern void    internal_error(char *, char *, int);    /* MR9 23-Sep-97 */\r
-extern FILE    *read_stream(char *);   /* opens file for reading */\r
-extern FILE    *write_stream(char *);  /* opens file for writing */\r
-extern void    make_nfa_model_node(void);\r
-extern void    make_dfa_model_node(int);\r
-extern char *ClassName(char *);\r
-extern char *OutMetaName(char *);\r
-extern void error(char*, int);\r
-extern void warning(char*, int);\r
-extern void p_head(void);\r
-extern void p_class_hdr(void);\r
-extern void p_includes(void);\r
-extern void p_tables(void);\r
-extern void p_tail(void);                                      /* MR1 */\r
-extern void p_class_def1(void);                                /* MR1 */\r
-extern void new_automaton_mode(void);                  /* MR1 */\r
-extern int  relabel(nfa_node *,int);                   /* MR1 */\r
-extern void p_shift_table(int);                                /* MR1 */\r
-extern void p_bshift_table(void);                              /* MR1 */\r
-extern void p_class_table(void);                               /* MR1 */\r
-extern void p_mode_def(char *,int);                    /* MR1 */\r
-extern void init(void);                                        /* MR1 */\r
-extern void p_class_def2(void);                                /* MR1 */\r
-extern void clear_hash(void);                          /* MR1 */\r
-extern void p_alternative_table(void);                 /* MR1 */\r
-extern void p_node_table(void);                                /* MR1 */\r
-extern void p_dfa_table(void);                         /* MR1 */\r
-extern void p_accept_table(void);                              /* MR1 */\r
-extern void p_action_table(void);                              /* MR1 */\r
-extern void p_base_table(void);                                /* MR1 */\r
-extern void p_single_node(int,int);                    /* MR1 */\r
-extern char * minsize(int);                            /* MR1 */\r
-extern void close1(nfa_node *,int,set *);              /* MR1 */\r
-extern void partition(nfa_node *,int);                 /* MR1 */\r
-extern void intersect_nfa_labels(nfa_node *,set *);    /* MR1 */\r
-extern void r_intersect(nfa_node *,set *);             /* MR1 */\r
-extern void label_node(nfa_node *);                    /* MR1 */\r
-extern void label_with_classes(nfa_node *);            /* MR1 */\r
-\r
-#else\r
-extern char *dlg_malloc();     /* wrapper malloc */\r
-extern char *dlg_calloc();     /* wrapper calloc */\r
-extern int     reach();\r
-extern set     closure();\r
-extern dfa_node *new_dfa_node();\r
-extern nfa_node *new_nfa_node();\r
-extern dfa_node *dfastate();\r
-extern dfa_node **nfa_to_dfa();\r
-extern void    internal_error();   /* MR9 23-Sep-97 */\r
-extern FILE    *read_stream();         /* opens file for reading */\r
-extern FILE    *write_stream();        /* opens file for writing */\r
-extern void    make_nfa_model_node();\r
-extern void    make_dfa_model_node();\r
-extern char *ClassName();\r
-extern char *OutMetaName();\r
-extern void error();\r
-extern void warning();\r
-extern void p_head();                   /* MR9 */\r
-extern void p_class_hdr();              /* MR9 */\r
-extern void p_includes();               /* MR9 */\r
-extern void p_tables();                 /* MR9 */\r
-extern void p_tail();                                  /* MR1 */\r
-extern void p_class_def1();                            /* MR1 */\r
-extern void new_automaton_mode();                      /* MR1 */\r
-extern int  relabel();                                 /* MR1 */\r
-extern void p_shift_table();                           /* MR1 */\r
-extern void p_bshift_table();                          /* MR1 */\r
-extern void p_class_table();                           /* MR1 */\r
-extern void p_mode_def();                              /* MR1 */\r
-extern void init();                                    /* MR1 */\r
-extern void p_class_def2();                            /* MR1 */\r
-extern void clear_hash();                              /* MR1 */\r
-extern void p_alternative_table();                     /* MR1 */\r
-extern void p_node_table();                            /* MR1 */\r
-extern void p_dfa_table();                             /* MR1 */\r
-extern void p_accept_table();                          /* MR1 */\r
-extern void p_action_table();                          /* MR1 */\r
-extern void p_base_table();                            /* MR1 */\r
-extern void p_single_node();                           /* MR1 */\r
-extern char * minsize();                               /* MR1 */\r
-extern void close1();                                  /* MR1 */\r
-extern void partition();                               /* MR1 */\r
-extern void intersect_nfa_labels();                    /* MR1 */\r
-extern void r_intersect();                             /* MR1 */\r
-extern void label_node();                              /* MR1 */\r
-extern void label_with_classes();                      /* MR1 */\r
-\r
-#endif\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/dlg/dlg.r b/Tools/CodeTools/TianoTools/Pccts/dlg/dlg.r
deleted file mode 100644 (file)
index c5311fa..0000000
+++ /dev/null
@@ -1,275 +0,0 @@
-/*\r
-       File:           dlgMPW.r\r
-       Target:         dlg 133MR\r
-       Created:    Monday, June 15, 1998 4:44:11 AM\r
-       Author:         Kenji Tanaka (kentar@osa.att.ne.jp)\r
-*/\r
-\r
-#include "cmdo.r"\r
-\r
-resource 'cmdo' (128, "Dlg") {\r
-       {       /* array dialogs: 1 elements */\r
-               /* [1] */\r
-               295,\r
-               "DLG -- Purdue Compiler Construction Tool"\r
-               " Set (PCCTS) lexical analyzer generator.",\r
-               {       /* array itemArray: 18 elements */\r
-                       /* [1] */\r
-                       NotDependent {\r
-\r
-                       },\r
-                       CheckOption {\r
-                               NotSet,\r
-                               {35, 175, 50, 225},\r
-                               "On",\r
-                               "-CC",\r
-                               "When this control is checked, DLG genera"\r
-                               "tes a scanner using C++ classes rather t"\r
-                               "han C functions."\r
-                       },\r
-                       /* [2] */\r
-                       Or {\r
-                               {       /* array OrArray: 1 elements */\r
-                                       /* [1] */\r
-                                       1\r
-                               }\r
-                       },\r
-                       RegularEntry {\r
-                               "Lexer Class Name:",\r
-                               {35, 225, 50, 355},\r
-                               {35, 355, 51, 450},\r
-                               "DLGLexer",\r
-                               keepCase,\r
-                               "-cl",\r
-                               "This entry specifies the name DLG uses f"\r
-                               "or the C++ lexer class."\r
-                       },\r
-                       /* [3] */\r
-                       NotDependent {\r
-\r
-                       },\r
-                       TextBox {\r
-                               gray,\r
-                               {25, 165, 60, 460},\r
-                               "C++ Code Generation"\r
-                       },\r
-                       /* [4] */\r
-                       NotDependent {\r
-\r
-                       },\r
-                       Files {\r
-                               InputFile,\r
-                               RequiredFile {\r
-                                       {37, 25, 56, 135},\r
-                                       "Input File",\r
-                                       "",\r
-                                       "Choose the lexical description file for "\r
-                                       "DLG to process."\r
-                               },\r
-                               Additional {\r
-                                       "",\r
-                                       "",\r
-                                       "",\r
-                                       "",\r
-                                       {       /* array TypesArray: 1 elements */\r
-                                               /* [1] */\r
-                                               text\r
-                                       }\r
-                               }\r
-                       },\r
-                       /* [5] */\r
-                       Or {\r
-                               {       /* array OrArray: 1 elements */\r
-                                       /* [1] */\r
-                                       -1\r
-                               }\r
-                       },\r
-                       Files {\r
-                               OutputFile,\r
-                               RequiredFile {\r
-                                       {66, 25, 85, 135},\r
-                                       "Output File",\r
-                                       "",\r
-                                       "Choose the name of the file that will ho"\r
-                                       "ld the DLG-produced scanner."\r
-                               },\r
-                               NoMore {\r
-\r
-                               }\r
-                       },\r
-                       /* [6] */\r
-                       Or {\r
-                               {       /* array OrArray: 2 elements */\r
-                                       /* [1] */\r
-                                       1,\r
-                                       /* [2] */\r
-                                       5\r
-                               }\r
-                       },\r
-                       Dummy {\r
-\r
-                       },\r
-                       /* [7] */\r
-                       NotDependent {\r
-\r
-                       },\r
-                       Redirection {\r
-                               DiagnosticOutput,\r
-                               {90, 25}\r
-                       },\r
-                       /* [8] */\r
-                       NotDependent {\r
-\r
-                       },\r
-                       TextBox {\r
-                               gray,\r
-                               {25, 20, 132, 145},\r
-                               "Files"\r
-                       },\r
-                       /* [9] */\r
-                       NotDependent {\r
-\r
-                       },\r
-                       Files {\r
-                               DirOnly,\r
-                               OptionalFile {\r
-                                       {68, 175, 84, 305},\r
-                                       {88, 175, 107, 305},\r
-                                       "Output Directory",\r
-                                       ":",\r
-                                       "-o",\r
-                                       "",\r
-                                       "Choose the directory where DLG will put "\r
-                                       "its output.",\r
-                                       dim,\r
-                                       "Output DirectoryI",\r
-                                       "",\r
-                                       ""\r
-                               },\r
-                               NoMore {\r
-\r
-                               }\r
-                       },\r
-                       /* [10] */\r
-                       NotDependent {\r
-\r
-                       },\r
-                       RegularEntry {\r
-                               "Mode File Name:",\r
-                               {68, 315, 83, 450},\r
-                               {88, 315, 104, 450},\r
-                               "mode.h",\r
-                               keepCase,\r
-                               "-m",\r
-                               "This entry specifies the name DLG uses f"\r
-                               "or its lexical mode output file."\r
-                       },\r
-                       /* [11] */\r
-                       NotDependent {\r
-\r
-                       },\r
-                       RadioButtons {\r
-                               {       /* array radioArray: 3 elements */\r
-                                       /* [1] */\r
-                                       {134, 175, 149, 255}, "None", "", Set, "When this option is selected, DLG will n"\r
-                                       "ot compress its tables.",\r
-                                       /* [2] */\r
-                                       {134, 265, 149, 345}, "Level 1", "-C1", NotSet, "When this option is selected, DLG will r"\r
-                                       "emove all unused characters from the tra"\r
-                                       "nsition-from table.",\r
-                                       /* [3] */\r
-                                       {134, 360, 149, 450}, "Level 2", "-C2", NotSet, "When this option is selected, DLG will p"\r
-                                       "erform level 1 compression plus it will "\r
-                                       "map equivalent characters into the same "\r
-                                       "character classes."\r
-                               }\r
-                       },\r
-                       /* [12] */\r
-                       NotDependent {\r
-\r
-                       },\r
-                       TextBox {\r
-                               gray,\r
-                               {124, 165, 156, 460},\r
-                               "Table Compression"\r
-                       },\r
-                       /* [13] */\r
-                       NotDependent {\r
-\r
-                       },\r
-                       CheckOption {\r
-                               Set,\r
-                               {165, 20, 180, 145},\r
-                               "Case Sensitive",\r
-                               "-ci",\r
-                               "When this control is checked, the DLG au"\r
-                               "tomaton will treat upper and lower case "\r
-                               "characters identically."\r
-                       },\r
-                       /* [14] */\r
-                       NotDependent {\r
-\r
-                       },\r
-                       CheckOption {\r
-                               NotSet,\r
-                               {165, 150, 180, 300},\r
-                               "Interactive Scanner",\r
-                               "-i",\r
-                               "When this control is checked, DLG will g"\r
-                               "enerate as interactive a scanner as poss"\r
-                               "ible."\r
-                       },\r
-                       /* [15] */\r
-                       NotDependent {\r
-\r
-                       },\r
-                       CheckOption {\r
-                               NotSet,\r
-                               {165, 310, 180, 460},\r
-                               "Ambiguity Warnings",\r
-                               "-Wambiguity",\r
-                               "When this control is checked, DLG warns "\r
-                               "if more than one regular expression coul"\r
-                               "d match the same character sequence."\r
-                       },\r
-                       /* [16] */\r
-                       NotDependent {\r
-\r
-                       },\r
-                       VersionDialog {\r
-                               VersionString {\r
-                                       "1.33MR"\r
-                               },\r
-                               "PCCTS was written by Terence Parr, Russe"\r
-                               "ll Quong, Will Cohen, and Hank Dietz: 19"\r
-                               "89-1998. MPW port by Scott Haney.",\r
-                               noDialog\r
-                       },\r
-                       /* [17] */\r
-                       And {\r
-                               {       /* array AndArray: 2 elements */\r
-                                       /* [1] */\r
-                                       4,\r
-                                       /* [2] */\r
-                                       6\r
-                               }\r
-                       },\r
-                       DoItButton {\r
-\r
-                       },\r
-                       /* [18] */\r
-                       NotDependent {\r
-\r
-                       },\r
-                       CheckOption {\r
-                               NotSet,\r
-                               {142, 20, 157, 148},\r
-                               "Generate ANSI C",\r
-                               "-ga",\r
-                               "When this control is checked, DLG genera"\r
-                               "tes ANSI C compatible code."\r
-                       }\r
-               }\r
-       }\r
-};\r
-\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/dlg/dlg1.txt b/Tools/CodeTools/TianoTools/Pccts/dlg/dlg1.txt
deleted file mode 100644 (file)
index 06b320d..0000000
+++ /dev/null
@@ -1,132 +0,0 @@
-\r
-\r
-\r
-dlg(1)                 PCCTS Manual Pages                  dlg(1)\r
-\r
-\r
-\r
-NAME\r
-     dlg - DFA Lexical Analyzer Generator\r
-\r
-SYNTAX\r
-     dlg [_\bo_\bp_\bt_\bi_\bo_\bn_\bs] _\bl_\be_\bx_\bi_\bc_\ba_\bl__\bs_\bp_\be_\bc [_\bo_\bu_\bt_\bp_\bu_\bt__\bf_\bi_\bl_\be]\r
-\r
-DESCRIPTION\r
-     dlg is a tool that produces fast deterministic finite auto-\r
-     mata for recognizing regular expressions in input.\r
-\r
-OPTIONS\r
-     -CC  Generate C++ output.  The _\bo_\bu_\bt_\bp_\bu_\bt__\bf_\bi_\bl_\be is not specified\r
-          in this case.\r
-\r
-     -C[ level]\r
-          Where level is the compression level used.  0 indica-\r
-          tions no compression, 1 removes all unused characters\r
-          from the transition from table, and 2 maps equivalent\r
-          characters into the same character classes.  It is sug-\r
-          gested that level -C2 is used, since it will signifi-\r
-          cantly reduce the size of the dfa produced for lexical\r
-          analyzer.\r
-\r
-     -m   Produces the header file for the lexical mode with a\r
-          name other than the default name of "mode.h".\r
-\r
-     -i   An interactive, or as interactive as possible, parser\r
-          is produced.  A character is only obtained when\r
-          required to decide which state to go to.  Some care\r
-          must be taken to obtain accept states that do not\r
-          require look ahead at the next character to determine\r
-          if that is the stop state.  Any regular expression with\r
-          a Kleene closure at the end is guaranteed to require\r
-          another character of look ahead.\r
-\r
-     -cl class\r
-          Specify a class name for DLG to generate.  The default\r
-          is DLGLexer.\r
-\r
-     -ci  The automaton will treat upper and lower case charac-\r
-          ters identically.  This is accomplished in the automa-\r
-          ton; the characters in the lexical buffer are unmodi-\r
-          fied.\r
-\r
-     -cs  Upper and lower case characters are treated as dis-\r
-          tinct.  This is the default.\r
-\r
-     -o dir\r
-          Directory where output files should go (default=".").\r
-          This is very nice for keeping the source directory\r
-          clear of ANTLR and DLG spawn.\r
-\r
-     -Wambiguity\r
-          Warns if more than one regular expression could match\r
-          the same character sequence.  The warnings give the\r
-          numbers of the expressions in the dlg lexical specifi-\r
-          cation file.  The numbering of the expressions starts\r
-          at one.  Multiple warnings may be print for the same\r
-          expressions.\r
-\r
-     -    Used in place of file names to get input from standard\r
-          in or send output to standard out.\r
-\r
-SPECIAL CONSIDERATIONS\r
-     _\bD_\bl_\bg works...  we think.  There is no implicit guarantee of\r
-     anything.  We reserve no legal rights to the software known\r
-     as the Purdue Compiler Construction Tool Set (PCCTS) - PCCTS\r
-     is in the public domain.  An individual or company may do\r
-     whatever they wish with source code distributed with PCCTS\r
-     or the code generated by PCCTS, including the incorporation\r
-     of PCCTS, or its output, into commercial software.  We\r
-     encourage users to develop software with PCCTS.  However, we\r
-     do ask that credit is given to us for developing PCCTS.  By\r
-     "credit", we mean that if you incorporate our source code\r
-     into one of your programs (commercial product, research pro-\r
-     ject, or otherwise) that you acknowledge this fact somewhere\r
-     in the documentation, research report, etc...  If you like\r
-     PCCTS and have developed a nice tool with the output, please\r
-     mention that you developed it using PCCTS.  As long as these\r
-     guidelines are followed, we expect to continue enhancing\r
-     this system and expect to make other tools available as they\r
-     are completed.\r
-\r
-FILES\r
-     mode.h , dlgauto.h , dlgdef.h\r
-\r
-SEE ALSO\r
-     antlr(1), pccts(1)\r
-\r
-BUGS\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/dlg/dlg_a.c b/Tools/CodeTools/TianoTools/Pccts/dlg/dlg_a.c
deleted file mode 100644 (file)
index 0b8982c..0000000
+++ /dev/null
@@ -1,1414 +0,0 @@
-\r
-/* parser.dlg -- DLG Description of scanner\r
- *\r
- * Generated from: dlg_p.g\r
- *\r
- * Terence Parr, Will Cohen, and Hank Dietz: 1989-2001\r
- * Purdue University Electrical Engineering\r
- * With AHPCRC, University of Minnesota\r
- * ANTLR Version 1.33MR33\r
- */\r
-\r
-#define ANTLR_VERSION  13333\r
-#include "pcctscfg.h"\r
-#include "pccts_stdio.h"\r
-\r
-#include <ctype.h>\r
-#include "dlg.h"\r
-#include "antlr.h"\r
-#include "tokens.h"\r
-#include "dlgdef.h"\r
-LOOKAHEAD\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-zzerraction(void)\r
-#else\r
-zzerraction()\r
-#endif\r
-{\r
-       (*zzerr)("invalid token");\r
-       zzadvance();\r
-       zzskip();\r
-}\r
-/*\r
- * D L G tables\r
- *\r
- * Generated from: parser.dlg\r
- *\r
- * 1989-2001 by  Will Cohen, Terence Parr, and Hank Dietz\r
- * Purdue University Electrical Engineering\r
- * DLG Version 1.33MR33\r
- */\r
-\r
-#include "mode.h"\r
-\r
-\r
-\r
-\r
-int    func_action;            /* should actions be turned into functions?*/\r
-int    lex_mode_counter = 0;   /* keeps track of the number of %%names */\r
-/* MR1                                                                     */\r
-/* MR1  11-Apr-97      Provide mechanism for inserting code into DLG class */\r
-/* MR1                         via <<%%lexmember...>>                      */\r
-/* MR1                                                                     */\r
-int    lexMember = 0;          /* <<%%lexmemeber ...>>                 MR1 */\r
-int    lexAction = 0;          /* <<%%lexaction ...>>                  MR1 */\r
-int    parserClass = 0;        /* <<%%parserclass ...>>        MR1 */\r
-int    lexPrefix = 0;          /* <<%%lexprefix ...>>                  MR1 */\r
-char   theClassName[100];                                                   /* MR11 */\r
-char   *pClassName=theClassName;                                        /* MR11 */\r
-int    firstLexMember=1;                                                    /* MR1 */\r
-\r
-#ifdef __USE_PROTOS\r
-void  xxputc(int c) {                                          /* MR1 */\r
-#else\r
-  void xxputc(c)                                                       /* MR1 */\r
-  int  c;                                                      /* MR1 */\r
-  {                                                            /* MR1 */\r
-#endif\r
-    if (parserClass) {                                         /* MR1 */\r
-      *pClassName++=c;                                         /* MR1 */\r
-      *pClassName=0;                                           /* MR1 */\r
-    } else if (lexMember || lexPrefix) {                               /* MR1 */\r
-      if (class_stream != NULL) fputc(c,class_stream);         /* MR1 */\r
-    } else {                                                   /* MR1 */\r
-      fputc(c,OUT);                                            /* MR1 */\r
-    };                                                         /* MR1 */\r
-  }                                                            /* MR1 */\r
-  \r
-#ifdef __USE_PROTOS\r
-  void xxprintf(char *format,char *string) {                   /* MR1 */\r
-#else\r
-    void xxprintf(format,string)                                       /* MR1 */\r
-    char *format;                                                      /* MR1 */\r
-    char *string;                                                      /* MR1 */\r
-    {                                                          /* MR1 */\r
-#endif\r
-      if (lexMember || lexPrefix || parserClass) {                     /* MR1 */\r
-        if (class_stream != NULL)                                      /* MR1 */\r
-        fprintf(class_stream,format,string);                   /* MR1 */\r
-      } else {                                                 /* MR1 */\r
-        fprintf(OUT,format,string);                                    /* MR1 */\r
-      };                                                               /* MR1 */\r
-    }                                                                  /* MR1 */\r
-\r
-static void act1()\r
-{ \r
-               NLA = 1;\r
-       }\r
-\r
-\r
-static void act2()\r
-{ \r
-               NLA = 2;\r
-    zzskip();   \r
-       }\r
-\r
-\r
-static void act3()\r
-{ \r
-               NLA = 3;\r
-    zzline++; zzskip(); DAWDLE;   \r
-       }\r
-\r
-\r
-static void act4()\r
-{ \r
-               NLA = L_EOF;\r
-       }\r
-\r
-\r
-static void act5()\r
-{ \r
-               NLA = PER_PER;\r
-       }\r
-\r
-\r
-static void act6()\r
-{ \r
-               NLA = NAME_PER_PER;\r
-    p_mode_def(&zzlextext[2],lex_mode_counter++);   \r
-       }\r
-\r
-\r
-static void act7()\r
-{ \r
-               NLA = LEXMEMBER;\r
-    lexMember=1;                                       /* MR1 */\r
-    if (firstLexMember != 0) {                 /* MR1 */\r
-      firstLexMember=0;                                /* MR1 */\r
-      p_class_def1();                          /* MR1 */\r
-    };                                         /* MR1 */\r
-    zzmode(ACT);                                       /* MR1 */\r
-       }\r
-\r
-\r
-static void act8()\r
-{ \r
-               NLA = LEXACTION;\r
-    lexAction=1;zzmode(ACT);  \r
-       }\r
-\r
-\r
-static void act9()\r
-{ \r
-               NLA = PARSERCLASS;\r
-    parserClass=1;                             /* MR1 */\r
-    zzmode(ACT);                                       /* MR1 */\r
-       }\r
-\r
-\r
-static void act10()\r
-{ \r
-               NLA = LEXPREFIX;\r
-    lexPrefix=1;zzmode(ACT);  \r
-       }\r
-\r
-\r
-static void act11()\r
-{ \r
-               NLA = ACTION;\r
-    if (func_action)\r
-    fprintf(OUT,"\n%s %sact%d()\n{ ",\r
-    gen_cpp?"ANTLRTokenType":"static void",\r
-    gen_cpp?ClassName("::"):"", ++action_no);\r
-    zzmode(ACT); zzskip();\r
-       }\r
-\r
-\r
-static void act12()\r
-{ \r
-               NLA = GREAT_GREAT;\r
-       }\r
-\r
-\r
-static void act13()\r
-{ \r
-               NLA = L_BRACE;\r
-       }\r
-\r
-\r
-static void act14()\r
-{ \r
-               NLA = R_BRACE;\r
-       }\r
-\r
-\r
-static void act15()\r
-{ \r
-               NLA = L_PAR;\r
-       }\r
-\r
-\r
-static void act16()\r
-{ \r
-               NLA = R_PAR;\r
-       }\r
-\r
-\r
-static void act17()\r
-{ \r
-               NLA = L_BRACK;\r
-       }\r
-\r
-\r
-static void act18()\r
-{ \r
-               NLA = R_BRACK;\r
-       }\r
-\r
-\r
-static void act19()\r
-{ \r
-               NLA = ZERO_MORE;\r
-       }\r
-\r
-\r
-static void act20()\r
-{ \r
-               NLA = ONE_MORE;\r
-       }\r
-\r
-\r
-static void act21()\r
-{ \r
-               NLA = OR;\r
-       }\r
-\r
-\r
-static void act22()\r
-{ \r
-               NLA = RANGE;\r
-       }\r
-\r
-\r
-static void act23()\r
-{ \r
-               NLA = NOT;\r
-       }\r
-\r
-\r
-static void act24()\r
-{ \r
-               NLA = OCTAL_VALUE;\r
-    {int t; sscanf(&zzlextext[1],"%o",&t); zzlextext[0] = t;}  \r
-       }\r
-\r
-\r
-static void act25()\r
-{ \r
-               NLA = HEX_VALUE;\r
-    {int t; sscanf(&zzlextext[3],"%x",&t); zzlextext[0] = t;}  \r
-       }\r
-\r
-\r
-static void act26()\r
-{ \r
-               NLA = DEC_VALUE;\r
-    {int t; sscanf(&zzlextext[1],"%d",&t); zzlextext[0] = t;}  \r
-       }\r
-\r
-\r
-static void act27()\r
-{ \r
-               NLA = TAB;\r
-    zzlextext[0] = '\t';  \r
-       }\r
-\r
-\r
-static void act28()\r
-{ \r
-               NLA = NL;\r
-    zzlextext[0] = '\n';  \r
-       }\r
-\r
-\r
-static void act29()\r
-{ \r
-               NLA = CR;\r
-    zzlextext[0] = '\r';  \r
-       }\r
-\r
-\r
-static void act30()\r
-{ \r
-               NLA = BS;\r
-    zzlextext[0] = '\b';  \r
-       }\r
-\r
-\r
-static void act31()\r
-{ \r
-               NLA = CONTINUATION;\r
-    zzline++; zzskip();  \r
-       }\r
-\r
-\r
-static void act32()\r
-{ \r
-               NLA = LIT;\r
-    zzlextext[0] = zzlextext[1];  \r
-       }\r
-\r
-\r
-static void act33()\r
-{ \r
-               NLA = REGCHAR;\r
-       }\r
-\r
-static unsigned char shift0[257] = {\r
-  0, 40, 40, 40, 40, 40, 40, 40, 40, 40, \r
-  1, 2, 40, 40, 1, 40, 40, 40, 40, 40, \r
-  40, 40, 40, 40, 40, 40, 40, 40, 40, 40, \r
-  40, 40, 40, 1, 40, 40, 40, 40, 4, 40, \r
-  40, 30, 31, 34, 35, 40, 37, 40, 40, 23, \r
-  24, 24, 24, 24, 24, 24, 24, 25, 25, 40, \r
-  40, 26, 40, 27, 40, 3, 21, 21, 21, 21, \r
-  21, 21, 22, 22, 22, 22, 22, 22, 22, 22, \r
-  22, 22, 22, 22, 22, 22, 22, 22, 22, 20, \r
-  22, 22, 32, 39, 33, 40, 22, 40, 11, 9, \r
-  12, 21, 6, 19, 22, 22, 14, 22, 22, 5, \r
-  8, 16, 15, 17, 22, 10, 18, 13, 22, 22, \r
-  22, 7, 22, 22, 28, 36, 29, 38, 40, 40, \r
-  40, 40, 40, 40, 40, 40, 40, 40, 40, 40, \r
-  40, 40, 40, 40, 40, 40, 40, 40, 40, 40, \r
-  40, 40, 40, 40, 40, 40, 40, 40, 40, 40, \r
-  40, 40, 40, 40, 40, 40, 40, 40, 40, 40, \r
-  40, 40, 40, 40, 40, 40, 40, 40, 40, 40, \r
-  40, 40, 40, 40, 40, 40, 40, 40, 40, 40, \r
-  40, 40, 40, 40, 40, 40, 40, 40, 40, 40, \r
-  40, 40, 40, 40, 40, 40, 40, 40, 40, 40, \r
-  40, 40, 40, 40, 40, 40, 40, 40, 40, 40, \r
-  40, 40, 40, 40, 40, 40, 40, 40, 40, 40, \r
-  40, 40, 40, 40, 40, 40, 40, 40, 40, 40, \r
-  40, 40, 40, 40, 40, 40, 40, 40, 40, 40, \r
-  40, 40, 40, 40, 40, 40, 40\r
-};\r
-\r
-\r
-static void act34()\r
-{ \r
-               NLA = 1;\r
-    error("unterminated action", zzline); zzmode(START);   \r
-       }\r
-\r
-\r
-static void act35()\r
-{ \r
-               NLA = ACTION;\r
-    if (func_action) fprintf(OUT,"}\n\n");\r
-    zzmode(START);\r
-    /* MR1                                                                         */\r
-    /* MR1  11-Apr-97  Provide mechanism for inserting code into DLG class */\r
-    /* MR1                             via <<%%lexmember ...>>                     */\r
-    /* MR1                     This is a consequence of not saving actions         */\r
-    /* MR1                                                                         */\r
-    /* MR1 */     parserClass=0;               \r
-    /* MR1 */     lexPrefix=0;\r
-    /* MR1 */     lexAction=0;\r
-    /* MR1 */     lexMember=0;\r
-       }\r
-\r
-\r
-static void act36()\r
-{ \r
-               NLA = 34;\r
-    xxputc(zzlextext[0]); zzskip();   \r
-       }\r
-\r
-\r
-static void act37()\r
-{ \r
-               NLA = 35;\r
-    xxputc('>'); zzskip();   \r
-       }\r
-\r
-\r
-static void act38()\r
-{ \r
-               NLA = 36;\r
-    xxputc('\\'); zzskip();   \r
-       }\r
-\r
-\r
-static void act39()\r
-{ \r
-               NLA = 37;\r
-    xxputc(zzlextext[0]); ++zzline; zzskip();   \r
-       }\r
-\r
-\r
-static void act40()\r
-{ \r
-               NLA = 38;\r
-    zzmode(ACTION_COMMENTS);                   /* MR1 */\r
-    xxprintf("%s", &(zzlextext[0])); zzskip(); /* MR1 */\r
-       }\r
-\r
-\r
-static void act41()\r
-{ \r
-               NLA = 39;\r
-    zzmode(ACTION_CPP_COMMENTS);                       /* MR1 */\r
-    xxprintf("%s", &(zzlextext[0])); zzskip(); /* MR1 */\r
-       }\r
-\r
-\r
-static void act42()\r
-{ \r
-               NLA = 40;\r
-    xxputc(zzlextext[0]); zzskip();   \r
-       }\r
-\r
-static unsigned char shift1[257] = {\r
-  0, 6, 6, 6, 6, 6, 6, 6, 6, 6, \r
-  6, 3, 6, 6, 6, 6, 6, 6, 6, 6, \r
-  6, 6, 6, 6, 6, 6, 6, 6, 6, 6, \r
-  6, 6, 6, 6, 6, 6, 6, 6, 6, 6, \r
-  6, 6, 6, 5, 6, 6, 6, 6, 4, 6, \r
-  6, 6, 6, 6, 6, 6, 6, 6, 6, 6, \r
-  6, 6, 6, 1, 6, 6, 6, 6, 6, 6, \r
-  6, 6, 6, 6, 6, 6, 6, 6, 6, 6, \r
-  6, 6, 6, 6, 6, 6, 6, 6, 6, 6, \r
-  6, 6, 6, 2, 6, 6, 6, 6, 6, 6, \r
-  6, 6, 6, 6, 6, 6, 6, 6, 6, 6, \r
-  6, 6, 6, 6, 6, 6, 6, 6, 6, 6, \r
-  6, 6, 6, 6, 6, 6, 6, 6, 6, 6, \r
-  6, 6, 6, 6, 6, 6, 6, 6, 6, 6, \r
-  6, 6, 6, 6, 6, 6, 6, 6, 6, 6, \r
-  6, 6, 6, 6, 6, 6, 6, 6, 6, 6, \r
-  6, 6, 6, 6, 6, 6, 6, 6, 6, 6, \r
-  6, 6, 6, 6, 6, 6, 6, 6, 6, 6, \r
-  6, 6, 6, 6, 6, 6, 6, 6, 6, 6, \r
-  6, 6, 6, 6, 6, 6, 6, 6, 6, 6, \r
-  6, 6, 6, 6, 6, 6, 6, 6, 6, 6, \r
-  6, 6, 6, 6, 6, 6, 6, 6, 6, 6, \r
-  6, 6, 6, 6, 6, 6, 6, 6, 6, 6, \r
-  6, 6, 6, 6, 6, 6, 6, 6, 6, 6, \r
-  6, 6, 6, 6, 6, 6, 6, 6, 6, 6, \r
-  6, 6, 6, 6, 6, 6, 6\r
-};\r
-\r
-\r
-static void act43()\r
-{ \r
-               NLA = 1;\r
-       }\r
-\r
-\r
-static void act44()\r
-{ \r
-               NLA = 41;\r
-    zzmode(ACT);                                       /* MR1 */\r
-    xxprintf("%s", &(zzlextext[0])); zzskip(); /* MR1 */\r
-       }\r
-\r
-\r
-static void act45()\r
-{ \r
-               NLA = 42;\r
-    zzline++; xxputc(zzlextext[0]); zzskip();  \r
-       }\r
-\r
-\r
-static void act46()\r
-{ \r
-               NLA = 43;\r
-    xxputc(zzlextext[0]); zzskip();  \r
-       }\r
-\r
-static unsigned char shift2[257] = {\r
-  0, 4, 4, 4, 4, 4, 4, 4, 4, 4, \r
-  4, 3, 4, 4, 3, 4, 4, 4, 4, 4, \r
-  4, 4, 4, 4, 4, 4, 4, 4, 4, 4, \r
-  4, 4, 4, 4, 4, 4, 4, 4, 4, 4, \r
-  4, 4, 4, 1, 4, 4, 4, 4, 2, 4, \r
-  4, 4, 4, 4, 4, 4, 4, 4, 4, 4, \r
-  4, 4, 4, 4, 4, 4, 4, 4, 4, 4, \r
-  4, 4, 4, 4, 4, 4, 4, 4, 4, 4, \r
-  4, 4, 4, 4, 4, 4, 4, 4, 4, 4, \r
-  4, 4, 4, 4, 4, 4, 4, 4, 4, 4, \r
-  4, 4, 4, 4, 4, 4, 4, 4, 4, 4, \r
-  4, 4, 4, 4, 4, 4, 4, 4, 4, 4, \r
-  4, 4, 4, 4, 4, 4, 4, 4, 4, 4, \r
-  4, 4, 4, 4, 4, 4, 4, 4, 4, 4, \r
-  4, 4, 4, 4, 4, 4, 4, 4, 4, 4, \r
-  4, 4, 4, 4, 4, 4, 4, 4, 4, 4, \r
-  4, 4, 4, 4, 4, 4, 4, 4, 4, 4, \r
-  4, 4, 4, 4, 4, 4, 4, 4, 4, 4, \r
-  4, 4, 4, 4, 4, 4, 4, 4, 4, 4, \r
-  4, 4, 4, 4, 4, 4, 4, 4, 4, 4, \r
-  4, 4, 4, 4, 4, 4, 4, 4, 4, 4, \r
-  4, 4, 4, 4, 4, 4, 4, 4, 4, 4, \r
-  4, 4, 4, 4, 4, 4, 4, 4, 4, 4, \r
-  4, 4, 4, 4, 4, 4, 4, 4, 4, 4, \r
-  4, 4, 4, 4, 4, 4, 4, 4, 4, 4, \r
-  4, 4, 4, 4, 4, 4, 4\r
-};\r
-\r
-\r
-static void act47()\r
-{ \r
-               NLA = 1;\r
-       }\r
-\r
-\r
-static void act48()\r
-{ \r
-               NLA = 44;\r
-    zzmode(ACT); zzline++;                     /* MR1 */\r
-    xxprintf("%s", &(zzlextext[0])); zzskip(); /* MR1 */\r
-       }\r
-\r
-\r
-static void act49()\r
-{ \r
-               NLA = 45;\r
-    xxputc(zzlextext[0]); zzskip();  \r
-       }\r
-\r
-static unsigned char shift3[257] = {\r
-  0, 2, 2, 2, 2, 2, 2, 2, 2, 2, \r
-  2, 1, 2, 2, 1, 2, 2, 2, 2, 2, \r
-  2, 2, 2, 2, 2, 2, 2, 2, 2, 2, \r
-  2, 2, 2, 2, 2, 2, 2, 2, 2, 2, \r
-  2, 2, 2, 2, 2, 2, 2, 2, 2, 2, \r
-  2, 2, 2, 2, 2, 2, 2, 2, 2, 2, \r
-  2, 2, 2, 2, 2, 2, 2, 2, 2, 2, \r
-  2, 2, 2, 2, 2, 2, 2, 2, 2, 2, \r
-  2, 2, 2, 2, 2, 2, 2, 2, 2, 2, \r
-  2, 2, 2, 2, 2, 2, 2, 2, 2, 2, \r
-  2, 2, 2, 2, 2, 2, 2, 2, 2, 2, \r
-  2, 2, 2, 2, 2, 2, 2, 2, 2, 2, \r
-  2, 2, 2, 2, 2, 2, 2, 2, 2, 2, \r
-  2, 2, 2, 2, 2, 2, 2, 2, 2, 2, \r
-  2, 2, 2, 2, 2, 2, 2, 2, 2, 2, \r
-  2, 2, 2, 2, 2, 2, 2, 2, 2, 2, \r
-  2, 2, 2, 2, 2, 2, 2, 2, 2, 2, \r
-  2, 2, 2, 2, 2, 2, 2, 2, 2, 2, \r
-  2, 2, 2, 2, 2, 2, 2, 2, 2, 2, \r
-  2, 2, 2, 2, 2, 2, 2, 2, 2, 2, \r
-  2, 2, 2, 2, 2, 2, 2, 2, 2, 2, \r
-  2, 2, 2, 2, 2, 2, 2, 2, 2, 2, \r
-  2, 2, 2, 2, 2, 2, 2, 2, 2, 2, \r
-  2, 2, 2, 2, 2, 2, 2, 2, 2, 2, \r
-  2, 2, 2, 2, 2, 2, 2, 2, 2, 2, \r
-  2, 2, 2, 2, 2, 2, 2\r
-};\r
-\r
-#define DfaStates      94\r
-typedef unsigned char DfaState;\r
-\r
-static DfaState st0[42] = {\r
-  1, 2, 3, 4, 5, 6, 6, 6, 6, 6, \r
-  6, 6, 6, 6, 6, 6, 6, 6, 6, 6, \r
-  6, 6, 6, 6, 6, 6, 7, 8, 9, 10, \r
-  11, 12, 13, 14, 15, 16, 17, 18, 19, 20, \r
-  6, 94\r
-};\r
-\r
-static DfaState st1[42] = {\r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94\r
-};\r
-\r
-static DfaState st2[42] = {\r
-  94, 21, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94\r
-};\r
-\r
-static DfaState st3[42] = {\r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94\r
-};\r
-\r
-static DfaState st4[42] = {\r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94\r
-};\r
-\r
-static DfaState st5[42] = {\r
-  94, 94, 94, 94, 22, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94\r
-};\r
-\r
-static DfaState st6[42] = {\r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94\r
-};\r
-\r
-static DfaState st7[42] = {\r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 23, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94\r
-};\r
-\r
-static DfaState st8[42] = {\r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 24, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94\r
-};\r
-\r
-static DfaState st9[42] = {\r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94\r
-};\r
-\r
-static DfaState st10[42] = {\r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94\r
-};\r
-\r
-static DfaState st11[42] = {\r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94\r
-};\r
-\r
-static DfaState st12[42] = {\r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94\r
-};\r
-\r
-static DfaState st13[42] = {\r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94\r
-};\r
-\r
-static DfaState st14[42] = {\r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94\r
-};\r
-\r
-static DfaState st15[42] = {\r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94\r
-};\r
-\r
-static DfaState st16[42] = {\r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94\r
-};\r
-\r
-static DfaState st17[42] = {\r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94\r
-};\r
-\r
-static DfaState st18[42] = {\r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94\r
-};\r
-\r
-static DfaState st19[42] = {\r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94\r
-};\r
-\r
-static DfaState st20[42] = {\r
-  94, 25, 26, 25, 25, 25, 25, 25, 25, 27, \r
-  28, 25, 25, 29, 25, 25, 30, 25, 25, 25, \r
-  25, 25, 25, 31, 32, 32, 25, 25, 25, 25, \r
-  25, 25, 25, 25, 25, 25, 25, 25, 25, 25, \r
-  25, 94\r
-};\r
-\r
-static DfaState st21[42] = {\r
-  94, 21, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94\r
-};\r
-\r
-static DfaState st22[42] = {\r
-  94, 94, 94, 94, 94, 33, 33, 33, 33, 33, \r
-  33, 33, 33, 33, 33, 33, 33, 33, 33, 33, \r
-  33, 33, 33, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94\r
-};\r
-\r
-static DfaState st23[42] = {\r
-  94, 94, 94, 94, 34, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94\r
-};\r
-\r
-static DfaState st24[42] = {\r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94\r
-};\r
-\r
-static DfaState st25[42] = {\r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94\r
-};\r
-\r
-static DfaState st26[42] = {\r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94\r
-};\r
-\r
-static DfaState st27[42] = {\r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94\r
-};\r
-\r
-static DfaState st28[42] = {\r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94\r
-};\r
-\r
-static DfaState st29[42] = {\r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94\r
-};\r
-\r
-static DfaState st30[42] = {\r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94\r
-};\r
-\r
-static DfaState st31[42] = {\r
-  94, 94, 94, 94, 94, 94, 94, 35, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  35, 94, 94, 36, 36, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94\r
-};\r
-\r
-static DfaState st32[42] = {\r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 37, 37, 37, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94\r
-};\r
-\r
-static DfaState st33[42] = {\r
-  94, 94, 94, 94, 94, 38, 38, 38, 38, 38, \r
-  38, 38, 38, 38, 38, 38, 38, 38, 38, 38, \r
-  38, 38, 38, 38, 38, 38, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94\r
-};\r
-\r
-static DfaState st34[42] = {\r
-  94, 94, 94, 94, 39, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94\r
-};\r
-\r
-static DfaState st35[42] = {\r
-  94, 94, 94, 94, 94, 94, 40, 94, 94, 40, \r
-  94, 40, 40, 94, 94, 94, 94, 94, 94, 40, \r
-  94, 40, 94, 40, 40, 40, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94\r
-};\r
-\r
-static DfaState st36[42] = {\r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 36, 36, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94\r
-};\r
-\r
-static DfaState st37[42] = {\r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 37, 37, 37, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94\r
-};\r
-\r
-static DfaState st38[42] = {\r
-  94, 94, 94, 94, 94, 38, 38, 38, 38, 38, \r
-  38, 38, 38, 38, 38, 38, 38, 38, 38, 38, \r
-  38, 38, 38, 38, 38, 38, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94\r
-};\r
-\r
-static DfaState st39[42] = {\r
-  94, 94, 94, 94, 94, 41, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 42, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94\r
-};\r
-\r
-static DfaState st40[42] = {\r
-  94, 94, 94, 94, 94, 94, 40, 94, 94, 40, \r
-  94, 40, 40, 94, 94, 94, 94, 94, 94, 40, \r
-  94, 40, 94, 40, 40, 40, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94\r
-};\r
-\r
-static DfaState st41[42] = {\r
-  94, 94, 94, 94, 94, 94, 43, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94\r
-};\r
-\r
-static DfaState st42[42] = {\r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 44, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94\r
-};\r
-\r
-static DfaState st43[42] = {\r
-  94, 94, 94, 94, 94, 94, 94, 45, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94\r
-};\r
-\r
-static DfaState st44[42] = {\r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  46, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94\r
-};\r
-\r
-static DfaState st45[42] = {\r
-  94, 94, 94, 94, 94, 94, 94, 94, 47, 94, \r
-  94, 48, 94, 94, 94, 94, 94, 49, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94\r
-};\r
-\r
-static DfaState st46[42] = {\r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 50, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94\r
-};\r
-\r
-static DfaState st47[42] = {\r
-  94, 94, 94, 94, 94, 94, 51, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94\r
-};\r
-\r
-static DfaState st48[42] = {\r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 52, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94\r
-};\r
-\r
-static DfaState st49[42] = {\r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  53, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94\r
-};\r
-\r
-static DfaState st50[42] = {\r
-  94, 94, 94, 94, 94, 94, 54, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94\r
-};\r
-\r
-static DfaState st51[42] = {\r
-  94, 94, 94, 94, 94, 94, 94, 94, 55, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94\r
-};\r
-\r
-static DfaState st52[42] = {\r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 56, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94\r
-};\r
-\r
-static DfaState st53[42] = {\r
-  94, 94, 94, 94, 94, 94, 57, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94\r
-};\r
-\r
-static DfaState st54[42] = {\r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  58, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94\r
-};\r
-\r
-static DfaState st55[42] = {\r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 59, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94\r
-};\r
-\r
-static DfaState st56[42] = {\r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 60, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94\r
-};\r
-\r
-static DfaState st57[42] = {\r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 61, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94\r
-};\r
-\r
-static DfaState st58[42] = {\r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 62, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94\r
-};\r
-\r
-static DfaState st59[42] = {\r
-  94, 94, 94, 94, 94, 94, 63, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94\r
-};\r
-\r
-static DfaState st60[42] = {\r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 64, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94\r
-};\r
-\r
-static DfaState st61[42] = {\r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 65, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94\r
-};\r
-\r
-static DfaState st62[42] = {\r
-  94, 94, 94, 94, 94, 66, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94\r
-};\r
-\r
-static DfaState st63[42] = {\r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  67, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94\r
-};\r
-\r
-static DfaState st64[42] = {\r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 68, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94\r
-};\r
-\r
-static DfaState st65[42] = {\r
-  94, 94, 94, 94, 94, 94, 94, 69, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94\r
-};\r
-\r
-static DfaState st66[42] = {\r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 70, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94\r
-};\r
-\r
-static DfaState st67[42] = {\r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94\r
-};\r
-\r
-static DfaState st68[42] = {\r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94\r
-};\r
-\r
-static DfaState st69[42] = {\r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94\r
-};\r
-\r
-static DfaState st70[42] = {\r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 71, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94\r
-};\r
-\r
-static DfaState st71[42] = {\r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 72, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94\r
-};\r
-\r
-static DfaState st72[42] = {\r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94, 94, 94, 94, 94, 94, 94, 94, 94, \r
-  94, 94\r
-};\r
-\r
-static DfaState st73[8] = {\r
-  74, 75, 76, 77, 78, 79, 79, 94\r
-};\r
-\r
-static DfaState st74[8] = {\r
-  94, 94, 94, 94, 94, 94, 94, 94\r
-};\r
-\r
-static DfaState st75[8] = {\r
-  94, 80, 94, 94, 94, 94, 94, 94\r
-};\r
-\r
-static DfaState st76[8] = {\r
-  94, 81, 94, 94, 94, 94, 94, 94\r
-};\r
-\r
-static DfaState st77[8] = {\r
-  94, 94, 94, 94, 94, 94, 94, 94\r
-};\r
-\r
-static DfaState st78[8] = {\r
-  94, 94, 94, 94, 82, 83, 94, 94\r
-};\r
-\r
-static DfaState st79[8] = {\r
-  94, 94, 94, 94, 94, 94, 94, 94\r
-};\r
-\r
-static DfaState st80[8] = {\r
-  94, 94, 94, 94, 94, 94, 94, 94\r
-};\r
-\r
-static DfaState st81[8] = {\r
-  94, 94, 94, 94, 94, 94, 94, 94\r
-};\r
-\r
-static DfaState st82[8] = {\r
-  94, 94, 94, 94, 94, 94, 94, 94\r
-};\r
-\r
-static DfaState st83[8] = {\r
-  94, 94, 94, 94, 94, 94, 94, 94\r
-};\r
-\r
-static DfaState st84[6] = {\r
-  85, 86, 87, 88, 87, 94\r
-};\r
-\r
-static DfaState st85[6] = {\r
-  94, 94, 94, 94, 94, 94\r
-};\r
-\r
-static DfaState st86[6] = {\r
-  94, 94, 89, 94, 94, 94\r
-};\r
-\r
-static DfaState st87[6] = {\r
-  94, 94, 94, 94, 94, 94\r
-};\r
-\r
-static DfaState st88[6] = {\r
-  94, 94, 94, 94, 94, 94\r
-};\r
-\r
-static DfaState st89[6] = {\r
-  94, 94, 94, 94, 94, 94\r
-};\r
-\r
-static DfaState st90[4] = {\r
-  91, 92, 93, 94\r
-};\r
-\r
-static DfaState st91[4] = {\r
-  94, 94, 94, 94\r
-};\r
-\r
-static DfaState st92[4] = {\r
-  94, 94, 94, 94\r
-};\r
-\r
-static DfaState st93[4] = {\r
-  94, 94, 94, 94\r
-};\r
-\r
-\r
-DfaState *dfa[94] = {\r
-       st0,\r
-       st1,\r
-       st2,\r
-       st3,\r
-       st4,\r
-       st5,\r
-       st6,\r
-       st7,\r
-       st8,\r
-       st9,\r
-       st10,\r
-       st11,\r
-       st12,\r
-       st13,\r
-       st14,\r
-       st15,\r
-       st16,\r
-       st17,\r
-       st18,\r
-       st19,\r
-       st20,\r
-       st21,\r
-       st22,\r
-       st23,\r
-       st24,\r
-       st25,\r
-       st26,\r
-       st27,\r
-       st28,\r
-       st29,\r
-       st30,\r
-       st31,\r
-       st32,\r
-       st33,\r
-       st34,\r
-       st35,\r
-       st36,\r
-       st37,\r
-       st38,\r
-       st39,\r
-       st40,\r
-       st41,\r
-       st42,\r
-       st43,\r
-       st44,\r
-       st45,\r
-       st46,\r
-       st47,\r
-       st48,\r
-       st49,\r
-       st50,\r
-       st51,\r
-       st52,\r
-       st53,\r
-       st54,\r
-       st55,\r
-       st56,\r
-       st57,\r
-       st58,\r
-       st59,\r
-       st60,\r
-       st61,\r
-       st62,\r
-       st63,\r
-       st64,\r
-       st65,\r
-       st66,\r
-       st67,\r
-       st68,\r
-       st69,\r
-       st70,\r
-       st71,\r
-       st72,\r
-       st73,\r
-       st74,\r
-       st75,\r
-       st76,\r
-       st77,\r
-       st78,\r
-       st79,\r
-       st80,\r
-       st81,\r
-       st82,\r
-       st83,\r
-       st84,\r
-       st85,\r
-       st86,\r
-       st87,\r
-       st88,\r
-       st89,\r
-       st90,\r
-       st91,\r
-       st92,\r
-       st93\r
-};\r
-\r
-\r
-DfaState accepts[95] = {\r
-  0, 1, 2, 3, 4, 33, 33, 33, 33, 13, \r
-  14, 15, 16, 17, 18, 19, 20, 21, 22, 23, \r
-  0, 2, 5, 11, 12, 32, 31, 30, 29, 27, \r
-  28, 24, 26, 6, 0, 0, 24, 26, 6, 0, \r
-  25, 0, 0, 0, 0, 0, 0, 0, 0, 0, \r
-  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \r
-  0, 0, 0, 0, 0, 0, 0, 7, 8, 10, \r
-  0, 0, 9, 0, 34, 36, 38, 39, 42, 42, \r
-  35, 37, 41, 40, 0, 43, 46, 46, 45, 44, \r
-  0, 47, 48, 49, 0\r
-};\r
-\r
-void (*actions[50])() = {\r
-       zzerraction,\r
-       act1,\r
-       act2,\r
-       act3,\r
-       act4,\r
-       act5,\r
-       act6,\r
-       act7,\r
-       act8,\r
-       act9,\r
-       act10,\r
-       act11,\r
-       act12,\r
-       act13,\r
-       act14,\r
-       act15,\r
-       act16,\r
-       act17,\r
-       act18,\r
-       act19,\r
-       act20,\r
-       act21,\r
-       act22,\r
-       act23,\r
-       act24,\r
-       act25,\r
-       act26,\r
-       act27,\r
-       act28,\r
-       act29,\r
-       act30,\r
-       act31,\r
-       act32,\r
-       act33,\r
-       act34,\r
-       act35,\r
-       act36,\r
-       act37,\r
-       act38,\r
-       act39,\r
-       act40,\r
-       act41,\r
-       act42,\r
-       act43,\r
-       act44,\r
-       act45,\r
-       act46,\r
-       act47,\r
-       act48,\r
-       act49\r
-};\r
-\r
-static DfaState dfa_base[] = {\r
-       0,\r
-       73,\r
-       84,\r
-       90\r
-};\r
-\r
-static unsigned char *b_class_no[] = {\r
-       shift0,\r
-       shift1,\r
-       shift2,\r
-       shift3\r
-};\r
-\r
-\r
-\r
-#define ZZSHIFT(c) (b_class_no[zzauto][1+c])\r
-#define MAX_MODE 4\r
-#include "dlgauto.h"\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/dlg/dlg_p.c b/Tools/CodeTools/TianoTools/Pccts/dlg/dlg_p.c
deleted file mode 100644 (file)
index e726ae3..0000000
+++ /dev/null
@@ -1,959 +0,0 @@
-/*\r
- * A n t l r  T r a n s l a t i o n  H e a d e r\r
- *\r
- * Terence Parr, Will Cohen, and Hank Dietz: 1989-2001\r
- * Purdue University Electrical Engineering\r
- * With AHPCRC, University of Minnesota\r
- * ANTLR Version 1.33MR33\r
- *\r
- *   ..\bin\antlr dlg_p.g -gh\r
- *\r
- */\r
-\r
-#define ANTLR_VERSION  13333\r
-#include "pcctscfg.h"\r
-#include "pccts_stdio.h"\r
-\r
-#include <ctype.h>\r
-#include "dlg.h"\r
-#define zzSET_SIZE 8\r
-#include "antlr.h"\r
-#include "tokens.h"\r
-#include "dlgdef.h"\r
-#include "mode.h"\r
-\r
-/* MR23 In order to remove calls to PURIFY use the antlr -nopurify option */\r
-\r
-#ifndef PCCTS_PURIFY\r
-#define PCCTS_PURIFY(r,s) memset((char *) &(r),'\0',(s));\r
-#endif\r
-\r
-ANTLR_INFO\r
-\r
-\r
-/* MR20 G. Hobbelt \r
-Fix for Borland C++ 4.x & 5.x compiling with ALL warnings enabled\r
-*/\r
-\r
-#ifdef __TURBOC__\r
-#pragma warn -aus  /* unused assignment of 'xxx' */\r
-#endif\r
-\r
-int    action_no = 0;     /* keep track of actions outputed */\r
-int    nfa_allocated = 0; /* keeps track of number of nfa nodes */\r
-nfa_node **nfa_array = NULL;/* root of binary tree that stores nfa array */\r
-nfa_node nfa_model_node;   /* model to initialize new nodes */\r
-set    used_chars;        /* used to label trans. arcs */\r
-set    used_classes;      /* classes or chars used to label trans. arcs */\r
-set    normal_chars;      /* mask to get rid elements that aren't used\r
-in set */\r
-int    flag_paren = FALSE;\r
-int    flag_brace = FALSE;\r
-int    mode_counter = 0;  /* keep track of number of %%names */\r
-\r
-  \r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-grammar(void)\r
-#else\r
-grammar()\r
-#endif\r
-{\r
-  zzRULE;\r
-  zzBLOCK(zztasp1);\r
-  zzMake0;\r
-  {\r
-  p_head(); p_class_hdr(); func_action = FALSE;\r
-  {\r
-    zzBLOCK(zztasp2);\r
-    zzMake0;\r
-    {\r
-    while ( (setwd1[LA(1)]&0x1) ) {\r
-      {\r
-        zzBLOCK(zztasp3);\r
-        zzMake0;\r
-        {\r
-        if ( (LA(1)==LEXACTION) ) {\r
-          zzmatch(LEXACTION); zzCONSUME;\r
-        }\r
-        else {\r
-          if ( (LA(1)==LEXMEMBER) ) {\r
-            zzmatch(LEXMEMBER); zzCONSUME;\r
-          }\r
-          else {\r
-            if ( (LA(1)==LEXPREFIX) ) {\r
-              zzmatch(LEXPREFIX); zzCONSUME;\r
-            }\r
-            else {\r
-              if ( (LA(1)==PARSERCLASS) ) {\r
-                zzmatch(PARSERCLASS); zzCONSUME;\r
-              }\r
-              else {\r
-                if ( (LA(1)==ACTION) ) {\r
-                }\r
-                else {zzFAIL(1,zzerr1,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
-              }\r
-            }\r
-          }\r
-        }\r
-        zzEXIT(zztasp3);\r
-        }\r
-      }\r
-      zzmatch(ACTION); zzCONSUME;\r
-      zzLOOP(zztasp2);\r
-    }\r
-    zzEXIT(zztasp2);\r
-    }\r
-  }\r
-  if ( gen_cpp ) p_includes();\r
-  start_states();\r
-  func_action = FALSE; p_tables(); p_tail();\r
-  {\r
-    zzBLOCK(zztasp2);\r
-    zzMake0;\r
-    {\r
-    while ( (LA(1)==ACTION) ) {\r
-      zzmatch(ACTION); zzCONSUME;\r
-      zzLOOP(zztasp2);\r
-    }\r
-    zzEXIT(zztasp2);\r
-    }\r
-  }\r
-  zzmatch(1);\r
-  if (firstLexMember != 0) p_class_def1();\r
- zzCONSUME;\r
-\r
-  zzEXIT(zztasp1);\r
-  return;\r
-fail:\r
-  zzEXIT(zztasp1);\r
-  zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);\r
-  zzresynch(setwd1, 0x2);\r
-  }\r
-}\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-start_states(void)\r
-#else\r
-start_states()\r
-#endif\r
-{\r
-  zzRULE;\r
-  zzBLOCK(zztasp1);\r
-  zzMake0;\r
-  {\r
-  {\r
-    zzBLOCK(zztasp2);\r
-    zzMake0;\r
-    {\r
-    if ( (LA(1)==PER_PER) ) {\r
-      zzmatch(PER_PER); zzCONSUME;\r
-      do_conversion();\r
-    }\r
-    else {\r
-      if ( (LA(1)==NAME_PER_PER) ) {\r
-        zzmatch(NAME_PER_PER); zzCONSUME;\r
-        do_conversion();\r
-        {\r
-          zzBLOCK(zztasp3);\r
-          zzMake0;\r
-          {\r
-          while ( (LA(1)==NAME_PER_PER) ) {\r
-            zzmatch(NAME_PER_PER); zzCONSUME;\r
-            do_conversion();\r
-            zzLOOP(zztasp3);\r
-          }\r
-          zzEXIT(zztasp3);\r
-          }\r
-        }\r
-      }\r
-      else {zzFAIL(1,zzerr2,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
-    }\r
-    zzEXIT(zztasp2);\r
-    }\r
-  }\r
-  zzmatch(PER_PER); zzCONSUME;\r
-  zzEXIT(zztasp1);\r
-  return;\r
-fail:\r
-  zzEXIT(zztasp1);\r
-  zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);\r
-  zzresynch(setwd1, 0x4);\r
-  }\r
-}\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-do_conversion(void)\r
-#else\r
-do_conversion()\r
-#endif\r
-{\r
-  zzRULE;\r
-  zzBLOCK(zztasp1);\r
-  zzMake0;\r
-  {\r
-  new_automaton_mode(); func_action = TRUE;\r
-  rule_list();\r
-  \r
-  dfa_class_nop[mode_counter] =\r
-  relabel(zzaArg(zztasp1,1 ).l,comp_level);\r
-  if (comp_level)\r
-  p_shift_table(mode_counter);\r
-  dfa_basep[mode_counter] = dfa_allocated+1;\r
-  make_dfa_model_node(dfa_class_nop[mode_counter]);\r
-  nfa_to_dfa(zzaArg(zztasp1,1 ).l);\r
-  ++mode_counter;\r
-  func_action = FALSE;\r
-#ifdef HASH_STAT\r
-  fprint_hash_stats(stderr);\r
-#endif\r
-  zzEXIT(zztasp1);\r
-  return;\r
-fail:\r
-  zzEXIT(zztasp1);\r
-  zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);\r
-  zzresynch(setwd1, 0x8);\r
-  }\r
-}\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-rule_list(void)\r
-#else\r
-rule_list()\r
-#endif\r
-{\r
-  zzRULE;\r
-  zzBLOCK(zztasp1);\r
-  zzMake0;\r
-  {\r
-  if ( (setwd1[LA(1)]&0x10) ) {\r
-    rule();\r
-    zzaRet.l=zzaArg(zztasp1,1 ).l; zzaRet.r=zzaArg(zztasp1,1 ).r;\r
-    {\r
-      zzBLOCK(zztasp2);\r
-      zzMake0;\r
-      {\r
-      while ( (setwd1[LA(1)]&0x20) ) {\r
-        rule();\r
-        {nfa_node *t1;\r
-          t1 = new_nfa_node();\r
-          (t1)->trans[0]=zzaRet.l;\r
-          (t1)->trans[1]=zzaArg(zztasp2,1 ).l;\r
-          /* all accept nodes "dead ends" */\r
-          zzaRet.l=t1; zzaRet.r=NULL;\r
-        }\r
-        zzLOOP(zztasp2);\r
-      }\r
-      zzEXIT(zztasp2);\r
-      }\r
-    }\r
-  }\r
-  else {\r
-    if ( (setwd1[LA(1)]&0x40) ) {\r
-      zzaRet.l = new_nfa_node(); zzaRet.r = NULL;\r
-      warning("no regular expressions", zzline);\r
-    }\r
-    else {zzFAIL(1,zzerr3,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
-  }\r
-  zzEXIT(zztasp1);\r
-  return;\r
-fail:\r
-  zzEXIT(zztasp1);\r
-  zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);\r
-  zzresynch(setwd1, 0x80);\r
-  }\r
-}\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-rule(void)\r
-#else\r
-rule()\r
-#endif\r
-{\r
-  zzRULE;\r
-  zzBLOCK(zztasp1);\r
-  zzMake0;\r
-  {\r
-  if ( (setwd2[LA(1)]&0x1) ) {\r
-    reg_expr();\r
-    zzmatch(ACTION);\r
-    if (zzaArg(zztasp1,1 ).r != NULL) {\r
-      zzaRet.l=zzaArg(zztasp1,1 ).l; zzaRet.r=zzaArg(zztasp1,1 ).r; (zzaArg(zztasp1,1 ).r)->accept=action_no;\r
-    }\r
- zzCONSUME;\r
-\r
-  }\r
-  else {\r
-    if ( (LA(1)==ACTION) ) {\r
-      zzmatch(ACTION);\r
-      zzaRet.l = NULL; zzaRet.r = NULL;\r
-      error("no expression for action  ", zzline);\r
- zzCONSUME;\r
-\r
-    }\r
-    else {zzFAIL(1,zzerr4,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
-  }\r
-  zzEXIT(zztasp1);\r
-  return;\r
-fail:\r
-  zzEXIT(zztasp1);\r
-  zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);\r
-  zzresynch(setwd2, 0x2);\r
-  }\r
-}\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-reg_expr(void)\r
-#else\r
-reg_expr()\r
-#endif\r
-{\r
-  zzRULE;\r
-  zzBLOCK(zztasp1);\r
-  zzMake0;\r
-  {\r
-  and_expr();\r
-  zzaRet.l=zzaArg(zztasp1,1 ).l; zzaRet.r=zzaArg(zztasp1,1 ).r;\r
-  {\r
-    zzBLOCK(zztasp2);\r
-    zzMake0;\r
-    {\r
-    while ( (LA(1)==OR) ) {\r
-      zzmatch(OR); zzCONSUME;\r
-      and_expr();\r
-      {nfa_node *t1, *t2;\r
-        t1 = new_nfa_node(); t2 = new_nfa_node();\r
-        (t1)->trans[0]=zzaRet.l;\r
-        (t1)->trans[1]=zzaArg(zztasp2,2 ).l;\r
-        /* MR23 */                if (zzaRet.r != NULL) (zzaRet.r)->trans[1]=t2;\r
-        if (zzaArg(zztasp2,2 ).r) {\r
-          (zzaArg(zztasp2,2 ).r)->trans[1]=t2;     /* MR20 */\r
-        }\r
-        zzaRet.l=t1; zzaRet.r=t2;\r
-      }\r
-      zzLOOP(zztasp2);\r
-    }\r
-    zzEXIT(zztasp2);\r
-    }\r
-  }\r
-  zzEXIT(zztasp1);\r
-  return;\r
-fail:\r
-  zzEXIT(zztasp1);\r
-  zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);\r
-  zzresynch(setwd2, 0x4);\r
-  }\r
-}\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-and_expr(void)\r
-#else\r
-and_expr()\r
-#endif\r
-{\r
-  zzRULE;\r
-  zzBLOCK(zztasp1);\r
-  zzMake0;\r
-  {\r
-  repeat_expr();\r
-  \r
-  zzaRet.l=zzaArg(zztasp1,1 ).l; zzaRet.r=zzaArg(zztasp1,1 ).r;\r
-  {\r
-    zzBLOCK(zztasp2);\r
-    zzMake0;\r
-    {\r
-    while ( (setwd2[LA(1)]&0x8) ) {\r
-      repeat_expr();\r
-      if (zzaRet.r != NULL) {\r
-        (zzaRet.r)->trans[1]=zzaArg(zztasp2,1 ).l;\r
-        zzaRet.r=zzaArg(zztasp2,1 ).r;\r
-      }\r
-      zzLOOP(zztasp2);\r
-    }\r
-    zzEXIT(zztasp2);\r
-    }\r
-  }\r
-  zzEXIT(zztasp1);\r
-  return;\r
-fail:\r
-  zzEXIT(zztasp1);\r
-  zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);\r
-  zzresynch(setwd2, 0x10);\r
-  }\r
-}\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-repeat_expr(void)\r
-#else\r
-repeat_expr()\r
-#endif\r
-{\r
-  zzRULE;\r
-  zzBLOCK(zztasp1);\r
-  zzMake0;\r
-  {\r
-  if ( (setwd2[LA(1)]&0x20) ) {\r
-    expr();\r
-    zzaRet.l=zzaArg(zztasp1,1 ).l; zzaRet.r=zzaArg(zztasp1,1 ).r;\r
-    {\r
-      zzBLOCK(zztasp2);\r
-      zzMake0;\r
-      {\r
-      if ( (LA(1)==ZERO_MORE) ) {\r
-        zzmatch(ZERO_MORE);\r
-        {      nfa_node *t1,*t2;\r
-          /* MR23 */           if (zzaRet.r != NULL) (zzaRet.r)->trans[0] = zzaRet.l;\r
-          t1 = new_nfa_node(); t2 = new_nfa_node();\r
-          t1->trans[0]=zzaRet.l;\r
-          t1->trans[1]=t2;\r
-          /* MR23 */           if (zzaRet.r != NULL) (zzaRet.r)->trans[1]=t2;\r
-          zzaRet.l=t1;zzaRet.r=t2;\r
-        }\r
- zzCONSUME;\r
-\r
-      }\r
-      else {\r
-        if ( (LA(1)==ONE_MORE) ) {\r
-          zzmatch(ONE_MORE);\r
-          if (zzaRet.r != NULL) (zzaRet.r)->trans[0] = zzaRet.l;\r
- zzCONSUME;\r
-\r
-        }\r
-        else {\r
-          if ( (setwd2[LA(1)]&0x40) ) {\r
-          }\r
-          else {zzFAIL(1,zzerr5,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
-        }\r
-      }\r
-      zzEXIT(zztasp2);\r
-      }\r
-    }\r
-  }\r
-  else {\r
-    if ( (LA(1)==ZERO_MORE) ) {\r
-      zzmatch(ZERO_MORE);\r
-      error("no expression for *", zzline);\r
- zzCONSUME;\r
-\r
-    }\r
-    else {\r
-      if ( (LA(1)==ONE_MORE) ) {\r
-        zzmatch(ONE_MORE);\r
-        error("no expression for +", zzline);\r
- zzCONSUME;\r
-\r
-      }\r
-      else {zzFAIL(1,zzerr6,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
-    }\r
-  }\r
-  zzEXIT(zztasp1);\r
-  return;\r
-fail:\r
-  zzEXIT(zztasp1);\r
-  zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);\r
-  zzresynch(setwd2, 0x80);\r
-  }\r
-}\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-expr(void)\r
-#else\r
-expr()\r
-#endif\r
-{\r
-  zzRULE;\r
-  zzBLOCK(zztasp1);\r
-  zzMake0;\r
-  {\r
-  zzaRet.l = new_nfa_node();\r
-  zzaRet.r = new_nfa_node();\r
-  if ( (LA(1)==L_BRACK) ) {\r
-    zzmatch(L_BRACK); zzCONSUME;\r
-    atom_list();\r
-    zzmatch(R_BRACK);\r
-    \r
-    /* MR23 */         if (zzaRet.l != NULL) {\r
-      (zzaRet.l)->trans[0] = zzaRet.r;\r
-      (zzaRet.l)->label = set_dup(zzaArg(zztasp1,2 ).label);\r
-      set_orin(&used_chars,(zzaRet.l)->label);\r
-    }\r
- zzCONSUME;\r
-\r
-  }\r
-  else {\r
-    if ( (LA(1)==NOT) ) {\r
-      zzmatch(NOT); zzCONSUME;\r
-      zzmatch(L_BRACK); zzCONSUME;\r
-      atom_list();\r
-      zzmatch(R_BRACK);\r
-      \r
-      /* MR23 */               if (zzaRet.l != NULL) {\r
-        (zzaRet.l)->trans[0] = zzaRet.r;\r
-        (zzaRet.l)->label = set_dif(normal_chars,zzaArg(zztasp1,3 ).label);\r
-        set_orin(&used_chars,(zzaRet.l)->label);\r
-      }\r
- zzCONSUME;\r
-\r
-    }\r
-    else {\r
-      if ( (LA(1)==L_PAR) ) {\r
-        zzmatch(L_PAR); zzCONSUME;\r
-        reg_expr();\r
-        zzmatch(R_PAR);\r
-        \r
-        /* MR23 */             if (zzaRet.l != NULL) {                         \r
-          (zzaRet.l)->trans[0] = zzaArg(zztasp1,2 ).l;\r
-          if (zzaArg(zztasp1,2 ).r) {\r
-            (zzaArg(zztasp1,2 ).r)->trans[1] = zzaRet.r;    /* MR20 */\r
-          }\r
-        }\r
- zzCONSUME;\r
-\r
-      }\r
-      else {\r
-        if ( (LA(1)==L_BRACE) ) {\r
-          zzmatch(L_BRACE); zzCONSUME;\r
-          reg_expr();\r
-          zzmatch(R_BRACE);\r
-          \r
-          /* MR23 */           if (zzaRet.l != NULL) {\r
-            (zzaRet.l)->trans[0] = zzaArg(zztasp1,2 ).l;\r
-            (zzaRet.l)->trans[1] = zzaRet.r;\r
-            if (zzaArg(zztasp1,2 ).r) {\r
-              (zzaArg(zztasp1,2 ).r)->trans[1] = zzaRet.r;    /* MR20 */\r
-            }\r
-          }\r
- zzCONSUME;\r
-\r
-        }\r
-        else {\r
-          if ( (setwd3[LA(1)]&0x1) ) {\r
-            atom();\r
-            \r
-            /* MR23 */         if (zzaRet.l != NULL) {\r
-              (zzaRet.l)->trans[0] = zzaRet.r;\r
-              (zzaRet.l)->label = set_dup(zzaArg(zztasp1,1 ).label);\r
-              set_orin(&used_chars,(zzaRet.l)->label);\r
-            }\r
-          }\r
-          else {zzFAIL(1,zzerr7,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
-        }\r
-      }\r
-    }\r
-  }\r
-  zzEXIT(zztasp1);\r
-  return;\r
-fail:\r
-  zzEXIT(zztasp1);\r
-  zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);\r
-  zzresynch(setwd3, 0x2);\r
-  }\r
-}\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-atom_list(void)\r
-#else\r
-atom_list()\r
-#endif\r
-{\r
-  zzRULE;\r
-  zzBLOCK(zztasp1);\r
-  zzMake0;\r
-  {\r
-  set_free(zzaRet.label);\r
-  {\r
-    zzBLOCK(zztasp2);\r
-    zzMake0;\r
-    {\r
-    while ( (setwd3[LA(1)]&0x4) ) {\r
-      near_atom();\r
-      set_orin(&(zzaRet.label),zzaArg(zztasp2,1 ).label);\r
-      zzLOOP(zztasp2);\r
-    }\r
-    zzEXIT(zztasp2);\r
-    }\r
-  }\r
-  zzEXIT(zztasp1);\r
-  return;\r
-fail:\r
-  zzEXIT(zztasp1);\r
-  zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);\r
-  zzresynch(setwd3, 0x8);\r
-  }\r
-}\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-near_atom(void)\r
-#else\r
-near_atom()\r
-#endif\r
-{\r
-  zzRULE;\r
-  zzBLOCK(zztasp1);\r
-  zzMake0;\r
-  {\r
-  register int i;\r
-  register int i_prime;\r
-  anychar();\r
-  zzaRet.letter=zzaArg(zztasp1,1 ).letter; zzaRet.label=set_of(zzaArg(zztasp1,1 ).letter);\r
-  i_prime = zzaArg(zztasp1,1 ).letter + MIN_CHAR;\r
-  if (case_insensitive && islower(i_prime))\r
-  set_orel(toupper(i_prime)-MIN_CHAR,\r
-  &(zzaRet.label));\r
-  if (case_insensitive && isupper(i_prime))\r
-  set_orel(tolower(i_prime)-MIN_CHAR,\r
-  &(zzaRet.label));\r
-  {\r
-    zzBLOCK(zztasp2);\r
-    zzMake0;\r
-    {\r
-    if ( (LA(1)==RANGE) ) {\r
-      zzmatch(RANGE); zzCONSUME;\r
-      anychar();\r
-      if (case_insensitive){\r
-        i_prime = zzaRet.letter+MIN_CHAR;\r
-        zzaRet.letter = (islower(i_prime) ?\r
-        toupper(i_prime) : i_prime)-MIN_CHAR;\r
-        i_prime = zzaArg(zztasp2,2 ).letter+MIN_CHAR;\r
-        zzaArg(zztasp2,2 ).letter = (islower(i_prime) ?\r
-        toupper(i_prime) : i_prime)-MIN_CHAR;\r
-      }\r
-      /* check to see if range okay */\r
-      {\r
-        int debugLetter1 = zzaRet.letter;\r
-        int debugLetter2 = zzaArg(zztasp2,2 ).letter;\r
-      }\r
-      if (zzaRet.letter > zzaArg(zztasp2,2 ).letter \r
-      && zzaArg(zztasp2,2 ).letter != 0xff){       /* MR16 */\r
-        error("invalid range  ", zzline);\r
-      }\r
-      for (i=zzaRet.letter; i<= (int)zzaArg(zztasp2,2 ).letter; ++i){\r
-        set_orel(i,&(zzaRet.label));\r
-        i_prime = i+MIN_CHAR;\r
-        if (case_insensitive && islower(i_prime))\r
-        set_orel(toupper(i_prime)-MIN_CHAR,\r
-        &(zzaRet.label));\r
-        if (case_insensitive && isupper(i_prime))\r
-        set_orel(tolower(i_prime)-MIN_CHAR,\r
-        &(zzaRet.label));\r
-      }\r
-    }\r
-    else {\r
-      if ( (setwd3[LA(1)]&0x10) ) {\r
-      }\r
-      else {zzFAIL(1,zzerr8,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
-    }\r
-    zzEXIT(zztasp2);\r
-    }\r
-  }\r
-  zzEXIT(zztasp1);\r
-  return;\r
-fail:\r
-  zzEXIT(zztasp1);\r
-  zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);\r
-  zzresynch(setwd3, 0x20);\r
-  }\r
-}\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-atom(void)\r
-#else\r
-atom()\r
-#endif\r
-{\r
-  zzRULE;\r
-  zzBLOCK(zztasp1);\r
-  zzMake0;\r
-  {\r
-  register int i_prime;\r
-  anychar();\r
-  zzaRet.label = set_of(zzaArg(zztasp1,1 ).letter);\r
-  i_prime = zzaArg(zztasp1,1 ).letter + MIN_CHAR;\r
-  if (case_insensitive && islower(i_prime))\r
-  set_orel(toupper(i_prime)-MIN_CHAR,\r
-  &(zzaRet.label));\r
-  if (case_insensitive && isupper(i_prime))\r
-  set_orel(tolower(i_prime)-MIN_CHAR,\r
-  &(zzaRet.label));\r
-  zzEXIT(zztasp1);\r
-  return;\r
-fail:\r
-  zzEXIT(zztasp1);\r
-  zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);\r
-  zzresynch(setwd3, 0x40);\r
-  }\r
-}\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-anychar(void)\r
-#else\r
-anychar()\r
-#endif\r
-{\r
-  zzRULE;\r
-  zzBLOCK(zztasp1);\r
-  zzMake0;\r
-  {\r
-  if ( (LA(1)==REGCHAR) ) {\r
-    zzmatch(REGCHAR);\r
-    zzaRet.letter = zzaArg(zztasp1,1 ).letter - MIN_CHAR;\r
- zzCONSUME;\r
-\r
-  }\r
-  else {\r
-    if ( (LA(1)==OCTAL_VALUE) ) {\r
-      zzmatch(OCTAL_VALUE);\r
-      zzaRet.letter = zzaArg(zztasp1,1 ).letter - MIN_CHAR;\r
- zzCONSUME;\r
-\r
-    }\r
-    else {\r
-      if ( (LA(1)==HEX_VALUE) ) {\r
-        zzmatch(HEX_VALUE);\r
-        zzaRet.letter = zzaArg(zztasp1,1 ).letter - MIN_CHAR;\r
- zzCONSUME;\r
-\r
-      }\r
-      else {\r
-        if ( (LA(1)==DEC_VALUE) ) {\r
-          zzmatch(DEC_VALUE);\r
-          zzaRet.letter = zzaArg(zztasp1,1 ).letter - MIN_CHAR;\r
- zzCONSUME;\r
-\r
-        }\r
-        else {\r
-          if ( (LA(1)==TAB) ) {\r
-            zzmatch(TAB);\r
-            zzaRet.letter = zzaArg(zztasp1,1 ).letter - MIN_CHAR;\r
- zzCONSUME;\r
-\r
-          }\r
-          else {\r
-            if ( (LA(1)==NL) ) {\r
-              zzmatch(NL);\r
-              zzaRet.letter = zzaArg(zztasp1,1 ).letter - MIN_CHAR;\r
- zzCONSUME;\r
-\r
-            }\r
-            else {\r
-              if ( (LA(1)==CR) ) {\r
-                zzmatch(CR);\r
-                zzaRet.letter = zzaArg(zztasp1,1 ).letter - MIN_CHAR;\r
- zzCONSUME;\r
-\r
-              }\r
-              else {\r
-                if ( (LA(1)==BS) ) {\r
-                  zzmatch(BS);\r
-                  zzaRet.letter = zzaArg(zztasp1,1 ).letter - MIN_CHAR;\r
- zzCONSUME;\r
-\r
-                }\r
-                else {\r
-                  if ( (LA(1)==LIT) ) {\r
-                    zzmatch(LIT);\r
-                    zzaRet.letter = zzaArg(zztasp1,1 ).letter - MIN_CHAR;\r
- zzCONSUME;\r
-\r
-                  }\r
-                  else {\r
-                    if ( (LA(1)==L_EOF) ) {\r
-                      zzmatch(L_EOF);\r
-                      zzaRet.letter = 0;\r
- zzCONSUME;\r
-\r
-                    }\r
-                    else {zzFAIL(1,zzerr9,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}\r
-                  }\r
-                }\r
-              }\r
-            }\r
-          }\r
-        }\r
-      }\r
-    }\r
-  }\r
-  zzEXIT(zztasp1);\r
-  return;\r
-fail:\r
-  zzEXIT(zztasp1);\r
-  /* empty action */  \r
-  zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);\r
-  zzresynch(setwd3, 0x80);\r
-  }\r
-}\r
-\r
-/* adds a new nfa to the binary tree and returns a pointer to it */\r
-nfa_node *\r
-#ifdef __USE_PROTOS\r
-new_nfa_node(void)\r
-#else\r
-new_nfa_node()\r
-#endif\r
-{\r
-  register nfa_node *t;\r
-  static int nfa_size=0;       /* elements nfa_array[] can hold */\r
-  \r
-       ++nfa_allocated;\r
-  if (nfa_size<=nfa_allocated){\r
-    /* need to redo array */\r
-    if (!nfa_array){\r
-      /* need some to do inital allocation */\r
-      nfa_size=nfa_allocated+NFA_MIN;\r
-      nfa_array=(nfa_node **) malloc(sizeof(nfa_node*)*\r
-      nfa_size);\r
-    }else{\r
-      /* need more space */\r
-      nfa_size=2*(nfa_allocated+1);\r
-      nfa_array=(nfa_node **) realloc(nfa_array,\r
-      sizeof(nfa_node*)*nfa_size);\r
-    }\r
-  }\r
-  /* fill out entry in array */\r
-  t = (nfa_node*) malloc(sizeof(nfa_node));\r
-  nfa_array[nfa_allocated] = t;\r
-  *t = nfa_model_node;\r
-  t->node_no = nfa_allocated;\r
-  return t;\r
-}\r
-\r
-\r
-/* initialize the model node used to fill in newly made nfa_nodes */\r
-void\r
-#ifdef __USE_PROTOS\r
-make_nfa_model_node(void)\r
-#else\r
-make_nfa_model_node()\r
-#endif\r
-{\r
-  nfa_model_node.node_no = -1; /* impossible value for real nfa node */\r
-  nfa_model_node.nfa_set = 0;\r
-  nfa_model_node.accept = 0;   /* error state default*/\r
-  nfa_model_node.trans[0] = NULL;\r
-  nfa_model_node.trans[1] = NULL;\r
-  nfa_model_node.label = empty;\r
-}\r
-\r
-#if defined(DEBUG) || defined(_DEBUG)\r
-\r
-/* print out the pointer value and the node_number */\r
-void\r
-#ifdef __USE_PROTOS\r
-fprint_dfa_pair(FILE *f, nfa_node *p)\r
-#else\r
-fprint_dfa_pair(f, p)\r
-FILE *f;\r
-nfa_node *p;\r
-#endif\r
-{\r
-  if (p){\r
-    fprintf(f, "%x (%d)", p, p->node_no);\r
-  }else{\r
-    fprintf(f, "(nil)");\r
-  }\r
-}\r
-\r
-/* print out interest information on a set */\r
-void\r
-#ifdef __USE_PROTOS\r
-fprint_set(FILE *f, set s)\r
-#else\r
-fprint_set(f,s)\r
-FILE *f;\r
-set s;\r
-#endif\r
-{\r
-  unsigned int *x;\r
-  \r
-       fprintf(f, "n = %d,", s.n);\r
-  if (s.setword){\r
-    fprintf(f, "setword = %x,   ", s.setword);\r
-    /* print out all the elements in the set */\r
-    x = set_pdq(s);\r
-    while (*x!=nil){\r
-      fprintf(f, "%d ", *x);\r
-      ++x;\r
-    }\r
-  }else{\r
-    fprintf(f, "setword = (nil)");\r
-  }\r
-}\r
-\r
-/* code to be able to dump out the nfas\r
-return 0 if okay dump\r
-return 1 if screwed up\r
-*/\r
-int\r
-#ifdef __USE_PROTOS\r
-dump_nfas(int first_node, int last_node)\r
-#else\r
-dump_nfas(first_node, last_node)\r
-int first_node;\r
-int last_node;\r
-#endif\r
-{\r
-  register int i;\r
-  nfa_node *t;\r
-  \r
-       for (i=first_node; i<=last_node; ++i){\r
-    t = NFA(i);\r
-    if (!t) break;\r
-    fprintf(stderr, "nfa_node %d {\n", t->node_no);\r
-    fprintf(stderr, "\n\tnfa_set = %d\n", t->nfa_set);\r
-    fprintf(stderr, "\taccept\t=\t%d\n", t->accept);\r
-    fprintf(stderr, "\ttrans\t=\t(");\r
-    fprint_dfa_pair(stderr, t->trans[0]);\r
-    fprintf(stderr, ",");\r
-    fprint_dfa_pair(stderr, t->trans[1]);\r
-    fprintf(stderr, ")\n");\r
-    fprintf(stderr, "\tlabel\t=\t{ ");\r
-    fprint_set(stderr, t->label);\r
-    fprintf(stderr, "\t}\n");\r
-    fprintf(stderr, "}\n\n");\r
-  }\r
-  return 0;\r
-}\r
-#endif\r
-\r
-/* DLG-specific syntax error message generator\r
-* (define USER_ZZSYN when compiling so don't get 2 definitions)\r
-*/\r
-void\r
-#ifdef __USE_PROTOS\r
-zzsyn(char *text, int tok, char *egroup, SetWordType *eset, int etok, int k, char *bad_text)\r
-#else\r
-zzsyn(text, tok, egroup, eset, etok, k, bad_text)\r
-char *text, *egroup, *bad_text;\r
-int tok;\r
-int etok;\r
-int k;\r
-SetWordType *eset;\r
-#endif\r
-{\r
-fprintf(stderr, ErrHdr, file_str[0]!=NULL?file_str[0]:"stdin", zzline);\r
-fprintf(stderr, " syntax error at \"%s\"", (tok==zzEOF_TOKEN)?"EOF":text);\r
-if ( !etok && !eset ) {fprintf(stderr, "\n"); return;}\r
-if ( k==1 ) fprintf(stderr, " missing");\r
-else\r
-{\r
-fprintf(stderr, "; \"%s\" not", bad_text);\r
-if ( zzset_deg(eset)>1 ) fprintf(stderr, " in");\r
-}\r
-if ( zzset_deg(eset)>0 ) zzedecode(eset);\r
-else fprintf(stderr, " %s", zztokens[etok]);\r
-if ( strlen(egroup) > (size_t)0 ) fprintf(stderr, " in %s", egroup);\r
-fprintf(stderr, "\n");\r
-}\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/dlg/dlg_p.g b/Tools/CodeTools/TianoTools/Pccts/dlg/dlg_p.g
deleted file mode 100644 (file)
index 58ca110..0000000
+++ /dev/null
@@ -1,614 +0,0 @@
-/*  This is the parser for the dlg\r
- *  This is a part of the Purdue Compiler Construction Tool Set\r
- *\r
- * SOFTWARE RIGHTS\r
- *\r
- * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
- * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
- * company may do whatever they wish with source code distributed with\r
- * PCCTS or the code generated by PCCTS, including the incorporation of\r
- * PCCTS, or its output, into commerical software.\r
- *\r
- * We encourage users to develop software with PCCTS.  However, we do ask\r
- * that credit is given to us for developing PCCTS.  By "credit",\r
- * we mean that if you incorporate our source code into one of your\r
- * programs (commercial product, research project, or otherwise) that you\r
- * acknowledge this fact somewhere in the documentation, research report,\r
- * etc...  If you like PCCTS and have developed a nice tool with the\r
- * output, please mention that you developed it using PCCTS.  In\r
- * addition, we ask that this header remain intact in our source code.\r
- * As long as these guidelines are kept, we expect to continue enhancing\r
- * this system and expect to make other tools available as they are\r
- * completed.\r
- *\r
- * DLG 1.33\r
- * Will Cohen\r
- * With mods by Terence Parr; AHPCRC, University of Minnesota\r
- * 1989-1995\r
- */\r
-\r
-#header        <<\r
-#include <ctype.h>\r
-#include "dlg.h"\r
->>\r
-\r
-<<\r
-\r
-/* MR20 G. Hobbelt \r
-   Fix for Borland C++ 4.x & 5.x compiling with ALL warnings enabled\r
-*/\r
-\r
-#ifdef __TURBOC__\r
-#pragma warn -aus  /* unused assignment of 'xxx' */\r
-#endif\r
-\r
-int    action_no = 0;     /* keep track of actions outputed */\r
-int    nfa_allocated = 0; /* keeps track of number of nfa nodes */\r
-nfa_node **nfa_array = NULL;/* root of binary tree that stores nfa array */\r
-nfa_node nfa_model_node;   /* model to initialize new nodes */\r
-set    used_chars;        /* used to label trans. arcs */\r
-set    used_classes;      /* classes or chars used to label trans. arcs */\r
-set    normal_chars;      /* mask to get rid elements that aren't used\r
-                             in set */\r
-int    flag_paren = FALSE;\r
-int    flag_brace = FALSE;\r
-int    mode_counter = 0;  /* keep track of number of %%names */\r
-\r
->>\r
-\r
-#lexaction <<\r
-int    func_action;            /* should actions be turned into functions?*/\r
-int    lex_mode_counter = 0;   /* keeps track of the number of %%names */\r
-/* MR1                                                                     */\r
-/* MR1  11-Apr-97      Provide mechanism for inserting code into DLG class */\r
-/* MR1                         via <<%%lexmember...>>                      */\r
-/* MR1                                                                     */\r
-int    lexMember = 0;          /* <<%%lexmemeber ...>>                 MR1 */\r
-int    lexAction = 0;          /* <<%%lexaction ...>>                  MR1 */\r
-int    parserClass = 0;        /* <<%%parserclass ...>>        MR1 */\r
-int    lexPrefix = 0;          /* <<%%lexprefix ...>>                  MR1 */\r
-char   theClassName[100];                                                   /* MR11 */\r
-char   *pClassName=theClassName;                                        /* MR11 */\r
-int    firstLexMember=1;                                                    /* MR1 */\r
-\r
-#ifdef __USE_PROTOS\r
-void  xxputc(int c) {                                          /* MR1 */\r
-#else\r
-void xxputc(c)                                                 /* MR1 */\r
-  int  c;                                                      /* MR1 */\r
-{                                                              /* MR1 */\r
-#endif\r
-  if (parserClass) {                                           /* MR1 */\r
-    *pClassName++=c;                                           /* MR1 */\r
-    *pClassName=0;                                             /* MR1 */\r
-  } else if (lexMember || lexPrefix) {                         /* MR1 */\r
-    if (class_stream != NULL) fputc(c,class_stream);           /* MR1 */\r
-  } else {                                                     /* MR1 */\r
-    fputc(c,OUT);                                              /* MR1 */\r
-  };                                                           /* MR1 */\r
-}                                                              /* MR1 */\r
-\r
-#ifdef __USE_PROTOS\r
-void xxprintf(char *format,char *string) {                     /* MR1 */\r
-#else\r
-void xxprintf(format,string)                                   /* MR1 */\r
-  char *format;                                                        /* MR1 */\r
-  char *string;                                                        /* MR1 */\r
-{                                                              /* MR1 */\r
-#endif\r
-  if (lexMember || lexPrefix || parserClass) {                 /* MR1 */\r
-    if (class_stream != NULL)                                  /* MR1 */\r
-        fprintf(class_stream,format,string);                   /* MR1 */\r
-  } else {                                                     /* MR1 */\r
-    fprintf(OUT,format,string);                                        /* MR1 */\r
-  };                                                           /* MR1 */\r
-}                                                              /* MR1 */\r
->>\r
-\r
-#token "[\r\t\ ]+"     << zzskip(); >>                                         /* Ignore white */\r
-#token "\n"                    << zzline++; zzskip(); DAWDLE; >>       /* Track Line # */\r
-#token L_EOF           "\@"\r
-#token PER_PER         "\%\%"\r
-#token NAME_PER_PER    "\%\%[a-zA-Z_][a-zA-Z0-9_]*"\r
-               << p_mode_def(&zzlextext[2],lex_mode_counter++); >>\r
-\r
-#token LEXMEMBER       "\<\<\%\%lexmember"                     /* MR1 */\r
-               <<lexMember=1;                                  /* MR1 */\r
-                 if (firstLexMember != 0) {                    /* MR1 */\r
-                   firstLexMember=0;                           /* MR1 */\r
-                   p_class_def1();                             /* MR1 */\r
-                 };                                            /* MR1 */\r
-                 zzmode(ACT);                                  /* MR1 */\r
-                >>                                             /* MR1 */\r
-#token LEXACTION       "\<\<\%\%lexaction"                     /* MR1 */\r
-               <<lexAction=1;zzmode(ACT);>>                    /* MR1 */\r
-#token PARSERCLASS     "\<\<\%\%parserclass"                   /* MR1 */\r
-               <<parserClass=1;                                /* MR1 */\r
-                 zzmode(ACT);                                  /* MR1 */\r
-               >>                                              /* MR1 */\r
-#token LEXPREFIX       "\<\<\%\%lexprefix"                     /* MR1 */\r
-               <<lexPrefix=1;zzmode(ACT);>>                    /* MR1 */\r
-\r
-#token ACTION          "\<\<"\r
-               << if (func_action)\r
-                       fprintf(OUT,"\n%s %sact%d()\n{ ",\r
-                                       gen_cpp?"ANTLRTokenType":"static void",\r
-                                       gen_cpp?ClassName("::"):"", ++action_no);\r
-                  zzmode(ACT); zzskip();\r
-               >>\r
-#token GREAT_GREAT     "\>\>"\r
-#token L_BRACE         "\{"\r
-#token R_BRACE         "\}"\r
-#token L_PAR           "\("\r
-#token R_PAR           "\)"\r
-#token L_BRACK         "\["\r
-#token R_BRACK         "\]"\r
-#token ZERO_MORE       "\*"\r
-#token ONE_MORE                "\+"\r
-#token OR              "\|"\r
-#token RANGE           "\-"\r
-#token NOT             "\~"\r
-#token OCTAL_VALUE "\\0[0-7]*"         \r
-       << {int t; sscanf(&zzlextext[1],"%o",&t); zzlextext[0] = t;}>>\r
-#token HEX_VALUE   "\\0[Xx][0-9a-fA-F]+"\r
-       << {int t; sscanf(&zzlextext[3],"%x",&t); zzlextext[0] = t;}>>\r
-#token DEC_VALUE   "\\[1-9][0-9]*"\r
-       << {int t; sscanf(&zzlextext[1],"%d",&t); zzlextext[0] = t;}>>\r
-#token TAB             "\\t"           << zzlextext[0] = '\t';>>\r
-#token NL              "\\n"           << zzlextext[0] = '\n';>>\r
-#token CR              "\\r"           << zzlextext[0] = '\r';>>\r
-#token BS              "\\b"           << zzlextext[0] = '\b';>>\r
-\r
-/* MR1                                                                 */\r
-/* MR1 10-Apr-97 MR1   Allow #token regular expressions to cross lines */\r
-/* MR1                                                                 */\r
-#token CONTINUATION    "\\ \n"         << zzline++; zzskip();>> /* MR1 */\r
-\r
-/* NOTE: this takes ANYTHING after the \ */\r
-#token LIT             "\\~[tnrb]"     << zzlextext[0] = zzlextext[1];>>\r
-\r
-/* NOTE: this takes ANYTHING that doesn't match the other tokens */\r
-#token REGCHAR         "~[\\]"\r
-\r
-\r
-grammar                :   << p_head(); p_class_hdr(); func_action = FALSE;>>\r
-                ( {LEXACTION | LEXMEMBER | LEXPREFIX | PARSERCLASS } ACTION)* /* MR1 */\r
-                   <<if ( gen_cpp ) p_includes();>>\r
-                   start_states\r
-                   << func_action = FALSE; p_tables(); p_tail(); >>\r
-                   (ACTION)* "@"\r
-                       << if (firstLexMember != 0) p_class_def1(); >>          /* MR1 */\r
-               ;\r
-\r
-start_states   : ( PER_PER do_conversion\r
-                 | NAME_PER_PER do_conversion (NAME_PER_PER do_conversion)*)\r
-                   PER_PER\r
-               ;\r
-\r
-do_conversion  : <<new_automaton_mode(); func_action = TRUE;>>\r
-                       rule_list\r
-                       <<\r
-                               dfa_class_nop[mode_counter] =\r
-                                       relabel($1.l,comp_level);\r
-                               if (comp_level)\r
-                                       p_shift_table(mode_counter);\r
-                               dfa_basep[mode_counter] = dfa_allocated+1;\r
-                               make_dfa_model_node(dfa_class_nop[mode_counter]);\r
-                               nfa_to_dfa($1.l);\r
-                               ++mode_counter;\r
-                               func_action = FALSE;\r
-#ifdef HASH_STAT\r
-                               fprint_hash_stats(stderr);\r
-#endif\r
-                       >>\r
-               ;\r
-\r
-rule_list      : rule <<$$.l=$1.l; $$.r=$1.r;>>\r
-                       (rule\r
-                               <<{nfa_node *t1;\r
-                                  t1 = new_nfa_node();\r
-                                  (t1)->trans[0]=$$.l;\r
-                                  (t1)->trans[1]=$1.l;\r
-                                  /* all accept nodes "dead ends" */\r
-                                  $$.l=t1; $$.r=NULL;\r
-                                  }\r
-                               >>\r
-                       )*\r
-               | /* empty */\r
-                       <<$$.l = new_nfa_node(); $$.r = NULL;\r
-                          warning("no regular expressions", zzline);\r
-                       >>\r
-               ;\r
-\r
-rule   : reg_expr ACTION\r
-/* MR23 */             << if ($1.r != NULL) {\r
-                                       $$.l=$1.l; $$.r=$1.r; ($1.r)->accept=action_no;\r
-                                  }\r
-                               >>\r
-               | ACTION\r
-                       <<$$.l = NULL; $$.r = NULL;\r
-                         error("no expression for action  ", zzline);\r
-                       >>\r
-               ;\r
-\r
-reg_expr       : and_expr <<$$.l=$1.l; $$.r=$1.r;>>\r
-                       (OR and_expr\r
-                               <<{nfa_node *t1, *t2;\r
-                                  t1 = new_nfa_node(); t2 = new_nfa_node();\r
-                                  (t1)->trans[0]=$$.l;\r
-                                  (t1)->trans[1]=$2.l;\r
-/* MR23 */                if ($$.r != NULL) ($$.r)->trans[1]=t2;\r
-                   if ($2.r) {\r
-                                  ($2.r)->trans[1]=t2;     /* MR20 */\r
-                   }\r
-                                  $$.l=t1; $$.r=t2;\r
-                                 }\r
-                               >>\r
-                       )*\r
-               ;\r
-\r
-and_expr       : repeat_expr\r
-                                       <<\r
-                                               $$.l=$1.l; $$.r=$1.r;\r
-                                   >>\r
-                       (repeat_expr \r
-/* MR23 */                             << if ($$.r != NULL) {\r
-                                                       ($$.r)->trans[1]=$1.l;\r
-                                                       $$.r=$1.r;\r
-                                                  }\r
-                                               >>\r
-                       )*\r
-               ;\r
-\r
-repeat_expr    : expr <<$$.l=$1.l; $$.r=$1.r;>>\r
-                       { ZERO_MORE\r
-                       <<{     nfa_node *t1,*t2;\r
-/* MR23 */             if ($$.r != NULL) ($$.r)->trans[0] = $$.l;\r
-                               t1 = new_nfa_node(); t2 = new_nfa_node();\r
-                               t1->trans[0]=$$.l;\r
-                               t1->trans[1]=t2;\r
-/* MR23 */             if ($$.r != NULL) ($$.r)->trans[1]=t2;\r
-                               $$.l=t1;$$.r=t2;\r
-                         }\r
-                       >>\r
-                       | ONE_MORE\r
-/* MR23 */             <<if ($$.r != NULL) ($$.r)->trans[0] = $$.l;>>\r
-                       }\r
-               | ZERO_MORE\r
-                       << error("no expression for *", zzline);>>\r
-               | ONE_MORE\r
-                       << error("no expression for +", zzline);>>\r
-               ;\r
-\r
-expr   : << $$.l = new_nfa_node();\r
-                        $$.r = new_nfa_node();\r
-                 >>\r
-                 L_BRACK atom_list R_BRACK\r
-                       <<\r
-/* MR23 */             if ($$.l != NULL) {\r
-                                       ($$.l)->trans[0] = $$.r;\r
-                                       ($$.l)->label = set_dup($2.label);\r
-                                       set_orin(&used_chars,($$.l)->label);\r
-                               }\r
-                       >>\r
-               | NOT L_BRACK atom_list R_BRACK\r
-                       <<\r
-/* MR23 */             if ($$.l != NULL) {\r
-                                       ($$.l)->trans[0] = $$.r;\r
-                                       ($$.l)->label = set_dif(normal_chars,$3.label);\r
-                                       set_orin(&used_chars,($$.l)->label);\r
-                               }\r
-                       >>\r
-               | L_PAR reg_expr R_PAR\r
-                       <<\r
-/* MR23 */             if ($$.l != NULL) {                             \r
-                                       ($$.l)->trans[0] = $2.l;\r
-                                       if ($2.r) {\r
-                                       ($2.r)->trans[1] = $$.r;    /* MR20 */\r
-                                       }\r
-                               }\r
-                       >>\r
-               | L_BRACE reg_expr R_BRACE\r
-                       <<\r
-/* MR23 */             if ($$.l != NULL) {\r
-                                       ($$.l)->trans[0] = $2.l;\r
-                                       ($$.l)->trans[1] = $$.r;\r
-                               if ($2.r) {\r
-                                       ($2.r)->trans[1] = $$.r;    /* MR20 */\r
-                                       }\r
-                               }\r
-                       >>\r
-               | atom\r
-                       <<\r
-/* MR23 */             if ($$.l != NULL) {\r
-                                       ($$.l)->trans[0] = $$.r;\r
-                                       ($$.l)->label = set_dup($1.label);\r
-                                       set_orin(&used_chars,($$.l)->label);\r
-                               }\r
-                       >>\r
-               ;\r
-\r
-atom_list      : << set_free($$.label); >>\r
-                               (near_atom <<set_orin(&($$.label),$1.label);>>)*\r
-               ;\r
-\r
-near_atom      : << register int i;\r
-                    register int i_prime;\r
-                 >>\r
-                 anychar\r
-                       <<$$.letter=$1.letter; $$.label=set_of($1.letter);\r
-                       i_prime = $1.letter + MIN_CHAR;\r
-                       if (case_insensitive && islower(i_prime))\r
-                               set_orel(toupper(i_prime)-MIN_CHAR,\r
-                                       &($$.label));\r
-                       if (case_insensitive && isupper(i_prime))\r
-                               set_orel(tolower(i_prime)-MIN_CHAR,\r
-                                       &($$.label));\r
-                       >>\r
-                       { RANGE anychar\r
-                               << if (case_insensitive){\r
-                                       i_prime = $$.letter+MIN_CHAR;\r
-                                       $$.letter = (islower(i_prime) ?\r
-                                               toupper(i_prime) : i_prime)-MIN_CHAR;\r
-                                       i_prime = $2.letter+MIN_CHAR;\r
-                                       $2.letter = (islower(i_prime) ?\r
-                                               toupper(i_prime) : i_prime)-MIN_CHAR;\r
-                                  }\r
-                                  /* check to see if range okay */\r
-                                       {\r
-                                           int debugLetter1 = $$.letter;\r
-                                               int debugLetter2 = $2.letter;\r
-                                       }\r
-                                  if ($$.letter > $2.letter \r
-                                       && $2.letter != 0xff){       /* MR16 */\r
-                                         error("invalid range  ", zzline);\r
-                                  }\r
-                                  for (i=$$.letter; i<= (int)$2.letter; ++i){\r
-                                       set_orel(i,&($$.label));\r
-                                       i_prime = i+MIN_CHAR;\r
-                                       if (case_insensitive && islower(i_prime))\r
-                                               set_orel(toupper(i_prime)-MIN_CHAR,\r
-                                                       &($$.label));\r
-                                       if (case_insensitive && isupper(i_prime))\r
-                                               set_orel(tolower(i_prime)-MIN_CHAR,\r
-                                                       &($$.label));\r
-                                       }\r
-                               >>\r
-                       }\r
-               ;\r
-\r
-atom           : << register int i_prime;>>\r
-                 anychar\r
-                 <<$$.label = set_of($1.letter);\r
-                   i_prime = $1.letter + MIN_CHAR;\r
-                   if (case_insensitive && islower(i_prime))\r
-                       set_orel(toupper(i_prime)-MIN_CHAR,\r
-                               &($$.label));\r
-                   if (case_insensitive && isupper(i_prime))\r
-                       set_orel(tolower(i_prime)-MIN_CHAR,\r
-                               &($$.label));\r
-                 >>\r
-               ;\r
-\r
-anychar                : REGCHAR       <<$$.letter = $1.letter - MIN_CHAR;>>\r
-               | OCTAL_VALUE   <<$$.letter = $1.letter - MIN_CHAR;>>\r
-               | HEX_VALUE     <<$$.letter = $1.letter - MIN_CHAR;>>\r
-               | DEC_VALUE     <<$$.letter = $1.letter - MIN_CHAR;>>\r
-               | TAB           <<$$.letter = $1.letter - MIN_CHAR;>>\r
-               | NL            <<$$.letter = $1.letter - MIN_CHAR;>>\r
-               | CR            <<$$.letter = $1.letter - MIN_CHAR;>>\r
-               | BS            <<$$.letter = $1.letter - MIN_CHAR;>>\r
-               | LIT           <<$$.letter = $1.letter - MIN_CHAR;>>\r
-               /* NOTE: LEX_EOF is ALWAYS shifted to 0 = MIN_CHAR - MIN_CHAR*/\r
-               | L_EOF         <<$$.letter = 0;>>\r
-               ;\r
-\r
-<</* empty action */>>\r
-\r
-#lexclass ACT\r
-#token "@"     << error("unterminated action", zzline); zzmode(START); >>\r
-#token ACTION "\>\>"\r
-               << if (func_action) fprintf(OUT,"}\n\n");\r
-                  zzmode(START);\r
-/* MR1                                                                     */\r
-/* MR1  11-Apr-97      Provide mechanism for inserting code into DLG class */\r
-/* MR1                         via <<%%lexmember ...>>                     */\r
-/* MR1                 This is a consequence of not saving actions         */\r
-/* MR1                                                                     */\r
-/* MR1 */         parserClass=0;               \r
-/* MR1 */         lexPrefix=0;\r
-/* MR1 */         lexAction=0;\r
-/* MR1 */         lexMember=0;\r
-               >>\r
-#token "\>"            << xxputc(zzlextext[0]); zzskip(); >>           /* MR1 */\r
-#token "\\\>"          << xxputc('>'); zzskip(); >>                    /* MR1 */\r
-#token "\\"            << xxputc('\\'); zzskip(); >>                   /* MR1 */\r
-#token "\n"            << xxputc(zzlextext[0]); ++zzline; zzskip(); >> /* MR1 */\r
-#token "/\*"           << zzmode(ACTION_COMMENTS);                     /* MR1 */\r
-                          xxprintf("%s", &(zzlextext[0])); zzskip();   /* MR1 */\r
-                       >>                                              /* MR1 */\r
-#token "//"            << zzmode(ACTION_CPP_COMMENTS);                 /* MR1 */\r
-                          xxprintf("%s", &(zzlextext[0])); zzskip();   /* MR1 */\r
-                       >>                                              /* MR1 */\r
-#token "~[]"           << xxputc(zzlextext[0]); zzskip(); >>           /* MR1 */\r
-                                                                       /* MR1 */\r
-#lexclass ACTION_COMMENTS                                              /* MR1 */\r
-#token "\*/"           << zzmode(ACT);                                 /* MR1 */\r
-                          xxprintf("%s", &(zzlextext[0])); zzskip();   /* MR1 */\r
-                       >>                                              /* MR1 */\r
-#token "[\n\r]"                << zzline++; xxputc(zzlextext[0]); zzskip();>>  /* MR1 */\r
-#token "~[]"           << xxputc(zzlextext[0]); zzskip();>>            /* MR1 */\r
-                                                                       /* MR1 */\r
-#lexclass ACTION_CPP_COMMENTS                                          /* MR1 */\r
-#token "[\n\r]"                << zzmode(ACT); zzline++;                       /* MR1 */\r
-                          xxprintf("%s", &(zzlextext[0])); zzskip();   /* MR1 */\r
-                       >>                                              /* MR1 */\r
-#token "~[]"           << xxputc(zzlextext[0]); zzskip();>>            /* MR1 */\r
-\r
-<<\r
-/* adds a new nfa to the binary tree and returns a pointer to it */\r
-nfa_node *\r
-#ifdef __USE_PROTOS\r
-new_nfa_node(void)\r
-#else\r
-new_nfa_node()\r
-#endif\r
-{\r
-       register nfa_node *t;\r
-       static int nfa_size=0;  /* elements nfa_array[] can hold */\r
-\r
-       ++nfa_allocated;\r
-       if (nfa_size<=nfa_allocated){\r
-               /* need to redo array */\r
-               if (!nfa_array){\r
-                       /* need some to do inital allocation */\r
-                       nfa_size=nfa_allocated+NFA_MIN;\r
-                       nfa_array=(nfa_node **) malloc(sizeof(nfa_node*)*\r
-                               nfa_size);\r
-               }else{\r
-                       /* need more space */\r
-                       nfa_size=2*(nfa_allocated+1);\r
-                       nfa_array=(nfa_node **) realloc(nfa_array,\r
-                               sizeof(nfa_node*)*nfa_size);\r
-               }\r
-       }\r
-       /* fill out entry in array */\r
-       t = (nfa_node*) malloc(sizeof(nfa_node));\r
-       nfa_array[nfa_allocated] = t;\r
-       *t = nfa_model_node;\r
-       t->node_no = nfa_allocated;\r
-       return t;\r
-}\r
-\r
-\r
-/* initialize the model node used to fill in newly made nfa_nodes */\r
-void\r
-#ifdef __USE_PROTOS\r
-make_nfa_model_node(void)\r
-#else\r
-make_nfa_model_node()\r
-#endif\r
-{\r
-       nfa_model_node.node_no = -1; /* impossible value for real nfa node */\r
-       nfa_model_node.nfa_set = 0;\r
-       nfa_model_node.accept = 0;   /* error state default*/\r
-       nfa_model_node.trans[0] = NULL;\r
-       nfa_model_node.trans[1] = NULL;\r
-       nfa_model_node.label = empty;\r
-}\r
->>\r
-\r
-<<\r
-#if defined(DEBUG) || defined(_DEBUG)\r
-\r
-/* print out the pointer value and the node_number */\r
-void\r
-#ifdef __USE_PROTOS\r
-fprint_dfa_pair(FILE *f, nfa_node *p)\r
-#else\r
-fprint_dfa_pair(f, p)\r
-FILE *f;\r
-nfa_node *p;\r
-#endif\r
-{\r
-       if (p){\r
-               fprintf(f, "%x (%d)", p, p->node_no);\r
-       }else{\r
-               fprintf(f, "(nil)");\r
-       }\r
-}\r
-\r
-/* print out interest information on a set */\r
-void\r
-#ifdef __USE_PROTOS\r
-fprint_set(FILE *f, set s)\r
-#else\r
-fprint_set(f,s)\r
-FILE *f;\r
-set s;\r
-#endif\r
-{\r
-       unsigned int *x;\r
-\r
-       fprintf(f, "n = %d,", s.n);\r
-       if (s.setword){\r
-               fprintf(f, "setword = %x,   ", s.setword);\r
-               /* print out all the elements in the set */\r
-               x = set_pdq(s);\r
-               while (*x!=nil){\r
-                       fprintf(f, "%d ", *x);\r
-                       ++x;\r
-               }\r
-       }else{\r
-               fprintf(f, "setword = (nil)");\r
-       }\r
-}\r
-\r
-/* code to be able to dump out the nfas\r
-       return 0 if okay dump\r
-       return 1 if screwed up\r
- */\r
-int\r
-#ifdef __USE_PROTOS\r
-dump_nfas(int first_node, int last_node)\r
-#else\r
-dump_nfas(first_node, last_node)\r
-int first_node;\r
-int last_node;\r
-#endif\r
-{\r
-       register int i;\r
-       nfa_node *t;\r
-\r
-       for (i=first_node; i<=last_node; ++i){\r
-               t = NFA(i);\r
-               if (!t) break;\r
-               fprintf(stderr, "nfa_node %d {\n", t->node_no);\r
-               fprintf(stderr, "\n\tnfa_set = %d\n", t->nfa_set);\r
-               fprintf(stderr, "\taccept\t=\t%d\n", t->accept);\r
-               fprintf(stderr, "\ttrans\t=\t(");\r
-               fprint_dfa_pair(stderr, t->trans[0]);\r
-               fprintf(stderr, ",");\r
-               fprint_dfa_pair(stderr, t->trans[1]);\r
-               fprintf(stderr, ")\n");\r
-               fprintf(stderr, "\tlabel\t=\t{ ");\r
-               fprint_set(stderr, t->label);\r
-               fprintf(stderr, "\t}\n");\r
-               fprintf(stderr, "}\n\n");\r
-       }\r
-       return 0;\r
-}\r
-#endif\r
->>\r
-\r
-<<\r
-/* DLG-specific syntax error message generator\r
- * (define USER_ZZSYN when compiling so don't get 2 definitions)\r
- */\r
-void\r
-#ifdef __USE_PROTOS\r
-zzsyn(char *text, int tok, char *egroup, SetWordType *eset, int etok, int k, char *bad_text)\r
-#else\r
-zzsyn(text, tok, egroup, eset, etok, k, bad_text)\r
-char *text, *egroup, *bad_text;\r
-int tok;\r
-int etok;\r
-int k;\r
-SetWordType *eset;\r
-#endif\r
-{\r
-       fprintf(stderr, ErrHdr, file_str[0]!=NULL?file_str[0]:"stdin", zzline);\r
-       fprintf(stderr, " syntax error at \"%s\"", (tok==zzEOF_TOKEN)?"EOF":text);\r
-       if ( !etok && !eset ) {fprintf(stderr, "\n"); return;}\r
-       if ( k==1 ) fprintf(stderr, " missing");\r
-       else\r
-       {\r
-               fprintf(stderr, "; \"%s\" not", bad_text);\r
-               if ( zzset_deg(eset)>1 ) fprintf(stderr, " in");\r
-       }\r
-       if ( zzset_deg(eset)>0 ) zzedecode(eset);\r
-       else fprintf(stderr, " %s", zztokens[etok]);\r
-       if ( strlen(egroup) > (size_t)0 ) fprintf(stderr, " in %s", egroup);\r
-       fprintf(stderr, "\n");\r
-}\r
->>\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/dlg/err.c b/Tools/CodeTools/TianoTools/Pccts/dlg/err.c
deleted file mode 100644 (file)
index c3eaeae..0000000
+++ /dev/null
@@ -1,99 +0,0 @@
-/*\r
- * A n t l r  S e t s / E r r o r  F i l e  H e a d e r\r
- *\r
- * Generated from: dlg_p.g\r
- *\r
- * Terence Parr, Russell Quong, Will Cohen, and Hank Dietz: 1989-2001\r
- * Parr Research Corporation\r
- * with Purdue University Electrical Engineering\r
- * With AHPCRC, University of Minnesota\r
- * ANTLR Version 1.33MR33\r
- */\r
-\r
-#define ANTLR_VERSION  13333\r
-#include "pcctscfg.h"\r
-#include "pccts_stdio.h"\r
-\r
-#include <ctype.h>\r
-#include "dlg.h"\r
-#define zzSET_SIZE 8\r
-#include "antlr.h"\r
-#include "tokens.h"\r
-#include "dlgdef.h"\r
-#include "err.h"\r
-\r
-ANTLRChar *zztokens[46]={\r
-       /* 00 */        "Invalid",\r
-       /* 01 */        "@",\r
-       /* 02 */        "[\\r\\t\\ ]+",\r
-       /* 03 */        "\\n",\r
-       /* 04 */        "L_EOF",\r
-       /* 05 */        "PER_PER",\r
-       /* 06 */        "NAME_PER_PER",\r
-       /* 07 */        "LEXMEMBER",\r
-       /* 08 */        "LEXACTION",\r
-       /* 09 */        "PARSERCLASS",\r
-       /* 10 */        "LEXPREFIX",\r
-       /* 11 */        "ACTION",\r
-       /* 12 */        "GREAT_GREAT",\r
-       /* 13 */        "L_BRACE",\r
-       /* 14 */        "R_BRACE",\r
-       /* 15 */        "L_PAR",\r
-       /* 16 */        "R_PAR",\r
-       /* 17 */        "L_BRACK",\r
-       /* 18 */        "R_BRACK",\r
-       /* 19 */        "ZERO_MORE",\r
-       /* 20 */        "ONE_MORE",\r
-       /* 21 */        "OR",\r
-       /* 22 */        "RANGE",\r
-       /* 23 */        "NOT",\r
-       /* 24 */        "OCTAL_VALUE",\r
-       /* 25 */        "HEX_VALUE",\r
-       /* 26 */        "DEC_VALUE",\r
-       /* 27 */        "TAB",\r
-       /* 28 */        "NL",\r
-       /* 29 */        "CR",\r
-       /* 30 */        "BS",\r
-       /* 31 */        "CONTINUATION",\r
-       /* 32 */        "LIT",\r
-       /* 33 */        "REGCHAR",\r
-       /* 34 */        "\\>",\r
-       /* 35 */        "\\\\>",\r
-       /* 36 */        "\\",\r
-       /* 37 */        "\\n",\r
-       /* 38 */        "/\\*",\r
-       /* 39 */        "//",\r
-       /* 40 */        "~[]",\r
-       /* 41 */        "\\*/",\r
-       /* 42 */        "[\\n\\r]",\r
-       /* 43 */        "~[]",\r
-       /* 44 */        "[\\n\\r]",\r
-       /* 45 */        "~[]"\r
-};\r
-SetWordType zzerr1[8] = {0x80,0xf,0x0,0x0, 0x0,0x0,0x0,0x0};\r
-SetWordType zzerr2[8] = {0x60,0x0,0x0,0x0, 0x0,0x0,0x0,0x0};\r
-SetWordType zzerr3[8] = {0x70,0xa8,0x9a,0x7f, 0x3,0x0,0x0,0x0};\r
-SetWordType setwd1[46] = {0x0,0x6,0x0,0x0,0x30,0xc8,0xc8,\r
-       0x1,0x1,0x1,0x1,0x35,0x0,0x30,0x0,\r
-       0x30,0x0,0x30,0x0,0x30,0x30,0x0,0x0,\r
-       0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,\r
-       0x0,0x30,0x30,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0};\r
-SetWordType zzerr4[8] = {0x10,0xa8,0x9a,0x7f, 0x3,0x0,0x0,0x0};\r
-SetWordType zzerr5[8] = {0x10,0xe8,0xbb,0x7f, 0x3,0x0,0x0,0x0};\r
-SetWordType zzerr6[8] = {0x10,0xa0,0x9a,0x7f, 0x3,0x0,0x0,0x0};\r
-SetWordType setwd2[46] = {0x0,0x0,0x0,0x0,0xeb,0x2,0x2,\r
-       0x0,0x0,0x0,0x0,0xd6,0x0,0xeb,0xd4,\r
-       0xeb,0xd4,0xeb,0x0,0xcb,0xcb,0xd0,0x0,\r
-       0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,\r
-       0x0,0xeb,0xeb,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0};\r
-SetWordType zzerr7[8] = {0x10,0xa0,0x82,0x7f, 0x3,0x0,0x0,0x0};\r
-SetWordType zzerr8[8] = {0x10,0x0,0x44,0x7f, 0x3,0x0,0x0,0x0};\r
-SetWordType zzerr9[8] = {0x10,0x0,0x0,0x7f, 0x3,0x0,0x0,0x0};\r
-SetWordType setwd3[46] = {0x0,0x0,0x0,0x0,0xf7,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0xc2,0x0,0xc2,0xc2,\r
-       0xc2,0xc2,0xc2,0xb8,0xc2,0xc2,0xc2,0x80,\r
-       0xc2,0xf7,0xf7,0xf7,0xf7,0xf7,0xf7,0xf7,\r
-       0x0,0xf7,0xf7,0x0,0x0,0x0,0x0,0x0,\r
-       0x0,0x0,0x0,0x0,0x0,0x0,0x0};\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/dlg/main.c b/Tools/CodeTools/TianoTools/Pccts/dlg/main.c
deleted file mode 100644 (file)
index 35bd827..0000000
+++ /dev/null
@@ -1,281 +0,0 @@
-/* Main function for dlg version\r
- *\r
- * SOFTWARE RIGHTS\r
- *\r
- * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
- * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
- * company may do whatever they wish with source code distributed with\r
- * PCCTS or the code generated by PCCTS, including the incorporation of\r
- * PCCTS, or its output, into commerical software.\r
- *\r
- * We encourage users to develop software with PCCTS.  However, we do ask\r
- * that credit is given to us for developing PCCTS.  By "credit",\r
- * we mean that if you incorporate our source code into one of your\r
- * programs (commercial product, research project, or otherwise) that you\r
- * acknowledge this fact somewhere in the documentation, research report,\r
- * etc...  If you like PCCTS and have developed a nice tool with the\r
- * output, please mention that you developed it using PCCTS.  In\r
- * addition, we ask that this header remain intact in our source code.\r
- * As long as these guidelines are kept, we expect to continue enhancing\r
- * this system and expect to make other tools available as they are\r
- * completed.\r
- *\r
- * DLG 1.33\r
- * Will Cohen\r
- * With mods by Terence Parr; AHPCRC, University of Minnesota\r
- * 1989-2001\r
- */\r
-\r
-#include <stdio.h>\r
-#include "stdpccts.h"\r
-\r
-char   program[] = "dlg";\r
-char   version[] = "1.33MR33";                                 /* MRXXX */\r
-int    numfiles = 0;\r
-char   *file_str[2] = {NULL, NULL};\r
-char   *mode_file = "mode.h";\r
-char   *class_name = DEFAULT_CLASSNAME;\r
-char   *OutputDirectory = TopDirectory;\r
-\r
-/* Option variables */\r
-int comp_level = 0;\r
-int interactive = FALSE;\r
-int case_insensitive = FALSE;\r
-int warn_ambig = FALSE;\r
-int gen_cpp = FALSE;\r
-\r
-#ifdef __USE_PROTOS\r
-static int ci_strequ(char *a,char *b)\r
-#else\r
-static int ci_strequ(a,b)\r
-  char  *a;\r
-  char  *b;\r
-#endif\r
-{\r
-  for ( ;*a != 0 && *b != 0; a++, b++) {\r
-    if (toupper(*a) != toupper(*b)) return 0;\r
-  }\r
-  return (*a == *b);\r
-}\r
-\r
-/* Option List Stuff */\r
-#ifdef __USE_PROTOS\r
-void p_comp0(void)             {comp_level = 0;}\r
-void p_comp1(void)             {comp_level = 1;}\r
-void p_comp2(void)             {comp_level = 2;}\r
-void p_stdio(void)             { file_str[numfiles++] = NULL;}\r
-void p_file(char *s)   { file_str[numfiles++] = s;}\r
-void p_cl_name(char *s, char *t)\r
-       {\r
-               if ( gen_cpp ) {\r
-                       class_name = t;\r
-               }\r
-               else {\r
-                       warning("-cl only valid in C++ mode; -cl ignored...",0);\r
-               }\r
-       }\r
-void p_mode_file(char *s, char *t){mode_file=t;}\r
-void p_outdir(char *s,char *t) {OutputDirectory=t;}\r
-void p_ansi(void)              {gen_ansi = TRUE;}\r
-void p_interactive(void)       {interactive = TRUE;}\r
-void p_case_s(void)            { case_insensitive = FALSE; }\r
-void p_case_i(void)            { case_insensitive = TRUE; }\r
-void p_warn_ambig(void)        { warn_ambig = TRUE; }\r
-void p_cpp(void)               { gen_cpp = TRUE; }\r
-#else\r
-void p_comp0()         {comp_level = 0;}\r
-void p_comp1()         {comp_level = 1;}\r
-void p_comp2()         {comp_level = 2;}\r
-void p_stdio()         { file_str[numfiles++] = NULL;}\r
-void p_file(s) char *s;        { file_str[numfiles++] = s;}\r
-void p_cl_name(s,t)\r
-       char *s, *t;\r
-       {\r
-               if ( gen_cpp ) {\r
-                       class_name = t;\r
-               }\r
-               else {\r
-                       warning("-cl only valid in C++ mode; -cl ignored...",0);\r
-               }\r
-       }\r
-void p_mode_file(s,t) char *s,*t;{mode_file=t;}\r
-void p_outdir(s,t) char *s,*t;{OutputDirectory=t;}\r
-void p_ansi()          {gen_ansi = TRUE;}\r
-void p_interactive()   {interactive = TRUE;}\r
-void p_case_s()                { case_insensitive = FALSE; }\r
-void p_case_i()                { case_insensitive = TRUE; }\r
-void p_warn_ambig()    { warn_ambig = TRUE; }\r
-void p_cpp()           { gen_cpp = TRUE; }\r
-#endif\r
-\r
-#ifdef __cplusplus\r
-typedef void (*WildFunc)(...);\r
-#else\r
-typedef void (*WildFunc)();\r
-#endif\r
-\r
-typedef struct {\r
-                       char *option;\r
-                       int  arg;\r
-                       WildFunc process;\r
-                       char *descr;\r
-               } Opt;\r
-\r
-Opt options[] = {\r
-       { "-CC", 0, (WildFunc)p_cpp, "Generate C++ output" },\r
-       { "-C0", 0, (WildFunc)p_comp0, "No compression (default)" },\r
-       { "-C1", 0, (WildFunc)p_comp1, "Compression level 1" },\r
-       { "-C2", 0, (WildFunc)p_comp2, "Compression level 2" },\r
-       { "-ga", 0, (WildFunc)p_ansi, "Generate ansi C"},\r
-       { "-Wambiguity", 0, (WildFunc)p_warn_ambig, "Warn if expressions ambiguous"},\r
-       { "-m", 1, (WildFunc)p_mode_file, "Rename lexical mode output file"},\r
-       { "-i", 0, (WildFunc)p_interactive, "Build interactive scanner (not valid for C++ mode)"},\r
-       { "-ci", 0, (WildFunc)p_case_i, "Make lexical analyzer case insensitive"},\r
-       { "-cl", 1, (WildFunc)p_cl_name, "Rename lexer class (DLGLexer); only used for -CC"},\r
-       { "-cs", 0, (WildFunc)p_case_s, "Make lexical analyzer case sensitive (default)"},\r
-       { "-o",  1, (WildFunc)p_outdir, OutputDirectoryOption},\r
-       { "-", 0, (WildFunc)p_stdio, "Use standard i/o rather than file"},\r
-       { "*", 0, (WildFunc)p_file, ""}, /* anything else is a file */\r
-       { NULL, 0, NULL }       \r
- };\r
-\r
-#ifdef __USE_PROTOS\r
-void ProcessArgs(int argc, char **argv, Opt *options)\r
-#else\r
-void ProcessArgs(argc, argv, options)\r
-int argc;\r
-char **argv;\r
-Opt *options;\r
-#endif\r
-{\r
-       Opt *p;\r
-       \r
-       while ( argc-- > 0 )\r
-       {\r
-               p = options;\r
-               while ( p->option != NULL )\r
-               {\r
-                       if ( strcmp(p->option, "*") == 0 ||\r
-                                ci_strequ(p->option,*argv) )\r
-                       {\r
-                               if ( p->arg )\r
-                               {\r
-                                       (*p->process)( *argv, *(argv+1) );\r
-                                       argv++;\r
-                                       argc--;\r
-                               }\r
-                               else\r
-                                       (*p->process)( *argv );\r
-                               break;\r
-                       }\r
-                       p++;\r
-               }\r
-               argv++;\r
-       }\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-int main(int argc, char *argv[])\r
-#else\r
-int main(argc, argv)\r
-int argc;\r
-char *argv[];\r
-#endif\r
-{\r
-       init();\r
-       fprintf(stderr, "%s  Version %s   1989-2001\n", &(program[0]),\r
-               &(version[0]));\r
-       if ( argc == 1 )\r
-       {\r
-               Opt *p = options;\r
-               fprintf(stderr, "%s [options] f1 f2 ... fn\n",argv[0]);\r
-               while ( *(p->option) != '*' )\r
-               {\r
-                       fprintf(stderr, "\t%s %s\t%s\n",\r
-                                                       p->option,\r
-                                                       (p->arg)?"___":"   ",\r
-                                                       p->descr);\r
-                       p++;\r
-               }\r
-       }else{\r
-               ProcessArgs(argc-1, &(argv[1]), options);\r
-               if (interactive && gen_cpp) {\r
-                       fprintf(stderr,"\n");\r
-/***  MR21a This statement is wrong ! ***/\r
-#if 0\r
-***                    fprintf(stderr,"Interactive lexer option (\"-i\") has no effect when in C++ mode\n");\r
-***                    fprintf(stderr,"because of extra buffering provided by ANTLRTokenBuffer class.\n");\r
-***                    fprintf(stderr,"\n");\r
-#endif\r
-               }\r
-               input_stream = read_stream(file_str[0]);\r
-               if (input_stream) {\r
-                       /* don't overwrite unless input okay */\r
-                       if ( gen_cpp ) {\r
-                               output_stream = write_stream(ClassName(CPP_FILE_SUFFIX));\r
-                               if ( file_str[1]!=NULL ) {\r
-                                       warning("output file implicit in C++ mode; ignored...",0);\r
-                               }\r
-                               class_stream = write_stream(ClassName(".h"));\r
-                               mode_stream = class_stream;\r
-                       }\r
-                       else {\r
-                               output_stream = write_stream(file_str[1]);\r
-                               mode_stream = write_stream(mode_file);\r
-                       }\r
-               }\r
-               /* make sure that error reporting routines in grammar\r
-                  know what the file really is */\r
-               /* make sure that reading and writing somewhere */\r
-               if (input_stream && output_stream && mode_stream){\r
-                       ANTLR(grammar(), input_stream);\r
-               }\r
-               p_class_def2();                 /* MR1 */\r
-       }\r
-       if ( output_stream!=NULL ) fclose(output_stream);\r
-       if ( !gen_cpp && mode_stream!=NULL ) fclose(mode_stream);\r
-       if ( class_stream!=NULL ) fclose(class_stream);\r
-       exit(PCCTS_EXIT_SUCCESS);\r
-       return 0;               /* get rid of warning message MR1 */\r
-}\r
-\r
-/* initialize all the variables */\r
-void \r
-#ifdef __USE_PROTOS\r
-init(void)\r
-#else\r
-init()\r
-#endif\r
-{\r
-       register int i;\r
-\r
-#ifdef SPECIAL_INITS\r
-       special_inits();                                        /* MR1 */\r
-#endif\r
-       used_chars = empty;\r
-       used_classes = empty;\r
-       /* make the valid character set */\r
-       normal_chars = empty;\r
-       /* NOTE: MIN_CHAR is EOF */\r
-       /* NOTE: EOF is not quite a valid char, it is special. Skip it*/\r
-       for (i = 1; i<CHAR_RANGE; ++i){\r
-               set_orel(i,&normal_chars);\r
-       }\r
-       make_nfa_model_node();\r
-       clear_hash();\r
-       /* NOTE: need to set this flag before the lexer starts getting */\r
-       /* tokens */\r
-       func_action = FALSE;    \r
-}\r
-\r
-/* stuff that needs to be reset when a new automaton is being built */\r
-void \r
-#ifdef __USE_PROTOS\r
-new_automaton_mode(void)                                       /* MR1 */\r
-#else\r
-new_automaton_mode()                                   /* MR1 */\r
-#endif\r
-{\r
-       set_free(used_chars);\r
-       clear_hash();\r
-}\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/dlg/makefile b/Tools/CodeTools/TianoTools/Pccts/dlg/makefile
deleted file mode 100644 (file)
index d5cceb8..0000000
+++ /dev/null
@@ -1,156 +0,0 @@
-#\r
-# Makefile for DLG 1.33\r
-# Terence Parr\r
-# Purdue University, U of MN, Parr Research Corporation\r
-# 1989-1994\r
-#\r
-# Ported to IBM C-Set/2 and Microsoft 6.0 by\r
-# Ed Harfmann\r
-# Micro Data Base Systems\r
-# Lafayette, Indiana\r
-#\r
-SET=../support/set\r
-PCCTS_H=../h\r
-\r
-##\r
-## Uncomment the appropriate section to build\r
-##\r
-\r
-#\r
-#   OS/2 & DOS 16 bit using MSC 6.0\r
-#\r
-#CC=cl\r
-#ANTLR=..\bin\antlr\r
-#DLG=..\bin\dlg\r
-#CFLAGS= -I. -I$(SET) -I$(PCCTS_H) /AL /Za /W3 -DPC -DUSER_ZZSYN\r
-#OUT_OBJ = -Fo\r
-#LIBS=/NOD:LLIBCE LLIBCEP\r
-#OBJ_EXT = obj\r
-#\r
-#dlg.exe : dlg_p.obj dlg_a.obj main.obj err.obj set.obj support.obj \\r
-#        output.obj relabel.obj automata.obj\r
-#        link @<<\r
-#$** /NOI\r
-#$@ /STACK:16384\r
-#\r
-#$(LIBS: = +^\r
-#)\r
-#$(DEF_FILE) $(LFLAGS) ;\r
-#<<\r
-#        bind $@ c:\os2\doscalls.lib\r
-#        copy *.exe ..\bin\r
-#\r
-\r
-#\r
-#   Borland C++ for DOS\r
-#\r
-#CC=bcc\r
-#ANTLR=..\bin\antlr\r
-#DLG=..\bin\dlg\r
-#CFLAGS= -I. -I$(SET) -I$(PCCTS_H) -ml -ff- -w- -DPC -DUSER_ZZSYN\r
-#OUT_OBJ = -o\r
-#LIBS= emu mathl cl\r
-#OBJ_EXT = obj\r
-#\r
-#dlg.exe : dlg_p.obj dlg_a.obj main.obj err.obj set.obj support.obj \\r
-#        output.obj relabel.obj automata.obj\r
-#       tlink @&&|\r
-#C0L $**\r
-#$@ /Tde /c\r
-#\r
-#$(LIBS)\r
-#$(DEF_FILE) $(LFLAGS) ;\r
-#|\r
-#        copy *.exe ..\bin\r
-#\r
-\r
-#\r
-# C-Set/2 for OS/2\r
-#\r
-#CC=icc\r
-#CFLAGS= -I. -I$(SET) -I$(PCCTS_H) /Sa /W3 /DUSER_ZZSYN\r
-#OUT_OBJ = -Fo\r
-#LIBS=\r
-#ANTLR=..\bin\antlr\r
-#DLG=..\bin\dlg\r
-#OBJ_EXT=obj\r
-#\r
-#dlg.exe : dlg_p.obj dlg_a.obj main.obj err.obj set.obj support.obj \\r
-#        output.obj relabel.obj automata.obj\r
-#        link386 @<<\r
-#$** /NOI\r
-#$@ /STACK:32768\r
-#\r
-#$(LIBS: = +^\r
-#)\r
-#$(DEF_FILE) $(LFLAGS) ;\r
-#<<\r
-#        copy *.exe ..\bin\r
-#\r
-\r
-#\r
-# Borland C++ for OS/2\r
-#\r
-#CC=bcc\r
-#CFLAGS= -I. -I$(SET) -I$(PCCTS_H) -w- -DUSER_ZZSYN\r
-#OUT_OBJ = -o\r
-#LIBS= c2 os2\r
-#\r
-#ANTLR=..\bin\antlr\r
-#DLG=..\bin\dlg\r
-#OBJ_EXT = obj\r
-#dlg.exe : dlg_p.obj dlg_a.obj main.obj err.obj set.obj support.obj \\r
-#        output.obj relabel.obj automata.obj\r
-#        tlink @&&|\r
-#c02 $** -c\r
-#dlg.exe\r
-#\r
-#C2 os2\r
-#\r
-#|\r
-#        copy *.exe ..\bin\r
-#\r
-\r
-#\r
-#   UNIX\r
-#\r
-CC=cc\r
-COPT=-O\r
-ANTLR=${BIN_DIR}/antlr\r
-DLG=${BIN_DIR}/dlg\r
-CFLAGS= $(COPT) -I. -I$(SET) -I$(PCCTS_H) -DUSER_ZZSYN -DZZLEXBUFSIZE=65536\r
-OBJ_EXT=o\r
-OUT_OBJ = -o\r
-OBJ = dlg_p.o dlg_a.o main.o err.o set.o support.o output.o \\r
-        relabel.o automata.o\r
-\r
-dlg : $(OBJ) $(SRC)\r
-               $(CC) $(CFLAGS) -o ${BIN_DIR}/dlg $(OBJ)\r
-\r
-SRC = dlg_p.c dlg_a.c main.c err.c $(SET)/set.c support.c output.c \\r
-        relabel.c automata.c\r
-\r
-#dlg_p.c parser.dlg err.c tokens.h : dlg_p.g\r
-#      $(ANTLR) dlg_p.g\r
-\r
-#dlg_a.c mode.h : parser.dlg\r
-#      $(DLG) -C2 parser.dlg dlg_a.c\r
-\r
-dlg_p.$(OBJ_EXT) : dlg_p.c dlg.h tokens.h mode.h\r
-       $(CC) $(CFLAGS) -c dlg_p.c\r
-\r
-dlg_a.$(OBJ_EXT) : dlg_a.c dlg.h tokens.h mode.h\r
-       $(CC) $(CFLAGS) -c dlg_a.c\r
-\r
-main.$(OBJ_EXT) : main.c dlg.h\r
-       $(CC) $(CFLAGS) -c main.c\r
-\r
-set.$(OBJ_EXT) : $(SET)/set.c\r
-       $(CC) -c $(CFLAGS) $(SET)/set.c\r
-\r
-lint:\r
-       lint *.c\r
-\r
-#clean up all the intermediate files\r
-clean:\r
-       rm -f *.$(OBJ_EXT) core\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/dlg/makefile.cygwin b/Tools/CodeTools/TianoTools/Pccts/dlg/makefile.cygwin
deleted file mode 100644 (file)
index bbba820..0000000
+++ /dev/null
@@ -1,157 +0,0 @@
-#\r
-# Makefile for DLG 1.33\r
-# Terence Parr\r
-# Purdue University, U of MN, Parr Research Corporation\r
-# 1989-1994\r
-#\r
-# Ported to IBM C-Set/2 and Microsoft 6.0 by\r
-# Ed Harfmann\r
-# Micro Data Base Systems\r
-# Lafayette, Indiana\r
-#\r
-SET=../support/set\r
-PCCTS_H=../h\r
-\r
-##\r
-## Uncomment the appropriate section to build\r
-##\r
-\r
-#\r
-#   OS/2 & DOS 16 bit using MSC 6.0\r
-#\r
-#CC=cl\r
-#ANTLR=..\bin\antlr\r
-#DLG=..\bin\dlg\r
-#CFLAGS= -I. -I$(SET) -I$(PCCTS_H) /AL /Za /W3 -DPC -DUSER_ZZSYN\r
-#OUT_OBJ = -Fo\r
-#LIBS=/NOD:LLIBCE LLIBCEP\r
-#OBJ_EXT = obj\r
-#\r
-#dlg.exe : dlg_p.obj dlg_a.obj main.obj err.obj set.obj support.obj \\r
-#        output.obj relabel.obj automata.obj\r
-#        link @<<\r
-#$** /NOI\r
-#$@ /STACK:16384\r
-#\r
-#$(LIBS: = +^\r
-#)\r
-#$(DEF_FILE) $(LFLAGS) ;\r
-#<<\r
-#        bind $@ c:\os2\doscalls.lib\r
-#        copy *.exe ..\bin\r
-#\r
-\r
-#\r
-#   Borland C++ for DOS\r
-#\r
-#CC=bcc\r
-#ANTLR=..\bin\antlr\r
-#DLG=..\bin\dlg\r
-#CFLAGS= -I. -I$(SET) -I$(PCCTS_H) -ml -ff- -w- -DPC -DUSER_ZZSYN\r
-#OUT_OBJ = -o\r
-#LIBS= emu mathl cl\r
-#OBJ_EXT = obj\r
-#\r
-#dlg.exe : dlg_p.obj dlg_a.obj main.obj err.obj set.obj support.obj \\r
-#        output.obj relabel.obj automata.obj\r
-#       tlink @&&|\r
-#C0L $**\r
-#$@ /Tde /c\r
-#\r
-#$(LIBS)\r
-#$(DEF_FILE) $(LFLAGS) ;\r
-#|\r
-#        copy *.exe ..\bin\r
-#\r
-\r
-#\r
-# C-Set/2 for OS/2\r
-#\r
-#CC=icc\r
-#CFLAGS= -I. -I$(SET) -I$(PCCTS_H) /Sa /W3 /DUSER_ZZSYN\r
-#OUT_OBJ = -Fo\r
-#LIBS=\r
-#ANTLR=..\bin\antlr\r
-#DLG=..\bin\dlg\r
-#OBJ_EXT=obj\r
-#\r
-#dlg.exe : dlg_p.obj dlg_a.obj main.obj err.obj set.obj support.obj \\r
-#        output.obj relabel.obj automata.obj\r
-#        link386 @<<\r
-#$** /NOI\r
-#$@ /STACK:32768\r
-#\r
-#$(LIBS: = +^\r
-#)\r
-#$(DEF_FILE) $(LFLAGS) ;\r
-#<<\r
-#        copy *.exe ..\bin\r
-#\r
-\r
-#\r
-# Borland C++ for OS/2\r
-#\r
-#CC=bcc\r
-#CFLAGS= -I. -I$(SET) -I$(PCCTS_H) -w- -DUSER_ZZSYN\r
-#OUT_OBJ = -o\r
-#LIBS= c2 os2\r
-#\r
-#ANTLR=..\bin\antlr\r
-#DLG=..\bin\dlg\r
-#OBJ_EXT = obj\r
-#dlg.exe : dlg_p.obj dlg_a.obj main.obj err.obj set.obj support.obj \\r
-#        output.obj relabel.obj automata.obj\r
-#        tlink @&&|\r
-#c02 $** -c\r
-#dlg.exe\r
-#\r
-#C2 os2\r
-#\r
-#|\r
-#        copy *.exe ..\bin\r
-#\r
-\r
-#\r
-#   UNIX\r
-#\r
-BIN_DIR=../../../../bin\r
-CC=cc\r
-COPT=-O\r
-ANTLR=$(BIN_DIR)/antlr.exe\r
-DLG=${BIN_DIR}/dlg.exe\r
-CFLAGS= $(COPT) -I. -I$(SET) -I$(PCCTS_H) -DUSER_ZZSYN -DZZLEXBUFSIZE=65536\r
-OBJ_EXT=o\r
-OUT_OBJ = -o\r
-OBJ = dlg_p.o dlg_a.o main.o err.o set.o support.o output.o \\r
-        relabel.o automata.o\r
-\r
-dlg : $(OBJ) $(SRC)\r
-               $(CC) $(CFLAGS) -o $(BIN_DIR)/dlg.exe $(OBJ)\r
-\r
-SRC = dlg_p.c dlg_a.c main.c err.c $(SET)/set.c support.c output.c \\r
-        relabel.c automata.c\r
-\r
-#dlg_p.c parser.dlg err.c tokens.h : dlg_p.g\r
-#      $(ANTLR) dlg_p.g\r
-\r
-#dlg_a.c mode.h : parser.dlg\r
-#      $(DLG) -C2 parser.dlg dlg_a.c\r
-\r
-dlg_p.$(OBJ_EXT) : dlg_p.c dlg.h tokens.h mode.h\r
-       $(CC) $(CFLAGS) -c dlg_p.c\r
-\r
-dlg_a.$(OBJ_EXT) : dlg_a.c dlg.h tokens.h mode.h\r
-       $(CC) $(CFLAGS) -c dlg_a.c\r
-\r
-main.$(OBJ_EXT) : main.c dlg.h\r
-       $(CC) $(CFLAGS) -c main.c\r
-\r
-set.$(OBJ_EXT) : $(SET)/set.c\r
-       $(CC) -c $(CFLAGS) $(SET)/set.c\r
-\r
-lint:\r
-       lint *.c\r
-\r
-#clean up all the intermediate files\r
-clean:\r
-       rm -f *.$(OBJ_EXT) core\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/dlg/makefile1 b/Tools/CodeTools/TianoTools/Pccts/dlg/makefile1
deleted file mode 100644 (file)
index 4d00f79..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-#\r
-# Makefile for DLG 1.33\r
-# Terence Parr\r
-# Purdue University, U of MN, Parr Research Corporation\r
-# 1989-1994\r
-#\r
-# Ported to IBM C-Set/2 and Microsoft 6.0 by\r
-# Ed Harfmann\r
-# Micro Data Base Systems\r
-# Lafayette, Indiana\r
-#\r
-SET=../support/set\r
-PCCTS_H=../h\r
-\r
-##\r
-## Uncomment the appropriate section to build\r
-##\r
-\r
-\r
-#\r
-#   UNIX\r
-#\r
-CC=cc\r
-ANTLR=../bin/antlr\r
-DLG=../bin/dlg\r
-ANSI=-ansi\r
-CFLAGS= -O -I. -I$(SET) -I$(PCCTS_H) -DUSER_ZZSYN $(COTHER) $(ANSI) -DZZLEXBUFSIZE=32000\r
-OBJ_EXT=o\r
-OUT_OBJ = -o\r
-OBJ = dlg_p.o dlg_a.o main.o err.o set.o support.o output.o \\r
-        relabel.o automata.o\r
-\r
-dlg : $(OBJ) $(SRC)\r
-               $(CC) $(CFLAGS) -o dlg $(OBJ)\r
-               mv dlg ../bin\r
-\r
-SRC = dlg_p.c dlg_a.c main.c err.c $(SET)/set.c support.c output.c \\r
-        relabel.c automata.c\r
-\r
-dlg_p.c parser.dlg err.c tokens.h : dlg_p.g\r
-       $(ANTLR) dlg_p.g\r
-\r
-dlg_a.c mode.h : parser.dlg\r
-       $(DLG) -C2 parser.dlg dlg_a.c\r
-\r
-dlg_p.$(OBJ_EXT) : dlg_p.c dlg.h tokens.h mode.h\r
-       $(CC) $(CFLAGS) -c dlg_p.c\r
-\r
-dlg_a.$(OBJ_EXT) : dlg_a.c dlg.h tokens.h mode.h\r
-       $(CC) $(CFLAGS) -c dlg_a.c\r
-\r
-main.$(OBJ_EXT) : main.c dlg.h\r
-       $(CC) $(CFLAGS) -c main.c\r
-\r
-set.$(OBJ_EXT) : $(SET)/set.c\r
-       $(CC) -c $(CFLAGS) $(SET)/set.c\r
-\r
-lint:\r
-       lint *.c\r
-\r
-#clean up all the intermediate files\r
-clean:\r
-       rm -f *.$(OBJ_EXT) core\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/dlg/mode.h b/Tools/CodeTools/TianoTools/Pccts/dlg/mode.h
deleted file mode 100644 (file)
index 3f3279e..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-#define START 0\r
-#define ACT 1\r
-#define ACTION_COMMENTS 2\r
-#define ACTION_CPP_COMMENTS 3\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/dlg/output.c b/Tools/CodeTools/TianoTools/Pccts/dlg/output.c
deleted file mode 100644 (file)
index 2e56a6d..0000000
+++ /dev/null
@@ -1,850 +0,0 @@
-/* output.c, output generator for dlg\r
- *\r
- * Output Notes:\r
- *\r
- * DfaStates == number of dfa nodes in automaton (just a #define)\r
- * DfaState == type large enough to index every node in automaton\r
- *         <256 unsigned char, <65536 unsigned short, etc.\r
- *\r
- * Thus, the elements in each of the automaton states (st%d) are type DfaState\r
- * and are size appropriately, since they must be able to index the next\r
- * automaton state.\r
- *\r
- * dfa[] == a linear array that points to all the automaton states (st%d)\r
- *         (dfa_base[] should be the same, but isn't right now)\r
- *\r
- * accepts[] == Taking a closer look at this one, it probably shouldn't be type\r
- *         DfaState because there is no real requirement that the number of\r
- *         accepts states is less than the number of dfa state.  However, if\r
- *         the number of accept states was more than the number of DFA states\r
- *         then the lexical specification would be really ambiguous.\r
- *\r
- *         Another note. Is that is should be possible to fold accepts[] and\r
- *         actions[] together.  If this is done, I would suggest get rid of\r
- *         accept[] and make actions[] have an entry for each state (st%d) in\r
- *         the automaton.\r
- *\r
- * dfa_base[] == starting location for each lexical mode.  This should be\r
- *         Dfastate type (but isn't right now), since it points to the states\r
- *         in the automaton.\r
- *\r
- * dfa_class_no[] == indicates the number of columns each lexical mode has.\r
- *\r
- * b_class_no[] == pointer to the start of the translation array used to\r
- *         convert from input character to character class.  This could cause\r
- *         problems if there are more than 256 classes\r
- *\r
- * shift%d[] == the actual translation arrays that convert the input character\r
- *         into the character class.  These will have to change if there are\r
- *         more than 256 character classes.\r
- *\r
- * SOFTWARE RIGHTS\r
- *\r
- * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
- * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
- * company may do whatever they wish with source code distributed with\r
- * PCCTS or the code generated by PCCTS, including the incorporation of\r
- * PCCTS, or its output, into commerical software.\r
- *\r
- * We encourage users to develop software with PCCTS.  However, we do ask\r
- * that credit is given to us for developing PCCTS.  By "credit",\r
- * we mean that if you incorporate our source code into one of your\r
- * programs (commercial product, research project, or otherwise) that you\r
- * acknowledge this fact somewhere in the documentation, research report,\r
- * etc...  If you like PCCTS and have developed a nice tool with the\r
- * output, please mention that you developed it using PCCTS.  In\r
- * addition, we ask that this header remain intact in our source code.\r
- * As long as these guidelines are kept, we expect to continue enhancing\r
- * this system and expect to make other tools available as they are\r
- * completed.\r
- *\r
- * DLG 1.33\r
- * Will Cohen\r
- * With mods by Terence Parr; AHPCRC, University of Minnesota\r
- * 1989-2001\r
- */\r
-\r
-#include <stdio.h>\r
-#include <string.h>\r
-#include "dlg.h"\r
-#ifdef MEMCHK\r
-#include "trax.h"\r
-#else\r
-#ifdef __STDC__\r
-#include <stdlib.h>\r
-#else\r
-#include <malloc.h>\r
-#endif /* __STDC__ */\r
-#endif\r
-\r
-static char *mode_name[MAX_MODES];\r
-static int mode_number[MAX_MODES];\r
-static int cur_mode=0;\r
-\r
-int operation_no = 0; /* used to mark nodes so that infinite loops avoided */\r
-int dfa_basep[MAX_MODES];      /* start of each group of states */\r
-int dfa_class_nop[MAX_MODES];  /* number of elements in each group of states*/\r
-\r
-int gen_ansi = FALSE;          /* allows ansi code to be generated */\r
-\r
-FILE *input_stream;    /* where to read description from */\r
-FILE *output_stream;   /* where to put the output        */\r
-FILE *mode_stream;     /* where to put the mode.h stuff */\r
-FILE *class_stream;    /* where to put the scan.h stuff (if gen_cpp) */\r
-\r
-/* NOTE: This section is MACHINE DEPENDENT */\r
-#define DIF_SIZE 4\r
-#if defined(PC) && !defined(PC32)\r
-unsigned long typesize[DIF_SIZE]  = { 0x7f, 0x7fff, 0x7ffful, 0x7ffffffful }; /* MR20 */\r
-char t0[] = "unsigned char";\r
-char t1[] = "unsigned short";\r
-char t2[] = "unsigned int";\r
-char t3[] = "unsigned long";\r
-char *typevar[DIF_SIZE] = { t0, t1, t2, t3};\r
-#else\r
-unsigned long typesize[DIF_SIZE]  = { 0x7f, 0x7fff, 0x7ffffffful, 0x7ffffffful }; /* MR20 */\r
-char t0[] = "unsigned char";\r
-char t1[] = "unsigned short";\r
-char t2[] = "unsigned int";\r
-char t3[] = "unsigned long";\r
-char *typevar[DIF_SIZE] = { t0, t1, t2, t3};\r
-#endif\r
-\r
-/* Added by TJP August 1994 */\r
-/* Take in MyLexer and return MyLexer_h */\r
-\r
-static char *\r
-#ifdef __USE_PROTOS\r
-gate_symbol(char *name)\r
-#else\r
-gate_symbol(name)\r
-char *name;\r
-#endif\r
-{\r
-       static char buf[100];\r
-       sprintf(buf, "%s_h", name);\r
-       return buf;\r
-}\r
-\r
-/* Added by TJP August 1994 */\r
-static char *\r
-#ifdef __USE_PROTOS\r
-mystrdup(char *s)\r
-#else\r
-mystrdup(s)\r
-char *s;\r
-#endif\r
-{\r
-       char *p = (char *)malloc(strlen(s)+1);\r
-       strcpy(p, s);\r
-       return p;\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-void p_class_hdr(void)\r
-#else\r
-void p_class_hdr()                                             \r
-#endif\r
-{\r
-       if ( class_stream == NULL ) return;\r
-       fprintf(class_stream, "#ifndef %s\n", gate_symbol(ClassName("")));\r
-       fprintf(class_stream, "#define %s\n", gate_symbol(ClassName("")));\r
-       fprintf(class_stream, "/*\n");\r
-       fprintf(class_stream, " * D L G L e x e r  C l a s s  D e f i n i t i o n\n");\r
-       fprintf(class_stream, " *\n");\r
-       fprintf(class_stream, " * Generated from:");\r
-       fprintf(class_stream, " %s", file_str[0]);\r
-       fprintf(class_stream, "\n");\r
-       fprintf(class_stream, " *\n");\r
-       fprintf(class_stream, " * 1989-2001 by  Will Cohen, Terence Parr, and Hank Dietz\n");\r
-       fprintf(class_stream, " * Purdue University Electrical Engineering\n");\r
-       fprintf(class_stream, " * DLG Version %s\n", version);\r
-       fprintf(class_stream, " */\n\n");\r
-       fprintf(class_stream, "\n");\r
-       fprintf(class_stream, "#include \"%s\"\n", DLEXERBASE_H);\r
-}\r
-\r
-/* MR1                                                                 */\r
-/* MR1 16-Apr-97  Split printing of class header up into several parts  */\r
-/* MR1             so that #lexprefix <<...>>and #lexmember <<...>>    */\r
-/* MR1             can be inserted in the appropriate spots            */\r
-/* MR1                                                                 */\r
-\r
-#ifdef __USE_PROTOS\r
-void p_class_def1(void)\r
-#else\r
-void p_class_def1()\r
-#endif\r
-{\r
-       if ( class_stream == NULL ) return;\r
-       fprintf(class_stream, "\nclass %s : public DLGLexerBase {\n", ClassName(""));\r
-       fprintf(class_stream, "public:\n");\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-void p_class_def2(void)\r
-#else\r
-void p_class_def2()\r
-#endif\r
-{\r
-       int i, m;\r
-       if ( class_stream == NULL ) return;\r
-       fprintf(class_stream, "public:\n");\r
-       fprintf(class_stream, "\tstatic const int MAX_MODE;\n");\r
-       fprintf(class_stream, "\tstatic const int DfaStates;\n");\r
-       for (i=0; i<cur_mode; i++) {\r
-               fprintf(class_stream, "\tstatic const int %s;\n", mode_name[i]);\r
-       }\r
-\r
-       fprintf(class_stream, "\ttypedef %s DfaState;\n\n", minsize(dfa_allocated));\r
-       fprintf(class_stream, "\t%s(DLGInputStream *in,\n",ClassName(""));\r
-       fprintf(class_stream, "\t\tunsigned bufsize=2000)\n");\r
-       fprintf(class_stream, "\t\t: DLGLexerBase(in, bufsize, %d)\n", interactive);\r
-       fprintf(class_stream, "\t{\n");\r
-       fprintf(class_stream, "\t;\n");\r
-       fprintf(class_stream, "\t}\n");\r
-       fprintf(class_stream, "\tvoid     mode(int);\n");\r
-       fprintf(class_stream, "\tANTLRTokenType nextTokenType(void);\n");\r
-       fprintf(class_stream, "\tvoid     advance(void);\n");\r
-       fprintf(class_stream, "protected:\n");\r
-       for (i=1; i<=action_no; ++i) {\r
-               fprintf(class_stream, "\tANTLRTokenType act%d();\n", i);\r
-       }\r
-\r
-       for(m=0; m<(mode_counter-1); ++m){\r
-               for(i=dfa_basep[m]; i<dfa_basep[m+1]; ++i)\r
-                       fprintf(class_stream, "\tstatic DfaState st%d[%d];\n", i-1, dfa_class_nop[m]+1);\r
-       }\r
-       for(i=dfa_basep[m]; i<=dfa_allocated; ++i)\r
-               fprintf(class_stream, "\tstatic DfaState st%d[%d];\n", i-1, dfa_class_nop[m]+1);\r
-\r
-       fprintf(class_stream, "\tstatic DfaState *dfa[%d];\n", dfa_allocated);\r
-       fprintf(class_stream, "\tstatic DfaState dfa_base[];\n");\r
-/*     fprintf(class_stream, "\tstatic int dfa_base_no[];\n"); */\r
-       fprintf(class_stream, "\tstatic unsigned char *b_class_no[];\n");\r
-       fprintf(class_stream, "\tstatic DfaState accepts[%d];\n",dfa_allocated+1);\r
-       fprintf(class_stream, "\tstatic DLGChar alternatives[%d];\n",dfa_allocated+1);\r
-       /* WARNING: should be ANTLRTokenType for action table, but g++ 2.5.6 is hosed */\r
-       fprintf(class_stream, "\tstatic ANTLRTokenType (%s::*actions[%d])();\n", ClassName(""), action_no+1);\r
-       for(m=0; m<mode_counter; ++m) {\r
-               fprintf(class_stream, "\tstatic unsigned char shift%d[%d];\n",\r
-                       m, CHAR_RANGE);\r
-       }\r
-       if (comp_level)\r
-               fprintf(class_stream, "\tint ZZSHIFT(int c) { return b_class_no[automaton][1+c]; }\n");\r
-       else\r
-               fprintf(class_stream, "\tint ZZSHIFT(int c) { return 1+c; }\n");\r
-\r
-/* MR1                                                                   */\r
-/* MR1 11-APr-97   Kludge to allow inclusion of user-defined code in     */\r
-/* MR1                  DLGLexer class header                            */\r
-/* MR1            Deprecated in favor of 133MR1 addition #lexmember <<>> */\r
-/* MR1                                                                   */\r
-/* MR1 */      fprintf(class_stream,"//\n");\r
-/* MR1 */      fprintf(class_stream,\r
-/* MR1 */         "// 133MR1 Deprecated feature to allow inclusion of ");\r
-/* MR1 */      fprintf(class_stream,\r
-/* MR1 */         "user-defined code in DLG class header\n");\r
-/* MR1 */      fprintf(class_stream,"//\n");\r
-/* MR1 */\r
-/* MR1 */      fprintf(class_stream,"#ifdef DLGLexerIncludeFile\n");\r
-/* MR1 */      fprintf(class_stream,"#include DLGLexerIncludeFile\n");\r
-/* MR1 */      fprintf(class_stream,"#endif\n");\r
-\r
-       fprintf(class_stream, "};\n");\r
-\r
-       fprintf(class_stream, "typedef ANTLRTokenType (%s::*Ptr%sMemberFunc)();\n",\r
-                       ClassName(""), ClassName(""));\r
-\r
-       fprintf(class_stream, "#endif\n");\r
-}\r
-\r
-/* generate required header on output */\r
-\r
-#ifdef __USE_PROTOS\r
-void p_head(void)\r
-#else\r
-void p_head()\r
-#endif\r
-{\r
-       fprintf(OUT, "/*\n");\r
-       fprintf(OUT, " * D L G tables\n");\r
-       fprintf(OUT, " *\n");\r
-       fprintf(OUT, " * Generated from:");\r
-       fprintf(OUT, " %s", file_str[0]);\r
-       fprintf(OUT, "\n");\r
-       fprintf(OUT, " *\n");\r
-       fprintf(OUT, " * 1989-2001 by  Will Cohen, Terence Parr, and Hank Dietz\n");\r
-       fprintf(OUT, " * Purdue University Electrical Engineering\n");\r
-       fprintf(OUT, " * DLG Version %s\n", version);\r
-       fprintf(OUT, " */\n\n");\r
-       if ( gen_cpp)  fprintf(OUT, "#include \"pcctscfg.h\"\n");\r
-       if ( gen_cpp ) fprintf(OUT, "#include \"pccts_stdio.h\"\n");\r
-       if ( !gen_cpp ) fprintf(OUT, "#include \"%s\"\n\n", mode_file);\r
-       fprintf(OUT,"\n");\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-void p_includes(void)\r
-#else\r
-void p_includes()\r
-#endif\r
-{\r
-       fprintf(OUT, "#include \"%s\"\n", APARSER_H);\r
-       fprintf(OUT, "#include \"%s\"\n", DLEXERBASE_H);\r
-       fprintf(OUT, "#include \"%s\"\n", ClassName(".h"));\r
-}\r
-\r
-/* generate code to tie up any loose ends */\r
-\r
-#ifdef __USE_PROTOS\r
-void p_tail(void)                              /* MR1 */\r
-#else\r
-void p_tail()                                          /* MR1 */\r
-#endif\r
-{\r
-       if ( gen_cpp ) {\r
-               if ( strcmp(ClassName(""), DEFAULT_CLASSNAME)!=0 )\r
-                       fprintf(OUT, "#define DLGLexer %s\n", ClassName(""));\r
-               fprintf(OUT, "#include \"%s\"\n", DLEXER_H);  /* MR23 Rename DLexer.cpp to DLexer.h */\r
-               return;\r
-       }\r
-       fprintf(OUT, "\n");\r
-       fprintf(OUT, "\n");\r
-       if (comp_level)\r
-               fprintf(OUT, "#define ZZSHIFT(c) (b_class_no[zzauto][1+c])\n");\r
-       else\r
-               fprintf(OUT, "#define ZZSHIFT(c) (1+c)\n");\r
-       if ( !gen_cpp ) fprintf(OUT, "#define MAX_MODE %d\n",mode_counter);\r
-       fprintf(OUT, "#include \"dlgauto.h\"\n");\r
-}\r
-\r
-\r
-/* output the table of DFA for general use */\r
-\r
-#ifdef __USE_PROTOS\r
-void p_tables()\r
-#else\r
-void p_tables()\r
-#endif\r
-{\r
-       if ( !gen_cpp ) {\r
-               fprintf(OUT, "#define DfaStates\t%d\n", dfa_allocated);\r
-               fprintf(OUT, "typedef %s DfaState;\n\n", minsize(dfa_allocated));\r
-       }\r
-\r
-       if ( gen_cpp ) {\r
-               int i;\r
-               fprintf(OUT, "\n");\r
-               fprintf(OUT, "const int %s::MAX_MODE=%d;\n",\r
-                               ClassName(""),\r
-                               mode_counter);\r
-               fprintf(OUT, "const int %s::DfaStates=%d;\n",\r
-                               ClassName(""),\r
-                               dfa_allocated);\r
-               for (i=0; i<cur_mode; i++) {\r
-                       fprintf(OUT, "const int %s::%s=%d;\n",\r
-                                       ClassName(""), mode_name[i], mode_number[i]);\r
-               }\r
-               fprintf(OUT, "\n");\r
-       }\r
-\r
-       p_node_table();\r
-       p_dfa_table();\r
-       p_accept_table();\r
-       p_action_table();\r
-       p_base_table();\r
-       p_class_table();\r
-       if (comp_level)\r
-               p_bshift_table();\r
-       if (interactive || gen_cpp )\r
-               p_alternative_table();\r
-}\r
-\r
-\r
-/* figures out the smallest variable type that will hold the transitions\r
- */\r
-\r
-#ifdef __USE_PROTOS\r
-char *minsize(int elements)\r
-#else\r
-char *minsize(elements)\r
-int elements;\r
-#endif\r
-{\r
-       int i = 0;\r
-\r
-       while ((unsigned long) elements > typesize[i]) /* MR20 */\r
-               ++i;\r
-       return typevar[i];\r
-}\r
-\r
-\r
-#ifdef __USE_PROTOS\r
-void p_node_table(void)\r
-#else\r
-void p_node_table()\r
-#endif\r
-{\r
-       register int    i;\r
-       register int    m = 0;\r
-\r
-       for(m=0; m<(mode_counter-1); ++m){\r
-               for(i=dfa_basep[m]; i<dfa_basep[m+1]; ++i)\r
-                       p_single_node(i,dfa_class_nop[m]);\r
-       }\r
-       for(i=dfa_basep[m]; i<=dfa_allocated; ++i)\r
-               p_single_node(i,dfa_class_nop[m]);\r
-}\r
-\r
-\r
-#ifdef __USE_PROTOS\r
-void p_single_node(int i,int classes)\r
-#else\r
-void p_single_node(i,classes)\r
-int i,classes;\r
-#endif\r
-{\r
-       register int    j;\r
-       register int    trans, items_on_line;\r
-\r
-#if 1\r
-       /* extra state (classes+1) for invalid characters */\r
-       fprintf(OUT, "%sDfaState %sst%d[%d] = {\n  ",\r
-               gen_cpp?ClassName("::"):"static ",\r
-               gen_cpp?ClassName("::"):"",(i-1), (classes+1));\r
-#else\r
-       fprintf(OUT, "static DfaState st%d[%d] = {\n  ", (i-1), classes);\r
-#endif\r
-       items_on_line = MAX_ON_LINE;\r
-       for(j=0; j<classes; ++j){\r
-               DAWDLE;\r
-               trans = DFA(i)->trans[j];\r
-               if (trans == NIL_INDEX)\r
-                       trans = dfa_allocated+1;\r
-               /* all of DFA moved down one in array */\r
-               fprintf(OUT, "%d", trans-1);\r
-               fprintf(OUT, ", ");\r
-               if (!(--items_on_line)){\r
-                       fprintf(OUT, "\n  ");\r
-                       items_on_line = MAX_ON_LINE;\r
-               }\r
-       }\r
-#if 1\r
-       /* put in jump to error state */\r
-       fprintf(OUT, "%d\n};\n\n", dfa_allocated);\r
-#else\r
-       fprintf(OUT, "\n};\n\n");\r
-#endif\r
-}\r
-\r
-\r
-#ifdef __USE_PROTOS\r
-void p_dfa_table(void)\r
-#else\r
-void p_dfa_table()\r
-#endif\r
-{\r
-       register int    i;\r
-\r
-       fprintf(OUT, "\n%sDfaState *%sdfa[%d] = {\n",\r
-               gen_cpp?ClassName("::"):"",gen_cpp?ClassName("::"):"", dfa_allocated);\r
-       for (i=0; i<(dfa_allocated-1); ++i){\r
-               fprintf(OUT, "\tst%d,\n", i);\r
-       }\r
-       fprintf(OUT, "\tst%d\n", i);\r
-       fprintf(OUT, "};\n\n");\r
-}\r
-\r
-\r
-#ifdef __USE_PROTOS\r
-void p_accept_table(void)\r
-#else\r
-void p_accept_table()\r
-#endif\r
-{\r
-       register int    i = 1;\r
-       register int    items_on_line = 0;\r
-       int             true_interactive = TRUE;\r
-\r
-       /* make sure element for one past (zzerraction) -WEC 12/16/92 */\r
-       fprintf(OUT,"\n%sDfaState %saccepts[%d] = {\n  ",\r
-                       gen_cpp?ClassName("::"):"",\r
-                       gen_cpp?ClassName("::"):"",\r
-                       dfa_allocated+1);\r
-       /* don't do anything if no dfa nodes */\r
-       if (i>dfa_allocated) goto skip_accepts;\r
-       for (;;) {\r
-               int accept=0;   /* MR14a - Manuel Kessler (mlkessle@cip.physik.uni-wuerzburg.de) */\r
-               set accept_set;\r
-               set nfa_states;\r
-               unsigned int *t, *nfa_i;\r
-               unsigned int *q, *regular_expr;\r
-\r
-               accept_set = empty;\r
-               nfa_states = DFA(i)->nfa_states;\r
-               t = nfa_i = set_pdq(nfa_states);\r
-               /* NOTE: picks lowest accept because accepts monotonic  */\r
-               /*      with respect to nfa node numbers and set_pdq    */\r
-               /*      returns in that order                           */\r
-               while((*nfa_i != nil) && (!(accept = NFA(*nfa_i)->accept))){\r
-                       nfa_i++;\r
-               }\r
-\r
-               /* figure out if more than one accept state there */\r
-               if (warn_ambig ){\r
-                       set_orel(accept, &accept_set);\r
-                       while(*nfa_i != nil){\r
-                               set_orel(NFA(*nfa_i)->accept, &accept_set);\r
-                               nfa_i++;\r
-                       }\r
-                       /* remove error action from consideration */\r
-                       set_rm(0, accept_set);\r
-\r
-                       if( set_deg(accept_set)>1){\r
-                               fprintf(stderr, "dlg warning: ambiguous regular expression ");\r
-                               q = regular_expr = set_pdq(accept_set);\r
-                               while(*regular_expr != nil){\r
-                                       fprintf(stderr," %d ", *regular_expr);\r
-                                       ++regular_expr;\r
-                               }\r
-                               fprintf(stderr, "\n");\r
-                               free(q);\r
-                       }\r
-               }\r
-\r
-               if ((DFA(i)->alternatives) && (accept != 0)){\r
-                       true_interactive = FALSE;\r
-               }\r
-               fprintf(OUT, "%d, ", accept);\r
-\r
-               /* free up memory before we "break" below -ATG 4/6/95 */\r
-               free(t);\r
-               set_free(accept_set);\r
-\r
-               if ((++i)>dfa_allocated)\r
-                       break;\r
-               if ((++items_on_line)>=MAX_ON_LINE){\r
-                       fprintf(OUT,"\n  ");\r
-                       items_on_line = 0;\r
-               }\r
-/*\r
-               free(t);\r
-               set_free(accept_set);\r
-*/\r
-       }\r
-       /* make sure element for one past (zzerraction) -WEC 12/16/92 */\r
-skip_accepts:\r
-       fprintf(OUT, "0\n};\n\n");\r
-}\r
-\r
-\r
-#ifdef __USE_PROTOS\r
-void p_action_table(void)\r
-#else\r
-void p_action_table()\r
-#endif\r
-{\r
-       register int    i;\r
-       char* theClassName = ClassName("");\r
-\r
-       if ( gen_cpp )\r
-               fprintf(OUT, "Ptr%sMemberFunc %s::actions[%d] = {\n", theClassName,\r
-                                       theClassName, action_no+1);\r
-       else\r
-               fprintf(OUT, "void (*actions[%d])() = {\n", action_no+1);\r
-       if ( gen_cpp )\r
-/*             fprintf(OUT, "\t(Ptr%sMemberFunc)&%s::erraction,\n", theClassName, theClassName);*/\r
-               fprintf(OUT, "\t&%s::erraction,\n", theClassName);\r
-       else\r
-               fprintf(OUT, "\tzzerraction,\n");\r
-       for (i=1; i<action_no; ++i) {\r
-               if ( gen_cpp )\r
-/*                     fprintf(OUT,"\t(Ptr%sMemberFunc)&%s::act%d,\n", theClassName, theClassName, i);*/\r
-                       fprintf(OUT,"\t&%s::act%d,\n", theClassName, i);\r
-               else\r
-                       fprintf(OUT,"\tact%d,\n", i);\r
-               DAWDLE;\r
-       }\r
-       if ( gen_cpp )\r
-/*             fprintf(OUT,"\t(Ptr%sMemberFunc)&%s::act%d\n", theClassName, theClassName, i);*/\r
-               fprintf(OUT,"\t&%s::act%d\n", theClassName, i);\r
-       else\r
-               fprintf(OUT,"\tact%d\n", i);\r
-       fprintf(OUT, "};\n\n");\r
-}\r
-\r
-\r
-#ifdef __USE_PROTOS\r
-void p_shift_table(int m)                                  /* MR1 */\r
-#else\r
-void p_shift_table(m)                                          /* MR1 */\r
-int m;\r
-#endif\r
-{\r
-       register int    i = 0, j;\r
-       register int    items_on_line = 0;\r
-\r
-       fprintf(OUT, "%s unsigned char %sshift%d[%d] = {\n  ",\r
-               gen_cpp?"":"static",\r
-               gen_cpp?ClassName("::"):"", m, CHAR_RANGE);\r
-       for (;;) {\r
-               /* find which partition character i is in */\r
-               for (j=0; j<dfa_class_nop[mode_counter]; ++j){\r
-                       if (set_el(i,class_sets[j]))\r
-                               break;\r
-                       }\r
-               fprintf(OUT,"%d",j);\r
-               if ((++i)>=CHAR_RANGE)\r
-                       break;\r
-               fprintf(OUT,", ");\r
-               if ((++items_on_line)>=MAX_ON_LINE){\r
-                       fprintf(OUT,"\n  ");\r
-                       items_on_line = 0;\r
-                       }\r
-               }\r
-       fprintf(OUT, "\n};\n\n");\r
-}\r
-\r
-\r
-#ifdef __USE_PROTOS\r
-void p_base_table(void)\r
-#else\r
-void p_base_table()\r
-#endif\r
-{\r
-       register int m;\r
-\r
-       fprintf(OUT, "%sDfaState %sdfa_base[] = {\n",\r
-                       gen_cpp?ClassName("::"):"static ",\r
-                       gen_cpp?ClassName("::"):"");\r
-       for(m=0; m<(mode_counter-1); ++m)\r
-               fprintf(OUT, "\t%d,\n", dfa_basep[m]-1);\r
-       fprintf(OUT, "\t%d\n};\n\n", dfa_basep[m]-1);\r
-}\r
-\r
-\r
-#ifdef __USE_PROTOS\r
-void p_class_table(void)                               /* MR1 */\r
-#else\r
-void p_class_table()                                           /* MR1 */\r
-#endif\r
-{\r
-#if 0\r
-       register int m;\r
-\r
-       fprintf(OUT,"%s int %sdfa_class_no[] = {\n",\r
-                       gen_cpp?"":"static",\r
-                       gen_cpp?ClassName("::"):"");\r
-       for(m=0; m<(mode_counter-1); ++m)\r
-               fprintf(OUT,"\t%d,\n", dfa_class_nop[m]);\r
-       fprintf(OUT,"\t%d\n};\n\n", dfa_class_nop[m]);\r
-#endif\r
-}\r
-\r
-\r
-#ifdef __USE_PROTOS\r
-void p_bshift_table(void)                                      /* MR1 */\r
-#else\r
-void p_bshift_table()                                          /* MR1 */\r
-#endif\r
-{\r
-       register int m;\r
-\r
-       fprintf(OUT,"%s unsigned char *%sb_class_no[] = {\n",\r
-               gen_cpp?"":"static",\r
-               gen_cpp?ClassName("::"):"");\r
-       for(m=0; m<(mode_counter-1); ++m)\r
-               fprintf(OUT, "\tshift%d,\n", m);\r
-       fprintf(OUT, "\tshift%d\n};\n\n", m);\r
-}\r
-\r
-\r
-#ifdef __USE_PROTOS\r
-void p_alternative_table(void)                         /* MR1 */\r
-#else\r
-void p_alternative_table()                                     /* MR1 */\r
-#endif\r
-{\r
-       register int i;\r
-\r
-       if ( !gen_cpp ) fprintf(OUT, "#define ZZINTERACTIVE\n\n");\r
-       if ( gen_cpp )\r
-               fprintf(OUT, "DLGChar %salternatives[%d] = {\n",  /* mr23 vhs %sDfaStates+1 */\r
-                               ClassName("::"),\r
-                               dfa_allocated+1); /* vhs ClassName("::")); */\r
-       else\r
-               fprintf(OUT, "static %s zzalternatives[DfaStates+1] = {\n",\r
-                               minsize(dfa_allocated));\r
-\r
-       for(i=1; i<=dfa_allocated; ++i)\r
-               fprintf(OUT, "\t%d,\n", DFA(i)->alternatives);\r
-       fprintf(OUT, "/* must have 0 for zzalternatives[DfaStates] */\n");\r
-       fprintf(OUT, "\t0\n};\n\n");\r
-}\r
-\r
-\r
-#ifdef __USE_PROTOS\r
-void p_mode_def(char *s,int m)                 /* MR1 */\r
-#else\r
-void p_mode_def(s,m)                                   /* MR1 */\r
-char *s;\r
-int m;\r
-#endif\r
-{\r
-       if ( gen_cpp )\r
-       {\r
-               mode_name[cur_mode] = mystrdup(s);\r
-               mode_number[cur_mode] = m;\r
-               cur_mode++;\r
-       }\r
-       else\r
-               fprintf(mode_stream, "#define %s %d\n", s, m);\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-char * ClassName(char *suffix)\r
-#else\r
-char * ClassName(suffix)\r
-char *suffix;\r
-#endif\r
-{\r
-       static char buf[200];\r
-       extern char *class_name;\r
-\r
-       sprintf(buf, "%s%s", class_name, suffix);\r
-       return buf;\r
-}\r
-\r
-#ifdef DEBUG\r
-\r
-/* print out a particular nfa node that is pointed to by p */\r
-\r
-#ifdef __USE_PROTOS\r
-void p_nfa_node(nfa_node *p)\r
-#else\r
-void p_nfa_node(p)\r
-nfa_node *p;\r
-#endif\r
-{\r
-        register nfa_node *t;\r
-\r
-       if (p != NIL_INDEX){\r
-               printf("NFA state : %d\naccept state : %d\n",\r
-                       NFA_NO(p),p->accept);\r
-               if (p->trans[0] != NIL_INDEX){\r
-                       printf("trans[0] => %d on ", NFA_NO(p->trans[0]));\r
-                       p_set(p->label);\r
-                       printf("\n");\r
-                       }\r
-               else\r
-                       printf("trans[0] => nil\n");\r
-               if (p->trans[1] != NIL_INDEX)\r
-                       printf("trans[1] => %d on epsilon\n",\r
-                               NFA_NO(p->trans[1]));\r
-               else\r
-                       printf("trans[1] => nil\n");\r
-               printf("\n");\r
-               }\r
-}\r
-#endif\r
-\r
-#ifdef  DEBUG\r
-\r
-/* code to print out special structures when using a debugger */\r
-\r
-#ifdef __USE_PROTOS\r
-void p_nfa(p)\r
-#else\r
-void p_nfa(nfa_node *p)\r
-nfa_node *p;   /* state number also index into array */\r
-#endif\r
-{\r
-/* each node has a marker on it so it only gets printed once */\r
-\r
-       operation_no++; /* get new number */\r
-       s_p_nfa(p);\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-void s_p_nfa(nfa_node *p)\r
-#else\r
-void s_p_nfa(p)\r
-nfa_node *p;   /* state number also index into array */\r
-#endif\r
-{\r
-       if ((p != NIL_INDEX) && (p->nfa_set != operation_no)){\r
-               /* so it is only printed once */\r
-               p->nfa_set = operation_no;\r
-               p_nfa_node(p);\r
-               s_p_nfa(p->trans[0]);\r
-               s_p_nfa(p->trans[1]);\r
-               }\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-void p_dfa_node(dfa_node *p)\r
-#else\r
-void p_dfa_node(p)\r
-dfa_node *p;\r
-#endif\r
-{\r
-       int i;\r
-\r
-       if (p != NIL_INDEX){\r
-               printf("DFA state :%d\n",NFA_NO(p));\r
-               if (p->done)\r
-                       printf("done\n");\r
-               else\r
-                       printf("undone\n");\r
-               printf("from nfa states : ");\r
-               p_set(p->nfa_states);\r
-               printf("\n");\r
-               /* NOTE: trans arcs stored as ints rather than pointer*/\r
-               for (i=0; i<class_no; i++){\r
-                       printf("%d ",p->trans[i]);\r
-                       }\r
-               printf("\n\n");\r
-               }\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-void p_dfa(void)\r
-#else\r
-void p_dfa()\r
-#endif\r
-{\r
-/* prints out all the dfa nodes actually allocated */\r
-\r
-       int i;\r
-\r
-       for (i = 1; i<=dfa_allocated; i++)\r
-               p_dfa_node(NFA(i));\r
-}\r
-\r
-\r
-/* print out numbers in the set label */\r
-\r
-#ifdef __USE_PROTOS\r
-void p_set(set label)\r
-#else\r
-void p_set(label)\r
-set label;\r
-#endif\r
-{\r
-       unsigned *t, *e;\r
-\r
-       if (set_nil(label)){\r
-               printf("epsilon\n");\r
-       }else{\r
-               t = e = set_pdq(label);\r
-               while(*e != nil){\r
-                       printf("%d ", (*e+MIN_CHAR));\r
-                       e++;\r
-               }\r
-               printf("\n");\r
-               free(t);\r
-       }\r
-       \r
-}\r
-#endif\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/dlg/parser.dlg b/Tools/CodeTools/TianoTools/Pccts/dlg/parser.dlg
deleted file mode 100644 (file)
index df9a637..0000000
+++ /dev/null
@@ -1,398 +0,0 @@
-<<\r
-/* parser.dlg -- DLG Description of scanner\r
- *\r
- * Generated from: dlg_p.g\r
- *\r
- * Terence Parr, Will Cohen, and Hank Dietz: 1989-2001\r
- * Purdue University Electrical Engineering\r
- * With AHPCRC, University of Minnesota\r
- * ANTLR Version 1.33MR33\r
- */\r
-\r
-#define ANTLR_VERSION  13333\r
-#include "pcctscfg.h"\r
-#include "pccts_stdio.h"\r
-\r
-#include <ctype.h>\r
-#include "dlg.h"\r
-#include "antlr.h"\r
-#include "tokens.h"\r
-#include "dlgdef.h"\r
-LOOKAHEAD\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-zzerraction(void)\r
-#else\r
-zzerraction()\r
-#endif\r
-{\r
-       (*zzerr)("invalid token");\r
-       zzadvance();\r
-       zzskip();\r
-}\r
->>\r
-\r
-<<%%lexaction\r
-\r
-int    func_action;            /* should actions be turned into functions?*/\r
-int    lex_mode_counter = 0;   /* keeps track of the number of %%names */\r
-/* MR1                                                                     */\r
-/* MR1  11-Apr-97      Provide mechanism for inserting code into DLG class */\r
-/* MR1                         via <<%%lexmember...>>                      */\r
-/* MR1                                                                     */\r
-int    lexMember = 0;          /* <<%%lexmemeber ...>>                 MR1 */\r
-int    lexAction = 0;          /* <<%%lexaction ...>>                  MR1 */\r
-int    parserClass = 0;        /* <<%%parserclass ...>>        MR1 */\r
-int    lexPrefix = 0;          /* <<%%lexprefix ...>>                  MR1 */\r
-char   theClassName[100];                                                   /* MR11 */\r
-char   *pClassName=theClassName;                                        /* MR11 */\r
-int    firstLexMember=1;                                                    /* MR1 */\r
-\r
-#ifdef __USE_PROTOS\r
-void  xxputc(int c) {                                          /* MR1 */\r
-#else\r
-  void xxputc(c)                                                       /* MR1 */\r
-  int  c;                                                      /* MR1 */\r
-  {                                                            /* MR1 */\r
-#endif\r
-    if (parserClass) {                                         /* MR1 */\r
-      *pClassName++=c;                                         /* MR1 */\r
-      *pClassName=0;                                           /* MR1 */\r
-    } else if (lexMember || lexPrefix) {                               /* MR1 */\r
-      if (class_stream != NULL) fputc(c,class_stream);         /* MR1 */\r
-    } else {                                                   /* MR1 */\r
-      fputc(c,OUT);                                            /* MR1 */\r
-    };                                                         /* MR1 */\r
-  }                                                            /* MR1 */\r
-  \r
-#ifdef __USE_PROTOS\r
-  void xxprintf(char *format,char *string) {                   /* MR1 */\r
-#else\r
-    void xxprintf(format,string)                                       /* MR1 */\r
-    char *format;                                                      /* MR1 */\r
-    char *string;                                                      /* MR1 */\r
-    {                                                          /* MR1 */\r
-#endif\r
-      if (lexMember || lexPrefix || parserClass) {                     /* MR1 */\r
-        if (class_stream != NULL)                                      /* MR1 */\r
-        fprintf(class_stream,format,string);                   /* MR1 */\r
-      } else {                                                 /* MR1 */\r
-        fprintf(OUT,format,string);                                    /* MR1 */\r
-      };                                                               /* MR1 */\r
-    }                                                                  /* MR1 */\r
->>\r
-\r
-\r
-%%START\r
-\r
-@\r
-       <<\r
-               NLA = 1;\r
-       >>\r
-\r
-[\r\t\ ]+\r
-       <<\r
-               NLA = 2;\r
-    zzskip();   \r
-       >>\r
-\r
-\n\r
-       <<\r
-               NLA = 3;\r
-    zzline++; zzskip(); DAWDLE;   \r
-       >>\r
-\r
-\@\r
-       <<\r
-               NLA = L_EOF;\r
-       >>\r
-\r
-\%\%\r
-       <<\r
-               NLA = PER_PER;\r
-       >>\r
-\r
-\%\%[a-zA-Z_][a-zA-Z0-9_]*\r
-       <<\r
-               NLA = NAME_PER_PER;\r
-    p_mode_def(&zzlextext[2],lex_mode_counter++);   \r
-       >>\r
-\r
-\<\<\%\%lexmember\r
-       <<\r
-               NLA = LEXMEMBER;\r
-    lexMember=1;                                       /* MR1 */\r
-    if (firstLexMember != 0) {                 /* MR1 */\r
-      firstLexMember=0;                                /* MR1 */\r
-      p_class_def1();                          /* MR1 */\r
-    };                                         /* MR1 */\r
-    zzmode(ACT);                                       /* MR1 */\r
-       >>\r
-\r
-\<\<\%\%lexaction\r
-       <<\r
-               NLA = LEXACTION;\r
-    lexAction=1;zzmode(ACT);  \r
-       >>\r
-\r
-\<\<\%\%parserclass\r
-       <<\r
-               NLA = PARSERCLASS;\r
-    parserClass=1;                             /* MR1 */\r
-    zzmode(ACT);                                       /* MR1 */\r
-       >>\r
-\r
-\<\<\%\%lexprefix\r
-       <<\r
-               NLA = LEXPREFIX;\r
-    lexPrefix=1;zzmode(ACT);  \r
-       >>\r
-\r
-\<\<\r
-       <<\r
-               NLA = ACTION;\r
-    if (func_action)\r
-    fprintf(OUT,"\n%s %sact%d()\n{ ",\r
-    gen_cpp?"ANTLRTokenType":"static void",\r
-    gen_cpp?ClassName("::"):"", ++action_no);\r
-    zzmode(ACT); zzskip();\r
-       >>\r
-\r
-\>\>\r
-       <<\r
-               NLA = GREAT_GREAT;\r
-       >>\r
-\r
-\{\r
-       <<\r
-               NLA = L_BRACE;\r
-       >>\r
-\r
-\}\r
-       <<\r
-               NLA = R_BRACE;\r
-       >>\r
-\r
-\(\r
-       <<\r
-               NLA = L_PAR;\r
-       >>\r
-\r
-\)\r
-       <<\r
-               NLA = R_PAR;\r
-       >>\r
-\r
-\[\r
-       <<\r
-               NLA = L_BRACK;\r
-       >>\r
-\r
-\]\r
-       <<\r
-               NLA = R_BRACK;\r
-       >>\r
-\r
-\*\r
-       <<\r
-               NLA = ZERO_MORE;\r
-       >>\r
-\r
-\+\r
-       <<\r
-               NLA = ONE_MORE;\r
-       >>\r
-\r
-\|\r
-       <<\r
-               NLA = OR;\r
-       >>\r
-\r
-\-\r
-       <<\r
-               NLA = RANGE;\r
-       >>\r
-\r
-\~\r
-       <<\r
-               NLA = NOT;\r
-       >>\r
-\r
-\\0[0-7]*\r
-       <<\r
-               NLA = OCTAL_VALUE;\r
-    {int t; sscanf(&zzlextext[1],"%o",&t); zzlextext[0] = t;}  \r
-       >>\r
-\r
-\\0[Xx][0-9a-fA-F]+\r
-       <<\r
-               NLA = HEX_VALUE;\r
-    {int t; sscanf(&zzlextext[3],"%x",&t); zzlextext[0] = t;}  \r
-       >>\r
-\r
-\\[1-9][0-9]*\r
-       <<\r
-               NLA = DEC_VALUE;\r
-    {int t; sscanf(&zzlextext[1],"%d",&t); zzlextext[0] = t;}  \r
-       >>\r
-\r
-\\t\r
-       <<\r
-               NLA = TAB;\r
-    zzlextext[0] = '\t';  \r
-       >>\r
-\r
-\\n\r
-       <<\r
-               NLA = NL;\r
-    zzlextext[0] = '\n';  \r
-       >>\r
-\r
-\\r\r
-       <<\r
-               NLA = CR;\r
-    zzlextext[0] = '\r';  \r
-       >>\r
-\r
-\\b\r
-       <<\r
-               NLA = BS;\r
-    zzlextext[0] = '\b';  \r
-       >>\r
-\r
-\\ \n\r
-       <<\r
-               NLA = CONTINUATION;\r
-    zzline++; zzskip();  \r
-       >>\r
-\r
-\\~[tnrb]\r
-       <<\r
-               NLA = LIT;\r
-    zzlextext[0] = zzlextext[1];  \r
-       >>\r
-\r
-~[\\]\r
-       <<\r
-               NLA = REGCHAR;\r
-       >>\r
-\r
-\r
-%%ACT\r
-\r
-@\r
-       <<\r
-               NLA = 1;\r
-    error("unterminated action", zzline); zzmode(START);   \r
-       >>\r
-\r
-\>\>\r
-       <<\r
-               NLA = ACTION;\r
-    if (func_action) fprintf(OUT,"}\n\n");\r
-    zzmode(START);\r
-    /* MR1                                                                         */\r
-    /* MR1  11-Apr-97  Provide mechanism for inserting code into DLG class */\r
-    /* MR1                             via <<%%lexmember ...>>                     */\r
-    /* MR1                     This is a consequence of not saving actions         */\r
-    /* MR1                                                                         */\r
-    /* MR1 */     parserClass=0;               \r
-    /* MR1 */     lexPrefix=0;\r
-    /* MR1 */     lexAction=0;\r
-    /* MR1 */     lexMember=0;\r
-       >>\r
-\r
-\>\r
-       <<\r
-               NLA = 34;\r
-    xxputc(zzlextext[0]); zzskip();   \r
-       >>\r
-\r
-\\\>\r
-       <<\r
-               NLA = 35;\r
-    xxputc('>'); zzskip();   \r
-       >>\r
-\r
-\\\r
-       <<\r
-               NLA = 36;\r
-    xxputc('\\'); zzskip();   \r
-       >>\r
-\r
-\n\r
-       <<\r
-               NLA = 37;\r
-    xxputc(zzlextext[0]); ++zzline; zzskip();   \r
-       >>\r
-\r
-/\*\r
-       <<\r
-               NLA = 38;\r
-    zzmode(ACTION_COMMENTS);                   /* MR1 */\r
-    xxprintf("%s", &(zzlextext[0])); zzskip(); /* MR1 */\r
-       >>\r
-\r
-//\r
-       <<\r
-               NLA = 39;\r
-    zzmode(ACTION_CPP_COMMENTS);                       /* MR1 */\r
-    xxprintf("%s", &(zzlextext[0])); zzskip(); /* MR1 */\r
-       >>\r
-\r
-~[]\r
-       <<\r
-               NLA = 40;\r
-    xxputc(zzlextext[0]); zzskip();   \r
-       >>\r
-\r
-\r
-%%ACTION_COMMENTS\r
-\r
-@\r
-       <<\r
-               NLA = 1;\r
-       >>\r
-\r
-\*/\r
-       <<\r
-               NLA = 41;\r
-    zzmode(ACT);                                       /* MR1 */\r
-    xxprintf("%s", &(zzlextext[0])); zzskip(); /* MR1 */\r
-       >>\r
-\r
-[\n\r]\r
-       <<\r
-               NLA = 42;\r
-    zzline++; xxputc(zzlextext[0]); zzskip();  \r
-       >>\r
-\r
-~[]\r
-       <<\r
-               NLA = 43;\r
-    xxputc(zzlextext[0]); zzskip();  \r
-       >>\r
-\r
-\r
-%%ACTION_CPP_COMMENTS\r
-\r
-@\r
-       <<\r
-               NLA = 1;\r
-       >>\r
-\r
-[\n\r]\r
-       <<\r
-               NLA = 44;\r
-    zzmode(ACT); zzline++;                     /* MR1 */\r
-    xxprintf("%s", &(zzlextext[0])); zzskip(); /* MR1 */\r
-       >>\r
-\r
-~[]\r
-       <<\r
-               NLA = 45;\r
-    xxputc(zzlextext[0]); zzskip();  \r
-       >>\r
-\r
-%%\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/dlg/relabel.c b/Tools/CodeTools/TianoTools/Pccts/dlg/relabel.c
deleted file mode 100644 (file)
index 0b8bc16..0000000
+++ /dev/null
@@ -1,217 +0,0 @@
-/* This group of functions does the character class compression.\r
-   It goes over the dfa and relabels the arcs with the partitions\r
-   of characters in the NFA.  The partitions are stored in the\r
-   array class.\r
-\r
- *\r
- * SOFTWARE RIGHTS\r
- *\r
- * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
- * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
- * company may do whatever they wish with source code distributed with\r
- * PCCTS or the code generated by PCCTS, including the incorporation of\r
- * PCCTS, or its output, into commerical software.\r
- *\r
- * We encourage users to develop software with PCCTS.  However, we do ask\r
- * that credit is given to us for developing PCCTS.  By "credit",\r
- * we mean that if you incorporate our source code into one of your\r
- * programs (commercial product, research project, or otherwise) that you\r
- * acknowledge this fact somewhere in the documentation, research report,\r
- * etc...  If you like PCCTS and have developed a nice tool with the\r
- * output, please mention that you developed it using PCCTS.  In\r
- * addition, we ask that this header remain intact in our source code.\r
- * As long as these guidelines are kept, we expect to continue enhancing\r
- * this system and expect to make other tools available as they are\r
- * completed.\r
- *\r
- * DLG 1.33\r
- * Will Cohen\r
- * With mods by Terence Parr; AHPCRC, University of Minnesota\r
- * 1989-2001\r
- */\r
-\r
-#include <stdio.h>\r
-#include "dlg.h"\r
-#ifdef MEMCHK\r
-#include "trax.h"\r
-#else\r
-#ifdef __STDC__\r
-#include <stdlib.h>\r
-#else\r
-#include <malloc.h>\r
-#endif /* __STDC__ */\r
-#endif\r
-\r
-int    class_no = CHAR_RANGE;  /* number of classes for labels */\r
-int    first_el[CHAR_RANGE];   /* first element in each class partition */\r
-set    class_sets[CHAR_RANGE]; /* array holds partitions from class */\r
-                               /* compression */\r
-\r
-/* goes through labels on NFA graph and partitions the characters into\r
- * character classes.  This reduces the amount of space required for each\r
- * dfa node, since only one arc is required each class instead of one arc\r
- * for each character\r
- * level:\r
- * 0 no compression done\r
- * 1 remove unused characters from classes\r
- * 2 compress equivalent characters into same class\r
- *\r
- * returns the number of character classes required\r
- */\r
-#ifdef __USE_PROTOS\r
-int relabel(nfa_node* start,int level)\r
-#else\r
-int relabel(start,level)\r
-int level;\r
-nfa_node *start;\r
-#endif\r
-{\r
-       if (level){\r
-               set_free(used_classes); \r
-               partition(start,level);\r
-               label_with_classes(start);\r
-       }else{\r
-               /* classes equivalent to all characters in alphabet */\r
-               class_no = CHAR_RANGE;\r
-       }\r
-       return class_no;\r
-}\r
-\r
-/* makes character class sets for new labels */\r
-#ifdef __USE_PROTOS\r
-void partition(nfa_node* start,int level)\r
-#else\r
-void partition(start,level)\r
-nfa_node       *start; /* beginning of nfa graph */\r
-int            level;  /* compression level to uses */\r
-#endif\r
-{\r
-       set current_class;\r
-       set unpart_chars;\r
-       set temp;\r
-\r
-       unpart_chars = set_dup(used_chars);\r
-#if 0\r
-       /* EOF (-1+1) alway in class 0 */\r
-       class_sets[0] = set_of(0);\r
-       first_el[0] = 0;\r
-       used_classes = set_of(0);\r
-       temp = set_dif(unpart_chars, class_sets[0]);\r
-       set_free(unpart_chars);\r
-       unpart_chars = temp;\r
-       class_no = 1;\r
-#else\r
-       class_no = 0;\r
-#endif\r
-       while (!set_nil(unpart_chars)){\r
-               /* don't look for equivalent labels if c <= 1 */\r
-               if (level <= 1){\r
-                       current_class = set_of(set_int(unpart_chars));\r
-               }else{\r
-                       current_class = set_dup(unpart_chars);\r
-                       intersect_nfa_labels(start,&current_class);\r
-               }\r
-               set_orel(class_no,&used_classes);\r
-               first_el[class_no] = set_int(current_class);\r
-               class_sets[class_no] = current_class;\r
-               temp = set_dif(unpart_chars,current_class);\r
-               set_free(unpart_chars);\r
-               unpart_chars = temp;\r
-               ++class_no;\r
-       }\r
-\r
-       /* free unpart_chars -ATG 5/6/95 */\r
-       set_free(unpart_chars);\r
-\r
-#if 0\r
-       /* group all the other unused characters into a class */\r
-       set_orel(class_no,&used_classes);\r
-       first_el[class_no] = set_int(current_class);\r
-       class_sets[class_no] = set_dif(normal_chars,used_chars);\r
-       ++class_no;\r
-#endif\r
-}\r
-\r
-\r
-/* given pointer to beginning of graph and recursively walks it trying\r
- * to find a maximal partition.  This partion in returned in maximal_class\r
- */\r
-#ifdef __USE_PROTOS\r
-void intersect_nfa_labels(nfa_node* start,set* maximal_class)\r
-#else\r
-void intersect_nfa_labels(start,maximal_class)\r
-nfa_node *start;\r
-set *maximal_class;\r
-#endif\r
-{\r
-       /* pick a new operation number */\r
-       ++operation_no;\r
-       r_intersect(start,maximal_class);       \r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-void r_intersect(nfa_node* start,set* maximal_class)\r
-#else\r
-void r_intersect(start,maximal_class)\r
-nfa_node *start;\r
-set * maximal_class;\r
-#endif\r
-{\r
-       set temp;\r
-\r
-       if(start && start->nfa_set != operation_no)\r
-       {\r
-               start->nfa_set = operation_no;\r
-               temp = set_and(*maximal_class,start->label);\r
-               if (!set_nil(temp))\r
-               {\r
-                       set_free(*maximal_class);\r
-                       *maximal_class = temp;\r
-               }else{\r
-                       set_free(temp);\r
-               }\r
-               r_intersect(start->trans[0],maximal_class);\r
-               r_intersect(start->trans[1],maximal_class);\r
-       }\r
-}\r
-\r
-\r
-/* puts class labels in place of old character labels */\r
-#ifdef __USE_PROTOS\r
-void label_with_classes(nfa_node* start)\r
-#else\r
-void label_with_classes(start)\r
-nfa_node *start;\r
-#endif\r
-{\r
-       ++operation_no;\r
-       label_node(start);\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-void label_node(nfa_node *start)\r
-#else\r
-void label_node(start)\r
-nfa_node *start;\r
-#endif\r
-{\r
-       set new_label;\r
-       register int i;\r
-\r
-       /* only do node if it hasn't been done before */\r
-       if (start && start->nfa_set != operation_no){\r
-               start->nfa_set = operation_no;\r
-               new_label = empty;\r
-               for (i = 0; i<class_no; ++i){\r
-                       /* if one element of class in old_label,\r
-                          all elements are. */\r
-                       if (set_el(first_el[i],start->label))\r
-                               set_orel(i,&new_label);\r
-               }\r
-               set_free(start->label);\r
-               start->label = new_label;\r
-               /* do any nodes that can be reached from this one */\r
-               label_node(start->trans[0]);\r
-               label_node(start->trans[1]);\r
-       }\r
-}\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/dlg/stdpccts.h b/Tools/CodeTools/TianoTools/Pccts/dlg/stdpccts.h
deleted file mode 100644 (file)
index 06ec67e..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-#ifndef STDPCCTS_H\r
-#define STDPCCTS_H\r
-/*\r
- * stdpccts.h -- P C C T S  I n c l u d e\r
- *\r
- * Terence Parr, Will Cohen, and Hank Dietz: 1989-2001\r
- * Purdue University Electrical Engineering\r
- * With AHPCRC, University of Minnesota\r
- * ANTLR Version 1.33MR33\r
- */\r
-\r
-#ifndef ANTLR_VERSION\r
-#define ANTLR_VERSION  13333\r
-#endif\r
-\r
-#include "pcctscfg.h"\r
-#include "pccts_stdio.h"\r
-\r
-#include <ctype.h>\r
-#include "dlg.h"\r
-#define zzSET_SIZE 8\r
-#include "antlr.h"\r
-#include "tokens.h"\r
-#include "dlgdef.h"\r
-#include "mode.h"\r
-#endif\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/dlg/support.c b/Tools/CodeTools/TianoTools/Pccts/dlg/support.c
deleted file mode 100644 (file)
index 84fe99d..0000000
+++ /dev/null
@@ -1,240 +0,0 @@
-/*\r
- * SOFTWARE RIGHTS\r
- *\r
- * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
- * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
- * company may do whatever they wish with source code distributed with\r
- * PCCTS or the code generated by PCCTS, including the incorporation of\r
- * PCCTS, or its output, into commerical software.\r
- *\r
- * We encourage users to develop software with PCCTS.  However, we do ask\r
- * that credit is given to us for developing PCCTS.  By "credit",\r
- * we mean that if you incorporate our source code into one of your\r
- * programs (commercial product, research project, or otherwise) that you\r
- * acknowledge this fact somewhere in the documentation, research report,\r
- * etc...  If you like PCCTS and have developed a nice tool with the\r
- * output, please mention that you developed it using PCCTS.  In\r
- * addition, we ask that this header remain intact in our source code.\r
- * As long as these guidelines are kept, we expect to continue enhancing\r
- * this system and expect to make other tools available as they are\r
- * completed.\r
- *\r
- * DLG 1.33\r
- * Will Cohen\r
- * With mods by Terence Parr; AHPCRC, University of Minnesota\r
- * 1989-2001\r
- */\r
-\r
-#include <stdio.h>\r
-#include <string.h>\r
-#include "dlg.h"\r
-#ifdef MEMCHK\r
-#include "trax.h"\r
-#else\r
-#ifdef __STDC__\r
-#include <stdlib.h>\r
-#else\r
-#include <malloc.h>\r
-#endif /* __STDC__ */\r
-#endif\r
-\r
-int    err_found = 0;                  /* indicates whether problem found */\r
-\r
-#ifdef __USE_PROTOS\r
-void internal_error(char *s, char *file,int line)    /* MR9 23-Sep-97 */\r
-#else\r
-void internal_error(s,file,line)    /* MR9 23-Sep-97 */\r
-char *s,*file;\r
-int line;\r
-#endif\r
-{\r
-       fprintf(stderr,s,file,line);\r
-       exit(PCCTS_EXIT_FAILURE);\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-char *dlg_malloc(int bytes,char *file,int line)\r
-#else\r
-char *dlg_malloc(bytes,file,line)\r
-int bytes;\r
-char *file;\r
-int line;\r
-#endif\r
-{\r
-       char *t;\r
-\r
-       t = (char *) malloc(bytes);\r
-       if (!t){\r
-               /* error */\r
-               internal_error("%s(%d): unable to allocate memory\n",\r
-                       file,line);\r
-       }\r
-       return t;\r
-}\r
-\r
-\r
-#ifdef __USE_PROTOS\r
-char *dlg_calloc(int n,int bytes,char *file,int line)\r
-#else\r
-char *dlg_calloc(n,bytes,file,line)\r
-int n,bytes;\r
-char *file;\r
-int line;\r
-#endif\r
-{\r
-       char *t;\r
-\r
-       t = (char *) calloc(n,bytes);\r
-       if (!t){\r
-               /* error */\r
-               internal_error("%s(%d): unable to allocate memory\n",\r
-                       file,line);\r
-       }\r
-       return t;\r
-}\r
-\r
-\r
-#ifdef __USE_PROTOS\r
-FILE *read_stream(char *name)\r
-#else\r
-FILE *read_stream(name)\r
-char *name;\r
-#endif\r
-{\r
-       FILE *f;\r
-\r
-       if (name){\r
-               if (name[0] == '-') {\r
-                       fprintf(stderr, "dlg: invalid option: '%s'\n", name);\r
-                       f = NULL;\r
-               }else{\r
-                       f = fopen(name, "r");\r
-                       if (f == NULL){\r
-                               /* couldn't open file */\r
-                               fprintf(stderr,\r
-                                       "dlg: Warning: Can't read file %s.\n",\r
-                                       name);\r
-                       }\r
-               }\r
-       }else{\r
-               /* open stdin if nothing there */\r
-               f = stdin;\r
-       }\r
-       return f;\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-FILE *write_stream(char *name)\r
-#else\r
-FILE *write_stream(name)\r
-char *name;\r
-#endif\r
-{\r
-       FILE *f;\r
-\r
-       if (name){\r
-               if (name[0] == '-') {\r
-                       fprintf(stderr, "dlg: invalid option: '%s'\n", name);\r
-                       f = NULL;\r
-               }else{\r
-                       f = fopen(OutMetaName(name), "w");\r
-                       if (f == NULL){\r
-                               /* couldn't open file */\r
-                               fprintf(stderr,\r
-                                       "dlg: Warning: Can't write to file %s.\n",\r
-                                       name);\r
-                       }\r
-                       else\r
-#ifdef SPECIAL_FOPEN\r
-                special_fopen_actions(OutMetaName(name));      /* MR1 */\r
-#else\r
-               ;                                               /* MR1 */\r
-#endif\r
-               }\r
-       }else{\r
-               /* open stdout if nothing there */\r
-               f = stdout;\r
-       }\r
-       return f;\r
-}\r
-\r
-\r
-#ifdef __USE_PROTOS\r
-void fatal(char *message,int line_no)\r
-#else\r
-void fatal(message,line_no)\r
-char *message;\r
-int line_no;\r
-#endif\r
-{\r
-       fprintf(stderr,ErrHdr,\r
-               (file_str[0] ? file_str[0] : "stdin"), line_no);\r
-       fprintf(stderr, " Fatal: %s\n", message);\r
-       exit(PCCTS_EXIT_FAILURE);\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-void error(char *message,int line_no)\r
-#else\r
-void error(message,line_no)\r
-char *message;\r
-int line_no;\r
-#endif\r
-{\r
-       fprintf(stderr,ErrHdr,\r
-               (file_str[0] ? file_str[0] : "stdin"), line_no);\r
-       fprintf(stderr, " Error: %s\n", message);\r
-       err_found = 1;\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-void warning(char *message,int line_no)\r
-#else\r
-void warning(message,line_no)\r
-char *message;\r
-int line_no;\r
-#endif\r
-{\r
-       fprintf(stderr,ErrHdr,\r
-               (file_str[0] ? file_str[0] : "stdin"), line_no);\r
-       fprintf(stderr, " Warning: %s\n", message);\r
-}\r
-\r
-/* MR10: Jeff Vincent\r
-   MR10: Changed to remove directory information from n only if\r
-   MR10: if OutputDirectory was changed by user (-o option)\r
-*/\r
-\r
-#ifdef __USE_PROTOS\r
-char *OutMetaName(char *n)\r
-#else\r
-char *OutMetaName(n)\r
-char *n;\r
-#endif\r
-{      \r
-    static char *dir_sym = DirectorySymbol;\r
-    static char newname[MaxFileName+1];\r
-    char *p;\r
-\r
-       /* If OutputDirectory is same as TopDirectory (platform default) then leave n alone. */\r
-    if (strcmp(OutputDirectory, TopDirectory) == 0)\r
-               return n;\r
-\r
-       /* p will point to filename without path information */\r
-       if ((p = strrchr(n, *dir_sym)) != NULL)\r
-               p++;\r
-       else\r
-               p = n;\r
-\r
-       /* Copy new output directory into newname[] */\r
-       strcpy(newname, OutputDirectory);\r
-\r
-       /* if new output directory does not have trailing dir_sym, add it! */\r
-       if (newname[strlen(newname)-1] != *dir_sym)\r
-               strcat(newname, dir_sym);\r
-\r
-       /* contatenate FILE NAME ONLY to new output directory */\r
-       strcat(newname, p);\r
-\r
-       return newname;\r
-}\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/dlg/tokens.h b/Tools/CodeTools/TianoTools/Pccts/dlg/tokens.h
deleted file mode 100644 (file)
index 73e502b..0000000
+++ /dev/null
@@ -1,133 +0,0 @@
-#ifndef tokens_h\r
-#define tokens_h\r
-/* tokens.h -- List of labelled tokens and stuff\r
- *\r
- * Generated from: dlg_p.g\r
- *\r
- * Terence Parr, Will Cohen, and Hank Dietz: 1989-2001\r
- * Purdue University Electrical Engineering\r
- * ANTLR Version 1.33MR33\r
- */\r
-#define zzEOF_TOKEN 1\r
-#define L_EOF 4\r
-#define PER_PER 5\r
-#define NAME_PER_PER 6\r
-#define LEXMEMBER 7\r
-#define LEXACTION 8\r
-#define PARSERCLASS 9\r
-#define LEXPREFIX 10\r
-#define ACTION 11\r
-#define GREAT_GREAT 12\r
-#define L_BRACE 13\r
-#define R_BRACE 14\r
-#define L_PAR 15\r
-#define R_PAR 16\r
-#define L_BRACK 17\r
-#define R_BRACK 18\r
-#define ZERO_MORE 19\r
-#define ONE_MORE 20\r
-#define OR 21\r
-#define RANGE 22\r
-#define NOT 23\r
-#define OCTAL_VALUE 24\r
-#define HEX_VALUE 25\r
-#define DEC_VALUE 26\r
-#define TAB 27\r
-#define NL 28\r
-#define CR 29\r
-#define BS 30\r
-#define CONTINUATION 31\r
-#define LIT 32\r
-#define REGCHAR 33\r
-\r
-#ifdef __USE_PROTOS\r
-void grammar(void);\r
-#else\r
-extern void grammar();\r
-#endif\r
-\r
-#ifdef __USE_PROTOS\r
-void start_states(void);\r
-#else\r
-extern void start_states();\r
-#endif\r
-\r
-#ifdef __USE_PROTOS\r
-void do_conversion(void);\r
-#else\r
-extern void do_conversion();\r
-#endif\r
-\r
-#ifdef __USE_PROTOS\r
-void rule_list(void);\r
-#else\r
-extern void rule_list();\r
-#endif\r
-\r
-#ifdef __USE_PROTOS\r
-void rule(void);\r
-#else\r
-extern void rule();\r
-#endif\r
-\r
-#ifdef __USE_PROTOS\r
-void reg_expr(void);\r
-#else\r
-extern void reg_expr();\r
-#endif\r
-\r
-#ifdef __USE_PROTOS\r
-void and_expr(void);\r
-#else\r
-extern void and_expr();\r
-#endif\r
-\r
-#ifdef __USE_PROTOS\r
-void repeat_expr(void);\r
-#else\r
-extern void repeat_expr();\r
-#endif\r
-\r
-#ifdef __USE_PROTOS\r
-void expr(void);\r
-#else\r
-extern void expr();\r
-#endif\r
-\r
-#ifdef __USE_PROTOS\r
-void atom_list(void);\r
-#else\r
-extern void atom_list();\r
-#endif\r
-\r
-#ifdef __USE_PROTOS\r
-void near_atom(void);\r
-#else\r
-extern void near_atom();\r
-#endif\r
-\r
-#ifdef __USE_PROTOS\r
-void atom(void);\r
-#else\r
-extern void atom();\r
-#endif\r
-\r
-#ifdef __USE_PROTOS\r
-void anychar(void);\r
-#else\r
-extern void anychar();\r
-#endif\r
-\r
-#endif\r
-extern SetWordType zzerr1[];\r
-extern SetWordType zzerr2[];\r
-extern SetWordType zzerr3[];\r
-extern SetWordType setwd1[];\r
-extern SetWordType zzerr4[];\r
-extern SetWordType zzerr5[];\r
-extern SetWordType zzerr6[];\r
-extern SetWordType setwd2[];\r
-extern SetWordType zzerr7[];\r
-extern SetWordType zzerr8[];\r
-extern SetWordType zzerr9[];\r
-extern SetWordType setwd3[];\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/h/AParser.cpp b/Tools/CodeTools/TianoTools/Pccts/h/AParser.cpp
deleted file mode 100644 (file)
index 720fe75..0000000
+++ /dev/null
@@ -1,871 +0,0 @@
-/* ANTLRParser.C\r
- *\r
- * SOFTWARE RIGHTS\r
- *\r
- * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
- * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
- * company may do whatever they wish with source code distributed with\r
- * PCCTS or the code generated by PCCTS, including the incorporation of\r
- * PCCTS, or its output, into commerical software.\r
- *\r
- * We encourage users to develop software with PCCTS.  However, we do ask\r
- * that credit is given to us for developing PCCTS.  By "credit",\r
- * we mean that if you incorporate our source code into one of your\r
- * programs (commercial product, research project, or otherwise) that you\r
- * acknowledge this fact somewhere in the documentation, research report,\r
- * etc...  If you like PCCTS and have developed a nice tool with the\r
- * output, please mention that you developed it using PCCTS.  In\r
- * addition, we ask that this header remain intact in our source code.\r
- * As long as these guidelines are kept, we expect to continue enhancing\r
- * this system and expect to make other tools available as they are\r
- * completed.\r
- *\r
- * ANTLR 1.33\r
- * Terence Parr\r
- * Parr Research Corporation\r
- * with Purdue University and AHPCRC, University of Minnesota\r
- * 1989-2000\r
- */\r
-\r
-#include "pcctscfg.h"\r
-\r
-#include "pccts_stdlib.h"\r
-#include "pccts_stdarg.h"\r
-#include "pccts_string.h"\r
-#include "pccts_stdio.h"\r
-\r
-PCCTS_NAMESPACE_STD\r
-\r
-/* I have to put this here due to C++ limitation\r
- * that you can't have a 'forward' decl for enums.\r
- * I hate C++!!!!!!!!!!!!!!!\r
- * Of course, if I could use real templates, this would go away.\r
- */\r
-// MR1\r
-// MR1  10-Apr-97  133MR1  Prevent use of varying sizes for the\r
-// MR1                         ANTLRTokenType enum\r
-// MR1\r
-\r
-enum ANTLRTokenType { TER_HATES_CPP=0, ITS_TOO_COMPLICATED=9999};          // MR1\r
-\r
-#define ANTLR_SUPPORT_CODE\r
-\r
-#include ATOKEN_H\r
-#include ATOKENBUFFER_H\r
-#include APARSER_H\r
-\r
-static const int zzINF_DEF_TOKEN_BUFFER_SIZE = 2000;    /* MR14 */\r
-static const int zzINF_BUFFER_TOKEN_CHUNK_SIZE = 1000;  /* MR14 */\r
-\r
-                 /* L o o k a h e a d  M a c r o s */\r
-\r
-/* maximum of 32 bits/unsigned int and must be 8 bits/byte;\r
- * we only use 8 bits of it.\r
- */\r
-SetWordType ANTLRParser::bitmask[sizeof(SetWordType)*8] = {\r
-       0x00000001, 0x00000002, 0x00000004, 0x00000008,\r
-       0x00000010, 0x00000020, 0x00000040, 0x00000080\r
-};\r
-\r
-char ANTLRParser::eMsgBuffer[500] = "";\r
-\r
-ANTLRParser::\r
-~ANTLRParser()\r
-{\r
-       delete [] token_type;\r
-    delete [] zzFAILtext;       // MR16 Manfred Kogler\r
-}\r
-\r
-ANTLRParser::\r
-ANTLRParser(ANTLRTokenBuffer *_inputTokens,\r
-                       int k,\r
-                       int use_inf_look,\r
-                       int dlook,\r
-                       int ssize)\r
-{\r
-       LLk = k;\r
-       can_use_inf_look = use_inf_look;\r
-/* MR14 */    if (dlook != 0) {\r
-/* MR14 */      panic("ANTLRParser::ANTLRParser - Demand lookahead not supported in C++ mode");\r
-/* MR14 */\r
-/* MR14 */    };\r
-    demand_look = 0;    /* demand_look = dlook; */\r
-    bsetsize = ssize;\r
-       guessing = 0;\r
-       token_tbl = NULL;\r
-       eofToken = (ANTLRTokenType)1;\r
-\r
-       // allocate lookahead buffer\r
-       token_type = new ANTLRTokenType[LLk];\r
-       lap = 0;\r
-       labase = 0;\r
-#ifdef ZZDEFER_FETCH\r
-       stillToFetch = 0;                                                   // MR19\r
-#endif\r
-       dirty = 0;\r
-    inf_labase = 0;                                                     // MR7\r
-    inf_last = 0;                                                       // MR7\r
-       /* prime lookahead buffer, point to inputTokens */\r
-       this->inputTokens = _inputTokens;\r
-       this->inputTokens->setMinTokens(k);\r
-       _inputTokens->setParser(this);                                                      // MR1\r
-    resynchConsumed=1;                                                  // MR8\r
-    zzFAILtext=NULL;                                                    // MR9\r
-    traceOptionValueDefault=0;                                          // MR10\r
-    traceReset();                                                       // MR10\r
-    zzGuessSeq=0;                                                       // MR10\r
-    syntaxErrCount=0;                                                   // MR11\r
-}\r
-\r
-void ANTLRParser::init()\r
-{\r
-   prime_lookahead();\r
-   resynchConsumed=1;                                                   // MR8\r
-   traceReset();                                                        // MR10\r
-}\r
-\r
-void ANTLRParser::traceReset()\r
-{\r
-   traceOptionValue=traceOptionValueDefault;\r
-   traceGuessOptionValue=1;\r
-   traceCurrentRuleName=NULL;\r
-   traceDepth=0;\r
-}\r
-\r
-\r
-#ifdef _MSC_VER  // MR23\r
-//Turn off warning:\r
-//interaction between '_setjmp' and C++ object destruction is non-portable\r
-#pragma warning(disable : 4611)\r
-#endif\r
-int ANTLRParser::\r
-guess(ANTLRParserState *st)\r
-{\r
-       saveState(st);\r
-       guessing = 1;\r
-       return setjmp(guess_start.state);\r
-}\r
-#ifdef _MSC_VER  // MR23\r
-#pragma warning(default: 4611)\r
-#endif\r
-\r
-void ANTLRParser::\r
-saveState(ANTLRParserState *buf)\r
-{\r
-       buf->guess_start = guess_start;\r
-       buf->guessing = guessing;\r
-       buf->inf_labase = inf_labase;\r
-       buf->inf_last = inf_last;\r
-       buf->dirty = dirty;\r
-    buf->traceOptionValue=traceOptionValue;            /* MR10 */\r
-    buf->traceGuessOptionValue=traceGuessOptionValue;  /* MR10 */\r
-    buf->traceCurrentRuleName=traceCurrentRuleName;    /* MR10 */\r
-    buf->traceDepth=traceDepth;                        /* MR10 */\r
-}\r
-\r
-void ANTLRParser::\r
-restoreState(ANTLRParserState *buf)\r
-{\r
-       int     i;\r
-    int     prevTraceOptionValue;\r
-\r
-       guess_start = buf->guess_start;\r
-       guessing = buf->guessing;\r
-       inf_labase = buf->inf_labase;\r
-       inf_last = buf->inf_last;\r
-       dirty = buf->dirty;\r
-\r
-       // restore lookahead buffer from k tokens before restored TokenBuffer position\r
-       // if demand_look, then I guess we don't look backwards for these tokens.\r
-       for (i=1; i<=LLk; i++) token_type[i-1] =\r
-               inputTokens->bufferedToken(i-LLk)->getType();\r
-       lap = 0;\r
-       labase = 0;\r
-\r
-    /* MR10 */\r
-\r
-    prevTraceOptionValue=traceOptionValue;\r
-    traceOptionValue=buf->traceOptionValue;\r
-    if ( (prevTraceOptionValue > 0) !=\r
-             (traceOptionValue > 0)) {\r
-      if (traceCurrentRuleName != NULL) {  /* MR21 */\r
-          if (traceOptionValue > 0) {\r
-            /* MR23 */ printMessage(stderr,\r
-                   "trace enable restored in rule %s depth %d\n",\r
-                   traceCurrentRuleName,\r
-                   traceDepth);\r
-          };\r
-          if (traceOptionValue <= 0) {\r
-            /* MR23 */ printMessage(stderr,\r
-            "trace disable restored in rule %s depth %d\n",\r
-            traceCurrentRuleName, /* MR21 */\r
-            traceDepth);\r
-          };\r
-       }\r
-    };\r
-    traceGuessOptionValue=buf->traceGuessOptionValue;\r
-    traceCurrentRuleName=buf->traceCurrentRuleName;\r
-    traceDepth=buf->traceDepth;\r
-    traceGuessDone(buf);\r
-}\r
-\r
-/* Get the next symbol from the input stream; put it into lookahead buffer;\r
- * fill token_type[] fast reference cache also.  NLA is the next place where\r
- * a lookahead ANTLRAbstractToken should go.\r
- */\r
-void ANTLRParser::\r
-consume()\r
-{\r
-\r
-#ifdef ZZDEBUG_CONSUME_ACTION\r
-    zzdebug_consume_action();\r
-#endif\r
-\r
-// MR19 V.H. Simonis\r
-//      Defer Fetch feature\r
-//      Moves action of consume() into LA() function\r
-\r
-#ifdef ZZDEFER_FETCH\r
-      stillToFetch++;\r
-#else\r
-      NLA = inputTokens->getToken()->getType();\r
-      dirty--;\r
-      lap = (lap+1)&(LLk-1);\r
-#endif\r
-\r
-}\r
-\r
-_ANTLRTokenPtr ANTLRParser::\r
-LT(int i)\r
-{\r
-\r
-// MR19 V.H. Simonis\r
-//      Defer Fetch feature\r
-//      Moves action of consume() into LA() function\r
-\r
-#ifdef ZZDEFER_FETCH\r
-    undeferFetch();\r
-#endif\r
-\r
-#ifdef DEBUG_TOKENBUFFER\r
-       if ( i >= inputTokens->bufferSize() || inputTokens->minTokens() < LLk )     /* MR20 Was "<=" */\r
-       {\r
-               char buf[2000];                 /* MR20 Was "static" */\r
-        sprintf(buf, "The minimum number of tokens you requested that the\nANTLRTokenBuffer buffer is not enough to satisfy your\nLT(%d) request; increase 'k' argument to constructor for ANTLRTokenBuffer\n", i);\r
-               panic(buf);\r
-       }\r
-#endif\r
-       return inputTokens->bufferedToken(i-LLk);\r
-}\r
-\r
-void\r
-ANTLRParser::\r
-look(int k)\r
-{\r
-       int i, c = k - (LLk-dirty);\r
-       for (i=1; i<=c; i++) consume();\r
-}\r
-\r
-/* fill the lookahead buffer up with k symbols (even if DEMAND_LOOK);\r
- */\r
-void\r
-ANTLRParser::\r
-prime_lookahead()\r
-{\r
-       int i;\r
-       for(i=1;i<=LLk; i++) consume();\r
-       dirty=0;\r
-       // lap = 0;     // MR14 Sinan Karasu (sinan.karasu@boeing.com)\r
-       // labase = 0;  // MR14\r
-    labase=lap;     // MR14\r
-}\r
-\r
-/* check to see if the current input symbol matches '_t'.\r
- * During NON demand lookahead mode, dirty will always be 0 and\r
- * hence the extra code for consuming tokens in _match is never\r
- * executed; the same routine can be used for both modes.\r
- */\r
-int ANTLRParser::\r
-_match(ANTLRTokenType _t, ANTLRChar **MissText,\r
-          ANTLRTokenType *MissTok, _ANTLRTokenPtr *BadTok,\r
-          SetWordType **MissSet)\r
-{\r
-       if ( dirty==LLk ) {\r
-               consume();\r
-       }\r
-       if ( LA(1)!=_t ) {\r
-               *MissText=NULL;\r
-               *MissTok= _t;\r
-               *BadTok = LT(1);\r
-               *MissSet=NULL;\r
-               return 0;\r
-       }\r
-       dirty++;\r
-       labase = (labase+1)&(LLk-1);    // labase maintained even if !demand look\r
-       return 1;\r
-}\r
-\r
-/* check to see if the current input symbol matches '_t'.\r
- * Used during exception handling.\r
- */\r
-int ANTLRParser::\r
-_match_wsig(ANTLRTokenType _t)\r
-{\r
-       if ( dirty==LLk ) {\r
-               consume();\r
-       }\r
-       if ( LA(1)!=_t ) return 0;\r
-       dirty++;\r
-       labase = (labase+1)&(LLk-1);    // labase maintained even if !demand look\r
-       return 1;\r
-}\r
-\r
-/* check to see if the current input symbol matches any token in a set.\r
- * During NON demand lookahead mode, dirty will always be 0 and\r
- * hence the extra code for consuming tokens in _match is never\r
- * executed; the same routine can be used for both modes.\r
- */\r
-int ANTLRParser::\r
-_setmatch(SetWordType *tset, ANTLRChar **MissText,\r
-          ANTLRTokenType *MissTok, _ANTLRTokenPtr *BadTok,\r
-          SetWordType **MissSet, SetWordType *tokclassErrset)\r
-{\r
-       if ( dirty==LLk ) {\r
-               consume();\r
-       }\r
-       if ( !set_el(LA(1), tset) ) {\r
-               *MissText=NULL;                                                                         /* MR23 */\r
-               *MissTok=(ANTLRTokenType) 0;                                            /* MR23 */\r
-               *BadTok=LT(1);                                                                          /* MR23 */\r
-               *MissSet=tokclassErrset;                                                        /* MR23 */\r
-               return 0;\r
-       }\r
-       dirty++;\r
-       labase = (labase+1)&(LLk-1);    // labase maintained even if !demand look\r
-       return 1;\r
-}\r
-\r
-int ANTLRParser::\r
-_setmatch_wsig(SetWordType *tset)\r
-{\r
-       if ( dirty==LLk ) {\r
-               consume();\r
-       }\r
-       if ( !set_el(LA(1), tset) ) return 0;\r
-       dirty++;\r
-       labase = (labase+1)&(LLk-1);    // labase maintained even if !demand look\r
-       return 1;\r
-}\r
-\r
-                   /* Exception handling routines */\r
-//\r
-//  7-Apr-97 133MR1\r
-//          Change suggested by Eli Sternheim (eli@interhdl.com)\r
-//\r
-void ANTLRParser::\r
-consumeUntil(SetWordType *st)\r
-{\r
-       ANTLRTokenType          tmp;                                                            // MR1\r
-       const                   int Eof=1;                                          // MR1\r
-       while ( !set_el( (tmp=LA(1)), st) && tmp!=Eof) { consume(); }       // MR1\r
-}\r
-\r
-//\r
-//  7-Apr-97 133MR1\r
-//          Change suggested by Eli Sternheim (eli@interhdl.com)\r
-//\r
-void ANTLRParser::\r
-consumeUntilToken(int t)\r
-{\r
-       int     tmp;                                                            // MR1\r
-       const   int Eof=1;                                                  // MR1\r
-       while ( (tmp=LA(1)) !=t && tmp!=Eof) { consume(); }                 // MR1\r
-}\r
-\r
-\r
-                        /* Old error stuff */\r
-\r
-void ANTLRParser::\r
-resynch(SetWordType *wd,SetWordType mask)\r
-{\r
-\r
-/* MR8              S.Bochnak@microtool.com.pl                          */\r
-/* MR8              Change file scope static "consumed" to instance var */\r
-\r
-       /* if you enter here without having consumed a token from last resynch\r
-        * force a token consumption.\r
-        */\r
-/* MR8 */      if ( !resynchConsumed ) {consume(); resynchConsumed=1; return;}\r
-\r
-       /* if current token is in resynch set, we've got what we wanted */\r
-\r
-/* MR8 */      if ( wd[LA(1)]&mask || LA(1) == eofToken ) {resynchConsumed=0; return;}\r
-       \r
-       /* scan until we find something in the resynch set */\r
-\r
-               while ( !(wd[LA(1)]&mask) && LA(1) != eofToken ) {consume();}\r
-\r
-/* MR8 */      resynchConsumed=1;\r
-}\r
-\r
-/* standard error reporting function that assumes DLG-based scanners;\r
- * you should redefine in subclass to change it or if you use your\r
- * own scanner.\r
- */\r
-\r
-/* MR23 THM There appears to be a parameter "badText" passed to syn()\r
-            which is not present in the parameter list.  This may be\r
-            because in C mode there is no attribute function which\r
-            returns the text, so the text representation of the token\r
-            must be passed explicitly.  I think.\r
-*/\r
-           \r
-void ANTLRParser::\r
-syn(_ANTLRTokenPtr /*tok MR23*/, ANTLRChar *egroup, SetWordType *eset,\r
-       ANTLRTokenType etok, int k)\r
-{\r
-       int line;\r
-\r
-       line = LT(1)->getLine();\r
-\r
-    syntaxErrCount++;                                   /* MR11 */\r
-\r
-    /* MR23  If the token is not an EOF token, then use the ->getText() value.\r
-\r
-             If the token is the EOF token the text returned by ->getText() \r
-             may be garbage.  If the text from the token table is "@" use\r
-             "<eof>" instead, because end-users don't know what "@" means.\r
-             If the text is not "@" then use that text, which must have been\r
-             supplied by the grammar writer.\r
-     */\r
-       const char * errorAt = LT(1)->getText();\r
-       if (LA(1) == eofToken) {\r
-         errorAt = parserTokenName(LA(1));\r
-         if (errorAt[0] == '@') errorAt = "<eof>";\r
-       }\r
-       /* MR23 */ printMessage(stderr, "line %d: syntax error at \"%s\"",\r
-                                       line, errorAt);\r
-       if ( !etok && !eset ) {/* MR23 */ printMessage(stderr, "\n"); return;}\r
-       if ( k==1 ) /* MR23 */ printMessage(stderr, " missing");\r
-       else\r
-       {\r
-               /* MR23 */ printMessage(stderr, "; \"%s\" not", LT(k)->getText()); // MR23 use LT(k) since k>1\r
-               if ( set_deg(eset)>1 ) /* MR23 */ printMessage(stderr, " in");\r
-       }\r
-       if ( set_deg(eset)>0 ) edecode(eset);\r
-       else /* MR23 */ printMessage(stderr, " %s", token_tbl[etok]);\r
-       if ( strlen(egroup) > 0 ) /* MR23 */ printMessage(stderr, " in %s", egroup);\r
-       /* MR23 */ printMessage(stderr, "\n");\r
-}\r
-\r
-/* is b an element of set p? */\r
-int ANTLRParser::\r
-set_el(ANTLRTokenType b, SetWordType *p)\r
-{\r
-       return( p[DIVWORD(b)] & bitmask[MODWORD(b)] );\r
-}\r
-\r
-int ANTLRParser::\r
-set_deg(SetWordType *a)\r
-{\r
-       /* Fast compute degree of a set... the number\r
-          of elements present in the set.  Assumes\r
-          that all word bits are used in the set\r
-       */\r
-       register SetWordType *p = a;\r
-       register SetWordType *endp = &(a[bsetsize]);\r
-       register int degree = 0;\r
-\r
-       if ( a == NULL ) return 0;\r
-       while ( p < endp )\r
-       {\r
-               register SetWordType t = *p;\r
-               register SetWordType *b = &(bitmask[0]);\r
-               do {\r
-                       if (t & *b) ++degree;\r
-               } while (++b < &(bitmask[sizeof(SetWordType)*8]));\r
-               p++;\r
-       }\r
-\r
-       return(degree);\r
-}\r
-\r
-void ANTLRParser::\r
-edecode(SetWordType *a)\r
-{\r
-       register SetWordType *p = a;\r
-       register SetWordType *endp = &(p[bsetsize]);\r
-       register unsigned e = 0;\r
-\r
-       if ( set_deg(a)>1 ) /* MR23 */ printMessage(stderr, " {");\r
-       do {\r
-               register SetWordType t = *p;\r
-               register SetWordType *b = &(bitmask[0]);\r
-               do {\r
-                       if ( t & *b ) /* MR23 */ printMessage(stderr, " %s", token_tbl[e]);\r
-                       e++;\r
-               } while (++b < &(bitmask[sizeof(SetWordType)*8]));\r
-       } while (++p < endp);\r
-       if ( set_deg(a)>1 ) /* MR23 */ printMessage(stderr, " }");\r
-}\r
-\r
-/* input looks like:\r
- *      zzFAIL(k, e1, e2, ...,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk)\r
- * where the zzMiss stuff is set here to the token that did not match\r
- * (and which set wasn't it a member of).\r
- */\r
-\r
-// MR9 29-Sep-97    Stan Bochnak (S.Bochnak@microTool.com.pl)\r
-// MR9              Original fix to static allocated text didn't\r
-// MR9                work because a pointer to it was passed back\r
-// MR9                to caller.  Replace with instance variable.\r
-\r
-const int   SETWORDCOUNT=20;\r
-\r
-void\r
-ANTLRParser::FAIL(int k, ...)\r
-{\r
-//\r
-//  MR1 10-Apr-97      \r
-//\r
-\r
-    if (zzFAILtext == NULL) zzFAILtext=new char [1000];          // MR9\r
-    SetWordType **f=new SetWordType *[SETWORDCOUNT];             // MR1 // MR9\r
-    SetWordType **miss_set;\r
-    ANTLRChar **miss_text;\r
-    _ANTLRTokenPtr *bad_tok;\r
-    ANTLRChar **bad_text;\r
-//\r
-//  7-Apr-97 133MR1\r
-//             err_k is passed as a "int *", not "unsigned *"\r
-//\r
-    int        *err_k;                                                         // MR1\r
-    int i;\r
-    va_list ap;\r
-\r
-    va_start(ap, k);\r
-\r
-    zzFAILtext[0] = '\0';\r
-       if ( k > SETWORDCOUNT ) panic("FAIL: overflowed buffer");\r
-    for (i=1; i<=k; i++)    /* collect all lookahead sets */\r
-    {\r
-        f[i-1] = va_arg(ap, SetWordType *);\r
-    }\r
-    for (i=1; i<=k; i++)    /* look for offending token */\r
-    {\r
-        if ( i>1 ) strcat(zzFAILtext, " ");\r
-        strcat(zzFAILtext, LT(i)->getText());\r
-        if ( !set_el(LA(i), f[i-1]) ) break;\r
-    }\r
-    miss_set = va_arg(ap, SetWordType **);\r
-    miss_text = va_arg(ap, ANTLRChar **);\r
-    bad_tok = va_arg(ap, _ANTLRTokenPtr *);\r
-    bad_text = va_arg(ap, ANTLRChar **);\r
-    err_k = va_arg(ap, int *);                                                         // MR1\r
-    if ( i>k )\r
-    {\r
-        /* bad; lookahead is permutation that cannot be matched,\r
-         * but, the ith token of lookahead is valid at the ith position\r
-         * (The old LL sub 1 (k) versus LL(k) parsing technique)\r
-         */\r
-        *miss_set = NULL;\r
-        *miss_text = LT(1)->getText();\r
-        *bad_tok = LT(1);\r
-        *bad_text = (*bad_tok)->getText();\r
-        *err_k = k;\r
-//\r
-//  MR4 20-May-97      erroneously deleted contents of f[]\r
-//  MR4                                reported by Bruce Guenter (bruceg@qcc.sk.ca)\r
-//  MR1 10-Apr-97      release temporary storage\r
-//\r
-      delete [] f;                                                      // MR1\r
-      return;                                                           // MR1\r
-    }\r
-/*  MR23 printMessage(stderr, "%s not in %dth set\n", zztokens[LA(i)], i);*/\r
-    *miss_set = f[i-1];\r
-    *miss_text = zzFAILtext;\r
-    *bad_tok = LT(i);\r
-    *bad_text = (*bad_tok)->getText();\r
-    if ( i==1 ) *err_k = 1;\r
-    else *err_k = k;\r
-//\r
-//  MR4 20-May-97      erroneously deleted contents of f[]\r
-//  MR4                              reported by Bruce Guenter (bruceg@qcc.sk.ca)\r
-//  MR1 10-Apr-97      release temporary storage\r
-//\r
-    delete [] f;                                                        // MR1\r
-    return;                                                             // MR1\r
-}\r
-\r
-int ANTLRParser::\r
-_match_wdfltsig(ANTLRTokenType tokenWanted, SetWordType *whatFollows)\r
-{\r
-       if ( dirty==LLk ) consume();\r
-\r
-       if ( LA(1)!=tokenWanted )\r
-       {\r
-        syntaxErrCount++;                                   /* MR11 */\r
-               /* MR23 */ printMessage(stderr,\r
-                               "line %d: syntax error at \"%s\" missing %s\n",\r
-                               LT(1)->getLine(),\r
-                               (LA(1)==eofToken && LT(1)->getText()[0] == '@')?"<eof>":LT(1)->getText(), /* MR21a */\r
-                               token_tbl[tokenWanted]);\r
-               consumeUntil( whatFollows );\r
-               return 0;\r
-       }\r
-       else {\r
-               dirty++;\r
-               labase = (labase+1)&(LLk-1); // labase maintained even if !demand look\r
-/*             if ( !demand_look ) consume(); */\r
-               return 1;\r
-       }\r
-}\r
-\r
-\r
-int ANTLRParser::\r
-_setmatch_wdfltsig(SetWordType *tokensWanted,\r
-                                       ANTLRTokenType tokenTypeOfSet,\r
-                                       SetWordType *whatFollows)\r
-{\r
-       if ( dirty==LLk ) consume();\r
-       if ( !set_el(LA(1), tokensWanted) )\r
-       {\r
-        syntaxErrCount++;                                   /* MR11 */\r
-               /* MR23 */ printMessage(stderr,\r
-                               "line %d: syntax error at \"%s\" missing %s\n",\r
-                               LT(1)->getLine(),\r
-                               (LA(1)==eofToken && LT(1)->getText()[0] == '@')?"<eof>":LT(1)->getText(), /* MR21a */\r
-                               token_tbl[tokenTypeOfSet]);\r
-               consumeUntil( whatFollows );\r
-               return 0;\r
-       }\r
-       else {\r
-               dirty++;\r
-               labase = (labase+1)&(LLk-1); // labase maintained even if !demand look\r
-/*             if ( !demand_look ) consume(); */\r
-               return 1;\r
-       }\r
-}\r
-\r
-char *ANTLRParser::\r
-eMsgd(char *err,int d)\r
-{\r
-       sprintf(eMsgBuffer, err, d);    // dangerous, but I don't care\r
-       return eMsgBuffer;\r
-}\r
-\r
-char *ANTLRParser::\r
-eMsg(char *err, char *s)\r
-{\r
-       sprintf(eMsgBuffer, err, s);\r
-       return eMsgBuffer;\r
-}\r
-\r
-char *ANTLRParser::\r
-eMsg2(char *err,char *s, char *t)\r
-{\r
-       sprintf(eMsgBuffer, err, s, t);\r
-       return eMsgBuffer;\r
-}\r
-\r
-void ANTLRParser::\r
-panic(const char *msg)  // MR20 const\r
-{\r
-       /* MR23 */ printMessage(stderr, "ANTLR panic: %s\n", msg);\r
-       exit(PCCTS_EXIT_FAILURE);           // MR1\r
-}\r
-\r
-const ANTLRChar *ANTLRParser::          // MR1\r
-parserTokenName(int tok) {              // MR1\r
-       return token_tbl[tok];              // MR1\r
-}                                       // MR1\r
-\r
-void ANTLRParser::traceGuessDone(const ANTLRParserState *state) {\r
-\r
-  int   doIt=0;\r
-\r
-  if (traceCurrentRuleName == NULL) return;\r
-\r
-  if (traceOptionValue <= 0) {\r
-    doIt=0;\r
-  } else if (traceGuessOptionValue <= 0) {\r
-    doIt=0;\r
-  } else {\r
-    doIt=1;\r
-  };\r
-\r
-  if (doIt) {\r
-    /* MR23 */ printMessage(stderr,"guess done - returning to rule %s {\"%s\"} at depth %d",\r
-        state->traceCurrentRuleName,\r
-        LT(1)->getType() == eofToken ? "@" : LT(1)->getText(),\r
-        state->traceDepth);\r
-    if (state->guessing != 0) {\r
-      /* MR23 */ printMessage(stderr," (guess mode continues - an enclosing guess is still active)");\r
-    } else {\r
-      /* MR23 */ printMessage(stderr," (guess mode ends)");\r
-    };\r
-    /* MR23 */ printMessage(stderr,"\n");\r
-  };\r
-}\r
-\r
-void ANTLRParser::traceGuessFail() {\r
-\r
-  int   doIt=0;\r
-\r
-  if (traceCurrentRuleName == NULL) return;     /* MR21 */\r
-\r
-  if (traceOptionValue <= 0) {\r
-    doIt=0;\r
-  } else if (guessing && traceGuessOptionValue <= 0) {\r
-    doIt=0;\r
-  } else {\r
-    doIt=1;\r
-  };\r
-\r
-  if (doIt) {\r
-    /* MR23 */ printMessage(stderr,"guess failed in %s\n",traceCurrentRuleName);\r
-  };\r
-}\r
-\r
-/* traceOption:\r
-     zero value turns off trace\r
-*/\r
-\r
-void ANTLRParser::tracein(const ANTLRChar * rule) {\r
-\r
-  int       doIt=0;\r
-\r
-  traceDepth++;\r
-  traceCurrentRuleName=rule;\r
-\r
-  if (traceOptionValue <= 0) {\r
-    doIt=0;\r
-  } else if (guessing && traceGuessOptionValue <= 0) {\r
-    doIt=0;\r
-  } else {\r
-    doIt=1;\r
-  };\r
-\r
-  if (doIt) {\r
-    /* MR23 */ printMessage(stderr,"enter rule %s {\"%s\"} depth %d",\r
-            rule,\r
-            LT(1)->getType() == eofToken ? "@" : LT(1)->getText(),\r
-            traceDepth);\r
-    if (guessing) /* MR23 */ printMessage(stderr," guessing");\r
-    /* MR23 */ printMessage(stderr,"\n");\r
-  };\r
-  return;\r
-}\r
-\r
-void ANTLRParser::traceout(const ANTLRChar * rule) {\r
-\r
-  int       doIt=0;\r
-\r
-  traceDepth--;\r
-\r
-  if (traceOptionValue <= 0) {\r
-    doIt=0;\r
-  } else if (guessing && traceGuessOptionValue <= 0) {\r
-    doIt=0;\r
-  } else {\r
-    doIt=1;\r
-  };\r
-\r
-  if (doIt) {\r
-    /* MR23 */ printMessage(stderr,"exit rule %s {\"%s\"} depth %d",\r
-            rule,\r
-            LT(1)->getType() == eofToken ? "@" : LT(1)->getText(),\r
-            traceDepth+1);\r
-    if (guessing) /* MR23 */ printMessage(stderr," guessing");\r
-    /* MR23 */ printMessage(stderr,"\n");\r
-  };\r
-}\r
-\r
-int ANTLRParser::traceOption(int delta) {\r
-\r
-    int     prevValue=traceOptionValue;\r
-\r
-    traceOptionValue=traceOptionValue+delta;\r
-\r
-    if (traceCurrentRuleName != NULL) {\r
-      if (prevValue <= 0 && traceOptionValue > 0) {\r
-        /* MR23 */ printMessage(stderr,"trace enabled in rule %s depth %d\n",traceCurrentRuleName,traceDepth);\r
-      };\r
-      if (prevValue > 0 && traceOptionValue <= 0) {\r
-        /* MR23 */ printMessage(stderr,"trace disabled in rule %s depth %d\n",traceCurrentRuleName,traceDepth);\r
-      };\r
-    };\r
-\r
-    return  prevValue;\r
-}\r
-\r
-int ANTLRParser::traceGuessOption(int delta) {\r
-\r
-    int     prevValue=traceGuessOptionValue;\r
-\r
-    traceGuessOptionValue=traceGuessOptionValue+delta;\r
-\r
-    if (traceCurrentRuleName != NULL) {\r
-      if (prevValue <= 0 && traceGuessOptionValue > 0) {\r
-        /* MR23 */ printMessage(stderr,"guess trace enabled in rule %s depth %d\n",traceCurrentRuleName,traceDepth);\r
-      };\r
-      if (prevValue > 0 && traceGuessOptionValue <= 0) {\r
-        /* MR23 */ printMessage(stderr,"guess trace disabled in rule %s depth %d\n",traceCurrentRuleName,traceDepth);\r
-      };\r
-    };\r
-    return prevValue;\r
-}\r
-\r
-// MR19 V.H. Simonis Defer Fetch feature\r
-\r
-void ANTLRParser::undeferFetch()\r
-{\r
-\r
-#ifdef ZZDEFER_FETCH\r
-    if (stillToFetch) {\r
-        for (int stillToFetch_x = 0; stillToFetch_x < stillToFetch; ++stillToFetch_x) {\r
-               NLA = inputTokens->getToken()->getType();\r
-               dirty--;\r
-               lap = (lap+1)&(LLk-1);\r
-        }\r
-        stillToFetch = 0;\r
-    }\r
-#else\r
-    return;\r
-#endif\r
-\r
-}\r
-\r
-int ANTLRParser::isDeferFetchEnabled()\r
-{\r
-#ifdef ZZDEFER_FETCH\r
-    return 1;\r
-#else\r
-    return 0;\r
-#endif\r
-}\r
-\r
-//MR23\r
-int ANTLRParser::printMessage(FILE* pFile, const char* pFormat, ...)\r
-{\r
-       va_list marker;\r
-       va_start( marker, pFormat );\r
-       int iRet = printMessageV(pFile, pFormat, marker);\r
-       va_end( marker );\r
-       return iRet;\r
-}\r
-\r
-int ANTLRParser::printMessageV(FILE* pFile, const char* pFormat, va_list arglist) // MR23\r
-{\r
-       return vfprintf(pFile, pFormat, arglist);\r
-}\r
-\r
-// MR23 Move semantic predicate error handling from macro to virtual function\r
-//\r
-// Called by the zzfailed_pred\r
-\r
-void ANTLRParser::failedSemanticPredicate(const char* predicate)\r
-{\r
-    printMessage(stdout,"line %d: semantic error; failed predicate: '%s'\n",\r
-       LT(1)->getLine(), predicate);\r
-}\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/h/AParser.h b/Tools/CodeTools/TianoTools/Pccts/h/AParser.h
deleted file mode 100644 (file)
index fe405f4..0000000
+++ /dev/null
@@ -1,376 +0,0 @@
-/* ANTLRParser.h\r
- *\r
- * Define the generic ANTLRParser superclass, which is subclassed to\r
- * define an actual parser.\r
- *\r
- * Before entry into this file: ANTLRTokenType must be set.\r
- *\r
- * SOFTWARE RIGHTS\r
- *\r
- * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
- * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
- * company may do whatever they wish with source code distributed with\r
- * PCCTS or the code generated by PCCTS, including the incorporation of\r
- * PCCTS, or its output, into commerical software.\r
- *\r
- * We encourage users to develop software with PCCTS.  However, we do ask\r
- * that credit is given to us for developing PCCTS.  By "credit",\r
- * we mean that if you incorporate our source code into one of your\r
- * programs (commercial product, research project, or otherwise) that you\r
- * acknowledge this fact somewhere in the documentation, research report,\r
- * etc...  If you like PCCTS and have developed a nice tool with the\r
- * output, please mention that you developed it using PCCTS.  In\r
- * addition, we ask that this header remain intact in our source code.\r
- * As long as these guidelines are kept, we expect to continue enhancing\r
- * this system and expect to make other tools available as they are\r
- * completed.\r
- *\r
- * ANTLR 1.33\r
- * Terence Parr\r
- * Parr Research Corporation\r
- * with Purdue University and AHPCRC, University of Minnesota\r
- * 1989-2000\r
- */\r
-\r
-#ifndef APARSER_H_GATE\r
-#define APARSER_H_GATE\r
-\r
-#include "pcctscfg.h"\r
-\r
-#include "pccts_stdio.h"\r
-#include "pccts_setjmp.h"\r
-\r
-PCCTS_NAMESPACE_STD\r
-\r
-#include ATOKEN_H\r
-#include ATOKENBUFFER_H\r
-\r
-#ifdef ZZCAN_GUESS\r
-#ifndef ZZINF_LOOK\r
-#define ZZINF_LOOK\r
-#endif\r
-#endif\r
-\r
-\r
-#define NLA                    (token_type[lap&(LLk-1)])/* --> next LA */\r
-\r
-typedef unsigned char SetWordType;\r
-\r
-/* Define external bit set stuff (for SetWordType) */\r
-#define EXT_WORDSIZE   (sizeof(char)*8)\r
-#define EXT_LOGWORDSIZE        3\r
-\r
-           /* s y n t a c t i c  p r e d i c a t e  s t u f f */\r
-\r
-#ifndef zzUSER_GUESS_HOOK\r
-#define zzUSER_GUESS_HOOK(seqFrozen,zzrv)\r
-#endif\r
-\r
-#ifndef zzUSER_GUESS_DONE_HOOK\r
-#define zzUSER_GUESS_DONE_HOOK(seqFrozen)\r
-#endif\r
-\r
-/* MR14 Add zzUSER_GUESS_FAIL_HOOK and related code */\r
-\r
-#define zzUSER_GUESS_FAIL_HOOK_INTERNAL zzUSER_GUESS_FAIL_HOOK(SeqFrozen)\r
-#ifndef zzUSER_GUESS_FAIL_HOOK\r
-#define zzUSER_GUESS_FAIL_HOOK(zzGuessSeq)\r
-#endif\r
-\r
-\r
-typedef struct _zzjmp_buf {\r
-                       jmp_buf state;\r
-               } zzjmp_buf;\r
-\r
-/* these need to be macros not member functions */\r
-#define zzGUESS_BLOCK          ANTLRParserState zzst; int zzrv; int _marker; int zzGuessSeqFrozen;\r
-#define zzNON_GUESS_MODE       if ( !guessing )\r
-#define zzGUESS_FAIL           guess_fail();\r
-\r
-/*  Note:  zzGUESS_DONE does not execute longjmp() */\r
-\r
-#define zzGUESS_DONE           {zzrv=1; inputTokens->rewind(_marker); guess_done(&zzst);zzUSER_GUESS_DONE_HOOK(zzGuessSeqFrozen) }\r
-#define zzGUESS                                saveState(&zzst); \\r
-                                                       guessing = 1; \\r
-                            zzGuessSeqFrozen = ++zzGuessSeq; \\r
-                                                       _marker = inputTokens->mark(); \\r
-                                                       zzrv = setjmp(guess_start.state); \\r
-                            zzUSER_GUESS_HOOK(zzGuessSeqFrozen,zzrv) \\r
-                                                   if ( zzrv ) zzGUESS_DONE\r
-\r
-#define zzTRACEdata     const ANTLRChar *zzTracePrevRuleName = NULL;\r
-\r
-#ifndef zzTRACEIN\r
-#define zzTRACEIN(r)   zzTracePrevRuleName=traceCurrentRuleName;tracein(r);\r
-#endif\r
-#ifndef zzTRACEOUT\r
-#define zzTRACEOUT(r)  traceout(r);traceCurrentRuleName=zzTracePrevRuleName;\r
-#endif\r
-\r
-                  /* a n t l r  p a r s e r  d e f */\r
-\r
-struct ANTLRParserState {\r
-       /* class variables */\r
-       zzjmp_buf guess_start;\r
-       int guessing;\r
-\r
-       int inf_labase;\r
-       int inf_last;\r
-\r
-       int dirty;\r
-\r
-    int             traceOptionValue;       // MR10\r
-    int             traceGuessOptionValue;  // MR10\r
-    const ANTLRChar *traceCurrentRuleName;  // MR10\r
-    int             traceDepth;             // MR10\r
-\r
-};\r
-\r
-/* notes:\r
- *\r
- * multiple inheritance is a cool way to include what stuff is needed\r
- * in this structure (like guess stuff).  however, i'm not convinced that\r
- * multiple inheritance works correctly on all platforms.  not that\r
- * much space is used--just include all possibly useful members.\r
- *\r
- * the class should also be a template with arguments for the lookahead\r
- * depth and so on.  that way, more than one parser can be defined (as\r
- * each will probably have different lookahead requirements).  however,\r
- * am i sure that templates work?  no, i'm not sure.\r
- *\r
- * no attributes are maintained and, hence, the 'asp' variable is not\r
- * needed.  $i can still be referenced, but it refers to the token\r
- * associated with that rule element.  question: where are the token's\r
- * stored if not on the software stack?  in local variables created\r
- * and assigned to by antlr.\r
- */\r
-class ANTLRParser {\r
-protected:\r
-       /* class variables */\r
-       static SetWordType bitmask[sizeof(SetWordType)*8];\r
-       static char eMsgBuffer[500];\r
-\r
-protected:\r
-       int LLk;                                        // number of lookahead symbols (old LL_K)\r
-       int demand_look;\r
-       ANTLRTokenType eofToken;                        // when do I stop during resynch()s\r
-       int bsetsize;                                   // size of bitsets created by ANTLR in\r
-                                                                       // units of SetWordType\r
-\r
-       ANTLRTokenBuffer *inputTokens;  //place to get input tokens\r
-\r
-       zzjmp_buf guess_start;          // where to jump back to upon failure\r
-       int guessing;                           // if guessing (using (...)? predicate)\r
-\r
-       // infinite lookahead stuff\r
-       int can_use_inf_look;           // set by subclass (generated by ANTLR)\r
-       int inf_lap;\r
-       int inf_labase;\r
-       int inf_last;\r
-       int *_inf_line;\r
-\r
-       const ANTLRChar **token_tbl; // pointer to table of token type strings MR20 const\r
-\r
-       int dirty;                                      // used during demand lookahead\r
-\r
-       ANTLRTokenType *token_type;             // fast reference cache of token.getType()\r
-//     ANTLRLightweightToken **token;  // the token with all its attributes\r
-       int lap;\r
-       int labase;\r
-#ifdef ZZDEFER_FETCH\r
-       int stillToFetch;                               // MR19 V.H. Simonis\r
-#endif\r
-\r
-private:\r
-       void fill_inf_look();\r
-\r
-protected:\r
-       virtual void guess_fail() {                         // MR9 27-Sep-97 make virtual\r
-        traceGuessFail();                               // MR10\r
-        longjmp(guess_start.state, 1); }                // MR9\r
-       virtual void guess_done(ANTLRParserState *st) {     // MR9 27-Sep-97 make virtual\r
-         restoreState(st); }                            // MR9\r
-       virtual int guess(ANTLRParserState *);              // MR9 27-Sep-97 make virtual\r
-       void look(int);\r
-    int _match(ANTLRTokenType, ANTLRChar **, ANTLRTokenType *,\r
-                          _ANTLRTokenPtr *, SetWordType **);\r
-    int _setmatch(SetWordType *, ANTLRChar **, ANTLRTokenType *,\r
-                          _ANTLRTokenPtr *, SetWordType **,\r
-                          SetWordType * tokclassErrset /* MR23 */);\r
-    int _match_wsig(ANTLRTokenType);\r
-    int _setmatch_wsig(SetWordType *);\r
-    virtual void consume();\r
-    virtual void resynch(SetWordType *wd,SetWordType mask); // MR21\r
-       void prime_lookahead();\r
-       virtual void tracein(const ANTLRChar *r);              // MR10\r
-       virtual void traceout(const ANTLRChar *r);             // MR10\r
-       static unsigned MODWORD(unsigned x) {return x & (EXT_WORDSIZE-1);}      // x % EXT_WORDSIZE // MR9\r
-       static unsigned DIVWORD(unsigned x) {return x >> EXT_LOGWORDSIZE;}      // x / EXT_WORDSIZE // MR9\r
-       int set_deg(SetWordType *);\r
-       int set_el(ANTLRTokenType, SetWordType *);\r
-       virtual void edecode(SetWordType *);                            // MR1\r
-       virtual void FAIL(int k, ...);                                      // MR1\r
-    int                 traceOptionValue;                           // MR10\r
-    int                 traceGuessOptionValue;                      // MR10\r
-    const ANTLRChar     *traceCurrentRuleName;                      // MR10\r
-    int                 traceDepth;                                 // MR10\r
-    void                traceReset();                               // MR10\r
-    virtual void        traceGuessFail();                           // MR10\r
-    virtual void        traceGuessDone(const ANTLRParserState *);   // MR10\r
-    int                 zzGuessSeq;                                 // MR10\r
-\r
-public:\r
-       ANTLRParser(ANTLRTokenBuffer *,\r
-                               int k=1,\r
-                               int use_inf_look=0,\r
-                               int demand_look=0,\r
-                               int bsetsize=1);\r
-       virtual ~ANTLRParser();\r
-\r
-       virtual void init();\r
-       \r
-       ANTLRTokenType LA(int i)\r
-       {\r
-//\r
-//  MR14 demand look will always be 0 for C++ mode\r
-//\r
-////   return demand_look ? token_type[(labase+(i)-1)&(LLk-1)] :\r
-////                                           token_type[(lap+(i)-1)&(LLk-1)];\r
-\r
-// MR19 V.H. Simonis Defer fetch feature\r
-\r
-#ifdef ZZDEFER_FETCH\r
-      undeferFetch();\r
-#endif\r
-         return token_type[(lap+(i)-1)&(LLk-1)];\r
-       }\r
-       _ANTLRTokenPtr LT(int i);\r
-\r
-       void setEofToken(ANTLRTokenType t)      { eofToken = t; }\r
-       ANTLRTokenType getEofToken() const  { return eofToken; }    // MR14\r
-\r
-       void noGarbageCollectTokens()   { inputTokens->noGarbageCollectTokens(); }\r
-       void garbageCollectTokens()             { inputTokens->garbageCollectTokens(); }\r
-\r
-    virtual void syn(_ANTLRTokenPtr tok, ANTLRChar *egroup,\r
-                                        SetWordType *eset, ANTLRTokenType etok, int k);\r
-       virtual void saveState(ANTLRParserState *);     // MR9 27-Sep-97 make virtual\r
-       virtual void restoreState(ANTLRParserState *);  // MR9 27-Sep-97 make virtual\r
-\r
-       virtual void panic(const char *msg); // MR20 const\r
-\r
-       static char *eMsgd(char *,int);\r
-       static char *eMsg(char *,char *);\r
-       static char *eMsg2(char *,char *,char *);\r
-\r
-       virtual int printMessage(FILE* pFile, const char* pFormat, ...); // MR23\r
-       virtual int printMessageV(FILE* pFile, const char* pFormat, va_list arglist); // MR23\r
-\r
-       void consumeUntil(SetWordType *st);\r
-       void consumeUntilToken(int t);\r
-\r
-       virtual int _setmatch_wdfltsig(SetWordType *tokensWanted,\r
-                                        ANTLRTokenType tokenTypeOfSet,\r
-                                        SetWordType *whatFollows);\r
-       virtual int _match_wdfltsig(ANTLRTokenType tokenWanted,\r
-                                        SetWordType *whatFollows);\r
-       \r
-       const ANTLRChar * parserTokenName(int tok);                     // MR1\r
-\r
-    int                 traceOptionValueDefault;        // MR11\r
-    int                 traceOption(int delta);         // MR11\r
-    int                 traceGuessOption(int delta);    // MR11\r
-\r
-//  MR8  5-Aug-97   S.Bochnak@microtool.com.pl\r
-//  MR8             Move resynch static local variable\r
-//  MR8               to class instance\r
-\r
-    int                 syntaxErrCount;                      // MR12\r
-    ANTLRTokenStream   *getLexer() const {                   // MR12\r
-      return inputTokens ? inputTokens->getLexer() : 0; }    // MR12\r
-protected:                                              // MR8\r
-    int     resynchConsumed;                            // MR8\r
-    char    *zzFAILtext; // workarea required by zzFAIL // MR9\r
-    void    undeferFetch();                             // MR19 V.H. Simonis\r
-    int     isDeferFetchEnabled();                      // MR19 V.H. Simonis\r
-    virtual void failedSemanticPredicate(const char* predicate); /* MR23 */\r
-};\r
-\r
-#define zzmatch(_t)                                                    \\r
-       if ( !_match((ANTLRTokenType)_t, &zzMissText, &zzMissTok, \\r
-                                (_ANTLRTokenPtr *) &zzBadTok, &zzMissSet) ) goto fail;\r
-\r
-#define zzmatch_wsig(_t,handler)                                               \\r
-       if ( !_match_wsig((ANTLRTokenType)_t) ) if ( guessing ) zzGUESS_FAIL else {_signal=MismatchedToken; goto handler;}\r
-\r
-#define zzsetmatch(_ts,_tokclassErrset)                                                        \\r
-       if ( !_setmatch(_ts, &zzMissText, &zzMissTok, \\r
-                                (_ANTLRTokenPtr *) &zzBadTok, &zzMissSet, _tokclassErrset) ) goto fail;\r
-\r
-#define zzsetmatch_wsig(_ts, handler)                          \\r
-       if ( !_setmatch_wsig(_ts) ) if ( guessing ) zzGUESS_FAIL else {_signal=MismatchedToken; goto handler;}\r
-\r
-/* For the dflt signal matchers, a FALSE indicates that an error occurred\r
- * just like the other matchers, but in this case, the routine has already\r
- * recovered--we do NOT want to consume another token.  However, when\r
- * the match was successful, we do want to consume hence _signal=0 so that\r
- * a token is consumed by the "if (!_signal) consume(); _signal=NoSignal;"\r
- * preamble.\r
- */\r
-#define zzsetmatch_wdfltsig(tokensWanted, tokenTypeOfSet, whatFollows) \\r
-       if ( !_setmatch_wdfltsig(tokensWanted, tokenTypeOfSet, whatFollows) ) \\r
-               _signal = MismatchedToken;\r
-\r
-#define zzmatch_wdfltsig(tokenWanted, whatFollows) \\r
-       if ( !_match_wdfltsig(tokenWanted, whatFollows) ) _signal = MismatchedToken;\r
-\r
-\r
-//  MR1  10-Apr-97     zzfailed_pred() macro does not backtrack in guess mode.\r
-//  MR1                            Identification and correction due to J. Lilley\r
-//\r
-//  MR23            Call virtual method to report error.\r
-//  MR23            Provide more control over failed predicate action\r
-//                  without any need for user to worry about guessing internals.\r
-\r
-#ifndef zzfailed_pred\r
-#define zzfailed_pred(_p,_hasuseraction,_useraction) \\r
-  if (guessing) { \\r
-    zzGUESS_FAIL; \\r
-  } else { \\r
-    zzfailed_pred_action(_p,_hasuseraction,_useraction) \\r
-  }\r
-#endif\r
-\r
-//  MR23            Provide more control over failed predicate action\r
-//                  without any need for user to worry about guessing internals.\r
-//                  _hasuseraction == 0 => no user specified error action\r
-//                  _hasuseraction == 1 => user specified error action\r
-\r
-#ifndef zzfailed_pred_action\r
-#define zzfailed_pred_action(_p,_hasuseraction,_useraction) \\r
-    if (_hasuseraction) { _useraction } else { failedSemanticPredicate(_p); }\r
-#endif\r
-\r
-#define zzRULE \\r
-               SetWordType *zzMissSet=NULL; ANTLRTokenType zzMissTok=(ANTLRTokenType)0;        \\r
-               _ANTLRTokenPtr zzBadTok=NULL; ANTLRChar *zzBadText=(ANTLRChar *)"";     \\r
-               int zzErrk=1,zzpf=0; \\r
-        zzTRACEdata \\r
-               ANTLRChar *zzMissText=(ANTLRChar *)"";\r
-\r
-#endif\r
-\r
-        /* S t a n d a r d  E x c e p t i o n  S i g n a l s */\r
-\r
-#define NoSignal                       0\r
-#define MismatchedToken                1\r
-#define NoViableAlt                    2\r
-#define NoSemViableAlt         3\r
-\r
-/* MR7  Allow more control over signalling                                  */\r
-/*        by adding "Unwind" and "SetSignal"                                */\r
-\r
-#define Unwind              4\r
-#define setSignal(newValue) *_retsignal=_signal=(newValue)\r
-#define suppressSignal       *_retsignal=_signal=0\r
-#define exportSignal        *_retsignal=_signal\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/h/ASTBase.cpp b/Tools/CodeTools/TianoTools/Pccts/h/ASTBase.cpp
deleted file mode 100644 (file)
index a94f080..0000000
+++ /dev/null
@@ -1,256 +0,0 @@
-/* Abstract syntax tree manipulation functions\r
- *\r
- * SOFTWARE RIGHTS\r
- *\r
- * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
- * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
- * company may do whatever they wish with source code distributed with\r
- * PCCTS or the code generated by PCCTS, including the incorporation of\r
- * PCCTS, or its output, into commerical software.\r
- *\r
- * We encourage users to develop software with PCCTS.  However, we do ask\r
- * that credit is given to us for developing PCCTS.  By "credit",\r
- * we mean that if you incorporate our source code into one of your\r
- * programs (commercial product, research project, or otherwise) that you\r
- * acknowledge this fact somewhere in the documentation, research report,\r
- * etc...  If you like PCCTS and have developed a nice tool with the\r
- * output, please mention that you developed it using PCCTS.  In\r
- * addition, we ask that this header remain intact in our source code.\r
- * As long as these guidelines are kept, we expect to continue enhancing\r
- * this system and expect to make other tools available as they are\r
- * completed.\r
- *\r
- * ANTLR 1.33\r
- * Terence Parr\r
- * Parr Research Corporation\r
- * with Purdue University and AHPCRC, University of Minnesota\r
- * 1989-2000\r
- */\r
-\r
-#include "pcctscfg.h"\r
-\r
-#include "pccts_stdio.h"\r
-#include "pccts_stdarg.h"\r
-\r
-PCCTS_NAMESPACE_STD\r
-\r
-#define ANTLR_SUPPORT_CODE\r
-\r
-#include "ASTBase.h"\r
-\r
-/* ensure that tree manipulation variables are current after a rule\r
- * reference\r
- */\r
-void\r
-ASTBase::link(ASTBase **_root, ASTBase **_sibling, ASTBase **_tail)\r
-{\r
-       if ( *_sibling == NULL ) return;\r
-       if ( *_root == NULL ) *_root = *_sibling;\r
-       else if ( *_root != *_sibling ) (*_root)->_down = *_sibling;\r
-       if ( *_tail==NULL ) *_tail = *_sibling;\r
-       while ( (*_tail)->_right != NULL ) *_tail = (*_tail)->_right;\r
-}\r
-\r
-/* add a child node to the current sibling list */\r
-void\r
-ASTBase::subchild(ASTBase **_root, ASTBase **_sibling, ASTBase **_tail)\r
-{\r
-       if ( *_tail != NULL ) (*_tail)->_right = this;\r
-       else {\r
-               *_sibling = this;\r
-               if ( *_root != NULL ) (*_root)->_down = *_sibling;\r
-       }\r
-       *_tail = this;\r
-       if ( *_root == NULL ) *_root = *_sibling;\r
-}\r
-\r
-/* make a new AST node.  Make the newly-created\r
- * node the root for the current sibling list.  If a root node already\r
- * exists, make the newly-created node the root of the current root.\r
- */\r
-void\r
-ASTBase::subroot(ASTBase **_root, ASTBase **_sibling, ASTBase **_tail)\r
-{\r
-       if ( *_root != NULL )\r
-               if ( (*_root)->_down == *_sibling ) *_sibling = *_tail = *_root;\r
-       *_root = this;\r
-       (*_root)->_down = *_sibling;\r
-}\r
-\r
-/* Apply preorder_action(), etc.. to root then each sibling */\r
-//\r
-//  7-Apr-97 133MR1\r
-//     Fix suggested by Ron House (house@helios.usq.edu.au)\r
-//\r
-void\r
-ASTBase::preorder(void* pData /*= NULL*/ /* MR23 */)\r
-{\r
-       ASTBase *tree = this;\r
-\r
-       while ( tree!= NULL )\r
-       {\r
-               if ( tree->_down != NULL ) {\r
-                       tree->preorder_before_action(pData);            // MR1  \r
-               };\r
-               tree->preorder_action(pData);\r
-               if ( tree->_down!=NULL )\r
-               {\r
-                       tree->_down->preorder(pData);\r
-                       tree->preorder_after_action(pData);                     // MR1\r
-               }\r
-               tree = tree->_right;\r
-       }\r
-}\r
-\r
-/* free all AST nodes in tree; apply func to each before freeing */\r
-void\r
-ASTBase::destroy()\r
-{\r
-   ASTBase* tree = this;\r
-   while (tree) {\r
-      if (tree->_down) tree->_down->destroy();\r
-\r
-      ASTBase* cur = tree;\r
-      tree = tree->_right;\r
-      delete cur;\r
-   }\r
-}\r
-\r
-/* build a tree (root child1 child2 ... NULL)\r
- * If root is NULL, simply make the children siblings and return ptr\r
- * to 1st sibling (child1).  If root is not single node, return NULL.\r
- *\r
- * Siblings that are actually siblins lists themselves are handled\r
- * correctly.  For example #( NULL, #( NULL, A, B, C), D) results\r
- * in the tree ( NULL A B C D ).\r
- *\r
- * Requires at least two parameters with the last one being NULL.  If\r
- * both are NULL, return NULL.\r
- */\r
-ASTBase *\r
-ASTBase::tmake(ASTBase *root, ...)\r
-{\r
-       va_list ap;\r
-       register ASTBase *child, *sibling=NULL, *tail=NULL /*MR23*/, *w;\r
-\r
-       va_start(ap, root);\r
-\r
-       if ( root != NULL )\r
-               if ( root->_down != NULL ) {  \r
-            root->reportOverwriteOfDownPointer();  /* MR21 Report problem which almost always an error */\r
-            return NULL;\r
-        }\r
-       child = va_arg(ap, ASTBase *);\r
-       while ( child != NULL )\r
-       {\r
-               for (w=child; w->_right!=NULL; w=w->_right) {;} /* find end of child */\r
-               if ( sibling == NULL ) {sibling = child; tail = w;}\r
-               else {tail->_right = child; tail = w;}\r
-               child = va_arg(ap, ASTBase *);\r
-       }\r
-       if ( root==NULL ) root = sibling;\r
-       else root->_down = sibling;\r
-       va_end(ap);\r
-       return root;\r
-}\r
-\r
-#ifndef PCCTS_NOT_USING_SOR\r
-\r
-/* tree duplicate */\r
-// forgot to check for NULL this (TJP July 23,1995)\r
-ASTBase *\r
-ASTBase::dup()\r
-{\r
-       ASTBase *u, *t=this;\r
-       \r
-       if ( t == NULL ) return NULL;\r
-/*\r
-       u = new ASTBase;\r
-       *u = *t;\r
-*/\r
-       u = (ASTBase *)this->shallowCopy();\r
-       if ( t->_right!=NULL ) u->_right = t->_right->dup();\r
-       else u->_right = NULL;\r
-       if ( t->_down!=NULL ) u->_down = t->_down->dup();\r
-       else u->_down = NULL;\r
-       return u;\r
-}\r
-#endif\r
-\r
-//\r
-//  7-Apr-97 133MR1\r
-//          Fix suggested by Asgeir Olafsson (olafsson@cstar.ac.com)\r
-//\r
-/* tree duplicate */\r
-\r
-#ifndef PCCTS_NOT_USING_SOR\r
-\r
-ASTBase *\r
-ASTDoublyLinkedBase::dup()\r
-{\r
-       ASTDoublyLinkedBase *u, *t=this;\r
-       \r
-       if ( t == NULL ) return NULL;\r
-       u = (ASTDoublyLinkedBase *)this->shallowCopy();\r
-       u->_up = NULL;          /* set by calling invocation */\r
-       u->_left = NULL;\r
-       if (t->_right!=NULL) {                                          // MR1\r
-          u->_right=t->_right->dup();                                  // MR1\r
-         ((ASTDoublyLinkedBase *)u->_right)->_left = u;                // MR1\r
-        } else {                                                       // MR1\r
-         u->_right = NULL;                                             // MR1\r
-        };                                                             // MR1\r
-       if (t->_down!=NULL) {                                           // MR1\r
-         u->_down = t->_down->dup();                                   // MR1\r
-          ((ASTDoublyLinkedBase *)u->_down)->_up = u;                  // MR1\r
-        } else {                                                       // MR1\r
-         u->_down = NULL;                                              // MR1\r
-        };                                                             // MR1\r
-       return u;\r
-}\r
-\r
-#endif\r
-\r
-/*\r
- * Set the 'up', and 'left' pointers of all nodes in 't'.\r
- * Initial call is double_link(your_tree, NULL, NULL).\r
- */\r
-void\r
-ASTDoublyLinkedBase::double_link(ASTBase *left, ASTBase *up)\r
-{\r
-    ASTDoublyLinkedBase *t = this;\r
-\r
-    t->_left = (ASTDoublyLinkedBase *) left;\r
-    t->_up = (ASTDoublyLinkedBase *) up;\r
-    if (t->_down != NULL)\r
-               ((ASTDoublyLinkedBase *)t->_down)->double_link(NULL, t);\r
-    if (t->_right != NULL)\r
-               ((ASTDoublyLinkedBase *)t->_right)->double_link(t, up);\r
-}\r
-\r
-// MR21 ASTBase::reportOverwriteOfDownPointer\r
-\r
-void ASTBase::reportOverwriteOfDownPointer()\r
-{\r
-    panic("Attempt to overwrite down pointer in ASTBase::tmake");\r
-}\r
-\r
-// MR21 ASTBase::panic\r
-\r
-void ASTBase::panic(const char *msg)\r
-{\r
-       /* MR23 */ printMessage(stderr,"ASTBase panic: %s\n", msg);\r
-       exit(PCCTS_EXIT_FAILURE);\r
-}\r
-\r
-#ifdef PCCTS_NOT_USING_SOR\r
-//MR23\r
-int ASTBase::printMessage(FILE* pFile, const char* pFormat, ...)\r
-{\r
-       va_list marker;\r
-       va_start( marker, pFormat );\r
-       int iRet = vfprintf(pFile, pFormat, marker);\r
-       va_end( marker );\r
-       return iRet;\r
-}\r
-#endif\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/h/ASTBase.h b/Tools/CodeTools/TianoTools/Pccts/h/ASTBase.h
deleted file mode 100644 (file)
index 912f4b8..0000000
+++ /dev/null
@@ -1,122 +0,0 @@
-/* Abstract syntax tree\r
- *\r
- * SOFTWARE RIGHTS\r
- *\r
- * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
- * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
- * company may do whatever they wish with source code distributed with\r
- * PCCTS or the code generated by PCCTS, including the incorporation of\r
- * PCCTS, or its output, into commerical software.\r
- *\r
- * We encourage users to develop software with PCCTS.  However, we do ask\r
- * that credit is given to us for developing PCCTS.  By "credit",\r
- * we mean that if you incorporate our source code into one of your\r
- * programs (commercial product, research project, or otherwise) that you\r
- * acknowledge this fact somewhere in the documentation, research report,\r
- * etc...  If you like PCCTS and have developed a nice tool with the\r
- * output, please mention that you developed it using PCCTS.  In\r
- * addition, we ask that this header remain intact in our source code.\r
- * As long as these guidelines are kept, we expect to continue enhancing\r
- * this system and expect to make other tools available as they are\r
- * completed.\r
- *\r
- * ANTLR 1.33\r
- * Terence Parr\r
- * Parr Research Corporation\r
- * with Purdue University and AHPCRC, University of Minnesota\r
- * 1989-2000\r
- */\r
-\r
-#ifndef ASTBase_H\r
-#define ASTBase_H\r
-\r
-#include "pcctscfg.h"\r
-\r
-#include "pccts_stdio.h"\r
-#include "pccts_stdlib.h"\r
-\r
-PCCTS_NAMESPACE_STD\r
-\r
-#ifndef PCCTS_NOT_USING_SOR\r
-#include "PCCTSAST.h"\r
-#endif\r
-\r
-/*\r
- * Notes:\r
- *\r
- * To specify a copy constructor, subclass one of these classes and\r
- * give the copy constructor.  To use dup(), you must define shallowCopy().\r
- * shallowCopy() can use either a copy constructor or just copy the node\r
- * itself.\r
- */\r
-\r
-#ifdef PCCTS_NOT_USING_SOR\r
-class DllExportPCCTS ASTBase {\r
-#else\r
-class DllExportPCCTS ASTBase : public PCCTS_AST {\r
-#endif\r
-\r
-protected:\r
-       ASTBase *_right, *_down;\r
-\r
-public:\r
-\r
-#ifdef PCCTS_NOT_USING_SOR\r
-       ASTBase *right()        { return _right; }\r
-       ASTBase *down()     { return _down; }\r
-       void setRight(ASTBase *t)       { _right = (ASTBase *)t; }\r
-       void setDown(ASTBase *t)        { _down = (ASTBase *)t; }\r
-#else\r
-       PCCTS_AST *right()      { return _right; }      // define the SORCERER interface\r
-       PCCTS_AST *down()       { return _down; }\r
-       void setRight(PCCTS_AST *t)     { _right = (ASTBase *)t; }\r
-       void setDown(PCCTS_AST *t)      { _down = (ASTBase *)t; }\r
-#endif\r
-       ASTBase() { _right = _down = NULL; }\r
-       virtual ~ASTBase() { ; }\r
-#ifndef PCCTS_NOT_USING_SOR\r
-       virtual ASTBase *dup();\r
-#endif\r
-       void destroy();\r
-       void preorder(void* pData = NULL /* MR23 */);\r
-       static ASTBase *tmake(ASTBase *, ...);\r
-       static void link(ASTBase **, ASTBase **, ASTBase **);\r
-       void subchild(ASTBase **, ASTBase **, ASTBase **);\r
-       void subroot(ASTBase **, ASTBase **, ASTBase **);\r
-       virtual void preorder_action(void* /*pData*/ = NULL /* MR23 */) { ; }\r
-       virtual void preorder_before_action(void* /*pData*/ = NULL /* MR23 */) { /* MR23 */ printMessage(stdout, " ("); }\r
-       virtual void preorder_after_action(void* /*pData*/ = NULL /* MR23 */) { /* MR23 */ printMessage(stdout, " )"); }\r
-    virtual void panic(const char *msg);         /* MR21 */\r
-    virtual void reportOverwriteOfDownPointer(); /* MR21 */\r
-#ifdef PCCTS_NOT_USING_SOR\r
-       virtual int printMessage(FILE* pFile, const char* pFormat, ...); // MR23\r
-#endif\r
-};\r
-\r
-class DllExportPCCTS ASTDoublyLinkedBase : public ASTBase {\r
-protected:\r
-    ASTDoublyLinkedBase *_left, *_up;\r
-\r
-public:\r
-  void double_link(ASTBase *left, ASTBase *up);\r
-\r
-#ifndef PCCTS_NOT_USING_SOR\r
-  virtual ASTBase *dup();\r
-#endif\r
-\r
-#ifdef PCCTS_NOT_USING_SOR\r
-  ASTBase *left() { return _left; }\r
-  ASTBase *up() { return _up; }\r
-  void setLeft(ASTBase *t) { _left = (ASTDoublyLinkedBase *)t; }    // MR6\r
-  void setUp(ASTBase *t)   { _up = (ASTDoublyLinkedBase *)t; }     // MR6\r
-#else\r
-  PCCTS_AST *left() { return _left; }\r
-  PCCTS_AST *up() { return _up; }\r
-  void setLeft(PCCTS_AST *t) { _left = (ASTDoublyLinkedBase *)t; }  // MR6\r
-  void setUp(PCCTS_AST *t)   { _up = (ASTDoublyLinkedBase *)t; }       // MR6\r
-#endif\r
-\r
-};\r
-\r
-class AST;     // announce that this class will be coming along shortly\r
-#endif\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/h/ATokPtr.h b/Tools/CodeTools/TianoTools/Pccts/h/ATokPtr.h
deleted file mode 100644 (file)
index 75b4c86..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-/* ATokPtr.h\r
- *\r
- * SOFTWARE RIGHTS\r
- *\r
- * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
- * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
- * company may do whatever they wish with source code distributed with\r
- * PCCTS or the code generated by PCCTS, including the incorporation of\r
- * PCCTS, or its output, into commerical software.\r
- *\r
- * We encourage users to develop software with PCCTS.  However, we do ask\r
- * that credit is given to us for developing PCCTS.  By "credit",\r
- * we mean that if you incorporate our source code into one of your\r
- * programs (commercial product, research project, or otherwise) that you\r
- * acknowledge this fact somewhere in the documentation, research report,\r
- * etc...  If you like PCCTS and have developed a nice tool with the\r
- * output, please mention that you developed it using PCCTS.  In\r
- * addition, we ask that this header remain intact in our source code.\r
- * As long as these guidelines are kept, we expect to continue enhancing\r
- * this system and expect to make other tools available as they are\r
- * completed.\r
- *\r
- * ANTLR 1.33\r
- * Written by Russell Quong June 30, 1995\r
- * Adapted by Terence Parr to ANTLR stuff\r
- * Parr Research Corporation\r
- * with Purdue University and AHPCRC, University of Minnesota\r
- * 1989-2000\r
- */\r
-\r
-#ifndef ATokPtr_h\r
-#define ATokPtr_h\r
-\r
-#include "pcctscfg.h"\r
-\r
-#include "pccts_stdio.h"\r
-\r
-PCCTS_NAMESPACE_STD\r
-\r
-// pointer to a reference counted object\r
-// robust in that an unused ANTLRTokenPtr can point to NULL.\r
-\r
-class ANTLRAbstractToken;\r
-\r
-class DllExportPCCTS ANTLRTokenPtr {\r
-public:\r
-    ANTLRTokenPtr(ANTLRAbstractToken *addr=NULL){ptr_ = addr; ref();}\r
-    ANTLRTokenPtr(const ANTLRTokenPtr &lhs)    {ptr_ = lhs.ptr_; lhs.ref();}\r
-    ~ANTLRTokenPtr();\r
-\r
-    // use ANTLRTokenPtr as a pointer to ANTLRToken\r
-//\r
-//  8-Apr-97   MR1     Make operator -> a const member function\r
-//                       as well as some other member functions\r
-//\r
-    ANTLRAbstractToken *operator-> () const { return ptr_; }           // MR1\r
-//\r
-//  7-Apr-97 133MR1\r
-//          Fix suggested by Andreas Magnusson\r
-//                     (Andreas.Magnusson@mailbox.swipnet.se)\r
-    void operator = (const ANTLRTokenPtr & lhs);                       // MR1\r
-    void operator = (ANTLRAbstractToken *addr);\r
-    int operator != (const ANTLRTokenPtr &q) const                     // MR1 // MR11 unsigned -> int\r
-       { return this->ptr_ != q.ptr_; }\r
-    int operator == (const ANTLRTokenPtr &q) const                     // MR1 // MR11 unsigned -> int\r
-       { return this->ptr_ == q.ptr_; }\r
-    int operator == (const ANTLRAbstractToken *addr) const      // MR11\r
-    { return this->ptr_ == addr; }\r
-    int operator != (const ANTLRAbstractToken *addr) const      // MR11\r
-    { return this->ptr_ != addr; }\r
-\r
-    void ref() const;\r
-    void deref();\r
-\r
-protected:\r
-    ANTLRAbstractToken *ptr_;\r
-};\r
-\r
-//typedef ANTLRTokenPtr _ANTLRTokenPtr;\r
-\r
-/*\r
- * Since you cannot redefine operator->() to return one of the user's\r
- * token object types, we must down cast.  This is a drag.  Here's\r
- * a macro that helps.  template: "mytoken(a-smart-ptr)->myfield".\r
- */\r
-#define mytoken(tk) ((ANTLRToken *)(tk.operator->()))\r
-\r
-#endif\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/h/ATokPtrImpl.h b/Tools/CodeTools/TianoTools/Pccts/h/ATokPtrImpl.h
deleted file mode 100644 (file)
index 9c07cf5..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-/*\r
- * ATokPtrImpl.h (formerly ATokPtr.cpp)\r
- *\r
- * This is #included in ATokBuffer.cpp for historical reasons.\r
- * It has been renamed because of problems with the .cpp extension\r
- * when used with IDE.\r
- *\r
- *\r
- * ANTLRToken MUST be defined before entry to this file.\r
- *\r
- * SOFTWARE RIGHTS\r
- *\r
- * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
- * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
- * company may do whatever they wish with source code distributed with\r
- * PCCTS or the code generated by PCCTS, including the incorporation of\r
- * PCCTS, or its output, into commerical software.\r
- *\r
- * We encourage users to develop software with PCCTS.  However, we do ask\r
- * that credit is given to us for developing PCCTS.  By "credit",\r
- * we mean that if you incorporate our source code into one of your\r
- * programs (commercial product, research project, or otherwise) that you\r
- * acknowledge this fact somewhere in the documentation, research report,\r
- * etc...  If you like PCCTS and have developed a nice tool with the\r
- * output, please mention that you developed it using PCCTS.  In\r
- * addition, we ask that this header remain intact in our source code.\r
- * As long as these guidelines are kept, we expect to continue enhancing\r
- * this system and expect to make other tools available as they are\r
- * completed.\r
- *\r
- * ANTLR 1.33\r
- * Written by Russell Quong June 30, 1995\r
- * Adapted by Terence Parr to ANTLR stuff\r
- * Parr Research Corporation\r
- * with Purdue University and AHPCRC, University of Minnesota\r
- * 1989-2000\r
- */\r
-\r
-#include "pcctscfg.h"\r
-\r
-PCCTS_NAMESPACE_STD\r
-\r
-#include "ATokPtr.h"\r
-\r
-void ANTLRTokenPtr::ref() const\r
-{\r
-    if (ptr_ != NULL) {\r
-               ptr_->ref();\r
-       }\r
-}\r
-\r
-void ANTLRTokenPtr::deref()\r
-{\r
-    if (ptr_ != NULL)\r
-    {\r
-               ptr_->deref();\r
-               if ( ptr_->nref()==0 )\r
-               {\r
-                   delete ptr_;\r
-                       ptr_ = NULL;\r
-               }\r
-    }\r
-}\r
-\r
-ANTLRTokenPtr::~ANTLRTokenPtr()\r
-{\r
-    deref();\r
-}\r
-\r
-//\r
-//  8-Apr-97   MR1     Make operator -> a const member function\r
-//                       as weall as some other member functions\r
-//\r
-void ANTLRTokenPtr::operator = (const ANTLRTokenPtr & lhs)     // MR1\r
-{\r
-    lhs.ref(); // protect against "xp = xp"; ie same underlying object\r
-    deref();\r
-    ptr_ = lhs.ptr_;\r
-}\r
-\r
-void ANTLRTokenPtr::operator = (ANTLRAbstractToken *addr)\r
-{\r
-    if (addr != NULL) {\r
-       addr->ref();\r
-    }\r
-    deref();\r
-    ptr_ = addr;\r
-}\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/h/AToken.h b/Tools/CodeTools/TianoTools/Pccts/h/AToken.h
deleted file mode 100644 (file)
index 6167c21..0000000
+++ /dev/null
@@ -1,325 +0,0 @@
-/* ANTLRToken.h\r
- *\r
- * SOFTWARE RIGHTS\r
- *\r
- * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
- * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
- * company may do whatever they wish with source code distributed with\r
- * PCCTS or the code generated by PCCTS, including the incorporation of\r
- * PCCTS, or its output, into commerical software.\r
- *\r
- * We encourage users to develop software with PCCTS.  However, we do ask\r
- * that credit is given to us for developing PCCTS.  By "credit",\r
- * we mean that if you incorporate our source code into one of your\r
- * programs (commercial product, research project, or otherwise) that you\r
- * acknowledge this fact somewhere in the documentation, research report,\r
- * etc...  If you like PCCTS and have developed a nice tool with the\r
- * output, please mention that you developed it using PCCTS.  In\r
- * addition, we ask that this header remain intact in our source code.\r
- * As long as these guidelines are kept, we expect to continue enhancing\r
- * this system and expect to make other tools available as they are\r
- * completed.\r
- *\r
- * ANTLR 1.33\r
- * Terence Parr\r
- * Parr Research Corporation\r
- * with Purdue University and AHPCRC, University of Minnesota\r
- * 1989-2000\r
- */\r
-\r
-#ifndef ATOKEN_H_GATE\r
-#define ATOKEN_H_GATE\r
-\r
-#include "pcctscfg.h"\r
-\r
-#include "pccts_string.h"\r
-#include "pccts_stdio.h"\r
-#include "pccts_stdlib.h"\r
-#include "pccts_stdarg.h" // MR23\r
-\r
-PCCTS_NAMESPACE_STD\r
-\r
-// MR9      RJV (JVincent@novell.com) Not needed for variable length strings\r
-\r
-//// MR9 #ifndef ANTLRCommonTokenTEXTSIZE\r
-//// MR9 #define ANTLRCommonTokenTEXTSIZE              100\r
-//// MR9 #endif\r
-\r
-\r
-/* must define what a char looks like; can make this a class too */\r
-typedef char ANTLRChar;\r
-\r
-/* D E F I N E  S M A R T  P O I N T E R S */\r
-\r
-//#include ATOKPTR_H   not tested yet, leave out\r
-class ANTLRAbstractToken;\r
-typedef ANTLRAbstractToken *_ANTLRTokenPtr;\r
-\r
-class ANTLRAbstractToken {\r
-public:\r
-    virtual ~ANTLRAbstractToken() {;}\r
-    virtual ANTLRTokenType getType() const = 0;\r
-    virtual void setType(ANTLRTokenType t) = 0;\r
-    virtual int getLine() const = 0;\r
-    virtual void setLine(int line) = 0;\r
-    virtual ANTLRChar *getText() const = 0;\r
-    virtual void setText(const ANTLRChar *) = 0;\r
-\r
-    /* This function will disappear when I can use templates */\r
-       virtual ANTLRAbstractToken *makeToken(ANTLRTokenType tt,\r
-                                                                                 ANTLRChar *text,\r
-                                                                                 int line) = 0;\r
-\r
-       /* define to satisfy ANTLRTokenBuffer's need to determine whether or\r
-          not a token object can be destroyed.  If nref()==0, no one has\r
-          a reference, and the object may be destroyed.  This function defaults\r
-          to 1, hence, if you use deleteTokens() message with a token object\r
-          not derived from ANTLRCommonRefCountToken, the parser will compile\r
-          but will not delete objects after they leave the token buffer.\r
-    */\r
-\r
-       virtual unsigned nref() const { return 1; }     // MR11\r
-       virtual void ref() {;}\r
-       virtual void deref() {;}\r
-\r
-       virtual void panic(const char *msg)             // MR20 const\r
-               {\r
-                       /* MR23 */ printMessage(stderr, "ANTLRAbstractToken panic: %s\n", msg);\r
-                       exit(PCCTS_EXIT_FAILURE);\r
-               }\r
-\r
-       virtual int printMessage(FILE* pFile, const char* pFormat, ...) // MR23\r
-               {\r
-                       va_list marker;\r
-                       va_start( marker, pFormat );\r
-                       int iRet = vfprintf(pFile, pFormat, marker);\r
-                       va_end( marker );\r
-                       return iRet;\r
-               }\r
-};\r
-\r
-/* This class should be subclassed.  It cannot store token type or text */\r
-\r
-class ANTLRRefCountToken : public ANTLRAbstractToken {\r
-public:\r
-#ifdef DBG_REFCOUNTTOKEN\r
-       static int ctor;\r
-       static int dtor;\r
-#endif\r
-protected:\r
-    unsigned refcnt_;\r
-#ifdef DBG_REFCOUNTTOKEN\r
-       char object[200];\r
-#endif\r
-\r
-public:\r
-\r
-       // MR23 - No matter what you do, you're hammered.\r
-       //        Don't give names to formals something breaks.\r
-       //                Give names to formals and don't use them it breaks.\r
-\r
-#ifndef DBG_REFCOUNTTOKEN\r
-       ANTLRRefCountToken(ANTLRTokenType /* t MR23 */, const ANTLRChar * /* s MR23 */)\r
-#else\r
-       ANTLRRefCountToken(ANTLRTokenType t, const ANTLRChar * s)\r
-#endif\r
-\r
-#ifndef DBG_REFCOUNTTOKEN\r
-               {\r
-                       refcnt_ = 0;\r
-               }\r
-#else\r
-       {\r
-               ctor++;\r
-               refcnt_ = 0;\r
-               if ( t==1 ) sprintf(object,"tok_EOF");\r
-               else sprintf(object,"tok_%s",s);\r
-               /* MR23 */ printMessage(stderr, "ctor %s #%d\n",object,ctor);\r
-       }\r
-#endif\r
-       ANTLRRefCountToken()\r
-#ifndef DBG_REFCOUNTTOKEN\r
-               { refcnt_ = 0; }\r
-#else\r
-               {\r
-                       ctor++;\r
-                       refcnt_ = 0;\r
-                       sprintf(object,"tok_blank");\r
-                       /* MR23 */ printMessage(stderr, "ctor %s #%d\n",object,ctor);\r
-               }\r
-       virtual ~ANTLRRefCountToken()\r
-               {\r
-                       dtor++;\r
-                       if ( dtor>ctor ) /* MR23 */ printMessage(stderr, "WARNING: dtor>ctor\n");\r
-                       /* MR23 */ printMessage(stderr, "dtor %s #%d\n", object, dtor);\r
-                       object[0]='\0';\r
-               }\r
-#endif\r
-\r
-       // reference counting stuff needed by ANTLRTokenPtr.\r
-       // User should not access these; for C++ language reasons, we had\r
-       // to make these public.  Yuck.\r
-\r
-       void ref()                    { refcnt_++; }\r
-       void deref()          { refcnt_--; }\r
-       unsigned nref() const { return refcnt_; }   // MR11\r
-\r
-       virtual ANTLRAbstractToken *makeToken(ANTLRTokenType /*tt MR23*/,\r
-                                                                                 ANTLRChar * /*txt MR23*/,\r
-                                                                                 int /*line MR23*/)\r
-       {\r
-               panic("call to ANTLRRefCountToken::makeToken()\n");\r
-               return NULL;\r
-       }\r
-};\r
-\r
-class ANTLRCommonNoRefCountToken : public ANTLRAbstractToken {\r
-protected:\r
-       ANTLRTokenType _type;\r
-       int _line;\r
-       ANTLRChar *_text;               // MR9 RJV\r
-\r
-public:\r
-       ANTLRCommonNoRefCountToken(ANTLRTokenType t, const ANTLRChar *s)\r
-       { setType(t); _line = 0; _text = NULL; setText(s); }\r
-       ANTLRCommonNoRefCountToken()\r
-       { setType((ANTLRTokenType)0); _line = 0; _text = NULL; setText(""); }\r
-\r
-       ~ANTLRCommonNoRefCountToken() { if (_text) delete [] _text; }  // MR9 RJV: Added Destructor to remove string\r
-\r
-       ANTLRTokenType getType() const  { return _type; }\r
-       void setType(ANTLRTokenType t)  { _type = t; }\r
-       virtual int getLine() const             { return _line; }\r
-       void setLine(int line)          { _line = line; }\r
-       ANTLRChar *getText() const      { return _text; }\r
-    int getLength() const           { return strlen(getText()); }       // MR11\r
-\r
-// MR9 RJV: Added code for variable length strings to setText()\r
-\r
-       void setText(const ANTLRChar *s)\r
-       {       if (s != _text) {\r
-          if (_text) delete [] _text;\r
-          if (s != NULL) {\r
-               _text = new ANTLRChar[strlen(s)+1];\r
-            if (_text == NULL) panic("ANTLRCommonNoRefCountToken::setText new failed");\r
-            strcpy(_text,s);\r
-         } else {\r
-            _text = new ANTLRChar[1];\r
-            if (_text == NULL) panic("ANTLRCommonNoRefCountToken::setText new failed");\r
-            strcpy(_text,"");\r
-          };\r
-        };\r
-       }\r
-\r
-       virtual ANTLRAbstractToken *makeToken(ANTLRTokenType tt,\r
-                                                                                 ANTLRChar *txt,\r
-                                                                                 int line)\r
-               {\r
-                       ANTLRAbstractToken *t = new ANTLRCommonNoRefCountToken;\r
-                       t->setType(tt); t->setText(txt); t->setLine(line);\r
-                       return t;\r
-               }\r
-\r
-// MR9 THM Copy constructor required when heap allocated string is used with copy semantics\r
-\r
-   ANTLRCommonNoRefCountToken (const ANTLRCommonNoRefCountToken& from) :\r
-         ANTLRAbstractToken(from) {\r
-        setType(from._type);\r
-        setLine(from._line);\r
-     _text=NULL;\r
-     setText(from._text);\r
-  };\r
-\r
-// MR9 THM operator =() required when heap allocated string is used with copy semantics\r
-\r
-   virtual ANTLRCommonNoRefCountToken& operator =(const ANTLRCommonNoRefCountToken& rhs) {\r
-\r
-//////  MR15 WatCom can't hack use of operator =()\r
-//////  Use this:  *( (ANTRLAbstractToken *) this)=rhs;\r
-\r
-     *( (ANTLRAbstractToken *) this ) = rhs;\r
-\r
-        setType(rhs._type);\r
-        setLine(rhs._line);\r
-     setText(rhs._text);\r
-     return *this;\r
-   };\r
-};\r
-\r
-class ANTLRCommonToken : public ANTLRRefCountToken {\r
-protected:\r
-       ANTLRTokenType       _type;\r
-       int                  _line;\r
-       ANTLRChar           *_text;               // MR9 RJV:Added\r
-\r
-public:\r
-       ANTLRCommonToken(ANTLRTokenType t, const ANTLRChar *s) : ANTLRRefCountToken(t,s)\r
-               { setType(t); _line = 0; _text = NULL; setText(s); }                    // MR9\r
-       ANTLRCommonToken()\r
-               { setType((ANTLRTokenType)0); _line = 0; _text = NULL; setText(""); }   // MR9\r
-\r
-       virtual ~ANTLRCommonToken() { if (_text) delete [] _text; } // MR9 RJV: Added Destructor to remove string\r
-\r
-       ANTLRTokenType getType() const  { return _type; }\r
-       void setType(ANTLRTokenType t)  { _type = t; }\r
-       virtual int getLine() const             { return _line; }\r
-       void setLine(int line)          { _line = line; }\r
-       ANTLRChar *getText() const              { return _text; }\r
-    int getLength() const           { return strlen(getText()); }       // MR11\r
-\r
-// MR9 RJV: Added code for variable length strings to setText()\r
-\r
-       void setText(const ANTLRChar *s)\r
-       {       if (s != _text) {\r
-          if (_text) delete [] _text;\r
-          if (s != NULL) {\r
-               _text = new ANTLRChar[strlen(s)+1];\r
-            if (_text == NULL) panic("ANTLRCommonToken::setText new failed");\r
-            strcpy(_text,s);\r
-         } else {\r
-            _text = new ANTLRChar[1];\r
-            if (_text == NULL) panic("ANTLRCommonToken::setText new failed");\r
-            strcpy(_text,"");\r
-          };\r
-        };\r
-       }\r
-\r
-       virtual ANTLRAbstractToken *makeToken(ANTLRTokenType tt,\r
-                                                                                 ANTLRChar *txt,\r
-                                                                                 int line)\r
-       {\r
-               ANTLRAbstractToken *t = new ANTLRCommonToken(tt,txt);\r
-               t->setLine(line);\r
-               return t;\r
-       }\r
-\r
-// MR9 THM Copy constructor required when heap allocated string is used with copy semantics\r
-\r
-   ANTLRCommonToken (const ANTLRCommonToken& from) :\r
-         ANTLRRefCountToken(from) {\r
-        setType(from._type);\r
-        setLine(from._line);\r
-     _text=NULL;\r
-     setText(from._text);\r
-  };\r
-\r
-// MR9 THM operator =() required when heap allocated string is used with copy semantics\r
-\r
-   virtual ANTLRCommonToken& operator =(const ANTLRCommonToken& rhs) {\r
-\r
-//////  MR15 WatCom can't hack use of operator =()\r
-//////  Use this instead:   *( (ANTRLRRefCountToken *) this)=rhs;\r
-\r
-     *( (ANTLRRefCountToken *) this) = rhs;\r
-\r
-        setType(rhs._type);\r
-        setLine(rhs._line);\r
-     setText(rhs._text);\r
-     return *this;\r
-   };\r
-};\r
-\r
-// used for backward compatibility\r
-typedef ANTLRCommonToken ANTLRCommonBacktrackingToken;\r
-\r
-#endif\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/h/ATokenBuffer.cpp b/Tools/CodeTools/TianoTools/Pccts/h/ATokenBuffer.cpp
deleted file mode 100644 (file)
index 9a2f2fc..0000000
+++ /dev/null
@@ -1,374 +0,0 @@
-/* ANTLRTokenBuffer.cpp\r
- *\r
- * SOFTWARE RIGHTS\r
- *\r
- * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
- * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
- * company may do whatever they wish with source code distributed with\r
- * PCCTS or the code generated by PCCTS, including the incorporation of\r
- * PCCTS, or its output, into commerical software.\r
- *\r
- * We encourage users to develop software with PCCTS.  However, we do ask\r
- * that credit is given to us for developing PCCTS.  By "credit",\r
- * we mean that if you incorporate our source code into one of your\r
- * programs (commercial product, research project, or otherwise) that you\r
- * acknowledge this fact somewhere in the documentation, research report,\r
- * etc...  If you like PCCTS and have developed a nice tool with the\r
- * output, please mention that you developed it using PCCTS.  In\r
- * addition, we ask that this header remain intact in our source code.\r
- * As long as these guidelines are kept, we expect to continue enhancing\r
- * this system and expect to make other tools available as they are\r
- * completed.\r
- *\r
- * ANTLR 1.33\r
- * Terence Parr\r
- * Parr Research Corporation\r
- * with Purdue University and AHPCRC, University of Minnesota\r
- * 1989-2000\r
- */\r
-\r
-typedef int ANTLRTokenType;    // fool AToken.h into compiling\r
-\r
-class ANTLRParser;                                     /* MR1 */\r
-\r
-#define ANTLR_SUPPORT_CODE\r
-\r
-#include "pcctscfg.h"\r
-\r
-#include ATOKENBUFFER_H\r
-#include APARSER_H             // MR23\r
-\r
-typedef ANTLRAbstractToken *_ANTLRTokenPtr;\r
-\r
-#if defined(DBG_TBUF)||defined(DBG_TBUF_MARK_REW)\r
-static unsigned char test[1000];\r
-#endif\r
-\r
-#ifdef DBG_REFCOUNTTOKEN\r
-int ANTLRRefCountToken::ctor = 0; /* MR23 */\r
-int ANTLRRefCountToken::dtor = 0; /* MR23 */\r
-#endif\r
-\r
-ANTLRTokenBuffer::\r
-ANTLRTokenBuffer(ANTLRTokenStream *_input, int _k, int _chunk_size_formal) /* MR14 */\r
-{\r
-       this->input = _input;\r
-       this->k = _k;\r
-       buffer_size = chunk_size = _chunk_size_formal;\r
-       buffer = (_ANTLRTokenPtr *)\r
-                        calloc(chunk_size+1,sizeof(_ANTLRTokenPtr ));\r
-       if ( buffer == NULL ) {\r
-               panic("cannot alloc token buffer");\r
-       }\r
-       buffer++;                               // leave the first elem empty so tp-1 is valid ptr\r
-\r
-       tp = &buffer[0];\r
-       last = tp-1;\r
-       next = &buffer[0];\r
-       num_markers = 0;\r
-       end_of_buffer = &buffer[buffer_size-1];\r
-       threshold = &buffer[(int)(buffer_size/2)];      // MR23 - Used to be 1.0/2.0 !\r
-       _deleteTokens = 1;      // assume we delete tokens\r
-       parser=NULL;                            // MR5 - uninitialized reference\r
-}\r
-\r
-static void f() {;}\r
-ANTLRTokenBuffer::\r
-~ANTLRTokenBuffer()\r
-{\r
-       f();\r
-       // Delete all remaining tokens (from 0..last inclusive)\r
-       if ( _deleteTokens )\r
-       {\r
-               _ANTLRTokenPtr *z;\r
-               for (z=buffer; z<=last; z++)\r
-               {\r
-                       (*z)->deref();\r
-//                     z->deref();\r
-#ifdef DBG_REFCOUNTTOKEN\r
-                                       /* MR23 */ printMessage(stderr, "##########dtor: deleting token '%s' (ref %d)\n",\r
-                                                       ((ANTLRCommonToken *)*z)->getText(), (*z)->nref());\r
-#endif\r
-                       if ( (*z)->nref()==0 )\r
-                       {\r
-                               delete (*z);\r
-                       }\r
-               }\r
-       }\r
-\r
-       if ( buffer!=NULL ) free((char *)(buffer-1));\r
-}\r
-\r
-#if defined(DBG_TBUF)||defined(DBG_TBUF_MARK_REW)\r
-#include "pccts_stdio.h"\r
-PCCTS_NAMESPACE_STD\r
-#endif\r
-\r
-_ANTLRTokenPtr ANTLRTokenBuffer::\r
-getToken()\r
-{\r
-       if ( tp <= last )       // is there any buffered lookahead still to be read?\r
-       {\r
-               return *tp++;   // read buffered lookahead\r
-       }\r
-       // out of buffered lookahead, get some more "real"\r
-       // input from getANTLRToken()\r
-       if ( num_markers==0 )\r
-       {\r
-               if( next > threshold )\r
-               {\r
-#ifdef DBG_TBUF\r
-/* MR23 */ printMessage(stderr,"getToken: next > threshold (high water is %d)\n", threshold-buffer);\r
-#endif\r
-                       makeRoom();\r
-               }\r
-       }\r
-       else {\r
-               if ( next > end_of_buffer )\r
-               {\r
-#ifdef DBG_TBUF\r
-/* MR23 */ printMessage(stderr,"getToken: next > end_of_buffer (size is %d)\n", buffer_size);\r
-#endif\r
-                       extendBuffer();\r
-               }\r
-       }\r
-       *next = getANTLRToken();\r
-       (*next)->ref();                         // say we have a copy of this pointer in buffer\r
-       last = next;\r
-       next++;\r
-       tp = last;\r
-       return *tp++;\r
-}\r
-\r
-void ANTLRTokenBuffer::\r
-rewind(int pos)\r
-{\r
-#if defined(DBG_TBUF)||defined(DBG_TBUF_MARK_REW)\r
-       /* MR23 */ printMessage(stderr, "rewind(%d)[nm=%d,from=%d,%d.n=%d]\n", pos, num_markers, tp-buffer,pos,test[pos]);\r
-       test[pos]--;\r
-#endif\r
-       tp = &buffer[pos];\r
-       num_markers--;\r
-}\r
-\r
-/*\r
- * This function is used to specify that the token pointers read\r
- * by the ANTLRTokenBuffer should be buffered up (to be reused later).\r
- */\r
-int ANTLRTokenBuffer::\r
-mark()\r
-{\r
-#if defined(DBG_TBUF)||defined(DBG_TBUF_MARK_REW)\r
-       test[tp-buffer]++;\r
-       /* MR23 */ printMessage(stderr,"mark(%d)[nm=%d,%d.n=%d]\n",tp-buffer,num_markers+1,tp-buffer,test[tp-buffer]);\r
-#endif\r
-       num_markers++;\r
-       return tp - buffer;\r
-}\r
-\r
-/*\r
- * returns the token pointer n positions ahead.\r
- * This implies that bufferedToken(1) gets the NEXT symbol of lookahead.\r
- * This is used in conjunction with the ANTLRParser lookahead buffer.\r
- *\r
- * No markers are set or anything.  A bunch of input is buffered--that's all.\r
- * The tp pointer is left alone as the lookahead has not been advanced\r
- * with getToken().  The next call to getToken() will find a token\r
- * in the buffer and won't have to call getANTLRToken().\r
- *\r
- * If this is called before a consume() is done, how_many_more_i_need is\r
- * set to 'n'.\r
- */\r
-_ANTLRTokenPtr ANTLRTokenBuffer::\r
-bufferedToken(int n)\r
-{\r
-//     int how_many_more_i_need = (last-tp < 0) ? n : n-(last-tp)-1;\r
-       int how_many_more_i_need = (tp > last) ? n : n-(last-tp)-1;\r
-       // Make sure that at least n tokens are available in the buffer\r
-#ifdef DBG_TBUF\r
-       /* MR23 */ printMessage(stderr, "bufferedToken(%d)\n", n);\r
-#endif\r
-       for (int i=1; i<=how_many_more_i_need; i++)\r
-       {\r
-               if ( next > end_of_buffer )     // buffer overflow?\r
-               {\r
-                       extendBuffer();\r
-               }\r
-               *next = getANTLRToken();\r
-               (*next)->ref();         // say we have a copy of this pointer in buffer\r
-               last = next;\r
-               next++;\r
-       }\r
-       return tp[n - 1];\r
-}\r
-\r
-/* If no markers are set, the none of the input needs to be saved (except\r
- * for the lookahead Token pointers).  We save only k-1 token pointers as\r
- * we are guaranteed to do a getANTLRToken() right after this because otherwise\r
- * we wouldn't have needed to extend the buffer.\r
- *\r
- * If there are markers in the buffer, we need to save things and so\r
- * extendBuffer() is called.\r
- */\r
-void ANTLRTokenBuffer::\r
-makeRoom()\r
-{\r
-#ifdef DBG_TBUF\r
-       /* MR23 */ printMessage(stderr, "in makeRoom.................\n");\r
-       /* MR23 */ printMessage(stderr, "num_markers==%d\n", num_markers);\r
-#endif\r
-/*\r
-       if ( num_markers == 0 )\r
-       {\r
-*/\r
-#ifdef DBG_TBUF\r
-               /* MR23 */ printMessage(stderr, "moving lookahead and resetting next\n");\r
-\r
-               _ANTLRTokenPtr *r;\r
-               /* MR23 */ printMessage(stderr, "tbuf = [");\r
-               for (r=buffer; r<=last; r++)\r
-               {\r
-                       if ( *r==NULL ) /* MR23 */ printMessage(stderr, " xxx");\r
-                       else /* MR23 */ printMessage(stderr, " '%s'", ((ANTLRCommonToken *)*r)->getText());\r
-               }\r
-               /* MR23 */ printMessage(stderr, " ]\n");\r
-\r
-               /* MR23 */ printMessage(stderr,\r
-               "before: tp=%d, last=%d, next=%d, threshold=%d\n",tp-buffer,last-buffer,next-buffer,threshold-buffer);\r
-#endif\r
-\r
-               // Delete all tokens from 0..last-(k-1) inclusive\r
-               if ( _deleteTokens )\r
-               {\r
-                       _ANTLRTokenPtr *z;\r
-                       for (z=buffer; z<=last-(k-1); z++)\r
-                       {\r
-                               (*z)->deref();\r
-//                             z->deref();\r
-#ifdef DBG_REFCOUNTTOKEN\r
-                                       /* MR23 */ printMessage(stderr, "##########makeRoom: deleting token '%s' (ref %d)\n",\r
-                                                       ((ANTLRCommonToken *)*z)->getText(), (*z)->nref());\r
-#endif\r
-                               if ( (*z)->nref()==0 )\r
-                               {\r
-                                       delete (*z);\r
-                               }\r
-                       }\r
-               }\r
-\r
-               // reset the buffer to initial conditions, but move k-1 symbols\r
-               // to the beginning of buffer and put new input symbol at k\r
-               _ANTLRTokenPtr *p = buffer, *q = last-(k-1)+1;\r
-//             ANTLRAbstractToken **p = buffer, **q = end_of_buffer-(k-1)+1;\r
-#ifdef DBG_TBUF\r
-               /* MR23 */ printMessage(stderr, "lookahead buffer = [");\r
-#endif\r
-               for (int i=1; i<=(k-1); i++)\r
-               {\r
-                       *p++ = *q++;\r
-#ifdef DBG_TBUF\r
-                       /* MR23 */ printMessage(stderr,\r
-                       " '%s'", ((ANTLRCommonToken *)buffer[i-1])->getText());\r
-#endif\r
-               }\r
-#ifdef DBG_TBUF\r
-               /* MR23 */ printMessage(stderr, " ]\n");\r
-#endif\r
-               next = &buffer[k-1];\r
-               tp = &buffer[k-1];      // tp points to what will be filled in next\r
-               last = tp-1;\r
-#ifdef DBG_TBUF\r
-               /* MR23 */ printMessage(stderr,\r
-               "after: tp=%d, last=%d, next=%d\n",\r
-               tp-buffer, last-buffer, next-buffer);\r
-#endif\r
-/*\r
-       }\r
-       else {\r
-               extendBuffer();\r
-       }\r
-*/\r
-}\r
-\r
-/* This function extends 'buffer' by chunk_size and returns with all\r
- * pointers at the same relative positions in the buffer (the buffer base\r
- * address could have changed in realloc()) except that 'next' comes\r
- * back set to where the next token should be stored.  All other pointers\r
- * are untouched.\r
- */\r
-void\r
-ANTLRTokenBuffer::\r
-extendBuffer()\r
-{\r
-       int save_last = last-buffer, save_tp = tp-buffer, save_next = next-buffer;\r
-#ifdef DBG_TBUF\r
-       /* MR23 */ printMessage(stderr, "extending physical buffer\n");\r
-#endif\r
-       buffer_size += chunk_size;\r
-       buffer = (_ANTLRTokenPtr *)\r
-               realloc((char *)(buffer-1),\r
-                               (buffer_size+1)*sizeof(_ANTLRTokenPtr ));\r
-       if ( buffer == NULL ) {\r
-               panic("cannot alloc token buffer");\r
-       }\r
-       buffer++;                               // leave the first elem empty so tp-1 is valid ptr\r
-\r
-       tp = buffer + save_tp;  // put the pointers back to same relative position\r
-       last = buffer + save_last;\r
-       next = buffer + save_next;\r
-       end_of_buffer = &buffer[buffer_size-1];\r
-       threshold = &buffer[(int)(buffer_size*(1.0/2.0))];\r
-\r
-/*\r
-       // zero out new token ptrs so we'll know if something to delete in buffer\r
-       ANTLRAbstractToken **p = end_of_buffer-chunk_size+1;\r
-       for (; p<=end_of_buffer; p++) *p = NULL;\r
-*/\r
-}\r
-\r
-ANTLRParser * ANTLRTokenBuffer::                               // MR1\r
-setParser(ANTLRParser *p) {                                    // MR1\r
-  ANTLRParser  *old=parser;                                    // MR1\r
-  parser=p;                                                    // MR1\r
-  input->setParser(p);                                         // MR1\r
-  return old;                                                  // MR1\r
-}                                                              // MR1\r
-                                                               // MR1\r
-ANTLRParser * ANTLRTokenBuffer::                               // MR1\r
-getParser() {                                                  // MR1\r
-  return parser;                                               // MR1\r
-}                                                              // MR1\r
-\r
-void ANTLRTokenBuffer::panic(const char *msg) // MR23\r
-{ \r
-       if (parser)                             //MR23\r
-               parser->panic(msg);     //MR23\r
-       else                                    //MR23\r
-               exit(PCCTS_EXIT_FAILURE); \r
-} \r
-\r
-//MR23\r
-int ANTLRTokenBuffer::printMessage(FILE* pFile, const char* pFormat, ...)\r
-{\r
-       va_list marker;\r
-       va_start( marker, pFormat );\r
-\r
-       int iRet = 0;\r
-       if (parser)\r
-               parser->printMessageV(pFile, pFormat, marker);\r
-       else\r
-               iRet = vfprintf(pFile, pFormat, marker);\r
-\r
-       va_end( marker );\r
-       return iRet;\r
-}\r
-\r
-/* to avoid having to link in another file just for the smart token ptr\r
- * stuff, we include it here.  Ugh.\r
- *\r
- * MR23 This causes nothing but problems for IDEs.\r
- *      Change from .cpp to .h\r
- *\r
- */\r
-\r
-#include ATOKPTR_IMPL_H\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/h/ATokenBuffer.h b/Tools/CodeTools/TianoTools/Pccts/h/ATokenBuffer.h
deleted file mode 100644 (file)
index 1c008fd..0000000
+++ /dev/null
@@ -1,109 +0,0 @@
-/* ANTLRTokenBuffer.h\r
- *\r
- * SOFTWARE RIGHTS\r
- *\r
- * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
- * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
- * company may do whatever they wish with source code distributed with\r
- * PCCTS or the code generated by PCCTS, including the incorporation of\r
- * PCCTS, or its output, into commerical software.\r
- *\r
- * We encourage users to develop software with PCCTS.  However, we do ask\r
- * that credit is given to us for developing PCCTS.  By "credit",\r
- * we mean that if you incorporate our source code into one of your\r
- * programs (commercial product, research project, or otherwise) that you\r
- * acknowledge this fact somewhere in the documentation, research report,\r
- * etc...  If you like PCCTS and have developed a nice tool with the\r
- * output, please mention that you developed it using PCCTS.  In\r
- * addition, we ask that this header remain intact in our source code.\r
- * As long as these guidelines are kept, we expect to continue enhancing\r
- * this system and expect to make other tools available as they are\r
- * completed.\r
- *\r
- * ANTLR 1.33\r
- * Terence Parr\r
- * Parr Research Corporation\r
- * with Purdue University and AHPCRC, University of Minnesota\r
- * 1989-2000\r
- */\r
-\r
-#ifndef ATOKENBUFFER_H_GATE\r
-#define ATOKENBUFFER_H_GATE\r
-\r
-#include "pcctscfg.h"\r
-\r
-#include "pccts_stdlib.h"\r
-\r
-PCCTS_NAMESPACE_STD\r
-\r
-#include ATOKEN_H\r
-#include ATOKENSTREAM_H\r
-\r
-/*\r
- * The parser is "attached" to an ANTLRTokenBuffer via interface\r
- * functions: getToken() and bufferedToken().  The object that actually\r
- * consumes characters and constructs tokens is connected to the\r
- * ANTLRTokenBuffer via interface function ANTLRTokenStream::getToken();\r
- * where ANTLRTokenStream is really just a behavior (class with no data).\r
- * C++ does not have this abstraction and hence we simply have come up\r
- * with a fancy name for "void *".  See the note in ANTLRTokenStream.h on\r
- * the "behavior" of ANTLRTokenStream.\r
- */\r
-\r
-class ANTLRParser;                                     // MR1\r
-\r
-class DllExportPCCTS ANTLRTokenBuffer {\r
-protected:\r
-       ANTLRTokenStream *input;        // where do I get tokens\r
-       int buffer_size;\r
-       int chunk_size;\r
-       int num_markers;\r
-       int k;                          // Need at least this many tokens in buffer\r
-       _ANTLRTokenPtr *buffer; // buffer used for arbitrary lookahead\r
-       _ANTLRTokenPtr *tp;        // pts into buffer; current token ptr\r
-       _ANTLRTokenPtr *last;      // pts to last valid token in buffer\r
-       _ANTLRTokenPtr *next;      // place to put token from getANTLRToken()\r
-       _ANTLRTokenPtr *end_of_buffer;\r
-       /* when you try to write a token past this and there are no markers\r
-          set, then move k-1 tokens back to the beginning of the buffer.\r
-          We want to stay away from the end of the buffer because we have\r
-          to extend it if a marker is set and we reach the end (we cannot\r
-          move tokens to the beginning of the buffer in this case).\r
-        */\r
-       _ANTLRTokenPtr *threshold;\r
-       unsigned char _deleteTokens;\r
-\r
-       // This function is filled in by the subclass; it initiates fetch of input\r
-       virtual _ANTLRTokenPtr getANTLRToken() { return input->getToken(); }\r
-       void makeRoom();\r
-       void extendBuffer();\r
-\r
-public:\r
-       ANTLRTokenBuffer(ANTLRTokenStream *in, int k=1, int chksz=50);\r
-       virtual ~ANTLRTokenBuffer();\r
-       virtual _ANTLRTokenPtr getToken();\r
-       virtual void rewind(int pos);\r
-       virtual int mark();\r
-       virtual _ANTLRTokenPtr bufferedToken(int i);\r
-\r
-       void noGarbageCollectTokens()   { _deleteTokens=0; }\r
-       void garbageCollectTokens()             { _deleteTokens=1; }\r
-\r
-       virtual int bufferSize() { return buffer_size; }\r
-       virtual int minTokens() { return k; }\r
-       virtual void setMinTokens(int k_new) { k = k_new; }\r
-\r
-       virtual void panic(const char *msg); /* MR20 const */\r
-\r
-       virtual int printMessage(FILE* pFile, const char* pFormat, ...); // MR23\r
-\r
-protected:                                             // MR1\r
-       ANTLRParser     *parser;                        // MR1\r
-public:                                                        // MR1\r
-       ANTLRParser     *setParser(ANTLRParser *p);     // MR1\r
-       ANTLRParser     *getParser();                       // MR1\r
-    ANTLRTokenStream *getLexer() const {    // MR12\r
-      return input;}                        // MR12\r
-};\r
-\r
-#endif\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/h/ATokenStream.h b/Tools/CodeTools/TianoTools/Pccts/h/ATokenStream.h
deleted file mode 100644 (file)
index 3dfea6e..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-/* ANTLRTokenStream.h\r
- *\r
- * SOFTWARE RIGHTS\r
- *\r
- * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
- * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
- * company may do whatever they wish with source code distributed with\r
- * PCCTS or the code generated by PCCTS, including the incorporation of\r
- * PCCTS, or its output, into commerical software.\r
- *\r
- * We encourage users to develop software with PCCTS.  However, we do ask\r
- * that credit is given to us for developing PCCTS.  By "credit",\r
- * we mean that if you incorporate our source code into one of your\r
- * programs (commercial product, research project, or otherwise) that you\r
- * acknowledge this fact somewhere in the documentation, research report,\r
- * etc...  If you like PCCTS and have developed a nice tool with the\r
- * output, please mention that you developed it using PCCTS.  In\r
- * addition, we ask that this header remain intact in our source code.\r
- * As long as these guidelines are kept, we expect to continue enhancing\r
- * this system and expect to make other tools available as they are\r
- * completed.\r
- *\r
- * ANTLR 1.33\r
- * Terence Parr\r
- * Parr Research Corporation\r
- * with Purdue University and AHPCRC, University of Minnesota\r
- * 1989-2000\r
- */\r
-\r
-#ifndef ATOKENSTREAM_H_GATE\r
-#define ATOKENSTREAM_H_GATE\r
-\r
-#include "pcctscfg.h"\r
-\r
-/* This is really a behavior or protocol; it merely indicates the behavior\r
- * required of the input and output of an ANTLRTokenBuffer.  You could\r
- * subclass it, but you can also just pass any old pointer to ANTLRTokenBuffer\r
- * with a type cast (in which case, your getANTLRToken() would have to\r
- * explicitly cast the input pointer to your REAL type (typically your lexer)).\r
- */\r
-\r
-class ANTLRParser;                                                     // MR1\r
-\r
-class DllExportPCCTS ANTLRTokenStream {\r
-public:\r
-    virtual _ANTLRTokenPtr getToken() = 0;\r
-       virtual ANTLRParser * setParser(ANTLRParser * /*p MR23*/) {return 0; };   // MR12\r
-       virtual ANTLRParser * getParser() { return 0; };                        // MR12\r
-};\r
-\r
-#endif\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/h/BufFileInput.cpp b/Tools/CodeTools/TianoTools/Pccts/h/BufFileInput.cpp
deleted file mode 100644 (file)
index 99d08a4..0000000
+++ /dev/null
@@ -1,100 +0,0 @@
-// FILE:        BufFileInput.cpp\r
-// AUTHOR:      Alexey Demakov (AVD) demakov@kazbek.ispras.ru\r
-// CREATION:    26-JAN-1998\r
-// DESCRIPTION: File Input Stream with lookahead for Scanner.\r
-//   See file BufFileInput.h for details\r
-\r
-// Change History:\r
-//\r
-//   22-Jun-1998    assert.h -> PCCTS_ASSERT_H\r
-//                  string.h -> PCCTS_STRING_H\r
-//\r
-//   28-May-1998    Add virtual destructor to release buffer.\r
-//\r
-//                  Add dummy definition for ANTLRTokenType\r
-//                  to allow compilation without knowing\r
-//                  token type codes.\r
-//\r
-//                  Manfred Kogler (km@cast.uni-linz.ac.at)\r
-//                  (1.33MR14)\r
-//\r
-//   20-Jul-1998    MR14a - Reorder initialization list for ctor.\r
-//\r
-\r
-enum ANTLRTokenType {TER_HATES_CPP=0, SO_DO_OTHERS=9999 };\r
-\r
-#include "pcctscfg.h"\r
-#include "pccts_assert.h"\r
-#include "pccts_string.h"\r
-\r
-PCCTS_NAMESPACE_STD\r
-\r
-#include "BufFileInput.h"\r
-\r
-BufFileInput::BufFileInput( FILE *f, int buf_size )\r
-: input( f ),\r
-  buf( new int[buf_size] ),\r
-  size( buf_size ),\r
-  start( 0 ),\r
-  len( 0 )\r
-{\r
-}\r
-\r
-BufFileInput::~BufFileInput()\r
-{\r
-  delete [] buf;\r
-}\r
-\r
-int BufFileInput::nextChar( void )\r
-{\r
-    if( len > 0 )\r
-    {\r
-        // get char from buffer\r
-        int c = buf[start];\r
-\r
-        if( c != EOF )\r
-        {\r
-            start++; start %= size;\r
-            len--;\r
-        }\r
-        return c;\r
-    } else {\r
-        // get char from file\r
-        int c = getc( input );\r
-\r
-        if( c == EOF )\r
-        {\r
-            // if EOF - put it in the buffer as indicator\r
-            buf[start] = EOF;\r
-            len++;\r
-        }\r
-        return c;\r
-    }\r
-}\r
-\r
-int BufFileInput::lookahead( char* s )\r
-{\r
-    int l = strlen( s );\r
-\r
-    assert( 0 < l && l <= size );\r
-\r
-    while( len < l )\r
-    {\r
-        int c = getc( input );\r
-\r
-        buf[ (start+len) % size ] = c;\r
-\r
-        len++;\r
-\r
-        if( c == EOF ) return 0;\r
-    }\r
-\r
-    for( int i = 0; i < l; i++ )\r
-    {\r
-        if( s[i] != buf[ (start+i) % size ] ) return 0;\r
-    }\r
-    return 1;\r
-}\r
-\r
-// End of file BufFileInput.cpp\r
-\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/h/BufFileInput.h b/Tools/CodeTools/TianoTools/Pccts/h/BufFileInput.h
deleted file mode 100644 (file)
index ea54c0e..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-// FILE:        BufFileInput.h\r
-// AUTHOR:      Alexey Demakov (AVD) demakov@kazbek.ispras.ru\r
-// CREATION:    26-JAN-1998\r
-// DESCRIPTION: File Input Stream with lookahead for Scanner\r
-// Tested under Win32 with ANTLR 1.33 MR10 and MSVC 5.0\r
-\r
-// Change History:\r
-//\r
-//   28-May-1998    Add virtual destructor to release buffer\r
-//                  Manfred Kogler (km@cast.uni-linz.ac.at)\r
-//                  (1.33MR14)\r
-\r
-#ifndef BufFileInput_h\r
-#define BufFileInput_h\r
-\r
-#include "pcctscfg.h"\r
-\r
-#include "pccts_stdio.h"\r
-\r
-PCCTS_NAMESPACE_STD\r
-\r
-#include "DLexerBase.h"\r
-\r
-class DllExportPCCTS BufFileInput : public DLGInputStream\r
-{\r
-public:\r
-    // constructor\r
-    // f - input stream\r
-    // buf_size - size of buffer (maximal length for string in is_in)\r
-\r
-    BufFileInput(FILE *f, int buf_size = 8 );\r
-\r
-    virtual ~BufFileInput();\r
-\r
-    // gets next char from stream\r
-\r
-    virtual int nextChar( void );\r
-\r
-    // looks in stream and compares next l characters with s\r
-    // returns the result of comparision\r
-\r
-    int lookahead( char* s );\r
-\r
-private:\r
-    FILE *input; // input stream;\r
-    int* buf;    // buffer\r
-    int  size;   // size of buffer\r
-    int  start;  // position of the first symbol in buffer\r
-    int  len;    // count of characters in buffers\r
-};\r
-\r
-#endif\r
-// end of file BufFileInput.h\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/h/DLG_stream_input.h b/Tools/CodeTools/TianoTools/Pccts/h/DLG_stream_input.h
deleted file mode 100644 (file)
index d2147f5..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-\r
-/************************************************************/\r
-/*                                                                                                                     */\r
-/*             Predefined char stream: Input from (c++) stream.        */\r
-/*                                                                                                                     */\r
-/* By Hubert Holin (Hubert.Holin@Bigfoot.com), 1998.           */\r
-/*                                                                                                                     */\r
-/* This is completely free stuff, do whatever you want with    */\r
-/* it (but then, I will take no responsability for whatever    */\r
-/* may happen if you do either... caveat emptor!).                     */\r
-/*                                                                                                                     */\r
-/************************************************************/\r
-\r
-#ifndef _DLG_STREAM_INPUT_H\r
-#define _DLG_STREAM_INPUT_H\r
-\r
-#include "pccts_istream.h"\r
-\r
-PCCTS_NAMESPACE_STD\r
-\r
-#ifndef DLGX_H\r
-#include "DLexerBase.h"\r
-#endif\r
-\r
-\r
-// NOTES:      The semantics of the copy constructor\r
-//                     and the affectation operator may be unwaranted...\r
-//                     and the stream may not be reset.\r
-//\r
-//                     It would have been so much nicer for nextChar()\r
-//                     to throw (of for the DLGInputStream to change status)\r
-//                     upon hiting EOF than to return an "int"...\r
-\r
-template       <\r
-                               class E,\r
-                               class T = ::std::char_traits<E>\r
-                       >\r
-class DLG_stream_input : public DLGInputStream\r
-{\r
-public:\r
-       \r
-                                               DLG_stream_input(::std::basic_istream<E,T> * p_input_stream)\r
-       :       input(p_input_stream)\r
-       {\r
-               // nothing to do!\r
-       };\r
-       \r
-                                               DLG_stream_input(const DLG_stream_input & a_recopier)\r
-       :       input(a_recopier.input)\r
-       {\r
-               // nothing to do!\r
-       };\r
-       \r
-       virtual                         ~DLG_stream_input()\r
-       {\r
-               this->purge();  // bloody templarized lookup...\r
-       };\r
-       \r
-       DLG_stream_input        operator = (const DLG_stream_input & a_affecter)\r
-       {\r
-               if (this != &a_affecter)\r
-               {\r
-                       input = a_affecter.input;\r
-               }\r
-\r
-               return(*this);\r
-       };\r
-       \r
-       virtual int                     nextChar()\r
-       {\r
-               E       extracted_stuff;\r
-               \r
-               input->get(extracted_stuff);\r
-               \r
-               if      (*input)\r
-               {\r
-                       return(int(extracted_stuff));\r
-               }\r
-               else\r
-               {\r
-                       return(EOF);\r
-               }\r
-       };\r
-       \r
-protected:\r
-       \r
-       ::std::basic_istream<E,T> *     input;\r
-       \r
-private:\r
-       \r
-       void    purge()\r
-       {\r
-               // nothing to do!\r
-       };\r
-};\r
-\r
-#endif /* _DLG_STREAM_INPUT_H */\r
-\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/h/DLexer.h b/Tools/CodeTools/TianoTools/Pccts/h/DLexer.h
deleted file mode 100644 (file)
index 37cac24..0000000
+++ /dev/null
@@ -1,191 +0,0 @@
-/* DLexer.h (formerly DLexer.cpp)\r
- *\r
- * This was renamed because the use of the .cpp extension caused problems\r
- * with IDEs.\r
- *\r
- * SOFTWARE RIGHTS\r
- *\r
- * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
- * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
- * company may do whatever they wish with source code distributed with\r
- * PCCTS or the code generated by PCCTS, including the incorporation of\r
- * PCCTS, or its output, into commerical software.\r
- *\r
- * We encourage users to develop software with PCCTS.  However, we do ask\r
- * that credit is given to us for developing PCCTS.  By "credit",\r
- * we mean that if you incorporate our source code into one of your\r
- * programs (commercial product, research project, or otherwise) that you\r
- * acknowledge this fact somewhere in the documentation, research report,\r
- * etc...  If you like PCCTS and have developed a nice tool with the\r
- * output, please mention that you developed it using PCCTS.  In\r
- * addition, we ask that this header remain intact in our source code.\r
- * As long as these guidelines are kept, we expect to continue enhancing\r
- * this system and expect to make other tools available as they are\r
- * completed.\r
- *\r
- * ANTLR 1.33\r
- * Terence Parr\r
- * Parr Research Corporation\r
- * with Purdue University and AHPCRC, University of Minnesota\r
- * 1989-2000\r
- */\r
-\r
-#define ZZINC {if ( track_columns ) (++_endcol);}\r
-\r
-#define ZZGETC {ch = input->nextChar(); cl = ZZSHIFT(ch);}\r
-\r
-#define ZZNEWSTATE     (newstate = dfa[state][cl])\r
-\r
-#ifndef ZZCOPY\r
-#define ZZCOPY \\r
-       /* Truncate matching buffer to size (not an error) */   \\r
-       if (nextpos < lastpos){                         \\r
-               *(nextpos++) = ch;                      \\r
-       }else{                                                  \\r
-               bufovf = 1;                                     \\r
-       }\r
-#endif\r
-\r
-void DLGLexer::\r
-mode( int m )\r
-{\r
-       /* points to base of dfa table */\r
-       if (m<MAX_MODE){\r
-               automaton = m;\r
-               /* have to redo class since using different compression */\r
-               cl = ZZSHIFT(ch);\r
-       }else{\r
-               sprintf((char *)ebuf,"Invalid automaton mode = %d ",m);\r
-               errstd(ebuf);\r
-       }\r
-}\r
-\r
-ANTLRTokenType DLGLexer::\r
-nextTokenType(void)\r
-{\r
-       register int state, newstate;\r
-       /* last space reserved for the null char */\r
-       register DLGChar *lastpos;\r
-       ANTLRTokenType tk;\r
-\r
-skip:\r
-       bufovf = 0;\r
-       lastpos = &_lextext[_bufsize-1];\r
-       nextpos = _lextext;\r
-       _begcol = _endcol+1;\r
-more:\r
-       _begexpr = nextpos;\r
-       if ( interactive ) {\r
-               /* interactive version of automaton */\r
-               /* if there is something in ch, process it */\r
-               state = newstate = dfa_base[automaton];\r
-               if (charfull){\r
-                       ZZINC;\r
-                       ZZCOPY;\r
-                       ZZNEWSTATE;\r
-               }\r
-               while (alternatives[newstate]){\r
-                       state = newstate;\r
-                       ZZGETC;\r
-                       ZZINC;\r
-                       ZZCOPY;\r
-                       ZZNEWSTATE;\r
-               }\r
-               /* figure out if last character really part of token */\r
-               if ((state != dfa_base[automaton]) && (newstate == DfaStates)){\r
-                       charfull = 1;\r
-                       --nextpos;\r
-               }else{\r
-                       charfull = 0;\r
-                       state = newstate;\r
-               }\r
-               *(nextpos) = '\0';\r
-               /* Able to transition out of start state to some non err state?*/\r
-               if ( state == dfa_base[automaton] ){\r
-                       /* make sure doesn't get stuck */\r
-                       advance();\r
-               }\r
-       }\r
-       else { /* non-interactive version of automaton */\r
-               if (!charfull)\r
-                       advance();\r
-               else\r
-                       ZZINC;\r
-               state = dfa_base[automaton];\r
-               while (ZZNEWSTATE != DfaStates) {\r
-                       state = newstate;\r
-                       ZZCOPY;\r
-                       ZZGETC;\r
-                       ZZINC;\r
-               }\r
-               charfull = 1;\r
-               if ( state == dfa_base[automaton] ){\r
-                       if (nextpos < lastpos){\r
-                               *(nextpos++) = ch;\r
-                       }else{\r
-                               bufovf = 1;\r
-                       }\r
-                       *nextpos = '\0';\r
-                       /* make sure doesn't get stuck */\r
-                       advance();\r
-               }else{\r
-                       *nextpos = '\0';\r
-               }\r
-       }\r
-       if ( track_columns ) _endcol -= charfull;\r
-       _endexpr = nextpos -1;\r
-       add_erase = 0;\r
-#ifdef OLD\r
-       tk = (ANTLRTokenType)\r
-                (*actions[accepts[state]])(this);      // must pass this manually\r
-                                                                                       // actions is not a [] of pointers\r
-                                                                                       // to member functions.\r
-#endif\r
-       tk = (this->*actions[accepts[state]])();\r
-\r
-// MR1\r
-// MR1 11-Apr-97  Help for tracking DLG results\r
-// MR1\r
-\r
-#ifdef DEBUG_LEXER\r
-\r
-/* MR1 */        if (debugLexerFlag) {\r
-/* MR1 */         if (parser != NULL) {\r
-/* MR1 */           /* MR23 */ printMessage(stdout, "\ntoken name=%s",parser->parserTokenName(tk));\r
-/* MR1 */         } else {\r
-/* MR1 */           /* MR23 */ printMessage(stdout, "\ntoken nnumber=%d",tk);\r
-/* MR1 */         };\r
-/* MR1 */         /* MR23 */ printMessage(stdout, " lextext=(%s) mode=%d",\r
-/* MR1 */               (_lextext[0]=='\n' && _lextext[1]==0) ?\r
-/* MR1 */                      "newline" : _lextext,\r
-/* MR1 */                              automaton);\r
-/* MR1 */          if (interactive && !charfull) {\r
-/* MR1 */           /* MR23 */ printMessage(stdout, " char=empty");\r
-/* MR1 */          } else {\r
-/* MR1 */           if (ch=='\n') {\r
-/* MR1 */             /* MR23 */ printMessage(stdout, " char=newline");\r
-/* MR1 */           } else {\r
-/* MR1 */             /* MR23 */ printMessage(stdout, " char=(%c)",ch);\r
-/* MR1 */           };\r
-/* MR1 */         };\r
-/* MR1 */         /* MR23 */ printMessage(stdout, " %s\n",\r
-/* MR1 */               (add_erase==1 ? "skip()" :\r
-/* MR1 */                add_erase==2 ? "more()" :\r
-/* MR1 */                ""));\r
-/* MR1 */        };\r
-\r
-#endif\r
-\r
-       switch (add_erase) {\r
-               case 1: goto skip;\r
-               case 2: goto more;\r
-       }\r
-       return tk;\r
-}\r
-\r
-void DLGLexer::\r
-advance()\r
-{\r
-       if ( input==NULL ) err_in();\r
-       ZZGETC; charfull = 1; ZZINC;\r
-}\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/h/DLexerBase.cpp b/Tools/CodeTools/TianoTools/Pccts/h/DLexerBase.cpp
deleted file mode 100644 (file)
index b218afc..0000000
+++ /dev/null
@@ -1,302 +0,0 @@
-/* DLGLexerBase.c\r
- *\r
- * SOFTWARE RIGHTS\r
- *\r
- * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
- * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
- * company may do whatever they wish with source code distributed with\r
- * PCCTS or the code generated by PCCTS, including the incorporation of\r
- * PCCTS, or its output, into commerical software.\r
- *\r
- * We encourage users to develop software with PCCTS.  However, we do ask\r
- * that credit is given to us for developing PCCTS.  By "credit",\r
- * we mean that if you incorporate our source code into one of your\r
- * programs (commercial product, research project, or otherwise) that you\r
- * acknowledge this fact somewhere in the documentation, research report,\r
- * etc...  If you like PCCTS and have developed a nice tool with the\r
- * output, please mention that you developed it using PCCTS.  In\r
- * addition, we ask that this header remain intact in our source code.\r
- * As long as these guidelines are kept, we expect to continue enhancing\r
- * this system and expect to make other tools available as they are\r
- * completed.\r
- *\r
- * ANTLR 1.33\r
- * Terence Parr\r
- * Parr Research Corporation\r
- * with Purdue University and AHPCRC, University of Minnesota\r
- * 1989-2000\r
- */\r
-\r
-#include "pcctscfg.h"\r
-\r
-#include "pccts_stdio.h"\r
-#include "pccts_stdlib.h"\r
-\r
-PCCTS_NAMESPACE_STD\r
-\r
-/* I have to put this here due to C++ limitation\r
- * that you can't have a 'forward' decl for enums.\r
- * I hate C++!!!!!!!!!!!!!!!\r
- */\r
-\r
-// MR1\r
-// MR1  10-Apr-97  133MR1  Prevent use of varying sizes for the\r
-// MR1                         ANTLRTokenType enum\r
-// MR1\r
-\r
-enum ANTLRTokenType { TER_HATES_CPP=0, ITS_UTTER_GARBAGE,              // MR1\r
-                                        WITH_SOME_GOOD_IDEAS=9999};    // MR1\r
-\r
-#define ANTLR_SUPPORT_CODE\r
-\r
-#include "pcctscfg.h"\r
-#include DLEXERBASE_H\r
-#include APARSER_H             // MR23\r
-\r
-DLGLexerBase::\r
-DLGLexerBase(DLGInputStream *in,\r
-            unsigned bufsize,\r
-            int _interactive,\r
-            int _track_columns)\r
-{\r
-       this->_bufsize = bufsize;\r
-       this->_lextext = new DLGChar[_bufsize];\r
-       if ( this->_lextext==NULL ) {\r
-           panic("text buffer is NULL");\r
-       }\r
-       this->_begexpr = this->_endexpr = NULL;\r
-       this->ch = this->bufovf = 0;\r
-       this->nextpos = NULL;\r
-       this->cl = 0;\r
-       this->add_erase = 0;\r
-       this->input = in;\r
-       this->_begcol = 0;\r
-       this->_endcol = 0;\r
-       this->_line = 1;\r
-       this->charfull = 0;\r
-       this->automaton = 0;\r
-       this->token_to_fill = NULL;\r
-       this->interactive = _interactive;\r
-       this->track_columns = _track_columns;\r
-       this->debugLexerFlag = 0;                                       // MR1\r
-       this->parser = NULL;                                            // MR1\r
-    this->lexErrCount=0;                        // MR11\r
-}\r
-\r
-// MR19  THM \r
-\r
-void DLGLexerBase::reset()\r
-{\r
-       this->charfull = 0;\r
-       this->_begcol = 0;\r
-       this->_endcol = 0;\r
-       this->automaton = 0;\r
-       this->_line=1;\r
-       this->lexErrCount=0;\r
-}\r
-\r
-void DLGLexerBase::\r
-setInputStream( DLGInputStream *in )\r
-{\r
-       this->input = in;\r
-       _line = 1;\r
-       charfull = 0;\r
-}\r
-\r
-/* saves dlg state, but not what feeds dlg (such as file position) */\r
-void DLGLexerBase::\r
-saveState(DLGState *state)\r
-{\r
-       state->input = input;\r
-       state->interactive = interactive;\r
-       state->track_columns = track_columns;\r
-       state->auto_num = automaton;\r
-       state->add_erase = add_erase;\r
-       state->lookc = ch;\r
-       state->char_full = charfull;\r
-       state->begcol = _begcol;\r
-       state->endcol = _endcol;\r
-       state->line = _line;\r
-       state->lextext = _lextext;\r
-       state->begexpr = _begexpr;\r
-       state->endexpr = _endexpr;\r
-       state->bufsize = _bufsize;\r
-       state->bufovf = bufovf;\r
-       state->nextpos = nextpos;\r
-       state->class_num = cl;\r
-       state->debugLexerFlag = debugLexerFlag;                         // MR1\r
-       state->parser = parser;                                         // MR1\r
-}\r
-\r
-void DLGLexerBase::\r
-restoreState(DLGState *state)\r
-{\r
-       input = state->input;\r
-       interactive = state->interactive;\r
-       track_columns = state->track_columns;\r
-       automaton = state->auto_num;\r
-       add_erase = state->add_erase;\r
-       ch = state->lookc;\r
-       charfull = state->char_full;\r
-       _begcol = state->begcol;\r
-       _endcol = state->endcol;\r
-       _line = state->line;\r
-       _lextext = state->lextext;\r
-       _begexpr = state->begexpr;\r
-       _endexpr = state->endexpr;\r
-       _bufsize = state->bufsize;\r
-       bufovf = state->bufovf;\r
-       nextpos = state->nextpos;\r
-       cl = state->class_num;\r
-       debugLexerFlag = state->debugLexerFlag;                         // MR1\r
-       parser = state->parser;                                         // MR1\r
-}\r
-\r
-/* erase what is currently in the buffer, and get a new reg. expr */\r
-void DLGLexerBase::\r
-skip()\r
-{\r
-       add_erase = 1;\r
-}\r
-\r
-/* don't erase what is in the lextext buffer, add on to it */\r
-void DLGLexerBase::\r
-more()\r
-{\r
-       add_erase = 2;\r
-}\r
-\r
-/* substitute c for the reg. expr last matched and is in the buffer */\r
-void DLGLexerBase::\r
-replchar(DLGChar c)\r
-{\r
-       /* can't allow overwriting null at end of string */\r
-       if (_begexpr < &_lextext[_bufsize-1]){\r
-               *_begexpr = c;\r
-               *(_begexpr+1) = '\0';\r
-       }\r
-       _endexpr = _begexpr;\r
-       if (c != '\0') {\r
-               nextpos = _begexpr + 1;\r
-       }\r
-       else {\r
-               nextpos = _begexpr;     /* MR30 Zero terminates string. */\r
-       }\r
-}\r
-\r
-/* replace the string s for the reg. expr last matched and in the buffer */\r
-\r
-#ifdef _MSC_VER  // MR23\r
-//Turn off "assignment within conditional expression" warning\r
-#pragma warning(disable : 4706)\r
-#endif\r
-void DLGLexerBase::\r
-replstr(const DLGChar *s) /* MR20 const */\r
-{\r
-       register DLGChar *l= &_lextext[_bufsize -1];\r
-\r
-       nextpos = _begexpr;\r
-       if (s){\r
-               while ((nextpos <= l) && (*(nextpos++) = *(s++))){\r
-                       /* empty */\r
-               }\r
-               /* correct for NULL at end of string */\r
-               nextpos--;\r
-       }\r
-       if ((nextpos <= l) && (*(--s) == 0)){\r
-               bufovf = 0;\r
-       }else{\r
-               bufovf = 1;\r
-       }\r
-       *(nextpos) = '\0';\r
-       _endexpr = nextpos - 1;\r
-}\r
-#ifdef _MSC_VER  // MR23\r
-#pragma warning(default: 4706)\r
-#endif\r
-\r
-void DLGLexerBase::\r
-errstd(const char *s)                               /* MR20 const */\r
-{\r
-        lexErrCount++;                              /* MR11 */\r
-        /* MR23 */ printMessage(stderr,\r
-                "%s near line %d (text was '%s')\n",\r
-                ((s == NULL) ? "Lexical error" : s),\r
-                _line,_lextext);\r
-}\r
-\r
-int DLGLexerBase::\r
-err_in()\r
-{\r
-       /* MR23 */ printMessage(stderr,"No input stream, function, or string\n");\r
-       /* return eof to get out gracefully */\r
-       return EOF;\r
-}\r
-\r
-ANTLRTokenType DLGLexerBase::\r
-erraction()\r
-{\r
-       errstd("invalid token");\r
-       advance();\r
-       skip();\r
-       return (ANTLRTokenType) 0;      // bogus, but satisfies compiler\r
-}\r
-\r
-_ANTLRTokenPtr DLGLexerBase::\r
-getToken()\r
-{\r
-       if ( token_to_fill==NULL ) panic("NULL token_to_fill");\r
-       ANTLRTokenType tt = nextTokenType();\r
-       _ANTLRTokenPtr tk = token_to_fill->makeToken(tt, _lextext,_line);\r
-       return tk;\r
-}\r
-\r
-void DLGLexerBase::\r
-panic(const char *msg)      /* MR20 const */\r
-{\r
-       if (parser)                             //MR23\r
-               parser->panic(msg);     //MR23\r
-       else                                    //MR23\r
-       {\r
-               /* MR23 */ printMessage(stderr, "DLG panic: %s\n", msg);\r
-       //\r
-       //  7-Apr-97 133MR1\r
-       //\r
-               exit(PCCTS_EXIT_FAILURE);                                       // MR1\r
-       }\r
-}\r
-\r
-ANTLRParser * DLGLexerBase::                                           // MR1\r
-setParser(ANTLRParser *p) {                                            // MR1\r
-  ANTLRParser  *oldValue=parser;                                       // MR1\r
-  parser=p;                                                            // MR1\r
-  return oldValue;                                                     // MR1\r
-}                                                                      // MR1\r
-                                                                       // MR1\r
-ANTLRParser * DLGLexerBase::                                           // MR1\r
-getParser() {                                                          // MR1\r
-  return parser;                                                       // MR1\r
-}                                                                      // MR1\r
-                                                                       // MR1\r
-int DLGLexerBase::                                                     // MR1\r
-debugLexer(int newValue) {                                             // MR1\r
-  int  oldValue=debugLexerFlag;                                        // MR1\r
-  debugLexerFlag=newValue;                                             // MR1\r
-  return oldValue;                                                     // MR1\r
-}                                                                      // MR1\r
-\r
-//MR23\r
-int DLGLexerBase::printMessage(FILE* pFile, const char* pFormat, ...)\r
-{\r
-       va_list marker;\r
-       va_start( marker, pFormat );\r
-\r
-       int iRet = 0;\r
-       if (parser)\r
-               parser->printMessageV(pFile, pFormat, marker);\r
-       else\r
-               iRet = vfprintf(pFile, pFormat, marker);\r
-\r
-       va_end( marker );\r
-       return iRet;\r
-}\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/h/DLexerBase.h b/Tools/CodeTools/TianoTools/Pccts/h/DLexerBase.h
deleted file mode 100644 (file)
index db6cc18..0000000
+++ /dev/null
@@ -1,198 +0,0 @@
-/* DLGLexerBase.h\r
- *\r
- * SOFTWARE RIGHTS\r
- *\r
- * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
- * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
- * company may do whatever they wish with source code distributed with\r
- * PCCTS or the code generated by PCCTS, including the incorporation of\r
- * PCCTS, or its output, into commerical software.\r
- *\r
- * We encourage users to develop software with PCCTS.  However, we do ask\r
- * that credit is given to us for developing PCCTS.  By "credit",\r
- * we mean that if you incorporate our source code into one of your\r
- * programs (commercial product, research project, or otherwise) that you\r
- * acknowledge this fact somewhere in the documentation, research report,\r
- * etc...  If you like PCCTS and have developed a nice tool with the\r
- * output, please mention that you developed it using PCCTS.  In\r
- * addition, we ask that this header remain intact in our source code.\r
- * As long as these guidelines are kept, we expect to continue enhancing\r
- * this system and expect to make other tools available as they are\r
- * completed.\r
- *\r
- * ANTLR 1.33\r
- * Terence Parr\r
- * Parr Research Corporation\r
- * with Purdue University and AHPCRC, University of Minnesota\r
- * 1989-2000\r
- */\r
-\r
-#ifndef DLGX_H\r
-#define DLGX_H\r
-\r
-#include "pcctscfg.h"\r
-#include "pccts_stdio.h"\r
-\r
-PCCTS_NAMESPACE_STD\r
-\r
-#include ATOKEN_H\r
-#include ATOKENSTREAM_H\r
-\r
-class ANTLRParser;                                                     // MR1\r
-\r
-/* must define what a char looks like; can make this a class too */\r
-typedef char DLGChar;\r
-\r
-/*  Can have it as a class too: (ack this looks weird; is it right?)\r
-class DllExportPCCTS DLGChar {\r
-private:\r
-       int c;\r
-public:\r
-       DLGChar(int ch) { c = ch; }\r
-       int atom() { return c; }\r
-};\r
-*/\r
-\r
-/* user must subclass this */\r
-class DllExportPCCTS DLGInputStream {\r
-public:\r
-       virtual int nextChar() = 0;\r
-};\r
-\r
-/* Predefined char stream: Input from FILE */\r
-class DllExportPCCTS DLGFileInput : public DLGInputStream {\r
-private:\r
-       int found_eof;\r
-       FILE *input;\r
-public:\r
-       DLGFileInput(FILE *f) { input = f; found_eof = 0; }\r
-       int nextChar() {\r
-                       int c;\r
-                       if ( found_eof ) return EOF;\r
-                       else {\r
-                               c=getc(input);\r
-                               if ( c==EOF ) found_eof = 1;\r
-                               return c;\r
-                       }\r
-       }\r
-    void DLGFileReset(FILE *f) {input=f; found_eof = 0; };              // MR11\r
-};\r
-\r
-// MR9  Suggested by Bruce Guenter (bruceg@qcc.sk.ca)\r
-// MR9  Make DLGStringInput const correct\r
-\r
-/* Predefined char stream: Input from string */\r
-class DllExportPCCTS DLGStringInput : public DLGInputStream {\r
-private:\r
-       const DLGChar *input;                                           // MR9\r
-       const DLGChar *p;                                               // MR9\r
-public:\r
-       DLGStringInput(const DLGChar *s) { input = s; p = &input[0];}   // MR9\r
-       int nextChar()\r
-               {\r
-                       if (*p) return (int) (unsigned char) *p++;              // MR14\r
-                       else return EOF;\r
-               }\r
-\r
-    void DLGStringReset(const DLGChar *s) {input=s; p= &input[0]; }; // MR11 // MR16\r
-};\r
-\r
-class DllExportPCCTS DLGState {\r
-public:\r
-       DLGInputStream *input;\r
-       int interactive;\r
-       int track_columns;\r
-       int auto_num;\r
-       int add_erase;\r
-       int lookc;\r
-       int char_full;\r
-       int begcol, endcol;\r
-       int line;\r
-       DLGChar *lextext, *begexpr, *endexpr;\r
-       int bufsize;\r
-       int bufovf;\r
-       DLGChar *nextpos;\r
-       int     class_num;\r
-       int     debugLexerFlag;                                         // MR1\r
-       ANTLRParser *parser;                                            // MR1\r
-};\r
-\r
-/* user must subclass this */\r
-class DllExportPCCTS DLGLexerBase : public ANTLRTokenStream {\r
-public:\r
-       virtual ANTLRTokenType erraction();\r
-\r
-protected:\r
-       DLGInputStream *input;\r
-       int interactive;\r
-       int track_columns;\r
-       DLGChar *_lextext;      /* text of most recently matched token */\r
-       DLGChar *_begexpr;      /* beginning of last reg expr recogn. */\r
-       DLGChar *_endexpr;      /* beginning of last reg expr recogn. */\r
-       int     _bufsize;               /* number of characters in lextext */\r
-       int     _begcol;                /* column that first character of token is in*/\r
-       int     _endcol;                /* column that last character of token is in */\r
-       int     _line;                  /* line current token is on */\r
-       int     ch;                             /* character to determine next state */\r
-       int     bufovf;                 /* indicates that buffer too small for text */\r
-       int     charfull;\r
-       DLGChar *nextpos;       /* points to next available position in lextext*/\r
-       int     cl;\r
-       int automaton;\r
-       int     add_erase;\r
-       DLGChar ebuf[70];\r
-       _ANTLRTokenPtr token_to_fill;\r
-\r
-       int     debugLexerFlag;                                         // MR1\r
-       ANTLRParser     *parser;                                        // MR1\r
-public:\r
-       virtual _ANTLRTokenPtr getToken();      // MR12 public\r
-       virtual void advance(void) = 0;\r
-       void    skip(void);             /* erase lextext, look for antoher token */\r
-       void    more(void);             /* keep lextext, look for another token */\r
-       void    mode(int k);    /* switch to automaton 'k' */\r
-       void    saveState(DLGState *);\r
-       void    restoreState(DLGState *);\r
-       virtual ANTLRTokenType nextTokenType(void)=0;/* get next token */\r
-       void    replchar(DLGChar c);    /* replace last recognized reg. expr. with\r
-                                                                        a character */\r
-       void    replstr(const DLGChar *s);      /* replace last recognized reg. expr. with\r
-                                                                        a string */ /* MR20 const */\r
-        virtual int err_in();                                          // MR1\r
-       virtual void errstd(const char *);                              // MR1  MR20 const\r
-       int             line()          { return _line; }\r
-       void    set_line(int newValue)  { _line=newValue; };            // MR1\r
-       virtual void newline()  { _line++; }\r
-       DLGChar *lextext()      { return _lextext; }\r
-\r
-       int             begcol()        { return _begcol; }\r
-       int             endcol()        { return _endcol; }\r
-       void    set_begcol(int a)       { _begcol=a; }\r
-       void    set_endcol(int a)       { _endcol=a; }\r
-       DLGChar *begexpr()      { return _begexpr; }\r
-       DLGChar *endexpr()      { return _endexpr; }\r
-       int             bufsize()       { return _bufsize; }\r
-\r
-       void    setToken(ANTLRAbstractToken *t) { token_to_fill = t; }\r
-\r
-       void    setInputStream(DLGInputStream *);\r
-       DLGLexerBase(DLGInputStream *in,\r
-                                unsigned bufsize=2000,\r
-                                int interactive=0,\r
-                                int track_columns=0);\r
-       void reset();                                                                   // MR19\r
-       virtual ~DLGLexerBase() { delete [] _lextext; }\r
-       virtual void panic(const char *msg);                    // MR1  MR20 const\r
-       void    trackColumns() {\r
-                               track_columns = 1;\r
-                               this->_begcol = 0;\r
-                               this->_endcol = 0;\r
-                       };\r
-       virtual ANTLRParser *setParser(ANTLRParser *p);                 // MR1\r
-       virtual ANTLRParser *getParser();                               // MR1\r
-       virtual int debugLexer(int value);                              // MR1\r
-    int     lexErrCount;                            // MR12\r
-       virtual int printMessage(FILE* pFile, const char* pFormat, ...); // MR23\r
-};\r
-\r
-#endif\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/h/PBlackBox.h b/Tools/CodeTools/TianoTools/Pccts/h/PBlackBox.h
deleted file mode 100644 (file)
index d25b8d6..0000000
+++ /dev/null
@@ -1,134 +0,0 @@
-#ifndef PBLACKBOX_H\r
-#define PBLACKBOX_H\r
-\r
-/*\r
- * SOFTWARE RIGHTS\r
- *\r
- * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
- * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
- * company may do whatever they wish with source code distributed with\r
- * PCCTS or the code generated by PCCTS, including the incorporation of\r
- * PCCTS, or its output, into commerical software.\r
- *\r
- * We encourage users to develop software with PCCTS.  However, we do ask\r
- * that credit is given to us for developing PCCTS.  By "credit",\r
- * we mean that if you incorporate our source code into one of your\r
- * programs (commercial product, research project, or otherwise) that you\r
- * acknowledge this fact somewhere in the documentation, research report,\r
- * etc...  If you like PCCTS and have developed a nice tool with the\r
- * output, please mention that you developed it using PCCTS.  In\r
- * addition, we ask that this header remain intact in our source code.\r
- * As long as these guidelines are kept, we expect to continue enhancing\r
- * this system and expect to make other tools available as they are\r
- * completed.\r
- *\r
- * ANTLR 1.33\r
- * Terence Parr\r
- * Parr Research Corporation\r
- * with Purdue University and AHPCRC, University of Minnesota\r
- * 1989-2000\r
- */\r
-\r
-/* Completely rewritten by Chris Uzdavinis (chris@atdesk.com) for MR23 */\r
-\r
-#include "pcctscfg.h"\r
-\r
-#include "pccts_iostream.h"\r
-\r
-PCCTS_NAMESPACE_STD\r
-\r
-//  MR20 Added #include for "DLexerBase.h"\r
-\r
-#include "DLexerBase.h"\r
-\r
-//\r
-//  The default buffer size of the lexer is given by the\r
-//   second argument of the lexer's ctor.  It is optional\r
-//   and defaults to 2000\r
-//\r
-\r
-template<class Lexer, class Parser, class Token>\r
-class DllExportPCCTS ParserBlackBox {\r
-private:\r
-  // no copy construction allowed\r
-  ParserBlackBox(ParserBlackBox const &);\r
-\r
-  // no copy assignment allowed\r
-  ParserBlackBox & operator=(ParserBlackBox const &);\r
-  \r
-protected:\r
-  DLGFileInput *in;\r
-  Lexer *scan;\r
-  _ANTLRTokenPtr tok;\r
-  ANTLRTokenBuffer *pipe;\r
-  Parser *_parser;\r
-  FILE *file;\r
-  int openByBlackBox;    /* MR21 Don't close what we haven't opened */\r
-public:\r
-       \r
-  ParserBlackBox(FILE *f)\r
-    : in(0)\r
-    , scan(0)\r
-    , tok(0)\r
-    , pipe(0)\r
-    , _parser(0)\r
-    , file(0)\r
-    , openByBlackBox(0)\r
-  {\r
-    if (f == NULL)\r
-    {\r
-      cerr << "invalid file pointer\n"; \r
-    }\r
-    else\r
-    {\r
-      openByBlackBox = 0;     /* MR21a */\r
-      file = f;\r
-      in = new DLGFileInput(f);\r
-      scan = new Lexer(in);\r
-      pipe = new ANTLRTokenBuffer(scan);\r
-      tok = new Token;\r
-      scan->setToken(tok);\r
-      _parser = new Parser(pipe);\r
-      _parser->init();\r
-    }\r
-  }\r
-  ParserBlackBox(char *fname)\r
-    : in(0)\r
-    , scan(0)\r
-    , tok(0)\r
-    , pipe(0)\r
-    , _parser(0)\r
-    , file(0)\r
-    , openByBlackBox(0)\r
-  {\r
-    FILE *f = fopen(fname, "r");\r
-    if ( f==NULL ) {\r
-      openByBlackBox = 0;\r
-      cerr << "cannot open " << fname << "\n"; return;\r
-    }\r
-    else {\r
-      openByBlackBox = 1;\r
-      file = f;\r
-      in = new DLGFileInput(f);\r
-      scan = new Lexer(in);\r
-      pipe = new ANTLRTokenBuffer(scan);\r
-      tok = new Token;\r
-      scan->setToken(tok);\r
-      _parser = new Parser(pipe);\r
-      _parser->init();\r
-    }\r
-  }\r
-       \r
-  ~ParserBlackBox()\r
-  {\r
-    delete in; delete scan; delete pipe; delete _parser; delete tok;\r
-    if (1 == openByBlackBox) {\r
-      fclose(file);\r
-    }\r
-  }\r
-\r
-  Parser *parser()        { return _parser; }\r
-  Lexer  *getLexer()     { return scan; }\r
-};\r
-\r
-#endif\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/h/PCCTSAST.cpp b/Tools/CodeTools/TianoTools/Pccts/h/PCCTSAST.cpp
deleted file mode 100644 (file)
index a8249cd..0000000
+++ /dev/null
@@ -1,684 +0,0 @@
-/*\r
- * PCCTSAST.C\r
- *\r
- * SOFTWARE RIGHTS\r
- *\r
- * We reserve no LEGAL rights to SORCERER -- SORCERER is in the public\r
- * domain.  An individual or company may do whatever they wish with\r
- * source code distributed with SORCERER or the code generated by\r
- * SORCERER, including the incorporation of SORCERER, or its output, into\r
- * commerical software.\r
- *\r
- * We encourage users to develop software with SORCERER.  However, we do\r
- * ask that credit is given to us for developing SORCERER.  By "credit",\r
- * we mean that if you incorporate our source code into one of your\r
- * programs (commercial product, research project, or otherwise) that you\r
- * acknowledge this fact somewhere in the documentation, research report,\r
- * etc...  If you like SORCERER and have developed a nice tool with the\r
- * output, please mention that you developed it using SORCERER.  In\r
- * addition, we ask that this header remain intact in our source code.\r
- * As long as these guidelines are kept, we expect to continue enhancing\r
- * this system and expect to make other tools available as they are\r
- * completed.\r
- *\r
- * SORCERER 1.00B14 and ANTLR 1.33\r
- * Terence Parr\r
- * Parr Research Corporation\r
- * AHPCRC, University of Minnesota\r
- * 1992-2000\r
- */\r
-\r
-#define ANTLR_SUPPORT_CODE\r
-\r
-#include "pcctscfg.h"\r
-\r
-#include "PCCTSAST.h"\r
-#include "pccts_stdarg.h"\r
-\r
-PCCTS_NAMESPACE_STD\r
-\r
-#include <ctype.h>\r
-\r
-//#include "SList.h"\r
-\r
-               /* String Scanning/Parsing Stuff */\r
-\r
-const char *PCCTS_AST::scan_token_tbl[] = {     /* MR20 const */\r
-       "invalid",      /*      0 */\r
-       "LPAREN",       /*      1 */\r
-       "RPAREN",       /*      2 */\r
-       "PERCENT",      /*      3 */\r
-       "INT",          /*      4 */\r
-       "COLON",        /*      5 */\r
-       "POUND",        /*      6 */\r
-       "PERIOD",       /*      7 */\r
-};\r
-\r
-void PCCTS_AST::\r
-addChild(PCCTS_AST *t)\r
-{\r
-       if ( t==NULL ) return;\r
-       PCCTS_AST *s = down();\r
-       if ( s!=NULL )\r
-       {\r
-               while ( s->right()!=NULL ) s = s->right();\r
-               s->setRight(t);\r
-       }\r
-       else\r
-               this->setDown(t);\r
-}\r
-\r
-void PCCTS_AST::\r
-lisp(FILE *f)\r
-{\r
-       if ( down() != NULL ) /* MR23 */ printMessage(f," (");\r
-       lisp_action(f);\r
-       if ( down()!=NULL ) down()->lisp(f);\r
-       if ( down() != NULL ) /* MR23 */ printMessage(f," )");\r
-       if ( right()!=NULL ) right()->lisp(f);\r
-}\r
-\r
-/* build a tree (root child1 child2 ... NULL)\r
- * If root is NULL, simply make the children siblings and return ptr\r
- * to 1st sibling (child1).  If root is not single node, return NULL.\r
- *\r
- * Siblings that are actually sibling lists themselves are handled\r
- * correctly.  For example #( NULL, #( NULL, A, B, C), D) results\r
- * in the tree ( NULL A B C D ).\r
- *\r
- * Requires at least two parameters with the last one being NULL.  If\r
- * both are NULL, return NULL.\r
- *\r
- * The down() and right() down/right pointers are used to make the tree.\r
- */\r
-PCCTS_AST *PCCTS_AST::\r
-make(PCCTS_AST *rt, ...)\r
-{\r
-       va_list ap;\r
-       register PCCTS_AST *child, *sibling=NULL, *tail=NULL /*MR23*/, *w;\r
-       PCCTS_AST *root;\r
-\r
-       va_start(ap, rt);\r
-       root = rt;\r
-\r
-       if ( root != NULL )\r
-               if ( root->down() != NULL ) return NULL;\r
-       child = va_arg(ap, PCCTS_AST *);\r
-       while ( child != NULL )\r
-       {\r
-               /* find end of child */\r
-               for (w=child; w->right()!=NULL; w=w->right()) {;}\r
-               if ( sibling == NULL ) {sibling = child; tail = w;}\r
-               else {tail->setRight(child); tail = w;}\r
-               child = va_arg(ap, PCCTS_AST *);\r
-       }\r
-       if ( root==NULL ) root = sibling;\r
-       else root->setDown(sibling);\r
-       va_end(ap);\r
-       return root;\r
-}\r
-\r
-/* The following push and pop routines are only used by ast_find_all() */\r
-\r
-void PCCTS_AST::\r
-_push(PCCTS_AST **st, int *sp, PCCTS_AST *e)\r
-{\r
-       (*sp)--;\r
-       require((*sp)>=0, "stack overflow");\r
-       st[(*sp)] = e;\r
-}\r
-\r
-PCCTS_AST *PCCTS_AST::\r
-_pop(PCCTS_AST **st, int *sp)\r
-{\r
-       PCCTS_AST *e = st[*sp];\r
-       (*sp)++;\r
-       require((*sp)<=MaxTreeStackDepth, "stack underflow");\r
-       return e;\r
-}\r
-\r
-/* Find all occurrences of u in t.\r
- * 'cursor' must be initialized to 't'.  It eventually\r
- * returns NULL when no more occurrences of 'u' are found.\r
- */\r
-PCCTS_AST *PCCTS_AST::\r
-ast_find_all(PCCTS_AST *u, PCCTS_AST **cursor)\r
-{\r
-       PCCTS_AST *sib;\r
-       /*** static ***/ PCCTS_AST *template_stack[MaxTreeStackDepth];  /* MR23 Remove "static" */\r
-       /*** static ***/ int tsp = MaxTreeStackDepth;                   /* MR23 Remove "static" */\r
-\r
-////static int nesting = 0;                                         /* MR23 Not referenced */\r
-\r
-       if ( *cursor == NULL ) return NULL;\r
-       if ( *cursor!=this ) sib = *cursor;\r
-       else {\r
-               /* else, first time--start at top of template 't' */\r
-               tsp = MaxTreeStackDepth;\r
-               sib = this;\r
-               /* bottom of stack is always a NULL--"cookie" indicates "done" */\r
-               _push(template_stack, &tsp, NULL);\r
-       }\r
-\r
-keep_looking:\r
-       if ( sib==NULL )        /* hit end of sibling list */\r
-       {\r
-               sib = _pop(template_stack, &tsp);\r
-               if ( sib == NULL ) { *cursor = NULL; return NULL; }\r
-       }\r
-\r
-       if ( sib->type() != u->type() )\r
-       {\r
-               /* look for another match */\r
-               if ( sib->down()!=NULL )\r
-               {\r
-                       if ( sib->right()!=NULL ) _push(template_stack, &tsp, sib->right());\r
-                       sib=sib->down();\r
-                       goto keep_looking;\r
-               }\r
-               /* nothing below to try, try next sibling */\r
-               sib=sib->right();\r
-               goto keep_looking;\r
-       }\r
-\r
-       /* found a matching root node, try to match what's below */\r
-       if ( match_partial(sib, u) )\r
-       {\r
-               /* record sibling cursor so we can pick up next from there */\r
-               if ( sib->down()!=NULL )\r
-               {\r
-                       if ( sib->right()!=NULL ) _push(template_stack, &tsp, sib->right());\r
-                       *cursor = sib->down();\r
-               }\r
-               else if ( sib->right()!=NULL ) *cursor = sib->right();\r
-               else *cursor = _pop(template_stack, &tsp);\r
-               return sib;\r
-       }\r
-\r
-       /* no match, keep searching */\r
-       if ( sib->down()!=NULL )\r
-       {\r
-               if ( sib->right()!=NULL ) _push(template_stack, &tsp, sib->right());\r
-               sib=sib->down();\r
-       }\r
-       else sib = sib->right();        /* else, try to right if zip below */\r
-       goto keep_looking;\r
-}\r
-\r
-/* are two trees exactly alike? */\r
-int PCCTS_AST::\r
-match(PCCTS_AST *u)\r
-{\r
-       PCCTS_AST *t = this;\r
-       PCCTS_AST *sib;\r
-\r
-       if ( u==NULL ) return 0;\r
-\r
-       for (sib=t; sib!=NULL&&u!=NULL; sib=sib->right(), u=u->right())\r
-       {\r
-               if ( sib->type() != u->type() ) return 0;\r
-               if ( sib->down()!=NULL )\r
-                       if ( !sib->down()->match(u->down()) ) return 0;\r
-       }\r
-       return 1;\r
-}\r
-\r
-/* Is 'u' a subtree of 't' beginning at the root? */\r
-int PCCTS_AST::\r
-match_partial(PCCTS_AST *t, PCCTS_AST *u)\r
-{\r
-       PCCTS_AST *sib;\r
-\r
-       if ( u==NULL ) return 1;\r
-       if ( t==NULL ) return 0; /* MR23 removed unreachable code */\r
-\r
-       for (sib=t; sib!=NULL&&u!=NULL; sib=sib->right(), u=u->right())\r
-       {\r
-               if ( sib->type() != u->type() ) return 0;\r
-               if ( sib->down()!=NULL )\r
-                       if ( !match_partial(sib->down(), u->down()) ) return 0;\r
-       }\r
-       return 1;\r
-}\r
-\r
-#ifdef _MSC_VER  // MR23\r
-//Turn off "unreachable code" warning\r
-#pragma warning(disable : 4702)\r
-#endif\r
-/* Walk the template tree 't' (matching against 'this'), filling in the\r
- * 'labels' array, and setting 'n' according to how many labels were matched.\r
- */\r
-int PCCTS_AST::\r
-scanmatch(ScanAST *t, PCCTS_AST **labels[], int *n)\r
-{\r
-       ScanAST *sib;\r
-       PCCTS_AST *u = this;\r
-\r
-       if ( u==NULL ) return 0;\r
-\r
-       for (sib=t; sib!=NULL&&u!=NULL; sib=sib->right(), u=u->right())\r
-       {\r
-               /* make sure tokens match; token of '0' means wildcard match */\r
-               if ( sib->type() != u->type() && sib->type()!=0 ) return 0;\r
-               /* we have a matched token here; set label pointers if exists */\r
-               if ( sib->label_num>0 )\r
-               {\r
-                       require(labels!=NULL, "label found in template, but no array of labels");\r
-                       (*n)++;\r
-                       *(labels[sib->label_num-1]) = u;\r
-               }\r
-               /* match what's below if something there and current node is not wildcard */\r
-               if ( sib->down()!=NULL && sib->type()!=0 )\r
-               {\r
-                       if ( sib->down()==NULL ) \r
-                       {\r
-                               if ( u->down()!=NULL ) \r
-                                       return 0; \r
-                               else \r
-                                       return 1;\r
-                       }\r
-                       if ( !u->down()->scanmatch(sib->down(), labels, n) ) return 0;\r
-               }\r
-       }\r
-       return 1;\r
-}\r
-#ifdef _MSC_VER  // MR23\r
-#pragma warning(default : 4702)\r
-#endif\r
-\r
-void PCCTS_AST::\r
-insert_after(PCCTS_AST *b)\r
-{\r
-       PCCTS_AST *end;\r
-       if ( b==NULL ) return;\r
-       /* find end of b's child list */\r
-       for (end=b; end->right()!=NULL; end=end->right()) {;}\r
-       end->setRight(this->right());\r
-       this->setRight(b);\r
-}\r
-\r
-void PCCTS_AST::\r
-append(PCCTS_AST *b)\r
-{\r
-       PCCTS_AST *end;\r
-       require(b!=NULL, "append: NULL input tree");\r
-       /* find end of child list */\r
-       for (end=this; end->right()!=NULL; end=end->right()) {;}\r
-       end->setRight(b);\r
-}\r
-\r
-PCCTS_AST *PCCTS_AST::\r
-tail()\r
-{\r
-       PCCTS_AST *end;\r
-       /* find end of child list */\r
-       for (end=this; end->right()!=NULL; end=end->right()) {;}\r
-       return end;\r
-}\r
-\r
-PCCTS_AST *PCCTS_AST::\r
-bottom()\r
-{\r
-       PCCTS_AST *end;\r
-       /* find end of child list */\r
-       for (end=this; end->down()!=NULL; end=end->down()) {;}\r
-       return end;\r
-}\r
-\r
-PCCTS_AST *PCCTS_AST::\r
-cut_between(PCCTS_AST *a, PCCTS_AST *b)\r
-{\r
-       PCCTS_AST *end, *ret;\r
-       if (a==NULL||b==NULL) return NULL;\r
-       /* find node pointing to b */\r
-       for (end=a; end->right()!=NULL&&end->right()!=b; end=end->right())\r
-               {;}\r
-       if (end->right()==NULL) return NULL; //ast_cut_between: a,b not connected\r
-       end->setRight(NULL);    /* don't want it point to 'b' anymore */\r
-       ret = a->right();\r
-       a->setRight(b);\r
-       return ret;\r
-}\r
-\r
-#ifdef NOT_YET\r
-SList *PCCTS_AST::\r
-to_slist()\r
-{\r
-       SList *list = new SList;\r
-       PCCTS_AST *p;\r
-\r
-       for (p=this; p!=NULL; p=p->right())\r
-       {\r
-               list->add(p);\r
-       }\r
-       return list;\r
-}\r
-#endif\r
-\r
-void PCCTS_AST::\r
-tfree()\r
-{\r
-       PCCTS_AST *t = this;\r
-    if ( t->down()!=NULL ) t->down()->tfree();\r
-    if ( t->right()!=NULL ) t->right()->tfree();\r
-    delete t;\r
-}\r
-\r
-int PCCTS_AST::\r
-nsiblings()\r
-{\r
-       PCCTS_AST *t = this;\r
-       int n=0;\r
-\r
-       while ( t!=NULL )\r
-       {\r
-               n++;\r
-               t = t->right();\r
-       }\r
-       return n;\r
-}\r
-\r
-PCCTS_AST *PCCTS_AST::\r
-sibling_index(int i)\r
-{\r
-       PCCTS_AST *t = this;\r
-       int j=1;\r
-       require(i>0, "sibling_index: i<=0");\r
-\r
-       while ( t!=NULL )\r
-       {\r
-               if ( j==i ) return t;\r
-               j++;\r
-               t = t->right();\r
-       }\r
-       return NULL;\r
-}\r
-\r
-/* Assume this is a root node of a tree--\r
- * duplicate that node and what's below; ignore siblings of root node.\r
- */\r
-\r
-// MR9 23-Sep-97 RJV\r
-// MR9\r
-// MR9 RJV: Original version only duplicated the node and down elements.\r
-// MR9      Made copies of the pointers to sibling.\r
-// MR9      Changed call "down()->deepCopy()" to "down()->deepCopyBushy()"\r
-// MR9\r
-\r
-PCCTS_AST *PCCTS_AST::\r
-deepCopy()\r
-{\r
-       PCCTS_AST *u = this->shallowCopy();\r
-       if ( down()!=NULL ) u->setDown(down()->deepCopyBushy());\r
-    u->setRight(NULL);\r
-       return u;\r
-}\r
-\r
-/* Copy all nodes including siblings of root. */\r
-PCCTS_AST *PCCTS_AST::\r
-deepCopyBushy()\r
-{\r
-       PCCTS_AST *u = this->shallowCopy();\r
-       /* copy the rest of the tree */\r
-       if ( down()!=NULL ) u->setDown(down()->deepCopyBushy());\r
-       if ( right()!=NULL ) u->setRight(right()->deepCopyBushy());\r
-       return u;\r
-}\r
-\r
-void PCCTS_AST::\r
-scanast_free(ScanAST *t)\r
-{\r
-    if ( t == NULL ) return;\r
-    scanast_free( t->down() );\r
-    scanast_free( t->right() );\r
-    free( (char *) t );                                                        // MR1\r
-}\r
-\r
-/*\r
- * scan\r
- *\r
- * This function is like scanf(): it attempts to match a template\r
- * against an input tree.  A variable number of tree pointers\r
- * may be set according to the '%i' labels in the template string.\r
- * For example:\r
- *\r
- *   t->ast_scan("#( 6 #(5 %1:4 %2:3) #(1 %3:3 %4:3) )",\r
- *            &w, &x, &y, &z);\r
- *\r
- * Naturally, you'd want this converted from\r
- *\r
- *      t->ast_scan("#( RangeOp #(Minus %1:IConst %2:Var) #(Plus %3:Var %4Var) )",\r
- *                       &w, &x, &y, &z);\r
- *\r
- * by SORCERER.\r
- *\r
- * This function call must be done withing a SORCERER file because SORCERER\r
- * must convert the token references to the associated token number.\r
- *\r
- * This functions parses the template and creates trees which are then\r
- * matched against the input tree.  The labels are set as they are\r
- * encountered; hence, partial matches may leave some pointers set\r
- * and some NULL.  This routines initializes all argument pointers to NULL\r
- * at the beginning.\r
- *\r
- * This function returns the number of labels matched.\r
- */\r
-int PCCTS_AST::\r
-ast_scan(char *templ, ...)\r
-{\r
-       va_list ap;\r
-       ScanAST *tmpl;\r
-       int n, i, found=0;\r
-       PCCTS_AST ***label_ptrs=NULL;\r
-\r
-       va_start(ap, templ);\r
-\r
-       /* make a ScanAST tree out of the template */\r
-       tmpl = stringparser_parse_scanast(templ, &n);\r
-\r
-       /* make an array out of the labels */\r
-       if ( n>0 )\r
-       {\r
-               label_ptrs = (PCCTS_AST ***) calloc(n, sizeof(PCCTS_AST **));\r
-               require(label_ptrs!=NULL, "scan: out of memory");\r
-               for (i=1; i<=n; i++)\r
-               {\r
-                       label_ptrs[i-1] = va_arg(ap, PCCTS_AST **);\r
-                       *(label_ptrs[i-1]) = NULL;\r
-               }\r
-       }\r
-\r
-       /* match the input tree against the template */\r
-       scanmatch(tmpl, label_ptrs, &found);\r
-\r
-       scanast_free(tmpl);\r
-       free( (char *) label_ptrs);                                     // MR1\r
-\r
-       return found;\r
-}\r
-\r
-ScanAST *PCCTS_AST::\r
-new_scanast(int tok)\r
-{\r
-    ScanAST *p = (ScanAST *) calloc(1, sizeof(ScanAST));\r
-//\r
-//  7-Apr-97 133MR1\r
-//\r
-    if ( p == NULL )\r
-        panic("out of memory\n");                      // MR23\r
-       p->_token = tok;\r
-       return p;\r
-}\r
-\r
-ScanAST *PCCTS_AST::\r
-stringparser_parse_scanast(char *templ, int *num_labels)\r
-{\r
-       StringLexer lex;\r
-       StringParser parser;\r
-       ScanAST *t;\r
-\r
-       stringlexer_init(&lex, templ);\r
-       stringparser_init(&parser, &lex);\r
-       t = stringparser_parse_tree(&parser);\r
-       *num_labels = parser.num_labels;\r
-       return t;\r
-}\r
-\r
-void PCCTS_AST::\r
-stringparser_match(StringParser *parser, int token)\r
-{\r
-       if ( parser->token != token ) panic("bad tree in scan()");\r
-}\r
-\r
-/*\r
- * Match a tree of the form:\r
- *             (root child1 child2 ... childn)\r
- * or,\r
- *             node\r
- *\r
- * where the elements are integers or labeled integers.\r
- */\r
-ScanAST *PCCTS_AST::\r
-stringparser_parse_tree(StringParser *parser)\r
-{\r
-       ScanAST *t=NULL, *root, *child, *last=NULL /*MR23*/;\r
-\r
-       if ( parser->token != __POUND )\r
-       {\r
-               return stringparser_parse_element(parser);\r
-       }\r
-       stringparser_match(parser,__POUND);\r
-       parser->token = stringscan_gettok(parser->lexer);\r
-       stringparser_match(parser,__LPAREN);\r
-       parser->token = stringscan_gettok(parser->lexer);\r
-       root = stringparser_parse_element(parser);\r
-       while ( parser->token != __RPAREN )\r
-       {\r
-               child = stringparser_parse_element(parser);\r
-               if ( t==NULL ) { t = child; last = t; }\r
-               else { last->_right = child; last = child; }\r
-       }\r
-       stringparser_match(parser,__RPAREN);\r
-       parser->token = stringscan_gettok(parser->lexer);\r
-       root->_down = t;\r
-       return root;\r
-}\r
-\r
-ScanAST *PCCTS_AST::\r
-stringparser_parse_element(StringParser *parser)\r
-{\r
-       char ebuf[100];\r
-       int label = 0;\r
-\r
-       if ( parser->token == __POUND )\r
-       {\r
-               return stringparser_parse_tree(parser);\r
-       }\r
-       if ( parser->token == __PERCENT )\r
-       {\r
-               parser->token = stringscan_gettok(parser->lexer);\r
-               stringparser_match(parser,__INT);\r
-               label = atoi(parser->lexer->text);\r
-               parser->num_labels++;\r
-               if ( label==0 ) panic("%%0 is an invalid label");\r
-               parser->token = stringscan_gettok(parser->lexer);\r
-               stringparser_match(parser,__COLON);\r
-               parser->token = stringscan_gettok(parser->lexer);\r
-               /* can label tokens and wildcards */\r
-               if ( parser->token != __INT && parser->token != __PERIOD )\r
-                       panic("can only label tokens");\r
-       }\r
-       if ( parser->token == __INT )\r
-       {\r
-               ScanAST *p = new_scanast(atoi(parser->lexer->text));\r
-               parser->token = stringscan_gettok(parser->lexer);\r
-               p->label_num = label;\r
-               return p;\r
-       }\r
-       if ( parser->token == __PERIOD )\r
-       {\r
-               ScanAST *p = new_scanast(0);    /* token of 0 is wildcard */\r
-               parser->token = stringscan_gettok(parser->lexer);\r
-               p->label_num = label;\r
-               return p;\r
-       }\r
-       sprintf(ebuf, "mismatch token in scan(): %s", scan_token_str(parser->token));\r
-       panic(ebuf);\r
-       return NULL;\r
-}\r
-\r
-void PCCTS_AST::\r
-stringparser_init(StringParser *parser, StringLexer *input)\r
-{\r
-       parser->lexer = input;\r
-       parser->token = stringscan_gettok(parser->lexer);\r
-       parser->num_labels = 0;\r
-}\r
-\r
-void PCCTS_AST::\r
-stringlexer_init(StringLexer *scanner, char *input)\r
-{\r
-       scanner->text[0]='\0';\r
-       scanner->input = input;\r
-       scanner->p = input;\r
-       stringscan_advance(scanner);\r
-}\r
-\r
-void PCCTS_AST::\r
-stringscan_advance(StringLexer *scanner)\r
-{\r
-       if ( *(scanner->p) == '\0' ) scanner->c = __StringScanEOF;\r
-       scanner->c = *(scanner->p)++;\r
-}\r
-\r
-int PCCTS_AST::\r
-stringscan_gettok(StringLexer *scanner)\r
-{\r
-       char *index = &scanner->text[0];\r
-       char ebuf[100]; /* MR23 Remove static */\r
-\r
-       while ( isspace(scanner->c) ) { stringscan_advance(scanner); }\r
-       if ( isdigit(scanner->c) )\r
-       {\r
-               int tok = __INT;\r
-               while ( isdigit(scanner->c) ) {\r
-                       *index++ = (char) /* static_cast<char> */ (scanner->c);     // MR23\r
-                       stringscan_advance(scanner);\r
-               }\r
-               *index = '\0';\r
-               return tok;\r
-       }\r
-       switch ( scanner->c )\r
-       {\r
-               case '#' : stringscan_advance(scanner); return __POUND;\r
-               case '(' : stringscan_advance(scanner); return __LPAREN;\r
-               case ')' : stringscan_advance(scanner); return __RPAREN;\r
-               case '%' : stringscan_advance(scanner); return __PERCENT;\r
-               case ':' : stringscan_advance(scanner); return __COLON;\r
-               case '.' : stringscan_advance(scanner); return __PERIOD;\r
-               case '\0' : return __StringScanEOF;\r
-               case __StringScanEOF : return __StringScanEOF;\r
-               default  :\r
-                       sprintf(ebuf, "invalid char in scan: '%c'", scanner->c);\r
-                       panic(ebuf);\r
-       }\r
-       return __StringScanEOF; // never reached\r
-}\r
-\r
-const char *PCCTS_AST:: /* MR20 const */\r
-scan_token_str(int t)\r
-{\r
-       if ( VALID_SCAN_TOKEN(t) ) return scan_token_tbl[t];\r
-       else if ( t==__StringScanEOF ) return "<end-of-string>";\r
-       else return "<invalid-token>";\r
-}\r
-\r
-//MR23\r
-int PCCTS_AST::printMessage(FILE* pFile, const char* pFormat, ...)\r
-{\r
-       va_list marker;\r
-       va_start( marker, pFormat );\r
-       int iRet = vfprintf(pFile, pFormat, marker);\r
-       va_end( marker );\r
-       return iRet;\r
-}\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/h/PCCTSAST.h b/Tools/CodeTools/TianoTools/Pccts/h/PCCTSAST.h
deleted file mode 100644 (file)
index 3485da7..0000000
+++ /dev/null
@@ -1,143 +0,0 @@
-/* Abstract syntax tree\r
- *\r
- * SOFTWARE RIGHTS\r
- *\r
- * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
- * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
- * company may do whatever they wish with source code distributed with\r
- * PCCTS or the code generated by PCCTS, including the incorporation of\r
- * PCCTS, or its output, into commerical software.\r
- *\r
- * We encourage users to develop software with PCCTS.  However, we do ask\r
- * that credit is given to us for developing PCCTS.  By "credit",\r
- * we mean that if you incorporate our source code into one of your\r
- * programs (commercial product, research project, or otherwise) that you\r
- * acknowledge this fact somewhere in the documentation, research report,\r
- * etc...  If you like PCCTS and have developed a nice tool with the\r
- * output, please mention that you developed it using PCCTS.  In\r
- * addition, we ask that this header remain intact in our source code.\r
- * As long as these guidelines are kept, we expect to continue enhancing\r
- * this system and expect to make other tools available as they are\r
- * completed.\r
- *\r
- * ANTLR 1.33\r
- * Terence Parr\r
- * Parr Research Corporation\r
- * with Purdue University and AHPCRC, University of Minnesota\r
- * 1989-2000\r
- */\r
-\r
-#ifndef PCCTSAST_H\r
-#define PCCTSAST_H\r
-\r
-#include "pcctscfg.h"\r
-\r
-#include "pccts_stdio.h"\r
-#include "pccts_stdlib.h"\r
-\r
-PCCTS_NAMESPACE_STD\r
-\r
-//class SList;\r
-\r
-#define StringScanMaxText      50\r
-#define MaxTreeStackDepth      400\r
-\r
-//\r
-//  7-Apr-97 133MR1    signed int not accepted by AT&T cfront\r
-//\r
-typedef struct stringlexer {\r
-                       int c;                                          // MR1\r
-                       char *input;\r
-                       char *p;\r
-                       char text[StringScanMaxText];\r
-               } StringLexer;\r
-\r
-/* Define the structures needed for ast_scan() */\r
-typedef struct stringparser {\r
-                       int token;\r
-                       StringLexer *lexer;\r
-                       int num_labels;\r
-               } StringParser;\r
-\r
-typedef struct _scanast {\r
-            struct _scanast *_right, *_down;\r
-            int _token;\r
-                       int label_num;\r
-                       int type() { return _token; }\r
-                       struct _scanast *right() { return _right; }\r
-                       struct _scanast *down() { return _down; }\r
-        } ScanAST;\r
-\r
-#define VALID_SCAN_TOKEN(t)            (t>=__LPAREN && t<=__PERIOD)\r
-\r
-class DllExportPCCTS PCCTS_AST {\r
-protected:\r
-       static const char *scan_token_tbl[];    /* MR20 const */\r
-       enum {\r
-       __LPAREN=1,\r
-       __RPAREN=2,\r
-       __PERCENT=3,\r
-       __INT=4,\r
-       __COLON=5,\r
-       __POUND=6,\r
-       __PERIOD=7,\r
-       __StringScanEOF=-1};\r
-\r
-protected:\r
-       const char *scan_token_str(int t);  /* MR20 const */\r
-       void stringlexer_init(StringLexer *scanner, char *input);\r
-       void stringparser_init(StringParser *, StringLexer *);\r
-       ScanAST *stringparser_parse_scanast(char *templ, int *n);\r
-       ScanAST *stringparser_parse_tree(StringParser *parser);\r
-       ScanAST *stringparser_parse_element(StringParser *parser);\r
-       void stringscan_advance(StringLexer *scanner);\r
-       int stringscan_gettok(StringLexer *scanner);\r
-       void _push(PCCTS_AST **st, int *sp, PCCTS_AST *e);\r
-       PCCTS_AST *_pop(PCCTS_AST **st, int *sp);\r
-       int match_partial(PCCTS_AST *t, PCCTS_AST *u);\r
-       int scanmatch(ScanAST *t, PCCTS_AST **labels[], int *n);\r
-       void scanast_free(ScanAST *t);\r
-       ScanAST *new_scanast(int tok);\r
-       void stringparser_match(StringParser *parser, int type);\r
-       virtual PCCTS_AST *deepCopyBushy();\r
-\r
-public:\r
-       PCCTS_AST()     {;}\r
-       virtual ~PCCTS_AST() {;}\r
-\r
-       /* This group must be defined for SORCERER to work correctly */\r
-       virtual PCCTS_AST *right() = 0;\r
-       virtual PCCTS_AST *down() = 0;\r
-       virtual void setRight(PCCTS_AST *t) = 0;\r
-       virtual void setDown(PCCTS_AST *t) = 0;\r
-// we define these so ANTLR doesn't have to\r
-       virtual int type() { return 0; }\r
-       virtual void setType(int /*t MR23 */) {;}\r
-       virtual PCCTS_AST *shallowCopy() {panic("no shallowCopy() defined"); return NULL;}\r
-\r
-       /* These are not needed by ANTLR, but are support functions */\r
-       virtual PCCTS_AST *deepCopy();  // used by SORCERER in transform mode\r
-       virtual void addChild(PCCTS_AST *t);\r
-       virtual void lisp_action(FILE * /*f MR23 */) {;}\r
-       virtual void lisp(FILE *f);\r
-       static PCCTS_AST *make(PCCTS_AST *rt, ...);\r
-       virtual PCCTS_AST *ast_find_all(PCCTS_AST *u, PCCTS_AST **cursor);\r
-       virtual int match(PCCTS_AST *u);\r
-       virtual void insert_after(PCCTS_AST *b);\r
-       virtual void append(PCCTS_AST *b);\r
-       virtual PCCTS_AST *tail();\r
-       virtual PCCTS_AST *bottom();\r
-       static  PCCTS_AST *cut_between(PCCTS_AST *a, PCCTS_AST *b);\r
-//     virtual SList *to_slist();\r
-       virtual void tfree();\r
-       int ast_scan(char *templ, ...);\r
-       virtual int nsiblings();\r
-       virtual PCCTS_AST *sibling_index(int i);\r
-\r
-       void require(int e,const char *err){ if ( !e ) panic(err); } /* MR20 const */\r
-       virtual void panic(const char *err)     // MR20 const\r
-               { /* MR23 */ printMessage(stderr, "PCCTS_AST: %s\n", err); exit(PCCTS_EXIT_FAILURE); }\r
-       virtual int printMessage(FILE* pFile, const char* pFormat, ...); // MR23\r
-};\r
-\r
-#endif /* PCCTSAST_H */\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/h/SList.h b/Tools/CodeTools/TianoTools/Pccts/h/SList.h
deleted file mode 100644 (file)
index 5b8bf97..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-#ifndef SList_h\r
-#define SList_h\r
-\r
-/*\r
- * SList.h\r
- *\r
- * SOFTWARE RIGHTS\r
- *\r
- * We reserve no LEGAL rights to SORCERER -- SORCERER is in the public\r
- * domain.  An individual or company may do whatever they wish with\r
- * source code distributed with SORCERER or the code generated by\r
- * SORCERER, including the incorporation of SORCERER, or its output, into\r
- * commerical software.\r
- *\r
- * We encourage users to develop software with SORCERER.  However, we do\r
- * ask that credit is given to us for developing SORCERER.  By "credit",\r
- * we mean that if you incorporate our source code into one of your\r
- * programs (commercial product, research project, or otherwise) that you\r
- * acknowledge this fact somewhere in the documentation, research report,\r
- * etc...  If you like SORCERER and have developed a nice tool with the\r
- * output, please mention that you developed it using SORCERER.  In\r
- * addition, we ask that this header remain intact in our source code.\r
- * As long as these guidelines are kept, we expect to continue enhancing\r
- * this system and expect to make other tools available as they are\r
- * completed.\r
- *\r
- * PCCTS 1.33\r
- * Terence Parr\r
- * Parr Research Corporation\r
- * with Purdue University and AHPCRC, University of Minnesota\r
- * 1992-2000\r
- */\r
-\r
-#include "pcctscfg.h"\r
-\r
-#include "pccts_stdio.h"\r
-#include "pccts_stdlib.h"\r
-\r
-PCCTS_NAMESPACE_STD\r
-\r
-#include "PCCTSAST.h"\r
-\r
-class PCCTS_AST;\r
-\r
-class SListNode {\r
-protected:\r
-       void *_elem;                    /* pointer to any kind of element */\r
-       SListNode *_next;\r
-public:\r
-       SListNode()                             {_elem=_next=NULL;}\r
-       virtual ~SListNode()    {_elem=_next=NULL;}\r
-       void *elem()                    { return _elem; }\r
-       void setElem(void *e)   { _elem = e; }\r
-       void setNext(SListNode *t)      { _next = t; }\r
-       SListNode *next()               { return _next; }\r
-};\r
-\r
-class SList {\r
-       SListNode *head, *tail;\r
-public:\r
-       SList() {head=tail=NULL;}\r
-       virtual ~SList() {head=tail=NULL;}\r
-       virtual void *iterate(SListNode **);\r
-       virtual void add(void *e);\r
-       virtual void lfree();\r
-       virtual PCCTS_AST *to_ast(SList list);\r
-       virtual void require(int e,char *err){ if ( !e ) panic(err); }\r
-       virtual void panic(char *err){ /* MR23 */ printMessage(stderr, "SList panic: %s\n", err); exit(PCCTS_EXIT_FAILURE); }\r
-       virtual int printMessage(FILE* pFile, const char* pFormat, ...); // MR23\r
-};\r
-\r
-#endif\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/h/antlr.h b/Tools/CodeTools/TianoTools/Pccts/h/antlr.h
deleted file mode 100644 (file)
index 8066453..0000000
+++ /dev/null
@@ -1,807 +0,0 @@
-/* antlr.h \r
- *\r
- * SOFTWARE RIGHTS\r
- *\r
- * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
- * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
- * company may do whatever they wish with source code distributed with\r
- * PCCTS or the code generated by PCCTS, including the incorporation of\r
- * PCCTS, or its output, into commerical software.\r
- *\r
- * We encourage users to develop software with PCCTS.  However, we do ask\r
- * that credit is given to us for developing PCCTS.  By "credit",\r
- * we mean that if you incorporate our source code into one of your\r
- * programs (commercial product, research project, or otherwise) that you\r
- * acknowledge this fact somewhere in the documentation, research report,\r
- * etc...  If you like PCCTS and have developed a nice tool with the\r
- * output, please mention that you developed it using PCCTS.  In\r
- * addition, we ask that this header remain intact in our source code.\r
- * As long as these guidelines are kept, we expect to continue enhancing\r
- * this system and expect to make other tools available as they are\r
- * completed.\r
- *\r
- * ANTLR 1.33\r
- * Terence Parr\r
- * Parr Research Corporation\r
- * with Purdue University and AHPCRC, University of Minnesota\r
- * 1989-2000\r
- */\r
-\r
-#ifndef ANTLR_H\r
-#define ANTLR_H\r
-\r
-#include "pcctscfg.h"\r
-\r
-#include "pccts_stdio.h"\r
-\r
-/* turn off warnings for unreferenced labels */\r
-\r
-#ifdef _MSC_VER\r
-#pragma warning(disable:4102)\r
-#endif\r
-\r
-/*\r
- * Define all of the stack setup and manipulation of $i, #i variables.\r
- *\r
- *     Notes:\r
- *             The type 'Attrib' must be defined before entry into this .h file.\r
- */\r
-\r
-\r
-#ifdef __USE_PROTOS\r
-#include "pccts_stdlib.h"\r
-#else\r
-#ifdef VAXC\r
-#include <stdlib.h>\r
-#else\r
-#include <malloc.h>\r
-#endif\r
-#endif\r
-#include "pccts_string.h"\r
-\r
-#if 0\r
-#include "set.h"\r
-#endif\r
-\r
-\r
-typedef int ANTLRTokenType;\r
-typedef unsigned char SetWordType;\r
-\r
-typedef char ANTLRChar;\r
-\r
-                                               /* G u e s s  S t u f f */\r
-\r
-#ifdef ZZCAN_GUESS\r
-#ifndef ZZINF_LOOK\r
-#define ZZINF_LOOK\r
-#endif\r
-#endif\r
-\r
-#ifdef ZZCAN_GUESS\r
-typedef struct _zzjmp_buf {\r
-                       jmp_buf state;\r
-               } zzjmp_buf;\r
-#endif\r
-\r
-\r
-/* can make this a power of 2 for more efficient lookup */\r
-\r
-#ifndef ZZLEXBUFSIZE\r
-#define ZZLEXBUFSIZE   8000 /* MR22 raise from 2k to 8k */\r
-#endif\r
-\r
-#define zzOvfChk                                                                                                               \\r
-            if ( zzasp <= 0 )                                           \\r
-            {                                                           \\r
-                fprintf(stderr, zzStackOvfMsg, __FILE__, __LINE__);            \\r
-                exit(PCCTS_EXIT_FAILURE);                                               \\r
-            }\r
-\r
-#ifndef ZZA_STACKSIZE\r
-#define ZZA_STACKSIZE  400\r
-#endif\r
-#ifndef ZZAST_STACKSIZE\r
-#define ZZAST_STACKSIZE        400\r
-#endif\r
-\r
-#ifndef zzfailed_pred\r
-#ifdef ZZCAN_GUESS\r
-#define zzfailed_pred(_p,_hasuseraction,_useraction) \\r
-  if (zzguessing) { \\r
-    zzGUESS_FAIL; \\r
-  } else { \\r
-    zzfailed_pred_action(_p,_hasuseraction,_useraction); \\r
-  }\r
-#else\r
-#define zzfailed_pred(_p,_hasuseraction,_useraction) \\r
-    zzfailed_pred_action(_p,_hasuseraction,_useraction);\r
-#endif\r
-#endif\r
-\r
-/*  MR23            Provide more control over failed predicate action\r
-                    without any need for user to worry about guessing internals.\r
-                    _hasuseraction == 0 => no user specified error action\r
-                    _hasuseraction == 1 => user specified error action\r
-*/\r
-\r
-#ifndef zzfailed_pred_action\r
-#define zzfailed_pred_action(_p,_hasuseraction,_useraction) \\r
-    if (_hasuseraction) { _useraction } \\r
-    else { fprintf(stderr, "semantic error; failed predicate: '%s'\n",_p); }\r
-#endif\r
-\r
-/* MR19 zzchar_t additions */\r
-\r
-#ifdef LL_K\r
-#define LOOKAHEAD \\r
-       int zztokenLA[LL_K]; \\r
-       zzchar_t zztextLA[LL_K][ZZLEXBUFSIZE]; \\r
-       int zzlap = 0, zzlabase=0; /* labase only used for DEMAND_LOOK */\r
-#else\r
-#define LOOKAHEAD                                                                                              \\r
-       int zztoken;\r
-#endif\r
-\r
-#ifndef zzcr_ast\r
-#define zzcr_ast(ast,attr,tok,text)\r
-#endif\r
-\r
-#ifdef DEMAND_LOOK\r
-#define DemandLookData  int zzdirty=1;\r
-#else\r
-#define DemandLookData\r
-#endif\r
-\r
-#ifndef zzUSER_GUESS_HOOK\r
-#define zzUSER_GUESS_HOOK(seqFrozen,zzrv)\r
-#endif\r
-\r
-#ifndef zzUSER_GUESS_DONE_HOOK\r
-#define zzUSER_GUESS_DONE_HOOK(seqFrozen)\r
-#endif\r
-\r
-                                               /* S t a t e  S t u f f */\r
-\r
-#ifdef ZZCAN_GUESS\r
-#define zzGUESS_BLOCK          zzantlr_state zzst; int zzrv; int zzGuessSeqFrozen;\r
-\r
-/* MR10 change zzGUESS: do zzGUESS_DONE when zzrv==1 after longjmp as in C++ mode */\r
-\r
-#define zzGUESS                                zzsave_antlr_state(&zzst); \\r
-                                                       zzguessing = 1; \\r
-                            zzGuessSeqFrozen=++zzGuessSeq; \\r
-                                                       zzrv = setjmp(zzguess_start.state); \\r
-                            zzUSER_GUESS_HOOK(zzGuessSeqFrozen,zzrv) \\r
-                            if (zzrv) zzGUESS_DONE;\r
-#ifdef zzTRACE_RULES\r
-#define zzGUESS_FAIL           { zzTraceGuessFail(); longjmp(zzguess_start.state, 1); }\r
-#else\r
-#define zzGUESS_FAIL           longjmp(zzguess_start.state, 1)\r
-#endif\r
-\r
-/* MR10 change zzGUESS_DONE: zzrv=1 to simulate longjmp() return value as in C++ mode */\r
-\r
-#define zzGUESS_DONE           { zzrestore_antlr_state(&zzst); zzrv=1; zzUSER_GUESS_DONE_HOOK(zzGuessSeqFrozen) }\r
-#define zzNON_GUESS_MODE       if ( !zzguessing )\r
-#define zzGuessData                                     \\r
-            zzjmp_buf zzguess_start;                    \\r
-            int zzguessing;\r
-#else\r
-#define zzGUESS_BLOCK\r
-#define zzGUESS\r
-#define zzGUESS_FAIL\r
-#define zzGUESS_DONE\r
-#define zzNON_GUESS_MODE\r
-#define zzGuessData\r
-#endif\r
-\r
-typedef struct _zzantlr_state {\r
-#ifdef ZZCAN_GUESS\r
-                       zzjmp_buf guess_start;\r
-                       int guessing;\r
-#endif\r
-                       int asp;\r
-                       int ast_sp;\r
-#ifdef ZZINF_LOOK\r
-                       int inf_lap;    /* not sure we need to save this one */\r
-                       int inf_labase;\r
-                       int inf_last;\r
-\r
-/* MR6         Gunnar Rxnning (gunnar@candleweb.no)                                */\r
-/* MR6   Additional state needs to be saved/restored                       */\r
-/* MR6    Matching changes in err.h                                         */\r
-\r
-                       int *inf_tokens;                                             /* MR6 */\r
-                       char **inf_text;                                             /* MR6 */\r
-                       char *inf_text_buffer;                                       /* MR6 */\r
-                       int *inf_line;                                               /* MR6 */\r
-#endif\r
-#ifdef DEMAND_LOOK\r
-                       int dirty;\r
-#endif\r
-\r
-#ifdef LL_K\r
-                       int tokenLA[LL_K];\r
-                       char textLA[LL_K][ZZLEXBUFSIZE];\r
-                       int lap;\r
-                       int labase;\r
-#else\r
-                       int token;\r
-                       char text[ZZLEXBUFSIZE];\r
-#endif\r
-#ifdef zzTRACE_RULES\r
-            int     traceOptionValue;       /* MR10 */\r
-            int     traceGuessOptionValue;  /* MR10 */\r
-            char    *traceCurrentRuleName;  /* MR10 */\r
-            int     traceDepth;             /* MR10 */\r
-#endif\r
-\r
-               } zzantlr_state;\r
-\r
-#ifdef zzTRACE_RULES\r
-extern int  zzTraceOptionValueDefault;\r
-extern int  zzTraceOptionValue;\r
-extern int  zzTraceGuessOptionValue;\r
-extern char *zzTraceCurrentRuleName;\r
-extern int  zzTraceDepth;\r
-#endif\r
-\r
-extern int zzGuessSeq;                      /* MR10 */\r
-extern int zzSyntaxErrCount;                /* MR11 */\r
-extern int zzLexErrCount;                   /* MR11 */\r
-\r
-                 /* I n f i n i t e  L o o k a h e a d */\r
-\r
-\r
-#ifdef ZZINF_LOOK\r
-#define InfLookData    \\r
-       int *zzinf_tokens;      \\r
-       char **zzinf_text;      \\r
-       char *zzinf_text_buffer;        \\r
-       int *zzinf_line;        \\r
-       int zzinf_labase;       \\r
-       int zzinf_last;\r
-#else\r
-#define InfLookData\r
-#endif\r
-\r
-#ifdef ZZINF_LOOK\r
-\r
-#ifndef ZZINF_DEF_TEXT_BUFFER_SIZE\r
-#define ZZINF_DEF_TEXT_BUFFER_SIZE         20000\r
-#endif\r
-#ifndef ZZINF_DEF_TOKEN_BUFFER_SIZE\r
-#define ZZINF_DEF_TOKEN_BUFFER_SIZE        2000\r
-#endif\r
-/* WARNING!!!!!!\r
- * ZZINF_BUFFER_TEXT_CHUNK_SIZE must be > sizeof(text) largest possible token.\r
- */\r
-#ifndef ZZINF_BUFFER_TEXT_CHUNK_SIZE\r
-#define ZZINF_BUFFER_TEXT_CHUNK_SIZE   5000\r
-#endif\r
-#ifndef ZZINF_BUFFER_TOKEN_CHUNK_SIZE\r
-#define ZZINF_BUFFER_TOKEN_CHUNK_SIZE  1000\r
-#endif\r
-\r
-#if ZZLEXBUFSIZE > ZZINF_BUFFER_TEXT_CHUNK_SIZE\r
-#define ZZINF_BUFFER_TEXT_CHUNK_SIZE   ZZLEXBUFSIZE+5\r
-#endif\r
-\r
-/* make inf_look user-access macros */\r
-#ifdef LL_K\r
-#define ZZINF_LA_VALID(i)      (((zzinf_labase+i-1)-LL_K+1) <= zzinf_last)\r
-#define ZZINF_LA(i)                    zzinf_tokens[(zzinf_labase+i-1)-LL_K+1]\r
-#define ZZINF_LATEXT(i)                zzinf_text[(zzinf_labase+i-1)-LL_K+1]\r
-/* MR6 In 1.33 vanilla the #define ZZINF_LINE(i) is was commented out  */\r
-#define ZZINF_LINE(i)       zzinf_line[(zzinf_labase+i-1)-LL_K+1]\r
-#else\r
-#define ZZINF_LA_VALID(i)      (((zzinf_labase+i-1)) <= zzinf_last)\r
-#define ZZINF_LA(i)                    zzinf_tokens[(zzinf_labase+i-1)]\r
-#define ZZINF_LATEXT(i)                zzinf_text[(zzinf_labase+i-1)]\r
-#endif\r
-\r
-#define inf_zzgettok _inf_zzgettok()\r
-extern void _inf_zzgettok();\r
-\r
-#endif /* ZZINF_LOOK */\r
-\r
-\r
-#ifdef LL_K\r
-\r
-#ifdef __USE_PROTOS\r
-#define ANTLR_INFO     \\r
-       Attrib zzempty_attr(void) {static Attrib a; return a;} \\r
-       Attrib zzconstr_attr(int _tok, char *_text) \\r
-               {Attrib a; zzcr_attr((&a),_tok,_text); return a;} \\r
-       int zzasp=ZZA_STACKSIZE; \\r
-       char zzStackOvfMsg[]="fatal: attrib/AST stack overflow %s(%d)!\n"; \\r
-       Attrib zzaStack[ZZA_STACKSIZE]; DemandLookData \\r
-       InfLookData \\r
-    zzGuessData\r
-#else\r
-#define ANTLR_INFO                                                                                             \\r
-       Attrib zzempty_attr() {static Attrib a; return a;}                  \\r
-       Attrib zzconstr_attr(_tok, _text) int _tok; char *_text;    \\r
-               {Attrib a; zzcr_attr((&a),_tok,_text); return a;}           \\r
-       int zzasp=ZZA_STACKSIZE;                                            \\r
-       char zzStackOvfMsg[]="fatal: attrib/AST stack overflow %s(%d)!\n";  \\r
-       Attrib zzaStack[ZZA_STACKSIZE]; DemandLookData                      \\r
-       InfLookData                                                 \\r
-    zzGuessData\r
-#endif\r
-\r
-#else\r
-\r
-#ifdef __USE_PROTOS\r
-#define ANTLR_INFO                                                                                             \\r
-       Attrib zzempty_attr(void) {static Attrib a; return a;}                  \\r
-       Attrib zzconstr_attr(int _tok, char *_text)                             \\r
-               {Attrib a; zzcr_attr((&a),_tok,_text); return a;}               \\r
-       int zzasp=ZZA_STACKSIZE;                                                \\r
-       char zzStackOvfMsg[]="fatal: attrib/AST stack overflow %s(%d)!\n";      \\r
-       Attrib zzaStack[ZZA_STACKSIZE]; DemandLookData                          \\r
-       InfLookData                                                             \\r
-    zzGuessData\r
-#else\r
-#define ANTLR_INFO                                                                                             \\r
-       Attrib zzempty_attr() {static Attrib a; return a;}                      \\r
-       Attrib zzconstr_attr(_tok, _text) int _tok; char *_text;                \\r
-               {Attrib a; zzcr_attr((&a),_tok,_text); return a;}               \\r
-       int zzasp=ZZA_STACKSIZE;                                                \\r
-       char zzStackOvfMsg[]="fatal: attrib/AST stack overflow %s(%d)!\n";      \\r
-       Attrib zzaStack[ZZA_STACKSIZE]; DemandLookData                          \\r
-       InfLookData                                                             \\r
-    zzGuessData\r
-#endif\r
-       \r
-#endif /* LL_k */\r
-\r
-\r
-#ifdef ZZINF_LOOK\r
-\r
-#ifdef LL_K\r
-#ifdef DEMAND_LOOK\r
-#define zzPrimeLookAhead  {zzdirty=LL_K; zzlap = zzlabase = 0;}\r
-#else\r
-#define zzPrimeLookAhead  {zzlap = zzlabase = 0; zzfill_inf_look();\\r
-                                                 {int _i;  for(_i=1;_i<=LL_K; _i++)            \\r
-                                                                               {zzCONSUME;} zzlap = zzlabase = 0;}}\r
-#endif\r
-\r
-#else /* LL_K */\r
-\r
-#ifdef DEMAND_LOOK\r
-#define zzPrimeLookAhead  zzfill_inf_look(); zzdirty=1\r
-#else\r
-#define zzPrimeLookAhead  zzfill_inf_look(); inf_zzgettok\r
-\r
-#endif\r
-#endif /* LL_K */\r
-\r
-#else  /* ZZINF_LOOK */\r
-\r
-#ifdef LL_K\r
-#ifdef DEMAND_LOOK\r
-#define zzPrimeLookAhead  {zzdirty=LL_K; zzlap = zzlabase = 0;}\r
-#else\r
-#define zzPrimeLookAhead  {int _i; zzlap = 0; for(_i=1;_i<=LL_K; _i++)         \\r
-                                                                               {zzCONSUME;} zzlap = 0;}\r
-#endif\r
-\r
-#else\r
-\r
-#ifdef DEMAND_LOOK\r
-#define zzPrimeLookAhead  zzdirty=1\r
-#else\r
-#define zzPrimeLookAhead  zzgettok()\r
-#endif\r
-#endif /* LL_K */\r
-\r
-#endif /* ZZINF_LOOK */\r
-\r
-\r
-#ifdef LL_K\r
-#define zzenterANTLRs(s)                            \\r
-        zzlextext = &(zztextLA[0][0]); zzrdstr( s ); zzPrimeLookAhead;\r
-#define zzenterANTLRf(f)                                                       \\r
-               zzlextext = &(zztextLA[0][0]); zzrdfunc( f ); zzPrimeLookAhead;\r
-#define zzenterANTLR(f)                                                        \\r
-               zzlextext = &(zztextLA[0][0]); zzrdstream( f ); zzPrimeLookAhead;\r
-#ifdef ZZINF_LOOK\r
-#define zzleaveANTLR(f)                        free(zzinf_text_buffer); free(zzinf_text); free(zzinf_tokens); free(zzinf_line);\r
-#define zzleaveANTLRf(f)               free(zzinf_text_buffer); free(zzinf_text); free(zzinf_tokens); free(zzinf_line);\r
-#define zzleaveANTLRs(f)               free(zzinf_text_buffer); free(zzinf_text); free(zzinf_tokens); free(zzinf_line);\r
-#else\r
-#define zzleaveANTLR(f)\r
-#define zzleaveANTLRf(f)\r
-#define zzleaveANTLRs(f)\r
-#endif\r
-\r
-#else\r
-\r
-#define zzenterANTLRs(s)                            \\r
-        {static char zztoktext[ZZLEXBUFSIZE];   \\r
-        zzlextext = zztoktext; zzrdstr( s ); zzPrimeLookAhead;}\r
-#define zzenterANTLRf(f)                                                       \\r
-               {static char zztoktext[ZZLEXBUFSIZE];   \\r
-               zzlextext = zztoktext; zzrdfunc( f ); zzPrimeLookAhead;}\r
-#define zzenterANTLR(f)                                                        \\r
-               {static char zztoktext[ZZLEXBUFSIZE];   \\r
-               zzlextext = zztoktext; zzrdstream( f ); zzPrimeLookAhead;}\r
-#ifdef ZZINF_LOOK\r
-#define zzleaveANTLR(f)                        free(zzinf_text_buffer); free(zzinf_text); free(zzinf_tokens); free(zzinf_line);\r
-#define zzleaveANTLRf(f)               free(zzinf_text_buffer); free(zzinf_text); free(zzinf_tokens); free(zzinf_line);\r
-#define zzleaveANTLRs(f)               free(zzinf_text_buffer); free(zzinf_text); free(zzinf_tokens); free(zzinf_line);\r
-#else\r
-#define zzleaveANTLR(f)\r
-#define zzleaveANTLRf(f)\r
-#define zzleaveANTLRs(f)\r
-#endif\r
-\r
-#endif\r
-\r
-/* MR19 Paul D. Smith (psmith@baynetworks.com)\r
-   Need to adjust AST stack pointer at exit.\r
-   Referenced in ANTLRx macros.\r
-*/\r
-\r
-#ifdef GENAST\r
-#define ZZAST_ADJUST ++zzast_sp;\r
-#else\r
-#define ZZAST_ADJUST\r
-#endif\r
-\r
-#define ANTLR(st, f)   zzbufsize = ZZLEXBUFSIZE;       \\r
-                                               zzenterANTLR(f);                        \\r
-            {                                            \\r
-              zzBLOCK(zztasp1);                          \\r
-                                                 st; /* ++zzasp; Removed MR20 G. Hobbelt */     \\r
-                                                     /* ZZAST_ADJUST Removed MR20 G. Hobbelt */ \\r
-              /* MR20 G. Hobbelt. Kill the top' attribute (+AST stack corr.) */  \\r
-              zzEXIT_ANTLR(zztasp1 + 1);                 \\r
-            }                                            \\r
-                                               zzleaveANTLR(f);\r
-                                               \r
-#define ANTLRm(st, f, _m)      zzbufsize = ZZLEXBUFSIZE;       \\r
-                                               zzmode(_m);                             \\r
-                                               zzenterANTLR(f);                        \\r
-            {                                            \\r
-              zzBLOCK(zztasp1);                          \\r
-                                                 st; /* ++zzasp; Removed MR20 G. Hobbelt */     \\r
-                                                     /* ZZAST_ADJUST Removed MR20 G. Hobbelt */ \\r
-              /* MR20 G. Hobbelt. Kill the top' attribute (+AST stack corr.) */  \\r
-              zzEXIT_ANTLR(zztasp1 + 1);                 \\r
-            }                                            \\r
-                                               zzleaveANTLR(f);\r
-                                               \r
-#define ANTLRf(st, f)  zzbufsize = ZZLEXBUFSIZE;       \\r
-                                               zzenterANTLRf(f);                       \\r
-            {                                            \\r
-              zzBLOCK(zztasp1);                          \\r
-                                                 st; /* ++zzasp; Removed MR20 G. Hobbelt */     \\r
-                                                     /* ZZAST_ADJUST Removed MR20 G. Hobbelt */ \\r
-              /* MR20 G. Hobbelt. Kill the top' attribute (+AST stack corr.) */  \\r
-              zzEXIT_ANTLR(zztasp1 + 1);                 \\r
-            }                                            \\r
-                                               zzleaveANTLRf(f);\r
-\r
-#define ANTLRs(st, s)   zzbufsize = ZZLEXBUFSIZE;      \\r
-                        zzenterANTLRs(s);           \\r
-            {                                            \\r
-              zzBLOCK(zztasp1);                          \\r
-                                                 st; /* ++zzasp; Removed MR20 G. Hobbelt */     \\r
-                                                     /* ZZAST_ADJUST Removed MR20 G. Hobbelt */ \\r
-              /* MR20 G. Hobbelt. Kill the top' attribute (+AST stack corr.) */  \\r
-              zzEXIT_ANTLR(zztasp1 + 1);                 \\r
-            }                                            \\r
-                        zzleaveANTLRs(s);\r
-\r
-#ifdef LL_K\r
-#define zztext         (&(zztextLA[zzlap][0]))\r
-#else\r
-#define zztext         zzlextext\r
-#endif\r
-\r
-\r
-                                       /* A r g u m e n t  A c c e s s */\r
-\r
-#define zzaCur                 (zzaStack[zzasp])\r
-#define zzaRet                 (*zzaRetPtr)\r
-#define zzaArg(v,n)            zzaStack[v-n]\r
-#define zzMakeAttr             { zzNON_GUESS_MODE {zzOvfChk; --zzasp; zzcr_attr(&(zzaStack[zzasp]),LA(1),LATEXT(1));}}\r
-#ifdef zzdef0\r
-#define zzMake0                        { zzOvfChk; --zzasp; zzdef0(&(zzaStack[zzasp]));}\r
-#else\r
-#define zzMake0                        { zzOvfChk; --zzasp;}\r
-#endif\r
-#define zzaPush(_v)            { zzOvfChk; zzaStack[--zzasp] = _v;}\r
-#ifndef zzd_attr\r
-#define zzREL(t)               zzasp=(t);              /* Restore state of stack */\r
-#else\r
-#define zzREL(t)               for (; zzasp<(t); zzasp++)                              \\r
-                                               { zzd_attr(&(zzaStack[zzasp])); }\r
-#endif\r
-\r
-\r
-#define zzsetmatch(_es,_tokclassErrset)                                                \\r
-       if ( !_zzsetmatch(_es, &zzBadText, &zzMissText, &zzMissTok, &zzBadTok, &zzMissSet, _tokclassErrset) ) goto fail; /* MR23 */\r
-\r
-#ifdef ZZCAN_GUESS\r
-#define zzsetmatch_wsig(_es, handler)          \\r
-       if ( !_zzsetmatch_wsig(_es) ) if (zzguessing) { zzGUESS_FAIL; } else {_signal=MismatchedToken; goto handler;}\r
-#else\r
-#define zzsetmatch_wsig(_es, handler)          \\r
-       if ( !_zzsetmatch_wsig(_es) ) {_signal=MismatchedToken; goto handler;}\r
-#endif\r
-\r
-#ifdef __USE_PROTOS\r
-extern int _zzsetmatch(SetWordType *, char **, char **, int *, int *, SetWordType **, SetWordType * /* MR23 */); \r
-extern int _zzsetmatch_wsig(SetWordType *);\r
-#else\r
-extern int _zzsetmatch();\r
-extern int _zzsetmatch_wsig();\r
-#endif\r
-\r
-#define zzmatch(_t)                                                    \\r
-       if ( !_zzmatch(_t, &zzBadText, &zzMissText, &zzMissTok, &zzBadTok, &zzMissSet) ) goto fail;\r
-\r
-#ifdef ZZCAN_GUESS\r
-#define zzmatch_wsig(_t,handler)                       \\r
-       if ( !_zzmatch_wsig(_t) ) if (zzguessing) { zzGUESS_FAIL; } else {_signal=MismatchedToken; goto handler;}\r
-#else\r
-#define zzmatch_wsig(_t,handler)                       \\r
-       if ( !_zzmatch_wsig(_t) ) {_signal=MismatchedToken; goto handler;}\r
-#endif\r
-\r
-#ifdef __USE_PROTOS\r
-extern int _zzmatch(int, char **, char **, int *, int *, SetWordType **);\r
-extern int _zzmatch_wsig(int);\r
-#else\r
-extern int _zzmatch();\r
-extern int _zzmatch_wsig();\r
-#endif\r
-\r
-#define zzmatch_wdfltsig(_t,_f)                        \\r
-       if ( !_zzmatch_wdfltsig(_t,_f) ) _signal=MismatchedToken;\r
-#define zzsetmatch_wdfltsig(tw,tt,wf)          \\r
-       if ( !_zzsetmatch_wdfltsig(tw,tt,wf) ) _signal=MismatchedToken;\r
-\r
-#ifdef __USE_PROTOS\r
-extern int _zzmatch_wdfltsig(int, SetWordType *);\r
-extern int _zzsetmatch_wdfltsig(SetWordType *tokensWanted,\r
-                                                               int tokenTypeOfSet,\r
-                                                               SetWordType *whatFollows);\r
-#else\r
-extern int _zzmatch_wdfltsig();\r
-extern int _zzsetmatch_wdfltsig();\r
-#endif\r
-\r
-#ifdef GENAST\r
-#define zzRULE         Attrib *zzaRetPtr = &(zzaStack[zzasp-1]);       \\r
-                                       SetWordType *zzMissSet=NULL; int zzMissTok=0;           \\r
-                                       int zzBadTok=0; char *zzBadText="";             \\r
-                                       int zzErrk=1,zzpf=0;                                    \\r
-                    zzTRACEdata \\r
-                                       char *zzMissText=""; zzASTVars\r
-#else\r
-#define zzRULE         Attrib *zzaRetPtr = &(zzaStack[zzasp-1]);       \\r
-                                       int zzBadTok=0; char *zzBadText="";             \\r
-                                       int zzErrk=1,zzpf=0;                                                            \\r
-                    zzTRACEdata \\r
-                                       SetWordType *zzMissSet=NULL; int zzMissTok=0; char *zzMissText=""\r
-#endif\r
-\r
-#ifdef GENAST\r
-#define zzBLOCK(i)     int i = zzasp - 1; int zztsp = zzast_sp\r
-#define zzEXIT(i)      zzREL(i); zzastREL; zzNON_GUESS_MODE { zzastPush(*_root); }\r
-#define zzEXIT_ANTLR(i)        zzREL(i); zzastREL /* [i_a] added as we want this for the ANTLRx() macros */\r
-#define zzLOOP(i)      zzREL(i); zzastREL\r
-#else\r
-#define zzBLOCK(i)     int i = zzasp - 1\r
-#define zzEXIT(i)      zzREL(i)\r
-#define zzEXIT_ANTLR(i)        zzREL(i)           /* [i_a] added as we want this for the ANTLRx() macros */\r
-#define zzLOOP(i)      zzREL(i)\r
-#endif\r
-\r
-#ifdef LL_K\r
-\r
-#ifdef DEMAND_LOOK\r
-#define LOOK(_k)       {int i,stop=_k-(LL_K-zzdirty); for (i=1; i<=stop; i++)  \\r
-                                       zzCONSUME;}\r
-#define zzCONSUME      {zzgettok(); zzdirty--;                                                 \\r
-                                       zzlap = (zzlap+1)&(LL_K-1);                                             \\r
-                                       zzlextext = &(zztextLA[zzlap][0]);}\r
-#else\r
-#ifdef ZZINF_LOOK\r
-#define zzCONSUME      {inf_zzgettok;                                                                  \\r
-                                       zzlap = (zzlap+1)&(LL_K-1);                                             \\r
-                                       zzlextext = &(zztextLA[zzlap][0]);                              \\r
-                                       }\r
-#else\r
-#define zzCONSUME      {zzgettok();                                                                    \\r
-                                       zzlap = (zzlap+1)&(LL_K-1);                                             \\r
-                                       zzlextext = &(zztextLA[zzlap][0]);}\r
-#endif /* ZZINF_LOOK */\r
-#endif /* DEMAND_LOOK */\r
-\r
-#else /* LL_K */\r
-\r
-#ifdef DEMAND_LOOK\r
-#define LOOK(_k)       if ( zzdirty) zzCONSUME;\r
-#ifdef ZZINF_LOOK\r
-#define zzCONSUME      inf_zzgettok; zzdirty=0;\r
-#else\r
-#define zzCONSUME      zzgettok(); zzdirty=0;\r
-#endif /* ZZINF_LOOK */\r
-\r
-#else  /* DEMAND_LOOK */\r
-\r
-#ifdef ZZINF_LOOK\r
-#define zzCONSUME      inf_zzgettok\r
-#else\r
-#define zzCONSUME      zzgettok();\r
-#endif\r
-\r
-#endif /* DEMAND_LOOK */\r
-\r
-#endif /* LL_K */\r
-\r
-#ifdef LL_K\r
-#define NLA                    zztokenLA[zzlap&(LL_K-1)]       /* --> next LA */\r
-#define NLATEXT                zztextLA[zzlap&(LL_K-1)]        /* --> next text of LA */\r
-#ifdef DEMAND_LOOK\r
-#define LA(i)       zztokenLA[(zzlabase+(i)-1)&(LL_K-1)]\r
-#define LATEXT(i)   (&(zztextLA[(zzlabase+(i)-1)&(LL_K-1)][0]))\r
-#else\r
-#define LA(i)       zztokenLA[(zzlap+(i)-1)&(LL_K-1)]\r
-#define LATEXT(i)   (&(zztextLA[(zzlap+(i)-1)&(LL_K-1)][0]))\r
-#endif\r
-#else\r
-#define NLA                    zztoken\r
-#define NLATEXT                zztext\r
-#define LA(i)       zztoken\r
-#define LATEXT(i)   zztext\r
-#endif\r
-\r
-\r
-           /* S t a n d a r d  S i g n a l s */\r
-\r
-#define NoSignal                       0\r
-#define MismatchedToken                1\r
-#define NoViableAlt                    2\r
-#define NoSemViableAlt         3\r
-\r
-/* MR7  Allow more control over signalling                                  */\r
-/*        by adding "Unwind" and "zzsetSignal"                              */\r
-\r
-#define Unwind              4\r
-#define zzsetSignal(newValue) *_retsignal=_signal=(newValue)\r
-#define zzsuppressSignal *_retsignal=_signal=0\r
-#define zzexportSignal    *_retsignal=_signal\r
-\r
-           /* F u n c t i o n  T r a c i n g */\r
-\r
-#ifndef zzTRACE_RULES\r
-#define zzTRACEdata\r
-#else\r
-#ifndef zzTRACEdata\r
-#define zzTRACEdata     ANTLRChar *zzTracePrevRuleName = NULL;\r
-#endif\r
-#endif\r
-\r
-#ifndef zzTRACEIN\r
-#define zzTRACEIN(r)   zzTracePrevRuleName=zzTraceCurrentRuleName;zzTraceIn(r);\r
-#endif\r
-#ifndef zzTRACEOUT\r
-#define zzTRACEOUT(r)  zzTraceOut(r);zzTraceCurrentRuleName=zzTracePrevRuleName;\r
-#endif\r
-\r
-/* MR19 zzchar_t additions */\r
-\r
-#ifndef zzchar_t\r
-#ifdef ZZWCHAR_T\r
-#define zzchar_t wchar_t\r
-#else\r
-#define zzchar_t char\r
-#endif\r
-#endif\r
-\r
-\r
-/* MR26 */\r
-\r
-#ifdef PCCTS_USE_STDARG\r
-extern void zzFAIL(int k, ...);\r
-#else\r
-extern void zzFAIL();\r
-#endif\r
-                               /* E x t e r n  D e f s */\r
-\r
-#ifdef __USE_PROTOS\r
-extern Attrib zzempty_attr(void);\r
-extern Attrib zzconstr_attr(int, char *);\r
-extern void zzsyn(char *, int, char *, SetWordType *, int, int, char *);\r
-extern int zzset_el(unsigned, SetWordType *);\r
-extern int zzset_deg(SetWordType *);\r
-extern void zzedecode(SetWordType *);\r
-\r
-extern void zzresynch(SetWordType *, SetWordType);\r
-extern void zzsave_antlr_state(zzantlr_state *);\r
-extern void zzrestore_antlr_state(zzantlr_state *);\r
-extern void zzfill_inf_look(void);\r
-extern void zzconsumeUntil(SetWordType *st);                         /* MR7 */\r
-extern void zzconsumeUntilToken(int t);                              /* MR7 */\r
-extern void zzTraceIn(char * ruleName);                              /* MR10 */\r
-extern void zzTraceOut(char * ruleName);                             /* MR10 */\r
-extern int  zzTraceOption(int delta);                                /* MR10 */\r
-extern int  zzTraceGuessOption(int delta);                           /* MR10 */\r
-extern void zzTraceReset(void);                                      /* MR10 */\r
-extern void zzTraceGuessFail(void);                                  /* MR10 */\r
-#ifdef EXCEPTION_HANDLING\r
-extern void zzdflthandlers(int, int *);\r
-#endif\r
-#else\r
-extern Attrib zzempty_attr();\r
-extern Attrib zzconstr_attr();\r
-extern void zzsyn();\r
-extern int zzset_el();\r
-extern int zzset_deg();\r
-extern void zzedecode();\r
-extern void zzresynch();\r
-extern void zzsave_antlr_state();\r
-extern void zzrestore_antlr_state();\r
-extern void zzfill_inf_look();\r
-extern void zzconsumeUntil();                                        /* MR7 */\r
-extern void zzconsumeUntilToken();                                   /* MR7 */\r
-extern void zzTraceIn();                                             /* MR10 */\r
-extern void zzTraceOut();                                            /* MR10 */\r
-extern int  zzTraceOption();                                         /* MR10 */\r
-extern int  zzTraceGuessOption();                                    /* MR10 */\r
-extern void zzTraceReset();                                          /* MR10 */\r
-extern void zzTraceGuessFail();                                      /* MR10 */\r
-#ifdef EXCEPTION_HANDLING\r
-extern void zzdflthandlers();\r
-#endif\r
-#endif\r
-\r
-                               /* G l o b a l  V a r i a b l e s */\r
-\r
-/* Define a parser; user should do a "#parser myname" in their grammar file */\r
-/*extern struct pccts_parser zzparser;*/\r
-\r
-extern char *zztokens[];\r
-#ifdef LL_K\r
-extern int zztokenLA[];\r
-extern zzchar_t zztextLA[][ZZLEXBUFSIZE];\r
-extern int zzlap;\r
-extern int zzlabase;\r
-#else\r
-extern int zztoken;\r
-#endif\r
-\r
-extern char zzStackOvfMsg[];\r
-extern int zzasp;\r
-extern Attrib zzaStack[];\r
-#ifdef ZZINF_LOOK\r
-extern int *zzinf_tokens;\r
-extern char **zzinf_text;\r
-extern char *zzinf_text_buffer;\r
-extern int *zzinf_line;\r
-extern int zzinf_labase;\r
-extern int zzinf_last;\r
-#endif\r
-#ifdef DEMAND_LOOK\r
-extern int zzdirty;\r
-#endif\r
-#ifdef ZZCAN_GUESS\r
-extern int zzguessing;\r
-extern zzjmp_buf zzguess_start;\r
-#endif\r
-\r
-/* Define global veriables that refer to values exported by the scanner.\r
- * These declarations duplicate those in dlgdef.h, but are needed\r
- * if ANTLR is not to generate a .dlg file (-gx); PS, this is a hack.\r
- */\r
-extern zzchar_t *zzlextext;     /* text of most recently matched token */\r
-extern int      zzbufsize;      /* how long zzlextext is */\r
-\r
-#endif\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/h/ast.c b/Tools/CodeTools/TianoTools/Pccts/h/ast.c
deleted file mode 100644 (file)
index 9326ae1..0000000
+++ /dev/null
@@ -1,345 +0,0 @@
-/* Abstract syntax tree manipulation functions\r
- *\r
- * SOFTWARE RIGHTS\r
- *\r
- * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
- * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
- * company may do whatever they wish with source code distributed with\r
- * PCCTS or the code generated by PCCTS, including the incorporation of\r
- * PCCTS, or its output, into commerical software.\r
- *\r
- * We encourage users to develop software with PCCTS.  However, we do ask\r
- * that credit is given to us for developing PCCTS.  By "credit",\r
- * we mean that if you incorporate our source code into one of your\r
- * programs (commercial product, research project, or otherwise) that you\r
- * acknowledge this fact somewhere in the documentation, research report,\r
- * etc...  If you like PCCTS and have developed a nice tool with the\r
- * output, please mention that you developed it using PCCTS.  In\r
- * addition, we ask that this header remain intact in our source code.\r
- * As long as these guidelines are kept, we expect to continue enhancing\r
- * this system and expect to make other tools available as they are\r
- * completed. \r
- *\r
- * ANTLR 1.33\r
- * Terence Parr\r
- * Parr Research Corporation\r
- * with Purdue University and AHPCRC, University of Minnesota\r
- * 1989-2000\r
- */\r
-\r
-#include "pcctscfg.h"\r
-\r
-#ifdef PCCTS_USE_STDARG\r
-#include "pccts_stdarg.h"\r
-#else\r
-#include <varargs.h>\r
-#endif\r
-\r
-/* ensure that tree manipulation variables are current after a rule\r
- * reference\r
- */\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-zzlink(AST **_root, AST **_sibling, AST **_tail)\r
-#else\r
-zzlink(_root, _sibling, _tail)\r
-AST **_root, **_sibling, **_tail;\r
-#endif\r
-{\r
-       if ( *_sibling == NULL ) return;\r
-       if ( *_root == NULL ) *_root = *_sibling;\r
-       else if ( *_root != *_sibling ) (*_root)->down = *_sibling;\r
-       if ( *_tail==NULL ) *_tail = *_sibling;\r
-       while ( (*_tail)->right != NULL ) *_tail = (*_tail)->right;\r
-}\r
-\r
-AST *\r
-#ifdef __USE_PROTOS\r
-zzastnew(void)\r
-#else\r
-zzastnew()\r
-#endif\r
-{\r
-       AST *p = (AST *) calloc(1, sizeof(AST));\r
-       if ( p == NULL ) fprintf(stderr,"%s(%d): cannot allocate AST node\n",__FILE__,__LINE__);\r
-       return p;\r
-}\r
-\r
-/* add a child node to the current sibling list */\r
-void\r
-#ifdef __USE_PROTOS\r
-zzsubchild(AST **_root, AST **_sibling, AST **_tail)\r
-#else\r
-zzsubchild(_root, _sibling, _tail)\r
-AST **_root, **_sibling, **_tail;\r
-#endif\r
-{\r
-       AST *n;\r
-       zzNON_GUESS_MODE {\r
-       n = zzastnew();\r
-#ifdef DEMAND_LOOK\r
-       zzcr_ast(n, &(zzaCur), LA(0), LATEXT(0));\r
-#else\r
-       zzcr_ast(n, &(zzaCur), LA(1), LATEXT(1));\r
-#endif\r
-       zzastPush( n );\r
-       if ( *_tail != NULL ) (*_tail)->right = n;\r
-       else {\r
-               *_sibling = n;\r
-               if ( *_root != NULL ) (*_root)->down = *_sibling;\r
-       }\r
-       *_tail = n;\r
-       if ( *_root == NULL ) *_root = *_sibling;\r
-       }\r
-}\r
-\r
-/* make a new AST node.  Make the newly-created\r
- * node the root for the current sibling list.  If a root node already\r
- * exists, make the newly-created node the root of the current root.\r
- */\r
-void\r
-#ifdef __USE_PROTOS\r
-zzsubroot(AST **_root, AST **_sibling, AST **_tail)\r
-#else\r
-zzsubroot(_root, _sibling, _tail)\r
-AST **_root, **_sibling, **_tail;\r
-#endif\r
-{\r
-       AST *n;\r
-       zzNON_GUESS_MODE {\r
-       n = zzastnew();\r
-#ifdef DEMAND_LOOK\r
-       zzcr_ast(n, &(zzaCur), LA(0), LATEXT(0));\r
-#else\r
-       zzcr_ast(n, &(zzaCur), LA(1), LATEXT(1));\r
-#endif\r
-       zzastPush( n );\r
-       if ( *_root != NULL )\r
-               if ( (*_root)->down == *_sibling ) *_sibling = *_tail = *_root;\r
-       *_root = n;\r
-       (*_root)->down = *_sibling;\r
-       }\r
-}\r
-\r
-/* Apply function to root then each sibling\r
- * example: print tree in child-sibling LISP-format (AST has token field)\r
- *\r
- *     void show(tree)\r
- *     AST *tree;\r
- *     {\r
- *             if ( tree == NULL ) return;\r
- *             printf(" %s", zztokens[tree->token]);\r
- *     }\r
- *\r
- *     void before() { printf(" ("); }\r
- *     void after()  { printf(" )"); }\r
- *\r
- *     LISPdump() { zzpre_ast(tree, show, before, after); }\r
- *\r
- */\r
-void\r
-#ifdef __USE_PROTOS\r
-zzpre_ast(\r
-         AST *tree,\r
-         void (*func)(AST *),   /* apply this to each tree node */\r
-         void (*before)(AST *), /* apply this to root of subtree before preordering it */\r
-         void (*after)(AST *))  /* apply this to root of subtree after preordering it */\r
-#else\r
-zzpre_ast(tree, func, before, after)\r
-AST *tree;\r
-void (*func)(),   /* apply this to each tree node */\r
-        (*before)(), /* apply this to root of subtree before preordering it */\r
-        (*after)();  /* apply this to root of subtree after preordering it */\r
-#endif\r
-{\r
-       while ( tree!= NULL )\r
-       {\r
-               if ( tree->down != NULL ) (*before)(tree);\r
-               (*func)(tree);\r
-               zzpre_ast(tree->down, func, before, after);\r
-               if ( tree->down != NULL ) (*after)(tree);\r
-               tree = tree->right;\r
-       }\r
-}\r
-\r
-/* free all AST nodes in tree; apply func to each before freeing */\r
-\r
-#if 0\r
-////void\r
-////#ifdef __USE_PROTOS\r
-////zzfree_ast(AST *tree)\r
-////#else\r
-////zzfree_ast(tree)\r
-////AST *tree;\r
-////#endif\r
-////{\r
-////   if ( tree == NULL ) return;\r
-////   zzfree_ast( tree->down );\r
-////   zzfree_ast( tree->right );\r
-////   zztfree( tree );\r
-////}\r
-#endif\r
-\r
-/*\r
-   MR19 Optimize freeing of the following structure to limit recursion\r
-   SAKAI Kiyotaka (ksakai@isr.co.jp)\r
-*/\r
-\r
-/*\r
-         NULL o\r
-             / \\r
-           NULL o\r
-               / \\r
-            NULL NULL\r
-*/\r
-\r
-/*\r
-   MR21 Another refinement to replace recursion with iteration\r
-   NAKAJIMA Mutsuki (muc@isr.co.jp).\r
-*/\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-zzfree_ast(AST *tree)\r
-#else\r
-zzfree_ast(tree)\r
-AST *tree;\r
-#endif\r
-{\r
-\r
-    AST *otree;\r
-\r
-    if (tree == NULL) return;\r
-\r
-    while (tree->down == NULL || tree->right == NULL) {\r
-\r
-        if (tree->down == NULL && tree->right == NULL) {\r
-            zztfree(tree);\r
-            return;\r
-        }\r
-\r
-        otree = tree;\r
-        if (tree->down == NULL) {\r
-            tree = tree->right;\r
-        } else {\r
-            tree = tree->down;\r
-        }\r
-        zztfree( otree );\r
-    }\r
-\r
-    while (tree != NULL) {\r
-        zzfree_ast(tree->down);\r
-        otree = tree;\r
-        tree = otree->right;\r
-        zztfree(otree);\r
-    }\r
-}\r
-\r
-/* build a tree (root child1 child2 ... NULL)\r
- * If root is NULL, simply make the children siblings and return ptr\r
- * to 1st sibling (child1).  If root is not single node, return NULL.\r
- *\r
- * Siblings that are actually siblins lists themselves are handled\r
- * correctly.  For example #( NULL, #( NULL, A, B, C), D) results\r
- * in the tree ( NULL A B C D ).\r
- *\r
- * Requires at least two parameters with the last one being NULL.  If\r
- * both are NULL, return NULL.\r
- */\r
-#ifdef PCCTS_USE_STDARG\r
-AST *zztmake(AST *rt, ...)\r
-#else\r
-AST *zztmake(va_alist)\r
-va_dcl\r
-#endif\r
-{\r
-       va_list ap;\r
-       register AST *child, *sibling=NULL, *tail=NULL /* MR20 */, *w;\r
-       AST *root;\r
-\r
-#ifdef PCCTS_USE_STDARG\r
-       va_start(ap, rt);\r
-       root = rt;\r
-#else\r
-       va_start(ap);\r
-       root = va_arg(ap, AST *);\r
-#endif\r
-\r
-       if ( root != NULL )\r
-               if ( root->down != NULL ) return NULL;\r
-       child = va_arg(ap, AST *);\r
-       while ( child != NULL )\r
-       {\r
-               for (w=child; w->right!=NULL; w=w->right) {;} /* find end of child */\r
-               if ( sibling == NULL ) {sibling = child; tail = w;}\r
-               else {tail->right = child; tail = w;}\r
-               child = va_arg(ap, AST *);\r
-       }\r
-       if ( root==NULL ) root = sibling;\r
-       else root->down = sibling;\r
-       va_end(ap);\r
-       return root;\r
-}\r
-\r
-/* tree duplicate */\r
-AST *\r
-#ifdef __USE_PROTOS\r
-zzdup_ast(AST *t)\r
-#else\r
-zzdup_ast(t)\r
-AST *t;\r
-#endif\r
-{\r
-       AST *u;\r
-       \r
-       if ( t == NULL ) return NULL;\r
-       u = zzastnew();\r
-       *u = *t;\r
-#ifdef zzAST_DOUBLE\r
-       u->up = NULL;           /* set by calling invocation */\r
-       u->left = NULL;\r
-#endif\r
-       u->right = zzdup_ast(t->right);\r
-       u->down = zzdup_ast(t->down);\r
-#ifdef zzAST_DOUBLE\r
-       if ( u->right!=NULL ) u->right->left = u;\r
-       if ( u->down!=NULL ) u->down->up = u;\r
-#endif\r
-       return u;\r
-}\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-zztfree(AST *t)\r
-#else\r
-zztfree(t)\r
-AST *t;\r
-#endif\r
-{\r
-#ifdef zzd_ast\r
-       zzd_ast( t );\r
-#endif\r
-       free( t );\r
-}\r
-\r
-#ifdef zzAST_DOUBLE\r
-/*\r
- * Set the 'up', and 'left' pointers of all nodes in 't'.\r
- * Initial call is double_link(your_tree, NULL, NULL).\r
- */\r
-void\r
-#ifdef __USE_PROTOS\r
-zzdouble_link(AST *t, AST *left, AST *up)\r
-#else\r
-zzdouble_link(t, left, up)\r
-AST *t, *left, *up;\r
-#endif\r
-{\r
-       if ( t==NULL ) return;\r
-       t->left = left;\r
-       t->up = up;\r
-       zzdouble_link(t->down, NULL, t);\r
-       zzdouble_link(t->right, t, up);\r
-}\r
-#endif\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/h/ast.h b/Tools/CodeTools/TianoTools/Pccts/h/ast.h
deleted file mode 100644 (file)
index 5ff84bd..0000000
+++ /dev/null
@@ -1,121 +0,0 @@
-/* Abstract syntax tree\r
- *\r
- * Macros, definitions\r
- *\r
- * SOFTWARE RIGHTS\r
- *\r
- * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
- * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
- * company may do whatever they wish with source code distributed with\r
- * PCCTS or the code generated by PCCTS, including the incorporation of\r
- * PCCTS, or its output, into commerical software.\r
- *\r
- * We encourage users to develop software with PCCTS.  However, we do ask\r
- * that credit is given to us for developing PCCTS.  By "credit",\r
- * we mean that if you incorporate our source code into one of your\r
- * programs (commercial product, research project, or otherwise) that you\r
- * acknowledge this fact somewhere in the documentation, research report,\r
- * etc...  If you like PCCTS and have developed a nice tool with the\r
- * output, please mention that you developed it using PCCTS.  In\r
- * addition, we ask that this header remain intact in our source code.\r
- * As long as these guidelines are kept, we expect to continue enhancing\r
- * this system and expect to make other tools available as they are\r
- * completed.\r
- *\r
- * ANTLR 1.33\r
- * Terence Parr\r
- * Parr Research Corporation\r
- * with Purdue University and AHPCRC, University of Minnesota\r
- * 1989-2000\r
- */\r
-\r
-#ifndef ZZAST_H\r
-#define ZZAST_H\r
-\r
-#define zzastOvfChk                                                                                                            \\r
-                       if ( zzast_sp <= 0 )                                        \\r
-            {                                                           \\r
-                fprintf(stderr, zzStackOvfMsg, __FILE__, __LINE__);            \\r
-                exit(PCCTS_EXIT_FAILURE);                                               \\r
-            }\r
-\r
-#ifndef USER_DEFINED_AST\r
-#ifndef AST_FIELDS\r
-#define AST_FIELDS\r
-#endif\r
-\r
-typedef struct _ast {\r
-            struct _ast *right, *down;\r
-#ifdef zzAST_DOUBLE\r
-            struct _ast *left, *up;\r
-#endif\r
-            AST_FIELDS\r
-} AST;\r
-\r
-#else\r
-\r
-#ifdef zzAST_DOUBLE\r
-#define AST_REQUIRED_FIELDS   struct _ast *right, *down, *left, *up;\r
-#else\r
-#define AST_REQUIRED_FIELDS   struct _ast *right, *down;\r
-#endif\r
-\r
-#endif\r
-\r
-\r
-/* N o d e  a c c e s s  m a c r o s */\r
-#define zzchild(t)             (((t)==NULL)? (AST *) NULL:(t->down))   /* MR19 */\r
-#define zzsibling(t)   (((t)==NULL)? (AST *) NULL:(t->right))  /* MR19 */\r
-\r
-\r
-/* define global variables needed by #i stack */\r
-#define zzASTgvars                                                                                             \\r
-       AST *zzastStack[ZZAST_STACKSIZE];                                                       \\r
-       int zzast_sp = ZZAST_STACKSIZE;\r
-\r
-#define zzASTVars      AST *_ast = NULL, *_sibling = NULL, *_tail = NULL\r
-#define zzSTR          ( (_tail==NULL)?(&_sibling):(&(_tail->right)) )\r
-#define zzastCur       (zzastStack[zzast_sp])\r
-#define zzastArg(i)    (zzastStack[zztsp-i])\r
-#define zzastPush(p) zzastOvfChk; zzastStack[--zzast_sp] = p;\r
-#define zzastDPush     --zzast_sp\r
-#define zzastMARK      zztsp=zzast_sp;         /* Save state of stack */\r
-#define zzastREL       zzast_sp=zztsp;         /* Return state of stack */\r
-#define zzrm_ast       {zzfree_ast(*_root); _tail = _sibling = (*_root)=NULL;}\r
-\r
-extern int zzast_sp;\r
-extern AST *zzastStack[];\r
-\r
-/* MR26 */\r
-\r
-#ifdef PCCTS_USE_STDARG\r
-AST *zztmake(AST *, ...);\r
-#else\r
-AST *zztmake();\r
-#endif\r
-\r
-#ifdef __USE_PROTOS\r
-void zzlink(AST **, AST **, AST **);\r
-void zzsubchild(AST **, AST **, AST **);\r
-void zzsubroot(AST **, AST **, AST **);\r
-void zzpre_ast(AST *, void (*)(AST *), void (*)(AST *), void (*)(AST *));\r
-void zzfree_ast(AST *);\r
-AST *zzdup_ast(AST *);\r
-void zztfree(AST *);\r
-void zzdouble_link(AST *, AST *, AST *);\r
-AST *zzastnew(void);\r
-\r
-#else\r
-\r
-void zzlink();\r
-AST *zzastnew();\r
-void zzsubchild();\r
-void zzsubroot();\r
-void zzpre_ast();\r
-void zzfree_ast();\r
-AST *zzdup_ast();\r
-void zztfree();\r
-void zzdouble_link();\r
-#endif\r
-\r
-#endif\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/h/charbuf.h b/Tools/CodeTools/TianoTools/Pccts/h/charbuf.h
deleted file mode 100644 (file)
index 5f01c8b..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-/* ANTLR attribute definition -- constant width text\r
- *\r
- * SOFTWARE RIGHTS\r
- *\r
- * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
- * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
- * company may do whatever they wish with source code distributed with\r
- * PCCTS or the code generated by PCCTS, including the incorporation of\r
- * PCCTS, or its output, into commerical software.\r
- *\r
- * We encourage users to develop software with PCCTS.  However, we do ask\r
- * that credit is given to us for developing PCCTS.  By "credit",\r
- * we mean that if you incorporate our source code into one of your\r
- * programs (commercial product, research project, or otherwise) that you\r
- * acknowledge this fact somewhere in the documentation, research report,\r
- * etc...  If you like PCCTS and have developed a nice tool with the\r
- * output, please mention that you developed it using PCCTS.  In\r
- * addition, we ask that this header remain intact in our source code.\r
- * As long as these guidelines are kept, we expect to continue enhancing\r
- * this system and expect to make other tools available as they are\r
- * completed.\r
- *\r
- * ANTLR 1.33\r
- * Terence Parr\r
- * Parr Research Corporation\r
- * with Purdue University and AHPCRC, University of Minnesota\r
- * 1989-2000\r
- */\r
-\r
-#ifndef ZZCHARBUF_H\r
-#define ZZCHARBUF_H\r
-\r
-#include "pcctscfg.h"\r
-\r
-#include "pccts_string.h"\r
-\r
-#ifndef D_TextSize\r
-#define D_TextSize     30\r
-#endif\r
-\r
-typedef struct { char text[D_TextSize]; } Attrib;\r
-\r
-#define zzcr_attr(a,tok,t)     strncpy((a)->text, t, D_TextSize-1); \\r
-                                                       (a)->text[D_TextSize-1] = '\0';\r
-\r
-#endif\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/h/charptr.c b/Tools/CodeTools/TianoTools/Pccts/h/charptr.c
deleted file mode 100644 (file)
index d3f80e6..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-/*\r
- * SOFTWARE RIGHTS\r
- *\r
- * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
- * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
- * company may do whatever they wish with source code distributed with\r
- * PCCTS or the code generated by PCCTS, including the incorporation of\r
- * PCCTS, or its output, into commerical software.\r
- *\r
- * We encourage users to develop software with PCCTS.  However, we do ask\r
- * that credit is given to us for developing PCCTS.  By "credit",\r
- * we mean that if you incorporate our source code into one of your\r
- * programs (commercial product, research project, or otherwise) that you\r
- * acknowledge this fact somewhere in the documentation, research report,\r
- * etc...  If you like PCCTS and have developed a nice tool with the\r
- * output, please mention that you developed it using PCCTS.  In\r
- * addition, we ask that this header remain intact in our source code.\r
- * As long as these guidelines are kept, we expect to continue enhancing\r
- * this system and expect to make other tools available as they are\r
- * completed.\r
- *\r
- * ANTLR 1.33\r
- * Terence Parr\r
- * Parr Research Corporation\r
- * with Purdue University and AHPCRC, University of Minnesota\r
- * 1989-2000\r
- */\r
-\r
-#include "pcctscfg.h"\r
-\r
-#ifdef __STDC__\r
-#include "pccts_stdlib.h"\r
-#else\r
-#include <malloc.h>\r
-#endif\r
-#include "pccts_string.h"\r
-\r
-/* 133MR1 include stdio.h for fprintf in charptr.c */\r
-\r
-#include "pccts_stdio.h"\r
-\r
-/* 133MR1 include charptr.h for Attrib in charptr.c */\r
-\r
-#include "charptr.h"\r
-\r
-#ifdef __USE_PROTOS\r
-zzcr_attr(Attrib *a,int token,char *text)\r
-#else\r
-zzcr_attr(a,token,text)\r
-Attrib *a;\r
-int token;\r
-char *text;\r
-#endif\r
-{\r
-       *a = (char *) malloc(strlen(text)+1);                   /* MR6 */\r
-       if ( *a == NULL ) {fprintf(stderr, "zzcr_attr: out of memory!\n"); exit(-1);}\r
-       strcpy(*a, text);\r
-}\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/h/charptr.h b/Tools/CodeTools/TianoTools/Pccts/h/charptr.h
deleted file mode 100644 (file)
index e73da68..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-/*\r
- *\r
- * SOFTWARE RIGHTS\r
- *\r
- * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
- * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
- * company may do whatever they wish with source code distributed with\r
- * PCCTS or the code generated by PCCTS, including the incorporation of\r
- * PCCTS, or its output, into commerical software.\r
- *\r
- * We encourage users to develop software with PCCTS.  However, we do ask\r
- * that credit is given to us for developing PCCTS.  By "credit",\r
- * we mean that if you incorporate our source code into one of your\r
- * programs (commercial product, research project, or otherwise) that you\r
- * acknowledge this fact somewhere in the documentation, research report,\r
- * etc...  If you like PCCTS and have developed a nice tool with the\r
- * output, please mention that you developed it using PCCTS.  In\r
- * addition, we ask that this header remain intact in our source code.\r
- * As long as these guidelines are kept, we expect to continue enhancing\r
- * this system and expect to make other tools available as they are\r
- * completed.\r
- *\r
- * ANTLR 1.33\r
- * Terence Parr\r
- * Parr Research Corporation\r
- * with Purdue University and AHPCRC, University of Minnesota\r
- * 1989-2000\r
- */\r
-\r
-/*\r
- * WARNING!!!!: charptr.h does NOT make copies and the\r
- * memory is freed after the attribute scope exits.\r
- */\r
-\r
-#ifndef ZZCHARPTR_H\r
-#define ZZCHARPTR_H\r
-\r
-typedef char *Attrib;\r
-#define zzdef0(a)              {*(a)=NULL;}\r
-/* MR8  Jens Tingleff (jensting@imaginet.fr)                                */\r
-/*          Set memory pointer to null after free()                         */\r
-#define zzd_attr(a)            {if ( *(a)!=NULL ) {free(*(a)); *(a)=NULL; }; }\r
-\r
-#ifdef __STDC__\r
-extern zzcr_attr(Attrib *,int,char *);\r
-#endif\r
-\r
-#endif\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/h/config.h b/Tools/CodeTools/TianoTools/Pccts/h/config.h
deleted file mode 100644 (file)
index 8aa50ad..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "pcctscfg.h"\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/h/dlgauto.h b/Tools/CodeTools/TianoTools/Pccts/h/dlgauto.h
deleted file mode 100644 (file)
index db94cef..0000000
+++ /dev/null
@@ -1,504 +0,0 @@
-/* dlgauto.h automaton\r
- *\r
- * SOFTWARE RIGHTS\r
- *\r
- * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
- * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
- * company may do whatever they wish with source code distributed with\r
- * PCCTS or the code generated by PCCTS, including the incorporation of\r
- * PCCTS, or its output, into commerical software.\r
- *\r
- * We encourage users to develop software with PCCTS.  However, we do ask\r
- * that credit is given to us for developing PCCTS.  By "credit",\r
- * we mean that if you incorporate our source code into one of your\r
- * programs (commercial product, research project, or otherwise) that you\r
- * acknowledge this fact somewhere in the documentation, research report,\r
- * etc...  If you like PCCTS and have developed a nice tool with the\r
- * output, please mention that you developed it using PCCTS.  In\r
- * addition, we ask that this header remain intact in our source code.\r
- * As long as these guidelines are kept, we expect to continue enhancing\r
- * this system and expect to make other tools available as they are\r
- * completed.\r
- *\r
- * ANTLR 1.33\r
- * Will Cohen and Terence Parr\r
- * Parr Research Corporation\r
- * with Purdue University and AHPCRC, University of Minnesota\r
- * 1989-2000\r
- */\r
-\r
-#ifndef ZZDEFAUTO_H\r
-#define ZZDEFAUTO_H\r
-\r
-/*  10-Apr-97 133MR1   Uses __USE_PROTOS show should #include pcctscfg.h */\r
-\r
-#include "pcctscfg.h"\r
-\r
-zzchar_t       *zzlextext;     /* text of most recently matched token */\r
-zzchar_t       *zzbegexpr;     /* beginning of last reg expr recogn. */\r
-zzchar_t       *zzendexpr;     /* beginning of last reg expr recogn. */\r
-int    zzbufsize = 0;  /* number of characters in zzlextext */          /* MR7 */\r
-int    zzbegcol = 0;   /* column that first character of token is in*/\r
-int    zzendcol = 0;   /* column that last character of token is in */\r
-int    zzline = 1;     /* line current token is on */\r
-int    zzreal_line=1;  /* line of 1st portion of token that is not skipped */\r
-int    zzchar;         /* character to determine next state */\r
-int    zzbufovf;       /* indicates that buffer too small for text */\r
-int    zzcharfull = 0;\r
-static zzchar_t        *zznextpos;/* points to next available position in zzlextext*/\r
-static int     zzclass;\r
-\r
-#ifdef __USE_PROTOS\r
-void   zzerrstd(const char *);\r
-void   (*zzerr)(const char *)=zzerrstd;/* pointer to error reporting function */\r
-extern int     zzerr_in(void);\r
-static int     (*zzfunc_in)(void) = zzerr_in;  /* MR20 */\r
-#else\r
-void   zzerrstd();\r
-void   (*zzerr)()=zzerrstd;    /* pointer to error reporting function */\r
-extern int     zzerr_in();\r
-static int     (*zzfunc_in)() = zzerr_in;      /* MR20 */\r
-#endif\r
-\r
-static FILE    *zzstream_in=0;\r
-static zzchar_t        *zzstr_in=0;\r
-\r
-#ifdef USER_ZZMODE_STACK\r
-int              zzauto = 0;\r
-#else\r
-static int     zzauto = 0;\r
-#endif\r
-static int     zzadd_erase;\r
-static char    zzebuf[70];\r
-\r
-#ifdef ZZCOL\r
-#define ZZINC (++zzendcol)\r
-#else\r
-#define ZZINC\r
-#endif\r
-\r
-\r
-#define ZZGETC_STREAM {zzchar = getc(zzstream_in); zzclass = ZZSHIFT(zzchar);}\r
-#define ZZGETC_FUNC {zzchar = (*zzfunc_in)(); zzclass = ZZSHIFT(zzchar);}\r
-#define ZZGETC_STR {                   \\r
-       if (*zzstr_in){                         \\r
-               zzchar = *zzstr_in;             \\r
-               ++zzstr_in;                             \\r
-       }else{                                          \\r
-               zzchar = EOF;                   \\r
-       }                                                       \\r
-       zzclass = ZZSHIFT(zzchar);      \\r
-}\r
-\r
-#define ZZNEWSTATE     (newstate = dfa[state][zzclass])\r
-\r
-#ifndef ZZCOPY\r
-#define ZZCOPY \\r
-       /* Truncate matching buffer to size (not an error) */   \\r
-       if (zznextpos < lastpos){                               \\r
-               *(zznextpos++) = zzchar;                        \\r
-       }else{                                                  \\r
-               zzbufovf = 1;                                   \\r
-       }\r
-#endif\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-zzrdstream( FILE *f )\r
-#else\r
-zzrdstream( f )\r
-FILE *f;\r
-#endif\r
-{\r
-       /* make sure that it is really set to something, otherwise just\r
-          leave it be.\r
-       */\r
-       if (f){\r
-               /* make sure that there is always someplace to get input\r
-                  before closing zzstream_in\r
-               */\r
-#if 0\r
-               if (zzstream_in && zzstream_in!=stdin) fclose( zzstream_in );\r
-#endif\r
-               zzline = 1;\r
-               zzstream_in = f;\r
-               zzfunc_in = NULL;\r
-               zzstr_in = 0;\r
-               zzcharfull = 0;\r
-       }\r
-}\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-zzrdfunc( int (*f)(void) )\r
-#else\r
-zzrdfunc( f )\r
-int (*f)();\r
-#endif\r
-{\r
-       /* make sure that it is really set to something, otherwise just\r
-          leave it be.\r
-       */\r
-       if (f){\r
-               /* make sure that there is always someplace to get input\r
-                  before closing zzstream_in\r
-               */\r
-#if 0\r
-               if (zzstream_in && zzstream_in!=stdin) fclose( zzstream_in );\r
-#endif\r
-               zzline = 1;\r
-               zzstream_in = NULL;\r
-               zzfunc_in = f;\r
-               zzstr_in = 0;\r
-               zzcharfull = 0;\r
-       }\r
-}\r
-\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-zzrdstr( zzchar_t *s )\r
-#else\r
-zzrdstr( s )\r
-zzchar_t *s;\r
-#endif\r
-{\r
-       /* make sure that it is really set to something, otherwise just\r
-          leave it be.\r
-       */\r
-       if (s){\r
-               /* make sure that there is always someplace to get input\r
-                  before closing zzstream_in\r
-               */\r
-#if 0\r
-               if (zzstream_in && zzstream_in!=stdin) fclose( zzstream_in );\r
-#endif\r
-               zzline = 1;\r
-               zzstream_in = NULL;\r
-               zzfunc_in = 0;\r
-               zzstr_in = s;\r
-               zzcharfull = 0;\r
-       }\r
-}\r
-\r
-\r
-#ifdef __USE_PROTOS\r
-void zzclose_stream(void)\r
-#else\r
-void zzclose_stream()\r
-#endif\r
-{\r
-#if 0\r
-       fclose( zzstream_in );\r
-       zzstream_in = NULL;\r
-       zzfunc_in = NULL;\r
-#endif\r
-}\r
-\r
-/* saves dlg state, but not what feeds dlg (such as file position) */\r
-void\r
-#ifdef __USE_PROTOS\r
-zzsave_dlg_state(struct zzdlg_state *state)\r
-#else\r
-zzsave_dlg_state(state)\r
-struct zzdlg_state *state;\r
-#endif\r
-{\r
-       state->stream = zzstream_in;\r
-       state->func_ptr = zzfunc_in;\r
-       state->str = zzstr_in;\r
-       state->auto_num = zzauto;\r
-       state->add_erase = zzadd_erase;\r
-       state->lookc = zzchar;\r
-       state->char_full = zzcharfull;\r
-       state->begcol = zzbegcol;\r
-       state->endcol = zzendcol;\r
-       state->line = zzline;\r
-       state->lextext = zzlextext;\r
-       state->begexpr = zzbegexpr;\r
-       state->endexpr = zzendexpr;\r
-       state->bufsize = zzbufsize;\r
-       state->bufovf = zzbufovf;\r
-       state->nextpos = zznextpos;\r
-       state->class_num = zzclass;\r
-}\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-zzrestore_dlg_state(struct zzdlg_state *state)\r
-#else\r
-zzrestore_dlg_state(state)\r
-struct zzdlg_state *state;\r
-#endif\r
-{\r
-       zzstream_in = state->stream;\r
-       zzfunc_in = state->func_ptr;\r
-       zzstr_in = state->str;\r
-       zzauto = state->auto_num;\r
-       zzadd_erase = state->add_erase;\r
-       zzchar = state->lookc;\r
-       zzcharfull = state->char_full;\r
-       zzbegcol = state->begcol;\r
-       zzendcol = state->endcol;\r
-       zzline = state->line;\r
-       zzlextext = state->lextext;\r
-       zzbegexpr = state->begexpr;\r
-       zzendexpr = state->endexpr;\r
-       zzbufsize = state->bufsize;\r
-       zzbufovf = state->bufovf;\r
-       zznextpos = state->nextpos;\r
-       zzclass = state->class_num;\r
-}\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-zzmode( int m )\r
-#else\r
-zzmode( m )\r
-int m;\r
-#endif\r
-{\r
-       /* points to base of dfa table */\r
-       if (m<MAX_MODE){\r
-               zzauto = m;\r
-               /* have to redo class since using different compression */\r
-               zzclass = ZZSHIFT(zzchar);\r
-       }else{\r
-               sprintf(zzebuf,"Invalid automaton mode = %d ",m);\r
-               zzerr(zzebuf);\r
-       }\r
-}\r
-\r
-/* erase what is currently in the buffer, and get a new reg. expr */\r
-\r
-#ifdef __USE_PROTOS\r
-void zzskip(void)\r
-#else\r
-void zzskip()\r
-#endif\r
-{\r
-       zzadd_erase = 1;\r
-}\r
-\r
-/* don't erase what is in the zzlextext buffer, add on to it */\r
-#ifdef __USE_PROTOS\r
-void zzmore()\r
-#else\r
-void zzmore()\r
-#endif\r
-{\r
-       zzadd_erase = 2;\r
-}\r
-\r
-/* substitute c for the reg. expr last matched and is in the buffer */\r
-#ifdef __USE_PROTOS\r
-void\r
-zzreplchar(zzchar_t c)\r
-#else\r
-void\r
-zzreplchar(c)\r
-zzchar_t c;\r
-#endif\r
-{\r
-       /* can't allow overwriting null at end of string */\r
-       if (zzbegexpr < &zzlextext[zzbufsize-1]){\r
-               *zzbegexpr = c;\r
-               *(zzbegexpr+1) = '\0';\r
-       }\r
-       zzendexpr = zzbegexpr;\r
-       if (c != '\0') {\r
-               zznextpos = zzbegexpr + 1;\r
-       }\r
-       else {\r
-               zznextpos = zzbegexpr;  /* MR30 Zero terminates string. */\r
-       }\r
-}\r
-\r
-/* replace the string s for the reg. expr last matched and in the buffer */\r
-void\r
-#ifdef __USE_PROTOS\r
-zzreplstr(register zzchar_t *s)\r
-#else\r
-zzreplstr(s)\r
-register zzchar_t *s;\r
-#endif\r
-{\r
-       register zzchar_t *l= &zzlextext[zzbufsize -1];\r
-\r
-       zznextpos = zzbegexpr;\r
-       if (s){\r
-               while ((zznextpos <= l) && (*(zznextpos++) = *(s++))!=0){\r
-                       /* empty */\r
-               }\r
-               /* correct for NULL at end of string */\r
-               zznextpos--;\r
-       }\r
-       if ((zznextpos <= l) && (*(--s) == 0)){\r
-               zzbufovf = 0;\r
-       }else{\r
-               zzbufovf = 1;\r
-       }\r
-       *(zznextpos) = '\0';\r
-       zzendexpr = zznextpos - 1;\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-void zzgettok(void)\r
-#else\r
-void zzgettok()\r
-#endif\r
-{\r
-       register int state, newstate;\r
-       /* last space reserved for the null char */\r
-       zzchar_t *lastpos;  /* MR27 Remove register since address operator used. */\r
-\r
-skip:\r
-       zzreal_line = zzline;\r
-       zzbufovf = 0;\r
-       lastpos = &zzlextext[zzbufsize-1];\r
-       zznextpos = zzlextext;\r
-       zzbegcol = zzendcol+1;\r
-more:\r
-       zzbegexpr = zznextpos;\r
-#ifdef ZZINTERACTIVE\r
-       /* interactive version of automaton */\r
-       /* if there is something in zzchar, process it */\r
-       state = newstate = dfa_base[zzauto];\r
-       if (zzcharfull){\r
-               ZZINC;\r
-               ZZCOPY;\r
-               ZZNEWSTATE;\r
-       }\r
-       if (zzstr_in)\r
-               while (zzalternatives[newstate]){\r
-                       state = newstate;\r
-                       ZZGETC_STR;\r
-                       ZZINC;\r
-                       ZZCOPY;\r
-                       ZZNEWSTATE;\r
-               }\r
-       else if (zzstream_in)\r
-               while (zzalternatives[newstate]){\r
-                       state = newstate;\r
-                       ZZGETC_STREAM;\r
-                       ZZINC;\r
-                       ZZCOPY;\r
-                       ZZNEWSTATE;\r
-               }\r
-       else if (zzfunc_in)\r
-               while (zzalternatives[newstate]){\r
-                       state = newstate;\r
-                       ZZGETC_FUNC;\r
-                       ZZINC;\r
-                       ZZCOPY;\r
-                       ZZNEWSTATE;\r
-               }\r
-       /* figure out if last character really part of token */\r
-       if ((state != dfa_base[zzauto]) && (newstate == DfaStates)){\r
-               zzcharfull = 1;\r
-               --zznextpos;\r
-       }else{\r
-               zzcharfull = 0;\r
-               state = newstate;\r
-       }\r
-       *(zznextpos) = '\0';\r
-       /* Able to transition out of start state to some non err state?*/\r
-       if ( state == dfa_base[zzauto] ){\r
-               /* make sure doesn't get stuck */\r
-               zzadvance();\r
-       }\r
-#else\r
-       /* non-interactive version of automaton */\r
-       if (!zzcharfull)\r
-               zzadvance();\r
-       else\r
-               ZZINC;\r
-       state = dfa_base[zzauto];\r
-       if (zzstr_in)\r
-               while (ZZNEWSTATE != DfaStates){\r
-                       state = newstate;\r
-                       ZZCOPY;\r
-                       ZZGETC_STR;\r
-                       ZZINC;\r
-               }\r
-       else if (zzstream_in)\r
-               while (ZZNEWSTATE != DfaStates){\r
-                       state = newstate;\r
-                       ZZCOPY;\r
-                       ZZGETC_STREAM;\r
-                       ZZINC;\r
-               }\r
-       else if (zzfunc_in)\r
-               while (ZZNEWSTATE != DfaStates){\r
-                       state = newstate;\r
-                       ZZCOPY;\r
-                       ZZGETC_FUNC;\r
-                       ZZINC;\r
-               }\r
-       zzcharfull = 1;\r
-       if ( state == dfa_base[zzauto] ){\r
-               if (zznextpos < lastpos){\r
-                       *(zznextpos++) = zzchar;\r
-               }else{\r
-                       zzbufovf = 1;\r
-               }\r
-               *zznextpos = '\0';\r
-               /* make sure doesn't get stuck */\r
-               zzadvance();\r
-       }else{\r
-               *zznextpos = '\0';\r
-       }\r
-#endif\r
-#ifdef ZZCOL\r
-       zzendcol -= zzcharfull;\r
-#endif\r
-       zzendexpr = zznextpos -1;\r
-       zzadd_erase = 0;\r
-       (*actions[accepts[state]])();\r
-       switch (zzadd_erase) {\r
-               case 1: goto skip;\r
-               case 2: goto more;\r
-       }\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-void zzadvance(void)\r
-#else\r
-void zzadvance()\r
-#endif\r
-{\r
-       if (zzstream_in) { ZZGETC_STREAM; zzcharfull = 1; ZZINC;}\r
-       if (zzfunc_in) { ZZGETC_FUNC; zzcharfull = 1; ZZINC;}\r
-       if (zzstr_in) { ZZGETC_STR; zzcharfull = 1; ZZINC;}\r
-       if (!(zzstream_in || zzfunc_in || zzstr_in)){\r
-               zzerr_in();\r
-       }\r
-}\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-zzerrstd(const char *s)\r
-#else\r
-zzerrstd(s)\r
-char *s;\r
-#endif\r
-{\r
-        zzLexErrCount++;                /* MR11 */\r
-        fprintf(stderr,\r
-                "%s near line %d (text was '%s')\n",\r
-                ((s == NULL) ? "Lexical error" : s),\r
-                zzline,zzlextext);\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-int zzerr_in(void)\r
-#else\r
-int zzerr_in()\r
-#endif\r
-{\r
-       fprintf(stderr,"No input stream, function, or string\n");\r
-       /* return eof to get out gracefully */\r
-       return EOF;\r
-}\r
-\r
-#endif\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/h/dlgdef.h b/Tools/CodeTools/TianoTools/Pccts/h/dlgdef.h
deleted file mode 100644 (file)
index 733d256..0000000
+++ /dev/null
@@ -1,128 +0,0 @@
-/* dlgdef.h\r
- * Things in scanner produced by dlg that should be visible to the outside\r
- * world\r
- *\r
- * SOFTWARE RIGHTS\r
- *\r
- * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
- * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
- * company may do whatever they wish with source code distributed with\r
- * PCCTS or the code generated by PCCTS, including the incorporation of\r
- * PCCTS, or its output, into commerical software.\r
- *\r
- * We encourage users to develop software with PCCTS.  However, we do ask\r
- * that credit is given to us for developing PCCTS.  By "credit",\r
- * we mean that if you incorporate our source code into one of your\r
- * programs (commercial product, research project, or otherwise) that you\r
- * acknowledge this fact somewhere in the documentation, research report,\r
- * etc...  If you like PCCTS and have developed a nice tool with the\r
- * output, please mention that you developed it using PCCTS.  In\r
- * addition, we ask that this header remain intact in our source code.\r
- * As long as these guidelines are kept, we expect to continue enhancing\r
- * this system and expect to make other tools available as they are\r
- * completed.\r
- *\r
- * ANTLR 1.33\r
- * Terence Parr\r
- * Parr Research Corporation\r
- * with Purdue University and AHPCRC, University of Minnesota\r
- * 1989-2000\r
- */\r
-\r
-#ifndef ZZDLGDEF_H\r
-#define ZZDLGDEF_H\r
-\r
-#include "pcctscfg.h"\r
-\r
-#ifndef zzchar_t\r
-#ifdef ZZWCHAR_T\r
-#define zzchar_t wchar_t\r
-#else\r
-#define zzchar_t char\r
-#endif\r
-#endif\r
-\r
-struct zzdlg_state {\r
-       FILE *stream;\r
-#ifdef __USE_PROTOS\r
-       int (*func_ptr)(void);\r
-#else\r
-       int (*func_ptr)();\r
-#endif\r
-       zzchar_t *str;\r
-       int auto_num;\r
-       int add_erase;\r
-       int lookc;\r
-       int char_full;\r
-       int begcol, endcol;\r
-       int line;\r
-       zzchar_t *lextext, *begexpr, *endexpr;\r
-       int bufsize;\r
-       int bufovf;\r
-       zzchar_t *nextpos;\r
-       int     class_num;\r
-};\r
-\r
-extern zzchar_t        *zzlextext;     /* text of most recently matched token */\r
-extern zzchar_t        *zzbegexpr;     /* beginning of last reg expr recogn. */\r
-extern zzchar_t        *zzendexpr;     /* beginning of last reg expr recogn. */\r
-extern int     zzbufsize;      /* how long zzlextext is */\r
-extern int     zzbegcol;       /* column that first character of token is in*/\r
-extern int     zzendcol;       /* column that last character of token is in */\r
-extern int     zzline;         /* line current token is on */\r
-extern int     zzreal_line;            /* line of 1st portion of token that is not skipped */\r
-extern int     zzchar;         /* character to determine next state */\r
-extern int     zzbufovf;       /* indicates that buffer too small for text */\r
-#ifdef __USE_PROTOS\r
-extern void    (*zzerr)(const char *);/* pointer to error reporting function */\r
-#else\r
-extern void    (*zzerr)();\r
-#endif\r
-\r
-#ifdef USER_ZZMODE_STACK\r
-extern int     zzauto;\r
-#endif\r
-\r
-#ifdef __USE_PROTOS\r
-extern void    zzadvance(void);\r
-extern void    zzskip(void);   /* erase zzlextext, look for antoher token */\r
-extern void    zzmore(void);   /* keep zzlextext, look for another token */\r
-extern void    zzmode(int k);  /* switch to automaton 'k' */\r
-extern void    zzrdstream(FILE *);/* what stream to read from */\r
-extern void    zzclose_stream(void);/* close the current input stream */\r
-extern void    zzrdfunc(int (*)(void));/* what function to get char from */\r
-extern void zzrdstr( zzchar_t * );\r
-extern void    zzgettok(void); /* get next token */\r
-extern void    zzreplchar(zzchar_t c);/* replace last recognized reg. expr. with\r
-                                       a character */\r
-extern void    zzreplstr(zzchar_t *s);/* replace last recognized reg. expr. with\r
-                                       a string */\r
-extern void zzsave_dlg_state(struct zzdlg_state *);\r
-extern void zzrestore_dlg_state(struct zzdlg_state *);\r
-extern int zzerr_in(void);\r
-extern void    zzerrstd(const char *);\r
-extern void zzerraction(void);\r
-\r
-#else\r
-\r
-extern void    zzadvance();\r
-extern void    zzskip();       /* erase zzlextext, look for antoher token */\r
-extern void    zzmore();       /* keep zzlextext, look for another token */\r
-extern void    zzmode(/*k*/);  /* switch to automaton 'k' */\r
-extern void    zzrdstream();   /* what stream to read from */\r
-extern void    zzclose_stream();/* close the current input stream */\r
-extern void    zzrdfunc();     /* what function to get char from */\r
-extern void zzrdstr();\r
-extern void    zzgettok();     /* get next token */\r
-extern void    zzreplchar();   /* replace last recognized reg. expr. with\r
-                                       a character */\r
-extern void    zzreplstr();    /* replace last recognized reg. expr. with\r
-                                       a string */\r
-extern void zzsave_dlg_state();\r
-extern void zzrestore_dlg_state();\r
-extern int zzerr_in();\r
-extern void    zzerrstd();\r
-extern void zzerraction();\r
-#endif\r
-\r
-#endif\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/h/err.h b/Tools/CodeTools/TianoTools/Pccts/h/err.h
deleted file mode 100644 (file)
index b2b196b..0000000
+++ /dev/null
@@ -1,1170 +0,0 @@
-/*\r
- * err.h\r
- *\r
- * Standard error handling mechanism\r
- *\r
- * SOFTWARE RIGHTS\r
- *\r
- * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
- * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
- * company may do whatever they wish with source code distributed with\r
- * PCCTS or the code generated by PCCTS, including the incorporation of\r
- * PCCTS, or its output, into commerical software.\r
- *\r
- * We encourage users to develop software with PCCTS.  However, we do ask\r
- * that credit is given to us for developing PCCTS.  By "credit",\r
- * we mean that if you incorporate our source code into one of your\r
- * programs (commercial product, research project, or otherwise) that you\r
- * acknowledge this fact somewhere in the documentation, research report,\r
- * etc...  If you like PCCTS and have developed a nice tool with the\r
- * output, please mention that you developed it using PCCTS.  In\r
- * addition, we ask that this header remain intact in our source code.\r
- * As long as these guidelines are kept, we expect to continue enhancing\r
- * this system and expect to make other tools available as they are\r
- * completed.\r
- *\r
- * Has grown to hold all kinds of stuff (err.h is increasingly misnamed)\r
- *\r
- * ANTLR 1.33\r
- * Terence Parr\r
- * Parr Research Corporation\r
- * with Purdue University and AHPCRC, University of Minnesota\r
- * 1989-2000\r
- */\r
-\r
-#ifndef ERR_H\r
-#define ERR_H\r
-\r
-#include "pcctscfg.h"\r
-#include <stdlib.h>\r
-#include <assert.h>\r
-\r
-/*                                                                           */\r
-/*  7-Apr-97  133MR1                                                         */\r
-/*             Proper choice of STDC and cplusplus pre-processor symbols (?) */\r
-/*                                                                           */\r
-#include "pccts_string.h"\r
-\r
-#ifdef PCCTS_USE_STDARG\r
-#include "pccts_stdarg.h"\r
-#else\r
-#include <varargs.h>\r
-#endif\r
-\r
-#ifdef DUM\r
-/* Define usable bits per unsigned int word (used for set stuff) */\r
-#ifdef PC\r
-#define BSETWORDSIZE 16\r
-#define BSETLOGWORDSIZE        4\r
-#else\r
-#define        BSETWORDSIZE 32\r
-#define BSETLOGWORDSIZE 5\r
-#endif\r
-#endif\r
-\r
-#define        BSETWORDSIZE 8\r
-#define BSETLOGWORDSIZE 3              /* SetWordType is 8bits */\r
-\r
-#define        BSETMODWORD(x) ((x) & (BSETWORDSIZE-1))         /* x % BSETWORDSIZE */\r
-#define        BSETDIVWORD(x) ((x) >> BSETLOGWORDSIZE)         /* x / BSETWORDSIZE */\r
-\r
-/* This is not put into the global pccts_parser structure because it is\r
- * hidden and does not need to be saved during a "save state" operation\r
- */\r
-/* maximum of 32 bits/unsigned int and must be 8 bits/byte */\r
-static SetWordType bitmask[] = {\r
-       0x00000001, 0x00000002, 0x00000004, 0x00000008,\r
-       0x00000010, 0x00000020, 0x00000040, 0x00000080\r
-};\r
-\r
-#ifdef zzTRACE_RULES\r
-int  zzTraceOptionValueDefault=1;\r
-int  zzTraceOptionValue=1;\r
-int  zzTraceGuessOptionValue=1;\r
-char *zzTraceCurrentRuleName=NULL;\r
-int  zzTraceDepth=0;\r
-#endif\r
-\r
-int  zzGuessSeq=0;          /* MR10 */\r
-int  zzSyntaxErrCount=0;    /* MR11 */\r
-int  zzLexErrCount=0;       /* MR11 */\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-zzresynch(SetWordType *wd,SetWordType mask)\r
-#else\r
-zzresynch(wd,mask)\r
-SetWordType *wd, mask;\r
-#endif\r
-{\r
-       static int consumed = 1;\r
-\r
-       /* if you enter here without having consumed a token from last resynch\r
-        * force a token consumption.\r
-        */\r
-       if ( !consumed ) {zzCONSUME; consumed=1; return;}   /* MR10 */\r
-\r
-       /* if current token is in resynch set, we've got what we wanted */\r
-       if ( wd[LA(1)]&mask || LA(1) == zzEOF_TOKEN ) {consumed=0; return;}\r
-       \r
-       /* scan until we find something in the resynch set */\r
-       while ( !(wd[LA(1)]&mask) && LA(1) != zzEOF_TOKEN ) {zzCONSUME;}\r
-       consumed=1;\r
-}\r
-\r
-/*                                                                          */\r
-/*  7-Apr-97 133MR1 for C++ and MR7 for C                                   */\r
-/*          Change suggested by Eli Sternheim (eli@interhdl.com)           */\r
-/*                                                                          */\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-zzconsumeUntil(SetWordType *st)\r
-#else\r
-zzconsumeUntil(st)\r
-SetWordType *st;\r
-#endif\r
-{\r
-    int     tmp;                                                     /* MR7 */\r
-       while ( !zzset_el( (tmp=LA(1)), st) && tmp!=1 /* Eof */) {       /* MR7 */\r
-                                                      zzCONSUME; }   /* MR7 */\r
-}\r
-\r
-/*                                                                          */\r
-/*  7-Apr-97 133MR1 for C++ and MR7 for C                                   */\r
-/*          Change suggested by Eli Sternheim (eli@interhdl.com)           */\r
-/*                                                                          */\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-zzconsumeUntilToken(int t)\r
-#else\r
-zzconsumeUntilToken(t)\r
-int t;\r
-#endif\r
-{\r
-    int     tmp;                                                     /* MR7 */\r
-       while ( (tmp=LA(1)) !=t && tmp!=1 /* Eof */) { zzCONSUME; }      /* MR7 */\r
-}\r
-\r
-/* input looks like:\r
- *             zzFAIL(k, e1, e2, ...,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText)\r
- * where the zzMiss stuff is set here to the token that did not match\r
- * (and which set wasn't it a member of).\r
- */\r
-\r
-#ifdef PCCTS_USE_STDARG\r
-void zzFAIL(int k, ...)\r
-#else\r
-void zzFAIL(va_alist)\r
-va_dcl\r
-#endif\r
-{\r
-#ifdef LL_K\r
-       static char text[LL_K*ZZLEXBUFSIZE+1];\r
-       SetWordType *f[LL_K];\r
-#else\r
-       static char text[ZZLEXBUFSIZE+1];\r
-       SetWordType *f[1];\r
-#endif\r
-       SetWordType **miss_set;\r
-       char **miss_text;\r
-       int *bad_tok;\r
-       char **bad_text;\r
-       int *err_k;\r
-       int i;\r
-       va_list ap;\r
-#ifndef PCCTS_USE_STDARG                       /* MR20 */\r
-       int k;\r
-#endif\r
-#ifdef PCCTS_USE_STDARG         /* MR20 */\r
-       va_start(ap, k);\r
-#else\r
-       va_start(ap);\r
-       k = va_arg(ap, int);    /* how many lookahead sets? */\r
-#endif\r
-    assert(k <= sizeof(f)/sizeof(f[0]));    /* MR20 G. Hobbelt */\r
-       text[0] = '\0';\r
-       for (i=1; i<=k; i++)    /* collect all lookahead sets */\r
-       {\r
-               f[i-1] = va_arg(ap, SetWordType *);\r
-       }\r
-       for (i=1; i<=k; i++)    /* look for offending token */\r
-       {\r
-               if ( i>1 ) strcat(text, " ");\r
-               strcat(text, LATEXT(i));\r
-               if ( !zzset_el((unsigned)LA(i), f[i-1]) ) break;\r
-       }\r
-       miss_set = va_arg(ap, SetWordType **);\r
-       miss_text = va_arg(ap, char **);\r
-       bad_tok = va_arg(ap, int *);\r
-       bad_text = va_arg(ap, char **);\r
-       err_k = va_arg(ap, int *);\r
-       if ( i>k )\r
-       {\r
-               /* bad; lookahead is permutation that cannot be matched,\r
-                * but, the ith token of lookahead is valid at the ith position\r
-                * (The old LL sub 1 (k) versus LL(k) parsing technique)\r
-                */\r
-               *miss_set = NULL;\r
-               *miss_text = zzlextext;\r
-               *bad_tok = LA(1);\r
-               *bad_text = LATEXT(1);\r
-               *err_k = k;\r
-               return;\r
-       }\r
-/*     fprintf(stderr, "%s not in %dth set\n", zztokens[LA(i)], i);*/\r
-       *miss_set = f[i-1];\r
-       *miss_text = text;\r
-       *bad_tok = LA(i);\r
-       *bad_text = LATEXT(i);\r
-       if ( i==1 ) *err_k = 1;\r
-       else *err_k = k;\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-void zzTraceGuessDone(zzantlr_state *state)\r
-#else\r
-void zzTraceGuessDone(state)\r
-  zzantlr_state     *state;\r
-#endif\r
-{\r
-#ifdef zzTRACE_RULES\r
-#ifdef ZZCAN_GUESS\r
-\r
-  int   doIt=0;\r
-\r
-  if (zzTraceCurrentRuleName == NULL) return;\r
-\r
-  if (zzTraceOptionValue <= 0) {\r
-    doIt=0;\r
-  } else if (zzTraceGuessOptionValue <= 0) {\r
-    doIt=0;\r
-  } else {\r
-    doIt=1;\r
-  };\r
-\r
-  if (doIt) {\r
-    fprintf(stderr,"guess done - returning to rule %s {\"%s\"} at depth %d",\r
-        state->traceCurrentRuleName,\r
-        LATEXT(1),\r
-        state->traceDepth);\r
-    if (state->guessing != 0) {\r
-      fprintf(stderr," (guess mode continues - an enclosing guess is still active)");\r
-    } else {\r
-      fprintf(stderr," (guess mode ends)");\r
-    };\r
-    fprintf(stderr,"\n");\r
-  };\r
-#endif\r
-#endif\r
-}\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-zzsave_antlr_state(zzantlr_state *buf)\r
-#else\r
-zzsave_antlr_state(buf)\r
-zzantlr_state *buf;\r
-#endif\r
-{\r
-#ifdef LL_K\r
-       int     i;\r
-#endif\r
-\r
-#ifdef ZZCAN_GUESS\r
-       buf->guess_start = zzguess_start;\r
-       buf->guessing = zzguessing;\r
-#endif\r
-       buf->asp = zzasp;\r
-#ifdef GENAST\r
-       buf->ast_sp = zzast_sp;\r
-#endif\r
-#ifdef ZZINF_LOOK\r
-       buf->inf_labase = zzinf_labase;\r
-       buf->inf_last = zzinf_last;\r
-\r
-/* MR6         Gunnar Rxnning (gunnar@candleweb.no)                                */\r
-/* MR6   Additional state needs to be saved/restored                       */\r
-\r
-       buf->inf_tokens = zzinf_tokens;                                  /* MR6 */\r
-       buf->inf_text = zzinf_text;                                      /* MR6 */\r
-       buf->inf_text_buffer = zzinf_text_buffer;                        /* MR6 */\r
-       buf->inf_line = zzinf_line;                                                  /* MR6 */\r
-\r
-#endif\r
-#ifdef DEMAND_LOOK\r
-       buf->dirty = zzdirty;\r
-#endif\r
-#ifdef LL_K\r
-       for (i=0; i<LL_K; i++) buf->tokenLA[i] = zztokenLA[i];\r
-       for (i=0; i<LL_K; i++) strcpy(buf->textLA[i], zztextLA[i]);\r
-       buf->lap = zzlap;\r
-       buf->labase = zzlabase;\r
-#else\r
-       buf->token = zztoken;\r
-       strcpy(buf->text, zzlextext);\r
-#endif\r
-#ifdef zzTRACE_RULES\r
-\r
-    /* MR10 */\r
-\r
-    buf->traceOptionValue=zzTraceOptionValue;\r
-    buf->traceGuessOptionValue=zzTraceGuessOptionValue;\r
-    buf->traceCurrentRuleName=zzTraceCurrentRuleName;\r
-    buf->traceDepth=zzTraceDepth;\r
-#endif\r
-}\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-zzrestore_antlr_state(zzantlr_state *buf)\r
-#else\r
-zzrestore_antlr_state(buf)\r
-zzantlr_state *buf;\r
-#endif\r
-{\r
-\r
-#ifdef zzTRACE_RULES\r
-    int     prevTraceOptionValue;\r
-#endif\r
-\r
-#ifdef LL_K\r
-       int     i;\r
-#endif\r
-\r
-#ifdef ZZCAN_GUESS\r
-       zzguess_start = buf->guess_start;\r
-       zzguessing = buf->guessing;\r
-#endif\r
-       zzasp = buf->asp;\r
-#ifdef GENAST\r
-       zzast_sp = buf->ast_sp;\r
-#endif\r
-#ifdef ZZINF_LOOK\r
-       zzinf_labase = buf->inf_labase;\r
-       zzinf_last = buf->inf_last;\r
-\r
-/* MR6         Gunnar Rxnning (gunnar@candleweb.no)                                */\r
-/* MR6   Additional state needs to be saved/restored                       */\r
-\r
-       zzinf_tokens = buf->inf_tokens;                                  /* MR6 */\r
-       zzinf_text = buf->inf_text;                                      /* MR6 */\r
-       zzinf_text_buffer = buf->inf_text_buffer;                        /* MR6 */\r
-       zzinf_line = buf->inf_line;                                                  /* MR6 */\r
-#endif\r
-#ifdef DEMAND_LOOK\r
-       zzdirty = buf->dirty;\r
-#endif\r
-#ifdef LL_K\r
-       for (i=0; i<LL_K; i++) zztokenLA[i] = buf->tokenLA[i];\r
-       for (i=0; i<LL_K; i++) strcpy(zztextLA[i], buf->textLA[i]);\r
-       zzlap = buf->lap;\r
-       zzlabase = buf->labase;\r
-#else\r
-       zztoken = buf->token;\r
-       strcpy(zzlextext, buf->text);\r
-#endif\r
-#ifdef zzTRACE_RULES\r
-\r
-    prevTraceOptionValue=zzTraceOptionValue;\r
-    zzTraceOptionValue=buf->traceOptionValue;\r
-    if ( (prevTraceOptionValue > 0) !=\r
-             (zzTraceOptionValue > 0)) {\r
-      if (zzTraceOptionValue > 0) {\r
-        fprintf(stderr,"trace enable restored in rule %s depth %d\n",\r
-                        zzTraceCurrentRuleName,zzTraceDepth);\r
-      };\r
-      if (zzTraceOptionValue <= 0) {\r
-        fprintf(stderr,"trace disable restored in rule %s depth %d\n",\r
-                        zzTraceCurrentRuleName,zzTraceDepth);\r
-      };\r
-    };\r
-\r
-    zzTraceOptionValue=buf->traceOptionValue;            /* MR10 */\r
-    zzTraceGuessOptionValue=buf->traceGuessOptionValue;  /* MR10 */\r
-    zzTraceCurrentRuleName=buf->traceCurrentRuleName;    /* MR10 */\r
-    zzTraceDepth=buf->traceDepth;                        /* MR10 */\r
-    zzTraceGuessDone(buf);                               /* MR10 */\r
-#endif\r
-}\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-zzedecode(SetWordType *a)\r
-#else\r
-zzedecode(a)\r
-SetWordType *a;\r
-#endif\r
-{\r
-       register SetWordType *p = a;\r
-       register SetWordType *endp = &(p[zzSET_SIZE]);\r
-       register unsigned e = 0;\r
-\r
-       if ( zzset_deg(a)>1 ) fprintf(stderr, " {");\r
-       do {\r
-               register SetWordType t = *p;\r
-               register SetWordType *b = &(bitmask[0]);\r
-               do {\r
-                       if ( t & *b ) fprintf(stderr, " %s", zztokens[e]);\r
-                       e++;\r
-               } while (++b < &(bitmask[sizeof(SetWordType)*8]));\r
-       } while (++p < endp);\r
-       if ( zzset_deg(a)>1 ) fprintf(stderr, " }");\r
-}\r
-\r
-#ifndef USER_ZZSYN\r
-/* standard error reporting function */\r
-void\r
-#ifdef __USE_PROTOS\r
-zzsyn(char *text, int tok, char *egroup, SetWordType *eset, int etok, int k, char *bad_text)\r
-#else\r
-zzsyn(text, tok, egroup, eset, etok, k, bad_text)\r
-char *text, *egroup, *bad_text;\r
-int tok;\r
-int etok;\r
-int k;\r
-SetWordType *eset;\r
-#endif\r
-{\r
-       \r
-    zzSyntaxErrCount++;                             /* MR11 */\r
-       fprintf(stderr, "line %d: syntax error at \"%s\"", zzline, (tok==zzEOF_TOKEN)?"EOF":bad_text);\r
-       if ( !etok && !eset ) {fprintf(stderr, "\n"); return;}\r
-       if ( k==1 ) fprintf(stderr, " missing");\r
-       else\r
-       {\r
-               fprintf(stderr, "; \"%s\" not", bad_text);\r
-               if ( zzset_deg(eset)>1 ) fprintf(stderr, " in");\r
-       }\r
-       if ( zzset_deg(eset)>0 ) zzedecode(eset);\r
-       else fprintf(stderr, " %s", zztokens[etok]);\r
-       if ( strlen(egroup) > 0 ) fprintf(stderr, " in %s", egroup);\r
-       fprintf(stderr, "\n");\r
-}\r
-#endif\r
-\r
-/* is b an element of set p? */\r
-int\r
-#ifdef __USE_PROTOS\r
-zzset_el(unsigned b, SetWordType *p)\r
-#else\r
-zzset_el(b,p)\r
-unsigned b;\r
-SetWordType *p;\r
-#endif\r
-{\r
-       return( p[BSETDIVWORD(b)] & bitmask[BSETMODWORD(b)] );\r
-}\r
-\r
-int\r
-#ifdef __USE_PROTOS\r
-zzset_deg(SetWordType *a)\r
-#else\r
-zzset_deg(a)\r
-SetWordType *a;\r
-#endif\r
-{\r
-       /* Fast compute degree of a set... the number\r
-          of elements present in the set.  Assumes\r
-          that all word bits are used in the set\r
-       */\r
-       register SetWordType *p = a;\r
-       register SetWordType *endp = &(a[zzSET_SIZE]);\r
-       register int degree = 0;\r
-\r
-       if ( a == NULL ) return 0;\r
-       while ( p < endp )\r
-       {\r
-               register SetWordType t = *p;\r
-               register SetWordType *b = &(bitmask[0]);\r
-               do {\r
-                       if (t & *b) ++degree;\r
-               } while (++b < &(bitmask[sizeof(SetWordType)*8]));\r
-               p++;\r
-       }\r
-\r
-       return(degree);\r
-}\r
-\r
-#ifdef DEMAND_LOOK\r
-\r
-#ifdef LL_K\r
-int\r
-#ifdef __USE_PROTOS\r
-_zzmatch(int _t, char **zzBadText, char **zzMissText,\r
-               int *zzMissTok, int *zzBadTok,\r
-               SetWordType **zzMissSet)\r
-#else\r
-_zzmatch(_t, zzBadText, zzMissText, zzMissTok, zzBadTok, zzMissSet)\r
-int _t;\r
-char **zzBadText;\r
-char **zzMissText;\r
-int *zzMissTok, *zzBadTok;\r
-SetWordType **zzMissSet;\r
-#endif\r
-{\r
-       if ( zzdirty==LL_K ) {\r
-               zzCONSUME;\r
-       }\r
-       if ( LA(1)!=_t ) {\r
-               *zzBadText = *zzMissText=LATEXT(1);     \r
-               *zzMissTok= _t; *zzBadTok=LA(1);\r
-               *zzMissSet=NULL;                                \r
-               return 0;\r
-       }\r
-       zzMakeAttr                                              \r
-       zzdirty++;                                              \r
-       zzlabase++;                                             \r
-       return 1;\r
-}\r
-\r
-int\r
-#ifdef __USE_PROTOS\r
-_zzmatch_wsig(int _t)\r
-#else\r
-_zzmatch_wsig(_t)\r
-int _t;\r
-#endif\r
-{\r
-       if ( zzdirty==LL_K ) {\r
-               zzCONSUME;\r
-       }\r
-       if ( LA(1)!=_t ) {\r
-               return 0;\r
-       }\r
-       zzMakeAttr                                              \r
-       zzdirty++;                                              \r
-       zzlabase++;                                             \r
-       return 1;\r
-}\r
-\r
-#else\r
-\r
-int\r
-#ifdef __USE_PROTOS\r
-_zzmatch(int _t, char **zzBadText, char **zzMissText,\r
-                int *zzMissTok, int *zzBadTok, SetWordType **zzMissSet)\r
-#else\r
-_zzmatch(_t, zzBadText, zzMissText, zzMissTok, zzBadTok, zzMissSet)\r
-int _t;\r
-char **zzBadText;\r
-char **zzMissText;\r
-int *zzMissTok, *zzBadTok;\r
-SetWordType **zzMissSet;\r
-#endif\r
-{                                                              \r
-       if ( zzdirty ) {zzCONSUME;}             \r
-       if ( LA(1)!=_t ) {\r
-               *zzBadText = *zzMissText=LATEXT(1);     \r
-               *zzMissTok= _t; *zzBadTok=LA(1);\r
-               *zzMissSet=NULL;                                \r
-               return 0;\r
-       }                                                               \r
-       zzdirty = 1;                                    \r
-       zzMakeAttr                                              \r
-       return 1;\r
-}\r
-\r
-int\r
-#ifdef __USE_PROTOS\r
-_zzmatch_wsig(int _t)\r
-#else\r
-_zzmatch_wsig(_t)\r
-int _t;\r
-#endif\r
-{\r
-       if ( zzdirty ) {zzCONSUME;}             \r
-       if ( LA(1)!=_t ) {\r
-               return 0;\r
-       }\r
-       zzdirty = 1;                                    \r
-       zzMakeAttr                                              \r
-       return 1;\r
-}\r
-\r
-#endif /*LL_K*/\r
-\r
-#else\r
-\r
-int\r
-#ifdef __USE_PROTOS\r
-_zzmatch(int _t, char **zzBadText, char **zzMissText,\r
-               int *zzMissTok, int *zzBadTok,\r
-               SetWordType **zzMissSet)\r
-#else\r
-_zzmatch(_t, zzBadText, zzMissText, zzMissTok, zzBadTok, zzMissSet)\r
-int _t;\r
-char **zzBadText;\r
-char **zzMissText;\r
-int *zzMissTok, *zzBadTok;\r
-SetWordType **zzMissSet;\r
-#endif\r
-{\r
-       if ( LA(1)!=_t ) {                              \r
-               *zzBadText = *zzMissText=LATEXT(1);     \r
-               *zzMissTok= _t; *zzBadTok=LA(1);\r
-               *zzMissSet=NULL;                                \r
-               return 0;\r
-       }\r
-       zzMakeAttr\r
-       return 1;\r
-}\r
-\r
-int\r
-#ifdef __USE_PROTOS\r
-_zzmatch_wsig(int _t)\r
-#else\r
-_zzmatch_wsig(_t)\r
-int _t;\r
-#endif\r
-{\r
-       if ( LA(1)!=_t ) return 0;\r
-       zzMakeAttr                                              \r
-       return 1;\r
-}\r
-\r
-#endif /*DEMAND_LOOK*/\r
-\r
-#ifdef ZZINF_LOOK\r
-void\r
-#ifdef __USE_PROTOS\r
-_inf_zzgettok(void)\r
-#else\r
-_inf_zzgettok()\r
-#endif\r
-{\r
-       if ( zzinf_labase >= zzinf_last )                                       \r
-               {NLA = zzEOF_TOKEN; strcpy(NLATEXT, "");}       \r
-       else {                                                                                  \r
-               NLA = zzinf_tokens[zzinf_labase];\r
-               zzline = zzinf_line[zzinf_labase];      /* wrong in 1.21 */\r
-               strcpy(NLATEXT, zzinf_text[zzinf_labase]);              \r
-               zzinf_labase++;                                                                 \r
-       }                                                                                               \r
-}\r
-#endif\r
-\r
-#ifdef ZZINF_LOOK\r
-/* allocate default size text,token and line arrays;\r
- * then, read all of the input reallocing the arrays as needed.\r
- * Once the number of total tokens is known, the LATEXT(i) array (zzinf_text)\r
- * is allocated and it's pointers are set to the tokens in zzinf_text_buffer.\r
- */\r
-void\r
-#ifdef __USE_PROTOS\r
-zzfill_inf_look(void)\r
-#else\r
-zzfill_inf_look()\r
-#endif\r
-{\r
-       int tok, line;\r
-       int zzinf_token_buffer_size = ZZINF_DEF_TOKEN_BUFFER_SIZE;\r
-       int zzinf_text_buffer_size = ZZINF_DEF_TEXT_BUFFER_SIZE;\r
-       int zzinf_text_buffer_index = 0;\r
-       int zzinf_lap = 0;\r
-\r
-       /* allocate text/token buffers */\r
-       zzinf_text_buffer = (char *) malloc(zzinf_text_buffer_size);\r
-       if ( zzinf_text_buffer == NULL )\r
-       {\r
-               fprintf(stderr, "cannot allocate lookahead text buffer (%d bytes)\n",\r
-               zzinf_text_buffer_size);\r
-               exit(PCCTS_EXIT_FAILURE);                                                                       \r
-       }\r
-       zzinf_tokens = (int *) calloc(zzinf_token_buffer_size,sizeof(int));\r
-       if ( zzinf_tokens == NULL )\r
-       {\r
-               fprintf(stderr, "cannot allocate token buffer (%d tokens)\n",\r
-                               zzinf_token_buffer_size);\r
-               exit(PCCTS_EXIT_FAILURE);                                                                       \r
-       }\r
-    zzinf_line = (int *) calloc(zzinf_token_buffer_size,sizeof(int));\r
-    if ( zzinf_line == NULL )\r
-    {\r
-        fprintf(stderr, "cannot allocate line buffer (%d ints)\n",\r
-                zzinf_token_buffer_size);\r
-        exit(PCCTS_EXIT_FAILURE);\r
-       }\r
-\r
-       /* get tokens, copying text to text buffer */\r
-       zzinf_text_buffer_index = 0;\r
-       do {\r
-               zzgettok();\r
-               line = zzreal_line;\r
-               while ( zzinf_lap>=zzinf_token_buffer_size )\r
-               {\r
-                       zzinf_token_buffer_size += ZZINF_BUFFER_TOKEN_CHUNK_SIZE;\r
-                       zzinf_tokens = (int *) realloc(zzinf_tokens,\r
-                                                                                                zzinf_token_buffer_size*sizeof(int));\r
-                       if ( zzinf_tokens == NULL )\r
-                       {\r
-                               fprintf(stderr, "cannot allocate lookahead token buffer (%d tokens)\n",\r
-                                               zzinf_token_buffer_size);\r
-                               exit(PCCTS_EXIT_FAILURE);\r
-                       }\r
-            zzinf_line = (int *) realloc(zzinf_line,\r
-                                         zzinf_token_buffer_size*sizeof(int));\r
-            if ( zzinf_line == NULL )\r
-            {\r
-                fprintf(stderr, "cannot allocate lookahead line buffer (%d ints)\n",\r
-                        zzinf_token_buffer_size);\r
-                exit(PCCTS_EXIT_FAILURE);\r
-                       }\r
-\r
-               }\r
-               while ( (zzinf_text_buffer_index+strlen(NLATEXT)+1) >= zzinf_text_buffer_size )\r
-               {\r
-                       zzinf_text_buffer_size += ZZINF_BUFFER_TEXT_CHUNK_SIZE;\r
-                       zzinf_text_buffer = (char *) realloc(zzinf_text_buffer,\r
-                                                                                                zzinf_text_buffer_size);\r
-                       if ( zzinf_text_buffer == NULL )\r
-                       {\r
-                               fprintf(stderr, "cannot allocate lookahead text buffer (%d bytes)\n",\r
-                                               zzinf_text_buffer_size);\r
-                               exit(PCCTS_EXIT_FAILURE);\r
-                       }\r
-               }\r
-               /* record token and text and line of input symbol */\r
-               tok = zzinf_tokens[zzinf_lap] = NLA;\r
-               strcpy(&zzinf_text_buffer[zzinf_text_buffer_index], NLATEXT);\r
-               zzinf_text_buffer_index += strlen(NLATEXT)+1;\r
-        zzinf_line[zzinf_lap] = line;\r
-               zzinf_lap++;\r
-       } while (tok!=zzEOF_TOKEN);\r
-       zzinf_labase = 0;\r
-       zzinf_last = zzinf_lap-1;\r
-\r
-       /* allocate ptrs to text of ith token */\r
-       zzinf_text = (char **) calloc(zzinf_last+1,sizeof(char *));\r
-       if ( zzinf_text == NULL )\r
-       {\r
-               fprintf(stderr, "cannot allocate lookahead text buffer (%d)\n",\r
-                               zzinf_text_buffer_size);\r
-               exit(PCCTS_EXIT_FAILURE);                                                                               \r
-       }                                                                                                       \r
-       zzinf_text_buffer_index = 0;\r
-       zzinf_lap = 0;\r
-       /* set ptrs so that zzinf_text[i] is the text of the ith token found on input */\r
-       while (zzinf_lap<=zzinf_last)\r
-       {\r
-           zzinf_text[zzinf_lap++] = &zzinf_text_buffer[zzinf_text_buffer_index];\r
-               zzinf_text_buffer_index += strlen(&zzinf_text_buffer[zzinf_text_buffer_index])+1;\r
-       }\r
-}\r
-#endif\r
-\r
-int\r
-#ifdef __USE_PROTOS\r
-_zzsetmatch(SetWordType *e, char **zzBadText, char **zzMissText,\r
-                       int *zzMissTok, int *zzBadTok,\r
-                       SetWordType **zzMissSet,\r
-                       SetWordType *zzTokclassErrset /* MR23 */)\r
-#else\r
-_zzsetmatch(e, zzBadText, zzMissText, zzMissTok, zzBadTok, zzMissSet, zzTokclassErrset /* MR23 */)\r
-SetWordType *e;\r
-char **zzBadText;\r
-char **zzMissText;\r
-int *zzMissTok, *zzBadTok;\r
-SetWordType **zzMissSet;\r
-SetWordType *zzTokclassErrset;\r
-#endif\r
-{\r
-#ifdef DEMAND_LOOK\r
-#ifdef LL_K\r
-       if ( zzdirty==LL_K ) {zzCONSUME;}\r
-#else\r
-       if ( zzdirty ) {zzCONSUME;}\r
-#endif\r
-#endif\r
-       if ( !zzset_el((unsigned)LA(1), e) ) {\r
-               *zzBadText = LATEXT(1); *zzMissText=NULL;\r
-               *zzMissTok= 0; *zzBadTok=LA(1);\r
-               *zzMissSet=zzTokclassErrset; /* MR23 */\r
-               return 0;\r
-       }\r
-       zzMakeAttr           /* MR14 Ger Hobbelt (hobbelt@axa.nl) */\r
-#ifdef DEMAND_LOOK\r
-#ifdef LL_K\r
-       zzdirty++;\r
-    zzlabase++;          /* MR14 Ger Hobbelt (hobbelt@axa.nl) */\r
-#else\r
-       zzdirty = 1;\r
-#endif\r
-#endif\r
-       return 1;\r
-}\r
-\r
-int\r
-#ifdef __USE_PROTOS\r
-_zzmatch_wdfltsig(int tokenWanted, SetWordType *whatFollows)\r
-#else\r
-_zzmatch_wdfltsig(tokenWanted, whatFollows)\r
-int tokenWanted;\r
-SetWordType *whatFollows;\r
-#endif\r
-{\r
-#ifdef DEMAND_LOOK\r
-#ifdef LL_K\r
-       if ( zzdirty==LL_K ) {\r
-                       zzCONSUME;\r
-       }\r
-#else\r
-       if ( zzdirty ) {zzCONSUME;}\r
-#endif\r
-#endif\r
-\r
-       if ( LA(1)!=tokenWanted )\r
-       {\r
-        zzSyntaxErrCount++;     /* MR11 */\r
-               fprintf(stderr,\r
-                               "line %d: syntax error at \"%s\" missing %s\n",\r
-                               zzline,\r
-                               (LA(1)==zzEOF_TOKEN)?"<eof>":(char *)LATEXT(1),\r
-                               zztokens[tokenWanted]);\r
-               zzconsumeUntil( whatFollows );\r
-               return 0;\r
-       }\r
-       else {\r
-               zzMakeAttr                                              \r
-#ifdef DEMAND_LOOK\r
-#ifdef LL_K\r
-               zzdirty++;\r
-               zzlabase++;\r
-#else\r
-               zzdirty = 1;\r
-#endif\r
-#else\r
-/*             zzCONSUME;               consume if not demand lookahead */\r
-#endif\r
-               return 1;\r
-       }\r
-}\r
-\r
-int\r
-#ifdef __USE_PROTOS\r
-_zzsetmatch_wdfltsig(SetWordType *tokensWanted,\r
-                                        int tokenTypeOfSet,\r
-                                        SetWordType *whatFollows)\r
-#else\r
-_zzsetmatch_wdfltsig(tokensWanted, tokenTypeOfSet, whatFollows)\r
-SetWordType *tokensWanted;\r
-int tokenTypeOfSet;\r
-SetWordType *whatFollows;\r
-#endif\r
-{\r
-#ifdef DEMAND_LOOK\r
-#ifdef LL_K\r
-       if ( zzdirty==LL_K ) {zzCONSUME;}\r
-#else\r
-       if ( zzdirty ) {zzCONSUME;}\r
-#endif\r
-#endif\r
-       if ( !zzset_el((unsigned)LA(1), tokensWanted) )\r
-       {\r
-        zzSyntaxErrCount++;     /* MR11 */\r
-               fprintf(stderr,\r
-                               "line %d: syntax error at \"%s\" missing %s\n",\r
-                               zzline,\r
-                               (LA(1)==zzEOF_TOKEN)?"<eof>":(char *)LATEXT(1),\r
-                               zztokens[tokenTypeOfSet]);\r
-               zzconsumeUntil( whatFollows );\r
-               return 0;\r
-       }\r
-       else {\r
-               zzMakeAttr\r
-#ifdef DEMAND_LOOK\r
-#ifdef LL_K\r
-               zzdirty++;\r
-               zzlabase++;\r
-#else\r
-               zzdirty = 1;\r
-#endif\r
-#else\r
-/*             zzCONSUME;              consume if not demand lookahead */\r
-#endif\r
-               return 1;\r
-       }\r
-}\r
-\r
-int\r
-#ifdef __USE_PROTOS\r
-_zzsetmatch_wsig(SetWordType *e)\r
-#else\r
-_zzsetmatch_wsig(e)\r
-SetWordType *e;\r
-#endif\r
-{\r
-#ifdef DEMAND_LOOK\r
-#ifdef LL_K\r
-       if ( zzdirty==LL_K ) {zzCONSUME;}\r
-#else\r
-       if ( zzdirty ) {zzCONSUME;}\r
-#endif\r
-#endif\r
-       if ( !zzset_el((unsigned)LA(1), e) ) return 0;\r
-       zzMakeAttr           /* MR14 Ger Hobbelt (hobbelt@axa.nl) */\r
-#ifdef DEMAND_LOOK\r
-#ifdef LL_K\r
-       zzdirty++;\r
-    zzlabase++;          /* MR14 Ger Hobbelt (hobbelt@axa.nl) */\r
-#else\r
-       zzdirty = 1;\r
-#endif\r
-#endif\r
-       return 1;\r
-}\r
-\r
-#ifdef USER_ZZMODE_STACK\r
-static int  zzmstk[ZZMAXSTK] = { -1 };\r
-static int  zzmdep = 0;\r
-static char zzmbuf[70];\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-zzmpush( int m )\r
-#else\r
-zzmpush( m )\r
-int m;\r
-#endif\r
-{\r
-   if(zzmdep == ZZMAXSTK - 1) {\r
-     sprintf(zzmbuf, "Mode stack overflow ");\r
-     zzerr(zzmbuf);\r
-   } else {\r
-     zzmstk[zzmdep++] = zzauto;\r
-     zzmode(m);\r
-   }\r
-}\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-zzmpop( void )\r
-#else\r
-zzmpop( )\r
-#endif\r
-{\r
-   if(zzmdep == 0)\r
-   {  sprintf(zzmbuf, "Mode stack underflow ");\r
-      zzerr(zzmbuf);\r
-   }\r
-   else\r
-   {  zzmdep--;\r
-      zzmode(zzmstk[zzmdep]);\r
-   }\r
-}\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-zzsave_mode_stack( int modeStack[], int *modeLevel )\r
-#else\r
-zzsave_mode_stack( modeStack, modeLevel )\r
-int modeStack[];\r
-int *modeLevel;\r
-#endif\r
-{\r
-  int i;\r
-  memcpy(modeStack, zzmstk, sizeof(zzmstk));\r
-  *modeLevel = zzmdep;\r
-  zzmdep = 0;\r
-\r
-  return;\r
-}\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-zzrestore_mode_stack( int modeStack[], int *modeLevel )\r
-#else\r
-zzrestore_mode_stack( modeStack, modeLevel )\r
-int modeStack[];\r
-int *modeLevel;\r
-#endif\r
-{\r
-  int i;\r
-\r
-  memcpy(zzmstk, modeStack, sizeof(zzmstk));\r
-  zzmdep = *modeLevel;\r
-\r
-  return;\r
-}\r
-#endif /* USER_ZZMODE_STACK */\r
-\r
-#ifdef __USE_PROTOS\r
-void zzTraceReset(void)\r
-#else\r
-void zzTraceReset()\r
-#endif\r
-{\r
-#ifdef zzTRACE_RULES\r
-  zzTraceOptionValue=zzTraceOptionValueDefault;\r
-  zzTraceGuessOptionValue=1;\r
-  zzTraceCurrentRuleName=NULL;\r
-  zzTraceDepth=0;\r
-#endif\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-void zzTraceGuessFail(void)\r
-#else\r
-void zzTraceGuessFail()\r
-#endif\r
-{\r
-\r
-#ifdef zzTRACE_RULES\r
-#ifdef ZZCAN_GUESS\r
-\r
-  int   doIt=0;\r
-\r
-  if (zzTraceOptionValue <= 0) {\r
-    doIt=0;\r
-  } else if (zzguessing && zzTraceGuessOptionValue <= 0) {\r
-    doIt=0;\r
-  } else {\r
-    doIt=1;\r
-  };\r
-\r
-  if (doIt) {\r
-    fprintf(stderr,"guess failed\n");\r
-  };\r
-#endif\r
-#endif\r
-}\r
-\r
-/* zzTraceOption:\r
-     zero value turns off trace\r
-*/\r
-\r
-#ifdef __USE_PROTOS\r
-void zzTraceIn(char * rule)\r
-#else\r
-void zzTraceIn(rule)\r
-  char  *rule;\r
-#endif\r
-{\r
-#ifdef zzTRACE_RULES\r
-\r
-  int           doIt=0;\r
-\r
-  zzTraceDepth++;\r
-  zzTraceCurrentRuleName=rule;\r
-\r
-  if (zzTraceOptionValue <= 0) {\r
-    doIt=0;\r
-#ifdef ZZCAN_GUESS\r
-  } else if (zzguessing && zzTraceGuessOptionValue <= 0) {\r
-    doIt=0;\r
-#endif\r
-  } else {\r
-    doIt=1;\r
-  };\r
-\r
-  if (doIt) {\r
-    fprintf(stderr,"enter rule %s {\"%s\"} depth %d",\r
-            rule,\r
-            LA(1)==1 ? "@" : (char *) LATEXT(1),    /* MR19 */\r
-            zzTraceDepth);\r
-#ifdef ZZCAN_GUESS\r
-    if (zzguessing) fprintf(stderr," guessing");\r
-#endif\r
-    fprintf(stderr,"\n");\r
-  };\r
-#endif\r
-  return;\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-void zzTraceOut(char * rule)\r
-#else\r
-void zzTraceOut(rule)\r
-  char  *rule;\r
-#endif\r
-{\r
-#ifdef zzTRACE_RULES\r
-  int       doIt=0;\r
-\r
-  zzTraceDepth--;\r
-\r
-  if (zzTraceOptionValue <= 0) {\r
-    doIt=0;\r
-#ifdef ZZCAN_GUESS\r
-  } else if (zzguessing && zzTraceGuessOptionValue <= 0) {\r
-    doIt=0;\r
-#endif\r
-  } else {\r
-    doIt=1;\r
-  };\r
-\r
-  if (doIt) {\r
-    fprintf(stderr,"exit rule %s {\"%s\"} depth %d",\r
-            rule,\r
-            LA(1)==1 ? "@" : (char *) LATEXT(1), /* MR19 */\r
-            zzTraceDepth+1);\r
-#ifdef ZZCAN_GUESS\r
-    if (zzguessing) fprintf(stderr," guessing");\r
-#endif\r
-    fprintf(stderr,"\n");\r
-  };\r
-#endif\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-int zzTraceOption(int delta)\r
-#else\r
-int zzTraceOption(delta)\r
-  int   delta;\r
-#endif\r
-{\r
-#ifdef zzTRACE_RULES\r
-    int     prevValue=zzTraceOptionValue;\r
-\r
-    zzTraceOptionValue=zzTraceOptionValue+delta;\r
-\r
-    if (zzTraceCurrentRuleName != NULL) {\r
-      if (prevValue <= 0 && zzTraceOptionValue > 0) {\r
-        fprintf(stderr,"trace enabled in rule %s depth %d\n",\r
-                                            zzTraceCurrentRuleName,zzTraceDepth);\r
-      };\r
-      if (prevValue > 0 && zzTraceOptionValue <= 0) {\r
-        fprintf(stderr,"trace disabled in rule %s depth %d\n",\r
-                                            zzTraceCurrentRuleName,zzTraceDepth);\r
-      };\r
-    };\r
-    return  prevValue;\r
-#else\r
-    return 0;\r
-#endif\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-int zzTraceGuessOption(int delta)\r
-#else\r
-int zzTraceGuessOption(delta)\r
-  int   delta;\r
-#endif\r
-{\r
-#ifdef zzTRACE_RULES\r
-#ifdef ZZCAN_GUESS\r
-    int     prevValue=zzTraceGuessOptionValue;\r
-\r
-    zzTraceGuessOptionValue=zzTraceGuessOptionValue+delta;\r
-\r
-    if (zzTraceCurrentRuleName != NULL) {\r
-      if (prevValue <= 0 && zzTraceGuessOptionValue > 0) {\r
-        fprintf(stderr,"guess trace enabled in rule %s depth %d\n",\r
-                                                zzTraceCurrentRuleName,zzTraceDepth);\r
-      };\r
-      if (prevValue > 0 && zzTraceGuessOptionValue <= 0) {\r
-        fprintf(stderr,"guess trace disabled in rule %s depth %d\n",\r
-                                                zzTraceCurrentRuleName,zzTraceDepth);\r
-      };\r
-    };\r
-    return prevValue;\r
-#else\r
-    return 0;\r
-#endif\r
-#else\r
-    return 0;\r
-#endif\r
-}\r
-\r
-#endif /* ERR_H */\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/h/int.h b/Tools/CodeTools/TianoTools/Pccts/h/int.h
deleted file mode 100644 (file)
index cdcaa92..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-/* ANTLR attribute definition -- long integers\r
- *\r
- * SOFTWARE RIGHTS\r
- *\r
- * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
- * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
- * company may do whatever they wish with source code distributed with\r
- * PCCTS or the code generated by PCCTS, including the incorporation of\r
- * PCCTS, or its output, into commerical software.\r
- *\r
- * We encourage users to develop software with PCCTS.  However, we do ask\r
- * that credit is given to us for developing PCCTS.  By "credit",\r
- * we mean that if you incorporate our source code into one of your\r
- * programs (commercial product, research project, or otherwise) that you\r
- * acknowledge this fact somewhere in the documentation, research report,\r
- * etc...  If you like PCCTS and have developed a nice tool with the\r
- * output, please mention that you developed it using PCCTS.  In\r
- * addition, we ask that this header remain intact in our source code.\r
- * As long as these guidelines are kept, we expect to continue enhancing\r
- * this system and expect to make other tools available as they are\r
- * completed.\r
- *\r
- * ANTLR 1.33\r
- * Terence Parr\r
- * Parr Research Corporation\r
- * with Purdue University and AHPCRC, University of Minnesota\r
- * 1989-2000\r
- */\r
-\r
-#ifndef ZZINT_H\r
-#define ZZINT_H\r
-\r
-typedef long Attrib;\r
-\r
-#define zzcr_attr(a,tok,t)     *(a) = atol(t);\r
-\r
-#endif\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/h/pccts_assert.h b/Tools/CodeTools/TianoTools/Pccts/h/pccts_assert.h
deleted file mode 100644 (file)
index ff0dfb5..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef __PCCTS_ASSERT_H__\r
-#define __PCCTS_ASSERT_H__\r
-\r
-#ifdef PCCTS_USE_NAMESPACE_STD\r
-#include <cassert>\r
-#else\r
-#include <assert.h>\r
-#endif\r
-\r
-#endif\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/h/pccts_iostream.h b/Tools/CodeTools/TianoTools/Pccts/h/pccts_iostream.h
deleted file mode 100644 (file)
index 972b32c..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef __PCCTS_IOSTREAM_H__\r
-#define __PCCTS_IOSTREAM_H__\r
-\r
-#ifdef PCCTS_USE_NAMESPACE_STD\r
-#include <iostream>\r
-#else\r
-#include <iostream.h>\r
-#endif\r
-\r
-#endif\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/h/pccts_istream.h b/Tools/CodeTools/TianoTools/Pccts/h/pccts_istream.h
deleted file mode 100644 (file)
index e25cb8c..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef __PCCTS_ISTREAM_H__\r
-#define __PCCTS_ISTREAM_H__\r
-\r
-#ifdef PCCTS_USE_NAMESPACE_STD\r
-#include <istream>\r
-#else\r
-#include <istream.h>\r
-#endif\r
-\r
-#endif\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/h/pccts_setjmp.h b/Tools/CodeTools/TianoTools/Pccts/h/pccts_setjmp.h
deleted file mode 100644 (file)
index 9ea185c..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef __PCCTS_SETJMP_H__\r
-#define __PCCTS_SETJMP_H__\r
-\r
-#ifdef PCCTS_USE_NAMESPACE_STD\r
-#include <csetjmp>\r
-#else\r
-#include <setjmp.h>\r
-#endif\r
-\r
-#endif\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/h/pccts_stdarg.h b/Tools/CodeTools/TianoTools/Pccts/h/pccts_stdarg.h
deleted file mode 100644 (file)
index e957430..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef __PCCTS_STDARG_H__\r
-#define __PCCTS_STDARG_H__\r
-\r
-#ifdef PCCTS_USE_NAMESPACE_STD\r
-#include <cstdarg>\r
-#else\r
-#include <stdarg.h>\r
-#endif\r
-\r
-#endif\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/h/pccts_stdio.h b/Tools/CodeTools/TianoTools/Pccts/h/pccts_stdio.h
deleted file mode 100644 (file)
index ac34d10..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef __PCCTS_STDIO_H__\r
-#define __PCCTS_STDIO_H__\r
-\r
-#ifdef PCCTS_USE_NAMESPACE_STD\r
-#include <cstdio>\r
-#else\r
-#include <stdio.h>\r
-#endif\r
-\r
-#endif\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/h/pccts_stdlib.h b/Tools/CodeTools/TianoTools/Pccts/h/pccts_stdlib.h
deleted file mode 100644 (file)
index f0b344e..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef __PCCTS_STDLIB_H__\r
-#define __PCCTS_STDLIB_H__\r
-\r
-#ifdef PCCTS_USE_NAMESPACE_STD\r
-#include <cstdlib>\r
-#else\r
-#include <stdlib.h>\r
-#endif\r
-\r
-#endif\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/h/pccts_string.h b/Tools/CodeTools/TianoTools/Pccts/h/pccts_string.h
deleted file mode 100644 (file)
index 458a08a..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef __PCCTS_STRING_H__\r
-#define __PCCTS_STRING_H__\r
-\r
-#ifdef PCCTS_USE_NAMESPACE_STD\r
-#include <cstring>\r
-#else\r
-#include <string.h>\r
-#endif\r
-\r
-#endif\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/h/pcctscfg.h b/Tools/CodeTools/TianoTools/Pccts/h/pcctscfg.h
deleted file mode 100644 (file)
index 0c3c5ba..0000000
+++ /dev/null
@@ -1,359 +0,0 @@
-#ifndef PCCTS_CONFIG_H\r
-#define PCCTS_CONFIG_H\r
-/*\r
- * pcctscfg.h (formerly config.h) (for ANTLR, DLG, and SORCERER)\r
- *\r
- * This is a simple configuration file that doesn't have config stuff\r
- * in it, but it's a start.\r
- *\r
- * SOFTWARE RIGHTS\r
- *\r
- * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
- * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
- * company may do whatever they wish with source code distributed with\r
- * PCCTS or the code generated by PCCTS, including the incorporation of\r
- * PCCTS, or its output, into commerical software.\r
- *\r
- * We encourage users to develop software with PCCTS.  However, we do ask\r
- * that credit is given to us for developing PCCTS.  By "credit",\r
- * we mean that if you incorporate our source code into one of your\r
- * programs (commercial product, research project, or otherwise) that you\r
- * acknowledge this fact somewhere in the documentation, research report,\r
- * etc...  If you like PCCTS and have developed a nice tool with the\r
- * output, please mention that you developed it using PCCTS.  In\r
- * addition, we ask that this header remain intact in our source code.\r
- * As long as these guidelines are kept, we expect to continue enhancing\r
- * this system and expect to make other tools available as they are\r
- * completed.\r
- *\r
- * Used by PCCTS 1.33 (SORCERER 1.00B11 and up)\r
- * Terence Parr\r
- * Parr Research Corporation\r
- * with Purdue University and AHPCRC, University of Minnesota\r
- * 1989-2000\r
- */\r
-\r
-/* This file knows about the following ``environments''\r
-       UNIX    (default)\r
-       DOS     (use #define PC)\r
-       MAC     (use #define MPW; has a few things for THINK C, Metrowerks)\r
-    MS/C++  (MR14 Microsoft Visual C++ environment uses symbol _MSC_VER)\r
-\r
- */\r
-\r
-/* should test __STDC__ for 1, but some compilers don't set value, just def */\r
-\r
-#ifndef __USE_PROTOS\r
-#ifdef __STDC__\r
-#define __USE_PROTOS\r
-#endif\r
-#ifdef __cplusplus\r
-#define __USE_PROTOS\r
-#endif\r
-#endif\r
-\r
-#ifdef PCCTS_USE_NAMESPACE_STD\r
-#define PCCTS_NAMESPACE_STD     namespace std {}; using namespace std;\r
-#else\r
-#define PCCTS_NAMESPACE_STD\r
-#endif\r
-\r
-#include "pccts_stdio.h"\r
-#include "pccts_stdlib.h"\r
-\r
-/* largest file name size */\r
-\r
-#ifdef _MAX_PATH\r
-#define MaxFileName            _MAX_PATH /* MR9 RJV: MAX_PATH defined in stdlib.h (MSVC++ 5.0) */\r
-#else\r
-#define MaxFileName            300\r
-#endif\r
-\r
-/*\r
-*  Define PC32 if in a 32-bit PC environment (e.g. extended DOS or Win32).\r
-*  The macros tested here are defined by Watcom, Microsoft, Borland,\r
-*  and djgpp, respectively, when they are used as 32-bit compilers.\r
-*  Users of these compilers *must* be sure to define PC in their\r
-*  makefiles for this to work correctly.\r
-*/\r
-#ifdef PC\r
-# if (defined(__WATCOMC__) || defined(_WIN32) || defined(__WIN32__) || \\r
-   defined(__GNUC__) || defined(__GNUG__))\r
-#     ifndef PC32\r
-#        define PC32\r
-#     endif\r
-#  endif\r
-#endif\r
-\r
-/* MR1  10-Apr-97  Default for PC is short file names                              */\r
-/* MR1            Default for non-PC is long file names                                */\r
-/* MR1            Can override via command line option LONGFILENAMES           */\r
-\r
-#ifndef LONGFILENAMES\r
-#ifndef PC\r
-#define LONGFILENAMES\r
-#endif\r
-#endif\r
-\r
-#ifndef LONGFILENAMES\r
-#define ATOKEN_H                       "AToken.h"\r
-#define ATOKPTR_H                      "ATokPtr.h"\r
-#define ATOKPTR_IMPL_H         "ATokPtrIm.h"\r
-#define ATOKENBUFFER_H         "ATokBuf.h"\r
-#define ATOKENBUFFER_C      "ATokBuf.cpp"\r
-#define ATOKENSTREAM_H         "ATokStr.h"\r
-#define APARSER_H                      "AParser.h"\r
-#define APARSER_C           "AParser.cpp"\r
-#define ASTBASE_H                      "ASTBase.h"\r
-#define ASTBASE_C           "ASTBase.cpp"\r
-#define PCCTSAST_C          "PCCTSAST.cpp"\r
-#define LIST_C              "List.cpp"\r
-#define DLEXERBASE_H           "DLexBase.h"\r
-#define DLEXERBASE_C        "DLexBase.cpp"\r
-#define DLEXER_H            "DLexer.h"\r
-#define STREESUPPORT_C         "STreeSup.C"\r
-#else\r
-#define ATOKEN_H                       "AToken.h"\r
-#define ATOKPTR_H                      "ATokPtr.h"\r
-#define ATOKPTR_IMPL_H         "ATokPtrImpl.h"\r
-#define ATOKENBUFFER_H         "ATokenBuffer.h"\r
-#define ATOKENBUFFER_C         "ATokenBuffer.cpp"\r
-#define ATOKENSTREAM_H         "ATokenStream.h"\r
-#define APARSER_H                      "AParser.h"\r
-#define APARSER_C                      "AParser.cpp"\r
-#define ASTBASE_H                      "ASTBase.h"\r
-#define ASTBASE_C                  "ASTBase.cpp"\r
-#define PCCTSAST_C                     "PCCTSAST.cpp"\r
-#define LIST_C                         "List.cpp"\r
-#define DLEXERBASE_H           "DLexerBase.h"\r
-#define DLEXERBASE_C           "DLexerBase.cpp"\r
-#define DLEXER_H                       "DLexer.h"\r
-#define STREESUPPORT_C         "STreeSupport.cpp"\r
-#endif\r
-\r
-/* SORCERER Stuff */\r
-\r
-/* MR8 6-Aug-97     Change from ifdef PC to ifndef LONGFILENAMES            */\r
-\r
-#ifndef LONGFILENAMES\r
-#define STPARSER_H                     "STreePar.h"\r
-#define STPARSER_C                     "STreePar.C"\r
-#else\r
-#define STPARSER_H                     "STreeParser.h"\r
-#define STPARSER_C                     "STreeParser.cpp"\r
-#endif\r
-\r
-#ifdef MPW\r
-#define CPP_FILE_SUFFIX                ".cp"\r
-#define CPP_FILE_SUFFIX_NO_DOT "cp"\r
-#define OBJ_FILE_SUFFIX                ".o"\r
-#else\r
-#ifdef PC\r
-#define CPP_FILE_SUFFIX                ".cpp"\r
-#define CPP_FILE_SUFFIX_NO_DOT "cpp"\r
-#define OBJ_FILE_SUFFIX                ".obj"\r
-#else\r
-#ifdef __VMS\r
-#define CPP_FILE_SUFFIX                ".cpp"\r
-#define CPP_FILE_SUFFIX_NO_DOT "cpp"\r
-#define OBJ_FILE_SUFFIX                ".obj"\r
-#else\r
-#define CPP_FILE_SUFFIX                ".cpp"\r
-#define CPP_FILE_SUFFIX_NO_DOT "cpp"\r
-#define OBJ_FILE_SUFFIX                ".o"\r
-#endif\r
-#endif\r
-#endif\r
-\r
-/* User may redefine how line information looks */     /* make it #line MR7 */\r
-/* MR21 Use #ifndef */\r
-\r
-#ifndef LineInfoFormatStr\r
-#define LineInfoFormatStr "#line %d \"%s\"\n"\r
-#endif\r
-\r
-#ifdef MPW                         /* Macintosh Programmer's Workshop */\r
-#define ErrHdr "File \"%s\"; Line %d #"\r
-#else\r
-#ifdef _MSC_VER                 /* MR14 Microsoft Visual C++ environment */\r
-#define ErrHdr "%s(%d) :"\r
-#else\r
-#define ErrHdr "%s, line %d:"   /* default */\r
-#endif\r
-#endif\r
-\r
-/* must assume old K&R cpp here, can't use #if defined(..)... */\r
-\r
-#ifdef MPW\r
-#define TopDirectory   ":"\r
-#define DirectorySymbol        ":"\r
-#define OutputDirectoryOption "Directory where all output files should go (default=\":\")"\r
-#else\r
-#ifdef PC\r
-#define TopDirectory   "."\r
-#define DirectorySymbol        "\\"\r
-#define OutputDirectoryOption "Directory where all output files should go (default=\".\")"\r
-#else\r
-#ifdef __VMS\r
-#define TopDirectory  "[000000]"\r
-#define DirectorySymbol       "]"\r
-#define OutputDirectoryOption "Directory where all output files should go (default=\"[]\")"\r
-#else\r
-#define TopDirectory   "."\r
-#define DirectorySymbol        "/"\r
-#define OutputDirectoryOption "Directory where all output files should go (default=\".\")"\r
-#endif\r
-#endif\r
-#endif\r
-\r
-#ifdef MPW\r
-\r
-/* Make sure we have prototypes for all functions under MPW */\r
-\r
-#include "pccts_string.h"\r
-#include "pccts_stdlib.h"\r
-\r
-/* MR6 2-Jun-97        Fixes false dependency caused by VC++ #include scanner  */\r
-/* MR6            Reported by Brad Schick (schick@interaccess.com)     */\r
-#define        MPW_CursorCtl_Header <CursorCtl.h>\r
-#include MPW_CursorCtl_Header\r
-#ifdef __cplusplus\r
-extern "C" {\r
-#endif\r
-extern void fsetfileinfo (const char *filename, unsigned long newcreator, unsigned long newtype);\r
-#ifdef __cplusplus\r
-}\r
-#endif\r
-\r
-/* File creators for various popular development environments */\r
-\r
-#define MAC_FILE_CREATOR 'MPS '   /* MPW Text files */\r
-#if 0\r
-#define MAC_FILE_CREATOR 'KAHL'   /* THINK C/Symantec C++ Text files */\r
-#endif\r
-#if 0\r
-#define MAC_FILE_CREATOR 'CWIE'   /* Metrowerks C/C++ Text files */\r
-#endif\r
-\r
-#endif\r
-\r
-#ifdef MPW\r
-#define DAWDLE SpinCursor(1)\r
-#else\r
-#define DAWDLE\r
-#endif\r
-\r
-#ifdef MPW\r
-#define SPECIAL_INITS\r
-#define SPECIAL_FOPEN\r
-#endif\r
-\r
-#ifdef MPW\r
-#ifdef __cplusplus\r
-inline\r
-#else\r
-static\r
-#endif\r
-void special_inits()\r
-{\r
-  InitCursorCtl((acurHandle) 0);\r
-}\r
-#endif\r
-\r
-#ifdef MPW\r
-#ifdef __cplusplus\r
-inline\r
-#else\r
-static\r
-#endif\r
-void special_fopen_actions(char * s)\r
-{\r
-  fsetfileinfo (s, MAC_FILE_CREATOR, 'TEXT');\r
-}\r
-#endif\r
-\r
-/* Define usable bits for set.c stuff */\r
-#define BytesPerWord   sizeof(unsigned)\r
-#define        WORDSIZE                (sizeof(unsigned)*8)\r
-#define LogWordSize     (WORDSIZE==16?4:5)\r
-\r
-#ifndef TRUE\r
-#define TRUE 1\r
-#endif\r
-#ifndef FALSE\r
-#define FALSE 0\r
-#endif\r
-\r
-#if defined(VAXC) || defined(__VMS)\r
-#include <ssdef.h>\r
-#define PCCTS_EXIT_SUCCESS 1\r
-#define PCCTS_EXIT_FAILURE SS$_ABORT\r
-#define zzDIE          return SS$_ABORT;\r
-#define zzDONE return 1;\r
-\r
-#else /* !VAXC and !__VMS */\r
-\r
-#define PCCTS_EXIT_SUCCESS 0\r
-#define PCCTS_EXIT_FAILURE 1\r
-#define zzDIE          return 1;\r
-#define zzDONE return 0;\r
-\r
-#endif\r
-\r
-#ifdef USER_ZZMODE_STACK\r
-# ifndef ZZSTACK_MAX_MODE\r
-#  define  ZZSTACK_MAX_MODE 32\r
-# endif\r
-# define  ZZMAXSTK (ZZSTACK_MAX_MODE * 2)\r
-#endif\r
-\r
-#ifndef DllExportPCCTS\r
-#define DllExportPCCTS\r
-#endif\r
-\r
-#ifdef PC\r
-#ifndef PCCTS_CASE_INSENSITIVE_FILE_NAME\r
-#define PCCTS_CASE_INSENSITIVE_FILE_NAME\r
-#endif\r
-#endif\r
-\r
-#ifdef PC32\r
-#ifndef PCCTS_CASE_INSENSITIVE_FILE_NAME\r
-#define PCCTS_CASE_INSENSITIVE_FILE_NAME\r
-#endif\r
-#endif\r
-\r
-#ifdef __VMS\r
-#ifndef PCCTS_CASE_INSENSITIVE_FILE_NAME\r
-#define PCCTS_CASE_INSENSITIVE_FILE_NAME\r
-#endif\r
-#endif\r
-\r
-#ifdef __USE_PROTOS\r
-#ifndef PCCTS_USE_STDARG\r
-#define PCCTS_USE_STDARG\r
-#endif\r
-#endif\r
-\r
-#ifdef __STDC__\r
-#ifndef PCCTS_USE_STDARG\r
-#define PCCTS_USE_STDARG\r
-#endif\r
-#endif\r
-\r
-#ifdef __cplusplus\r
-#ifndef PCCTS_USE_STDARG\r
-#define PCCTS_USE_STDARG\r
-#endif\r
-#endif\r
-\r
-#ifdef _MSC_VER\r
-/*Turn off the warnings for:\r
-  unreferenced inline/local function has been removed\r
-*/\r
-#pragma warning(disable : 4514)\r
-/* function not expanded */\r
-#pragma warning(disable : 4710)\r
-#endif\r
-\r
-#endif\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/h/pcnames.bat b/Tools/CodeTools/TianoTools/Pccts/h/pcnames.bat
deleted file mode 100644 (file)
index 8784aee..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-ren aparser.c aparser.cpp\r
-ren astbase.c astbase.cpp\r
-ren atokenbu.c atokbuf.cpp\r
-ren atokenbu.h atokbuf.h\r
-ren atokenst.h atokstr.h\r
-ren dlexerba.c dlexbase.cpp\r
-ren dlexerba.h dlexbase.h\r
-ren dlexer.c dlexer.cpp\r
-ren list.c list.cpp\r
-ren pblackbo.h pblckbox.h\r
-ren pcctsast.c pcctsast.cpp\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/h/slist.cpp b/Tools/CodeTools/TianoTools/Pccts/h/slist.cpp
deleted file mode 100644 (file)
index faf2fe4..0000000
+++ /dev/null
@@ -1,116 +0,0 @@
-/*\r
- * SList.C\r
- *\r
- * SOFTWARE RIGHTS\r
- *\r
- * We reserve no LEGAL rights to SORCERER -- SORCERER is in the public\r
- * domain.  An individual or company may do whatever they wish with\r
- * source code distributed with SORCERER or the code generated by\r
- * SORCERER, including the incorporation of SORCERER, or its output, into\r
- * commerical software.\r
- *\r
- * We encourage users to develop software with SORCERER.  However, we do\r
- * ask that credit is given to us for developing SORCERER.  By "credit",\r
- * we mean that if you incorporate our source code into one of your\r
- * programs (commercial product, research project, or otherwise) that you\r
- * acknowledge this fact somewhere in the documentation, research report,\r
- * etc...  If you like SORCERER and have developed a nice tool with the\r
- * output, please mention that you developed it using SORCERER.  In\r
- * addition, we ask that this header remain intact in our source code.\r
- * As long as these guidelines are kept, we expect to continue enhancing\r
- * this system and expect to make other tools available as they are\r
- * completed.\r
- *\r
- * PCCTS 1.33\r
- * Terence Parr\r
- * Parr Research Corporation\r
- * with Purdue University and AHPCRC, University of Minnesota\r
- * 1992-2000\r
- */\r
-\r
-#define ANTLR_SUPPORT_CODE\r
-\r
-#include "SList.h"\r
-#include "pccts_stdarg.h" // MR23\r
-\r
-/* Iterate over a list of elements; returns ptr to a new element\r
- * in list upon every call and NULL when no more are left.\r
- * Very useful like this:\r
- *\r
- *             cursor = mylist;\r
- *             while ( (p=mylist->iterate(&cursor)) ) {\r
- *                     // place with element p\r
- *             }\r
- *\r
- * The cursor must be initialized to point to the list to iterate over.\r
- */\r
-void *SList::\r
-iterate(SListNode **cursor)\r
-{\r
-       void *e;\r
-\r
-       if ( cursor == NULL || *cursor==NULL ) return NULL;\r
-       if ( head == *cursor ) { *cursor = (*cursor)->next(); }\r
-       e = (*cursor)->elem();\r
-       (*cursor) = (*cursor)->next();\r
-       return e;\r
-}\r
-\r
-/* add an element to end of list. */\r
-void SList::\r
-add(void *e)\r
-{\r
-       SListNode *p, *tail=NULL;\r
-       require(e!=NULL, "slist_add: attempting to add NULL list element");\r
-\r
-       p = new SListNode;\r
-       require(p!=NULL, "add: cannot alloc new list node");\r
-       p->setElem(e);\r
-       if ( head == NULL )\r
-       {\r
-               head = tail = p;\r
-       }\r
-       else                                                            /* find end of list */\r
-       {\r
-               tail->setNext(p);\r
-               tail = p;\r
-       }\r
-}\r
-\r
-void SList::\r
-lfree()\r
-{\r
-       SListNode *p,*q;\r
-\r
-       if ( head==NULL ) return;       /* empty list */\r
-       for (p = head; p!=NULL; p=q)\r
-       {\r
-               q = p->next();\r
-               free(p);\r
-       }\r
-}\r
-\r
-PCCTS_AST *SList::\r
-to_ast(SList list)\r
-{\r
-       PCCTS_AST *t=NULL, *last=NULL;\r
-       SListNode *p;\r
-\r
-       for (p = head; p!=NULL; p=p->next())\r
-       {\r
-               PCCTS_AST *u = (PCCTS_AST *)p->elem();\r
-               if ( last==NULL ) last = t = u;\r
-               else { last->setRight(u); last = u; }\r
-       }\r
-       return t;\r
-}\r
-\r
-// MR23\r
-int SList::printMessage(FILE* pFile, const char* pFormat, ...)\r
-{\r
-       va_list marker;\r
-       va_start( marker, pFormat );\r
-       int iRet = vfprintf(pFile, pFormat, marker);\r
-       va_end( marker );\r
-       return iRet;\r
-}\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/history.ps b/Tools/CodeTools/TianoTools/Pccts/history.ps
deleted file mode 100644 (file)
index e2600d5..0000000
+++ /dev/null
@@ -1,473 +0,0 @@
-%!PS-Adobe-3.0
-%%Creator: groff version 1.06
-%%DocumentNeededResources: font Times-Roman
-%%+ font Times-Italic
-%%+ font Courier
-%%DocumentSuppliedResources: procset grops 1.06 0
-%%Pages: 3
-%%PageOrder: Ascend
-%%Orientation: Portrait
-%%EndComments
-%%BeginProlog
-%%BeginResource: procset grops 1.06 0
-
-/setpacking where {
-       pop
-       currentpacking
-       true setpacking
-} if
-
-/grops 120 dict dup begin 
-
-% The ASCII code of the space character.
-/SC 32 def
-
-/A /show load def
-/B { 0 SC 3 -1 roll widthshow } bind def
-/C { 0 exch ashow } bind def
-/D { 0 exch 0 SC 5 2 roll awidthshow } bind def
-/E { 0 rmoveto show } bind def
-/F { 0 rmoveto 0 SC 3 -1 roll widthshow } bind def
-/G { 0 rmoveto 0 exch ashow } bind def
-/H { 0 rmoveto 0 exch 0 SC 5 2 roll awidthshow } bind def
-/I { 0 exch rmoveto show } bind def
-/J { 0 exch rmoveto 0 SC 3 -1 roll widthshow } bind def
-/K { 0 exch rmoveto 0 exch ashow } bind def
-/L { 0 exch rmoveto 0 exch 0 SC 5 2 roll awidthshow } bind def
-/M { rmoveto show } bind def
-/N { rmoveto 0 SC 3 -1 roll widthshow } bind def
-/O { rmoveto 0 exch ashow } bind def
-/P { rmoveto 0 exch 0 SC 5 2 roll awidthshow } bind def
-/Q { moveto show } bind def 
-/R { moveto 0 SC 3 -1 roll widthshow } bind def
-/S { moveto 0 exch ashow } bind def
-/T { moveto 0 exch 0 SC 5 2 roll awidthshow } bind def
-
-% name size font SF -
-
-/SF {
-       findfont exch
-       [ exch dup 0 exch 0 exch neg 0 0 ] makefont
-       dup setfont
-       [ exch /setfont cvx ] cvx bind def
-} bind def
-
-% name a c d font MF -
-
-/MF {
-       findfont
-       [ 5 2 roll
-       0 3 1 roll % b
-       neg 0 0 ] makefont
-       dup setfont
-       [ exch /setfont cvx ] cvx bind def
-} bind def
-
-/level0 0 def
-/RES 0 def
-/PL 0 def
-/LS 0 def
-
-% Guess the page length.
-% This assumes that the imageable area is vertically centered on the page.
-% PLG - length
-
-/PLG {
-       gsave newpath clippath pathbbox grestore
-       exch pop add exch pop
-} bind def
-
-% BP -
-
-/BP {
-       /level0 save def
-       1 setlinecap
-       1 setlinejoin
-       72 RES div dup scale
-       LS {
-               90 rotate
-       } {
-               0 PL translate
-       } ifelse
-       1 -1 scale
-} bind def
-
-/EP {
-       level0 restore
-       showpage
-} bind def
-
-
-% centerx centery radius startangle endangle DA -
-
-/DA {
-       newpath arcn stroke
-} bind def
-
-% x y SN - x' y'
-% round a position to nearest (pixel + (.25,.25))
-
-/SN {
-       transform 
-       .25 sub exch .25 sub exch
-       round .25 add exch round .25 add exch
-       itransform
-} bind def
-       
-% endx endy startx starty DL -
-% we round the endpoints of the line, so that parallel horizontal
-% and vertical lines will appear even
-
-/DL {
-       SN
-       moveto
-       SN
-       lineto stroke
-} bind def
-
-% centerx centery radius DC -
-
-/DC {
-       newpath 0 360 arc closepath
-} bind def
-
-
-/TM matrix def
-
-%  width height centerx centery DE -
-
-/DE {
-       TM currentmatrix pop
-       translate scale newpath 0 0 .5 0 360 arc closepath
-       TM setmatrix
-} bind def
-
-% these are for splines
-
-/RC /rcurveto load def
-/RL /rlineto load def
-/ST /stroke load def
-/MT /moveto load def
-/CL /closepath load def
-
-% fill the last path
-
-% amount FL -
-
-/FL {
-       currentgray exch setgray fill setgray
-} bind def
-
-% fill with the ``current color''
-
-/BL /fill load def
-
-/LW /setlinewidth load def
-% new_font_name encoding_vector old_font_name RE -
-
-/RE {
-       findfont
-       dup maxlength dict begin
-       {
-               1 index /FID ne { def } { pop pop } ifelse
-       } forall
-       /Encoding exch def
-       dup /FontName exch def
-       currentdict end definefont pop
-} bind def
-
-/DEFS 0 def
-
-% hpos vpos EBEGIN -
-
-/EBEGIN {
-       moveto
-       DEFS begin
-} bind def
-
-/EEND /end load def
-
-/CNT 0 def
-/level1 0 def
-
-% llx lly newwid wid newht ht newllx newlly PBEGIN -
-
-/PBEGIN {
-       /level1 save def
-       translate
-       div 3 1 roll div exch scale
-       neg exch neg exch translate
-       % set the graphics state to default values
-       0 setgray
-       0 setlinecap
-       1 setlinewidth
-       0 setlinejoin
-       10 setmiterlimit
-       [] 0 setdash
-       /setstrokeadjust where {
-               pop
-               false setstrokeadjust
-       } if
-       /setoverprint where {
-               pop
-               false setoverprint
-       } if
-       newpath
-       /CNT countdictstack def
-       userdict begin
-       /showpage {} def
-} bind def
-
-/PEND {
-       clear
-       countdictstack CNT sub { end } repeat
-       level1 restore
-} bind def
-
-end def
-
-/setpacking where {
-       pop
-       setpacking
-} if
-%%EndResource
-%%IncludeResource: font Times-Roman
-%%IncludeResource: font Times-Italic
-%%IncludeResource: font Courier
-grops begin/DEFS 1 dict def DEFS begin/u{.001 mul}bind def end/RES 72 def/PL
-792 def/LS false def/ENC0[/asciicircum/asciitilde/Scaron/Zcaron/scaron/zcaron
-/Ydieresis/trademark/quotesingle/.notdef/.notdef/.notdef/.notdef/.notdef
-/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
-/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/space
-/exclam/quotedbl/numbersign/dollar/percent/ampersand/quoteright/parenleft
-/parenright/asterisk/plus/comma/hyphen/period/slash/zero/one/two/three/four
-/five/six/seven/eight/nine/colon/semicolon/less/equal/greater/question/at/A/B/C
-/D/E/F/G/H/I/J/K/L/M/N/O/P/Q/R/S/T/U/V/W/X/Y/Z/bracketleft/backslash
-/bracketright/circumflex/underscore/quoteleft/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q
-/r/s/t/u/v/w/x/y/z/braceleft/bar/braceright/tilde/.notdef/quotesinglbase
-/guillemotleft/guillemotright/bullet/florin/fraction/perthousand/dagger
-/daggerdbl/endash/emdash/ff/fi/fl/ffi/ffl/dotlessi/dotlessj/grave/hungarumlaut
-/dotaccent/breve/caron/ring/ogonek/quotedblleft/quotedblright/oe/lslash
-/quotedblbase/OE/Lslash/.notdef/exclamdown/cent/sterling/currency/yen/brokenbar
-/section/dieresis/copyright/ordfeminine/guilsinglleft/logicalnot/minus
-/registered/macron/degree/plusminus/twosuperior/threesuperior/acute/mu
-/paragraph/periodcentered/cedilla/onesuperior/ordmasculine/guilsinglright
-/onequarter/onehalf/threequarters/questiondown/Agrave/Aacute/Acircumflex/Atilde
-/Adieresis/Aring/AE/Ccedilla/Egrave/Eacute/Ecircumflex/Edieresis/Igrave/Iacute
-/Icircumflex/Idieresis/Eth/Ntilde/Ograve/Oacute/Ocircumflex/Otilde/Odieresis
-/multiply/Oslash/Ugrave/Uacute/Ucircumflex/Udieresis/Yacute/Thorn/germandbls
-/agrave/aacute/acircumflex/atilde/adieresis/aring/ae/ccedilla/egrave/eacute
-/ecircumflex/edieresis/igrave/iacute/icircumflex/idieresis/eth/ntilde/ograve
-/oacute/ocircumflex/otilde/odieresis/divide/oslash/ugrave/uacute/ucircumflex
-/udieresis/yacute/thorn/ydieresis]def/Courier@0 ENC0/Courier RE/Times-Italic@0
-ENC0/Times-Italic RE/Times-Roman@0 ENC0/Times-Roman RE
-%%EndProlog
-%%Page: 1 1
-%%BeginPageSetup
-BP
-%%EndPageSetup
-/F0 13/Times-Roman@0 SF(The History of PCCTS)228.232 84 Q/F1 11/Times-Roman@0
-SF(The Purdue Compiler)190.468 108 Q(-Construction T)-.22 E(ool Set)-.88 E/F2
-10/Times-Italic@0 SF -.92(Te)262.245 144 S -.37(re).92 G(nce P).37 E(arr)-.8 E
-/F3 10/Times-Roman@0 SF -.15(Pa)234.755 156 S(rr Research Corporation).15 E
-(Minneapolis, Minnesota)239.39 168 Q(and)280.78 180 Q(Uni)239.315 192 Q -.15
-(ve)-.25 G(rsity of Minnesota).15 E
-(Army High Performance Computing Research Center)180.38 204 Q F2
-([Updated 8-7-94])252.31 228 Q F1 .084(The PCCTS project be)97 259.6 R -.055
-(ga)-.165 G 2.834(na).055 G 2.833(sap)220.547 259.6 S(arser)240.876 259.6 Q
-.083(-generator project for a graduate course at Purdue Uni-)-.22 F -.165(ve)72
-275.6 S 1.085(rsity in the F).165 F 1.086
-(all of 1988 taught by Hank Dietz\212 translator)-.165 F 1.086
-(-writing systems.)-.22 F 1.086(Under the guid-)6.586 F .627
-(ance of Professor Dietz, the parser generator)72 291.6 R 3.377(,A)-.44 G .626
-(NTLR \(originally called YUCC\), continued after)285.18 291.6 R .253
-(the termination of the course and e)72 307.6 R -.165(ve)-.275 G .254
-(ntually became the subject of T).165 F .254(erence P)-.77 F(arr')-.165 E 3.004
-(sM)-.605 G(aster')445.083 307.6 Q 3.004(st)-.605 G(hesis.)479.25 307.6 Q
-(Originally)72 323.6 Q 4.092(,l)-.715 G -.165(ex)126.406 323.6 S 1.342
-(ical analysis w).165 F 1.342(as performed via ALX which w)-.11 F 1.342
-(as soon replaced by W)-.11 F 1.341(ill Cohen')-.44 F(s)-.605 E .594
-(DLG in the F)72 339.6 R .594(all of 1989 \(DF)-.165 F .595(A-based le)-.814 F
-.595(xical-analyzer generator)-.165 F 3.345(,a)-.44 G .595(lso an of)367.188
-339.6 R .595(fshoot of the graduate)-.275 F(translation course\).)72 355.6 Q
-.877(The alpha v)97 375.2 R .877(ersion of ANTLR w)-.165 F .877(as totally re)
--.11 F .876(written resulting in 1.00B.)-.275 F -1.221(Ve)6.376 G .876
-(rsion 1.00B w)1.221 F(as)-.11 E 1.577(released via an internet ne)72 391.2 R
-1.577(wsgroup \(comp.compilers\) posting in February of 1990 and quickly)-.275
-F -.055(ga)72 407.2 S .356(thered a lar).055 F .356(ge follo)-.198 F 3.106
-(wing. 1.00B)-.275 F .356(generated only LL\(1\) parsers, b)3.106 F .356
-(ut allo)-.22 F .356(wed the mer)-.275 F .356(ged descrip-)-.198 F 1.859
-(tion of le)72 423.2 R 1.859(xical and syntactic analysis.)-.165 F 1.86
-(It had rudimentary attrib)7.359 F 1.86(ute handling similar to that of)-.22 F
--.55 -1.32(YA C)72 439.2 T 3.549(Ca)1.32 G .799
-(nd did not incorporate rule parameters or return v)109.231 439.2 R .798
-(alues; do)-.275 F(wnw)-.275 E .798(ard inheritance w)-.11 F .798(as v)-.11 F
-(ery)-.165 E -.165(aw)72 455.2 S(kw).165 E 6.433(ard. 1.00B-generated)-.11 F
-3.684(parsers terminated upon the \214rst syntax error)6.433 F 9.184(.L)-.605 G
--.165(ex)440.916 455.2 S 3.684(ical classes).165 F(\(modes\) were not allo)72
-471.2 Q(wed and DLG did not ha)-.275 E .33 -.165(ve a)-.22 H 2.75(ni).165 G
-(nteracti)305.959 471.2 Q .33 -.165(ve m)-.275 H(ode.).165 E .831
-(Upon starting his Ph.D. at Purdue in the F)97 490.8 R .83(all of 1990, T)-.165
-F .83(erence P)-.77 F .83(arr be)-.165 F -.055(ga)-.165 G 3.58(nt).055 G .83
-(he second total)436.351 490.8 R(re)72 506.8 Q 1.646(write of ANTLR.)-.275 F
-1.646(The method by which grammars may be practically analyzed to generate)
-7.146 F/F4 11/Times-Italic@0 SF(LL)72.638 522.8 Q F1(\().583 E F4(k).396 E F1
-3.849(\)l).737 G 1.099(ookahead information w)105.703 522.8 R 1.099(as disco)
--.11 F -.165(ve)-.165 G 1.099(red in August of 1990 just before his return.)
-.165 F -1.221(Ve)6.598 G(rsion)1.221 E .626
-(1.00 incorporated this algorithm and included the AST mechanism, le)72 538.8 R
-.626(xical classes, error classes,)-.165 F .354(and automatic error reco)72
-554.8 R -.165(ve)-.165 G .353(ry; code quality and portability were higher).165
-F 5.853(.I)-.605 G 3.103(nF)395.965 554.8 S .353(ebruary of 1992 1.00)410.684
-554.8 R -.11(wa)72 570.8 S 2.76(sr).11 G .01
-(eleased via an article in SIGPLAN Notices.)95.418 570.8 R .01
-(Peter Dahl, Ph.D. candidate, and Professor Matt)5.51 F(O'K)72 586.8 Q 2.074
-(eefe \(both at the Uni)-.275 F -.165(ve)-.275 G 2.073
-(rsity of Minnesota\) tested this v).165 F 2.073(ersion e)-.165 F(xtensi)-.165
-E -.165(ve)-.275 G(ly).165 E 7.573(.D)-.715 G 2.073(ana Hogg)448.522 586.8 R
-(att)-.055 E .078(\(Micro Data Base Systems, Inc.\) came up with the idea of e\
-rror grouping \(strings attached to non-)72 602.8 R
-(terminals\) and tested 1.00 hea)72 618.8 Q(vily)-.22 E(.)-.715 E -1.221(Ve)97
-638.4 S .878(rsion 1.06 w)1.221 F .877
-(as released in December 1992 and represented a lar)-.11 F .877
-(ge feature enhancement)-.198 F -.165(ove)72 654.4 S 3.648(r1).165 G 3.648
-(.00. F)100.365 654.4 R .898(or e)-.165 F .899
-(xample, rudimentary semantic predicates were introduced, error messages were)
--.165 F 2.281(signi\214cantly impro)72 670.4 R -.165(ve)-.165 G 5.031(df).165 G
-(or)181.953 670.4 Q F4(k)5.427 E F1 2.281
-(>1 lookahead and ANTLR parsers could indicate that lookahead).737 F 1.381
-(fetches were to occur only when necessary for the parse \(normally)72 686.4 R
-4.131(,t)-.715 G 1.381(he lookahead `)387.051 686.4 R(`pipe')-.814 E 4.132('w)
--.814 G(as)494.837 686.4 Q 1.182(constantly full\).)72 702.4 R 1.182
-(Russell Quong joined the project in the Spring of 1992 to aid in the semantic)
-6.682 F .681(predicate design.)72 718.4 R(Be)6.181 E .681(ginning and adv)-.165
-F .682(anced tutorials were created and released as well.)-.275 F 3.432(Am)
-6.182 G(ak)485.179 718.4 Q(e-)-.11 E .993(\214le generator w)72 734.4 R .993
-(as included that sets up dependencies and such correctly for ANTLR and DLG.)
--.11 F EP
-%%Page: 2 2
-%%BeginPageSetup
-BP
-%%EndPageSetup
-/F0 11/Times-Roman@0 SF 2.75(-2-)278.837 52 S -1.221(Ve)72 88 S 1.414(ry fe)
-1.221 F 4.164(w1)-.275 G 1.414(.00 incompatibilities were introduced \(1.00 w)
-122.81 88 R 1.415(as quite dif)-.11 F 1.415(ferent from 1.00B in some)-.275 F
-(areas\).)72 104 Q 1.089(1.10 w)97 123.6 R 1.088
-(as released on August 31, 1993 and incorporated b)-.11 F 1.088(ug \214x)-.22 F
-1.088(es, a fe)-.165 F 3.838(wf)-.275 G 1.088(eature enhance-)433.59 123.6 R
-3.112(ments and a major ne)72 139.6 R 5.863(wc)-.275 G(apability \212)196.957
-139.6 Q 3.113(an arbitrary lookahead operator \(syntactic predicate\),)5.863 F
-/F1 11/Courier@0 SF(\(alpha\)?beta)72 155.6 Q F0 6.754(.T)C 1.254
-(his feature w)167.425 155.6 R 1.254
-(as co-designed with Professor Russell Quong also at Purdue.)-.11 F 3.297 -.88
-(To s)72 171.6 T 1.537
-(upport in\214nite lookahead, a preprocessor \215ag, ZZINF_LOOK, w).88 F 1.537
-(as created that forced the)-.11 F .21(ANTLR\(\) macro to tok)72 187.6 R .21
-(enize all input prior to parsing.)-.11 F .209(Hence, at an)5.709 F 2.959(ym)
--.165 G .209(oment, an action or predi-)389.215 187.6 R .936
-(cate can see the entire input sentence.)72 203.6 R .936
-(The predicate mechanism of 1.06 w)6.436 F .937(as e)-.11 F .937
-(xtended to allo)-.165 F(w)-.275 E .55
-(multiple predicates to be hoisted; the syntactic conte)72 219.6 R .55
-(xt of a predicate w)-.165 F .55(as also mo)-.11 F -.165(ve)-.165 G 3.299(da)
-.165 G .549(long with)461.585 219.6 R(the predicate.)72 235.6 Q .754
-(In February of 1994, SORCERER \(a simple tree-parser generator\) w)97 255.2 R
-.755(as released.)-.11 F .755(This tool)6.255 F(allo)72 271.2 Q .6(ws the user\
- to parse child-sibling trees by specifying a grammar rather than b)-.275 F
-.599(uilding a recur)-.22 F(-)-.22 E(si)72 287.2 Q -.165(ve)-.275 G 1.39
-(-descent tree w).165 F(alk)-.11 E 1.391(er by hand.)-.11 F -.88(Wo)6.891 G
-1.391(rk to).88 F -.11(wa)-.275 G 1.391
-(rds a library of tree transformations is underw).11 F(ay)-.11 E(.)-.715 E .581
-(Aaron Sa)72 303.2 R(wde)-.165 E 3.331(ya)-.165 G 3.331(tT)145.531 303.2 S .581
-(he Uni)158.641 303.2 R -.165(ve)-.275 G .58
-(rsity of Minnesota became a second author of SORCERER after the).165 F
-(initial release.)72 319.2 Q .627(On April 1, 1994, PCCTS 1.20 w)97 338.8 R
-.627(as released.)-.11 F .627(This w)6.127 F .627(as the \214rst v)-.11 F .627
-(ersion to acti)-.165 F -.165(ve)-.275 G .627(ly support).165 F 1.664
-(C++ output.)72 354.8 R 1.664(It also included important \214x)7.164 F 1.663
-(es re)-.165 F -.055(ga)-.165 G 1.663
-(rding semantic predicates and \(..\)+ subrules.).055 F(This v)72 370.8 Q
-(ersion also introduced tok)-.165 E(en classes, the `)-.11 E(`)-.814 E/F2 11
-/Times-Italic@0 SF(not)A F0 1.628 -.814('' o)D(perator).814 E 2.75(,a)-.44 G
-(nd tok)355.294 370.8 Q(en ranges.)-.11 E .764
-(On June 19, 1994, SORCERER 1.00B9 w)97 390.4 R .765(as released.)-.11 F .765
-(Gary Funck of Intrepid T)6.265 F(echnology)-.77 E .807
-(joined the SORCERER team and pro)72 406.4 R .807(vided v)-.165 F .807(ery v)
--.165 F .807(aluable suggestions re)-.275 F -.055(ga)-.165 G .806(rding the `)
-.055 F(`transform')-.814 E(')-.814 E(mode of SORCERER.)72 422.4 Q 1.137
-(On August 8, 1994, PCCTS 1.21 w)97 442 R 1.137(as released.)-.11 F 1.138
-(It mainly cleaned up the C++ output and)6.637 F(included a number of b)72 458
-Q(ug \214x)-.22 E(es.)-.165 E .316(From the 1.21 release forw)97 477.6 R .316
-(ard, the maintenance and support of all PCCTS tools will be pri-)-.11 F 1.557
-(marily pro)72 493.6 R 1.557(vided by P)-.165 F 1.557
-(arr Research Corporation, Minneapolis MN---an or)-.165 F -.055(ga)-.198 G
-1.558(nization founded on).055 F 1.616(the principles of e)72 509.6 R 1.616
-(xcellence in research and inte)-.165 F 1.616(grity in b)-.165 F 1.616
-(usiness; we are de)-.22 F -.22(vo)-.275 G 1.616(ted to pro).22 F(viding)-.165
-E 1.202(really cool softw)72 525.6 R 1.202(are tools.)-.11 F 1.202
-(Please see \214le PCCTS.FUTURE for more information.)6.702 F 1.203(All PCCTS)
-6.703 F(tools currently in the public domain will continue to be in the public\
- domain.)72 541.6 Q 1.198(Looking to)97 561.2 R -.11(wa)-.275 G 1.198
-(rds the future, a graphical user).11 F(-interf)-.22 E 1.197
-(ace is in the design phase.)-.11 F 1.197(This w)6.697 F(ould)-.11 E(allo)72
-577.2 Q 2.753(wu)-.275 G .003(sers to vie)104.42 577.2 R 2.753(wt)-.275 G .004
-(he syntax diagram representation of their grammars and w)162.509 577.2 R .004
-(ould highlight non-)-.11 F 1.181(deterministic productions.)72 593.2 R -.165
-(Pa)6.681 G 1.18(rsing can be traced graphically as well.).165 F 1.18
-(This system will be b)6.68 F(uilt)-.22 E .167(using a multiplatform windo)72
-609.2 R 2.917(wl)-.275 G(ibrary)211.73 609.2 Q 5.667(.W)-.715 G 2.917(ea)
-255.204 609.2 S .168(lso anticipate the introduction of a sophisticated error)
-267.889 609.2 R(handling mechanism called `)72 625.2 Q(`parser e)-.814 E
-(xception handling')-.165 E 2.75('i)-.814 G 2.75(nan)327.431 625.2 S
-(ear future release.)348.815 625.2 Q(Currently)97 644.8 Q 3.019(,P)-.715 G .269
-(CCTS is used at o)150.333 644.8 R -.165(ve)-.165 G 3.019(r1).165 G .269
-(000 kno)253.098 644.8 R .268(wn academic, go)-.275 F -.165(ve)-.165 G .268
-(rnment, and commercial sites).165 F .859(in 37 countries.)72 660.8 R .859
-(Of course, the true number of users is unkno)6.359 F .859(wn due to the lar)
--.275 F .859(ge number of ftp)-.198 F(sites.)72 676.8 Q EP
-%%Page: 3 3
-%%BeginPageSetup
-BP
-%%EndPageSetup
-/F0 11/Times-Roman@0 SF 2.75(-3-)278.837 52 S(Credits)272.11 88 Q .44 LW
-472.162 103.75 103.838 103.75 DL(Idea/T)134.236 117 Q 52.987(ool Coder)-.88 F
-(Co-designer\(s\))345.436 117 Q 281.334 103.75 281.334 124.75 DL 209.273 103.75
-209.273 124.75 DL 209.273 124.75 103.838 124.75 DL 103.838 126.75 209.273
-126.75 DL 281.334 124.75 209.273 124.75 DL 209.273 126.75 281.334 126.75 DL
-472.162 124.75 281.334 124.75 DL 281.334 126.75 472.162 126.75 DL(ANTLR 1.00A)
-109.338 140 Q -.77(Te)217.523 140 S(rence P).77 E 13.75(arr Hank)-.165 F(Dietz)
-2.75 E 82.83(ALX T)109.338 156 R(erence P)-.77 E 13.75(arr Hank)-.165 F(Dietz)
-2.75 E(ANTLR 1.00B)109.338 172 Q -.77(Te)217.523 172 S(rence P).77 E 13.75
-(arr Hank)-.165 F(Dietz, W)2.75 E(ill Cohen)-.44 E(DLG 1.00B)109.338 188 Q -.44
-(Wi)217.523 188 S(ll Cohen).44 E -.77(Te)289.584 188 S(rence P).77 E(arr)-.165
-E 2.75(,H)-.44 G(ank Dietz)358.147 188 Q(NF)109.338 204 Q 2.75(AR)-.814 G
-30.778(elabelling W)140.611 204 R(ill Cohen)-.44 E/F1 11/Times-Italic@0 SF(LL)
-109.976 220 Q F0(\().583 E F1(k).396 E F0 2.75(\)a).737 G 40.447(nalysis T)
-143.768 220 R(erence P)-.77 E 13.75(arr Hank)-.165 F(Dietz)2.75 E(ANTLR 1.00)
-109.338 236 Q -.77(Te)217.523 236 S(rence P).77 E 13.75(arr Hank)-.165 F
-(Dietz, W)2.75 E(ill Cohen)-.44 E(DLG 1.00)109.338 252 Q -.44(Wi)217.523 252 S
-(ll Cohen).44 E -.77(Te)289.584 252 S(rence P).77 E(arr)-.165 E 2.75(,H)-.44 G
-(ank Dietz)358.147 252 Q(ANTLR 1.06)109.338 268 Q -.77(Te)217.523 268 S
-(rence P).77 E 13.75(arr W)-.165 F(ill Cohen, Russell Quong, Hank Dietz)-.44 E
-(DLG 1.06)109.338 284 Q -.44(Wi)217.523 284 S(ll Cohen).44 E -.77(Te)289.584
-284 S(rence P).77 E(arr)-.165 E 2.75(,H)-.44 G(ank Dietz)358.147 284 Q
-(ANTLR 1.10)109.338 300 Q -.77(Te)217.523 300 S(rence P).77 E 13.75(arr W)-.165
-F(ill Cohen, Russell Quong)-.44 E(ANTLR 1.20)109.338 316 Q -.77(Te)217.523 316
-S(rence P).77 E 13.75(arr W)-.165 F(ill Cohen, Russell Quong)-.44 E(ANTLR 1.21)
-109.338 332 Q -.77(Te)217.523 332 S(rence P).77 E 13.75(arr Russell)-.165 F
-(Quong)2.75 E(DLG 1.10)109.338 348 Q -.44(Wi)217.523 348 S(ll Cohen).44 E -.77
-(Te)289.584 348 S(rence P).77 E(arr)-.165 E(DLG 1.20)109.338 364 Q -.44(Wi)
-217.523 364 S(ll Cohen).44 E -.77(Te)289.584 364 S(rence P).77 E(arr)-.165 E
-(DLG 1.21)109.338 380 Q -.77(Te)217.523 380 S(rence P).77 E(arr)-.165 E
-(Semantic predicates)109.338 396 Q -.77(Te)217.523 396 S(rence P).77 E 13.75
-(arr Russell)-.165 F(Quonq)2.75 E(Syntactic predicates)109.338 412 Q -.77(Te)
-217.523 412 S(rence P).77 E 13.75(arr Russell)-.165 F(Quonq)2.75 E
-(SORCERER 1.00A)109.338 428 Q -.77(Te)217.523 428 S(rence P).77 E(arr)-.165 E
-(SORCERER 1.00B)109.338 444 Q -.77(Te)217.523 444 S(rence P).77 E 13.75
-(arr Aaron)-.165 F(Sa)2.75 E(wde)-.165 E(y)-.165 E(SORCERER 1.00B9)109.338 460
-Q -.77(Te)217.523 460 S(rence P).77 E 13.75(arr Aaron)-.165 F(Sa)2.75 E(wde)
--.165 E 1.43 -.715(y, G)-.165 H(ary Funck).715 E 472.162 467.75 103.838 467.75
-DL 472.162 103.75 472.162 467.75 DL 103.838 103.75 103.838 467.75 DL EP
-%%Trailer
-end
-%%EOF
diff --git a/Tools/CodeTools/TianoTools/Pccts/history.txt b/Tools/CodeTools/TianoTools/Pccts/history.txt
deleted file mode 100644 (file)
index 89ad840..0000000
+++ /dev/null
@@ -1,186 +0,0 @@
-\r
-\r
-\r
-                    The History of PCCTS\r
-\r
-         The Purdue Compiler-Construction Tool Set\r
-\r
-\r
-                        Terence Parr\r
-                 Parr Research Corporation\r
-                   Minneapolis, Minnesota\r
-                            and\r
-                  University of Minnesota\r
-      Army High Performance Computing Research Center\r
-\r
-                      [Updated 8-7-94]\r
-\r
-\r
-     The PCCTS project began as a parser-generator project for a  gra-\r
-duate  course  at Purdue University in the Fall of 1988 taught by Hank\r
-Dietz- translator-writing systems.  Under the  guidance  of  Professor\r
-Dietz, the parser generator, ANTLR (originally called YUCC), continued\r
-after the termination of the course and eventually became the  subject\r
-of  Terence  Parr's Master's thesis.  Originally, lexical analysis was\r
-performed via ALX which was soon replaced by Will Cohen's DLG  in  the\r
-Fall  of  1989 (DFA-based lexical-analyzer generator, also an offshoot\r
-of the graduate translation course).\r
-\r
-     The alpha version of ANTLR was  totally  rewritten  resulting  in\r
-1.00B.    Version   1.00B  was  released  via  an  internet  newsgroup\r
-(comp.compilers) posting in February of 1990 and  quickly  gathered  a\r
-large  following.  1.00B generated only LL(1) parsers, but allowed the\r
-merged description of lexical and syntactic analysis.  It had rudimen-\r
-tary  attribute  handling  similar  to that of YACC and did not incor-\r
-porate rule parameters or return values; downward inheritance was very\r
-awkward.   1.00B-generated  parsers  terminated  upon the first syntax\r
-error.  Lexical classes (modes) were not allowed and DLG did not  have\r
-an interactive mode.\r
-\r
-     Upon starting his Ph.D. at Purdue in the Fall  of  1990,  Terence\r
-Parr  began  the  second  total rewrite of ANTLR.  The method by which\r
-grammars may be  practically  analyzed  to  generate  LL(k)  lookahead\r
-information  was  discovered in August of 1990 just before his return.\r
-Version 1.00 incorporated this algorithm and included the AST  mechan-\r
-ism,  lexical  classes,  error  classes, and automatic error recovery;\r
-code quality and portability were higher.  In February  of  1992  1.00\r
-was  released  via  an  article in SIGPLAN Notices.  Peter Dahl, Ph.D.\r
-candidate, and Professor Matt O'Keefe (both at the University of  Min-\r
-nesota)  tested  this  version  extensively.  Dana Hoggatt (Micro Data\r
-Base Systems, Inc.) came up with the idea of error  grouping  (strings\r
-attached to non-terminals) and tested 1.00 heavily.\r
-\r
-     Version 1.06 was released in  December  1992  and  represented  a\r
-large  feature enhancement over 1.00.  For example, rudimentary seman-\r
-tic predicates were  introduced,  error  messages  were  significantly\r
-improved  for k>1 lookahead and ANTLR parsers could indicate that loo-\r
-kahead fetches were  to  occur  only  when  necessary  for  the  parse\r
-\r
-\r
-\r
-                                                                Page 1\r
-\f\r
-                                                                 PCCTS\r
-\r
-\r
-(normally,  the  lookahead "pipe" was constantly full).  Russell Quong\r
-joined the project in the Spring of 1992 to aid in the semantic predi-\r
-cate  design.   Beginning  and  advanced  tutorials  were  created and\r
-released as well.  A makefile generator  was  included  that  sets  up\r
-dependencies  and  such  correctly  for  ANTLR and DLG.  Very few 1.00\r
-incompatibilities were introduced (1.00 was quite different from 1.00B\r
-in some areas).\r
-\r
-     1.10 was released on August 31, 1993 and incorporated bug  fixes,\r
-a  few  feature enhancements and a major new capability - an arbitrary\r
-lookahead operator (syntactic predicate), (alpha)?beta.  This  feature\r
-was  co-designed with Professor Russell Quong also at Purdue.  To sup-\r
-port infinite lookahead, a preprocessor flag, ZZINF_LOOK, was  created\r
-that  forced the ANTLR() macro to tokenize all input prior to parsing.\r
-Hence, at any moment, an action or predicate can see the entire  input\r
-sentence.   The predicate mechanism of 1.06 was extended to allow mul-\r
-tiple predicates to be hoisted; the syntactic context of  a  predicate\r
-was also moved along with the predicate.\r
-\r
-     In February of 1994, SORCERER (a  simple  tree-parser  generator)\r
-was  released.  This tool allows the user to parse child-sibling trees\r
-by specifying a grammar rather than building a recursive-descent  tree\r
-walker  by  hand.   Work  towards a library of tree transformations is\r
-underway.  Aaron Sawdey at The University of Minnesota became a second\r
-author of SORCERER after the initial release.\r
-\r
-     On April 1, 1994, PCCTS 1.20 was released.  This  was  the  first\r
-version  to  actively  support C++ output.  It also included important\r
-fixes regarding semantic predicates and (..)+ subrules.  This  version\r
-also introduced token classes, the "not" operator, and token ranges.\r
-\r
-     On June 19, 1994, SORCERER 1.00B9 was released.   Gary  Funck  of\r
-Intrepid  Technology  joined the SORCERER team and provided very valu-\r
-able suggestions regarding the "transform" mode of SORCERER.\r
-\r
-     On August 8, 1994, PCCTS 1.21 was released.  It mainly cleaned up\r
-the C++ output and included a number of bug fixes.\r
-\r
-     From the 1.21 release forward, the maintenance and support of all\r
-PCCTS  tools  will be primarily provided by Parr Research Corporation,\r
-Minneapolis MN---an organization founded on the principles  of  excel-\r
-lence in research and integrity in business; we are devoted to provid-\r
-ing really cool software tools.  Please see file PCCTS.FUTURE for more\r
-information.  All PCCTS tools currently in the public domain will con-\r
-tinue to be in the public domain.\r
-\r
-     Looking towards the future, a graphical user-interface is in  the\r
-design  phase.   This  would  allow  users  to view the syntax diagram\r
-representation of their grammars and would highlight  nondeterministic\r
-productions.   Parsing can be traced graphically as well.  This system\r
-will be built using a multiplatform window library.  We  also  antici-\r
-pate  the  introduction  of  a  sophisticated error handling mechanism\r
-called "parser exception handling" in a near future release.\r
-\r
-\r
-\r
-\r
-                                                                Page 2\r
-\f\r
-                                                                 PCCTS\r
-\r
-\r
-     Currently, PCCTS is used at over 1000 known academic, government,\r
-and  commercial  sites in 37 countries.  Of course, the true number of\r
-users is unknown due to the large number of ftp sites.\r
-                               Credits\r
-\r
-_____________________________________________________________________________\r
-_____________________________________________________________________________\r
-|ANTLR 1.00A            Terence Parr   Hank Dietz                           |\r
-|ALX                    Terence Parr   Hank Dietz                           |\r
-|ANTLR 1.00B            Terence Parr   Hank Dietz, Will Cohen               |\r
-|DLG 1.00B              Will Cohen     Terence Parr, Hank Dietz             |\r
-|NFA Relabelling        Will Cohen                                          |\r
-|LL(k) analysis         Terence Parr   Hank Dietz                           |\r
-|ANTLR 1.00             Terence Parr   Hank Dietz, Will Cohen               |\r
-|DLG 1.00               Will Cohen     Terence Parr, Hank Dietz             |\r
-|ANTLR 1.06             Terence Parr   Will Cohen, Russell Quong, Hank Dietz|\r
-|DLG 1.06               Will Cohen     Terence Parr, Hank Dietz             |\r
-|ANTLR 1.10             Terence Parr   Will Cohen, Russell Quong            |\r
-|ANTLR 1.20             Terence Parr   Will Cohen, Russell Quong            |\r
-|ANTLR 1.21             Terence Parr   Russell Quong                        |\r
-|DLG 1.10               Will Cohen     Terence Parr                         |\r
-|DLG 1.20               Will Cohen     Terence Parr                         |\r
-|DLG 1.21               Terence Parr                                        |\r
-|Semantic predicates    Terence Parr   Russell Quonq                        |\r
-|Syntactic predicates   Terence Parr   Russell Quonq                        |\r
-|SORCERER 1.00A         Terence Parr                                        |\r
-|SORCERER 1.00B         Terence Parr   Aaron Sawdey                         |\r
-|SORCERER 1.00B9        Terence Parr   Aaron Sawdey, Gary Funck             |\r
-|___________________________________________________________________________|\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-                                                                Page 3\r
-\f\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/makefile b/Tools/CodeTools/TianoTools/Pccts/makefile
deleted file mode 100644 (file)
index f9b2dd2..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-#\r
-# Main makefile for PCCTS 1.33MR33     /* MRXXX */\r
-#\r
-# Terence Parr\r
-# Parr Research Corporation\r
-#\r
-# verbosity versus silence...\r
-PSss=\r
-#\r
-# this can be set to /user/local/bin etc...\r
-BINDIR=bin\r
-# This part added by Thomas Herter, M"unchen, Germany. See also manpages\r
-# target.\r
-MANDIR=$(HOME)/man\r
-MANEXT=1\r
-MANFILES=dlg/dlg.1 antlr/antlr.1\r
-\r
-#CC=cc\r
-#CC=gcc\r
-#COPT=-O2\r
-\r
-pccts:\r
-       @echo " "\r
-       @echo "             Welcome to PCCTS 1.33MR33 installation"\r
-       @echo " "\r
-       @echo "             (Version 1.33 Maintenance Release #33)" # mrxxx\r
-       @echo " "\r
-       @echo "                  Released 19 April 2002"\r
-       @echo " "\r
-       @echo "                        Featuring"\r
-       @echo "         ANTLR     -- ANother Tool for Language Recognition"\r
-       @echo "         DLG       -- DFA-based Lexical Analyzer Generator"\r
-       @echo "         SORCERER  -- Source-to-source translator (tree walker)" \r
-       @echo " "\r
-       @echo "                  http://www.antlr.org"  \r
-       @echo " "\r
-       @echo "             Trouble reports to tmoog@polhode.com"\r
-       @echo "             Additional PCCTS 1.33 information at"\r
-       @echo "                  http://www.polhode.com"\r
-       @echo\r
-       @echo\r
-       @echo "To substitute gcc for CC to invoke compiler: make CC=gcc"\r
-       @echo "If there are problems with cr and lf try: unzip -a ..."\r
-       @echo\r
-#\r
-       @if [ ! -d $(BINDIR) ] ; then mkdir $(BINDIR) ; fi\r
-       @echo Making executables...\r
-       (cd ./antlr; $(MAKE) CC="$(CC)" COPT="$(COPT)")\r
-       @echo antlr executable now in $(BINDIR)\r
-       (cd ./dlg; $(MAKE) CC="$(CC)" COPT="$(COPT)")\r
-       @echo dlg executable now in $(BINDIR)\r
-       @echo\r
-       @echo "       PCCTS 1.33MR33 installation complete"  # MRXXX\r
-\r
-clean:\r
-       (cd ./antlr; $(MAKE) -s clean)\r
-       (cd ./dlg; $(MAKE) -s clean)\r
-\r
-\r
-manpages:\r
-       # mkdir -p $(MANDIR)/man$(MANEXT)\r
-       if [ ! -d $(MANDIR) ] ; then \\r
-         mkdir $(MANDIR) ; fi\r
-       if [ ! -d $(MANDIR)/man$(MANEXT) ] ; then \\r
-         mkdir $(MANDIR)/man$(MANEXT); fi\r
-       cp -p $(MANFILES) $(MANDIR)/man$(MANEXT)\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/support/genmk/genmk.c b/Tools/CodeTools/TianoTools/Pccts/support/genmk/genmk.c
deleted file mode 100644 (file)
index 4952a30..0000000
+++ /dev/null
@@ -1,1063 +0,0 @@
-/*\r
- * genmk -- a program to make makefiles for PCCTS\r
- *\r
- * ANTLR 1.33MR23\r
- * Terence John Parr 1989 - 2000\r
- * Purdue University\r
- * U of MN\r
- */\r
-\r
-#include <stdio.h>\r
-#include <string.h>\r
-#include "pcctscfg.h" /* be sensitive to what ANTLR/DLG call the files */\r
-\r
-#ifdef VAXC\r
-#define DIE            return 0;\r
-#define DONE   return 1;\r
-#else\r
-#define DIE            return 1;\r
-#define DONE   return 0;\r
-#endif\r
-\r
-#ifndef require\r
-#define require(expr, err) {if ( !(expr) ) fatal(err);}\r
-#endif\r
-\r
-#define MAX_FILES      50\r
-#define MAX_CFILES     1600\r
-#define MAX_SFILES     50\r
-#define MAX_SORS       50\r
-#define MAX_CLASSES    50\r
-\r
-char *RENAME_OBJ_FLAG="-o",\r
-     *RENAME_EXE_FLAG="-o";\r
-\r
-char *dlg = "parser.dlg";\r
-char *err = "err.c";\r
-char *hdr = "stdpccts.h";\r
-char *tok = "tokens.h";\r
-char *mode = "mode.h";\r
-char *scan = "scan";\r
-\r
-char ATOKENBUFFER_O[100];\r
-char APARSER_O[100];\r
-char ASTBASE_O[100];\r
-char PCCTSAST_O[100];\r
-char LIST_O[100];\r
-char DLEXERBASE_O[100];\r
-\r
-/* Option flags */\r
-static char *project="t", *files[MAX_FILES], *classes[MAX_CLASSES];\r
-static char *cfiles[MAX_CFILES];\r
-static char *sfiles[MAX_SORS][MAX_SFILES],*sclasses[MAX_SORS];\r
-static int  num_sfiles[MAX_SORS]; /*sorcerer files in group */\r
-static int  num_sors = 0; /*sorcerer groups */\r
-static int  num_files = 0; /* grammar files */\r
-static int  num_cfiles = 0; /* additional C/C++ files */\r
-static int  num_classes = 0; /* ANTLR classes */\r
-static int  user_lexer = 0;\r
-static char *user_token_types = NULL;\r
-static int  gen_CPP = 0;\r
-static char *outdir=".";\r
-static char *dlg_class = "DLGLexer";\r
-static int  gen_trees = 0;\r
-static int  gen_hoist = 0;\r
-static int  nondef_comp = 0; /* 1=compiler is non default */\r
-static char *compilerCCC="CC";\r
-static char *compilerCC="cc";\r
-static char *pccts_path="/usr/local/pccts";\r
-\r
-#ifdef __STDC__\r
-void help(void);\r
-void mk(char *project, char **files, int n, int argc, char **argv);\r
-void pfiles(char **files, int n, char *suffix);\r
-void fatal(char *msg);\r
-void warn(char *msg);\r
-#else\r
-void help();\r
-void mk();\r
-void pfiles();\r
-void fatal();\r
-void warn();\r
-#endif\r
-\r
-typedef struct _Opt {\r
-                       char *option;\r
-                       int arg;\r
-#ifdef __cplusplus\r
-                       void (*process)(...);\r
-#else\r
-                       void (*process)();\r
-#endif\r
-                       char *descr;\r
-               } Opt;\r
-\r
-#ifdef __STDC__\r
-static void ProcessArgs(int, char **, Opt *);\r
-#else\r
-static void ProcessArgs();\r
-#endif\r
-\r
-static void\r
-#ifdef __STDC__\r
-pProj(char *s, char *t )\r
-#else\r
-pProj( s, t )\r
-char *s;\r
-char *t;\r
-#endif\r
-{\r
-       project = t;\r
-}\r
-\r
-static void\r
-#ifdef __STDC__\r
-pUL( char *s )\r
-#else\r
-pUL( s )\r
-char *s;\r
-#endif\r
-{\r
-       user_lexer = 1;\r
-}\r
-\r
-static void\r
-#ifdef __STDC__\r
-pCPP( char *s )\r
-#else\r
-pCPP( s )\r
-char *s;\r
-#endif\r
-{\r
-       gen_CPP = 1;\r
-}\r
-\r
-static void\r
-#ifdef __STDC__\r
-pUT( char *s, char *t )\r
-#else\r
-pUT( s, t )\r
-char *s;\r
-char *t;\r
-#endif\r
-{\r
-       user_token_types = t;\r
-}\r
-\r
-static void\r
-#ifdef __STDC__\r
-pTrees( char *s )\r
-#else\r
-pTrees( s )\r
-char *s;\r
-#endif\r
-{\r
-       gen_trees = 1;\r
-}\r
-\r
-static void\r
-#ifdef __STDC__\r
-pHoist( char *s )\r
-#else\r
-pHoist( s )\r
-char *s;\r
-#endif\r
-{\r
-       gen_hoist = 1;\r
-}\r
-\r
-static void\r
-#ifdef __STDC__\r
-pSor( char *s )\r
-#else\r
-pSor( s )\r
-char *s;\r
-#endif\r
-{\r
-       require(num_sors<MAX_SORS, "exceeded max # of sorcerer groups");\r
-       num_sors++;\r
-       pTrees(NULL); /* silently turn on tree generation */\r
-}\r
-\r
-static void\r
-#ifdef __STDC__\r
-pSFiles( char *s, char *t )\r
-#else\r
-pSFiles( s, t )\r
-char *s;\r
-char *t;\r
-#endif\r
-{\r
-       if (num_sors==0)\r
-       {\r
-               pSor(NULL);\r
-               warn("sorcerer input file before any '-sor' option");\r
-       }\r
-               \r
-       require(num_sfiles[num_sors-1]<MAX_SFILES,\r
-                "exceeded max # of sorcerer input files");\r
-       sfiles[num_sors-1][num_sfiles[num_sors-1]++] = t;\r
-}\r
-\r
-static void\r
-#ifdef __STDC__\r
-pCFiles( char *s, char *t )\r
-#else\r
-pCFiles( s, t )\r
-char *s;\r
-char *t;\r
-#endif\r
-{\r
-       require(num_cfiles<MAX_CFILES, "exceeded max # of C/C++ input files");\r
-       cfiles[num_cfiles++] = t;\r
-}\r
-\r
-int\r
-#ifdef __STDC__\r
-isKnownSuffix( char *s )\r
-#else\r
-isKnownSuffix( s )\r
-       char *s;\r
-#endif\r
-{\r
-       if(s==NULL) return 0;\r
-       if (strcasecmp(s,".c")==0) return 1;\r
-       if (strcasecmp(s,".cc")==0) return 1;\r
-       if (strcasecmp(s,".cpp")==0) return 1;\r
-       if (strcasecmp(s,".cxx")==0) return 1;\r
-       if (strcasecmp(s,CPP_FILE_SUFFIX)==0) return 1;\r
-       if (strcasecmp(s,".sor")==0) return 2;\r
-       return 0;\r
-}\r
-\r
-static void\r
-#ifdef __STDC__\r
-pFile( char *s )\r
-#else\r
-pFile( s )\r
-char *s;\r
-#endif\r
-{\r
-       if ( *s=='-' )\r
-       {\r
-               fprintf(stderr, "invalid option: '%s'; ignored...",s);\r
-               return;\r
-       }\r
-       switch(isKnownSuffix(strrchr(s,'.')))\r
-       {\r
-        case 1: /* c/c++ */\r
-               pCFiles("-cfiles",s);\r
-               return;\r
-        case 2: /* sorcerer */\r
-               pSFiles("",s);\r
-               return;\r
-        default: /* grammar (ANTLR) */\r
-               break;\r
-       }\r
-       require(num_files<MAX_FILES, "exceeded max # of input files");\r
-       files[num_files++] = s;\r
-}\r
-\r
-static void\r
-#ifdef __STDC__\r
-pClass( char *s, char *t )\r
-#else\r
-pClass( s, t )\r
-char *s;\r
-char *t;\r
-#endif\r
-{\r
-       if (num_sors==0)\r
-       {\r
-               require(num_classes<MAX_CLASSES, "exceeded max # of grammar classes");\r
-               classes[num_classes++] = t;\r
-       } else\r
-       {\r
-               sclasses[num_sors-1] = t; /* one class per sorcerer group (last valid) */\r
-       }\r
-}\r
-\r
-static void\r
-#ifdef __STDC__\r
-pDLGClass( char *s, char *t )\r
-#else\r
-pDLGClass( s, t )\r
-char *s;\r
-char *t;\r
-#endif\r
-{\r
-       if ( !gen_CPP ) {\r
-               fprintf(stderr, "-dlg-class makes no sense without C++ mode; ignored...");\r
-       }\r
-       else dlg_class = t;\r
-}\r
-\r
-static void\r
-#ifdef __STDC__\r
-pOdir( char *s, char *t )\r
-#else\r
-pOdir( s, t )\r
-char *s;\r
-char *t;\r
-#endif\r
-{\r
-       outdir = t;\r
-}\r
-\r
-static void\r
-#ifdef __STDC__\r
-pHdr( char *s, char *t )\r
-#else\r
-pHdr( s, t )\r
-char *s;\r
-char *t;\r
-#endif\r
-{\r
-       hdr = t;\r
-}\r
-\r
-static void\r
-#ifdef __STDC__\r
-pCompiler( char *s, char *t )\r
-#else\r
-pCompiler( s, t )\r
-char *s;\r
-char *t;\r
-#endif\r
-{\r
-       compilerCCC = t;\r
-       compilerCC = t;\r
-       nondef_comp = 1;\r
-}\r
-\r
-static void\r
-#ifdef __STDC__\r
-ppccts_path( char *s, char *t )\r
-#else\r
-ppccts_path( s, t )\r
-char *s;\r
-char *t;\r
-#endif\r
-{\r
-       pccts_path = t;\r
-}\r
-\r
-Opt options[] = {\r
-       { "-CC", 0,     pCPP,                   "Generate C++ output"},\r
-       { "-class", 1,  pClass,         "Name of a grammar class defined in grammar (if C++)"},\r
-       { "-dlg-class", 1,pDLGClass,"Name of DLG lexer class (default=DLGLexer) (if C++)"},\r
-       { "-header", 1,pHdr,            "Name of ANTLR standard header info (default=no file)"},\r
-       { "-o", 1,      pOdir,                  "Directory where output files should go (default=\".\")"},\r
-       { "-project", 1,        pProj,  "Name of executable to create (default=t)"},\r
-       { "-token-types", 1, pUT,       "Token types are in this file (don't use tokens.h)"},\r
-       { "-trees", 0, pTrees,          "Generate ASTs"},\r
-       { "-user-lexer", 0,     pUL,    "Do not create a DLG-based scanner"},\r
-       { "-mrhoist",0,pHoist,      "Maintenance release style hoisting"},\r
-       { "-cfiles",1,pCFiles,      "Additional files in C or C++ to compile"},\r
-       { "-sor",0,pSor,           "Start of sorcerer group"},\r
-       { "-pccts_path",1,ppccts_path,\r
-                       "Path for $PCCTS directory (default is /usr/local/pccts)"},\r
-       { "-compiler",1,pCompiler,\r
-                       "Default compiler (default is CC/cc)"},\r
-       { "*", 0,pFile,                 "" },   /* anything else is a file */\r
-       { NULL, 0, NULL, NULL }\r
-};\r
-\r
-#ifdef __STDC__\r
-extern char *DIR(void);\r
-#else\r
-extern char *DIR();\r
-#endif\r
-\r
-#ifdef __STDC__\r
-int main(int argc, char **argv)\r
-#else\r
-int main(argc, argv)\r
-int argc;\r
-char **argv;\r
-#endif\r
-{\r
-       int i;\r
-       \r
-       if ( argc == 1 ) { help(); DIE; }\r
-       for(i=0;i<MAX_SORS;i++) num_sfiles[i]=0;\r
-       \r
-       ProcessArgs(argc-1, &(argv[1]), options);\r
-\r
-       strcpy(ATOKENBUFFER_O, ATOKENBUFFER_C);\r
-       ATOKENBUFFER_O[strlen(ATOKENBUFFER_C)-strlen(CPP_FILE_SUFFIX)] = '\0';\r
-       strcat(ATOKENBUFFER_O, OBJ_FILE_SUFFIX);\r
-       strcpy(APARSER_O, APARSER_C);\r
-       APARSER_O[strlen(APARSER_O)-strlen(CPP_FILE_SUFFIX)] = '\0';\r
-       strcat(APARSER_O, OBJ_FILE_SUFFIX);\r
-\r
-       strcpy(ASTBASE_O, ASTBASE_C);\r
-       ASTBASE_O[strlen(ASTBASE_C)-strlen(CPP_FILE_SUFFIX)] = '\0';\r
-       strcat(ASTBASE_O, OBJ_FILE_SUFFIX);\r
-\r
-       strcpy(PCCTSAST_O, PCCTSAST_C);\r
-       PCCTSAST_O[strlen(PCCTSAST_C)-strlen(CPP_FILE_SUFFIX)] = '\0';\r
-       strcat(PCCTSAST_O, OBJ_FILE_SUFFIX);\r
-\r
-       strcpy(LIST_O, LIST_C);\r
-       LIST_O[strlen(LIST_C)-strlen(CPP_FILE_SUFFIX)] = '\0';\r
-       strcat(LIST_O, OBJ_FILE_SUFFIX);\r
-\r
-       strcpy(DLEXERBASE_O, DLEXERBASE_C);\r
-       DLEXERBASE_O[strlen(DLEXERBASE_C)-strlen(CPP_FILE_SUFFIX)] = '\0';\r
-       strcat(DLEXERBASE_O, OBJ_FILE_SUFFIX);\r
-\r
-       if ( num_files == 0 ) fatal("no grammar files specified; exiting...");\r
-       if ( !gen_CPP && num_classes>0 ) {\r
-               warn("can't define classes w/o C++ mode; turning on C++ mode...\n");\r
-               gen_CPP=1;\r
-       }\r
-       if (!gen_CPP && num_sors) {\r
-               warn("can't define sorcerer group in C mode (yet); turning on C++ mode...\n");\r
-               gen_CPP=1;\r
-       }\r
-       if ( gen_CPP && num_classes==0 ) {\r
-               fatal("must define classes >0 grammar classes in C++ mode\n");\r
-       }\r
-\r
-       mk(project, files, num_files, argc, argv);\r
-       DONE;\r
-}\r
-\r
-#ifdef __STDC__\r
-void help(void)\r
-#else\r
-void help()\r
-#endif\r
-{\r
-       Opt *p = options;\r
-       static char buf[1000+1];\r
-\r
-       fprintf(stderr, "genmk [options] f1.g ... fn.g\n");\r
-       while ( p->option!=NULL && *(p->option) != '*' )\r
-       {\r
-               buf[0]='\0';\r
-               if ( p->arg ) sprintf(buf, "%s ___", p->option);\r
-               else strcpy(buf, p->option);\r
-               fprintf(stderr, "\t%-16s   %s\n", buf, p->descr);\r
-               p++;\r
-       }\r
-}\r
-\r
-#ifdef __STDC__\r
-void mk(char *project, char **files, int n, int argc, char **argv)\r
-#else\r
-void mk(project, files, n, argc, argv)\r
-char *project;\r
-char **files;\r
-int n;\r
-int argc;\r
-char **argv;\r
-#endif\r
-{\r
-       int i,j;\r
-\r
-       printf("#\n");\r
-       printf("# PCCTS makefile for: ");\r
-       pfiles(files, n, NULL);\r
-       printf("\n");\r
-       printf("#\n");\r
-       printf("# Created from:");\r
-       for (i=0; i<argc; i++) printf(" %s", argv[i]);\r
-       printf("\n");\r
-       printf("#\n");\r
-       printf("# PCCTS release 1.33MR23\n");\r
-       printf("# Project: %s\n", project);\r
-       if ( gen_CPP ) printf("# C++ output\n");\r
-       else printf("# C output\n");\r
-       if ( user_lexer ) printf("# User-defined scanner\n");\r
-       else printf("# DLG scanner\n");\r
-       if ( user_token_types!=NULL ) printf("# User-defined token types in '%s'\n", user_token_types);\r
-       else printf("# ANTLR-defined token types\n");\r
-       printf("#\n");\r
-/***********\r
-       printf(".SUFFIXES:\n.SUFFIXES:\t.o .cpp .c .h .g .i .dlg .sor\n"); \r
- ***********/\r
-       if ( user_token_types!=NULL ) {\r
-               printf("# Make sure #tokdefs directive in ANTLR grammar lists this file:\n");\r
-               printf("TOKENS = %s", user_token_types);\r
-       }\r
-       else printf("TOKENS = %stokens.h", DIR());\r
-       printf("\n");\r
-       printf("#\n");\r
-       printf("# The following filenames must be consistent with ANTLR/DLG flags\n");\r
-       printf("DLG_FILE = %s%s\n", DIR(), dlg);\r
-       printf("ERR = %serr\n", DIR());\r
-       if ( strcmp(hdr,"stdpccts.h")!=0 ) printf("HDR_FILE = %s%s\n", DIR(), hdr);\r
-       else printf("HDR_FILE =\n");\r
-       if ( !gen_CPP ) printf("MOD_FILE = %s%s\n", DIR(), mode);\r
-       if ( !gen_CPP ) printf("SCAN = %s\n", scan);\r
-       else printf("SCAN = %s%s\n", DIR(), dlg_class);\r
-\r
-       printf("PCCTS = %s\n",pccts_path);\r
-       printf("ANTLR_H = $(PCCTS)%sh\n", DirectorySymbol);\r
-       if (num_sors>0) {\r
-               printf("SOR_H = $(PCCTS)%ssorcerer%sh\n", DirectorySymbol, DirectorySymbol);\r
-               printf("SOR_LIB = $(PCCTS)%ssorcerer%slib\n",\r
-                               DirectorySymbol, DirectorySymbol);\r
-       }\r
-       printf("BIN = $(PCCTS)%sbin\n", DirectorySymbol);\r
-       printf("ANTLR = $(BIN)%santlr\n", DirectorySymbol);\r
-       printf("DLG = $(BIN)%sdlg\n", DirectorySymbol);\r
-       if (num_sors>0) printf("SOR = $(BIN)%ssor\n", DirectorySymbol);\r
-       printf("CFLAGS = -I. -I$(ANTLR_H)");\r
-       if (num_sors>0) printf(" -I$(SOR_H)");\r
-       if ( strcmp(outdir, ".")!=0 ) printf(" -I%s", outdir);\r
-       printf(" $(COTHER)");\r
-       printf("\n");\r
-       printf("AFLAGS =");\r
-       if ( strcmp(outdir,".")!=0 ) printf(" -o %s", outdir);\r
-       if ( user_lexer ) printf(" -gx");\r
-       if ( gen_CPP ) printf(" -CC");\r
-       if ( strcmp(hdr,"stdpccts.h")!=0 ) printf(" -gh %s", hdr);\r
-       if ( gen_trees ) printf(" -gt");\r
-       if ( gen_hoist ) {\r
-               printf(" -mrhoist on") ;\r
-       } else {\r
-               printf(" -mrhoist off");\r
-       };\r
-       printf(" $(AOTHER)");\r
-       printf("\n");\r
-       printf("DFLAGS = -C2 -i");\r
-       if ( gen_CPP ) printf(" -CC");\r
-       if ( strcmp(dlg_class,"DLGLexer")!=0 ) printf(" -cl %s", dlg_class);\r
-       if ( strcmp(outdir,".")!=0 ) printf(" -o %s", outdir);\r
-       printf(" $(DOTHER)");\r
-       printf("\n");\r
-       if (num_sors>0)\r
-       {\r
-               printf("SFLAGS = -CPP");\r
-               if ( strcmp(outdir,".")!=0 ) printf(" -out-dir %s", outdir);\r
-               printf(" $(SOTHER)\n");\r
-       }\r
-       printf("GRM = ");\r
-       pfiles(files, n, NULL);\r
-       printf("\n");\r
-       printf("SRC = ");\r
-       if ( gen_CPP ) pfiles(files, n, CPP_FILE_SUFFIX_NO_DOT);\r
-       else pfiles(files, n, "c");\r
-       if ( gen_CPP ) {\r
-               printf(" \\\n\t");\r
-               pclasses(classes, num_classes, CPP_FILE_SUFFIX_NO_DOT);\r
-               printf(" \\\n\t");\r
-               printf("$(ANTLR_H)%s%s", DirectorySymbol, APARSER_C);\r
-               if ( !user_lexer ) printf(" $(ANTLR_H)%s%s", DirectorySymbol, DLEXERBASE_C);\r
-               if ( gen_trees ) {\r
-                       printf(" \\\n\t");\r
-                       printf("$(ANTLR_H)%s%s", DirectorySymbol, ASTBASE_C);\r
-                       printf(" $(ANTLR_H)%s%s", DirectorySymbol, PCCTSAST_C);\r
-/*                     printf(" $(ANTLR_H)%s%s", DirectorySymbol, LIST_C); */\r
-                       printf(" \\\n\t");\r
-               }\r
-               printf(" $(ANTLR_H)%s%s", DirectorySymbol, ATOKENBUFFER_C);\r
-       }\r
-       if ( !user_lexer ) {\r
-               if ( gen_CPP ) printf(" $(SCAN)%s", CPP_FILE_SUFFIX);\r
-               else printf(" %s$(SCAN).c", DIR());\r
-       }\r
-       if ( !gen_CPP ) printf(" $(ERR).c");\r
-       for (i=0;i<num_sors;i++)\r
-       {\r
-               printf(" \\\n\t");\r
-               pclasses(&sclasses[i],1,CPP_FILE_SUFFIX_NO_DOT);\r
-               printf(" ");\r
-               pfiles(&sfiles[i][0],num_sfiles[i],CPP_FILE_SUFFIX_NO_DOT);\r
-       }\r
-       if(num_sors>0)\r
-               printf(" \\\n\t$(SOR_LIB)%sSTreeParser.cpp", DirectorySymbol);\r
-       if (num_cfiles>0)\r
-       {\r
-               printf(" \\\n\t");\r
-               pfiles(cfiles,num_cfiles,NULL);\r
-       }\r
-       printf("\n\n");\r
-       printf("OBJ = ");\r
-       pfiles(files, n, "o");\r
-       if ( gen_CPP ) {\r
-               printf(" \\\n\t");\r
-               pclasses(classes, num_classes, "o");\r
-               printf(" \\\n\t");\r
-               printf("%s%s", DIR(), APARSER_O);\r
-               if ( !user_lexer ) {\r
-                       printf(" %s%s", DIR(), DLEXERBASE_O);\r
-               }\r
-               if ( gen_trees ) {\r
-                       printf(" \\\n\t");\r
-                       printf("%s%s", DIR(), ASTBASE_O);\r
-                       printf(" %s%s", DIR(), PCCTSAST_O);\r
-/*                     printf(" %s%s", DIR(), LIST_O); */\r
-                       printf(" \\\n\t");\r
-               }\r
-               printf(" %s%s", DIR(), ATOKENBUFFER_O);\r
-       }\r
-       if ( !user_lexer ) {\r
-               if ( gen_CPP ) printf(" $(SCAN)%s", OBJ_FILE_SUFFIX);\r
-               else printf(" %s$(SCAN)%s", DIR(), OBJ_FILE_SUFFIX);\r
-       }\r
-       if ( !gen_CPP ) printf(" $(ERR)%s", OBJ_FILE_SUFFIX);\r
-       for (i=0;i<num_sors;i++)\r
-       {\r
-               printf(" \\\n\t");\r
-               pclasses(&sclasses[i],1,"o");\r
-               printf(" ");\r
-               pfiles(&sfiles[i][0],num_sfiles[i],"o");\r
-       }\r
-       if(num_sors>0) printf(" \\\n\tSTreeParser.o");\r
-       if (num_cfiles>0)\r
-       {\r
-               printf(" \\\n\t");\r
-               pfiles(cfiles,num_cfiles,"o");\r
-       }\r
-       printf("\n\n");\r
-\r
-       printf("ANTLR_SPAWN = ");\r
-       if ( gen_CPP ) pfiles(files, n, CPP_FILE_SUFFIX_NO_DOT);\r
-       else pfiles(files, n, "c");\r
-       if ( gen_CPP ) {\r
-               printf(" ");\r
-               pclasses(classes, num_classes, CPP_FILE_SUFFIX_NO_DOT);\r
-               printf(" \\\n\t\t");\r
-               pclasses(classes, num_classes, "h");\r
-               if ( strcmp(hdr,"stdpccts.h")!=0 ) {\r
-                       printf(" \\\n\t\t");\r
-                       printf("$(HDR_FILE) stdpccts.h");\r
-               }\r
-       }\r
-       if ( user_lexer ) {\r
-               if ( !user_token_types ) printf(" $(TOKENS)");\r
-       }\r
-       else {\r
-               printf(" $(DLG_FILE)");\r
-               if ( !user_token_types ) printf(" $(TOKENS)");\r
-       }\r
-       if ( !gen_CPP ) printf(" $(ERR).c");\r
-       printf("\n");\r
-\r
-       if ( !user_lexer ) {\r
-               if ( gen_CPP ) printf("DLG_SPAWN = $(SCAN)%s", CPP_FILE_SUFFIX);\r
-               else printf("DLG_SPAWN = %s$(SCAN).c", DIR());\r
-               if ( gen_CPP ) printf(" $(SCAN).h");\r
-               if ( !gen_CPP ) printf(" $(MOD_FILE)");\r
-               printf("\n");\r
-       }\r
-\r
-       if ( gen_CPP ) {\r
-               if ( !nondef_comp )\r
-                       printf("ifdef CXX\nCCC = $(CXX)\nendif\n\nifndef CCC\n");\r
-               printf("CCC = %s\n",compilerCCC);\r
-               if ( !nondef_comp ) printf("endif\n\n");\r
-       }\r
-       else\r
-       {\r
-               if ( !nondef_comp ) printf("ifndef CC\n");\r
-               printf("CC = %s\n",compilerCC);\r
-               if ( !nondef_comp ) printf("endif\n\n");\r
-       }\r
-\r
-       /* set up dependencies */\r
-       printf("\n%s : $(SRC) $(OBJ)\n", project);\r
-       printf("\t%s %s %s $(CFLAGS) $(OBJ)\n",\r
-               gen_CPP?"$(CCC)":"$(CC)",\r
-               RENAME_EXE_FLAG,\r
-               project);\r
-       printf("\n");\r
-\r
-       /* implicit rules */\r
-\r
-/*     if(gen_CPP)\r
-               printf("%%.o : %%.cpp\n\t$(CCC) -c $(CFLAGS) $<\n\n");\r
-\r
-       printf("%%.o : %%.c\n\t%s -c $(CFLAGS) $<\n\n",\r
-                       gen_CPP?"$(CCC)":"$(CC)");\r
-*/\r
-       /* how to compile parser files */\r
-\r
-       for (i=0; i<num_files; i++)\r
-       {\r
-               pfiles(&files[i], 1, "o");\r
-               if ( user_lexer ) {\r
-                       printf(" : $(TOKENS)");\r
-               }\r
-               else {\r
-                       if ( gen_CPP ) printf(" : $(TOKENS) $(SCAN).h");\r
-                       else printf(" : $(MOD_FILE) $(TOKENS)");\r
-               }\r
-               printf(" ");\r
-               if ( gen_CPP ) pfiles(&files[i], 1, CPP_FILE_SUFFIX_NO_DOT);\r
-               else pfiles(&files[i], 1, "c");\r
-               if ( gen_CPP && strcmp(hdr,"stdpccts.h")!=0 ) printf(" $(HDR_FILE)");\r
-               printf("\n");\r
-               printf("\t%s -c $(CFLAGS) %s ",\r
-                       gen_CPP?"$(CCC)":"$(CC)",RENAME_OBJ_FLAG);\r
-               pfiles(&files[i], 1, "o");\r
-               printf(" ");\r
-               if ( gen_CPP ) pfiles(&files[i], 1, CPP_FILE_SUFFIX_NO_DOT);\r
-               else pfiles(&files[i], 1, "c");\r
-               printf("\n\n");\r
-       }\r
-\r
-       for (i=0; i<num_cfiles; i++)\r
-       {\r
-               pfiles(&cfiles[i], 1, "o");\r
-               printf(" : ");\r
-               pfiles(&cfiles[i], 1, NULL);\r
-               if ( gen_CPP && strcmp(hdr,"stdpccts.h")!=0 ) printf(" $(HDR_FILE)");\r
-/***   printf(" "); ***/\r
-/***   pfiles(&cfiles[i], 1, "h"); ***/\r
-               printf("\n");\r
-               printf("\t%s -c $(CFLAGS) %s ",\r
-                       gen_CPP?"$(CCC)":"$(CC)",RENAME_OBJ_FLAG);\r
-               pfiles(&cfiles[i], 1, "o");\r
-               printf(" ");\r
-               pfiles(&cfiles[i], 1, NULL);\r
-               printf("\n\n");\r
-\r
-/*\r
- *             pfiles(&cfiles[i], 1, "h");\r
- *             printf(" :\ntouch ");\r
- *             pfiles(&cfiles[i], 1, "h");\r
- *             printf("\n\n");\r
- */\r
-       }\r
-\r
-       /* how to compile err.c */\r
-       if ( !gen_CPP ) {\r
-               printf("$(ERR)%s : $(ERR).c", OBJ_FILE_SUFFIX);\r
-               if ( !user_lexer ) printf(" $(TOKENS)");\r
-               printf("\n");\r
-               printf("\t%s -c $(CFLAGS) %s $(ERR)%s $(ERR).c",\r
-                       gen_CPP?"$(CCC)":"$(CC)",\r
-                       RENAME_OBJ_FLAG,\r
-                       OBJ_FILE_SUFFIX);\r
-               printf("\n\n");\r
-       }\r
-\r
-       /* how to compile Class.c */\r
-       for (i=0; i<num_classes; i++)\r
-       {\r
-               pclasses(&classes[i], 1, "o");\r
-               if ( user_lexer ) {\r
-                       printf(" : $(TOKENS)");\r
-               }\r
-               else {\r
-                       printf(" : $(TOKENS) $(SCAN).h");\r
-               }\r
-               printf(" ");\r
-               pclasses(&classes[i], 1, CPP_FILE_SUFFIX_NO_DOT);\r
-               printf(" ");\r
-               pclasses(&classes[i], 1, "h");\r
-               if ( gen_CPP && strcmp(hdr,"stdpccts.h")!=0 ) printf(" $(HDR_FILE)");\r
-               printf("\n");\r
-               printf("\t%s -c $(CFLAGS) %s ",\r
-                       gen_CPP?"$(CCC)":"$(CC)",\r
-                       RENAME_OBJ_FLAG);\r
-               pclasses(&classes[i], 1, "o");\r
-               printf(" ");\r
-               pclasses(&classes[i], 1, CPP_FILE_SUFFIX_NO_DOT);\r
-               printf("\n\n");\r
-       }\r
-\r
-       /* how to compile scan.c */\r
-       if ( !user_lexer ) {\r
-               if ( gen_CPP ) printf("$(SCAN)%s : $(SCAN)%s", OBJ_FILE_SUFFIX, CPP_FILE_SUFFIX);\r
-               else printf("%s$(SCAN)%s : %s$(SCAN).c", DIR(), OBJ_FILE_SUFFIX, DIR());\r
-               if ( !user_lexer ) printf(" $(TOKENS)");\r
-               printf("\n");\r
-               if ( gen_CPP ) printf("\t$(CCC) -c $(CFLAGS) %s $(SCAN)%s $(SCAN)%s",\r
-                                                       RENAME_OBJ_FLAG,\r
-                                                       OBJ_FILE_SUFFIX,\r
-                                                       CPP_FILE_SUFFIX);\r
-               else printf("\t$(CC) -c $(CFLAGS) %s %s$(SCAN)%s %s$(SCAN).c",\r
-                                       RENAME_OBJ_FLAG,\r
-                                       DIR(),\r
-                                       OBJ_FILE_SUFFIX,\r
-                                       DIR());\r
-               printf("\n\n");\r
-       }\r
-/* how to compile sorcerer classes */\r
-       for (i=0;i<num_sors;i++)\r
-       {\r
-               pclasses(&sclasses[i], 1, "o");\r
-               printf(" : ");\r
-               pclasses(&sclasses[i], 1, CPP_FILE_SUFFIX_NO_DOT);\r
-               printf(" ");\r
-               pclasses(&sclasses[i], 1, "h");\r
-               if ( gen_CPP && strcmp(hdr,"stdpccts.h")!=0 ) printf(" $(HDR_FILE)");\r
-               printf("\n");\r
-               printf("\t%s -c $(CFLAGS) %s ",\r
-                               gen_CPP?"$(CCC)":"$(CC)",\r
-                               RENAME_OBJ_FLAG);\r
-               pclasses(&sclasses[i], 1, "o");\r
-               printf(" ");\r
-               pclasses(&sclasses[i], 1, CPP_FILE_SUFFIX_NO_DOT);\r
-               printf("\n\n");\r
-/* how to compile i-th sorcerer's files*/\r
-               for (j=0; j<num_sfiles[i]; j++)\r
-               {\r
-                       pfiles(&sfiles[i][j], 1, "o");\r
-                       printf(" : ");\r
-                       if ( gen_CPP ) pfiles(&sfiles[i][j], 1, CPP_FILE_SUFFIX_NO_DOT);\r
-                       else pfiles(&sfiles[i][j], 1, "c");\r
-                       if ( gen_CPP && strcmp(hdr,"stdpccts.h")!=0 ) printf(" $(HDR_FILE)");\r
-                       printf("\n");\r
-                       printf("\t%s -c $(CFLAGS) %s ",\r
-                                       gen_CPP?"$(CCC)":"$(CC)",RENAME_OBJ_FLAG);\r
-                       pfiles(&sfiles[i][j], 1, "o");\r
-                       printf(" ");\r
-                       if ( gen_CPP ) pfiles(&sfiles[i][j], 1, CPP_FILE_SUFFIX_NO_DOT);\r
-                       else pfiles(&sfiles[i][j], 1, "c");\r
-                       printf("\n\n");\r
-               }\r
-               if ( gen_CPP ) pfiles(&sfiles[i][0], num_sfiles[i], CPP_FILE_SUFFIX_NO_DOT);\r
-               else pfiles(&sfiles[i][0], num_sfiles[i], "c");\r
-               if ( gen_CPP )\r
-               {\r
-                       printf(" ");\r
-                       pclasses(&sclasses[i], 1, CPP_FILE_SUFFIX_NO_DOT);\r
-                       printf(" ");\r
-                       pclasses(&sclasses[i], 1, "h");\r
-                       if ( strcmp(hdr,"stdpccts.h")!=0 ) \r
-                       {\r
-                               printf(" ");\r
-                               printf("$(HDR_FILE) stdpccts.h");\r
-                       }\r
-               }\r
-               printf(" : ");\r
-               pfiles(&sfiles[i][0],num_sfiles[i],NULL);\r
-               printf("\n\t$(SOR) $(SFLAGS) ");\r
-               pfiles(&sfiles[i][0],num_sfiles[i],NULL);\r
-               printf("\n\n");\r
-       }\r
-       if(num_sors>0)\r
-       {\r
-               printf("STreeParser%s : $(SOR_LIB)%sSTreeParser.cpp\n",\r
-                               OBJ_FILE_SUFFIX,DirectorySymbol);\r
-               printf("\t%s -c $(CFLAGS) %s ",\r
-                               gen_CPP?"$(CCC)":"$(CC)",RENAME_OBJ_FLAG);\r
-               printf("STreeParser%s ",OBJ_FILE_SUFFIX);\r
-               printf("$(SOR_LIB)%sSTreeParser.cpp\n\n",DirectorySymbol);\r
-       }\r
-       \r
-       printf("$(ANTLR_SPAWN) : $(GRM)\n");\r
-       printf("\t$(ANTLR) $(AFLAGS) $(GRM)\n");\r
-\r
-       if ( !user_lexer )\r
-       {\r
-               printf("\n");\r
-               printf("$(DLG_SPAWN) : $(DLG_FILE)\n");\r
-               if ( gen_CPP ) printf("\t$(DLG) $(DFLAGS) $(DLG_FILE)\n");\r
-               else printf("\t$(DLG) $(DFLAGS) $(DLG_FILE) $(SCAN).c\n");\r
-       }\r
-\r
-       /* do the makes for ANTLR/DLG support */\r
-       if ( gen_CPP ) {\r
-               printf("\n");\r
-               printf("%s%s : $(ANTLR_H)%s%s\n", DIR(), APARSER_O, DirectorySymbol, APARSER_C);\r
-               printf("\t%s -c $(CFLAGS) %s ",\r
-                               gen_CPP?"$(CCC)":"$(CC)",\r
-                               RENAME_OBJ_FLAG);\r
-               printf("%s%s $(ANTLR_H)%s%s\n", DIR(), APARSER_O, DirectorySymbol, APARSER_C);\r
-               printf("\n");\r
-               printf("%s%s : $(ANTLR_H)%s%s\n", DIR(), ATOKENBUFFER_O, DirectorySymbol, ATOKENBUFFER_C);\r
-               printf("\t%s -c $(CFLAGS) %s ",\r
-                               gen_CPP?"$(CCC)":"$(CC)",\r
-                               RENAME_OBJ_FLAG);\r
-               printf("%s%s $(ANTLR_H)%s%s\n", DIR(), ATOKENBUFFER_O, DirectorySymbol, ATOKENBUFFER_C);\r
-               if ( !user_lexer ) {\r
-                       printf("\n");\r
-                       printf("%s%s : $(ANTLR_H)%s%s\n", DIR(), DLEXERBASE_O, DirectorySymbol, DLEXERBASE_C);\r
-                       printf("\t%s -c $(CFLAGS) %s ",\r
-                                       gen_CPP?"$(CCC)":"$(CC)",\r
-                                       RENAME_OBJ_FLAG);\r
-                       printf("%s%s $(ANTLR_H)%s%s\n", DIR(), DLEXERBASE_O, DirectorySymbol, DLEXERBASE_C);\r
-               }\r
-               if ( gen_trees ) {\r
-                       printf("\n");\r
-                       printf("%s%s : $(ANTLR_H)%s%s\n", DIR(), ASTBASE_O, DirectorySymbol, ASTBASE_C);\r
-                       printf("\t%s -c $(CFLAGS) %s ",\r
-                                       gen_CPP?"$(CCC)":"$(CC)",\r
-                                       RENAME_OBJ_FLAG);\r
-                       printf("%s%s $(ANTLR_H)%s%s\n", DIR(), ASTBASE_O, DirectorySymbol, ASTBASE_C);\r
-                       printf("\n");\r
-                       printf("%s%s : $(ANTLR_H)%s%s\n", DIR(), PCCTSAST_O, DirectorySymbol, PCCTSAST_C);\r
-                       printf("\t%s -c $(CFLAGS) %s ",\r
-                                       gen_CPP?"$(CCC)":"$(CC)",\r
-                                       RENAME_OBJ_FLAG);\r
-                       printf("%s%s $(ANTLR_H)%s%s\n", DIR(), PCCTSAST_O, DirectorySymbol, PCCTSAST_C);\r
-                       printf("\n");\r
-/*\r
-                       printf("%s%s : $(ANTLR_H)%s%s\n", DIR(), LIST_O, DirectorySymbol, LIST_C);\r
-                       printf("\t%s -c $(CFLAGS) %s ",\r
-                                       gen_CPP?"$(CCC)":"$(CC)",RENAME_OBJ_FLAG);\r
-                       printf("%s%s $(ANTLR_H)%s%s\n", DIR(), LIST_O, DirectorySymbol, LIST_C);\r
-*/\r
-               }\r
-       }\r
-\r
-       /* clean and scrub targets */\r
-\r
-       printf("\nclean:\n");\r
-       printf("\trm -f *%s core %s", OBJ_FILE_SUFFIX, project);\r
-       if ( strcmp(outdir, ".")!=0 ) printf(" %s*%s", DIR(), OBJ_FILE_SUFFIX);\r
-       printf("\n");\r
-\r
-       printf("\nscrub: clean\n");\r
-/*     printf("\trm -f *%s core %s", OBJ_FILE_SUFFIX, project); */\r
-/*     if ( strcmp(outdir, ".")!=0 ) printf(" %s*%s", DIR(), OBJ_FILE_SUFFIX); */\r
-       printf("\trm -f $(ANTLR_SPAWN)");\r
-       if ( !user_lexer ) printf(" $(DLG_SPAWN)");\r
-       for (i=0;i<num_sors;i++)\r
-       {\r
-               printf(" ");\r
-               if ( gen_CPP ) pfiles(&sfiles[i][0], num_sfiles[i], CPP_FILE_SUFFIX_NO_DOT);\r
-               else pfiles(&sfiles[i][0], num_sfiles[i], "c");\r
-               if ( gen_CPP )\r
-               {\r
-                       printf(" ");\r
-                       pclasses(&sclasses[i], 1, CPP_FILE_SUFFIX_NO_DOT);\r
-                       printf(" ");\r
-                       pclasses(&sclasses[i], 1, "h");\r
-               }\r
-       }\r
-       printf("\n\n");\r
-}\r
-\r
-#ifdef __STDC__\r
-void pfiles(char **files, int n, char *suffix)\r
-#else\r
-void pfiles(files, n, suffix)\r
-char **files;\r
-int n;\r
-char *suffix;\r
-#endif\r
-{\r
-       int first=1;\r
-\r
-       while ( n>0 )\r
-       {\r
-               char *p = &(*files)[strlen(*files)-1];\r
-               if ( !first ) putchar(' ');\r
-               first=0;\r
-               while ( p > *files && *p != '.' ) --p;\r
-               if ( p == *files )\r
-               {\r
-                       fprintf(stderr,\r
-                                       "genmk: filenames must be file.suffix format: %s\n",\r
-                                       *files);\r
-                       exit(-1);\r
-               }\r
-               if ( suffix == NULL ) printf("%s", *files);\r
-               else\r
-               {\r
-                       *p = '\0';\r
-                       printf("%s", DIR());\r
-                       if ( strcmp(suffix, "o")==0 ) printf("%s%s", *files, OBJ_FILE_SUFFIX);\r
-                       else printf("%s.%s", *files, suffix);\r
-                       *p = '.';\r
-               }\r
-               files++;\r
-               --n;\r
-       }\r
-}\r
-\r
-#ifdef __STDC__\r
-pclasses(char **classes, int n, char *suffix)\r
-#else\r
-pclasses(classes, n, suffix)\r
-char **classes;\r
-int n;\r
-char *suffix;\r
-#endif\r
-{\r
-       int first=1;\r
-\r
-       while ( n>0 )\r
-       {\r
-               if ( !first ) putchar(' ');\r
-               first=0;\r
-               if ( suffix == NULL ) printf("%s", *classes);\r
-               else {\r
-                       printf("%s", DIR());\r
-                       if ( strcmp(suffix, "o")==0 ) printf("%s%s", *classes, OBJ_FILE_SUFFIX);\r
-                       else printf("%s.%s", *classes, suffix);\r
-               }\r
-               classes++;\r
-               --n;\r
-       }\r
-}\r
-\r
-static void\r
-#ifdef __STDC__\r
-ProcessArgs( int argc, char **argv, Opt *options )\r
-#else\r
-ProcessArgs( argc, argv, options )\r
-int argc;\r
-char **argv;\r
-Opt *options;\r
-#endif\r
-{\r
-       Opt *p;\r
-       require(argv!=NULL, "ProcessArgs: command line NULL");\r
-\r
-       while ( argc-- > 0 )\r
-       {\r
-               p = options;\r
-               while ( p->option != NULL )\r
-               {\r
-                       if ( strcmp(p->option, "*") == 0 ||\r
-                                strcmp(p->option, *argv) == 0 )\r
-                       {\r
-                               if ( p->arg )\r
-                               {\r
-                                       (*p->process)( *argv, *(argv+1) );\r
-                                       argv++;\r
-                                       argc--;\r
-                               }\r
-                               else\r
-                                       (*p->process)( *argv );\r
-                               break;\r
-                       }\r
-                       p++;\r
-               }\r
-               argv++;\r
-       }\r
-}\r
-\r
-#ifdef __STDC__\r
-void fatal( char *err_)\r
-#else\r
-void fatal( err_)\r
-char *err_;\r
-#endif\r
-{\r
-       fprintf(stderr, "genmk: %s\n", err_);\r
-       exit(1);\r
-}\r
-\r
-#ifdef __STDC__\r
-void warn( char *err_)\r
-#else\r
-void warn( err_)\r
-char *err_;\r
-#endif\r
-{\r
-       fprintf(stderr, "genmk: %s\n", err_);\r
-}\r
-\r
-#ifdef __STDC__\r
-char *DIR(void)\r
-#else\r
-char *DIR()\r
-#endif\r
-{\r
-       static char buf[200+1];\r
-       \r
-       if ( strcmp(outdir,TopDirectory)==0 ) return "";\r
-       sprintf(buf, "%s%s", outdir, DirectorySymbol);\r
-       return buf;\r
-}\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/support/genmk/genmk_old.c b/Tools/CodeTools/TianoTools/Pccts/support/genmk/genmk_old.c
deleted file mode 100644 (file)
index 2cf9fad..0000000
+++ /dev/null
@@ -1,762 +0,0 @@
-/*\r
- * genmk -- a program to make makefiles for PCCTS\r
- *\r
- * ANTLR 1.33MR10\r
- * Terence John Parr 1989 - 1998\r
- * Purdue University\r
- * U of MN\r
- */\r
-\r
-#include <stdio.h>\r
-#include "pcctscfg.h" /* be sensitive to what ANTLR/DLG call the files */\r
-\r
-#ifdef VAXC\r
-#define DIE            return 0;\r
-#define DONE   return 1;\r
-#else\r
-#define DIE            return 1;\r
-#define DONE   return 0;\r
-#endif\r
-\r
-#ifndef require\r
-#define require(expr, err) {if ( !(expr) ) fatal(err);}\r
-#endif\r
-\r
-#define MAX_FILES      50\r
-#define MAX_CLASSES    50\r
-\r
-char *RENAME_OBJ_FLAG="-o",\r
-     *RENAME_EXE_FLAG="-o";\r
-\r
-char *dlg = "parser.dlg";\r
-char *err = "err.c";\r
-char *hdr = "stdpccts.h";\r
-char *tok = "tokens.h";\r
-char *mode = "mode.h";\r
-char *scan = "scan";\r
-\r
-char ATOKENBUFFER_O[100];\r
-char APARSER_O[100];\r
-char ASTBASE_O[100];\r
-char PCCTSAST_O[100];\r
-char LIST_O[100];\r
-char DLEXERBASE_O[100];\r
-\r
-/* Option flags */\r
-static char *project="t", *files[MAX_FILES], *classes[MAX_CLASSES];\r
-static int     num_files = 0;\r
-static int     num_classes = 0;\r
-static int     user_lexer = 0;\r
-static char    *user_token_types = NULL;\r
-static int     gen_CPP = 0;\r
-static char *outdir=".";\r
-static char *dlg_class = "DLGLexer";\r
-static int     gen_trees = 0;\r
-static int  gen_hoist = 0;\r
-static char cfiles[1600]="";\r
-static char *compilerCCC="CC";\r
-static char *compilerCC="cc";\r
-static char *pccts_path="/usr/local/pccts";\r
-\r
-void help();\r
-void mk();\r
-void pfiles();\r
-void pclasses();\r
-void fatal();\r
-void warn();\r
-\r
-typedef struct _Opt {\r
-                       char *option;\r
-                       int  arg;\r
-#ifdef __cplusplus\r
-                       void (*process)(...);\r
-#else\r
-                       void (*process)();\r
-#endif\r
-                       char *descr;\r
-               } Opt;\r
-\r
-#ifdef __STDC__\r
-static void ProcessArgs(int, char **, Opt *);\r
-#else\r
-static void ProcessArgs();\r
-#endif\r
-\r
-static void\r
-pProj( s, t )\r
-char *s;\r
-char *t;\r
-{\r
-       project = t;\r
-}\r
-\r
-static void\r
-pUL( s )\r
-char *s;\r
-{\r
-       user_lexer = 1;\r
-}\r
-\r
-static void\r
-pCPP( s )\r
-char *s;\r
-{\r
-       gen_CPP = 1;\r
-}\r
-\r
-static void\r
-pUT( s, t )\r
-char *s;\r
-char *t;\r
-{\r
-       user_token_types = t;\r
-}\r
-\r
-static void\r
-pTrees( s )\r
-char *s;\r
-{\r
-       gen_trees = 1;\r
-}\r
-\r
-static void\r
-pHoist( s )\r
-char *s;\r
-{\r
-       gen_hoist = 1;\r
-}\r
-\r
-static void\r
-#ifdef __STDC__\r
-pFile( char *s )\r
-#else\r
-pFile( s )\r
-char *s;\r
-#endif\r
-{\r
-       if ( *s=='-' )\r
-       {\r
-               fprintf(stderr, "invalid option: '%s'; ignored...",s);\r
-               return;\r
-       }\r
-\r
-       require(num_files<MAX_FILES, "exceeded max # of input files");\r
-       files[num_files++] = s;\r
-}\r
-\r
-static void\r
-#ifdef __STDC__\r
-pClass( char *s, char *t )\r
-#else\r
-pClass( s, t )\r
-char *s;\r
-char *t;\r
-#endif\r
-{\r
-       require(num_classes<MAX_CLASSES, "exceeded max # of grammar classes");\r
-       classes[num_classes++] = t;\r
-}\r
-\r
-static void\r
-#ifdef __STDC__\r
-pDLGClass( char *s, char *t )\r
-#else\r
-pDLGClass( s, t )\r
-char *s;\r
-char *t;\r
-#endif\r
-{\r
-       if ( !gen_CPP ) {\r
-               fprintf(stderr, "-dlg-class makes no sense without C++ mode; ignored...");\r
-       }\r
-       else dlg_class = t;\r
-}\r
-\r
-static void\r
-#ifdef __STDC__\r
-pOdir( char *s, char *t )\r
-#else\r
-pOdir( s, t )\r
-char *s;\r
-char *t;\r
-#endif\r
-{\r
-       outdir = t;\r
-}\r
-\r
-static void\r
-#ifdef __STDC__\r
-pHdr( char *s, char *t )\r
-#else\r
-pHdr( s, t )\r
-char *s;\r
-char *t;\r
-#endif\r
-{\r
-       hdr = t;\r
-}\r
-\r
-static void\r
-#ifdef __STDC__\r
-pCFiles( char *s, char *t )\r
-#else\r
-pCFiles( s, t )\r
-char *s;\r
-char *t;\r
-#endif\r
-{\r
-       strcat(strcat(cfiles," "), t);\r
-}\r
-\r
-static void\r
-#ifdef __STDC__\r
-pCompiler( char *s, char *t )\r
-#else\r
-pCompiler( s, t )\r
-char *s;\r
-char *t;\r
-#endif\r
-{\r
-        compilerCCC = t;\r
-       compilerCC = t;\r
-}\r
-\r
-static void\r
-#ifdef __STDC__\r
-ppccts_path( char *s, char *t )\r
-#else\r
-ppccts_path( s, t )\r
-char *s;\r
-char *t;\r
-#endif\r
-{\r
-        pccts_path = t;\r
-}\r
-\r
-Opt options[] = {\r
-    { "-CC", 0,        pCPP,                   "Generate C++ output"},\r
-    { "-class", 1,     pClass,         "Name of a grammar class defined in grammar (if C++)"},\r
-    { "-dlg-class", 1,pDLGClass,"Name of DLG lexer class (default=DLGLexer) (if C++)"},\r
-    { "-header", 1,pHdr,               "Name of ANTLR standard header info (default=no file)"},\r
-    { "-o", 1, pOdir,                  "Directory where output files should go (default=\".\")"},\r
-    { "-project", 1,   pProj,  "Name of executable to create (default=t)"},\r
-    { "-token-types", 1, pUT,  "Token types are in this file (don't use tokens.h)"},\r
-    { "-trees", 0, pTrees,             "Generate ASTs"},\r
-    { "-user-lexer", 0,        pUL,    "Do not create a DLG-based scanner"},\r
-    { "-mrhoist",0,pHoist,      "Maintenance release style hoisting"},\r
-    { "-cfiles",1,pCFiles,      "Additional files in C or C++ to compile"},\r
-    { "-pccts_path",1,ppccts_path,\r
-              "Path for $PCCTS directory (default is /usr/local/pccts)"},\r
-    { "-compiler",1,pCompiler,\r
-              "Default compiler (default is CC/cc)"},\r
-    { "*", 0,pFile,            "" },   /* anything else is a file */\r
-       { NULL, 0, NULL, NULL }\r
-};\r
-\r
-extern char *DIR();\r
-\r
-int main(argc, argv)\r
-int argc;\r
-char **argv;\r
-{\r
-       if ( argc == 1 ) { help(); DIE; }\r
-       ProcessArgs(argc-1, &(argv[1]), options);\r
-\r
-       strcpy(ATOKENBUFFER_O, ATOKENBUFFER_C);\r
-       ATOKENBUFFER_O[strlen(ATOKENBUFFER_C)-strlen(CPP_FILE_SUFFIX)] = '\0';\r
-       strcat(ATOKENBUFFER_O, OBJ_FILE_SUFFIX);\r
-       strcpy(APARSER_O, APARSER_C);\r
-       APARSER_O[strlen(APARSER_O)-strlen(CPP_FILE_SUFFIX)] = '\0';\r
-       strcat(APARSER_O, OBJ_FILE_SUFFIX);\r
-\r
-       strcpy(ASTBASE_O, ASTBASE_C);\r
-       ASTBASE_O[strlen(ASTBASE_C)-strlen(CPP_FILE_SUFFIX)] = '\0';\r
-       strcat(ASTBASE_O, OBJ_FILE_SUFFIX);\r
-\r
-       strcpy(PCCTSAST_O, PCCTSAST_C);\r
-       PCCTSAST_O[strlen(PCCTSAST_C)-strlen(CPP_FILE_SUFFIX)] = '\0';\r
-       strcat(PCCTSAST_O, OBJ_FILE_SUFFIX);\r
-\r
-       strcpy(LIST_O, LIST_C);\r
-       LIST_O[strlen(LIST_C)-strlen(CPP_FILE_SUFFIX)] = '\0';\r
-       strcat(LIST_O, OBJ_FILE_SUFFIX);\r
-\r
-       strcpy(DLEXERBASE_O, DLEXERBASE_C);\r
-       DLEXERBASE_O[strlen(DLEXERBASE_C)-strlen(CPP_FILE_SUFFIX)] = '\0';\r
-       strcat(DLEXERBASE_O, OBJ_FILE_SUFFIX);\r
-\r
-       if ( num_files == 0 ) fatal("no grammar files specified; exiting...");\r
-       if ( !gen_CPP && num_classes>0 ) {\r
-               warn("can't define classes w/o C++ mode; turning on C++ mode...\n");\r
-               gen_CPP=1;\r
-       }\r
-       if ( gen_CPP && num_classes==0 ) {\r
-               fatal("must define classes >0 grammar classes in C++ mode\n");\r
-       }\r
-\r
-       mk(project, files, num_files, argc, argv);\r
-       DONE;\r
-}\r
-\r
-void help()\r
-{\r
-       Opt *p = options;\r
-       static char buf[1000+1];\r
-\r
-       fprintf(stderr, "genmk [options] f1.g ... fn.g\n");\r
-       while ( p->option!=NULL && *(p->option) != '*' )\r
-       {\r
-               buf[0]='\0';\r
-               if ( p->arg ) sprintf(buf, "%s ___", p->option);\r
-               else strcpy(buf, p->option);\r
-               fprintf(stderr, "\t%-16s   %s\n", buf, p->descr);\r
-               p++;\r
-       }\r
-}\r
-\r
-void mk(project, files, n, argc, argv)\r
-char *project;\r
-char **files;\r
-int n;\r
-int argc;\r
-char **argv;\r
-{\r
-       int i;\r
-\r
-       printf("#\n");\r
-       printf("# PCCTS makefile for: ");\r
-       pfiles(files, n, NULL);\r
-       printf("\n");\r
-       printf("#\n");\r
-       printf("# Created from:");\r
-       for (i=0; i<argc; i++) printf(" %s", argv[i]);\r
-       printf("\n");\r
-       printf("#\n");\r
-       printf("# PCCTS release 1.33MR21\n");\r
-       printf("# Project: %s\n", project);\r
-       if ( gen_CPP ) printf("# C++ output\n");\r
-       else printf("# C output\n");\r
-       if ( user_lexer ) printf("# User-defined scanner\n");\r
-       else printf("# DLG scanner\n");\r
-       if ( user_token_types!=NULL ) printf("# User-defined token types in '%s'\n", user_token_types);\r
-       else printf("# ANTLR-defined token types\n");\r
-       printf("#\n");\r
-       printf(".SUFFIXES:\n.SUFFIXES:      .o .cpp .c .h .g .i .dlg\n"); \r
-       if ( user_token_types!=NULL ) {\r
-               printf("# Make sure #tokdefs directive in ANTLR grammar lists this file:\n");\r
-               printf("TOKENS = %s", user_token_types);\r
-       }\r
-       else printf("TOKENS = %stokens.h", DIR());\r
-       printf("\n");\r
-       printf("#\n");\r
-       printf("# The following filenames must be consistent with ANTLR/DLG flags\n");\r
-       printf("DLG_FILE = %s%s\n", DIR(), dlg);\r
-       printf("ERR = %serr\n", DIR());\r
-       if ( strcmp(hdr,"stdpccts.h")!=0 ) printf("HDR_FILE = %s%s\n", DIR(), hdr);\r
-       else printf("HDR_FILE =\n");\r
-       if ( !gen_CPP ) printf("MOD_FILE = %s%s\n", DIR(), mode);\r
-       if ( !gen_CPP ) printf("SCAN = %s\n", scan);\r
-       else printf("SCAN = %s%s\n", DIR(), dlg_class);\r
-\r
-       printf("PCCTS = %s\n",pccts_path);\r
-       printf("ANTLR_H = $(PCCTS)%sh\n", DirectorySymbol);\r
-       printf("BIN = $(PCCTS)%sbin\n", DirectorySymbol);\r
-       printf("ANTLR = $(BIN)%santlr\n", DirectorySymbol);\r
-       printf("DLG = $(BIN)%sdlg\n", DirectorySymbol);\r
-       printf("CFLAGS = -I. -I$(ANTLR_H)");\r
-       if ( strcmp(outdir, ".")!=0 ) printf(" -I%s", outdir);\r
-    printf(" $(COTHER)");\r
-       printf("\n");\r
-       printf("AFLAGS =");\r
-       if ( strcmp(outdir,".")!=0 ) printf(" -o %s", outdir);\r
-       if ( user_lexer ) printf(" -gx");\r
-       if ( gen_CPP ) printf(" -CC");\r
-       if ( strcmp(hdr,"stdpccts.h")!=0 ) printf(" -gh %s", hdr);\r
-       if ( gen_trees ) printf(" -gt");\r
-    if ( gen_hoist ) {\r
-      printf(" -mrhoist on") ;\r
-    } else {\r
-      printf(" -mrhoist off");\r
-    };\r
-    printf(" $(AOTHER)");\r
-       printf("\n");\r
-       printf("DFLAGS = -C2 -i");\r
-       if ( gen_CPP ) printf(" -CC");\r
-       if ( strcmp(dlg_class,"DLGLexer")!=0 ) printf(" -cl %s", dlg_class);\r
-       if ( strcmp(outdir,".")!=0 ) printf(" -o %s", outdir);\r
-    printf(" $(DOTHER)");\r
-       printf("\n");\r
-       printf("GRM = ");\r
-       pfiles(files, n, NULL);\r
-       printf("\n");\r
-       printf("MYFILES = %s\n",cfiles);\r
-       printf("SRC = ");\r
-       if ( gen_CPP ) pfiles(files, n, CPP_FILE_SUFFIX_NO_DOT);\r
-       else pfiles(files, n, "c");\r
-       if ( gen_CPP ) {\r
-               printf(" \\\n     ");\r
-               printf(" ");\r
-               pclasses(classes, num_classes, CPP_FILE_SUFFIX_NO_DOT);\r
-               printf(" \\\n      ");\r
-               printf("$(ANTLR_H)%s%s", DirectorySymbol, APARSER_C);\r
-               if ( !user_lexer ) printf(" $(ANTLR_H)%s%s", DirectorySymbol, DLEXERBASE_C);\r
-               if ( gen_trees ) {\r
-                       printf(" \\\n      ");\r
-                       printf("$(ANTLR_H)%s%s", DirectorySymbol, ASTBASE_C);\r
-                       printf(" $(ANTLR_H)%s%s", DirectorySymbol, PCCTSAST_C);\r
-/*                     printf(" $(ANTLR_H)%s%s", DirectorySymbol, LIST_C); */\r
-                       printf(" \\\n      ");\r
-               }\r
-               printf(" $(ANTLR_H)%s%s", DirectorySymbol, ATOKENBUFFER_C);\r
-       }\r
-       if ( !user_lexer ) {\r
-               if ( gen_CPP ) printf(" $(SCAN)%s", CPP_FILE_SUFFIX);\r
-               else printf(" %s$(SCAN).c", DIR());\r
-       }\r
-       if ( !gen_CPP ) printf(" $(ERR).c");\r
-       printf("\\\n    $(MYFILES)\n");\r
-       printf("OBJ = ");\r
-       pfiles(files, n, "o");\r
-       if ( gen_CPP ) {\r
-               printf(" \\\n     ");\r
-               printf(" ");\r
-               pclasses(classes, num_classes, "o");\r
-               printf(" \\\n      ");\r
-               printf(" %s%s", DIR(), APARSER_O);\r
-               if ( !user_lexer ) {\r
-                       printf(" %s%s", DIR(), DLEXERBASE_O);\r
-               }\r
-               if ( gen_trees ) {\r
-                       printf(" \\\n      ");\r
-                       printf("%s%s", DIR(), ASTBASE_O);\r
-                       printf(" %s%s", DIR(), PCCTSAST_O);\r
-/*                     printf(" %s%s", DIR(), LIST_O); */\r
-                       printf(" \\\n      ");\r
-               }\r
-               printf(" %s%s", DIR(), ATOKENBUFFER_O);\r
-       }\r
-       if ( !user_lexer ) {\r
-               if ( gen_CPP ) printf(" $(SCAN)%s", OBJ_FILE_SUFFIX);\r
-               else printf(" %s$(SCAN)%s", DIR(), OBJ_FILE_SUFFIX);\r
-       }\r
-       if ( !gen_CPP ) printf(" $(ERR)%s", OBJ_FILE_SUFFIX);\r
-       printf("\\\n    $(MYFILES:.cpp=.o)\n");\r
-\r
-       printf("ANTLR_SPAWN = ");\r
-       if ( gen_CPP ) pfiles(files, n, CPP_FILE_SUFFIX_NO_DOT);\r
-       else pfiles(files, n, "c");\r
-       if ( gen_CPP ) {\r
-               printf(" ");\r
-               pclasses(classes, num_classes, CPP_FILE_SUFFIX_NO_DOT);\r
-               printf(" \\\n              ");\r
-               pclasses(classes, num_classes, "h");\r
-               if ( strcmp(hdr,"stdpccts.h")!=0 ) {\r
-                       printf(" \\\n              ");\r
-                       printf("$(HDR_FILE) stdpccts.h");\r
-               }\r
-       }\r
-       if ( user_lexer ) {\r
-               if ( !user_token_types ) printf(" $(TOKENS)");\r
-       }\r
-       else {\r
-               printf(" $(DLG_FILE)");\r
-               if ( !user_token_types ) printf(" $(TOKENS)");\r
-       }\r
-       if ( !gen_CPP ) printf(" $(ERR).c");\r
-       printf("\n");\r
-\r
-       if ( !user_lexer ) {\r
-               if ( gen_CPP ) printf("DLG_SPAWN = $(SCAN)%s", CPP_FILE_SUFFIX);\r
-               else printf("DLG_SPAWN = %s$(SCAN).c", DIR());\r
-               if ( gen_CPP ) printf(" $(SCAN).h");\r
-               if ( !gen_CPP ) printf(" $(MOD_FILE)");\r
-               printf("\n");\r
-       }\r
-\r
-       if ( gen_CPP ) {\r
-               printf("CCC = %s\n",compilerCCC);\r
-       }\r
-       else printf("CC = %s\n",compilerCC);\r
-\r
-       /* set up dependencies */\r
-       printf("\n%s : $(OBJ) $(SRC)\n", project);\r
-       printf("        %s %s %s $(CFLAGS) $(OBJ)\n",\r
-                  gen_CPP?"$(CCC)":"$(CC)",\r
-                  RENAME_EXE_FLAG,\r
-                  project);\r
-       printf("\n");\r
-\r
-       /* implicit rules */\r
-\r
-       if(gen_CPP)\r
-               printf("%%.o : %%.cpp\n\t$(CCC) -c $(CFLAGS) $<\n\n");\r
-\r
-       printf("%%.o : %%.c\n\t%s -c $(CFLAGS) $<\n\n",\r
-                       gen_CPP?"$(CCC)":"$(CC)");\r
-\r
-       /* how to compile parser files */\r
-\r
-       for (i=0; i<num_files; i++)\r
-       {\r
-               pfiles(&files[i], 1, "o");\r
-               if ( user_lexer ) {\r
-                       printf(" : $(TOKENS)");\r
-               }\r
-               else {\r
-                       if ( gen_CPP ) printf(" : $(TOKENS) $(SCAN).h");\r
-                       else printf(" : $(MOD_FILE) $(TOKENS)");\r
-               }\r
-               printf(" ");\r
-               if ( gen_CPP ) pfiles(&files[i], 1, CPP_FILE_SUFFIX_NO_DOT);\r
-               else pfiles(&files[i], 1, "c");\r
-               if ( gen_CPP && strcmp(hdr,"stdpccts.h")!=0 ) printf(" $(HDR_FILE)");\r
-               printf("\n");\r
-               printf("        %s -c $(CFLAGS) %s ",\r
-                      gen_CPP?"$(CCC)":"$(CC)",RENAME_OBJ_FLAG);\r
-               pfiles(&files[i], 1, "o");\r
-               printf(" ");\r
-               if ( gen_CPP ) pfiles(&files[i], 1, CPP_FILE_SUFFIX_NO_DOT);\r
-               else pfiles(&files[i], 1, "c");\r
-               printf("\n\n");\r
-       }\r
-\r
-       /* how to compile err.c */\r
-       if ( !gen_CPP ) {\r
-               printf("$(ERR)%s : $(ERR).c", OBJ_FILE_SUFFIX);\r
-               if ( !user_lexer ) printf(" $(TOKENS)");\r
-               printf("\n");\r
-               printf("        %s -c $(CFLAGS) %s $(ERR)%s $(ERR).c",\r
-                          gen_CPP?"$(CCC)":"$(CC)",\r
-                          RENAME_OBJ_FLAG,\r
-                          OBJ_FILE_SUFFIX);\r
-               printf("\n\n");\r
-       }\r
-\r
-       /* how to compile Class.c */\r
-       for (i=0; i<num_classes; i++)\r
-       {\r
-               pclasses(&classes[i], 1, "o");\r
-               if ( user_lexer ) {\r
-                       printf(" : $(TOKENS)");\r
-               }\r
-               else {\r
-                       printf(" : $(TOKENS) $(SCAN).h");\r
-               }\r
-               printf(" ");\r
-               pclasses(&classes[i], 1, CPP_FILE_SUFFIX_NO_DOT);\r
-               printf(" ");\r
-               pclasses(&classes[i], 1, "h");\r
-               if ( gen_CPP && strcmp(hdr,"stdpccts.h")!=0 ) printf(" $(HDR_FILE)");\r
-               printf("\n");\r
-               printf("        %s -c $(CFLAGS) %s ",\r
-                          gen_CPP?"$(CCC)":"$(CC)",\r
-                          RENAME_OBJ_FLAG);\r
-               pclasses(&classes[i], 1, "o");\r
-               printf(" ");\r
-               pclasses(&classes[i], 1, CPP_FILE_SUFFIX_NO_DOT);\r
-               printf("\n\n");\r
-       }\r
-\r
-       /* how to compile scan.c */\r
-       if ( !user_lexer ) {\r
-               if ( gen_CPP ) printf("$(SCAN)%s : $(SCAN)%s", OBJ_FILE_SUFFIX, CPP_FILE_SUFFIX);\r
-               else printf("%s$(SCAN)%s : %s$(SCAN).c", DIR(), OBJ_FILE_SUFFIX, DIR());\r
-               if ( !user_lexer ) printf(" $(TOKENS)");\r
-               printf("\n");\r
-               if ( gen_CPP ) printf(" $(CCC) -c $(CFLAGS) %s $(SCAN)%s $(SCAN)%s",\r
-                                                         RENAME_OBJ_FLAG,\r
-                                                         OBJ_FILE_SUFFIX,\r
-                                                         CPP_FILE_SUFFIX);\r
-               else printf("   $(CC) -c $(CFLAGS) %s %s$(SCAN)%s %s$(SCAN).c",\r
-                                       RENAME_OBJ_FLAG,\r
-                                       DIR(),\r
-                                       OBJ_FILE_SUFFIX,\r
-                                       DIR());\r
-               printf("\n\n");\r
-       }\r
-\r
-       printf("$(ANTLR_SPAWN) : $(GRM)\n");\r
-       printf("        $(ANTLR) $(AFLAGS) $(GRM)\n");\r
-\r
-       if ( !user_lexer )\r
-       {\r
-               printf("\n");\r
-               printf("$(DLG_SPAWN) : $(DLG_FILE)\n");\r
-               if ( gen_CPP ) printf(" $(DLG) $(DFLAGS) $(DLG_FILE)\n");\r
-               else printf("   $(DLG) $(DFLAGS) $(DLG_FILE) $(SCAN).c\n");\r
-       }\r
-\r
-       /* do the makes for ANTLR/DLG support */\r
-       if ( gen_CPP ) {\r
-               printf("\n");\r
-               printf("%s%s : $(ANTLR_H)%s%s\n", DIR(), APARSER_O, DirectorySymbol, APARSER_C);\r
-               printf("        %s -c $(CFLAGS) %s ",\r
-                          gen_CPP?"$(CCC)":"$(CC)",\r
-                          RENAME_OBJ_FLAG);\r
-               printf("%s%s $(ANTLR_H)%s%s\n", DIR(), APARSER_O, DirectorySymbol, APARSER_C);\r
-               printf("\n");\r
-               printf("%s%s : $(ANTLR_H)%s%s\n", DIR(), ATOKENBUFFER_O, DirectorySymbol, ATOKENBUFFER_C);\r
-               printf("        %s -c $(CFLAGS) %s ",\r
-                          gen_CPP?"$(CCC)":"$(CC)",\r
-                          RENAME_OBJ_FLAG);\r
-               printf("%s%s $(ANTLR_H)%s%s\n", DIR(), ATOKENBUFFER_O, DirectorySymbol, ATOKENBUFFER_C);\r
-               if ( !user_lexer ) {\r
-                       printf("\n");\r
-                       printf("%s%s : $(ANTLR_H)%s%s\n", DIR(), DLEXERBASE_O, DirectorySymbol, DLEXERBASE_C);\r
-                       printf("        %s -c $(CFLAGS) %s ",\r
-                                  gen_CPP?"$(CCC)":"$(CC)",\r
-                                  RENAME_OBJ_FLAG);\r
-                       printf("%s%s $(ANTLR_H)%s%s\n", DIR(), DLEXERBASE_O, DirectorySymbol, DLEXERBASE_C);\r
-               }\r
-               if ( gen_trees ) {\r
-                       printf("\n");\r
-                       printf("%s%s : $(ANTLR_H)%s%s\n", DIR(), ASTBASE_O, DirectorySymbol, ASTBASE_C);\r
-                       printf("        %s -c $(CFLAGS) %s ",\r
-                                  gen_CPP?"$(CCC)":"$(CC)",\r
-                                  RENAME_OBJ_FLAG);\r
-                       printf("%s%s $(ANTLR_H)%s%s\n", DIR(), ASTBASE_O, DirectorySymbol, ASTBASE_C);\r
-                       printf("\n");\r
-                       printf("%s%s : $(ANTLR_H)%s%s\n", DIR(), PCCTSAST_O, DirectorySymbol, PCCTSAST_C);\r
-                       printf("        %s -c $(CFLAGS) %s ",\r
-                                  gen_CPP?"$(CCC)":"$(CC)",\r
-                                  RENAME_OBJ_FLAG);\r
-                       printf("%s%s $(ANTLR_H)%s%s\n", DIR(), PCCTSAST_O, DirectorySymbol, PCCTSAST_C);\r
-                       printf("\n");\r
-/*\r
-                       printf("%s%s : $(ANTLR_H)%s%s\n", DIR(), LIST_O, DirectorySymbol, LIST_C);\r
-                       printf("        %s -c $(CFLAGS) %s ",\r
-                              gen_CPP?"$(CCC)":"$(CC)",RENAME_OBJ_FLAG);\r
-                       printf("%s%s $(ANTLR_H)%s%s\n", DIR(), LIST_O, DirectorySymbol, LIST_C);\r
-*/\r
-               }\r
-       }\r
-\r
-       /* clean and scrub targets */\r
-\r
-       printf("\nclean:\n");\r
-       printf("        rm -f *%s core %s", OBJ_FILE_SUFFIX, project);\r
-       if ( strcmp(outdir, ".")!=0 ) printf(" %s*%s", DIR(), OBJ_FILE_SUFFIX);\r
-       printf("\n");\r
-\r
-       printf("\nscrub:\n");\r
-       printf("        rm -f *%s core %s", OBJ_FILE_SUFFIX, project);\r
-       if ( strcmp(outdir, ".")!=0 ) printf(" %s*%s", DIR(), OBJ_FILE_SUFFIX);\r
-       printf(" $(ANTLR_SPAWN)");\r
-       if ( !user_lexer ) printf(" $(DLG_SPAWN)");\r
-       printf("\n");\r
-}\r
-\r
-void pfiles(files, n, suffix)\r
-char **files;\r
-int n;\r
-char *suffix;\r
-{\r
-       int first=1;\r
-\r
-       while ( n>0 )\r
-       {\r
-               char *p = &(*files)[strlen(*files)-1];\r
-               if ( !first ) putchar(' ');\r
-               first=0;\r
-               while ( p > *files && *p != '.' ) --p;\r
-               if ( p == *files )\r
-               {\r
-                       fprintf(stderr,\r
-                                       "genmk: filenames must be file.suffix format: %s\n",\r
-                                       *files);\r
-                       exit(-1);\r
-               }\r
-               if ( suffix == NULL ) printf("%s", *files);\r
-               else\r
-               {\r
-                       *p = '\0';\r
-                       printf("%s", DIR());\r
-                       if ( strcmp(suffix, "o")==0 ) printf("%s%s", *files, OBJ_FILE_SUFFIX);\r
-                       else printf("%s.%s", *files, suffix);\r
-                       *p = '.';\r
-               }\r
-               files++;\r
-               --n;\r
-       }\r
-}\r
-\r
-void pclasses(classes, n, suffix)\r
-char **classes;\r
-int n;\r
-char *suffix;\r
-{\r
-       int first=1;\r
-\r
-       while ( n>0 )\r
-       {\r
-               if ( !first ) putchar(' ');\r
-               first=0;\r
-               if ( suffix == NULL ) printf("%s", *classes);\r
-               else {\r
-                       printf("%s", DIR());\r
-                       if ( strcmp(suffix, "o")==0 ) printf("%s%s", *classes, OBJ_FILE_SUFFIX);\r
-                       else printf("%s.%s", *classes, suffix);\r
-               }\r
-               classes++;\r
-               --n;\r
-       }\r
-}\r
-\r
-static void\r
-#ifdef __STDC__\r
-ProcessArgs( int argc, char **argv, Opt *options )\r
-#else\r
-ProcessArgs( argc, argv, options )\r
-int argc;\r
-char **argv;\r
-Opt *options;\r
-#endif\r
-{\r
-       Opt *p;\r
-       require(argv!=NULL, "ProcessArgs: command line NULL");\r
-\r
-       while ( argc-- > 0 )\r
-       {\r
-               p = options;\r
-               while ( p->option != NULL )\r
-               {\r
-                       if ( strcmp(p->option, "*") == 0 ||\r
-                                strcmp(p->option, *argv) == 0 )\r
-                       {\r
-                               if ( p->arg )\r
-                               {\r
-                                       (*p->process)( *argv, *(argv+1) );\r
-                                       argv++;\r
-                                       argc--;\r
-                               }\r
-                               else\r
-                                       (*p->process)( *argv );\r
-                               break;\r
-                       }\r
-                       p++;\r
-               }\r
-               argv++;\r
-       }\r
-}\r
-\r
-void fatal( err_)\r
-char *err_;\r
-{\r
-    fprintf(stderr, "genmk: %s\n", err_);\r
-    exit(1);\r
-}\r
-\r
-void warn( err_)\r
-char *err_;\r
-{\r
-    fprintf(stderr, "genmk: %s\n", err_);\r
-}\r
-\r
-char *DIR()\r
-{\r
-       static char buf[200+1];\r
-       \r
-       if ( strcmp(outdir,TopDirectory)==0 ) return "";\r
-       sprintf(buf, "%s%s", outdir, DirectorySymbol);\r
-       return buf;\r
-}\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/support/genmk/makefile b/Tools/CodeTools/TianoTools/Pccts/support/genmk/makefile
deleted file mode 100644 (file)
index a003c2f..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-##\r
-##  7-Apr-97\r
-##  added support/genmk/makefile to pccts 1.33MR1 distribution kit\r
-##             (support/genmk/makefile" omitted from 1.33 distribution kit)\r
-##\r
-SRC=genmk.c\r
-OBJ=genmk.o\r
-# Define PC if you use a PC OS (changes directory symbol and object file extension)\r
-# see pccts/h/pcctscfg.h\r
-CC=cc\r
-COPT=-O\r
-#CFLAGS=-I../../h -DPC\r
-CFLAGS=$(COPT) -I../../h\r
-BAG=../../bin/bag\r
-\r
-genmk: $(OBJ) $(SRC) ../../h/pcctscfg.h\r
-       $(CC) -o genmk $(OBJ)\r
-\r
-clean:\r
-       rm -rf core *.o\r
-\r
-scrub:\r
-       rm -rf genmk core *.o\r
-\r
-shar:\r
-       shar genmk.c makefile > genmk.shar\r
-\r
-archive:\r
-       $(BAG) genmk.c makefile > genmk.bag\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/support/rexpr/makefile b/Tools/CodeTools/TianoTools/Pccts/support/rexpr/makefile
deleted file mode 100644 (file)
index 44caef1..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-BAG=../../bin/bag\r
-SRC=test.c rexpr.c\r
-OBJ=test.o rexpr.o\r
-CFLAGS = -g\r
-\r
-test: $(OBJ) $(SRC)\r
-       cc -g -o texpr $(OBJ)\r
-\r
-shar:\r
-       shar makefile test.c rexpr.c rexpr.h > rexpr.shar\r
-\r
-archive:\r
-       $(BAG) makefile test.c rexpr.c rexpr.h > rexpr.bag\r
-\r
-clean:\r
-       rm -rf *.o core texpr\r
-\r
-scrub:\r
-       rm -rf *.o core texpr\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/support/rexpr/rexpr.c b/Tools/CodeTools/TianoTools/Pccts/support/rexpr/rexpr.c
deleted file mode 100644 (file)
index 805bf65..0000000
+++ /dev/null
@@ -1,586 +0,0 @@
-/*\r
- * This file contains code for\r
- *\r
- *      int rexpr(char *expr, char *s);\r
- *\r
- * which answers\r
- *\r
- *      1 if 's' is in the language described by the regular expression 'expr'\r
- *      0 if it is not\r
- *     -1 if the regular expression is invalid\r
- *\r
- * Language membership is determined by constructing a non-deterministic\r
- * finite automata (NFA) from the regular expression.  A depth-\r
- * first-search is performed on the NFA (graph) to check for a match of 's'.\r
- * Each non-epsilon arc consumes one character from 's'.  Backtracking is\r
- * performed to check all possible paths through the NFA.\r
- *\r
- * Regular expressions follow the meta-language:\r
- *\r
- * <regExpr>        ::= <andExpr> ( '|' <andExpr> )*\r
- *\r
- * <andExpr>        ::= <expr> ( <expr> )*\r
- *\r
- * <expr>           ::= {'~'} '[' <atomList> ']' <repeatSymbol>\r
- *                      | '(' <regExpr> ')' <repeatSymbol>\r
- *                      | '{' <regExpr> '}' <repeatSymbol>\r
- *                      | <atom> <repeatSymbol>\r
- *\r
- * <repeatSymbol>   ::= { '*' | '+' }\r
- *\r
- * <atomList>       ::= <atom> ( <atom> )*\r
- *                      | { <atomList> } <atom> '-' <atom> { <atomList> }\r
- *\r
- * <atom>           ::= Token[Atom]\r
- *\r
- * Notes:\r
- *             ~       means complement the set in [..]. i.e. all characters not listed\r
- *             *       means match 0 or more times (can be on expression or atom)\r
- *             +       means match 1 or more times (can be on expression or atom)\r
- *             {}      optional\r
- *             ()      grouping\r
- *             []      set of atoms\r
- *             x-y     all characters from x to y (found only in [..])\r
- *             \xx the character with value xx\r
- *\r
- * Examples:\r
- *             [a-z]+\r
- *                     match 1 or more lower-case letters (e.g. variable)\r
- *\r
- *             0x[0-9A-Fa-f]+\r
- *                     match a hex number with 0x on front (e.g. 0xA1FF)\r
- *\r
- *             [0-9]+.[0-9]+{e[0-9]+}\r
- *                     match a floating point number (e.g. 3.14e21)\r
- *\r
- * Code example:\r
- *             if ( rexpr("[a-zA-Z][a-zA-Z0-9]+", str) ) then str is keyword\r
- *\r
- * Terence Parr\r
- * Purdue University\r
- * April 1991\r
- */\r
-\r
-#include <stdio.h>\r
-#include <ctype.h>\r
-#ifdef __STDC__\r
-#include <stdlib.h>\r
-#else\r
-#include <malloc.h>\r
-#endif\r
-#include "rexpr.h"\r
-\r
-#ifdef __USE_PROTOS\r
-static int regExpr( GraphPtr g );\r
-static int andExpr( GraphPtr g );\r
-static int expr( GraphPtr g );\r
-static int repeatSymbol( GraphPtr g );\r
-static int atomList( char *p, int complement );\r
-static void next( void );\r
-static ArcPtr newGraphArc( void );\r
-static NodePtr newNode( void );\r
-static int ArcBetweenGraphNode( NodePtr i, NodePtr j, int label );\r
-static Graph BuildNFA_atom( int label );\r
-static Graph BuildNFA_AB( Graph A, Graph B );\r
-static Graph BuildNFA_AorB( Graph A, Graph B );\r
-static Graph BuildNFA_set( char *s );\r
-static Graph BuildNFA_Astar( Graph A );\r
-static Graph BuildNFA_Aplus( Graph A );\r
-static Graph BuildNFA_Aoptional( Graph A );\r
-#else\r
-static int regExpr();\r
-static int andExpr();\r
-static int expr();\r
-static int repeatSymbol();\r
-static int atomList();\r
-static void next();\r
-static ArcPtr newGraphArc();\r
-static NodePtr newNode();\r
-static int ArcBetweenGraphNode();\r
-static Graph BuildNFA_atom();\r
-static Graph BuildNFA_AB();\r
-static Graph BuildNFA_AorB();\r
-static Graph BuildNFA_set();\r
-static Graph BuildNFA_Astar();\r
-static Graph BuildNFA_Aplus();\r
-static Graph BuildNFA_Aoptional();\r
-#endif\r
-\r
-static char *_c;\r
-static int token, tokchar;\r
-static NodePtr accept;\r
-static NodePtr freelist = NULL;\r
-\r
-/*\r
- * return 1 if s in language described by expr\r
- *        0 if s is not\r
- *       -1 if expr is an invalid regular expression\r
- */\r
-#ifdef __USE_PROTOS\r
-static int rexpr(char *expr,char *s)\r
-#else\r
-static int rexpr(expr, s)\r
-char *expr, *s;\r
-#endif\r
-{\r
-       NodePtr p,q;\r
-       Graph nfa;\r
-       int result;\r
-\r
-       fprintf(stderr, "rexpr(%s,%s);\n", expr,s);\r
-       freelist = NULL;\r
-       _c = expr;\r
-       next();\r
-       if ( regExpr(&nfa) == -1 ) return -1;\r
-       accept = nfa.right;\r
-       result = match(nfa.left, s);\r
-       /* free all your memory */\r
-       p = q = freelist;\r
-       while ( p!=NULL ) { q = p->track; free(p); p = q; }\r
-       return result;\r
-}\r
-\r
-/*\r
- * do a depth-first-search on the NFA looking for a path from start to\r
- * accept state labelled with the characters of 's'.\r
- */\r
-\r
-#ifdef __USE_PROTOS\r
-static int match(NodePtr automaton,char *s)\r
-#else\r
-static int match(automaton, s)\r
-NodePtr automaton;\r
-char *s;\r
-#endif\r
-{\r
-       ArcPtr p;\r
-       \r
-       if ( automaton == accept && *s == '\0' ) return 1;      /* match */\r
-\r
-       for (p=automaton->arcs; p!=NULL; p=p->next)                     /* try all arcs */\r
-       {\r
-               if ( p->label == Epsilon )\r
-               {\r
-                       if ( match(p->target, s) ) return 1;\r
-               }\r
-               else if ( p->label == *s )\r
-                               if ( match(p->target, s+1) ) return 1;\r
-       }\r
-       return 0;\r
-}\r
-\r
-/*\r
- * <regExpr>        ::= <andExpr> ( '|' {<andExpr>} )*\r
- *\r
- * Return -1 if syntax error\r
- * Return  0 if none found\r
- * Return  1 if a regExrp was found\r
- */\r
-\r
-#ifdef __USE_PROTOS\r
-static int regExpr(GraphPtr g)\r
-#else\r
-static int regExpr(g)\r
-GraphPtr g;\r
-#endif\r
-{\r
-       Graph g1, g2;\r
-       \r
-       if ( andExpr(&g1) == -1 )\r
-       {\r
-               return -1;\r
-       }\r
-       \r
-       while ( token == '|' )\r
-       {\r
-               int a;\r
-               next();\r
-               a = andExpr(&g2);\r
-               if ( a == -1 ) return -1;       /* syntax error below */\r
-               else if ( !a ) return 1;        /* empty alternative */\r
-               g1 = BuildNFA_AorB(g1, g2);\r
-       }\r
-       \r
-       if ( token!='\0' ) return -1;\r
-\r
-       *g = g1;\r
-       return 1;\r
-}\r
-\r
-/*\r
- * <andExpr>        ::= <expr> ( <expr> )*\r
- */\r
-\r
-#ifdef __USE_PROTOS\r
-static int andExpr(GraphPtr g)\r
-#else\r
-static int andExpr(g)\r
-GraphPtr g;\r
-#endif\r
-{\r
-       Graph g1, g2;\r
-       \r
-       if ( expr(&g1) == -1 )\r
-       {\r
-               return -1;\r
-       }\r
-       \r
-       while ( token==Atom || token=='{' || token=='(' || token=='~' || token=='[' )\r
-       {\r
-               if (expr(&g2) == -1) return -1;\r
-               g1 = BuildNFA_AB(g1, g2);\r
-       }\r
-       \r
-       *g = g1;\r
-       return 1;\r
-}\r
-\r
-/*\r
- * <expr>           ::=    {'~'} '[' <atomList> ']' <repeatSymbol>\r
- *                      | '(' <regExpr> ')' <repeatSymbol>\r
- *                      | '{' <regExpr> '}' <repeatSymbol>\r
- *                      | <atom> <repeatSymbol>\r
- */\r
-\r
-#ifdef __USE_PROTOS\r
-static int expr(GraphPtr g)\r
-#else\r
-static int expr(g)\r
-GraphPtr g;\r
-#endif\r
-{\r
-       int complement = 0;\r
-       char s[257];    /* alloc space for string of char in [] */\r
-       \r
-       if ( token == '~' || token == '[' )\r
-       {\r
-               if ( token == '~' ) {complement = 1; next();}\r
-               if ( token != '[' ) return -1;\r
-               next();\r
-               if ( atomList( s, complement ) == -1 ) return -1;\r
-               *g = BuildNFA_set( s );\r
-               if ( token != ']' ) return -1;\r
-               next();\r
-               repeatSymbol( g );\r
-               return 1;\r
-       }\r
-       if ( token == '(' )\r
-       {\r
-               next();\r
-               if ( regExpr( g ) == -1 ) return -1;\r
-               if ( token != ')' ) return -1;\r
-               next();\r
-               repeatSymbol( g );\r
-               return 1;\r
-       }\r
-       if ( token == '{' )\r
-       {\r
-               next();\r
-               if ( regExpr( g ) == -1 ) return -1;\r
-               if ( token != '}' ) return -1;\r
-               next();\r
-               /* S p e c i a l  C a s e   O p t i o n a l  {  } */\r
-               if ( token != '*' && token != '+' )\r
-               {\r
-                       *g = BuildNFA_Aoptional( *g );\r
-               }\r
-               repeatSymbol( g );\r
-               return 1;\r
-       }\r
-       if ( token == Atom )\r
-       {\r
-               *g = BuildNFA_atom( tokchar );\r
-               next();\r
-               repeatSymbol( g );\r
-               return 1;\r
-       }\r
-       \r
-       return -1;\r
-}\r
-\r
-/*\r
- * <repeatSymbol>   ::= { '*' | '+' }\r
- */\r
-#ifdef __USE_PROTOS\r
-static int repeatSymbol(GraphPtr g)\r
-#else\r
-static int repeatSymbol(g)\r
-GraphPtr g;\r
-#endif\r
-{\r
-       switch ( token )\r
-       {\r
-               case '*' : *g = BuildNFA_Astar( *g ); next(); break;\r
-               case '+' : *g = BuildNFA_Aplus( *g ); next(); break;\r
-       }\r
-       return 1;\r
-}\r
-\r
-/*\r
- * <atomList>       ::= <atom> { <atom> }*\r
- *                      { <atomList> } <atom> '-' <atom> { <atomList> }\r
- *\r
- * a-b is same as ab\r
- * q-a is same as q\r
- */\r
-\r
-#ifdef __USE_PROTOS\r
-static int atomList(char *p, int complement)\r
-#else\r
-static int atomList(p, complement)\r
-char *p;\r
-int complement;\r
-#endif\r
-{\r
-       static unsigned char set[256];          /* no duplicates */\r
-       int first, last, i;\r
-       char *s = p;\r
-       \r
-       if ( token != Atom ) return -1;\r
-       \r
-       for (i=0; i<256; i++) set[i] = 0;\r
-       while ( token == Atom )\r
-       {\r
-               if ( !set[tokchar] ) *s++ = tokchar;\r
-               set[tokchar] = 1;                       /* Add atom to set */\r
-               next();\r
-               if ( token == '-' )             /* have we found '-' */\r
-               {\r
-                       first = *(s-1);             /* Get last char */\r
-                       next();\r
-                       if ( token != Atom ) return -1;\r
-                       else\r
-                       {\r
-                               last = tokchar;\r
-                       }\r
-                       for (i = first+1; i <= last; i++)\r
-                       {\r
-                               if ( !set[tokchar] ) *s++ = i;\r
-                               set[i] = 1;                     /* Add atom to set */\r
-                       }\r
-                       next();\r
-               }\r
-       }\r
-       *s = '\0';\r
-       if ( complement )\r
-       {\r
-               for (i=0; i<256; i++) set[i] = !set[i];\r
-               for (i=1,s=p; i<256; i++) if ( set[i] ) *s++ = i;\r
-               *s = '\0';\r
-       }\r
-       return 1;\r
-}\r
-\r
-/* a somewhat stupid lexical analyzer */\r
-\r
-#ifdef __USE_PROTOS\r
-static void next(void)\r
-#else\r
-static void next()\r
-#endif\r
-{\r
-       while ( *_c==' ' || *_c=='\t' || *_c=='\n' ) _c++;\r
-       if ( *_c=='\\' )\r
-       {\r
-               _c++;\r
-               if ( isdigit(*_c) )\r
-               {\r
-                       int n=0;\r
-                       while ( isdigit(*_c) )\r
-                       {\r
-                               n = n*10 + (*_c++ - '0');\r
-                       }\r
-                       if ( n>255 ) n=255;\r
-                       tokchar = n;\r
-               }\r
-               else\r
-               {\r
-                       switch (*_c)\r
-                       {\r
-                               case 'n' : tokchar = '\n'; break;\r
-                               case 't' : tokchar = '\t'; break;\r
-                               case 'r' : tokchar = '\r'; break;\r
-                               default  : tokchar = *_c;\r
-                       }\r
-                       _c++;\r
-               }\r
-               token = Atom;\r
-       }\r
-       else if ( isgraph(*_c) && *_c!='[' && *_c!='(' && *_c!='{' &&\r
-                         *_c!='-' && *_c!='}' && *_c!=')' && *_c!=']' &&\r
-                         *_c!='+' && *_c!='*' && *_c!='~' && *_c!='|' )\r
-       {\r
-               token = Atom;\r
-               tokchar = *_c++;\r
-       }\r
-       else\r
-       {\r
-               token = tokchar = *_c++;\r
-       }\r
-}\r
-\r
-/* N F A  B u i l d i n g  R o u t i n e s */\r
-\r
-#ifdef __USE_PROTOS\r
-static ArcPtr newGraphArc(void)\r
-#else\r
-static ArcPtr newGraphArc()\r
-#endif\r
-{\r
-       ArcPtr p;\r
-       p = (ArcPtr) calloc(1, sizeof(Arc));\r
-       if ( p==NULL ) {fprintf(stderr,"rexpr: out of memory\n"); exit(-1);}\r
-       if ( freelist != NULL ) p->track = (ArcPtr) freelist;\r
-       freelist = (NodePtr) p;\r
-       return p;\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-static NodePtr newNode(void)\r
-#else\r
-static NodePtr newNode()\r
-#endif\r
-{\r
-       NodePtr p;\r
-       p = (NodePtr) calloc(1, sizeof(Node));\r
-       if ( p==NULL ) {fprintf(stderr,"rexpr: out of memory\n"); exit(-1);}\r
-       if ( freelist != NULL ) p->track = freelist;\r
-       freelist = p;\r
-       return p;\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-static void ArcBetweenGraphNodes(NodePtr i,NodePtr j,int label)\r
-#else\r
-static void ArcBetweenGraphNodes(i, j, label)\r
-NodePtr i, j;\r
-int label;\r
-#endif\r
-{\r
-       ArcPtr a;\r
-       \r
-       a = newGraphArc();\r
-       if ( i->arcs == NULL ) i->arctail = i->arcs = a;\r
-       else {(i->arctail)->next = a; i->arctail = a;}\r
-       a->label = label;\r
-       a->target = j;\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-static Graph BuildNFA_atom(int label)\r
-#else\r
-static Graph BuildNFA_atom(label)\r
-int label;\r
-#endif\r
-{\r
-       Graph g;\r
-       \r
-       g.left = newNode();\r
-       g.right = newNode();\r
-       ArcBetweenGraphNodes(g.left, g.right, label);\r
-       return( g );\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-static Graph BuildNFA_AB(Graph A,Graph B)\r
-#else\r
-static Graph BuildNFA_AB(A, B)\r
-Graph A, B;\r
-#endif\r
-{\r
-       Graph g;\r
-       \r
-       ArcBetweenGraphNodes(A.right, B.left, Epsilon);\r
-       g.left = A.left;\r
-       g.right = B.right;\r
-       return( g );\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-static Graph BuildNFA_AorB(Graph A,Graph B)\r
-#else\r
-static Graph BuildNFA_AorB(A, B)\r
-Graph A, B;\r
-#endif\r
-{\r
-       Graph g;\r
-       \r
-       g.left = newNode();\r
-       ArcBetweenGraphNodes(g.left, A.left, Epsilon);\r
-       ArcBetweenGraphNodes(g.left, B.left, Epsilon);\r
-       g.right = newNode();\r
-       ArcBetweenGraphNodes(A.right, g.right, Epsilon);\r
-       ArcBetweenGraphNodes(B.right, g.right, Epsilon);\r
-       return( g );\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-static Graph BuildNFA_set(char *s)\r
-#else\r
-static Graph BuildNFA_set( s )\r
-char *s;\r
-#endif\r
-{\r
-       Graph g;\r
-       \r
-       if ( s == NULL ) return g;\r
-       \r
-       g.left = newNode();\r
-       g.right = newNode();\r
-       while ( *s != '\0' )\r
-       {\r
-               ArcBetweenGraphNodes(g.left, g.right, *s++);\r
-       }\r
-       return g;\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-static Graph BuildNFA_Astar(Graph A)\r
-#else\r
-static Graph BuildNFA_Astar( A )\r
-Graph A;\r
-#endif\r
-{\r
-       Graph g;\r
-\r
-       g.left = newNode();\r
-       g.right = newNode();\r
-       \r
-       ArcBetweenGraphNodes(g.left, A.left, Epsilon);\r
-       ArcBetweenGraphNodes(g.left, g.right, Epsilon);\r
-       ArcBetweenGraphNodes(A.right, g.right, Epsilon);\r
-       ArcBetweenGraphNodes(A.right, A.left, Epsilon);\r
-       \r
-       return( g );\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-static Graph BuildNFA_Aplus(Graph A)\r
-#else\r
-static Graph BuildNFA_Aplus( A )\r
-Graph A;\r
-#endif\r
-{\r
-       ArcBetweenGraphNodes(A.right, A.left, Epsilon);\r
-       \r
-       return( A );\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-static Graph BuildNFA_Aoptional(Graph A)\r
-#else\r
-static Graph BuildNFA_Aoptional( A )\r
-Graph A;\r
-#endif\r
-{\r
-       Graph g;\r
-       \r
-       g.left = newNode();\r
-       g.right = newNode();\r
-       \r
-       ArcBetweenGraphNodes(g.left, A.left, Epsilon);\r
-       ArcBetweenGraphNodes(g.left, g.right, Epsilon);\r
-       ArcBetweenGraphNodes(A.right, g.right, Epsilon);\r
-       \r
-       return( g );\r
-}\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/support/rexpr/rexpr.h b/Tools/CodeTools/TianoTools/Pccts/support/rexpr/rexpr.h
deleted file mode 100644 (file)
index e67a965..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-#define Atom   256             /* token Atom (an impossible char value) */\r
-#define Epsilon        257             /* epsilon arc (an impossible char value) */\r
-\r
-/* track field must be same for all node types */\r
-typedef struct _a {\r
-                                       struct _a *track;       /* track mem allocation */\r
-                                       int label;\r
-                                       struct _a *next;\r
-                                       struct _n *target;\r
-                               } Arc, *ArcPtr;\r
-\r
-typedef struct _n {\r
-                                       struct _n *track;\r
-                                       ArcPtr arcs, arctail;\r
-                               } Node, *NodePtr;\r
-\r
-typedef struct {\r
-                                       NodePtr left,\r
-                                                       right;\r
-                               } Graph, *GraphPtr;\r
-\r
-#ifdef __USE_PROTOS\r
-int rexpr( char *expr, char *s );\r
-int match( NodePtr automaton, char *s );\r
-#else\r
-int rexpr();\r
-int match();\r
-#endif\r
-\r
-\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/support/rexpr/test.c b/Tools/CodeTools/TianoTools/Pccts/support/rexpr/test.c
deleted file mode 100644 (file)
index 2619539..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-#include <stdio.h>\r
-#include "rexpr.h"\r
-\r
-/*\r
- * test for rexpr().\r
- * To make this test:\r
- *     cc -o rexpr test.c rexpr.c\r
- * Then from command line type:\r
- *     rexpr r string\r
- * where r is the regular expression that decribes a language\r
- * and string is the string to verify.\r
- */\r
-main(argc,argv)\r
-int argc;\r
-char *argv[];\r
-{\r
-       if ( argc!=3 ) fprintf(stderr,"rexpr: expr s\n");\r
-       else printf("%d\n", rexpr(argv[1], argv[2]));\r
-}\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/support/set/set.c b/Tools/CodeTools/TianoTools/Pccts/support/set/set.c
deleted file mode 100644 (file)
index eb6fba7..0000000
+++ /dev/null
@@ -1,816 +0,0 @@
-/*     set.c\r
-\r
-       The following is a general-purpose set library originally developed\r
-       by Hank Dietz and enhanced by Terence Parr to allow dynamic sets.\r
-       \r
-       Sets are now structs containing the #words in the set and\r
-       a pointer to the actual set words.\r
-       \r
-       Generally, sets need not be explicitly allocated.  They are\r
-       created/extended/shrunk when appropriate (e.g. in set_of()).\r
-       HOWEVER, sets need to be destroyed (free()ed) when they go out of scope\r
-       or are otherwise no longer needed.  A routine is provided to\r
-       free a set.\r
-       \r
-       Sets can be explicitly created with set_new(s, max_elem).\r
-       \r
-       Sets can be declared to have minimum size to reduce realloc traffic.\r
-       Default minimum size = 1.\r
-       \r
-       Sets can be explicitly initialized to have no elements (set.n == 0)\r
-       by using the 'empty' initializer:\r
-       \r
-       Examples:\r
-               set a = empty;  -- set_deg(a) == 0\r
-               \r
-               return( empty );\r
-       \r
-       Example set creation and destruction:\r
-       \r
-       set\r
-       set_of2(e,g)\r
-       unsigned e,g;\r
-       {\r
-               set a,b,c;\r
-               \r
-               b = set_of(e);          -- Creates space for b and sticks in e\r
-               set_new(c, g);          -- set_new(); set_orel() ==> set_of()\r
-               set_orel(g, &c);\r
-               a = set_or(b, c);\r
-               .\r
-               .\r
-               .\r
-               set_free(b);\r
-               set_free(c);\r
-               return( a );\r
-       }\r
-\r
-       1987 by Hank Dietz\r
-       \r
-       Modified by:\r
-               Terence Parr\r
-               Purdue University\r
-               October 1989\r
-\r
-       Made it smell less bad to C++ 7/31/93 -- TJP\r
-*/\r
-\r
-#include <stdio.h>\r
-#include "pcctscfg.h"\r
-#ifdef __STDC__\r
-#include <stdlib.h>\r
-#else\r
-#include <malloc.h>\r
-#endif\r
-#include <string.h>\r
-\r
-#include "set.h"\r
-\r
-#define MIN(i,j) ( (i) > (j) ? (j) : (i))\r
-#define MAX(i,j) ( (i) < (j) ? (j) : (i))\r
-\r
-/* elems can be a maximum of 32 bits */\r
-static unsigned bitmask[] = {\r
-       0x00000001, 0x00000002, 0x00000004, 0x00000008,\r
-       0x00000010, 0x00000020, 0x00000040, 0x00000080,\r
-       0x00000100, 0x00000200, 0x00000400, 0x00000800,\r
-       0x00001000, 0x00002000, 0x00004000, 0x00008000,\r
-#if !defined(PC) || defined(PC32)\r
-       0x00010000, 0x00020000, 0x00040000, 0x00080000,\r
-       0x00100000, 0x00200000, 0x00400000, 0x00800000,\r
-       0x01000000, 0x02000000, 0x04000000, 0x08000000,\r
-       0x10000000, 0x20000000, 0x40000000, 0x80000000\r
-#endif\r
-};\r
-\r
-set empty = set_init;\r
-static unsigned min=1;\r
-\r
-#define StrSize                200\r
-\r
-#ifdef MEMCHK\r
-#define CHK(a)                                 \\r
-       if ( a.setword != NULL )        \\r
-         if ( !valid(a.setword) )      \\r
-               {fprintf(stderr, "%s(%d): invalid set\n",__FILE__,__LINE__); exit(-1);}\r
-#else\r
-#define CHK(a)\r
-#endif\r
-\r
-/*\r
- * Set the minimum size (in words) of a set to reduce realloc calls\r
- */\r
-void\r
-#ifdef __USE_PROTOS\r
-set_size( unsigned n )\r
-#else\r
-set_size( n )\r
-unsigned n;\r
-#endif\r
-{\r
-       min = n;\r
-}\r
-\r
-unsigned int\r
-#ifdef __USE_PROTOS\r
-set_deg( set a )\r
-#else\r
-set_deg( a )\r
-set a;\r
-#endif\r
-{\r
-       /* Fast compute degree of a set... the number\r
-          of elements present in the set.  Assumes\r
-          that all word bits are used in the set\r
-          and that SETSIZE(a) is a multiple of WORDSIZE.\r
-       */\r
-       register unsigned *p = &(a.setword[0]);\r
-       register unsigned *endp = NULL; /* MR27 Avoid false memory check report */\r
-       register unsigned degree = 0;\r
-\r
-       CHK(a);\r
-       if ( a.n == 0 ) return(0);\r
-       endp = &(a.setword[a.n]);\r
-       while ( p < endp )\r
-       {\r
-               register unsigned t = *p;\r
-               register unsigned *b = &(bitmask[0]);\r
-               do {\r
-                       if (t & *b) ++degree;\r
-               } while (++b < &(bitmask[WORDSIZE]));\r
-               p++;\r
-       }\r
-\r
-       return(degree);\r
-}\r
-\r
-set\r
-#ifdef __USE_PROTOS\r
-set_or( set b, set c )\r
-#else\r
-set_or( b, c )\r
-set b;\r
-set c;\r
-#endif\r
-{\r
-       /* Fast set union operation */\r
-       /* resultant set size is max(b, c); */\r
-       set *big;\r
-       set t;\r
-       unsigned int m,n;\r
-       register unsigned *r, *p, *q, *endp;\r
-\r
-       CHK(b); CHK(c);\r
-       t = empty;\r
-       if (b.n > c.n) {big= &b; m=b.n; n=c.n;} else {big= &c; m=c.n; n=b.n;}\r
-       set_ext(&t, m);\r
-       r = t.setword;\r
-\r
-       /* Or b,c until max of smaller set */\r
-       q = c.setword;\r
-       p = b.setword;\r
-       endp = &(b.setword[n]);\r
-       while ( p < endp ) *r++ = *p++ | *q++;  \r
-\r
-       /* Copy rest of bigger set into result */\r
-       p = &(big->setword[n]);\r
-       endp = &(big->setword[m]);\r
-       while ( p < endp ) *r++ = *p++;\r
-\r
-       return(t);\r
-}\r
-\r
-set\r
-#ifdef __USE_PROTOS\r
-set_and( set b, set c )\r
-#else\r
-set_and( b, c )\r
-set b;\r
-set c;\r
-#endif\r
-{\r
-       /* Fast set intersection operation */\r
-       /* resultant set size is min(b, c); */\r
-       set t;\r
-       unsigned int n;\r
-       register unsigned *r, *p, *q, *endp;\r
-\r
-       CHK(b); CHK(c);\r
-       t = empty;\r
-       n = (b.n > c.n) ? c.n : b.n;\r
-       if ( n == 0 ) return t;         /* TJP 4-27-92 fixed for empty set */\r
-       set_ext(&t, n);\r
-       r = t.setword;\r
-\r
-       /* & b,c until max of smaller set */\r
-       q = c.setword;\r
-       p = b.setword;\r
-       endp = &(b.setword[n]);\r
-       while ( p < endp ) *r++ = *p++ & *q++;  \r
-\r
-       return(t);\r
-}\r
-\r
-set\r
-#ifdef __USE_PROTOS\r
-set_dif( set b, set c )\r
-#else\r
-set_dif( b, c )\r
-set b;\r
-set c;\r
-#endif\r
-{\r
-       /* Fast set difference operation b - c */\r
-       /* resultant set size is size(b) */\r
-       set t;\r
-       unsigned int n;\r
-       register unsigned *r, *p, *q, *endp;\r
-\r
-       CHK(b); CHK(c);\r
-       t = empty;\r
-       n = (b.n <= c.n) ? b.n : c.n ;\r
-       if ( b.n == 0 ) return t;               /* TJP 4-27-92 fixed for empty set */\r
-                                                                       /* WEC 12-1-92 fixed for c.n = 0 */\r
-       set_ext(&t, b.n);\r
-       r = t.setword;\r
-\r
-       /* Dif b,c until smaller set size */\r
-       q = c.setword;\r
-       p = b.setword;\r
-       endp = &(b.setword[n]);\r
-       while ( p < endp ) *r++ = *p++ & (~ *q++);      \r
-\r
-       /* Copy rest of b into result if size(b) > c */\r
-       if ( b.n > n )\r
-       {\r
-               p = &(b.setword[n]);\r
-               endp = &(b.setword[b.n]);\r
-               while ( p < endp ) *r++ = *p++;\r
-       }\r
-\r
-       return(t);\r
-}\r
-\r
-set\r
-#ifdef __USE_PROTOS\r
-set_of( unsigned b )\r
-#else\r
-set_of( b )\r
-unsigned b;\r
-#endif\r
-{\r
-       /* Fast singleton set constructor operation */\r
-       static set a;\r
-\r
-       if ( b == nil ) return( empty );\r
-       set_new(a, b);\r
-       a.setword[DIVWORD(b)] = bitmask[MODWORD(b)];\r
-\r
-       return(a);\r
-}\r
-\r
-/*\r
- * Extend (or shrink) the set passed in to have n words.\r
- *\r
- * if n is smaller than the minimum, boost n to have the minimum.\r
- * if the new set size is the same as the old one, do nothing.\r
- *\r
- * TJP 4-27-92 Fixed so won't try to alloc 0 bytes\r
- */\r
-void\r
-#ifdef __USE_PROTOS\r
-set_ext( set *a, unsigned int n )\r
-#else\r
-set_ext( a, n )\r
-set *a;\r
-unsigned int n;\r
-#endif\r
-{\r
-       register unsigned *p;\r
-       register unsigned *endp;\r
-       unsigned int size;\r
-       \r
-       CHK((*a));\r
-    if ( a->n == 0 )\r
-    {\r
-               if ( n == 0 ) return;\r
-               if (a->setword != NULL) {\r
-                       free (a->setword);      /* MR20 */\r
-               }\r
-        a->setword = (unsigned *) calloc(n, BytesPerWord);\r
-        if ( a->setword == NULL )\r
-        {\r
-            fprintf(stderr, "set_ext(%d words): cannot allocate set\n", n);\r
-            exit(-1);\r
-        }\r
-        a->n = n;\r
-        return;\r
-    }\r
-       if ( n < min ) n = min;\r
-       if ( a->n == n || n == 0 ) return;\r
-       size = a->n;\r
-       a->n = n;\r
-       a->setword = (unsigned *) realloc( (char *)a->setword, (n*BytesPerWord) );\r
-       if ( a->setword == NULL )\r
-       {\r
-               fprintf(stderr, "set_ext(%d words): cannot allocate set\n", n);\r
-               exit(-1);\r
-       }\r
-\r
-       p    = &(a->setword[size]);             /* clear from old size to new size */\r
-       endp = &(a->setword[a->n]);\r
-       do {\r
-               *p++ = 0;\r
-       } while ( p < endp );\r
-}\r
-\r
-set\r
-#ifdef __USE_PROTOS\r
-set_not( set a )\r
-#else\r
-set_not( a )\r
-set a;\r
-#endif\r
-{\r
-       /* Fast not of set a (assumes all bits used) */\r
-       /* size of resultant set is size(a) */\r
-       /* ~empty = empty cause we don't know how bit to make set */\r
-       set t;\r
-       register unsigned *r;\r
-       register unsigned *p = a.setword;\r
-       register unsigned *endp = &(a.setword[a.n]);\r
-\r
-       CHK(a);\r
-       t = empty;\r
-       if ( a.n == 0 ) return( empty );\r
-       set_ext(&t, a.n);\r
-       r = t.setword;\r
-       \r
-       do {\r
-               *r++ = (~ *p++);\r
-       } while ( p < endp );\r
-\r
-       return(t);\r
-}\r
-\r
-int\r
-#ifdef __USE_PROTOS\r
-set_equ( set a, set b )\r
-#else\r
-set_equ( a, b )\r
-set a;\r
-set b;\r
-#endif\r
-{\r
-/* 8-Nov-97     Make it work with sets of different sizes       */\r
-/*              Easy to understand, too.  Probably faster.      */\r
-/*              Check for a equal to b                          */\r
-\r
-    unsigned int    count;      /* MR11 */\r
-    unsigned int    i;          /* MR11 */\r
-\r
-       CHK(a); CHK(b);\r
-\r
-    count=MIN(a.n,b.n);\r
-    if (count == 0) return 1;\r
-    for (i=0; i < count; i++) {\r
-      if (a.setword[i] != b.setword[i]) return 0;\r
-    };\r
-    if (a.n < b.n) {\r
-      for (i=count; i < b.n; i++) {\r
-        if (b.setword[i] != 0) return 0;\r
-      }\r
-      return 1;\r
-    } else if (a.n > b.n) {\r
-      for (i=count; i < a.n; i++) {\r
-        if (a.setword[i] != 0) return 0;\r
-      }\r
-      return 1;\r
-    } else {\r
-      return 1;\r
-    };\r
-}\r
-\r
-int\r
-#ifdef __USE_PROTOS\r
-set_sub( set a, set b )\r
-#else\r
-set_sub( a, b )\r
-set a;\r
-set b;\r
-#endif\r
-{\r
-\r
-/* 8-Nov-97     Make it work with sets of different sizes       */\r
-/*              Easy to understand, too.  Probably faster.      */\r
-/*              Check for a is a PROPER subset of b             */\r
-\r
-    unsigned int    count;\r
-    unsigned int    i;\r
-\r
-       CHK(a); CHK(b);\r
-\r
-    if (a.n == 0) return 1;\r
-    count=MIN(a.n,b.n);\r
-    for (i=0; i < count; i++) {\r
-      if (a.setword[i] & ~b.setword[i]) return 0;\r
-    };\r
-    if (a.n <= b.n) {\r
-      return 1;\r
-    } else {\r
-      for (i=count; i<a.n ; i++) {\r
-        if (a.setword[i]) return 0;\r
-      };\r
-    };\r
-    return 1;\r
-}\r
-\r
-unsigned\r
-#ifdef __USE_PROTOS\r
-set_int( set b )\r
-#else\r
-set_int( b )\r
-set b;\r
-#endif\r
-{\r
-       /* Fast pick any element of the set b */\r
-       register unsigned *p = b.setword;\r
-       register unsigned *endp = &(b.setword[b.n]);\r
-\r
-       CHK(b);\r
-       if ( b.n == 0 ) return( nil );\r
-\r
-       do {\r
-               if (*p) {\r
-                       /* Found a non-empty word of the set */\r
-                       register unsigned i = ((p - b.setword) << LogWordSize);\r
-                       register unsigned t = *p;\r
-                       p = &(bitmask[0]);\r
-                       while (!(*p & t)) {\r
-                               ++i; ++p;\r
-                       }\r
-                       return(i);\r
-               }\r
-       } while (++p < endp);\r
-\r
-       /* Empty -- only element it contains is nil */\r
-       return(nil);\r
-}\r
-\r
-int\r
-#ifdef __USE_PROTOS\r
-set_el( unsigned b, set a )\r
-#else\r
-set_el( b, a )\r
-unsigned b;\r
-set a;\r
-#endif\r
-{\r
-       CHK(a);\r
-       /* nil is an element of every set */\r
-       if (b == nil) return(1);\r
-       if ( a.n == 0 || NumWords(b) > a.n ) return(0);\r
-       \r
-       /* Otherwise, we have to check */\r
-       return( a.setword[DIVWORD(b)] & bitmask[MODWORD(b)] );\r
-}\r
-\r
-int\r
-#ifdef __USE_PROTOS\r
-set_nil( set a )\r
-#else\r
-set_nil( a )\r
-set a;\r
-#endif\r
-{\r
-       /* Fast check for nil set */\r
-       register unsigned *p = a.setword;\r
-       register unsigned *endp;\r
-\r
-       CHK(a);\r
-       if ( a.n == 0 ) return(1);\r
-       endp = &(a.setword[a.n]);\r
-       \r
-       /* The set is not empty if any word used to store\r
-          the set is non-zero.  This means one must be a\r
-          bit careful about doing things like negation.\r
-       */\r
-       do {\r
-               if (*p) return(0);\r
-       } while (++p < endp);\r
-       \r
-       return(1);\r
-}\r
-\r
-char *\r
-#ifdef __USE_PROTOS\r
-set_str( set a )\r
-#else\r
-set_str( a )\r
-set a;\r
-#endif\r
-{\r
-       /* Fast convert set a into ASCII char string...\r
-          assumes that all word bits are used in the set\r
-          and that SETSIZE is a multiple of WORDSIZE.\r
-          Trailing 0 bits are removed from the string.\r
-          if no bits are on or set is empty, "" is returned.\r
-       */\r
-       register unsigned *p = a.setword;\r
-       register unsigned *endp = &(a.setword[a.n]);\r
-       static char str_tmp[StrSize+1];\r
-       register char *q = &(str_tmp[0]);\r
-\r
-       CHK(a);\r
-       if ( a.n==0 ) {*q=0; return( &(str_tmp[0]) );}\r
-       do {\r
-               register unsigned t = *p;\r
-               register unsigned *b = &(bitmask[0]);\r
-               do {\r
-                       *(q++) = (char) ((t & *b) ? '1' : '0');\r
-               } while (++b < &(bitmask[WORDSIZE]));\r
-       } while (++p < endp);\r
-\r
-       /* Trim trailing 0s & NULL terminate the string */\r
-       while ((q > &(str_tmp[0])) && (*(q-1) != '1')) --q;\r
-       *q = 0;\r
-\r
-       return(&(str_tmp[0]));\r
-}\r
-\r
-set\r
-#ifdef __USE_PROTOS\r
-set_val( register char *s )\r
-#else\r
-set_val( s )\r
-register char *s;\r
-#endif\r
-{\r
-       /* Fast convert set ASCII char string into a set.\r
-          If the string ends early, the remaining set bits\r
-          are all made zero.\r
-          The resulting set size is just big enough to hold all elements.\r
-       */\r
-       static set a;\r
-       register unsigned *p, *endp;\r
-\r
-       set_new(a, strlen(s));\r
-       p = a.setword;\r
-       endp = &(a.setword[a.n]);\r
-       do {\r
-               register unsigned *b = &(bitmask[0]);\r
-               /* Start with a word with no bits on */\r
-               *p = 0;\r
-               do {\r
-                       if (*s) {\r
-                               if (*s == '1') {\r
-                                       /* Turn-on this bit */\r
-                                       *p |= *b;\r
-                               }\r
-                               ++s;\r
-                       }\r
-               } while (++b < &(bitmask[WORDSIZE]));\r
-       } while (++p < endp);\r
-\r
-       return(a);\r
-}\r
-\r
-/*\r
- * Or element e into set a.  a can be empty.\r
- */\r
-void\r
-#ifdef __USE_PROTOS\r
-set_orel( unsigned e, set *a )\r
-#else\r
-set_orel( e, a )\r
-unsigned e;\r
-set *a;\r
-#endif\r
-{\r
-       CHK((*a));\r
-       if ( e == nil ) return;\r
-       if ( NumWords(e) > a->n ) set_ext(a, NumWords(e));\r
-       a->setword[DIVWORD(e)] |= bitmask[MODWORD(e)];\r
-}\r
-\r
-/*\r
- * Or set b into set a.  a can be empty. does nothing if b empty.\r
- */\r
-void\r
-#ifdef __USE_PROTOS\r
-set_orin( set *a, set b )\r
-#else\r
-set_orin( a, b )\r
-set *a;\r
-set b;\r
-#endif\r
-{\r
-       /* Fast set union operation */\r
-       /* size(a) is max(a, b); */\r
-       unsigned int m;\r
-       register unsigned *p,\r
-                                         *q    = b.setword,\r
-                                         *endq; /* MR20 */\r
-\r
-       CHK((*a)); CHK(b);\r
-       if ( b.n == 0 ) return;\r
-       endq = &(b.setword[b.n]); /* MR20 */\r
-       m = (a->n > b.n) ? a->n : b.n;\r
-       set_ext(a, m);\r
-       p = a->setword;\r
-       do {\r
-               *p++ |= *q++;\r
-       } while ( q < endq );\r
-}\r
-\r
-/*\r
- * And set b into set a.  a can be empty. does nothing if b empty.\r
- */\r
-void\r
-#ifdef __USE_PROTOS\r
-set_andin( set *a, set b )\r
-#else\r
-set_andin( a, b )\r
-set *a;\r
-set b;\r
-#endif\r
-{\r
-       /* Fast set intersection operation */\r
-       /* size(a) is max(a, b); */\r
-       unsigned int m;\r
-       register unsigned *p,\r
-                                         *q    = b.setword,\r
-                                         *endq = &(b.setword[b.n]);\r
-\r
-       CHK((*a)); CHK(b);\r
-       if ( b.n == 0 ) return;\r
-       m = (a->n > b.n) ? a->n : b.n;\r
-       set_ext(a, m);\r
-       p = a->setword;\r
-       do {\r
-               *p++ &= *q++;\r
-       } while ( q < endq );\r
-}\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-set_rm( unsigned e, set a )\r
-#else\r
-set_rm( e, a )\r
-unsigned e;\r
-set a;\r
-#endif\r
-{\r
-       /* Does not effect size of set */\r
-       CHK(a);\r
-       if ( (e == nil) || (NumWords(e) > a.n) ) return;\r
-       a.setword[DIVWORD(e)] ^= (a.setword[DIVWORD(e)]&bitmask[MODWORD(e)]);\r
-}\r
-\r
-void\r
-#ifdef __USE_PROTOS\r
-set_clr( set a )\r
-#else\r
-set_clr( a )\r
-set a;\r
-#endif\r
-{\r
-       /* Does not effect size of set */\r
-       register unsigned *p = a.setword;\r
-       register unsigned *endp;\r
-       \r
-       CHK(a);\r
-       if ( a.n == 0 ) return;\r
-       endp = &(a.setword[a.n]);\r
-       do {\r
-               *p++ = 0;\r
-       } while ( p < endp );\r
-}\r
-\r
-set\r
-#ifdef __USE_PROTOS\r
-set_dup( set a )\r
-#else\r
-set_dup( a )\r
-set a;\r
-#endif\r
-{\r
-       set b;\r
-       register unsigned *p,\r
-                                         *q    = a.setword,\r
-                                         *endq; /* MR20 */\r
-       \r
-       CHK(a);\r
-       b = empty;\r
-       if ( a.n == 0 ) return( empty );\r
-       endq = &(a.setword[a.n]);       /* MR20 */\r
-       set_ext(&b, a.n);\r
-       p = b.setword;\r
-       do {\r
-               *p++ = *q++;\r
-       } while ( q < endq );\r
-       \r
-       return(b);\r
-}\r
-\r
-/*\r
- * Return a nil terminated list of unsigned ints that represents all\r
- * "on" bits in the bit set.\r
- *\r
- * e.g. {011011} --> {1, 2, 4, 5, nil}\r
- *\r
- * _set_pdq and set_pdq are useful when an operation is required on each element\r
- * of a set.  Normally, the sequence is:\r
- *\r
- *             while ( set_deg(a) > 0 ) {\r
- *                     e = set_int(a);\r
- *                     set_rm(e, a);\r
- *                     ...process e...\r
- *             }\r
- * Now,\r
- *\r
- *             t = e = set_pdq(a);\r
- *             while ( *e != nil ) {\r
- *                     ...process *e...\r
- *                     e++;\r
- *             }\r
- *             free( t );\r
- *\r
- * We have saved many set calls and have not destroyed set a.\r
- */\r
-void\r
-#ifdef __USE_PROTOS\r
-_set_pdq( set a, register unsigned *q )\r
-#else\r
-_set_pdq( a, q )\r
-set a;\r
-register unsigned *q;\r
-#endif\r
-{\r
-       register unsigned *p = a.setword,\r
-                                         *endp = &(a.setword[a.n]);\r
-       register unsigned e=0;\r
-\r
-       CHK(a);\r
-       /* are there any space (possibility of elements)? */\r
-       if ( a.n == 0 ) return;\r
-       do {\r
-               register unsigned t = *p;\r
-               register unsigned *b = &(bitmask[0]);\r
-               do {\r
-                       if ( t & *b ) *q++ = e;\r
-                       ++e;\r
-               } while (++b < &(bitmask[WORDSIZE]));\r
-       } while (++p < endp);\r
-       *q = nil;\r
-}\r
-\r
-/*\r
- * Same as _set_pdq except allocate memory.  set_pdq is the natural function\r
- * to use.\r
- */\r
-unsigned *\r
-#ifdef __USE_PROTOS\r
-set_pdq( set a )\r
-#else\r
-set_pdq( a )\r
-set a;\r
-#endif\r
-{\r
-       unsigned *q;\r
-       int max_deg;\r
-       \r
-       CHK(a);\r
-       max_deg = WORDSIZE*a.n;\r
-       /* assume a.n!=0 & no elements is rare, but still ok */\r
-       if ( a.n == 0 ) return(NULL);\r
-       q = (unsigned *) malloc((max_deg+1)*BytesPerWord);\r
-       if ( q == NULL ) return( NULL );\r
-       _set_pdq(a, q);\r
-       return( q );\r
-}\r
-\r
-/* a function that produces a hash number for the set\r
- */\r
-unsigned int\r
-#ifdef __USE_PROTOS\r
-set_hash( set a, register unsigned int mod )\r
-#else\r
-set_hash( a, mod )\r
-set a;\r
-register unsigned int mod;\r
-#endif\r
-{\r
-       /* Fast hash of set a (assumes all bits used) */\r
-       register unsigned *p = &(a.setword[0]);\r
-       register unsigned *endp = &(a.setword[a.n]);\r
-       register unsigned i = 0;\r
-\r
-       CHK(a);\r
-       while (p<endp){\r
-               i += (*p);\r
-               ++p;\r
-       }\r
-\r
-       return(i % mod);\r
-}\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/support/set/set.h b/Tools/CodeTools/TianoTools/Pccts/support/set/set.h
deleted file mode 100644 (file)
index 5d68152..0000000
+++ /dev/null
@@ -1,121 +0,0 @@
-#ifndef __GATE_SET_H\r
-#define __GATE_SET_H\r
-\r
-/*     set.h\r
-\r
-       The following is a general-purpose set library originally developed\r
-       by Hank Dietz and enhanced by Terence Parr to allow dynamic sets.\r
-       \r
-       Sets are now structs containing the #words in the set and\r
-       a pointer to the actual set words.\r
-\r
-       1987 by Hank Dietz\r
-       \r
-       Modified by:\r
-               Terence Parr\r
-               Purdue University\r
-               October 1989\r
-\r
-               Added ANSI prototyping Dec. 1992 -- TJP\r
-*/\r
-\r
-#include "pcctscfg.h"\r
-\r
-#ifdef NOT_USED /* SEE config.h */\r
-/* Define usable bits per unsigned int word */\r
-#ifdef PC\r
-#define WORDSIZE 16\r
-#define LogWordSize    4\r
-#else\r
-#define        WORDSIZE 32\r
-#define LogWordSize 5\r
-#endif\r
-#define BytesPerWord   sizeof(unsigned)\r
-#endif\r
-\r
-#define        SETSIZE(a) ((a).n<<LogWordSize)         /* Maximum items per set */\r
-#define        MODWORD(x) ((x) & (WORDSIZE-1))         /* x % WORDSIZE */\r
-#define        DIVWORD(x) ((x) >> LogWordSize)         /* x / WORDSIZE */\r
-#define        nil     (~((unsigned) 0))       /* An impossible set member all bits on (big!) */\r
-\r
-typedef struct _set {\r
-                       unsigned int n;         /* Number of words in set */\r
-                       unsigned *setword;\r
-               } set;\r
-\r
-#define set_init       {0, NULL}\r
-#define set_null(a)    ((a).setword==NULL)\r
-\r
-#define        NumBytes(x)             (((x)>>3)+1)                                            /* Num bytes to hold x */\r
-#define        NumWords(x)             ((((unsigned)(x))>>LogWordSize)+1)      /* Num words to hold x */\r
-\r
-\r
-/* M a c r o s */\r
-\r
-/* make arg1 a set big enough to hold max elem # of arg2 */\r
-#define set_new(a,_max) \\r
-if (((a).setword=(unsigned *)calloc(NumWords(_max),BytesPerWord))==NULL) \\r
-        fprintf(stderr, "set_new: Cannot allocate set with max of %d\n", _max); \\r
-        (a).n = NumWords(_max);\r
-\r
-#define set_free(a)                                                                    \\r
-       {if ( (a).setword != NULL ) free((char *)((a).setword));        \\r
-       (a) = empty;}\r
-\r
-#ifdef __USE_PROTOS\r
-extern void set_size( unsigned );\r
-extern unsigned int set_deg( set );\r
-extern set set_or( set, set );\r
-extern set set_and( set, set );\r
-extern set set_dif( set, set );\r
-extern set set_of( unsigned );\r
-extern void set_ext( set *, unsigned int );\r
-extern set set_not( set );\r
-extern int set_equ( set, set );\r
-extern int set_sub( set, set );\r
-extern unsigned set_int( set );\r
-extern int set_el( unsigned, set );\r
-extern int set_nil( set );\r
-extern char * set_str( set );\r
-extern set set_val( register char * );\r
-extern void set_orel( unsigned, set * );\r
-extern void set_orin( set *, set );\r
-extern void set_andin( set *, set );\r
-extern void set_rm( unsigned, set );\r
-extern void set_clr( set );\r
-extern set set_dup( set );\r
-extern void set_PDQ( set, register unsigned * );\r
-extern unsigned *set_pdq( set );\r
-extern void _set_pdq( set a, register unsigned *q );\r
-extern unsigned int set_hash( set, register unsigned int );\r
-#else\r
-extern void set_size();\r
-extern unsigned int set_deg();\r
-extern set set_or();\r
-extern set set_and();\r
-extern set set_dif();\r
-extern set set_of();\r
-extern void set_ext();\r
-extern set set_not();\r
-extern int set_equ();\r
-extern int set_sub();\r
-extern unsigned set_int();\r
-extern int set_el();\r
-extern int set_nil();\r
-extern char * set_str();\r
-extern set set_val();\r
-extern void set_orel();\r
-extern void set_orin();\r
-extern void set_andin();\r
-extern void set_rm();\r
-extern void set_clr();\r
-extern set set_dup();\r
-extern void set_PDQ();\r
-extern unsigned *set_pdq();\r
-extern void _set_pdq();\r
-extern unsigned int set_hash();\r
-#endif\r
-\r
-extern set empty;\r
-\r
-#endif\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/support/sym/sym.c b/Tools/CodeTools/TianoTools/Pccts/support/sym/sym.c
deleted file mode 100644 (file)
index eccce05..0000000
+++ /dev/null
@@ -1,402 +0,0 @@
-/*\r
- * Simple symbol table manager using coalesced chaining to resolve collisions\r
- *\r
- * Doubly-linked lists are used for fast removal of entries.\r
- *\r
- * 'sym.h' must have a definition for typedef "Sym".  Sym must include at\r
- * minimum the following fields:\r
- *\r
- *             ...\r
- *             char *symbol;\r
- *             struct ... *next, *prev, **head, *scope;\r
- *             unsigned int hash;\r
- *             ...\r
- *\r
- * 'template.h' can be used as a template to create a 'sym.h'.\r
- *\r
- * 'head' is &(table[hash(itself)]).\r
- * The hash table is not resizable at run-time.\r
- * The scope field is used to link all symbols of a current scope together.\r
- * Scope() sets the current scope (linked list) to add symbols to.\r
- * Any number of scopes can be handled.  The user passes the address of\r
- * a pointer to a symbol table\r
- * entry (INITIALIZED TO NULL first time).\r
- *\r
- * Available Functions:\r
- *\r
- *     zzs_init(s1,s2) --      Create hash table with size s1, string table size s2.\r
- *     zzs_done()              --      Free hash and string table created with zzs_init().\r
- *     zzs_add(key,rec)--      Add 'rec' with key 'key' to the symbol table.\r
- *     zzs_newadd(key) --      create entry; add using 'key' to the symbol table.\r
- *     zzs_get(key)    --      Return pointer to last record entered under 'key'\r
- *                                             Else return NULL\r
- *     zzs_del(p)              --      Unlink the entry associated with p.  This does\r
- *                                             NOT free 'p' and DOES NOT remove it from a scope\r
- *                                             list.  If it was a part of your intermediate code\r
- *                                             tree or another structure.  It will still be there.\r
- *                                             It is only removed from further consideration\r
- *                                             by the symbol table.\r
- *     zzs_keydel(s)   --      Unlink the entry associated with key s.\r
- *                                             Calls zzs_del(p) to unlink.\r
- *     zzs_scope(sc)   --      Specifies that everything added to the symbol\r
- *                                             table with zzs_add() is added to the list (scope)\r
- *                                             'sc'.  'sc' is of 'Sym **sc' type and must be\r
- *                                             initialized to NULL before trying to add anything\r
- *                                             to it (passing it to zzs_scope()).  Scopes can be\r
- *                                         switched at any time and merely links a set of\r
- *                                             symbol table entries.  If a NULL pointer is\r
- *                                             passed, the current scope is returned.\r
- *     zzs_rmscope(sc) --      Remove (zzs_del()) all elements of scope 'sc'\r
- *                                             from the symbol table.  The entries are NOT\r
- *                                             free()'d.  A pointer to the first\r
- *                                             element in the "scope" is returned.  The user\r
- *                                             can then manipulate the list as he/she chooses\r
- *                                             (such as freeing them all). NOTE that this\r
- *                                             function sets your scope pointer to NULL,\r
- *                                             but returns a pointer to the list for you to use.\r
- *     zzs_stat()              --      Print out the symbol table and some relevant stats.\r
- *     zzs_new(key)    --      Create a new record with calloc() of type Sym.\r
- *                                             Add 'key' to the string table and make the new\r
- *                                             records 'symbol' pointer point to it.\r
- *     zzs_strdup(s)   --      Add s to the string table and return a pointer\r
- *                                             to it.  Very fast allocation routine\r
- *                                             and does not require strlen() nor calloc().\r
- *\r
- * Example:\r
- *\r
- *     #include <stdio.h>\r
- *     #include "sym.h"\r
- *\r
- *     main()\r
- *     {\r
- *         Sym *scope1=NULL, *scope2=NULL, *a, *p;\r
- *     \r
- *         zzs_init(101, 100);\r
- *     \r
- *         a = zzs_new("Apple");       zzs_add(a->symbol, a);  -- No scope\r
- *         zzs_scope( &scope1 );       -- enter scope 1\r
- *         a = zzs_new("Plum");        zzs_add(a->symbol, a);\r
- *         zzs_scope( &scope2 );       -- enter scope 2\r
- *         a = zzs_new("Truck");       zzs_add(a->symbol, a);\r
- *     \r
- *     p = zzs_get("Plum");\r
- *     if ( p == NULL ) fprintf(stderr, "Hmmm...Can't find 'Plum'\n");\r
- *     \r
- *     p = zzs_rmscope(&scope1)\r
- *     for (; p!=NULL; p=p->scope) {printf("Scope1:  %s\n", p->symbol);}\r
- *     p = zzs_rmscope(&scope2)\r
- *     for (; p!=NULL; p=p->scope) {printf("Scope2:  %s\n", p->symbol);}\r
- * }\r
- *\r
- * Terence Parr\r
- * Purdue University\r
- * February 1990\r
- *\r
- * CHANGES\r
- *\r
- *     Terence Parr\r
- *     May 1991\r
- *             Renamed functions to be consistent with ANTLR\r
- *             Made HASH macro\r
- *             Added zzs_keydel()\r
- *             Added zzs_newadd()\r
- *             Fixed up zzs_stat()\r
- *\r
- *     July 1991\r
- *             Made symbol table entry save its hash code for fast comparison\r
- *                     during searching etc...\r
- */\r
-\r
-#include <stdio.h>\r
-#if defined(__STDC__) || defined(__USE_PROTOS)\r
-#include <string.h>\r
-#include <stdlib.h>\r
-#else\r
-#include <malloc.h>\r
-#endif\r
-#include "sym.h"\r
-\r
-#define StrSame                0\r
-\r
-static Sym **CurScope = NULL;\r
-static unsigned size = 0;\r
-static Sym **table=NULL;\r
-static char *strings;\r
-static char *strp;\r
-static int strsize = 0;\r
-\r
-#ifdef __USE_PROTOS\r
-void zzs_init(int sz,int strs)\r
-#else\r
-void zzs_init(sz, strs)\r
-int sz, strs;\r
-#endif\r
-{\r
-       if ( sz <= 0 || strs <= 0 ) return;\r
-       table = (Sym **) calloc(sz, sizeof(Sym *));\r
-       if ( table == NULL )\r
-       {\r
-               fprintf(stderr, "Cannot allocate table of size %d\n", sz);\r
-               exit(1);\r
-       }\r
-       strings = (char *) calloc(strs, sizeof(char));\r
-       if ( strings == NULL )\r
-       {\r
-               fprintf(stderr, "Cannot allocate string table of size %d\n", strs);\r
-               exit(1);\r
-       }\r
-       size = sz;\r
-       strsize = strs;\r
-       strp = strings;\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-void zzs_done(void)\r
-#else\r
-void zzs_done()\r
-#endif\r
-{\r
-       if ( table != NULL ) free( table );\r
-       if ( strings != NULL ) free( strings );\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-void zzs_add(char *key,Sym rec)\r
-#else\r
-void zzs_add(key, rec)\r
-char *key;\r
-register Sym *rec;\r
-#endif\r
-{\r
-       register unsigned int h=0;\r
-       register char *p=key;\r
-       \r
-       HASH(p, h);\r
-       rec->hash = h;                                  /* save hash code for fast comp later */\r
-       h %= size;\r
-       \r
-       if ( CurScope != NULL ) {rec->scope = *CurScope; *CurScope = rec;}\r
-       rec->next = table[h];                   /* Add to doubly-linked list */\r
-       rec->prev = NULL;\r
-       if ( rec->next != NULL ) (rec->next)->prev = rec;\r
-       table[h] = rec;\r
-       rec->head = &(table[h]);\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-Sym * zzs_get(char *key)\r
-#else\r
-Sym * zzs_get(key)\r
-char *key;\r
-#endif\r
-{\r
-       register unsigned int h=0;\r
-       register char *p=key;\r
-       register Sym *q;\r
-       \r
-       HASH(p, h);\r
-       \r
-       for (q = table[h%size]; q != NULL; q = q->next)\r
-       {\r
-               if ( q->hash == h )             /* do we even have a chance of matching? */\r
-                       if ( strcmp(key, q->symbol) == StrSame ) return( q );\r
-       }\r
-       return( NULL );\r
-}\r
-\r
-/*\r
- * Unlink p from the symbol table.  Hopefully, it's actually in the\r
- * symbol table.\r
- *\r
- * If p is not part of a bucket chain of the symbol table, bad things\r
- * will happen.\r
- *\r
- * Will do nothing if all list pointers are NULL\r
- */\r
-#ifdef __USE_PROTOS\r
-void zzs_del(Sym *p)\r
-#else\r
-void zzs_del(p)\r
-register Sym *p;\r
-#endif\r
-{\r
-       if ( p == NULL ) {fprintf(stderr, "zzs_del(NULL)\n"); exit(1);}\r
-       if ( p->prev == NULL )  /* Head of list */\r
-       {\r
-               register Sym **t = p->head;\r
-               \r
-               if ( t == NULL ) return;        /* not part of symbol table */\r
-               (*t) = p->next;\r
-               if ( (*t) != NULL ) (*t)->prev = NULL;\r
-       }\r
-       else\r
-       {\r
-               (p->prev)->next = p->next;\r
-               if ( p->next != NULL ) (p->next)->prev = p->prev;\r
-       }\r
-       p->next = p->prev = NULL;       /* not part of symbol table anymore */\r
-       p->head = NULL;\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-void zzs_keydel(char *key)\r
-#else\r
-void zzs_keydel(key)\r
-char *key;\r
-#endif\r
-{\r
-       Sym *p = zzs_get(key);\r
-\r
-       if ( p != NULL ) zzs_del( p );\r
-}\r
-\r
-/* S c o p e  S t u f f */\r
-\r
-/* Set current scope to 'scope'; return current scope if 'scope' == NULL */\r
-\r
-#ifdef __USE_PROTOS\r
-Sym ** zzs_scope(Sym **scope)\r
-#else\r
-Sym ** zzs_scope(scope)\r
-Sym **scope;\r
-#endif\r
-{\r
-       if ( scope == NULL ) return( CurScope );\r
-       CurScope = scope;\r
-       return( scope );\r
-}\r
-\r
-/* Remove a scope described by 'scope'.  Return pointer to 1st element in scope */\r
-\r
-#ifdef __USE_PROTOS\r
-Sym * zzs_rmscope(Sym **scope)\r
-#else\r
-Sym * zzs_rmscope(scope)\r
-register Sym **scope;\r
-#endif\r
-{\r
-       register Sym *p;\r
-       Sym *start;\r
-\r
-       if ( scope == NULL ) return(NULL);\r
-       start = p = *scope;\r
-       for (; p != NULL; p=p->scope) { zzs_del( p ); }\r
-       *scope = NULL;\r
-       return( start );\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-void zzs_stat(void)\r
-#else\r
-void zzs_stat()\r
-#endif\r
-{\r
-       static unsigned short count[20];\r
-       unsigned int i,n=0,low=0, hi=0;\r
-       register Sym **p;\r
-       float avg=0.0;\r
-       \r
-       for (i=0; i<20; i++) count[i] = 0;\r
-       for (p=table; p<&(table[size]); p++)\r
-       {\r
-               register Sym *q = *p;\r
-               unsigned int len;\r
-               \r
-               if ( q != NULL && low==0 ) low = p-table;\r
-               len = 0;\r
-               if ( q != NULL ) printf("[%d]", p-table);\r
-               while ( q != NULL )\r
-               {\r
-                       len++;\r
-                       n++;\r
-                       printf(" %s", q->symbol);\r
-                       q = q->next;\r
-                       if ( q == NULL ) printf("\n");\r
-               }\r
-               if ( len>=20 ) printf("zzs_stat: count table too small\n");\r
-               else count[len]++;\r
-               if ( *p != NULL ) hi = p-table;\r
-       }\r
-\r
-       printf("Storing %d recs used %d hash positions out of %d\n",\r
-                       n, size-count[0], size);\r
-       printf("%f %% utilization\n",\r
-                       ((float)(size-count[0]))/((float)size));\r
-       for (i=0; i<20; i++)\r
-       {\r
-               if ( count[i] != 0 )\r
-               {\r
-                       avg += (((float)(i*count[i]))/((float)n)) * i;\r
-                       printf("Buckets of len %d == %d (%f %% of recs)\n",\r
-                                       i, count[i], 100.0*((float)(i*count[i]))/((float)n));\r
-               }\r
-       }\r
-       printf("Avg bucket length %f\n", avg);\r
-       printf("Range of hash function: %d..%d\n", low, hi);\r
-}\r
-\r
-/*\r
- * Given a string, this function allocates and returns a pointer to a\r
- * symbol table record whose "symbol" pointer is reset to a position\r
- * in the string table.\r
- */\r
-\r
-#ifdef __USE_PROTOS\r
-Sym * zzs_new(char *text)\r
-#else\r
-Sym * zzs_new(text)\r
-char *text;\r
-#endif\r
-{\r
-       Sym *p;\r
-       \r
-       if ( (p = (Sym *) calloc(1,sizeof(Sym))) == 0 )\r
-       {\r
-               fprintf(stderr,"Out of memory\n");\r
-               exit(1);\r
-       }\r
-       p->symbol = zzs_strdup(text);\r
-       \r
-       return p;\r
-}\r
-\r
-/* create a new symbol table entry and add it to the symbol table */\r
-\r
-#ifdef __USE_PROTOS\r
-Sym * zzs_newadd(char *text)\r
-#else\r
-Sym * zzs_newadd(text)\r
-char *text;\r
-#endif\r
-{\r
-       Sym *p = zzs_new(text);\r
-       if ( p != NULL ) zzs_add(text, p);\r
-       return p;\r
-}\r
-\r
-/* Add a string to the string table and return a pointer to it.\r
- * Bump the pointer into the string table to next avail position.\r
- */\r
-\r
-#ifdef __USE_PROTOS\r
-char * zzs_strdup(char *s)\r
-#else\r
-char * zzs_strdup(s)\r
-register char *s;\r
-#endif\r
-{\r
-       register char *start=strp;\r
-\r
-       while ( *s != '\0' )\r
-       {\r
-               if ( strp >= &(strings[strsize-2]) )\r
-               {\r
-                       fprintf(stderr, "sym: string table overflow (%d chars)\n", strsize);\r
-                       exit(-1);\r
-               }\r
-               *strp++ = *s++;\r
-       }\r
-       *strp++ = '\0';\r
-\r
-       return( start );\r
-}\r
diff --git a/Tools/CodeTools/TianoTools/Pccts/support/sym/template.h b/Tools/CodeTools/TianoTools/Pccts/support/sym/template.h
deleted file mode 100644 (file)
index ee6e665..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-/* T e m p l a t e  F o r  S y m b o l  T a b l e  M a n a g e r */\r
-\r
-/* define some hash function */\r
-#ifndef HASH\r
-#define HASH(p, h) while ( *p != '\0' ) h = (h<<1) + *p++;\r
-#endif\r
-\r
-/* minimum symbol table record */\r
-typedef struct _sym {\r
-                       char *symbol;\r
-                       struct _sym *next, *prev, **head, *scope;\r
-                       unsigned int hash;\r
-               } Sym, *SymPtr;\r
-\r
-#ifdef __USE_PROTOS\r
-void zzs_init(int, int);\r
-void zzs_done(void);\r
-void zzs_add(char *, Sym *);\r
-Sym *zzs_get(char *);\r
-void zzs_del(Sym *);\r
-void zzs_keydel(char *);\r
-Sym **zzs_scope(Sym **);\r
-Sym *zzs_rmscope(Sym **);\r
-void zzs_stat(void);\r
-Sym *zzs_new(char *);\r
-Sym *zzs_newadd(char *);\r
-char *zzs_strdup(char *);\r
-#else\r
-void zzs_init();\r
-void zzs_done();\r
-void zzs_add();\r
-Sym *zzs_get();\r
-void zzs_del();\r
-void zzs_keydel();\r
-Sym **zzs_scope();\r
-Sym *zzs_rmscope();\r
-void zzs_stat();\r
-Sym *zzs_new();\r
-Sym *zzs_newadd();\r
-char *zzs_strdup();\r
-#endif\r
diff --git a/Tools/CodeTools/TianoTools/PeCoffLoader/BasePeCoff.c b/Tools/CodeTools/TianoTools/PeCoffLoader/BasePeCoff.c
deleted file mode 100644 (file)
index 9c25e1f..0000000
+++ /dev/null
@@ -1,1060 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2004 - 2005, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-Module Name:\r
-\r
-  PeCoffLoader.c\r
-\r
-Abstract:\r
-\r
-  Tiano PE/COFF loader \r
-\r
-Revision History\r
-\r
---*/\r
-\r
-\r
-#include <Common/UefiBaseTypes.h>\r
-#include <Common/EfiImage.h>\r
-#include <Library/PeCoffLib.h>\r
-\r
-STATIC\r
-RETURN_STATUS\r
-PeCoffLoaderGetPeHeader (\r
-  IN OUT PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext,\r
-  OUT    EFI_IMAGE_NT_HEADERS          *PeHdr,\r
-  OUT    EFI_TE_IMAGE_HEADER           *TeHdr\r
-  );\r
-\r
-STATIC\r
-RETURN_STATUS\r
-PeCoffLoaderCheckImageType (\r
-  IN OUT PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext,\r
-  IN     EFI_IMAGE_NT_HEADERS          *PeHdr,\r
-  IN     EFI_TE_IMAGE_HEADER           *TeHdr\r
-  );\r
-\r
-STATIC\r
-VOID                            *\r
-PeCoffLoaderImageAddress (\r
-  IN OUT PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext,\r
-  IN     UINTN                         Address\r
-  );\r
-\r
-\r
-STATIC\r
-RETURN_STATUS\r
-PeCoffLoaderGetPeHeader (\r
-  IN OUT PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext,\r
-  OUT    EFI_IMAGE_NT_HEADERS          *PeHdr,\r
-  OUT    EFI_TE_IMAGE_HEADER           *TeHdr\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Retrieves the PE or TE Header from a PE/COFF or TE image\r
-\r
-Arguments:\r
-\r
-  ImageContext  - The context of the image being loaded\r
-\r
-  PeHdr         - The buffer in which to return the PE header\r
-  \r
-  TeHdr         - The buffer in which to return the TE header\r
-\r
-Returns:\r
-\r
-  RETURN_SUCCESS if the PE or TE Header is read, \r
-  Otherwise, the error status from reading the PE/COFF or TE image using the ImageRead function.\r
-\r
---*/\r
-{\r
-  RETURN_STATUS            Status;\r
-  EFI_IMAGE_DOS_HEADER  DosHdr;\r
-  UINTN                 Size;\r
-\r
-  ImageContext->IsTeImage = FALSE;\r
-  //\r
-  // Read the DOS image headers\r
-  //\r
-  Size = sizeof (EFI_IMAGE_DOS_HEADER);\r
-  Status = ImageContext->ImageRead (\r
-                          ImageContext->Handle,\r
-                          0,\r
-                          &Size,\r
-                          &DosHdr\r
-                          );\r
-  if (RETURN_ERROR (Status)) {\r
-    ImageContext->ImageError = IMAGE_ERROR_IMAGE_READ;\r
-    return Status;\r
-  }\r
-\r
-  ImageContext->PeCoffHeaderOffset = 0;\r
-  if (DosHdr.e_magic == EFI_IMAGE_DOS_SIGNATURE) {\r
-    //\r
-    // DOS image header is present, so read the PE header after the DOS image header\r
-    //\r
-    ImageContext->PeCoffHeaderOffset = DosHdr.e_lfanew;\r
-  }\r
-  //\r
-  // Read the PE/COFF Header\r
-  //\r
-  Size = sizeof (EFI_IMAGE_NT_HEADERS);\r
-  Status = ImageContext->ImageRead (\r
-                          ImageContext->Handle,\r
-                          ImageContext->PeCoffHeaderOffset,\r
-                          &Size,\r
-                          PeHdr\r
-                          );\r
-  if (RETURN_ERROR (Status)) {\r
-    ImageContext->ImageError = IMAGE_ERROR_IMAGE_READ;\r
-    return Status;\r
-  }\r
-  //\r
-  // Check the PE/COFF Header Signature. If not, then try to read a TE header\r
-  //\r
-  if (PeHdr->Signature != EFI_IMAGE_NT_SIGNATURE) {\r
-    Size = sizeof (EFI_TE_IMAGE_HEADER);\r
-    Status = ImageContext->ImageRead (\r
-                            ImageContext->Handle,\r
-                            0,\r
-                            &Size,\r
-                            TeHdr\r
-                            );\r
-    if (TeHdr->Signature != EFI_TE_IMAGE_HEADER_SIGNATURE) {\r
-      return RETURN_UNSUPPORTED;\r
-    }\r
-\r
-    ImageContext->IsTeImage = TRUE;\r
-  }\r
-\r
-  return RETURN_SUCCESS;\r
-}\r
-\r
-STATIC\r
-RETURN_STATUS\r
-PeCoffLoaderCheckImageType (\r
-  IN OUT PE_COFF_LOADER_IMAGE_CONTEXT          *ImageContext,\r
-  IN     EFI_IMAGE_NT_HEADERS                  *PeHdr,\r
-  IN     EFI_TE_IMAGE_HEADER                   *TeHdr\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Checks the PE or TE header of a PE/COFF or TE image to determine if it supported\r
-\r
-Arguments:\r
-\r
-  ImageContext  - The context of the image being loaded\r
-\r
-  PeHdr         - The buffer in which to return the PE header\r
-  \r
-  TeHdr         - The buffer in which to return the TE header\r
-\r
-Returns:\r
-\r
-  RETURN_SUCCESS if the PE/COFF or TE image is supported\r
-  RETURN_UNSUPPORTED of the PE/COFF or TE image is not supported.\r
-\r
---*/\r
-{\r
-  //\r
-  // See if the machine type is supported.  We support a native machine type (IA-32/Itanium-based)\r
-  // and the machine type for the Virtual Machine.\r
-  //\r
-  if (ImageContext->IsTeImage == FALSE) {\r
-    ImageContext->Machine = PeHdr->FileHeader.Machine;\r
-  } else {\r
-    ImageContext->Machine = TeHdr->Machine;\r
-  }\r
-\r
-  if (!(EFI_IMAGE_MACHINE_TYPE_SUPPORTED (ImageContext->Machine))) {\r
-    ImageContext->ImageError = IMAGE_ERROR_INVALID_MACHINE_TYPE;\r
-    return RETURN_UNSUPPORTED;\r
-  }\r
-\r
-  //\r
-  // See if the image type is supported.  We support EFI Applications,\r
-  // EFI Boot Service Drivers, and EFI Runtime Drivers.\r
-  //\r
-  if (ImageContext->IsTeImage == FALSE) {\r
-    ImageContext->ImageType = PeHdr->OptionalHeader.Subsystem;\r
-  } else {\r
-    ImageContext->ImageType = (UINT16) (TeHdr->Subsystem);\r
-  }\r
-\r
-\r
-  return RETURN_SUCCESS;\r
-}\r
-\r
-RETURN_STATUS\r
-EFIAPI\r
-PeCoffLoaderGetImageInfo (\r
-  IN OUT PE_COFF_LOADER_IMAGE_CONTEXT           *ImageContext\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Retrieves information on a PE/COFF image\r
-\r
-Arguments:\r
-\r
-  This         - Calling context\r
-  ImageContext - The context of the image being loaded\r
-\r
-Returns:\r
-\r
-  RETURN_SUCCESS           - The information on the PE/COFF image was collected.\r
-  RETURN_INVALID_PARAMETER - ImageContext is NULL.\r
-  RETURN_UNSUPPORTED       - The PE/COFF image is not supported.\r
-  Otherwise             - The error status from reading the PE/COFF image using the\r
-                          ImageContext->ImageRead() function\r
-\r
---*/\r
-{\r
-  RETURN_STATUS                      Status;\r
-  EFI_IMAGE_NT_HEADERS            PeHdr;\r
-  EFI_TE_IMAGE_HEADER             TeHdr;\r
-  EFI_IMAGE_DATA_DIRECTORY        *DebugDirectoryEntry;\r
-  UINTN                           Size;\r
-  UINTN                           Index;\r
-  UINTN                           DebugDirectoryEntryRva;\r
-  UINTN                           DebugDirectoryEntryFileOffset;\r
-  UINTN                           SectionHeaderOffset;\r
-  EFI_IMAGE_SECTION_HEADER        SectionHeader;\r
-  EFI_IMAGE_DEBUG_DIRECTORY_ENTRY DebugEntry;\r
-\r
-  if (NULL == ImageContext) {\r
-    return RETURN_INVALID_PARAMETER;\r
-  }\r
-  //\r
-  // Assume success\r
-  //\r
-  ImageContext->ImageError  = IMAGE_ERROR_SUCCESS;\r
-\r
-  Status                    = PeCoffLoaderGetPeHeader (ImageContext, &PeHdr, &TeHdr);\r
-  if (RETURN_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  //\r
-  // Verify machine type\r
-  //\r
-  Status = PeCoffLoaderCheckImageType (ImageContext, &PeHdr, &TeHdr);\r
-  if (RETURN_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  //\r
-  // Retrieve the base address of the image\r
-  //\r
-  if (!(ImageContext->IsTeImage)) {\r
-    ImageContext->ImageAddress = PeHdr.OptionalHeader.ImageBase;\r
-  } else {\r
-    ImageContext->ImageAddress = (PHYSICAL_ADDRESS) (TeHdr.ImageBase);\r
-  }\r
-  //\r
-  // Initialize the alternate destination address to 0 indicating that it\r
-  // should not be used.\r
-  //\r
-  ImageContext->DestinationAddress = 0;\r
-\r
-  //\r
-  // Initialize the codeview pointer.\r
-  //\r
-  ImageContext->CodeView    = NULL;\r
-  ImageContext->PdbPointer  = NULL;\r
-\r
-  //\r
-  // Three cases with regards to relocations:\r
-  // - Image has base relocs, RELOCS_STRIPPED==0    => image is relocatable\r
-  // - Image has no base relocs, RELOCS_STRIPPED==1 => Image is not relocatable\r
-  // - Image has no base relocs, RELOCS_STRIPPED==0 => Image is relocatable but\r
-  //   has no base relocs to apply\r
-  // Obviously having base relocations with RELOCS_STRIPPED==1 is invalid.\r
-  //\r
-  // Look at the file header to determine if relocations have been stripped, and\r
-  // save this info in the image context for later use.\r
-  //\r
-  if ((!(ImageContext->IsTeImage)) && ((PeHdr.FileHeader.Characteristics & EFI_IMAGE_FILE_RELOCS_STRIPPED) != 0)) {\r
-    ImageContext->RelocationsStripped = TRUE;\r
-  } else {\r
-    ImageContext->RelocationsStripped = FALSE;\r
-  }\r
-\r
-  if (!(ImageContext->IsTeImage)) {\r
-    ImageContext->ImageSize         = (UINT64) PeHdr.OptionalHeader.SizeOfImage;\r
-    ImageContext->SectionAlignment  = PeHdr.OptionalHeader.SectionAlignment;\r
-    ImageContext->SizeOfHeaders     = PeHdr.OptionalHeader.SizeOfHeaders;\r
-\r
-    //\r
-    // Modify ImageSize to contain .PDB file name if required and initialize\r
-    // PdbRVA field...\r
-    //\r
-    if (PeHdr.OptionalHeader.NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_DEBUG) {\r
-      DebugDirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *) &(PeHdr.OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG]);\r
-\r
-      DebugDirectoryEntryRva = DebugDirectoryEntry->VirtualAddress;\r
-\r
-      //\r
-      // Determine the file offset of the debug directory...  This means we walk\r
-      // the sections to find which section contains the RVA of the debug\r
-      // directory\r
-      //\r
-      DebugDirectoryEntryFileOffset = 0;\r
-\r
-      SectionHeaderOffset = (UINTN)(\r
-                               ImageContext->PeCoffHeaderOffset +\r
-                               sizeof (UINT32) + \r
-                               sizeof (EFI_IMAGE_FILE_HEADER) + \r
-                               PeHdr.FileHeader.SizeOfOptionalHeader\r
-                               );\r
-\r
-      for (Index = 0; Index < PeHdr.FileHeader.NumberOfSections; Index++) {\r
-        //\r
-        // Read section header from file\r
-        //\r
-        Size = sizeof (EFI_IMAGE_SECTION_HEADER);\r
-        Status = ImageContext->ImageRead (\r
-                                 ImageContext->Handle,\r
-                                 SectionHeaderOffset,\r
-                                 &Size,\r
-                                 &SectionHeader\r
-                                 );\r
-        if (RETURN_ERROR (Status)) {\r
-          ImageContext->ImageError = IMAGE_ERROR_IMAGE_READ;\r
-          return Status;\r
-        }\r
-\r
-        if (DebugDirectoryEntryRva >= SectionHeader.VirtualAddress &&\r
-            DebugDirectoryEntryRva < SectionHeader.VirtualAddress + SectionHeader.Misc.VirtualSize) {\r
-            DebugDirectoryEntryFileOffset =\r
-            DebugDirectoryEntryRva - SectionHeader.VirtualAddress + SectionHeader.PointerToRawData;\r
-          break;\r
-        }\r
-\r
-        SectionHeaderOffset += sizeof (EFI_IMAGE_SECTION_HEADER);\r
-      }\r
-\r
-      if (DebugDirectoryEntryFileOffset != 0) {\r
-        for (Index = 0; Index < DebugDirectoryEntry->Size; Index++) {\r
-          //\r
-          // Read next debug directory entry\r
-          //\r
-          Size = sizeof (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY);\r
-          Status = ImageContext->ImageRead (\r
-                                   ImageContext->Handle,\r
-                                   DebugDirectoryEntryFileOffset,\r
-                                   &Size,\r
-                                   &DebugEntry\r
-                                   );\r
-          if (RETURN_ERROR (Status)) {\r
-            ImageContext->ImageError = IMAGE_ERROR_IMAGE_READ;\r
-            return Status;\r
-          }\r
-\r
-          if (DebugEntry.Type == EFI_IMAGE_DEBUG_TYPE_CODEVIEW) {\r
-            ImageContext->DebugDirectoryEntryRva = (UINT32) (DebugDirectoryEntryRva + Index * sizeof (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY));\r
-            if (DebugEntry.RVA == 0 && DebugEntry.FileOffset != 0) {\r
-              ImageContext->ImageSize += DebugEntry.SizeOfData;\r
-            }\r
-\r
-            return RETURN_SUCCESS;\r
-          }\r
-        }\r
-      }\r
-    }\r
-  } else {\r
-    ImageContext->ImageSize         = 0;\r
-    ImageContext->SectionAlignment  = 4096;\r
-    ImageContext->SizeOfHeaders     = sizeof (EFI_TE_IMAGE_HEADER) + (UINTN) TeHdr.BaseOfCode - (UINTN) TeHdr.StrippedSize;\r
-\r
-    DebugDirectoryEntry             = &TeHdr.DataDirectory[1];\r
-    DebugDirectoryEntryRva          = DebugDirectoryEntry->VirtualAddress;\r
-    SectionHeaderOffset             = (UINTN) (sizeof (EFI_TE_IMAGE_HEADER));\r
-\r
-    DebugDirectoryEntryFileOffset   = 0;\r
-\r
-    for (Index = 0; Index < TeHdr.NumberOfSections;) {\r
-      //\r
-      // Read section header from file\r
-      //\r
-      Size = sizeof (EFI_IMAGE_SECTION_HEADER);\r
-      Status = ImageContext->ImageRead (\r
-                               ImageContext->Handle,\r
-                               SectionHeaderOffset,\r
-                               &Size,\r
-                               &SectionHeader\r
-                               );\r
-      if (RETURN_ERROR (Status)) {\r
-        ImageContext->ImageError = IMAGE_ERROR_IMAGE_READ;\r
-        return Status;\r
-      }\r
-\r
-      if (DebugDirectoryEntryRva >= SectionHeader.VirtualAddress &&\r
-          DebugDirectoryEntryRva < SectionHeader.VirtualAddress + SectionHeader.Misc.VirtualSize) {\r
-        DebugDirectoryEntryFileOffset = DebugDirectoryEntryRva -\r
-          SectionHeader.VirtualAddress +\r
-          SectionHeader.PointerToRawData +\r
-          sizeof (EFI_TE_IMAGE_HEADER) -\r
-          TeHdr.StrippedSize;\r
-\r
-        //\r
-        // File offset of the debug directory was found, if this is not the last\r
-        // section, then skip to the last section for calculating the image size.\r
-        //\r
-        if (Index < (UINTN) TeHdr.NumberOfSections - 1) {\r
-          SectionHeaderOffset += (TeHdr.NumberOfSections - 1 - Index) * sizeof (EFI_IMAGE_SECTION_HEADER);\r
-          Index = TeHdr.NumberOfSections - 1;\r
-          continue;\r
-        }\r
-      }\r
-\r
-      //\r
-      // In Te image header there is not a field to describe the ImageSize.\r
-      // Actually, the ImageSize equals the RVA plus the VirtualSize of \r
-      // the last section mapped into memory (Must be rounded up to \r
-      // a mulitple of Section Alignment). Per the PE/COFF specification, the\r
-      // section headers in the Section Table must appear in order of the RVA\r
-      // values for the corresponding sections. So the ImageSize can be determined\r
-      // by the RVA and the VirtualSize of the last section header in the\r
-      // Section Table.\r
-      //\r
-      if ((++Index) == (UINTN) TeHdr.NumberOfSections) {\r
-        ImageContext->ImageSize = (SectionHeader.VirtualAddress + SectionHeader.Misc.VirtualSize +\r
-                                   ImageContext->SectionAlignment - 1) & ~(ImageContext->SectionAlignment - 1);\r
-      }\r
-\r
-      SectionHeaderOffset += sizeof (EFI_IMAGE_SECTION_HEADER);\r
-    }\r
-\r
-    if (DebugDirectoryEntryFileOffset != 0) {\r
-      for (Index = 0; Index < DebugDirectoryEntry->Size; Index++) {\r
-        //\r
-        // Read next debug directory entry\r
-        //\r
-        Size = sizeof (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY);\r
-        Status = ImageContext->ImageRead (\r
-                                 ImageContext->Handle,\r
-                                 DebugDirectoryEntryFileOffset,\r
-                                 &Size,\r
-                                 &DebugEntry\r
-                                 );\r
-        if (RETURN_ERROR (Status)) {\r
-          ImageContext->ImageError = IMAGE_ERROR_IMAGE_READ;\r
-          return Status;\r
-        }\r
-\r
-        if (DebugEntry.Type == EFI_IMAGE_DEBUG_TYPE_CODEVIEW) {\r
-          ImageContext->DebugDirectoryEntryRva = (UINT32) (DebugDirectoryEntryRva + Index * sizeof (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY));\r
-          return RETURN_SUCCESS;\r
-        }\r
-      }\r
-    }\r
-  }\r
-\r
-  return RETURN_SUCCESS;\r
-}\r
-\r
-STATIC\r
-VOID *\r
-PeCoffLoaderImageAddress (\r
-  IN OUT PE_COFF_LOADER_IMAGE_CONTEXT          *ImageContext,\r
-  IN     UINTN                                 Address\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Converts an image address to the loaded address\r
-\r
-Arguments:\r
-\r
-  ImageContext  - The context of the image being loaded\r
-\r
-  Address       - The address to be converted to the loaded address\r
-\r
-Returns:\r
-\r
-  NULL if the address can not be converted, otherwise, the converted address\r
-\r
---*/\r
-{\r
-  if (Address >= ImageContext->ImageSize) {\r
-    ImageContext->ImageError = IMAGE_ERROR_INVALID_IMAGE_ADDRESS;\r
-    return NULL;\r
-  }\r
-\r
-  return (CHAR8 *) ((UINTN) ImageContext->ImageAddress + Address);\r
-}\r
-\r
-RETURN_STATUS\r
-EFIAPI\r
-PeCoffLoaderRelocateImage (\r
-  IN OUT PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Relocates a PE/COFF image in memory\r
-\r
-Arguments:\r
-\r
-  This         - Calling context\r
-\r
-  ImageContext - Contains information on the loaded image to relocate\r
-\r
-Returns:\r
-\r
-  RETURN_SUCCESS      if the PE/COFF image was relocated\r
-  RETURN_LOAD_ERROR   if the image is not a valid PE/COFF image\r
-  RETURN_UNSUPPORTED  not support\r
-\r
---*/\r
-{\r
-  RETURN_STATUS                Status;\r
-  EFI_IMAGE_NT_HEADERS      *PeHdr;\r
-  EFI_TE_IMAGE_HEADER       *TeHdr;\r
-  EFI_IMAGE_DATA_DIRECTORY  *RelocDir;\r
-  UINT64                    Adjust;\r
-  EFI_IMAGE_BASE_RELOCATION *RelocBase;\r
-  EFI_IMAGE_BASE_RELOCATION *RelocBaseEnd;\r
-  UINT16                    *Reloc;\r
-  UINT16                    *RelocEnd;\r
-  CHAR8                     *Fixup;\r
-  CHAR8                     *FixupBase;\r
-  UINT16                    *F16;\r
-  UINT32                    *F32;\r
-  CHAR8                     *FixupData;\r
-  PHYSICAL_ADDRESS      BaseAddress;\r
-\r
-  PeHdr = NULL;\r
-  TeHdr = NULL;\r
-  //\r
-  // Assume success\r
-  //\r
-  ImageContext->ImageError = IMAGE_ERROR_SUCCESS;\r
-\r
-  //\r
-  // If there are no relocation entries, then we are done\r
-  //\r
-  if (ImageContext->RelocationsStripped) {\r
-    return RETURN_SUCCESS;\r
-  }\r
-\r
-  //\r
-  // If the destination address is not 0, use that rather than the\r
-  // image address as the relocation target.\r
-  //\r
-  if (ImageContext->DestinationAddress) {\r
-    BaseAddress = ImageContext->DestinationAddress;\r
-  } else {\r
-    BaseAddress = ImageContext->ImageAddress;\r
-  }\r
-\r
-  if (!(ImageContext->IsTeImage)) {\r
-    PeHdr = (EFI_IMAGE_NT_HEADERS *)((UINTN)ImageContext->ImageAddress + \r
-                                            ImageContext->PeCoffHeaderOffset);\r
-    Adjust = (UINT64) BaseAddress - PeHdr->OptionalHeader.ImageBase;\r
-    PeHdr->OptionalHeader.ImageBase = (UINTN) BaseAddress;\r
-\r
-    //\r
-    // Find the relocation block\r
-    //\r
-    // Per the PE/COFF spec, you can't assume that a given data directory\r
-    // is present in the image. You have to check the NumberOfRvaAndSizes in\r
-    // the optional header to verify a desired directory entry is there.\r
-    //\r
-    if (PeHdr->OptionalHeader.NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC) {\r
-      RelocDir  = &PeHdr->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC];\r
-      RelocBase = PeCoffLoaderImageAddress (ImageContext, RelocDir->VirtualAddress);\r
-      RelocBaseEnd = PeCoffLoaderImageAddress (\r
-                      ImageContext,\r
-                      RelocDir->VirtualAddress + RelocDir->Size - 1\r
-                      );\r
-    } else {\r
-      //\r
-      // Set base and end to bypass processing below.\r
-      //\r
-      RelocBase = RelocBaseEnd = 0;\r
-    }\r
-  } else {\r
-    TeHdr             = (EFI_TE_IMAGE_HEADER *) (UINTN) (ImageContext->ImageAddress);\r
-    Adjust            = (UINT64) (BaseAddress - TeHdr->ImageBase);\r
-    TeHdr->ImageBase  = (UINT64) (BaseAddress);\r
-\r
-    //\r
-    // Find the relocation block\r
-    //\r
-    RelocDir = &TeHdr->DataDirectory[0];\r
-    RelocBase = (EFI_IMAGE_BASE_RELOCATION *)(UINTN)(\r
-                                    ImageContext->ImageAddress + \r
-                                    RelocDir->VirtualAddress +\r
-                                    sizeof(EFI_TE_IMAGE_HEADER) - \r
-                                    TeHdr->StrippedSize\r
-                                    );\r
-    RelocBaseEnd = (EFI_IMAGE_BASE_RELOCATION *) ((UINTN) RelocBase + (UINTN) RelocDir->Size - 1);\r
-  }\r
-  \r
-  //\r
-  // Run the relocation information and apply the fixups\r
-  //\r
-  FixupData = ImageContext->FixupData;\r
-  while (RelocBase < RelocBaseEnd) {\r
-\r
-    Reloc     = (UINT16 *) ((CHAR8 *) RelocBase + sizeof (EFI_IMAGE_BASE_RELOCATION));\r
-    RelocEnd  = (UINT16 *) ((CHAR8 *) RelocBase + RelocBase->SizeOfBlock);\r
-    if (!(ImageContext->IsTeImage)) {\r
-      FixupBase = PeCoffLoaderImageAddress (ImageContext, RelocBase->VirtualAddress);\r
-    } else {\r
-      FixupBase = (CHAR8 *)(UINTN)(ImageContext->ImageAddress +\r
-                    RelocBase->VirtualAddress +\r
-                    sizeof(EFI_TE_IMAGE_HEADER) - \r
-                    TeHdr->StrippedSize\r
-                    );\r
-    }\r
-\r
-    if ((CHAR8 *) RelocEnd < (CHAR8 *) ((UINTN) ImageContext->ImageAddress) ||\r
-        (CHAR8 *) RelocEnd > (CHAR8 *)((UINTN)ImageContext->ImageAddress + \r
-          (UINTN)ImageContext->ImageSize)) {\r
-      ImageContext->ImageError = IMAGE_ERROR_FAILED_RELOCATION;\r
-      return RETURN_LOAD_ERROR;\r
-    }\r
-\r
-    //\r
-    // Run this relocation record\r
-    //\r
-    while (Reloc < RelocEnd) {\r
-\r
-      Fixup = FixupBase + (*Reloc & 0xFFF);\r
-      switch ((*Reloc) >> 12) {\r
-      case EFI_IMAGE_REL_BASED_ABSOLUTE:\r
-        break;\r
-\r
-      case EFI_IMAGE_REL_BASED_HIGH:\r
-        F16   = (UINT16 *) Fixup;\r
-        *F16 = (UINT16) (*F16 + ((UINT16) ((UINT32) Adjust >> 16)));\r
-        if (FixupData != NULL) {\r
-          *(UINT16 *) FixupData = *F16;\r
-          FixupData             = FixupData + sizeof (UINT16);\r
-        }\r
-        break;\r
-\r
-      case EFI_IMAGE_REL_BASED_LOW:\r
-        F16   = (UINT16 *) Fixup;\r
-        *F16  = (UINT16) (*F16 + (UINT16) Adjust);\r
-        if (FixupData != NULL) {\r
-          *(UINT16 *) FixupData = *F16;\r
-          FixupData             = FixupData + sizeof (UINT16);\r
-        }\r
-        break;\r
-\r
-      case EFI_IMAGE_REL_BASED_HIGHLOW:\r
-        F32   = (UINT32 *) Fixup;\r
-        *F32  = *F32 + (UINT32) Adjust;\r
-        if (FixupData != NULL) {\r
-          FixupData             = ALIGN_POINTER (FixupData, sizeof (UINT32));\r
-          *(UINT32 *) FixupData = *F32;\r
-          FixupData             = FixupData + sizeof (UINT32);\r
-        }\r
-        break;\r
-\r
-      case EFI_IMAGE_REL_BASED_HIGHADJ:\r
-        //\r
-        // Return the same EFI_UNSUPPORTED return code as\r
-        // PeCoffLoaderRelocateImageEx() returns if it does not recognize\r
-        // the relocation type.\r
-        //\r
-        ImageContext->ImageError = IMAGE_ERROR_FAILED_RELOCATION;\r
-        return RETURN_UNSUPPORTED;\r
-\r
-      default:\r
-        Status = PeCoffLoaderRelocateImageEx (Reloc, Fixup, &FixupData, Adjust);\r
-        if (RETURN_ERROR (Status)) {\r
-          ImageContext->ImageError = IMAGE_ERROR_FAILED_RELOCATION;\r
-          return Status;\r
-        }\r
-      }\r
-\r
-      //\r
-      // Next relocation record\r
-      //\r
-      Reloc += 1;\r
-    }\r
-\r
-    //\r
-    // Next reloc block\r
-    //\r
-    RelocBase = (EFI_IMAGE_BASE_RELOCATION *) RelocEnd;\r
-  }\r
-\r
-  return RETURN_SUCCESS;\r
-}\r
-\r
-RETURN_STATUS\r
-EFIAPI\r
-PeCoffLoaderLoadImage (\r
-  IN OUT PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Loads a PE/COFF image into memory\r
-\r
-Arguments:\r
-\r
-  This         - Calling context\r
-\r
-  ImageContext - Contains information on image to load into memory\r
-\r
-Returns:\r
-\r
-  RETURN_SUCCESS            if the PE/COFF image was loaded\r
-  RETURN_BUFFER_TOO_SMALL   if the caller did not provide a large enough buffer\r
-  RETURN_LOAD_ERROR         if the image is a runtime driver with no relocations\r
-  RETURN_INVALID_PARAMETER  if the image address is invalid\r
-\r
---*/\r
-{\r
-  RETURN_STATUS                            Status;\r
-  EFI_IMAGE_NT_HEADERS                  *PeHdr;\r
-  EFI_TE_IMAGE_HEADER                   *TeHdr;\r
-  PE_COFF_LOADER_IMAGE_CONTEXT  CheckContext;\r
-  EFI_IMAGE_SECTION_HEADER              *FirstSection;\r
-  EFI_IMAGE_SECTION_HEADER              *Section;\r
-  UINTN                                 NumberOfSections;\r
-  UINTN                                 Index;\r
-  CHAR8                                 *Base;\r
-  CHAR8                                 *End;\r
-  CHAR8                                 *MaxEnd;\r
-  EFI_IMAGE_DATA_DIRECTORY              *DirectoryEntry;\r
-  EFI_IMAGE_DEBUG_DIRECTORY_ENTRY       *DebugEntry;\r
-  UINTN                                 Size;\r
-  UINT32                                TempDebugEntryRva;\r
-\r
-  PeHdr = NULL;\r
-  TeHdr = NULL;\r
-  //\r
-  // Assume success\r
-  //\r
-  ImageContext->ImageError = IMAGE_ERROR_SUCCESS;\r
-\r
-  //\r
-  // Copy the provided context info into our local version, get what we\r
-  // can from the original image, and then use that to make sure everything\r
-  // is legit.\r
-  //\r
-  CopyMem (&CheckContext, ImageContext, sizeof (PE_COFF_LOADER_IMAGE_CONTEXT));\r
-\r
-  Status = PeCoffLoaderGetImageInfo (&CheckContext);\r
-  if (RETURN_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Make sure there is enough allocated space for the image being loaded\r
-  //\r
-  if (ImageContext->ImageSize < CheckContext.ImageSize) {\r
-    ImageContext->ImageError = IMAGE_ERROR_INVALID_IMAGE_SIZE;\r
-    return RETURN_BUFFER_TOO_SMALL;\r
-  }\r
-\r
-  //\r
-  // If there's no relocations, then make sure it's not a runtime driver,\r
-  // and that it's being loaded at the linked address.\r
-  //\r
-  if (CheckContext.RelocationsStripped) {\r
-    //\r
-    // If the image does not contain relocations and it is a runtime driver\r
-    // then return an error.\r
-    //\r
-    if (CheckContext.ImageType == EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER) {\r
-      ImageContext->ImageError = IMAGE_ERROR_INVALID_SUBSYSTEM;\r
-      return RETURN_LOAD_ERROR;\r
-    }\r
-    //\r
-    // If the image does not contain relocations, and the requested load address\r
-    // is not the linked address, then return an error.\r
-    //\r
-    if (CheckContext.ImageAddress != ImageContext->ImageAddress) {\r
-      ImageContext->ImageError = IMAGE_ERROR_INVALID_IMAGE_ADDRESS;\r
-      return RETURN_INVALID_PARAMETER;\r
-    }\r
-  }\r
-  //\r
-  // Make sure the allocated space has the proper section alignment\r
-  //\r
-  if (!(ImageContext->IsTeImage)) {\r
-    if ((ImageContext->ImageAddress & (CheckContext.SectionAlignment - 1)) != 0) {\r
-      ImageContext->ImageError = IMAGE_ERROR_INVALID_SECTION_ALIGNMENT;\r
-      return RETURN_INVALID_PARAMETER;\r
-    }\r
-  }\r
-  //\r
-  // Read the entire PE/COFF or TE header into memory\r
-  //\r
-  if (!(ImageContext->IsTeImage)) {\r
-    Status = ImageContext->ImageRead (\r
-                            ImageContext->Handle,\r
-                            0,\r
-                            &ImageContext->SizeOfHeaders,\r
-                            (VOID *) (UINTN) ImageContext->ImageAddress\r
-                            );\r
-\r
-    PeHdr = (EFI_IMAGE_NT_HEADERS *)\r
-      ((UINTN)ImageContext->ImageAddress + ImageContext->PeCoffHeaderOffset);\r
-\r
-    FirstSection = (EFI_IMAGE_SECTION_HEADER *) (\r
-                      (UINTN)ImageContext->ImageAddress +\r
-                      ImageContext->PeCoffHeaderOffset +\r
-                      sizeof(UINT32) + \r
-                      sizeof(EFI_IMAGE_FILE_HEADER) + \r
-                      PeHdr->FileHeader.SizeOfOptionalHeader\r
-      );\r
-    NumberOfSections = (UINTN) (PeHdr->FileHeader.NumberOfSections);\r
-  } else {\r
-    Status = ImageContext->ImageRead (\r
-                            ImageContext->Handle,\r
-                            0,\r
-                            &ImageContext->SizeOfHeaders,\r
-                            (void *) (UINTN) ImageContext->ImageAddress\r
-                            );\r
-\r
-    TeHdr             = (EFI_TE_IMAGE_HEADER *) (UINTN) (ImageContext->ImageAddress);\r
-\r
-    FirstSection = (EFI_IMAGE_SECTION_HEADER *) (\r
-          (UINTN)ImageContext->ImageAddress +\r
-          sizeof(EFI_TE_IMAGE_HEADER)\r
-          );\r
-    NumberOfSections  = (UINTN) (TeHdr->NumberOfSections);\r
-\r
-  }\r
-\r
-  if (RETURN_ERROR (Status)) {\r
-    ImageContext->ImageError = IMAGE_ERROR_IMAGE_READ;\r
-    return RETURN_LOAD_ERROR;\r
-  }\r
-\r
-  //\r
-  // Load each section of the image\r
-  //\r
-  Section = FirstSection;\r
-  for (Index = 0, MaxEnd = NULL; Index < NumberOfSections; Index++) {\r
-\r
-    //\r
-    // Compute sections address\r
-    //\r
-    Base = PeCoffLoaderImageAddress (ImageContext, Section->VirtualAddress);\r
-    End = PeCoffLoaderImageAddress (\r
-            ImageContext,\r
-            Section->VirtualAddress + Section->Misc.VirtualSize - 1\r
-            );\r
-    if (ImageContext->IsTeImage) {\r
-      Base  = (CHAR8 *) ((UINTN) Base + sizeof (EFI_TE_IMAGE_HEADER) - (UINTN) TeHdr->StrippedSize);\r
-      End   = (CHAR8 *) ((UINTN) End + sizeof (EFI_TE_IMAGE_HEADER) - (UINTN) TeHdr->StrippedSize);\r
-    }\r
-\r
-    if (End > MaxEnd) {\r
-      MaxEnd = End;\r
-    }\r
-    //\r
-    // If the base start or end address resolved to 0, then fail.\r
-    //\r
-    if ((Base == NULL) || (End == NULL)) {\r
-      ImageContext->ImageError = IMAGE_ERROR_SECTION_NOT_LOADED;\r
-      return RETURN_LOAD_ERROR;\r
-    }\r
-\r
-    //\r
-    // Read the section\r
-    //\r
-    Size = (UINTN) Section->Misc.VirtualSize;\r
-    if ((Size == 0) || (Size > Section->SizeOfRawData)) {\r
-      Size = (UINTN) Section->SizeOfRawData;\r
-    }\r
-\r
-    if (Section->SizeOfRawData) {\r
-      if (!(ImageContext->IsTeImage)) {\r
-        Status = ImageContext->ImageRead (\r
-                                ImageContext->Handle,\r
-                                Section->PointerToRawData,\r
-                                &Size,\r
-                                Base\r
-                                );\r
-      } else {\r
-        Status = ImageContext->ImageRead (\r
-                                ImageContext->Handle,\r
-                                Section->PointerToRawData + sizeof (EFI_TE_IMAGE_HEADER) - (UINTN) TeHdr->StrippedSize,\r
-                                &Size,\r
-                                Base\r
-                                );\r
-      }\r
-\r
-      if (RETURN_ERROR (Status)) {\r
-        ImageContext->ImageError = IMAGE_ERROR_IMAGE_READ;\r
-        return Status;\r
-      }\r
-    }\r
-\r
-    //\r
-    // If raw size is less then virt size, zero fill the remaining\r
-    //\r
-\r
-    if (Size < Section->Misc.VirtualSize) {\r
-      ZeroMem (Base + Size, Section->Misc.VirtualSize - Size);\r
-    }\r
-\r
-    //\r
-    // Next Section\r
-    //\r
-    Section += 1;\r
-  }\r
-\r
-  //\r
-  // Get image's entry point\r
-  //\r
-  if (!(ImageContext->IsTeImage)) {\r
-    ImageContext->EntryPoint = (PHYSICAL_ADDRESS) (UINTN) PeCoffLoaderImageAddress (\r
-                                                                ImageContext,\r
-                                                                PeHdr->OptionalHeader.AddressOfEntryPoint\r
-                                                                );\r
-  } else {\r
-    ImageContext->EntryPoint =  (PHYSICAL_ADDRESS) (\r
-                       (UINTN)ImageContext->ImageAddress +\r
-                       (UINTN)TeHdr->AddressOfEntryPoint +\r
-                       (UINTN)sizeof(EFI_TE_IMAGE_HEADER) -\r
-          (UINTN) TeHdr->StrippedSize\r
-      );\r
-  }\r
-\r
-  //\r
-  // Determine the size of the fixup data\r
-  //\r
-  // Per the PE/COFF spec, you can't assume that a given data directory\r
-  // is present in the image. You have to check the NumberOfRvaAndSizes in\r
-  // the optional header to verify a desired directory entry is there.\r
-  //\r
-  if (!(ImageContext->IsTeImage)) {\r
-    if (PeHdr->OptionalHeader.NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC) {\r
-      DirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *)\r
-        &PeHdr->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC];\r
-      ImageContext->FixupDataSize = DirectoryEntry->Size / sizeof (UINT16) * sizeof (UINTN);\r
-    } else {\r
-      ImageContext->FixupDataSize = 0;\r
-    }\r
-  } else {\r
-    DirectoryEntry              = &TeHdr->DataDirectory[0];\r
-    ImageContext->FixupDataSize = DirectoryEntry->Size / sizeof (UINT16) * sizeof (UINTN);\r
-  }\r
-  //\r
-  // Consumer must allocate a buffer for the relocation fixup log.\r
-  // Only used for runtime drivers.\r
-  //\r
-  ImageContext->FixupData = NULL;\r
-\r
-  //\r
-  // Load the Codeview info if present\r
-  //\r
-  if (ImageContext->DebugDirectoryEntryRva != 0) {\r
-    if (!(ImageContext->IsTeImage)) {\r
-      DebugEntry = PeCoffLoaderImageAddress (\r
-                    ImageContext,\r
-                    ImageContext->DebugDirectoryEntryRva\r
-                    );\r
-    } else {\r
-      DebugEntry = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *)(UINTN)(\r
-                                               ImageContext->ImageAddress +\r
-                                               ImageContext->DebugDirectoryEntryRva +\r
-                                               sizeof(EFI_TE_IMAGE_HEADER) -\r
-                                               TeHdr->StrippedSize\r
-                                               );\r
-    }\r
-\r
-    if (DebugEntry != NULL) {\r
-      TempDebugEntryRva = DebugEntry->RVA;\r
-      if (DebugEntry->RVA == 0 && DebugEntry->FileOffset != 0) {\r
-        Section--;\r
-        if ((UINTN) Section->SizeOfRawData < Section->Misc.VirtualSize) {\r
-          TempDebugEntryRva = Section->VirtualAddress + Section->Misc.VirtualSize;\r
-        } else {\r
-          TempDebugEntryRva = Section->VirtualAddress + Section->SizeOfRawData;\r
-        }\r
-      }\r
-\r
-      if (TempDebugEntryRva != 0) {\r
-        if (!(ImageContext->IsTeImage)) {\r
-          ImageContext->CodeView = PeCoffLoaderImageAddress (ImageContext, TempDebugEntryRva);\r
-        } else {\r
-          ImageContext->CodeView = (VOID *)(\r
-                      (UINTN)ImageContext->ImageAddress +\r
-                      (UINTN)TempDebugEntryRva +\r
-                      (UINTN)sizeof(EFI_TE_IMAGE_HEADER) -\r
-                (UINTN) TeHdr->StrippedSize\r
-            );\r
-        }\r
-\r
-        if (ImageContext->CodeView == NULL) {\r
-          ImageContext->ImageError = IMAGE_ERROR_IMAGE_READ;\r
-          return RETURN_LOAD_ERROR;\r
-        }\r
-\r
-        if (DebugEntry->RVA == 0) {\r
-          Size = DebugEntry->SizeOfData;\r
-          if (!(ImageContext->IsTeImage)) {\r
-            Status = ImageContext->ImageRead (\r
-                                    ImageContext->Handle,\r
-                                    DebugEntry->FileOffset,\r
-                                    &Size,\r
-                                    ImageContext->CodeView\r
-                                    );\r
-          } else {\r
-            Status = ImageContext->ImageRead (\r
-                                    ImageContext->Handle,\r
-                                    DebugEntry->FileOffset + sizeof (EFI_TE_IMAGE_HEADER) - TeHdr->StrippedSize,\r
-                                    &Size,\r
-                                    ImageContext->CodeView\r
-                                    );\r
-            //\r
-            // Should we apply fix up to this field according to the size difference between PE and TE?\r
-            // Because now we maintain TE header fields unfixed, this field will also remain as they are\r
-            // in original PE image.\r
-            //\r
-          }\r
-\r
-          if (RETURN_ERROR (Status)) {\r
-            ImageContext->ImageError = IMAGE_ERROR_IMAGE_READ;\r
-            return RETURN_LOAD_ERROR;\r
-          }\r
-\r
-          DebugEntry->RVA = TempDebugEntryRva;\r
-        }\r
-\r
-        switch (*(UINT32 *) ImageContext->CodeView) {\r
-        case CODEVIEW_SIGNATURE_NB10:\r
-          ImageContext->PdbPointer = (CHAR8 *) ImageContext->CodeView + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY);\r
-          break;\r
-\r
-        case CODEVIEW_SIGNATURE_RSDS:\r
-          ImageContext->PdbPointer = (CHAR8 *) ImageContext->CodeView + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_RSDS_ENTRY);\r
-          break;\r
-\r
-        default:\r
-          break;\r
-        }\r
-      }\r
-    }\r
-  }\r
-\r
-  return Status;\r
-}\r
diff --git a/Tools/CodeTools/TianoTools/PeCoffLoader/Common/EfiImage.h b/Tools/CodeTools/TianoTools/PeCoffLoader/Common/EfiImage.h
deleted file mode 100644 (file)
index 9528e6b..0000000
+++ /dev/null
@@ -1,701 +0,0 @@
-/** @file\r
-  EFI image format for PE32+. Please note some data structures are different\r
-  for IA-32 and Itanium-based images, look for UINTN and the #ifdef EFI_IA64\r
-\r
-  @bug Fix text - doc as defined in MSFT EFI specification.\r
-\r
-  Copyright (c) 2006, Intel Corporation                                                         \r
-  All rights reserved. This program and the accompanying materials                          \r
-  are licensed and made available under the terms and conditions of the BSD License         \r
-  which accompanies this distribution.  The full text of the license may be found at        \r
-  http://opensource.org/licenses/bsd-license.php                                            \r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-  Module Name:  EfiImage.h\r
-\r
-**/\r
-\r
-#ifndef __EFI_IMAGE_H__\r
-#define __EFI_IMAGE_H__\r
-\r
-//\r
-// PE32+ Subsystem type for EFI images\r
-//\r
-#define EFI_IMAGE_SUBSYSTEM_EFI_APPLICATION         10\r
-#define EFI_IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER 11\r
-#define EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER      12\r
-#define EFI_IMAGE_SUBSYSTEM_SAL_RUNTIME_DRIVER      13\r
-\r
-//\r
-// BugBug: Need to get a real answer for this problem. This is not in the\r
-//         PE specification.\r
-//\r
-//         A SAL runtime driver does not get fixed up when a transition to\r
-//         virtual mode is made. In all other cases it should be treated\r
-//         like a EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER image\r
-//\r
-#define EFI_IMAGE_SUBSYSTEM_SAL_RUNTIME_DRIVER  13\r
-\r
-//\r
-// PE32+ Machine type for EFI images\r
-//\r
-#define IMAGE_FILE_MACHINE_I386     0x014c\r
-#define IMAGE_FILE_MACHINE_IA64     0x0200\r
-#define IMAGE_FILE_MACHINE_EBC      0x0EBC\r
-#define IMAGE_FILE_MACHINE_X64      0x8664\r
-//\r
-// Support old names for backward compatible\r
-//\r
-#define EFI_IMAGE_MACHINE_IA32      IMAGE_FILE_MACHINE_I386 \r
-#define EFI_IMAGE_MACHINE_IA64      IMAGE_FILE_MACHINE_IA64  \r
-#define EFI_IMAGE_MACHINE_IPF       IMAGE_FILE_MACHINE_IA64  \r
-#define EFI_IMAGE_MACHINE_EBC       IMAGE_FILE_MACHINE_EBC  \r
-#define EFI_IMAGE_MACHINE_X64       IMAGE_FILE_MACHINE_X64\r
-\r
-#define EFI_IMAGE_DOS_SIGNATURE     0x5A4D      // MZ\r
-#define EFI_IMAGE_OS2_SIGNATURE     0x454E      // NE\r
-#define EFI_IMAGE_OS2_SIGNATURE_LE  0x454C      // LE\r
-#define EFI_IMAGE_NT_SIGNATURE      0x00004550  // PE00\r
-#define EFI_IMAGE_EDOS_SIGNATURE    0x44454550  // PEED\r
-\r
-///\r
-/// PE images can start with an optional DOS header, so if an image is run\r
-///  under DOS it can print an error message.\r
-///\r
-typedef struct {\r
-  UINT16  e_magic;    // Magic number\r
-  UINT16  e_cblp;     // Bytes on last page of file\r
-  UINT16  e_cp;       // Pages in file\r
-  UINT16  e_crlc;     // Relocations\r
-  UINT16  e_cparhdr;  // Size of header in paragraphs\r
-  UINT16  e_minalloc; // Minimum extra paragraphs needed\r
-  UINT16  e_maxalloc; // Maximum extra paragraphs needed\r
-  UINT16  e_ss;       // Initial (relative) SS value\r
-  UINT16  e_sp;       // Initial SP value\r
-  UINT16  e_csum;     // Checksum\r
-  UINT16  e_ip;       // Initial IP value\r
-  UINT16  e_cs;       // Initial (relative) CS value\r
-  UINT16  e_lfarlc;   // File address of relocation table\r
-  UINT16  e_ovno;     // Overlay number\r
-  UINT16  e_res[4];   // Reserved words\r
-  UINT16  e_oemid;    // OEM identifier (for e_oeminfo)\r
-  UINT16  e_oeminfo;  // OEM information; e_oemid specific\r
-  UINT16  e_res2[10]; // Reserved words\r
-  UINT32  e_lfanew;   // File address of new exe header\r
-} EFI_IMAGE_DOS_HEADER;\r
-\r
-///\r
-/// File header format.\r
-///\r
-typedef struct {\r
-  UINT16  Machine;\r
-  UINT16  NumberOfSections;\r
-  UINT32  TimeDateStamp;\r
-  UINT32  PointerToSymbolTable;\r
-  UINT32  NumberOfSymbols;\r
-  UINT16  SizeOfOptionalHeader;\r
-  UINT16  Characteristics;\r
-} EFI_IMAGE_FILE_HEADER;\r
-\r
-#define EFI_IMAGE_SIZEOF_FILE_HEADER        20\r
-\r
-#define EFI_IMAGE_FILE_RELOCS_STRIPPED      0x0001  // Relocation info stripped from file.\r
-#define EFI_IMAGE_FILE_EXECUTABLE_IMAGE     0x0002  // File is executable  (i.e. no unresolved externel references).\r
-#define EFI_IMAGE_FILE_LINE_NUMS_STRIPPED   0x0004  // Line nunbers stripped from file.\r
-#define EFI_IMAGE_FILE_LOCAL_SYMS_STRIPPED  0x0008  // Local symbols stripped from file.\r
-#define EFI_IMAGE_FILE_BYTES_REVERSED_LO    0x0080  // Bytes of machine word are reversed.\r
-#define EFI_IMAGE_FILE_32BIT_MACHINE        0x0100  // 32 bit word machine.\r
-#define EFI_IMAGE_FILE_DEBUG_STRIPPED       0x0200  // Debugging info stripped from file in .DBG file\r
-#define EFI_IMAGE_FILE_SYSTEM               0x1000  // System File.\r
-#define EFI_IMAGE_FILE_DLL                  0x2000  // File is a DLL.\r
-#define EFI_IMAGE_FILE_BYTES_REVERSED_HI    0x8000  // Bytes of machine word are reversed.\r
-#define EFI_IMAGE_FILE_MACHINE_UNKNOWN      0\r
-#define EFI_IMAGE_FILE_MACHINE_I386         0x14c   // Intel 386.\r
-#define EFI_IMAGE_FILE_MACHINE_R3000        0x162   // MIPS* little-endian, 0540 big-endian\r
-#define EFI_IMAGE_FILE_MACHINE_R4000        0x166   // MIPS* little-endian\r
-#define EFI_IMAGE_FILE_MACHINE_ALPHA        0x184   // Alpha_AXP*\r
-#define EFI_IMAGE_FILE_MACHINE_POWERPC      0x1F0   // IBM* PowerPC Little-Endian\r
-#define EFI_IMAGE_FILE_MACHINE_TAHOE        0x7cc   // Intel EM machine\r
-//\r
-// * Other names and brands may be claimed as the property of others.\r
-//\r
-\r
-///\r
-/// Directory format.\r
-///\r
-typedef struct {\r
-  UINT32  VirtualAddress;\r
-  UINT32  Size;\r
-} EFI_IMAGE_DATA_DIRECTORY;\r
-\r
-#define EFI_IMAGE_NUMBER_OF_DIRECTORY_ENTRIES 16\r
-\r
-typedef struct {\r
-  UINT16  Magic;\r
-  UINT8   MajorLinkerVersion;\r
-  UINT8   MinorLinkerVersion;\r
-  UINT32  SizeOfCode;\r
-  UINT32  SizeOfInitializedData;\r
-  UINT32  SizeOfUninitializedData;\r
-  UINT32  AddressOfEntryPoint;\r
-  UINT32  BaseOfCode;\r
-  UINT32  BaseOfData;\r
-  UINT32  BaseOfBss;\r
-  UINT32  GprMask;\r
-  UINT32  CprMask[4];\r
-  UINT32  GpValue;\r
-} EFI_IMAGE_ROM_OPTIONAL_HEADER;\r
-\r
-#define EFI_IMAGE_ROM_OPTIONAL_HDR_MAGIC      0x107\r
-#define EFI_IMAGE_SIZEOF_ROM_OPTIONAL_HEADER  sizeof (EFI_IMAGE_ROM_OPTIONAL_HEADER)\r
-\r
-typedef struct {\r
-  EFI_IMAGE_FILE_HEADER         FileHeader;\r
-  EFI_IMAGE_ROM_OPTIONAL_HEADER OptionalHeader;\r
-} EFI_IMAGE_ROM_HEADERS;\r
-\r
-///\r
-/// @attention\r
-/// EFI_IMAGE_OPTIONAL_HEADER32 and EFI_IMAGE_OPTIONAL_HEADER64\r
-/// are for use ONLY by tools.  All proper EFI code MUST use\r
-/// EFI_IMAGE_OPTIONAL_HEADER ONLY!!!\r
-///\r
-#define EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC 0x10b\r
-\r
-typedef struct {\r
-  //\r
-  // Standard fields.\r
-  //\r
-  UINT16                    Magic;\r
-  UINT8                     MajorLinkerVersion;\r
-  UINT8                     MinorLinkerVersion;\r
-  UINT32                    SizeOfCode;\r
-  UINT32                    SizeOfInitializedData;\r
-  UINT32                    SizeOfUninitializedData;\r
-  UINT32                    AddressOfEntryPoint;\r
-  UINT32                    BaseOfCode;\r
-  UINT32                    BaseOfData;\r
-  //\r
-  // NT additional fields.\r
-  //\r
-  UINT32                    ImageBase;\r
-  UINT32                    SectionAlignment;\r
-  UINT32                    FileAlignment;\r
-  UINT16                    MajorOperatingSystemVersion;\r
-  UINT16                    MinorOperatingSystemVersion;\r
-  UINT16                    MajorImageVersion;\r
-  UINT16                    MinorImageVersion;\r
-  UINT16                    MajorSubsystemVersion;\r
-  UINT16                    MinorSubsystemVersion;\r
-  UINT32                    Win32VersionValue;\r
-  UINT32                    SizeOfImage;\r
-  UINT32                    SizeOfHeaders;\r
-  UINT32                    CheckSum;\r
-  UINT16                    Subsystem;\r
-  UINT16                    DllCharacteristics;\r
-  UINT32                    SizeOfStackReserve;\r
-  UINT32                    SizeOfStackCommit;\r
-  UINT32                    SizeOfHeapReserve;\r
-  UINT32                    SizeOfHeapCommit;\r
-  UINT32                    LoaderFlags;\r
-  UINT32                    NumberOfRvaAndSizes;\r
-  EFI_IMAGE_DATA_DIRECTORY  DataDirectory[EFI_IMAGE_NUMBER_OF_DIRECTORY_ENTRIES];\r
-} EFI_IMAGE_OPTIONAL_HEADER32;\r
-\r
-///\r
-/// @attention\r
-/// EFI_IMAGE_OPTIONAL_HEADER32 and EFI_IMAGE_OPTIONAL_HEADER64\r
-/// are for use ONLY by tools.  All proper EFI code MUST use\r
-/// EFI_IMAGE_OPTIONAL_HEADER ONLY!!!\r
-///\r
-#define EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC 0x20b\r
-\r
-typedef struct {\r
-  //\r
-  // Standard fields.\r
-  //\r
-  UINT16                    Magic;\r
-  UINT8                     MajorLinkerVersion;\r
-  UINT8                     MinorLinkerVersion;\r
-  UINT32                    SizeOfCode;\r
-  UINT32                    SizeOfInitializedData;\r
-  UINT32                    SizeOfUninitializedData;\r
-  UINT32                    AddressOfEntryPoint;\r
-  UINT32                    BaseOfCode;\r
-  //\r
-  // NT additional fields.\r
-  //\r
-  UINT64                    ImageBase;\r
-  UINT32                    SectionAlignment;\r
-  UINT32                    FileAlignment;\r
-  UINT16                    MajorOperatingSystemVersion;\r
-  UINT16                    MinorOperatingSystemVersion;\r
-  UINT16                    MajorImageVersion;\r
-  UINT16                    MinorImageVersion;\r
-  UINT16                    MajorSubsystemVersion;\r
-  UINT16                    MinorSubsystemVersion;\r
-  UINT32                    Win32VersionValue;\r
-  UINT32                    SizeOfImage;\r
-  UINT32                    SizeOfHeaders;\r
-  UINT32                    CheckSum;\r
-  UINT16                    Subsystem;\r
-  UINT16                    DllCharacteristics;\r
-  UINT64                    SizeOfStackReserve;\r
-  UINT64                    SizeOfStackCommit;\r
-  UINT64                    SizeOfHeapReserve;\r
-  UINT64                    SizeOfHeapCommit;\r
-  UINT32                    LoaderFlags;\r
-  UINT32                    NumberOfRvaAndSizes;\r
-  EFI_IMAGE_DATA_DIRECTORY  DataDirectory[EFI_IMAGE_NUMBER_OF_DIRECTORY_ENTRIES];\r
-} EFI_IMAGE_OPTIONAL_HEADER64;\r
-\r
-///\r
-/// @attention\r
-/// EFI_IMAGE_NT_HEADERS32 and EFI_IMAGE_HEADERS64 are for use ONLY\r
-/// by tools.  All proper EFI code MUST use EFI_IMAGE_NT_HEADERS ONLY!!!\r
-///\r
-typedef struct {\r
-  UINT32                      Signature;\r
-  EFI_IMAGE_FILE_HEADER       FileHeader;\r
-  EFI_IMAGE_OPTIONAL_HEADER32 OptionalHeader;\r
-} EFI_IMAGE_NT_HEADERS32;\r
-\r
-#define EFI_IMAGE_SIZEOF_NT_OPTIONAL32_HEADER sizeof (EFI_IMAGE_NT_HEADERS32)\r
-\r
-typedef struct {\r
-  UINT32                      Signature;\r
-  EFI_IMAGE_FILE_HEADER       FileHeader;\r
-  EFI_IMAGE_OPTIONAL_HEADER64 OptionalHeader;\r
-} EFI_IMAGE_NT_HEADERS64;\r
-\r
-#define EFI_IMAGE_SIZEOF_NT_OPTIONAL64_HEADER sizeof (EFI_IMAGE_NT_HEADERS64)\r
-\r
-//\r
-// Processor specific definition of EFI_IMAGE_OPTIONAL_HEADER so the\r
-// type name EFI_IMAGE_OPTIONAL_HEADER is appropriate to the build.  Same for\r
-// EFI_IMAGE_NT_HEADERS.  These definitions MUST be used by ALL EFI code.\r
-//\r
-#if   defined (MDE_CPU_IA32) && !defined (BUILDING_TOOLS) || \\r
-      defined (BUILDING_TOOLS) && defined (TOOL_BUILD_IA32_TARGET)\r
-\r
-// typedef EFI_IMAGE_OPTIONAL_HEADER32     EFI_IMAGE_OPTIONAL_HEADER;\r
-typedef EFI_IMAGE_NT_HEADERS32          EFI_IMAGE_NT_HEADERS;\r
-\r
-#define EFI_IMAGE_NT_OPTIONAL_HDR_MAGIC EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC\r
-#define EFI_IMAGE_MACHINE_TYPE_SUPPORTED(Machine) \\r
-  (((Machine) == EFI_IMAGE_MACHINE_IA32) || ((Machine) == EFI_IMAGE_MACHINE_EBC))\r
-\r
-#elif defined (MDE_CPU_IPF) && !defined (BUILDING_TOOLS) || \\r
-      defined (BUILDING_TOOLS) && defined (TOOL_BUILD_IPF_TARGET)\r
-\r
-typedef EFI_IMAGE_OPTIONAL_HEADER64     EFI_IMAGE_OPTIONAL_HEADER;\r
-typedef EFI_IMAGE_NT_HEADERS64          EFI_IMAGE_NT_HEADERS;\r
-\r
-#define EFI_IMAGE_NT_OPTIONAL_HDR_MAGIC EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC\r
-#define EFI_IMAGE_MACHINE_TYPE_SUPPORTED(Machine) \\r
-  (((Machine) == EFI_IMAGE_MACHINE_IPF) || ((Machine) == EFI_IMAGE_MACHINE_EBC))\r
-\r
-#elif defined (MDE_CPU_X64) && !defined (BUILDING_TOOLS) || \\r
-      defined (BUILDING_TOOLS) && defined (TOOL_BUILD_X64_TARGET)\r
-\r
-typedef EFI_IMAGE_OPTIONAL_HEADER64     EFI_IMAGE_OPTIONAL_HEADER;\r
-typedef EFI_IMAGE_NT_HEADERS64          EFI_IMAGE_NT_HEADERS;\r
-\r
-#define EFI_IMAGE_NT_OPTIONAL_HDR_MAGIC EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC\r
-#define EFI_IMAGE_MACHINE_TYPE_SUPPORTED(Machine) \\r
-  (((Machine) == EFI_IMAGE_MACHINE_X64) || ((Machine) == EFI_IMAGE_MACHINE_EBC))\r
-\r
-#elif defined (MDE_CPU_EBC)\r
-\r
-//\r
-// This is just to make sure you can cross compile with the EBC compiiler.\r
-// It does not make sense to have a PE loader coded in EBC. You need to \r
-// understand the basic \r
-//\r
-typedef EFI_IMAGE_OPTIONAL_HEADER64     EFI_IMAGE_OPTIONAL_HEADER;\r
-typedef EFI_IMAGE_NT_HEADERS64          EFI_IMAGE_NT_HEADERS;\r
-\r
-#define EFI_IMAGE_NT_OPTIONAL_HDR_MAGIC EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC\r
-#define EFI_IMAGE_MACHINE_TYPE_SUPPORTED(Machine) ((Machine) == EFI_IMAGE_MACHINE_EBC)\r
-\r
-#else\r
-#error Unknown Processor Type\r
-#endif\r
-\r
-\r
-#define EFI_IMAGE_FIRST_SECTION(ntheader) \\r
-    ( \\r
-      (EFI_IMAGE_SECTION_HEADER *) \\r
-        ( \\r
-          (UINT32) ntheader + \\r
-          FIELD_OFFSET (EFI_IMAGE_NT_HEADERS, OptionalHeader) + \\r
-          ((EFI_IMAGE_NT_HEADERS *) (ntheader))->FileHeader.SizeOfOptionalHeader \\r
-        ) \\r
-    )\r
-\r
-//\r
-// Subsystem Values\r
-//\r
-#define EFI_IMAGE_SUBSYSTEM_UNKNOWN     0\r
-#define EFI_IMAGE_SUBSYSTEM_NATIVE      1\r
-#define EFI_IMAGE_SUBSYSTEM_WINDOWS_GUI 2\r
-#define EFI_IMAGE_SUBSYSTEM_WINDOWS_CUI 3.\r
-#define EFI_IMAGE_SUBSYSTEM_OS2_CUI     5\r
-#define EFI_IMAGE_SUBSYSTEM_POSIX_CUI   7\r
-\r
-//\r
-// Directory Entries\r
-//\r
-#define EFI_IMAGE_DIRECTORY_ENTRY_EXPORT      0\r
-#define EFI_IMAGE_DIRECTORY_ENTRY_IMPORT      1\r
-#define EFI_IMAGE_DIRECTORY_ENTRY_RESOURCE    2\r
-#define EFI_IMAGE_DIRECTORY_ENTRY_EXCEPTION   3\r
-#define EFI_IMAGE_DIRECTORY_ENTRY_SECURITY    4\r
-#define EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC   5\r
-#define EFI_IMAGE_DIRECTORY_ENTRY_DEBUG       6\r
-#define EFI_IMAGE_DIRECTORY_ENTRY_COPYRIGHT   7\r
-#define EFI_IMAGE_DIRECTORY_ENTRY_GLOBALPTR   8\r
-#define EFI_IMAGE_DIRECTORY_ENTRY_TLS         9\r
-#define EFI_IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG 10\r
-\r
-//\r
-// Section header format.\r
-//\r
-#define EFI_IMAGE_SIZEOF_SHORT_NAME 8\r
-\r
-typedef struct {\r
-  UINT8 Name[EFI_IMAGE_SIZEOF_SHORT_NAME];\r
-  union {\r
-    UINT32  PhysicalAddress;\r
-    UINT32  VirtualSize;\r
-  } Misc;\r
-  UINT32  VirtualAddress;\r
-  UINT32  SizeOfRawData;\r
-  UINT32  PointerToRawData;\r
-  UINT32  PointerToRelocations;\r
-  UINT32  PointerToLinenumbers;\r
-  UINT16  NumberOfRelocations;\r
-  UINT16  NumberOfLinenumbers;\r
-  UINT32  Characteristics;\r
-} EFI_IMAGE_SECTION_HEADER;\r
-\r
-#define EFI_IMAGE_SIZEOF_SECTION_HEADER       40\r
-\r
-#define EFI_IMAGE_SCN_TYPE_NO_PAD             0x00000008  // Reserved.\r
-#define EFI_IMAGE_SCN_CNT_CODE                0x00000020\r
-#define EFI_IMAGE_SCN_CNT_INITIALIZED_DATA    0x00000040\r
-#define EFI_IMAGE_SCN_CNT_UNINITIALIZED_DATA  0x00000080\r
-\r
-#define EFI_IMAGE_SCN_LNK_OTHER               0x00000100  // Reserved.\r
-#define EFI_IMAGE_SCN_LNK_INFO                0x00000200  // Section contains comments or some other type of information.\r
-#define EFI_IMAGE_SCN_LNK_REMOVE              0x00000800  // Section contents will not become part of image.\r
-#define EFI_IMAGE_SCN_LNK_COMDAT              0x00001000\r
-\r
-#define EFI_IMAGE_SCN_ALIGN_1BYTES            0x00100000\r
-#define EFI_IMAGE_SCN_ALIGN_2BYTES            0x00200000\r
-#define EFI_IMAGE_SCN_ALIGN_4BYTES            0x00300000\r
-#define EFI_IMAGE_SCN_ALIGN_8BYTES            0x00400000\r
-#define EFI_IMAGE_SCN_ALIGN_16BYTES           0x00500000\r
-#define EFI_IMAGE_SCN_ALIGN_32BYTES           0x00600000\r
-#define EFI_IMAGE_SCN_ALIGN_64BYTES           0x00700000\r
-\r
-#define EFI_IMAGE_SCN_MEM_DISCARDABLE         0x02000000\r
-#define EFI_IMAGE_SCN_MEM_NOT_CACHED          0x04000000\r
-#define EFI_IMAGE_SCN_MEM_NOT_PAGED           0x08000000\r
-#define EFI_IMAGE_SCN_MEM_SHARED              0x10000000\r
-#define EFI_IMAGE_SCN_MEM_EXECUTE             0x20000000\r
-#define EFI_IMAGE_SCN_MEM_READ                0x40000000\r
-#define EFI_IMAGE_SCN_MEM_WRITE               0x80000000\r
-\r
-///\r
-/// Symbol format.\r
-///\r
-#define EFI_IMAGE_SIZEOF_SYMBOL 18\r
-\r
-//\r
-// Section values.\r
-//\r
-// Symbols have a section number of the section in which they are\r
-// defined. Otherwise, section numbers have the following meanings:\r
-//\r
-#define EFI_IMAGE_SYM_UNDEFINED (UINT16) 0  // Symbol is undefined or is common.\r
-#define EFI_IMAGE_SYM_ABSOLUTE  (UINT16) -1 // Symbol is an absolute value.\r
-#define EFI_IMAGE_SYM_DEBUG     (UINT16) -2 // Symbol is a special debug item.\r
-//\r
-// Type (fundamental) values.\r
-//\r
-#define EFI_IMAGE_SYM_TYPE_NULL   0   // no type.\r
-#define EFI_IMAGE_SYM_TYPE_VOID   1   //\r
-#define EFI_IMAGE_SYM_TYPE_CHAR   2   // type character.\r
-#define EFI_IMAGE_SYM_TYPE_SHORT  3   // type short integer.\r
-#define EFI_IMAGE_SYM_TYPE_INT    4\r
-#define EFI_IMAGE_SYM_TYPE_LONG   5\r
-#define EFI_IMAGE_SYM_TYPE_FLOAT  6\r
-#define EFI_IMAGE_SYM_TYPE_DOUBLE 7\r
-#define EFI_IMAGE_SYM_TYPE_STRUCT 8\r
-#define EFI_IMAGE_SYM_TYPE_UNION  9\r
-#define EFI_IMAGE_SYM_TYPE_ENUM   10  // enumeration.\r
-#define EFI_IMAGE_SYM_TYPE_MOE    11  // member of enumeration.\r
-#define EFI_IMAGE_SYM_TYPE_BYTE   12\r
-#define EFI_IMAGE_SYM_TYPE_WORD   13\r
-#define EFI_IMAGE_SYM_TYPE_UINT   14\r
-#define EFI_IMAGE_SYM_TYPE_DWORD  15\r
-\r
-//\r
-// Type (derived) values.\r
-//\r
-#define EFI_IMAGE_SYM_DTYPE_NULL      0 // no derived type.\r
-#define EFI_IMAGE_SYM_DTYPE_POINTER   1\r
-#define EFI_IMAGE_SYM_DTYPE_FUNCTION  2\r
-#define EFI_IMAGE_SYM_DTYPE_ARRAY     3\r
-\r
-//\r
-// Storage classes.\r
-//\r
-#define EFI_IMAGE_SYM_CLASS_END_OF_FUNCTION   (UINT8) -1\r
-#define EFI_IMAGE_SYM_CLASS_NULL              0\r
-#define EFI_IMAGE_SYM_CLASS_AUTOMATIC         1\r
-#define EFI_IMAGE_SYM_CLASS_EXTERNAL          2\r
-#define EFI_IMAGE_SYM_CLASS_STATIC            3\r
-#define EFI_IMAGE_SYM_CLASS_REGISTER          4\r
-#define EFI_IMAGE_SYM_CLASS_EXTERNAL_DEF      5\r
-#define EFI_IMAGE_SYM_CLASS_LABEL             6\r
-#define EFI_IMAGE_SYM_CLASS_UNDEFINED_LABEL   7\r
-#define EFI_IMAGE_SYM_CLASS_MEMBER_OF_STRUCT  8\r
-#define EFI_IMAGE_SYM_CLASS_ARGUMENT          9\r
-#define EFI_IMAGE_SYM_CLASS_STRUCT_TAG        10\r
-#define EFI_IMAGE_SYM_CLASS_MEMBER_OF_UNION   11\r
-#define EFI_IMAGE_SYM_CLASS_UNION_TAG         12\r
-#define EFI_IMAGE_SYM_CLASS_TYPE_DEFINITION   13\r
-#define EFI_IMAGE_SYM_CLASS_UNDEFINED_STATIC  14\r
-#define EFI_IMAGE_SYM_CLASS_ENUM_TAG          15\r
-#define EFI_IMAGE_SYM_CLASS_MEMBER_OF_ENUM    16\r
-#define EFI_IMAGE_SYM_CLASS_REGISTER_PARAM    17\r
-#define EFI_IMAGE_SYM_CLASS_BIT_FIELD         18\r
-#define EFI_IMAGE_SYM_CLASS_BLOCK             100\r
-#define EFI_IMAGE_SYM_CLASS_FUNCTION          101\r
-#define EFI_IMAGE_SYM_CLASS_END_OF_STRUCT     102\r
-#define EFI_IMAGE_SYM_CLASS_FILE              103\r
-#define EFI_IMAGE_SYM_CLASS_SECTION           104\r
-#define EFI_IMAGE_SYM_CLASS_WEAK_EXTERNAL     105\r
-\r
-//\r
-// type packing constants\r
-//\r
-#define EFI_IMAGE_N_BTMASK  017\r
-#define EFI_IMAGE_N_TMASK   060\r
-#define EFI_IMAGE_N_TMASK1  0300\r
-#define EFI_IMAGE_N_TMASK2  0360\r
-#define EFI_IMAGE_N_BTSHFT  4\r
-#define EFI_IMAGE_N_TSHIFT  2\r
-\r
-//\r
-// Communal selection types.\r
-//\r
-#define EFI_IMAGE_COMDAT_SELECT_NODUPLICATES    1\r
-#define EFI_IMAGE_COMDAT_SELECT_ANY             2\r
-#define EFI_IMAGE_COMDAT_SELECT_SAME_SIZE       3\r
-#define EFI_IMAGE_COMDAT_SELECT_EXACT_MATCH     4\r
-#define EFI_IMAGE_COMDAT_SELECT_ASSOCIATIVE     5\r
-\r
-#define EFI_IMAGE_WEAK_EXTERN_SEARCH_NOLIBRARY  1\r
-#define EFI_IMAGE_WEAK_EXTERN_SEARCH_LIBRARY    2\r
-#define EFI_IMAGE_WEAK_EXTERN_SEARCH_ALIAS      3\r
-\r
-///\r
-/// Relocation format.\r
-///\r
-typedef struct {\r
-  UINT32  VirtualAddress;\r
-  UINT32  SymbolTableIndex;\r
-  UINT16  Type;\r
-} EFI_IMAGE_RELOCATION;\r
-\r
-#define EFI_IMAGE_SIZEOF_RELOCATION 10\r
-\r
-//\r
-// I386 relocation types.\r
-//\r
-#define EFI_IMAGE_REL_I386_ABSOLUTE 0   // Reference is absolute, no relocation is necessary\r
-#define EFI_IMAGE_REL_I386_DIR16    01  // Direct 16-bit reference to the symbols virtual address\r
-#define EFI_IMAGE_REL_I386_REL16    02  // PC-relative 16-bit reference to the symbols virtual address\r
-#define EFI_IMAGE_REL_I386_DIR32    06  // Direct 32-bit reference to the symbols virtual address\r
-#define EFI_IMAGE_REL_I386_DIR32NB  07  // Direct 32-bit reference to the symbols virtual address, base not included\r
-#define EFI_IMAGE_REL_I386_SEG12    011 // Direct 16-bit reference to the segment-selector bits of a 32-bit virtual address\r
-#define EFI_IMAGE_REL_I386_SECTION  012\r
-#define EFI_IMAGE_REL_I386_SECREL   013\r
-#define EFI_IMAGE_REL_I386_REL32    024 // PC-relative 32-bit reference to the symbols virtual address\r
-\r
-///\r
-/// Based relocation format.\r
-///\r
-typedef struct {\r
-  UINT32  VirtualAddress;\r
-  UINT32  SizeOfBlock;\r
-} EFI_IMAGE_BASE_RELOCATION;\r
-\r
-#define EFI_IMAGE_SIZEOF_BASE_RELOCATION  8\r
-\r
-//\r
-// Based relocation types.\r
-//\r
-#define EFI_IMAGE_REL_BASED_ABSOLUTE      0\r
-#define EFI_IMAGE_REL_BASED_HIGH          1\r
-#define EFI_IMAGE_REL_BASED_LOW           2\r
-#define EFI_IMAGE_REL_BASED_HIGHLOW       3\r
-#define EFI_IMAGE_REL_BASED_HIGHADJ       4\r
-#define EFI_IMAGE_REL_BASED_MIPS_JMPADDR  5\r
-#define EFI_IMAGE_REL_BASED_IA64_IMM64    9\r
-#define EFI_IMAGE_REL_BASED_DIR64         10\r
-\r
-///\r
-/// Line number format.\r
-///\r
-typedef struct {\r
-  union {\r
-    UINT32  SymbolTableIndex; // Symbol table index of function name if Linenumber is 0.\r
-    UINT32  VirtualAddress;   // Virtual address of line number.\r
-  } Type;\r
-  UINT16  Linenumber;         // Line number.\r
-} EFI_IMAGE_LINENUMBER;\r
-\r
-#define EFI_IMAGE_SIZEOF_LINENUMBER 6\r
-\r
-//\r
-// Archive format.\r
-//\r
-#define EFI_IMAGE_ARCHIVE_START_SIZE        8\r
-#define EFI_IMAGE_ARCHIVE_START             "!<arch>\n"\r
-#define EFI_IMAGE_ARCHIVE_END               "`\n"\r
-#define EFI_IMAGE_ARCHIVE_PAD               "\n"\r
-#define EFI_IMAGE_ARCHIVE_LINKER_MEMBER     "/               "\r
-#define EFI_IMAGE_ARCHIVE_LONGNAMES_MEMBER  "//              "\r
-\r
-typedef struct {\r
-  UINT8 Name[16];     // File member name - `/' terminated.\r
-  UINT8 Date[12];     // File member date - decimal.\r
-  UINT8 UserID[6];    // File member user id - decimal.\r
-  UINT8 GroupID[6];   // File member group id - decimal.\r
-  UINT8 Mode[8];      // File member mode - octal.\r
-  UINT8 Size[10];     // File member size - decimal.\r
-  UINT8 EndHeader[2]; // String to end header.\r
-} EFI_IMAGE_ARCHIVE_MEMBER_HEADER;\r
-\r
-#define EFI_IMAGE_SIZEOF_ARCHIVE_MEMBER_HDR 60\r
-\r
-//\r
-// DLL support.\r
-//\r
-\r
-///\r
-/// DLL Export Format\r
-///\r
-typedef struct {\r
-  UINT32  Characteristics;\r
-  UINT32  TimeDateStamp;\r
-  UINT16  MajorVersion;\r
-  UINT16  MinorVersion;\r
-  UINT32  Name;\r
-  UINT32  Base;\r
-  UINT32  NumberOfFunctions;\r
-  UINT32  NumberOfNames;\r
-  UINT32  AddressOfFunctions;\r
-  UINT32  AddressOfNames;\r
-  UINT32  AddressOfNameOrdinals;\r
-} EFI_IMAGE_EXPORT_DIRECTORY;\r
-\r
-///\r
-/// DLL support.\r
-/// Import Format\r
-///\r
-typedef struct {\r
-  UINT16  Hint;\r
-  UINT8   Name[1];\r
-} EFI_IMAGE_IMPORT_BY_NAME;\r
-\r
-typedef struct {\r
-  union {\r
-    UINT32                    Function;\r
-    UINT32                    Ordinal;\r
-    EFI_IMAGE_IMPORT_BY_NAME  *AddressOfData;\r
-  } u1;\r
-} EFI_IMAGE_THUNK_DATA;\r
-\r
-#define EFI_IMAGE_ORDINAL_FLAG              0x80000000\r
-#define EFI_IMAGE_SNAP_BY_ORDINAL(Ordinal)  ((Ordinal & EFI_IMAGE_ORDINAL_FLAG) != 0)\r
-#define EFI_IMAGE_ORDINAL(Ordinal)          (Ordinal & 0xffff)\r
-\r
-typedef struct {\r
-  UINT32                Characteristics;\r
-  UINT32                TimeDateStamp;\r
-  UINT32                ForwarderChain;\r
-  UINT32                Name;\r
-  EFI_IMAGE_THUNK_DATA  *FirstThunk;\r
-} EFI_IMAGE_IMPORT_DESCRIPTOR;\r
-\r
-///\r
-/// Debug Format\r
-///\r
-#define EFI_IMAGE_DEBUG_TYPE_CODEVIEW 2\r
-\r
-typedef struct {\r
-  UINT32  Characteristics;\r
-  UINT32  TimeDateStamp;\r
-  UINT16  MajorVersion;\r
-  UINT16  MinorVersion;\r
-  UINT32  Type;\r
-  UINT32  SizeOfData;\r
-  UINT32  RVA;\r
-  UINT32  FileOffset;\r
-} EFI_IMAGE_DEBUG_DIRECTORY_ENTRY;\r
-\r
-#define CODEVIEW_SIGNATURE_NB10 0x3031424E  // "NB10"\r
-typedef struct {\r
-  UINT32  Signature;                        // "NB10"\r
-  UINT32  Unknown;\r
-  UINT32  Unknown2;\r
-  UINT32  Unknown3;\r
-  //\r
-  // Filename of .PDB goes here\r
-  //\r
-} EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY;\r
-\r
-#define CODEVIEW_SIGNATURE_RSDS 0x53445352  // "RSDS"\r
-typedef struct {\r
-  UINT32  Signature;                        // "RSDS"\r
-  UINT32  Unknown;\r
-  UINT32  Unknown2;\r
-  UINT32  Unknown3;\r
-  UINT32  Unknown4;\r
-  UINT32  Unknown5;\r
-  //\r
-  // Filename of .PDB goes here\r
-  //\r
-} EFI_IMAGE_DEBUG_CODEVIEW_RSDS_ENTRY;\r
-\r
-///\r
-/// Header format for TE images\r
-///\r
-typedef struct {\r
-  UINT16                    Signature;            // signature for TE format = "VZ"\r
-  UINT16                    Machine;              // from the original file header\r
-  UINT8                     NumberOfSections;     // from the original file header\r
-  UINT8                     Subsystem;            // from original optional header\r
-  UINT16                    StrippedSize;         // how many bytes we removed from the header\r
-  UINT32                    AddressOfEntryPoint;  // offset to entry point -- from original optional header\r
-  UINT32                    BaseOfCode;           // from original image -- required for ITP debug\r
-  UINT64                    ImageBase;            // from original file header\r
-  EFI_IMAGE_DATA_DIRECTORY  DataDirectory[2];     // only base relocation and debug directory\r
-} EFI_TE_IMAGE_HEADER;\r
-\r
-#define EFI_TE_IMAGE_HEADER_SIGNATURE 0x5A56      // "VZ"\r
-\r
-//\r
-// Data directory indexes in our TE image header\r
-//\r
-#define EFI_TE_IMAGE_DIRECTORY_ENTRY_BASERELOC  0\r
-#define EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG      1\r
-\r
-#endif\r
diff --git a/Tools/CodeTools/TianoTools/PeCoffLoader/Ia32/PeCoffLoaderEx.c b/Tools/CodeTools/TianoTools/PeCoffLoader/Ia32/PeCoffLoaderEx.c
deleted file mode 100644 (file)
index f58e8d0..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2004, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-Module Name:\r
-\r
-    PeCoffLoaderEx.c\r
-\r
-Abstract:\r
-\r
-    IA-32 Specific relocation fixups\r
-\r
-Revision History\r
-\r
---*/\r
-\r
-#include <Common/UefiBaseTypes.h>\r
-\r
-RETURN_STATUS\r
-PeCoffLoaderRelocateImageEx (\r
-  IN UINT16      *Reloc,\r
-  IN OUT CHAR8   *Fixup,\r
-  IN OUT CHAR8   **FixupData,\r
-  IN UINT64      Adjust\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Performs an IA-32 specific relocation fixup\r
-\r
-Arguments:\r
-\r
-  Reloc      - Pointer to the relocation record\r
-\r
-  Fixup      - Pointer to the address to fix up\r
-\r
-  FixupData  - Pointer to a buffer to log the fixups\r
-\r
-  Adjust     - The offset to adjust the fixup\r
-\r
-Returns:\r
-\r
-  EFI_UNSUPPORTED   - Unsupported now\r
-\r
---*/\r
-{\r
-  return RETURN_UNSUPPORTED;\r
-}\r
diff --git a/Tools/CodeTools/TianoTools/PeCoffLoader/Ipf/PeCoffLoaderEx.c b/Tools/CodeTools/TianoTools/PeCoffLoader/Ipf/PeCoffLoaderEx.c
deleted file mode 100644 (file)
index 3f39899..0000000
+++ /dev/null
@@ -1,249 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2004, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-Module Name:\r
-\r
-    PeCoffLoaderEx.c\r
-\r
-Abstract:\r
-\r
-    Fixes Intel Itanium(TM) specific relocation types\r
-\r
-\r
-Revision History\r
-\r
---*/\r
-\r
-#include <Common/UefiBaseTypes.h>\r
-#include <Common/EfiImage.h>\r
-#include <Library/PeCoffLib.h>\r
-\r
-\r
-\r
-\r
-\r
-#define EXT_IMM64(Value, Address, Size, InstPos, ValPos)  \\r
-    Value |= (((UINT64)((*(Address) >> InstPos) & (((UINT64)1 << Size) - 1))) << ValPos)\r
-\r
-#define INS_IMM64(Value, Address, Size, InstPos, ValPos)  \\r
-    *(UINT32*)Address = (*(UINT32*)Address & ~(((1 << Size) - 1) << InstPos)) | \\r
-          ((UINT32)((((UINT64)Value >> ValPos) & (((UINT64)1 << Size) - 1))) << InstPos)\r
-\r
-#define IMM64_IMM7B_INST_WORD_X         3  \r
-#define IMM64_IMM7B_SIZE_X              7  \r
-#define IMM64_IMM7B_INST_WORD_POS_X     4  \r
-#define IMM64_IMM7B_VAL_POS_X           0  \r
-\r
-#define IMM64_IMM9D_INST_WORD_X         3  \r
-#define IMM64_IMM9D_SIZE_X              9  \r
-#define IMM64_IMM9D_INST_WORD_POS_X     18  \r
-#define IMM64_IMM9D_VAL_POS_X           7  \r
-\r
-#define IMM64_IMM5C_INST_WORD_X         3  \r
-#define IMM64_IMM5C_SIZE_X              5  \r
-#define IMM64_IMM5C_INST_WORD_POS_X     13  \r
-#define IMM64_IMM5C_VAL_POS_X           16  \r
-\r
-#define IMM64_IC_INST_WORD_X            3  \r
-#define IMM64_IC_SIZE_X                 1  \r
-#define IMM64_IC_INST_WORD_POS_X        12  \r
-#define IMM64_IC_VAL_POS_X              21  \r
-\r
-#define IMM64_IMM41a_INST_WORD_X        1  \r
-#define IMM64_IMM41a_SIZE_X             10  \r
-#define IMM64_IMM41a_INST_WORD_POS_X    14  \r
-#define IMM64_IMM41a_VAL_POS_X          22  \r
-\r
-#define IMM64_IMM41b_INST_WORD_X        1  \r
-#define IMM64_IMM41b_SIZE_X             8  \r
-#define IMM64_IMM41b_INST_WORD_POS_X    24  \r
-#define IMM64_IMM41b_VAL_POS_X          32  \r
-\r
-#define IMM64_IMM41c_INST_WORD_X        2  \r
-#define IMM64_IMM41c_SIZE_X             23  \r
-#define IMM64_IMM41c_INST_WORD_POS_X    0  \r
-#define IMM64_IMM41c_VAL_POS_X          40  \r
-\r
-#define IMM64_SIGN_INST_WORD_X          3  \r
-#define IMM64_SIGN_SIZE_X               1  \r
-#define IMM64_SIGN_INST_WORD_POS_X      27  \r
-#define IMM64_SIGN_VAL_POS_X            63  \r
-\r
-RETURN_STATUS\r
-PeCoffLoaderRelocateImageEx (\r
-  IN UINT16      *Reloc,\r
-  IN OUT CHAR8   *Fixup, \r
-  IN OUT CHAR8   **FixupData,\r
-  IN UINT64      Adjust\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Performs an Itanium-based specific relocation fixup\r
-\r
-Arguments:\r
-\r
-  Reloc      - Pointer to the relocation record\r
-\r
-  Fixup      - Pointer to the address to fix up\r
-\r
-  FixupData  - Pointer to a buffer to log the fixups\r
-\r
-  Adjust     - The offset to adjust the fixup\r
-\r
-Returns:\r
-\r
-  Status code\r
-\r
---*/\r
-{\r
-  UINT64      *F64;\r
-  UINT64      FixupVal;\r
-\r
-  switch ((*Reloc) >> 12) {\r
-\r
-    case EFI_IMAGE_REL_BASED_DIR64:\r
-      F64 = (UINT64 *) Fixup;\r
-      *F64 = *F64 + (UINT64) Adjust;\r
-      if (*FixupData != NULL) {\r
-        *FixupData = ALIGN_POINTER(*FixupData, sizeof(UINT64));\r
-        *(UINT64 *)(*FixupData) = *F64;\r
-        *FixupData = *FixupData + sizeof(UINT64);\r
-      }\r
-      break;\r
-\r
-    case EFI_IMAGE_REL_BASED_IA64_IMM64:\r
-\r
-      //\r
-      // Align it to bundle address before fixing up the\r
-      // 64-bit immediate value of the movl instruction.\r
-      //\r
-\r
-      Fixup = (CHAR8 *)((UINTN) Fixup & (UINTN) ~(15));\r
-      FixupVal = (UINT64)0;\r
-                       \r
-      // \r
-      // Extract the lower 32 bits of IMM64 from bundle\r
-      //\r
-      EXT_IMM64(FixupVal,\r
-                (UINT32 *)Fixup + IMM64_IMM7B_INST_WORD_X,\r
-                IMM64_IMM7B_SIZE_X,\r
-                IMM64_IMM7B_INST_WORD_POS_X,\r
-                IMM64_IMM7B_VAL_POS_X\r
-                );\r
-\r
-      EXT_IMM64(FixupVal,\r
-                (UINT32 *)Fixup + IMM64_IMM9D_INST_WORD_X,\r
-                IMM64_IMM9D_SIZE_X,\r
-                IMM64_IMM9D_INST_WORD_POS_X,\r
-                IMM64_IMM9D_VAL_POS_X\r
-                );\r
-\r
-      EXT_IMM64(FixupVal,\r
-                (UINT32 *)Fixup + IMM64_IMM5C_INST_WORD_X,\r
-                IMM64_IMM5C_SIZE_X,\r
-                IMM64_IMM5C_INST_WORD_POS_X,\r
-                IMM64_IMM5C_VAL_POS_X\r
-                );\r
-\r
-      EXT_IMM64(FixupVal,\r
-                (UINT32 *)Fixup + IMM64_IC_INST_WORD_X,\r
-                IMM64_IC_SIZE_X,\r
-                IMM64_IC_INST_WORD_POS_X,\r
-                IMM64_IC_VAL_POS_X\r
-                );\r
-\r
-      EXT_IMM64(FixupVal,\r
-                (UINT32 *)Fixup + IMM64_IMM41a_INST_WORD_X,\r
-                IMM64_IMM41a_SIZE_X,\r
-                IMM64_IMM41a_INST_WORD_POS_X,\r
-                IMM64_IMM41a_VAL_POS_X\r
-                );\r
-                       \r
-      // \r
-      // Update 64-bit address\r
-      //\r
-      FixupVal += Adjust;\r
-\r
-      // \r
-      // Insert IMM64 into bundle\r
-      //\r
-      INS_IMM64(FixupVal,\r
-                ((UINT32 *)Fixup + IMM64_IMM7B_INST_WORD_X),\r
-                IMM64_IMM7B_SIZE_X,\r
-                IMM64_IMM7B_INST_WORD_POS_X,\r
-                IMM64_IMM7B_VAL_POS_X\r
-                );\r
-\r
-      INS_IMM64(FixupVal,\r
-                ((UINT32 *)Fixup + IMM64_IMM9D_INST_WORD_X),\r
-                IMM64_IMM9D_SIZE_X,\r
-                IMM64_IMM9D_INST_WORD_POS_X,\r
-                IMM64_IMM9D_VAL_POS_X\r
-                );\r
-\r
-      INS_IMM64(FixupVal,\r
-                ((UINT32 *)Fixup + IMM64_IMM5C_INST_WORD_X),\r
-                IMM64_IMM5C_SIZE_X,\r
-                IMM64_IMM5C_INST_WORD_POS_X,\r
-                IMM64_IMM5C_VAL_POS_X\r
-                );\r
-\r
-      INS_IMM64(FixupVal,\r
-                ((UINT32 *)Fixup + IMM64_IC_INST_WORD_X),\r
-                IMM64_IC_SIZE_X,\r
-                IMM64_IC_INST_WORD_POS_X,\r
-                IMM64_IC_VAL_POS_X\r
-                );\r
-\r
-      INS_IMM64(FixupVal,\r
-                ((UINT32 *)Fixup + IMM64_IMM41a_INST_WORD_X),\r
-                IMM64_IMM41a_SIZE_X,\r
-                IMM64_IMM41a_INST_WORD_POS_X,\r
-                IMM64_IMM41a_VAL_POS_X\r
-                );\r
-\r
-      INS_IMM64(FixupVal,\r
-                ((UINT32 *)Fixup + IMM64_IMM41b_INST_WORD_X),\r
-                IMM64_IMM41b_SIZE_X,\r
-                IMM64_IMM41b_INST_WORD_POS_X,\r
-                IMM64_IMM41b_VAL_POS_X\r
-                );\r
-\r
-      INS_IMM64(FixupVal,\r
-                ((UINT32 *)Fixup + IMM64_IMM41c_INST_WORD_X),\r
-                IMM64_IMM41c_SIZE_X,\r
-                IMM64_IMM41c_INST_WORD_POS_X,\r
-                IMM64_IMM41c_VAL_POS_X\r
-                );\r
-\r
-      INS_IMM64(FixupVal,\r
-                ((UINT32 *)Fixup + IMM64_SIGN_INST_WORD_X),\r
-                IMM64_SIGN_SIZE_X,\r
-                IMM64_SIGN_INST_WORD_POS_X,\r
-                IMM64_SIGN_VAL_POS_X\r
-                );\r
-\r
-      F64 = (UINT64 *) Fixup;\r
-      if (*FixupData != NULL) {\r
-        *FixupData = ALIGN_POINTER(*FixupData, sizeof(UINT64));\r
-        *(UINT64 *)(*FixupData) = *F64;\r
-        *FixupData = *FixupData + sizeof(UINT64);\r
-      }\r
-      break;\r
-\r
-    default:\r
-      return RETURN_UNSUPPORTED;\r
-  }\r
-\r
-  return RETURN_SUCCESS;\r
-}\r
diff --git a/Tools/CodeTools/TianoTools/PeCoffLoader/X64/PeCoffLoaderEx.c b/Tools/CodeTools/TianoTools/PeCoffLoader/X64/PeCoffLoaderEx.c
deleted file mode 100644 (file)
index 1e6cc34..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-/*++\r
-\r
-Copyright 2005, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-\r
-Module Name:\r
-\r
-  PeCoffLoaderEx.c\r
-\r
-Abstract:\r
-\r
-  x64 Specific relocation fixups\r
-\r
-Revision History\r
-\r
---*/\r
-\r
-#include <Common/UefiBaseTypes.h>\r
-#include <Common/EfiImage.h>\r
-#include <Library/PeCoffLib.h>\r
-\r
-\r
-\r
-\r
-RETURN_STATUS\r
-PeCoffLoaderRelocateImageEx (\r
-  IN UINT16      *Reloc,\r
-  IN OUT CHAR8   *Fixup, \r
-  IN OUT CHAR8   **FixupData,\r
-  IN UINT64      Adjust\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Performs an x64 specific relocation fixup\r
-\r
-Arguments:\r
-  Reloc      - Pointer to the relocation record\r
-  Fixup      - Pointer to the address to fix up\r
-  FixupData  - Pointer to a buffer to log the fixups\r
-  Adjust     - The offset to adjust the fixup\r
-\r
-Returns:\r
-  None\r
-\r
---*/\r
-{\r
-  UINT64      *F64;\r
-\r
-  switch ((*Reloc) >> 12) {\r
-\r
-    case EFI_IMAGE_REL_BASED_DIR64:\r
-      F64 = (UINT64 *) Fixup;\r
-      *F64 = *F64 + (UINT64) Adjust;\r
-      if (*FixupData != NULL) {\r
-        *FixupData = ALIGN_POINTER(*FixupData, sizeof(UINT64));\r
-        *(UINT64 *)(*FixupData) = *F64;\r
-        *FixupData = *FixupData + sizeof(UINT64);\r
-      }\r
-      break;\r
-\r
-    default:\r
-      return RETURN_UNSUPPORTED;\r
-  }\r
-\r
-  return RETURN_SUCCESS;\r
-}\r
diff --git a/Tools/CodeTools/TianoTools/PeCoffLoader/build.xml b/Tools/CodeTools/TianoTools/PeCoffLoader/build.xml
deleted file mode 100644 (file)
index db37829..0000000
+++ /dev/null
@@ -1,153 +0,0 @@
-<?xml version="1.0" ?>\r
-<!--\r
-Copyright (c) 2006, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
--->\r
-<project default="GenTool" basedir=".">\r
-<!--\r
-    EDK PeCoffLoader\r
-  Copyright (c) 2006, Intel Corporation\r
--->\r
-  <taskdef resource="cpptasks.tasks"/>\r
-  <typedef resource="cpptasks.types"/>\r
-  <taskdef resource="net/sf/antcontrib/antlib.xml"/>\r
-\r
-  <property name="LibName" value="PeCoffLoader"/>\r
-  <property name="LINK_OUTPUT_TYPE" value="static"/>\r
-  <property name="BUILD_DIR_IA32" value="${PACKAGE_DIR}/${LibName}/tmp/Ia32"/>\r
-  <property name="BUILD_DIR_X64" value="${PACKAGE_DIR}/${LibName}/tmp/X64"/>\r
-  <property name="BUILD_DIR_IPF" value="${PACKAGE_DIR}/${LibName}/tmp/Ipf"/>\r
-\r
-  <target name="GenTool" depends="init, PeCoffLoaderLib">\r
-    <echo message="The EDK Library: ${LibName} build has completed!"/>\r
-  </target>\r
-\r
-  <target name="init">\r
-    <echo message="Building the EDK Library: ${LibName}"/>\r
-    <mkdir dir="${BUILD_DIR_IA32}"/>\r
-    <mkdir dir="${BUILD_DIR_X64}"/>\r
-    <mkdir dir="${BUILD_DIR_IPF}"/>\r
-\r
-    <condition property="syslibdirs" value="">\r
-      <os family="mac"/>\r
-    </condition>\r
-    \r
-    <condition property="syslibs" value="">\r
-      <os family="mac"/>\r
-    </condition>\r
-    \r
-    <condition property="syslibdirs" value="${env.CYGWIN_HOME}/lib/e2fsprogs">\r
-      <os family="windows"/>\r
-    </condition>\r
-    \r
-    <condition property="syslibs" value="uuid">\r
-      <os family="windows"/>\r
-    </condition>\r
-    \r
-    <condition property="syslibdirs" value="/usr/lib">\r
-      <os name="Linux"/>\r
-    </condition>\r
-    \r
-    <condition property="syslibs" value="uuid">\r
-      <os name="Linux"/>\r
-    </condition>\r
-    \r
-  </target>\r
-\r
-  <target name="PeCoffLoaderLib" depends="init, PeCoffLoader_Ia32, PeCoffLoader_Ipf, PeCoffLoader_X64"/>\r
-\r
-  <target name="PeCoffLoader_Ia32" >\r
-    <cc name="${ToolChain}" objdir="${BUILD_DIR_IA32}" \r
-        outfile="${LIB_DIR}/${LibName}_Ia32"\r
-        outtype="static"\r
-        debug="true"\r
-        optimize="speed">\r
-\r
-      <defineset>\r
-        <define name="BUILDING_TOOLS"/>\r
-        <define name="TOOL_BUILD_IA32_TARGET"/>\r
-      </defineset>\r
-    \r
-      <fileset dir="${basedir}/${LibName}" \r
-        includes="BasePeCoff.c Ia32/PeCoffLoaderEx.c" />\r
-\r
-      <includepath path="${PACKAGE_DIR}/${LibName}"/>\r
-      <includepath path="${PACKAGE_DIR}/Include"/>\r
-      <includepath path="${PACKAGE_DIR}/Include/Ia32"/>\r
-      <includepath path="${PACKAGE_DIR}/Common"/>\r
-    </cc>\r
-  </target>\r
-\r
-  <target name="PeCoffLoader_Ipf" >\r
-    <cc name="${ToolChain}" objdir="${BUILD_DIR_IPF}" \r
-        outfile="${LIB_DIR}/${LibName}_Ipf"\r
-        outtype="static"\r
-        debug="true"\r
-        optimize="speed">\r
-\r
-      <defineset>\r
-        <define name="BUILDING_TOOLS"/>\r
-        <define name="TOOL_BUILD_IPF_TARGET"/>\r
-      </defineset>\r
-    \r
-      <fileset dir="${basedir}/${LibName}" \r
-        includes="BasePeCoff.c Ipf/PeCoffLoaderEx.c" />\r
-\r
-      <includepath path="${PACKAGE_DIR}/${LibName}"/>\r
-      <includepath path="${PACKAGE_DIR}/Include"/>\r
-      <includepath path="${PACKAGE_DIR}/Include/Ia32"/>\r
-      <includepath path="${PACKAGE_DIR}/Common"/>\r
-    </cc>\r
-  </target>\r
-\r
-  <target name="PeCoffLoader_X64" >\r
-    <cc name="${ToolChain}" objdir="${BUILD_DIR_X64}" \r
-        outfile="${LIB_DIR}/${LibName}_X64"\r
-        outtype="static"\r
-        debug="true"\r
-        optimize="speed">\r
-\r
-      <defineset>\r
-        <define name="BUILDING_TOOLS"/>\r
-        <define name="TOOL_BUILD_X64_TARGET"/>\r
-      </defineset>\r
-    \r
-      <fileset dir="${basedir}/${LibName}" \r
-        includes="BasePeCoff.c X64/PeCoffLoaderEx.c" />\r
-\r
-      <includepath path="${PACKAGE_DIR}/${LibName}"/>\r
-      <includepath path="${PACKAGE_DIR}/Include"/>\r
-      <includepath path="${PACKAGE_DIR}/Include/Ia32"/>\r
-      <includepath path="${PACKAGE_DIR}/Common"/>\r
-    </cc>\r
-  </target>\r
-\r
-\r
-  <target name="clean">\r
-    <echo message="Removing Intermediate Files Only"/>  \r
-    <delete>\r
-      <fileset dir="${BUILD_DIR_IA32}" includes="*.obj"/>\r
-      <fileset dir="${BUILD_DIR_X64}" includes="*.obj"/>\r
-      <fileset dir="${BUILD_DIR_IPF}" includes="*.obj"/>\r
-    </delete>\r
-  </target>\r
-\r
-  <target name="cleanall">\r
-    <echo message="Removing Object Files and the Executable: ${LibName}${ext_exe}"/>  \r
-    <delete dir="${PACKAGE_DIR}/${LibName}/tmp">\r
-    </delete>\r
-    <delete failonerror="false" quiet="true" includeEmptyDirs="true">\r
-      <fileset dir="${BUILD_DIR}"/>\r
-      <fileset file="${LIB_DIR}/${LibName}_Ia32${ext_static}"/>\r
-      <fileset file="${BIN_DIR}/${LibName}_X64${ext_static}"/>\r
-      <fileset file="${BIN_DIR}/${LibName}_IPF${ext_static}"/>\r
-    </delete>\r
-  </target>\r
-\r
-</project>\r
diff --git a/Tools/CodeTools/TianoTools/PeiRebase/PeiRebaseExe.c b/Tools/CodeTools/TianoTools/PeiRebase/PeiRebaseExe.c
deleted file mode 100644 (file)
index 27c646e..0000000
+++ /dev/null
@@ -1,1059 +0,0 @@
-/*++\r
-\r
-Copyright (c)  1999-2006 Intel Corporation. All rights reserved\r
-This program and the accompanying materials are licensed and made available \r
-under the terms and conditions of the BSD License which accompanies this \r
-distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-\r
-Module Name:\r
-\r
-  PeiRebaseExe.c\r
-\r
-Abstract:\r
-\r
-  This contains all code necessary to build the PeiRebase.exe utility.\r
-  This utility relies heavily on the PeiRebase DLL.  Definitions for both\r
-  can be found in the PEI Rebase Utility Specification, review draft.\r
-\r
---*/\r
-\r
-#include <stdlib.h>\r
-#include <stdio.h>\r
-#include <string.h>\r
-\r
-#include <Common/UefiBaseTypes.h>\r
-#include <Common/FirmwareVolumeImageFormat.h>\r
-#include <Common/FirmwareFileSystem.h>\r
-#include <Library/PeCoffLib.h>\r
-\r
-#include "CommonLib.h"\r
-#include "ParseInf.h"\r
-#include "FvLib.h"\r
-#include "EfiUtilityMsgs.h"\r
-#include "PeiRebaseExe.h"\r
-\r
-EFI_STATUS\r
-ReadHeader (\r
-  IN FILE       *InputFile,\r
-  OUT UINT32    *FvSize,\r
-  OUT BOOLEAN   *ErasePolarity\r
-  );\r
-\r
-int\r
-main (\r
-  int  argc,\r
-  char **argv\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  This utility relocates PEI XIP PE32s in a FV.\r
-\r
-Arguments:\r
-\r
-  argc          - Number of command line arguments\r
-  argv[]:\r
-  BaseAddress     The base address to use for rebasing the FV.  The correct \r
-                  format is a hex number preceded by 0x.\r
-  InputFileName   The name of the input FV file.\r
-  OutputFileName  The name of the output FV file.\r
-  MapFileName     The name of the map file of relocation info.\r
-\r
-  Arguments come in pair in any order.\r
-    -I InputFileName \r
-    -O OutputFileName\r
-    -B BaseAddress \r
-    -M MapFileName \r
-\r
-Returns:\r
-\r
-  0   No error conditions detected.\r
-  1   One or more of the input parameters is invalid.\r
-  2   A resource required by the utility was unavailable.  \r
-      Most commonly this will be memory allocation or file creation.\r
-  3   PeiRebase.dll could not be loaded.\r
-  4   Error executing the PEI rebase.\r
-\r
---*/\r
-{\r
-  UINT8                       Index;\r
-  CHAR8                       InputFileName[_MAX_PATH];\r
-  CHAR8                       OutputFileName[_MAX_PATH];\r
-  CHAR8                       MapFileName[_MAX_PATH];\r
-  EFI_PHYSICAL_ADDRESS        BaseAddress;\r
-  BOOLEAN                     BaseAddressSet;\r
-  EFI_STATUS                  Status;\r
-  FILE                        *InputFile;\r
-  FILE                        *OutputFile;\r
-  FILE                        *MapFile;\r
-  UINT64                      FvOffset;\r
-  UINT32                      FileCount;\r
-  int                         BytesRead;\r
-  EFI_FIRMWARE_VOLUME_HEADER  *FvImage;\r
-  UINT32                      FvSize;\r
-  EFI_FFS_FILE_HEADER         *CurrentFile;\r
-  BOOLEAN                     ErasePolarity;\r
-  EFI_PHYSICAL_ADDRESS        CurrentFileBaseAddress;\r
-\r
-  ErasePolarity = FALSE;\r
-  //\r
-  // Set utility name for error/warning reporting purposes.\r
-  //\r
-  SetUtilityName (UTILITY_NAME);\r
-  //\r
-  // Verify the correct number of arguments\r
-  //\r
-  if (argc != MAX_ARGS) {\r
-    PrintUsage ();\r
-    return STATUS_ERROR;\r
-  }\r
-\r
-  //\r
-  // Initialize variables\r
-  //\r
-  InputFileName[0]  = 0;\r
-  OutputFileName[0] = 0;\r
-  MapFileName[0]    = 0;\r
-  BaseAddress       = 0;\r
-  BaseAddressSet    = FALSE;\r
-  FvOffset          = 0;\r
-  FileCount         = 0;\r
-  ErasePolarity     = FALSE;\r
-  InputFile         = NULL;\r
-  OutputFile        = NULL;\r
-  MapFile           = NULL;\r
-  FvImage           = NULL;\r
-\r
-  //\r
-  // Parse the command line arguments\r
-  //\r
-  for (Index = 1; Index < MAX_ARGS; Index += 2) {\r
-    //\r
-    // Make sure argument pair begin with - or /\r
-    //\r
-    if (argv[Index][0] != '-' && argv[Index][0] != '/') {\r
-      PrintUsage ();\r
-      Error (NULL, 0, 0, argv[Index], "unrecognized option");\r
-      return STATUS_ERROR;\r
-    }\r
-    //\r
-    // Make sure argument specifier is only one letter\r
-    //\r
-    if (argv[Index][2] != 0) {\r
-      PrintUsage ();\r
-      Error (NULL, 0, 0, argv[Index], "unrecognized option");\r
-      return STATUS_ERROR;\r
-    }    \r
-    //\r
-    // Determine argument to read\r
-    //\r
-    switch (argv[Index][1]) {\r
-    case 'I':\r
-    case 'i':\r
-      if (strlen (InputFileName) == 0) {\r
-        strcpy (InputFileName, argv[Index + 1]);\r
-      } else {\r
-        PrintUsage ();\r
-        Error (NULL, 0, 0, argv[Index + 1], "only one -i InputFileName may be specified");\r
-        return STATUS_ERROR;\r
-      }\r
-      break;\r
-\r
-    case 'O':\r
-    case 'o':\r
-      if (strlen (OutputFileName) == 0) {\r
-        strcpy (OutputFileName, argv[Index + 1]);\r
-      } else {\r
-        PrintUsage ();\r
-        Error (NULL, 0, 0, argv[Index + 1], "only one -o OutputFileName may be specified");\r
-        return STATUS_ERROR;\r
-      }\r
-      break;\r
-\r
-    case 'B':\r
-    case 'b':\r
-      if (!BaseAddressSet) {\r
-        Status = AsciiStringToUint64 (argv[Index + 1], FALSE, &BaseAddress);\r
-        if (EFI_ERROR (Status)) {\r
-          PrintUsage ();\r
-          Error (NULL, 0, 0, argv[Index + 1], "invalid hex digit given for the base address");\r
-          return STATUS_ERROR;\r
-        }\r
-\r
-        BaseAddressSet = TRUE;\r
-      } else {\r
-        PrintUsage ();\r
-        Error (NULL, 0, 0, argv[Index + 1], "-b BaseAddress may only be specified once");\r
-        return STATUS_ERROR;\r
-      }\r
-      break;\r
-\r
-    case 'M':\r
-    case 'm':\r
-      if (strlen (MapFileName) == 0) {\r
-        strcpy (MapFileName, argv[Index + 1]);\r
-      } else {\r
-        PrintUsage ();\r
-        Error (NULL, 0, 0, argv[Index + 1], "only one -m MapFileName may be specified");\r
-        return STATUS_ERROR;\r
-      }\r
-      break;\r
-\r
-    default:\r
-      PrintUsage ();\r
-      Error (NULL, 0, 0, argv[Index], "unrecognized argument");\r
-      return STATUS_ERROR;\r
-      break;\r
-    }\r
-  }\r
-\r
-  //\r
-  // Create the Map file if we need it\r
-  //\r
-  if (strlen (MapFileName) != 0) {\r
-    MapFile = fopen (MapFileName, "w");\r
-    if (MapFile == NULL) {\r
-      Error (NULL, 0, 0, MapFileName, "failed to open map file");\r
-      goto Finish;\r
-    }\r
-  } \r
-\r
-  //\r
-  // Open the file containing the FV\r
-  //\r
-  InputFile = fopen (InputFileName, "rb");\r
-  if (InputFile == NULL) {\r
-    Error (NULL, 0, 0, InputFileName, "could not open input file for reading");\r
-    return STATUS_ERROR;\r
-  }\r
-  //\r
-  // Determine size of FV\r
-  //\r
-  Status = ReadHeader (InputFile, &FvSize, &ErasePolarity);\r
-  if (EFI_ERROR (Status)) {\r
-    Error (NULL, 0, 0, "could not parse the FV header", NULL);\r
-    goto Finish;\r
-  }\r
-  //\r
-  // Allocate a buffer for the FV image\r
-  //\r
-  FvImage = malloc (FvSize);\r
-  if (FvImage == NULL) {\r
-    Error (NULL, 0, 0, "application error", "memory allocation failed");\r
-    goto Finish;\r
-  }\r
-  //\r
-  // Read the entire FV to the buffer\r
-  //\r
-  BytesRead = fread (FvImage, 1, FvSize, InputFile);\r
-  fclose (InputFile);\r
-  InputFile = NULL;\r
-  if ((unsigned int) BytesRead != FvSize) {\r
-    Error (NULL, 0, 0, InputFileName, "failed to read from file");\r
-    goto Finish;\r
-  }\r
-  //\r
-  // Prepare to walk the FV image\r
-  //\r
-  InitializeFvLib (FvImage, FvSize);\r
-  //\r
-  // Get the first file\r
-  //\r
-  Status = GetNextFile (NULL, &CurrentFile);\r
-  if (EFI_ERROR (Status)) {\r
-    Error (NULL, 0, 0, "cannot find the first file in the FV image", NULL);\r
-    goto Finish;\r
-  }\r
-  //\r
-  // Check if each file should be rebased\r
-  //\r
-  while (CurrentFile != NULL) {\r
-    //\r
-    // Rebase this file\r
-    //\r
-    CurrentFileBaseAddress  = BaseAddress + ((UINTN) CurrentFile - (UINTN) FvImage);\r
-    Status                  = FfsRebase (CurrentFile, CurrentFileBaseAddress, MapFile);\r
-\r
-    if (EFI_ERROR (Status)) {\r
-      switch (Status) {\r
-\r
-      case EFI_INVALID_PARAMETER:\r
-        Error (NULL, 0, 0, "invalid parameter passed to FfsRebase", NULL);\r
-        break;\r
-\r
-      case EFI_ABORTED:\r
-        Error (NULL, 0, 0, "error detected while rebasing -- aborted", NULL);\r
-        break;\r
-\r
-      case EFI_OUT_OF_RESOURCES:\r
-        Error (NULL, 0, 0, "FfsRebase could not allocate required resources", NULL);\r
-        break;\r
-\r
-      case EFI_NOT_FOUND:\r
-        Error (NULL, 0, 0, "FfsRebase could not locate a PE32 section", NULL);\r
-        break;\r
-\r
-      default:\r
-        Error (NULL, 0, 0, "FfsRebase returned unknown status", "status=0x%08X", Status);\r
-        break;\r
-      }\r
-\r
-      goto Finish;\r
-    }\r
-\r
-    //\r
-    // Get the next file\r
-    //\r
-    Status = GetNextFile (CurrentFile, &CurrentFile);\r
-    if (EFI_ERROR (Status)) {\r
-      Error (NULL, 0, 0, "cannot find the next file in the FV image", NULL);\r
-      goto Finish;\r
-    }\r
-  }\r
-  //\r
-  // Open the output file\r
-  //\r
-  OutputFile = fopen (OutputFileName, "wb");\r
-  if (OutputFile == NULL) {\r
-    Error (NULL, 0, 0, OutputFileName, "failed to open output file");\r
-    goto Finish;\r
-  }\r
-\r
-  if (fwrite (FvImage, 1, FvSize, OutputFile) != FvSize) {\r
-    Error (NULL, 0, 0, "failed to write to output file", 0);\r
-    goto Finish;\r
-  }\r
-\r
-Finish:\r
-  if (InputFile != NULL) {\r
-    fclose (InputFile);\r
-  }\r
-  //\r
-  // If we created an output file, and there was an error, remove it so\r
-  // subsequent builds will rebuild it.\r
-  //\r
-  if (OutputFile != NULL) {\r
-    if (GetUtilityStatus () == STATUS_ERROR) {\r
-      remove (OutputFileName);\r
-    }\r
-\r
-    fclose (OutputFile);\r
-  }\r
-\r
-  if (MapFile != NULL) {\r
-    fclose (MapFile);\r
-  }\r
-\r
-  if (FvImage != NULL) {\r
-    free (FvImage);\r
-  }\r
-\r
-  return GetUtilityStatus ();\r
-}\r
-\r
-EFI_STATUS\r
-ReadHeader (\r
-  IN FILE       *InputFile,\r
-  OUT UINT32    *FvSize,\r
-  OUT BOOLEAN   *ErasePolarity\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  This function determines the size of the FV and the erase polarity.  The \r
-  erase polarity is the FALSE value for file state.\r
-\r
-Arguments:\r
-\r
-  InputFile       The file that contains the FV image.\r
-  FvSize          The size of the FV.\r
-  ErasePolarity   The FV erase polarity.\r
-    \r
-Returns:\r
\r
-  EFI_SUCCESS             Function completed successfully.\r
-  EFI_INVALID_PARAMETER   A required parameter was NULL or is out of range.\r
-  EFI_ABORTED             The function encountered an error.\r
-\r
---*/\r
-{\r
-  EFI_FIRMWARE_VOLUME_HEADER  VolumeHeader;\r
-  EFI_FV_BLOCK_MAP_ENTRY      BlockMap;\r
-  UINTN                       Signature[2];\r
-  UINTN                       BytesRead;\r
-  UINT32                      Size;\r
-\r
-  BytesRead = 0;\r
-  Size      = 0;\r
-  //\r
-  // Check input parameters\r
-  //\r
-  if ((InputFile == NULL) || (FvSize == NULL) || (ErasePolarity == NULL)) {\r
-    Error (NULL, 0, 0, "ReadHeader()", "invalid input parameter");\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-  //\r
-  // Read the header\r
-  //\r
-  fread (&VolumeHeader, sizeof (EFI_FIRMWARE_VOLUME_HEADER) - sizeof (EFI_FV_BLOCK_MAP_ENTRY), 1, InputFile);\r
-  BytesRead     = sizeof (EFI_FIRMWARE_VOLUME_HEADER) - sizeof (EFI_FV_BLOCK_MAP_ENTRY);\r
-  Signature[0]  = VolumeHeader.Signature;\r
-  Signature[1]  = 0;\r
-\r
-  //\r
-  // Get erase polarity\r
-  //\r
-  if (VolumeHeader.Attributes & EFI_FVB_ERASE_POLARITY) {\r
-    *ErasePolarity = TRUE;\r
-  }\r
-\r
-  do {\r
-    fread (&BlockMap, sizeof (EFI_FV_BLOCK_MAP_ENTRY), 1, InputFile);\r
-    BytesRead += sizeof (EFI_FV_BLOCK_MAP_ENTRY);\r
-\r
-    if (BlockMap.NumBlocks != 0) {\r
-      Size += BlockMap.NumBlocks * BlockMap.BlockLength;\r
-    }\r
-\r
-  } while (!(BlockMap.NumBlocks == 0 && BlockMap.BlockLength == 0));\r
-\r
-  if (VolumeHeader.FvLength != Size) {\r
-    Error (NULL, 0, 0, "volume size not consistant with block maps", NULL);\r
-    return EFI_ABORTED;\r
-  }\r
-\r
-  *FvSize = Size;\r
-\r
-  rewind (InputFile);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-VOID\r
-PrintUtilityInfo (\r
-  VOID\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Displays the standard utility information to SDTOUT\r
-\r
-Arguments:\r
-\r
-  None\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-{\r
-  printf (\r
-    "%s, PEI Rebase Utility. Version %i.%i, %s.\n\n",\r
-    UTILITY_NAME,\r
-    UTILITY_MAJOR_VERSION,\r
-    UTILITY_MINOR_VERSION,\r
-    UTILITY_DATE\r
-    );\r
-}\r
-\r
-VOID\r
-PrintUsage (\r
-  VOID\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Displays the utility usage syntax to STDOUT\r
-\r
-Arguments:\r
-\r
-  None\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-{\r
-  printf (\r
-    "Usage: %s -I InputFileName -O OutputFileName -B BaseAddress [-M MapFile]\n",\r
-    UTILITY_NAME\r
-    );\r
-  printf ("  Where:\n");\r
-  printf ("    InputFileName is the name of the EFI FV file to rebase.\n");\r
-  printf ("    OutputFileName is the desired output file name.\n");\r
-  printf ("    BaseAddress is the FV base address to rebase agains.\n");\r
-  printf ("    MapFileName is an optional map file of the relocations\n");\r
-  printf ("  Argument pair may be in any order.\n\n");\r
-}\r
-\r
-EFI_STATUS\r
-FfsRebase (\r
-  IN OUT EFI_FFS_FILE_HEADER    *FfsFile,\r
-  IN EFI_PHYSICAL_ADDRESS       BaseAddress,\r
-  IN FILE                       *MapFile      OPTIONAL\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  This function determines if a file is XIP and should be rebased.  It will \r
-  rebase any PE32 sections found in the file using the base address.\r
-  \r
-Arguments:\r
-\r
-  FfsFile           A pointer to Ffs file image.\r
-  BaseAddress       The base address to use for rebasing the file image.\r
-  MapFile           Optional file to dump relocation information into\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS             The image was properly rebased.\r
-  EFI_INVALID_PARAMETER   An input parameter is invalid.\r
-  EFI_ABORTED             An error occurred while rebasing the input file image.\r
-  EFI_OUT_OF_RESOURCES    Could not allocate a required resource.\r
-  EFI_NOT_FOUND           No compressed sections could be found.\r
-\r
---*/\r
-{\r
-  EFI_STATUS                            Status;\r
-  PE_COFF_LOADER_IMAGE_CONTEXT          ImageContext;\r
-  UINTN                                 MemoryImagePointer;\r
-  UINTN                                 MemoryImagePointerAligned;\r
-  EFI_PHYSICAL_ADDRESS                  ImageAddress;\r
-  UINT64                                ImageSize;\r
-  EFI_PHYSICAL_ADDRESS                  EntryPoint;\r
-  UINT32                                Pe32ImageSize;\r
-  UINT32                                NewPe32BaseAddress;\r
-  UINTN                                 Index;\r
-  EFI_FILE_SECTION_POINTER              CurrentPe32Section;\r
-  EFI_FFS_FILE_STATE                    SavedState;\r
-  EFI_IMAGE_NT_HEADERS                  *PeHdr;\r
-  UINT32                                *PeHdrSizeOfImage;\r
-  UINT32                                *PeHdrChecksum;\r
-  UINT32                                FoundCount;\r
-  EFI_TE_IMAGE_HEADER                   *TEImageHeader;\r
-  UINT8                                 *TEBuffer;\r
-  EFI_IMAGE_DOS_HEADER                  *DosHeader;\r
-  UINT8                                 FileGuidString[80];\r
-  UINT32                                TailSize;\r
-  EFI_FFS_FILE_TAIL                     TailValue;\r
-\r
-  //\r
-  // Verify input parameters\r
-  //\r
-  if (FfsFile == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-  \r
-  //\r
-  // Convert the GUID to a string so we can at least report which file\r
-  // if we find an error.\r
-  //\r
-  PrintGuidToBuffer (&FfsFile->Name, FileGuidString, sizeof (FileGuidString), TRUE);\r
-  if (FfsFile->Attributes & FFS_ATTRIB_TAIL_PRESENT) {\r
-    TailSize = sizeof (EFI_FFS_FILE_TAIL);\r
-  } else {\r
-    TailSize = 0;\r
-  }\r
-  \r
-  //\r
-  // Do some cursory checks on the FFS file contents\r
-  //\r
-  Status = VerifyFfsFile (FfsFile);\r
-  if (EFI_ERROR (Status)) {\r
-    Error (NULL, 0, 0, "file does not appear to be a valid FFS file, cannot be rebased", FileGuidString);\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  memset (&ImageContext, 0, sizeof (ImageContext));\r
-\r
-  //\r
-  // Check if XIP file type. If not XIP, don't rebase.\r
-  //\r
-  if (FfsFile->Type != EFI_FV_FILETYPE_PEI_CORE &&\r
-      FfsFile->Type != EFI_FV_FILETYPE_PEIM &&\r
-      FfsFile->Type != EFI_FV_FILETYPE_SECURITY_CORE &&\r
-      FfsFile->Type != EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER\r
-      ) {\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  //\r
-  // Rebase each PE32 section\r
-  //\r
-  Status      = EFI_SUCCESS;\r
-  FoundCount  = 0;\r
-  for (Index = 1;; Index++) {\r
-    Status = GetSectionByType (FfsFile, EFI_SECTION_PE32, Index, &CurrentPe32Section);\r
-    if (EFI_ERROR (Status)) {\r
-      break;\r
-    }\r
-\r
-    FoundCount++;\r
-\r
-    //\r
-    // Calculate the PE32 base address, the FFS file base plus the offset of the PE32 section\r
-    //\r
-    NewPe32BaseAddress = ((UINT32) BaseAddress) + ((UINTN) CurrentPe32Section.Pe32Section + sizeof (EFI_COMMON_SECTION_HEADER) - (UINTN) FfsFile);\r
-\r
-    //\r
-    // Initialize context\r
-    //\r
-    memset (&ImageContext, 0, sizeof (ImageContext));\r
-    ImageContext.Handle     = (VOID *) ((UINTN) CurrentPe32Section.Pe32Section + sizeof (EFI_PE32_SECTION));\r
-    ImageContext.ImageRead  = (PE_COFF_LOADER_READ_FILE) FfsRebaseImageRead;\r
-\r
-    Status                  = PeCoffLoaderGetImageInfo (&ImageContext);\r
-\r
-    if (EFI_ERROR (Status)) {\r
-      Error (NULL, 0, 0, "GetImageInfo() call failed on rebase", FileGuidString);\r
-      return Status;\r
-    }\r
-    //\r
-    // Allocate a buffer for the image to be loaded into.\r
-    //\r
-    Pe32ImageSize       = GetLength (CurrentPe32Section.Pe32Section->CommonHeader.Size) - sizeof (EFI_PE32_SECTION);\r
-    MemoryImagePointer  = (UINTN) (malloc (Pe32ImageSize + 0x1000));\r
-    if (MemoryImagePointer == 0) {\r
-      Error (NULL, 0, 0, "memory allocation failure", NULL);\r
-      return EFI_OUT_OF_RESOURCES;\r
-    }\r
-    memset ((void *) MemoryImagePointer, 0, Pe32ImageSize + 0x1000);\r
-    MemoryImagePointerAligned = (MemoryImagePointer + 0x0FFF) & (-1 << 12);\r
-    \r
-\r
-    ImageContext.ImageAddress = MemoryImagePointerAligned;\r
-\r
-    Status                    = PeCoffLoaderLoadImage (&ImageContext);\r
-    if (EFI_ERROR (Status)) {\r
-      Error (NULL, 0, 0, "LoadImage() call failed on rebase", FileGuidString);\r
-      free ((VOID *) MemoryImagePointer);\r
-      return Status;\r
-    }\r
-\r
-    ImageContext.DestinationAddress = NewPe32BaseAddress;\r
-    Status                          = PeCoffLoaderRelocateImage (&ImageContext);\r
-    if (EFI_ERROR (Status)) {\r
-      Error (NULL, 0, 0, "RelocateImage() call failed on rebase", FileGuidString);\r
-      free ((VOID *) MemoryImagePointer);\r
-      return Status;\r
-    }\r
-\r
-    ImageAddress  = ImageContext.ImageAddress;\r
-    ImageSize     = ImageContext.ImageSize;\r
-    EntryPoint    = ImageContext.EntryPoint;\r
-\r
-    if (ImageSize > Pe32ImageSize) {\r
-      Error (\r
-        NULL,\r
-        0,\r
-        0,\r
-        "rebased image is larger than original PE32 image",\r
-        "0x%X > 0x%X, file %s",\r
-        ImageSize,\r
-        Pe32ImageSize,\r
-        FileGuidString\r
-        );\r
-      free ((VOID *) MemoryImagePointer);\r
-      return EFI_ABORTED;\r
-    }\r
-    //\r
-    // Since we may have updated the Codeview RVA, we need to insure the PE\r
-    // header indicates the image is large enough to contain the Codeview data\r
-    // so it will be loaded properly later if the PEIM is reloaded into memory...\r
-    //\r
-    PeHdr = (VOID *) ((UINTN) ImageAddress + ImageContext.PeCoffHeaderOffset);\r
-    if (PeHdr->FileHeader.Machine == EFI_IMAGE_MACHINE_IA32) {\r
-      PeHdrSizeOfImage     = (UINT32 *) (&(*(EFI_IMAGE_OPTIONAL_HEADER32 *) &PeHdr->OptionalHeader).SizeOfImage);\r
-      PeHdrChecksum        = (UINT32 *) (&(*(EFI_IMAGE_OPTIONAL_HEADER32 *) &PeHdr->OptionalHeader).CheckSum);\r
-    } else if (PeHdr->FileHeader.Machine == EFI_IMAGE_MACHINE_IA64) {\r
-      PeHdrSizeOfImage     = (UINT32 *) (&(*(EFI_IMAGE_OPTIONAL_HEADER64 *) &PeHdr->OptionalHeader).SizeOfImage);\r
-      PeHdrChecksum        = (UINT32 *) (&(*(EFI_IMAGE_OPTIONAL_HEADER64 *) &PeHdr->OptionalHeader).CheckSum);\r
-    } else if (PeHdr->FileHeader.Machine == EFI_IMAGE_MACHINE_X64) {\r
-      PeHdrSizeOfImage     = (UINT32 *) (&(*(EFI_IMAGE_OPTIONAL_HEADER64 *) &PeHdr->OptionalHeader).SizeOfImage);\r
-      PeHdrChecksum        = (UINT32 *) (&(*(EFI_IMAGE_OPTIONAL_HEADER64 *) &PeHdr->OptionalHeader).CheckSum);\r
-    } else {\r
-      Error (\r
-        NULL,\r
-        0,\r
-        0,\r
-        "unknown machine type in PE32 image",\r
-        "machine type=0x%X, file=%s",\r
-        (UINT32) PeHdr->FileHeader.Machine,\r
-        FileGuidString\r
-        );\r
-      free ((VOID *) MemoryImagePointer);\r
-      return EFI_ABORTED;\r
-    }\r
-\r
-    if (*PeHdrSizeOfImage != ImageContext.ImageSize) {\r
-      *PeHdrSizeOfImage = (UINT32) ImageContext.ImageSize;\r
-      if (*PeHdrChecksum) {\r
-        *PeHdrChecksum = 0;\r
-      }\r
-    }\r
-\r
-    memcpy (CurrentPe32Section.Pe32Section + 1, (VOID *) MemoryImagePointerAligned, (UINT32) ImageSize);\r
-    \r
-    //\r
-    // Get EntryPoint in Flash Region.\r
-    //\r
-    EntryPoint = NewPe32BaseAddress + EntryPoint - ImageAddress;\r
-\r
-    //\r
-    // If a map file was selected output mapping information for any file that\r
-    // was rebased.\r
-    //\r
-    if (MapFile != NULL) {\r
-      fprintf (MapFile, "PE32 File: %s Base:%08lx", FileGuidString, BaseAddress);\r
-      fprintf (MapFile, " EntryPoint:%08lx", EntryPoint);\r
-      if (ImageContext.PdbPointer != NULL) {\r
-        fprintf (MapFile, " FileName: %s", ImageContext.PdbPointer);\r
-      }\r
-      fprintf (MapFile, "\n");\r
-    }\r
-\r
-    free ((VOID *) MemoryImagePointer);\r
-\r
-    //\r
-    // Now update file checksum\r
-    //\r
-    if (FfsFile->Attributes & FFS_ATTRIB_TAIL_PRESENT) {\r
-      TailSize = sizeof (EFI_FFS_FILE_TAIL);\r
-    } else {\r
-      TailSize = 0;\r
-    }\r
-\r
-    if (FfsFile->Attributes & FFS_ATTRIB_CHECKSUM) {\r
-      SavedState  = FfsFile->State;\r
-      FfsFile->IntegrityCheck.Checksum.File = 0;\r
-      FfsFile->State                        = 0;\r
-      if (FfsFile->Attributes & FFS_ATTRIB_CHECKSUM) {\r
-        FfsFile->IntegrityCheck.Checksum.File = CalculateChecksum8 (\r
-                                                  (UINT8 *) FfsFile,\r
-                                                  GetLength (FfsFile->Size) - TailSize\r
-                                                  );\r
-      } else {\r
-        FfsFile->IntegrityCheck.Checksum.File = FFS_FIXED_CHECKSUM;\r
-      }\r
-\r
-      FfsFile->State = SavedState;\r
-    }\r
-    //\r
-    // Update tail if present\r
-    //\r
-    if (FfsFile->Attributes & FFS_ATTRIB_TAIL_PRESENT) {\r
-      TailValue = (EFI_FFS_FILE_TAIL) (~(FfsFile->IntegrityCheck.TailReference));\r
-      *(EFI_FFS_FILE_TAIL *) (((UINTN) FfsFile + GetLength (FfsFile->Size) - sizeof (EFI_FFS_FILE_TAIL))) = TailValue;\r
-    }\r
-  }\r
-  //\r
-  // Now process TE sections\r
-  //\r
-  for (Index = 1;; Index++) {\r
-    Status = GetSectionByType (FfsFile, EFI_SECTION_TE, Index, &CurrentPe32Section);\r
-    if (EFI_ERROR (Status)) {\r
-      break;\r
-    }\r
-\r
-    FoundCount++;\r
-\r
-    //\r
-    // Calculate the TE base address, the FFS file base plus the offset of the TE section less the size stripped off\r
-    // by GenTEImage\r
-    //\r
-    TEImageHeader = (EFI_TE_IMAGE_HEADER *) ((UINT8 *) CurrentPe32Section.Pe32Section + sizeof (EFI_COMMON_SECTION_HEADER));\r
-\r
-    NewPe32BaseAddress = ((UINT32) BaseAddress) +\r
-      (\r
-        (UINTN) CurrentPe32Section.Pe32Section +\r
-        sizeof (EFI_COMMON_SECTION_HEADER) +\r
-        sizeof (EFI_TE_IMAGE_HEADER) -\r
-        TEImageHeader->StrippedSize -\r
-        (UINTN) FfsFile\r
-      );\r
-\r
-    //\r
-    // Allocate a buffer to unshrink the image into.\r
-    //\r
-    Pe32ImageSize = GetLength (CurrentPe32Section.Pe32Section->CommonHeader.Size) - sizeof (EFI_PE32_SECTION) -\r
-    sizeof (EFI_TE_IMAGE_HEADER);\r
-    Pe32ImageSize += TEImageHeader->StrippedSize;\r
-    TEBuffer = (UINT8 *) malloc (Pe32ImageSize);\r
-    if (TEBuffer == NULL) {\r
-      Error (NULL, 0, 0, "failed to allocate memory", NULL);\r
-      return EFI_OUT_OF_RESOURCES;\r
-    }\r
-    //\r
-    // Expand the image into our buffer and fill in critical fields in the DOS header\r
-    // Fill in fields required by the loader.\r
-    // At offset 0x3C is the offset to the PE signature. We'll put it immediately following the offset value\r
-    // itself.\r
-    //\r
-    memset (TEBuffer, 0, Pe32ImageSize);\r
-    DosHeader = (EFI_IMAGE_DOS_HEADER *) TEBuffer;\r
-    DosHeader->e_magic = EFI_IMAGE_DOS_SIGNATURE;\r
-    *(UINT32 *) (TEBuffer + 0x3C) = 0x40;\r
-    PeHdr = (EFI_IMAGE_NT_HEADERS *) (TEBuffer + 0x40);\r
-    PeHdr->Signature = EFI_IMAGE_NT_SIGNATURE;\r
-    PeHdr->FileHeader.Machine = TEImageHeader->Machine;\r
-    PeHdr->FileHeader.NumberOfSections = TEImageHeader->NumberOfSections;\r
-\r
-    //\r
-    // Say the size of the optional header is the total we stripped off less the size of a PE file header and PE signature and\r
-    // the 0x40 bytes for our DOS header.\r
-    //\r
-    PeHdr->FileHeader.SizeOfOptionalHeader = (UINT16) (TEImageHeader->StrippedSize - 0x40 - sizeof (UINT32) - sizeof (EFI_IMAGE_FILE_HEADER));\r
-    PeHdr->OptionalHeader.ImageBase = (UINTN) (TEImageHeader->ImageBase - TEImageHeader->StrippedSize + sizeof (EFI_TE_IMAGE_HEADER));\r
-    PeHdr->OptionalHeader.AddressOfEntryPoint = TEImageHeader->AddressOfEntryPoint;\r
-    PeHdr->OptionalHeader.BaseOfCode  = TEImageHeader->BaseOfCode;\r
-    PeHdr->OptionalHeader.SizeOfImage = Pe32ImageSize;\r
-    PeHdr->OptionalHeader.Subsystem   = TEImageHeader->Subsystem;\r
-    PeHdr->OptionalHeader.SizeOfImage = Pe32ImageSize;\r
-    PeHdr->OptionalHeader.SizeOfHeaders = TEImageHeader->StrippedSize + TEImageHeader->NumberOfSections *\r
-    sizeof (EFI_IMAGE_SECTION_HEADER) - 12;\r
-\r
-    //\r
-    // Set NumberOfRvaAndSizes in the optional header to what we had available in the original image\r
-    //\r
-    if ((TEImageHeader->DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_BASERELOC].VirtualAddress != 0) ||\r
-        (TEImageHeader->DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_BASERELOC].Size != 0)\r
-        ) {\r
-      PeHdr->OptionalHeader.NumberOfRvaAndSizes = EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC + 1;\r
-      PeHdr->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC].VirtualAddress = TEImageHeader->DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_BASERELOC].VirtualAddress;\r
-      PeHdr->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC].Size = TEImageHeader->DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_BASERELOC].Size;\r
-    }\r
-\r
-    if ((TEImageHeader->DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG].VirtualAddress != 0) ||\r
-        (TEImageHeader->DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG].Size != 0)\r
-        ) {\r
-      PeHdr->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG].VirtualAddress = TEImageHeader->DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG].VirtualAddress;\r
-      PeHdr->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG].Size = TEImageHeader->DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG].Size;\r
-      if (PeHdr->OptionalHeader.NumberOfRvaAndSizes < EFI_IMAGE_DIRECTORY_ENTRY_DEBUG + 1) {\r
-        PeHdr->OptionalHeader.NumberOfRvaAndSizes = EFI_IMAGE_DIRECTORY_ENTRY_DEBUG + 1;\r
-      }\r
-    }\r
-    //\r
-    // NOTE: These values are defaults, and should be verified to be correct in the GenTE utility\r
-    //\r
-    PeHdr->OptionalHeader.SectionAlignment = 0x10;\r
-\r
-    //\r
-    // Copy the rest of the image to its original offset\r
-    //\r
-    memcpy (\r
-      TEBuffer + TEImageHeader->StrippedSize,\r
-      (UINT8 *) CurrentPe32Section.Pe32Section + sizeof (EFI_PE32_SECTION) + sizeof (EFI_TE_IMAGE_HEADER),\r
-      GetLength (CurrentPe32Section.Pe32Section->CommonHeader.Size) - sizeof (EFI_PE32_SECTION) -\r
-      sizeof (EFI_TE_IMAGE_HEADER)\r
-      );\r
-\r
-    //\r
-    // Initialize context\r
-    //\r
-    memset (&ImageContext, 0, sizeof (ImageContext));\r
-    ImageContext.Handle     = (VOID *) TEBuffer;\r
-    ImageContext.ImageRead  = (PE_COFF_LOADER_READ_FILE) FfsRebaseImageRead;\r
-\r
-    Status                  = PeCoffLoaderGetImageInfo (&ImageContext);\r
-\r
-    if (EFI_ERROR (Status)) {\r
-      Error (NULL, 0, 0, "GetImageInfo() call failed on rebase of TE image", FileGuidString);\r
-      free (TEBuffer);\r
-      return Status;\r
-    }\r
-    //\r
-    // Allocate a buffer for the image to be loaded into.\r
-    //\r
-    MemoryImagePointer = (UINTN) (malloc (Pe32ImageSize + 0x1000));\r
-    if (MemoryImagePointer == 0) {\r
-      Error (NULL, 0, 0, "memory allocation error on rebase of TE image", FileGuidString);\r
-      free (TEBuffer);\r
-      return EFI_OUT_OF_RESOURCES;\r
-    }\r
-    memset ((void *) MemoryImagePointer, 0, Pe32ImageSize + 0x1000);\r
-    MemoryImagePointerAligned = (MemoryImagePointer + 0x0FFF) & (-1 << 12);\r
-    \r
-\r
-    ImageContext.ImageAddress = MemoryImagePointerAligned;\r
-    Status                    = PeCoffLoaderLoadImage (&ImageContext);\r
-    if (EFI_ERROR (Status)) {\r
-      Error (NULL, 0, 0, "LoadImage() call failed on rebase of TE image", FileGuidString);\r
-      free (TEBuffer);\r
-      free ((VOID *) MemoryImagePointer);\r
-      return Status;\r
-    }\r
-\r
-    ImageContext.DestinationAddress = NewPe32BaseAddress;\r
-    Status                          = PeCoffLoaderRelocateImage (&ImageContext);\r
-    if (EFI_ERROR (Status)) {\r
-      Error (NULL, 0, 0, "RelocateImage() call failed on rebase of TE image", FileGuidString);\r
-      free ((VOID *) MemoryImagePointer);\r
-      free (TEBuffer);\r
-      return Status;\r
-    }\r
-\r
-    ImageAddress  = ImageContext.ImageAddress;\r
-    ImageSize     = ImageContext.ImageSize;\r
-    EntryPoint    = ImageContext.EntryPoint;\r
-\r
-    //\r
-    // Since we may have updated the Codeview RVA, we need to insure the PE\r
-    // header indicates the image is large enough to contain the Codeview data\r
-    // so it will be loaded properly later if the PEIM is reloaded into memory...\r
-    //\r
-    PeHdr = (VOID *) ((UINTN) ImageAddress + ImageContext.PeCoffHeaderOffset);\r
-    if (PeHdr->FileHeader.Machine == EFI_IMAGE_MACHINE_IA32) {\r
-      PeHdrSizeOfImage     = (UINT32 *) (&(*(EFI_IMAGE_OPTIONAL_HEADER32 *) &PeHdr->OptionalHeader).SizeOfImage);\r
-      PeHdrChecksum        = (UINT32 *) (&(*(EFI_IMAGE_OPTIONAL_HEADER32 *) &PeHdr->OptionalHeader).CheckSum);\r
-    } else if (PeHdr->FileHeader.Machine == EFI_IMAGE_MACHINE_IA64) {\r
-      PeHdrSizeOfImage     = (UINT32 *) (&(*(EFI_IMAGE_OPTIONAL_HEADER64 *) &PeHdr->OptionalHeader).SizeOfImage);\r
-      PeHdrChecksum        = (UINT32 *) (&(*(EFI_IMAGE_OPTIONAL_HEADER64 *) &PeHdr->OptionalHeader).CheckSum);\r
-    } else {\r
-      Error (\r
-        NULL,\r
-        0,\r
-        0,\r
-        "unknown machine type in TE image",\r
-        "machine type=0x%X, file=%s",\r
-        (UINT32) PeHdr->FileHeader.Machine,\r
-        FileGuidString\r
-        );\r
-      free ((VOID *) MemoryImagePointer);\r
-      free (TEBuffer);\r
-      return EFI_ABORTED;\r
-    }\r
-\r
-    if (*PeHdrSizeOfImage != ImageContext.ImageSize) {\r
-      *PeHdrSizeOfImage = (UINT32) ImageContext.ImageSize;\r
-      if (*PeHdrChecksum) {\r
-        *PeHdrChecksum = 0;\r
-      }\r
-    }\r
-\r
-    TEImageHeader->ImageBase = (UINT64) (NewPe32BaseAddress + TEImageHeader->StrippedSize - sizeof (EFI_TE_IMAGE_HEADER));\r
-    memcpy (\r
-      (UINT8 *) (CurrentPe32Section.Pe32Section + 1) + sizeof (EFI_TE_IMAGE_HEADER),\r
-      (VOID *) ((UINT8 *) MemoryImagePointerAligned + TEImageHeader->StrippedSize),\r
-      GetLength (CurrentPe32Section.Pe32Section->CommonHeader.Size) - sizeof (EFI_PE32_SECTION) -\r
-      sizeof (EFI_TE_IMAGE_HEADER)\r
-      );\r
-    \r
-    //\r
-    // Get EntryPoint in Flash Region.\r
-    //\r
-    EntryPoint = NewPe32BaseAddress + EntryPoint - ImageAddress;\r
-\r
-    //\r
-    // If a map file was selected output mapping information for any file that\r
-    // was rebased.\r
-    //\r
-    if (MapFile != NULL) {\r
-      fprintf (MapFile, "TE   File: %s Base:%08lx", FileGuidString, BaseAddress);\r
-      fprintf (MapFile, " EntryPoint:%08lx", EntryPoint);\r
-      if (ImageContext.PdbPointer != NULL) {\r
-        fprintf (MapFile, " FileName: %s", ImageContext.PdbPointer);\r
-      }\r
-      fprintf (MapFile, "\n");\r
-    }\r
-\r
-    free ((VOID *) MemoryImagePointer);\r
-    free (TEBuffer);\r
-    if (FfsFile->Attributes & FFS_ATTRIB_TAIL_PRESENT) {\r
-      TailSize = sizeof (EFI_FFS_FILE_TAIL);\r
-    } else {\r
-      TailSize = 0;\r
-    }\r
-    //\r
-    // Now update file checksum\r
-    //\r
-    if (FfsFile->Attributes & FFS_ATTRIB_CHECKSUM) {\r
-      SavedState  = FfsFile->State;\r
-      FfsFile->IntegrityCheck.Checksum.File = 0;\r
-      FfsFile->State                        = 0;\r
-      if (FfsFile->Attributes & FFS_ATTRIB_CHECKSUM) {\r
-        FfsFile->IntegrityCheck.Checksum.File = CalculateChecksum8 (\r
-                                                  (UINT8 *) FfsFile,\r
-                                                  GetLength (FfsFile->Size) - TailSize\r
-                                                  );\r
-      } else {\r
-        FfsFile->IntegrityCheck.Checksum.File = FFS_FIXED_CHECKSUM;\r
-      }\r
-\r
-      FfsFile->State = SavedState;\r
-    }\r
-    //\r
-    // Update tail if present\r
-    //\r
-    if (FfsFile->Attributes & FFS_ATTRIB_TAIL_PRESENT) {\r
-      TailValue = (EFI_FFS_FILE_TAIL) (~(FfsFile->IntegrityCheck.TailReference));\r
-      *(EFI_FFS_FILE_TAIL *) (((UINTN) FfsFile + GetLength (FfsFile->Size) - sizeof (EFI_FFS_FILE_TAIL))) = TailValue;\r
-    }\r
-  }\r
-  //\r
-  // If we found no files, then emit an error if no compressed sections either\r
-  //\r
-  if (FoundCount == 0) {\r
-    Status = GetSectionByType (FfsFile, EFI_SECTION_COMPRESSION, Index, &CurrentPe32Section);\r
-    if (EFI_ERROR (Status)) {\r
-      Error (NULL, 0, 0, "no PE32, TE, nor compressed section found in FV file", FileGuidString);\r
-      return EFI_NOT_FOUND;\r
-    }\r
-  }\r
-  \r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-FfsRebaseImageRead (\r
-  IN     VOID    *FileHandle,\r
-  IN     UINTN   FileOffset,\r
-  IN OUT UINT32  *ReadSize,\r
-  OUT    VOID    *Buffer\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Support routine for the PE/COFF Loader that reads a buffer from a PE/COFF file\r
-\r
-Arguments:\r
-\r
-  FileHandle - The handle to the PE/COFF file\r
-\r
-  FileOffset - The offset, in bytes, into the file to read\r
-\r
-  ReadSize   - The number of bytes to read from the file starting at FileOffset\r
-\r
-  Buffer     - A pointer to the buffer to read the data into.\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS - ReadSize bytes of data were read into Buffer from the PE/COFF file starting at FileOffset\r
-\r
---*/\r
-{\r
-  CHAR8   *Destination8;\r
-  CHAR8   *Source8;\r
-  UINT32  Length;\r
-\r
-  Destination8  = Buffer;\r
-  Source8       = (CHAR8 *) ((UINTN) FileHandle + FileOffset);\r
-  Length        = *ReadSize;\r
-  while (Length--) {\r
-    *(Destination8++) = *(Source8++);\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
diff --git a/Tools/CodeTools/TianoTools/PeiRebase/PeiRebaseExe.h b/Tools/CodeTools/TianoTools/PeiRebase/PeiRebaseExe.h
deleted file mode 100644 (file)
index b05baef..0000000
+++ /dev/null
@@ -1,155 +0,0 @@
-/*++\r
-\r
-Copyright (c)  1999-2006 Intel Corporation. All rights reserved\r
-This program and the accompanying materials are licensed and made available \r
-under the terms and conditions of the BSD License which accompanies this \r
-distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-\r
-Module Name:\r
-  \r
-  PeiRebaseExe.h\r
-\r
-Abstract:\r
-\r
-  Definitions for the PeiRebase exe utility.\r
-\r
---*/\r
-\r
-#ifndef _EFI_PEIM_FIXUP_EXE_H\r
-#define _EFI_PEIM_FIXUP_EXE_H\r
-\r
-#include <Common/FirmwareVolumeImageFormat.h>\r
-#include <Common/FirmwareFileSystem.h>\r
-#include <Common/FirmwareVolumeHeader.h>\r
-#include <Common/MultiPhase.h>\r
-\r
-//\r
-// Utility Name\r
-//\r
-#define UTILITY_NAME  "PeiRebase"\r
-\r
-//\r
-// Utility version information\r
-//\r
-#define UTILITY_MAJOR_VERSION 0\r
-#define UTILITY_MINOR_VERSION 1\r
-#define UTILITY_DATE          __DATE__\r
-\r
-//\r
-// The maximum number of arguments accepted from the command line.\r
-//\r
-#define MAX_ARGS  9\r
-\r
-//\r
-// The file copy buffer size\r
-//\r
-#define FILE_COPY_BUFFER_SIZE 512\r
-\r
-//\r
-// The function that displays general utility information\r
-//\r
-VOID\r
-PrintUtilityInfo (\r
-  VOID\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  None\r
-\r
-Returns:\r
-\r
-  GC_TODO: add return values\r
-\r
---*/\r
-;\r
-\r
-//\r
-// The function that displays the utility usage message.\r
-//\r
-VOID\r
-PrintUsage (\r
-  VOID\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  None\r
-\r
-Returns:\r
-\r
-  GC_TODO: add return values\r
-\r
---*/\r
-;\r
-\r
-//\r
-// Internal function declarations\r
-//\r
-EFI_STATUS\r
-FfsRebaseImageRead (\r
-  IN     VOID    *FileHandle,\r
-  IN     UINTN   FileOffset,\r
-  IN OUT UINT32  *ReadSize,\r
-  OUT    VOID    *Buffer\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  FileHandle  - GC_TODO: add argument description\r
-  FileOffset  - GC_TODO: add argument description\r
-  ReadSize    - GC_TODO: add argument description\r
-  Buffer      - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
-  GC_TODO: add return values\r
-\r
---*/\r
-;\r
-\r
-EFI_STATUS\r
-FfsRebase (\r
-  IN OUT EFI_FFS_FILE_HEADER    *FfsFile,\r
-  IN EFI_PHYSICAL_ADDRESS       BaseAddress,\r
-  IN FILE                       *MapFile      OPTIONAL\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  FfsFile     - GC_TODO: add argument description\r
-  BaseAddress - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
-  GC_TODO: add return values\r
-\r
---*/\r
-;\r
-\r
-#endif\r
diff --git a/Tools/CodeTools/TianoTools/PeiRebase/build.xml b/Tools/CodeTools/TianoTools/PeiRebase/build.xml
deleted file mode 100644 (file)
index 7174441..0000000
+++ /dev/null
@@ -1,107 +0,0 @@
-<?xml version="1.0" ?>\r
-<!--\r
-Copyright (c) 2006, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
--->\r
-<project default="GenTool" basedir=".">\r
-<!--\r
-    EDK PeiRebase Tool\r
-  Copyright (c) 2006, Intel Corporation\r
--->\r
-  <property name="ToolName" value="PeiRebase"/>\r
-  <property name="FileSet" value="*.c"/>\r
-\r
-  <taskdef resource="cpptasks.tasks"/>\r
-  <typedef resource="cpptasks.types"/>\r
-  <taskdef resource="net/sf/antcontrib/antlib.xml"/>\r
-\r
-  <property name="LINK_OUTPUT_TYPE" value="static"/>\r
-  <property name="BUILD_DIR" value="${PACKAGE_DIR}/${ToolName}/tmp"/>\r
-\r
-  <target name="GenTool" depends="init, Tool">\r
-    <echo message="The EDK Tool: ${ToolName} build has completed"/>\r
-  </target>\r
-\r
-  <target name="Tool" depends="init, PeiRebase_Ia32, PeiRebase_Ipf, PeiRebase_X64"/>\r
-\r
-  <target name="init">\r
-    <echo message="Building the EDK Tool: ${ToolName}"/>\r
-    <mkdir dir="${BUILD_DIR}"/>\r
-  </target>\r
-\r
-  <target name="PeiRebase_Ia32" depends="init">\r
-    <cc name="${ToolChain}" objdir="${BUILD_DIR}" \r
-        outfile="${BIN_DIR}/${ToolName}_Ia32"\r
-        outtype="executable"\r
-        debug="true"\r
-        optimize="speed">\r
-      <compilerarg value="${ExtraArgus}" if="ExtraArgus" />\r
-\r
-      <fileset dir="${basedir}/${ToolName}" \r
-        includes="${FileSet}"/>\r
-\r
-      <includepath path="${PACKAGE_DIR}/Include"/>\r
-      <includepath path="${PACKAGE_DIR}/Include/Ia32"/>\r
-      <includepath path="${PACKAGE_DIR}/Common"/>\r
-      <libset dir="${LIB_DIR}" libs="CommonTools PeCoffLoader_Ia32"/>\r
-    </cc>\r
-  </target>\r
-\r
-  <target name="PeiRebase_Ipf" depends="init">\r
-    <cc name="${ToolChain}" objdir="${BUILD_DIR}" \r
-        outfile="${BIN_DIR}/${ToolName}_Ipf"\r
-        outtype="executable"\r
-        debug="true"\r
-        optimize="speed">\r
-      <compilerarg value="${ExtraArgus}" if="ExtraArgus" />\r
-      <fileset dir="${basedir}/${ToolName}" \r
-        includes="${FileSet}"/>\r
-\r
-      <includepath path="${PACKAGE_DIR}/Include"/>\r
-      <includepath path="${PACKAGE_DIR}/Include/Ia32"/>\r
-      <includepath path="${PACKAGE_DIR}/Common"/>\r
-      <libset dir="${LIB_DIR}" libs="CommonTools PeCoffLoader_Ipf"/>\r
-    </cc>\r
-  </target>\r
-\r
-  <target name="PeiRebase_X64" depends="init">\r
-    <cc name="${ToolChain}" objdir="${BUILD_DIR}" \r
-        outfile="${BIN_DIR}/${ToolName}_X64"\r
-        outtype="executable"\r
-        debug="true"\r
-        optimize="speed">\r
-      <compilerarg value="${ExtraArgus}" if="ExtraArgus" />\r
-      <fileset dir="${basedir}/${ToolName}" \r
-        includes="${FileSet}" />\r
-\r
-      <includepath path="${PACKAGE_DIR}/Include"/>\r
-      <includepath path="${PACKAGE_DIR}/Include/Ia32"/>\r
-      <includepath path="${PACKAGE_DIR}/Common"/>\r
-      <libset dir="${LIB_DIR}" libs="CommonTools PeCoffLoader_X64"/>\r
-    </cc>\r
-  </target>\r
-\r
-  <target name="clean">\r
-    <echo message="Removing Intermediate Files Only"/>  \r
-    <delete>\r
-      <fileset dir="${BUILD_DIR}" includes="*.obj"/>\r
-    </delete>\r
-  </target>\r
-\r
-  <target name="cleanall">\r
-    <echo message="Removing Object Files and the Executable: ${ToolName}_*${ext_exe}"/>  \r
-    <delete failonerror="false" quiet="true" includeEmptyDirs="true">\r
-      <fileset dir="${BUILD_DIR}"/>\r
-      <fileset file="${BIN_DIR}/${ToolName}_Ia32${ext_exe}"/>\r
-      <fileset file="${BIN_DIR}/${ToolName}_Ipf${ext_exe}"/>\r
-      <fileset file="${BIN_DIR}/${ToolName}_X64${ext_exe}"/>\r
-    </delete>\r
-  </target>\r
-\r
-</project>\r
diff --git a/Tools/CodeTools/TianoTools/SecApResetVectorFixup/SecApResetVectorFixup.c b/Tools/CodeTools/TianoTools/SecApResetVectorFixup/SecApResetVectorFixup.c
deleted file mode 100644 (file)
index 4426457..0000000
+++ /dev/null
@@ -1,363 +0,0 @@
-/*++\r
-\r
-Copyright (c)  2004-2006 Intel Corporation. All rights reserved\r
-This program and the accompanying materials are licensed and made available \r
-under the terms and conditions of the BSD License which accompanies this \r
-distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-\r
-Module Name:\r
-\r
-    SecApResetVectorFixup.c\r
-\r
-Abstract:\r
-\r
-    This utility is part of build process for IA32 Fvrecovery.fv whose total size\r
-    is larger than 128kB so that we cannot use GenFvImage utility to put Ap reset \r
-    vector at the zero vector of Fv header.\r
-    \r
-      PEI FV after using the tool\r
-    \r
-    -------------------------\r
-    |zzz                    |\r
-    |                       |\r
-    |                       |\r
-    |      FFS              |\r
-    |                       |\r
-    |                       |\r
-    |                       |\r
-    |---------------------- |\r
-    |       PAD             |\r
-    |                       |\r
-    |.......................|  --- \r
-    |                       |   |\r
-    |xxx                    |   | 128K    \r
-    |---------------------- |   | \r
-    |       VTF (SEC)       |   |\r
-    -------------------------  ---\r
-    \r
-    1. zzz --> Zero vector, which is beyond the 128K limited address space\r
-    2. xxx --> AP reset vector at 4K alignment below 128K and it is in the PAD\r
-       file area.\r
-    3. After the build process ,the PAD guid is changed to a new GUID to avoid \r
-       the PAD definition confusing. If there is some problem, try to disable\r
-       UpdatePadFileGuid\r
-    \r
-     \r
-    \r
---*/\r
-\r
-#include "SecApResetVectorFixup.h"\r
-\r
-\r
-EFI_GUID  DefaultFvPadFileNameGuid = { 0x78f54d4, 0xcc22, 0x4048, 0x9e, 0x94, 0x87, 0x9c, 0x21, 0x4d, 0x56, 0x2f };\r
-EFI_GUID  NewFvPadFileNameGuid     = { 0x145372bc, 0x66b9, 0x476d, 0x81, 0xbc, 0x21, 0x27, 0xc3, 0x76, 0xbb, 0x66 };\r
-\r
-//\r
-// jmp 0xf000:0xffd0 (0xFFFFFFD0)\r
-//\r
-UINT8 ApResetVector[5] = {0xEA, 0xD0, 0xFF, 0x00, 0xF0};\r
-\r
-VOID\r
-PrintUtilityInfo (\r
-  VOID\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Displays the standard utility information to SDTOUT\r
-\r
-Arguments:\r
-\r
-  None\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-{\r
-  printf (\r
-    "%s - Tiano IA32 SEC Ap Reset Vector Fixup Utility."" Version %i.%i\n\n",\r
-    UTILITY_NAME,\r
-    UTILITY_MAJOR_VERSION,\r
-    UTILITY_MINOR_VERSION\r
-    );\r
-}\r
-\r
-VOID\r
-PrintUsage (\r
-  VOID\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Displays the utility usage syntax to STDOUT\r
-\r
-Arguments:\r
-\r
-  None\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-{\r
-  printf ("Usage: %s InputFvrecoveryFile OutputFvrecoveryFile\n", UTILITY_NAME);\r
-  printf ("  Where:\n");\r
-  printf ("\tInputFvrecoveryFile   - Name of the IA32 input Fvrecovery.fv file.\n");\r
-  printf ("\tOutputFvrecoveryFile  - Name of the IA32 output Fvrecovery.fv file.\n");\r
-}\r
-\r
-\r
-VOID \r
-UpdatePadFileGuid (\r
-  IN     EFI_FIRMWARE_VOLUME_HEADER  *FvHeader,\r
-  IN     EFI_FFS_FILE_HEADER         *FileHeader,\r
-  IN     UINT32                      FileLength,\r
-  IN OUT EFI_GUID                    *Guid\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Update the Pad File Guid to change it to other guid and update\r
-  the checksum\r
-\r
-Arguments:\r
-  FvHeader   - EFI_FIRMWARE_VOLUME_HEADER \r
-  FileHeader - The FFS PAD file header.\r
-  FileLength - The FFS PAD file length.\r
-  Guid       - The Guid to compare and if it is PAD Guid, update it to new Guid\r
-Returns:\r
-  VOID\r
---*/\r
-\r
-{\r
-  if ((CompareGuid (Guid, (EFI_GUID *)&DefaultFvPadFileNameGuid)) == 0) {\r
-    //\r
-    // Set new Pad file guid\r
-    // \r
-    memcpy (Guid, &NewFvPadFileNameGuid, sizeof (EFI_GUID));\r
-\r
-\r
-\r
-    FileHeader->Type       = EFI_FV_FILETYPE_FFS_PAD;\r
-    FileHeader->Attributes = 0;\r
-    //\r
-    // Fill in checksums and state, must be zero during checksum calculation.\r
-    //\r
-    FileHeader->IntegrityCheck.Checksum.Header = 0;\r
-    FileHeader->IntegrityCheck.Checksum.File   = 0;\r
-    FileHeader->State                          = 0;\r
-    FileHeader->IntegrityCheck.Checksum.Header = CalculateChecksum8 ((UINT8 *) FileHeader, sizeof (EFI_FFS_FILE_HEADER));\r
-    if (FileHeader->Attributes & FFS_ATTRIB_CHECKSUM) {\r
-      FileHeader->IntegrityCheck.Checksum.File = CalculateChecksum8 ((UINT8 *) FileHeader, FileLength);\r
-    } else {\r
-      FileHeader->IntegrityCheck.Checksum.File = FFS_FIXED_CHECKSUM;\r
-    }\r
-\r
-    FileHeader->State = EFI_FILE_HEADER_CONSTRUCTION | EFI_FILE_HEADER_VALID | EFI_FILE_DATA_VALID;\r
-\r
-    if (FvHeader->Attributes & EFI_FVB_ERASE_POLARITY) {\r
-      FileHeader->State = (UINT8)~(FileHeader->State);\r
-    }    \r
-  }\r
-  \r
-}\r
-\r
-\r
-STATUS\r
-main (\r
-  IN INTN   argc,\r
-  IN CHAR8  **argv\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Main function.\r
-\r
-Arguments:\r
-\r
-  argc - Number of command line parameters.\r
-  argv - Array of pointers to parameter strings.\r
-\r
-Returns:\r
-  STATUS_SUCCESS - Utility exits successfully.\r
-  STATUS_ERROR   - Some error occurred during execution.\r
-\r
---*/\r
-{\r
-  FILE                        *FpIn;\r
-  FILE                        *FpOut;\r
-  UINT32                      FvrecoveryFileSize;\r
-  UINT8                       *FileBuffer;\r
-  UINT8                       *FileBufferRaw;\r
-  UINT64                      FvLength;\r
-  UINT32                      Offset;\r
-  UINT32                      FileLength;\r
-  UINT32                      FileOccupiedSize;\r
-  EFI_FIRMWARE_VOLUME_HEADER  *FvHeader;\r
-  EFI_FFS_FILE_HEADER         *FileHeader;\r
-  EFI_GUID                    *TempGuid;\r
-  UINT8                       *FixPoint;\r
-  UINT32                      TempResult;\r
-  UINT32                      Index;\r
-  UINT32                      IpiVector;\r
-\r
-  TempGuid = NULL;\r
-  SetUtilityName (UTILITY_NAME);\r
-\r
-  //\r
-  // Display utility information\r
-  //\r
-  PrintUtilityInfo ();\r
-\r
-  //\r
-  // Verify the correct number of arguments\r
-  //\r
-  if (argc != MAX_ARGS) {\r
-    Error (NULL, 0, 0, "invalid number of input parameters specified", NULL);\r
-    PrintUsage ();\r
-    return STATUS_ERROR;\r
-  }\r
-  //\r
-  // Open the Input Fvrecovery.fv file\r
-  //\r
-  if ((FpIn = fopen (argv[1], "rb")) == NULL) {\r
-    Error (NULL, 0, 0, "Unable to open file", argv[1]);\r
-    return STATUS_ERROR;\r
-  }\r
-  //\r
-  // Get the Input Fvrecovery.fv file size\r
-  //\r
-  fseek (FpIn, 0, SEEK_END);\r
-  FvrecoveryFileSize = ftell (FpIn);\r
-  //\r
-  // Read the contents of input file to memory buffer\r
-  //\r
-  FileBuffer    = NULL;\r
-  FileBufferRaw = NULL;\r
-  FileBufferRaw = (UINT8 *) malloc (FvrecoveryFileSize + 0x10000);\r
-  if (NULL == FileBufferRaw) {\r
-    Error (NULL, 0, 0, "No sufficient memory to allocate!", NULL);\r
-    fclose (FpIn);\r
-    return STATUS_ERROR;\r
-  }\r
-  TempResult = 0x10000 - ((UINT32)FileBufferRaw & 0x0FFFF);\r
-  FileBuffer = (UINT8 *)((UINT32)FileBufferRaw + TempResult);\r
-  fseek (FpIn, 0, SEEK_SET);\r
-  TempResult = fread (FileBuffer, 1, FvrecoveryFileSize, FpIn);\r
-  if (TempResult != FvrecoveryFileSize) {\r
-    Error (NULL, 0, 0, "Read input file error!", NULL);\r
-    free ((VOID *)FileBufferRaw);\r
-    fclose (FpIn);\r
-    return STATUS_ERROR;\r
-  }\r
-  //\r
-  // Close the input Fvrecovery.fv file\r
-  //\r
-  fclose (FpIn);\r
-  //\r
-  // Find the pad FFS file\r
-  //\r
-  FvHeader         = (EFI_FIRMWARE_VOLUME_HEADER *)FileBuffer;\r
-  FvLength         = FvHeader->FvLength;\r
-  FileHeader       = (EFI_FFS_FILE_HEADER *)(FileBuffer + FvHeader->HeaderLength);\r
-  FileLength       = (*(UINT32 *)(FileHeader->Size)) & 0x00FFFFFF;\r
-  FileOccupiedSize = GETOCCUPIEDSIZE(FileLength, 8);\r
-  Offset           = (UINT32)FileHeader - (UINT32)FileBuffer;\r
-  \r
-  while (Offset < FvLength) {\r
-    TempGuid = (EFI_GUID *)&(FileHeader->Name);\r
-    FileLength = (*(UINT32 *)(FileHeader->Size)) & 0x00FFFFFF;\r
-    FileOccupiedSize = GETOCCUPIEDSIZE(FileLength, 8);\r
-    if ((CompareGuid (TempGuid, (EFI_GUID *)&DefaultFvPadFileNameGuid)) == 0) {\r
-      break;\r
-    }\r
-    FileHeader = (EFI_FFS_FILE_HEADER *)((UINT32)FileHeader + FileOccupiedSize);\r
-    Offset = (UINT32)FileHeader - (UINT32)FileBuffer;\r
-  }\r
-\r
-  if (Offset >= FvLength) {\r
-    Error (NULL, 0, 0, "No pad file found!", NULL);\r
-    free ((VOID *)FileBufferRaw);\r
-    return STATUS_ERROR;\r
-  }\r
-  //\r
-  // Find the position to place Ap reset vector, the offset\r
-  // between the position and the end of Fvrecovery.fv file\r
-  // should not exceed 128kB to prevent Ap reset vector from\r
-  // outside legacy E and F segment\r
-  //\r
-  FixPoint = (UINT8 *)(FileHeader + sizeof(EFI_FFS_FILE_HEADER));\r
-  TempResult = 0x1000 - ((UINT32)FixPoint & 0x0FFF);\r
-  FixPoint +=TempResult;\r
-  if (((UINT32)FixPoint - (UINT32)FileHeader + 5) > FileOccupiedSize) {\r
-    Error (NULL, 0, 0, "No appropriate space in pad file to add Ap reset vector!", NULL);\r
-    free ((VOID *)FileBufferRaw);\r
-    return STATUS_ERROR;  \r
-  }\r
-  while (((UINT32)FixPoint - (UINT32)FileHeader + 5) <= FileOccupiedSize) {\r
-    FixPoint += 0x1000;\r
-  }\r
-  FixPoint -= 0x1000;\r
-  if ((UINT32)FvHeader + FvLength - (UINT32)FixPoint > 0x20000) {\r
-    Error (NULL, 0, 0, "The position to place Ap reset vector is not in E and F segment!", NULL);\r
-    free ((VOID *)FileBufferRaw);\r
-    return STATUS_ERROR; \r
-  }    \r
-  //\r
-  // Fix up Ap reset vector and calculate the IPI vector\r
-  //\r
-  for (Index = 0; Index < 5; Index++) {\r
-    FixPoint[Index] = ApResetVector[Index];\r
-  } \r
-  TempResult = 0x0FFFFFFFF - ((UINT32)FvHeader + (UINT32)FvLength - 1 - (UINT32)FixPoint);\r
-  TempResult >>= 12;\r
-  IpiVector = TempResult & 0x0FF;\r
-  \r
-  \r
-  UpdatePadFileGuid (FvHeader, FileHeader, FileLength, TempGuid);\r
-\r
-  //\r
-  // Open the output Fvrecovery.fv file\r
-  //\r
-  if ((FpOut = fopen (argv[2], "w+b")) == NULL) {\r
-    Error (NULL, 0, 0, "Unable to open file", argv[2]);\r
-    free ((VOID *)FileBufferRaw);\r
-    return STATUS_ERROR;\r
-  }\r
-  //\r
-  // Write the output Fvrecovery.fv file\r
-  //\r
-  if ((fwrite (FileBuffer, 1, FvrecoveryFileSize, FpOut)) != FvrecoveryFileSize) {\r
-    Error (NULL, 0, 0, "Write output file error!", NULL);\r
-    free ((VOID *)FileBufferRaw);\r
-    return STATUS_ERROR;   \r
-  }\r
-  //\r
-  //\r
-  //\r
-  fseek (FpOut, -8, SEEK_END);\r
-  if ((fwrite (&IpiVector, 1, sizeof(UINT32), FpOut)) != sizeof(UINT32)) {\r
-    Error (NULL, 0, 0, "Write output file error!", NULL);\r
-    free ((VOID *)FileBufferRaw);\r
-    return STATUS_ERROR;\r
-  }  \r
-  //\r
-  // Close the output Fvrecovery.fv file\r
-  //\r
-  fclose (FpOut);\r
-  free ((VOID *)FileBufferRaw);\r
-  return STATUS_SUCCESS;\r
-}\r
-\r
diff --git a/Tools/CodeTools/TianoTools/SecApResetVectorFixup/SecApResetVectorFixup.h b/Tools/CodeTools/TianoTools/SecApResetVectorFixup/SecApResetVectorFixup.h
deleted file mode 100644 (file)
index 6d234e3..0000000
+++ /dev/null
@@ -1,104 +0,0 @@
-/*++\r
-\r
-Copyright (c)  1999-2006 Intel Corporation. All rights reserved\r
-This program and the accompanying materials are licensed and made available\r
-under the terms and conditions of the BSD License which accompanies this\r
-distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-\r
-Module Name:\r
-\r
-  SecApResetVectorFixup.h\r
-\r
-Abstract:\r
-\r
-  Definitions for the SecApResetVectorFixup utility.\r
-\r
---*/\r
-\r
-#ifndef _SEC_AP_RESET_VECTOR_FIXUP_H\r
-#define _SEC_AP_RESET_VECTOR_FIXUP_H\r
-\r
-#include <stdio.h>\r
-#include <stdlib.h>\r
-\r
-#include <Common/UefiBaseTypes.h>\r
-#include <Common/EfiImage.h>\r
-#include <Common/FirmwareVolumeImageFormat.h>\r
-#include <Common/FirmwareFileSystem.h>\r
-#include <Common/FirmwareVolumeHeader.h>\r
-\r
-#include "EfiUtilityMsgs.c"\r
-#include "CommonLib.h"\r
-\r
-\r
-//\r
-// Utility Name\r
-//\r
-#define UTILITY_NAME  "SecApResetVectorFixup"\r
-\r
-//\r
-// Utility version information\r
-//\r
-#define UTILITY_MAJOR_VERSION 0\r
-#define UTILITY_MINOR_VERSION 1\r
-#define UTILITY_DATE          __DATE__\r
-\r
-//\r
-// The maximum number of arguments accepted from the command line.\r
-//\r
-#define MAX_ARGS        3\r
-#define BUF_SIZE        (8 * 1024)\r
-\r
-#define GETOCCUPIEDSIZE(ActualSize, Alignment) \\r
-  (ActualSize) + (((Alignment) - ((ActualSize) & ((Alignment) - 1))) & ((Alignment) - 1))\r
-\r
-\r
-VOID\r
-PrintUtilityInfo (\r
-  VOID\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Displays the standard utility information to SDTOUT\r
-\r
-Arguments:\r
-\r
-  None\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-;\r
-\r
-VOID\r
-PrintUsage (\r
-  VOID\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Displays the utility usage syntax to STDOUT\r
-\r
-Arguments:\r
-\r
-  None\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-;\r
-\r
-\r
-#endif\r
diff --git a/Tools/CodeTools/TianoTools/SecApResetVectorFixup/build.xml b/Tools/CodeTools/TianoTools/SecApResetVectorFixup/build.xml
deleted file mode 100644 (file)
index f615b2a..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-<?xml version="1.0" ?>\r
-<!--\r
-Copyright (c) 2006, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
--->\r
-<project default="GenTool" basedir=".">\r
-<!--\r
-    EDK SecApResetVectorFixup Tool\r
-  Copyright (c) 2006, Intel Corporation\r
--->\r
-  <property name="ToolName" value="SecApResetVectorFixup"/>\r
-  <property name="FileSet" value="*.c"/>\r
-\r
-  <taskdef resource="cpptasks.tasks"/>\r
-  <typedef resource="cpptasks.types"/>\r
-  <taskdef resource="net/sf/antcontrib/antlib.xml"/>\r
-\r
-  <property name="LINK_OUTPUT_TYPE" value="static"/>\r
-  <property name="BUILD_DIR" value="${PACKAGE_DIR}/${ToolName}/tmp"/>\r
-\r
-  <target name="GenTool" depends="init, Tool">\r
-    <echo message="The EDK Tool: ${ToolName} build has completed"/>\r
-  </target>\r
-\r
-  <target name="init">\r
-    <echo message="Building the EDK Tool: ${ToolName}"/>\r
-    <mkdir dir="${BUILD_DIR}"/>\r
-  </target>\r
-\r
-  <target name="Tool" depends="init">\r
-    <cc name="${ToolChain}" objdir="${BUILD_DIR}" \r
-        outfile="${BIN_DIR}/${ToolName}"\r
-        outtype="executable"\r
-        optimize="speed" \r
-        debug="true">\r
-\r
-      <fileset dir="${basedir}/${ToolName}" \r
-        includes="${FileSet}" \r
-        defaultexcludes="TRUE" \r
-        excludes="*.xml *.inf"/>\r
-\r
-      <includepath path="${PACKAGE_DIR}/Include"/>\r
-      <includepath path="${PACKAGE_DIR}/Include/${HostArch}"/>\r
-      <includepath path="${PACKAGE_DIR}/Common"/>\r
-      <libset dir="${LIB_DIR}" libs="CommonTools"/>\r
-    </cc>\r
-  </target>\r
-\r
-  <target name="clean">\r
-    <echo message="Removing Intermediate Files Only"/>  \r
-    <delete>\r
-      <fileset dir="${BUILD_DIR}" includes="*.obj"/>\r
-    </delete>\r
-  </target>\r
-\r
-  <target name="cleanall">\r
-    <echo message="Removing Object Files and the Executable: ${ToolName}${ext_exe}"/>  \r
-    <delete failonerror="false" quiet="true" includeEmptyDirs="true">\r
-      <fileset dir="${BUILD_DIR}"/>\r
-      <fileset file="${BIN_DIR}/${ToolName}${ext_exe}"/>\r
-    </delete>\r
-  </target>\r
-\r
-</project>\r
diff --git a/Tools/CodeTools/TianoTools/SecFixup/SecFixup.c b/Tools/CodeTools/TianoTools/SecFixup/SecFixup.c
deleted file mode 100644 (file)
index c2d46a1..0000000
+++ /dev/null
@@ -1,362 +0,0 @@
-/*++\r
-\r
-Copyright (c)  1999-2006 Intel Corporation. All rights reserved\r
-This program and the accompanying materials are licensed and made available \r
-under the terms and conditions of the BSD License which accompanies this \r
-distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-\r
-Module Name:\r
-\r
-    SecFixup.c\r
-\r
-Abstract:\r
-\r
-    This utility is part of build process for IA32 SEC FFS file.\r
-    \r
-    It fixup the reset vector data. The reset vector data binary file\r
-    will be wrapped as a RAW section and be located immediately after\r
-    the PE/TE section.\r
-\r
-    The SEC EXE file can be either PE or TE file.\r
-    \r
---*/\r
-\r
-#include <stdio.h>\r
-\r
-#include <Common/UefiBaseTypes.h>\r
-#include <Common/EfiImage.h>\r
-#include <Common/FirmwareVolumeImageFormat.h>\r
-\r
-#include "EfiUtilityMsgs.c"\r
-#include "SecFixup.h"\r
-\r
-VOID\r
-PrintUtilityInfo (\r
-  VOID\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Displays the standard utility information to SDTOUT\r
-\r
-Arguments:\r
-\r
-  None\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-{\r
-  printf (\r
-    "%s - Tiano IA32 SEC Fixup Utility."" Version %i.%i\n\n",\r
-    UTILITY_NAME,\r
-    UTILITY_MAJOR_VERSION,\r
-    UTILITY_MINOR_VERSION\r
-    );\r
-}\r
-\r
-VOID\r
-PrintUsage (\r
-  VOID\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Displays the utility usage syntax to STDOUT\r
-\r
-Arguments:\r
-\r
-  None\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-{\r
-  printf ("Usage: %s SecExeFile ResetVectorDataFile OutputFile\n", UTILITY_NAME);\r
-  printf ("  Where:\n");\r
-  printf ("\tSecExeFile           - Name of the IA32 SEC EXE file.\n");\r
-  printf ("\tResetVectorDataFile  - Name of the reset vector data binary file.\n");\r
-  printf ("\tOutputFileName       - Name of the output file.\n\n");\r
-}\r
-\r
-STATUS\r
-main (\r
-  IN INTN   argc,\r
-  IN CHAR8  **argv\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Main function.\r
-\r
-Arguments:\r
-\r
-  argc - Number of command line parameters.\r
-  argv - Array of pointers to parameter strings.\r
-\r
-Returns:\r
-  STATUS_SUCCESS - Utility exits successfully.\r
-  STATUS_ERROR   - Some error occurred during execution.\r
-\r
---*/\r
-{\r
-  FILE    *FpIn;\r
-\r
-  FILE    *FpOut;\r
-  UINT32  AddressOfEntryPoint;\r
-  INT32   DestRel;\r
-  STATUS  Status;\r
-  UINT32  SecFileSize;\r
-\r
-  SetUtilityName (UTILITY_NAME);\r
-\r
-  //\r
-  // Display utility information\r
-  //\r
-  PrintUtilityInfo ();\r
-\r
-  //\r
-  // Verify the correct number of arguments\r
-  //\r
-  if (argc != MAX_ARGS) {\r
-    Error (NULL, 0, 0, "invalid number of input parameters specified", NULL);\r
-    PrintUsage ();\r
-    return STATUS_ERROR;\r
-  }\r
-  //\r
-  // Open the SEC exe file\r
-  //\r
-  if ((FpIn = fopen (argv[1], "rb")) == NULL) {\r
-    Error (NULL, 0, 0, "Unable to open file", argv[1]);\r
-    return STATUS_ERROR;\r
-  }\r
-  //\r
-  // Get the entry point of the EXE file\r
-  //\r
-  Status = GetEntryPoint (FpIn, &AddressOfEntryPoint);\r
-  if (Status != STATUS_SUCCESS) {\r
-    fclose (FpIn);\r
-    return STATUS_ERROR;\r
-  }\r
-  //\r
-  // Get the SEC file size\r
-  //\r
-  fseek (FpIn, 0, SEEK_END);\r
-  SecFileSize = ftell (FpIn);\r
-\r
-  //\r
-  // Close the SEC file\r
-  //\r
-  fclose (FpIn);\r
-\r
-  //\r
-  // Open the reset vector data file\r
-  //\r
-  if ((FpIn = fopen (argv[2], "rb")) == NULL) {\r
-    Error (NULL, 0, 0, "Unable to open file", argv[2]);\r
-    return STATUS_ERROR;\r
-  }\r
-  //\r
-  // Open the output file\r
-  //\r
-  if ((FpOut = fopen (argv[3], "w+b")) == NULL) {\r
-    Error (NULL, 0, 0, "Unable to open file", argv[3]);\r
-    fclose (FpIn);\r
-    return STATUS_ERROR;\r
-  }\r
-  //\r
-  // Copy the input file to the output file\r
-  //\r
-  if (CopyFile (FpIn, FpOut) != STATUS_SUCCESS) {\r
-    fclose (FpIn);\r
-    fclose (FpOut);\r
-    return STATUS_ERROR;\r
-  }\r
-  //\r
-  // Close the reset vector data file\r
-  //\r
-  fclose (FpIn);\r
-\r
-  //\r
-  // Fix the destination relative in the jmp instruction\r
-  // in the reset vector data structure\r
-  //\r
-  fseek (FpOut, -DEST_REL_OFFSET, SEEK_END);\r
-  DestRel = AddressOfEntryPoint - (SecFileSize + sizeof (EFI_COMMON_SECTION_HEADER) + (UINT32) (ftell (FpOut)) + 2);\r
-  if (DestRel <= -65536) {\r
-    Error (NULL, 0, 0, "The SEC EXE file size is too big", NULL);\r
-    fclose (FpOut);\r
-    return STATUS_ERROR;\r
-  }\r
-\r
-  if (fwrite (&DestRel, sizeof (UINT16), 1, FpOut) != 1) {\r
-    Error (NULL, 0, 0, "Failed to write to the output file", NULL);\r
-    fclose (FpOut);\r
-    return STATUS_ERROR;\r
-  }\r
-  //\r
-  // Close the output file\r
-  //\r
-  fclose (FpOut);\r
-\r
-  return STATUS_SUCCESS;\r
-}\r
-\r
-STATUS\r
-GetEntryPoint (\r
-  IN  FILE   *ExeFile,\r
-  OUT UINT32 *EntryPoint\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Get the address of the entry point of a PE/TE file.\r
-\r
-Arguments:\r
-\r
-  PeFile     - File pointer to the specified PE/TE file.\r
-  EntryPoint - Buffer for the address of the entry point to be returned.\r
-\r
-Returns:\r
-  STATUS_SUCCESS - Function completed successfully.\r
-  STATUS_ERROR   - Error occured.\r
-\r
---*/\r
-// GC_TODO:    ExeFile - add argument and description to function comment\r
-{\r
-  EFI_IMAGE_DOS_HEADER    DosHeader;\r
-  EFI_IMAGE_NT_HEADERS32  NtHeader;\r
-  EFI_TE_IMAGE_HEADER     TeHeader;\r
-\r
-  //\r
-  // Check if it is a TE file\r
-  //\r
-  fseek (ExeFile, 0, SEEK_SET);\r
-  //\r
-  // Attempt to read the TE header\r
-  //\r
-  if (fread (&TeHeader, sizeof (TeHeader), 1, ExeFile) == 1) {\r
-    if (TeHeader.Signature == EFI_TE_IMAGE_HEADER_SIGNATURE) {\r
-      if (TeHeader.Machine != EFI_IMAGE_MACHINE_IA32) {\r
-        Error (NULL, 0, 0, "The SEC file is PE but is not PE32 for IA32", NULL);\r
-        return STATUS_ERROR;\r
-      }\r
-\r
-      *EntryPoint = TeHeader.AddressOfEntryPoint + sizeof (EFI_TE_IMAGE_HEADER) - TeHeader.StrippedSize;\r
-      return STATUS_SUCCESS;\r
-    }\r
-  }\r
-  //\r
-  // Check if it is a PE file\r
-  //\r
-  fseek (ExeFile, 0, SEEK_SET);\r
-  //\r
-  // Attempt to read the DOS header\r
-  //\r
-  if (fread (&DosHeader, sizeof (DosHeader), 1, ExeFile) != 1) {\r
-    goto InvalidFile;\r
-  }\r
-  //\r
-  // Check the magic number\r
-  //\r
-  if (DosHeader.e_magic != EFI_IMAGE_DOS_SIGNATURE) {\r
-    goto InvalidFile;\r
-  }\r
-  //\r
-  // Position into the file and read the NT PE header\r
-  //\r
-  fseek (ExeFile, (long) DosHeader.e_lfanew, SEEK_SET);\r
-  if (fread (&NtHeader, sizeof (NtHeader), 1, ExeFile) != 1) {\r
-    goto InvalidFile;\r
-  }\r
-  //\r
-  // Check the PE signature in the header\r
-  //\r
-  if (NtHeader.Signature != EFI_IMAGE_NT_SIGNATURE) {\r
-    goto InvalidFile;\r
-  }\r
-  //\r
-  // Make sure the PE file is PE32 for IA32\r
-  //\r
-  if (NtHeader.FileHeader.Machine != EFI_IMAGE_MACHINE_IA32 ||\r
-      NtHeader.OptionalHeader.Magic != EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC\r
-      ) {\r
-    Error (NULL, 0, 0, "The SEC file is PE but is not PE32 for IA32", NULL);\r
-    return STATUS_ERROR;\r
-  }\r
-  //\r
-  // Get the entry point from the optional header\r
-  //\r
-  *EntryPoint = NtHeader.OptionalHeader.AddressOfEntryPoint;\r
-  return STATUS_SUCCESS;\r
-\r
-InvalidFile:\r
-  Error (NULL, 0, 0, "The SEC file is neither PE nor TE file", NULL);\r
-  return STATUS_ERROR;\r
-}\r
-\r
-STATUS\r
-CopyFile (\r
-  FILE    *FpIn,\r
-  FILE    *FpOut\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Copy file.\r
-\r
-Arguments:\r
-\r
-  FpIn  - File pointer to the source file.\r
-  FpOut - File pointer to the destination file.\r
-\r
-Returns:\r
-  STATUS_SUCCESS - Function completed successfully.\r
-  STATUS_ERROR   - Error occured.\r
-\r
---*/\r
-{\r
-  INTN  FileSize;\r
-\r
-  INTN  Offset;\r
-\r
-  INTN  Length;\r
-  UINT8 Buffer[BUF_SIZE];\r
-\r
-  fseek (FpIn, 0, SEEK_END);\r
-  FileSize = ftell (FpIn);\r
-\r
-  fseek (FpIn, 0, SEEK_SET);\r
-  fseek (FpOut, 0, SEEK_SET);\r
-\r
-  Offset = 0;\r
-  while (Offset < FileSize) {\r
-    Length = sizeof (Buffer);\r
-    if (FileSize - Offset < Length) {\r
-      Length = FileSize - Offset;\r
-    }\r
-\r
-    if (fread (Buffer, Length, 1, FpIn) != 1 || fwrite (Buffer, Length, 1, FpOut) != 1) {\r
-      Error (NULL, 0, 0, "Copy file error", NULL);\r
-      return STATUS_ERROR;\r
-    }\r
-\r
-    Offset += Length;\r
-  }\r
-\r
-  return STATUS_SUCCESS;\r
-}\r
diff --git a/Tools/CodeTools/TianoTools/SecFixup/SecFixup.h b/Tools/CodeTools/TianoTools/SecFixup/SecFixup.h
deleted file mode 100644 (file)
index 3694b15..0000000
+++ /dev/null
@@ -1,146 +0,0 @@
-/*++\r
-\r
-Copyright (c)  1999-2006 Intel Corporation. All rights reserved\r
-This program and the accompanying materials are licensed and made available \r
-under the terms and conditions of the BSD License which accompanies this \r
-distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-\r
-Module Name:\r
-  \r
-  SecFixup.h\r
-\r
-Abstract:\r
-\r
-  Definitions for the SecFixup utility.\r
-\r
---*/\r
-\r
-#ifndef _SEC_FIXUP_H\r
-#define _SEC_FIXUP_H\r
-\r
-//\r
-// Utility Name\r
-//\r
-#define UTILITY_NAME  "SecFixup"\r
-\r
-//\r
-// Utility version information\r
-//\r
-#define UTILITY_MAJOR_VERSION 0\r
-#define UTILITY_MINOR_VERSION 1\r
-#define UTILITY_DATE          __DATE__\r
-\r
-//\r
-// The maximum number of arguments accepted from the command line.\r
-//\r
-#define MAX_ARGS        4\r
-\r
-#define DEST_REL_OFFSET 13\r
-#define BUF_SIZE        (8 * 1024)\r
-\r
-//\r
-// The function that displays general utility information\r
-//\r
-VOID\r
-PrintUtilityInfo (\r
-  VOID\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  None\r
-\r
-Returns:\r
-\r
-  GC_TODO: add return values\r
-\r
---*/\r
-;\r
-\r
-//\r
-// The function that displays the utility usage message.\r
-//\r
-VOID\r
-PrintUsage (\r
-  VOID\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  None\r
-\r
-Returns:\r
-\r
-  GC_TODO: add return values\r
-\r
---*/\r
-;\r
-\r
-//\r
-// The function that gets the entry point of a PE/TE file.\r
-//\r
-STATUS\r
-GetEntryPoint (\r
-  IN  FILE   *ExeFile,\r
-  OUT UINT32 *EntryPoint\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  ExeFile     - GC_TODO: add argument description\r
-  EntryPoint  - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
-  GC_TODO: add return values\r
-\r
---*/\r
-;\r
-\r
-//\r
-// The function that copies a file.\r
-//\r
-STATUS\r
-CopyFile (\r
-  FILE    *FpIn,\r
-  FILE    *FpOut\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  FpIn  - GC_TODO: add argument description\r
-  FpOut - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
-  GC_TODO: add return values\r
-\r
---*/\r
-;\r
-\r
-#endif\r
diff --git a/Tools/CodeTools/TianoTools/SecFixup/build.xml b/Tools/CodeTools/TianoTools/SecFixup/build.xml
deleted file mode 100644 (file)
index ebc408b..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-<?xml version="1.0" ?>\r
-<!--\r
-Copyright (c) 2006, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
--->\r
-<project default="GenTool" basedir=".">\r
-<!--\r
-    EDK SecFixup Tool\r
-  Copyright (c) 2006, Intel Corporation\r
--->\r
-  <property name="ToolName" value="SecFixup"/>\r
-  <property name="FileSet" value="*.c"/>\r
-\r
-  <taskdef resource="cpptasks.tasks"/>\r
-  <typedef resource="cpptasks.types"/>\r
-  <taskdef resource="net/sf/antcontrib/antlib.xml"/>\r
-\r
-  <property name="LINK_OUTPUT_TYPE" value="static"/>\r
-  <property name="BUILD_DIR" value="${PACKAGE_DIR}/${ToolName}/tmp"/>\r
-\r
-  <target name="GenTool" depends="init, Tool">\r
-    <echo message="The EDK Tool: ${ToolName} build has completed!"/>\r
-  </target>\r
-\r
-  <target name="init">\r
-    <echo message="Building the EDK Tool: ${ToolName}"/>\r
-    <mkdir dir="${BUILD_DIR}"/>\r
-  </target>\r
-\r
-  <target name="Tool" depends="init">\r
-    <cc name="${ToolChain}" objdir="${BUILD_DIR}" \r
-        outfile="${BIN_DIR}/${ToolName}"\r
-        outtype="executable"\r
-        optimize="speed" \r
-        debug="true">\r
-\r
-      <fileset dir="${basedir}/${ToolName}" \r
-        includes="${FileSet}" \r
-        defaultexcludes="TRUE" \r
-        excludes="*.xml *.inf"/>\r
-\r
-      <includepath path="${PACKAGE_DIR}/Include"/>\r
-      <includepath path="${PACKAGE_DIR}/Include/${HostArch}"/>\r
-      <includepath path="${PACKAGE_DIR}/Common"/>\r
-      <libset dir="${LIB_DIR}" libs="CommonTools"/>\r
-    </cc>\r
-  </target>\r
-\r
-  <target name="clean">\r
-    <echo message="Removing Intermediate Files Only"/>  \r
-    <delete>\r
-      <fileset dir="${BUILD_DIR}" includes="*.obj"/>\r
-    </delete>\r
-  </target>\r
-\r
-  <target name="cleanall">\r
-    <echo message="Removing Object Files and the Executable: ${ToolName}${ext_exe}"/>  \r
-    <delete failonerror="false" quiet="true" includeEmptyDirs="true">\r
-      <fileset dir="${BUILD_DIR}"/>\r
-      <fileset file="${BIN_DIR}/${ToolName}${ext_exe}"/>\r
-    </delete>\r
-  </target>\r
-\r
-</project>\r
diff --git a/Tools/CodeTools/TianoTools/SetStamp/SetStamp.c b/Tools/CodeTools/TianoTools/SetStamp/SetStamp.c
deleted file mode 100644 (file)
index 539aced..0000000
+++ /dev/null
@@ -1,475 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2004, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-Module Name:\r
-  SetStamp.c\r
-\r
-Abstract:\r
-  Set Date/Time Stamp of Portable Executable (PE) format file\r
-\r
---*/\r
-\r
-#include <stdio.h>\r
-#include <string.h>\r
-#include <time.h>\r
-\r
-#define LINE_MAXLEN 80\r
-\r
-void\r
-PrintUsage (\r
-  void\r
-  )\r
-/*++\r
-Routine Description:\r
-  print usage of setstamp command\r
-\r
-Arguments:\r
-  void\r
-\r
-Returns:\r
-  None\r
---*/\r
-{\r
-  //\r
-  // print usage of command\r
-  //\r
-  printf ("Usage: SetStamp <PE-File> <TIME-File>\n");\r
-}\r
-\r
-int\r
-GetDateTime (\r
-  FILE      *fp,\r
-  time_t    *ltime\r
-  )\r
-/*++\r
-Routine Description:\r
-  Read the date and time from TIME file. If the date/time string is\r
-"NOW NOW", write the current date and time to TIME file and set it to\r
-ltime. Else, set the date and time of TIME file to ltime.\r
-\r
-Arguments:\r
-  fp              - The pointer of TIME file\r
-  ltime           - Date and time\r
-\r
-Returns:\r
-  =  0            - Success\r
-  = -1            - Failed\r
---*/\r
-{\r
-  char      buffer[LINE_MAXLEN];\r
-  struct tm stime;\r
-  struct tm *now;\r
-\r
-  if (fgets (buffer, LINE_MAXLEN, fp) == NULL) {\r
-    printf ("Error: Cannot read TIME file.\n");\r
-    return -1;\r
-  }\r
-  //\r
-  // compare the value with "NOW NOW", write TIME file if equal\r
-  //\r
-  if (strncmp (buffer, "NOW NOW", 7) == 0) {\r
-    //\r
-    // get system current time and date\r
-    //\r
-    time (ltime);\r
-\r
-    now = localtime (ltime);\r
-    if (now == NULL) {\r
-      printf ("Error: Cannot get local time.\n");\r
-      return -1;\r
-    }\r
-\r
-    if (strftime (buffer, LINE_MAXLEN, "%Y-%m-%d %H:%M:%S", now) == 0) {\r
-      printf ("Error: Cannot format time string.\n");\r
-      return -1;\r
-    }\r
-    //\r
-    // write TIME file\r
-    //\r
-    if (fseek (fp, 0, SEEK_SET) != 0) {\r
-      printf ("Error: Cannot move location of TIME file.\n");\r
-      return -1;\r
-    }\r
-\r
-    if (fputs (buffer, fp) == EOF) {\r
-      printf ("Error: Cannot write time string to TIME file.\n");\r
-      return -1;\r
-    }\r
-    //\r
-    // ltime has been set as current time and date, return\r
-    //\r
-    return 0;\r
-  }\r
-  //\r
-  // get the date and time from buffer\r
-  //\r
-  if (6 != sscanf (\r
-            buffer,\r
-            "%d-%d-%d %d:%d:%d",\r
-            &stime.tm_year,\r
-            &stime.tm_mon,\r
-            &stime.tm_mday,\r
-            &stime.tm_hour,\r
-            &stime.tm_min,\r
-            &stime.tm_sec\r
-            )) {\r
-    printf ("Error: Invaild date or time!\n");\r
-    return -1;\r
-  }\r
-  //\r
-  // in struct, Month (0 - 11; Jan = 0). So decrease 1 from it\r
-  //\r
-  stime.tm_mon -= 1;\r
-\r
-  //\r
-  // in struct, Year (current year minus 1900)\r
-  // and only the dates can be handled from Jan 1, 1970 to Jan 18, 2038\r
-  //\r
-  //\r
-  // convert 0 -> 100 (2000), 1 -> 101 (2001), ..., 38 -> 138 (2038)\r
-  //\r
-  if (stime.tm_year <= 38) {\r
-    stime.tm_year += 100;\r
-  }\r
-  //\r
-  // convert 1970 -> 70, 2000 -> 100, ...\r
-  //\r
-  else if (stime.tm_year >= 1970) {\r
-    stime.tm_year -= 1900;\r
-  }\r
-  //\r
-  // convert the date and time to time_t format\r
-  //\r
-  *ltime = mktime (&stime);\r
-  if (*ltime == (time_t) - 1) {\r
-    printf ("Error: Invalid date or time!\n");\r
-    return -1;\r
-  }\r
-\r
-  return 0;\r
-}\r
-\r
-int\r
-ReadFromFile (\r
-  FILE      *fp,\r
-  long      offset,\r
-  void      *buffer,\r
-  int       size\r
-  )\r
-/*++\r
-Routine Description:\r
-  read data from a specified location of file\r
-\r
-Arguments:\r
-  fp              - file pointer\r
-  offset          - number of bytes from beginning of file\r
-  buffer          - buffer used to store data\r
-  size            - size of buffer\r
-\r
-Returns:\r
-  =  0            - Success\r
-  = -1            - Failed\r
---*/\r
-{\r
-  //\r
-  // set file pointer to the specified location of file\r
-  //\r
-  if (fseek (fp, offset, SEEK_SET) != 0) {\r
-    printf ("Error: Cannot move the current location of the file.\n");\r
-    return -1;\r
-  }\r
-  //\r
-  // read data from the file\r
-  //\r
-  if (fread (buffer, size, 1, fp) != 1) {\r
-    printf ("Error: Cannot read data from the file.\n");\r
-    return -1;\r
-  }\r
-\r
-  return 0;\r
-}\r
-\r
-int\r
-WriteToFile (\r
-  FILE      *fp,\r
-  long      offset,\r
-  void      *buffer,\r
-  int       size\r
-  )\r
-/*++\r
-Routine Description:\r
-  write data to a specified location of file\r
-\r
-Arguments:\r
-  fp              - file pointer\r
-  offset          - number of bytes from beginning of file\r
-  buffer          - buffer used to store data\r
-  size            - size of buffer\r
-\r
-Returns:\r
-  =  0            - Success\r
-  = -1            - Failed\r
---*/\r
-{\r
-  //\r
-  // set file pointer to the specified location of file\r
-  //\r
-  if (fseek (fp, offset, SEEK_SET) != 0) {\r
-    printf ("Error: Cannot move the current location of the file.\n");\r
-    return -1;\r
-  }\r
-  //\r
-  // write data to the file\r
-  //\r
-  if (fwrite (buffer, size, 1, fp) != 1) {\r
-    perror ("Error: Cannot write data to the file.\n");\r
-    return -1;\r
-  }\r
-\r
-  return 0;\r
-}\r
-\r
-int\r
-SetStamp (\r
-  FILE      *fp,\r
-  time_t    ltime\r
-  )\r
-/*++\r
-Routine Description:\r
-  set Date/Time Stamp of the file\r
-\r
-Arguments:\r
-  fp              - file pointer\r
-  ltime           - time and date\r
-\r
-Returns:\r
-  =  0            - Success\r
-  = -1            - Failed\r
---*/\r
-{\r
-  unsigned char header[4];\r
-  unsigned long offset;\r
-  unsigned long NumberOfRvaAndSizes;\r
-  unsigned int  nvalue;\r
-  unsigned long lvalue;\r
-\r
-  //\r
-  // read the header of file\r
-  //\r
-  if (ReadFromFile (fp, 0, header, 2) != 0) {\r
-    return -1;\r
-  }\r
-  //\r
-  // "MZ" -- the header of image file (PE)\r
-  //\r
-  if (strncmp ((char *) header, "MZ", 2) != 0) {\r
-    printf ("Error: Invalid Image file.\n");\r
-    return -1;\r
-  }\r
-  //\r
-  // At location 0x3C, the stub has the file offset to the\r
-  // PE signature.\r
-  //\r
-  if (ReadFromFile (fp, 0x3C, &offset, 4) != 0) {\r
-    return -1;\r
-  }\r
-  //\r
-  // read the header of optional\r
-  //\r
-  if (ReadFromFile (fp, offset, header, 4) != 0) {\r
-    return -1;\r
-  }\r
-  //\r
-  // "PE\0\0" -- the signature of optional header\r
-  //\r
-  if (strncmp ((char *) header, "PE\0\0", 4) != 0) {\r
-    printf ("Error: Invalid PE format file.\n");\r
-    return -1;\r
-  }\r
-  //\r
-  // Add 8 to skip PE signature (4-byte), Machine (2-byte) and\r
-  // NumberOfSection (2-byte)\r
-  //\r
-  offset += 8;\r
-\r
-  if (WriteToFile (fp, offset, &ltime, 4) != 0) {\r
-    return -1;\r
-  }\r
-  //\r
-  // Add 16 to skip COFF file header, and get to optional header.\r
-  //\r
-  offset += 16;\r
-\r
-  //\r
-  // Check the magic field, 0x10B for PE32 and 0x20B for PE32+\r
-  //\r
-  if (ReadFromFile (fp, offset, &nvalue, 2) != 0) {\r
-    return -1;\r
-  }\r
-  //\r
-  // If this is PE32 image file, offset of NumberOfRvaAndSizes is 92.\r
-  // Else it is 108.\r
-  //\r
-  switch (nvalue & 0xFFFF) {\r
-  case 0x10B:\r
-    offset += 92;\r
-    break;\r
-\r
-  case 0x20B:\r
-    offset += 108;\r
-    break;\r
-\r
-  default:\r
-    printf ("Error: Sorry! The Magic value is unknown.\n");\r
-    return -1;\r
-  }\r
-  //\r
-  // get the value of NumberOfRvaAndSizes\r
-  //\r
-  if (ReadFromFile (fp, offset, &NumberOfRvaAndSizes, 4) != 0) {\r
-    return -1;\r
-  }\r
-  //\r
-  // Date/time stamp exists in Export Table, Import Table, Resource Table,\r
-  // Debug Table and Delay Import Table. And in Import Table and Delay Import\r
-  // Table, it will be set when bound. So here only set the date/time stamp\r
-  // of Export Table, Resource Table and Debug Table.\r
-  //\r
-  //\r
-  // change date/time stamp of Export Table, the offset of Export Table\r
-  // is 4 + 0 * 8 = 4. And the offset of stamp is 4.\r
-  //\r
-  if (NumberOfRvaAndSizes >= 1) {\r
-    if (ReadFromFile (fp, offset + 4, &lvalue, 4) != 0) {\r
-      return -1;\r
-    }\r
-\r
-    if (lvalue != 0) {\r
-      if (WriteToFile (fp, lvalue + 4, &ltime, 4) != 0) {\r
-        return -1;\r
-      }\r
-    }\r
-  }\r
-  //\r
-  // change date/time stamp of Resource Table, the offset of Resource Table\r
-  // is 4 + 2 * 8 = 20. And the offset of stamp is 4.\r
-  //\r
-  if (NumberOfRvaAndSizes >= 3) {\r
-    if (ReadFromFile (fp, offset + 20, &lvalue, 4) != 0) {\r
-      return -1;\r
-    }\r
-\r
-    if (lvalue != 0) {\r
-      if (WriteToFile (fp, lvalue + 4, &ltime, 4) != 0) {\r
-        return -1;\r
-      }\r
-    }\r
-  }\r
-  //\r
-  // change date/time stamp of Debug Table, offset of Debug Table\r
-  // is 4 + 6 * 8 = 52. And the offset of stamp is 4.\r
-  //\r
-  if (NumberOfRvaAndSizes >= 7) {\r
-    if (ReadFromFile (fp, offset + 52, &lvalue, 4) != 0) {\r
-      return -1;\r
-    }\r
-\r
-    if (lvalue != 0) {\r
-      if (WriteToFile (fp, lvalue + 4, &ltime, 4) != 0) {\r
-        return -1;\r
-      }\r
-    }\r
-    //\r
-    // change the date/time stamp of Debug Data\r
-    //\r
-    if (ReadFromFile (fp, lvalue + 24, &lvalue, 4) != 0) {\r
-      return -1;\r
-    }\r
-    //\r
-    // get the signature of debug data\r
-    //\r
-    if (ReadFromFile (fp, lvalue, header, 2) != 0) {\r
-      return -1;\r
-    }\r
-    //\r
-    // "NB" - the signature of Debug Data\r
-    // Need Review: (From Spec. is "NB05", From .dll is "NB10")\r
-    //\r
-    if (strncmp ((char *) header, "NB", 2) == 0) {\r
-      if (WriteToFile (fp, lvalue + 8, &ltime, 4) != 0) {\r
-        return -1;\r
-      }\r
-    }\r
-  }\r
-\r
-  return 0;\r
-}\r
-\r
-int\r
-main (\r
-  int       argc,\r
-  char      *argv[]\r
-  )\r
-{\r
-  FILE    *fp;\r
-  time_t  ltime;\r
-\r
-  //\r
-  // check the number of parameters\r
-  //\r
-  if (argc != 3) {\r
-    PrintUsage ();\r
-    return -1;\r
-  }\r
-  //\r
-  // open the TIME file, if not exists, return\r
-  //\r
-  fp = fopen (argv[2], "r+");\r
-  if (fp == NULL) {\r
-    return 0;\r
-  }\r
-  //\r
-  // get time and date from file\r
-  //\r
-  if (GetDateTime (fp, &ltime) != 0) {\r
-    fclose (fp);\r
-    return -1;\r
-  }\r
-  //\r
-  // close the TIME file\r
-  //\r
-  fclose (fp);\r
-\r
-  //\r
-  // open the PE file\r
-  //\r
-  fp = fopen (argv[1], "r+b");\r
-  if (fp == NULL) {\r
-    printf ("Error: Cannot open the PE file!\n");\r
-    return -1;\r
-  }\r
-  //\r
-  // set time and date stamp to the PE file\r
-  //\r
-  if (SetStamp (fp, ltime) != 0) {\r
-    fclose (fp);\r
-    return -1;\r
-  }\r
-\r
-  printf ("Set Date/Time Stamp to %s", ctime (&ltime));\r
-\r
-  //\r
-  // close the PE file\r
-  //\r
-  fclose (fp);\r
-\r
-  return 0;\r
-}\r
diff --git a/Tools/CodeTools/TianoTools/SetStamp/build.xml b/Tools/CodeTools/TianoTools/SetStamp/build.xml
deleted file mode 100644 (file)
index 9425797..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-<?xml version="1.0" ?>\r
-<!--\r
-Copyright (c) 2006, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
--->\r
-<project default="GenTool" basedir=".">\r
-<!--\r
-    EDK SetStamp Tool\r
-  Copyright (c) 2006, Intel Corporation\r
--->\r
-  <property name="ToolName" value="SetStamp"/>\r
-  <property name="FileSet" value="SetStamp.c"/>\r
-\r
-  <taskdef resource="cpptasks.tasks"/>\r
-  <typedef resource="cpptasks.types"/>\r
-  <taskdef resource="net/sf/antcontrib/antlib.xml"/>\r
-\r
-  <property name="LINK_OUTPUT_TYPE" value="static"/>\r
-  <property name="BUILD_DIR" value="${PACKAGE_DIR}/${ToolName}/tmp"/>\r
-\r
-  <target name="GenTool" depends="init, Tool">\r
-    <echo message="The EDK Tool: ${ToolName} build has completed!"/>\r
-  </target>\r
-\r
-  <target name="init">\r
-    <echo message="Building the EDK Tool: ${ToolName}"/>\r
-    <mkdir dir="${BUILD_DIR}"/>\r
-  </target>\r
-\r
-  <target name="Tool" depends="init">\r
-    <cc name="${ToolChain}" objdir="${BUILD_DIR}" \r
-        outfile="${BIN_DIR}/${ToolName}"\r
-        outtype="executable"\r
-        debug="true"\r
-        optimize="speed">\r
-\r
-      <fileset dir="${basedir}/${ToolName}" \r
-        includes="${FileSet}" \r
-        defaultexcludes="TRUE" \r
-        excludes="*.xml *.inf"/>\r
-\r
-      <includepath path="${PACKAGE_DIR}/Include"/>\r
-      <includepath path="${PACKAGE_DIR}/Include/Ia32"/>\r
-      <includepath path="${PACKAGE_DIR}/Common"/>\r
-\r
-    </cc>\r
-  </target>\r
-\r
-  <target name="clean">\r
-    <echo message="Removing Intermediate Files Only"/>  \r
-    <delete>\r
-      <fileset dir="${BUILD_DIR}" includes="*.obj"/>\r
-    </delete>\r
-  </target>\r
-\r
-  <target name="cleanall">\r
-    <echo message="Removing Object Files and the Executable: ${ToolName}${ext_exe}"/>  \r
-    <delete failonerror="false" quiet="true" includeEmptyDirs="true">\r
-      <fileset dir="${BUILD_DIR}"/>\r
-      <fileset file="${BIN_DIR}/${ToolName}${ext_exe}"/>\r
-    </delete>\r
-  </target>\r
-\r
-</project>\r
diff --git a/Tools/CodeTools/TianoTools/SplitFile/SplitFile.c b/Tools/CodeTools/TianoTools/SplitFile/SplitFile.c
deleted file mode 100644 (file)
index a1bda7d..0000000
+++ /dev/null
@@ -1,131 +0,0 @@
-/*\r
-\r
-Copyright (c)  1999-2006 Intel Corporation. All rights reserved\r
-This program and the accompanying materials are licensed and made available \r
-under the terms and conditions of the BSD License which accompanies this \r
-distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-*/\r
-\r
-// GC_TODO: fix comment to start with /*++\r
-#include "stdio.h"\r
-#include "string.h"\r
-#include "stdlib.h"\r
-\r
-void\r
-helpmsg (\r
-  void\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
-\r
-Returns:\r
-\r
-  GC_TODO: add return values\r
-\r
---*/\r
-{\r
-  printf (\r
-    "SplitFile Filename Offset\n""   Filename = Input file to split\n""   Offset = offset at which to split file\n"\r
-    "\n\n""SplitFile will break a file in two pieces at the requested offset\n"\r
-    "  outputting Filename1 and Filename2\n"\r
-    );\r
-}\r
-\r
-int\r
-main (\r
-  int argc,\r
-  char*argv[]\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  argc  - GC_TODO: add argument description\r
-  ]     - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
-  GC_TODO: add return values\r
-\r
---*/\r
-{\r
-  FILE          *In;\r
-\r
-  FILE          *Out1;\r
-\r
-  FILE          *Out2;\r
-  char          OutName1[512];\r
-  char          OutName2[512];\r
-  unsigned long Index;\r
-  unsigned long splitpoint;\r
-  char          CharC;\r
-\r
-  if (argc != 3) {\r
-    helpmsg ();\r
-    return -1;\r
-  }\r
-\r
-  In = fopen (argv[1], "rb");\r
-  if (In == NULL) {\r
-    printf ("Unable to open file \"%s\"\n", argv[1]);\r
-    return -1;\r
-  }\r
-\r
-  strncpy (OutName1, argv[1], 510);\r
-  strncpy (OutName2, argv[1], 510);\r
-  strcat (OutName1, "1");\r
-  strcat (OutName2, "2");\r
-\r
-  Out1 = fopen (OutName1, "wb");\r
-  if (Out1 == NULL) {\r
-    printf ("Unable to open file \"%s\"\n", OutName1);\r
-    return -1;\r
-  }\r
-\r
-  Out2 = fopen (OutName2, "wb");\r
-  if (Out2 == NULL) {\r
-    printf ("Unable to open file \"%s\"\n", OutName2);\r
-    return -1;\r
-  }\r
-\r
-  splitpoint = atoi (argv[2]);\r
-\r
-  for (Index = 0; Index < splitpoint; Index++) {\r
-    CharC = (char) fgetc (In);\r
-    if (feof (In)) {\r
-      break;\r
-    }\r
-\r
-    fputc (CharC, Out1);\r
-  }\r
-\r
-  for (;;) {\r
-    CharC = (char) fgetc (In);\r
-    if (feof (In)) {\r
-      break;\r
-    }\r
-\r
-    fputc (CharC, Out2);\r
-  }\r
-\r
-  fclose (In);\r
-  fclose (Out1);\r
-  fclose (Out2);\r
-\r
-  return 0;\r
-}\r
diff --git a/Tools/CodeTools/TianoTools/SplitFile/build.xml b/Tools/CodeTools/TianoTools/SplitFile/build.xml
deleted file mode 100644 (file)
index 6fa9b57..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-<?xml version="1.0" ?>\r
-<!--\r
-Copyright (c) 2006, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
--->\r
-<project default="GenTool" basedir=".">\r
-<!--\r
-    EDK SplitFile Tool\r
-  Copyright (c) 2006, Intel Corporation\r
--->\r
-  <property name="ToolName" value="SplitFile"/>\r
-  <property name="FileSet" value="*.c"/>\r
-\r
-  <taskdef resource="cpptasks.tasks"/>\r
-  <typedef resource="cpptasks.types"/>\r
-  <taskdef resource="net/sf/antcontrib/antlib.xml"/>\r
-\r
-  <property name="LINK_OUTPUT_TYPE" value="static"/>\r
-  <property name="BUILD_DIR" value="${PACKAGE_DIR}/${ToolName}/tmp"/>\r
-\r
-  <target name="GenTool" depends="init, Tool">\r
-    <echo message="The EDK Tool: ${ToolName} build has completed!"/>\r
-  </target>\r
-\r
-  <target name="init">\r
-    <echo message="Building the EDK Tool: ${ToolName}"/>\r
-    <mkdir dir="${BUILD_DIR}"/>\r
-  </target>\r
-\r
-  <target name="Tool" depends="init">\r
-    <cc name="${ToolChain}" objdir="${BUILD_DIR}" \r
-        outfile="${BIN_DIR}/${ToolName}"\r
-        outtype="executable"\r
-        optimize="speed" \r
-        debug="true">\r
-\r
-      <fileset dir="${basedir}/${ToolName}" \r
-        includes="${FileSet}" \r
-        defaultexcludes="TRUE" \r
-        excludes="*.xml *.inf"/>\r
-\r
-      <includepath path="${PACKAGE_DIR}/Include"/>\r
-      <includepath path="${PACKAGE_DIR}/Include/Ia32"/>\r
-      <includepath path="${PACKAGE_DIR}/Common"/>\r
-    </cc>\r
-  </target>\r
-\r
-  <target name="clean">\r
-    <echo message="Removing Intermediate Files Only"/>  \r
-    <delete>\r
-      <fileset dir="${BUILD_DIR}" includes="*.obj"/>\r
-    </delete>\r
-  </target>\r
-\r
-  <target name="cleanall">\r
-    <echo message="Removing Object Files and the Executable: ${ToolName}${ext_exe}"/>  \r
-    <delete failonerror="false" quiet="true" includeEmptyDirs="true">\r
-      <fileset dir="${BUILD_DIR}"/>\r
-      <fileset file="${BIN_DIR}/${ToolName}${ext_exe}"/>\r
-    </delete>\r
-  </target>\r
-\r
-</project>\r
diff --git a/Tools/CodeTools/TianoTools/StrGather/StrGather.c b/Tools/CodeTools/TianoTools/StrGather/StrGather.c
deleted file mode 100644 (file)
index 9eb5c5a..0000000
+++ /dev/null
@@ -1,2531 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2004, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-Module Name:\r
-\r
-  StrGather.c  \r
-\r
-Abstract:\r
-\r
-  Parse a strings file and create or add to a string database file.\r
-\r
---*/\r
-\r
-#include <stdio.h>\r
-#include <string.h>\r
-#include <stdlib.h>\r
-#include <ctype.h>\r
-\r
-#include <Common/UefiBaseTypes.h>\r
-\r
-#include "CommonLib.h"\r
-#include "EfiUtilityMsgs.h"\r
-#include "StrGather.h"\r
-#include "StringDB.h"\r
-\r
-#define TOOL_VERSION  "0.31"\r
-\r
-#ifndef MAX_PATH\r
-#define MAX_PATH                    255\r
-#endif\r
-#define MAX_NEST_DEPTH              20  // just in case we get in an endless loop.\r
-#define MAX_STRING_IDENTIFIER_NAME  100 // number of wchars\r
-#define MAX_LINE_LEN                200\r
-#define STRING_TOKEN                "STRING_TOKEN"\r
-#define DEFAULT_BASE_NAME           "BaseName"\r
-//\r
-// Operational modes for this utility\r
-//\r
-#define MODE_UNKNOWN  0\r
-#define MODE_PARSE    1\r
-#define MODE_SCAN     2\r
-#define MODE_DUMP     3\r
-\r
-//\r
-// We keep a linked list of these for the source files we process\r
-//\r
-typedef struct _SOURCE_FILE {\r
-  FILE                *Fptr;\r
-  WCHAR               *FileBuffer;\r
-  WCHAR               *FileBufferPtr;\r
-  UINT32              FileSize;\r
-  CHAR8               FileName[MAX_PATH];\r
-  UINT32              LineNum;\r
-  BOOLEAN             EndOfFile;\r
-  BOOLEAN             SkipToHash;\r
-  struct _SOURCE_FILE *Previous;\r
-  struct _SOURCE_FILE *Next;\r
-  WCHAR               ControlCharacter;\r
-} SOURCE_FILE;\r
-\r
-#define DEFAULT_CONTROL_CHARACTER UNICODE_SLASH\r
-\r
-//\r
-// Here's all our globals. We need a linked list of include paths, a linked\r
-// list of source files, a linked list of subdirectories (appended to each\r
-// include path when searching), and a couple other fields.\r
-//\r
-static struct {\r
-  SOURCE_FILE                 SourceFiles;\r
-  TEXT_STRING_LIST            *IncludePaths;                    // all include paths to search\r
-  TEXT_STRING_LIST            *LastIncludePath;\r
-  TEXT_STRING_LIST            *ScanFileName;\r
-  TEXT_STRING_LIST            *LastScanFileName;\r
-  TEXT_STRING_LIST            *SkipExt;                         // if -skipext .uni\r
-  TEXT_STRING_LIST            *LastSkipExt;\r
-  TEXT_STRING_LIST            *IndirectionFileName;\r
-  TEXT_STRING_LIST            *LastIndirectionFileName;\r
-  TEXT_STRING_LIST            *DatabaseFileName;\r
-  TEXT_STRING_LIST            *LastDatabaseFileName;\r
-  WCHAR_STRING_LIST           *Language;\r
-  WCHAR_STRING_LIST           *LastLanguage;\r
-  WCHAR_MATCHING_STRING_LIST  *IndirectionList;                 // from indirection file(s)\r
-  WCHAR_MATCHING_STRING_LIST  *LastIndirectionList;\r
-  BOOLEAN                     Verbose;                          // for more detailed output\r
-  BOOLEAN                     VerboseDatabaseWrite;             // for more detailed output when writing database\r
-  BOOLEAN                     VerboseDatabaseRead;              // for more detailed output when reading database\r
-  BOOLEAN                     NewDatabase;                      // to start from scratch\r
-  BOOLEAN                     IgnoreNotFound;                   // when scanning\r
-  BOOLEAN                     VerboseScan;\r
-  BOOLEAN                     UnquotedStrings;                  // -uqs option\r
-  CHAR8                       OutputDatabaseFileName[MAX_PATH];\r
-  CHAR8                       StringHFileName[MAX_PATH];\r
-  CHAR8                       StringCFileName[MAX_PATH];        // output .C filename\r
-  CHAR8                       DumpUFileName[MAX_PATH];          // output unicode dump file name\r
-  CHAR8                       HiiExportPackFileName[MAX_PATH];  // HII export pack file name\r
-  CHAR8                       BaseName[MAX_PATH];               // base filename of the strings file\r
-  UINT32                      Mode;\r
-} mGlobals;\r
-\r
-static\r
-BOOLEAN\r
-IsValidIdentifierChar (\r
-  CHAR8     Char,\r
-  BOOLEAN   FirstChar\r
-  );\r
-\r
-static\r
-void\r
-RewindFile (\r
-  SOURCE_FILE *SourceFile\r
-  );\r
-\r
-static\r
-BOOLEAN\r
-SkipTo (\r
-  SOURCE_FILE *SourceFile,\r
-  WCHAR       WChar,\r
-  BOOLEAN     StopAfterNewline\r
-  );\r
-\r
-static\r
-UINT32\r
-SkipWhiteSpace (\r
-  SOURCE_FILE *SourceFile\r
-  );\r
-\r
-static\r
-BOOLEAN\r
-IsWhiteSpace (\r
-  SOURCE_FILE *SourceFile\r
-  );\r
-\r
-static\r
-BOOLEAN\r
-EndOfFile (\r
-  SOURCE_FILE *SourceFile\r
-  );\r
-\r
-static\r
-void\r
-PreprocessFile (\r
-  SOURCE_FILE *SourceFile\r
-  );\r
-\r
-static\r
-UINT32\r
-GetStringIdentifierName (\r
-  IN SOURCE_FILE  *SourceFile,\r
-  IN OUT WCHAR    *StringIdentifierName,\r
-  IN UINT32       StringIdentifierNameLen\r
-  );\r
-\r
-static\r
-UINT32\r
-GetLanguageIdentifierName (\r
-  IN SOURCE_FILE  *SourceFile,\r
-  IN OUT WCHAR    *LanguageIdentifierName,\r
-  IN UINT32       LanguageIdentifierNameLen,\r
-  IN BOOLEAN      Optional\r
-  );\r
-\r
-static\r
-WCHAR *\r
-GetPrintableLanguageName (\r
-  IN SOURCE_FILE  *SourceFile\r
-  );\r
-\r
-static\r
-STATUS\r
-AddCommandLineLanguage (\r
-  IN CHAR8         *Language\r
-  );\r
-\r
-static\r
-WCHAR *\r
-GetQuotedString (\r
-  SOURCE_FILE *SourceFile,\r
-  BOOLEAN     Optional\r
-  );\r
-\r
-static\r
-STATUS\r
-ProcessIncludeFile (\r
-  SOURCE_FILE *SourceFile,\r
-  SOURCE_FILE *ParentSourceFile\r
-  );\r
-\r
-static\r
-STATUS\r
-ParseFile (\r
-  SOURCE_FILE *SourceFile\r
-  );\r
-\r
-static\r
-FILE  *\r
-FindFile (\r
-  IN CHAR8    *FileName,\r
-  OUT CHAR8   *FoundFileName,\r
-  IN UINT32   FoundFileNameLen\r
-  );\r
-\r
-static\r
-STATUS\r
-ProcessArgs (\r
-  int   Argc,\r
-  char  *Argv[]\r
-  );\r
-\r
-static\r
-STATUS\r
-ProcessFile (\r
-  SOURCE_FILE *SourceFile\r
-  );\r
-\r
-static\r
-UINT32\r
-wstrcmp (\r
-  WCHAR *Buffer,\r
-  WCHAR *Str\r
-  );\r
-\r
-static\r
-void\r
-Usage (\r
-  VOID\r
-  );\r
-\r
-static\r
-void\r
-FreeLists (\r
-  VOID\r
-  );\r
-\r
-static\r
-void\r
-ProcessTokenString (\r
-  SOURCE_FILE *SourceFile\r
-  );\r
-\r
-static\r
-void\r
-ProcessTokenInclude (\r
-  SOURCE_FILE *SourceFile\r
-  );\r
-\r
-static\r
-void\r
-ProcessTokenScope (\r
-  SOURCE_FILE *SourceFile\r
-  );\r
-\r
-static\r
-void\r
-ProcessTokenLanguage (\r
-  SOURCE_FILE *SourceFile\r
-  );\r
-\r
-static\r
-void\r
-ProcessTokenLangDef (\r
-  SOURCE_FILE *SourceFile\r
-  );\r
-\r
-static\r
-STATUS\r
-ScanFiles (\r
-  TEXT_STRING_LIST *ScanFiles\r
-  );\r
-\r
-static\r
-STATUS\r
-ParseIndirectionFiles (\r
-  TEXT_STRING_LIST    *Files\r
-  );\r
-\r
-STATUS\r
-StringDBCreateHiiExportPack (\r
-  CHAR8               *OutputFileName\r
-  );\r
-\r
-int\r
-main (\r
-  int   Argc,\r
-  char  *Argv[]\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Call the routine to parse the command-line options, then process the file.\r
-  \r
-Arguments:\r
-\r
-  Argc - Standard C main() argc and argv.\r
-  Argv - Standard C main() argc and argv.\r
-\r
-Returns:\r
-\r
-  0       if successful\r
-  nonzero otherwise\r
-  \r
---*/\r
-{\r
-  STATUS  Status;\r
-\r
-  SetUtilityName (PROGRAM_NAME);\r
-  //\r
-  // Process the command-line arguments\r
-  //\r
-  Status = ProcessArgs (Argc, Argv);\r
-  if (Status != STATUS_SUCCESS) {\r
-    return Status;\r
-  }\r
-  //\r
-  // Initialize the database manager\r
-  //\r
-  StringDBConstructor ();\r
-  //\r
-  // We always try to read in an existing database file. It may not\r
-  // exist, which is ok usually.\r
-  //\r
-  if (mGlobals.NewDatabase == 0) {\r
-    //\r
-    // Read all databases specified.\r
-    //\r
-    for (mGlobals.LastDatabaseFileName = mGlobals.DatabaseFileName;\r
-         mGlobals.LastDatabaseFileName != NULL;\r
-         mGlobals.LastDatabaseFileName = mGlobals.LastDatabaseFileName->Next\r
-        ) {\r
-      Status = StringDBReadDatabase (mGlobals.LastDatabaseFileName->Str, TRUE, mGlobals.VerboseDatabaseRead);\r
-      if (Status != STATUS_SUCCESS) {\r
-        return Status;\r
-      }\r
-    }\r
-  }\r
-  //\r
-  // Read indirection file(s) if specified\r
-  //\r
-  if (ParseIndirectionFiles (mGlobals.IndirectionFileName) != STATUS_SUCCESS) {\r
-    goto Finish;\r
-  }\r
-  //\r
-  // If scanning source files, do that now\r
-  //\r
-  if (mGlobals.Mode == MODE_SCAN) {\r
-    ScanFiles (mGlobals.ScanFileName);\r
-  } else if (mGlobals.Mode == MODE_PARSE) {\r
-    //\r
-    // Parsing a unicode strings file\r
-    //\r
-    mGlobals.SourceFiles.ControlCharacter = DEFAULT_CONTROL_CHARACTER;\r
-    Status = ProcessIncludeFile (&mGlobals.SourceFiles, NULL);\r
-    if (Status != STATUS_SUCCESS) {\r
-      goto Finish;\r
-    }\r
-  }\r
-  //\r
-  // Create the string defines header file if there have been no errors.\r
-  //\r
-  ParserSetPosition (NULL, 0);\r
-  if ((mGlobals.StringHFileName[0] != 0) && (GetUtilityStatus () < STATUS_ERROR)) {\r
-    Status = StringDBDumpStringDefines (mGlobals.StringHFileName, mGlobals.BaseName);\r
-    if (Status != EFI_SUCCESS) {\r
-      goto Finish;\r
-    }\r
-  }\r
-  //\r
-  // Dump the strings to a .c file if there have still been no errors.\r
-  //\r
-  if ((mGlobals.StringCFileName[0] != 0) && (GetUtilityStatus () < STATUS_ERROR)) {\r
-    Status = StringDBDumpCStrings (\r
-              mGlobals.StringCFileName,\r
-              mGlobals.BaseName,\r
-              mGlobals.Language,\r
-              mGlobals.IndirectionList\r
-              );\r
-    if (Status != EFI_SUCCESS) {\r
-      goto Finish;\r
-    }\r
-  }\r
-  //\r
-  // Dump the database if requested\r
-  //\r
-  if ((mGlobals.DumpUFileName[0] != 0) && (GetUtilityStatus () < STATUS_ERROR)) {\r
-    StringDBDumpDatabase (NULL, mGlobals.DumpUFileName, FALSE);\r
-  }\r
-  //\r
-  // Dump the string data as HII binary string pack if requested\r
-  //\r
-  if ((mGlobals.HiiExportPackFileName[0] != 0) && (GetUtilityStatus () < STATUS_ERROR)) {\r
-    StringDBCreateHiiExportPack (mGlobals.HiiExportPackFileName);\r
-  }\r
-  //\r
-  // Always update the database if no errors and not in dump mode. If they specified -od\r
-  // for an output database file name, then use that name. Otherwise use the name of\r
-  // the first database file specified with -db\r
-  //\r
-  if ((mGlobals.Mode != MODE_DUMP) && (GetUtilityStatus () < STATUS_ERROR)) {\r
-    if (mGlobals.OutputDatabaseFileName[0]) {\r
-      Status = StringDBWriteDatabase (mGlobals.OutputDatabaseFileName, mGlobals.VerboseDatabaseWrite);\r
-    } else {\r
-      Status = StringDBWriteDatabase (mGlobals.DatabaseFileName->Str, mGlobals.VerboseDatabaseWrite);\r
-    }\r
-\r
-    if (Status != EFI_SUCCESS) {\r
-      goto Finish;\r
-    }\r
-  }\r
-\r
-Finish:\r
-  //\r
-  // Free up memory\r
-  //\r
-  FreeLists ();\r
-  StringDBDestructor ();\r
-  return GetUtilityStatus ();\r
-}\r
-\r
-static\r
-STATUS\r
-ProcessIncludeFile (\r
-  SOURCE_FILE *SourceFile,\r
-  SOURCE_FILE *ParentSourceFile\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Given a source file, open the file and parse it\r
-  \r
-Arguments:\r
-\r
-  SourceFile        - name of file to parse\r
-  ParentSourceFile  - for error reporting purposes, the file that #included SourceFile.\r
-\r
-Returns:\r
-\r
-  Standard status.\r
-  \r
---*/\r
-{\r
-  static UINT32 NestDepth = 0;\r
-  CHAR8         FoundFileName[MAX_PATH];\r
-  STATUS        Status;\r
-\r
-  Status = STATUS_SUCCESS;\r
-  NestDepth++;\r
-  //\r
-  // Print the file being processed. Indent so you can tell the include nesting\r
-  // depth.\r
-  //\r
-  if (mGlobals.Verbose) {\r
-    fprintf (stdout, "%*cProcessing file '%s'\n", NestDepth * 2, ' ', SourceFile->FileName);\r
-  }\r
-\r
-  //\r
-  // Make sure we didn't exceed our maximum nesting depth\r
-  //\r
-  if (NestDepth > MAX_NEST_DEPTH) {\r
-    Error (NULL, 0, 0, SourceFile->FileName, "max nesting depth (%d) exceeded", NestDepth);\r
-    Status = STATUS_ERROR;\r
-    goto Finish;\r
-  }\r
-  //\r
-  // Try to open the file locally, and if that fails try along our include paths.\r
-  //\r
-  strcpy (FoundFileName, SourceFile->FileName);\r
-  if ((SourceFile->Fptr = fopen (FoundFileName, "rb")) == NULL) {\r
-    //\r
-    // Try to find it among the paths if it has a parent (that is, it is included\r
-    // by someone else).\r
-    //\r
-    if (ParentSourceFile == NULL) {\r
-      Error (NULL, 0, 0, SourceFile->FileName, "file not found");\r
-      return STATUS_ERROR;\r
-    }\r
-\r
-    SourceFile->Fptr = FindFile (SourceFile->FileName, FoundFileName, sizeof (FoundFileName));\r
-    if (SourceFile->Fptr == NULL) {\r
-      Error (ParentSourceFile->FileName, ParentSourceFile->LineNum, 0, SourceFile->FileName, "include file not found");\r
-      return STATUS_ERROR;\r
-    }\r
-  }\r
-  //\r
-  // Process the file found\r
-  //\r
-  ProcessFile (SourceFile);\r
-Finish:\r
-  //\r
-  // Close open files and return status\r
-  //\r
-  if (SourceFile->Fptr != NULL) {\r
-    fclose (SourceFile->Fptr);\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-static\r
-STATUS\r
-ProcessFile (\r
-  SOURCE_FILE *SourceFile\r
-  )\r
-{\r
-  //\r
-  // Get the file size, and then read the entire thing into memory.\r
-  // Allocate space for a terminator character.\r
-  //\r
-  fseek (SourceFile->Fptr, 0, SEEK_END);\r
-  SourceFile->FileSize = ftell (SourceFile->Fptr);\r
-  fseek (SourceFile->Fptr, 0, SEEK_SET);\r
-  SourceFile->FileBuffer = (WCHAR *) malloc (SourceFile->FileSize + sizeof (WCHAR));\r
-  if (SourceFile->FileBuffer == NULL) {\r
-    Error (NULL, 0, 0, "memory allocation failure", NULL);\r
-    return STATUS_ERROR;\r
-  }\r
-\r
-  fread ((VOID *) SourceFile->FileBuffer, SourceFile->FileSize, 1, SourceFile->Fptr);\r
-  SourceFile->FileBuffer[(SourceFile->FileSize / sizeof (WCHAR))] = UNICODE_NULL;\r
-  //\r
-  // Pre-process the file to replace comments with spaces\r
-  //\r
-  PreprocessFile (SourceFile);\r
-  //\r
-  // Parse the file\r
-  //\r
-  ParseFile (SourceFile);\r
-  free (SourceFile->FileBuffer);\r
-  return STATUS_SUCCESS;\r
-}\r
-\r
-static\r
-STATUS\r
-ParseFile (\r
-  SOURCE_FILE *SourceFile\r
-  )\r
-{\r
-  BOOLEAN InComment;\r
-  UINT32  Len;\r
-\r
-  //\r
-  // First character of a unicode file is special. Make sure\r
-  //\r
-  if (SourceFile->FileBufferPtr[0] != UNICODE_FILE_START) {\r
-    Error (SourceFile->FileName, 1, 0, SourceFile->FileName, "file does not appear to be a unicode file");\r
-    return STATUS_ERROR;\r
-  }\r
-\r
-  SourceFile->FileBufferPtr++;\r
-  InComment = FALSE;\r
-  //\r
-  // Print the first line if in verbose mode\r
-  //\r
-  if (mGlobals.Verbose) {\r
-    printf ("%d: %S\n", SourceFile->LineNum, SourceFile->FileBufferPtr);\r
-  }\r
-  //\r
-  // Since the syntax is relatively straightforward, just switch on the next char\r
-  //\r
-  while (!EndOfFile (SourceFile)) {\r
-    //\r
-    // Check for whitespace\r
-    //\r
-    if (SourceFile->FileBufferPtr[0] == UNICODE_SPACE) {\r
-      SourceFile->FileBufferPtr++;\r
-    } else if (SourceFile->FileBufferPtr[0] == UNICODE_TAB) {\r
-      SourceFile->FileBufferPtr++;\r
-    } else if (SourceFile->FileBufferPtr[0] == UNICODE_CR) {\r
-      SourceFile->FileBufferPtr++;\r
-    } else if (SourceFile->FileBufferPtr[0] == UNICODE_LF) {\r
-      SourceFile->FileBufferPtr++;\r
-      SourceFile->LineNum++;\r
-      if (mGlobals.Verbose) {\r
-        printf ("%d: %S\n", SourceFile->LineNum, SourceFile->FileBufferPtr);\r
-      }\r
-\r
-      InComment = FALSE;\r
-    } else if (SourceFile->FileBufferPtr[0] == 0) {\r
-      SourceFile->FileBufferPtr++;\r
-    } else if (InComment) {\r
-      SourceFile->FileBufferPtr++;\r
-    } else if ((SourceFile->FileBufferPtr[0] == UNICODE_SLASH) && (SourceFile->FileBufferPtr[1] == UNICODE_SLASH)) {\r
-      SourceFile->FileBufferPtr += 2;\r
-      InComment = TRUE;\r
-    } else if (SourceFile->SkipToHash && (SourceFile->FileBufferPtr[0] != SourceFile->ControlCharacter)) {\r
-      SourceFile->FileBufferPtr++;\r
-    } else {\r
-      SourceFile->SkipToHash = FALSE;\r
-      if ((SourceFile->FileBufferPtr[0] == SourceFile->ControlCharacter) &&\r
-          ((Len = wstrcmp (SourceFile->FileBufferPtr + 1, L"include")) > 0)\r
-          ) {\r
-        SourceFile->FileBufferPtr += Len + 1;\r
-        ProcessTokenInclude (SourceFile);\r
-      } else if ((SourceFile->FileBufferPtr[0] == SourceFile->ControlCharacter) &&\r
-               (Len = wstrcmp (SourceFile->FileBufferPtr + 1, L"scope")) > 0\r
-              ) {\r
-        SourceFile->FileBufferPtr += Len + 1;\r
-        ProcessTokenScope (SourceFile);\r
-      } else if ((SourceFile->FileBufferPtr[0] == SourceFile->ControlCharacter) &&\r
-               (Len = wstrcmp (SourceFile->FileBufferPtr + 1, L"language")) > 0\r
-              ) {\r
-        SourceFile->FileBufferPtr += Len + 1;\r
-        ProcessTokenLanguage (SourceFile);\r
-      } else if ((SourceFile->FileBufferPtr[0] == SourceFile->ControlCharacter) &&\r
-               (Len = wstrcmp (SourceFile->FileBufferPtr + 1, L"langdef")) > 0\r
-              ) {\r
-        SourceFile->FileBufferPtr += Len + 1;\r
-        ProcessTokenLangDef (SourceFile);\r
-      } else if ((SourceFile->FileBufferPtr[0] == SourceFile->ControlCharacter) &&\r
-               (Len = wstrcmp (SourceFile->FileBufferPtr + 1, L"string")) > 0\r
-              ) {\r
-        SourceFile->FileBufferPtr += Len + 1;\r
-        ProcessTokenString (SourceFile);\r
-      } else if ((SourceFile->FileBufferPtr[0] == SourceFile->ControlCharacter) &&\r
-               (Len = wstrcmp (SourceFile->FileBufferPtr + 1, L"EFI_BREAKPOINT()")) > 0\r
-              ) {\r
-        SourceFile->FileBufferPtr += Len;\r
-        //\r
-        // BUGBUG: Caling EFI_BREAKOINT() is breaking the link.  What is the proper action for this tool\r
-        // in this condition?\r
-        //\r
-//        EFI_BREAKPOINT ();\r
-      } else if ((SourceFile->FileBufferPtr[0] == SourceFile->ControlCharacter) &&\r
-               (SourceFile->FileBufferPtr[1] == UNICODE_EQUAL_SIGN)\r
-              ) {\r
-        SourceFile->ControlCharacter = SourceFile->FileBufferPtr[2];\r
-        SourceFile->FileBufferPtr += 3;\r
-      } else {\r
-        Error (SourceFile->FileName, SourceFile->LineNum, 0, "unrecognized token", "%S", SourceFile->FileBufferPtr);\r
-        //\r
-        // Treat rest of line as a comment.\r
-        //\r
-        InComment = TRUE;\r
-      }\r
-    }\r
-  }\r
-\r
-  return STATUS_SUCCESS;\r
-}\r
-\r
-static\r
-void\r
-PreprocessFile (\r
-  SOURCE_FILE *SourceFile\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Preprocess a file to replace all carriage returns with NULLs so\r
-  we can print lines from the file to the screen.\r
-  \r
-Arguments:\r
-  SourceFile - structure that we use to keep track of an input file.\r
-\r
-Returns:\r
-  Nothing.\r
-  \r
---*/\r
-{\r
-  BOOLEAN InComment;\r
-\r
-  RewindFile (SourceFile);\r
-  InComment = FALSE;\r
-  while (!EndOfFile (SourceFile)) {\r
-    //\r
-    // If a line-feed, then no longer in a comment\r
-    //\r
-    if (SourceFile->FileBufferPtr[0] == UNICODE_LF) {\r
-      SourceFile->FileBufferPtr++;\r
-      SourceFile->LineNum++;\r
-      InComment = 0;\r
-    } else if (SourceFile->FileBufferPtr[0] == UNICODE_CR) {\r
-      //\r
-      // Replace all carriage returns with a NULL so we can print stuff\r
-      //\r
-      SourceFile->FileBufferPtr[0] = 0;\r
-      SourceFile->FileBufferPtr++;\r
-    } else if (InComment) {\r
-      SourceFile->FileBufferPtr[0] = UNICODE_SPACE;\r
-      SourceFile->FileBufferPtr++;\r
-    } else if ((SourceFile->FileBufferPtr[0] == UNICODE_SLASH) && (SourceFile->FileBufferPtr[1] == UNICODE_SLASH)) {\r
-      SourceFile->FileBufferPtr += 2;\r
-      InComment = TRUE;\r
-    } else {\r
-      SourceFile->FileBufferPtr++;\r
-    }\r
-  }\r
-  //\r
-  // Could check for end-of-file and still in a comment, but\r
-  // should not be necessary. So just restore the file pointers.\r
-  //\r
-  RewindFile (SourceFile);\r
-}\r
-\r
-static\r
-WCHAR *\r
-GetPrintableLanguageName (\r
-  IN SOURCE_FILE  *SourceFile\r
-  )\r
-{\r
-  WCHAR   *String;\r
-  WCHAR   *Start;\r
-  WCHAR   *Ptr;\r
-  UINT32  Len;\r
-\r
-  SkipWhiteSpace (SourceFile);\r
-  if (SourceFile->FileBufferPtr[0] != UNICODE_DOUBLE_QUOTE) {\r
-    Error (\r
-      SourceFile->FileName,\r
-      SourceFile->LineNum,\r
-      0,\r
-      "expected quoted printable language name",\r
-      "%S",\r
-      SourceFile->FileBufferPtr\r
-      );\r
-    SourceFile->SkipToHash = TRUE;\r
-    return NULL;\r
-  }\r
-\r
-  Len = 0;\r
-  SourceFile->FileBufferPtr++;\r
-  Start = Ptr = SourceFile->FileBufferPtr;\r
-  while (!EndOfFile (SourceFile)) {\r
-    if (SourceFile->FileBufferPtr[0] == UNICODE_CR) {\r
-      Warning (SourceFile->FileName, SourceFile->LineNum, 0, "carriage return found in quoted string", "%S", Start);\r
-      break;\r
-    } else if (SourceFile->FileBufferPtr[0] == UNICODE_DOUBLE_QUOTE) {\r
-      break;\r
-    }\r
-\r
-    SourceFile->FileBufferPtr++;\r
-    Len++;\r
-  }\r
-\r
-  if (SourceFile->FileBufferPtr[0] != UNICODE_DOUBLE_QUOTE) {\r
-    Warning (\r
-      SourceFile->FileName,\r
-      SourceFile->LineNum,\r
-      0,\r
-      "missing closing quote on printable language name string",\r
-      "%S",\r
-      Start\r
-      );\r
-  } else {\r
-    SourceFile->FileBufferPtr++;\r
-  }\r
-  //\r
-  // Now allocate memory for the string and save it off\r
-  //\r
-  String = (WCHAR *) malloc ((Len + 1) * sizeof (WCHAR));\r
-  if (String == NULL) {\r
-    Error (NULL, 0, 0, "memory allocation failed", NULL);\r
-    return NULL;\r
-  }\r
-  //\r
-  // Copy the string from the file buffer to the local copy.\r
-  // We do no reformatting of it whatsoever at this point.\r
-  //\r
-  Ptr = String;\r
-  while (Len > 0) {\r
-    *Ptr = *Start;\r
-    Start++;\r
-    Ptr++;\r
-    Len--;\r
-  }\r
-\r
-  *Ptr = 0;\r
-  //\r
-  // Now format the string to convert \wide and \narrow controls\r
-  //\r
-  StringDBFormatString (String);\r
-  return String;\r
-}\r
-\r
-static\r
-WCHAR *\r
-GetQuotedString (\r
-  SOURCE_FILE *SourceFile,\r
-  BOOLEAN     Optional\r
-  )\r
-{\r
-  WCHAR   *String;\r
-  WCHAR   *Start;\r
-  WCHAR   *Ptr;\r
-  UINT32  Len;\r
-  BOOLEAN PreviousBackslash;\r
-\r
-  if (SourceFile->FileBufferPtr[0] != UNICODE_DOUBLE_QUOTE) {\r
-    if (!Optional) {\r
-      Error (SourceFile->FileName, SourceFile->LineNum, 0, "expected quoted string", "%S", SourceFile->FileBufferPtr);\r
-    }\r
-\r
-    return NULL;\r
-  }\r
-\r
-  Len = 0;\r
-  SourceFile->FileBufferPtr++;\r
-  Start             = Ptr = SourceFile->FileBufferPtr;\r
-  PreviousBackslash = FALSE;\r
-  while (!EndOfFile (SourceFile)) {\r
-    if ((SourceFile->FileBufferPtr[0] == UNICODE_DOUBLE_QUOTE) && (!PreviousBackslash)) {\r
-      break;\r
-    } else if (SourceFile->FileBufferPtr[0] == UNICODE_CR) {\r
-      Warning (SourceFile->FileName, SourceFile->LineNum, 0, "carriage return found in quoted string", "%S", Start);\r
-      PreviousBackslash = FALSE;\r
-    } else if (SourceFile->FileBufferPtr[0] == UNICODE_BACKSLASH) {\r
-      PreviousBackslash = TRUE;\r
-    } else {\r
-      PreviousBackslash = FALSE;\r
-    }\r
-\r
-    SourceFile->FileBufferPtr++;\r
-    Len++;\r
-  }\r
-\r
-  if (SourceFile->FileBufferPtr[0] != UNICODE_DOUBLE_QUOTE) {\r
-    Warning (SourceFile->FileName, SourceFile->LineNum, 0, "missing closing quote on string", "%S", Start);\r
-  } else {\r
-    SourceFile->FileBufferPtr++;\r
-  }\r
-  //\r
-  // Now allocate memory for the string and save it off\r
-  //\r
-  String = (WCHAR *) malloc ((Len + 1) * sizeof (WCHAR));\r
-  if (String == NULL) {\r
-    Error (NULL, 0, 0, "memory allocation failed", NULL);\r
-    return NULL;\r
-  }\r
-  //\r
-  // Copy the string from the file buffer to the local copy.\r
-  // We do no reformatting of it whatsoever at this point.\r
-  //\r
-  Ptr = String;\r
-  while (Len > 0) {\r
-    *Ptr = *Start;\r
-    Start++;\r
-    Ptr++;\r
-    Len--;\r
-  }\r
-\r
-  *Ptr = 0;\r
-  return String;\r
-}\r
-//\r
-// Parse:\r
-//    #string STR_ID_NAME\r
-//\r
-// All we can do is call the string database to add the string identifier. Unfortunately\r
-// he'll have to keep track of the last identifier we added.\r
-//\r
-static\r
-void\r
-ProcessTokenString (\r
-  SOURCE_FILE *SourceFile\r
-  )\r
-{\r
-  WCHAR   StringIdentifier[MAX_STRING_IDENTIFIER_NAME];\r
-  UINT16  StringId;\r
-  //\r
-  // Extract the string identifier name and add it to the database.\r
-  //\r
-  if (GetStringIdentifierName (SourceFile, StringIdentifier, sizeof (StringIdentifier)) > 0) {\r
-    StringId = STRING_ID_INVALID;\r
-    StringDBAddStringIdentifier (StringIdentifier, &StringId, 0);\r
-  } else {\r
-    //\r
-    // Error recovery -- skip to the next #\r
-    //\r
-    SourceFile->SkipToHash = TRUE;\r
-  }\r
-}\r
-\r
-static\r
-BOOLEAN\r
-EndOfFile (\r
-  SOURCE_FILE *SourceFile\r
-  )\r
-{\r
-  //\r
-  // The file buffer pointer will typically get updated before the End-of-file flag in the\r
-  // source file structure, so check it first.\r
-  //\r
-  if (SourceFile->FileBufferPtr >= SourceFile->FileBuffer + SourceFile->FileSize / sizeof (WCHAR)) {\r
-    SourceFile->EndOfFile = TRUE;\r
-    return TRUE;\r
-  }\r
-\r
-  if (SourceFile->EndOfFile) {\r
-    return TRUE;\r
-  }\r
-\r
-  return FALSE;\r
-}\r
-\r
-static\r
-UINT32\r
-GetStringIdentifierName (\r
-  IN SOURCE_FILE  *SourceFile,\r
-  IN OUT WCHAR    *StringIdentifierName,\r
-  IN UINT32       StringIdentifierNameLen\r
-  )\r
-{\r
-  UINT32  Len;\r
-  WCHAR   *From;\r
-  WCHAR   *Start;\r
-\r
-  //\r
-  // Skip whitespace\r
-  //\r
-  SkipWhiteSpace (SourceFile);\r
-  if (SourceFile->EndOfFile) {\r
-    Error (SourceFile->FileName, SourceFile->LineNum, 0, "end-of-file encountered", "expected string identifier");\r
-    return 0;\r
-  }\r
-  //\r
-  // Verify first character of name is [A-Za-z]\r
-  //\r
-  Len = 0;\r
-  StringIdentifierNameLen /= 2;\r
-  From  = SourceFile->FileBufferPtr;\r
-  Start = SourceFile->FileBufferPtr;\r
-  if (((SourceFile->FileBufferPtr[0] >= UNICODE_A) && (SourceFile->FileBufferPtr[0] <= UNICODE_Z)) ||\r
-      ((SourceFile->FileBufferPtr[0] >= UNICODE_z) && (SourceFile->FileBufferPtr[0] <= UNICODE_z))\r
-      ) {\r
-    //\r
-    // Do nothing\r
-    //\r
-  } else {\r
-    Error (SourceFile->FileName, SourceFile->LineNum, 0, "invalid character in string identifier name", "%S", Start);\r
-    return 0;\r
-  }\r
-\r
-  while (!EndOfFile (SourceFile)) {\r
-    if (((SourceFile->FileBufferPtr[0] >= UNICODE_A) && (SourceFile->FileBufferPtr[0] <= UNICODE_Z)) ||\r
-        ((SourceFile->FileBufferPtr[0] >= UNICODE_z) && (SourceFile->FileBufferPtr[0] <= UNICODE_z)) ||\r
-        ((SourceFile->FileBufferPtr[0] >= UNICODE_0) && (SourceFile->FileBufferPtr[0] <= UNICODE_9)) ||\r
-        (SourceFile->FileBufferPtr[0] == UNICODE_UNDERSCORE)\r
-        ) {\r
-      Len++;\r
-      if (Len >= StringIdentifierNameLen) {\r
-        Error (SourceFile->FileName, SourceFile->LineNum, 0, "string identifier name too long", "%S", Start);\r
-        return 0;\r
-      }\r
-\r
-      *StringIdentifierName = SourceFile->FileBufferPtr[0];\r
-      StringIdentifierName++;\r
-      SourceFile->FileBufferPtr++;\r
-    } else if (SkipWhiteSpace (SourceFile) == 0) {\r
-      Error (SourceFile->FileName, SourceFile->LineNum, 0, "invalid string identifier name", "%S", Start);\r
-      return 0;\r
-    } else {\r
-      break;\r
-    }\r
-  }\r
-  //\r
-  // Terminate the copy of the string.\r
-  //\r
-  *StringIdentifierName = 0;\r
-  return Len;\r
-}\r
-\r
-static\r
-UINT32\r
-GetLanguageIdentifierName (\r
-  IN SOURCE_FILE  *SourceFile,\r
-  IN OUT WCHAR    *LanguageIdentifierName,\r
-  IN UINT32       LanguageIdentifierNameLen,\r
-  IN BOOLEAN      Optional\r
-  )\r
-{\r
-  UINT32  Len;\r
-  WCHAR   *From;\r
-  WCHAR   *Start;\r
-  //\r
-  // Skip whitespace\r
-  //\r
-  SkipWhiteSpace (SourceFile);\r
-  if (SourceFile->EndOfFile) {\r
-    if (!Optional) {\r
-      Error (\r
-        SourceFile->FileName,\r
-        SourceFile->LineNum,\r
-        0,\r
-        "end-of-file encountered",\r
-        "expected language identifier"\r
-        );\r
-    }\r
-\r
-    return 0;\r
-  }\r
-  //\r
-  // This function is called to optionally get a language identifier name in:\r
-  //   #string STR_ID eng "the string"\r
-  // If it's optional, and we find a double-quote, then return now.\r
-  //\r
-  if (Optional) {\r
-    if (*SourceFile->FileBufferPtr == UNICODE_DOUBLE_QUOTE) {\r
-      return 0;\r
-    }\r
-  }\r
-\r
-  Len = 0;\r
-  LanguageIdentifierNameLen /= 2;\r
-  //\r
-  // Internal error if we weren't given at least 4 WCHAR's to work with.\r
-  //\r
-  if (LanguageIdentifierNameLen < LANGUAGE_IDENTIFIER_NAME_LEN + 1) {\r
-    Error (\r
-      SourceFile->FileName,\r
-      SourceFile->LineNum,\r
-      0,\r
-      "app error -- language identifier name length is invalid",\r
-      NULL\r
-      );\r
-  }\r
-\r
-  From  = SourceFile->FileBufferPtr;\r
-  Start = SourceFile->FileBufferPtr;\r
-  while (!EndOfFile (SourceFile)) {\r
-    if (((SourceFile->FileBufferPtr[0] >= UNICODE_a) && (SourceFile->FileBufferPtr[0] <= UNICODE_z))) {\r
-      Len++;\r
-      if (Len > LANGUAGE_IDENTIFIER_NAME_LEN) {\r
-        Error (SourceFile->FileName, SourceFile->LineNum, 0, "language identifier name too long", "%S", Start);\r
-        return 0;\r
-      }\r
-\r
-      *LanguageIdentifierName = SourceFile->FileBufferPtr[0];\r
-      SourceFile->FileBufferPtr++;\r
-      LanguageIdentifierName++;\r
-    } else if (!IsWhiteSpace (SourceFile)) {\r
-      Error (SourceFile->FileName, SourceFile->LineNum, 0, "invalid language identifier name", "%S", Start);\r
-      return 0;\r
-    } else {\r
-      break;\r
-    }\r
-  }\r
-  //\r
-  // Terminate the copy of the string.\r
-  //\r
-  *LanguageIdentifierName = 0;\r
-  return Len;\r
-}\r
-\r
-static\r
-void\r
-ProcessTokenInclude (\r
-  SOURCE_FILE *SourceFile\r
-  )\r
-{\r
-  CHAR8       IncludeFileName[MAX_PATH];\r
-  CHAR8       *To;\r
-  UINT32      Len;\r
-  BOOLEAN     ReportedError;\r
-  SOURCE_FILE IncludedSourceFile;\r
-\r
-  ReportedError = FALSE;\r
-  if (SkipWhiteSpace (SourceFile) == 0) {\r
-    Warning (SourceFile->FileName, SourceFile->LineNum, 0, "expected whitespace following #include keyword", NULL);\r
-  }\r
-  //\r
-  // Should be quoted file name\r
-  //\r
-  if (SourceFile->FileBufferPtr[0] != UNICODE_DOUBLE_QUOTE) {\r
-    Error (SourceFile->FileName, SourceFile->LineNum, 0, "expected quoted include file name", NULL);\r
-    goto FailDone;\r
-  }\r
-\r
-  SourceFile->FileBufferPtr++;\r
-  //\r
-  // Copy the filename as ascii to our local string\r
-  //\r
-  To  = IncludeFileName;\r
-  Len = 0;\r
-  while (!EndOfFile (SourceFile)) {\r
-    if ((SourceFile->FileBufferPtr[0] == UNICODE_CR) || (SourceFile->FileBufferPtr[0] == UNICODE_LF)) {\r
-      Error (SourceFile->FileName, SourceFile->LineNum, 0, "end-of-line found in quoted include file name", NULL);\r
-      goto FailDone;\r
-    }\r
-\r
-    if (SourceFile->FileBufferPtr[0] == UNICODE_DOUBLE_QUOTE) {\r
-      SourceFile->FileBufferPtr++;\r
-      break;\r
-    }\r
-    //\r
-    // If too long, then report the error once and process until the closing quote\r
-    //\r
-    Len++;\r
-    if (!ReportedError && (Len >= sizeof (IncludeFileName))) {\r
-      Error (SourceFile->FileName, SourceFile->LineNum, 0, "length of include file name exceeds limit", NULL);\r
-      ReportedError = TRUE;\r
-    }\r
-\r
-    if (!ReportedError) {\r
-      *To = UNICODE_TO_ASCII (SourceFile->FileBufferPtr[0]);\r
-      To++;\r
-    }\r
-\r
-    SourceFile->FileBufferPtr++;\r
-  }\r
-\r
-  if (!ReportedError) {\r
-    *To = 0;\r
-    memset ((char *) &IncludedSourceFile, 0, sizeof (SOURCE_FILE));\r
-    strcpy (IncludedSourceFile.FileName, IncludeFileName);\r
-    IncludedSourceFile.ControlCharacter = DEFAULT_CONTROL_CHARACTER;\r
-    ProcessIncludeFile (&IncludedSourceFile, SourceFile);\r
-    //\r
-    // printf ("including file '%s'\n", IncludeFileName);\r
-    //\r
-  }\r
-\r
-  return ;\r
-FailDone:\r
-  //\r
-  // Error recovery -- skip to next #\r
-  //\r
-  SourceFile->SkipToHash = TRUE;\r
-}\r
-\r
-static\r
-void\r
-ProcessTokenScope (\r
-  SOURCE_FILE *SourceFile\r
-  )\r
-{\r
-  WCHAR StringIdentifier[MAX_STRING_IDENTIFIER_NAME];\r
-  //\r
-  // Extract the scope name\r
-  //\r
-  if (GetStringIdentifierName (SourceFile, StringIdentifier, sizeof (StringIdentifier)) > 0) {\r
-    StringDBSetScope (StringIdentifier);\r
-  }\r
-}\r
-//\r
-// Parse:  #langdef eng "English"\r
-//         #langdef chn "\wideChinese"\r
-//\r
-static\r
-void\r
-ProcessTokenLangDef (\r
-  SOURCE_FILE *SourceFile\r
-  )\r
-{\r
-  WCHAR   LanguageIdentifier[MAX_STRING_IDENTIFIER_NAME];\r
-  UINT32  Len;\r
-  WCHAR   *PrintableName;\r
-  //\r
-  // Extract the 3-character language identifier\r
-  //\r
-  Len = GetLanguageIdentifierName (SourceFile, LanguageIdentifier, sizeof (LanguageIdentifier), FALSE);\r
-  if (Len != LANGUAGE_IDENTIFIER_NAME_LEN) {\r
-    Error (SourceFile->FileName, SourceFile->LineNum, 0, "invalid or missing language identifier", NULL);\r
-  } else {\r
-    //\r
-    // Extract the printable name\r
-    //\r
-    PrintableName = GetPrintableLanguageName (SourceFile);\r
-    if (PrintableName != NULL) {\r
-      ParserSetPosition (SourceFile->FileName, SourceFile->LineNum);\r
-      StringDBAddLanguage (LanguageIdentifier, PrintableName);\r
-      free (PrintableName);\r
-      return ;\r
-    }\r
-  }\r
-  //\r
-  // Error recovery -- skip to next #\r
-  //\r
-  SourceFile->SkipToHash = TRUE;\r
-}\r
-\r
-static\r
-BOOLEAN\r
-ApparentQuotedString (\r
-  SOURCE_FILE *SourceFile\r
-  )\r
-{\r
-  WCHAR *Ptr;\r
-  //\r
-  // See if the first and last nonblank characters on the line are double quotes\r
-  //\r
-  for (Ptr = SourceFile->FileBufferPtr; *Ptr && (*Ptr == UNICODE_SPACE); Ptr++)\r
-    ;\r
-  if (*Ptr != UNICODE_DOUBLE_QUOTE) {\r
-    return FALSE;\r
-  }\r
-\r
-  while (*Ptr) {\r
-    Ptr++;\r
-  }\r
-\r
-  Ptr--;\r
-  for (; *Ptr && (*Ptr == UNICODE_SPACE); Ptr--)\r
-    ;\r
-  if (*Ptr != UNICODE_DOUBLE_QUOTE) {\r
-    return FALSE;\r
-  }\r
-\r
-  return TRUE;\r
-}\r
-//\r
-// Parse:\r
-//   #language eng "some string " "more string"\r
-//\r
-static\r
-void\r
-ProcessTokenLanguage (\r
-  SOURCE_FILE *SourceFile\r
-  )\r
-{\r
-  WCHAR   *String;\r
-  WCHAR   *SecondString;\r
-  WCHAR   *TempString;\r
-  WCHAR   *From;\r
-  WCHAR   *To;\r
-  WCHAR   Language[LANGUAGE_IDENTIFIER_NAME_LEN + 1];\r
-  UINT32  Len;\r
-  BOOLEAN PreviousNewline;\r
-  //\r
-  // Get the language identifier\r
-  //\r
-  Language[0] = 0;\r
-  Len         = GetLanguageIdentifierName (SourceFile, Language, sizeof (Language), TRUE);\r
-  if (Len != LANGUAGE_IDENTIFIER_NAME_LEN) {\r
-    Error (SourceFile->FileName, SourceFile->LineNum, 0, "invalid or missing language identifier", "%S", Language);\r
-    SourceFile->SkipToHash = TRUE;\r
-    return ;\r
-  }\r
-  //\r
-  // Extract the string value. It's either a quoted string that starts on the current line, or\r
-  // an unquoted string that starts on the following line and continues until the next control\r
-  // character in column 1.\r
-  // Look ahead to find a quote or a newline\r
-  //\r
-  if (SkipTo (SourceFile, UNICODE_DOUBLE_QUOTE, TRUE)) {\r
-    String = GetQuotedString (SourceFile, FALSE);\r
-    if (String != NULL) {\r
-      //\r
-      // Set the position in the file of where we are parsing for error\r
-      // reporting purposes. Then start looking ahead for additional\r
-      // quoted strings, and concatenate them until we get a failure\r
-      // back from the string parser.\r
-      //\r
-      Len = StrLen (String) + 1;\r
-      ParserSetPosition (SourceFile->FileName, SourceFile->LineNum);\r
-      do {\r
-        SkipWhiteSpace (SourceFile);\r
-        SecondString = GetQuotedString (SourceFile, TRUE);\r
-        if (SecondString != NULL) {\r
-          Len += StrLen (SecondString);\r
-          TempString = (WCHAR *) malloc (Len * sizeof (WCHAR));\r
-          if (TempString == NULL) {\r
-            Error (NULL, 0, 0, "application error", "failed to allocate memory");\r
-            return ;\r
-          }\r
-\r
-          StrCpy (TempString, String);\r
-          StrCat (TempString, SecondString);\r
-          free (String);\r
-          free (SecondString);\r
-          String = TempString;\r
-        }\r
-      } while (SecondString != NULL);\r
-      StringDBAddString (Language, NULL, NULL, String, TRUE, 0);\r
-      free (String);\r
-    } else {\r
-      //\r
-      // Error was reported at lower level. Error recovery mode.\r
-      //\r
-      SourceFile->SkipToHash = TRUE;\r
-    }\r
-  } else {\r
-    if (!mGlobals.UnquotedStrings) {\r
-      //\r
-      // They're using unquoted strings. If the next non-blank character is a double quote, and the\r
-      // last non-blank character on the line is a double quote, then more than likely they're using\r
-      // quotes, so they need to put the quoted string on the end of the previous line\r
-      //\r
-      if (ApparentQuotedString (SourceFile)) {\r
-        Warning (\r
-          SourceFile->FileName,\r
-          SourceFile->LineNum,\r
-          0,\r
-          "unexpected quoted string on line",\r
-          "specify -uqs option if necessary"\r
-          );\r
-      }\r
-    }\r
-    //\r
-    // Found end-of-line (hopefully). Skip over it and start taking in characters\r
-    // until we find a control character at the start of a line.\r
-    //\r
-    Len             = 0;\r
-    From            = SourceFile->FileBufferPtr;\r
-    PreviousNewline = FALSE;\r
-    while (!EndOfFile (SourceFile)) {\r
-      if (SourceFile->FileBufferPtr[0] == UNICODE_LF) {\r
-        PreviousNewline = TRUE;\r
-        SourceFile->LineNum++;\r
-      } else {\r
-        Len++;\r
-        if (PreviousNewline && (SourceFile->FileBufferPtr[0] == SourceFile->ControlCharacter)) {\r
-          break;\r
-        }\r
-\r
-        PreviousNewline = FALSE;\r
-      }\r
-\r
-      SourceFile->FileBufferPtr++;\r
-    }\r
-\r
-    if ((Len == 0) && EndOfFile (SourceFile)) {\r
-      Error (SourceFile->FileName, SourceFile->LineNum, 0, "unexpected end of file", NULL);\r
-      SourceFile->SkipToHash = TRUE;\r
-      return ;\r
-    }\r
-    //\r
-    // Now allocate a buffer, copy the characters, and add the string.\r
-    //\r
-    String = (WCHAR *) malloc ((Len + 1) * sizeof (WCHAR));\r
-    if (String == NULL) {\r
-      Error (NULL, 0, 0, "application error", "failed to allocate memory");\r
-      return ;\r
-    }\r
-\r
-    To = String;\r
-    while (From < SourceFile->FileBufferPtr) {\r
-      switch (*From) {\r
-      case UNICODE_LF:\r
-      case 0:\r
-        break;\r
-\r
-      default:\r
-        *To = *From;\r
-        To++;\r
-        break;\r
-      }\r
-\r
-      From++;\r
-    }\r
-\r
-    //\r
-    // String[Len] = 0;\r
-    //\r
-    *To = 0;\r
-    StringDBAddString (Language, NULL, NULL, String, TRUE, 0);\r
-  }\r
-}\r
-\r
-static\r
-BOOLEAN\r
-IsWhiteSpace (\r
-  SOURCE_FILE *SourceFile\r
-  )\r
-{\r
-  switch (SourceFile->FileBufferPtr[0]) {\r
-  case UNICODE_NULL:\r
-  case UNICODE_CR:\r
-  case UNICODE_SPACE:\r
-  case UNICODE_TAB:\r
-  case UNICODE_LF:\r
-    return TRUE;\r
-\r
-  default:\r
-    return FALSE;\r
-  }\r
-}\r
-\r
-static\r
-UINT32\r
-SkipWhiteSpace (\r
-  SOURCE_FILE *SourceFile\r
-  )\r
-{\r
-  UINT32  Count;\r
-\r
-  Count = 0;\r
-  while (!EndOfFile (SourceFile)) {\r
-    Count++;\r
-    switch (*SourceFile->FileBufferPtr) {\r
-    case UNICODE_NULL:\r
-    case UNICODE_CR:\r
-    case UNICODE_SPACE:\r
-    case UNICODE_TAB:\r
-      SourceFile->FileBufferPtr++;\r
-      break;\r
-\r
-    case UNICODE_LF:\r
-      SourceFile->FileBufferPtr++;\r
-      SourceFile->LineNum++;\r
-      if (mGlobals.Verbose) {\r
-        printf ("%d: %S\n", SourceFile->LineNum, SourceFile->FileBufferPtr);\r
-      }\r
-      break;\r
-\r
-    default:\r
-      return Count - 1;\r
-    }\r
-  }\r
-  //\r
-  // Some tokens require trailing whitespace. If we're at the end of the\r
-  // file, then we count that as well.\r
-  //\r
-  if ((Count == 0) && (EndOfFile (SourceFile))) {\r
-    Count++;\r
-  }\r
-\r
-  return Count;\r
-}\r
-\r
-static\r
-UINT32\r
-wstrcmp (\r
-  WCHAR *Buffer,\r
-  WCHAR *Str\r
-  )\r
-{\r
-  UINT32  Len;\r
-\r
-  Len = 0;\r
-  while (*Str == *Buffer) {\r
-    Buffer++;\r
-    Str++;\r
-    Len++;\r
-  }\r
-\r
-  if (*Str) {\r
-    return 0;\r
-  }\r
-\r
-  return Len;\r
-}\r
-//\r
-// Given a filename, try to find it along the include paths.\r
-//\r
-static\r
-FILE *\r
-FindFile (\r
-  IN CHAR8   *FileName,\r
-  OUT CHAR8  *FoundFileName,\r
-  IN UINT32  FoundFileNameLen\r
-  )\r
-{\r
-  FILE              *Fptr;\r
-  TEXT_STRING_LIST  *List;\r
-\r
-  //\r
-  // Traverse the list of paths and try to find the file\r
-  //\r
-  List = mGlobals.IncludePaths;\r
-  while (List != NULL) {\r
-    //\r
-    // Put the path and filename together\r
-    //\r
-    if (strlen (List->Str) + strlen (FileName) + 1 > FoundFileNameLen) {\r
-      Error (PROGRAM_NAME, 0, 0, NULL, "internal error - cannot concatenate path+filename");\r
-      return NULL;\r
-    }\r
-    //\r
-    // Append the filename to this include path and try to open the file.\r
-    //\r
-    strcpy (FoundFileName, List->Str);\r
-    strcat (FoundFileName, FileName);\r
-    if ((Fptr = fopen (FoundFileName, "rb")) != NULL) {\r
-      //\r
-      // Return the file pointer\r
-      //\r
-      return Fptr;\r
-    }\r
-\r
-    List = List->Next;\r
-  }\r
-  //\r
-  // Not found\r
-  //\r
-  FoundFileName[0] = 0;\r
-  return NULL;\r
-}\r
-//\r
-// Process the command-line arguments\r
-//\r
-static\r
-STATUS\r
-ProcessArgs (\r
-  int   Argc,\r
-  char  *Argv[]\r
-  )\r
-{\r
-  TEXT_STRING_LIST  *NewList;\r
-  //\r
-  // Clear our globals\r
-  //\r
-  memset ((char *) &mGlobals, 0, sizeof (mGlobals));\r
-  strcpy (mGlobals.BaseName, DEFAULT_BASE_NAME);\r
-  //\r
-  // Skip program name\r
-  //\r
-  Argc--;\r
-  Argv++;\r
-\r
-  if (Argc == 0) {\r
-    Usage ();\r
-    return STATUS_ERROR;\r
-  }\r
-\r
-  mGlobals.Mode = MODE_UNKNOWN;\r
-  //\r
-  // Process until no more -args.\r
-  //\r
-  while ((Argc > 0) && (Argv[0][0] == '-')) {\r
-    //\r
-    // -parse option\r
-    //\r
-    if (stricmp (Argv[0], "-parse") == 0) {\r
-      if (mGlobals.Mode != MODE_UNKNOWN) {\r
-        Error (NULL, 0, 0, "only one of -parse/-scan/-dump allowed", NULL);\r
-        return STATUS_ERROR;\r
-      }\r
-\r
-      mGlobals.Mode = MODE_PARSE;\r
-      //\r
-      // -scan option\r
-      //\r
-    } else if (stricmp (Argv[0], "-scan") == 0) {\r
-      if (mGlobals.Mode != MODE_UNKNOWN) {\r
-        Error (NULL, 0, 0, "only one of -parse/-scan/-dump allowed", NULL);\r
-        return STATUS_ERROR;\r
-      }\r
-\r
-      mGlobals.Mode = MODE_SCAN;\r
-      //\r
-      // -vscan verbose scanning option\r
-      //\r
-    } else if (stricmp (Argv[0], "-vscan") == 0) {\r
-      mGlobals.VerboseScan = TRUE;\r
-      //\r
-      // -dump option\r
-      //\r
-    } else if (stricmp (Argv[0], "-dump") == 0) {\r
-      if (mGlobals.Mode != MODE_UNKNOWN) {\r
-        Error (NULL, 0, 0, "only one of -parse/-scan/-dump allowed", NULL);\r
-        return STATUS_ERROR;\r
-      }\r
-\r
-      mGlobals.Mode = MODE_DUMP;\r
-    } else if (stricmp (Argv[0], "-uqs") == 0) {\r
-      mGlobals.UnquotedStrings = TRUE;\r
-      //\r
-      // -i path    add include search path when parsing\r
-      //\r
-    } else if (stricmp (Argv[0], "-i") == 0) {\r
-      //\r
-      // check for one more arg\r
-      //\r
-      if ((Argc <= 1) || (Argv[1][0] == '-')) {\r
-        Error (PROGRAM_NAME, 0, 0, Argv[0], "missing include path");\r
-        return STATUS_ERROR;\r
-      }\r
-      //\r
-      // Allocate memory for a new list element, fill it in, and\r
-      // add it to our list of include paths. Always make sure it\r
-      // has a "\" on the end of it.\r
-      //\r
-      NewList = malloc (sizeof (TEXT_STRING_LIST));\r
-      if (NewList == NULL) {\r
-        Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");\r
-        return STATUS_ERROR;\r
-      }\r
-\r
-      memset ((char *) NewList, 0, sizeof (TEXT_STRING_LIST));\r
-      NewList->Str = malloc (strlen (Argv[1]) + 2);\r
-      if (NewList->Str == NULL) {\r
-        free (NewList);\r
-        Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");\r
-        return STATUS_ERROR;\r
-      }\r
-\r
-      strcpy (NewList->Str, Argv[1]);\r
-      if (NewList->Str[strlen (NewList->Str) - 1] != '\\') {\r
-        strcat (NewList->Str, "\\");\r
-      }\r
-      //\r
-      // Add it to our linked list\r
-      //\r
-      if (mGlobals.IncludePaths == NULL) {\r
-        mGlobals.IncludePaths = NewList;\r
-      } else {\r
-        mGlobals.LastIncludePath->Next = NewList;\r
-      }\r
-\r
-      mGlobals.LastIncludePath = NewList;\r
-      Argc--;\r
-      Argv++;\r
-    } else if (stricmp (Argv[0], "-if") == 0) {\r
-      //\r
-      // Indirection file -- check for one more arg\r
-      //\r
-      if ((Argc <= 1) || (Argv[1][0] == '-')) {\r
-        Error (PROGRAM_NAME, 0, 0, Argv[0], "missing indirection file name");\r
-        return STATUS_ERROR;\r
-      }\r
-      //\r
-      // Allocate memory for a new list element, fill it in, and\r
-      // add it to our list of include paths. Always make sure it\r
-      // has a "\" on the end of it.\r
-      //\r
-      NewList = malloc (sizeof (TEXT_STRING_LIST));\r
-      if (NewList == NULL) {\r
-        Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");\r
-        return STATUS_ERROR;\r
-      }\r
-\r
-      memset ((char *) NewList, 0, sizeof (TEXT_STRING_LIST));\r
-      NewList->Str = malloc (strlen (Argv[1]) + 1);\r
-      if (NewList->Str == NULL) {\r
-        free (NewList);\r
-        Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");\r
-        return STATUS_ERROR;\r
-      }\r
-\r
-      strcpy (NewList->Str, Argv[1]);\r
-      //\r
-      // Add it to our linked list\r
-      //\r
-      if (mGlobals.IndirectionFileName == NULL) {\r
-        mGlobals.IndirectionFileName = NewList;\r
-      } else {\r
-        mGlobals.LastIndirectionFileName->Next = NewList;\r
-      }\r
-\r
-      mGlobals.LastIndirectionFileName = NewList;\r
-      Argc--;\r
-      Argv++;\r
-    } else if (stricmp (Argv[0], "-db") == 0) {\r
-      //\r
-      // -db option to specify a database file.\r
-      // Check for one more arg (the database file name)\r
-      //\r
-      if ((Argc <= 1) || (Argv[1][0] == '-')) {\r
-        Error (PROGRAM_NAME, 0, 0, Argv[0], "missing database file name");\r
-        return STATUS_ERROR;\r
-      }\r
-\r
-      NewList = malloc (sizeof (TEXT_STRING_LIST));\r
-      if (NewList == NULL) {\r
-        Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");\r
-        return STATUS_ERROR;\r
-      }\r
-\r
-      memset ((char *) NewList, 0, sizeof (TEXT_STRING_LIST));\r
-      NewList->Str = malloc (strlen (Argv[1]) + 1);\r
-      if (NewList->Str == NULL) {\r
-        free (NewList);\r
-        Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");\r
-        return STATUS_ERROR;\r
-      }\r
-\r
-      strcpy (NewList->Str, Argv[1]);\r
-      //\r
-      // Add it to our linked list\r
-      //\r
-      if (mGlobals.DatabaseFileName == NULL) {\r
-        mGlobals.DatabaseFileName = NewList;\r
-      } else {\r
-        mGlobals.LastDatabaseFileName->Next = NewList;\r
-      }\r
-\r
-      mGlobals.LastDatabaseFileName = NewList;\r
-      Argc--;\r
-      Argv++;\r
-    } else if (stricmp (Argv[0], "-ou") == 0) {\r
-      //\r
-      // -ou option to specify an output unicode file to\r
-      // which we can dump our database.\r
-      //\r
-      if ((Argc <= 1) || (Argv[1][0] == '-')) {\r
-        Error (PROGRAM_NAME, 0, 0, Argv[0], "missing database dump output file name");\r
-        return STATUS_ERROR;\r
-      }\r
-\r
-      if (mGlobals.DumpUFileName[0] == 0) {\r
-        strcpy (mGlobals.DumpUFileName, Argv[1]);\r
-      } else {\r
-        Error (PROGRAM_NAME, 0, 0, Argv[1], "-ou option already specified with '%s'", mGlobals.DumpUFileName);\r
-        return STATUS_ERROR;\r
-      }\r
-\r
-      Argc--;\r
-      Argv++;\r
-    } else if (stricmp (Argv[0], "-hpk") == 0) {\r
-      //\r
-      // -hpk option to create an HII export pack of the input database file\r
-      //\r
-      if ((Argc <= 1) || (Argv[1][0] == '-')) {\r
-        Error (PROGRAM_NAME, 0, 0, Argv[0], "missing raw string data dump output file name");\r
-        return STATUS_ERROR;\r
-      }\r
-\r
-      if (mGlobals.HiiExportPackFileName[0] == 0) {\r
-        strcpy (mGlobals.HiiExportPackFileName, Argv[1]);\r
-      } else {\r
-        Error (PROGRAM_NAME, 0, 0, Argv[1], "-or option already specified with '%s'", mGlobals.HiiExportPackFileName);\r
-        return STATUS_ERROR;\r
-      }\r
-\r
-      Argc--;\r
-      Argv++;\r
-    } else if ((stricmp (Argv[0], "-?") == 0) || (stricmp (Argv[0], "-h") == 0)) {\r
-      Usage ();\r
-      return STATUS_ERROR;\r
-    } else if (stricmp (Argv[0], "-v") == 0) {\r
-      mGlobals.Verbose = 1;\r
-    } else if (stricmp (Argv[0], "-vdbw") == 0) {\r
-      mGlobals.VerboseDatabaseWrite = 1;\r
-    } else if (stricmp (Argv[0], "-vdbr") == 0) {\r
-      mGlobals.VerboseDatabaseRead = 1;\r
-    } else if (stricmp (Argv[0], "-newdb") == 0) {\r
-      mGlobals.NewDatabase = 1;\r
-    } else if (stricmp (Argv[0], "-ignorenotfound") == 0) {\r
-      mGlobals.IgnoreNotFound = 1;\r
-    } else if (stricmp (Argv[0], "-oc") == 0) {\r
-      //\r
-      // check for one more arg\r
-      //\r
-      if ((Argc <= 1) || (Argv[1][0] == '-')) {\r
-        Error (PROGRAM_NAME, 0, 0, Argv[0], "missing output C filename");\r
-        return STATUS_ERROR;\r
-      }\r
-\r
-      strcpy (mGlobals.StringCFileName, Argv[1]);\r
-      Argc--;\r
-      Argv++;\r
-    } else if (stricmp (Argv[0], "-bn") == 0) {\r
-      //\r
-      // check for one more arg\r
-      //\r
-      if ((Argc <= 1) || (Argv[1][0] == '-')) {\r
-        Error (PROGRAM_NAME, 0, 0, Argv[0], "missing base name");\r
-        Usage ();\r
-        return STATUS_ERROR;\r
-      }\r
-\r
-      strcpy (mGlobals.BaseName, Argv[1]);\r
-      Argc--;\r
-      Argv++;\r
-    } else if (stricmp (Argv[0], "-oh") == 0) {\r
-      //\r
-      // -oh to specify output .h defines file name\r
-      //\r
-      if ((Argc <= 1) || (Argv[1][0] == '-')) {\r
-        Error (PROGRAM_NAME, 0, 0, Argv[0], "missing output .h filename");\r
-        return STATUS_ERROR;\r
-      }\r
-\r
-      strcpy (mGlobals.StringHFileName, Argv[1]);\r
-      Argc--;\r
-      Argv++;\r
-    } else if (stricmp (Argv[0], "-skipext") == 0) {\r
-      //\r
-      // -skipext to skip scanning of files with certain filename extensions\r
-      //\r
-      if ((Argc <= 1) || (Argv[1][0] == '-')) {\r
-        Error (PROGRAM_NAME, 0, 0, Argv[0], "missing filename extension");\r
-        return STATUS_ERROR;\r
-      }\r
-      //\r
-      // Allocate memory for a new list element, fill it in, and\r
-      // add it to our list of excluded extensions. Always make sure it\r
-      // has a "." as the first character.\r
-      //\r
-      NewList = malloc (sizeof (TEXT_STRING_LIST));\r
-      if (NewList == NULL) {\r
-        Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");\r
-        return STATUS_ERROR;\r
-      }\r
-\r
-      memset ((char *) NewList, 0, sizeof (TEXT_STRING_LIST));\r
-      NewList->Str = malloc (strlen (Argv[1]) + 2);\r
-      if (NewList->Str == NULL) {\r
-        free (NewList);\r
-        Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");\r
-        return STATUS_ERROR;\r
-      }\r
-\r
-      if (Argv[1][0] == '.') {\r
-        strcpy (NewList->Str, Argv[1]);\r
-      } else {\r
-        NewList->Str[0] = '.';\r
-        strcpy (NewList->Str + 1, Argv[1]);\r
-      }\r
-      //\r
-      // Add it to our linked list\r
-      //\r
-      if (mGlobals.SkipExt == NULL) {\r
-        mGlobals.SkipExt = NewList;\r
-      } else {\r
-        mGlobals.LastSkipExt->Next = NewList;\r
-      }\r
-\r
-      mGlobals.LastSkipExt = NewList;\r
-      Argc--;\r
-      Argv++;\r
-    } else if (stricmp (Argv[0], "-lang") == 0) {\r
-      //\r
-      // "-lang eng" or "-lang spa+cat" to only output certain languages\r
-      //\r
-      if ((Argc <= 1) || (Argv[1][0] == '-')) {\r
-        Error (PROGRAM_NAME, 0, 0, Argv[0], "missing language name");\r
-        Usage ();\r
-        return STATUS_ERROR;\r
-      }\r
-\r
-      if (AddCommandLineLanguage (Argv[1]) != STATUS_SUCCESS) {\r
-        return STATUS_ERROR;\r
-      }\r
-\r
-      Argc--;\r
-      Argv++;\r
-    } else if (stricmp (Argv[0], "-od") == 0) {\r
-      //\r
-      // Output database file name -- check for another arg\r
-      //\r
-      if ((Argc <= 1) || (Argv[1][0] == '-')) {\r
-        Error (PROGRAM_NAME, 0, 0, Argv[0], "missing output database file name");\r
-        return STATUS_ERROR;\r
-      }\r
-\r
-      strcpy (mGlobals.OutputDatabaseFileName, Argv[1]);\r
-      Argv++;\r
-      Argc--;\r
-    } else {\r
-      //\r
-      // Unrecognized arg\r
-      //\r
-      Error (PROGRAM_NAME, 0, 0, Argv[0], "unrecognized option");\r
-      Usage ();\r
-      return STATUS_ERROR;\r
-    }\r
-\r
-    Argv++;\r
-    Argc--;\r
-  }\r
-  //\r
-  // Make sure they specified the mode parse/scan/dump\r
-  //\r
-  if (mGlobals.Mode == MODE_UNKNOWN) {\r
-    Error (NULL, 0, 0, "must specify one of -parse/-scan/-dump", NULL);\r
-    return STATUS_ERROR;\r
-  }\r
-  //\r
-  // All modes require a database filename\r
-  //\r
-  if (mGlobals.DatabaseFileName == 0) {\r
-    Error (NULL, 0, 0, "must specify a database filename using -db DbFileName", NULL);\r
-    Usage ();\r
-    return STATUS_ERROR;\r
-  }\r
-  //\r
-  // If dumping the database file, then return immediately if all\r
-  // parameters check out.\r
-  //\r
-  if (mGlobals.Mode == MODE_DUMP) {\r
-    //\r
-    // Not much use if they didn't specify -oh or -oc or -ou or -hpk\r
-    //\r
-    if ((mGlobals.DumpUFileName[0] == 0) &&\r
-        (mGlobals.StringHFileName[0] == 0) &&\r
-        (mGlobals.StringCFileName[0] == 0) &&\r
-        (mGlobals.HiiExportPackFileName[0] == 0)\r
-        ) {\r
-      Error (NULL, 0, 0, "-dump without -oc/-oh/-ou/-hpk is a NOP", NULL);\r
-      return STATUS_ERROR;\r
-    }\r
-\r
-    return STATUS_SUCCESS;\r
-  }\r
-  //\r
-  // Had to specify source string file and output string defines header filename.\r
-  //\r
-  if (mGlobals.Mode == MODE_SCAN) {\r
-    if (Argc < 1) {\r
-      Error (PROGRAM_NAME, 0, 0, NULL, "must specify at least one source file to scan with -scan");\r
-      Usage ();\r
-      return STATUS_ERROR;\r
-    }\r
-    //\r
-    // Get the list of filenames\r
-    //\r
-    while (Argc > 0) {\r
-      NewList = malloc (sizeof (TEXT_STRING_LIST));\r
-      if (NewList == NULL) {\r
-        Error (PROGRAM_NAME, 0, 0, "memory allocation failure", NULL);\r
-        return STATUS_ERROR;\r
-      }\r
-\r
-      memset (NewList, 0, sizeof (TEXT_STRING_LIST));\r
-      NewList->Str = (CHAR8 *) malloc (strlen (Argv[0]) + 1);\r
-      if (NewList->Str == NULL) {\r
-        Error (PROGRAM_NAME, 0, 0, "memory allocation failure", NULL);\r
-        return STATUS_ERROR;\r
-      }\r
-\r
-      strcpy (NewList->Str, Argv[0]);\r
-      if (mGlobals.ScanFileName == NULL) {\r
-        mGlobals.ScanFileName = NewList;\r
-      } else {\r
-        mGlobals.LastScanFileName->Next = NewList;\r
-      }\r
-\r
-      mGlobals.LastScanFileName = NewList;\r
-      Argc--;\r
-      Argv++;\r
-    }\r
-  } else {\r
-    //\r
-    // Parse mode -- must specify an input unicode file name\r
-    //\r
-    if (Argc < 1) {\r
-      Error (PROGRAM_NAME, 0, 0, NULL, "must specify input unicode string file name with -parse");\r
-      Usage ();\r
-      return STATUS_ERROR;\r
-    }\r
-\r
-    strcpy (mGlobals.SourceFiles.FileName, Argv[0]);\r
-  }\r
-\r
-  return STATUS_SUCCESS;\r
-}\r
-//\r
-// Found "-lang eng,spa+cat" on the command line. Parse the\r
-// language list and save the setting for later processing.\r
-//\r
-static\r
-STATUS\r
-AddCommandLineLanguage (\r
-  IN CHAR8         *Language\r
-  )\r
-{\r
-  WCHAR_STRING_LIST *WNewList;\r
-  WCHAR             *From;\r
-  WCHAR             *To;\r
-  //\r
-  // Keep processing the input string until we find the end.\r
-  //\r
-  while (*Language) {\r
-    //\r
-    // Allocate memory for a new list element, fill it in, and\r
-    // add it to our list.\r
-    //\r
-    WNewList = MALLOC (sizeof (WCHAR_STRING_LIST));\r
-    if (WNewList == NULL) {\r
-      Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");\r
-      return STATUS_ERROR;\r
-    }\r
-\r
-    memset ((char *) WNewList, 0, sizeof (WCHAR_STRING_LIST));\r
-    WNewList->Str = malloc ((strlen (Language) + 1) * sizeof (WCHAR));\r
-    if (WNewList->Str == NULL) {\r
-      free (WNewList);\r
-      Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");\r
-      return STATUS_ERROR;\r
-    }\r
-    //\r
-    // Copy it as unicode to our new structure. Then remove the\r
-    // plus signs in it, and verify each language name is 3 characters\r
-    // long. If we find a comma, then we're done with this group, so\r
-    // break out.\r
-    //\r
-    UnicodeSPrint (WNewList->Str, (strlen (Language) + 1) * sizeof (WCHAR), L"%a", Language);\r
-    From = To = WNewList->Str;\r
-    while (*From) {\r
-      if (*From == L',') {\r
-        break;\r
-      }\r
-\r
-      if ((StrLen (From) < LANGUAGE_IDENTIFIER_NAME_LEN) ||\r
-            (\r
-              (From[LANGUAGE_IDENTIFIER_NAME_LEN] != 0) &&\r
-              (From[LANGUAGE_IDENTIFIER_NAME_LEN] != UNICODE_PLUS_SIGN) &&\r
-              (From[LANGUAGE_IDENTIFIER_NAME_LEN] != L',')\r
-            )\r
-          ) {\r
-        Error (PROGRAM_NAME, 0, 0, Language, "invalid format for language name on command line");\r
-        FREE (WNewList->Str);\r
-        FREE (WNewList);\r
-        return STATUS_ERROR;\r
-      }\r
-\r
-      StrnCpy (To, From, LANGUAGE_IDENTIFIER_NAME_LEN);\r
-      To += LANGUAGE_IDENTIFIER_NAME_LEN;\r
-      From += LANGUAGE_IDENTIFIER_NAME_LEN;\r
-      if (*From == L'+') {\r
-        From++;\r
-      }\r
-    }\r
-\r
-    *To = 0;\r
-    //\r
-    // Add it to our linked list\r
-    //\r
-    if (mGlobals.Language == NULL) {\r
-      mGlobals.Language = WNewList;\r
-    } else {\r
-      mGlobals.LastLanguage->Next = WNewList;\r
-    }\r
-\r
-    mGlobals.LastLanguage = WNewList;\r
-    //\r
-    // Skip to next entry (comma-separated list)\r
-    //\r
-    while (*Language) {\r
-      if (*Language == L',') {\r
-        Language++;\r
-        break;\r
-      }\r
-\r
-      Language++;\r
-    }\r
-  }\r
-\r
-  return STATUS_SUCCESS;\r
-}\r
-//\r
-// The contents of the text file are expected to be (one per line)\r
-//   STRING_IDENTIFIER_NAME   ScopeName\r
-// For example:\r
-//   STR_ID_MY_FAVORITE_STRING   IBM\r
-//\r
-static\r
-STATUS\r
-ParseIndirectionFiles (\r
-  TEXT_STRING_LIST    *Files\r
-  )\r
-{\r
-  FILE                        *Fptr;\r
-  CHAR8                       Line[200];\r
-  CHAR8                       *StringName;\r
-  CHAR8                       *ScopeName;\r
-  CHAR8                       *End;\r
-  UINT32                      LineCount;\r
-  WCHAR_MATCHING_STRING_LIST  *NewList;\r
-\r
-  Line[sizeof (Line) - 1] = 0;\r
-  Fptr                    = NULL;\r
-  while (Files != NULL) {\r
-    Fptr      = fopen (Files->Str, "r");\r
-    LineCount = 0;\r
-    if (Fptr == NULL) {\r
-      Error (NULL, 0, 0, Files->Str, "failed to open input indirection file for reading");\r
-      return STATUS_ERROR;\r
-    }\r
-\r
-    while (fgets (Line, sizeof (Line), Fptr) != NULL) {\r
-      //\r
-      // remove terminating newline for error printing purposes.\r
-      //\r
-      if (Line[strlen (Line) - 1] == '\n') {\r
-        Line[strlen (Line) - 1] = 0;\r
-      }\r
-\r
-      LineCount++;\r
-      if (Line[sizeof (Line) - 1] != 0) {\r
-        Error (Files->Str, LineCount, 0, "line length exceeds maximum supported", NULL);\r
-        goto Done;\r
-      }\r
-\r
-      StringName = Line;\r
-      while (*StringName && (isspace (*StringName))) {\r
-        StringName++;\r
-      }\r
-\r
-      if (*StringName) {\r
-        if ((*StringName == '_') || isalpha (*StringName)) {\r
-          End = StringName;\r
-          while ((*End) && (*End == '_') || (isalnum (*End))) {\r
-            End++;\r
-          }\r
-\r
-          if (isspace (*End)) {\r
-            *End = 0;\r
-            End++;\r
-            while (isspace (*End)) {\r
-              End++;\r
-            }\r
-\r
-            if (*End) {\r
-              ScopeName = End;\r
-              while (*End && !isspace (*End)) {\r
-                End++;\r
-              }\r
-\r
-              *End = 0;\r
-              //\r
-              // Add the string name/scope pair\r
-              //\r
-              NewList = malloc (sizeof (WCHAR_MATCHING_STRING_LIST));\r
-              if (NewList == NULL) {\r
-                Error (NULL, 0, 0, "memory allocation error", NULL);\r
-                goto Done;\r
-              }\r
-\r
-              memset (NewList, 0, sizeof (WCHAR_MATCHING_STRING_LIST));\r
-              NewList->Str1 = (WCHAR *) malloc ((strlen (StringName) + 1) * sizeof (WCHAR));\r
-              NewList->Str2 = (WCHAR *) malloc ((strlen (ScopeName) + 1) * sizeof (WCHAR));\r
-              if ((NewList->Str1 == NULL) || (NewList->Str2 == NULL)) {\r
-                Error (NULL, 0, 0, "memory allocation error", NULL);\r
-                goto Done;\r
-              }\r
-\r
-              UnicodeSPrint (NewList->Str1, strlen (StringName) + 1, L"%a", StringName);\r
-              UnicodeSPrint (NewList->Str2, strlen (ScopeName) + 1, L"%a", ScopeName);\r
-              if (mGlobals.IndirectionList == NULL) {\r
-                mGlobals.IndirectionList = NewList;\r
-              } else {\r
-                mGlobals.LastIndirectionList->Next = NewList;\r
-              }\r
-\r
-              mGlobals.LastIndirectionList = NewList;\r
-            } else {\r
-              Error (Files->Str, LineCount, 0, StringName, "invalid line : expected 'StringIdentifier Scope'");\r
-              goto Done;\r
-            }\r
-          } else {\r
-            Error (Files->Str, LineCount, 0, StringName, "invalid line : expected 'StringIdentifier Scope'");\r
-            goto Done;\r
-          }\r
-        } else {\r
-          Error (Files->Str, LineCount, 0, StringName, "invalid string identifier");\r
-          goto Done;\r
-        }\r
-      }\r
-    }\r
-\r
-    fclose (Fptr);\r
-    Fptr  = NULL;\r
-    Files = Files->Next;\r
-  }\r
-\r
-Done:\r
-  if (Fptr != NULL) {\r
-    fclose (Fptr);\r
-    return STATUS_ERROR;\r
-  }\r
-\r
-  return STATUS_SUCCESS;\r
-}\r
-\r
-static\r
-STATUS\r
-ScanFiles (\r
-  TEXT_STRING_LIST *ScanFiles\r
-  )\r
-{\r
-  char              Line[MAX_LINE_LEN];\r
-  FILE              *Fptr;\r
-  UINT32            LineNum;\r
-  char              *Cptr;\r
-  char              *SavePtr;\r
-  char              *TermPtr;\r
-  char              *StringTokenPos;\r
-  TEXT_STRING_LIST  *SList;\r
-  BOOLEAN           SkipIt;\r
-\r
-  //\r
-  // Put a null-terminator at the end of the line. If we read in\r
-  // a line longer than we support, then we can catch it.\r
-  //\r
-  Line[MAX_LINE_LEN - 1] = 0;\r
-  //\r
-  // Process each file. If they gave us a skip extension list, then\r
-  // skip it if the extension matches.\r
-  //\r
-  while (ScanFiles != NULL) {\r
-    SkipIt = FALSE;\r
-    for (SList = mGlobals.SkipExt; SList != NULL; SList = SList->Next) {\r
-      if ((strlen (ScanFiles->Str) > strlen (SList->Str)) &&\r
-          (strcmp (ScanFiles->Str + strlen (ScanFiles->Str) - strlen (SList->Str), SList->Str) == 0)\r
-          ) {\r
-        SkipIt = TRUE;\r
-        //\r
-        // printf ("Match: %s : %s\n", ScanFiles->Str, SList->Str);\r
-        //\r
-        break;\r
-      }\r
-    }\r
-\r
-    if (!SkipIt) {\r
-      if (mGlobals.VerboseScan) {\r
-        printf ("Scanning %s\n", ScanFiles->Str);\r
-      }\r
-\r
-      Fptr = fopen (ScanFiles->Str, "r");\r
-      if (Fptr == NULL) {\r
-        Error (NULL, 0, 0, ScanFiles->Str, "failed to open input file for scanning");\r
-        return STATUS_ERROR;\r
-      }\r
-\r
-      LineNum = 0;\r
-      while (fgets (Line, sizeof (Line), Fptr) != NULL) {\r
-        LineNum++;\r
-        if (Line[MAX_LINE_LEN - 1] != 0) {\r
-          Error (ScanFiles->Str, LineNum, 0, "line length exceeds maximum supported by tool", NULL);\r
-          fclose (Fptr);\r
-          return STATUS_ERROR;\r
-        }\r
-        //\r
-        // Remove the newline from the input line so we can print a warning message\r
-        //\r
-        if (Line[strlen (Line) - 1] == '\n') {\r
-          Line[strlen (Line) - 1] = 0;\r
-        }\r
-        //\r
-        // Terminate the line at // comments\r
-        //\r
-        Cptr = strstr (Line, "//");\r
-        if (Cptr != NULL) {\r
-          *Cptr = 0;\r
-        }\r
-\r
-        Cptr = Line;\r
-        while ((Cptr = strstr (Cptr, STRING_TOKEN)) != NULL) {\r
-          //\r
-          // Found "STRING_TOKEN". Make sure we don't have NUM_STRING_TOKENS or\r
-          // something like that. Then make sure it's followed by\r
-          // an open parenthesis, a string identifier, and then a closing\r
-          // parenthesis.\r
-          //\r
-          if (mGlobals.VerboseScan) {\r
-            printf (" %d: %s", LineNum, Cptr);\r
-          }\r
-\r
-          if (((Cptr == Line) || (!IsValidIdentifierChar (*(Cptr - 1), FALSE))) &&\r
-              (!IsValidIdentifierChar (*(Cptr + sizeof (STRING_TOKEN) - 1), FALSE))\r
-              ) {\r
-            StringTokenPos  = Cptr;\r
-            SavePtr         = Cptr;\r
-            Cptr += strlen (STRING_TOKEN);\r
-            while (*Cptr && isspace (*Cptr) && (*Cptr != '(')) {\r
-              Cptr++;\r
-            }\r
-\r
-            if (*Cptr != '(') {\r
-              Warning (ScanFiles->Str, LineNum, 0, StringTokenPos, "expected "STRING_TOKEN "(identifier)");\r
-            } else {\r
-              //\r
-              // Skip over the open-parenthesis and find the next non-blank character\r
-              //\r
-              Cptr++;\r
-              while (isspace (*Cptr)) {\r
-                Cptr++;\r
-              }\r
-\r
-              SavePtr = Cptr;\r
-              if ((*Cptr == '_') || isalpha (*Cptr)) {\r
-                while ((*Cptr == '_') || (isalnum (*Cptr))) {\r
-                  Cptr++;\r
-                }\r
-\r
-                TermPtr = Cptr;\r
-                while (*Cptr && isspace (*Cptr)) {\r
-                  Cptr++;\r
-                }\r
-\r
-                if (*Cptr != ')') {\r
-                  Warning (ScanFiles->Str, LineNum, 0, StringTokenPos, "expected "STRING_TOKEN "(identifier)");\r
-                }\r
-\r
-                if (*TermPtr) {\r
-                  *TermPtr  = 0;\r
-                  Cptr      = TermPtr + 1;\r
-                } else {\r
-                  Cptr = TermPtr;\r
-                }\r
-                //\r
-                // Add the string identifier to the list of used strings\r
-                //\r
-                ParserSetPosition (ScanFiles->Str, LineNum);\r
-                StringDBSetStringReferenced (SavePtr, mGlobals.IgnoreNotFound);\r
-                if (mGlobals.VerboseScan) {\r
-                  printf ("...referenced %s", SavePtr);\r
-                }\r
-              } else {\r
-                Warning (ScanFiles->Str, LineNum, 0, StringTokenPos, "expected valid string identifier name");\r
-              }\r
-            }\r
-          } else {\r
-            //\r
-            // Found it, but it's a substring of something else. Advance our pointer.\r
-            //\r
-            Cptr++;\r
-          }\r
-\r
-          if (mGlobals.VerboseScan) {\r
-            printf ("\n");\r
-          }\r
-        }\r
-      }\r
-\r
-      fclose (Fptr);\r
-    } else {\r
-      //\r
-      // Skipping this file type\r
-      //\r
-      if (mGlobals.VerboseScan) {\r
-        printf ("Skip scanning of %s\n", ScanFiles->Str);\r
-      }\r
-    }\r
-\r
-    ScanFiles = ScanFiles->Next;\r
-  }\r
-\r
-  return STATUS_SUCCESS;\r
-}\r
-//\r
-// Free the global string lists we allocated memory for\r
-//\r
-static\r
-void\r
-FreeLists (\r
-  VOID\r
-  )\r
-{\r
-  TEXT_STRING_LIST  *Temp;\r
-  WCHAR_STRING_LIST *WTemp;\r
-\r
-  //\r
-  // Traverse the include paths, freeing each\r
-  //\r
-  while (mGlobals.IncludePaths != NULL) {\r
-    Temp = mGlobals.IncludePaths->Next;\r
-    free (mGlobals.IncludePaths->Str);\r
-    free (mGlobals.IncludePaths);\r
-    mGlobals.IncludePaths = Temp;\r
-  }\r
-  //\r
-  // If we did a scan, then free up our\r
-  // list of files to scan.\r
-  //\r
-  while (mGlobals.ScanFileName != NULL) {\r
-    Temp = mGlobals.ScanFileName->Next;\r
-    free (mGlobals.ScanFileName->Str);\r
-    free (mGlobals.ScanFileName);\r
-    mGlobals.ScanFileName = Temp;\r
-  }\r
-  //\r
-  // If they gave us a list of filename extensions to\r
-  // skip on scan, then free them up.\r
-  //\r
-  while (mGlobals.SkipExt != NULL) {\r
-    Temp = mGlobals.SkipExt->Next;\r
-    free (mGlobals.SkipExt->Str);\r
-    free (mGlobals.SkipExt);\r
-    mGlobals.SkipExt = Temp;\r
-  }\r
-  //\r
-  // Free up any languages specified\r
-  //\r
-  while (mGlobals.Language != NULL) {\r
-    WTemp = mGlobals.Language->Next;\r
-    free (mGlobals.Language->Str);\r
-    free (mGlobals.Language);\r
-    mGlobals.Language = WTemp;\r
-  }\r
-  //\r
-  // Free up our indirection list\r
-  //\r
-  while (mGlobals.IndirectionList != NULL) {\r
-    mGlobals.LastIndirectionList = mGlobals.IndirectionList->Next;\r
-    free (mGlobals.IndirectionList->Str1);\r
-    free (mGlobals.IndirectionList->Str2);\r
-    free (mGlobals.IndirectionList);\r
-    mGlobals.IndirectionList = mGlobals.LastIndirectionList;\r
-  }\r
-\r
-  while (mGlobals.IndirectionFileName != NULL) {\r
-    mGlobals.LastIndirectionFileName = mGlobals.IndirectionFileName->Next;\r
-    free (mGlobals.IndirectionFileName->Str);\r
-    free (mGlobals.IndirectionFileName);\r
-    mGlobals.IndirectionFileName = mGlobals.LastIndirectionFileName;\r
-  }\r
-}\r
-\r
-static\r
-BOOLEAN\r
-IsValidIdentifierChar (\r
-  CHAR8     Char,\r
-  BOOLEAN   FirstChar\r
-  )\r
-{\r
-  //\r
-  // If it's the first character of an identifier, then\r
-  // it must be one of [A-Za-z_].\r
-  //\r
-  if (FirstChar) {\r
-    if (isalpha (Char) || (Char == '_')) {\r
-      return TRUE;\r
-    }\r
-  } else {\r
-    //\r
-    // If it's not the first character, then it can\r
-    // be one of [A-Za-z_0-9]\r
-    //\r
-    if (isalnum (Char) || (Char == '_')) {\r
-      return TRUE;\r
-    }\r
-  }\r
-\r
-  return FALSE;\r
-}\r
-\r
-static\r
-void\r
-RewindFile (\r
-  SOURCE_FILE *SourceFile\r
-  )\r
-{\r
-  SourceFile->LineNum       = 1;\r
-  SourceFile->FileBufferPtr = SourceFile->FileBuffer;\r
-  SourceFile->EndOfFile     = 0;\r
-}\r
-\r
-static\r
-BOOLEAN\r
-SkipTo (\r
-  SOURCE_FILE *SourceFile,\r
-  WCHAR       WChar,\r
-  BOOLEAN     StopAfterNewline\r
-  )\r
-{\r
-  while (!EndOfFile (SourceFile)) {\r
-    //\r
-    // Check for the character of interest\r
-    //\r
-    if (SourceFile->FileBufferPtr[0] == WChar) {\r
-      return TRUE;\r
-    } else {\r
-      if (SourceFile->FileBufferPtr[0] == UNICODE_LF) {\r
-        SourceFile->LineNum++;\r
-        if (StopAfterNewline) {\r
-          SourceFile->FileBufferPtr++;\r
-          if (SourceFile->FileBufferPtr[0] == 0) {\r
-            SourceFile->FileBufferPtr++;\r
-          }\r
-\r
-          return FALSE;\r
-        }\r
-      }\r
-\r
-      SourceFile->FileBufferPtr++;\r
-    }\r
-  }\r
-\r
-  return FALSE;\r
-}\r
-\r
-static\r
-void\r
-Usage (\r
-  VOID\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Print usage information for this utility.\r
-  \r
-Arguments:\r
-\r
-  None.\r
-\r
-Returns:\r
-\r
-  Nothing.\r
-  \r
---*/\r
-{\r
-  int               Index;\r
-  static const char *Str[] = {\r
-    "",\r
-    PROGRAM_NAME " version "TOOL_VERSION " -- process unicode strings file",\r
-    "  Usage: "PROGRAM_NAME " -parse {parse options} [FileNames]",\r
-    "         "PROGRAM_NAME " -scan {scan options} [FileName]",\r
-    "         "PROGRAM_NAME " -dump {dump options}",\r
-    "    Common options include:",\r
-    "      -h or -?         for this help information",\r
-    "      -db Database     required name of output/input database file",\r
-    "      -bn BaseName     for use in the .h and .c output files",\r
-    "                       Default = "DEFAULT_BASE_NAME,\r
-    "      -v               for verbose output",\r
-    "      -vdbw            for verbose output when writing database",\r
-    "      -vdbr            for verbose output when reading database",\r
-    "      -od FileName     to specify an output database file name",\r
-    "    Parse options include:",\r
-    "      -i IncludePath   add IncludePath to list of search paths",\r
-    "      -newdb           to not read in existing database file",\r
-    "      -uqs             to indicate that unquoted strings are used",\r
-    "      FileNames        name of one or more unicode files to parse",\r
-    "    Scan options include:",\r
-    "      -scan            scan text file(s) for STRING_TOKEN() usage",\r
-    "      -skipext .ext    to skip scan of files with .ext filename extension",\r
-    "      -ignorenotfound  ignore if a given STRING_TOKEN(STR) is not ",\r
-    "                       found in the database",\r
-    "      FileNames        one or more files to scan",\r
-    "    Dump options include:",\r
-    "      -oc FileName     write string data to FileName",\r
-    "      -oh FileName     write string defines to FileName",\r
-    "      -ou FileName     dump database to unicode file FileName",\r
-    "      -lang Lang       only dump for the language 'Lang'",\r
-    "      -if FileName     to specify an indirection file",\r
-    "      -hpk FileName    to create an HII export pack of the strings",\r
-    "",\r
-    "  The expected process is to parse a unicode string file to create an initial",\r
-    "  database of string identifier names and string definitions. Then text files",\r
-    "  should be scanned for STRING_TOKEN() usages, and the referenced",\r
-    "  strings will be tagged as used in the database. After all files have been",\r
-    "  scanned, then the database should be dumped to create the necessary output",\r
-    "  files.",\r
-    "",\r
-    NULL\r
-  };\r
-  for (Index = 0; Str[Index] != NULL; Index++) {\r
-    fprintf (stdout, "%s\n", Str[Index]);\r
-  }\r
-}\r
diff --git a/Tools/CodeTools/TianoTools/StrGather/StrGather.h b/Tools/CodeTools/TianoTools/StrGather/StrGather.h
deleted file mode 100644 (file)
index 65dc15c..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2004, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-Module Name:\r
-\r
-  StrGather.h\r
-\r
-Abstract:\r
-\r
-  Common defines and prototypes for StrGather.\r
-  \r
---*/\r
-\r
-#ifndef _STR_GATHER_H_\r
-#define _STR_GATHER_H_\r
-\r
-#define MALLOC(size)  malloc (size)\r
-#define FREE(ptr)     free (ptr)\r
-\r
-#define PROGRAM_NAME  "StrGather"\r
-\r
-typedef CHAR16  WCHAR;\r
-\r
-#define UNICODE_TO_ASCII(w)   (INT8) ((w) & 0xFF)\r
-#define ASCII_TO_UNICODE(a)   (WCHAR) ((UINT8) (a))\r
-\r
-#define UNICODE_HASH          L'#'\r
-#define UNICODE_BACKSLASH     L'\\'\r
-#define UNICODE_SLASH         L'/'\r
-#define UNICODE_EQUAL_SIGN    L'='\r
-#define UNICODE_PLUS_SIGN     L'+'\r
-\r
-#define UNICODE_FILE_START    0xFEFF\r
-#define UNICODE_CR            0x000D\r
-#define UNICODE_LF            0x000A\r
-#define UNICODE_NULL          0x0000\r
-#define UNICODE_SPACE         L' '\r
-#define UNICODE_SLASH         L'/'\r
-#define UNICODE_DOUBLE_QUOTE  L'"'\r
-#define UNICODE_Z             L'Z'\r
-#define UNICODE_z             L'z'\r
-#define UNICODE_A             L'A'\r
-#define UNICODE_a             L'a'\r
-#define UNICODE_F             L'F'\r
-#define UNICODE_f             L'f'\r
-#define UNICODE_UNDERSCORE    L'_'\r
-#define UNICODE_0             L'0'\r
-#define UNICODE_9             L'9'\r
-#define UNICODE_TAB           L'\t'\r
-#define UNICODE_NBR_STRING    L"\\nbr"\r
-#define UNICODE_BR_STRING     L"\\br"\r
-#define UNICODE_WIDE_STRING   L"\\wide"\r
-#define UNICODE_NARROW_STRING L"\\narrow"\r
-\r
-//\r
-// This is the length of a valid string identifier\r
-//\r
-#define LANGUAGE_IDENTIFIER_NAME_LEN  3\r
-\r
-typedef struct _TEXT_STRING_LIST {\r
-  struct _TEXT_STRING_LIST  *Next;\r
-  CHAR8                     *Str;\r
-} TEXT_STRING_LIST;\r
-\r
-typedef struct _WCHAR_STRING_LIST {\r
-  struct _WCHAR_STRING_LIST *Next;\r
-  WCHAR                     *Str;\r
-} WCHAR_STRING_LIST;\r
-\r
-typedef struct _WCHAR_MATCHING_STRING_LIST {\r
-  struct _WCHAR_MATCHING_STRING_LIST  *Next;\r
-  WCHAR                               *Str1;\r
-  WCHAR                               *Str2;\r
-} WCHAR_MATCHING_STRING_LIST;\r
-\r
-#endif // #ifndef _STR_GATHER_H_\r
diff --git a/Tools/CodeTools/TianoTools/StrGather/StringDB.c b/Tools/CodeTools/TianoTools/StrGather/StringDB.c
deleted file mode 100644 (file)
index 16ef052..0000000
+++ /dev/null
@@ -1,2759 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2004, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-Module Name:\r
-\r
-  StringDB.c\r
-\r
-Abstract:\r
-\r
-  String database implementation\r
-  \r
---*/\r
-\r
-#include <stdio.h>\r
-#include <stdlib.h>\r
-#include <string.h>\r
-#include <ctype.h>  // for tolower()\r
-\r
-#include <Common/UefiBaseTypes.h>\r
-#include <Common/MultiPhase.h>\r
-#include <Common/InternalFormRepresentation.h>\r
-#include <Protocol/UgaDraw.h>  // for EFI_UGA_PIXEL definition\r
-#include <Protocol/Hii.h>\r
-\r
-#include "EfiUtilityMsgs.h"\r
-#include "StrGather.h"\r
-#include "StringDB.h"\r
-\r
-\r
-#define STRING_OFFSET RELOFST\r
-\r
-#define STRING_DB_KEY (('S' << 24) | ('D' << 16) | ('B' << 8) | 'K')\r
-//\r
-// Version supported by this tool\r
-//\r
-#define STRING_DB_VERSION             0x00010000\r
-\r
-#define STRING_DB_MAJOR_VERSION_MASK  0xFFFF0000\r
-#define STRING_DB_MINOR_VERSION_MASK  0x0000FFFF\r
-\r
-#define DEFINE_STR                    L"// #define"\r
-\r
-#define LANGUAGE_CODE_WIDTH           4\r
-//\r
-// This is the header that gets written to the top of the\r
-// output binary database file.\r
-//\r
-typedef struct {\r
-  UINT32  Key;\r
-  UINT32  HeaderSize;\r
-  UINT32  Version;\r
-  UINT32  NumStringIdenfiers;\r
-  UINT32  StringIdentifiersSize;\r
-  UINT32  NumLanguages;\r
-} STRING_DB_HEADER;\r
-\r
-//\r
-// When we write out data to the database, we have a UINT16 identifier, which\r
-// indicates what follows, followed by the data. Here's the structure.\r
-//\r
-typedef struct {\r
-  UINT16  DataType;\r
-  UINT16  Reserved;\r
-} DB_DATA_ITEM_HEADER;\r
-\r
-#define DB_DATA_TYPE_INVALID              0x0000\r
-#define DB_DATA_TYPE_STRING_IDENTIFIER    0x0001\r
-#define DB_DATA_TYPE_LANGUAGE_DEFINITION  0x0002\r
-#define DB_DATA_TYPE_STRING_DEFINITION    0x0003\r
-#define DB_DATA_TYPE_LAST                 DB_DATA_TYPE_STRING_DEFINITION\r
-\r
-//\r
-// We have to keep track of a list of languages, each of which has its own\r
-// list of strings. Define a structure to keep track of all languages and\r
-// their list of strings.\r
-//\r
-typedef struct _STRING_LIST {\r
-  struct _STRING_LIST *Next;\r
-  UINT32              Size;         // number of bytes in string, including null terminator\r
-  WCHAR               *LanguageName;\r
-  WCHAR               *StringName;  // for example STR_ID_TEXT1\r
-  WCHAR               *Scope;       //\r
-  WCHAR               *Str;         // the actual string\r
-  UINT16              Flags;        // properties of this string (used, undefined)\r
-} STRING_LIST;\r
-\r
-typedef struct _LANGUAGE_LIST {\r
-  struct _LANGUAGE_LIST *Next;\r
-  WCHAR                 LanguageName[4];\r
-  WCHAR                 *PrintableLanguageName;\r
-  STRING_LIST           *String;\r
-  STRING_LIST           *LastString;\r
-} LANGUAGE_LIST;\r
-\r
-//\r
-// We also keep track of all the string identifier names, which we assign unique\r
-// values to. Create a structure to keep track of them all.\r
-//\r
-typedef struct _STRING_IDENTIFIER {\r
-  struct _STRING_IDENTIFIER *Next;\r
-  UINT32                    Index;  // only need 16 bits, but makes it easier with UINT32\r
-  WCHAR                     *StringName;\r
-  UINT16                    Flags;  // if someone referenced it via STRING_TOKEN()\r
-} STRING_IDENTIFIER;\r
-//\r
-// Keep our globals in this structure to be as modular as possible.\r
-//\r
-typedef struct {\r
-  FILE              *StringDBFptr;\r
-  LANGUAGE_LIST     *LanguageList;\r
-  LANGUAGE_LIST     *LastLanguageList;\r
-  LANGUAGE_LIST     *CurrentLanguage;         // keep track of the last language they used\r
-  STRING_IDENTIFIER *StringIdentifier;\r
-  STRING_IDENTIFIER *LastStringIdentifier;\r
-  UINT8             *StringDBFileName;\r
-  UINT32            NumStringIdentifiers;\r
-  UINT32            NumStringIdentifiersReferenced;\r
-  STRING_IDENTIFIER *CurrentStringIdentifier; // keep track of the last string identifier they added\r
-  WCHAR             *CurrentScope;\r
-} STRING_DB_DATA;\r
-\r
-static STRING_DB_DATA mDBData;\r
-\r
-static const char     *mSourceFileHeader[] = {\r
-  "//",\r
-  "//  DO NOT EDIT -- auto-generated file",\r
-  "//",\r
-  "//  This file is generated by the string gather utility",\r
-  "//",\r
-  NULL\r
-};\r
-\r
-static\r
-STRING_LIST           *\r
-StringDBFindString (\r
-  WCHAR                       *LanguageName,\r
-  WCHAR                       *StringName,\r
-  WCHAR                       *Scope,\r
-  WCHAR_STRING_LIST           *LanguagesOfInterest,\r
-  WCHAR_MATCHING_STRING_LIST  *IndirectionList\r
-  );\r
-\r
-static\r
-STRING_IDENTIFIER     *\r
-StringDBFindStringIdentifierByName (\r
-  WCHAR *Name\r
-  );\r
-\r
-static\r
-STRING_IDENTIFIER     *\r
-StringDBFindStringIdentifierByIndex (\r
-  UINT32    Index\r
-  );\r
-\r
-static\r
-LANGUAGE_LIST         *\r
-StringDBFindLanguageList (\r
-  WCHAR *LanguageName\r
-  );\r
-\r
-static\r
-void\r
-StringDBWriteStandardFileHeader (\r
-  FILE *OutFptr\r
-  );\r
-\r
-static\r
-WCHAR                 *\r
-AsciiToWchar (\r
-  CHAR8 *Str\r
-  );\r
-\r
-static\r
-WCHAR                 *\r
-DuplicateString (\r
-  WCHAR   *Str\r
-  );\r
-\r
-static\r
-STATUS\r
-StringDBWriteStringIdentifier (\r
-  FILE                *DBFptr,\r
-  UINT16              StringId,\r
-  UINT16              Flags,\r
-  WCHAR               *IdentifierName\r
-  );\r
-\r
-static\r
-STATUS\r
-StringDBReadStringIdentifier (\r
-  FILE                *DBFptr\r
-  );\r
-\r
-static\r
-STATUS\r
-StringDBWriteLanguageDefinition (\r
-  FILE            *DBFptr,\r
-  WCHAR           *LanguageName,\r
-  WCHAR           *PrintableLanguageName\r
-  );\r
-\r
-static\r
-STATUS\r
-StringDBReadLanguageDefinition (\r
-  FILE            *DBFptr\r
-  );\r
-\r
-static\r
-STATUS\r
-StringDBWriteString (\r
-  FILE            *DBFptr,\r
-  UINT16          Flags,\r
-  WCHAR           *Language,\r
-  WCHAR           *StringName,\r
-  WCHAR           *Scope,\r
-  WCHAR           *Str\r
-  );\r
-\r
-static\r
-STATUS\r
-StringDBReadString (\r
-  FILE            *DBFptr\r
-  );\r
-\r
-static\r
-STATUS\r
-StringDBReadGenericString (\r
-  FILE      *DBFptr,\r
-  UINT16    *Size,\r
-  WCHAR     **Str\r
-  );\r
-\r
-static\r
-STATUS\r
-StringDBWriteGenericString (\r
-  FILE      *DBFptr,\r
-  WCHAR     *Str\r
-  );\r
-\r
-static\r
-void\r
-StringDBAssignStringIndexes (\r
-  VOID\r
-  );\r
-\r
-/*****************************************************************************/\r
-\r
-/*++\r
-\r
-Routine Description:\r
-  Constructor function for the string database handler.\r
-\r
-Arguments:\r
-  None.\r
-\r
-Returns:\r
-  None.\r
-\r
---*/\r
-void\r
-StringDBConstructor (\r
-  VOID\r
-  )\r
-{\r
-  memset ((char *) &mDBData, 0, sizeof (STRING_DB_DATA));\r
-  mDBData.CurrentScope = DuplicateString (L"NULL");\r
-}\r
-\r
-/*****************************************************************************/\r
-\r
-/*++\r
-\r
-Routine Description:\r
-  Destructor function for the string database handler.\r
-\r
-Arguments:\r
-  None.\r
-\r
-Returns:\r
-  None.\r
-\r
---*/\r
-void\r
-StringDBDestructor (\r
-  VOID\r
-  )\r
-{\r
-  LANGUAGE_LIST     *NextLang;\r
-  STRING_LIST       *NextStr;\r
-  STRING_IDENTIFIER *NextIdentifier;\r
-  //\r
-  // Close the database file if it's open\r
-  //\r
-  if (mDBData.StringDBFptr != NULL) {\r
-    fclose (mDBData.StringDBFptr);\r
-    mDBData.StringDBFptr = NULL;\r
-  }\r
-  //\r
-  // If we've allocated any strings/languages, free them up\r
-  //\r
-  while (mDBData.LanguageList != NULL) {\r
-    NextLang = mDBData.LanguageList->Next;\r
-    //\r
-    // Free up all strings for this language\r
-    //\r
-    while (mDBData.LanguageList->String != NULL) {\r
-      NextStr = mDBData.LanguageList->String->Next;\r
-      FREE (mDBData.LanguageList->String->Str);\r
-      FREE (mDBData.LanguageList->String);\r
-      mDBData.LanguageList->String = NextStr;\r
-    }\r
-\r
-    FREE (mDBData.LanguageList->PrintableLanguageName);\r
-    FREE (mDBData.LanguageList);\r
-    mDBData.LanguageList = NextLang;\r
-  }\r
-  //\r
-  // Free up string identifiers\r
-  //\r
-  while (mDBData.StringIdentifier != NULL) {\r
-    NextIdentifier = mDBData.StringIdentifier->Next;\r
-    FREE (mDBData.StringIdentifier->StringName);\r
-    FREE (mDBData.StringIdentifier);\r
-    mDBData.StringIdentifier = NextIdentifier;\r
-  }\r
-  //\r
-  // Free the filename\r
-  //\r
-  if (mDBData.StringDBFileName != NULL) {\r
-    FREE (mDBData.StringDBFileName);\r
-    mDBData.StringDBFileName = NULL;\r
-  }\r
-  //\r
-  // We save a copy of the scope, so free it up if we\r
-  // have one.\r
-  //\r
-  if (mDBData.CurrentScope != NULL) {\r
-    FREE (mDBData.CurrentScope);\r
-    mDBData.CurrentScope = NULL;\r
-  }\r
-}\r
-\r
-/*****************************************************************************/\r
-\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Dump the contents of a database to an output C file.\r
-\r
-Arguments:\r
-\r
-  FileName        - name of the output file to write \r
-  BaseName        - used for the name of the C array defined\r
-  Languages       - list of languages of interest\r
-\r
-Returns:\r
-\r
-  STATUS\r
-\r
-Notes:\r
-\r
-  Languages is a pointer to a linked list of languages specified on\r
-  the command line. Format is "eng" and "spa+cat". For this, print\r
-  the strings for eng. Print the strings for spa too, but if one is\r
-  missing look for a cat string and print if it it exists.\r
-\r
---*/\r
-STATUS\r
-StringDBDumpCStrings (\r
-  CHAR8                       *FileName,\r
-  CHAR8                       *BaseName,\r
-  WCHAR_STRING_LIST           *LanguagesOfInterest,\r
-  WCHAR_MATCHING_STRING_LIST  *IndirectionList\r
-  )\r
-{\r
-  FILE                        *Fptr;\r
-  LANGUAGE_LIST               *Lang;\r
-  STRING_LIST                 *CurrString;\r
-  STRING_LIST                 EmptyString;\r
-  UINT32                      Offset;\r
-  UINT32                      StringIndex;\r
-  UINT32                      TempIndex;\r
-  UINT32                      BytesThisLine;\r
-  EFI_HII_STRING_PACK         StringPack;\r
-  UINT8                       *Ptr;\r
-  UINT32                      Len;\r
-  WCHAR                       ZeroString[1];\r
-  WCHAR_STRING_LIST           *LOIPtr;\r
-  BOOLEAN                     LanguageOk;\r
-  WCHAR                       *TempStringPtr;\r
-  WCHAR                       *LangName;\r
-  STRING_IDENTIFIER           *StringIdentifier;\r
-  WCHAR                       Line[200];\r
-\r
-  if ((Fptr = fopen (FileName, "w")) == NULL) {\r
-    Error (NULL, 0, 0, FileName, "failed to open output C string file");\r
-    return STATUS_ERROR;\r
-  }\r
-  //\r
-  // Assign index values to the string identifiers\r
-  //\r
-  StringDBAssignStringIndexes ();\r
-  //\r
-  // Write the standard header to the output file, then the structure\r
-  // definition header.\r
-  //\r
-  StringDBWriteStandardFileHeader (Fptr);\r
-  fprintf (Fptr, "\nunsigned char %s[] = {\n", BaseName);\r
-  //\r
-  // If a given string is not defined, then we'll use this one.\r
-  //\r
-  memset (&EmptyString, 0, sizeof (EmptyString));\r
-  EmptyString.Size  = sizeof (ZeroString);\r
-  EmptyString.Str   = ZeroString;\r
-  //\r
-  // Process each language, then each string for each langage\r
-  //\r
-  ZeroString[0] = 0;\r
-  for (Lang = mDBData.LanguageList; Lang != NULL; Lang = Lang->Next) {\r
-    //\r
-    // If we have a language list, then make sure this language is in that\r
-    // list.\r
-    //\r
-    LanguageOk  = TRUE;\r
-    LangName    = Lang->LanguageName;\r
-    if (LanguagesOfInterest != NULL) {\r
-      LanguageOk = FALSE;\r
-      for (LOIPtr = LanguagesOfInterest; LOIPtr != NULL; LOIPtr = LOIPtr->Next) {\r
-        if (StrnCmp (LOIPtr->Str, Lang->LanguageName, LANGUAGE_IDENTIFIER_NAME_LEN) == 0) {\r
-          LangName    = LOIPtr->Str;\r
-          LanguageOk  = TRUE;\r
-          break;\r
-        }\r
-      }\r
-    }\r
-\r
-    if (!LanguageOk) {\r
-      continue;\r
-    }\r
-    //\r
-    // Process each string for this language. We have to make 3 passes on the strings:\r
-    //   Pass1: computes sizes and fill in the string pack header\r
-    //   Pass2: write the array of offsets\r
-    //   Pass3: write the strings\r
-    //\r
-    //\r
-    // PASS 1: Fill in and print the HII string pack header\r
-    //\r
-    // Compute the size for this language package and write\r
-    // the header out. Each string package contains:\r
-    //   Header\r
-    //   Offset[]  -- an array of offsets to strings, of type RELOFST each\r
-    //   String[]  -- the actual strings themselves\r
-    //\r
-    AsciiSPrint ( Line, sizeof(Line),\r
-      "\n//******************************************************************************"\r
-      "\n// Start of string definitions for %s/%s",\r
-      Lang->LanguageName,\r
-      Lang->PrintableLanguageName\r
-      );\r
-    fprintf (Fptr, "%s", Line);\r
-    memset ((char *) &StringPack, 0, sizeof (EFI_HII_STRING_PACK));\r
-    StringPack.Header.Type        = EFI_HII_STRING;\r
-    StringPack.NumStringPointers  = (UINT16) mDBData.NumStringIdentifiersReferenced;\r
-    //\r
-    // First string is the language name. If we're printing all languages, then\r
-    // it's just the "spa". If we were given a list of languages to print, then it's\r
-    // the "spacat" string. Compute its offset and fill in\r
-    // the info in the header. Since we know the language name string's length,\r
-    // and the printable language name follows it, use that info to fill in the\r
-    // entry for the printable language name as well.\r
-    //\r
-    StringPack.LanguageNameString = (STRING_OFFSET) (sizeof (EFI_HII_STRING_PACK) + (mDBData.NumStringIdentifiersReferenced * sizeof (STRING_OFFSET)));\r
-    StringPack.PrintableLanguageName = (STRING_OFFSET) (StringPack.LanguageNameString + (StrLen (LangName) + 1) * sizeof (WCHAR));\r
-    //\r
-    // Add up the size of all strings so we can fill in our header.\r
-    //\r
-    Len = 0;\r
-    for (StringIndex = 0; StringIndex < mDBData.NumStringIdentifiersReferenced; StringIndex++) {\r
-      //\r
-      // For the first string (language name), we print out the "spacat" if they\r
-      // requested it. We set LangName to point to the proper language name string above.\r
-      //\r
-      if (StringIndex == STRING_ID_LANGUAGE_NAME) {\r
-        Len += (StrLen (LangName) + 1) * sizeof (WCHAR);\r
-      } else {\r
-        //\r
-        // Find a string with this language.stringname\r
-        //\r
-        StringIdentifier = StringDBFindStringIdentifierByIndex (StringIndex);\r
-        if (StringIdentifier == NULL) {\r
-          Error (NULL, 0, 0, "internal error", "invalid string index 0x%X", StringIndex);\r
-          return STATUS_ERROR;\r
-        }\r
-        //\r
-        // Find a matching string if this string identifier was referenced\r
-        //\r
-        EmptyString.Flags = STRING_FLAGS_UNDEFINED;\r
-        CurrString        = NULL;\r
-        if (StringIdentifier->Flags & STRING_FLAGS_REFERENCED) {\r
-          CurrString = StringDBFindString (\r
-                        Lang->LanguageName,\r
-                        StringIdentifier->StringName,\r
-                        NULL,\r
-                        LanguagesOfInterest,\r
-                        IndirectionList\r
-                        );\r
-          if (NULL == CurrString) {\r
-            //\r
-            // If string for Lang->LanguageName is not found, try to get an English version\r
-            //\r
-            CurrString = StringDBFindString (\r
-                          L"eng",\r
-                          StringIdentifier->StringName,\r
-                          NULL,\r
-                          LanguagesOfInterest,\r
-                          IndirectionList\r
-                          );\r
-          }\r
-        }\r
-\r
-        if (CurrString == NULL) {\r
-          CurrString = &EmptyString;\r
-          EmptyString.Flags |= StringIdentifier->Flags;\r
-        }\r
-\r
-        Len += CurrString->Size;\r
-      }\r
-    }\r
-    StringPack.Header.Length =    sizeof (EFI_HII_STRING_PACK) \r
-                                + mDBData.NumStringIdentifiersReferenced * sizeof (STRING_OFFSET) \r
-                                + Len;\r
-    //\r
-    // Write out the header one byte at a time\r
-    //\r
-    Ptr = (UINT8 *) &StringPack;\r
-    for (TempIndex = 0; TempIndex < sizeof (EFI_HII_STRING_PACK); TempIndex++, Ptr++) {\r
-      if ((TempIndex & 0x07) == 0) {\r
-        fprintf (Fptr, "\n  ");\r
-      }\r
-\r
-      fprintf (Fptr, "0x%02X, ", (UINT32) *Ptr);\r
-    }\r
-\r
-    fprintf (Fptr, "\n  // offset 0x%X\n", sizeof (StringPack));\r
-    //\r
-    // PASS2 : write the offsets\r
-    //\r
-    // Traverse the list of strings again and write the array of offsets. The\r
-    // offset to the first string is the size of the string pack header\r
-    // plus the size of the offsets array. The other strings follow it.\r
-    //\r
-    StringIndex = 0;\r
-    Offset      = sizeof (StringPack) + mDBData.NumStringIdentifiersReferenced * sizeof (STRING_OFFSET);\r
-    for (StringIndex = 0; StringIndex < mDBData.NumStringIdentifiersReferenced; StringIndex++) {\r
-      //\r
-      // Write the offset, followed by a useful comment\r
-      //\r
-      fprintf (Fptr, "  ");\r
-      Ptr = (UINT8 *) &Offset;\r
-      for (TempIndex = 0; TempIndex < sizeof (STRING_OFFSET); TempIndex++) {\r
-        fprintf (Fptr, "0x%02X, ", (UINT32) Ptr[TempIndex]);\r
-      }\r
-      //\r
-      // Find the string name\r
-      //\r
-      StringIdentifier = StringDBFindStringIdentifierByIndex (StringIndex);\r
-      if (StringIdentifier == NULL) {\r
-        Error (NULL, 0, 0, "internal error", "invalid string index 0x%X", StringIndex);\r
-        return STATUS_ERROR;\r
-      }\r
-\r
-      AsciiSPrint (Line, sizeof(Line) , " // offset to string %s (0x%04X)", StringIdentifier->StringName, StringIndex);\r
-      fprintf (Fptr, "%s", Line);\r
-      //\r
-      // For the first string (language name), we print out the "spacat" if they\r
-      // requested it. We set LangName to point to the proper language name string above.\r
-      //\r
-      if (StringIndex == STRING_ID_LANGUAGE_NAME) {\r
-        Offset += (StrLen (LangName) + 1) * sizeof (WCHAR);\r
-        CurrString = StringDBFindString (\r
-                      Lang->LanguageName,\r
-                      StringIdentifier->StringName,\r
-                      NULL, // scope\r
-                      NULL,\r
-                      NULL\r
-                      );\r
-      } else {\r
-        //\r
-        // Find a matching string\r
-        //\r
-        CurrString = StringDBFindString (\r
-                      Lang->LanguageName,\r
-                      StringIdentifier->StringName,\r
-                      NULL,   // scope\r
-                      LanguagesOfInterest,\r
-                      IndirectionList\r
-                      );\r
-\r
-        if (NULL == CurrString) {\r
-          CurrString = StringDBFindString (\r
-                        L"eng",\r
-                        StringIdentifier->StringName,\r
-                        NULL, // scope\r
-                        LanguagesOfInterest,\r
-                        IndirectionList\r
-                        );\r
-        }\r
-\r
-        EmptyString.LanguageName = Lang->LanguageName;\r
-        if (CurrString == NULL) {\r
-          CurrString        = &EmptyString;\r
-          EmptyString.Flags = STRING_FLAGS_UNDEFINED;\r
-        } else if ((StringIdentifier->Flags & STRING_FLAGS_REFERENCED) == 0) {\r
-          CurrString        = &EmptyString;\r
-          EmptyString.Flags = 0;\r
-        }\r
-\r
-        Offset += CurrString->Size;\r
-      }\r
-      //\r
-      // Print useful info about this string\r
-      //\r
-      if ((StringIdentifier->Flags & STRING_FLAGS_REFERENCED) == 0) {\r
-        fprintf (Fptr, " - not referenced");\r
-      }\r
-\r
-      if (CurrString->Flags & STRING_FLAGS_UNDEFINED) {\r
-        fprintf (Fptr, " - not defined for this language");\r
-      } else if (StrCmp (CurrString->LanguageName, Lang->LanguageName) != 0) {\r
-        AsciiSPrint (\r
-          Line, sizeof(Line),\r
-          " - not defined for this language -- using secondary language %s definition",\r
-          CurrString->LanguageName\r
-          );\r
-        fprintf ( Fptr, "%s", Line);\r
-      }\r
-\r
-      fprintf (Fptr, "\n");\r
-    }\r
-    //\r
-    // For unreferenced string identifiers, print a message that they are not referenced anywhere\r
-    //\r
-    while (StringIndex < mDBData.NumStringIdentifiers) {\r
-      StringIdentifier = StringDBFindStringIdentifierByIndex (StringIndex);\r
-      if (StringIdentifier != NULL) {\r
-        AsciiSPrint (Line, sizeof(Line), "  // %s not referenced\n", StringIdentifier->StringName);\r
-        fprintf (Fptr, "%s", Line);\r
-      }\r
-\r
-      StringIndex++;\r
-    }\r
-\r
-    //\r
-    // PASS 3: write the strings themselves.\r
-    // Keep track of how many bytes we write per line because some editors\r
-    // (Visual Studio for instance) can't handle too long of lines.\r
-    //\r
-    Offset = sizeof (StringPack) + mDBData.NumStringIdentifiersReferenced * sizeof (STRING_OFFSET);\r
-    for (StringIndex = 0; StringIndex < mDBData.NumStringIdentifiersReferenced; StringIndex++) {\r
-      StringIdentifier = StringDBFindStringIdentifierByIndex (StringIndex);\r
-      if (StringIdentifier == NULL) {\r
-        Error (NULL, 0, 0, "internal error", "invalid string index 0x%X", StringIndex);\r
-        return STATUS_ERROR;\r
-      }\r
-\r
-      AsciiSPrint (Line, sizeof(Line), "  // string %s offset 0x%08X\n  ", StringIdentifier->StringName, Offset);\r
-      fprintf (Fptr, "%s", Line);\r
-      //\r
-      // For the first string (language name), we print out the "spacat" if they\r
-      // requested it. We set LangName to point to the proper language name string above.\r
-      //\r
-      if (StringIndex == STRING_ID_LANGUAGE_NAME) {\r
-        TempStringPtr = LangName;\r
-      } else {\r
-        //\r
-        // Find a matching string if this string identifier was referenced\r
-        //\r
-        CurrString = NULL;\r
-        if (StringIdentifier->Flags & STRING_FLAGS_REFERENCED) {\r
-          CurrString = StringDBFindString (\r
-                        Lang->LanguageName,\r
-                        StringIdentifier->StringName,\r
-                        NULL,   // scope\r
-                        LanguagesOfInterest,\r
-                        IndirectionList\r
-                        );\r
-          if (NULL == CurrString) {\r
-            CurrString = StringDBFindString (\r
-                          L"eng",\r
-                          StringIdentifier->StringName,\r
-                          NULL, // scope\r
-                          LanguagesOfInterest,\r
-                          IndirectionList\r
-                          );\r
-          }\r
-        }\r
-\r
-        if (CurrString == NULL) {\r
-          CurrString = &EmptyString;\r
-        }\r
-\r
-        TempStringPtr = CurrString->Str;\r
-      }\r
-\r
-      BytesThisLine = 0;\r
-      for (TempIndex = 0; TempStringPtr[TempIndex] != 0; TempIndex++) {\r
-        fprintf (\r
-          Fptr,\r
-          "0x%02X, 0x%02X, ",\r
-          (UINT32) TempStringPtr[TempIndex] & 0xFF,\r
-          (UINT32) ((TempStringPtr[TempIndex] >> 8) & 0xFF)\r
-          );\r
-        BytesThisLine += 2;\r
-        Offset += 2;\r
-        //\r
-        // Let's say we only allow 14 per line\r
-        //\r
-        if (BytesThisLine > 14) {\r
-          fprintf (Fptr, "\n  ");\r
-          BytesThisLine = 0;\r
-        }\r
-      }\r
-      //\r
-      // Print NULL WCHAR at the end of this string.\r
-      //\r
-      fprintf (Fptr, "0x00, 0x00,\n");\r
-      Offset += 2;\r
-    }\r
-    //\r
-    // Sanity check the offset. Make sure our running offset is what we put in the\r
-    // string pack header.\r
-    //\r
-    if (StringPack.Header.Length != Offset) {\r
-      Error (\r
-        __FILE__,\r
-        __LINE__,\r
-        0,\r
-        "application error",\r
-        "stringpack size 0x%X does not match final size 0x%X",\r
-        StringPack.Header.Length,\r
-        Offset\r
-        );\r
-    }\r
-  }\r
-  //\r
-  // Print terminator string pack, closing brace and close the file.\r
-  // The size of 0 triggers to the consumer that this is the end.\r
-  //\r
-  memset ((char *) &StringPack, 0, sizeof (EFI_HII_STRING_PACK));\r
-  StringPack.Header.Type  = EFI_HII_STRING;\r
-  Ptr                     = (UINT8 *) &StringPack;\r
-  fprintf (Fptr, "\n  // strings terminator pack");\r
-  for (TempIndex = 0; TempIndex < sizeof (StringPack); TempIndex++, Ptr++) {\r
-    if ((TempIndex & 0x0F) == 0) {\r
-      fprintf (Fptr, "\n  ");\r
-    }\r
-\r
-    fprintf (Fptr, "0x%02X, ", (UINT32) *Ptr);\r
-  }\r
-\r
-  fprintf (Fptr, "\n};\n");\r
-  fclose (Fptr);\r
-  return STATUS_SUCCESS;\r
-}\r
-\r
-/*****************************************************************************/\r
-\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Dump the #define string names\r
-\r
-Arguments:\r
-\r
-  FileName        - name of the output file to write \r
-  BaseName        - used for the protection #ifndef/#endif \r
-\r
-Returns:\r
-\r
-  STATUS\r
-\r
---*/\r
-STATUS\r
-StringDBDumpStringDefines (\r
-  CHAR8 *FileName,\r
-  CHAR8 *BaseName\r
-  )\r
-{\r
-  FILE              *Fptr;\r
-  STRING_IDENTIFIER *Identifier;\r
-  CHAR8             CopyBaseName[100];\r
-  WCHAR             Line[200];\r
-  UINT32            Index;\r
-  const CHAR8       *StrDefHeader[] = {\r
-    "#ifndef _%s_STRINGS_DEFINE_H_\n",\r
-    "#define _%s_STRINGS_DEFINE_H_\n\n",\r
-    NULL\r
-  };\r
-\r
-  if ((Fptr = fopen (FileName, "w")) == NULL) {\r
-    Error (NULL, 0, 0, FileName, "failed to open output string defines file");\r
-    return STATUS_ERROR;\r
-  }\r
-  //\r
-  // Get the base source filename and convert to uppercase.\r
-  //\r
-  if (sizeof (CopyBaseName) <= strlen (BaseName) + 1) {\r
-    Error (NULL, 0, 0, "application error", "StringDBDumpStringDefines() string length insufficient");\r
-    return STATUS_ERROR;\r
-  }\r
-\r
-  strcpy (CopyBaseName, BaseName);\r
-  for (Index = 0; CopyBaseName[Index] != 0; Index++) {\r
-    if (islower (CopyBaseName[Index])) {\r
-      CopyBaseName[Index] = (INT8) toupper (CopyBaseName[Index]);\r
-    }\r
-  }\r
-  //\r
-  // Assign index values to the string identifiers\r
-  //\r
-  StringDBAssignStringIndexes ();\r
-  //\r
-  // Write the standard header to the output file, and then the\r
-  // protective #ifndef.\r
-  //\r
-  StringDBWriteStandardFileHeader (Fptr);\r
-  for (Index = 0; StrDefHeader[Index] != NULL; Index++) {\r
-    fprintf (Fptr, StrDefHeader[Index], CopyBaseName);\r
-  }\r
-  //\r
-  // Print all the #defines for the string identifiers. Print identifiers\r
-  // whose names start with '$' as comments. Add comments for string\r
-  // identifiers not used as well.\r
-  //\r
-  Identifier = mDBData.StringIdentifier;\r
-  while (Identifier != NULL) {\r
-    if (Identifier->StringName[0] == L'$') {\r
-      fprintf (Fptr, "// ");\r
-    }\r
-\r
-    if (Identifier->Flags & STRING_FLAGS_REFERENCED) {\r
-      AsciiSPrint (Line, sizeof(Line), "#define %-40s 0x%04X\n", Identifier->StringName, Identifier->Index);\r
-      fprintf (Fptr, "%s", Line);\r
-    } else {\r
-      AsciiSPrint (Line, sizeof(Line), "//#define %-40s 0x%04X // not referenced\n", Identifier->StringName, Identifier->Index);\r
-      fprintf (Fptr, "%s", Line);\r
-    }\r
-\r
-    Identifier = Identifier->Next;\r
-  }\r
-\r
-  fprintf (Fptr, "\n#endif\n");\r
-  fclose (Fptr);\r
-  return STATUS_SUCCESS;\r
-}\r
-\r
-/*****************************************************************************/\r
-\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Add a string identifier to the database.\r
-\r
-Arguments:\r
-\r
-  StringName      - name of the string identifier. For example "STR_MY_STRING"\r
-  NewId           - if an ID has been assigned\r
-  Flags           - characteristics for the identifier\r
-\r
-Returns:\r
-\r
-  STATUS\r
-\r
---*/\r
-STATUS\r
-StringDBAddStringIdentifier (\r
-  WCHAR     *StringName,\r
-  UINT16    *NewId,\r
-  UINT16    Flags\r
-  )\r
-{\r
-  STRING_IDENTIFIER *StringIdentifier;\r
-  STATUS            Status;\r
-  //\r
-  // If it was already used for some other language, then we don't\r
-  // need to add it. But set it to the current string identifier.\r
-  // The referenced bit is sticky.\r
-  //\r
-  Status            = STATUS_SUCCESS;\r
-  StringIdentifier  = StringDBFindStringIdentifierByName (StringName);\r
-  if (StringIdentifier != NULL) {\r
-    if (Flags & STRING_FLAGS_REFERENCED) {\r
-      StringIdentifier->Flags |= STRING_FLAGS_REFERENCED;\r
-    }\r
-\r
-    mDBData.CurrentStringIdentifier = StringIdentifier;\r
-    *NewId                          = (UINT16) StringIdentifier->Index;\r
-    return Status;\r
-  }\r
-\r
-  StringIdentifier = (STRING_IDENTIFIER *) MALLOC (sizeof (STRING_IDENTIFIER));\r
-  if (StringIdentifier == NULL) {\r
-    Error (NULL, 0, 0, NULL, "memory allocation error");\r
-    return STATUS_ERROR;\r
-  }\r
-\r
-  memset ((char *) StringIdentifier, 0, sizeof (STRING_IDENTIFIER));\r
-  StringIdentifier->StringName = (WCHAR *) malloc ((StrLen (StringName) + 1) * sizeof (WCHAR));\r
-  if (StringIdentifier->StringName == NULL) {\r
-    Error (NULL, 0, 0, NULL, "memory allocation error");\r
-    return STATUS_ERROR;\r
-  }\r
-\r
-  StrCpy (StringIdentifier->StringName, StringName);\r
-  if (*NewId != STRING_ID_INVALID) {\r
-    StringIdentifier->Index = *NewId;\r
-    StringIdentifier->Flags |= STRING_FLAGS_INDEX_ASSIGNED;\r
-    if (mDBData.NumStringIdentifiers <= StringIdentifier->Index) {\r
-      mDBData.NumStringIdentifiers = StringIdentifier->Index + 1;\r
-    }\r
-  } else {\r
-    StringIdentifier->Index = mDBData.NumStringIdentifiers++;\r
-  }\r
-\r
-  StringIdentifier->Flags |= Flags;\r
-  //\r
-  // Add it to our list of string identifiers\r
-  //\r
-  if (mDBData.StringIdentifier == NULL) {\r
-    mDBData.StringIdentifier = StringIdentifier;\r
-  } else {\r
-    mDBData.LastStringIdentifier->Next = StringIdentifier;\r
-  }\r
-\r
-  mDBData.LastStringIdentifier    = StringIdentifier;\r
-  mDBData.CurrentStringIdentifier = StringIdentifier;\r
-  *NewId                          = (UINT16) StringIdentifier->Index;\r
-  return Status;\r
-}\r
-\r
-/*****************************************************************************/\r
-\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Add a new string to the database.\r
-\r
-Arguments:\r
-\r
-  LanguageName    - "eng" or "spa" language name\r
-  StringName      - "STR_MY_TEXT" string name\r
-  Scope           - from the #scope statements in the string file\r
-  Format          - if we should format the string\r
-  Flags           - characteristic flags for the string\r
-\r
-Returns:\r
-\r
-  STATUS\r
-\r
-Notes:\r
-\r
-  Several of the fields can be "inherited" from the previous calls to\r
-  our database functions. For example, if scope is NULL here, then\r
-  we'll use the previous setting.\r
-\r
---*/\r
-STATUS\r
-StringDBAddString (\r
-  WCHAR   *LanguageName,\r
-  WCHAR   *StringName,\r
-  WCHAR   *Scope,\r
-  WCHAR   *String,\r
-  BOOLEAN Format,\r
-  UINT16  Flags\r
-  )\r
-{\r
-  LANGUAGE_LIST     *Lang;\r
-  UINT32            Size;\r
-  STRING_LIST       *Str;\r
-  UINT16            StringIndex;\r
-  WCHAR             TempLangName[4];\r
-  STRING_IDENTIFIER *StringIdentifier;\r
-\r
-  //\r
-  // Check that language name is exactly 3 characters, or emit an error.\r
-  // Truncate at 3 if it's longer, or make it 3 if it's shorter.\r
-  //\r
-  if (LanguageName != NULL) {\r
-    Size = StrLen (LanguageName);\r
-    if (Size != 3) {\r
-      ParserError (0, "invalid length for language name", "%S", LanguageName);\r
-      if (Size > 3) {\r
-        LanguageName[3] = 0;\r
-      } else {\r
-        //\r
-        // Make a local copy of the language name string, and extend to\r
-        // 3 characters since we make assumptions elsewhere in this program\r
-        // on the length.\r
-        //\r
-        StrCpy (TempLangName, LanguageName);\r
-        for (; Size < 3; Size++) {\r
-          TempLangName[Size] = L'?';\r
-        }\r
-\r
-        TempLangName[4] = 0;\r
-        LanguageName    = TempLangName;\r
-      }\r
-    }\r
-  }\r
-  //\r
-  // If they specified a language, make sure they've defined it already\r
-  // via a #langdef statement. Otherwise use the current default language.\r
-  //\r
-  if (LanguageName != NULL) {\r
-    Lang = StringDBFindLanguageList (LanguageName);\r
-    if (Lang == NULL) {\r
-      ParserError (0, "language not defined", "%S", LanguageName);\r
-      return STATUS_ERROR;\r
-    } else {\r
-      StringDBSetCurrentLanguage (LanguageName);\r
-    }\r
-  } else {\r
-    Lang = mDBData.CurrentLanguage;\r
-    if (Lang == NULL) {\r
-      //\r
-      // Have to call SetLanguage() first\r
-      //\r
-      ParserError (0, "no language defined", "%S", StringName);\r
-      return STATUS_ERROR;\r
-    }\r
-  }\r
-  //\r
-  // If they didn't define a string identifier, use the last string identifier\r
-  // added.\r
-  //\r
-  if (StringName == NULL) {\r
-    StringName = mDBData.CurrentStringIdentifier->StringName;\r
-    if (StringName == NULL) {\r
-      ParserError (0, "no string identifier previously specified", NULL);\r
-      return STATUS_ERROR;\r
-    }\r
-  }\r
-  //\r
-  // If scope was not specified, use the default setting\r
-  //\r
-  if (Scope != NULL) {\r
-    Scope = DuplicateString (Scope);\r
-  } else {\r
-    Scope = DuplicateString (mDBData.CurrentScope);\r
-  }\r
-  //\r
-  // printf ("Adding string: %S.%S.%S\n", Lang->LanguageName, StringName, Scope);\r
-  //\r
-  // Check for duplicates for this Language.StringName.Scope. Allow multiple\r
-  // definitions of the language name and printable language name, since the\r
-  // user does not specifically define them.\r
-  //\r
-  if (StringDBFindString (Lang->LanguageName, StringName, Scope, NULL, NULL) != NULL) {\r
-    if ((StrCmp (StringName, LANGUAGE_NAME_STRING_NAME) == 0) &&\r
-        (StrCmp (StringName, PRINTABLE_LANGUAGE_NAME_STRING_NAME) == 0)\r
-        ) {\r
-      ParserError (\r
-        0,\r
-        "string multiply defined",\r
-        "Language.Name.Scope = %S.%S.%S",\r
-        Lang->LanguageName,\r
-        StringName,\r
-        Scope\r
-        );\r
-      return STATUS_ERROR;\r
-    }\r
-  }\r
-\r
-  StringIndex = STRING_ID_INVALID;\r
-  if (StringDBAddStringIdentifier (StringName, &StringIndex, Flags) != STATUS_SUCCESS) {\r
-    return STATUS_ERROR;\r
-  }\r
-\r
-  StringIdentifier = StringDBFindStringIdentifierByName (StringName);\r
-  //\r
-  // Add this string to the end of the strings for this language.\r
-  //\r
-  Str = (STRING_LIST *) malloc (sizeof (STRING_LIST));\r
-  if (Str == NULL) {\r
-    Error (NULL, 0, 0, NULL, "memory allocation error");\r
-    return STATUS_ERROR;\r
-  }\r
-\r
-  memset ((char *) Str, 0, sizeof (STRING_LIST));\r
-  Size              = (StrLen (String) + 1) * sizeof (WCHAR);\r
-  Str->Flags        = Flags;\r
-  Str->Scope        = Scope;\r
-  Str->StringName   = StringIdentifier->StringName;\r
-  Str->LanguageName = DuplicateString (LanguageName);\r
-  Str->Str          = (WCHAR *) MALLOC (Size);\r
-  if (Str->Str == NULL) {\r
-    Error (NULL, 0, 0, NULL, "memory allocation error");\r
-    return STATUS_ERROR;\r
-  }\r
-  //\r
-  // If not formatting, just copy the string.\r
-  //\r
-  StrCpy (Str->Str, String);\r
-  if (Format) {\r
-    StringDBFormatString (Str->Str);\r
-  }\r
-  //\r
-  // Size may change after formatting. We set the size to\r
-  // the actual size of the string, including the null for\r
-  // easier processing later.\r
-  //\r
-  Str->Size = (StrLen (Str->Str) + 1) * sizeof (WCHAR);\r
-  if (Lang->String == NULL) {\r
-    Lang->String = Str;\r
-  } else {\r
-    Lang->LastString->Next = Str;\r
-  }\r
-\r
-  Lang->LastString = Str;\r
-  return STATUS_SUCCESS;\r
-}\r
-\r
-/*****************************************************************************/\r
-\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Given a language name, see if a language list for it has been defined\r
-\r
-Arguments:\r
-\r
-  LanguageName    - like "eng"\r
-\r
-Returns:\r
-\r
-  A pointer to the language list\r
-\r
---*/\r
-static\r
-LANGUAGE_LIST *\r
-StringDBFindLanguageList (\r
-  WCHAR *LanguageName\r
-  )\r
-{\r
-  LANGUAGE_LIST *Lang;\r
-\r
-  Lang = mDBData.LanguageList;\r
-  while (Lang != NULL) {\r
-    if (StrCmp (LanguageName, Lang->LanguageName) == 0) {\r
-      break;\r
-    }\r
-\r
-    Lang = Lang->Next;\r
-  }\r
-\r
-  return Lang;\r
-}\r
-\r
-/*****************************************************************************/\r
-STATUS\r
-StringDBSetCurrentLanguage (\r
-  WCHAR *LanguageName\r
-  )\r
-{\r
-  LANGUAGE_LIST *Lang;\r
-\r
-  Lang = StringDBFindLanguageList (LanguageName);\r
-  if (Lang == NULL) {\r
-    ParserError (0, "language not previously defined", "%S", LanguageName);\r
-    return STATUS_ERROR;\r
-  }\r
-\r
-  mDBData.CurrentLanguage = Lang;\r
-  return STATUS_SUCCESS;\r
-}\r
-\r
-/*****************************************************************************/\r
-STATUS\r
-StringDBAddLanguage (\r
-  WCHAR *LanguageName,\r
-  WCHAR *PrintableLanguageName\r
-  )\r
-{\r
-  LANGUAGE_LIST *Lang;\r
-  //\r
-  // Check for redefinitions\r
-  //\r
-  Lang = StringDBFindLanguageList (LanguageName);\r
-  if (Lang != NULL) {\r
-    //\r
-    // Better be the same printable name\r
-    //\r
-    if (StrCmp (PrintableLanguageName, Lang->PrintableLanguageName) != 0) {\r
-      ParserError (\r
-        0,\r
-        "language redefinition",\r
-        "%S:%S != %S:%S",\r
-        Lang->LanguageName,\r
-        Lang->PrintableLanguageName,\r
-        LanguageName,\r
-        PrintableLanguageName\r
-        );\r
-      return STATUS_ERROR;\r
-      //\r
-      //    } else {\r
-      //      ParserWarning (0, "benign language redefinition", "%S", PrintableLanguageName);\r
-      //      return STATUS_WARNING;\r
-      //\r
-    }\r
-  } else {\r
-    //\r
-    // Allocate memory to keep track of this new language\r
-    //\r
-    Lang = (LANGUAGE_LIST *) malloc (sizeof (LANGUAGE_LIST));\r
-    if (Lang == NULL) {\r
-      Error (NULL, 0, 0, NULL, "memory allocation error");\r
-      return STATUS_ERROR;\r
-    }\r
-\r
-    memset ((char *) Lang, 0, sizeof (LANGUAGE_LIST));\r
-    //\r
-    // Save the language name, then allocate memory to save the\r
-    // printable language name\r
-    //\r
-    StrCpy (Lang->LanguageName, LanguageName);\r
-    Lang->PrintableLanguageName = (WCHAR *) malloc ((StrLen (PrintableLanguageName) + 1) * sizeof (WCHAR));\r
-    if (Lang->PrintableLanguageName == NULL) {\r
-      Error (NULL, 0, 0, NULL, "memory allocation error");\r
-      return STATUS_ERROR;\r
-    }\r
-\r
-    StrCpy (Lang->PrintableLanguageName, PrintableLanguageName);\r
-\r
-    if (mDBData.LanguageList == NULL) {\r
-      mDBData.LanguageList = Lang;\r
-    } else {\r
-      mDBData.LastLanguageList->Next = Lang;\r
-    }\r
-\r
-    mDBData.LastLanguageList = Lang;\r
-  }\r
-  //\r
-  // Default is to make our active language this new one\r
-  //\r
-  StringDBSetCurrentLanguage (LanguageName);\r
-  //\r
-  // The first two strings for any language are the language name,\r
-  // followed by the printable language name. Add them and set them\r
-  // to referenced so they never get stripped out.\r
-  //\r
-  StringDBAddString (\r
-    LanguageName,\r
-    LANGUAGE_NAME_STRING_NAME,\r
-    NULL,\r
-    LanguageName,\r
-    FALSE,\r
-    STRING_FLAGS_REFERENCED\r
-    );\r
-  StringDBAddString (\r
-    LanguageName,\r
-    PRINTABLE_LANGUAGE_NAME_STRING_NAME,\r
-    NULL,\r
-    PrintableLanguageName,\r
-    FALSE,\r
-    STRING_FLAGS_REFERENCED\r
-    );\r
-  return STATUS_SUCCESS;\r
-}\r
-\r
-/*****************************************************************************/\r
-static\r
-STRING_IDENTIFIER *\r
-StringDBFindStringIdentifierByName (\r
-  WCHAR *StringName\r
-  )\r
-{\r
-  STRING_IDENTIFIER *Identifier;\r
-\r
-  Identifier = mDBData.StringIdentifier;\r
-  while (Identifier != NULL) {\r
-    if (StrCmp (StringName, Identifier->StringName) == 0) {\r
-      return Identifier;\r
-    }\r
-\r
-    Identifier = Identifier->Next;\r
-  }\r
-\r
-  return NULL;\r
-}\r
-\r
-static\r
-STRING_IDENTIFIER *\r
-StringDBFindStringIdentifierByIndex (\r
-  UINT32    StringIndex\r
-  )\r
-{\r
-  STRING_IDENTIFIER *Identifier;\r
-\r
-  Identifier = mDBData.StringIdentifier;\r
-  while (Identifier != NULL) {\r
-    if (Identifier->Index == StringIndex) {\r
-      return Identifier;\r
-    }\r
-\r
-    Identifier = Identifier->Next;\r
-  }\r
-\r
-  return NULL;\r
-}\r
-\r
-/*****************************************************************************/\r
-static\r
-void\r
-StringDBWriteStandardFileHeader (\r
-  FILE *OutFptr\r
-  )\r
-{\r
-  UINT32  TempIndex;\r
-  for (TempIndex = 0; mSourceFileHeader[TempIndex] != NULL; TempIndex++) {\r
-    fprintf (OutFptr, "%s\n", mSourceFileHeader[TempIndex]);\r
-  }\r
-}\r
-\r
-/*****************************************************************************/\r
-\r
-/*++\r
-\r
-Routine Description:\r
-  \r
-  Given a Unicode string from an input file, reformat the string to replace\r
-  backslash control sequences with the appropriate encoding.\r
-\r
-Arguments:\r
-\r
-  String        - pointer to string to reformat\r
-\r
-Returns:\r
-\r
-  Nothing\r
-\r
---*/\r
-void\r
-StringDBFormatString (\r
-  WCHAR   *String\r
-  )\r
-{\r
-  WCHAR *From;\r
-  WCHAR *To;\r
-  int   HexNibbles;\r
-  WCHAR HexValue;\r
-  //\r
-  // Go through the string and process any formatting characters\r
-  //\r
-  From  = String;\r
-  To    = String;\r
-  while (*From) {\r
-    if (*From == UNICODE_BACKSLASH) {\r
-      //\r
-      // First look for \wide and replace with the appropriate control character. Note that\r
-      // when you have "define STR L"ABC"", then sizeof(ABC) is 8 because the null char is\r
-      // counted. Make adjustments for this. We advance From below, so subtract 2 each time.\r
-      //\r
-      if (StrnCmp (From, UNICODE_WIDE_STRING, sizeof (UNICODE_WIDE_STRING) / sizeof (WCHAR) - 1) == 0) {\r
-        *To = WIDE_CHAR;\r
-        From += sizeof (UNICODE_WIDE_STRING) / sizeof (WCHAR) - 2;\r
-      } else if (StrnCmp (From, UNICODE_NARROW_STRING, sizeof (UNICODE_NARROW_STRING) / sizeof (WCHAR) - 1) == 0) {\r
-        //\r
-        // Found: \narrow\r
-        //\r
-        *To = NARROW_CHAR;\r
-        From += sizeof (UNICODE_NARROW_STRING) / sizeof (WCHAR) - 2;\r
-      } else if (StrnCmp (From, UNICODE_NBR_STRING, sizeof (UNICODE_NBR_STRING) / sizeof (WCHAR) - 1) == 0) {\r
-        //\r
-        // Found: \nbr\r
-        //\r
-        *To = NON_BREAKING_CHAR;\r
-        From += sizeof (UNICODE_NBR_STRING) / sizeof (WCHAR) - 2;\r
-      } else if (StrnCmp (From, UNICODE_BR_STRING, sizeof (UNICODE_BR_STRING) / sizeof (WCHAR) - 1) == 0) {\r
-        //\r
-        // Found: \br -- pass through untouched\r
-        //\r
-        *To = *From;\r
-      } else {\r
-        //\r
-        // Standard one-character control sequences such as \n, \r, \\, or \x\r
-        //\r
-        From++;\r
-        switch (*From) {\r
-        case ASCII_TO_UNICODE ('n'):\r
-          *To = UNICODE_CR;\r
-          To++;\r
-          *To = UNICODE_LF;\r
-          break;\r
-\r
-        //\r
-        // carriage return\r
-        //\r
-        case ASCII_TO_UNICODE ('r'):\r
-          *To = UNICODE_CR;\r
-          break;\r
-\r
-        //\r
-        // backslash\r
-        //\r
-        case UNICODE_BACKSLASH:\r
-          *To = UNICODE_BACKSLASH;\r
-          break;\r
-\r
-        //\r
-        // Tab\r
-        //\r
-        case ASCII_TO_UNICODE ('t'):\r
-          *To = UNICODE_TAB;\r
-          break;\r
-\r
-        //\r
-        // embedded double-quote\r
-        //\r
-        case UNICODE_DOUBLE_QUOTE:\r
-          *To = UNICODE_DOUBLE_QUOTE;\r
-          break;\r
-\r
-        //\r
-        // Hex Unicode character \x1234. We'll process up to 4 hex characters\r
-        //\r
-        case ASCII_TO_UNICODE ('x'):\r
-          HexValue = 0;\r
-          for (HexNibbles = 0; HexNibbles < 4; HexNibbles++) {\r
-            if ((From[1] >= UNICODE_0) && (From[1] <= UNICODE_9)) {\r
-              HexValue = (HexValue << 4) | (From[1] - UNICODE_0);\r
-            } else if ((From[1] >= UNICODE_a) && (From[1] <= UNICODE_f)) {\r
-              HexValue = (HexValue << 4) | (10 + From[1] - UNICODE_a);\r
-            } else if ((From[1] >= UNICODE_A) && (From[1] <= UNICODE_F)) {\r
-              HexValue = (HexValue << 4) | (10 + From[1] - UNICODE_A);\r
-            } else {\r
-              break;\r
-            }\r
-\r
-            From++;\r
-          }\r
-\r
-          if (HexNibbles == 0) {\r
-            ParserWarning (\r
-              0,\r
-              "expected at least one valid hex digit with \\x escaped character in string",\r
-              "\\%C",\r
-              *From\r
-              );\r
-          } else {\r
-            *To = HexValue;\r
-          }\r
-          break;\r
-\r
-        default:\r
-          *To = UNICODE_SPACE;\r
-          ParserWarning (0, "invalid escaped character in string", "\\%C", *From);\r
-          break;\r
-        }\r
-      }\r
-    } else {\r
-      *To = *From;\r
-    }\r
-\r
-    From++;\r
-    To++;\r
-  }\r
-\r
-  *To = 0;\r
-}\r
-\r
-/*****************************************************************************/\r
-STATUS\r
-StringDBReadDatabase (\r
-  CHAR8   *DBFileName,\r
-  BOOLEAN IgnoreIfNotExist,\r
-  BOOLEAN Verbose\r
-  )\r
-{\r
-  STRING_DB_HEADER    DbHeader;\r
-  STATUS              Status;\r
-  FILE                *DBFptr;\r
-  DB_DATA_ITEM_HEADER DataItemHeader;\r
-\r
-  Status  = STATUS_SUCCESS;\r
-  DBFptr  = NULL;\r
-  //\r
-  //  if (Verbose) {\r
-  //    fprintf (stdout, "Reading database file %s\n", DBFileName);\r
-  //  }\r
-  //\r
-  // Try to open the input file\r
-  //\r
-  if ((DBFptr = fopen (DBFileName, "rb")) == NULL) {\r
-    if (IgnoreIfNotExist) {\r
-      return STATUS_SUCCESS;\r
-    }\r
-\r
-    Error (NULL, 0, 0, DBFileName, "failed to open input database file for reading");\r
-    return STATUS_ERROR;\r
-  }\r
-  //\r
-  // Read and verify the database header\r
-  //\r
-  if (fread ((void *) &DbHeader, sizeof (STRING_DB_HEADER), 1, DBFptr) != 1) {\r
-    Error (NULL, 0, 0, DBFileName, "failed to read header from database file");\r
-    Status = STATUS_ERROR;\r
-    goto Finish;\r
-  }\r
-\r
-  if (DbHeader.Key != STRING_DB_KEY) {\r
-    Error (NULL, 0, 0, DBFileName, "invalid header in database file");\r
-    Status = STATUS_ERROR;\r
-    goto Finish;\r
-  }\r
-\r
-  if ((DbHeader.Version & STRING_DB_MAJOR_VERSION_MASK) != (STRING_DB_VERSION & STRING_DB_MAJOR_VERSION_MASK)) {\r
-    Error (NULL, 0, 0, DBFileName, "incompatible database file version -- rebuild clean");\r
-    Status = STATUS_ERROR;\r
-    goto Finish;\r
-  }\r
-  //\r
-  // Read remaining items\r
-  //\r
-  while (fread (&DataItemHeader, sizeof (DataItemHeader), 1, DBFptr) == 1) {\r
-    switch (DataItemHeader.DataType) {\r
-    case DB_DATA_TYPE_STRING_IDENTIFIER:\r
-      StringDBReadStringIdentifier (DBFptr);\r
-      break;\r
-\r
-    case DB_DATA_TYPE_LANGUAGE_DEFINITION:\r
-      StringDBReadLanguageDefinition (DBFptr);\r
-      break;\r
-\r
-    case DB_DATA_TYPE_STRING_DEFINITION:\r
-      StringDBReadString (DBFptr);\r
-      break;\r
-\r
-    default:\r
-      Error (\r
-        NULL,\r
-        0,\r
-        0,\r
-        "database corrupted",\r
-        "invalid data item type 0x%X at offset 0x%X",\r
-        (UINT32) DataItemHeader.DataType,\r
-        ftell (DBFptr) - sizeof (DataItemHeader)\r
-        );\r
-      Status = STATUS_ERROR;\r
-      goto Finish;\r
-    }\r
-  }\r
-\r
-Finish:\r
-  if (DBFptr != NULL) {\r
-    fclose (DBFptr);\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-/*****************************************************************************/\r
-\r
-/*++\r
-\r
-Routine Description:\r
-  \r
-  Write everything we know to the output database file. Write:\r
-\r
-  Database header\r
-  String identifiers[]\r
-  StringPacks[]\r
-\r
-Arguments:\r
-\r
-  DBFileName    - name of the file to write to\r
-  Verbose       - for debug purposes, print info messages along the way.\r
-\r
-Returns:\r
-\r
-  STATUS\r
-\r
---*/\r
-STATUS\r
-StringDBWriteDatabase (\r
-  CHAR8   *DBFileName,\r
-  BOOLEAN Verbose\r
-  )\r
-{\r
-  STRING_DB_HEADER  DbHeader;\r
-  UINT32            Counter;\r
-  UINT32            StrLength;\r
-  LANGUAGE_LIST     *Lang;\r
-  STRING_IDENTIFIER *StringIdentifier;\r
-  STRING_LIST       *StrList;\r
-  FILE              *DBFptr;\r
-\r
-  if (Verbose) {\r
-    fprintf (stdout, "Writing database %s\n", DBFileName);\r
-  }\r
-\r
-  if ((DBFptr = fopen (DBFileName, "wb")) == NULL) {\r
-    Error (NULL, 0, 0, DBFileName, "failed to open output database file for writing");\r
-    return STATUS_ERROR;\r
-  }\r
-  //\r
-  // Fill in and write the database header\r
-  //\r
-  memset (&DbHeader, 0, sizeof (STRING_DB_HEADER));\r
-  DbHeader.HeaderSize = sizeof (STRING_DB_HEADER);\r
-  DbHeader.Key        = STRING_DB_KEY;\r
-  DbHeader.Version    = STRING_DB_VERSION;\r
-  //\r
-  // Count the number of languages we have\r
-  //\r
-  for (Lang = mDBData.LanguageList; Lang != NULL; Lang = Lang->Next) {\r
-    DbHeader.NumLanguages++;\r
-  }\r
-  //\r
-  // Count up how many string identifiers we have, and total up the\r
-  // size of the names plus the size of the flags field we will\r
-  // write out too.\r
-  //\r
-  DbHeader.NumStringIdenfiers = mDBData.NumStringIdentifiers;\r
-  StringIdentifier            = mDBData.StringIdentifier;\r
-  for (Counter = 0; Counter < mDBData.NumStringIdentifiers; Counter++) {\r
-    StrLength = StrLen (StringIdentifier->StringName) + 1;\r
-    DbHeader.StringIdentifiersSize += StrLength * sizeof (WCHAR) + sizeof (StringIdentifier->Flags);\r
-    StringIdentifier = StringIdentifier->Next;\r
-  }\r
-\r
-  //\r
-  // Write the header\r
-  //\r
-  fwrite (&DbHeader, sizeof (STRING_DB_HEADER), 1, DBFptr);\r
-  if (Verbose) {\r
-    fprintf (stdout, "  Number of string identifiers  0x%04X\n", DbHeader.NumStringIdenfiers);\r
-    fprintf (stdout, "  Number of languages           %d\n", DbHeader.NumLanguages);\r
-  }\r
-  //\r
-  // Write the string identifiers\r
-  //\r
-  for (StringIdentifier = mDBData.StringIdentifier; StringIdentifier != NULL; StringIdentifier = StringIdentifier->Next) {\r
-    StringDBWriteStringIdentifier (\r
-      DBFptr,\r
-      (UINT16) StringIdentifier->Index,\r
-      StringIdentifier->Flags,\r
-      StringIdentifier->StringName\r
-      );\r
-  }\r
-  //\r
-  // Now write all the strings for each language\r
-  //\r
-  for (Lang = mDBData.LanguageList; Lang != NULL; Lang = Lang->Next) {\r
-    StringDBWriteLanguageDefinition (DBFptr, Lang->LanguageName, Lang->PrintableLanguageName);\r
-    for (StrList = Lang->String; StrList != NULL; StrList = StrList->Next) {\r
-      StringDBWriteString (\r
-        DBFptr,\r
-        StrList->Flags,\r
-        Lang->LanguageName,\r
-        StrList->StringName,\r
-        StrList->Scope,\r
-        StrList->Str\r
-        );\r
-    }\r
-  }\r
-\r
-  fclose (DBFptr);\r
-  return STATUS_SUCCESS;\r
-}\r
-\r
-STATUS\r
-StringDBSetStringReferenced (\r
-  CHAR8     *StringIdentifierName,\r
-  BOOLEAN   IgnoreNotFound\r
-  )\r
-{\r
-  STRING_IDENTIFIER *Id;\r
-  WCHAR             *WName;\r
-  STATUS            Status;\r
-  //\r
-  // See if it's already been defined.\r
-  //\r
-  Status  = STATUS_SUCCESS;\r
-  WName   = (WCHAR *) malloc ((strlen (StringIdentifierName) + 1) * sizeof (WCHAR));\r
-  UnicodeSPrint (WName, (strlen (StringIdentifierName) + 1) * sizeof (WCHAR), L"%a", StringIdentifierName);\r
-  Id = StringDBFindStringIdentifierByName (WName);\r
-  if (Id != NULL) {\r
-    Id->Flags |= STRING_FLAGS_REFERENCED;\r
-  } else {\r
-    if (IgnoreNotFound == 0) {\r
-      ParserWarning (0, StringIdentifierName, "string identifier not found in database");\r
-      Status = STATUS_WARNING;\r
-    }\r
-  }\r
-\r
-  free (WName);\r
-  return Status;\r
-}\r
-\r
-/*****************************************************************************/\r
-\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Dump the contents of a database to an output unicode file.\r
-\r
-Arguments:\r
-\r
-  DBFileName        - name of the pre-existing database file to read\r
-  OutputFileName    - name of the file to dump the database contents to\r
-  Verbose           - for printing of additional info useful for debugging\r
-\r
-Returns:\r
-\r
-  STATUS\r
-\r
-Notes:\r
-\r
-  There's some issue with the unicode printing routines. Therefore to \r
-  write to the output file properly, open it as binary and use fwrite.\r
-  Ideally we could open it with just L"w" and use fwprintf().\r
-\r
---*/\r
-STATUS\r
-StringDBDumpDatabase (\r
-  CHAR8               *DBFileName,\r
-  CHAR8               *OutputFileName,\r
-  BOOLEAN             Verbose\r
-  )\r
-{\r
-  LANGUAGE_LIST     *Lang;\r
-  STRING_IDENTIFIER *StringIdentifier;\r
-  STRING_LIST       *StrList;\r
-  FILE              *OutFptr;\r
-  WCHAR             WChar;\r
-  WCHAR             CrLf[2];\r
-  WCHAR             Line[200];\r
-  WCHAR             *Scope;\r
-  //\r
-  // This function assumes the database has already been read, and\r
-  // we're just dumping our internal data structures to a unicode file.\r
-  //\r
-  if (Verbose) {\r
-    fprintf (stdout, "Dumping database file %s\n", DBFileName);\r
-  }\r
-\r
-  OutFptr         = fopen (OutputFileName, "wb");\r
-  if (OutFptr == NULL) {\r
-    Error (NULL, 0, 0, OutputFileName, "failed to open output file for writing");\r
-    return STATUS_ERROR;\r
-  }\r
-\r
-  WChar = UNICODE_FILE_START;\r
-  fwrite (&WChar, sizeof (WCHAR), 1, OutFptr);\r
-  CrLf[1] = UNICODE_LF;\r
-  CrLf[0] = UNICODE_CR;\r
-  //\r
-  // The default control character is '/'. Make it '#' by writing\r
-  // "/=#" to the output file.\r
-  //\r
-  UnicodeSPrint (Line, sizeof(Line), L"/=#");\r
-  fwrite (Line, StrLen (Line) * sizeof (WCHAR), 1, OutFptr);\r
-  fwrite (&CrLf, sizeof (CrLf), 1, OutFptr);\r
-  fwrite (&CrLf, sizeof (CrLf), 1, OutFptr);\r
-  //\r
-  // Dump all the string identifiers and their values\r
-  //\r
-  StringDBAssignStringIndexes ();\r
-  for (StringIdentifier = mDBData.StringIdentifier; StringIdentifier != NULL; StringIdentifier = StringIdentifier->Next) {\r
-    //\r
-    // Write the "#define " string\r
-    //\r
-    if (StringIdentifier->Flags & STRING_FLAGS_REFERENCED) {\r
-      UnicodeSPrint (\r
-        Line,\r
-        sizeof(Line), L"%s %-60.60s 0x%04X",\r
-        DEFINE_STR,\r
-        StringIdentifier->StringName,\r
-        StringIdentifier->Index\r
-        );\r
-    } else {\r
-      UnicodeSPrint (\r
-        Line,\r
-        sizeof(Line), L"%s %-60.60s 0x%04X  // NOT REFERENCED",\r
-        DEFINE_STR,\r
-        StringIdentifier->StringName,\r
-        StringIdentifier->Index\r
-        );\r
-    }\r
-\r
-    fwrite (Line, StrLen (Line) * sizeof (WCHAR), 1, OutFptr);\r
-    fwrite (&CrLf, sizeof (CrLf), 1, OutFptr);\r
-  }\r
-\r
-  fwrite (&CrLf, sizeof (CrLf), 1, OutFptr);\r
-  //\r
-  // Now write all the strings for each language.\r
-  //\r
-  WChar = UNICODE_DOUBLE_QUOTE;\r
-  Scope = NULL;\r
-  for (Lang = mDBData.LanguageList; Lang != NULL; Lang = Lang->Next) {\r
-    fwrite (&CrLf, sizeof (CrLf), 1, OutFptr);\r
-    UnicodeSPrint (Line, sizeof(Line), L"#langdef %s \"%s\"", Lang->LanguageName, Lang->PrintableLanguageName);\r
-    fwrite (Line, StrLen (Line) * sizeof (WCHAR), 1, OutFptr);\r
-    fwrite (&CrLf, sizeof (CrLf), 1, OutFptr);\r
-    fwrite (&CrLf, sizeof (CrLf), 1, OutFptr);\r
-    //\r
-    // Now the strings (in double-quotes) for this language. Write\r
-    // #string STR_NAME  #language eng "string"\r
-    //\r
-    for (StrList = Lang->String; StrList != NULL; StrList = StrList->Next) {\r
-      //\r
-      // Print the internal flags for debug\r
-      //\r
-      UnicodeSPrint (Line, sizeof(Line), L"// flags=0x%02X", (UINT32) StrList->Flags);\r
-      fwrite (Line, StrLen (Line) * sizeof (WCHAR), 1, OutFptr);\r
-      fwrite (&CrLf, sizeof (CrLf), 1, OutFptr);\r
-      //\r
-      // Print the scope if changed\r
-      //\r
-      if ((Scope == NULL) || (StrCmp (Scope, StrList->Scope) != 0)) {\r
-        UnicodeSPrint (Line, sizeof(Line), L"#scope %s", StrList->Scope);\r
-        fwrite (Line, StrLen (Line) * sizeof (WCHAR), 1, OutFptr);\r
-        fwrite (&CrLf, sizeof (CrLf), 1, OutFptr);\r
-        Scope = StrList->Scope;\r
-      }\r
-\r
-      UnicodeSPrint (\r
-        Line,\r
-        sizeof(Line), L"#string %-50.50s #language %s \"",\r
-        StrList->StringName,\r
-        Lang->LanguageName\r
-        );\r
-      fwrite (Line, StrLen (Line) * sizeof (WCHAR), 1, OutFptr);\r
-      fwrite (StrList->Str, StrList->Size - sizeof (WCHAR), 1, OutFptr);\r
-      UnicodeSPrint (Line, sizeof(Line), L"\"");\r
-      fwrite (Line, StrLen (Line) * sizeof (WCHAR), 1, OutFptr);\r
-      fwrite (&CrLf, sizeof (CrLf), 1, OutFptr);\r
-    }\r
-  }\r
-\r
-  fclose (OutFptr);\r
-  return STATUS_SUCCESS;\r
-}\r
-\r
-/*****************************************************************************/\r
-\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Given a primary language, a string identifier number, and a list of\r
-  languages, find a secondary string.\r
-\r
-Arguments:\r
-\r
-  LanguageName      - primary language, like "spa"\r
-  StringId          - string index value\r
-  LanguageList      - linked list of "eng", "spa+cat",...\r
-\r
-Returns:\r
-\r
-  Pointer to a secondary string if found. NULL otherwise.\r
-\r
-Notes:\r
\r
-  Given: LanguageName "spa"   and  LanguageList "spa+cat", match the\r
-  "spa" and extract the "cat" and see if there is a string defined\r
-  for "cat".StringId.\r
-\r
---*/\r
-static\r
-STATUS\r
-StringDBWriteStringIdentifier (\r
-  FILE                *DBFptr,\r
-  UINT16              StringId,\r
-  UINT16              Flags,\r
-  WCHAR               *IdentifierName\r
-  )\r
-{\r
-  DB_DATA_ITEM_HEADER Hdr;\r
-  memset (&Hdr, 0, sizeof (DB_DATA_ITEM_HEADER));\r
-  Hdr.DataType = DB_DATA_TYPE_STRING_IDENTIFIER;\r
-  if (fwrite (&Hdr, sizeof (DB_DATA_ITEM_HEADER), 1, DBFptr) != 1) {\r
-    Error (NULL, 0, 0, "failed to write string to output database file", NULL);\r
-    return STATUS_ERROR;\r
-  }\r
-\r
-  if (fwrite (&StringId, sizeof (StringId), 1, DBFptr) != 1) {\r
-    Error (NULL, 0, 0, "failed to write StringId to output database", NULL);\r
-    return STATUS_ERROR;\r
-  }\r
-\r
-  if (fwrite (&Flags, sizeof (Flags), 1, DBFptr) != 1) {\r
-    Error (NULL, 0, 0, "failed to write StringId flags to output database", NULL);\r
-    return STATUS_ERROR;\r
-  }\r
-\r
-  if (StringDBWriteGenericString (DBFptr, IdentifierName) != STATUS_SUCCESS) {\r
-    return STATUS_ERROR;\r
-  }\r
-\r
-  return STATUS_SUCCESS;\r
-}\r
-\r
-static\r
-STATUS\r
-StringDBReadStringIdentifier (\r
-  FILE                *DBFptr\r
-  )\r
-{\r
-  WCHAR   *IdentifierName;\r
-  UINT16  Flags;\r
-  UINT16  StringId;\r
-  UINT16  Size;\r
-\r
-  if (fread (&StringId, sizeof (StringId), 1, DBFptr) != 1) {\r
-    Error (NULL, 0, 0, "failed to read StringId from database", NULL);\r
-    return STATUS_ERROR;\r
-  }\r
-\r
-  if (fread (&Flags, sizeof (Flags), 1, DBFptr) != 1) {\r
-    Error (NULL, 0, 0, "failed to read StringId flags from database", NULL);\r
-    return STATUS_ERROR;\r
-  }\r
-\r
-  if (StringDBReadGenericString (DBFptr, &Size, &IdentifierName) != STATUS_SUCCESS) {\r
-    return STATUS_ERROR;\r
-  }\r
-\r
-  StringDBAddStringIdentifier (IdentifierName, &StringId, Flags);\r
-  //\r
-  // printf ("STRID:  0x%04X %S\n", (UINT32)StringId, IdentifierName);\r
-  //\r
-  FREE (IdentifierName);\r
-  return STATUS_SUCCESS;\r
-}\r
-\r
-static\r
-STATUS\r
-StringDBWriteString (\r
-  FILE            *DBFptr,\r
-  UINT16          Flags,\r
-  WCHAR           *Language,\r
-  WCHAR           *StringName,\r
-  WCHAR           *Scope,\r
-  WCHAR           *Str\r
-  )\r
-{\r
-  DB_DATA_ITEM_HEADER Hdr;\r
-  memset (&Hdr, 0, sizeof (DB_DATA_ITEM_HEADER));\r
-  Hdr.DataType = DB_DATA_TYPE_STRING_DEFINITION;\r
-  if (fwrite (&Hdr, sizeof (DB_DATA_ITEM_HEADER), 1, DBFptr) != 1) {\r
-    Error (NULL, 0, 0, "failed to write string header to output database file", NULL);\r
-    return STATUS_ERROR;\r
-  }\r
-\r
-  if (fwrite (&Flags, sizeof (Flags), 1, DBFptr) != 1) {\r
-    Error (NULL, 0, 0, "failed to write string flags to output database", NULL);\r
-    return STATUS_ERROR;\r
-  }\r
-\r
-  if (StringDBWriteGenericString (DBFptr, Language) != STATUS_SUCCESS) {\r
-    return STATUS_ERROR;\r
-  }\r
-\r
-  if (StringDBWriteGenericString (DBFptr, StringName) != STATUS_SUCCESS) {\r
-    return STATUS_ERROR;\r
-  }\r
-\r
-  if (StringDBWriteGenericString (DBFptr, Scope) != STATUS_SUCCESS) {\r
-    return STATUS_ERROR;\r
-  }\r
-\r
-  if (StringDBWriteGenericString (DBFptr, Str) != STATUS_SUCCESS) {\r
-    return STATUS_ERROR;\r
-  }\r
-  //\r
-  // printf ("DBWriteString: %S.%S.%S\n", Language, StringName, Scope);\r
-  //\r
-  return STATUS_SUCCESS;\r
-}\r
-\r
-static\r
-STATUS\r
-StringDBReadString (\r
-  FILE            *DBFptr\r
-  )\r
-{\r
-  UINT16  Flags;\r
-  UINT16  Size;\r
-  WCHAR   *Language;\r
-  WCHAR   *StringName;\r
-  WCHAR   *Scope;\r
-  WCHAR   *Str;\r
-\r
-  if (fread (&Flags, sizeof (Flags), 1, DBFptr) != 1) {\r
-    Error (NULL, 0, 0, "failed to read string flags from database", NULL);\r
-    return STATUS_ERROR;\r
-  }\r
-\r
-  if (StringDBReadGenericString (DBFptr, &Size, &Language) != STATUS_SUCCESS) {\r
-    return STATUS_ERROR;\r
-  }\r
-\r
-  if (StringDBReadGenericString (DBFptr, &Size, &StringName) != STATUS_SUCCESS) {\r
-    return STATUS_ERROR;\r
-  }\r
-\r
-  if (StringDBReadGenericString (DBFptr, &Size, &Scope) != STATUS_SUCCESS) {\r
-    return STATUS_ERROR;\r
-  }\r
-\r
-  if (StringDBReadGenericString (DBFptr, &Size, &Str) != STATUS_SUCCESS) {\r
-    return STATUS_ERROR;\r
-  }\r
-  //\r
-  // If the first or second string (language name and printable language name),\r
-  // then skip them. They're added via language definitions data items in\r
-  // the database.\r
-  //\r
-  if (StringName[0] != L'$') {\r
-    StringDBAddString (Language, StringName, Scope, Str, FALSE, Flags);\r
-  }\r
-  //\r
-  // printf ("DBReadString: %S.%S.%S\n", Language, StringName, Scope);\r
-  //\r
-  FREE (Language);\r
-  FREE (StringName);\r
-  if (Str != NULL) {\r
-    FREE (Str);\r
-  }\r
-\r
-  if (Scope != NULL) {\r
-    FREE (Scope);\r
-  }\r
-\r
-  return STATUS_SUCCESS;\r
-}\r
-\r
-static\r
-STATUS\r
-StringDBWriteLanguageDefinition (\r
-  FILE            *DBFptr,\r
-  WCHAR           *LanguageName,\r
-  WCHAR           *PrintableLanguageName\r
-  )\r
-{\r
-  DB_DATA_ITEM_HEADER Hdr;\r
-  memset (&Hdr, 0, sizeof (DB_DATA_ITEM_HEADER));\r
-  Hdr.DataType = DB_DATA_TYPE_LANGUAGE_DEFINITION;\r
-  if (fwrite (&Hdr, sizeof (DB_DATA_ITEM_HEADER), 1, DBFptr) != 1) {\r
-    Error (NULL, 0, 0, "failed to write string to output database file", NULL);\r
-    return STATUS_ERROR;\r
-  }\r
-\r
-  if (StringDBWriteGenericString (DBFptr, LanguageName) != STATUS_SUCCESS) {\r
-    return STATUS_ERROR;\r
-  }\r
-\r
-  if (StringDBWriteGenericString (DBFptr, PrintableLanguageName) != STATUS_SUCCESS) {\r
-    return STATUS_ERROR;\r
-  }\r
-\r
-  return STATUS_SUCCESS;\r
-}\r
-\r
-static\r
-STATUS\r
-StringDBReadLanguageDefinition (\r
-  FILE            *DBFptr\r
-  )\r
-{\r
-  WCHAR   *LanguageName;\r
-  WCHAR   *PrintableLanguageName;\r
-  UINT16  Size;\r
-  STATUS  Status;\r
-\r
-  if (StringDBReadGenericString (DBFptr, &Size, &LanguageName) != STATUS_SUCCESS) {\r
-    return STATUS_ERROR;\r
-  }\r
-\r
-  if (StringDBReadGenericString (DBFptr, &Size, &PrintableLanguageName) != STATUS_SUCCESS) {\r
-    return STATUS_ERROR;\r
-  }\r
-  //\r
-  // printf("LANG: %S %S\n", LanguageName, PrintableLanguageName);\r
-  //\r
-  Status = StringDBAddLanguage (LanguageName, PrintableLanguageName);\r
-  FREE (LanguageName);\r
-  FREE (PrintableLanguageName);\r
-  return Status;\r
-}\r
-//\r
-// All unicode strings in the database consist of a UINT16 length\r
-// field, followed by the string itself. This routine reads one\r
-// of those and returns the info.\r
-//\r
-static\r
-STATUS\r
-StringDBReadGenericString (\r
-  FILE      *DBFptr,\r
-  UINT16    *Size,\r
-  WCHAR     **Str\r
-  )\r
-{\r
-  UINT16  LSize;\r
-  UINT16  Flags;\r
-  WCHAR   *LStr;\r
-\r
-  if (fread (&LSize, sizeof (UINT16), 1, DBFptr) != 1) {\r
-    Error (NULL, 0, 0, "failed to read a string length field from the database", NULL);\r
-    return STATUS_ERROR;\r
-  }\r
-\r
-  if (fread (&Flags, sizeof (UINT16), 1, DBFptr) != 1) {\r
-    Error (NULL, 0, 0, "failed to read a string flags field from the database", NULL);\r
-    return STATUS_ERROR;\r
-  }\r
-\r
-  LStr = MALLOC (LSize);\r
-  if (LStr == NULL) {\r
-    Error (__FILE__, __LINE__, 0, "memory allocation failed reading the database", NULL);\r
-    return STATUS_ERROR;\r
-  }\r
-\r
-  if (fread (LStr, sizeof (WCHAR), (UINT32) LSize / sizeof (WCHAR), DBFptr) != (UINT32) LSize / sizeof (WCHAR)) {\r
-    Error (NULL, 0, 0, "failed to read string from database", NULL);\r
-    Error (NULL, 0, 0, "database read failure", "offset 0x%X", ftell (DBFptr));\r
-    free (LStr);\r
-    return STATUS_ERROR;\r
-  }\r
-  //\r
-  // printf ("DBR: %S\n", LStr);\r
-  //\r
-  // If the flags field indicated we were asked to write a NULL string, then\r
-  // return them a NULL pointer.\r
-  //\r
-  if (Flags & STRING_FLAGS_UNDEFINED) {\r
-    *Size = 0;\r
-    *Str  = NULL;\r
-  } else {\r
-    *Size = LSize;\r
-    *Str  = LStr;\r
-  }\r
-\r
-  return STATUS_SUCCESS;\r
-}\r
-\r
-static\r
-STATUS\r
-StringDBWriteGenericString (\r
-  FILE      *DBFptr,\r
-  WCHAR     *Str\r
-  )\r
-{\r
-  UINT16  Size;\r
-  UINT16  Flags;\r
-  WCHAR   ZeroString[1];\r
-  //\r
-  // Strings in the database consist of a size UINT16 followed\r
-  // by the string itself.\r
-  //\r
-  if (Str == NULL) {\r
-    ZeroString[0] = 0;\r
-    Str           = ZeroString;\r
-    Size          = sizeof (ZeroString);\r
-    Flags         = STRING_FLAGS_UNDEFINED;\r
-  } else {\r
-    Flags = 0;\r
-    Size  = (UINT16) ((StrLen (Str) + 1) * sizeof (WCHAR));\r
-  }\r
-\r
-  if (fwrite (&Size, sizeof (UINT16), 1, DBFptr) != 1) {\r
-    Error (NULL, 0, 0, "failed to write string size to database", NULL);\r
-    return STATUS_ERROR;\r
-  }\r
-\r
-  if (fwrite (&Flags, sizeof (UINT16), 1, DBFptr) != 1) {\r
-    Error (NULL, 0, 0, "failed to write string flags to database", NULL);\r
-    return STATUS_ERROR;\r
-  }\r
-\r
-  if (fwrite (Str, sizeof (WCHAR), Size / sizeof (WCHAR), DBFptr) != Size / sizeof (WCHAR)) {\r
-    Error (NULL, 0, 0, "failed to write string to database", NULL);\r
-    return STATUS_ERROR;\r
-  }\r
-\r
-  return STATUS_SUCCESS;\r
-}\r
-\r
-static\r
-STRING_LIST *\r
-StringDBFindString (\r
-  WCHAR                       *LanguageName,\r
-  WCHAR                       *StringName,\r
-  WCHAR                       *Scope,\r
-  WCHAR_STRING_LIST           *LanguagesOfInterest,\r
-  WCHAR_MATCHING_STRING_LIST  *IndirectionList\r
-  )\r
-{\r
-  LANGUAGE_LIST               *Lang;\r
-  STRING_LIST                 *CurrString;\r
-  WCHAR_MATCHING_STRING_LIST  *IndListPtr;\r
-  WCHAR                       TempLangName[LANGUAGE_IDENTIFIER_NAME_LEN + 1];\r
-  WCHAR                       *WCharPtr;\r
-\r
-  //\r
-  // If we were given an indirection list, then see if one was specified for this\r
-  // string identifier. That is to say, if the indirection says "STR_ID_MY_FAVORITE MyScope",\r
-  // then if this string name matches one in the list, then do a lookup with the\r
-  // specified scope and return that value.\r
-  //\r
-  if (IndirectionList != NULL) {\r
-    for (IndListPtr = IndirectionList; IndListPtr != NULL; IndListPtr = IndListPtr->Next) {\r
-      if (StrCmp (StringName, IndListPtr->Str1) == 0) {\r
-        CurrString = StringDBFindString (LanguageName, StringName, IndListPtr->Str2, LanguagesOfInterest, NULL);\r
-        if (CurrString != NULL) {\r
-          return CurrString;\r
-        }\r
-      }\r
-    }\r
-  }\r
-  //\r
-  // First look for exact match language.stringname\r
-  //\r
-  for (Lang = mDBData.LanguageList; Lang != NULL; Lang = Lang->Next) {\r
-    if (StrCmp (LanguageName, Lang->LanguageName) == 0) {\r
-      //\r
-      // Found language match. Try to find string name match\r
-      //\r
-      for (CurrString = Lang->String; CurrString != NULL; CurrString = CurrString->Next) {\r
-        if (StrCmp (StringName, CurrString->StringName) == 0) {\r
-          //\r
-          // Found a string name match. See if we're supposed to find\r
-          // a scope match.\r
-          //\r
-          if (Scope != NULL) {\r
-            if (StrCmp (CurrString->Scope, Scope) == 0) {\r
-              return CurrString;\r
-            }\r
-          } else {\r
-            return CurrString;\r
-          }\r
-        }\r
-      }\r
-    }\r
-  }\r
-  //\r
-  // If we got here, then we didn't find a match. Look for secondary string\r
-  // matches. That is to say, if we're processing "spa", and they requested\r
-  // "spa+cat", then recursively call with "cat"\r
-  //\r
-  while (LanguagesOfInterest != NULL) {\r
-    //\r
-    // If this is the language we're looking for, then process the\r
-    // languages of interest list for it.\r
-    //\r
-    if (StrnCmp (LanguageName, LanguagesOfInterest->Str, LANGUAGE_IDENTIFIER_NAME_LEN) == 0) {\r
-      WCharPtr = LanguagesOfInterest->Str + LANGUAGE_IDENTIFIER_NAME_LEN;\r
-      while (*WCharPtr) {\r
-        //\r
-        // Double-check the length, though it should have been checked on the\r
-        // command line.\r
-        //\r
-        if (StrLen (WCharPtr) < LANGUAGE_IDENTIFIER_NAME_LEN) {\r
-          Error (NULL, 0, 0, "malformed alternate language list", "%S", LanguagesOfInterest->Str);\r
-          return NULL;\r
-        }\r
-\r
-        StrnCpy (TempLangName, WCharPtr, LANGUAGE_IDENTIFIER_NAME_LEN);\r
-        TempLangName[LANGUAGE_IDENTIFIER_NAME_LEN]  = 0;\r
-        CurrString = StringDBFindString (TempLangName, StringName, NULL, NULL, IndirectionList);\r
-        if (CurrString != NULL) {\r
-          return CurrString;\r
-        }\r
-\r
-        WCharPtr += LANGUAGE_IDENTIFIER_NAME_LEN;\r
-      }\r
-    }\r
-\r
-    LanguagesOfInterest = LanguagesOfInterest->Next;\r
-  }\r
-\r
-  return NULL;\r
-}\r
-\r
-STATUS\r
-StringDBSetScope (\r
-  WCHAR   *Scope\r
-  )\r
-{\r
-  //\r
-  // Free up existing scope memory.\r
-  //\r
-  if (mDBData.CurrentScope != NULL) {\r
-    FREE (mDBData.CurrentScope);\r
-  }\r
-\r
-  mDBData.CurrentScope = DuplicateString (Scope);\r
-  return STATUS_SUCCESS;\r
-}\r
-//\r
-// We typically don't assign index values to string identifiers\r
-// until we're ready to write out files. To reduce the size of\r
-// the output file, re-order the string identifiers to move any\r
-// unreferenced ones to the end. Then we'll walk the list\r
-// again to assign string indexes, keeping track of the last\r
-// one referenced.\r
-//\r
-static\r
-void\r
-StringDBAssignStringIndexes (\r
-  VOID\r
-  )\r
-{\r
-  STRING_IDENTIFIER *StrId;\r
-  STRING_IDENTIFIER *FirstUsed;\r
-  STRING_IDENTIFIER *LastUsed;\r
-  STRING_IDENTIFIER *FirstUnused;\r
-  STRING_IDENTIFIER *LastUnused;\r
-  UINT32            Index;\r
-  UINT32            MaxReferenced;\r
-\r
-  //\r
-  // Create two lists -- used and unused. Then put them together with\r
-  // the unused ones on the end.\r
-  //\r
-  FirstUsed   = NULL;\r
-  LastUsed    = NULL;\r
-  FirstUnused = NULL;\r
-  LastUnused  = NULL;\r
-  StrId       = mDBData.StringIdentifier;\r
-  while (StrId != NULL) {\r
-    if ((StrId->Flags & STRING_FLAGS_REFERENCED) == 0) {\r
-      //\r
-      // Put it on the unused list\r
-      //\r
-      if (FirstUnused == NULL) {\r
-        FirstUnused = StrId;\r
-      } else {\r
-        LastUnused->Next = StrId;\r
-      }\r
-\r
-      LastUnused        = StrId;\r
-      StrId             = StrId->Next;\r
-      LastUnused->Next  = NULL;\r
-    } else {\r
-      //\r
-      // Put it on the used list\r
-      //\r
-      if (FirstUsed == NULL) {\r
-        FirstUsed = StrId;\r
-      } else {\r
-        LastUsed->Next = StrId;\r
-      }\r
-\r
-      LastUsed        = StrId;\r
-      StrId           = StrId->Next;\r
-      LastUsed->Next  = NULL;\r
-    }\r
-  }\r
-  //\r
-  // Join the lists\r
-  //\r
-  if (FirstUsed != NULL) {\r
-    mDBData.StringIdentifier  = FirstUsed;\r
-    LastUsed->Next            = FirstUnused;\r
-  } else {\r
-    mDBData.StringIdentifier = FirstUnused;\r
-  }\r
-\r
-  MaxReferenced = 0;\r
-  Index         = 0;\r
-  for (StrId = mDBData.StringIdentifier; StrId != NULL; StrId = StrId->Next) {\r
-    StrId->Index = Index;\r
-    Index++;\r
-    if (StrId->Flags & STRING_FLAGS_REFERENCED) {\r
-      mDBData.NumStringIdentifiersReferenced = Index;\r
-    }\r
-  }\r
-\r
-  mDBData.NumStringIdentifiers = Index;\r
-}\r
-\r
-static\r
-WCHAR *\r
-DuplicateString (\r
-  WCHAR   *Str\r
-  )\r
-{\r
-  WCHAR *NewStr;\r
-  if (Str == NULL) {\r
-    return NULL;\r
-  }\r
-\r
-  NewStr = MALLOC ((StrLen (Str) + 1) * sizeof (WCHAR));\r
-  if (NewStr == NULL) {\r
-    Error (NULL, 0, 0, "memory allocation failure", NULL);\r
-    return NULL;\r
-  }\r
-\r
-  StrCpy (NewStr, Str);\r
-  return NewStr;\r
-}\r
-\r
-static\r
-WCHAR *\r
-AsciiToWchar (\r
-  CHAR8 *Str\r
-  )\r
-{\r
-  UINT32  Len;\r
-  WCHAR   *NewStr;\r
-  WCHAR   *Ptr;\r
-\r
-  Len     = strlen (Str) + 1;\r
-  NewStr  = (WCHAR *) malloc (Len * sizeof (WCHAR));\r
-  for (Ptr = NewStr; *Str != 0; Str++, Ptr++) {\r
-    *Ptr = (UINT16) (UINT8) *Str;\r
-  }\r
-\r
-  *Ptr = 0;\r
-  return NewStr;\r
-}\r
-\r
-/*****************************************************************************/\r
-\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Create an HII export string pack for the strings in our database.\r
-\r
-Arguments:\r
-\r
-  FileName        - name of the output file to write \r
-\r
-Returns:\r
-\r
-  STATUS\r
-\r
-\r
---*/\r
-STATUS\r
-StringDBCreateHiiExportPack (\r
-  CHAR8                       *FileName\r
-  )\r
-{\r
-  FILE                        *Fptr;\r
-  LANGUAGE_LIST               *Lang;\r
-  STRING_LIST                 *CurrString;\r
-  STRING_LIST                 EmptyString;\r
-  UINT32                      Offset;\r
-  UINT32                      StringIndex;\r
-  UINT32                      TempIndex;\r
-  EFI_HII_STRING_PACK         StringPack;\r
-  UINT32                      Len;\r
-  WCHAR                       ZeroString[1];\r
-  WCHAR                       *TempStringPtr;\r
-  WCHAR                       *LangName;\r
-  STRING_IDENTIFIER           *StringIdentifier;\r
-\r
-  if ((Fptr = fopen (FileName, "wb")) == NULL) {\r
-    Error (NULL, 0, 0, FileName, "failed to open output HII export file");\r
-    return STATUS_ERROR;\r
-  }\r
-  //\r
-  // Assign index values to the string identifiers\r
-  //\r
-  StringDBAssignStringIndexes ();\r
-  //\r
-  // If a given string is not defined, then we'll use this one.\r
-  //\r
-  memset (&EmptyString, 0, sizeof (EmptyString));\r
-  EmptyString.Size  = sizeof (ZeroString);\r
-  EmptyString.Str   = ZeroString;\r
-  //\r
-  // Process each language, then each string for each langage\r
-  //\r
-  ZeroString[0] = 0;\r
-  for (Lang = mDBData.LanguageList; Lang != NULL; Lang = Lang->Next) {\r
-    //\r
-    // Process each string for this language. We have to make 3 passes on the strings:\r
-    //   Pass1: computes sizes and fill in the string pack header\r
-    //   Pass2: write the array of offsets\r
-    //   Pass3: write the strings\r
-    //\r
-    //\r
-    // PASS 1: Fill in and print the HII string pack header\r
-    //\r
-    // Compute the size for this language package and write\r
-    // the header out. Each string package contains:\r
-    //   Header\r
-    //   Offset[]  -- an array of offsets to strings, of type RELOFST each\r
-    //   String[]  -- the actual strings themselves\r
-    //\r
-    memset ((char *) &StringPack, 0, sizeof (EFI_HII_STRING_PACK));\r
-    StringPack.Header.Type        = EFI_HII_STRING;\r
-    StringPack.NumStringPointers  = (UINT16) mDBData.NumStringIdentifiersReferenced;\r
-    LangName                      = Lang->LanguageName;\r
-    //\r
-    // First string is the language name. If we're printing all languages, then\r
-    // it's just the "spa". If we were given a list of languages to print, then it's\r
-    // the "spacat" string. Compute its offset and fill in\r
-    // the info in the header. Since we know the language name string's length,\r
-    // and the printable language name follows it, use that info to fill in the\r
-    // entry for the printable language name as well.\r
-    //\r
-    StringPack.LanguageNameString = (STRING_OFFSET) (sizeof (EFI_HII_STRING_PACK) + (mDBData.NumStringIdentifiersReferenced * sizeof (STRING_OFFSET)));\r
-    StringPack.PrintableLanguageName = (STRING_OFFSET) (StringPack.LanguageNameString + (StrLen (LangName) + 1) * sizeof (WCHAR));\r
-    //\r
-    // Add up the size of all strings so we can fill in our header.\r
-    //\r
-    Len = 0;\r
-    for (StringIndex = 0; StringIndex < mDBData.NumStringIdentifiersReferenced; StringIndex++) {\r
-      //\r
-      // For the first string (language name), we print out the "spacat" if they\r
-      // requested it. We set LangName to point to the proper language name string above.\r
-      //\r
-      if (StringIndex == STRING_ID_LANGUAGE_NAME) {\r
-        Len += (StrLen (LangName) + 1) * sizeof (WCHAR);\r
-      } else {\r
-        //\r
-        // Find a string with this language.stringname\r
-        //\r
-        StringIdentifier = StringDBFindStringIdentifierByIndex (StringIndex);\r
-        if (StringIdentifier == NULL) {\r
-          Error (NULL, 0, 0, "internal error", "invalid string index 0x%X", StringIndex);\r
-          return STATUS_ERROR;\r
-        }\r
-        //\r
-        // Find a matching string if this string identifier was referenced\r
-        //\r
-        EmptyString.Flags = STRING_FLAGS_UNDEFINED;\r
-        CurrString        = NULL;\r
-        if (StringIdentifier->Flags & STRING_FLAGS_REFERENCED) {\r
-          CurrString = StringDBFindString (\r
-                        Lang->LanguageName,\r
-                        StringIdentifier->StringName,\r
-                        NULL,\r
-                        NULL, // LanguagesOfInterest,\r
-                        NULL\r
-                        );\r
-          //\r
-          // IndirectionList);\r
-          //\r
-          if (NULL == CurrString) {\r
-            //\r
-            // If string for Lang->LanguageName is not found, try to get an English version\r
-            //\r
-            CurrString = StringDBFindString (\r
-                          L"eng",\r
-                          StringIdentifier->StringName,\r
-                          NULL,\r
-                          NULL, // LanguagesOfInterest,\r
-                          NULL\r
-                          );\r
-            //\r
-            // IndirectionList);\r
-            //\r
-          }\r
-        }\r
-\r
-        if (CurrString == NULL) {\r
-          CurrString = &EmptyString;\r
-          EmptyString.Flags |= StringIdentifier->Flags;\r
-        }\r
-\r
-        Len += CurrString->Size;\r
-      }\r
-    }\r
-    StringPack.Header.Length =    sizeof (EFI_HII_STRING_PACK) \r
-                                + mDBData.NumStringIdentifiersReferenced * sizeof (STRING_OFFSET) \r
-                                + Len;\r
-    //\r
-    // Write out the string pack header\r
-    //\r
-    fwrite ((void *) &StringPack, sizeof (StringPack), 1, Fptr);\r
-    //\r
-    // PASS2 : write the offsets\r
-    //\r
-    // Traverse the list of strings again and write the array of offsets. The\r
-    // offset to the first string is the size of the string pack header\r
-    // plus the size of the offsets array. The other strings follow it.\r
-    //\r
-    StringIndex = 0;\r
-    Offset      = sizeof (StringPack) + mDBData.NumStringIdentifiersReferenced * sizeof (STRING_OFFSET);\r
-    for (StringIndex = 0; StringIndex < mDBData.NumStringIdentifiersReferenced; StringIndex++) {\r
-      //\r
-      // Write the offset\r
-      //\r
-      fwrite (&Offset, sizeof (STRING_OFFSET), 1, Fptr);\r
-      //\r
-      // Find the string name\r
-      //\r
-      StringIdentifier = StringDBFindStringIdentifierByIndex (StringIndex);\r
-      if (StringIdentifier == NULL) {\r
-        Error (NULL, 0, 0, "internal error", "invalid string index 0x%X", StringIndex);\r
-        return STATUS_ERROR;\r
-      }\r
-      //\r
-      // For the first string (language name), we print out the "spacat" if they\r
-      // requested it. We set LangName to point to the proper language name string above.\r
-      //\r
-      if (StringIndex == STRING_ID_LANGUAGE_NAME) {\r
-        Offset += (StrLen (LangName) + 1) * sizeof (WCHAR);\r
-        CurrString = StringDBFindString (\r
-                      Lang->LanguageName,\r
-                      StringIdentifier->StringName,\r
-                      NULL, // scope\r
-                      NULL,\r
-                      NULL\r
-                      );\r
-      } else {\r
-        //\r
-        // Find a matching string\r
-        //\r
-        CurrString = StringDBFindString (\r
-                      Lang->LanguageName,\r
-                      StringIdentifier->StringName,\r
-                      NULL, // scope\r
-                      NULL, // LanguagesOfInterest,\r
-                      NULL\r
-                      );\r
-        //\r
-        // IndirectionList);\r
-        //\r
-        if (NULL == CurrString) {\r
-          CurrString = StringDBFindString (\r
-                        L"eng",\r
-                        StringIdentifier->StringName,\r
-                        NULL, // scope\r
-                        NULL, // LanguagesOfInterest,\r
-                        NULL\r
-                        );\r
-          //\r
-          // IndirectionList);\r
-          //\r
-        }\r
-\r
-        EmptyString.LanguageName = Lang->LanguageName;\r
-        if (CurrString == NULL) {\r
-          CurrString        = &EmptyString;\r
-          EmptyString.Flags = STRING_FLAGS_UNDEFINED;\r
-        } else if ((StringIdentifier->Flags & STRING_FLAGS_REFERENCED) == 0) {\r
-          CurrString        = &EmptyString;\r
-          EmptyString.Flags = 0;\r
-        }\r
-\r
-        Offset += CurrString->Size;\r
-      }\r
-    }\r
-\r
-    //\r
-    // PASS 3: write the strings themselves.\r
-    //\r
-    Offset = sizeof (StringPack) + mDBData.NumStringIdentifiersReferenced * sizeof (STRING_OFFSET);\r
-    for (StringIndex = 0; StringIndex < mDBData.NumStringIdentifiersReferenced; StringIndex++) {\r
-      StringIdentifier = StringDBFindStringIdentifierByIndex (StringIndex);\r
-      if (StringIdentifier == NULL) {\r
-        Error (NULL, 0, 0, "internal error", "invalid string index 0x%X", StringIndex);\r
-        return STATUS_ERROR;\r
-      }\r
-      //\r
-      // For the first string (language name), we print out the "spacat" if they\r
-      // requested it. We set LangName to point to the proper language name string above.\r
-      //\r
-      if (StringIndex == STRING_ID_LANGUAGE_NAME) {\r
-        TempStringPtr = LangName;\r
-      } else {\r
-        //\r
-        // Find a matching string if this string identifier was referenced\r
-        //\r
-        CurrString = NULL;\r
-        if (StringIdentifier->Flags & STRING_FLAGS_REFERENCED) {\r
-          CurrString = StringDBFindString (\r
-                        Lang->LanguageName,\r
-                        StringIdentifier->StringName,\r
-                        NULL, // scope\r
-                        NULL, // LanguagesOfInterest,\r
-                        NULL\r
-                        );\r
-          //\r
-          // IndirectionList);\r
-          //\r
-          if (NULL == CurrString) {\r
-            CurrString = StringDBFindString (\r
-                          L"eng",\r
-                          StringIdentifier->StringName,\r
-                          NULL, // scope\r
-                          NULL, // LanguagesOfInterest,\r
-                          NULL\r
-                          );\r
-            //\r
-            // IndirectionList);\r
-            //\r
-          }\r
-        }\r
-\r
-        if (CurrString == NULL) {\r
-          CurrString = &EmptyString;\r
-        }\r
-\r
-        TempStringPtr = CurrString->Str;\r
-      }\r
-\r
-      for (TempIndex = 0; TempStringPtr[TempIndex] != 0; TempIndex++) {\r
-        fwrite (&TempStringPtr[TempIndex], sizeof (CHAR16), 1, Fptr);\r
-        Offset += 2;\r
-      }\r
-      //\r
-      // Print NULL WCHAR at the end of this string.\r
-      //\r
-      TempIndex = 0;\r
-      fwrite (&TempIndex, sizeof (CHAR16), 1, Fptr);\r
-      Offset += 2;\r
-    }\r
-    //\r
-    // Sanity check the offset. Make sure our running offset is what we put in the\r
-    // string pack header.\r
-    //\r
-    if (StringPack.Header.Length != Offset) {\r
-      Error (\r
-        __FILE__,\r
-        __LINE__,\r
-        0,\r
-        "application error",\r
-        "stringpack size 0x%X does not match final size 0x%X",\r
-        StringPack.Header.Length,\r
-        Offset\r
-        );\r
-    }\r
-  }\r
-  //\r
-  // Print terminator string pack, closing brace and close the file.\r
-  // The size of 0 triggers to the consumer that this is the end.\r
-  //\r
-  memset ((char *) &StringPack, 0, sizeof (EFI_HII_STRING_PACK));\r
-  StringPack.Header.Type = EFI_HII_STRING;\r
-  fwrite ((void *) &StringPack, sizeof (StringPack), 1, Fptr);\r
-  fclose (Fptr);\r
-  return STATUS_SUCCESS;\r
-}\r
diff --git a/Tools/CodeTools/TianoTools/StrGather/StringDB.h b/Tools/CodeTools/TianoTools/StrGather/StringDB.h
deleted file mode 100644 (file)
index c525731..0000000
+++ /dev/null
@@ -1,136 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2004, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-Module Name:\r
-\r
-  StringDB.h\r
-\r
-Abstract:\r
-\r
-  Common defines and prototypes for string database management\r
-  \r
---*/\r
-\r
-#ifndef _STRING_DB_H_\r
-#define _STRING_DB_H_\r
-\r
-#define LANGUAGE_NAME_STRING_NAME           L"$LANGUAGE_NAME"\r
-#define PRINTABLE_LANGUAGE_NAME_STRING_NAME L"$PRINTABLE_LANGUAGE_NAME"\r
-\r
-void\r
-StringDBConstructor (\r
-  void\r
-  )\r
-;\r
-void\r
-StringDBDestructor (\r
-  void\r
-  )\r
-;\r
-\r
-STATUS\r
-StringDBAddString (\r
-  WCHAR   *LanguageName,\r
-  WCHAR   *StringIdentifier,\r
-  WCHAR   *Scope,\r
-  WCHAR   *String,\r
-  BOOLEAN Format,\r
-  UINT16  Flags\r
-  )\r
-;\r
-\r
-STATUS\r
-StringDBSetScope (\r
-  WCHAR   *Scope\r
-  )\r
-;\r
-\r
-#define STRING_FLAGS_REFERENCED           0x0001  // if referenced somewhere\r
-#define STRING_FLAGS_UNDEFINED            0x0002  // if we added it for padding purposes\r
-#define STRING_FLAGS_INDEX_ASSIGNED       0x0004  // so don't change the index value\r
-#define STRING_ID_INVALID                 0xFFFF\r
-#define STRING_ID_LANGUAGE_NAME           0x0000\r
-#define STRING_ID_PRINTABLE_LANGUAGE_NAME 0x0001\r
-\r
-STATUS\r
-StringDBAddStringIdentifier (\r
-  WCHAR     *StringIdentifier,\r
-  UINT16    *NewId,\r
-  UINT16    Flags\r
-  )\r
-;\r
-\r
-STATUS\r
-StringDBReadDatabase (\r
-  CHAR8   *DBFileName,\r
-  BOOLEAN IgnoreIfNotExist,\r
-  BOOLEAN Verbose\r
-  )\r
-;\r
-\r
-STATUS\r
-StringDBWriteDatabase (\r
-  CHAR8   *DBFileName,\r
-  BOOLEAN Verbose\r
-  )\r
-;\r
-\r
-STATUS\r
-StringDBDumpDatabase (\r
-  CHAR8               *DBFileName,\r
-  CHAR8               *OutputFileName,\r
-  BOOLEAN             Verbose\r
-  )\r
-;\r
-\r
-STATUS\r
-StringDBAddLanguage (\r
-  WCHAR *LanguageName,\r
-  WCHAR *PrintableLanguageName\r
-  )\r
-;\r
-\r
-STATUS\r
-StringDBDumpCStrings (\r
-  CHAR8                       *FileName,\r
-  CHAR8                       *BaseName,\r
-  WCHAR_STRING_LIST           *LanguagesOfInterest,\r
-  WCHAR_MATCHING_STRING_LIST  *IndirectionList\r
-  )\r
-;\r
-\r
-STATUS\r
-StringDBDumpStringDefines (\r
-  CHAR8               *FileName,\r
-  CHAR8               *BaseName\r
-  )\r
-;\r
-\r
-STATUS\r
-StringDBSetCurrentLanguage (\r
-  WCHAR *LanguageName\r
-  )\r
-;\r
-\r
-STATUS\r
-StringDBSetStringReferenced (\r
-  CHAR8     *StringIdentifierName,\r
-  BOOLEAN   IgnoreNotFound\r
-  )\r
-;\r
-\r
-void\r
-StringDBFormatString (\r
-  WCHAR   *String\r
-  )\r
-;\r
-\r
-#endif // #ifndef _STRING_DB_H_\r
diff --git a/Tools/CodeTools/TianoTools/StrGather/build.xml b/Tools/CodeTools/TianoTools/StrGather/build.xml
deleted file mode 100644 (file)
index f011177..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-<?xml version="1.0" ?>\r
-<!--\r
-Copyright (c) 2006, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
--->\r
-<project default="GenTool" basedir=".">\r
-<!--\r
-    EDK StrGather Tool\r
-  Copyright (c) 2006, Intel Corporation\r
--->\r
-  <property name="ToolName" value="StrGather"/>\r
-  <property name="FileSet" value="*.c *.h"/>\r
-\r
-  <taskdef resource="cpptasks.tasks"/>\r
-  <typedef resource="cpptasks.types"/>\r
-  <taskdef resource="net/sf/antcontrib/antlib.xml"/>\r
-\r
-  <property name="LINK_OUTPUT_TYPE" value="static"/>\r
-  <property name="BUILD_DIR" value="${PACKAGE_DIR}/${ToolName}/tmp"/>\r
-\r
-  <target name="GenTool" depends="init, Tool">\r
-    <echo message="The EDK Tool: ${ToolName} build has completed!"/>\r
-  </target>\r
-\r
-  <target name="init">\r
-    <echo message="Building the EDK Tool: ${ToolName}"/>\r
-    <mkdir dir="${BUILD_DIR}"/>\r
-  </target>\r
-\r
-  <target name="Tool" depends="init">\r
-    <cc name="${ToolChain}" objdir="${BUILD_DIR}" \r
-        outfile="${BIN_DIR}/${ToolName}"\r
-        outtype="executable"\r
-        optimize="speed" \r
-        debug="true">\r
-\r
-      <compilerarg value="-fshort-wchar" if="gcc"/>\r
-\r
-      <fileset dir="${basedir}/${ToolName}" \r
-        includes="${FileSet}" \r
-        defaultexcludes="TRUE" \r
-        excludes="*.xml *.inf"/>\r
-\r
-      <includepath path="${PACKAGE_DIR}/Include"/>\r
-      <includepath path="${PACKAGE_DIR}/Include/${HostArch}"/>\r
-      <includepath path="${PACKAGE_DIR}/Common"/>\r
-      <libset dir="${LIB_DIR}" libs="CommonTools String"/>\r
-    </cc>\r
-  </target>\r
-\r
-  <target name="clean">\r
-    <echo message="Removing Intermediate Files Only"/>  \r
-    <delete>\r
-      <fileset dir="${BUILD_DIR}" includes="*.obj"/>\r
-    </delete>\r
-  </target>\r
-\r
-  <target name="cleanall">\r
-    <echo message="Removing Object Files and the Executable: ${ToolName}${ext_exe}"/>  \r
-    <delete failonerror="false" quiet="true" includeEmptyDirs="true">\r
-      <fileset dir="${BUILD_DIR}"/>\r
-      <fileset file="${BIN_DIR}/${ToolName}${ext_exe}"/>\r
-    </delete>\r
-  </target>\r
-\r
-</project>\r
diff --git a/Tools/CodeTools/TianoTools/String/PrintLib.c b/Tools/CodeTools/TianoTools/String/PrintLib.c
deleted file mode 100644 (file)
index eef3f4d..0000000
+++ /dev/null
@@ -1,674 +0,0 @@
-/*++\r
-\r
-Copyright (c)  2004-2006 Intel Corporation. All rights reserved\r
-This program and the accompanying materials are licensed and made available\r
-under the terms and conditions of the BSD License which accompanies this\r
-distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-\r
-Module Name:\r
-\r
-  PrintLib.c\r
-\r
-Abstract:\r
-\r
-  Print Library.\r
-\r
---*/\r
-\r
-#include <Common/UefiBaseTypes.h>\r
-#include <Library/PrintLib.h>\r
-\r
-#include "CommonLib.h"\r
-#include "PrintLibInternal.h"\r
-\r
-typedef struct {\r
-  RETURN_STATUS  Status;\r
-  CHAR8          *String;\r
-} STATUS_LOOKUP_TABLE_ENTRY;\r
-\r
-static CONST STATUS_LOOKUP_TABLE_ENTRY  StatusString[] = {\r
-  { RETURN_SUCCESS,               "Success" },\r
-  { RETURN_LOAD_ERROR,            "Load Error" },\r
-  { RETURN_INVALID_PARAMETER,     "Invalid Parameter" },\r
-  { RETURN_UNSUPPORTED,           "Unsupported" },\r
-  { RETURN_BAD_BUFFER_SIZE,       "Bad Buffer Size" },\r
-  { RETURN_BUFFER_TOO_SMALL,      "Buffer Too Small" },\r
-  { RETURN_NOT_READY,             "Not Ready" },\r
-  { RETURN_DEVICE_ERROR,          "Device Error" },\r
-  { RETURN_WRITE_PROTECTED,       "Write Protected" },\r
-  { RETURN_OUT_OF_RESOURCES,      "Out of Resources" },\r
-  { RETURN_VOLUME_CORRUPTED,      "Volume Corrupt" },\r
-  { RETURN_VOLUME_FULL,           "Volume Full" },\r
-  { RETURN_NO_MEDIA,              "No Media" },\r
-  { RETURN_MEDIA_CHANGED,         "Media changed" },\r
-  { RETURN_NOT_FOUND,             "Not Found" },\r
-  { RETURN_ACCESS_DENIED,         "Access Denied" },\r
-  { RETURN_NO_RESPONSE,           "No Response" },\r
-  { RETURN_NO_MAPPING,            "No mapping" },\r
-  { RETURN_TIMEOUT,               "Time out" },\r
-  { RETURN_NOT_STARTED,           "Not started" },\r
-  { RETURN_ALREADY_STARTED,       "Already started" },\r
-  { RETURN_ABORTED,               "Aborted" },\r
-  { RETURN_ICMP_ERROR,            "ICMP Error" },\r
-  { RETURN_TFTP_ERROR,            "TFTP Error" },\r
-  { RETURN_PROTOCOL_ERROR,        "Protocol Error" },\r
-  { RETURN_WARN_UNKNOWN_GLYPH,    "Warning Unknown Glyph" },\r
-  { RETURN_WARN_DELETE_FAILURE,   "Warning Delete Failure" },\r
-  { RETURN_WARN_WRITE_FAILURE,    "Warning Write Failure" },\r
-  { RETURN_WARN_BUFFER_TOO_SMALL, "Warning Buffer Too Small" },\r
-  { 0,                              NULL                     }\r
-};\r
-\r
-\r
-/**\r
-  VSPrint function to process format and place the results in Buffer. Since a\r
-  VA_LIST is used this rountine allows the nesting of Vararg routines. Thus\r
-  this is the main print working routine\r
-\r
-  @param  StartOfBuffer Unicode buffer to print the results of the parsing of Format into.\r
-\r
-  @param  BufferSize Maximum number of characters to put into buffer. Zero means\r
-  no limit.\r
-\r
-  @param  Flags Intial flags value.  Can only have FORMAT_UNICODE and OUTPUT_UNICODE set\r
-\r
-  @param  FormatString Unicode format string see file header for more details.\r
-\r
-  @param  Marker Vararg list consumed by processing Format.\r
-\r
-  @return Number of characters printed.\r
-\r
-**/\r
-UINTN\r
-BasePrintLibVSPrint (\r
-  OUT CHAR8        *Buffer,\r
-  IN  UINTN        BufferSize,\r
-  IN  UINTN        Flags,\r
-  IN  CONST CHAR8  *Format,\r
-  IN  VA_LIST      Marker\r
-  )\r
-{\r
-  CHAR8           *OriginalBuffer;\r
-  CHAR8           ValueBuffer[MAXIMUM_VALUE_CHARACTERS];\r
-  UINTN           BytesPerOutputCharacter;\r
-  UINTN           BytesPerFormatCharacter;\r
-  UINTN           FormatMask;\r
-  UINTN           FormatCharacter;\r
-  UINTN           Width;\r
-  UINTN           Precision;\r
-  INT64           Value;\r
-  CHAR8           *ArgumentString;\r
-  UINTN           Character;\r
-  GUID            *TmpGuid;\r
-  TIME            *TmpTime;\r
-  UINTN           Count;\r
-  UINTN           ArgumentMask;\r
-  INTN            BytesPerArgumentCharacter;\r
-  UINTN           ArgumentCharacter;\r
-  BOOLEAN         Done;\r
-  UINTN           Index;\r
-  CHAR8           Prefix;\r
-  BOOLEAN         ZeroPad;\r
-  BOOLEAN         Comma;\r
-  UINTN           Digits;\r
-  UINTN           Radix;\r
-  RETURN_STATUS   Status;\r
-\r
-  OriginalBuffer = Buffer;\r
-\r
-  if ((Flags & OUTPUT_UNICODE) != 0) {\r
-    BytesPerOutputCharacter = 2;\r
-  } else {\r
-    BytesPerOutputCharacter = 1;\r
-  }\r
-  if ((Flags & FORMAT_UNICODE) != 0) {\r
-    BytesPerFormatCharacter = 2;\r
-    FormatMask = 0xffff;\r
-  } else {\r
-    BytesPerFormatCharacter = 1;\r
-    FormatMask = 0xff;\r
-  }\r
-\r
-  //\r
-  // Reserve space for the Null terminator.\r
-  // If BufferSize is 0, this will set BufferSize to the max unsigned value\r
-  //\r
-  BufferSize--;\r
-\r
-  //\r
-  // Get the first character from the format string\r
-  //\r
-  FormatCharacter = (*Format | (*(Format + 1) << 8)) & FormatMask;\r
-\r
-  //\r
-  // Loop until the end of the format string is reached or the output buffer is full\r
-  //\r
-  while (FormatCharacter != 0 && BufferSize > 0) {\r
-    //\r
-    // Clear all the flag bits except those that may have been passed in\r
-    //\r
-    Flags &= (OUTPUT_UNICODE | FORMAT_UNICODE);\r
-\r
-    //\r
-    // Set the default width to zero, and the default precision to 1\r
-    //\r
-    Width     = 0;\r
-    Precision = 1;\r
-    Prefix    = 0;\r
-    Comma     = FALSE;\r
-    ZeroPad   = FALSE;\r
-    Count     = 0;\r
-    Digits    = 0;\r
-\r
-    switch (FormatCharacter) {\r
-    case '%':\r
-      //\r
-      // Parse Flags and Width\r
-      //\r
-      for (Done = FALSE; !Done; ) {\r
-        Format += BytesPerFormatCharacter;\r
-        FormatCharacter = (*Format | (*(Format + 1) << 8)) & FormatMask;\r
-        switch (FormatCharacter) {\r
-        case '.':\r
-          Flags |= PRECISION;\r
-          break;\r
-        case '-':\r
-          Flags |= LEFT_JUSTIFY;\r
-          break;\r
-        case '+':\r
-          Flags |= PREFIX_SIGN;\r
-          break;\r
-        case ' ':\r
-          Flags |= PREFIX_BLANK;\r
-          break;\r
-        case ',':\r
-          Flags |= COMMA_TYPE;\r
-          break;\r
-        case 'L':\r
-        case 'l':\r
-          Flags |= LONG_TYPE;\r
-          break;\r
-        case '*':\r
-          if ((Flags & PRECISION) == 0) {\r
-            Flags |= PAD_TO_WIDTH;\r
-            Width = VA_ARG (Marker, UINTN);\r
-          } else {\r
-            Precision = VA_ARG (Marker, UINTN);\r
-          }\r
-          break;\r
-        case '0':\r
-          if ((Flags & PRECISION) == 0) {\r
-            Flags |= PREFIX_ZERO;\r
-          }\r
-        case '1':\r
-        case '2':\r
-        case '3':\r
-        case '4':\r
-        case '5':\r
-        case '6':\r
-        case '7':\r
-        case '8':\r
-        case '9':\r
-          for (Count = 0; ((FormatCharacter >= '0') &&  (FormatCharacter <= '9')); ){\r
-            Count = (Count * 10) + FormatCharacter - '0';\r
-            Format += BytesPerFormatCharacter;\r
-            FormatCharacter = (*Format | (*(Format + 1) << 8)) & FormatMask;\r
-          }\r
-          Format -= BytesPerFormatCharacter;\r
-          if ((Flags & PRECISION) == 0) {\r
-            Flags |= PAD_TO_WIDTH;\r
-            Width = Count;\r
-          } else {\r
-            Precision = Count;\r
-          }\r
-          break;\r
-        default:\r
-          Done = TRUE;\r
-          break;\r
-        }\r
-      }\r
-\r
-      //\r
-      // Limit the maximum field width to the remaining characters in the output buffer\r
-      //\r
-      if (Width > BufferSize) {\r
-        Width = BufferSize;\r
-      }\r
-\r
-      //\r
-      // Handle each argument type\r
-      //\r
-      switch (FormatCharacter) {\r
-      case 'X':\r
-        Flags |= PREFIX_ZERO;\r
-        //\r
-        // break skiped on purpose\r
-        //\r
-      case 'x':\r
-        Flags |= RADIX_HEX;\r
-        //\r
-        // break skiped on purpose\r
-        //\r
-      case 'd':\r
-        if ((Flags & LONG_TYPE) == 0) {\r
-          Value = (VA_ARG (Marker, INTN));\r
-        } else {\r
-          Value = VA_ARG (Marker, INT64);\r
-        }\r
-        if ((Flags & PREFIX_BLANK) != 0) {\r
-          Prefix = ' ';\r
-        }\r
-        if ((Flags & PREFIX_SIGN) != 0) {\r
-          Prefix = '+';\r
-        }\r
-        if ((Flags & COMMA_TYPE) != 0) {\r
-          Comma = TRUE;\r
-        }\r
-        if ((Flags & RADIX_HEX) == 0) {\r
-          Radix = 10;\r
-          if (Comma) {\r
-            Flags &= (~PREFIX_ZERO);\r
-            Precision = 1;\r
-          }\r
-          if (Value < 0) {\r
-            Flags |= PREFIX_SIGN;\r
-            Prefix = '-';\r
-            Value = -Value;\r
-          }\r
-        } else {\r
-          Radix = 16;\r
-          Comma = FALSE;\r
-          if ((Flags & LONG_TYPE) == 0 && Value < 0) {\r
-            Value = (UINTN)Value;\r
-          }\r
-        }\r
-        //\r
-        // Convert Value to a reversed string\r
-        //\r
-        Count = BasePrintLibValueToString (ValueBuffer, Value, Radix);\r
-        if (Value == 0 && Precision == 0) {\r
-          Count = 0;\r
-        }\r
-        ArgumentString = (CHAR8 *)ValueBuffer + Count;\r
-        Digits = 3 - (Count % 3);\r
-        if (Comma && Count != 0) {\r
-          Count += ((Count - 1) / 3);\r
-        }\r
-        if (Prefix != 0) {\r
-          Count++;\r
-        }\r
-        Flags |= ARGUMENT_REVERSED;\r
-        ZeroPad = TRUE;\r
-        if ((Flags & PREFIX_ZERO) != 0) {\r
-          if ((Flags & PAD_TO_WIDTH) != 0) {\r
-            if ((Flags & PRECISION) == 0) {\r
-              Precision = Width;\r
-            }\r
-          }\r
-        }\r
-        break;\r
-\r
-      case 's':\r
-      case 'S':\r
-        Flags |= ARGUMENT_UNICODE;\r
-        //\r
-        // break skipped on purpose\r
-        //\r
-      case 'a':\r
-        ArgumentString = (CHAR8 *)VA_ARG (Marker, CHAR8 *);\r
-        if (ArgumentString == NULL) {\r
-          Flags &= (~ARGUMENT_UNICODE);\r
-          ArgumentString = "<null string>";\r
-        }\r
-        break;\r
-\r
-      case 'c':\r
-        Character = VA_ARG (Marker, UINTN) & 0xffff;\r
-        ArgumentString = (CHAR8 *)&Character;\r
-        Flags |= ARGUMENT_UNICODE;\r
-        break;\r
-\r
-      case 'g':\r
-        TmpGuid = VA_ARG (Marker, GUID *);\r
-        if (TmpGuid == NULL) {\r
-          ArgumentString = "<null guid>";\r
-        } else {\r
-          BasePrintLibSPrint (\r
-            ValueBuffer,\r
-            0,\r
-            0,\r
-            "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",\r
-            TmpGuid->Data1,\r
-            TmpGuid->Data2,\r
-            TmpGuid->Data3,\r
-            TmpGuid->Data4[0],\r
-            TmpGuid->Data4[1],\r
-            TmpGuid->Data4[2],\r
-            TmpGuid->Data4[3],\r
-            TmpGuid->Data4[4],\r
-            TmpGuid->Data4[5],\r
-            TmpGuid->Data4[6],\r
-            TmpGuid->Data4[7]\r
-            );\r
-          ArgumentString = ValueBuffer;\r
-        }\r
-        break;\r
-\r
-      case 't':\r
-        TmpTime = VA_ARG (Marker, TIME *);\r
-        if (TmpTime == NULL) {\r
-          ArgumentString = "<null time>";\r
-        } else {\r
-          BasePrintLibSPrint (\r
-            ValueBuffer,\r
-            0,\r
-            0,\r
-            "%02d/%02d/%04d  %02d:%02d",\r
-            TmpTime->Month,\r
-            TmpTime->Day,\r
-            TmpTime->Year,\r
-            TmpTime->Hour,\r
-            TmpTime->Minute\r
-            );\r
-          ArgumentString = ValueBuffer;\r
-        }\r
-        break;\r
-\r
-      case 'r':\r
-        Status = VA_ARG (Marker, RETURN_STATUS);\r
-        ArgumentString = ValueBuffer;\r
-        for (Index = 0; StatusString[Index].String != NULL; Index++) {\r
-          if (Status == StatusString[Index].Status) {\r
-            ArgumentString = StatusString[Index].String;\r
-          }\r
-        }\r
-        if (ArgumentString == ValueBuffer) {\r
-          BasePrintLibSPrint ((CHAR8 *) ValueBuffer, 0, 0, "%08X", Status);\r
-        }\r
-        break;\r
-\r
-      case '%':\r
-      default:\r
-        //\r
-        // if the type is '%' or unknown, then print it to the screen\r
-        //\r
-        ArgumentString = (CHAR8 *)&FormatCharacter;\r
-        Flags |= ARGUMENT_UNICODE;\r
-        break;\r
-      }\r
-      break;\r
-    case '\n':\r
-      ArgumentString = "\n";\r
-         \r
-      break;\r
-    default:\r
-      ArgumentString = (CHAR8 *)&FormatCharacter;\r
-      Flags |= ARGUMENT_UNICODE;\r
-      break;\r
-    }\r
-\r
-    //\r
-    // Retrieve the ArgumentString attriubutes\r
-    //\r
-    if ((Flags & ARGUMENT_UNICODE) != 0) {\r
-      ArgumentMask = 0xffff;\r
-      BytesPerArgumentCharacter = 2;\r
-    } else {\r
-      ArgumentMask = 0xff;\r
-      BytesPerArgumentCharacter = 1;\r
-    }\r
-    if ((Flags & ARGUMENT_REVERSED) != 0) {\r
-      BytesPerArgumentCharacter = -BytesPerArgumentCharacter;\r
-    } else {\r
-      //\r
-      // Compute the number of characters in ArgumentString and store it in Count\r
-      // ArgumentString is either null-terminated, or it contains Precision characters\r
-      //\r
-      for (Count = 0; Count < Precision || ((Flags & PRECISION) == 0); Count++) {\r
-        ArgumentCharacter = ((ArgumentString[Count * BytesPerArgumentCharacter] & 0xff) | ((ArgumentString[Count * BytesPerArgumentCharacter + 1]) << 8)) & ArgumentMask;\r
-        if (ArgumentCharacter == 0) {\r
-          break;\r
-        }\r
-      }\r
-    }\r
-\r
-    //\r
-    // Limit the length of the string to append to the remaining characters in the output buffer\r
-    //\r
-    if (Count > BufferSize) {\r
-      Count = BufferSize;\r
-    }\r
-    if (Precision < Count) {\r
-      Precision = Count;\r
-    }\r
-\r
-    //\r
-    // Pad before the string\r
-    //\r
-    if ((Flags & (PAD_TO_WIDTH | LEFT_JUSTIFY)) == (PAD_TO_WIDTH)) {\r
-      Buffer = BasePrintLibFillBuffer (Buffer, Width - Precision, ' ', BytesPerOutputCharacter);\r
-    }\r
-\r
-    if (ZeroPad) {\r
-      if (Prefix != 0) {\r
-        Buffer = BasePrintLibFillBuffer (Buffer, 1, Prefix, BytesPerOutputCharacter);\r
-      }\r
-      Buffer = BasePrintLibFillBuffer (Buffer, Precision - Count, '0', BytesPerOutputCharacter);\r
-    } else {\r
-      Buffer = BasePrintLibFillBuffer (Buffer, Precision - Count, ' ', BytesPerOutputCharacter);\r
-      if (Prefix != 0) {\r
-        Buffer = BasePrintLibFillBuffer (Buffer, 1, Prefix, BytesPerOutputCharacter);\r
-      }\r
-    }\r
-\r
-    //\r
-    // Output the Prefix character if it is present\r
-    //\r
-    Index = 0;\r
-    if (Prefix) {\r
-      Index++;\r
-    }\r
-\r
-    //\r
-    // Copy the string into the output buffer performing the required type conversions\r
-    //\r
-    while (Index < Count) {\r
-      ArgumentCharacter = ((*ArgumentString & 0xff) | (*(ArgumentString + 1) << 8)) & ArgumentMask;\r
-\r
-      Buffer = BasePrintLibFillBuffer (Buffer, 1, ArgumentCharacter, BytesPerOutputCharacter);\r
-      ArgumentString    += BytesPerArgumentCharacter;\r
-      Index++;\r
-      if (Comma) {\r
-        Digits++;\r
-        if (Digits == 3) {\r
-          Digits = 0;\r
-          Index++;\r
-          if (Index < Count) {\r
-            Buffer = BasePrintLibFillBuffer (Buffer, 1, ',', BytesPerOutputCharacter);\r
-          }\r
-        }\r
-      }\r
-    }\r
-\r
-    //\r
-    // Pad after the string\r
-    //\r
-    if ((Flags & (PAD_TO_WIDTH | LEFT_JUSTIFY)) == (PAD_TO_WIDTH | LEFT_JUSTIFY)) {\r
-      Buffer = BasePrintLibFillBuffer (Buffer, Width - Precision, ' ', BytesPerOutputCharacter);\r
-    }\r
-\r
-    //\r
-    // Reduce the number of characters\r
-    //\r
-    BufferSize -= Count;\r
-\r
-    //\r
-    // Get the next character from the format string\r
-    //\r
-    Format += BytesPerFormatCharacter;\r
-\r
-    //\r
-    // Get the next character from the format string\r
-    //\r
-    FormatCharacter = (*Format | (*(Format + 1) << 8)) & FormatMask;\r
-  }\r
-\r
-  //\r
-  // Null terminate the Unicode or ASCII string\r
-  //\r
-  Buffer = BasePrintLibFillBuffer (Buffer, 1, 0, BytesPerOutputCharacter);\r
-\r
-  return ((Buffer - OriginalBuffer) / BytesPerOutputCharacter);\r
-}\r
-\r
-UINTN\r
-BasePrintLibSPrint (\r
-  OUT CHAR8        *StartOfBuffer,\r
-  IN  UINTN        BufferSize,\r
-  IN  UINTN        Flags,\r
-  IN  CONST CHAR8  *FormatString,\r
-  ...\r
-  )\r
-{\r
-  VA_LIST  Marker;\r
-\r
-  VA_START (Marker, FormatString);\r
-  return BasePrintLibVSPrint (StartOfBuffer, BufferSize, Flags, FormatString, Marker);\r
-}\r
-\r
-UINTN\r
-EFIAPI\r
-UnicodeVSPrint (\r
-  OUT CHAR16        *StartOfBuffer,\r
-  IN  UINTN         BufferSize,\r
-  IN  CONST CHAR16  *FormatString,\r
-  IN  VA_LIST       Marker\r
-  )\r
-{\r
-  return BasePrintLibVSPrint ((CHAR8 *)StartOfBuffer, BufferSize >> 1, FORMAT_UNICODE | OUTPUT_UNICODE, (CHAR8 *)FormatString, Marker);\r
-}\r
-\r
-UINTN\r
-EFIAPI\r
-UnicodeSPrint (\r
-  OUT CHAR16        *StartOfBuffer,\r
-  IN  UINTN         BufferSize,\r
-  IN  CONST CHAR16  *FormatString,\r
-  ...\r
-  )\r
-{\r
-  VA_LIST Marker;\r
-\r
-  VA_START (Marker, FormatString);\r
-  return UnicodeVSPrint (StartOfBuffer, BufferSize, FormatString, Marker);\r
-}\r
-\r
-UINTN\r
-EFIAPI\r
-UnicodeVSPrintAsciiFormat (\r
-  OUT CHAR16       *StartOfBuffer,\r
-  IN  UINTN        BufferSize,\r
-  IN  CONST CHAR8  *FormatString,\r
-  IN  VA_LIST      Marker\r
-  )\r
-{\r
-  return BasePrintLibVSPrint ((CHAR8 *)StartOfBuffer, BufferSize >> 1, OUTPUT_UNICODE,FormatString, Marker);\r
-}\r
-\r
-UINTN\r
-EFIAPI\r
-UnicodeSPrintAsciiFormat (\r
-  OUT CHAR16       *StartOfBuffer,\r
-  IN  UINTN        BufferSize,\r
-  IN  CONST CHAR8  *FormatString,\r
-  ...\r
-  )\r
-{\r
-  VA_LIST Marker;\r
-\r
-  VA_START (Marker, FormatString);\r
-  return UnicodeVSPrintAsciiFormat (StartOfBuffer, BufferSize >> 1, FormatString, Marker);\r
-}\r
-\r
-UINTN\r
-EFIAPI\r
-AsciiVSPrint (\r
-  OUT CHAR8         *StartOfBuffer,\r
-  IN  UINTN         BufferSize,\r
-  IN  CONST CHAR8   *FormatString,\r
-  IN  VA_LIST       Marker\r
-  )\r
-{\r
-  return BasePrintLibVSPrint (StartOfBuffer, BufferSize, 0, FormatString, Marker);\r
-}\r
-\r
-UINTN\r
-EFIAPI\r
-AsciiSPrint (\r
-  OUT CHAR8        *StartOfBuffer,\r
-  IN  UINTN        BufferSize,\r
-  IN  CONST CHAR8  *FormatString,\r
-  ...\r
-  )\r
-{\r
-  VA_LIST Marker;\r
-\r
-  VA_START (Marker, FormatString);\r
-  return AsciiVSPrint (StartOfBuffer, BufferSize, FormatString, Marker);\r
-}\r
-\r
-UINTN\r
-EFIAPI\r
-AsciiVSPrintUnicodeFormat (\r
-  OUT CHAR8         *StartOfBuffer,\r
-  IN  UINTN         BufferSize,\r
-  IN  CONST CHAR16  *FormatString,\r
-  IN  VA_LIST       Marker\r
-  )\r
-{\r
-  return BasePrintLibVSPrint (StartOfBuffer, BufferSize, FORMAT_UNICODE, (CHAR8 *)FormatString, Marker);\r
-}\r
-\r
-UINTN\r
-EFIAPI\r
-AsciiSPrintUnicodeFormat (\r
-  OUT CHAR8         *StartOfBuffer,\r
-  IN  UINTN         BufferSize,\r
-  IN  CONST CHAR16  *FormatString,\r
-  ...\r
-  )\r
-{\r
-  VA_LIST Marker;\r
-\r
-  VA_START (Marker, FormatString);\r
-  return AsciiVSPrintUnicodeFormat (StartOfBuffer, BufferSize, FormatString, Marker);\r
-}\r
-\r
-UINTN\r
-EFIAPI\r
-UnicodeValueToString (\r
-  IN OUT CHAR16  *Buffer,\r
-  IN UINTN       Flags,\r
-  IN INT64       Value,\r
-  IN UINTN       Width\r
-  )\r
-{\r
-  return BasePrintLibConvertValueToString ((CHAR8 *)Buffer, Flags, Value, Width, 2);\r
-}\r
-\r
-UINTN\r
-EFIAPI\r
-AsciiValueToString (\r
-  IN OUT CHAR8  *Buffer,\r
-  IN UINTN      Flags,\r
-  IN INT64      Value,\r
-  IN UINTN      Width\r
-  )\r
-{\r
-  return BasePrintLibConvertValueToString ((CHAR8 *)Buffer, Flags, Value, Width, 1);\r
-}\r
diff --git a/Tools/CodeTools/TianoTools/String/PrintLibInternal.c b/Tools/CodeTools/TianoTools/String/PrintLibInternal.c
deleted file mode 100644 (file)
index 63d0c71..0000000
+++ /dev/null
@@ -1,142 +0,0 @@
-/*++\r
-\r
-Copyright (c)  2004-2006 Intel Corporation. All rights reserved\r
-This program and the accompanying materials are licensed and made available\r
-under the terms and conditions of the BSD License which accompanies this\r
-distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-\r
-Module Name:\r
-\r
-  PrintLibInternal.c\r
-\r
-Abstract:\r
-\r
-  Print Library worker functions.\r
-\r
---*/\r
-\r
-#include <Common/UefiBaseTypes.h>\r
-#include <Library/PrintLib.h>\r
-\r
-#include "CommonLib.h"\r
-#include "PrintLibInternal.h"\r
-\r
-static CONST CHAR8 mHexStr[] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};\r
-\r
-CHAR8 *\r
-BasePrintLibFillBuffer (\r
-  CHAR8   *Buffer,\r
-  INTN    Length,\r
-  UINTN   Character,\r
-  INTN    Increment\r
-  )\r
-{\r
-  INTN  Index;\r
-\r
-  for (Index = 0; Index < Length; Index++) {\r
-    *Buffer       =  (CHAR8) Character;\r
-    *(Buffer + 1) =  (CHAR8) (Character >> 8);\r
-    Buffer        += Increment;\r
-  }\r
-  return Buffer;\r
-}\r
-\r
-/**\r
-  Print worker function that prints a Value as a decimal number in Buffer.\r
-\r
-  @param  Buffer Location to place the Unicode or ASCII string of Value.\r
-\r
-  @param  Value Value to convert to a Decimal or Hexidecimal string in Buffer.\r
-\r
-  @param  Flags Flags to use in printing string, see file header for details.\r
-\r
-  @param  Precision Minimum number of digits to return in the ASCII string\r
-\r
-  @return Number of characters printed.\r
-\r
-**/\r
-UINTN\r
-EFIAPI\r
-BasePrintLibValueToString (\r
-  IN OUT CHAR8  *Buffer,\r
-  IN INT64      Value,\r
-  IN UINTN      Radix\r
-  )\r
-{\r
-  UINTN   Digits;\r
-  UINT32  Remainder;\r
-\r
-  //\r
-  // Loop to convert one digit at a time in reverse order\r
-  //\r
-  *(Buffer++) = 0;\r
-  Digits = 0;\r
-  do {\r
-    // Value = (INT64)DivU64x32Remainder ((UINT64)Value, (UINT32)Radix, &Remainder);\r
-    Remainder = (UINT64)Value % (UINT32)Radix;\r
-    Value = (UINT64)Value / (UINT32)Radix;\r
-    *(Buffer++) = mHexStr[Remainder];\r
-    Digits++;\r
-  } while (Value != 0);\r
-  return Digits;\r
-}\r
-\r
-UINTN\r
-BasePrintLibConvertValueToString (\r
-  IN OUT CHAR8   *Buffer,\r
-  IN UINTN       Flags,\r
-  IN INT64       Value,\r
-  IN UINTN       Width,\r
-  IN UINTN       Increment\r
-  )\r
-{\r
-  CHAR8  *OriginalBuffer;\r
-  CHAR8  ValueBuffer[MAXIMUM_VALUE_CHARACTERS];\r
-  UINTN  Count;\r
-  UINTN  Digits;\r
-  UINTN  Index;\r
-\r
-  OriginalBuffer = Buffer;\r
-\r
-  if (Width == 0 || (Flags & COMMA_TYPE) != 0) {\r
-    Flags &= (~PREFIX_ZERO);\r
-  }\r
-\r
-  if (Width == 0 || Width > (MAXIMUM_VALUE_CHARACTERS - 1)) {\r
-    Width = MAXIMUM_VALUE_CHARACTERS - 1;\r
-  }\r
-\r
-  if (Value < 0) {\r
-    Value = -Value;\r
-    Buffer = BasePrintLibFillBuffer (Buffer, 1, '-', Increment);\r
-  }\r
-\r
-  Count = BasePrintLibValueToString (ValueBuffer, Value, 10);\r
-\r
-  if ((Flags & PREFIX_ZERO) != 0) {\r
-    Buffer = BasePrintLibFillBuffer (Buffer, Width - Count, '0', Increment);\r
-  }\r
-\r
-  Digits = 3 - (Count % 3);\r
-  for (Index = 0; Index < Count; Index++) {\r
-    Buffer = BasePrintLibFillBuffer (Buffer, 1, ValueBuffer[Count - Index], Increment);\r
-    if ((Flags & COMMA_TYPE) != 0) {\r
-      Digits++;\r
-      if (Digits == 3) {\r
-        Digits = 0;\r
-        if ((Index + 1) < Count) {\r
-          Buffer = BasePrintLibFillBuffer (Buffer, 1, ',', Increment);\r
-        }\r
-      }\r
-    }\r
-  }\r
-\r
-  Buffer = BasePrintLibFillBuffer (Buffer, 1, 0, Increment);\r
-\r
-  return ((Buffer - OriginalBuffer) / Increment);\r
-}\r
diff --git a/Tools/CodeTools/TianoTools/String/PrintLibInternal.h b/Tools/CodeTools/TianoTools/String/PrintLibInternal.h
deleted file mode 100644 (file)
index 87f0955..0000000
+++ /dev/null
@@ -1,101 +0,0 @@
-/*++\r
-\r
-Copyright (c)  2004-2006 Intel Corporation. All rights reserved\r
-This program and the accompanying materials are licensed and made available\r
-under the terms and conditions of the BSD License which accompanies this\r
-distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-\r
-Module Name:\r
-\r
-  PrintLibInternal.h\r
-\r
-Abstract:\r
-\r
-  Print Library.\r
-\r
---*/\r
-\r
-\r
-\r
-//\r
-// Print primitives\r
-//\r
-//#define LEFT_JUSTIFY      0x01\r
-#define PREFIX_SIGN       0x02\r
-#define PREFIX_BLANK      0x04\r
-//#define COMMA_TYPE        0x08\r
-#define LONG_TYPE         0x10\r
-//#define PREFIX_ZERO       0x20\r
-#define OUTPUT_UNICODE    0x40\r
-#define RADIX_HEX         0x80\r
-#define FORMAT_UNICODE    0x100\r
-#define PAD_TO_WIDTH      0x200\r
-#define ARGUMENT_UNICODE  0x400\r
-#define PRECISION         0x800\r
-#define ARGUMENT_REVERSED 0x1000\r
-\r
-///\r
-/// Define the maximum number of characters that are required to encode\r
-/// a decimal, hexidecimal, GUID, or TIME value with a Nll terminator.\r
-///   Maximum Length Decimal String     = 28    "-9,223,372,036,854,775,808"\r
-///   Maximum Length Hexidecimal String = 17    "FFFFFFFFFFFFFFFF"\r
-///   Maximum Length GUID               = 37    "00000000-0000-0000-0000-000000000000"\r
-///   Maximum Length TIME               = 18    "12/12/2006  12:12"\r
-///\r
-#define MAXIMUM_VALUE_CHARACTERS  38\r
-\r
-//\r
-//\r
-//\r
-typedef struct {\r
-  UINT16  Year;\r
-  UINT8   Month;\r
-  UINT8   Day;\r
-  UINT8   Hour;\r
-  UINT8   Minute;\r
-  UINT8   Second;\r
-  UINT8   Pad1;\r
-  UINT32  Nanosecond;\r
-  INT16   TimeZone;\r
-  UINT8   Daylight;\r
-  UINT8   Pad2;\r
-} TIME;\r
-\r
-UINTN\r
-BasePrintLibSPrint (\r
-  OUT CHAR8        *Buffer,\r
-  IN  UINTN        BufferSize,\r
-  IN  UINTN        Flags,\r
-  IN  CONST CHAR8  *FormatString,\r
-  ...\r
-  );\r
-\r
-CHAR8 *\r
-BasePrintLibFillBuffer (\r
-  CHAR8   *Buffer,\r
-  INTN    Length,\r
-  UINTN   Character,\r
-  INTN    Increment\r
-  );\r
-\r
-UINTN\r
-EFIAPI\r
-BasePrintLibValueToString (\r
-  IN OUT CHAR8  *Buffer,\r
-  IN INT64      Value,\r
-  IN UINTN      Radix\r
-  );\r
-\r
-UINTN\r
-BasePrintLibConvertValueToString (\r
-  IN OUT CHAR8   *Buffer,\r
-  IN UINTN       Flags,\r
-  IN INT64       Value,\r
-  IN UINTN       Width,\r
-  IN UINTN       Increment\r
-  );\r
diff --git a/Tools/CodeTools/TianoTools/String/String.c b/Tools/CodeTools/TianoTools/String/String.c
deleted file mode 100644 (file)
index 78d0a59..0000000
+++ /dev/null
@@ -1,732 +0,0 @@
-/*++\r
-\r
-Copyright (c)  2004-2006 Intel Corporation. All rights reserved\r
-This program and the accompanying materials are licensed and made available\r
-under the terms and conditions of the BSD License which accompanies this\r
-distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-\r
-Module Name:\r
-\r
-  String.c\r
-\r
-Abstract:\r
-\r
-  Unicode and ASCII string primatives.\r
-\r
---*/\r
-\r
-#include <assert.h>\r
-\r
-#include <Common/UefiBaseTypes.h>\r
-\r
-#include <string.h>\r
-\r
-#include "CommonLib.h"\r
-\r
-/**\r
-  Returns the length of a Null-terminated Unicode string.\r
-\r
-  This function returns the number of Unicode characters in the Null-terminated\r
-  Unicode string specified by String.\r
-\r
-  If String is NULL, then ASSERT().\r
-\r
-  @param  String  Pointer to a Null-terminated Unicode string.\r
-\r
-  @return The length of String.\r
-\r
-**/\r
-UINTN\r
-EFIAPI\r
-StrLen (\r
-  IN      CONST CHAR16              *String\r
-  )\r
-{\r
-  UINTN                             Length;\r
-\r
-  ASSERT (String != NULL);\r
-\r
-  for (Length = 0; *String != L'\0'; String++, Length++) {\r
-    ;\r
-  }\r
-  return Length;\r
-}\r
-\r
-/**\r
-  Returns the length of a Null-terminated ASCII string.\r
-\r
-  This function returns the number of ASCII characters in the Null-terminated\r
-  ASCII string specified by String.\r
-\r
-  If String is NULL, then ASSERT().\r
-\r
-  @param  String  Pointer to a Null-terminated ASCII string.\r
-\r
-  @return The length of String.\r
-\r
-**/\r
-UINTN\r
-EFIAPI\r
-AsciiStrLen (\r
-  IN      CONST CHAR8               *String\r
-  )\r
-{\r
-  UINTN                             Length;\r
-\r
-  ASSERT (String != NULL);\r
-\r
-  for (Length = 0; *String != '\0'; String++, Length++) {\r
-    ;\r
-  }\r
-  return Length;\r
-}\r
-\r
-/**\r
-  Copies one Null-terminated Unicode string to another Null-terminated Unicode\r
-  string and returns the new Unicode string.\r
-\r
-  This function copies the contents of the Unicode string Source to the Unicode\r
-  string Destination, and returns Destination. If Source and Destination\r
-  overlap, then the results are undefined.\r
-\r
-  If Destination is NULL, then ASSERT().\r
-  If Source is NULL, then ASSERT().\r
-  If Source and Destination overlap, then ASSERT().\r
-\r
-  @param  Destination Pointer to a Null-terminated Unicode string.\r
-  @param  Source      Pointer to a Null-terminated Unicode string.\r
-\r
-  @return Destiantion\r
-\r
-**/\r
-CHAR16 *\r
-EFIAPI\r
-StrCpy (\r
-  OUT     CHAR16                    *Destination,\r
-  IN      CONST CHAR16              *Source\r
-  )\r
-{\r
-  CHAR16                            *ReturnValue;\r
-\r
-  //\r
-  // Destination cannot be NULL\r
-  //\r
-  ASSERT (Destination != NULL);\r
-\r
-  //\r
-  // Destination and source cannot overlap\r
-  //\r
-  ASSERT ((UINTN)(Destination - Source) > StrLen (Source));\r
-  ASSERT ((UINTN)(Source - Destination) > StrLen (Source));\r
-\r
-  ReturnValue = Destination;\r
-  while (*Source) {\r
-    *(Destination++) = *(Source++);\r
-  }\r
-  *Destination = 0;\r
-  return ReturnValue;\r
-}\r
-\r
-/**\r
-  Copies one Null-terminated Unicode string with a maximum length to another\r
-  Null-terminated Unicode string with a maximum length and returns the new\r
-  Unicode string.\r
-\r
-  This function copies the contents of the Unicode string Source to the Unicode\r
-  string Destination, and returns Destination. At most, Length Unicode\r
-  characters are copied from Source to Destination. If Length is 0, then\r
-  Destination is returned unmodified. If Length is greater that the number of\r
-  Unicode characters in Source, then Destination is padded with Null Unicode\r
-  characters. If Source and Destination overlap, then the results are\r
-  undefined.\r
-\r
-  If Destination is NULL, then ASSERT().\r
-  If Source is NULL, then ASSERT().\r
-  If Source and Destination overlap, then ASSERT().\r
-\r
-  @param  Destination Pointer to a Null-terminated Unicode string.\r
-  @param  Source      Pointer to a Null-terminated Unicode string.\r
-  @param  Length      Maximum number of Unicode characters to copy.\r
-\r
-  @return Destination\r
-\r
-**/\r
-CHAR16 *\r
-EFIAPI\r
-StrnCpy (\r
-  OUT     CHAR16                    *Destination,\r
-  IN      CONST CHAR16              *Source,\r
-  IN      UINTN                     Length\r
-  )\r
-{\r
-  CHAR16                            *ReturnValue;\r
-\r
-  if (Length == 0) {\r
-    return Destination;\r
-  }\r
-\r
-  //\r
-  // Destination cannot be NULL if Length is not zero\r
-  //\r
-  ASSERT (Destination != NULL);\r
-\r
-  //\r
-  // Destination and source cannot overlap\r
-  // Q: Does Source have to be NULL-terminated?\r
-  //\r
-  ASSERT ((UINTN)(Destination - Source) > StrLen (Source));\r
-  ASSERT ((UINTN)(Source - Destination) >= Length);\r
-\r
-  ReturnValue = Destination;\r
-\r
-  while ((*Source != L'\0') && (Length > 0)) {\r
-    *(Destination++) = *(Source++);\r
-    Length--;\r
-  }\r
-\r
-  memset (Destination, 0, Length * sizeof (*Destination));\r
-  return ReturnValue;\r
-}\r
-\r
-/**\r
-  Returns the size of a Null-terminated Unicode string in bytes, including the\r
-  Null terminator.\r
-\r
-  This function returns the size, in bytes, of the Null-terminated Unicode\r
-  string specified by String.\r
-\r
-  If String is NULL, then ASSERT().\r
-\r
-  @param  String  Pointer to a Null-terminated Unicode string.\r
-\r
-  @return The size of String.\r
-\r
-**/\r
-UINTN\r
-EFIAPI\r
-StrSize (\r
-  IN      CONST CHAR16              *String\r
-  )\r
-{\r
-  return (StrLen (String) + 1) * sizeof (*String);\r
-}\r
-\r
-/**\r
-  Compares two Null-terminated Unicode strings, and returns the difference\r
-  between the first mismatched Unicode characters.\r
-\r
-  This function compares the Null-terminated Unicode string FirstString to the\r
-  Null-terminated Unicode string SecondString. If FirstString is identical to\r
-  SecondString, then 0 is returned. Otherwise, the value returned is the first\r
-  mismatched Unicode character in SecondString subtracted from the first\r
-  mismatched Unicode character in FirstString.\r
-\r
-  If FirstString is NULL, then ASSERT().\r
-  If SecondString is NULL, then ASSERT().\r
-\r
-  @param  FirstString   Pointer to a Null-terminated Unicode string.\r
-  @param  SecondString  Pointer to a Null-terminated Unicode string.\r
-\r
-  @retval 0   FirstString is identical to SecondString.\r
-  @retval !=0 FirstString is not identical to SecondString.\r
-\r
-**/\r
-INTN\r
-EFIAPI\r
-StrCmp (\r
-  IN      CONST CHAR16              *FirstString,\r
-  IN      CONST CHAR16              *SecondString\r
-  )\r
-{\r
-  //\r
-  // ASSERT both strings should never be zero\r
-  //\r
-  ASSERT (StrSize (FirstString) != 0);\r
-  ASSERT (StrSize (SecondString) != 0);\r
-\r
-  while ((*FirstString != L'\0') && (*FirstString == *SecondString)) {\r
-    FirstString++;\r
-    SecondString++;\r
-  }\r
-  return *FirstString - *SecondString;\r
-}\r
-\r
-/**\r
-  Compares two Null-terminated Unicode strings with maximum lengths, and\r
-  returns the difference between the first mismatched Unicode characters.\r
-\r
-  This function compares the Null-terminated Unicode string FirstString to the\r
-  Null-terminated Unicode string SecondString. At most, Length Unicode\r
-  characters will be compared. If Length is 0, then 0 is returned. If\r
-  FirstString is identical to SecondString, then 0 is returned. Otherwise, the\r
-  value returned is the first mismatched Unicode character in SecondString\r
-  subtracted from the first mismatched Unicode character in FirstString.\r
-\r
-  If FirstString is NULL, then ASSERT().\r
-  If SecondString is NULL, then ASSERT().\r
-\r
-  @param  FirstString   Pointer to a Null-terminated Unicode string.\r
-  @param  SecondString  Pointer to a Null-terminated Unicode string.\r
-  @param  Length        Maximum number of Unicode characters to compare.\r
-\r
-  @retval 0   FirstString is identical to SecondString.\r
-  @retval !=0 FirstString is not identical to SecondString.\r
-\r
-**/\r
-INTN\r
-EFIAPI\r
-StrnCmp (\r
-  IN      CONST CHAR16              *FirstString,\r
-  IN      CONST CHAR16              *SecondString,\r
-  IN      UINTN                     Length\r
-  )\r
-{\r
-  if (Length == 0) {\r
-    return 0;\r
-  }\r
-\r
-  //\r
-  // ASSERT both strings should never be zero\r
-  //\r
-  ASSERT (StrSize (FirstString) != 0);\r
-  ASSERT (StrSize (SecondString) != 0);\r
-\r
-  while ((*FirstString != L'\0') &&\r
-         (*FirstString == *SecondString) &&\r
-         (Length > 1)) {\r
-    FirstString++;\r
-    SecondString++;\r
-    Length--;\r
-  }\r
-\r
-  return *FirstString - *SecondString;\r
-}\r
-\r
-/**\r
-  Concatenates one Null-terminated Unicode string to another Null-terminated\r
-  Unicode string, and returns the concatenated Unicode string.\r
-\r
-  This function concatenates two Null-terminated Unicode strings. The contents\r
-  of Null-terminated Unicode string Source are concatenated to the end of\r
-  Null-terminated Unicode string Destination. The Null-terminated concatenated\r
-  Unicode String is returned. If Source and Destination overlap, then the\r
-  results are undefined.\r
-\r
-  If Destination is NULL, then ASSERT().\r
-  If Source is NULL, then ASSERT().\r
-  If Source and Destination overlap, then ASSERT().\r
-\r
-  @param  Destination Pointer to a Null-terminated Unicode string.\r
-  @param  Source      Pointer to a Null-terminated Unicode string.\r
-\r
-  @return Destination\r
-\r
-**/\r
-CHAR16 *\r
-EFIAPI\r
-StrCat (\r
-  IN OUT  CHAR16                    *Destination,\r
-  IN      CONST CHAR16              *Source\r
-  )\r
-{\r
-  StrCpy (Destination + StrLen (Destination), Source);\r
-\r
-  //\r
-  // Size of the resulting string should never be zero.\r
-  //\r
-  ASSERT (StrSize (Destination) != 0);\r
-  return Destination;\r
-}\r
-\r
-/**\r
-  Concatenates one Null-terminated Unicode string with a maximum length to the\r
-  end of another Null-terminated Unicode string, and returns the concatenated\r
-  Unicode string.\r
-\r
-  This function concatenates two Null-terminated Unicode strings. The contents\r
-  of Null-terminated Unicode string Source are concatenated to the end of\r
-  Null-terminated Unicode string Destination, and Destination is returned. At\r
-  most, Length Unicode characters are concatenated from Source to the end of\r
-  Destination, and Destination is always Null-terminated. If Length is 0, then\r
-  Destination is returned unmodified. If Source and Destination overlap, then\r
-  the results are undefined.\r
-\r
-  If Destination is NULL, then ASSERT().\r
-  If Source is NULL, then ASSERT().\r
-  If Source and Destination overlap, then ASSERT().\r
-\r
-  @param  Destination Pointer to a Null-terminated Unicode string.\r
-  @param  Source      Pointer to a Null-terminated Unicode string.\r
-  @param  Length      Maximum number of Unicode characters to concatenate from\r
-                      Source.\r
-\r
-  @return Destination\r
-\r
-**/\r
-CHAR16 *\r
-EFIAPI\r
-StrnCat (\r
-  IN OUT  CHAR16                    *Destination,\r
-  IN      CONST CHAR16              *Source,\r
-  IN      UINTN                     Length\r
-  )\r
-{\r
-  StrnCpy (Destination + StrLen (Destination), Source, Length);\r
-\r
-  //\r
-  // Size of the resulting string should never be zero.\r
-  //\r
-  ASSERT (StrSize (Destination) != 0);\r
-  return Destination;\r
-}\r
-\r
-/**\r
-  Copies one Null-terminated ASCII string to another Null-terminated ASCII\r
-  string and returns the new ASCII string.\r
-\r
-  This function copies the contents of the ASCII string Source to the ASCII\r
-  string Destination, and returns Destination. If Source and Destination\r
-  overlap, then the results are undefined.\r
-\r
-  If Destination is NULL, then ASSERT().\r
-  If Source is NULL, then ASSERT().\r
-  If Source and Destination overlap, then ASSERT().\r
-\r
-  @param  Destination Pointer to a Null-terminated ASCII string.\r
-  @param  Source      Pointer to a Null-terminated ASCII string.\r
-\r
-  @return Destination\r
-\r
-**/\r
-CHAR8 *\r
-EFIAPI\r
-AsciiStrCpy (\r
-  OUT     CHAR8                     *Destination,\r
-  IN      CONST CHAR8               *Source\r
-  )\r
-{\r
-  CHAR8                             *ReturnValue;\r
-\r
-  //\r
-  // Destination cannot be NULL\r
-  //\r
-  ASSERT (Destination != NULL);\r
-\r
-  //\r
-  // Destination and source cannot overlap\r
-  //\r
-  ASSERT ((UINTN)(Destination - Source) > AsciiStrLen (Source));\r
-  ASSERT ((UINTN)(Source - Destination) > AsciiStrLen (Source));\r
-\r
-  ReturnValue = Destination;\r
-  while (*Source) {\r
-    *(Destination++) = *(Source++);\r
-  }\r
-  *Destination = 0;\r
-  return ReturnValue;\r
-}\r
-\r
-/**\r
-  Copies one Null-terminated ASCII string with a maximum length to another\r
-  Null-terminated ASCII string with a maximum length and returns the new ASCII\r
-  string.\r
-\r
-  This function copies the contents of the ASCII string Source to the ASCII\r
-  string Destination, and returns Destination. At most, Length ASCII characters\r
-  are copied from Source to Destination. If Length is 0, then Destination is\r
-  returned unmodified. If Length is greater that the number of ASCII characters\r
-  in Source, then Destination is padded with Null ASCII characters. If Source\r
-  and Destination overlap, then the results are undefined.\r
-\r
-  If Destination is NULL, then ASSERT().\r
-  If Source is NULL, then ASSERT().\r
-  If Source and Destination overlap, then ASSERT().\r
-\r
-  @param  Destination Pointer to a Null-terminated ASCII string.\r
-  @param  Source      Pointer to a Null-terminated ASCII string.\r
-  @param  Length      Maximum number of ASCII characters to copy.\r
-\r
-  @return Destination\r
-\r
-**/\r
-CHAR8 *\r
-EFIAPI\r
-AsciiStrnCpy (\r
-  OUT     CHAR8                     *Destination,\r
-  IN      CONST CHAR8               *Source,\r
-  IN      UINTN                     Length\r
-  )\r
-{\r
-  CHAR8                             *ReturnValue;\r
-\r
-  if (Length == 0) {\r
-    return Destination;\r
-  }\r
-\r
-  //\r
-  // Destination cannot be NULL\r
-  //\r
-  ASSERT (Destination != NULL);\r
-\r
-  //\r
-  // Destination and source cannot overlap\r
-  //\r
-  ASSERT ((UINTN)(Destination - Source) > AsciiStrLen (Source));\r
-  ASSERT ((UINTN)(Source - Destination) >= Length);\r
-\r
-  ReturnValue = Destination;\r
-\r
-  while (*Source && Length > 0) {\r
-    *(Destination++) = *(Source++);\r
-    Length--;\r
-  }\r
-\r
-  // ZeroMem (Destination, Length * sizeof (*Destination));\r
-  memset (Destination, 0, Length * sizeof (*Destination));\r
-  return ReturnValue;\r
-}\r
-\r
-/**\r
-  Returns the size of a Null-terminated ASCII string in bytes, including the\r
-  Null terminator.\r
-\r
-  This function returns the size, in bytes, of the Null-terminated ASCII string\r
-  specified by String.\r
-\r
-  If String is NULL, then ASSERT().\r
-\r
-  @param  String  Pointer to a Null-terminated ASCII string.\r
-\r
-  @return The size of String.\r
-\r
-**/\r
-UINTN\r
-EFIAPI\r
-AsciiStrSize (\r
-  IN      CONST CHAR8               *String\r
-  )\r
-{\r
-  return (AsciiStrLen (String) + 1) * sizeof (*String);\r
-}\r
-\r
-/**\r
-  Compares two Null-terminated ASCII strings, and returns the difference\r
-  between the first mismatched ASCII characters.\r
-\r
-  This function compares the Null-terminated ASCII string FirstString to the\r
-  Null-terminated ASCII string SecondString. If FirstString is identical to\r
-  SecondString, then 0 is returned. Otherwise, the value returned is the first\r
-  mismatched ASCII character in SecondString subtracted from the first\r
-  mismatched ASCII character in FirstString.\r
-\r
-  If FirstString is NULL, then ASSERT().\r
-  If SecondString is NULL, then ASSERT().\r
-\r
-  @param  FirstString   Pointer to a Null-terminated ASCII string.\r
-  @param  SecondString  Pointer to a Null-terminated ASCII string.\r
-\r
-  @retval 0   FirstString is identical to SecondString.\r
-  @retval !=0 FirstString is not identical to SecondString.\r
-\r
-**/\r
-INTN\r
-EFIAPI\r
-AsciiStrCmp (\r
-  IN      CONST CHAR8               *FirstString,\r
-  IN      CONST CHAR8               *SecondString\r
-  )\r
-{\r
-  //\r
-  // ASSERT both strings should never be zero\r
-  //\r
-  ASSERT (AsciiStrSize (FirstString));\r
-  ASSERT (AsciiStrSize (SecondString));\r
-\r
-  while ((*FirstString != '\0') && (*FirstString == *SecondString)) {\r
-    FirstString++;\r
-    SecondString++;\r
-  }\r
-\r
-  return *FirstString - *SecondString;\r
-}\r
-\r
-STATIC\r
-CHAR8\r
-EFIAPI\r
-AsciiToUpper (\r
-  IN      CHAR8                     Chr\r
-  )\r
-{\r
-  return (Chr >= 'a' && Chr <= 'z') ? Chr - ('a' - 'A') : Chr;\r
-}\r
-\r
-/**\r
-  Performs a case insensitive comparison of two Null-terminated ASCII strings,\r
-  and returns the difference between the first mismatched ASCII characters.\r
-\r
-  This function performs a case insensitive comparison of the Null-terminated\r
-  ASCII string FirstString to the Null-terminated ASCII string SecondString. If\r
-  FirstString is identical to SecondString, then 0 is returned. Otherwise, the\r
-  value returned is the first mismatched lower case ASCII character in\r
-  SecondString subtracted from the first mismatched lower case ASCII character\r
-  in FirstString.\r
-\r
-  If FirstString is NULL, then ASSERT().\r
-  If SecondString is NULL, then ASSERT().\r
-\r
-  @param  FirstString   Pointer to a Null-terminated ASCII string.\r
-  @param  SecondString  Pointer to a Null-terminated ASCII string.\r
-\r
-  @retval 0   FirstString is identical to SecondString using case insensitive\r
-              comparisons.\r
-  @retval !=0 FirstString is not identical to SecondString using case\r
-              insensitive comparisons.\r
-\r
-**/\r
-INTN\r
-EFIAPI\r
-AsciiStriCmp (\r
-  IN      CONST CHAR8               *FirstString,\r
-  IN      CONST CHAR8               *SecondString\r
-  )\r
-{\r
-  //\r
-  // ASSERT both strings should never be zero\r
-  //\r
-  ASSERT (AsciiStrSize (FirstString));\r
-  ASSERT (AsciiStrSize (SecondString));\r
-\r
-  while ((*FirstString != '\0') &&\r
-         (AsciiToUpper (*FirstString) == AsciiToUpper (*SecondString))) {\r
-    FirstString++;\r
-    SecondString++;\r
-  }\r
-\r
-  return AsciiToUpper (*FirstString) - AsciiToUpper (*SecondString);\r
-}\r
-\r
-/**\r
-  Compares two Null-terminated ASCII strings with maximum lengths, and returns\r
-  the difference between the first mismatched ASCII characters.\r
-\r
-  This function compares the Null-terminated ASCII string FirstString to the\r
-  Null-terminated ASCII  string SecondString. At most, Length ASCII characters\r
-  will be compared. If Length is 0, then 0 is returned. If FirstString is\r
-  identical to SecondString, then 0 is returned. Otherwise, the value returned\r
-  is the first mismatched ASCII character in SecondString subtracted from the\r
-  first mismatched ASCII character in FirstString.\r
-\r
-  If FirstString is NULL, then ASSERT().\r
-  If SecondString is NULL, then ASSERT().\r
-\r
-  @param  FirstString   Pointer to a Null-terminated ASCII string.\r
-  @param  SecondString  Pointer to a Null-terminated ASCII string.\r
-\r
-  @retval 0   FirstString is identical to SecondString.\r
-  @retval !=0 FirstString is not identical to SecondString.\r
-\r
-**/\r
-INTN\r
-EFIAPI\r
-AsciiStrnCmp (\r
-  IN      CONST CHAR8               *FirstString,\r
-  IN      CONST CHAR8               *SecondString,\r
-  IN      UINTN                     Length\r
-  )\r
-{\r
-  //\r
-  // ASSERT both strings should never be zero\r
-  //\r
-  ASSERT (AsciiStrSize (FirstString));\r
-  ASSERT (AsciiStrSize (SecondString));\r
-\r
-  while ((*FirstString != '\0') &&\r
-         (*FirstString == *SecondString) &&\r
-         (Length > 1)) {\r
-    FirstString++;\r
-    SecondString++;\r
-    Length--;\r
-  }\r
-  return *FirstString - *SecondString;\r
-}\r
-\r
-/**\r
-  Concatenates one Null-terminated ASCII string to another Null-terminated\r
-  ASCII string, and returns the concatenated ASCII string.\r
-\r
-  This function concatenates two Null-terminated ASCII strings. The contents of\r
-  Null-terminated ASCII string Source are concatenated to the end of Null-\r
-  terminated ASCII string Destination. The Null-terminated concatenated ASCII\r
-  String is returned.\r
-\r
-  If Destination is NULL, then ASSERT().\r
-  If Source is NULL, then ASSERT().\r
-\r
-  @param  Destination Pointer to a Null-terminated ASCII string.\r
-  @param  Source      Pointer to a Null-terminated ASCII string.\r
-\r
-  @return Destination\r
-\r
-**/\r
-CHAR8 *\r
-EFIAPI\r
-AsciiStrCat (\r
-  IN OUT CHAR8    *Destination,\r
-  IN CONST CHAR8  *Source\r
-  )\r
-{\r
-  AsciiStrCpy (Destination + AsciiStrLen (Destination), Source);\r
-\r
-  //\r
-  // Size of the resulting string should never be zero.\r
-  //\r
-  ASSERT (AsciiStrSize (Destination) != 0);\r
-  return Destination;\r
-}\r
-\r
-/**\r
-  Concatenates one Null-terminated ASCII string with a maximum length to the\r
-  end of another Null-terminated ASCII string, and returns the concatenated\r
-  ASCII string.\r
-\r
-  This function concatenates two Null-terminated ASCII strings. The contents\r
-  of Null-terminated ASCII string Source are concatenated to the end of Null-\r
-  terminated ASCII string Destination, and Destination is returned. At most,\r
-  Length ASCII characters are concatenated from Source to the end of\r
-  Destination, and Destination is always Null-terminated. If Length is 0, then\r
-  Destination is returned unmodified. If Source and Destination overlap, then\r
-  the results are undefined.\r
-\r
-  If Destination is NULL, then ASSERT().\r
-  If Source is NULL, then ASSERT().\r
-  If Source and Destination overlap, then ASSERT().\r
-\r
-  @param  Destination Pointer to a Null-terminated ASCII string.\r
-  @param  Source      Pointer to a Null-terminated ASCII string.\r
-  @param  Length      Maximum number of ASCII characters to concatenate from\r
-                      Source.\r
-\r
-  @return Destination\r
-\r
-**/\r
-CHAR8 *\r
-EFIAPI\r
-AsciiStrnCat (\r
-  IN OUT  CHAR8                     *Destination,\r
-  IN      CONST CHAR8               *Source,\r
-  IN      UINTN                     Length\r
-  )\r
-{\r
-  AsciiStrnCpy (Destination + AsciiStrLen (Destination), Source, Length);\r
-\r
-  //\r
-  // Size of the resulting string should never be zero.\r
-  //\r
-  ASSERT (AsciiStrSize (Destination) != 0);\r
-  return Destination;\r
-}\r
diff --git a/Tools/CodeTools/TianoTools/String/build.xml b/Tools/CodeTools/TianoTools/String/build.xml
deleted file mode 100644 (file)
index 933cb5c..0000000
+++ /dev/null
@@ -1,96 +0,0 @@
-<?xml version="1.0" ?>\r
-<!--\r
-Copyright (c) 2006, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
--->\r
-<project default="GenTool" basedir=".">\r
-<!--\r
-    EDK String\r
-  Copyright (c) 2006, Intel Corporation\r
--->\r
-  <taskdef resource="cpptasks.tasks"/>\r
-  <typedef resource="cpptasks.types"/>\r
-  <taskdef resource="net/sf/antcontrib/antlib.xml"/>\r
-\r
-  <property name="LibName" value="String"/>\r
-  <property name="LINK_OUTPUT_TYPE" value="static"/>\r
-  <property name="BUILD_DIR" value="${PACKAGE_DIR}/${LibName}/tmp"/>\r
-\r
-  <target name="GenTool" depends="init, String">\r
-    <echo message="The EDK Library: ${LibName} build has completed!"/>\r
-  </target>\r
-\r
-  <target name="init">\r
-    <echo message="Building the EDK Library: ${LibName}"/>\r
-    <mkdir dir="${BUILD_DIR}"/>\r
-\r
-    <condition property="syslibdirs" value="">\r
-      <os family="mac"/>\r
-    </condition>\r
-    \r
-    <condition property="syslibs" value="">\r
-      <os family="mac"/>\r
-    </condition>\r
-    \r
-    <condition property="syslibdirs" value="${env.CYGWIN_HOME}/lib/e2fsprogs">\r
-      <os family="windows"/>\r
-    </condition>\r
-    \r
-    <condition property="syslibs" value="uuid">\r
-      <os family="windows"/>\r
-    </condition>\r
-    \r
-    <condition property="syslibdirs" value="/usr/lib">\r
-      <os name="Linux"/>\r
-    </condition>\r
-    \r
-    <condition property="syslibs" value="uuid">\r
-      <os name="Linux"/>\r
-    </condition>\r
-    \r
-  </target>\r
-\r
-  <target name="String" depends="init">\r
-    <cc name="${ToolChain}" objdir="${BUILD_DIR}" \r
-        outfile="${LIB_DIR}/${LibName}"\r
-        outtype="static"\r
-        debug="true"\r
-        optimize="speed">\r
-      <compilerarg value="${ExtraArgus}" if="ExtraArgus" />\r
-      <compilerarg value="-fshort-wchar" if="gcc"/>\r
-\r
-      <fileset dir="${basedir}/${LibName}" \r
-        includes="*.c" />\r
-\r
-      <includepath path="${PACKAGE_DIR}/${LibName}"/>\r
-      <includepath path="${PACKAGE_DIR}/Include"/>\r
-      <includepath path="${PACKAGE_DIR}/Include/${HostArch}"/>\r
-      <includepath path="${PACKAGE_DIR}/Common"/>\r
-    </cc>\r
-  </target>\r
-\r
-\r
-  <target name="clean">\r
-    <echo message="Removing Intermediate Files Only"/>  \r
-    <delete>\r
-      <fileset dir="${BUILD_DIR}" includes="*.obj"/>\r
-    </delete>\r
-  </target>\r
-\r
-  <target name="cleanall">\r
-    <echo message="Removing Object Files and the Library: ${LibName}${ext_static}"/>  \r
-    <delete dir="${PACKAGE_DIR}/${LibName}/tmp">\r
-    </delete>\r
-    <delete failonerror="false" quiet="true" includeEmptyDirs="true">\r
-      <fileset dir="${BUILD_DIR}"/>\r
-      <fileset file="${LIB_DIR}/${LibName}${ext_static}"/>\r
-    </delete>\r
-  </target>\r
-\r
-</project>\r
diff --git a/Tools/CodeTools/TianoTools/Strip/Strip.c b/Tools/CodeTools/TianoTools/Strip/Strip.c
deleted file mode 100644 (file)
index bccdffb..0000000
+++ /dev/null
@@ -1,105 +0,0 @@
-/*++\r
-\r
-Copyright (c)  2004-2006 Intel Corporation. All rights reserved\r
-This program and the accompanying materials are licensed and made available\r
-under the terms and conditions of the BSD License which accompanies this\r
-distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-\r
-Module Name:\r
-\r
-  Strip.c\r
-\r
-Abstract:\r
-\r
-  Quick Exe2Bin equivalent.\r
-\r
---*/\r
-\r
-#include <stdio.h>\r
-#include <memory.h>\r
-#include <string.h>\r
-#include <stdlib.h>\r
-\r
-int\r
-main (\r
-  int  argc,\r
-  char *argv[]\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Converts executable files to binary files.\r
-\r
-Arguments:\r
-\r
-  argc   - Number of command line arguments\r
-  argv[] - Array of pointers to the command line arguments\r
-\r
-Returns:\r
-\r
-  Zero     - Function completed successfully.\r
-  Non-zero - Function exited with errors.\r
-\r
---*/\r
-{\r
-  FILE  *InFile;\r
-  FILE  *OutFile;\r
-  int   Index;\r
-  int   FileSize;\r
-  char  *Buffer;\r
-  char  *Ptrx;\r
-\r
-  if (argc < 3) {\r
-    printf ("Need more args, such as file name to convert and output name\n");\r
-    return -1;\r
-  }\r
-\r
-  InFile  = fopen (argv[1], "rb");\r
-  OutFile = fopen (argv[2], "wb");\r
-\r
-  if (!InFile) {\r
-    printf ("no file, exit\n");\r
-    return -1;\r
-  }\r
-\r
-  if (OutFile == NULL) {\r
-    printf ("Unable to open output file.\n");\r
-    return -1;\r
-  }\r
-\r
-  fseek (InFile, 0, SEEK_END);\r
-  FileSize = ftell (InFile);\r
-\r
-  if (FileSize < 0x200) {\r
-    printf ("%d is not a legal size, exit\n", FileSize);\r
-    return -1;\r
-  }\r
-\r
-  fseek (InFile, 0, SEEK_SET);\r
-\r
-  Buffer = (char *) malloc (FileSize);\r
-  if (Buffer == NULL) {\r
-    printf ("Error: Out of resources.\n");\r
-    return -1;\r
-  }\r
-\r
-  fread (Buffer, 1, FileSize, InFile);\r
-\r
-  Ptrx  = Buffer + 0x200;\r
-\r
-  Index = FileSize - 0x200;\r
-\r
-  fwrite (Ptrx, Index, 1, OutFile);\r
-\r
-  fclose (InFile);\r
-  fclose (OutFile);\r
-  free (Buffer);\r
-\r
-  return 0;\r
-}\r
diff --git a/Tools/CodeTools/TianoTools/Strip/build.xml b/Tools/CodeTools/TianoTools/Strip/build.xml
deleted file mode 100644 (file)
index 9ead28d..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-<?xml version="1.0" ?>\r
-<!--\r
-Copyright (c) 2006, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
--->\r
-<project default="GenTool" basedir=".">\r
-<!--\r
-    EDK Strip Tool\r
-  Copyright (c) 2006, Intel Corporation\r
--->\r
-  <property name="ToolName" value="Strip"/>\r
-  <property name="FileSet" value="*.c"/>\r
-\r
-  <taskdef resource="cpptasks.tasks"/>\r
-  <typedef resource="cpptasks.types"/>\r
-  <taskdef resource="net/sf/antcontrib/antlib.xml"/>\r
-\r
-  <property name="LINK_OUTPUT_TYPE" value="static"/>\r
-  <property name="BUILD_DIR" value="${PACKAGE_DIR}/${ToolName}/tmp"/>\r
-\r
-  <target name="GenTool" depends="init, Tool">\r
-    <echo message="The EDK Tool: ${ToolName} build has completed!"/>\r
-  </target>\r
-\r
-  <target name="init">\r
-    <echo message="Building the EDK Tool: ${ToolName}"/>\r
-    <mkdir dir="${BUILD_DIR}"/>\r
-  </target>\r
-\r
-  <target name="Tool" depends="init">\r
-    <cc name="${ToolChain}" objdir="${BUILD_DIR}" \r
-        outfile="${BIN_DIR}/${ToolName}"\r
-        outtype="executable"\r
-        optimize="speed" \r
-        debug="true">\r
-\r
-      <fileset dir="${basedir}/${ToolName}" \r
-        includes="${FileSet}" \r
-        defaultexcludes="TRUE" \r
-        excludes="*.xml *.inf"/>\r
-\r
-      <includepath path="${PACKAGE_DIR}/Include"/>\r
-      <includepath path="${PACKAGE_DIR}/Include/Ia32"/>\r
-      <includepath path="${PACKAGE_DIR}/Common"/>\r
-    </cc>\r
-  </target>\r
-\r
-  <target name="clean">\r
-    <echo message="Removing Intermediate Files Only"/>  \r
-    <delete>\r
-      <fileset dir="${BUILD_DIR}" includes="*.obj"/>\r
-    </delete>\r
-  </target>\r
-\r
-  <target name="cleanall">\r
-    <echo message="Removing Object Files and the Executable: ${ToolName}${ext_exe}"/>  \r
-    <delete failonerror="false" quiet="true" includeEmptyDirs="true">\r
-      <fileset dir="${BUILD_DIR}"/>\r
-      <fileset file="${BIN_DIR}/${ToolName}${ext_exe}"/>\r
-    </delete>\r
-  </target>\r
-\r
-</project>\r
diff --git a/Tools/CodeTools/TianoTools/TianoTools.msa b/Tools/CodeTools/TianoTools/TianoTools.msa
deleted file mode 100644 (file)
index 2e4b27c..0000000
+++ /dev/null
@@ -1,316 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>\r
-<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">\r
-  <MsaHeader>\r
-    <ModuleName>Tiano C Tools</ModuleName>\r
-    <ModuleType>TOOL</ModuleType>\r
-    <GuidValue>A169C678-3F55-4b6a-80BF-FD8B8DCAB883</GuidValue>\r
-    <Version>2.0</Version>\r
-    <Abstract>This is the TianoTools Module</Abstract>\r
-    <Description>This Module provides the EFI/Tiano Tools that are used to create EFI/Tiano
-      Modules and Platform Binary Files (PBF)
-      These tools require compilation only once if the Developer Workstation and
-      the Developer's choice of HOST tool chain are stable.  If the developer
-      updates either the OS or the HOST tool chain, these tools should be rebuilt.</Description>\r
-    <Copyright>Copyright 2006, Intel Corporation</Copyright>\r
-    <License URL="http://opensource.org/licenses/bsd-license.php">All rights reserved.  This program and the accompanying materials
-are licensed and made available under the terms and conditions of the 
-BSD License which accompanies this distribution.  The full text of the 
-license may be found at
-http://opensource.org/licenses/bsd-license.php
-
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.</License>\r
-    <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION   0x00000052</Specification>\r
-  </MsaHeader>\r
-  <ModuleDefinitions>\r
-    <SupportedArchitectures>EBC IA32 X64 IPF</SupportedArchitectures>\r
-    <BinaryModule>false</BinaryModule>\r
-    <OutputFileBasename>NULL</OutputFileBasename>\r
-  </ModuleDefinitions>\r
-  <SourceFiles>\r
-    <Filename>build.xml</Filename>\r
-    <Filename>Common/build.xml</Filename>\r
-    <Filename>Common/CommonLib.c</Filename>\r
-    <Filename>Common/CommonLib.h</Filename>\r
-    <Filename>Common/Crc32.c</Filename>\r
-    <Filename>Common/Crc32.h</Filename>\r
-    <Filename>Common/EfiCompress.c</Filename>\r
-    <Filename>Common/EfiCompress.h</Filename>\r
-    <Filename>Common/EfiCustomizedCompress.h</Filename>\r
-    <Filename>Common/EfiDecompress.c</Filename>\r
-    <Filename>Common/EfiDecompress.h</Filename>\r
-    <Filename>Common/EfiUtilityMsgs.c</Filename>\r
-    <Filename>Common/EfiUtilityMsgs.h</Filename>\r
-    <Filename>Common/FvLib.c</Filename>\r
-    <Filename>Common/FvLib.h</Filename>\r
-    <Filename>Common/MyAlloc.c</Filename>\r
-    <Filename>Common/MyAlloc.h</Filename>\r
-    <Filename>Common/ParseInf.c</Filename>\r
-    <Filename>Common/ParseInf.h</Filename>\r
-    <Filename>Common/SimpleFileParsing.c</Filename>\r
-    <Filename>Common/SimpleFileParsing.h</Filename>\r
-    <Filename>Common/WinNtInclude.h</Filename>\r
-    <Filename>CompressDll/build.xml</Filename>\r
-    <Filename>CompressDll/CompressDll.c</Filename>\r
-    <Filename>CompressDll/CompressDll.h</Filename>\r
-    <Filename>CreateMtFile/build.xml</Filename>\r
-    <Filename>CreateMtFile/CreateMtFile.c</Filename>\r
-    <Filename>CustomizedCompress/build.xml</Filename>\r
-    <Filename>CustomizedCompress/CustomizedCompress.c</Filename>\r
-    <Filename>EfiCompress/build.xml</Filename>\r
-    <Filename>EfiCompress/EfiCompressMain.c</Filename>\r
-    <Filename>EfiCompress/makefile</Filename>\r
-    <Filename>EfiRom/build.xml</Filename>\r
-    <Filename>EfiRom/EfiRom.c</Filename>\r
-    <Filename>FlashMap/build.xml</Filename>\r
-    <Filename>FlashMap/FlashDefFile.c</Filename>\r
-    <Filename>FlashMap/FlashDefFile.h</Filename>\r
-    <Filename>FlashMap/FlashMap.c</Filename>\r
-    <Filename>FlashMap/Microcode.c</Filename>\r
-    <Filename>FlashMap/Microcode.h</Filename>\r
-    <Filename>FlashMap/Symbols.c</Filename>\r
-    <Filename>FlashMap/Symbols.h</Filename>\r
-    <Filename>FwImage/build.xml</Filename>\r
-    <Filename>FwImage/fwimage.c</Filename>\r
-    <Filename>GenAcpiTable/build.xml</Filename>\r
-    <Filename>GenAcpiTable/GenAcpiTable.c</Filename>\r
-    <Filename>GenCapsuleHdr/build.xml</Filename>\r
-    <Filename>GenCapsuleHdr/CreateGuid.c</Filename>\r
-    <Filename>GenCapsuleHdr/GenCapsuleHdr.c</Filename>\r
-    <Filename>GenCRC32Section/build.xml</Filename>\r
-    <Filename>GenCRC32Section/GenCRC32Section.c</Filename>\r
-    <Filename>GenCRC32Section/GenCRC32Section.h</Filename>\r
-    <Filename>GenDepex/build.xml</Filename>\r
-    <Filename>GenDepex/DepexParser.c</Filename>\r
-    <Filename>GenDepex/DepexParser.h</Filename>\r
-    <Filename>GenDepex/GenDepex.c</Filename>\r
-    <Filename>GenDepex/GenDepex.h</Filename>\r
-    <Filename>GenFfsFile/build.xml</Filename>\r
-    <Filename>GenFfsFile/GenFfsFile.c</Filename>\r
-    <Filename>GenFfsFile/GenFfsFile.h</Filename>\r
-    <Filename>GenFfsFile/SimpleFileParsing.c</Filename>\r
-    <Filename>GenFvImage/build.xml</Filename>\r
-    <Filename>GenFvImage/Ebc/PeCoffLoaderEx.c</Filename>\r
-    <Filename>GenFvImage/GenFvImageExe.c</Filename>\r
-    <Filename>GenFvImage/GenFvImageExe.h</Filename>\r
-    <Filename>GenFvImage/GenFvImageLib.c</Filename>\r
-    <Filename>GenFvImage/GenFvImageLib.h</Filename>\r
-    <Filename>GenFvImage/GenFvImageLibInternal.h</Filename>\r
-    <Filename>GenSection/build.xml</Filename>\r
-    <Filename>GenSection/GenSection.c</Filename>\r
-    <Filename>GenSection/GenSection.h</Filename>\r
-    <Filename>GenTEImage/build.xml</Filename>\r
-    <Filename>GenTEImage/GenTEImage.c</Filename>\r
-    <Filename>GuidChk/build.xml</Filename>\r
-    <Filename>GuidChk/CommonUtils.h</Filename>\r
-    <Filename>GuidChk/FileSearch.c</Filename>\r
-    <Filename>GuidChk/FileSearch.h</Filename>\r
-    <Filename>GuidChk/GuidChk.c</Filename>\r
-    <Filename>GuidChk/GuidList.c</Filename>\r
-    <Filename>GuidChk/UtilsMsgs.c</Filename>\r
-    <Filename>GuidChk/UtilsMsgs.h</Filename>\r
-    <Filename>Include/Common/BaseTypes.h</Filename>\r
-    <Filename>Include/Common/Capsule.h</Filename>\r
-    <Filename>Include/Common/Dependency.h</Filename>\r
-    <Filename>Include/Common/EfiImage.h</Filename>\r
-    <Filename>Include/Common/FirmwareFileSystem.h</Filename>\r
-    <Filename>Include/Common/FirmwareVolumeHeader.h</Filename>\r
-    <Filename>Include/Common/FirmwareVolumeImageFormat.h</Filename>\r
-    <Filename>Include/Common/InternalFormRepresentation.h</Filename>\r
-    <Filename>Include/Common/MultiPhase.h</Filename>\r
-    <Filename>Include/Common/UefiBaseTypes.h</Filename>\r
-    <Filename>Include/Common/Variable.h</Filename>\r
-    <Filename>Include/Common/WorkingBlockHeader.h</Filename>\r
-    <Filename>Include/Guid/AcpiTableStorage.h</Filename>\r
-    <Filename>Include/Guid/Apriori.h</Filename>\r
-    <Filename>Include/Guid/Capsule.h</Filename>\r
-    <Filename>Include/Guid/FirmwareFileSystem.h</Filename>\r
-    <Filename>Include/Ia32/ProcessorBind.h</Filename>\r
-    <Filename>Include/IndustryStandard/pci22.h</Filename>\r
-    <Filename>Include/Library/PeCoffLib.h</Filename>\r
-    <Filename>Include/Library/PrintLib.h</Filename>\r
-    <Filename>Include/Protocol/DevicePath.h</Filename>\r
-    <Filename>Include/Protocol/GuidedSectionExtraction.h</Filename>\r
-    <Filename>Include/Protocol/Hii.h</Filename>\r
-    <Filename>Include/Protocol/UgaDraw.h</Filename>\r
-    <Filename>MakeDeps/build.xml</Filename>\r
-    <Filename>MakeDeps/MakeDeps.c</Filename>\r
-    <Filename>ModifyInf/build.xml</Filename>\r
-    <Filename>ModifyInf/ModifyInf.c</Filename>\r
-    <Filename>Pccts/antlr/antlr.1</Filename>\r
-    <Filename>Pccts/antlr/antlr.c</Filename>\r
-    <Filename>Pccts/antlr/antlr.g</Filename>\r
-    <Filename>Pccts/antlr/antlr.ilk</Filename>\r
-    <Filename>Pccts/antlr/antlr.pdb</Filename>\r
-    <Filename>Pccts/antlr/antlr.r</Filename>\r
-    <Filename>Pccts/antlr/antlr1.txt</Filename>\r
-    <Filename>Pccts/antlr/AntlrMS.mak</Filename>\r
-    <Filename>Pccts/antlr/AntlrPPC.mak</Filename>\r
-    <Filename>Pccts/antlr/bits.c</Filename>\r
-    <Filename>Pccts/antlr/build.c</Filename>\r
-    <Filename>Pccts/antlr/build.xml</Filename>\r
-    <Filename>Pccts/antlr/dumpcycles.c</Filename>\r
-    <Filename>Pccts/antlr/dumpnode.c</Filename>\r
-    <Filename>Pccts/antlr/egman.c</Filename>\r
-    <Filename>Pccts/antlr/err.c</Filename>\r
-    <Filename>Pccts/antlr/fcache.c</Filename>\r
-    <Filename>Pccts/antlr/fset.c</Filename>\r
-    <Filename>Pccts/antlr/fset2.c</Filename>\r
-    <Filename>Pccts/antlr/gen.c</Filename>\r
-    <Filename>Pccts/antlr/generic.h</Filename>\r
-    <Filename>Pccts/antlr/globals.c</Filename>\r
-    <Filename>Pccts/antlr/hash.c</Filename>\r
-    <Filename>Pccts/antlr/hash.h</Filename>\r
-    <Filename>Pccts/antlr/lex.c</Filename>\r
-    <Filename>Pccts/antlr/main.c</Filename>\r
-    <Filename>Pccts/antlr/makefile</Filename>\r
-    <Filename>Pccts/antlr/makefile1</Filename>\r
-    <Filename>Pccts/antlr/misc.c</Filename>\r
-    <Filename>Pccts/antlr/mode.h</Filename>\r
-    <Filename>Pccts/antlr/mrhoist.c</Filename>\r
-    <Filename>Pccts/antlr/parser.dlg</Filename>\r
-    <Filename>Pccts/antlr/pred.c</Filename>\r
-    <Filename>Pccts/antlr/proto.h</Filename>\r
-    <Filename>Pccts/antlr/README</Filename>\r
-    <Filename>Pccts/antlr/scan.c</Filename>\r
-    <Filename>Pccts/antlr/stdpccts.h</Filename>\r
-    <Filename>Pccts/antlr/syn.h</Filename>\r
-    <Filename>Pccts/antlr/tokens.h</Filename>\r
-    <Filename>Pccts/antlr/vc70.pdb</Filename>\r
-    <Filename>Pccts/build.xml</Filename>\r
-    <Filename>Pccts/CHANGES_FROM_131.txt</Filename>\r
-    <Filename>Pccts/CHANGES_FROM_133.txt</Filename>\r
-    <Filename>Pccts/CHANGES_FROM_133_BEFORE_MR13.txt</Filename>\r
-    <Filename>Pccts/CHANGES_SUMMARY.txt</Filename>\r
-    <Filename>Pccts/dlg/automata.c</Filename>\r
-    <Filename>Pccts/dlg/build.xml</Filename>\r
-    <Filename>Pccts/dlg/dlg.1</Filename>\r
-    <Filename>Pccts/dlg/dlg.h</Filename>\r
-    <Filename>Pccts/dlg/dlg.r</Filename>\r
-    <Filename>Pccts/dlg/dlg1.txt</Filename>\r
-    <Filename>Pccts/dlg/dlg_a.c</Filename>\r
-    <Filename>Pccts/dlg/dlg_p.c</Filename>\r
-    <Filename>Pccts/dlg/dlg_p.g</Filename>\r
-    <Filename>Pccts/dlg/DlgMS.mak</Filename>\r
-    <Filename>Pccts/dlg/DlgPPC.mak</Filename>\r
-    <Filename>Pccts/dlg/err.c</Filename>\r
-    <Filename>Pccts/dlg/main.c</Filename>\r
-    <Filename>Pccts/dlg/makefile</Filename>\r
-    <Filename>Pccts/dlg/makefile1</Filename>\r
-    <Filename>Pccts/dlg/mode.h</Filename>\r
-    <Filename>Pccts/dlg/output.c</Filename>\r
-    <Filename>Pccts/dlg/parser.dlg</Filename>\r
-    <Filename>Pccts/dlg/relabel.c</Filename>\r
-    <Filename>Pccts/dlg/stdpccts.h</Filename>\r
-    <Filename>Pccts/dlg/support.c</Filename>\r
-    <Filename>Pccts/dlg/tokens.h</Filename>\r
-    <Filename>Pccts/h/antlr.h</Filename>\r
-    <Filename>Pccts/h/AParser.cpp</Filename>\r
-    <Filename>Pccts/h/AParser.h</Filename>\r
-    <Filename>Pccts/h/ast.c</Filename>\r
-    <Filename>Pccts/h/ast.h</Filename>\r
-    <Filename>Pccts/h/ASTBase.cpp</Filename>\r
-    <Filename>Pccts/h/ASTBase.h</Filename>\r
-    <Filename>Pccts/h/AToken.h</Filename>\r
-    <Filename>Pccts/h/ATokenBuffer.cpp</Filename>\r
-    <Filename>Pccts/h/ATokenBuffer.h</Filename>\r
-    <Filename>Pccts/h/ATokenStream.h</Filename>\r
-    <Filename>Pccts/h/ATokPtr.h</Filename>\r
-    <Filename>Pccts/h/ATokPtrImpl.h</Filename>\r
-    <Filename>Pccts/h/BufFileInput.cpp</Filename>\r
-    <Filename>Pccts/h/BufFileInput.h</Filename>\r
-    <Filename>Pccts/h/charbuf.h</Filename>\r
-    <Filename>Pccts/h/charptr.c</Filename>\r
-    <Filename>Pccts/h/charptr.h</Filename>\r
-    <Filename>Pccts/h/config.h</Filename>\r
-    <Filename>Pccts/h/DLexer.h</Filename>\r
-    <Filename>Pccts/h/DLexerBase.cpp</Filename>\r
-    <Filename>Pccts/h/DLexerBase.h</Filename>\r
-    <Filename>Pccts/h/DLG_stream_input.h</Filename>\r
-    <Filename>Pccts/h/dlgauto.h</Filename>\r
-    <Filename>Pccts/h/dlgdef.h</Filename>\r
-    <Filename>Pccts/h/err.h</Filename>\r
-    <Filename>Pccts/h/int.h</Filename>\r
-    <Filename>Pccts/h/PBlackBox.h</Filename>\r
-    <Filename>Pccts/h/pccts_assert.h</Filename>\r
-    <Filename>Pccts/h/pccts_iostream.h</Filename>\r
-    <Filename>Pccts/h/pccts_istream.h</Filename>\r
-    <Filename>Pccts/h/pccts_setjmp.h</Filename>\r
-    <Filename>Pccts/h/pccts_stdarg.h</Filename>\r
-    <Filename>Pccts/h/pccts_stdio.h</Filename>\r
-    <Filename>Pccts/h/pccts_stdlib.h</Filename>\r
-    <Filename>Pccts/h/pccts_string.h</Filename>\r
-    <Filename>Pccts/h/PCCTSAST.cpp</Filename>\r
-    <Filename>Pccts/h/PCCTSAST.h</Filename>\r
-    <Filename>Pccts/h/pcctscfg.h</Filename>\r
-    <Filename>Pccts/h/pcnames.bat</Filename>\r
-    <Filename>Pccts/h/slist.cpp</Filename>\r
-    <Filename>Pccts/h/SList.h</Filename>\r
-    <Filename>Pccts/history.ps</Filename>\r
-    <Filename>Pccts/history.txt</Filename>\r
-    <Filename>Pccts/KNOWN_PROBLEMS.txt</Filename>\r
-    <Filename>Pccts/makefile</Filename>\r
-    <Filename>Pccts/MPW_Read_Me</Filename>\r
-    <Filename>Pccts/NOTES.bcc</Filename>\r
-    <Filename>Pccts/NOTES.msvc</Filename>\r
-    <Filename>Pccts/README</Filename>\r
-    <Filename>Pccts/RIGHTS</Filename>\r
-    <Filename>Pccts/support/genmk/genmk.c</Filename>\r
-    <Filename>Pccts/support/genmk/genmk_old.c</Filename>\r
-    <Filename>Pccts/support/genmk/makefile</Filename>\r
-    <Filename>Pccts/support/rexpr/makefile</Filename>\r
-    <Filename>Pccts/support/rexpr/rexpr.c</Filename>\r
-    <Filename>Pccts/support/rexpr/rexpr.h</Filename>\r
-    <Filename>Pccts/support/rexpr/test.c</Filename>\r
-    <Filename>Pccts/support/set/set.c</Filename>\r
-    <Filename>Pccts/support/set/set.h</Filename>\r
-    <Filename>Pccts/support/sym/sym.c</Filename>\r
-    <Filename>Pccts/support/sym/template.h</Filename>\r
-    <Filename>PeCoffLoader/BasePeCoff.c</Filename>\r
-    <Filename>PeCoffLoader/build.xml</Filename>\r
-    <Filename>PeCoffLoader/Common/EfiImage.h</Filename>\r
-    <Filename>PeCoffLoader/Ia32/PeCoffLoaderEx.c</Filename>\r
-    <Filename>PeCoffLoader/Ipf/PeCoffLoaderEx.c</Filename>\r
-    <Filename>PeCoffLoader/X64/PeCoffLoaderEx.c</Filename>\r
-    <Filename>PeiRebase/build.xml</Filename>\r
-    <Filename>PeiRebase/makefile</Filename>\r
-    <Filename>PeiRebase/PeiRebaseExe.c</Filename>\r
-    <Filename>PeiRebase/PeiRebaseExe.h</Filename>\r
-    <Filename>SecApResetVectorFixup/build.xml</Filename>\r
-    <Filename>SecApResetVectorFixup/SecApResetVectorFixup.c</Filename>\r
-    <Filename>SecApResetVectorFixup/SecApResetVectorFixup.h</Filename>\r
-    <Filename>SecFixup/build.xml</Filename>\r
-    <Filename>SecFixup/SecFixup.c</Filename>\r
-    <Filename>SecFixup/SecFixup.h</Filename>\r
-    <Filename>SetStamp/build.xml</Filename>\r
-    <Filename>SetStamp/SetStamp.c</Filename>\r
-    <Filename>SplitFile/build.xml</Filename>\r
-    <Filename>SplitFile/SplitFile.c</Filename>\r
-    <Filename>StrGather/build.xml</Filename>\r
-    <Filename>StrGather/StrGather.c</Filename>\r
-    <Filename>StrGather/StrGather.h</Filename>\r
-    <Filename>StrGather/StringDB.c</Filename>\r
-    <Filename>StrGather/StringDB.h</Filename>\r
-    <Filename>String/build.xml</Filename>\r
-    <Filename>String/PrintLib.c</Filename>\r
-    <Filename>String/PrintLibInternal.c</Filename>\r
-    <Filename>String/PrintLibInternal.h</Filename>\r
-    <Filename>String/String.c</Filename>\r
-    <Filename>Strip/build.xml</Filename>\r
-    <Filename>Strip/Strip.c</Filename>\r
-    <Filename>VfrCompile/build.xml</Filename>\r
-    <Filename>VfrCompile/DLGLexer.cpp</Filename>\r
-    <Filename>VfrCompile/DLGLexer.h</Filename>\r
-    <Filename>VfrCompile/EfiVfr.h</Filename>\r
-    <Filename>VfrCompile/EfiVfrParser.cpp</Filename>\r
-    <Filename>VfrCompile/EfiVfrParser.h</Filename>\r
-    <Filename>VfrCompile/parser.dlg</Filename>\r
-    <Filename>VfrCompile/tokens.h</Filename>\r
-    <Filename>VfrCompile/VfrCompile.cpp</Filename>\r
-    <Filename>VfrCompile/VfrCompile.g</Filename>\r
-    <Filename>VfrCompile/VfrServices.cpp</Filename>\r
-    <Filename>VfrCompile/VfrServices.h</Filename>\r
-    <Filename>ZeroDebugData/build.xml</Filename>\r
-    <Filename>ZeroDebugData/ZeroDebugData.c</Filename>\r
-  </SourceFiles>\r
-</ModuleSurfaceArea>
\ No newline at end of file
diff --git a/Tools/CodeTools/TianoTools/VfrCompile/EfiVfr.h b/Tools/CodeTools/TianoTools/VfrCompile/EfiVfr.h
deleted file mode 100644 (file)
index 6419ad7..0000000
+++ /dev/null
@@ -1,181 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2004 - 2005, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-Module Name:\r
-\r
-  EfiVfr.h\r
-\r
-Abstract:\r
-\r
-  Defines and prototypes for the EFI internal forms representation\r
-  setup protocol and drivers\r
-  \r
---*/\r
-\r
-#ifndef _EFI_VFR_H_\r
-#define _EFI_VFR_H_\r
-\r
-#include <string.h>\r
-\r
-#include <Common/UefiBaseTypes.h>\r
-#include <Common/InternalFormRepresentation.h>\r
-\r
-//\r
-// This number should be incremented with each change to the VFR compiler.\r
-// We write the version to the output list file for debug purposes.\r
-//\r
-#define VFR_COMPILER_VERSION  "1.88"\r
-\r
-//\r
-// Maximum file path for filenames\r
-//\r
-#ifndef MAX_PATH\r
-#define MAX_PATH        255\r
-#endif\r
-#define MAX_QUEUE_COUNT 255\r
-#define MAX_LINE_LEN    1024\r
-#define PROGRAM_NAME    "VfrCompile"\r
-\r
-//\r
-// We parse C-style structure definitions which can then be referenced\r
-// in VFR statements.\r
-// We need to define an internal structure that can be used to\r
-// track the fields in a structure definition, and another structure\r
-// to keep track of the structure name and subfields.\r
-//\r
-typedef struct _STRUCT_FIELD_DEFINITION {\r
-  struct _STRUCT_FIELD_DEFINITION *Next;\r
-  int                             DataSize;\r
-  int                             Offset;     // from the start of the structure\r
-  int                             ArrayLength;\r
-  char                            IsArray;\r
-  char                            *Name;\r
-} STRUCT_FIELD_DEFINITION;\r
-\r
-typedef struct _STRUCT_DEFINITION {\r
-  struct _STRUCT_DEFINITION *Next;\r
-  int                       Size;\r
-  int                       LineNum;          // line number where the structure was defined\r
-  int                       IsNonNV;          // if this is the non-NV data structure definition\r
-  int                       Referenced;       // if it's referenced anywhere in the VFR\r
-  int                       VarStoreIdValid;  // found a 'varstore' statement for it in the VFR\r
-  unsigned short            VarStoreId;       // key from a varstore IFR statement\r
-  int                       VarStoreLineNum;  // line number where VARSTORE was defined\r
-  char                      *Name;\r
-  STRUCT_FIELD_DEFINITION   *Field;\r
-  STRUCT_FIELD_DEFINITION   *LastField;\r
-} STRUCT_DEFINITION;\r
-\r
-//\r
-// For the IdEqValList variable list of UINT16's, keep track of them using\r
-// a linked list until we know how many there are.\r
-// We also use a linked list of these to keep track of labels used in\r
-// the VFR script so we can catch duplicates.\r
-// We'll also use it to keep track of defined varstore id's so we can\r
-// detect duplicate definitions.\r
-//\r
-typedef struct _UINT16_LIST {\r
-  struct _UINT16_LIST *Next;\r
-  UINT16              Value;\r
-  UINT32              LineNum;\r
-} UINT16_LIST;\r
-\r
-typedef struct _GOTO_REFERENCE {\r
-  struct _GOTO_REFERENCE  *Next;\r
-  UINT32                  RefLineNum; // line number of source file where referenced\r
-  UINT16                  Value;\r
-} GOTO_REFERENCE;\r
-\r
-typedef struct _FORM_ID_VALUE {\r
-  struct _FORM_ID_VALUE *Next;\r
-  UINT32                LineNum;\r
-  UINT16                Value;\r
-} FORM_ID_VALUE;\r
-\r
-//\r
-// We keep track in the parser of all "#line 4 "x.y"" strings so we\r
-// can cross-reference the line numbers in the preprocessor output .i file\r
-// to the original input files.\r
-//\r
-typedef struct _PARSER_LINE_DEFINITION {\r
-  struct _PARSER_LINE_DEFINITION  *Next;\r
-  UINT32                          HashLineNum;  // from the #line stmt\r
-  UINT32                          TokenLineNum; // line number in the .i file\r
-  CHAR8                           *FileName;    // from the #line stmt\r
-} PARSER_LINE_DEFINITION;\r
-\r
-extern PARSER_LINE_DEFINITION *gLineDefinition;\r
-extern PARSER_LINE_DEFINITION *gLastLineDefinition;\r
-\r
-extern\r
-char                          *\r
-ConvertLineNumber (\r
-  UINT32 *LineNum\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Given the line number in the preprocessor-output file, use the line number\r
-  information we've saved to determine the source file name and line number\r
-  where the code originally came from. This is required for error reporting.\r
-\r
-Arguments:\r
-  LineNum - the line number in the preprocessor-output file.\r
-\r
-Returns:\r
-  Returns a pointer to the source file name. Also returns the line number \r
-  in the provided LineNum argument\r
-\r
---*/\r
-;\r
-\r
-typedef struct _IFR_BYTE {\r
-  struct _IFR_BYTE  *Next;\r
-  UINT32            LineNum;\r
-  UINT8             OpcodeByte;\r
-  UINT8             KeyByte;\r
-} IFR_BYTE;\r
-\r
-typedef struct {\r
-  CHAR8 VfrFileName[MAX_PATH];\r
-  CHAR8 VfrListFileName[MAX_PATH];\r
-  INT8  CreateListFile;\r
-  INT8  CreateIfrBinFile;\r
-  CHAR8 IfrOutputFileName[MAX_PATH];\r
-  CHAR8 OutputDirectory[MAX_PATH];\r
-  CHAR8 PreprocessorOutputFileName[MAX_PATH];\r
-  CHAR8 VfrBaseFileName[MAX_PATH];  // name of input VFR file with no path or extension\r
-  CHAR8 *IncludePaths;\r
-  CHAR8 *CPreprocessorOptions;\r
-} OPTIONS;\r
-\r
-extern OPTIONS  gOptions;\r
-\r
-VOID\r
-WriteStandardFileHeader (\r
-  FILE *OutFptr\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  This function is invoked to emit a standard header to an\r
-  output text file.\r
-  \r
-Arguments:\r
-  OutFptr - file to write the header to\r
-\r
-Returns:\r
-  None\r
-\r
---*/\r
-;\r
-\r
-#endif // #ifndef _EFI_VFR_H_\r
diff --git a/Tools/CodeTools/TianoTools/VfrCompile/VfrCompile.g b/Tools/CodeTools/TianoTools/VfrCompile/VfrCompile.g
deleted file mode 100644 (file)
index 44820bc..0000000
+++ /dev/null
@@ -1,3529 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2004 - 2005, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-Module Name:\r
-\r
-  VfrCompile.g\r
-\r
-Abstract:\r
-\r
-  PCCTS parser and lexer definitions for the EFI VFR forms compiler\r
-  \r
---*/  \r
-\r
-#header<<\r
-\r
-#include <Common/UefiBaseTypes.h>\r
-#include <Common/MultiPhase.h>\r
-#include <Common/InternalFormRepresentation.h>\r
-#include <Protocol/UgaDraw.h>\r
-#include <Protocol/Hii.h>\r
-\r
-#include "CommonLib.h"\r
-#include "EfiUtilityMsgs.h"\r
-#include "EfiVfr.h"\r
-#include "VfrServices.h"\r
-\r
-#include <ctype.h>\r
-#ifndef __GNUC__\r
-#include <direct.h>\r
-#include <process.h> // for spawn functions\r
-#else\r
-#include <unistd.h>\r
-#endif\r
-\r
->>\r
-\r
-<<\r
-\r
-//\r
-// Base info for DLG-generated scanner\r
-//\r
-#include "DLexerBase.h"    \r
-\r
-//\r
-// Include the scanner file generated by DLG\r
-//\r
-#include "DLGLexer.h"    \r
-\r
-class DLGLexerVfr : public DLGLexer\r
-{\r
-public:\r
-  DLGLexerVfr (DLGFileInput *F) : DLGLexer (F) {};\r
-  INT32 errstd (char *Text) \r
-  { \r
-    printf ("unrecognized input '%s'\n", Text); \r
-  }\r
-\r
-};\r
-\r
-//\r
-// Base token definitions for ANTLR\r
-//\r
-#include "AToken.h"\r
-\r
-//\r
-// This is how we invoke the C preprocessor on the VFR source file\r
-// to resolve #defines, #includes, etc. To make C source files\r
-// shareable between VFR and drivers, define VFRCOMPILE so that\r
-// #ifdefs can be used in shared .h files.\r
-//\r
-#ifdef __GNUC__\r
-#define PREPROCESSOR_COMMAND        "gcc "\r
-#define PREPROCESSOR_OPTIONS        "-x c -E -P -DVFRCOMPILE "\r
-#define FILE_SEP_CHAR '/'\r
-#define FILE_SEP_STRING "/"\r
-#else\r
-#define PREPROCESSOR_COMMAND        "cl.exe "\r
-#define PREPROCESSOR_OPTIONS        "/nologo /P /TC /DVFRCOMPILE "\r
-#define FILE_SEP_CHAR '/'\r
-#define FILE_SEP_STRING "/"\r
-#endif\r
-\r
-typedef ANTLRCommonToken ANTLRToken;\r
-\r
-//\r
-// Specify the filename extensions for the files we generate.\r
-//\r
-#define VFR_BINARY_FILENAME_EXTENSION       ".c"\r
-#define VFR_LIST_FILENAME_EXTENSION         ".lst"\r
-\r
-static \r
-VOID \r
-Usage ();\r
-\r
-static \r
-STATUS \r
-ProcessArgs (\r
-  int         Argc, \r
-  char        *Argv[]\r
-  );\r
-\r
-static \r
-VOID \r
-Cleanup ();\r
-\r
-//\r
-// Globals\r
-//\r
-OPTIONS gOptions;\r
-\r
-int \r
-main (\r
-  int   argc, \r
-  char  **argv\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Application entry point function. Parse command-line arguments, \r
-  invoke the parser, clean up, and return.\r
-\r
-Arguments:\r
-  argc - standard argc passed to main() per C conventions\r
-  argv - standard argv passed to main() per C conventions\r
-\r
-Returns:\r
-  STATUS_SUCCESS - program executed with no errors or warnings\r
-  STATUS_WARNING - program executed with warnings\r
-  STATUS_ERROR   - non-recoverable errors encountered while processing\r
-\r
---*/\r
-{\r
-  FILE      *VfrFptr;\r
-  char      *Cmd;\r
-  char      *Cptr;\r
-  int       Len;\r
-  STATUS    Status;\r
-    \r
-  //\r
-  // Set our program name for the error printing routines.\r
-  // Then set printing limits.\r
-  //\r
-  SetUtilityName (PROGRAM_NAME);\r
-  SetPrintLimits (20, 20, 30);\r
-  //\r
-  // Process the command-line arguments\r
-  //\r
-  if (ProcessArgs (argc, argv) != STATUS_SUCCESS) {\r
-    Usage ();\r
-    Cleanup();\r
-    return STATUS_ERROR;\r
-  }\r
-  VfrFptr = NULL;\r
-  //\r
-  // Verify the VFR script file exists\r
-  //\r
-  if ((VfrFptr = fopen (gOptions.VfrFileName, "r")) == NULL) {\r
-    Error (PROGRAM_NAME, 0, 0, gOptions.VfrFileName, "could not open input VFR file");\r
-    Cleanup();\r
-    return STATUS_ERROR;\r
-  }\r
-  //\r
-  // Now close the file and make a system call to run the preprocessor\r
-  // on it.\r
-  //\r
-  fclose (VfrFptr);\r
-  Len = strlen (PREPROCESSOR_OPTIONS) + strlen (gOptions.VfrFileName) + 10;\r
-  if (gOptions.CPreprocessorOptions != NULL) {\r
-    Len += strlen (gOptions.CPreprocessorOptions) + 1;\r
-  }\r
-  if (gOptions.IncludePaths != NULL) {\r
-    Len += strlen (gOptions.IncludePaths) + 1;\r
-  }\r
-  Cmd = (char *)malloc (Len);\r
-  if (Cmd == NULL) {\r
-    Error (PROGRAM_NAME, 0, 0, NULL, "could not allocate memory");\r
-    Cleanup();\r
-    return STATUS_ERROR;\r
-  }  \r
-  strcpy (Cmd, PREPROCESSOR_OPTIONS);\r
-  if (gOptions.IncludePaths != NULL) {\r
-    strcat (Cmd, gOptions.IncludePaths);\r
-    strcat (Cmd, " ");\r
-  }\r
-  if (gOptions.CPreprocessorOptions != NULL) {\r
-    strcat (Cmd, gOptions.CPreprocessorOptions);\r
-    strcat (Cmd, " ");\r
-  }\r
-  strcat (Cmd, gOptions.VfrFileName);\r
-#ifndef __GNUC__\r
-  Status = _spawnlp (_P_WAIT, PREPROCESSOR_COMMAND, Cmd, NULL);\r
-#else\r
-  {\r
-    char CommandLine[1000];\r
-    char *p;\r
-\r
-    //\r
-    // Lean the slashes forward.\r
-    //\r
-    for (p = gOptions.PreprocessorOutputFileName; *p; p++) {\r
-      if (*p=='\\') {\r
-        *p=FILE_SEP_CHAR;\r
-      }\r
-    }\r
\r
-    //\r
-    // Lean the slashes forward.\r
-    //\r
-    for (p = Cmd; *p; p++) {\r
-      if (*p=='\\') {\r
-        *p=FILE_SEP_CHAR;\r
-      }\r
-    }\r
\r
-    sprintf(CommandLine, "%s %s > %s", PREPROCESSOR_COMMAND, Cmd, gOptions.PreprocessorOutputFileName);\r
-    Status = system (CommandLine);\r
-  }\r
-#endif\r
-  if (Status != 0) {\r
-    Error (PROGRAM_NAME, 0, 0, gOptions.VfrFileName, "failed to spawn C preprocessor on VFR file");\r
-    printf ("Command: '%s %s'\n", PREPROCESSOR_COMMAND, Cmd);\r
-    Cleanup();\r
-    return STATUS_ERROR;\r
-  }\r
-  free (Cmd);\r
-  //\r
-  // Open the preprocessor output file\r
-  //\r
-  if ((VfrFptr = fopen (gOptions.PreprocessorOutputFileName, "r")) == NULL) {\r
-    Error (PROGRAM_NAME, 0, 0, "failed to open input VFR preprocessor output file", \r
-      gOptions.PreprocessorOutputFileName);\r
-    Cleanup();\r
-    return STATUS_ERROR;\r
-  }\r
-  //\r
-  // Define input VFR file\r
-  //\r
-  DLGFileInput InputFile (VfrFptr);\r
-  //\r
-  // Define an instance of the scanner    \r
-  //\r
-  DLGLexerVfr Scanner (&InputFile);\r
-  //\r
-  // Define token buffer between scanner and parser\r
-  //\r
-  ANTLRTokenBuffer Pipe (&Scanner);    \r
-  //\r
-  // Create a token to use as a model\r
-  //\r
-  ANTLRToken Tok;     \r
-  //\r
-  // Tell the scanner what type the token is\r
-  //\r
-  Scanner.setToken (&Tok);    \r
-  //\r
-  // Create an instance of our parser\r
-  //\r
-  EfiVfrParser Parser (&Pipe);    \r
-  //\r
-  // Initialize the parser    \r
-  //\r
-  Parser.init ();\r
-  Status = GetUtilityStatus ();\r
-  if (Status != STATUS_SUCCESS) {\r
-    Cleanup();\r
-    return Status;\r
-  }  \r
-  //\r
-  // Start the first rule    \r
-  //\r
-  Parser.program ();\r
-  //\r
-  // Close the input script file\r
-  //\r
-  fclose (VfrFptr);\r
-  Parser.WriteIfrBytes ();\r
-  //\r
-  // Call cleanup, which does some extra checking of the script\r
-  //\r
-  Parser.Cleanup ();\r
-  Cleanup();\r
-  //\r
-  // If we had an error somewhere, delete our output files so that\r
-  // a subsequent build will rebuild them.\r
-  //\r
-  Status = GetUtilityStatus ();\r
-  if (Status == STATUS_ERROR) {\r
-    remove (gOptions.IfrOutputFileName);\r
-  }\r
-  return Status;\r
-}\r
-static\r
-VOID\r
-Cleanup ()\r
-/*++\r
-\r
-Routine Description:\r
-  Free up memory allocated during parsing.\r
-\r
-Arguments:\r
-  None\r
-\r
-Returns:\r
-  None\r
-\r
---*/\r
-{\r
-  //\r
-  // Free up our string we allocated to track the include paths\r
-  //\r
-  if (gOptions.IncludePaths != NULL) {\r
-    free (gOptions.IncludePaths);\r
-    gOptions.IncludePaths = NULL;\r
-  }\r
-  //\r
-  // Free up our string we allocated to track preprocessor options\r
-  //\r
-  if (gOptions.CPreprocessorOptions != NULL) {\r
-    free (gOptions.CPreprocessorOptions);\r
-    gOptions.CPreprocessorOptions = NULL;\r
-  }\r
-}  \r
-\r
-static\r
-STATUS\r
-ProcessArgs (\r
-  int         Argc, \r
-  char        *Argv[]\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Process the command-line arguments.\r
-\r
-Arguments:\r
-  Argc - standard argc passed to main()\r
-  Argv - standard argv passed to main()\r
-\r
-Returns:\r
-  STATUS_SUCCESS - program should continue (all args ok)\r
-\r
---*/\r
-{\r
-  char    *IncludePaths;\r
-  char    *CPreprocessorOptions;\r
-  int     Len;  \r
-  char    CopyStr[MAX_PATH];\r
-  char    *Cptr;\r
-\r
-  //\r
-  // Put options in known state.\r
-  //\r
-  memset ((char *)&gOptions, 0, sizeof (OPTIONS));\r
-  //\r
-  // Go through all the arguments that start with '-'\r
-  //\r
-  Argc--;\r
-  Argv++;\r
-  while ((Argc > 0) && (Argv[0][0] == '-')) {\r
-    //\r
-    // -? or -h help option -- return an error for printing usage\r
-    //\r
-    if ((stricmp (Argv[0], "-?") == 0) || (stricmp (Argv[0], "-h") == 0)) {\r
-      return STATUS_ERROR;\r
-      break;\r
-    //\r
-    // -l to create a listing output file\r
-    //\r
-    } else if (stricmp (Argv[0], "-l") == 0) {\r
-      gOptions.CreateListFile = 1;\r
-    //\r
-    // -I include_path option for finding include files. We'll pass this\r
-    // to the preprocessor. Turn them all into a single include string.\r
-    //\r
-    } else if (stricmp (Argv[0], "-i") == 0) {\r
-      if ((Argc < 2) || (Argv[1][0] == '-')) {\r
-        Error (PROGRAM_NAME, 0, 0, Argv[0], "missing path argument");\r
-        return STATUS_ERROR;\r
-      }\r
-      Argc--;\r
-      Argv++;\r
-      Len = strlen (" -I ");\r
-      Len += strlen (Argv[0]) + 2;\r
-      if (gOptions.IncludePaths != NULL) {\r
-        Len += strlen (gOptions.IncludePaths);\r
-      }\r
-      IncludePaths = (CHAR8 *)malloc (Len);\r
-      if (IncludePaths == NULL) {\r
-        Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");\r
-        return STATUS_ERROR;\r
-      }\r
-      IncludePaths[0] = 0;\r
-      if (gOptions.IncludePaths != NULL) {\r
-        strcpy (IncludePaths, gOptions.IncludePaths);\r
-        free (gOptions.IncludePaths);\r
-      }\r
-      strcat (IncludePaths, " -I ");\r
-      strcat (IncludePaths, Argv[0]);\r
-      gOptions.IncludePaths = IncludePaths;\r
-    //\r
-    // -od OutputDirectory to define a common directory for output files\r
-    //\r
-    } else if (stricmp (Argv[0], "-od") == 0) {\r
-      if ((Argc < 2) || (Argv[1][0] == '-')) {\r
-        Error (PROGRAM_NAME, 0, 0, Argv[0], "missing output directory name");\r
-        return STATUS_ERROR;\r
-      }\r
-      Argc--;\r
-      Argv++;\r
-      strcpy (gOptions.OutputDirectory, Argv[0]);\r
-    } else if (stricmp (Argv[0], "-ibin") == 0) {\r
-      gOptions.CreateIfrBinFile = 1;\r
-    } else if (stricmp (Argv[0], "-nostrings") == 0) {\r
-      // deprecated option\r
-    //\r
-    // -ppflag C-preprocessor-flag option for passing options to the C preprocessor.\r
-    // Turn them all into a single string.\r
-    //\r
-    } else if (stricmp (Argv[0], "-ppflag") == 0) {\r
-      if (Argc < 2) {\r
-        Error (PROGRAM_NAME, 0, 0, Argv[0], "missing C-preprocessor argument");\r
-        return STATUS_ERROR;\r
-      }\r
-      Argc--;\r
-      Argv++;\r
-      Len = strlen (Argv[0]) + 2;\r
-      if (gOptions.CPreprocessorOptions != NULL) {\r
-        Len += strlen (gOptions.CPreprocessorOptions);\r
-      }\r
-      CPreprocessorOptions = (CHAR8 *)malloc (Len);\r
-      if (CPreprocessorOptions == NULL) {\r
-        Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");\r
-        return STATUS_ERROR;\r
-      }\r
-      CPreprocessorOptions[0] = 0;\r
-      if (gOptions.CPreprocessorOptions != NULL) {\r
-        strcpy (CPreprocessorOptions, gOptions.CPreprocessorOptions);\r
-        free (gOptions.CPreprocessorOptions);\r
-      }\r
-      strcat (CPreprocessorOptions, " ");\r
-      strcat (CPreprocessorOptions, Argv[0]);\r
-      gOptions.CPreprocessorOptions = CPreprocessorOptions;\r
-    } else {\r
-      Error (PROGRAM_NAME, 0, 0, Argv[0], "unrecognized option");\r
-      return STATUS_ERROR;\r
-    }\r
-    Argc--;\r
-    Argv++;\r
-  }\r
-  //\r
-  // Must specify at least the vfr file name\r
-  //\r
-  if (Argc > 1) {\r
-    Error (PROGRAM_NAME, 0, 0, Argv[1], "unrecognized argument after VFR file name");\r
-    return STATUS_ERROR;\r
-  } else if (Argc < 1) {\r
-    Error (PROGRAM_NAME, 0, 0, NULL, "must specify VFR file name");\r
-    return STATUS_ERROR;\r
-  }\r
-  strcpy (gOptions.VfrFileName, Argv[0]);\r
-  //\r
-  // We run the preprocessor on the VFR file to manage #include statements.\r
-  // Unfortunately the preprocessor does not allow you to specify the\r
-  // output name or path of the resultant .i file, so we have to do\r
-  // some work. Here we'll extract the basename of the VFR file, then\r
-  // append .i on the end. \r
-  //\r
-  strcpy (CopyStr, gOptions.VfrFileName);\r
-  Cptr = CopyStr + strlen (CopyStr) - 1;\r
-  for (;(Cptr > CopyStr) && (*Cptr != '\\') && (*Cptr != ':') && (*Cptr != '/'); Cptr--);\r
-  if (Cptr == CopyStr) {\r
-    strcpy (gOptions.PreprocessorOutputFileName, Cptr);\r
-    strcpy (gOptions.VfrBaseFileName, Cptr);\r
-  } else {\r
-    strcpy (gOptions.PreprocessorOutputFileName, Cptr+1);\r
-    strcpy (gOptions.VfrBaseFileName, Cptr+1);\r
-  }\r
-  for (Cptr = gOptions.PreprocessorOutputFileName; *Cptr && (*Cptr != '.'); Cptr++);\r
-  strcpy (Cptr, ".i");\r
-  //\r
-  // Terminate the vfr file basename at the extension\r
-  //\r
-  for (Cptr = gOptions.VfrBaseFileName; *Cptr && (*Cptr != '.'); Cptr++) {\r
-  }\r
-  *Cptr = 0; \r
-  //\r
-  // If they defined an output directory, prepend all output files\r
-  // with the working directory. Output files of interest:\r
-  //    VfrListFileName             -- list file\r
-  //    IfrOutputFileName           -- IFR bytes \r
-  //    StringOutputFileName        -- string bytes\r
-  //    StringListFileName          -- not used\r
-  //    StringDefineFileName        -- #defines of string identifiers\r
-  //\r
-  // We have two cases:\r
-  //   1. Output directory (-od) not specified, in which case output files\r
-  //      go to the current working directory.\r
-  //   2. Output directory specified, in which case the output files\r
-  //      go directly to the specified directory.\r
-  //\r
-  if (gOptions.OutputDirectory[0] == 0) {\r
-    CopyStr[0] = 0;\r
-#ifndef __GNUC__\r
-    _getcwd (CopyStr, sizeof (CopyStr));\r
-#else\r
-    getcwd (CopyStr, sizeof (CopyStr));\r
-#endif\r
-    strcpy (gOptions.OutputDirectory, CopyStr);\r
-  }\r
-  //\r
-  // Make sure output directory has a trailing backslash\r
-  //\r
-  if (gOptions.OutputDirectory[strlen (gOptions.OutputDirectory) - 1] != '\\' ||\r
-      gOptions.OutputDirectory[strlen (gOptions.OutputDirectory) - 1] != '/') {\r
-    strcat (gOptions.OutputDirectory, FILE_SEP_STRING);\r
-  }\r
-  //\r
-  // Create the base output file name as: path\base, copy it to all the output\r
-  // filenames, and then add the appropriate extension to each.\r
-  //\r
-  strcpy (gOptions.VfrListFileName, gOptions.OutputDirectory);\r
-  strcat (gOptions.VfrListFileName, gOptions.VfrBaseFileName);\r
-  strcpy (gOptions.IfrOutputFileName, gOptions.VfrListFileName);\r
-  strcat (gOptions.VfrListFileName, VFR_LIST_FILENAME_EXTENSION);\r
-  strcat (gOptions.IfrOutputFileName, VFR_BINARY_FILENAME_EXTENSION);\r
-  //\r
-  // We set a default list file name, so if they do not\r
-  // want a list file, null out the name now.\r
-  //\r
-  if (gOptions.CreateListFile == 0) {\r
-    gOptions.VfrListFileName[0] = 0;\r
-  }\r
-  return STATUS_SUCCESS;\r
-}\r
-static \r
-VOID \r
-Usage ()\r
-/*++\r
-\r
-Routine Description:\r
-  Print utility usage instructions\r
-\r
-Arguments:\r
-  None\r
-\r
-Returns:\r
-  None\r
-\r
---*/\r
-{\r
-  int Index;\r
-  const char *Help[] = {\r
-    " ", \r
-    "VfrCompile version " VFR_COMPILER_VERSION,\r
-    " ",\r
-    "  Usage: VfrCompile {options} [VfrFile]",\r
-    " ",\r
-    "    where options include:",\r
-    "      -? or -h       prints this help",\r
-    "      -l             create an output IFR listing file",\r
-    "      -i IncPath     add IncPath to the search path for VFR included files",\r
-    "      -od OutputDir  deposit all output files to directory OutputDir (default=cwd)",\r
-    "      -ibin          create an IFR HII pack file",\r
-    "    where parameters include:",\r
-    "      VfrFile        name of the input VFR script file",\r
-    " ",\r
-    NULL\r
-    };\r
-  for (Index = 0; Help[Index] != NULL; Index++) {\r
-    fprintf (stdout, "%s\n", Help[Index]);\r
-  }\r
-}\r
-    \r
->>\r
-\r
-\r
-#lexaction\r
-<<\r
-\r
-#include "EfiVfr.h"\r
-\r
-PARSER_LINE_DEFINITION  *gLineDefinition = NULL;\r
-PARSER_LINE_DEFINITION  *gLastLineDefinition = NULL;\r
-\r
-VOID\r
-AddFileLine (\r
-  char      *TokenString,\r
-  UINT32    TokenLine\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  During the lexer phase, if we encounter a #line statement output by\r
-  the preprocessor, this function gets called. We'll save off the info \r
-  for error reporting purposes. The preprocessor line information has the\r
-  form:\r
-    \r
-    #line 3 "FileName.c"  \r
-\r
-Arguments:\r
-  TokenString - the parsed string as shown above\r
-  TokenLine   - the line number in the preprocessed output file \r
-  \r
-Returns:\r
-  NA\r
-\r
---*/\r
-{\r
-  PARSER_LINE_DEFINITION  *LineDef;\r
-  CHAR8                   *Cptr;\r
-  \r
-  //\r
-  // Allocate a structure in which we can keep track of this line information.\r
-  //\r
-  LineDef = (PARSER_LINE_DEFINITION *)malloc (sizeof (PARSER_LINE_DEFINITION));\r
-  memset ((char *)LineDef, 0, sizeof (PARSER_LINE_DEFINITION));\r
-  LineDef->TokenLineNum = TokenLine;\r
-  LineDef->HashLineNum = atoi (TokenString + 6);\r
-  //\r
-  // Find the quotes in the filename, then allocate space in the line\r
-  // def structure for a copy of the filename. Finally, copy it without\r
-  // quotes to the line def.\r
-  //\r
-  for (Cptr = TokenString + 7; *Cptr && (*Cptr != '"'); Cptr++);\r
-  if (*Cptr == '"') {\r
-    LineDef->FileName = (CHAR8 *)malloc (strlen (Cptr));\r
-    Cptr++;\r
-    strcpy (LineDef->FileName, Cptr);\r
-    for (Cptr = LineDef->FileName; *Cptr && (*Cptr != '"'); Cptr++);\r
-    *Cptr = 0;   \r
-    //\r
-    // Now add this new one to the list\r
-    //\r
-    if (gLineDefinition == NULL) {\r
-      gLineDefinition = LineDef;\r
-    } else {\r
-      gLastLineDefinition->Next = LineDef;\r
-    }\r
-    gLastLineDefinition = LineDef;\r
-  } else {\r
-    Error (PROGRAM_NAME, 0, 0, "invalid line definition in preprocessor output file", TokenString);\r
-    free (LineDef);\r
-    return;\r
-  }\r
-}\r
-char *\r
-ConvertLineNumber (\r
-  UINT32 *LineNum\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Given the line number in the preprocessor-output file, use the line number\r
-  information we've saved to determine the source file name and line number\r
-  where the code originally came from. This is required for error reporting.\r
-\r
-Arguments:\r
-  LineNum - the line number in the preprocessor-output file.\r
-\r
-Returns:\r
-  Returns a pointer to the source file name. Also returns the line number \r
-  in the provided LineNum argument\r
-\r
---*/\r
-{\r
-  PARSER_LINE_DEFINITION  *LineDef;\r
-  //\r
-  // Step through our linked list of #line information we saved off. \r
-  // For each one, look at its line number, and the line number of the\r
-  // next record, and see if the passed-in line number is in the range.\r
-  // If it is, then convert the line number to the appropriate line number\r
-  // of the original source file.\r
-  //\r
-  for (LineDef = gLineDefinition; LineDef != NULL; LineDef = LineDef->Next) {\r
-    //\r
-    // The given LineNum is the line number from the .i file.\r
-    // Find a line definition whose range includes this line number,\r
-    // convert the line number, and return the filename.\r
-    //\r
-    if (LineDef->TokenLineNum <= *LineNum) {\r
-      if (LineDef->Next != NULL) {\r
-        if (LineDef->Next->TokenLineNum > *LineNum) {\r
-          *LineNum = *LineNum - LineDef->TokenLineNum + LineDef->HashLineNum;\r
-          return LineDef->FileName;\r
-        }\r
-      } else {\r
-        //\r
-        // Last one in the list of line definitions, so has to be right\r
-        //\r
-        *LineNum = *LineNum - LineDef->TokenLineNum + LineDef->HashLineNum;\r
-        return LineDef->FileName;\r
-      }\r
-    }\r
-  }\r
-  return NULL;\r
-}\r
-\r
->>\r
-\r
-//\r
-// Define a lexical class for parsing quoted strings. Basically\r
-// starts with a double quote, and ends with a double quote that\r
-// is not preceeded with a backslash.\r
-//\r
-#lexclass QUOTED_STRING\r
-#token TheString            "~[\"]*\"" << mode (START); >>     \r
-\r
-//\r
-// Define a lexical class for parsing "#pragma pack" statements. \r
-// We do this just for convenience (since we skip them here) so\r
-// that users can include some minimal .h files.\r
-//\r
-#lexclass PRAGMA_PACK\r
-#token "pack"     << skip (); >>\r
-#token "[\ \t]"   << skip (); >> \r
-#token "\("       << skip (); >>\r
-#token "[0-9]*"   << skip (); >>\r
-#token "\)"       << skip (); mode (START); >>\r
-\r
-//\r
-// Define a lexclass for skipping over C++ style comments\r
-//\r
-#lexclass CPP_COMMENT\r
-#token "~[\n]*"       << skip (); >>\r
-#token "\n"           << skip (); mode (START); newline (); >>\r
-\r
-//\r
-// Standard lexclass is START\r
-//\r
-#lexclass START\r
-\r
-//\r
-// Find start of C++ style comments\r
-//\r
-#token "//"     << skip (); mode (CPP_COMMENT); >>\r
-\r
-//\r
-// Skip whitespace\r
-//\r
-#token "[\ \t]"   << skip (); >> \r
-\r
-//\r
-// Skip over newlines, but count them\r
-//\r
-#token "\n"       << skip (); newline (); >>\r
-\r
-//\r
-// Skip pragma pack statements\r
-//\r
-#token "\#pragma" << skip (); mode(PRAGMA_PACK); >>\r
-\r
-//\r
-// Skip over 'extern' in any included .H file\r
-//\r
-#token "extern"   << skip (); >>\r
-\r
-//\r
-// Tokens for the different keywords. Syntax is:\r
-// TokenName("ErrorMessageText")    "TokenString"\r
-//   where:\r
-//     TokenName is the token name (must be capitalized) that is used in the rules\r
-//     ErrorMessageText is the string the compiler emits when it detects a syntax error\r
-//     TokenString is the actual matching string used in the user script\r
-//\r
-#token LineDefinition                           "#line\ [0-9]+\ \"~[\"]+\"[\ \t]*\n" << AddFileLine (begexpr (), line ()); skip (); >>\r
-#token FormSet("formset")                       "formset"\r
-#token EndFormSet("endformset")                 "endformset"\r
-#token Title("title")                           "title"\r
-#token FormId("formid")                         "formid"\r
-#token OneOf("oneof")                           "oneof"\r
-#token Prompt("prompt")                         "prompt"\r
-#token OrderedList("orderedlist")               "orderedlist"\r
-#token EndList("endlist")                       "endlist"\r
-#token EndForm("endform")                       "endform"\r
-#token EndOneOf("endoneof")                     "endoneof"\r
-#token Form("form")                             "form"\r
-#token Subtitle("subtitle")                     "subtitle"\r
-#token Help("help")                             "help"\r
-#token VarId("varid")                           "varid"\r
-#token Text("text")                             "text"\r
-#token Option("option")                         "option"\r
-#token Value("value")                           "value"\r
-#token Flags("flags")                           "flags"\r
-#token Date("date")                             "date"\r
-#token EndDate("enddate")                       "enddate"\r
-#token Year("year")                             "year"\r
-#token Month("month")                           "month"\r
-#token Day("day")                               "day"\r
-#token Time("time")                             "time"\r
-#token EndTime("endtime")                       "endtime"\r
-#token Hour("hour")                             "hour"\r
-#token Minute("minute")                         "minute"\r
-#token Second("second")                         "second"\r
-#token AND("AND")                               "AND"\r
-#token OR("OR")                                 "OR"\r
-#token GrayOutIf("grayoutif")                   "grayoutif"\r
-#token NOT("NOT")                               "NOT"\r
-#token Label("label")                           "label"\r
-#token Timeout("timeout")                       "timeout"\r
-#token Inventory("inventory")                   "inventory"\r
-#token StringToken("STRING_TOKEN")              "STRING_TOKEN"\r
-#token NonNvDataMap("_NON_NV_DATA_MAP")         "_NON_NV_DATA_MAP"\r
-#token Struct("struct")                         "struct"\r
-#token Uint64("UINT64")                         "UINT64"\r
-#token Uint32("UINT32")                         "UINT32"\r
-#token Uint16("UINT16")                         "UINT16"\r
-#token Char16("CHAR16")                         "CHAR16"\r
-#token Uint8("UINT8")                           "UINT8"\r
-#token Guid("guid")                             "guid"\r
-#token CheckBox("checkbox")                     "checkbox"\r
-#token EndCheckBox("endcheckbox")               "endcheckbox"\r
-#token Numeric("numeric")                       "numeric"\r
-#token EndNumeric("endnumeric")                 "endnumeric"            \r
-#token Minimum("minimum")                       "minimum"         \r
-#token Maximum("maximum")                       "maximum"         \r
-#token Step("step")                             "step"      \r
-#token Default("default")                       "default"         \r
-#token Password("password")                     "password"          \r
-#token EndPassword("endpassword")               "endpassword"             \r
-#token String("string")                         "string"        \r
-#token EndString("endstring")                   "endstring"           \r
-#token MinSize("minsize")                       "minsize"         \r
-#token MaxSize("maxsize")                       "maxsize"         \r
-#token Encoding("encoding")                     "encoding"\r
-#token SuppressIf("suppressif")                 "suppressif"\r
-#token Hidden("hidden")                         "hidden"\r
-#token Goto("goto")                             "goto"\r
-#token InconsistentIf                           "inconsistentif"\r
-#token EndIf("endif")                           "endif"\r
-#token IdEqId("ideqid")                         "ideqid"\r
-#token IdEqVal("ideqval")                       "ideqval"\r
-#token VarEqVal("vareqval")                     "vareqval"\r
-#token Var("var")                               "var"\r
-#token IdEqValList("ideqvallist")               "ideqvallist"\r
-#token Length("length")                         "length"\r
-#token Values("values")                         "values"\r
-#token Key("key")                               "key"\r
-#token DefaultFlag("DEFAULT")                   "DEFAULT"\r
-#token ManufacturingFlag("MANUFACTURING")       "MANUFACTURING"\r
-#token InteractiveFlag("INTERACTIVE")           "INTERACTIVE"\r
-#token NVAccessFlag("NV_ACCESS")                "NV_ACCESS"\r
-#token ResetRequiredFlag("RESET_REQUIRED")      "RESET_REQUIRED"\r
-#token LateCheckFlag("LATE_CHECK")              "LATE_CHECK"\r
-#token Class("class")                           "class"\r
-#token Subclass("subclass")                     "subclass"\r
-#token TypeDef("typedef")                       "typedef"\r
-#token Restore("restore")                       "restore"\r
-#token Save("save")                             "save"\r
-#token Defaults("defaults")                     "defaults"\r
-#token Banner("banner")                         "banner"\r
-#token Align("align")                           "align"\r
-#token Left("left")                             "left"\r
-#token Right("right")                           "right"\r
-#token Center("center")                         "center"\r
-#token Line("line")                             "line"\r
-#token VarStore("varstore")                     "varstore"\r
-#token Name("name")                             "name"\r
-#token Oem("oem")                               "oem"\r
-#token True("TRUE")                             "TRUE"\r
-#token False("FALSE")                           "FALSE"\r
-#token GreaterThan(">")                         ">"\r
-#token GreaterEqual(">=")                       ">="\r
-#token LessThan("<")                          "<"\r
-#token LessEqual("<=")                        "<="\r
-\r
-//\r
-// Define the class and subclass tokens\r
-//\r
-#token ClassNonDevice("NONDEVICE")                        "NON_DEVICE"\r
-#token ClassDiskDevice("DISK_DEVICE")                     "DISK_DEVICE"\r
-#token ClassVideoDevice("VIDEO_DEVICE")                   "VIDEO_DEVICE"\r
-#token ClassNetworkDevice("NETWORK_DEVICE")               "NETWORK_DEVICE"\r
-#token ClassInputDevice("INPUT_DEVICE")                   "INPUT_DEVICE"\r
-#token ClassOnBoardDevice("ONBOARD_DEVICE")               "ONBOARD_DEVICE"\r
-#token ClassOtherDevice("OTHER_DEVICE")                   "OTHER_DEVICE"\r
-\r
-#token SubclassSetupApplication("SETUP_APPLICATION")      "SETUP_APPLICATION"\r
-#token SubclassGeneralApplication("GENERAL_APPLICATION")  "GENERAL_APPLICATION"\r
-#token SubclassFrontPage("FRONT_PAGE")                    "FRONT_PAGE"\r
-#token SubclassSingleUse("SINGLE_USE")                    "SINGLE_USE"\r
-\r
-#token LanguageIdentifier("language identifier") "[a-z][a-z][a-z]"   // 3 lowercase characters\r
-#token StringIdentifier("string identifier")    "[A-Za-z_][A-Za-z_0-9]*"\r
-#token Number("numeric value")                  "(0x[0-9A-Fa-f]+) | [0-9]+"\r
-#token OpenBrace("{")                           "\{"\r
-#token CloseBrace("}")                          "\}"\r
-#token OpenParen("(")                           "\("\r
-#token CloseParen(")")                          "\)"\r
-#token OpenBracket("[")                         "\["\r
-#token CloseBracket("]")                        "\]"\r
-\r
-//\r
-// Define all other invalid characters so that they get through the lexical phase\r
-// and we can catch them during the parse phase. We get much better error\r
-// messages then. \r
-//\r
-#token InvalidCharacters("invalid characters")  "~[;:=,\.\|]"  \r
-\r
-//\r
-// This is the overall definition of a VFR form definition script.\r
-//\r
-program :\r
-  ( dataStructDefinition )*\r
-  formSetStatement   \r
-  ( vfrStatementVarStore )*\r
-  ( formDefinition )*\r
-  EFS:EndFormSet  ";"                   << WriteOpByte (EFS->getLine(), EFI_IFR_END_FORM_SET_OP); >>\r
-  "@" // end of file\r
-  ;\r
-    \r
-formSetStatement :\r
-  FS:FormSet                            << WriteOpByte (FS->getLine(), EFI_IFR_FORM_SET_OP); >>\r
-  Guid "=" \r
-  OpenBrace \r
-  G1:Number ","\r
-  G2:Number ","\r
-  G3:Number ","\r
-  OpenBrace\r
-  G4:Number ","\r
-  G5:Number ","\r
-  G6:Number ","\r
-  G7:Number ","\r
-  G8:Number ","\r
-  G9:Number ","\r
-  G10:Number ","\r
-  G11:Number \r
-  CloseBrace\r
-  CloseBrace                            << WriteGuidValue (G1->getLine (), G1->getText (), G2->getText (), G3->getText (),\r
-                                                           G4->getText (), G5->getText (), G6->getText (), G7->getText (),\r
-                                                           G8->getText (), G9->getText (), G10->getText (), G11->getText ()\r
-                                                          );\r
-                                         >>\r
-  ","\r
-  Title "=" getStringId ","\r
-  Help  "=" getStringId ","\r
-  //\r
-  // insert padding for an EFI_PHYSICAL_ADDRESS (UINT64)\r
-  //\r
-                                            << WriteDWord (0, 0); WriteDWord (0, 0); >>\r
-  Class "=" CVAL:classDefinition ","        << WriteClass (); >>\r
-  Subclass "=" SVAL:subclassDefinition ","  << WriteSubclass (); >>\r
-                                            << WriteWord (mNvDataStructSize); >>\r
-  ;  \r
-\r
-//\r
-// A form can be of multiple classes, thus allow CLASS_A | CLASS_B | CLASS_C\r
-//\r
-classDefinition :\r
-  validClassNames ( "\|" validClassNames )*\r
-  ;\r
-  \r
-validClassNames :\r
-    CND:ClassNonDevice          << SetClass (CND->getLine(), EFI_NON_DEVICE_CLASS); >>\r
-  | CDD:ClassDiskDevice         << SetClass (CDD->getLine(), EFI_DISK_DEVICE_CLASS); >>\r
-  | CVD:ClassVideoDevice        << SetClass (CVD->getLine(), EFI_VIDEO_DEVICE_CLASS); >>\r
-  | CNW:ClassNetworkDevice      << SetClass (CNW->getLine(), EFI_NETWORK_DEVICE_CLASS); >>\r
-  | CID:ClassInputDevice        << SetClass (CID->getLine(), EFI_INPUT_DEVICE_CLASS); >>\r
-  | COB:ClassOnBoardDevice      << SetClass (COB->getLine(), EFI_ON_BOARD_DEVICE_CLASS); >>\r
-  | COD:ClassOtherDevice        << SetClass (COD->getLine(), EFI_OTHER_DEVICE_CLASS); >>\r
-  | CNUM:Number                 << SetClass (CNUM->getLine(), GetNumber (CNUM->getText(), CNUM->getLine(), 4)); >>\r
-  ; << PrintErrorMessage (LT(1)->getLine(), LT(1)->getText(), "invalid class"); >>\r
-\r
-//\r
-// A form can only be of one subclass type.\r
-//\r
-subclassDefinition :\r
-    SSA:SubclassSetupApplication    << SetSubclass (SSA->getLine(), EFI_SETUP_APPLICATION_SUBCLASS); >>\r
-  | SGA:SubclassGeneralApplication  << SetSubclass (SGA->getLine(), EFI_GENERAL_APPLICATION_SUBCLASS); >>\r
-  | SFP:SubclassFrontPage           << SetSubclass (SFP->getLine(), EFI_FRONT_PAGE_SUBCLASS); >>\r
-  | SSU:SubclassSingleUse           << SetSubclass (SSU->getLine(), EFI_SINGLE_USE_SUBCLASS); >>\r
-  | SNUM:Number                     << SetSubclass (SNUM->getLine(), GetNumber (SNUM->getText(), SNUM->getLine(), 4)); >>\r
-  ; << PrintErrorMessage (LT(1)->getLine(), LT(1)->getText(), "invalid subclass"); >>\r
-\r
-//\r
-// Parse a C type data structure for storing VFR setup data. Allow:\r
-//  typedef struct _XXX_ {\r
-//     (fields)\r
-//  } MY_NV_DATA;\r
-//\r
-dataStructDefinition :\r
-  << int IsNonNV = 0; >>\r
-  { TypeDef } \r
-  S:Struct                          \r
-  (\r
-    NonNvDataMap                    << IsNonNV = 1; >>\r
-  |\r
-    { StringIdentifier }\r
-  )                                 << StartStructDefinition (IsNonNV, S->getLine()); >>\r
-  OpenBrace \r
-  dataStructFields \r
-  CloseBrace NAME:StringIdentifier  << EndStructDefinition (NAME->getText(), NAME->getLine()); >>\r
-  ";"\r
-  ;\r
-\r
-//\r
-// Parse a C type data structure for defining data that is not stored in NV.\r
-//  typedef struct _NON_NV_DATA_MAP {\r
-//     (fields)\r
-//  } NON_NV_DATA_MAP;\r
-//\r
-nonNvDataStructDefinition :\r
-  { TypeDef } \r
-  Struct NonNvDataMap\r
-  { StringIdentifier }\r
-  OpenBrace \r
-  dataStructFields \r
-  CloseBrace NAME:StringIdentifier        << AddStructField (NAME->getText(), NAME->getLine(), 0, 0, 0); >>\r
-  ";"                                             \r
-  ;\r
-\r
-dataStructFields :\r
-  ( dataStructField64 | dataStructField32 | dataStructField16 | dataStructField8 ) *\r
-  ;\r
-\r
-//*****************************************************************************\r
-//\r
-// PARSE:\r
-//   UINT64 Name[4];\r
-//   UINT64 Name;\r
-//\r
-// Used while parsing the NV data map structures.\r
-//\r
-dataStructField64 :\r
-  << int ArrayLength = 1; char IsArray = 0; >>\r
-  "UINT64" \r
-  NAME:StringIdentifier \r
-  ( ";" | OpenBracket IVal:Number CloseBracket ";"  << ArrayLength = GetNumber (IVal->getText(), IVal->getLine(), 4); IsArray = 1; >> ) \r
-                                                    << AddStructField (NAME->getText(), NAME->getLine(), 8, ArrayLength, IsArray); >>\r
-  ;\r
-\r
-//*****************************************************************************\r
-//\r
-// PARSE:\r
-//   UINT32 Name[4];\r
-//   UINT32 Name;\r
-//\r
-// Used while parsing the NV data map structures.\r
-//\r
-dataStructField32 :\r
-  << int ArrayLength = 1; char IsArray = 0; >>\r
-  "UINT32" \r
-  NAME:StringIdentifier \r
-  ( ";" | OpenBracket IVal:Number CloseBracket ";"  << ArrayLength = GetNumber (IVal->getText(), IVal->getLine(), 4); IsArray = 1; >> )  \r
-                                                    << AddStructField (NAME->getText(), NAME->getLine(), 4, ArrayLength, IsArray); >>\r
-  ;\r
-\r
-//*****************************************************************************\r
-//\r
-// PARSE:\r
-//   UINT16 Name[4];\r
-//   UINT16 Name;\r
-//\r
-// Used while parsing the NV data map structures.\r
-//\r
-dataStructField16 :\r
-  << int ArrayLength = 1; char IsArray = 0; >>\r
-  ( "UINT16" | "CHAR16" )\r
-  NAME:StringIdentifier \r
-  ( ";" | OpenBracket IVal:Number CloseBracket ";"  << ArrayLength = GetNumber (IVal->getText(), IVal->getLine(), 4); IsArray = 1; >> ) \r
-                                                    << AddStructField (NAME->getText(), NAME->getLine(), 2, ArrayLength, IsArray); >>\r
-  ;\r
-\r
-//*****************************************************************************\r
-//\r
-// PARSE:\r
-//   UINT8 Name[4];\r
-//   UINT8 Name;\r
-//\r
-// Used while parsing the NV data map structures.\r
-//\r
-dataStructField8 :\r
-  << int ArrayLength = 1; char IsArray = 0; >>\r
-  "UINT8" \r
-  NAME:StringIdentifier \r
-  ( ";" | OpenBracket IVal:Number CloseBracket ";"  << ArrayLength = GetNumber (IVal->getText(), IVal->getLine(), 4); IsArray = 1; >> ) \r
-                                                    << AddStructField (NAME->getText(), NAME->getLine(), 1, ArrayLength, IsArray); >>\r
-  ;\r
-\r
-//*****************************************************************************\r
-//\r
-// PARSE:\r
-//    form formid = 1,\r
-//      title  = STRING_TOKEN(STR_FORM_TITLE);\r
-//      -- form statements --\r
-//    endform;\r
-//\r
-//  The Form ID cannot be 0\r
-//\r
-formDefinition :\r
-  FRM:Form FormId                << WriteOpByte (FRM->getLine(), EFI_IFR_FORM_OP); >> \r
-  "=" \r
-  VAL:Number                     << WriteWord (GetNumber (VAL->getText(), VAL->getLine(), 2)); AddFormId (GetNumber (VAL->getText(), VAL->getLine(), 2), VAL->getLine()); >>\r
-  ","\r
-  Title "=" getStringId ";"      // writes string identifier\r
-  ( vfrStatements )*\r
-  ENDF:EndForm  ";"              << WriteOpByte (ENDF->getLine(), EFI_IFR_END_FORM_OP); >>\r
-  ;\r
-\r
-//\r
-// VFR statements in a formset\r
-//\r
-vfrStatements :\r
-  vfrStatementSubTitle        | \r
-  vfrStatementOneOf           |\r
-  vfrStatementTextText        |\r
-  vfrStatementCheckBox        |\r
-  vfrStatementNumeric         |\r
-  vfrStatementDate            |\r
-  vfrStatementTime            |\r
-  vfrStatementPassword        |\r
-  vfrStatementString          |\r
-  vfrStatementSuppressIf      |\r
-  vfrStatementHidden          |\r
-  vfrStatementGoto            | \r
-  vfrStatementGrayOutIf       |\r
-  vfrStatementInconsistentIf  |\r
-  vfrStatementLabel           |\r
-  vfrStatementBanner          |\r
-  vfrStatementInventory       |\r
-  vfrStatementOrderedList     |\r
-  vfrStatementOem             |\r
-  vfrStatementSaveRestoreDefaults\r
-  ;\r
-\r
-//*****************************************************************************\r
-//\r
-// PARSE:\r
-//   label 100;\r
-//\r
-vfrStatementLabel :\r
-  OPID:Label                              << WriteOpByte (OPID->getLine(), EFI_IFR_LABEL_OP); >>\r
-  VAL:Number                              << \r
-                                              WriteWord (GetNumber (VAL->getText(), VAL->getLine(), 2)); \r
-                                              AddLabel (GetNumber (VAL->getText(), VAL->getLine(), 2), VAL->getLine());\r
-                                          >>\r
-  ";"\r
-  ;\r
-\r
-//*****************************************************************************\r
-//\r
-// PARSE:\r
-//   oem 0x12, 0x34, 0x56;\r
-//\r
-vfrStatementOem :\r
-  OPID:Oem                              << WriteOpByte (OPID->getLine(), EFI_IFR_OEM_DEFINED_OP); >>\r
-  ( VAL1:Number << WriteByte (GetNumber (VAL1->getText(), VAL1->getLine(), 1), 0); >> )\r
-  ( "," VAL2:Number << WriteByte (GetNumber (VAL2->getText(), VAL2->getLine(), 1), 0); >> )*\r
-  ";"\r
-  ;\r
-  \r
-//*****************************************************************************\r
-//\r
-// PARSE:\r
-//   inconsistentif NOT .... AND NOT .... OR ... endif;\r
-//\r
-vfrStatementInconsistentIf : \r
-  << ResetFlags (); >>\r
-  IIFOP:InconsistentIf                  << WriteOpByte (IIFOP->getLine(), EFI_IFR_INCONSISTENT_IF_OP); >>\r
-  Prompt "=" getStringId ","\r
-  { \r
-    FF:Flags  "=" flagsField ( "\|" flagsField )* "," \r
-  }\r
-  << WriteFlags (); >> //  write the flags field\r
-  vfrBooleanExpression\r
-  EOP:EndIf ";"                         << WriteOpByte (EOP->getLine(), EFI_IFR_END_IF_OP); >>\r
-  ;\r
-\r
-//*****************************************************************************\r
-// \r
-// PARSE:\r
-//   TRUE AND (ideqval SomeStruct.SomeMember >= 0x10 OR \r
-//               ideqid SomeStruct.SomeMember < SomeStruct.SomeOtherMember) AND\r
-//            (ideqlist SomeStruct.SomeOtherMember == 0x10, 0x20, 0x30 OR\r
-//               vareqval var(VAR_EQ_TEST_NAME) == 0x1)\r
-//\r
-// For supporting complex express, divide the vfrBooleanExpression to two parts\r
-// so that pred-LL(k) parser can parse incrementally.\r
-//\r
-vfrBooleanExpression :\r
-  leftPartVfrBooleanExp { rightPartVfrBooleanExp }\r
-  ;\r
-  \r
-leftPartVfrBooleanExp :\r
-  OpenParen vfrBooleanExpression CloseParen                                                        |\r
-  (ideqval | ideqid | ideqvallist | vareqval | truefalse)                                          |\r
-  NOPID:NOT leftPartVfrBooleanExp           << WriteOpByte (NOPID->getLine(), EFI_IFR_NOT_OP); >>\r
-  ;\r
-\r
-rightPartVfrBooleanExp :\r
-  AOPID:AND vfrBooleanExpression            << WriteOpByte (AOPID->getLine(), EFI_IFR_AND_OP); >>  |\r
-  OOPID:OR vfrBooleanExpression             << WriteOpByte (OOPID->getLine(), EFI_IFR_OR_OP); >>\r
-  ;\r
-\r
-//*****************************************************************************\r
-//\r
-// PARSE:\r
-//   TRUE\r
-//\r
-truefalse :\r
-  TOPID:True                                << WriteOpByte (TOPID->getLine(), EFI_IFR_TRUE_OP); >> |\r
-  FOPID:False                               << WriteOpByte (FOPID->getLine(), EFI_IFR_FALSE_OP); >>\r
-  ;\r
-\r
-//*****************************************************************************\r
-//\r
-// PARSE:\r
-//   varstore MY_STRUCT_NAME, key = 0x1234, name = "MyVariableName", guid = {...};\r
-//\r
-vfrStatementVarStore : \r
-  OP:VarStore                           << WriteOpByte (OP->getLine(), EFI_IFR_VARSTORE_OP); >>\r
-  STRUCT_NAME:StringIdentifier ","\r
-  Key   "=" KNUM:Number ","\r
-  Name  "=" VAR_NAME:StringIdentifier ","  \r
-  Guid "=" \r
-  OpenBrace \r
-  G1:Number ","\r
-  G2:Number ","\r
-  G3:Number ","\r
-  OpenBrace\r
-  G4:Number ","\r
-  G5:Number ","\r
-  G6:Number ","\r
-  G7:Number ","\r
-  G8:Number ","\r
-  G9:Number ","\r
-  G10:Number ","\r
-  G11:Number \r
-  CloseBrace\r
-  CloseBrace                            << WriteGuidValue (G1->getLine (), G1->getText (), G2->getText (), G3->getText (),\r
-                                                           G4->getText (), G5->getText (), G6->getText (), G7->getText (),\r
-                                                           G8->getText (), G9->getText (), G10->getText (), G11->getText ()\r
-                                                          );\r
-                                           WriteWord (GetNumber (KNUM->getText(), KNUM->getLine(), 2)); \r
-                                           AddVarStore (STRUCT_NAME->getText(), VAR_NAME->getText(), GetNumber (KNUM->getText(), KNUM->getLine(), 2), STRUCT_NAME->getLine());\r
-                                         >>\r
-  \r
-  ";"\r
-  ;\r
-\r
-//*****************************************************************************\r
-//\r
-// PARSE:  \r
-//   vareqval var(0x100) == 0x20\r
-//\r
-vareqval : \r
-  OPID:VarEqVal                           << WriteOpByte (OPID->getLine(), EFI_IFR_EQ_VAR_VAL_OP); >>\r
-  Var OpenParen \r
-  VAR:Number                              << WriteWord (GetNumber (VAR->getText(), VAR->getLine(), 2)); >>\r
-  CloseParen\r
-  compareNumber\r
-  ;\r
-\r
-ideqval : \r
-  OPID:IdEqVal                            << WriteOpByte (OPID->getLine(), EFI_IFR_EQ_ID_VAL_OP); >>\r
-  vfrStructFieldName[0]\r
-  compareNumber\r
-  ;\r
-\r
-//*****************************************************************************\r
-//\r
-// PARSE:\r
-//   ideqid MyNVData3.Field16A == MyNVData3.Field16B\r
-//\r
-// NOTE: Before processing the second variable store in the ideqid statement, set a global flag\r
-//       so that when we parse the second variable we set the secondary variable store id.\r
-//\r
-ideqid : \r
-  OPID:IdEqId                             << WriteOpByte (OPID->getLine(), EFI_IFR_EQ_ID_ID_OP);  >>\r
-  vfrStructFieldName[0]\r
-  compareVfrStructFieldNameNL0\r
-  ;\r
-\r
-//*****************************************************************************\r
-//\r
-// compareNumber is the combination of compare operation and Number\r
-//\r
-compareNumber :\r
-  (\r
-  "=="\r
-  VAL1:Number                             << WriteWord (GetNumber (VAL1->getText(), VAL1->getLine(), 2)); >>\r
-  ) |\r
-  (\r
-  GTOPID:GreaterThan\r
-  VAL2:Number                             << WriteWord (GetNumber (VAL2->getText(), VAL2->getLine(), 2));\r
-                                             WriteOpByte (GTOPID->getLine(), EFI_IFR_GT_OP); >>\r
-  ) |\r
-  (\r
-  GEOPID:GreaterEqual\r
-  VAL3:Number                             << WriteWord (GetNumber (VAL3->getText(), VAL3->getLine(), 2));\r
-                                             WriteOpByte (GEOPID->getLine(), EFI_IFR_GE_OP); >>\r
-  ) |\r
-  (\r
-  LTOPID:LessThan\r
-  VAL4:Number                             << WriteWord (GetNumber (VAL4->getText(), VAL4->getLine(), 2));\r
-                                             WriteOpByte (LTOPID->getLine(), EFI_IFR_GE_OP);\r
-                                             WriteOpByte (LTOPID->getLine(), EFI_IFR_NOT_OP); >>\r
-  ) |\r
-  (\r
-  LEOPID:LessEqual\r
-  VAL5:Number                             << WriteWord (GetNumber (VAL5->getText(), VAL5->getLine(), 2));\r
-                                             WriteOpByte (LEOPID->getLine(), EFI_IFR_GT_OP);\r
-                                             WriteOpByte (LEOPID->getLine(), EFI_IFR_NOT_OP); >>\r
-  )\r
-  ;\r
-\r
-//*****************************************************************************\r
-//\r
-// compareVfrStructFieldNameNL0 is the combination of compare operation and  vfrStructFieldNameNL[0]\r
-//\r
-compareVfrStructFieldNameNL0 :\r
-  (\r
-  "=="                                    << mIdEqIdStmt = 1; >>\r
-  vfrStructFieldNameNL[0]                 << mIdEqIdStmt = 0; >>\r
-  ) |\r
-  (\r
-  GTOPID:GreaterThan                      << mIdEqIdStmt = 1; >>\r
-  vfrStructFieldNameNL[0]                 << mIdEqIdStmt = 0;\r
-                                             WriteOpByte (GTOPID->getLine(), EFI_IFR_GT_OP); >>\r
-  ) |\r
-  (\r
-  GEOPID:GreaterEqual                     << mIdEqIdStmt = 1; >>\r
-  vfrStructFieldNameNL[0]                 << mIdEqIdStmt = 0;\r
-                                             WriteOpByte (GEOPID->getLine(), EFI_IFR_GE_OP); >>\r
-  ) |\r
-  (\r
-  LTOPID:LessThan                       << mIdEqIdStmt = 1; >>\r
-  vfrStructFieldNameNL[0]                 << mIdEqIdStmt = 0;\r
-                                             WriteOpByte (LTOPID->getLine(), EFI_IFR_GE_OP);\r
-                                             WriteOpByte (LTOPID->getLine(), EFI_IFR_NOT_OP); >>\r
-  ) |\r
-  (\r
-  LEOPID:LessEqual                      << mIdEqIdStmt = 1; >>\r
-  vfrStructFieldNameNL[0]                 << mIdEqIdStmt = 0;\r
-                                             WriteOpByte (LEOPID->getLine(), EFI_IFR_GT_OP);\r
-                                             WriteOpByte (LEOPID->getLine(), EFI_IFR_NOT_OP); >>\r
-  )\r
-  ;\r
-  \r
-\r
-ideqvallist : \r
-  OPID:IdEqValList                        << WriteOpByte (OPID->getLine(), EFI_IFR_EQ_ID_LIST_OP); >>\r
-  vfrStructFieldName[0] \r
-  "=="\r
-  ( VAL:Number                            << QueueIdEqValList (GetNumber (VAL->getText(), VAL->getLine(), 2)); >> ) +\r
-                                          << FlushQueueIdEqValList(); >>\r
-  ;\r
-    \r
-vfrStatementGoto : \r
-  << UINT32 LineNum, KeyValue = 0; ResetFlags (); >>\r
-  IDG:Goto                          << WriteOpByte (IDG->getLine(), EFI_IFR_REF_OP); >>\r
-  VAL:Number  ","                   << WriteWord (GetNumber (VAL->getText(), VAL->getLine(), 2)); \r
-                                       AddGotoReference (GetNumber (VAL->getText(), VAL->getLine(), 2), VAL->getLine());\r
-                                    >>\r
-  KP:Prompt   "=" getStringId ","   << LineNum = KP->getLine();  >>\r
-  Help        "=" getStringId\r
-  { \r
-    "," \r
-    FF:Flags  "=" flagsField ( "\|" flagsField )*  << LineNum = FF->getLine(); >>\r
-  }\r
-  {\r
-    "," Key   "=" KNUM:Number       << LineNum = KNUM->getLine(); KeyValue = GetNumber(KNUM->getText(), LineNum, 2); >>\r
-  }\r
-                                    << WriteFlagsKey (KeyValue, LineNum); >>\r
-  ";"\r
-  ;\r
-    \r
-vfrStatementHidden : \r
-  IDH:Hidden                  << WriteOpByte (IDH->getLine(), EFI_IFR_HIDDEN_OP); >>\r
-  Value "="\r
-  VAL:Number ","              << WriteWord (GetNumber (VAL->getText(), VAL->getLine(), 2)); >>\r
-  Key "="\r
-  KVAL:Number                 << WriteWord (GetNumber (KVAL->getText(), KVAL->getLine(), 2)); >>\r
-  ";"\r
-  ;    \r
-\r
-//*****************************************************************************\r
-//\r
-// PARSE:\r
-//   suppressif <boolean_expression> { grayoutif } <statements>+ endif;\r
-// Note:\r
-//   You can have: suppressif:grayoutif:statements:endif\r
-//                 suppressif:grayoutif:endif                  -- serves no purpose\r
-//                 suppressif:statements:endif\r
-//                 suppressif:endif                            -- serves no purpose\r
-//\r
-vfrStatementSuppressIf : \r
-  << ResetFlags (); >>\r
-  OPID:SuppressIf                     << WriteOpByte (OPID->getLine(), EFI_IFR_SUPPRESS_IF_OP); SetIfStart (OPID->getLine()); >>\r
-  { \r
-    FF:Flags  "=" flagsField ( "\|" flagsField )* ","\r
-  }\r
-  << WriteFlags (); >> //  write the flags field \r
-  vfrBooleanExpression\r
-  ";"\r
-  { suppressIfGrayOutIf } ( suppressIfAndGrayoutIfSubstatements )+\r
-  ENDOP:EndIf ";"                     << WriteOpByte (ENDOP->getLine(), EFI_IFR_END_IF_OP); SetIfStart (0); >>\r
-  ;\r
-\r
-//\r
-// This is the form for a grayoutif nested in a suppressif statement\r
-//\r
-suppressIfGrayOutIf :\r
-  << ResetFlags (); >>\r
-  OPID:GrayOutIf                      << WriteOpByte (OPID->getLine(), EFI_IFR_GRAYOUT_IF_OP); >>\r
-  { \r
-    FF:Flags  "=" flagsField ( "\|" flagsField )* "," \r
-  }\r
-  << WriteFlags (); >> //  write the flags field\r
-  vfrBooleanExpression\r
-  ";"\r
-  ; \r
-\r
-//*****************************************************************************\r
-//\r
-// PARSE:\r
-//   grayoutif { flags = n, } <boolean_expression> endif;\r
-// Note:\r
-//   You can have: grayoutif:suppressif:statements:endif\r
-//                 grayoutif:statements:endif\r
-//\r
-//\r
-vfrStatementGrayOutIf :\r
-  << ResetFlags (); >>\r
-  OPID:GrayOutIf                      << WriteOpByte (OPID->getLine(), EFI_IFR_GRAYOUT_IF_OP); SetIfStart (OPID->getLine()); >>\r
-  { \r
-    FF:Flags  "=" flagsField ( "\|" flagsField )* "," \r
-  }\r
-  << WriteFlags (); >> //  write the flags field\r
-  vfrBooleanExpression\r
-  ";"\r
-  { grayoutIfSuppressIf } ( suppressIfAndGrayoutIfSubstatements )+ \r
-  ENDOP:EndIf ";"                     << WriteOpByte (ENDOP->getLine(), EFI_IFR_END_IF_OP); SetIfStart (0); >>\r
-  ;\r
-\r
-//\r
-// This is the format for a suppressif nested in a grayoutif\r
-//\r
-grayoutIfSuppressIf : \r
-  << ResetFlags (); >>\r
-  OPID:SuppressIf                     << WriteOpByte (OPID->getLine(), EFI_IFR_SUPPRESS_IF_OP); >>\r
-  { \r
-    FF:Flags  "=" flagsField ( "\|" flagsField )* ","\r
-  }\r
-  << WriteFlags (); >> //  write the flags field\r
-  vfrBooleanExpression\r
-  ";"\r
-  ;\r
-\r
-//\r
-// These are the VFR statements that are valid inside a suppressif or grayoutif statement.\r
-//\r
-suppressIfAndGrayoutIfSubstatements :\r
-  vfrStatementOneOf           |\r
-  vfrStatementTextText        |\r
-  vfrStatementCheckBox        |\r
-  vfrStatementNumeric         |\r
-  vfrStatementDate            |\r
-  vfrStatementTime            |\r
-  vfrStatementPassword        |\r
-  vfrStatementString          |\r
-  vfrStatementHidden          |\r
-  vfrStatementGoto            | \r
-  vfrStatementLabel           |\r
-  vfrStatementInventory       |\r
-  vfrStatementOrderedList     |\r
-  vfrStatementSaveRestoreDefaults\r
-  ; \r
-\r
-//*****************************************************************************\r
-//\r
-// PARSE:\r
-//\r
-//    password  varid    = MyNvData.Password,\r
-//              prompt   = STRING_TOKEN(STR_PASSWORD_PROMPT),\r
-//              help     = STRING_TOKEN(STR_PASSWORD_HELP),\r
-//              minsize  = 6,\r
-//              maxsize  = 20,\r
-//              encoding = 1,\r
-//    endpassword; \r
-  \r
-vfrStatementPassword : \r
-  << UINT32 KeyValue = 0; UINT32 LineNum; ResetFlags (); >>\r
-  IDPW:Password                       << WriteOpByte (IDPW->getLine(), EFI_IFR_PASSWORD_OP); >>\r
-  VarId       "=" vfrStructFieldNameArray[0] ","\r
-  Prompt      "=" getStringId ","\r
-  KH:Help     "=" getStringId ","    << LineNum = KH->getLine(); >>\r
-  { \r
-    FF:Flags  "=" flagsField ( "\|" flagsField )* ","  << LineNum = FF->getLine(); >>\r
-  }\r
-  {\r
-    Key "=" KNUM:Number ","           << LineNum = KNUM->getLine(); KeyValue = GetNumber(KNUM->getText(), LineNum, 2); >>\r
-  }\r
-                                      << WriteFlagsKey (KeyValue, LineNum); >>\r
-  MinSize   "=" MIN:Number ","        << WriteByte (GetNumber (MIN->getText(), MIN->getLine(), 1), 0); >>\r
-  MaxSize   "=" MAX:Number ","        << WriteByte (GetNumber (MAX->getText(), MAX->getLine(), 1), 0); >>\r
-  Encoding  "=" ENC:Number ","        << WriteWord (GetNumber (ENC->getText(), ENC->getLine(), 2)); >>\r
-  EndPassword  ";"              \r
-  ;\r
-\r
-//*****************************************************************************\r
-//\r
-//  PARSE:\r
-//\r
-//    string    varid    = MyNv.String,\r
-//              prompt   = STRING_TOKEN(STR_STRING_PROMPT),\r
-//              help     = STRING_TOKEN(STR_STRING_HELP),\r
-//              flags    = INTERACTIVE,\r
-//              key      = 0x1234,\r
-//              minsize  = 6,\r
-//              maxsize  = 0x14,\r
-//    endstring; \r
-//\r
-// Since flags and key are optional, we can't use Flags->getLine(). Therefore for error\r
-// reporting we save the line number of the "help" keyword.\r
-//\r
-vfrStatementString : \r
-  << unsigned int KeyValue = 0; UINT32 LineNum; ResetFlags (); >>\r
-  IDS:String                                << WriteOpByte (IDS->getLine(), EFI_IFR_STRING_OP); >>\r
-  VarId     "=" vfrStructFieldNameArray[0] ","\r
-  Prompt    "=" getStringId ","\r
-  KH:Help   "=" getStringId ","             << LineNum = KH->getLine(); >>\r
-  { \r
-    FF:Flags "=" \r
-    flagsField ( "\|" flagsField )*         << LineNum = FF->getLine(); >>\r
-    "," \r
-  }\r
-  {\r
-    Key "=" KNUM:Number ","                 << LineNum = KNUM->getLine(); KeyValue = GetNumber(KNUM->getText(), LineNum, 2); >>\r
-  }\r
-                                            << WriteFlagsKey (KeyValue, LineNum); >>\r
-  MinSize   "=" MIN:Number ","              << WriteByte (GetNumber (MIN->getText(), MIN->getLine(), 1), 0);  >>\r
-  MaxSize   "=" MAX:Number ","              << WriteByte (GetNumber (MAX->getText(), MAX->getLine(), 1), 0); >>\r
-  EndString  ";"\r
-  ;\r
-\r
-//*****************************************************************************\r
-//\r
-// PARSE:\r
-//    numeric varid   = MyIfrNVData.HowOldAreYouInYears, \r
-//            prompt  = STRING_TOKEN(STR_NUMERIC_PROMPT),\r
-//            help    = STRING_TOKEN(STR_NUMERIC_HELP),\r
-//            flags   = INTERACTIVE,  // flags is optional\r
-//            key     = 0x1234,       // key is optional if (flags & INTERACTIVE = 0)\r
-//            minimum = 0x0,\r
-//            maximum = 0xf0,\r
-//            step    = 1,            // step is option, and step=1 if not specified\r
-//            default = 0;            // default is optional, and default=minimum if not specified\r
-//    endnumeric;\r
-//\r
-// Make flags and key optional. However if flags includes INTERACTIVE, then a key is required.\r
-// That check is done in WriteFlagsKey() function.\r
-//\r
-vfrStatementNumeric :  \r
-  << UINT32 LineNum, KeyValue = 0; ResetFlags (); >>\r
-  IDN:Numeric                         << WriteOpByte (IDN->getLine(), EFI_IFR_NUMERIC_OP); >>\r
-  VarId     "=" vfrStructFieldName[2] ","\r
-  Prompt    "=" getStringId ","\r
-  KH:Help   "=" getStringId ","       << LineNum = KH->getLine(); >>\r
-  { \r
-    FF:Flags "=" flagsField ( "\|" flagsField )* ","     << LineNum = FF->getLine (); >>\r
-  }\r
-  {\r
-    Key "=" KNUM:Number  ","          << LineNum = KNUM->getLine(); KeyValue = GetNumber(KNUM->getText(), LineNum, 2); >>\r
-  }\r
-                                      << WriteFlagsKey (KeyValue, LineNum); >>\r
-  minMaxStepDefault                   \r
-  EndNumeric ";"                      << WriteMinMaxStepDefault (); >>\r
-  ;\r
-\r
-//\r
-// Parse minimum/maximum/step/default statements. Special cases:\r
-//   - if step not specified, then the value is 1\r
-//   - if default not specified, then the value is the min value specified\r
-//   - if max < min, print a warning and swap the values (changes default too)\r
-//\r
-minMaxStepDefault :\r
-  << InitMinMaxStepDefault (); >>\r
-  Minimum   "=" MIN:Number ","        << SetMinMaxStepDefault (GetNumber (MIN->getText(),  MIN->getLine(), 2), 0, MIN->getLine()); >>\r
-  Maximum   "=" MAX:Number ","        << SetMinMaxStepDefault (GetNumber (MAX->getText(),  MAX->getLine(), 2), 1, MAX->getLine()); >>\r
-  { Step    "=" STEP:Number ","       << SetMinMaxStepDefault (GetNumber (STEP->getText(), STEP->getLine(), 2), 2, STEP->getLine()); >> }\r
-  { Default "=" DEF:Number ","        << SetMinMaxStepDefault (GetNumber (DEF->getText(),  DEF->getLine(), 2), 3, DEF->getLine()); >> }\r
-  ;\r
-\r
-\r
-//*****************************************************************************\r
-//\r
-// PARSE:\r
-//\r
-//    date    year varid  = Date.Year,                        // "Date.Year" is a special case we recognize\r
-//            prompt      = STRING_TOKEN(STR_DATE_PROMPT),\r
-//            help        = STRING_TOKEN(STR_DATE_YEAR_HELP),\r
-//            minimum     = 1939,\r
-//            maximum     = 2101,\r
-//            step        = 1,\r
-//            default     = 1964,\r
-//\r
-//            month varid = Date.Month,    \r
-//            prompt      = STRING_TOKEN(STR_DATE_PROMPT),\r
-//            help        = STRING_TOKEN(STR_DATE_MONTH_HELP),\r
-//            minimum     = 1,\r
-//            maximum     = 12,\r
-//            step        = 1,\r
-//            default     = 1,\r
-//\r
-//            day varid   = Date.Day,\r
-//            prompt      = STRING_TOKEN(STR_DATE_PROMPT),\r
-//            help        = STRING_TOKEN(STR_DATE_DAY_HELP),\r
-//            minimum     = 1,\r
-//            maximum     = 31,\r
-//            step        = 0x1,\r
-//            default     = 1,\r
-//\r
-//    enddate;\r
-//  \r
-vfrStatementDate :  \r
-  Date                            \r
-  IDY:Year VarId "="                  << WriteOpByte (IDY->getLine(), EFI_IFR_DATE_OP); >>\r
-  vfrStructFieldName[2] "," \r
-  dateTimeSubStatement                    \r
-  IDM:Month VarId "="                 << WriteOpByte (IDM->getLine(), EFI_IFR_DATE_OP); >>\r
-  vfrStructFieldName[2] "," \r
-  dateTimeSubStatement                    \r
-  IDD:Day VarId "="                   << WriteOpByte (IDD->getLine(), EFI_IFR_DATE_OP); >> \r
-  vfrStructFieldName[2] ","  \r
-  dateTimeSubStatement    \r
-  EndDate ";"\r
-  ;\r
-  \r
-vfrStatementTime :  \r
-  Time                            \r
-  IDH:Hour VarId "="                  << WriteOpByte (IDH->getLine(), EFI_IFR_TIME_OP); >>\r
-  vfrStructFieldName[2] ","  \r
-  dateTimeSubStatement                    \r
-  IDM:Minute VarId "="                << WriteOpByte (IDM->getLine(), EFI_IFR_TIME_OP); >>\r
-  vfrStructFieldName[2] "," \r
-  dateTimeSubStatement                    \r
-  IDS:Second VarId "="                << WriteOpByte (IDS->getLine(), EFI_IFR_TIME_OP); >>\r
-  vfrStructFieldName[2] "," \r
-  dateTimeSubStatement\r
-  EndTime ";"\r
-  ;\r
-\r
-//*****************************************************************************\r
-//\r
-// PARSE:\r
-//\r
-//   text  text = STRING_ID;\r
-//   text  text = STRING_ID, text = STRING_ID;\r
-//   text  text = STRING_ID, text = STRING_ID, flags = x, key = y;\r
-//\r
-vfrStatementTextText :\r
-  << ResetFlags (); >>\r
-  IDT:Text                            << WriteOpByte (IDT->getLine(), EFI_IFR_TEXT_OP); >>\r
-  Help "=" getStringId ","\r
-  Text "=" \r
-  getStringId                         // writes string identifier\r
-  { "," Text "=" getStringId\r
-    "," Flags "=" flagsField ( "\|" flagsField )*  << WriteFlags (); >>\r
-    "," \r
-    Key "=" KNUM:Number               << WriteWord (GetNumber(KNUM->getText(), KNUM->getLine(), 2)); >>\r
-  }\r
-  ";" \r
-  ;\r
-\r
-//*****************************************************************************\r
-//\r
-// PARSE:\r
-//\r
-//   inventory help = ID, text = ID;\r
-//   inventory help = ID, text = id, text = ID;\r
-//\r
-vfrStatementInventory :\r
-  IDI:Inventory                        << WriteOpByte (IDI->getLine(), EFI_IFR_INVENTORY_OP); >>\r
-  Help        "=" getStringId ","\r
-  Text        "=" getStringId                 // writes string identifier\r
-  { "," Text  "=" getStringId\r
-  }\r
-  ";" \r
-  ;\r
-\r
-//*****************************************************************************\r
-//\r
-// PARSE:\r
-//\r
-//    restore defaults,\r
-//      formid  = 4,\r
-//      prompt  = STRING_TOKEN(STR_RESTORE_DEFAULTS_PROMPT),\r
-//      help    = STRING_TOKEN(STR_RESTORE_DEFAULTS_HELP),\r
-//      flags   = 0,\r
-//      key     = 0;\r
-//\r
-//    save defaults,\r
-//      formid  = 4,\r
-//      prompt  = STRING_TOKEN(STR_SAVE_DEFAULTS_PROMPT),\r
-//      help    = STRING_TOKEN(STR_SAVE_DEFAULTS_HELP),\r
-//      flags   = 0,\r
-//      key     = 0;\r
-//\r
-vfrStatementSaveRestoreDefaults : \r
-  << unsigned int KeyValue = 0; UINT32 LineNum; ResetFlags (); >>\r
-  ( IDS:Save                            << WriteOpByte (IDS->getLine(), EFI_IFR_SAVE_DEFAULTS_OP); >>\r
-  | IDR:Restore                         << WriteOpByte (IDR->getLine(), EFI_IFR_RESTORE_DEFAULTS_OP); >>\r
-  )\r
-  Defaults ","\r
-  FormId    "=" FRMID:Number  ","       << WriteWord (GetNumber (FRMID->getText(), FRMID->getLine(), 2)); \r
-                                           AddGotoReference (GetNumber (FRMID->getText(), FRMID->getLine(), 2), FRMID->getLine());\r
-                                        >>\r
-  Prompt    "=" getStringId ","\r
-  KH:Help   "=" getStringId             << LineNum = KH->getLine(); >>\r
-  { \r
-    "," FF:Flags "=" flagsField ( "\|" flagsField )*  << LineNum = FF->getLine(); >>\r
-  }\r
-  {\r
-    "," Key "=" KNUM:Number             << LineNum = KNUM->getLine(); KeyValue = GetNumber(KNUM->getText(), LineNum, 2); >>\r
-  }\r
-                                        << WriteFlagsKey (KeyValue, LineNum); >>\r
-  ";"\r
-  ;\r
-\r
-//*****************************************************************************\r
-//\r
-// PARSE:\r
-//\r
-//   flags = 0x10 | DEFAULT | MANUFACTURING | INTERACTIVE | NV_ACCESS | RESET_REQUIRED | LATE_CHECK\r
-//\r
-// \r
-flagsField :\r
-  VAL:Number                          << SetFlags (GetNumber(VAL->getText(), VAL->getLine(), 4), VAL->getLine()); >>\r
-  | IF:InteractiveFlag                << SetFlags (EFI_IFR_FLAG_INTERACTIVE, IF->getLine());    >>\r
-  | MF:ManufacturingFlag              << SetFlags (EFI_IFR_FLAG_MANUFACTURING, MF->getLine());  >>\r
-  | DF:DefaultFlag                    << SetFlags (EFI_IFR_FLAG_DEFAULT, DF->getLine());        >>\r
-  | NV:NVAccessFlag                   << SetFlags (EFI_IFR_FLAG_NV_ACCESS, NV->getLine());      >>\r
-  | RR:ResetRequiredFlag              << SetFlags (EFI_IFR_FLAG_RESET_REQUIRED, RR->getLine()); >>\r
-  | LC:LateCheckFlag                  << SetFlags (EFI_IFR_FLAG_LATE_CHECK, LC->getLine());     >>\r
-  ;\r
-\r
-dateTimeSubStatement :\r
-  Prompt  "=" getStringId ","\r
-  Help    "=" getStringId ","\r
-                                      << WriteByte (0, 0); WriteWord (0); >> // bogus flags and key\r
-  minMaxStepDefault                   << WriteMinMaxStepDefault (); >>\r
-  ;\r
-  \r
-vfrStatementCheckBox :  \r
-  << UINT32 LineNum, KeyValue = 0; ResetFlags (); >>\r
-  IDCB:CheckBox                       << WriteOpByte (IDCB->getLine(), EFI_IFR_CHECKBOX_OP); >>\r
-  VarId     "=" vfrStructFieldName[1] ","\r
-  Prompt    "=" getStringId ","\r
-  Help      "=" getStringId ","\r
-  FF:Flags  "=" flagsField ( "\|" flagsField )*  "," << LineNum = FF->getLine(); >>\r
-  { \r
-    Key "=" KV:Number  ","           << LineNum = KV->getLine(); KeyValue = GetNumber(KV->getText(), LineNum, 2); >>\r
-  }\r
-                                     << WriteFlagsKey (KeyValue, LineNum); >>\r
-  EndCheckBox ";"\r
-  ;\r
-     \r
-vfrStatementSubTitle :\r
-  IDS:Subtitle Text "="               << WriteOpByte (IDS->getLine(), EFI_IFR_SUBTITLE_OP); >>\r
-  getStringId                         // writes string indentifier\r
-  ";"\r
-  ;\r
-\r
-//*****************************************************************************\r
-//\r
-// PARSE:\r
-//    banner \r
-//      title = STRING_TOKEN(STR_BANNER_TITLE),\r
-//      line  1,\r
-//      align center;     // or left or right\r
-//\r
-//    banner, \r
-//      title = STRING_TOKEN(STR_BANNER_TITLE), timeout = 100;\r
-//\r
-vfrStatementBanner :\r
-  IDB:Banner { "," }                    << WriteOpByte (IDB->getLine(), EFI_IFR_BANNER_OP); >>\r
-  Title "=" getStringId ","\r
-  ( \r
-    Line VAL:Number ","                 << WriteWord (GetNumber(VAL->getText(), VAL->getLine(), 2)); >>\r
-    Align \r
-    ( Left                              << WriteByte (EFI_IFR_BANNER_ALIGN_LEFT, 0); >>\r
-    | Center                            << WriteByte (EFI_IFR_BANNER_ALIGN_CENTER, 0); >>\r
-    | Right                             << WriteByte (EFI_IFR_BANNER_ALIGN_RIGHT, 0); >>\r
-    ) ";"\r
-  |\r
-    Timeout "=" TO:Number ";"           << WriteWord (GetNumber(TO->getText(), TO->getLine(), 2)); >>\r
-                                        << WriteByte (EFI_IFR_BANNER_TIMEOUT, 0); >>\r
-  )\r
-  ;\r
-\r
-//*****************************************************************************\r
-//\r
-// PARSE:\r
-//   oneof  varid       = MyNv.OneOfData,\r
-//          prompt      = STRING_TOKEN(STR_ONE_OF_PROMPT),\r
-//          help        = STRING_TOKEN(STR_ONE_OF_HELP),\r
-//          option text = STRING_TOKEN(STR_ONE_OF_TEXT), \r
-//          value       = 0, \r
-//          flags       = DEFAULT | INTERACTIVE;\r
-//\r
-// supressif/grayoutif are supported inside oneof stmt.\r
-// We do not restrict the number of oneOfOptionText to >=2, but >=1.\r
-// The situation that all oneOfOptionText are suppressed is also possiable.\r
-//\r
-vfrStatementOneOf :\r
-  << ResetFlags (); >>\r
-  IDOO:OneOf                              << WriteOpByte (IDOO->getLine(), EFI_IFR_ONE_OF_OP); >>\r
-  VarId   "=" vfrStructFieldName[2] ","       \r
-  Prompt  "=" getStringId  ","           // writes string identifier\r
-  Help    "=" getStringId  ","           // writes string identifier\r
-  ( oneOfOptionText )+                   // there must be at least 1 option to be choosed, not 2.\r
-  IDEOO:EndOneOf   ";"                    << TestOneOfFlags (IDEOO->getLine()); WriteOpByte (IDEOO->getLine(), EFI_IFR_END_ONE_OF_OP); >>\r
-  ;\r
-\r
-//*****************************************************************************\r
-//\r
-// PARSE:\r
-//  \r
-//   orderedlist  varid       = MyNv.OrderedListData,\r
-//                prompt      = STRING_TOKEN(STR_ORDERED_LIST_PROMPT),\r
-//                help        = STRING_TOKEN(STR_ORDERED_LIST_HELP),  \r
-//                option text = STRING_TOKEN(STR_ORDERED_LIST_TEXT), value = 0, flags = INTERACTIVE;\r
-//                -- additional option text -- \r
-//   endlist;\r
-//\r
-vfrStatementOrderedList :\r
-  << ResetFlags (); InitOrderedList(); >>\r
-  IDOL:OrderedList                       << WriteOpByte (IDOL->getLine(), EFI_IFR_ORDERED_LIST_OP); >>\r
-  VarId   "=" vfrStructFieldNameArray[1] ","       \r
-  Prompt  "=" getStringId  ","           // writes string identifier\r
-  Help    "=" getStringId  ","           // writes string identifier\r
-  orderedListOptionText ( orderedListOptionText )+\r
-  IDEOL:EndList   ";"                    << WriteOpByte (IDEOL->getLine(), EFI_IFR_END_OP); EndOrderedList(IDEOL->getLine()); >>\r
-  ;\r
-\r
-//*****************************************************************************\r
-//\r
-// PARSE:\r
-//\r
-//   option text = STRING_TOKEN(STRING_ID), value = 0 flags = 99;\r
-//\r
-// Differs from the oneOfOptionText in that we don't allow the DEFAULT flag to\r
-// be set, and value cannot be 0.\r
-//\r
-orderedListOptionText :\r
-  << UINT32 KeyValue = 0; >>\r
-  IDO:Option                          << WriteOpByte (IDO->getLine(), EFI_IFR_ONE_OF_OPTION_OP); >>\r
-  Text      "=" getStringId ","       // writes string identifier\r
-  Value     "=" WVAL:Number ","       << \r
-                                          if (GetNumber(WVAL->getText(), WVAL->getLine(), 2) == 0) {\r
-                                            PrintErrorMessage (WVAL->getLine(), "value=0 is invalid for ordered lists", NULL); \r
-                                          } else {\r
-                                            WriteWord (GetNumber(WVAL->getText(), WVAL->getLine(), 2)); \r
-                                          }\r
-                                      >>\r
-  FF:Flags  "=" orderedListFlagsField  \r
-                ("\|" orderedListFlagsField )*                   \r
-  { \r
-    "," Key "=" KV:Number             << KeyValue = GetNumber (KV->getText(), KV->getLine(), 2); >> \r
-  }\r
-                                      << WriteFlagsKey (KeyValue, FF->getLine()); >>\r
-  ";"                                 << mOptionCount++; >>\r
-  ;\r
-\r
-//*****************************************************************************\r
-//\r
-// PARSE:\r
-//\r
-//   flags = 0x10 | DEFAULT | MANUFACTURING | INTERACTIVE | NV_ACCESS | RESET_REQUIRED | LATE_CHECK\r
-//\r
-// The ordered list flags field cannot have a default.\r
-//\r
-orderedListFlagsField :\r
-  VAL:Number                          << SetFlags (GetNumber(VAL->getText(), VAL->getLine(), 4), VAL->getLine()); >>\r
-  | IF:InteractiveFlag                << SetFlags (EFI_IFR_FLAG_INTERACTIVE, IF->getLine());    >>\r
-  | MF:ManufacturingFlag              << SetFlags (EFI_IFR_FLAG_MANUFACTURING, MF->getLine());  >>\r
-  | NV:NVAccessFlag                   << SetFlags (EFI_IFR_FLAG_NV_ACCESS, NV->getLine());      >>\r
-  | RR:ResetRequiredFlag              << SetFlags (EFI_IFR_FLAG_RESET_REQUIRED, RR->getLine()); >>\r
-  | LC:LateCheckFlag                  << SetFlags (EFI_IFR_FLAG_LATE_CHECK, LC->getLine());     >>\r
-  | DF:DefaultFlag                    << PrintWarningMessage (DF->getLine(), "DEFAULT flag not valid for ordered lists", NULL); >>\r
-  ;\r
-\r
-//\r
-// Parse references to VFR structure field names of form "MyNvStructure.Field". \r
-// This implementation is specific to strings, passwords, and references in an \r
-// ordered list statement because we want to specify the size of the entire \r
-// field, rather than just one element. Then call a function to write out its \r
-// offset and length.\r
-//\r
-vfrStructFieldNameArray[int FieldWidth] :\r
-  << int ArrayIndex = 1; char IsArrayIndex = 0; >>\r
-  SName:StringIdentifier \r
-  "." \r
-  SFieldName:StringIdentifier \r
-  { OpenBracket AIndex:Number CloseBracket << ArrayIndex = GetNumber(AIndex->getText(), AIndex->getLine(), 4); IsArrayIndex = 1; >> }\r
-            << \r
-                WriteFieldOffset (1, \r
-                                  SName->getText(), \r
-                                  SName->getLine(), \r
-                                  SFieldName->getText(), \r
-                                  SFieldName->getLine(),\r
-                                  ArrayIndex, \r
-                                  IsArrayIndex,\r
-                                  FieldWidth,\r
-                                  1\r
-                                  ); \r
-            >>\r
-  ;\r
-\r
-//\r
-// Parse references to VFR structure field names of form "MyNvStructure.Field",\r
-// then call a function to write out its offset and length.\r
-//\r
-vfrStructFieldName[int FieldWidth] :\r
-  << int ArrayIndex = 1; char IsArrayIndex = 0; >>\r
-  SName:StringIdentifier \r
-  "." \r
-  SFieldName:StringIdentifier \r
-  { OpenBracket AIndex:Number CloseBracket << ArrayIndex = GetNumber(AIndex->getText(), AIndex->getLine(), 4); IsArrayIndex = 1; >> }\r
-            << \r
-                WriteFieldOffset (1, \r
-                                  SName->getText(), \r
-                                  SName->getLine(), \r
-                                  SFieldName->getText(), \r
-                                  SFieldName->getLine(),\r
-                                  ArrayIndex, \r
-                                  IsArrayIndex,\r
-                                  FieldWidth,\r
-                                  0\r
-                                  ); \r
-            >>\r
-  ;\r
-\r
-//*****************************************************************************\r
-//\r
-// PARSE:\r
-//\r
-//   MyNvStructure.FieldName[4]\r
-//\r
-// Parse references to VFR structure field names of form "MyNvStructure.Field",\r
-// then call a function to write out the offset with no length.\r
-//\r
-vfrStructFieldNameNL[int FieldWidth] :\r
-  << int ArrayIndex = 1; char IsArrayIndex = 0; >>\r
-  SName:StringIdentifier \r
-  "." \r
-  SFieldName:StringIdentifier \r
-  { OpenBracket AIndex:Number CloseBracket   << ArrayIndex = GetNumber(AIndex->getText(), AIndex->getLine(), 4); IsArrayIndex = 1; >> }\r
-            << \r
-                WriteFieldOffset (0, \r
-                                  SName->getText(), \r
-                                  SName->getLine(), \r
-                                  SFieldName->getText(), \r
-                                  SFieldName->getLine(),\r
-                                  ArrayIndex, \r
-                                  IsArrayIndex,\r
-                                  FieldWidth,\r
-                                  0\r
-                                  ); \r
-            >>\r
-  ;\r
-\r
-//*****************************************************************************\r
-//\r
-// PARSE:\r
-//   suppressif TRUE OR FALSE;\r
-//   grayoutif FALSE OR TRUE;\r
-//     option text = STRING_TOKEN(STRING_ID), value = 0 flags = 99;\r
-//     option text = STRING_TOKEN(STRING_ID2), value = 1 flags = 98;\r
-//   endif;\r
-//\r
-oneOfOptionText :\r
-  suppressIfOptionText    |\r
-  grayOutIfOptionText     |\r
-  commonOptionText\r
-  ;\r
-\r
-suppressIfOptionText : \r
-  << ResetFlags (); >>\r
-  OPID:SuppressIf                     << WriteOpByte (OPID->getLine(), EFI_IFR_SUPPRESS_IF_OP); SetIfStart (OPID->getLine()); >>\r
-  { \r
-    FF:Flags  "=" flagsField ( "\|" flagsField )* ","\r
-  }\r
-  << WriteFlags (); >> //  write the flags field \r
-  vfrBooleanExpression\r
-  ";"\r
-  { suppressIfGrayOutIf } ( commonOptionText )+\r
-  ENDOP:EndIf ";"                     << WriteOpByte (ENDOP->getLine(), EFI_IFR_END_IF_OP); SetIfStart (0); >>\r
-  ;\r
-\r
-grayOutIfOptionText :\r
-  << ResetFlags (); >>\r
-  OPID:GrayOutIf                      << WriteOpByte (OPID->getLine(), EFI_IFR_GRAYOUT_IF_OP); SetIfStart (OPID->getLine()); >>\r
-  { \r
-    FF:Flags  "=" flagsField ( "\|" flagsField )* "," \r
-  }\r
-  << WriteFlags (); >> //  write the flags field\r
-  vfrBooleanExpression\r
-  ";"\r
-  { grayoutIfSuppressIf } ( commonOptionText )+ \r
-  ENDOP:EndIf ";"                     << WriteOpByte (ENDOP->getLine(), EFI_IFR_END_IF_OP); SetIfStart (0); >>\r
-  ;\r
-\r
-commonOptionText : \r
-  << UINT32 KeyValue = 0; >>\r
-  IDO:Option                      << WriteOpByte (IDO->getLine(), EFI_IFR_ONE_OF_OPTION_OP); >>\r
-  Text      "=" getStringId ","   // writes string identifier\r
-  Value     "=" WVal:Number ","   << WriteWord (GetNumber(WVal->getText(), WVal->getLine(), 2)); >>\r
-  FF:Flags  "=" flagsField  ("\|" flagsField )*                   \r
-  { \r
-    "," Key "=" KV:Number         << KeyValue = GetNumber (KV->getText(), KV->getLine(), 2); >> \r
-  }\r
-                                  << WriteFlagsKey (KeyValue, FF->getLine()); >>\r
-  ";"                             << mOptionCount++; >>\r
-  ;\r
-\r
-//\r
-// Gets a string identifier. It must be a numeric value of form:\r
-// \r
-//   STRING_TOKEN(100)\r
-//\r
-getStringId :\r
-  << unsigned short StrId; >>\r
-  StringToken OpenParen\r
-  IdVal:Number             << StrId = GetNumber (IdVal->getText(), IdVal->getLine(), 2); WriteStringIdWord (StrId); >> \r
-  CloseParen\r
-  ;\r
-\r
-//******************************************************************************\r
-//\r
-// Parser class definition. \r
-//  \r
-class EfiVfrParser {\r
-<<\r
-//\r
-// Parser definitions go here    \r
-//\r
-private:\r
-  STRUCT_DEFINITION   *mFirstStructDefinition;\r
-  STRUCT_DEFINITION   *mLastStructDefinition;\r
-  INT32               mNvDataStructSize;                    \r
-  INT32               mNonNvDataStructSize;\r
-  //\r
-  // Flag to indicate that we're processing a ideqid VFR statement so that\r
-  // we can do late checks on the statement.\r
-  //\r
-  INT32               mIdEqIdStmt;\r
-  INT32               mLastNVVariableDataSize;\r
-  GOTO_REFERENCE      *mGotoReferences;\r
-  FORM_ID_VALUE       *mFormIdValues;\r
-  VfrOpcodeHandler    mOpcodeHandler;\r
-  UINT16_LIST         *mUint16List;\r
-  UINT16_LIST         *mLastUint16;\r
-  UINT16_LIST         *mDefinedLabels;\r
-  UINT16_LIST         *mDefinedVarStoreId;\r
-  UINT16_LIST         *mLastDefinedVarStoreId;\r
-  UINT32              mMinimumValue, mMaximumValue, mStepValue, mDefaultValue;\r
-  UINT32              mStmtFlags;\r
-  UINT32              mSubStmtFlags;\r
-  UINT32              mSubStmtFlagsLineNum;\r
-  EFI_GUID            mFormSetGuid;\r
-  UINT8               mNvDataStructDefined;\r
-  UINT16              mClass, mSubclass;\r
-  UINT32              mIfStart;\r
-  UINT32              mOptionCount;  // how many "option" fields in a given statement\r
-  UINT32              mLastVarIdSize;\r
-  UINT8               mOutput;\r
-public:        \r
-\r
-VOID \r
-EfiVfrParser::SetIfStart (\r
-  UINT32 LineNum\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Invoked during VFR parsing when an "if" is encountered. Save the\r
-  source line number so we can point to it if we don't find a \r
-  corresponding endif later.\r
-\r
-Arguments:\r
-  LineNum - source line number where the "if" was parsed.\r
-\r
-Returns:\r
-  None\r
-\r
---*/\r
-{\r
-  mIfStart = LineNum;\r
-}\r
-VOID \r
-EfiVfrParser::SetClass (\r
-  UINT32 LineNum, \r
-  UINT32 Value\r
-  ) \r
-/*++\r
-\r
-Routine Description:\r
-  Invoked during VFR parsing when a "class" statement is found. Check the\r
-  range on the class value and save it for later.\r
-\r
-Arguments:\r
-  LineNum - source line number where the class statement was parsed.\r
-  Value   - the class value\r
-\r
-Returns:\r
-  None\r
-\r
---*/\r
-{\r
-  if (Value & 0xFFFF0000) {\r
-    PrintWarningMessage (LineNum, NULL, "class value exceeds maximum allowed");\r
-  }\r
-  mClass |= (UINT16)Value;\r
-}\r
-VOID \r
-EfiVfrParser::SetSubclass (\r
-  UINT32 LineNum, \r
-  UINT32 Value\r
-  ) \r
-/*++\r
-\r
-Routine Description:\r
-  Invoked during VFR parsing when a subclass statement is found. Check the\r
-  range on the value and save it for later.\r
-\r
-Arguments:\r
-  LineNum - source line number where the class statement was parsed.\r
-  Value   - the subclass value from the VFR statement\r
-\r
-Returns:\r
-  None\r
-\r
---*/\r
-{\r
-  if (Value & 0xFFFF0000) {\r
-    PrintWarningMessage (LineNum, NULL, "subclass value exceeds maximum allowed");\r
-  }\r
-  mSubclass |= (UINT16)Value;\r
-}\r
-VOID EfiVfrParser::WriteClass ()\r
-{\r
-  WriteWord (mClass);\r
-  mClass = 0;\r
-}\r
-VOID EfiVfrParser::WriteSubclass ()\r
-{\r
-  WriteWord (mSubclass);\r
-  mSubclass = 0;\r
-}\r
-VOID EfiVfrParser::WriteIfrBytes ()\r
-{\r
-  mOpcodeHandler.WriteIfrBytes ();\r
-}\r
-VOID \r
-EfiVfrParser::WriteFlagsKey (\r
-  UINT32 KeyValue, \r
-  UINT32 LineNum\r
-  ) \r
-/*++\r
-\r
-Routine Description:\r
-  Write out the flags and key values from the previous VFR statement.\r
-  Many statements take a flags/key pair. If not specified, then 0\r
-  values are written out. However do not allow an interactive flags field\r
-  to be specified if no key value is specified. Also, if NV_ACCESS flag\r
-  is set but INTERACTIVE is not, then set interactive and issue a warning.\r
-\r
-Arguments:\r
-  KeyValue  - the key value from the VFR statement\r
-  LineNum   - source line number where the statement was parsed\r
-\r
-Returns:\r
-  None\r
-\r
---*/\r
-{\r
-  if ((mSubStmtFlags & EFI_IFR_FLAG_INTERACTIVE) && (KeyValue == 0)) {\r
-    PrintErrorMessage (LineNum, NULL, "invalid or missing key value - required with INTERACTIVE");\r
-  }\r
-  if ((mSubStmtFlags & EFI_IFR_FLAG_NV_ACCESS) && !(mSubStmtFlags & EFI_IFR_FLAG_INTERACTIVE)) {\r
-    PrintWarningMessage (LineNum, NULL, "NV_ACCESS without INTERACTIVE has no effect -- setting INTERACTIVE");\r
-    mSubStmtFlags |= EFI_IFR_FLAG_INTERACTIVE;\r
-  }\r
-  WriteFlags ();\r
-  WriteWord (KeyValue);\r
-}\r
-VOID \r
-EfiVfrParser::InitOrderedList ()\r
-{\r
-  mOptionCount = 0;\r
-}  \r
-VOID \r
-EfiVfrParser::EndOrderedList (\r
-  UINT32 LineNum\r
-  )\r
-{\r
-  if (mLastVarIdSize < mOptionCount) {\r
-    PrintErrorMessage (LineNum, NULL, "number of options exceeds the variable store size");\r
-  }\r
-}\r
-VOID \r
-EfiVfrParser::ResetFlags ()\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Flags are set for each substatement in a given one-of statement.\r
-  To make sure there are no conflicts, for example setting DEFAULT on\r
-  more than one substatement, we keep track of the flags at a statement\r
-  level and a substatement level. This function resets the flags so \r
-  we get a fresh start.\r
-\r
-Arguments:\r
-  None\r
-\r
-Returns:\r
-  None\r
-\r
---*/\r
-{\r
-  mStmtFlags = 0;\r
-  mSubStmtFlagsLineNum = 0;\r
-  mSubStmtFlags = 0;\r
-}\r
-//\r
-// Test validity of flags value for a one-of statement.\r
-//\r
-VOID \r
-EfiVfrParser::TestOneOfFlags (\r
-  UINT32 LineNum\r
-  ) \r
-{\r
-  //\r
-  // One of the fields must have had the default bit set\r
-  //\r
-  if ((mStmtFlags & EFI_IFR_FLAG_DEFAULT) == 0) {\r
-    PrintWarningMessage (LineNum, "default value must be specified", NULL);\r
-  }\r
-}\r
-VOID \r
-EfiVfrParser::SetFlags (\r
-  UINT32 Flags, \r
-  UINT32 LineNum\r
-  ) \r
-{\r
-  //\r
-  // Check for redefinitions and invalid combinations\r
-  //\r
-  if (mStmtFlags & Flags & EFI_IFR_FLAG_MANUFACTURING) {\r
-    PrintErrorMessage (LineNum, "MANUFACTURING", "a field with this flag already defined");\r
-  }\r
-  if (mStmtFlags & Flags & EFI_IFR_FLAG_DEFAULT) {\r
-    PrintErrorMessage (LineNum, "DEFAULT", "a field with this flag already defined");\r
-  }\r
-  mSubStmtFlags |= Flags;\r
-  mSubStmtFlagsLineNum = LineNum;\r
-}\r
-VOID \r
-EfiVfrParser::WriteFlags ()\r
-{\r
-  //\r
-  // Check value for validity\r
-  //\r
-  if (mSubStmtFlags & ~(EFI_IFR_FLAG_DEFAULT | \r
-                        EFI_IFR_FLAG_MANUFACTURING | \r
-                        EFI_IFR_FLAG_INTERACTIVE | \r
-                        EFI_IFR_FLAG_NV_ACCESS | \r
-                        EFI_IFR_FLAG_RESET_REQUIRED | \r
-                        EFI_IFR_FLAG_LATE_CHECK )) {\r
-    PrintWarningMessage (mSubStmtFlagsLineNum, "invalid bits defined in flag", NULL);\r
-  }\r
-  WriteByte ((UINT8)mSubStmtFlags, 'F');\r
-  //\r
-  // We can now clear the substatement flags\r
-  //\r
-  mStmtFlags |= mSubStmtFlags;\r
-  mSubStmtFlags = 0;\r
-}\r
-//\r
-// When we parse a min/max/step/default sequence, save off the values for\r
-// later use. Call this first to init the values.\r
-//\r
-VOID \r
-EfiVfrParser::InitMinMaxStepDefault ()\r
-{\r
-  mMinimumValue         = 0;\r
-  mMaximumValue         = 0;\r
-  mStepValue            = 1;\r
-  mDefaultValue         = 0;\r
-}  \r
-VOID \r
-EfiVfrParser::WriteMinMaxStepDefault ()\r
-{\r
-  WriteWord (mMinimumValue);\r
-  WriteWord (mMaximumValue);\r
-  WriteWord (mStepValue);\r
-  WriteWord (mDefaultValue);\r
-}  \r
-VOID \r
-EfiVfrParser::SetMinMaxStepDefault (\r
-  UINT16  Value, \r
-  INT32   MMSD, \r
-  INT32   LineNum\r
-  ) \r
-{\r
-  UINT16 TempValue;\r
-  //\r
-  // Min specified\r
-  //\r
-  if (MMSD == 0) {\r
-    mMinimumValue = Value;\r
-    mDefaultValue = Value;\r
-  //\r
-  // Max specified\r
-  //\r
-  } else if (MMSD == 1) {\r
-    mMaximumValue = Value;\r
-    //\r
-    // If min > max, then swap the values. That includes resetting the default\r
-    // value as well.\r
-    //\r
-    if (mMinimumValue > mMaximumValue) {\r
-      PrintWarningMessage (LineNum, NULL, "maximum < minimum");      \r
-      TempValue = Value;\r
-      mMaximumValue = mMinimumValue;\r
-      mMinimumValue = TempValue;\r
-      mDefaultValue = mMinimumValue;\r
-    }\r
-  //\r
-  // Step specified\r
-  //\r
-  } else if (MMSD == 2) { \r
-    mStepValue = Value;\r
-  //\r
-  // Default specified. Make sure min <= default <= max.\r
-  //\r
-  } else if (MMSD == 3) {\r
-    mDefaultValue = Value;\r
-    if (mMinimumValue > Value) {\r
-      PrintErrorMessage (LineNum, NULL, "default value < minimum value");\r
-    } else if (Value > mMaximumValue) {\r
-      PrintErrorMessage (LineNum, NULL, "default value > maximum value");\r
-    }\r
-  } else {\r
-    PrintErrorMessage (LineNum, "application error", "internal MMSD error");    \r
-  }\r
-}\r
-VOID \r
-EfiVfrParser::AddLabel (\r
-  UINT32 LabelNumber, \r
-  UINT32 LineNum\r
-  ) \r
-{\r
-  UINT16_LIST *Label;\r
-\r
-  //\r
-  // Added a label from the user VFR script. Make sure they haven't already \r
-  // defined the same label elsewhere\r
-  //\r
-  for (Label = mDefinedLabels; Label != NULL; Label = Label->Next) {\r
-    if (Label->Value == LabelNumber) {\r
-      PrintErrorMessage (LineNum, NULL, "label already defined");\r
-      PrintErrorMessage (Label->LineNum, NULL, "previous definition of redefined label");\r
-      break;\r
-    }\r
-  }\r
-  Label = (UINT16_LIST *)malloc (sizeof (UINT16_LIST));\r
-  if (Label == NULL) {\r
-    PrintErrorMessage (0, NULL, "memory allocation error");\r
-    return;\r
-  }\r
-  memset ((char *)Label, 0, sizeof (UINT16_LIST));\r
-  Label->Value = LabelNumber;\r
-  Label->LineNum = LineNum;\r
-  Label->Next = mDefinedLabels;\r
-  mDefinedLabels = Label;\r
-}\r
-VOID \r
-EfiVfrParser::QueueIdEqValList (\r
-  UINT16 Value\r
-  )\r
-{\r
-  UINT16_LIST   *U16;\r
-  \r
-  U16 = (UINT16_LIST *)malloc (sizeof (UINT16_LIST));\r
-  if (U16 == NULL) {\r
-    Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failed");\r
-  } else {\r
-    memset ((char *)U16, 0, sizeof (UINT16_LIST));\r
-    U16->Value = Value;\r
-    if (mUint16List == NULL) {\r
-      mUint16List = U16;\r
-    } else {\r
-      mLastUint16->Next = U16;\r
-    } \r
-    mLastUint16 = U16;\r
-  }\r
-}    \r
-VOID \r
-EfiVfrParser::FlushQueueIdEqValList ()\r
-{\r
-  UINT32 Count;\r
-  \r
-  //\r
-  // We queued up a list of IdEqValList items. The IFR requires a count\r
-  // followed by the actual values. Do it.\r
-  //\r
-  Count = 0;\r
-  mLastUint16 = mUint16List;\r
-  while (mLastUint16 != NULL) {\r
-    Count++;\r
-    mLastUint16 = mLastUint16->Next;\r
-  }\r
-  // BUGBUG -- check for more than 16K items?\r
-  WriteWord (Count);\r
-  //\r
-  // Now write the values.\r
-  //\r
-  mLastUint16 = mUint16List;\r
-  while (mLastUint16 != NULL) {\r
-    WriteWord ((UINT32)mLastUint16->Value);\r
-    mLastUint16 = mLastUint16->Next;\r
-  }\r
-  //\r
-  // Free up the list\r
-  //  \r
-  mLastUint16 = mUint16List;\r
-  while (mUint16List != NULL) {\r
-    mLastUint16 = mUint16List->Next;\r
-    free (mUint16List);\r
-    mUint16List = mLastUint16;\r
-  }\r
-}\r
-VOID \r
-EfiVfrParser::PrintErrorMessage (\r
-  UINT32              LineNum,\r
-  CHAR8               *Msg1,\r
-  CHAR8               *Msg2\r
-  )\r
-{\r
-  char *FileName;\r
-  \r
-  if (LineNum != 0) {\r
-    FileName = ConvertLineNumber ((UINT32 *)&LineNum);\r
-    Error (FileName, LineNum, 0, Msg1, Msg2);\r
-  } else {\r
-    Error (PROGRAM_NAME, 0, 0, Msg1, Msg2);\r
-  }\r
-}\r
-VOID \r
-EfiVfrParser::PrintWarningMessage (\r
-  UINT32              LineNum,\r
-  CHAR8               *Msg1,\r
-  CHAR8               *Msg2\r
-  )\r
-{\r
-  char *FileName;\r
-  \r
-  if (LineNum != 0) {\r
-    FileName = ConvertLineNumber ((UINT32 *)&LineNum);\r
-    Warning (FileName, LineNum, 0, Msg1, Msg2);\r
-  } else {\r
-    Warning (PROGRAM_NAME, 0, 0, Msg1, Msg2);\r
-  }\r
-}\r
-VOID \r
-EfiVfrParser::syn (\r
-  ANTLRAbstractToken  *Tok, \r
-  ANTLRChar           *Egroup, \r
-  SetWordType         *Eset, \r
-  ANTLRTokenType      ETok, \r
-  INT32               Huh\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Called by the parser base class as a result of parse syntax errors.\r
-\r
-Arguments:\r
-  Tok     - token that caused the error\r
-  Egroup  - not sure\r
-  Eset    - index in token table of the expected token\r
-  Huh     - not sure\r
-\r
-Returns:\r
-  NA\r
-\r
---*/\r
-{\r
-  char    *FileName;\r
-  UINT32  LineNum;\r
-  \r
-  LineNum = Tok->getLine ();\r
-  FileName = ConvertLineNumber ((UINT32 *)&LineNum);\r
-  //\r
-  // Sometimes the token number is 0, in which case I don't know what to\r
-  // print.\r
-  //\r
-  if (ETok == 0) {\r
-    Error (FileName, LineNum, 0, Tok->getText (), "unexpected token");\r
-  } else {\r
-    //\r
-    // If we were expecting an endif, then report the line where the corresponding\r
-    // IF began.\r
-    //\r
-    if ((strcmp (_token_tbl[ETok], "endif") == 0) && (mIfStart != 0)) {\r
-      LineNum = mIfStart;\r
-      FileName = ConvertLineNumber (&LineNum);\r
-      Error (FileName, LineNum, 0, "statement missing corresponding endif", NULL);\r
-    } else {\r
-      Error (FileName, LineNum, 0, Tok->getText (), "expected %s", _token_tbl[ETok]);\r
-    }\r
-  }\r
-}\r
-\r
-VOID \r
-EfiVfrParser::init()        \r
-/*++\r
-\r
-Routine Description:\r
-  Initializations function for our parser.\r
-\r
-Arguments:\r
-  None.\r
-\r
-Returns:\r
-  None.\r
-\r
---*/\r
-{\r
-  ANTLRParser::init();\r
-\r
-  //\r
-  // Used for queuing a variable list of UINT16's\r
-  //\r
-  mUint16List               = NULL;\r
-  mLastUint16               = NULL;\r
-  mFirstStructDefinition    = NULL;\r
-  mLastStructDefinition     = NULL;\r
-  mNvDataStructSize         = 0;\r
-  mNonNvDataStructSize      = 0;\r
-  mNvDataStructDefined      = 0;\r
-  mGotoReferences           = NULL;\r
-  mFormIdValues             = NULL;\r
-  mDefinedLabels            = NULL;\r
-  mClass                    = 0;\r
-  mSubclass                 = 0;\r
-  mIfStart                  = 0;\r
-  mDefinedVarStoreId        = NULL;\r
-  mLastDefinedVarStoreId    = NULL;\r
-  mIdEqIdStmt               = 0;\r
-  mLastNVVariableDataSize   = 0;\r
-    \r
-  memset ((char *)&mFormSetGuid, 0, sizeof (EFI_GUID));\r
-}\r
-//\r
-// Destructor for the parser.\r
-//\r
-EfiVfrParser::~EfiVfrParser(VOID)\r
-{\r
-  Cleanup();\r
-}\r
-VOID\r
-EfiVfrParser::Cleanup (VOID)\r
-/*++\r
-\r
-Routine Description:\r
-  Free memory allocated during parsing\r
-\r
-Arguments:\r
-  None.\r
-\r
-Returns:\r
-  None.\r
-\r
---*/\r
-{\r
-  STRUCT_DEFINITION         *NextStruct;\r
-  STRUCT_FIELD_DEFINITION   *NextField;\r
-  UINT8                     Buff[6];\r
-  UINT16_LIST               *NextU16List;\r
-  \r
-  //\r
-  // Free up the structure definitions if any\r
-  //\r
-  while (mFirstStructDefinition != NULL) {\r
-    //\r
-    // Free up all the fields for this struct\r
-    //\r
-    while (mFirstStructDefinition->Field != NULL) {\r
-      NextField = mFirstStructDefinition->Field->Next;\r
-      free (mFirstStructDefinition->Field->Name);\r
-      free (mFirstStructDefinition->Field);\r
-      mFirstStructDefinition->Field = NextField;\r
-    }\r
-    NextStruct = mFirstStructDefinition->Next;\r
-    free (mFirstStructDefinition->Name);\r
-    free (mFirstStructDefinition);\r
-    mFirstStructDefinition = NextStruct;\r
-  }\r
-  //\r
-  // Free up the goto references and form id defines\r
-  //\r
-  FreeGotoReferences ();\r
-  //\r
-  // Free up label list\r
-  //\r
-  while (mDefinedLabels != NULL) {\r
-    NextU16List = mDefinedLabels->Next;\r
-    delete (mDefinedLabels);\r
-    mDefinedLabels = NextU16List;\r
-  }\r
-  //\r
-  // Free up the list of defined variable storage IDs\r
-  //\r
-  while (mDefinedVarStoreId != NULL) {\r
-    NextU16List = mDefinedVarStoreId->Next;\r
-    delete (mDefinedVarStoreId);\r
-    mDefinedVarStoreId = NextU16List;\r
-  }\r
-}\r
-\r
-INT32 \r
-EfiVfrParser::AtoX (\r
-  CHAR8   *HexString, \r
-  INT32   NumBytes, \r
-  UINT32  *HexValue\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Given a pointer to a ascii hex string, convert to a number with the given\r
-  number of bytes.\r
-\r
-Arguments:\r
-  HexString   - pointer to a string of format 30BCA\r
-  Size        - number of bytes to convert\r
-  HexValue    - return result\r
-\r
-Returns:\r
-  The number of bytes converted.\r
-\r
---*/\r
-{\r
-  INT32 Count;\r
-  INT32 Value;\r
-\r
-  *HexValue = 0;\r
-  Count = 0;\r
-  while (Count < NumBytes) {\r
-    if ((*HexString >= '0') && (*HexString <= '9')) {\r
-      Value = *HexString - '0';\r
-    } else if ((*HexString >= 'a') && (*HexString <= 'f')) {\r
-      Value = *HexString - 'a' + 10;\r
-    } else if ((*HexString >= 'A') && (*HexString <= 'F')) {\r
-      Value = *HexString - 'A' + 10;\r
-    } else {\r
-      return Count;\r
-    }\r
-    HexString++;\r
-    *HexValue = (*HexValue << 4) | Value;\r
-    if ((*HexString >= '0') && (*HexString <= '9')) {\r
-      Value = *HexString - '0';\r
-    } else if ((*HexString >= 'a') && (*HexString <= 'f')) {\r
-      Value = *HexString - 'a' + 10;\r
-    } else if ((*HexString >= 'A') && (*HexString <= 'F')) {\r
-      Value = *HexString - 'A' + 10;\r
-    } else {\r
-      return Count;\r
-    }\r
-    *HexValue = (*HexValue << 4) | Value;\r
-    HexString++;\r
-    Count++;\r
-  }\r
-  return Count;\r
-}\r
-VOID \r
-EfiVfrParser::WriteGuidValue (\r
-  UINT32       TokenLineNum,\r
-  CHAR8        *G1, \r
-  CHAR8        *G2,\r
-  CHAR8        *G3,\r
-  CHAR8        *G4,\r
-  CHAR8        *G5,\r
-  CHAR8        *G6,\r
-  CHAR8        *G7,\r
-  CHAR8        *G8,\r
-  CHAR8        *G9,\r
-  CHAR8        *G10,\r
-  CHAR8        *G11\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  A Guid was parsed, likely of format:\r
-  #define MY_GUID { 0x12345678, 0xAABB, 0xCCDD, 0xEE, 0xFF, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66 }\r
-\r
-  Write out the value.\r
-\r
-Arguments:\r
-  TokenLineNum   - line number where the guid was used\r
-  G1-G11         - the 11 fields of the guid value\r
-\r
-Returns:\r
-  None.\r
-\r
---*/\r
-{\r
-  UINT32        Value;\r
-  INT32         Loop;\r
-\r
-  mFormSetGuid.Data1 = GetNumber (G1, TokenLineNum, 4);\r
-  mFormSetGuid.Data2 = (UINT16)GetNumber (G2, TokenLineNum, 2);\r
-  mFormSetGuid.Data3 = (UINT16)GetNumber (G3, TokenLineNum, 2);\r
-  mFormSetGuid.Data4[0] = (UINT8)GetNumber (G4, TokenLineNum, 1);\r
-  mFormSetGuid.Data4[1] = (UINT8)GetNumber (G5, TokenLineNum, 1);\r
-  mFormSetGuid.Data4[2] = (UINT8)GetNumber (G6, TokenLineNum, 1);\r
-  mFormSetGuid.Data4[3] = (UINT8)GetNumber (G7, TokenLineNum, 1);\r
-  mFormSetGuid.Data4[4] = (UINT8)GetNumber (G8, TokenLineNum, 1);\r
-  mFormSetGuid.Data4[5] = (UINT8)GetNumber (G9, TokenLineNum, 1);\r
-  mFormSetGuid.Data4[6] = (UINT8)GetNumber (G10, TokenLineNum, 1);\r
-  mFormSetGuid.Data4[7] = (UINT8)GetNumber (G11, TokenLineNum, 1);\r
-  \r
-  WriteDWord (mFormSetGuid.Data1, 'G');\r
-  WriteWord (mFormSetGuid.Data2);\r
-  WriteWord (mFormSetGuid.Data3);\r
-  WriteByte (mFormSetGuid.Data4[0], 0);\r
-  WriteByte (mFormSetGuid.Data4[1], 0);\r
-  WriteByte (mFormSetGuid.Data4[2], 0);\r
-  WriteByte (mFormSetGuid.Data4[3], 0);\r
-  WriteByte (mFormSetGuid.Data4[4], 0);\r
-  WriteByte (mFormSetGuid.Data4[5], 0);\r
-  WriteByte (mFormSetGuid.Data4[6], 0);\r
-  WriteByte (mFormSetGuid.Data4[7], 0);\r
-}\r
-VOID \r
-EfiVfrParser::WriteFieldOffset (\r
-  INT8    WriteLength,\r
-  CHAR8   *StructName, \r
-  INT32   LineNum1, \r
-  CHAR8   *FieldName, \r
-  INT32   LineNum2,\r
-  INT32   ArrayIndex,\r
-  INT8    IsArrayIndex,\r
-  INT32   FieldWidth,\r
-  INT8    WriteArraySize\r
-  ) \r
-/*++\r
-\r
-Routine Description:\r
-  A VFR script referenced the NV store structure. Given the structure's name\r
-  and the field's name, write the offset of the field to the output file.\r
-\r
-Arguments:\r
-  WriteLength     - write the field length byte out\r
-  StructName      - name of the NV store structure\r
-  LineNum1        - line number in the VFR where we are (for error printing)\r
-  FieldName       - the name of the field within the NV store structure\r
-  LineNum2        - line number in the VFR where FieldName is referenced \r
-  ArrayIndex      - the index specified, for example NV_DATA.Field[ArrayIndex]\r
-  IsArrayIndex    - non-zero if an array index was specified\r
-  FieldWidth      - expected size for the Field (1 byte? 2 bytes?)\r
-  WriteArraySize  - write the size of the entire field, not the size of a single element\r
-\r
-Returns:\r
-  None.\r
-\r
---*/\r
-{\r
-  STRUCT_DEFINITION         *StructDef;\r
-  STRUCT_FIELD_DEFINITION   *FieldDef;\r
-  UINT32                    Offset;\r
-  UINT32                    VarSize;\r
-  CHAR8                     Msg[100];\r
-  //\r
-  // If we're writing an array size, then they better have referenced the field without an\r
-  // index. \r
-  //\r
-  if (WriteArraySize && IsArrayIndex) {\r
-    sprintf (Msg, "array index specified where an array is required");\r
-    PrintErrorMessage (LineNum2, FieldName, Msg);\r
-    return;\r
-  }\r
-  //\r
-  // Look through our list of known structures for a match\r
-  //\r
-  for (StructDef = mFirstStructDefinition; StructDef != NULL; StructDef = StructDef->Next) {\r
-    //\r
-    // Check for matching structure name\r
-    //\r
-    if (strcmp (StructDef->Name, StructName) == 0) {\r
-      //\r
-      // Mark it as referenced (for debug purposes only). Check the\r
-      // flag that indicates that we have already found a varstore VFR\r
-      // statement for it.\r
-      //\r
-      StructDef->Referenced++;\r
-      if (StructDef->VarStoreIdValid == 0) {\r
-        //\r
-        // Set it valid so we don't flag it multiple times, then emit the error\r
-        //\r
-        StructDef->VarStoreIdValid = 1;\r
-        PrintErrorMessage (LineNum1, StructName, "varstore statement missing for this variable store");\r
-      }\r
-      //\r
-      // Let the opcode-handler know which variable storage we're now using\r
-      //\r
-      if (mIdEqIdStmt) {\r
-        mOpcodeHandler.SetSecondaryVarStoreId (StructDef->VarStoreId);\r
-      } else {\r
-        mOpcodeHandler.SetVarStoreId (StructDef->VarStoreId);\r
-      }\r
-      //\r
-      // Found matching structure name. Now find the matching field name\r
-      //\r
-      for (FieldDef = StructDef->Field; FieldDef != NULL; FieldDef = FieldDef->Next) {\r
-        if (strcmp (FieldDef->Name, FieldName) == 0) {\r
-          //\r
-          // Make sure the variable size is valid\r
-          //\r
-          if ((FieldWidth != 0) && (FieldDef->DataSize > FieldWidth)) {\r
-            sprintf (Msg, "field width exceeds %d byte%c", FieldWidth, FieldWidth == 1 ? ' ' : 's');\r
-            PrintErrorMessage (LineNum2, FieldName, Msg);\r
-          }\r
-          //\r
-          // If they specified an index (MyVfrData.FieldX[10]), then make sure that the\r
-          // data structure was declared as an array, and that the index is in bounds.\r
-          // If they did not specify an index, then we'll assume 0. This is required for\r
-          // strings.\r
-          //\r
-          if (IsArrayIndex) {\r
-            VarSize = FieldDef->DataSize;\r
-            if (FieldDef->IsArray == 0) {\r
-              PrintErrorMessage (LineNum2, FieldName, "field is not declared as an array");\r
-              return;\r
-            }\r
-            if (FieldDef->ArrayLength < ArrayIndex) {\r
-              PrintErrorMessage (LineNum2, FieldName, "array index exceeds declared size of field");\r
-              return;\r
-            }\r
-          } else {\r
-            if (FieldDef->IsArray) {\r
-              VarSize = FieldDef->DataSize * FieldDef->ArrayLength;\r
-            } else {\r
-              VarSize = FieldDef->DataSize;\r
-            }\r
-          }\r
-          //\r
-          // If we're in the middle of a ideqid VFR statement, then this is the second\r
-          // variable ID that we're now processing. Make sure that its size is the same\r
-          // as the first variable.\r
-          // \r
-          if (mIdEqIdStmt) {\r
-            if (mLastVarIdSize != VarSize) {\r
-              PrintErrorMessage (LineNum2, FieldName, "variables must have the same size");\r
-              return;\r
-            }\r
-          }\r
-          mLastVarIdSize = VarSize;\r
-          //\r
-          // If we're supposed to write an array size, then require it to be an array\r
-          //\r
-          if (WriteArraySize && !FieldDef->IsArray) {\r
-            PrintErrorMessage (LineNum2, FieldName, "array required");\r
-            return;\r
-          }\r
-          //\r
-          // Write the variable offset and size. If we're in the non-NV structure, then\r
-          // set the offset beyond the NV data structure size.\r
-          //\r
-          Offset = FieldDef->Offset + FieldDef->DataSize * (ArrayIndex - 1);\r
-          if (StructDef->IsNonNV) Offset += mNvDataStructSize; \r
-          WriteWord (Offset);\r
-          if (WriteLength) {\r
-            if (WriteArraySize) {\r
-              if (FieldDef->DataSize * FieldDef->ArrayLength > 255) {\r
-                PrintErrorMessage (LineNum2, FieldName, "array size exceeds 255 maximum encoding limit");\r
-                return;\r
-              }\r
-              WriteByte (FieldDef->DataSize * FieldDef->ArrayLength, 0);\r
-            } else {\r
-              WriteByte (FieldDef->DataSize, 0);\r
-            }\r
-          }\r
-          return;\r
-        }\r
-      }\r
-      sprintf (Msg, "structure %s does not have a field named '%s'", StructName, FieldName);\r
-      PrintErrorMessage (LineNum2, Msg, NULL);\r
-      PrintErrorMessage (StructDef->LineNum, "see structure definition", NULL);\r
-      return;\r
-    }\r
-  }\r
-  //\r
-  // The structure was not found in the defined list. See if it's the "Date" structure\r
-  //\r
-  if (strcmp (StructName, "Date") == 0) {\r
-    //\r
-    // BUGBUG -- remove support for Date and Time as valid structure \r
-    // names. They should use the NON_NV_DATA_MAP structure for this.\r
-    //\r
-    // Someone specified Date.Years|Months|Days\r
-    // BUGBUG -- define some constants for the IDs used here\r
-    // Length == 0 implies that this is not user NV data storage.\r
-    //\r
-    if (strcmp (FieldName, "Year") == 0) {\r
-      //\r
-      // Write ID (offset), ID, and size\r
-      //\r
-      WriteWord (mNvDataStructSize + mNonNvDataStructSize + 0);\r
-      if (WriteLength) {\r
-        WriteByte (0, 0);\r
-      }\r
-    } else if (strcmp (FieldName, "Month") == 0) {\r
-      //\r
-      // Write ID (offset), ID, and size\r
-      //\r
-      WriteWord (mNvDataStructSize + mNonNvDataStructSize + 2);\r
-      if (WriteLength) {\r
-        WriteByte (0, 0);\r
-      }\r
-    } else if (strcmp (FieldName, "Day") == 0) {\r
-      //\r
-      // Write ID (offset), ID, and size\r
-      //\r
-      WriteWord (mNvDataStructSize + mNonNvDataStructSize + 4);\r
-      if (WriteLength) {\r
-        WriteByte (0, 0);\r
-      }\r
-    } else {\r
-      PrintErrorMessage (LineNum1, FieldName, "expected valid field name TheYear/TheMonth/TheDay");\r
-    }\r
-    return;\r
-  } else if (strcmp (StructName, "Time") == 0) {\r
-    //\r
-    // Someone specified Time.Hours|Minutes|Seconds\r
-    // BUGBUG -- define some constants for the IDs used here\r
-    //\r
-    if (strcmp (FieldName, "Hours") == 0) {\r
-      //\r
-      // Write ID (offset), ID, and size\r
-      //\r
-      WriteWord (mNvDataStructSize + mNonNvDataStructSize + 6);\r
-      if (WriteLength) {\r
-        WriteByte (0, 0);\r
-      }\r
-    } else if (strcmp (FieldName, "Minutes") == 0) {\r
-      //\r
-      // Write ID (offset), ID, and size\r
-      //\r
-      WriteWord (mNvDataStructSize + mNonNvDataStructSize + 8);\r
-      if (WriteLength) {\r
-        WriteByte (0, 0);\r
-      }\r
-    } else if (strcmp (FieldName, "Seconds") == 0) {\r
-      //\r
-      // Write ID (offset), ID, and size\r
-      //\r
-      WriteWord (mNvDataStructSize + mNonNvDataStructSize + 10);\r
-      if (WriteLength) {\r
-        WriteByte (0, 0);\r
-      }\r
-    } else {\r
-      PrintErrorMessage (LineNum1, FieldName, "expected valid field name Hours/Minutes/Seconds");\r
-    }\r
-    return;\r
-  } else {\r
-    PrintErrorMessage (LineNum1, StructName, "undefined structure");\r
-    return;\r
-  }\r
-}\r
-VOID\r
-EfiVfrParser::StartStructDefinition (\r
-  INT32  IsNonNV,\r
-  INT32  LineNum\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Called when we encounter a new "struct _MY_STRUCT..." statement while parsing. \r
-  Initialize internal data and structures for parsing the fields of the structure.\r
-\r
-Arguments:\r
-  LineNum  - line number in the source file (for error reporting purposes)\r
-  IsNonNv  - flag indicating (if nonzero) that the variable referred to is not in\r
-             the standard NV store.\r
-Returns:\r
-  None\r
-\r
---*/\r
-{\r
-  STRUCT_DEFINITION *StructDef;\r
-  //\r
-  // Allocate memory for the structure record\r
-  //\r
-  StructDef = (STRUCT_DEFINITION *)malloc (sizeof (STRUCT_DEFINITION));\r
-  memset (StructDef, 0, sizeof (STRUCT_DEFINITION));\r
-  StructDef->LineNum = LineNum;\r
-  //\r
-  // Set flag indicating non-NV data structure or not\r
-  //\r
-  StructDef->IsNonNV = IsNonNV;\r
-  //\r
-  // Add it to the end of our linked list. If it's the first one\r
-  // defined, then it's the default varstore ID, so set it valid.\r
-  //\r
-  if (mFirstStructDefinition == NULL) {\r
-    mFirstStructDefinition = StructDef;\r
-    StructDef->VarStoreIdValid = 1;\r
-  } else {\r
-    mLastStructDefinition->Next = StructDef;\r
-  }\r
-  mLastStructDefinition = StructDef;\r
-}\r
-VOID\r
-EfiVfrParser::EndStructDefinition (\r
-  CHAR8  *StructName,\r
-  INT32  LineNum\r
-  )\r
-{\r
-  STRUCT_DEFINITION         *StructDef;\r
-  STRUCT_FIELD_DEFINITION   *FieldDef;\r
-  UINT32                    Offset;\r
-  //\r
-  // Make sure they have not already defined a structure with this name\r
-  //\r
-  for (StructDef = mFirstStructDefinition; StructDef != NULL; StructDef = StructDef->Next) {\r
-    if ((StructDef->Name != NULL) && (strcmp (StructDef->Name, StructName) == 0)) {\r
-      PrintErrorMessage (LineNum, StructName, "structure with this name already defined");\r
-      //\r
-      // Fall through and fill in the rest of the structure information. We do\r
-      // this because the structure has already been added to our global list,\r
-      // so will be used elsewhere, so we want it to contain valid fields.\r
-      //\r
-    }\r
-  }    \r
-  //\r
-  // Allocate memory for the structure name \r
-  //\r
-  mLastStructDefinition->Name = (char *)malloc (strlen (StructName) + 1);\r
-  strcpy (mLastStructDefinition->Name, StructName);\r
-  //\r
-  // Compute the structure size, and the offsets to each field\r
-  //\r
-  Offset = 0;\r
-  for (FieldDef = mLastStructDefinition->Field; FieldDef != NULL; FieldDef = FieldDef->Next) {\r
-    FieldDef->Offset = Offset;\r
-    Offset += FieldDef->ArrayLength * FieldDef->DataSize;\r
-  }\r
-  mLastStructDefinition->Size = Offset;\r
-  //\r
-  // Go through all the structure we have so far and figure out (if we can)\r
-  // the size of the non-NV storage. We also assume that the first structure\r
-  // definition is the primary/default storage for the VFR form.\r
-  //\r
-  if (mNonNvDataStructSize == 0) {\r
-    for (StructDef = mFirstStructDefinition; StructDef != NULL; StructDef = StructDef->Next) {\r
-      if (StructDef->IsNonNV) {\r
-        mNonNvDataStructSize = StructDef->Size;\r
-        break;\r
-      }\r
-    }\r
-  }\r
-  if (mNvDataStructSize == 0) {\r
-    for (StructDef = mFirstStructDefinition; StructDef != NULL; StructDef = StructDef->Next) {\r
-      if (StructDef->IsNonNV == 0) {\r
-        mNvDataStructSize = StructDef->Size;\r
-        break;\r
-      }\r
-    }\r
-  }\r
-}\r
-VOID \r
-EfiVfrParser::AddStructField (\r
-  CHAR8   *FieldName, \r
-  INT32   LineNum, \r
-  INT32   DataSize,\r
-  INT32   ArrayLength,\r
-  INT8    IsArray\r
-  ) \r
-/*++\r
-\r
-Routine Description:\r
-  We're parsing the VFR structure definition. Add another defined field to \r
-  our definition.\r
-\r
-Arguments:\r
-  FieldName   - name of the field in the structure.\r
-  LineNum     - the line number from the input (preprocessor output) file\r
-  DataSize    - the size of the field (1, 2, or 4 bytes)\r
-  ArrayLength - the number of elements (for array)\r
-  IsArray     - non-zero if the field is an array\r
-\r
-Returns:\r
-  None.\r
-\r
---*/\r
-{\r
-  STRUCT_FIELD_DEFINITION *FieldDef;\r
-  STRUCT_FIELD_DEFINITION *Temp;\r
-  //\r
-  // Make sure we don't already have a field of this name in our structure\r
-  //\r
-  for (FieldDef = mLastStructDefinition->Field; FieldDef != NULL; FieldDef = FieldDef->Next) {\r
-    if (strcmp (FieldDef->Name, FieldName) == 0) {\r
-      PrintErrorMessage (LineNum, FieldName, "field with this name already defined");\r
-      return;\r
-    }\r
-  } \r
-  //\r
-  // If it's an array, then they better not have a size of 0. For example:\r
-  //   UINT8 MyBytes[0];\r
-  //\r
-  if (IsArray && (ArrayLength <= 0)) {\r
-    PrintErrorMessage (LineNum, FieldName, "invalid array size");\r
-    return;\r
-  }    \r
-  //\r
-  // Allocate memory for a new structure field definition\r
-  //    \r
-  FieldDef = (STRUCT_FIELD_DEFINITION *)malloc (sizeof (STRUCT_FIELD_DEFINITION));\r
-  memset ((char *)FieldDef, 0, sizeof (STRUCT_FIELD_DEFINITION));\r
-  FieldDef->ArrayLength  = ArrayLength;\r
-  FieldDef->DataSize     = DataSize;\r
-  FieldDef->IsArray      = IsArray;\r
-  FieldDef->Name = (char *)malloc (strlen (FieldName) + 1);\r
-  strcpy (FieldDef->Name, FieldName);\r
-  //\r
-  // Add it to the end of the field list for the currently active structure\r
-  //\r
-  if (mLastStructDefinition->Field == NULL) {\r
-    mLastStructDefinition->Field = FieldDef;\r
-  } else {\r
-    mLastStructDefinition->LastField->Next = FieldDef;\r
-  }\r
-  mLastStructDefinition->LastField = FieldDef;\r
-}\r
-VOID\r
-EfiVfrParser::AddVarStore (\r
-  CHAR8  *StructName,       // actual name of the structure\r
-  CHAR8  *VarName,          // actual NV variable name\r
-  UINT16 VarStoreId,        // key value\r
-  INT32  LineNum            // parse line number (for error reporting)\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Called while parsing a varstore statement. Add the variable store \r
-  to our linked list.\r
-\r
-Arguments:\r
-  StructName    - the name of the typedef'ed structure to use\r
-  VarName       - the NV variable name as specified in the varstore statement\r
-  VarStoreId    - the variable store ID as specified in the varstore statememt\r
-  LineNum       - the line number from the input (preprocessor output) file\r
-\r
-Returns:\r
-  None.\r
-\r
---*/\r
-{\r
-  STRUCT_DEFINITION *StructDef;\r
-  UINT16_LIST       *L16Ptr;\r
-  //\r
-  // Go through our list of previously-defined variable store IDs and\r
-  // make sure this one is not a duplicate in name or key value.\r
-  //\r
-  for (L16Ptr = mDefinedVarStoreId; L16Ptr != NULL; L16Ptr = L16Ptr->Next) {\r
-    if (L16Ptr->Value == VarStoreId) {\r
-      PrintErrorMessage (LineNum, "variable storage key already used", NULL);\r
-      PrintErrorMessage (L16Ptr->LineNum, "previous usage of storage key", NULL);\r
-    }\r
-  }\r
-  // \r
-  // Key value of 0 is invalid since that's assigned by default to the default\r
-  // variable store (the first structure parsed).\r
-  //\r
-  if (VarStoreId == 0) {\r
-    PrintErrorMessage (LineNum, "variable storage key of 0 is invalid", NULL);\r
-  }\r
-  //\r
-  // Create a new element to add to the list\r
-  //\r
-  L16Ptr = (UINT16_LIST *)malloc(sizeof (UINT16_LIST));\r
-  memset (L16Ptr, 0, sizeof (UINT16_LIST));\r
-  L16Ptr->LineNum = LineNum;\r
-  L16Ptr->Value = VarStoreId;\r
-  if (mDefinedVarStoreId == NULL) {\r
-    mDefinedVarStoreId = L16Ptr;\r
-  } else {\r
-    mLastDefinedVarStoreId->Next = L16Ptr;\r
-  }\r
-  mLastDefinedVarStoreId = L16Ptr;\r
-  //\r
-  // Find the structure definition with this name\r
-  //\r
-  for (StructDef = mFirstStructDefinition; StructDef != NULL; StructDef = StructDef->Next) {\r
-    if (strcmp (StructDef->Name, StructName) == 0) {\r
-      //\r
-      // Make sure they did not already define a variable storage ID \r
-      // for this structure.\r
-      //\r
-      if (StructDef->VarStoreId != 0) {\r
-        PrintErrorMessage (LineNum, StructName, "variable storage already defined for this structure");\r
-        PrintErrorMessage (StructDef->VarStoreLineNum, StructName, "previous definition for variable storage");\r
-      }\r
-      StructDef->VarStoreId       = VarStoreId;\r
-      StructDef->VarStoreIdValid  = 1;\r
-      StructDef->VarStoreLineNum  = LineNum;\r
-      WriteWord (StructDef->Size);\r
-      while (*VarName) {\r
-        WriteByte(*VarName, 0);\r
-        VarName++;\r
-      }\r
-      WriteByte(0,0);\r
-      return;\r
-    }\r
-  }    \r
-  PrintErrorMessage (LineNum, StructName, "structure with this name not defined");\r
-}\r
-VOID \r
-EfiVfrParser::WriteDWord (\r
-  UINT32    Value, \r
-  UINT8     KeyByte\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  During parsing, we came upon some code that requires a 32-bit value be\r
-  written to the VFR binary file. Queue up the 4 bytes.\r
-\r
-Arguments:\r
-  Value   - the 32-bit value to write\r
-  KeyByte - a single character which gets written out beside the first byte.\r
-            This is used to tag the data in the output file so that during \r
-            debug you have an idea what the value is.\r
-\r
-Returns:\r
-  None.\r
-\r
---*/\r
-{\r
-  //\r
-  // Write 4 bytes, little endian. Specify a key byte only on the first one\r
-  //\r
-  mOpcodeHandler.AddByte ((UINT8)Value, KeyByte);\r
-  Value \>>= 8;\r
-  mOpcodeHandler.AddByte ((UINT8)Value, 0);\r
-  Value \>>= 8;\r
-  mOpcodeHandler.AddByte ((UINT8)Value, 0);\r
-  Value \>>= 8;\r
-  mOpcodeHandler.AddByte ((UINT8)Value, 0);\r
-}\r
-VOID \r
-EfiVfrParser::WriteOpByte (\r
-  UINT32    LineNum,\r
-  UINT8     ByteValue\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  \r
-  During parsing, we came upon a new VFR opcode. At this point we flush\r
-  the output queue and then queue up this byte (with 'O' for opcode tag).\r
-\r
-Arguments:\r
-\r
-  ByteValue   - opcode value\r
-\r
-Returns:\r
-\r
-  None.\r
-\r
---*/\r
-{\r
-  mOpcodeHandler.AddOpcodeByte (ByteValue, LineNum);\r
-}\r
-VOID \r
-EfiVfrParser::WriteByte (\r
-  UINT8   ByteValue, \r
-  UINT8   Key\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  \r
-  During parsing of the VFR we spoonfeed this function with bytes to write to\r
-  the output VFR binary file. This function simply queues up the bytes, and\r
-  the queue gets flushed each time a new VFR opcode is encountered.\r
-\r
-Arguments:\r
-\r
-  ByteValue   - raw byte to write\r
-  Key         - character to tag the byte with when we write ByteValue to the\r
-                output file.\r
-\r
-Returns:\r
-\r
-  None.\r
-\r
---*/\r
-{\r
-  mOpcodeHandler.AddByte (ByteValue, Key);\r
-}\r
-VOID \r
-EfiVfrParser::WriteWord (\r
-  UINT32  Value\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  During VFR parsing we came upon a case where we need to write out a \r
-  16-bit value. Queue it up.\r
-\r
-Arguments:\r
-  Value - value to write.\r
-\r
-Returns:\r
-  None.\r
-\r
---*/\r
-{\r
-  mOpcodeHandler.AddByte ((UINT8)Value, 0);\r
-  mOpcodeHandler.AddByte ((UINT8)((Value \>> 8) & 0xFF), 0);\r
-}\r
-VOID \r
-EfiVfrParser::WriteStringIdWord (\r
-  UINT16 WordValue\r
-  )\r
-{\r
-  mOpcodeHandler.AddByte ((UINT8)WordValue, 'S');\r
-  mOpcodeHandler.AddByte ((UINT8)((WordValue \>> 8) & 0xFF), 0);\r
-}\r
-VOID\r
-EfiVfrParser::FreeGotoReferences ()\r
-/*++\r
-\r
-Routine Description:\r
-  Called during cleanup to free up the memory we allocated when\r
-  keeping track of VFR goto statements.\r
-\r
-Arguments:\r
-  None\r
-\r
-Returns:\r
-  None\r
-\r
---*/\r
-{\r
-  GOTO_REFERENCE  *CurrRef;\r
-  GOTO_REFERENCE  *NextRef;\r
-  FORM_ID_VALUE   *CurrFormId;\r
-  FORM_ID_VALUE   *NextFormId;\r
-  UINT8           Found;\r
-  CHAR8           Name[20];\r
-\r
-  //\r
-  // Go through all the "goto" references and make sure there was a \r
-  // form ID of that value defined.\r
-  //\r
-  for (CurrRef = mGotoReferences; CurrRef != NULL; CurrRef = CurrRef->Next) {\r
-    Found = 0;\r
-    for (CurrFormId = mFormIdValues; CurrFormId != NULL; CurrFormId = CurrFormId->Next) {\r
-      if (CurrRef->Value == CurrFormId->Value) {\r
-        Found = 1;\r
-        break;\r
-      }\r
-    }\r
-    if (!Found) {\r
-      sprintf (Name, "%d", (UINT32)CurrRef->Value);\r
-      PrintErrorMessage (CurrRef->RefLineNum, Name, "undefined form ID");\r
-    }  \r
-  }  \r
-  //\r
-  // Now free up the form id and goto references\r
-  //\r
-  CurrFormId = mFormIdValues;\r
-  while (CurrFormId != NULL) {\r
-    NextFormId = CurrFormId->Next;\r
-    free (CurrFormId);\r
-    CurrFormId = NextFormId;\r
-  }\r
-  mFormIdValues = NULL;\r
-  CurrRef = mGotoReferences;\r
-  while (CurrRef != NULL) {\r
-    NextRef = CurrRef->Next;\r
-    free (CurrRef);\r
-    CurrRef = NextRef;\r
-  }  \r
-  mGotoReferences = NULL;\r
-}\r
-VOID\r
-EfiVfrParser::AddGotoReference (\r
-  UINT32  GotoNumber,\r
-  UINT32  LineNum\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  During VFR parsing we came upon a goto statement. Since we support\r
-  forward references, save the referenced label and at the end of parsing\r
-  we'll check that the label was actually defined somewhere.\r
-\r
-Arguments:\r
-  GotoNumber  - the label number referenced\r
-  LineNum     - the line number where the reference was made (used for\r
-                error reporting)\r
-\r
-Returns:\r
-  None\r
-\r
---*/\r
-{\r
-  GOTO_REFERENCE *NewRef;\r
-  \r
-  NewRef = (GOTO_REFERENCE *)malloc (sizeof (GOTO_REFERENCE));\r
-  if (NewRef == NULL) {\r
-    Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");\r
-    return;\r
-  }\r
-  memset ((char *)NewRef, 0, sizeof (GOTO_REFERENCE));\r
-  NewRef->Value = (UINT16)GotoNumber;\r
-  NewRef->RefLineNum = LineNum;\r
-  NewRef->Next = mGotoReferences;\r
-  mGotoReferences = NewRef;\r
-}\r
-VOID\r
-EfiVfrParser::AddFormId (\r
-  INT32   FormIdValue,\r
-  UINT32  LineNum\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  This function is called when we parse "form formid = 3" statements.\r
-  We save the form ID valud so we can verify that duplicates are not\r
-  defined. Also, these are the targets of goto statements, so when we're\r
-  done parsing the script we also go through all the goto statements to\r
-  check that there was a target FormId defined as referenced by each\r
-  goto statement.\r
-  \r
-  Note that formid = 0 is invalid.\r
-\r
-Arguments:\r
-  FormIdValue  - the parsed value for the Form ID\r
-  LineNum      - line number of the source file we're parsing\r
-\r
-Returns:\r
-  NA\r
-\r
---*/\r
-{\r
-  FORM_ID_VALUE *NewFormId;\r
-  char          *FileName;\r
-  char          *FileName2;\r
-  UINT32        LineNum2;  \r
-  //\r
-  // Verify that FormId != 0\r
-  //\r
-  if (FormIdValue == 0) {\r
-    FileName = ConvertLineNumber (&LineNum);\r
-    Error (FileName, LineNum, 0, "form ID cannot be 0", NULL);\r
-    return;\r
-  }\r
-  //\r
-  // First go through all previously defined form IDs and make sure they have not defined\r
-  // duplicates.\r
-  //\r
-  for (NewFormId = mFormIdValues; NewFormId != NULL; NewFormId = NewFormId->Next) {\r
-    if ((UINT16)FormIdValue == NewFormId->Value) {\r
-      FileName = ConvertLineNumber (&LineNum);\r
-      LineNum2 = NewFormId->LineNum;\r
-      FileName2 = ConvertLineNumber (&LineNum2);\r
-      Error (FileName, LineNum, 0, NULL, "form ID %d already defined", FormIdValue);\r
-      Error (FileName2, LineNum2, 0, NULL, "form ID %d previous definition", FormIdValue);\r
-      return;\r
-    }\r
-  }\r
-  //\r
-  // Allocate memory for a new one \r
-  //\r
-  NewFormId = (FORM_ID_VALUE *)malloc (sizeof (FORM_ID_VALUE));\r
-  if (NewFormId == NULL) {\r
-    Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");\r
-    return;\r
-  }\r
-  memset ((char *)NewFormId, 0, sizeof (FORM_ID_VALUE));\r
-  NewFormId->LineNum = LineNum;\r
-  NewFormId->Next = mFormIdValues;\r
-  NewFormId->Value = (UINT16)FormIdValue;\r
-  mFormIdValues = NewFormId;\r
-}\r
-UINT32\r
-EfiVfrParser::GetNumber (\r
-  CHAR8   *NumStr,\r
-  UINT32  LineNum,\r
-  UINT32  NumBytes\r
-  )\r
-{\r
-  UINT32 Value;\r
-  \r
-  if ((NumStr[0] == '0') && (NumStr[1] == 'x')) {\r
-    AtoX (NumStr + 2, 4, &Value);\r
-  } else {\r
-    Value = (UINT32)atoi (NumStr);\r
-  }\r
-  //\r
-  // Check range\r
-  //\r
-  if ((NumBytes < 4) && (Value & ((UINT32)0xFFFFFFFF << (NumBytes * 8)))) {\r
-    PrintErrorMessage (LineNum, NumStr, "value out of range");\r
-    return 0;\r
-  }\r
-  return Value;\r
-}\r
-\r
->>\r
-\r
-} // end grammar class\r
-\r
diff --git a/Tools/CodeTools/TianoTools/VfrCompile/VfrServices.cpp b/Tools/CodeTools/TianoTools/VfrCompile/VfrServices.cpp
deleted file mode 100644 (file)
index 359256a..0000000
+++ /dev/null
@@ -1,758 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2004 - 2005, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-Module Name:\r
-\r
-  VfrServices.cpp\r
-\r
-Abstract:\r
-\r
-  Support routines for the VFR compiler\r
-  \r
---*/  \r
-\r
-#include <stdio.h>    // for FILE routines\r
-#include <stdlib.h>   // for malloc() and free()\r
-\r
-#include <Common/UefiBaseTypes.h>\r
-#include <Common/MultiPhase.h>\r
-#include <Common/InternalFormRepresentation.h>\r
-#include <Protocol/UgaDraw.h>  // for EFI_UGA_PIXEL definition\r
-#include <Protocol/Hii.h>\r
-\r
-#include "EfiUtilityMsgs.h"\r
-#include "EfiVfr.h"\r
-#include "VfrServices.h"\r
-\r
-\r
-static const char *mSourceFileHeader[] = {\r
-  "//",\r
-  "//  DO NOT EDIT -- auto-generated file",\r
-  "//",\r
-  "//  This file is generated by the VFR compiler.",\r
-  "//",\r
-  NULL\r
-};\r
-\r
-typedef struct {\r
-   CHAR8    *Name;\r
-   INT32    Size;\r
-} IFR_OPCODE_SIZES;\r
-\r
-//\r
-// Create a table that can be used to do internal checking on the IFR\r
-// bytes we emit.\r
-//\r
-static const IFR_OPCODE_SIZES mOpcodeSizes[] = {\r
-  { 0, 0 },     // invalid\r
-  { "EFI_IFR_FORM",                       sizeof (EFI_IFR_FORM) },\r
-  { "EFI_IFR_SUBTITLE",                   sizeof (EFI_IFR_SUBTITLE) }, \r
-  { "EFI_IFR_TEXT",                       -6 }, //sizeof (EFI_IFR_TEXT) }, \r
-  { "unused 0x04 opcode",                 0 }, // EFI_IFR_GRAPHIC_OP\r
-  { "EFI_IFR_ONE_OF",                     sizeof (EFI_IFR_ONE_OF) }, \r
-  { "EFI_IFR_CHECKBOX",                   sizeof (EFI_IFR_CHECKBOX) }, \r
-  { "EFI_IFR_NUMERIC",                    sizeof (EFI_IFR_NUMERIC) }, \r
-  { "EFI_IFR_PASSWORD",                   sizeof (EFI_IFR_PASSWORD) }, \r
-  { "EFI_IFR_ONE_OF_OPTION",              sizeof (EFI_IFR_ONE_OF_OPTION) }, \r
-  { "EFI_IFR_SUPPRESS",                   sizeof (EFI_IFR_SUPPRESS) }, \r
-  { "EFI_IFR_END_FORM",                   sizeof (EFI_IFR_END_FORM) }, \r
-  { "EFI_IFR_HIDDEN",                     sizeof (EFI_IFR_HIDDEN) }, \r
-  { "EFI_IFR_END_FORM_SET",               sizeof (EFI_IFR_END_FORM_SET) }, \r
-  { "EFI_IFR_FORM_SET",                   sizeof (EFI_IFR_FORM_SET) }, \r
-  { "EFI_IFR_REF",                        sizeof (EFI_IFR_REF) }, \r
-  { "EFI_IFR_END_ONE_OF",                 sizeof (EFI_IFR_END_ONE_OF) }, \r
-  { "EFI_IFR_INCONSISTENT",               sizeof (EFI_IFR_INCONSISTENT) }, \r
-  { "EFI_IFR_EQ_ID_VAL",                  sizeof (EFI_IFR_EQ_ID_VAL) }, \r
-  { "EFI_IFR_EQ_ID_ID",                   sizeof (EFI_IFR_EQ_ID_ID) }, \r
-  { "EFI_IFR_EQ_ID_LIST",                 -sizeof (EFI_IFR_EQ_ID_LIST) }, \r
-  { "EFI_IFR_AND",                        sizeof (EFI_IFR_AND) }, \r
-  { "EFI_IFR_OR",                         sizeof (EFI_IFR_OR) }, \r
-  { "EFI_IFR_NOT",                        sizeof (EFI_IFR_NOT) }, \r
-  { "EFI_IFR_END_EXPR",                   sizeof (EFI_IFR_END_EXPR) }, \r
-  { "EFI_IFR_GRAY_OUT",                   sizeof (EFI_IFR_GRAY_OUT) }, \r
-  { "EFI_IFR_DATE",                       sizeof (EFI_IFR_DATE) / 3 }, \r
-  { "EFI_IFR_TIME",                       sizeof (EFI_IFR_TIME) / 3 }, \r
-  { "EFI_IFR_STRING",                     sizeof (EFI_IFR_STRING) }, \r
-  { "EFI_IFR_LABEL",                      sizeof (EFI_IFR_LABEL) }, \r
-  { "EFI_IFR_SAVE_DEFAULTS",              sizeof (EFI_IFR_SAVE_DEFAULTS) }, \r
-  { "EFI_IFR_RESTORE_DEFAULTS",           sizeof (EFI_IFR_RESTORE_DEFAULTS) }, \r
-  { "EFI_IFR_BANNER",                     sizeof (EFI_IFR_BANNER) },\r
-  { "EFI_IFR_INVENTORY",                  sizeof (EFI_IFR_INVENTORY) },\r
-  { "EFI_IFR_EQ_VAR_VAL_OP",              sizeof (EFI_IFR_EQ_VAR_VAL) },\r
-  { "EFI_IFR_ORDERED_LIST_OP",            sizeof (EFI_IFR_ORDERED_LIST) },\r
-  { "EFI_IFR_VARSTORE_OP",                -sizeof (EFI_IFR_VARSTORE) },\r
-  { "EFI_IFR_VARSTORE_SELECT_OP",         sizeof (EFI_IFR_VARSTORE_SELECT) },\r
-  { "EFI_IFR_VARSTORE_SELECT_PAIR_OP",    sizeof (EFI_IFR_VARSTORE_SELECT_PAIR) },\r
-  { "EFI_IFR_TRUE",                       sizeof (EFI_IFR_TRUE)},\r
-  { "EFI_IFR_FALSE",                      sizeof (EFI_IFR_FALSE)},\r
-  { "EFI_IFR_GT",                         sizeof (EFI_IFR_GT)},\r
-  { "EFI_IFR_GE",                         sizeof (EFI_IFR_GE)},\r
-  { "EFI_IFR_OEM_DEFINED_OP",             -2 },\r
-};\r
-\r
-\r
-VfrOpcodeHandler::VfrOpcodeHandler (\r
-  ) \r
-/*++\r
-\r
-Routine Description:\r
-  Constructor for the VFR opcode handling class.\r
-  \r
-Arguments:\r
-  None\r
-\r
-Returns:\r
-  None\r
-\r
---*/\r
-{ \r
-  mIfrBytes                       = NULL; \r
-  mLastIfrByte                    = NULL;\r
-  mBytesWritten                   = 0;\r
-  mQueuedByteCount                = 0;\r
-  mQueuedOpcodeByteValid          = 0;\r
-  mPrimaryVarStoreId              = 0;\r
-  mSecondaryVarStoreId            = 0;\r
-  mSecondaryVarStoreIdSet         = 0;\r
-  mPrimaryVarStoreIdSet           = 0;\r
-  mDefaultVarStoreId              = 0;\r
-}\r
-\r
-VOID \r
-VfrOpcodeHandler::SetVarStoreId (\r
-  UINT16 VarStoreId\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  This function is invoked by the parser when a variable is referenced in the \r
-  VFR. Save the variable store (and set a flag) so that we can later determine \r
-  if we need to emit a varstore-select or varstore-select-pair opcode.\r
-  \r
-Arguments:\r
-  VarStoreId - ID of the variable store referenced in the VFR\r
-\r
-Returns:\r
-  None\r
-\r
---*/\r
-{\r
-  mPrimaryVarStoreId    = VarStoreId;\r
-  mPrimaryVarStoreIdSet = 1;\r
-}\r
-\r
-VOID \r
-VfrOpcodeHandler::SetSecondaryVarStoreId (\r
-  UINT16 VarStoreId\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  This function is invoked by the parser when a secondary variable is \r
-  referenced in the VFR. Save the variable store (and set a flag) so \r
-  that we can later determine if we need to emit a varstore-select or \r
-  varstore-pair opcode.\r
-  \r
-Arguments:\r
-  VarStoreId - ID of the variable store referenced in the VFR\r
-\r
-Returns:\r
-  None\r
-\r
---*/\r
-{\r
-  mSecondaryVarStoreId    = VarStoreId;\r
-  mSecondaryVarStoreIdSet = 1;\r
-}\r
-\r
-VOID \r
-VfrOpcodeHandler::WriteIfrBytes (\r
-  ) \r
-/*++\r
-\r
-Routine Description:\r
-  This function is invoked at the end of parsing. Its purpose\r
-  is to write out all the IFR bytes that were queued up while\r
-  parsing.\r
-  \r
-Arguments:\r
-  None\r
-\r
-Returns:\r
-  None\r
-\r
---*/\r
-{ \r
-  IFR_BYTE                  *Curr;\r
-  IFR_BYTE                  *Next;\r
-  UINT32                    Count;\r
-  UINT32                    LineCount;\r
-  UINT32                    PoundLines;\r
-  UINT32                    ByteCount;\r
-  CHAR8                     Line[MAX_LINE_LEN];\r
-  CHAR8                     *Cptr;\r
-  FILE                      *InFptr;\r
-  FILE                      *OutFptr;\r
-  UINT32                    ListFile;\r
-  EFI_HII_IFR_PACK_HEADER   IfrHeader;\r
-  UINT8                     *Ptr;\r
-  FILE                      *IfrBinFptr;\r
-  UINT32                    BytesLeftThisOpcode;\r
-  //\r
-  // If someone added a new opcode and didn't update our opcode sizes structure, error out.\r
-  //\r
-  if (sizeof(mOpcodeSizes) / sizeof (mOpcodeSizes[0]) != EFI_IFR_LAST_OPCODE + 1) {\r
-    Error (__FILE__, __LINE__, 0, "application error", "internal IFR binary table size is incorrect");\r
-    return;\r
-  }\r
-  //\r
-  // Flush the queue\r
-  //\r
-  FlushQueue ();    \r
-  //\r
-  // If there have been any errors to this point, then skip dumping the IFR\r
-  // binary data. This way doing an nmake again will try to build it again, and\r
-  // the build will fail if they did not fix the problem.\r
-  //\r
-  if (GetUtilityStatus () != STATUS_ERROR) {\r
-    if ((IfrBinFptr = fopen (gOptions.IfrOutputFileName, "w")) == NULL) {\r
-      Error (PROGRAM_NAME, 0, 0, gOptions.IfrOutputFileName, "could not open file for writing");\r
-      return;\r
-    }\r
-    //\r
-    // Write the standard file header to the output file\r
-    //\r
-    WriteStandardFileHeader (IfrBinFptr);\r
-    //\r
-    // Write the structure header\r
-    //\r
-    fprintf (IfrBinFptr, "\nunsigned char %sBin[] = {", gOptions.VfrBaseFileName);\r
-    //\r
-    // Write the header\r
-    //\r
-    memset ((char *)&IfrHeader, 0, sizeof (IfrHeader));\r
-    IfrHeader.Header.Type = EFI_HII_IFR;\r
-    IfrHeader.Header.Length = mBytesWritten + sizeof (IfrHeader);    \r
-    Ptr = (UINT8 *)&IfrHeader;\r
-    for (Count = 0; Count < sizeof (IfrHeader); Count++, Ptr++) {\r
-      if ((Count & 0x03) == 0) {\r
-        fprintf (IfrBinFptr, "\n  ");\r
-      }\r
-      fprintf (IfrBinFptr, "0x%02X, ", *Ptr);      \r
-    }\r
-    //\r
-    //\r
-    // Write all the IFR bytes\r
-    //\r
-    fprintf (IfrBinFptr, "\n  // start of IFR data");\r
-    Curr = mIfrBytes;\r
-    Count = 0;\r
-    while (Curr != NULL) {\r
-      if ((Count & 0x0F) == 0) {\r
-        fprintf (IfrBinFptr, "\n  ");\r
-      }\r
-      if (Curr->KeyByte != 0) {\r
-        fprintf (IfrBinFptr, "/*%c*/ ", Curr->KeyByte);\r
-      }\r
-      fprintf (IfrBinFptr, "0x%02X, ", Curr->OpcodeByte);\r
-      Count++;\r
-      Curr = Curr->Next;\r
-    }\r
-    fprintf (IfrBinFptr, "\n};\n\n");\r
-    //\r
-    //\r
-    // Close the file\r
-    //\r
-    fclose (IfrBinFptr); \r
-    IfrBinFptr = NULL;\r
-  }\r
-  //\r
-  // Write the bytes as binary data if the user specified to do so\r
-  //\r
-  if ((GetUtilityStatus () != STATUS_ERROR) &&  (gOptions.CreateIfrBinFile != 0)) {\r
-    //\r
-    // Use the Ifr output file name with a ".hpk" extension.\r
-    //\r
-    for (Cptr = gOptions.IfrOutputFileName + strlen (gOptions.IfrOutputFileName) - 1;\r
-         (*Cptr != '.') && (Cptr > gOptions.IfrOutputFileName) && (*Cptr != '\\');\r
-         Cptr--) {\r
-      //\r
-      // do nothing\r
-      //\r
-    }\r
-    if (*Cptr == '.') {\r
-      strcpy (Cptr, ".hpk");\r
-    } else {\r
-      strcat (gOptions.IfrOutputFileName, ".hpk");\r
-    }\r
-    if ((IfrBinFptr = fopen (gOptions.IfrOutputFileName, "wb")) == NULL) {\r
-      Error (PROGRAM_NAME, 0, 0, gOptions.IfrOutputFileName, "could not open file for writing");\r
-      return;\r
-    }\r
-    //\r
-    // Write the structure header\r
-    //\r
-    memset ((char *)&IfrHeader, 0, sizeof (IfrHeader));\r
-    IfrHeader.Header.Type = EFI_HII_IFR;\r
-    IfrHeader.Header.Length = mBytesWritten + sizeof (IfrHeader);    \r
-    Ptr = (UINT8 *)&IfrHeader;\r
-    for (Count = 0; Count < sizeof (IfrHeader); Count++, Ptr++) {\r
-      fwrite (Ptr, 1, 1, IfrBinFptr);\r
-    }\r
-    //\r
-    //\r
-    // Write all the IFR bytes\r
-    //\r
-    Curr = mIfrBytes;\r
-    Count = 0;\r
-    while (Curr != NULL) {\r
-      fwrite (&Curr->OpcodeByte, 1, 1, IfrBinFptr);\r
-      Curr = Curr->Next;\r
-    }\r
-    //\r
-    //\r
-    // Close the file\r
-    //\r
-    fclose (IfrBinFptr); \r
-    IfrBinFptr = NULL;\r
-  }\r
-  //\r
-  // If creating a listing file, then open the input and output files\r
-  //\r
-  ListFile = 0;\r
-  if (gOptions.CreateListFile) {\r
-    //\r
-    // Open the input VFR file and the output list file\r
-    //\r
-    if ((InFptr = fopen (gOptions.PreprocessorOutputFileName, "r")) == NULL) {\r
-      Warning (PROGRAM_NAME, 0, 0, gOptions.PreprocessorOutputFileName, "could not open file for creating a list file");\r
-    } else {\r
-      if ((OutFptr = fopen (gOptions.VfrListFileName, "w")) == NULL) {\r
-        Warning (PROGRAM_NAME, 0, 0, gOptions.VfrListFileName, "could not open output list file for writing");\r
-        fclose (InFptr);\r
-        InFptr = NULL;\r
-      } else {\r
-        LineCount   = 0;\r
-        ListFile    = 1;\r
-        PoundLines  = 0;\r
-        ByteCount   = 0;\r
-      }\r
-    }\r
-  }\r
-  //\r
-  // Write the list file\r
-  //\r
-  if (ListFile) {\r
-    //\r
-    // Write out the VFR compiler version\r
-    //\r
-    fprintf (OutFptr, "//\n//  VFR compiler version " VFR_COMPILER_VERSION "\n//\n");\r
-    Curr = mIfrBytes;\r
-    while (Curr != NULL) {\r
-      //\r
-      // Print lines until we reach the line of the current opcode\r
-      //\r
-      while (LineCount < PoundLines + Curr->LineNum) {\r
-        if (fgets (Line, sizeof (Line), InFptr) != NULL) {\r
-          //\r
-          // We should check for line length exceeded on the fgets(). Otherwise it\r
-          // throws the listing file output off. Future enhancement perhaps.\r
-          //\r
-          fprintf (OutFptr, "%s", Line);\r
-          if (strncmp (Line, "#line", 5) == 0) {\r
-            PoundLines++;\r
-          }\r
-        }\r
-        LineCount++;\r
-      }\r
-      //\r
-      // Print all opcodes with line numbers less than where we are now\r
-      //\r
-      BytesLeftThisOpcode = 0;\r
-      while ((Curr != NULL) && ((Curr->LineNum == 0) || (LineCount >= PoundLines + Curr->LineNum))) {\r
-        if (BytesLeftThisOpcode == 0) {\r
-          fprintf (OutFptr, ">%08X: ", ByteCount);\r
-          if (Curr->Next != NULL) {\r
-            BytesLeftThisOpcode = (UINT32)Curr->Next->OpcodeByte;\r
-          }\r
-        }\r
-        fprintf (OutFptr, "%02X ", (UINT32)Curr->OpcodeByte);\r
-        ByteCount++;\r
-        BytesLeftThisOpcode--;\r
-        if (BytesLeftThisOpcode == 0) {\r
-          fprintf (OutFptr, "\n");\r
-        }\r
-        Curr = Curr->Next;\r
-      }\r
-    }\r
-    //\r
-    // Dump any remaining lines from the input file\r
-    //\r
-    while (fgets (Line, sizeof (Line), InFptr) != NULL) {\r
-      fprintf (OutFptr, "%s", Line);\r
-    }\r
-    fclose (InFptr);\r
-    fclose (OutFptr);\r
-  }\r
-  //\r
-  // Debug code to make sure that each opcode we write out has as many\r
-  // bytes as the IFR structure requires. If there were errors, then\r
-  // don't do this step.\r
-  //\r
-  if (GetUtilityStatus () != STATUS_ERROR) {\r
-    Curr = mIfrBytes;\r
-    ByteCount = 0;\r
-    while (Curr != NULL) {\r
-      //\r
-      // First byte is the opcode, second byte is the length\r
-      //\r
-      if (Curr->Next == NULL) {\r
-        Error (__FILE__, __LINE__, 0, "application error", "last opcode written does not contain a length byte");\r
-        break;\r
-      }\r
-      Count = (UINT32)Curr->Next->OpcodeByte;\r
-      if (Count == 0) {\r
-        Error (\r
-          __FILE__, \r
-          __LINE__, \r
-          0, \r
-          "application error", \r
-          "opcode with 0 length specified in output at offset 0x%X", \r
-          ByteCount\r
-          );\r
-        break;\r
-      }\r
-      //\r
-      // Check the length\r
-      //\r
-      if ((Curr->OpcodeByte > EFI_IFR_LAST_OPCODE) || (Curr->OpcodeByte == 0)) {\r
-        Error (\r
-          __FILE__, \r
-          __LINE__, \r
-          0, \r
-          "application error", \r
-          "invalid opcode 0x%X in output at offset 0x%X", \r
-          (UINT32) Curr->OpcodeByte, ByteCount\r
-          );\r
-      } else if (mOpcodeSizes[Curr->OpcodeByte].Size < 0) {\r
-        //\r
-        // For those cases where the length is variable, the size is negative, and indicates\r
-        // the miniumum size.\r
-        //\r
-        if ((mOpcodeSizes[Curr->OpcodeByte].Size * -1) > Count) {\r
-          Error (\r
-            __FILE__, \r
-            __LINE__, \r
-            0, \r
-            "application error", \r
-            "insufficient number of bytes written for %s at offset 0x%X",\r
-            mOpcodeSizes[Curr->OpcodeByte].Name, \r
-            ByteCount\r
-            );\r
-        }\r
-      } else {\r
-        //\r
-        // Check for gaps\r
-        //\r
-        if (mOpcodeSizes[Curr->OpcodeByte].Size == 0) {\r
-          Error (\r
-            __FILE__, \r
-            __LINE__, \r
-            0, \r
-            "application error", \r
-            "invalid opcode 0x%X in output at offset 0x%X", \r
-            (UINT32)Curr->OpcodeByte, \r
-            ByteCount\r
-            );\r
-        } else {\r
-          //\r
-          // Check size\r
-          //\r
-          if (mOpcodeSizes[Curr->OpcodeByte].Size != Count) {\r
-            Error (\r
-              __FILE__, \r
-              __LINE__, \r
-              0, \r
-              "application error", \r
-              "invalid number of bytes (%d written s/b %d) written for %s at offset 0x%X",\r
-              Count, \r
-              mOpcodeSizes[Curr->OpcodeByte].Size, \r
-              mOpcodeSizes[Curr->OpcodeByte].Name, \r
-              ByteCount\r
-              );\r
-          }\r
-        }\r
-      }\r
-      //\r
-      // Skip to next opcode\r
-      //\r
-      while (Count > 0) {\r
-        ByteCount++;\r
-        if (Curr == NULL) {\r
-          Error (__FILE__, __LINE__, 0, "application error", "last opcode written has invalid length");\r
-          break;\r
-        }\r
-        Curr = Curr->Next;\r
-        Count--;\r
-      }\r
-    }\r
-  }\r
-}\r
-\r
-VfrOpcodeHandler::~VfrOpcodeHandler(\r
-  ) \r
-/*++\r
-\r
-Routine Description:\r
-  Destructor for the VFR opcode handler. Free up memory allocated\r
-  while parsing the VFR script.\r
-  \r
-Arguments:\r
-  None\r
-\r
-Returns:\r
-  None\r
-\r
---*/\r
-{\r
-  IFR_BYTE    *Curr;\r
-  IFR_BYTE    *Next;\r
-  //\r
-  // Free up the IFR bytes\r
-  //\r
-  Curr = mIfrBytes;\r
-  while (Curr != NULL) {\r
-    Next = Curr->Next;\r
-    free (Curr);\r
-    Curr = Next;\r
-  }\r
-}\r
-\r
-int \r
-VfrOpcodeHandler::AddOpcodeByte (\r
-  UINT8 OpcodeByte, \r
-  UINT32 LineNum\r
-  ) \r
-/*++\r
-\r
-Routine Description:\r
-  This function is invoked by the parser when a new IFR\r
-  opcode should be emitted.\r
-  \r
-Arguments:\r
-  OpcodeByte  - the IFR opcode\r
-  LineNum     - the line number from the source file that resulted\r
-                in the opcode being emitted.\r
-\r
-Returns:\r
-  0 always\r
-\r
---*/\r
-{\r
-  UINT32 Count;\r
-\r
-  FlushQueue();\r
-  //\r
-  // Now add this new byte\r
-  //\r
-  mQueuedOpcodeByte       = OpcodeByte;\r
-  mQueuedLineNum          = LineNum;\r
-  mQueuedOpcodeByteValid  = 1;\r
-  return 0;\r
-}\r
-\r
-VOID \r
-VfrOpcodeHandler::AddByte (\r
-  UINT8 ByteVal, \r
-  UINT8 KeyByte\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  This function is invoked by the parser when it determines\r
-  that more raw IFR bytes should be emitted to the output stream.\r
-  Here we just queue them up into an output buffer.\r
-  \r
-Arguments:\r
-  ByteVal   - the raw byte to emit to the output IFR stream\r
-  KeyByte   - a value that can be used for debug. \r
-\r
-Returns:\r
-  None\r
-\r
---*/\r
-{\r
-  //\r
-  // Check for buffer overflow\r
-  //\r
-  if (mQueuedByteCount > MAX_QUEUE_COUNT) {\r
-    Error (PROGRAM_NAME, 0, 0, NULL, "opcode queue overflow");\r
-  } else {\r
-    mQueuedBytes[mQueuedByteCount]    = ByteVal;\r
-    mQueuedKeyBytes[mQueuedByteCount] = KeyByte;\r
-    mQueuedByteCount++;\r
-  }\r
-}\r
-\r
-int \r
-VfrOpcodeHandler::FlushQueue (\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  This function is invoked to flush the internal IFR buffer.\r
-  \r
-Arguments:\r
-  None\r
-\r
-Returns:\r
-  0 always\r
-\r
---*/\r
-{\r
-  UINT32 Count;\r
-  UINT32 EmitNoneOnePair;\r
-\r
-  EmitNoneOnePair = 0;\r
-  //\r
-  // If the secondary varstore was specified, then we have to emit\r
-  // a varstore-select-pair opcode, which only applies to the following\r
-  // statement. \r
-  //\r
-  if (mSecondaryVarStoreIdSet) {\r
-    mSecondaryVarStoreIdSet = 0;\r
-    //\r
-    // If primary and secondary are the same as the current default\r
-    // varstore, then we don't have to do anything.\r
-    // Note that the varstore-select-pair only applies to the following\r
-    // opcode.\r
-    //\r
-    if ((mPrimaryVarStoreId != mSecondaryVarStoreId) || (mPrimaryVarStoreId != mDefaultVarStoreId)) {\r
-      IAddByte (EFI_IFR_VARSTORE_SELECT_PAIR_OP, 'O', mQueuedLineNum);\r
-      IAddByte ((UINT8)sizeof (EFI_IFR_VARSTORE_SELECT_PAIR), 'L', 0);\r
-      IAddByte ((UINT8)mPrimaryVarStoreId, 0, 0);\r
-      IAddByte ((UINT8)(mPrimaryVarStoreId >> 8), 0, 0);\r
-      IAddByte ((UINT8)mSecondaryVarStoreId, 0, 0);\r
-      IAddByte ((UINT8)(mSecondaryVarStoreId >> 8), 0, 0);\r
-    }\r
-  } else if (mPrimaryVarStoreIdSet != 0) {\r
-    mPrimaryVarStoreIdSet = 0;\r
-    if (mDefaultVarStoreId != mPrimaryVarStoreId) {\r
-      //\r
-      // The VFR statement referenced a different variable store \r
-      // than the last one we reported. Insert a new varstore select \r
-      // statement. \r
-      //\r
-      IAddByte (EFI_IFR_VARSTORE_SELECT_OP, 'O', mQueuedLineNum);\r
-      IAddByte ((UINT8)sizeof (EFI_IFR_VARSTORE_SELECT), 'L', 0);\r
-      IAddByte ((UINT8)mPrimaryVarStoreId, 0, 0);\r
-      IAddByte ((UINT8)(mPrimaryVarStoreId >> 8), 0, 0);\r
-      mDefaultVarStoreId = mPrimaryVarStoreId;\r
-    }\r
-  }\r
-  //\r
-  // Likely a new opcode is being added. Since each opcode item in the IFR has \r
-  // a header that specifies the size of the opcode item (which we don't\r
-  // know until we find the next opcode in the VFR), we queue up bytes\r
-  // until we know the size. Then we write them out. So flush the queue\r
-  // now.\r
-  //\r
-  if (mQueuedOpcodeByteValid != 0) {\r
-    // \r
-    // Add the previous opcode byte, the length byte, and the binary\r
-    // data.\r
-    //\r
-    IAddByte (mQueuedOpcodeByte, 'O', mQueuedLineNum);\r
-    IAddByte ((UINT8)(mQueuedByteCount + 2), 'L', 0);\r
-    for (Count = 0; Count < mQueuedByteCount; Count++) {\r
-      IAddByte (mQueuedBytes[Count], mQueuedKeyBytes[Count], 0);          \r
-    }\r
-    mQueuedByteCount = 0;\r
-    mQueuedOpcodeByteValid = 0;\r
-  }    \r
-  return 0;\r
-}\r
-\r
-int \r
-VfrOpcodeHandler::IAddByte (\r
-  UINT8   ByteVal, \r
-  UINT8   KeyByte, \r
-  UINT32  LineNum\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  This internal function is used to add actual IFR bytes to\r
-  the output stream. Most other functions queue up the bytes\r
-  in an internal buffer. Once they come here, there's no\r
-  going back.\r
-\r
-  \r
-Arguments:\r
-  ByteVal   - value to write to output \r
-  KeyByte   - key value tied to the byte -- useful for debug\r
-  LineNum   - line number from source file the byte resulted from\r
-\r
-Returns:\r
-  0 - if successful\r
-  1 - failed due to memory allocation failure\r
-\r
---*/\r
-{\r
-  IFR_BYTE    *NewByte;\r
-  NewByte = (IFR_BYTE *)malloc (sizeof (IFR_BYTE));\r
-  if (NewByte == NULL) {\r
-    return 1;\r
-  }\r
-  memset ((char *)NewByte, 0, sizeof (IFR_BYTE));\r
-  NewByte->OpcodeByte = ByteVal;\r
-  NewByte->KeyByte = KeyByte;\r
-  NewByte->LineNum = LineNum;\r
-  //\r
-  // Add to the list\r
-  //\r
-  if (mIfrBytes == NULL) {\r
-    mIfrBytes = NewByte;\r
-  } else {\r
-    mLastIfrByte->Next = NewByte;\r
-  } \r
-  mLastIfrByte = NewByte;\r
-  mBytesWritten++;\r
-  return 0;\r
-}\r
-\r
-VOID \r
-WriteStandardFileHeader (\r
-  FILE *OutFptr\r
-  ) \r
-/*++\r
-\r
-Routine Description:\r
-  This function is invoked to emit a standard header to an\r
-  output text file.\r
-  \r
-Arguments:\r
-  OutFptr - file to write the header to\r
-\r
-Returns:\r
-  None\r
-\r
---*/\r
-{\r
-  UINT32 TempIndex;\r
-  for (TempIndex = 0; mSourceFileHeader[TempIndex] != NULL; TempIndex++) {\r
-    fprintf (OutFptr, "%s\n", mSourceFileHeader[TempIndex]);\r
-  }\r
-  //\r
-  // Write out the VFR compiler version\r
-  //\r
-  fprintf (OutFptr, "//  VFR compiler version " VFR_COMPILER_VERSION "\n//\n");\r
-}\r
diff --git a/Tools/CodeTools/TianoTools/VfrCompile/VfrServices.h b/Tools/CodeTools/TianoTools/VfrCompile/VfrServices.h
deleted file mode 100644 (file)
index 6b8c560..0000000
+++ /dev/null
@@ -1,227 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2004, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-Module Name:\r
-\r
-  VfrServices.h\r
-\r
-Abstract:\r
-\r
-  Prototypes and defines for routines and classes used by the\r
-  EFI VFR compiler.\r
-  \r
---*/\r
-\r
-#ifndef _VFR_SERVICES_H_\r
-#define _VFR_SERVICES_H_\r
-\r
-class VfrOpcodeHandler\r
-{\r
-public:\r
-  VfrOpcodeHandler (\r
-    VOID\r
-    )\r
-  /*++\r
-\r
-Routine Description:\r
-  Constructor for the VFR opcode handling class.\r
-  \r
-Arguments:\r
-  None\r
-\r
-Returns:\r
-  None\r
-\r
---*/\r
-  ;\r
-  ~VfrOpcodeHandler (\r
-    VOID\r
-    )\r
-  /*++\r
-\r
-Routine Description:\r
-  Destructor for the VFR opcode handler. Free up memory allocated\r
-  while parsing the VFR script.\r
-  \r
-Arguments:\r
-  None\r
-\r
-Returns:\r
-  None\r
-\r
---*/\r
-  ;\r
-  void\r
-  WriteIfrBytes (\r
-    VOID\r
-    )\r
-  /*++\r
-\r
-Routine Description:\r
-  This function is invoked at the end of parsing. Its purpose\r
-  is to write out all the IFR bytes that were queued up while\r
-  parsing.\r
-  \r
-Arguments:\r
-  None\r
-\r
-Returns:\r
-  None\r
-\r
---*/\r
-  ;\r
-  int\r
-  AddOpcodeByte (\r
-    UINT8  OpcodeByte,\r
-    UINT32 LineNum\r
-    )\r
-  /*++\r
-\r
-Routine Description:\r
-  This function is invoked by the parser when a new IFR\r
-  opcode should be emitted.\r
-  \r
-Arguments:\r
-  OpcodeByte  - the IFR opcode\r
-  LineNum     - the line number from the source file that resulted\r
-                in the opcode being emitted.\r
-\r
-Returns:\r
-  0 always\r
-\r
---*/\r
-  ;\r
-  void\r
-  AddByte (\r
-    UINT8 ByteVal,\r
-    UINT8 KeyByte\r
-    )\r
-  /*++\r
-\r
-Routine Description:\r
-  This function is invoked by the parser when it determines\r
-  that more raw IFR bytes should be emitted to the output stream.\r
-  Here we just queue them up into an output buffer.\r
-  \r
-Arguments:\r
-  ByteVal   - the raw byte to emit to the output IFR stream\r
-  KeyByte   - a value that can be used for debug. \r
-\r
-Returns:\r
-  None\r
-\r
---*/\r
-  ;\r
-  void\r
-  SetVarStoreId (\r
-    UINT16 VarStoreId\r
-    )\r
-  /*++\r
-\r
-Routine Description:\r
-  This function is invoked by the parser when a variable is referenced in the \r
-  VFR. Save the variable store (and set a flag) so that we can later determine \r
-  if we need to emit a varstore-select or varstore-select-pair opcode.\r
-  \r
-Arguments:\r
-  VarStoreId - ID of the variable store referenced in the VFR\r
-\r
-Returns:\r
-  None\r
-\r
---*/\r
-  ;\r
-  void\r
-  SetSecondaryVarStoreId (\r
-    UINT16 VarStoreId\r
-    )\r
-  /*++\r
-\r
-Routine Description:\r
-  This function is invoked by the parser when a secondary variable is \r
-  referenced in the VFR. Save the variable store (and set a flag) so \r
-  that we can later determine if we need to emit a varstore-select or \r
-  varstore-pair opcode.\r
-  \r
-Arguments:\r
-  VarStoreId - ID of the variable store referenced in the VFR\r
-\r
-Returns:\r
-  None\r
-\r
---*/\r
-  ;\r
-\r
-/* */\r
-private:\r
-  int\r
-  FlushQueue (\r
-    VOID\r
-    )\r
-  /*++\r
-\r
-Routine Description:\r
-  This function is invoked to flush the internal IFR buffer.\r
-  \r
-Arguments:\r
-  None\r
-\r
-Returns:\r
-  0 always\r
-\r
---*/\r
-  ;\r
-  int\r
-  IAddByte (\r
-    UINT8  ByteVal,\r
-    UINT8  KeyByte,\r
-    UINT32 LineNum\r
-    )\r
-  /*++\r
-\r
-Routine Description:\r
-  This internal function is used to add actual IFR bytes to\r
-  the output stream. Most other functions queue up the bytes\r
-  in an internal buffer. Once they come here, there's no\r
-  going back.\r
-\r
-  \r
-Arguments:\r
-  ByteVal   - value to write to output \r
-  KeyByte   - key value tied to the byte -- useful for debug\r
-  LineNum   - line number from source file the byte resulted from\r
-\r
-Returns:\r
-  0 - if successful\r
-  1 - failed due to memory allocation failure\r
-\r
---*/\r
-  ;\r
-\r
-/* */\r
-private:\r
-  IFR_BYTE  *mIfrBytes;\r
-  IFR_BYTE  *mLastIfrByte;\r
-  UINT32    mQueuedByteCount;\r
-  UINT32    mBytesWritten;\r
-  UINT32    mQueuedLineNum;\r
-  UINT8     mQueuedBytes[MAX_QUEUE_COUNT];\r
-  UINT8     mQueuedKeyBytes[MAX_QUEUE_COUNT];\r
-  UINT8     mQueuedOpcodeByte;\r
-  UINT32    mQueuedOpcodeByteValid;\r
-  UINT16    mPrimaryVarStoreId;\r
-  UINT8     mPrimaryVarStoreIdSet;\r
-  UINT16    mSecondaryVarStoreId;\r
-  UINT8     mSecondaryVarStoreIdSet;\r
-  UINT16    mDefaultVarStoreId;\r
-};\r
-\r
-#endif // #ifndef _VFR_SERVICES_H_\r
diff --git a/Tools/CodeTools/TianoTools/VfrCompile/build.xml b/Tools/CodeTools/TianoTools/VfrCompile/build.xml
deleted file mode 100644 (file)
index 247f0d2..0000000
+++ /dev/null
@@ -1,123 +0,0 @@
-<?xml version="1.0" ?>\r
-<!--\r
-Copyright (c) 2006, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
--->\r
-<project default="GenTool" basedir="." name="VfrCompile">\r
-<!--\r
-    EDK VfrCompile Tool\r
-  Copyright (c) 2006, Intel Corporation\r
--->\r
-  <property name="ToolName" value="VfrCompile"/>\r
-  <property name="FileSet" value="*.cpp"/>\r
-  <property name="FileSetPccts" value="ATokenBuffer.cpp DLexerBase.cpp AParser.cpp"/>\r
-  <taskdef resource="cpptasks.tasks"/>\r
-  <typedef resource="cpptasks.types"/>\r
-  <taskdef resource="net/sf/antcontrib/antlib.xml"/>\r
-\r
-  <property name="LINK_OUTPUT_TYPE" value="static"/>\r
-  <property name="BUILD_DIR" value="${PACKAGE_DIR}/${ToolName}/tmp"/>\r
-\r
-  <target name="GenTool" depends="init, Antlr, Dlg, Tool">\r
-    <echo message="The EDK Tool: ${ToolName} build has completed"/>\r
-  </target>\r
-\r
-  <target name="init">\r
-\r
-    <echo message="Building the EDK Tool: ${ToolName}"/>\r
-    <mkdir dir="${BUILD_DIR}"/>\r
-\r
-    <condition property="AntlrDepends">\r
-      <uptodate targetfile="${PACKAGE_DIR}/VfrCompile/parser.dlg" srcfile="${PACKAGE_DIR}/VfrCompile/VfrCompile.g" value="true"/>\r
-    </condition>\r
-\r
-    <condition property="DlgDepends">\r
-      <uptodate targetfile="${PACKAGE_DIR}/VfrCompile/DLGLexer.cpp" srcfile="${PACKAGE_DIR}/VfrCompile/parser.dlg" value="true"/>\r
-    </condition>\r
-\r
-    <condition property="CheckDepends">\r
-      <or>\r
-        <isset property="AntlrDepends"/>\r
-        <isset property="DlgDepends"/>\r
-      </or>\r
-    </condition>\r
-\r
-    <condition property="gxx_extra_libs" value="stdc++ System gcc_s.10.4 gcc">\r
-      <os family="mac"/>\r
-    </condition>\r
-    \r
-    <condition property="gxx_extra_libs" value="stdc++">\r
-      <os name="linux"/>\r
-    </condition>\r
-    \r
-    <condition property="gxx_extra_libs" value="stdc++">\r
-      <os family="windows"/>\r
-    </condition>\r
-    \r
-  </target>\r
-\r
-  <target name="Antlr" depends="init" unless="AntlrDepends">\r
-    <echo message="Executing ANTLR"/>\r
-    <exec dir="${basedir}/${ToolName}" executable="${env.FRAMEWORK_TOOLS_PATH}/antlr" failonerror="TRUE">\r
-      <arg line="-CC -e3 -ck 3 -o . VfrCompile.g"/>\r
-    </exec>\r
-  </target>\r
-\r
-  <target name="Dlg" depends="Antlr" unless="DlgDepends">\r
-    <echo message="Executing DLG"/>\r
-    <exec dir="${basedir}/${ToolName}" executable="${env.FRAMEWORK_TOOLS_PATH}/dlg" failonerror="TRUE">\r
-      <arg line="-C2 -i -CC -o . parser.dlg"/>\r
-    </exec>\r
-  </target>\r
-\r
-  <target name="Tool" depends="init">\r
-    <cc name="${ToolChain}" objdir="${BUILD_DIR}" \r
-        outfile="${BIN_DIR}/${ToolName}"\r
-        outtype="executable"\r
-        debug="true"\r
-        optimize="speed">\r
-\r
-      <fileset dir="${basedir}/${ToolName}" \r
-        includes="${FileSet}" />\r
-\r
-      <fileset dir="${basedir}/Pccts/h" \r
-        includes="${FileSetPccts}" />\r
-\r
-      <includepath path="${PACKAGE_DIR}/Pccts/h"/>\r
-      <includepath path="${PACKAGE_DIR}/Include"/>\r
-      <includepath path="${PACKAGE_DIR}/Include/${HostArch}"/>\r
-      <includepath path="${PACKAGE_DIR}/Common"/>\r
-      <libset dir="${LIB_DIR}" libs="CommonTools"/>\r
-      <syslibset libs="${gxx_extra_libs}" if="gcc"/>\r
-    </cc>\r
-  </target>\r
-\r
-  <target name="clean">\r
-    <echo message="Removing Intermediate Files Only"/>\r
-    <delete>\r
-      <fileset dir="${BUILD_DIR}" includes="*.obj"/>\r
-    </delete>\r
-  </target>\r
-\r
-  <target name="cleanall">\r
-    <echo message="Removing Object Files and the Executable: ${ToolName}${ext_exe}"/>\r
-    <delete failonerror="false" quiet="true" includeEmptyDirs="true">\r
-      <fileset dir="${BUILD_DIR}"/>\r
-      <fileset file="${basedir}/${ToolName}/DLGLexer.cpp"/>\r
-      <fileset file="${basedir}/${ToolName}/DLGLexer.h"/>\r
-      <fileset file="${basedir}/${ToolName}/EfiVfrParser.cpp"/>\r
-      <fileset file="${basedir}/${ToolName}/EfiVfrParser.h"/>\r
-      <fileset file="${basedir}/${ToolName}/parser.dlg"/>\r
-      <fileset file="${basedir}/${ToolName}/tokens.h"/>\r
-      <fileset file="${basedir}/${ToolName}/VfrCompile.cpp"/>\r
-      <fileset file="${BIN_DIR}/${ToolName}${ext_exe}"/>\r
-    </delete>\r
-  </target>\r
-\r
-</project>\r
diff --git a/Tools/CodeTools/TianoTools/ZeroDebugData/ZeroDebugData.c b/Tools/CodeTools/TianoTools/ZeroDebugData/ZeroDebugData.c
deleted file mode 100644 (file)
index caf129b..0000000
+++ /dev/null
@@ -1,391 +0,0 @@
-/*++\r
-\r
-Copyright (c)  2004-2006 Intel Corporation. All rights reserved\r
-This program and the accompanying materials are licensed and made available\r
-under the terms and conditions of the BSD License which accompanies this\r
-distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-\r
-Module Name:\r
-\r
-  ZeroDebugData.c\r
-\r
-Abstract:\r
-\r
-  Zero the Debug Data Fields of Portable Executable (PE) format file.\r
-\r
---*/\r
-\r
-#include <stdio.h>\r
-#include <string.h>\r
-#include <stdlib.h>\r
-\r
-void\r
-PrintUsage (\r
-  void\r
-  )\r
-/*++\r
-Routine Description:\r
-  print usage of ZeroDebugData command\r
-\r
-Arguments:\r
-  None\r
-\r
-Returns:\r
-  None\r
---*/\r
-// GC_TODO:    void - add argument and description to function comment\r
-{\r
-  //\r
-  // print usage of command\r
-  //\r
-  printf ("\nUsage: ZeroDebugData <PE-File> [DebugData-File]\n");\r
-}\r
-\r
-int\r
-ReadFromFile (\r
-  FILE      *fp,\r
-  long      offset,\r
-  void      *buffer,\r
-  int       size\r
-  )\r
-/*++\r
-Routine Description:\r
-  read data from a specified location of file\r
-\r
-Arguments:\r
-  fp              - file pointer\r
-  offset          - number of bytes from beginning of file\r
-  buffer          - buffer used to store data\r
-  size            - size of buffer\r
-\r
-Returns:\r
-  =  0            - Success\r
-  = -1            - Failed\r
---*/\r
-{\r
-  //\r
-  // set file pointer to the specified location of file\r
-  //\r
-  if (fseek (fp, offset, SEEK_SET) != 0) {\r
-    printf ("Error: Cannot move the current location of the file.\n");\r
-    return -1;\r
-  }\r
-  //\r
-  // read data from the file\r
-  //\r
-  if (fread (buffer, size, 1, fp) != 1) {\r
-    printf ("Error: Cannot read data from the file.\n");\r
-    return -1;\r
-  }\r
-\r
-  return 0;\r
-}\r
-\r
-int\r
-ZeroDebugData (\r
-  FILE      *fp,\r
-  FILE      *fpData\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Zero the debug data fields of the file\r
-\r
-Arguments:\r
-\r
-  fp              - file pointer\r
-  fpData          - pointer to output file that ZeroDebugData progress is written to\r
-\r
-Returns:\r
-\r
-  =  0            - Success\r
-  = -1            - Failed\r
-\r
---*/\r
-{\r
-  unsigned char header[4];\r
-  unsigned long offset;\r
-  unsigned long NumberOfRvaAndSizes;\r
-  unsigned int  nvalue;\r
-  unsigned long lvalue;\r
-  unsigned long Size;\r
-  unsigned long Pointer;\r
-  unsigned char *Buffer;\r
-  unsigned long Index;\r
-\r
-  //\r
-  // read the header of file\r
-  //\r
-  if (ReadFromFile (fp, 0, header, 2) != 0) {\r
-    printf ("Error: open image file\n");\r
-    return -1;\r
-  }\r
-  //\r
-  // "MZ" -- the header of image file (PE)\r
-  //\r
-  if (strncmp ((char *) header, "MZ", 2) != 0) {\r
-    printf ("Error: Invalid Image file.\n");\r
-    return -1;\r
-  }\r
-  //\r
-  // At location 0x3C, the stub has the file offset to the\r
-  // PE signature.\r
-  //\r
-  if (ReadFromFile (fp, 0x3C, &offset, 4) != 0) {\r
-    return -1;\r
-  }\r
-  //\r
-  // read the header of optional\r
-  //\r
-  if (ReadFromFile (fp, offset, header, 4) != 0) {\r
-    return -1;\r
-  }\r
-  //\r
-  // "PE\0\0" -- the signature of optional header\r
-  //\r
-  if (strncmp ((char *) header, "PE\0\0", 4) != 0) {\r
-    printf ("Error: Invalid PE format file.\n");\r
-    return -1;\r
-  }\r
-  //\r
-  // Add 16 to skip COFF file header, and get to optional header.\r
-  //\r
-  offset += 24;\r
-\r
-  //\r
-  // Check the magic field, 0x10B for PE32 and 0x20B for PE32+\r
-  //\r
-  if (ReadFromFile (fp, offset, &nvalue, 2) != 0) {\r
-    return -1;\r
-  }\r
-  //\r
-  // If this is PE32 image file, offset of NumberOfRvaAndSizes is 92.\r
-  // Else it is 108.\r
-  //\r
-  switch (nvalue & 0xFFFF) {\r
-  case 0x10B:\r
-    offset += 92;\r
-    printf ("Info: Image is PE32. ");\r
-    break;\r
-\r
-  case 0x20B:\r
-    offset += 108;\r
-    printf ("Info: Image is PE32+. ");\r
-    break;\r
-\r
-  default:\r
-    printf ("Error: Magic value is unknown.\n");\r
-    return -1;\r
-  }\r
-  //\r
-  // get the value of NumberOfRvaAndSizes\r
-  //\r
-  if (ReadFromFile (fp, offset, &NumberOfRvaAndSizes, 4) != 0) {\r
-    printf ("Error: read NumberOfRvaAndSizes error.\n");\r
-    return -1;\r
-  }\r
-  //\r
-  // printf ("Info: NumberOfRvaAndSizes = %d\n", NumberOfRvaAndSizes);\r
-  //\r
-  //\r
-  // Finding Debug Table, offset of Debug Table\r
-  // is 4 + 6 * 8 = 52.\r
-  //\r
-  if (NumberOfRvaAndSizes >= 7) {\r
-    if (ReadFromFile (fp, offset + 52, &lvalue, 4) != 0) {\r
-      return -1;\r
-    }\r
-    //\r
-    // Read the SizeOfData(16) and PointerToRawData(24)\r
-    //\r
-    if (ReadFromFile (fp, lvalue + 16, &Size, 4) != 0) {\r
-      printf ("error: Size = %d\n", Size);\r
-      return -1;\r
-    }\r
-\r
-    printf ("Debug data: size = %xh, ", Size);\r
-    fprintf (fpData, "Debug data: size = %xh, ", Size);\r
-\r
-    if (ReadFromFile (fp, lvalue + 20, &Pointer, 4) != 0) {\r
-      printf ("error: LoadOffset = %xh\n", Pointer);\r
-      return -1;\r
-    }\r
-    //\r
-    // printf ("LoadOffset = %xh, ", Pointer);\r
-    //\r
-    fprintf (fpData, "LoadOffset = %xh, ", Pointer);\r
-\r
-    if (ReadFromFile (fp, lvalue + 24, &Pointer, 4) != 0) {\r
-      printf ("error: FileOffset = %xh\n", Pointer);\r
-      return -1;\r
-    }\r
-\r
-    printf ("FileOffset = %xh, ", Pointer);\r
-    fprintf (fpData, "FileOffset = %xh, \n", Pointer);\r
-\r
-    if ((lvalue != 0) && (Pointer != 0)) {\r
-      //\r
-      // prepare buffer\r
-      //\r
-      Buffer = malloc (Size + 1);\r
-      if (Buffer == NULL) {\r
-        printf ("Error: Cannot allocate memory.\n");\r
-        return -1;\r
-      }\r
-      //\r
-      // set file pointer to the specified location of file\r
-      //\r
-      if (fseek (fp, Pointer, SEEK_SET) != 0) {\r
-        printf ("Error: Cannot move the current location of the file.\n");\r
-        free (Buffer);\r
-        return -1;\r
-      }\r
-      //\r
-      // read data from PE file\r
-      //\r
-      if (fread (Buffer, Size, 1, fp) != 1) {\r
-        printf ("Error: Cannot read data from the file.\n");\r
-        free (Buffer);\r
-        return -1;\r
-      }\r
-      //\r
-      // write to data file\r
-      //\r
-      for (Index = 0; Index < Size;) {\r
-        fprintf (fpData, "%02x ", Buffer[Index]);\r
-\r
-        Index++;\r
-        if (Index % 8 == 0) {\r
-          fprintf (fpData, "\n");\r
-        }\r
-      }\r
-\r
-      fprintf (fpData, "\n");\r
-\r
-      //\r
-      // zero buffer and write back to PE file\r
-      //\r
-      if (fseek (fp, Pointer, SEEK_SET) != 0) {\r
-        printf ("Error: Cannot move the current location of the file.\n");\r
-        free (Buffer);\r
-        return -1;\r
-      }\r
-\r
-      memset (Buffer, 0, Size);\r
-      if (fwrite (Buffer, Size, 1, fp) != 1) {\r
-        perror ("Error: Cannot write zero to the file.\n");\r
-        free (Buffer);\r
-        return -1;\r
-      }\r
-      //\r
-      // set file pointer to the specified location of file\r
-      //\r
-      if (fseek (fp, lvalue + 4, SEEK_SET) != 0) {\r
-        printf ("Error: Cannot move the current location of the file.\n");\r
-        free (Buffer);\r
-        return -1;\r
-      }\r
-\r
-      if (fwrite (Buffer, 4, 1, fp) != 1) {\r
-        perror ("Error: Cannot write zero to the file.\n");\r
-        free (Buffer);\r
-        return -1;\r
-      }\r
-\r
-      free (Buffer);\r
-    }\r
-  }\r
-\r
-  return 0;\r
-}\r
-\r
-int\r
-main (\r
-  int       argc,\r
-  char      *argv[]\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Prints the zero debug data of the PE file to the DebugData file.\r
-  Executes the ZeroDebugData function.\r
-\r
-Arguments:\r
-\r
-  argc   - Standard C argument, number of command line arguments.\r
-  argv[] - Standard C argument, array of pointers to the input files,\r
-           such as the PE and DebugData files.\r
-\r
-Returns:\r
-\r
-  zero    - success\r
-  nonzero - failure\r
-\r
---*/\r
-{\r
-  FILE  *fp;\r
-  FILE  *fpData;\r
-  char  DataFile[1024] = "";\r
-\r
-  //\r
-  // check the number of parameters\r
-  //\r
-  if (argc < 2) {\r
-    printf ("\nUsage: ZeroDebugData <PE-File> [DebugData-File]\n");\r
-    return -1;\r
-  }\r
-  //\r
-  // open the DebugData file, if not exists, return\r
-  //\r
-  if (argc >= 3) {\r
-    strcpy (DataFile, argv[2]);\r
-  } else {\r
-    strcpy (DataFile, "DebugData.dat");\r
-  }\r
-\r
-  fpData = fopen (DataFile, "a+");\r
-  if (fpData == NULL) {\r
-    fpData = fopen (DataFile, "w");\r
-    if (fpData == NULL) {\r
-      printf ("Error: Cannot open the data file!\n");\r
-      return -1;\r
-    }\r
-  }\r
-  //\r
-  // open the PE file\r
-  //\r
-  fp = fopen (argv[1], "r+b");\r
-  if (fp == NULL) {\r
-    printf ("Error: Cannot open the PE file!\n");\r
-    return -1;\r
-  }\r
-  //\r
-  // Zero the Debug Data to the PE file\r
-  //\r
-  printf ("Zero Debug Data to file %s:\n", argv[1]);\r
-  fprintf (fpData, "\nZero Debug Data to file %s:\n", argv[1]);\r
-  if ((int *) ZeroDebugData (fp, fpData) != 0) {\r
-    printf ("Error: Zero Debug Data PE file\n");\r
-    fclose (fp);\r
-    return -1;\r
-  }\r
-\r
-  printf (" success\n");\r
-\r
-  //\r
-  // close the PE file\r
-  //\r
-  fflush (fpData);\r
-  fflush (fp);\r
-  fclose (fpData);\r
-  fclose (fp);\r
-\r
-  return 0;\r
-}\r
diff --git a/Tools/CodeTools/TianoTools/ZeroDebugData/build.xml b/Tools/CodeTools/TianoTools/ZeroDebugData/build.xml
deleted file mode 100644 (file)
index 2a85fc1..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-<?xml version="1.0" ?>\r
-<!--\r
-Copyright (c) 2006, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
--->\r
-<project default="GenTool" basedir=".">\r
-<!--\r
-    EDK ZeroDebugData Tool\r
-  Copyright (c) 2006, Intel Corporation\r
--->\r
-  <property name="ToolName" value="ZeroDebugData"/>\r
-  <property name="FileSet" value="*.c"/>\r
-\r
-  <taskdef resource="cpptasks.tasks"/>\r
-  <typedef resource="cpptasks.types"/>\r
-  <taskdef resource="net/sf/antcontrib/antlib.xml"/>\r
-\r
-  <property name="LINK_OUTPUT_TYPE" value="static"/>\r
-  <property name="BUILD_DIR" value="${PACKAGE_DIR}/${ToolName}/tmp"/>\r
-\r
-  <target name="GenTool" depends="init, Tool">\r
-    <echo message="The EDK Tool: ${ToolName} build  has completed"/>\r
-  </target>\r
-\r
-  <target name="init">\r
-    <echo message="Building the EDK Tool: ${ToolName}"/>\r
-    <mkdir dir="${BUILD_DIR}"/>\r
-  </target>\r
-\r
-  <target name="Tool" depends="init">\r
-    <cc name="${ToolChain}" objdir="${BUILD_DIR}" \r
-        outfile="${BIN_DIR}/${ToolName}"\r
-        outtype="executable"\r
-        optimize="speed" \r
-        debug="true">\r
-\r
-      <fileset dir="${basedir}/${ToolName}" \r
-        includes="${FileSet}" \r
-        defaultexcludes="TRUE" \r
-        excludes="*.xml *.inf"/>\r
-\r
-      <includepath path="${PACKAGE_DIR}/Include"/>\r
-      <includepath path="${PACKAGE_DIR}/Include/${HostArch}"/>\r
-      <includepath path="${PACKAGE_DIR}/Common"/>\r
-    </cc>\r
-  </target>\r
-\r
-  <target name="clean">\r
-    <echo message="Removing Intermediate Files Only"/>  \r
-    <delete failonerror="false" quiet="true" includeEmptyDirs="true">\r
-      <fileset dir="${BUILD_DIR}"/>\r
-    </delete>\r
-  </target>\r
-\r
-  <target name="cleanall">\r
-    <echo message="Removing Object Files and the Executable: ${ToolName}${ext_exe}"/>  \r
-    <delete failonerror="false" quiet="true" includeEmptyDirs="true">\r
-      <fileset dir="${BUILD_DIR}"/>\r
-      <fileset file="${BIN_DIR}/${ToolName}${ext_exe}"/>\r
-    </delete>\r
-  </target>\r
-\r
-</project>\r
diff --git a/Tools/CodeTools/TianoTools/build.xml b/Tools/CodeTools/TianoTools/build.xml
deleted file mode 100644 (file)
index 3d59c9c..0000000
+++ /dev/null
@@ -1,269 +0,0 @@
-<?xml version="1.0" encoding="utf-8" ?> \r
-<!--\r
-Copyright (c) 2006, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
--->\r
-<project default="all" basedir="." name="C_Code">\r
-<!-- Copyright (c) 2006, Intel Corporation -->\r
-<!-- Filename: Tools/Source/build.xml -->\r
-\r
-  <taskdef resource="net/sf/antcontrib/antlib.xml"/>\r
-\r
-  <property name="ReallyVerbose" value="false"/>\r
-  <property environment="env" />\r
-\r
-  <property name="WORKSPACE" value="${env.WORKSPACE}" />\r
-  <property name="WORKSPACE_DIR" value="${WORKSPACE}" />\r
-  <property name="PACKAGE" value="Tools" />\r
-  <property name="PACKAGE_DIR" value="${WORKSPACE}/Tools/Source/TianoTools" />\r
-  <property name="LIB_DIR" value="${PACKAGE_DIR}/Library" />\r
-  <property name="BIN_DIR" value="${WORKSPACE}/Tools/bin" />\r
-  <property name="BUILD_MODE" value="PACKAGE" />\r
-  <property name="Libs" \r
-    value="Common/build.xml CustomizedCompress/build.xml PeCoffLoader/build.xml String/build.xml"/>\r
-\r
-  <import file="${WORKSPACE_DIR}/Tools/Conf/BuildMacro.xml" />\r
-\r
-  <path id="classpath">\r
-    <fileset dir="${WORKSPACE}/Tools/Jars" includes="*.jar"/>\r
-    <fileset dir="${env.XMLBEANS_HOME}/lib" includes="*.jar"/>\r
-  </path>\r
-\r
-  <taskdef classpathref="classpath" resource="GenBuild.tasks" />\r
-  <taskdef classpathref="classpath" resource="net/sf/antcontrib/antlib.xml" />\r
-\r
-  <taskdef classpathref="classpath" resource="cpptasks.tasks"/>\r
-  <typedef classpathref="classpath" resource="cpptasks.types"/>\r
-\r
-  <target name="all" depends="init, Tools">\r
-    <echo message="The EDK II C Tools build complete!"/>\r
-  </target>\r
-  \r
-  <target name="init">\r
-    <echo message="EDK C Code Tools, build initialization"/>\r
-    <mkdir dir="${BIN_DIR}" />\r
-    <mkdir dir="${LIB_DIR}" />\r
-\r
-    <condition property="HostArch" value="X64">\r
-      <os arch="amd64"/>\r
-    </condition>\r
-    <condition property="HostArch" value="Ia32">\r
-      <or>\r
-        <os arch="x86"/>\r
-        <os arch="i386"/>\r
-      </or>\r
-    </condition>\r
-    <condition property="HostArch" value="Ia32">\r
-      <os arch="i386"/>\r
-    </condition> \r
-\r
-    <if>\r
-      <os family="unix" />\r
-      <then>\r
-        <echo message="OS Family UNIX, ${HostArch}" />\r
-      </then>\r
-      <elseif>\r
-        <os family="dos" />\r
-        <then>\r
-          <echo message="OS Family DOS, ${HostArch}" />\r
-        </then>\r
-      </elseif>\r
-      <elseif>\r
-        <os family="mac" />\r
-        <then>\r
-          <echo message="OS Family OS X, ${HostArch}" />\r
-        </then>\r
-      </elseif>\r
-      <else>\r
-        <fail message="OS Family Unsupported, ${HostArch}" />\r
-      </else>\r
-    </if>\r
-\r
-    <if>\r
-      <not>\r
-        <isset property="ToolChain" />\r
-      </not>\r
-      <then>\r
-        <if>\r
-          <isset property="env.TOOL_CHAIN" />\r
-          <then>\r
-            <property name="ToolChain" value="${env.TOOL_CHAIN}"/>\r
-          </then>\r
-          <else>\r
-            <!-- Default Tool Chain is Microsoft Visual Studio -->\r
-            <property name="ToolChain" value="msvc"/>\r
-          </else>\r
-        </if>\r
-      </then>\r
-    </if>\r
-    \r
-    <if>\r
-      <equals arg1="${ToolChain}" arg2="gcc" />\r
-      <then>\r
-        <exec executable="gcc" outputproperty="host.gcc.ver">\r
-          <arg line="-E" />\r
-          <arg line="-P" />\r
-          <arg line="-x c" />\r
-          <arg line="gcc.ver" />\r
-        </exec>\r
-        <if>\r
-          <contains string="${host.gcc.ver}" substring="4" />\r
-          <then>\r
-            <property name="ExtraArgus" value="-Wno-pointer-sign" />\r
-          </then>\r
-        </if>\r
-      </then>\r
-    </if>\r
-\r
-    <condition property="linux" value="true">\r
-      <os name="Linux"/>\r
-    </condition>\r
-    \r
-    <condition property="intel_win">\r
-      <and>\r
-        <os family="dos"/>\r
-        <equals arg1="${ToolChain}" arg2="intel"/>\r
-      </and>\r
-    </condition>\r
-    \r
-    <condition property="intel_linux">\r
-      <and>\r
-        <os name="Linux"/>\r
-        <equals arg1="${ToolChain}" arg2="intel"/>\r
-      </and>\r
-    </condition>\r
-    \r
-    <condition property="intel_mac">\r
-      <and>\r
-        <os family="mac"/>\r
-        <equals arg1="${ToolChain}" arg2="intel"/>\r
-      </and>\r
-    </condition>\r
-    \r
-    <condition property="gcc">\r
-      <and>\r
-        <equals arg1="${ToolChain}" arg2="gcc"/>\r
-      </and>\r
-    </condition>\r
-\r
-    <condition property="cygwin">\r
-      <and>\r
-        <os family="dos"/>\r
-        <equals arg1="${ToolChain}" arg2="gcc"/>\r
-      </and>\r
-    </condition>\r
-    \r
-    <condition property="x86_64_linux">\r
-      <and>\r
-        <os name="Linux"/>\r
-        <equals arg1="${HostArch}" arg2="X64"/>\r
-      </and>\r
-    </condition>\r
-    \r
-    <condition property="windows" value="true">\r
-      <os family="Windows"/>\r
-    </condition>\r
-    \r
-    <condition property="OSX" value="true">\r
-      <os family="Mac"/>\r
-    </condition>\r
-\r
-    <condition property="cyglinux">\r
-      <or>\r
-        <istrue value="${linux}"/>\r
-        <istrue value="${cygwin}"/>\r
-      </or>\r
-    </condition>\r
-\r
-    <!-- msft is a family, used by both Microsoft and Intel Windows compiler tool chains -->\r
-    <condition property="msft">\r
-      <isfalse value="${gcc}"/>\r
-    </condition>\r
-\r
-    <if>\r
-      <istrue value="${ReallyVerbose}"/>\r
-      <then>\r
-        <echo message="Test property msvc:         ${msvc}"/> \r
-        <echo message="Test property gcc:          ${gcc}"/> \r
-        <echo message="Test property intel_win:    ${intel_win}"/> \r
-        <echo message="Test property intel_linux:  ${intel_linux}"/> \r
-        <echo message="Test property intel_mac:    ${intel_mac}"/> \r
-        <echo message="Test property msft:         ${msft}"/> \r
-        <echo message="Test property cygwin:       ${cygwin}"/> \r
-        <echo message="Test property cyglinux:     ${cyglinux}"/> \r
-        <echo message="Test property windows:      ${windows}"/> \r
-        <echo message="Test property linux:        ${linux}"/> \r
-        <echo message="Test property OSX:          ${OSX}"/> \r
-        <echo message="Test property x86_64_linux: ${x86_64_linux}"/> \r
-       </then>\r
-    </if>\r
-\r
-    <property name="haveLibtool" value="false"/>\r
-    <if>\r
-      <and>\r
-        <not>\r
-          <isset property="env.CYGWIN_HOME"/>\r
-        </not>\r
-          <isset property="cygwin"/>\r
-      </and>\r
-      <then>\r
-        <fail message="You must set the environment variable: CYGWIN_HOME"/>\r
-      </then>\r
-    </if>\r
-\r
-    <if>\r
-        <istrue value="${gcc}"/>\r
-      <then>\r
-        <property name="ext_static" value=".a"/>\r
-        <property name="ext_dynamic" value=".so"/>\r
-        <if>\r
-          <istrue value="${cygwin}"/>\r
-          <then>\r
-            <property name="ext_exe" value=".exe"/>\r
-          </then>\r
-          <else>\r
-            <property name="ext_exe" value=""/>\r
-          </else>\r
-        </if>\r
-      </then>\r
-      <else>\r
-        <property name="ext_static" value=".lib"/>\r
-        <property name="ext_dynamic" value=".dll"/>\r
-        <property name="ext_exe" value=".exe"/>\r
-      </else>\r
-    </if>\r
-  </target>\r
-\r
-  <target name="Libraries" depends="init">\r
-    <subant target="" inheritall="true">\r
-      <fileset dir="${PACKAGE_DIR}" \r
-        includes="${Libs}"/>\r
-    </subant>\r
-  </target>\r
-\r
-  <target name="Tools" depends="Libraries">\r
-    <subant target="" inheritall="true">\r
-      <fileset dir="${PACKAGE_DIR}" includes="*/build.xml"\r
-        excludes="${Libs}"/>\r
-    </subant>\r
-  </target>\r
-\r
-  <target name="clean" depends="init">\r
-    <subant target="clean" inheritall="true">\r
-      <fileset dir="${PACKAGE_DIR}" includes="*/build.xml"/>\r
-    </subant>\r
-  </target>\r
-\r
-  <target name="cleanall" depends="init">\r
-    <subant target="cleanall" inheritall="true">\r
-      <fileset dir="${PACKAGE_DIR}" includes="*/build.xml"/>\r
-    </subant>\r
-    <delete dir="${LIB_DIR}"/>\r
-  </target>\r
-</project>\r
index 5b194667e45787757d2748442ad01dbd91813c46..59f027a7155c53f2a847d839af61340ab1c678a6 100644 (file)
@@ -22,7 +22,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
     <subant target="" inheritall="false">\r
       <filelist dir="."\r
         files="\r
-          Source/TianoTools/build.xml\r
+          CTools/Source/build.xml\r
           "/>\r
     </subant>\r
   </target>\r
@@ -124,7 +124,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
           Java/Source/PcdTools/build.xml \r
           Java/Source/Common/build.xml \r
           Java/Source/SurfaceArea/build.xml \r
-          Source/TianoTools/build.xml\r
+          CCode/Source/build.xml\r
           Java/Source/MigrationTools/build.xml\r
           Java/Source/ContextTool/build.xml\r
           Java/Source/Merge/build.xml\r
@@ -158,7 +158,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
           Java/Source/PcdTools/build.xml \r
           Java/Source/Common/build.xml \r
           Java/Source/SurfaceArea/build.xml \r
-          Source/TianoTools/build.xml\r
+          CCode/Source/build.xml\r
           Java/Source/MigrationTools/build.xml\r
           Java/Source/ContextTool/build.xml\r
           Java/Source/Merge/build.xml\r